"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Panels = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const icons_1 = require("@gravity-ui/icons");
const uikit_1 = require("@gravity-ui/uikit");
const react_resizable_panels_1 = require("react-resizable-panels");
const cn_1 = require("../../utils/cn.js");
const b = (0, cn_1.editorCn)('panels');
const Panels = ({ left, right, middle }) => {
    const leftPanel = React.useRef(null);
    const rightPanel = React.useRef(null);
    const expandPanel = (reference) => {
        const panel = reference.current;
        if (panel) {
            panel.expand();
        }
    };
    const isCollapsed = {
        left: leftPanel.current?.isCollapsed() || false,
        right: rightPanel.current?.isCollapsed() || false,
    };
    return ((0, jsx_runtime_1.jsxs)(react_resizable_panels_1.PanelGroup, { className: b('panel'), autoSaveId: "page-constructor-editor", direction: "horizontal", children: [(0, jsx_runtime_1.jsx)(react_resizable_panels_1.Panel, { ref: leftPanel, collapsible: true, defaultSize: 25, minSize: 15, children: left }), (0, jsx_runtime_1.jsxs)(react_resizable_panels_1.PanelResizeHandle, { className: b('draggable'), children: [(0, jsx_runtime_1.jsx)(icons_1.Grip, { className: b('grip') }), isCollapsed.left && ((0, jsx_runtime_1.jsx)("div", { className: b('button-wrap', { left: true }), children: (0, jsx_runtime_1.jsx)(uikit_1.Button, { className: b('button'), view: "action", onClick: () => expandPanel(leftPanel), children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.LayoutSideContentLeft }) }) }))] }), (0, jsx_runtime_1.jsx)(react_resizable_panels_1.Panel, { minSize: 20, children: middle }), (0, jsx_runtime_1.jsxs)(react_resizable_panels_1.PanelResizeHandle, { className: b('draggable'), children: [(0, jsx_runtime_1.jsx)(icons_1.Grip, { className: b('grip') }), isCollapsed.right && ((0, jsx_runtime_1.jsx)("div", { className: b('button-wrap', { right: true }), children: (0, jsx_runtime_1.jsx)(uikit_1.Button, { className: b('button'), view: "action", onClick: () => expandPanel(rightPanel), children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.LayoutSideContentRight }) }) }))] }), (0, jsx_runtime_1.jsx)(react_resizable_panels_1.Panel, { ref: rightPanel, collapsible: true, minSize: 15, defaultSize: 25, children: right })] }));
};
exports.Panels = Panels;
//# sourceMappingURL=Panels.js.map
