import { EditorState as Dt, NodeSelection as G, Plugin as O, PluginKey as j, Selection as F, TextSelection as P, AllSelection as Lt } from "../../../../../prosemirror-state@1.4.3/node_modules/prosemirror-state/dist/index.js";
import { EditorView as zt } from "../../../../../prosemirror-view@1.40.0/node_modules/prosemirror-view/dist/index.js";
import { keymap as Ht } from "../../../../../prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.js";
import { DOMSerializer as _t, Schema as Et, Fragment as I, Node as Vt, DOMParser as et, Slice as Wt } from "../../../../../prosemirror-model@1.25.1/node_modules/prosemirror-model/dist/index.js";
import { findWrapping as Kt, canJoin as lt, Transform as Ut, canSplit as W, joinPoint as xt, liftTarget as qt, ReplaceStep as Gt, ReplaceAroundStep as Jt } from "../../../../../prosemirror-transform@1.10.4/node_modules/prosemirror-transform/dist/index.js";
import { wrapIn as Yt, setBlockType as gt, selectTextblockStart as Qt, selectTextblockEnd as Xt, selectParentNode as Zt, selectNodeForward as te, selectNodeBackward as ee, newlineInCode as ne, liftEmptyBlock as re, lift as se, joinUp as oe, joinTextblockForward as ie, joinTextblockBackward as ae, joinForward as ce, joinDown as le, joinBackward as de, exitCode as ue, deleteSelection as fe, createParagraphNear as pe } from "../../../../../prosemirror-commands@1.7.1/node_modules/prosemirror-commands/dist/index.js";
import { wrapInList as he, sinkListItem as me, liftListItem as ge } from "../../../../../prosemirror-schema-list@1.5.1/node_modules/prosemirror-schema-list/dist/index.js";
function J(n) {
  const { state: t, transaction: e } = n;
  let { selection: r } = e, { doc: s } = e, { storedMarks: o } = e;
  return {
    ...t,
    apply: t.apply.bind(t),
    applyTransaction: t.applyTransaction.bind(t),
    plugins: t.plugins,
    schema: t.schema,
    reconfigure: t.reconfigure.bind(t),
    toJSON: t.toJSON.bind(t),
    get storedMarks() {
      return o;
    },
    get selection() {
      return r;
    },
    get doc() {
      return s;
    },
    get tr() {
      return r = e.selection, s = e.doc, o = e.storedMarks, e;
    }
  };
}
class Y {
  constructor(t) {
    this.editor = t.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = t.state;
  }
  get hasCustomState() {
    return !!this.customState;
  }
  get state() {
    return this.customState || this.editor.state;
  }
  get commands() {
    const { rawCommands: t, editor: e, state: r } = this, { view: s } = e, { tr: o } = r, i = this.buildProps(o);
    return Object.fromEntries(Object.entries(t).map(([c, a]) => [c, (...u) => {
      const d = a(...u)(i);
      return !o.getMeta("preventDispatch") && !this.hasCustomState && s.dispatch(o), d;
    }]));
  }
  get chain() {
    return () => this.createChain();
  }
  get can() {
    return () => this.createCan();
  }
  createChain(t, e = !0) {
    const { rawCommands: r, editor: s, state: o } = this, { view: i } = s, c = [], a = !!t, l = t || o.tr, u = () => (!a && e && !l.getMeta("preventDispatch") && !this.hasCustomState && i.dispatch(l), c.every((f) => f === !0)), d = {
      ...Object.fromEntries(Object.entries(r).map(([f, p]) => [f, (...h) => {
        const m = this.buildProps(l, e), k = p(...h)(m);
        return c.push(k), d;
      }])),
      run: u
    };
    return d;
  }
  createCan(t) {
    const { rawCommands: e, state: r } = this, s = !1, o = t || r.tr, i = this.buildProps(o, s);
    return {
      ...Object.fromEntries(Object.entries(e).map(([a, l]) => [a, (...u) => l(...u)({ ...i, dispatch: void 0 })])),
      chain: () => this.createChain(o, s)
    };
  }
  buildProps(t, e = !0) {
    const { rawCommands: r, editor: s, state: o } = this, { view: i } = s, c = {
      tr: t,
      editor: s,
      view: i,
      state: J({
        state: o,
        transaction: t
      }),
      dispatch: e ? () => {
      } : void 0,
      chain: () => this.createChain(t, e),
      can: () => this.createCan(t),
      get commands() {
        return Object.fromEntries(Object.entries(r).map(([a, l]) => [a, (...u) => l(...u)(c)]));
      }
    };
    return c;
  }
}
class ye {
  constructor() {
    this.callbacks = {};
  }
  on(t, e) {
    return this.callbacks[t] || (this.callbacks[t] = []), this.callbacks[t].push(e), this;
  }
  emit(t, ...e) {
    const r = this.callbacks[t];
    return r && r.forEach((s) => s.apply(this, e)), this;
  }
  off(t, e) {
    const r = this.callbacks[t];
    return r && (e ? this.callbacks[t] = r.filter((s) => s !== e) : delete this.callbacks[t]), this;
  }
  once(t, e) {
    const r = (...s) => {
      this.off(t, r), e.apply(this, s);
    };
    return this.on(t, r);
  }
  removeAllListeners() {
    this.callbacks = {};
  }
}
function y(n, t, e) {
  return n.config[t] === void 0 && n.parent ? y(n.parent, t, e) : typeof n.config[t] == "function" ? n.config[t].bind({
    ...e,
    parent: n.parent ? y(n.parent, t, e) : null
  }) : n.config[t];
}
function Q(n) {
  const t = n.filter((s) => s.type === "extension"), e = n.filter((s) => s.type === "node"), r = n.filter((s) => s.type === "mark");
  return {
    baseExtensions: t,
    nodeExtensions: e,
    markExtensions: r
  };
}
function Ct(n) {
  const t = [], { nodeExtensions: e, markExtensions: r } = Q(n), s = [...e, ...r], o = {
    default: null,
    rendered: !0,
    renderHTML: null,
    parseHTML: null,
    keepOnSplit: !0,
    isRequired: !1
  };
  return n.forEach((i) => {
    const c = {
      name: i.name,
      options: i.options,
      storage: i.storage,
      extensions: s
    }, a = y(i, "addGlobalAttributes", c);
    if (!a)
      return;
    a().forEach((u) => {
      u.types.forEach((d) => {
        Object.entries(u.attributes).forEach(([f, p]) => {
          t.push({
            type: d,
            name: f,
            attribute: {
              ...o,
              ...p
            }
          });
        });
      });
    });
  }), s.forEach((i) => {
    const c = {
      name: i.name,
      options: i.options,
      storage: i.storage
    }, a = y(i, "addAttributes", c);
    if (!a)
      return;
    const l = a();
    Object.entries(l).forEach(([u, d]) => {
      const f = {
        ...o,
        ...d
      };
      typeof (f == null ? void 0 : f.default) == "function" && (f.default = f.default()), f != null && f.isRequired && (f == null ? void 0 : f.default) === void 0 && delete f.default, t.push({
        type: i.name,
        name: u,
        attribute: f
      });
    });
  }), t;
}
function S(n, t) {
  if (typeof n == "string") {
    if (!t.nodes[n])
      throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);
    return t.nodes[n];
  }
  return n;
}
function ke(...n) {
  return n.filter((t) => !!t).reduce((t, e) => {
    const r = { ...t };
    return Object.entries(e).forEach(([s, o]) => {
      if (!r[s]) {
        r[s] = o;
        return;
      }
      if (s === "class") {
        const c = o ? String(o).split(" ") : [], a = r[s] ? r[s].split(" ") : [], l = c.filter((u) => !a.includes(u));
        r[s] = [...a, ...l].join(" ");
      } else if (s === "style") {
        const c = o ? o.split(";").map((u) => u.trim()).filter(Boolean) : [], a = r[s] ? r[s].split(";").map((u) => u.trim()).filter(Boolean) : [], l = /* @__PURE__ */ new Map();
        a.forEach((u) => {
          const [d, f] = u.split(":").map((p) => p.trim());
          l.set(d, f);
        }), c.forEach((u) => {
          const [d, f] = u.split(":").map((p) => p.trim());
          l.set(d, f);
        }), r[s] = Array.from(l.entries()).map(([u, d]) => `${u}: ${d}`).join("; ");
      } else
        r[s] = o;
    }), r;
  }, {});
}
function ot(n, t) {
  return t.filter((e) => e.type === n.type.name).filter((e) => e.attribute.rendered).map((e) => e.attribute.renderHTML ? e.attribute.renderHTML(n.attrs) || {} : {
    [e.name]: n.attrs[e.name]
  }).reduce((e, r) => ke(e, r), {});
}
function Tt(n) {
  return typeof n == "function";
}
function b(n, t = void 0, ...e) {
  return Tt(n) ? t ? n.bind(t)(...e) : n(...e) : n;
}
function be(n = {}) {
  return Object.keys(n).length === 0 && n.constructor === Object;
}
function ve(n) {
  return typeof n != "string" ? n : n.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(n) : n === "true" ? !0 : n === "false" ? !1 : n;
}
function yt(n, t) {
  return "style" in n ? n : {
    ...n,
    getAttrs: (e) => {
      const r = n.getAttrs ? n.getAttrs(e) : n.attrs;
      if (r === !1)
        return !1;
      const s = t.reduce((o, i) => {
        const c = i.attribute.parseHTML ? i.attribute.parseHTML(e) : ve(e.getAttribute(i.name));
        return c == null ? o : {
          ...o,
          [i.name]: c
        };
      }, {});
      return { ...r, ...s };
    }
  };
}
function kt(n) {
  return Object.fromEntries(
    // @ts-ignore
    Object.entries(n).filter(([t, e]) => t === "attrs" && be(e) ? !1 : e != null)
  );
}
function we(n, t) {
  var e;
  const r = Ct(n), { nodeExtensions: s, markExtensions: o } = Q(n), i = (e = s.find((l) => y(l, "topNode"))) === null || e === void 0 ? void 0 : e.name, c = Object.fromEntries(s.map((l) => {
    const u = r.filter((k) => k.type === l.name), d = {
      name: l.name,
      options: l.options,
      storage: l.storage,
      editor: t
    }, f = n.reduce((k, v) => {
      const w = y(v, "extendNodeSchema", d);
      return {
        ...k,
        ...w ? w(l) : {}
      };
    }, {}), p = kt({
      ...f,
      content: b(y(l, "content", d)),
      marks: b(y(l, "marks", d)),
      group: b(y(l, "group", d)),
      inline: b(y(l, "inline", d)),
      atom: b(y(l, "atom", d)),
      selectable: b(y(l, "selectable", d)),
      draggable: b(y(l, "draggable", d)),
      code: b(y(l, "code", d)),
      whitespace: b(y(l, "whitespace", d)),
      linebreakReplacement: b(y(l, "linebreakReplacement", d)),
      defining: b(y(l, "defining", d)),
      isolating: b(y(l, "isolating", d)),
      attrs: Object.fromEntries(u.map((k) => {
        var v;
        return [k.name, { default: (v = k == null ? void 0 : k.attribute) === null || v === void 0 ? void 0 : v.default }];
      }))
    }), g = b(y(l, "parseHTML", d));
    g && (p.parseDOM = g.map((k) => yt(k, u)));
    const h = y(l, "renderHTML", d);
    h && (p.toDOM = (k) => h({
      node: k,
      HTMLAttributes: ot(k, u)
    }));
    const m = y(l, "renderText", d);
    return m && (p.toText = m), [l.name, p];
  })), a = Object.fromEntries(o.map((l) => {
    const u = r.filter((m) => m.type === l.name), d = {
      name: l.name,
      options: l.options,
      storage: l.storage,
      editor: t
    }, f = n.reduce((m, k) => {
      const v = y(k, "extendMarkSchema", d);
      return {
        ...m,
        ...v ? v(l) : {}
      };
    }, {}), p = kt({
      ...f,
      inclusive: b(y(l, "inclusive", d)),
      excludes: b(y(l, "excludes", d)),
      group: b(y(l, "group", d)),
      spanning: b(y(l, "spanning", d)),
      code: b(y(l, "code", d)),
      attrs: Object.fromEntries(u.map((m) => {
        var k;
        return [m.name, { default: (k = m == null ? void 0 : m.attribute) === null || k === void 0 ? void 0 : k.default }];
      }))
    }), g = b(y(l, "parseHTML", d));
    g && (p.parseDOM = g.map((m) => yt(m, u)));
    const h = y(l, "renderHTML", d);
    return h && (p.toDOM = (m) => h({
      mark: m,
      HTMLAttributes: ot(m, u)
    })), [l.name, p];
  }));
  return new Et({
    topNode: i,
    nodes: c,
    marks: a
  });
}
function nt(n, t) {
  return t.nodes[n] || t.marks[n] || null;
}
function bt(n, t) {
  return Array.isArray(t) ? t.some((e) => (typeof e == "string" ? e : e.name) === n.name) : t;
}
function dt(n, t) {
  const e = _t.fromSchema(t).serializeFragment(n), s = document.implementation.createHTMLDocument().createElement("div");
  return s.appendChild(e), s.innerHTML;
}
const Me = (n, t = 500) => {
  let e = "";
  const r = n.parentOffset;
  return n.parent.nodesBetween(Math.max(0, r - t), r, (s, o, i, c) => {
    var a, l;
    const u = ((l = (a = s.type.spec).toText) === null || l === void 0 ? void 0 : l.call(a, {
      node: s,
      pos: o,
      parent: i,
      index: c
    })) || s.textContent || "%leaf%";
    e += s.isAtom && !s.isText ? u : u.slice(0, Math.max(0, r - o));
  }), e;
};
function ut(n) {
  return Object.prototype.toString.call(n) === "[object RegExp]";
}
class X {
  constructor(t) {
    this.find = t.find, this.handler = t.handler;
  }
}
const Se = (n, t) => {
  if (ut(t))
    return t.exec(n);
  const e = t(n);
  if (!e)
    return null;
  const r = [e.text];
  return r.index = e.index, r.input = n, r.data = e.data, e.replaceWith && (e.text.includes(e.replaceWith) || console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'), r.push(e.replaceWith)), r;
};
function z(n) {
  var t;
  const { editor: e, from: r, to: s, text: o, rules: i, plugin: c } = n, { view: a } = e;
  if (a.composing)
    return !1;
  const l = a.state.doc.resolve(r);
  if (
    // check for code node
    l.parent.type.spec.code || !((t = l.nodeBefore || l.nodeAfter) === null || t === void 0) && t.marks.find((f) => f.type.spec.code)
  )
    return !1;
  let u = !1;
  const d = Me(l) + o;
  return i.forEach((f) => {
    if (u)
      return;
    const p = Se(d, f.find);
    if (!p)
      return;
    const g = a.state.tr, h = J({
      state: a.state,
      transaction: g
    }), m = {
      from: r - (p[0].length - o.length),
      to: s
    }, { commands: k, chain: v, can: w } = new Y({
      editor: e,
      state: h
    });
    f.handler({
      state: h,
      range: m,
      match: p,
      commands: k,
      chain: v,
      can: w
    }) === null || !g.steps.length || (g.setMeta(c, {
      transform: g,
      from: r,
      to: s,
      text: o
    }), a.dispatch(g), u = !0);
  }), u;
}
function Ee(n) {
  const { editor: t, rules: e } = n, r = new O({
    state: {
      init() {
        return null;
      },
      apply(s, o, i) {
        const c = s.getMeta(r);
        if (c)
          return c;
        const a = s.getMeta("applyInputRules");
        return !!a && setTimeout(() => {
          let { text: u } = a;
          typeof u == "string" ? u = u : u = dt(I.from(u), i.schema);
          const { from: d } = a, f = d + u.length;
          z({
            editor: t,
            from: d,
            to: f,
            text: u,
            rules: e,
            plugin: r
          });
        }), s.selectionSet || s.docChanged ? null : o;
      }
    },
    props: {
      handleTextInput(s, o, i, c) {
        return z({
          editor: t,
          from: o,
          to: i,
          text: c,
          rules: e,
          plugin: r
        });
      },
      handleDOMEvents: {
        compositionend: (s) => (setTimeout(() => {
          const { $cursor: o } = s.state.selection;
          o && z({
            editor: t,
            from: o.pos,
            to: o.pos,
            text: "",
            rules: e,
            plugin: r
          });
        }), !1)
      },
      // add support for input rules to trigger on enter
      // this is useful for example for code blocks
      handleKeyDown(s, o) {
        if (o.key !== "Enter")
          return !1;
        const { $cursor: i } = s.state.selection;
        return i ? z({
          editor: t,
          from: i.pos,
          to: i.pos,
          text: `
`,
          rules: e,
          plugin: r
        }) : !1;
      }
    },
    // @ts-ignore
    isInputRules: !0
  });
  return r;
}
function xe(n) {
  return Object.prototype.toString.call(n).slice(8, -1);
}
function H(n) {
  return xe(n) !== "Object" ? !1 : n.constructor === Object && Object.getPrototypeOf(n) === Object.prototype;
}
function Z(n, t) {
  const e = { ...n };
  return H(n) && H(t) && Object.keys(t).forEach((r) => {
    H(t[r]) && H(n[r]) ? e[r] = Z(n[r], t[r]) : e[r] = t[r];
  }), e;
}
class U {
  constructor(t = {}) {
    this.type = "mark", this.name = "mark", this.parent = null, this.child = null, this.config = {
      name: this.name,
      defaultOptions: {}
    }, this.config = {
      ...this.config,
      ...t
    }, this.name = this.config.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = b(y(this, "addOptions", {
      name: this.name
    }))), this.storage = b(y(this, "addStorage", {
      name: this.name,
      options: this.options
    })) || {};
  }
  static create(t = {}) {
    return new U(t);
  }
  configure(t = {}) {
    const e = this.extend({
      ...this.config,
      addOptions: () => Z(this.options, t)
    });
    return e.name = this.name, e.parent = this.parent, e;
  }
  extend(t = {}) {
    const e = new U(t);
    return e.parent = this, this.child = e, e.name = t.name ? t.name : e.parent.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`), e.options = b(y(e, "addOptions", {
      name: e.name
    })), e.storage = b(y(e, "addStorage", {
      name: e.name,
      options: e.options
    })), e;
  }
  static handleExit({ editor: t, mark: e }) {
    const { tr: r } = t.state, s = t.state.selection.$from;
    if (s.pos === s.end()) {
      const i = s.marks();
      if (!!!i.find((l) => (l == null ? void 0 : l.type.name) === e.name))
        return !1;
      const a = i.find((l) => (l == null ? void 0 : l.type.name) === e.name);
      return a && r.removeStoredMark(a), r.insertText(" ", s.pos), t.view.dispatch(r), !0;
    }
    return !1;
  }
}
function Ce(n) {
  return typeof n == "number";
}
class Te {
  constructor(t) {
    this.find = t.find, this.handler = t.handler;
  }
}
const Ae = (n, t, e) => {
  if (ut(t))
    return [...n.matchAll(t)];
  const r = t(n, e);
  return r ? r.map((s) => {
    const o = [s.text];
    return o.index = s.index, o.input = n, o.data = s.data, s.replaceWith && (s.text.includes(s.replaceWith) || console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'), o.push(s.replaceWith)), o;
  }) : [];
};
function Pe(n) {
  const { editor: t, state: e, from: r, to: s, rule: o, pasteEvent: i, dropEvent: c } = n, { commands: a, chain: l, can: u } = new Y({
    editor: t,
    state: e
  }), d = [];
  return e.doc.nodesBetween(r, s, (p, g) => {
    if (!p.isTextblock || p.type.spec.code)
      return;
    const h = Math.max(r, g), m = Math.min(s, g + p.content.size), k = p.textBetween(h - g, m - g, void 0, "￼");
    Ae(k, o.find, i).forEach((w) => {
      if (w.index === void 0)
        return;
      const E = h + w.index + 1, M = E + w[0].length, x = {
        from: e.tr.mapping.map(E),
        to: e.tr.mapping.map(M)
      }, T = o.handler({
        state: e,
        range: x,
        match: w,
        commands: a,
        chain: l,
        can: u,
        pasteEvent: i,
        dropEvent: c
      });
      d.push(T);
    });
  }), d.every((p) => p !== null);
}
let _ = null;
const Oe = (n) => {
  var t;
  const e = new ClipboardEvent("paste", {
    clipboardData: new DataTransfer()
  });
  return (t = e.clipboardData) === null || t === void 0 || t.setData("text/html", n), e;
};
function Ie(n) {
  const { editor: t, rules: e } = n;
  let r = null, s = !1, o = !1, i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c;
  try {
    c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
  } catch {
    c = null;
  }
  const a = ({ state: u, from: d, to: f, rule: p, pasteEvt: g }) => {
    const h = u.tr, m = J({
      state: u,
      transaction: h
    });
    if (!(!Pe({
      editor: t,
      state: m,
      from: Math.max(d - 1, 0),
      to: f.b - 1,
      rule: p,
      pasteEvent: g,
      dropEvent: c
    }) || !h.steps.length)) {
      try {
        c = typeof DragEvent < "u" ? new DragEvent("drop") : null;
      } catch {
        c = null;
      }
      return i = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, h;
    }
  };
  return e.map((u) => new O({
    // we register a global drag handler to track the current drag source element
    view(d) {
      const f = (g) => {
        var h;
        r = !((h = d.dom.parentElement) === null || h === void 0) && h.contains(g.target) ? d.dom.parentElement : null, r && (_ = t);
      }, p = () => {
        _ && (_ = null);
      };
      return window.addEventListener("dragstart", f), window.addEventListener("dragend", p), {
        destroy() {
          window.removeEventListener("dragstart", f), window.removeEventListener("dragend", p);
        }
      };
    },
    props: {
      handleDOMEvents: {
        drop: (d, f) => {
          if (o = r === d.dom.parentElement, c = f, !o) {
            const p = _;
            p != null && p.isEditable && setTimeout(() => {
              const g = p.state.selection;
              g && p.commands.deleteRange({ from: g.from, to: g.to });
            }, 10);
          }
          return !1;
        },
        paste: (d, f) => {
          var p;
          const g = (p = f.clipboardData) === null || p === void 0 ? void 0 : p.getData("text/html");
          return i = f, s = !!(g != null && g.includes("data-pm-slice")), !1;
        }
      }
    },
    appendTransaction: (d, f, p) => {
      const g = d[0], h = g.getMeta("uiEvent") === "paste" && !s, m = g.getMeta("uiEvent") === "drop" && !o, k = g.getMeta("applyPasteRules"), v = !!k;
      if (!h && !m && !v)
        return;
      if (v) {
        let { text: M } = k;
        typeof M == "string" ? M = M : M = dt(I.from(M), p.schema);
        const { from: x } = k, T = x + M.length, A = Oe(M);
        return a({
          rule: u,
          state: p,
          from: x,
          to: { b: T },
          pasteEvt: A
        });
      }
      const w = f.doc.content.findDiffStart(p.doc.content), E = f.doc.content.findDiffEnd(p.doc.content);
      if (!(!Ce(w) || !E || w === E.b))
        return a({
          rule: u,
          state: p,
          from: w,
          to: E,
          pasteEvt: i
        });
    }
  }));
}
function $e(n) {
  const t = n.filter((e, r) => n.indexOf(e) !== r);
  return Array.from(new Set(t));
}
class R {
  constructor(t, e) {
    this.splittableMarks = [], this.editor = e, this.extensions = R.resolve(t), this.schema = we(this.extensions, e), this.setupExtensions();
  }
  /**
   * Returns a flattened and sorted extension list while
   * also checking for duplicated extensions and warns the user.
   * @param extensions An array of Tiptap extensions
   * @returns An flattened and sorted array of Tiptap extensions
   */
  static resolve(t) {
    const e = R.sort(R.flatten(t)), r = $e(e.map((s) => s.name));
    return r.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map((s) => `'${s}'`).join(", ")}]. This can lead to issues.`), e;
  }
  /**
   * Create a flattened array of extensions by traversing the `addExtensions` field.
   * @param extensions An array of Tiptap extensions
   * @returns A flattened array of Tiptap extensions
   */
  static flatten(t) {
    return t.map((e) => {
      const r = {
        name: e.name,
        options: e.options,
        storage: e.storage
      }, s = y(e, "addExtensions", r);
      return s ? [e, ...this.flatten(s())] : e;
    }).flat(10);
  }
  /**
   * Sort extensions by priority.
   * @param extensions An array of Tiptap extensions
   * @returns A sorted array of Tiptap extensions by priority
   */
  static sort(t) {
    return t.sort((r, s) => {
      const o = y(r, "priority") || 100, i = y(s, "priority") || 100;
      return o > i ? -1 : o < i ? 1 : 0;
    });
  }
  /**
   * Get all commands from the extensions.
   * @returns An object with all commands where the key is the command name and the value is the command function
   */
  get commands() {
    return this.extensions.reduce((t, e) => {
      const r = {
        name: e.name,
        options: e.options,
        storage: e.storage,
        editor: this.editor,
        type: nt(e.name, this.schema)
      }, s = y(e, "addCommands", r);
      return s ? {
        ...t,
        ...s()
      } : t;
    }, {});
  }
  /**
   * Get all registered Prosemirror plugins from the extensions.
   * @returns An array of Prosemirror plugins
   */
  get plugins() {
    const { editor: t } = this, e = R.sort([...this.extensions].reverse()), r = [], s = [], o = e.map((i) => {
      const c = {
        name: i.name,
        options: i.options,
        storage: i.storage,
        editor: t,
        type: nt(i.name, this.schema)
      }, a = [], l = y(i, "addKeyboardShortcuts", c);
      let u = {};
      if (i.type === "mark" && y(i, "exitable", c) && (u.ArrowRight = () => U.handleExit({ editor: t, mark: i })), l) {
        const h = Object.fromEntries(Object.entries(l()).map(([m, k]) => [m, () => k({ editor: t })]));
        u = { ...u, ...h };
      }
      const d = Ht(u);
      a.push(d);
      const f = y(i, "addInputRules", c);
      bt(i, t.options.enableInputRules) && f && r.push(...f());
      const p = y(i, "addPasteRules", c);
      bt(i, t.options.enablePasteRules) && p && s.push(...p());
      const g = y(i, "addProseMirrorPlugins", c);
      if (g) {
        const h = g();
        a.push(...h);
      }
      return a;
    }).flat();
    return [
      Ee({
        editor: t,
        rules: r
      }),
      ...Ie({
        editor: t,
        rules: s
      }),
      ...o
    ];
  }
  /**
   * Get all attributes from the extensions.
   * @returns An array of attributes
   */
  get attributes() {
    return Ct(this.extensions);
  }
  /**
   * Get all node views from the extensions.
   * @returns An object with all node views where the key is the node name and the value is the node view function
   */
  get nodeViews() {
    const { editor: t } = this, { nodeExtensions: e } = Q(this.extensions);
    return Object.fromEntries(e.filter((r) => !!y(r, "addNodeView")).map((r) => {
      const s = this.attributes.filter((a) => a.type === r.name), o = {
        name: r.name,
        options: r.options,
        storage: r.storage,
        editor: t,
        type: S(r.name, this.schema)
      }, i = y(r, "addNodeView", o);
      if (!i)
        return [];
      const c = (a, l, u, d, f) => {
        const p = ot(a, s);
        return i()({
          // pass-through
          node: a,
          view: l,
          getPos: u,
          decorations: d,
          innerDecorations: f,
          // tiptap-specific
          editor: t,
          extension: r,
          HTMLAttributes: p
        });
      };
      return [r.name, c];
    }));
  }
  /**
   * Go through all extensions, create extension storages & setup marks
   * & bind editor event listener.
   */
  setupExtensions() {
    this.extensions.forEach((t) => {
      var e;
      this.editor.extensionStorage[t.name] = t.storage;
      const r = {
        name: t.name,
        options: t.options,
        storage: t.storage,
        editor: this.editor,
        type: nt(t.name, this.schema)
      };
      t.type === "mark" && (!((e = b(y(t, "keepOnSplit", r))) !== null && e !== void 0) || e) && this.splittableMarks.push(t.name);
      const s = y(t, "onBeforeCreate", r), o = y(t, "onCreate", r), i = y(t, "onUpdate", r), c = y(t, "onSelectionUpdate", r), a = y(t, "onTransaction", r), l = y(t, "onFocus", r), u = y(t, "onBlur", r), d = y(t, "onDestroy", r);
      s && this.editor.on("beforeCreate", s), o && this.editor.on("create", o), i && this.editor.on("update", i), c && this.editor.on("selectionUpdate", c), a && this.editor.on("transaction", a), l && this.editor.on("focus", l), u && this.editor.on("blur", u), d && this.editor.on("destroy", d);
    });
  }
}
class C {
  constructor(t = {}) {
    this.type = "extension", this.name = "extension", this.parent = null, this.child = null, this.config = {
      name: this.name,
      defaultOptions: {}
    }, this.config = {
      ...this.config,
      ...t
    }, this.name = this.config.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = b(y(this, "addOptions", {
      name: this.name
    }))), this.storage = b(y(this, "addStorage", {
      name: this.name,
      options: this.options
    })) || {};
  }
  static create(t = {}) {
    return new C(t);
  }
  configure(t = {}) {
    const e = this.extend({
      ...this.config,
      addOptions: () => Z(this.options, t)
    });
    return e.name = this.name, e.parent = this.parent, e;
  }
  extend(t = {}) {
    const e = new C({ ...this.config, ...t });
    return e.parent = this, this.child = e, e.name = t.name ? t.name : e.parent.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`), e.options = b(y(e, "addOptions", {
      name: e.name
    })), e.storage = b(y(e, "addStorage", {
      name: e.name,
      options: e.options
    })), e;
  }
}
function At(n, t, e) {
  const { from: r, to: s } = t, { blockSeparator: o = `

`, textSerializers: i = {} } = e || {};
  let c = "";
  return n.nodesBetween(r, s, (a, l, u, d) => {
    var f;
    a.isBlock && l > r && (c += o);
    const p = i == null ? void 0 : i[a.type.name];
    if (p)
      return u && (c += p({
        node: a,
        pos: l,
        parent: u,
        index: d,
        range: t
      })), !1;
    a.isText && (c += (f = a == null ? void 0 : a.text) === null || f === void 0 ? void 0 : f.slice(Math.max(r, l) - l, s - l));
  }), c;
}
function Pt(n) {
  return Object.fromEntries(Object.entries(n.nodes).filter(([, t]) => t.spec.toText).map(([t, e]) => [t, e.spec.toText]));
}
const Be = C.create({
  name: "clipboardTextSerializer",
  addOptions() {
    return {
      blockSeparator: void 0
    };
  },
  addProseMirrorPlugins() {
    return [
      new O({
        key: new j("clipboardTextSerializer"),
        props: {
          clipboardTextSerializer: () => {
            const { editor: n } = this, { state: t, schema: e } = n, { doc: r, selection: s } = t, { ranges: o } = s, i = Math.min(...o.map((u) => u.$from.pos)), c = Math.max(...o.map((u) => u.$to.pos)), a = Pt(e);
            return At(r, { from: i, to: c }, {
              ...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {},
              textSerializers: a
            });
          }
        }
      })
    ];
  }
}), Ne = () => ({ editor: n, view: t }) => (requestAnimationFrame(() => {
  var e;
  n.isDestroyed || (t.dom.blur(), (e = window == null ? void 0 : window.getSelection()) === null || e === void 0 || e.removeAllRanges());
}), !0), je = (n = !1) => ({ commands: t }) => t.setContent("", n), Re = () => ({ state: n, tr: t, dispatch: e }) => {
  const { selection: r } = t, { ranges: s } = r;
  return e && s.forEach(({ $from: o, $to: i }) => {
    n.doc.nodesBetween(o.pos, i.pos, (c, a) => {
      if (c.type.isText)
        return;
      const { doc: l, mapping: u } = t, d = l.resolve(u.map(a)), f = l.resolve(u.map(a + c.nodeSize)), p = d.blockRange(f);
      if (!p)
        return;
      const g = qt(p);
      if (c.type.isTextblock) {
        const { defaultType: h } = d.parent.contentMatchAt(d.index());
        t.setNodeMarkup(p.start, h);
      }
      (g || g === 0) && t.lift(p, g);
    });
  }), !0;
}, Fe = (n) => (t) => n(t), De = () => ({ state: n, dispatch: t }) => pe(n, t), Le = (n, t) => ({ editor: e, tr: r }) => {
  const { state: s } = e, o = s.doc.slice(n.from, n.to);
  r.deleteRange(n.from, n.to);
  const i = r.mapping.map(t);
  return r.insert(i, o.content), r.setSelection(new P(r.doc.resolve(i - 1))), !0;
}, ze = () => ({ tr: n, dispatch: t }) => {
  const { selection: e } = n, r = e.$anchor.node();
  if (r.content.size > 0)
    return !1;
  const s = n.selection.$anchor;
  for (let o = s.depth; o > 0; o -= 1)
    if (s.node(o).type === r.type) {
      if (t) {
        const c = s.before(o), a = s.after(o);
        n.delete(c, a).scrollIntoView();
      }
      return !0;
    }
  return !1;
}, He = (n) => ({ tr: t, state: e, dispatch: r }) => {
  const s = S(n, e.schema), o = t.selection.$anchor;
  for (let i = o.depth; i > 0; i -= 1)
    if (o.node(i).type === s) {
      if (r) {
        const a = o.before(i), l = o.after(i);
        t.delete(a, l).scrollIntoView();
      }
      return !0;
    }
  return !1;
}, _e = (n) => ({ tr: t, dispatch: e }) => {
  const { from: r, to: s } = n;
  return e && t.delete(r, s), !0;
}, Ve = () => ({ state: n, dispatch: t }) => fe(n, t), We = () => ({ commands: n }) => n.keyboardShortcut("Enter"), Ke = () => ({ state: n, dispatch: t }) => ue(n, t);
function q(n, t, e = { strict: !0 }) {
  const r = Object.keys(t);
  return r.length ? r.every((s) => e.strict ? t[s] === n[s] : ut(t[s]) ? t[s].test(n[s]) : t[s] === n[s]) : !0;
}
function Ot(n, t, e = {}) {
  return n.find((r) => r.type === t && q(
    // Only check equality for the attributes that are provided
    Object.fromEntries(Object.keys(e).map((s) => [s, r.attrs[s]])),
    e
  ));
}
function vt(n, t, e = {}) {
  return !!Ot(n, t, e);
}
function ft(n, t, e) {
  var r;
  if (!n || !t)
    return;
  let s = n.parent.childAfter(n.parentOffset);
  if ((!s.node || !s.node.marks.some((u) => u.type === t)) && (s = n.parent.childBefore(n.parentOffset)), !s.node || !s.node.marks.some((u) => u.type === t) || (e = e || ((r = s.node.marks[0]) === null || r === void 0 ? void 0 : r.attrs), !Ot([...s.node.marks], t, e)))
    return;
  let i = s.index, c = n.start() + s.offset, a = i + 1, l = c + s.node.nodeSize;
  for (; i > 0 && vt([...n.parent.child(i - 1).marks], t, e); )
    i -= 1, c -= n.parent.child(i).nodeSize;
  for (; a < n.parent.childCount && vt([...n.parent.child(a).marks], t, e); )
    l += n.parent.child(a).nodeSize, a += 1;
  return {
    from: c,
    to: l
  };
}
function $(n, t) {
  if (typeof n == "string") {
    if (!t.marks[n])
      throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);
    return t.marks[n];
  }
  return n;
}
const Ue = (n, t = {}) => ({ tr: e, state: r, dispatch: s }) => {
  const o = $(n, r.schema), { doc: i, selection: c } = e, { $from: a, from: l, to: u } = c;
  if (s) {
    const d = ft(a, o, t);
    if (d && d.from <= l && d.to >= u) {
      const f = P.create(i, d.from, d.to);
      e.setSelection(f);
    }
  }
  return !0;
}, qe = (n) => (t) => {
  const e = typeof n == "function" ? n(t) : n;
  for (let r = 0; r < e.length; r += 1)
    if (e[r](t))
      return !0;
  return !1;
};
function It(n) {
  return n instanceof P;
}
function N(n = 0, t = 0, e = 0) {
  return Math.min(Math.max(n, t), e);
}
function $t(n, t = null) {
  if (!t)
    return null;
  const e = F.atStart(n), r = F.atEnd(n);
  if (t === "start" || t === !0)
    return e;
  if (t === "end")
    return r;
  const s = e.from, o = r.to;
  return t === "all" ? P.create(n, N(0, s, o), N(n.content.size, s, o)) : P.create(n, N(t, s, o), N(t, s, o));
}
function Ge() {
  return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
}
function pt() {
  return [
    "iPad Simulator",
    "iPhone Simulator",
    "iPod Simulator",
    "iPad",
    "iPhone",
    "iPod"
  ].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
}
const Je = (n = null, t = {}) => ({ editor: e, view: r, tr: s, dispatch: o }) => {
  t = {
    scrollIntoView: !0,
    ...t
  };
  const i = () => {
    (pt() || Ge()) && r.dom.focus(), requestAnimationFrame(() => {
      e.isDestroyed || (r.focus(), t != null && t.scrollIntoView && e.commands.scrollIntoView());
    });
  };
  if (r.hasFocus() && n === null || n === !1)
    return !0;
  if (o && n === null && !It(e.state.selection))
    return i(), !0;
  const c = $t(s.doc, n) || e.state.selection, a = e.state.selection.eq(c);
  return o && (a || s.setSelection(c), a && s.storedMarks && s.setStoredMarks(s.storedMarks), i()), !0;
}, Ye = (n, t) => (e) => n.every((r, s) => t(r, { ...e, index: s })), Qe = (n, t) => ({ tr: e, commands: r }) => r.insertContentAt({ from: e.selection.from, to: e.selection.to }, n, t), Bt = (n) => {
  const t = n.childNodes;
  for (let e = t.length - 1; e >= 0; e -= 1) {
    const r = t[e];
    r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? n.removeChild(r) : r.nodeType === 1 && Bt(r);
  }
  return n;
};
function V(n) {
  const t = `<body>${n}</body>`, e = new window.DOMParser().parseFromString(t, "text/html").body;
  return Bt(e);
}
function D(n, t, e) {
  if (n instanceof Vt || n instanceof I)
    return n;
  e = {
    slice: !0,
    parseOptions: {},
    ...e
  };
  const r = typeof n == "object" && n !== null, s = typeof n == "string";
  if (r)
    try {
      if (Array.isArray(n) && n.length > 0)
        return I.fromArray(n.map((c) => t.nodeFromJSON(c)));
      const i = t.nodeFromJSON(n);
      return e.errorOnInvalidContent && i.check(), i;
    } catch (o) {
      if (e.errorOnInvalidContent)
        throw new Error("[tiptap error]: Invalid JSON content", { cause: o });
      return console.warn("[tiptap warn]: Invalid content.", "Passed value:", n, "Error:", o), D("", t, e);
    }
  if (s) {
    if (e.errorOnInvalidContent) {
      let i = !1, c = "";
      const a = new Et({
        topNode: t.spec.topNode,
        marks: t.spec.marks,
        // Prosemirror's schemas are executed such that: the last to execute, matches last
        // This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle
        nodes: t.spec.nodes.append({
          __tiptap__private__unknown__catch__all__node: {
            content: "inline*",
            group: "block",
            parseDOM: [
              {
                tag: "*",
                getAttrs: (l) => (i = !0, c = typeof l == "string" ? l : l.outerHTML, null)
              }
            ]
          }
        })
      });
      if (e.slice ? et.fromSchema(a).parseSlice(V(n), e.parseOptions) : et.fromSchema(a).parse(V(n), e.parseOptions), e.errorOnInvalidContent && i)
        throw new Error("[tiptap error]: Invalid HTML content", { cause: new Error(`Invalid element found: ${c}`) });
    }
    const o = et.fromSchema(t);
    return e.slice ? o.parseSlice(V(n), e.parseOptions).content : o.parse(V(n), e.parseOptions);
  }
  return D("", t, e);
}
function Xe(n, t, e) {
  const r = n.steps.length - 1;
  if (r < t)
    return;
  const s = n.steps[r];
  if (!(s instanceof Gt || s instanceof Jt))
    return;
  const o = n.mapping.maps[r];
  let i = 0;
  o.forEach((c, a, l, u) => {
    i === 0 && (i = u);
  }), n.setSelection(F.near(n.doc.resolve(i), e));
}
const Ze = (n) => !("type" in n), tn = (n, t, e) => ({ tr: r, dispatch: s, editor: o }) => {
  var i;
  if (s) {
    e = {
      parseOptions: o.options.parseOptions,
      updateSelection: !0,
      applyInputRules: !1,
      applyPasteRules: !1,
      ...e
    };
    let c;
    const a = (m) => {
      o.emit("contentError", {
        editor: o,
        error: m,
        disableCollaboration: () => {
          o.storage.collaboration && (o.storage.collaboration.isDisabled = !0);
        }
      });
    }, l = {
      preserveWhitespace: "full",
      ...e.parseOptions
    };
    if (!e.errorOnInvalidContent && !o.options.enableContentCheck && o.options.emitContentError)
      try {
        D(t, o.schema, {
          parseOptions: l,
          errorOnInvalidContent: !0
        });
      } catch (m) {
        a(m);
      }
    try {
      c = D(t, o.schema, {
        parseOptions: l,
        errorOnInvalidContent: (i = e.errorOnInvalidContent) !== null && i !== void 0 ? i : o.options.enableContentCheck
      });
    } catch (m) {
      return a(m), !1;
    }
    let { from: u, to: d } = typeof n == "number" ? { from: n, to: n } : { from: n.from, to: n.to }, f = !0, p = !0;
    if ((Ze(c) ? c : [c]).forEach((m) => {
      m.check(), f = f ? m.isText && m.marks.length === 0 : !1, p = p ? m.isBlock : !1;
    }), u === d && p) {
      const { parent: m } = r.doc.resolve(u);
      m.isTextblock && !m.type.spec.code && !m.childCount && (u -= 1, d += 1);
    }
    let h;
    if (f) {
      if (Array.isArray(t))
        h = t.map((m) => m.text || "").join("");
      else if (t instanceof I) {
        let m = "";
        t.forEach((k) => {
          k.text && (m += k.text);
        }), h = m;
      } else typeof t == "object" && t && t.text ? h = t.text : h = t;
      r.insertText(h, u, d);
    } else
      h = c, r.replaceWith(u, d, h);
    e.updateSelection && Xe(r, r.steps.length - 1, -1), e.applyInputRules && r.setMeta("applyInputRules", { from: u, text: h }), e.applyPasteRules && r.setMeta("applyPasteRules", { from: u, text: h });
  }
  return !0;
}, en = () => ({ state: n, dispatch: t }) => oe(n, t), nn = () => ({ state: n, dispatch: t }) => le(n, t), rn = () => ({ state: n, dispatch: t }) => de(n, t), sn = () => ({ state: n, dispatch: t }) => ce(n, t), on = () => ({ state: n, dispatch: t, tr: e }) => {
  try {
    const r = xt(n.doc, n.selection.$from.pos, -1);
    return r == null ? !1 : (e.join(r, 2), t && t(e), !0);
  } catch {
    return !1;
  }
}, an = () => ({ state: n, dispatch: t, tr: e }) => {
  try {
    const r = xt(n.doc, n.selection.$from.pos, 1);
    return r == null ? !1 : (e.join(r, 2), t && t(e), !0);
  } catch {
    return !1;
  }
}, cn = () => ({ state: n, dispatch: t }) => ae(n, t), ln = () => ({ state: n, dispatch: t }) => ie(n, t);
function Nt() {
  return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1;
}
function dn(n) {
  const t = n.split(/-(?!$)/);
  let e = t[t.length - 1];
  e === "Space" && (e = " ");
  let r, s, o, i;
  for (let c = 0; c < t.length - 1; c += 1) {
    const a = t[c];
    if (/^(cmd|meta|m)$/i.test(a))
      i = !0;
    else if (/^a(lt)?$/i.test(a))
      r = !0;
    else if (/^(c|ctrl|control)$/i.test(a))
      s = !0;
    else if (/^s(hift)?$/i.test(a))
      o = !0;
    else if (/^mod$/i.test(a))
      pt() || Nt() ? i = !0 : s = !0;
    else
      throw new Error(`Unrecognized modifier name: ${a}`);
  }
  return r && (e = `Alt-${e}`), s && (e = `Ctrl-${e}`), i && (e = `Meta-${e}`), o && (e = `Shift-${e}`), e;
}
const un = (n) => ({ editor: t, view: e, tr: r, dispatch: s }) => {
  const o = dn(n).split(/-(?!$)/), i = o.find((l) => !["Alt", "Ctrl", "Meta", "Shift"].includes(l)), c = new KeyboardEvent("keydown", {
    key: i === "Space" ? " " : i,
    altKey: o.includes("Alt"),
    ctrlKey: o.includes("Ctrl"),
    metaKey: o.includes("Meta"),
    shiftKey: o.includes("Shift"),
    bubbles: !0,
    cancelable: !0
  }), a = t.captureTransaction(() => {
    e.someProp("handleKeyDown", (l) => l(e, c));
  });
  return a == null || a.steps.forEach((l) => {
    const u = l.map(r.mapping);
    u && s && r.maybeStep(u);
  }), !0;
};
function L(n, t, e = {}) {
  const { from: r, to: s, empty: o } = n.selection, i = t ? S(t, n.schema) : null, c = [];
  n.doc.nodesBetween(r, s, (d, f) => {
    if (d.isText)
      return;
    const p = Math.max(r, f), g = Math.min(s, f + d.nodeSize);
    c.push({
      node: d,
      from: p,
      to: g
    });
  });
  const a = s - r, l = c.filter((d) => i ? i.name === d.node.type.name : !0).filter((d) => q(d.node.attrs, e, { strict: !1 }));
  return o ? !!l.length : l.reduce((d, f) => d + f.to - f.from, 0) >= a;
}
const fn = (n, t = {}) => ({ state: e, dispatch: r }) => {
  const s = S(n, e.schema);
  return L(e, s, t) ? se(e, r) : !1;
}, pn = () => ({ state: n, dispatch: t }) => re(n, t), hn = (n) => ({ state: t, dispatch: e }) => {
  const r = S(n, t.schema);
  return ge(r)(t, e);
}, mn = () => ({ state: n, dispatch: t }) => ne(n, t);
function tt(n, t) {
  return t.nodes[n] ? "node" : t.marks[n] ? "mark" : null;
}
function wt(n, t) {
  const e = typeof t == "string" ? [t] : t;
  return Object.keys(n).reduce((r, s) => (e.includes(s) || (r[s] = n[s]), r), {});
}
const gn = (n, t) => ({ tr: e, state: r, dispatch: s }) => {
  let o = null, i = null;
  const c = tt(typeof n == "string" ? n : n.name, r.schema);
  return c ? (c === "node" && (o = S(n, r.schema)), c === "mark" && (i = $(n, r.schema)), s && e.selection.ranges.forEach((a) => {
    r.doc.nodesBetween(a.$from.pos, a.$to.pos, (l, u) => {
      o && o === l.type && e.setNodeMarkup(u, void 0, wt(l.attrs, t)), i && l.marks.length && l.marks.forEach((d) => {
        i === d.type && e.addMark(u, u + l.nodeSize, i.create(wt(d.attrs, t)));
      });
    });
  }), !0) : !1;
}, yn = () => ({ tr: n, dispatch: t }) => (t && n.scrollIntoView(), !0), kn = () => ({ tr: n, dispatch: t }) => {
  if (t) {
    const e = new Lt(n.doc);
    n.setSelection(e);
  }
  return !0;
}, bn = () => ({ state: n, dispatch: t }) => ee(n, t), vn = () => ({ state: n, dispatch: t }) => te(n, t), wn = () => ({ state: n, dispatch: t }) => Zt(n, t), Mn = () => ({ state: n, dispatch: t }) => Xt(n, t), Sn = () => ({ state: n, dispatch: t }) => Qt(n, t);
function it(n, t, e = {}, r = {}) {
  return D(n, t, {
    slice: !1,
    parseOptions: e,
    errorOnInvalidContent: r.errorOnInvalidContent
  });
}
const En = (n, t = !1, e = {}, r = {}) => ({ editor: s, tr: o, dispatch: i, commands: c }) => {
  var a, l;
  const { doc: u } = o;
  if (e.preserveWhitespace !== "full") {
    const d = it(n, s.schema, e, {
      errorOnInvalidContent: (a = r.errorOnInvalidContent) !== null && a !== void 0 ? a : s.options.enableContentCheck
    });
    return i && o.replaceWith(0, u.content.size, d).setMeta("preventUpdate", !t), !0;
  }
  return i && o.setMeta("preventUpdate", !t), c.insertContentAt({ from: 0, to: u.content.size }, n, {
    parseOptions: e,
    errorOnInvalidContent: (l = r.errorOnInvalidContent) !== null && l !== void 0 ? l : s.options.enableContentCheck
  });
};
function jt(n, t) {
  const e = $(t, n.schema), { from: r, to: s, empty: o } = n.selection, i = [];
  o ? (n.storedMarks && i.push(...n.storedMarks), i.push(...n.selection.$head.marks())) : n.doc.nodesBetween(r, s, (a) => {
    i.push(...a.marks);
  });
  const c = i.find((a) => a.type.name === e.name);
  return c ? { ...c.attrs } : {};
}
function gr(n, t) {
  const e = new Ut(n);
  return t.forEach((r) => {
    r.steps.forEach((s) => {
      e.step(s);
    });
  }), e;
}
function xn(n) {
  for (let t = 0; t < n.edgeCount; t += 1) {
    const { type: e } = n.edge(t);
    if (e.isTextblock && !e.hasRequiredAttrs())
      return e;
  }
  return null;
}
function yr(n, t, e) {
  const r = [];
  return n.nodesBetween(t.from, t.to, (s, o) => {
    e(s) && r.push({
      node: s,
      pos: o
    });
  }), r;
}
function Cn(n, t) {
  for (let e = n.depth; e > 0; e -= 1) {
    const r = n.node(e);
    if (t(r))
      return {
        pos: e > 0 ? n.before(e) : 0,
        start: n.start(e),
        depth: e,
        node: r
      };
  }
}
function ht(n) {
  return (t) => Cn(t.$from, n);
}
function Tn(n, t) {
  const e = {
    from: 0,
    to: n.content.size
  };
  return At(n, e, t);
}
function An(n, t) {
  const e = S(t, n.schema), { from: r, to: s } = n.selection, o = [];
  n.doc.nodesBetween(r, s, (c) => {
    o.push(c);
  });
  const i = o.reverse().find((c) => c.type.name === e.name);
  return i ? { ...i.attrs } : {};
}
function Pn(n, t) {
  const e = tt(typeof t == "string" ? t : t.name, n.schema);
  return e === "node" ? An(n, t) : e === "mark" ? jt(n, t) : {};
}
function On(n, t = JSON.stringify) {
  const e = {};
  return n.filter((r) => {
    const s = t(r);
    return Object.prototype.hasOwnProperty.call(e, s) ? !1 : e[s] = !0;
  });
}
function In(n) {
  const t = On(n);
  return t.length === 1 ? t : t.filter((e, r) => !t.filter((o, i) => i !== r).some((o) => e.oldRange.from >= o.oldRange.from && e.oldRange.to <= o.oldRange.to && e.newRange.from >= o.newRange.from && e.newRange.to <= o.newRange.to));
}
function kr(n) {
  const { mapping: t, steps: e } = n, r = [];
  return t.maps.forEach((s, o) => {
    const i = [];
    if (s.ranges.length)
      s.forEach((c, a) => {
        i.push({ from: c, to: a });
      });
    else {
      const { from: c, to: a } = e[o];
      if (c === void 0 || a === void 0)
        return;
      i.push({ from: c, to: a });
    }
    i.forEach(({ from: c, to: a }) => {
      const l = t.slice(o).map(c, -1), u = t.slice(o).map(a), d = t.invert().map(l, -1), f = t.invert().map(u);
      r.push({
        oldRange: {
          from: d,
          to: f
        },
        newRange: {
          from: l,
          to: u
        }
      });
    });
  }), In(r);
}
function Rt(n, t, e) {
  const r = [];
  return n === t ? e.resolve(n).marks().forEach((s) => {
    const o = e.resolve(n), i = ft(o, s.type);
    i && r.push({
      mark: s,
      ...i
    });
  }) : e.nodesBetween(n, t, (s, o) => {
    !s || (s == null ? void 0 : s.nodeSize) === void 0 || r.push(...s.marks.map((i) => ({
      from: o,
      to: o + s.nodeSize,
      mark: i
    })));
  }), r;
}
function K(n, t, e) {
  return Object.fromEntries(Object.entries(e).filter(([r]) => {
    const s = n.find((o) => o.type === t && o.name === r);
    return s ? s.attribute.keepOnSplit : !1;
  }));
}
function at(n, t, e = {}) {
  const { empty: r, ranges: s } = n.selection, o = t ? $(t, n.schema) : null;
  if (r)
    return !!(n.storedMarks || n.selection.$from.marks()).filter((d) => o ? o.name === d.type.name : !0).find((d) => q(d.attrs, e, { strict: !1 }));
  let i = 0;
  const c = [];
  if (s.forEach(({ $from: d, $to: f }) => {
    const p = d.pos, g = f.pos;
    n.doc.nodesBetween(p, g, (h, m) => {
      if (!h.isText && !h.marks.length)
        return;
      const k = Math.max(p, m), v = Math.min(g, m + h.nodeSize), w = v - k;
      i += w, c.push(...h.marks.map((E) => ({
        mark: E,
        from: k,
        to: v
      })));
    });
  }), i === 0)
    return !1;
  const a = c.filter((d) => o ? o.name === d.mark.type.name : !0).filter((d) => q(d.mark.attrs, e, { strict: !1 })).reduce((d, f) => d + f.to - f.from, 0), l = c.filter((d) => o ? d.mark.type !== o && d.mark.type.excludes(o) : !0).reduce((d, f) => d + f.to - f.from, 0);
  return (a > 0 ? a + l : a) >= i;
}
function $n(n, t, e = {}) {
  if (!t)
    return L(n, null, e) || at(n, null, e);
  const r = tt(t, n.schema);
  return r === "node" ? L(n, t, e) : r === "mark" ? at(n, t, e) : !1;
}
function Mt(n, t) {
  const { nodeExtensions: e } = Q(t), r = e.find((i) => i.name === n);
  if (!r)
    return !1;
  const s = {
    name: r.name,
    options: r.options,
    storage: r.storage
  }, o = b(y(r, "group", s));
  return typeof o != "string" ? !1 : o.split(" ").includes("list");
}
function mt(n, { checkChildren: t = !0, ignoreWhitespace: e = !1 } = {}) {
  var r;
  if (e) {
    if (n.type.name === "hardBreak")
      return !0;
    if (n.isText)
      return /^\s*$/m.test((r = n.text) !== null && r !== void 0 ? r : "");
  }
  if (n.isText)
    return !n.text;
  if (n.isAtom || n.isLeaf)
    return !1;
  if (n.content.childCount === 0)
    return !0;
  if (t) {
    let s = !0;
    return n.content.forEach((o) => {
      s !== !1 && (mt(o, { ignoreWhitespace: e, checkChildren: t }) || (s = !1));
    }), s;
  }
  return !1;
}
function br(n) {
  return n instanceof G;
}
function Bn(n, t, e) {
  var r;
  const { selection: s } = t;
  let o = null;
  if (It(s) && (o = s.$cursor), o) {
    const c = (r = n.storedMarks) !== null && r !== void 0 ? r : o.marks();
    return !!e.isInSet(c) || !c.some((a) => a.type.excludes(e));
  }
  const { ranges: i } = s;
  return i.some(({ $from: c, $to: a }) => {
    let l = c.depth === 0 ? n.doc.inlineContent && n.doc.type.allowsMarkType(e) : !1;
    return n.doc.nodesBetween(c.pos, a.pos, (u, d, f) => {
      if (l)
        return !1;
      if (u.isInline) {
        const p = !f || f.type.allowsMarkType(e), g = !!e.isInSet(u.marks) || !u.marks.some((h) => h.type.excludes(e));
        l = p && g;
      }
      return !l;
    }), l;
  });
}
const Nn = (n, t = {}) => ({ tr: e, state: r, dispatch: s }) => {
  const { selection: o } = e, { empty: i, ranges: c } = o, a = $(n, r.schema);
  if (s)
    if (i) {
      const l = jt(r, a);
      e.addStoredMark(a.create({
        ...l,
        ...t
      }));
    } else
      c.forEach((l) => {
        const u = l.$from.pos, d = l.$to.pos;
        r.doc.nodesBetween(u, d, (f, p) => {
          const g = Math.max(p, u), h = Math.min(p + f.nodeSize, d);
          f.marks.find((k) => k.type === a) ? f.marks.forEach((k) => {
            a === k.type && e.addMark(g, h, a.create({
              ...k.attrs,
              ...t
            }));
          }) : e.addMark(g, h, a.create(t));
        });
      });
  return Bn(r, e, a);
}, jn = (n, t) => ({ tr: e }) => (e.setMeta(n, t), !0), Rn = (n, t = {}) => ({ state: e, dispatch: r, chain: s }) => {
  const o = S(n, e.schema);
  let i;
  return e.selection.$anchor.sameParent(e.selection.$head) && (i = e.selection.$anchor.parent.attrs), o.isTextblock ? s().command(({ commands: c }) => gt(o, { ...i, ...t })(e) ? !0 : c.clearNodes()).command(({ state: c }) => gt(o, { ...i, ...t })(c, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), !1);
}, Fn = (n) => ({ tr: t, dispatch: e }) => {
  if (e) {
    const { doc: r } = t, s = N(n, 0, r.content.size), o = G.create(r, s);
    t.setSelection(o);
  }
  return !0;
}, Dn = (n) => ({ tr: t, dispatch: e }) => {
  if (e) {
    const { doc: r } = t, { from: s, to: o } = typeof n == "number" ? { from: n, to: n } : n, i = P.atStart(r).from, c = P.atEnd(r).to, a = N(s, i, c), l = N(o, i, c), u = P.create(r, a, l);
    t.setSelection(u);
  }
  return !0;
}, Ln = (n) => ({ state: t, dispatch: e }) => {
  const r = S(n, t.schema);
  return me(r)(t, e);
};
function St(n, t) {
  const e = n.storedMarks || n.selection.$to.parentOffset && n.selection.$from.marks();
  if (e) {
    const r = e.filter((s) => t == null ? void 0 : t.includes(s.type.name));
    n.tr.ensureMarks(r);
  }
}
const zn = ({ keepMarks: n = !0 } = {}) => ({ tr: t, state: e, dispatch: r, editor: s }) => {
  const { selection: o, doc: i } = t, { $from: c, $to: a } = o, l = s.extensionManager.attributes, u = K(l, c.node().type.name, c.node().attrs);
  if (o instanceof G && o.node.isBlock)
    return !c.parentOffset || !W(i, c.pos) ? !1 : (r && (n && St(e, s.extensionManager.splittableMarks), t.split(c.pos).scrollIntoView()), !0);
  if (!c.parent.isBlock)
    return !1;
  const d = a.parentOffset === a.parent.content.size, f = c.depth === 0 ? void 0 : xn(c.node(-1).contentMatchAt(c.indexAfter(-1)));
  let p = d && f ? [
    {
      type: f,
      attrs: u
    }
  ] : void 0, g = W(t.doc, t.mapping.map(c.pos), 1, p);
  if (!p && !g && W(t.doc, t.mapping.map(c.pos), 1, f ? [{ type: f }] : void 0) && (g = !0, p = f ? [
    {
      type: f,
      attrs: u
    }
  ] : void 0), r) {
    if (g && (o instanceof P && t.deleteSelection(), t.split(t.mapping.map(c.pos), 1, p), f && !d && !c.parentOffset && c.parent.type !== f)) {
      const h = t.mapping.map(c.before()), m = t.doc.resolve(h);
      c.node(-1).canReplaceWith(m.index(), m.index() + 1, f) && t.setNodeMarkup(t.mapping.map(c.before()), f);
    }
    n && St(e, s.extensionManager.splittableMarks), t.scrollIntoView();
  }
  return g;
}, Hn = (n, t = {}) => ({ tr: e, state: r, dispatch: s, editor: o }) => {
  var i;
  const c = S(n, r.schema), { $from: a, $to: l } = r.selection, u = r.selection.node;
  if (u && u.isBlock || a.depth < 2 || !a.sameParent(l))
    return !1;
  const d = a.node(-1);
  if (d.type !== c)
    return !1;
  const f = o.extensionManager.attributes;
  if (a.parent.content.size === 0 && a.node(-1).childCount === a.indexAfter(-1)) {
    if (a.depth === 2 || a.node(-3).type !== c || a.index(-2) !== a.node(-2).childCount - 1)
      return !1;
    if (s) {
      let k = I.empty;
      const v = a.index(-1) ? 1 : a.index(-2) ? 2 : 3;
      for (let A = a.depth - v; A >= a.depth - 3; A -= 1)
        k = I.from(a.node(A).copy(k));
      const w = a.indexAfter(-1) < a.node(-2).childCount ? 1 : a.indexAfter(-2) < a.node(-3).childCount ? 2 : 3, E = {
        ...K(f, a.node().type.name, a.node().attrs),
        ...t
      }, M = ((i = c.contentMatch.defaultType) === null || i === void 0 ? void 0 : i.createAndFill(E)) || void 0;
      k = k.append(I.from(c.createAndFill(null, M) || void 0));
      const x = a.before(a.depth - (v - 1));
      e.replace(x, a.after(-w), new Wt(k, 4 - v, 0));
      let T = -1;
      e.doc.nodesBetween(x, e.doc.content.size, (A, Ft) => {
        if (T > -1)
          return !1;
        A.isTextblock && A.content.size === 0 && (T = Ft + 1);
      }), T > -1 && e.setSelection(P.near(e.doc.resolve(T))), e.scrollIntoView();
    }
    return !0;
  }
  const p = l.pos === a.end() ? d.contentMatchAt(0).defaultType : null, g = {
    ...K(f, d.type.name, d.attrs),
    ...t
  }, h = {
    ...K(f, a.node().type.name, a.node().attrs),
    ...t
  };
  e.delete(a.pos, l.pos);
  const m = p ? [
    { type: c, attrs: g },
    { type: p, attrs: h }
  ] : [{ type: c, attrs: g }];
  if (!W(e.doc, a.pos, 2))
    return !1;
  if (s) {
    const { selection: k, storedMarks: v } = r, { splittableMarks: w } = o.extensionManager, E = v || k.$to.parentOffset && k.$from.marks();
    if (e.split(a.pos, 2, m).scrollIntoView(), !E || !s)
      return !0;
    const M = E.filter((x) => w.includes(x.type.name));
    e.ensureMarks(M);
  }
  return !0;
}, rt = (n, t) => {
  const e = ht((i) => i.type === t)(n.selection);
  if (!e)
    return !0;
  const r = n.doc.resolve(Math.max(0, e.pos - 1)).before(e.depth);
  if (r === void 0)
    return !0;
  const s = n.doc.nodeAt(r);
  return e.node.type === (s == null ? void 0 : s.type) && lt(n.doc, e.pos) && n.join(e.pos), !0;
}, st = (n, t) => {
  const e = ht((i) => i.type === t)(n.selection);
  if (!e)
    return !0;
  const r = n.doc.resolve(e.start).after(e.depth);
  if (r === void 0)
    return !0;
  const s = n.doc.nodeAt(r);
  return e.node.type === (s == null ? void 0 : s.type) && lt(n.doc, r) && n.join(r), !0;
}, _n = (n, t, e, r = {}) => ({ editor: s, tr: o, state: i, dispatch: c, chain: a, commands: l, can: u }) => {
  const { extensions: d, splittableMarks: f } = s.extensionManager, p = S(n, i.schema), g = S(t, i.schema), { selection: h, storedMarks: m } = i, { $from: k, $to: v } = h, w = k.blockRange(v), E = m || h.$to.parentOffset && h.$from.marks();
  if (!w)
    return !1;
  const M = ht((x) => Mt(x.type.name, d))(h);
  if (w.depth >= 1 && M && w.depth - M.depth <= 1) {
    if (M.node.type === p)
      return l.liftListItem(g);
    if (Mt(M.node.type.name, d) && p.validContent(M.node.content) && c)
      return a().command(() => (o.setNodeMarkup(M.pos, p), !0)).command(() => rt(o, p)).command(() => st(o, p)).run();
  }
  return !e || !E || !c ? a().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => rt(o, p)).command(() => st(o, p)).run() : a().command(() => {
    const x = u().wrapInList(p, r), T = E.filter((A) => f.includes(A.type.name));
    return o.ensureMarks(T), x ? !0 : l.clearNodes();
  }).wrapInList(p, r).command(() => rt(o, p)).command(() => st(o, p)).run();
}, Vn = (n, t = {}, e = {}) => ({ state: r, commands: s }) => {
  const { extendEmptyMarkRange: o = !1 } = e, i = $(n, r.schema);
  return at(r, i, t) ? s.unsetMark(i, { extendEmptyMarkRange: o }) : s.setMark(i, t);
}, Wn = (n, t, e = {}) => ({ state: r, commands: s }) => {
  const o = S(n, r.schema), i = S(t, r.schema), c = L(r, o, e);
  let a;
  return r.selection.$anchor.sameParent(r.selection.$head) && (a = r.selection.$anchor.parent.attrs), c ? s.setNode(i, a) : s.setNode(o, { ...a, ...e });
}, Kn = (n, t = {}) => ({ state: e, commands: r }) => {
  const s = S(n, e.schema);
  return L(e, s, t) ? r.lift(s) : r.wrapIn(s, t);
}, Un = () => ({ state: n, dispatch: t }) => {
  const e = n.plugins;
  for (let r = 0; r < e.length; r += 1) {
    const s = e[r];
    let o;
    if (s.spec.isInputRules && (o = s.getState(n))) {
      if (t) {
        const i = n.tr, c = o.transform;
        for (let a = c.steps.length - 1; a >= 0; a -= 1)
          i.step(c.steps[a].invert(c.docs[a]));
        if (o.text) {
          const a = i.doc.resolve(o.from).marks();
          i.replaceWith(o.from, o.to, n.schema.text(o.text, a));
        } else
          i.delete(o.from, o.to);
      }
      return !0;
    }
  }
  return !1;
}, qn = () => ({ tr: n, dispatch: t }) => {
  const { selection: e } = n, { empty: r, ranges: s } = e;
  return r || t && s.forEach((o) => {
    n.removeMark(o.$from.pos, o.$to.pos);
  }), !0;
}, Gn = (n, t = {}) => ({ tr: e, state: r, dispatch: s }) => {
  var o;
  const { extendEmptyMarkRange: i = !1 } = t, { selection: c } = e, a = $(n, r.schema), { $from: l, empty: u, ranges: d } = c;
  if (!s)
    return !0;
  if (u && i) {
    let { from: f, to: p } = c;
    const g = (o = l.marks().find((m) => m.type === a)) === null || o === void 0 ? void 0 : o.attrs, h = ft(l, a, g);
    h && (f = h.from, p = h.to), e.removeMark(f, p, a);
  } else
    d.forEach((f) => {
      e.removeMark(f.$from.pos, f.$to.pos, a);
    });
  return e.removeStoredMark(a), !0;
}, Jn = (n, t = {}) => ({ tr: e, state: r, dispatch: s }) => {
  let o = null, i = null;
  const c = tt(typeof n == "string" ? n : n.name, r.schema);
  return c ? (c === "node" && (o = S(n, r.schema)), c === "mark" && (i = $(n, r.schema)), s && e.selection.ranges.forEach((a) => {
    const l = a.$from.pos, u = a.$to.pos;
    let d, f, p, g;
    e.selection.empty ? r.doc.nodesBetween(l, u, (h, m) => {
      o && o === h.type && (p = Math.max(m, l), g = Math.min(m + h.nodeSize, u), d = m, f = h);
    }) : r.doc.nodesBetween(l, u, (h, m) => {
      m < l && o && o === h.type && (p = Math.max(m, l), g = Math.min(m + h.nodeSize, u), d = m, f = h), m >= l && m <= u && (o && o === h.type && e.setNodeMarkup(m, void 0, {
        ...h.attrs,
        ...t
      }), i && h.marks.length && h.marks.forEach((k) => {
        if (i === k.type) {
          const v = Math.max(m, l), w = Math.min(m + h.nodeSize, u);
          e.addMark(v, w, i.create({
            ...k.attrs,
            ...t
          }));
        }
      }));
    }), f && (d !== void 0 && e.setNodeMarkup(d, void 0, {
      ...f.attrs,
      ...t
    }), i && f.marks.length && f.marks.forEach((h) => {
      i === h.type && e.addMark(p, g, i.create({
        ...h.attrs,
        ...t
      }));
    }));
  }), !0) : !1;
}, Yn = (n, t = {}) => ({ state: e, dispatch: r }) => {
  const s = S(n, e.schema);
  return Yt(s, t)(e, r);
}, Qn = (n, t = {}) => ({ state: e, dispatch: r }) => {
  const s = S(n, e.schema);
  return he(s, t)(e, r);
};
var Xn = /* @__PURE__ */ Object.freeze({
  __proto__: null,
  blur: Ne,
  clearContent: je,
  clearNodes: Re,
  command: Fe,
  createParagraphNear: De,
  cut: Le,
  deleteCurrentNode: ze,
  deleteNode: He,
  deleteRange: _e,
  deleteSelection: Ve,
  enter: We,
  exitCode: Ke,
  extendMarkRange: Ue,
  first: qe,
  focus: Je,
  forEach: Ye,
  insertContent: Qe,
  insertContentAt: tn,
  joinBackward: rn,
  joinDown: nn,
  joinForward: sn,
  joinItemBackward: on,
  joinItemForward: an,
  joinTextblockBackward: cn,
  joinTextblockForward: ln,
  joinUp: en,
  keyboardShortcut: un,
  lift: fn,
  liftEmptyBlock: pn,
  liftListItem: hn,
  newlineInCode: mn,
  resetAttributes: gn,
  scrollIntoView: yn,
  selectAll: kn,
  selectNodeBackward: bn,
  selectNodeForward: vn,
  selectParentNode: wn,
  selectTextblockEnd: Mn,
  selectTextblockStart: Sn,
  setContent: En,
  setMark: Nn,
  setMeta: jn,
  setNode: Rn,
  setNodeSelection: Fn,
  setTextSelection: Dn,
  sinkListItem: Ln,
  splitBlock: zn,
  splitListItem: Hn,
  toggleList: _n,
  toggleMark: Vn,
  toggleNode: Wn,
  toggleWrap: Kn,
  undoInputRule: Un,
  unsetAllMarks: qn,
  unsetMark: Gn,
  updateAttributes: Jn,
  wrapIn: Yn,
  wrapInList: Qn
});
const Zn = C.create({
  name: "commands",
  addCommands() {
    return {
      ...Xn
    };
  }
}), tr = C.create({
  name: "drop",
  addProseMirrorPlugins() {
    return [
      new O({
        key: new j("tiptapDrop"),
        props: {
          handleDrop: (n, t, e, r) => {
            this.editor.emit("drop", {
              editor: this.editor,
              event: t,
              slice: e,
              moved: r
            });
          }
        }
      })
    ];
  }
}), er = C.create({
  name: "editable",
  addProseMirrorPlugins() {
    return [
      new O({
        key: new j("editable"),
        props: {
          editable: () => this.editor.options.editable
        }
      })
    ];
  }
}), nr = new j("focusEvents"), rr = C.create({
  name: "focusEvents",
  addProseMirrorPlugins() {
    const { editor: n } = this;
    return [
      new O({
        key: nr,
        props: {
          handleDOMEvents: {
            focus: (t, e) => {
              n.isFocused = !0;
              const r = n.state.tr.setMeta("focus", { event: e }).setMeta("addToHistory", !1);
              return t.dispatch(r), !1;
            },
            blur: (t, e) => {
              n.isFocused = !1;
              const r = n.state.tr.setMeta("blur", { event: e }).setMeta("addToHistory", !1);
              return t.dispatch(r), !1;
            }
          }
        }
      })
    ];
  }
}), sr = C.create({
  name: "keymap",
  addKeyboardShortcuts() {
    const n = () => this.editor.commands.first(({ commands: i }) => [
      () => i.undoInputRule(),
      // maybe convert first text block node to default node
      () => i.command(({ tr: c }) => {
        const { selection: a, doc: l } = c, { empty: u, $anchor: d } = a, { pos: f, parent: p } = d, g = d.parent.isTextblock && f > 0 ? c.doc.resolve(f - 1) : d, h = g.parent.type.spec.isolating, m = d.pos - d.parentOffset, k = h && g.parent.childCount === 1 ? m === d.pos : F.atStart(l).from === f;
        return !u || !p.type.isTextblock || p.textContent.length || !k || k && d.parent.type.name === "paragraph" ? !1 : i.clearNodes();
      }),
      () => i.deleteSelection(),
      () => i.joinBackward(),
      () => i.selectNodeBackward()
    ]), t = () => this.editor.commands.first(({ commands: i }) => [
      () => i.deleteSelection(),
      () => i.deleteCurrentNode(),
      () => i.joinForward(),
      () => i.selectNodeForward()
    ]), r = {
      Enter: () => this.editor.commands.first(({ commands: i }) => [
        () => i.newlineInCode(),
        () => i.createParagraphNear(),
        () => i.liftEmptyBlock(),
        () => i.splitBlock()
      ]),
      "Mod-Enter": () => this.editor.commands.exitCode(),
      Backspace: n,
      "Mod-Backspace": n,
      "Shift-Backspace": n,
      Delete: t,
      "Mod-Delete": t,
      "Mod-a": () => this.editor.commands.selectAll()
    }, s = {
      ...r
    }, o = {
      ...r,
      "Ctrl-h": n,
      "Alt-Backspace": n,
      "Ctrl-d": t,
      "Ctrl-Alt-Backspace": t,
      "Alt-Delete": t,
      "Alt-d": t,
      "Ctrl-a": () => this.editor.commands.selectTextblockStart(),
      "Ctrl-e": () => this.editor.commands.selectTextblockEnd()
    };
    return pt() || Nt() ? o : s;
  },
  addProseMirrorPlugins() {
    return [
      // With this plugin we check if the whole document was selected and deleted.
      // In this case we will additionally call `clearNodes()` to convert e.g. a heading
      // to a paragraph if necessary.
      // This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well
      // with many other commands.
      new O({
        key: new j("clearDocument"),
        appendTransaction: (n, t, e) => {
          if (n.some((h) => h.getMeta("composition")))
            return;
          const r = n.some((h) => h.docChanged) && !t.doc.eq(e.doc), s = n.some((h) => h.getMeta("preventClearDocument"));
          if (!r || s)
            return;
          const { empty: o, from: i, to: c } = t.selection, a = F.atStart(t.doc).from, l = F.atEnd(t.doc).to;
          if (o || !(i === a && c === l) || !mt(e.doc))
            return;
          const f = e.tr, p = J({
            state: e,
            transaction: f
          }), { commands: g } = new Y({
            editor: this.editor,
            state: p
          });
          if (g.clearNodes(), !!f.steps.length)
            return f;
        }
      })
    ];
  }
}), or = C.create({
  name: "paste",
  addProseMirrorPlugins() {
    return [
      new O({
        key: new j("tiptapPaste"),
        props: {
          handlePaste: (n, t, e) => {
            this.editor.emit("paste", {
              editor: this.editor,
              event: t,
              slice: e
            });
          }
        }
      })
    ];
  }
}), ir = C.create({
  name: "tabindex",
  addProseMirrorPlugins() {
    return [
      new O({
        key: new j("tabindex"),
        props: {
          attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
        }
      })
    ];
  }
});
class B {
  get name() {
    return this.node.type.name;
  }
  constructor(t, e, r = !1, s = null) {
    this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = t, this.editor = e, this.currentNode = s;
  }
  get node() {
    return this.currentNode || this.resolvedPos.node();
  }
  get element() {
    return this.editor.view.domAtPos(this.pos).node;
  }
  get depth() {
    var t;
    return (t = this.actualDepth) !== null && t !== void 0 ? t : this.resolvedPos.depth;
  }
  get pos() {
    return this.resolvedPos.pos;
  }
  get content() {
    return this.node.content;
  }
  set content(t) {
    let e = this.from, r = this.to;
    if (this.isBlock) {
      if (this.content.size === 0) {
        console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);
        return;
      }
      e = this.from + 1, r = this.to - 1;
    }
    this.editor.commands.insertContentAt({ from: e, to: r }, t);
  }
  get attributes() {
    return this.node.attrs;
  }
  get textContent() {
    return this.node.textContent;
  }
  get size() {
    return this.node.nodeSize;
  }
  get from() {
    return this.isBlock ? this.pos : this.resolvedPos.start(this.resolvedPos.depth);
  }
  get range() {
    return {
      from: this.from,
      to: this.to
    };
  }
  get to() {
    return this.isBlock ? this.pos + this.size : this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1);
  }
  get parent() {
    if (this.depth === 0)
      return null;
    const t = this.resolvedPos.start(this.resolvedPos.depth - 1), e = this.resolvedPos.doc.resolve(t);
    return new B(e, this.editor);
  }
  get before() {
    let t = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
    return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.from - 3)), new B(t, this.editor);
  }
  get after() {
    let t = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
    return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.to + 3)), new B(t, this.editor);
  }
  get children() {
    const t = [];
    return this.node.content.forEach((e, r) => {
      const s = e.isBlock && !e.isTextblock, o = e.isAtom && !e.isText, i = this.pos + r + (o ? 0 : 1);
      if (i < 0 || i > this.resolvedPos.doc.nodeSize - 2)
        return;
      const c = this.resolvedPos.doc.resolve(i);
      if (!s && c.depth <= this.depth)
        return;
      const a = new B(c, this.editor, s, s ? e : null);
      s && (a.actualDepth = this.depth + 1), t.push(new B(c, this.editor, s, s ? e : null));
    }), t;
  }
  get firstChild() {
    return this.children[0] || null;
  }
  get lastChild() {
    const t = this.children;
    return t[t.length - 1] || null;
  }
  closest(t, e = {}) {
    let r = null, s = this.parent;
    for (; s && !r; ) {
      if (s.node.type.name === t)
        if (Object.keys(e).length > 0) {
          const o = s.node.attrs, i = Object.keys(e);
          for (let c = 0; c < i.length; c += 1) {
            const a = i[c];
            if (o[a] !== e[a])
              break;
          }
        } else
          r = s;
      s = s.parent;
    }
    return r;
  }
  querySelector(t, e = {}) {
    return this.querySelectorAll(t, e, !0)[0] || null;
  }
  querySelectorAll(t, e = {}, r = !1) {
    let s = [];
    if (!this.children || this.children.length === 0)
      return s;
    const o = Object.keys(e);
    return this.children.forEach((i) => {
      r && s.length > 0 || (i.node.type.name === t && o.every((a) => e[a] === i.node.attrs[a]) && s.push(i), !(r && s.length > 0) && (s = s.concat(i.querySelectorAll(t, e, r))));
    }), s;
  }
  setAttribute(t) {
    const { tr: e } = this.editor.state;
    e.setNodeMarkup(this.from, void 0, {
      ...this.node.attrs,
      ...t
    }), this.editor.view.dispatch(e);
  }
}
const ar = `.ProseMirror {
  position: relative;
}

.ProseMirror {
  word-wrap: break-word;
  white-space: pre-wrap;
  white-space: break-spaces;
  -webkit-font-variant-ligatures: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}

.ProseMirror [contenteditable="false"] {
  white-space: normal;
}

.ProseMirror [contenteditable="false"] [contenteditable="true"] {
  white-space: pre-wrap;
}

.ProseMirror pre {
  white-space: pre-wrap;
}

img.ProseMirror-separator {
  display: inline !important;
  border: none !important;
  margin: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

.ProseMirror-gapcursor {
  display: none;
  pointer-events: none;
  position: absolute;
  margin: 0;
}

.ProseMirror-gapcursor:after {
  content: "";
  display: block;
  position: absolute;
  top: -2px;
  width: 20px;
  border-top: 1px solid black;
  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}

@keyframes ProseMirror-cursor-blink {
  to {
    visibility: hidden;
  }
}

.ProseMirror-hideselection *::selection {
  background: transparent;
}

.ProseMirror-hideselection *::-moz-selection {
  background: transparent;
}

.ProseMirror-hideselection * {
  caret-color: transparent;
}

.ProseMirror-focused .ProseMirror-gapcursor {
  display: block;
}

.tippy-box[data-animation=fade][data-state=hidden] {
  opacity: 0
}`;
function cr(n, t, e) {
  const r = document.querySelector("style[data-tiptap-style]");
  if (r !== null)
    return r;
  const s = document.createElement("style");
  return t && s.setAttribute("nonce", t), s.setAttribute("data-tiptap-style", ""), s.innerHTML = n, document.getElementsByTagName("head")[0].appendChild(s), s;
}
class vr extends ye {
  constructor(t = {}) {
    super(), this.isFocused = !1, this.isInitialized = !1, this.extensionStorage = {}, this.options = {
      element: document.createElement("div"),
      content: "",
      injectCSS: !0,
      injectNonce: void 0,
      extensions: [],
      autofocus: !1,
      editable: !0,
      editorProps: {},
      parseOptions: {},
      coreExtensionOptions: {},
      enableInputRules: !0,
      enablePasteRules: !0,
      enableCoreExtensions: !0,
      enableContentCheck: !1,
      emitContentError: !1,
      onBeforeCreate: () => null,
      onCreate: () => null,
      onUpdate: () => null,
      onSelectionUpdate: () => null,
      onTransaction: () => null,
      onFocus: () => null,
      onBlur: () => null,
      onDestroy: () => null,
      onContentError: ({ error: e }) => {
        throw e;
      },
      onPaste: () => null,
      onDrop: () => null
    }, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.setOptions(t), this.createExtensionManager(), this.createCommandManager(), this.createSchema(), this.on("beforeCreate", this.options.onBeforeCreate), this.emit("beforeCreate", { editor: this }), this.on("contentError", this.options.onContentError), this.createView(), this.injectCSS(), this.on("create", this.options.onCreate), this.on("update", this.options.onUpdate), this.on("selectionUpdate", this.options.onSelectionUpdate), this.on("transaction", this.options.onTransaction), this.on("focus", this.options.onFocus), this.on("blur", this.options.onBlur), this.on("destroy", this.options.onDestroy), this.on("drop", ({ event: e, slice: r, moved: s }) => this.options.onDrop(e, r, s)), this.on("paste", ({ event: e, slice: r }) => this.options.onPaste(e, r)), window.setTimeout(() => {
      this.isDestroyed || (this.commands.focus(this.options.autofocus), this.emit("create", { editor: this }), this.isInitialized = !0);
    }, 0);
  }
  /**
   * Returns the editor storage.
   */
  get storage() {
    return this.extensionStorage;
  }
  /**
   * An object of all registered commands.
   */
  get commands() {
    return this.commandManager.commands;
  }
  /**
   * Create a command chain to call multiple commands at once.
   */
  chain() {
    return this.commandManager.chain();
  }
  /**
   * Check if a command or a command chain can be executed. Without executing it.
   */
  can() {
    return this.commandManager.can();
  }
  /**
   * Inject CSS styles.
   */
  injectCSS() {
    this.options.injectCSS && document && (this.css = cr(ar, this.options.injectNonce));
  }
  /**
   * Update editor options.
   *
   * @param options A list of options
   */
  setOptions(t = {}) {
    this.options = {
      ...this.options,
      ...t
    }, !(!this.view || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state));
  }
  /**
   * Update editable state of the editor.
   */
  setEditable(t, e = !0) {
    this.setOptions({ editable: t }), e && this.emit("update", { editor: this, transaction: this.state.tr });
  }
  /**
   * Returns whether the editor is editable.
   */
  get isEditable() {
    return this.options.editable && this.view && this.view.editable;
  }
  /**
   * Returns the editor state.
   */
  get state() {
    return this.view.state;
  }
  /**
   * Register a ProseMirror plugin.
   *
   * @param plugin A ProseMirror plugin
   * @param handlePlugins Control how to merge the plugin into the existing plugins.
   * @returns The new editor state
   */
  registerPlugin(t, e) {
    const r = Tt(e) ? e(t, [...this.state.plugins]) : [...this.state.plugins, t], s = this.state.reconfigure({ plugins: r });
    return this.view.updateState(s), s;
  }
  /**
   * Unregister a ProseMirror plugin.
   *
   * @param nameOrPluginKeyToRemove The plugins name
   * @returns The new editor state or undefined if the editor is destroyed
   */
  unregisterPlugin(t) {
    if (this.isDestroyed)
      return;
    const e = this.state.plugins;
    let r = e;
    if ([].concat(t).forEach((o) => {
      const i = typeof o == "string" ? `${o}$` : o.key;
      r = r.filter((c) => !c.key.startsWith(i));
    }), e.length === r.length)
      return;
    const s = this.state.reconfigure({
      plugins: r
    });
    return this.view.updateState(s), s;
  }
  /**
   * Creates an extension manager.
   */
  createExtensionManager() {
    var t, e;
    const s = [...this.options.enableCoreExtensions ? [
      er,
      Be.configure({
        blockSeparator: (e = (t = this.options.coreExtensionOptions) === null || t === void 0 ? void 0 : t.clipboardTextSerializer) === null || e === void 0 ? void 0 : e.blockSeparator
      }),
      Zn,
      rr,
      sr,
      ir,
      tr,
      or
    ].filter((o) => typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[o.name] !== !1 : !0) : [], ...this.options.extensions].filter((o) => ["extension", "node", "mark"].includes(o == null ? void 0 : o.type));
    this.extensionManager = new R(s, this);
  }
  /**
   * Creates an command manager.
   */
  createCommandManager() {
    this.commandManager = new Y({
      editor: this
    });
  }
  /**
   * Creates a ProseMirror schema.
   */
  createSchema() {
    this.schema = this.extensionManager.schema;
  }
  /**
   * Creates a ProseMirror view.
   */
  createView() {
    var t;
    let e;
    try {
      e = it(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
    } catch (i) {
      if (!(i instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(i.message))
        throw i;
      this.emit("contentError", {
        editor: this,
        error: i,
        disableCollaboration: () => {
          this.storage.collaboration && (this.storage.collaboration.isDisabled = !0), this.options.extensions = this.options.extensions.filter((c) => c.name !== "collaboration"), this.createExtensionManager();
        }
      }), e = it(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 });
    }
    const r = $t(e, this.options.autofocus);
    this.view = new zt(this.options.element, {
      ...this.options.editorProps,
      attributes: {
        // add `role="textbox"` to the editor element
        role: "textbox",
        ...(t = this.options.editorProps) === null || t === void 0 ? void 0 : t.attributes
      },
      dispatchTransaction: this.dispatchTransaction.bind(this),
      state: Dt.create({
        doc: e,
        selection: r || void 0
      })
    });
    const s = this.state.reconfigure({
      plugins: this.extensionManager.plugins
    });
    this.view.updateState(s), this.createNodeViews(), this.prependClass();
    const o = this.view.dom;
    o.editor = this;
  }
  /**
   * Creates all node views.
   */
  createNodeViews() {
    this.view.isDestroyed || this.view.setProps({
      nodeViews: this.extensionManager.nodeViews
    });
  }
  /**
   * Prepend class name to element.
   */
  prependClass() {
    this.view.dom.className = `tiptap ${this.view.dom.className}`;
  }
  captureTransaction(t) {
    this.isCapturingTransaction = !0, t(), this.isCapturingTransaction = !1;
    const e = this.capturedTransaction;
    return this.capturedTransaction = null, e;
  }
  /**
   * The callback over which to send transactions (state updates) produced by the view.
   *
   * @param transaction An editor state transaction
   */
  dispatchTransaction(t) {
    if (this.view.isDestroyed)
      return;
    if (this.isCapturingTransaction) {
      if (!this.capturedTransaction) {
        this.capturedTransaction = t;
        return;
      }
      t.steps.forEach((i) => {
        var c;
        return (c = this.capturedTransaction) === null || c === void 0 ? void 0 : c.step(i);
      });
      return;
    }
    const e = this.state.apply(t), r = !this.state.selection.eq(e.selection);
    this.emit("beforeTransaction", {
      editor: this,
      transaction: t,
      nextState: e
    }), this.view.updateState(e), this.emit("transaction", {
      editor: this,
      transaction: t
    }), r && this.emit("selectionUpdate", {
      editor: this,
      transaction: t
    });
    const s = t.getMeta("focus"), o = t.getMeta("blur");
    s && this.emit("focus", {
      editor: this,
      event: s.event,
      transaction: t
    }), o && this.emit("blur", {
      editor: this,
      event: o.event,
      transaction: t
    }), !(!t.docChanged || t.getMeta("preventUpdate")) && this.emit("update", {
      editor: this,
      transaction: t
    });
  }
  /**
   * Get attributes of the currently selected node or mark.
   */
  getAttributes(t) {
    return Pn(this.state, t);
  }
  isActive(t, e) {
    const r = typeof t == "string" ? t : null, s = typeof t == "string" ? e : t;
    return $n(this.state, r, s);
  }
  /**
   * Get the document as JSON.
   */
  getJSON() {
    return this.state.doc.toJSON();
  }
  /**
   * Get the document as HTML.
   */
  getHTML() {
    return dt(this.state.doc.content, this.schema);
  }
  /**
   * Get the document as text.
   */
  getText(t) {
    const { blockSeparator: e = `

`, textSerializers: r = {} } = t || {};
    return Tn(this.state.doc, {
      blockSeparator: e,
      textSerializers: {
        ...Pt(this.schema),
        ...r
      }
    });
  }
  /**
   * Check if there is no content.
   */
  get isEmpty() {
    return mt(this.state.doc);
  }
  /**
   * Get the number of characters for the current document.
   *
   * @deprecated
   */
  getCharacterCount() {
    return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'), this.state.doc.content.size - 2;
  }
  /**
   * Destroy the editor.
   */
  destroy() {
    if (this.emit("destroy"), this.view) {
      const t = this.view.dom;
      t && t.editor && delete t.editor, this.view.destroy();
    }
    this.removeAllListeners();
  }
  /**
   * Check if the editor is already destroyed.
   */
  get isDestroyed() {
    var t;
    return !(!((t = this.view) === null || t === void 0) && t.docView);
  }
  $node(t, e) {
    var r;
    return ((r = this.$doc) === null || r === void 0 ? void 0 : r.querySelector(t, e)) || null;
  }
  $nodes(t, e) {
    var r;
    return ((r = this.$doc) === null || r === void 0 ? void 0 : r.querySelectorAll(t, e)) || null;
  }
  $pos(t) {
    const e = this.state.doc.resolve(t);
    return new B(e, this);
  }
  get $doc() {
    return this.$pos(0);
  }
}
function wr(n) {
  return new X({
    find: n.find,
    handler: ({ state: t, range: e, match: r }) => {
      const s = b(n.getAttributes, void 0, r);
      if (s === !1 || s === null)
        return null;
      const { tr: o } = t, i = r[r.length - 1], c = r[0];
      if (i) {
        const a = c.search(/\S/), l = e.from + c.indexOf(i), u = l + i.length;
        if (Rt(e.from, e.to, t.doc).filter((p) => p.mark.type.excluded.find((h) => h === n.type && h !== p.mark.type)).filter((p) => p.to > l).length)
          return null;
        u < e.to && o.delete(u, e.to), l > e.from && o.delete(e.from + a, l);
        const f = e.from + a + i.length;
        o.addMark(e.from + a, f, n.type.create(s || {})), o.removeStoredMark(n.type);
      }
    }
  });
}
function Mr(n) {
  return new X({
    find: n.find,
    handler: ({ state: t, range: e, match: r }) => {
      const s = b(n.getAttributes, void 0, r) || {}, { tr: o } = t, i = e.from;
      let c = e.to;
      const a = n.type.create(s);
      if (r[1]) {
        const l = r[0].lastIndexOf(r[1]);
        let u = i + l;
        u > c ? u = c : c = u + r[1].length;
        const d = r[0][r[0].length - 1];
        o.insertText(d, i + r[0].length - 1), o.replaceWith(u, c, a);
      } else if (r[0]) {
        const l = n.type.isInline ? i : i - 1;
        o.insert(l, n.type.create(s)).delete(o.mapping.map(i), o.mapping.map(c));
      }
      o.scrollIntoView();
    }
  });
}
function Sr(n) {
  return new X({
    find: n.find,
    handler: ({ state: t, range: e, match: r }) => {
      const s = t.doc.resolve(e.from), o = b(n.getAttributes, void 0, r) || {};
      if (!s.node(-1).canReplaceWith(s.index(-1), s.indexAfter(-1), n.type))
        return null;
      t.tr.delete(e.from, e.to).setBlockType(e.from, e.from, n.type, o);
    }
  });
}
function Er(n) {
  return new X({
    find: n.find,
    handler: ({ state: t, range: e, match: r, chain: s }) => {
      const o = b(n.getAttributes, void 0, r) || {}, i = t.tr.delete(e.from, e.to), a = i.doc.resolve(e.from).blockRange(), l = a && Kt(a, n.type, o);
      if (!l)
        return null;
      if (i.wrap(a, l), n.keepMarks && n.editor) {
        const { selection: d, storedMarks: f } = t, { splittableMarks: p } = n.editor.extensionManager, g = f || d.$to.parentOffset && d.$from.marks();
        if (g) {
          const h = g.filter((m) => p.includes(m.type.name));
          i.ensureMarks(h);
        }
      }
      if (n.keepAttributes) {
        const d = n.type.name === "bulletList" || n.type.name === "orderedList" ? "listItem" : "taskList";
        s().updateAttributes(d, o).run();
      }
      const u = i.doc.resolve(e.from - 1).nodeBefore;
      u && u.type === n.type && lt(i.doc, e.from - 1) && (!n.joinPredicate || n.joinPredicate(r, u)) && i.join(e.from - 1);
    }
  });
}
class ct {
  constructor(t = {}) {
    this.type = "node", this.name = "node", this.parent = null, this.child = null, this.config = {
      name: this.name,
      defaultOptions: {}
    }, this.config = {
      ...this.config,
      ...t
    }, this.name = this.config.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`), this.options = this.config.defaultOptions, this.config.addOptions && (this.options = b(y(this, "addOptions", {
      name: this.name
    }))), this.storage = b(y(this, "addStorage", {
      name: this.name,
      options: this.options
    })) || {};
  }
  static create(t = {}) {
    return new ct(t);
  }
  configure(t = {}) {
    const e = this.extend({
      ...this.config,
      addOptions: () => Z(this.options, t)
    });
    return e.name = this.name, e.parent = this.parent, e;
  }
  extend(t = {}) {
    const e = new ct(t);
    return e.parent = this, this.child = e, e.name = t.name ? t.name : e.parent.name, t.defaultOptions && Object.keys(t.defaultOptions).length > 0 && console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`), e.options = b(y(e, "addOptions", {
      name: e.name
    })), e.storage = b(y(e, "addStorage", {
      name: e.name,
      options: e.options
    })), e;
  }
}
function xr(n) {
  return new Te({
    find: n.find,
    handler: ({ state: t, range: e, match: r, pasteEvent: s }) => {
      const o = b(n.getAttributes, void 0, r, s);
      if (o === !1 || o === null)
        return null;
      const { tr: i } = t, c = r[r.length - 1], a = r[0];
      let l = e.to;
      if (c) {
        const u = a.search(/\S/), d = e.from + a.indexOf(c), f = d + c.length;
        if (Rt(e.from, e.to, t.doc).filter((g) => g.mark.type.excluded.find((m) => m === n.type && m !== g.mark.type)).filter((g) => g.to > d).length)
          return null;
        f < e.to && i.delete(f, e.to), d > e.from && i.delete(e.from + u, d), l = e.from + u + c.length, i.addMark(e.from + u, l, n.type.create(o || {})), i.removeStoredMark(n.type);
      }
    }
  });
}
function Cr(n, t) {
  const { selection: e } = n, { $from: r } = e;
  if (e instanceof G) {
    const o = r.index();
    return r.parent.canReplaceWith(o, o + 1, t);
  }
  let s = r.depth;
  for (; s >= 0; ) {
    const o = r.index(s);
    if (r.node(s).contentMatchAt(o).matchType(t))
      return !0;
    s -= 1;
  }
  return !1;
}
export {
  Y as CommandManager,
  vr as Editor,
  C as Extension,
  X as InputRule,
  U as Mark,
  ct as Node,
  B as NodePos,
  Te as PasteRule,
  b as callOrReturn,
  Cr as canInsertNode,
  gr as combineTransactionSteps,
  J as createChainableState,
  it as createDocument,
  D as createNodeFromContent,
  cr as createStyleTag,
  xn as defaultBlockAt,
  wt as deleteProps,
  V as elementFromString,
  yr as findChildrenInRange,
  $e as findDuplicates,
  ht as findParentNode,
  Cn as findParentNodeClosestToPos,
  ve as fromString,
  Pn as getAttributes,
  Ct as getAttributesFromExtensions,
  kr as getChangedRanges,
  y as getExtensionField,
  dt as getHTMLFromFragment,
  jt as getMarkAttributes,
  ft as getMarkRange,
  $ as getMarkType,
  Rt as getMarksBetween,
  An as getNodeAttributes,
  S as getNodeType,
  ot as getRenderedAttributes,
  we as getSchemaByResolvedExtensions,
  nt as getSchemaTypeByName,
  tt as getSchemaTypeNameByName,
  K as getSplittedAttributes,
  Tn as getText,
  At as getTextBetween,
  Me as getTextContentFromNodes,
  Pt as getTextSerializersFromSchema,
  yt as injectExtensionAttributesToParseRule,
  Ee as inputRulesPlugin,
  $n as isActive,
  be as isEmptyObject,
  bt as isExtensionRulesEnabled,
  Tt as isFunction,
  Mt as isList,
  Nt as isMacOS,
  at as isMarkActive,
  L as isNodeActive,
  mt as isNodeEmpty,
  br as isNodeSelection,
  Ce as isNumber,
  H as isPlainObject,
  ut as isRegExp,
  It as isTextSelection,
  pt as isiOS,
  wr as markInputRule,
  xr as markPasteRule,
  ke as mergeAttributes,
  Z as mergeDeep,
  N as minMax,
  Mr as nodeInputRule,
  q as objectIncludes,
  Ie as pasteRulesPlugin,
  On as removeDuplicates,
  $t as resolveFocusPosition,
  Xe as selectionToInsertionEnd,
  Q as splitExtensions,
  Sr as textblockTypeInputRule,
  Er as wrappingInputRule
};
//# sourceMappingURL=index.js.map
