/*---------------------------------------------------------------------------------------------
 * 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
 */
import * as React from "react";
import { IModelApp } from "@itwin/core-frontend";
import { isArgsUtil } from "../backstage/BackstageItemUtilities.js";
import { ToolUtilities } from "@itwin/imodel-components-react";
/** Helper namespace to create toolbar items.
 * @public
 */
export var ToolbarItemUtilities;
(function (ToolbarItemUtilities) {
    function createDeprecatedActionItem(...[id, itemPriority, icon, label, execute, overrides,]) {
        return {
            id,
            itemPriority,
            // eslint-disable-next-line @typescript-eslint/no-deprecated
            icon,
            label,
            execute,
            ...overrides,
        };
    }
    /** Creates an action item. */
    function createActionItem(...args) {
        if (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,
            // eslint-disable-next-line @typescript-eslint/no-deprecated
            icon,
            label,
            items,
            ...overrides,
        };
    }
    /** Creates a group item. */
    function createGroupItem(...args) {
        if (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,
            // eslint-disable-next-line @typescript-eslint/no-deprecated
            icon,
            label,
            panelContent,
            ...overrides,
        };
    }
    /** Creates a custom item. */
    function createCustomItem(...args) {
        if (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) {
        const iconNode = ToolUtilities.isWithIcon(toolType)
            ? toolType.iconElement
            : undefined;
        // eslint-disable-next-line @typescript-eslint/no-deprecated
        return ToolbarItemUtilities.createActionItem(toolType.toolId, 0, toolType.iconSpec, toolType.flyover, () => {
            void IModelApp.tools.run(toolType.toolId);
        }, {
            description: toolType.description,
            iconNode,
            ...overrides,
        });
    }
    ToolbarItemUtilities.createForTool = createForTool;
})(ToolbarItemUtilities || (ToolbarItemUtilities = {}));
//# sourceMappingURL=ToolbarItemUtilities.js.map