{"version":3,"sources":["../src/lib/editor/withSlate.ts","../src/internal/plugin/resolvePlugins.ts","../src/lib/plugin/createSlatePlugin.ts","../src/internal/utils/isFunction.ts","../src/internal/utils/mergePlugins.ts","../src/lib/plugin/getEditorPlugin.ts","../src/internal/plugin/resolvePlugin.ts","../src/lib/plugin/getSlatePlugin.ts","../src/lib/plugins/AstPlugin.ts","../src/lib/plugins/HistoryPlugin.ts","../src/lib/plugins/paragraph/BaseParagraphPlugin.ts","../src/lib/plugins/override/withBreakRules.ts","../src/lib/plugins/override/withDeleteRules.ts","../src/lib/plugins/override/withMergeRules.ts","../src/lib/plugins/override/withNormalizeRules.ts","../src/lib/plugins/override/OverridePlugin.ts","../src/internal/plugin/pipeInsertFragment.ts","../src/internal/plugin/pipeTransformData.ts","../src/internal/plugin/pipeTransformFragment.ts","../src/lib/utils/applyDeepToNodes.ts","../src/lib/utils/defaultsDeepToNodes.ts","../src/lib/utils/getInjectMatch.ts","../src/lib/utils/getKeysByTypes.ts","../src/lib/utils/getInjectedPlugins.ts","../src/lib/utils/getPluginNodeProps.ts","../src/lib/static/pipeRenderElementStatic.tsx","../src/lib/static/components/slate-nodes.tsx","../src/lib/static/pluginRenderElementStatic.tsx","../src/lib/static/utils/createStaticString.ts","../src/lib/static/utils/getNodeDataAttributes.ts","../src/lib/static/utils/getRenderNodeStaticProps.ts","../src/internal/plugin/pipeInjectNodeProps.tsx","../src/internal/plugin/isEditOnlyDisabled.ts","../src/internal/plugin/pluginInjectNodeProps.ts","../src/lib/static/utils/pipeDecorate.ts","../src/lib/static/utils/stripHtmlClassNames.ts","../src/lib/static/utils/stripSlateDataAttributes.ts","../src/lib/static/pluginRenderLeafStatic.tsx","../src/lib/static/components/PlateStatic.tsx","../src/lib/static/pluginRenderTextStatic.tsx","../src/lib/static/serializeHtml.tsx","../src/lib/static/deserialize/checkUtils.ts","../src/lib/static/deserialize/htmlStringToEditorDOM.ts","../src/lib/utils/getSlateClass.ts","../src/lib/utils/hotkeys.ts","../src/lib/utils/isType.ts","../src/lib/utils/mergeDeepToNodes.ts","../src/lib/utils/normalizeDescendantsToDocumentFragment.ts","../src/lib/plugins/affinity/AffinityPlugin.ts","../src/lib/plugins/affinity/queries/getEdgeNodes.ts","../../../node_modules/is-plain-object/dist/is-plain-object.mjs","../../../node_modules/immer/src/utils/env.ts","../../../node_modules/immer/src/utils/errors.ts","../../../node_modules/immer/src/utils/common.ts","../../../node_modules/immer/src/utils/plugins.ts","../../../node_modules/immer/src/core/scope.ts","../../../node_modules/immer/src/core/finalize.ts","../../../node_modules/immer/src/core/proxy.ts","../../../node_modules/immer/src/core/immerClass.ts","../../../node_modules/immer/src/core/current.ts","../../../node_modules/immer/src/plugins/patches.ts","../../../node_modules/immer/src/plugins/mapset.ts","../../../node_modules/immer/src/immer.ts","../../../node_modules/slate/src/interfaces/path-ref.ts","../../../node_modules/slate/src/interfaces/point-ref.ts","../../../node_modules/slate/src/interfaces/range-ref.ts","../../../node_modules/slate/src/utils/weak-maps.ts","../../../node_modules/slate/src/interfaces/path.ts","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/typeof.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/toPrimitive.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/defineProperty.js","../../../node_modules/slate/src/interfaces/transforms/general.ts","../../../node_modules/slate/src/interfaces/transforms/node.ts","../../../node_modules/slate/src/interfaces/transforms/selection.ts","../../../node_modules/slate/src/utils/deep-equal.ts","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js","../../../node_modules/slate/src/interfaces/range.ts","../../../node_modules/slate/src/interfaces/element.ts","../../../node_modules/slate/src/interfaces/node.ts","../../../node_modules/slate/src/interfaces/operation.ts","../../../node_modules/slate/src/editor/is-editor.ts","../../../node_modules/slate/src/interfaces/editor.ts","../../../node_modules/slate/src/interfaces/location.ts","../../../node_modules/slate/src/interfaces/point.ts","../../../node_modules/slate/src/interfaces/scrubber.ts","../../../node_modules/slate/src/interfaces/text.ts","../../../node_modules/slate/src/utils/get-default-insert-location.ts","../../../node_modules/slate/src/utils/match-path.ts","../../../node_modules/slate/src/utils/string.ts","../../../node_modules/slate/src/interfaces/transforms/text.ts","../../../node_modules/slate/src/interfaces/transforms/index.ts","../../../node_modules/slate/src/core/batch-dirty-paths.ts","../../../node_modules/slate/src/core/update-dirty-paths.ts","../../../node_modules/slate/src/core/apply.ts","../../../node_modules/slate/src/core/get-dirty-paths.ts","../../../node_modules/slate/src/core/get-fragment.ts","../../../node_modules/slate/src/core/normalize-node.ts","../../../node_modules/slate/src/core/should-normalize.ts","../../../node_modules/slate/src/editor/above.ts","../../../node_modules/slate/src/editor/add-mark.ts","../../../node_modules/slate/src/editor/after.ts","../../../node_modules/slate/src/editor/before.ts","../../../node_modules/slate/src/editor/delete-backward.ts","../../../node_modules/slate/src/editor/delete-forward.ts","../../../node_modules/slate/src/editor/delete-fragment.ts","../../../node_modules/slate/src/editor/edges.ts","../../../node_modules/slate/src/editor/element-read-only.ts","../../../node_modules/slate/src/editor/end.ts","../../../node_modules/slate/src/editor/first.ts","../../../node_modules/slate/src/editor/fragment.ts","../../../node_modules/slate/src/editor/get-void.ts","../../../node_modules/slate/src/editor/has-blocks.ts","../../../node_modules/slate/src/editor/has-inlines.ts","../../../node_modules/slate/src/editor/has-path.ts","../../../node_modules/slate/src/editor/has-texts.ts","../../../node_modules/slate/src/editor/insert-break.ts","../../../node_modules/slate/src/editor/insert-node.ts","../../../node_modules/slate/src/editor/insert-soft-break.ts","../../../node_modules/slate/src/editor/insert-text.ts","../../../node_modules/slate/src/editor/is-block.ts","../../../node_modules/slate/src/editor/is-edge.ts","../../../node_modules/slate/src/editor/is-empty.ts","../../../node_modules/slate/src/editor/is-end.ts","../../../node_modules/slate/src/editor/is-normalizing.ts","../../../node_modules/slate/src/editor/is-start.ts","../../../node_modules/slate/src/editor/last.ts","../../../node_modules/slate/src/editor/leaf.ts","../../../node_modules/slate/src/editor/levels.ts","../../../node_modules/slate/src/editor/marks.ts","../../../node_modules/slate/src/editor/next.ts","../../../node_modules/slate/src/editor/node.ts","../../../node_modules/slate/src/editor/nodes.ts","../../../node_modules/slate/src/editor/normalize.ts","../../../node_modules/slate/src/editor/parent.ts","../../../node_modules/slate/src/editor/path-ref.ts","../../../node_modules/slate/src/editor/path-refs.ts","../../../node_modules/slate/src/editor/path.ts","../../../node_modules/slate/src/editor/point-ref.ts","../../../node_modules/slate/src/editor/point-refs.ts","../../../node_modules/slate/src/editor/point.ts","../../../node_modules/slate/src/editor/positions.ts","../../../node_modules/slate/src/editor/previous.ts","../../../node_modules/slate/src/editor/range-ref.ts","../../../node_modules/slate/src/editor/range-refs.ts","../../../node_modules/slate/src/editor/range.ts","../../../node_modules/slate/src/editor/remove-mark.ts","../../../node_modules/slate/src/editor/set-normalizing.ts","../../../node_modules/slate/src/editor/start.ts","../../../node_modules/slate/src/editor/string.ts","../../../node_modules/slate/src/editor/unhang-range.ts","../../../node_modules/slate/src/editor/without-normalizing.ts","../../../node_modules/slate/src/editor/should-merge-nodes-remove-prev-node.ts","../../../node_modules/slate/src/transforms-text/delete-text.ts","../../../node_modules/slate/src/transforms-text/insert-fragment.ts","../../../node_modules/slate/src/transforms-selection/collapse.ts","../../../node_modules/slate/src/transforms-selection/deselect.ts","../../../node_modules/slate/src/transforms-selection/move.ts","../../../node_modules/slate/src/transforms-selection/select.ts","../../../node_modules/slate/src/transforms-selection/set-point.ts","../../../node_modules/slate/src/transforms-selection/set-selection.ts","../../../node_modules/slate/src/transforms-node/insert-nodes.ts","../../../node_modules/slate/src/transforms-node/lift-nodes.ts","../../../node_modules/slate/src/transforms-node/merge-nodes.ts","../../../node_modules/slate/src/transforms-node/move-nodes.ts","../../../node_modules/slate/src/transforms-node/remove-nodes.ts","../../../node_modules/slate/src/transforms-node/set-nodes.ts","../../../node_modules/slate/src/transforms-node/split-nodes.ts","../../../node_modules/slate/src/transforms-node/unset-nodes.ts","../../../node_modules/slate/src/transforms-node/unwrap-nodes.ts","../../../node_modules/slate/src/transforms-node/wrap-nodes.ts","../../../node_modules/slate/src/create-editor.ts","../src/lib/plugins/affinity/queries/getMarkBoundaryAffinity.ts","../src/lib/plugins/affinity/queries/isNodeAffinity.ts","../src/lib/plugins/affinity/transforms/setAffinitySelection.ts","../src/lib/plugins/debug/DebugPlugin.ts","../src/lib/plugins/dom/DOMPlugin.ts","../src/lib/plugins/dom/withScrolling.ts","../src/lib/plugins/html/HtmlPlugin.ts","../src/lib/plugins/html/constants.ts","../src/lib/plugins/html/utils/isHtmlElement.ts","../src/lib/plugins/html/utils/traverseHtmlNode.ts","../src/lib/plugins/html/utils/traverseHtmlElements.ts","../src/lib/plugins/html/utils/cleanHtmlBrElements.ts","../src/lib/plugins/html/utils/cleanHtmlCrLf.ts","../src/lib/plugins/html/utils/cleanHtmlEmptyElements.ts","../src/lib/plugins/html/utils/replaceTagName.ts","../src/lib/plugins/html/utils/cleanHtmlFontElements.ts","../src/lib/plugins/html/utils/isHtmlFragmentHref.ts","../src/lib/plugins/html/utils/unwrapHtmlElement.ts","../src/lib/plugins/html/utils/cleanHtmlLinkElements.ts","../src/lib/plugins/html/utils/isHtmlText.ts","../src/lib/plugins/html/utils/traverseHtmlTexts.ts","../src/lib/plugins/html/utils/cleanHtmlTextNodes.ts","../src/lib/plugins/html/utils/inlineTagNames.ts","../src/lib/plugins/html/utils/isHtmlInlineElement.ts","../src/lib/plugins/html/utils/isHtmlBlockElement.ts","../src/lib/plugins/html/utils/isHtmlTable.ts","../src/lib/plugins/html/utils/copyBlockMarksToSpanChild.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseString.ts","../src/lib/plugins/html/utils/collapse-white-space/isLastNonEmptyTextOfInlineFormattingContext.ts","../src/lib/plugins/html/utils/collapse-white-space/stateTransforms.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpaceText.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpaceNode.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpaceChildren.ts","../src/lib/plugins/html/utils/collapse-white-space/inferWhiteSpaceRule.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpaceElement.ts","../src/lib/plugins/html/utils/collapse-white-space/collapseWhiteSpace.ts","../src/lib/plugins/html/utils/htmlBodyToFragment.ts","../src/lib/plugins/html/utils/deserializeHtmlNodeChildren.ts","../src/lib/plugins/html/utils/htmlBrToNewLine.ts","../src/lib/plugins/html/utils/htmlElementToElement.ts","../src/lib/plugins/html/utils/pluginDeserializeHtml.ts","../src/lib/plugins/html/utils/getDataNodeProps.ts","../src/lib/plugins/html/utils/pipeDeserializeHtmlElement.ts","../src/lib/plugins/html/utils/htmlElementToLeaf.ts","../src/lib/plugins/html/utils/pipeDeserializeHtmlLeaf.ts","../src/lib/plugins/html/utils/htmlTextNodeToString.ts","../src/lib/plugins/html/utils/deserializeHtmlNode.ts","../src/lib/plugins/html/utils/deserializeHtmlElement.ts","../src/lib/plugins/html/utils/htmlStringToDOMNode.ts","../src/lib/plugins/html/utils/deserializeHtml.ts","../src/lib/plugins/html/utils/findHtmlElement.ts","../src/lib/plugins/html/utils/getHtmlComments.ts","../src/lib/plugins/html/utils/isHtmlComment.ts","../src/lib/plugins/html/utils/isOlSymbol.ts","../src/lib/plugins/html/utils/parseHtmlDocument.ts","../src/lib/plugins/html/utils/parseHtmlElement.ts","../src/lib/plugins/html/utils/postCleanHtml.ts","../src/lib/plugins/html/utils/removeHtmlSurroundings.ts","../src/lib/plugins/html/utils/preCleanHtml.ts","../src/lib/plugins/html/utils/traverseHtmlComments.ts","../src/lib/plugins/html/utils/removeHtmlNodesBetweenComments.ts","../src/lib/plugins/length/LengthPlugin.ts","../src/lib/plugins/node-id/NodeIdPlugin.ts","../src/lib/plugins/node-id/withNodeId.ts","../src/lib/plugins/slate-extension/SlateExtensionPlugin.ts","../src/internal/plugin/pipeNormalizeInitialValue.ts","../src/lib/plugins/slate-extension/transforms/init.ts","../src/lib/plugins/slate-extension/transforms/insertExitBreak.ts","../src/lib/plugins/slate-extension/transforms/resetBlock.ts","../src/lib/plugins/slate-extension/transforms/setValue.ts","../src/lib/utils/omitPluginContext.ts","../src/lib/utils/overridePluginsByKey.ts","../src/lib/utils/pipeInsertDataQuery.ts","../src/lib/plugins/ParserPlugin.ts","../src/lib/plugins/getCorePlugins.ts","../src/lib/libs/nanoid.ts","../src/lib/libs/zustand.ts"],"sourcesContent":["import {\n  type Editor,\n  type TSelection,\n  type Value,\n  createEditor,\n} from '@udecode/slate';\nimport { nanoid } from 'nanoid';\n\nimport type { AnyPluginConfig, NodeComponents } from '../plugin/BasePlugin';\nimport type { AnySlatePlugin } from '../plugin/SlatePlugin';\nimport type { NodeIdConfig } from '../plugins/node-id/NodeIdPlugin';\nimport type { InferPlugins, SlateEditor, TSlateEditor } from './SlateEditor';\n\nimport { resolvePlugins } from '../../internal/plugin/resolvePlugins';\nimport { createSlatePlugin } from '../plugin/createSlatePlugin';\nimport { getPluginType, getSlatePlugin } from '../plugin/getSlatePlugin';\nimport { type CorePlugin, getCorePlugins } from '../plugins/getCorePlugins';\n\nexport type BaseWithSlateOptions<P extends AnyPluginConfig = CorePlugin> = {\n  /**\n   * Unique identifier for the editor instance.\n   *\n   * @default nanoid()\n   */\n  id?: string;\n  /**\n   * Determines which mark/element to apply at boundaries between different\n   * marks, based on cursor movement using the left/right arrow keys.\n   *\n   * Example: <text bold>Bold</text><cursor><text italic>Italic</text>\n   *\n   * If the cursor moved here from the left (via → key), typing applies\n   * **bold**.\n   *\n   * If the cursor moved here from the right (via ← key), typing applies\n   * _italic_.\n   *\n   * Without mark affinity, the preceding mark (**bold**) is always applied\n   * regardless of direction.\n   *\n   * @default true\n   */\n  affinity?: boolean;\n  /**\n   * Select the editor after initialization.\n   *\n   * @default false\n   *\n   * - `true` | 'end': Select the end of the editor\n   * - `false`: Do not select anything\n   * - `'start'`: Select the start of the editor\n   */\n  autoSelect?: boolean | 'end' | 'start';\n  /** Specifies the component for each plugin key. */\n  components?: NodeComponents;\n  /** Specifies the component for each plugin key. */\n  // components?: Partial<\n  //   Record<KeyofNodePlugins<InferPlugins<P[]>>, NodeComponent | null>\n  // >;\n  /**\n   * Specifies the maximum number of characters allowed in the editor. When the\n   * limit is reached, further input will be prevented.\n   */\n  maxLength?: number;\n  /**\n   * Configuration for automatic node ID generation and management.\n   *\n   * Unless set to `false`, the editor automatically adds unique IDs to nodes\n   * through the core NodeIdPlugin:\n   *\n   * - Normalizes the initial value for missing IDs\n   * - Adds IDs to new nodes during insertion\n   * - Preserves or reuses IDs on undo/redo and copy/paste operations\n   * - Handles ID conflicts and duplicates\n   *\n   * @default { idKey: 'id', filterInline: true, filterText: true, idCreator: () => nanoid(10) }\n   */\n  nodeId?: NodeIdConfig['options'] | boolean;\n  // override?: {\n  //   components?: Partial<\n  //     Record<KeyofNodePlugins<InferPlugins<P[]>>, NodeComponent | null>\n  //   >;\n  // };\n  /**\n   * Array of plugins to be loaded into the editor. Plugins extend the editor's\n   * functionality and define custom behavior.\n   */\n  plugins?: P[];\n  /**\n   * Editor read-only initial state. For dynamic read-only control, use the\n   * `Plate.readOnly` prop instead.\n   *\n   * @default false\n   */\n  readOnly?: boolean;\n  /**\n   * Initial selection state for the editor. Defines where the cursor should be\n   * positioned when the editor loads.\n   */\n  selection?: TSelection;\n  /**\n   * When `true`, normalizes the initial `value` passed to the editor. This is\n   * useful when adding normalization rules to already existing content or when\n   * the initial value might not conform to the current schema.\n   *\n   * Note: Normalization may take time for large documents.\n   *\n   * @default false\n   */\n  shouldNormalizeEditor?: boolean;\n  /**\n   * When `true`, skips the initial value, selection, and normalization logic.\n   * Useful when the editor state is managed externally (e.g., with Yjs\n   * collaboration) or when you want to manually control the initialization\n   * process.\n   *\n   * @default false\n   */\n  skipInitialization?: boolean;\n};\n\nexport type WithSlateOptions<\n  V extends Value = Value,\n  P extends AnyPluginConfig = CorePlugin,\n> = BaseWithSlateOptions<P> &\n  Pick<\n    Partial<AnySlatePlugin>,\n    | 'api'\n    | 'decorate'\n    | 'extendEditor'\n    | 'inject'\n    | 'normalizeInitialValue'\n    | 'options'\n    | 'override'\n    | 'transforms'\n  > & {\n    // override?: {\n    //   /** Enable or disable plugins */\n    //   enabled?: Partial<Record<KeyofPlugins<InferPlugins<P[]>>, boolean>>;\n    //   plugins?: Partial<\n    //     Record<\n    //       KeyofPlugins<InferPlugins<P[]>>,\n    //       PartialEditorPlugin<AnyPluginConfig>\n    //     >\n    //   >;\n    // };\n    /**\n     * Initial content for the editor.\n     *\n     * Can be:\n     *\n     * - A static value (array of nodes)\n     * - An HTML string that will be deserialized\n     * - A function that returns a value or Promise<value>\n     * - `null` for an empty editor\n     *\n     * @default [{ type: 'p'; children: [{ text: '' }] }]\n     */\n    value?: ((editor: SlateEditor) => Promise<V> | V) | V | string | null;\n    /** Function to configure the root plugin */\n    rootPlugin?: (plugin: AnySlatePlugin) => AnySlatePlugin;\n  };\n\n/**\n * Applies Plate enhancements to an editor instance (non-React version).\n *\n * @remarks\n *   This function supports server-side usage as it doesn't include React-specific\n *   features like component rendering or hooks integration.\n * @see {@link createSlateEditor} for a higher-level non-React editor creation function.\n * @see {@link createPlateEditor} for a React-specific version of editor creation.\n * @see {@link usePlateEditor} for a memoized React version.\n * @see {@link withPlate} for the React-specific enhancement function.\n */\nexport const withSlate = <\n  V extends Value = Value,\n  P extends AnyPluginConfig = CorePlugin,\n>(\n  e: Editor,\n  {\n    id,\n    affinity = true,\n    autoSelect,\n    maxLength,\n    nodeId,\n    plugins = [],\n    readOnly = false,\n    rootPlugin,\n    selection,\n    shouldNormalizeEditor,\n    skipInitialization,\n    value,\n    ...pluginConfig\n  }: WithSlateOptions<V, P> = {}\n): TSlateEditor<V, InferPlugins<P[]>> => {\n  const editor = e as SlateEditor;\n\n  editor.id = id ?? editor.id ?? nanoid();\n  editor.meta.key = editor.meta.key ?? nanoid();\n  editor.meta.isFallback = false;\n  editor.dom = {\n    composing: false,\n    currentKeyboardEvent: null,\n    focused: false,\n    prevSelection: null,\n    readOnly,\n  };\n\n  editor.getApi = () => editor.api as any;\n  editor.getTransforms = () => editor.transforms as any;\n  editor.getPlugin = (plugin) => getSlatePlugin(editor, plugin) as any;\n  editor.getType = (pluginKey) => getPluginType(editor, pluginKey);\n  editor.getInjectProps = (plugin) => {\n    const nodeProps =\n      editor.getPlugin<AnySlatePlugin>(plugin).inject?.nodeProps ?? ({} as any);\n\n    nodeProps.nodeKey = nodeProps.nodeKey ?? editor.getType(plugin.key);\n    nodeProps.styleKey = nodeProps.styleKey ?? nodeProps.nodeKey;\n\n    return nodeProps;\n  };\n  editor.getOptionsStore = (plugin) => {\n    return editor.getPlugin(plugin).optionsStore;\n  };\n  editor.getOptions = (plugin) => {\n    const store = editor.getOptionsStore(plugin);\n\n    if (!store) return editor.getPlugin(plugin).options;\n\n    return editor.getOptionsStore(plugin).get('state');\n  };\n  editor.getOption = (plugin, key, ...args) => {\n    const store = editor.getOptionsStore(plugin);\n\n    if (!store) return editor.getPlugin(plugin).options[key];\n\n    if (!(key in store.get('state')) && !(key in store.selectors)) {\n      editor.api.debug.error(\n        `editor.getOption: ${key as string} option is not defined in plugin ${plugin.key}.`,\n        'OPTION_UNDEFINED'\n      );\n      return;\n    }\n\n    return (store.get as any)(key, ...args);\n  };\n  editor.setOption = (plugin: any, key: any, ...args: any) => {\n    const store = editor.getOptionsStore(plugin);\n\n    if (!store) return;\n\n    if (!(key in store.get('state'))) {\n      editor.api.debug.error(\n        `editor.setOption: ${key} option is not defined in plugin ${plugin.key}.`,\n        'OPTION_UNDEFINED'\n      );\n      return;\n    }\n\n    (store.set as any)(key, ...args);\n  };\n  editor.setOptions = (plugin: any, options: any) => {\n    const store = editor.getOptionsStore(plugin);\n\n    if (!store) return;\n    if (typeof options === 'object') {\n      store.set('state', (draft: any) => {\n        Object.assign(draft, options);\n      });\n    } else if (typeof options === 'function') {\n      store.set('state', options);\n    }\n  };\n\n  // Plugin initialization code\n  const corePlugins = getCorePlugins({\n    affinity,\n    maxLength,\n    nodeId,\n    plugins,\n  });\n\n  let rootPluginInstance = createSlatePlugin({\n    key: 'root',\n    priority: 10_000,\n    ...pluginConfig,\n    override: {\n      ...pluginConfig.override,\n      components: {\n        ...pluginConfig.components,\n        ...pluginConfig.override?.components,\n      },\n    },\n    plugins: [...corePlugins, ...plugins],\n  });\n\n  // Apply rootPlugin configuration if provided\n  if (rootPlugin) {\n    rootPluginInstance = rootPlugin(rootPluginInstance) as any;\n  }\n\n  resolvePlugins(editor, [rootPluginInstance]);\n\n  /** Ignore normalizeNode overrides if shouldNormalizeNode returns false */\n  const normalizeNode = editor.tf.normalizeNode;\n  editor.tf.normalizeNode = (...args) => {\n    if (!editor.api.shouldNormalizeNode(args[0])) {\n      return;\n    }\n\n    return normalizeNode(...args);\n  };\n  editor.normalizeNode = editor.tf.normalizeNode;\n\n  if (!skipInitialization) {\n    void editor.tf.init({\n      autoSelect,\n      selection,\n      shouldNormalizeEditor,\n      value,\n    });\n  }\n\n  return editor as any;\n};\n\nexport type CreateSlateEditorOptions<\n  V extends Value = Value,\n  P extends AnyPluginConfig = CorePlugin,\n> = WithSlateOptions<V, P> & {\n  /**\n   * Initial editor to be extended with `withSlate`.\n   *\n   * @default createEditor()\n   */\n  editor?: Editor;\n};\n\n/**\n * Creates a Slate editor (non-React version).\n *\n * This function creates a fully configured Plate editor instance that can be\n * used in non-React environments or server-side contexts. It applies all the\n * specified plugins and configurations to create a functional editor.\n *\n * Examples:\n *\n * ```ts\n * const editor = createSlateEditor({\n *   plugins: [ParagraphPlugin, HeadingPlugin],\n *   value: [{ type: 'p', children: [{ text: 'Hello world!' }] }],\n * });\n *\n * // Editor with custom configuration\n * const editor = createSlateEditor({\n *   plugins: [ParagraphPlugin],\n *   maxLength: 1000,\n *   nodeId: { idCreator: () => uuidv4() },\n *   autoSelect: 'end',\n * });\n *\n * // Server-side editor\n * const editor = createSlateEditor({\n *   plugins: [ParagraphPlugin],\n *   value: '<p>HTML content</p>',\n *   skipInitialization: true,\n * });\n * ```\n *\n * @see {@link createPlateEditor} for a React-specific version of editor creation.\n * @see {@link usePlateEditor} for a memoized React version.\n * @see {@link withSlate} for the underlying function that applies Slate enhancements to an editor.\n */\nexport const createSlateEditor = <\n  V extends Value = Value,\n  P extends AnyPluginConfig = CorePlugin,\n>({\n  editor = createEditor(),\n  ...options\n}: CreateSlateEditorOptions<V, P> = {}) => {\n  return withSlate<V, P>(editor, options);\n};\n","import {\n  assignLegacyApi,\n  assignLegacyTransforms,\n  syncLegacyMethods,\n} from '@udecode/slate';\nimport { isDefined } from '@udecode/utils';\nimport merge from 'lodash/merge.js';\nimport { createZustandStore } from 'zustand-x';\n\nimport type { SlateEditor, SlatePlugin, SlatePlugins } from '../../lib';\n\nimport { getEditorPlugin } from '../../lib/plugin';\nimport { mergePlugins } from '../utils/mergePlugins';\nimport { resolvePlugin } from './resolvePlugin';\n\n/**\n * Initialize and configure the editor's plugin system. This function sets up\n * the editor's plugins, resolving core and custom plugins, and applying any\n * overrides specified in the plugins.\n */\nexport const resolvePlugins = (\n  editor: SlateEditor,\n  plugins: SlatePlugins = []\n) => {\n  editor.plugins = {};\n  editor.meta.pluginList = [];\n  editor.meta.shortcuts = {} as Record<\n    string,\n    SlatePlugin['shortcuts'][string]\n  >;\n  editor.meta.components = {};\n  editor.meta.pluginCache = {\n    decorate: [],\n    handlers: {\n      onChange: [],\n    },\n    inject: {\n      nodeProps: [],\n    },\n    node: {\n      isContainer: [],\n      isElement: [],\n      isInline: [],\n      isLeaf: [],\n      isMarkableVoid: [],\n      isNotSelectable: [],\n      isStrictSiblings: [],\n      isVoid: [],\n      types: {},\n    },\n    normalizeInitialValue: [],\n    render: {\n      aboveEditable: [],\n      aboveNodes: [],\n      aboveSlate: [],\n      afterContainer: [],\n      afterEditable: [],\n      beforeContainer: [],\n      beforeEditable: [],\n      belowNodes: [],\n      belowRootNodes: [],\n    },\n    rules: {\n      match: [],\n    },\n    useHooks: [],\n  };\n\n  const resolvedPlugins = resolveAndSortPlugins(editor, plugins);\n\n  applyPluginsToEditor(editor, resolvedPlugins);\n\n  resolvePluginOverrides(editor);\n\n  resolvePluginStores(editor);\n\n  // Last pass\n  editor.meta.pluginList.forEach((plugin: SlatePlugin) => {\n    if (plugin.extendEditor) {\n      editor = plugin.extendEditor(getEditorPlugin(editor, plugin) as any);\n\n      // Sync any editor methods that were modified by extendEditor\n      syncLegacyMethods(editor);\n    }\n\n    // Sync overridden plugin methods to legacy editor methods\n    resolvePluginMethods(editor, plugin);\n\n    if (plugin.node?.isContainer) {\n      editor.meta.pluginCache.node.isContainer.push(plugin.key);\n    }\n\n    editor.meta.pluginCache.node.types[plugin.node.type] = plugin.key;\n\n    if (plugin.inject?.nodeProps) {\n      editor.meta.pluginCache.inject.nodeProps.push(plugin.key);\n    }\n\n    if (plugin.render?.node) {\n      editor.meta.components[plugin.key] = plugin.render.node;\n    }\n\n    if (plugin.node?.isLeaf) {\n      editor.meta.pluginCache.node.isLeaf.push(plugin.key);\n    }\n\n    if (plugin.node?.isElement) {\n      editor.meta.pluginCache.node.isElement.push(plugin.key);\n    }\n\n    if (plugin.node?.isInline) {\n      editor.meta.pluginCache.node.isInline.push(plugin.key);\n    }\n\n    if (plugin.node?.isVoid) {\n      editor.meta.pluginCache.node.isVoid.push(plugin.key);\n    }\n\n    if (plugin.node?.isMarkableVoid) {\n      editor.meta.pluginCache.node.isMarkableVoid.push(plugin.key);\n    }\n\n    if (plugin.node?.isStrictSiblings) {\n      editor.meta.pluginCache.node.isStrictSiblings.push(plugin.key);\n    }\n\n    if (plugin.node?.isSelectable === false) {\n      editor.meta.pluginCache.node.isNotSelectable.push(plugin.key);\n    }\n\n    if (plugin.render.aboveEditable) {\n      editor.meta.pluginCache.render.aboveEditable.push(plugin.key);\n    }\n\n    if (plugin.render.aboveSlate) {\n      editor.meta.pluginCache.render.aboveSlate.push(plugin.key);\n    }\n\n    if (plugin.render.afterEditable) {\n      editor.meta.pluginCache.render.afterEditable.push(plugin.key);\n    }\n\n    if (plugin.render.beforeEditable) {\n      editor.meta.pluginCache.render.beforeEditable.push(plugin.key);\n    }\n\n    if (plugin.rules?.match) {\n      editor.meta.pluginCache.rules.match.push(plugin.key);\n    }\n\n    if (plugin.render.afterContainer) {\n      editor.meta.pluginCache.render.afterContainer.push(plugin.key);\n    }\n\n    if (plugin.render.beforeContainer) {\n      editor.meta.pluginCache.render.beforeContainer.push(plugin.key);\n    }\n\n    if (plugin.render.belowRootNodes) {\n      editor.meta.pluginCache.render.belowRootNodes.push(plugin.key);\n    }\n\n    if (plugin.normalizeInitialValue) {\n      editor.meta.pluginCache.normalizeInitialValue.push(plugin.key);\n    }\n\n    if (plugin.decorate) {\n      editor.meta.pluginCache.decorate.push(plugin.key);\n    }\n\n    if (plugin.render.aboveNodes) {\n      editor.meta.pluginCache.render.aboveNodes.push(plugin.key);\n    }\n\n    if (plugin.render.belowNodes) {\n      editor.meta.pluginCache.render.belowNodes.push(plugin.key);\n    }\n\n    if ((plugin as any).useHooks) {\n      editor.meta.pluginCache.useHooks.push(plugin.key);\n    }\n\n    if ((plugin as any).handlers?.onChange) {\n      editor.meta.pluginCache.handlers.onChange.push(plugin.key);\n    }\n  });\n\n  resolvePluginShortcuts(editor);\n\n  return editor;\n};\n\nconst resolvePluginStores = (editor: SlateEditor) => {\n  // Create zustand stores for each plugin\n  editor.meta.pluginList.forEach((plugin) => {\n    let store = createZustandStore(plugin.options, {\n      mutative: true,\n      name: plugin.key,\n    });\n\n    // Apply option extensions\n    if (\n      (plugin as any).__selectorExtensions &&\n      (plugin as any).__selectorExtensions.length > 0\n    ) {\n      (plugin as any).__selectorExtensions.forEach((extension: any) => {\n        const extendedOptions = extension(getEditorPlugin(editor, plugin));\n\n        store = store.extendSelectors(() => extendedOptions);\n      });\n    }\n\n    plugin.optionsStore = store;\n  });\n};\n\nconst resolvePluginMethods = (editor: SlateEditor, plugin: any) => {\n  // Merge APIs\n  Object.entries(plugin.api).forEach(([apiKey, apiFunction]) => {\n    (editor.api as any)[apiKey] = apiFunction;\n  });\n\n  // Apply API and transform extensions\n  if (plugin.__apiExtensions && plugin.__apiExtensions.length > 0) {\n    plugin.__apiExtensions.forEach(\n      ({ extension, isOverride, isPluginSpecific, isTransform }: any) => {\n        const newExtensions = extension(getEditorPlugin(editor, plugin) as any);\n\n        if (isOverride) {\n          // Handle combined API and transforms override\n          if (newExtensions.api) {\n            merge(editor.api, newExtensions.api);\n            merge(plugin.api, newExtensions.api);\n            assignLegacyApi(editor, editor.api);\n          }\n          if (newExtensions.transforms) {\n            merge(editor.transforms, newExtensions.transforms);\n            merge(plugin.transforms, newExtensions.transforms);\n            assignLegacyTransforms(editor, newExtensions.transforms);\n          }\n        } else if (isTransform) {\n          // Handle transforms\n          if (isPluginSpecific) {\n            // Plugin-specific transform\n            if (!(editor.transforms as any)[plugin.key]) {\n              (editor.transforms as any)[plugin.key] = {};\n            }\n            if (!(plugin.transforms as any)[plugin.key]) {\n              (plugin.transforms as any)[plugin.key] = {};\n            }\n\n            merge((editor.transforms as any)[plugin.key], newExtensions);\n            merge((plugin.transforms as any)[plugin.key], newExtensions);\n          } else {\n            // Editor-wide transform\n            merge(editor.transforms, newExtensions);\n            merge(plugin.transforms, newExtensions);\n            assignLegacyTransforms(editor, newExtensions);\n          }\n        } else {\n          // Handle APIs\n          if (isPluginSpecific) {\n            // Plugin-specific API\n            if (!(editor.api as any)[plugin.key]) {\n              (editor.api as any)[plugin.key] = {};\n            }\n            if (!(plugin.api as any)[plugin.key]) {\n              (plugin.api as any)[plugin.key] = {};\n            }\n\n            merge((editor.api as any)[plugin.key], newExtensions);\n            merge((plugin.api as any)[plugin.key], newExtensions);\n          } else {\n            // Editor-wide API\n            merge(editor.api, newExtensions);\n            merge(plugin.api, newExtensions);\n            assignLegacyApi(editor, editor.api);\n          }\n        }\n      }\n    );\n    delete plugin.__apiExtensions;\n  }\n};\n\nconst resolvePluginShortcuts = (editor: SlateEditor) => {\n  editor.meta.shortcuts = {} as Record<\n    string,\n    SlatePlugin['shortcuts'][string]\n  >; // Initialize with a more specific type\n\n  editor.meta.pluginList.forEach((plugin) => {\n    Object.entries(plugin.shortcuts).forEach(([originalKey, hotkey]) => {\n      const namespacedKey = `${plugin.key}.${originalKey}`;\n\n      if (hotkey === null) {\n        // If hotkey is null, remove the namespaced shortcut\n        delete (\n          editor.meta.shortcuts as Record<\n            string,\n            SlatePlugin['shortcuts'][string]\n          >\n        )[namespacedKey];\n      } else if (hotkey && typeof hotkey === 'object') {\n        const resolvedHotkey = { ...hotkey } as NonNullable<\n          SlatePlugin['shortcuts'][string]\n        >;\n\n        // If no custom handler is provided, try to use plugin transform method as handler\n        if (!resolvedHotkey.handler) {\n          const pluginSpecificTransforms = (plugin.transforms as any)?.[\n            plugin.key\n          ];\n          const pluginSpecificApi = (plugin.api as any)?.[plugin.key];\n\n          if (pluginSpecificTransforms?.[originalKey]) {\n            resolvedHotkey.handler = () => {\n              return pluginSpecificTransforms[originalKey]();\n            };\n          } else if (pluginSpecificApi?.[originalKey]) {\n            resolvedHotkey.handler = () => {\n              return pluginSpecificApi[originalKey]();\n            };\n          }\n        }\n\n        // Set shortcut priority, falling back to plugin priority\n        resolvedHotkey.priority = resolvedHotkey.priority ?? plugin.priority;\n\n        (\n          editor.meta.shortcuts as Record<\n            string,\n            SlatePlugin['shortcuts'][string]\n          >\n        )[namespacedKey] = resolvedHotkey;\n      }\n    });\n  });\n};\n\nconst flattenAndResolvePlugins = (\n  editor: SlateEditor,\n  plugins: SlatePlugins\n): Map<string, SlatePlugin> => {\n  const pluginMap = new Map<string, SlatePlugin>();\n\n  const processPlugin = (plugin: SlatePlugin) => {\n    const resolvedPlugin = resolvePlugin(editor, plugin);\n\n    if (resolvedPlugin.key) {\n      const existingPlugin = pluginMap.get(resolvedPlugin.key);\n\n      if (existingPlugin) {\n        pluginMap.set(\n          resolvedPlugin.key,\n          mergePlugins(existingPlugin, resolvedPlugin)\n        );\n      } else {\n        pluginMap.set(resolvedPlugin.key, resolvedPlugin);\n      }\n    } else {\n      // If the plugin has no key, we just just skip it.\n    }\n\n    if (resolvedPlugin.plugins && resolvedPlugin.plugins.length > 0) {\n      resolvedPlugin.plugins.forEach(processPlugin);\n    }\n  };\n\n  plugins.forEach(processPlugin);\n\n  return pluginMap;\n};\n\nexport const resolveAndSortPlugins = (\n  editor: SlateEditor,\n  plugins: SlatePlugins\n): SlatePlugins => {\n  // Step 1: Resolve, flatten, and merge all plugins\n  const pluginMap = flattenAndResolvePlugins(editor, plugins);\n\n  // Step 2: Filter out disabled plugins\n  const enabledPlugins = Array.from(pluginMap.values()).filter(\n    (plugin) => plugin.enabled !== false\n  );\n\n  // Step 3: Sort plugins by priority\n  enabledPlugins.sort((a, b) => b.priority - a.priority);\n\n  // Step 4: Reorder based on dependencies\n  const orderedPlugins: SlatePlugins = [];\n  const visited = new Set<string>();\n\n  const visit = (plugin: SlatePlugin) => {\n    if (visited.has(plugin.key)) return;\n\n    visited.add(plugin.key);\n\n    plugin.dependencies?.forEach((depKey) => {\n      const depPlugin = pluginMap.get(depKey);\n\n      if (depPlugin) {\n        visit(depPlugin);\n      } else {\n        editor.api.debug.warn(\n          `Plugin \"${plugin.key}\" depends on missing plugin \"${depKey}\"`,\n          'PLUGIN_DEPENDENCY_MISSING'\n        );\n      }\n    });\n\n    orderedPlugins.push(plugin);\n  };\n\n  enabledPlugins.forEach(visit);\n\n  return orderedPlugins;\n};\n\nexport const applyPluginsToEditor = (\n  editor: SlateEditor,\n  plugins: SlatePlugins\n) => {\n  editor.meta.pluginList = plugins;\n  editor.plugins = Object.fromEntries(\n    plugins.map((plugin) => [plugin.key, plugin])\n  );\n};\n\nexport const resolvePluginOverrides = (editor: SlateEditor) => {\n  const applyOverrides = (plugins: SlatePlugin[]): SlatePlugin[] => {\n    let overriddenPlugins = [...plugins];\n\n    const enabledOverrides: Record<string, boolean> = {};\n    const componentOverrides: Record<\n      string,\n      { component: any; priority: number }\n    > = {};\n    const pluginOverrides: Record<string, Partial<SlatePlugin>> = {};\n\n    // Collect all overrides\n    for (const plugin of plugins) {\n      if (plugin.override.enabled) {\n        Object.assign(enabledOverrides, plugin.override.enabled);\n      }\n      // TODO react\n      if ((plugin.override as any).components) {\n        Object.entries((plugin.override as any).components).forEach(\n          ([key, component]) => {\n            if (\n              !componentOverrides[key] ||\n              plugin.priority > componentOverrides[key].priority\n            ) {\n              componentOverrides[key] = {\n                component,\n                priority: plugin.priority,\n              };\n            }\n          }\n        );\n      }\n      if (plugin.override.plugins) {\n        Object.entries(plugin.override.plugins).forEach(([key, value]) => {\n          pluginOverrides[key] = mergePlugins(pluginOverrides[key], value);\n\n          if (value.enabled !== undefined) {\n            enabledOverrides[key] = value.enabled;\n          }\n        });\n      }\n    }\n\n    // Apply overrides\n    overriddenPlugins = overriddenPlugins.map((p) => {\n      let updatedPlugin = { ...p };\n\n      // Apply plugin overrides\n      if (pluginOverrides[p.key]) {\n        updatedPlugin = mergePlugins(updatedPlugin, pluginOverrides[p.key]);\n      }\n      // Apply component overrides\n      // TODO react\n      if (\n        componentOverrides[p.key] &&\n        ((!(p as any).render.node && !(p as any).node.component) ||\n          componentOverrides[p.key].priority > p.priority)\n      ) {\n        (updatedPlugin as any).render.node =\n          componentOverrides[p.key].component;\n        (updatedPlugin as any).node.component =\n          componentOverrides[p.key].component;\n      }\n\n      // Apply enabled overrides\n      const enabled = enabledOverrides[p.key] ?? updatedPlugin.enabled;\n\n      if (isDefined(enabled)) {\n        updatedPlugin.enabled = enabled;\n      }\n\n      return updatedPlugin;\n    });\n\n    return overriddenPlugins\n      .filter((p) => p.enabled !== false)\n      .map((plugin) => ({\n        ...plugin,\n        plugins: applyOverrides(plugin.plugins || []),\n      }));\n  };\n\n  applyPluginsToEditor;\n\n  editor.meta.pluginList = applyOverrides(editor.meta.pluginList as any);\n  editor.plugins = Object.fromEntries(\n    editor.meta.pluginList.map((plugin) => [plugin.key, plugin])\n  );\n};\n","import { type Modify, isDefined } from '@udecode/utils';\n\nimport type { SlateEditor } from '../editor/SlateEditor';\nimport type { AnyPluginConfig, PluginConfig } from './BasePlugin';\nimport type {\n  SlatePlugin,\n  SlatePluginMethods,\n  SlatePlugins,\n} from './SlatePlugin';\n\nimport { isFunction } from '../../internal/utils/isFunction';\nimport { mergePlugins } from '../../internal/utils/mergePlugins';\n\ntype SlatePluginConfig<\n  K extends string = any,\n  O = {},\n  A = {},\n  T = {},\n  S = {},\n> = Omit<\n  Partial<\n    Modify<\n      SlatePlugin<PluginConfig<K, O, A, T, S>>,\n      { node?: Partial<SlatePlugin<PluginConfig<K, O, A, T, S>>['node']> }\n    >\n  >,\n  keyof SlatePluginMethods | 'optionsStore'\n>;\n\ntype TSlatePluginConfig<C extends AnyPluginConfig = PluginConfig> = Omit<\n  Partial<\n    Modify<\n      SlatePlugin<C>,\n      {\n        node?: Partial<SlatePlugin<C>['node']>;\n      }\n    >\n  >,\n  keyof SlatePluginMethods | 'optionsStore'\n>;\n\n/**\n * Creates a new Plate plugin with the given configuration.\n *\n * @remarks\n *   - The plugin's key is required and specified by the K generic.\n *   - The `__extensions` array stores functions to be applied when `resolvePlugin`\n *       is called with an editor.\n *   - The `extend` method adds new extensions to be applied later.\n *   - The `extendPlugin` method extends an existing plugin (including nested\n *       plugins) or adds a new one if not found.\n *\n * @example\n *   const myPlugin = createSlatePlugin<\n *     'myPlugin',\n *     MyOptions,\n *     MyApi,\n *     MyTransforms\n *   >({\n *     key: 'myPlugin',\n *     options: { someOption: true },\n *     transforms: { someTransform: () => {} },\n *   });\n *\n *   const extendedPlugin = myPlugin.extend({\n *     options: { anotherOption: false },\n *   });\n *\n *   const pluginWithNestedExtension = extendedPlugin.extendPlugin(\n *     nestedPlugin,\n *     { options: { nestedOption: true } }\n *   );\n *\n * @template K - The literal type of the plugin key.\n * @template O - The type of the plugin options.\n * @template A - The type of the plugin utilities.\n * @template T - The type of the plugin transforms.\n * @template S - The type of the plugin storage.\n * @param {Partial<SlatePlugin<K, O, A, T, S>>} config - The configuration\n *   object for the plugin.\n * @returns {SlatePlugin<K, O, A, T, S>} A new Plate plugin instance with the\n *   following properties and methods:\n *\n *   - All properties from the input config, merged with default values.\n *   - `configure`: A method to create a new plugin instance with updated options.\n *   - `extend`: A method to create a new plugin instance with additional\n *       configuration.\n *   - `extendPlugin`: A method to extend an existing plugin (including nested\n *       plugins) or add a new one if not found.\n */\nexport function createSlatePlugin<\n  K extends string = any,\n  O = {},\n  A = {},\n  T = {},\n  S = {},\n>(\n  config:\n    | ((editor: SlateEditor) => SlatePluginConfig<K, O, A, T, S>)\n    | SlatePluginConfig<K, O, A, T, S> = {}\n): SlatePlugin<PluginConfig<K, O, A, T, S>> {\n  let baseConfig: Partial<SlatePlugin<PluginConfig<K, O, A, T, S>>>;\n  let initialExtension: any;\n\n  if (isFunction(config)) {\n    baseConfig = { key: '' as K };\n    initialExtension = (editor: any) => config(editor);\n  } else {\n    baseConfig = config as any;\n  }\n\n  const key = baseConfig.key ?? '';\n\n  const plugin = mergePlugins(\n    {\n      key,\n      __apiExtensions: [],\n      __configuration: null,\n      __extensions: initialExtension ? [initialExtension] : [],\n      __selectorExtensions: [],\n      api: {},\n      dependencies: [],\n      editor: {},\n      handlers: {},\n      inject: {},\n      node: { type: key },\n      options: {},\n      override: {},\n      parser: {},\n      parsers: {},\n      plugins: [],\n      priority: 100,\n      render: {},\n      rules: {},\n      shortcuts: {},\n      transforms: {},\n    },\n    config\n  ) as unknown as SlatePlugin<PluginConfig<K, O, A, T, S>>;\n\n  if (plugin.node.isLeaf && !isDefined(plugin.node.isDecoration)) {\n    plugin.node.isDecoration = true;\n  }\n\n  plugin.configure = (config) => {\n    const newPlugin = { ...plugin };\n    newPlugin.__configuration = (ctx) =>\n      isFunction(config) ? config(ctx as any) : config;\n\n    return createSlatePlugin(newPlugin) as any;\n  };\n\n  plugin.configurePlugin = (p, config) => {\n    const newPlugin = { ...plugin };\n\n    const configureNestedPlugin = (\n      plugins: SlatePlugins\n    ): { found: boolean; plugins: SlatePlugins } => {\n      let found = false;\n\n      const updatedPlugins = plugins.map((nestedPlugin) => {\n        if (nestedPlugin.key === p.key) {\n          found = true;\n\n          return createSlatePlugin({\n            ...nestedPlugin,\n            __configuration: (ctx: any) =>\n              isFunction(config) ? config(ctx) : config,\n          } as any);\n        }\n        if (nestedPlugin.plugins && nestedPlugin.plugins.length > 0) {\n          const result = configureNestedPlugin(nestedPlugin.plugins);\n\n          if (result.found) {\n            found = true;\n\n            return { ...nestedPlugin, plugins: result.plugins };\n          }\n        }\n\n        return nestedPlugin;\n      });\n\n      return { found, plugins: updatedPlugins };\n    };\n\n    const result = configureNestedPlugin(newPlugin.plugins as any);\n    newPlugin.plugins = result.plugins as any;\n\n    // We're not adding a new plugin if not found\n\n    return createSlatePlugin(newPlugin);\n  };\n\n  plugin.extendEditorApi = (extension) => {\n    const newPlugin = { ...plugin };\n    newPlugin.__apiExtensions = [\n      ...(newPlugin.__apiExtensions as any),\n      { extension, isPluginSpecific: false },\n    ];\n\n    return createSlatePlugin(newPlugin) as any;\n  };\n\n  plugin.extendSelectors = (extension) => {\n    const newPlugin = { ...plugin };\n    newPlugin.__selectorExtensions = [\n      ...(newPlugin.__selectorExtensions as any),\n      extension,\n    ];\n\n    return createSlatePlugin(newPlugin) as any;\n  };\n\n  plugin.extendApi = (extension) => {\n    const newPlugin = { ...plugin };\n    newPlugin.__apiExtensions = [\n      ...(newPlugin.__apiExtensions as any),\n      { extension, isPluginSpecific: true },\n    ];\n\n    return createSlatePlugin(newPlugin) as any;\n  };\n\n  plugin.extendEditorTransforms = (extension) => {\n    const newPlugin = { ...plugin };\n    newPlugin.__apiExtensions = [\n      ...(newPlugin.__apiExtensions as any),\n      { extension, isPluginSpecific: false, isTransform: true },\n    ];\n\n    return createSlatePlugin(newPlugin) as any;\n  };\n\n  plugin.extendTransforms = (extension) => {\n    const newPlugin = { ...plugin };\n    newPlugin.__apiExtensions = [\n      ...(newPlugin.__apiExtensions as any),\n      { extension, isPluginSpecific: true, isTransform: true },\n    ];\n\n    return createSlatePlugin(newPlugin) as any;\n  };\n\n  plugin.overrideEditor = (extension) => {\n    const newPlugin = { ...plugin };\n    newPlugin.__apiExtensions = [\n      ...(newPlugin.__apiExtensions as any),\n      {\n        extension,\n        isOverride: true,\n        isPluginSpecific: false,\n        isTransform: true,\n      },\n    ];\n\n    return createSlatePlugin(newPlugin) as any;\n  };\n\n  plugin.extend = (extendConfig) => {\n    let newPlugin = { ...plugin };\n\n    if (isFunction(extendConfig)) {\n      newPlugin.__extensions = [\n        ...(newPlugin.__extensions as any),\n        extendConfig,\n      ];\n    } else {\n      newPlugin = mergePlugins(newPlugin, extendConfig as any);\n    }\n\n    return createSlatePlugin(newPlugin) as any;\n  };\n\n  plugin.clone = () => mergePlugins(plugin);\n\n  plugin.extendPlugin = (p, extendConfig) => {\n    const newPlugin = { ...plugin };\n\n    const extendNestedPlugin = (\n      plugins: SlatePlugins\n    ): { found: boolean; plugins: SlatePlugins } => {\n      let found = false;\n      const updatedPlugins = plugins.map((nestedPlugin) => {\n        if (nestedPlugin.key === p.key) {\n          found = true;\n\n          return createSlatePlugin({\n            ...nestedPlugin,\n            __extensions: [\n              ...(nestedPlugin.__extensions as any),\n              (ctx: any) =>\n                isFunction(extendConfig) ? extendConfig(ctx) : extendConfig,\n            ],\n          } as any);\n        }\n        if (nestedPlugin.plugins && nestedPlugin.plugins.length > 0) {\n          const result = extendNestedPlugin(nestedPlugin.plugins);\n\n          if (result.found) {\n            found = true;\n\n            return { ...nestedPlugin, plugins: result.plugins };\n          }\n        }\n\n        return nestedPlugin;\n      });\n\n      return { found, plugins: updatedPlugins };\n    };\n\n    const result = extendNestedPlugin(newPlugin.plugins as any);\n    newPlugin.plugins = result.plugins as any;\n\n    // If the plugin wasn't found at any level, add it at the top level\n    if (!result.found) {\n      newPlugin.plugins.push(\n        createSlatePlugin({\n          key: p.key,\n          __extensions: [\n            (ctx: any) =>\n              isFunction(extendConfig)\n                ? extendConfig(ctx as any)\n                : (extendConfig as any),\n          ],\n        } as any)\n      );\n    }\n\n    return createSlatePlugin(newPlugin);\n  };\n\n  plugin.withComponent = (component) => {\n    return plugin.extend({\n      node: { component },\n      render: { node: component },\n    }) as any;\n  };\n\n  return plugin;\n}\n\n/**\n * Explicitly typed version of `createSlatePlugin`.\n *\n * @remarks\n *   While `createSlatePlugin` uses type inference, this function requires an\n *   explicit type parameter. Use this when you need precise control over the\n *   plugin's type structure or when type inference doesn't provide the desired\n *   result.\n */\nexport function createTSlatePlugin<C extends AnyPluginConfig = PluginConfig>(\n  config:\n    | ((editor: SlateEditor) => TSlatePluginConfig<C>)\n    | TSlatePluginConfig<C> = {}\n): SlatePlugin<C> {\n  return createSlatePlugin(config as any) as any;\n}\n","export function isFunction(value: any): value is Function {\n  return typeof value === 'function';\n}\n","import mergeWith from 'lodash/mergeWith.js';\n\nimport type { SlatePlugin } from '../../lib';\n\nexport function mergePlugins<T>(basePlugin: T, ...sourcePlugins: any[]): T {\n  return mergeWith(\n    {},\n    basePlugin,\n    ...sourcePlugins,\n    (objValue: unknown, srcValue: unknown, key: keyof SlatePlugin) => {\n      // Overwrite array (including plugins) without cloning\n      if (Array.isArray(srcValue)) {\n        return srcValue;\n      }\n      // Shallow merge options\n      if (key === 'options') {\n        return { ...(objValue as any), ...(srcValue as any) };\n      }\n    }\n  );\n}\n","import type { SlateEditor } from '../editor';\nimport type { AnyPluginConfig, WithRequiredKey } from './BasePlugin';\nimport type {\n  InferConfig,\n  SlatePlugin,\n  SlatePluginContext,\n} from './SlatePlugin';\n\nexport function getEditorPlugin<\n  P extends AnyPluginConfig | SlatePlugin<AnyPluginConfig>,\n>(\n  editor: SlateEditor,\n  p: WithRequiredKey<P>\n): SlatePluginContext<InferConfig<P> extends never ? P : InferConfig<P>> {\n  const plugin = editor.getPlugin(p) as any;\n\n  return {\n    api: editor.api,\n    editor,\n    plugin: plugin as any,\n    setOption: ((keyOrOptions: any, value: any) =>\n      editor.setOption(plugin, keyOrOptions, value)) as any,\n    setOptions: ((options: any) => editor.setOptions(plugin, options)) as any,\n    tf: editor.transforms,\n    type: plugin.node.type,\n    getOption: (key: any, ...args: any) =>\n      (editor.getOption as any)(plugin, key, ...args),\n    getOptions: () => editor.getOptions(plugin),\n  };\n}\n","import merge from 'lodash/merge.js';\n\nimport type { SlateEditor } from '../../lib/editor';\nimport type { PluginConfig } from '../../lib/plugin/BasePlugin';\nimport type { AnySlatePlugin, SlatePlugin } from '../../lib/plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../lib/plugin/getEditorPlugin';\nimport { mergePlugins } from '../utils/mergePlugins';\n\n/**\n * Resolves and finalizes a plugin configuration for use in a Plate editor.\n *\n * This function processes a given plugin configuration, applying any extensions\n * and resolving nested plugins. It prepares the plugin for integration into the\n * Plate editor system by:\n *\n * 1. Cloning the plugin to avoid mutating the original\n * 2. Applying all stored extensions to the plugin\n * 3. Clearing the extensions array after application\n *\n * @example\n *   const plugin = createSlatePlugin({ key: 'myPlugin', ...otherOptions }).extend(...);\n *   const resolvedPlugin = resolvePlugin(editor, plugin);\n */\nexport const resolvePlugin = <P extends AnySlatePlugin>(\n  editor: SlateEditor,\n  _plugin: P\n): P => {\n  // Create a deep clone of the plugin\n  let plugin = mergePlugins({}, _plugin) as P;\n\n  plugin.__resolved = true;\n\n  // Apply the stored configuration first\n  if (plugin.__configuration) {\n    const configResult = plugin.__configuration(\n      getEditorPlugin(editor, plugin as any)\n    );\n\n    plugin = mergePlugins(plugin, configResult);\n\n    delete (plugin as any).__configuration;\n  }\n  // Apply all stored extensions\n  if (plugin.__extensions && plugin.__extensions.length > 0) {\n    plugin.__extensions.forEach((extension) => {\n      plugin = mergePlugins(\n        plugin,\n        extension(getEditorPlugin(editor, plugin as any))\n      );\n    });\n    plugin.__extensions = [];\n  }\n\n  const targetPluginToInject = plugin.inject?.targetPluginToInject;\n  const targetPlugins = plugin.inject?.targetPlugins;\n\n  if (targetPluginToInject && targetPlugins && targetPlugins.length > 0) {\n    plugin.inject = plugin.inject || {};\n    plugin.inject.plugins = merge(\n      {},\n      plugin.inject.plugins,\n      Object.fromEntries(\n        targetPlugins.map((targetPlugin) => {\n          const injectedPlugin = targetPluginToInject({\n            ...getEditorPlugin(editor, plugin as any),\n            targetPlugin,\n          });\n\n          return [targetPlugin, injectedPlugin];\n        })\n      )\n    );\n  }\n  if (plugin.node?.component) {\n    plugin.render.node = plugin.node.component;\n  }\n  if (plugin.render?.node) {\n    plugin.node.component = plugin.render.node;\n  }\n\n  validatePlugin(editor, plugin);\n\n  return plugin;\n};\n\nexport const validatePlugin = <\n  K extends string = any,\n  O = {},\n  A = {},\n  T = {},\n  S = {},\n>(\n  editor: SlateEditor,\n  plugin: SlatePlugin<PluginConfig<K, O, A, T, S>>\n) => {\n  if (!plugin.__extensions) {\n    editor.api.debug.error(\n      `Invalid plugin '${plugin.key}', you should use createSlatePlugin.`,\n      'USE_CREATE_PLUGIN'\n    );\n  }\n  if (plugin.node.isElement && plugin.node.isLeaf) {\n    editor.api.debug.error(\n      `Plugin ${plugin.key} cannot be both an element and a leaf.`,\n      'PLUGIN_NODE_TYPE'\n    );\n  }\n};\n","import type { SlateEditor } from '../editor';\nimport type {\n  AnyPluginConfig,\n  PluginConfig,\n  WithRequiredKey,\n} from './BasePlugin';\nimport type { AnySlatePlugin, SlatePlugin } from './SlatePlugin';\n\nimport { resolvePlugin } from '../../internal/plugin/resolvePlugin';\nimport { createSlatePlugin } from './createSlatePlugin';\n\n/** Get editor plugin by key or plugin object. */\nexport function getSlatePlugin<C extends AnyPluginConfig = PluginConfig>(\n  editor: SlateEditor,\n  p: WithRequiredKey<C>\n): C extends { node: any } ? C : SlatePlugin<C> {\n  let plugin = p as any;\n\n  const editorPlugin = editor.plugins[p.key] as any;\n\n  if (!editorPlugin) {\n    // When passing only { key }\n    if (!plugin.node) {\n      plugin = createSlatePlugin(plugin);\n    }\n\n    // Resolve is need when passing an external plugin with extensions (e.g. in withLink)\n    return plugin.__resolved ? plugin : resolvePlugin(editor, plugin);\n  }\n\n  return editorPlugin;\n}\n\n/** Get editor plugin type by key or plugin object. */\nexport function getPluginType(editor: SlateEditor, key: string): string {\n  const p = editor.getPlugin<AnySlatePlugin>({ key });\n\n  return p.node.type ?? p.key ?? '';\n}\n\n/** Get editor plugin types by key. */\nexport const getPluginTypes = (editor: SlateEditor, keys: string[]) =>\n  keys.map((key) => editor.getType(key));\n\nexport const getPluginKey = (\n  editor: SlateEditor,\n  type: string\n): string | undefined => editor.meta.pluginCache.node.types[type];\n\nexport const getPluginByType = (editor: SlateEditor, type: string) => {\n  const key = getPluginKey(editor, type);\n  if (!key) return null;\n\n  return editor.getPlugin({ key });\n};\n\nexport const getContainerTypes = (editor: SlateEditor) => {\n  return getPluginTypes(editor, editor.meta.pluginCache.node.isContainer);\n};\n","import { createSlatePlugin } from '../plugin';\n\n/**\n * Enables support for deserializing inserted content from Slate Ast format to\n * Slate format while apply a small bug fix.\n */\nexport const AstPlugin = createSlatePlugin({\n  key: 'ast',\n  parser: {\n    format: 'application/x-slate-fragment',\n    deserialize: ({ data }) => {\n      const decoded = decodeURIComponent(window.atob(data));\n      let parsed;\n\n      try {\n        parsed = JSON.parse(decoded);\n      } catch {\n        /* empty */\n      }\n\n      return parsed;\n    },\n  },\n});\n","import { withHistory } from '@udecode/slate';\n\nimport type { SlateEditor } from '../editor';\n\nimport { type ExtendEditor, createSlatePlugin } from '../plugin';\n\nexport const withPlateHistory: ExtendEditor = ({ editor }) =>\n  withHistory(editor as any) as any as SlateEditor;\n\n/** @see {@link withHistory} */\nexport const HistoryPlugin = createSlatePlugin({\n  key: 'history',\n  extendEditor: withPlateHistory,\n});\n","import { type PluginConfig, createSlatePlugin } from '../../plugin';\n\nexport type ParagraphConfig = PluginConfig<'p'>;\n\nexport const BaseParagraphPlugin = createSlatePlugin({\n  key: 'p',\n  node: {\n    isElement: true,\n  },\n  parsers: {\n    html: {\n      deserializer: {\n        rules: [\n          {\n            validNodeName: 'P',\n          },\n        ],\n        query: ({ element }) => element.style.fontFamily !== 'Consolas',\n      },\n    },\n  },\n  rules: {\n    merge: { removeEmpty: true },\n  },\n});\n","import { PathApi } from '@udecode/slate';\n\nimport type { OverrideEditor } from '../../plugin';\nimport type { BreakRules } from '../../plugin/BasePlugin';\n\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\n\nexport const withBreakRules: OverrideEditor = (ctx) => {\n  const {\n    editor,\n    tf: { insertBreak },\n  } = ctx;\n  const checkMatchRulesOverride = (\n    rule: string,\n    blockNode: any,\n    blockPath: any\n  ): BreakRules | null => {\n    const matchRulesKeys = editor.meta.pluginCache.rules.match;\n    for (const key of matchRulesKeys) {\n      const overridePlugin = editor.getPlugin({ key });\n      if (\n        overridePlugin.rules?.break &&\n        overridePlugin.rules?.match?.({\n          ...ctx,\n          node: blockNode,\n          path: blockPath,\n          rule: rule as any,\n        })\n      ) {\n        return overridePlugin.rules.break;\n      }\n    }\n    return null;\n  };\n\n  const executeBreakAction = (\n    action: string | undefined,\n    blockPath: any\n  ): boolean => {\n    if (action === 'reset') {\n      editor.tf.resetBlock({ at: blockPath });\n      return true;\n    }\n    if (action === 'exit') {\n      editor.tf.insertExitBreak();\n      return true;\n    }\n    if (action === 'deleteExit') {\n      editor.tf.deleteBackward('character');\n      editor.tf.insertExitBreak();\n      return true;\n    }\n    if (action === 'lineBreak') {\n      editor.tf.insertSoftBreak();\n      return true;\n    }\n    return false;\n  };\n\n  return {\n    transforms: {\n      insertBreak() {\n        if (editor.selection && editor.api.isCollapsed()) {\n          const block = editor.api.block();\n          if (block) {\n            const [blockNode, blockPath] = block;\n            const plugin = getPluginByType(editor, blockNode.type);\n\n            const breakRules = plugin?.rules.break;\n\n            // Handle 'empty' scenario\n            if (\n              editor.api.isEmpty(editor.selection, {\n                block: true,\n              })\n            ) {\n              const overrideBreakRules = checkMatchRulesOverride(\n                'break.empty',\n                blockNode,\n                blockPath\n              );\n              const effectiveBreakRules = overrideBreakRules || breakRules;\n              const emptyAction = effectiveBreakRules?.empty;\n\n              if (executeBreakAction(emptyAction, blockPath)) return;\n              // if 'default', fall through to breakRules.default or standard behavior\n            }\n\n            // Handle 'emptyLineEnd' scenario\n            if (\n              !editor.api.isEmpty(editor.selection, {\n                block: true,\n              }) &&\n              editor.api.isAt({ end: true })\n            ) {\n              const range = editor.api.range('before', editor.selection!);\n              if (range) {\n                const char = editor.api.string(range);\n                if (char === '\\n') {\n                  const overrideBreakRules = checkMatchRulesOverride(\n                    'break.emptyLineEnd',\n                    blockNode,\n                    blockPath\n                  );\n                  const effectiveBreakRules = overrideBreakRules || breakRules;\n                  const emptyLineEndAction = effectiveBreakRules?.emptyLineEnd;\n\n                  if (executeBreakAction(emptyLineEndAction, blockPath)) return;\n                }\n              }\n            }\n\n            // Handle 'default' scenario (or fallthrough from 'empty: default' or 'emptyLineEnd: default')\n            const overrideDefaultBreakRules = checkMatchRulesOverride(\n              'break.default',\n              blockNode,\n              blockPath\n            );\n            const defaultAction = (overrideDefaultBreakRules || breakRules)\n              ?.default;\n\n            if (executeBreakAction(defaultAction, blockPath)) return;\n\n            const overrideSplitResetBreakRules = checkMatchRulesOverride(\n              'break.splitReset',\n              blockNode,\n              blockPath\n            );\n            const splitReset =\n              overrideSplitResetBreakRules?.splitReset ??\n              breakRules?.splitReset;\n\n            if (splitReset) {\n              const isAtStart = editor.api.isAt({ start: true });\n\n              insertBreak();\n\n              editor.tf.resetBlock({\n                at: isAtStart ? blockPath : PathApi.next(blockPath),\n              });\n              return;\n            }\n          }\n        }\n\n        // Standard Slate insertBreak if no custom breakRules handled it\n        insertBreak();\n      },\n    },\n  };\n};\n","import { PointApi, RangeApi } from '@udecode/slate';\n\nimport type { OverrideEditor } from '../../plugin';\nimport type { DeleteRules } from '../../plugin/BasePlugin';\n\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\n\nexport const withDeleteRules: OverrideEditor = (ctx) => {\n  const {\n    editor,\n    tf: { deleteBackward, deleteForward, deleteFragment },\n  } = ctx;\n\n  const resetMarks = () => {\n    if (editor.api.isAt({ start: true })) {\n      editor.tf.removeMarks();\n    }\n  };\n\n  const checkMatchRulesOverride = (\n    rule: string,\n    blockNode: any,\n    blockPath: any\n  ): DeleteRules | null => {\n    const matchRulesKeys = editor.meta.pluginCache.rules.match;\n    for (const key of matchRulesKeys) {\n      const overridePlugin = editor.getPlugin({ key });\n      if (\n        overridePlugin.rules?.delete &&\n        overridePlugin.rules?.match?.({\n          ...ctx,\n          node: blockNode,\n          path: blockPath,\n          rule: rule as any,\n        })\n      ) {\n        return overridePlugin.rules.delete;\n      }\n    }\n    return null;\n  };\n\n  const executeDeleteAction = (\n    action: string | undefined,\n    blockPath: any\n  ): boolean => {\n    if (action === 'reset') {\n      editor.tf.resetBlock({ at: blockPath });\n      return true;\n    }\n    return false;\n  };\n\n  return {\n    transforms: {\n      deleteBackward(unit) {\n        if (editor.selection && editor.api.isCollapsed()) {\n          const block = editor.api.block();\n          if (block) {\n            const [blockNode, blockPath] = block;\n            const plugin = getPluginByType(editor, blockNode.type);\n\n            const deleteRules = plugin?.rules.delete;\n\n            // Handle 'start' scenario\n            if (editor.api.isAt({ start: true })) {\n              const overrideDeleteRules = checkMatchRulesOverride(\n                'delete.start',\n                blockNode,\n                blockPath\n              );\n              const effectiveDeleteRules = overrideDeleteRules || deleteRules;\n              const startAction = effectiveDeleteRules?.start;\n\n              if (executeDeleteAction(startAction, blockPath)) {\n                return;\n              }\n            }\n\n            // Handle 'empty' scenario\n            if (editor.api.isEmpty(editor.selection, { block: true })) {\n              const overrideDeleteRules = checkMatchRulesOverride(\n                'delete.empty',\n                blockNode,\n                blockPath\n              );\n              const effectiveDeleteRules = overrideDeleteRules || deleteRules;\n              const emptyAction = effectiveDeleteRules?.empty;\n\n              if (executeDeleteAction(emptyAction, blockPath)) return;\n            }\n          }\n\n          // Default behavior: reset first block when deleting at start of the document\n          if (\n            PointApi.equals(editor.selection!.anchor, editor.api.start([])!)\n          ) {\n            editor.tf.resetBlock({ at: [0] });\n            return;\n          }\n        }\n\n        deleteBackward(unit);\n        resetMarks();\n      },\n      deleteForward(unit) {\n        deleteForward(unit);\n        resetMarks();\n      },\n      deleteFragment(options) {\n        // Default behavior: reset entire editor when deleting full selection\n        if (\n          editor.selection &&\n          RangeApi.equals(editor.selection, editor.api.range([])!)\n        ) {\n          editor.tf.reset({\n            children: true,\n            select: true,\n          });\n          return;\n        }\n\n        deleteFragment(options);\n        resetMarks();\n      },\n    },\n  };\n};\n","import {\n  type Path,\n  type TElement,\n  ElementApi,\n  PathApi,\n  TextApi,\n} from '@udecode/slate';\n\nimport type { OverrideEditor } from '../../plugin';\nimport type { MergeRules } from '../../plugin/BasePlugin';\n\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\n\nexport const withMergeRules: OverrideEditor = (ctx) => {\n  const {\n    editor,\n    tf: { removeNodes },\n  } = ctx;\n\n  const checkMatchRulesOverride = (\n    rule: string,\n    blockNode: any,\n    blockPath: any\n  ): MergeRules | null => {\n    const matchRulesKeys = editor.meta.pluginCache.rules.match;\n    for (const key of matchRulesKeys) {\n      const overridePlugin = editor.getPlugin({ key });\n      if (\n        overridePlugin.rules.merge &&\n        overridePlugin.rules?.match?.({\n          ...ctx,\n          node: blockNode,\n          path: blockPath,\n          rule: rule as any,\n        })\n      ) {\n        return overridePlugin.rules.merge;\n      }\n    }\n    return null;\n  };\n\n  return {\n    api: {\n      shouldMergeNodes(prevNodeEntry, nextNodeEntry, { reverse } = {}) {\n        const [prevNode, prevPath] = prevNodeEntry;\n        const [, nextPath] = nextNodeEntry;\n        const [curNode, curPath] = reverse ? prevNodeEntry : nextNodeEntry;\n        const [targetNode, targetPath] = reverse\n          ? nextNodeEntry\n          : prevNodeEntry;\n\n        if (\n          TextApi.isText(prevNode) &&\n          prevNode.text === '' &&\n          prevPath.at(-1) !== 0\n        ) {\n          editor.tf.removeNodes({ at: prevPath });\n          return false;\n        }\n\n        const shouldRemove = (node: TElement, path: Path) => {\n          // Override Slate's default: typically only pure text blocks like paragraph and heading nodes want this to be true, so plugin default is false.\n          const plugin = getPluginByType(editor, node.type);\n          if (!plugin) {\n            return true;\n          }\n\n          const mergeRules = plugin.rules.merge;\n          if (!mergeRules?.removeEmpty) {\n            return false;\n          }\n\n          // Check if any plugin with matchRules overrides the merge behavior\n          const overrideMergeRules = checkMatchRulesOverride(\n            'merge.removeEmpty',\n            node,\n            path\n          );\n\n          if (overrideMergeRules?.removeEmpty === false) {\n            return false;\n          }\n\n          return true;\n        };\n\n        // Don't delete target void blocks by default\n        if (ElementApi.isElement(targetNode) && editor.api.isVoid(targetNode)) {\n          // Remove if plugin allows it\n          if (shouldRemove(targetNode, targetPath)) {\n            editor.tf.removeNodes({ at: prevPath });\n          }\n          // Remove current node if empty before selecting the void block\n          else if (\n            ElementApi.isElement(curNode) &&\n            editor.api.isEmpty(curNode)\n          ) {\n            editor.tf.removeNodes({ at: curPath });\n          }\n          return false;\n        }\n\n        // Not void, remove prevNode if sibling and empty\n        if (\n          ElementApi.isElement(prevNode) &&\n          editor.api.isEmpty(prevNode) &&\n          PathApi.isSibling(prevPath, nextPath) &&\n          shouldRemove(prevNode, prevPath)\n        ) {\n          editor.tf.removeNodes({ at: prevPath });\n          return false;\n        }\n\n        return true;\n      },\n    },\n    transforms: {\n      removeNodes(options = {}) {\n        if (options.event?.type === 'mergeNodes' && options.at) {\n          const nodeEntry = editor.api.node(options.at);\n          if (nodeEntry) {\n            const [node, path] = nodeEntry;\n\n            if (ElementApi.isElement(node)) {\n              // Check if this node should be removed based on merge rules\n              const plugin = getPluginByType(editor, node.type);\n              if (plugin) {\n                const mergeRules = plugin.rules.merge;\n\n                // Check for override rules\n                const overrideMergeRules = checkMatchRulesOverride(\n                  'merge.removeEmpty',\n                  node,\n                  path\n                );\n\n                const shouldNotRemove =\n                  overrideMergeRules?.removeEmpty === false ||\n                  mergeRules?.removeEmpty === false;\n\n                if (shouldNotRemove) {\n                  // Don't remove the node, just return without calling removeNodes\n                  return;\n                }\n              }\n            }\n          }\n        }\n\n        removeNodes(options);\n      },\n    },\n  };\n};\n","import { ElementApi } from '@udecode/slate';\n\nimport type { NormalizeRules } from '../../plugin/BasePlugin';\nimport type { OverrideEditor } from '../../plugin/SlatePlugin';\n\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\n\nexport const withNormalizeRules: OverrideEditor = (ctx) => {\n  const {\n    editor,\n    tf: { normalizeNode },\n  } = ctx;\n\n  const checkMatchRulesOverride = (\n    rule: string,\n    node: any,\n    path: any\n  ): NormalizeRules | null => {\n    const matchRulesKeys = editor.meta.pluginCache.rules.match;\n    for (const key of matchRulesKeys) {\n      const overridePlugin = editor.getPlugin({ key });\n      if (\n        overridePlugin.rules?.normalize &&\n        overridePlugin.rules?.match?.({\n          ...ctx,\n          node: node,\n          path: path,\n          rule: rule as any,\n        })\n      ) {\n        return overridePlugin.rules.normalize;\n      }\n    }\n    return null;\n  };\n\n  return {\n    transforms: {\n      normalizeNode([node, path]) {\n        if (ElementApi.isElement(node) && node.type) {\n          const plugin = getPluginByType(editor, node.type);\n          const normalizeRules = plugin?.rules.normalize;\n\n          // Handle 'removeEmpty' scenario\n          const overridenormalizeRules = checkMatchRulesOverride(\n            'normalize.removeEmpty',\n            node,\n            path\n          );\n          const effectivenormalizeRules =\n            overridenormalizeRules || normalizeRules;\n\n          if (\n            effectivenormalizeRules?.removeEmpty &&\n            editor.api.isEmpty(node)\n          ) {\n            editor.tf.removeNodes({ at: path });\n            return;\n          }\n        }\n\n        normalizeNode([node, path]);\n      },\n    },\n  };\n};\n","import type { OverrideEditor } from '../../plugin';\n\nimport { createSlatePlugin } from '../../plugin/createSlatePlugin';\nimport { BaseParagraphPlugin } from '../paragraph';\nimport { withBreakRules } from './withBreakRules';\nimport { withDeleteRules } from './withDeleteRules';\nimport { withMergeRules } from './withMergeRules';\nimport { withNormalizeRules } from './withNormalizeRules';\n\n/**\n * Merge and register all the inline types and void types from the plugins and\n * options, using `editor.api.isInline`, `editor.api.markableVoid` and\n * `editor.api.isVoid`\n */\nexport const withOverrides: OverrideEditor = ({\n  api: { isInline, isSelectable, isVoid, markableVoid },\n  editor,\n}) => {\n  // Use pre-computed arrays from plugin resolution\n  const voidTypes = editor.meta.pluginCache.node.isVoid;\n  const inlineTypes = editor.meta.pluginCache.node.isInline;\n  const markableVoidTypes = editor.meta.pluginCache.node.isMarkableVoid;\n  const notSelectableTypes = editor.meta.pluginCache.node.isNotSelectable;\n\n  return {\n    api: {\n      create: {\n        block: (node) => ({\n          children: [{ text: '' }],\n          type: editor.getType(BaseParagraphPlugin.key),\n          ...node,\n        }),\n      },\n      isInline(element) {\n        return inlineTypes.includes(element.type as any)\n          ? true\n          : isInline(element);\n      },\n      isSelectable(element) {\n        return notSelectableTypes.includes(element.type)\n          ? false\n          : isSelectable(element);\n      },\n      isVoid(element) {\n        return voidTypes.includes(element.type as any) ? true : isVoid(element);\n      },\n      markableVoid(element) {\n        return markableVoidTypes.includes(element.type)\n          ? true\n          : markableVoid(element);\n      },\n    },\n  };\n};\n\n/** Override the editor api and transforms based on the plugins. */\nexport const OverridePlugin = createSlatePlugin({\n  key: 'override',\n})\n  .overrideEditor(withOverrides)\n  .overrideEditor(withBreakRules)\n  .overrideEditor(withDeleteRules)\n  .overrideEditor(withMergeRules)\n  .overrideEditor(withNormalizeRules);\n","import type { Descendant } from '@udecode/slate';\n\nimport type { SlateEditor } from '../../lib/editor';\nimport type { ParserOptions } from '../../lib/plugin/BasePlugin';\nimport type { AnyEditorPlugin } from '../../lib/plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../lib/plugin';\n\n/** Pipe preInsert then insertFragment. */\nexport const pipeInsertFragment = (\n  editor: SlateEditor,\n  injectedPlugins: Partial<AnyEditorPlugin>[],\n  { fragment, ...options }: ParserOptions & { fragment: Descendant[] }\n) => {\n  editor.tf.withoutNormalizing(() => {\n    injectedPlugins.some((p) => {\n      return (\n        p.parser?.preInsert?.({\n          ...getEditorPlugin(editor, p as any),\n          fragment,\n          ...options,\n        }) === true\n      );\n    });\n\n    editor.tf.insertFragment(fragment);\n  });\n};\n","import type { SlateEditor } from '../../lib/editor';\nimport type { ParserOptions } from '../../lib/plugin/BasePlugin';\nimport type { AnyEditorPlugin } from '../../lib/plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../lib/plugin';\n\n/** Pipe editor.tf.insertData.transformData */\nexport const pipeTransformData = (\n  editor: SlateEditor,\n  plugins: Partial<AnyEditorPlugin>[],\n  { data, dataTransfer }: ParserOptions\n) => {\n  plugins.forEach((p) => {\n    const transformData = p.parser?.transformData;\n\n    if (!transformData) return;\n\n    data = transformData({\n      ...getEditorPlugin(editor, p as any),\n      data,\n      dataTransfer,\n    });\n  });\n\n  return data;\n};\n","import type { Descendant } from '@udecode/slate';\n\nimport type { SlateEditor } from '../../lib/editor';\nimport type { ParserOptions } from '../../lib/plugin/BasePlugin';\nimport type { AnyEditorPlugin } from '../../lib/plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../lib/plugin';\n\n/** Pipe editor.tf.insertData.transformFragment */\nexport const pipeTransformFragment = (\n  editor: SlateEditor,\n  plugins: Partial<AnyEditorPlugin>[],\n  { fragment, ...options }: ParserOptions & { fragment: Descendant[] }\n) => {\n  plugins.forEach((p) => {\n    const transformFragment = p.parser?.transformFragment;\n\n    if (!transformFragment) return;\n\n    fragment = transformFragment({\n      fragment,\n      ...options,\n      ...getEditorPlugin(editor, p as any),\n    });\n  });\n\n  return fragment;\n};\n","import {\n  type NodeEntry,\n  type NodeOf,\n  type Path,\n  type QueryNodeOptions,\n  type TNode,\n  NodeApi,\n  queryNode,\n} from '@udecode/slate';\n\nexport interface ApplyDeepToNodesOptions<N extends TNode> {\n  // Function to call on each node following the query.\n  apply: (\n    node: NodeOf<N>,\n    source: (() => Record<string, any>) | Record<string, any>\n  ) => void;\n  // The destination node object.\n  node: N;\n  // The source object. Can be a factory.\n  source: (() => Record<string, any>) | Record<string, any>;\n  path?: Path;\n  // Query to filter the nodes.\n  query?: QueryNodeOptions;\n}\n\n/** Recursively apply an operation to children nodes with a query. */\nexport const applyDeepToNodes = <N extends TNode>({\n  apply,\n  node,\n  path = [],\n  query,\n  source,\n}: ApplyDeepToNodesOptions<N>) => {\n  const entry: NodeEntry<N> = [node, path];\n\n  if (queryNode<N>(entry, query)) {\n    if (typeof source === 'function') {\n      apply(node, source());\n    } else {\n      apply(node, source);\n    }\n  }\n  if (!NodeApi.isAncestor(node)) return;\n\n  node.children.forEach((child, index) => {\n    applyDeepToNodes({\n      apply,\n      node: child as any,\n      path: path.concat([index]),\n      query,\n      source,\n    });\n  });\n};\n","import type { TNode } from '@udecode/slate';\n\nimport defaults from 'lodash/defaults.js';\n\nimport {\n  type ApplyDeepToNodesOptions,\n  applyDeepToNodes,\n} from './applyDeepToNodes';\n\n/** Recursively merge a source object to children nodes with a query. */\nexport const defaultsDeepToNodes = <N extends TNode>(\n  options: Omit<ApplyDeepToNodesOptions<N>, 'apply'>\n) => {\n  applyDeepToNodes({ ...options, apply: defaults });\n};\n","import { type Path, type TNode, ElementApi } from '@udecode/slate';\n\nimport type { SlateEditor } from '../editor';\nimport type { EditorPlugin } from '../plugin';\n\nimport { getKeyByType, getKeysByTypes } from './getKeysByTypes';\n\nexport const getInjectMatch = <E extends SlateEditor>(\n  editor: E,\n  plugin: EditorPlugin\n) => {\n  return (node: TNode, path: Path) => {\n    const {\n      inject: {\n        excludeBelowPlugins,\n        excludePlugins,\n        isBlock: _isBlock,\n        isElement: _isElement,\n        isLeaf,\n        maxLevel,\n        targetPlugins,\n      },\n    } = plugin;\n\n    const element = ElementApi.isElement(node) ? node : undefined;\n\n    if (_isElement && !element) return false;\n    if (_isBlock && (!element || !editor.api.isBlock(element))) return false;\n    if (isLeaf && element) return false;\n    if (element?.type) {\n      // Exclude plugins\n      if (excludePlugins?.includes(getKeyByType(editor, element.type))) {\n        return false;\n      }\n      // Target plugins\n      if (\n        targetPlugins &&\n        !targetPlugins.includes(getKeyByType(editor, element.type))\n      ) {\n        return false;\n      }\n    }\n    // Exclude below plugins\n    if (excludeBelowPlugins || maxLevel) {\n      if (maxLevel && path.length > maxLevel) {\n        return false;\n      }\n      if (excludeBelowPlugins) {\n        const excludeTypes = getKeysByTypes(editor, excludeBelowPlugins);\n        const isBelow = editor.api.above({\n          at: path,\n          match: (n) =>\n            ElementApi.isElement(n) && excludeTypes.includes(n.type),\n        });\n\n        if (isBelow) return false;\n      }\n    }\n\n    return true;\n  };\n};\n","import type { SlateEditor } from '../editor';\n\n/** Get plugin keys by types */\nexport const getKeysByTypes = (\n  editor: SlateEditor,\n  types: string[]\n): string[] => {\n  return Object.values(editor.plugins)\n    .filter((plugin) => types.includes(plugin.node.type))\n    .map((plugin) => plugin.key);\n};\n\n/** Get plugin key by type */\nexport const getKeyByType = (editor: SlateEditor, type: string): string => {\n  const plugin = Object.values(editor.plugins).find(\n    (plugin) => plugin.node.type === type\n  );\n\n  return plugin?.key ?? type;\n};\n","import type { SlateEditor } from '../editor';\nimport type { AnyEditorPlugin, SlatePlugins } from '../plugin/SlatePlugin';\n\n/**\n * Get all plugins having a defined `inject.plugins[plugin.key]`. It includes\n * `plugin` itself.\n */\nexport const getInjectedPlugins = (\n  editor: SlateEditor,\n  plugin: AnyEditorPlugin\n): Partial<AnyEditorPlugin>[] => {\n  const injectedPlugins: SlatePlugins = [];\n\n  [...editor.meta.pluginList].reverse().forEach((p) => {\n    const injectedPlugin = p.inject.plugins?.[plugin.key];\n\n    if (injectedPlugin) injectedPlugins.push(injectedPlugin as any);\n  });\n\n  return [plugin, ...injectedPlugins];\n};\n","import type { TElement, TText } from '@udecode/slate';\nimport type { AnyObject } from '@udecode/utils';\n\nimport pick from 'lodash/pick.js';\n\nimport type { AnyEditorPlugin } from '../plugin';\n\nimport { type SlateRenderNodeProps, getNodeDataAttributeKeys } from '../static';\n\nexport const getPluginNodeProps = ({\n  attributes: nodeAttributes,\n  node,\n  plugin,\n  props,\n}: {\n  props: SlateRenderNodeProps;\n  attributes?: AnyObject;\n  node?: TElement | TText;\n  plugin?: AnyEditorPlugin;\n}): any => {\n  const newProps: any = { ...props, attributes: { ...props.attributes } };\n\n  if (plugin?.node.props) {\n    const pluginNodeProps =\n      (typeof plugin.node.props === 'function'\n        ? plugin.node.props(newProps as any)\n        : plugin.node.props) ?? {};\n\n    newProps.attributes = {\n      ...newProps.attributes,\n      ...pluginNodeProps,\n    };\n  }\n  if (nodeAttributes && plugin) {\n    // Add data attributes to attributes if attributes is already set\n    newProps.attributes = {\n      ...newProps.attributes,\n      ...pick(\n        nodeAttributes,\n        /**\n         * WARNING: Improper use of `dangerouslyAllowAttributes` WILL make your\n         * application vulnerable to cross-site scripting (XSS) or information\n         * exposure attacks.\n         *\n         * @see {@link BasePluginNode.dangerouslyAllowAttributes}\n         */\n        ...(plugin.node.dangerouslyAllowAttributes ?? []),\n        [...(node ? getNodeDataAttributeKeys(node) : [])]\n      ),\n    };\n  }\n\n  // remove attributes values that are undefined\n  Object.keys(newProps.attributes).forEach((key) => {\n    if (newProps.attributes?.[key] === undefined) {\n      delete newProps.attributes?.[key];\n    }\n  });\n\n  return newProps;\n};\n","import React from 'react';\n\nimport type { SlateEditor } from '../editor';\n\nimport { SlateElement } from './components/slate-nodes';\nimport {\n  type SlateRenderElement,\n  pluginRenderElementStatic,\n} from './pluginRenderElementStatic';\nimport { getRenderNodeStaticProps } from './utils';\n\nexport const pipeRenderElementStatic = (\n  editor: SlateEditor,\n  {\n    renderElement: renderElementProp,\n  }: {\n    renderElement?: SlateRenderElement;\n  } = {}\n): SlateRenderElement => {\n  return function render(props) {\n    let element;\n\n    editor.meta.pluginCache.node.isElement.some((key) => {\n      const plugin = editor.getPlugin({ key });\n\n      element = pluginRenderElementStatic(editor, plugin)(props as any);\n\n      return !!element;\n    });\n\n    if (element) return element;\n    if (renderElementProp) {\n      return renderElementProp(props);\n    }\n\n    const ctxProps = getRenderNodeStaticProps({\n      editor,\n      props: { ...props } as any,\n    }) as any;\n\n    return (\n      <SlateElement {...ctxProps}>\n        {props.children}\n\n        {editor.meta.pluginCache.render.belowRootNodes.map((key) => {\n          const plugin = editor.getPlugin({ key }) as any;\n          const Component = plugin.render.belowRootNodes;\n\n          return <Component key={key} {...ctxProps} />;\n        })}\n      </SlateElement>\n    );\n  };\n};\n","/* eslint-disable perfectionist/sort-jsx-props */\nimport React from 'react';\n\nimport type { Path, TElement, TText } from '@udecode/slate';\nimport type { UnknownObject } from '@udecode/utils';\n\nimport { clsx } from 'clsx';\n\nimport type {\n  AnyPluginConfig,\n  PluginConfig,\n  SlatePluginContext,\n} from '../../plugin';\nimport type {\n  RenderElementProps,\n  RenderLeafProps,\n  RenderTextProps,\n} from '../../types';\n\nexport const useNodeAttributes = (props: any, ref?: any) => {\n  return {\n    ...props.attributes,\n    className:\n      clsx((props.attributes as any).className, props.className) || undefined,\n    ref,\n    style: { ...(props.attributes as any).style, ...props.style },\n  };\n};\n\nexport type SlateElementProps<\n  N extends TElement = TElement,\n  C extends AnyPluginConfig = PluginConfig,\n> = SlateNodeProps<C> &\n  RenderElementProps<N> & {\n    path: Path;\n  } & DeprecatedNodeProps;\n\ntype DeprecatedNodeProps = {\n  /**\n   * @deprecated Optional class to be merged with `attributes.className`.\n   * @default undefined\n   */\n  className?: string;\n  /**\n   * @deprecated Optional style to be merged with `attributes.style`\n   * @default undefined\n   */\n  style?: React.CSSProperties;\n};\n\nexport type SlateNodeProps<C extends AnyPluginConfig = PluginConfig> =\n  SlatePluginContext<C> & {\n    /**\n     * Optional ref to be merged with `attributes.ref`\n     *\n     * @default undefined\n     */\n    ref?: any;\n  };\n\nexport type SlateHTMLProps<\n  C extends AnyPluginConfig = PluginConfig,\n  T extends keyof HTMLElementTagNameMap = 'div',\n> = SlateNodeProps<C> & {\n  /** HTML attributes to pass to the underlying HTML element */\n  attributes: React.PropsWithoutRef<React.JSX.IntrinsicElements[T]> &\n    UnknownObject;\n  as?: T;\n  /** Class to be merged with `attributes.className` */\n  className?: string;\n  /** Style to be merged with `attributes.style` */\n  style?: React.CSSProperties;\n};\n\nexport type StyledSlateElementProps<\n  N extends TElement = TElement,\n  C extends AnyPluginConfig = PluginConfig,\n  T extends keyof HTMLElementTagNameMap = 'div',\n> = Omit<SlateElementProps<N, C>, keyof DeprecatedNodeProps> &\n  SlateHTMLProps<C, T>;\n\nexport const SlateElement = React.forwardRef(function SlateElement(\n  { as: Tag = 'div', children, ...props }: StyledSlateElementProps,\n  ref: React.ForwardedRef<HTMLDivElement>\n) {\n  const attributes = useNodeAttributes(props, ref);\n\n  const block = !!props.element.id && !!props.editor.api.isBlock(props.element);\n\n  return (\n    <Tag\n      data-slate-node=\"element\"\n      data-slate-inline={attributes['data-slate-inline']}\n      data-block-id={block ? props.element.id : undefined}\n      {...attributes}\n      style={\n        {\n          position: 'relative',\n          ...attributes?.style,\n        } as React.CSSProperties\n      }\n    >\n      {children}\n    </Tag>\n  );\n}) as <\n  N extends TElement = TElement,\n  C extends AnyPluginConfig = PluginConfig,\n  T extends keyof HTMLElementTagNameMap = 'div',\n>(\n  props: StyledSlateElementProps<N, C, T>\n) => React.ReactElement;\n\nexport type SlateTextProps<\n  N extends TText = TText,\n  C extends AnyPluginConfig = PluginConfig,\n> = SlateNodeProps<C> & RenderTextProps<N> & DeprecatedNodeProps;\n\nexport type StyledSlateTextProps<\n  N extends TText = TText,\n  C extends AnyPluginConfig = PluginConfig,\n  T extends keyof HTMLElementTagNameMap = 'span',\n> = Omit<SlateTextProps<N, C>, keyof DeprecatedNodeProps> &\n  SlateHTMLProps<C, T>;\n\nexport const SlateText = React.forwardRef<\n  HTMLSpanElement,\n  StyledSlateTextProps\n>(({ as: Tag = 'span', children, ...props }, ref) => {\n  const attributes = useNodeAttributes(props, ref);\n\n  return <Tag {...attributes}>{children}</Tag>;\n}) as <\n  N extends TText = TText,\n  C extends AnyPluginConfig = PluginConfig,\n  T extends keyof HTMLElementTagNameMap = 'span',\n>(\n  props: StyledSlateTextProps<N, C, T>\n) => React.ReactElement;\n\nexport type SlateLeafProps<\n  N extends TText = TText,\n  C extends AnyPluginConfig = PluginConfig,\n> = SlateNodeProps<C> &\n  RenderLeafProps<N> &\n  DeprecatedNodeProps & { inset?: boolean };\n\nexport type StyledSlateLeafProps<\n  N extends TText = TText,\n  C extends AnyPluginConfig = PluginConfig,\n  T extends keyof HTMLElementTagNameMap = 'span',\n> = Omit<SlateLeafProps<N, C>, keyof DeprecatedNodeProps> &\n  SlateHTMLProps<C, T>;\n\nconst NonBreakingSpace = () => (\n  <span style={{ fontSize: 0 }} contentEditable={false}>\n    {String.fromCodePoint(160)}\n  </span>\n);\n\nexport const SlateLeaf = React.forwardRef<\n  HTMLSpanElement,\n  StyledSlateLeafProps\n>(({ as: Tag = 'span', children, inset, ...props }, ref) => {\n  const attributes = useNodeAttributes(props, ref);\n\n  if (inset) {\n    return (\n      <>\n        <NonBreakingSpace />\n        <Tag {...attributes}>\n          {children}\n          <NonBreakingSpace />\n        </Tag>\n      </>\n    );\n  }\n\n  return <Tag {...attributes}>{children}</Tag>;\n}) as <\n  N extends TText = TText,\n  C extends AnyPluginConfig = PluginConfig,\n  T extends keyof HTMLElementTagNameMap = 'span',\n>({\n  className,\n  ...props\n}: StyledSlateLeafProps<N, C, T>) => React.ReactElement;\n","import React from 'react';\n\nimport type { SlateEditor } from '../editor';\nimport type { AnyEditorPlugin } from '../plugin';\nimport type { RenderElementProps } from '../types/RenderElementProps';\n\nimport { SlateElement } from './components/slate-nodes';\nimport { getPluginDataAttributes } from './utils';\nimport { getRenderNodeStaticProps } from './utils/getRenderNodeStaticProps';\n\nexport type SlateRenderElement = (\n  props: RenderElementProps\n) => React.ReactElement<any> | undefined;\n\nexport const pluginRenderElementStatic = (\n  editor: SlateEditor,\n  plugin: AnyEditorPlugin\n): SlateRenderElement =>\n  function render(nodeProps) {\n    if (nodeProps.element.type === plugin.node.type) {\n      const element = nodeProps.element;\n\n      const Component = editor.meta.components?.[plugin.key] as any;\n      const Element = Component ?? SlateElement;\n\n      let { children } = nodeProps;\n\n      const dataAttributes = getPluginDataAttributes(editor, plugin, element);\n\n      nodeProps = getRenderNodeStaticProps({\n        attributes: {\n          ...(element.attributes as any),\n          ...dataAttributes,\n        },\n        editor,\n        node: element,\n        plugin,\n        props: nodeProps as any,\n      }) as any;\n\n      editor.meta.pluginCache.render.belowNodes.forEach((key) => {\n        const hoc = editor.getPlugin({ key }).render.belowNodes!({\n          ...nodeProps,\n          key,\n        } as any);\n\n        if (hoc) {\n          children = hoc({ ...nodeProps, children } as any);\n        }\n      });\n\n      const defaultProps = Component ? {} : { as: plugin.render?.as };\n\n      let component: React.ReactNode = (\n        <Element {...defaultProps} {...nodeProps}>\n          {children}\n\n          {editor.meta.pluginCache.render.belowRootNodes.map((key) => {\n            const plugin = editor.getPlugin({ key }) as any;\n            const Component = plugin.render.belowRootNodes;\n\n            return <Component key={key} {...defaultProps} {...nodeProps} />;\n          })}\n        </Element>\n      );\n\n      editor.meta.pluginCache.render.aboveNodes.forEach((key) => {\n        const hoc = editor.getPlugin({ key }).render.aboveNodes!({\n          ...nodeProps,\n          key,\n        } as any);\n\n        if (hoc) {\n          component = hoc({ ...nodeProps, children: component } as any);\n        }\n      });\n\n      return component;\n    }\n  };\n","import React from 'react';\n\nexport function createStaticString({ text }: { text: string }) {\n  return React.createElement(\n    'span',\n    { 'data-slate-string': true },\n    text === '' ? '\\uFEFF' : text\n  );\n}\n","import { type TElement, type TText, TextApi } from '@udecode/slate';\nimport kebabCase from 'lodash/kebabCase.js';\n\nimport type { SlateEditor } from '../../editor';\n\nimport { type AnyEditorPlugin, getEditorPlugin } from '../../plugin';\n\nexport const getNodeDataAttributes = (\n  editor: SlateEditor,\n  node: TElement | TText,\n  {\n    isElement,\n    isLeaf,\n    isText,\n  }: { isElement?: boolean; isLeaf?: boolean; isText?: boolean }\n) => {\n  const dataAttributes = Object.keys(node).reduce((acc, key) => {\n    if (typeof node[key] === 'object') return acc;\n    if (isElement && key === 'children') return acc;\n    if ((isLeaf || isText) && key === 'text') return acc;\n\n    const plugin = editor.getPlugin({ key });\n\n    if (isLeaf && plugin?.node.isLeaf && plugin?.node.isDecoration !== true) {\n      return acc;\n    }\n\n    if (isText && plugin?.node.isLeaf && plugin?.node.isDecoration !== false) {\n      return acc;\n    }\n\n    const attributeName = keyToDataAttribute(key);\n\n    return { ...acc, [attributeName]: node[key] };\n  }, {});\n\n  return dataAttributes;\n};\n\nexport const getPluginDataAttributes = (\n  editor: SlateEditor,\n  plugin: AnyEditorPlugin,\n  node: TElement | TText\n) => {\n  const isElement = plugin.node.isElement;\n  const isLeaf = plugin.node.isLeaf && plugin.node.isDecoration === true;\n  const isText = plugin.node.isLeaf && plugin.node.isDecoration === false;\n\n  const dataAttributes = getNodeDataAttributes(editor, node, {\n    isElement,\n    isLeaf,\n    isText,\n  });\n\n  const customAttributes =\n    plugin.node.toDataAttributes?.({\n      ...(plugin ? (getEditorPlugin(editor, plugin) as any) : {}),\n      node,\n    }) ?? {};\n\n  return { ...dataAttributes, ...customAttributes };\n};\n\nexport const getNodeDataAttributeKeys = (node: TElement | TText) => {\n  return Object.keys(node)\n    .filter(\n      (key) =>\n        typeof node[key] !== 'object' &&\n        (!TextApi.isText(node) || key !== 'text')\n    )\n    .map((key) => keyToDataAttribute(key));\n};\n\nexport const keyToDataAttribute = (key: string) => {\n  return `data-slate-${kebabCase(key)}`;\n};\n","import type { TElement, TText } from '@udecode/slate';\nimport type { AnyObject } from '@udecode/utils';\n\nimport clsx from 'clsx';\n\nimport type { SlateEditor } from '../../editor';\nimport type { SlateRenderNodeProps } from '../types';\n\nimport { pipeInjectNodeProps } from '../../../internal/plugin/pipeInjectNodeProps';\nimport { type AnyEditorPlugin, getEditorPlugin } from '../../plugin';\nimport { getSlateClass } from '../../utils';\nimport { getPluginNodeProps } from '../../utils/getPluginNodeProps';\n\nexport const getRenderNodeStaticProps = ({\n  attributes: nodeAttributes,\n  editor,\n  node,\n  plugin,\n  props,\n}: {\n  editor: SlateEditor;\n  props: SlateRenderNodeProps;\n  attributes?: AnyObject;\n  node?: TElement | TText;\n  plugin?: AnyEditorPlugin;\n}): SlateRenderNodeProps => {\n  let newProps = {\n    ...props,\n    ...(plugin\n      ? (getEditorPlugin(editor, plugin) as any)\n      : {\n          api: editor.api,\n          editor,\n          tf: editor.transforms,\n        }),\n  };\n\n  const { className } = props;\n\n  const pluginProps = getPluginNodeProps({\n    attributes: nodeAttributes,\n    node,\n    plugin,\n    props: newProps,\n  });\n\n  newProps = {\n    ...pluginProps,\n    attributes: {\n      ...pluginProps.attributes,\n      className: clsx(getSlateClass(plugin?.node.type), className) || undefined,\n    },\n  };\n\n  newProps = pipeInjectNodeProps(\n    editor,\n    newProps,\n    (node) => editor.api.findPath(node)!\n  );\n\n  if (newProps.style && Object.keys(newProps.style).length === 0) {\n    delete newProps.style;\n  }\n\n  return newProps;\n};\n","import type { Path, TElement, TText } from '@udecode/slate';\n\nimport clsx from 'clsx';\n\nimport type { SlateEditor } from '../../lib/editor';\n\nimport { isEditOnly } from './isEditOnlyDisabled';\nimport { pluginInjectNodeProps } from './pluginInjectNodeProps';\n\n/** Inject plugin props, editor. */\nexport const pipeInjectNodeProps = (\n  editor: SlateEditor,\n  nodeProps: any,\n  getElementPath: (node: TElement | TText) => Path,\n  readOnly = false\n) => {\n  editor.meta.pluginCache.inject.nodeProps.forEach((key) => {\n    const plugin = editor.getPlugin({ key });\n\n    const newAttributes = pluginInjectNodeProps(\n      editor,\n      plugin,\n      nodeProps,\n      getElementPath\n    );\n\n    // Since `inject.nodeProps` can have hooks, we can't return early.\n    if (isEditOnly(readOnly, plugin, 'inject')) {\n      return;\n    }\n\n    if (!newAttributes) return;\n\n    const attributes = nodeProps.attributes;\n\n    nodeProps.attributes = {\n      ...attributes,\n      ...newAttributes,\n      className:\n        clsx(attributes?.className, newAttributes.className) || undefined,\n      style: {\n        ...attributes?.style,\n        ...newAttributes.style,\n      },\n    };\n  });\n\n  return nodeProps;\n};\n","const DEFAULT = {\n  handlers: true,\n  inject: true,\n  normalizeInitialValue: false,\n  render: true,\n};\n\n/**\n * Check if a plugin feature is disabled in read-only mode based on editOnly\n * configuration.\n *\n * @param plugin The plugin to check\n * @param isReadOnly Whether the editor is in read-only mode\n * @param feature The feature to check ('render' | 'handlers' | 'inject' |\n *   'normalizeInitialValue')\n * @returns True if the feature should be disabled\n */\nexport const isEditOnly = (\n  readOnly: boolean,\n  plugin: any,\n  feature: keyof typeof DEFAULT\n): boolean => {\n  if (!readOnly) return false;\n\n  // If editOnly is true, use the default value for the feature\n  if (plugin.editOnly === true) {\n    return DEFAULT[feature];\n  }\n\n  // If editOnly is an object, use its value if specified, otherwise use default\n  if (typeof plugin.editOnly === 'object') {\n    return plugin.editOnly[feature] ?? DEFAULT[feature];\n  }\n\n  return false;\n};\n","import type { Path, TElement, TText } from '@udecode/slate';\n\nimport { isDefined } from '@udecode/utils';\n\nimport type { SlateEditor } from '../../lib/editor';\nimport type {\n  EditorPlugin,\n  TransformOptions,\n} from '../../lib/plugin/SlatePlugin';\n\nimport {\n  type GetInjectNodePropsOptions,\n  type GetInjectNodePropsReturnType,\n  getEditorPlugin,\n} from '../../lib/plugin';\nimport { getInjectMatch } from '../../lib/utils/getInjectMatch';\n\n/**\n * Return if `element`, `text`, `nodeKey` is defined. Return if `node.type` is\n * not in `targetPlugins` (if defined). Return if `value = node[nodeKey]` is not\n * in `validNodeValues` (if defined). If `classNames[value]` is defined,\n * override `className` with it. If `styleKey` is defined, override `style` with\n * `[styleKey]: value`.\n */\nexport const pluginInjectNodeProps = (\n  editor: SlateEditor,\n  plugin: EditorPlugin,\n  nodeProps: GetInjectNodePropsOptions,\n  getElementPath: (node: TElement | TText) => Path\n): GetInjectNodePropsReturnType | undefined => {\n  const {\n    key,\n    inject: { nodeProps: injectNodeProps },\n  } = plugin;\n\n  const { element, text } = nodeProps;\n\n  const node = element ?? text;\n\n  if (!node) return;\n  if (!injectNodeProps) return;\n\n  const {\n    classNames,\n    defaultNodeValue,\n    nodeKey = editor.getType(key),\n    query,\n    styleKey = nodeKey as any,\n    transformClassName,\n    transformNodeValue,\n    transformProps,\n    transformStyle,\n    validNodeValues,\n  } = injectNodeProps;\n\n  const injectMatch = getInjectMatch(editor, plugin);\n\n  if (!injectMatch(node, getElementPath(node))) return;\n\n  const queryResult = query?.({\n    ...injectNodeProps,\n    ...(getEditorPlugin(editor, plugin) as any),\n    nodeProps,\n  });\n\n  if (query && !queryResult) {\n    return;\n  }\n\n  const nodeValue = node[nodeKey!] as any;\n\n  // early return if there is no reason to inject props\n  if (\n    !transformProps &&\n    (!isDefined(nodeValue) ||\n      (validNodeValues && !validNodeValues.includes(nodeValue)) ||\n      nodeValue === defaultNodeValue)\n  ) {\n    return;\n  }\n\n  const transformOptions: TransformOptions = {\n    ...nodeProps,\n    ...(getEditorPlugin(editor, plugin) as any),\n    nodeValue,\n  };\n  const value = transformNodeValue?.(transformOptions) ?? nodeValue;\n  transformOptions.value = value;\n\n  let newProps: GetInjectNodePropsReturnType = {};\n\n  if (element && nodeKey && nodeValue) {\n    newProps.className = `slate-${nodeKey}-${nodeValue}`;\n  }\n  if (classNames?.[nodeValue] || transformClassName) {\n    newProps.className =\n      transformClassName?.(transformOptions) ?? classNames?.[value];\n  }\n  if (styleKey) {\n    newProps.style =\n      transformStyle?.(transformOptions) ??\n      ({\n        [styleKey as string]: value,\n      } as any);\n  }\n  if (transformProps) {\n    newProps =\n      transformProps({ ...transformOptions, props: newProps }) ?? newProps;\n  }\n\n  return newProps;\n};\n","import type { NodeEntry, TRange } from '@udecode/slate';\n\nimport type { SlateEditor } from '../../editor';\nimport type { EditableProps } from '../../types/EditableProps';\n\nimport { getEditorPlugin } from '../../plugin';\n\n/**\n * @see {@link Decorate} .\n * Optimization: return undefined if empty list so Editable uses a memo.\n */\nexport const pipeDecorate = (\n  editor: SlateEditor,\n  decorateProp?:\n    | ((ctx: { editor: SlateEditor; entry: NodeEntry }) => TRange[] | undefined)\n    | null\n): EditableProps['decorate'] => {\n  if (editor.meta.pluginCache.decorate.length === 0 && !decorateProp) return;\n\n  return (entry: NodeEntry) => {\n    let ranges: TRange[] = [];\n\n    const addRanges = (newRanges?: TRange[]) => {\n      if (newRanges?.length) ranges = [...ranges, ...newRanges];\n    };\n\n    editor.meta.pluginCache.decorate.forEach((key) => {\n      const plugin = editor.getPlugin({ key });\n      addRanges(\n        plugin.decorate!({\n          ...(getEditorPlugin(editor, plugin) as any),\n          entry,\n        })\n      );\n    });\n\n    if (decorateProp) {\n      addRanges(\n        decorateProp({\n          editor,\n          entry,\n        })\n      );\n    }\n\n    return ranges;\n  };\n};\n","const classAttrRegExp = / class=\"([^\"]*)\"/g;\n\n/**\n * Remove all class names that do not start with one of preserveClassNames\n * (`slate-` by default)\n */\nexport const stripHtmlClassNames = (\n  html: string,\n  { preserveClassNames = ['slate-'] }: { preserveClassNames?: string[] }\n) => {\n  if (preserveClassNames.length === 0) {\n    return html.replaceAll(classAttrRegExp, '');\n  }\n\n  const preserveRegExp = new RegExp(\n    preserveClassNames.map((cn) => `^${cn}`).join('|')\n  );\n\n  return html.replaceAll(\n    classAttrRegExp,\n    (match: string, className: string) => {\n      const classesToKeep = className\n        .split(/\\s+/)\n        .filter((cn) => preserveRegExp.test(cn));\n\n      return classesToKeep.length === 0\n        ? ''\n        : ` class=\"${classesToKeep.join(' ')}\"`;\n    }\n  );\n};\n","// Remove redundant data attributes\nexport const stripSlateDataAttributes = (rawHtml: string): string =>\n  rawHtml\n    .replaceAll(/ data-slate(?:-node|-type|-leaf|-string)=\"[^\"]+\"/g, '')\n    .replaceAll(/ data-testid=\"[^\"]+\"/g, '');\n","import React from 'react';\n\nimport clsx from 'clsx';\n\nimport type { SlateEditor } from '../editor';\nimport type { SlatePlugin } from '../plugin';\nimport type { RenderLeafProps } from '../types/RenderLeafProps';\n\nimport { SlateLeaf } from './components';\nimport { getNodeDataAttributes } from './utils/getNodeDataAttributes';\nimport { getRenderNodeStaticProps } from './utils/getRenderNodeStaticProps';\n\nexport type SlateRenderLeaf = (\n  props: RenderLeafProps\n) => React.ReactElement<any> | undefined;\n\nexport const pluginRenderLeafStatic = (\n  editor: SlateEditor,\n  plugin: SlatePlugin\n): SlateRenderLeaf =>\n  function render(props) {\n    const { children, leaf } = props;\n\n    if (leaf[plugin.node.type ?? plugin.key]) {\n      const Component = (plugin.render.leaf ??\n        editor.meta.components?.[plugin.key]) as any;\n      const Leaf = Component ?? SlateLeaf;\n\n      const ctxProps = getRenderNodeStaticProps({\n        attributes: { ...(leaf.attributes as any) },\n        editor,\n        node: leaf,\n        plugin,\n        props: props as any,\n      }) as any;\n\n      const defaultProps = Component ? {} : { as: plugin.render?.as };\n\n      return (\n        <Leaf {...defaultProps} {...ctxProps}>\n          {children}\n        </Leaf>\n      );\n    }\n\n    return children;\n  };\n\n/** @see {@link RenderLeaf} */\nexport const pipeRenderLeafStatic = (\n  editor: SlateEditor,\n  { renderLeaf: renderLeafProp }: { renderLeaf?: SlateRenderLeaf } = {}\n): SlateRenderLeaf => {\n  const renderLeafs: SlateRenderLeaf[] = [];\n  const leafPropsPlugins: SlatePlugin[] = [];\n\n  editor.meta.pluginList.forEach((plugin) => {\n    if (\n      plugin.node.isLeaf &&\n      (plugin.node.isDecoration === true || plugin.render.leaf)\n    ) {\n      renderLeafs.push(pluginRenderLeafStatic(editor, plugin));\n    }\n\n    if (plugin.node.leafProps) {\n      leafPropsPlugins.push(plugin);\n    }\n  });\n\n  return function render({ attributes, ...props }) {\n    renderLeafs.forEach((render) => {\n      const newChildren = render(props as any);\n\n      if (newChildren !== undefined) {\n        props.children = newChildren;\n      }\n    });\n\n    leafPropsPlugins.forEach((plugin) => {\n      if (props.leaf[plugin.node.type ?? plugin.key]) {\n        const pluginLeafProps =\n          typeof plugin.node.leafProps === 'function'\n            ? plugin.node.leafProps(props as any)\n            : (plugin.node.leafProps ?? {});\n\n        if (pluginLeafProps.className) {\n          pluginLeafProps.className = clsx(\n            (props as any).className,\n            pluginLeafProps.className\n          );\n        }\n\n        attributes = {\n          ...attributes,\n          ...pluginLeafProps,\n        };\n      }\n    });\n\n    if (renderLeafProp) {\n      return renderLeafProp({ attributes, ...props });\n    }\n\n    const ctxProps = getRenderNodeStaticProps({\n      editor,\n      props: { attributes, ...props } as any,\n    }) as any;\n\n    const leaf = ctxProps.leaf;\n    const dataAttributes = getNodeDataAttributes(editor, leaf, {\n      isLeaf: true,\n    });\n\n    return (\n      <SlateLeaf\n        {...ctxProps}\n        attributes={{\n          ...ctxProps.attributes,\n          ...dataAttributes,\n        }}\n      />\n    );\n  };\n};\n","import React from 'react';\n\nimport {\n  type DecoratedRange,\n  type Descendant,\n  type NodeEntry,\n  type TElement,\n  type TText,\n  type Value,\n  ElementApi,\n  isElementDecorationsEqual,\n  isTextDecorationsEqual,\n  RangeApi,\n  TextApi,\n} from '@udecode/slate';\nimport clsx from 'clsx';\n\nimport type { SlateEditor } from '../../editor';\nimport type { EditableProps } from '../../types/EditableProps';\nimport type { SlateRenderElementProps } from '../types';\n\nimport { pipeRenderElementStatic } from '../pipeRenderElementStatic';\nimport { pipeRenderLeafStatic } from '../pluginRenderLeafStatic';\nimport { pipeRenderTextStatic } from '../pluginRenderTextStatic';\nimport { pipeDecorate } from '../utils/pipeDecorate';\n\nfunction BaseElementStatic({\n  decorate,\n  decorations,\n  editor,\n  element = { children: [], type: '' },\n}: {\n  decorate: EditableProps['decorate'];\n  decorations: DecoratedRange[];\n  editor: SlateEditor;\n  element: TElement;\n  style?: React.CSSProperties;\n}) {\n  const renderElement = pipeRenderElementStatic(editor);\n\n  const attributes: SlateRenderElementProps['attributes'] = {\n    'data-slate-node': 'element',\n    ref: null,\n  };\n\n  let children: React.ReactNode = (\n    <Children decorate={decorate} decorations={decorations} editor={editor}>\n      {element.children}\n    </Children>\n  );\n\n  if (editor.api.isVoid(element)) {\n    attributes['data-slate-void'] = true;\n    children = (\n      <span\n        style={{\n          color: 'transparent',\n          height: '0',\n          outline: 'none',\n          position: 'absolute',\n        }}\n        data-slate-spacer\n      >\n        <Children decorate={decorate} decorations={decorations} editor={editor}>\n          {element.children}\n        </Children>\n      </span>\n    );\n  }\n  if (editor.api.isInline(element)) {\n    attributes['data-slate-inline'] = true;\n  }\n\n  return (\n    <React.Fragment>\n      {renderElement?.({ attributes, children, element })}\n    </React.Fragment>\n  );\n}\n\nexport const ElementStatic = React.memo(BaseElementStatic, (prev, next) => {\n  return (\n    (prev.element === next.element ||\n      (prev.element._memo !== undefined &&\n        prev.element._memo === next.element._memo)) &&\n    isElementDecorationsEqual(prev.decorations, next.decorations)\n  );\n});\n\nfunction BaseLeafStatic({\n  decorations,\n  editor,\n  text: text = { text: '' },\n}: {\n  decorations: DecoratedRange[];\n  editor: SlateEditor;\n  text: TText;\n}) {\n  const renderLeaf = pipeRenderLeafStatic(editor);\n  const renderText = pipeRenderTextStatic(editor);\n\n  const decoratedLeaves = TextApi.decorations(text, decorations);\n\n  const leafElements = decoratedLeaves.map(({ leaf, position }, index) => {\n    const leafElement = renderLeaf({\n      attributes: { 'data-slate-leaf': true },\n      children: (\n        <span data-slate-string={true}>\n          {leaf.text === '' ? '\\uFEFF' : leaf.text}\n        </span>\n      ),\n      leaf: leaf as TText,\n      leafPosition: position,\n      text: leaf as TText,\n    });\n\n    return <React.Fragment key={index}>{leafElement}</React.Fragment>;\n  });\n\n  return renderText({\n    attributes: { 'data-slate-node': 'text' as const, ref: null },\n    children: leafElements,\n    text: text as TText,\n  });\n}\n\nexport const LeafStatic = React.memo(BaseLeafStatic, (prev, next) => {\n  return (\n    // prev.text === next.text &&\n    TextApi.equals(next.text, prev.text) &&\n    isTextDecorationsEqual(next.decorations, prev.decorations)\n  );\n});\n\nconst defaultDecorate: (entry: NodeEntry) => DecoratedRange[] = () => [];\n\nfunction Children({\n  children = [],\n  decorate = defaultDecorate,\n  decorations = [],\n  editor,\n}: {\n  children: Descendant[];\n  decorate: EditableProps['decorate'];\n  decorations: DecoratedRange[];\n  editor: SlateEditor;\n}) {\n  return (\n    <React.Fragment>\n      {children.map((child, i) => {\n        const p = editor.api.findPath(child);\n\n        let ds: DecoratedRange[] = [];\n\n        if (p) {\n          const range = editor.api.range(p)!;\n          ds = decorate([child, p]);\n\n          for (const dec of decorations) {\n            const d = RangeApi.intersection(dec, range);\n\n            if (d) {\n              ds.push(d);\n            }\n          }\n        }\n\n        return ElementApi.isElement(child) ? (\n          <ElementStatic\n            key={i}\n            decorate={decorate}\n            decorations={ds}\n            editor={editor}\n            element={child}\n          />\n        ) : (\n          <LeafStatic key={i} decorations={ds} editor={editor} text={child} />\n        );\n      })}\n    </React.Fragment>\n  );\n}\n\nexport type PlateStaticProps = {\n  /** Editor instance. */\n  editor: SlateEditor;\n  style?: React.CSSProperties;\n  /** Controlled value. Alias to `editor.children`. */\n  value?: Value;\n} & React.HTMLAttributes<HTMLDivElement>;\n\nexport function PlateStatic(props: PlateStaticProps) {\n  const { className, editor, value, ...rest } = props;\n\n  if (value) {\n    editor.children = value;\n  }\n\n  const decorate = pipeDecorate(editor);\n\n  let afterEditable: React.ReactNode = null;\n  let beforeEditable: React.ReactNode = null;\n\n  editor.meta.pluginCache.render.beforeEditable.forEach((key) => {\n    const plugin = editor.getPlugin({ key });\n    const BeforeEditable = plugin.render.beforeEditable;\n\n    if (BeforeEditable) {\n      beforeEditable = (\n        <>\n          {beforeEditable}\n          <BeforeEditable />\n        </>\n      );\n    }\n  });\n\n  editor.meta.pluginCache.render.afterEditable.forEach((key) => {\n    const plugin = editor.getPlugin({ key });\n    const AfterEditable = plugin.render.afterEditable;\n\n    if (AfterEditable) {\n      afterEditable = (\n        <>\n          {afterEditable}\n          <AfterEditable />\n        </>\n      );\n    }\n  });\n\n  const content = (\n    <div\n      className={clsx('slate-editor', className)}\n      data-slate-editor\n      data-slate-node=\"value\"\n      {...rest}\n    >\n      <Children decorate={decorate} decorations={[]} editor={editor}>\n        {editor.children}\n      </Children>\n    </div>\n  );\n\n  let aboveEditable: React.ReactNode = (\n    <>\n      {beforeEditable}\n      {content}\n      {afterEditable}\n    </>\n  );\n\n  // Use pre-computed arrays for aboveEditable components\n  editor.meta.pluginCache.render.aboveEditable.forEach((key) => {\n    const plugin = editor.getPlugin({ key });\n    const AboveEditable = plugin.render.aboveEditable;\n\n    if (AboveEditable) {\n      aboveEditable = <AboveEditable>{aboveEditable}</AboveEditable>;\n    }\n  });\n\n  return aboveEditable;\n}\n","import React from 'react';\n\nimport clsx from 'clsx';\n\nimport type { SlateEditor } from '../editor';\nimport type { SlatePlugin } from '../plugin';\nimport type { RenderTextProps } from '../types/RenderTextProps';\n\nimport { SlateText } from './components';\nimport { getNodeDataAttributes } from './utils/getNodeDataAttributes';\nimport { getRenderNodeStaticProps } from './utils/getRenderNodeStaticProps';\n\nexport type SlateRenderText = (\n  props: RenderTextProps\n) => React.ReactElement<any> | undefined;\n\nexport const pluginRenderTextStatic = (\n  editor: SlateEditor,\n  plugin: SlatePlugin\n): SlateRenderText =>\n  function render(nodeProps) {\n    const { children, text } = nodeProps;\n\n    if (text[plugin.node.type ?? plugin.key]) {\n      const Component = editor.meta.components?.[plugin.key] as any;\n      const Text = Component ?? SlateText;\n\n      // const dataAttributes = getPluginDataAttributes(editor, plugin, text);\n\n      const ctxProps = getRenderNodeStaticProps({\n        attributes: { ...(text.attributes as any) },\n        editor,\n        node: text,\n        plugin,\n        props: nodeProps as any,\n      }) as any;\n\n      const defaultProps = Component ? {} : { as: plugin.render?.as };\n\n      return (\n        <Text {...defaultProps} {...ctxProps}>\n          {children}\n        </Text>\n      );\n    }\n\n    return children;\n  };\n\n/** @see {@link RenderText} */\nexport const pipeRenderTextStatic = (\n  editor: SlateEditor,\n  { renderText: renderTextProp }: { renderText?: SlateRenderText } = {}\n): SlateRenderText => {\n  const renderTexts: SlateRenderText[] = [];\n  const textPropsPlugins: SlatePlugin[] = [];\n\n  editor.meta.pluginList.forEach((plugin) => {\n    if (plugin.node.isLeaf && plugin.node.isDecoration === false) {\n      renderTexts.push(pluginRenderTextStatic(editor, plugin));\n    }\n\n    if (plugin.node.textProps) {\n      textPropsPlugins.push(plugin);\n    }\n  });\n\n  return function render({ attributes, ...props }) {\n    renderTexts.forEach((render) => {\n      const newChildren = render(props as any);\n\n      if (newChildren !== undefined) {\n        props.children = newChildren;\n      }\n    });\n\n    textPropsPlugins.forEach((plugin) => {\n      if (props.text[plugin.node.type ?? plugin.key]) {\n        const pluginTextProps =\n          typeof plugin.node.textProps === 'function'\n            ? plugin.node.textProps(props as any)\n            : (plugin.node.textProps ?? {});\n\n        if (pluginTextProps.className) {\n          pluginTextProps.className = clsx(\n            (props as any).className,\n            pluginTextProps.className\n          );\n        }\n\n        attributes = {\n          ...attributes,\n          ...pluginTextProps,\n        };\n      }\n    });\n\n    if (renderTextProp) {\n      return renderTextProp({ attributes, ...props });\n    }\n\n    const ctxProps = getRenderNodeStaticProps({\n      editor,\n      props: { attributes, ...props } as any,\n    }) as any;\n\n    const text = ctxProps.text;\n    const dataAttributes = getNodeDataAttributes(editor, text, {\n      isText: true,\n    });\n\n    return (\n      <SlateText\n        {...ctxProps}\n        attributes={{\n          ...ctxProps.attributes,\n          ...dataAttributes,\n        }}\n      />\n    );\n  };\n};\n","import React from 'react';\n\nimport { decode } from 'html-entities';\n\nimport type { SlateEditor } from '../editor';\nimport type { PlateStaticProps } from './components/PlateStatic';\n\nimport { PlateStatic } from './components/PlateStatic';\nimport { stripHtmlClassNames } from './utils/stripHtmlClassNames';\nimport { stripSlateDataAttributes } from './utils/stripSlateDataAttributes';\n\nconst getReactDOMServer = async () => {\n  const ReactDOMServer = (await import('react-dom/server')).default;\n\n  return ReactDOMServer;\n};\n\nconst renderComponentToHtml = <P extends {}>(\n  ReactDOMServer: any,\n  Component: React.ComponentType<P>,\n  props: P\n): string => {\n  return decode(\n    ReactDOMServer.renderToStaticMarkup(React.createElement(Component, props))\n  );\n};\n\nexport type SerializeHtmlOptions<\n  T extends PlateStaticProps = PlateStaticProps,\n> = {\n  /** The component used to render the editor content */\n  editorComponent?: React.ComponentType<T>;\n  /** List of className prefixes to preserve from being stripped out */\n  preserveClassNames?: string[];\n  /** Props to pass to the editor component */\n  props?: Partial<T>;\n  /** Enable stripping class names */\n  stripClassNames?: boolean;\n  /** Enable stripping data attributes */\n  stripDataAttributes?: boolean;\n};\n\n/**\n * Serialize the editor content to HTML. By default, uses `PlateStatic` as the\n * editor component, but you can provide a custom component (e.g.\n * `EditorStatic`).\n */\nexport const serializeHtml = async <\n  T extends PlateStaticProps = PlateStaticProps,\n>(\n  editor: SlateEditor,\n  {\n    editorComponent: EditorComponent = PlateStatic,\n    preserveClassNames,\n    props = {},\n    stripClassNames = false,\n    stripDataAttributes = false,\n  }: SerializeHtmlOptions<T> = {}\n): Promise<string> => {\n  const ReactDOMServer = await getReactDOMServer();\n\n  let htmlString = renderComponentToHtml(ReactDOMServer, EditorComponent, {\n    editor,\n    ...props,\n  } as T);\n\n  if (stripClassNames) {\n    htmlString = stripHtmlClassNames(htmlString, {\n      preserveClassNames,\n    });\n  }\n  if (stripDataAttributes) {\n    htmlString = stripSlateDataAttributes(htmlString);\n  }\n\n  return htmlString;\n};\n","export const isSlateVoid = (element: HTMLElement) => {\n  return element.dataset.slateVoid === 'true';\n};\n\nexport const isSlateElement = (element: HTMLElement) => {\n  return element.dataset.slateNode === 'element';\n};\n\nexport const isSlateText = (element: HTMLElement) => {\n  return element.dataset.slateNode === 'text';\n};\n\nexport const isSlateString = (element: HTMLElement) => {\n  return element.dataset.slateString === 'true';\n};\n\nexport const isSlateLeaf = (element: HTMLElement) => {\n  return element.dataset.slateLeaf === 'true';\n};\n\nexport const isSlateEditor = (element: HTMLElement) => {\n  return element.dataset.slateEditor === 'true';\n};\n\nexport const isSlateNode = (element: HTMLElement) => {\n  return (\n    isSlateLeaf(element) ||\n    isSlateElement(element) ||\n    isSlateVoid(element) ||\n    isSlateString(element) ||\n    isSlateText(element)\n  );\n};\n\nexport const isSlatePluginElement = (\n  element: HTMLElement,\n  pluginKey: string\n) => {\n  return (\n    element.dataset.slateNode === 'element' &&\n    element.classList.contains(`slate-${pluginKey}`)\n  );\n};\n\nexport const isSlatePluginNode = (element: HTMLElement, pluginKey: string) => {\n  return element.classList.contains(`slate-${pluginKey}`);\n};\n\nexport const getSlateElements = (element: HTMLElement): HTMLElement[] => {\n  return Array.from(element.querySelectorAll('[data-slate-node=\"element\"]'));\n};\n","/**\n * Convert HTML string exported from Plate into HTML element.\n *\n * @param html - The HTML string to convert exported from Plate.\n * @returns The Editor element without head and body.\n */\nexport const getEditorDOMFromHtmlString = (html: string) => {\n  const node = document.createElement('body');\n  node.innerHTML = html;\n  const editorNode = node.querySelector('[data-slate-editor=\"true\"]');\n\n  return editorNode as HTMLElement;\n};\n","/** Get slate class name: slate-<type> */\nexport const getSlateClass = (type?: string) => (type ? `slate-${type}` : '');\n","import type { Editor } from '@udecode/slate';\n\nimport { IS_APPLE } from '@udecode/utils';\nimport { type KeyboardEventLike, isKeyHotkey } from 'is-hotkey';\n\nexport { isHotkey } from 'is-hotkey';\n\n/** Hotkey mappings for each platform. */\nconst HOTKEYS = {\n  bold: 'mod+b',\n  compose: ['down', 'left', 'right', 'up', 'backspace', 'enter'],\n  deleteBackward: 'shift?+backspace',\n  deleteForward: 'shift?+delete',\n  escape: 'escape',\n  extendBackward: 'shift+left',\n  extendDownward: 'shift+down',\n  extendForward: 'shift+right',\n  extendUpward: 'shift+up',\n  insertSoftBreak: 'shift+enter',\n  italic: 'mod+i',\n  moveBackward: 'left',\n  moveDownward: 'down',\n  moveForward: 'right',\n  moveUpward: 'up',\n  moveWordBackward: 'ctrl+left',\n  moveWordForward: 'ctrl+right',\n  selectAll: 'mod+a',\n  splitBlock: 'enter',\n  tab: 'tab',\n  undo: 'mod+z',\n  untab: 'shift+tab',\n};\n\nconst APPLE_HOTKEYS = {\n  deleteBackward: ['ctrl+backspace', 'ctrl+h'],\n  deleteForward: ['ctrl+delete', 'ctrl+d'],\n  deleteLineBackward: 'cmd+shift?+backspace',\n  deleteLineForward: ['cmd+shift?+delete', 'ctrl+k'],\n  deleteWordBackward: 'opt+shift?+backspace',\n  deleteWordForward: 'opt+shift?+delete',\n  extendLineBackward: 'opt+shift+up',\n  extendLineForward: 'opt+shift+down',\n  moveLineBackward: 'opt+up',\n  moveLineForward: 'opt+down',\n  moveWordBackward: 'opt+left',\n  moveWordForward: 'opt+right',\n  redo: 'cmd+shift+z',\n  transposeCharacter: 'ctrl+t',\n};\n\nconst WINDOWS_HOTKEYS = {\n  deleteWordBackward: 'ctrl+shift?+backspace',\n  deleteWordForward: 'ctrl+shift?+delete',\n  redo: ['ctrl+y', 'ctrl+shift+z'],\n};\n\n/** Create a platform-aware hotkey checker. */\n\nexport const createHotkey = (key: string) => {\n  const generic = (HOTKEYS as any)[key];\n  const apple = (APPLE_HOTKEYS as any)[key];\n  const windows = (WINDOWS_HOTKEYS as any)[key];\n  const isGeneric = generic && isKeyHotkey(generic);\n  const isApple = apple && isKeyHotkey(apple);\n  const isWindows = windows && isKeyHotkey(windows);\n\n  return (event: KeyboardEventLike) => {\n    if (isGeneric?.(event)) return true;\n    if (IS_APPLE && isApple?.(event)) return true;\n    if (!IS_APPLE && isWindows?.(event)) return true;\n\n    return false;\n  };\n};\n\nconst createComposing =\n  (key: string) =>\n  (\n    editor: Editor,\n    event: React.KeyboardEvent,\n    {\n      composing,\n    }: {\n      /** Ignore the event if composing. */\n      composing?: boolean;\n    } = {}\n  ) => {\n    if (!createHotkey(key)(event)) return false;\n    if (!!composing !== editor.api.isComposing()) return false;\n\n    return true;\n  };\n\nexport const Hotkeys = {\n  isBold: createHotkey('bold'),\n  isCompose: createHotkey('compose'),\n  isDeleteBackward: createHotkey('deleteBackward'),\n  isDeleteForward: createHotkey('deleteForward'),\n  isDeleteLineBackward: createHotkey('deleteLineBackward'),\n  isDeleteLineForward: createHotkey('deleteLineForward'),\n  isDeleteWordBackward: createHotkey('deleteWordBackward'),\n  isDeleteWordForward: createHotkey('deleteWordForward'),\n  isEscape: createHotkey('escape'),\n  isExtendBackward: createHotkey('extendBackward'),\n  isExtendDownward: createHotkey('extendDownward'),\n  isExtendForward: createHotkey('extendForward'),\n  isExtendLineBackward: createHotkey('extendLineBackward'),\n  isExtendLineForward: createHotkey('extendLineForward'),\n  isExtendUpward: createHotkey('extendUpward'),\n  isItalic: createHotkey('italic'),\n  isMoveBackward: createHotkey('moveBackward'),\n  isMoveDownward: createHotkey('moveDownward'),\n  isMoveForward: createHotkey('moveForward'),\n  isMoveLineBackward: createHotkey('moveLineBackward'),\n  isMoveLineForward: createHotkey('moveLineForward'),\n  isMoveUpward: createHotkey('moveUpward'),\n  isMoveWordBackward: createHotkey('moveWordBackward'),\n  isMoveWordForward: createHotkey('moveWordForward'),\n  isRedo: createHotkey('redo'),\n  isSelectAll: createHotkey('selectAll'),\n  isSoftBreak: createHotkey('insertSoftBreak'),\n  isSplitBlock: createHotkey('splitBlock'),\n  isTab: createComposing('tab'),\n  isTransposeCharacter: createHotkey('transposeCharacter'),\n  isUndo: createHotkey('undo'),\n  isUntab: createComposing('untab'),\n};\n","import castArray from 'lodash/castArray.js';\n\nimport type { SlateEditor } from '../editor';\n\n/** Does the node match the type provided. */\nexport const isType = (\n  editor: SlateEditor,\n  node: any,\n  key?: string[] | string\n) => {\n  const keys = castArray(key);\n  const types: string[] = [];\n\n  keys.forEach((_key) => types.push(editor.getType(_key)));\n\n  return types.includes(node?.type);\n};\n","import type { TNode } from '@udecode/slate';\n\nimport merge from 'lodash/merge.js';\n\nimport {\n  type ApplyDeepToNodesOptions,\n  applyDeepToNodes,\n} from './applyDeepToNodes';\n\n/** Recursively merge a source object to children nodes with a query. */\nexport const mergeDeepToNodes = <N extends TNode>(\n  options: Omit<ApplyDeepToNodesOptions<N>, 'apply'>\n) => {\n  applyDeepToNodes({ ...options, apply: merge });\n};\n","import {\n  type Descendant,\n  type Editor,\n  ElementApi,\n  TextApi,\n} from '@udecode/slate';\n\nimport type { SlateEditor } from '../editor';\nimport type { WithRequiredKey } from '../plugin';\n\nimport { BaseParagraphPlugin } from '../plugins';\n\nconst isInlineNode = (editor: Editor) => (node: Descendant) =>\n  TextApi.isText(node) ||\n  (ElementApi.isElement(node) && editor.api.isInline(node));\n\nconst makeBlockLazy = (type: string) => (): Descendant => ({\n  children: [],\n  type,\n});\n\nconst hasDifferentChildNodes = (\n  descendants: Descendant[],\n  isInline: (node: Descendant) => boolean\n): boolean => {\n  return descendants.some((descendant, index, arr) => {\n    const prevDescendant = arr[index - 1];\n\n    if (index !== 0) {\n      return isInline(descendant) !== isInline(prevDescendant);\n    }\n\n    return false;\n  });\n};\n\n/**\n * Handles 3rd constraint: \"Block nodes can only contain other blocks, or inline\n * and text nodes.\"\n */\nconst normalizeDifferentNodeTypes = (\n  descendants: Descendant[],\n  isInline: (node: Descendant) => boolean,\n  makeDefaultBlock: () => Descendant\n): Descendant[] => {\n  const hasDifferentNodes = hasDifferentChildNodes(descendants, isInline);\n\n  const { fragment } = descendants.reduce(\n    (memo, node) => {\n      if (hasDifferentNodes && isInline(node)) {\n        let block = memo.precedingBlock;\n\n        if (!block) {\n          block = makeDefaultBlock();\n          memo.precedingBlock = block;\n          memo.fragment.push(block);\n        }\n\n        (block.children as Descendant[]).push(node);\n      } else {\n        memo.fragment.push(node);\n        memo.precedingBlock = null;\n      }\n\n      return memo;\n    },\n    {\n      fragment: [] as Descendant[],\n      precedingBlock: null as Descendant | null,\n    }\n  );\n\n  return fragment;\n};\n\n/**\n * Handles 1st constraint: \"All Element nodes must contain at least one Text\n * descendant.\"\n */\nconst normalizeEmptyChildren = (descendants: Descendant[]): Descendant[] => {\n  if (descendants.length === 0) {\n    return [{ text: '' } as Descendant];\n  }\n\n  return descendants;\n};\n\nconst normalize = (\n  descendants: Descendant[],\n  isInline: (node: Descendant) => boolean,\n  makeDefaultBlock: () => Descendant\n): Descendant[] => {\n  descendants = normalizeEmptyChildren(descendants);\n  descendants = normalizeDifferentNodeTypes(\n    descendants,\n    isInline,\n    makeDefaultBlock\n  );\n\n  descendants = descendants.map((node) => {\n    if (ElementApi.isElement(node)) {\n      return {\n        ...node,\n        children: normalize(\n          node.children as Descendant[],\n          isInline,\n          makeDefaultBlock\n        ),\n      };\n    }\n\n    return node;\n  });\n\n  return descendants;\n};\n\n/** Normalize the descendants to a valid document fragment. */\nexport const normalizeDescendantsToDocumentFragment = (\n  editor: SlateEditor,\n  {\n    defaultElementPlugin = BaseParagraphPlugin,\n    descendants,\n  }: { descendants: Descendant[]; defaultElementPlugin?: WithRequiredKey }\n): Descendant[] => {\n  const isInline = isInlineNode(editor);\n  const defaultType = editor.getType(defaultElementPlugin.key);\n  const makeDefaultBlock = makeBlockLazy(defaultType);\n\n  return normalize(descendants, isInline, makeDefaultBlock as any);\n};\n","import {\n  type Path,\n  type TText,\n  ElementApi,\n  NodeApi,\n  TextApi,\n} from '@udecode/slate';\n\nimport type { PluginConfig } from '../../plugin/BasePlugin';\nimport type { EdgeNodes } from './types';\n\nimport { createTSlatePlugin } from '../../plugin/createSlatePlugin';\nimport { getPluginByType } from '../../plugin/getSlatePlugin';\nimport { getEdgeNodes } from './queries';\nimport { getMarkBoundaryAffinity } from './queries/getMarkBoundaryAffinity';\nimport { isNodesAffinity } from './queries/isNodeAffinity';\nimport { setAffinitySelection } from './transforms/setAffinitySelection';\n\nexport type ElementAffinity = {\n  affinity: 'backward' | 'forward';\n  at: Path;\n  type: string;\n};\n\nexport type AffinityConfig = PluginConfig<'affinity'>;\n\n// REVIEW: performance\nexport const AffinityPlugin = createTSlatePlugin<AffinityConfig>({\n  key: 'affinity',\n}).overrideEditor(({ editor, tf: { deleteBackward, insertText, move } }) => ({\n  transforms: {\n    /**\n     * On backspace, if the deletion results in the cursor being at a mark\n     * boundary, then the affinity should be forward. If the deletion removes a\n     * character from the left mark, then the affinity should be backward.\n     */\n    deleteBackward: (unit) => {\n      const apply = () => {\n        if (unit === 'character' && editor.api.isCollapsed()) {\n          const [start] = getEdgeNodes(editor) ?? [null];\n\n          const startText =\n            start &&\n            (TextApi.isText(start[0])\n              ? start[0].text\n              : NodeApi.string(start[0]));\n\n          deleteBackward(unit);\n\n          const edgeNodes = getEdgeNodes(editor);\n\n          if (\n            edgeNodes &&\n            isNodesAffinity(editor, edgeNodes, 'directional') &&\n            !hasElement(edgeNodes)\n          ) {\n            const affinity =\n              startText && startText.length > 1 ? 'backward' : 'forward';\n            setAffinitySelection(editor, edgeNodes, affinity);\n          }\n          return true;\n        }\n      };\n\n      if (apply()) return;\n\n      deleteBackward(unit);\n    },\n    insertText(text, options) {\n      /** This will be computed only for text nodes with marks. */\n      const applyOutwardAffinity = () => {\n        if (!editor.selection || editor.api.isExpanded()) {\n          return;\n        }\n\n        const textPath = editor.selection.focus.path;\n        const textNode = NodeApi.get<TText>(editor, textPath);\n\n        if (!textNode) {\n          return;\n        }\n\n        const marks = Object.keys(NodeApi.extractProps(textNode));\n        const outwardMarks = marks.filter(\n          (type) =>\n            getPluginByType(editor, type)?.rules.selection?.affinity ===\n            'outward'\n        );\n\n        if (\n          !outwardMarks.length ||\n          !editor.api.isEnd(editor.selection.focus, textPath)\n        ) {\n          return;\n        }\n\n        const nextPoint = editor.api.start(textPath, { next: true });\n        const marksToRemove: string[] = [];\n\n        // Get next text node once outside the loop\n        let nextTextNode: TText | null = null;\n        if (nextPoint) {\n          const nextTextPath = nextPoint.path;\n          nextTextNode = NodeApi.get<TText>(editor, nextTextPath) || null;\n        }\n\n        // Check each mark individually\n        for (const markKey of outwardMarks) {\n          if (!textNode[markKey]) {\n            continue; // Skip marks not present on current node\n          }\n\n          const isBetweenSameMarks = nextTextNode?.[markKey];\n\n          if (!isBetweenSameMarks) {\n            marksToRemove.push(markKey);\n          }\n        }\n\n        if (marksToRemove.length > 0) {\n          editor.tf.removeMarks(marksToRemove);\n        }\n      };\n\n      applyOutwardAffinity();\n\n      return insertText(text, options);\n    },\n    move: (options) => {\n      const apply = () => {\n        const {\n          distance = 1,\n          reverse = false,\n          unit = 'character',\n        } = options || {};\n\n        if (\n          unit === 'character' &&\n          distance === 1 &&\n          editor.api.isCollapsed()\n        ) {\n          const preEdgeNodes = getEdgeNodes(editor);\n\n          if (preEdgeNodes && isNodesAffinity(editor, preEdgeNodes, 'hard')) {\n            if (\n              preEdgeNodes &&\n              preEdgeNodes[reverse ? 0 : 1] === null &&\n              getMarkBoundaryAffinity(editor, preEdgeNodes) ===\n                (reverse ? 'forward' : 'backward')\n            ) {\n              setAffinitySelection(\n                editor,\n                preEdgeNodes,\n                reverse ? 'backward' : 'forward'\n              );\n\n              return true;\n            }\n\n            move({ ...options, unit: 'offset' });\n            return true;\n          }\n\n          move(options);\n\n          const postEdgeNodes = getEdgeNodes(editor);\n\n          /**\n           * If the move places the cursor at a mark boundary, then the affinity\n           * should be set to the direction the cursor came from.\n           */\n          if (\n            postEdgeNodes &&\n            isNodesAffinity(editor, postEdgeNodes, 'directional') &&\n            !hasElement(postEdgeNodes)\n          ) {\n            setAffinitySelection(\n              editor,\n              postEdgeNodes,\n              reverse ? 'forward' : 'backward'\n            );\n          }\n\n          return true;\n        }\n      };\n\n      if (apply()) return;\n\n      move(options);\n    },\n  },\n}));\n\nconst hasElement = (edgeNodes: EdgeNodes) => {\n  const [before, after] = edgeNodes;\n\n  return (\n    (before && ElementApi.isElement(before[0])) ||\n    (after && ElementApi.isElement(after[0]))\n  );\n};\n","import {\n  type TElement,\n  type TText,\n  ElementApi,\n  NodeApi,\n  PathApi,\n} from '@udecode/slate';\nimport { type NodeEntry, Path } from 'slate';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { EdgeNodes } from '../types';\n\nimport { getPluginByType } from '../../../plugin/getSlatePlugin';\n\n/**\n * When the cursor is at a mark edge, this function returns the inward node and\n * the outward node (if any). If the cursor is at the start of the text, then\n * the node before the text is returned. If the cursor is at the end of the\n * text, then the node after the text is returned. Otherwise, null is returned.\n */\nexport const getEdgeNodes = (editor: SlateEditor): EdgeNodes | null => {\n  if (!editor.api.isCollapsed()) return null;\n\n  const cursor = editor.selection!.anchor;\n\n  const textRange = editor.api.range(cursor.path);\n\n  if (!textRange) return null;\n\n  const edge = editor.api.isStart(cursor, textRange)\n    ? 'start'\n    : editor.api.isEnd(cursor, textRange)\n      ? 'end'\n      : null;\n\n  if (!edge) return null;\n\n  const parent: TElement | null = (NodeApi.parent(editor, cursor.path) ??\n    null) as TElement | null;\n\n  /** Inline elements */\n\n  const isAffinityInlineElement = (() => {\n    if (!parent || !ElementApi.isElement(parent)) return false;\n\n    const parentAffinity = getPluginByType(editor, parent.type)?.rules.selection\n      ?.affinity;\n\n    return parentAffinity === 'hard' || parentAffinity === 'directional';\n  })();\n\n  const nodeEntry: NodeEntry<TElement | TText> = isAffinityInlineElement\n    ? [parent!, PathApi.parent(cursor.path)]\n    : [NodeApi.get(editor, cursor.path)!, cursor.path];\n\n  if (\n    edge === 'start' &&\n    cursor.path.at(-1) === 0 &&\n    !isAffinityInlineElement\n  ) {\n    return [null, nodeEntry];\n  }\n\n  const siblingPath =\n    edge === 'end' ? Path.next(nodeEntry[1]) : Path.previous(nodeEntry[1]);\n  const siblingNode = NodeApi.get<TText>(editor, siblingPath);\n\n  const siblingEntry: NodeEntry<TText> | null = siblingNode\n    ? [siblingNode, siblingPath]\n    : null;\n\n  return edge === 'end' ? [nodeEntry, siblingEntry] : [siblingEntry, nodeEntry];\n};\n","/*!\n * is-plain-object <https://github.com/jonschlinkert/is-plain-object>\n *\n * Copyright (c) 2014-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\n\nfunction isObject(o) {\n  return Object.prototype.toString.call(o) === '[object Object]';\n}\n\nfunction isPlainObject(o) {\n  var ctor,prot;\n\n  if (isObject(o) === false) return false;\n\n  // If has modified constructor\n  ctor = o.constructor;\n  if (ctor === undefined) return true;\n\n  // If has modified prototype\n  prot = ctor.prototype;\n  if (isObject(prot) === false) return false;\n\n  // If constructor does not have an Object-specific method\n  if (prot.hasOwnProperty('isPrototypeOf') === false) {\n    return false;\n  }\n\n  // Most likely a plain Object\n  return true;\n}\n\nexport { isPlainObject };\n","// Should be no imports here!\n\n/**\n * The sentinel value returned by producers to replace the draft with undefined.\n */\nexport const NOTHING: unique symbol = Symbol.for(\"immer-nothing\")\n\n/**\n * To let Immer treat your class instances as plain immutable objects\n * (albeit with a custom prototype), you must define either an instance property\n * or a static property on each of your custom classes.\n *\n * Otherwise, your class instance will never be drafted, which means it won't be\n * safe to mutate in a produce callback.\n */\nexport const DRAFTABLE: unique symbol = Symbol.for(\"immer-draftable\")\n\nexport const DRAFT_STATE: unique symbol = Symbol.for(\"immer-state\")\n","export const errors =\n\tprocess.env.NODE_ENV !== \"production\"\n\t\t? [\n\t\t\t\t// All error codes, starting by 0:\n\t\t\t\tfunction(plugin: string) {\n\t\t\t\t\treturn `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \\`enable${plugin}()\\` when initializing your application.`\n\t\t\t\t},\n\t\t\t\tfunction(thing: string) {\n\t\t\t\t\treturn `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`\n\t\t\t\t},\n\t\t\t\t\"This object has been frozen and should not be mutated\",\n\t\t\t\tfunction(data: any) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t\"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? \" +\n\t\t\t\t\t\tdata\n\t\t\t\t\t)\n\t\t\t\t},\n\t\t\t\t\"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.\",\n\t\t\t\t\"Immer forbids circular references\",\n\t\t\t\t\"The first or second argument to `produce` must be a function\",\n\t\t\t\t\"The third argument to `produce` must be a function or undefined\",\n\t\t\t\t\"First argument to `createDraft` must be a plain object, an array, or an immerable object\",\n\t\t\t\t\"First argument to `finishDraft` must be a draft returned by `createDraft`\",\n\t\t\t\tfunction(thing: string) {\n\t\t\t\t\treturn `'current' expects a draft, got: ${thing}`\n\t\t\t\t},\n\t\t\t\t\"Object.defineProperty() cannot be used on an Immer draft\",\n\t\t\t\t\"Object.setPrototypeOf() cannot be used on an Immer draft\",\n\t\t\t\t\"Immer only supports deleting array indices\",\n\t\t\t\t\"Immer only supports setting array indices and the 'length' property\",\n\t\t\t\tfunction(thing: string) {\n\t\t\t\t\treturn `'original' expects a draft, got: ${thing}`\n\t\t\t\t}\n\t\t\t\t// Note: if more errors are added, the errorOffset in Patches.ts should be increased\n\t\t\t\t// See Patches.ts for additional errors\n\t\t  ]\n\t\t: []\n\nexport function die(error: number, ...args: any[]): never {\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tconst e = errors[error]\n\t\tconst msg = typeof e === \"function\" ? e.apply(null, args as any) : e\n\t\tthrow new Error(`[Immer] ${msg}`)\n\t}\n\tthrow new Error(\n\t\t`[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`\n\t)\n}\n","import {\n\tDRAFT_STATE,\n\tDRAFTABLE,\n\tObjectish,\n\tDrafted,\n\tAnyObject,\n\tAnyMap,\n\tAnySet,\n\tImmerState,\n\tArchType,\n\tdie,\n\tStrictMode\n} from \"../internal\"\n\nexport const getPrototypeOf = Object.getPrototypeOf\n\n/** Returns true if the given value is an Immer draft */\n/*#__PURE__*/\nexport function isDraft(value: any): boolean {\n\treturn !!value && !!value[DRAFT_STATE]\n}\n\n/** Returns true if the given value can be drafted by Immer */\n/*#__PURE__*/\nexport function isDraftable(value: any): boolean {\n\tif (!value) return false\n\treturn (\n\t\tisPlainObject(value) ||\n\t\tArray.isArray(value) ||\n\t\t!!value[DRAFTABLE] ||\n\t\t!!value.constructor?.[DRAFTABLE] ||\n\t\tisMap(value) ||\n\t\tisSet(value)\n\t)\n}\n\nconst objectCtorString = Object.prototype.constructor.toString()\n/*#__PURE__*/\nexport function isPlainObject(value: any): boolean {\n\tif (!value || typeof value !== \"object\") return false\n\tconst proto = getPrototypeOf(value)\n\tif (proto === null) {\n\t\treturn true\n\t}\n\tconst Ctor =\n\t\tObject.hasOwnProperty.call(proto, \"constructor\") && proto.constructor\n\n\tif (Ctor === Object) return true\n\n\treturn (\n\t\ttypeof Ctor == \"function\" &&\n\t\tFunction.toString.call(Ctor) === objectCtorString\n\t)\n}\n\n/** Get the underlying object that is represented by the given draft */\n/*#__PURE__*/\nexport function original<T>(value: T): T | undefined\nexport function original(value: Drafted<any>): any {\n\tif (!isDraft(value)) die(15, value)\n\treturn value[DRAFT_STATE].base_\n}\n\n/**\n * Each iterates a map, set or array.\n * Or, if any other kind of object, all of its own properties.\n * Regardless whether they are enumerable or symbols\n */\nexport function each<T extends Objectish>(\n\tobj: T,\n\titer: (key: string | number, value: any, source: T) => void\n): void\nexport function each(obj: any, iter: any) {\n\tif (getArchtype(obj) === ArchType.Object) {\n\t\tReflect.ownKeys(obj).forEach(key => {\n\t\t\titer(key, obj[key], obj)\n\t\t})\n\t} else {\n\t\tobj.forEach((entry: any, index: any) => iter(index, entry, obj))\n\t}\n}\n\n/*#__PURE__*/\nexport function getArchtype(thing: any): ArchType {\n\tconst state: undefined | ImmerState = thing[DRAFT_STATE]\n\treturn state\n\t\t? state.type_\n\t\t: Array.isArray(thing)\n\t\t? ArchType.Array\n\t\t: isMap(thing)\n\t\t? ArchType.Map\n\t\t: isSet(thing)\n\t\t? ArchType.Set\n\t\t: ArchType.Object\n}\n\n/*#__PURE__*/\nexport function has(thing: any, prop: PropertyKey): boolean {\n\treturn getArchtype(thing) === ArchType.Map\n\t\t? thing.has(prop)\n\t\t: Object.prototype.hasOwnProperty.call(thing, prop)\n}\n\n/*#__PURE__*/\nexport function get(thing: AnyMap | AnyObject, prop: PropertyKey): any {\n\t// @ts-ignore\n\treturn getArchtype(thing) === ArchType.Map ? thing.get(prop) : thing[prop]\n}\n\n/*#__PURE__*/\nexport function set(thing: any, propOrOldValue: PropertyKey, value: any) {\n\tconst t = getArchtype(thing)\n\tif (t === ArchType.Map) thing.set(propOrOldValue, value)\n\telse if (t === ArchType.Set) {\n\t\tthing.add(value)\n\t} else thing[propOrOldValue] = value\n}\n\n/*#__PURE__*/\nexport function is(x: any, y: any): boolean {\n\t// From: https://github.com/facebook/fbjs/blob/c69904a511b900266935168223063dd8772dfc40/packages/fbjs/src/core/shallowEqual.js\n\tif (x === y) {\n\t\treturn x !== 0 || 1 / x === 1 / y\n\t} else {\n\t\treturn x !== x && y !== y\n\t}\n}\n\n/*#__PURE__*/\nexport function isMap(target: any): target is AnyMap {\n\treturn target instanceof Map\n}\n\n/*#__PURE__*/\nexport function isSet(target: any): target is AnySet {\n\treturn target instanceof Set\n}\n/*#__PURE__*/\nexport function latest(state: ImmerState): any {\n\treturn state.copy_ || state.base_\n}\n\n/*#__PURE__*/\nexport function shallowCopy(base: any, strict: StrictMode) {\n\tif (isMap(base)) {\n\t\treturn new Map(base)\n\t}\n\tif (isSet(base)) {\n\t\treturn new Set(base)\n\t}\n\tif (Array.isArray(base)) return Array.prototype.slice.call(base)\n\n\tconst isPlain = isPlainObject(base)\n\n\tif (strict === true || (strict === \"class_only\" && !isPlain)) {\n\t\t// Perform a strict copy\n\t\tconst descriptors = Object.getOwnPropertyDescriptors(base)\n\t\tdelete descriptors[DRAFT_STATE as any]\n\t\tlet keys = Reflect.ownKeys(descriptors)\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tconst key: any = keys[i]\n\t\t\tconst desc = descriptors[key]\n\t\t\tif (desc.writable === false) {\n\t\t\t\tdesc.writable = true\n\t\t\t\tdesc.configurable = true\n\t\t\t}\n\t\t\t// like object.assign, we will read any _own_, get/set accessors. This helps in dealing\n\t\t\t// with libraries that trap values, like mobx or vue\n\t\t\t// unlike object.assign, non-enumerables will be copied as well\n\t\t\tif (desc.get || desc.set)\n\t\t\t\tdescriptors[key] = {\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true, // could live with !!desc.set as well here...\n\t\t\t\t\tenumerable: desc.enumerable,\n\t\t\t\t\tvalue: base[key]\n\t\t\t\t}\n\t\t}\n\t\treturn Object.create(getPrototypeOf(base), descriptors)\n\t} else {\n\t\t// perform a sloppy copy\n\t\tconst proto = getPrototypeOf(base)\n\t\tif (proto !== null && isPlain) {\n\t\t\treturn {...base} // assumption: better inner class optimization than the assign below\n\t\t}\n\t\tconst obj = Object.create(proto)\n\t\treturn Object.assign(obj, base)\n\t}\n}\n\n/**\n * Freezes draftable objects. Returns the original object.\n * By default freezes shallowly, but if the second argument is `true` it will freeze recursively.\n *\n * @param obj\n * @param deep\n */\nexport function freeze<T>(obj: T, deep?: boolean): T\nexport function freeze<T>(obj: any, deep: boolean = false): T {\n\tif (isFrozen(obj) || isDraft(obj) || !isDraftable(obj)) return obj\n\tif (getArchtype(obj) > 1 /* Map or Set */) {\n\t\tobj.set = obj.add = obj.clear = obj.delete = dontMutateFrozenCollections as any\n\t}\n\tObject.freeze(obj)\n\tif (deep)\n\t\t// See #590, don't recurse into non-enumerable / Symbol properties when freezing\n\t\t// So use Object.entries (only string-like, enumerables) instead of each()\n\t\tObject.entries(obj).forEach(([key, value]) => freeze(value, true))\n\treturn obj\n}\n\nfunction dontMutateFrozenCollections() {\n\tdie(2)\n}\n\nexport function isFrozen(obj: any): boolean {\n\treturn Object.isFrozen(obj)\n}\n","import {\n\tImmerState,\n\tPatch,\n\tDrafted,\n\tImmerBaseState,\n\tAnyMap,\n\tAnySet,\n\tArchType,\n\tdie\n} from \"../internal\"\n\n/** Plugin utilities */\nconst plugins: {\n\tPatches?: {\n\t\tgeneratePatches_(\n\t\t\tstate: ImmerState,\n\t\t\tbasePath: PatchPath,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tgenerateReplacementPatches_(\n\t\t\tbase: any,\n\t\t\treplacement: any,\n\t\t\tpatches: Patch[],\n\t\t\tinversePatches: Patch[]\n\t\t): void\n\t\tapplyPatches_<T>(draft: T, patches: readonly Patch[]): T\n\t}\n\tMapSet?: {\n\t\tproxyMap_<T extends AnyMap>(target: T, parent?: ImmerState): T\n\t\tproxySet_<T extends AnySet>(target: T, parent?: ImmerState): T\n\t}\n} = {}\n\ntype Plugins = typeof plugins\n\nexport function getPlugin<K extends keyof Plugins>(\n\tpluginKey: K\n): Exclude<Plugins[K], undefined> {\n\tconst plugin = plugins[pluginKey]\n\tif (!plugin) {\n\t\tdie(0, pluginKey)\n\t}\n\t// @ts-ignore\n\treturn plugin\n}\n\nexport function loadPlugin<K extends keyof Plugins>(\n\tpluginKey: K,\n\timplementation: Plugins[K]\n): void {\n\tif (!plugins[pluginKey]) plugins[pluginKey] = implementation\n}\n/** Map / Set plugin */\n\nexport interface MapState extends ImmerBaseState {\n\ttype_: ArchType.Map\n\tcopy_: AnyMap | undefined\n\tassigned_: Map<any, boolean> | undefined\n\tbase_: AnyMap\n\trevoked_: boolean\n\tdraft_: Drafted<AnyMap, MapState>\n}\n\nexport interface SetState extends ImmerBaseState {\n\ttype_: ArchType.Set\n\tcopy_: AnySet | undefined\n\tbase_: AnySet\n\tdrafts_: Map<any, Drafted> // maps the original value to the draft value in the new set\n\trevoked_: boolean\n\tdraft_: Drafted<AnySet, SetState>\n}\n\n/** Patches plugin */\n\nexport type PatchPath = (string | number)[]\n","import {\n\tPatch,\n\tPatchListener,\n\tDrafted,\n\tImmer,\n\tDRAFT_STATE,\n\tImmerState,\n\tArchType,\n\tgetPlugin\n} from \"../internal\"\n\n/** Each scope represents a `produce` call. */\n\nexport interface ImmerScope {\n\tpatches_?: Patch[]\n\tinversePatches_?: Patch[]\n\tcanAutoFreeze_: boolean\n\tdrafts_: any[]\n\tparent_?: ImmerScope\n\tpatchListener_?: PatchListener\n\timmer_: Immer\n\tunfinalizedDrafts_: number\n}\n\nlet currentScope: ImmerScope | undefined\n\nexport function getCurrentScope() {\n\treturn currentScope!\n}\n\nfunction createScope(\n\tparent_: ImmerScope | undefined,\n\timmer_: Immer\n): ImmerScope {\n\treturn {\n\t\tdrafts_: [],\n\t\tparent_,\n\t\timmer_,\n\t\t// Whenever the modified draft contains a draft from another scope, we\n\t\t// need to prevent auto-freezing so the unowned draft can be finalized.\n\t\tcanAutoFreeze_: true,\n\t\tunfinalizedDrafts_: 0\n\t}\n}\n\nexport function usePatchesInScope(\n\tscope: ImmerScope,\n\tpatchListener?: PatchListener\n) {\n\tif (patchListener) {\n\t\tgetPlugin(\"Patches\") // assert we have the plugin\n\t\tscope.patches_ = []\n\t\tscope.inversePatches_ = []\n\t\tscope.patchListener_ = patchListener\n\t}\n}\n\nexport function revokeScope(scope: ImmerScope) {\n\tleaveScope(scope)\n\tscope.drafts_.forEach(revokeDraft)\n\t// @ts-ignore\n\tscope.drafts_ = null\n}\n\nexport function leaveScope(scope: ImmerScope) {\n\tif (scope === currentScope) {\n\t\tcurrentScope = scope.parent_\n\t}\n}\n\nexport function enterScope(immer: Immer) {\n\treturn (currentScope = createScope(currentScope, immer))\n}\n\nfunction revokeDraft(draft: Drafted) {\n\tconst state: ImmerState = draft[DRAFT_STATE]\n\tif (state.type_ === ArchType.Object || state.type_ === ArchType.Array)\n\t\tstate.revoke_()\n\telse state.revoked_ = true\n}\n","import {\n\tImmerScope,\n\tDRAFT_STATE,\n\tisDraftable,\n\tNOTHING,\n\tPatchPath,\n\teach,\n\thas,\n\tfreeze,\n\tImmerState,\n\tisDraft,\n\tSetState,\n\tset,\n\tArchType,\n\tgetPlugin,\n\tdie,\n\trevokeScope,\n\tisFrozen\n} from \"../internal\"\n\nexport function processResult(result: any, scope: ImmerScope) {\n\tscope.unfinalizedDrafts_ = scope.drafts_.length\n\tconst baseDraft = scope.drafts_![0]\n\tconst isReplaced = result !== undefined && result !== baseDraft\n\tif (isReplaced) {\n\t\tif (baseDraft[DRAFT_STATE].modified_) {\n\t\t\trevokeScope(scope)\n\t\t\tdie(4)\n\t\t}\n\t\tif (isDraftable(result)) {\n\t\t\t// Finalize the result in case it contains (or is) a subset of the draft.\n\t\t\tresult = finalize(scope, result)\n\t\t\tif (!scope.parent_) maybeFreeze(scope, result)\n\t\t}\n\t\tif (scope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(\n\t\t\t\tbaseDraft[DRAFT_STATE].base_,\n\t\t\t\tresult,\n\t\t\t\tscope.patches_,\n\t\t\t\tscope.inversePatches_!\n\t\t\t)\n\t\t}\n\t} else {\n\t\t// Finalize the base draft.\n\t\tresult = finalize(scope, baseDraft, [])\n\t}\n\trevokeScope(scope)\n\tif (scope.patches_) {\n\t\tscope.patchListener_!(scope.patches_, scope.inversePatches_!)\n\t}\n\treturn result !== NOTHING ? result : undefined\n}\n\nfunction finalize(rootScope: ImmerScope, value: any, path?: PatchPath) {\n\t// Don't recurse in tho recursive data structures\n\tif (isFrozen(value)) return value\n\n\tconst state: ImmerState = value[DRAFT_STATE]\n\t// A plain object, might need freezing, might contain drafts\n\tif (!state) {\n\t\teach(value, (key, childValue) =>\n\t\t\tfinalizeProperty(rootScope, state, value, key, childValue, path)\n\t\t)\n\t\treturn value\n\t}\n\t// Never finalize drafts owned by another scope.\n\tif (state.scope_ !== rootScope) return value\n\t// Unmodified draft, return the (frozen) original\n\tif (!state.modified_) {\n\t\tmaybeFreeze(rootScope, state.base_, true)\n\t\treturn state.base_\n\t}\n\t// Not finalized yet, let's do that now\n\tif (!state.finalized_) {\n\t\tstate.finalized_ = true\n\t\tstate.scope_.unfinalizedDrafts_--\n\t\tconst result = state.copy_\n\t\t// Finalize all children of the copy\n\t\t// For sets we clone before iterating, otherwise we can get in endless loop due to modifying during iteration, see #628\n\t\t// To preserve insertion order in all cases we then clear the set\n\t\t// And we let finalizeProperty know it needs to re-add non-draft children back to the target\n\t\tlet resultEach = result\n\t\tlet isSet = false\n\t\tif (state.type_ === ArchType.Set) {\n\t\t\tresultEach = new Set(result)\n\t\t\tresult.clear()\n\t\t\tisSet = true\n\t\t}\n\t\teach(resultEach, (key, childValue) =>\n\t\t\tfinalizeProperty(rootScope, state, result, key, childValue, path, isSet)\n\t\t)\n\t\t// everything inside is frozen, we can freeze here\n\t\tmaybeFreeze(rootScope, result, false)\n\t\t// first time finalizing, let's create those patches\n\t\tif (path && rootScope.patches_) {\n\t\t\tgetPlugin(\"Patches\").generatePatches_(\n\t\t\t\tstate,\n\t\t\t\tpath,\n\t\t\t\trootScope.patches_,\n\t\t\t\trootScope.inversePatches_!\n\t\t\t)\n\t\t}\n\t}\n\treturn state.copy_\n}\n\nfunction finalizeProperty(\n\trootScope: ImmerScope,\n\tparentState: undefined | ImmerState,\n\ttargetObject: any,\n\tprop: string | number,\n\tchildValue: any,\n\trootPath?: PatchPath,\n\ttargetIsSet?: boolean\n) {\n\tif (process.env.NODE_ENV !== \"production\" && childValue === targetObject)\n\t\tdie(5)\n\tif (isDraft(childValue)) {\n\t\tconst path =\n\t\t\trootPath &&\n\t\t\tparentState &&\n\t\t\tparentState!.type_ !== ArchType.Set && // Set objects are atomic since they have no keys.\n\t\t\t!has((parentState as Exclude<ImmerState, SetState>).assigned_!, prop) // Skip deep patches for assigned keys.\n\t\t\t\t? rootPath!.concat(prop)\n\t\t\t\t: undefined\n\t\t// Drafts owned by `scope` are finalized here.\n\t\tconst res = finalize(rootScope, childValue, path)\n\t\tset(targetObject, prop, res)\n\t\t// Drafts from another scope must prevented to be frozen\n\t\t// if we got a draft back from finalize, we're in a nested produce and shouldn't freeze\n\t\tif (isDraft(res)) {\n\t\t\trootScope.canAutoFreeze_ = false\n\t\t} else return\n\t} else if (targetIsSet) {\n\t\ttargetObject.add(childValue)\n\t}\n\t// Search new objects for unfinalized drafts. Frozen objects should never contain drafts.\n\tif (isDraftable(childValue) && !isFrozen(childValue)) {\n\t\tif (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {\n\t\t\t// optimization: if an object is not a draft, and we don't have to\n\t\t\t// deepfreeze everything, and we are sure that no drafts are left in the remaining object\n\t\t\t// cause we saw and finalized all drafts already; we can stop visiting the rest of the tree.\n\t\t\t// This benefits especially adding large data tree's without further processing.\n\t\t\t// See add-data.js perf test\n\t\t\treturn\n\t\t}\n\t\tfinalize(rootScope, childValue)\n\t\t// Immer deep freezes plain objects, so if there is no parent state, we freeze as well\n\t\t// Per #590, we never freeze symbolic properties. Just to make sure don't accidentally interfere\n\t\t// with other frameworks.\n\t\tif (\n\t\t\t(!parentState || !parentState.scope_.parent_) &&\n\t\t\ttypeof prop !== \"symbol\" &&\n\t\t\tObject.prototype.propertyIsEnumerable.call(targetObject, prop)\n\t\t)\n\t\t\tmaybeFreeze(rootScope, childValue)\n\t}\n}\n\nfunction maybeFreeze(scope: ImmerScope, value: any, deep = false) {\n\t// we never freeze for a non-root scope; as it would prevent pruning for drafts inside wrapping objects\n\tif (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {\n\t\tfreeze(value, deep)\n\t}\n}\n","import {\n\teach,\n\thas,\n\tis,\n\tisDraftable,\n\tshallowCopy,\n\tlatest,\n\tImmerBaseState,\n\tImmerState,\n\tDrafted,\n\tAnyObject,\n\tAnyArray,\n\tObjectish,\n\tgetCurrentScope,\n\tgetPrototypeOf,\n\tDRAFT_STATE,\n\tdie,\n\tcreateProxy,\n\tArchType,\n\tImmerScope\n} from \"../internal\"\n\ninterface ProxyBaseState extends ImmerBaseState {\n\tassigned_: {\n\t\t[property: string]: boolean\n\t}\n\tparent_?: ImmerState\n\trevoke_(): void\n}\n\nexport interface ProxyObjectState extends ProxyBaseState {\n\ttype_: ArchType.Object\n\tbase_: any\n\tcopy_: any\n\tdraft_: Drafted<AnyObject, ProxyObjectState>\n}\n\nexport interface ProxyArrayState extends ProxyBaseState {\n\ttype_: ArchType.Array\n\tbase_: AnyArray\n\tcopy_: AnyArray | null\n\tdraft_: Drafted<AnyArray, ProxyArrayState>\n}\n\ntype ProxyState = ProxyObjectState | ProxyArrayState\n\n/**\n * Returns a new draft of the `base` object.\n *\n * The second argument is the parent draft-state (used internally).\n */\nexport function createProxyProxy<T extends Objectish>(\n\tbase: T,\n\tparent?: ImmerState\n): Drafted<T, ProxyState> {\n\tconst isArray = Array.isArray(base)\n\tconst state: ProxyState = {\n\t\ttype_: isArray ? ArchType.Array : (ArchType.Object as any),\n\t\t// Track which produce call this is associated with.\n\t\tscope_: parent ? parent.scope_ : getCurrentScope()!,\n\t\t// True for both shallow and deep changes.\n\t\tmodified_: false,\n\t\t// Used during finalization.\n\t\tfinalized_: false,\n\t\t// Track which properties have been assigned (true) or deleted (false).\n\t\tassigned_: {},\n\t\t// The parent draft state.\n\t\tparent_: parent,\n\t\t// The base state.\n\t\tbase_: base,\n\t\t// The base proxy.\n\t\tdraft_: null as any, // set below\n\t\t// The base copy with any updated values.\n\t\tcopy_: null,\n\t\t// Called by the `produce` function.\n\t\trevoke_: null as any,\n\t\tisManual_: false\n\t}\n\n\t// the traps must target something, a bit like the 'real' base.\n\t// but also, we need to be able to determine from the target what the relevant state is\n\t// (to avoid creating traps per instance to capture the state in closure,\n\t// and to avoid creating weird hidden properties as well)\n\t// So the trick is to use 'state' as the actual 'target'! (and make sure we intercept everything)\n\t// Note that in the case of an array, we put the state in an array to have better Reflect defaults ootb\n\tlet target: T = state as any\n\tlet traps: ProxyHandler<object | Array<any>> = objectTraps\n\tif (isArray) {\n\t\ttarget = [state] as any\n\t\ttraps = arrayTraps\n\t}\n\n\tconst {revoke, proxy} = Proxy.revocable(target, traps)\n\tstate.draft_ = proxy as any\n\tstate.revoke_ = revoke\n\treturn proxy as any\n}\n\n/**\n * Object drafts\n */\nexport const objectTraps: ProxyHandler<ProxyState> = {\n\tget(state, prop) {\n\t\tif (prop === DRAFT_STATE) return state\n\n\t\tconst source = latest(state)\n\t\tif (!has(source, prop)) {\n\t\t\t// non-existing or non-own property...\n\t\t\treturn readPropFromProto(state, source, prop)\n\t\t}\n\t\tconst value = source[prop]\n\t\tif (state.finalized_ || !isDraftable(value)) {\n\t\t\treturn value\n\t\t}\n\t\t// Check for existing draft in modified state.\n\t\t// Assigned values are never drafted. This catches any drafts we created, too.\n\t\tif (value === peek(state.base_, prop)) {\n\t\t\tprepareCopy(state)\n\t\t\treturn (state.copy_![prop as any] = createProxy(value, state))\n\t\t}\n\t\treturn value\n\t},\n\thas(state, prop) {\n\t\treturn prop in latest(state)\n\t},\n\townKeys(state) {\n\t\treturn Reflect.ownKeys(latest(state))\n\t},\n\tset(\n\t\tstate: ProxyObjectState,\n\t\tprop: string /* strictly not, but helps TS */,\n\t\tvalue\n\t) {\n\t\tconst desc = getDescriptorFromProto(latest(state), prop)\n\t\tif (desc?.set) {\n\t\t\t// special case: if this write is captured by a setter, we have\n\t\t\t// to trigger it with the correct context\n\t\t\tdesc.set.call(state.draft_, value)\n\t\t\treturn true\n\t\t}\n\t\tif (!state.modified_) {\n\t\t\t// the last check is because we need to be able to distinguish setting a non-existing to undefined (which is a change)\n\t\t\t// from setting an existing property with value undefined to undefined (which is not a change)\n\t\t\tconst current = peek(latest(state), prop)\n\t\t\t// special case, if we assigning the original value to a draft, we can ignore the assignment\n\t\t\tconst currentState: ProxyObjectState = current?.[DRAFT_STATE]\n\t\t\tif (currentState && currentState.base_ === value) {\n\t\t\t\tstate.copy_![prop] = value\n\t\t\t\tstate.assigned_[prop] = false\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif (is(value, current) && (value !== undefined || has(state.base_, prop)))\n\t\t\t\treturn true\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t}\n\n\t\tif (\n\t\t\t(state.copy_![prop] === value &&\n\t\t\t\t// special case: handle new props with value 'undefined'\n\t\t\t\t(value !== undefined || prop in state.copy_)) ||\n\t\t\t// special case: NaN\n\t\t\t(Number.isNaN(value) && Number.isNaN(state.copy_![prop]))\n\t\t)\n\t\t\treturn true\n\n\t\t// @ts-ignore\n\t\tstate.copy_![prop] = value\n\t\tstate.assigned_[prop] = true\n\t\treturn true\n\t},\n\tdeleteProperty(state, prop: string) {\n\t\t// The `undefined` check is a fast path for pre-existing keys.\n\t\tif (peek(state.base_, prop) !== undefined || prop in state.base_) {\n\t\t\tstate.assigned_[prop] = false\n\t\t\tprepareCopy(state)\n\t\t\tmarkChanged(state)\n\t\t} else {\n\t\t\t// if an originally not assigned property was deleted\n\t\t\tdelete state.assigned_[prop]\n\t\t}\n\t\tif (state.copy_) {\n\t\t\tdelete state.copy_[prop]\n\t\t}\n\t\treturn true\n\t},\n\t// Note: We never coerce `desc.value` into an Immer draft, because we can't make\n\t// the same guarantee in ES5 mode.\n\tgetOwnPropertyDescriptor(state, prop) {\n\t\tconst owner = latest(state)\n\t\tconst desc = Reflect.getOwnPropertyDescriptor(owner, prop)\n\t\tif (!desc) return desc\n\t\treturn {\n\t\t\twritable: true,\n\t\t\tconfigurable: state.type_ !== ArchType.Array || prop !== \"length\",\n\t\t\tenumerable: desc.enumerable,\n\t\t\tvalue: owner[prop]\n\t\t}\n\t},\n\tdefineProperty() {\n\t\tdie(11)\n\t},\n\tgetPrototypeOf(state) {\n\t\treturn getPrototypeOf(state.base_)\n\t},\n\tsetPrototypeOf() {\n\t\tdie(12)\n\t}\n}\n\n/**\n * Array drafts\n */\n\nconst arrayTraps: ProxyHandler<[ProxyArrayState]> = {}\neach(objectTraps, (key, fn) => {\n\t// @ts-ignore\n\tarrayTraps[key] = function() {\n\t\targuments[0] = arguments[0][0]\n\t\treturn fn.apply(this, arguments)\n\t}\n})\narrayTraps.deleteProperty = function(state, prop) {\n\tif (process.env.NODE_ENV !== \"production\" && isNaN(parseInt(prop as any)))\n\t\tdie(13)\n\t// @ts-ignore\n\treturn arrayTraps.set!.call(this, state, prop, undefined)\n}\narrayTraps.set = function(state, prop, value) {\n\tif (\n\t\tprocess.env.NODE_ENV !== \"production\" &&\n\t\tprop !== \"length\" &&\n\t\tisNaN(parseInt(prop as any))\n\t)\n\t\tdie(14)\n\treturn objectTraps.set!.call(this, state[0], prop, value, state[0])\n}\n\n// Access a property without creating an Immer draft.\nfunction peek(draft: Drafted, prop: PropertyKey) {\n\tconst state = draft[DRAFT_STATE]\n\tconst source = state ? latest(state) : draft\n\treturn source[prop]\n}\n\nfunction readPropFromProto(state: ImmerState, source: any, prop: PropertyKey) {\n\tconst desc = getDescriptorFromProto(source, prop)\n\treturn desc\n\t\t? `value` in desc\n\t\t\t? desc.value\n\t\t\t: // This is a very special case, if the prop is a getter defined by the\n\t\t\t  // prototype, we should invoke it with the draft as context!\n\t\t\t  desc.get?.call(state.draft_)\n\t\t: undefined\n}\n\nfunction getDescriptorFromProto(\n\tsource: any,\n\tprop: PropertyKey\n): PropertyDescriptor | undefined {\n\t// 'in' checks proto!\n\tif (!(prop in source)) return undefined\n\tlet proto = getPrototypeOf(source)\n\twhile (proto) {\n\t\tconst desc = Object.getOwnPropertyDescriptor(proto, prop)\n\t\tif (desc) return desc\n\t\tproto = getPrototypeOf(proto)\n\t}\n\treturn undefined\n}\n\nexport function markChanged(state: ImmerState) {\n\tif (!state.modified_) {\n\t\tstate.modified_ = true\n\t\tif (state.parent_) {\n\t\t\tmarkChanged(state.parent_)\n\t\t}\n\t}\n}\n\nexport function prepareCopy(state: {\n\tbase_: any\n\tcopy_: any\n\tscope_: ImmerScope\n}) {\n\tif (!state.copy_) {\n\t\tstate.copy_ = shallowCopy(\n\t\t\tstate.base_,\n\t\t\tstate.scope_.immer_.useStrictShallowCopy_\n\t\t)\n\t}\n}\n","import {\n\tIProduceWithPatches,\n\tIProduce,\n\tImmerState,\n\tDrafted,\n\tisDraftable,\n\tprocessResult,\n\tPatch,\n\tObjectish,\n\tDRAFT_STATE,\n\tDraft,\n\tPatchListener,\n\tisDraft,\n\tisMap,\n\tisSet,\n\tcreateProxyProxy,\n\tgetPlugin,\n\tdie,\n\tenterScope,\n\trevokeScope,\n\tleaveScope,\n\tusePatchesInScope,\n\tgetCurrentScope,\n\tNOTHING,\n\tfreeze,\n\tcurrent\n} from \"../internal\"\n\ninterface ProducersFns {\n\tproduce: IProduce\n\tproduceWithPatches: IProduceWithPatches\n}\n\nexport type StrictMode = boolean | \"class_only\";\n\nexport class Immer implements ProducersFns {\n\tautoFreeze_: boolean = true\n\tuseStrictShallowCopy_: StrictMode = false\n\n\tconstructor(config?: {\n\t\tautoFreeze?: boolean\n\t\tuseStrictShallowCopy?: StrictMode\n\t}) {\n\t\tif (typeof config?.autoFreeze === \"boolean\")\n\t\t\tthis.setAutoFreeze(config!.autoFreeze)\n\t\tif (typeof config?.useStrictShallowCopy === \"boolean\")\n\t\t\tthis.setUseStrictShallowCopy(config!.useStrictShallowCopy)\n\t}\n\n\t/**\n\t * The `produce` function takes a value and a \"recipe function\" (whose\n\t * return value often depends on the base state). The recipe function is\n\t * free to mutate its first argument however it wants. All mutations are\n\t * only ever applied to a __copy__ of the base state.\n\t *\n\t * Pass only a function to create a \"curried producer\" which relieves you\n\t * from passing the recipe function every time.\n\t *\n\t * Only plain objects and arrays are made mutable. All other objects are\n\t * considered uncopyable.\n\t *\n\t * Note: This function is __bound__ to its `Immer` instance.\n\t *\n\t * @param {any} base - the initial state\n\t * @param {Function} recipe - function that receives a proxy of the base state as first argument and which can be freely modified\n\t * @param {Function} patchListener - optional function that will be called with all the patches produced here\n\t * @returns {any} a new state, or the initial state if nothing was modified\n\t */\n\tproduce: IProduce = (base: any, recipe?: any, patchListener?: any) => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\" && typeof recipe !== \"function\") {\n\t\t\tconst defaultBase = recipe\n\t\t\trecipe = base\n\n\t\t\tconst self = this\n\t\t\treturn function curriedProduce(\n\t\t\t\tthis: any,\n\t\t\t\tbase = defaultBase,\n\t\t\t\t...args: any[]\n\t\t\t) {\n\t\t\t\treturn self.produce(base, (draft: Drafted) => recipe.call(this, draft, ...args)) // prettier-ignore\n\t\t\t}\n\t\t}\n\n\t\tif (typeof recipe !== \"function\") die(6)\n\t\tif (patchListener !== undefined && typeof patchListener !== \"function\")\n\t\t\tdie(7)\n\n\t\tlet result\n\n\t\t// Only plain objects, arrays, and \"immerable classes\" are drafted.\n\t\tif (isDraftable(base)) {\n\t\t\tconst scope = enterScope(this)\n\t\t\tconst proxy = createProxy(base, undefined)\n\t\t\tlet hasError = true\n\t\t\ttry {\n\t\t\t\tresult = recipe(proxy)\n\t\t\t\thasError = false\n\t\t\t} finally {\n\t\t\t\t// finally instead of catch + rethrow better preserves original stack\n\t\t\t\tif (hasError) revokeScope(scope)\n\t\t\t\telse leaveScope(scope)\n\t\t\t}\n\t\t\tusePatchesInScope(scope, patchListener)\n\t\t\treturn processResult(result, scope)\n\t\t} else if (!base || typeof base !== \"object\") {\n\t\t\tresult = recipe(base)\n\t\t\tif (result === undefined) result = base\n\t\t\tif (result === NOTHING) result = undefined\n\t\t\tif (this.autoFreeze_) freeze(result, true)\n\t\t\tif (patchListener) {\n\t\t\t\tconst p: Patch[] = []\n\t\t\t\tconst ip: Patch[] = []\n\t\t\t\tgetPlugin(\"Patches\").generateReplacementPatches_(base, result, p, ip)\n\t\t\t\tpatchListener(p, ip)\n\t\t\t}\n\t\t\treturn result\n\t\t} else die(1, base)\n\t}\n\n\tproduceWithPatches: IProduceWithPatches = (base: any, recipe?: any): any => {\n\t\t// curried invocation\n\t\tif (typeof base === \"function\") {\n\t\t\treturn (state: any, ...args: any[]) =>\n\t\t\t\tthis.produceWithPatches(state, (draft: any) => base(draft, ...args))\n\t\t}\n\n\t\tlet patches: Patch[], inversePatches: Patch[]\n\t\tconst result = this.produce(base, recipe, (p: Patch[], ip: Patch[]) => {\n\t\t\tpatches = p\n\t\t\tinversePatches = ip\n\t\t})\n\t\treturn [result, patches!, inversePatches!]\n\t}\n\n\tcreateDraft<T extends Objectish>(base: T): Draft<T> {\n\t\tif (!isDraftable(base)) die(8)\n\t\tif (isDraft(base)) base = current(base)\n\t\tconst scope = enterScope(this)\n\t\tconst proxy = createProxy(base, undefined)\n\t\tproxy[DRAFT_STATE].isManual_ = true\n\t\tleaveScope(scope)\n\t\treturn proxy as any\n\t}\n\n\tfinishDraft<D extends Draft<any>>(\n\t\tdraft: D,\n\t\tpatchListener?: PatchListener\n\t): D extends Draft<infer T> ? T : never {\n\t\tconst state: ImmerState = draft && (draft as any)[DRAFT_STATE]\n\t\tif (!state || !state.isManual_) die(9)\n\t\tconst {scope_: scope} = state\n\t\tusePatchesInScope(scope, patchListener)\n\t\treturn processResult(undefined, scope)\n\t}\n\n\t/**\n\t * Pass true to automatically freeze all copies created by Immer.\n\t *\n\t * By default, auto-freezing is enabled.\n\t */\n\tsetAutoFreeze(value: boolean) {\n\t\tthis.autoFreeze_ = value\n\t}\n\n\t/**\n\t * Pass true to enable strict shallow copy.\n\t *\n\t * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.\n\t */\n\tsetUseStrictShallowCopy(value: StrictMode) {\n\t\tthis.useStrictShallowCopy_ = value\n\t}\n\n\tapplyPatches<T extends Objectish>(base: T, patches: readonly Patch[]): T {\n\t\t// If a patch replaces the entire state, take that replacement as base\n\t\t// before applying patches\n\t\tlet i: number\n\t\tfor (i = patches.length - 1; i >= 0; i--) {\n\t\t\tconst patch = patches[i]\n\t\t\tif (patch.path.length === 0 && patch.op === \"replace\") {\n\t\t\t\tbase = patch.value\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\t// If there was a patch that replaced the entire state, start from the\n\t\t// patch after that.\n\t\tif (i > -1) {\n\t\t\tpatches = patches.slice(i + 1)\n\t\t}\n\n\t\tconst applyPatchesImpl = getPlugin(\"Patches\").applyPatches_\n\t\tif (isDraft(base)) {\n\t\t\t// N.B: never hits if some patch a replacement, patches are never drafts\n\t\t\treturn applyPatchesImpl(base, patches)\n\t\t}\n\t\t// Otherwise, produce a copy of the base state.\n\t\treturn this.produce(base, (draft: Drafted) =>\n\t\t\tapplyPatchesImpl(draft, patches)\n\t\t)\n\t}\n}\n\nexport function createProxy<T extends Objectish>(\n\tvalue: T,\n\tparent?: ImmerState\n): Drafted<T, ImmerState> {\n\t// precondition: createProxy should be guarded by isDraftable, so we know we can safely draft\n\tconst draft: Drafted = isMap(value)\n\t\t? getPlugin(\"MapSet\").proxyMap_(value, parent)\n\t\t: isSet(value)\n\t\t? getPlugin(\"MapSet\").proxySet_(value, parent)\n\t\t: createProxyProxy(value, parent)\n\n\tconst scope = parent ? parent.scope_ : getCurrentScope()\n\tscope.drafts_.push(draft)\n\treturn draft\n}\n","import {\n\tdie,\n\tisDraft,\n\tshallowCopy,\n\teach,\n\tDRAFT_STATE,\n\tset,\n\tImmerState,\n\tisDraftable,\n\tisFrozen\n} from \"../internal\"\n\n/** Takes a snapshot of the current state of a draft and finalizes it (but without freezing). This is a great utility to print the current state during debugging (no Proxies in the way). The output of current can also be safely leaked outside the producer. */\nexport function current<T>(value: T): T\nexport function current(value: any): any {\n\tif (!isDraft(value)) die(10, value)\n\treturn currentImpl(value)\n}\n\nfunction currentImpl(value: any): any {\n\tif (!isDraftable(value) || isFrozen(value)) return value\n\tconst state: ImmerState | undefined = value[DRAFT_STATE]\n\tlet copy: any\n\tif (state) {\n\t\tif (!state.modified_) return state.base_\n\t\t// Optimization: avoid generating new drafts during copying\n\t\tstate.finalized_ = true\n\t\tcopy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_)\n\t} else {\n\t\tcopy = shallowCopy(value, true)\n\t}\n\t// recurse\n\teach(copy, (key, childValue) => {\n\t\tset(copy, key, currentImpl(childValue))\n\t})\n\tif (state) {\n\t\tstate.finalized_ = false\n\t}\n\treturn copy\n}\n","import {immerable} from \"../immer\"\nimport {\n\tImmerState,\n\tPatch,\n\tSetState,\n\tProxyArrayState,\n\tMapState,\n\tProxyObjectState,\n\tPatchPath,\n\tget,\n\teach,\n\thas,\n\tgetArchtype,\n\tgetPrototypeOf,\n\tisSet,\n\tisMap,\n\tloadPlugin,\n\tArchType,\n\tdie,\n\tisDraft,\n\tisDraftable,\n\tNOTHING,\n\terrors\n} from \"../internal\"\n\nexport function enablePatches() {\n\tconst errorOffset = 16\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\terrors.push(\n\t\t\t'Sets cannot have \"replace\" patches.',\n\t\t\tfunction(op: string) {\n\t\t\t\treturn \"Unsupported patch operation: \" + op\n\t\t\t},\n\t\t\tfunction(path: string) {\n\t\t\t\treturn \"Cannot apply patch, path doesn't resolve: \" + path\n\t\t\t},\n\t\t\t\"Patching reserved attributes like __proto__, prototype and constructor is not allowed\"\n\t\t)\n\t}\n\n\tconst REPLACE = \"replace\"\n\tconst ADD = \"add\"\n\tconst REMOVE = \"remove\"\n\n\tfunction generatePatches_(\n\t\tstate: ImmerState,\n\t\tbasePath: PatchPath,\n\t\tpatches: Patch[],\n\t\tinversePatches: Patch[]\n\t): void {\n\t\tswitch (state.type_) {\n\t\t\tcase ArchType.Object:\n\t\t\tcase ArchType.Map:\n\t\t\t\treturn generatePatchesFromAssigned(\n\t\t\t\t\tstate,\n\t\t\t\t\tbasePath,\n\t\t\t\t\tpatches,\n\t\t\t\t\tinversePatches\n\t\t\t\t)\n\t\t\tcase ArchType.Array:\n\t\t\t\treturn generateArrayPatches(state, basePath, patches, inversePatches)\n\t\t\tcase ArchType.Set:\n\t\t\t\treturn generateSetPatches(\n\t\t\t\t\t(state as any) as SetState,\n\t\t\t\t\tbasePath,\n\t\t\t\t\tpatches,\n\t\t\t\t\tinversePatches\n\t\t\t\t)\n\t\t}\n\t}\n\n\tfunction generateArrayPatches(\n\t\tstate: ProxyArrayState,\n\t\tbasePath: PatchPath,\n\t\tpatches: Patch[],\n\t\tinversePatches: Patch[]\n\t) {\n\t\tlet {base_, assigned_} = state\n\t\tlet copy_ = state.copy_!\n\n\t\t// Reduce complexity by ensuring `base` is never longer.\n\t\tif (copy_.length < base_.length) {\n\t\t\t// @ts-ignore\n\t\t\t;[base_, copy_] = [copy_, base_]\n\t\t\t;[patches, inversePatches] = [inversePatches, patches]\n\t\t}\n\n\t\t// Process replaced indices.\n\t\tfor (let i = 0; i < base_.length; i++) {\n\t\t\tif (assigned_[i] && copy_[i] !== base_[i]) {\n\t\t\t\tconst path = basePath.concat([i])\n\t\t\t\tpatches.push({\n\t\t\t\t\top: REPLACE,\n\t\t\t\t\tpath,\n\t\t\t\t\t// Need to maybe clone it, as it can in fact be the original value\n\t\t\t\t\t// due to the base/copy inversion at the start of this function\n\t\t\t\t\tvalue: clonePatchValueIfNeeded(copy_[i])\n\t\t\t\t})\n\t\t\t\tinversePatches.push({\n\t\t\t\t\top: REPLACE,\n\t\t\t\t\tpath,\n\t\t\t\t\tvalue: clonePatchValueIfNeeded(base_[i])\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\t// Process added indices.\n\t\tfor (let i = base_.length; i < copy_.length; i++) {\n\t\t\tconst path = basePath.concat([i])\n\t\t\tpatches.push({\n\t\t\t\top: ADD,\n\t\t\t\tpath,\n\t\t\t\t// Need to maybe clone it, as it can in fact be the original value\n\t\t\t\t// due to the base/copy inversion at the start of this function\n\t\t\t\tvalue: clonePatchValueIfNeeded(copy_[i])\n\t\t\t})\n\t\t}\n\t\tfor (let i = copy_.length - 1; base_.length <= i; --i) {\n\t\t\tconst path = basePath.concat([i])\n\t\t\tinversePatches.push({\n\t\t\t\top: REMOVE,\n\t\t\t\tpath\n\t\t\t})\n\t\t}\n\t}\n\n\t// This is used for both Map objects and normal objects.\n\tfunction generatePatchesFromAssigned(\n\t\tstate: MapState | ProxyObjectState,\n\t\tbasePath: PatchPath,\n\t\tpatches: Patch[],\n\t\tinversePatches: Patch[]\n\t) {\n\t\tconst {base_, copy_} = state\n\t\teach(state.assigned_!, (key, assignedValue) => {\n\t\t\tconst origValue = get(base_, key)\n\t\t\tconst value = get(copy_!, key)\n\t\t\tconst op = !assignedValue ? REMOVE : has(base_, key) ? REPLACE : ADD\n\t\t\tif (origValue === value && op === REPLACE) return\n\t\t\tconst path = basePath.concat(key as any)\n\t\t\tpatches.push(op === REMOVE ? {op, path} : {op, path, value})\n\t\t\tinversePatches.push(\n\t\t\t\top === ADD\n\t\t\t\t\t? {op: REMOVE, path}\n\t\t\t\t\t: op === REMOVE\n\t\t\t\t\t? {op: ADD, path, value: clonePatchValueIfNeeded(origValue)}\n\t\t\t\t\t: {op: REPLACE, path, value: clonePatchValueIfNeeded(origValue)}\n\t\t\t)\n\t\t})\n\t}\n\n\tfunction generateSetPatches(\n\t\tstate: SetState,\n\t\tbasePath: PatchPath,\n\t\tpatches: Patch[],\n\t\tinversePatches: Patch[]\n\t) {\n\t\tlet {base_, copy_} = state\n\n\t\tlet i = 0\n\t\tbase_.forEach((value: any) => {\n\t\t\tif (!copy_!.has(value)) {\n\t\t\t\tconst path = basePath.concat([i])\n\t\t\t\tpatches.push({\n\t\t\t\t\top: REMOVE,\n\t\t\t\t\tpath,\n\t\t\t\t\tvalue\n\t\t\t\t})\n\t\t\t\tinversePatches.unshift({\n\t\t\t\t\top: ADD,\n\t\t\t\t\tpath,\n\t\t\t\t\tvalue\n\t\t\t\t})\n\t\t\t}\n\t\t\ti++\n\t\t})\n\t\ti = 0\n\t\tcopy_!.forEach((value: any) => {\n\t\t\tif (!base_.has(value)) {\n\t\t\t\tconst path = basePath.concat([i])\n\t\t\t\tpatches.push({\n\t\t\t\t\top: ADD,\n\t\t\t\t\tpath,\n\t\t\t\t\tvalue\n\t\t\t\t})\n\t\t\t\tinversePatches.unshift({\n\t\t\t\t\top: REMOVE,\n\t\t\t\t\tpath,\n\t\t\t\t\tvalue\n\t\t\t\t})\n\t\t\t}\n\t\t\ti++\n\t\t})\n\t}\n\n\tfunction generateReplacementPatches_(\n\t\tbaseValue: any,\n\t\treplacement: any,\n\t\tpatches: Patch[],\n\t\tinversePatches: Patch[]\n\t): void {\n\t\tpatches.push({\n\t\t\top: REPLACE,\n\t\t\tpath: [],\n\t\t\tvalue: replacement === NOTHING ? undefined : replacement\n\t\t})\n\t\tinversePatches.push({\n\t\t\top: REPLACE,\n\t\t\tpath: [],\n\t\t\tvalue: baseValue\n\t\t})\n\t}\n\n\tfunction applyPatches_<T>(draft: T, patches: readonly Patch[]): T {\n\t\tpatches.forEach(patch => {\n\t\t\tconst {path, op} = patch\n\n\t\t\tlet base: any = draft\n\t\t\tfor (let i = 0; i < path.length - 1; i++) {\n\t\t\t\tconst parentType = getArchtype(base)\n\t\t\t\tlet p = path[i]\n\t\t\t\tif (typeof p !== \"string\" && typeof p !== \"number\") {\n\t\t\t\t\tp = \"\" + p\n\t\t\t\t}\n\n\t\t\t\t// See #738, avoid prototype pollution\n\t\t\t\tif (\n\t\t\t\t\t(parentType === ArchType.Object || parentType === ArchType.Array) &&\n\t\t\t\t\t(p === \"__proto__\" || p === \"constructor\")\n\t\t\t\t)\n\t\t\t\t\tdie(errorOffset + 3)\n\t\t\t\tif (typeof base === \"function\" && p === \"prototype\")\n\t\t\t\t\tdie(errorOffset + 3)\n\t\t\t\tbase = get(base, p)\n\t\t\t\tif (typeof base !== \"object\") die(errorOffset + 2, path.join(\"/\"))\n\t\t\t}\n\n\t\t\tconst type = getArchtype(base)\n\t\t\tconst value = deepClonePatchValue(patch.value) // used to clone patch to ensure original patch is not modified, see #411\n\t\t\tconst key = path[path.length - 1]\n\t\t\tswitch (op) {\n\t\t\t\tcase REPLACE:\n\t\t\t\t\tswitch (type) {\n\t\t\t\t\t\tcase ArchType.Map:\n\t\t\t\t\t\t\treturn base.set(key, value)\n\t\t\t\t\t\t/* istanbul ignore next */\n\t\t\t\t\t\tcase ArchType.Set:\n\t\t\t\t\t\t\tdie(errorOffset)\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t// if value is an object, then it's assigned by reference\n\t\t\t\t\t\t\t// in the following add or remove ops, the value field inside the patch will also be modifyed\n\t\t\t\t\t\t\t// so we use value from the cloned patch\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\treturn (base[key] = value)\n\t\t\t\t\t}\n\t\t\t\tcase ADD:\n\t\t\t\t\tswitch (type) {\n\t\t\t\t\t\tcase ArchType.Array:\n\t\t\t\t\t\t\treturn key === \"-\"\n\t\t\t\t\t\t\t\t? base.push(value)\n\t\t\t\t\t\t\t\t: base.splice(key as any, 0, value)\n\t\t\t\t\t\tcase ArchType.Map:\n\t\t\t\t\t\t\treturn base.set(key, value)\n\t\t\t\t\t\tcase ArchType.Set:\n\t\t\t\t\t\t\treturn base.add(value)\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn (base[key] = value)\n\t\t\t\t\t}\n\t\t\t\tcase REMOVE:\n\t\t\t\t\tswitch (type) {\n\t\t\t\t\t\tcase ArchType.Array:\n\t\t\t\t\t\t\treturn base.splice(key as any, 1)\n\t\t\t\t\t\tcase ArchType.Map:\n\t\t\t\t\t\t\treturn base.delete(key)\n\t\t\t\t\t\tcase ArchType.Set:\n\t\t\t\t\t\t\treturn base.delete(patch.value)\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn delete base[key]\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tdie(errorOffset + 1, op)\n\t\t\t}\n\t\t})\n\n\t\treturn draft\n\t}\n\n\t// optimize: this is quite a performance hit, can we detect intelligently when it is needed?\n\t// E.g. auto-draft when new objects from outside are assigned and modified?\n\t// (See failing test when deepClone just returns obj)\n\tfunction deepClonePatchValue<T>(obj: T): T\n\tfunction deepClonePatchValue(obj: any) {\n\t\tif (!isDraftable(obj)) return obj\n\t\tif (Array.isArray(obj)) return obj.map(deepClonePatchValue)\n\t\tif (isMap(obj))\n\t\t\treturn new Map(\n\t\t\t\tArray.from(obj.entries()).map(([k, v]) => [k, deepClonePatchValue(v)])\n\t\t\t)\n\t\tif (isSet(obj)) return new Set(Array.from(obj).map(deepClonePatchValue))\n\t\tconst cloned = Object.create(getPrototypeOf(obj))\n\t\tfor (const key in obj) cloned[key] = deepClonePatchValue(obj[key])\n\t\tif (has(obj, immerable)) cloned[immerable] = obj[immerable]\n\t\treturn cloned\n\t}\n\n\tfunction clonePatchValueIfNeeded<T>(obj: T): T {\n\t\tif (isDraft(obj)) {\n\t\t\treturn deepClonePatchValue(obj)\n\t\t} else return obj\n\t}\n\n\tloadPlugin(\"Patches\", {\n\t\tapplyPatches_,\n\t\tgeneratePatches_,\n\t\tgenerateReplacementPatches_\n\t})\n}\n","// types only!\nimport {\n\tImmerState,\n\tAnyMap,\n\tAnySet,\n\tMapState,\n\tSetState,\n\tDRAFT_STATE,\n\tgetCurrentScope,\n\tlatest,\n\tisDraftable,\n\tcreateProxy,\n\tloadPlugin,\n\tmarkChanged,\n\tdie,\n\tArchType,\n\teach\n} from \"../internal\"\n\nexport function enableMapSet() {\n\tclass DraftMap extends Map {\n\t\t[DRAFT_STATE]: MapState\n\n\t\tconstructor(target: AnyMap, parent?: ImmerState) {\n\t\t\tsuper()\n\t\t\tthis[DRAFT_STATE] = {\n\t\t\t\ttype_: ArchType.Map,\n\t\t\t\tparent_: parent,\n\t\t\t\tscope_: parent ? parent.scope_ : getCurrentScope()!,\n\t\t\t\tmodified_: false,\n\t\t\t\tfinalized_: false,\n\t\t\t\tcopy_: undefined,\n\t\t\t\tassigned_: undefined,\n\t\t\t\tbase_: target,\n\t\t\t\tdraft_: this as any,\n\t\t\t\tisManual_: false,\n\t\t\t\trevoked_: false\n\t\t\t}\n\t\t}\n\n\t\tget size(): number {\n\t\t\treturn latest(this[DRAFT_STATE]).size\n\t\t}\n\n\t\thas(key: any): boolean {\n\t\t\treturn latest(this[DRAFT_STATE]).has(key)\n\t\t}\n\n\t\tset(key: any, value: any) {\n\t\t\tconst state: MapState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\tif (!latest(state).has(key) || latest(state).get(key) !== value) {\n\t\t\t\tprepareMapCopy(state)\n\t\t\t\tmarkChanged(state)\n\t\t\t\tstate.assigned_!.set(key, true)\n\t\t\t\tstate.copy_!.set(key, value)\n\t\t\t\tstate.assigned_!.set(key, true)\n\t\t\t}\n\t\t\treturn this\n\t\t}\n\n\t\tdelete(key: any): boolean {\n\t\t\tif (!this.has(key)) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tconst state: MapState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\tprepareMapCopy(state)\n\t\t\tmarkChanged(state)\n\t\t\tif (state.base_.has(key)) {\n\t\t\t\tstate.assigned_!.set(key, false)\n\t\t\t} else {\n\t\t\t\tstate.assigned_!.delete(key)\n\t\t\t}\n\t\t\tstate.copy_!.delete(key)\n\t\t\treturn true\n\t\t}\n\n\t\tclear() {\n\t\t\tconst state: MapState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\tif (latest(state).size) {\n\t\t\t\tprepareMapCopy(state)\n\t\t\t\tmarkChanged(state)\n\t\t\t\tstate.assigned_ = new Map()\n\t\t\t\teach(state.base_, key => {\n\t\t\t\t\tstate.assigned_!.set(key, false)\n\t\t\t\t})\n\t\t\t\tstate.copy_!.clear()\n\t\t\t}\n\t\t}\n\n\t\tforEach(cb: (value: any, key: any, self: any) => void, thisArg?: any) {\n\t\t\tconst state: MapState = this[DRAFT_STATE]\n\t\t\tlatest(state).forEach((_value: any, key: any, _map: any) => {\n\t\t\t\tcb.call(thisArg, this.get(key), key, this)\n\t\t\t})\n\t\t}\n\n\t\tget(key: any): any {\n\t\t\tconst state: MapState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\tconst value = latest(state).get(key)\n\t\t\tif (state.finalized_ || !isDraftable(value)) {\n\t\t\t\treturn value\n\t\t\t}\n\t\t\tif (value !== state.base_.get(key)) {\n\t\t\t\treturn value // either already drafted or reassigned\n\t\t\t}\n\t\t\t// despite what it looks, this creates a draft only once, see above condition\n\t\t\tconst draft = createProxy(value, state)\n\t\t\tprepareMapCopy(state)\n\t\t\tstate.copy_!.set(key, draft)\n\t\t\treturn draft\n\t\t}\n\n\t\tkeys(): IterableIterator<any> {\n\t\t\treturn latest(this[DRAFT_STATE]).keys()\n\t\t}\n\n\t\tvalues(): IterableIterator<any> {\n\t\t\tconst iterator = this.keys()\n\t\t\treturn {\n\t\t\t\t[Symbol.iterator]: () => this.values(),\n\t\t\t\tnext: () => {\n\t\t\t\t\tconst r = iterator.next()\n\t\t\t\t\t/* istanbul ignore next */\n\t\t\t\t\tif (r.done) return r\n\t\t\t\t\tconst value = this.get(r.value)\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdone: false,\n\t\t\t\t\t\tvalue\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} as any\n\t\t}\n\n\t\tentries(): IterableIterator<[any, any]> {\n\t\t\tconst iterator = this.keys()\n\t\t\treturn {\n\t\t\t\t[Symbol.iterator]: () => this.entries(),\n\t\t\t\tnext: () => {\n\t\t\t\t\tconst r = iterator.next()\n\t\t\t\t\t/* istanbul ignore next */\n\t\t\t\t\tif (r.done) return r\n\t\t\t\t\tconst value = this.get(r.value)\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdone: false,\n\t\t\t\t\t\tvalue: [r.value, value]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} as any\n\t\t}\n\n\t\t[Symbol.iterator]() {\n\t\t\treturn this.entries()\n\t\t}\n\t}\n\n\tfunction proxyMap_<T extends AnyMap>(target: T, parent?: ImmerState): T {\n\t\t// @ts-ignore\n\t\treturn new DraftMap(target, parent)\n\t}\n\n\tfunction prepareMapCopy(state: MapState) {\n\t\tif (!state.copy_) {\n\t\t\tstate.assigned_ = new Map()\n\t\t\tstate.copy_ = new Map(state.base_)\n\t\t}\n\t}\n\n\tclass DraftSet extends Set {\n\t\t[DRAFT_STATE]: SetState\n\t\tconstructor(target: AnySet, parent?: ImmerState) {\n\t\t\tsuper()\n\t\t\tthis[DRAFT_STATE] = {\n\t\t\t\ttype_: ArchType.Set,\n\t\t\t\tparent_: parent,\n\t\t\t\tscope_: parent ? parent.scope_ : getCurrentScope()!,\n\t\t\t\tmodified_: false,\n\t\t\t\tfinalized_: false,\n\t\t\t\tcopy_: undefined,\n\t\t\t\tbase_: target,\n\t\t\t\tdraft_: this,\n\t\t\t\tdrafts_: new Map(),\n\t\t\t\trevoked_: false,\n\t\t\t\tisManual_: false\n\t\t\t}\n\t\t}\n\n\t\tget size(): number {\n\t\t\treturn latest(this[DRAFT_STATE]).size\n\t\t}\n\n\t\thas(value: any): boolean {\n\t\t\tconst state: SetState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\t// bit of trickery here, to be able to recognize both the value, and the draft of its value\n\t\t\tif (!state.copy_) {\n\t\t\t\treturn state.base_.has(value)\n\t\t\t}\n\t\t\tif (state.copy_.has(value)) return true\n\t\t\tif (state.drafts_.has(value) && state.copy_.has(state.drafts_.get(value)))\n\t\t\t\treturn true\n\t\t\treturn false\n\t\t}\n\n\t\tadd(value: any): any {\n\t\t\tconst state: SetState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\tif (!this.has(value)) {\n\t\t\t\tprepareSetCopy(state)\n\t\t\t\tmarkChanged(state)\n\t\t\t\tstate.copy_!.add(value)\n\t\t\t}\n\t\t\treturn this\n\t\t}\n\n\t\tdelete(value: any): any {\n\t\t\tif (!this.has(value)) {\n\t\t\t\treturn false\n\t\t\t}\n\n\t\t\tconst state: SetState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\tprepareSetCopy(state)\n\t\t\tmarkChanged(state)\n\t\t\treturn (\n\t\t\t\tstate.copy_!.delete(value) ||\n\t\t\t\t(state.drafts_.has(value)\n\t\t\t\t\t? state.copy_!.delete(state.drafts_.get(value))\n\t\t\t\t\t: /* istanbul ignore next */ false)\n\t\t\t)\n\t\t}\n\n\t\tclear() {\n\t\t\tconst state: SetState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\tif (latest(state).size) {\n\t\t\t\tprepareSetCopy(state)\n\t\t\t\tmarkChanged(state)\n\t\t\t\tstate.copy_!.clear()\n\t\t\t}\n\t\t}\n\n\t\tvalues(): IterableIterator<any> {\n\t\t\tconst state: SetState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\tprepareSetCopy(state)\n\t\t\treturn state.copy_!.values()\n\t\t}\n\n\t\tentries(): IterableIterator<[any, any]> {\n\t\t\tconst state: SetState = this[DRAFT_STATE]\n\t\t\tassertUnrevoked(state)\n\t\t\tprepareSetCopy(state)\n\t\t\treturn state.copy_!.entries()\n\t\t}\n\n\t\tkeys(): IterableIterator<any> {\n\t\t\treturn this.values()\n\t\t}\n\n\t\t[Symbol.iterator]() {\n\t\t\treturn this.values()\n\t\t}\n\n\t\tforEach(cb: any, thisArg?: any) {\n\t\t\tconst iterator = this.values()\n\t\t\tlet result = iterator.next()\n\t\t\twhile (!result.done) {\n\t\t\t\tcb.call(thisArg, result.value, result.value, this)\n\t\t\t\tresult = iterator.next()\n\t\t\t}\n\t\t}\n\t}\n\tfunction proxySet_<T extends AnySet>(target: T, parent?: ImmerState): T {\n\t\t// @ts-ignore\n\t\treturn new DraftSet(target, parent)\n\t}\n\n\tfunction prepareSetCopy(state: SetState) {\n\t\tif (!state.copy_) {\n\t\t\t// create drafts for all entries to preserve insertion order\n\t\t\tstate.copy_ = new Set()\n\t\t\tstate.base_.forEach(value => {\n\t\t\t\tif (isDraftable(value)) {\n\t\t\t\t\tconst draft = createProxy(value, state)\n\t\t\t\t\tstate.drafts_.set(value, draft)\n\t\t\t\t\tstate.copy_!.add(draft)\n\t\t\t\t} else {\n\t\t\t\t\tstate.copy_!.add(value)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\n\tfunction assertUnrevoked(state: any /*ES5State | MapState | SetState*/) {\n\t\tif (state.revoked_) die(3, JSON.stringify(latest(state)))\n\t}\n\n\tloadPlugin(\"MapSet\", {proxyMap_, proxySet_})\n}\n","import {\n\tIProduce,\n\tIProduceWithPatches,\n\tImmer,\n\tDraft,\n\tImmutable\n} from \"./internal\"\n\nexport {\n\tDraft,\n\tWritableDraft,\n\tImmutable,\n\tPatch,\n\tPatchListener,\n\tProducer,\n\toriginal,\n\tcurrent,\n\tisDraft,\n\tisDraftable,\n\tNOTHING as nothing,\n\tDRAFTABLE as immerable,\n\tfreeze,\n\tObjectish,\n\tStrictMode\n} from \"./internal\"\n\nconst immer = new Immer()\n\n/**\n * The `produce` function takes a value and a \"recipe function\" (whose\n * return value often depends on the base state). The recipe function is\n * free to mutate its first argument however it wants. All mutations are\n * only ever applied to a __copy__ of the base state.\n *\n * Pass only a function to create a \"curried producer\" which relieves you\n * from passing the recipe function every time.\n *\n * Only plain objects and arrays are made mutable. All other objects are\n * considered uncopyable.\n *\n * Note: This function is __bound__ to its `Immer` instance.\n *\n * @param {any} base - the initial state\n * @param {Function} producer - function that receives a proxy of the base state as first argument and which can be freely modified\n * @param {Function} patchListener - optional function that will be called with all the patches produced here\n * @returns {any} a new state, or the initial state if nothing was modified\n */\nexport const produce: IProduce = immer.produce\n\n/**\n * Like `produce`, but `produceWithPatches` always returns a tuple\n * [nextState, patches, inversePatches] (instead of just the next state)\n */\nexport const produceWithPatches: IProduceWithPatches = immer.produceWithPatches.bind(\n\timmer\n)\n\n/**\n * Pass true to automatically freeze all copies created by Immer.\n *\n * Always freeze by default, even in production mode\n */\nexport const setAutoFreeze = immer.setAutoFreeze.bind(immer)\n\n/**\n * Pass true to enable strict shallow copy.\n *\n * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.\n */\nexport const setUseStrictShallowCopy = immer.setUseStrictShallowCopy.bind(immer)\n\n/**\n * Apply an array of Immer patches to the first argument.\n *\n * This function is a producer, which means copy-on-write is in effect.\n */\nexport const applyPatches = immer.applyPatches.bind(immer)\n\n/**\n * Create an Immer draft from the given base state, which may be a draft itself.\n * The draft can be modified until you finalize it with the `finishDraft` function.\n */\nexport const createDraft = immer.createDraft.bind(immer)\n\n/**\n * Finalize an Immer draft from a `createDraft` call, returning the base state\n * (if no changes were made) or a modified copy. The draft must *not* be\n * mutated afterwards.\n *\n * Pass a function as the 2nd argument to generate Immer patches based on the\n * changes that were made.\n */\nexport const finishDraft = immer.finishDraft.bind(immer)\n\n/**\n * This function is actually a no-op, but can be used to cast an immutable type\n * to an draft type and make TypeScript happy\n *\n * @param value\n */\nexport function castDraft<T>(value: T): Draft<T> {\n\treturn value as any\n}\n\n/**\n * This function is actually a no-op, but can be used to cast a mutable type\n * to an immutable type and make TypeScript happy\n * @param value\n */\nexport function castImmutable<T>(value: T): Immutable<T> {\n\treturn value as any\n}\n\nexport {Immer}\n\nexport {enablePatches} from \"./plugins/patches\"\nexport {enableMapSet} from \"./plugins/mapset\"\n","import { Operation, Path } from '..'\n\n/**\n * `PathRef` objects keep a specific path in a document synced over time as new\n * operations are applied to the editor. You can access their `current` property\n * at any time for the up-to-date path value.\n */\n\nexport interface PathRef {\n  current: Path | null\n  affinity: 'forward' | 'backward' | null\n  unref(): Path | null\n}\n\nexport interface PathRefInterface {\n  /**\n   * Transform the path ref's current value by an operation.\n   */\n  transform: (ref: PathRef, op: Operation) => void\n}\n\n// eslint-disable-next-line no-redeclare\nexport const PathRef: PathRefInterface = {\n  transform(ref: PathRef, op: Operation): void {\n    const { current, affinity } = ref\n\n    if (current == null) {\n      return\n    }\n\n    const path = Path.transform(current, op, { affinity })\n    ref.current = path\n\n    if (path == null) {\n      ref.unref()\n    }\n  },\n}\n","import { Operation, Point } from '..'\nimport { TextDirection } from '../types/types'\n\n/**\n * `PointRef` objects keep a specific point in a document synced over time as new\n * operations are applied to the editor. You can access their `current` property\n * at any time for the up-to-date point value.\n */\n\nexport interface PointRef {\n  current: Point | null\n  affinity: TextDirection | null\n  unref(): Point | null\n}\n\nexport interface PointRefInterface {\n  /**\n   * Transform the point ref's current value by an operation.\n   */\n  transform: (ref: PointRef, op: Operation) => void\n}\n\n// eslint-disable-next-line no-redeclare\nexport const PointRef: PointRefInterface = {\n  transform(ref: PointRef, op: Operation): void {\n    const { current, affinity } = ref\n\n    if (current == null) {\n      return\n    }\n\n    const point = Point.transform(current, op, { affinity })\n    ref.current = point\n\n    if (point == null) {\n      ref.unref()\n    }\n  },\n}\n","import { Operation, Range } from '..'\n\n/**\n * `RangeRef` objects keep a specific range in a document synced over time as new\n * operations are applied to the editor. You can access their `current` property\n * at any time for the up-to-date range value.\n */\n\nexport interface RangeRef {\n  current: Range | null\n  affinity: 'forward' | 'backward' | 'outward' | 'inward' | null\n  unref(): Range | null\n}\n\nexport interface RangeRefInterface {\n  /**\n   * Transform the range ref's current value by an operation.\n   */\n  transform: (ref: RangeRef, op: Operation) => void\n}\n\n// eslint-disable-next-line no-redeclare\nexport const RangeRef: RangeRefInterface = {\n  transform(ref: RangeRef, op: Operation): void {\n    const { current, affinity } = ref\n\n    if (current == null) {\n      return\n    }\n\n    const path = Range.transform(current, op, { affinity })\n    ref.current = path\n\n    if (path == null) {\n      ref.unref()\n    }\n  },\n}\n","import { Editor, Path, PathRef, PointRef, RangeRef } from '..'\n\nexport const DIRTY_PATHS: WeakMap<Editor, Path[]> = new WeakMap()\nexport const DIRTY_PATH_KEYS: WeakMap<Editor, Set<string>> = new WeakMap()\nexport const FLUSHING: WeakMap<Editor, boolean> = new WeakMap()\nexport const NORMALIZING: WeakMap<Editor, boolean> = new WeakMap()\nexport const PATH_REFS: WeakMap<Editor, Set<PathRef>> = new WeakMap()\nexport const POINT_REFS: WeakMap<Editor, Set<PointRef>> = new WeakMap()\nexport const RANGE_REFS: WeakMap<Editor, Set<RangeRef>> = new WeakMap()\n","import {\n  InsertNodeOperation,\n  MergeNodeOperation,\n  MoveNodeOperation,\n  Operation,\n  RemoveNodeOperation,\n  SplitNodeOperation,\n} from '..'\nimport { TextDirection } from '../types/types'\n\n/**\n * `Path` arrays are a list of indexes that describe a node's exact position in\n * a Slate node tree. Although they are usually relative to the root `Editor`\n * object, they can be relative to any `Node` object.\n */\n\nexport type Path = number[]\n\nexport interface PathAncestorsOptions {\n  reverse?: boolean\n}\n\nexport interface PathLevelsOptions {\n  reverse?: boolean\n}\n\nexport interface PathTransformOptions {\n  affinity?: TextDirection | null\n}\n\nexport interface PathInterface {\n  /**\n   * Get a list of ancestor paths for a given path.\n   *\n   * The paths are sorted from shallowest to deepest ancestor. However, if the\n   * `reverse: true` option is passed, they are reversed.\n   */\n  ancestors: (path: Path, options?: PathAncestorsOptions) => Path[]\n\n  /**\n   * Get the common ancestor path of two paths.\n   */\n  common: (path: Path, another: Path) => Path\n\n  /**\n   * Compare a path to another, returning an integer indicating whether the path\n   * was before, at, or after the other.\n   *\n   * Note: Two paths of unequal length can still receive a `0` result if one is\n   * directly above or below the other. If you want exact matching, use\n   * [[Path.equals]] instead.\n   */\n  compare: (path: Path, another: Path) => -1 | 0 | 1\n\n  /**\n   * Check if a path ends after one of the indexes in another.\n   */\n  endsAfter: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if a path ends at one of the indexes in another.\n   */\n  endsAt: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if a path ends before one of the indexes in another.\n   */\n  endsBefore: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if a path is exactly equal to another.\n   */\n  equals: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if the path of previous sibling node exists\n   */\n  hasPrevious: (path: Path) => boolean\n\n  /**\n   * Check if a path is after another.\n   */\n  isAfter: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if a path is an ancestor of another.\n   */\n  isAncestor: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if a path is before another.\n   */\n  isBefore: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if a path is a child of another.\n   */\n  isChild: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if a path is equal to or an ancestor of another.\n   */\n  isCommon: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if a path is a descendant of another.\n   */\n  isDescendant: (path: Path, another: Path) => boolean\n\n  /**\n   * Check if a path is the parent of another.\n   */\n  isParent: (path: Path, another: Path) => boolean\n\n  /**\n   * Check is a value implements the `Path` interface.\n   */\n  isPath: (value: any) => value is Path\n\n  /**\n   * Check if a path is a sibling of another.\n   */\n  isSibling: (path: Path, another: Path) => boolean\n\n  /**\n   * Get a list of paths at every level down to a path. Note: this is the same\n   * as `Path.ancestors`, but including the path itself.\n   *\n   * The paths are sorted from shallowest to deepest. However, if the `reverse:\n   * true` option is passed, they are reversed.\n   */\n  levels: (path: Path, options?: PathLevelsOptions) => Path[]\n\n  /**\n   * Given a path, get the path to the next sibling node.\n   */\n  next: (path: Path) => Path\n\n  /**\n   * Returns whether this operation can affect paths or not. Used as an\n   * optimization when updating dirty paths during normalization\n   *\n   * NOTE: This *must* be kept in sync with the implementation of 'transform'\n   * below\n   */\n  operationCanTransformPath: (\n    operation: Operation\n  ) => operation is\n    | InsertNodeOperation\n    | RemoveNodeOperation\n    | MergeNodeOperation\n    | SplitNodeOperation\n    | MoveNodeOperation\n\n  /**\n   * Given a path, return a new path referring to the parent node above it.\n   */\n  parent: (path: Path) => Path\n\n  /**\n   * Given a path, get the path to the previous sibling node.\n   */\n  previous: (path: Path) => Path\n\n  /**\n   * Get a path relative to an ancestor.\n   */\n  relative: (path: Path, ancestor: Path) => Path\n\n  /**\n   * Transform a path by an operation.\n   */\n  transform: (\n    path: Path,\n    operation: Operation,\n    options?: PathTransformOptions\n  ) => Path | null\n}\n\n// eslint-disable-next-line no-redeclare\nexport const Path: PathInterface = {\n  ancestors(path: Path, options: PathAncestorsOptions = {}): Path[] {\n    const { reverse = false } = options\n    let paths = Path.levels(path, options)\n\n    if (reverse) {\n      paths = paths.slice(1)\n    } else {\n      paths = paths.slice(0, -1)\n    }\n\n    return paths\n  },\n\n  common(path: Path, another: Path): Path {\n    const common: Path = []\n\n    for (let i = 0; i < path.length && i < another.length; i++) {\n      const av = path[i]\n      const bv = another[i]\n\n      if (av !== bv) {\n        break\n      }\n\n      common.push(av)\n    }\n\n    return common\n  },\n\n  compare(path: Path, another: Path): -1 | 0 | 1 {\n    const min = Math.min(path.length, another.length)\n\n    for (let i = 0; i < min; i++) {\n      if (path[i] < another[i]) return -1\n      if (path[i] > another[i]) return 1\n    }\n\n    return 0\n  },\n\n  endsAfter(path: Path, another: Path): boolean {\n    const i = path.length - 1\n    const as = path.slice(0, i)\n    const bs = another.slice(0, i)\n    const av = path[i]\n    const bv = another[i]\n    return Path.equals(as, bs) && av > bv\n  },\n\n  endsAt(path: Path, another: Path): boolean {\n    const i = path.length\n    const as = path.slice(0, i)\n    const bs = another.slice(0, i)\n    return Path.equals(as, bs)\n  },\n\n  endsBefore(path: Path, another: Path): boolean {\n    const i = path.length - 1\n    const as = path.slice(0, i)\n    const bs = another.slice(0, i)\n    const av = path[i]\n    const bv = another[i]\n    return Path.equals(as, bs) && av < bv\n  },\n\n  equals(path: Path, another: Path): boolean {\n    return (\n      path.length === another.length && path.every((n, i) => n === another[i])\n    )\n  },\n\n  hasPrevious(path: Path): boolean {\n    return path[path.length - 1] > 0\n  },\n\n  isAfter(path: Path, another: Path): boolean {\n    return Path.compare(path, another) === 1\n  },\n\n  isAncestor(path: Path, another: Path): boolean {\n    return path.length < another.length && Path.compare(path, another) === 0\n  },\n\n  isBefore(path: Path, another: Path): boolean {\n    return Path.compare(path, another) === -1\n  },\n\n  isChild(path: Path, another: Path): boolean {\n    return (\n      path.length === another.length + 1 && Path.compare(path, another) === 0\n    )\n  },\n\n  isCommon(path: Path, another: Path): boolean {\n    return path.length <= another.length && Path.compare(path, another) === 0\n  },\n\n  isDescendant(path: Path, another: Path): boolean {\n    return path.length > another.length && Path.compare(path, another) === 0\n  },\n\n  isParent(path: Path, another: Path): boolean {\n    return (\n      path.length + 1 === another.length && Path.compare(path, another) === 0\n    )\n  },\n\n  isPath(value: any): value is Path {\n    return (\n      Array.isArray(value) &&\n      (value.length === 0 || typeof value[0] === 'number')\n    )\n  },\n\n  isSibling(path: Path, another: Path): boolean {\n    if (path.length !== another.length) {\n      return false\n    }\n\n    const as = path.slice(0, -1)\n    const bs = another.slice(0, -1)\n    const al = path[path.length - 1]\n    const bl = another[another.length - 1]\n    return al !== bl && Path.equals(as, bs)\n  },\n\n  levels(path: Path, options: PathLevelsOptions = {}): Path[] {\n    const { reverse = false } = options\n    const list: Path[] = []\n\n    for (let i = 0; i <= path.length; i++) {\n      list.push(path.slice(0, i))\n    }\n\n    if (reverse) {\n      list.reverse()\n    }\n\n    return list\n  },\n\n  next(path: Path): Path {\n    if (path.length === 0) {\n      throw new Error(\n        `Cannot get the next path of a root path [${path}], because it has no next index.`\n      )\n    }\n\n    const last = path[path.length - 1]\n    return path.slice(0, -1).concat(last + 1)\n  },\n\n  operationCanTransformPath(\n    operation: Operation\n  ): operation is\n    | InsertNodeOperation\n    | RemoveNodeOperation\n    | MergeNodeOperation\n    | SplitNodeOperation\n    | MoveNodeOperation {\n    switch (operation.type) {\n      case 'insert_node':\n      case 'remove_node':\n      case 'merge_node':\n      case 'split_node':\n      case 'move_node':\n        return true\n      default:\n        return false\n    }\n  },\n\n  parent(path: Path): Path {\n    if (path.length === 0) {\n      throw new Error(`Cannot get the parent path of the root path [${path}].`)\n    }\n\n    return path.slice(0, -1)\n  },\n\n  previous(path: Path): Path {\n    if (path.length === 0) {\n      throw new Error(\n        `Cannot get the previous path of a root path [${path}], because it has no previous index.`\n      )\n    }\n\n    const last = path[path.length - 1]\n\n    if (last <= 0) {\n      throw new Error(\n        `Cannot get the previous path of a first child path [${path}] because it would result in a negative index.`\n      )\n    }\n\n    return path.slice(0, -1).concat(last - 1)\n  },\n\n  relative(path: Path, ancestor: Path): Path {\n    if (!Path.isAncestor(ancestor, path) && !Path.equals(path, ancestor)) {\n      throw new Error(\n        `Cannot get the relative path of [${path}] inside ancestor [${ancestor}], because it is not above or equal to the path.`\n      )\n    }\n\n    return path.slice(ancestor.length)\n  },\n\n  transform(\n    path: Path | null,\n    operation: Operation,\n    options: PathTransformOptions = {}\n  ): Path | null {\n    if (!path) return null\n\n    // PERF: use destructing instead of immer\n    const p = [...path]\n    const { affinity = 'forward' } = options\n\n    // PERF: Exit early if the operation is guaranteed not to have an effect.\n    if (path.length === 0) {\n      return p\n    }\n\n    switch (operation.type) {\n      case 'insert_node': {\n        const { path: op } = operation\n\n        if (\n          Path.equals(op, p) ||\n          Path.endsBefore(op, p) ||\n          Path.isAncestor(op, p)\n        ) {\n          p[op.length - 1] += 1\n        }\n\n        break\n      }\n\n      case 'remove_node': {\n        const { path: op } = operation\n\n        if (Path.equals(op, p) || Path.isAncestor(op, p)) {\n          return null\n        } else if (Path.endsBefore(op, p)) {\n          p[op.length - 1] -= 1\n        }\n\n        break\n      }\n\n      case 'merge_node': {\n        const { path: op, position } = operation\n\n        if (Path.equals(op, p) || Path.endsBefore(op, p)) {\n          p[op.length - 1] -= 1\n        } else if (Path.isAncestor(op, p)) {\n          p[op.length - 1] -= 1\n          p[op.length] += position\n        }\n\n        break\n      }\n\n      case 'split_node': {\n        const { path: op, position } = operation\n\n        if (Path.equals(op, p)) {\n          if (affinity === 'forward') {\n            p[p.length - 1] += 1\n          } else if (affinity === 'backward') {\n            // Nothing, because it still refers to the right path.\n          } else {\n            return null\n          }\n        } else if (Path.endsBefore(op, p)) {\n          p[op.length - 1] += 1\n        } else if (Path.isAncestor(op, p) && path[op.length] >= position) {\n          p[op.length - 1] += 1\n          p[op.length] -= position\n        }\n\n        break\n      }\n\n      case 'move_node': {\n        const { path: op, newPath: onp } = operation\n\n        // If the old and new path are the same, it's a no-op.\n        if (Path.equals(op, onp)) {\n          return p\n        }\n\n        if (Path.isAncestor(op, p) || Path.equals(op, p)) {\n          const copy = onp.slice()\n\n          if (Path.endsBefore(op, onp) && op.length < onp.length) {\n            copy[op.length - 1] -= 1\n          }\n\n          return copy.concat(p.slice(op.length))\n        } else if (\n          Path.isSibling(op, onp) &&\n          (Path.isAncestor(onp, p) || Path.equals(onp, p))\n        ) {\n          if (Path.endsBefore(op, p)) {\n            p[op.length - 1] -= 1\n          } else {\n            p[op.length - 1] += 1\n          }\n        } else if (\n          Path.endsBefore(onp, p) ||\n          Path.equals(onp, p) ||\n          Path.isAncestor(onp, p)\n        ) {\n          if (Path.endsBefore(op, p)) {\n            p[op.length - 1] -= 1\n          }\n\n          p[onp.length - 1] += 1\n        } else if (Path.endsBefore(op, p)) {\n          if (Path.equals(onp, p)) {\n            p[onp.length - 1] += 1\n          }\n\n          p[op.length - 1] -= 1\n        }\n\n        break\n      }\n    }\n\n    return p\n  },\n}\n","export default function _typeof(o) {\n  \"@babel/helpers - typeof\";\n\n  return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n    return typeof o;\n  } : function (o) {\n    return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n  }, _typeof(o);\n}","import _typeof from \"./typeof.js\";\nexport default function _toPrimitive(input, hint) {\n  if (_typeof(input) !== \"object\" || input === null) return input;\n  var prim = input[Symbol.toPrimitive];\n  if (prim !== undefined) {\n    var res = prim.call(input, hint || \"default\");\n    if (_typeof(res) !== \"object\") return res;\n    throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n  }\n  return (hint === \"string\" ? String : Number)(input);\n}","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nexport default function _toPropertyKey(arg) {\n  var key = toPrimitive(arg, \"string\");\n  return _typeof(key) === \"symbol\" ? key : String(key);\n}","import toPropertyKey from \"./toPropertyKey.js\";\nexport default function _defineProperty(obj, key, value) {\n  key = toPropertyKey(key);\n  if (key in obj) {\n    Object.defineProperty(obj, key, {\n      value: value,\n      enumerable: true,\n      configurable: true,\n      writable: true\n    });\n  } else {\n    obj[key] = value;\n  }\n  return obj;\n}","import { createDraft, finishDraft, isDraft } from 'immer'\nimport {\n  Ancestor,\n  Descendant,\n  Editor,\n  Element,\n  Node,\n  NodeEntry,\n  Operation,\n  Path,\n  Point,\n  Range,\n  Scrubber,\n  Selection,\n  Text,\n} from '../../index'\n\nexport interface GeneralTransforms {\n  /**\n   * Transform the editor by an operation.\n   */\n  transform: (editor: Editor, op: Operation) => void\n}\n\nconst applyToDraft = (editor: Editor, selection: Selection, op: Operation) => {\n  switch (op.type) {\n    case 'insert_node': {\n      const { path, node } = op\n      const parent = Node.parent(editor, path)\n      const index = path[path.length - 1]\n\n      if (index > parent.children.length) {\n        throw new Error(\n          `Cannot apply an \"insert_node\" operation at path [${path}] because the destination is past the end of the node.`\n        )\n      }\n\n      parent.children.splice(index, 0, node)\n\n      if (selection) {\n        for (const [point, key] of Range.points(selection)) {\n          selection[key] = Point.transform(point, op)!\n        }\n      }\n\n      break\n    }\n\n    case 'insert_text': {\n      const { path, offset, text } = op\n      if (text.length === 0) break\n      const node = Node.leaf(editor, path)\n      const before = node.text.slice(0, offset)\n      const after = node.text.slice(offset)\n      node.text = before + text + after\n\n      if (selection) {\n        for (const [point, key] of Range.points(selection)) {\n          selection[key] = Point.transform(point, op)!\n        }\n      }\n\n      break\n    }\n\n    case 'merge_node': {\n      const { path } = op\n      const node = Node.get(editor, path)\n      const prevPath = Path.previous(path)\n      const prev = Node.get(editor, prevPath)\n      const parent = Node.parent(editor, path)\n      const index = path[path.length - 1]\n\n      if (Text.isText(node) && Text.isText(prev)) {\n        prev.text += node.text\n      } else if (!Text.isText(node) && !Text.isText(prev)) {\n        prev.children.push(...node.children)\n      } else {\n        throw new Error(\n          `Cannot apply a \"merge_node\" operation at path [${path}] to nodes of different interfaces: ${Scrubber.stringify(\n            node\n          )} ${Scrubber.stringify(prev)}`\n        )\n      }\n\n      parent.children.splice(index, 1)\n\n      if (selection) {\n        for (const [point, key] of Range.points(selection)) {\n          selection[key] = Point.transform(point, op)!\n        }\n      }\n\n      break\n    }\n\n    case 'move_node': {\n      const { path, newPath } = op\n\n      if (Path.isAncestor(path, newPath)) {\n        throw new Error(\n          `Cannot move a path [${path}] to new path [${newPath}] because the destination is inside itself.`\n        )\n      }\n\n      const node = Node.get(editor, path)\n      const parent = Node.parent(editor, path)\n      const index = path[path.length - 1]\n\n      // This is tricky, but since the `path` and `newPath` both refer to\n      // the same snapshot in time, there's a mismatch. After either\n      // removing the original position, the second step's path can be out\n      // of date. So instead of using the `op.newPath` directly, we\n      // transform `op.path` to ascertain what the `newPath` would be after\n      // the operation was applied.\n      parent.children.splice(index, 1)\n      const truePath = Path.transform(path, op)!\n      const newParent = Node.get(editor, Path.parent(truePath)) as Ancestor\n      const newIndex = truePath[truePath.length - 1]\n\n      newParent.children.splice(newIndex, 0, node)\n\n      if (selection) {\n        for (const [point, key] of Range.points(selection)) {\n          selection[key] = Point.transform(point, op)!\n        }\n      }\n\n      break\n    }\n\n    case 'remove_node': {\n      const { path } = op\n      const index = path[path.length - 1]\n      const parent = Node.parent(editor, path)\n      parent.children.splice(index, 1)\n\n      // Transform all the points in the value, but if the point was in the\n      // node that was removed we need to update the range or remove it.\n      if (selection) {\n        for (const [point, key] of Range.points(selection)) {\n          const result = Point.transform(point, op)\n\n          if (selection != null && result != null) {\n            selection[key] = result\n          } else {\n            let prev: NodeEntry<Text> | undefined\n            let next: NodeEntry<Text> | undefined\n\n            for (const [n, p] of Node.texts(editor)) {\n              if (Path.compare(p, path) === -1) {\n                prev = [n, p]\n              } else {\n                next = [n, p]\n                break\n              }\n            }\n\n            let preferNext = false\n            if (prev && next) {\n              if (Path.equals(next[1], path)) {\n                preferNext = !Path.hasPrevious(next[1])\n              } else {\n                preferNext =\n                  Path.common(prev[1], path).length <\n                  Path.common(next[1], path).length\n              }\n            }\n\n            if (prev && !preferNext) {\n              point.path = prev[1]\n              point.offset = prev[0].text.length\n            } else if (next) {\n              point.path = next[1]\n              point.offset = 0\n            } else {\n              selection = null\n            }\n          }\n        }\n      }\n\n      break\n    }\n\n    case 'remove_text': {\n      const { path, offset, text } = op\n      if (text.length === 0) break\n      const node = Node.leaf(editor, path)\n      const before = node.text.slice(0, offset)\n      const after = node.text.slice(offset + text.length)\n      node.text = before + after\n\n      if (selection) {\n        for (const [point, key] of Range.points(selection)) {\n          selection[key] = Point.transform(point, op)!\n        }\n      }\n\n      break\n    }\n\n    case 'set_node': {\n      const { path, properties, newProperties } = op\n\n      if (path.length === 0) {\n        throw new Error(`Cannot set properties on the root node!`)\n      }\n\n      const node = Node.get(editor, path)\n\n      for (const key in newProperties) {\n        if (key === 'children' || key === 'text') {\n          throw new Error(`Cannot set the \"${key}\" property of nodes!`)\n        }\n\n        const value = newProperties[<keyof Node>key]\n\n        if (value == null) {\n          delete node[<keyof Node>key]\n        } else {\n          node[<keyof Node>key] = value\n        }\n      }\n\n      // properties that were previously defined, but are now missing, must be deleted\n      for (const key in properties) {\n        if (!newProperties.hasOwnProperty(key)) {\n          delete node[<keyof Node>key]\n        }\n      }\n\n      break\n    }\n\n    case 'set_selection': {\n      const { newProperties } = op\n\n      if (newProperties == null) {\n        selection = newProperties\n      } else {\n        if (selection == null) {\n          if (!Range.isRange(newProperties)) {\n            throw new Error(\n              `Cannot apply an incomplete \"set_selection\" operation properties ${Scrubber.stringify(\n                newProperties\n              )} when there is no current selection.`\n            )\n          }\n\n          selection = { ...newProperties }\n        }\n\n        for (const key in newProperties) {\n          const value = newProperties[<keyof Range>key]\n\n          if (value == null) {\n            if (key === 'anchor' || key === 'focus') {\n              throw new Error(`Cannot remove the \"${key}\" selection property`)\n            }\n\n            delete selection[<keyof Range>key]\n          } else {\n            selection[<keyof Range>key] = value\n          }\n        }\n      }\n\n      break\n    }\n\n    case 'split_node': {\n      const { path, position, properties } = op\n\n      if (path.length === 0) {\n        throw new Error(\n          `Cannot apply a \"split_node\" operation at path [${path}] because the root node cannot be split.`\n        )\n      }\n\n      const node = Node.get(editor, path)\n      const parent = Node.parent(editor, path)\n      const index = path[path.length - 1]\n      let newNode: Descendant\n\n      if (Text.isText(node)) {\n        const before = node.text.slice(0, position)\n        const after = node.text.slice(position)\n        node.text = before\n        newNode = {\n          ...(properties as Partial<Text>),\n          text: after,\n        }\n      } else {\n        const before = node.children.slice(0, position)\n        const after = node.children.slice(position)\n        node.children = before\n\n        newNode = {\n          ...(properties as Partial<Element>),\n          children: after,\n        }\n      }\n\n      parent.children.splice(index + 1, 0, newNode)\n\n      if (selection) {\n        for (const [point, key] of Range.points(selection)) {\n          selection[key] = Point.transform(point, op)!\n        }\n      }\n\n      break\n    }\n  }\n  return selection\n}\n\n// eslint-disable-next-line no-redeclare\nexport const GeneralTransforms: GeneralTransforms = {\n  transform(editor: Editor, op: Operation): void {\n    editor.children = createDraft(editor.children)\n    let selection = editor.selection && createDraft(editor.selection)\n\n    try {\n      selection = applyToDraft(editor, selection, op)\n    } finally {\n      editor.children = finishDraft(editor.children)\n\n      if (selection) {\n        editor.selection = isDraft(selection)\n          ? (finishDraft(selection) as Range)\n          : selection\n      } else {\n        editor.selection = null\n      }\n    }\n  },\n}\n","import { Editor, Element, Location, Node, Path } from '../../index'\nimport { NodeMatch, PropsCompare, PropsMerge } from '../editor'\nimport { MaximizeMode, RangeMode } from '../../types/types'\n\nexport interface NodeInsertNodesOptions<T extends Node> {\n  at?: Location\n  match?: NodeMatch<T>\n  mode?: RangeMode\n  hanging?: boolean\n  select?: boolean\n  voids?: boolean\n  batchDirty?: boolean\n}\n\nexport interface NodeTransforms {\n  /**\n   * Insert nodes in the editor\n   * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.\n   */\n  insertNodes: <T extends Node>(\n    editor: Editor,\n    nodes: Node | Node[],\n    options?: NodeInsertNodesOptions<T>\n  ) => void\n\n  /**\n   * Lift nodes at a specific location upwards in the document tree, splitting\n   * their parent in two if necessary.\n   */\n  liftNodes: <T extends Node>(\n    editor: Editor,\n    options?: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: MaximizeMode\n      voids?: boolean\n    }\n  ) => void\n\n  /**\n   * Merge a node at a location with the previous node of the same depth,\n   * removing any empty containing nodes after the merge if necessary.\n   */\n  mergeNodes: <T extends Node>(\n    editor: Editor,\n    options?: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: RangeMode\n      hanging?: boolean\n      voids?: boolean\n    }\n  ) => void\n\n  /**\n   * Move the nodes at a location to a new location.\n   */\n  moveNodes: <T extends Node>(\n    editor: Editor,\n    options: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: MaximizeMode\n      to: Path\n      voids?: boolean\n    }\n  ) => void\n\n  /**\n   * Remove the nodes at a specific location in the document.\n   */\n  removeNodes: <T extends Node>(\n    editor: Editor,\n    options?: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: RangeMode\n      hanging?: boolean\n      voids?: boolean\n    }\n  ) => void\n\n  /**\n   * Set new properties on the nodes at a location.\n   */\n  setNodes: <T extends Node>(\n    editor: Editor,\n    props: Partial<T>,\n    options?: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: MaximizeMode\n      hanging?: boolean\n      split?: boolean\n      voids?: boolean\n      compare?: PropsCompare\n      merge?: PropsMerge\n    }\n  ) => void\n\n  /**\n   * Split the nodes at a specific location.\n   */\n  splitNodes: <T extends Node>(\n    editor: Editor,\n    options?: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: RangeMode\n      always?: boolean\n      height?: number\n      voids?: boolean\n    }\n  ) => void\n\n  /**\n   * Unset properties on the nodes at a location.\n   */\n  unsetNodes: <T extends Node>(\n    editor: Editor,\n    props: string | string[],\n    options?: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: MaximizeMode\n      hanging?: boolean\n      split?: boolean\n      voids?: boolean\n    }\n  ) => void\n\n  /**\n   * Unwrap the nodes at a location from a parent node, splitting the parent if\n   * necessary to ensure that only the content in the range is unwrapped.\n   */\n  unwrapNodes: <T extends Node>(\n    editor: Editor,\n    options?: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: MaximizeMode\n      split?: boolean\n      voids?: boolean\n    }\n  ) => void\n\n  /**\n   * Wrap the nodes at a location in a new container node, splitting the edges\n   * of the range first to ensure that only the content in the range is wrapped.\n   */\n  wrapNodes: <T extends Node>(\n    editor: Editor,\n    element: Element,\n    options?: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: MaximizeMode\n      split?: boolean\n      voids?: boolean\n    }\n  ) => void\n}\n\n// eslint-disable-next-line no-redeclare\nexport const NodeTransforms: NodeTransforms = {\n  insertNodes(editor, nodes, options) {\n    editor.insertNodes(nodes, options)\n  },\n  liftNodes(editor, options) {\n    editor.liftNodes(options)\n  },\n  mergeNodes(editor, options) {\n    editor.mergeNodes(options)\n  },\n  moveNodes(editor, options) {\n    editor.moveNodes(options)\n  },\n  removeNodes(editor, options) {\n    editor.removeNodes(options)\n  },\n  setNodes(editor, props, options) {\n    editor.setNodes(props, options)\n  },\n  splitNodes(editor, options) {\n    editor.splitNodes(options)\n  },\n  unsetNodes(editor, props, options) {\n    editor.unsetNodes(props, options)\n  },\n  unwrapNodes(editor, options) {\n    editor.unwrapNodes(options)\n  },\n  wrapNodes(editor, element, options) {\n    editor.wrapNodes(element, options)\n  },\n}\n","import { Editor, Location, Point, Range } from '../../index'\nimport { MoveUnit, SelectionEdge } from '../../types/types'\n\nexport interface SelectionCollapseOptions {\n  edge?: SelectionEdge\n}\n\nexport interface SelectionMoveOptions {\n  distance?: number\n  unit?: MoveUnit\n  reverse?: boolean\n  edge?: SelectionEdge\n}\n\nexport interface SelectionSetPointOptions {\n  edge?: SelectionEdge\n}\n\nexport interface SelectionTransforms {\n  /**\n   * Collapse the selection.\n   */\n  collapse: (editor: Editor, options?: SelectionCollapseOptions) => void\n\n  /**\n   * Unset the selection.\n   */\n  deselect: (editor: Editor) => void\n\n  /**\n   * Move the selection's point forward or backward.\n   */\n  move: (editor: Editor, options?: SelectionMoveOptions) => void\n\n  /**\n   * Set the selection to a new value.\n   */\n  select: (editor: Editor, target: Location) => void\n\n  /**\n   * Set new properties on one of the selection's points.\n   */\n  setPoint: (\n    editor: Editor,\n    props: Partial<Point>,\n    options?: SelectionSetPointOptions\n  ) => void\n\n  /**\n   * Set new properties on the selection.\n   */\n  setSelection: (editor: Editor, props: Partial<Range>) => void\n}\n\n// eslint-disable-next-line no-redeclare\nexport const SelectionTransforms: SelectionTransforms = {\n  collapse(editor, options) {\n    editor.collapse(options)\n  },\n  deselect(editor) {\n    editor.deselect()\n  },\n  move(editor, options) {\n    editor.move(options)\n  },\n  select(editor, target) {\n    editor.select(target)\n  },\n  setPoint(editor, props, options) {\n    editor.setPoint(props, options)\n  },\n  setSelection(editor, props) {\n    editor.setSelection(props)\n  },\n}\n","import { isPlainObject } from 'is-plain-object'\n\n/*\n  Custom deep equal comparison for Slate nodes.\n\n  We don't need general purpose deep equality;\n  Slate only supports plain values, Arrays, and nested objects.\n  Complex values nested inside Arrays are not supported.\n\n  Slate objects are designed to be serialised, so\n  missing keys are deliberately normalised to undefined.\n */\nexport const isDeepEqual = (\n  node: Record<string, any>,\n  another: Record<string, any>\n): boolean => {\n  for (const key in node) {\n    const a = node[key]\n    const b = another[key]\n    if (isPlainObject(a) && isPlainObject(b)) {\n      if (!isDeepEqual(a, b)) return false\n    } else if (Array.isArray(a) && Array.isArray(b)) {\n      if (a.length !== b.length) return false\n      for (let i = 0; i < a.length; i++) {\n        if (a[i] !== b[i]) return false\n      }\n    } else if (a !== b) {\n      return false\n    }\n  }\n\n  /*\n    Deep object equality is only necessary in one direction; in the reverse direction\n    we are only looking for keys that are missing.\n    As above, undefined keys are normalised to missing.\n  */\n\n  for (const key in another) {\n    if (node[key] === undefined && another[key] !== undefined) {\n      return false\n    }\n  }\n\n  return true\n}\n","export default function _objectWithoutPropertiesLoose(source, excluded) {\n  if (source == null) return {};\n  var target = {};\n  var sourceKeys = Object.keys(source);\n  var key, i;\n  for (i = 0; i < sourceKeys.length; i++) {\n    key = sourceKeys[i];\n    if (excluded.indexOf(key) >= 0) continue;\n    target[key] = source[key];\n  }\n  return target;\n}","import objectWithoutPropertiesLoose from \"./objectWithoutPropertiesLoose.js\";\nexport default function _objectWithoutProperties(source, excluded) {\n  if (source == null) return {};\n  var target = objectWithoutPropertiesLoose(source, excluded);\n  var key, i;\n  if (Object.getOwnPropertySymbols) {\n    var sourceSymbolKeys = Object.getOwnPropertySymbols(source);\n    for (i = 0; i < sourceSymbolKeys.length; i++) {\n      key = sourceSymbolKeys[i];\n      if (excluded.indexOf(key) >= 0) continue;\n      if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;\n      target[key] = source[key];\n    }\n  }\n  return target;\n}","import { produce } from 'immer'\nimport { isPlainObject } from 'is-plain-object'\nimport { ExtendedType, Operation, Path, Point, PointEntry } from '..'\nimport { RangeDirection } from '../types/types'\n\n/**\n * `Range` objects are a set of points that refer to a specific span of a Slate\n * document. They can define a span inside a single node or a can span across\n * multiple nodes.\n */\n\nexport interface BaseRange {\n  anchor: Point\n  focus: Point\n}\n\nexport type Range = ExtendedType<'Range', BaseRange>\n\nexport interface RangeEdgesOptions {\n  reverse?: boolean\n}\n\nexport interface RangeTransformOptions {\n  affinity?: RangeDirection | null\n}\n\nexport interface RangeInterface {\n  /**\n   * Get the start and end points of a range, in the order in which they appear\n   * in the document.\n   */\n  edges: (range: Range, options?: RangeEdgesOptions) => [Point, Point]\n\n  /**\n   * Get the end point of a range.\n   */\n  end: (range: Range) => Point\n\n  /**\n   * Check if a range is exactly equal to another.\n   */\n  equals: (range: Range, another: Range) => boolean\n\n  /**\n   * Check if a range includes a path, a point or part of another range.\n   */\n  includes: (range: Range, target: Path | Point | Range) => boolean\n\n  /**\n   * Check if a range includes another range.\n   */\n  surrounds: (range: Range, target: Range) => boolean\n\n  /**\n   * Get the intersection of a range with another.\n   */\n  intersection: (range: Range, another: Range) => Range | null\n\n  /**\n   * Check if a range is backward, meaning that its anchor point appears in the\n   * document _after_ its focus point.\n   */\n  isBackward: (range: Range) => boolean\n\n  /**\n   * Check if a range is collapsed, meaning that both its anchor and focus\n   * points refer to the exact same position in the document.\n   */\n  isCollapsed: (range: Range) => boolean\n\n  /**\n   * Check if a range is expanded.\n   *\n   * This is the opposite of [[Range.isCollapsed]] and is provided for legibility.\n   */\n  isExpanded: (range: Range) => boolean\n\n  /**\n   * Check if a range is forward.\n   *\n   * This is the opposite of [[Range.isBackward]] and is provided for legibility.\n   */\n  isForward: (range: Range) => boolean\n\n  /**\n   * Check if a value implements the [[Range]] interface.\n   */\n  isRange: (value: any) => value is Range\n\n  /**\n   * Iterate through all of the point entries in a range.\n   */\n  points: (range: Range) => Generator<PointEntry, void, undefined>\n\n  /**\n   * Get the start point of a range.\n   */\n  start: (range: Range) => Point\n\n  /**\n   * Transform a range by an operation.\n   */\n  transform: (\n    range: Range,\n    op: Operation,\n    options?: RangeTransformOptions\n  ) => Range | null\n}\n\n// eslint-disable-next-line no-redeclare\nexport const Range: RangeInterface = {\n  edges(range: Range, options: RangeEdgesOptions = {}): [Point, Point] {\n    const { reverse = false } = options\n    const { anchor, focus } = range\n    return Range.isBackward(range) === reverse\n      ? [anchor, focus]\n      : [focus, anchor]\n  },\n\n  end(range: Range): Point {\n    const [, end] = Range.edges(range)\n    return end\n  },\n\n  equals(range: Range, another: Range): boolean {\n    return (\n      Point.equals(range.anchor, another.anchor) &&\n      Point.equals(range.focus, another.focus)\n    )\n  },\n\n  surrounds(range: Range, target: Range): boolean {\n    const intersectionRange = Range.intersection(range, target)\n    if (!intersectionRange) {\n      return false\n    }\n    return Range.equals(intersectionRange, target)\n  },\n\n  includes(range: Range, target: Path | Point | Range): boolean {\n    if (Range.isRange(target)) {\n      if (\n        Range.includes(range, target.anchor) ||\n        Range.includes(range, target.focus)\n      ) {\n        return true\n      }\n\n      const [rs, re] = Range.edges(range)\n      const [ts, te] = Range.edges(target)\n      return Point.isBefore(rs, ts) && Point.isAfter(re, te)\n    }\n\n    const [start, end] = Range.edges(range)\n    let isAfterStart = false\n    let isBeforeEnd = false\n\n    if (Point.isPoint(target)) {\n      isAfterStart = Point.compare(target, start) >= 0\n      isBeforeEnd = Point.compare(target, end) <= 0\n    } else {\n      isAfterStart = Path.compare(target, start.path) >= 0\n      isBeforeEnd = Path.compare(target, end.path) <= 0\n    }\n\n    return isAfterStart && isBeforeEnd\n  },\n\n  intersection(range: Range, another: Range): Range | null {\n    const { anchor, focus, ...rest } = range\n    const [s1, e1] = Range.edges(range)\n    const [s2, e2] = Range.edges(another)\n    const start = Point.isBefore(s1, s2) ? s2 : s1\n    const end = Point.isBefore(e1, e2) ? e1 : e2\n\n    if (Point.isBefore(end, start)) {\n      return null\n    } else {\n      return { anchor: start, focus: end, ...rest }\n    }\n  },\n\n  isBackward(range: Range): boolean {\n    const { anchor, focus } = range\n    return Point.isAfter(anchor, focus)\n  },\n\n  isCollapsed(range: Range): boolean {\n    const { anchor, focus } = range\n    return Point.equals(anchor, focus)\n  },\n\n  isExpanded(range: Range): boolean {\n    return !Range.isCollapsed(range)\n  },\n\n  isForward(range: Range): boolean {\n    return !Range.isBackward(range)\n  },\n\n  isRange(value: any): value is Range {\n    return (\n      isPlainObject(value) &&\n      Point.isPoint(value.anchor) &&\n      Point.isPoint(value.focus)\n    )\n  },\n\n  *points(range: Range): Generator<PointEntry, void, undefined> {\n    yield [range.anchor, 'anchor']\n    yield [range.focus, 'focus']\n  },\n\n  start(range: Range): Point {\n    const [start] = Range.edges(range)\n    return start\n  },\n\n  transform(\n    range: Range | null,\n    op: Operation,\n    options: RangeTransformOptions = {}\n  ): Range | null {\n    return produce(range, r => {\n      if (r === null) {\n        return null\n      }\n      const { affinity = 'inward' } = options\n      let affinityAnchor: 'forward' | 'backward' | null\n      let affinityFocus: 'forward' | 'backward' | null\n\n      if (affinity === 'inward') {\n        // If the range is collapsed, make sure to use the same affinity to\n        // avoid the two points passing each other and expanding in the opposite\n        // direction\n        const isCollapsed = Range.isCollapsed(r)\n        if (Range.isForward(r)) {\n          affinityAnchor = 'forward'\n          affinityFocus = isCollapsed ? affinityAnchor : 'backward'\n        } else {\n          affinityAnchor = 'backward'\n          affinityFocus = isCollapsed ? affinityAnchor : 'forward'\n        }\n      } else if (affinity === 'outward') {\n        if (Range.isForward(r)) {\n          affinityAnchor = 'backward'\n          affinityFocus = 'forward'\n        } else {\n          affinityAnchor = 'forward'\n          affinityFocus = 'backward'\n        }\n      } else {\n        affinityAnchor = affinity\n        affinityFocus = affinity\n      }\n      const anchor = Point.transform(r.anchor, op, { affinity: affinityAnchor })\n      const focus = Point.transform(r.focus, op, { affinity: affinityFocus })\n\n      if (!anchor || !focus) {\n        return null\n      }\n\n      r.anchor = anchor\n      r.focus = focus\n    })\n  },\n}\n","import { isPlainObject } from 'is-plain-object'\nimport { Ancestor, Descendant, Editor, ExtendedType, Node, Path } from '..'\n\n/**\n * `Element` objects are a type of node in a Slate document that contain other\n * element nodes or text nodes. They can be either \"blocks\" or \"inlines\"\n * depending on the Slate editor's configuration.\n */\n\nexport interface BaseElement {\n  children: Descendant[]\n}\n\nexport type Element = ExtendedType<'Element', BaseElement>\n\nexport interface ElementInterface {\n  /**\n   * Check if a value implements the 'Ancestor' interface.\n   */\n  isAncestor: (value: any) => value is Ancestor\n\n  /**\n   * Check if a value implements the `Element` interface.\n   */\n  isElement: (value: any) => value is Element\n\n  /**\n   * Check if a value is an array of `Element` objects.\n   */\n  isElementList: (value: any) => value is Element[]\n\n  /**\n   * Check if a set of props is a partial of Element.\n   */\n  isElementProps: (props: any) => props is Partial<Element>\n\n  /**\n   * Check if a value implements the `Element` interface and has elementKey with selected value.\n   * Default it check to `type` key value\n   */\n  isElementType: <T extends Element>(\n    value: any,\n    elementVal: string,\n    elementKey?: string\n  ) => value is T\n\n  /**\n   * Check if an element matches set of properties.\n   *\n   * Note: this checks custom properties, and it does not ensure that any\n   * children are equivalent.\n   */\n  matches: (element: Element, props: Partial<Element>) => boolean\n}\n\n/**\n * Shared the function with isElementType utility\n */\nconst isElement = (value: any): value is Element => {\n  return (\n    isPlainObject(value) &&\n    Node.isNodeList(value.children) &&\n    !Editor.isEditor(value)\n  )\n}\n\n// eslint-disable-next-line no-redeclare\nexport const Element: ElementInterface = {\n  isAncestor(value: any): value is Ancestor {\n    return isPlainObject(value) && Node.isNodeList(value.children)\n  },\n\n  isElement,\n\n  isElementList(value: any): value is Element[] {\n    return Array.isArray(value) && value.every(val => Element.isElement(val))\n  },\n\n  isElementProps(props: any): props is Partial<Element> {\n    return (props as Partial<Element>).children !== undefined\n  },\n\n  isElementType: <T extends Element>(\n    value: any,\n    elementVal: string,\n    elementKey: string = 'type'\n  ): value is T => {\n    return (\n      isElement(value) && value[<keyof Descendant>elementKey] === elementVal\n    )\n  },\n\n  matches(element: Element, props: Partial<Element>): boolean {\n    for (const key in props) {\n      if (key === 'children') {\n        continue\n      }\n\n      if (element[<keyof Descendant>key] !== props[<keyof Descendant>key]) {\n        return false\n      }\n    }\n\n    return true\n  },\n}\n\n/**\n * `ElementEntry` objects refer to an `Element` and the `Path` where it can be\n * found inside a root node.\n */\nexport type ElementEntry = [Element, Path]\n","import { produce } from 'immer'\nimport { Editor, Path, Range, Scrubber, Text } from '..'\nimport { Element, ElementEntry } from './element'\n\n/**\n * The `Node` union type represents all of the different types of nodes that\n * occur in a Slate document tree.\n */\n\nexport type BaseNode = Editor | Element | Text\nexport type Node = Editor | Element | Text\n\nexport interface NodeAncestorsOptions {\n  reverse?: boolean\n}\n\nexport interface NodeChildrenOptions {\n  reverse?: boolean\n}\n\nexport interface NodeDescendantsOptions {\n  from?: Path\n  to?: Path\n  reverse?: boolean\n  pass?: (node: NodeEntry) => boolean\n}\n\nexport interface NodeElementsOptions {\n  from?: Path\n  to?: Path\n  reverse?: boolean\n  pass?: (node: NodeEntry) => boolean\n}\n\nexport interface NodeLevelsOptions {\n  reverse?: boolean\n}\n\nexport interface NodeNodesOptions {\n  from?: Path\n  to?: Path\n  reverse?: boolean\n  pass?: (entry: NodeEntry) => boolean\n}\n\nexport interface NodeTextsOptions {\n  from?: Path\n  to?: Path\n  reverse?: boolean\n  pass?: (node: NodeEntry) => boolean\n}\n\nexport interface NodeInterface {\n  /**\n   * Get the node at a specific path, asserting that it's an ancestor node.\n   */\n  ancestor: (root: Node, path: Path) => Ancestor\n\n  /**\n   * Return a generator of all the ancestor nodes above a specific path.\n   *\n   * By default the order is top-down, from highest to lowest ancestor in\n   * the tree, but you can pass the `reverse: true` option to go bottom-up.\n   */\n  ancestors: (\n    root: Node,\n    path: Path,\n    options?: NodeAncestorsOptions\n  ) => Generator<NodeEntry<Ancestor>, void, undefined>\n\n  /**\n   * Get the child of a node at a specific index.\n   */\n  child: (root: Node, index: number) => Descendant\n\n  /**\n   * Iterate over the children of a node at a specific path.\n   */\n  children: (\n    root: Node,\n    path: Path,\n    options?: NodeChildrenOptions\n  ) => Generator<NodeEntry<Descendant>, void, undefined>\n\n  /**\n   * Get an entry for the common ancesetor node of two paths.\n   */\n  common: (root: Node, path: Path, another: Path) => NodeEntry\n\n  /**\n   * Get the node at a specific path, asserting that it's a descendant node.\n   */\n  descendant: (root: Node, path: Path) => Descendant\n\n  /**\n   * Return a generator of all the descendant node entries inside a root node.\n   */\n  descendants: (\n    root: Node,\n    options?: NodeDescendantsOptions\n  ) => Generator<NodeEntry<Descendant>, void, undefined>\n\n  /**\n   * Return a generator of all the element nodes inside a root node. Each iteration\n   * will return an `ElementEntry` tuple consisting of `[Element, Path]`. If the\n   * root node is an element it will be included in the iteration as well.\n   */\n  elements: (\n    root: Node,\n    options?: NodeElementsOptions\n  ) => Generator<ElementEntry, void, undefined>\n\n  /**\n   * Extract props from a Node.\n   */\n  extractProps: (node: Node) => NodeProps\n\n  /**\n   * Get the first node entry in a root node from a path.\n   */\n  first: (root: Node, path: Path) => NodeEntry\n\n  /**\n   * Get the sliced fragment represented by a range inside a root node.\n   */\n  fragment: (root: Node, range: Range) => Descendant[]\n\n  /**\n   * Get the descendant node referred to by a specific path. If the path is an\n   * empty array, it refers to the root node itself.\n   */\n  get: (root: Node, path: Path) => Node\n\n  /**\n   * Similar to get, but returns undefined if the node does not exist.\n   */\n  getIf: (root: Node, path: Path) => Node | undefined\n\n  /**\n   * Check if a descendant node exists at a specific path.\n   */\n  has: (root: Node, path: Path) => boolean\n\n  /**\n   * Check if a value implements the `Node` interface.\n   */\n  isNode: (value: any) => value is Node\n\n  /**\n   * Check if a value is a list of `Node` objects.\n   */\n  isNodeList: (value: any) => value is Node[]\n\n  /**\n   * Get the last node entry in a root node from a path.\n   */\n  last: (root: Node, path: Path) => NodeEntry\n\n  /**\n   * Get the node at a specific path, ensuring it's a leaf text node.\n   */\n  leaf: (root: Node, path: Path) => Text\n\n  /**\n   * Return a generator of the in a branch of the tree, from a specific path.\n   *\n   * By default the order is top-down, from highest to lowest node in the tree,\n   * but you can pass the `reverse: true` option to go bottom-up.\n   */\n  levels: (\n    root: Node,\n    path: Path,\n    options?: NodeLevelsOptions\n  ) => Generator<NodeEntry, void, undefined>\n\n  /**\n   * Check if a node matches a set of props.\n   */\n  matches: (node: Node, props: Partial<Node>) => boolean\n\n  /**\n   * Return a generator of all the node entries of a root node. Each entry is\n   * returned as a `[Node, Path]` tuple, with the path referring to the node's\n   * position inside the root node.\n   */\n  nodes: (\n    root: Node,\n    options?: NodeNodesOptions\n  ) => Generator<NodeEntry, void, undefined>\n\n  /**\n   * Get the parent of a node at a specific path.\n   */\n  parent: (root: Node, path: Path) => Ancestor\n\n  /**\n   * Get the concatenated text string of a node's content.\n   *\n   * Note that this will not include spaces or line breaks between block nodes.\n   * It is not a user-facing string, but a string for performing offset-related\n   * computations for a node.\n   */\n  string: (node: Node) => string\n\n  /**\n   * Return a generator of all leaf text nodes in a root node.\n   */\n  texts: (\n    root: Node,\n    options?: NodeTextsOptions\n  ) => Generator<NodeEntry<Text>, void, undefined>\n}\n\nconst IS_NODE_LIST_CACHE = new WeakMap<any[], boolean>()\n\n// eslint-disable-next-line no-redeclare\nexport const Node: NodeInterface = {\n  ancestor(root: Node, path: Path): Ancestor {\n    const node = Node.get(root, path)\n\n    if (Text.isText(node)) {\n      throw new Error(\n        `Cannot get the ancestor node at path [${path}] because it refers to a text node instead: ${Scrubber.stringify(\n          node\n        )}`\n      )\n    }\n\n    return node\n  },\n\n  *ancestors(\n    root: Node,\n    path: Path,\n    options: NodeAncestorsOptions = {}\n  ): Generator<NodeEntry<Ancestor>, void, undefined> {\n    for (const p of Path.ancestors(path, options)) {\n      const n = Node.ancestor(root, p)\n      const entry: NodeEntry<Ancestor> = [n, p]\n      yield entry\n    }\n  },\n\n  child(root: Node, index: number): Descendant {\n    if (Text.isText(root)) {\n      throw new Error(\n        `Cannot get the child of a text node: ${Scrubber.stringify(root)}`\n      )\n    }\n\n    const c = root.children[index] as Descendant\n\n    if (c == null) {\n      throw new Error(\n        `Cannot get child at index \\`${index}\\` in node: ${Scrubber.stringify(\n          root\n        )}`\n      )\n    }\n\n    return c\n  },\n\n  *children(\n    root: Node,\n    path: Path,\n    options: NodeChildrenOptions = {}\n  ): Generator<NodeEntry<Descendant>, void, undefined> {\n    const { reverse = false } = options\n    const ancestor = Node.ancestor(root, path)\n    const { children } = ancestor\n    let index = reverse ? children.length - 1 : 0\n\n    while (reverse ? index >= 0 : index < children.length) {\n      const child = Node.child(ancestor, index)\n      const childPath = path.concat(index)\n      yield [child, childPath]\n      index = reverse ? index - 1 : index + 1\n    }\n  },\n\n  common(root: Node, path: Path, another: Path): NodeEntry {\n    const p = Path.common(path, another)\n    const n = Node.get(root, p)\n    return [n, p]\n  },\n\n  descendant(root: Node, path: Path): Descendant {\n    const node = Node.get(root, path)\n\n    if (Editor.isEditor(node)) {\n      throw new Error(\n        `Cannot get the descendant node at path [${path}] because it refers to the root editor node instead: ${Scrubber.stringify(\n          node\n        )}`\n      )\n    }\n\n    return node\n  },\n\n  *descendants(\n    root: Node,\n    options: NodeDescendantsOptions = {}\n  ): Generator<NodeEntry<Descendant>, void, undefined> {\n    for (const [node, path] of Node.nodes(root, options)) {\n      if (path.length !== 0) {\n        // NOTE: we have to coerce here because checking the path's length does\n        // guarantee that `node` is not a `Editor`, but TypeScript doesn't know.\n        yield [node, path] as NodeEntry<Descendant>\n      }\n    }\n  },\n\n  *elements(\n    root: Node,\n    options: NodeElementsOptions = {}\n  ): Generator<ElementEntry, void, undefined> {\n    for (const [node, path] of Node.nodes(root, options)) {\n      if (Element.isElement(node)) {\n        yield [node, path]\n      }\n    }\n  },\n\n  extractProps(node: Node): NodeProps {\n    if (Element.isAncestor(node)) {\n      const { children, ...properties } = node\n\n      return properties\n    } else {\n      const { text, ...properties } = node\n\n      return properties\n    }\n  },\n\n  first(root: Node, path: Path): NodeEntry {\n    const p = path.slice()\n    let n = Node.get(root, p)\n\n    while (n) {\n      if (Text.isText(n) || n.children.length === 0) {\n        break\n      } else {\n        n = n.children[0]\n        p.push(0)\n      }\n    }\n\n    return [n, p]\n  },\n\n  fragment(root: Node, range: Range): Descendant[] {\n    if (Text.isText(root)) {\n      throw new Error(\n        `Cannot get a fragment starting from a root text node: ${Scrubber.stringify(\n          root\n        )}`\n      )\n    }\n\n    const newRoot = produce({ children: root.children }, r => {\n      const [start, end] = Range.edges(range)\n      const nodeEntries = Node.nodes(r, {\n        reverse: true,\n        pass: ([, path]) => !Range.includes(range, path),\n      })\n\n      for (const [, path] of nodeEntries) {\n        if (!Range.includes(range, path)) {\n          const parent = Node.parent(r, path)\n          const index = path[path.length - 1]\n          parent.children.splice(index, 1)\n        }\n\n        if (Path.equals(path, end.path)) {\n          const leaf = Node.leaf(r, path)\n          leaf.text = leaf.text.slice(0, end.offset)\n        }\n\n        if (Path.equals(path, start.path)) {\n          const leaf = Node.leaf(r, path)\n          leaf.text = leaf.text.slice(start.offset)\n        }\n      }\n\n      if (Editor.isEditor(r)) {\n        r.selection = null\n      }\n    })\n\n    return newRoot.children\n  },\n\n  get(root: Node, path: Path): Node {\n    const node = Node.getIf(root, path)\n    if (node === undefined) {\n      throw new Error(\n        `Cannot find a descendant at path [${path}] in node: ${Scrubber.stringify(\n          root\n        )}`\n      )\n    }\n    return node\n  },\n\n  getIf(root: Node, path: Path): Node | undefined {\n    let node = root\n\n    for (let i = 0; i < path.length; i++) {\n      const p = path[i]\n\n      if (Text.isText(node) || !node.children[p]) {\n        return\n      }\n\n      node = node.children[p]\n    }\n\n    return node\n  },\n\n  has(root: Node, path: Path): boolean {\n    let node = root\n\n    for (let i = 0; i < path.length; i++) {\n      const p = path[i]\n\n      if (Text.isText(node) || !node.children[p]) {\n        return false\n      }\n\n      node = node.children[p]\n    }\n\n    return true\n  },\n\n  isNode(value: any): value is Node {\n    return (\n      Text.isText(value) || Element.isElement(value) || Editor.isEditor(value)\n    )\n  },\n\n  isNodeList(value: any): value is Node[] {\n    if (!Array.isArray(value)) {\n      return false\n    }\n    const cachedResult = IS_NODE_LIST_CACHE.get(value)\n    if (cachedResult !== undefined) {\n      return cachedResult\n    }\n    const isNodeList = value.every(val => Node.isNode(val))\n    IS_NODE_LIST_CACHE.set(value, isNodeList)\n    return isNodeList\n  },\n\n  last(root: Node, path: Path): NodeEntry {\n    const p = path.slice()\n    let n = Node.get(root, p)\n\n    while (n) {\n      if (Text.isText(n) || n.children.length === 0) {\n        break\n      } else {\n        const i = n.children.length - 1\n        n = n.children[i]\n        p.push(i)\n      }\n    }\n\n    return [n, p]\n  },\n\n  leaf(root: Node, path: Path): Text {\n    const node = Node.get(root, path)\n\n    if (!Text.isText(node)) {\n      throw new Error(\n        `Cannot get the leaf node at path [${path}] because it refers to a non-leaf node: ${Scrubber.stringify(\n          node\n        )}`\n      )\n    }\n\n    return node\n  },\n\n  *levels(\n    root: Node,\n    path: Path,\n    options: NodeLevelsOptions = {}\n  ): Generator<NodeEntry, void, undefined> {\n    for (const p of Path.levels(path, options)) {\n      const n = Node.get(root, p)\n      yield [n, p]\n    }\n  },\n\n  matches(node: Node, props: Partial<Node>): boolean {\n    return (\n      (Element.isElement(node) &&\n        Element.isElementProps(props) &&\n        Element.matches(node, props)) ||\n      (Text.isText(node) &&\n        Text.isTextProps(props) &&\n        Text.matches(node, props))\n    )\n  },\n\n  *nodes(\n    root: Node,\n    options: NodeNodesOptions = {}\n  ): Generator<NodeEntry, void, undefined> {\n    const { pass, reverse = false } = options\n    const { from = [], to } = options\n    const visited = new Set()\n    let p: Path = []\n    let n = root\n\n    while (true) {\n      if (to && (reverse ? Path.isBefore(p, to) : Path.isAfter(p, to))) {\n        break\n      }\n\n      if (!visited.has(n)) {\n        yield [n, p]\n      }\n\n      // If we're allowed to go downward and we haven't descended yet, do.\n      if (\n        !visited.has(n) &&\n        !Text.isText(n) &&\n        n.children.length !== 0 &&\n        (pass == null || pass([n, p]) === false)\n      ) {\n        visited.add(n)\n        let nextIndex = reverse ? n.children.length - 1 : 0\n\n        if (Path.isAncestor(p, from)) {\n          nextIndex = from[p.length]\n        }\n\n        p = p.concat(nextIndex)\n        n = Node.get(root, p)\n        continue\n      }\n\n      // If we're at the root and we can't go down, we're done.\n      if (p.length === 0) {\n        break\n      }\n\n      // If we're going forward...\n      if (!reverse) {\n        const newPath = Path.next(p)\n\n        if (Node.has(root, newPath)) {\n          p = newPath\n          n = Node.get(root, p)\n          continue\n        }\n      }\n\n      // If we're going backward...\n      if (reverse && p[p.length - 1] !== 0) {\n        const newPath = Path.previous(p)\n        p = newPath\n        n = Node.get(root, p)\n        continue\n      }\n\n      // Otherwise we're going upward...\n      p = Path.parent(p)\n      n = Node.get(root, p)\n      visited.add(n)\n    }\n  },\n\n  parent(root: Node, path: Path): Ancestor {\n    const parentPath = Path.parent(path)\n    const p = Node.get(root, parentPath)\n\n    if (Text.isText(p)) {\n      throw new Error(\n        `Cannot get the parent of path [${path}] because it does not exist in the root.`\n      )\n    }\n\n    return p\n  },\n\n  string(node: Node): string {\n    if (Text.isText(node)) {\n      return node.text\n    } else {\n      return node.children.map(Node.string).join('')\n    }\n  },\n\n  *texts(\n    root: Node,\n    options: NodeTextsOptions = {}\n  ): Generator<NodeEntry<Text>, void, undefined> {\n    for (const [node, path] of Node.nodes(root, options)) {\n      if (Text.isText(node)) {\n        yield [node, path]\n      }\n    }\n  },\n}\n\n/**\n * The `Descendant` union type represents nodes that are descendants in the\n * tree. It is returned as a convenience in certain cases to narrow a value\n * further than the more generic `Node` union.\n */\n\nexport type Descendant = Element | Text\n\n/**\n * The `Ancestor` union type represents nodes that are ancestors in the tree.\n * It is returned as a convenience in certain cases to narrow a value further\n * than the more generic `Node` union.\n */\n\nexport type Ancestor = Editor | Element\n\n/**\n * `NodeEntry` objects are returned when iterating over the nodes in a Slate\n * document tree. They consist of the node and its `Path` relative to the root\n * node in the document.\n */\n\nexport type NodeEntry<T extends Node = Node> = [T, Path]\n\n/**\n * Convenience type for returning the props of a node.\n */\nexport type NodeProps =\n  | Omit<Editor, 'children'>\n  | Omit<Element, 'children'>\n  | Omit<Text, 'text'>\n","import { ExtendedType, Node, Path, Range } from '..'\nimport { isPlainObject } from 'is-plain-object'\n\nexport type BaseInsertNodeOperation = {\n  type: 'insert_node'\n  path: Path\n  node: Node\n}\n\nexport type InsertNodeOperation = ExtendedType<\n  'InsertNodeOperation',\n  BaseInsertNodeOperation\n>\n\nexport type BaseInsertTextOperation = {\n  type: 'insert_text'\n  path: Path\n  offset: number\n  text: string\n}\n\nexport type InsertTextOperation = ExtendedType<\n  'InsertTextOperation',\n  BaseInsertTextOperation\n>\n\nexport type BaseMergeNodeOperation = {\n  type: 'merge_node'\n  path: Path\n  position: number\n  properties: Partial<Node>\n}\n\nexport type MergeNodeOperation = ExtendedType<\n  'MergeNodeOperation',\n  BaseMergeNodeOperation\n>\n\nexport type BaseMoveNodeOperation = {\n  type: 'move_node'\n  path: Path\n  newPath: Path\n}\n\nexport type MoveNodeOperation = ExtendedType<\n  'MoveNodeOperation',\n  BaseMoveNodeOperation\n>\n\nexport type BaseRemoveNodeOperation = {\n  type: 'remove_node'\n  path: Path\n  node: Node\n}\n\nexport type RemoveNodeOperation = ExtendedType<\n  'RemoveNodeOperation',\n  BaseRemoveNodeOperation\n>\n\nexport type BaseRemoveTextOperation = {\n  type: 'remove_text'\n  path: Path\n  offset: number\n  text: string\n}\n\nexport type RemoveTextOperation = ExtendedType<\n  'RemoveTextOperation',\n  BaseRemoveTextOperation\n>\n\nexport type BaseSetNodeOperation = {\n  type: 'set_node'\n  path: Path\n  properties: Partial<Node>\n  newProperties: Partial<Node>\n}\n\nexport type SetNodeOperation = ExtendedType<\n  'SetNodeOperation',\n  BaseSetNodeOperation\n>\n\nexport type BaseSetSelectionOperation =\n  | {\n      type: 'set_selection'\n      properties: null\n      newProperties: Range\n    }\n  | {\n      type: 'set_selection'\n      properties: Partial<Range>\n      newProperties: Partial<Range>\n    }\n  | {\n      type: 'set_selection'\n      properties: Range\n      newProperties: null\n    }\n\nexport type SetSelectionOperation = ExtendedType<\n  'SetSelectionOperation',\n  BaseSetSelectionOperation\n>\n\nexport type BaseSplitNodeOperation = {\n  type: 'split_node'\n  path: Path\n  position: number\n  properties: Partial<Node>\n}\n\nexport type SplitNodeOperation = ExtendedType<\n  'SplitNodeOperation',\n  BaseSplitNodeOperation\n>\n\nexport type NodeOperation =\n  | InsertNodeOperation\n  | MergeNodeOperation\n  | MoveNodeOperation\n  | RemoveNodeOperation\n  | SetNodeOperation\n  | SplitNodeOperation\n\nexport type SelectionOperation = SetSelectionOperation\n\nexport type TextOperation = InsertTextOperation | RemoveTextOperation\n\n/**\n * `Operation` objects define the low-level instructions that Slate editors use\n * to apply changes to their internal state. Representing all changes as\n * operations is what allows Slate editors to easily implement history,\n * collaboration, and other features.\n */\n\nexport type BaseOperation = NodeOperation | SelectionOperation | TextOperation\nexport type Operation = ExtendedType<'Operation', BaseOperation>\n\nexport interface OperationInterface {\n  /**\n   * Check if a value is a `NodeOperation` object.\n   */\n  isNodeOperation: (value: any) => value is NodeOperation\n\n  /**\n   * Check if a value is an `Operation` object.\n   */\n  isOperation: (value: any) => value is Operation\n\n  /**\n   * Check if a value is a list of `Operation` objects.\n   */\n  isOperationList: (value: any) => value is Operation[]\n\n  /**\n   * Check if a value is a `SelectionOperation` object.\n   */\n  isSelectionOperation: (value: any) => value is SelectionOperation\n\n  /**\n   * Check if a value is a `TextOperation` object.\n   */\n  isTextOperation: (value: any) => value is TextOperation\n\n  /**\n   * Invert an operation, returning a new operation that will exactly undo the\n   * original when applied.\n   */\n  inverse: (op: Operation) => Operation\n}\n\n// eslint-disable-next-line no-redeclare\nexport const Operation: OperationInterface = {\n  isNodeOperation(value: any): value is NodeOperation {\n    return Operation.isOperation(value) && value.type.endsWith('_node')\n  },\n\n  isOperation(value: any): value is Operation {\n    if (!isPlainObject(value)) {\n      return false\n    }\n\n    switch (value.type) {\n      case 'insert_node':\n        return Path.isPath(value.path) && Node.isNode(value.node)\n      case 'insert_text':\n        return (\n          typeof value.offset === 'number' &&\n          typeof value.text === 'string' &&\n          Path.isPath(value.path)\n        )\n      case 'merge_node':\n        return (\n          typeof value.position === 'number' &&\n          Path.isPath(value.path) &&\n          isPlainObject(value.properties)\n        )\n      case 'move_node':\n        return Path.isPath(value.path) && Path.isPath(value.newPath)\n      case 'remove_node':\n        return Path.isPath(value.path) && Node.isNode(value.node)\n      case 'remove_text':\n        return (\n          typeof value.offset === 'number' &&\n          typeof value.text === 'string' &&\n          Path.isPath(value.path)\n        )\n      case 'set_node':\n        return (\n          Path.isPath(value.path) &&\n          isPlainObject(value.properties) &&\n          isPlainObject(value.newProperties)\n        )\n      case 'set_selection':\n        return (\n          (value.properties === null && Range.isRange(value.newProperties)) ||\n          (value.newProperties === null && Range.isRange(value.properties)) ||\n          (isPlainObject(value.properties) &&\n            isPlainObject(value.newProperties))\n        )\n      case 'split_node':\n        return (\n          Path.isPath(value.path) &&\n          typeof value.position === 'number' &&\n          isPlainObject(value.properties)\n        )\n      default:\n        return false\n    }\n  },\n\n  isOperationList(value: any): value is Operation[] {\n    return (\n      Array.isArray(value) && value.every(val => Operation.isOperation(val))\n    )\n  },\n\n  isSelectionOperation(value: any): value is SelectionOperation {\n    return Operation.isOperation(value) && value.type.endsWith('_selection')\n  },\n\n  isTextOperation(value: any): value is TextOperation {\n    return Operation.isOperation(value) && value.type.endsWith('_text')\n  },\n\n  inverse(op: Operation): Operation {\n    switch (op.type) {\n      case 'insert_node': {\n        return { ...op, type: 'remove_node' }\n      }\n\n      case 'insert_text': {\n        return { ...op, type: 'remove_text' }\n      }\n\n      case 'merge_node': {\n        return { ...op, type: 'split_node', path: Path.previous(op.path) }\n      }\n\n      case 'move_node': {\n        const { newPath, path } = op\n\n        // PERF: in this case the move operation is a no-op anyways.\n        if (Path.equals(newPath, path)) {\n          return op\n        }\n\n        // If the move happens completely within a single parent the path and\n        // newPath are stable with respect to each other.\n        if (Path.isSibling(path, newPath)) {\n          return { ...op, path: newPath, newPath: path }\n        }\n\n        // If the move does not happen within a single parent it is possible\n        // for the move to impact the true path to the location where the node\n        // was removed from and where it was inserted. We have to adjust for this\n        // and find the original path. We can accomplish this (only in non-sibling)\n        // moves by looking at the impact of the move operation on the node\n        // after the original move path.\n        const inversePath = Path.transform(path, op)!\n        const inverseNewPath = Path.transform(Path.next(path), op)!\n        return { ...op, path: inversePath, newPath: inverseNewPath }\n      }\n\n      case 'remove_node': {\n        return { ...op, type: 'insert_node' }\n      }\n\n      case 'remove_text': {\n        return { ...op, type: 'insert_text' }\n      }\n\n      case 'set_node': {\n        const { properties, newProperties } = op\n        return { ...op, properties: newProperties, newProperties: properties }\n      }\n\n      case 'set_selection': {\n        const { properties, newProperties } = op\n\n        if (properties == null) {\n          return {\n            ...op,\n            properties: newProperties as Range,\n            newProperties: null,\n          }\n        } else if (newProperties == null) {\n          return {\n            ...op,\n            properties: null,\n            newProperties: properties as Range,\n          }\n        } else {\n          return { ...op, properties: newProperties, newProperties: properties }\n        }\n      }\n\n      case 'split_node': {\n        return { ...op, type: 'merge_node', path: Path.next(op.path) }\n      }\n    }\n  },\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { isPlainObject } from 'is-plain-object'\nimport { Range } from '../interfaces/range'\nimport { Node } from '../interfaces/node'\nimport { Operation } from '../interfaces/operation'\n\nconst IS_EDITOR_CACHE = new WeakMap<object, boolean>()\n\nexport const isEditor: EditorInterface['isEditor'] = (\n  value: any\n): value is Editor => {\n  const cachedIsEditor = IS_EDITOR_CACHE.get(value)\n  if (cachedIsEditor !== undefined) {\n    return cachedIsEditor\n  }\n\n  if (!isPlainObject(value)) {\n    return false\n  }\n\n  const isEditor =\n    typeof value.addMark === 'function' &&\n    typeof value.apply === 'function' &&\n    typeof value.deleteFragment === 'function' &&\n    typeof value.insertBreak === 'function' &&\n    typeof value.insertSoftBreak === 'function' &&\n    typeof value.insertFragment === 'function' &&\n    typeof value.insertNode === 'function' &&\n    typeof value.insertText === 'function' &&\n    typeof value.isElementReadOnly === 'function' &&\n    typeof value.isInline === 'function' &&\n    typeof value.isSelectable === 'function' &&\n    typeof value.isVoid === 'function' &&\n    typeof value.normalizeNode === 'function' &&\n    typeof value.onChange === 'function' &&\n    typeof value.removeMark === 'function' &&\n    typeof value.getDirtyPaths === 'function' &&\n    (value.marks === null || isPlainObject(value.marks)) &&\n    (value.selection === null || Range.isRange(value.selection)) &&\n    Node.isNodeList(value.children) &&\n    Operation.isOperationList(value.operations)\n  IS_EDITOR_CACHE.set(value, isEditor)\n  return isEditor\n}\n","import {\n  Ancestor,\n  Descendant,\n  Element,\n  ExtendedType,\n  Location,\n  Node,\n  NodeEntry,\n  Operation,\n  Path,\n  PathRef,\n  Point,\n  PointRef,\n  Range,\n  RangeRef,\n  Span,\n  Text,\n  Transforms,\n} from '..'\nimport {\n  LeafEdge,\n  MaximizeMode,\n  RangeDirection,\n  SelectionMode,\n  TextDirection,\n  TextUnit,\n  TextUnitAdjustment,\n} from '../types/types'\nimport { OmitFirstArg } from '../utils/types'\nimport { isEditor } from '../editor/is-editor'\nimport {\n  TextInsertFragmentOptions,\n  TextInsertTextOptions,\n} from './transforms/text'\nimport { NodeInsertNodesOptions } from './transforms/node'\n\n/**\n * The `Editor` interface stores all the state of a Slate editor. It is extended\n * by plugins that wish to add their own helpers and implement new behaviors.\n */\nexport interface BaseEditor {\n  // Core state.\n\n  children: Descendant[]\n  selection: Selection\n  operations: Operation[]\n  marks: EditorMarks | null\n\n  // Overrideable core methods.\n\n  apply: (operation: Operation) => void\n  getDirtyPaths: (operation: Operation) => Path[]\n  getFragment: () => Descendant[]\n  isElementReadOnly: (element: Element) => boolean\n  isSelectable: (element: Element) => boolean\n  markableVoid: (element: Element) => boolean\n  normalizeNode: (entry: NodeEntry, options?: { operation?: Operation }) => void\n  onChange: (options?: { operation?: Operation }) => void\n  shouldNormalize: ({\n    iteration,\n    dirtyPaths,\n    operation,\n  }: {\n    iteration: number\n    initialDirtyPathsLength: number\n    dirtyPaths: Path[]\n    operation?: Operation\n  }) => boolean\n\n  // Overrideable core transforms.\n\n  addMark: OmitFirstArg<typeof Editor.addMark>\n  collapse: OmitFirstArg<typeof Transforms.collapse>\n  delete: OmitFirstArg<typeof Transforms.delete>\n  deleteBackward: (unit: TextUnit) => void\n  deleteForward: (unit: TextUnit) => void\n  deleteFragment: OmitFirstArg<typeof Editor.deleteFragment>\n  deselect: OmitFirstArg<typeof Transforms.deselect>\n  insertBreak: OmitFirstArg<typeof Editor.insertBreak>\n  insertFragment: OmitFirstArg<typeof Transforms.insertFragment>\n  insertNode: OmitFirstArg<typeof Editor.insertNode>\n  insertNodes: OmitFirstArg<typeof Transforms.insertNodes>\n  insertSoftBreak: OmitFirstArg<typeof Editor.insertSoftBreak>\n  insertText: OmitFirstArg<typeof Transforms.insertText>\n  liftNodes: OmitFirstArg<typeof Transforms.liftNodes>\n  mergeNodes: OmitFirstArg<typeof Transforms.mergeNodes>\n  move: OmitFirstArg<typeof Transforms.move>\n  moveNodes: OmitFirstArg<typeof Transforms.moveNodes>\n  normalize: OmitFirstArg<typeof Editor.normalize>\n  removeMark: OmitFirstArg<typeof Editor.removeMark>\n  removeNodes: OmitFirstArg<typeof Transforms.removeNodes>\n  select: OmitFirstArg<typeof Transforms.select>\n  setNodes: <T extends Node>(\n    props: Partial<T>,\n    options?: {\n      at?: Location\n      match?: NodeMatch<T>\n      mode?: MaximizeMode\n      hanging?: boolean\n      split?: boolean\n      voids?: boolean\n      compare?: PropsCompare\n      merge?: PropsMerge\n    }\n  ) => void\n  setNormalizing: OmitFirstArg<typeof Editor.setNormalizing>\n  setPoint: OmitFirstArg<typeof Transforms.setPoint>\n  setSelection: OmitFirstArg<typeof Transforms.setSelection>\n  splitNodes: OmitFirstArg<typeof Transforms.splitNodes>\n  unsetNodes: OmitFirstArg<typeof Transforms.unsetNodes>\n  unwrapNodes: OmitFirstArg<typeof Transforms.unwrapNodes>\n  withoutNormalizing: OmitFirstArg<typeof Editor.withoutNormalizing>\n  wrapNodes: OmitFirstArg<typeof Transforms.wrapNodes>\n\n  // Overrideable core queries.\n\n  above: <T extends Ancestor>(\n    options?: EditorAboveOptions<T>\n  ) => NodeEntry<T> | undefined\n  after: OmitFirstArg<typeof Editor.after>\n  before: OmitFirstArg<typeof Editor.before>\n  edges: OmitFirstArg<typeof Editor.edges>\n  elementReadOnly: OmitFirstArg<typeof Editor.elementReadOnly>\n  end: OmitFirstArg<typeof Editor.end>\n  first: OmitFirstArg<typeof Editor.first>\n  fragment: OmitFirstArg<typeof Editor.fragment>\n  getMarks: OmitFirstArg<typeof Editor.marks>\n  hasBlocks: OmitFirstArg<typeof Editor.hasBlocks>\n  hasInlines: OmitFirstArg<typeof Editor.hasInlines>\n  hasPath: OmitFirstArg<typeof Editor.hasPath>\n  hasTexts: OmitFirstArg<typeof Editor.hasTexts>\n  isBlock: OmitFirstArg<typeof Editor.isBlock>\n  isEdge: OmitFirstArg<typeof Editor.isEdge>\n  isEmpty: OmitFirstArg<typeof Editor.isEmpty>\n  isEnd: OmitFirstArg<typeof Editor.isEnd>\n  isInline: OmitFirstArg<typeof Editor.isInline>\n  isNormalizing: OmitFirstArg<typeof Editor.isNormalizing>\n  isStart: OmitFirstArg<typeof Editor.isStart>\n  isVoid: OmitFirstArg<typeof Editor.isVoid>\n  last: OmitFirstArg<typeof Editor.last>\n  leaf: OmitFirstArg<typeof Editor.leaf>\n  levels: <T extends Node>(\n    options?: EditorLevelsOptions<T>\n  ) => Generator<NodeEntry<T>, void, undefined>\n  next: <T extends Descendant>(\n    options?: EditorNextOptions<T>\n  ) => NodeEntry<T> | undefined\n  node: OmitFirstArg<typeof Editor.node>\n  nodes: <T extends Node>(\n    options?: EditorNodesOptions<T>\n  ) => Generator<NodeEntry<T>, void, undefined>\n  parent: OmitFirstArg<typeof Editor.parent>\n  path: OmitFirstArg<typeof Editor.path>\n  pathRef: OmitFirstArg<typeof Editor.pathRef>\n  pathRefs: OmitFirstArg<typeof Editor.pathRefs>\n  point: OmitFirstArg<typeof Editor.point>\n  pointRef: OmitFirstArg<typeof Editor.pointRef>\n  pointRefs: OmitFirstArg<typeof Editor.pointRefs>\n  positions: OmitFirstArg<typeof Editor.positions>\n  previous: <T extends Node>(\n    options?: EditorPreviousOptions<T>\n  ) => NodeEntry<T> | undefined\n  range: OmitFirstArg<typeof Editor.range>\n  rangeRef: OmitFirstArg<typeof Editor.rangeRef>\n  rangeRefs: OmitFirstArg<typeof Editor.rangeRefs>\n  start: OmitFirstArg<typeof Editor.start>\n  string: OmitFirstArg<typeof Editor.string>\n  unhangRange: OmitFirstArg<typeof Editor.unhangRange>\n  void: OmitFirstArg<typeof Editor.void>\n  shouldMergeNodesRemovePrevNode: OmitFirstArg<\n    typeof Editor.shouldMergeNodesRemovePrevNode\n  >\n}\n\nexport type Editor = ExtendedType<'Editor', BaseEditor>\n\nexport type BaseSelection = Range | null\n\nexport type Selection = ExtendedType<'Selection', BaseSelection>\n\nexport type EditorMarks = Omit<Text, 'text'>\n\nexport interface EditorAboveOptions<T extends Ancestor> {\n  at?: Location\n  match?: NodeMatch<T>\n  mode?: MaximizeMode\n  voids?: boolean\n}\n\nexport interface EditorAfterOptions {\n  distance?: number\n  unit?: TextUnitAdjustment\n  voids?: boolean\n}\n\nexport interface EditorBeforeOptions {\n  distance?: number\n  unit?: TextUnitAdjustment\n  voids?: boolean\n}\n\nexport interface EditorDirectedDeletionOptions {\n  unit?: TextUnit\n}\n\nexport interface EditorElementReadOnlyOptions {\n  at?: Location\n  mode?: MaximizeMode\n  voids?: boolean\n}\n\nexport interface EditorFragmentDeletionOptions {\n  direction?: TextDirection\n}\n\nexport interface EditorLeafOptions {\n  depth?: number\n  edge?: LeafEdge\n}\n\nexport interface EditorLevelsOptions<T extends Node> {\n  at?: Location\n  match?: NodeMatch<T>\n  reverse?: boolean\n  voids?: boolean\n}\n\nexport interface EditorNextOptions<T extends Descendant> {\n  at?: Location\n  match?: NodeMatch<T>\n  mode?: SelectionMode\n  voids?: boolean\n}\n\nexport interface EditorNodeOptions {\n  depth?: number\n  edge?: LeafEdge\n}\n\nexport interface EditorNodesOptions<T extends Node> {\n  at?: Location | Span\n  match?: NodeMatch<T>\n  mode?: SelectionMode\n  universal?: boolean\n  reverse?: boolean\n  voids?: boolean\n  pass?: (entry: NodeEntry) => boolean\n  ignoreNonSelectable?: boolean\n}\n\nexport interface EditorNormalizeOptions {\n  force?: boolean\n  operation?: Operation\n}\n\nexport interface EditorParentOptions {\n  depth?: number\n  edge?: LeafEdge\n}\n\nexport interface EditorPathOptions {\n  depth?: number\n  edge?: LeafEdge\n}\n\nexport interface EditorPathRefOptions {\n  affinity?: TextDirection | null\n}\n\nexport interface EditorPointOptions {\n  edge?: LeafEdge\n}\n\nexport interface EditorPointRefOptions {\n  affinity?: TextDirection | null\n}\n\nexport interface EditorPositionsOptions {\n  at?: Location\n  unit?: TextUnitAdjustment\n  reverse?: boolean\n  voids?: boolean\n  ignoreNonSelectable?: boolean\n}\n\nexport interface EditorPreviousOptions<T extends Node> {\n  at?: Location\n  match?: NodeMatch<T>\n  mode?: SelectionMode\n  voids?: boolean\n}\n\nexport interface EditorRangeRefOptions {\n  affinity?: RangeDirection | null\n}\n\nexport interface EditorStringOptions {\n  voids?: boolean\n}\n\nexport interface EditorUnhangRangeOptions {\n  voids?: boolean\n}\n\nexport interface EditorVoidOptions {\n  at?: Location\n  mode?: MaximizeMode\n  voids?: boolean\n}\n\nexport interface EditorInterface {\n  /**\n   * Get the ancestor above a location in the document.\n   */\n  above: <T extends Ancestor>(\n    editor: Editor,\n    options?: EditorAboveOptions<T>\n  ) => NodeEntry<T> | undefined\n\n  /**\n   * Add a custom property to the leaf text nodes in the current selection.\n   *\n   * If the selection is currently collapsed, the marks will be added to the\n   * `editor.marks` property instead, and applied when text is inserted next.\n   */\n  addMark: (editor: Editor, key: string, value: any) => void\n\n  /**\n   * Get the point after a location.\n   */\n  after: (\n    editor: Editor,\n    at: Location,\n    options?: EditorAfterOptions\n  ) => Point | undefined\n\n  /**\n   * Get the point before a location.\n   */\n  before: (\n    editor: Editor,\n    at: Location,\n    options?: EditorBeforeOptions\n  ) => Point | undefined\n\n  /**\n   * Delete content in the editor backward from the current selection.\n   */\n  deleteBackward: (\n    editor: Editor,\n    options?: EditorDirectedDeletionOptions\n  ) => void\n\n  /**\n   * Delete content in the editor forward from the current selection.\n   */\n  deleteForward: (\n    editor: Editor,\n    options?: EditorDirectedDeletionOptions\n  ) => void\n\n  /**\n   * Delete the content in the current selection.\n   */\n  deleteFragment: (\n    editor: Editor,\n    options?: EditorFragmentDeletionOptions\n  ) => void\n\n  /**\n   * Get the start and end points of a location.\n   */\n  edges: (editor: Editor, at: Location) => [Point, Point]\n\n  /**\n   * Match a read-only element in the current branch of the editor.\n   */\n  elementReadOnly: (\n    editor: Editor,\n    options?: EditorElementReadOnlyOptions\n  ) => NodeEntry<Element> | undefined\n\n  /**\n   * Get the end point of a location.\n   */\n  end: (editor: Editor, at: Location) => Point\n\n  /**\n   * Get the first node at a location.\n   */\n  first: (editor: Editor, at: Location) => NodeEntry\n\n  /**\n   * Get the fragment at a location.\n   */\n  fragment: (editor: Editor, at: Location) => Descendant[]\n\n  /**\n   * Check if a node has block children.\n   */\n  hasBlocks: (editor: Editor, element: Element) => boolean\n\n  /**\n   * Check if a node has inline and text children.\n   */\n  hasInlines: (editor: Editor, element: Element) => boolean\n\n  hasPath: (editor: Editor, path: Path) => boolean\n\n  /**\n   * Check if a node has text children.\n   */\n  hasTexts: (editor: Editor, element: Element) => boolean\n\n  /**\n   * Insert a block break at the current selection.\n   *\n   * If the selection is currently expanded, it will be deleted first.\n   */\n  insertBreak: (editor: Editor) => void\n\n  /**\n   * Inserts a fragment\n   * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.\n   */\n  insertFragment: (\n    editor: Editor,\n    fragment: Node[],\n    options?: TextInsertFragmentOptions\n  ) => void\n\n  /**\n   * Atomically inserts `nodes`\n   * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.\n   */\n  insertNode: <T extends Node>(\n    editor: Editor,\n    node: Node,\n    options?: NodeInsertNodesOptions<T>\n  ) => void\n\n  /**\n   * Insert a soft break at the current selection.\n   *\n   * If the selection is currently expanded, it will be deleted first.\n   */\n  insertSoftBreak: (editor: Editor) => void\n\n  /**\n   * Insert a string of text\n   * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.\n   */\n  insertText: (\n    editor: Editor,\n    text: string,\n    options?: TextInsertTextOptions\n  ) => void\n\n  /**\n   * Check if a value is a block `Element` object.\n   */\n  isBlock: (editor: Editor, value: Element) => boolean\n\n  /**\n   * Check if a point is an edge of a location.\n   */\n  isEdge: (editor: Editor, point: Point, at: Location) => boolean\n\n  /**\n   * Check if a value is an `Editor` object.\n   */\n  isEditor: (value: any) => value is Editor\n\n  /**\n   * Check if a value is a read-only `Element` object.\n   */\n  isElementReadOnly: (editor: Editor, element: Element) => boolean\n\n  /**\n   * Check if an element is empty, accounting for void nodes.\n   */\n  isEmpty: (editor: Editor, element: Element) => boolean\n\n  /**\n   * Check if a point is the end point of a location.\n   */\n  isEnd: (editor: Editor, point: Point, at: Location) => boolean\n\n  /**\n   * Check if a value is an inline `Element` object.\n   */\n  isInline: (editor: Editor, value: Element) => boolean\n\n  /**\n   * Check if the editor is currently normalizing after each operation.\n   */\n  isNormalizing: (editor: Editor) => boolean\n\n  /**\n   * Check if a value is a selectable `Element` object.\n   */\n  isSelectable: (editor: Editor, element: Element) => boolean\n\n  /**\n   * Check if a point is the start point of a location.\n   */\n  isStart: (editor: Editor, point: Point, at: Location) => boolean\n\n  /**\n   * Check if a value is a void `Element` object.\n   */\n  isVoid: (editor: Editor, value: Element) => boolean\n\n  /**\n   * Get the last node at a location.\n   */\n  last: (editor: Editor, at: Location) => NodeEntry\n\n  /**\n   * Get the leaf text node at a location.\n   */\n  leaf: (\n    editor: Editor,\n    at: Location,\n    options?: EditorLeafOptions\n  ) => NodeEntry<Text>\n\n  /**\n   * Iterate through all of the levels at a location.\n   */\n  levels: <T extends Node>(\n    editor: Editor,\n    options?: EditorLevelsOptions<T>\n  ) => Generator<NodeEntry<T>, void, undefined>\n\n  /**\n   * Get the marks that would be added to text at the current selection.\n   */\n  marks: (editor: Editor) => Omit<Text, 'text'> | null\n\n  /**\n   * Get the matching node in the branch of the document after a location.\n   */\n  next: <T extends Descendant>(\n    editor: Editor,\n    options?: EditorNextOptions<T>\n  ) => NodeEntry<T> | undefined\n\n  /**\n   * Get the node at a location.\n   */\n  node: (editor: Editor, at: Location, options?: EditorNodeOptions) => NodeEntry\n\n  /**\n   * Iterate through all of the nodes in the Editor.\n   */\n  nodes: <T extends Node>(\n    editor: Editor,\n    options?: EditorNodesOptions<T>\n  ) => Generator<NodeEntry<T>, void, undefined>\n\n  /**\n   * Normalize any dirty objects in the editor.\n   */\n  normalize: (editor: Editor, options?: EditorNormalizeOptions) => void\n\n  /**\n   * Get the parent node of a location.\n   */\n  parent: (\n    editor: Editor,\n    at: Location,\n    options?: EditorParentOptions\n  ) => NodeEntry<Ancestor>\n\n  /**\n   * Get the path of a location.\n   */\n  path: (editor: Editor, at: Location, options?: EditorPathOptions) => Path\n\n  /**\n   * Create a mutable ref for a `Path` object, which will stay in sync as new\n   * operations are applied to the editor.\n   */\n  pathRef: (\n    editor: Editor,\n    path: Path,\n    options?: EditorPathRefOptions\n  ) => PathRef\n\n  /**\n   * Get the set of currently tracked path refs of the editor.\n   */\n  pathRefs: (editor: Editor) => Set<PathRef>\n\n  /**\n   * Get the start or end point of a location.\n   */\n  point: (editor: Editor, at: Location, options?: EditorPointOptions) => Point\n\n  /**\n   * Create a mutable ref for a `Point` object, which will stay in sync as new\n   * operations are applied to the editor.\n   */\n  pointRef: (\n    editor: Editor,\n    point: Point,\n    options?: EditorPointRefOptions\n  ) => PointRef\n\n  /**\n   * Get the set of currently tracked point refs of the editor.\n   */\n  pointRefs: (editor: Editor) => Set<PointRef>\n\n  /**\n   * Return all the positions in `at` range where a `Point` can be placed.\n   *\n   * By default, moves forward by individual offsets at a time, but\n   * the `unit` option can be used to to move by character, word, line, or block.\n   *\n   * The `reverse` option can be used to change iteration direction.\n   *\n   * Note: By default void nodes are treated as a single point and iteration\n   * will not happen inside their content unless you pass in true for the\n   * `voids` option, then iteration will occur.\n   */\n  positions: (\n    editor: Editor,\n    options?: EditorPositionsOptions\n  ) => Generator<Point, void, undefined>\n\n  /**\n   * Get the matching node in the branch of the document before a location.\n   */\n  previous: <T extends Node>(\n    editor: Editor,\n    options?: EditorPreviousOptions<T>\n  ) => NodeEntry<T> | undefined\n\n  /**\n   * Get a range of a location.\n   */\n  range: (editor: Editor, at: Location, to?: Location) => Range\n\n  /**\n   * Create a mutable ref for a `Range` object, which will stay in sync as new\n   * operations are applied to the editor.\n   */\n  rangeRef: (\n    editor: Editor,\n    range: Range,\n    options?: EditorRangeRefOptions\n  ) => RangeRef\n\n  /**\n   * Get the set of currently tracked range refs of the editor.\n   */\n  rangeRefs: (editor: Editor) => Set<RangeRef>\n\n  /**\n   * Remove a custom property from all of the leaf text nodes in the current\n   * selection.\n   *\n   * If the selection is currently collapsed, the removal will be stored on\n   * `editor.marks` and applied to the text inserted next.\n   */\n  removeMark: (editor: Editor, key: string) => void\n\n  /**\n   * Manually set if the editor should currently be normalizing.\n   *\n   * Note: Using this incorrectly can leave the editor in an invalid state.\n   *\n   */\n  setNormalizing: (editor: Editor, isNormalizing: boolean) => void\n\n  /**\n   * Get the start point of a location.\n   */\n  start: (editor: Editor, at: Location) => Point\n\n  /**\n   * Get the text string content of a location.\n   *\n   * Note: by default the text of void nodes is considered to be an empty\n   * string, regardless of content, unless you pass in true for the voids option\n   */\n  string: (\n    editor: Editor,\n    at: Location,\n    options?: EditorStringOptions\n  ) => string\n\n  /**\n   * Convert a range into a non-hanging one.\n   */\n  unhangRange: (\n    editor: Editor,\n    range: Range,\n    options?: EditorUnhangRangeOptions\n  ) => Range\n\n  /**\n   * Match a void node in the current branch of the editor.\n   */\n  void: (\n    editor: Editor,\n    options?: EditorVoidOptions\n  ) => NodeEntry<Element> | undefined\n\n  /**\n   * Call a function, deferring normalization until after it completes.\n   */\n  withoutNormalizing: (editor: Editor, fn: () => void) => void\n\n  /**\n   *  Call a function, Determine whether or not remove the previous node when merge.\n   */\n  shouldMergeNodesRemovePrevNode: (\n    editor: Editor,\n    prevNodeEntry: NodeEntry,\n    curNodeEntry: NodeEntry\n  ) => boolean\n}\n\n// eslint-disable-next-line no-redeclare\nexport const Editor: EditorInterface = {\n  above(editor, options) {\n    return editor.above(options)\n  },\n\n  addMark(editor, key, value) {\n    editor.addMark(key, value)\n  },\n\n  after(editor, at, options) {\n    return editor.after(at, options)\n  },\n\n  before(editor, at, options) {\n    return editor.before(at, options)\n  },\n\n  deleteBackward(editor, options = {}) {\n    const { unit = 'character' } = options\n    editor.deleteBackward(unit)\n  },\n\n  deleteForward(editor, options = {}) {\n    const { unit = 'character' } = options\n    editor.deleteForward(unit)\n  },\n\n  deleteFragment(editor, options) {\n    editor.deleteFragment(options)\n  },\n\n  edges(editor, at) {\n    return editor.edges(at)\n  },\n\n  elementReadOnly(editor: Editor, options: EditorElementReadOnlyOptions = {}) {\n    return editor.elementReadOnly(options)\n  },\n\n  end(editor, at) {\n    return editor.end(at)\n  },\n\n  first(editor, at) {\n    return editor.first(at)\n  },\n\n  fragment(editor, at) {\n    return editor.fragment(at)\n  },\n\n  hasBlocks(editor, element) {\n    return editor.hasBlocks(element)\n  },\n\n  hasInlines(editor, element) {\n    return editor.hasInlines(element)\n  },\n\n  hasPath(editor, path) {\n    return editor.hasPath(path)\n  },\n\n  hasTexts(editor, element) {\n    return editor.hasTexts(element)\n  },\n\n  insertBreak(editor) {\n    editor.insertBreak()\n  },\n\n  insertFragment(editor, fragment, options) {\n    editor.insertFragment(fragment, options)\n  },\n\n  insertNode(editor, node) {\n    editor.insertNode(node)\n  },\n\n  insertSoftBreak(editor) {\n    editor.insertSoftBreak()\n  },\n\n  insertText(editor, text) {\n    editor.insertText(text)\n  },\n\n  isBlock(editor, value) {\n    return editor.isBlock(value)\n  },\n\n  isEdge(editor, point, at) {\n    return editor.isEdge(point, at)\n  },\n\n  isEditor(value: any): value is Editor {\n    return isEditor(value)\n  },\n\n  isElementReadOnly(editor, element) {\n    return editor.isElementReadOnly(element)\n  },\n\n  isEmpty(editor, element) {\n    return editor.isEmpty(element)\n  },\n\n  isEnd(editor, point, at) {\n    return editor.isEnd(point, at)\n  },\n\n  isInline(editor, value) {\n    return editor.isInline(value)\n  },\n\n  isNormalizing(editor) {\n    return editor.isNormalizing()\n  },\n\n  isSelectable(editor: Editor, value: Element) {\n    return editor.isSelectable(value)\n  },\n\n  isStart(editor, point, at) {\n    return editor.isStart(point, at)\n  },\n\n  isVoid(editor, value) {\n    return editor.isVoid(value)\n  },\n\n  last(editor, at) {\n    return editor.last(at)\n  },\n\n  leaf(editor, at, options) {\n    return editor.leaf(at, options)\n  },\n\n  levels(editor, options) {\n    return editor.levels(options)\n  },\n\n  marks(editor) {\n    return editor.getMarks()\n  },\n\n  next<T extends Descendant>(\n    editor: Editor,\n    options?: EditorNextOptions<T>\n  ): NodeEntry<T> | undefined {\n    return editor.next(options)\n  },\n\n  node(editor, at, options) {\n    return editor.node(at, options)\n  },\n\n  nodes(editor, options) {\n    return editor.nodes(options)\n  },\n\n  normalize(editor, options) {\n    editor.normalize(options)\n  },\n\n  parent(editor, at, options) {\n    return editor.parent(at, options)\n  },\n\n  path(editor, at, options) {\n    return editor.path(at, options)\n  },\n\n  pathRef(editor, path, options) {\n    return editor.pathRef(path, options)\n  },\n\n  pathRefs(editor) {\n    return editor.pathRefs()\n  },\n\n  point(editor, at, options) {\n    return editor.point(at, options)\n  },\n\n  pointRef(editor, point, options) {\n    return editor.pointRef(point, options)\n  },\n\n  pointRefs(editor) {\n    return editor.pointRefs()\n  },\n\n  positions(editor, options) {\n    return editor.positions(options)\n  },\n\n  previous(editor, options) {\n    return editor.previous(options)\n  },\n\n  range(editor, at, to) {\n    return editor.range(at, to)\n  },\n\n  rangeRef(editor, range, options) {\n    return editor.rangeRef(range, options)\n  },\n\n  rangeRefs(editor) {\n    return editor.rangeRefs()\n  },\n\n  removeMark(editor, key) {\n    editor.removeMark(key)\n  },\n\n  setNormalizing(editor, isNormalizing) {\n    editor.setNormalizing(isNormalizing)\n  },\n\n  start(editor, at) {\n    return editor.start(at)\n  },\n\n  string(editor, at, options) {\n    return editor.string(at, options)\n  },\n\n  unhangRange(editor, range, options) {\n    return editor.unhangRange(range, options)\n  },\n\n  void(editor, options) {\n    return editor.void(options)\n  },\n\n  withoutNormalizing(editor, fn: () => void) {\n    editor.withoutNormalizing(fn)\n  },\n  shouldMergeNodesRemovePrevNode: (editor, prevNode, curNode) => {\n    return editor.shouldMergeNodesRemovePrevNode(prevNode, curNode)\n  },\n}\n\n/**\n * A helper type for narrowing matched nodes with a predicate.\n */\n\nexport type NodeMatch<T extends Node> =\n  | ((node: Node, path: Path) => node is T)\n  | ((node: Node, path: Path) => boolean)\n\nexport type PropsCompare = (prop: Partial<Node>, node: Partial<Node>) => boolean\nexport type PropsMerge = (prop: Partial<Node>, node: Partial<Node>) => object\n","import { Path, Point, Range } from '..'\n\n/**\n * The `Location` interface is a union of the ways to refer to a specific\n * location in a Slate document: paths, points or ranges.\n *\n * Methods will often accept a `Location` instead of requiring only a `Path`,\n * `Point` or `Range`. This eliminates the need for developers to manage\n * converting between the different interfaces in their own code base.\n */\n\nexport type Location = Path | Point | Range\n\nexport interface LocationInterface {\n  /**\n   * Check if a value implements the `Location` interface.\n   */\n  isLocation: (value: any) => value is Location\n}\n\n// eslint-disable-next-line no-redeclare\nexport const Location: LocationInterface = {\n  isLocation(value: any): value is Location {\n    return Path.isPath(value) || Point.isPoint(value) || Range.isRange(value)\n  },\n}\n\n/**\n * The `Span` interface is a low-level way to refer to locations in nodes\n * without using `Point` which requires leaf text nodes to be present.\n */\n\nexport type Span = [Path, Path]\n\nexport interface SpanInterface {\n  /**\n   * Check if a value implements the `Span` interface.\n   */\n  isSpan: (value: any) => value is Span\n}\n\n// eslint-disable-next-line no-redeclare\nexport const Span: SpanInterface = {\n  isSpan(value: any): value is Span {\n    return (\n      Array.isArray(value) && value.length === 2 && value.every(Path.isPath)\n    )\n  },\n}\n","import { isPlainObject } from 'is-plain-object'\nimport { produce } from 'immer'\nimport { ExtendedType, Operation, Path } from '..'\nimport { TextDirection } from '../types/types'\n\n/**\n * `Point` objects refer to a specific location in a text node in a Slate\n * document. Its path refers to the location of the node in the tree, and its\n * offset refers to the distance into the node's string of text. Points can\n * only refer to `Text` nodes.\n */\n\nexport interface BasePoint {\n  path: Path\n  offset: number\n}\n\nexport type Point = ExtendedType<'Point', BasePoint>\n\nexport interface PointTransformOptions {\n  affinity?: TextDirection | null\n}\n\nexport interface PointInterface {\n  /**\n   * Compare a point to another, returning an integer indicating whether the\n   * point was before, at, or after the other.\n   */\n  compare: (point: Point, another: Point) => -1 | 0 | 1\n\n  /**\n   * Check if a point is after another.\n   */\n  isAfter: (point: Point, another: Point) => boolean\n\n  /**\n   * Check if a point is before another.\n   */\n  isBefore: (point: Point, another: Point) => boolean\n\n  /**\n   * Check if a point is exactly equal to another.\n   */\n  equals: (point: Point, another: Point) => boolean\n\n  /**\n   * Check if a value implements the `Point` interface.\n   */\n  isPoint: (value: any) => value is Point\n\n  /**\n   * Transform a point by an operation.\n   */\n  transform: (\n    point: Point,\n    op: Operation,\n    options?: PointTransformOptions\n  ) => Point | null\n}\n\n// eslint-disable-next-line no-redeclare\nexport const Point: PointInterface = {\n  compare(point: Point, another: Point): -1 | 0 | 1 {\n    const result = Path.compare(point.path, another.path)\n\n    if (result === 0) {\n      if (point.offset < another.offset) return -1\n      if (point.offset > another.offset) return 1\n      return 0\n    }\n\n    return result\n  },\n\n  isAfter(point: Point, another: Point): boolean {\n    return Point.compare(point, another) === 1\n  },\n\n  isBefore(point: Point, another: Point): boolean {\n    return Point.compare(point, another) === -1\n  },\n\n  equals(point: Point, another: Point): boolean {\n    // PERF: ensure the offsets are equal first since they are cheaper to check.\n    return (\n      point.offset === another.offset && Path.equals(point.path, another.path)\n    )\n  },\n\n  isPoint(value: any): value is Point {\n    return (\n      isPlainObject(value) &&\n      typeof value.offset === 'number' &&\n      Path.isPath(value.path)\n    )\n  },\n\n  transform(\n    point: Point | null,\n    op: Operation,\n    options: PointTransformOptions = {}\n  ): Point | null {\n    return produce(point, p => {\n      if (p === null) {\n        return null\n      }\n      const { affinity = 'forward' } = options\n      const { path, offset } = p\n\n      switch (op.type) {\n        case 'insert_node':\n        case 'move_node': {\n          p.path = Path.transform(path, op, options)!\n          break\n        }\n\n        case 'insert_text': {\n          if (\n            Path.equals(op.path, path) &&\n            (op.offset < offset ||\n              (op.offset === offset && affinity === 'forward'))\n          ) {\n            p.offset += op.text.length\n          }\n\n          break\n        }\n\n        case 'merge_node': {\n          if (Path.equals(op.path, path)) {\n            p.offset += op.position\n          }\n\n          p.path = Path.transform(path, op, options)!\n          break\n        }\n\n        case 'remove_text': {\n          if (Path.equals(op.path, path) && op.offset <= offset) {\n            p.offset -= Math.min(offset - op.offset, op.text.length)\n          }\n\n          break\n        }\n\n        case 'remove_node': {\n          if (Path.equals(op.path, path) || Path.isAncestor(op.path, path)) {\n            return null\n          }\n\n          p.path = Path.transform(path, op, options)!\n          break\n        }\n\n        case 'split_node': {\n          if (Path.equals(op.path, path)) {\n            if (op.position === offset && affinity == null) {\n              return null\n            } else if (\n              op.position < offset ||\n              (op.position === offset && affinity === 'forward')\n            ) {\n              p.offset -= op.position\n\n              p.path = Path.transform(path, op, {\n                ...options,\n                affinity: 'forward',\n              })!\n            }\n          } else {\n            p.path = Path.transform(path, op, options)!\n          }\n\n          break\n        }\n      }\n    })\n  },\n}\n\n/**\n * `PointEntry` objects are returned when iterating over `Point` objects that\n * belong to a range.\n */\n\nexport type PointEntry = [Point, 'anchor' | 'focus']\n","export type Scrubber = (key: string, value: unknown) => unknown\n\nexport interface ScrubberInterface {\n  setScrubber(scrubber: Scrubber | undefined): void\n  stringify(value: any): string\n}\n\nlet _scrubber: Scrubber | undefined = undefined\n\n/**\n * This interface implements a stringify() function, which is used by Slate\n * internally when generating exceptions containing end user data. Developers\n * using Slate may call Scrubber.setScrubber() to alter the behavior of this\n * stringify() function.\n *\n * For example, to prevent the cleartext logging of 'text' fields within Nodes:\n *\n *    import { Scrubber } from 'slate';\n *    Scrubber.setScrubber((key, val) => {\n *      if (key === 'text') return '...scrubbed...'\n *      return val\n *    });\n *\n */\n// eslint-disable-next-line no-redeclare\nexport const Scrubber: ScrubberInterface = {\n  setScrubber(scrubber: Scrubber | undefined): void {\n    _scrubber = scrubber\n  },\n\n  stringify(value: any): string {\n    return JSON.stringify(value, _scrubber)\n  },\n}\n","import { isPlainObject } from 'is-plain-object'\nimport { Path, Range } from '..'\nimport { ExtendedType } from '../types/custom-types'\nimport { isDeepEqual } from '../utils/deep-equal'\n\n/**\n * `Text` objects represent the nodes that contain the actual text content of a\n * Slate document along with any formatting properties. They are always leaf\n * nodes in the document tree as they cannot contain any children.\n */\n\nexport interface BaseText {\n  text: string\n}\n\nexport type Text = ExtendedType<'Text', BaseText>\n\nexport interface LeafPosition {\n  start: number\n  end: number\n  isFirst?: true\n  isLast?: true\n}\n\nexport interface TextEqualsOptions {\n  loose?: boolean\n}\n\nexport type DecoratedRange = Range & {\n  /**\n   * Customize how another decoration is merged into a text node. If not specified, `Object.assign` would be used.\n   * It is useful for overlapping decorations with the same key but different values.\n   */\n  merge?: (leaf: Text, decoration: object) => void\n}\n\nexport interface TextInterface {\n  /**\n   * Check if two text nodes are equal.\n   *\n   * When loose is set, the text is not compared. This is\n   * used to check whether sibling text nodes can be merged.\n   */\n  equals: (text: Text, another: Text, options?: TextEqualsOptions) => boolean\n\n  /**\n   * Check if a value implements the `Text` interface.\n   */\n  isText: (value: any) => value is Text\n\n  /**\n   * Check if a value is a list of `Text` objects.\n   */\n  isTextList: (value: any) => value is Text[]\n\n  /**\n   * Check if some props are a partial of Text.\n   */\n  isTextProps: (props: any) => props is Partial<Text>\n\n  /**\n   * Check if an text matches set of properties.\n   *\n   * Note: this is for matching custom properties, and it does not ensure that\n   * the `text` property are two nodes equal.\n   */\n  matches: (text: Text, props: Partial<Text>) => boolean\n\n  /**\n   * Get the leaves for a text node given decorations.\n   */\n  decorations: (\n    node: Text,\n    decorations: DecoratedRange[]\n  ) => { leaf: Text; position?: LeafPosition }[]\n}\n\n// eslint-disable-next-line no-redeclare\nexport const Text: TextInterface = {\n  equals(text: Text, another: Text, options: TextEqualsOptions = {}): boolean {\n    const { loose = false } = options\n\n    function omitText(obj: Record<any, any>) {\n      const { text, ...rest } = obj\n\n      return rest\n    }\n\n    return isDeepEqual(\n      loose ? omitText(text) : text,\n      loose ? omitText(another) : another\n    )\n  },\n\n  isText(value: any): value is Text {\n    return isPlainObject(value) && typeof value.text === 'string'\n  },\n\n  isTextList(value: any): value is Text[] {\n    return Array.isArray(value) && value.every(val => Text.isText(val))\n  },\n\n  isTextProps(props: any): props is Partial<Text> {\n    return (props as Partial<Text>).text !== undefined\n  },\n\n  matches(text: Text, props: Partial<Text>): boolean {\n    for (const key in props) {\n      if (key === 'text') {\n        continue\n      }\n\n      if (\n        !text.hasOwnProperty(key) ||\n        text[<keyof Text>key] !== props[<keyof Text>key]\n      ) {\n        return false\n      }\n    }\n\n    return true\n  },\n\n  decorations(\n    node: Text,\n    decorations: DecoratedRange[]\n  ): { leaf: Text; position?: LeafPosition }[] {\n    let leaves: { leaf: Text; position?: LeafPosition }[] = [\n      { leaf: { ...node } },\n    ]\n\n    for (const dec of decorations) {\n      const { anchor, focus, merge: mergeDecoration, ...rest } = dec\n      const [start, end] = Range.edges(dec)\n      const next = []\n      let leafEnd = 0\n      const decorationStart = start.offset\n      const decorationEnd = end.offset\n      const merge = mergeDecoration ?? Object.assign\n\n      for (const { leaf } of leaves) {\n        const { length } = leaf.text\n        const leafStart = leafEnd\n        leafEnd += length\n\n        // If the range encompasses the entire leaf, add the range.\n        if (decorationStart <= leafStart && leafEnd <= decorationEnd) {\n          merge(leaf, rest)\n          next.push({ leaf })\n          continue\n        }\n\n        // If the range expanded and match the leaf, or starts after, or ends before it, continue.\n        if (\n          (decorationStart !== decorationEnd &&\n            (decorationStart === leafEnd || decorationEnd === leafStart)) ||\n          decorationStart > leafEnd ||\n          decorationEnd < leafStart ||\n          (decorationEnd === leafStart && leafStart !== 0)\n        ) {\n          next.push({ leaf })\n          continue\n        }\n\n        // Otherwise we need to split the leaf, at the start, end, or both,\n        // and add the range to the middle intersecting section. Do the end\n        // split first since we don't need to update the offset that way.\n        let middle = leaf\n        let before\n        let after\n\n        if (decorationEnd < leafEnd) {\n          const off = decorationEnd - leafStart\n          after = { leaf: { ...middle, text: middle.text.slice(off) } }\n          middle = { ...middle, text: middle.text.slice(0, off) }\n        }\n\n        if (decorationStart > leafStart) {\n          const off = decorationStart - leafStart\n          before = { leaf: { ...middle, text: middle.text.slice(0, off) } }\n          middle = { ...middle, text: middle.text.slice(off) }\n        }\n\n        merge(middle, rest)\n\n        if (before) {\n          next.push(before)\n        }\n\n        next.push({ leaf: middle })\n\n        if (after) {\n          next.push(after)\n        }\n      }\n\n      leaves = next\n    }\n\n    if (leaves.length > 1) {\n      let currentOffset = 0\n      for (const [index, item] of leaves.entries()) {\n        const start = currentOffset\n        const end = start + item.leaf.text.length\n        const position: LeafPosition = { start, end }\n\n        if (index === 0) position.isFirst = true\n        if (index === leaves.length - 1) position.isLast = true\n\n        item.position = position\n        currentOffset = end\n      }\n    }\n\n    return leaves\n  },\n}\n","import { Editor, Location } from '../interfaces'\n\n/**\n * Get the default location to insert content into the editor.\n * By default, use the selection as the target location. But if there is\n * no selection, insert at the end of the document since that is such a\n * common use case when inserting from a non-selected state.\n */\nexport const getDefaultInsertLocation = (editor: Editor): Location => {\n  if (editor.selection) {\n    return editor.selection\n  } else if (editor.children.length > 0) {\n    return Editor.end(editor, [])\n  } else {\n    return [0]\n  }\n}\n","import { Editor } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { Node } from '../interfaces/node'\n\nexport const matchPath = (\n  editor: Editor,\n  path: Path\n): ((node: Node) => boolean) => {\n  const [node] = Editor.node(editor, path)\n  return n => n === node\n}\n","// Character (grapheme cluster) boundaries are determined according to\n// the default grapheme cluster boundary specification, extended grapheme clusters variant[1].\n//\n// References:\n//\n// [1] https://www.unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table\n// [2] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt\n// [3] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.html\n// [4] https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt\n\n/**\n * Get the distance to the end of the first character in a string of text.\n */\n\nexport const getCharacterDistance = (str: string, isRTL = false): number => {\n  const isLTR = !isRTL\n  const codepoints = isRTL ? codepointsIteratorRTL(str) : str\n\n  let left: CodepointType = CodepointType.None\n  let right: CodepointType = CodepointType.None\n  let distance = 0\n  // Evaluation of these conditions are deferred.\n  let gb11: boolean | null = null // Is GB11 applicable?\n  let gb12Or13: boolean | null = null // Is GB12 or GB13 applicable?\n\n  for (const char of codepoints) {\n    const code = char.codePointAt(0)\n    if (!code) break\n\n    const type = getCodepointType(char, code)\n    ;[left, right] = isLTR ? [right, type] : [type, left]\n\n    if (\n      intersects(left, CodepointType.ZWJ) &&\n      intersects(right, CodepointType.ExtPict)\n    ) {\n      if (isLTR) {\n        gb11 = endsWithEmojiZWJ(str.substring(0, distance))\n      } else {\n        gb11 = endsWithEmojiZWJ(str.substring(0, str.length - distance))\n      }\n      if (!gb11) break\n    }\n\n    if (\n      intersects(left, CodepointType.RI) &&\n      intersects(right, CodepointType.RI)\n    ) {\n      if (gb12Or13 !== null) {\n        gb12Or13 = !gb12Or13\n      } else {\n        if (isLTR) {\n          gb12Or13 = true\n        } else {\n          gb12Or13 = endsWithOddNumberOfRIs(\n            str.substring(0, str.length - distance)\n          )\n        }\n      }\n      if (!gb12Or13) break\n    }\n\n    if (\n      left !== CodepointType.None &&\n      right !== CodepointType.None &&\n      isBoundaryPair(left, right)\n    ) {\n      break\n    }\n\n    distance += char.length\n  }\n\n  return distance || 1\n}\n\nconst SPACE = /\\s/\nconst PUNCTUATION =\n  /[\\u002B\\u0021-\\u0023\\u0025-\\u002A\\u002C-\\u002F\\u003A\\u003B\\u003F\\u0040\\u005B-\\u005D\\u005F\\u007B\\u007D\\u00A1\\u00A7\\u00AB\\u00B6\\u00B7\\u00BB\\u00BF\\u037E\\u0387\\u055A-\\u055F\\u0589\\u058A\\u05BE\\u05C0\\u05C3\\u05C6\\u05F3\\u05F4\\u0609\\u060A\\u060C\\u060D\\u061B\\u061E\\u061F\\u066A-\\u066D\\u06D4\\u0700-\\u070D\\u07F7-\\u07F9\\u0830-\\u083E\\u085E\\u0964\\u0965\\u0970\\u0AF0\\u0DF4\\u0E4F\\u0E5A\\u0E5B\\u0F04-\\u0F12\\u0F14\\u0F3A-\\u0F3D\\u0F85\\u0FD0-\\u0FD4\\u0FD9\\u0FDA\\u104A-\\u104F\\u10FB\\u1360-\\u1368\\u1400\\u166D\\u166E\\u169B\\u169C\\u16EB-\\u16ED\\u1735\\u1736\\u17D4-\\u17D6\\u17D8-\\u17DA\\u1800-\\u180A\\u1944\\u1945\\u1A1E\\u1A1F\\u1AA0-\\u1AA6\\u1AA8-\\u1AAD\\u1B5A-\\u1B60\\u1BFC-\\u1BFF\\u1C3B-\\u1C3F\\u1C7E\\u1C7F\\u1CC0-\\u1CC7\\u1CD3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205E\\u207D\\u207E\\u208D\\u208E\\u2329\\u232A\\u2768-\\u2775\\u27C5\\u27C6\\u27E6-\\u27EF\\u2983-\\u2998\\u29D8-\\u29DB\\u29FC\\u29FD\\u2CF9-\\u2CFC\\u2CFE\\u2CFF\\u2D70\\u2E00-\\u2E2E\\u2E30-\\u2E3B\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u3030\\u303D\\u30A0\\u30FB\\uA4FE\\uA4FF\\uA60D-\\uA60F\\uA673\\uA67E\\uA6F2-\\uA6F7\\uA874-\\uA877\\uA8CE\\uA8CF\\uA8F8-\\uA8FA\\uA92E\\uA92F\\uA95F\\uA9C1-\\uA9CD\\uA9DE\\uA9DF\\uAA5C-\\uAA5F\\uAADE\\uAADF\\uAAF0\\uAAF1\\uABEB\\uFD3E\\uFD3F\\uFE10-\\uFE19\\uFE30-\\uFE52\\uFE54-\\uFE61\\uFE63\\uFE68\\uFE6A\\uFE6B\\uFF01-\\uFF03\\uFF05-\\uFF0A\\uFF0C-\\uFF0F\\uFF1A\\uFF1B\\uFF1F\\uFF20\\uFF3B-\\uFF3D\\uFF3F\\uFF5B\\uFF5D\\uFF5F-\\uFF65]/\nconst CHAMELEON = /['\\u2018\\u2019]/\n\n/**\n * Get the distance to the end of the first word in a string of text.\n */\n\nexport const getWordDistance = (text: string, isRTL = false): number => {\n  let dist = 0\n  let started = false\n\n  while (text.length > 0) {\n    const charDist = getCharacterDistance(text, isRTL)\n    const [char, remaining] = splitByCharacterDistance(text, charDist, isRTL)\n\n    if (isWordCharacter(char, remaining, isRTL)) {\n      started = true\n      dist += charDist\n    } else if (!started) {\n      dist += charDist\n    } else {\n      break\n    }\n\n    text = remaining\n  }\n\n  return dist\n}\n\n/**\n * Split a string in two parts at a given distance starting from the end when\n * `isRTL` is set to `true`.\n */\n\nexport const splitByCharacterDistance = (\n  str: string,\n  dist: number,\n  isRTL?: boolean\n): [string, string] => {\n  if (isRTL) {\n    const at = str.length - dist\n    return [str.slice(at, str.length), str.slice(0, at)]\n  }\n\n  return [str.slice(0, dist), str.slice(dist)]\n}\n\n/**\n * Check if a character is a word character. The `remaining` argument is used\n * because sometimes you must read subsequent characters to truly determine it.\n */\n\nconst isWordCharacter = (\n  char: string,\n  remaining: string,\n  isRTL = false\n): boolean => {\n  if (SPACE.test(char)) {\n    return false\n  }\n\n  // Chameleons count as word characters as long as they're in a word, so\n  // recurse to see if the next one is a word character or not.\n  if (CHAMELEON.test(char)) {\n    const charDist = getCharacterDistance(remaining, isRTL)\n    const [nextChar, nextRemaining] = splitByCharacterDistance(\n      remaining,\n      charDist,\n      isRTL\n    )\n\n    if (isWordCharacter(nextChar, nextRemaining, isRTL)) {\n      return true\n    }\n  }\n\n  if (PUNCTUATION.test(char)) {\n    return false\n  }\n\n  return true\n}\n\n/**\n * Iterate on codepoints from right to left.\n */\n\nexport const codepointsIteratorRTL = function* (str: string) {\n  const end = str.length - 1\n\n  for (let i = 0; i < str.length; i++) {\n    const char1 = str.charAt(end - i)\n\n    if (isLowSurrogate(char1.charCodeAt(0))) {\n      const char2 = str.charAt(end - i - 1)\n      if (isHighSurrogate(char2.charCodeAt(0))) {\n        yield char2 + char1\n\n        i++\n        continue\n      }\n    }\n\n    yield char1\n  }\n}\n\n/**\n * Is `charCode` a high surrogate.\n *\n * https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates\n */\n\nconst isHighSurrogate = (charCode: number) => {\n  return charCode >= 0xd800 && charCode <= 0xdbff\n}\n\n/**\n * Is `charCode` a low surrogate.\n *\n * https://en.wikipedia.org/wiki/Universal_Character_Set_characters#Surrogates\n */\n\nconst isLowSurrogate = (charCode: number) => {\n  return charCode >= 0xdc00 && charCode <= 0xdfff\n}\n\nenum CodepointType {\n  None = 0,\n  Extend = 1 << 0,\n  ZWJ = 1 << 1,\n  RI = 1 << 2,\n  Prepend = 1 << 3,\n  SpacingMark = 1 << 4,\n  L = 1 << 5,\n  V = 1 << 6,\n  T = 1 << 7,\n  LV = 1 << 8,\n  LVT = 1 << 9,\n  ExtPict = 1 << 10,\n  Any = 1 << 11,\n}\n\nconst reExtend = /^[\\p{Gr_Ext}\\p{EMod}]$/u\nconst rePrepend =\n  /^[\\u0600-\\u0605\\u06DD\\u070F\\u0890-\\u0891\\u08E2\\u0D4E\\u{110BD}\\u{110CD}\\u{111C2}-\\u{111C3}\\u{1193F}\\u{11941}\\u{11A3A}\\u{11A84}-\\u{11A89}\\u{11D46}]$/u\nconst reSpacingMark =\n  /^[\\u0903\\u093B\\u093E-\\u0940\\u0949-\\u094C\\u094E-\\u094F\\u0982-\\u0983\\u09BF-\\u09C0\\u09C7-\\u09C8\\u09CB-\\u09CC\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB-\\u0ACC\\u0B02-\\u0B03\\u0B40\\u0B47-\\u0B48\\u0B4B-\\u0B4C\\u0BBF\\u0BC1-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82-\\u0C83\\u0CBE\\u0CC0-\\u0CC1\\u0CC3-\\u0CC4\\u0CC7-\\u0CC8\\u0CCA-\\u0CCB\\u0D02-\\u0D03\\u0D3F-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D82-\\u0D83\\u0DD0-\\u0DD1\\u0DD8-\\u0DDE\\u0DF2-\\u0DF3\\u0E33\\u0EB3\\u0F3E-\\u0F3F\\u0F7F\\u1031\\u103B-\\u103C\\u1056-\\u1057\\u1084\\u1715\\u1734\\u17B6\\u17BE-\\u17C5\\u17C7-\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930-\\u1931\\u1933-\\u1938\\u1A19-\\u1A1A\\u1A55\\u1A57\\u1A6D-\\u1A72\\u1B04\\u1B3B\\u1B3D-\\u1B41\\u1B43-\\u1B44\\u1B82\\u1BA1\\u1BA6-\\u1BA7\\u1BAA\\u1BE7\\u1BEA-\\u1BEC\\u1BEE\\u1BF2-\\u1BF3\\u1C24-\\u1C2B\\u1C34-\\u1C35\\u1CE1\\u1CF7\\uA823-\\uA824\\uA827\\uA880-\\uA881\\uA8B4-\\uA8C3\\uA952-\\uA953\\uA983\\uA9B4-\\uA9B5\\uA9BA-\\uA9BB\\uA9BE-\\uA9C0\\uAA2F-\\uAA30\\uAA33-\\uAA34\\uAA4D\\uAAEB\\uAAEE-\\uAAEF\\uAAF5\\uABE3-\\uABE4\\uABE6-\\uABE7\\uABE9-\\uABEA\\uABEC\\u{11000}\\u{11002}\\u{11082}\\u{110B0}-\\u{110B2}\\u{110B7}-\\u{110B8}\\u{1112C}\\u{11145}-\\u{11146}\\u{11182}\\u{111B3}-\\u{111B5}\\u{111BF}-\\u{111C0}\\u{111CE}\\u{1122C}-\\u{1122E}\\u{11232}-\\u{11233}\\u{11235}\\u{112E0}-\\u{112E2}\\u{11302}-\\u{11303}\\u{1133F}\\u{11341}-\\u{11344}\\u{11347}-\\u{11348}\\u{1134B}-\\u{1134D}\\u{11362}-\\u{11363}\\u{11435}-\\u{11437}\\u{11440}-\\u{11441}\\u{11445}\\u{114B1}-\\u{114B2}\\u{114B9}\\u{114BB}-\\u{114BC}\\u{114BE}\\u{114C1}\\u{115B0}-\\u{115B1}\\u{115B8}-\\u{115BB}\\u{115BE}\\u{11630}-\\u{11632}\\u{1163B}-\\u{1163C}\\u{1163E}\\u{116AC}\\u{116AE}-\\u{116AF}\\u{116B6}\\u{11726}\\u{1182C}-\\u{1182E}\\u{11838}\\u{11931}-\\u{11935}\\u{11937}-\\u{11938}\\u{1193D}\\u{11940}\\u{11942}\\u{119D1}-\\u{119D3}\\u{119DC}-\\u{119DF}\\u{119E4}\\u{11A39}\\u{11A57}-\\u{11A58}\\u{11A97}\\u{11C2F}\\u{11C3E}\\u{11CA9}\\u{11CB1}\\u{11CB4}\\u{11D8A}-\\u{11D8E}\\u{11D93}-\\u{11D94}\\u{11D96}\\u{11EF5}-\\u{11EF6}\\u{16F51}-\\u{16F87}\\u{16FF0}-\\u{16FF1}\\u{1D166}\\u{1D16D}]$/u\nconst reL = /^[\\u1100-\\u115F\\uA960-\\uA97C]$/u\nconst reV = /^[\\u1160-\\u11A7\\uD7B0-\\uD7C6]$/u\nconst reT = /^[\\u11A8-\\u11FF\\uD7CB-\\uD7FB]$/u\nconst reLV =\n  /^[\\uAC00\\uAC1C\\uAC38\\uAC54\\uAC70\\uAC8C\\uACA8\\uACC4\\uACE0\\uACFC\\uAD18\\uAD34\\uAD50\\uAD6C\\uAD88\\uADA4\\uADC0\\uADDC\\uADF8\\uAE14\\uAE30\\uAE4C\\uAE68\\uAE84\\uAEA0\\uAEBC\\uAED8\\uAEF4\\uAF10\\uAF2C\\uAF48\\uAF64\\uAF80\\uAF9C\\uAFB8\\uAFD4\\uAFF0\\uB00C\\uB028\\uB044\\uB060\\uB07C\\uB098\\uB0B4\\uB0D0\\uB0EC\\uB108\\uB124\\uB140\\uB15C\\uB178\\uB194\\uB1B0\\uB1CC\\uB1E8\\uB204\\uB220\\uB23C\\uB258\\uB274\\uB290\\uB2AC\\uB2C8\\uB2E4\\uB300\\uB31C\\uB338\\uB354\\uB370\\uB38C\\uB3A8\\uB3C4\\uB3E0\\uB3FC\\uB418\\uB434\\uB450\\uB46C\\uB488\\uB4A4\\uB4C0\\uB4DC\\uB4F8\\uB514\\uB530\\uB54C\\uB568\\uB584\\uB5A0\\uB5BC\\uB5D8\\uB5F4\\uB610\\uB62C\\uB648\\uB664\\uB680\\uB69C\\uB6B8\\uB6D4\\uB6F0\\uB70C\\uB728\\uB744\\uB760\\uB77C\\uB798\\uB7B4\\uB7D0\\uB7EC\\uB808\\uB824\\uB840\\uB85C\\uB878\\uB894\\uB8B0\\uB8CC\\uB8E8\\uB904\\uB920\\uB93C\\uB958\\uB974\\uB990\\uB9AC\\uB9C8\\uB9E4\\uBA00\\uBA1C\\uBA38\\uBA54\\uBA70\\uBA8C\\uBAA8\\uBAC4\\uBAE0\\uBAFC\\uBB18\\uBB34\\uBB50\\uBB6C\\uBB88\\uBBA4\\uBBC0\\uBBDC\\uBBF8\\uBC14\\uBC30\\uBC4C\\uBC68\\uBC84\\uBCA0\\uBCBC\\uBCD8\\uBCF4\\uBD10\\uBD2C\\uBD48\\uBD64\\uBD80\\uBD9C\\uBDB8\\uBDD4\\uBDF0\\uBE0C\\uBE28\\uBE44\\uBE60\\uBE7C\\uBE98\\uBEB4\\uBED0\\uBEEC\\uBF08\\uBF24\\uBF40\\uBF5C\\uBF78\\uBF94\\uBFB0\\uBFCC\\uBFE8\\uC004\\uC020\\uC03C\\uC058\\uC074\\uC090\\uC0AC\\uC0C8\\uC0E4\\uC100\\uC11C\\uC138\\uC154\\uC170\\uC18C\\uC1A8\\uC1C4\\uC1E0\\uC1FC\\uC218\\uC234\\uC250\\uC26C\\uC288\\uC2A4\\uC2C0\\uC2DC\\uC2F8\\uC314\\uC330\\uC34C\\uC368\\uC384\\uC3A0\\uC3BC\\uC3D8\\uC3F4\\uC410\\uC42C\\uC448\\uC464\\uC480\\uC49C\\uC4B8\\uC4D4\\uC4F0\\uC50C\\uC528\\uC544\\uC560\\uC57C\\uC598\\uC5B4\\uC5D0\\uC5EC\\uC608\\uC624\\uC640\\uC65C\\uC678\\uC694\\uC6B0\\uC6CC\\uC6E8\\uC704\\uC720\\uC73C\\uC758\\uC774\\uC790\\uC7AC\\uC7C8\\uC7E4\\uC800\\uC81C\\uC838\\uC854\\uC870\\uC88C\\uC8A8\\uC8C4\\uC8E0\\uC8FC\\uC918\\uC934\\uC950\\uC96C\\uC988\\uC9A4\\uC9C0\\uC9DC\\uC9F8\\uCA14\\uCA30\\uCA4C\\uCA68\\uCA84\\uCAA0\\uCABC\\uCAD8\\uCAF4\\uCB10\\uCB2C\\uCB48\\uCB64\\uCB80\\uCB9C\\uCBB8\\uCBD4\\uCBF0\\uCC0C\\uCC28\\uCC44\\uCC60\\uCC7C\\uCC98\\uCCB4\\uCCD0\\uCCEC\\uCD08\\uCD24\\uCD40\\uCD5C\\uCD78\\uCD94\\uCDB0\\uCDCC\\uCDE8\\uCE04\\uCE20\\uCE3C\\uCE58\\uCE74\\uCE90\\uCEAC\\uCEC8\\uCEE4\\uCF00\\uCF1C\\uCF38\\uCF54\\uCF70\\uCF8C\\uCFA8\\uCFC4\\uCFE0\\uCFFC\\uD018\\uD034\\uD050\\uD06C\\uD088\\uD0A4\\uD0C0\\uD0DC\\uD0F8\\uD114\\uD130\\uD14C\\uD168\\uD184\\uD1A0\\uD1BC\\uD1D8\\uD1F4\\uD210\\uD22C\\uD248\\uD264\\uD280\\uD29C\\uD2B8\\uD2D4\\uD2F0\\uD30C\\uD328\\uD344\\uD360\\uD37C\\uD398\\uD3B4\\uD3D0\\uD3EC\\uD408\\uD424\\uD440\\uD45C\\uD478\\uD494\\uD4B0\\uD4CC\\uD4E8\\uD504\\uD520\\uD53C\\uD558\\uD574\\uD590\\uD5AC\\uD5C8\\uD5E4\\uD600\\uD61C\\uD638\\uD654\\uD670\\uD68C\\uD6A8\\uD6C4\\uD6E0\\uD6FC\\uD718\\uD734\\uD750\\uD76C\\uD788]$/u\nconst reLVT =\n  /^[\\uAC01-\\uAC1B\\uAC1D-\\uAC37\\uAC39-\\uAC53\\uAC55-\\uAC6F\\uAC71-\\uAC8B\\uAC8D-\\uACA7\\uACA9-\\uACC3\\uACC5-\\uACDF\\uACE1-\\uACFB\\uACFD-\\uAD17\\uAD19-\\uAD33\\uAD35-\\uAD4F\\uAD51-\\uAD6B\\uAD6D-\\uAD87\\uAD89-\\uADA3\\uADA5-\\uADBF\\uADC1-\\uADDB\\uADDD-\\uADF7\\uADF9-\\uAE13\\uAE15-\\uAE2F\\uAE31-\\uAE4B\\uAE4D-\\uAE67\\uAE69-\\uAE83\\uAE85-\\uAE9F\\uAEA1-\\uAEBB\\uAEBD-\\uAED7\\uAED9-\\uAEF3\\uAEF5-\\uAF0F\\uAF11-\\uAF2B\\uAF2D-\\uAF47\\uAF49-\\uAF63\\uAF65-\\uAF7F\\uAF81-\\uAF9B\\uAF9D-\\uAFB7\\uAFB9-\\uAFD3\\uAFD5-\\uAFEF\\uAFF1-\\uB00B\\uB00D-\\uB027\\uB029-\\uB043\\uB045-\\uB05F\\uB061-\\uB07B\\uB07D-\\uB097\\uB099-\\uB0B3\\uB0B5-\\uB0CF\\uB0D1-\\uB0EB\\uB0ED-\\uB107\\uB109-\\uB123\\uB125-\\uB13F\\uB141-\\uB15B\\uB15D-\\uB177\\uB179-\\uB193\\uB195-\\uB1AF\\uB1B1-\\uB1CB\\uB1CD-\\uB1E7\\uB1E9-\\uB203\\uB205-\\uB21F\\uB221-\\uB23B\\uB23D-\\uB257\\uB259-\\uB273\\uB275-\\uB28F\\uB291-\\uB2AB\\uB2AD-\\uB2C7\\uB2C9-\\uB2E3\\uB2E5-\\uB2FF\\uB301-\\uB31B\\uB31D-\\uB337\\uB339-\\uB353\\uB355-\\uB36F\\uB371-\\uB38B\\uB38D-\\uB3A7\\uB3A9-\\uB3C3\\uB3C5-\\uB3DF\\uB3E1-\\uB3FB\\uB3FD-\\uB417\\uB419-\\uB433\\uB435-\\uB44F\\uB451-\\uB46B\\uB46D-\\uB487\\uB489-\\uB4A3\\uB4A5-\\uB4BF\\uB4C1-\\uB4DB\\uB4DD-\\uB4F7\\uB4F9-\\uB513\\uB515-\\uB52F\\uB531-\\uB54B\\uB54D-\\uB567\\uB569-\\uB583\\uB585-\\uB59F\\uB5A1-\\uB5BB\\uB5BD-\\uB5D7\\uB5D9-\\uB5F3\\uB5F5-\\uB60F\\uB611-\\uB62B\\uB62D-\\uB647\\uB649-\\uB663\\uB665-\\uB67F\\uB681-\\uB69B\\uB69D-\\uB6B7\\uB6B9-\\uB6D3\\uB6D5-\\uB6EF\\uB6F1-\\uB70B\\uB70D-\\uB727\\uB729-\\uB743\\uB745-\\uB75F\\uB761-\\uB77B\\uB77D-\\uB797\\uB799-\\uB7B3\\uB7B5-\\uB7CF\\uB7D1-\\uB7EB\\uB7ED-\\uB807\\uB809-\\uB823\\uB825-\\uB83F\\uB841-\\uB85B\\uB85D-\\uB877\\uB879-\\uB893\\uB895-\\uB8AF\\uB8B1-\\uB8CB\\uB8CD-\\uB8E7\\uB8E9-\\uB903\\uB905-\\uB91F\\uB921-\\uB93B\\uB93D-\\uB957\\uB959-\\uB973\\uB975-\\uB98F\\uB991-\\uB9AB\\uB9AD-\\uB9C7\\uB9C9-\\uB9E3\\uB9E5-\\uB9FF\\uBA01-\\uBA1B\\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235-\\uC24F\\uC251-\\uC26B\\uC26D-\\uC287\\uC289-\\uC2A3\\uC2A5-\\uC2BF\\uC2C1-\\uC2DB\\uC2DD-\\uC2F7\\uC2F9-\\uC313\\uC315-\\uC32F\\uC331-\\uC34B\\uC34D-\\uC367\\uC369-\\uC383\\uC385-\\uC39F\\uC3A1-\\uC3BB\\uC3BD-\\uC3D7\\uC3D9-\\uC3F3\\uC3F5-\\uC40F\\uC411-\\uC42B\\uC42D-\\uC447\\uC449-\\uC463\\uC465-\\uC47F\\uC481-\\uC49B\\uC49D-\\uC4B7\\uC4B9-\\uC4D3\\uC4D5-\\uC4EF\\uC4F1-\\uC50B\\uC50D-\\uC527\\uC529-\\uC543\\uC545-\\uC55F\\uC561-\\uC57B\\uC57D-\\uC597\\uC599-\\uC5B3\\uC5B5-\\uC5CF\\uC5D1-\\uC5EB\\uC5ED-\\uC607\\uC609-\\uC623\\uC625-\\uC63F\\uC641-\\uC65B\\uC65D-\\uC677\\uC679-\\uC693\\uC695-\\uC6AF\\uC6B1-\\uC6CB\\uC6CD-\\uC6E7\\uC6E9-\\uC703\\uC705-\\uC71F\\uC721-\\uC73B\\uC73D-\\uC757\\uC759-\\uC773\\uC775-\\uC78F\\uC791-\\uC7AB\\uC7AD-\\uC7C7\\uC7C9-\\uC7E3\\uC7E5-\\uC7FF\\uC801-\\uC81B\\uC81D-\\uC837\\uC839-\\uC853\\uC855-\\uC86F\\uC871-\\uC88B\\uC88D-\\uC8A7\\uC8A9-\\uC8C3\\uC8C5-\\uC8DF\\uC8E1-\\uC8FB\\uC8FD-\\uC917\\uC919-\\uC933\\uC935-\\uC94F\\uC951-\\uC96B\\uC96D-\\uC987\\uC989-\\uC9A3\\uC9A5-\\uC9BF\\uC9C1-\\uC9DB\\uC9DD-\\uC9F7\\uC9F9-\\uCA13\\uCA15-\\uCA2F\\uCA31-\\uCA4B\\uCA4D-\\uCA67\\uCA69-\\uCA83\\uCA85-\\uCA9F\\uCAA1-\\uCABB\\uCABD-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2EF\\uD2F1-\\uD30B\\uD30D-\\uD327\\uD329-\\uD343\\uD345-\\uD35F\\uD361-\\uD37B\\uD37D-\\uD397\\uD399-\\uD3B3\\uD3B5-\\uD3CF\\uD3D1-\\uD3EB\\uD3ED-\\uD407\\uD409-\\uD423\\uD425-\\uD43F\\uD441-\\uD45B\\uD45D-\\uD477\\uD479-\\uD493\\uD495-\\uD4AF\\uD4B1-\\uD4CB\\uD4CD-\\uD4E7\\uD4E9-\\uD503\\uD505-\\uD51F\\uD521-\\uD53B\\uD53D-\\uD557\\uD559-\\uD573\\uD575-\\uD58F\\uD591-\\uD5AB\\uD5AD-\\uD5C7\\uD5C9-\\uD5E3\\uD5E5-\\uD5FF\\uD601-\\uD61B\\uD61D-\\uD637\\uD639-\\uD653\\uD655-\\uD66F\\uD671-\\uD68B\\uD68D-\\uD6A7\\uD6A9-\\uD6C3\\uD6C5-\\uD6DF\\uD6E1-\\uD6FB\\uD6FD-\\uD717\\uD719-\\uD733\\uD735-\\uD74F\\uD751-\\uD76B\\uD76D-\\uD787\\uD789-\\uD7A3]$/u\nconst reExtPict = /^\\p{ExtPict}$/u\n\nconst getCodepointType = (char: string, code: number): CodepointType => {\n  let type = CodepointType.Any\n  if (char.search(reExtend) !== -1) {\n    type |= CodepointType.Extend\n  }\n  if (code === 0x200d) {\n    type |= CodepointType.ZWJ\n  }\n  if (code >= 0x1f1e6 && code <= 0x1f1ff) {\n    type |= CodepointType.RI\n  }\n  if (char.search(rePrepend) !== -1) {\n    type |= CodepointType.Prepend\n  }\n  if (char.search(reSpacingMark) !== -1) {\n    type |= CodepointType.SpacingMark\n  }\n  if (char.search(reL) !== -1) {\n    type |= CodepointType.L\n  }\n  if (char.search(reV) !== -1) {\n    type |= CodepointType.V\n  }\n  if (char.search(reT) !== -1) {\n    type |= CodepointType.T\n  }\n  if (char.search(reLV) !== -1) {\n    type |= CodepointType.LV\n  }\n  if (char.search(reLVT) !== -1) {\n    type |= CodepointType.LVT\n  }\n  if (char.search(reExtPict) !== -1) {\n    type |= CodepointType.ExtPict\n  }\n\n  return type\n}\n\nfunction intersects(x: CodepointType, y: CodepointType) {\n  return (x & y) !== 0\n}\n\nconst NonBoundaryPairs: [CodepointType, CodepointType][] = [\n  // GB6\n  [\n    CodepointType.L,\n    CodepointType.L | CodepointType.V | CodepointType.LV | CodepointType.LVT,\n  ],\n  // GB7\n  [CodepointType.LV | CodepointType.V, CodepointType.V | CodepointType.T],\n  // GB8\n  [CodepointType.LVT | CodepointType.T, CodepointType.T],\n  // GB9\n  [CodepointType.Any, CodepointType.Extend | CodepointType.ZWJ],\n  // GB9a\n  [CodepointType.Any, CodepointType.SpacingMark],\n  // GB9b\n  [CodepointType.Prepend, CodepointType.Any],\n  // GB11\n  [CodepointType.ZWJ, CodepointType.ExtPict],\n  // GB12 and GB13\n  [CodepointType.RI, CodepointType.RI],\n]\n\nfunction isBoundaryPair(left: CodepointType, right: CodepointType) {\n  return (\n    NonBoundaryPairs.findIndex(\n      r => intersects(left, r[0]) && intersects(right, r[1])\n    ) === -1\n  )\n}\n\nconst endingEmojiZWJ = /\\p{ExtPict}[\\p{Gr_Ext}\\p{EMod}]*\\u200D$/u\nconst endsWithEmojiZWJ = (str: string): boolean => {\n  return str.search(endingEmojiZWJ) !== -1\n}\n\nconst endingRIs = /\\p{RI}+$/gu\nconst endsWithOddNumberOfRIs = (str: string): boolean => {\n  const match = str.match(endingRIs)\n  if (match === null) {\n    return false\n  } else {\n    // A RI is represented by a surrogate pair.\n    const numRIs = match[0].length / 2\n    return numRIs % 2 === 1\n  }\n}\n","import { Editor, Location, Node, Path, Range, Transforms } from '../../index'\nimport { TextUnit } from '../../types/types'\nimport { getDefaultInsertLocation } from '../../utils'\n\nexport interface TextDeleteOptions {\n  at?: Location\n  distance?: number\n  unit?: TextUnit\n  reverse?: boolean\n  hanging?: boolean\n  voids?: boolean\n}\n\nexport interface TextInsertFragmentOptions {\n  at?: Location\n  hanging?: boolean\n  voids?: boolean\n  batchDirty?: boolean\n}\n\nexport interface TextInsertTextOptions {\n  at?: Location\n  voids?: boolean\n}\n\nexport interface TextTransforms {\n  /**\n   * Delete content in the editor.\n   */\n  delete: (editor: Editor, options?: TextDeleteOptions) => void\n\n  /**\n   * Insert a fragment in the editor\n   * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.\n   */\n  insertFragment: (\n    editor: Editor,\n    fragment: Node[],\n    options?: TextInsertFragmentOptions\n  ) => void\n\n  /**\n   * Insert a string of text in the editor\n   * at the specified location or (if not defined) the current selection or (if not defined) the end of the document.\n   */\n  insertText: (\n    editor: Editor,\n    text: string,\n    options?: TextInsertTextOptions\n  ) => void\n}\n\n// eslint-disable-next-line no-redeclare\nexport const TextTransforms: TextTransforms = {\n  delete(editor, options) {\n    editor.delete(options)\n  },\n  insertFragment(editor, fragment, options) {\n    editor.insertFragment(fragment, options)\n  },\n  insertText(\n    editor: Editor,\n    text: string,\n    options: TextInsertTextOptions = {}\n  ): void {\n    Editor.withoutNormalizing(editor, () => {\n      const { voids = false } = options\n      let { at = getDefaultInsertLocation(editor) } = options\n\n      if (Path.isPath(at)) {\n        at = Editor.range(editor, at)\n      }\n\n      if (Range.isRange(at)) {\n        if (Range.isCollapsed(at)) {\n          at = at.anchor\n        } else {\n          const end = Range.end(at)\n          if (!voids && Editor.void(editor, { at: end })) {\n            return\n          }\n          const start = Range.start(at)\n          const startRef = Editor.pointRef(editor, start)\n          const endRef = Editor.pointRef(editor, end)\n          Transforms.delete(editor, { at, voids })\n          const startPoint = startRef.unref()\n          const endPoint = endRef.unref()\n\n          at = startPoint || endPoint!\n          Transforms.setSelection(editor, { anchor: at, focus: at })\n        }\n      }\n\n      if (\n        (!voids && Editor.void(editor, { at })) ||\n        Editor.elementReadOnly(editor, { at })\n      ) {\n        return\n      }\n\n      const { path, offset } = at\n      if (text.length > 0)\n        editor.apply({ type: 'insert_text', path, offset, text })\n    })\n  },\n}\n","import { GeneralTransforms } from './general'\nimport { NodeTransforms } from './node'\nimport { SelectionTransforms } from './selection'\nimport { TextTransforms } from './text'\n\nexport const Transforms: GeneralTransforms &\n  NodeTransforms &\n  SelectionTransforms &\n  TextTransforms = {\n  ...GeneralTransforms,\n  ...NodeTransforms,\n  ...SelectionTransforms,\n  ...TextTransforms,\n}\n","// perf\n\nimport { Editor } from '../interfaces/editor'\n\nconst BATCHING_DIRTY_PATHS: WeakMap<Editor, boolean> = new WeakMap()\n\nexport const isBatchingDirtyPaths = (editor: Editor) => {\n  return BATCHING_DIRTY_PATHS.get(editor) || false\n}\n\nexport const batchDirtyPaths = (\n  editor: Editor,\n  fn: () => void,\n  update: () => void\n) => {\n  const value = BATCHING_DIRTY_PATHS.get(editor) || false\n  BATCHING_DIRTY_PATHS.set(editor, true)\n  try {\n    fn()\n    update()\n  } finally {\n    BATCHING_DIRTY_PATHS.set(editor, value)\n  }\n}\n","import { DIRTY_PATH_KEYS, DIRTY_PATHS } from '../utils/weak-maps'\nimport { Path } from '../interfaces/path'\nimport { Editor } from '../interfaces/editor'\n\n/**\n * update editor dirty paths\n *\n * @param newDirtyPaths: Path[]; new dirty paths\n * @param transform: (p: Path) => Path | null; how to transform existing dirty paths\n */\nexport function updateDirtyPaths(\n  editor: Editor,\n  newDirtyPaths: Path[],\n  transform?: (p: Path) => Path | null\n) {\n  const oldDirtyPaths = DIRTY_PATHS.get(editor) || []\n  const oldDirtyPathKeys = DIRTY_PATH_KEYS.get(editor) || new Set()\n  let dirtyPaths: Path[]\n  let dirtyPathKeys: Set<string>\n\n  const add = (path: Path | null) => {\n    if (path) {\n      const key = path.join(',')\n\n      if (!dirtyPathKeys.has(key)) {\n        dirtyPathKeys.add(key)\n        dirtyPaths.push(path)\n      }\n    }\n  }\n\n  if (transform) {\n    dirtyPaths = []\n    dirtyPathKeys = new Set()\n    for (const path of oldDirtyPaths) {\n      const newPath = transform(path)\n      add(newPath)\n    }\n  } else {\n    dirtyPaths = oldDirtyPaths\n    dirtyPathKeys = oldDirtyPathKeys\n  }\n\n  for (const path of newDirtyPaths) {\n    add(path)\n  }\n\n  DIRTY_PATHS.set(editor, dirtyPaths)\n  DIRTY_PATH_KEYS.set(editor, dirtyPathKeys)\n}\n","import { PathRef } from '../interfaces/path-ref'\nimport { PointRef } from '../interfaces/point-ref'\nimport { RangeRef } from '../interfaces/range-ref'\nimport { FLUSHING } from '../utils/weak-maps'\nimport { Path } from '../interfaces/path'\nimport { Transforms } from '../interfaces/transforms'\nimport { WithEditorFirstArg } from '../utils/types'\nimport { Editor } from '../interfaces/editor'\nimport { isBatchingDirtyPaths } from './batch-dirty-paths'\nimport { updateDirtyPaths } from './update-dirty-paths'\n\nexport const apply: WithEditorFirstArg<Editor['apply']> = (editor, op) => {\n  for (const ref of Editor.pathRefs(editor)) {\n    PathRef.transform(ref, op)\n  }\n\n  for (const ref of Editor.pointRefs(editor)) {\n    PointRef.transform(ref, op)\n  }\n\n  for (const ref of Editor.rangeRefs(editor)) {\n    RangeRef.transform(ref, op)\n  }\n\n  // update dirty paths\n  if (!isBatchingDirtyPaths(editor)) {\n    const transform = Path.operationCanTransformPath(op)\n      ? (p: Path) => Path.transform(p, op)\n      : undefined\n    updateDirtyPaths(editor, editor.getDirtyPaths(op), transform)\n  }\n\n  Transforms.transform(editor, op)\n  editor.operations.push(op)\n  Editor.normalize(editor, {\n    operation: op,\n  })\n\n  // Clear any formats applied to the cursor if the selection changes.\n  if (op.type === 'set_selection') {\n    editor.marks = null\n  }\n\n  if (!FLUSHING.get(editor)) {\n    FLUSHING.set(editor, true)\n\n    Promise.resolve().then(() => {\n      FLUSHING.set(editor, false)\n      editor.onChange({ operation: op })\n      editor.operations = []\n    })\n  }\n}\n","import { WithEditorFirstArg } from '../utils/types'\nimport { Path } from '../interfaces/path'\nimport { Text } from '../interfaces/text'\nimport { Node } from '../interfaces/node'\nimport { Editor } from '../interfaces/editor'\n\n/**\n * Get the \"dirty\" paths generated from an operation.\n */\nexport const getDirtyPaths: WithEditorFirstArg<Editor['getDirtyPaths']> = (\n  editor,\n  op\n) => {\n  switch (op.type) {\n    case 'insert_text':\n    case 'remove_text':\n    case 'set_node': {\n      const { path } = op\n      return Path.levels(path)\n    }\n\n    case 'insert_node': {\n      const { node, path } = op\n      const levels = Path.levels(path)\n      const descendants = Text.isText(node)\n        ? []\n        : Array.from(Node.nodes(node), ([, p]) => path.concat(p))\n\n      return [...levels, ...descendants]\n    }\n\n    case 'merge_node': {\n      const { path } = op\n      const ancestors = Path.ancestors(path)\n      const previousPath = Path.previous(path)\n      return [...ancestors, previousPath]\n    }\n\n    case 'move_node': {\n      const { path, newPath } = op\n\n      if (Path.equals(path, newPath)) {\n        return []\n      }\n\n      const oldAncestors: Path[] = []\n      const newAncestors: Path[] = []\n\n      for (const ancestor of Path.ancestors(path)) {\n        const p = Path.transform(ancestor, op)\n        oldAncestors.push(p!)\n      }\n\n      for (const ancestor of Path.ancestors(newPath)) {\n        const p = Path.transform(ancestor, op)\n        newAncestors.push(p!)\n      }\n\n      const newParent = newAncestors[newAncestors.length - 1]\n      const newIndex = newPath[newPath.length - 1]\n      const resultPath = newParent.concat(newIndex)\n\n      return [...oldAncestors, ...newAncestors, resultPath]\n    }\n\n    case 'remove_node': {\n      const { path } = op\n      const ancestors = Path.ancestors(path)\n      return [...ancestors]\n    }\n\n    case 'split_node': {\n      const { path } = op\n      const levels = Path.levels(path)\n      const nextPath = Path.next(path)\n      return [...levels, nextPath]\n    }\n\n    default: {\n      return []\n    }\n  }\n}\n","import { Editor, Node } from '../interfaces'\nimport { WithEditorFirstArg } from '../utils'\n\nexport const getFragment: WithEditorFirstArg<\n  Editor['getFragment']\n> = editor => {\n  const { selection } = editor\n\n  if (selection) {\n    return Node.fragment(editor, selection)\n  }\n  return []\n}\n","import { WithEditorFirstArg } from '../utils/types'\nimport { Text } from '../interfaces/text'\nimport { Element } from '../interfaces/element'\nimport { Transforms } from '../interfaces/transforms'\nimport { Descendant, Node } from '../interfaces/node'\nimport { Editor } from '../interfaces/editor'\n\nexport const normalizeNode: WithEditorFirstArg<Editor['normalizeNode']> = (\n  editor,\n  entry\n) => {\n  const [node, path] = entry\n\n  // There are no core normalizations for text nodes.\n  if (Text.isText(node)) {\n    return\n  }\n\n  // Ensure that block and inline nodes have at least one text child.\n  if (Element.isElement(node) && node.children.length === 0) {\n    const child = { text: '' }\n    Transforms.insertNodes(editor, child, {\n      at: path.concat(0),\n      voids: true,\n    })\n    return\n  }\n\n  // Determine whether the node should have block or inline children.\n  const shouldHaveInlines = Editor.isEditor(node)\n    ? false\n    : Element.isElement(node) &&\n      (editor.isInline(node) ||\n        node.children.length === 0 ||\n        Text.isText(node.children[0]) ||\n        editor.isInline(node.children[0]))\n\n  // Since we'll be applying operations while iterating, keep track of an\n  // index that accounts for any added/removed nodes.\n  let n = 0\n\n  for (let i = 0; i < node.children.length; i++, n++) {\n    const currentNode = Node.get(editor, path)\n    if (Text.isText(currentNode)) continue\n    const child = currentNode.children[n] as Descendant\n    const prev = currentNode.children[n - 1] as Descendant\n    const isLast = i === node.children.length - 1\n    const isInlineOrText =\n      Text.isText(child) || (Element.isElement(child) && editor.isInline(child))\n\n    // Only allow block nodes in the top-level children and parent blocks\n    // that only contain block nodes. Similarly, only allow inline nodes in\n    // other inline nodes, or parent blocks that only contain inlines and\n    // text.\n    if (isInlineOrText !== shouldHaveInlines) {\n      if (isInlineOrText) {\n        Transforms.removeNodes(editor, { at: path.concat(n), voids: true })\n      } else {\n        Transforms.unwrapNodes(editor, { at: path.concat(n), voids: true })\n      }\n      n--\n    } else if (Element.isElement(child)) {\n      // Ensure that inline nodes are surrounded by text nodes.\n      if (editor.isInline(child)) {\n        if (prev == null || !Text.isText(prev)) {\n          const newChild = { text: '' }\n          Transforms.insertNodes(editor, newChild, {\n            at: path.concat(n),\n            voids: true,\n          })\n          n++\n        } else if (isLast) {\n          const newChild = { text: '' }\n          Transforms.insertNodes(editor, newChild, {\n            at: path.concat(n + 1),\n            voids: true,\n          })\n          n++\n        }\n      }\n    } else {\n      // If the child is not a text node, and doesn't have a `children` field,\n      // then we have an invalid node that will upset slate.\n      //\n      // eg: `{ type: 'some_node' }`.\n      //\n      // To prevent slate from breaking, we can add the `children` field,\n      // and now that it is valid, we can to many more operations easily,\n      // such as extend normalizers to fix erronous structure.\n      if (!Text.isText(child) && !('children' in child)) {\n        const elementChild = child as Element\n        elementChild.children = []\n      }\n\n      // Merge adjacent text nodes that are empty or match.\n      if (prev != null && Text.isText(prev)) {\n        if (Text.equals(child, prev, { loose: true })) {\n          Transforms.mergeNodes(editor, { at: path.concat(n), voids: true })\n          n--\n        } else if (prev.text === '') {\n          Transforms.removeNodes(editor, {\n            at: path.concat(n - 1),\n            voids: true,\n          })\n          n--\n        } else if (child.text === '') {\n          Transforms.removeNodes(editor, {\n            at: path.concat(n),\n            voids: true,\n          })\n          n--\n        }\n      }\n    }\n  }\n}\n","import { WithEditorFirstArg } from '../utils/types'\nimport { Editor } from '../interfaces/editor'\n\nexport const shouldNormalize: WithEditorFirstArg<Editor['shouldNormalize']> = (\n  editor,\n  { iteration, initialDirtyPathsLength }\n) => {\n  const maxIterations = initialDirtyPathsLength * 42 // HACK: better way?\n\n  if (iteration > maxIterations) {\n    throw new Error(\n      `Could not completely normalize the editor after ${maxIterations} iterations! This is usually due to incorrect normalization logic that leaves a node in an invalid state.`\n    )\n  }\n\n  return true\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Text } from '../interfaces/text'\nimport { Range } from '../interfaces/range'\nimport { Path } from '../interfaces/path'\n\nexport const above: EditorInterface['above'] = (editor, options = {}) => {\n  const {\n    voids = false,\n    mode = 'lowest',\n    at = editor.selection,\n    match,\n  } = options\n\n  if (!at) {\n    return\n  }\n\n  const path = Editor.path(editor, at)\n  const reverse = mode === 'lowest'\n\n  for (const [n, p] of Editor.levels(editor, {\n    at: path,\n    voids,\n    match,\n    reverse,\n  })) {\n    if (Text.isText(n)) continue\n    if (Range.isRange(at)) {\n      if (\n        Path.isAncestor(p, at.anchor.path) &&\n        Path.isAncestor(p, at.focus.path)\n      ) {\n        return [n, p]\n      }\n    } else {\n      if (!Path.equals(path, p)) {\n        return [n, p]\n      }\n    }\n  }\n}\n","import { Node } from '../interfaces/node'\nimport { Path } from '../interfaces/path'\nimport { Text } from '../interfaces/text'\nimport { Range } from '../interfaces/range'\nimport { Transforms } from '../interfaces/transforms'\nimport { FLUSHING } from '../utils/weak-maps'\nimport { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const addMark: EditorInterface['addMark'] = (editor, key, value) => {\n  const { selection } = editor\n\n  if (selection) {\n    const match = (node: Node, path: Path) => {\n      if (!Text.isText(node)) {\n        return false // marks can only be applied to text\n      }\n      const [parentNode, parentPath] = Editor.parent(editor, path)\n      return !editor.isVoid(parentNode) || editor.markableVoid(parentNode)\n    }\n    const expandedSelection = Range.isExpanded(selection)\n    let markAcceptingVoidSelected = false\n    if (!expandedSelection) {\n      const [selectedNode, selectedPath] = Editor.node(editor, selection)\n      if (selectedNode && match(selectedNode, selectedPath)) {\n        const [parentNode] = Editor.parent(editor, selectedPath)\n        markAcceptingVoidSelected =\n          parentNode && editor.markableVoid(parentNode)\n      }\n    }\n    if (expandedSelection || markAcceptingVoidSelected) {\n      Transforms.setNodes(\n        editor,\n        { [key]: value },\n        {\n          match,\n          split: true,\n          voids: true,\n        }\n      )\n    } else {\n      const marks = {\n        ...(Editor.marks(editor) || {}),\n        [key]: value,\n      }\n\n      editor.marks = marks\n      if (!FLUSHING.get(editor)) {\n        editor.onChange()\n      }\n    }\n  }\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const after: EditorInterface['after'] = (editor, at, options = {}) => {\n  const anchor = Editor.point(editor, at, { edge: 'end' })\n  const focus = Editor.end(editor, [])\n  const range = { anchor, focus }\n  const { distance = 1 } = options\n  let d = 0\n  let target\n\n  for (const p of Editor.positions(editor, {\n    ...options,\n    at: range,\n  })) {\n    if (d > distance) {\n      break\n    }\n\n    if (d !== 0) {\n      target = p\n    }\n\n    d++\n  }\n\n  return target\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const before: EditorInterface['before'] = (editor, at, options = {}) => {\n  const anchor = Editor.start(editor, [])\n  const focus = Editor.point(editor, at, { edge: 'start' })\n  const range = { anchor, focus }\n  const { distance = 1 } = options\n  let d = 0\n  let target\n\n  for (const p of Editor.positions(editor, {\n    ...options,\n    at: range,\n    reverse: true,\n  })) {\n    if (d > distance) {\n      break\n    }\n\n    if (d !== 0) {\n      target = p\n    }\n\n    d++\n  }\n\n  return target\n}\n","import { Editor } from '../interfaces/editor'\nimport { Transforms } from '../interfaces/transforms'\nimport { Range } from '../interfaces/range'\nimport { WithEditorFirstArg } from '../utils/types'\n\nexport const deleteBackward: WithEditorFirstArg<Editor['deleteBackward']> = (\n  editor,\n  unit\n) => {\n  const { selection } = editor\n\n  if (selection && Range.isCollapsed(selection)) {\n    Transforms.delete(editor, { unit, reverse: true })\n  }\n}\n","import { Editor } from '../interfaces/editor'\nimport { Transforms } from '../interfaces/transforms'\nimport { Range } from '../interfaces/range'\nimport { WithEditorFirstArg } from '../utils/types'\n\nexport const deleteForward: WithEditorFirstArg<Editor['deleteForward']> = (\n  editor,\n  unit\n) => {\n  const { selection } = editor\n\n  if (selection && Range.isCollapsed(selection)) {\n    Transforms.delete(editor, { unit })\n  }\n}\n","import { Range } from '../interfaces/range'\nimport { Transforms } from '../interfaces/transforms'\nimport { EditorInterface } from '../interfaces/editor'\n\nexport const deleteFragment: EditorInterface['deleteFragment'] = (\n  editor,\n  { direction = 'forward' } = {}\n) => {\n  const { selection } = editor\n\n  if (selection && Range.isExpanded(selection)) {\n    Transforms.delete(editor, { reverse: direction === 'backward' })\n  }\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const edges: EditorInterface['edges'] = (editor, at) => {\n  return [Editor.start(editor, at), Editor.end(editor, at)]\n}\n","import { Element } from '../interfaces/element'\nimport { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const elementReadOnly: EditorInterface['elementReadOnly'] = (\n  editor,\n  options = {}\n) => {\n  return Editor.above(editor, {\n    ...options,\n    match: n => Element.isElement(n) && Editor.isElementReadOnly(editor, n),\n  })\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const end: EditorInterface['end'] = (editor, at) => {\n  return Editor.point(editor, at, { edge: 'end' })\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const first: EditorInterface['first'] = (editor, at) => {\n  const path = Editor.path(editor, at, { edge: 'start' })\n  return Editor.node(editor, path)\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Node } from '../interfaces/node'\n\nexport const fragment: EditorInterface['fragment'] = (editor, at) => {\n  const range = Editor.range(editor, at)\n  return Node.fragment(editor, range)\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Element } from '../interfaces/element'\n\nexport const getVoid: EditorInterface['void'] = (editor, options = {}) => {\n  return Editor.above(editor, {\n    ...options,\n    match: n => Element.isElement(n) && Editor.isVoid(editor, n),\n  })\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Element } from '../interfaces/element'\n\nexport const hasBlocks: EditorInterface['hasBlocks'] = (editor, element) => {\n  return element.children.some(\n    n => Element.isElement(n) && Editor.isBlock(editor, n)\n  )\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Text } from '../interfaces/text'\n\nexport const hasInlines: EditorInterface['hasInlines'] = (editor, element) => {\n  return element.children.some(\n    n => Text.isText(n) || Editor.isInline(editor, n)\n  )\n}\n","import { EditorInterface } from '../interfaces/editor'\nimport { Node } from '../interfaces/node'\n\nexport const hasPath: EditorInterface['hasPath'] = (editor, path) => {\n  return Node.has(editor, path)\n}\n","import { EditorInterface } from '../interfaces/editor'\nimport { Text } from '../interfaces/text'\n\nexport const hasTexts: EditorInterface['hasTexts'] = (editor, element) => {\n  return element.children.every(n => Text.isText(n))\n}\n","import { Transforms } from '../interfaces/transforms'\nimport { EditorInterface } from '../interfaces/editor'\n\nexport const insertBreak: EditorInterface['insertBreak'] = editor => {\n  Transforms.splitNodes(editor, { always: true })\n}\n","import { Transforms } from '../interfaces/transforms'\nimport { EditorInterface } from '../interfaces/editor'\n\nexport const insertNode: EditorInterface['insertNode'] = (\n  editor,\n  node,\n  options\n) => {\n  Transforms.insertNodes(editor, node, options)\n}\n","import { Transforms } from '../interfaces/transforms'\nimport { EditorInterface } from '../interfaces/editor'\n\nexport const insertSoftBreak: EditorInterface['insertSoftBreak'] = editor => {\n  Transforms.splitNodes(editor, { always: true })\n}\n","import { Transforms } from '../interfaces/transforms'\nimport { EditorInterface } from '../interfaces/editor'\n\nexport const insertText: EditorInterface['insertText'] = (\n  editor,\n  text,\n  options = {}\n) => {\n  const { selection, marks } = editor\n\n  if (selection) {\n    if (marks) {\n      const node = { text, ...marks }\n      Transforms.insertNodes(editor, node, {\n        at: options.at,\n        voids: options.voids,\n      })\n    } else {\n      Transforms.insertText(editor, text, options)\n    }\n\n    editor.marks = null\n  }\n}\n","import { EditorInterface } from '../interfaces/editor'\n\nexport const isBlock: EditorInterface['isBlock'] = (editor, value) => {\n  return !editor.isInline(value)\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const isEdge: EditorInterface['isEdge'] = (editor, point, at) => {\n  return Editor.isStart(editor, point, at) || Editor.isEnd(editor, point, at)\n}\n","import { EditorInterface } from '../interfaces/editor'\nimport { Text } from '../interfaces/text'\n\nexport const isEmpty: EditorInterface['isEmpty'] = (editor, element) => {\n  const { children } = element\n  const [first] = children\n  return (\n    children.length === 0 ||\n    (children.length === 1 &&\n      Text.isText(first) &&\n      first.text === '' &&\n      !editor.isVoid(element))\n  )\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Point } from '../interfaces/point'\n\nexport const isEnd: EditorInterface['isEnd'] = (editor, point, at) => {\n  const end = Editor.end(editor, at)\n  return Point.equals(point, end)\n}\n","import { EditorInterface } from '../interfaces/editor'\nimport { NORMALIZING } from '../utils/weak-maps'\n\nexport const isNormalizing: EditorInterface['isNormalizing'] = editor => {\n  const isNormalizing = NORMALIZING.get(editor)\n  return isNormalizing === undefined ? true : isNormalizing\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Point } from '../interfaces/point'\n\nexport const isStart: EditorInterface['isStart'] = (editor, point, at) => {\n  // PERF: If the offset isn't `0` we know it's not the start.\n  if (point.offset !== 0) {\n    return false\n  }\n\n  const start = Editor.start(editor, at)\n  return Point.equals(point, start)\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const last: EditorInterface['last'] = (editor, at) => {\n  const path = Editor.path(editor, at, { edge: 'end' })\n  return Editor.node(editor, path)\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Node } from '../interfaces/node'\n\nexport const leaf: EditorInterface['leaf'] = (editor, at, options = {}) => {\n  const path = Editor.path(editor, at, options)\n  const node = Node.leaf(editor, path)\n  return [node, path]\n}\n","import { Node, NodeEntry } from '../interfaces/node'\nimport { Editor, EditorLevelsOptions } from '../interfaces/editor'\nimport { Element } from '../interfaces/element'\n\nexport function* levels<T extends Node>(\n  editor: Editor,\n  options: EditorLevelsOptions<T> = {}\n): Generator<NodeEntry<T>, void, undefined> {\n  const { at = editor.selection, reverse = false, voids = false } = options\n  let { match } = options\n\n  if (match == null) {\n    match = () => true\n  }\n\n  if (!at) {\n    return\n  }\n\n  const levels: NodeEntry<T>[] = []\n  const path = Editor.path(editor, at)\n\n  for (const [n, p] of Node.levels(editor, path)) {\n    if (!match(n, p)) {\n      continue\n    }\n\n    levels.push([n, p] as NodeEntry<T>)\n\n    if (!voids && Element.isElement(n) && Editor.isVoid(editor, n)) {\n      break\n    }\n  }\n\n  if (reverse) {\n    levels.reverse()\n  }\n\n  yield* levels\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { NodeEntry } from '../interfaces/node'\nimport { Range } from '../interfaces/range'\nimport { Path } from '../interfaces/path'\nimport { Text } from '../interfaces/text'\nimport { Element } from '../interfaces/element'\nimport { Point } from '../interfaces'\n\nexport const marks: EditorInterface['marks'] = (editor, options = {}) => {\n  const { marks, selection } = editor\n\n  if (!selection) {\n    return null\n  }\n  let { anchor, focus } = selection\n\n  if (marks) {\n    return marks\n  }\n\n  if (Range.isExpanded(selection)) {\n    const isBackward = Range.isBackward(selection)\n    if (isBackward) {\n      ;[focus, anchor] = [anchor, focus]\n    }\n    /**\n     * COMPAT: Make sure hanging ranges (caused by double clicking in Firefox)\n     * do not adversely affect the returned marks.\n     */\n    const isEnd = Editor.isEnd(editor, anchor, anchor.path)\n    if (isEnd) {\n      const after = Editor.after(editor, anchor as Point)\n      if (after) {\n        anchor = after\n      }\n    }\n\n    const [match] = Editor.nodes(editor, {\n      match: Text.isText,\n      at: {\n        anchor,\n        focus,\n      },\n    })\n\n    if (match) {\n      const [node] = match as NodeEntry<Text>\n      const { text, ...rest } = node\n      return rest\n    } else {\n      return {}\n    }\n  }\n\n  const { path } = anchor\n\n  let [node] = Editor.leaf(editor, path)\n\n  if (anchor.offset === 0) {\n    const prev = Editor.previous(editor, { at: path, match: Text.isText })\n    const markedVoid = Editor.above(editor, {\n      match: n =>\n        Element.isElement(n) &&\n        Editor.isVoid(editor, n) &&\n        editor.markableVoid(n),\n    })\n    if (!markedVoid) {\n      const block = Editor.above(editor, {\n        match: n => Element.isElement(n) && Editor.isBlock(editor, n),\n      })\n\n      if (prev && block) {\n        const [prevNode, prevPath] = prev\n        const [, blockPath] = block\n\n        if (Path.isAncestor(blockPath, prevPath)) {\n          node = prevNode as Text\n        }\n      }\n    }\n  }\n\n  const { text, ...rest } = node\n  return rest\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Span } from '../interfaces/location'\nimport { Path } from '../interfaces/path'\n\nexport const next: EditorInterface['next'] = (editor, options = {}) => {\n  const { mode = 'lowest', voids = false } = options\n  let { match, at = editor.selection } = options\n\n  if (!at) {\n    return\n  }\n\n  const pointAfterLocation = Editor.after(editor, at, { voids })\n\n  if (!pointAfterLocation) return\n\n  const [, to] = Editor.last(editor, [])\n\n  const span: Span = [pointAfterLocation.path, to]\n\n  if (Path.isPath(at) && at.length === 0) {\n    throw new Error(`Cannot get the next node from the root node!`)\n  }\n\n  if (match == null) {\n    if (Path.isPath(at)) {\n      const [parent] = Editor.parent(editor, at)\n      match = n => parent.children.includes(n)\n    } else {\n      match = () => true\n    }\n  }\n\n  const [next] = Editor.nodes(editor, { at: span, match, mode, voids })\n  return next\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Node } from '../interfaces/node'\n\nexport const node: EditorInterface['node'] = (editor, at, options = {}) => {\n  const path = Editor.path(editor, at, options)\n  const node = Node.get(editor, path)\n  return [node, path]\n}\n","import { Node, NodeEntry } from '../interfaces/node'\nimport { Editor, EditorNodesOptions } from '../interfaces/editor'\nimport { Span } from '../interfaces/location'\nimport { Element } from '../interfaces/element'\nimport { Path } from '../interfaces/path'\nimport { Text } from '../interfaces/text'\n\nexport function* nodes<T extends Node>(\n  editor: Editor,\n  options: EditorNodesOptions<T> = {}\n): Generator<NodeEntry<T>, void, undefined> {\n  const {\n    at = editor.selection,\n    mode = 'all',\n    universal = false,\n    reverse = false,\n    voids = false,\n    pass,\n    ignoreNonSelectable = false,\n  } = options\n  let { match } = options\n\n  if (!match) {\n    match = () => true\n  }\n\n  if (!at) {\n    return\n  }\n\n  let from\n  let to\n\n  if (Span.isSpan(at)) {\n    from = at[0]\n    to = at[1]\n  } else {\n    const first = Editor.path(editor, at, { edge: 'start' })\n    const last = Editor.path(editor, at, { edge: 'end' })\n    from = reverse ? last : first\n    to = reverse ? first : last\n  }\n\n  const nodeEntries = Node.nodes(editor, {\n    reverse,\n    from,\n    to,\n    pass: ([node, path]) => {\n      if (pass && pass([node, path])) return true\n      if (!Element.isElement(node)) return false\n      if (\n        !voids &&\n        (Editor.isVoid(editor, node) || Editor.isElementReadOnly(editor, node))\n      )\n        return true\n      if (ignoreNonSelectable && !Editor.isSelectable(editor, node)) return true\n      return false\n    },\n  })\n\n  const matches: NodeEntry<T>[] = []\n  let hit: NodeEntry<T> | undefined\n\n  for (const [node, path] of nodeEntries) {\n    if (\n      ignoreNonSelectable &&\n      Element.isElement(node) &&\n      !Editor.isSelectable(editor, node)\n    ) {\n      continue\n    }\n\n    const isLower = hit && Path.compare(path, hit[1]) === 0\n\n    // In highest mode any node lower than the last hit is not a match.\n    if (mode === 'highest' && isLower) {\n      continue\n    }\n\n    if (!match(node, path)) {\n      // If we've arrived at a leaf text node that is not lower than the last\n      // hit, then we've found a branch that doesn't include a match, which\n      // means the match is not universal.\n      if (universal && !isLower && Text.isText(node)) {\n        return\n      } else {\n        continue\n      }\n    }\n\n    // If there's a match and it's lower than the last, update the hit.\n    if (mode === 'lowest' && isLower) {\n      hit = [node, path] as NodeEntry<T>\n      continue\n    }\n\n    // In lowest mode we emit the last hit, once it's guaranteed lowest.\n    const emit: NodeEntry<T> | undefined =\n      mode === 'lowest' ? hit : ([node, path] as NodeEntry<T>)\n\n    if (emit) {\n      if (universal) {\n        matches.push(emit)\n      } else {\n        yield emit\n      }\n    }\n\n    hit = [node, path] as NodeEntry<T>\n  }\n\n  // Since lowest is always emitting one behind, catch up at the end.\n  if (mode === 'lowest' && hit) {\n    if (universal) {\n      matches.push(hit)\n    } else {\n      yield hit\n    }\n  }\n\n  // Universal defers to ensure that the match occurs in every branch, so we\n  // yield all of the matches after iterating.\n  if (universal) {\n    yield* matches\n  }\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { DIRTY_PATH_KEYS, DIRTY_PATHS } from '../utils/weak-maps'\nimport { Path } from '../interfaces/path'\nimport { Node } from '../interfaces/node'\nimport { Element } from '../interfaces/element'\n\nexport const normalize: EditorInterface['normalize'] = (\n  editor,\n  options = {}\n) => {\n  const { force = false, operation } = options\n  const getDirtyPaths = (editor: Editor) => {\n    return DIRTY_PATHS.get(editor) || []\n  }\n\n  const getDirtyPathKeys = (editor: Editor) => {\n    return DIRTY_PATH_KEYS.get(editor) || new Set()\n  }\n\n  const popDirtyPath = (editor: Editor): Path => {\n    const path = getDirtyPaths(editor).pop()!\n    const key = path.join(',')\n    getDirtyPathKeys(editor).delete(key)\n    return path\n  }\n\n  if (!Editor.isNormalizing(editor)) {\n    return\n  }\n\n  if (force) {\n    const allPaths = Array.from(Node.nodes(editor), ([, p]) => p)\n    const allPathKeys = new Set(allPaths.map(p => p.join(',')))\n    DIRTY_PATHS.set(editor, allPaths)\n    DIRTY_PATH_KEYS.set(editor, allPathKeys)\n  }\n\n  if (getDirtyPaths(editor).length === 0) {\n    return\n  }\n\n  Editor.withoutNormalizing(editor, () => {\n    /*\n      Fix dirty elements with no children.\n      editor.normalizeNode() does fix this, but some normalization fixes also require it to work.\n      Running an initial pass avoids the catch-22 race condition.\n    */\n    for (const dirtyPath of getDirtyPaths(editor)) {\n      if (Node.has(editor, dirtyPath)) {\n        const entry = Editor.node(editor, dirtyPath)\n        const [node, _] = entry\n\n        /*\n          The default normalizer inserts an empty text node in this scenario, but it can be customised.\n          So there is some risk here.\n\n          As long as the normalizer only inserts child nodes for this case it is safe to do in any order;\n          by definition adding children to an empty node can't cause other paths to change.\n        */\n        if (Element.isElement(node) && node.children.length === 0) {\n          editor.normalizeNode(entry, { operation })\n        }\n      }\n    }\n\n    let dirtyPaths = getDirtyPaths(editor)\n    const initialDirtyPathsLength = dirtyPaths.length\n    let iteration = 0\n\n    while (dirtyPaths.length !== 0) {\n      if (\n        !editor.shouldNormalize({\n          dirtyPaths,\n          iteration,\n          initialDirtyPathsLength,\n          operation,\n        })\n      ) {\n        return\n      }\n\n      const dirtyPath = popDirtyPath(editor)\n\n      // If the node doesn't exist in the tree, it does not need to be normalized.\n      if (Node.has(editor, dirtyPath)) {\n        const entry = Editor.node(editor, dirtyPath)\n        editor.normalizeNode(entry, { operation })\n      }\n      iteration++\n      dirtyPaths = getDirtyPaths(editor)\n    }\n  })\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { Ancestor, NodeEntry } from '../interfaces/node'\n\nexport const parent: EditorInterface['parent'] = (editor, at, options = {}) => {\n  const path = Editor.path(editor, at, options)\n  const parentPath = Path.parent(path)\n  const entry = Editor.node(editor, parentPath)\n  return entry as NodeEntry<Ancestor>\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { PathRef } from '../interfaces/path-ref'\n\nexport const pathRef: EditorInterface['pathRef'] = (\n  editor,\n  path,\n  options = {}\n) => {\n  const { affinity = 'forward' } = options\n  const ref: PathRef = {\n    current: path,\n    affinity,\n    unref() {\n      const { current } = ref\n      const pathRefs = Editor.pathRefs(editor)\n      pathRefs.delete(ref)\n      ref.current = null\n      return current\n    },\n  }\n\n  const refs = Editor.pathRefs(editor)\n  refs.add(ref)\n  return ref\n}\n","import { EditorInterface } from '../interfaces/editor'\nimport { PATH_REFS } from '../utils/weak-maps'\n\nexport const pathRefs: EditorInterface['pathRefs'] = editor => {\n  let refs = PATH_REFS.get(editor)\n\n  if (!refs) {\n    refs = new Set()\n    PATH_REFS.set(editor, refs)\n  }\n\n  return refs\n}\n","import { EditorInterface, Node, Path, Point, Range } from '../interfaces'\n\nexport const path: EditorInterface['path'] = (editor, at, options = {}) => {\n  const { depth, edge } = options\n\n  if (Path.isPath(at)) {\n    if (edge === 'start') {\n      const [, firstPath] = Node.first(editor, at)\n      at = firstPath\n    } else if (edge === 'end') {\n      const [, lastPath] = Node.last(editor, at)\n      at = lastPath\n    }\n  }\n\n  if (Range.isRange(at)) {\n    if (edge === 'start') {\n      at = Range.start(at)\n    } else if (edge === 'end') {\n      at = Range.end(at)\n    } else {\n      at = Path.common(at.anchor.path, at.focus.path)\n    }\n  }\n\n  if (Point.isPoint(at)) {\n    at = at.path\n  }\n\n  if (depth != null) {\n    at = at.slice(0, depth)\n  }\n\n  return at\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { PointRef } from '../interfaces/point-ref'\n\nexport const pointRef: EditorInterface['pointRef'] = (\n  editor,\n  point,\n  options = {}\n) => {\n  const { affinity = 'forward' } = options\n  const ref: PointRef = {\n    current: point,\n    affinity,\n    unref() {\n      const { current } = ref\n      const pointRefs = Editor.pointRefs(editor)\n      pointRefs.delete(ref)\n      ref.current = null\n      return current\n    },\n  }\n\n  const refs = Editor.pointRefs(editor)\n  refs.add(ref)\n  return ref\n}\n","import { EditorInterface } from '../interfaces/editor'\nimport { POINT_REFS } from '../utils/weak-maps'\n\nexport const pointRefs: EditorInterface['pointRefs'] = editor => {\n  let refs = POINT_REFS.get(editor)\n\n  if (!refs) {\n    refs = new Set()\n    POINT_REFS.set(editor, refs)\n  }\n\n  return refs\n}\n","import { EditorInterface } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { Node } from '../interfaces/node'\nimport { Text } from '../interfaces/text'\nimport { Range } from '../interfaces/range'\n\nexport const point: EditorInterface['point'] = (editor, at, options = {}) => {\n  const { edge = 'start' } = options\n\n  if (Path.isPath(at)) {\n    let path\n\n    if (edge === 'end') {\n      const [, lastPath] = Node.last(editor, at)\n      path = lastPath\n    } else {\n      const [, firstPath] = Node.first(editor, at)\n      path = firstPath\n    }\n\n    const node = Node.get(editor, path)\n\n    if (!Text.isText(node)) {\n      throw new Error(\n        `Cannot get the ${edge} point in the node at path [${at}] because it has no ${edge} text node.`\n      )\n    }\n\n    return { path, offset: edge === 'end' ? node.text.length : 0 }\n  }\n\n  if (Range.isRange(at)) {\n    const [start, end] = Range.edges(at)\n    return edge === 'start' ? start : end\n  }\n\n  return at\n}\n","import { Editor, EditorPositionsOptions } from '../interfaces/editor'\nimport { Point } from '../interfaces/point'\nimport { Range } from '../interfaces/range'\nimport { Element } from '../interfaces/element'\nimport { Path } from '../interfaces/path'\nimport { Text } from '../interfaces/text'\nimport {\n  getCharacterDistance,\n  getWordDistance,\n  splitByCharacterDistance,\n} from '../utils/string'\n\nexport function* positions(\n  editor: Editor,\n  options: EditorPositionsOptions = {}\n): Generator<Point, void, undefined> {\n  const {\n    at = editor.selection,\n    unit = 'offset',\n    reverse = false,\n    voids = false,\n    ignoreNonSelectable = false,\n  } = options\n\n  if (!at) {\n    return\n  }\n\n  /**\n   * Algorithm notes:\n   *\n   * Each step `distance` is dynamic depending on the underlying text\n   * and the `unit` specified.  Each step, e.g., a line or word, may\n   * span multiple text nodes, so we iterate through the text both on\n   * two levels in step-sync:\n   *\n   * `leafText` stores the text on a text leaf level, and is advanced\n   * through using the counters `leafTextOffset` and `leafTextRemaining`.\n   *\n   * `blockText` stores the text on a block level, and is shortened\n   * by `distance` every time it is advanced.\n   *\n   * We only maintain a window of one blockText and one leafText because\n   * a block node always appears before all of its leaf nodes.\n   */\n\n  const range = Editor.range(editor, at)\n  const [start, end] = Range.edges(range)\n  const first = reverse ? end : start\n  let isNewBlock = false\n  let blockText = ''\n  let distance = 0 // Distance for leafText to catch up to blockText.\n  let leafTextRemaining = 0\n  let leafTextOffset = 0\n\n  // Iterate through all nodes in range, grabbing entire textual content\n  // of block nodes in blockText, and text nodes in leafText.\n  // Exploits the fact that nodes are sequenced in such a way that we first\n  // encounter the block node, then all of its text nodes, so when iterating\n  // through the blockText and leafText we just need to remember a window of\n  // one block node and leaf node, respectively.\n  for (const [node, path] of Editor.nodes(editor, {\n    at,\n    reverse,\n    voids,\n    ignoreNonSelectable,\n  })) {\n    /*\n     * ELEMENT NODE - Yield position(s) for voids, collect blockText for blocks\n     */\n    if (Element.isElement(node)) {\n      // Void nodes are a special case, so by default we will always\n      // yield their first point. If the `voids` option is set to true,\n      // then we will iterate over their content.\n      if (!voids && (editor.isVoid(node) || editor.isElementReadOnly(node))) {\n        yield Editor.start(editor, path)\n        continue\n      }\n\n      // Inline element nodes are ignored as they don't themselves\n      // contribute to `blockText` or `leafText` - their parent and\n      // children do.\n      if (editor.isInline(node)) continue\n\n      // Block element node - set `blockText` to its text content.\n      if (Editor.hasInlines(editor, node)) {\n        // We always exhaust block nodes before encountering a new one:\n        //   console.assert(blockText === '',\n        //     `blockText='${blockText}' - `+\n        //     `not exhausted before new block node`, path)\n\n        // Ensure range considered is capped to `range`, in the\n        // start/end edge cases where block extends beyond range.\n        // Equivalent to this, but presumably more performant:\n        //   blockRange = Editor.range(editor, ...Editor.edges(editor, path))\n        //   blockRange = Range.intersection(range, blockRange) // intersect\n        //   blockText = Editor.string(editor, blockRange, { voids })\n        const e = Path.isAncestor(path, end.path)\n          ? end\n          : Editor.end(editor, path)\n        const s = Path.isAncestor(path, start.path)\n          ? start\n          : Editor.start(editor, path)\n\n        blockText = Editor.string(editor, { anchor: s, focus: e }, { voids })\n        isNewBlock = true\n      }\n    }\n\n    /*\n     * TEXT LEAF NODE - Iterate through text content, yielding\n     * positions every `distance` offset according to `unit`.\n     */\n    if (Text.isText(node)) {\n      const isFirst = Path.equals(path, first.path)\n\n      // Proof that we always exhaust text nodes before encountering a new one:\n      //   console.assert(leafTextRemaining <= 0,\n      //     `leafTextRemaining=${leafTextRemaining} - `+\n      //     `not exhausted before new leaf text node`, path)\n\n      // Reset `leafText` counters for new text node.\n      if (isFirst) {\n        leafTextRemaining = reverse\n          ? first.offset\n          : node.text.length - first.offset\n        leafTextOffset = first.offset // Works for reverse too.\n      } else {\n        leafTextRemaining = node.text.length\n        leafTextOffset = reverse ? leafTextRemaining : 0\n      }\n\n      // Yield position at the start of node (potentially).\n      if (isFirst || isNewBlock || unit === 'offset') {\n        yield { path, offset: leafTextOffset }\n        isNewBlock = false\n      }\n\n      // Yield positions every (dynamically calculated) `distance` offset.\n      while (true) {\n        // If `leafText` has caught up with `blockText` (distance=0),\n        // and if blockText is exhausted, break to get another block node,\n        // otherwise advance blockText forward by the new `distance`.\n        if (distance === 0) {\n          if (blockText === '') break\n          distance = calcDistance(blockText, unit, reverse)\n          // Split the string at the previously found distance and use the\n          // remaining string for the next iteration.\n          blockText = splitByCharacterDistance(blockText, distance, reverse)[1]\n        }\n\n        // Advance `leafText` by the current `distance`.\n        leafTextOffset = reverse\n          ? leafTextOffset - distance\n          : leafTextOffset + distance\n        leafTextRemaining = leafTextRemaining - distance\n\n        // If `leafText` is exhausted, break to get a new leaf node\n        // and set distance to the overflow amount, so we'll (maybe)\n        // catch up to blockText in the next leaf text node.\n        if (leafTextRemaining < 0) {\n          distance = -leafTextRemaining\n          break\n        }\n\n        // Successfully walked `distance` offsets through `leafText`\n        // to catch up with `blockText`, so we can reset `distance`\n        // and yield this position in this node.\n        distance = 0\n        yield { path, offset: leafTextOffset }\n      }\n    }\n  }\n  // Proof that upon completion, we've exahusted both leaf and block text:\n  //   console.assert(leafTextRemaining <= 0, \"leafText wasn't exhausted\")\n  //   console.assert(blockText === '', \"blockText wasn't exhausted\")\n\n  // Helper:\n  // Return the distance in offsets for a step of size `unit` on given string.\n  function calcDistance(text: string, unit: string, reverse?: boolean) {\n    if (unit === 'character') {\n      return getCharacterDistance(text, reverse)\n    } else if (unit === 'word') {\n      return getWordDistance(text, reverse)\n    } else if (unit === 'line' || unit === 'block') {\n      return text.length\n    }\n    return 1\n  }\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Span } from '../interfaces/location'\nimport { Path } from '../interfaces/path'\n\nexport const previous: EditorInterface['previous'] = (editor, options = {}) => {\n  const { mode = 'lowest', voids = false } = options\n  let { match, at = editor.selection } = options\n\n  if (!at) {\n    return\n  }\n\n  const pointBeforeLocation = Editor.before(editor, at, { voids })\n\n  if (!pointBeforeLocation) {\n    return\n  }\n\n  const [, to] = Editor.first(editor, [])\n\n  // The search location is from the start of the document to the path of\n  // the point before the location passed in\n  const span: Span = [pointBeforeLocation.path, to]\n\n  if (Path.isPath(at) && at.length === 0) {\n    throw new Error(`Cannot get the previous node from the root node!`)\n  }\n\n  if (match == null) {\n    if (Path.isPath(at)) {\n      const [parent] = Editor.parent(editor, at)\n      match = n => parent.children.includes(n)\n    } else {\n      match = () => true\n    }\n  }\n\n  const [previous] = Editor.nodes(editor, {\n    reverse: true,\n    at: span,\n    match,\n    mode,\n    voids,\n  })\n\n  return previous\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { RangeRef } from '../interfaces/range-ref'\n\nexport const rangeRef: EditorInterface['rangeRef'] = (\n  editor,\n  range,\n  options = {}\n) => {\n  const { affinity = 'forward' } = options\n  const ref: RangeRef = {\n    current: range,\n    affinity,\n    unref() {\n      const { current } = ref\n      const rangeRefs = Editor.rangeRefs(editor)\n      rangeRefs.delete(ref)\n      ref.current = null\n      return current\n    },\n  }\n\n  const refs = Editor.rangeRefs(editor)\n  refs.add(ref)\n  return ref\n}\n","import { EditorInterface } from '../interfaces/editor'\nimport { RANGE_REFS } from '../utils/weak-maps'\n\nexport const rangeRefs: EditorInterface['rangeRefs'] = editor => {\n  let refs = RANGE_REFS.get(editor)\n\n  if (!refs) {\n    refs = new Set()\n    RANGE_REFS.set(editor, refs)\n  }\n\n  return refs\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Range } from '../interfaces/range'\n\nexport const range: EditorInterface['range'] = (editor, at, to) => {\n  if (Range.isRange(at) && !to) {\n    return at\n  }\n\n  const start = Editor.start(editor, at)\n  const end = Editor.end(editor, to || at)\n  return { anchor: start, focus: end }\n}\n","import { Node } from '../interfaces/node'\nimport { Path } from '../interfaces/path'\nimport { Text } from '../interfaces/text'\nimport { Range } from '../interfaces/range'\nimport { Transforms } from '../interfaces/transforms'\nimport { FLUSHING } from '../utils/weak-maps'\nimport { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const removeMark: EditorInterface['removeMark'] = (editor, key) => {\n  const { selection } = editor\n\n  if (selection) {\n    const match = (node: Node, path: Path) => {\n      if (!Text.isText(node)) {\n        return false // marks can only be applied to text\n      }\n      const [parentNode, parentPath] = Editor.parent(editor, path)\n      return !editor.isVoid(parentNode) || editor.markableVoid(parentNode)\n    }\n    const expandedSelection = Range.isExpanded(selection)\n    let markAcceptingVoidSelected = false\n    if (!expandedSelection) {\n      const [selectedNode, selectedPath] = Editor.node(editor, selection)\n      if (selectedNode && match(selectedNode, selectedPath)) {\n        const [parentNode] = Editor.parent(editor, selectedPath)\n        markAcceptingVoidSelected =\n          parentNode && editor.markableVoid(parentNode)\n      }\n    }\n    if (expandedSelection || markAcceptingVoidSelected) {\n      Transforms.unsetNodes(editor, key, {\n        match,\n        split: true,\n        voids: true,\n      })\n    } else {\n      const marks = { ...(Editor.marks(editor) || {}) }\n      delete marks[<keyof Node>key]\n      editor.marks = marks\n      if (!FLUSHING.get(editor)) {\n        editor.onChange()\n      }\n    }\n  }\n}\n","import { EditorInterface } from '../interfaces/editor'\nimport { NORMALIZING } from '../utils/weak-maps'\n\nexport const setNormalizing: EditorInterface['setNormalizing'] = (\n  editor,\n  isNormalizing\n) => {\n  NORMALIZING.set(editor, isNormalizing)\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const start: EditorInterface['start'] = (editor, at) => {\n  return Editor.point(editor, at, { edge: 'start' })\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Range } from '../interfaces/range'\nimport { Text } from '../interfaces/text'\nimport { Path } from '../interfaces/path'\n\nexport const string: EditorInterface['string'] = (editor, at, options = {}) => {\n  const { voids = false } = options\n  const range = Editor.range(editor, at)\n  const [start, end] = Range.edges(range)\n  let text = ''\n\n  for (const [node, path] of Editor.nodes(editor, {\n    at: range,\n    match: Text.isText,\n    voids,\n  })) {\n    let t = node.text\n\n    if (Path.equals(path, end.path)) {\n      t = t.slice(0, end.offset)\n    }\n\n    if (Path.equals(path, start.path)) {\n      t = t.slice(start.offset)\n    }\n\n    text += t\n  }\n\n  return text\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\nimport { Range } from '../interfaces/range'\nimport { Path } from '../interfaces/path'\nimport { Element } from '../interfaces/element'\nimport { Text } from '../interfaces/text'\n\nexport const unhangRange: EditorInterface['unhangRange'] = (\n  editor,\n  range,\n  options = {}\n) => {\n  const { voids = false } = options\n  let [start, end] = Range.edges(range)\n\n  // PERF: exit early if we can guarantee that the range isn't hanging.\n  if (\n    start.offset !== 0 ||\n    end.offset !== 0 ||\n    Range.isCollapsed(range) ||\n    Path.hasPrevious(end.path)\n  ) {\n    return range\n  }\n\n  const endBlock = Editor.above(editor, {\n    at: end,\n    match: n => Element.isElement(n) && Editor.isBlock(editor, n),\n    voids,\n  })\n  const blockPath = endBlock ? endBlock[1] : []\n  const first = Editor.start(editor, start)\n  const before = { anchor: first, focus: end }\n  let skip = true\n\n  for (const [node, path] of Editor.nodes(editor, {\n    at: before,\n    match: Text.isText,\n    reverse: true,\n    voids,\n  })) {\n    if (skip) {\n      skip = false\n      continue\n    }\n\n    if (node.text !== '' || Path.isBefore(path, blockPath)) {\n      end = { path, offset: node.text.length }\n      break\n    }\n  }\n\n  return { anchor: start, focus: end }\n}\n","import { Editor, EditorInterface } from '../interfaces/editor'\n\nexport const withoutNormalizing: EditorInterface['withoutNormalizing'] = (\n  editor,\n  fn\n) => {\n  const value = Editor.isNormalizing(editor)\n  Editor.setNormalizing(editor, false)\n  try {\n    fn()\n  } finally {\n    Editor.setNormalizing(editor, value)\n  }\n  Editor.normalize(editor)\n}\n","import { EditorInterface, Element, Editor, Text } from '../interfaces'\n\nexport const shouldMergeNodesRemovePrevNode: EditorInterface['shouldMergeNodesRemovePrevNode'] =\n  (editor, [prevNode, prevPath], [curNode, curNodePath]) => {\n    // If the target node that we're merging with is empty, remove it instead\n    // of merging the two. This is a common rich text editor behavior to\n    // prevent losing formatting when deleting entire nodes when you have a\n    // hanging selection.\n    // if prevNode is first child in parent,don't remove it.\n\n    return (\n      (Element.isElement(prevNode) && Editor.isEmpty(editor, prevNode)) ||\n      (Text.isText(prevNode) &&\n        prevNode.text === '' &&\n        prevPath[prevPath.length - 1] !== 0)\n    )\n  }\n","import { TextTransforms } from '../interfaces/transforms/text'\nimport { Editor } from '../interfaces/editor'\nimport { Range } from '../interfaces/range'\nimport { Point } from '../interfaces/point'\nimport { Path } from '../interfaces/path'\nimport { Transforms } from '../interfaces/transforms'\nimport { Element } from '../interfaces/element'\nimport { NodeEntry } from '../interfaces/node'\n\nexport const deleteText: TextTransforms['delete'] = (editor, options = {}) => {\n  Editor.withoutNormalizing(editor, () => {\n    const {\n      reverse = false,\n      unit = 'character',\n      distance = 1,\n      voids = false,\n    } = options\n    let { at = editor.selection, hanging = false } = options\n\n    if (!at) {\n      return\n    }\n\n    let isCollapsed = false\n    if (Range.isRange(at) && Range.isCollapsed(at)) {\n      isCollapsed = true\n      at = at.anchor\n    }\n\n    if (Point.isPoint(at)) {\n      const furthestVoid = Editor.void(editor, { at, mode: 'highest' })\n\n      if (!voids && furthestVoid) {\n        const [, voidPath] = furthestVoid\n        at = voidPath\n      } else {\n        const opts = { unit, distance }\n        const target = reverse\n          ? Editor.before(editor, at, opts) || Editor.start(editor, [])\n          : Editor.after(editor, at, opts) || Editor.end(editor, [])\n        at = { anchor: at, focus: target }\n        hanging = true\n      }\n    }\n\n    if (Path.isPath(at)) {\n      Transforms.removeNodes(editor, { at, voids })\n      return\n    }\n\n    if (Range.isCollapsed(at)) {\n      return\n    }\n\n    if (!hanging) {\n      const [, end] = Range.edges(at)\n      const endOfDoc = Editor.end(editor, [])\n\n      if (!Point.equals(end, endOfDoc)) {\n        at = Editor.unhangRange(editor, at, { voids })\n      }\n    }\n\n    let [start, end] = Range.edges(at)\n    const startBlock = Editor.above(editor, {\n      match: n => Element.isElement(n) && Editor.isBlock(editor, n),\n      at: start,\n      voids,\n    })\n    const endBlock = Editor.above(editor, {\n      match: n => Element.isElement(n) && Editor.isBlock(editor, n),\n      at: end,\n      voids,\n    })\n    const isAcrossBlocks =\n      startBlock && endBlock && !Path.equals(startBlock[1], endBlock[1])\n    const isSingleText = Path.equals(start.path, end.path)\n    const startNonEditable = voids\n      ? null\n      : Editor.void(editor, { at: start, mode: 'highest' }) ??\n        Editor.elementReadOnly(editor, { at: start, mode: 'highest' })\n    const endNonEditable = voids\n      ? null\n      : Editor.void(editor, { at: end, mode: 'highest' }) ??\n        Editor.elementReadOnly(editor, { at: end, mode: 'highest' })\n\n    // If the start or end points are inside an inline void, nudge them out.\n    if (startNonEditable) {\n      const before = Editor.before(editor, start)\n\n      if (before && startBlock && Path.isAncestor(startBlock[1], before.path)) {\n        start = before\n      }\n    }\n\n    if (endNonEditable) {\n      const after = Editor.after(editor, end)\n\n      if (after && endBlock && Path.isAncestor(endBlock[1], after.path)) {\n        end = after\n      }\n    }\n\n    // Get the highest nodes that are completely inside the range, as well as\n    // the start and end nodes.\n    const matches: NodeEntry[] = []\n    let lastPath: Path | undefined\n\n    for (const entry of Editor.nodes(editor, { at, voids })) {\n      const [node, path] = entry\n\n      if (lastPath && Path.compare(path, lastPath) === 0) {\n        continue\n      }\n\n      if (\n        (!voids &&\n          Element.isElement(node) &&\n          (Editor.isVoid(editor, node) ||\n            Editor.isElementReadOnly(editor, node))) ||\n        (!Path.isCommon(path, start.path) && !Path.isCommon(path, end.path))\n      ) {\n        matches.push(entry)\n        lastPath = path\n      }\n    }\n\n    const pathRefs = Array.from(matches, ([, p]) => Editor.pathRef(editor, p))\n    const startRef = Editor.pointRef(editor, start)\n    const endRef = Editor.pointRef(editor, end)\n\n    let removedText = ''\n\n    if (!isSingleText && !startNonEditable) {\n      const point = startRef.current!\n      const [node] = Editor.leaf(editor, point)\n      const { path } = point\n      const { offset } = start\n      const text = node.text.slice(offset)\n      if (text.length > 0) {\n        editor.apply({ type: 'remove_text', path, offset, text })\n        removedText = text\n      }\n    }\n\n    pathRefs\n      .reverse()\n      .map(r => r.unref())\n      .filter((r): r is Path => r !== null)\n      .forEach(p => Transforms.removeNodes(editor, { at: p, voids }))\n\n    if (!endNonEditable) {\n      const point = endRef.current!\n      const [node] = Editor.leaf(editor, point)\n      const { path } = point\n      const offset = isSingleText ? start.offset : 0\n      const text = node.text.slice(offset, end.offset)\n      if (text.length > 0) {\n        editor.apply({ type: 'remove_text', path, offset, text })\n        removedText = text\n      }\n    }\n\n    if (!isSingleText && isAcrossBlocks && endRef.current && startRef.current) {\n      Transforms.mergeNodes(editor, {\n        at: endRef.current,\n        hanging: true,\n        voids,\n      })\n    }\n\n    // For Thai script, deleting N character(s) backward should delete\n    // N code point(s) instead of an entire grapheme cluster.\n    // Therefore, the remaining code points should be inserted back.\n    if (\n      isCollapsed &&\n      reverse &&\n      unit === 'character' &&\n      removedText.length > 1 &&\n      removedText.match(/[\\u0E00-\\u0E7F]+/)\n    ) {\n      Transforms.insertText(\n        editor,\n        removedText.slice(0, removedText.length - distance)\n      )\n    }\n\n    const startUnref = startRef.unref()\n    const endUnref = endRef.unref()\n    const point = reverse ? startUnref || endUnref : endUnref || startUnref\n\n    if (options.at == null && point) {\n      Transforms.select(editor, point)\n    }\n  })\n}\n","import { Transforms } from '../interfaces/transforms'\nimport { Editor } from '../interfaces/editor'\nimport { Range } from '../interfaces/range'\nimport { Path } from '../interfaces/path'\nimport { Element } from '../interfaces/element'\nimport { Node, NodeEntry } from '../interfaces/node'\nimport { Text } from '../interfaces/text'\nimport { TextTransforms } from '../interfaces/transforms/text'\nimport { getDefaultInsertLocation } from '../utils'\n\nexport const insertFragment: TextTransforms['insertFragment'] = (\n  editor,\n  fragment,\n  options = {}\n) => {\n  Editor.withoutNormalizing(editor, () => {\n    const { hanging = false, voids = false } = options\n    let { at = getDefaultInsertLocation(editor), batchDirty = true } = options\n\n    if (!fragment.length) {\n      return\n    }\n\n    if (Range.isRange(at)) {\n      if (!hanging) {\n        at = Editor.unhangRange(editor, at, { voids })\n      }\n\n      if (Range.isCollapsed(at)) {\n        at = at.anchor\n      } else {\n        const [, end] = Range.edges(at)\n\n        if (!voids && Editor.void(editor, { at: end })) {\n          return\n        }\n\n        const pointRef = Editor.pointRef(editor, end)\n        Transforms.delete(editor, { at })\n        at = pointRef.unref()!\n      }\n    } else if (Path.isPath(at)) {\n      at = Editor.start(editor, at)\n    }\n\n    if (!voids && Editor.void(editor, { at })) {\n      return\n    }\n\n    // If the insert point is at the edge of an inline node, move it outside\n    // instead since it will need to be split otherwise.\n    const inlineElementMatch = Editor.above(editor, {\n      at,\n      match: n => Element.isElement(n) && Editor.isInline(editor, n),\n      mode: 'highest',\n      voids,\n    })\n\n    if (inlineElementMatch) {\n      const [, inlinePath] = inlineElementMatch\n\n      if (Editor.isEnd(editor, at, inlinePath)) {\n        const after = Editor.after(editor, inlinePath)!\n        at = after\n      } else if (Editor.isStart(editor, at, inlinePath)) {\n        const before = Editor.before(editor, inlinePath)!\n        at = before\n      }\n    }\n\n    const blockMatch = Editor.above(editor, {\n      match: n => Element.isElement(n) && Editor.isBlock(editor, n),\n      at,\n      voids,\n    })!\n    const [, blockPath] = blockMatch\n    const isBlockStart = Editor.isStart(editor, at, blockPath)\n    const isBlockEnd = Editor.isEnd(editor, at, blockPath)\n    const isBlockEmpty = isBlockStart && isBlockEnd\n    const mergeStart = !isBlockStart || (isBlockStart && isBlockEnd)\n    const mergeEnd = !isBlockEnd\n    const [, firstPath] = Node.first({ children: fragment }, [])\n    const [, lastPath] = Node.last({ children: fragment }, [])\n\n    const matches: NodeEntry[] = []\n    const matcher = ([n, p]: NodeEntry) => {\n      const isRoot = p.length === 0\n      if (isRoot) {\n        return false\n      }\n\n      if (isBlockEmpty) {\n        return true\n      }\n\n      if (\n        mergeStart &&\n        Path.isAncestor(p, firstPath) &&\n        Element.isElement(n) &&\n        !editor.isVoid(n) &&\n        !editor.isInline(n)\n      ) {\n        return false\n      }\n\n      if (\n        mergeEnd &&\n        Path.isAncestor(p, lastPath) &&\n        Element.isElement(n) &&\n        !editor.isVoid(n) &&\n        !editor.isInline(n)\n      ) {\n        return false\n      }\n\n      return true\n    }\n\n    for (const entry of Node.nodes({ children: fragment }, { pass: matcher })) {\n      if (matcher(entry)) {\n        matches.push(entry)\n      }\n    }\n\n    const starts = []\n    const middles = []\n    const ends = []\n    let starting = true\n    let hasBlocks = false\n\n    for (const [node] of matches) {\n      if (Element.isElement(node) && !editor.isInline(node)) {\n        starting = false\n        hasBlocks = true\n        middles.push(node)\n      } else if (starting) {\n        starts.push(node)\n      } else {\n        ends.push(node)\n      }\n    }\n\n    const [inlineMatch] = Editor.nodes(editor, {\n      at,\n      match: n => Text.isText(n) || Editor.isInline(editor, n),\n      mode: 'highest',\n      voids,\n    })!\n\n    const [, inlinePath] = inlineMatch\n    const isInlineStart = Editor.isStart(editor, at, inlinePath)\n    const isInlineEnd = Editor.isEnd(editor, at, inlinePath)\n\n    const middleRef = Editor.pathRef(\n      editor,\n      isBlockEnd && !ends.length ? Path.next(blockPath) : blockPath\n    )\n\n    const endRef = Editor.pathRef(\n      editor,\n      isInlineEnd ? Path.next(inlinePath) : inlinePath\n    )\n\n    Transforms.splitNodes(editor, {\n      at,\n      match: n =>\n        hasBlocks\n          ? Element.isElement(n) && Editor.isBlock(editor, n)\n          : Text.isText(n) || Editor.isInline(editor, n),\n      mode: hasBlocks ? 'lowest' : 'highest',\n      always:\n        hasBlocks &&\n        (!isBlockStart || starts.length > 0) &&\n        (!isBlockEnd || ends.length > 0),\n      voids,\n    })\n\n    const startRef = Editor.pathRef(\n      editor,\n      !isInlineStart || (isInlineStart && isInlineEnd)\n        ? Path.next(inlinePath)\n        : inlinePath\n    )\n\n    Transforms.insertNodes(editor, starts, {\n      at: startRef.current!,\n      match: n => Text.isText(n) || Editor.isInline(editor, n),\n      mode: 'highest',\n      voids,\n      batchDirty,\n    })\n\n    if (isBlockEmpty && !starts.length && middles.length && !ends.length) {\n      Transforms.delete(editor, { at: blockPath, voids })\n    }\n\n    Transforms.insertNodes(editor, middles, {\n      at: middleRef.current!,\n      match: n => Element.isElement(n) && Editor.isBlock(editor, n),\n      mode: 'lowest',\n      voids,\n      batchDirty,\n    })\n\n    Transforms.insertNodes(editor, ends, {\n      at: endRef.current!,\n      match: n => Text.isText(n) || Editor.isInline(editor, n),\n      mode: 'highest',\n      voids,\n      batchDirty,\n    })\n\n    if (!options.at) {\n      let path\n\n      if (ends.length > 0 && endRef.current) {\n        path = Path.previous(endRef.current)\n      } else if (middles.length > 0 && middleRef.current) {\n        path = Path.previous(middleRef.current)\n      } else if (startRef.current) {\n        path = Path.previous(startRef.current)\n      }\n\n      if (path) {\n        const end = Editor.end(editor, path)\n        Transforms.select(editor, end)\n      }\n    }\n\n    startRef.unref()\n    middleRef.unref()\n    endRef.unref()\n  })\n}\n","import { SelectionTransforms } from '../interfaces/transforms/selection'\nimport { Transforms } from '../interfaces/transforms'\nimport { Range } from '../interfaces/range'\n\nexport const collapse: SelectionTransforms['collapse'] = (\n  editor,\n  options = {}\n) => {\n  const { edge = 'anchor' } = options\n  const { selection } = editor\n\n  if (!selection) {\n    return\n  } else if (edge === 'anchor') {\n    Transforms.select(editor, selection.anchor)\n  } else if (edge === 'focus') {\n    Transforms.select(editor, selection.focus)\n  } else if (edge === 'start') {\n    const [start] = Range.edges(selection)\n    Transforms.select(editor, start)\n  } else if (edge === 'end') {\n    const [, end] = Range.edges(selection)\n    Transforms.select(editor, end)\n  }\n}\n","import { SelectionTransforms } from '../interfaces/transforms/selection'\n\nexport const deselect: SelectionTransforms['deselect'] = editor => {\n  const { selection } = editor\n\n  if (selection) {\n    editor.apply({\n      type: 'set_selection',\n      properties: selection,\n      newProperties: null,\n    })\n  }\n}\n","import { SelectionTransforms } from '../interfaces/transforms/selection'\nimport { Range } from '../interfaces/range'\nimport { Editor } from '../interfaces/editor'\nimport { Transforms } from '../interfaces/transforms'\n\nexport const move: SelectionTransforms['move'] = (editor, options = {}) => {\n  const { selection } = editor\n  const { distance = 1, unit = 'character', reverse = false } = options\n  let { edge = null } = options\n\n  if (!selection) {\n    return\n  }\n\n  if (edge === 'start') {\n    edge = Range.isBackward(selection) ? 'focus' : 'anchor'\n  }\n\n  if (edge === 'end') {\n    edge = Range.isBackward(selection) ? 'anchor' : 'focus'\n  }\n\n  const { anchor, focus } = selection\n  const opts = { distance, unit, ignoreNonSelectable: true }\n  const props: Partial<Range> = {}\n\n  if (edge == null || edge === 'anchor') {\n    const point = reverse\n      ? Editor.before(editor, anchor, opts)\n      : Editor.after(editor, anchor, opts)\n\n    if (point) {\n      props.anchor = point\n    }\n  }\n\n  if (edge == null || edge === 'focus') {\n    const point = reverse\n      ? Editor.before(editor, focus, opts)\n      : Editor.after(editor, focus, opts)\n\n    if (point) {\n      props.focus = point\n    }\n  }\n\n  Transforms.setSelection(editor, props)\n}\n","import { SelectionTransforms } from '../interfaces/transforms/selection'\nimport { Editor } from '../interfaces/editor'\nimport { Transforms } from '../interfaces/transforms'\nimport { Range } from '../interfaces/range'\nimport { Scrubber } from '../interfaces/scrubber'\n\nexport const select: SelectionTransforms['select'] = (editor, target) => {\n  const { selection } = editor\n  target = Editor.range(editor, target)\n\n  if (selection) {\n    Transforms.setSelection(editor, target)\n    return\n  }\n\n  if (!Range.isRange(target)) {\n    throw new Error(\n      `When setting the selection and the current selection is \\`null\\` you must provide at least an \\`anchor\\` and \\`focus\\`, but you passed: ${Scrubber.stringify(\n        target\n      )}`\n    )\n  }\n\n  editor.apply({\n    type: 'set_selection',\n    properties: selection,\n    newProperties: target,\n  })\n}\n","import { SelectionTransforms } from '../interfaces/transforms/selection'\nimport { Range } from '../interfaces/range'\nimport { Transforms } from '../interfaces/transforms'\n\nexport const setPoint: SelectionTransforms['setPoint'] = (\n  editor,\n  props,\n  options = {}\n) => {\n  const { selection } = editor\n  let { edge = 'both' } = options\n\n  if (!selection) {\n    return\n  }\n\n  if (edge === 'start') {\n    edge = Range.isBackward(selection) ? 'focus' : 'anchor'\n  }\n\n  if (edge === 'end') {\n    edge = Range.isBackward(selection) ? 'anchor' : 'focus'\n  }\n\n  const { anchor, focus } = selection\n  const point = edge === 'anchor' ? anchor : focus\n\n  Transforms.setSelection(editor, {\n    [edge === 'anchor' ? 'anchor' : 'focus']: { ...point, ...props },\n  })\n}\n","import { SelectionTransforms } from '../interfaces/transforms/selection'\nimport { Range } from '../interfaces/range'\nimport { Point } from '../interfaces/point'\n\nexport const setSelection: SelectionTransforms['setSelection'] = (\n  editor,\n  props\n) => {\n  const { selection } = editor\n  const oldProps: Partial<Range> | null = {}\n  const newProps: Partial<Range> = {}\n\n  if (!selection) {\n    return\n  }\n\n  for (const k in props) {\n    if (\n      (k === 'anchor' &&\n        props.anchor != null &&\n        !Point.equals(props.anchor, selection.anchor)) ||\n      (k === 'focus' &&\n        props.focus != null &&\n        !Point.equals(props.focus, selection.focus)) ||\n      (k !== 'anchor' &&\n        k !== 'focus' &&\n        props[<keyof Range>k] !== selection[<keyof Range>k])\n    ) {\n      oldProps[<keyof Range>k] = selection[<keyof Range>k]\n      newProps[<keyof Range>k] = props[<keyof Range>k]\n    }\n  }\n\n  if (Object.keys(oldProps).length > 0) {\n    editor.apply({\n      type: 'set_selection',\n      properties: oldProps,\n      newProperties: newProps,\n    })\n  }\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Editor } from '../interfaces/editor'\nimport { Node } from '../interfaces/node'\nimport { Range } from '../interfaces/range'\nimport { Transforms } from '../interfaces/transforms'\nimport { Point } from '../interfaces/point'\nimport { Text } from '../interfaces/text'\nimport { Element } from '../interfaces/element'\nimport { Path } from '../interfaces/path'\nimport { getDefaultInsertLocation } from '../utils'\nimport { batchDirtyPaths } from '../core/batch-dirty-paths'\nimport { BaseInsertNodeOperation } from '../interfaces'\nimport { updateDirtyPaths } from '../core/update-dirty-paths'\n\nexport const insertNodes: NodeTransforms['insertNodes'] = (\n  editor,\n  nodes,\n  options = {}\n) => {\n  Editor.withoutNormalizing(editor, () => {\n    const {\n      hanging = false,\n      voids = false,\n      mode = 'lowest',\n      batchDirty = true,\n    } = options\n    let { at, match, select } = options\n\n    if (Node.isNode(nodes)) {\n      nodes = [nodes]\n    }\n\n    if (nodes.length === 0) {\n      return\n    }\n\n    const [node] = nodes\n\n    if (!at) {\n      at = getDefaultInsertLocation(editor)\n      if (select !== false) {\n        select = true\n      }\n    }\n\n    if (select == null) {\n      select = false\n    }\n\n    if (Range.isRange(at)) {\n      if (!hanging) {\n        at = Editor.unhangRange(editor, at, { voids })\n      }\n\n      if (Range.isCollapsed(at)) {\n        at = at.anchor\n      } else {\n        const [, end] = Range.edges(at)\n        const pointRef = Editor.pointRef(editor, end)\n        Transforms.delete(editor, { at })\n        at = pointRef.unref()!\n      }\n    }\n\n    if (Point.isPoint(at)) {\n      if (match == null) {\n        if (Text.isText(node)) {\n          match = n => Text.isText(n)\n        } else if (editor.isInline(node)) {\n          match = n => Text.isText(n) || Editor.isInline(editor, n)\n        } else {\n          match = n => Element.isElement(n) && Editor.isBlock(editor, n)\n        }\n      }\n\n      const [entry] = Editor.nodes(editor, {\n        at: at.path,\n        match,\n        mode,\n        voids,\n      })\n\n      if (entry) {\n        const [, matchPath] = entry\n        const pathRef = Editor.pathRef(editor, matchPath)\n        const isAtEnd = Editor.isEnd(editor, at, matchPath)\n        Transforms.splitNodes(editor, { at, match, mode, voids })\n        const path = pathRef.unref()!\n        at = isAtEnd ? Path.next(path) : path\n      } else {\n        return\n      }\n    }\n\n    const parentPath = Path.parent(at)\n    let index = at[at.length - 1]\n\n    if (!voids && Editor.void(editor, { at: parentPath })) {\n      return\n    }\n\n    if (batchDirty) {\n      // PERF: batch update dirty paths\n      // batched ops used to transform existing dirty paths\n      const batchedOps: BaseInsertNodeOperation[] = []\n      const newDirtyPaths: Path[] = Path.levels(parentPath)\n      batchDirtyPaths(\n        editor,\n        () => {\n          for (const node of nodes as Node[]) {\n            const path = parentPath.concat(index)\n            index++\n\n            const op: BaseInsertNodeOperation = {\n              type: 'insert_node',\n              path,\n              node,\n            }\n            editor.apply(op)\n            at = Path.next(at as Path)\n\n            batchedOps.push(op)\n            if (Text.isText(node)) {\n              newDirtyPaths.push(path)\n            } else {\n              newDirtyPaths.push(\n                ...Array.from(Node.nodes(node), ([, p]) => path.concat(p))\n              )\n            }\n          }\n        },\n        () => {\n          updateDirtyPaths(editor, newDirtyPaths, p => {\n            let newPath: Path | null = p\n            for (const op of batchedOps) {\n              if (Path.operationCanTransformPath(op)) {\n                newPath = Path.transform(newPath, op)\n                if (!newPath) {\n                  return null\n                }\n              }\n            }\n            return newPath\n          })\n        }\n      )\n    } else {\n      for (const node of nodes as Node[]) {\n        const path = parentPath.concat(index)\n        index++\n\n        editor.apply({ type: 'insert_node', path, node })\n        at = Path.next(at as Path)\n      }\n    }\n\n    at = Path.previous(at)\n\n    if (select) {\n      const point = Editor.end(editor, at)\n\n      if (point) {\n        Transforms.select(editor, point)\n      }\n    }\n  })\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Editor } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { matchPath } from '../utils/match-path'\nimport { Element } from '../interfaces/element'\nimport { Ancestor, NodeEntry } from '../interfaces/node'\nimport { Transforms } from '../interfaces/transforms'\n\nexport const liftNodes: NodeTransforms['liftNodes'] = (\n  editor,\n  options = {}\n) => {\n  Editor.withoutNormalizing(editor, () => {\n    const { at = editor.selection, mode = 'lowest', voids = false } = options\n    let { match } = options\n\n    if (match == null) {\n      match = Path.isPath(at)\n        ? matchPath(editor, at)\n        : n => Element.isElement(n) && Editor.isBlock(editor, n)\n    }\n\n    if (!at) {\n      return\n    }\n\n    const matches = Editor.nodes(editor, { at, match, mode, voids })\n    const pathRefs = Array.from(matches, ([, p]) => Editor.pathRef(editor, p))\n\n    for (const pathRef of pathRefs) {\n      const path = pathRef.unref()!\n\n      if (path.length < 2) {\n        throw new Error(\n          `Cannot lift node at a path [${path}] because it has a depth of less than \\`2\\`.`\n        )\n      }\n\n      const parentNodeEntry = Editor.node(editor, Path.parent(path))\n      const [parent, parentPath] = parentNodeEntry as NodeEntry<Ancestor>\n      const index = path[path.length - 1]\n      const { length } = parent.children\n\n      if (length === 1) {\n        const toPath = Path.next(parentPath)\n        Transforms.moveNodes(editor, { at: path, to: toPath, voids })\n        Transforms.removeNodes(editor, { at: parentPath, voids })\n      } else if (index === 0) {\n        Transforms.moveNodes(editor, { at: path, to: parentPath, voids })\n      } else if (index === length - 1) {\n        const toPath = Path.next(parentPath)\n        Transforms.moveNodes(editor, { at: path, to: toPath, voids })\n      } else {\n        const splitPath = Path.next(path)\n        const toPath = Path.next(parentPath)\n        Transforms.splitNodes(editor, { at: splitPath, voids })\n        Transforms.moveNodes(editor, { at: path, to: toPath, voids })\n      }\n    }\n  })\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Editor } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { Element } from '../interfaces/element'\nimport { Range } from '../interfaces/range'\nimport { Transforms } from '../interfaces/transforms'\nimport { Text } from '../interfaces/text'\nimport { Scrubber } from '../interfaces/scrubber'\nimport { Node } from '../interfaces/node'\n\nconst hasSingleChildNest = (editor: Editor, node: Node): boolean => {\n  if (Element.isElement(node)) {\n    const element = node as Element\n    if (Editor.isVoid(editor, node)) {\n      return true\n    } else if (element.children.length === 1) {\n      return hasSingleChildNest(editor, element.children[0])\n    } else {\n      return false\n    }\n  } else if (Editor.isEditor(node)) {\n    return false\n  } else {\n    return true\n  }\n}\n\nexport const mergeNodes: NodeTransforms['mergeNodes'] = (\n  editor,\n  options = {}\n) => {\n  Editor.withoutNormalizing(editor, () => {\n    let { match, at = editor.selection } = options\n    const { hanging = false, voids = false, mode = 'lowest' } = options\n\n    if (!at) {\n      return\n    }\n\n    if (match == null) {\n      if (Path.isPath(at)) {\n        const [parent] = Editor.parent(editor, at)\n        match = n => parent.children.includes(n)\n      } else {\n        match = n => Element.isElement(n) && Editor.isBlock(editor, n)\n      }\n    }\n\n    if (!hanging && Range.isRange(at)) {\n      at = Editor.unhangRange(editor, at, { voids })\n    }\n\n    if (Range.isRange(at)) {\n      if (Range.isCollapsed(at)) {\n        at = at.anchor\n      } else {\n        const [, end] = Range.edges(at)\n        const pointRef = Editor.pointRef(editor, end)\n        Transforms.delete(editor, { at })\n        at = pointRef.unref()!\n\n        if (options.at == null) {\n          Transforms.select(editor, at)\n        }\n      }\n    }\n\n    const [current] = Editor.nodes(editor, { at, match, voids, mode })\n    const prev = Editor.previous(editor, { at, match, voids, mode })\n\n    if (!current || !prev) {\n      return\n    }\n\n    const [node, path] = current\n    const [prevNode, prevPath] = prev\n\n    if (path.length === 0 || prevPath.length === 0) {\n      return\n    }\n\n    const newPath = Path.next(prevPath)\n    const commonPath = Path.common(path, prevPath)\n    const isPreviousSibling = Path.isSibling(path, prevPath)\n    const levels = Array.from(Editor.levels(editor, { at: path }), ([n]) => n)\n      .slice(commonPath.length)\n      .slice(0, -1)\n\n    // Determine if the merge will leave an ancestor of the path empty as a\n    // result, in which case we'll want to remove it after merging.\n    const emptyAncestor = Editor.above(editor, {\n      at: path,\n      mode: 'highest',\n      match: n => levels.includes(n) && hasSingleChildNest(editor, n),\n    })\n\n    const emptyRef = emptyAncestor && Editor.pathRef(editor, emptyAncestor[1])\n    let properties\n    let position\n\n    // Ensure that the nodes are equivalent, and figure out what the position\n    // and extra properties of the merge will be.\n    if (Text.isText(node) && Text.isText(prevNode)) {\n      const { text, ...rest } = node\n      position = prevNode.text.length\n      properties = rest as Partial<Text>\n    } else if (Element.isElement(node) && Element.isElement(prevNode)) {\n      const { children, ...rest } = node\n      position = prevNode.children.length\n      properties = rest as Partial<Element>\n    } else {\n      throw new Error(\n        `Cannot merge the node at path [${path}] with the previous sibling because it is not the same kind: ${Scrubber.stringify(\n          node\n        )} ${Scrubber.stringify(prevNode)}`\n      )\n    }\n\n    // If the node isn't already the next sibling of the previous node, move\n    // it so that it is before merging.\n    if (!isPreviousSibling) {\n      Transforms.moveNodes(editor, { at: path, to: newPath, voids })\n    }\n\n    // If there was going to be an empty ancestor of the node that was merged,\n    // we remove it from the tree.\n    if (emptyRef) {\n      Transforms.removeNodes(editor, { at: emptyRef.current!, voids })\n    }\n\n    if (Editor.shouldMergeNodesRemovePrevNode(editor, prev, current)) {\n      Transforms.removeNodes(editor, { at: prevPath, voids })\n    } else {\n      editor.apply({\n        type: 'merge_node',\n        path: newPath,\n        position,\n        properties,\n      })\n    }\n\n    if (emptyRef) {\n      emptyRef.unref()\n    }\n  })\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Editor } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { matchPath } from '../utils/match-path'\nimport { Element } from '../interfaces/element'\n\nexport const moveNodes: NodeTransforms['moveNodes'] = (editor, options) => {\n  Editor.withoutNormalizing(editor, () => {\n    const {\n      to,\n      at = editor.selection,\n      mode = 'lowest',\n      voids = false,\n    } = options\n    let { match } = options\n\n    if (!at) {\n      return\n    }\n\n    if (match == null) {\n      match = Path.isPath(at)\n        ? matchPath(editor, at)\n        : n => Element.isElement(n) && Editor.isBlock(editor, n)\n    }\n\n    const toRef = Editor.pathRef(editor, to)\n    const targets = Editor.nodes(editor, { at, match, mode, voids })\n    const pathRefs = Array.from(targets, ([, p]) => Editor.pathRef(editor, p))\n\n    for (const pathRef of pathRefs) {\n      const path = pathRef.unref()!\n      const newPath = toRef.current!\n\n      if (path.length !== 0) {\n        editor.apply({ type: 'move_node', path, newPath })\n      }\n\n      if (\n        toRef.current &&\n        Path.isSibling(newPath, path) &&\n        Path.isAfter(newPath, path)\n      ) {\n        // When performing a sibling move to a later index, the path at the destination is shifted\n        // to before the insertion point instead of after. To ensure our group of nodes are inserted\n        // in the correct order we increment toRef to account for that\n        toRef.current = Path.next(toRef.current)\n      }\n    }\n\n    toRef.unref()\n  })\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Editor } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { matchPath } from '../utils/match-path'\nimport { Element } from '../interfaces/element'\nimport { Range } from '../interfaces/range'\n\nexport const removeNodes: NodeTransforms['removeNodes'] = (\n  editor,\n  options = {}\n) => {\n  Editor.withoutNormalizing(editor, () => {\n    const { hanging = false, voids = false, mode = 'lowest' } = options\n    let { at = editor.selection, match } = options\n\n    if (!at) {\n      return\n    }\n\n    if (match == null) {\n      match = Path.isPath(at)\n        ? matchPath(editor, at)\n        : n => Element.isElement(n) && Editor.isBlock(editor, n)\n    }\n\n    if (!hanging && Range.isRange(at)) {\n      at = Editor.unhangRange(editor, at, { voids })\n    }\n\n    const depths = Editor.nodes(editor, { at, match, mode, voids })\n    const pathRefs = Array.from(depths, ([, p]) => Editor.pathRef(editor, p))\n\n    for (const pathRef of pathRefs) {\n      const path = pathRef.unref()!\n\n      if (path) {\n        const [node] = Editor.node(editor, path)\n        editor.apply({ type: 'remove_node', path, node })\n      }\n    }\n  })\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Editor } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { matchPath } from '../utils/match-path'\nimport { Element } from '../interfaces/element'\nimport { Range } from '../interfaces/range'\nimport { Transforms } from '../interfaces/transforms'\nimport { Node } from '../interfaces/node'\n\nexport const setNodes: NodeTransforms['setNodes'] = (\n  editor,\n  props: Partial<Node>,\n  options = {}\n) => {\n  Editor.withoutNormalizing(editor, () => {\n    let { match, at = editor.selection, compare, merge } = options\n    const {\n      hanging = false,\n      mode = 'lowest',\n      split = false,\n      voids = false,\n    } = options\n\n    if (!at) {\n      return\n    }\n\n    if (match == null) {\n      match = Path.isPath(at)\n        ? matchPath(editor, at)\n        : n => Element.isElement(n) && Editor.isBlock(editor, n)\n    }\n\n    if (!hanging && Range.isRange(at)) {\n      at = Editor.unhangRange(editor, at, { voids })\n    }\n\n    if (split && Range.isRange(at)) {\n      if (\n        Range.isCollapsed(at) &&\n        Editor.leaf(editor, at.anchor)[0].text.length > 0\n      ) {\n        // If the range is collapsed in a non-empty node and 'split' is true, there's nothing to\n        // set that won't get normalized away\n        return\n      }\n      const rangeRef = Editor.rangeRef(editor, at, { affinity: 'inward' })\n      const [start, end] = Range.edges(at)\n      const splitMode = mode === 'lowest' ? 'lowest' : 'highest'\n      const endAtEndOfNode = Editor.isEnd(editor, end, end.path)\n      Transforms.splitNodes(editor, {\n        at: end,\n        match,\n        mode: splitMode,\n        voids,\n        always: !endAtEndOfNode,\n      })\n      const startAtStartOfNode = Editor.isStart(editor, start, start.path)\n      Transforms.splitNodes(editor, {\n        at: start,\n        match,\n        mode: splitMode,\n        voids,\n        always: !startAtStartOfNode,\n      })\n      at = rangeRef.unref()!\n\n      if (options.at == null) {\n        Transforms.select(editor, at)\n      }\n    }\n\n    if (!compare) {\n      compare = (prop, nodeProp) => prop !== nodeProp\n    }\n\n    for (const [node, path] of Editor.nodes(editor, {\n      at,\n      match,\n      mode,\n      voids,\n    })) {\n      const properties: Partial<Node> = {}\n      // FIXME: is this correct?\n      const newProperties: Partial<Node> & { [key: string]: unknown } = {}\n\n      // You can't set properties on the editor node.\n      if (path.length === 0) {\n        continue\n      }\n\n      let hasChanges = false\n\n      for (const k in props) {\n        if (k === 'children' || k === 'text') {\n          continue\n        }\n\n        if (compare(props[<keyof Node>k], node[<keyof Node>k])) {\n          hasChanges = true\n          // Omit new properties from the old properties list\n          if (node.hasOwnProperty(k))\n            properties[<keyof Node>k] = node[<keyof Node>k]\n          // Omit properties that have been removed from the new properties list\n          if (merge) {\n            if (props[<keyof Node>k] != null)\n              newProperties[<keyof Node>k] = merge(\n                node[<keyof Node>k],\n                props[<keyof Node>k]\n              )\n          } else {\n            if (props[<keyof Node>k] != null)\n              newProperties[<keyof Node>k] = props[<keyof Node>k]\n          }\n        }\n      }\n\n      if (hasChanges) {\n        editor.apply({\n          type: 'set_node',\n          path,\n          properties,\n          newProperties,\n        })\n      }\n    }\n  })\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Editor } from '../interfaces/editor'\nimport { Element } from '../interfaces/element'\nimport { Range } from '../interfaces/range'\nimport { Path } from '../interfaces/path'\nimport { PointRef } from '../interfaces/point-ref'\nimport { Transforms } from '../interfaces/transforms'\nimport { Node } from '../interfaces/node'\nimport { Point } from '../interfaces/point'\n\n/**\n * Convert a range into a point by deleting it's content.\n */\nconst deleteRange = (editor: Editor, range: Range): Point | null => {\n  if (Range.isCollapsed(range)) {\n    return range.anchor\n  } else {\n    const [, end] = Range.edges(range)\n    const pointRef = Editor.pointRef(editor, end)\n    Transforms.delete(editor, { at: range })\n    return pointRef.unref()\n  }\n}\n\nexport const splitNodes: NodeTransforms['splitNodes'] = (\n  editor,\n  options = {}\n) => {\n  Editor.withoutNormalizing(editor, () => {\n    const { mode = 'lowest', voids = false } = options\n    let { match, at = editor.selection, height = 0, always = false } = options\n\n    if (match == null) {\n      match = n => Element.isElement(n) && Editor.isBlock(editor, n)\n    }\n\n    if (Range.isRange(at)) {\n      at = deleteRange(editor, at)\n    }\n\n    // If the target is a path, the default height-skipping and position\n    // counters need to account for us potentially splitting at a non-leaf.\n    if (Path.isPath(at)) {\n      const path = at\n      const point = Editor.point(editor, path)\n      const [parent] = Editor.parent(editor, path)\n      match = n => n === parent\n      height = point.path.length - path.length + 1\n      at = point\n      always = true\n    }\n\n    if (!at) {\n      return\n    }\n\n    const beforeRef = Editor.pointRef(editor, at, {\n      affinity: 'backward',\n    })\n    let afterRef: PointRef | undefined\n    try {\n      const [highest] = Editor.nodes(editor, { at, match, mode, voids })\n\n      if (!highest) {\n        return\n      }\n\n      const voidMatch = Editor.void(editor, { at, mode: 'highest' })\n      const nudge = 0\n\n      if (!voids && voidMatch) {\n        const [voidNode, voidPath] = voidMatch\n\n        if (Element.isElement(voidNode) && editor.isInline(voidNode)) {\n          let after = Editor.after(editor, voidPath)\n\n          if (!after) {\n            const text = { text: '' }\n            const afterPath = Path.next(voidPath)\n            Transforms.insertNodes(editor, text, { at: afterPath, voids })\n            after = Editor.point(editor, afterPath)!\n          }\n\n          at = after\n          always = true\n        }\n\n        const siblingHeight = at.path.length - voidPath.length\n        height = siblingHeight + 1\n        always = true\n      }\n\n      afterRef = Editor.pointRef(editor, at)\n      const depth = at.path.length - height\n      const [, highestPath] = highest\n      const lowestPath = at.path.slice(0, depth)\n      let position = height === 0 ? at.offset : at.path[depth] + nudge\n\n      for (const [node, path] of Editor.levels(editor, {\n        at: lowestPath,\n        reverse: true,\n        voids,\n      })) {\n        let split = false\n\n        if (\n          path.length < highestPath.length ||\n          path.length === 0 ||\n          (!voids && Element.isElement(node) && Editor.isVoid(editor, node))\n        ) {\n          break\n        }\n\n        const point = beforeRef.current!\n        const isEnd = Editor.isEnd(editor, point, path)\n\n        if (always || !beforeRef || !Editor.isEdge(editor, point, path)) {\n          split = true\n          const properties = Node.extractProps(node)\n          editor.apply({\n            type: 'split_node',\n            path,\n            position,\n            properties,\n          })\n        }\n\n        position = path[path.length - 1] + (split || isEnd ? 1 : 0)\n      }\n\n      if (options.at == null) {\n        const point = afterRef.current || Editor.end(editor, [])\n        Transforms.select(editor, point)\n      }\n    } finally {\n      beforeRef.unref()\n      afterRef?.unref()\n    }\n  })\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Transforms } from '../interfaces/transforms'\n\nexport const unsetNodes: NodeTransforms['unsetNodes'] = (\n  editor,\n  props,\n  options = {}\n) => {\n  if (!Array.isArray(props)) {\n    props = [props]\n  }\n\n  const obj: any = {}\n\n  for (const key of props) {\n    obj[key] = null\n  }\n\n  Transforms.setNodes(editor, obj, options)\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Editor } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { matchPath } from '../utils/match-path'\nimport { Element } from '../interfaces/element'\nimport { Range } from '../interfaces/range'\nimport { Transforms } from '../interfaces/transforms'\n\nexport const unwrapNodes: NodeTransforms['unwrapNodes'] = (\n  editor,\n  options = {}\n) => {\n  Editor.withoutNormalizing(editor, () => {\n    const { mode = 'lowest', split = false, voids = false } = options\n    let { at = editor.selection, match } = options\n\n    if (!at) {\n      return\n    }\n\n    if (match == null) {\n      match = Path.isPath(at)\n        ? matchPath(editor, at)\n        : n => Element.isElement(n) && Editor.isBlock(editor, n)\n    }\n\n    if (Path.isPath(at)) {\n      at = Editor.range(editor, at)\n    }\n\n    const rangeRef = Range.isRange(at) ? Editor.rangeRef(editor, at) : null\n    const matches = Editor.nodes(editor, { at, match, mode, voids })\n    const pathRefs = Array.from(\n      matches,\n      ([, p]) => Editor.pathRef(editor, p)\n      // unwrapNode will call liftNode which does not support splitting the node when nested.\n      // If we do not reverse the order and call it from top to the bottom, it will remove all blocks\n      // that wrap target node. So we reverse the order.\n    ).reverse()\n\n    for (const pathRef of pathRefs) {\n      const path = pathRef.unref()!\n      const [node] = Editor.node(editor, path)\n      let range = Editor.range(editor, path)\n\n      if (split && rangeRef) {\n        range = Range.intersection(rangeRef.current!, range)!\n      }\n\n      Transforms.liftNodes(editor, {\n        at: range,\n        match: n => Element.isAncestor(node) && node.children.includes(n),\n        voids,\n      })\n    }\n\n    if (rangeRef) {\n      rangeRef.unref()\n    }\n  })\n}\n","import { NodeTransforms } from '../interfaces/transforms/node'\nimport { Editor } from '../interfaces/editor'\nimport { Path } from '../interfaces/path'\nimport { matchPath } from '../utils/match-path'\nimport { Element } from '../interfaces/element'\nimport { Text } from '../interfaces/text'\nimport { Range } from '../interfaces/range'\nimport { Transforms } from '../interfaces/transforms'\n\nexport const wrapNodes: NodeTransforms['wrapNodes'] = (\n  editor,\n  element,\n  options = {}\n) => {\n  Editor.withoutNormalizing(editor, () => {\n    const { mode = 'lowest', split = false, voids = false } = options\n    let { match, at = editor.selection } = options\n\n    if (!at) {\n      return\n    }\n\n    if (match == null) {\n      if (Path.isPath(at)) {\n        match = matchPath(editor, at)\n      } else if (editor.isInline(element)) {\n        match = n =>\n          (Element.isElement(n) && Editor.isInline(editor, n)) || Text.isText(n)\n      } else {\n        match = n => Element.isElement(n) && Editor.isBlock(editor, n)\n      }\n    }\n\n    if (split && Range.isRange(at)) {\n      const [start, end] = Range.edges(at)\n      const rangeRef = Editor.rangeRef(editor, at, {\n        affinity: 'inward',\n      })\n      Transforms.splitNodes(editor, { at: end, match, voids })\n      Transforms.splitNodes(editor, { at: start, match, voids })\n      at = rangeRef.unref()!\n\n      if (options.at == null) {\n        Transforms.select(editor, at)\n      }\n    }\n\n    const roots = Array.from(\n      Editor.nodes(editor, {\n        at,\n        match: editor.isInline(element)\n          ? n => Element.isElement(n) && Editor.isBlock(editor, n)\n          : n => Editor.isEditor(n),\n        mode: 'lowest',\n        voids,\n      })\n    )\n\n    for (const [, rootPath] of roots) {\n      const a = Range.isRange(at)\n        ? Range.intersection(at, Editor.range(editor, rootPath))\n        : at\n\n      if (!a) {\n        continue\n      }\n\n      const matches = Array.from(\n        Editor.nodes(editor, { at: a, match, mode, voids })\n      )\n\n      if (matches.length > 0) {\n        const [first] = matches\n        const last = matches[matches.length - 1]\n        const [, firstPath] = first\n        const [, lastPath] = last\n\n        if (firstPath.length === 0 && lastPath.length === 0) {\n          // if there's no matching parent - usually means the node is an editor - don't do anything\n          continue\n        }\n\n        const commonPath = Path.equals(firstPath, lastPath)\n          ? Path.parent(firstPath)\n          : Path.common(firstPath, lastPath)\n\n        const range = Editor.range(editor, firstPath, lastPath)\n        const commonNodeEntry = Editor.node(editor, commonPath)\n        const [commonNode] = commonNodeEntry\n        const depth = commonPath.length + 1\n        const wrapperPath = Path.next(lastPath.slice(0, depth))\n        const wrapper = { ...element, children: [] }\n        Transforms.insertNodes(editor, wrapper, { at: wrapperPath, voids })\n\n        Transforms.moveNodes(editor, {\n          at: range,\n          match: n =>\n            Element.isAncestor(commonNode) && commonNode.children.includes(n),\n          to: wrapperPath.concat(0),\n          voids,\n        })\n      }\n    }\n  })\n}\n","import {\n  addMark,\n  deleteFragment,\n  Editor,\n  getDirtyPaths,\n  getFragment,\n  insertBreak,\n  insertFragment,\n  insertNode,\n  insertSoftBreak,\n  insertText,\n  normalizeNode,\n  removeMark,\n  shouldNormalize,\n} from './'\nimport { apply } from './core'\nimport {\n  above,\n  after,\n  before,\n  deleteBackward,\n  deleteForward,\n  edges,\n  elementReadOnly,\n  end,\n  first,\n  fragment,\n  getVoid,\n  hasBlocks,\n  hasInlines,\n  hasPath,\n  hasTexts,\n  isBlock,\n  isEdge,\n  isEmpty,\n  isEnd,\n  isNormalizing,\n  isStart,\n  last,\n  leaf,\n  levels,\n  marks,\n  next,\n  node,\n  nodes,\n  normalize,\n  parent,\n  path,\n  pathRef,\n  pathRefs,\n  point,\n  pointRef,\n  pointRefs,\n  positions,\n  previous,\n  range,\n  rangeRef,\n  rangeRefs,\n  setNormalizing,\n  shouldMergeNodesRemovePrevNode,\n  start,\n  string,\n  unhangRange,\n  withoutNormalizing,\n} from './editor'\nimport { deleteText } from './transforms-text'\nimport {\n  collapse,\n  deselect,\n  move,\n  select,\n  setPoint,\n  setSelection,\n} from './transforms-selection'\nimport {\n  insertNodes,\n  liftNodes,\n  mergeNodes,\n  moveNodes,\n  removeNodes,\n  setNodes,\n  splitNodes,\n  unsetNodes,\n  unwrapNodes,\n  wrapNodes,\n} from './transforms-node'\n\n/**\n * Create a new Slate `Editor` object.\n */\nexport const createEditor = (): Editor => {\n  const editor: Editor = {\n    children: [],\n    operations: [],\n    selection: null,\n    marks: null,\n    isElementReadOnly: () => false,\n    isInline: () => false,\n    isSelectable: () => true,\n    isVoid: () => false,\n    markableVoid: () => false,\n    onChange: () => {},\n\n    // Core\n    apply: (...args) => apply(editor, ...args),\n\n    // Editor\n    addMark: (...args) => addMark(editor, ...args),\n    deleteBackward: (...args) => deleteBackward(editor, ...args),\n    deleteForward: (...args) => deleteForward(editor, ...args),\n    deleteFragment: (...args) => deleteFragment(editor, ...args),\n    getFragment: (...args) => getFragment(editor, ...args),\n    insertBreak: (...args) => insertBreak(editor, ...args),\n    insertSoftBreak: (...args) => insertSoftBreak(editor, ...args),\n    insertFragment: (...args) => insertFragment(editor, ...args),\n    insertNode: (...args) => insertNode(editor, ...args),\n    insertText: (...args) => insertText(editor, ...args),\n    normalizeNode: (...args) => normalizeNode(editor, ...args),\n    removeMark: (...args) => removeMark(editor, ...args),\n    getDirtyPaths: (...args) => getDirtyPaths(editor, ...args),\n    shouldNormalize: (...args) => shouldNormalize(editor, ...args),\n\n    // Editor interface\n    above: (...args) => above(editor, ...args),\n    after: (...args) => after(editor, ...args),\n    before: (...args) => before(editor, ...args),\n    collapse: (...args) => collapse(editor, ...args),\n    delete: (...args) => deleteText(editor, ...args),\n    deselect: (...args) => deselect(editor, ...args),\n    edges: (...args) => edges(editor, ...args),\n    elementReadOnly: (...args) => elementReadOnly(editor, ...args),\n    end: (...args) => end(editor, ...args),\n    first: (...args) => first(editor, ...args),\n    fragment: (...args) => fragment(editor, ...args),\n    getMarks: (...args) => marks(editor, ...args),\n    hasBlocks: (...args) => hasBlocks(editor, ...args),\n    hasInlines: (...args) => hasInlines(editor, ...args),\n    hasPath: (...args) => hasPath(editor, ...args),\n    hasTexts: (...args) => hasTexts(editor, ...args),\n    insertNodes: (...args) => insertNodes(editor, ...args),\n    isBlock: (...args) => isBlock(editor, ...args),\n    isEdge: (...args) => isEdge(editor, ...args),\n    isEmpty: (...args) => isEmpty(editor, ...args),\n    isEnd: (...args) => isEnd(editor, ...args),\n    isNormalizing: (...args) => isNormalizing(editor, ...args),\n    isStart: (...args) => isStart(editor, ...args),\n    last: (...args) => last(editor, ...args),\n    leaf: (...args) => leaf(editor, ...args),\n    levels: (...args) => levels(editor, ...args),\n    liftNodes: (...args) => liftNodes(editor, ...args),\n    mergeNodes: (...args) => mergeNodes(editor, ...args),\n    move: (...args) => move(editor, ...args),\n    moveNodes: (...args) => moveNodes(editor, ...args),\n    next: (...args) => next(editor, ...args),\n    node: (...args) => node(editor, ...args),\n    nodes: (...args) => nodes(editor, ...args),\n    normalize: (...args) => normalize(editor, ...args),\n    parent: (...args) => parent(editor, ...args),\n    path: (...args) => path(editor, ...args),\n    pathRef: (...args) => pathRef(editor, ...args),\n    pathRefs: (...args) => pathRefs(editor, ...args),\n    point: (...args) => point(editor, ...args),\n    pointRef: (...args) => pointRef(editor, ...args),\n    pointRefs: (...args) => pointRefs(editor, ...args),\n    positions: (...args) => positions(editor, ...args),\n    previous: (...args) => previous(editor, ...args),\n    range: (...args) => range(editor, ...args),\n    rangeRef: (...args) => rangeRef(editor, ...args),\n    rangeRefs: (...args) => rangeRefs(editor, ...args),\n    removeNodes: (...args) => removeNodes(editor, ...args),\n    select: (...args) => select(editor, ...args),\n    setNodes: (...args) => setNodes(editor, ...args),\n    setNormalizing: (...args) => setNormalizing(editor, ...args),\n    setPoint: (...args) => setPoint(editor, ...args),\n    setSelection: (...args) => setSelection(editor, ...args),\n    splitNodes: (...args) => splitNodes(editor, ...args),\n    start: (...args) => start(editor, ...args),\n    string: (...args) => string(editor, ...args),\n    unhangRange: (...args) => unhangRange(editor, ...args),\n    unsetNodes: (...args) => unsetNodes(editor, ...args),\n    unwrapNodes: (...args) => unwrapNodes(editor, ...args),\n    void: (...args) => getVoid(editor, ...args),\n    withoutNormalizing: (...args) => withoutNormalizing(editor, ...args),\n    wrapNodes: (...args) => wrapNodes(editor, ...args),\n    shouldMergeNodesRemovePrevNode: (...args) =>\n      shouldMergeNodesRemovePrevNode(editor, ...args),\n  }\n\n  return editor\n}\n","import type { TElement, TText } from '@udecode/slate';\n\nimport { IS_FIREFOX, NodeApi } from '@udecode/slate';\nimport isEqual from 'lodash/isEqual.js';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { EdgeNodes } from '../types';\n\nexport const getMarkBoundaryAffinity = (\n  editor: SlateEditor,\n  markBoundary: EdgeNodes\n): 'backward' | 'forward' | undefined => {\n  const { marks, selection } = editor;\n  if (!selection) return;\n\n  const marksMatchLeaf = (leaf: TElement | TText) => {\n    return (\n      marks &&\n      isEqual(NodeApi.extractProps(leaf), marks) &&\n      Object.keys(marks).length > 1\n    );\n  };\n\n  const [backwardLeafEntry, forwardLeafEntry] = markBoundary;\n\n  if (!backwardLeafEntry || !forwardLeafEntry) {\n    const leafEntry = backwardLeafEntry || forwardLeafEntry;\n    const affinityIsTowardsLeaf = !marks || marksMatchLeaf(leafEntry[0]);\n\n    if (affinityIsTowardsLeaf) {\n      return leafEntry === backwardLeafEntry ? 'backward' : 'forward';\n    }\n    return;\n  }\n\n  const marksDirection: 'backward' | 'forward' | null =\n    marks &&\n    (() => {\n      if (backwardLeafEntry && marksMatchLeaf(backwardLeafEntry[0]))\n        return 'backward';\n      if (forwardLeafEntry && marksMatchLeaf(forwardLeafEntry[0]))\n        return 'forward';\n      return null;\n    })();\n\n  const selectionDirection =\n    selection.anchor.offset === 0 ? 'forward' : 'backward';\n\n  if (selectionDirection === 'backward' && marksDirection === 'forward')\n    return 'forward';\n\n  if (\n    IS_FIREFOX &&\n    selectionDirection === 'forward' &&\n    marksDirection !== 'backward'\n  )\n    return 'forward';\n\n  return 'backward';\n};\n","import { type TElement, type TText, ElementApi, NodeApi } from '@udecode/slate';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { EdgeNodes } from '../types';\n\nimport { getPluginByType } from '../../../plugin/getSlatePlugin';\n\nexport const isNodeAffinity = (\n  editor: SlateEditor,\n  node: TElement | TText,\n  affinity: 'directional' | 'hard' | 'outward'\n) => {\n  const marks = Object.keys(NodeApi.extractProps(node));\n  const keys = ElementApi.isElement(node) ? [node.type] : marks;\n  return keys.some(\n    (type) =>\n      getPluginByType(editor, type)?.rules.selection?.affinity === affinity\n  );\n};\n\nexport const isNodesAffinity = (\n  editor: SlateEditor,\n  edgeNodes: EdgeNodes,\n  affinity: 'directional' | 'hard' | 'outward'\n) => {\n  const [backwardLeafEntry, forwardLeafEntry] = edgeNodes;\n\n  return (\n    (backwardLeafEntry &&\n      isNodeAffinity(editor, backwardLeafEntry[0], affinity)) ||\n    (forwardLeafEntry && isNodeAffinity(editor, forwardLeafEntry[0], affinity))\n  );\n};\n","import type { Point } from 'slate';\n\nimport { ElementApi, NodeApi } from '@udecode/slate';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { EdgeNodes } from '../types';\n\nexport const setAffinitySelection = (\n  editor: SlateEditor,\n  edgeNodes: EdgeNodes,\n  affinity: 'backward' | 'forward'\n) => {\n  const setMarks = (marks: typeof editor.marks) => {\n    editor.marks = marks;\n    editor.api.onChange();\n  };\n\n  const select = (point: Point) => {\n    editor.tf.setSelection({ anchor: point, focus: point });\n  };\n\n  const [before, after] = edgeNodes;\n\n  if (affinity === 'backward') {\n    if (before === null) {\n      setMarks({});\n      return;\n    }\n\n    const beforeEnd = editor.api.end(before[1]);\n    if (beforeEnd) {\n      select(beforeEnd);\n    }\n\n    if (ElementApi.isElement(before[0])) return;\n    setMarks(null);\n\n    return;\n  }\n\n  if (before === null) {\n    setMarks(null);\n    return;\n  }\n\n  if (after === null) {\n    setMarks({});\n    return;\n  }\n\n  const beforeEnd = editor.api.end(before[1])!;\n  select(beforeEnd);\n\n  if (ElementApi.isElement(after[0])) {\n    return;\n  } else {\n    setMarks(NodeApi.extractProps(after[0]));\n  }\n};\n","import type { DebugConfig } from '../getCorePlugins';\n\nimport { createTSlatePlugin } from '../../plugin';\n\nexport type DebugErrorType =\n  | (string & {})\n  | 'DEFAULT'\n  | 'OPTION_UNDEFINED'\n  | 'OVERRIDE_MISSING'\n  | 'PLUGIN_DEPENDENCY_MISSING'\n  | 'PLUGIN_MISSING'\n  | 'USE_CREATE_PLUGIN'\n  | 'USE_ELEMENT_CONTEXT';\n\nexport type LogLevel = 'error' | 'info' | 'log' | 'warn';\n\nexport class PlateError extends Error {\n  constructor(\n    message: string,\n    public type: DebugErrorType = 'DEFAULT'\n  ) {\n    super(`[${type}] ${message}`);\n    this.name = 'PlateError';\n  }\n}\n\nexport const DebugPlugin = createTSlatePlugin<DebugConfig>({\n  key: 'debug',\n  options: {\n    isProduction: process.env.NODE_ENV === 'production',\n    logger: {\n      error: (message, type, details) =>\n        console.error(`${type ? `[${type}] ` : ''}${message}`, details),\n      info: (message, type, details) =>\n        console.info(`${type ? `[${type}] ` : ''}${message}`, details),\n      log: (message, type, details) =>\n        console.log(`${type ? `[${type}] ` : ''}${message}`, details),\n      warn: (message, type, details) =>\n        console.warn(`${type ? `[${type}] ` : ''}${message}`, details),\n    },\n    logLevel:\n      process.env.NODE_ENV === 'production' ? 'error' : ('log' as LogLevel),\n    throwErrors: true,\n  },\n}).extendEditorApi<DebugConfig['api']>(({ getOptions }) => {\n  const logLevels: LogLevel[] = ['error', 'warn', 'info', 'log'];\n\n  const log = (\n    level: LogLevel,\n    message: any,\n    type?: DebugErrorType,\n    details?: any\n  ) => {\n    if (process.env.NODE_ENV === 'production') return;\n\n    const options = getOptions();\n\n    if (options.isProduction && level === 'log') return;\n    if (logLevels.indexOf(level) <= logLevels.indexOf(options.logLevel!)) {\n      if (level === 'error' && options.throwErrors) {\n        throw new PlateError(message, type);\n      } else {\n        options.logger[level]?.(message, type, details);\n      }\n    }\n  };\n\n  return {\n    debug: {\n      error: (message, type, details) => log('error', message, type, details),\n      info: (message, type, details) => log('info', message, type, details),\n      log: (message, type, details) => log('log', message, type, details),\n      warn: (message, type, details) => log('warn', message, type, details),\n    },\n  };\n});\n","import type { Operation, ScrollIntoViewOptions, TRange } from '@udecode/slate';\n\nimport { bindFirst } from '@udecode/utils';\n\nimport type { SlateEditor } from '../../';\n\nimport { type PluginConfig, createTSlatePlugin } from '../../plugin';\nimport { withScrolling } from './withScrolling';\n\nexport const AUTO_SCROLL = new WeakMap<SlateEditor, boolean>();\n\nexport type AutoScrollOperationsMap = Partial<\n  Record<Operation['type'], boolean>\n>;\n\nexport type DomConfig = PluginConfig<\n  'dom',\n  {\n    /** Choose the first or last matching operation as the scroll target */\n    scrollMode?: ScrollMode;\n    /**\n     * Operations map; false to disable an operation, true or undefined to\n     * enable\n     */\n    scrollOperations?: AutoScrollOperationsMap;\n    /** Options passed to scrollIntoView */\n    scrollOptions?: ScrollIntoViewOptions;\n  }\n>;\n\n/** Mode for picking target op when multiple enabled */\nexport type ScrollMode = 'first' | 'last';\n\n/**\n * Placeholder plugin for DOM interaction, that could be replaced with\n * ReactPlugin.\n */\nexport const DOMPlugin = createTSlatePlugin<DomConfig>({\n  key: 'dom',\n  options: {\n    scrollMode: 'last',\n    scrollOperations: {\n      insert_node: true,\n      insert_text: true,\n    },\n    scrollOptions: {\n      scrollMode: 'if-needed',\n    },\n  },\n})\n  .extendEditorApi(({ editor }) => ({\n    isScrolling: () => {\n      return AUTO_SCROLL.get(editor) ?? false;\n    },\n  }))\n  .extendEditorTransforms(({ editor }) => ({\n    withScrolling: bindFirst(withScrolling, editor),\n  }))\n  .overrideEditor(({ api, editor, getOption, tf: { apply } }) => ({\n    transforms: {\n      apply(operation) {\n        if (api.isScrolling()) {\n          apply(operation);\n\n          // Check if this op type is enabled (default true)\n          const scrollOperations = getOption('scrollOperations')!;\n\n          if (!scrollOperations[operation.type]) return;\n\n          // Gather enabled ops in this batch\n          const matched = editor.operations.filter(\n            (op) => !!scrollOperations[op.type]\n          );\n\n          if (matched.length === 0) return;\n\n          const mode = getOption('scrollMode')!;\n\n          // Pick target\n          const targetOp = mode === 'first' ? matched[0] : matched.at(-1);\n\n          if (!targetOp) return;\n\n          const { offset, path } = (targetOp as any).path\n            ? (targetOp as any as { path: number[]; offset?: number })\n            : {};\n\n          if (!path) return;\n\n          const scrollOptions = getOption('scrollOptions')!;\n\n          const scrollTarget = {\n            offset: offset ?? 0,\n            path,\n          };\n\n          api.scrollIntoView(scrollTarget, scrollOptions);\n\n          return;\n        }\n\n        return apply(operation);\n      },\n    },\n  }))\n  .overrideEditor(({ editor, tf: { apply } }) => ({\n    transforms: {\n      apply(operation) {\n        if (operation.type === 'set_selection') {\n          const { properties } = operation;\n          editor.dom.prevSelection = properties as TRange | null;\n          apply(operation);\n          editor.dom.currentKeyboardEvent = null;\n          return;\n        }\n\n        apply(operation);\n      },\n    },\n  }));\n","import type { ScrollIntoViewOptions } from '@udecode/slate';\n\nimport isUndefined from 'lodash/isUndefined.js';\nimport omitBy from 'lodash/omitBy.js';\n\nimport type { SlateEditor } from '../../editor';\nimport type { AutoScrollOperationsMap, ScrollMode } from './DOMPlugin';\n\nimport { AUTO_SCROLL, DOMPlugin } from './DOMPlugin';\n\nexport interface WithAutoScrollOptions {\n  mode?: ScrollMode;\n  operations?: AutoScrollOperationsMap;\n  scrollOptions?: ScrollIntoViewOptions;\n}\n\nexport const withScrolling = (\n  editor: SlateEditor,\n  fn: () => void,\n  options?: WithAutoScrollOptions\n) => {\n  const prevOptions = editor.getOptions(DOMPlugin);\n  const prevAutoScroll = AUTO_SCROLL.get(editor) ?? false;\n\n  if (options) {\n    const ops = {\n      ...prevOptions,\n      ...omitBy(options, isUndefined),\n    };\n\n    editor.setOptions(DOMPlugin, ops);\n  }\n  AUTO_SCROLL.set(editor, true);\n  fn();\n  // reset\n  AUTO_SCROLL.set(editor, prevAutoScroll);\n  editor.setOptions(DOMPlugin, prevOptions);\n};\n","import { bindFirst } from '@udecode/utils';\n\nimport { createSlatePlugin } from '../../plugin';\nimport { deserializeHtml, parseHtmlDocument } from './utils';\n\n/**\n * Enables support for deserializing inserted content from HTML format to Slate\n * format and serializing Slate content to HTML format.\n */\nexport const HtmlPlugin = createSlatePlugin({\n  key: 'html',\n})\n  .extendApi(({ editor }) => ({\n    deserialize: bindFirst(deserializeHtml, editor),\n  }))\n  .extend({\n    parser: {\n      format: 'text/html',\n      deserialize: ({ api, data }) => {\n        const document = parseHtmlDocument(data);\n\n        return api.html.deserialize({\n          element: document.body,\n        });\n      },\n    },\n  });\n","export const CARRIAGE_RETURN = '\\u000D';\n\nexport const LINE_FEED = '\\u000A';\n\nexport const NO_BREAK_SPACE = '\\u00A0';\n\nexport const SPACE = '\\u0020';\n\nexport const TAB = '\\u0009';\n\nexport const ZERO_WIDTH_SPACE = '\\u200B';\n","export const isHtmlElement = (node: Node): node is Element =>\n  node.nodeType === Node.ELEMENT_NODE;\n","type Callback = (node: Node) => boolean;\n\n/**\n * Depth-first pre-order tree traverse the given HTML node and calls the given\n * callback for each node. see:\n * https://en.wikipedia.org/wiki/Tree_traversal#Pre-order_(NLR)\n *\n * @param callback Returns a boolean indicating whether traversal should be\n *   continued\n */\nexport const traverseHtmlNode = (node: Node, callback: Callback): void => {\n  const keepTraversing = callback(node);\n\n  if (!keepTraversing) {\n    return;\n  }\n\n  let child = node.firstChild;\n\n  while (child) {\n    const currentChild = child;\n    const previousChild = child.previousSibling;\n    child = child.nextSibling;\n\n    traverseHtmlNode(currentChild, callback);\n\n    if (\n      // An unwrap was made. Need to compute the next child again.\n      !currentChild.previousSibling &&\n      !currentChild.nextSibling &&\n      !currentChild.parentNode &&\n      child &&\n      previousChild !== child.previousSibling &&\n      child.parentNode\n    ) {\n      child = previousChild ? previousChild.nextSibling : node.firstChild;\n    } else if (\n      // A list was created. Need to compute the next child again.\n      !currentChild.previousSibling &&\n      !currentChild.nextSibling &&\n      !currentChild.parentNode &&\n      child &&\n      !child.previousSibling &&\n      !child.nextSibling &&\n      !child.parentNode\n    ) {\n      if (previousChild) {\n        child = previousChild.nextSibling\n          ? previousChild.nextSibling.nextSibling\n          : null;\n      } else if (node.firstChild) {\n        child = node.firstChild.nextSibling;\n      }\n    }\n  }\n};\n","import { isHtmlElement } from './isHtmlElement';\nimport { traverseHtmlNode } from './traverseHtmlNode';\n\ntype Callback = (node: Element) => boolean;\n\n/**\n * Traverse the HTML elements of the given HTML node.\n *\n * @param rootNode The root HTML node to traverse.\n * @param callback The callback to call for each HTML element.\n */\nexport const traverseHtmlElements = (\n  rootNode: Node,\n  callback: Callback\n): void => {\n  traverseHtmlNode(rootNode, (node) => {\n    if (!isHtmlElement(node)) {\n      return true;\n    }\n\n    return callback(node);\n  });\n};\n","import { LINE_FEED } from '../constants';\nimport { traverseHtmlElements } from './traverseHtmlElements';\n\n/** Replace BR elements with line feeds. */\nexport const cleanHtmlBrElements = (rootNode: Node): void => {\n  traverseHtmlElements(rootNode, (element) => {\n    if (element.tagName !== 'BR') {\n      return true;\n    }\n\n    const replacementTextNode = document.createTextNode(LINE_FEED);\n\n    if (element.parentElement) {\n      element.parentElement.replaceChild(replacementTextNode, element);\n    }\n\n    return false;\n  });\n};\n","/** Replace \\r\\n and \\r with \\n */\nexport const cleanHtmlCrLf = (html: string): string => {\n  return html.replaceAll(/\\r\\n|\\r/g, '\\n');\n};\n","import { traverseHtmlElements } from './traverseHtmlElements';\n\nconst ALLOWED_EMPTY_ELEMENTS = new Set(['BR', 'IMG', 'TD', 'TH']);\n\nconst isEmpty = (element: Element): boolean => {\n  return (\n    !ALLOWED_EMPTY_ELEMENTS.has(element.nodeName) && !element.innerHTML.trim()\n  );\n};\n\nconst removeIfEmpty = (element: Element): void => {\n  if (isEmpty(element)) {\n    const { parentElement } = element;\n\n    element.remove();\n\n    if (parentElement) {\n      removeIfEmpty(parentElement);\n    }\n  }\n};\n\n/** Remove empty elements from rootNode. Allowed empty elements: BR, IMG. */\nexport const cleanHtmlEmptyElements = (rootNode: Node): void => {\n  traverseHtmlElements(rootNode, (element) => {\n    removeIfEmpty(element);\n\n    return true;\n  });\n};\n","/**\n * Replace `element` tag name by `tagName`. Attributes, innerHTML and parent\n * relationship is kept.\n */\nexport const replaceTagName = (element: Element, tagName: string): Element => {\n  const newElement = document.createElement(tagName);\n\n  newElement.innerHTML = element.innerHTML;\n\n  for (const { name } of element.attributes) {\n    const value = element.getAttribute(name);\n\n    if (value) {\n      newElement.setAttribute(name, value);\n    }\n  }\n\n  if (element.parentNode) {\n    element.parentNode.replaceChild(newElement, element);\n  }\n\n  return newElement;\n};\n","import { replaceTagName } from './replaceTagName';\nimport { traverseHtmlElements } from './traverseHtmlElements';\n\n/**\n * Replace FONT elements with SPAN elements if there is textContent (remove\n * otherwise).\n */\nexport const cleanHtmlFontElements = (rootNode: Node): void => {\n  traverseHtmlElements(rootNode, (element) => {\n    if (element.tagName === 'FONT') {\n      if (element.textContent) {\n        replaceTagName(element, 'span');\n      } else {\n        element.remove();\n      }\n    }\n\n    return true;\n  });\n};\n","/** If href starts with '#'. */\nexport const isHtmlFragmentHref = (href: string): boolean =>\n  href.startsWith('#');\n","/** Unwrap the given HTML element. */\nexport const unwrapHtmlElement = (element: Element): void => {\n  element.outerHTML = element.innerHTML;\n};\n","import { isHtmlFragmentHref } from './isHtmlFragmentHref';\nimport { traverseHtmlElements } from './traverseHtmlElements';\nimport { unwrapHtmlElement } from './unwrapHtmlElement';\n\n/** Remove fragment hrefs and spans without inner text. */\nexport const cleanHtmlLinkElements = (rootNode: Node): void => {\n  traverseHtmlElements(rootNode, (element) => {\n    if (element.tagName !== 'A') {\n      return true;\n    }\n\n    const href = element.getAttribute('href');\n\n    if (!href || isHtmlFragmentHref(href)) {\n      unwrapHtmlElement(element);\n    }\n    if (href && element.querySelector('img')) {\n      for (const span of element.querySelectorAll('span')) {\n        if (!span.textContent) {\n          unwrapHtmlElement(span);\n        }\n      }\n    }\n\n    return true;\n  });\n};\n","export const isHtmlText = (node: Node): node is Text =>\n  node.nodeType === Node.TEXT_NODE;\n","import { isHtmlText } from './isHtmlText';\nimport { traverseHtmlNode } from './traverseHtmlNode';\n\ntype Callback = (node: Text) => boolean;\n\nexport const traverseHtmlTexts = (rootNode: Node, callback: Callback): void => {\n  traverseHtmlNode(rootNode, (node) => {\n    if (!isHtmlText(node)) {\n      return true;\n    }\n\n    return callback(node);\n  });\n};\n","import {\n  CARRIAGE_RETURN,\n  LINE_FEED,\n  NO_BREAK_SPACE,\n  SPACE,\n} from '../constants';\nimport { traverseHtmlTexts } from './traverseHtmlTexts';\n\nexport const cleanHtmlTextNodes = (rootNode: Node): void => {\n  traverseHtmlTexts(rootNode, (textNode) => {\n    if (\n      /^\\n\\s*$/.test(textNode.data) &&\n      (textNode.previousElementSibling || textNode.nextElementSibling)\n    ) {\n      textNode.remove();\n\n      return true;\n    }\n\n    textNode.data = textNode.data.replaceAll(/\\n\\s*/g, '\\n');\n\n    if (\n      textNode.data.includes(CARRIAGE_RETURN) ||\n      textNode.data.includes(LINE_FEED) ||\n      textNode.data.includes(NO_BREAK_SPACE)\n    ) {\n      const hasSpace = textNode.data.includes(SPACE);\n      const hasNonWhitespace = /\\S/.test(textNode.data);\n      const hasLineFeed = textNode.data.includes(LINE_FEED);\n\n      if (!(hasSpace || hasNonWhitespace) && !hasLineFeed) {\n        if (textNode.data === NO_BREAK_SPACE) {\n          textNode.data = SPACE;\n\n          return true;\n        }\n\n        textNode.remove();\n\n        return true;\n      }\n      if (\n        textNode.previousSibling &&\n        textNode.previousSibling.nodeName === 'BR' &&\n        textNode.parentElement\n      ) {\n        textNode.previousSibling.remove();\n\n        const matches = /^[\\n\\r]+/.exec(textNode.data);\n        const offset = matches ? matches[0].length : 0;\n\n        textNode.data = textNode.data\n          .slice(Math.max(0, offset))\n          .replaceAll(new RegExp(LINE_FEED, 'g'), SPACE)\n          .replaceAll(new RegExp(CARRIAGE_RETURN, 'g'), SPACE);\n        textNode.data = `\\n${textNode.data}`;\n      } else {\n        textNode.data = textNode.data\n          .replaceAll(new RegExp(LINE_FEED, 'g'), SPACE)\n          .replaceAll(new RegExp(CARRIAGE_RETURN, 'g'), SPACE);\n      }\n    }\n\n    return true;\n  });\n};\n","/**\n * # Methodology\n *\n * ## Step 1. Get the list of all standard tag names\n *\n * Go to https://developer.mozilla.org/en-US/docs/Web/HTML/Element and run the\n * following in the console to generate a JSON array of tag names:\n *\n * ```js\n * JSON.stringify(\n *   Array.from(document.querySelectorAll('article table td:first-child'))\n *     .map((td) => {\n *       const body = document.createElement('body');\n *       body.innerHTML = td.textContent;\n *       return body.firstChild?.tagName;\n *     })\n *     .filter((tagName) => tagName)\n * );\n * ```\n *\n * Output (as of 2023-11-06):\n *\n * ```json\n * '[\"BASE\",\"LINK\",\"META\",\"STYLE\",\"TITLE\",\"ADDRESS\",\"ARTICLE\",\"ASIDE\",\"FOOTER\",\"HEADER\",\"H1\",\"HGROUP\",\"MAIN\",\"NAV\",\"SECTION\",\"SEARCH\",\"BLOCKQUOTE\",\"DD\",\"DIV\",\"DL\",\"DT\",\"FIGCAPTION\",\"FIGURE\",\"HR\",\"LI\",\"MENU\",\"OL\",\"P\",\"PRE\",\"UL\",\"A\",\"ABBR\",\"B\",\"BDI\",\"BDO\",\"BR\",\"CITE\",\"CODE\",\"DATA\",\"DFN\",\"EM\",\"I\",\"KBD\",\"MARK\",\"Q\",\"RP\",\"RT\",\"RUBY\",\"S\",\"SAMP\",\"SMALL\",\"SPAN\",\"STRONG\",\"SUB\",\"SUP\",\"TIME\",\"U\",\"VAR\",\"WBR\",\"AREA\",\"AUDIO\",\"IMG\",\"MAP\",\"TRACK\",\"VIDEO\",\"EMBED\",\"IFRAME\",\"OBJECT\",\"PICTURE\",\"PORTAL\",\"SOURCE\",\"svg\",\"math\",\"CANVAS\",\"NOSCRIPT\",\"SCRIPT\",\"DEL\",\"INS\",\"TABLE\",\"BUTTON\",\"DATALIST\",\"FIELDSET\",\"FORM\",\"INPUT\",\"LABEL\",\"LEGEND\",\"METER\",\"OPTGROUP\",\"OPTION\",\"OUTPUT\",\"PROGRESS\",\"SELECT\",\"TEXTAREA\",\"DETAILS\",\"DIALOG\",\"SUMMARY\",\"SLOT\",\"TEMPLATE\",\"ACRONYM\",\"BIG\",\"CENTER\",\"CONTENT\",\"DIR\",\"FONT\",\"IMG\",\"MARQUEE\",\"MENUITEM\",\"NOBR\",\"NOEMBED\",\"NOFRAMES\",\"PARAM\",\"PLAINTEXT\",\"RB\",\"RTC\",\"SHADOW\",\"STRIKE\",\"TT\",\"XMP\"]'\n * ```\n *\n * ## Step 2. For each tag name, determine the default browser style\n *\n * Open an empty HTML file in the browser and run the following in the console:\n *\n * ```js\n * const tagNames = JSON.parse(<JSON string from step 1>);\n *\n * JSON.stringify(\n *   tagNames.filter((tagName) => {\n *     const element = document.createElement(tagName);\n *     document.body.appendChild(element);\n *     const display = window.getComputedStyle(element).display;\n *     element.remove();\n *     return display.startsWith('inline');\n *   })\n * );\n * ```\n *\n * Place the result in the array below (accurate as of 2023-11-06).\n */\n\nexport const inlineTagNames = new Set([\n  'A',\n  'ABBR',\n  'ACRONYM',\n  'B',\n  'BDI',\n  'BDO',\n  'BIG',\n  'BR',\n  'BUTTON',\n  'CANVAS',\n  'CITE',\n  'CODE',\n  'CONTENT',\n  'DATA',\n  'DEL',\n  'DFN',\n  'EM',\n  'EMBED',\n  'FONT',\n  'I',\n  'IFRAME',\n  'IMG',\n  'IMG',\n  'INPUT',\n  'INS',\n  'KBD',\n  'LABEL',\n  'MAP',\n  'MARK',\n  'MARQUEE',\n  'math',\n  'MENUITEM',\n  'METER',\n  'NOBR',\n  'OBJECT',\n  'OUTPUT',\n  'PICTURE',\n  'PORTAL',\n  'PROGRESS',\n  'Q',\n  'S',\n  'SAMP',\n  'SELECT',\n  'SHADOW',\n  'SMALL',\n  'SOURCE',\n  'SPAN',\n  'STRIKE',\n  'STRONG',\n  'SUB',\n  'SUP',\n  'svg',\n  'TEXTAREA',\n  'TIME',\n  'TRACK',\n  'TT',\n  'U',\n  'VAR',\n  'VIDEO',\n  'WBR',\n]);\n","import { inlineTagNames } from './inlineTagNames';\nimport { isHtmlElement } from './isHtmlElement';\n\nexport const isHtmlInlineElement = (node: Node): boolean => {\n  if (!isHtmlElement(node)) return false;\n\n  const element = node as HTMLElement;\n\n  const tagNameIsInline = inlineTagNames.has(element.tagName);\n\n  /**\n   * Valid display values include 'inline flow'. We only care about the first\n   * part.\n   */\n  const displayProperty = element.style.display.split(' ')[0];\n\n  if (displayProperty === '') {\n    return tagNameIsInline;\n  }\n  if (displayProperty.startsWith('inline')) {\n    return true;\n  }\n  if (displayProperty === 'inherit' && element.parentElement) {\n    return isHtmlInlineElement(element.parentElement);\n  }\n  /**\n   * Handle all special values manually, so that any unhandled values can be\n   * assumed to be block.\n   *\n   * Note: Ideally, content inside `display: none` elements should not be\n   * parsed. However, if such elements are parsed, it's best for their inline or\n   * block status to be left unchanged.\n   */\n  if (\n    ['contents', 'initial', 'none', 'revert', 'revert-layer', 'unset'].includes(\n      displayProperty\n    )\n  ) {\n    return tagNameIsInline;\n  }\n\n  return false;\n};\n","import { isHtmlElement } from './isHtmlElement';\nimport { isHtmlInlineElement } from './isHtmlInlineElement';\n\nexport const isHtmlBlockElement = (node: Node): boolean => {\n  if (!isHtmlElement(node)) return false;\n\n  const element = node as HTMLElement;\n\n  return !isHtmlInlineElement(element);\n};\n","export const isHtmlTable = (element: Element) => element.nodeName === 'TABLE';\n","import { isHtmlBlockElement } from './isHtmlBlockElement';\nimport { isHtmlTable } from './isHtmlTable';\nimport { traverseHtmlElements } from './traverseHtmlElements';\n\n/**\n * Set HTML blocks mark styles to a new child span element if any. This allows\n * Plate to use block marks.\n */\nexport const copyBlockMarksToSpanChild = (rootNode: Node) => {\n  traverseHtmlElements(rootNode, (element) => {\n    const el = element as HTMLElement;\n\n    const styleAttribute = element.getAttribute('style');\n\n    if (!styleAttribute) return true;\n    if (isHtmlBlockElement(el) && !isHtmlTable(el)) {\n      const {\n        style: {\n          backgroundColor,\n          color,\n          fontFamily,\n          fontSize,\n          fontStyle,\n          fontWeight,\n          textDecoration,\n        },\n      } = el;\n\n      if (\n        backgroundColor ||\n        color ||\n        fontFamily ||\n        fontSize ||\n        fontStyle ||\n        fontWeight ||\n        textDecoration\n      ) {\n        const span = document.createElement('span');\n\n        if (!['inherit', 'initial'].includes(color)) {\n          span.style.color = color;\n        }\n\n        span.style.fontFamily = fontFamily;\n        span.style.fontSize = fontSize;\n\n        if (!['inherit', 'initial', 'normal'].includes(color)) {\n          span.style.fontStyle = fontStyle;\n        }\n        if (![400, 'normal'].includes(fontWeight)) {\n          span.style.fontWeight = fontWeight;\n        }\n\n        span.style.textDecoration = textDecoration;\n\n        span.innerHTML = el.innerHTML;\n        element.innerHTML = span.outerHTML;\n      }\n    }\n\n    return true;\n  });\n};\n","import type { TrimEndRule, TrimStartRule } from './types';\n\nexport const collapseString = (\n  text: string,\n  {\n    shouldCollapseWhiteSpace = true,\n    trimEnd = 'collapse',\n    trimStart = 'collapse',\n    whiteSpaceIncludesNewlines = true,\n  }: {\n    shouldCollapseWhiteSpace?: boolean;\n    trimEnd?: TrimEndRule;\n    trimStart?: TrimStartRule;\n    whiteSpaceIncludesNewlines?: boolean;\n  } = {}\n) => {\n  if (trimStart === 'all') {\n    text = text.replace(/^\\s+/, '');\n  }\n  if (trimEnd === 'single-newline') {\n    // Strip at most one newline from the end\n    text = text.replace(/\\n$/, '');\n  }\n  if (shouldCollapseWhiteSpace) {\n    if (whiteSpaceIncludesNewlines) {\n      text = text.replaceAll(/\\s+/g, ' ');\n    } else {\n      // Collapse horizontal whitespace\n      text = text.replaceAll(/[^\\S\\n\\r]+/g, ' ');\n\n      /**\n       * Trim horizontal whitespace from the start and end of lines (behavior of\n       * pre-line).\n       */\n      text = text.replaceAll(/^[^\\S\\n\\r]+/gm, '');\n      text = text.replaceAll(/[^\\S\\n\\r]+$/gm, '');\n    }\n  }\n\n  return text;\n};\n","import { isHtmlBlockElement } from '../isHtmlBlockElement';\n\nexport const isLastNonEmptyTextOfInlineFormattingContext = (\n  initialText: Text\n): boolean => {\n  let currentNode: Node | null = initialText;\n\n  while (true) {\n    if (currentNode.nextSibling) {\n      currentNode = currentNode.nextSibling;\n    } else {\n      // If there is no next sibling, ascend to the parent node\n      currentNode = currentNode.parentElement;\n\n      // If the parent node is a block, we've reached the end\n      if (currentNode && isHtmlBlockElement(currentNode)) {\n        return true;\n      }\n\n      // Otherwise, continue to the next sibling of the parent node\n      currentNode = currentNode?.nextSibling || null;\n    }\n    // If there's no next node, we've reached the end\n    if (!currentNode) {\n      return true;\n    }\n    // If the next node is a block, we've reached the end\n    if (isHtmlBlockElement(currentNode)) {\n      return true;\n    }\n    // If the next node is a non-empty text node, we're not at the end\n    if ((currentNode.textContent || '').length > 0) {\n      return false;\n    }\n\n    // Otherwise, continue to the next node\n  }\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nexport const upsertInlineFormattingContext = (\n  state: CollapseWhiteSpaceState\n) => {\n  if (state.inlineFormattingContext) {\n    state.inlineFormattingContext.atStart = false;\n  } else {\n    state.inlineFormattingContext = {\n      atStart: true,\n      lastHasTrailingWhiteSpace: false,\n    };\n  }\n};\n\nexport const endInlineFormattingContext = (state: CollapseWhiteSpaceState) => {\n  state.inlineFormattingContext = null;\n};\n","import type {\n  CollapseWhiteSpaceState,\n  TrimEndRule,\n  TrimStartRule,\n} from './types';\n\nimport { collapseString } from './collapseString';\nimport { isLastNonEmptyTextOfInlineFormattingContext } from './isLastNonEmptyTextOfInlineFormattingContext';\nimport { upsertInlineFormattingContext } from './stateTransforms';\n\nexport const collapseWhiteSpaceText = (\n  text: Text,\n  state: CollapseWhiteSpaceState\n) => {\n  const textContent = text.textContent || '';\n  const isWhiteSpaceOnly = textContent.trim() === '';\n\n  /**\n   * Do not start an inline formatting context with a text node containing only\n   * white space.\n   */\n  if (state.inlineFormattingContext || !isWhiteSpaceOnly) {\n    upsertInlineFormattingContext(state);\n  }\n\n  const { whiteSpaceRule } = state;\n\n  /**\n   * Note: Due to the way HTML strings are parsed in htmlStringToDOMNode, up to\n   * one newline is already trimmed from the start of text nodes inside <pre>\n   * elements. If we do so again here, we may remove too many newlines. This\n   * only applies to actual <pre> elements, not elements with the white-space\n   * CSS property.\n   */\n  const trimStart: TrimStartRule = (() => {\n    if (whiteSpaceRule !== 'normal') return 'collapse';\n    if (\n      !state.inlineFormattingContext ||\n      state.inlineFormattingContext.atStart ||\n      state.inlineFormattingContext.lastHasTrailingWhiteSpace\n    )\n      return 'all';\n\n    return 'collapse';\n  })();\n\n  const trimEnd: TrimEndRule = (() => {\n    if (whiteSpaceRule === 'normal') return 'collapse';\n    if (isLastNonEmptyTextOfInlineFormattingContext(text))\n      return 'single-newline';\n\n    return 'collapse';\n  })();\n\n  const shouldCollapseWhiteSpace: boolean = {\n    normal: true,\n    pre: false,\n    'pre-line': true,\n  }[whiteSpaceRule];\n\n  const whiteSpaceIncludesNewlines = whiteSpaceRule !== 'pre-line';\n\n  const collapsedTextContent = collapseString(textContent || '', {\n    shouldCollapseWhiteSpace,\n    trimEnd,\n    trimStart,\n    whiteSpaceIncludesNewlines,\n  });\n\n  if (state.inlineFormattingContext && shouldCollapseWhiteSpace) {\n    state.inlineFormattingContext.lastHasTrailingWhiteSpace =\n      collapsedTextContent.endsWith(' ');\n  }\n\n  text.textContent = collapsedTextContent;\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nimport { isHtmlElement } from '../isHtmlElement';\nimport { isHtmlText } from '../isHtmlText';\nimport { collapseWhiteSpaceChildren } from './collapseWhiteSpaceChildren';\nimport { collapseWhiteSpaceElement } from './collapseWhiteSpaceElement';\nimport { collapseWhiteSpaceText } from './collapseWhiteSpaceText';\n\nexport const collapseWhiteSpaceNode = (\n  node: Node,\n  state: CollapseWhiteSpaceState\n) => {\n  if (isHtmlElement(node)) {\n    collapseWhiteSpaceElement(node as HTMLElement, state);\n\n    return;\n  }\n  if (isHtmlText(node)) {\n    collapseWhiteSpaceText(node as Text, state);\n\n    return;\n  }\n\n  collapseWhiteSpaceChildren(node, state);\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nimport { collapseWhiteSpaceNode } from './collapseWhiteSpaceNode';\n\nexport const collapseWhiteSpaceChildren = (\n  node: Node,\n  state: CollapseWhiteSpaceState\n) => {\n  const childNodes = Array.from(node.childNodes);\n\n  for (const childNode of childNodes) {\n    collapseWhiteSpaceNode(childNode, state);\n  }\n};\n","import type { WhiteSpaceRule } from './types';\n\nexport const inferWhiteSpaceRule = (\n  element: HTMLElement\n): WhiteSpaceRule | null => {\n  const whiteSpaceProperty = element.style.whiteSpace;\n\n  switch (whiteSpaceProperty) {\n    case 'break-spaces':\n    case 'pre':\n    case 'pre-wrap': {\n      return 'pre';\n    }\n    case 'normal':\n    case 'nowrap': {\n      return 'normal';\n    }\n    case 'pre-line': {\n      return 'pre-line';\n    }\n  }\n\n  if (element.tagName === 'PRE') {\n    return 'pre';\n  }\n  if (whiteSpaceProperty === 'initial') {\n    return 'normal';\n  }\n\n  return null;\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nimport { isHtmlInlineElement } from '../isHtmlInlineElement';\nimport { collapseWhiteSpaceChildren } from './collapseWhiteSpaceChildren';\nimport { inferWhiteSpaceRule } from './inferWhiteSpaceRule';\nimport { endInlineFormattingContext } from './stateTransforms';\n\n/**\n * Note: We do not want to start an inline formatting context until we encounter\n * a text node.\n */\nexport const collapseWhiteSpaceElement = (\n  element: HTMLElement,\n  state: CollapseWhiteSpaceState\n) => {\n  const isInlineElement = isHtmlInlineElement(element);\n  const previousWhiteSpaceRule = state.whiteSpaceRule;\n  const inferredWhiteSpaceRule = inferWhiteSpaceRule(element);\n\n  if (inferredWhiteSpaceRule) {\n    state.whiteSpaceRule = inferredWhiteSpaceRule;\n  }\n  // End any existing inline formatting context\n  if (!isInlineElement) {\n    endInlineFormattingContext(state);\n  }\n\n  collapseWhiteSpaceChildren(element, state);\n\n  // Do not let inline formatting context break out of block elements\n  if (!isInlineElement) {\n    endInlineFormattingContext(state);\n  }\n\n  // Restore previous whiteSpaceRule\n  state.whiteSpaceRule = previousWhiteSpaceRule;\n};\n","import type { CollapseWhiteSpaceState } from './types';\n\nimport { collapseWhiteSpaceElement } from './collapseWhiteSpaceElement';\n\n// Entrypoint\nexport const collapseWhiteSpace = (element: HTMLElement) => {\n  const clonedElement = element.cloneNode(true) as HTMLElement;\n\n  // Mutable state object\n  const state: CollapseWhiteSpaceState = {\n    inlineFormattingContext: null,\n    whiteSpaceRule: 'normal',\n  };\n\n  collapseWhiteSpaceElement(clonedElement, state);\n\n  return clonedElement;\n};\n","import type { Descendant } from '@udecode/slate';\n\nimport { jsx } from 'slate-hyperscript';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { deserializeHtmlNodeChildren } from './deserializeHtmlNodeChildren';\n\njsx;\n\n/** Deserialize HTML body element to Fragment. */\nexport const htmlBodyToFragment = (\n  editor: SlateEditor,\n  element: HTMLElement\n): Descendant[] | undefined => {\n  if (element.nodeName === 'BODY') {\n    return jsx(\n      'fragment',\n      {},\n      deserializeHtmlNodeChildren(editor, element)\n    ) as Descendant[];\n  }\n};\n","import type { SlateEditor } from '../../../editor';\nimport type { DeserializeHtmlChildren } from '../types';\n\nimport { isSlateNode } from '../../../static';\nimport { deserializeHtmlNode } from './deserializeHtmlNode';\n\nexport const deserializeHtmlNodeChildren = (\n  editor: SlateEditor,\n  node: ChildNode | HTMLElement,\n  isSlateParent = false\n): DeserializeHtmlChildren[] => {\n  return Array.from(node.childNodes).flatMap((child) => {\n    if (\n      child.nodeType === 1 &&\n      !isSlateNode(child as HTMLElement) &&\n      isSlateParent\n    ) {\n      return deserializeHtmlNodeChildren(\n        editor,\n        child as HTMLElement,\n        isSlateParent\n      );\n    }\n\n    return deserializeHtmlNode(editor)(child);\n  }) as DeserializeHtmlChildren[];\n};\n","/** Deserialize HTML to break line. */\nexport const htmlBrToNewLine = (node: ChildNode | HTMLElement) => {\n  if (node.nodeName === 'BR') {\n    return '\\n';\n  }\n};\n","import type { Descendant } from '@udecode/slate';\n\nimport { jsx } from 'slate-hyperscript';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { isSlateVoid } from '../../../static';\nimport { deserializeHtmlNodeChildren } from './deserializeHtmlNodeChildren';\nimport { pipeDeserializeHtmlElement } from './pipeDeserializeHtmlElement';\n\n/** Deserialize HTML to Element. */\nexport const htmlElementToElement = (\n  editor: SlateEditor,\n  element: HTMLElement,\n  isSlate = false\n) => {\n  const deserialized = pipeDeserializeHtmlElement(editor, element);\n\n  if (deserialized) {\n    const { node, withoutChildren } = deserialized;\n\n    let descendants =\n      node.children ??\n      (deserializeHtmlNodeChildren(editor, element, isSlate) as Descendant[]);\n\n    if (descendants.length === 0 || withoutChildren || isSlateVoid(element)) {\n      descendants = [{ text: '' }];\n    }\n\n    return jsx('element', node, descendants) as Descendant;\n  }\n};\n","import { type AnyObject, type Nullable, isDefined } from '@udecode/utils';\nimport castArray from 'lodash/castArray.js';\n\nimport type { SlateEditor } from '../../../editor';\nimport type {\n  AnyEditorPlugin,\n  HtmlDeserializer,\n} from '../../../plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../../../plugin';\nimport { isSlateNode } from '../../../static';\nimport { getInjectedPlugins } from '../../../utils/getInjectedPlugins';\nimport { getDataNodeProps } from './getDataNodeProps';\n\n/**\n * Get a deserializer and add default rules for deserializing plate static\n * elements\n */\nconst getDeserializedWithStaticRules = (plugin: AnyEditorPlugin) => {\n  let deserializer = plugin.parsers?.html?.deserializer;\n\n  const rules = deserializer?.rules ?? [];\n\n  // Check if rules already contain slate-xxx className\n  const hasSlateRule = rules.some((rule) =>\n    rule.validClassName?.includes(`slate-${plugin.key}`)\n  );\n\n  const staticRules = hasSlateRule\n    ? rules\n    : [\n        {\n          validClassName: `slate-${plugin.key}`,\n          validNodeName: '*',\n        },\n        ...rules,\n      ];\n\n  if (!deserializer) deserializer = { rules: staticRules };\n\n  deserializer.rules = staticRules;\n\n  return deserializer;\n};\n\n/** Get a deserializer by type, node names, class names and styles. */\nexport const pluginDeserializeHtml = (\n  editor: SlateEditor,\n  plugin: AnyEditorPlugin,\n  {\n    deserializeLeaf,\n    element: el,\n  }: { element: HTMLElement; deserializeLeaf?: boolean }\n): (Nullable<HtmlDeserializer> & { node: AnyObject }) | undefined => {\n  const {\n    node: { isElement: isElementRoot, isLeaf: isLeafRoot },\n  } = plugin;\n\n  const deserializer = getDeserializedWithStaticRules(plugin);\n\n  if (!deserializer) return;\n\n  const {\n    attributeNames,\n    isElement: isElementRule,\n    isLeaf: isLeafRule,\n    query,\n    rules,\n  } = deserializer;\n  let { parse } = deserializer;\n\n  const isElement = isElementRule || isElementRoot;\n  const isLeaf = isLeafRule || isLeafRoot;\n\n  if (!deserializeLeaf && !isElement) {\n    return;\n  }\n  if (deserializeLeaf && !isLeaf) {\n    return;\n  }\n  if (rules) {\n    const isValid = rules.some(\n      ({ validAttribute, validClassName, validNodeName = '*', validStyle }) => {\n        if (validNodeName) {\n          const validNodeNames = castArray<string>(validNodeName);\n\n          // Ignore if el nodeName is not included in rule validNodeNames (except *).\n          if (\n            validNodeNames.length > 0 &&\n            !validNodeNames.includes(el.nodeName) &&\n            validNodeName !== '*'\n          )\n            return false;\n        }\n        // Ignore if the rule className is not in el class list.\n        if (validClassName && !el.classList.contains(validClassName))\n          return false;\n        if (validStyle) {\n          for (const [key, value] of Object.entries(validStyle)) {\n            const values = castArray<string>(value);\n\n            // Ignore if el style value is not included in rule style values (except *)\n            if (!values.includes((el.style as any)[key]) && value !== '*')\n              return;\n            // Ignore if el style value is falsy (for value *)\n            if (value === '*' && !(el.style as any)[key]) return;\n\n            const defaultNodeValue = plugin.inject.nodeProps?.defaultNodeValue;\n\n            // Ignore if the style value = plugin.inject.nodeProps.defaultNodeValue\n            if (\n              defaultNodeValue &&\n              defaultNodeValue === (el.style as any)[key]\n            ) {\n              return false;\n            }\n          }\n        }\n        if (validAttribute) {\n          if (typeof validAttribute === 'string') {\n            if (!el.getAttributeNames().includes(validAttribute)) return false;\n          } else {\n            for (const [attributeName, attributeValue] of Object.entries(\n              validAttribute\n            )) {\n              const attributeValues = castArray<string>(attributeValue);\n              const elAttribute = el.getAttribute(attributeName);\n\n              if (\n                !isDefined(elAttribute) ||\n                !attributeValues.includes(elAttribute)\n              )\n                return false;\n            }\n          }\n        }\n\n        return true;\n      }\n    );\n\n    if (!isValid) return;\n  }\n  if (\n    query &&\n    !query({ ...(getEditorPlugin(editor, plugin) as any), element: el })\n  ) {\n    return;\n  }\n  if (!parse)\n    if (isElement) {\n      parse = ({ type }) => ({ type: type });\n    } else if (isLeaf) {\n      parse = ({ type }) => ({ [type!]: true });\n    } else {\n      return;\n    }\n\n  const parsedNode = (() => {\n    if (isSlateNode(el)) {\n      return {};\n    }\n\n    return (\n      parse({\n        ...(getEditorPlugin(editor, plugin) as any),\n        element: el,\n        node: {},\n      }) ?? {}\n    );\n  })();\n\n  const dataNodeProps = getDataNodeProps({\n    editor,\n    element: el,\n    plugin,\n  });\n\n  let node = {\n    ...parsedNode,\n    ...dataNodeProps,\n  };\n\n  if (Object.keys(node).length === 0) return;\n\n  const injectedPlugins = getInjectedPlugins(editor, plugin);\n\n  injectedPlugins.forEach((injectedPlugin) => {\n    const res = injectedPlugin.parsers?.html?.deserializer?.parse?.({\n      ...(getEditorPlugin(editor, plugin) as any),\n      element: el,\n      node,\n    });\n\n    if (res && !isSlateNode(el)) {\n      node = {\n        ...node,\n        ...res,\n      };\n    }\n  });\n\n  if (attributeNames) {\n    const elementAttributes = {};\n\n    const elementAttributeNames = el.getAttributeNames();\n\n    for (const elementAttributeName of elementAttributeNames) {\n      if (attributeNames.includes(elementAttributeName)) {\n        (elementAttributes as any)[elementAttributeName] =\n          el.getAttribute(elementAttributeName);\n      }\n    }\n\n    if (Object.keys(elementAttributes).length > 0) {\n      node.attributes = elementAttributes;\n    }\n  }\n\n  return { ...deserializer, node };\n};\n","import type { SlateEditor } from '../../../editor';\n\nimport { type AnyEditorPlugin, getEditorPlugin } from '../../../plugin';\nimport { isSlateLeaf, isSlatePluginNode } from '../../../static';\n\nconst getDefaultNodeProps = ({\n  element,\n  type,\n}: {\n  element: HTMLElement;\n  type: string;\n}) => {\n  if (!isSlatePluginNode(element, type) && !isSlateLeaf(element)) return;\n\n  const dataAttributes: Record<string, any> = {};\n\n  // Get all data-slate-* attributes from dataset\n  Object.entries(element.dataset).forEach(([key, value]) => {\n    if (\n      key.startsWith('slate') &&\n      value &&\n      // Ignore slate default attributes\n      !['slateInline', 'slateLeaf', 'slateNode', 'slateVoid'].includes(key)\n    ) {\n      // Remove 'slate' prefix and convert to camelCase\n      const attributeKey = key.slice(5).charAt(0).toLowerCase() + key.slice(6);\n\n      // Parse value if it's a boolean or number string\n\n      if (value === undefined) return;\n\n      let parsedValue: any = value;\n\n      if (value === 'true') parsedValue = true;\n      else if (value === 'false') parsedValue = false;\n      else if (!Number.isNaN(Number(value))) parsedValue = Number(value);\n\n      dataAttributes[attributeKey] = parsedValue;\n    }\n  });\n\n  if (Object.keys(dataAttributes).length > 0) {\n    return dataAttributes;\n  }\n};\n\nexport const getDataNodeProps = ({\n  editor,\n  element,\n  plugin,\n}: {\n  editor: SlateEditor;\n  element: HTMLElement;\n  plugin: AnyEditorPlugin;\n}) => {\n  const toNodeProps = plugin.parsers.html?.deserializer?.toNodeProps;\n\n  const disableDefaultNodeProps =\n    plugin.parsers.html?.deserializer?.disableDefaultNodeProps ?? false;\n\n  const defaultNodeProps = disableDefaultNodeProps\n    ? {}\n    : getDefaultNodeProps({\n        ...(getEditorPlugin(editor, plugin) as any),\n        element,\n      });\n\n  if (!toNodeProps) return defaultNodeProps;\n\n  const customNodeProps =\n    toNodeProps({\n      ...(getEditorPlugin(editor, plugin) as any),\n      element,\n    }) ?? {};\n\n  return {\n    ...defaultNodeProps,\n    ...customNodeProps,\n  };\n};\n","import type { AnyObject, Nullable } from '@udecode/utils';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { HtmlDeserializer } from '../../../plugin/SlatePlugin';\n\nimport { pluginDeserializeHtml } from './pluginDeserializeHtml';\n\nexport const pipeDeserializeHtmlElement = (\n  editor: SlateEditor,\n  element: HTMLElement\n) => {\n  let result: (Nullable<HtmlDeserializer> & { node: AnyObject }) | undefined;\n\n  [...editor.meta.pluginList].reverse().some((plugin) => {\n    result = pluginDeserializeHtml(editor, plugin, { element });\n\n    return !!result;\n  });\n\n  return result;\n};\n","import { type Descendant, ElementApi, TextApi } from '@udecode/slate';\nimport { jsx } from 'slate-hyperscript';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { mergeDeepToNodes } from '../../../utils';\nimport { deserializeHtmlNodeChildren } from './deserializeHtmlNodeChildren';\nimport { pipeDeserializeHtmlLeaf } from './pipeDeserializeHtmlLeaf';\n\n/**\n * Deserialize HTML to Descendant[] with marks on Text. Build the leaf from the\n * leaf deserializers of each plugin.\n */\nexport const htmlElementToLeaf = (\n  editor: SlateEditor,\n  element: HTMLElement\n) => {\n  const node = pipeDeserializeHtmlLeaf(editor, element);\n\n  return deserializeHtmlNodeChildren(editor, element).reduce(\n    (arr: Descendant[], child) => {\n      if (!child) return arr;\n      if (ElementApi.isElement(child)) {\n        if (Object.keys(node).length > 0) {\n          mergeDeepToNodes({\n            node: child,\n            query: {\n              filter: ([n]) => TextApi.isText(n),\n            },\n            source: node,\n          });\n        }\n\n        arr.push(child);\n      } else {\n        const attributes = { ...node };\n\n        // attributes should not override child attributes\n        if (TextApi.isText(child) && child.text) {\n          Object.keys(attributes).forEach((key) => {\n            if (attributes[key] && child[key]) {\n              attributes[key] = child[key];\n            }\n          });\n        }\n\n        arr.push(jsx('text', attributes, child) as any);\n      }\n\n      return arr;\n    },\n    []\n  ) as Descendant[];\n};\n","import type { AnyObject } from '@udecode/utils';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { pluginDeserializeHtml } from './pluginDeserializeHtml';\n\nexport const pipeDeserializeHtmlLeaf = (\n  editor: SlateEditor,\n  element: HTMLElement\n) => {\n  let node: AnyObject = {};\n\n  [...editor.meta.pluginList].reverse().forEach((plugin) => {\n    const deserialized = pluginDeserializeHtml(editor, plugin, {\n      deserializeLeaf: true,\n      element,\n    });\n\n    if (!deserialized) return;\n\n    node = { ...node, ...deserialized.node };\n  });\n\n  return node;\n};\n","/** Deserialize HTML text node to text. */\nimport { isHtmlText } from './isHtmlText';\n\nexport const htmlTextNodeToString = (node: ChildNode | HTMLElement) => {\n  if (isHtmlText(node)) {\n    if (node.parentElement?.dataset.platePreventDeserialization) return '';\n\n    return node.textContent || '';\n  }\n};\n","import type { SlateEditor } from '../../../editor';\nimport type { DeserializeHtmlNodeReturnType } from '../types';\n\nimport { isSlateNode } from '../../../static';\nimport { htmlBodyToFragment } from './htmlBodyToFragment';\nimport { htmlBrToNewLine } from './htmlBrToNewLine';\nimport { htmlElementToElement } from './htmlElementToElement';\nimport { htmlElementToLeaf } from './htmlElementToLeaf';\nimport { htmlTextNodeToString } from './htmlTextNodeToString';\nimport { isHtmlElement } from './isHtmlElement';\n\n/** Deserialize HTML element or child node. */\nexport const deserializeHtmlNode =\n  (editor: SlateEditor) =>\n  (node: ChildNode | HTMLElement): DeserializeHtmlNodeReturnType => {\n    const textNode = htmlTextNodeToString(node);\n\n    if (textNode) return textNode;\n    if (!isHtmlElement(node)) return null;\n\n    // break line\n    const breakLine = htmlBrToNewLine(node);\n\n    if (breakLine) return breakLine;\n\n    // body\n    const fragment = htmlBodyToFragment(editor, node as HTMLElement);\n\n    if (fragment) return fragment;\n\n    // element\n    const element = htmlElementToElement(\n      editor,\n      node as HTMLElement,\n      isSlateNode(node as HTMLElement)\n    );\n\n    if (element) return element;\n\n    // leaf\n    return htmlElementToLeaf(editor, node as HTMLElement);\n  };\n","import type { SlateEditor } from '../../../editor';\nimport type { DeserializeHtmlNodeReturnType } from '../types';\n\nimport { deserializeHtmlNode } from './deserializeHtmlNode';\n\n/** Deserialize HTML element to fragment. */\nexport const deserializeHtmlElement = (\n  editor: SlateEditor,\n  element: HTMLElement\n): DeserializeHtmlNodeReturnType => {\n  return deserializeHtmlNode(editor)(element);\n};\n","/** Convert HTML string into HTML element. */\nexport const htmlStringToDOMNode = (rawHtml: string) => {\n  const node = document.createElement('body');\n  node.innerHTML = rawHtml;\n\n  return node;\n};\n","import type { Descendant } from '@udecode/slate';\n\nimport type { SlateEditor } from '../../../editor';\nimport type { WithRequiredKey } from '../../../plugin';\n\nimport { normalizeDescendantsToDocumentFragment } from '../../../utils/normalizeDescendantsToDocumentFragment';\nimport { collapseWhiteSpace } from './collapse-white-space';\nimport { deserializeHtmlElement } from './deserializeHtmlElement';\nimport { htmlStringToDOMNode } from './htmlStringToDOMNode';\n\n/** Deserialize HTML element to a valid document fragment. */\nexport const deserializeHtml = (\n  editor: SlateEditor,\n  {\n    collapseWhiteSpace: shouldCollapseWhiteSpace = true,\n    defaultElementPlugin,\n    element,\n  }: {\n    element: HTMLElement | string;\n    collapseWhiteSpace?: boolean;\n    defaultElementPlugin?: WithRequiredKey;\n  }\n): Descendant[] => {\n  // for serializer\n  if (typeof element === 'string') {\n    element = htmlStringToDOMNode(element);\n  }\n  if (shouldCollapseWhiteSpace) {\n    element = collapseWhiteSpace(element);\n  }\n\n  const fragment = deserializeHtmlElement(editor, element) as Descendant[];\n\n  return normalizeDescendantsToDocumentFragment(editor, {\n    defaultElementPlugin,\n    descendants: fragment,\n  });\n};\n","import { traverseHtmlElements } from './traverseHtmlElements';\n\n/**\n * Find the first HTML element that matches the given selector.\n *\n * @param rootNode\n * @param predicate\n */\nexport const findHtmlElement = (\n  rootNode: Node,\n  predicate: (node: HTMLElement) => boolean\n) => {\n  let res: Node | null = null;\n\n  traverseHtmlElements(rootNode, (node) => {\n    if (predicate(node as HTMLElement)) {\n      res = node;\n\n      return false;\n    }\n\n    return true;\n  });\n\n  return res;\n};\n\nexport const someHtmlElement = (\n  rootNode: Node,\n  predicate: (node: HTMLElement) => boolean\n) => {\n  return !!findHtmlElement(rootNode, predicate);\n};\n","const acceptNode = () => NodeFilter.FILTER_ACCEPT;\n\nexport const getHtmlComments = (node: Node): string[] => {\n  const comments: string[] = [];\n  const iterator = document.createNodeIterator(node, NodeFilter.SHOW_COMMENT, {\n    acceptNode,\n  });\n  let currentNode = iterator.nextNode();\n\n  while (currentNode) {\n    if (currentNode.nodeValue) {\n      comments.push(currentNode.nodeValue);\n    }\n\n    currentNode = iterator.nextNode();\n  }\n\n  return comments;\n};\n","export const isHtmlComment = (node: Node): node is Comment =>\n  node.nodeType === Node.COMMENT_NODE;\n","export const isOlSymbol = (symbol: string): boolean => {\n  return /[\\da-np-z]\\S/.test(symbol.toLowerCase());\n};\n","export const parseHtmlDocument = (html: string) => {\n  return new DOMParser().parseFromString(html, 'text/html');\n};\n","import { parseHtmlDocument } from './parseHtmlDocument';\n\nexport const parseHtmlElement = (html: string) => {\n  const { body } = parseHtmlDocument(html);\n\n  return body.firstElementChild as HTMLElement;\n};\n","import { ZERO_WIDTH_SPACE } from '../constants';\n\n/** Trim the html and remove zero width spaces, then wrap it with a body element. */\nexport const postCleanHtml = (html: string): string => {\n  const cleanHtml = html\n    .trim()\n    .replaceAll(new RegExp(ZERO_WIDTH_SPACE, 'g'), '');\n\n  return `<body>${cleanHtml}</body>`;\n};\n","/** Remove string before <html */\nconst removeBeforeHtml = (html: string): string => {\n  const index = html.indexOf('<html');\n\n  if (index === -1) {\n    return html;\n  }\n\n  return html.slice(Math.max(0, index));\n};\n\n/** Remove string after </html> */\nconst removeAfterHtml = (html: string): string => {\n  const index = html.lastIndexOf('</html>');\n\n  if (index === -1) {\n    return html;\n  }\n\n  return html.slice(0, Math.max(0, index + '</html>'.length));\n};\n\n/** Remove string before <html and after </html> */\nexport const removeHtmlSurroundings = (html: string): string => {\n  return removeBeforeHtml(removeAfterHtml(html));\n};\n","import { cleanHtmlCrLf } from './cleanHtmlCrLf';\nimport { removeHtmlSurroundings } from './removeHtmlSurroundings';\n\nconst cleaners = [removeHtmlSurroundings, cleanHtmlCrLf];\n\n/** Remove HTML surroundings and clean HTML from CR/LF */\nexport const preCleanHtml = (html: string): string => {\n  return cleaners.reduce((result, clean) => clean(result), html);\n};\n","import { isHtmlComment } from './isHtmlComment';\nimport { traverseHtmlNode } from './traverseHtmlNode';\n\ntype Callback = (node: Comment) => boolean;\n\n/** Traverse HTML comments. */\nexport const traverseHtmlComments = (\n  rootNode: Node,\n  callback: Callback\n): void => {\n  traverseHtmlNode(rootNode, (node) => {\n    if (!isHtmlComment(node)) {\n      return true;\n    }\n\n    return callback(node);\n  });\n};\n","import { isHtmlComment } from './isHtmlComment';\nimport { traverseHtmlComments } from './traverseHtmlComments';\n\n/** Removes HTML nodes between HTML comments. */\nexport const removeHtmlNodesBetweenComments = (\n  rootNode: Node,\n  start: string,\n  end: string\n): void => {\n  const isClosingComment = (node: Node) =>\n    isHtmlComment(node) && node.data === end;\n\n  traverseHtmlComments(rootNode, (comment) => {\n    if (comment.data === start) {\n      let node = comment.nextSibling;\n\n      comment.remove();\n\n      while (node && !isClosingComment(node)) {\n        const { nextSibling } = node;\n        node.remove();\n        node = nextSibling;\n      }\n\n      if (node && isClosingComment(node)) {\n        node.remove();\n      }\n    }\n\n    return true;\n  });\n};\n","import type { LengthConfig } from '../getCorePlugins';\n\nimport { createTSlatePlugin } from '../../plugin';\n\nexport const LengthPlugin = createTSlatePlugin<LengthConfig>({\n  key: 'length',\n}).overrideEditor(({ editor, getOptions, tf: { apply } }) => ({\n  transforms: {\n    apply(operation) {\n      editor.tf.withoutNormalizing(() => {\n        apply(operation);\n\n        const options = getOptions();\n\n        if (options.maxLength) {\n          const length = editor.api.string([]).length;\n\n          // Make sure to remove overflow of text beyond character limit\n          if (length > options.maxLength) {\n            const overflowLength = length - options.maxLength;\n\n            editor.tf.delete({\n              distance: overflowLength,\n              reverse: true,\n              unit: 'character',\n            });\n          }\n        }\n      });\n    },\n  },\n}));\n","import {\n  type Descendant,\n  type QueryNodeOptions,\n  ElementApi,\n  queryNode,\n} from '@udecode/slate';\nimport { nanoid } from 'nanoid';\n\nimport type { PluginConfig } from '../../plugin/BasePlugin';\n\nimport { createTSlatePlugin } from '../../plugin/createSlatePlugin';\nimport { withNodeId } from './withNodeId';\n\nexport type NodeIdConfig = PluginConfig<\n  'nodeId',\n  {\n    /**\n     * By default, when a node inserted using editor.tf.insertNode(s) has an id,\n     * it will be used instead of the id generator, except if it already exists\n     * in the document. Set this option to true to disable this behavior.\n     */\n    disableInsertOverrides?: boolean;\n    /**\n     * Filter inline `Element` nodes.\n     *\n     * @default true\n     */\n    filterInline?: boolean;\n    /**\n     * Filter `Text` nodes.\n     *\n     * @default true\n     */\n    filterText?: boolean;\n    /**\n     * Node key to store the id.\n     *\n     * @default 'id'\n     */\n    idKey?: string;\n    /**\n     * Normalize initial value. If false, normalize only the first and last node\n     * are missing id. To disable this behavior, use `NodeIdPlugin.configure({\n     * normalizeInitialValue: null })`.\n     *\n     * @default false\n     */\n    normalizeInitialValue?: boolean;\n    /**\n     * Reuse ids on undo/redo and copy/pasting if not existing in the document.\n     * This is disabled by default to avoid duplicate ids across documents.\n     *\n     * @default false\n     */\n    reuseId?: boolean;\n    /**\n     * A function that generates and returns a unique ID.\n     *\n     * @default () => nanoid(10)\n     */\n    idCreator?: () => any;\n  } & QueryNodeOptions\n>;\n\n/** @see {@link withNodeId} */\nexport const NodeIdPlugin = createTSlatePlugin<NodeIdConfig>({\n  key: 'nodeId',\n  options: {\n    filterInline: true,\n    filterText: true,\n    idKey: 'id',\n    normalizeInitialValue: false,\n    filter: () => true,\n    idCreator: () => nanoid(10),\n  },\n  normalizeInitialValue: ({ editor, getOptions }) => {\n    const {\n      allow,\n      exclude,\n      filter,\n      filterInline,\n      filterText,\n      idKey,\n      normalizeInitialValue,\n    } = getOptions();\n\n    // Perf: check if normalization is needed by looking at the first node and last node\n    if (!normalizeInitialValue) {\n      const firstNode = editor.children[0];\n      const lastNode = editor.children.at(-1);\n\n      if (firstNode?.id && lastNode?.id) {\n        return;\n      }\n    }\n\n    const addNodeId = (entry: [Descendant, number[]]) => {\n      const [node, path] = entry;\n\n      if (\n        !node[idKey!] &&\n        queryNode([node, path], {\n          allow,\n          exclude,\n          filter: (entry) => {\n            const [node] = entry;\n\n            if (filterText && !ElementApi.isElement(node)) {\n              return false;\n            }\n            if (\n              filterInline &&\n              ElementApi.isElement(node) &&\n              !editor.api.isBlock(node)\n            ) {\n              return false;\n            }\n\n            return filter!(entry);\n          },\n        })\n      ) {\n        // Verify node exists at path before attempting to modify\n        const existingNode = editor.api.node(path);\n        if (!existingNode) {\n          return;\n        }\n\n        editor.tf.withoutSaving(() => {\n          editor.tf.setNodes(\n            { [idKey!]: getOptions().idCreator!() },\n            { at: path }\n          );\n        });\n      }\n\n      // Only traverse children if this is an Element node\n      if (ElementApi.isElement(node)) {\n        node.children.forEach((child: any, index: number) => {\n          addNodeId([child, [...path, index]]);\n        });\n      }\n    };\n\n    // Process top-level nodes in place\n    editor.children.forEach((node, index) => {\n      addNodeId([node, [index]]);\n    });\n  },\n}).overrideEditor(withNodeId);\n","import {\n  type Descendant,\n  type NodeEntry,\n  type NodeProps,\n  type TNode,\n  queryNode,\n} from '@udecode/slate';\nimport { isDefined } from '@udecode/utils';\nimport castArray from 'lodash/castArray.js';\nimport cloneDeep from 'lodash/cloneDeep.js';\n\nimport type { OverrideEditor } from '../../plugin';\nimport type { NodeIdConfig } from './NodeIdPlugin';\n\nimport { applyDeepToNodes, defaultsDeepToNodes } from '../../utils';\n\n/** Enables support for inserting nodes with an id key. */\nexport const withNodeId: OverrideEditor<NodeIdConfig> = ({\n  editor,\n  getOptions,\n  tf: { apply, insertNode, insertNodes },\n}) => {\n  const idPropsCreator = () => ({\n    [getOptions().idKey ?? '']: getOptions().idCreator!(),\n  });\n\n  const filterNode = (nodeEntry: NodeEntry) => {\n    const { filter, filterText } = getOptions();\n\n    return (\n      filter!(nodeEntry) && (!filterText || nodeEntry[0]?.type !== undefined)\n    );\n  };\n\n  const removeIdFromNodeIfDuplicate = <N extends Descendant>(node: N) => {\n    const { idKey = '', reuseId } = getOptions();\n\n    if (\n      !reuseId &&\n      editor.api.some({ at: [], match: { [idKey]: node[idKey] } })\n    ) {\n      delete node[idKey];\n    }\n  };\n\n  const overrideIdIfSet = (node: TNode) => {\n    const { idKey = '' } = getOptions();\n\n    if (isDefined(node._id)) {\n      const id = node._id;\n      delete node._id;\n\n      if (!editor.api.some({ at: [], match: { [idKey]: id } })) {\n        node[idKey] = id;\n      }\n    }\n  };\n\n  return {\n    transforms: {\n      apply(operation) {\n        const {\n          allow,\n          disableInsertOverrides,\n          exclude,\n          idCreator,\n          idKey = '',\n          reuseId,\n        } = getOptions();\n\n        const query = {\n          allow,\n          exclude,\n          filter: filterNode,\n        };\n\n        if (operation.type === 'insert_node') {\n          // clone to be able to write (read-only)\n          const node = cloneDeep(operation.node);\n\n          // Delete ids from node that are already being used\n          applyDeepToNodes({\n            apply: removeIdFromNodeIfDuplicate,\n            node,\n            query,\n            source: {},\n          });\n\n          defaultsDeepToNodes({\n            node,\n            path: operation.path,\n            query,\n            source: idPropsCreator,\n          });\n\n          if (!disableInsertOverrides) {\n            applyDeepToNodes({\n              apply: overrideIdIfSet,\n              node,\n              query,\n              source: {},\n            });\n          }\n\n          return apply({\n            ...operation,\n            node,\n          });\n        }\n        if (operation.type === 'split_node') {\n          const node = operation.properties as NodeProps<TNode>;\n          let id = (operation.properties as any)[idKey];\n\n          // only for elements (node with a type) or all nodes if `filterText=false`\n\n          if (queryNode([node as any, operation.path], query)) {\n            /**\n             * Create a new id if:\n             *\n             * - The id in the new node is already being used in the editor or,\n             * - The node has no id\n             */\n            if (\n              !reuseId ||\n              id === undefined ||\n              editor.api.some({\n                at: [],\n                match: { [idKey]: id },\n              })\n            ) {\n              id = idCreator!();\n            }\n\n            return apply({\n              ...operation,\n              properties: {\n                ...operation.properties,\n                [idKey]: id,\n              },\n            });\n          }\n          // if the node is allowed, we don't want to use the same id\n          if (id) {\n            delete (operation.properties as any)[idKey];\n          }\n        }\n\n        return apply(operation);\n      },\n\n      insertNode(node) {\n        const { disableInsertOverrides, idKey = '' } = getOptions();\n\n        if (!disableInsertOverrides && node[idKey]) {\n          if (!Object.isExtensible(node)) {\n            node = cloneDeep(node);\n          }\n\n          node._id = node[idKey];\n        }\n\n        insertNode(node);\n      },\n\n      insertNodes(_nodes, options) {\n        const nodes = castArray<Descendant>(_nodes as any).filter(\n          (node) => !!node\n        );\n\n        if (nodes.length === 0) return;\n\n        const { disableInsertOverrides, idKey = '' } = getOptions();\n\n        insertNodes(\n          nodes.map((node) => {\n            if (!disableInsertOverrides && node[idKey]) {\n              if (!Object.isExtensible(node)) {\n                node = cloneDeep(node);\n              }\n\n              node._id = node[idKey];\n            }\n\n            return node;\n          }),\n          options\n        );\n      },\n    },\n  };\n};\n","import { type OmitFirst, bindFirst } from '@udecode/utils';\n\nimport { type PluginConfig, createSlatePlugin } from '../../plugin';\nimport { init } from './transforms/init';\nimport { insertExitBreak } from './transforms/insertExitBreak';\nimport { resetBlock } from './transforms/resetBlock';\nimport { setValue } from './transforms/setValue';\n\nexport type SlateExtensionConfig = PluginConfig<\n  'slateExtension',\n  {},\n  {},\n  {\n    init: OmitFirst<typeof init>;\n    insertExitBreak: OmitFirst<typeof insertExitBreak>;\n    resetBlock: OmitFirst<typeof resetBlock>;\n    setValue: OmitFirst<typeof setValue>;\n  }\n>;\n\n/** Opinionated extension of slate default behavior. */\nexport const SlateExtensionPlugin = createSlatePlugin({\n  key: 'slateExtension',\n}).extendEditorTransforms(({ editor }) => ({\n  /**\n   * Initialize the editor value, selection and normalization. Set `value` to\n   * `null` to skip children initialization.\n   */\n  init: bindFirst(init, editor),\n  insertExitBreak: bindFirst(insertExitBreak, editor),\n  resetBlock: bindFirst(resetBlock, editor),\n  setValue: bindFirst(setValue, editor),\n}));\n","import type { SlateEditor } from '../../lib/editor';\n\nimport { getEditorPlugin } from '../../lib/plugin';\nimport { isEditOnly } from './isEditOnlyDisabled';\n\n/** Normalize initial value from editor plugins. Set into plate store if diff. */\nexport const pipeNormalizeInitialValue = (editor: SlateEditor) => {\n  editor.meta.pluginCache.normalizeInitialValue.forEach((key) => {\n    const p = editor.getPlugin({ key });\n\n    if (isEditOnly(editor.dom.readOnly, p, 'normalizeInitialValue')) {\n      return;\n    }\n\n    p.normalizeInitialValue?.({\n      ...getEditorPlugin(editor, p),\n      value: editor.children,\n    } as any);\n  });\n};\n","import type { EditorTransforms, TSelection, Value } from '@udecode/slate';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { pipeNormalizeInitialValue } from '../../../../internal/plugin/pipeNormalizeInitialValue';\n\n// import { pipeNormalizeInitialValue } from '../../../../internal/plugin/pipeNormalizeInitialValue';\n\nexport type InitOptions = {\n  autoSelect?: boolean | 'end' | 'start';\n  selection?: TSelection;\n  shouldNormalizeEditor?: boolean;\n  value?: any;\n};\n\nexport const init = async (\n  editor: SlateEditor,\n  { autoSelect, selection, shouldNormalizeEditor, value }: InitOptions\n) => {\n  if (value !== null) {\n    if (typeof value === 'string') {\n      editor.children = editor.api.html.deserialize({\n        element: value,\n      }) as Value;\n    } else if (typeof value === 'function') {\n      editor.children = await value(editor);\n    } else if (value) {\n      editor.children = value;\n    }\n    if (!editor.children || editor.children?.length === 0) {\n      editor.children = editor.api.create.value();\n    }\n  }\n\n  if (selection) {\n    editor.selection = selection;\n  } else if (autoSelect) {\n    const edge = autoSelect === 'start' ? 'start' : 'end';\n    const target = edge === 'start' ? editor.api.start([]) : editor.api.end([]);\n\n    editor.tf.select(target!);\n  }\n  if (editor.children.length > 0) {\n    pipeNormalizeInitialValue(editor);\n  }\n  if (shouldNormalizeEditor) {\n    (editor.tf as EditorTransforms).normalize({ force: true });\n  }\n};\n","import {\n  type EditorAboveOptions,\n  combineMatchOptions,\n  PathApi,\n} from '@udecode/slate';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { getPluginTypes } from '../../../plugin/getSlatePlugin';\n\nexport type InsertExitBreakOptions = {\n  match?: EditorAboveOptions['match'];\n  reverse?: boolean;\n};\n\n/**\n * Exits the current block structure by creating a new block next to the\n * appropriate ancestor.\n *\n * This function automatically determines the exit point by finding the first\n * ancestor that doesn't have strict sibling constraints (`isStrictSiblings:\n * false`), allowing standard text blocks to be inserted as siblings.\n *\n * For example:\n *\n * - In `column_group > column > codeblock > codeline`, exits after `codeblock`,\n *   then after `column_group`\n * - In `table > tr > td > p`, exits after `table`\n */\nexport const insertExitBreak = (\n  editor: SlateEditor,\n  { match, reverse }: InsertExitBreakOptions = {}\n) => {\n  if (!editor.selection || !editor.api.isCollapsed()) return;\n\n  const block = editor.api.block();\n\n  if (!block) return;\n\n  // Find the nearest ancestor that allows arbitrary block siblings (isStrictSiblings: false)\n  // We traverse up the tree until we find an element that can have paragraph siblings\n  const target = editor.api.above({\n    at: block[1],\n    match: combineMatchOptions(\n      editor,\n      (n, p) =>\n        p.length === 1 ||\n        (p.length > 1 &&\n          !!n.type &&\n          !getPluginTypes(\n            editor,\n            editor.meta.pluginCache.node.isStrictSiblings\n          ).includes(n.type as string)),\n      { match }\n    ),\n  });\n\n  const ancestorPath = target?.[1] ?? block[1];\n\n  const targetPath = reverse ? ancestorPath : PathApi.next(ancestorPath);\n\n  if (!targetPath) return;\n\n  editor.tf.insertNodes(editor.api.create.block(), {\n    at: targetPath,\n    select: true,\n  });\n\n  return true;\n};\n","import { type Path, NodeApi } from '@udecode/slate';\n\nimport type { SlateEditor } from '../../../editor';\n\nimport { BaseParagraphPlugin } from '../../paragraph';\n\n/**\n * Reset the current block to a paragraph, removing all properties except id and\n * type.\n */\nexport const resetBlock = (editor: SlateEditor, { at }: { at?: Path } = {}) => {\n  const entry = editor.api.block({ at });\n  if (!entry?.[0]) return;\n\n  const [block, path] = entry;\n\n  editor.tf.withoutNormalizing(() => {\n    // Extract only id and type, unset all other properties\n    const { id, type, ...otherProps } = NodeApi.extractProps(block);\n\n    // Unset all properties except id and type\n    Object.keys(otherProps).forEach((key) => {\n      editor.tf.unsetNodes(key, { at: path });\n    });\n\n    const paragraphType = editor.getType(BaseParagraphPlugin.key);\n\n    if (block.type !== paragraphType) {\n      // Set the new type to paragraph\n      editor.tf.setNodes({ type: paragraphType }, { at: path });\n    }\n  });\n\n  return true;\n};\n","import type { Descendant, EditorTransforms, Value } from '@udecode/slate';\n\nimport type { SlateEditor } from '../../../editor';\n\nexport const setValue = <V extends Value>(\n  editor: SlateEditor,\n  value?: V | string\n) => {\n  let children: Descendant[] = value as any;\n\n  if (typeof value === 'string') {\n    children = editor.api.html.deserialize({\n      element: value,\n    });\n  } else if (!value || value.length === 0) {\n    children = editor.api.create.value();\n  }\n\n  (editor.tf as EditorTransforms).replaceNodes(children, {\n    at: [],\n    children: true,\n  });\n};\n","import type { AnySlatePlugin, SlatePluginContext } from '../plugin';\n\nexport const omitPluginContext = <T extends SlatePluginContext<AnySlatePlugin>>(\n  ctx: T\n) => {\n  const {\n    api,\n    editor,\n    getOption,\n    getOptions,\n    plugin,\n    setOption,\n    setOptions,\n    tf,\n    type,\n    ...rest\n  } = ctx;\n\n  return rest;\n};\n","import defaultsDeep from 'lodash/defaultsDeep.js';\n\nimport type { AnySlatePlugin } from '../plugin/SlatePlugin';\n\n/**\n * Recursive deep merge of each plugin from `override.plugins` into plugin with\n * same key (plugin > plugin.plugins).\n */\nexport const overridePluginsByKey = (\n  plugin: AnySlatePlugin,\n  overrideByKey: Record<string, Partial<AnySlatePlugin>> = {},\n  nested = false\n): AnySlatePlugin => {\n  if (overrideByKey[plugin.key]) {\n    const {\n      __extensions: pluginOverridesExtensions,\n      plugins: pluginOverridesPlugins,\n      ...pluginOverrides\n    } = overrideByKey[plugin.key];\n\n    // Override plugin\n    plugin = defaultsDeep({}, pluginOverrides, plugin);\n\n    // Merge __extensions\n    if (pluginOverridesExtensions) {\n      plugin.__extensions = [\n        ...(plugin.__extensions || []),\n        ...pluginOverridesExtensions,\n      ];\n    }\n    if (!nested) {\n      // Concat new pluginOverrides.plugins to plugin.plugins\n      pluginOverridesPlugins?.forEach((pOverrides) => {\n        if (!plugin.plugins) plugin.plugins = [];\n\n        const found = plugin.plugins.find((p) => p.key === pOverrides.key);\n\n        if (!found) plugin.plugins.push(pOverrides);\n      });\n    }\n  }\n  if (plugin.plugins) {\n    // Override plugin.plugins\n    plugin.plugins = plugin.plugins.map((p) =>\n      overridePluginsByKey(p, overrideByKey, true)\n    );\n  }\n\n  return plugin;\n};\n","import type { SlateEditor } from '../editor';\nimport type { ParserOptions } from '../plugin/BasePlugin';\nimport type { AnyEditorPlugin } from '../plugin/SlatePlugin';\n\nimport { getEditorPlugin } from '../plugin';\n\n/** Is the plugin disabled by another plugin. */\nexport const pipeInsertDataQuery = (\n  editor: SlateEditor,\n  plugins: Partial<AnyEditorPlugin>[],\n  { data, dataTransfer }: ParserOptions\n) =>\n  plugins.every((p) => {\n    const query = p.parser?.query;\n\n    return (\n      !query ||\n      query({\n        ...getEditorPlugin(editor, p as any),\n        data,\n        dataTransfer,\n      })\n    );\n  });\n","import { pipeInsertFragment } from '../../internal/plugin/pipeInsertFragment';\nimport { pipeTransformData } from '../../internal/plugin/pipeTransformData';\nimport { pipeTransformFragment } from '../../internal/plugin/pipeTransformFragment';\nimport { createSlatePlugin, getEditorPlugin } from '../plugin';\nimport { getInjectedPlugins } from '../utils';\nimport { pipeInsertDataQuery } from '../utils/pipeInsertDataQuery';\n\nexport const ParserPlugin = createSlatePlugin({\n  key: 'parser',\n}).overrideEditor(({ editor, tf: { insertData } }) => ({\n  transforms: {\n    insertData(dataTransfer: DataTransfer) {\n      const inserted = [...editor.meta.pluginList].reverse().some((plugin) => {\n        const parser = plugin.parser;\n\n        if (!parser) return false;\n\n        const injectedPlugins = getInjectedPlugins(editor, plugin);\n        const { deserialize, format, mimeTypes } = parser;\n\n        if (!format) return false;\n\n        // Handle both string and string[] formats\n        const formats = Array.isArray(format) ? format : [format];\n        const mimeTypeList =\n          mimeTypes ||\n          formats.map((fmt) => (fmt.includes('/') ? fmt : `text/${fmt}`));\n\n        for (const mimeType of mimeTypeList) {\n          let data = dataTransfer.getData(mimeType);\n\n          if (!data) continue;\n          if (\n            !pipeInsertDataQuery(editor, injectedPlugins, {\n              data,\n              dataTransfer,\n            })\n          ) {\n            continue;\n          }\n\n          data = pipeTransformData(editor, injectedPlugins, {\n            data,\n            dataTransfer,\n          });\n\n          let fragment = deserialize?.({\n            ...getEditorPlugin(editor, plugin),\n            data,\n            dataTransfer,\n          });\n\n          if (!fragment?.length) continue;\n\n          fragment = pipeTransformFragment(editor, injectedPlugins, {\n            data,\n            dataTransfer,\n            fragment,\n          });\n\n          if (fragment.length === 0) continue;\n\n          pipeInsertFragment(editor, injectedPlugins, {\n            data,\n            dataTransfer,\n            fragment,\n          });\n\n          return true;\n        }\n\n        return false;\n      });\n\n      if (inserted) return;\n\n      insertData(dataTransfer);\n    },\n  },\n}));\n","/* eslint-disable perfectionist/sort-imports */\nimport type { AnyPluginConfig, PluginConfig } from '../plugin/BasePlugin';\nimport type { SlatePlugin } from '../plugin/SlatePlugin';\n\nimport { AstPlugin } from './AstPlugin';\nimport { HistoryPlugin } from './HistoryPlugin';\nimport { OverridePlugin } from './override/OverridePlugin';\nimport { ParserPlugin } from './ParserPlugin';\nimport { type DebugErrorType, type LogLevel, DebugPlugin } from './debug';\nimport { DOMPlugin } from './dom';\nimport { HtmlPlugin } from './html';\nimport { LengthPlugin } from './length';\nimport { AffinityPlugin } from './affinity';\nimport { type NodeIdConfig, NodeIdPlugin } from './node-id/NodeIdPlugin';\nimport { BaseParagraphPlugin } from './paragraph';\nimport {\n  type SlateExtensionConfig,\n  SlateExtensionPlugin,\n} from './slate-extension';\n\nexport type CorePlugin = ReturnType<typeof getCorePlugins>[number];\n\nexport type GetCorePluginsOptions = {\n  /** Enable mark/element affinity. */\n  affinity?: boolean;\n  /** Specifies the maximum number of characters allowed in the editor. */\n  maxLength?: number;\n  /** Configure the node id plugin. */\n  nodeId?: NodeIdConfig['options'] | boolean;\n  /** Override the core plugins using the same key. */\n  plugins?: AnyPluginConfig[];\n};\n\nexport const getCorePlugins = ({\n  affinity,\n  maxLength,\n  nodeId,\n  plugins = [],\n}: GetCorePluginsOptions) => {\n  // Disable nodeId by default in test environment for deterministic tests\n  let resolvedNodeId: any = nodeId;\n  if (process.env.NODE_ENV === 'test' && nodeId === undefined) {\n    resolvedNodeId = false;\n  }\n\n  let corePlugins = [\n    DebugPlugin as SlatePlugin<DebugConfig>,\n    SlateExtensionPlugin,\n    DOMPlugin,\n    HistoryPlugin,\n    OverridePlugin,\n    ParserPlugin,\n    maxLength\n      ? LengthPlugin.configure({ options: { maxLength } })\n      : LengthPlugin,\n    HtmlPlugin,\n    AstPlugin,\n    NodeIdPlugin.configure({\n      enabled: resolvedNodeId !== false,\n      options: resolvedNodeId === false ? undefined : resolvedNodeId,\n    }),\n    AffinityPlugin.configure({ enabled: affinity }),\n    BaseParagraphPlugin,\n  ];\n\n  // Create a map for quick lookup of custom plugins\n  const customPluginsMap = new Map(\n    plugins.map((plugin) => [plugin.key, plugin])\n  );\n\n  // Replace core plugins with custom plugins if they exist and remove them from plugins\n  corePlugins = corePlugins.map((corePlugin) => {\n    const customPlugin = customPluginsMap.get(corePlugin.key);\n\n    if (customPlugin) {\n      // Remove the custom plugin from the plugins array\n      const index = plugins.findIndex((p) => p.key === corePlugin.key);\n\n      if (index !== -1) {\n        plugins.splice(index, 1);\n      }\n\n      return customPlugin;\n    }\n\n    return corePlugin as any;\n  });\n\n  return corePlugins;\n};\n\nexport type CorePluginTransforms = SlateExtensionConfig['transforms'];\nexport type CorePluginApi = SlateExtensionConfig['api'];\n\nexport type DebugConfig = PluginConfig<\n  'debug',\n  {\n    isProduction: boolean;\n    logger: Partial<Record<LogLevel, LogFunction>>;\n    logLevel: LogLevel;\n    throwErrors: boolean;\n  },\n  {\n    debug: {\n      error: (\n        message: string | unknown,\n        type?: DebugErrorType,\n        details?: any\n      ) => void;\n      info: (message: string, type?: DebugErrorType, details?: any) => void;\n      log: (message: string, type?: DebugErrorType, details?: any) => void;\n      warn: (message: string, type?: DebugErrorType, details?: any) => void;\n    };\n  }\n>;\n\nexport type LengthConfig = PluginConfig<\n  'length',\n  {\n    maxLength: number;\n  }\n>;\n\ntype LogFunction = (\n  message: string,\n  type?: DebugErrorType,\n  details?: any\n) => void;\n","export { nanoid } from 'nanoid';\n","export type { TStateApi as ZustandStoreApi } from 'zustand-x';\n\nexport { createZustandStore } from 'zustand-x';\n"],"mappings":";AAAA;AAAA,EAIE;AAAA,OACK;AACP,SAAS,UAAAA,eAAc;;;ACNvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAAC,kBAAiB;AAC1B,OAAOC,YAAW;AAClB,SAAS,0BAA0B;;;ACPnC,SAAsB,iBAAiB;;;ACAhC,SAAS,WAAW,OAA+B;AACxD,SAAO,OAAO,UAAU;AAC1B;;;ACFA,OAAO,eAAe;AAIf,SAAS,aAAgB,eAAkB,eAAyB;AACzE,SAAO;AAAA,IACL,CAAC;AAAA,IACD;AAAA,IACA,GAAG;AAAA,IACH,CAAC,UAAmB,UAAmB,QAA2B;AAEhE,UAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,eAAO;AAAA,MACT;AAEA,UAAI,QAAQ,WAAW;AACrB,eAAO,EAAE,GAAI,UAAkB,GAAI,SAAiB;AAAA,MACtD;AAAA,IACF;AAAA,EACF;AACF;;;AFsEO,SAAS,kBAOd,SAEuC,CAAC,GACE;AAC1C,MAAI;AACJ,MAAI;AAEJ,MAAI,WAAW,MAAM,GAAG;AACtB,iBAAa,EAAE,KAAK,GAAQ;AAC5B,uBAAmB,CAAC,WAAgB,OAAO,MAAM;AAAA,EACnD,OAAO;AACL,iBAAa;AAAA,EACf;AAEA,QAAM,MAAM,WAAW,OAAO;AAE9B,QAAM,SAAS;AAAA,IACb;AAAA,MACE;AAAA,MACA,iBAAiB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AAY;AAAA,QACV,GAAG,aAAa;AAAA,QAChB,GAAG,aAAa,UAAU;AAAA,MAC5B;AAAA,IACF;AAAA,IACA,SAAS,CAAC,GAAG,aAAa,GAAGA,QAAO;AAAA,EACtC,CAAC;AAGD,MAAI,YAAY;AACd,yBAAqB,WAAW,kBAAkB;AAAA,EACpD;AAEA,iBAAe,QAAQ,CAAC,kBAAkB,CAAC;AAG3C,QAAM,gBAAgB,OAAO,GAAG;AAChC,SAAO,GAAG,gBAAgB,IAAI,SAAS;AACrC,QAAI,CAAC,OAAO,IAAI,oBAAoB,KAAK,CAAC,CAAC,GAAG;AAC5C;AAAA,IACF;AAEA,WAAO,cAAc,GAAG,IAAI;AAAA,EAC9B;AACA,SAAO,gBAAgB,OAAO,GAAG;AAEjC,MAAI,CAAC,oBAAoB;AACvB,SAAK,OAAO,GAAG,KAAK;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAiDO,IAAM,oBAAoB,CAG/B;AAAA,EACA,SAAS,aAAa;AAAA,EACtB,GAAG;AACL,IAAoC,CAAC,MAAM;AACzC,SAAO,UAAgB,QAAQ,OAAO;AACxC;;;AwP7XA,SAAS,UAAAE,eAAc;;;ACEvB,SAAS,sBAAAC,2BAA0B;","names":["nanoid","isDefined","merge","config","plugins","result","plugins","merge","isDefined","PathApi","PathApi","ElementApi","ElementApi","plugins","plugins","ElementApi","plugin","ElementApi","React","SlateElement","React","React","TextApi","isElement","TextApi","clsx","clsx","isDefined","isDefined","clsx","clsx","node","Element","React","plugin","Component","React","React","clsx","React","ElementApi","RangeApi","TextApi","clsx","React","clsx","Text","React","render","clsx","React","TextApi","RangeApi","ElementApi","clsx","React","render","clsx","React","React","merge","merge","ElementApi","TextApi","ElementApi","NodeApi","TextApi","ElementApi","NodeApi","PathApi","isPlainObject","isPlainObject","immer","isSet","current","Immer","base","Immer","Path","ancestors","path","options","arguments","length","undefined","reverse","paths","levels","slice","common","another","i","av","bv","push","compare","min","Math","endsAfter","as","bs","equals","endsAt","endsBefore","every","n","hasPrevious","isAfter","isAncestor","isBefore","isChild","isCommon","isDescendant","isParent","isPath","value","Array","isArray","isSibling","al","bl","list","next","Error","concat","last","operationCanTransformPath","operation","type","parent","previous","relative","ancestor","transform","p","affinity","op","position","newPath","onp","copy","o","toPrimitive","toPropertyKey","applyToDraft","editor","selection","node","Node","index","children","splice","point","key","Range","points","Point","offset","text","leaf","before","after","get","prevPath","prev","Text","isText","Scrubber","stringify","truePath","newParent","newIndex","result","texts","preferNext","properties","newProperties","hasOwnProperty","isRange","_objectSpread","newNode","GeneralTransforms","createDraft","finishDraft","isDraft","NodeTransforms","insertNodes","nodes","liftNodes","mergeNodes","moveNodes","removeNodes","setNodes","props","splitNodes","unsetNodes","unwrapNodes","wrapNodes","element","SelectionTransforms","collapse","deselect","move","select","target","setPoint","setSelection","isDeepEqual","a","b","isPlainObject","objectWithoutPropertiesLoose","edges","range","anchor","focus","isBackward","end","surrounds","intersectionRange","intersection","includes","rs","re","ts","te","start","isAfterStart","isBeforeEnd","isPoint","rest","_objectWithoutProperties","_excluded","s1","e1","s2","e2","isCollapsed","isExpanded","isForward","produce","r","affinityAnchor","affinityFocus","isElement","isNodeList","Editor","isEditor","Element","isElementList","val","isElementProps","isElementType","elementVal","elementKey","matches","IS_NODE_LIST_CACHE","WeakMap","root","entry","child","c","childPath","descendant","descendants","elements","extractProps","_excluded2","first","fragment","newRoot","nodeEntries","pass","_ref","getIf","has","isNode","cachedResult","set","isTextProps","from","to","visited","Set","add","nextIndex","parentPath","string","map","join","Operation","isNodeOperation","isOperation","endsWith","isOperationList","isSelectionOperation","isTextOperation","inverse","inversePath","inverseNewPath","IS_EDITOR_CACHE","cachedIsEditor","addMark","apply","deleteFragment","insertBreak","insertSoftBreak","insertFragment","insertNode","insertText","isElementReadOnly","isInline","isSelectable","isVoid","normalizeNode","onChange","removeMark","getDirtyPaths","marks","operations","above","at","deleteBackward","unit","deleteForward","elementReadOnly","hasBlocks","hasInlines","hasPath","hasTexts","isBlock","isEdge","isEmpty","isEnd","isNormalizing","isStart","getMarks","normalize","pathRef","pathRefs","pointRef","pointRefs","positions","rangeRef","rangeRefs","setNormalizing","unhangRange","void","withoutNormalizing","fn","shouldMergeNodesRemovePrevNode","prevNode","curNode","Point","compare","point","another","result","Path","path","offset","isAfter","isBefore","equals","isPoint","value","isPlainObject","isPath","transform","op","options","produce","p","affinity","type","text","length","position","Math","min","isAncestor","_objectSpread","_scrubber","undefined","Scrubber","setScrubber","scrubber","stringify","JSON","Text","loose","omitText","obj","rest","_objectWithoutProperties","_excluded","isDeepEqual","isText","isTextList","Array","isArray","every","val","isTextProps","props","matches","key","hasOwnProperty","decorations","node","leaves","leaf","dec","anchor","focus","merge","mergeDecoration","_excluded2","start","end","Range","edges","next","leafEnd","decorationStart","decorationEnd","Object","assign","leafStart","push","middle","before","after","off","slice","currentOffset","index","item","entries","isFirst","isLast","getDefaultInsertLocation","editor","selection","children","Editor","CodepointType","NonBoundaryPairs","CodepointType","L","V","LV","LVT","T","Any","Extend","ZWJ","SpacingMark","Prepend","ExtPict","RI","TextTransforms","delete","editor","options","insertFragment","fragment","insertText","text","Editor","withoutNormalizing","voids","at","getDefaultInsertLocation","Path","isPath","range","Range","isRange","isCollapsed","anchor","end","void","start","startRef","pointRef","endRef","Transforms","startPoint","unref","endPoint","setSelection","focus","elementReadOnly","path","offset","length","apply","type","_objectSpread","GeneralTransforms","NodeTransforms","SelectionTransforms","NodeApi","ElementApi","PathApi","NodeApi","ElementApi","NodeApi","NodeApi","ElementApi","ElementApi","NodeApi","beforeEnd","TextApi","NodeApi","ElementApi","bindFirst","jsx","isDefined","castArray","isElement","castArray","isDefined","jsx","ElementApi","TextApi","jsx","ElementApi","TextApi","jsx","bindFirst","document","ElementApi","queryNode","queryNode","isDefined","castArray","isDefined","queryNode","castArray","queryNode","entry","node","ElementApi","bindFirst","PathApi","PathApi","NodeApi","NodeApi","bindFirst","TextApi","ElementApi","plugins","plugins","plugins","nanoid","nanoid","createZustandStore"]}