-- Portal Authority — options/register.lua
-- Root/home panel, Blizzard compatibility stubs, and final settings registration.
--
-- Depends on: PortalAuthority.OptionsInternal shared helpers and panel factories; PortalAuthority
-- Exposes:    settingsCategory, rootPanel, rootCategoryID, defaultCategoryID, settingsWindowSectionMeta, settingsWindowNavOrder, settingsPanelWalkOrder, settingsPanelRegistry
-- DB keys:    none direct
-- Events:     none
-- Search key: none

PortalAuthority = PortalAuthority or {}

if PortalAuthority.IsSettingsBaselineGateEnabled and PortalAuthority:IsSettingsBaselineGateEnabled() then
    return
end

if not Settings or not Settings.RegisterCanvasLayoutCategory then
    return
end

PortalAuthority.OptionsInternal = PortalAuthority.OptionsInternal or {}
local OptionsInternal = PortalAuthority.OptionsInternal

local settingsSearchRuntime = OptionsInternal.SearchRuntime
local trim = OptionsInternal.trim
local rgba255 = OptionsInternal.rgba255
local unpackColor = OptionsInternal.unpackColor
local applyGlobalFontToObject = OptionsInternal.applyGlobalFontToObject
local getPortalMedia = OptionsInternal.getPortalMedia
local normalizeSoundChoiceValue = OptionsInternal.normalizeSoundChoiceValue
local compareChoiceLabels = OptionsInternal.compareChoiceLabels
local normalizeChoicePathKey = OptionsInternal.normalizeChoicePathKey
local resolveFontChoicePath = OptionsInternal.resolveFontChoicePath
local getSoundChoiceValueKey = OptionsInternal.getSoundChoiceValueKey
local buildFallbackSoundChoices = OptionsInternal.buildFallbackSoundChoices
local getSummonSoundChoices = OptionsInternal.getSummonSoundChoices
local getAvailableFontChoices = OptionsInternal.getAvailableFontChoices
local buildSharedFontPickerChoices = OptionsInternal.buildSharedFontPickerChoices
local SUMMON_SOUND_CHANNEL_CHOICES = OptionsInternal.SUMMON_SOUND_CHANNEL_CHOICES
local debugSettingsLog = OptionsInternal.debugSettingsLog or function() end
local FLAT_SETTINGS_BACKDROP = OptionsInternal.FLAT_SETTINGS_BACKDROP
local SETTINGS_WINDOW_HOSTED_TOP_RHYTHM_NUDGE = OptionsInternal.SETTINGS_WINDOW_HOSTED_TOP_RHYTHM_NUDGE
local SETTINGS_WINDOW_SCROLLBAR_WIDTH = OptionsInternal.SETTINGS_WINDOW_SCROLLBAR_WIDTH
local SETTINGS_WINDOW_SCROLLBAR_GAP = OptionsInternal.SETTINGS_WINDOW_SCROLLBAR_GAP
local SETTINGS_WINDOW_SCROLLBAR_MIN_THUMB_HEIGHT = OptionsInternal.SETTINGS_WINDOW_SCROLLBAR_MIN_THUMB_HEIGHT
local SETTINGS_WINDOW_HOST_COLORS = OptionsInternal.SETTINGS_WINDOW_HOST_COLORS
local SETTINGS_WINDOW_SCROLLBAR_TRACK = OptionsInternal.SETTINGS_WINDOW_SCROLLBAR_TRACK
local SETTINGS_WINDOW_SCROLLBAR_THUMB = OptionsInternal.SETTINGS_WINDOW_SCROLLBAR_THUMB
local SETTINGS_WINDOW_SCROLLBAR_THUMB_HOVER = OptionsInternal.SETTINGS_WINDOW_SCROLLBAR_THUMB_HOVER
local frameIsAlive = OptionsInternal.frameIsAlive
local isDescendedFromFrame = OptionsInternal.isDescendedFromFrame
local markSettingsWindowVisualOptIn = OptionsInternal.markSettingsWindowVisualOptIn
local isUsingCustomSettingsWindowVisualStyle = OptionsInternal.isUsingCustomSettingsWindowVisualStyle
local registerSettingsWindowVisualRefresh = OptionsInternal.registerSettingsWindowVisualRefresh
local setTextureSolidColor = OptionsInternal.setTextureSolidColor
local hideDefaultScrollBarPart = OptionsInternal.hideDefaultScrollBarPart
local getTemplateScrollBar = OptionsInternal.getTemplateScrollBar
local hideDefaultScrollBarChrome = OptionsInternal.hideDefaultScrollBarChrome
local refreshCustomSettingsScrollBarThumb = OptionsInternal.refreshCustomSettingsScrollBarThumb
local settingsScrollRuntime = PortalAuthority._settingsScrollRuntime or OptionsInternal.settingsScrollRuntime
local createStyledFontString = OptionsInternal.createStyledFontString
local createTopRightHeader = OptionsInternal.createTopRightHeader
local PA_SafeBool = OptionsInternal.PA_SafeBool
local getClassHex = OptionsInternal.getClassHex
local createCheckbox = OptionsInternal.createCheckbox
local createActionButton = OptionsInternal.createActionButton
local styleSecondaryActionButtonShared = OptionsInternal.styleSecondaryActionButtonShared
local createNumeric = OptionsInternal.createNumeric
local createDropdown = OptionsInternal.createDropdown
local createDynamicDropdown = OptionsInternal.createDynamicDropdown
local createPremiumSegmentedChoice = OptionsInternal.createPremiumSegmentedChoice
local CreatePicker = OptionsInternal.CreatePicker
local CreateStepperControl = OptionsInternal.CreateStepperControl
local createCanonicalDockFontSizeStepperControl = OptionsInternal.CreateStepperControl or OptionsInternal.createCanonicalDockFontSizeStepperControl
local createTextPlacement = OptionsInternal.createTextPlacement
local setSettingsControlEnabled = OptionsInternal.setSettingsControlEnabled
local setSettingsTextEnabled = OptionsInternal.setSettingsTextEnabled
local createScrollableChild = OptionsInternal.createScrollableChild
local updateScrollBehavior = OptionsInternal.updateScrollBehavior
local withPanelHydration = OptionsInternal.withPanelHydration
local panelHasSizedViewport = OptionsInternal.panelHasSizedViewport
local handleSettingsFirstOpenSizeReady = OptionsInternal.handleSettingsFirstOpenSizeReady
local handleSettingsFirstOpenPanelShow = OptionsInternal.handleSettingsFirstOpenPanelShow
local handleSettingsFirstOpenPanelHide = OptionsInternal.handleSettingsFirstOpenPanelHide
local shouldSuppressSettingsFirstOpenExternalRefresh = OptionsInternal.shouldSuppressSettingsFirstOpenExternalRefresh
local isPanelUsingCustomSettingsWindowHost = OptionsInternal.isPanelUsingCustomSettingsWindowHost
local refreshPanel = OptionsInternal.refreshPanel
local createScrollableTextArea = OptionsInternal.createScrollableTextArea
local createSettingsSectionDescriptor = OptionsInternal.createSettingsSectionDescriptor
local layoutSettingsSectionDescriptor = OptionsInternal.layoutSettingsSectionDescriptor
local registerRefreshCallback = OptionsInternal.registerRefreshCallback
local ensureDatabase = OptionsInternal.ensureDatabase
local IsPointerInsideActivePickerSafeZone = OptionsInternal.IsPointerInsideActivePickerSafeZone
local CloseActivePortalPicker = OptionsInternal.CloseActivePortalPicker
local settingsFirstOpenHost = OptionsInternal.settingsFirstOpenHost
local resetSettingsFirstOpenPanelState = OptionsInternal.resetSettingsFirstOpenPanelState

