"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.WidgetContentContainer = void 0;
require("./ContentContainer.scss");
const classnames_1 = require("classnames");
const React = require("react");
const core_bentley_1 = require("@itwin/core-bentley");
const ContentManager_1 = require("./ContentManager");
const Panel_1 = require("../widget-panels/Panel");
const Widget_1 = require("./Widget");
const LayoutStore_1 = require("../base/LayoutStore");
const WidgetStateHelpers_1 = require("../state/internal/WidgetStateHelpers");
/** @internal */
function WidgetContentContainer(props) {
    const widgetId = React.useContext(Widget_1.WidgetIdContext);
    const widgetContentManager = React.useContext(ContentManager_1.WidgetContentManagerContext);
    const side = React.useContext(Panel_1.PanelSideContext);
    (0, core_bentley_1.assert)(!!widgetId);
    const { minimized, activeTabId } = (0, LayoutStore_1.useLayout)((state) => {
        const widget = (0, WidgetStateHelpers_1.getWidgetState)(state, widgetId);
        return { minimized: widget.minimized, activeTabId: widget.activeTabId };
    }, true);
    const ref = React.useCallback((instance) => {
        if (!widgetContentManager)
            return;
        widgetContentManager.setContainer(activeTabId, instance ?? undefined);
    }, [widgetContentManager, activeTabId]);
    const className = (0, classnames_1.default)("nz-widget-contentContainer", undefined === side && minimized && "nz-minimized");
    return (React.createElement("div", { className: className },
        React.createElement("div", { className: "nz-content", ref: ref }),
        props.children));
}
exports.WidgetContentContainer = WidgetContentContainer;
//# sourceMappingURL=ContentContainer.js.map