-- Icons.lua -- Icon loader for the icon selector button --
-- WanderBook: Forge your path through Azeroth with your own goals. --
-- Made by Blakmane. May 2025. --

local _, addon = ...
WanderBook = addon

--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------

local uniqueIcons = {}
for _, iconID in ipairs(GetMacroIcons()) do
    uniqueIcons[iconID] = true
end
for _, iconID in ipairs(GetMacroItemIcons()) do
    uniqueIcons[iconID] = true
end
local function groupAndSortIcons()
    local spellIcons = GetMacroIcons()
    local itemIcons = GetMacroItemIcons()

    local categories = {
        spells = {},
        items = {},
    }

    local seen = {}
    for _, id in ipairs(spellIcons) do
        if not seen[id] then
            table.insert(categories.spells, id)
            seen[id] = true
        end
    end
    for _, id in ipairs(itemIcons) do
        if not seen[id] then
            table.insert(categories.items, id)
            seen[id] = true
        end
    end
    -- Optional: sort for visual consistency
    table.sort(categories.spells)
    table.sort(categories.items)

    local pool = {}
    for _, id in ipairs(categories.spells) do table.insert(pool, id) end
    for _, id in ipairs(categories.items) do table.insert(pool, id) end

    return pool
end

WanderBook.iconPool = groupAndSortIcons()

--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