local settingsEagerBuildGateEnabled = PortalAuthority.IsSettingsEagerBuildGateEnabled and PortalAuthority:IsSettingsEagerBuildGateEnabled() or false
local settingsWindowHostGateEnabled = PortalAuthority.IsSettingsWindowHostEnabled and PortalAuthority:IsSettingsWindowHostEnabled() or false
local createAnnouncementsPanelLegacy = OptionsInternal.createAnnouncementsPanelLegacy
local createAnnouncementsPanel = OptionsInternal.createAnnouncementsPanel
local createDockPanel = OptionsInternal.createDockPanel
local createTimersPanel = OptionsInternal.createTimersPanel
local createInterruptTrackerPanel = OptionsInternal.createInterruptTrackerPanel
local createKeystoneUtilityPanel = OptionsInternal.createKeystoneUtilityPanel
local createCombatAlertsPanel = OptionsInternal.createCombatAlertsPanel
local createProfilesPanel = OptionsInternal.createProfilesPanel

local function getPortalAuthorityLandingVersionText()
    local version = nil
    if C_AddOns and C_AddOns.GetAddOnMetadata then
        version = C_AddOns.GetAddOnMetadata("PortalAuthority", "Version")
    end
    if (type(version) ~= "string" or trim(version) == "") and GetAddOnMetadata then
        version = GetAddOnMetadata("PortalAuthority", "Version")
    end
    if (type(version) ~= "string" or trim(version) == "")
        and PortalAuthority and type(PortalAuthority.GetAnnouncementReleaseVersionString) == "function"
    then
        version = PortalAuthority:GetAnnouncementReleaseVersionString()
    end

    version = trim(tostring(version or ""))
    if version == "" then
        version = "1.0.0"
    end
    if not version:match("^[vV]") then
        version = "v" .. version
    end
    return version
end

local function createPortalAuthorityLandingDivider(parent, width)
    local divider = parent:CreateTexture(nil, "ARTWORK")
    divider:SetTexture("Interface\\Buttons\\WHITE8x8")
    divider:SetVertexColor(0.27, 0.27, 0.27, 0.60)
    divider:SetSize(width or 40, 1)
    return divider
end

local function configurePortalAuthorityLandingFontString(fontString, size, flags, justifyH)
    if not fontString then
        return nil
    end
    fontString._paLandingFontSize = size
    fontString._paLandingFontFlags = flags
    applyGlobalFontToObject(fontString, size, flags)
    fontString:SetJustifyH(justifyH or "CENTER")
    fontString:SetJustifyV("MIDDLE")
    if fontString.SetWordWrap then
        fontString:SetWordWrap(false)
    end
    if fontString.SetNonSpaceWrap then
        fontString:SetNonSpaceWrap(false)
    end
    if fontString.SetMaxLines then
        fontString:SetMaxLines(1)
    end
    return fontString
end

local function createPortalAuthorityLandingStyledFontString(parent, layer, template, size, justifyH)
    local fontString = createStyledFontString(parent, layer, template, size)
    return configurePortalAuthorityLandingFontString(fontString, size, nil, justifyH)
end

local function createPortalAuthorityLandingRawFontString(parent, layer, template, size, flags, justifyH)
    local fontString = parent:CreateFontString(nil, layer, template)
    return configurePortalAuthorityLandingFontString(fontString, size, flags, justifyH)
end

local function refreshPortalAuthorityLandingFontString(fontString)
    if not fontString or not fontString._paLandingFontSize then
        return
    end
    applyGlobalFontToObject(fontString, fontString._paLandingFontSize, fontString._paLandingFontFlags)
end

local function isOnboardingD3GateEnabled()
    return PortalAuthority
        and PortalAuthority.IsOnboardingD3DevGateEnabled
        and PortalAuthority:IsOnboardingD3DevGateEnabled()
end

local function applyPremiumAuthoredFontToObject(object, size, flags)
    if PortalAuthority and PortalAuthority.ApplyPremiumAuthoredFont then
        PortalAuthority:ApplyPremiumAuthoredFont(object, size, flags)
        return
    end
    if object and object.SetFont then
        object:SetFont("Fonts\\FRIZQT__.TTF", size or select(2, object:GetFont()) or 12, flags or "")
    end
end

local function configurePortalAuthorityPremiumFontString(fontString, size, flags, justifyH)
    if not fontString then
        return nil
    end
    fontString._paPremiumLandingFontSize = size
    fontString._paPremiumLandingFontFlags = flags
    applyPremiumAuthoredFontToObject(fontString, size, flags)
    fontString:SetJustifyH(justifyH or "CENTER")
    fontString:SetJustifyV("MIDDLE")
    if fontString.SetWordWrap then
        fontString:SetWordWrap(false)
    end
    if fontString.SetNonSpaceWrap then
        fontString:SetNonSpaceWrap(false)
    end
    if fontString.SetMaxLines then
        fontString:SetMaxLines(1)
    end
    return fontString
end

local function createPortalAuthorityPremiumStyledFontString(parent, layer, template, size, justifyH)
    local fontString = createStyledFontString(parent, layer, template, size)
    return configurePortalAuthorityPremiumFontString(fontString, size, nil, justifyH)
end

local function createPortalAuthorityPremiumRawFontString(parent, layer, template, size, flags, justifyH)
    local fontString = parent:CreateFontString(nil, layer, template)
    return configurePortalAuthorityPremiumFontString(fontString, size, flags, justifyH)
