"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 Toolbar
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolbarItemUtilities = void 0;
const React = require("react");
const core_frontend_1 = require("@itwin/core-frontend");
const BackstageItemUtilities_1 = require("../backstage/BackstageItemUtilities");
/** Helper namespace to create toolbar items.
 * @public
 */
var ToolbarItemUtilities;
(function (ToolbarItemUtilities) {
    function createDeprecatedActionItem(...[id, itemPriority, icon, label, execute, overrides,]) {
        return {
            id,
            itemPriority,
            icon,
            label,
            execute,
            ...overrides,
        };
    }
    /** Creates an action item. */
    function createActionItem(...args) {
        if ((0, BackstageItemUtilities_1.isArgsUtil)(args)) {
            const { execute = () => { }, icon, itemPriority = 0, label = "", ...other } = args[0];
            return {
                execute,
                itemPriority,
                iconNode: icon,
                icon: icon ? React.createElement(React.Fragment, null, icon) : undefined,
                label,
                ...other,
            };
        }
        return createDeprecatedActionItem(...args);
    }
    ToolbarItemUtilities.createActionItem = createActionItem;
    function createDeprecatedGroupItem(...[id, itemPriority, icon, label, items, overrides,]) {
        return {
            id,
            itemPriority,
            icon,
            label,
            items,
            ...overrides,
        };
    }
    /** Creates a group item. */
    function createGroupItem(...args) {
        if ((0, BackstageItemUtilities_1.isArgsUtil)(args)) {
            const { icon, itemPriority = 0, items = [], label = "", ...other } = args[0];
            return {
                itemPriority,
                items,
                iconNode: icon,
                icon: icon ? React.createElement(React.Fragment, null, icon) : undefined,
                label,
                ...other,
            };
        }
        return createDeprecatedGroupItem(...args);
    }
    ToolbarItemUtilities.createGroupItem = createGroupItem;
    function createDeprecatedCustomItem(...[id, itemPriority, icon, label, panelContent, overrides,]) {
        return {
            id,
            itemPriority,
            icon,
            label,
            panelContent,
            ...overrides,
        };
    }
    /** Creates a custom item. */
    function createCustomItem(...args) {
        if ((0, BackstageItemUtilities_1.isArgsUtil)(args)) {
            const { icon, itemPriority = 0, ...other } = args[0];
            return {
                itemPriority,
                iconNode: icon,
                icon: icon ? React.createElement(React.Fragment, null, icon) : undefined,
                ...other,
            };
        }
        return createDeprecatedCustomItem(...args);
    }
    ToolbarItemUtilities.createCustomItem = createCustomItem;
    /** Creates an action item from the specified tool type. */
    function createForTool(toolType, overrides) {
        // eslint-disable-next-line deprecation/deprecation
        return ToolbarItemUtilities.createActionItem(toolType.toolId, 0, toolType.iconSpec, toolType.flyover, () => {
            void core_frontend_1.IModelApp.tools.run(toolType.toolId);
        }, {
            description: toolType.description,
            ...overrides,
        });
    }
    ToolbarItemUtilities.createForTool = createForTool;
})(ToolbarItemUtilities || (exports.ToolbarItemUtilities = ToolbarItemUtilities = {}));
//# sourceMappingURL=ToolbarItemUtilities.js.map