"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 Backstage
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.isArgsUtil = exports.BackstageItemUtilities = void 0;
const React = require("react");
/** Utilities for creating and maintaining backstage items
 * @public
 */
var BackstageItemUtilities;
(function (BackstageItemUtilities) {
    function createDeprecatedStageLauncher(...[frontstageId, groupPriority, itemPriority, label, subtitle, icon, overrides,]) {
        return {
            id: frontstageId,
            stageId: frontstageId,
            groupPriority,
            icon,
            itemPriority,
            label,
            subtitle,
            ...overrides,
        };
    }
    /** Creates a stage launcher backstage item. */
    function createStageLauncher(...args) {
        if (isArgsUtil(args)) {
            const { stageId, groupPriority = 0, itemPriority = 0, label = "", icon, ...other } = args[0];
            return {
                id: stageId,
                stageId,
                groupPriority,
                itemPriority,
                label,
                iconNode: icon,
                icon: icon ? React.createElement(React.Fragment, null, icon) : undefined,
                ...other,
            };
        }
        return createDeprecatedStageLauncher(...args);
    }
    BackstageItemUtilities.createStageLauncher = createStageLauncher;
    function createDeprecatedActionItem(...[itemId, groupPriority, itemPriority, execute, label, subtitle, icon, overrides,]) {
        return {
            execute,
            groupPriority,
            icon,
            id: itemId,
            itemPriority,
            label,
            subtitle,
            ...overrides,
        };
    }
    /** Creates an action backstage item. */
    function createActionItem(...args) {
        if (isArgsUtil(args)) {
            const { groupPriority = 0, itemPriority = 0, execute = () => { }, label = "", icon, ...other } = args[0];
            return {
                groupPriority,
                itemPriority,
                execute,
                label,
                iconNode: icon,
                icon: icon ? React.createElement(React.Fragment, null, icon) : undefined,
                ...other,
            };
        }
        return createDeprecatedActionItem(...args);
    }
    BackstageItemUtilities.createActionItem = createActionItem;
})(BackstageItemUtilities || (exports.BackstageItemUtilities = BackstageItemUtilities = {}));
/** Type-guard that returns `true` if specified array has a single object.
 * @internal
 */
function isArgsUtil(args) {
    return args.length === 1 && typeof args[0] === "object";
}
exports.isArgsUtil = isArgsUtil;
//# sourceMappingURL=BackstageItemUtilities.js.map