"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const reactBinding = require("@contember/react-binding");
const utilities = require("@contember/utilities");
const editorTemplateAnalyzer = require("./editorTemplateAnalyzer.cjs");
const getEditorTemplate = (blockContents, env) => {
  let contentOutlet = void 0;
  const processed = editorTemplateAnalyzer.editorTemplateAnalyzer.processChildren(blockContents, env);
  const nodesBefore = [];
  const nodesAfter = [];
  let currentTarget = nodesBefore;
  for (const node of processed) {
    if (node instanceof editorTemplateAnalyzer.BoxedContentOutletProps) {
      if (contentOutlet === void 0) {
        contentOutlet = node.value;
        currentTarget = nodesAfter;
      } else {
        throw new reactBinding.BindingError(`BlockEditor: There must be no more than one ContentOutlet per block!`);
      }
    } else if (node instanceof editorTemplateAnalyzer.BoxedCatchAllJSX) {
      currentTarget.push(node.value);
    } else {
      utilities.assertNever(node);
    }
  }
  if (contentOutlet === void 0) {
    return void 0;
  }
  return {
    blockContent: {
      nodeBefore: nodesBefore.length ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: nodesBefore }) : void 0,
      value: contentOutlet,
      nodeAfter: nodesAfter.length ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: nodesAfter }) : void 0
    }
  };
};
exports.getEditorTemplate = getEditorTemplate;
//# sourceMappingURL=getEditorTemplate.cjs.map
