"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 Widget
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.useMaximizeToggle = exports.MaximizeToggle = void 0;
const React = require("react");
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
const Button_1 = require("../widget-action-dropdown/Button");
const Widget_1 = require("../../layout/widget/Widget");
const MaximizedWidget_1 = require("./MaximizedWidget");
const PreviewFeatures_1 = require("../PreviewFeatures");
const FloatingWidget_1 = require("../../layout/widget/FloatingWidget");
const usePanelWidgetId_1 = require("../../layout/widget/usePanelWidgetId");
/** @internal */
function MaximizeToggle() {
    const widgetId = React.useContext(Widget_1.WidgetIdContext);
    const { maximizedWidget, setMaximizedWidget } = React.useContext(MaximizedWidget_1.MaximizedWidgetContext);
    const { id, label, iconSpec } = maximizedWidget === widgetId
        ? {
            id: undefined,
            label: "Restore",
            iconSpec: React.createElement(itwinui_icons_react_1.SvgWindowMinimize, null),
        }
        : {
            id: widgetId,
            label: "Maximize",
            iconSpec: React.createElement(itwinui_icons_react_1.SvgWindowMaximize, null),
        };
    return (React.createElement(Button_1.ActionButton, { icon: iconSpec, label: label, onClick: () => {
            setMaximizedWidget(id);
        } }));
}
exports.MaximizeToggle = MaximizeToggle;
/** @internal */
function useMaximizeToggle() {
    const { enableMaximizedFloatingWidget, enableMaximizedPanelWidget } = (0, PreviewFeatures_1.usePreviewFeatures)();
    const floatingWidgetId = (0, FloatingWidget_1.useFloatingWidgetId)();
    const panelWidgetId = (0, usePanelWidgetId_1.usePanelWidgetId)();
    if (enableMaximizedFloatingWidget && floatingWidgetId)
        return true;
    if (enableMaximizedPanelWidget && panelWidgetId)
        return true;
    return false;
}
exports.useMaximizeToggle = useMaximizeToggle;
//# sourceMappingURL=MaximizeToggle.js.map