"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Editor = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const PageConstructor_1 = require("../../../containers/PageConstructor/index.js");
const GravityBlocksExtension_1 = require("../../../gravity-blocks/extensions/GravityBlocksExtension.js");
const utils_1 = require("../../../utils/index.js");
const AddBlock_1 = tslib_1.__importDefault(require("../../components/AddBlock/AddBlock.js"));
const CodeEditor_1 = require("../../components/CodeEditor/CodeEditor.js");
const ControlPanel_1 = tslib_1.__importDefault(require("../../components/ControlPanel/ControlPanel.js"));
const ErrorBoundary_1 = require("../../components/ErrorBoundary/ErrorBoundary.js");
const Layout_1 = tslib_1.__importDefault(require("../../components/Layout/Layout.js"));
const PageSettings_1 = require("../../components/PageSettings/PageSettings.js");
const context_1 = require("../../context.js");
const Form_1 = require("../Form/Form.js");
const useEditorState_1 = require("./hooks/useEditorState.js");
const b = (0, utils_1.block)('editor');
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, } = (0, useEditorState_1.useEditorState)(props);
    return ((0, jsx_runtime_1.jsxs)(context_1.EditorContext.Provider, { value: context, children: [(0, jsx_runtime_1.jsx)(ControlPanel_1.default, { viewMode: viewMode, onViewModeChange: onViewModeUpdate, editMode: editMode, onEditModeChange: onEditModeUpdate, theme: constructorTheme, className: b('panel'), onThemeChange: onThemeUpdate }), isFormEditMode && isDesktopViewMode && ((0, jsx_runtime_1.jsx)(PageSettings_1.PageSettings, { content: content, schema: schema, onChange: onContentUpdate })), isCodeEditMode && ((0, jsx_runtime_1.jsx)(CodeEditor_1.CodeEditor, { code: code, onChange: onContentUpdate, validator: codeValidator, fullscreenModeOn: codeFullscreeModeOn, onFullscreenModeOnUpdate: onCodeFullscreeModeOnUpdate })), (0, jsx_runtime_1.jsxs)(Layout_1.default, { editMode: editMode, viewMode: viewMode, children: [isFormEditMode && isDesktopViewMode && ((0, jsx_runtime_1.jsx)(Layout_1.default.Left, { children: (0, jsx_runtime_1.jsx)(Form_1.Form, { content: content, onChange: onContentUpdate, activeBlockIndex: activeBlockIndex, schema: schema, onSelect: onSelect }) })), !isCodeOnlyMode && ((0, jsx_runtime_1.jsxs)(Layout_1.default.Right, { children: [(0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { children: (0, jsx_runtime_1.jsx)(PageConstructor_1.PageConstructorProvider, { ...providerProps, children: (0, jsx_runtime_1.jsx)(GravityBlocksExtension_1.GravityBlocksProvider, { theme: constructorTheme, children: (0, jsx_runtime_1.jsx)(PageConstructor_1.PageConstructor, { ...outgoingProps }) }) }) }, errorBoundaryState), isFormEditMode && (0, jsx_runtime_1.jsx)(AddBlock_1.default, { onAdd: onAdd })] }))] })] }));
};
exports.Editor = Editor;
//# sourceMappingURL=Editor.js.map
