"use strict";
/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Item
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.GroupItemDef = void 0;
const ActionButtonItemDef_1 = require("../shared/ActionButtonItemDef");
const ItemMap_1 = require("../shared/ItemMap");
const PropsHelper_1 = require("../utils/PropsHelper");
// -----------------------------------------------------------------------------
// GroupItemDef class
// -----------------------------------------------------------------------------
/** An Item that opens a group of items.
 * @public
 */
class GroupItemDef extends ActionButtonItemDef_1.ActionButtonItemDef {
    constructor(groupItemProps, onItemExecuted) {
        super(groupItemProps, onItemExecuted);
        /** @internal */
        this.overflow = false;
        this._panelLabel = "";
        this.groupId =
            groupItemProps.groupId !== undefined ? groupItemProps.groupId : "";
        if (groupItemProps.groupId)
            this.groupId = groupItemProps.groupId;
        else {
            GroupItemDef._sId++;
            this.groupId = GroupItemDef.groupIdPrefix + GroupItemDef._sId;
        }
        this.itemsInColumn =
            groupItemProps.itemsInColumn !== undefined
                ? groupItemProps.itemsInColumn
                : 7;
        this._panelLabel = PropsHelper_1.PropsHelper.getStringSpec(groupItemProps.panelLabel, groupItemProps.panelLabelKey);
        this.items = groupItemProps.items;
        this.defaultActiveItemId = groupItemProps.defaultActiveItemId;
    }
    get id() {
        return this.groupId;
    }
    /** Get the panelLabel string */
    get panelLabel() {
        return PropsHelper_1.PropsHelper.getStringFromSpec(this._panelLabel);
    }
    /** Set the panelLabel.
     * @param v A string or a function to get the string.
     */
    setPanelLabel(v) {
        this._panelLabel = v;
    }
    resolveItems(force) {
        if (this._itemList && !force)
            return;
        this._itemList = new ItemMap_1.ItemList();
        this._itemMap = new ItemMap_1.ItemMap();
        this.items.map((item) => {
            const id = item.id;
            this._itemList.addItem(item);
            this._itemMap.set(id, item);
        });
    }
    getItemById(id) {
        return this._itemMap.get(id);
    }
    getItemByIndex(index) {
        return this._itemList.items[index];
    }
    get itemCount() {
        return this._itemList.items.length;
    }
    execute() { }
}
GroupItemDef._sId = 0;
GroupItemDef.groupIdPrefix = "Group-";
exports.GroupItemDef = GroupItemDef;
//# sourceMappingURL=GroupItem.js.map