import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import { Panels } from "../../components/Panels/Panels.js";
import { Sidebar } from "../../components/Sidebar/Sidebar.js";
import BigOverlay from "../BigOverlay/BigOverlay.js";
import MiddleScreen from "../MiddleScreen/MiddleScreen.js";
import { MainEditorStoreProvider } from "../../context/editorStore/index.js";
import { IframeProvider } from "../../context/iframeContext/index.js";
import { useEditorTabs } from "../../hooks/useEditorTabs.js";
import useMainEditorInitialize from "../../hooks/useMainEditorInitialize.js";
import { useMainEditorStore } from "../../hooks/useMainEditorStore.js";
import { editorCn } from "../../utils/cn.js";
import Source from "../Source/Source.js";
import ViewSwitches from "../ViewSwitches/ViewSwitches.js";
import './Editor.css';
const b = editorCn('editor');
const EditorView = ({ componentsConfig = {}, initialContent }) => {
    const store = useMainEditorStore();
    const { manipulateOverlayMode, disableMode } = store;
    useMainEditorInitialize(initialContent);
    // Disable insert mode on any MouseUp event
    // Maybe should be attached to body
    const onMouseUp = React.useCallback((e) => {
        if (manipulateOverlayMode) {
            e.preventDefault();
            disableMode();
        }
    }, [disableMode, manipulateOverlayMode]);
    const { left, right } = useEditorTabs(componentsConfig);
    return (
    // eslint-disable-next-line jsx-a11y/no-static-element-interactions
    _jsxs("div", { className: b(), onMouseUp: onMouseUp, children: [_jsx("div", { className: b('body'), children: _jsx(Panels, { left: _jsx(Sidebar, { tabs: left, top: componentsConfig.leftTop }), right: _jsx(Sidebar, { tabs: right, top: [...(componentsConfig.rightTop || []), Source, ViewSwitches], defaultTab: "block-config" }), middle: _jsx(MiddleScreen, { CustomTop: componentsConfig.middleTop }) }) }), _jsx(BigOverlay, { className: b('overlay') })] }));
};
export const Editor = (props) => {
    return (_jsx(IframeProvider, { initialUrl: props.initialUrl, disableUrlField: props.disableUrlField, children: _jsx(MainEditorStoreProvider, { children: _jsx(EditorView, { ...props }) }) }));
};
//# sourceMappingURL=Editor.js.map
