/*---------------------------------------------------------------------------------------------
 * 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
 */
import { IModelApp } from "@itwin/core-frontend";
import { ActionButtonItemDef } from "./ActionButtonItemDef";
/** An Item that starts the execution of a Tool.
 * @public
 */
export class ToolItemDef extends 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. */
    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 () => IModelApp.tools.run(tool.toolId, ...args),
        });
    }
}
//# sourceMappingURL=ToolItemDef.js.map