"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const reactUtils = require("@contember/react-utils");
const presets = require("./presets.cjs");
const createEditorWithEssentials = require("../baseEditor/createEditorWithEssentials.cjs");
const withAnchors = require("../plugins/element/anchors/withAnchors.cjs");
const withParagraphs = require("../plugins/element/paragraphs/withParagraphs.cjs");
const withHeadings = require("../plugins/element/headings/withHeadings.cjs");
const withLists = require("../plugins/element/lists/withLists.cjs");
const withHorizontalRules = require("../plugins/element/horizonalRules/withHorizontalRules.cjs");
const withScrollTargets = require("../plugins/element/scrollTargets/withScrollTargets.cjs");
const withTables = require("../plugins/element/tables/withTables.cjs");
const withBold = require("../plugins/text/bold/withBold.cjs");
const withCode = require("../plugins/text/code/withCode.cjs");
const withHighlight = require("../plugins/text/highlight/withHighlight.cjs");
const withItalic = require("../plugins/text/italic/withItalic.cjs");
const withNewline = require("../plugins/text/newline/withNewline.cjs");
const withStrikeThrough = require("../plugins/text/strikeThrough/withStrikeThrough.cjs");
const withUnderline = require("../plugins/text/underline/withUnderline.cjs");
const pluginAugmenters = {
  anchor: withAnchors.withAnchors,
  paragraph: withParagraphs.withParagraphs,
  heading: withHeadings.withHeadings,
  list: withLists.withLists,
  horizontalRule: withHorizontalRules.withHorizontalRules,
  scrollTarget: withScrollTargets.withScrollTargets,
  table: withTables.withTables,
  bold: withBold.withBold,
  code: withCode.withCode,
  highlight: withHighlight.withHighlight,
  italic: withItalic.withItalic,
  newline: withNewline.withNewline,
  strikeThrough: withStrikeThrough.withStrikeThrough,
  underline: withUnderline.withUnderline
};
const createEditor = ({
  plugins = presets.defaultEditorPluginPreset,
  defaultElementType,
  augmentEditorBuiltins = reactUtils.identityFunction,
  addEditorBuiltins,
  augmentEditor = reactUtils.identityFunction
}) => {
  const editor = createEditorWithEssentials.createEditorWithEssentials(defaultElementType);
  return initializeEditor({ editor, plugins, augmentEditor, addEditorBuiltins, augmentEditorBuiltins });
};
const initializeEditor = ({
  editor,
  plugins = presets.defaultEditorPluginPreset,
  augmentEditorBuiltins = reactUtils.identityFunction,
  addEditorBuiltins,
  augmentEditor = reactUtils.identityFunction
}) => {
  for (const plugin of new Set(plugins)) {
    editor = pluginAugmenters[plugin](editor);
  }
  const withAugmentedBase = augmentEditor(editor) ?? editor;
  const withBuiltins = addEditorBuiltins(withAugmentedBase) ?? withAugmentedBase;
  return augmentEditorBuiltins(withBuiltins) ?? withBuiltins;
};
exports.createEditor = createEditor;
exports.initializeEditor = initializeEditor;
//# sourceMappingURL=createEditor.cjs.map