end

local function refreshPortalAuthorityPremiumFontString(fontString)
    if not fontString or not fontString._paPremiumLandingFontSize then
        return
    end
    applyPremiumAuthoredFontToObject(fontString, fontString._paPremiumLandingFontSize, fontString._paPremiumLandingFontFlags)
end

local function printPortalAuthorityCompatMessage(message)
    message = trim(tostring(message or ""))
    if message == "" then
        return
    end
    print("|cffE88BC7Portal Authority:|r " .. message)
end

local function createPortalAuthorityCompatStubButton(parent, label)
    local button = CreateFrame("Button", nil, parent, "BackdropTemplate")
    button:SetBackdrop({
        bgFile = "Interface\\Buttons\\WHITE8x8",
        edgeFile = "Interface\\Buttons\\WHITE8x8",
        edgeSize = 1,
        insets = { left = 0, right = 0, top = 0, bottom = 0 },
    })

    local text = button:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
    applyPremiumAuthoredFontToObject(text, 12, "")
    text:SetPoint("CENTER")
    text:SetText(label or "Open Settings")
    text:SetTextColor(0.98, 0.96, 0.88, 1.0)
    text:SetShadowOffset(0, -1)
    text:SetShadowColor(0, 0, 0, 0.35)

    button._text = text

    local function setVisual(state)
        local bgR, bgG, bgB, bgA = 0.11, 0.09, 0.06, 0.97
        local borderR, borderG, borderB, borderA = 0.74, 0.60, 0.24, 0.92
        local textR, textG, textB = 0.99, 0.97, 0.90

        if state == "hover" then
            bgR, bgG, bgB = 0.16, 0.12, 0.07
            borderR, borderG, borderB = 0.90, 0.74, 0.32
            textR, textG, textB = 1.0, 0.98, 0.94
        elseif state == "down" then
            bgR, bgG, bgB = 0.09, 0.07, 0.05
            borderR, borderG, borderB = 0.68, 0.52, 0.18
            textR, textG, textB = 0.96, 0.94, 0.86
        end

        button:SetBackdropColor(bgR, bgG, bgB, bgA)
        button:SetBackdropBorderColor(borderR, borderG, borderB, borderA)
        text:SetTextColor(textR, textG, textB, 1.0)
    end

    button:SetSize(164, 36)
    setVisual("idle")

    button:SetScript("OnEnter", function()
        setVisual("hover")
    end)
    button:SetScript("OnLeave", function()
        setVisual("idle")
    end)
    button:SetScript("OnMouseDown", function()
        setVisual("down")
    end)
    button:SetScript("OnMouseUp", function(selfBtn)
        if selfBtn:IsMouseOver() then
            setVisual("hover")
        else
            setVisual("idle")
        end
    end)

    return button
end

local function createBlizzardCompatibilityStubPanel(sectionKey, name)
    local panel = CreateFrame("Frame")
    panel.name = name
    panel._compatStubSectionKey = sectionKey

    panel.EnsureBuilt = function(self)
        if self._initialized then
            return
        end
        self._initialized = true

        local widgets = {}
        self._compatStubWidgets = widgets

        widgets.group = CreateFrame("Frame", nil, self)

        widgets.banner = widgets.group:CreateTexture(nil, "ARTWORK")
        widgets.banner:SetTexture("Interface\\AddOns\\PortalAuthority\\Media\\Images\\01.PA_banner_wow_1024x256_centered.png")
        widgets.banner:SetTexCoord(0, 1, 0, 1)

        widgets.button = createPortalAuthorityCompatStubButton(widgets.group, "Open Settings")
        widgets.button:SetScript("OnClick", function()
            if not PortalAuthority or type(PortalAuthority.OpenSettingsWindowFromBlizzardStub) ~= "function" then
                printPortalAuthorityCompatMessage("Settings window is unavailable.")
                return
            end

            local ok, err = PortalAuthority:OpenSettingsWindowFromBlizzardStub(self._compatStubSectionKey)
            if not ok and err then
                printPortalAuthorityCompatMessage(err)
            end
        end)

        self._layout = function(frame)
            local stub = frame and frame._compatStubWidgets or nil
            if not stub then
                return
            end

            local panelWidth = tonumber(frame:GetWidth()) or 0
            if panelWidth <= 1 and frame.GetParent then
                local parent = frame:GetParent()
                panelWidth = parent and tonumber(parent:GetWidth()) or 0
            end

            local bannerWidth = math.min(480, math.max(1, panelWidth - 64))
            local bannerHeight = math.max(1, math.floor((bannerWidth / 4) + 0.5))
            local buttonWidth = math.max(156, math.ceil((stub.button._text:GetStringWidth() or 0) + 28))
            local buttonHeight = 36
            local groupWidth = math.max(bannerWidth, buttonWidth)
            local groupHeight = bannerHeight + 18 + buttonHeight

            stub.group:SetSize(groupWidth, groupHeight)
            stub.group:ClearAllPoints()
            stub.group:SetPoint("CENTER", frame, "CENTER", 0, 0)

            stub.banner:SetSize(bannerWidth, bannerHeight)
            stub.banner:ClearAllPoints()
            stub.banner:SetPoint("TOP", stub.group, "TOP", 0, 0)

            stub.button:SetSize(buttonWidth, buttonHeight)
            stub.button:ClearAllPoints()
            stub.button:SetPoint("TOP", stub.banner, "BOTTOM", 0, -18)
        end

        self._refresh = function(frame)
            if frame and frame._layout then
                frame._layout(frame)
            end
        end
    end

    panel:SetScript("OnShow", function(self)
        self:EnsureBuilt()
        if self._refresh then
            self._refresh(self)
        end
    end)

    panel:SetScript("OnSizeChanged", function(self)
        if self._initialized and self._layout then
            self._layout(self)
        end
    end)

    return panel
end

