#pragma once

#include <vector>

#include <QWidget>

#include "BuildingId.h"
#include "SelectionContext.h"

class EmptyNote;
class ItemChipRow;
class SectionBox;

// What the selected belt-subsystem tiles are carrying (REQ-UI-BELT-ITEMS): one item chip
// per item type held across the whole selection, in the same form the buffer sections and
// the HQ's block stock use (REQ-UI-SINGLE-SELECTION, REQ-UI-HQ-PANEL).
//
// It stands above the clear action so the player reads a line's contents before emptying
// it, and it is the only place those contents can be read at all -- items on a moving belt
// are too small and too transient to count by eye, and items inside a tunnel are drawn
// nowhere (REQ-BLD-TUNNEL-TRANSIT).
//
// Shared by the belt card and the splitter card, which show the same thing over different
// selections (REQ-UI-SELECTION-AGGREGATE).
class BeltItemList : public QWidget
{
    Q_OBJECT

public:
    BeltItemList(const SelectionContext& context, const std::vector<BuildingId>& ids,
                 QWidget* parent = nullptr);

    // Re-reads what the tiles hold. Called per refresh of the owning card's runtime
    // group, the counts changing as often as items move.
    void refresh();

private:
    SelectionContext        m_context;
    std::vector<BuildingId> m_ids;
    SectionBox*             m_section;
    ItemChipRow*            m_chips;
    // Shown in the chips' place while the tiles carry nothing, so the card holds one
    // shape as items come and go (REQ-UI-BELT-ITEMS).
    EmptyNote*              m_emptyNote;
};
