local PT = AhUI
if not PT or not PT.InfoPanel then return end
local IP = PT.InfoPanel
local L = PT.L or {}

local function EnsureInfo(typeId, def)
    IP:RegisterElementInfo(typeId, def)
end

local function RebuildSystemAvailability()
    EnsureInfo("fpsms", {
        name  = L["FPS_MS"] or "FPS / MS",
        order = 10
    })

    EnsureInfo("gold", {
        name  = L["GOLD"] or "Gold",
        order = 20
    })
    EnsureInfo("token", {
        name  = L["TOKEN"] or "Token",
        order = 25,
    })
	
    EnsureInfo("durability", {
        name  = L["DURABILITY"] or "Durability",
        order = 30
    })

    EnsureInfo("itemlevel", {
        name  = L["ITEM_LEVEL"] or "Item Level",
        order = 40
    })

    EnsureInfo("spec", {
        name  = L["LOOT_SPEC"] or "Loot Spec",
        order = 50
    })

    if IsInGuild() then
        EnsureInfo("guild", {
            name  = L["GUILD"] or "Guild",
            order = 60
        })
    end
end

local ev = CreateFrame("Frame")
ev:RegisterEvent("PLAYER_LOGIN")
ev:RegisterEvent("PLAYER_ENTERING_WORLD")
ev:RegisterEvent("GUILD_ROSTER_UPDATE")
ev:RegisterEvent("PLAYER_GUILD_UPDATE")

ev:SetScript("OnEvent", function()
    RebuildSystemAvailability()
end)
