/*---------------------------------------------------------------------------------------------
 * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
 * See LICENSE.md in the project root for license terms and full copyright notice.
 *--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module WidgetPanels
 */
import "./StandardLayout.scss";
import classnames from "classnames";
import * as React from "react";
import { useLayout } from "./base/LayoutStore.js";
import { useContentAlwaysMaxSize } from "../preview/content-always-max-size/useContentAlwaysMaxSize.js";
import { useMaximizedPanelLayout } from "../preview/enable-maximized-widget/useMaximizedWidget.js";
import { useHorizontalPanelAlignment } from "../preview/horizontal-panel-alignment/useHorizontalPanelAlignment.js";
import { usePanelsAutoCollapse } from "./widget-panels/usePanelsAutoCollapse.js";
import { ConfigurableUiContext } from "../configurableui/ConfigurableUiContent.js";
import { useRefs } from "@itwin/core-react/internal";
/** Component that displays widgets in a standard layout.
 * @internal
 */
export function StandardLayout(props) {
    const { contentElementRef } = React.useContext(ConfigurableUiContext);
    const pinned = usePinnedPanels();
    const appContentRef = usePanelsAutoCollapse();
    const refs = useRefs(contentElementRef, appContentRef);
    const className = classnames("nz-standardLayout", pinned, props.className);
    const contentAlwaysMaxSize = useContentAlwaysMaxSize();
    return (React.createElement("div", { className: className, style: props.style },
        React.createElement("div", { className: classnames("nz-appContent", contentAlwaysMaxSize), ref: refs }, props.children),
        React.createElement("div", { className: "nz-centerContent" }, props.centerContent),
        React.createElement(Panel, { side: "left" }, props.leftPanel),
        React.createElement(Panel, { side: "right" }, props.rightPanel),
        React.createElement(Panel, { side: "top" }, props.topPanel),
        React.createElement(Panel, { side: "bottom" }, props.bottomPanel),
        React.createElement("div", { className: "nz-toolSettings" }, props.toolSettings),
        React.createElement("div", { className: "nz-statusBar" }, props.statusBar)));
}
function Panel({ children, side }) {
    const maximizedWidget = useMaximizedPanelLayout(side);
    const horizontalAlignment = useHorizontalPanelAlignment(side);
    const className = classnames(`nz-standardLayout_${side}Panel`, maximizedWidget, horizontalAlignment.classNames);
    return (React.createElement("div", { className: className, ...horizontalAlignment.attributes }, children));
}
function usePinnedPanels() {
    const leftPinned = useLayout((state) => state.panels.left.pinned);
    const rightPinned = useLayout((state) => state.panels.right.pinned);
    const topPinned = useLayout((state) => state.panels.top.pinned);
    const bottomPinned = useLayout((state) => state.panels.bottom.pinned);
    return {
        "nz-pinned-left": leftPinned,
        "nz-pinned-right": rightPinned,
        "nz-pinned-top": topPinned,
        "nz-pinned-bottom": bottomPinned,
    };
}
//# sourceMappingURL=StandardLayout.js.map