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 = [[

[v5.5.10-release] - 05/08/2026

 Added:

 Buy Me A Coffee link in General settings (optional, copy-only). The General tab now has a Support group with Discord + BMAC, plus a By group showing the author.

 Changed:

 General tab reorganized into Support and By groups. Toggles above are unchanged.

 Localization parity restored across all 11 locales. deDE, esES, esMX, frFR, itIT, koKR, ptBR, ruRU, zhCN, zhTW now translate every option string from v5.5.8 / v5.5.9 / v5.5.10.

 Fixed:

 Send Crits to Say no longer broadcasts inside instances (dungeons, raids, battlegrounds, arenas). Open-world /say is unchanged.

 critFormat / critHealFormat defaults switched from {star} to {rt1} so the gold star icon shows on every locale.

 Updated:

 In-game changelog popup refreshed with all release notes from v5.5.0 through v5.5.10. Going forward this popup is updated as part of every release.


[v5.5.9-release] - 05/08/2026

 Added:

 Lock Crit Log Position toggle in General settings. When on, hold Ctrl while dragging to move the window. Default off.

 Full top strip and the gold-ringed CritMatic icon are now drag handles, not just the small title label.

 Changed:

 Crit Log rows now size to their own content. Damage-only and heal-only rows are tighter; hybrid spells with all four stat lines keep their space.

 Fixed:

 Right-click menu and hover tooltip on the CritMatic icon work alongside the new full-width drag handle.


[v5.5.8-release] - 05/07/2026

 Added:

 Track Crits Only toggle in General settings. Records only critical hits and critical heals; skips normal hits, normal heals, DoT/HoT ticks, and bandage ticks. Default off.

 Full translations for deDE, esES, esMX, itIT, koKR, ptBR, ruRU, zhCN, zhTW. frFR brought up to parity with new strings.

 Fixed:

 Send Crits to Battlegrounds and Send Crits to Raid toggles are now actually honored, no more bypass via the LFG or party route.

 Locale-safe chat broadcast: prefix changed from {star} to {rt1} so the gold star icon shows on every locale.

 Tooltip code no longer errors on Retail 11.x spells where cast time is nil. Tooltip hooks guarded against missing methods on Retail 11.x.

 Version broadcast group-gated; GROUP_ROSTER_UPDATE throttled to one broadcast per 5 seconds. Self-cast heals (paladin / druid / priest healing yourself) are now tracked.

 /cmhelp lines all use the [CritMatic] prefix consistently. Packager renamed to .pkgmeta and ignore: list added; zip slimmed from 2.3 MB to 1.3 MB.


[v5.5.7-release] - 04/22/2026

 Fixed:

 CritMatic icon textures (black circle, icon, gold ring) no longer render behind the Crit Log window.


[v5.5.6-release] - 04/22/2026

 Fixed:

 Right-click menu renders above the Crit Log window instead of behind it.

 Inner scroll area follows the outer frame on resize; spell rows span the full available width.


[v5.5.5-release] - 04/22/2026

 Fixed:

 Crit Log window is movable and resizable on retail 11.0 again; drag and corner/edge sizers receive clicks correctly.


[v5.5.4-release] - 04/17/2026

 Fixed:

 Retail 11.0 context menus and hover errors fixed (right-click context menus and spell-row hover highlight).

 Open Settings menu item works on retail 11.0+.


[v5.5.3-release] - 04/13/2026

 Fixed:

 frFR typo: corrected valeures to valeurs.


[v5.5.2-release] - 04/13/2026

 Added:

 French (frFR) localization contributed by Surfingnet, full translation of all 134 strings.


[v5.5.1-release] - 04/13/2026

 Fixed:

 Login crash on Crit Log creation; removed stray RegisterForClicks calls on non-Button frames.


[v5.5.0-release] - 04/12/2026

 Added:

 Spell icons in alert notifications with bounce animation.

 Resizable Crit Log: drag the corner or edge.

 Right-click context menus on spell rows (Ignore, Delete) and on the CritMatic icon (Settings, Lock / Unlock, Reset Position, Hide).

 Ignored Spells settings panel.

 Hover highlights on spell rows.

 Improved:

 Tooltip performance: per-spell max values cached.

 Spell icon accuracy: icons stored at record time.


[v0.4.3.0-release] - 01/14/2026

 Updated:

 Updated the in-game changelog popup to show recent release notes.

[v0.4.2.9-release] - 01/12/2026

 Fixed:

 Fixed tooltip conflict with StatWeightsClassic - Removed redundant tooltip Show() call that caused CritMatic tooltip info to disappear when used alongside StatWeightsClassic addon.

 Fixed WoW 11.0 compatibility - Removed deprecated InterfaceOptionsList_DisplayPanel hook that was causing errors in modern WoW clients.

[v0.4.2.8-release] - 12/25/2023




[v0.4.2.7.5-release] - 12/25/2023



[v0.4.2.7.4-release] - 12/16/2023



[v0.4.2.7.1-release] - 12/10/2023



[v0.4.2.7-release] - 12/6/2023

 Added:

 Added options for maxMessages, startDelay, and fadeTime settings also a way to reset them.



[v0.4.2.5-release] - 12/6/2023

 Added:

 Added alert notification preview feature in options under Alert

 Chat customization is coming next.



[v0.4.2.1-release] - 12/4/2023

 Updated:

 Removed ignore Auto Attack from options. You can use /cmignore spell name to ignore Auto Attack instead.

 Added:

 You can now customize the alert notification message. Use /cm Its under Alert. Soon chat messages too.



[v0.4.1-release] - 12/3/2023

 Updated:

 When you use /cmcritlogdefaultpos it will now show if its currently hidden.



[v0.4.0-release] - 12/2/2023

 Fixed:

 Fixed issue where Crit Log shifts right on Reload/Logout.

 Added:

 To reset specific spell data, use the command /cmdeletespelldata spell name This avoids the need to clear all data
  with /cmreset.



[v0.3.9.8-release] - 12/1/2023

 Added:

 Added a new slash command to reset the position of Crit Log if it goes off screen. Use /cmcritlogdefaultpos Causes a
  ReloadUI.



[v0.3.9.7-release] - 12/1/2023



[v0.3.9.6-release] - 12/1/2023

 Fixed:

 Removed localization for everything but English for now, because it was causing bugs.



[v0.3.9.5-release] - 11/30/2023

 Fixed:

 Resolved issue with /cmcritlog slash command not functioning as expected.

 Additional slash commands have been tested and confirmed operational.

 Updated:

 You can now ignore specific spells from tracking by using /cmignore Spell Name.

 Make sure the spelling is correct, but it's case insensitive. Use /cmhelp for even more slash commands.



[v0.3.8.8-release] - 11/29/2023

 Updated:

 We need your help translating CritMatic to other languages just visit the localization tab
  on https://legacy.curseforge.com/wow/addons/critmatic to start.

 You will translation credit in the addon and on CurseForge.



[v0.3.8.3-release] - 11/26/2023

 Fixed:

 A bug where spells not in the spellbook caused an error for the action bar tooltip.



[v0.3.8.2-release] - 11/25/2023

 Fixed:

 Good news! We've fixed a bug that affected how the crit log displayed information for spells that can both heal and
  damage. Previously, if a spell had both of these capabilities, the crit log wasn't displaying correctly.

 This issue did not affect spells that were exclusively for healing or damage. With this latest update, you can
  expect accurate and consistent display for all spells, regardless of whether they heal, damage, or do both.

 Thank you for your continued support and feedback, which helps us improve CritMatic. Enjoy your enhanced gaming
  experience!



[v0.3.8-release] - 11/24/2023

 Updated:

 Changed the spell data handling from using spell names to spell IDs. This update enhances localization support,
  allowing CritMatic to be more compatible with different language settings and paving the way for future international
  releases.

 Due to this change, existing spell data in CritMatic had to be cleared. We apologize for any inconvenience this may
  cause and appreciate your understanding.



[v0.3.7.1-release] - 11/20/2023

 Updated:

 Crit Log now sorts by latest Crits/Hits/Crit Heals/Heals.



[v0.3.7-release] - 11/19/2023

 Added:

 New CritLog widget, that displays your latest Crits/Normal Hits/CritHeals/Heals. Open it with /cmcritlog that
  you can macro.



[v0.3.6.2.5-release] - 11/12/2023

 Fixed:

 Turning off social messages was not working its fixed now.


]]

    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