local root = CreateFrame("Frame")
root.name = "Portal Authority"
debugSettingsLog("create frame:", root.name)
root.EnsureBuilt = function(self)
    debugSettingsLog("EnsureBuilt:", self.name, "initialized=", self._initialized and "true" or "false")
    if self._initialized then return end
    self._initialized = true
    resetSettingsFirstOpenPanelState(self)
    ensureDatabase()
    self._sizingFrame = self

    local widgets = {}
    self._landingWidgets = widgets

    local PORTAL_AUTHORITY_LANDING_PERCEPTUAL_CENTER_RATIO = 0.45
    local PORTAL_AUTHORITY_LANDING_MIN_TOP_INSET = 20

    local function getPortalAuthorityLandingElementHeight(element, fallback)
        fallback = math.max(0, tonumber(fallback) or 0)
        if not element then
            return fallback
        end

        local objectType = element.GetObjectType and element:GetObjectType() or nil
        if objectType == "FontString" and element.GetStringHeight then
            local stringHeight = tonumber(element:GetStringHeight()) or 0
            if stringHeight > 0 then
                return math.max(fallback, math.ceil(stringHeight))
            end
        end

        local height = tonumber(element.GetHeight and element:GetHeight()) or 0
        if height > 0 then
            return math.max(fallback, math.ceil(height))
        end

        return fallback
    end

    local function getPortalAuthorityLandingGroupTopOffset(panel, items)
        if type(items) ~= "table" or #items <= 0 then
            return -PORTAL_AUTHORITY_LANDING_MIN_TOP_INSET
        end

        local groupHeight = 0
        for i = 1, #items do
            local item = items[i]
            if type(item) == "table" then
                groupHeight = groupHeight + getPortalAuthorityLandingElementHeight(item.ref, item.fallback)
                groupHeight = groupHeight + math.max(0, tonumber(item.gapAfter) or 0)
            end
        end

        if groupHeight <= 0 then
            return -PORTAL_AUTHORITY_LANDING_MIN_TOP_INSET
        end

        local panelHeight = tonumber(panel and panel.GetHeight and panel:GetHeight()) or 0
        if panelHeight <= 1 then
            return -PORTAL_AUTHORITY_LANDING_MIN_TOP_INSET
        end

        local topInset = (panelHeight * PORTAL_AUTHORITY_LANDING_PERCEPTUAL_CENTER_RATIO) - (groupHeight * 0.5)
        topInset = math.max(PORTAL_AUTHORITY_LANDING_MIN_TOP_INSET, topInset)
        return -math.floor(topInset + 0.5)
    end

    if isOnboardingD3GateEnabled() then
        widgets.banner = self:CreateTexture(nil, "ARTWORK")
        widgets.banner:SetTexture("Interface\\AddOns\\PortalAuthority\\Media\\Images\\01.PA_banner_wow_1024x256_centered.png")
        widgets.banner:SetTexCoord(0, 1, 0, 1)
        widgets.banner:SetSize(460, 115)

        widgets.separator1 = createPortalAuthorityLandingDivider(self, 80)

        widgets.dedicatedLabel = createPortalAuthorityPremiumStyledFontString(self, "ARTWORK", "GameFontNormalSmall", 12)
        widgets.dedicatedLabel:SetText("DEDICATED TO")
        widgets.dedicatedLabel:SetTextColor(1.0, 0.82, 0.0, 1.0)

        widgets.characterName = createPortalAuthorityPremiumRawFontString(self, "ARTWORK", "GameFontHighlight", 15)
        widgets.characterName:SetText("|cFF33937FImbabyuwu|r|cFF555555-Illidan|r")

        widgets.alias = createPortalAuthorityPremiumStyledFontString(self, "ARTWORK", "GameFontHighlightSmall", 12)
        widgets.alias:SetText("Navarone")
        widgets.alias:SetTextColor(0.54, 0.54, 0.56, 1.0)

        widgets.separator2 = createPortalAuthorityLandingDivider(self, 40)

        widgets.inspiredLabel = createPortalAuthorityPremiumStyledFontString(self, "ARTWORK", "GameFontNormalSmall", 12)
        widgets.inspiredLabel:SetText("INSPIRED BY")
        widgets.inspiredLabel:SetTextColor(1.0, 0.82, 0.0, 1.0)

        widgets.guildRow = CreateFrame("Button", nil, self)
        widgets.guildRow:SetSize(1, 28)
        widgets.guildRow:SetHitRectInsets(-8, -8, -4, -4)

        widgets.guildLogo = widgets.guildRow:CreateTexture(nil, "ARTWORK")
        widgets.guildLogo:SetTexture("Interface\\AddOns\\PortalAuthority\\Media\\Images\\overclock_logo_wow_64x64.png")
        widgets.guildLogo:SetTexCoord(0, 1, 0, 1)
        widgets.guildLogo:SetSize(28, 28)

        widgets.guildName = createPortalAuthorityPremiumStyledFontString(widgets.guildRow, "ARTWORK", "GameFontHighlight", 15, "LEFT")
        widgets.guildName:SetText("Overclock")
        widgets.guildName:SetTextColor(1.0, 1.0, 1.0, 1.0)

        widgets.separator3 = createPortalAuthorityLandingDivider(self, 40)

        widgets.author = createPortalAuthorityPremiumRawFontString(self, "ARTWORK", "GameFontNormal", 12)
        widgets.author:SetText("|cFF999999by |r|cFF3FC7EBStormyeyes|r|cFF555555-Mal'Ganis|r")

        widgets.version = createPortalAuthorityPremiumStyledFontString(self, "ARTWORK", "GameFontHighlightSmall", 11)
        widgets.version:SetTextColor(0.34, 0.34, 0.36, 1.0)

        widgets.showMeAround = CreateFrame("Button", nil, self)
        widgets.showMeAround:SetSize(1, 18)
        widgets.showMeAround:SetHitRectInsets(-8, -8, -4, -4)
        widgets.showMeAroundText = createPortalAuthorityPremiumStyledFontString(widgets.showMeAround, "ARTWORK", "GameFontHighlightSmall", 11)
        widgets.showMeAroundText:SetPoint("CENTER")
        widgets.showMeAroundText:SetText("Show Me Around")
        widgets.showMeAroundText:SetTextColor(0.78, 0.78, 0.82, 1.0)

        widgets.fontStrings = {
            widgets.dedicatedLabel,
            widgets.characterName,
            widgets.alias,
            widgets.inspiredLabel,
            widgets.guildName,
            widgets.author,
            widgets.version,
            widgets.showMeAroundText,
        }

        local function setGuildRowHoverState(isHover)
            if isHover then
                widgets.guildName:SetTextColor(0.96, 0.96, 0.98, 1.0)
            else
                widgets.guildName:SetTextColor(1.0, 1.0, 1.0, 1.0)
            end
        end

        widgets.guildRow:SetScript("OnEnter", function()
            setGuildRowHoverState(true)
        end)
        widgets.guildRow:SetScript("OnLeave", function()
            setGuildRowHoverState(false)
        end)
        widgets.guildRow:SetScript("OnClick", function()
            if PortalAuthority and PortalAuthority.ShowOverclockLinkPopup then
                PortalAuthority:ShowOverclockLinkPopup()
            end
        end)

        widgets.showMeAround:SetScript("OnEnter", function()
            widgets.showMeAroundText:SetTextColor(0.92, 0.92, 0.95, 1.0)
        end)
        widgets.showMeAround:SetScript("OnLeave", function()
            widgets.showMeAroundText:SetTextColor(0.78, 0.78, 0.82, 1.0)
        end)
        widgets.showMeAround:SetScript("OnMouseDown", function()
            widgets.showMeAroundText:SetTextColor(0.98, 0.98, 1.0, 1.0)
        end)
        widgets.showMeAround:SetScript("OnMouseUp", function()
            if widgets.showMeAround:IsMouseOver() then
                widgets.showMeAroundText:SetTextColor(0.92, 0.92, 0.95, 1.0)
            else
                widgets.showMeAroundText:SetTextColor(0.78, 0.78, 0.82, 1.0)
            end
        end)
        widgets.showMeAround:SetScript("OnClick", function()
            if PortalAuthority and PortalAuthority.StartPremiumOnboardingExperience then
                PortalAuthority:StartPremiumOnboardingExperience("root-show-me-around")
            end
        end)

        self._layout = function()
            local landing = self._landingWidgets
            if not landing then
                return
            end

            local guildRowWidth = tonumber(self._landingGuildRowWidth) or 1
            landing.guildRow:SetSize(guildRowWidth, 28)

            local showMeAroundWidth = tonumber(self._landingShowMeAroundWidth) or 1
            landing.showMeAround:SetSize(showMeAroundWidth, 18)

            local groupTopOffset = getPortalAuthorityLandingGroupTopOffset(self, {
                { ref = landing.banner, fallback = 115, gapAfter = 20 },
                { ref = landing.separator1, fallback = 1, gapAfter = 20 },
                { ref = landing.dedicatedLabel, fallback = 12, gapAfter = 8 },
                { ref = landing.characterName, fallback = 15, gapAfter = 2 },
                { ref = landing.alias, fallback = 12, gapAfter = 18 },
                { ref = landing.separator2, fallback = 1, gapAfter = 18 },
                { ref = landing.inspiredLabel, fallback = 12, gapAfter = 8 },
                { ref = landing.guildRow, fallback = 28, gapAfter = 18 },
                { ref = landing.separator3, fallback = 1, gapAfter = 18 },
                { ref = landing.author, fallback = 12, gapAfter = 16 },
                { ref = landing.version, fallback = 11, gapAfter = 22 },
                { ref = landing.showMeAround, fallback = 18, gapAfter = 0 },
            })

            landing.guildLogo:ClearAllPoints()
            landing.guildLogo:SetPoint("LEFT", landing.guildRow, "LEFT", 0, 0)

            landing.guildName:ClearAllPoints()
            landing.guildName:SetPoint("LEFT", landing.guildLogo, "RIGHT", 8, 0)

            landing.banner:ClearAllPoints()
            landing.banner:SetPoint("TOP", self, "TOP", 0, groupTopOffset)

            landing.separator1:ClearAllPoints()
            landing.separator1:SetPoint("TOP", landing.banner, "BOTTOM", 0, -20)

            landing.dedicatedLabel:ClearAllPoints()
            landing.dedicatedLabel:SetPoint("TOP", landing.separator1, "BOTTOM", 0, -20)

            landing.characterName:ClearAllPoints()
            landing.characterName:SetPoint("TOP", landing.dedicatedLabel, "BOTTOM", 0, -8)

            landing.alias:ClearAllPoints()
            landing.alias:SetPoint("TOP", landing.characterName, "BOTTOM", 0, -2)

            landing.separator2:ClearAllPoints()
            landing.separator2:SetPoint("TOP", landing.alias, "BOTTOM", 0, -18)

            landing.inspiredLabel:ClearAllPoints()
            landing.inspiredLabel:SetPoint("TOP", landing.separator2, "BOTTOM", 0, -18)

            landing.guildRow:ClearAllPoints()
            landing.guildRow:SetPoint("TOP", landing.inspiredLabel, "BOTTOM", 0, -8)

            landing.separator3:ClearAllPoints()
            landing.separator3:SetPoint("TOP", landing.guildRow, "BOTTOM", 0, -18)

            landing.author:ClearAllPoints()
            landing.author:SetPoint("TOP", landing.separator3, "BOTTOM", 0, -18)

            landing.version:ClearAllPoints()
            landing.version:SetPoint("TOP", landing.author, "BOTTOM", 0, -16)

            landing.showMeAround:ClearAllPoints()
            landing.showMeAround:SetPoint("TOP", landing.version, "BOTTOM", 0, -22)
        end

        self._refresh = function()
            local landing = self._landingWidgets
            if not landing then
                return
            end

            for _, fontString in ipairs(landing.fontStrings or {}) do
                refreshPortalAuthorityPremiumFontString(fontString)
            end

            local versionText = getPortalAuthorityLandingVersionText()
            if landing.version:GetText() ~= versionText then
                landing.version:SetText(versionText)
            end

            local guildNameWidth = math.max(1, math.ceil(tonumber((landing.guildName.GetStringWidth and landing.guildName:GetStringWidth()) or 0) or 0))
            self._landingGuildRowWidth = 28 + 8 + guildNameWidth
            self._landingShowMeAroundWidth = math.max(1, math.ceil(tonumber((landing.showMeAroundText.GetStringWidth and landing.showMeAroundText:GetStringWidth()) or 0) or 0))

            if self._layout then
                self._layout()
            end
        end

        registerRefreshCallback(function()
            if shouldSuppressSettingsFirstOpenExternalRefresh(self) then
                return
            end
            if self and self._refresh then
                self._refresh()
            end
        end, self)

        self:SetScript("OnSizeChanged", function(panel)
            if handleSettingsFirstOpenSizeReady(panel, "size_changed") then
                return
            end
            if shouldSuppressSettingsFirstOpenExternalRefresh(panel) then
                return
            end
            if panel and panel._initialized and panel._layout and panel:IsShown() then
                panel._layout()
            end
        end)

        self._settingsFirstOpenKey = "root"
        self._settingsFirstOpenSizeTarget = self
        self._settingsFirstOpenRender = function(panel)
            if panel._refresh then
                panel._refresh()
            elseif panel._layout then
                panel._layout()
            end
        end
        self._settingsFirstOpenIsReady = function(panel)
            local landing = panel and panel._landingWidgets or nil
            return panelHasSizedViewport(panel)
                and landing ~= nil
                and landing.banner ~= nil and landing.banner:IsShown()
                and landing.version ~= nil and landing.version:IsShown()
                and landing.author ~= nil and landing.author:IsShown()
        end

        self._refresh()
        return
    end

    widgets.banner = self:CreateTexture(nil, "ARTWORK")
    widgets.banner:SetTexture("Interface\\AddOns\\PortalAuthority\\Media\\Images\\01.PA_banner_wow_1024x256_centered.png")
    widgets.banner:SetTexCoord(0, 1, 0, 1)
    widgets.banner:SetSize(460, 115)

    widgets.separator1 = createPortalAuthorityLandingDivider(self, 80)

    widgets.dedicatedLabel = createPortalAuthorityLandingStyledFontString(self, "ARTWORK", "GameFontNormalSmall", 11)
    widgets.dedicatedLabel:SetText("DEDICATED TO")
    widgets.dedicatedLabel:SetTextColor(1.0, 0.82, 0.0, 1.0)

    -- Use raw font strings for inline color escapes so their embedded colors remain untouched.
    widgets.characterName = createPortalAuthorityLandingRawFontString(self, "ARTWORK", "GameFontHighlight", 14)
    widgets.characterName:SetText("|cFF33937FImbabyuwu|r|cFF555555-Illidan|r")

    widgets.alias = createPortalAuthorityLandingStyledFontString(self, "ARTWORK", "GameFontHighlightSmall", 11)
    widgets.alias:SetText("Navarone")
    widgets.alias:SetTextColor(0.40, 0.40, 0.40, 1.0)

    widgets.separator2 = createPortalAuthorityLandingDivider(self, 40)

    widgets.inspiredLabel = createPortalAuthorityLandingStyledFontString(self, "ARTWORK", "GameFontNormalSmall", 11)
    widgets.inspiredLabel:SetText("INSPIRED BY")
    widgets.inspiredLabel:SetTextColor(1.0, 0.82, 0.0, 1.0)

    widgets.guildRow = CreateFrame("Frame", nil, self)
    widgets.guildRow:SetSize(1, 28)

    widgets.guildLogo = widgets.guildRow:CreateTexture(nil, "ARTWORK")
    widgets.guildLogo:SetTexture("Interface\\AddOns\\PortalAuthority\\Media\\Images\\overclock_logo_wow_64x64.png")
    widgets.guildLogo:SetTexCoord(0, 1, 0, 1)
    widgets.guildLogo:SetSize(28, 28)

    widgets.guildName = createPortalAuthorityLandingStyledFontString(widgets.guildRow, "ARTWORK", "GameFontHighlight", 13, "LEFT")
    widgets.guildName:SetText("Overclock")
    widgets.guildName:SetTextColor(0.80, 0.80, 0.80, 1.0)

    widgets.separator3 = createPortalAuthorityLandingDivider(self, 40)

    widgets.author = createPortalAuthorityLandingRawFontString(self, "ARTWORK", "GameFontNormal", 11)
    widgets.author:SetText("|cFF999999by |r|cFF3FC7EBStormyeyes|r|cFF555555-Mal'Ganis|r")

    widgets.version = createPortalAuthorityLandingStyledFontString(self, "ARTWORK", "GameFontHighlightSmall", 10)
    widgets.version:SetTextColor(0.22, 0.22, 0.22, 1.0)

    widgets.fontStrings = {
        widgets.dedicatedLabel,
        widgets.characterName,
        widgets.alias,
        widgets.inspiredLabel,
        widgets.guildName,
        widgets.author,
        widgets.version,
    }

    self._layout = function()
        local landing = self._landingWidgets
        if not landing then
            return
        end

        local guildRowWidth = tonumber(self._landingGuildRowWidth) or 1
        landing.guildRow:SetSize(guildRowWidth, 28)

        local groupTopOffset = getPortalAuthorityLandingGroupTopOffset(self, {
            { ref = landing.banner, fallback = 115, gapAfter = 20 },
            { ref = landing.separator1, fallback = 1, gapAfter = 20 },
            { ref = landing.dedicatedLabel, fallback = 11, gapAfter = 6 },
            { ref = landing.characterName, fallback = 14, gapAfter = 2 },
            { ref = landing.alias, fallback = 11, gapAfter = 18 },
            { ref = landing.separator2, fallback = 1, gapAfter = 18 },
            { ref = landing.inspiredLabel, fallback = 11, gapAfter = 8 },
            { ref = landing.guildRow, fallback = 28, gapAfter = 18 },
            { ref = landing.separator3, fallback = 1, gapAfter = 18 },
            { ref = landing.author, fallback = 11, gapAfter = 16 },
            { ref = landing.version, fallback = 10, gapAfter = 0 },
        })

        landing.guildLogo:ClearAllPoints()
        landing.guildLogo:SetPoint("LEFT", landing.guildRow, "LEFT", 0, 0)

        landing.guildName:ClearAllPoints()
        landing.guildName:SetPoint("LEFT", landing.guildLogo, "RIGHT", 8, 0)

        landing.banner:ClearAllPoints()
        landing.banner:SetPoint("TOP", self, "TOP", 0, groupTopOffset)

        landing.separator1:ClearAllPoints()
        landing.separator1:SetPoint("TOP", landing.banner, "BOTTOM", 0, -20)

        landing.dedicatedLabel:ClearAllPoints()
        landing.dedicatedLabel:SetPoint("TOP", landing.separator1, "BOTTOM", 0, -20)

        landing.characterName:ClearAllPoints()
        landing.characterName:SetPoint("TOP", landing.dedicatedLabel, "BOTTOM", 0, -6)

        landing.alias:ClearAllPoints()
        landing.alias:SetPoint("TOP", landing.characterName, "BOTTOM", 0, -2)

        landing.separator2:ClearAllPoints()
        landing.separator2:SetPoint("TOP", landing.alias, "BOTTOM", 0, -18)

        landing.inspiredLabel:ClearAllPoints()
        landing.inspiredLabel:SetPoint("TOP", landing.separator2, "BOTTOM", 0, -18)

        landing.guildRow:ClearAllPoints()
        landing.guildRow:SetPoint("TOP", landing.inspiredLabel, "BOTTOM", 0, -8)

        landing.separator3:ClearAllPoints()
        landing.separator3:SetPoint("TOP", landing.guildRow, "BOTTOM", 0, -18)

        landing.author:ClearAllPoints()
        landing.author:SetPoint("TOP", landing.separator3, "BOTTOM", 0, -18)

        landing.version:ClearAllPoints()
        landing.version:SetPoint("TOP", landing.author, "BOTTOM", 0, -16)
    end

    self._refresh = function()
        local landing = self._landingWidgets
        if not landing then
            return
        end

        for _, fontString in ipairs(landing.fontStrings or {}) do
            refreshPortalAuthorityLandingFontString(fontString)
        end

        local versionText = getPortalAuthorityLandingVersionText()
        if landing.version:GetText() ~= versionText then
            landing.version:SetText(versionText)
        end

        local guildNameWidth = math.max(1, math.ceil(tonumber((landing.guildName.GetStringWidth and landing.guildName:GetStringWidth()) or 0) or 0))
        self._landingGuildRowWidth = 28 + 8 + guildNameWidth

        if self._layout then
            self._layout()
        end
    end

    registerRefreshCallback(function()
        if shouldSuppressSettingsFirstOpenExternalRefresh(self) then
            return
        end
        if self and self._refresh then
            self._refresh()
        end
    end, self)

    self:SetScript("OnSizeChanged", function(panel)
        if handleSettingsFirstOpenSizeReady(panel, "size_changed") then
            return
        end
        if shouldSuppressSettingsFirstOpenExternalRefresh(panel) then
            return
        end
        if panel and panel._initialized and panel._layout and panel:IsShown() then
            panel._layout()
        end
    end)

    self._settingsFirstOpenKey = "root"
    self._settingsFirstOpenSizeTarget = self
    self._settingsFirstOpenRender = function(panel)
        if panel._refresh then
            panel._refresh()
        elseif panel._layout then
            panel._layout()
        end
    end
    self._settingsFirstOpenIsReady = function(panel)
        local landing = panel and panel._landingWidgets or nil
        return panelHasSizedViewport(panel)
            and landing ~= nil
            and landing.banner ~= nil and landing.banner:IsShown()
            and landing.version ~= nil and landing.version:IsShown()
            and landing.author ~= nil and landing.author:IsShown()
    end

    self._refresh()
