-- HDG_HT_W_LumberWallet.lua  (C4a — split from CurrencyWallet)
-- Lumber item-counts only. Source: HDG_ExpansionData.LUMBER_TYPES → bag scan
-- via C_Item.GetItemCount. Renders as ChipStrip (auto-wraps).

local _, privateDB = ...
privateDB.HDG_HT = privateDB.HDG_HT or {}
privateDB.HDG_HT.Widgets = privateDB.HDG_HT.Widgets or {}
local W = { id = "lumberWallet", title = "Lumber Stock" }
privateDB.HDG_HT.Widgets.LumberWallet = W

local Patterns = privateDB.HDG_HT.Patterns

function W.Create(parent, dims)
    local self = {}
    self.pattern = Patterns.ChipStrip(parent, dims, {
        chipHeight = (dims and dims.chipHeight) or 18,
        chipGap    = (dims and dims.chipGap)    or 4,
    })

    function self:Refresh(snap)
        local lumber = (snap and snap.wallet and snap.wallet.lumber) or {}
        local ED = _G.HDG_ExpansionData
        local chips = {}
        for _, l in ipairs(lumber) do
            chips[#chips + 1] = {
                label = l.name,
                count = l.count,
                color = (l.expansion and ED and ED.GetColor and ED.GetColor(l.expansion)) or nil,
            }
        end
        if #chips == 0 then chips[1] = { label = "Lumber", count = "none" } end
        self.pattern:Update({ chips = chips })
    end

    function self:Resize(w, h) self.pattern:Resize(w, h) end
    return self
end

return W
