-- HDG_HT_W_HotPicks.lua  (B1)
-- Top-5 uncollected items ranked by firstAcquisitionBonus XP. Click row to
-- open the item link tooltip (preview integration deferred to v2.39+).

local _, privateDB = ...
privateDB.HDG_HT = privateDB.HDG_HT or {}
privateDB.HDG_HT.Widgets = privateDB.HDG_HT.Widgets or {}
local W = { id = "hotPicks", title = "Hot Picks" }
privateDB.HDG_HT.Widgets.HotPicks = W

local Patterns = privateDB.HDG_HT.Patterns

function W.Create(parent, dims)
    local self = {}
    self.pattern = Patterns.IconRowList(parent, dims, {
        rowHeight = dims.rowHeight or 26,
        iconSize  = dims.iconSize  or 22,
    })

    function self:Refresh(snap)
        local cAccent = _G.HousingDecorGuide.Theme.C_Accent()
        local picks = snap and snap.firstCatchPicks or {}
        local rows = {}
        for i, p in ipairs(picks) do
            rows[i] = {
                icon  = p.icon,
                lineA = string.format("%s+%d XP|r  %s", cAccent, p.xp or 0, p.name or "?"),
                lineB = (p.sourceName or "") ..
                        (p.zone and (" - " .. p.zone) or ""),
                onClick = p.itemID and function()
                    if SetItemRef then
                        SetItemRef("item:" .. p.itemID, "item:" .. p.itemID, "LeftButton")
                    end
                end,
            }
        end
        self.pattern:Update({ rows = rows })
    end

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

return W