end

local function ensureRootPanelAnchored(self)
    local parent = self and self:GetParent() or nil
    if not parent then
        return false
    end
    if self._paAnchorParent ~= parent or not self._paAnchored then
        self:ClearAllPoints()
        self:SetAllPoints(parent)
        self._paAnchorParent = parent
    end
    self._paAnchored = true
    return true
end

root:SetScript("OnShow", function(self)
    debugSettingsLog("OnShow:", self.name)
    ensureRootPanelAnchored(self)
    self:EnsureBuilt()
    if not handleSettingsFirstOpenPanelShow(self) then
        withPanelHydration(self, function()
            if self._refresh then
                self._refresh()
            elseif self._layout then
                self._layout()
            end
        end)
    end
end)

root:HookScript("OnHide", function(self)
    handleSettingsFirstOpenPanelHide(self)
end)

local announcementsPanel = createAnnouncementsPanel()
local dockPanel = createDockPanel()
local timersPanel = createTimersPanel()
local interruptTrackerPanel = createInterruptTrackerPanel()
local combatAlertsPanel = createCombatAlertsPanel()
local keystoneUtilityPanel = createKeystoneUtilityPanel()
local profilesPanel = createProfilesPanel()
local rootCategoryPanel = settingsWindowHostGateEnabled and createBlizzardCompatibilityStubPanel("root", root.name) or root

