"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.usePopoutToggle = exports.PopoutToggle = void 0;
const React = require("react");
const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
const NineZone_1 = require("../base/NineZone");
const Widget_1 = require("./Widget");
const LayoutStore_1 = require("../base/LayoutStore");
const Button_1 = require("../../preview/widget-action-dropdown/Button");
/** @internal */
function PopoutToggle() {
    const dispatch = React.useContext(NineZone_1.NineZoneDispatchContext);
    const activeTabId = (0, Widget_1.useActiveTabId)();
    const label = (0, NineZone_1.useLabel)("popoutActiveTab");
    return (React.createElement(Button_1.ActionButton, { icon: React.createElement(itwinui_icons_react_1.SvgWindowPopout, null), label: label, onClick: () => {
            dispatch({
                id: activeTabId,
                type: "WIDGET_TAB_POPOUT",
            });
        } }));
}
exports.PopoutToggle = PopoutToggle;
/** @internal */
function usePopoutToggle() {
    const tabId = (0, Widget_1.useActiveTabId)();
    return (0, LayoutStore_1.useLayout)((state) => {
        const tab = state.tabs[tabId];
        return !!tab.canPopout;
    });
}
exports.usePopoutToggle = usePopoutToggle;
//# sourceMappingURL=PopoutToggle.js.map