import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { PageConstructor, PageConstructorProvider } from "../../../containers/PageConstructor/index.js";
import { GravityBlocksProvider } from "../../../gravity-blocks/extensions/GravityBlocksExtension.js";
import { block } from "../../../utils/index.js";
import AddBlock from "../../components/AddBlock/AddBlock.js";
import { CodeEditor } from "../../components/CodeEditor/CodeEditor.js";
import ControlPanel from "../../components/ControlPanel/ControlPanel.js";
import { ErrorBoundary } from "../../components/ErrorBoundary/ErrorBoundary.js";
import Layout from "../../components/Layout/Layout.js";
import { PageSettings } from "../../components/PageSettings/PageSettings.js";
import { EditorContext } from "../../context.js";
import { Form } from "../Form/Form.js";
import { useEditorState } from "./hooks/useEditorState.js";
import './Editor.css';
const b = block('editor');
export const Editor = (props) => {
    const { providerProps } = props;
    const { context, viewMode, editMode, constructorTheme, onThemeUpdate, onViewModeUpdate, onEditModeUpdate, isCodeEditMode, isFormEditMode, isDesktopViewMode, content, schema, onContentUpdate, code, codeValidator, codeFullscreeModeOn, onCodeFullscreeModeOnUpdate, activeBlockIndex, onSelect, isCodeOnlyMode, errorBoundaryState, outgoingProps, onAdd, } = useEditorState(props);
    return (_jsxs(EditorContext.Provider, { value: context, children: [_jsx(ControlPanel, { viewMode: viewMode, onViewModeChange: onViewModeUpdate, editMode: editMode, onEditModeChange: onEditModeUpdate, theme: constructorTheme, className: b('panel'), onThemeChange: onThemeUpdate }), isFormEditMode && isDesktopViewMode && (_jsx(PageSettings, { content: content, schema: schema, onChange: onContentUpdate })), isCodeEditMode && (_jsx(CodeEditor, { code: code, onChange: onContentUpdate, validator: codeValidator, fullscreenModeOn: codeFullscreeModeOn, onFullscreenModeOnUpdate: onCodeFullscreeModeOnUpdate })), _jsxs(Layout, { editMode: editMode, viewMode: viewMode, children: [isFormEditMode && isDesktopViewMode && (_jsx(Layout.Left, { children: _jsx(Form, { content: content, onChange: onContentUpdate, activeBlockIndex: activeBlockIndex, schema: schema, onSelect: onSelect }) })), !isCodeOnlyMode && (_jsxs(Layout.Right, { children: [_jsx(ErrorBoundary, { children: _jsx(PageConstructorProvider, { ...providerProps, children: _jsx(GravityBlocksProvider, { theme: constructorTheme, children: _jsx(PageConstructor, { ...outgoingProps }) }) }) }, errorBoundaryState), isFormEditMode && _jsx(AddBlock, { onAdd: onAdd })] }))] })] }));
};
//# sourceMappingURL=Editor.js.map