local function initializeDeferredSettingsPanelHidden(panel)
    if not panel or not panel.Hide or not panel.IsShown then
        return
    end
    if panel:IsShown() then
        panel:Hide()
    end
end

-- These panels were being created in the shown state, which means their first
-- real selection never produced an OnShow transition. Starting them hidden
-- makes first selection own the initial build/show path instead of relying on
-- later click-away/click-back or background priming.
local rootCategory = Settings.RegisterCanvasLayoutCategory(rootCategoryPanel, root.name, root.name)
Settings.RegisterAddOnCategory(rootCategory)
debugSettingsLog("register category:", root.name, "id=", rootCategory and rootCategory.GetID and rootCategory:GetID() or "nil")

initializeDeferredSettingsPanelHidden(root)
initializeDeferredSettingsPanelHidden(announcementsPanel)
initializeDeferredSettingsPanelHidden(dockPanel)
initializeDeferredSettingsPanelHidden(timersPanel)
initializeDeferredSettingsPanelHidden(interruptTrackerPanel)
initializeDeferredSettingsPanelHidden(combatAlertsPanel)
initializeDeferredSettingsPanelHidden(profilesPanel)

-- Direct settings panels now build on demand when opened for the first time.

local function bootstrapKeystoneUtilityPanelBuild(attempt)
    if not keystoneUtilityPanel then
        return
    end
    if keystoneUtilityPanel._initialized and keystoneUtilityPanel._layout and keystoneUtilityPanel._refresh and keystoneUtilityPanel._fullRefresh then
        return
    end

    ensureDatabase()
    if PortalAuthorityDB then
        keystoneUtilityPanel:EnsureBuilt()
        if keystoneUtilityPanel._fullRefresh then
            keystoneUtilityPanel._fullRefresh("bootstrap-eager")
        end
        return
    end

    local n = tonumber(attempt) or 0
    if n >= 180 then
        return
    end
    if C_Timer and C_Timer.After then
        C_Timer.After(0, function()
            bootstrapKeystoneUtilityPanelBuild(n + 1)
        end)
    end
