"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RestoreAllFrontstagesTool = exports.RestoreFrontstageLayoutTool = void 0;
/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module Tools
 */
const core_frontend_1 = require("@itwin/core-frontend");
const InternalFrontstageManager_1 = require("../frontstage/InternalFrontstageManager");
const UiFramework_1 = require("../UiFramework");
const view_layouts_svg_1 = require("@bentley/icons-generic/icons/view-layouts.svg");
/**
 * Immediate tool that will reset the layout to that specified in the stage definition. A stage Id
 * may be passed in, if not the active stage is used. The stage Id is case sensitive.
 * @public
 */
class RestoreFrontstageLayoutTool extends core_frontend_1.Tool {
    static get minArgs() {
        return 0;
    }
    static get maxArgs() {
        return 1;
    }
    async run(frontstageId) {
        let frontstageDef;
        if (frontstageId) {
            frontstageDef = await UiFramework_1.UiFramework.frontstages.getFrontstageDef(frontstageId);
        }
        else {
            frontstageDef = UiFramework_1.UiFramework.frontstages.activeFrontstageDef;
        }
        if (frontstageDef)
            frontstageDef.restoreLayout();
        else
            core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(core_frontend_1.OutputMessagePriority.Info, UiFramework_1.UiFramework.translate("tools.RestoreFrontstageLayout.noStageFound")));
        return true;
    }
    async parseAndRun(...args) {
        return this.run(args[0]);
    }
}
exports.RestoreFrontstageLayoutTool = RestoreFrontstageLayoutTool;
RestoreFrontstageLayoutTool.toolId = "RestoreFrontstageLayout";
RestoreFrontstageLayoutTool.iconSpec = view_layouts_svg_1.default;
/**
 * Immediate tool that will reset the layout of all frontstages to that specified in the stage definition.
 * @public
 */
class RestoreAllFrontstagesTool extends core_frontend_1.Tool {
    async run() {
        const frontstages = InternalFrontstageManager_1.InternalFrontstageManager.frontstageDefs;
        for (const [, frontstage] of frontstages) {
            frontstage.restoreLayout();
        }
        return true;
    }
}
exports.RestoreAllFrontstagesTool = RestoreAllFrontstagesTool;
RestoreAllFrontstagesTool.toolId = "RestoreAllFrontstages";
RestoreAllFrontstagesTool.iconSpec = view_layouts_svg_1.default;
//# sourceMappingURL=RestoreLayoutTool.js.map