"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.useCloseTab = exports.CloseWidgetButton = 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 PreviewFeatures_1 = require("../PreviewFeatures");
const Widget_1 = require("../../layout/widget/Widget");
const NineZone_1 = require("../../layout/base/NineZone");
/** @internal */
function CloseWidgetButton() {
    const id = (0, Widget_1.useActiveTabId)();
    const dispatch = React.useContext(NineZone_1.NineZoneDispatchContext);
    return (React.createElement(Button_1.ActionButton, { icon: React.createElement(itwinui_icons_react_1.SvgCloseSmall, null), label: "Close widget", onClick: () => {
            dispatch({
                type: "WIDGET_TAB_HIDE",
                id,
            });
        } }));
}
exports.CloseWidgetButton = CloseWidgetButton;
/** @internal */
function useCloseTab() {
    const id = (0, Widget_1.useActiveTabId)();
    const { controlWidgetVisibility } = (0, PreviewFeatures_1.usePreviewFeatures)();
    if (Array.isArray(controlWidgetVisibility)) {
        return controlWidgetVisibility.includes(id);
    }
    return !!controlWidgetVisibility;
}
exports.useCloseTab = useCloseTab;
//# sourceMappingURL=CloseWidgetButton.js.map