"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.ToolItemDef = void 0;
const core_frontend_1 = require("@itwin/core-frontend");
const ActionButtonItemDef_1 = require("./ActionButtonItemDef");
/* eslint-disable deprecation/deprecation */
/** An Item that starts the execution of a Tool.
 * @public
 * @deprecated in 4.15.0. Use {@link ToolbarItemUtilities.createForTool} instead.
 */
class ToolItemDef extends ActionButtonItemDef_1.ActionButtonItemDef {
    constructor(toolItemProps, onItemExecuted) {
        super(toolItemProps, onItemExecuted);
        this.toolId = "";
        if (toolItemProps.execute) {
            this._commandHandler = {
                execute: toolItemProps.execute,
                parameters: toolItemProps.parameters,
                getCommandArgs: toolItemProps.getCommandArgs,
            };
        }
        this.toolId = toolItemProps.toolId;
    }
    get id() {
        return this.toolId;
    }
    /** Create a ToolItemDef that will run a registered tool.
     * @deprecated in 4.15.0. Use {@link ToolbarItemUtilities.createForTool} instead.
     */
    static getItemDefForTool(tool, icon, ...args) {
        return new ToolItemDef({
            toolId: tool.toolId,
            icon: icon
                ? icon
                : tool.iconSpec && tool.iconSpec.length > 0
                    ? tool.iconSpec
                    : undefined,
            label: () => tool.flyover,
            description: () => tool.description,
            execute: async () => core_frontend_1.IModelApp.tools.run(tool.toolId, ...args),
        });
    }
}
exports.ToolItemDef = ToolItemDef;
//# sourceMappingURL=ToolItemDef.js.map