end

if PortalAuthority and PortalAuthority.SetSettingsKeystoneBootstrapState then
    if settingsEagerBuildGateEnabled then
        PortalAuthority:SetSettingsKeystoneBootstrapState("suppressed")
    else
        PortalAuthority:SetSettingsKeystoneBootstrapState("unknown")
    end
end

if settingsEagerBuildGateEnabled then
    -- The eager-build gate suppresses the delayed bootstrap kickoff entirely.
elseif C_Timer and C_Timer.After then
    if PortalAuthority and PortalAuthority.SetSettingsKeystoneBootstrapState then
        PortalAuthority:SetSettingsKeystoneBootstrapState("scheduled")
    end
    C_Timer.After(0, function()
        if PortalAuthority and PortalAuthority.SetSettingsKeystoneBootstrapState then
            PortalAuthority:SetSettingsKeystoneBootstrapState("ran")
        end
        bootstrapKeystoneUtilityPanelBuild(0)
    end)
end

if PortalAuthority then
    PortalAuthority.settingsWindowSectionMeta = {
        root = {
            key = "root",
            title = "Home",
            descriptor = "",
            navLabel = nil,
            showInNav = false,
        },
        announcements = {
            key = "announcements",
            title = "Announcements",
            descriptor = "Customize your Utility alerts.",
            navLabel = "Announcements",
            showInNav = true,
        },
        dock = {
            key = "dock",
            title = "Mythic+ Dock",
            descriptor = "Configure your custom portal layout.",
            navLabel = "Mythic+ Dock",
            showInNav = true,
        },
        timers = {
            key = "timers",
            title = "Timers",
            descriptor = "Configure your M+ timers.",
            navLabel = "Timers",
            showInNav = true,
        },
        interrupt = {
            key = "interrupt",
            title = "Interrupt Tracker",
            descriptor = "Tune interrupt visibility and preview behavior.",
            navLabel = "Interrupt Tracker",
            showInNav = true,
        },
        combat = {
            key = "combat",
            title = "Combat Alerts",
            descriptor = "Control death alerts, audio, and on-screen messaging.",
            navLabel = "Combat Alerts",
            showInNav = true,
        },
        keystone = {
            key = "keystone",
            title = "Keystone Utility",
            descriptor = "Configure keystone assistant behavior and automation.",
            navLabel = "Keystone Utility",
            showInNav = true,
        },
        profiles = {
            key = "profiles",
            title = "Profiles",
            descriptor = "Manage your saved profiles.",
            navLabel = "Profiles",
            showInNav = true,
        },
    }
    PortalAuthority.settingsWindowNavOrder = {
        "announcements",
        "dock",
        "timers",
        "interrupt",
        "combat",
        "keystone",
        "profiles",
    }
    PortalAuthority.settingsCategory = rootCategory
    PortalAuthority.rootPanel = root
    local rootCategoryID = rootCategory and rootCategory.GetID and rootCategory:GetID() or nil
    PortalAuthority.rootCategoryID = rootCategoryID
    PortalAuthority.rootCategory = rootCategory
    PortalAuthority.defaultCategoryID = rootCategoryID
    PortalAuthority._settingsFirstOpenHostDebug = settingsFirstOpenHost
    PortalAuthority._settingsFirstOpenDebugPanels = {
        { key = "root", name = root.name, panel = root },
        { key = "announcements", name = announcementsPanel.name, panel = announcementsPanel },
        { key = "dock", name = dockPanel.name, panel = dockPanel },
        { key = "timers", name = timersPanel.name, panel = timersPanel },
        { key = "interrupt", name = interruptTrackerPanel.name, panel = interruptTrackerPanel },
        { key = "combat", name = combatAlertsPanel.name, panel = combatAlertsPanel },
        { key = "keystone", name = keystoneUtilityPanel.name, panel = keystoneUtilityPanel },
        { key = "profiles", name = profilesPanel.name, panel = profilesPanel },
    }
    PortalAuthority.settingsPanelWalkOrder = {
        "root",
        "announcements",
        "dock",
        "timers",
        "interrupt",
        "combat",
        "keystone",
        "profiles",
    }
    PortalAuthority.settingsPanelRegistry = {
        root = {
            key = "root",
            name = root.name,
            panel = root,
            category = rootCategory,
            categoryID = PortalAuthority.rootCategoryID,
            title = PortalAuthority.settingsWindowSectionMeta.root.title,
            descriptor = PortalAuthority.settingsWindowSectionMeta.root.descriptor,
            navLabel = PortalAuthority.settingsWindowSectionMeta.root.navLabel,
            showInNav = PortalAuthority.settingsWindowSectionMeta.root.showInNav,
        },
        announcements = {
            key = "announcements",
            name = announcementsPanel.name,
            panel = announcementsPanel,
            title = PortalAuthority.settingsWindowSectionMeta.announcements.title,
            descriptor = PortalAuthority.settingsWindowSectionMeta.announcements.descriptor,
            navLabel = PortalAuthority.settingsWindowSectionMeta.announcements.navLabel,
            showInNav = PortalAuthority.settingsWindowSectionMeta.announcements.showInNav,
        },
        dock = {
            key = "dock",
            name = dockPanel.name,
            panel = dockPanel,
            title = PortalAuthority.settingsWindowSectionMeta.dock.title,
            descriptor = PortalAuthority.settingsWindowSectionMeta.dock.descriptor,
            navLabel = PortalAuthority.settingsWindowSectionMeta.dock.navLabel,
            showInNav = PortalAuthority.settingsWindowSectionMeta.dock.showInNav,
        },
        timers = {
            key = "timers",
            name = timersPanel.name,
            panel = timersPanel,
            title = PortalAuthority.settingsWindowSectionMeta.timers.title,
            descriptor = PortalAuthority.settingsWindowSectionMeta.timers.descriptor,
            navLabel = PortalAuthority.settingsWindowSectionMeta.timers.navLabel,
            showInNav = PortalAuthority.settingsWindowSectionMeta.timers.showInNav,
        },
        interrupt = {
            key = "interrupt",
            name = interruptTrackerPanel.name,
            panel = interruptTrackerPanel,
            title = PortalAuthority.settingsWindowSectionMeta.interrupt.title,
            descriptor = PortalAuthority.settingsWindowSectionMeta.interrupt.descriptor,
            navLabel = PortalAuthority.settingsWindowSectionMeta.interrupt.navLabel,
            showInNav = PortalAuthority.settingsWindowSectionMeta.interrupt.showInNav,
        },
        combat = {
            key = "combat",
            name = combatAlertsPanel.name,
            panel = combatAlertsPanel,
            title = PortalAuthority.settingsWindowSectionMeta.combat.title,
            descriptor = PortalAuthority.settingsWindowSectionMeta.combat.descriptor,
            navLabel = PortalAuthority.settingsWindowSectionMeta.combat.navLabel,
            showInNav = PortalAuthority.settingsWindowSectionMeta.combat.showInNav,
        },
        keystone = {
            key = "keystone",
            name = keystoneUtilityPanel.name,
            panel = keystoneUtilityPanel,
            title = PortalAuthority.settingsWindowSectionMeta.keystone.title,
            descriptor = PortalAuthority.settingsWindowSectionMeta.keystone.descriptor,
            navLabel = PortalAuthority.settingsWindowSectionMeta.keystone.navLabel,
            showInNav = PortalAuthority.settingsWindowSectionMeta.keystone.showInNav,
        },
        profiles = {
            key = "profiles",
            name = profilesPanel.name,
            panel = profilesPanel,
            title = PortalAuthority.settingsWindowSectionMeta.profiles.title,
            descriptor = PortalAuthority.settingsWindowSectionMeta.profiles.descriptor,
            navLabel = PortalAuthority.settingsWindowSectionMeta.profiles.navLabel,
            showInNav = PortalAuthority.settingsWindowSectionMeta.profiles.showInNav,
        },
    }
end
