local AceGUI = LibStub("AceGUI-3.0")

-- Ensure SharedMedia is loaded
local LSM = LibStub("LibSharedMedia-3.0")

-- Function to show the change log
Critmatic.showChangeLog = function()
    -- Create a container frame
    local frame = AceGUI:Create("Frame")
    frame:SetTitle("CritMatic - Change Log")
    frame:SetStatusText("Need Help? Copy the Discord Link in General Options. ")
    frame:SetLayout("Fill")
    frame:SetWidth(600)
    frame:SetHeight(500)

    local backgroundTexture = LSM:Fetch("background", Critmatic.db.profile.changeLogPopUp.borderAndBackgroundSettings.backgroundTexture)
    frame.frame:SetBackdrop({
        bgFile = backgroundTexture,
        edgeFile = LSM:Fetch("border", Critmatic.db.profile.changeLogPopUp.borderAndBackgroundSettings.borderTexture),
        edgeSize = Critmatic.db.profile.changeLogPopUp.borderAndBackgroundSettings.borderSize,
    })

    -- Create a scroll container
    local scrollContainer = AceGUI:Create("SimpleGroup")
    scrollContainer:SetFullWidth(true)
    scrollContainer:SetFullHeight(true)
    scrollContainer:SetLayout("Fill")
    frame:AddChild(scrollContainer)

    -- Create a ScrollFrame
    local scroll = AceGUI:Create("ScrollFrame")
    scroll:SetLayout("List")
    scrollContainer:AddChild(scroll)

    -- Add the change log text
    local changelog = [[

[v6.2.1-release] - 05/15/2026

 Fixed:

 Locale parity for the new Follow on X row. v6.2.0 shipped with English-only fallbacks; this release translates options_x_link and options_x_link_desc into all eleven supported locales (deDE, enUS, esES, esMX, frFR, itIT, koKR, ptBR, ruRU, zhCN, zhTW). No behavior changes; the URL is the same everywhere.


[v6.2.0-release] - 05/15/2026

 Added:

 Follow on X link added to the Support / By section of General Options. New 24x24 X icon plus a full-width copyable input field pre-filled with https://x.com/infiniteloopalc. Click the field, Ctrl+A / Cmd+A, copy, paste into a browser. Mirrors the Buy Me A Coffee row directly above it.


[v6.1.0-release] - 05/10/2026

 Changed:

 TOC Interface line refreshed for every live Classic WoW client. Multi-flavor list is now 50503, 40402, 38001, 20505, 11508 covering MoP Classic 5.5.3, Cataclysm, Wrath / Titan Reforged 3.8.1, TBC Anniversary 2.5.5, and Classic Era 1.15.8. Per-flavor packager keys updated to match: Interface-Mists 50503, Interface-Cata 40402, Interface-Wrath 38001, Interface-BCC 20505, Interface-Classic 11508. The bogus Interface-Titan key was dropped.

 Removed:

 Retail / Mainline support dropped this release. Patch 12.0 ("Midnight") blocks unprivileged addons from registering COMBAT_LOG_EVENT_UNFILTERED, which is what CritMatic uses to record crits. Without CLEU there is no addon. Shipping a retail-listed CritMatic that can't perform its core function would just mislead users, so retail is intentionally untargeted until Blizzard relaxes the restriction. Classic flavors unaffected.


For the full version history see CHANGE_LOG.md on GitHub or CurseForge.

]]

    local r, g, b = unpack(Critmatic.db.profile.changeLogPopUp.fontSettings.fontColor)
    -- Fetch the custom font from SharedMedia
    local customFont = LSM:Fetch("font", Critmatic.db.profile.changeLogPopUp.fontSettings.font)
    local logLabel = AceGUI:Create("Label")
    logLabel:SetText(changelog)
    logLabel:SetFullWidth(true)

    logLabel:SetFont(customFont, Critmatic.db.profile.changeLogPopUp.fontSettings.fontSize, Critmatic.db.profile.changeLogPopUp.fontSettings.fontOutline)
    logLabel:SetColor(r, g, b)

    scroll:AddChild(logLabel)

end

