local addonName, SinsToolkit = ...

SinsToolkit.UI = SinsToolkit.UI or {}
SinsToolkit.UI.Pages = SinsToolkit.UI.Pages or {}

local PageBase = SinsToolkit.UI.Pages.Base or {}
local Helpers = SinsToolkit.UI.Pages.Helpers or {}
local Page = {}
setmetatable(Page, { __index = PageBase })
SinsToolkit.UI.Pages.Professions = Page
Page.density = Helpers.GetDefaultDensity and Helpers.GetDefaultDensity() or "compact"

function Page:Create(CreateScrollablePage, Window, CreateWrappedText)
    local getGV = Helpers.GetGV
    local setGV = Helpers.SetGV
    local GetToolkitValue = Helpers.GetToolkitValue
    local SetToolkitValue = Helpers.SetToolkitValue

    local profPage = Helpers.CreateContentPage(Window, "Professions")
    local profHeader = Window:CreateSectionHeader(profPage, "Professions & Lookups")
    CreateWrappedText(profPage, {"TOPLEFT", profHeader, "BOTTOMLEFT", 0, -8}, 720, "Hold your selected modifier over an eligible bag item to show the secure profession overlay, then click to mill, prospect, disenchant, or open supported items. Quick Link creates copyable Wowhead, Armory, and Raider.IO URLs from supported tooltips.", "GameFontHighlightSmall")
    local cbProfHotkey = Window:CreateCheckbox(profPage, "Profession Item Hotkey", getGV("professionItemHotkeyEnabled"), setGV("professionItemHotkeyEnabled"), "When enabled, hold the selected modifier over an eligible bag item. Sin's Toolkit highlights supported items and routes your click through a secure profession action for milling, prospecting, disenchanting, or opening.")
    cbProfHotkey:SetPoint("TOPLEFT", profHeader, "BOTTOMLEFT", 0, -48)
    local btnProfModifier = Helpers.CreateOptionGroup(Window, profPage, "Profession Modifier", Helpers.MODIFIER_OPTIONS, function()
        if GetToolkitValue("professionItemHotkeyEnabled") == false then return "NONE" end
        return GetToolkitValue("professionItemHotkeyModifier") or "ALT"
    end, function(value)
        if value == "NONE" then
            SetToolkitValue("professionItemHotkeyEnabled", false)
        else
            SetToolkitValue("professionItemHotkeyEnabled", true)
            SetToolkitValue("professionItemHotkeyModifier", value)
        end
    end, "Select the modifier used by the secure profession overlay. None disables the profession hotkey.")
    btnProfModifier:SetPoint("TOPLEFT", cbProfHotkey, "BOTTOMLEFT", 4, -16)
    local cbWowhead = Window:CreateCheckbox(profPage, "Wowhead Quick Link", getGV("wowheadSearchEnabled"), setGV("wowheadSearchEnabled"), "Mouse over supported UI elements and press Ctrl+C to open a copyable Wowhead, Armory, or Raider.IO link.")
    cbWowhead:SetPoint("TOPLEFT", btnProfModifier, "BOTTOMLEFT", -4, -16)

    self.frame = profPage
    return profPage
end

Page:Register("Professions")

return Page