PageSourceSearch

https://portal.godesignguru.com/build/assets/TipTapEditor-syDIvp4e.js

js godesignguru.com collected 2026-10-04 05:47:41 UTC 470,175 bytes, 10,691 lines download raw bytes

1import { k as Xc, ab as ei, a5 as Zc, a6 as xl, X as eu, K as Sl, u as H, G as _e, a8 as tu, as as wl, O as nu, at as Vi, a7 as ru, ac as su, j as iu, z as Jr, o as he, c as Ve, F as Gr, r as Yr, C as Et, i as An, H as Qr, e as Ne, f as lt, M as ou, a as at, w as lu, S as au, B as cu, D as uu, t as Hi, b as _i, I as du } from "./app-yg_pP4S4.js";
2import { v as fu } from "./functions-DLrKIvnr.js";
3import { M as hu, Q as pu, w as mu } from "./index-CDyB1Hog.js";
4import { f as gu, I as yu, g as bu, i as ku, j as xu, l as Su, m as wu, L as Cu, o as Mu, p as vu, s as Tu, t as Eu, u as Au } from "./XMarkIcon-C7ztHuKP.js";
5import { G as ji, j as Wi, y as Ui } from "./popover-DTQdCRwt.js";
6function Q(n2) {
7  this.content = n2;
8}
9Q.prototype = { constructor: Q, find: function(n2) {
10  for (var e = 0; e < this.content.length; e += 2) if (this.content[e] === n2) return e;
11  return -1;
12}, get: function(n2) {
13  var e = this.find(n2);
14  return e == -1 ? void 0 : this.content[e + 1];
15}, update: function(n2, e, t) {
16  var r = t && t != n2 ? this.remove(t) : this, s = r.find(n2), i = r.content.slice();
17  return s == -1 ? i.push(t || n2, e) : (i[s + 1] = e, t && (i[s] = t)), new Q(i);
18}, remove: function(n2) {
19  var e = this.find(n2);
20  if (e == -1) return this;
21  var t = this.content.slice();
22  return t.splice(e, 2), new Q(t);
23}, addToStart: function(n2, e) {
24  return new Q([n2, e].concat(this.remove(n2).content));
25}, addToEnd: function(n2, e) {
26  var t = this.remove(n2).content.slice();
27  return t.push(n2, e), new Q(t);
28}, addBefore: function(n2, e, t) {
29  var r = this.remove(e), s = r.content.slice(), i = r.find(n2);
30  return s.splice(i == -1 ? s.length : i, 0, e, t), new Q(s);
31}, forEach: function(n2) {
32  for (var e = 0; e < this.content.length; e += 2) n2(this.content[e], this.content[e + 1]);
33}, prepend: function(n2) {
34  return n2 = Q.from(n2), n2.size ? new Q(n2.content.concat(this.subtract(n2).content)) : this;
35}, append: function(n2) {
36  return n2 = Q.from(n2), n2.size ? new Q(this.subtract(n2).content.concat(n2.content)) : this;
37}, subtract: function(n2) {
38  var e = this;
39  n2 = Q.from(n2);
40  for (var t = 0; t < n2.content.length; t += 2) e = e.remove(n2.content[t]);
41  return e;
42}, toObject: function() {
43  var n2 = {};
44  return this.forEach(function(e, t) {
45    n2[e] = t;
46  }), n2;
47}, get size() {
48  return this.content.length >> 1;
49} };
50Q.from = function(n2) {
51  if (n2 instanceof Q) return n2;
52  var e = [];
53  if (n2) for (var t in n2) e.push(t, n2[t]);
54  return new Q(e);
55};
56function Cl(n2, e, t) {
57  for (let r = 0; ; r++) {
58    if (r == n2.childCount || r == e.childCount) return n2.childCount == e.childCount ? null : t;
59    let s = n2.child(r), i = e.child(r);
60    if (s == i) {
61      t += s.nodeSize;
62      continue;
63    }
64    if (!s.sameMarkup(i)) return t;
65    if (s.isText && s.text != i.text) {
66      for (let o = 0; s.text[o] == i.text[o]; o++) t++;
67      return t;
68    }
69    if (s.content.size || i.content.size) {
70      let o = Cl(s.content, i.content, t + 1);
71      if (o != null) return o;
72    }
73    t += s.nodeSize;
74  }
75}
76function Ml(n2, e, t, r) {
77  for (let s = n2.childCount, i = e.childCount; ; ) {
78    if (s == 0 || i == 0) return s == i ? null : { a: t, b: r };
79    let o = n2.child(--s), l = e.child(--i), a = o.nodeSize;
80    if (o == l) {
81      t -= a, r -= a;
82      continue;
83    }
84    if (!o.sameMarkup(l)) return { a: t, b: r };
85    if (o.isText && o.text != l.text) {
86      let c = 0, u = Math.min(o.text.length, l.text.length);
87      for (; c < u && o.text[o.text.length - c - 1] == l.text[l.text.length - c - 1]; ) c++, t--, r--;
88      return { a: t, b: r };
89    }
90    if (o.content.size || l.content.size) {
91      let c = Ml(o.content, l.content, t - 1, r - 1);
92      if (c) return c;
93    }
94    t -= a, r -= a;
95  }
96}
97class b {
98  constructor(e, t) {
99    if (this.content = e, this.size = t || 0, t == null) for (let r = 0; r < e.length; r++) this.size += e[r].nodeSize;
100  }
101  nodesBetween(e, t, r, s = 0, i) {
102    for (let o = 0, l = 0; l < t; o++) {
103      let a = this.content[o], c = l + a.nodeSize;
104      if (c > e && r(a, s + l, i || null, o) !== false && a.content.size) {
105        let u = l + 1;
106        a.nodesBetween(Math.max(0, e - u), Math.min(a.content.size, t - u), r, s + u);
107      }
108      l = c;
109    }
110  }
111  descendants(e) {
112    this.nodesBetween(0, this.size, e);
113  }
114  textBetween(e, t, r, s) {
115    let i = "", o = true;
116    return this.nodesBetween(e, t, (l, a) => {
117      let c = l.isText ? l.text.slice(Math.max(e, a) - a, t - a) : l.isLeaf ? s ? typeof s == "function" ? s(l) : s : l.type.spec.leafText ? l.type.spec.leafText(l) : "" : "";
118      l.isBlock && (l.isLeaf && c || l.isTextblock) && r && (o ? o = false : i += r), i += c;
119    }, 0), i;
120  }
121  append(e) {
122    if (!e.size) return this;
123    if (!this.size) return e;
124    let t = this.lastChild, r = e.firstChild, s = this.content.slice(), i = 0;
125    for (t.isText && t.sameMarkup(r) && (s[s.length - 1] = t.withText(t.text + r.text), i = 1); i < e.content.length; i++) s.push(e.content[i]);
126    return new b(s, this.size + e.size);
127  }
128  cut(e, t = this.size) {
129    if (e == 0 && t == this.size) return this;
130    let r = [], s = 0;
131    if (t > e) for (let i = 0, o = 0; o < t; i++) {
132      let l = this.content[i], a = o + l.nodeSize;
133      a > e && ((o < e || a > t) && (l.isText ? l = l.cut(Math.max(0, e - o), Math.min(l.text.length, t - o)) : l = l.cut(Math.max(0, e - o - 1), Math.min(l.content.size, t - o - 1))), r.push(l), s += l.nodeSize), o = a;
134    }
135    return new b(r, s);
136  }
137  cutByIndex(e, t) {
138    return e == t ? b.empty : e == 0 && t == this.content.length ? this 
138: new b(this.content.slice(e, t));
139  }
140  replaceChild(e, t) {
141    let r = this.content[e];
142    if (r == t) return this;
143    let s = this.content.slice(), i = this.size + t.nodeSize - r.nodeSize;
144    return s[e] = t, new b(s, i);
145  }
146  addToStart(e) {
147    return new b([e].concat(this.content), this.size + e.nodeSize);
148  }
149  addToEnd(e) {
150    return new b(this.content.concat(e), this.size + e.nodeSize);
151  }
152  eq(e) {
153    if (this.content.length != e.content.length) return false;
154    for (let t = 0; t < this.content.length; t++) if (!this.content[t].eq(e.content[t])) return false;
155    return true;
156  }
157  get firstChild() {
158    return this.content.length ? this.content[0] : null;
159  }
160  get lastChild() {
161    return this.content.length ? this.content[this.content.length - 1] : null;
162  }
163  get childCount() {
164    return this.content.length;
165  }
166  child(e) {
167    let t = this.content[e];
168    if (!t) throw new RangeError("Index " + e + " out of range for " + this);
169    return t;
170  }
171  maybeChild(e) {
172    return this.content[e] || null;
173  }
174  forEach(e) {
175    for (let t = 0, r = 0; t < this.content.length; t++) {
176      let s = this.content[t];
177      e(s, r, t), r += s.nodeSize;
178    }
179  }
180  findDiffStart(e, t = 0) {
181    return Cl(this, e, t);
182  }
183  findDiffEnd(e, t = this.size, r = e.size) {
184    return Ml(this, e, t, r);
185  }
186  findIndex(e) {
187    if (e == 0) return Nn(0, e);
188    if (e == this.size) return Nn(this.content.length, e);
189    if (e > this.size || e < 0) throw new RangeError(`Position ${e} outside of fragment (${this})`);
190    for (let t = 0, r = 0; ; t++) {
191      let s = this.child(t), i = r + s.nodeSize;
192      if (i >= e) return i == e ? Nn(t + 1, i) : Nn(t, r);
193      r = i;
194    }
195  }
196  toString() {
197    return "<" + this.toStringInner() + ">";
198  }
199  toStringInner() {
200    return this.content.join(", ");
201  }
202  toJSON() {
203    return this.content.length ? this.content.map((e) => e.toJSON()) : null;
204  }
205  static fromJSON(e, t) {
206    if (!t) return b.empty;
207    if (!Array.isArray(t)) throw new RangeError("Invalid input for Fragment.fromJSON");
208    return new b(t.map(e.nodeFromJSON));
209  }
210  static fromArray(e) {
211    if (!e.length) return b.empty;
212    let t, r = 0;
213    for (let s = 0; s < e.length; s++) {
214      let i = e[s];
215      r += i.nodeSize, s && i.isText && e[s - 1].sameMarkup(i) ? (t || (t = e.slice(0, s)), t[t.length - 1] = i.withText(t[t.length - 1].text + i.text)) : t && t.push(i);
216    }
217    return new b(t || e, r);
218  }
219  static from(e) {
220    if (!e) return b.empty;
221    if (e instanceof b) return e;
222    if (Array.isArray(e)) return this.fromArray(e);
223    if (e.attrs) return new b([e], e.nodeSize);
224    throw new RangeError("Can not convert " + e + " to a Fragment" + (e.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
225  }
226}
227b.empty = new b([], 0);
228const Xr = { index: 0, offset: 0 };
229function Nn(n2, e) {
230  return Xr.index = n2, Xr.offset = e, Xr;
231}
232function Un(n2, e) {
233  if (n2 === e) return true;
234  if (!(n2 && typeof n2 == "object") || !(e && typeof e == "object")) return false;
235  let t = Array.isArray(n2);
236  if (Array.isArray(e) != t) return false;
237  if (t) {
238    if (n2.length != e.length) return false;
239    for (let r = 0; r < n2.length; r++) if (!Un(n2[r], e[r])) return false;
240  } else {
241    for (let r in n2) if (!(r in e) || !Un(n2[r], e[r])) return false;
242    for (let r in e) if (!(r in n2)) return false;
243  }
244  return true;
245}
246let B = class vs {
247  constructor(e, t) {
248    this.type = e, this.attrs = t;
249  }
250  addToSet(e) {
251    let t, r = false;
252    for (let s = 0; s < e.length; s++) {
253      let i = e[s];
254      if (this.eq(i)) return e;
255      if (this.type.excludes(i.type)) t || (t = e.slice(0, s));
256      else {
257        if (i.type.excludes(this.type)) return e;
258        !r && i.type.rank > this.type.rank && (t || (t = e.slice(0, s)), t.push(this), r = true), t && t.push(i);
259      }
260    }
261    return t || (t = e.slice()), r || t.push(this), t;
262  }
263  removeFromSet(e) {
264    for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1));
265    return e;
266  }
267  isInSet(e) {
268    for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return true;
269    return false;
270  }
271  eq(e) {
272    return this == e || this.type == e.type && Un(this.attrs, e.attrs);
273  }
274  toJSON() {
275    let e = { type: this.type.name };
276    for (let t in this.attrs) {
277      e.attrs = this.attrs;
278      break;
279    }
280    return e;
281  }
282  static fromJSON(e, t) {
283    if (!t) throw new RangeError("Invalid input for Mark.fromJSON");
284    let r = e.marks[t.type];
285    if (!r) throw new RangeError(`There is no mark type ${t.type} in this schema`);
286    let s = r.create(t.attrs);
287    return r.checkAttrs(s.attrs), s;
288  }
289  static sameSet(e, t) {
290    if (e == t) return true;
291    if (e.length != t.length) return false;
292    for (let r = 0; r < e.length; r++) if (!e[r].eq(t[r])) return false;
293    return true;
294  }
295  static setFrom(e) {
296    if (!e || Array.isArray(e) && e.length == 0) return vs.none;
297    if (e instanceof vs) return [e];
298    let t = e.slice();
299    return t.sort((r, s) => r.type.rank - s.type.rank), t;
300  }
301};
302B.none = [];
303class Kn extends Error {
304}
305class w {
306  constructor(e, t, r) {
307    this.content = e, this.openStart = t, this.openEnd = r;
308  }
309  get size() {
310    return this.content.size - this.openStart - this.openEnd;
311  }
312  insertAt(e, t) {
313    let r = Tl(this.content, e + this.openStart, t);
314    return r && new w(r, this.openStart, this.openEnd);
315  }
316  removeBetween(e, t) {
317    return new w(vl(this.content, e + this.openStart, t + this.openStart), this.openStart, this.openEnd);
318  }
319  eq(e) {
320    return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd;
321  }
322  toString() {
323    return this.content + "(" + this.openStart + "," + this.openEnd + ")";
324  }
325  toJSON() {
326    if (!this.content.size) return null;
327    let e = { content: this.content.toJSON() };
328    return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e;
329  }
330  static fromJSON(e, t) {
331    if (!t) return w.empty;
332    let r = t.openStart || 0, s = t.openEnd || 0;
333    if (typeof r != "number" || typeof s != "number") throw new RangeError("Invalid input for Slice.fromJSON");
334    return new w(b.fromJSON(e, t.content), r, s);
335  }
336  static maxOpen(e, t = true) {
337    let r = 0, s = 0;
338    for (let i = e.firstChild; i && !i.isLeaf && (t || !i.type.spec.isolating); i = i.firstChild) r++;
339    for (let i = e.lastChild; i && !i.isLeaf && (t || !i.type.spec.isolating); i = i.lastChild) s++;
340    return new w(e, r, s);
341  }
342}
343w.empty = new w(b.empty, 0, 0);
344function vl(n2, e, t) {
345  let { index: r, offset: s } = n2.findIndex(e), i = n2.maybeChild(r), { index: o, offset: l } = n2.findIndex(t);
346  if (s == e || i.isText) {
347    if (l != t && !n2.child(o).isText) throw new RangeError("Removing non-flat range");
348    return n2.cut(0, e).append(n2.cut(t));
349  }
350  if (r != o) throw new RangeError("Removing non-flat range");
351  return n2.replaceChild(r, i.copy(vl(i.content, e - s - 1, t - s - 1)));
352}
353function Tl(n2, e, t, r) {
354  let { index: s, offset: i } = n2.findIndex(e), o = n2.maybeChild(s);
355  if (i == e || o.isText) return r && !r.canReplace(s, s, t) ? null : n2.cut(0, e).append(t).append(n2.cut(e));
356  let l = Tl(o.content, e - i - 1, t, o);
357  return l && n2.replaceChild(s, o.copy(l));
358}
359function Nu(n2, e, t) {
360  if (t.openStart > n2.depth) throw new Kn("Inserted content deeper than insertion position");
361  if (n2.depth - t.openStart != e.depth - t.openEnd) throw new Kn("Inconsistent open depths");
362  return El(n2, e, t, 0);
363}
364function El(n2, e, t, r) {
365  let s = n2.index(r), i = n2.node(r);
366  if (s == e.index(r) && r < n2.depth - t.openStart) {
367    let o = El(n2, e, t, r + 1);
368    return i.copy(i.content.replaceChild(s, o));
369  } else if (t.content.size) if (!t.openStart && !t.openEnd && n2.depth == r && e.depth == r) {
370    let o = n2.parent, l = o.content;
371    return gt(o, l.cut(0, n2.parentOffset).append(t.content).append(l.cut(e.parentOffset)));
372  } else {
373    let { start: o, end: l } = Ou(t, n2);
374    return gt(i, Nl(n2, o, l, e, r));
375  }
376  else return gt(i, qn(n2, e, r));
377}
378function Al(n2, e) {
379  if (!e.type.compatibleContent(n2.type)) throw new Kn("Cannot join " + e.type.name + " onto " + n2.type.name);
380}
381function Ts(n2, e, t) {
vendor: 5,223 bytes, lines 382-522
382  let r = n2.node(t);
383  return Al(r, e.node(t)), r;
384}
385function mt(n2, e) {
386  let t = e.length - 1;
387  t >= 0 && n2.isText && n2.sameMarkup(e[t]) ? e[t] = n2.withText(e[t].text + n2.text) : e.push(n2);
388}
389function en(n2, e, t, r) {
390  let s = (e || n2).node(t), i = 0, o = e ? e.index(t) : s.childCount;
391  n2 && (i = n2.index(t), n2.depth > t ? i++ : n2.textOffset && (mt(n2.nodeAfter, r), i++));
392  for (let l = i; l < o; l++) mt(s.child(l), r);
393  e && e.depth == t && e.textOffset && mt(e.nodeBefore, r);
394}
395function gt(n2, e) {
396  return n2.type.checkContent(e), n2.copy(e);
397}
398function Nl(n2, e, t, r, s) {
399  let i = n2.depth > s && Ts(n2, e, s + 1), o = r.depth > s && Ts(t, r, s + 1), l = [];
400  return en(null, n2, s, l), i && o && e.index(s) == t.index(s) ? (Al(i, o), mt(gt(i, Nl(n2, e, t, r, s + 1)), l)) : (i && mt(gt(i, qn(n2, e, s + 1)), l), en(e, t, s, l), o && mt(gt(o, qn(t, r, s + 1)), l)), en(r, null, s, l), new b(l);
401}
402function qn(n2, e, t) {
403  let r = [];
404  if (en(null, n2, t, r), n2.depth > t) {
405    let s = Ts(n2, e, t + 1);
406    mt(gt(s, qn(n2, e, t + 1)), r);
407  }
408  return en(e, null, t, r), new b(r);
409}
410function Ou(n2, e) {
411  let t = e.depth - n2.openStart, s = e.node(t).copy(n2.content);
412  for (let i = t - 1; i >= 0; i--) s = e.node(i).copy(b.from(s));
413  return { start: s.resolveNoCache(n2.openStart + t), end: s.resolveNoCache(s.content.size - n2.openEnd - t) };
414}
415class fn {
416  constructor(e, t, r) {
417    this.pos = e, this.path = t, this.parentOffset = r, this.depth = t.length / 3 - 1;
418  }
419  resolveDepth(e) {
420    return e == null ? this.depth : e < 0 ? this.depth + e : e;
421  }
422  get parent() {
423    return this.node(this.depth);
424  }
425  get doc() {
426    return this.node(0);
427  }
428  node(e) {
429    return this.path[this.resolveDepth(e) * 3];
430  }
431  index(e) {
432    return this.path[this.resolveDepth(e) * 3 + 1];
433  }
434  indexAfter(e) {
435    return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1);
436  }
437  start(e) {
438    return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1;
439  }
440  end(e) {
441    return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size;
442  }
443  before(e) {
444    if (e = this.resolveDepth(e), !e) throw new RangeError("There is no position before the top-level node");
445    return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1];
446  }
447  after(e) {
448    if (e = this.resolveDepth(e), !e) throw new RangeError("There is no position after the top-level node");
449    return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize;
450  }
451  get textOffset() {
452    return this.pos - this.path[this.path.length - 1];
453  }
454  get nodeAfter() {
455    let e = this.parent, t = this.index(this.depth);
456    if (t == e.childCount) return null;
457    let r = this.pos - this.path[this.path.length - 1], s = e.child(t);
458    return r ? e.child(t).cut(r) : s;
459  }
460  get nodeBefore() {
461    let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1];
462    return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1);
463  }
464  posAtIndex(e, t) {
465    t = this.resolveDepth(t);
466    let r = this.path[t * 3], s = t == 0 ? 0 : this.path[t * 3 - 1] + 1;
467    for (let i = 0; i < e; i++) s += r.child(i).nodeSize;
468    return s;
469  }
470  marks() {
471    let e = this.parent, t = this.index();
472    if (e.content.size == 0) return B.none;
473    if (this.textOffset) return e.child(t).marks;
474    let r = e.maybeChild(t - 1), s = e.maybeChild(t);
475    if (!r) {
476      let l = r;
477      r = s, s = l;
478    }
479    let i = r.marks;
480    for (var o = 0; o < i.length; o++) i[o].type.spec.inclusive === false && (!s || !i[o].isInSet(s.marks)) && (i = i[o--].removeFromSet(i));
481    return i;
482  }
483  marksAcross(e) {
484    let t = this.parent.maybeChild(this.index());
485    if (!t || !t.isInline) return null;
486    let r = t.marks, s = e.parent.maybeChild(e.index());
487    for (var i = 0; i < r.length; i++) r[i].type.spec.inclusive === false && (!s || !r[i].isInSet(s.marks)) && (r = r[i--].removeFromSet(r));
488    return r;
489  }
490  sharedDepth(e) {
491    for (let t = this.depth; t > 0; t--) if (this.start(t) <= e && this.end(t) >= e) return t;
492    return 0;
493  }
494  blockRange(e = this, t) {
495    if (e.pos < this.pos) return e.blockRange(this);
496    for (let r = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); r >= 0; r--) if (e.pos <= this.end(r) && (!t || t(this.node(r)))) return new Jn(this, e, r);
497    return null;
498  }
499  sameParent(e) {
500    return this.pos - this.parentOffset == e.pos - e.parentOffset;
501  }
502  max(e) {
503    return e.pos > this.pos ? e : this;
504  }
505  min(e) {
506    return e.pos < this.pos ? e : this;
507  }
508  toString() {
509    let e = "";
510    for (let t = 1; t <= this.depth; t++) e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1);
511    return e + ":" + this.parentOffset;
512  }
513  static resolve(e, t) {
514    if (!(t >= 0 && t <= e.content.size)) throw new RangeError("Position " + t + " out of range");
515    let r = [], s = 0, i = t;
516    for (let o = e; ; ) {
517      let { index: l, offset: a } = o.content.findIndex(i), c = i - a;
518      if (r.push(o, l, s + a), !c || (o = o.child(l), o.isText)) break;
519      i = c - 1, s += a + 1;
520    }
521    return new fn(t, r, i);
522  }
523  static resolveCached(e, t) {
524    let r = Ki.get(e);
525    if (r) for (let i = 0; i < r.elts.length; i++) {
526      let o = r.elts[i];
527      if (o.pos == t) return o;
528    }
529    else Ki.set(e, r = new Iu());
530    let s = r.elts[r.i] = fn.resolve(e, t);
531    return r.i = (r.i + 1) % Du, s;
532  }
533}
534class Iu {
535  constructor() {
536    this.elts = [], this.i = 0;
537  }
538}
539const Du = 12, Ki = /* @__PURE__ */ new WeakMap();
540class Jn {
541  constructor(e, t, r) {
542    this.$from = e, this.$to = t, this.depth = r;
543  }
544  get start() {
545    return this.$from.before(this.depth + 1);
546  }
547  get end() {
548    return this.$to.after(this.depth + 1);
549  }
550  get parent() {
551    return this.$from.node(this.depth);
552  }
553  get startIndex() {
554    return this.$from.index(this.depth);
555  }
556  get endIndex() {
557    return this.$to.indexAfter(this.depth);
558  }
559}
560const Ru = /* @__PURE__ */ Object.create(null);
561class Ce {
562  constructor(e, t, r, s = B.none) {
563    this.type = e, this.attrs = t, this.marks = s, this.content = r || b.empty;
564  }
565  get children() {
566    return this.content.content;
567  }
568  get nodeSize() {
569    return this.isLeaf ? 1 : 2 + this.content.size;
570  }
571  get childCount() {
572    return this.content.childCount;
573  }
574  child(e) {
575    return this.content.child(e);
576  }
577  maybeChild(e) {
578    return this.content.maybeChild(e);
579  }
580  forEach(e) {
581    this.content.forEach(e);
582  }
583  nodesBetween(e, t, r, s = 0) {
584    this.content.nodesBetween(e, t, r, s, this);
585  }
586  descendants(e) {
587    this.nodesBetween(0, this.content.size, e);
588  }
589  get textContent() {
590    return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, "");
591  }
592  textBetween(e, t, r, s) {
593    return this.content.textBetween(e, t, r, s);
594  }
595  get firstChild() {
596    return this.content.firstChild;
597  }
598  get lastChild() {
599    return this.content.lastChild;
600  }
601  eq(e) {
602    return this == e || this.sameMarkup(e) && this.content.eq(e.content);
603  }
604  sameMarkup(e) {
605    return this.hasMarkup(e.type, e.attrs, e.marks);
606  }
607  hasMarkup(e, t, r) {
608    return this.type == e && Un(this.attrs, t || e.defaultAttrs || Ru) && B.sameSet(this.marks, r || B.none);
609  }
610  copy(e = null) {
611    return e == this.content ? this : new Ce(this.type, this.attrs, e, this.marks);
612  }
613  mark(e) {
614    return e == this.marks ? this : new Ce(this.type, this.attrs, this.content, e);
615  }
616  cut(e, t = this.content.size) {
617    return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t));
618  }
619  slice(e, t = this.content.size, r = false) {
620    if (e == t) return w.empty;
621    let s = this.resolve(e), i = this.resolve(t), o = r ? 0 : s.sharedDepth(t), l = s.start(o), c = s.node(o).content.cut(s.pos - l, i.pos - l);
622    return new w(c, s.depth - o, i.depth - o);
623  }
624  replace(e, t, r) {
625    return Nu(this.resolve(e), this.resolve(t), r);
626  }
627  nodeAt(e) {
628    for (let t = this; ; ) {
629      let { index: r, offset: s } = t.content.findIndex(e);
630      if (t = t.maybeChild(r), !t) return null;
631      if (s == e || t.isText) return t;
632      e -= s + 1;
633    }
634  }
635  childAfter(e) {
636    let { index: t, offset: r } = this.content.findIndex(e);
637    return { node: this.content.maybeChild(t), index: t, offset: r };
638  }
639  childBefore(e) {
640    if (e == 0) return { node: null, index: 0, offset: 0 };
641    let { index: t, offset: r } = this.content.findIndex(e);
642    if (r < e) return { node: this.content.child(t), index: t, offset: r };
643    let s = this.content.child(t - 1);
644    return { node: s, index: t - 1, offset: r - s.nodeSize };
645  }
646  resolve(e) {
647    return fn.resolveCached(this, e);
648  }
649  resolveNoCache(e) {
650    return fn.resolve(this, e);
651  }
652  rangeHasMark(e, t, r) {
653    let s = false;
654    return t > e && this.nodesBetween(e, t, (i) => (r.isInSet(i.marks) && (s = true), !s)), s;
655  }
656  get isBlock() {
657    return this.type.isBlock;
658  }
659  get isTextblock() {
660    return this.type.isTextblock;
661  }
662  get inlineContent() {
663    return this.type.inlineContent;
664  }
665  get isInline() {
666    return this.type.isInline;
667  }
668  get isText() {
669    return this.type.isText;
670  }
671  get isLeaf() {
672    return this.type.isLeaf;
673  }
674  get isAtom() {
675    return this.type.isAtom;
676  }
677  toString() {
678    if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);
679    let e = this.type.name;
680    return this.content.size && (e += "(" + this.content.toStringInner() + ")"), Ol(this.marks, e);
681  }
682  contentMatchAt(e) {
683    let t = this.type.contentMatch.matchFragment(this.content, 0, e);
684    if (!t) throw new Error("Called contentMatchAt on a node with invalid content");
685    return t;
686  }
687  canReplace(e, t, r = b.empty, s = 0, i = r.childCount) {
688    let o = this.contentMatchAt(e).matchFragment(r, s, i), l = o && o.matchFragment(this.content, t);
689    if (!l || !l.validEnd) return false;
690    for (let a = s; a < i; a++) if (!this.type.allowsMarks(r.child(a).marks)) return false;
691    return true;
692  }
693  canReplaceWith(e, t, r, s) {
694    if (s && !this.type.allowsMarks(s)) return false;
695    let i = this.contentMatchAt(e).matchType(r), o = i && i.matchFragment(this.content, t);
696    return o ? o.validEnd : false;
697  }
698  canAppend(e) {
699    return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type);
700  }
701  check() {
702    this.type.checkContent(this.content), this.type.checkAttrs(this.attrs);
703    let e = B.none;
704    for (let t = 0; t < this.marks.length; t++) {
705      let r = this.marks[t];
706      r.type.checkAttrs(r.attrs), e = r.addToSet(e);
707    }
708    if (!B.sameSet(e, this.marks)) throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((t) =>
708 t.type.name)}`);
709    this.content.forEach((t) => t.check());
710  }
711  toJSON() {
712    let e = { type: this.type.name };
713    for (let t in this.attrs) {
714      e.attrs = this.attrs;
715      break;
716    }
717    return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((t) => t.toJSON())), e;
718  }
719  static fromJSON(e, t) {
720    if (!t) throw new RangeError("Invalid input for Node.fromJSON");
721    let r;
722    if (t.marks) {
723      if (!Array.isArray(t.marks)) throw new RangeError("Invalid mark data for Node.fromJSON");
724      r = t.marks.map(e.markFromJSON);
725    }
726    if (t.type == "text") {
727      if (typeof t.text != "string") throw new RangeError("Invalid text node in JSON");
728      return e.text(t.text, r);
729    }
730    let s = b.fromJSON(e, t.content), i = e.nodeType(t.type).create(t.attrs, s, r);
731    return i.type.checkAttrs(i.attrs), i;
732  }
733}
734Ce.prototype.text = void 0;
735class Gn extends Ce {
736  constructor(e, t, r, s) {
737    if (super(e, t, null, s), !r) throw new RangeError("Empty text nodes are not allowed");
738    this.text = r;
739  }
740  toString() {
741    return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : Ol(this.marks, JSON.stringify(this.text));
742  }
743  get textContent() {
744    return this.text;
745  }
746  textBetween(e, t) {
747    return this.text.slice(e, t);
748  }
749  get nodeSize() {
750    return this.text.length;
751  }
752  mark(e) {
753    return e == this.marks ? this : new Gn(this.type, this.attrs, this.text, e);
754  }
755  withText(e) {
756    return e == this.text ? this : new Gn(this.type, this.attrs, e, this.marks);
757  }
758  cut(e = 0, t = this.text.length) {
759    return e == 0 && t == this.text.length ? this : this.withText(this.text.slice(e, t));
760  }
761  eq(e) {
762    return this.sameMarkup(e) && this.text == e.text;
763  }
764  toJSON() {
765    let e = super.toJSON();
766    return e.text = this.text, e;
767  }
768}
769function Ol(n2, e) {
770  for (let t = n2.length - 1; t >= 0; t--) e = n2[t].type.name + "(" + e + ")";
771  return e;
772}
773class xt {
774  constructor(e) {
775    this.validEnd = e, this.next = [], this.wrapCache = [];
776  }
777  static parse(e, t) {
778    let r = new Pu(e, t);
779    if (r.next == null) return xt.empty;
780    let s = Il(r);
781    r.next && r.err("Unexpected trailing text");
782    let i = Hu(Vu(s));
783    return _u(i, r), i;
784  }
785  matchType(e) {
786    for (let t = 0; t < this.next.length; t++) if (this.next[t].type == e) return this.next[t].next;
787    return null;
788  }
789  matchFragment(e, t = 0, r = e.childCount) {
790    let s = this;
791    for (let i = t; s && i < r; i++) s = s.matchType(e.child(i).type);
792    return s;
793  }
794  get inlineContent() {
795    return this.next.length != 0 && this.next[0].type.isInline;
796  }
797  get defaultType() {
798    for (let e = 0; e < this.next.length; e++) {
799      let { type: t } = this.next[e];
800      if (!(t.isText || t.hasRequiredAttrs())) return t;
801    }
802    return null;
803  }
804  compatible(e) {
805    for (let t = 0; t < this.next.length; t++) for (let r = 0; r < e.next.length; r++) if (this.next[t].type == e.next[r].type) return true;
806    return false;
807  }
808  fillBefore(e, t = false, r = 0) {
809    let s = [this];
810    function i(o, l) {
811      let a = o.matchFragment(e, r);
812      if (a && (!t || a.validEnd)) return b.from(l.map((c) => c.createAndFill()));
813      for (let c = 0; c < o.next.length; c++) {
814        let { type: u, next: d } = o.next[c];
815        if (!(u.isText || u.hasRequiredAttrs()) && s.indexOf(d) == -1) {
816          s.push(d);
817          let f = i(d, l.concat(u));
818          if (f) return f;
819        }
820      }
821      return null;
822    }
823    return i(this, []);
824  }
825  findWrapping(e) {
826    for (let r = 0; r < this.wrapCache.length; r += 2) if (this.wrapCache[r] == e) return this.wrapCache[r + 1];
827    let t = this.computeWrapping(e);
828    return this.wrapCache.push(e, t), t;
829  }
830  computeWrapping(e) {
831    let t = /* @__PURE__ */ Object.create(null), r = [{ match: this, type: null, via: null }];
832    for (; r.length; ) {
833      let s = r.shift(), i = s.match;
834      if (i.matchType(e)) {
835        let o = [];
836        for (let l = s; l.type; l = l.via) o.push(l.type);
837        return o.reverse();
838      }
839      for (let o = 0; o < i.next.length; o++) {
840        let { type: l, next: a } = i.next[o];
841        !l.isLeaf && !l.hasRequiredAttrs() && !(l.name in t) && (!s.type || a.validEnd) && (r.push({ match: l.contentMatch, type: l, via: s }), t[l.name] = true);
842      }
843    }
844    return null;
845  }
846  get edgeCount() {
847    return this.next.length;
848  }
849  edge(e) {
850    if (e >= this.next.length) throw new RangeError(`There's no ${e}th edge in this content match`);
851    return this.next[e];
852  }
853  toString() {
854    let e = [];
855    function t(r) {
856      e.push(r);
857      for (let s = 0; s < r.next.length; s++) e.indexOf(r.next[s].next) == -1 && t(r.next[s].next);
858    }
859    return t(this), e.map((r, s) => {
860      let i = s + (r.validEnd ? "*" : " ") + " ";
861      for (let o = 0; o < r.next.length; o++) i += (o ? ", " : "") + r.next[o].type.name + "->" + e.indexOf(r.next[o].next);
862      return i;
863    }).join(`
864`);
865  }
866}
867xt.empty = new xt(true);
868class Pu {
869  constructor(e, t) {
870    this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?
870=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift();
871  }
872  get next() {
873    return this.tokens[this.pos];
874  }
875  eat(e) {
876    return this.next == e && (this.pos++ || true);
877  }
878  err(e) {
879    throw new SyntaxError(e + " (in content expression '" + this.string + "')");
880  }
881}
882function Il(n2) {
883  let e = [];
884  do
885    e.push(Lu(n2));
886  while (n2.eat("|"));
887  return e.length == 1 ? e[0] : { type: "choice", exprs: e };
888}
889function Lu(n2) {
890  let e = [];
891  do
892    e.push(Bu(n2));
893  while (n2.next && n2.next != ")" && n2.next != "|");
894  return e.length == 1 ? e[0] : { type: "seq", exprs: e };
895}
896function Bu(n2) {
897  let e = Fu(n2);
898  for (; ; ) if (n2.eat("+")) e = { type: "plus", expr: e };
899  else if (n2.eat("*")) e = { type: "star", expr: e };
900  else if (n2.eat("?")) e = { type: "opt", expr: e };
901  else if (n2.eat("{")) e = zu(n2, e);
902  else break;
903  return e;
904}
905function qi(n2) {
906  /\D/.test(n2.next) && n2.err("Expected number, got '" + n2.next + "'");
907  let e = Number(n2.next);
908  return n2.pos++, e;
909}
910function zu(n2, e) {
911  let t = qi(n2), r = t;
912  return n2.eat(",") && (n2.next != "}" ? r = qi(n2) : r = -1), n2.eat("}") || n2.err("Unclosed braced range"), { type: "range", min: t, max: r, expr: e };
913}
914function $u(n2, e) {
915  let t = n2.nodeTypes, r = t[e];
916  if (r) return [r];
917  let s = [];
918  for (let i in t) {
919    let o = t[i];
920    o.isInGroup(e) && s.push(o);
921  }
922  return s.length == 0 && n2.err("No node type or group '" + e + "' found"), s;
923}
924function Fu(n2) {
925  if (n2.eat("(")) {
926    let e = Il(n2);
927    return n2.eat(")") || n2.err("Missing closing paren"), e;
928  } else if (/\W/.test(n2.next)) n2.err("Unexpected token '" + n2.next + "'");
929  else {
930    let e = $u(n2, n2.next).map((t) => (n2.inline == null ? n2.inline = t.isInline : n2.inline != t.isInline && n2.err("Mixing inline and block content"), { type: "name", value: t }));
931    return n2.pos++, e.length == 1 ? e[0] : { type: "choice", exprs: e };
932  }
933}
934function Vu(n2) {
935  let e = [[]];
936  return s(i(n2, 0), t()), e;
937  function t() {
938    return e.push([]) - 1;
939  }
940  function r(o, l, a) {
vendor: 4,387 bytes, lines 941-1088
941    let c = { term: a, to: l };
942    return e[o].push(c), c;
943  }
944  function s(o, l) {
945    o.forEach((a) => a.to = l);
946  }
947  function i(o, l) {
948    if (o.type == "choice") return o.exprs.reduce((a, c) => a.concat(i(c, l)), []);
949    if (o.type == "seq") for (let a = 0; ; a++) {
950      let c = i(o.exprs[a], l);
951      if (a == o.exprs.length - 1) return c;
952      s(c, l = t());
953    }
954    else if (o.type == "star") {
955      let a = t();
956      return r(l, a), s(i(o.expr, a), a), [r(a)];
957    } else if (o.type == "plus") {
958      let a = t();
959      return s(i(o.expr, l), a), s(i(o.expr, a), a), [r(a)];
960    } else {
961      if (o.type == "opt") return [r(l)].concat(i(o.expr, l));
962      if (o.type == "range") {
963        let a = l;
964        for (let c = 0; c < o.min; c++) {
965          let u = t();
966          s(i(o.expr, a), u), a = u;
967        }
968        if (o.max == -1) s(i(o.expr, a), a);
969        else for (let c = o.min; c < o.max; c++) {
970          let u = t();
971          r(a, u), s(i(o.expr, a), u), a = u;
972        }
973        return [r(a)];
974      } else {
975        if (o.type == "name") return [r(l, void 0, o.value)];
976        throw new Error("Unknown expr type");
977      }
978    }
979  }
980}
981function Dl(n2, e) {
982  return e - n2;
983}
984function Ji(n2, e) {
985  let t = [];
986  return r(e), t.sort(Dl);
987  function r(s) {
988    let i = n2[s];
989    if (i.length == 1 && !i[0].term) return r(i[0].to);
990    t.push(s);
991    for (let o = 0; o < i.length; o++) {
992      let { term: l, to: a } = i[o];
993      !l && t.indexOf(a) == -1 && r(a);
994    }
995  }
996}
997function Hu(n2) {
998  let e = /* @__PURE__ */ Object.create(null);
999  return t(Ji(n2, 0));
1000  function t(r) {
1001    let s = [];
1002    r.forEach((o) => {
1003      n2[o].forEach(({ term: l, to: a }) => {
1004        if (!l) return;
1005        let c;
1006        for (let u = 0; u < s.length; u++) s[u][0] == l && (c = s[u][1]);
1007        Ji(n2, a).forEach((u) => {
1008          c || s.push([l, c = []]), c.indexOf(u) == -1 && c.push(u);
1009        });
1010      });
1011    });
1012    let i = e[r.join(",")] = new xt(r.indexOf(n2.length - 1) > -1);
1013    for (let o = 0; o < s.length; o++) {
1014      let l = s[o][1].sort(Dl);
1015      i.next.push({ type: s[o][0], next: e[l.join(",")] || t(l) });
1016    }
1017    return i;
1018  }
1019}
1020function _u(n2, e) {
1021  for (let t = 0, r = [n2]; t < r.length; t++) {
1022    let s = r[t], i = !s.validEnd, o = [];
1023    for (let l = 0; l < s.next.length; l++) {
1024      let { type: a, next: c } = s.next[l];
1025      o.push(a.name), i && !(a.isText || a.hasRequiredAttrs()) && (i = false), r.indexOf(c) == -1 && r.push(c);
1026    }
1027    i && e.err("Only non-generatable nodes (" + o.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
1028  }
1029}
1030function Rl(n2) {
1031  let e = /* @__PURE__ */ Object.create(null);
1032  for (let t in n2) {
1033    let r = n2[t];
1034    if (!r.hasDefault) return null;
1035    e[t] = r.default;
1036  }
1037  return e;
1038}
1039function Pl(n2, e) {
1040  let t = /* @__PURE__ */ Object.create(null);
1041  for (let r in n2) {
1042    let s = e && e[r];
1043    if (s === void 0) {
1044      let i = n2[r];
1045      if (i.hasDefault) s = i.default;
1046      else throw new RangeError("No value supplied for attribute " + r);
1047    }
1048    t[r] = s;
1049  }
1050  return t;
1051}
1052function Ll(n2, e, t, r) {
1053  for (let s in e) if (!(s in n2)) throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);
1054  for (let s in n2) {
1055    let i = n2[s];
1056    i.validate && i.validate(e[s]);
1057  }
1058}
1059function Bl(n2, e) {
1060  let t = /* @__PURE__ */ Object.create(null);
1061  if (e) for (let r in e) t[r] = new Wu(n2, r, e[r]);
1062  return t;
1063}
1064let Gi = class zl {
1065  constructor(e, t, r) {
1066    this.name = e, this.schema = t, this.spec = r, this.markSet = null, this.groups = r.group ? r.group.split(" ") : [], this.attrs = Bl(e, r.attrs), this.defaultAttrs = Rl(this.attrs), this.contentMatch = null, this.inlineContent = null, this.isBlock = !(r.inline || e == "text"), this.isText = e == "text";
1067  }
1068  get isInline() {
1069    return !this.isBlock;
1070  }
1071  get isTextblock() {
1072    return this.isBlock && this.inlineContent;
1073  }
1074  get isLeaf() {
1075    return this.contentMatch == xt.empty;
1076  }
1077  get isAtom() {
1078    return this.isLeaf || !!this.spec.atom;
1079  }
1080  isInGroup(e) {
1081    return this.groups.indexOf(e) > -1;
1082  }
1083  get whitespace() {
1084    return this.spec.whitespace || (this.spec.code ? "pre" : "normal");
1085  }
1086  hasRequiredAttrs() {
1087    for (let e in this.attrs) if (this.attrs[e].isRequired) return true;
1088    return false;
1089  }
1090  compatibleContent(e) {
1091    return this == e || this.contentMatch.compatible(e.contentMatch);
1092  }
1093  computeAttrs(e) {
1094    return !e && this.defaultAttrs ? this.defaultAttrs : Pl(this.attrs, e);
1095  }
1096  create(e = null, t, r) {
1097    if (this.isText) throw new Error("NodeType.create can't construct text nodes");
1098    return new Ce(this, this.computeAttrs(e), b.from(t), B.setFrom(r));
1099  }
1100  createChecked(e = null, t, r) {
1101    return t = b.from(t), this.checkContent(t), new Ce(this, this.computeAttrs(e), t, B.setFrom(r));
1102  }
1103  createAndFill(e = null, t, r) {
1104    if (e = this.computeAttrs(e), t = b.from(t), t.size) {
1105      let o = this.contentMatch.fillBefore(t);
1106      if (!o) return null;
1107      t = o.append(t);
1108    }
1109    let s = this.contentMatch.matchFragment(t), i = s && s.fillBefore(b.empty, true);
1110    return i ? new Ce(this, e, t.append(i), B.setFrom(r)) : null;
1111  }
1112  validContent(e) {
1113    let t = this.contentMatch.matchFragment(e);
1114    if (!t || !t.validEnd) return false;
1115    for (let r = 0; r < e.childCount; r++) if (!this.allowsMarks(e.child(r).marks)) return false;
1116    return true;
1117  }
1118  checkContent(e) {
1119    if (!this.validContent(e)) throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0, 50)}`);
1120  }
1121  checkAttrs(e) {
1122    Ll(this.attrs, e, "node", this.name);
1123  }
1124  allowsMarkType(e) {
1125    return this.markSet == null || this.markSet.indexOf(e) > -1;
1126  }
1127  allowsMarks(e) {
1128    if (this.markSet == null) return true;
1129    for (let t = 0; t < e.length; t++) if (!this.allowsMarkType(e[t].type)) return false;
1130    return true;
1131  }
1132  allowedMarks(e) {
1133    if (this.markSet == null) return e;
1134    let t;
1135    for (let r = 0; r < e.length; r++) this.allowsMarkType(e[r].type) ? t && t.push(e[r]) : t || (t = e.slice(0, r));
1136    return t ? t.length ? t : B.none : e;
1137  }
1138  static compile(e, t) {
1139    let r = /* @__PURE__ */ Object.create(null);
1140    e.forEach((i, o) => r[i] = new zl(i, t, o));
1141    let s = t.spec.topNode || "doc";
1142    if (!r[s]) throw new RangeError("Schema is missing its top node type ('" + s + "')");
1143    if (!r.text) throw new RangeError("Every schema needs a 'text' type");
1144    for (let i in r.text.attrs) throw new RangeError("The text node type should not have attributes");
1145    return r;
1146  }
1147};
1148function ju(n2, e, t) {
1149  let r = t.split("|");
1150  return (s) => {
1151    let i = s === null ? "null" : typeof s;
1152    if (r.indexOf(i) < 0) throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n2}, got ${i}`);
1153  };
1154}
1155class Wu {
1156  constructor(e, t, r) {
1157    this.hasDefault = Object.prototype.hasOwnProperty.call(r, "default"), this.default = r.default, this.validate = typeof r.validate == "string" ? ju(e, t, r.validate) : r.validate;
1158  }
1159  get isRequired() {
1160    return !this.hasDefault;
1161  }
1162}
1163class Rr {
1164  constructor(e, t, r, s) {
1165    this.name = e, this.rank = t, this.schema = r, this.spec = s, this.attrs = Bl(e, s.attrs), this.excluded = null;
1166    let i = Rl(this.attrs);
1167    this.instance = i ? new B(this, i) : null;
1168  }
1169  create(e = null) {
1170    return !e && this.instance ? this.instance : new B(this, Pl(this.attrs, e));
1171  }
1172  static compile(e, t) {
1173    let r = /* @__PURE__ */ Object.create(null), s = 0;
1174    return e.forEach((i, o) => r[i] = new Rr(i, s++, t, o)), r;
1175  }
1176  removeFromSet(e) {
1177    for (var t = 0; t < e.length; t++) e[t].type == this && (e = e.slice(0, t).concat(e.slice(t + 1)), t--);
1178    return e;
1179  }
1180  isInSet(e) {
1181    for (let t = 0; t < e.length; t++) if (e[t].type == this) return e[t];
1182  }
1183  checkAttrs(e) {
1184    Ll(this.attrs, e, "mark", this.name);
1185  }
1186  excludes(e) {
1187    return this.excluded.indexOf(e) > -1;
1188  }
1189}
1190class $l {
1191  constructor(e) {
1192    this.linebreakReplacement = null, this.cached = /* @__PURE__ */ Object.create(null);
1193    let t = this.spec = {};
1194    for (let s in e) t[s] = e[s];
1195    t.nodes = Q.from(e.nodes), t.marks = Q.from(e.marks || {}), this.nodes = Gi.compile(this.spec.nodes, this), this.marks = Rr.compile(this.spec.marks, this);
1196    let r = /* @__PURE__ */ Object.create(null);
1197    for (let s in this.nodes) {
1198      if (s in this.marks) throw new RangeError(s + " can not be both a node and a mark");
1199      let i = this.nodes[s], o = i.spec.content || "", l = i.spec.marks;
1200      if (i.contentMatch = r[o] || (r[o] = xt.parse(o, this.nodes)), i.inlineContent = i.contentMatch.inlineContent, i.spec.linebreakReplacement) {
1201        if (this.linebreakReplacement) throw new RangeError("Multiple linebreak nodes defined");
1202        if (!i.isInline || !i.isLeaf) throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");
1203        this.linebreakReplacement = i;
1204      }
1205      i.markSet = l == "_" ? null : l ? Yi(this, l.split(" ")) : l == "" || !i.inlineContent ? [] : null;
1206    }
1207    for (let s in this.marks) {
1208      let i = this.marks[s], o = i.spec.excludes;
1209      i.excluded = o == null ? [i] : o == "" ? [] : Yi(this, o.split(" "));
1210    }
1211    this.nodeFromJSON = (s) => Ce.fromJSON(this, s), this.markFromJSON = (s) => B.fromJSON(this, s), this.topNodeType = this.nodes[this.spec.topNode || "doc"], this.cached.wrappings = /* @__PURE__ */ Object.create(null);
1212  }
1213  node(e, t = null, r, s) {
1214    if (typeof e == "string") e = this.nodeType(e);
1215    else if (e instanceof Gi) {
1216      if (e.schema != this) throw new RangeError("Node type from different schema used (" + e.name + ")");
1217    } else throw new RangeError("Invalid node type: " + e);
1218    return e.createChecked(t, r, s);
1219  }
1220  text(e, t) {
1221    let r = this.nodes.text;
1222    return new Gn(r, r.defaultAttrs, e, B.setFrom(t));
1223  }
1224  mark(e, t) {
1225    return typeof e == "string" && (e = this.marks[e]), e.create(t);
1226  }
1227  nodeType(e) {
1228    let t = this.nodes[e];
1229    if (!t) throw new RangeError("Unknown node type: " + e);
1230    return t;
1231  }
1232}
1233function Yi(n2, e) {
1234  let t = [];
1235  for (let r = 0; r < e.length; r++) {
1236    let s = e[r], i = n2.marks[s], o = i;
1237    if (i) t.push(i);
1238    else for (let l in n2.marks) {
1239      let a = n2.marks[l];
1240      (s == "_" || a.spec.group && a.spec.group.split(" ").indexOf(s) > -1) && t.push(o = a);
1241    }
1242    if (!o) throw new SyntaxError("Unknown mark type: '" + e[r] + "'");
1243  }
1244  return t;
1245}
1246function Uu(n2) {
1247  return n2.tag != null;
1248}
1249function Ku(n2) {
1250  return n2.style != null;
1251}
1252class Xe {
1253  constructor(e, t) {
1254    this.schema = e, this.rules = t, this.tags = [], this.styles = [];
1255    let r = this.matchedStyles = [];
1256    t.forEach((s) => {
1257      if (Uu(s)) this.tags.push(s);
1258      else if (Ku(s)) {
1259        let i = /[^=]*/.exec(s.style)[0];
1260        r.indexOf(i) < 0 && r.push(i), this.styles.push(s);
1261      }
1262    }), this.normalizeLists = !this.tags.some((s) => {
1263      if (!/^(ul|ol)\b/.test(s.tag) || !s.node) return false;
1264      let i = e.nodes[s.node];
1265      return i.contentMatch.matchType(i);
1266    });
1267  }
1268  parse(e, t = {}) {
1269    let r = new Xi(this, t, false);
1270    return r.addAll(e, B.none, t.from, t.to), r.finish();
1271  }
1272  parseSlice(e, t = {}) {
1273    let r = new Xi(this, t, true);
1274    return r.addAll(e, B.none, t.from, t.to), w.maxOpen(r.finish());
1275  }
1276  matchTag(e, t, r) {
1277    for (let s = r ? this.tags.indexOf(r) + 1 : 0; s < this.tags.length; s++) {
1278      let i = this.tags[s];
1279      if (Gu(e, i.tag) && (i.namespace === void 0 || e.namespaceURI == i.namespace) && (!i.context || t.matchesContext(i.context))) {
1280        if (i.getAttrs) {
1281          let o = i.getAttrs(e);
1282          if (o === false) continue;
1283          i.attrs = o || void 0;
1284        }
1285        return i;
1286      }
1287    }
1288  }
1289  matchStyle(e, t, r, s) {
1290    for (let i = s ? this.styles.indexOf(s) + 1 : 0; i < this.styles.length; i++) {
1291      let o = this.styles[i], l = o.style;
1292      if (!(l.indexOf(e) != 0 || o.context && !r.matchesContext(o.context) || l.length > e.length && (l.charCodeAt(e.length) != 61 || l.slice(e.length + 1) != t))) {
1293        if (o.getAttrs) {
1294          let a = o.getAttrs(t);
1295          if (a === false) continue;
1296          o.attrs = a || void 0;
1297        }
1298        return o;
1299      }
1300    }
1301  }
1302  static schemaRules(e) {
1303    let t = [];
1304    function r(s) {
1305      let i = s.priority == null ? 50 : s.priority, o = 0;
1306      for (; o < t.length; o++) {
1307        let l = t[o];
1308        if ((l.priority == null ? 50 : l.priority) < i) break;
1309      }
1310      t.splice(o, 0, s);
1311    }
1312    for (let s in e.marks) {
1313      let i = e.marks[s].spec.parseDOM;
1314      i && i.forEach((o) => {
1315        r(o = Zi(o)), o.mark || o.ignore || o.clearMark || (o.mark = s);
1316      });
1317    }
1318    for (let s in e.nodes) {
1319      let i = e.nodes[s].spec.parseDOM;
1320      i && i.forEach((o) => {
1321        r(o = Zi(o)), o.node || o.ignore || o.mark || (o.node = s);
1322      });
1323    }
1324    return t;
1325  }
1326  static fromSchema(e) {
1327    return e.cached.domParser || (e.cached.domParser = new Xe(e, Xe.schemaRules(e)));
1328  }
1329}
1330const Fl = { address: true, article: true, aside: true, blockquote: true, canvas: true, dd: true, div: true, dl: true, fieldset: true, figcaption: true, figure: true, footer: true, form: true, h1: true, h2: true, h3: true, h4: true, h5: true, h6: true, header: true, hgroup: true, hr: true, li: true, noscript: true, ol: true, output: true, p: true, pre: true, section: true, table: true, tfoot: true, ul: true }, qu = { head: true, noscript: true, object: true, script: true, style: true, title: true }, Vl = { ol: true, ul: true }, hn = 1, Es = 2, tn = 4;
1331function Qi(n2, e, t) {
1332  return e != null ? (e ? hn : 0) | (e === "full" ? Es : 0) : n2 && n2.whitespace == "pre" ? hn | Es : t & ~tn;
1333}
1334class On {
1335  constructor(e, t, r, s, i, o) {
1336    this.type = e, this.attrs = t, this.marks = r, this.solid = s, this.options = o, this.content = [], this.activeMarks = B.none, this.match = i || (o & tn ? null : e.contentMatch);
1337  }
1338  findWrapping(e) {
1339    if (!this.match) {
1340      if (!this.type) return [];
1341      let t = this.type.contentMatch.fillBefore(b.from(e));
1342      if (t) this.match = this.type.contentMatch.matchFragment(t);
1343      else {
1344        let r = this.type.contentMatch, s;
1345        return (s = r.findWrapping(e.type)) ? (this.match = r, s) : null;
1346      }
1347    }
1348    return this.match.findWrapping(e.type);
1349  }
1350  finish(e) {
1351    if (!(this.options & hn)) {
1352      let r = this.content[this.content.length - 1], s;
1353      if (r && r.isText && (s = /[ \t\r\n\u000c]+$/.exec(r.text))) {
1354        let i = r;
1355        r.text.length == s[0].length ? this.content.pop() : this.content[this.content.length - 1] = i.withText(i.text.slice(0, i.text.length - s[0].length));
1356      }
1357    }
1358    let t = b.from(this.content);
1359    return !e && this.match && (t = t.append(this.match.fillBefore(b.empty, true))), this.type ? this.type.create(this.attrs, t, this.marks) : t;
1360  }
1361  inlineContext(e) {
1362    return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : e.parentNode && !Fl.hasOwnProperty(e.parentNode.nodeName.toLowerCase());
1363  }
1364}
1365class Xi {
1366  constructor(e, t, r) {
1367    this.parser = e, this.options = t, this.isOpen = r, this.open = 0, this.localPreserveWS = false;
1368    let s = t.topNode, i, o = Qi(null, t.preserveWhitespace, 0) | (r ? tn : 0);
1369    s ? i = new On(s.type, s.attrs, B.none, true, t.topMatch || s.type.contentMatch, o) : r ? i = new On(null, null, B.none, true, null, o) : i = new On(e.schema.topNodeType, null, B.none, true, null, o), this.nodes = [i], this.find = t.findPositions, this.needsBlock = false;
1370  }
1371  get top() {
1372    return this.nodes[this.open];
1373  }
1374  addDOM(e, t) {
1375    e.nodeType == 3 ? this.addTextNode(e, t) : e.nodeType == 1 && this.addElement(e, t);
1376  }
1377  addTextNode(e, t) {
1378    let r = e.nodeValue, s = this.top, i = s.options & Es ? "full" : this.localPreserveWS || (s.options & hn) > 0, { schema: o } = this.parser;
1379    if (i === "full" || s.inlineContext(e) || /[^ \t\r\n\u000c]/.test(r)) {
1380      if (i) if (i === "full") r = r.replace(/\r\n?/g, `
1381`);
1382      else if (o.linebreakReplacement && /[\r\n]/.test(r) && this.top.findWrapping(o.linebreakReplacement.create())) {
1383        let l = r.split(/\r?\n|\r/);
1384        for (let a = 0; a < l.length; a++) a && this.insertNode(o.linebreakReplacement.create(), t, true), l[a] && this.insertNode(o.text(l[a]), t, !/\S/.test(l[a]));
1385        r = "";
1386      } else r = r.replace(/\r?\n|\r/g, " ");
1387      else if (r = r.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(r) && this.open == this.nodes.length - 1) {
1388        let l = s.content[s.content.length - 1], a = e.previousSibling;
1389        (!l || a && a.nodeName == "BR" || l.isText && /[ \t\r\n\u000c]$/.test(l.text)) && (r = r.slice(1));
1390      }
1391      r && this.insertNode(o.text(r), t, !/\S/.test(r)), this.findInText(e);
1392    } else this.findInside(e);
1393  }
1394  addElement(e, t, r) {
1395    let s = this.localPreserveWS, i = this.top;
1396    (e.tagName == "PRE" || /pre/.test(e.style && e.style.whiteSpace)) && (this.localPreserveWS = true);
1397    let o = e.nodeName.toLowerCase(), l;
1398    Vl.hasOwnProperty(o) && this.parser.normalizeLists && Ju(e);
1399    let a = this.options.ruleFromNode && this.options.ruleFromNode(e) || (l = this.parser.matchTag(e, this, r));
1400    e: if (a ? a.ignore : qu.hasOwnProperty(o)) this.findInside(e), this.ignoreFallback(e, t);
1401    else if (!a || a.skip || a.closeParent) {
1402      a && a.closeParent ? this.open = Math.max(0, this.open - 1) : a && a.skip.nodeType && (e = a.skip);
1403      let c, u = this.needsBlock;
1404      if (Fl.hasOwnProperty(o)) i.content.length && i.content[0].isInline && this.open && (this.open--, i = this.top), c = true, i.type || (this.needsBlock = true);
1405      else if (!e.firstChild) {
1406        this.leafFallback(e, t);
1407        break e;
1408      }
1409      let d = a && a.skip ? t : this.readStyles(e, t);
1410      d && this.addAll(e, d), c && this.sync(i), this.needsBlock = u;
1411    } else {
1412      let c = this.readStyles(e, t);
1413      c && this.addElementByRule(e, a, c, a.consuming === false ? l : void 0);
1414    }
1415    this.localPreserveWS = s;
1416  }
1417  leafFallback(e, t) {
1418    e.nodeName == "BR" && this.top.type && this.top.type.inlineContent && this.addTextNode(e.ownerDocument.createTextNode(`
1419`), t);
1420  }
1421  ignoreFallback(e, t) {
1422    e.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent) && this.findPlace(this.parser.schema.text("-"), t, true);
1423  }
1424  readStyles(e, t) {
1425    let r = e.style;
1426    if (r && r.length) for (let s = 0; s < this.parser.matchedStyles.length; s++) {
1427      let i = this.parser.matchedStyles[s], o = r.getPropertyValue(i);
1428      if (o) for (let l = void 0; ; ) {
1429        let a = this.parser.matchStyle(i, o, this, l);
1430        if (!a) break;
1431        if (a.ignore) return null;
1432        if (a.clearMark ? t = t.filter((c) => !a.clearMark(c)) : t = t.concat(this.parser.schema.marks[a.mark].create(a.attrs)), a.consuming === false) l = a;
1433        else break;
1434      }
1435    }
1436    return t;
1437  }
1438  addElementByRule(e, t, r, s) {
1439    let i, o;
1440    if (t.node) if (o = this.parser.schema.nodes[t.node], o.isLeaf) this.insertNode(o.create(t.attrs), r, e.nodeName == "BR") || this.leafFallback(e, r);
1441    else {
1442      let a = this.enter(o, t.attrs || null, r, t.preserveWhitespace);
1443      a && (i = true, r = a);
1444    }
1445    else {
1446      let a = this.parser.schema.marks[t.mark];
1447      r = r.concat(a.create(t.attrs));
1448    }
1449    let l = this.top;
1450    if (o && o.isLeaf) this.findInside(e);
1451    else if (s) this.addElement(e, r, s);
1452    else if (t.getContent) this.findInside(e), t.getContent(e, this.parser.schema).forEac
1452h((a) => this.insertNode(a, r, false));
1453    else {
1454      let a = e;
1455      typeof t.contentElement == "string" ? a = e.querySelector(t.contentElement) : typeof t.contentElement == "function" ? a = t.contentElement(e) : t.contentElement && (a = t.contentElement), this.findAround(e, a, true), this.addAll(a, r), this.findAround(e, a, false);
1456    }
1457    i && this.sync(l) && this.open--;
1458  }
1459  addAll(e, t, r, s) {
1460    let i = r || 0;
1461    for (let o = r ? e.childNodes[r] : e.firstChild, l = s == null ? null : e.childNodes[s]; o != l; o = o.nextSibling, ++i) this.findAtPoint(e, i), this.addDOM(o, t);
1462    this.findAtPoint(e, i);
1463  }
1464  findPlace(e, t, r) {
1465    let s, i;
1466    for (let o = this.open, l = 0; o >= 0; o--) {
1467      let a = this.nodes[o], c = a.findWrapping(e);
1468      if (c && (!s || s.length > c.length + l) && (s = c, i = a, !c.length)) break;
1469      if (a.solid) {
1470        if (r) break;
1471        l += 2;
1472      }
1473    }
1474    if (!s) return null;
1475    this.sync(i);
1476    for (let o = 0; o < s.length; o++) t = this.enterInner(s[o], null, t, false);
1477    return t;
1478  }
1479  insertNode(e, t, r) {
1480    if (e.isInline && this.needsBlock && !this.top.type) {
1481      let i = this.textblockFromContext();
1482      i && (t = this.enterInner(i, null, t));
1483    }
1484    let s = this.findPlace(e, t, r);
1485    if (s) {
1486      this.closeExtra();
1487      let i = this.top;
1488      i.match && (i.match = i.match.matchType(e.type));
1489      let o = B.none;
1490      for (let l of s.concat(e.marks)) (i.type ? i.type.allowsMarkType(l.type) : eo(l.type, e.type)) && (o = l.addToSet(o));
1491      return i.content.push(e.mark(o)), true;
1492    }
1493    return false;
1494  }
1495  enter(e, t, r, s) {
1496    let i = this.findPlace(e.create(t), r, false);
1497    return i && (i = this.enterInner(e, t, r, true, s)), i;
1498  }
1499  enterInner(e, t, r, s = false, i) {
1500    this.closeExtra();
1501    let o = this.top;
1502    o.match = o.match && o.match.matchType(e);
1503    let l = Qi(e, i, o.options);
1504    o.options & tn && o.content.length == 0 && (l |= tn);
1505    let a = B.none;
1506    return r = r.filter((c) => (o.type ? o.type.allowsMarkType(c.type) : eo(c.type, e)) ? (a = c.addToSet(a), false) : true), this.nodes.push(new On(e, t, a, s, null, l)), this.open++, r;
1507  }
1508  closeExtra(e = false) {
1509    let t = this.nodes.length - 1;
1510    if (t > this.open) {
1511      for (; t > this.open; t--) this.nodes[t - 1].content.push(this.nodes[t].finish(e));
1512      this.nodes.length = this.open + 1;
1513    }
1514  }
1515  finish() {
1516    return this.open = 0, this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));
1517  }
1518  sync(e) {
1519    for (let t = this.open; t >= 0; t--) {
1520      if (this.nodes[t] == e) return this.open = t, true;
1521      this.localPreserveWS && (this.nodes[t].options |= hn);
1522    }
1523    return false;
1524  }
1525  get currentPos() {
1526    this.closeExtra();
1527    let e = 0;
1528    for (let t = this.open; t >= 0; t--) {
1529      let r = this.nodes[t].content;
1530      for (let s = r.length - 1; s >= 0; s--) e += r[s].nodeSize;
1531      t && e++;
1532    }
1533    return e;
1534  }
1535  findAtPoint(e, t) {
1536    if (this.find) for (let r = 0; r < this.find.length; r++) this.find[r].node == e && this.find[r].offset == t && (this.find[r].pos = this.currentPos);
1537  }
1538  findInside(e) {
1539    if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].pos == null && e.nodeType == 1 && e.contains(this.find[t].node) && (this.find[t].pos = this.currentPos);
1540  }
1541  findAround(e, t, r) {
1542    if (e != t && this.find) for (let s = 0; s < this.find.length; s++) this.find[s].pos == null && e.nodeType == 1 && e.contains(this.find[s].node) && t.compareDocumentPosition(this.find[s].node) & (r ? 2 : 4) && (this.find[s].pos = this.currentPos);
1543  }
1544  findInText(e) {
1545    if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].node == e && (this.find[t].pos = this.currentPos - (e.nodeValue.length - this.find[t].offset));
1546  }
1547  matchesContext(e) {
1548    if (e.indexOf("|") > -1) return e.split(/\s*\|\s*/).some(this.matchesContext, this);
1549    let t = e.split("/"), r = this.options.context, s = !this.isOpen && (!r || r.parent.type == this.nodes[0].type), i = -(r ? r.depth + 1 : 0) + (s ? 0 : 1), o = (l, a) => {
1550      for (; l >= 0; l--) {
1551        let c = t[l];
1552        if (c == "") {
1553          if (l == t.length - 1 || l == 0) continue;
1554          for (; a >= i; a--) if (o(l - 1, a)) return true;
1555          return false;
1556        } else {
1557          let u = a > 0 || a == 0 && s ? this.nodes[a].type : r && a >= i ? r.node(a - i).type : null;
1558          if (!u || u.name != c && !u.isInGroup(c)) return false;
1559          a--;
1560        }
1561      }
1562      return true;
1563    };
1564    return o(t.length - 1, this.open);
1565  }
1566  textblockFromContext() {
1567    let e = this.options.context;
1568    if (e) for (let t = e.depth; t >= 0; t--) {
1569      let r = e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;
1570      if (r && r.isTextblock && r.defaultAttrs) return r;
1571    }
1572    for (let t in this.parser.schema.nodes) {
1573      let r = this.parser.schema.nodes[t];
1574      if (r.isTextblock && r.defaultAttrs) return r;
1575    }
1576  }
1577}
1578function Ju(n2) {
1579  for (let e = n2.firstChild, t = null; e; e = e.nextSibling) {
1580    let r = e.nodeType == 1 ? e.nodeName.toLowerCase() : null;
1581    r && Vl.hasOwnProperty(r) && t ? (t.appendChild(e), e = t) : r == "li" ? t = e : r && (t = null);
1582  }
1583}
1584function Gu(n2, e) {
1585  return (n2.matches || n2.msMatchesSelector || n2.webkitMatchesSelector || n2.mozMatchesSelector).call(n2, e);
1586}
1587function Zi(n2) {
1588  let e = {};
1589  for (let t in n2) e[t] = n2[t];
1590  return e;
1591}
1592function eo(n2, e) {
1593  let t = e.schema.nodes;
1594  for (let r in t) {
1595    let s = t[r];
1596    if (!s.allowsMarkType(n2)) continue;
1597    let i = [], o = (l) => {
1598      i.push(l);
1599      for (let a = 0; a < l.edgeCount; a++) {
1600        let { type: c, next: u } = l.edge(a);
1601        if (c == e || i.indexOf(u) < 0 && o(u)) return true;
1602      }
1603    };
1604    if (o(s.contentMatch)) return true;
1605  }
1606}
1607class Mt {
1608  constructor(e, t) {
1609    this.nodes = e, this.marks = t;
1610  }
1611  serializeFragment(e, t = {}, r) {
1612    r || (r = Zr(t).createDocumentFragment());
1613    let s = r, i = [];
1614    return e.forEach((o) => {
1615      if (i.length || o.marks.length) {
1616        let l = 0, a = 0;
1617        for (; l < i.length && a < o.marks.length; ) {
1618          let c = o.marks[a];
1619          if (!this.marks[c.type.name]) {
1620            a++;
1621            continue;
1622          }
1623          if (!c.eq(i[l][0]) || c.type.spec.spanning === false) break;
1624          l++, a++;
1625        }
1626        for (; l < i.length; ) s = i.pop()[1];
1627        for (; a < o.marks.length; ) {
1628          let c = o.marks[a++], u = this.serializeMark(c, o.isInline, t);
1629          u && (i.push([c, s]), s.appendChild(u.dom), s = u.contentDOM || u.dom);
1630        }
1631      }
1632      s.appendChild(this.serializeNodeInner(o, t));
1633    }), r;
1634  }
1635  serializeNodeInner(e, t) {
1636    let { dom: r, contentDOM: s } = Vn(Zr(t), this.nodes[e.type.name](e), null, e.attrs);
1637    if (s) {
1638      if (e.isLeaf) throw new RangeError("Content hole not allowed in a leaf node spec");
1639      this.serializeFragment(e.content, t, s);
1640    }
1641    return r;
1642  }
1643  serializeNode(e, t = {}) {
1644    let r = this.serializeNodeInner(e, t);
1645    for (let s = e.marks.length - 1; s >= 0; s--) {
1646      let i = this.serializeMark(e.marks[s], e.isInline, t);
1647      i && ((i.contentDOM || i.dom).appendChild(r), r = i.dom);
1648    }
1649    return r;
1650  }
1651  serializeMark(e, t, r = {}) {
1652    let s = this.marks[e.type.name];
1653    return s && Vn(Zr(r), s(e, t), null, e.attrs);
1654  }
1655  static renderSpec(e, t, r = null, s) {
1656    return Vn(e, t, r, s);
1657  }
1658  static fromSchema(e) {
1659    return e.cached.domSerializer || (e.cached.domSerializer = new Mt(this.nodesFromSchema(e), this.marksFromSchema(e)));
1660  }
1661  static nodesFromSchema(e) {
1662    let t = to(e.nodes);
1663    return t.text || (t.text = (r) => r.text), t;
1664  }
1665  static marksFromSchema(e) {
1666    return to(e.marks);
1667  }
1668}
1669function to(n2) {
1670  let e = {};
1671  for (let t in n2) {
1672    let r = n2[t].spec.toDOM;
1673    r && (e[t] = r);
1674  }
1675  return e;
1676}
1677function Zr(n2) {
1678  return n2.document || window.document;
1679}
1680const no = /* @__PURE__ */ new WeakMap();
1681function Yu(n2) {
1682  let e = no.get(n2);
1683  return e === void 0 && no.set(n2, e = Qu(n2)), e;
1684}
1685function Qu(n2) {
1686  let e = null;
1687  function t(r) {
1688    if (r && typeof r == "object") if (Array.isArray(r)) if (typeof r[0] == "string") e || (e = []), e.push(r);
1689    else for (let s = 0; s < r.length; s++) t(r[s]);
1690    else for (let s in r) t(r[s]);
1691  }
1692  return t(n2), e;
1693}
1694function Vn(n2, e, t, r) {
1695  if (typeof e == "string") return { dom: n2.createTextNode(e) };
1696  if (e.nodeType != null) return { dom: e };
1697  if (e.dom && e.dom.nodeType != null) return e;
1698  let s = e[0], i;
1699  if (typeof s != "string") throw new RangeError("Invalid array passed to renderSpec");
1700  if (r && (i = Yu(r)) && i.indexOf(e) > -1) throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
1701  let o = s.indexOf(" ");
1702  o > 0 && (t = s.slice(0, o), s = s.slice(o + 1));
1703  let l, a = t ? n2.createElementNS(t, s) : n2.createElement(s), c = e[1], u = 1;
1704  if (c && typeof c == "object" && c.nodeType == null && !Array.isArray(c)) {
1705    u = 2;
1706    for (let d in c) if (c[d] != null) {
1707      let f = d.indexOf(" ");
1708      f > 0 ? a.setAttributeNS(d.slice(0, f), d.slice(f + 1), c[d]) : d == "style" && a.style ? a.style.cssText = c[d] : a.setAttribute(d, c[d]);
1709    }
1710  }
1711  for (let d = u; d < e.length; d++) {
1712    let f = e[d];
1713    if (f === 0) {
1714      if (d < e.length - 1 || d > u) throw new RangeError("Content hole must be the only child of its parent node");
1715      return { dom: a, contentDOM: a };
1716    } else {
1717      let { dom: h, contentDOM: p } = Vn(n2, f, t, r);
1718      if (a.appendChild(h), p) {
1719        if (l) throw new RangeError("Multiple content holes");
1720        l = p;
1721      }
1722    }
1723  }
1724  return { dom: a, contentDOM: l };
1725}
1726const Hl = 65535, _l = Math.pow(2, 16);
1727function Xu(n2, e) {
1728  return n2 + e * _l;
1729}
1730function ro(n2) {
1731  return n2 & Hl;
1732}
1733function Zu(n2) {
1734  return (n2 - (n2 & Hl)) / _l;
1735}
1736const jl = 1, Wl = 2, Hn = 4, Ul = 8;
1737class As {
1738  constructor(e, t, r) {
1739    this.pos = e, this.delInfo = t, this.recover = r;
1740  }
1741  get deleted() {
1742    return (this.delInfo & Ul) > 0;
1743  }
1744  get deletedBefore() {
1745    return (this.delInfo & (jl | Hn)) > 0;
1746  }
1747  get deletedAfter() {
1748    return (this.delInfo & (Wl | Hn)) > 0;
1749  }
1750  get deletedAcross() {
1751    return (this.delInfo & Hn) > 0;
1752  }
1753}
1754class ue {
1755  constructor(e, t = false) {
1756    if (this.ranges = e, this.inverted = t, !e.length && ue.empty) return ue.empty;
1757  }
1758  recover(e) {
1759    let t = 0, r = ro(e);
1760    if (!this.inverted) for (let s = 0; s < r; s++) t += this.ranges[s * 3 + 2] - this.ranges[s * 3 + 1];
1761    return this.ranges[r * 3] + t + Zu(e);
1762  }
1763  mapResult(e, t = 1) {
1764    return this._map(e, t, false);
1765  }
1766  map(e, t = 1) {
1767    return this._map(e, t, true);
1768  }
1769  _map(e, t, r) {
1770    let s = 0, i = this.inverted ? 2 : 1, o = this.inverted ? 1 : 2;
1771    for (let l = 0; l < this.ranges.length; l += 3) {
1772      let a = this.ranges[l] - (this.inverted ? s : 0);
1773      if (a > e) break;
1774      let c = this.ranges[l + i], u = this.ranges[l + o], d = a + c;
1775      if (e <= d) {
1776        let f = c ? e == a ? -1 : e == d ? 1 : t : t, h = a + s + (f < 0 ? 0 : u);
1777        if (r) return h;
1778        let p = e == (t < 0 ? a : d) ? null : Xu(l / 3, e - a), m = e == a ? Wl : e == d ? jl : Hn;
1779        return (t < 0 ? e != a : e != d) && (m |= Ul), new As(h, m, p);
1780      }
1781      s += u - c;
1782    }
1783    return r ? e + s : new As(e + s, 0, null);
1784  }
1785  touches(e, t) {
1786    let r = 0, s = ro(t), i = this.inverted ? 2 : 1, o = this.inverted ? 1 : 2;
1787    for (let l = 0; l < this.ranges.length; l += 3) {
1788      let a = this.ranges[l] - (this.inverted ? r : 0);
1789      if (a > e) break;
1790      let c = this.ranges[l + i], u = a + c;
1791      if (e <= u && l == s * 3) return true;
1792      r += this.ranges[l + o] - c;
1793    }
1794    return false;
vendor: 11,977 bytes, lines 1795-2100
1795  }
1796  forEach(e) {
1797    let t = this.inverted ? 2 : 1, r = this.inverted ? 1 : 2;
1798    for (let s = 0, i = 0; s < this.ranges.length; s += 3) {
1799      let o = this.ranges[s], l = o - (this.inverted ? i : 0), a = o + (this.inverted ? 0 : i), c = this.ranges[s + t], u = this.ranges[s + r];
1800      e(l, l + c, a, a + u), i += u - c;
1801    }
1802  }
1803  invert() {
1804    return new ue(this.ranges, !this.inverted);
1805  }
1806  toString() {
1807    return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
1808  }
1809  static offset(e) {
1810    return e == 0 ? ue.empty : new ue(e < 0 ? [0, -e, 0] : [0, 0, e]);
1811  }
1812}
1813ue.empty = new ue([]);
1814class pn {
1815  constructor(e, t, r = 0, s = e ? e.length : 0) {
1816    this.mirror = t, this.from = r, this.to = s, this._maps = e || [], this.ownData = !(e || t);
1817  }
1818  get maps() {
1819    return this._maps;
1820  }
1821  slice(e = 0, t = this.maps.length) {
1822    return new pn(this._maps, this.mirror, e, t);
1823  }
1824  appendMap(e, t) {
1825    this.ownData || (this._maps = this._maps.slice(), this.mirror = this.mirror && this.mirror.slice(), this.ownData = true), this.to = this._maps.push(e), t != null && this.setMirror(this._maps.length - 1, t);
1826  }
1827  appendMapping(e) {
1828    for (let t = 0, r = this._maps.length; t < e._maps.length; t++) {
1829      let s = e.getMirror(t);
1830      this.appendMap(e._maps[t], s != null && s < t ? r + s : void 0);
1831    }
1832  }
1833  getMirror(e) {
1834    if (this.mirror) {
1835      for (let t = 0; t < this.mirror.length; t++) if (this.mirror[t] == e) return this.mirror[t + (t % 2 ? -1 : 1)];
1836    }
1837  }
1838  setMirror(e, t) {
1839    this.mirror || (this.mirror = []), this.mirror.push(e, t);
1840  }
1841  appendMappingInverted(e) {
1842    for (let t = e.maps.length - 1, r = this._maps.length + e._maps.length; t >= 0; t--) {
1843      let s = e.getMirror(t);
1844      this.appendMap(e._maps[t].invert(), s != null && s > t ? r - s - 1 : void 0);
1845    }
1846  }
1847  invert() {
1848    let e = new pn();
1849    return e.appendMappingInverted(this), e;
1850  }
1851  map(e, t = 1) {
1852    if (this.mirror) return this._map(e, t, true);
1853    for (let r = this.from; r < this.to; r++) e = this._maps[r].map(e, t);
1854    return e;
1855  }
1856  mapResult(e, t = 1) {
1857    return this._map(e, t, false);
1858  }
1859  _map(e, t, r) {
1860    let s = 0;
1861    for (let i = this.from; i < this.to; i++) {
1862      let o = this._maps[i], l = o.mapResult(e, t);
1863      if (l.recover != null) {
1864        let a = this.getMirror(i);
1865        if (a != null && a > i && a < this.to) {
1866          i = a, e = this._maps[a].recover(l.recover);
1867          continue;
1868        }
1869      }
1870      s |= l.delInfo, e = l.pos;
1871    }
1872    return r ? e : new As(e, s, null);
1873  }
1874}
1875const es = /* @__PURE__ */ Object.create(null);
1876class re {
1877  getMap() {
1878    return ue.empty;
1879  }
1880  merge(e) {
1881    return null;
1882  }
1883  static fromJSON(e, t) {
1884    if (!t || !t.stepType) throw new RangeError("Invalid input for Step.fromJSON");
1885    let r = es[t.stepType];
1886    if (!r) throw new RangeError(`No step type ${t.stepType} defined`);
1887    return r.fromJSON(e, t);
1888  }
1889  static jsonID(e, t) {
1890    if (e in es) throw new RangeError("Duplicate use of step JSON ID " + e);
1891    return es[e] = t, t.prototype.jsonID = e, t;
1892  }
1893}
1894class j {
1895  constructor(e, t) {
1896    this.doc = e, this.failed = t;
1897  }
1898  static ok(e) {
1899    return new j(e, null);
1900  }
1901  static fail(e) {
1902    return new j(null, e);
1903  }
1904  static fromReplace(e, t, r, s) {
1905    try {
1906      return j.ok(e.replace(t, r, s));
1907    } catch (i) {
1908      if (i instanceof Kn) return j.fail(i.message);
1909      throw i;
1910    }
1911  }
1912}
1913function ti(n2, e, t) {
1914  let r = [];
1915  for (let s = 0; s < n2.childCount; s++) {
1916    let i = n2.child(s);
1917    i.content.size && (i = i.copy(ti(i.content, e, i))), i.isInline && (i = e(i, t, s)), r.push(i);
1918  }
1919  return b.fromArray(r);
1920}
1921class Ge extends re {
1922  constructor(e, t, r) {
1923    super(), this.from = e, this.to = t, this.mark = r;
1924  }
1925  apply(e) {
1926    let t = e.slice(this.from, this.to), r = e.resolve(this.from), s = r.node(r.sharedDepth(this.to)), i = new w(ti(t.content, (o, l) => !o.isAtom || !l.type.allowsMarkType(this.mark.type) ? o : o.mark(this.mark.addToSet(o.marks)), s), t.openStart, t.openEnd);
1927    return j.fromReplace(e, this.from, this.to, i);
1928  }
1929  invert() {
1930    return new we(this.from, this.to, this.mark);
1931  }
1932  map(e) {
1933    let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
1934    return t.deleted && r.deleted || t.pos >= r.pos ? null : new Ge(t.pos, r.pos, this.mark);
1935  }
1936  merge(e) {
1937    return e instanceof Ge && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new Ge(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null;
1938  }
1939  toJSON() {
1940    return { stepType: "addMark", mark: this.mark.toJSON(), from: this.from, to: this.to };
1941  }
1942  static fromJSON(e, t) {
1943    if (typeof t.from != "number" || typeof t.to != "number") throw new RangeError("Invalid input for AddMarkStep.fromJSON");
1944    return new Ge(t.from, t.to, e.markFromJSON(t.mark));
1945  }
1946}
1947re.jsonID("addMark", Ge);
1948class we extends re {
1949  constructor(e, t, r) {
1950    super(), this.from = e, this.to = t, this.mark = r;
1951  }
1952  apply(e) {
1953    let t = e.slice(this.from, this.to), r = new w(ti(t.content, (s) => s.mark(this.mark.removeFromSet(s.marks)), e), t.openStart, t.openEnd);
1954    return j.fromReplace(e, this.from, this.to, r);
1955  }
1956  invert() {
1957    return new Ge(this.from, this.to, this.mark);
1958  }
1959  map(e) {
1960    let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
1961    return t.deleted && r.deleted || t.pos >= r.pos ? null : new we(t.pos, r.pos, this.mark);
1962  }
1963  merge(e) {
1964    return e instanceof we && e.mark.eq(this.mark) && this.from <= e.to && this.to >= e.from ? new we(Math.min(this.from, e.from), Math.max(this.to, e.to), this.mark) : null;
1965  }
1966  toJSON() {
1967    return { stepType: "removeMark", mark: this.mark.toJSON(), from: this.from, to: this.to };
1968  }
1969  static fromJSON(e, t) {
1970    if (typeof t.from != "number" || typeof t.to != "number") throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
1971    return new we(t.from, t.to, e.markFromJSON(t.mark));
1972  }
1973}
1974re.jsonID("removeMark", we);
1975class Ye extends re {
1976  constructor(e, t) {
1977    super(), this.pos = e, this.mark = t;
1978  }
1979  apply(e) {
1980    let t = e.nodeAt(this.pos);
1981    if (!t) return j.fail("No node at mark step's position");
1982    let r = t.type.create(t.attrs, null, this.mark.addToSet(t.marks));
1983    return j.fromReplace(e, this.pos, this.pos + 1, new w(b.from(r), 0, t.isLeaf ? 0 : 1));
1984  }
1985  invert(e) {
1986    let t = e.nodeAt(this.pos);
1987    if (t) {
1988      let r = this.mark.addToSet(t.marks);
1989      if (r.length == t.marks.length) {
1990        for (let s = 0; s < t.marks.length; s++) if (!t.marks[s].isInSet(r)) return new Ye(this.pos, t.marks[s]);
1991        return new Ye(this.pos, this.mark);
1992      }
1993    }
1994    return new St(this.pos, this.mark);
1995  }
1996  map(e) {
1997    let t = e.mapResult(this.pos, 1);
1998    return t.deletedAfter ? null : new Ye(t.pos, this.mark);
1999  }
2000  toJSON() {
2001    return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
2002  }
2003  static fromJSON(e, t) {
2004    if (typeof t.pos != "number") throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
2005    return new Ye(t.pos, e.markFromJSON(t.mark));
2006  }
2007}
2008re.jsonID("addNodeMark", Ye);
2009class St extends re {
2010  constructor(e, t) {
2011    super(), this.pos = e, this.mark = t;
2012  }
2013  apply(e) {
2014    let t = e.nodeAt(this.pos);
2015    if (!t) return j.fail("No node at mark step's position");
2016    let r = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks));
2017    return j.fromReplace(e, this.pos, this.pos + 1, new w(b.from(r), 0, t.isLeaf ? 0 : 1));
2018  }
2019  invert(e) {
2020    let t = e.nodeAt(this.pos);
2021    return !t || !this.mark.isInSet(t.marks) ? this : new Ye(this.pos, this.mark);
2022  }
2023  map(e) {
2024    let t = e.mapResult(this.pos, 1);
2025    return t.deletedAfter ? null : new St(t.pos, this.mark);
2026  }
2027  toJSON() {
2028    return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
2029  }
2030  static fromJSON(e, t) {
2031    if (typeof t.pos != "number") throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
2032    return new St(t.pos, e.markFromJSON(t.mark));
2033  }
2034}
2035re.jsonID("removeNodeMark", St);
2036class q extends re {
2037  constructor(e, t, r, s = false) {
2038    super(), this.from = e, this.to = t, this.slice = r, this.structure = s;
2039  }
2040  apply(e) {
2041    return this.structure && Ns(e, this.from, this.to) ? j.fail("Structure replace would overwrite content") : j.fromReplace(e, this.from, this.to, this.slice);
2042  }
2043  getMap() {
2044    return new ue([this.from, this.to - this.from, this.slice.size]);
2045  }
2046  invert(e) {
2047    return new q(this.from, this.from + this.slice.size, e.slice(this.from, this.to));
2048  }
2049  map(e) {
2050    let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1);
2051    return t.deletedAcross && r.deletedAcross ? null : new q(t.pos, Math.max(t.pos, r.pos), this.slice, this.structure);
2052  }
2053  merge(e) {
2054    if (!(e instanceof q) || e.structure || this.structure) return null;
2055    if (this.from + this.slice.size == e.from && !this.slice.openEnd && !e.slice.openStart) {
2056      let t = this.slice.size + e.slice.size == 0 ? w.empty : new w(this.slice.content.append(e.slice.content), this.slice.openStart, e.slice.openEnd);
2057      return new q(this.from, this.to + (e.to - e.from), t, this.structure);
2058    } else if (e.to == this.from && !this.slice.openStart && !e.slice.openEnd) {
2059      let t = this.slice.size + e.slice.size == 0 ? w.empty : new w(e.slice.content.append(this.slice.content), e.slice.openStart, this.slice.openEnd);
2060      return new q(e.from, this.to, t, this.structure);
2061    } else return null;
2062  }
2063  toJSON() {
2064    let e = { stepType: "replace", from: this.from, to: this.to };
2065    return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = true), e;
2066  }
2067  static fromJSON(e, t) {
2068    if (typeof t.from != "number" || typeof t.to != "number") throw new RangeError("Invalid input for ReplaceStep.fromJSON");
2069    return new q(t.from, t.to, w.fromJSON(e, t.slice), !!t.structure);
2070  }
2071}
2072re.jsonID("replace", q);
2073class J extends re {
2074  constructor(e, t, r, s, i, o, l = false) {
2075    super(), this.from = e, this.to = t, this.gapFrom = r, this.gapTo = s, this.slice = i, this.insert = o, this.structure = l;
2076  }
2077  apply(e) {
2078    if (this.structure && (Ns(e, this.from, this.gapFrom) || Ns(e, this.gapTo, this.to))) return j.fail("Structure gap-replace would overwrite content");
2079    let t = e.slice(this.gapFrom, this.gapTo);
2080    if (t.openStart || t.openEnd) return j.fail("Gap is not a flat range");
2081    let r = this.slice.insertAt(this.insert, t.content);
2082    return r ? j.fromReplace(e, this.from, this.to, r) : j.fail("Content does not fit in gap");
2083  }
2084  getMap() {
2085    return new ue([this.from, this.gapFrom - this.from, this.insert, this.gapTo, this.to - this.gapTo, this.slice.size - this.insert]);
2086  }
2087  invert(e) {
2088    let t = this.gapTo - this.gapFrom;
2089    return new J(this.from, this.from + this.slice.size + t, this.from + this.insert, this.from + this.insert + t, e.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
2090  }
2091  map(e) {
2092    let t = e.mapResult(this.from, 1), r = e.mapResult(this.to, -1), s = this.from == this.gapFrom ? t.pos : e.map(this.gapFrom, -1), i = this.to == this.gapTo ? r.pos : e.map(this.gapTo, 1);
2093    return t.deletedAcross && r.deletedAcross || s < t.pos || i > r.pos ? null : new J(t.pos, r.pos, s, i, this.slice, this.insert, this.structure);
2094  }
2095  toJSON() {
2096    let e = { stepType: "replaceAround", from: this.from, to: this.to, gapFrom: this.gapFrom, gapTo: this.gapTo, insert: this.insert };
2097    return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = true), e;
2098  }
2099  static fromJSON(e, t) {
2100    if (typeof t.from != "number" || typeof t.to != "number" || typeof t.gapFrom != "number" || typeof t.gapTo != "number" || typeof t.insert != "number") throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
2101    return new J(t.from, t.to, t.gapFrom, t.gapTo, w.fromJSON(e, t.slice), t.insert, !!t.structure);
2102  }
2103}
2104re.jsonID("replaceAround", J);
2105function Ns(n2, e, t) {
2106  let r = n2.resolve(e), s = t - e, i = r.depth;
2107  for (; s > 0 && i > 0 && r.indexAfter(i) == r.node(i).childCount; ) i--, s--;
2108  if (s > 0) {
2109    let o = r.node(i).maybeChild(r.indexAfter(i));
2110    for (; s > 0; ) {
2111      if (!o || o.isLeaf) return true;
2112      o = o.firstChild, s--;
2113    }
2114  }
2115  return false;
2116}
2117function ed(n2, e, t, r) {
2118  let s = [], i = [], o, l;
2119  n2.doc.nodesBetween(e, t, (a, c, u) => {
2120    if (!a.isInline) return;
2121    let d = a.marks;
2122    if (!r.isInSet(d) && u.type.allowsMarkType(r.type)) {
2123      let f = Math.max(c, e), h = Math.min(c + a.nodeSize, t), p = r.addToSet(d);
2124      for (let m = 0; m < d.length; m++) d[m].isInSet(p) || (o && o.to == f && o.mark.eq(d[m]) ? o.to = h : s.push(o = new we(f, h, d[m])));
2125      l && l.to == f ? l.to = h : i.push(l = new Ge(f, h, r));
2126    }
2127  }), s.forEach((a) => n2.step(a)), i.forEach((a) => n2.step(a));
2128}
2129function td(n2, e, t, r) {
2130  let s = [], i = 0;
2131  n2.doc.nodesBetween(e, t, (o, l) => {
2132    if (!o.isInline) return;
2133    i++;
2134    let a = null;
2135    if (r instanceof Rr) {
2136      let c = o.marks, u;
2137      for (; u = r.isInSet(c); ) (a || (a = [])).push(u), c = u.removeFromSet(c);
2138    } else r ? r.isInSet(o.marks) && (a = [r]) : a = o.marks;
2139    if (a && a.length) {
2140      let c = Math.min(l + o.nodeSize, t);
2141      for (let u = 0; u < a.length; u++) {
2142        let d = a[u], f;
2143        for (let h = 0; h < s.length; h++) {
2144          let p = s[h];
2145          p.step == i - 1 && d.eq(s[h].style) && (f = p);
2146        }
2147        f ? (f.to = c, f.step = i) : s.push({ style: d, from: Math.max(l, e), to: c, step: i });
2148      }
2149    }
2150  }), s.forEach((o) => n2.step(new we(o.from, o.to, o.style)));
2151}
2152function ni(n2, e, t, r = t.contentMatch, s = true) {
2153  let i = n2.doc.nodeAt(e), o = [], l = e + 1;
2154  for (let a = 0; a < i.childCount; a++) {
2155    let c = i.child(a), u = l + c.nodeSize, d = r.matchType(c.type);
2156    if (!d) o.push(new q(l, u, w.empty));
2157    else {
2158      r = d;
2159      for (let f = 0; f < c.marks.length; f++) t.allowsMarkType(c.marks[f].type) || n2.step(new we(l, u, c.marks[f]));
2160      if (s && c.isText && t.whitespace != "pre") {
2161        let f, h = /\r?\n|\r/g, p;
2162        for (; f = h.exec(c.text); ) p || (p = new w(b.from(t.schema.text(" ", t.allowedMarks(c.marks))), 0, 0)), o.push(new q(l + f.index, l + f.index + f[0].length, p));
2163      }
2164    }
2165    l = u;
2166  }
2167  if (!r.validEnd) {
2168    let a = r.fillBefore(b.empty, true);
2169    n2.replace(l, l, new w(a, 0, 0));
2170  }
2171  for (let a = o.length - 1; a >= 0; a--) n2.step(o[a]);
2172}
2173function nd(n2, e, t) {
2174  return (e == 0 || n2.canReplace(e, n2.childCount)) && (t == n2.childCount || n2.canReplace(0, t));
2175}
2176function jt(n2) {
2177  let t = n2.parent.content.cutByIndex(n2.startIndex, n2.endIndex);
2178  for (let r = n2.depth, s = 0, i = 0; ; --r) {
2179    let o = n2.$from.node(r), l = n2.$from.index(r) + s, a = n2.$to.indexAfter(r) - i;
2180    if (r < n2.depth && o.canReplace(l, a, t)) return r;
2181    if (r == 0 || o.type.spec.isolating || !nd(o, l, a)) break;
2182    l && (s = 1), a < o.childCount && (i = 1);
2183  }
2184  return null;
2185}
2186function rd(n2, e, t) {
2187  let { $from: r, $to: s, depth: i } = e, o = r.before(i + 1), l = s.after(i + 1), a = o, c = l, u = b.empty, d = 0;
2188  for (let p = i, m = false; p > t; p--) m || r.index(p) > 0 ? (m = true, u = b.from(r.node(p).copy(u)), d++) : a--;
2189  let f = b.empty, h = 0;
2190  for (let p = i, m = false; p > t; p--) m || s.after(p + 1) < s.end(p) ? (m = true, f = b.from(s.node(p).copy(f)), h++) : c++;
2191  n2.step(new J(a, c, o, l, new w(u.append(f), d, h), u.size - d, true));
2192}
2193function ri(n2, e, t = null, r = n2) {
2194  let s = sd(n2, e), i = s && id(r, e);
2195  return i ? s.map(so).concat({ type: e, attrs: t }).concat(i.map(so)) : null;
2196}
2197function so(n2) {
2198  return { type: n2, attrs: null };
2199}
2200function sd(n2, e) {
2201  let { parent: t, startIndex: r, endIndex: s } = n2, i = t.contentMatchAt(r).findWrapping(e);
2202  if (!i) return null;
2203  let o = i.length ? i[0] : e;
2204  return t.canReplaceWith(r, s, o) ? i : null;
2205}
2206function id(n2, e) {
2207  let { parent: t, startIndex: r, endIndex: s } = n2, i = t.child(r), o = e.contentMatch.findWrapping(i.type);
2208  if (!o) return null;
2209  let a = (o.length ? o[o.length - 1] : e).contentMatch;
2210  for (let c = r; a && c < s; c++) a = a.matchType(t.child(c).type);
2211  return !a || !a.validEnd ? null : o;
2212}
2213function od(n2, e, t) {
2214  let r = b.empty;
2215  for (let o = t.length - 1; o >= 0; o--) {
2216    if (r.size) {
2217      let l = t[o].type.contentMatch.matchFragment(r);
2218      if (!l || !l.validEnd) throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper");
2219    }
2220    r = b.from(t[o].type.create(t[o].attrs, r));
2221  }
2222  let s = e.start, i = e.end;
2223  n2.step(new J(s, i, s, i, new w(r, 0, 0), t.length, true));
2224}
2225function ld(n2, e, t, r, s) {
2226  if (!r.isTextblock) throw new RangeError("Type given to setBlockType should be a textblock");
2227  let i = n2.steps.length;
2228  n2.doc.nodesBetween(e, t, (o, l) => {
2229    let a = typeof s == "function" ? s(o) : s;
2230    if (o.isTextblock && !o.hasMarkup(r, a) && ad(n2.doc, n2.mapping.slice(i).map(l), r)) {
2231      let c = null;
2232      if (r.schema.linebreakReplacement) {
2233        let h = r.whitespace == "pre", p = !!r.contentMatch.matchType(r.schema.linebreakReplacement);
2234        h && !p ? c = false : !h && p && (c = true);
2235      }
2236      c === false && ql(n2, o, l, i), ni(n2, n2.mapping.slice(i).map(l, 1), r, void 0, c === null);
2237      let u = n2.mapping.slice(i), d = u.map(l, 1), f = u.map(l + o.nodeSize, 1);
2238      return n2.step(new J(d, f, d + 1, f - 1, new w(b.from(r.create(a, null, o.marks)), 0, 0), 1, true)), c === true && Kl(n2, o, l, i), false;
2239    }
2240  });
2241}
2242function Kl(n2, e, t, r) {
2243  e.forEach((s, i) => {
2244    if (s.isText) {
2245      let o, l = /\r?\n|\r/g;
2246      for (; o = l.exec(s.text); ) {
2247        let a = n2.mapping.slice(r).map(t + 1 + i + o.index);
2248        n2.replaceWith(a, a + 1, e.type.schema.linebreakReplacement.create());
2249      }
2250    }
2251  });
2252}
2253function ql(n2, e, t, r) {
2254  e.forEach((s, i) => {
2255    if (s.type == s.type.schema.linebreakReplacement) {
2256      let o = n2.mapping.slice(r).map(t + 1 + i);
2257      n2.replaceWith(o, o + 1, e.type.schema.text(`
2258`));
2259    }
2260  });
2261}
2262function ad(n2, e, t) {
2263  let r = n2.resolve(e), s = r.index();
2264  return r.parent.canReplaceWith(s, s + 1, t);
2265}
2266function cd(n2, e, t, r, s) {
2267  let i = n2.doc.nodeAt(e);
2268  if (!i) throw new RangeError("No node at given position");
2269  t || (t = i.type);
2270  let o = t.create(r, null, s || i.marks);
2271  if (i.isLeaf) return n2.replaceWith(e, e + i.nodeSize, o);
2272  if (!t.validContent(i.content)) throw new RangeError("Invalid content for node type " + t.name);
2273  n2.step(new J(e, e + i.nodeSize, e + 1, e + i.nodeSize - 1, new w(b.from(o), 0, 0), 1, true));
2274}
2275function Be(n2, e, t = 1, r) {
2276  let s = n2.resolve(e), i = s.depth - t, o = r && r[r.length - 1] || s.parent;
2277  if (i < 0 || s.parent.type.spec.isolating || !s.parent.canReplace(s.index(), s.parent.childCount) || !o.type.validContent(s.parent.content.cutByIndex(s.index(), s.parent.childCount))) return false;
vendor: 16,196 bytes, lines 2278-2664
2278  for (let c = s.depth - 1, u = t - 2; c > i; c--, u--) {
2279    let d = s.node(c), f = s.index(c);
2280    if (d.type.spec.isolating) return false;
2281    let h = d.content.cutByIndex(f, d.childCount), p = r && r[u + 1];
2282    p && (h = h.replaceChild(0, p.type.create(p.attrs)));
2283    let m = r && r[u] || d;
2284    if (!d.canReplace(f + 1, d.childCount) || !m.type.validContent(h)) return false;
2285  }
2286  let l = s.indexAfter(i), a = r && r[0];
2287  return s.node(i).canReplaceWith(l, l, a ? a.type : s.node(i + 1).type);
2288}
2289function ud(n2, e, t = 1, r) {
2290  let s = n2.doc.resolve(e), i = b.empty, o = b.empty;
2291  for (let l = s.depth, a = s.depth - t, c = t - 1; l > a; l--, c--) {
2292    i = b.from(s.node(l).copy(i));
2293    let u = r && r[c];
2294    o = b.from(u ? u.type.create(u.attrs, o) : s.node(l).copy(o));
2295  }
2296  n2.step(new q(e, e, new w(i.append(o), t, t), true));
2297}
2298function st(n2, e) {
2299  let t = n2.resolve(e), r = t.index();
2300  return Jl(t.nodeBefore, t.nodeAfter) && t.parent.canReplace(r, r + 1);
2301}
2302function dd(n2, e) {
2303  e.content.size || n2.type.compatibleContent(e.type);
2304  let t = n2.contentMatchAt(n2.childCount), { linebreakReplacement: r } = n2.type.schema;
2305  for (let s = 0; s < e.childCount; s++) {
2306    let i = e.child(s), o = i.type == r ? n2.type.schema.nodes.text : i.type;
2307    if (t = t.matchType(o), !t || !n2.type.allowsMarks(i.marks)) return false;
2308  }
2309  return t.validEnd;
2310}
2311function Jl(n2, e) {
2312  return !!(n2 && e && !n2.isLeaf && dd(n2, e));
2313}
2314function Pr(n2, e, t = -1) {
2315  let r = n2.resolve(e);
2316  for (let s = r.depth; ; s--) {
2317    let i, o, l = r.index(s);
2318    if (s == r.depth ? (i = r.nodeBefore, o = r.nodeAfter) : t > 0 ? (i = r.node(s + 1), l++, o = r.node(s).maybeChild(l)) : (i = r.node(s).maybeChild(l - 1), o = r.node(s + 1)), i && !i.isTextblock && Jl(i, o) && r.node(s).canReplace(l, l + 1)) return e;
2319    if (s == 0) break;
2320    e = t < 0 ? r.before(s) : r.after(s);
2321  }
2322}
2323function fd(n2, e, t) {
2324  let r = null, { linebreakReplacement: s } = n2.doc.type.schema, i = n2.doc.resolve(e - t), o = i.node().type;
2325  if (s && o.inlineContent) {
2326    let u = o.whitespace == "pre", d = !!o.contentMatch.matchType(s);
2327    u && !d ? r = false : !u && d && (r = true);
2328  }
2329  let l = n2.steps.length;
2330  if (r === false) {
2331    let u = n2.doc.resolve(e + t);
2332    ql(n2, u.node(), u.before(), l);
2333  }
2334  o.inlineContent && ni(n2, e + t - 1, o, i.node().contentMatchAt(i.index()), r == null);
2335  let a = n2.mapping.slice(l), c = a.map(e - t);
2336  if (n2.step(new q(c, a.map(e + t, -1), w.empty, true)), r === true) {
2337    let u = n2.doc.resolve(c);
2338    Kl(n2, u.node(), u.before(), n2.steps.length);
2339  }
2340  return n2;
2341}
2342function hd(n2, e, t) {
2343  let r = n2.resolve(e);
2344  if (r.parent.canReplaceWith(r.index(), r.index(), t)) return e;
2345  if (r.parentOffset == 0) for (let s = r.depth - 1; s >= 0; s--) {
2346    let i = r.index(s);
2347    if (r.node(s).canReplaceWith(i, i, t)) return r.before(s + 1);
2348    if (i > 0) return null;
2349  }
2350  if (r.parentOffset == r.parent.content.size) for (let s = r.depth - 1; s >= 0; s--) {
2351    let i = r.indexAfter(s);
2352    if (r.node(s).canReplaceWith(i, i, t)) return r.after(s + 1);
2353    if (i < r.node(s).childCount) return null;
2354  }
2355  return null;
2356}
2357function Gl(n2, e, t) {
2358  let r = n2.resolve(e);
2359  if (!t.content.size) return e;
2360  let s = t.content;
2361  for (let i = 0; i < t.openStart; i++) s = s.firstChild.content;
2362  for (let i = 1; i <= (t.openStart == 0 && t.size ? 2 : 1); i++) for (let o = r.depth; o >= 0; o--) {
2363    let l = o == r.depth ? 0 : r.pos <= (r.start(o + 1) + r.end(o + 1)) / 2 ? -1 : 1, a = r.index(o) + (l > 0 ? 1 : 0), c = r.node(o), u = false;
2364    if (i == 1) u = c.canReplace(a, a, s);
2365    else {
2366      let d = c.contentMatchAt(a).findWrapping(s.firstChild.type);
2367      u = d && c.canReplaceWith(a, a, d[0]);
2368    }
2369    if (u) return l == 0 ? r.pos : l < 0 ? r.before(o + 1) : r.after(o + 1);
2370  }
2371  return null;
2372}
2373function Lr(n2, e, t = e, r = w.empty) {
2374  if (e == t && !r.size) return null;
2375  let s = n2.resolve(e), i = n2.resolve(t);
2376  return Yl(s, i, r) ? new q(e, t, r) : new pd(s, i, r).fit();
2377}
2378function Yl(n2, e, t) {
2379  return !t.openStart && !t.openEnd && n2.start() == e.start() && n2.parent.canReplace(n2.index(), e.index(), t.content);
2380}
2381class pd {
2382  constructor(e, t, r) {
2383    this.$from = e, this.$to = t, this.unplaced = r, this.frontier = [], this.placed = b.empty;
2384    for (let s = 0; s <= e.depth; s++) {
2385      let i = e.node(s);
2386      this.frontier.push({ type: i.type, match: i.contentMatchAt(e.indexAfter(s)) });
2387    }
2388    for (let s = e.depth; s > 0; s--) this.placed = b.from(e.node(s).copy(this.placed));
2389  }
2390  get depth() {
2391    return this.frontier.length - 1;
2392  }
2393  fit() {
2394    for (; this.unplaced.size; ) {
2395      let c = this.findFittable();
2396      c ? this.placeNodes(c) : this.openMore() || this.dropNode();
2397    }
2398    let e = this.mustMoveInline(), t = this.placed.size - this.depth - this.$from.depth, r = this.$from, s = this.close(e < 0 ? this.$to : r.doc.resolve(e));
2399    if (!s) return null;
2400    let i = this.placed, o = r.depth, l = s.depth;
2401    for (; o && l && i.childCount == 1; ) i = i.firstChild.content, o--, l--;
2402    let a = new w(i, o, l);
2403    return e > -1 ? new J(r.pos, e, this.$to.pos, this.$to.end(), a, t) : a.size || r.pos != this.$to.pos ? new q(r.pos, s.pos, a) : null;
2404  }
2405  findFittable() {
2406    let e = this.unplaced.openStart;
2407    for (let t = this.unplaced.content, r = 0, s = this.unplaced.openEnd; r < e; r++) {
2408      let i = t.firstChild;
2409      if (t.childCount > 1 && (s = 0), i.type.spec.isolating && s <= r) {
2410        e = r;
2411        break;
2412      }
2413      t = i.content;
2414    }
2415    for (let t = 1; t <= 2; t++) for (let r = t == 1 ? e : this.unplaced.openStart; r >= 0; r--) {
2416      let s, i = null;
2417      r ? (i = ts(this.unplaced.content, r - 1).firstChild, s = i.content) : s = this.unplaced.content;
2418      let o = s.firstChild;
2419      for (let l = this.depth; l >= 0; l--) {
2420        let { type: a, match: c } = this.frontier[l], u, d = null;
2421        if (t == 1 && (o ? c.matchType(o.type) || (d = c.fillBefore(b.from(o), false)) : i && a.compatibleContent(i.type))) return { sliceDepth: r, frontierDepth: l, parent: i, inject: d };
2422        if (t == 2 && o && (u = c.findWrapping(o.type))) return { sliceDepth: r, frontierDepth: l, parent: i, wrap: u };
2423        if (i && c.matchType(i.type)) break;
2424      }
2425    }
2426  }
2427  openMore() {
2428    let { content: e, openStart: t, openEnd: r } = this.unplaced, s = ts(e, t);
2429    return !s.childCount || s.firstChild.isLeaf ? false : (this.unplaced = new w(e, t + 1, Math.max(r, s.size + t >= e.size - r ? t + 1 : 0)), true);
2430  }
2431  dropNode() {
2432    let { content: e, openStart: t, openEnd: r } = this.unplaced, s = ts(e, t);
2433    if (s.childCount <= 1 && t > 0) {
2434      let i = e.size - t <= t + s.size;
2435      this.unplaced = new w(Gt(e, t - 1, 1), t - 1, i ? t - 1 : r);
2436    } else this.unplaced = new w(Gt(e, t, 1), t, r);
2437  }
2438  placeNodes({ sliceDepth: e, frontierDepth: t, parent: r, inject: s, wrap: i }) {
2439    for (; this.depth > t; ) this.closeFrontierNode();
2440    if (i) for (let m = 0; m < i.length; m++) this.openFrontierNode(i[m]);
2441    let o = this.unplaced, l = r ? r.content : o.content, a = o.openStart - e, c = 0, u = [], { match: d, type: f } = this.frontier[t];
2442    if (s) {
2443      for (let m = 0; m < s.childCount; m++) u.push(s.child(m));
2444      d = d.matchFragment(s);
2445    }
2446    let h = l.size + e - (o.content.size - o.openEnd);
2447    for (; c < l.childCount; ) {
2448      let m = l.child(c), g = d.matchType(m.type);
2449      if (!g) break;
2450      c++, (c > 1 || a == 0 || m.content.size) && (d = g, u.push(Ql(m.mark(f.allowedMarks(m.marks)), c == 1 ? a : 0, c == l.childCount ? h : -1)));
2451    }
2452    let p = c == l.childCount;
2453    p || (h = -1), this.placed = Yt(this.placed, t, b.from(u)), this.frontier[t].match = d, p && h < 0 && r && r.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode();
2454    for (let m = 0, g = l; m < h; m++) {
2455      let y = g.lastChild;
2456      this.frontier.push({ type: y.type, match: y.contentMatchAt(y.childCount) }), g = y.content;
2457    }
2458    this.unplaced = p ? e == 0 ? w.empty : new w(Gt(o.content, e - 1, 1), e - 1, h < 0 ? o.openEnd : e - 1) : new w(Gt(o.content, e, c), o.openStart, o.openEnd);
2459  }
2460  mustMoveInline() {
2461    if (!this.$to.parent.isTextblock) return -1;
2462    let e = this.frontier[this.depth], t;
2463    if (!e.type.isTextblock || !ns(this.$to, this.$to.depth, e.type, e.match, false) || this.$to.depth == this.depth && (t = this.findCloseLevel(this.$to)) && t.depth == this.depth) return -1;
2464    let { depth: r } = this.$to, s = this.$to.after(r);
2465    for (; r > 1 && s == this.$to.end(--r); ) ++s;
2466    return s;
2467  }
2468  findCloseLevel(e) {
2469    e: for (let t = Math.min(this.depth, e.depth); t >= 0; t--) {
2470      let { match: r, type: s } = this.frontier[t], i = t < e.depth && e.end(t + 1) == e.pos + (e.depth - (t + 1)), o = ns(e, t, s, r, i);
2471      if (o) {
2472        for (let l = t - 1; l >= 0; l--) {
2473          let { match: a, type: c } = this.frontier[l], u = ns(e, l, c, a, true);
2474          if (!u || u.childCount) continue e;
2475        }
2476        return { depth: t, fit: o, move: i ? e.doc.resolve(e.after(t + 1)) : e };
2477      }
2478    }
2479  }
2480  close(e) {
2481    let t = this.findCloseLevel(e);
2482    if (!t) return null;
2483    for (; this.depth > t.depth; ) this.closeFrontierNode();
2484    t.fit.childCount && (this.placed = Yt(this.placed, t.depth, t.fit)), e = t.move;
2485    for (let r = t.depth + 1; r <= e.depth; r++) {
2486      let s = e.node(r), i = s.type.contentMatch.fillBefore(s.content, true, e.index(r));
2487      this.openFrontierNode(s.type, s.attrs, i);
2488    }
2489    return e;
2490  }
2491  openFrontierNode(e, t = null, r) {
2492    let s = this.frontier[this.depth];
2493    s.match = s.match.matchType(e), this.placed = Yt(this.placed, this.depth, b.from(e.create(t, r))), this.frontier.push({ type: e, match: e.contentMatch });
2494  }
2495  closeFrontierNode() {
2496    let t = this.frontier.pop().match.fillBefore(b.empty, true);
2497    t.childCount && (this.placed = Yt(this.placed, this.frontier.length, t));
2498  }
2499}
2500function Gt(n2, e, t) {
2501  return e == 0 ? n2.cutByIndex(t, n2.childCount) : n2.replaceChild(0, n2.firstChild.copy(Gt(n2.firstChild.content, e - 1, t)));
2502}
2503function Yt(n2, e, t) {
2504  return e == 0 ? n2.append(t) : n2.replaceChild(n2.childCount - 1, n2.lastChild.copy(Yt(n2.lastChild.content, e - 1, t)));
2505}
2506function ts(n2, e) {
2507  for (let t = 0; t < e; t++) n2 = n2.firstChild.content;
2508  return n2;
2509}
2510function Ql(n2, e, t) {
2511  if (e <= 0) return n2;
2512  let r = n2.content;
2513  return e > 1 && (r = r.replaceChild(0, Ql(r.firstChild, e - 1, r.childCount == 1 ? t - 1 : 0))), e > 0 && (r = n2.type.contentMatch.fillBefore(r).append(r), t <= 0 && (r = r.append(n2.type.contentMatch.matchFragment(r).fillBefore(b.empty, true)))), n2.copy(r);
2514}
2515function ns(n2, e, t, r, s) {
2516  let i = n2.node(e), o = s ? n2.indexAfter(e) : n2.index(e);
2517  if (o == i.childCount && !t.compatibleContent(i.type)) return null;
2518  let l = r.fillBefore(i.content, true, o);
2519  return l && !md(t, i.content, o) ? l : null;
2520}
2521function md(n2, e, t) {
2522  for (let r = t; r < e.childCount; r++) if (!n2.allowsMarks(e.child(r).marks)) return true;
2523  return false;
2524}
2525function gd(n2) {
2526  return n2.spec.defining || n2.spec.definingForContent;
2527}
2528function yd(n2, e, t, r) {
2529  if (!r.size) return n2.deleteRange(e, t);
2530  let s = n2.doc.resolve(e), i = n2.doc.resolve(t);
2531  if (Yl(s, i, r)) return n2.step(new q(e, t, r));
2532  let o = Zl(s, i);
2533  o[o.length - 1] == 0 && o.pop();
2534  let l = -(s.depth + 1);
2535  o.unshift(l);
2536  for (let f = s.depth, h = s.pos - 1; f > 0; f--, h--) {
2537    let p = s.node(f).type.spec;
2538    if (p.defining || p.definingAsContext || p.isolating) break;
2539    o.indexOf(f) > -1 ? l = f : s.before(f) == h && o.splice(1, 0, -f);
2540  }
2541  let a = o.indexOf(l), c = [], u = r.openStart;
2542  for (let f = r.content, h = 0; ; h++) {
2543    let p = f.firstChild;
2544    if (c.push(p), h == r.openStart) break;
2545    f = p.content;
2546  }
2547  for (let f = u - 1; f >= 0; f--) {
2548    let h = c[f], p = gd(h.type);
2549    if (p && !h.sameMarkup(s.node(Math.abs(l) - 1))) u = f;
2550    else if (p || !h.type.isTextblock) break;
2551  }
2552  for (let f = r.openStart; f >= 0; f--) {
2553    let h = (f + u + 1) % (r.openStart + 1), p = c[h];
2554    if (p) for (let m = 0; m < o.length; m++) {
2555      let g = o[(m + a) % o.length], y = true;
2556      g < 0 && (y = false, g = -g);
2557      let x = s.node(g - 1), M = s.index(g - 1);
2558      if (x.canReplaceWith(M, M, p.type, p.marks)) return n2.replace(s.before(g), y ? i.after(g) : t, new w(Xl(r.content, 0, r.openStart, h), h, r.openEnd));
2559    }
2560  }
2561  let d = n2.steps.length;
2562  for (let f = o.length - 1; f >= 0 && (n2.replace(e, t, r), !(n2.steps.length > d)); f--) {
2563    let h = o[f];
2564    h < 0 || (e = s.before(h), t = i.after(h));
2565  }
2566}
2567function Xl(n2, e, t, r, s) {
2568  if (e < t) {
2569    let i = n2.firstChild;
2570    n2 = n2.replaceChild(0, i.copy(Xl(i.content, e + 1, t, r, i)));
2571  }
2572  if (e > r) {
2573    let i = s.contentMatchAt(0), o = i.fillBefore(n2).append(n2);
2574    n2 = o.append(i.matchFragment(o).fillBefore(b.empty, true));
2575  }
2576  return n2;
2577}
2578function bd(n2, e, t, r) {
2579  if (!r.isInline && e == t && n2.doc.resolve(e).parent.content.size) {
2580    let s = hd(n2.doc, e, r.type);
2581    s != null && (e = t = s);
2582  }
2583  n2.replaceRange(e, t, new w(b.from(r), 0, 0));
2584}
2585function kd(n2, e, t) {
2586  let r = n2.doc.resolve(e), s = n2.doc.resolve(t), i = Zl(r, s);
2587  for (let o = 0; o < i.length; o++) {
2588    let l = i[o], a = o == i.length - 1;
2589    if (a && l == 0 || r.node(l).type.contentMatch.validEnd) return n2.delete(r.start(l), s.end(l));
2590    if (l > 0 && (a || r.node(l - 1).canReplace(r.index(l - 1), s.indexAfter(l - 1)))) return n2.delete(r.before(l), s.after(l));
2591  }
2592  for (let o = 1; o <= r.depth && o <= s.depth; o++) if (e - r.start(o) == r.depth - o && t > r.end(o) && s.end(o) - t != s.depth - o && r.start(o - 1) == s.start(o - 1) && r.node(o - 1).canReplace(r.index(o - 1), s.index(o - 1))) return n2.delete(r.before(o), t);
2593  n2.delete(e, t);
2594}
2595function Zl(n2, e) {
2596  let t = [], r = Math.min(n2.depth, e.depth);
2597  for (let s = r; s >= 0; s--) {
2598    let i = n2.start(s);
2599    if (i < n2.pos - (n2.depth - s) || e.end(s) > e.pos + (e.depth - s) || n2.node(s).type.spec.isolating || e.node(s).type.spec.isolating) break;
2600    (i == e.start(s) || s == n2.depth && s == e.depth && n2.parent.inlineContent && e.parent.inlineContent && s && e.start(s - 1) == i - 1) && t.push(s);
2601  }
2602  return t;
2603}
2604class Pt extends re {
2605  constructor(e, t, r) {
2606    super(), this.pos = e, this.attr = t, this.value = r;
2607  }
2608  apply(e) {
2609    let t = e.nodeAt(this.pos);
2610    if (!t) return j.fail("No node at attribute step's position");
2611    let r = /* @__PURE__ */ Object.create(null);
2612    for (let i in t.attrs) r[i] = t.attrs[i];
2613    r[this.attr] = this.value;
2614    let s = t.type.create(r, null, t.marks);
2615    return j.fromReplace(e, this.pos, this.pos + 1, new w(b.from(s), 0, t.isLeaf ? 0 : 1));
2616  }
2617  getMap() {
2618    return ue.empty;
2619  }
2620  invert(e) {
2621    return new Pt(this.pos, this.attr, e.nodeAt(this.pos).attrs[this.attr]);
2622  }
2623  map(e) {
2624    let t = e.mapResult(this.pos, 1);
2625    return t.deletedAfter ? null : new Pt(t.pos, this.attr, this.value);
2626  }
2627  toJSON() {
2628    return { stepType: "attr", pos: this.pos, attr: this.attr, value: this.value };
2629  }
2630  static fromJSON(e, t) {
2631    if (typeof t.pos != "number" || typeof t.attr != "string") throw new RangeError("Invalid input for AttrStep.fromJSON");
2632    return new Pt(t.pos, t.attr, t.value);
2633  }
2634}
2635re.jsonID("attr", Pt);
2636class mn extends re {
2637  constructor(e, t) {
2638    super(), this.attr = e, this.value = t;
2639  }
2640  apply(e) {
2641    let t = /* @__PURE__ */ Object.create(null);
2642    for (let s in e.attrs) t[s] = e.attrs[s];
2643    t[this.attr] = this.value;
2644    let r = e.type.create(t, e.content, e.marks);
2645    return j.ok(r);
2646  }
2647  getMap() {
2648    return ue.empty;
2649  }
2650  invert(e) {
2651    return new mn(this.attr, e.attrs[this.attr]);
2652  }
2653  map(e) {
2654    return this;
2655  }
2656  toJSON() {
2657    return { stepType: "docAttr", attr: this.attr, value: this.value };
2658  }
2659  static fromJSON(e, t) {
2660    if (typeof t.attr != "string") throw new RangeError("Invalid input for DocAttrStep.fromJSON");
2661    return new mn(t.attr, t.value);
2662  }
2663}
2664re.jsonID("docAttr", mn);
2665let Bt = class extends Error {
2666};
2667Bt = function n(e) {
2668  let t = Error.call(this, e);
2669  return t.__proto__ = n.prototype, t;
2670};
2671Bt.prototype = Object.create(Error.prototype);
2672Bt.prototype.constructor = Bt;
2673Bt.prototype.name = "TransformError";
2674class ea {
2675  constructor(e) {
2676    this.doc = e, this.steps = [], this.docs = [], this.mapping = new pn();
2677  }
2678  get before() {
2679    return this.docs.length ? this.docs[0] : this.doc;
2680  }
2681  step(e) {
2682    let t = this.maybeStep(e);
2683    if (t.failed) throw new Bt(t.failed);
2684    return this;
2685  }
2686  maybeStep(e) {
2687    let t = e.apply(this.doc);
2688    return t.failed || this.addStep(e, t.doc), t;
2689  }
2690  get docChanged() {
2691    return this.steps.length > 0;
2692  }
2693  changedRange() {
2694    let e = 1e9, t = -1e9;
2695    for (let r = 0; r < this.mapping.maps.length; r++) {
2696      let s = this.mapping.maps[r];
2697      r && (e = s.map(e, 1), t = s.map(t, -1)), s.forEach((i, o, l, a) => {
2698        e = Math.min(e, l), t = Math.max(t, a);
2699      });
2700    }
2701    return e == 1e9 ? null : { from: e, to: t };
2702  }
2703  addStep(e, t) {
2704    this.docs.push(this.doc), this.steps.push(e), this.mapping.appendMap(e.getMap()), this.doc = t;
2705  }
2706  replace(e, t = e, r = w.empty) {
2707    let s = Lr(this.doc, e, t, r);
2708    return s && this.step(s), this;
2709  }
2710  replaceWith(e, t, r) {
2711    return this.replace(e, t, new w(b.from(r), 0, 0));
2712  }
2713  delete(e, t) {
2714    return this.replace(e, t, w.empty);
2715  }
2716  insert(e, t) {
2717    return this.replaceWith(e, e, t);
2718  }
2719  replaceRange(e, t, r) {
2720    return yd(this, e, t, r), this;
2721  }
2722  replaceRangeWith(e, t, r) {
2723    return bd(this, e, t, r), this;
2724  }
2725  deleteRange(e, t) {
2726    return kd(this, e, t), this;
2727  }
2728  lift(e, t) {
2729    return rd(this, e, t), this;
2730  }
2731  join(e, t = 1) {
2732    return fd(this, e, t), this;
2733  }
2734  wrap(e, t) {
2735    return od(this, e, t), this;
2736  }
2737  setBlockType(e, t = e, r, s = null) {
2738    return ld(this, e, t, r, s), this;
2739  }
2740  setNodeMarkup(e, t, r = null, s) {
2741    return cd(this, e, t, r, s), this;
2742  }
2743  setNodeAttribute(e, t, r) {
2744    return this.step(new Pt(e, t, r)), this;
2745  }
2746  setDocAttribute(e, t) {
2747    return this.step(new mn(e, t)), this;
2748  }
2749  addNodeMark(e, t) {
2750    return this.step(new Ye(e, t)), this;
2751  }
2752  removeNodeMark(e, t) {
2753    let r = this.doc.nodeAt(e);
2754    if (!r) throw new RangeError("No node at position " + e);
2755    if (t instanceof B) t.isInSet(r.marks) && this.step(new St(e, t));
2756    else {
2757      let s = r.marks, i, o = [];
2758      for (; i = t.isInSet(s); ) o.push(new St(e, i)), s = i.removeFromSet(s);
2759      for (let l = o.length - 1; l >= 0; l--) this.step(o[l]);
2760    }
2761    return this;
2762  }
2763  split(e, t = 1, r) {
2764    return ud(this, e, t, r), this;
2765  }
2766  addMark(e, t, r) {
2767    return ed(this, e, t, r), this;
2768  }
2769  removeMark(e, t, r) {
2770    return td(this, e, t, r), this;
2771  }
2772  clearIncompatible(e, t, r) {
2773    return ni(this, e, t, r), this;
2774  }
2775}
2776const rs = /* @__PURE__ */ Object.create(null);
2777class R {
2778  constructor(e, t, r) {
2779    this.$anchor = e, this.$head = t, this.ranges = r || [new xd(e.min(t), e.max(t))];
2780  }
2781  get anchor() {
2782    return this.$anchor.pos;
2783  }
2784  get head() {
2785    return this.$head.pos;
2786  }
2787  get from() {
2788    return this.$from.pos;
2789  }
2790  get to() {
2791    return this.$to.pos;
2792  }
2793  get $from() {
2794    return this.ranges[0].$from;
2795  }
2796  get $to() {
2797    return this.ranges[0].$to;
2798  }
2799  get empty() {
2800    let e = this.ranges;
2801    for (let t = 0; t < e.length; t++) if (e[t].$from.pos != e[t].$to.pos) return false;
2802    return true;
2803  }
2804  content() {
2805    return this.$from.doc.slice(this.from, this.to, true);
2806  }
2807  replace(e, t = w.empty) {
2808    let r = t.content.lastChild, s = null;
2809    for (let l = 0; l < t.openEnd; l++) s = r, r = r.lastChild;
2810    let i = e.steps.length, o = this.ranges;
2811    for (let l = 0; l < o.length; l++) {
2812      let { $from: a, $to: c } = o[l], u = e.mapping.slice(i);
2813      e.replaceRange(u.map(a.pos), u.map(c.pos), l ? w.empty : t), l == 0 && lo(e, i, (r ? r.isInline : s && s.isTextblock) ? -1 : 1);
2814    }
2815  }
2816  replaceWith(e, t) {
2817    let r = e.steps.length, s = this.ranges;
2818    for (let i = 0; i < s.length; i++) {
2819      let { $from: o, $to: l } = s[i], a = e.mapping.slice(r), c = a.map(o.pos), u = a.map(l.pos);
2820      i ? e.deleteRange(c, u) : (e.replaceRangeWith(c, u, t), lo(e, r, t.isInline ? -1 : 1));
2821    }
2822  }
2823  static findFrom(e, t, r = false) {
2824    let s = e.parent.inlineContent ? new I(e) : Ot(e.node(0), e.parent, e.pos, e.index(), t, r);
2825    if (s) return s;
2826    for (let i = e.depth - 1; i >= 0; i--) {
2827      let o = t < 0 ? Ot(e.node(0), e.node(i), e.before(i + 1), e.index(i), t, r) : Ot(e.node(0), e.node(i), e.after(i + 1), e.index(i) + 1, t, r);
2828      if (o) return o;
2829    }
2830    return null;
2831  }
2832  static near(e, t = 1) {
2833    return this.findFrom(e, t) || this.findFrom(e, -t) || new de(e.node(0));
2834  }
2835  static atStart(e) {
2836    return Ot(e, e, 0, 0, 1) || new de(e);
2837  }
2838  static atEnd(e) {
2839    return Ot(e, e, e.content.size, e.childCount, -1) || new de(e);
2840  }
2841  static fromJSON(e, t) {
2842    if (!t || !t.type) throw new RangeError("Invalid input for Selection.fromJSON");
2843    let r = rs[t.type];
2844    if (!r) throw new RangeError(`No selection type ${t.type} defined`);
2845    return r.fromJSON(e, t);
2846  }
2847  static jsonID(e, t) {
2848    if (e in rs) throw new RangeError("Duplicate use of selection JSON ID " + e);
2849    return rs[e] = t, t.prototype.jsonID = e, t;
2850  }
2851  getBookmark() {
2852    return I.between(this.$anchor, this.$head).getBookmark();
2853  }
2854}
2855R.prototype.visible = true;
2856class xd {
2857  constructor(e, t) {
2858    this.$from = e, this.$to = t;
2859  }
2860}
2861let io = false;
2862function oo(n2) {
2863  !io && !n2.parent.inlineContent && (io = true, console.warn("TextSelection endpoint not pointing into a node with inline content (" + n2.parent.type.name + ")"));
2864}
2865class I extends R {
2866  constructor(e, t = e) {
2867    oo(e), oo(t), super(e, t);
2868  }
2869  get $cursor() {
2870    return this.$anchor.pos == this.$head.pos ? this.$head : null;
2871  }
2872  map(e, t) {
2873    let r = e.resolve(t.map(this.head));
2874    if (!r.parent.inlineContent) return R.near(r);
2875    let s = e.resolve(t.map(this.anchor));
2876    return new I(s.parent.inlineContent ? s : r, r);
2877  }
2878  replace(e, t = w.empty) {
2879    if (super.replace(e, t), t == w.empty) {
2880      let r = this.$from.marksAcross(this.$to);
2881      r && e.ensureMarks(r);
2882    }
2883  }
2884  eq(e) {
2885    return e instanceof I && e.anchor == this.anchor && e.head == this.head;
2886  }
2887  getBookmark() {
2888    return new Br(this.anchor, this.head);
2889  }
2890  toJSON() {
2891    return { type: "text", anchor: this.anchor, head: this.head };
2892  }
2893  static fromJSON(e, t) {
2894    if (typeof t.anchor != "number" || typeof t.head != "number") throw new RangeError("Invalid input for TextSelection.fromJSON");
2895    return new I(e.resolve(t.anchor), e.resolve(t.head));
2896  }
2897  static create(e, t, r = t) {
2898    let s = e.resolve(t);
2899    return new this(s, r == t ? s : e.resolve(r));
2900  }
2901  static between(e, t, r) {
2902    let s = e.pos - t.pos;
2903    if ((!r || s) && (r = s >= 0 ? 1 : -1), !t.parent.inlineContent) {
2904      let i = R.findFrom(t, r, true) || R.findFrom(t, -r, true);
2905      if (i) t = i.$head;
2906      else return R.near(t, r);
2907    }
2908    return e.parent.inlineContent || (s == 0 ? e = t : (e = (R.findFrom(e, -r, true) || R.findFrom(e, r, true)).$anchor, e.pos < t.pos != s < 0 && (e = t))), new I(e, t);
2909  }
2910}
2911R.jsonID("text", I);
2912class Br {
2913  constructor(e, t) {
2914    this.anchor = e, this.head = t;
2915  }
2916  map(e) {
2917    return new Br(e.map(this.anchor), e.map(this.head));
2918  }
2919  resolve(e) {
2920    return I.between(e.resolve(this.anchor), e.resolve(this.head));
2921  }
2922}
2923class T extends R {
2924  constructor(e) {
2925    let t = e.nodeAfter, r = e.node(0).resolve(e.pos + t.nodeSize);
2926    super(e, r), this.node = t;
2927  }
2928  map(e, t) {
2929    let { deleted: r, pos: s } = t.mapResult(this.anchor), i = e.resolve(s);
2930    return r ? R.near(i) : new T(i);
2931  }
2932  content() {
2933    return new w(b.from(this.node), 0, 0);
2934  }
2935  eq(e) {
2936    return e instanceof T && e.anchor == this.anchor;
2937  }
2938  toJSON() {
2939    return { type: "node", anchor: this.anchor };
2940  }
2941  getBookmark() {
2942    return new si(this.anchor);
2943  }
2944  static fromJSON(e, t) {
2945    if (typeof t.anchor != "number") throw new RangeError("Invalid input for NodeSelection.fromJSON");
2946    return new T(e.resolve(t.anchor));
2947  }
2948  static create(e, t) {
2949    return new T(e.resolve(t));
2950  }
2951  static isSelectable(e) {
2952    return !e.isText && e.type.spec.selectable !== false;
2953  }
2954}
2955T.prototype.visible = false;
2956R.jsonID("node", T);
2957class si {
2958  constructor(e) {
2959    this.anchor = e;
2960  }
2961  map(e) {
2962    let { deleted: t, pos: r } = e.mapResult(this.anchor);
2963    return t ? new Br(r, r) : new si(r);
2964  }
2965  resolve(e) {
2966    let t = e.resolve(this.anchor), r = t.nodeAfter;
2967    return r && T.isSelectable(r) ? new T(t) : R.near(t);
2968  }
2969}
2970class de extends R {
2971  constructor(e) {
2972    super(e.resolve(0), e.resolve(e.content.size));
2973  }
2974  replace(e, t = w.empty) {
2975    if (t == w.empty) {
2976      e.delete(0, e.doc.content.size);
2977      let r = R.atStart(e.doc);
2978      r.eq(e.selection) || e.setSelection(r);
2979    } else super.replace(e, t);
2980  }
2981  toJSON() {
2982    return { type: "all" };
2983  }
2984  static fromJSON(e) {
2985    return new de(e);
2986  }
2987  map(e) {
2988    return new de(e);
2989  }
2990  eq(e) {
2991    return e instanceof de;
2992  }
2993  getBookmark() {
2994    return Sd;
2995  }
2996}
2997R.jsonID("all", de);
2998const Sd = { map() {
2999  return this;
3000}, resolve(n2) {
3001  return new de(n2);
3002} };
3003function Ot(n2, e, t, r, s, i = false) {
3004  if (e.inlineContent) return I.create(n2, t);
3005  for (let o = r - (s > 0 ? 0 : 1); s > 0 ? o < e.childCount : o >= 0; o += s) {
3006    let l = e.child(o);
3007    if (l.isAtom) {
3008      if (!i && T.isSelectable(l)) return T.create(n2, t - (s < 0 ? l.nodeSize : 0));
3009    } else {
3010      let a = Ot(n2, l, t + s, s < 0 ? l.childCount : 0, s, i);
3011      if (a) return a;
3012    }
3013    t += l.nodeSize * s;
3014  }
3015  return null;
3016}
3017function lo(n2, e, t) {
3018  let r = n2.steps.length - 1;
3019  if (r < e) return;
3020  let s = n2.steps[r];
3021  if (!(s instanceof q || s instanceof J)) return;
3022  let i = n2.mapping.maps[r], o;
3023  i.forEach((l, a, c, u) => {
3024    o == null && (o = u);
3025  }), n2.setSelection(R.near(n2.doc.resolve(o), t));
3026}
3027const ao = 1, In = 2, co = 4;
3028class wd extends ea {
3029  constructor(e) {
3030    super(e.doc), this.curSelectionFor = 0, this.updated = 0, this.meta = /* @__PURE__ */ Object.create(null), this.time = Date.now(), this.curSelection = e.selection, this.storedMarks = e.storedMarks;
3031  }
3032  get selection() {
3033    return this.curSelectionFor < this.steps.length && (this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor)), this.curSelectionFor = this.steps.length), this.curSelection;
3034  }
3035  setSelection(e) {
3036    if (e.$from.doc != this.doc) throw new RangeError("Selection passed to setSelection must point at the current document");
3037    return this.curSelection = e, this.curSelectionFor = this.steps.length, this.updated = (this.updated | ao) & ~In, this.storedMarks = null, this;
3038  }
3039  get selectionSet() {
3040    return (this.updated & ao) > 0;
3041  }
3042  setStoredMarks(e) {
3043    return this.storedMarks = e, this.updated |= In, this;
3044  }
3045  ensureMarks(e) {
3046    return B.sameSet(this.storedMarks || this.selection.$from.marks(), e) || this.setStoredMarks(e), this;
3047  }
3048  addStoredMark(e) {
3049    return this.ensureMarks(e.addToSet(this.storedMarks || this.selection.$head.marks()));
3050  }
3051  removeStoredMark(e) {
3052    return this.ensureMarks(e.removeFromSet(this.storedMarks || this.selection.$head.marks()));
3053  }
3054  get storedMarksSet() {
3055    return (this.updated & In) > 0;
3056  }
3057  addStep(e, t) {
3058    super.addStep(e, t), this.updated = this.updated & ~In, this.storedMarks = null;
3059  }
3060  setTime(e) {
3061    return this.time = e, this;
3062  }
3063  replaceSelection(e) {
3064    return this.selection.replace(this, e), this;
3065  }
3066  replaceSelectionWith(e, t = true) {
3067    let r = this.selection;
3068    return t && (e = e.mark(this.storedMarks || (r.empty ? r.$from.marks() : r.$from.marksAcross(r.$to) || B.none))), r.replaceWith(this, e), this;
3069  }
3070  deleteSelection() {
3071    return this.selection.replace(this), this;
3072  }
3073  insertText(e, t, r) {
3074    let s = this.doc.type.schema;
3075    if (t == null) return e ? this.replaceSelectionWith(s.text(e), true) : this.deleteSelection();
3076    {
3077      if (r == null && (r = t), !e) return this.deleteRange(t, r);
3078      let i = this.storedMarks;
3079      if (!i) {
3080        let o = this.doc.resolve(t);
3081        i = r == t ? o.marks() : o.marksAcross(this.doc.resolve(r));
3082      }
3083      return this.replaceRangeWith(t, r, s.text(e, i)), !this.selection.empty && this.selection.to == t + e.length && this.setSelection(R.near(this.selection.$to)), this;
3084    }
3085  }
3086  setMeta(e, t) {
3087    return this.meta[typeof e == "string" ? e : e.key] = t, this;
3088  }
3089  getMeta(e) {
3090    return this.meta[typeof e == "string" ? e : e.key];
3091  }
3092  get isGeneric() {
3093    for (let e in this.meta) return false;
3094    return true;
3095  }
3096  scrollIntoView() {
3097    return this.updated |= co, this;
3098  }
3099  get scrolledIntoView() {
3100    return (this.updated & co) > 0;
3101  }
3102}
3103function uo(n2, e) {
3104  return !e || !n2 ? n2 : n2.bind(e);
3105}
3106class Qt {
3107  constructor(e, t, r) {
3108    this.name = e, this.init = uo(t.init, r), this.apply = uo(t.apply, r);
3109  }
3110}
3111const Cd = [new Qt("doc", { init(n2) {
3112  return n2.doc || n2.schema.topNodeType.createAndFill();
3113}, apply(n2) {
3114  return n2.doc;
3115} }), new Qt("selection", { init(n2, e) {
3116  return n2.selection || R.atStart(e.doc);
3117}, apply(n2) {
3118  return n2.selection;
3119} }), new Qt("storedMarks", { init(n2) {
3120  return n2.storedMarks || null;
3121}, apply(n2, e, t, r) {
3122  return r.selection.$cursor ? n2.storedMarks : null;
3123} }), new Qt("scrollToSelection", { init() {
3124  return 0;
3125}, apply(n2, e) {
3126  return n2.scrolledIntoView ? e + 1 : e;
3127} })];
3128class ss {
3129  constructor(e, t) {
3130    this.schema = e, this.plugins = [], this.pluginsByKey = /* @__PURE__ */ Object.create(null), this.fields = Cd.slice(), t && t.forEach((r) => {
3131      if (this.pluginsByKey[r.key]) throw new RangeError("Adding different instances of a keyed plugin (" + r.key + ")");
3132      this.plugins.push(r), this.pluginsByKey[r.key] = r, r.spec.state && this.fields.push(new Qt(r.key, r.spec.state, r));
3133    });
3134  }
3135}
3136class Rt {
3137  constructor(e) {
3138    this.config = e;
3139  }
3140  get schema() {
3141    return this.config.schema;
3142  }
3143  get plugins() {
3144    return this.config.plugins;
3145  }
3146  apply(e) {
3147    return this.applyTransaction(e).state;
3148  }
3149  filterTransaction(e, t = -1) {
3150    for (let r = 0; r < this.config.plugins.length; r++) if (r != t) {
3151      let s = this.config.plugins[r];
3152      if (s.spec.filterTransaction && !s.spec.filterTransaction.call(s, e, this)) return false;
3153    }
3154    return true;
3155  }
3156  applyTransaction(e) {
3157    if (!this.filterTransaction(e)) return { state: this, transactions: [] };
3158    let t = [e], r = this.applyInner(e), s = null;
3159    for (; ; ) {
3160      let i = false;
3161      for (let o = 0; o < this.config.plugins.length; o++) {
3162        let l = this.config.plugins[o];
3163        if (l.spec.appendTransaction) {
3164          let a = s ? s[o].n : 0, c = s ? s[o].state : this, u = a < t.length && l.spec.appendTransaction.call(l, a ? t.slice(a) : t, c, r);
3165          if (u && r.filterTransaction(u, o)) {
3166            if (u.setMeta("appendedTransaction", e), !s) {
3167              s = [];
3168              for (let d = 0; d < this.config.plugins.length; d++) s.push(d < o ? { state: r, n: t.length } : { state: this, n: 0 });
3169            }
3170            t.push(u), r = r.applyInner(u), i = true;
3171          }
3172          s && (s[o] = { state: r, n: t.length });
3173        }
3174      }
3175      if (!i) return { state: r, transactions: t };
3176    }
3177  }
3178  applyInner(e) {
3179    if (!e.before.eq(this.doc)) throw new RangeError("Applying a mismatched transaction");
3180    let t = new Rt(this.config), r = this.config.fields;
3181    for (let s = 0; s < r.length; s++) {
3182      let i = r[s];
3183      t[i.name] = i.apply(e, this[i.name], this, t);
3184    }
3185    return t;
3186  }
3187  get tr() {
3188    return new wd(this);
3189  }
3190  static create(e) {
3191    let t = new ss(e.doc ? e.doc.type.schema : e.schema, e.plugins), r = new Rt(t);
3192    for (let s = 0; s < t.fields.length;
3192 s++) r[t.fields[s].name] = t.fields[s].init(e, r);
3193    return r;
3194  }
3195  reconfigure(e) {
3196    let t = new ss(this.schema, e.plugins), r = t.fields, s = new Rt(t);
3197    for (let i = 0; i < r.length; i++) {
3198      let o = r[i].name;
3199      s[o] = this.hasOwnProperty(o) ? this[o] : r[i].init(e, s);
3200    }
3201    return s;
3202  }
3203  toJSON(e) {
3204    let t = { doc: this.doc.toJSON(), selection: this.selection.toJSON() };
3205    if (this.storedMarks && (t.storedMarks = this.storedMarks.map((r) => r.toJSON())), e && typeof e == "object") for (let r in e) {
3206      if (r == "doc" || r == "selection") throw new RangeError("The JSON fields `doc` and `selection` are reserved");
3207      let s = e[r], i = s.spec.state;
3208      i && i.toJSON && (t[r] = i.toJSON.call(s, this[s.key]));
3209    }
3210    return t;
3211  }
3212  static fromJSON(e, t, r) {
3213    if (!t) throw new RangeError("Invalid input for EditorState.fromJSON");
3214    if (!e.schema) throw new RangeError("Required config field 'schema' missing");
3215    let s = new ss(e.schema, e.plugins), i = new Rt(s);
3216    return s.fields.forEach((o) => {
3217      if (o.name == "doc") i.doc = Ce.fromJSON(e.schema, t.doc);
3218      else if (o.name == "selection") i.selection = R.fromJSON(i.doc, t.selection);
3219      else if (o.name == "storedMarks") t.storedMarks && (i.storedMarks = t.storedMarks.map(e.schema.markFromJSON));
3220      else {
3221        if (r) for (let l in r) {
3222          let a = r[l], c = a.spec.state;
3223          if (a.key == o.name && c && c.fromJSON && Object.prototype.hasOwnProperty.call(t, l)) {
3224            i[o.name] = c.fromJSON.call(a, e, t[l], i);
3225            return;
3226          }
3227        }
3228        i[o.name] = o.init(e, i);
3229      }
3230    }), i;
3231  }
3232}
3233function ta(n2, e, t) {
3234  for (let r in n2) {
3235    let s = n2[r];
3236    s instanceof Function ? s = s.bind(e) : r == "handleDOMEvents" && (s = ta(s, e, {})), t[r] = s;
3237  }
3238  return t;
3239}
3240class F {
3241  constructor(e) {
3242    this.spec = e, this.props = {}, e.props && ta(e.props, this, this.props), this.key = e.key ? e.key.key : na("plugin");
3243  }
3244  getState(e) {
3245    return e[this.key];
3246  }
3247}
3248const is = /* @__PURE__ */ Object.create(null);
3249function na(n2) {
3250  return n2 in is ? n2 + "$" + ++is[n2] : (is[n2] = 0, n2 + "$");
3251}
3252class K {
3253  constructor(e = "key") {
3254    this.key = na(e);
3255  }
3256  get(e) {
3257    return e.config.pluginsByKey[this.key];
3258  }
3259  getState(e) {
3260    return e[this.key];
3261  }
3262}
3263const ii = (n2, e) => n2.selection.empty ? false : (e && e(n2.tr.deleteSelection().scrollIntoView()), true);
3264function ra(n2, e) {
3265  let { $cursor: t } = n2.selection;
3266  return !t || (e ? !e.endOfTextblock("backward", n2) : t.parentOffset > 0) ? null : t;
3267}
3268const sa = (n2, e, t) => {
3269  let r = ra(n2, t);
3270  if (!r) return false;
3271  let s = oi(r);
3272  if (!s) {
3273    let o = r.blockRange(), l = o && jt(o);
3274    return l == null ? false : (e && e(n2.tr.lift(o, l).scrollIntoView()), true);
3275  }
3276  let i = s.nodeBefore;
3277  if (ha(n2, s, e, -1)) return true;
3278  if (r.parent.content.size == 0 && (zt(i, "end") || T.isSelectable(i))) for (let o = r.depth; ; o--) {
3279    let l = Lr(n2.doc, r.before(o), r.after(o), w.empty);
3280    if (l && l.slice.size < l.to - l.from) {
3281      if (e) {
3282        let a = n2.tr.step(l);
3283        a.setSelection(zt(i, "end") ? R.findFrom(a.doc.resolve(a.mapping.map(s.pos, -1)), -1) : T.create(a.doc, s.pos - i.nodeSize)), e(a.scrollIntoView());
3284      }
3285      return true;
3286    }
3287    if (o == 1 || r.node(o - 1).childCount > 1) break;
3288  }
3289  return i.isAtom && s.depth == r.depth - 1 ? (e && e(n2.tr.delete(s.pos - i.nodeSize, s.pos).scrollIntoView()), true) : false;
3290}, Md = (n2, e, t) => {
3291  let r = ra(n2, t);
3292  if (!r) return false;
3293  let s = oi(r);
3294  return s ? ia(n2, s, e) : false;
3295}, vd = (n2, e, t) => {
3296  let r = la(n2, t);
3297  if (!r) return false;
3298  let s = li(r);
3299  return s ? ia(n2, s, e) : false;
3300};
3301function ia(n2, e, t) {
3302  let r = e.nodeBefore, s = r, i = e.pos - 1;
3303  for (; !s.isTextblock; i--) {
3304    if (s.type.spec.isolating) return false;
3305    let u = s.lastChild;
3306    if (!u) return false;
3307    s = u;
3308  }
3309  let o = e.nodeAfter, l = o, a = e.pos + 1;
3310  for (; !l.isTextblock; a++) {
3311    if (l.type.spec.isolating) return false;
3312    let u = l.firstChild;
3313    if (!u) return false;
3314    l = u;
3315  }
3316  let c = Lr(n2.doc, i, a, w.empty);
3317  if (!c || c.from != i || c instanceof q && c.slice.size >= a - i) return false;
3318  if (t) {
3319    let u = n2.tr.step(c);
3320    u.setSelection(I.create(u.doc, i)), t(u.scrollIntoView());
3321  }
3322  return true;
3323}
3324function zt(n2, e, t = false) {
3325  for (let r = n2; r; r = e == "start" ? r.firstChild : r.lastChild) {
3326    if (r.isTextblock) return true;
3327    if (t && r.childCount != 1) return false;
3328  }
3329  return false;
3330}
3331const oa = (n2, e, t) => {
3332  let { $head: r, empty: s } = n2.selection, i = r;
3333  if (!s) return false;
3334  if (r.parent.isTextblock) {
3335    if (t ? !t.endOfTextblock("backward", n2) : r.parentOffset > 0) return false;
3336    i = oi(r);
3337  }
3338  let o = i && i.nodeBefore;
3339  return !o || !T.isSelectable(o) ? false : (e && e(n2.tr.setSelection(T.create(n2.doc, i.pos - o.nodeSize)).scrollIntoView()), true);
3340};
3341function oi(n2) {
3342  if (!n2.parent.type.spec.isolating) for (let e = n2.depth - 1; e >= 0; e--) {
3343    if (n2.index(e) > 0) return n2.doc.resolve(n2.before(e + 1));
3344    if (n2.node(e).type.spec.isolating) break;
3345  }
3346  return null;
3347}
3348function la(n2, e) {
3349  let { $cursor: t } = n2.selection;
3350  return !t || (e ? !e.endOfTextblock("forward", n2) : t.parentOffset < t.parent.content.size) ? null : t;
3351}
3352const aa = (n2, e, t) => {
3353  let r = la(n2, t);
3354  if (!r) return false;
3355  let s = li(r);
3356  if (!s) return false;
3357  let i = s.nodeAfter;
3358  if (ha(n2, s, e, 1)) return true;
3359  if (r.parent.content.size == 0 && (zt(i, "start") || T.isSelectable(i))) {
3360    let o = Lr(n2.doc, r.before(), r.after(), w.empty);
3361    if (o && o.slice.size < o.to - o.from) {
3362      if (e) {
3363        let l = n2.tr.step(o);
3364        l.setSelection(zt(i, "start") ? R.findFrom(l.doc.resolve(l.mapping.map(s.pos)), 1) : T.create(l.doc, l.mapping.map(s.pos))), e(l.scrollIntoView());
3365      }
3366      return true;
3367    }
3368  }
3369  return i.isAtom && s.depth == r.depth - 1 ? (e && e(n2.tr.delete(s.pos, s.pos + i.nodeSize).scrollIntoView()), true) : false;
3370}, ca = (n2, e, t) => {
3371  let { $head: r, empty: s } = n2.selection, i = r;
3372  if (!s) return false;
3373  if (r.parent.isTextblock) {
3374    if (t ? !t.endOfTextblock("forward", n2) : r.parentOffset < r.parent.content.size) return false;
3375    i = li(r);
3376  }
3377  let o = i && i.nodeAfter;
3378  return !o || !T.isSelectable(o) ? false : (e && e(n2.tr.setSelection(T.create(n2.doc, i.pos)).scrollIntoView()), true);
3379};
3380function li(n2) {
3381  if (!n2.parent.type.spec.isolating) for (let e = n2.depth - 1; e >= 0; e--) {
3382    let t = n2.node(e);
3383    if (n2.index(e) + 1 < t.childCount) return n2.doc.resolve(n2.after(e + 1));
3384    if (t.type.spec.isolating) break;
3385  }
3386  return null;
3387}
3388const Td = (n2, e) => {
3389  let t = n2.selection, r = t instanceof T, s;
3390  if (r) {
3391    if (t.node.isTextblock || !st(n2.doc, t.from)) return false;
3392    s = t.from;
3393  } else if (s = Pr(n2.doc, t.from, -1), s == null) return false;
3394  if (e) {
3395    let i = n2.tr.join(s);
3396    r && i.setSelection(T.create(i.doc, s - n2.doc.resolve(s).nodeBefore.nodeSize)), e(i.scrollIntoView());
3397  }
3398  return true;
3399}, Ed = (n2, e) => {
3400  let t = n2.selection, r;
3401  if (t instanceof T) {
3402    if (t.node.isTextblock || !st(n2.doc, t.to)) return false;
3403    r = t.to;
3404  } else if (r = Pr(n2.doc, t.to, 1), r == null) return false;
3405  return e && e(n2.tr.join(r).scrollIntoView()), true;
3406}, Ad = (n2, e) => {
3407  let { $from: t, $to: r } = n2.selection, s = t.blockRange(r), i = s && jt(s);
3408  return i == null ? false : (e && e(n2.tr.lift(s, i).scrollIntoView()), true);
3409}, ua = (n2, e) => {
3410  let { $head: t, $anchor: r } = n2.selection;
3411  return !t.parent.type.spec.code || !t.sameParent(r) ? false : (e && e(n2.tr.insertText(`
3412`).scrollIntoView()), true);
3413};
3414function ai(n2) {
3415  for (let e = 0; e < n2.edgeCount; e++) {
3416    let { type: t } = n2.edge(e);
3417    if (t.isTextblock && !t.hasRequiredAttrs()) return t;
3418  }
3419  return null;
3420}
3421const Nd = (n2, e) => {
3422  let { $head: t, $anchor: r } = n2.selection;
3423  if (!t.parent.type.spec.code || !t.sameParent(r)) return false;
3424  let s = t.node(-1), i = t.indexAfter(-1), o = ai(s.contentMatchAt(i));
3425  if (!o || !s.canReplaceWith(i, i, o)) return false;
3426  if (e) {
3427    let l = t.after(), a = n2.tr.replaceWith(l, l, o.createAndFill());
3428    a.setSelection(R.near(a.doc.resolve(l), 1)), e(a.scrollIntoView());
3429  }
3430  return true;
3431}, da = (n2, e) => {
3432  let t = n2.selection, { $from: r, $to: s } = t;
3433  if (t instanceof de || r.parent.inlineContent || s.parent.inlineContent) return false;
3434  let i = ai(s.parent.contentMatchAt(s.indexAfter()));
3435  if (!i || !i.isTextblock) return false;
3436  if (e) {
3437    let o = (!r.parentOffset && s.index() < s.parent.childCount ? r : s).pos, l = n2.tr.insert(o, i.createAndFill());
3438    l.setSelection(I.create(l.doc, o + 1)), e(l.scrollIntoView());
3439  }
3440  return true;
3441}, fa = (n2, e) => {
3442  let { $cursor: t } = n2.selection;
3443  if (!t || t.parent.content.size) return false;
3444  if (t.depth > 1 && t.after() != t.end(-1)) {
3445    let i = t.before();
3446    if (Be(n2.doc, i)) return e && e(n2.tr.split(i).scrollIntoView()), true;
3447  }
3448  let r = t.blockRange(), s = r && jt(r);
3449  return s == null ? false : (e && e(n2.tr.lift(r, s).scrollIntoView()), true);
3450};
3451function Od(n2) {
3452  return (e, t) => {
3453    let { $from: r, $to: s } = e.selection;
3454    if (e.selection instanceof T && e.selection.node.isBlock) return !r.parentOffset || !Be(e.doc, r.pos) ? false : (t && t(e.tr.split(r.pos).scrollIntoView()), true);
3455    if (!r.depth) return false;
3456    let i = [], o, l, a = false, c = false;
3457    for (let h = r.depth; ; h--) if (r.node(h).isBlock) {
3458      a = r.end(h) == r.pos + (r.depth - h), c = r.start(h) == r.pos - (r.depth - h), l = ai(r.node(h - 1).contentMatchAt(r.indexAfter(h - 1))), i.unshift(a && l ? { type: l } : null), o = h;
3459      break;
3460    } else {
3461      if (h == 1) return false;
3462      i.unshift(null);
3463    }
3464    let u = e.tr;
3465    (e.selection instanceof I || e.selection instanceof de) && u.deleteSelection();
3466    let d = u.mapping.map(r.pos), f = Be(u.doc, d, i.length, i);
3467    if (f || (i[0] = l ? { type: l } : null, f = Be(u.doc, d, i.length, i)), !f) return false;
3468    if (u.split(d, i.length, i), !a && c && r.node(o).type != l) {
3469      let h = u.mapping.map(r.before(o)), p = u.doc.resolve(h);
3470      l && r.node(o - 1).canReplaceWith(p.index(), p.index() + 1, l) && u.setNodeMarkup(u.mapping.map(r.before(o)), l);
3471    }
3472    return t && t(u.scrollIntoView()), true;
3473  };
3474}
3475const Id = Od(), Dd = (n2, e) => {
3476  let { $from: t, to: r } = n2.selection, s, i = t.sharedDepth(r);
3477  return i == 0 ? false : (s = t.before(i), e && e(n2.tr.setSelection(T.create(n2.doc, s))), true);
3478};
3479function Rd(n2, e, t) {
3480  let r = e.nodeBefore, s = e.nodeAfter, i = e.index();
3481  return !r || !s || !r.type.compatibleContent(s.type) ? false : !r.content.size && e.parent.canReplace(i - 1, i) ? (t && t(n2.tr.delete(e.pos - r.nodeSize, e.pos).scrollIntoView()), true) : !e.parent.canReplace(i, i + 1) || !(s.isTextblock || st(n2.doc, e.pos)) ? false : (t && t(n2.tr.join(e.pos).scrollIntoView()), true);
3482}
3483function ha(n2, e, t, r) {
3484  let s = e.nodeBefore, i = e.nodeAfter, o, l, a = s.type.spec.isolating || i.type.spec.isolating;
3485  if (!a && Rd(n2, e, t)) return true;
3486  let c = !a && e.parent.canReplace(e.index(), e.index() + 1);
3487  if (c && (o = (l = s.contentMatchAt(s.childCount)).findWrapping(i.type)) && l.matchType(o[0] || i.type).validEnd) {
3488    if (t) {
3489      let h = e.pos + i.nodeSize, p = b.empty;
3490      for (let y = o.length - 1; y >= 0; y--) p = b.from(o[y].create(null, p));
3491      p = b.from(s.copy(p));
3492      let m = n2.tr.step(new J(e.pos - 1, h, e.pos, h, new w(p, 1, 0), o.length, true)), g = m.doc.resolve(h + 2 * o.length);
3493      g.nodeAfter && g.nodeAfter.type == s.type && st(m.doc, g.pos) && m.join(g.pos), t(m.scrollIntoView());
3494    }
3495    return true;
3496  }
3497  let u = i.type.spec.isolating || r > 0 && a ? null : R.findFrom(e, 1), d = u && u.$from.blockRange(u.$to), f = d && jt(d);
3498  if (f != null && f >= e.depth) return t && t(n2.tr.lift(d, f).scrollIntoView()), true;
3499  if (c && zt(i, "start", true) && zt(s, "end")) {
3500    let h = s, p = [];
3501    for (; p.push(h), !h.isTextblock; ) h = h.lastChild;
3502    let m = i, g = 1;
3503    for (; !m.isTextblock; m = m.firstChild) g++;
3504    if (h.canReplace(h.childCount, h.childCount, m.content)) {
3505      if (t) {
3506        let y = b.empty;
3507        for (let M = p.length - 1; M >= 0; M--) y = b.from(p[M].copy(y));
3508        let x = n2.tr.step(new J(e.pos - p.length, e.pos + i.nodeSize, e.pos + g, e.pos + i.nodeSize - g, new w(y, p.length, 0), 0, true));
3509        t(x.scrollIntoView());
3510      }
3511      return true;
3512    }
3513  }
3514  return false;
3515}
3516function pa(n2) {
3517  return function(e, t) {
3518    let r = e.selection, s = n2 < 0 ? r.$from : r.$to, i = s.depth;
3519    for (; s.node(i).isInline; ) {
3520      if (!i) return false;
3521      i--;
3522    }
3523    return s.node(i).isTextblock ? (t && t(e.tr.setSelection(I.create(e.doc, n2 < 0 ? s.start(i) : s.end(i)))), true) : false;
3524  };
3525}
3526const Pd = pa(-1), Ld = pa(1);
3527function Bd(n2, e = null) {
3528  return function(t, r) {
3529    let { $from: s, $to: i } = t.selection, o = s.blockRange(i), l = o && ri(o, n2, e);
3530    return l ? (r && r(t.tr.wrap(o, l).scrollIntoView()), true) : false;
3531  };
3532}
3533function fo(n2, e = null) {
3534  return function(t, r) {
3535    let s = false;
3536    for (let i = 0; i < t.selection.ranges.length && !s; i++) {
3537      let { $from: { pos: o }, $to: { pos: l } } = t.selection.ranges[i];
3538      t.doc.nodesBetween(o, l, (a, c) => {
3539        if (s) return false;
3540        if (!(!a.isTextblock || a.hasMarkup(n2, e))) if (a.type == n2) s = true;
3541        else {
3542          let u = t.doc.resolve(c), d = u.index();
3543          s = u.parent.canReplaceWith(d, d + 1, n2);
3544        }
3545      });
3546    }
3547    if (!s) return false;
3548    if (r) {
3549      let i = t.tr;
3550      for (let o = 0; o < t.selection.ranges.length; o++) {
3551        let { $from: { pos: l }, $to: { pos: a } } = t.selection.ranges[o];
3552        i.setBlockType(l, a, n2, e);
3553      }
3554      r(i.scrollIntoView());
3555    }
3556    return true;
3557  };
3558}
3559function ci(...n2) {
3560  return function(e, t, r) {
3561    for (let s = 0; s < n2.length; s++) if (n2[s](e, t, r)) return true;
3562    return false;
3563  };
3564}
3565ci(ii, sa, oa);
3566ci(ii, aa, ca);
3567ci(ua, da, fa, Id);
3568typeof navigator < "u" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : typeof os < "u" && os.platform && os.platform() == "darwin";
3569function zd(n2, e = null) {
3570  return function(t, r) {
3571    let { $from: s, $to: i } = t.selection, o = s.blockRange(i);
3572    if (!o) return false;
3573    let l = r ? t.tr : null;
3574    return $d(l, o, n2, e) ? (r && r(l.scrollIntoView()), true) : false;
3575  };
3576}
3577function $d(n2, e, t, r = null) {
3578  let s = false, i = e, o = e.$from.doc;
3579  if (e.depth >= 2 && e.$from.node(e.depth - 1).type.compatibleContent(t) && e.startIndex == 0) {
3580    if (e.$from.index(e.depth - 1) == 0) return false;
3581    let a = o.resolve(e.start - 2);
3582    i = new Jn(a, a, e.depth), e.endIndex < e.parent.childCount && (e = new Jn(e.$from, o.resolve(e.$to.end(e.depth)), e.depth)), s = true;
3583  }
3584  let l = ri(i, t, r, e);
3585  return l ? (n2 && Fd(n2, e, l, s, t), true) : false;
3586}
3587function Fd(n2, e, t, r, s) {
3588  let i = b.empty;
3589  for (let u = t.length - 1; u >= 0; u--) i = b.from(t[u].type.create(t[u].attrs, i));
3590  n2.step(new J(e.start - (r ? 2 : 0), e.end, e.start, e.end, new w(i, 0, 0), t.length, true));
3591  let o = 0;
3592  for (let u = 0; u < t.length; u++) t[u].type == s && (o = u + 1);
3593  let l = t.length - o, a = e.start + t.length - (r ? 2 : 0), c = e.parent;
3594  for (let u = e.startIndex, d = e.endIndex, f = true; u < d; u++, f = false) !f && Be(n2.doc, a, l) && (n2.split(a, l), a += 2 * l), a += c.child(u).nodeSize;
3595  return n2;
3596}
3597function Vd(n2) {
3598  return function(e, t) {
3599    let { $from: r, $to: s } = e.selection, i = r.blockRange(s, (o) => o.childCount > 0 && o.firstChild.type == n2);
3600    return i ? t ? r.node(i.depth - 1).type == n2 ? Hd(e, t, n2, i) : _d(e, t, i) : true : false;
3601  };
3602}
3603function Hd(n2, e, t, r) {
3604  let s = n2.tr, i = r.end, o = r.$to.end(r.depth);
3605  i < o && (s.step(new J(i - 1, o, i, o, new w(b.from(t.create(null, r.parent.copy())), 1, 0), 1, true)), r = new Jn(s.doc.resolve(r.$from.pos), s.doc.resolve(o), r.depth));
3606  const l = jt(r);
3607  if (l == null) return false;
3608  s.lift(r, l);
3609  let a = s.doc.resolve(s.mapping.map(i, -1) - 1);
3610  return st(s.doc, a.pos) && a.nodeBefore.type == a.nodeAfter.type && s.join(a.pos), e(s.scrollIntoView()), true;
3611}
3612function _d(n2, e, t) {
3613  let r = n2.tr, s = t.parent;
3614  for (let h = t.end, p = t.endIndex - 1, m = t.startIndex; p > m; p--) h -= s.child(p).nodeSize, r.delete(h - 1, h + 1);
3615  let i = r.doc.resolve(t.start), o = i.nodeAfter;
3616  if (r.mapping.map(t.end) != t.start + i.nodeAfter.nodeSize) return false;
3617  let l = t.startIndex == 0, a = t.endIndex == s.childCount, c = i.node(-1), u = i.index(-1);
3618  if (!c.canReplace(u + (l ? 0 : 1), u + 1, o.content.append(a ? b.empty : b.from(s)))) return false;
3619  let d = i.pos, f = d + o.nodeSize;
3620  return r.step(new J(d - (l ? 1 : 0), f + (a ? 1 : 0), d + 1, f - 1, new w((l ? b.empty : b.from(s.copy(b.empty))).append(a ? b.empty : b.from(s.copy(b.empty))), l ? 0 : 1, a ? 0 : 1), l ? 0 : 1)), e(r.scrollIntoView()), true;
3621}
3622function jd(n2) {
3623  return function(e, t) {
3624    let { $from: r, $to: s } = e.selection, i = r.blockRange(s, (c) => c.childCount > 0 && c.firstChild.type == n2);
3625    if (!i) return false;
3626    let o = i.startIndex;
3627    if (o == 0) return false;
3628    let l = i.parent, a = l.child(o - 1);
3629    if (a.type != n2) return false;
3630    if (t) {
3631      let c = a.lastChild && a.lastChild.type == l.type, u = b.from(c ? n2.create() : null), d = new w(b.from(n2.create(null, b.from(l.type.create(null, u)))), c ? 3 : 1, 0), f = i.start, h = i.end;
3632      t(e.tr.step(new J(f - (c ? 3 : 1), h, f, h, d, 1, true)).scrollIntoView());
3633    }
3634    return true;
3635  };
3636}
3637const X = function(n2) {
3638  for (var e = 0; ; e++) if (n2 = n2.previousSibling, !n2) return e;
3639}, $t = function(n2) {
3640  let e = n2.assignedSlot || n2.parentNode;
3641  return e && e.nodeType == 11 ? e.host : e;
3642};
3643let Os = null;
3644const Pe = function(n2, e, t) {
3645  let r = Os || (Os = document.createRange());
3646  return r.setEnd(n2, t ?? n2.nodeValue.length), r.setStart(n2, e || 0), r;
3647}, Wd = function() {
3648  Os = null;
3649}, wt = function(n2, e, t, r) {
3650  return t && (ho(n2, e, t, r, -1) || ho(n2, e, t, r, 1));
3651}, Ud = /^(img|br|input|textarea|hr)$/i;
3652function ho(n2, e, t, r, s) {
3653  for (var i; ; ) {
3654    if (n2 == t && e == r) return true;
3655    if (e == (s < 0 ? 0 : ye(n2))) {
3656      let o = n2.parentNode;
3657      if (!o || o.nodeType != 1 || Mn(n2) || Ud.test(n2.nodeName) || n2.contentEditable == "false") return false;
3658      e = X(n2) + (s < 0 ? 0 : 1), n2 = o;
3659    } else if (n2.nodeType == 1) {
3660      let o = n2.childNodes[e + (s < 0 ? -1 : 0)];
3661      if (o.nodeType == 1 && o.contentEditable == "false") if (!((i = o.pmViewDesc) === null || i === void 0) && i.ignoreForSelection) e += s;
3662      else return false;
3663      else n2 = o, e = s < 0 ? ye(n2) : 0;
3664    } else return false;
3665  }
3666}
3667function ye(n2) {
3668  return n2.nodeType == 3 ? n2.nodeValue.length : n2.childNodes.length;
3669}
3670function Kd(n2, e) {
3671  for (; ; ) {
3672    if (n2.nodeType == 3 && e) return n2;
3673    if (n2.nodeType == 1 && e > 0) {
3674      if (n2.contentEditable == "false") return null;
3675      n2 = n2.childNodes[e - 1], e = ye(n2);
3676    } else if (n2.parentNode && !Mn(n2)) e = X(n2), n2 = n2.parentNode;
3677    else return null;
3678  }
3679}
3680function qd(n2, e) {
3681  for (; ; ) {
3682    if (n2.nodeType == 3 && e < n2.nodeValue.length) return n2;
3683    if (n2.nodeType == 1 && e < n2.childNodes.length) {
3684      if (n2.contentEditable == "false") return null;
3685      n2 = n2.childNodes[e], e = 0;
3686    } else if (n2.parentNode && !Mn(n2)) e = X(n2) + 1, n2 = n2.parentNode;
3687    else return null;
3688  }
3689}
3690function Jd(n2, e, t) {
3691  for (let r = e == 0, s = e == ye(n2); r || s; ) {
3692    if (n2 == t) return true;
3693    let i = X(n2);
3694    if (n2 = n2.parentNode, !n2) return false;
3695    r = r && i == 0, s = s && i == ye(n2);
3696  }
3697}
3698function Mn(n2) {
3699  let e;
3700  for (let t = n2; t && !(e = t.pmViewDesc); t = t.parentNode) ;
3701  return e && e.node && e.node.isBlock && (e.dom == n2 || e.contentDOM == n2);
3702}
3703const zr = function(n2) {
3704  return n2.focusNode && wt(n2.focusNode, n2.focusOffset, n2.anchorNode, n2.anchorOffset);
3705};
3706function ut(n2, e) {
3707  let t = document.createEvent("Event");
3708  return t.initEvent("keydown", true, true), t.keyCode = n2, t.key = t.code = e, t;
3709}
3710function Gd(n2) {
3711  let e = n2.activeElement;
3712  for (; e && e.shadowRoot; ) e = e.shadowRoot.activeElement;
3713  return e;
3714}
3715function Yd(n2, e, t) {
3716  if (n2.caretPositionFromPoint) try {
3717    let r = n2.caretPositionFromPoint(e, t);
3718    if (r) return { node: r.offsetNode, offset: Math.min(ye(r.offsetNode), r.offset) };
3719  } catch {
3720  }
3721  if (n2.caretRangeFromPoint) {
3722    let r = n2.caretRangeFromPoint(e, t);
3723    if (r) return { node: r.startContainer, offset: Math.min(ye(r.startContainer), r.startOffset) };
3724  }
3725}
3726const Ee = typeof navigator < "u" ? navigator : null, po = typeof document < "u" ? document : null, it = Ee && Ee.userAgent || "", Is = /Edge\/(\d+)/.exec(it), ma = /MSIE \d/.exec(it), Ds = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(it), ce = !!(ma || Ds || Is), Ze = ma ? document.documentMode : Ds ? +Ds[1] : Is ? +Is[1] : 0, be = !ce && /gecko\/(\d+)/i.test(it);
3727be && +(/Firefox\/(\d+)/.exec(it) || [0, 0])[1];
3728const Rs = !ce && /Chrome\/(\d+)/.exec(it), ee = !!Rs, ga = Rs ? +Rs[1] : 0, ne = !ce && !!Ee && /Apple Computer/.test(Ee.vendor), Ft = ne && (/Mobile\/\w+/.test(it) || !!Ee && Ee.maxTouchPoints > 2), ge = Ft || (Ee ? /Mac/.test(Ee.platform) : false), ya = Ee ? /Win/.test(Ee.platform) : false, Le = /Android \d/.test(it), vn = !!po && "webkitFontSmoothing" in po.documentElement.style, Qd = vn ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
3729function Xd(n2) {
vendor: 11,061 bytes, lines 3730-3983
3730  let e = n2.defaultView && n2.defaultView.visualViewport;
3731  return e ? { left: 0, right: e.width, top: 0, bottom: e.height } : { left: 0, right: n2.documentElement.clientWidth, top: 0, bottom: n2.documentElement.clientHeight };
3732}
3733function Oe(n2, e) {
3734  return typeof n2 == "number" ? n2 : n2[e];
3735}
3736function Zd(n2) {
3737  let e = n2.getBoundingClientRect(), t = e.width / n2.offsetWidth || 1, r = e.height / n2.offsetHeight || 1;
3738  return { left: e.left, right: e.left + n2.clientWidth * t, top: e.top, bottom: e.top + n2.clientHeight * r };
3739}
3740function mo(n2, e, t) {
3741  let r = n2.someProp("scrollThreshold") || 0, s = n2.someProp("scrollMargin") || 5, i = n2.dom.ownerDocument;
3742  for (let o = t || n2.dom; o; ) {
3743    if (o.nodeType != 1) {
3744      o = $t(o);
3745      continue;
3746    }
3747    let l = o, a = l == i.body, c = a ? Xd(i) : Zd(l), u = 0, d = 0;
3748    if (e.top < c.top + Oe(r, "top") ? d = -(c.top - e.top + Oe(s, "top")) : e.bottom > c.bottom - Oe(r, "bottom") && (d = e.bottom - e.top > c.bottom - c.top ? e.top + Oe(s, "top") - c.top : e.bottom - c.bottom + Oe(s, "bottom")), e.left < c.left + Oe(r, "left") ? u = -(c.left - e.left + Oe(s, "left")) : e.right > c.right - Oe(r, "right") && (u = e.right - c.right + Oe(s, "right")), u || d) if (a) i.defaultView.scrollBy(u, d);
3749    else {
3750      let h = l.scrollLeft, p = l.scrollTop;
3751      d && (l.scrollTop += d), u && (l.scrollLeft += u);
3752      let m = l.scrollLeft - h, g = l.scrollTop - p;
3753      e = { left: e.left - m, top: e.top - g, right: e.right - m, bottom: e.bottom - g };
3754    }
3755    let f = a ? "fixed" : getComputedStyle(o).position;
3756    if (/^(fixed|sticky)$/.test(f)) break;
3757    o = f == "absolute" ? o.offsetParent : $t(o);
3758  }
3759}
3760function ef(n2) {
3761  let e = n2.dom.getBoundingClientRect(), t = Math.max(0, e.top), r, s;
3762  for (let i = (e.left + e.right) / 2, o = t + 1; o < Math.min(innerHeight, e.bottom); o += 5) {
3763    let l = n2.root.elementFromPoint(i, o);
3764    if (!l || l == n2.dom || !n2.dom.contains(l)) continue;
3765    let a = l.getBoundingClientRect();
3766    if (a.top >= t - 20) {
3767      r = l, s = a.top;
3768      break;
3769    }
3770  }
3771  return { refDOM: r, refTop: s, stack: ba(n2.dom) };
3772}
3773function ba(n2) {
3774  let e = [], t = n2.ownerDocument;
3775  for (let r = n2; r && (e.push({ dom: r, top: r.scrollTop, left: r.scrollLeft }), n2 != t); r = $t(r)) ;
3776  return e;
3777}
3778function tf({ refDOM: n2, refTop: e, stack: t }) {
3779  let r = n2 ? n2.getBoundingClientRect().top : 0;
3780  ka(t, r == 0 ? 0 : r - e);
3781}
3782function ka(n2, e) {
3783  for (let t = 0; t < n2.length; t++) {
3784    let { dom: r, top: s, left: i } = n2[t];
3785    r.scrollTop != s + e && (r.scrollTop = s + e), r.scrollLeft != i && (r.scrollLeft = i);
3786  }
3787}
3788let At = null;
3789function nf(n2) {
3790  if (n2.setActive) return n2.setActive();
3791  if (At) return n2.focus(At);
3792  let e = ba(n2);
3793  n2.focus(At == null ? { get preventScroll() {
3794    return At = { preventScroll: true }, true;
3795  } } : void 0), At || (At = false, ka(e, 0));
3796}
3797function xa(n2, e) {
3798  let t, r = 2e8, s, i = 0, o = e.top, l = e.top, a, c;
3799  for (let u = n2.firstChild, d = 0; u; u = u.nextSibling, d++) {
3800    let f;
3801    if (u.nodeType == 1) f = u.getClientRects();
3802    else if (u.nodeType == 3) f = Pe(u).getClientRects();
3803    else continue;
3804    for (let h = 0; h < f.length; h++) {
3805      let p = f[h];
3806      if (p.top <= o && p.bottom >= l) {
3807        o = Math.max(p.bottom, o), l = Math.min(p.top, l);
3808        let m = p.left > e.left ? p.left - e.left : p.right < e.left ? e.left - p.right : 0;
3809        if (m < r) {
3810          t = u, r = m, s = m && t.nodeType == 3 ? { left: p.right < e.left ? p.right : p.left, top: e.top } : e, u.nodeType == 1 && m && (i = d + (e.left >= (p.left + p.right) / 2 ? 1 : 0));
3811          continue;
3812        }
3813      } else p.top > e.top && !a && p.left <= e.left && p.right >= e.left && (a = u, c = { left: Math.max(p.left, Math.min(p.right, e.left)), top: p.top });
3814      !t && (e.left >= p.right && e.top >= p.top || e.left >= p.left && e.top >= p.bottom) && (i = d + 1);
3815    }
3816  }
3817  return !t && a && (t = a, s = c, r = 0), t && t.nodeType == 3 ? rf(t, s) : !t || r && t.nodeType == 1 ? { node: n2, offset: i } : xa(t, s);
3818}
3819function rf(n2, e) {
3820  let t = n2.nodeValue.length, r = document.createRange(), s;
3821  for (let i = 0; i < t; i++) {
3822    r.setEnd(n2, i + 1), r.setStart(n2, i);
3823    let o = je(r, 1);
3824    if (o.top != o.bottom && ui(e, o)) {
3825      s = { node: n2, offset: i + (e.left >= (o.left + o.right) / 2 ? 1 : 0) };
3826      break;
3827    }
3828  }
3829  return r.detach(), s || { node: n2, offset: 0 };
3830}
3831function ui(n2, e) {
3832  return n2.left >= e.left - 1 && n2.left <= e.right + 1 && n2.top >= e.top - 1 && n2.top <= e.bottom + 1;
3833}
3834function sf(n2, e) {
3835  let t = n2.parentNode;
3836  return t && /^li$/i.test(t.nodeName) && e.left < n2.getBoundingClientRect().left ? t : n2;
3837}
3838function of(n2, e, t) {
3839  let { node: r, offset: s } = xa(e, t), i = -1;
3840  if (r.nodeType == 1 && !r.firstChild) {
3841    let o = r.getBoundingClientRect();
3842    i = o.left != o.right && t.left > (o.left + o.right) / 2 ? 1 : -1;
3843  }
3844  return n2.docView.posFromDOM(r, s, i);
3845}
3846function lf(n2, e, t, r) {
3847  let s = -1;
3848  for (let i = e, o = false; i != n2.dom; ) {
3849    let l = n2.docView.nearestDesc(i, true), a;
3850    if (!l) return null;
3851    if (l.dom.nodeType == 1 && (l.node.isBlock && l.parent || !l.contentDOM) && ((a = l.dom.getBoundingClientRect()).width || a.height) && (l.node.isBlock && l.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName) && (!o && a.left > r.left || a.top > r.top ? s = l.posBefore : (!o && a.right < r.left || a.bottom < r.top) && (s = l.posAfter), o = true), !l.contentDOM && s < 0 && !l.node.isText)) return (l.node.isBlock ? r.top < (a.top + a.bottom) / 2 : r.left < (a.left + a.right) / 2) ? l.posBefore : l.posAfter;
3852    i = l.dom.parentNode;
3853  }
3854  return s > -1 ? s : n2.docView.posFromDOM(e, t, -1);
3855}
3856function Sa(n2, e, t) {
3857  let r = n2.childNodes.length;
3858  if (r && t.top < t.bottom) for (let s = Math.max(0, Math.min(r - 1, Math.floor(r * (e.top - t.top) / (t.bottom - t.top)) - 2)), i = s; ; ) {
3859    let o = n2.childNodes[i];
3860    if (o.nodeType == 1) {
3861      let l = o.getClientRects();
3862      for (let a = 0; a < l.length; a++) {
3863        let c = l[a];
3864        if (ui(e, c)) return Sa(o, e, c);
3865      }
3866    }
3867    if ((i = (i + 1) % r) == s) break;
3868  }
3869  return n2;
3870}
3871function af(n2, e) {
3872  let t = n2.dom.ownerDocument, r, s = 0, i = Yd(t, e.left, e.top);
3873  i && ({ node: r, offset: s } = i);
3874  let o = (n2.root.elementFromPoint ? n2.root : t).elementFromPoint(e.left, e.top), l;
3875  if (!o || !n2.dom.contains(o.nodeType != 1 ? o.parentNode : o)) {
3876    let c = n2.dom.getBoundingClientRect();
3877    if (!ui(e, c) || (o = Sa(n2.dom, e, c), !o)) return null;
3878  }
3879  if (ne) for (let c = o; r && c; c = $t(c)) c.draggable && (r = void 0);
3880  if (o = sf(o, e), r) {
3881    if (be && r.nodeType == 1 && (s = Math.min(s, r.childNodes.length), s < r.childNodes.length)) {
3882      let u = r.childNodes[s], d;
3883      u.nodeName == "IMG" && (d = u.getBoundingClientRect()).right <= e.left && d.bottom > e.top && s++;
3884    }
3885    let c;
3886    vn && s && r.nodeType == 1 && (c = r.childNodes[s - 1]).nodeType == 1 && c.contentEditable == "false" && c.getBoundingClientRect().top >= e.top && s--, r == n2.dom && s == r.childNodes.length - 1 && r.lastChild.nodeType == 1 && e.top > r.lastChild.getBoundingClientRect().bottom ? l = n2.state.doc.content.size : (s == 0 || r.nodeType != 1 || r.childNodes[s - 1].nodeName != "BR") && (l = lf(n2, r, s, e));
3887  }
3888  l == null && (l = of(n2, o, e));
3889  let a = n2.docView.nearestDesc(o, true);
3890  return { pos: l, inside: a ? a.posAtStart - a.border : -1 };
3891}
3892function go(n2) {
3893  return n2.top < n2.bottom || n2.left < n2.right;
3894}
3895function je(n2, e) {
3896  let t = n2.getClientRects();
3897  if (t.length) {
3898    let r = t[e < 0 ? 0 : t.length - 1];
3899    if (go(r)) return r;
3900  }
3901  return Array.prototype.find.call(t, go) || n2.getBoundingClientRect();
3902}
3903const cf = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
3904function wa(n2, e, t) {
3905  let { node: r, offset: s, atom: i } = n2.docView.domFromPos(e, t < 0 ? -1 : 1), o = vn || be;
3906  if (r.nodeType == 3) if (o && (cf.test(r.nodeValue) || (t < 0 ? !s : s == r.nodeValue.length))) {
3907    let a = je(Pe(r, s, s), t);
3908    if (be && s && /\s/.test(r.nodeValue[s - 1]) && s < r.nodeValue.length) {
3909      let c = je(Pe(r, s - 1, s - 1), -1);
3910      if (c.top == a.top) {
3911        let u = je(Pe(r, s, s + 1), -1);
3912        if (u.top != a.top) return Kt(u, u.left < c.left);
3913      }
3914    }
3915    return a;
3916  } else {
3917    let a = s, c = s, u = t < 0 ? 1 : -1;
3918    return t < 0 && !s ? (c++, u = -1) : t >= 0 && s == r.nodeValue.length ? (a--, u = 1) : t < 0 ? a-- : c++, Kt(je(Pe(r, a, c), u), u < 0);
3919  }
3920  if (!n2.state.doc.resolve(e - (i || 0)).parent.inlineContent) {
3921    if (i == null && s && (t < 0 || s == ye(r))) {
3922      let a = r.childNodes[s - 1];
3923      if (a.nodeType == 1) return ls(a.getBoundingClientRect(), false);
3924    }
3925    if (i == null && s < ye(r)) {
3926      let a = r.childNodes[s];
3927      if (a.nodeType == 1) return ls(a.getBoundingClientRect(), true);
3928    }
3929    return ls(r.getBoundingClientRect(), t >= 0);
3930  }
3931  if (i == null && s && (t < 0 || s == ye(r))) {
3932    let a = r.childNodes[s - 1], c = a.nodeType == 3 ? Pe(a, ye(a) - (o ? 0 : 1)) : a.nodeType == 1 && (a.nodeName != "BR" || !a.nextSibling) ? a : null;
3933    if (c) return Kt(je(c, 1), false);
3934  }
3935  if (i == null && s < ye(r)) {
3936    let a = r.childNodes[s];
3937    for (; a.pmViewDesc && a.pmViewDesc.ignoreForCoords; ) a = a.nextSibling;
3938    let c = a ? a.nodeType == 3 ? Pe(a, 0, o ? 0 : 1) : a.nodeType == 1 ? a : null : null;
3939    if (c) return Kt(je(c, -1), true);
3940  }
3941  return Kt(je(r.nodeType == 3 ? Pe(r) : r, -t), t >= 0);
3942}
3943function Kt(n2, e) {
3944  if (n2.width == 0) return n2;
3945  let t = e ? n2.left : n2.right;
3946  return { top: n2.top, bottom: n2.bottom, left: t, right: t };
3947}
3948function ls(n2, e) {
3949  if (n2.height == 0) return n2;
3950  let t = e ? n2.top : n2.bottom;
3951  return { top: t, bottom: t, left: n2.left, right: n2.right };
3952}
3953function Ca(n2, e, t) {
3954  let r = n2.state, s = n2.root.activeElement;
3955  r != e && n2.updateState(e), s != n2.dom && n2.focus();
3956  try {
3957    return t();
3958  } finally {
3959    r != e && n2.updateState(r), s != n2.dom && s && s.focus();
3960  }
3961}
3962function uf(n2, e, t) {
3963  let r = e.selection, s = t == "up" ? r.$from : r.$to;
3964  return Ca(n2, e, () => {
3965    let { node: i } = n2.docView.domFromPos(s.pos, t == "up" ? -1 : 1);
3966    for (; ; ) {
3967      let l = n2.docView.nearestDesc(i, true);
3968      if (!l) break;
3969      if (l.node.isBlock) {
3970        i = l.contentDOM || l.dom;
3971        break;
3972      }
3973      i = l.dom.parentNode;
3974    }
3975    let o = wa(n2, s.pos, 1);
3976    for (let l = i.firstChild; l; l = l.nextSibling) {
3977      let a;
3978      if (l.nodeType == 1) a = l.getClientRects();
3979      else if (l.nodeType == 3) a = Pe(l, 0, l.nodeValue.length).getClientRects();
3980      else continue;
3981      for (let c = 0; c < a.length; c++) {
3982        let u = a[c];
3983        if (u.bottom > u.top + 1 && (t == "up" ? o.top - u.top > (u.bottom - o.top) * 2 : u.bottom - o.bottom > (o.bottom - u.top) * 2)) return false;
3984      }
3985    }
3986    return true;
3987  });
3988}
3989const df = /[\u0590-\u08ac]/;
3990function ff(n2, e, t) {
3991  let { $head: r } = e.selection;
3992  if (!r.parent.isTextblock) return false;
3993  let s = r.parentOffset, i = !s, o = s == r.parent.content.size, l = n2.domSelection();
3994  return l ? !df.test(r.parent.textContent) || !l.modify ? t == "left" || t == "backward" ? i : o : Ca(n2, e, () => {
3995    let { focusNode: a, focusOffset: c, anchorNode: u, anchorOffset: d } = n2.domSelectionRange(), f = l.caretBidiLevel;
3996    l.modify("move", t, "character");
3997    let h = r.depth ? n2.docView.domAfterPos(r.before()) : n2.dom, { focusNode: p, focusOffset: m } = n2.domSelectionRange(), g = p && !h.contains(p.nodeType == 1 ? p : p.parentNode) || a == p && c == m;
3998    try {
3999      l.collapse(u, d), a && (a != u || c != d) && l.extend && l.extend(a, c);
4000    } catch {
4001    }
4002    return f != null && (l.caretBidiLevel = f), g;
4003  }) : r.pos == r.start() || r.pos == r.end();
4004}
4005let yo = null, bo = null, ko = false;
4006function hf(n2, e, t) {
4007  return yo == e && bo == t ? ko : (yo = e, bo = t, ko = t == "up" || t == "down" ? uf(n2, e, t) : ff(n2, e, t));
4008}
4009const ke = 0, xo = 1, dt = 2, Ae = 3;
4010class Tn {
4011  constructor(e, t, r, s) {
4012    this.parent = e, this.children = t, this.dom = r, this.contentDOM = s, this.dirty = ke, r.pmViewDesc = this;
4013  }
4014  matchesWidget(e) {
4015    return false;
4016  }
4017  matchesMark(e) {
4018    return false;
4019  }
4020  matchesNode(e, t, r) {
4021    return false;
4022  }
4023  matchesHack(e) {
4024    return false;
4025  }
4026  parseRule() {
4027    return null;
4028  }
4029  stopEvent(e) {
4030    return false;
4031  }
4032  get size() {
4033    let e = 0;
4034    for (let t = 0; t < this.children.length; t++) e += this.children[t].size;
4035    return e;
4036  }
4037  get border() {
4038    return 0;
4039  }
4040  destroy() {
4041    this.parent = void 0, this.dom.pmViewDesc == this && (this.dom.pmViewDesc = void 0);
4042    for (let e = 0; e < this.children.length; e++) this.children[e].destroy();
4043  }
4044  posBeforeChild(e) {
4045    for (let t = 0, r = this.posAtStart; ; t++) {
4046      let s = this.children[t];
4047      if (s == e) return r;
4048      r += s.size;
4049    }
4050  }
4051  get posBefore() {
4052    return this.parent.posBeforeChild(this);
4053  }
4054  get posAtStart() {
4055    return this.parent ? this.parent.posBeforeChild(this) + this.border : 0;
4056  }
4057  get posAfter() {
4058    return this.posBefore + this.size;
4059  }
4060  get posAtEnd() {
4061    return this.posAtStart + this.size - 2 * this.border;
4062  }
4063  localPosFromDOM(e, t, r) {
4064    if (this.contentDOM && this.contentDOM.contains(e.nodeType == 1 ? e : e.parentNode)) if (r < 0) {
4065      let i, o;
4066      if (e == this.contentDOM) i = e.childNodes[t - 1];
4067      else {
4068        for (; e.parentNode != this.contentDOM; ) e = e.parentNode;
4069        i = e.previousSibling;
4070      }
4071      for (; i && !((o = i.pmViewDesc) && o.parent == this); ) i = i.previousSibling;
4072      return i ? this.posBeforeChild(o) + o.size : this.posAtStart;
4073    } else {
4074      let i, o;
4075      if (e == this.contentDOM) i = e.childNodes[t];
4076      else {
4077        for (; e.parentNode != this.contentDOM; ) e = e.parentNode;
4078        i = e.nextSibling;
4079      }
4080      for (; i && !((o = i.pmViewDesc) && o.parent == this); ) i = i.nextSibling;
4081      return i ? this.posBeforeChild(o) : this.posAtEnd;
4082    }
4083    let s;
4084    if (e == this.dom && this.contentDOM) s = t > X(this.contentDOM);
4085    else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) s = e.compareDocumentPosition(this.contentDOM) & 2;
4086    else if (this.dom.firstChild) {
4087      if (t == 0) for (let i = e; ; i = i.parentNode) {
4088        if (i == this.dom) {
4089          s = false;
4090          break;
4091        }
4092        if (i.previousSibling) break;
4093      }
4094      if (s == null && t == e.childNodes.length) for (let i = e; ; i = i.parentNode) {
4095        if (i == this.dom) {
4096          s = true;
4097          break;
4098        }
4099        if (i.nextSibling) break;
4100      }
4101    }
4102    return s ?? r > 0 ? this.posAtEnd : this.posAtStart;
4103  }
4104  nearestDesc(e, t = false) {
4105    for (let r = true, s = e; s; s = s.parentNode) {
4106      let i = this.getDesc(s), o;
4107      if (i && (!t || i.node)) if (r && (o = i.nodeDOM) && !(o.nodeType == 1 ? o.contains(e.nodeType == 1 ? e : e.parentNode) : o == e)) r = false;
vendor: 4,107 bytes, lines 4108-4215
4108      else return i;
4109    }
4110  }
4111  getDesc(e) {
4112    let t = e.pmViewDesc;
4113    for (let r = t; r; r = r.parent) if (r == this) return t;
4114  }
4115  posFromDOM(e, t, r) {
4116    for (let s = e; s; s = s.parentNode) {
4117      let i = this.getDesc(s);
4118      if (i) return i.localPosFromDOM(e, t, r);
4119    }
4120    return -1;
4121  }
4122  descAt(e) {
4123    for (let t = 0, r = 0; t < this.children.length; t++) {
4124      let s = this.children[t], i = r + s.size;
4125      if (r == e && i != r) {
4126        for (; !s.border && s.children.length; ) for (let o = 0; o < s.children.length; o++) {
4127          let l = s.children[o];
4128          if (l.size) {
4129            s = l;
4130            break;
4131          }
4132        }
4133        return s;
4134      }
4135      if (e < i) return s.descAt(e - r - s.border);
4136      r = i;
4137    }
4138  }
4139  domFromPos(e, t) {
4140    if (!this.contentDOM) return { node: this.dom, offset: 0, atom: e + 1 };
4141    let r = 0, s = 0;
4142    for (let i = 0; r < this.children.length; r++) {
4143      let o = this.children[r], l = i + o.size;
4144      if (l > e || o instanceof va) {
4145        s = e - i;
4146        break;
4147      }
4148      i = l;
4149    }
4150    if (s) return this.children[r].domFromPos(s - this.children[r].border, t);
4151    for (let i; r && !(i = this.children[r - 1]).size && i instanceof Ma && i.side >= 0; r--) ;
4152    if (t <= 0) {
4153      let i, o = true;
4154      for (; i = r ? this.children[r - 1] : null, !(!i || i.dom.parentNode == this.contentDOM); r--, o = false) ;
4155      return i && t && o && !i.border && !i.domAtom ? i.domFromPos(i.size, t) : { node: this.contentDOM, offset: i ? X(i.dom) + 1 : 0 };
4156    } else {
4157      let i, o = true;
4158      for (; i = r < this.children.length ? this.children[r] : null, !(!i || i.dom.parentNode == this.contentDOM); r++, o = false) ;
4159      return i && o && !i.border && !i.domAtom ? i.domFromPos(0, t) : { node: this.contentDOM, offset: i ? X(i.dom) : this.contentDOM.childNodes.length };
4160    }
4161  }
4162  parseRange(e, t, r = 0) {
4163    if (this.children.length == 0) return { node: this.contentDOM, from: e, to: t, fromOffset: 0, toOffset: this.contentDOM.childNodes.length };
4164    let s = -1, i = -1;
4165    for (let o = r, l = 0; ; l++) {
4166      let a = this.children[l], c = o + a.size;
4167      if (s == -1 && e <= c) {
4168        let u = o + a.border;
4169        if (e >= u && t <= c - a.border && a.node && a.contentDOM && this.contentDOM.contains(a.contentDOM)) return a.parseRange(e, t, u);
4170        e = o;
4171        for (let d = l; d > 0; d--) {
4172          let f = this.children[d - 1];
4173          if (f.size && f.dom.parentNode == this.contentDOM && !f.emptyChildAt(1)) {
4174            s = X(f.dom) + 1;
4175            break;
4176          }
4177          e -= f.size;
4178        }
4179        s == -1 && (s = 0);
4180      }
4181      if (s > -1 && (c > t || l == this.children.length - 1)) {
4182        t = c;
4183        for (let u = l + 1; u < this.children.length; u++) {
4184          let d = this.children[u];
4185          if (d.size && d.dom.parentNode == this.contentDOM && !d.emptyChildAt(-1)) {
4186            i = X(d.dom);
4187            break;
4188          }
4189          t += d.size;
4190        }
4191        i == -1 && (i = this.contentDOM.childNodes.length);
4192        break;
4193      }
4194      o = c;
4195    }
4196    return { node: this.contentDOM, from: e, to: t, fromOffset: s, toOffset: i };
4197  }
4198  emptyChildAt(e) {
4199    if (this.border || !this.contentDOM || !this.children.length) return false;
4200    let t = this.children[e < 0 ? 0 : this.children.length - 1];
4201    return t.size == 0 || t.emptyChildAt(e);
4202  }
4203  domAfterPos(e) {
4204    let { node: t, offset: r } = this.domFromPos(e, 0);
4205    if (t.nodeType != 1 || r == t.childNodes.length) throw new RangeError("No node after pos " + e);
4206    return t.childNodes[r];
4207  }
4208  setSelection(e, t, r, s = false) {
4209    let i = Math.min(e, t), o = Math.max(e, t);
4210    for (let h = 0, p = 0; h < this.children.length; h++) {
4211      let m = this.children[h], g = p + m.size;
4212      if (i > p && o < g) return m.setSelection(e - p - m.border, t - p - m.border, r, s);
4213      p = g;
4214    }
4215    let l = this.domFromPos(e, e ? -1 : 1), a = t == e ? l : this.domFromPos(t, t ? -1 : 1), c = r.root.getSelection(), u = r.domSelectionRange(), d = false;
4216    if ((be || ne) && e == t) {
4217      let { node: h, offset: p } = l;
4218      if (h.nodeType == 3) {
4219        if (d = !!(p && h.nodeValue[p - 1] == `
4220`), d && p == h.nodeValue.length) for (let m = h, g; m; m = m.parentNode) {
4221          if (g = m.nextSibling) {
4222            g.nodeName == "BR" && (l = a = { node: g.parentNode, offset: X(g) + 1 });
4223            break;
4224          }
4225          let y = m.pmViewDesc;
4226          if (y && y.node && y.node.isBlock) break;
4227        }
4228      } else {
4229        let m = h.childNodes[p - 1];
4230        d = m && (m.nodeName == "BR" || m.contentEditable == "false");
4231      }
4232    }
4233    if (be && u.focusNode && u.focusNode != a.node && u.focusNode.nodeType == 1) {
4234      let h = u.focusNode.childNodes[u.focusOffset];
4235      h && h.contentEditable == "false" && (s = true);
4236    }
4237    if (!(s || d && ne) && wt(l.node, l.offset, u.anchorNode, u.anchorOffset) && wt(a.node, a.offset, u.focusNode, u.focusOffset)) return;
4238    let f = false;
4239    if ((c.extend || e == t) && !(d && be)) {
4240      c.collapse(l.node, l.offset);
4241      try {
4242        e != t && c.extend(a.node, a.offset), f = true;
4243      } catch {
4244      }
4245    }
4246    if (!f) {
4247      if (e > t) {
4248        let p = l;
4249        l = a, a = p;
4250      }
4251      let h = document.createRange();
4252      h.setEnd(a.node, a.offset), h.setStart(l.node, l.offset), c.removeAllRanges(), c.addRange(h);
4253    }
4254  }
4255  ignoreMutation(e) {
4256    return !this.contentDOM && e.type != "selection";
4257  }
4258  get contentLost() {
4259    return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM);
4260  }
4261  markDirty(e, t) {
4262    for (let r = 0, s = 0; s < this.children.length; s++) {
4263      let i = this.children[s], o = r + i.size;
4264      if (r == o ? e <= o && t >= r : e < o && t > r) {
4265        let l = r + i.border, a = o - i.border;
4266        if (e >= l && t <= a) {
4267          this.dirty = e == r || t == o ? dt : xo, e == l && t == a && (i.contentLost || i.dom.parentNode != this.contentDOM) ? i.dirty = Ae : i.markDirty(e - l, t - l);
4268          return;
4269        } else i.dirty = i.dom == i.contentDOM && i.dom.parentNode == this.contentDOM && !i.children.length ? dt : Ae;
4270      }
4271      r = o;
4272    }
4273    this.dirty = dt;
4274  }
4275  markParentsDirty() {
4276    let e = 1;
4277    for (let t = this.parent; t; t = t.parent, e++) {
4278      let r = e == 1 ? dt : xo;
4279      t.dirty < r && (t.dirty = r);
4280    }
4281  }
4282  get domAtom() {
4283    return false;
4284  }
4285  get ignoreForCoords() {
4286    return false;
4287  }
4288  get ignoreForSelection() {
4289    return false;
4290  }
4291  isText(e) {
4292    return false;
4293  }
4294}
4295class Ma extends Tn {
4296  constructor(e, t, r, s) {
4297    let i, o = t.type.toDOM;
4298    if (typeof o == "function" && (o = o(r, () => {
4299      if (!i) return s;
4300      if (i.parent) return i.parent.posBeforeChild(i);
4301    })), !t.type.spec.raw) {
4302      if (o.nodeType != 1) {
4303        let l = document.createElement("span");
4304        l.appendChild(o), o = l;
4305      }
4306      o.contentEditable = "false", o.classList.add("ProseMirror-widget");
4307    }
4308    super(e, [], o, null), this.widget = t, this.widget = t, i = this;
4309  }
4310  matchesWidget(e) {
4311    return this.dirty == ke && e.type.eq(this.widget.type);
4312  }
4313  parseRule() {
4314    return { ignore: true };
4315  }
4316  stopEvent(e) {
4317    let t = this.widget.spec.stopEvent;
4318    return t ? t(e) : false;
4319  }
4320  ignoreMutation(e) {
4321    return e.type != "selection" || this.widget.spec.ignoreSelection;
4322  }
4323  destroy() {
4324    this.widget.type.destroy(this.dom), super.destroy();
4325  }
4326  get domAtom() {
4327    return true;
4328  }
4329  get ignoreForSelection() {
4330    return !!this.widget.type.spec.relaxedSide;
4331  }
4332  get side() {
4333    return this.widget.type.side;
4334  }
4335}
4336class pf extends Tn {
4337  constructor(e, t, r, s) {
4338    super(e, [], t, null), this.textDOM = r, this.text = s;
4339  }
4340  get size() {
4341    return this.text.length;
4342  }
4343  localPosFromDOM(e, t) {
4344    return e != this.textDOM ? this.posAtStart + (t ? this.size : 0) : this.posAtStart + t;
4345  }
4346  domFromPos(e) {
4347    return { node: this.textDOM, offset: e };
4348  }
4349  ignoreMutation(e) {
4350    return e.type === "characterData" && e.target.nodeValue == e.oldValue;
4351  }
4352}
4353class Ct extends Tn {
4354  constructor(e, t, r, s, i) {
4355    super(e, [], r, s), this.mark = t, this.spec = i;
4356  }
4357  static create(e, t, r, s) {
vendor: 5,673 bytes, lines 4358-4470
4358    let i = s.nodeViews[t.type.name], o = i && i(t, s, r);
4359    return (!o || !o.dom) && (o = Mt.renderSpec(document, t.type.spec.toDOM(t, r), null, t.attrs)), new Ct(e, t, o.dom, o.contentDOM || o.dom, o);
4360  }
4361  parseRule() {
4362    return this.dirty & Ae || this.mark.type.spec.reparseInView ? null : { mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM };
4363  }
4364  matchesMark(e) {
4365    return this.dirty != Ae && this.mark.eq(e);
4366  }
4367  markDirty(e, t) {
4368    if (super.markDirty(e, t), this.dirty != ke) {
4369      let r = this.parent;
4370      for (; !r.node; ) r = r.parent;
4371      r.dirty < this.dirty && (r.dirty = this.dirty), this.dirty = ke;
4372    }
4373  }
4374  slice(e, t, r) {
4375    let s = Ct.create(this.parent, this.mark, true, r), i = this.children, o = this.size;
4376    t < o && (i = Ls(i, t, o, r)), e > 0 && (i = Ls(i, 0, e, r));
4377    for (let l = 0; l < i.length; l++) i[l].parent = s;
4378    return s.children = i, s;
4379  }
4380  ignoreMutation(e) {
4381    return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e);
4382  }
4383  destroy() {
4384    this.spec.destroy && this.spec.destroy(), super.destroy();
4385  }
4386}
4387class et extends Tn {
4388  constructor(e, t, r, s, i, o, l, a, c) {
4389    super(e, [], i, o), this.node = t, this.outerDeco = r, this.innerDeco = s, this.nodeDOM = l;
4390  }
4391  static create(e, t, r, s, i, o) {
4392    let l = i.nodeViews[t.type.name], a, c = l && l(t, i, () => {
4393      if (!a) return o;
4394      if (a.parent) return a.parent.posBeforeChild(a);
4395    }, r, s), u = c && c.dom, d = c && c.contentDOM;
4396    if (t.isText) {
4397      if (!u) u = document.createTextNode(t.text);
4398      else if (u.nodeType != 3) throw new RangeError("Text must be rendered as a DOM text node");
4399    } else u || ({ dom: u, contentDOM: d } = Mt.renderSpec(document, t.type.spec.toDOM(t), null, t.attrs));
4400    !d && !t.isText && u.nodeName != "BR" && (u.hasAttribute("contenteditable") || (u.contentEditable = "false"), t.type.spec.draggable && (u.draggable = true));
4401    let f = u;
4402    return u = Aa(u, r, t), c ? a = new mf(e, t, r, s, u, d || null, f, c, i, o + 1) : t.isText ? new $r(e, t, r, s, u, f, i) : new et(e, t, r, s, u, d || null, f, i, o + 1);
4403  }
4404  parseRule() {
4405    if (this.node.type.spec.reparseInView) return null;
4406    let e = { node: this.node.type.name, attrs: this.node.attrs };
4407    if (this.node.type.whitespace == "pre" && (e.preserveWhitespace = "full"), !this.contentDOM) e.getContent = () => this.node.content;
4408    else if (!this.contentLost) e.contentElement = this.contentDOM;
4409    else {
4410      for (let t = this.children.length - 1; t >= 0; t--) {
4411        let r = this.children[t];
4412        if (this.dom.contains(r.dom.parentNode)) {
4413          e.contentElement = r.dom.parentNode;
4414          break;
4415        }
4416      }
4417      e.contentElement || (e.getContent = () => b.empty);
4418    }
4419    return e;
4420  }
4421  matchesNode(e, t, r) {
4422    return this.dirty == ke && e.eq(this.node) && Yn(t, this.outerDeco) && r.eq(this.innerDeco);
4423  }
4424  get size() {
4425    return this.node.nodeSize;
4426  }
4427  get border() {
4428    return this.node.isLeaf ? 0 : 1;
4429  }
4430  updateChildren(e, t) {
4431    let r = this.node.inlineContent, s = t, i = e.composing ? this.localCompositionInfo(e, t) : null, o = i && i.pos > -1 ? i : null, l = i && i.pos < 0, a = new yf(this, o && o.node, e);
4432    xf(this.node, this.innerDeco, (c, u, d) => {
4433      c.spec.marks ? a.syncToMarks(c.spec.marks, r, e, u) : c.type.side >= 0 && !d && a.syncToMarks(u == this.node.childCount ? B.none : this.node.child(u).marks, r, e, u), a.placeWidget(c, e, s);
4434    }, (c, u, d, f) => {
4435      a.syncToMarks(c.marks, r, e, f);
4436      let h;
4437      a.findNodeMatch(c, u, d, f) || l && e.state.selection.from > s && e.state.selection.to < s + c.nodeSize && (h = a.findIndexWithChild(i.node)) > -1 && a.updateNodeAt(c, u, d, h, e) || a.updateNextNode(c, u, d, e, f, s) || a.addNode(c, u, d, e, s), s += c.nodeSize;
4438    }), a.syncToMarks([], r, e, 0), this.node.isTextblock && a.addTextblockHacks(), a.destroyRest(), (a.changed || this.dirty == dt) && (o && this.protectLocalComposition(e, o), Ta(this.contentDOM, this.children, e), Ft && Sf(this.dom));
4439  }
4440  localCompositionInfo(e, t) {
4441    let { from: r, to: s } = e.state.selection;
4442    if (!(e.state.selection instanceof I) || r < t || s > t + this.node.content.size) return null;
4443    let i = e.input.compositionNode;
4444    if (!i || !this.dom.contains(i.parentNode)) return null;
4445    if (this.node.inlineContent) {
4446      let o = i.nodeValue, l = wf(this.node.content, o, r - t, s - t);
4447      return l < 0 ? null : { node: i, pos: l, text: o };
4448    } else return { node: i, pos: -1, text: "" };
4449  }
4450  protectLocalComposition(e, { node: t, pos: r, text: s }) {
4451    if (this.getDesc(t)) return;
4452    let i = t;
4453    for (; i.parentNode != this.contentDOM; i = i.parentNode) {
4454      for (; i.previousSibling; ) i.parentNode.removeChild(i.previousSibling);
4455      for (; i.nextSibling; ) i.parentNode.removeChild(i.nextSibling);
4456      i.pmViewDesc && (i.pmViewDesc = void 0);
4457    }
4458    let o = new pf(this, i, t, s);
4459    e.input.compositionNodes.push(o), this.children = Ls(this.children, r, r + s.length, e, o);
4460  }
4461  update(e, t, r, s) {
4462    return this.dirty == Ae || !e.sameMarkup(this.node) ? false : (this.updateInner(e, t, r, s), true);
4463  }
4464  updateInner(e, t, r, s) {
4465    this.updateOuterDeco(t), this.node = e, this.innerDeco = r, this.contentDOM && this.updateChildren(s, this.posAtStart), this.dirty = ke;
4466  }
4467  updateOuterDeco(e) {
4468    if (Yn(e, this.outerDeco)) return;
4469    let t = this.nodeDOM.nodeType != 1, r = this.dom;
4470    this.dom = Ea(this.dom, this.nodeDOM, Ps(this.outerDeco, this.node, t), Ps(e, this.node, t)), this.dom != r && (r.pmVie
4470wDesc = void 0, this.dom.pmViewDesc = this), this.outerDeco = e;
4471  }
4472  selectNode() {
4473    this.nodeDOM.nodeType == 1 && (this.nodeDOM.classList.add("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && (this.nodeDOM.draggable = true));
4474  }
4475  deselectNode() {
4476    this.nodeDOM.nodeType == 1 && (this.nodeDOM.classList.remove("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && this.nodeDOM.removeAttribute("draggable"));
4477  }
4478  get domAtom() {
4479    return this.node.isAtom;
4480  }
4481}
4482function So(n2, e, t, r, s) {
4483  Aa(r, e, n2);
4484  let i = new et(void 0, n2, e, t, r, r, r, s, 0);
4485  return i.contentDOM && i.updateChildren(s, 0), i;
4486}
4487class $r extends et {
4488  constructor(e, t, r, s, i, o, l) {
4489    super(e, t, r, s, i, null, o, l, 0);
4490  }
4491  parseRule() {
4492    let e = this.nodeDOM.parentNode;
4493    for (; e && e != this.dom && !e.pmIsDeco; ) e = e.parentNode;
4494    return { skip: e || true };
4495  }
4496  update(e, t, r, s) {
4497    return this.dirty == Ae || this.dirty != ke && !this.inParent() || !e.sameMarkup(this.node) ? false : (this.updateOuterDeco(t), (this.dirty != ke || e.text != this.node.text) && e.text != this.nodeDOM.nodeValue && (this.nodeDOM.nodeValue = e.text, s.trackWrites == this.nodeDOM && (s.trackWrites = null)), this.node = e, this.dirty = ke, true);
4498  }
4499  inParent() {
4500    let e = this.parent.contentDOM;
4501    for (let t = this.nodeDOM; t; t = t.parentNode) if (t == e) return true;
4502    return false;
4503  }
4504  domFromPos(e) {
4505    return { node: this.nodeDOM, offset: e };
4506  }
4507  localPosFromDOM(e, t, r) {
4508    return e == this.nodeDOM ? this.posAtStart + Math.min(t, this.node.text.length) : super.localPosFromDOM(e, t, r);
4509  }
4510  ignoreMutation(e) {
4511    return e.type != "characterData" && e.type != "selection";
4512  }
4513  slice(e, t, r) {
4514    let s = this.node.cut(e, t), i = document.createTextNode(s.text);
4515    return new $r(this.parent, s, this.outerDeco, this.innerDeco, i, i, r);
4516  }
4517  markDirty(e, t) {
4518    super.markDirty(e, t), this.dom != this.nodeDOM && (e == 0 || t == this.nodeDOM.nodeValue.length) && (this.dirty = Ae);
4519  }
4520  get domAtom() {
4521    return false;
4522  }
4523  isText(e) {
4524    return this.node.text == e;
4525  }
4526}
4527class va extends Tn {
4528  parseRule() {
4529    return { ignore: true };
4530  }
4531  matchesHack(e) {
4532    return this.dirty == ke && this.dom.nodeName == e;
4533  }
4534  get domAtom() {
4535    return true;
4536  }
4537  get ignoreForCoords() {
4538    return this.dom.nodeName == "IMG";
4539  }
4540}
4541class mf extends et {
4542  constructor(e, t, r, s, i, o, l, a, c, u) {
4543    super(e, t, r, s, i, o, l, c, u), this.spec = a;
4544  }
4545  update(e, t, r, s) {
4546    if (this.dirty == Ae) return false;
4547    if (this.spec.update && (this.node.type == e.type || this.spec.multiType)) {
4548      let i = this.spec.update(e, t, r);
4549      return i && this.updateInner(e, t, r, s), i;
4550    } else return !this.contentDOM && !e.isLeaf ? false : super.update(e, t, r, s);
4551  }
4552  selectNode() {
4553    this.spec.selectNode ? this.spec.selectNode() : super.selectNode();
4554  }
4555  deselectNode() {
4556    this.spec.deselectNode ? this.spec.deselectNode() : super.deselectNode();
4557  }
4558  setSelection(e, t, r, s) {
4559    this.spec.setSelection ? this.spec.setSelection(e, t, r.root) : super.setSelection(e, t, r, s);
4560  }
4561  destroy() {
4562    this.spec.destroy && this.spec.destroy(), super.destroy();
4563  }
4564  stopEvent(e) {
4565    return this.spec.stopEvent ? this.spec.stopEvent(e) : false;
4566  }
4567  ignoreMutation(e) {
4568    return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e);
4569  }
4570}
4571function Ta(n2, e, t) {
4572  let r = n2.firstChild, s = false;
4573  for (let i = 0; i < e.length; i++) {
4574    let o = e[i], l = o.dom;
4575    if (l.parentNode == n2) {
4576      for (; l != r; ) r = wo(r), s = true;
4577      r = r.nextSibling;
4578    } else s = true, n2.insertBefore(l, r);
4579    if (o instanceof Ct) {
4580      let a = r ? r.previousSibling : n2.lastChild;
4581      Ta(o.contentDOM, o.children, t), r = a ? a.nextSibling : n2.firstChild;
4582    }
4583  }
4584  for (; r; ) r = wo(r), s = true;
4585  s && t.trackWrites == n2 && (t.trackWrites = null);
4586}
4587const nn = function(n2) {
4588  n2 && (this.nodeName = n2);
4589};
4590nn.prototype = /* @__PURE__ */ Object.create(null);
4591const ft = [new nn()];
4592function Ps(n2, e, t) {
4593  if (n2.length == 0) return ft;
4594  let r = t ? ft[0] : new nn(), s = [r];
4595  for (let i = 0; i < n2.length; i++) {
4596    let o = n2[i].type.attrs;
4597    if (o) {
4598      o.nodeName && s.push(r = new nn(o.nodeName));
4599      for (let l in o) {
4600        let a = o[l];
4601        a != null && (t && s.length == 1 && s.push(r = new nn(e.isInline ? "span" : "div")), l == "class" ? r.class = (r.class ? r.class + " " : "") + a : l == "style" ? r.style = (r.style ? r.style + ";" : "") + a : l != "nodeName" && (r[l] = a));
4602      }
4603    }
4604  }
4605  return s;
4606}
4607function Ea(n2, e, t, r) {
4608  if (t == ft && r == ft) return e;
4609  let s = e;
4610  for (let i = 0; i < r.length; i++) {
4611    let o = r[i], l = t[i];
4612    if (i) {
4613      let a;
4614      l && l.nodeName == o.nodeName && s != n2 && (a = s.parentNode) && a.nodeName.toLowerCase() == o.nodeName || (a = document.createElement(o.nodeName), a.pmIsDeco = true, a.appendChild(s), l = ft[0]), s = a;
4615    }
4616    gf(s, l || ft[0], o);
4617  }
4618  return s;
4619}
4620function gf(n2, e, t) {
4621  for (let r in e) r != "class" && r != "style" && r != "nodeName" && !(r in t) && n2.removeAttribute(r);
4622  for (let r in t) r != "class" && r != "style" && r != "nodeName" && t[r] != e[r] && n2.setAttribute(r, t[r]);
4623  if (e.class != t.class) {
4624    let r = e.class ? e.class.split(" ").filter(Boolean) : [], s = t.class ? t.class.split(" ").filter(Boolean) : [];
4625    for (let i = 0; i < r.length; i++) s.indexOf(r[i]) == -1 && n2.classList.remove(r[i]);
4626    for (let i = 0; i < s.length; i++) r.indexOf(s[i]) == -1 && n2.classList.add(s[i]);
4627    n2.classList.length == 0 && n2.removeAttribute("class");
4628  }
4629  if (e.style != t.style) {
4630    if (e.style) {
4631      let r = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g, s;
4632      for (; s = r.exec(e.style); ) n2.style.removeProperty(s[1]);
4633    }
4634    t.style && (n2.style.cssText += t.style);
4635  }
4636}
4637function Aa(n2, e, t) {
4638  return Ea(n2, n2, ft, Ps(e, t, n2.nodeType != 1));
4639}
4640function Yn(n2, e) {
4641  if (n2.length != e.length) return false;
4642  for (let t = 0; t < n2.length; t++) if (!n2[t].type.eq(e[t].type)) return false;
4643  return true;
4644}
4645function wo(n2) {
4646  let e = n2.nextSibling;
4647  return n2.parentNode.removeChild(n2), e;
4648}
4649class yf {
4650  constructor(e, t, r) {
4651    this.lock = t, this.view = r, this.index = 0, this.stack = [], this.changed = false, this.top = e, this.preMatch = bf(e.node.content, e);
4652  }
4653  destroyBetween(e, t) {
4654    if (e != t) {
4655      for (let r = e; r < t; r++) this.top.children[r].destroy();
4656      this.top.children.splice(e, t - e), this.changed = true;
4657    }
4658  }
4659  destroyRest() {
4660    this.destroyBetween(this.index, this.top.children.length);
4661  }
4662  syncToMarks(e, t, r, s) {
4663    let i = 0, o = this.stack.length >> 1, l = Math.min(o, e.length);
4664    for (; i < l && (i == o - 1 ? this.top : this.stack[i + 1 << 1]).matchesMark(e[i]) && e[i].type.spec.spanning !== false; ) i++;
4665    for (; i < o; ) this.destroyRest(), this.top.dirty = ke, this.index = this.stack.pop(), this.top = this.stack.pop(), o--;
4666    for (; o < e.length; ) {
4667      this.stack.push(this.top, this.index + 1);
4668      let a = -1, c = this.top.children.length;
4669      s < this.preMatch.index && (c = Math.min(this.index + 3, c));
4670      for (let u = this.index; u < c; u++) {
4671        let d = this.top.children[u];
4672        if (d.matchesMark(e[o]) && !this.isLocked(d.dom)) {
4673          a = u;
4674          break;
4675        }
4676      }
4677      if (a > -1) a > this.index && (this.changed = true, this.destroyBetween(this.index, a)), this.top = this.top.children[this.index];
4678      else {
4679        let u = Ct.create(this.top, e[o], t, r);
4680        this.top.children.splice(this.index, 0, u), this.top = u, this.changed = true;
4681      }
4682      this.index = 0, o++;
4683    }
4684  }
4685  findNodeMatch(e, t, r, s) {
4686    let i = -1, o;
4687    if (s >= this.preMatch.index && (o = this.preMatch.matches[s - this.preMatch.index]).parent == this.top && o.matchesNode(e, t, r)) i = this.top.children.indexOf(o, this.index);
4688    else for (let l = this.index, a = Math.min(this.top.children.length, l + 5); l < a; l++) {
4689      let c = this.top.children[l];
4690      if (c.matchesNode(e, t, r) && !this.preMatch.matched.has(c)) {
4691        i = l;
4692        break;
4693      }
4694    }
4695    return i < 0 ? false : (this.destroyBetween(this.index, i), this.index++, true);
4696  }
4697  updateNodeAt(e, t, r, s, i) {
4698    let o = this.top.children[s];
4699    return o.dirty == Ae && o.dom == o.contentDOM && (o.dirty = dt), o.update(e, t, r, i) ? (this.destroyBetween(this.index, s), this.index++, true) : false;
4700  }
4701  findIndexWithChild(e) {
4702    for (; ; ) {
4703      let t = e.parentNode;
4704      if (!t) return -1;
4705      if (t == this.top.contentDOM) {
4706        let r = e.pmViewDesc;
4707        if (r) {
4708          for (let s = this.index; s < this.top.children.length; s++) if (this.top.children[s] == r) return s;
4709        }
4710        return -1;
4711      }
4712      e = t;
4713    }
4714  }
4715  updateNextNode(e, t, r, s, i, o) {
4716    for (let l = this.index; l < this.top.children.length; l++) {
4717      let a = this.top.children[l];
4718      if (a instanceof et) {
4719        let c = this.preMatch.matched.get(a);
4720        if (c != null && c != i) return false;
4721        let u = a.dom, d, f = this.isLocked(u) && !(e.isText && a.node && a.node.isText && a.nodeDOM.nodeValue == e.text && a.dirty != Ae && Yn(t, a.outerDeco));
4722        if (!f && a.update(e, t, r, s)) return this.destroyBetween(this.index, l), a.dom != u && (this.changed = true), this.index++, true;
4723        if (!f && (d = this.recreateWrapper(a, e, t, r, s, o))) return this.destroyBetween(this.index, l), this.top.children[this.index] = d, d.contentDOM && (d.dirty = dt, d.updateChildren(s, o + 1), d.dirty = ke), this.changed = true, this.index++, true;
4724        break;
4725      }
4726    }
4727    return false;
4728  }
4729  recreateWrapper(e, t, r, s, i, o) {
4730    if (e.dirty || t.isAtom || !e.children.length || !e.node.content.eq(t.content) || !Yn(r, e.outerDeco) || !s.eq(e.innerDeco)) return null;
4731    let l = et.create(this.top, t, r, s, i, o);
4732    if (l.contentDOM) {
4733      l.children = e.children, e.children = [];
4734      for (let a of l.children) a.parent = l;
4735    }
4736    return e.destroy(), l;
4737  }
4738  addNode(e, t, r, s, i) {
4739    let o = et.create(this.top, e, t, r, s, i);
4740    o.contentDOM && o.updateChildren(s, i + 1), this.top.children.splice(this.index++, 0, o), this.changed = true;
4741  }
4742  placeWidget(e, t, r) {
4743    let s = this.index < this.top.children.length ? this.top.children[this.index] : null;
4744    if (s && s.matchesWidget(e) && (e == s.widget || !s.widget.type.toDOM.parentNode)) this.index++;
4745    else {
4746      let i = new Ma(this.top, e, t, r);
4747      this.top.children.splice(this.index++, 0, i), this.changed = true;
4748    }
4749  }
4750  addTextblockHacks() {
4751    let e = this.top.children[this.index - 1], t = this.top;
4752    for (; e instanceof Ct; ) t = e, e = t.children[t.children.length - 1];
4753    (!e || !(e instanceof $r) || /\n$/.test(e.node.text) || this.view.requiresGeckoHackNode && /\s$/.test(e.node.text)) && ((ne || ee) && e && e.dom.contentEditable == "false" && this.addHackNode("IMG", t), this.addHackNode("BR", this.top));
4754  }
4755  addHackNode(e, t) {
4756    if (t == this.top && this.index < t.children.length && t.children[this.index].matchesHack(e)) this.index++;
4757    else {
4758      let r = document.createElement(e);
4759      e == "IMG" && (r.className = "ProseMirror-separator", r.alt = ""), e == "BR" && (r.className = "ProseMirror-trailingBreak");
4760      let s = new va(this.top, [], r, null);
4761      t != this.top ? t.children.push(s) : t.children.splice(this.index++, 0, s), this.changed = true;
4762    }
4763  }
4764  isLocked(e) {
4765    return this.lock && (e == this.lock || e.nodeType == 1 && e.contains(this.lock.parentNode));
4766  }
4767}
4768function bf(n2, e) {
4769  let t = e, r = t.children.length, s = n2.childCount, i = /* @__PURE__ */ new Map(), o = [];
4770  e: for (; s > 0; ) {
4771    let l;
4772    for (; ; ) if (r) {
4773      let c = t.children[r - 1];
4774      if (c instanceof Ct) t = c, r = c.children.length;
4775      else {
4776        l = c, r--;
4777        break;
4778      }
4779    } else {
4780      if (t == e) break e;
4781      r = t.parent.children.indexOf(t), t = t.parent;
4782    }
4783    let a = l.node;
4784    if (a) {
4785      if (a != n2.child(s - 1)) break;
4786      --s, i.set(l, s), o.push(l);
4787    }
4788  }
4789  return { index: s, matched: i, matches: o.reverse() };
4790}
4791function kf(n2, e) {
4792  return n2.type.side - e.type.side;
4793}
4794function xf(n2, e, t, r) {
4795  let s = e.locals(n2), i = 0;
4796  if (s.length == 0) {
4797    for (let c = 0; c < n2.childCount; c++) {
4798      let u = n2.child(c);
4799      r(u, s, e.forChild(i, u), c), i += u.nodeSize;
4800    }
4801    return;
4802  }
4803  let o = 0, l = [], a = null;
4804  for (let c = 0; ; ) {
4805    let u, d;
4806    for (; o < s.length && s[o].to == i; ) {
4807      let g = s[o++];
4808      g.widget && (u ? (d || (d = [u])).push(g) : u = g);
4809    }
4810    if (u) if (d) {
4811      d.sort(kf);
4812      for (let g = 0; g < d.length; g++) t(d[g], c, !!a);
4813    } else t(u, c, !!a);
4814    let f, h;
4815    if (a) h = -1, f = a, a = null;
4816    else if (c < n2.childCount) h = c, f = n2.child(c++);
4817    else break;
4818    for (let g = 0; g < l.length; g++) l[g].to <= i && l.splice(g--, 1);
4819    for (; o < s.length && s[o].from <= i && s[o].to > i; ) l.push(s[o++]);
4820    let p = i + f.nodeSize;
4821    if (f.isText) {
4822      let g = p;
4823      o < s.length && s[o].from < g && (g = s[o].from);
4824      for (let y = 0; y < l.length; y++) l[y].to < g && (g = l[y].to);
vendor: 4,655 bytes, lines 4825-4933
4825      g < p && (a = f.cut(g - i), f = f.cut(0, g - i), p = g, h = -1);
4826    } else for (; o < s.length && s[o].to < p; ) o++;
4827    let m = f.isInline && !f.isLeaf ? l.filter((g) => !g.inline) : l.slice();
4828    r(f, m, e.forChild(i, f), h), i = p;
4829  }
4830}
4831function Sf(n2) {
4832  if (n2.nodeName == "UL" || n2.nodeName == "OL") {
4833    let e = n2.style.cssText;
4834    n2.style.cssText = e + "; list-style: square !important", window.getComputedStyle(n2).listStyle, n2.style.cssText = e;
4835  }
4836}
4837function wf(n2, e, t, r) {
4838  for (let s = 0, i = 0; s < n2.childCount && i <= r; ) {
4839    let o = n2.child(s++), l = i;
4840    if (i += o.nodeSize, !o.isText) continue;
4841    let a = o.text;
4842    for (; s < n2.childCount; ) {
4843      let c = n2.child(s++);
4844      if (i += c.nodeSize, !c.isText) break;
4845      a += c.text;
4846    }
4847    if (i >= t) {
4848      if (i >= r && a.slice(r - e.length - l, r - l) == e) return r - e.length;
4849      let c = l < r ? a.lastIndexOf(e, r - l - 1) : -1;
4850      if (c >= 0 && c + e.length + l >= t) return l + c;
4851      if (t == r && a.length >= r + e.length - l && a.slice(r - l, r - l + e.length) == e) return r;
4852    }
4853  }
4854  return -1;
4855}
4856function Ls(n2, e, t, r, s) {
4857  let i = [];
4858  for (let o = 0, l = 0; o < n2.length; o++) {
4859    let a = n2[o], c = l, u = l += a.size;
4860    c >= t || u <= e ? i.push(a) : (c < e && i.push(a.slice(0, e - c, r)), s && (i.push(s), s = void 0), u > t && i.push(a.slice(t - c, a.size, r)));
4861  }
4862  return i;
4863}
4864function di(n2, e = null) {
4865  let t = n2.domSelectionRange(), r = n2.state.doc;
4866  if (!t.focusNode) return null;
4867  let s = n2.docView.nearestDesc(t.focusNode), i = s && s.size == 0, o = n2.docView.posFromDOM(t.focusNode, t.focusOffset, 1);
4868  if (o < 0) return null;
4869  let l = r.resolve(o), a, c;
4870  if (zr(t)) {
4871    for (a = o; s && !s.node; ) s = s.parent;
4872    let d = s.node;
4873    if (s && d.isAtom && T.isSelectable(d) && s.parent && !(d.isInline && Jd(t.focusNode, t.focusOffset, s.dom))) {
4874      let f = s.posBefore;
4875      c = new T(o == f ? l : r.resolve(f));
4876    }
4877  } else {
4878    if (t instanceof n2.dom.ownerDocument.defaultView.Selection && t.rangeCount > 1) {
4879      let d = o, f = o;
4880      for (let h = 0; h < t.rangeCount; h++) {
4881        let p = t.getRangeAt(h);
4882        d = Math.min(d, n2.docView.posFromDOM(p.startContainer, p.startOffset, 1)), f = Math.max(f, n2.docView.posFromDOM(p.endContainer, p.endOffset, -1));
4883      }
4884      if (d < 0) return null;
4885      [a, o] = f == n2.state.selection.anchor ? [f, d] : [d, f], l = r.resolve(o);
4886    } else a = n2.docView.posFromDOM(t.anchorNode, t.anchorOffset, 1);
4887    if (a < 0) return null;
4888  }
4889  let u = r.resolve(a);
4890  if (!c) {
4891    let d = e == "pointer" || n2.state.selection.head < l.pos && !i ? 1 : -1;
4892    c = fi(n2, u, l, d);
4893  }
4894  return c;
4895}
4896function Na(n2) {
4897  return n2.editable ? n2.hasFocus() : Ia(n2) && document.activeElement && document.activeElement.contains(n2.dom);
4898}
4899function ze(n2, e = false) {
4900  let t = n2.state.selection;
4901  if (Oa(n2, t), !!Na(n2)) {
4902    if (!e && n2.input.mouseDown && n2.input.mouseDown.allowDefault && ee) {
4903      let r = n2.domSelectionRange(), s = n2.domObserver.currentSelection;
4904      if (r.anchorNode && s.anchorNode && wt(r.anchorNode, r.anchorOffset, s.anchorNode, s.anchorOffset)) {
4905        n2.input.mouseDown.delayedSelectionSync = true, n2.domObserver.setCurSelection();
4906        return;
4907      }
4908    }
4909    if (n2.domObserver.disconnectSelection(), n2.cursorWrapper) Mf(n2);
4910    else {
4911      let { anchor: r, head: s } = t, i, o;
4912      Co && !(t instanceof I) && (t.$from.parent.inlineContent || (i = Mo(n2, t.from)), !t.empty && !t.$from.parent.inlineContent && (o = Mo(n2, t.to))), n2.docView.setSelection(r, s, n2, e), Co && (i && vo(i), o && vo(o)), t.visible ? n2.dom.classList.remove("ProseMirror-hideselection") : (n2.dom.classList.add("ProseMirror-hideselection"), "onselectionchange" in document && Cf(n2));
4913    }
4914    n2.domObserver.setCurSelection(), n2.domObserver.connectSelection();
4915  }
4916}
4917const Co = ne || ee && ga < 63;
4918function Mo(n2, e) {
4919  let { node: t, offset: r } = n2.docView.domFromPos(e, 0), s = r < t.childNodes.length ? t.childNodes[r] : null, i = r ? t.childNodes[r - 1] : null;
4920  if (ne && s && s.contentEditable == "false") return as(s);
4921  if ((!s || s.contentEditable == "false") && (!i || i.contentEditable == "false")) {
4922    if (s) return as(s);
4923    if (i) return as(i);
4924  }
4925}
4926function as(n2) {
4927  return n2.contentEditable = "true", ne && n2.draggable && (n2.draggable = false, n2.wasDraggable = true), n2;
4928}
4929function vo(n2) {
4930  n2.contentEditable = "false", n2.wasDraggable && (n2.draggable = true, n2.wasDraggable = null);
4931}
4932function Cf(n2) {
4933  let e = n2.dom.ownerDocument;
4934  e.removeEventListener("selectionchange", n2.input.hideSelectionGuard);
4935  let t = n2.domSelectionRange(), r = t.anchorNode, s = t.anchorOffset;
4936  e.addEventListener("selectionchange", n2.input.hideSelectionGuard = () => {
4937    (t.anchorNode != r || t.anchorOffset != s) && (e.removeEventListener("selectionchange", n2.input.hideSelectionGuard), setTimeout(() => {
4938      (!Na(n2) || n2.state.selection.visible) && n2.dom.classList.remove("ProseMirror-hideselection");
4939    }, 20));
4940  });
4941}
4942function Mf(n2) {
4943  let e = n2.domSelection();
4944  if (!e) return;
4945  let t = n2.cursorWrapper.dom, r = t.nodeName == "IMG";
4946  r ? e.collapse(t.parentNode, X(t) + 1) : e.collapse(t, 0), !r && !n2.state.selection.visible && ce && Ze <= 11 && (t.disabled = true, t.disabled = false);
4947}
4948function Oa(n2, e) {
4949  if (e instanceof T) {
4950    let t = n2.docView.descAt(e.from);
4951    t != n2.lastSelectedViewDesc && (To(n2), t && t.selectNode(), n2.lastSelectedViewDesc = t);
4952  } else To(n2);
4953}
4954function To(n2) {
4955  n2.lastSelectedViewDesc && (n2.lastSelectedViewDesc.parent && n2.lastSelectedViewDesc.deselectNode(), n2.lastSelectedViewDesc = void 0);
4956}
4957function fi(n2, e, t, r) {
4958  return n2.someProp("createSelectionBetween", (s) => s(n2, e, t)) || I.between(e, t, r);
4959}
4960function Eo(n2) {
4961  return n2.editable && !n2.hasFocus() ? false : Ia(n2);
4962}
4963function Ia(n2) {
4964  let e = n2.domSelectionRange();
4965  if (!e.anchorNode) return false;
4966  try {
4967    return n2.dom.contains(e.anchorNode.nodeType == 3 ? e.anchorNode.parentNode : e.anchorNode) && (n2.editable || n2.dom.contains(e.focusNode.nodeType == 3 ? e.focusNode.parentNode : e.focusNode));
4968  } catch {
4969    return false;
4970  }
4971}
4972function vf(n2) {
4973  let e = n2.docView.domFromPos(n2.state.selection.anchor, 0), t = n2.domSelectionRange();
4974  return wt(e.node, e.offset, t.anchorNode, t.anchorOffset);
4975}
4976function Bs(n2, e) {
4977  let { $anchor: t, $head: r } = n2.selection, s = e > 0 ? t.max(r) : t.min(r), i = s.parent.inlineContent ? s.depth ? n2.doc.resolve(e > 0 ? s.after() : s.before()) : null : s;
4978  return i && R.findFrom(i, e);
4979}
4980function We(n2, e) {
4981  return n2.dispatch(n2.state.tr.setSelection(e).scrollIntoView()), true;
4982}
4983function Ao(n2, e, t) {
4984  let r = n2.state.selection;
4985  if (r instanceof I) if (t.indexOf("s") > -1) {
4986    let { $head: s } = r, i = s.textOffset ? null : e < 0 ? s.nodeBefore : s.nodeAfter;
4987    if (!i || i.isText || !i.isLeaf) return false;
4988    let o = n2.state.doc.resolve(s.pos + i.nodeSize * (e < 0 ? -1 : 1));
4989    return We(n2, new I(r.$anchor, o));
4990  } else if (r.empty) {
4991    if (n2.endOfTextblock(e > 0 ? "forward" : "backward")) {
4992      let s = Bs(n2.state, e);
4993      return s && s instanceof T ? We(n2, s) : false;
4994    } else if (!(ge && t.indexOf("m") > -1)) {
4995      let s = r.$head, i = s.textOffset ? null : e < 0 ? s.nodeBefore : s.nodeAfter, o;
4996      if (!i || i.isText) return false;
4997      let l = e < 0 ? s.pos - i.nodeSize : s.pos;
4998      return i.isAtom || (o = n2.docView.descAt(l)) && !o.contentDOM ? T.isSelectable(i) ? We(n2, new T(e < 0 ? n2.state.doc.resolve(s.pos - i.nodeSize) : s)) : vn ? We(n2, new I(n2.state.doc.resolve(e < 0 ? l : l + i.nodeSize))) : false : false;
4999    }
5000  } else return false;
5001  else {
5002    if (r instanceof T && r.node.isInline) return We(n2, new I(e > 0 ? r.$to : r.$from));
5003    {
5004      let s = Bs(n2.state, e);
5005      return s ? We(n2, s) : false;
5006    }
5007  }
5008}
5009function Qn(n2) {
5010  return n2.nodeType == 3 ? n2.nodeValue.length : n2.childNodes.length;
5011}
5012function rn(n2, e) {
5013  let t = n2.pmViewDesc;
5014  return t && t.size == 0 && (e < 0 || n2.nextSibling || n2.nodeName != "BR");
5015}
5016function Nt(n2, e) {
5017  return e < 0 ? Tf(n2) : Ef(n2);
5018}
5019function Tf(n2) {
5020  let e = n2.domSelectionRange(), t = e.focusNode, r = e.focusOffset;
5021  if (!t) return;
5022  let s, i, o = false;
5023  for (be && t.nodeType == 1 && r < Qn(t) && rn(t.childNodes[r], -1) && (o = true); ; ) if (r > 0) {
5024    if (t.nodeType != 1) break;
5025    {
5026      let l = t.childNodes[r - 1];
5027      if (rn(l, -1)) s = t, i = --r;
5028      else if (l.nodeType == 3) t = l, r = t.nodeValue.length;
5029      else break;
5030    }
5031  } else {
5032    if (Da(t)) break;
5033    {
5034      let l = t.previousSibling;
5035      for (; l && rn(l, -1); ) s = t.parentNode, i = X(l), l = l.previousSibling;
5036      if (l) t = l, r = Qn(t);
5037      else {
5038        if (t = t.parentNode, t == n2.dom) break;
5039        r = 0;
5040      }
5041    }
5042  }
5043  o ? zs(n2, t, r) : s && zs(n2, s, i);
5044}
5045function Ef(n2) {
5046  let e = n2.domSelectionRange(), t = e.focusNode, r = e.focusOffset;
5047  if (!t) return;
5048  let s = Qn(t), i, o;
5049  for (; ; ) if (r < s) {
5050    if (t.nodeType != 1) break;
5051    let l = t.childNodes[r];
5052    if (rn(l, 1)) i = t, o = ++r;
5053    else break;
5054  } else {
5055    if (Da(t)) break;
5056    {
5057      let l = t.nextSibling;
5058      for (; l && rn(l, 1); ) i = l.parentNode, o = X(l) + 1, l = l.nextSibling;
5059      if (l) t = l, r = 0, s = Qn(t);
5060      else {
5061        if (t = t.parentNode, t == n2.dom) break;
5062        r = s = 0;
5063      }
5064    }
5065  }
5066  i && zs(n2, i, o);
5067}
5068function Da(n2) {
5069  let e = n2.pmViewDesc;
5070  return e && e.node && e.node.isBlock;
5071}
5072function Af(n2, e) {
5073  for (; n2 && e == n2.childNodes.length && !Mn(n2); ) e = X(n2) + 1, n2 = n2.parentNode;
5074  for (; n2 && e < n2.childNodes.length; ) {
5075    let t = n2.childNodes[e];
5076    if (t.nodeType == 3) return t;
5077    if (t.nodeType == 1 && t.contentEditable == "false") break;
5078    n2 = t, e = 0;
5079  }
5080}
5081function Nf(n2, e) {
5082  for (; n2 && !e && !Mn(n2); ) e = X(n2), n2 = n2.parentNode;
5083  for (; n2 && e; ) {
5084    let t = n2.childNodes[e - 1];
5085    if (t.nodeType == 3) return t;
5086    if (t.nodeType == 1 && t.contentEditable == "false") break;
5087    n2 = t, e = n2.childNodes.length;
5088  }
5089}
5090function zs(n2, e, t) {
5091  if (e.nodeType != 3) {
5092    let i, o;
5093    (o = Af(e, t)) ? (e = o, t = 0) : (i = Nf(e, t)) && (e = i, t = i.nodeValue.length);
5094  }
5095  let r = n2.domSelection();
5096  if (!r) return;
5097  if (zr(r)) {
5098    let i = document.createRange();
5099    i.setEnd(e, t), i.setStart(e, t), r.removeAllRanges(), r.addRange(i);
5100  } else r.extend && r.extend(e, t);
5101  n2.domObserver.setCurSelection();
5102  let { state: s } = n2;
5103  setTimeout(() => {
5104    n2.state == s && ze(n2);
5105  }, 50);
5106}
5107function No(n2, e) {
5108  let t = n2.state.doc.resolve(e);
5109  if (!(ee || ya) && t.parent.inlineContent) {
5110    let s = n2.coordsAtPos(e);
5111    if (e > t.start()) {
5112      let i = n2.coordsAtPos(e - 1), o = (i.top + i.bottom) / 2;
5113      if (o > s.top && o < s.bottom && Math.abs(i.left - s.left) > 1) return i.left < s.left ? "ltr" : "rtl";
5114    }
5115    if (e < t.end()) {
5116      let i = n2.coordsAtPos(e + 1), o = (i.top + i.bottom) / 2;
5117      if (o > s.top && o < s.bottom && Math.abs(i.left - s.left) > 1) return i.left > s.left ? "ltr" : "rtl";
5118    }
5119  }
5120  return getComputedStyle(n2.dom).direction == "rtl" ? "rtl" : "ltr";
5121}
5122function Oo(n2, e, t) {
5123  let r = n2.state.selection;
5124  if (r instanceof I && !r.empty || t.indexOf("s") > -1 || ge && t.indexOf("m") > -1) return false;
5125  let { $from: s, $to: i } = r;
5126  if (!s.parent.inlineContent || n2.endOfTextblock(e < 0 ? "up" : "down")) {
5127    let o = Bs(n2.state, e);
5128    if (o && o instanceof T) return We(n2, o);
5129  }
5130  if (!s.parent.inlineContent) {
5131    let o = e < 0 ? s : i, l = r instanceof de ? R.near(o, e) : R.findFrom(o, e);
5132    return l ? We(n2, l) : false;
5133  }
5134  return false;
5135}
5136function Io(n2, e) {
5137  if (!(n2.state.selection instanceof I)) return true;
5138  let { $head: t, $anchor: r, empty: s } = n2.state.selection;
5139  if (!t.sameParent(r)) return true;
5140  if (!s) return false;
5141  if (n2.endOfTextblock(e > 0 ? "forward" : "backward")) return true;
5142  let i = !t.textOffset && (e < 0 ? t.nodeBefore : t.nodeAfter);
5143  if (i && !i.isText) {
5144    let o = n2.state.tr;
5145    return e < 0 ? o.delete(t.pos - i.nodeSize, t.pos) : o.delete(t.pos, t.pos + i.nodeSize), n2.dispatch(o), true;
5146  }
5147  return false;
5148}
5149function Do(n2, e, t) {
5150  n2.domObserver.stop(), e.contentEditable = t, n2.domObserver.start();
5151}
5152function Of(n2) {
5153  if (!ne || n2.state.selection.$head.parentOffset > 0) return false;
5154  let { focusNode: e, focusOffset: t } = n2.domSelectionRange();
5155  if (e && e.nodeType == 1 && t == 0 && e.firstChild && e.firstChild.contentEditable == "false") {
5156    let r = e.firstChild;
5157    Do(n2, r, "true"), setTimeout(() => Do(n2, r, "false"), 20);
5158  }
5159  return false;
5160}
5161function If(n2) {
5162  let e = "";
5163  return n2.ctrlKey && (e += "c"), n2.metaKey && (e += "m"), n2.altKey && (e += "a"), n2.shiftKey && (e += "s"), e;
5164}
5165function Df(n2, e) {
5166  let t = e.keyCode, r = If(e);
5167  if (t == 8 || ge && t == 72 && r == "c") return Io(n2, -1) || Nt(n2, -1);
5168  if (t == 46 && !e.shiftKey || ge && t == 68 && r == "c") return Io(n2, 1) || Nt(n2, 1);
5169  if (t == 13 || t == 27) return true;
5170  if (t == 37 || ge && t == 66 && r == "c") {
5171    let s = t == 37 ? No(n2, n2.state.selection.from) == "ltr" ? -1 : 1 : -1;
5172    return Ao(n2, s, r) || Nt(n2, s);
5173  } else if (t == 39 || ge && t == 70 && r == "c") {
5174    let s = t == 39 ? No(n2, n2.state.selection.from) == "ltr" ? 1 : -1 : 1;
5175    return Ao(n2, s, r) || Nt(n2, s);
5176  } else {
5177    if (t == 38 || ge && t == 80 && r == "c") return Oo(n2, -1, r) || Nt(n2, -1);
5178    if (t == 40 || ge && t == 78 && r == "c") return Of(n2) || Oo(n2, 1, r) || Nt(n2, 1);
5179    if (r == (ge ? "m" : "c") && (t == 66 || t == 73 || t == 89 || t == 90)) return true;
5180  }
5181  return false;
5182}
5183function hi(n2, e) {
5184  n2.someProp("transformCopied", (h) => {
5185    e = h(e, n2);
5186  });
5187  let t = [], { content: r, openStart: s, openEnd: i } = e;
5188  for (; s > 1 && i > 1 && r.childCount == 1 && r.firstChild.childCount == 1; ) {
5189    s--, i--;
5190    let h = r.firstChild;
5191    t.push(h.type.name, h.attrs != h.type.defaultAttrs ? h.attrs : null), r = h.content;
5192  }
5193  let o = n2.someProp("clipboardSerializer") || Mt.fromSchema(n2.state.schema), l = $a(), a = l.createElement("div");
5194  a.appendChild(o.serializeFragment(r, { document: l }));
5195  let c = a.firstChild, u, d = 0;
5196  for (; c && c.nodeType == 1 && (u = za[c.nodeName.toLowerCase()]); ) {
5197    for (let h = u.length - 1; h >= 0; h--) {
5198      let p = l.createElement(u[h]);
5199      for (; a.firstChild; ) p.appendChild(a.firstChild);
5200      a.appendChild(p), d++;
5201    }
5202    c = a.firstChild;
5203  }
5204  c && c.nodeType == 1 && c.setAttribute("data-pm-slice", `${s} ${i}${d ? ` -${d}` : ""} ${JSON.stringify(t)}`);
5205  let f = n2.someProp("clipboardTextSerializer", (h) => h(e, n2)) || e.content.textBetween(0, e.content.size, `
5206
5207`);
5208  return { dom: a, text: f, slice: e };
5209}
5210function Ra(n2, e, t, r, s) {
5211  let i = s.parent.type.spec.code, o, l;
5212  if (!t && !e) return null;
5213  let a = !!e && (r || i || !t);
5214  if (a) {
5215    if (n2.someProp("transformPastedText", (f) => {
5216      e = f(e, i || r, n2);
5217    }), i) return l = new w(b.from(n2.state.schema.text(e.replace(/\r\n?/g, `
5218`))), 0, 0), n2.someProp("transformPasted", (f) => {
5219      l = f(l, n2, true);
5220    }), l;
5221    let d = n2.someProp("clipboardTextParser", (f) => f(e, s, r, n2));
5222    if (d) l = d;
5223    else {
5224      let f = s.marks(), { schema: h } = n2.state, p = Mt.fromSchema(h);
5225      o = document.createElement("div"), e.split(/(?:\r\n?|\n)+/).forEac
5225h((m) => {
5226        let g = o.appendChild(document.createElement("p"));
5227        m && g.appendChild(p.serializeNode(h.text(m, f)));
5228      });
5229    }
5230  } else n2.someProp("transformPastedHTML", (d) => {
5231    t = d(t, n2);
5232  }), o = Bf(t), vn && zf(o);
5233  let c = o && o.querySelector("[data-pm-slice]"), u = c && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice") || "");
5234  if (u && u[3]) for (let d = +u[3]; d > 0; d--) {
5235    let f = o.firstChild;
5236    for (; f && f.nodeType != 1; ) f = f.nextSibling;
5237    if (!f) break;
5238    o = f;
5239  }
5240  if (l || (l = (n2.someProp("clipboardParser") || n2.someProp("domParser") || Xe.fromSchema(n2.state.schema)).parseSlice(o, { preserveWhitespace: !!(a || u), context: s, ruleFromNode(f) {
5241    return f.nodeName == "BR" && !f.nextSibling && f.parentNode && !Rf.test(f.parentNode.nodeName) ? { ignore: true } : null;
5242  } })), u) l = $f(Ro(l, +u[1], +u[2]), u[4]);
5243  else if (l = w.maxOpen(Pf(l.content, s), true), l.openStart || l.openEnd) {
5244    let d = 0, f = 0;
5245    for (let h = l.content.firstChild; d < l.openStart && !h.type.spec.isolating; d++, h = h.firstChild) ;
5246    for (let h = l.content.lastChild; f < l.openEnd && !h.type.spec.isolating; f++, h = h.lastChild) ;
5247    l = Ro(l, d, f);
5248  }
5249  return n2.someProp("transformPasted", (d) => {
5250    l = d(l, n2, a);
5251  }), l;
5252}
5253const Rf = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;
5254function Pf(n2, e) {
5255  if (n2.childCount < 2) return n2;
5256  for (let t = e.depth; t >= 0; t--) {
5257    let s = e.node(t).contentMatchAt(e.index(t)), i, o = [];
5258    if (n2.forEach((l) => {
5259      if (!o) return;
5260      let a = s.findWrapping(l.type), c;
5261      if (!a) return o = null;
5262      if (c = o.length && i.length && La(a, i, l, o[o.length - 1], 0)) o[o.length - 1] = c;
5263      else {
5264        o.length && (o[o.length - 1] = Ba(o[o.length - 1], i.length));
5265        let u = Pa(l, a);
5266        o.push(u), s = s.matchType(u.type), i = a;
5267      }
5268    }), o) return b.from(o);
5269  }
5270  return n2;
5271}
5272function Pa(n2, e, t = 0) {
5273  for (let r = e.length - 1; r >= t; r--) n2 = e[r].create(null, b.from(n2));
5274  return n2;
5275}
5276function La(n2, e, t, r, s) {
5277  if (s < n2.length && s < e.length && n2[s] == e[s]) {
5278    let i = La(n2, e, t, r.lastChild, s + 1);
5279    if (i) return r.copy(r.content.replaceChild(r.childCount - 1, i));
5280    if (r.contentMatchAt(r.childCount).matchType(s == n2.length - 1 ? t.type : n2[s + 1])) return r.copy(r.content.append(b.from(Pa(t, n2, s + 1))));
5281  }
5282}
5283function Ba(n2, e) {
5284  if (e == 0) return n2;
5285  let t = n2.content.replaceChild(n2.childCount - 1, Ba(n2.lastChild, e - 1)), r = n2.contentMatchAt(n2.childCount).fillBefore(b.empty, true);
5286  return n2.copy(t.append(r));
5287}
5288function $s(n2, e, t, r, s, i) {
5289  let o = e < 0 ? n2.firstChild : n2.lastChild, l = o.content;
5290  return n2.childCount > 1 && (i = 0), s < r - 1 && (l = $s(l, e, t, r, s + 1, i)), s >= t && (l = e < 0 ? o.contentMatchAt(0).fillBefore(l, i <= s).append(l) : l.append(o.contentMatchAt(o.childCount).fillBefore(b.empty, true))), n2.replaceChild(e < 0 ? 0 : n2.childCount - 1, o.copy(l));
5291}
5292function Ro(n2, e, t) {
5293  return e < n2.openStart && (n2 = new w($s(n2.content, -1, e, n2.openStart, 0, n2.openEnd), e, n2.openEnd)), t < n2.openEnd && (n2 = new w($s(n2.content, 1, t, n2.openEnd, 0, 0), n2.openStart, t)), n2;
5294}
5295const za = { thead: ["table"], tbody: ["table"], tfoot: ["table"], caption: ["table"], colgroup: ["table"], col: ["table", "colgroup"], tr: ["table", "tbody"], td: ["table", "tbody", "tr"], th: ["table", "tbody", "tr"] };
5296let Po = null;
5297function $a() {
5298  return Po || (Po = document.implementation.createHTMLDocument("title"));
5299}
5300let cs = null;
5301function Lf(n2) {
5302  let e = window.trustedTypes;
5303  return e ? (cs || (cs = e.defaultPolicy || e.createPolicy("ProseMirrorClipboard", { createHTML: (t) => t })), cs.createHTML(n2)) : n2;
5304}
5305function Bf(n2) {
5306  let e = /^(\s*<meta [^>]*>)*/.exec(n2);
5307  e && (n2 = n2.slice(e[0].length));
5308  let t = $a().createElement("div"), r = /<([a-z][^>\s]+)/i.exec(n2), s;
5309  if ((s = r && za[r[1].toLowerCase()]) && (n2 = s.map((i) => "<" + i + ">").join("") + n2 + s.map((i) => "</" + i + ">").reverse().join("")), t.innerHTML = Lf(n2), s) for (let i = 0; i < s.length; i++) t = t.querySelector(s[i]) || t;
5310  return t;
5311}
5312function zf(n2) {
5313  let e = n2.querySelectorAll(ee ? "span:not([class]):not([style])" : "span.Apple-converted-space");
5314  for (let t = 0; t < e.length; t++) {
5315    let r = e[t];
5316    r.childNodes.length == 1 && r.textContent == "\xA0" && r.parentNode && r.parentNode.replaceChild(n2.ownerDocument.createTextNode(" "), r);
5317  }
5318}
5319function $f(n2, e) {
5320  if (!n2.size) return n2;
5321  let t = n2.content.firstChild.type.schema, r;
5322  try {
5323    r = JSON.parse(e);
5324  } catch {
5325    return n2;
5326  }
5327  let { content: s, openStart: i, openEnd: o } = n2;
5328  for (let l = r.length - 2; l >= 0; l -= 2) {
5329    let a = t.nodes[r[l]];
5330    if (!a || a.hasRequiredAttrs()) break;
5331    s = b.from(a.create(r[l + 1], s)), i++, o++;
5332  }
5333  return new w(s, i, o);
5334}
5335const ie = {}, oe = {}, Ff = { touchstart: true, touchmove: true };
5336class Vf {
5337  constructor() {
5338    this.shiftKey = false, this.mouseDown = null, this.lastKeyCode = null, this.lastKeyCodeTime = 0, this.lastClick = { time: 0, x: 0, y: 0, type: "", button: 0 }, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastIOSEnter = 0, this.lastIOSEnterFallbackTimeout = -1, this.lastFocus = 0, this.lastTouch = 0, this.lastChromeDelete = 0, this.composing = false, this.compositionNode = null, this.composingTimeout = -1, this.compositionNodes = [], this.compositionEndedAt = -2e8, this.compositionID = 1, this.badSafariComposition = false, this.compositionPendingChanges = 0, this.domChangeCount = 0, this.eventHandlers = /* @__PURE__ */ Object.create(null), this.hideSelectionGuard = null;
5339  }
5340}
5341function Hf(n2) {
5342  for (let e in ie) {
5343    let t = ie[e];
5344    n2.dom.addEventListener(e, n2.input.eventHandlers[e] = (r) => {
5345      jf(n2, r) && !pi(n2, r) && (n2.editable || !(r.type in oe)) && t(n2, r);
5346    }, Ff[e] ? { passive: true } : void 0);
5347  }
5348  ne && n2.dom.addEventListener("input", () => null), Fs(n2);
5349}
5350function Qe(n2, e) {
5351  n2.input.lastSelectionOrigin = e, n2.input.lastSelectionTime = Date.now();
5352}
5353function _f(n2) {
5354  n2.domObserver.stop();
5355  for (let e in n2.input.eventHandlers) n2.dom.removeEventListener(e, n2.input.eventHandlers[e]);
5356  clearTimeout(n2.input.composingTimeout), clearTimeout(n2.input.lastIOSEnterFallbackTimeout);
5357}
5358function Fs(n2) {
5359  n2.someProp("handleDOMEvents", (e) => {
5360    for (let t in e) n2.input.eventHandlers[t] || n2.dom.addEventListener(t, n2.input.eventHandlers[t] = (r) => pi(n2, r));
5361  });
5362}
5363function pi(n2, e) {
5364  return n2.someProp("handleDOMEvents", (t) => {
5365    let r = t[e.type];
5366    return r ? r(n2, e) || e.defaultPrevented : false;
5367  });
5368}
5369function jf(n2, e) {
5370  if (!e.bubbles) return true;
5371  if (e.defaultPrevented) return false;
5372  for (let t = e.target; t != n2.dom; t = t.parentNode) if (!t || t.nodeType == 11 || t.pmViewDesc && t.pmViewDesc.stopEvent(e)) return false;
5373  return true;
5374}
5375function Wf(n2, e) {
5376  !pi(n2, e) && ie[e.type] && (n2.editable || !(e.type in oe)) && ie[e.type](n2, e);
5377}
5378oe.keydown = (n2, e) => {
5379  let t = e;
5380  if (n2.input.shiftKey = t.keyCode == 16 || t.shiftKey, !Va(n2, t) && (n2.input.lastKeyCode = t.keyCode, n2.input.lastKeyCodeTime = Date.now(), !(Le && ee && t.keyCode == 13))) if (t.keyCode != 229 && n2.domObserver.forceFlush(), Ft && t.keyCode == 13 && !t.ctrlKey && !t.altKey && !t.metaKey) {
5381    let r = Date.now();
5382    n2.input.lastIOSEnter = r, n2.input.lastIOSEnterFallbackTimeout = setTimeout(() => {
5383      n2.input.lastIOSEnter == r && (n2.someProp("handleKeyDown", (s) => s(n2, ut(13, "Enter"))), n2.input.lastIOSEnter = 0);
5384    }, 200);
5385  } else n2.someProp("handleKeyDown", (r) => r(n2, t)) || Df(n2, t) ? t.preventDefault() : Qe(n2, "key");
5386};
5387oe.keyup = (n2, e) => {
5388  e.keyCode == 16 && (n2.input.shiftKey = false);
5389};
5390oe.keypress = (n2, e) => {
5391  let t = e;
5392  if (Va(n2, t) || !t.charCode || t.ctrlKey && !t.altKey || ge && t.metaKey) return;
5393  if (n2.someProp("handleKeyPress", (s) => s(n2, t))) {
5394    t.preventDefault();
5395    return;
5396  }
5397  let r = n2.state.selection;
5398  if (!(r instanceof I) || !r.$from.sameParent(r.$to)) {
5399    let s = String.fromCharCode(t.charCode), i = () => n2.state.tr.insertText(s).scrollIntoView();
5400    !/[\r\n]/.test(s) && !n2.someProp("handleTextInput", (o) => o(n2, r.$from.pos, r.$to.pos, s, i)) && n2.dispatch(i()), t.preventDefault();
5401  }
5402};
5403function Fr(n2) {
5404  return { left: n2.clientX, top: n2.clientY };
5405}
5406function Uf(n2, e) {
5407  let t = e.x - n2.clientX, r = e.y - n2.clientY;
5408  return t * t + r * r < 100;
5409}
5410function mi(n2, e, t, r, s) {
5411  if (r == -1) return false;
5412  let i = n2.state.doc.resolve(r);
5413  for (let o = i.depth + 1; o > 0; o--) if (n2.someProp(e, (l) => o > i.depth ? l(n2, t, i.nodeAfter, i.before(o), s, true) : l(n2, t, i.node(o), i.before(o), s, false))) return true;
5414  return false;
5415}
5416function Lt(n2, e, t) {
5417  if (n2.focused || n2.focus(), n2.state.selection.eq(e)) return;
5418  let r = n2.state.tr.setSelection(e);
5419  r.setMeta("pointer", true), n2.dispatch(r);
5420}
5421function Kf(n2, e) {
5422  if (e == -1) return false;
5423  let t = n2.state.doc.resolve(e), r = t.nodeAfter;
5424  return r && r.isAtom && T.isSelectable(r) ? (Lt(n2, new T(t)), true) : false;
5425}
5426function qf(n2, e) {
5427  if (e == -1) return false;
5428  let t = n2.state.selection, r, s;
5429  t instanceof T && (r = t.node);
5430  let i = n2.state.doc.resolve(e);
5431  for (let o = i.depth + 1; o > 0; o--) {
5432    let l = o > i.depth ? i.nodeAfter : i.node(o);
5433    if (T.isSelectable(l)) {
5434      r && t.$from.depth > 0 && o >= t.$from.depth && i.before(t.$from.depth + 1) == t.$from.pos ? s = i.before(t.$from.depth) : s = i.before(o);
5435      break;
5436    }
5437  }
5438  return s != null ? (Lt(n2, T.create(n2.state.doc, s)), true) : false;
5439}
5440function Jf(n2, e, t, r, s) {
5441  return mi(n2, "handleClickOn", e, t, r) || n2.someProp("handleClick", (i) => i(n2, e, r)) || (s ? qf(n2, t) : Kf(n2, t));
5442}
5443function Gf(n2, e, t, r) {
5444  return mi(n2, "handleDoubleClickOn", e, t, r) || n2.someProp("handleDoubleClick", (s) => s(n2, e, r));
5445}
5446function Yf(n2, e, t, r) {
5447  return mi(n2, "handleTripleClickOn", e, t, r) || n2.someProp("handleTripleClick", (s) => s(n2, e, r)) || Qf(n2, t, r);
5448}
5449function Qf(n2, e, t) {
5450  if (t.button != 0) return false;
5451  let r = n2.state.doc;
5452  if (e == -1) return r.inlineContent ? (Lt(n2, I.create(r, 0, r.content.size)), true) : false;
5453  let s = r.resolve(e);
5454  for (let i = s.depth + 1; i > 0; i--) {
5455    let o = i > s.depth ? s.nodeAfter : s.node(i), l = s.before(i);
5456    if (o.inlineContent) Lt(n2, I.create(r, l + 1, l + 1 + o.content.size));
5457    else if (T.isSelectable(o)) Lt(n2, T.create(r, l));
5458    else continue;
5459    return true;
5460  }
5461}
5462function gi(n2) {
5463  return Xn(n2);
5464}
5465const Fa = ge ? "metaKey" : "ctrlKey";
5466ie.mousedown = (n2, e) => {
5467  let t = e;
5468  n2.input.shiftKey = t.shiftKey;
5469  let r = gi(n2), s = Date.now(), i = "singleClick";
5470  s - n2.input.lastClick.time < 500 && Uf(t, n2.input.lastClick) && !t[Fa] && n2.input.lastClick.button == t.button && (n2.input.lastClick.type == "singleClick" ? i = "doubleClick" : n2.input.lastClick.type == "doubleClick" && (i = "tripleClick")), n2.input.lastClick = { time: s, x: t.clientX, y: t.clientY, type: i, button: t.button };
5471  let o = n2.posAtCoords(Fr(t));
5472  o && (i == "singleClick" ? (n2.input.mouseDown && n2.input.mouseDown.done(), n2.input.mouseDown = new Xf(n2, o, t, !!r)) : (i == "doubleClick" ? Gf : Yf)(n2, o.pos, o.inside, t) ? t.preventDefault() : Qe(n2, "pointer"));
5473};
5474class Xf {
5475  constructor(e, t, r, s) {
5476    this.view = e, this.pos = t, this.event = r, this.flushed = s, this.delayedSelectionSync = false, this.mightDrag = null, this.startDoc = e.state.doc, this.selectNode = !!r[Fa], this.allowDefault = r.shiftKey;
5477    let i, o;
5478    if (t.inside > -1) i = e.state.doc.nodeAt(t.inside), o = t.inside;
5479    else {
5480      let u = e.state.doc.resolve(t.pos);
5481      i = u.parent, o = u.depth ? u.before() : 0;
5482    }
5483    const l = s ? null : r.target, a = l ? e.docView.nearestDesc(l, true) : null;
5484    this.target = a && a.nodeDOM.nodeType == 1 ? a.nodeDOM : null;
5485    let { selection: c } = e.state;
5486    (r.button == 0 && i.type.spec.draggable && i.type.spec.selectable !== false || c instanceof T && c.from <= o && c.to > o) && (this.mightDrag = { node: i, pos: o, addAttr: !!(this.target && !this.target.draggable), setUneditable: !!(this.target && be && !this.target.hasAttribute("contentEditable")) }), this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable) && (this.view.domObserver.stop(), this.mightDrag.addAttr && (this.target.draggable = true), this.mightDrag.setUneditable && setTimeout(() => {
5487      this.view.input.mouseDown == this && this.target.setAttribute("contentEditable", "false");
5488    }, 20), this.view.domObserver.start()), e.root.addEventListener("mouseup", this.up = this.up.bind(this)), e.root.addEventListener("mousemove", this.move = this.move.bind(this)), Qe(e, "pointer");
5489  }
5490  done() {
5491    this.view.root.removeEventListener("mouseup", this.up), this.view.root.removeEventListener("mousemove", this.move), this.mightDrag && this.target && (this.view.domObserver.stop(), this.mightDrag.addAttr && this.target.removeAttribute("draggable"), this.mightDrag.setUneditable && this.target.removeAttribute("contentEditable"), this.view.domObserver.start()), this.delayedSelectionSync && setTimeout(() => ze(this.view)), this.view.input.mouseDown = null;
5492  }
5493  up(e) {
5494    if (this.done(), !this.view.dom.contains(e.target)) return;
5495    let t = this.pos;
5496    this.view.state.doc != this.startDoc && (t = this.view.posAtCoords(Fr(e))), this.updateAllowDefault(e), this.allowDefault || !t ? Qe(this.view, "pointer") : Jf(this.view, t.pos, t.inside, e, this.selectNode) ? e.preventDefault() : e.button == 0 && (this.flushed || ne && this.mightDrag && !this.mightDrag.node.isAtom || ee && !this.view.state.selection.visible && Math.min(Math.abs(t.pos - this.view.state.selection.from), Math.abs(t.pos - this.view.state.selection.to)) <= 2) ? (Lt(this.view, R.near
5496(this.view.state.doc.resolve(t.pos))), e.preventDefault()) : Qe(this.view, "pointer");
5497  }
5498  move(e) {
5499    this.updateAllowDefault(e), Qe(this.view, "pointer"), e.buttons == 0 && this.done();
5500  }
5501  updateAllowDefault(e) {
5502    !this.allowDefault && (Math.abs(this.event.x - e.clientX) > 4 || Math.abs(this.event.y - e.clientY) > 4) && (this.allowDefault = true);
5503  }
5504}
5505ie.touchstart = (n2) => {
5506  n2.input.lastTouch = Date.now(), gi(n2), Qe(n2, "pointer");
5507};
5508ie.touchmove = (n2) => {
5509  n2.input.lastTouch = Date.now(), Qe(n2, "pointer");
5510};
5511ie.contextmenu = (n2) => gi(n2);
5512function Va(n2, e) {
5513  return n2.composing ? true : ne && Math.abs(e.timeStamp - n2.input.compositionEndedAt) < 500 ? (n2.input.compositionEndedAt = -2e8, true) : false;
5514}
5515const Zf = Le ? 5e3 : -1;
5516oe.compositionstart = oe.compositionupdate = (n2) => {
5517  if (!n2.composing) {
5518    n2.domObserver.flush();
5519    let { state: e } = n2, t = e.selection.$to;
5520    if (e.selection instanceof I && (e.storedMarks || !t.textOffset && t.parentOffset && t.nodeBefore.marks.some((r) => r.type.spec.inclusive === false) || ee && ya && eh(n2))) n2.markCursor = n2.state.storedMarks || t.marks(), Xn(n2, true), n2.markCursor = null;
5521    else if (Xn(n2, !e.selection.empty), be && e.selection.empty && t.parentOffset && !t.textOffset && t.nodeBefore.marks.length) {
5522      let r = n2.domSelectionRange();
5523      for (let s = r.focusNode, i = r.focusOffset; s && s.nodeType == 1 && i != 0; ) {
5524        let o = i < 0 ? s.lastChild : s.childNodes[i - 1];
5525        if (!o) break;
5526        if (o.nodeType == 3) {
5527          let l = n2.domSelection();
5528          l && l.collapse(o, o.nodeValue.length);
5529          break;
5530        } else s = o, i = -1;
5531      }
5532    }
5533    n2.input.composing = true;
5534  }
5535  Ha(n2, Zf);
5536};
5537function eh(n2) {
5538  let { focusNode: e, focusOffset: t } = n2.domSelectionRange();
5539  if (!e || e.nodeType != 1 || t >= e.childNodes.length) return false;
5540  let r = e.childNodes[t];
5541  return r.nodeType == 1 && r.contentEditable == "false";
5542}
5543oe.compositionend = (n2, e) => {
5544  n2.composing && (n2.input.composing = false, n2.input.compositionEndedAt = e.timeStamp, n2.input.compositionPendingChanges = n2.domObserver.pendingRecords().length ? n2.input.compositionID : 0, n2.input.compositionNode = null, n2.input.badSafariComposition ? n2.domObserver.forceFlush() : n2.input.compositionPendingChanges && Promise.resolve().then(() => n2.domObserver.flush()), n2.input.compositionID++, Ha(n2, 20));
5545};
5546function Ha(n2, e) {
5547  clearTimeout(n2.input.composingTimeout), e > -1 && (n2.input.composingTimeout = setTimeout(() => Xn(n2), e));
5548}
5549function _a(n2) {
5550  for (n2.composing && (n2.input.composing = false, n2.input.compositionEndedAt = nh()); n2.input.compositionNodes.length > 0; ) n2.input.compositionNodes.pop().markParentsDirty();
5551}
5552function th(n2) {
5553  let e = n2.domSelectionRange();
5554  if (!e.focusNode) return null;
5555  let t = Kd(e.focusNode, e.focusOffset), r = qd(e.focusNode, e.focusOffset);
5556  if (t && r && t != r) {
5557    let s = r.pmViewDesc, i = n2.domObserver.lastChangedTextNode;
5558    if (t == i || r == i) return i;
5559    if (!s || !s.isText(r.nodeValue)) return r;
5560    if (n2.input.compositionNode == r) {
5561      let o = t.pmViewDesc;
5562      if (!(!o || !o.isText(t.nodeValue))) return r;
5563    }
5564  }
5565  return t || r;
5566}
5567function nh() {
5568  let n2 = document.createEvent("Event");
5569  return n2.initEvent("event", true, true), n2.timeStamp;
5570}
5571function Xn(n2, e = false) {
5572  if (!(Le && n2.domObserver.flushingSoon >= 0)) {
5573    if (n2.domObserver.forceFlush(), _a(n2), e || n2.docView && n2.docView.dirty) {
5574      let t = di(n2), r = n2.state.selection;
5575      return t && !t.eq(r) ? n2.dispatch(n2.state.tr.setSelection(t)) : (n2.markCursor || e) && !r.$from.node(r.$from.sharedDepth(r.to)).inlineContent ? n2.dispatch(n2.state.tr.deleteSelection()) : n2.updateState(n2.state), true;
5576    }
5577    return false;
5578  }
5579}
5580function rh(n2, e) {
5581  if (!n2.dom.parentNode) return;
5582  let t = n2.dom.parentNode.appendChild(document.createElement("div"));
5583  t.appendChild(e), t.style.cssText = "position: fixed; left: -10000px; top: 10px";
5584  let r = getSelection(), s = document.createRange();
5585  s.selectNodeContents(e), n2.dom.blur(), r.removeAllRanges(), r.addRange(s), setTimeout(() => {
5586    t.parentNode && t.parentNode.removeChild(t), n2.focus();
5587  }, 50);
5588}
5589const gn = ce && Ze < 15 || Ft && Qd < 604;
5590ie.copy = oe.cut = (n2, e) => {
5591  let t = e, r = n2.state.selection, s = t.type == "cut";
5592  if (r.empty) return;
5593  let i = gn ? null : t.clipboardData, o = r.content(), { dom: l, text: a } = hi(n2, o);
5594  i ? (t.preventDefault(), i.clearData(), i.setData("text/html", l.innerHTML), i.setData("text/plain", a)) : rh(n2, l), s && n2.dispatch(n2.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut"));
5595};
5596function sh(n2) {
5597  return n2.openStart == 0 && n2.openEnd == 0 && n2.content.childCount == 1 ? n2.content.firstChild : null;
5598}
5599function ih(n2, e) {
5600  if (!n2.dom.parentNode) return;
5601  let t = n2.input.shiftKey || n2.state.selection.$from.parent.type.spec.code, r = n2.dom.parentNode.appendChild(document.createElement(t ? "textarea" : "div"));
5602  t || (r.contentEditable = "true"), r.style.cssText = "position: fixed; left: -10000px; top: 10px", r.focus();
5603  let s = n2.input.shiftKey && n2.input.lastKeyCode != 45;
5604  setTimeout(() => {
5605    n2.focus(), r.parentNode && r.parentNode.removeChild(r), t ? yn(n2, r.value, null, s, e) : yn(n2, r.textContent, r.innerHTML, s, e);
5606  }, 50);
5607}
5608function yn(n2, e, t, r, s) {
5609  let i = Ra(n2, e, t, r, n2.state.selection.$from);
5610  if (n2.someProp("handlePaste", (a) => a(n2, s, i || w.empty))) return true;
5611  if (!i) return false;
5612  let o = sh(i), l = o ? n2.state.tr.replaceSelectionWith(o, r) : n2.state.tr.replaceSelection(i);
5613  return n2.dispatch(l.scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste")), true;
5614}
5615function ja(n2) {
5616  let e = n2.getData("text/plain") || n2.getData("Text");
5617  if (e) return e;
5618  let t = n2.getData("text/uri-list");
5619  return t ? t.replace(/\r?\n/g, " ") : "";
5620}
5621oe.paste = (n2, e) => {
5622  let t = e;
5623  if (n2.composing && !Le) return;
5624  let r = gn ? null : t.clipboardData, s = n2.input.shiftKey && n2.input.lastKeyCode != 45;
5625  r && yn(n2, ja(r), r.getData("text/html"), s, t) ? t.preventDefault() : ih(n2, t);
5626};
5627class Wa {
5628  constructor(e, t, r) {
5629    this.slice = e, this.move = t, this.node = r;
5630  }
5631}
5632const oh = ge ? "altKey" : "ctrlKey";
5633function Ua(n2, e) {
5634  let t = n2.someProp("dragCopies", (r) => !r(e));
5635  return t ?? !e[oh];
5636}
5637ie.dragstart = (n2, e) => {
5638  let t = e, r = n2.input.mouseDown;
5639  if (r && r.done(), !t.dataTransfer) return;
5640  let s = n2.state.selection, i = s.empty ? null : n2.posAtCoords(Fr(t)), o;
5641  if (!(i && i.pos >= s.from && i.pos <= (s instanceof T ? s.to - 1 : s.to))) {
5642    if (r && r.mightDrag) o = T.create(n2.state.doc, r.mightDrag.pos);
5643    else if (t.target && t.target.nodeType == 1) {
5644      let d = n2.docView.nearestDesc(t.target, true);
5645      d && d.node.type.spec.draggable && d != n2.docView && (o = T.create(n2.state.doc, d.posBefore));
5646    }
5647  }
5648  let l = (o || n2.state.selection).content(), { dom: a, text: c, slice: u } = hi(n2, l);
5649  (!t.dataTransfer.files.length || !ee || ga > 120) && t.dataTransfer.clearData(), t.dataTransfer.setData(gn ? "Text" : "text/html", a.innerHTML), t.dataTransfer.effectAllowed = "copyMove", gn || t.dataTransfer.setData("text/plain", c), n2.dragging = new Wa(u, Ua(n2, t), o);
5650};
5651ie.dragend = (n2) => {
5652  let e = n2.dragging;
5653  window.setTimeout(() => {
5654    n2.dragging == e && (n2.dragging = null);
5655  }, 50);
5656};
5657oe.dragover = oe.dragenter = (n2, e) => e.preventDefault();
5658oe.drop = (n2, e) => {
5659  try {
5660    lh(n2, e, n2.dragging);
5661  } finally {
5662    n2.dragging = null;
5663  }
5664};
5665function lh(n2, e, t) {
5666  if (!e.dataTransfer) return;
5667  let r = n2.posAtCoords(Fr(e));
5668  if (!r) return;
5669  let s = n2.state.doc.resolve(r.pos), i = t && t.slice;
5670  i ? n2.someProp("transformPasted", (h) => {
5671    i = h(i, n2, false);
5672  }) : i = Ra(n2, ja(e.dataTransfer), gn ? null : e.dataTransfer.getData("text/html"), false, s);
5673  let o = !!(t && Ua(n2, e));
5674  if (n2.someProp("handleDrop", (h) => h(n2, e, i || w.empty, o))) {
5675    e.preventDefault();
5676    return;
5677  }
5678  if (!i) return;
5679  e.preventDefault();
5680  let l = i ? Gl(n2.state.doc, s.pos, i) : s.pos;
5681  l == null && (l = s.pos);
5682  let a = n2.state.tr;
5683  if (o) {
5684    let { node: h } = t;
5685    h ? h.replace(a) : a.deleteSelection();
5686  }
5687  let c = a.mapping.map(l), u = i.openStart == 0 && i.openEnd == 0 && i.content.childCount == 1, d = a.doc;
5688  if (u ? a.replaceRangeWith(c, c, i.content.firstChild) : a.replaceRange(c, c, i), a.doc.eq(d)) return;
5689  let f = a.doc.resolve(c);
5690  if (u && T.isSelectable(i.content.firstChild) && f.nodeAfter && f.nodeAfter.sameMarkup(i.content.firstChild)) a.setSelection(new T(f));
5691  else {
5692    let h = a.mapping.map(l);
5693    a.mapping.maps[a.mapping.maps.length - 1].forEach((p, m, g, y) => h = y), a.setSelection(fi(n2, f, a.doc.resolve(h)));
5694  }
5695  n2.focus(), n2.dispatch(a.setMeta("uiEvent", "drop"));
5696}
5697ie.focus = (n2) => {
5698  n2.input.lastFocus = Date.now(), n2.focused || (n2.domObserver.stop(), n2.dom.classList.add("ProseMirror-focused"), n2.domObserver.start(), n2.focused = true, setTimeout(() => {
5699    n2.docView && n2.hasFocus() && !n2.domObserver.currentSelection.eq(n2.domSelectionRange()) && ze(n2);
5700  }, 20));
5701};
5702ie.blur = (n2, e) => {
5703  let t = e;
5704  n2.focused && (n2.domObserver.stop(), n2.dom.classList.remove("ProseMirror-focused"), n2.domObserver.start(), t.relatedTarget && n2.dom.contains(t.relatedTarget) && n2.domObserver.currentSelection.clear(), n2.focused = false);
5705};
5706ie.beforeinput = (n2, e) => {
5707  if (ee && Le && e.inputType == "deleteContentBackward") {
5708    n2.domObserver.flushSoon();
5709    let { domChangeCount: r }
5709 = n2.input;
5710    setTimeout(() => {
5711      if (n2.input.domChangeCount != r || (n2.dom.blur(), n2.focus(), n2.someProp("handleKeyDown", (i) => i(n2, ut(8, "Backspace"))))) return;
5712      let { $cursor: s } = n2.state.selection;
5713      s && s.pos > 0 && n2.dispatch(n2.state.tr.delete(s.pos - 1, s.pos).scrollIntoView());
5714    }, 50);
5715  }
5716};
5717for (let n2 in oe) ie[n2] = oe[n2];
5718function bn(n2, e) {
5719  if (n2 == e) return true;
5720  for (let t in n2) if (n2[t] !== e[t]) return false;
5721  for (let t in e) if (!(t in n2)) return false;
5722  return true;
5723}
5724class Zn {
5725  constructor(e, t) {
5726    this.toDOM = e, this.spec = t || yt, this.side = this.spec.side || 0;
5727  }
5728  map(e, t, r, s) {
5729    let { pos: i, deleted: o } = e.mapResult(t.from + s, this.side < 0 ? -1 : 1);
5730    return o ? null : new se(i - r, i - r, this);
5731  }
5732  valid() {
5733    return true;
5734  }
5735  eq(e) {
5736    return this == e || e instanceof Zn && (this.spec.key && this.spec.key == e.spec.key || this.toDOM == e.toDOM && bn(this.spec, e.spec));
5737  }
5738  destroy(e) {
5739    this.spec.destroy && this.spec.destroy(e);
5740  }
5741}
5742class tt {
5743  constructor(e, t) {
5744    this.attrs = e, this.spec = t || yt;
5745  }
5746  map(e, t, r, s) {
5747    let i = e.map(t.from + s, this.spec.inclusiveStart ? -1 : 1) - r, o = e.map(t.to + s, this.spec.inclusiveEnd ? 1 : -1) - r;
5748    return i >= o ? null : new se(i, o, this);
5749  }
5750  valid(e, t) {
5751    return t.from < t.to;
5752  }
5753  eq(e) {
5754    return this == e || e instanceof tt && bn(this.attrs, e.attrs) && bn(this.spec, e.spec);
5755  }
5756  static is(e) {
5757    return e.type instanceof tt;
5758  }
5759  destroy() {
5760  }
5761}
5762class yi {
5763  constructor(e, t) {
5764    this.attrs = e, this.spec = t || yt;
5765  }
5766  map(e, t, r, s) {
5767    let i = e.mapResult(t.from + s, 1);
5768    if (i.deleted) return null;
5769    let o = e.mapResult(t.to + s, -1);
5770    return o.deleted || o.pos <= i.pos ? null : new se(i.pos - r, o.pos - r, this);
5771  }
5772  valid(e, t) {
5773    let { index: r, offset: s } = e.content.findIndex(t.from), i;
5774    return s == t.from && !(i = e.child(r)).isText && s + i.nodeSize == t.to;
5775  }
5776  eq(e) {
5777    return this == e || e instanceof yi && bn(this.attrs, e.attrs) && bn(this.spec, e.spec);
5778  }
5779  destroy() {
5780  }
5781}
5782class se {
5783  constructor(e, t, r) {
5784    this.from = e, this.to = t, this.type = r;
5785  }
5786  copy(e, t) {
5787    return new se(e, t, this.type);
5788  }
5789  eq(e, t = 0) {
5790    return this.type.eq(e.type) && this.from + t == e.from && this.to + t == e.to;
5791  }
5792  map(e, t, r) {
5793    return this.type.map(e, this, t, r);
5794  }
5795  static widget(e, t, r) {
5796    return new se(e, e, new Zn(t, r));
5797  }
5798  static inline(e, t, r, s) {
5799    return new se(e, t, new tt(r, s));
5800  }
5801  static node(e, t, r, s) {
5802    return new se(e, t, new yi(r, s));
5803  }
5804  get spec() {
5805    return this.type.spec;
5806  }
5807  get inline() {
5808    return this.type instanceof tt;
5809  }
5810  get widget() {
5811    return this.type instanceof Zn;
5812  }
5813}
5814const It = [], yt = {};
5815class $ {
5816  constructor(e, t) {
5817    this.local = e.length ? e : It, this.children = t.length ? t : It;
5818  }
5819  static create(e, t) {
5820    return t.length ? er(t, e, 0, yt) : te;
5821  }
5822  find(e, t, r) {
5823    let s = [];
5824    return this.findInner(e ?? 0, t ?? 1e9, s, 0, r), s;
5825  }
5826  findInner(e, t, r, s, i) {
5827    for (let o = 0; o < this.local.length; o++) {
5828      let l = this.local[o];
5829      l.from <= t && l.to >= e && (!i || i(l.spec)) && r.push(l.copy(l.from + s, l.to + s));
5830    }
5831    for (let o = 0; o < this.children.length; o += 3) if (this.children[o] < t && this.children[o + 1] > e) {
5832      let l = this.children[o] + 1;
5833      this.children[o + 2].findInner(e - l, t - l, r, s + l, i);
5834    }
5835  }
5836  map(e, t, r) {
5837    return this == te || e.maps.length == 0 ? this : this.mapInner(e, t, 0, 0, r || yt);
5838  }
5839  mapInner(e, t, r, s, i) {
5840    let o;
5841    for (let l = 0; l < this.local.length; l++) {
5842      let a = this.local[l].map(e, r, s);
5843      a && a.type.valid(t, a) ? (o || (o = [])).push(a) : i.onRemove && i.onRemove(this.local[l].spec);
5844    }
5845    return this.children.length ? ah(this.children, o || [], e, t, r, s, i) : o ? new $(o.sort(bt), It) : te;
5846  }
5847  add(e, t) {
5848    return t.length ? this == te ? $.create(e, t) : this.addInner(e, t, 0) : this;
5849  }
5850  addInner(e, t, r) {
5851    let s, i = 0;
5852    e.forEach((l, a) => {
5853      let c = a + r, u;
5854      if (u = qa(t, l, c)) {
5855        for (s || (s = this.children.slice()); i < s.length && s[i] < a; ) i += 3;
5856        s[i] == a ? s[i + 2] = s[i + 2].addInner(l, u, c + 1) : s.splice(i, 0, a, a + l.nodeSize, er(u, l, c + 1, yt)), i += 3;
5857      }
5858    });
5859    let o = Ka(i ? Ja(t) : t, -r);
5860    for (let l = 0; l < o.length; l++) o[l].type.valid(e, o[l]) || o.splice(l--, 1);
5861    return new $(o.length ? this.local.concat(o).sort(bt) : this.local, s || this.children);
5862  }
5863  remove(e) {
5864    return e.length == 0 || this == te ? this : this.removeInner(e, 0);
5865  }
5866  removeInner(e, t) {
5867    let r = this.children, s = this.local;
5868    for (let i = 0; i < r.length; i += 3) {
5869      let o, l = r[i] + t, a = r[i + 1] + t;
5870      for (let u = 0, d; u < e.length; u++) (d = e[u]) && d.from > l && d.to < a && (e[u] = null, (o || (o = [])).push(d));
5871      if (!o) continue;
5872      r == this.children && (r = this.children.slice());
5873      let c = r[i + 2].removeInner(o, l + 1);
5874      c != te ? r[i + 2] = c : (r.splice(i, 3), i -= 3);
5875    }
5876    if (s.length) {
5877      for (let i = 0, o; i < e.length; i++) if (o = e[i]) for (let l = 0; l < s.length; l++) s[l].eq(o, t) && (s == this.local && (s = this.local.slice()), s.splice(l--, 1));
5878    }
5879    return r == this.children && s == this.local ? this : s.length || r.length ? new $(s, r) : te;
5880  }
5881  forChild(e, t) {
5882    if (this == te) return this;
5883    if (t.isLeaf) return $.empty;
5884    let r, s;
5885    for (let l = 0; l < this.children.length; l += 3) if (this.children[l] >= e) {
5886      this.children[l] == e && (r = this.children[l + 2]);
5887      break;
5888    }
5889    let i = e + 1, o = i + t.content.size;
5890    for (let l = 0; l < this.local.length; l++) {
5891      let a = this.local[l];
5892      if (a.from < o && a.to > i && a.type instanceof tt) {
5893        let c = Math.max(i, a.from) - i, u = Math.min(o, a.to) - i;
5894        c < u && (s || (s = [])).push(a.copy(c, u));
5895      }
5896    }
5897    if (s) {
5898      let l = new $(s.sort(bt), It);
5899      return r ? new qe([l, r]) : l;
5900    }
5901    return r || te;
5902  }
5903  eq(e) {
5904    if (this == e) return true;
5905    if (!(e instanceof $) || this.local.length != e.local.length || this.children.length != e.children.length) return false;
5906    for (let t = 0; t < this.local.length; t++) if (!this.local[t].eq(e.local[t])) return false;
5907    for (let t = 0; t < this.children.length; t += 3) if (this.children[t] != e.children[t] || this.children[t + 1] != e.children[t + 1] || !this.children[t + 2].eq(e.children[t + 2])) return false;
5908    return true;
5909  }
5910  locals(e) {
5911    return bi(this.localsInner(e));
5912  }
5913  localsInner(e) {
5914    if (this == te) return It;
5915    if (e.inlineContent || !this.local.some(tt.is)) return this.local;
5916    let t = [];
5917    for (let r = 0; r < this.local.length; r++) this.local[r].type instanceof tt || t.push(this.local[r]);
5918    return t;
5919  }
5920  forEachSet(e) {
5921    e(this);
5922  }
5923}
5924$.empty = new $([], []);
5925$.removeOverlap = bi;
5926const te = $.empty;
5927class qe {
5928  constructor(e) {
5929    this.members = e;
5930  }
5931  map(e, t) {
5932    const r = this.members.map((s) => s.map(e, t, yt));
5933    return qe.from(r);
5934  }
5935  forChild(e, t) {
5936    if (t.isLeaf) return $.empty;
5937    let r = [];
5938    for (let s = 0; s < this.members.length; s++) {
5939      let i = this.members[s].forChild(e, t);
5940      i != te && (i instanceof qe ? r = r.concat(i.members) : r.push(i));
5941    }
5942    return qe.from(r);
5943  }
5944  eq(e) {
5945    if (!(e instanceof qe) || e.members.length != this.members.length) return false;
5946    for (let t = 0; t < this.members.length; t++) if (!this.members[t].eq(e.members[t])) return false;
5947    return true;
5948  }
5949  locals(e) {
5950    let t, r = true;
5951    for (let s = 0; s < this.members.length; s++) {
5952      let i = this.members[s].localsInner(e);
5953      if (i.length) if (!t) t = i;
5954      else {
5955        r && (t = t.slice(), r = false);
5956        for (let o = 0; o < i.length; o++) t.push(i[o]);
5957      }
5958    }
5959    return t ? bi(r ? t : t.sort(bt)) : It;
5960  }
5961  static from(e) {
5962    switch (e.length) {
5963      case 0:
5964        return te;
5965      case 1:
5966        return e[0];
5967      default:
5968        return new qe(e.every((t) => t instanceof $) ? e : e.reduce((t, r) => t.concat(r instanceof $ ? r : r.members), []));
5969    }
5970  }
5971  forEachSet(e) {
5972    for (let t = 0; t < this.members.length; t++) this.members[t].forEachSet(e);
5973  }
5974}
5975function ah(n2, e, t, r, s, i, o) {
5976  let l = n2.slice();
5977  for (let c = 0, u = i; c < t.maps.length; c++) {
5978    let d = 0;
5979    t.maps[c].forEach((f, h, p, m) => {
5980      let g = m - p - (h - f);
5981      for (let y = 0; y < l.length; y += 3) {
5982        let x = l[y + 1];
5983        if (x < 0 || f > x + u - d) continue;
5984        let M = l[y] + u - d;
5985        h >= M ? l[y + 1] = f <= M ? -2 : -1 : f >= u && g && (l[y] += g, l[y + 1] += g);
5986      }
5987      d += g;
5988    }), u = t.maps[c].map(u, -1);
5989  }
5990  let a = false;
5991  for (let c = 0; c < l.length; c += 3) if (l[c + 1] < 0) {
5992    if (l[c + 1] == -2) {
5993      a = true, l[c + 1] = -1;
5994      continue;
5995    }
5996    let u = t.map(n2[c] + i), d = u - s;
5997    if (d < 0 || d >= r.content.size) {
5998      a = true;
5999      continue;
6000    }
6001    let f = t.map(n2[c + 1] + i, -1), h = f - s, { index: p, offset: m } = r.content.findIndex(d), g = r.maybeChild(p);
6002    if (g && m == d && m + g.nodeSize == h) {
6003      let y = l[c + 2].mapInner(t, g, u + 1, n2[c] + i + 1, o);
6004      y != te ? (l[c] = d, l[c + 1] = h, l[c + 2] = y) : (l[c + 1] = -2, a = true);
6005    } else a = true;
6006  }
6007  if (a) {
6008    let c = ch(l, n2, e, t, s, i, o), u = er(c, r, 0, o);
6009    e = u.local;
6010    for (let d = 0; d < l.length; d += 3) l[d + 1] < 0 && (l.splice(d, 3), d -= 3);
6011    for (let d = 0, f = 0; d < u.children.length; d += 3) {
6012      let h = u.children[d];
6013      for (; f < l.length && l[f] < h; ) f += 3;
6014      l.splice(f, 0, u.children[d], u.children[d + 1], u.children[d + 2]);
6015    }
6016  }
6017  return new $(e.sort(bt), l);
6018}
6019function Ka(n2, e) {
6020  if (!e || !n2.length) return n2;
6021  let t = [];
6022  for (let r = 0; r < n2.length; r++) {
6023    let s = n2[r];
6024    t.push(new se(s.from + e, s.to + e, s.type));
6025  }
6026  return t;
6027}
6028function ch(n2, e, t, r, s, i, o) {
6029  function l(a, c) {
6030    for (let u = 0; u < a.local.length; u++) {
6031      let d = a.local[u].map(r, s, c);
6032      d ? t.push(d) : o.onRemove && o.onRemove(a.local[u].spec);
6033    }
6034    for (let u = 0; u < a.children.length; u += 3) l(a.children[u + 2], a.children[u] + c + 1);
6035  }
6036  for (let a = 0; a < n2.length; a += 3) n2[a + 1] == -1 && l(n2[a + 2], e[a] + i + 1);
6037  return t;
6038}
6039function qa(n2, e, t) {
6040  if (e.isLeaf) return null;
6041  let r = t + e.nodeSize, s = null;
6042  for (let i = 0, o; i < n2.length; i++) (o = n2[i]) && o.from > t && o.to < r && ((s || (s = [])).push(o), n2[i] = null);
6043  return s;
6044}
6045function Ja(n2) {
6046  let e = [];
6047  for (let t = 0; t < n2.length; t++) n2[t] != null && e.push(n2[t]);
6048  return e;
6049}
6050function er(n2, e, t, r) {
6051  let s = [], i = false;
6052  e.forEach((l, a) => {
6053    let c = qa(n2, l, a + t);
6054    if (c) {
6055      i = true;
6056      let u = er(c, l, t + a + 1, r);
6057      u != te && s.push(a, a + l.nodeSize, u);
6058    }
6059  });
6060  let o = Ka(i ? Ja(n2) : n2, -t).sort(bt);
6061  for (let l = 0; l < o.length; l++) o[l].type.valid(e, o[l]) || (r.onRemove && r.onRemove(o[l].spec), o.splice(l--, 1));
6062  return o.length || s.length ? new $(o, s) : te;
6063}
6064function bt(n2, e) {
6065  return n2.from - e.from || n2.to - e.to;
6066}
6067function bi(n2) {
6068  let e = n2;
6069  for (let t = 0; t < e.length - 1; t++) {
6070    let r = e[t];
6071    if (r.from != r.to) for (let s = t + 1; s < e.length; s++) {
6072      let i = e[s];
6073      if (i.from == r.from) {
6074        i.to != r.to && (e == n2 && (e = n2.slice()), e[s] = i.copy(i.from, r.to), Lo(e, s + 1, i.copy(r.to, i.to)));
6075        continue;
6076      } else {
6077        i.from < r.to && (e == n2 && (e = n2.slice()), e[t] = r.copy(r.from, i.from), Lo(e, s, r.copy(i.from, r.to)));
6078        break;
6079      }
6080    }
6081  }
6082  return e;
6083}
6084function Lo(n2, e, t) {
6085  for (; e < n2.length && bt(t, n2[e]) > 0; ) e++;
6086  n2.splice(e, 0, t);
6087}
6088function us(n2) {
6089  let e = [];
6090  return n2.someProp("decorations", (t) => {
6091    let r = t(n2.state);
6092    r && r != te && e.push(r);
6093  }), n2.cursorWrapper && e.push($.create(n2.state.doc, [n2.cursorWrapper.deco])), qe.from(e);
6094}
6095const uh = { childList: true, characterData: true, characterDataOldValue: true, attributes: true, attributeOldValue: true, subtree: true }, dh = ce && Ze <= 11;
6096class fh {
6097  constructor() {
6098    this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0;
6099  }
6100  set(e) {
6101    this.anchorNode = e.anchorNode, this.anchorOffset = e.anchorOffset, this.focusNode = e.focusNode, this.focusOffset = e.focusOffset;
6102  }
6103  clear() {
6104    this.anchorNode = this.focusNode = null;
6105  }
6106  eq(e) {
6107    return e.anchorNode == this.anchorNode && e.anchorOffset == this.anchorOffset && e.focusNode == this.focusNode && e.focusOffset == this.focusOffset;
6108  }
6109}
6110class hh {
6111  constructor(e, t) {
6112    this.view = e, this.handleDOMChange = t, this.queue = [], this.flushingSoon = -1, this.observer = null, this.currentSelection = new fh(), this.onCharData = null, this.suppressingSelectionUpdates = false, this.lastChangedTextNode = null, this.observer = window.MutationObserver && new window.MutationObserver((r) => {
6113      for (let s = 0; s < r.length; s++) this.queue.push(r[s]);
6114      ce && Ze <= 11 && r.some((s) => s.type == "childList" && s.removedNodes.length || s.type == "characterData" && s.oldValue.length > s.target.nodeValue.length) ? this.flushSoon() : ne && e.composing && r.some((s) => s.type == "childList" && s.target.nodeName == "TR") ? (e.input.badSafariComposition = true, this.flushSoon()) : this.flush();
6115    }), dh && (this.onCharData = (r) => {
6116      this.queue.push({ target: r.target, type: "characterData", oldValue: r.prevValue }), this.flushSoon();
6117    }), this.onSelectionChange = this.onSelectionChange.bind(this);
6118  }
6119  flushSoon() {
6120    this.flushingSoon < 0 && (this.flushingSoon = window.setTimeout(() => {
6121      this.flushingSoon = -1, this.flush();
6122    }, 20));
6123  }
6124  forceFlush() {
6125    this.flushingSoon > -1 && (window.clearTimeout(this.flushingSoon), this.flushingSoon = -1, this.flush());
6126  }
6127  start() {
6128    this.observer && (this.observer.takeRecords(), this.observer.observe(this.view.dom, uh)), this.onCharData && this.view.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.connectSelection();
6129  }
6130  stop() {
6131    if (this.observer) {
6132      let e = this.observer.takeRecords();
6133      if (e.length) {
6134        for (let t = 0; t < e.length; t++) this.queue.push(e[t]);
6135        window.setTimeout(() => this.flush(), 20);
6136      }
6137      this.observer.disconnect();
6138    }
6139    this.onCharData && this.view.dom.removeEventListener("DOMCharacterDataModified", this.onCharData), this.disconnectSelection();
6140  }
6141  connectSelection() {
6142    this.view.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
6143  }
6144  disconnectSelection() {
6145    this.view.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
6146  }
6147  suppressSelectionUpdates() {
6148    this.suppressingSelectionUpdates = true, setTimeout(() => this.suppressingSelectionUpdates = false, 50);
6149  }
6150  onSelectionChange() {
6151    if (Eo(this.view)) {
6152      if (this.suppressingSelectionUpdates) return ze(this.view);
6153      if (ce && Ze <= 11 && !this.view.state.selection.empty) {
6154        let e = this.view.domSelectionRange();
6155        if (e.focusNode && wt(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset)) return this.flushSoon();
6156      }
6157      this.flush();
6158    }
6159  }
6160  setCurSelection() {
6161    this.currentSelection.set(this.view.domSelectionRange());
6162  }
6163  ignoreSelectionChange(e) {
6164    if (!e.focusNode) return true;
6165    let t = /* @__PURE__ */ new Set(), r;
6166    for (let i = e.focusNode; i; i = $t(i)) t.add(i);
6167    for (let i = e.anchorNode; i; i = $t(i)) if (t.has(i)) {
6168      r = i;
6169      break;
6170    }
6171    let s = r && this.view.docView.nearestDesc(r);
6172    if (s && s.ignoreMutation({ type: "selection", target: r.nodeType == 3 ? r.parentNode : r })) return this.setCurSelection(), true;
6173  }
6174  pendingRecords() {
6175    if (this.observer) for (let e of this.observer.takeRecords()) this.queue.push(e);
6176    return this.queue;
6177  }
6178  flush() {
6179    let { view: e } = this;
6180    if (!e.docView || this.flushingSoon > -1) return;
6181    let t = this.pendingRecords();
6182    t.length && (this.queue = []);
6183    let r = e.domSelectionRange(), s = !this.suppressingSelectionUpdates && !this.currentSelection.eq(r) && Eo(e) && !this.ignoreSelectionChange(r), i = -1, o = -1, l = false, a = [];
6184    if (e.editable) for (let u = 0; u < t.length; u++) {
6185      let d = this.registerMutation(t[u], a);
6186      d && (i = i < 0 ? d.from : Math.min(d.from, i), o = o < 0 ? d.to : Math.max(d.to, o), d.typeOver && (l = true));
6187    }
6188    if (a.some((u) => u.nodeName == "BR") && (e.input.lastKeyCode == 8 || e.input.lastKeyCode == 46)) {
6189      for (let u of a) if (u.nodeName == "BR" && u.parentNode) {
6190        let d = u.nextSibling;
6191        d && d.nodeType == 1 && d.contentEditable == "false" && u.parentNode.removeChild(u);
6192      }
6193    } else if (be && a.length) {
6194      let u = a.filter((d) => d.nodeName == "BR");
6195      if (u.length == 2) {
6196        let [d, f] = u;
6197        d.parentNode && d.parentNode.parentNode == f.parentNode ? f.remove() : d.remove();
6198      } else {
6199        let { focusNode: d } = this.currentSelection;
6200        for (let f of u) {
6201          let h = f.parentNode;
6202          h && h.nodeName == "LI" && (!d || gh(e, d) != h) && f.remove();
6203        }
6204      }
6205    }
6206    let c = null;
6207    i < 0 && s && e.input.lastFocus > Date.now() - 200 && Math.max(e.input.lastTouch, e.input.lastClick.time) < Date.now() - 300 && zr(r) && (c = di(e)) && c.eq(R.near(e.state.doc.resolve(0), 1)) ? (e.input.lastFocus = 0, ze(e), this.currentSelection.set(r), e.scrollToSelection()) : (i > -1 || s) && (i > -1 && (e.docView.markDirty(i, o), ph(e)), e.input.badSafariComposition && (e.input.badSafariComposition = false, yh(e, a)), this.handleDOMChange(i, o, l, a), e.docView && e.docView.dirty ? e.updateState(e.state) : this.currentSelection.eq(r) || ze(e), this.currentSelection.set(r));
6208  }
6209  registerMutation(e, t) {
6210    if (t.indexOf(e.target) > -1) return null;
6211    let r = this.view.docView.nearestDesc(e.target);
6212    if (e.type == "attributes" && (r == this.view.docView || e.attributeName == "contenteditable" || e.attributeName == "style" && !e.oldValue && !e.target.getAttribute("style")) || !r || r.ignoreMutation(e)) return null;
6213    if (e.type == "childList") {
6214      for (let u = 0; u < e.addedNodes.length; u++) {
6215        let d = e.addedNodes[u];
6216        t.push(d), d.nodeType == 3 && (this.lastChangedTextNode = d);
6217      }
6218      if (r.contentDOM && r.contentDOM != r.dom && !r.contentDOM.contains(e.target)) return { from: r.posBefore, to: r.posAfter };
6219      let s = e.previousSibling, i = e.nextSibling;
6220      if (ce && Ze <= 11 && e.addedNodes.length) for (let u = 0; u < e.addedNodes.length; u++) {
6221        let { previousSibling: d, nextSibling: f } = e.addedNodes[u];
6222        (!d || Array.prototype.indexOf.call(e.addedNodes, d) < 0) && (s = d), (!f || Array.prototype.indexOf.call(e.addedNodes, f) < 0) && (i = f);
6223      }
6224      let o = s && s.parentNode == e.target ? X(s) + 1 : 0, l = r.localPosFromDOM(e.target, o, -1), a = i && i.parentNode == e.target ? X(i) : e.target.childNodes.length, c = r.localPosFromDOM(e.target, a, 1);
6225      return { from: l, to: c };
6226    } else return e.type == "attributes" ? { from: r.posAtStart - r.border, to: r.posAtEnd + r.border } : (this.lastChangedTextNode = e.target, { from: r.posAtStart, to: r.posAtEnd, typeOver: e.target.nodeValue == e.oldValue });
6227  }
6228}
6229let Bo = /* @__PURE__ */ new WeakMap(), zo = false;
6230function ph(n2) {
6231  if (!Bo.has(n2) && (Bo.set(n2, null), ["normal", "nowrap", "pre-line"].indexOf(getComputedStyle(n2.dom).whiteSpace) !== -1)) {
6232    if (n2.requiresGeckoHackNode = be, zo) return;
6233    console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."), zo = true;
6234  }
6235}
6236function $o(n2, e) {
6237  let t = e.startContainer, r = e.startOffset, s = e.endContainer, i = e.endOffset, o = n2.domAtPos(n2.state.selection.anchor);
6238  return wt(o.node, o.offset, s, i) && ([t, r, s, i] = [s, i, t, r]), { anchorNode: t, anchorOffset: r, focusNode: s, focusOffset: i };
6239}
6240function mh(n2, e) {
6241  if (e.getComposedRanges) {
6242    let s = e.getComposedRanges(n2.root)[0];
6243    if (s) return $o(n2, s);
6244  }
6245  let t;
6246  function r(s) {
6247    s.preventDefault(), s.stopImmediatePropagation(), t = s.getTargetRanges()[0];
6248  }
6249  return n2.dom.addEventListener("beforeinput", r, true), document.execCommand("indent"), n2.dom.removeEventListener("beforeinput", r, true), t ? $o(n2, t) : null;
6250}
6251function gh(n2, e) {
6252  for (let t = e.parentNode; t && t != n2.dom; t = t.parentNode) {
6253    let r = n2.docView.nearestDesc(t, true);
6254    if (r && r.node.isBlock) return t;
6255  }
6256  return null;
6257}
6258function yh(n2, e) {
6259  var t;
6260  let { focusNode: r, focusOffset: s } = n2.domSelectionRange();
6261  for (let i of e) if (((t = i.parentNode) === null || t === void 0 ? void 0 : t.nodeName) == "TR") {
6262    let o = i.nextSibling;
6263    for (; o && o.nodeName != "TD" && o.nodeName != "TH"; ) o = o.nextSibling;
6264    if (o) {
6265      let l = o;
6266      for (; ; ) {
6267        let a = l.firstChild;
6268        if (!a || a.nodeType != 1 || a.contentEditable == "false" || /^(BR|IMG)$/.test(a.nodeName)) break;
6269        l = a;
6270      }
6271      l.insertBefore(i, l.firstChild), r == i && n2.domSelection().collapse(i, s);
6272    } else i.parentNode.removeChild(i);
6273  }
6274}
6275function bh(n2, e, t) {
6276  let { node: r, fromOffset: s, toOffset: i, from: o, to: l } = n2.docView.parseRange(e, t), a = n2.domSelectionRange(), c, u = a.anchorNode;
6277  if (u && n2.dom.contains(u.nodeType == 1 ? u : u.parentNode) && (c = [{ node: u, offset: a.anchorOffset }], zr(a) || c.push({ node: a.focusNode, offset: a.focusOffset })), ee && n2.input.lastKeyCode === 8) for (let g = i; g > s; g--) {
6278    let y = r.childNodes[g - 1], x = y.pmViewDesc;
6279    if (y.nodeName == "BR" && !x) {
6280      i = g;
6281      break;
6282    }
6283    if (!x || x.size) break;
6284  }
6285  let d = n2.state.doc, f = n2.someProp("domParser") || Xe.fromSchema(n2.state.schema), h = d.resolve(o), p = null, m = f.parse(r, { topNode: h.parent, topMatch: h.parent.contentMatchAt(h.index()), topOpen: true, from: s, to: i, preserveWhitespace: h.parent.type.whitespace == "pre" ? "full" : true, findPositions: c, ruleFromNode: kh, context: h });
6286  if (c && c[0].pos != null) {
6287    let g = c[0].pos, y = c[1] && c[1].pos;
6288    y == null && (y = g), p = { anchor: g + o, head: y + o };
6289  }
6290  return { doc: m, sel: p, from: o, to: l };
6291}
6292function kh(n2) {
6293  let e = n2.pmViewDesc;
6294  if (e) return e.parseRule();
6295  if (n2.nodeName == "BR" && n2.parentNode) {
6296    if (ne && /^(ul|ol)$/i.test(n2.parentNode.nodeName)) {
6297      let t = document.createElement("div");
6298      return t.appendChild(document.createElement("li")), { skip: t };
6299    } else if (n2.parentNode.lastChild == n2 || ne && /^(tr|table)$/i.test(n2.parentNode.nodeName)) return { ignore: true };
6300  } else if (n2.nodeName == "IMG" && n2.getAttribute("mark-placeholder")) return { ignore: true };
6301  return null;
6302}
6303const xh = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;
6304function Sh(n2, e, t, r, s) {
6305  let i = n2.input.compositionPendingChanges || (n2.composing ? n2.input.compositionID : 0);
6306  if (n2.input.compositionPendingChanges = 0, e < 0) {
6307    let S = n2.input.lastSelectionTime > Date.now() - 50 ? n2.input.lastSelectionOrigin : null, O = di(n2, S);
6308    if (O && !n2.state.selection.eq(O)) {
6309      if (ee && Le && n2.input.lastKeyCode === 13 && Date.now() - 100 < n2.input.lastKeyCodeTime && n2.someProp("handleKeyDown", (L) => L(n2, ut(13, "Enter")))) return;
6310      let A = n2.state.tr.setSelection(O);
6311      S == "pointer" ? A.setMeta("pointer", true) : S == "key" && A.scrollIntoView(), i && A.setMeta("composition", i), n2.dispatch(A);
6312    }
6313    return;
6314  }
6315  let o = n2.state.doc.resolve(e), l = o.sharedDepth(t);
6316  e = o.before(l + 1), t = n2.state.doc.resolve(t).after(l + 1);
6317  let a = n2.state.selection, c = bh(n2, e, t), u = n2.state.doc, d = u.slice(c.from, c.to), f, h;
6318  n2.input.lastKeyCode === 8 && Date.now() - 100 < n2.input.lastKeyCodeTime ? (f = n2.state.selection.to, h = "end") : (f = n2.state.selection.from, h = "start"), n2.input.lastKeyCode = null;
6319  let p = Mh(d.content, c.doc.content, c.from, f, h);
6320  if (p && n2.input.domChangeCount++, (Ft && n2.input.lastIOSEnter > Date.now() - 225 || Le) && s.some((S) => S.nodeType == 1 && !xh.test(S.nodeName)) && (!p || p.endA >= p.endB) && n2.someProp("handleKeyDown", (S) => S(n2, ut(13, "Enter")))) {
6321    n2.input.lastIOSEnter = 0;
6322    return;
6323  }
6324  if (!p) if (r && a instanceof I && !a.empty && a.$head.sameParent(a.$anchor) && !n2.composing && !(c.sel && c.sel.anchor != c.sel.head)
vendor: 4,357 bytes, lines 6324-6386
6324) p = { start: a.from, endA: a.to, endB: a.to };
6325  else {
6326    if (c.sel) {
6327      let S = Fo(n2, n2.state.doc, c.sel);
6328      if (S && !S.eq(n2.state.selection)) {
6329        let O = n2.state.tr.setSelection(S);
6330        i && O.setMeta("composition", i), n2.dispatch(O);
6331      }
6332    }
6333    return;
6334  }
6335  n2.state.selection.from < n2.state.selection.to && p.start == p.endB && n2.state.selection instanceof I && (p.start > n2.state.selection.from && p.start <= n2.state.selection.from + 2 && n2.state.selection.from >= c.from ? p.start = n2.state.selection.from : p.endA < n2.state.selection.to && p.endA >= n2.state.selection.to - 2 && n2.state.selection.to <= c.to && (p.endB += n2.state.selection.to - p.endA, p.endA = n2.state.selection.to)), ce && Ze <= 11 && p.endB == p.start + 1 && p.endA == p.start && p.start > c.from && c.doc.textBetween(p.start - c.from - 1, p.start - c.from + 1) == " \xA0" && (p.start--, p.endA--, p.endB--);
6336  let m = c.doc.resolveNoCache(p.start - c.from), g = c.doc.resolveNoCache(p.endB - c.from), y = u.resolve(p.start), x = m.sameParent(g) && m.parent.inlineContent && y.end() >= p.endA;
6337  if ((Ft && n2.input.lastIOSEnter > Date.now() - 225 && (!x || s.some((S) => S.nodeName == "DIV" || S.nodeName == "P")) || !x && m.pos < c.doc.content.size && (!m.sameParent(g) || !m.parent.inlineContent) && m.pos < g.pos && !/\S/.test(c.doc.textBetween(m.pos, g.pos, "", ""))) && n2.someProp("handleKeyDown", (S) => S(n2, ut(13, "Enter")))) {
6338    n2.input.lastIOSEnter = 0;
6339    return;
6340  }
6341  if (n2.state.selection.anchor > p.start && Ch(u, p.start, p.endA, m, g) && n2.someProp("handleKeyDown", (S) => S(n2, ut(8, "Backspace")))) {
6342    Le && ee && n2.domObserver.suppressSelectionUpdates();
6343    return;
6344  }
6345  ee && p.endB == p.start && (n2.input.lastChromeDelete = Date.now()), Le && !x && m.start() != g.start() && g.parentOffset == 0 && m.depth == g.depth && c.sel && c.sel.anchor == c.sel.head && c.sel.head == p.endA && (p.endB -= 2, g = c.doc.resolveNoCache(p.endB - c.from), setTimeout(() => {
6346    n2.someProp("handleKeyDown", function(S) {
6347      return S(n2, ut(13, "Enter"));
6348    });
6349  }, 20));
6350  let M = p.start, E = p.endA, C = (S) => {
6351    let O = S || n2.state.tr.replace(M, E, c.doc.slice(p.start - c.from, p.endB - c.from));
6352    if (c.sel) {
6353      let A = Fo(n2, O.doc, c.sel);
6354      A && !(ee && n2.composing && A.empty && (p.start != p.endB || n2.input.lastChromeDelete < Date.now() - 100) && (A.head == M || A.head == O.mapping.map(E) - 1) || ce && A.empty && A.head == M) && O.setSelection(A);
6355    }
6356    return i && O.setMeta("composition", i), O.scrollIntoView();
6357  }, N;
6358  if (x) if (m.pos == g.pos) {
6359    ce && Ze <= 11 && m.parentOffset == 0 && (n2.domObserver.suppressSelectionUpdates(), setTimeout(() => ze(n2), 20));
6360    let S = C(n2.state.tr.delete(M, E)), O = u.resolve(p.start).marksAcross(u.resolve(p.endA));
6361    O && S.ensureMarks(O), n2.dispatch(S);
6362  } else if (p.endA == p.endB && (N = wh(m.parent.content.cut(m.parentOffset, g.parentOffset), y.parent.content.cut(y.parentOffset, p.endA - y.start())))) {
6363    let S = C(n2.state.tr);
6364    N.type == "add" ? S.addMark(M, E, N.mark) : S.removeMark(M, E, N.mark), n2.dispatch(S);
6365  } else if (m.parent.child(m.index()).isText && m.index() == g.index() - (g.textOffset ? 0 : 1)) {
6366    let S = m.parent.textBetween(m.parentOffset, g.parentOffset), O = () => C(n2.state.tr.insertText(S, M, E));
6367    n2.someProp("handleTextInput", (A) => A(n2, M, E, S, O)) || n2.dispatch(O());
6368  } else n2.dispatch(C());
6369  else n2.dispatch(C());
6370}
6371function Fo(n2, e, t) {
6372  return Math.max(t.anchor, t.head) > e.content.size ? null : fi(n2, e.resolve(t.anchor), e.resolve(t.head));
6373}
6374function wh(n2, e) {
6375  let t = n2.firstChild.marks, r = e.firstChild.marks, s = t, i = r, o, l, a;
6376  for (let u = 0; u < r.length; u++) s = r[u].removeFromSet(s);
6377  for (let u = 0; u < t.length; u++) i = t[u].removeFromSet(i);
6378  if (s.length == 1 && i.length == 0) l = s[0], o = "add", a = (u) => u.mark(l.addToSet(u.marks));
6379  else if (s.length == 0 && i.length == 1) l = i[0], o = "remove", a = (u) => u.mark(l.removeFromSet(u.marks));
6380  else return null;
6381  let c = [];
6382  for (let u = 0; u < e.childCount; u++) c.push(a(e.child(u)));
6383  if (b.from(c).eq(n2)) return { mark: l, type: o };
6384}
6385function Ch(n2, e, t, r, s) {
6386  if (t - e <= s.pos - r.pos || ds(r, true, false) < s.pos) return false;
6387  let i = n2.resolve(e);
6388  if (!r.parent.isTextblock) {
6389    let l = i.nodeAfter;
6390    return l != null && t == e + l.nodeSize;
6391  }
6392  if (i.parentOffset < i.parent.content.size || !i.parent.isTextblock) return false;
6393  let o = n2.resolve(ds(i, true, true));
6394  return !o.parent.isTextblock || o.pos > t || ds(o, true, false) < t ? false : r.parent.content.cut(r.parentOffset).eq(o.parent.content);
6395}
6396function ds(n2, e, t) {
6397  let r = n2.depth, s = e ? n2.end() : n2.pos;
6398  for (; r > 0 && (e || n2.indexAfter(r) == n2.node(r).childCount); ) r--, s++, e = false;
6399  if (t) {
6400    let i = n2.node(r).maybeChild(n2.indexAfter(r));
6401    for (; i && !i.isLeaf; ) i = i.firstChild, s++;
6402  }
6403  return s;
6404}
6405function Mh(n2, e, t, r, s) {
6406  let i = n2.findDiffStart(e, t);
6407  if (i == null) return null;
6408  let { a: o, b: l } = n2.findDiffEnd(e, t + n2.size, t + e.size);
6409  if (s == "end") {
6410    let a = Math.max(0, i - Math.min(o, l));
6411    r -= o + a - i;
6412  }
6413  if (o < i && n2.size < e.size) {
6414    let a = r <= i && r >= o ? i - r : 0;
6415    i -= a, i && i < e.size && Vo(e.textBetween(i - 1, i + 1)) && (i += a ? 1 : -1), l = i + (l - o), o = i;
6416  } else if (l < i) {
6417    let a = r <= i && r >= l ? i - r : 0;
6418    i -= a, i && i < n2.size && Vo(n2.textBetween(i - 1, i + 1)) && (i += a ? 1 : -1), o = i + (o - l), l = i;
6419  }
6420  return { start: i, endA: o, endB: l };
6421}
6422function Vo(n2) {
6423  if (n2.length != 2) return false;
6424  let e = n2.charCodeAt(0), t = n2.charCodeAt(1);
6425  return e >= 56320 && e <= 57343 && t >= 55296 && t <= 56319;
6426}
6427class Ga {
6428  constructor(e, t) {
6429    this._root = null, this.focused = false, this.trackWrites = null, this.mounted = false, this.markCursor = null, this.cursorWrapper = null, this.lastSelectedViewDesc = void 0, this.input = new Vf(), this.prevDirectPlugins = [], this.pluginViews = [], this.requiresGeckoHackNode = false, this.dragging = null, this._props = t, this.state = t.state, this.directPlugins = t.plugins || [], this.directPlugins.forEach(Uo), this.dispatch = this.dispatch.bind(this), this.dom = e && e.mount || document.createElement("div"), e && (e.appendChild ? e.appendChild(this.dom) : typeof e == "function" ? e(this.dom) : e.mount && (this.mounted = true)), this.editable = jo(this), _o(this), this.nodeViews = Wo(this), this.docView = So(this.state.doc, Ho(this), us(this), this.dom, this), this.domObserver = new hh(this, (r, s, i, o) => Sh(this, r, s, i, o)), this.domObserver.start(), Hf(this), this.updatePluginViews();
6430  }
6431  get composing() {
6432    return this.input.composing;
6433  }
6434  get props() {
6435    if (this._props.state != this.state) {
6436      let e = this._props;
6437      this._props = {};
6438      for (let t in e) this._props[t] = e[t];
6439      this._props.state = this.state;
6440    }
6441    return this._props;
6442  }
6443  update(e) {
6444    e.handleDOMEvents != this._props.handleDOMEvents && Fs(this);
6445    let t = this._props;
6446    this._props = e, e.plugins && (e.plugins.forEach(Uo), this.directPlugins = e.plugins), this.updateStateInner(e.state, t);
6447  }
6448  setProps(e) {
6449    let t = {};
6450    for (let r in this._props) t[r] = this._props[r];
6451    t.state = this.state;
6452    for (let r in e) t[r] = e[r];
6453    this.update(t);
6454  }
6455  updateState(e) {
6456    this.updateStateInner(e, this._props);
6457  }
6458  updateStateInner(e, t) {
6459    var r;
6460    let s = this.state, i = false, o = false;
6461    e.storedMarks && this.composing && (_a(this), o = true), this.state = e;
6462    let l = s.plugins != e.plugins || this._props.plugins != t.plugins;
6463    if (l || this._props.plugins != t.plugins || this._props.nodeViews != t.nodeViews) {
6464      let h = Wo(this);
6465      Th(h, this.nodeViews) && (this.nodeViews = h, i = true);
6466    }
6467    (l || t.handleDOMEvents != this._props.handleDOMEvents) && Fs(this), this.editable = jo(this), _o(this);
6468    let a = us(this), c = Ho(this), u = s.plugins != e.plugins && !s.doc.eq(e.doc) ? "reset" : e.scrollToSelection > s.scrollToSelection ? "to selection" : "preserve", d = i || !this.docView.matchesNode(e.doc, c, a);
6469    (d || !e.selection.eq(s.selection)) && (o = true);
6470    let f = u == "preserve" && o && this.dom.style.overflowAnchor == null && ef(this);
6471    if (o) {
6472      this.domObserver.stop();
6473      let h = d && (ce || ee) && !this.composing && !s.selection.empty && !e.selection.empty && vh(s.selection, e.selection);
6474      if (d) {
6475        let p = ee ? this.trackWrites = this.domSelectionRange().focusNode : null;
6476        this.composing && (this.input.compositionNode = th(this)), (i || !this.docView.update(e.doc, c, a, this)) && (this.docView.updateOuterDeco(c), this.docView.destroy(), this.docView = So(e.doc, c, a, this.dom, this)), p && (!this.trackWrites || !this.dom.contains(this.trackWrites)) && (h = true);
6477      }
6478      h || !(this.input.mouseDown && this.domObserver.currentSelection.eq(this.domSelectionRange()) && vf(this)) ? ze(this, h) : (Oa(this, e.selection), this.domObserver.setCurSelection()), this.domObserver.start();
6479    }
6480    this.updatePluginViews(s), !((r = this.dragging) === null || r === void 0) && r.node && !s.doc.eq(e.doc) && this.updateDraggedNode(this.dragging, s), u == "reset" ? this.dom.scrollTop = 0 : u == "to selection" ? this.scrollToSelection() : f && tf(f);
6481  }
6482  scrollToSelection() {
6483    let e = this.domSelectionRange().focusNode;
6484    if (!(!e || !this.dom.contains(e.nodeType == 1 ? e : e.parentNode))) {
6485      if (!this.someProp("handleScrollToSelection", (t) => t(this))) if (this.state.selection instanceof T) {
6486        let t = this.docView.domAfterPos(this.state.selection.from);
6487        t.nodeType == 1 && mo(this, t.getBoundingClientRect(), e);
6488      }
6488 else mo(this, this.coordsAtPos(this.state.selection.head, 1), e);
6489    }
6490  }
6491  destroyPluginViews() {
6492    let e;
6493    for (; e = this.pluginViews.pop(); ) e.destroy && e.destroy();
6494  }
6495  updatePluginViews(e) {
6496    if (!e || e.plugins != this.state.plugins || this.directPlugins != this.prevDirectPlugins) {
6497      this.prevDirectPlugins = this.directPlugins, this.destroyPluginViews();
6498      for (let t = 0; t < this.directPlugins.length; t++) {
6499        let r = this.directPlugins[t];
6500        r.spec.view && this.pluginViews.push(r.spec.view(this));
6501      }
6502      for (let t = 0; t < this.state.plugins.length; t++) {
6503        let r = this.state.plugins[t];
6504        r.spec.view && this.pluginViews.push(r.spec.view(this));
6505      }
6506    } else for (let t = 0; t < this.pluginViews.length; t++) {
6507      let r = this.pluginViews[t];
6508      r.update && r.update(this, e);
6509    }
6510  }
6511  updateDraggedNode(e, t) {
6512    let r = e.node, s = -1;
6513    if (this.state.doc.nodeAt(r.from) == r.node) s = r.from;
6514    else {
6515      let i = r.from + (this.state.doc.content.size - t.doc.content.size);
6516      (i > 0 && this.state.doc.nodeAt(i)) == r.node && (s = i);
6517    }
6518    this.dragging = new Wa(e.slice, e.move, s < 0 ? void 0 : T.create(this.state.doc, s));
6519  }
6520  someProp(e, t) {
6521    let r = this._props && this._props[e], s;
6522    if (r != null && (s = t ? t(r) : r)) return s;
6523    for (let o = 0; o < this.directPlugins.length; o++) {
6524      let l = this.directPlugins[o].props[e];
6525      if (l != null && (s = t ? t(l) : l)) return s;
6526    }
6527    let i = this.state.plugins;
6528    if (i) for (let o = 0; o < i.length; o++) {
6529      let l = i[o].props[e];
6530      if (l != null && (s = t ? t(l) : l)) return s;
6531    }
6532  }
6533  hasFocus() {
6534    if (ce) {
6535      let e = this.root.activeElement;
6536      if (e == this.dom) return true;
6537      if (!e || !this.dom.contains(e)) return false;
6538      for (; e && this.dom != e && this.dom.contains(e); ) {
6539        if (e.contentEditable == "false") return false;
6540        e = e.parentElement;
6541      }
6542      return true;
6543    }
6544    return this.root.activeElement == this.dom;
6545  }
6546  focus() {
6547    this.domObserver.stop(), this.editable && nf(this.dom), ze(this), this.domObserver.start();
6548  }
6549  get root() {
6550    let e = this._root;
6551    if (e == null) {
6552      for (let t = this.dom.parentNode; t; t = t.parentNode) if (t.nodeType == 9 || t.nodeType == 11 && t.host) return t.getSelection || (Object.getPrototypeOf(t).getSelection = () => t.ownerDocument.getSelection()), this._root = t;
6553    }
6554    return e || document;
6555  }
6556  updateRoot() {
6557    this._root = null;
6558  }
6559  posAtCoords(e) {
6560    return af(this, e);
6561  }
6562  coordsAtPos(e, t = 1) {
6563    return wa(this, e, t);
6564  }
6565  domAtPos(e, t = 0) {
6566    return this.docView.domFromPos(e, t);
6567  }
6568  nodeDOM(e) {
6569    let t = this.docView.descAt(e);
6570    return t ? t.nodeDOM : null;
6571  }
6572  posAtDOM(e, t, r = -1) {
6573    let s = this.docView.posFromDOM(e, t, r);
6574    if (s == null) throw new RangeError("DOM position not inside the editor");
6575    return s;
6576  }
6577  endOfTextblock(e, t) {
6578    return hf(this, t || this.state, e);
6579  }
6580  pasteHTML(e, t) {
6581    return yn(this, "", e, false, t || new ClipboardEvent("paste"));
6582  }
6583  pasteText(e, t) {
6584    return yn(this, e, null, true, t || new ClipboardEvent("paste"));
6585  }
6586  serializeForClipboard(e) {
6587    return hi(this, e);
6588  }
6589  destroy() {
6590    this.docView && (_f(this), this.destroyPluginViews(), this.mounted ? (this.docView.update(this.state.doc, [], us(this), this), this.dom.textContent = "") : this.dom.parentNode && this.dom.parentNode.removeChild(this.dom), this.docView.destroy(), this.docView = null, Wd());
6591  }
6592  get isDestroyed() {
6593    return this.docView == null;
6594  }
6595  dispatchEvent(e) {
6596    return Wf(this, e);
6597  }
6598  domSelectionRange() {
6599    let e = this.domSelection();
6600    return e ? ne && this.root.nodeType === 11 && Gd(this.dom.ownerDocument) == this.dom && mh(this, e) || e : { focusNode: null, focusOffset: 0, anchorNode: null, anchorOffset: 0 };
6601  }
6602  domSelection() {
6603    return this.root.getSelection();
6604  }
6605}
6606Ga.prototype.dispatch = function(n2) {
6607  let e = this._props.dispatchTransaction;
6608  e ? e.call(this, n2) : this.updateState(this.state.apply(n2));
6609};
6610function Ho(n2) {
6611  let e = /* @__PURE__ */ Object.create(null);
6612  return e.class = "ProseMirror", e.contenteditable = String(n2.editable), n2.someProp("attributes", (t) => {
6613    if (typeof t == "function" && (t = t(n2.state)), t) for (let r in t) r == "class" ? e.class += " " + t[r] : r == "style" ? e.style = (e.style ? e.style + ";" : "") + t[r] : !e[r] && r != "contenteditable" && r != "nodeName" && (e[r] = String(t[r]));
6614  }), e.translate || (e.translate = "no"), [se.node(0, n2.state.doc.
6614content.size, e)];
6615}
6616function _o(n2) {
6617  if (n2.markCursor) {
6618    let e = document.createElement("img");
6619    e.className = "ProseMirror-separator", e.setAttribute("mark-placeholder", "true"), e.setAttribute("alt", ""), n2.cursorWrapper = { dom: e, deco: se.widget(n2.state.selection.from, e, { raw: true, marks: n2.markCursor }) };
6620  } else n2.cursorWrapper = null;
6621}
6622function jo(n2) {
6623  return !n2.someProp("editable", (e) => e(n2.state) === false);
6624}
6625function vh(n2, e) {
6626  let t = Math.min(n2.$anchor.sharedDepth(n2.head), e.$anchor.sharedDepth(e.head));
6627  return n2.$anchor.start(t) != e.$anchor.start(t);
6628}
6629function Wo(n2) {
6630  let e = /* @__PURE__ */ Object.create(null);
6631  function t(r) {
6632    for (let s in r) Object.prototype.hasOwnProperty.call(e, s) || (e[s] = r[s]);
6633  }
6634  return n2.someProp("nodeViews", t), n2.someProp("markViews", t), e;
6635}
6636function Th(n2, e) {
6637  let t = 0, r = 0;
6638  for (let s in n2) {
6639    if (n2[s] != e[s]) return true;
6640    t++;
6641  }
6642  for (let s in e) r++;
6643  return t != r;
6644}
6645function Uo(n2) {
6646  if (n2.spec.state || n2.spec.filterTransaction || n2.spec.appendTransaction) throw new RangeError("Plugins passed directly to the view must not have a state component");
6647}
6648var nt = { 8: "Backspace", 9: "Tab", 10: "Enter", 12: "NumLock", 13: "Enter", 16: "Shift", 17: "Control", 18: "Alt", 20: "CapsLock", 27: "Escape", 32: " ", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", 37: "ArrowLeft", 38: "ArrowUp", 39: "ArrowRight", 40: "ArrowDown", 44: "PrintScreen", 45: "Insert", 46: "Delete", 59: ";", 61: "=", 91: "Meta", 92: "Meta", 106: "*", 107: "+", 108: ",", 109: "-", 110: ".", 111: "/", 144: "NumLock", 145: "ScrollLock", 160: "Shift", 161: "Shift", 162: "Control", 163: "Control", 164: "Alt", 165: "Alt", 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'" }, tr = { 48: ")", 49: "!", 50: "@", 51: "#", 52: "$", 53: "%", 54: "^", 55: "&", 56: "*", 57: "(", 59: ":", 61: "+", 173: "_", 186: ":", 187: "+", 188: "<", 189: "_", 190: ">", 191: "?", 192: "~", 219: "{", 220: "|", 221: "}", 222: '"' }, Eh = typeof navigator < "u" && /Mac/.test(navigator.platform), Ah = typeof navigator < "u" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
6649for (var Z = 0; Z < 10; Z++) nt[48 + Z] = nt[96 + Z] = String(Z);
6650for (var Z = 1; Z <= 24; Z++) nt[Z + 111] = "F" + Z;
6651for (var Z = 65; Z <= 90; Z++) nt[Z] = String.fromCharCode(Z + 32), tr[Z] = String.fromCharCode(Z);
6652for (var fs in nt) tr.hasOwnProperty(fs) || (tr[fs] = nt[fs]);
6653function Nh(n2) {
6654  var e = Eh && n2.metaKey && n2.shiftKey && !n2.ctrlKey && !n2.altKey || Ah && n2.shiftKey && n2.key && n2.key.length == 1 || n2.key == "Unidentified", t = !e && n2.key || (n2.shiftKey ? tr : nt)[n2.keyCode] || n2.key || "Unidentified";
6655  return t == "Esc" && (t = "Escape"), t == "Del" && (t = "Delete"), t == "Left" && (t = "ArrowLeft"), t == "Up" && (t = "ArrowUp"), t == "Right" && (t = "ArrowRight"), t == "Down" && (t = "ArrowDown"), t;
6656}
6657const Oh = typeof navigator < "u" && /Mac|iP(hone|[oa]d)/.test(navigator.platform), Ih = typeof navigator < "u" && /Win/.test(navigator.platform);
6658function Dh(n2) {
6659  let e = n2.split(/-(?!$)/), t = e[e.length - 1];
6660  t == "Space" && (t = " ");
6661  let r, s, i, o;
6662  for (let l = 0; l < e.length - 1; l++) {
6663    let a = e[l];
6664    if (/^(cmd|meta|m)$/i.test(a)) o = true;
6665    else if (/^a(lt)?$/i.test(a)) r = true;
6666    else if (/^(c|ctrl|control)$/i.test(a)) s = true;
6667    else if (/^s(hift)?$/i.test(a)) i = true;
6668    else if (/^mod$/i.test(a)) Oh ? o = true : s = true;
6669    else throw new Error("Unrecognized modifier name: " + a);
6670  }
6671  return r && (t = "Alt-" + t), s && (t = "Ctrl-" + t), o && (t = "Meta-" + t), i && (t = "Shift-" + t), t;
6672}
6673function Rh(n2) {
6674  let e = /* @__PURE__ */ Object.create(null);
6675  for (let t in n2) e[Dh(t)] = n2[t];
6676  return e;
6677}
6678function hs(n2, e, t = true) {
6679  return e.altKey && (n2 = "Alt-" + n2), e.ctrlKey && (n2 = "Ctrl-" + n2), e.metaKey && (n2 = "Meta-" + n2), t && e.shiftKey && (n2 = "Shift-" + n2), n2;
6680}
6681function Ph(n2) {
6682  return new F({ props: { handleKeyDown: Ya(n2) } });
6683}
6684function Ya(n2) {
6685  let e = Rh(n2);
6686  return function(t, r) {
6687    let s = Nh(r), i, o = e[hs(s, r)];
6688    if (o && o(t.state, t.dispatch, t)) return true;
6689    if (s.length == 1 && s != " ") {
6690      if (r.shiftKey) {
6691        let l = e[hs(s, r, false)];
6692        if (l && l(t.state, t.dispatch, t)) return true;
6693      }
6694      if ((r.altKey || r.metaKey || r.ctrlKey) && !(Ih && r.ctrlKey && r.altKey) && (i = nt[r.keyCode]) && i != s) {
6695        let l = e[hs(i, r)];
6696        if (l && l(t.state, t.dispatch, t)) return true;
6697      }
6698    }
6699    return false;
6700  };
6701}
6702var Lh = Object.defineProperty, ki = (n2, e) => {
6703  for (var t in e) Lh(n2, t, { get: e[t], enumerable: true });
6704};
6705function Vr(n2) {
6706  const { state: e, transaction: t } = n2;
6707  let { selection: r } = t, { doc: s } = t, { storedMarks: i } = t;
6708  return { ...e, apply: e.apply.bind(e), applyTransaction: e.applyTransaction.bind(e), plugins: e.plugins, schema: e.schema, reconfigure: e.reconfigure.bind(e), toJSON: e.toJSON.bind(e), get storedMarks() {
6709    return i;
6710  }, get selection() {
6711    return r;
6712  }, get doc() {
6713    return s;
6714  }, get tr() {
6715    return r = t.selection, s = t.doc, i = t.storedMarks, t;
6716  } };
6717}
6718var Hr = class {
6719  constructor(n2) {
6720    this.editor = n2.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = n2.state;
6721  }
6722  get hasCustomState() {
6723    return !!this.customState;
6724  }
6725  get state() {
6726    return this.customState || this.editor.state;
6727  }
6728  get commands() {
6729    const { rawCommands: n2, editor: e, state: t } = this, { view: r } = e, { tr: s } = t, i = this.buildProps(s);
6730    return Object.fromEntries(Object.entries(n2).map(([o, l]) => [o, (...c) => {
6731      const u = l(...c)(i);
6732      return !s.getMeta("preventDispatch") && !this.hasCustomState && r.dispatch(s), u;
6733    }]));
6734  }
6735  get chain() {
6736    return () => this.createChain();
6737  }
6738  get can() {
6739    return () => this.createCan();
6740  }
6741  createChain(n2, e = true) {
6742    const { rawCommands: t, editor: r, state: s } = this, { view: i } = r, o = [], l = !!n2, a = n2 || s.tr, c = () => (!l && e && !a.getMeta("preventDispatch") && !this.hasCustomState && i.dispatch(a), o.every((d) => d === true)), u = { ...Object.fromEntries(Object.entries(t).map(([d, f]) => [d, (...p) => {
6743      const m = this.buildProps(a, e), g = f(...p)(m);
6744      return o.push(g), u;
6745    }])), run: c };
6746    return u;
6747  }
6748  createCan(n2) {
6749    const { rawCommands: e, state: t } = this, r = false, s = n2 || t.tr, i = this.buildProps(s, r);
6750    return { ...Object.fromEntries(Object.entries(e).map(([l, a]) => [l, (...c) => a(...c)({ ...i, dispatch: void 0 })])), chain: () => this.createChain(s, r) };
6751  }
6752  buildProps(n2, e = true) {
6753    const { rawCommands: t, editor: r, state: s } = this, { view: i } = r, o = { tr: n2, editor: r, view: i, state: Vr({ state: s, transaction: n2 }), dispatch: e ? () => {
6754    } : void 0, chain: () => this.createChain(n2, e), can: () => this.createCan(n2), get commands() {
6755      return Object.fromEntries(Object.entries(t).map(([l, a]) => [l, (...c) => a(...c)(o)]));
6756    } };
6757    return o;
6758  }
6759}, Qa = {};
6760ki(Qa, { blur: () => Bh, clearContent: () => zh, clearNodes: () => $h, command: () => Fh, createParagraphNear: () => Vh, cut: () => Hh, deleteCurrentNode: () => _h, deleteNode: () => jh, deleteRange: () => Wh, deleteSelection: () => Uh, enter: () => Kh, exitCode: () => qh, extendMarkRange: () => Jh, first: () => Gh, focus: () => Qh, forEach: () => Xh, insertContent: () => Zh, insertContentAt: () => np, joinBackward: () => ip, joinDown: () => sp, joinForward: () => op, joinItemBackward: () => lp, joinItemForward: () => ap, joinTextblockBackward: () => cp, joinTextblockForward: () => up, joinUp: () => rp, keyboardShortcut: () => fp, lift: () => hp, liftEmptyBlock: () => pp, liftListItem: () => mp, newlineInCode: () => gp, resetAttributes: () => yp, scrollIntoView: () => bp, selectAll: () => kp, selectNodeBackward: () => xp, selectNodeForward: () => Sp, selectParentNode: () => wp, selectTextblockEnd: () => Cp, selectTextblockStart: () => Mp, setContent: () => vp, setMark: () => qp, setMeta: () => Jp, setNode: () => Gp, setNodeSelection: () => Yp, setTextDirection: () => Qp, setTextSelection: () => Xp, sinkListItem: () => Zp, splitBlock: () => em, splitListItem: () => tm, toggleList: () => nm, toggleMark: () => rm, toggleNode: () => sm, toggleWrap: () => im, undoInputRule: () => om, unsetAllMarks: () => lm, unsetMark: () => am, unsetTextDirection: () => cm, updateAttributes: () => um, wrapIn: () => dm, wrapInList: () => fm });
6761var Bh = () => ({ editor: n2, view: e }) => (requestAnimationFrame(() => {
6762  var t;
6763  n2.isDestroyed || (e.dom.blur(), (t = window == null ? void 0 : window.getSelection()) == null || t.removeAllRanges());
6764}), true), zh = (n2 = true) => ({ commands: e }) => e.setContent("", { emitUpdate: n2 }), $h = () => ({ state: n2, tr: e, dispatch: t }) => {
6765  const { selection: r } = e, { ranges: s } = r;
6766  return t && s.forEach(({ $from: i, $to: o }) => {
6767    n2.doc.nodesBetween(i.pos, o.pos, (l, a) => {
6768      if (l.type.isText) return;
6769      const { doc: c, mapping: u } = e, d = c.resolve(u.map(a)), f = c.resolve(u.map(a + l.nodeSize)), h = d.blockRange(f);
6770      if (!h) return;
6771      const p = jt(h);
6772      if (l.type.isTextblock) {
6773        const { defaultType: m } = d.parent.contentMatchAt(d.index());
6774        e.setNodeMarkup(h.start, m);
6775      }
6776      (p || p === 0) && e.lift(h, p);
6777    });
6778  }), true;
6779}, Fh = (n2) => (e) => n2(e), Vh = () => ({ state: n2, dispatch: e }) => da(n2, e), Hh = (n2, e) => ({ editor: t, tr: r }) => {
6780  const { state: s } = t, i = s.doc.slice(n2.from, n2.to);
6781  r.deleteRange(n2.from, n2.to);
6782  const o = r.mapping.map(e);
6783  return r.insert(o, i.content), r.setSelection(new I(r.doc.resolve(Math.max(o - 1, 0)))), true;
6784}, _h = () => ({ tr: n2, dispatch: e }) => {
6785  const { selection: t } = n2, r = t.$anchor.node();
6786  if (r.content.size > 0) return false;
6787  const s = n2.selection.$anchor;
6788  for (let i = s.depth; i > 0; i -= 1) if (s.node(i).type === r.type) {
6789    if (e) {
6790      const l = s.before(i), a = s.after(i);
6791      n2.delete(l, a).scrollIntoView();
6792    }
6793    return true;
6794  }
6795  return false;
6796};
6797function W(n2, e) {
6798  if (typeof n2 == "string") {
6799    if (!e.nodes[n2]) throw Error(`There is no node type named '${n2}'. Maybe you forgot to add the extension?`);
6800    return e.nodes[n2];
6801  }
6802  return n2;
6803}
6804var jh = (n2) => ({ tr: e, state: t, dispatch: r }) => {
6805  const s = W(n2, t.schema), i = e.selection.$anchor;
6806  for (let o = i.depth; o > 0; o -= 1) if (i.node(o).type === s) {
6807    if (r) {
6808      const a = i.before(o), c = i.after(o);
6809      e.delete(a, c).scrollIntoView();
6810    }
6811    return true;
6812  }
6813  return false;
6814}, Wh = (n2) => ({ tr: e, dispatch: t }) => {
6815  const { from: r, to: s } = n2;
6816  return t && e.delete(r, s), true;
6817}, Uh = () => ({ state: n2, dispatch: e }) => ii(n2, e), Kh = () => ({ commands: n2 }) => n2.keyboardShortcut("Enter"), qh = () => ({ state: n2, dispatch: e }) => Nd(n2, e);
6818function xi(n2) {
6819  return Object.prototype.toString.call(n2) === "[object RegExp]";
6820}
6821function nr(n2, e, t = { strict: true }) {
6822  const r = Object.keys(e);
6823  return r.length ? r.every((s) => t.strict ? e[s] === n2[s] : xi(e[s]) ? e[s].test(n2[s]) : e[s] === n2[s]) : true;
6824}
6825function Xa(n2, e, t = {}) {
6826  return n2.find((r) => r.type === e && nr(Object.fromEntries(Object.keys(t).map((s) => [s, r.attrs[s]])), t));
6827}
6828function Ko(n2, e, t = {}) {
6829  return !!Xa(n2, e, t);
6830}
6831function Si(n2, e, t) {
6832  var r;
6833  if (!n2 || !e) return;
6834  let s = n2.parent.childAfter(n2.parentOffset);
6835  if ((!s.node || !s.node.marks.some((u) => u.type === e)) && (s = n2.parent.childBefore(n2.parentOffset)), !s.node || !s.node.marks.some((u) => u.type === e) || (t = t || ((r = s.node.marks[0]) == null ? void 0 : r.attrs), !Xa([...s.node.marks], e, t))) return;
6836  let o = s.index, l = n2.start() + s.offset, a = o + 1, c = l + s.node.nodeSize;
6837  for (; o > 0 && Ko([...n2.parent.child(o - 1).marks], e, t); ) o -= 1, l -= n2.parent.child(o).nodeSize;
6838  for (; a < n2.parent.childCount && Ko([...n2.parent.child(a).marks], e, t); ) c += n2.parent.child(a).nodeSize, a += 1;
6839  return { from: l, to: c };
6840}
6841function $e(n2, e) {
6842  if (typeof n2 == "string") {
6843    if (!e.marks[n2]) throw Error(`There is no mark type named '${n2}'. Maybe you forgot to add the extension?`);
6844    return e.marks[n2];
6845  }
6846  return n2;
6847}
6848var Jh = (n2, e = {}) => ({ tr: t, state: r, dispatch: s }) => {
6849  const i = $e(n2, r.schema), { doc: o, selection: l } = t, { $from: a, from: c, to: u } = l;
6850  if (s) {
6851    const d = Si(a, i, e);
6852    if (d && d.from <= c && d.to >= u) {
6853      const f = I.create(o, d.from, d.to);
6854      t.setSelection(f);
6855    }
6856  }
6857  return true;
6858}, Gh = (n2) => (e) => {
6859  const t = typeof n2 == "function" ? n2(e) : n2;
6860  for (let r = 0; r < t.length; r += 1) if (t[r](e)) return true;
6861  return false;
6862};
6863function Za(n2) {
6864  return n2 instanceof I;
6865}
6866function ht(n2 = 0, e = 0, t = 0) {
6867  return Math.min(Math.max(n2, e), t);
6868}
6869function ec(n2, e = null) {
6870  if (!e) return null;
6871  const t = R.atStart(n2), r = R.atEnd(n2);
6872  if (e === "start" || e === true) return t;
6873  if (e === "end") return r;
6874  const s = t.from, i = r.to;
6875  return e === "all" ? I.create(n2, ht(0, s, i), ht(n2.content.size, s, i)) : I.create(n2, ht(e, s, i), ht(e, s, i));
6876}
6877function qo() {
6878  return navigator.platform === "Android" || /android/i.test(navigator.userAgent);
6879}
6880function rr() {
6881  return ["iPad Simulator", "iPhone Simulator", "iPod Simulator", "iPad", "iPhone", "iPod"].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document;
6882}
6883function Yh() {
6884  return typeof navigator < "u" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;
6885}
6886var Qh = (n2 = null, e = {}) => ({ editor: t, view: r, tr: s, dispatch: i }) => {
6887  e = { scrollIntoView: true, ...e };
6888  const o = () => {
6889    (rr() || qo()) && r.dom.focus(), Yh() && !rr() && !qo() && r.dom.focus({ preventScroll: true }), requestAnimationFrame(() => {
6890      t.isDestroyed || (r.focus(), (e == null ? void 0 : e.scrollIntoView) && t.commands.scrollIntoView());
6891    });
6892  };
6893  try {
6894    if (r.hasFocus() && n2 === null || n2 === false) return true;
6895  } catch {
6896    return false;
6897  }
6898  if (i && n2 === null && !Za(t.state.selection)) return o(), true;
6899  const l = ec(s.doc, n2) || t.state.selection, a = t.state.selection.eq(l);
6900  return i && (a || s.setSelection(l), a && s.storedMarks && s.setStoredMarks(s.storedMarks), o()), true;
6901}, Xh = (n2, e) => (t) => n2.every((r, s) => e(r, { ...t, index: s })), Zh = (n2, e) => ({ tr: t, commands: r }) => r.insertContentAt({ from: t.selection.from, to: t.selection.to }, n2, e), tc = (n2) => {
6902  const e = n2.childNodes;
6903  for (let t = e.length - 1; t >= 0; t -= 1) {
6904    const r = e[t];
6905    r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? n2.removeChild(r) : r.nodeType === 1 && tc(r);
6906  }
6907  return n2;
6908};
6909function Dn(n2) {
6910  if (typeof window > "u") throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");
6911  const e = `<body>${n2}</body>`, t = new window.DOMParser().parseFromString(e, "text/html").body;
6912  return tc(t);
6913}
6914function kn(n2, e, t) {
6915  if (n2 instanceof Ce || n2 instanceof b) return n2;
6916  t = { slice: true, parseOptions: {}, ...t };
6917  const r = typeof n2 == "object" && n2 !== null, s = typeof n2 == "string";
6918  if (r) try {
6919    if (Array.isArray(n2) && n2.length > 0) return b.fromArray(n2.map((l) => e.nodeFromJSON(l)));
6920    const o = e.nodeFromJSON(n2);
6921    return t.errorOnInvalidContent && o.check(), o;
6922  } catch (i) {
6923    if (t.errorOnInvalidContent) throw new Error("[tiptap error]: Invalid JSON content", { cause: i });
6924    return console.warn("[tiptap warn]: Invalid content.", "Passed value:", n2, "Error:", i), kn("", e, t);
6925  }
6926  if (s) {
6927    if (t.errorOnInvalidContent) {
6928      let o = false, l = "";
6929      const a = new $l({ topNode: e.spec.topNode, marks: e.spec.marks, nodes: e.spec.nodes.append({ __tiptap__private__unknown__catch__all__node: { content: "inline*", group: "block", parseDOM: [{ tag: "*", getAttrs: (c) => (o = true, l = typeof c == "string" ? c : c.outerHTML, null) }] } }) });
6930      if (t.slice ? Xe.fromSchema(a).parseSlice(Dn(n2), t.parseOptions) : Xe.fromSchema(a).parse(Dn(n2), t.parseOptions), t.errorOnInvalidContent && o) throw new Error("[tiptap error]: Invalid HTML content", { cause: new Error(`Invalid element found: ${l}`) });
6931    }
6932    const i = Xe.fromSchema(e);
6933    return t.slice ? i.parseSlice(Dn(n2), t.parseOptions).content : i.parse(Dn(n2), t.parseOptions);
6934  }
6935  return kn("", e, t);
6936}
6937function ep(n2, e, t) {
6938  const r = n2.steps.length - 1;
6939  if (r < e) return;
6940  const s = n2.steps[r];
6941  if (!(s instanceof q || s instanceof J)) return;
6942  const i = n2.mapping.maps[r];
6943  let o = 0;
6944  i.forEach((l, a, c, u) => {
6945    o === 0 && (o = u);
6946  }), n2.setSelection(R.near(n2.doc.resolve(o), t));
6947}
6948var tp = (n2) => !("type" in n2), np = (n2, e, t) => ({ tr: r, dispatch: s, editor: i }) => {
6949  var o;
6950  if (s) {
6951    t = { parseOptions: i.options.parseOptions, updateSelection: true, applyInputRules: false, applyPasteRules: false, ...t };
6952    let l;
6953    const a = (g) => {
6954      i.emit("contentError", { editor: i, error: g, disableCollaboration: () => {
6955        "collaboration" in i.storage && typeof i.storage.collaboration == "object" && i.storage.collaboration && (i.storage.collaboration.isDisabled = true);
6956      } });
6957    }, c = { preserveWhitespace: "full", ...t.parseOptions };
6958    if (!t.errorOnInvalidContent && !i.options.enableContentCheck && i.options.emitContentError) try {
6959      kn(e, i.schema, { parseOptions: c, errorOnInvalidContent: true });
6960    } catch (g) {
6961      a(g);
6962    }
6963    try {
6964      l = kn(e, i.schema, { parseOptions: c, errorOnInvalidContent: (o = t.errorOnInvalidContent) != null ? o : i.options.enableContentCheck });
6965    } catch (g) {
6966      return a(g), false;
6967    }
6968    let { from: u, to: d } = typeof n2 == "number" ? { from: n2, to: n2 } : { from: n2.from, to: n2.to }, f = true, h = true;
6969    if ((tp(l) ? l : [l]).forEach((g) => {
6970      g.check(), f = f ? g.isText && g.marks.length === 0 : false, h = h ? g.isBlock : false;
6971    }), u === d && h) {
6972      const { parent: g } = r.doc.resolve(u);
6973      g.isTextblock && !g.type.spec.code && !g.childCount && (u -= 1, d += 1);
6974    }
6975    let m;
6976    if (f) {
6977      if (Array.isArray(e)) m = e.map((g) => g.text || "").join("");
6978      else if (e instanceof b) {
6979        let g = "";
6980        e.forEach((y) => {
6981          y.text && (g += y.text);
6982        }), m = g;
6983      } else typeof e == "object" && e && e.text ? m = e.text : m = e;
6984      r.insertText(m, u, d);
6985    } else {
6986      m = l;
6987      const g = r.doc.resolve(u), y = g.node(), x = g.parentOffset === 0, M = y.isText || y.isTextblock, E = y.content.size > 0;
6988      x && M && E && (u = Math.max(0, u - 1)), r.replaceWith(u, d, m);
6989    }
6990    t.updateSelection && ep(r, r.steps.length - 1, -1), t.applyInputRules && r.setMeta("applyInputRules", { from: u, text: m }), t.applyPasteRules && r.setMeta("applyPasteRules", { from: u, text: m });
6991  }
6992  return true;
6993}, rp = () => ({ state: n2, dispatch: e }) => Td(n2, e), sp = () => ({ state: n2, dispatch: e }) => Ed(n2, e), ip = () => ({ state: n2, dispatch: e }) => sa(n2, e), op = () => ({ state: n2, dispatch: e }) => aa(n2, e), lp = () => ({ state: n2, dispatch: e, tr: t }) => {
6994  try {
6995    const r = Pr(n2.doc, n2.selection.$from.pos, -1);
6996    return r == null ? false : (t.join(r, 2), e && e(t), true);
6997  } catch {
6998    return false;
6999  }
7000}, ap = () => ({ state: n2, dispatch: e, tr: t }) => {
7001  try {
7002    const r = Pr(n2.doc, n2.selection.$from.pos, 1);
7003    return r == null ? false : (t.join(r, 2), e && e(t), true);
7004  } catch {
7005    return false;
7006  }
7007}, cp = () => ({ state: n2, dispatch: e }) => Md(n2, e), up = () => ({ state: n2, dispatch: e }) => vd(n2, e);
7008function nc() {
7009  return typeof navigator < "u" ? /Mac/.test(navigator.platform) : false;
7010}
7011function dp(n2) {
7012  const e = n2.split(/-(?!$)/);
7013  let t = e[e.length - 1];
7014  t === "Space" && (t = " ");
7015  let r, s, i, o;
7016  for (let l = 0; l < e.length - 1; l += 1) {
7017    const a = e[l];
7018    if (/^(cmd|meta|m)$/i.test(a)) o = true;
7019    else if (/^a(lt)?$/i.test(a)) r = true;
7020    else if (/^(c|ctrl|control)$/i.test(a)) s = true;
7021    else if (/^s(hift)?$/i.test(a)) i = true;
7022    else if (/^mod$/i.test(a)) rr() || nc() ? o = true : s = true;
7023    else throw new Error(`Unrecognized modifier name: ${a}`);
7024  }
7025  return r && (t = `Alt-${t}`), s && (t = `Ctrl-${t}`), o && (t = `Meta-${t}`), i && (t = `Shift-${t}`), t;
7026}
7027var fp = (n2) => ({ editor: e, view: t, tr: r, dispatch: s }) => {
7028  const i = dp(n2).split(/-(?!$)/), o = i.find((c) => !["Alt", "Ctrl", "Meta", "Shift"].includes(c)), l = new KeyboardEvent("keydown", { key: o === "Space" ? " " : o, altKey: i.includes("Alt"), ctrlKey: i.includes("Ctrl"), metaKey: i.includes("Meta"), shiftKey: i.includes("Shift"), bubbles: true, cancelable: true }), a = e.captureTransaction(() => {
7029    t.someProp("handleKeyDown", (c) => c(t, l));
7030  });
7031  return a == null ? void 0 : a.steps.forEach((c) => {
7032    const u = c.map(r.mapping);
7033    u && s && r.maybeStep(u);
7034  }), true;
7035};
7036function rt(n2, e, t = {}) {
7037  const { from: r, to: s, empty: i } = n2.selection, o = e ? W(e, n2.schema) : null, l = [];
7038  n2.doc.nodesBetween(r, s, (d, f) => {
7039    if (d.isText) return;
7040    const h = Math.max(r, f), p = Math.min(s, f + d.nodeSize);
7041    l.push({ node: d, from: h, to: p });
7042  });
7043  const a = s - r, c = l.filter((d) => o ? o.name === d.node.type.name : true).filter((d) => nr(d.node.attrs, t, { strict: false }));
7044  return i ? !!c.length : c.reduce((d, f) => d + f.to - f.from, 0) >= a;
7045}
7046var hp = (n2, e = {}) => ({ state: t, dispatch: r }) => {
7047  const s = W(n2, t.schema);
7048  return rt(t, s, e) ? Ad(t, r) : false;
7049}, pp = () => ({ state: n2, dispatch: e }) => fa(n2, e), mp = (n2) => ({ state: e, dispatch: t }) => {
7050  const r = W(n2, e.schema);
7051  return Vd(r)(e, t);
7052}, gp = () => ({ state: n2, dispatch: e }) => ua(n2, e);
7053function _r(n2, e) {
7054  return e.nodes[n2] ? "node" : e.marks[n2] ? "mark" : null;
7055}
7056function Jo(n2, e) {
7057  const t = typeof e == "string" ? [e] : e;
7058  return Object.keys(n2).reduce((r, s) => (t.includes(s) || (r[s] = n2[s]), r), {});
7059}
7060var yp = (n2, e) => ({ tr: t, state: r, dispatch: s }) => {
7061  let i = null, o = null;
7062  const l = _r(typeof n2 == "string" ? n2 : n2.name, r.schema);
7063  if (!l) return false;
7064  l === "node" && (i = W(n2, r.schema)), l === "mark" && (o = $e(n2, r.schema));
7065  let a = false;
7066  return t.selection.ranges.forEach((c) => {
7067    r.doc.nodesBetween(c.$from.pos, c.$to.pos, (u, d) => {
7068      i && i === u.type && (a = true, s && t.setNodeMarkup(d, void 0, Jo(u.attrs, e))), o && u.marks.length && u.marks.forEach((f) => {
7069        o === f.type && (a = true, s && t.addMark(d, d + u.nodeSize, o.create(Jo(f.attrs, e))));
7070      });
7071    });
7072  }), a;
7073}, bp = () => ({ tr: n2, dispatch: e }) => (e && n2.scrollIntoView(), true), kp = () => ({ tr: n2, dispatch: e }) => {
7074  if (e) {
7075    const t = new de(n2.doc);
7076    n2.setSelection(t);
7077  }
7078  return true;
7079}, xp = () => ({ state: n2, dispatch: e }) => oa(n2, e), Sp = () => ({ state: n2, dispatch: e }) => ca(n2, e), wp = () => ({ state: n2, dispatch: e }) => Dd(n2, e), Cp = () => ({ state: n2, dispatch: e }) => Ld(n2, e), Mp = () => ({ state: n2, dispatch: e }) => Pd(n2, e);
7080function Vs(n2, e, t = {}, r = {}) {
7081  return kn(n2, e, { slice: false, parseOptions: t, errorOnInvalidContent: r.errorOnInvalidContent });
7082}
7083var vp = (n2, { errorOnInvalidContent: e, emitUpdate: t = true, parseOptions: r = {} } = {}) => ({ editor: s, tr: i, dispatch: o, commands: l }) => {
7084  const { doc: a } = i;
7085  if (r.preserveWhitespace !== "full") {
7086    const c = Vs(n2, s.schema, r, { errorOnInvalidContent: e ?? s.options.enableContentCheck });
7087    return o && i.replaceWith(0, a.content.size, c).setMeta("preventUpdate", !t), true;
7088  }
7089  return o && i.setMeta("preventUpdate", !t), l.insertContentAt({ from: 0, to: a.content.size }, n2, { parseOptions: r, errorOnInvalidContent: e ?? s.options.enableContentCheck });
7090};
7091function rc(n2, e) {
7092  const t = $e(e, n2.schema), { from: r, to: s, empty: i } = n2.selection, o = [];
7093  i ? (n2.storedMarks && o.push(...n2.storedMarks), o.push(...n2.selection.$head.marks())) : n2.doc.nodesBetween(r, s, (a) => {
7094    o.push(...a.marks);
7095  });
7096  const l = o.find((a) => a.type.name === t.name);
7097  return l ? { ...l.attrs } : {};
7098}
7099function sc(n2, e) {
7100  const t = new ea(n2);
7101  return e.forEach((r) => {
7102    r.steps.forEach((s) => {
7103      t.step(s);
7104    });
7105  }), t;
7106}
7107function Tp(n2) {
7108  for (let e = 0; e < n2.edgeCount; e += 1) {
7109    const { type: t } = n2.edge(e);
7110    if (t.isTextblock && !t.hasRequiredAttrs()) return t;
7111  }
7112  return null;
7113}
7114function Ep(n2, e, t) {
7115  const r = [];
7116  return n2.nodesBetween(e.from, e.to, (s, i) => {
7117    t(s) && r.push({ node: s, pos: i });
7118  }), r;
7119}
7120function Ap(n2, e) {
7121  for (let t = n2.depth; t > 0; t -= 1) {
7122    const r = n2.node(t);
7123    if (e(r)) return { pos: t > 0 ? n2.before(t) : 0, start: n2.start(t), depth: t, node: r };
7124  }
7125}
7126function jr(n2) {
7127  return (e) => Ap(e.$from, n2);
7128}
7129function v(n2, e, t) {
7130  return n2.config[e] === void 0 && n2.parent ? v(n2.parent, e, t) : typeof n2.config[e] == "function" ? n2.config[e].bind({ ...t, parent: n2.parent ? v(n2.parent, e, t) : null }) : n2.config[e];
7131}
7132function wi(n2) {
7133  return n2.map((e) => {
7134    const t = { name: e.name, options: e.options, storage: e.storage }, r = v(e, "addExtensions", t);
7135    return r ? [e, ...wi(r())] : e;
7136  }).flat(10);
7137}
7138function Ci(n2, e) {
7139  const t = Mt.fromSchema(e).serializeFragment(n2), s = document.implementation.createHTMLDocument().createElement("div");
7140  return s.appendChild(t), s.innerHTML;
7141}
7142function ic(n2) {
7143  return typeof n2 == "function";
7144}
7145function P(n2, e = void 0, ...t) {
7146  return ic(n2) ? e ? n2.bind(e)(...t) : n2(...t) : n2;
7147}
7148function Np(n2 = {}) {
7149  return Object.keys(n2).length === 0 && n2.constructor === Object;
7150}
7151function Vt(n2) {
7152  const e = n2.filter((s) => s.type === "extension"), t = n2.filter((s) => s.type === "node"), r = n2.filter((s) => s.type === "mark");
7153  return { baseExtensions: e, nodeExtensions: t, markExtensions: r };
7154}
7155function oc(n2) {
7156  const e = [], { nodeExtensions: t, markExtensions: r } = Vt(n2), s = [...t, ...r], i = { default: null, validate: void 0, rendered: true, renderHTML: null, parseHTML: null, keepOnSplit: true, isRequired: false }, o = t.filter((c) => c.name !== "text").map((c) => c.name), l = r.map((c) => c.name), a = [...o, ...l];
7157  return n2.forEach((c) => {
7158    const u = { name: c.name, options: c.options, storage: c.storage, extensions: s }, d = v(c, "addGlobalAttributes", u);
7159    if (!d) return;
7160    d().forEach((h) => {
7161      let p;
7162      Array.isArray(h.types) ? p = h.types : h.types === "*" ? p = a : h.types === "nodes" ? p = o : h.types === "marks" ? p = l : p = [], p.forEach((m) => {
7163        Object.entries(h.attributes).forEach(([g, y]) => {
7164          e.push({ type: m, name: g, attribute: { ...i, ...y } });
7165        });
7166      });
7167    });
7168  }), s.forEach((c) => {
7169    const u = { name: c.name, options: c.options, storage: c.storage }, d = v(c, "addAttributes", u);
7170    if (!d) return;
7171    const f = d();
7172    Object.entries(f).forEach(([h, p]) => {
7173      const m = { ...i, ...p };
7174      typeof (m == null ? void 0 : m.default) == "function" && (m.default = m.default()), (m == null ? void 0 : m.isRequired) && (m == null ? void 0 : m.default) === void 0 && delete m.default, e.push({ type: c.name, name: h, attribute: m });
7175    });
7176  }), e;
7177}
7178function Op(n2) {
7179  const e = [];
7180  let t = "", r = false, s = false, i = 0;
7181  const o = n2.length;
7182  for (let l = 0; l < o; l += 1) {
7183    const a = n2[l];
7184    if (a === "'" && !s) {
7185      r = !r, t += a;
7186      continue;
7187    }
7188    if (a === '"' && !r) {
7189      s = !s, t += a;
7190      continue;
7191    }
7192    if (!r && !s) {
7193      if (a === "(") {
7194        i += 1, t += a;
7195        continue;
7196      }
7197      if (a === ")" && i > 0) {
7198        i -= 1, t += a;
7199        continue;
7200      }
7201      if (a === ";" && i === 0) {
7202        e.push(t), t = "";
7203        continue;
7204      }
7205    }
7206    t += a;
7207  }
7208  return t && e.push(t), e;
7209}
7210function Go(n2) {
7211  const e = [], t = Op(n2 || ""), r = t.length;
7212  for (let s = 0; s < r; s += 1) {
7213    const i = t[s], o = i.indexOf(":");
7214    if (o === -1) continue;
7215    const l = i.slice(0, o).trim(), a = i.slice(o + 1).trim();
7216    l && a && e.push([l, a]);
7217  }
7218  return e;
7219}
7220function Y(...n2) {
7221  return n2.filter((e) => !!e).reduce((e, t) => {
7222    const r = { ...e };
7223    return Object.entries(t).forEach(([s, i]) => {
7224      if (!r[s]) {
7225        r[s] = i;
7226        return;
7227      }
7228      if (s === "class") {
7229        const l = i ? String(i).split(" ") : [], a = r[s] ? r[s].split(" ") : [], c = l.filter((u) => !a.includes(u));
7230        r[s] = [...a, ...c].join(" ");
7231      } else if (s === "style") {
7232        const l = new Map([...Go(r[s]), ...Go(i)]);
7233        r[s] = Array.from(l.entries()).map(([a, c]) => `${a}: ${c}`).join("; ");
7234      } else r[s] = i;
7235    }), r;
7236  }, {});
7237}
7238function xn(n2, e) {
7239  return e.filter((t) => t.type === n2.type.name).filter((t) => t.attribute.rendered).map((t) => t.attribute.renderHTML ? t.attribute.renderHTML(n2.attrs) || {} : { [t.name]: n2.attrs[t.name] }).reduce((t, r) => Y(t, r), {});
7240}
7241function Ip(n2) {
7242  return typeof n2 != "string" ? n2 : n2.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(n2) : n2 === "true" ? true : n2 === "false" ? false : n2;
7243}
7244function Yo(n2, e) {
7245  return "style" in n2 ? n2 : { ...n2, getAttrs: (t) => {
7246    const r = n2.getAttrs ? n2.getAttrs(t) : n2.attrs;
7247    if (r === false) return false;
7248    const s = e.reduce((i, o) => {
7249      const l = o.attribute.parseHTML ? o.attribute.parseHTML(t) : Ip(t.getAttribute(o.name));
7250      return l == null ? i : { ...i, [o.name]: l };
7251    }, {});
7252    return { ...r, ...s };
7253  } };
7254}
7255function Qo(n2) {
7256  return Object.fromEntries(Object.entries(n2).filter(([e, t]) => e === "attrs" && Np(t) ? false : t != null));
7257}
7258function Xo(n2) {
7259  var e, t;
7260  const r = {};
7261  return !((e = n2 == null ? void 0 : n2.attribute) != null && e.isRequired) && "default" in ((n2 == null ? void 0 : n2.attribute) || {}) && (r.default = n2.attribute.default), ((t = n2 == null ? void 0 : n2.attribute) == null ? void 0 : t.validate) !== void 0 && (r.validate = n2.attribute.validate), [n2.name, r];
7262}
7263function Dp(n2, e) {
7264  var t;
7265  const r = oc(n2), { nodeExtensions: s, markExtensions: i } = Vt(n2), o = (t = s.find((c) => v(c, "topNode"))) == null ? void 0 : t.name, l = Object.fromEntries(s.map((c) => {
7266    const u = r.filter((y) => y.type === c.name), d = { name: c.name, options: c.options, storage: c.storage, editor: e }, f = n2.reduce((y, x) => {
7267      const M = v(x, "extendNodeSchema", d);
7268      return { ...y, ...M ? M(c) : {} };
7269    }, {}), h = Qo({ ...f, content: P(v(c, "content", d)), marks: P(v(c, "marks", d)), group: P(v(c, "group", d)), inline: P(v(c, "inline", d)), atom: P(v(c, "atom", d)), selectable: P(v(c, "selectable", d)), draggable: P(v(c, "draggable", d)), code: P(v(c, "code", d)), whitespace: P(v(c, "whitespace", d)), linebreakReplacement: P(v(c, "linebreakReplacement", d)), defining: P(v(c, "defining", d)), isolating: P(v(c, "isolating", d)), attrs: Object.fromEntries(u.map(Xo)) }), p = P(v(c, "parseHTML", d));
7270    p && (h.parseDOM = p.map((y) => Yo(y, u)));
7271    const m = v(c, "renderHTML", d);
7272    m && (h.toDOM = (y) => m({ node: y, HTMLAttributes: xn(y, u) }));
7273    const g = v(c, "renderText", d);
7274    return g && (h.toText = g), [c.name, h];
7275  })), a = Object.fromEntries(i.map((c) => {
7276    const u = r.filter((g) => g.type === c.name), d = { name: c.name, options: c.options, storage: c.storage, editor: e }, f = n2.reduce((g, y) => {
7277      const x = v(y, "extendMarkSchema", d);
7278      return { ...g, ...x ? x(c) : {} };
7279    }, {}), h = Qo({ ...f, inclusive: P(v(c, "inclusive", d)), excludes: P(v(c, "excludes", d)), group: P(v(c, "group", d)), spanning: P(v(c, "spanning", d)), code: P(v(c, "code", d)), attrs: Object.fromEntries(u.map(Xo)) }), p = P(v(c, "parseHTML", d));
7280    p && (h.parseDOM = p.map((g) => Yo(g, u)));
7281    const m = v(c, "renderHTML", d);
7282    return m && (h.toDOM = (g) => m({ mark: g, HTMLAttributes: xn(g, u) })), [c.name, h];
7283  }));
7284  return new $l({ topNode: o, nodes: l, marks: a });
7285}
7286function Rp(n2) {
7287  const e = n2.filter((t, r) => n2.indexOf(t) !== r);
7288  return Array.from(new Set(e));
7289}
7290function sn(n2) {
7291  return n2.sort((t, r) => {
7292    const s = v(t, "priority") || 100, i = v(r, "priority") || 100;
7293    return s > i ? -1 : s < i ? 1 : 0;
7294  });
7295}
7296function lc(n2) {
7297  const e = sn(wi(n2)), t = Rp(e.map((r) => r.name));
7298  return t.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${t.map((r) => `'${r}'`).join(", ")}]. This can lead to issues.`), e;
7299}
7300function ac(n2, e, t) {
7301  const { from: r, to: s } = e, { blockSeparator: i = `
7302
7303`, textSerializers: o = {} } = t || {};
7304  let l = "";
7305  return n2.nodesBetween(r, s, (a, c, u, d) => {
7306    var f;
7307    a.isBlock && c > r && (l += i);
7308    const h = o == null ? void 0 : o[a.type.name];
7309    if (h) return u && (l += h({ node: a, pos: c, parent: u, index: d, range: e })), false;
7310    a.isText && (l += (f = a == null ? void 0 : a.text) == null ? void 0 : f.slice(Math.max(r, c) - c, s - c));
7311  }), l;
7312}
7313function Pp(n2, e) {
7314  const t = { from: 0, to: n2.content.size };
7315  return ac(n2, t, e);
7316}
7317function cc(n2) {
7318  return Object.fromEntries(Object.entries(n2.nodes).filter(([, e]) => e.spec.toText).map(([e, t]) => [e, t.spec.toText]));
7319}
7320function Lp(n2, e) {
7321  const t = W(e, n2.schema), { from: r, to: s } = n2.selection, i = [];
7322  n2.doc.nodesBetween(r, s, (l) => {
7323    i.push(l);
7324  });
7325  const o = i.reverse().find((l) => l.type.name === t.name);
7326  return o ? { ...o.attrs } : {};
7327}
7328function uc(n2, e) {
7329  const t = _r(typeof e == "string" ? e : e.name, n2.schema);
7330  return t === "node" ? Lp(n2, e) : t === "mark" ? rc(n2, e) : {};
7331}
7332function Bp(n2, e = JSON.stringify) {
7333  const t = {};
7334  return n2.filter((r) => {
7335    const s = e(r);
7336    return Object.prototype.hasOwnProperty.call(t, s) ? false : t[s] = true;
7337  });
7338}
7339function zp(n2) {
7340  const e = Bp(n2);
7341  return e.length === 1 ? e : e.filter((t, r) => !e.filter((i, o) => o !== r).some((i) => t.oldRange.from >= i.oldRange.from && t.oldRange.to <= i.oldRange.to && t.newRange.from >= i.newRange.from && t.newRange.to <= i.newRange.to));
7342}
7343function dc(n2) {
7344  const { mapping: e, steps: t } = n2, r = [];
7345  return e.maps.forEach((s, i) => {
7346    const o = [];
7347    if (s.ranges.length) s.forEach((l, a) => {
7348      o.push({ from: l, to: a });
7349    });
7350    else {
7351      const { from: l, to: a } = t[i];
7352      if (l === void 0 || a === void 0) return;
7353      o.push({ from: l, to: a });
7354    }
7355    o.forEach(({ from: l, to: a }) => {
7356      const c = e.slice(i).map(l, -1), u = e.slice(i).map(a), d = e.invert().map(c, -1), f = e.invert().map(u);
7357      r.push({ oldRange: { from: d, to: f }, newRange: { from: c, to: u } });
7358    });
7359  }), zp(r);
7360}
7361function Mi(n2, e, t) {
7362  const r = [];
7363  return n2 === e ? t.resolve(n2).marks().forEach((s) => {
7364    const i = t.resolve(n2), o = Si(i, s.type);
7365    o && r.push({ mark: s, ...o });
7366  }) : t.nodesBetween(n2, e, (s, i) => {
7367    !s || (s == null ? void 0 : s.nodeSize) === void 0 || r.push(...s.marks.map((o) => ({ from: i, to: i + s.nodeSize, mark: o })));
7368  }), r;
7369}
7370var $p = (n2, e, t, r = 20) => {
7371  const s = n2.doc.resolve(t);
7372  let i = r, o = null;
7373  for (; i > 0 && o === null; ) {
7374    const l = s.node(i);
7375    (l == null ? void 0 : l.type.name) === e ? o = l : i -= 1;
7376  }
7377  return [o, i];
7378};
7379function qt(n2, e) {
7380  return e.nodes[n2] || e.marks[n2] || null;
7381}
7382function _n(n2, e, t) {
7383  return Object.fromEntries(Object.entries(t).filter(([r]) => {
7384    const s = n2.find((i) => i.type === e && i.name === r);
7385    return s ? s.attribute.keepOnSplit : false;
7386  }));
7387}
7388var Fp = (n2, e = 500) => {
7389  let t = "";
7390  const r = n2.parentOffset;
7391  return n2.parent.nodesBetween(Math.max(0, r - e), r, (s, i, o, l) => {
7392    var a, c;
7393    const u = ((c = (a = s.type.spec).toText) == null ? void 0 : c.call(a, { node: s, pos: i, parent: o, index: l })) || s.textContent || "%leaf%";
7394    t += s.isAtom && !s.isText ? u : u.slice(0, Math.max(0, r - i));
7395  }), t;
7396};
7397function Hs(n2, e, t = {}) {
7398  const { empty: r, ranges: s } = n2.selection, i = e ? $e(e, n2.schema) : null;
7399  if (r) return !!(n2.storedMarks || n2.selection.$from.marks()).filter((d) => i ? i.name === d.type.name : true).find((d) => nr(d.attrs, t, { strict: false }));
7400  let o = 0;
7401  const l = [];
7402  if (s.forEach(({ $from: d, $to: f }) => {
7403    const h = d.pos, p = f.pos;
7404    n2.doc.nodesBetween(h, p, (m, g) => {
7405      if (i && m.inlineContent && !m.type.allowsMarkType(i)) return false;
7406      if (!m.isText && !m.marks.length) return;
7407      const y = Math.max(h, g), x = Math.min(p, g + m.nodeSize), M = x - y;
7408      o += M, l.push(...m.marks.map((E) => ({ mark: E, from: y, to: x })));
7409    });
7410  }), o === 0) return false;
7411  const a = l.filter((d) => i ? i.name === d.mark.type.name : true).filter((d) => nr(d.mark.attrs, t, { strict: false })).reduce((d, f) => d + f.to - f.from, 0), c = l.filter((d) => i ? d.mark.type !== i && d.mark.type.excludes(i) : true).reduce((d, f) => d + f.to - f.from, 0);
7412  return (a > 0 ? a + c : a) >= o;
7413}
7414function Vp(n2, e, t = {}) {
7415  if (!e) return rt(n2, null, t) || Hs(n2, null, t);
7416  const r = _r(e, n2.schema);
7417  return r === "node" ? rt(n2, e, t) : r === "mark" ? Hs(n2, e, t) : false;
7418}
7419var Hp = (n2, e) => {
7420  const { $from: t, $to: r, $anchor: s } = n2.selection;
7421  if (e) {
7422    const i = jr((l) => l.type.name === e)(n2.selection);
7423    if (!i) return false;
7424    const o = n2.doc.resolve(i.pos + 1);
7425    return s.pos + 1 === o.end();
7426  }
7427  return !(r.parentOffset < r.parent.nodeSize - 2 || t.pos !== r.pos);
7428}, _p = (n2) => {
7429  const { $from: e, $to: t } = n2.selection;
7430  return !(e.parentOffset > 0 || e.pos !== t.pos);
7431};
7432function Zo(n2, e) {
7433  return Array.isArray(e) ? e.some((t) => (typeof t == "string" ? t : t.name) === n2.name) : e;
7434}
7435function el(n2, e) {
7436  const { nodeExtensions: t } = Vt(e), r = t.find((o) => o.name === n2);
7437  if (!r) return false;
7438  const s = { name: r.name, options: r.options, storage: r.storage }, i = P(v(r, "group", s));
7439  return typeof i != "string" ? false : i.split(" ").includes("list");
7440}
7441function Wr(n2, { checkChildren: e = true, ignoreWhitespace: t = false } = {}) {
7442  var r;
7443  if (t) {
7444    if (n2.type.name === "hardBreak") return true;
7445    if (n2.isText) return /^\s*$/m.test((r = n2.text) != null ? r : "");
7446  }
7447  if (n2.isText) return !n2.text;
7448  if (n2.isAtom || n2.isLeaf) return false;
7449  if (n2.content.childCount === 0) return true;
7450  if (e) {
7451    let s = true;
7452    return n2.content.forEach((i) => {
7453      s !== false && (Wr(i, { ignoreWhitespace: t, checkChildren: e }) || (s = false));
7454    }), s;
7455  }
7456  return false;
7457}
7458function jp(n2) {
7459  return n2 instanceof T;
7460}
7461var fc = class hc {
7462  constructor(e) {
7463    this.position = e;
7464  }
7465  static fromJSON(e) {
7466    return new hc(e.position);
7467  }
7468  toJSON() {
7469    return { position: this.position };
7470  }
7471};
7472function Wp(n2, e) {
7473  const t = e.mapping.mapResult(n2.position);
7474  return { position: new fc(t.pos), mapResult: t };
7475}
7476function Up(n2) {
7477  return new fc(n2);
7478}
7479function Kp(n2, e, t) {
7480  var r;
7481  const { selection: s } = e;
7482  let i = null;
7483  if (Za(s) && (i = s.$cursor), i) {
7484    const l = (r = n2.storedMarks) != null ? r : i.marks();
7485    return i.parent.type.allowsMarkType(t) && (!!t.isInSet(l) || !l.some((c) => c.type.excludes(t)));
7486  }
7487  const { ranges: o } = s;
7488  return o.some(({ $from: l, $to: a }) => {
7489    let c = l.depth === 0 ? n2.doc.inlineContent && n2.doc.type.allowsMarkType(t) : false;
7490    return n2.doc.nodesBetween(l.pos, a.pos, (u, d, f) => {
7491      if (c) return false;
7492      if (u.isInline) {
7493        const h = !f || f.type.allowsMarkType(t), p = !!t.isInSet(u.marks) || !u.marks.some((m) => m.type.excludes(t));
7494        c = h && p;
7495      }
7496      return !c;
7497    }), c;
7498  });
7499}
7500var qp = (n2, e = {}) => ({ tr: t, state: r, dispatch: s }) => {
7501  const { selection: i } = t, { empty: o, ranges: l } = i, a = $e(n2, r.schema);
7502  if (s) if (o) {
7503    const c = rc(r, a);
7504    t.addStoredMark(a.create({ ...c, ...e }));
7505  } else l.forEach((c) => {
7506    const u = c.$from.pos, d = c.$to.pos;
7507    r.doc.nodesBetween(u, d, (f, h) => {
7508      const p = Math.max(h, u), m = Math.min(h + f.nodeSize, d);
7509      f.marks.find((y) => y.type === a) ? f.marks.forEach((y) => {
7510        a === y.type && t.addMark(p, m, a.create({ ...y.attrs, ...e }));
7511      }) : t.addMark(p, m, a.create(e));
7512    });
7513  });
7514  return Kp(r, t, a);
7515}, Jp = (n2, e) => ({ tr: t }) => (t.setMeta(n2, e), true), Gp = (n2, e = {}) => ({ state: t, dispatch: r, chain: s }) => {
7516  const i = W(n2, t.schema);
7517  let o;
7518  return t.selection.$anchor.sameParent(t.selection.$head) && (o = t.selection.$anchor.parent.attrs), i.isTextblock ? s().command(({ commands: l }) => fo(i, { ...o, ...e })(t) ? true : l.clearNodes()).command(({ state: l }) => fo(i, { ...o, ...e })(l, r)).run() : (console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'), false);
7519}, Yp = (n2) => ({ tr: e, dispatch: t }) => {
7520  if (t) {
7521    const { doc: r } = e, s = ht(n2, 0, r.content.size), i = T.create(r, s);
7522    e.setSelection(i);
7523  }
7524  return true;
7525}, Qp = (n2, e) => ({ tr: t, state: r, dispatch: s }) => {
7526  const { selection: i } = r;
7527  let o, l;
7528  return typeof e == "number" ? (o = e, l = e) : e && "from" in e && "to" in e ? (o = e.from, l = e.to) : (o = i.from, l = i.to), s && t.doc.nodesBetween(o, l, (a, c) => {
7529    a.isText || t.setNodeMarkup(c, void 0, { ...a.attrs, dir: n2 });
7530  }), true;
7531}, Xp = (n2) => ({ tr: e, dispatch: t }) => {
7532  if (t) {
7533    const { doc: r } = e, { from: s, to: i } = typeof n2 == "number" ? { from: n2, to: n2 } : n2, o = I.atStart(r).from, l = I.atEnd(r).to, a = ht(s, o, l), c = ht(i, o, l), u = I.create(r, a, c);
7534    e.setSelection(u);
7535  }
7536  return true;
7537}, Zp = (n2) => ({ state: e, dispatch: t }) => {
7538  const r = W(n2, e.schema);
7539  return jd(r)(e, t);
7540};
7541function tl(n2, e) {
7542  const t = n2.storedMarks || n2.selection.$to.parentOffset && n2.selection.$from.marks();
7543  if (t) {
7544    const r = t.filter((s) => e == null ? void 0 : e.includes(s.type.name));
7545    n2.tr.ensureMarks(r);
7546  }
7547}
7548var em = ({ keepMarks: n2 = true } = {}) => ({ tr: e, state: t, dispatch: r, editor: s }) => {
7549  const { selection: i, doc: o } = e, { $from: l, $to: a } = i, c = s.extensionManager.attributes, u = _n(c, l.node().type.name, l.node().attrs);
7550  if (i instanceof T && i.node.isBlock) return !l.parentOffset || !Be(o, l.pos) ? false : (r && (n2 && tl(t, s.extensionManager.splittableMarks), e.split(l.pos).scrollIntoView()), true);
7551  if (!l.parent.isBlock) return false;
7552  const d = a.parentOffset === a.parent.content.size, f = l.depth === 0 ? void 0 : Tp(l.node(-1).contentMatchAt(l.indexAfter(-1)));
7553  let h = d && f ? [{ type: f, attrs: u }] : void 0, p = Be(e.doc, e.mapping.map(l.pos), 1, h);
7554  if (!h && !p && Be(e.doc, e.mapping.map(l.pos), 1, f ? [{ type: f }] : void 0) && (p = true, h = f ? [{ type: f, attrs: u }] : void 0), r) {
7555    if (p && (i instanceof I && e.deleteSelection(), e.split(e.mapping.map(l.pos), 1, h), f && !d && !l.parentOffset && l.parent.type !== f)) {
7556      const m = e.mapping.map(l.before()), g = e.doc.resolve(m);
7557      l.node(-1).canReplaceWith(g.index(), g.index() + 1, f) && e.setNodeMarkup(e.mapping.map(l.before()), f);
7558    }
7559    n2 && tl(t, s.extensionManager.splittableMarks), e.scrollIntoView();
7560  }
7561  return p;
7562}, tm = (n2, e = {}) => ({ tr: t, state: r, dispatch: s, editor: i }) => {
7563  var o;
7564  const l = W(n2, r.schema), { $from: a, $to: c } = r.selection, u = r.selection.node;
7565  if (u && u.isBlock || a.depth < 2 || !a.sameParent(c)) return false;
7566  const d = a.node(-1);
7567  if (d.type !== l) return false;
7568  const f = i.extensionManager.attributes;
7569  if (a.parent.content.size === 0 && a.node(-1).childCount === a.indexAfter(-1)) {
7570    if (a.depth === 2 || a.node(-3).type !== l || a.index(-2) !== a.node(-2).childCount - 1) return false;
7571    if (s) {
7572      let y = b.empty;
7573      const x = a.index(-1) ? 1 : a.index(-2) ? 2 : 3;
7574      for (let O = a.depth - x; O >= a.depth - 3; O -= 1) y = b.from(a.node(O).copy(y));
7575      const M = a.indexAfter(-1) < a.node(-2).childCount ? 1 : a.indexAfter(-2) < a.node(-3).childCount ? 2 : 3, E = { ..._n(f, a.node().type.name, a.node().attrs), ...e }, C = ((o = l.contentMatch.defaultType) == null ? void 0 : o.createAndFill(E)) || void 0;
7576      y = y.append(b.from(l.createAndFill(null, C) || void 0));
7577      const N = a.before(a.depth - (x - 1));
7578      t.replace(N, a.after(-M), new w(y, 4 - x, 0));
7579      let S = -1;
7580      t.doc.nodesBetween(N, t.doc.content.size, (O, A) => {
7581        if (S > -1) return false;
7582        O.isTextblock && O.content.size === 0 && (S = A + 1);
7583      }), S > -1 && t.setSelection(I.near(t.doc.resolve(S))), t.scrollIntoView();
7584    }
7585    return true;
7586  }
7587  const h = c.pos === a.end() ? d.contentMatchAt(0).defaultType : null, p = { ..._n(f, d.type.name, d.attrs), ...e }, m = { ..._n(f, a.node().type.name, a.node().attrs), ...e };
7588  t.delete(a.pos, c.pos);
7589  const g = h ? [{ type: l, attrs: p }, { type: h, attrs: m }] : [{ type: l, attrs: p }];
7590  if (!Be(t.doc, a.pos, 2)) return false;
7591  if (s) {
7592    const { selection: y, storedMarks: x } = r, { splittableMarks: M } = i.extensionManager, E = x || y.$to.parentOffset && y.$from.marks();
7593    if (t.split(a.pos, 2, g).scrollIntoView(), !E || !s) return true;
7594    const C = E.filter((N) => M.includes(N.type.name));
7595    t.ensureMarks(C);
7596  }
7597  return true;
7598}, ps = (n2, e) => {
7599  const t = jr((o) => o.type === e)(n2.selection);
7600  if (!t) return true;
7601  const r = n2.doc.resolve(Math.max(0, t.pos - 1)).before(t.depth);
7602  if (r === void 0) return true;
7603  const s = n2.doc.nodeAt(r);
7604  return t.node.type === (s == null ? void 0 : s.type) && st(n2.doc, t.pos) && n2.join(t.pos), true;
7605}, ms = (n2, e) => {
7606  const t = jr((o) => o.type === e)(n2.selection);
7607  if (!t) return true;
7608  const r = n2.doc.resolve(t.start).after(t.depth);
7609  if (r === void 0) return true;
7610  const s = n2.doc.nodeAt(r);
7611  return t.node.type === (s == null ? void 0 : s.type) && st(n2.doc, r) && n2.join(r), true;
7612}, nm = (n2, e, t, r = {}) => ({ editor: s, tr: i, state: o, dispatch: l, chain: a, commands: c, c
7612an: u }) => {
7613  const { extensions: d, splittableMarks: f } = s.extensionManager, h = W(n2, o.schema), p = W(e, o.schema), { selection: m, storedMarks: g } = o, { $from: y, $to: x } = m, M = y.blockRange(x), E = g || m.$to.parentOffset && m.$from.marks();
7614  if (!M) return false;
7615  const C = jr((N) => el(N.type.name, d))(m);
7616  if (M.depth >= 1 && C && M.depth - C.depth <= 1) {
7617    if (C.node.type === h) return c.liftListItem(p);
7618    if (el(C.node.type.name, d) && h.validContent(C.node.content) && l) return a().command(() => (i.setNodeMarkup(C.pos, h), true)).command(() => ps(i, h)).command(() => ms(i, h)).run();
7619  }
7620  return !t || !E || !l ? a().command(() => u().wrapInList(h, r) ? true : c.clearNodes()).wrapInList(h, r).command(() => ps(i, h)).command(() => ms(i, h)).run() : a().command(() => {
7621    const N = u().wrapInList(h, r), S = E.filter((O) => f.includes(O.type.name));
7622    return i.ensureMarks(S), N ? true : c.clearNodes();
7623  }).wrapInList(h, r).command(() => ps(i, h)).command(() => ms(i, h)).run();
7624}, rm = (n2, e = {}, t = {}) => ({ state: r, commands: s }) => {
7625  const { extendEmptyMarkRange: i = false } = t, o = $e(n2, r.schema);
7626  return Hs(r, o, e) ? s.unsetMark(o, { extendEmptyMarkRange: i }) : s.setMark(o, e);
7627}, sm = (n2, e, t = {}) => ({ state: r, commands: s }) => {
7628  const i = W(n2, r.schema), o = W(e, r.schema), l = rt(r, i, t);
7629  let a;
7630  return r.selection.$anchor.sameParent(r.selection.$head) && (a = r.selection.$anchor.parent.attrs), l ? s.setNode(o, a) : s.setNode(i, { ...a, ...t });
7631}, im = (n2, e = {}) => ({ state: t, commands: r }) => {
7632  const s = W(n2, t.schema);
7633  return rt(t, s, e) ? r.lift(s) : r.wrapIn(s, e);
7634}, om = () => ({ state: n2, dispatch: e }) => {
7635  const t = n2.plugins;
7636  for (let r = 0; r < t.length; r += 1) {
7637    const s = t[r];
7638    let i;
7639    if (s.spec.isInputRules && (i = s.getState(n2))) {
7640      if (e) {
7641        const o = n2.tr, l = i.transform;
7642        for (let a = l.steps.length - 1; a >= 0; a -= 1) o.step(l.steps[a].invert(l.docs[a]));
7643        if (i.text) {
7644          const a = o.doc.resolve(i.from).marks();
7645          o.replaceWith(i.from, i.to, n2.schema.text(i.text, a));
7646        } else o.delete(i.from, i.to);
7647      }
7648      return true;
7649    }
7650  }
7651  return false;
7652}, lm = () => ({ tr: n2, dispatch: e }) => {
7653  const { selection: t } = n2, { empty: r, ranges: s } = t;
7654  return r || e && s.forEach((i) => {
7655    n2.removeMark(i.$from.pos, i.$to.pos);
7656  }), true;
7657}, am = (n2, e = {}) => ({ tr: t, state: r, dispatch: s }) => {
7658  var i;
7659  const { extendEmptyMarkRange: o = false } = e, { selection: l } = t, a = $e(n2, r.schema), { $from: c, empty: u, ranges: d } = l;
7660  if (!s) return true;
7661  if (u && o) {
7662    let { from: f, to: h } = l;
7663    const p = (i = c.marks().find((g) => g.type === a)) == null ? void 0 : i.attrs, m = Si(c, a, p);
7664    m && (f = m.from, h = m.to), t.removeMark(f, h, a);
7665  } else d.forEach((f) => {
7666    t.removeMark(f.$from.pos, f.$to.pos, a);
7667  });
7668  return t.removeStoredMark(a), true;
7669}, cm = (n2) => ({ tr: e, state: t, dispatch: r }) => {
7670  const { selection: s } = t;
7671  let i, o;
7672  return typeof n2 == "number" ? (i = n2, o = n2) : n2 && "from" in n2 && "to" in n2 ? (i = n2.from, o = n2.to) : (i = s.from, o = s.to), r && e.doc.nodesBetween(i, o, (l, a) => {
7673    if (l.isText) return;
7674    const c = { ...l.attrs };
7675    delete c.dir, e.setNodeMarkup(a, void 0, c);
7676  }), true;
7677}, um = (n2, e = {}) => ({ tr: t, state: r, dispatch: s }) => {
7678  let i = null, o = null;
7679  const l = _r(typeof n2 == "string" ? n2 : n2.name, r.schema);
7680  if (!l) return false;
7681  l === "node" && (i = W(n2, r.schema)), l === "mark" && (o = $e(n2, r.schema));
7682  let a = false;
7683  return t.selection.ranges.forEach((c) => {
7684    const u = c.$from.pos, d = c.$to.pos;
7685    let f, h, p, m;
7686    t.selection.empty ? r.doc.nodesBetween(u, d, (g, y) => {
7687      i && i === g.type && (a = true, p = Math.max(y, u), m = Math.min(y + g.nodeSize, d), f = y, h = g);
7688    }) : r.doc.nodesBetween(u, d, (g, y) => {
7689      y < u && i && i === g.type && (a = true, p = Math.max(y, u), m = Math.min(y + g.nodeSize, d), f = y, h = g), y >= u && y <= d && (i && i === g.type && (a = true, s && t.setNodeMarkup(y, void 0, { ...g.attrs, ...e })), o && g.marks.length && g.marks.forEach((x) => {
7690        if (o === x.type && (a = true, s)) {
7691          const M = Math.max(y, u), E = Math.min(y + g.nodeSize, d);
7692          t.addMark(M, E, o.create({ ...x.attrs, ...e }));
7693        }
7694      }));
7695    }), h && (f !== void 0 && s && t.setNodeMarkup(f, void 0, { ...h.attrs, ...e }), o && h.marks.length && h.marks.forEach((g) => {
7696      o === g.type && s && t.addMark(p, m, o.create({ ...g.attrs, ...e }));
7697    }));
7698  }), a;
7699}, dm = (n2, e = {}) => ({ state: t, dispatch: r }) => {
7700  const s = W(n2, t.schema);
7701  return Bd(s, e)(t, r);
7702}, fm = (n2, e = {}) => ({ state: t, dispatch: r }) => {
7703  const s = W(n2, t.schema);
7704  return zd(s, e)(t, r);
7705}, hm = class {
7706  constructor() {
7707    this.callbacks = {};
7708  }
7709  on(n2, e) {
7710    return this.callbacks[n2] || (this.callbacks[n2] = []), this.callbacks[n2].push(e), this;
7711  }
7712  emit(n2, ...e) {
7713    const t = this.callbacks[n2];
7714    return t && t.forEach((r) => r.apply(this, e)), this;
7715  }
7716  off(n2, e) {
7717    const t = this.callbacks[n2];
7718    return t && (e ? this.callbacks[n2] = t.filter((r) => r !== e) : delete this.callbacks[n2]), this;
7719  }
7720  once(n2, e) {
7721    const t = (...r) => {
7722      this.off(n2, t), e.apply(this, r);
7723    };
7724    return this.on(n2, t);
7725  }
7726  removeAllListeners() {
7727    this.callbacks = {};
7728  }
7729}, Ur = class {
7730  constructor(n2) {
7731    var e;
7732    this.find = n2.find, this.handler = n2.handler, this.undoable = (e = n2.undoable) != null ? e : true;
7733  }
7734}, pm = (n2, e) => {
7735  if (xi(e)) return e.exec(n2);
7736  const t = e(n2);
7737  if (!t) return null;
7738  const r = [t.text];
7739  return r.index = t.index, r.input = n2, r.data = t.data, t.replaceWith && (t.text.includes(t.replaceWith) || console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'), r.push(t.replaceWith)), r;
7740};
7741function Rn(n2) {
7742  var e;
7743  const { editor: t, from: r, to: s, text: i, rules: o, plugin: l } = n2, { view: a } = t;
7744  if (a.composing) return false;
7745  const c = a.state.doc.resolve(r);
7746  if (c.parent.type.spec.code || (e = c.nodeBefore || c.nodeAfter) != null && e.marks.find((f) => f.type.spec.code)) return false;
7747  let u = false;
7748  const d = Fp(c) + i;
7749  return o.forEach((f) => {
7750    if (u) return;
7751    const h = pm(d, f.find);
7752    if (!h) return;
7753    const p = a.state.tr, m = Vr({ state: a.state, transaction: p }
7753), g = { from: r - (h[0].length - i.length), to: s }, { commands: y, chain: x, can: M } = new Hr({ editor: t, state: m });
7754    f.handler({ state: m, range: g, match: h, commands: y, chain: x, can: M }) === null || !p.steps.length || (f.undoable && p.setMeta(l, { transform: p, from: r, to: s, text: i }), a.dispatch(p), u = true);
7755  }), u;
7756}
7757function mm(n2) {
7758  const { editor: e, rules: t } = n2, r = new F({ state: { init() {
7759    return null;
7760  }, apply(s, i, o) {
7761    const l = s.getMeta(r);
7762    if (l) return l;
7763    const a = s.getMeta("applyInputRules");
7764    return a && setTimeout(() => {
7765      let { text: u } = a;
7766      typeof u == "string" ? u = u : u = Ci(b.from(u), o.schema);
7767      const { from: d } = a, f = d + u.length;
7768      Rn({ editor: e, from: d, to: f, text: u, rules: t, plugin: r });
7769    }), s.selectionSet || s.docChanged ? null : i;
7770  } }, props: { handleTextInput(s, i, o, l) {
7771    return Rn({ editor: e, from: i, to: o, text: l, rules: t, plugin: r });
7772  }, handleDOMEvents: { compositionend: (s) => (setTimeout(() => {
7773    const { $cursor: i } = s.state.selection;
7774    i && Rn({ editor: e, from: i.pos, to: i.pos, text: "", rules: t, plugin: r });
7775  }), false) }, handleKeyDown(s, i) {
7776    if (i.key !== "Enter") return false;
7777    const { $cursor: o } = s.state.selection;
7778    return o ? Rn({ editor: e, from: o.pos, to: o.pos, text: `
7779`, rules: t, plugin: r }) : false;
7780  } }, isInputRules: true });
7781  return r;
7782}
7783function gm(n2) {
7784  return Object.prototype.toString.call(n2).slice(8, -1);
7785}
7786function Pn(n2) {
7787  return gm(n2) !== "Object" ? false : n2.constructor === Object && Object.getPrototypeOf(n2) === Object.prototype;
7788}
7789function pc(n2, e) {
7790  const t = { ...n2 };
7791  return Pn(n2) && Pn(e) && Object.keys(e).forEach((r) => {
7792    Pn(e[r]) && Pn(n2[r]) ? t[r] = pc(n2[r], e[r]) : t[r] = e[r];
7793  }), t;
7794}
7795var vi = class {
7796  constructor(n2 = {}) {
7797    this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { name: this.name }, this.config = { ...this.config, ...n2 }, this.name = this.config.name;
7798  }
7799  get options() {
7800    return { ...P(v(this, "addOptions", { name: this.name })) || {} };
7801  }
7802  get storage() {
7803    return { ...P(v(this, "addStorage", { name: this.name, options: this.options })) || {} };
7804  }
7805  configure(n2 = {}) {
7806    const e = this.extend({ ...this.config, addOptions: () => pc(this.options, n2) });
7807    return e.name = this.name, e.parent = this.parent, e;
7808  }
7809  extend(n2 = {}) {
7810    const e = new this.constructor({ ...this.config, ...n2 });
7811    return e.parent = this, this.child = e, e.name = "name" in n2 ? n2.name : e.parent.name, e;
7812  }
7813}, Wt = class mc extends vi {
7814  constructor() {
7815    super(...arguments), this.type = "mark";
7816  }
7817  static create(e = {}) {
7818    const t = typeof e == "function" ? e() : e;
7819    return new mc(t);
7820  }
7821  static handleExit({ editor: e, mark: t }) {
7822    const { tr: r } = e.state, s = e.state.selection.$from;
7823    if (s.pos === s.end()) {
7824      const o = s.marks();
7825      if (!!!o.find((c) => (c == null ? void 0 : c.type.name) === t.name)) return false;
7826      const a = o.find((c) => (c == null ? void 0 : c.type.name) === t.name);
7827      return a && r.removeStoredMark(a), r.insertText(" ", s.pos), e.view.dispatch(r), true;
7828    }
7829    return false;
7830  }
7831  configure(e) {
7832    return super.configure(e);
7833  }
7834  extend(e) {
7835    const t = typeof e == "function" ? e() : e;
7836    return super.extend(t);
7837  }
7838};
7839function ym(n2) {
7840  return typeof n2 == "number";
7841}
7842var bm = class {
7843  constructor(n2) {
7844    this.find = n2.find, this.handler = n2.handler;
7845  }
7846}, km = (n2, e, t) => {
7847  if (xi(e)) return [...n2.matchAll(e)];
7848  const r = e(n2, t);
7849  return r ? r.map((s) => {
7850    const i = [s.text];
7851    return i.index = s.index, i.input = n2, i.data = s.data, s.replaceWith && (s.text.includes(s.replaceWith) || console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'), i.push(s.replaceWith)), i;
7852  }) : [];
7853};
7854function xm(n2) {
7855  const { editor: e, state: t, from: r, to: s, rule: i, pasteEvent: o, dropEvent: l } = n2, { commands: a, chain: c, can: u } = new Hr({ editor: e, state: t }), d = [];
7856  return t.doc.nodesBetween(r, s, (h, p) => {
7857    var m, g, y, x, M;
7858    if ((g = (m = h.type) == null ? void 0 : m.spec) != null && g.code || !(h.isText || h.isTextblock || h.isInline)) return;
7859    const E = (M = (x = (y = h.content) == null ? void 0 : y.size) != null ? x : h.nodeSize) != null ? M : 0, C = Math.max(r, p), N = Math.min(s, p + E);
7860    if (C >= N) return;
7861    const S = h.isText ? h.text || "" : h.textBetween(C - p, N - p, void 0, "\uFFFC");
7862    km(S, i.find, o).forEach((A) => {
7863      if (A.index === void 0) return;
7864      const L = C + A.index + 1, ot = L + A[0].length, Fe = { from: t.tr.mapping.map(L), to: t.tr.mapping.map(ot) }, vt = i.handler({ state: t, range: Fe, match: A, commands: a, chain: c, can: u, pasteEvent: o, dropEvent: l });
7865      d.push(vt);
7866    });
7867  }), d.every((h) => h !== null);
7868}
7869var Ln = null, Sm = (n2) => {
7870  var e;
7871  const t = new ClipboardEvent("paste", { clipboardData: new DataTransfer() });
7872  return (e = t.clipboardData) == null || e.setData("text/html", n2), t;
7873};
7874function wm(n2) {
7875  const { editor: e, rules: t } = n2;
7876  let r = null, s = false, i = false, o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, l;
7877  try {
7878    l = typeof DragEvent < "u" ? new DragEvent("drop") : null;
7879  } catch {
7880    l = null;
7881  }
7882  const a = ({ state: u, from: d, to: f, rule: h, pasteEvt: p }) => {
7883    const m = u.tr, g = Vr({ state: u, transaction: m });
7884    if (!(!xm({ editor: e, state: g, from: Math.max(d - 1, 0), to: f.b - 1, rule: h, pasteEvent: p, dropEvent: l }) || !m.steps.length)) {
7885      try {
7886        l = typeof DragEvent < "u" ? new DragEvent("drop") : null;
7887      } catch {
7888        l = null;
7889      }
7890      return o = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, m;
7891    }
7892  };
7893  return t.map((u) => new F({ view(d) {
7894    const f = (p) => {
7895      var m;
7896      r = (m = d.dom.parentElement) != null && m.contains(p.target) ? d.dom.parentElement : null, r && (Ln = e);
7897    }, h = () => {
7898      Ln && (Ln = null);
7899    };
7900    return window.addEventListener("dragstart", f), window.addEventListener("dragend", h), { destroy() {
7901      window.removeEventListener("dragstart", f), window.removeEventListener("dragend", h);
7902    } };
7903  }, props: { handleDOMEvents: { drop: (d, f) => {
7904    if (i = r === d.dom.parentElement, l = f, !i) {
7905      const h = Ln;
7906      (h == null ? void 0 : h.isEditable) && setTimeout(() => {
7907        const p = h.state.selection;
7908        p && h.commands.deleteRange({ from: p.from, to: p.to });
7909      }, 10);
7910    }
7911    return false;
7912  }, paste: (d, f) => {
7913    var h;
7914    const p = (h = f.clipboardData) == null ? void 0 : h.getData("text/html");
7915    return o = f, s = !!(p == null ? void 0 : p.includes("data-pm-slice")), false;
7916  } } }, appendTransaction: (d, f, h) => {
7917    const p = d[0], m = p.getMeta("uiEvent") === "paste" && !s, g = p.getMeta("uiEvent") === "drop" && !i, y = p.getMeta("applyPasteRules"), x = !!y;
7918    if (!m && !g && !x) return;
7919    if (x) {
7920      let { text: C } = y;
7921      typeof C == "string" ? C = C : C = Ci(b.from(C), h.schema);
7922      const { from: N } = y, S = N + C.length, O = Sm(C);
7923      return a({ rule: u, state: h, from: N, to: { b: S }, pasteEvt: O });
7924    }
7925    const M = f.doc.content.findDiffStart(h.doc.content), E = f.doc.content.findDiffEnd(h.doc.content);
7926    if (!(!ym(M) || !E || M === E.b)) return a({ rule: u, state: h, from: M, to: E, pasteEvt: o });
7927  } }));
7928}
7929var Kr = class {
7930  constructor(n2, e) {
7931    this.splittableMarks = [], this.editor = e, this.baseExtensions = n2, this.extensions = lc(n2), this.schema = Dp(this.extensions, e), this.setupExtensions();
7932  }
7933  get commands() {
7934    return this.extensions.reduce((n2, e) => {
7935      const t = { name: e.name, options: e.options, storage: this.editor.extensionStorage[e.name], editor: this.editor, type: qt(e.name, this.schema) }, r = v(e, "addCommands", t);
7936      return r ? { ...n2, ...r() } : n2;
7937    }, {});
7938  }
7939  get plugins() {
7940    const { editor: n2 } = this;
7941    return sn([...this.extensions].reverse()).flatMap((r) => {
7942      const s = { name: r.name, options: r.options, storage: this.editor.extensionStorage[r.name], editor: n2, type: qt(r.name, this.schema) }, i = [], o = v(r, "addKeyboardShortcuts", s);
7943      let l = {};
7944      if (r.type === "mark" && v(r, "exitable", s) && (l.ArrowRight = () => Wt.handleExit({ editor: n2, mark: r })), o) {
7945        const f = Object.fromEntries(Object.entries(o()).map(([h, p]) => [h, () => p({ editor: n2 })]));
7946        l = { ...l, ...f };
7947      }
7948      const a = Ph(l);
7949      i.push(a);
7950      const c = v(r, "addInputRules", s);
7951      if (Zo(r, n2.options.enableInputRules) && c) {
7952        const f = c();
7953        if (f && f.length) {
7954          const h = mm({ editor: n2, rules: f }), p = Array.isArray(h) ? h : [h];
7955          i.push(...p);
7956        }
7957      }
7958      const u = v(r, "addPasteRules", s);
7959      if (Zo(r, n2.options.enablePasteRules) && u) {
7960        const f = u();
7961        if (f && f.length) {
7962          const h = wm({ editor: n2, rules: f });
7963          i.push(...h);
7964        }
7965      }
7966      const d = v(r, "addProseMirrorPlugins", s);
7967      if (d) {
7968        const f = d();
7969        i.push(...f);
7970      }
7971      return i;
7972    });
7973  }
7974  get attributes() {
7975    return oc(this.extensions);
7976  }
7977  get nodeViews() {
7978    const { editor: n2 } = this, { nodeExtensions: e } = Vt(this.extensions);
7979    return Object.fromEntries(e.filter((t) => !!v(t, "addNodeView")).map((t) => {
7980      const r = this.attributes.filter((a) => a.type === t.name), s = { name: t.name, options: t.options, storage: this.editor.extensionStorage[t.name], editor: n2, type: W(t.
7980name, this.schema) }, i = v(t, "addNodeView", s);
7981      if (!i) return [];
7982      const o = i();
7983      if (!o) return [];
7984      const l = (a, c, u, d, f) => {
7985        const h = xn(a, r);
7986        return o({ node: a, view: c, getPos: u, decorations: d, innerDecorations: f, editor: n2, extension: t, HTMLAttributes: h });
7987      };
7988      return [t.name, l];
7989    }));
7990  }
7991  dispatchTransaction(n2) {
7992    const { editor: e } = this;
7993    return sn([...this.extensions].reverse()).reduceRight((r, s) => {
7994      const i = { name: s.name, options: s.options, storage: this.editor.extensionStorage[s.name], editor: e, type: qt(s.name, this.schema) }, o = v(s, "dispatchTransaction", i);
7995      return o ? (l) => {
7996        o.call(i, { transaction: l, next: r });
7997      } : r;
7998    }, n2);
7999  }
8000  transformPastedHTML(n2) {
8001    const { editor: e } = this;
8002    return sn([...this.extensions]).reduce((r, s) => {
8003      const i = { name: s.name, options: s.options, storage: this.editor.extensionStorage[s.name], editor: e, type: qt(s.name, this.schema) }, o = v(s, "transformPastedHTML", i);
8004      return o ? (l, a) => {
8005        const c = r(l, a);
8006        return o.call(i, c);
8007      } : r;
8008    }, n2 || ((r) => r));
8009  }
8010  get markViews() {
8011    const { editor: n2 } = this, { markExtensions: e } = Vt(this.extensions);
8012    return Object.fromEntries(e.filter((t) => !!v(t, "addMarkView")).map((t) => {
8013      const r = this.attributes.filter((l) => l.type === t.name), s = { name: t.name, options: t.options, storage: this.editor.extensionStorage[t.name], editor: n2, type: $e(t.name, this.schema) }, i = v(t, "addMarkView", s);
8014      if (!i) return [];
8015      const o = (l, a, c) => {
8016        const u = xn(l, r);
8017        return i()({ mark: l, view: a, inline: c, editor: n2, extension: t, HTMLAttributes: u, updateAttributes: (d) => {
8018          Pm(l, n2, d);
8019        } });
8020      };
8021      return [t.name, o];
8022    }));
8023  }
8024  setupExtensions() {
8025    const n2 = this.extensions;
8026    this.editor.extensionStorage = Object.fromEntries(n2.map((e) => [e.name, e.storage])), n2.forEach((e) => {
8027      var t;
8028      const r = { name: e.name, options: e.options, storage: this.editor.extensionStorage[e.name], editor: this.editor, type: qt(e.name, this.schema) };
8029      e.type === "mark" && ((t = P(v(e, "keepOnSplit", r))) == null || t) && this.splittableMarks.push(e.name);
8030      const s = v(e, "onBeforeCreate", r), i = v(e, "onCreate", r), o = v(e, "onUpdate", r), l = v(e, "onSelectionUpdate", r), a = v(e, "onTransaction", r), c = v(e, "onFocus", r), u = v(e, "onBlur", r), d = v(e, "onDestroy", r);
8031      s && this.editor.on("beforeCreate", s), i && this.editor.on("create", i), o && this.editor.on("update", o), l && this.editor.on("selectionUpdate", l), a && this.editor.on("transaction", a), c && this.editor.on("focus", c), u && this.editor.on("blur", u), d && this.editor.on("destroy", d);
8032    });
8033  }
8034};
8035Kr.resolve = lc;
8036Kr.sort = sn;
8037Kr.flatten = wi;
8038var Cm = {};
8039ki(Cm, { ClipboardTextSerializer: () => yc, Commands: () => bc, Delete: () => kc, Drop: () => xc, Editable: () => Sc, FocusEvents: () => Cc, Keymap: () => Mc, Paste: () => vc, Tabindex: () => Tc, TextDirection: () => Ec, focusEventsPluginKey: () => wc });
8040var U = class gc extends vi {
8041  constructor() {
8042    super(...arguments), this.type = "extension";
8043  }
8044  static create(e = {}) {
8045    const t = typeof e == "function" ? e() : e;
8046    return new gc(t);
8047  }
8048  configure(e) {
8049    return super.configure(e);
8050  }
8051  extend(e) {
8052    const t = typeof e == "function" ? e() : e;
8053    return super.extend(t);
8054  }
8055}, yc = U.create({ name: "clipboardTextSerializer", addOptions() {
8056  return { blockSeparator: void 0 };
8057}, addProseMirrorPlugins() {
8058  return [new F({ key: new K("clipboardTextSerializer"), props: { clipboardTextSerializer: () => {
8059    const { editor: n2 } = this, { state: e, schema: t } = n2, { doc: r, selection: s } = e, { ranges: i } = s, o = Math.min(...i.map((u) => u.$from.pos)), l = Math.max(...i.map((u) => u.$to.pos)), a = cc(t);
8060    return ac(r, { from: o, to: l }, { ...this.options.blockSeparator !== void 0 ? { blockSeparator: this.options.blockSeparator } : {}
8060, textSerializers: a });
8061  } } })];
8062} }), bc = U.create({ name: "commands", addCommands() {
8063  return { ...Qa };
8064} }), kc = U.create({ name: "delete", onUpdate({ transaction: n2, appendedTransactions: e }) {
8065  var t, r, s;
8066  const i = () => {
8067    var o, l, a, c;
8068    if ((c = (a = (l = (o = this.editor.options.coreExtensionOptions) == null ? void 0 : o.delete) == null ? void 0 : l.filterTransaction) == null ? void 0 : a.call(l, n2)) != null ? c : n2.getMeta("y-sync$")) return;
8069    const u = sc(n2.before, [n2, ...e]);
8070    dc(u).forEach((h) => {
8071      u.mapping.mapResult(h.oldRange.from).deletedAfter && u.mapping.mapResult(h.oldRange.to).deletedBefore && u.before.nodesBetween(h.oldRange.from, h.oldRange.to, (p, m) => {
8072        const g = m + p.nodeSize - 2, y = h.oldRange.from <= m && g <= h.oldRange.to;
8073        this.editor.emit("delete", { type: "node", node: p, from: m, to: g, newFrom: u.mapping.map(m), newTo: u.mapping.map(g), deletedRange: h.oldRange, newRange: h.newRange, partial: !y, editor: this.editor, transaction: n2, combinedTransform: u });
8074      });
8075    });
8076    const f = u.mapping;
8077    u.steps.forEach((h, p) => {
8078      var m, g;
8079      if (h instanceof we) {
8080        const y = f.slice(p).map(h.from, -1), x = f.slice(p).map(h.to), M = f.invert().map(y, -1), E = f.invert().map(x), C = (m = u.doc.nodeAt(y - 1)) == null ? void 0 : m.marks.some((S) => S.eq(h.mark)), N = (g = u.doc.nodeAt(x)) == null ? void 0 : g.marks.some((S) => S.eq(h.mark));
8081        this.editor.emit("delete", { type: "mark", mark: h.mark, from: h.from, to: h.to, deletedRange: { from: M, to: E }, newRange: { from: y, to: x }, partial: !!(N || C), editor: this.editor, transaction: n2, combinedTransform: u });
8082      }
8083    });
8084  };
8085  (s = (r = (t = this.editor.options.coreExtensionOptions) == null ? void 0 : t.delete) == null ? void 0 : r.async) == null || s ? setTimeout(i, 0) : i();
8086} }), xc = U.create({ name: "drop", addProseMirrorPlugins() {
8087  return [new F({ key: new K("tiptapDrop"), props: { handleDrop: (n2, e, t, r) => {
8088    this.editor.emit("drop", { editor: this.editor, event: e, slice: t, moved: r });
8089  } } })];
8090} }), Sc = U.create({ name: "editable", addProseMirrorPlugins() {
8091  return [new F({ key: new K("editable"), props: { editable: () => this.editor.options.editable } })];
8092} }), wc = new K("focusEvents"), Cc = U.create({ name: "focusEvents", addProseMirrorPlugins() {
8093  const { editor: n2 } = this;
8094  return [new F({ key: wc, props: { handleDOMEvents: { focus: (e, t) => {
8095    n2.isFocused = true;
8096    const r = n2.state.tr.setMeta("focus", { event: t }).setMeta("addToHistory", false);
8097    return e.dispatch(r), false;
8098  }, blur: (e, t) => {
8099    n2.isFocused = false;
8100    const r = n2.state.tr.setMeta("blur", { event: t }).setMeta("addToHistory", false);
8101    return e.dispatch(r), false;
8102  } } } })];
8103} }), Mc = U.create({ name: "keymap", addKeyboardShortcuts() {
8104  const n2 = () => this.editor.commands.first(({ commands: o }) => [() => o.undoInputRule(), () => o.command(({ tr: l }) => {
8105    const { selection: a, doc: c } = l, { empty: u, $anchor: d } = a, { pos: f, parent: h } = d, p = d.parent.isTextblock && f > 0 ? l.doc.resolve(f - 1) : d, m = p.parent.type.spec.isolating, g = d.pos - d.parentOffset, y = m && p.parent.childCount === 1 ? g === d.pos : R.atStart(c).from === f;
8106    return !u || !h.type.isTextblock || h.textContent.length || !y || y && d.parent.type.name === "paragraph" ? false : o.clearNodes();
8107  }), () => o.deleteSelection(), () => o.joinBackward(), () => o.selectNodeBackward()]), e = () => this.editor.commands.first(({ commands: o }) => [() => o.deleteSelection(), () => o.deleteCurrentNode(), () => o.joinForward(), () => o.selectNodeForward()]), r = { Enter: () => this.editor.commands.first(({ commands: o }) => [() => o.newlineInCode(), () => o.createParagraphNear(), () => o.liftEmptyBlock(), () => o.splitBlock()]), "Mod-Enter": () => this.editor.commands.exitCode(), Backspace: n2, "Mod-Backspace": n2, "Shift-Backspace": n2, Delete: e, "Mod-Delete": e, "Mod-a": () => this.editor.commands.selectAll() }, s = { ...r }
8107, i = { ...r, "Ctrl-h": n2, "Alt-Backspace": n2, "Ctrl-d": e, "Ctrl-Alt-Backspace": e, "Alt-Delete": e, "Alt-d": e, "Ctrl-a": () => this.editor.commands.selectTextblockStart(), "Ctrl-e": () => this.editor.commands.selectTextblockEnd() };
8108  return rr() || nc() ? i : s;
8109}, addProseMirrorPlugins() {
8110  return [new F({ key: new K("clearDocument"), appendTransaction: (n2, e, t) => {
8111    if (n2.some((m) => m.getMeta("composition"))) return;
8112    const r = n2.some((m) => m.docChanged) && !e.doc.eq(t.doc), s = n2.some((m) => m.getMeta("preventClearDocument"));
8113    if (!r || s) return;
8114    const { empty: i, from: o, to: l } = e.selection, a = R.atStart(e.doc).from, c = R.atEnd(e.doc).to;
8115    if (i || !(o === a && l === c) || !Wr(t.doc)) return;
8116    const f = t.tr, h = Vr({ state: t, transaction: f }), { commands: p } = new Hr({ editor: this.editor, state: h });
8117    if (p.clearNodes(), !!f.steps.length) return f;
8118  } })];
8119} }), vc = U.create({ name: "paste", addProseMirrorPlugins() {
8120  return [new F({ key: new K("tiptapPaste"), props: { handlePaste: (n2, e, t) => {
8121    this.editor.emit("paste", { editor: this.editor, event: e, slice: t });
8122  } } })];
8123} }), Tc = U.create({ name: "tabindex", addProseMirrorPlugins() {
8124  return [new F({ key: new K("tabindex"), props: { attributes: () => this.editor.isEditable ? { tabindex: "0" } : {} } })];
8125} }), Ec = U.create({ name: "textDirection", addOptions() {
8126  return { direction: void 0 };
8127}, addGlobalAttributes() {
8128  if (!this.options.direction) return [];
8129  const { nodeExtensions: n2 } = Vt(this.extensions);
8130  return [{ types: n2.filter((e) => e.name !== "text").map((e) => e.name), attributes: { dir: { default: this.options.direction, parseHTML: (e) => {
8131    const t = e.getAttribute("dir");
8132    return t && (t === "ltr" || t === "rtl" || t === "auto") ? t : this.options.direction;
8133  }, renderHTML: (e) => e.dir ? { dir: e.dir } : {} } } }];
8134}, addProseMirrorPlugins() {
8135  return [new F({ key: new K("textDirection"), props: { attributes: () => {
8136    const n2 = this.options.direction;
8137    return n2 ? { dir: n2 } : {};
8138  } } })];
8139} }), Mm = class Xt {
8140  constructor(e, t, r = false, s = null) {
8141    this.currentNode = null, this.actualDepth = null, this.isBlock = r, this.resolvedPos = e, this.editor = t, this.currentNode = s;
8142  }
8143  get name() {
8144    return this.node.type.name;
8145  }
8146  get node() {
8147    return this.currentNode || this.resolvedPos.node();
8148  }
8149  get element() {
8150    return this.editor.view.domAtPos(this.pos).node;
8151  }
8152  get depth() {
8153    var e;
8154    return (e = this.actualDepth) != null ? e : this.resolvedPos.depth;
8155  }
8156  get pos() {
8157    return this.resolvedPos.pos;
8158  }
8159  get content() {
8160    return this.node.content;
8161  }
8162  set content(e) {
8163    let t = this.from, r = this.to;
8164    if (this.isBlock) {
8165      if (this.content.size === 0) {
8166        console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);
8167        return;
8168      }
8169      t = this.from + 1, r = this.to - 1;
8170    }
8171    this.editor.commands.insertContentAt({ from: t, to: r }, e);
8172  }
8173  get attributes() {
8174    return this.node.attrs;
8175  }
8176  get textContent() {
8177    return this.node.textContent;
8178  }
8179  get size() {
8180    return this.node.nodeSize;
8181  }
8182  get from() {
8183    return this.isBlock ? this.pos : this.resolvedPos.start(this.resolvedPos.depth);
8184  }
8185  get range() {
8186    return { from: this.from, to: this.to };
8187  }
8188  get to() {
8189    return this.isBlock ? this.pos + this.size : this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1);
8190  }
8191  get parent() {
8192    if (this.depth === 0) return null;
8193    const e = this.resolvedPos.start(this.resolvedPos.depth - 1), t = this.resolvedPos.doc.resolve(e);
8194    return new Xt(t, this.editor);
8195  }
8196  get before() {
8197    let e = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));
8198    return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.from - 3)), new Xt(e, this.editor);
8199  }
8200  get after() {
8201    let e = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));
8202    return e.depth !== this.depth && (e = this.resolvedPos.doc.resolve(this.to + 3)), new Xt(e, this.editor);
8203  }
8204  get children() {
8205    const e = [];
8206    return this.node.content.forEach((t, r) => {
8207      const s = t.isBlock && !t.isTextblock, i = t.isAtom && !t.isText, o = t.isInline, l = this.pos + r + (i ? 0 : 1);
8208      if (l < 0 || l > this.resolvedPos.doc.nodeSize - 2) return;
8209      const a = this.resolvedPos.doc.resolve(l);
8210      if (!s && !o && a.depth <= this.depth) return;
8211      const c = new Xt(a, this.editor, s, s || o ? t : null);
8212      s && (c.actualDepth = this.depth + 1), e.push(c);
8213    }), e;
8214  }
8215  get firstChild() {
8216    return this.children[0] || null;
8217  }
8218  get lastChild() {
8219    const e = this.children;
8220    return e[e.length - 1] || null;
8221  }
8222  closest(e, t = {}) {
8223    let r = null, s = this.parent;
8224    for (; s && !r; ) {
8225      if (s.node.type.name === e) if (Object.keys(t).length > 0) {
8226        const i = s.node.attrs, o = Object.keys(t);
8227        for (let l = 0; l < o.length; l += 1) {
8228          const a = o[l];
8229          if (i[a] !== t[a]) break;
8230        }
8231      } else r = s;
8232      s = s.parent;
8233    }
8234    return r;
8235  }
8236  querySelector(e, t = {}) {
8237    return this.querySelectorAll(e, t, true)[0] || null;
8238  }
8239  querySelectorAll(e, t = {}, r = false) {
8240    let s = [];
8241    if (!this.children || this.children.length === 0) return s;
8242    const i = Object.keys(t);
8243    return this.children.forEach((o) => {
8244      r && s.length > 0 || (o.node.type.name === e && i.every((a) => t[a] === o.node.attrs[a]) && s.push(o), !(r && s.length > 0) && (s = s.concat(o.querySelectorAll(e, t, r))));
8245    }), s;
8246  }
8247  setAttribute(e) {
8248    const { tr: t } = this.editor.state;
8249    t.setNodeMarkup(this.from, void 0, { ...this.node.attrs, ...e }), this.editor.view.dispatch(t);
8250  }
8251}, vm = `.ProseMirror {
8252  position: relative;
8253}
8254
8255.ProseMirror {
8256  word-wrap: break-word;
8257  white-space: pre-wrap;
8258  white-space: break-spaces;
8259  -webkit-font-variant-ligatures: none;
8260  font-variant-ligatures: none;
8261  font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
8262}
8263
8264.ProseMirror [contenteditable="false"] {
8265  white-space: normal;
8266}
8267
8268.ProseMirror [contenteditable="false"] [contenteditable="true"] {
8269  white-space: pre-wrap;
8270}
8271
8272.ProseMirror pre {
8273  white-space: pre-wrap;
8274}
8275
8276img.ProseMirror-separator {
8277  display: inline !important;
8278  border: none !important;
8279  margin: 0 !important;
8280  width: 0 !important;
8281  height: 0 !important;
8282}
8283
8284.ProseMirror-gapcursor {
8285  display: none;
8286  pointer-events: none;
8287  position: absolute;
8288  margin: 0;
8289}
8290
8291.ProseMirror-gapcursor:after {
8292  content: "";
8293  display: block;
8294  position: absolute;
8295  top: -2px;
8296  width: 20px;
8297  border-top: 1px solid black;
8298  animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
8299}
8300
8301@keyframes ProseMirror-cursor-blink {
8302  to {
8303    visibility: hidden;
8304  }
8305}
8306
8307.ProseMirror-hideselection *::selection {
8308  background: transparent;
8309}
8310
8311.ProseMirror-hideselection *::-moz-selection {
8312  background: transparent;
8313}
8314
8315.ProseMirror-hideselection * {
8316  caret-color: transparent;
8317}
8318
8319.ProseMirror-focused .ProseMirror-gapcursor {
8320  display: block;
8321}`;
8322function Tm(n2, e, t) {
8323  const r = document.querySelector("style[data-tiptap-style]");
8324  if (r !== null) return r;
8325  const s = document.createElement("style");
8326  return e && s.setAttribute("nonce", e), s.setAttribute("data-tiptap-style", ""), s.innerHTML = n2, document.getElementsByTagName("head")[0].appendChild(s), s;
8327}
8328var Em = class extends hm {
8329  constructor(e = {}) {
8330    super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = false, this.isInitialized = false, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.options = { element: typeof document < "u" ? document.createElement("div") : null, content: "", injectCSS: true, injectNonce: void 0, extensions: [], autofocus: false, editable: true, textDirection: void 0, editorProps: {}, parseOptions: {}, coreExtensionOptions: {}, enableInputRules: true, enablePasteRules: true, enableCoreExtensions: true, enableContentCheck: false, emitContentError: false, onBeforeCreate: () => null, onCreate: () => null, onMount: () => null, onUnmount: () => null, onUpdate: () => null, onSelectionUpdate: () => null, onTransaction: () => null, onFocus: () => null, onBlur: () => null, onDestroy: () => null, onContentError: ({ error: s }) => {
8331      throw s;
8332    }, onPaste: () => null, onDrop: () => null, onDelete: () => null, enableExtensionDispatchTransaction: true }, this.isCapturingTransaction = false, this.capturedTransaction = null, this.utils = { getUpdatedPosition: Wp, createMappablePosition: Up }, this.setOptions(e), this.createExtensionManager(), this.createCommandManager(), this.createSchema(), this.on("beforeCreate", this.options.onBeforeCreate), this.emit("beforeCreate", { editor: this }), this.on("mount", this.options.onMount), this.on("unmount", this.options.onUnmount), this.on("contentError", this.options.onContentError), 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: s, slice: i, moved: o }) => this.options.onDrop(s, i, o)), this.on("paste", ({ event: s, slice: i }) => this.options.onPaste(s, i)), this.on("delete", this.options.onDelete);
8333    const t = this.createDoc(), r = ec(t, this.options.autofocus);
8334    this.editorState = Rt.create({ doc: t, schema: this.schema, selection: r || void 0 }), this.options.element && this.mount(this.options.element);
8335  }
8336  mount(e) {
8337    if (typeof document > "u") throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");
8338    this.createView(e), this.emit("mount", { editor: this }), this.css && !document.head.contains(this.css) && document.head.appendChild(this.css), window.setTimeout(() => {
8339      this.isDestroyed || (this.options.autofocus !== false && this.options.autofocus !== null && this.commands.focus(this.options.autofocus), this.emit("create", { editor: this }), this.isInitialized = true);
8340    }, 0);
8341  }
8342  unmount() {
8343    if (this.editorView) {
8344      const e = this.editorView.dom;
8345      (e == null ? void 0 : e.editor) && delete e.editor, this.editorView.destroy();
8346    }
8347    if (this.editorView = null, this.isInitialized = false, this.css && !document.querySelectorAll(`.${this.className}`).length) try {
8348      typeof this.css.remove == "function" ? this.css.remove() : this.css.parentNode && this.css.parentNode.removeChild(this.css);
8349    } catch (e) {
8350      console.warn("Failed to remove CSS element:", e);
8351    }
8352    this.css = null, this.emit("unmount", { editor: this });
8353  }
8354  get storage() {
8355    return this.extensionStorage;
8356  }
8357  get commands() {
8358    return this.commandManager.commands;
8359  }
8360  chain() {
8361    return this.commandManager.chain();
8362  }
8363  can() {
8364    return this.commandManager.can();
8365  }
8366  injectCSS() {
8367    this.options.injectCSS && typeof document < "u" && (this.css = Tm(vm, this.options.injectNonce));
8368  }
8369  setOptions(e = {}) {
8370    this.options = { ...this.options, ...e }, !(!this.editorView || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state));
8371  }
8372  setEditable(e, t = true) {
8373    this.setOptions({ editable: e }), t && this.emit("update", { editor: this, transaction: this.state.tr, appendedTransactions: [] });
8374  }
8375  get isEditable() {
8376    return this.options.editable && this.view && this.view.editable;
8377  }
8378  get view() {
8379    return this.editorView ? this.editorView : new Proxy({ state: this.editorState, updateState: (e) => {
8380      this.editorState = e;
8381    }, dispatch: (e) => {
8382      this.dispatchTransaction(e);
8383    }, composing: false, dragging: null, editable: true, isDestroyed: false }, { get: (e, t) => {
8384      if (this.editorView) return this.editorView[t];
8385      if (t === "state") return this.editorState;
8386      if (t in e) return Reflect.get(e, t);
8387      throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`);
8388    } });
8389  }
8390  get state() {
8391    return this.editorView && (this.editorState = this.view.state), this.editorState;
8392  }
8393  registerPlugin(e, t) {
8394    const r = ic(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], s = this.state.reconfigure({ plugins: r });
8395    return this.view.updateState(s), s;
8396  }
8397  unregisterPlugin(e) {
8398    if (this.isDestroyed) return;
8399    const t = this.state.plugins;
8400    let r = t;
8401    if ([].concat(e).forEach((i) => {
8402      const o = typeof i == "string" ? `${i}$` : i.key;
8403      r = r.filter((l) => !l.key.startsWith(o));
8404    }), t.length === r.length) return;
8405    const s = this.state.reconfigure({ plugins: r });
8406    return this.view.updateState(s), s;
8407  }
8408  createExtensionManager() {
8409    var e, t;
8410    const s = [...this.options.enableCoreExtensions ? [Sc, yc.configure({ blockSeparator: (t = (e = this.options.coreExtensionOptions) == null ? void 0 : e.clipboardTextSerializer) == null ? void 0 : t.blockSeparator }), bc, Cc, Mc, Tc, xc, vc, kc, Ec.configure({ direction: this.options.textDirection })].filter((i) => typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[i.name] !== false : true) : [], ...this.options.extensions].filter((i) => ["extension", "node", "mark"].includes(i == null ? void 0 : i.type));
8411    this.extensionManager = new Kr(s, this);
8412  }
8413  createCommandManager() {
8414    this.commandManager = new Hr({ editor: this });
8415  }
8416  createSchema() {
8417    this.schema = this.extensionManager.schema;
8418  }
8419  createDoc() {
8420    let e;
8421    try {
8422      e = Vs(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
8423    } catch (t) {
8424      if (!(t instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(t.message)) throw t;
8425      this.emit("contentError", { editor: this, error: t, disableCollaboration: () => {
8426        "collaboration" in this.storage && typeof this.storage.collaboration == "object" && this.storage.collaboration && (this.storage.collaboration.isDisabled = true), this.options.extensions = this.options.extensions.filter((r) => r.name !== "collaboration"), this.createExtensionManager();
8427      } }), e = Vs(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: false });
8428    }
8429    return e;
8430  }
8431  createView(e) {
8432    const { editorProps: t, enableExtensionDispatchTransaction: r } = this.options, s = t.dispatchTransaction || this.dispatchTransaction.bind(this), i = r ? this.extensionManager.dispatchTransaction(s) : s, o = t.transformPastedHTML, l = this.extensionManager.transformPastedHTML(o);
8433    this.editorView = new Ga(e, { ...t, attributes: { role: "textbox", ...t == null ? void 0 : t.attributes }, dispatchTransaction: i, transformPastedHTML: l, state: this.editorState, markViews: this.extensionManager.markViews, nodeViews: this.extensionManager.nodeViews });
8434    const a = this.state.reconfigure({ plugins: this.extensionManager.plugins });
8435    this.view.updateState(a), this.prependClass(), this.injectCSS();
8436    const c = this.view.dom;
8437    c.editor = this;
8438  }
8439  createNodeViews() {
8440    this.view.isDestroyed || this.view.setProps({ markViews: this.extensionManager.markViews, nodeViews: this.extensionManager.nodeViews });
8441  }
8442  prependClass() {
8443    this.view.dom.className = `${this.className} ${this.view.dom.className}`;
8444  }
8445  captureTransaction(e) {
8446    this.isCapturingTransaction = true, e(), this.isCapturingTransaction = false;
8447    const t = this.capturedTransaction;
8448    return this.capturedTransaction = null, t;
8449  }
8450  dispatchTransaction(e) {
8451    if (this.view.isDestroyed) return;
8452    if (this.isCapturingTransaction) {
8453      if (!this.capturedTransaction) {
8454        this.capturedTransaction = e;
8455        return;
8456      }
8457      e.steps.forEach((u) => {
8458        var d;
8459        return (d = this.capturedTransaction) == null ? void 0 : d.step(u);
8460      });
8461      return;
8462    }
8463    const { state: t, transactions: r } = this.state.applyTransaction(e), s = !this.state.selection.eq(t.selection), i = r.includes(e), o = this.state;
8464    if (this.emit("beforeTransaction", { editor: this, transaction: e, nextState: t }), !i) return;
8465    this.view.updateState(t), this.emit("transaction", { editor: this, transaction: e, appendedTransactions: r.slice(1) }), s && this.emit("selectionUpdate", { editor: this, transaction: e });
8466    const l = r.findLast((u) => u.getMeta("focus") || u.getMeta("blur")), a = l == null ? void 0 : l.getMeta("focus"), c = l == null ? void 0 : l.getMeta("blur");
8467    a && this.emit("focus", { editor: this, event: a.event, transaction: l }), c && this.emit("blur", { editor: this, event: c.event, transaction: l }), !(e.getMeta("preventUpdate") || !r.some((u) => u.docChanged) || o.doc.eq(t.doc)) && this.emit("update", { editor: this, transaction: e, appendedTransactions: r.slice(1) });
8468  }
8469  getAttributes(e) {
8470    return uc(this.state, e);
8471  }
8472  isActive(e, t) {
8473    const r = typeof e == "string" ? e : null, s = typeof e == "string" ? t : e;
8474    return Vp(this.state, r, s);
8475  }
8476  getJSON() {
8477    return this.state.doc.toJSON();
8478  }
8479  getHTML() {
8480    return Ci(this.state.doc.content, this.schema);
8481  }
8482  getText(e) {
8483    const { blockSeparator: t = `
8484
8485`, textSerializers: r = {} } = e || {};
8486    return Pp(this.state.doc, { blockSeparator: t, textSerializers: { ...cc(this.schema), ...r } });
8487  }
8488  get isEmpty() {
8489    return Wr(this.state.doc);
8490  }
8491  destroy() {
8492    this.emit("destroy"), this.unmount(), this.removeAllListeners();
8493  }
8494  get isDestroyed() {
8495    var e, t;
8496    return (t = (e = this.editorView) == null ? void 0 : e.isDestroyed) != null ? t : true;
8497  }
8498  $node(e, t) {
8499    var r;
8500    return ((r = this.$doc) == null ? void 0 : r.querySelector(e, t)) || null;
8501  }
8502  $nodes(e, t) {
8503    var r;
8504    return ((r = this.$doc) == null ? void 0 : r.querySelectorAll(e, t)) || null;
8505  }
8506  $pos(e) {
8507    const t = this.state.doc.resolve(e);
8508    return new Mm(t, this);
8509  }
8510  get $doc() {
8511    return this.$pos(0);
8512  }
8513};
8514function Sn(n2) {
8515  return new Ur({ find: n2.find, handler: ({ state: e, range: t, match: r }) => {
8516    const s = P(n2.getAttributes, void 0, r);
8517    if (s === false || s === null) return null;
8518    const { tr: i } = e, o = r[r.length - 1], l = r[0];
8519    if (o) {
8520      const a = l.search(/\S/), c = t.from + l.indexOf(o), u = c + o.length;
8521      if (Mi(t.from, t.to, e.doc).filter((h) => h.mark.type.excluded.find((m) => m === n2.type && m !== h.mark.type)).filter((h) => h.to > c).length) return null;
8522      u < t.to && i.delete(u, t.to), c > t.from && i.delete(t.from + a, c);
8523      const f = t.from + a + o.length;
8524      i.addMark(t.from + a, f, n2.type.create(s || {})), i.removeStoredMark(n2.type);
8525    }
8526  }, undoable: n2.undoable });
8527}
8528function Uy(n2) {
8529  return new Ur({ find: n2.find, handler: ({ state: e, range: t, match: r }) => {
8530    const s = P(n2.getAttributes, void 0, r) || {}, { tr: i } = e, o = t.from;
8531    let l = t.to;
8532    const a = n2.type.create(s);
8533    if (r[1]) {
8534      const c = r[0].lastIndexOf(r[1]);
8535      let u = o + c;
8536      u > l ? u = l : l = u + r[1].length;
8537      const d = r[0][r[0].length - 1];
8538      i.insertText(d, o + r[0].length - 1), i.replaceWith(u, l, a);
8539    } else if (r[0]) {
8540      const c = n2.type.isInline ? o : o - 1;
8541      i.insert(c, n2.type.create(s)).delete(i.mapping.map(o), i.mapping.map(l));
8542    }
8543    i.scrollIntoView();
8544  }, undoable: n2.undoable });
8545}
8546function _s(n2) {
8547  return new Ur({ find: n2.find, handler: ({ state: e, range: t, match: r }) => {
8548    const s = e.doc.resolve(t.from), i = P(n2.getAttributes, void 0, r) || {};
8549    if (!s.node(-1).canReplaceWith(s.index(-1), s.indexAfter(-1), n2.type)) return null;
8550    e.tr.delete(t.from, t.to).setBlockType(t.from, t.from, n2.type, i);
8551  }, undoable: n2.undoable });
8552}
8553function Ht(n2) {
8554  return new Ur({ find: n2.find, handler: ({ state: e, range: t, match: r, chain: s }) => {
8555    const i = P(n2.getAttributes, void 0, r) || {}, o = e.tr.delete(t.from, t.to), a = o.doc.resolve(t.from).blockRange(), c = a && ri(a, n2.type, i);
8556    if (!c) return null;
8557    if (o.wrap(a, c), n2.keepMarks && n2.editor) {
8558      const { selection: d, storedMarks: f } = e, { splittableMarks: h } = n2.editor.extensionManager, p = f || d.$to.parentOffset && d.$from.marks();
8559      if (p) {
8560        const m = p.filter((g) => h.includes(g.type.name));
8561        o.ensureMarks(m);
8562      }
8563    }
8564    if (n2.keepAttributes) {
8565      const d = n2.type.name === "bulletList" || n2.type.name === "orderedList" ? "listItem" : "taskList";
8566      s().updateAttributes(d, i).run();
8567    }
8568    const u = o.doc.resolve(t.from - 1).nodeBefore;
8569    u && u.type === n2.type && st(o.doc, t.from - 1) && (!n2.joinPredicate || n2.joinPredicate(r, u)) && o.join(t.from - 1);
8570  }, undoable: n2.undoable });
8571}
8572function Ky(n2, e) {
8573  const { selection: t } = n2, { $from: r } = t;
8574  if (t instanceof T) {
8575    const i = r.index();
8576    return r.parent.canReplaceWith(i, i + 1, e);
8577  }
8578  let s = r.depth;
8579  for (; s >= 0; ) {
8580    const i = r.index(s);
8581    if (r.node(s).contentMatchAt(i).matchType(e)) return true;
8582    s -= 1;
8583  }
8584  return false;
8585}
8586function qy(n2) {
8587  return n2.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
8588}
8589var Am = {};
8590ki(Am, { createAtomBlockMarkdownSpec: () => Nm, createBlockMarkdownSpec: () => Om, createInlineMarkdownSpec: () => Rm, parseAttributes: () => Ti, parseIndentedBlocks: () => js, renderNestedMarkdownContent: () => Ai, serializeAttributes: () => Ei });
8591function Ti(n2) {
8592  if (!(n2 == null ? void 0 : n2.trim())) return {};
8593  const e = {}, t = [], r = n2.replace(/["']([^"']*)["']/g, (c) => (t.push(c), `__QUOTED_${t.length - 1}__`)), s = r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);
8594  if (s) {
8595    const c = s.map((u) => u.trim().slice(1));
8596    e.class = c.join(" ");
8597  }
8598  const i = r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);
8599  i && (e.id = i[1]);
8600  const o = /([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;
8601  Array.from(r.matchAll(o)).forEach(([, c, u]) => {
8602    var d;
8603    const f = parseInt(((d = u.match(/__QUOTED_(\d+)__/)) == null ? void 0 : d[1]) || "0", 10), h = t[f];
8604    h && (e[c] = h.slice(1, -1));
8605  });
8606  const a = r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g, "").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g, "").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g, "").trim();
8607  return a && a.split(/\s+/).filter(Boolean).forEach((u) => {
8608    u.match(/^[a-zA-Z][\w-]*$/) && (e[u] = true);
8609  }), e;
8610}
8611function Ei(n2) {
8612  if (!n2 || Object.keys(n2).length === 0) return "";
8613  const e = [];
8614  return n2.class && String(n2.class).split(/\s+/).filter(Boolean).forEach((r) => e.push(`.${r}`)), n2.id && e.push(`#${n2.id}`), Object.entries(n2).forEach(([t, r]) => {
8615    t === "class" || t === "id" || (r === true ? e.push(t) : r !== false && r != null && e.push(`${t}="${String(r)}"`));
8616  }), e.join(" ");
8617}
8618function Nm(n2) {
8619  const { nodeName: e, name: t, parseAttributes: r = Ti, serializeAttributes: s = Ei, defaultAttributes: i = {}, requiredAttributes: o = [], allowedAttributes: l } = n2, a = t || e, c = (u) => {
8620    if (!l) return u;
8621    const d = {};
8622    return l.forEach((f) => {
8623      f in u && (d[f] = u[f]);
8624    }), d;
8625  };
8626  return { parseMarkdown: (u, d) => {
8627    const f = { ...i, ...u.attributes };
8628    return d.createNode(e, f, []);
8629  }, markdownTokenizer: { name: e, level: "block", start(u) {
8630    var d;
8631    const f = new RegExp(`^:::${a}(?:\\s|$)`, "m"), h = (d = u.match(f)) == null ? void 0 : d.index;
8632    return h !== void 0 ? h : -1;
8633  }, tokenize(u, d, f) {
8634    const h = new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`), p = u.match(h);
8635    if (!p) return;
8636    const m = p[1] || "", g = r(m);
8637    if (!o.find((x) => !(x in g))) return { type: e, raw: p[0], attributes: g };
8638  } }, renderMarkdown: (u) => {
8639    const d = c(u.attrs || {}), f = s(d), h = f ? ` {${f}}` : "";
8640    return `:::${a}${h} :::`;
8641  } };
8642}
8643function Om(n2) {
8644  const { nodeName: e, name: t, getContent: r, parseAttributes: s = Ti, serializeAttributes: i = Ei, defaultAttributes: o = {}, content: l = "block", allowedAttributes: a } = n2, c = t || e, u = (d) => {
8645    if (!a) return d;
8646    const f = {};
8647    return a.forEach((h) => {
8648      h in d && (f[h] = d[h]);
8649    }), f;
8650  };
8651  return { parseMarkdown: (d, f) => {
8652    let h;
8653    if (r) {
8654      const m = r(d);
8655      h = typeof m == "string" ? [{ type: "text", text: m }] : m;
8656    } else l === "block" ? h = f.parseChildren(d.tokens || []) : h = f.parseInline(d.tokens || []);
8657    const p = { ...o, ...d.attributes };
8658    return f.createNode(e, p, h);
8659  }, markdownTokenizer: { name: e, level: "block", start(d) {
8660    var f;
8661    const h = new RegExp(`^:::${c}`, "m"), p = (f = d.match(h)) == null ? void 0 : f.index;
8662    return p !== void 0 ? p : -1;
8663  }, tokenize(d, f, h) {
8664    var p;
8665    const m = new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`), g = d.match(m);
8666    if (!g) return;
8667    const [y, x = ""] = g, M = s(x);
8668    let E = 1;
8669    const C = y.length;
8670    let N = "";
8671    const S = /^:::([\w-]*)(\s.*)?/gm, O = d.slice(C);
8672    for (S.lastIndex = 0; ; ) {
8673      const A = S.exec(O);
8674      if (A === null) break;
8675      const L = A.index, ot = A[1];
8676      if (!((p = A[2]) != null && p.endsWith(":::"))) {
8677        if (ot) E += 1;
8678        else if (E -= 1, E === 0) {
8679          const Fe = O.slice(0, L);
8680          N = Fe.trim();
8681          const vt = d.slice(0, C + L + A[0].length);
8682          let fe = [];
8683          if (N) if (l === "block") for (fe = h.blockTokens(Fe), fe.forEach((le) => {
8684            le.text && (!le.tokens || le.tokens.length === 0) && (le.tokens = h.inlineTokens(le.text));
8685          }); fe.length > 0; ) {
8686            const le = fe[fe.length - 1];
8687            if (le.type === "paragraph" && (!le.text || le.text.trim() === "")) fe.pop();
8688            else break;
8689          }
8690          else fe = h.inlineTokens(N);
8691          return { type: e, raw: vt, attributes: M, content: N, tokens: fe };
8692        }
8693      }
8694    }
8695  } }, renderMarkdown: (d, f) => {
8696    const h = u(d.attrs || {}), p = i(h), m = p ? ` {${p}}` : "", g = f.renderChildren(d.content || [], `
8697
8698`);
8699    return `:::${c}${m}
8700
8701${g}
8702
8703:::`;
8704  } };
8705}
8706function Im(n2) {
8707  if (!n2.trim()) return {};
8708  const e = {}, t = /(\w+)=(?:"([^"]*)"|'([^']*)')/g;
8709  let r = t.exec(n2);
8710  for (; r !== null; ) {
8711    const [, s, i, o] = r;
8712    e[s] = i || o, r = t.exec(n2);
8713  }
8714  return e;
8715}
8716function Dm(n2) {
8717  return Object.entries(n2).filter(([, e]) => e != null).map(([e, t]) => `${e}="${t}"`).join(" ");
8718}
8719function Rm(n2) {
8720  const { nodeName: e, name: t, getContent: r, parseAttributes: s = Im, serializeAttributes: i = Dm, defaultAttributes: o = {}, selfClosing: l = false, allowedAttributes: a } = n2, c = t || e, u = (f) => {
8721    if (!a) return f;
8722    const h = {};
8723    return a.forEach((p) => {
8724      const m = typeof p == "string" ? p : p.name, g = typeof p == "string" ? void 0 : p.skipIfDefault;
8725      if (m in f) {
8726        const y = f[m];
8727        if (g !== void 0 && y === g) return;
8728        h[m] = y;
8729      }
8730    }), h;
8731  }, d = c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
8732  return { parseMarkdown: (f, h) => {
8733    const p = { ...o, ...f.attributes };
8734    if (l) return h.createNode(e, p);
8735    const m = r ? r(f) : f.content || "";
8736    return m ? h.createNode(e, p, [h.createTextNode(m)]) : h.createNode(e, p, []);
8737  }, markdownTokenizer: { name: e, level: "inline", start(f) {
8738    const h = l ? new RegExp(`\\[${d}\\s*[^\\]]*\\]`) : new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`), p = f.match(h), m = p == null ? void 0 : p.index;
8739    return m !== void 0 ? m : -1;
8740  }, tokenize(f, h, p) {
8741    const m = l ? new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`) : new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`), g = f.match(m);
8742    if (!g) return;
8743    let y = "", x = "";
8744    if (l) {
8745      const [, E] = g;
8746      x = E;
8747    } else {
8748      const [, E, C] = g;
8749      x = E, y = C || "";
8750    }
8751    const M = s(x.trim());
8752    return { type: e, raw: g[0], content: y.trim(), attributes: M };
8753  } }, renderMarkdown: (f) => {
8754    let h = "";
8755    r ? h = r(f) : f.content && f.content.length > 0 && (h = f.content.filter((y) => y.type === "text").map((y) => y.text).join(""));
8756    const p = u(f.attrs || {}), m = i(p), g = m ? ` ${m}` : "";
8757    return l ? `[${c}${g}]` : `[${c}${g}]${h}[/${c}]`;
8758  } };
8759}
8760function js(n2, e, t) {
8761  var r, s, i, o;
8762  const l = n2.split(`
8763`), a = [];
8764  let c = "", u = 0;
8765  const d = e.baseIndentSize || 2;
8766  for (; u < l.length; ) {
8767    const f = l[u], h = f.match(e.itemPattern);
8768    if (!h) {
8769      if (a.length > 0) break;
8770      if (f.trim() === "") {
8771        u += 1, c = `${c}${f}
8772`;
8773        continue;
8774      } else return;
8775    }
8776    const p = e.extractItemData(h), { indentLevel: m, mainContent: g } = p;
8777    c = `${c}${f}
8778`;
8779    const y = [g];
8780    for (u += 1; u < l.length; ) {
8781      const C = l[u];
8782      if (C.trim() === "") {
8783        const S = l.slice(u + 1).findIndex((L) => L.trim() !== "");
8784        if (S === -1) break;
8785        if ((((s = (r = l[u + 1 + S].match(/^(\s*)/)) == null ? void 0 : r[1]) == null ? void 0 : s.length) || 0) > m) {
8786          y.push(C), c = `${c}${C}
8787`, u += 1;
8788          continue;
8789        } else break;
8790      }
8791      if ((((o = (i = C.match(/^(\s*)/)) == null ? void 0 : i[1]) == null ? void 0 : o.length) || 0) > m) y.push(C), c = `${c}${C}
8792`, u += 1;
8793      else break;
8794    }
8795    let x;
8796    const M = y.slice(1);
8797    if (M.length > 0) {
8798      const C = M.map((N) => N.slice(m + d)).join(`
8799`);
8800      C.trim() && (e.customNestedParser ? x = e.customNestedParser(C) : x 
8800= t.blockTokens(C));
8801    }
8802    const E = e.createToken(p, x);
8803    a.push(E);
8804  }
8805  if (a.length !== 0) return { items: a, raw: c };
8806}
8807function Ai(n2, e, t, r) {
8808  if (!n2 || !Array.isArray(n2.content)) return "";
8809  const s = typeof t == "function" ? t(r) : t, [i, ...o] = n2.content, l = e.renderChildren([i]), a = [`${s}${l}`];
8810  return o && o.length > 0 && o.forEach((c) => {
8811    const u = e.renderChildren([c]);
8812    if (u) {
8813      const d = u.split(`
8814`).map((f) => f ? e.indent(f) : "").join(`
8815`);
8816      a.push(d);
8817    }
8818  }), a.join(`
8819`);
8820}
8821function Pm(n2, e, t = {}) {
8822  const { state: r } = e, { doc: s, tr: i } = r, o = n2;
8823  s.descendants((l, a) => {
8824    const c = i.mapping.map(a), u = i.mapping.map(a) + l.nodeSize;
8825    let d = null;
8826    if (l.marks.forEach((h) => {
8827      if (h !== o) return false;
8828      d = h;
8829    }), !d) return;
8830    let f = false;
8831    if (Object.keys(t).forEach((h) => {
8832      t[h] !== d.attrs[h] && (f = true);
8833    }), f) {
8834      const h = n2.type.create({ ...n2.attrs, ...t });
8835      i.removeMark(c, u, n2.type), i.addMark(c, u, h);
8836    }
8837  }), i.docChanged && e.view.dispatch(i);
8838}
8839var xe = class Ac extends vi {
8840  constructor() {
8841    super(...arguments), this.type = "node";
8842  }
8843  static create(e = {}) {
8844    const t = typeof e == "function" ? e() : e;
8845    return new Ac(t);
8846  }
8847  configure(e) {
8848    return super.configure(e);
8849  }
8850  extend(e) {
8851    const t = typeof e == "function" ? e() : e;
8852    return super.extend(t);
8853  }
8854};
8855function _t(n2) {
8856  return new bm({ find: n2.find, handler: ({ state: e, range: t, match: r, pasteEvent: s }) => {
8857    const i = P(n2.getAttributes, void 0, r, s);
8858    if (i === false || i === null) return null;
8859    const { tr: o } = e, l = r[r.length - 1], a = r[0];
8860    let c = t.to;
8861    if (l) {
8862      const u = a.search(/\S/), d = t.from + a.indexOf(l), f = d + l.length;
8863      if (Mi(t.from, t.to, e.doc).filter((p) => p.mark.type.excluded.find((g) => g === n2.type && g !== p.mark.type)).filter((p) => p.to > d).length) return null;
8864      f < t.to && o.delete(f, t.to), d > t.from && o.delete(t.from + u, d), c = t.from + u + l.length, o.addMark(t.from + u, c, n2.type.create(i || {})), o.removeStoredMark(n2.type);
8865    }
8866  } });
8867}
8868var sr = (n2, e) => {
8869  if (n2 === "slot") return 0;
8870  if (n2 instanceof Function) return n2(e);
8871  const { children: t, ...r } = e ?? {};
8872  if (n2 === "svg") throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");
8873  return [n2, r, t];
8874}, Lm = /^\s*>\s$/, Bm = xe.create({ name: "blockquote", addOptions() {
8875  return { HTMLAttributes: {} };
8876}, content: "block+", group: "block", defining: true, parseHTML() {
8877  return [{ tag: "blockquote" }];
8878}, renderHTML({ HTMLAttributes: n2 }) {
8879  return sr("blockquote", { ...Y(this.options.HTMLAttributes, n2), children: sr("slot", {}) });
8880}, parseMarkdown: (n2, e) => e.createNode("blockquote", void 0, e.parseChildren(n2.tokens || [])), renderMarkdown: (n2, e) => {
8881  if (!n2.content) return "";
8882  const t = ">", r = [];
8883  return n2.content.forEach((s) => {
8884    const l = e.renderChildren([s]).split(`
8885`).map((a) => a.trim() === "" ? t : `${t} ${a}`);
8886    r.push(l.join(`
8887`));
8888  }), r.join(`
8889${t}
8890`);
8891}, addCommands() {
8892  return { setBlockquote: () => ({ commands: n2 }) => n2.wrapIn(this.name), toggleBlockquote: () => ({ commands: n2 }) => n2.toggleWrap(this.name), unsetBlockquote: () => ({ commands: n2 }) => n2.lift(this.name) };
8893}, addKeyboardShortcuts() {
8894  return { "Mod-Shift-b": () => this.editor.commands.toggleBlockquote() };
8895}, addInputRules() {
8896  return [Ht({ find: Lm, type: this.type })];
8897} }), zm = Bm, $m = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, Fm = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, Vm = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, Hm = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, _m = Wt.create({ name: "bold", addOptions() {
8898  return { HTMLAttributes: {} };
8899}, parseHTML() {
8900  return [{ tag: "strong" }, { tag: "b", getAttrs: (n2) => n2.style.fontWeight !== "normal" && null }, { style: "font-weight=400", clearMark: (n2) => n2.type.name === this.name }, { style: "font-weight", getAttrs: (n2) => /^(bold(er)?|[5-9]\d{2,})$/.test(n2) && null }];
8901}, renderHTML({ HTMLAttributes: n2 }) {
8902  return sr("strong", { ...Y(this.options.HTMLAttributes, n2), children: sr("slot", {}) });
8903}, markdownTokenName: "strong", parseMarkdown: (n2, e) => e.applyMark("bold", e.parseInline(n2.tokens || [])), renderMarkdown: (n2, e) => `**${e.renderChildren(n2)}**`, addCommands() {
8904  return { setBold: () => ({ commands: n2 }) => n2.setMark(this.name), toggleBold: () => ({ commands: n2 }) => n2.toggleMark(this.name), unsetBold: () => ({ commands: n2 }) => n2.unsetMark(this.name) };
8905}, addKeyboardShortcuts() {
8906  return { "Mod-b": () => this.editor.commands.toggleBold(), "Mod-B": () => this.editor.commands.toggleBold() };
8907}, addInputRules() {
8908  return [Sn({ find: $m, type: this.type }), Sn({ find: Vm, type: this.type })];
8909}, addPasteRules() {
8910  return [_t({ find: Fm, type: this.type }), _t({ find: Hm, type: this.type })];
8911} }), jm = _m, Wm = Object.defineProperty, Um = (n2, e) => {
8912  for (var t in e) Wm(n2, t, { get: e[t], enumerable: true });
8913}, Km = "listItem", nl = "textStyle", rl = /^\s*([-+*])\s$/, Nc = xe.create({ name: "bulletList", addOptions() {
8914  return { itemTypeName: "listItem", HTMLAttributes: {}, keepMarks: false, keepAttributes: false };
8915}, group: "block list", content() {
8916  return `${this.options.itemTypeName}+`;
8917}, parseHTML() {
8918  return [{ tag: "ul" }];
8919}, renderHTML({ HTMLAttributes: n2 }) {
8920  return ["ul", Y(this.options.HTMLAttributes, n2), 0];
8921}, markdownTokenName: "list", parseMarkdown: (n2, e) => n2.type !== "list" || n2.ordered ? [] : { type: "bulletList", content: n2.items ? e.parseChildren(n2.items) : [] }, renderMarkdown: (n2, e) => n2.content ? e.renderChildren(n2.content, `
8922`) : "", markdownOptions: { indentsContent: true }, addCommands() {
8923  return { toggleBulletList: () => ({ commands: n2, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Km, this.editor.getAttributes(nl)).run() : n2.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks) };
8924}, addKeyboardShortcuts() {
8925  return { "Mod-Shift-8": () => this.editor.commands.toggleBulletList() };
8926}, addInputRules() {
8927  let n2 = Ht({ find: rl, type: this.type });
8928  return (this.options.keepMarks || this.options.keepAttributes) && (n2 = Ht({ find: rl, type: this.type, keepMarks: this.options.keepMarks, keepAttributes: this.options.keepAttributes, getAttributes: () => this.editor.getAttributes(nl), editor: this.editor })), [n2];
8929} }), Oc = xe.create({ name: "listItem", addOptions() {
8930  return { HTMLAttributes: {}, bulletListTypeName: "bulletList", orderedListTypeName: "orderedList" };
8931}, content: "paragraph block*", defining: true, parseHTML() {
8932  return [{ tag: "li" }];
8933}, renderHTML({ HTMLAttributes: n2 }) {
8934  return ["li", Y(this.options.HTMLAttributes, n2), 0];
8935}, markdownTokenName: "list_item", parseMarkdown: (n2, e) => {
8936  if (n2.type !== "list_item") return [];
8937  let t = [];
8938  if (n2.tokens && n2.tokens.length > 0) if (n2.tokens.some((s) => s.type === "paragraph")) t = e.parseChildren(n2.tokens);
8939  else {
8940    const s = n2.tokens[0];
8941    if (s && s.type === "text" && s.tokens && s.tokens.length > 0) {
8942      if (t = [{ type: "paragraph", content: e.parseInline(s.tokens) }], n2.tokens.length > 1) {
8943        const o = n2.tokens.slice(1), l = e.parseChildren(o);
8944        t.push(...l);
8945      }
8946    } else t = e.parseChildren(n2.tokens);
8947  }
8948  return t.length === 0 && (t = [{ type: "paragraph", content: [] }]), { type: "listItem", content: t };
8949}, renderMarkdown: (n2, e, t) => Ai(n2, e, (r) => {
8950  var s, i;
8951  return r.parentType === "bulletList" ? "- " : r.parentType === "orderedList" ? `${(((i = (s = r.meta) == null ? void 0 : s.parentAttrs) == null ? void 0 : i.start) || 1) + r.index}. ` : "- ";
8952}, t), addKeyboardShortcuts() {
8953  return { Enter: () => this.editor.commands.splitListItem(this.name), Tab: () => this.editor.commands.sinkListItem(this.name), "Shift-Tab": () => this.editor.commands.liftListItem(this.name) };
8954} }), qm = {};
8955Um(qm, { findListItemPos: () => En, getNextListDepth: () => Ni, handleBackspace: () => Ws, handleDelete: () => Us, hasListBefore: () => Ic, hasListItemAfter: () => Jm, hasListItemBefore: () => Dc, listItemHasSubList: () => Rc, nextListIsDeeper: () => Pc, nextListIsHigher: () => Lc });
8956var En = (n2, e) => {
8957  const { $from: t } = e.selection, r = W(n2, e.schema);
8958  let s = null, i = t.depth, o = t.pos, l = null;
8959  for (; i > 0 && l === null; ) s = t.node(i), s.type === r ? l = i : (i -= 1, o -= 1);
8960  return l === null ? null : { $pos: e.doc.resolve(o), depth: l };
8961}, Ni = (n2, e) => {
8962  const t = En(n2, e);
8963  if (!t) return false;
8964  const [, r] = $p(e, n2, t.$pos.pos + 4);
8965  return r;
8966}, Ic = (n2, e, t) => {
8967  const { $anchor: r } = n2.selection, s = Math.max(0, r.pos - 2), i = n2.doc.resolve(s).node();
8968  return !(!i || !t.includes(i.type.name));
8969}, Dc = (n2, e) => {
8970  var t;
8971  const { $anchor: r } = e.selection, s = e.doc.resolve(r.pos - 2);
8972  return !(s.index() === 0 || ((t = s.nodeBefore) == null ? void 0 : t.type.name) !== n2);
8973}, Rc = (n2, e, t) => {
8974  if (!t) return false;
8975  const r = W(n2, e.schema);
8976  let s = false;
8977  return t.descendants((i) => {
8978    i.type === r && (s = true);
8979  }), s;
8980}, Ws = (n2, e, t) => {
8981  if (n2.commands.undoInputRule()) return true;
8982  if (n2.state.selection.from !== n2.state.selection.to) return false;
8983  if (!rt(n2.state, e) && Ic(n2.state, e, t)) {
8984    const { $anchor: l } = n2.state.selection, a = n2.state.doc.resolve(l.before() - 1), c = [];
8985    a.node().descendants((f, h) => {
8986      f.type.name === e && c.push({ node: f, pos: h });
8987    });
8988    const u = c.at(-1);
8989    if (!u) return false;
8990    const d = n2.state.doc.resolve(a.start() + u.pos + 1);
8991    return n2.chain().cut({ from: l.start() - 1, to: l.end() + 1 }, d.end()).joinForward().run();
8992  }
8993  if (!rt(n2.state, e) || !_p(n2.state)) return false;
8994  const r = En(e, n2.state);
8995  if (!r) return false;
8996  const i = n2.state.doc.resolve(r.$pos.pos - 2).node(r.depth), o = Rc(e, n2.state, i);
8997  return Dc(e, n2.state) && !o ? n2.commands.joinItemBackward() : n2.chain().liftListItem(e).run();
8998}, Pc = (n2, e) => {
8999  const t = Ni(n2, e), r = En(n2, e);
9000  return !r || !t ? false : t > r.depth;
9001}, Lc = (n2, e) => {
9002  const t = Ni(n2, e), r = En(n2, e);
9003  return !r || !t ? false : t < r.depth;
9004}, Us = (n2, e) => {
9005  if (!rt(n2.state, e) || !Hp(n2.state, e)) return false;
9006  const { selection: t } = n2.state, { $from: r, $to: s } = t;
9007  return !t.empty && r.sameParent(s) ? false : Pc(e, n2.state) ? n2.chain().focus(n2.state.selection.from + 4).lift(e).joinBackward().run() : Lc(e, n2.state) ? n2.chain().joinForward().joinBackward().run() : n2.commands.joinItemForward();
9008}, Jm = (n2, e) => {
9009  var t;
9010  const { $anchor: r } = e.selection, s = e.doc.resolve(r.pos - r.parentOffset - 2);
9011  return !(s.index() === s.parent.childCount - 1 || ((t = s.nodeAfter) == null ? void 0 : t.type.name) !== n2);
9012}, Gm = U.create({ name: "listKeymap", addOptions() {
9013  return { listTypes: [{ itemName: "listItem", wrapperNames: ["bulletList", "orderedList"] }, { itemName: "taskItem", wrapperNames: ["taskList"] }] };
9014}, addKeyboardShortcuts() {
9015  return { Delete: ({ editor: n2 }) => {
9016    let e = false;
9017    return this.options.listTypes.forEach(({ itemName: t }) => {
9018      n2.state.schema.nodes[t] !== void 0 && Us(n2, t) && (e = true);
9019    }), e;
9020  }, "Mod-Delete": ({ editor: n2 }) => {
9021    let e = false;
9022    return this.options.listTypes.forEach(({ itemName: t }) => {
9023      n2.state.schema.nodes[t] !== void 0 && Us(n2, t) && (e = true);
9024    }), e;
9025  }, Backspace: ({ editor: n2 }) => {
9026    let e = false;
9027    return this.options.listTypes.forEach(({ itemName: t, wrapperNames: r }) => {
9028      n2.state.schema.nodes[t] !== void 0 && Ws(n2, t, r) && (e = true);
9029    }), e;
9030  }, "Mod-Backspace": ({ editor: n2 }) => {
9031    let e = false;
9032    return this.options.listTypes.forEach(({ itemName: t, wrapperNames: r }) => {
9033      n2.state.schema.nodes[t] !== void 0 && Ws(n2, t, r) && (e = true);
9034    }), e;
9035  } };
9036} }), sl = /^(\s*)(\d+)\.\s+(.*)$/, Ym = /^\s/;
9037function Qm(n2) {
9038  const e = [];
9039  let t = 0, r = 0;
9040  for (; t < n2.length; ) {
9041    const s = n2[t], i = s.match(sl);
9042    if (!i) break;
9043    const [, o, l, a] = i, c = o.length;
9044    let u = a, d = t + 1;
9045    const f = [s];
9046    for (; d < n2.length; ) {
9047      const h = n2[d];
9048      if (h.match(sl)) break;
9049      if (h.trim() === "") f.push(h), u += `
9050`, d += 1;
9051      else if (h.match(Ym)) f.push(h), u += `
9052${h.slice(c + 2)}`, d += 1;
9053      else break;
9054    }
9055    e.push({ indent: c, number: parseInt(l, 10), content: u.trim(), raw: f.join(`
9056`) }), r = d, t = d;
9057  }
9058  return [e, r];
9059}
9060function Bc(n2, e, t) {
9061  var r;
9062  const s = [];
9063  let i = 0;
9064  for (; i < n2.length; ) {
9065    const o = n2[i];
9066    if (o.indent === e) {
9067      const l = o.content.split(`
9068`), a = ((r = l[0]) == null ? void 0 : r.trim()) || "", c = [];
9069      a && c.push({ type: "paragraph", raw: a, tokens: t.inlineTokens(a) });
9070      const u = l.slice(1).join(`
9071`).trim();
9072      if (u) {
9073        const h = t.blockTokens(u);
9074        c.push(...h);
9075      }
9076      let d = i + 1;
9077      const f = [];
9078      for (; d < n2.length && n2[d].indent > e; ) f.push(n2[d]), d += 1;
9079      if (f.length > 0) {
9080        const h = Math.min(...f.map((m) => m.indent)), p = Bc(f, h, t);
9081        c.push({ type: "list", ordered: true, start: f[0].number, items: p, raw: f.map((m) => m.raw).join(`
9082`) });
9083      }
9084      s.push({ type: "list_item", raw: o.raw, tokens: c }), i = d;
9085    } else i += 1;
9086  }
9087  return s;
9088}
9089function Xm(n2, e) {
9090  return n2.map((t) => {
9091    if (t.type !== "list_item") return e.parseChildren([t])[0];
9092    const r = [];
9093    return t.tokens && t.tokens.length > 0 && t.tokens.forEach((s) => {
9094      if (s.type === "paragraph" || s.type === "list" || s.type === "blockquote" || s.type === "code") r.push(...e.parseChildren([s]));
9095      else if (s.type === "text" && s.tokens) {
9096        const i = e.parseChildren([s]);
9097        r.push({ type: "paragraph", content: i });
9098      } else {
9099        const i = e.parseChildren([s]);
9100        i.length > 0 && r.push(...i);
9101      }
9102    }), { type: "listItem", content: r };
9103  });
9104}
9105var Zm = "listItem", il = "textStyle", ol = /^(\d+)\.\s$/, zc = xe.create({ name: "orderedList", addOptions() {
9106  return { itemTypeName: "listItem", HTMLAttributes: {}, keepMarks: false, keepAttributes: false };
9107}, group: "block list", content() {
9108  return `${this.options.itemTypeName}+`;
9109}, addAttributes() {
9110  return { start: { default: 1, parseHTML: (n2) => n2.hasAttribute("start") ? parseInt(n2.getAttribute("start") || "", 10) : 1 }, type: { default: null, parseHTML: (n2) => n2.getAttribute("type") } };
9111}, parseHTML() {
9112  return [{ tag: "ol" }];
9113}, renderHTML({ HTMLAttributes: n2 }) {
9114  const { start: e, ...t } = n2;
9115  return e === 1 ? ["ol", Y(this.options.HTMLAttributes, t), 0] : ["ol", Y(this.options.HTMLAttributes, n2), 0];
9116}, markdownTokenName: "list", parseMarkdown: (n2, e) => {
9117  if (n2.type !== "list" || !n2.ordered) return [];
9118  const t = n2.start || 1, r = n2.items ? Xm(n2.items, e) : [];
9119  return t !== 1 ? { type: "orderedList", attrs: { start: t }, content: r } : { type: "orderedList", content: r };
9120}, renderMarkdown: (n2, e) => n2.content ? e.renderChildren(n2.content, `
9121`) : "", markdownTokenizer: { name: "orderedList", level: "block", start: (n2) => {
9122  const e = n2.match(/^(\s*)(\d+)\.\s+/), t = e == null ? void 0 : e.index;
9123  return t !== void 0 ? t : -1;
9124}, tokenize: (n2, e, t) => {
9125  var r;
9126  const s = n2.split(`
9127`), [i, o] = Qm(s);
9128  if (i.length === 0) return;
9129  const l = Bc(i, 0, t);
9130  return l.length === 0 ? void 0 : { type: "list", ordered: true, start: ((r = i[0]) == null ? void 0 : r.number) || 1, items: l, raw: s.slice(0, o).join(`
9131`) };
9132} }, markdownOptions: { indentsContent: true }, addCommands() {
9133  return { toggleOrderedList: () => ({ commands: n2, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Zm, this.editor.getAttributes(il)).run() : n2.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks) };
9134}, addKeyboardShortcuts() {
9135  return { "Mod-Shift-7": () => this.editor.commands.toggleOrderedList() };
9136}, addInputRules() {
9137  let n2 = Ht({ find: ol, type: this.type, getAttributes: (e) => ({ start: +e[1] }), joinPredicate: (e, t) => t.childCount + t.attrs.start === +e[1] });
9138  return (this.options.keepMarks || this.options.keepAttributes) && (n2 = Ht({ find: ol, type: this.type, keepMarks: this.options.keepMarks, keepAttributes: this.options.keepAttributes, getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(il) }), joinPredicate: (e, t) => t.childCount + t.attrs.start === +e[1], editor: this.editor })), [n2];
9139} }), eg = /^\s*(\[([( |x])?\])\s$/, tg = xe.create({ name: "taskItem", addOptions() {
9140  return { nested: false, HTMLAttributes: {}, taskListTypeName: "taskList", a11y: void 0 };
9141}, content() {
9142  return this.options.nested ? "paragraph block*" : "paragraph+";
9143}, defining: true, addAttributes() {
9144  return { checked: { default: false, keepOnSplit: false, parseHTML: (n2) => {
9145    const e = n2.getAttribute("data-checked");
9146    return e === "" || e === "true";
9147  }, renderHTML: (n2) => ({ "data-checked": n2.checked }) } };
9148}, parseHTML() {
9149  return [{ tag: `li[data-type="${this.name}"]`, priority: 51 }];
9150}, renderHTML({ node: n2, HTMLAttributes: e }) {
9151  return ["li", Y(this.options.HTMLAttributes, e, { "data-type": this.name }), ["label", ["input", { type: "checkbox", checked: n2.attrs.checked ? "checked" : null }], ["span"]], ["div", 0]];
9152}, parseMarkdown: (n2, e) => {
9153  const t = [];
9154  if (n2.tokens && n2.tokens.length > 0 ? t.push(e.createNode("paragraph", {}, e.parseInline(n2.tokens))) : n2.text ? t.push(e.createNode("paragraph", {}, [e.createNode("text", { text: n2.text })])) : t.push(e.createNode("paragraph", {}, [])), n2.nestedTokens && n2.nestedTokens.length > 0) {
9155    const r = e.parseChildren(n2.nestedTokens);
9156    t.push(...r);
9157  }
9158  return e.createNode("taskItem", { checked: n2.checked || false }, t);
9159}, renderMarkdown: (n2, e) => {
9160  var t;
9161  const s = `- [${(t = n2.attrs) != null && t.checked ? "x" : " "}] `;
9162  return Ai(n2, e, s);
9163}, addKeyboardShortcuts() {
9164  const n2 = { Enter: () => this.editor.commands.splitListItem(this.name), "Shift-Tab": () => this.editor.commands.liftListItem(this.name) };
9165  return this.options.nested ? { ...n2, Tab: () => this.editor.commands.sinkListItem(this.name) } : n2;
9166}, addNodeView() {
9167  return ({ node: n2, HTMLAttributes: e, getPos: t, editor: r }) => {
9168    const s = document.createElement("li"), i = document.createElement("label"), o = document.createElement("span"), l = document.createElement("input"), a = document.createElement("div"), c = (d) => {
9169      var f, h;
9170      l.ariaLabel = ((h = (f = this.options.a11y) == null ? void 0 : f.checkboxLabel) == null ? void 0 : h.call(f, d, l.checked)) || `Task item checkbox for ${d.textContent || "empty task item"}`;
9171    };
9172    c(n2), i.contentEditable = "false", l.type = "checkbox", l.addEventListener("mousedown", (d) => d.preventDefault()), l.addEventListener("change", (d) => {
9173      if (!r.isEditable && !this.options.onReadOnlyChecked) {
9174        l.checked = !l.checked;
9175        return;
9176      }
9177      const { checked: f } = d.target;
9178      r.isEditable && typeof t == "function" && r.chain().focus(void 0, { scrollIntoView: false }).command(({ tr: h }) => {
9179        const p = t();
9180        if (typeof p != "number") return false;
9181        const m = h.doc.nodeAt(p);
9182        return h.setNodeMarkup(p, void 0, { ...m == null ? void 0 : m.attrs, checked: f }), true;
9183      }).run(), !r.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(n2, f) || (l.checked = !l.checked));
9184    }), Object.entries(this.options.HTMLAttributes).forEach(([d, f]) => {
9185      s.setAttribute(d, f);
9186    }), s.dataset.checked = n2.attrs.checked, l.checked = n2.attrs.checked, i.append(l, o), s.append(i, a), Object.entries(e).forEach(([d, f]) => {
9187      s.setAttribute(d, f);
9188    });
9189    let u = new Set(Object.keys(e));
9190    return { dom: s, contentDOM: a, update: (d) => {
9191      if (d.type !== this.type) return false;
9192      s.dataset.checked = d.attrs.checked, l.checked = d.attrs.checked, c(d);
9193      const f = r.extensionManager.attributes, h = xn(d, f), p = new Set(Object.keys(h)), m = this.options.HTMLAttributes;
9194      return u.forEach((g) => {
9195        p.has(g) || (g in m ? s.setAttribute(g, m[g]) : s.removeAttribute(g));
9196      }
9196), Object.entries(h).forEach(([g, y]) => {
9197        y == null ? g in m ? s.setAttribute(g, m[g]) : s.removeAttribute(g) : s.setAttribute(g, y);
9198      }), u = p, true;
9199    } };
9200  };
9201}, addInputRules() {
9202  return [Ht({ find: eg, type: this.type, getAttributes: (n2) => ({ checked: n2[n2.length - 1] === "x" }) })];
9203} }), ng = xe.create({ name: "taskList", addOptions() {
9204  return { itemTypeName: "taskItem", HTMLAttributes: {} };
9205}, group: "block list", content() {
9206  return `${this.options.itemTypeName}+`;
9207}, parseHTML() {
9208  return [{ tag: `ul[data-type="${this.name}"]`, priority: 51 }];
9209}, renderHTML({ HTMLAttributes: n2 }) {
9210  return ["ul", Y(this.options.HTMLAttributes, n2, { "data-type": this.name }), 0];
9211}, parseMarkdown: (n2, e) => e.createNode("taskList", {}, e.parseChildren(n2.items || [])), renderMarkdown: (n2, e) => n2.content ? e.renderChildren(n2.content, `
9212`) : "", markdownTokenizer: { name: "taskList", level: "block", start(n2) {
9213  var e;
9214  const t = (e = n2.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)) == null ? void 0 : e.index;
9215  return t !== void 0 ? t : -1;
9216}, tokenize(n2, e, t) {
9217  const r = (i) => {
9218    const o = js(i, { itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/, extractItemData: (l) => ({ indentLevel: l[1].length, mainContent: l[4], checked: l[3].toLowerCase() === "x" }), createToken: (l, a) => ({ type: "taskItem", raw: "", mainContent: l.mainContent, indentLevel: l.indentLevel, checked: l.checked, text: l.mainContent, tokens: t.inlineTokens(l.mainContent), nestedTokens: a }), customNestedParser: r }, t);
9219    return o ? [{ type: "taskList", raw: o.raw, items: o.items }] : t.blockTokens(i);
9220  }, s = js(n2, { itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/, extractItemData: (i) => ({ indentLevel: i[1].length, mainContent: i[4], checked: i[3].toLowerCase() === "x" }), createToken: (i, o) => ({ type: "taskItem", raw: "", mainContent: i.mainContent, indentLevel: i.indentLevel, checked: i.checked, text: i.mainContent, tokens: t.inlineTokens(i.mainContent), nestedTokens: o }), customNestedParser: r }, t);
9221  if (s) return { type: "taskList", raw: s.raw, items: s.items };
9222} }, markdownOptions: { indentsContent: true }, addCommands() {
9223  return { toggleTaskList: () => ({ commands: n2 }) => n2.toggleList(this.name, this.options.itemTypeName) };
9224}, addKeyboardShortcuts() {
9225  return { "Mod-Shift-9": () => this.editor.commands.toggleTaskList() };
9226} });
9227U.create({ name: "listKit", addExtensions() {
9228  const n2 = [];
9229  return this.options.bulletList !== false && n2.push(Nc.configure(this.options.bulletList)), this.options.listItem !== false && n2.push(Oc.configure(this.options.listItem)), this.options.listKeymap !== false && n2.push(Gm.configure(this.options.listKeymap)), this.options.orderedList !== false && n2.push(zc.configure(this.options.orderedList)), this.options.taskItem !== false && n2.push(tg.configure(this.options.taskItem)), this.options.taskList !== false && n2.push(ng.configure(this.options.taskList)), n2;
9230} });
9231var rg = Nc, gs = 4, sg = /^```([a-z]+)?[\s\n]$/, ig = /^~~~([a-z]+)?[\s\n]$/, og = xe.create({ name: "codeBlock", addOptions() {
9232  return { languageClassPrefix: "language-", exitOnTripleEnter: true, exitOnArrowDown: true, defaultLanguage: null, enableTabIndentation: false, tabSize: gs, HTMLAttributes: {} };
9233}, content: "text*", marks: "", group: "block", code: true, defining: true, addAttributes() {
9234  return { language: { default: this.options.defaultLanguage, parseHTML: (n2) => {
9235    var e;
9236    const { languageClassPrefix: t } = this.options;
9237    if (!t) return null;
9238    const i = [...((e = n2.firstElementChild) == null ? void 0 : e.classList) || []].filter((o) => o.startsWith(t)).map((o) => o.replace(t, ""))[0];
9239    return i || null;
9240  }, rendered: false } };
9241}, parseHTML() {
9242  return [{ tag: "pre", preserveWhitespace: "full" }];
9243}, renderHTML({ node: n2, HTMLAttributes: e }) {
9244  return ["pre", Y(this.options.HTMLAttributes, e), ["code", { class: n2.attrs.language ? this.options.languageClassPrefix + n2.attrs.language : null }, 0]];
9245}, markdownTokenName: "code", parseMarkdown: (n2, e) => {
9246  var t, r;
9247  return ((t = n2.raw) == null ? void 0 : t.startsWith("```")) === false && ((r = n2.raw) == null ? void 0 : r.startsWith("~~~")) === false && n2.codeBlockStyle !== "indented" ? [] : e.createNode("codeBlock", { language: n2.lang || null }, n2.text ? [e.createTextNode(n2.text)] : []);
9248}, renderMarkdown: (n2, e) => {
9249  var t;
9250  let r = "";
9251  const s = ((t = n2.attrs) == null ? void 0 : t.language) || "";
9252  return n2.content ? r = [`\`\`\`${s}`, e.renderChildren(n2.content), "```"].join(`
9253`) : r = `\`\`\`${s}
9254
9255\`\`\``, r;
9256}, addCommands() {
9257  return { setCodeBlock: (n2) => ({ commands: e }) => e.setNode(this.name, n2), toggleCodeBlock: (n2) => ({ commands: e }) => e.toggleNode(this.name, "paragraph", n2) };
9258}, addKeyboardShortcuts() {
9259  return { "Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(), Backspace: () => {
9260    const { empty: n2, $anchor: e } = this.editor.state.selection, t = e.pos === 1;
9261    return !n2 || e.parent.type.name !== this.name ? false : t || !e.parent.textContent.length ? this.editor.commands.clearNodes() : false;
9262  }, Tab: ({ editor: n2 }) => {
9263    var e;
9264    if (!this.options.enableTabIndentation) return false;
9265    const t = (e = this.options.tabSize) != null ? e : gs, { state: r } = n2, { selection: s } = r, { $from: i, empty: o } = s;
9266    if (i.parent.type !== this.type) return false;
9267    const l = " ".repeat(t);
9268    return o ? n2.commands.insertContent(l) : n2.commands.command(({ tr: a }) => {
9269      const { from: c, to: u } = s, h = r.doc.textBetween(c, u, `
9270`, `
9271`).split(`
9272`).map((p) => l + p).join(`
9273`);
9274      return a.replaceWith(c, u, r.schema.text(h)), true;
9275    });
9276  }, "Shift-Tab": ({ editor: n2 }) => {
9277    var e;
9278    if (!this.options.enableTabIndentation) return false;
9279    const t = (e = this.options.tabSize) != null ? e : gs, { state: r } = n2, { selection: s } = r, { $from: i, empty: o } = s;
9280    return i.parent.type !== this.type ? false : o ? n2.commands.command(({ tr: l }) => {
9281      var a;
9282      const { pos: c } = i, u = i.start(), d = i.end(), h = r.doc.textBetween(u, d, `
9283`, `
9284`).split(`
9285`);
9286      let p = 0, m = 0;
9287      const g = c - u;
9288      for (let N = 0; N < h.length; N += 1) {
9289        if (m + h[N].length >= g) {
9290          p = N;
9291          break;
9292        }
9293        m += h[N].length + 1;
9294      }
9295      const x = ((a = h[p].match(/^ */)) == null ? void 0 : a[0]) || "", M = Math.min(x.length, t);
9296      if (M === 0) return true;
9297      let E = u;
9298      for (let N = 0; N < p; N += 1) E += h[N].length + 1;
9299      return l.delete(E, E + M), c - E <= M && l.setSelection(I.create(l.doc, E)), true;
9300    }) : n2.commands.command(({ tr: l }) => {
9301      const { from: a, to: c } = s, f = r.doc.textBetween(a, c, `
9302`, `
9303`).split(`
9304`).map((h) => {
9305        var p;
9306        const m = ((p = h.match(/^ */)) == null ? void 0 : p[0]) || "", g = Math.min(m.length, t);
9307        return h.slice(g);
9308      }).join(`
9309`);
9310      return l.replaceWith(a, c, r.schema.text(f)), true;
9311    });
9312  }, Enter: ({ editor: n2 }) => {
9313    if (!this.options.exitOnTripleEnter) return false;
9314    const { state: e } = n2, { selection: t } = e, { $from: r, empty: s } = t;
9315    if (!s || r.parent.type !== this.type) return false;
9316    const i = r.parentOffset === r.parent.nodeSize - 2, o = r.parent.textContent.endsWith(`
9317
9318`);
9319    return !i || !o ? false : n2.chain().command(({ tr: l }) => (l.delete(r.pos - 2, r.pos), true)).exitCode().run();
9320  }, ArrowDown: ({ editor: n2 }) => {
9321    if (!this.options.exitOnArrowDown) return false;
9322    const { state: e } = n2, { selection: t, doc: r } = e, { $from: s, empty: i } = t;
9323    if (!i || s.parent.type !== this.type || !(s.parentOffset === s.parent.nodeSize - 2)) return false;
9324    const l = s.after();
9325    return l === void 0 ? false : r.nodeAt(l) ? n2.commands.command(({ tr: c }) => (c.setSelection(R.near(r.resolve(l))), true)) : n2.commands.exitCode();
9326  } };
9327}, addInputRules() {
9328  return [_s({ find: sg, type: this.type, getAttributes: (n2) => ({ language: n2[1] }) }), _s({ find: ig, type: this.type, getAttributes: (n2) => ({ language: n2[1] }) })];
9329}, addProseMirrorPlugins() {
9330  return [new F({ key: new K("codeBlockVSCodeHandler"), props: { handlePaste: (n2, e) => {
9331    if (!e.clipboardData || this.editor.isActive(this.type.name)) return false;
9332    const t = e.clipboardData.getData("text/plain"), r = e.clipboardData.getData("vscode-editor-data"), s = r ? JSON.parse(r) : void 0, i = s == null ? void 0 : s.mode;
9333    if (!t || !i) return false;
9334    const { tr: o, schema: l } = n2.state, a = l.text(t.replace(/\r\n?/g, `
9335`));
9336    return o.replaceSelectionWith(this.type.create({ language: i }, a)), o.selection.$from.parent.type !== this.type && o.setSelection(I.near(o.doc.resolve(Math.max(0, o.selection.from - 2)))), o.setMeta("paste", true), n2.dispatch(o), true;
9337  } } })];
9338} }), lg = og, ag = xe.create({ name: "doc", topNode: true, content: "block+", renderMarkdown: (n2, e) => n2.content ? e.renderChildren(n2.content, `
9339
9340`) : "" }), cg = ag, ug = xe.create({ name: "hardBreak", markdownTokenName: "br", addOptions() {
9341  return { keepMarks: true, HTMLAttributes: {} };
9342}, inline: true, group: "inline", selectable: false, linebreakReplacement: true, parseHTML() {
9343  return [{ tag: "br" }];
9344}, renderHTML({ HTMLAttributes: n2 }) {
9345  return ["br", Y(this.options.HTMLAttributes, n2)];
9346}, renderText() {
9347  return `
9348`;
9349}, renderMarkdown: () => `  
9350`, parseMarkdown: () => ({ type: "hardBreak" }), addCommands() {
9351  return { setHardBreak: () => ({ commands: n2, chain: e, state: t, editor: r }) => n2.first([() => n2.exitCode(), () => n2.command(() => {
9352    const { selection: s, storedMarks: i } = t;
9353    if (s.$from.parent.type.spec.isolating) return false;
9354    const { keepMarks: o } = this.options, { splittableMarks: l } = r.extensionManager, a = i || s.$to.parentOffset && s.$from.marks();
9355    return e().insertContent({ type: this.name }).command(({ tr: c, dispatch: u }) => {
9356      if (u && a && o) {
9357        const d = a.filter((f) => l.includes(f.type.name));
9358        c.ensureMarks(d);
9359      }
9360      return true;
9361    }).run();
9362  })]) };
9363}, addKeyboardShortcuts() {
9364  return { "Mod-Enter": () => this.editor.commands.setHardBreak(), "Shift-Enter": () => this.editor.commands.setHardBreak() };
9365} }), dg = ug, fg = xe.create({ name: "heading", addOptions() {
9366  return { levels: [1, 2, 3, 4, 5, 6], HTMLAttributes: {} };
9367}, content: "inline*", group: "block", defining: true, addAttributes() {
9368  return { level: { default: 1, rendered: false } };
9369}, parseHTML() {
9370  return this.options.levels.map((n2) => ({ tag: `h${n2}`, attrs: { level: n2 } }));
9371}, renderHTML({ node: n2, HTMLAttributes: e }) {
9372  return [`h${this.options.levels.includes(n2.attrs.level) ? n2.attrs.level : this.options.levels[0]}`, Y(this.options.HTMLAttributes, e), 0];
9373}, parseMarkdown: (n2, e) => e.createNode("heading", { level: n2.depth || 1 }, e.parseInline(n2.tokens || [])), renderMarkdown: (n2, e) => {
9374  var t;
9375  const r = (t = n2.attrs) != null && t.level ? parseInt(n2.attrs.level, 10) : 1, s = "#".repeat(r);
9376  return n2.content ? `${s} ${e.renderChildren(n2.content)}` : "";
9377}, addCommands() {
9378  return { setHeading: (n2) => ({ commands: e }) => this.options.levels.includes(n2.level) ? e.setNode(this.name, n2) : false, toggleHeading: (n2) => ({ commands: e }) => this.options.levels.includes(n2.level) ? e.toggleNode(this.name, "paragraph", n2) : false };
9379}, addKeyboardShortcuts() {
9380  return this.options.levels.reduce((n2, e) => ({ ...n2, [`Mod-Alt-${e}`]: () => this.editor.commands.toggleHeading({ level: e }) }), {});
9381}, addInputRules() {
9382  return this.options.levels.map((n2) => _s({ find: new RegExp(`^(#{${Math.min(...this.options.levels)},${n2}})\\s$`), type: this.type, getAttributes: { level: n2 } }));
9383} }), hg = fg, pg = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, mg = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, gg = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, yg = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, bg = Wt.create({ name: "italic", addOptions() {
9384  return { HTMLAttributes: {} };
9385}, parseHTML() {
9386  return [{ tag: "em" }, { tag: "i", getAttrs: (n2) => n2.style.fontStyle !== "normal" && null }, { style: "font-style=normal", clearMark: (n2) => n2.type.name === this.name }, { style: "font-style=italic" }];
9387}, renderHTML({ HTMLAttributes: n2 }) {
9388  return ["em", Y(this.options.HTMLAttributes, n2), 0];
9389}, addCommands() {
9390  return { setItalic: () => ({ commands: n2 }) => n2.setMark(this.name), toggleItalic: () => ({ commands: n2 }) => n2.toggleMark(this.name), unsetItalic: () => ({ commands: n2 }) => n2.unsetMark(this.name) };
9391}, markdownTokenName: "em", parseMarkdown: (n2, e) => e.applyMark("italic", e.parseInline(n2.tokens || [])), renderMarkdown: (n2, e) => `*${e.renderChildren(n2)}*`, addKeyboardShortcuts() {
9392  return { "Mod-i": () => this.editor.commands.toggleItalic(), "Mod-I": () => this.editor.commands.toggleItalic() };
9393}, addInputRules() {
9394  return [Sn({ find: pg, type: this.type }), Sn({ find: gg, type: this.type })];
9395}, addPasteRules() {
9396  return [_t({ find: mg, type: this.type }), _t({ find: yg, type: this.type })];
9397} }), kg = bg;
9398const xg = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2
vendor: 16,594 bytes, lines 9398-9616
9398ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2", Sg = "\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2", Ks = "numeric", qs = "ascii", Js = "alpha", on = "asciinumeric", Zt = "alphanumeric", Gs = "domain", $c = "emoji", wg = "scheme", Cg = "slashscheme", ys = "whitespace";
9399function Mg(n2, e) {
9400  return n2 in e || (e[n2] = []), e[n2];
9401}
9402function pt(n2, e, t) {
9403  e[Ks] && (e[on] = true, e[Zt] = true), e[qs] && (e[on] = true, e[Js] = true), e[on] && (e[Zt] = true), e[Js] && (e[Zt] = true), e[Zt] && (e[Gs] = true), e[$c] && (e[Gs] = true);
9404  for (const r in e) {
9405    const s = Mg(r, t);
9406    s.indexOf(n2) < 0 && s.push(n2);
9407  }
9408}
9409function vg(n2, e) {
9410  const t = {};
9411  for (const r in e) e[r].indexOf(n2) >= 0 && (t[r] = true);
9412  return t;
9413}
9414function ae(n2 = null) {
9415  this.j = {}, this.jr = [], this.jd = null, this.t = n2;
9416}
9417ae.groups = {};
9418ae.prototype = { accepts() {
9419  return !!this.t;
9420}, go(n2) {
9421  const e = this, t = e.j[n2];
9422  if (t) return t;
9423  for (let r = 0; r < e.jr.length; r++) {
9424    const s = e.jr[r][0], i = e.jr[r][1];
9425    if (i && s.test(n2)) return i;
9426  }
9427  return e.jd;
9428}, has(n2, e = false) {
9429  return e ? n2 in this.j : !!this.go(n2);
9430}, ta(n2, e, t, r) {
9431  for (let s = 0; s < n2.length; s++) this.tt(n2[s], e, t, r);
9432}, tr(n2, e, t, r) {
9433  r = r || ae.groups;
9434  let s;
9435  return e && e.j ? s = e : (s = new ae(e), t && r && pt(e, t, r)), this.jr.push([n2, s]), s;
9436}, ts(n2, e, t, r) {
9437  let s = this;
9438  const i = n2.length;
9439  if (!i) return s;
9440  for (let o = 0; o < i - 1; o++) s = s.tt(n2[o]);
9441  return s.tt(n2[i - 1], e, t, r);
9442}, tt(n2, e, t, r) {
9443  r = r || ae.groups;
9444  const s = this;
9445  if (e && e.j) return s.j[n2] = e, e;
9446  const i = e;
9447  let o, l = s.go(n2);
9448  if (l ? (o = new ae(), Object.assign(o.j, l.j), o.jr.push.apply(o.jr, l.jr), o.jd = l.jd, o.t = l.t) : o = new ae(), i) {
9449    if (r) if (o.t && typeof o.t == "string") {
9450      const a = Object.assign(vg(o.t, r), t);
9451      pt(i, a, r);
9452    } else t && pt(i, t, r);
9453    o.t = i;
9454  }
9455  return s.j[n2] = o, o;
9456} };
9457const D = (n2, e, t, r, s) => n2.ta(e, t, r, s), V = (n2, e, t, r, s) => n2.tr(e, t, r, s), ll = (n2, e, t, r, s) => n2.ts(e, t, r, s), k = (n2, e, t, r, s) => n2.tt(e, t, r, s), Re = "WORD", Ys = "UWORD", Fc = "ASCIINUMERICAL", Vc = "ALPHANUMERICAL", wn = "LOCALHOST", Qs = "TLD", Xs = "UTLD", jn = "SCHEME", Dt = "SLASH_SCHEME", Oi = "NUM", Zs = "WS", Ii = "NL", ln = "OPENBRACE", an = "CLOSEBRACE", ir = "OPENBRACKET", or = "CLOSEBRACKET", lr = "OPENPAREN", ar = "CLOSEPAREN", cr = "OPENANGLEBRACKET", ur = "CLOSEANGLEBRACKET", dr = "FULLWIDTHLEFTPAREN", fr = "FULLWIDTHRIGHTPAREN", hr = "LEFTCORNERBRACKET", pr = "RIGHTCORNERBRACKET", mr = "LEFTWHITECORNERBRACKET", gr = "RIGHTWHITECORNERBRACKET", yr = "FULLWIDTHLESSTHAN", br = "FULLWIDTHGREATERTHAN", kr = "AMPERSAND", xr = "APOSTROPHE", Sr = "ASTERISK", Ue = "AT", wr = "BACKSLASH", Cr = "BACKTICK", Mr = "CARET", Je = "COLON", Di = "COMMA", vr = "DOLLAR", Me = "DOT", Tr = "EQUALS", Ri = "EXCLAMATION", me = "HYPHEN", cn = "PERCENT", Er = "PIPE", Ar = "PLUS", Nr = "POUND", un = "QUERY", Pi = "QUOTE", Hc = "FULLWIDTHMIDDLEDOT", Li = "SEMI", ve = "SLASH", dn = "TILDE", Or = "UNDERSCORE", _c = "EMOJI", Ir = "SYM";
9458var jc = Object.freeze({ __proto__: null, ALPHANUMERICAL: Vc, AMPERSAND: kr, APOSTROPHE: xr, ASCIINUMERICAL: Fc, ASTERISK: Sr, AT: Ue, BACKSLASH: wr, BACKTICK: Cr, CARET: Mr, CLOSEANGLEBRACKET: ur, CLOSEBRACE: an, CLOSEBRACKET: or, CLOSEPAREN: ar, COLON: Je, COMMA: Di, DOLLAR: vr, DOT: Me, EMOJI: _c, EQUALS: Tr, EXCLAMATION: Ri, FULLWIDTHGREATERTHAN: br, FULLWIDTHLEFTPAREN: dr, FULLWIDTHLESSTHAN: yr, FULLWIDTHMIDDLEDOT: Hc, FULLWIDTHRIGHTPAREN: fr, HYPHEN: me, LEFTCORNERBRACKET: hr, LEFTWHITECORNERBRACKET: mr, LOCALHOST: wn, NL: Ii, NUM: Oi, OPENANGLEBRACKET: cr, OPENBRACE: ln, OPENBRACKET: ir, OPENPAREN: lr, PERCENT: cn, PIPE: Er, PLUS: Ar, POUND: Nr, QUERY: un, QUOTE: Pi, RIGHTCORNERBRACKET: pr, RIGHTWHITECORNERBRACKET: gr, SCHEME: jn, SEMI: Li, SLASH: ve, SLASH_SCHEME: Dt, SYM: Ir, TILDE: dn, TLD: Qs, UNDERSCORE: Or, UTLD: Xs, UWORD: Ys, WORD: Re, WS: Zs });
9459const Ie = /[a-z]/, Jt = new RegExp("\\p{L}", "u"), bs = new RegExp("\\p{Emoji}", "u"), De = /\d/, ks = /\s/, al = "\r", xs = `
9460`, Tg = "\uFE0F", Eg = "\u200D", Ss = "\uFFFC";
9461let Bn = null, zn = null;
9462function Ag(n2 = []) {
9463  const e = {};
9464  ae.groups = e;
9465  const t = new ae();
9466  Bn == null && (Bn = cl(xg)), zn == null && (zn = cl(Sg)), k(t, "'", xr), k(t, "{", ln), k(t, "}", an), k(t, "[", ir), k(t, "]", or), k(t, "(", lr), k(t, ")", ar), k(t, "<", cr), k(t, ">", ur), k(t, "\uFF08", dr), k(t, "\uFF09", fr), k(t, "\u300C", hr), k(t, "\u300D", pr), k(t, "\u300E", mr), k(t, "\u300F", gr), k(t, "\uFF1C", yr), k(t, "\uFF1E", br), k(t, "&", kr), k(t, "*", Sr), k(t, "@", Ue), k(t, "`", Cr), k(t, "^", Mr), k(t, ":", Je), k(t, ",", Di), k(t, "$", vr), k(t, ".", Me), k(t, "=", Tr), k(t, "!", Ri), k(t, "-", me), k(t, "%", cn), k(t, "|", Er), k(t, "+", Ar), k(t, "#", Nr), k(t, "?", un), k(t, '"', Pi), k(t, "/", ve), k(t, ";", Li), k(t, "~", dn), k(t, "_", Or), k(t, "\\", wr), k(t, "\u30FB", Hc);
9467  const r = V(t, De, Oi, { [Ks]: true });
9468  V(r, De, r);
9469  const s = V(r, Ie, Fc, { [on]: true }), i = V(r, Jt, Vc, { [Zt]: true }), o = V(t, Ie, Re, { [qs]: true });
9470  V(o, De, s), V(o, Ie, o), V(s, De, s), V(s, Ie, s);
9471  const l = V(t, Jt, Ys, { [Js]: true });
9472  V(l, Ie), V(l, De, i), V(l, Jt, l), V(i, De, i), V(i, Ie), V(i, Jt, i);
9473  const a = k(t, xs, Ii, { [ys]: true }), c = k(t, al, Zs, { [ys]: true }), u = V(t, ks, Zs, { [ys]: true });
9474  k(t, Ss, u), k(c, xs, a), k(c, Ss, u), V(c, ks, u), k(u, al), k(u, xs), V(u, ks, u), k(u, Ss, u);
9475  const d = V(t, bs, _c, { [$c]: true });
9476  k(d, "#"), V(d, bs, d), k(d, Tg, d);
9477  const f = k(d, Eg);
9478  k(f, "#"), V(f, bs, d);
9479  const h = [[Ie, o], [De, s]], p = [[Ie, null], [Jt, l], [De, i]];
9480  for (let m = 0; m < Bn.length; m++) He(t, Bn[m], Qs, Re, h);
9481  for (let m = 0; m < zn.length; m++) He(t, zn[m], Xs, Ys, p);
9482  pt(Qs, { tld: true, ascii: true }, e), pt(Xs, { utld: true, alpha: true }, e), He(t, "file", jn, Re, h), He(t, "mailto", jn, Re, h), He(t, "http", Dt, Re, h), He(t, "https", Dt, Re, h), He(t, "ftp", Dt, Re, h), He(t, "ftps", Dt, Re, h), pt(jn, { scheme: true, ascii: true }, e), pt(Dt, { slashscheme: true, ascii: true }, e), n2 = n2.sort((m, g) => m[0] > g[0] ? 1 : -1);
9483  for (let m = 0; m < n2.length; m++) {
9484    const g = n2[m][0], x = n2[m][1] ? { [wg]: true } : { [Cg]: true };
9485    g.indexOf("-") >= 0 ? x[Gs] = true : Ie.test(g) ? De.test(g) ? x[on] = true : x[qs] = true : x[Ks] = true, ll(t, g, g, x);
9486  }
9487  return ll(t, "localhost", wn, { ascii: true }), t.jd = new ae(Ir), { start: t, tokens: Object.assign({ groups: e }, jc) };
9488}
9489function Wc(n2, e) {
9490  const t = Ng(e.replace(/[A-Z]/g, (l) => l.toLowerCase())), r = t.length, s = [];
9491  let i = 0, o = 0;
9492  for (; o < r; ) {
9493    let l = n2, a = null, c = 0, u = null, d = -1, f = -1;
9494    for (; o < r && (a = l.go(t[o])); ) l = a, l.accepts() ? (d = 0, f = 0, u = l) : d >= 0 && (d += t[o].length, f++), c += t[o].length, i += t[o].length, o++;
9495    i -= d, o -= f, c -= d, s.push({ t: u.t, v: e.slice(i - c, i), s: i - c, e: i });
9496  }
9497  return s;
9498}
9499function Ng(n2) {
9500  const e = [], t = n2.length;
9501  let r = 0;
9502  for (; r < t; ) {
9503    let s = n2.charCodeAt(r), i, o = s < 55296 || s > 56319 || r + 1 === t || (i = n2.charCodeAt(r + 1)) < 56320 || i > 57343 ? n2[r] : n2.slice(r, r + 2);
9504    e.push(o), r += o.length;
9505  }
9506  return e;
9507}
9508function He(n2, e, t, r, s) {
9509  let i;
9510  const o = e.length;
9511  for (let l = 0; l < o - 1; l++) {
9512    const a = e[l];
9513    n2.j[a] ? i = n2.j[a] : (i = new ae(r), i.jr = s.slice(), n2.j[a] = i), n2 = i;
9514  }
9515  return i = new ae(t), i.jr = s.slice(), n2.j[e[o - 1]] = i, i;
9516}
9517function cl(n2) {
9518  const e = [], t = [];
9519  let r = 0, s = "0123456789";
9520  for (; r < n2.length; ) {
9521    let i = 0;
9522    for (; s.indexOf(n2[r + i]) >= 0; ) i++;
9523    if (i > 0) {
9524      e.push(t.join(""));
9525      for (let o = parseInt(n2.substring(r, r + i), 10); o > 0; o--) t.pop();
9526      r += i;
9527    } else t.push(n2[r]), r++;
9528  }
9529  return e;
9530}
9531const Cn = { defaultProtocol: "http", events: null, format: ul, formatHref: ul, nl2br: false, tagName: "a", target: null, rel: null, validate: true, truncate: 1 / 0, className: null, attributes: null, ignoreTags: [], render: null };
9532function Bi(n2, e = null) {
9533  let t = Object.assign({}, Cn);
9534  n2 && (t = Object.assign(t, n2 instanceof Bi ? n2.o : n2));
9535  const r = t.ignoreTags, s = [];
9536  for (let i = 0; i < r.length; i++) s.push(r[i].toUpperCase());
9537  this.o = t, e && (this.defaultRender = e), this.ignoreTags = s;
9538}
9539Bi.prototype = { o: Cn, ignoreTags: [], defaultRender(n2) {
9540  return n2;
9541}, check(n2) {
9542  return this.get("validate", n2.toString(), n2);
9543}, get(n2, e, t) {
9544  const r = e != null;
9545  let s = this.o[n2];
9546  return s && (typeof s == "object" ? (s = t.t in s ? s[t.t] : Cn[n2], typeof s == "function" && r && (s = s(e, t))) : typeof s == "function" && r && (s = s(e, t.t, t)), s);
9547}, getObj(n2, e, t) {
9548  let r = this.o[n2];
9549  return typeof r == "function" && e != null && (r = r(e, t.t, t)), r;
9550}, render(n2) {
9551  const e = n2.render(this);
9552  return (this.get("render", null, n2) || this.defaultRender)(e, n2.t, n2);
9553} };
9554function ul(n2) {
9555  return n2;
9556}
9557function Uc(n2, e) {
9558  this.t = "token", this.v = n2, this.tk = e;
9559}
9560Uc.prototype = { isLink: false, toString() {
9561  return this.v;
9562}, toHref(n2) {
9563  return this.toString();
9564}, toFormattedString(n2) {
9565  const e = this.toString(), t = n2.get("truncate", e, this), r = n2.get("format", e, this);
9566  return t && r.length > t ? r.substring(0, t) + "\u2026" : r;
9567}, toFormattedHref(n2) {
9568  return n2.get("formatHref", this.toHref(n2.get("defaultProtocol")), this);
9569}, startIndex() {
9570  return this.tk[0].s;
9571}, endIndex() {
9572  return this.tk[this.tk.length - 1].e;
9573}, toObject(n2 = Cn.defaultProtocol) {
9574  return { type: this.t, value: this.toString(), isLink: this.isLink, href: this.toHref(n2), start: this.startIndex(), end: this.endIndex() };
9575}, toFormattedObject(n2) {
9576  return { type: this.t, value: this.toFormattedString(n2), isLink: this.isLink, href: this.toFormattedHref(n2), start: this.startIndex(), end: this.endIndex() };
9577}, validate(n2) {
9578  return n2.get("validate", this.toString(), this);
9579}, render(n2) {
9580  const e = this, t = this.toHref(n2.get("defaultProtocol")), r = n2.get("formatHref", t, this), s = n2.get("tagName", t, e), i = this.toFormattedString(n2), o = {}, l = n2.get("className", t, e), a = n2.get("target", t, e), c = n2.get("rel", t, e), u = n2.getObj("attributes", t, e), d = n2.getObj("events", t, e);
9581  return o.href = r, l && (o.class = l), a && (o.target = a), c && (o.rel = c), u && Object.assign(o, u), { tagName: s, attributes: o, content: i, eventListeners: d };
9582} };
9583function qr(n2, e) {
9584  class t extends Uc {
9585    constructor(s, i) {
9586      super(s, i), this.t = n2;
9587    }
9588  }
9589  for (const r in e) t.prototype[r] = e[r];
9590  return t.t = n2, t;
9591}
9592const dl = qr("email", { isLink: true, toHref() {
9593  return "mailto:" + this.toString();
9594} }), fl = qr("text"), Og = qr("nl"), $n = qr("url", { isLink: true, toHref(n2 = Cn.defaultProtocol) {
9595  return this.hasProtocol() ? this.v : `${n2}://${this.v}`;
9596}, hasProtocol() {
9597  const n2 = this.tk;
9598  return n2.length >= 2 && n2[0].t !== wn && n2[1].t === Je;
9599} }), pe = (n2) => new ae(n2);
9600function Ig({ groups: n2 }) {
9601  const e = n2.domain.concat([kr, Sr, Ue, wr, Cr, Mr, vr, Tr, me, Oi, cn, Er, Ar, Nr, ve, Ir, dn, Or]), t = [xr, Je, Di, Me, Ri, cn, un, Pi, Li, cr, ur, ln, an, or, ir, lr, ar, dr, fr, hr, pr, mr, gr, yr, br], r = [kr, xr, Sr, wr, Cr, Mr, vr, Tr, me, ln, an, cn, Er, Ar, Nr, un, ve, Ir, dn, Or], s = pe(), i = k(s, dn);
9602  D(i, r, i), D(i, n2.domain, i);
9603  const o = pe(), l = pe(), a = pe();
9604  D(s, n2.domain, o), D(s, n2.scheme, l), D(s, n2.slashscheme, a), D(o, r, i), D(o, n2.domain, o);
9605  const c = k(o, Ue);
9606  k(i, Ue, c), k(l, Ue, c), k(a, Ue, c);
9607  const u = k(i, Me);
9608  D(u, r, i), D(u, n2.domain, i);
9609  const d = pe();
9610  D(c, n2.domain, d), D(d, n2.domain, d);
9611  const f = k(d, Me);
9612  D(f, n2.domain, d);
9613  const h = pe(dl);
9614  D(f, n2.tld, h), D(f, n2.utld, h), k(c, wn, h);
9615  const p = k(d, me);
9616  k(p, me, p), D(p, n2.domain, d), D(h, n2.domain, d), k(h, Me, f), k(
9616h, me, p);
9617  const m = k(h, Je);
9618  D(m, n2.numeric, dl);
9619  const g = k(o, me), y = k(o, Me);
9620  k(g, me, g), D(g, n2.domain, o), D(y, r, i), D(y, n2.domain, o);
9621  const x = pe($n);
9622  D(y, n2.tld, x), D(y, n2.utld, x), D(x, n2.domain, o), D(x, r, i), k(x, Me, y), k(x, me, g), k(x, Ue, c);
9623  const M = k(x, Je), E = pe($n);
9624  D(M, n2.numeric, E);
9625  const C = pe($n), N = pe();
9626  D(C, e, C), D(C, t, N), D(N, e, C), D(N, t, N), k(x, ve, C), k(E, ve, C);
9627  const S = k(l, Je), O = k(a, Je), A = k(O, ve), L = k(A, ve);
9628  D(l, n2.domain, o), k(l, Me, y), k(l, me, g), D(a, n2.domain, o), k(a, Me, y), k(a, me, g), D(S, n2.domain, C), k(S, ve, C), k(S, un, C), D(L, n2.domain, C), D(L, e, C), k(L, ve, C);
9629  const ot = [[ln, an], [ir, or], [lr, ar], [cr, ur], [dr, fr], [hr, pr], [mr, gr], [yr, br]];
9630  for (let Fe = 0; Fe < ot.length; Fe++) {
9631    const [vt, fe] = ot[Fe], le = k(C, vt);
9632    k(N, vt, le), k(le, fe, C);
9633    const Tt = pe($n);
9634    D(le, e, Tt);
9635    const Ut = pe();
9636    D(le, t), D(Tt, e, Tt), D(Tt, t, Ut), D(Ut, e, Tt), D(Ut, t, Ut), k(Tt, fe, C), k(Ut, fe, C);
9637  }
9638  return k(s, wn, x), k(s, Ii, Og), { start: s, tokens: jc };
9639}
9640function Dg(n2, e, t) {
9641  let r = t.length, s = 0, i = [], o = [];
9642  for (; s < r; ) {
9643    let l = n2, a = null, c = null, u = 0, d = null, f = -1;
9644    for (; s < r && !(a = l.go(t[s].t)); ) o.push(t[s++]);
9645    for (; s < r && (c = a || l.go(t[s].t)); ) a = null, l = c, l.accepts() ? (f = 0, d = l) : f >= 0 && f++, s++, u++;
9646    if (f < 0) s -= u, s < r && (o.push(t[s]), s++);
9647    else {
9648      o.length > 0 && (i.push(ws(fl, e, o)), o = []), s -= f, u -= f;
9649      const h = d.t, p = t.slice(s - u, s);
9650      i.push(ws(h, e, p));
9651    }
9652  }
9653  return o.length > 0 && i.push(ws(fl, e, o)), i;
9654}
9655function ws(n2, e, t) {
9656  const r = t[0].s, s = t[t.length - 1].e, i = e.slice(r, s);
9657  return new n2(i, t);
9658}
9659const Rg = typeof console < "u" && console && console.warn || (() => {
9660}), Pg = "until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.", z = { scanner: null, parser: null, tokenQueue: [], pluginQueue: [], customSchemes: [], initialized: false };
9661function Lg() {
9662  return ae.groups = {}, z.scanner = null, z.parser = null, z.tokenQueue = [], z.pluginQueue = [], z.customSchemes = [], z.initialized = false, z;
9663}
9664function hl(n2, e = false) {
9665  if (z.initialized && Rg(`linkifyjs: already initialized - will not register custom scheme "${n2}" ${Pg}`), !/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n2)) throw new Error(`linkifyjs: incorrect scheme format.
96661. Must only contain digits, lowercase ASCII letters or "-"
96672. Cannot start or end with "-"
96683. "-" cannot repeat`);
9669  z.customSchemes.push([n2, e]);
9670}
9671function Bg() {
9672  z.scanner = Ag(z.customSchemes);
9673  for (let n2 = 0; n2 < z.tokenQueue.length; n2++) z.tokenQueue[n2][1]({ scanner: z.scanner });
9674  z.parser = Ig(z.scanner.tokens);
9675  for (let n2 = 0; n2 < z.pluginQueue.length; n2++) z.pluginQueue[n2][1]({ scanner: z.scanner, parser: z.parser });
9676  return z.initialized = true, z;
9677}
9678function zi(n2) {
9679  return z.initialized || Bg(), Dg(z.parser.start, n2, Wc(z.scanner.start, n2));
9680}
9681zi.scan = Wc;
9682function Kc(n2, e = null, t = null) {
9683  if (e && typeof e == "object") {
9684    if (t) throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);
9685    t = e, e = null;
9686  }
9687  const r = new Bi(t), s = zi(n2), i = [];
9688  for (let o = 0; o < s.length; o++) {
9689    const l = s[o];
9690    l.isLink && (!e || l.t === e) && r.check(l) && i.push(l.toFormattedObject(r));
9691  }
9692  return i;
9693}
9694var $i = "[\0- \xA0\u1680\u180E\u2000-\u2029\u205F\u3000]", zg = new RegExp($i), $g = new RegExp(`${$i}$`), Fg = new RegExp($i, "g");
9695function Vg(n2) {
9696  return n2.length === 1 ? n2[0].isLink : n2.length === 3 && n2[1].isLink ? ["()", "[]"].includes(n2[0].value + n2[2].value) : false;
9697}
9698function Hg(n2) {
9699  return new F({ key: new K("autolink"), appendTransaction: (e, t, r) => {
9700    const s = e.some((c) => c.docChanged) && !t.doc.eq(r.doc), i = e.some((c) => c.getMeta("preventAutolink"));
9701    if (!s || i) return;
9702    const { tr: o } = r, l = sc(t.doc, [...e]);
9703    if (dc(l).forEach(({ newRange: c }) => {
9704      const u = Ep(r.doc, c, (h) => h.isTextblock);
9705      let d, f;
9706      if (u.length > 1) d = u[0], f = r.doc.textBetween(d.pos, d.pos + d.node.nodeSize, void 0, " ");
9707      else if (u.length) {
9708        const h = r.doc.textBetween(c.from, c.to, " ", " ");
9709        if (!$g.test(h)) return;
9710        d = u[0], f = r.doc.textBetween(d.pos, c.to, void 0, " ");
9711      }
9712      if (d && f) {
9713        const h = f.split(zg).filter(Boolean);
9714        if (h.length <= 0) return false;
9715        const p = h[h.length - 1], m = d.pos + f.lastIndexOf(p);
9716        if (!p) return false;
9717        const g = zi(p).map((y) => y.toObject(n2.defaultProtocol));
9718        if (!Vg(g)) return false;
9719        g.filter((y) => y.isLink).map((y) => ({ ...y, from: m + y.start + 1, to: m + y.end + 1 })).filter((y) => r.schema.marks.code ? !r.doc.rangeHasMark(y.from, y.to, r.schema.marks.code) : true).filter((y) => n2.validate(y.value)).filter((y) => n2.shouldAutoLink(y.value)).forEach((y) => {
9720          Mi(y.from, y.to, r.doc).some((x) => x.mark.type === n2.type) || o.addMark(y.from, y.to, n2.type.create({ href: y.href }));
9721        });
9722      }
9723    }), !!o.steps.length) return o;
9724  } });
9725}
9726function _g(n2) {
9727  return new F({ key: new K("handleClickLink"), props: { handleClick: (e, t, r) => {
9728    var s, i;
9729    if (r.button !== 0 || !e.editable) return false;
9730    let o = null;
9731    if (r.target instanceof HTMLAnchorElement) o = r.target;
9732    else {
9733      const a = r.target;
9734      if (!a) return false;
9735      const c = n2.editor.view.dom;
9736      o = a.closest("a"), o && !c.contains(o) && (o = null);
9737    }
9738    if (!o) return false;
9739    let l = false;
9740    if (n2.enableClickSelection && (l = n2.editor.commands.extendMarkRange(n2.type.name)), n2.openOnClick) {
9741      const a = uc(e.state, n2.type.name), c = (s = o.href) != null ? s : a.href, u = (i = o.target) != null ? i : a.target;
9742      c && (window.open(c, u), l = true);
9743    }
9744    return l;
9745  } } });
9746}
9747function jg(n2) {
9748  return new F({ key: new K("handlePasteLink"), props: { handlePaste: (e, t, r) => {
9749    const { shouldAutoLink: s } = n2, { state: i } = e, { selection: o } = i, { empty: l } = o;
9750    if (l) return false;
9751    let a = "";
9752    r.content.forEach((u) => {
9753      a += u.textContent;
9754    });
9755    const c = Kc(a, { defaultProtocol: n2.defaultProtocol }).find((u) => u.isLink && u.value === a);
9756    return !a || !c || s !== void 0 && !s(c.value) ? false : n2.editor.commands.setMark(n2.type, { href: c.href });
9757  } } });
9758}
9759function ct(n2, e) {
9760  const t = ["http", "https", "ftp", "ftps", "mailto", "tel", "callto", "sms", "cid", "xmpp"];
9761  return e && e.forEach((r) => {
9762    const s = typeof r == "string" ? r : r.scheme;
9763    s && t.push(s);
9764  }), !n2 || n2.replace(Fg, "").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`, "i"));
9765}
9766var Wg = Wt.create({ name: "link", priority: 1e3, keepOnSplit: false, exitable: true, onCreate() {
9767  this.options.validate && !this.options.shouldAutoLink && (this.options.shouldAutoLink = this.options.validate, console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")), this.options.protocols.forEach((n2) => {
9768    if (typeof n2 == "string") {
9769      hl(n2);
9770      return;
9771    }
9772    hl(n2.scheme, n2.optionalSlashes);
9773  });
9774}, onDestroy() {
9775  Lg();
9776}, inclusive() {
9777  return this.options.autolink;
9778}, addOptions() {
9779  return { openOnClick: true, enableClickSelection: false, linkOnPaste: true, autolink: true, protocols: [], defaultProtocol: "http", HTMLAttributes: { target: "_blank", rel: "noopener noreferrer nofollow", class: null }, isAllowedUri: (n2, e) => !!ct(n2, e.protocols), validate: (n2) => !!n2, shouldAutoLink: (n2) => {
9780    const e = /^[a-z][a-z0-9+.-]*:\/\//i.test(n2), t = /^[a-z][a-z0-9+.-]*:/i.test(n2);
9781    if (e || t && !n2.includes("@")) return true;
9782    const s = (n2.includes("@") ? n2.split("@").pop() : n2).split(/[/?#:]/)[0];
9783    return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(s) || !/\./.test(s));
9784  } };
9785}, addAttributes() {
9786  return { href: { default: null, parseHTML(n2) {
9787    return n2.getAttribute("href");
9788  } }, target: { default: this.options.HTMLAttributes.target }, rel: { default: this.options.HTMLAttributes.rel }, class: { default: this.options.HTMLAttributes.class }, title: { default: null } };
9789}, parseHTML() {
9790  return [{ tag: "a[href]", getAttrs: (n2) => {
9791    const e = n2.getAttribute("href");
9792    return !e || !this.options.isAllowedUri(e, { defaultValidate: (t) => !!ct(t, this.options.protocols), protocols: this.options.protocols, defaultProtocol: this.options.defaultProtocol }) ? false : null;
9793  } }];
9794}, renderHTML({ HTMLAttributes: n2 }) {
9795  return this.options.isAllowedUri(n2.href, { defaultValidate: (e) => !!ct(e, this.options.protocols), protocols: this.options.protocols, defaultProtocol: this.options.defaultProtocol }) ? ["a", Y(this.options.HTMLAttributes, n2), 0] : ["a", Y(this.options.HTMLAttributes, { ...n2, href: "" }), 0];
9796}, markdownTokenName: "link", parseMarkdown: (n2, e) => e.applyMark("link", e.parseInline(n2.tokens || []), { href: n2.href, title: n2.title || null }), renderMarkdown: (n2, e) => {
9797  var t, r, s, i;
9798  const o = (r = (t = n2.attrs) == null ? void 0 : t.href) != null ? r : "", l = (i = (s = n2.attrs) == null ? void 0 : s.title) != null ? i : "", a = e.renderChildren(n2);
9799  return l ? `[${a}](${o} "${l}")` : `[${a}](${o})`;
9800}, addCommands() {
9801  return { setLink: (n2) => ({ chain: e }) => {
9802    const { href: t } = n2;
9803    return this.options.isAllowedUri(t, { defaultValidate: (r) => !!ct(r, this.options.protocols), protocols: this.options.protocols, defaultProtocol: this.options.defaultProtocol }) ? e().setMark(this.name, n2).setMeta("preventAutolink", true).run() : false;
9804  }, toggleLink: (n2) => ({ chain: e }) => {
9805    const { href: t } = n2 || {};
9806    return t && !this.options.isAllowedUri(t, { defaultValidate: (r) => !!ct(r, this.options.protocols), protocols: this.options.protocols, defaultProtocol: this.options.defaultProtocol }) ? false : e().toggleMark(this.name, n2, { extendEmptyMarkRange: true }).setMeta("preventAutolink", true).run();
9807  }, unsetLink: () => ({ chain: n2 }) => n2().unsetMark(this.name, { extendEmptyMarkRange: true }).setMeta("preventAutolink", true).run() };
9808}, addPasteRules() {
9809  return [_t({ find: (n2) => {
9810    const e = [];
9811    if (n2) {
9812      const { protocols: t, defaultProtocol: r } = this.options, s = Kc(n2).filter((i) => i.isLink && this.options.isAllowedUri(i.value, { defaultValidate: (o) => !!ct(o, t), protocols: t, defaultProtocol: r }));
9813      s.length && s.forEach((i) => {
9814        this.options.shouldAutoLink(i.value) && e.push({ text: i.value, data: { href: i.href }, index: i.start });
9815      });
9816    }
9817    return e;
9818  }, type: this.type, getAttributes: (n2) => {
9819    var e;
9820    return { href: (e = n2.data) == null ? void 0 : e.href };
9821  } })];
9822}, addProseMirrorPlugins() {
9823  const n2 = [], { protocols: e, defaultProtocol: t } = this.options;
9824  return this.options.autolink && n2.push(Hg({ type: this.type, defaultProtocol: this.options.defaultProtocol, validate: (r) => this.options.isAllowedUri(r, { defaultValidate: (s) => !!ct(s, e), protocols: e, defaultProtocol: t }), shouldAutoLink: this.options.shouldAutoLink })), n2.push(_g({ type: this.type, editor: this.editor, openOnClick: this.options.openOnClick === "whenNotEditable" ? true : this.options.openOnClick, enableClickSelection: this.options.enableClickSelection })), this.options.linkOnPaste && n2.push(jg({ editor: this.editor, defaultProtocol: this.options.defaultProtocol, type: this.type, shouldAutoLink: this.options.shouldAutoLink })), n2;
9825} }), Ug = Wg, Kg = Oc, qg = zc, pl = "&nbsp;", Jg = "\xA0", Gg = xe.create({ name: "paragraph", priority: 1e3, addOptions() {
9826  return { HTMLAttributes: {} };
9827}, group: "block", content: "inline*", parseHTML() {
9828  return [{ tag: "p" }];
9829}, renderHTML({ HTMLAttributes: n2 }) {
9830  return ["p", Y(this.options.HTMLAttributes, n2), 0];
9831}, parseMarkdown: (n2, e) => {
9832  const t = n2.tokens || [];
9833  if (t.length === 1 && t[0].type === "image") return e.parseChildren([t[0]]);
9834  const r = e.parseInline(t);
9835  return r.length === 1 && r[0].type === "text" && (r[0].text === pl || r[0].text === Jg) ? e.createNode("paragraph", void 0, []) : e.createNode("paragraph", void 0, r);
9836}, renderMarkdown: (n2, e) => {
9837  if (!n2) return "";
9838  const t = Array.isArray(n2.content) ? n2.content : [];
9839  return t.length === 0 ? pl : e.renderChildren(t);
9840}, addCommands() {
9841  return { setParagraph: () => ({ commands: n2 }) => n2.setNode(this.name) };
9842}, addKeyboardShortcuts() {
9843  return { "Mod-Alt-0": () => this.editor.commands.setParagraph() };
9844} }), Yg = Gg, Qg = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, Xg = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, Zg = Wt.create({ name: "strike", addOptions() {
9845  return { HTMLAttributes: {} };
9846}, parseHTML() {
9847  return [{ tag: "s" }, { tag: "del" }, { tag: "strike" }, { style: "text-decoration", consuming: false, getAttrs: (n2) => n2.includes("line-through") ? {} : false }];
9848}, renderHTML({ HTMLAttributes: n2 }) {
9849  return ["s", Y(this.options.HTMLAttributes, n2), 0];
9850}, markdownTokenName: "del", parseMarkdown: (n2, e) => e.applyMark("strike", e.parseInline(n2.tokens || [])), renderMarkdown: (n2, e) => `~~${e.renderChildren(n2)}~~`, addCommands() {
9851  return { setStrike: () => ({ commands: n2 }) => n2.setMark(this.name), toggleStrike: () => ({ commands: n2 }) => n2.toggleMark(this.name), unsetStrike: () => ({ commands: n2 }) => n2.unsetMark(this.name) };
9852}, addKeyboardShortcuts() {
9853  return { "Mod-Shift-s": () => this.editor.commands.toggleStrike() };
9854}, addInputRules() {
9855  return [Sn({ find: Qg, type: this.type })];
9856}, addPasteRules() {
9857  return [_t({ find: Xg, type: this.type })];
9858} }), ey = Zg, ty = xe.create({ name: "text", group: "inline", parseMarkdown: (n2) => ({ type: "text", text: n2.text || "" }), renderMarkdown: (n2) => n2.text || "" }), ny = ty, ry = Wt.create({ name: "underline", addOptions() {
9859  return { HTMLAttributes: {} };
9860}, parseHTML() {
9861  return [{ tag: "u" }, { style: "text-decoration", consuming: false, getAttrs: (n2) => n2.includes("underline") ? {} : false }];
9862}, renderHTML({ HTMLAttributes: n2 }) {
9863  return ["u", Y(this.options.HTMLAttributes, n2), 0];
9864}, parseMarkdown(n2, e) {
9865  return e.applyMark(this.name || "underline", e.parseInline(n2.tokens || []));
9866}, renderMarkdown(n2, e) {
9867  return `++${e.renderChildren(n2)}++`;
9868}, markdownTokenizer: { name: "underline", level: "inline", start(n2) {
9869  return n2.indexOf("++");
9870}, tokenize(n2, e, t) {
9871  const s = /^(\+\+)([\s\S]+?)(\+\+)/.exec(n2);
9872  if (!s) return;
9873  const i = s[2].trim();
9874  return { type: "underline", raw: s[0], text: i, tokens: t.inlineTokens(i) };
9875} }, addCommands() {
9876  return { setUnderline: () => ({ commands: n2 }) => n2.setMark(this.name), toggleUnderline: () => ({ commands: n2 }) => n2.toggleMark(this.name), unsetUnderline: () => ({ commands: n2 }) => n2.unsetMark(this.name) };
9877}, addKeyboardShortcuts() {
9878  return { "Mod-u": () => this.editor.commands.toggleUnderline(), "Mod-U": () => this.editor.commands.toggleUnderline() };
9879} }), sy = ry;
9880function iy(n2 = {}) {
9881  return new F({ view(e) {
9882    return new oy(e, n2);
9883  } });
9884}
9885class oy {
9886  constructor(e, t) {
9887    var r;
vendor: 4,372 bytes, lines 9888-9983
9888    this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (r = t.width) !== null && r !== void 0 ? r : 1, this.color = t.color === false ? void 0 : t.color || "black", this.class = t.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((s) => {
9889      let i = (o) => {
9890        this[s](o);
9891      };
9892      return e.dom.addEventListener(s, i), { name: s, handler: i };
9893    });
9894  }
9895  destroy() {
9896    this.handlers.forEach(({ name: e, handler: t }) => this.editorView.dom.removeEventListener(e, t));
9897  }
9898  update(e, t) {
9899    this.cursorPos != null && t.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
9900  }
9901  setCursor(e) {
9902    e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
9903  }
9904  updateOverlay() {
9905    let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent, r, s = this.editorView.dom, i = s.getBoundingClientRect(), o = i.width / s.offsetWidth, l = i.height / s.offsetHeight;
9906    if (t) {
9907      let d = e.nodeBefore, f = e.nodeAfter;
9908      if (d || f) {
9909        let h = this.editorView.nodeDOM(this.cursorPos - (d ? d.nodeSize : 0));
9910        if (h) {
9911          let p = h.getBoundingClientRect(), m = d ? p.bottom : p.top;
9912          d && f && (m = (m + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
9913          let g = this.width / 2 * l;
9914          r = { left: p.left, right: p.right, top: m - g, bottom: m + g };
9915        }
9916      }
9917    }
9918    if (!r) {
9919      let d = this.editorView.coordsAtPos(this.cursorPos), f = this.width / 2 * o;
9920      r = { left: d.left - f, right: d.left + f, top: d.top, bottom: d.bottom };
9921    }
9922    let a = this.editorView.dom.offsetParent;
9923    this.element || (this.element = a.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", t), this.element.classList.toggle("prosemirror-dropcursor-inline", !t);
9924    let c, u;
9925    if (!a || a == document.body && getComputedStyle(a).position == "static") c = -pageXOffset, u = -pageYOffset;
9926    else {
9927      let d = a.getBoundingClientRect(), f = d.width / a.offsetWidth, h = d.height / a.offsetHeight;
9928      c = d.left - a.scrollLeft * f, u = d.top - a.scrollTop * h;
9929    }
9930    this.element.style.left = (r.left - c) / o + "px", this.element.style.top = (r.top - u) / l + "px", this.element.style.width = (r.right - r.left) / o + "px", this.element.style.height = (r.bottom - r.top) / l + "px";
9931  }
9932  scheduleRemoval(e) {
9933    clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
9934  }
9935  dragover(e) {
9936    if (!this.editorView.editable) return;
9937    let t = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), r = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), s = r && r.type.spec.disableDropCursor, i = typeof s == "function" ? s(this.editorView, t, e) : s;
9938    if (t && !i) {
9939      let o = t.pos;
9940      if (this.editorView.dragging && this.editorView.dragging.slice) {
9941        let l = Gl(this.editorView.state.doc, o, this.editorView.dragging.slice);
9942        l != null && (o = l);
9943      }
9944      this.setCursor(o), this.scheduleRemoval(5e3);
9945    }
9946  }
9947  dragend() {
9948    this.scheduleRemoval(20);
9949  }
9950  drop() {
9951    this.scheduleRemoval(20);
9952  }
9953  dragleave(e) {
9954    this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
9955  }
9956}
9957class _ extends R {
9958  constructor(e) {
9959    super(e, e);
9960  }
9961  map(e, t) {
9962    let r = e.resolve(t.map(this.head));
9963    return _.valid(r) ? new _(r) : R.near(r);
9964  }
9965  content() {
9966    return w.empty;
9967  }
9968  eq(e) {
9969    return e instanceof _ && e.head == this.head;
9970  }
9971  toJSON() {
9972    return { type: "gapcursor", pos: this.head };
9973  }
9974  static fromJSON(e, t) {
9975    if (typeof t.pos != "number") throw new RangeError("Invalid input for GapCursor.fromJSON");
9976    return new _(e.resolve(t.pos));
9977  }
9978  getBookmark() {
9979    return new Fi(this.anchor);
9980  }
9981  static valid(e) {
9982    let t = e.parent;
9983    if (t.inlineContent || !ly(e) || !ay(e)) return false;
9984    let r = t.type.spec.allowGapCursor;
9985    if (r != null) return r;
9986    let s = t.contentMatchAt(e.index()).defaultType;
9987    return s && s.isTextblock;
9988  }
9989  static findGapCursorFrom(e, t, r = false) {
9990    e: for (; ; ) {
9991      if (!r && _.valid(e)) return e;
9992      let s = e.pos, i = null;
9993      for (let o = e.depth; ; o--) {
9994        let l = e.node(o);
9995        if (t > 0 ? e.indexAfter(o) < l.childCount : e.index(o) > 0) {
9996          i = l.child(t > 0 ? e.indexAfter(o) : e.index(o) - 1);
9997          break;
9998        } else if (o == 0) return null;
9999        s += t;
10000        let a = e.doc.resolve(s);
10001        if (_.valid(a)) return a;
10002      }
10003      for (; ; ) {
10004        let o = t > 0 ? i.firstChild : i.lastChild;
10005        if (!o) {
10006          if (i.isAtom && !i.isText && !T.isSelectable(i)) {
10007            e = e.doc.resolve(s + i.nodeSize * t), r = false;
10008            continue e;
10009          }
10010          break;
10011        }
10012        i = o, s += t;
10013        let l = e.doc.resolve(s);
10014        if (_.valid(l)) return l;
10015      }
10016      return null;
10017    }
10018  }
10019}
10020_.prototype.visible = false;
10021_.findFrom = _.findGapCursorFrom;
10022R.jsonID("gapcursor", _);
10023class Fi {
10024  constructor(e) {
10025    this.pos = e;
10026  }
10027  map(e) {
10028    return new Fi(e.map(this.pos));
10029  }
10030  resolve(e) {
10031    let t = e.resolve(this.pos);
10032    return _.valid(t) ? new _(t) : R.near(t);
10033  }
10034}
10035function qc(n2) {
10036  return n2.isAtom || n2.spec.isolating || n2.spec.createGapCursor;
10037}
10038function ly(n2) {
10039  for (let e = n2.depth; e >= 0; e--) {
10040    let t = n2.index(e), r = n2.node(e);
10041    if (t == 0) {
10042      if (r.type.spec.isolating) return true;
10043      continue;
10044    }
10045    for (let s = r.child(t - 1); ; s = s.lastChild) {
10046      if (s.childCount == 0 && !s.inlineContent || qc(s.type)) return true;
10047      if (s.inlineContent) return false;
10048    }
10049  }
10050  return true;
10051}
10052function ay(n2) {
10053  for (let e = n2.depth; e >= 0; e--) {
10054    let t = n2.indexAfter(e), r = n2.node(e);
10055    if (t == r.childCount) {
10056      if (r.type.spec.isolating) return true;
10057      continue;
10058    }
10059    for (let s = r.child(t); ; s = s.firstChild) {
10060      if (s.childCount == 0 && !s.inlineContent || qc(s.type)) return true;
10061      if (s.inlineContent) return false;
10062    }
10063  }
10064  return true;
10065}
10066function cy() {
10067  return new F({ props: { decorations: hy, createSelectionBetween(n2, e, t) {
10068    return e.pos == t.pos && _.valid(t) ? new _(t) : null;
10069  }, handleClick: dy, handleKeyDown: uy, handleDOMEvents: { beforeinput: fy } } });
10070}
10071const uy = Ya({ ArrowLeft: Fn("horiz", -1), ArrowRight: Fn("horiz", 1), ArrowUp: Fn("vert", -1), ArrowDown: Fn("vert", 1) });
10072function Fn(n2, e) {
10073  const t = n2 == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
10074  return function(r, s, i) {
10075    let o = r.selection, l = e > 0 ? o.$to : o.$from, a = o.empty;
10076    if (o instanceof I) {
10077      if (!i.endOfTextblock(t) || l.depth == 0) return false;
10078      a = false, l = r.doc.resolve(e > 0 ? l.after() : l.before());
10079    }
10080    let c = _.findGapCursorFrom(l, e, a);
10081    return c ? (s && s(r.tr.setSelection(new _(c))), true) : false;
10082  };
10083}
10084function dy(n2, e, t) {
10085  if (!n2 || !n2.editable) return false;
10086  let r = n2.state.doc.resolve(e);
10087  if (!_.valid(r)) return false;
10088  let s = n2.posAtCoords({ left: t.clientX, top: t.clientY });
10089  return s && s.inside > -1 && T.isSelectable(n2.state.doc.nodeAt(s.inside)) ? false : (n2.dispatch(n2.state.tr.setSelection(new _(r))), true);
10090}
10091function fy(n2, e) {
10092  if (e.inputType != "insertCompositionText" || !(n2.state.selection instanceof _)) return false;
10093  let { $from: t } = n2.state.selection, r = t.parent.contentMatchAt(t.index()).findWrapping(n2.state.schema.nodes.text);
10094  if (!r) return false;
10095  let s = b.empty;
10096  for (let o = r.length - 1; o >= 0; o--) s = b.from(r[o].createAndFill(null, s));
10097  let i = n2.state.tr.replace(t.pos, t.pos, new w(s, 0, 0));
10098  return i.setSelection(I.near(i.doc.resolve(t.pos + 1))), n2.dispatch(i), false;
10099}
10100function hy(n2) {
10101  if (!(n2.selection instanceof _)) return null;
10102  let e = document.createElement("div");
10103  return e.className = "ProseMirror-gapcursor", $.create(n2.doc, [se.widget(n2.selection.head, e, { key: "gapcursor" })]);
10104}
10105var Dr = 200, G = function() {
10106};
10107G.prototype.append = function(e) {
10108  return e.length ? (e = G.from(e), !this.length && e || e.length < Dr && this.leafAppend(e) || this.length < Dr && e.leafPrepend(this) || this.appendInner(e)) : this;
10109};
10110G.prototype.prepend = function(e) {
10111  return e.length ? G.from(e).append(this) : this;
10112};
10113G.prototype.appendInner = function(e) {
10114  return new py(this, e);
10115};
10116G.prototype.slice = function(e, t) {
10117  return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? G.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t));
10118};
10119G.prototype.get = function(e) {
10120  if (!(e < 0 || e >= this.length)) return this.getInner(e);
10121};
10122G.prototype.forEach = function(e, t, r) {
10123  t === void 0 && (t = 0), r === void 0 && (r = this.length), t <= r ? this.forEachInner(e, t, r, 0) : this.forEachInvertedInner(e, t, r, 0);
10124};
10125G.prototype.map = function(e, t, r) {
10126  t === void 0 && (t = 0), r === void 0 && (r = this.length);
10127  var s = [];
10128  return this.forEach(function(i, o) {
10129    return s.push(e(i, o));
10130  }, t, r), s;
10131};
10132G.from = function(e) {
10133  return e instanceof G ? e : e && e.length ? new Jc(e) : G.empty;
10134};
10135var Jc = (function(n2) {
10136  function e(r) {
10137    n2.call(this), this.values = r;
10138  }
10139  n2 && (e.__proto__ = n2), e.prototype = Object.create(n2 && n2.prototype), e.prototype.constructor = e;
10140  var t = { length: { configurable: true }, depth: { configurable: true } };
10141  return e.prototype.flatten = function() {
10142    return this.values;
10143  }, e.prototype.sliceInner = function(s, i) {
10144    return s == 0 && i == this.length ? this : new e(this.values.slice(s, i));
10145  }, e.prototype.getInner = function(s) {
10146    return this.values[s];
10147  }, e.prototype.forEachInner = function(s, i, o, l) {
10148    for (var a = i; a < o; a++) if (s(this.values[a], l + a) === false) return false;
10149  }, e.prototype.forEachInvertedInner = function(s, i, o, l) {
10150    for (var a = i - 1; a >= o; a--) if (s(this.values[a], l + a) === false) return false;
10151  }, e.prototype.leafAppend = function(s) {
10152    if (this.length + s.length <= Dr) return new e(this.values.concat(s.flatten()));
10153  }, e.prototype.leafPrepend = function(s) {
10154    if (this.length + s.length <= Dr) return new e(s.flatten().concat(this.values));
10155  }, t.length.get = function() {
10156    return this.values.length;
10157  }, t.depth.get = function() {
10158    return 0;
10159  }, Object.defineProperties(e.prototype, t), e;
10160})(G);
10161G.empty = new Jc([]);
10162var py = (function(n2) {
10163  function e(t, r) {
10164    n2.call(this), this.left = t, this.right = r, this.length = t.length + r.length, this.depth = Math.max(t.depth, r.depth) + 1;
10165  }
10166  return n2 && (e.__proto__ = n2), e.prototype = Object.create(n2 && n2.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
10167    return this.left.flatten().concat(this.right.flatten());
10168  }, e.prototype.getInner = function(r) {
10169    return r < this.left.length ? this.left.get(r) : this.right.get(r - this.left.length);
10170  }, e.prototype.forEachInner = function(r, s, i, o) {
10171    var l = this.left.length;
10172    if (s < l && this.left.forEachInner(r, s, Math.min(i, l), o) === false || i > l && this.right.forEachInner(r, Math.max(s - l, 0), Math.min(this.length, i) - l, o + l) === false) return false;
10173  }, e.prototype.forEachInvertedInner = function(r, s, i, o) {
10174    var l = this.left.length;
10175    if (s > l && this.right.forEachInvertedInner(r, s - l, Math.max(i, l) - l, o + l) === false || i < l && this.left.forEachInvertedInner(r, Math.min(s, l), i, o) === false) return false;
10176  }, e.prototype.sliceInner = function(r, s) {
10177    if (r == 0 && s == this.length) return this;
10178    var i = this.left.length;
10179    return s <= i ? this.left.slice(r, s) : r >= i ? this.right.slice(r - i, s - i) : this.left.slice(r, i).append(this.right.slice(0, s - i));
10180  }, e.prototype.leafAppend = function(r) {
10181    var s = this.right.leafAppend(r);
10182    if (s) return new e(this.left, s);
10183  }, e.prototype.leafPrepend = function(r) {
10184    var s = this.left.leafPrepend(r);
10185    if (s) return new e(s, this.right);
10186  }, e.prototype.appendInner = function(r) {
10187    return this.left.depth >= Math.max(this.right.depth, r.depth) + 1 ? new e(this.left, new e(this.right, r)) : new e(this, r);
10188  }, e;
10189})(G);
10190const my = 500;
10191class Se {
10192  constructor(e, t) {
10193    this.items = e, this.eventCount = t;
10194  }
10195  popEvent(e, t) {
10196    if (this.eventCount == 0) return null;
10197    let r = this.items.length;
10198    for (; ; r--) if (this.items.get(r - 1).selection) {
10199      --r;
10200      break;
10201    }
10202    let s, i;
10203    t && (s = this.remapping(r, this.items.length), i = s.maps.length);
10204    let o = e.tr, l, a, c = [], u = [];
10205    return this.items.forEach((d, f) => {
10206      if (!d.step) {
10207        s || (s = this.remapping(r, f + 1), i = s.maps.length), i--, u.push(d);
10208        return;
10209      }
10210      if (s) {
10211        u.push(new Te(d.map));
10212        let h = d.step.map(s.slice(i)), p;
10213        h && o.maybeStep(h).doc && (p = o.mapping.maps[o.mapping.maps.length - 1], c.push(new Te(p, void 0, void 0, c.length + u.length))), i--, p && s.appendMap(p, i);
10214      } else o.maybeStep(d.step);
10215      if (d.selection) return l = s ? d.selection.map(s.slice(i)) : d.selection, a = new Se(this.items.slice(0, r).append(u.reverse().concat(c)), this.eventCount - 1), false;
10216    }, this.items.length, 0), { remaining: a, transform: o, selection: l };
10217  }
10218  addTransform(e, t, r, s) {
10219    let i = [], o = this.eventCount, l = this.items, a = !s && l.length ? l.get(l.length - 1) : null;
10220    for (let u = 0; u < e.steps.length; u++) {
10221      let d = e.steps[u].invert(e.docs[u]), f = new Te(e.mapping.maps[u], d, t), h;
10222      (h = a && a.merge(f)) && (f = h, u ? i.pop() : l = l.slice(0, l.length - 1)), i.push(f), t && (o++, t = void 0), s || (a = f);
10223    }
10224    let c = o - r.depth;
10225    return c > yy && (l = gy(l, c), o -= c), new Se(l.append(i), o);
10226  }
10227  remapping(e, t) {
10228    let r = new pn();
10229    return this.items.forEach((s, i) => {
10230      let o = s.mirrorOffset != null && i - s.mirrorOffset >= e ? r.maps.length - s.mirrorOffset : void 0;
10231      r.appendMap(s.map, o);
10232    }, e, t), r;
10233  }
10234  addMaps(e) {
10235    return this.eventCount == 0 ? this : new Se(this.items.append(e.map((t) => new Te(t))), this.eventCount);
10236  }
10237  rebased(e, t) {
10238    if (!this.eventCount) return this;
10239    let r = [], s = Math.max(0, this.items.length - t), i = e.mapping, o = e.steps.length, l = this.eventCount;
10240    this.items.forEach((f) => {
10241      f.selection && l--;
10242    }, s);
10243    let a = t;
10244    this.items.forEach((f) => {
10245      let h = i.getMirror(--a);
10246      if (h == null) return;
10247      o = Math.min(o, h);
10248      let p = i.maps[h];
10249      if (f.step) {
10250        let m = e.steps[h].invert(e.docs[h]), g = f.selection && f.selection.map(i.slice(a + 1, h));
10251        g && l++, r.push(new Te(p, m, g));
10252      } else r.push(new Te(p));
10253    }, s);
10254    let c = [];
10255    for (let f = t; f < o; f++) c.push(new Te(i.maps[f]));
10256    let u = this.items.slice(0, s).append(c).append(r), d = new Se(u, l);
10257    return d.emptyItemCount() > my && (d = d.compress(this.items.length - r.length)), d;
10258  }
10259  emptyItemCount() {
10260    let e = 0;
10261    return this.items.forEach((t) => {
10262      t.step || e++;
10263    }), e;
10264  }
10265  compress(e = this.items.length) {
10266    let t = this.remapping(0, e), r = t.maps.length, s = [], i = 0;
10267    return this.items.forEach((o, l) => {
10268      if (l >= e) s.push(o), o.selection && i++;
10269      else if (o.step) {
10270        let a = o.step.map(t.slice(r)), c = a && a.getMap();
10271        if (r--, c && t.appendMap(c, r), a) {
10272          let u = o.selection && o.selection.map(t.slice(r));
10273          u && i++;
10274          let d = new Te(c.invert(), a, u), f, h = s.length - 1;
10275          (f = s.length && s[h].merge(d)) ? s[h] = f : s.push(d);
10276        }
10277      } else o.map && r--;
10278    }, this.items.length, 0), new Se(G.from(s.reverse()), i);
10279  }
10280}
10281Se.empty = new Se(G.empty, 0);
10282function gy(n2, e) {
10283  let t;
10284  return n2.forEach((r, s) => {
10285    if (r.selection && e-- == 0) return t = s, false;
10286  }), n2.slice(t);
10287}
10288class Te {
10289  constructor(e, t, r, s) {
10290    this.map = e, this.step = t, this.selection = r, this.mirrorOffset = s;
10291  }
10292  merge(e) {
10293    if (this.step && e.step && !e.selection) {
10294      let t = e.step.merge(this.step);
10295      if (t) return new Te(t.getMap().invert(), t, this.selection);
10296    }
10297  }
10298}
10299class Ke {
10300  constructor(e, t, r, s, i) {
10301    this.done = e, this.undone = t, this.prevRanges = r, this.prevTime = s, this.prevComposition = i;
10302  }
10303}
10304const yy = 20;
10305function by(n2, e, t, r) {
10306  let s = t.getMeta(kt), i;
10307  if (s) return s.historyState;
10308  t.getMeta(Sy) && (n2 = new Ke(n2.done, n2.undone, null, 0, -1));
10309  let o = t.getMeta("appendedTransaction");
10310  if (t.steps.length == 0) return n2;
10311  if (o && o.getMeta(kt)) return o.getMeta(kt).redo ? new Ke(n2.done.addTransform(t, void 0, r, Wn(e)), n2.undone, ml(t.mapping.maps), n2.prevTime, n2.prevComposition) : new Ke(n2.done, n2.undone.addTransform(t, void 0, r, Wn(e)), null, n2.prevTime, n2.prevComposition);
10312  if (t.getMeta("addToHistory") !== false && !(o && o.getMeta("addToHistory") === false)) {
10313    let l = t.getMeta("composition"), a = n2.prevTime == 0 || !o && n2.prevComposition != l && (n2.prevTime < (t.time || 0) - r.newGroupDelay || !ky(t, n2.prevRanges)), c = o ? Cs(n2.prevRanges, t.mapping) : ml(t.mapping.maps);
10314    return new Ke(n2.done.addTransform(t, a ? e.selection.getBookmark() : void 0, r, Wn(e)), Se.empty, c, t.time, l ?? n2.prevComposition);
10315  } else return (i = t.getMeta("rebased")) ? new Ke(n2.done.rebased(t, i), n2.undone.rebased(t, i), Cs(n2.prevRanges, t.mapping), n2.prevTime, n2.prevComposition) : new Ke(n2.done.addMaps(t.mapping.maps), n2.undone.addMaps(t.mapping.maps), Cs(n2.prevRanges, t.mapping), n2.prevTime, n2.prevComposition);
10316}
10317function ky(n2, e) {
10318  if (!e) return false;
10319  if (!n2.docChanged) return true;
10320  let t = false;
10321  return n2.mapping.maps[0].forEach((r, s) => {
10322    for (let i = 0; i < e.length; i += 2) r <= e[i + 1] && s >= e[i] && (t = true);
10323  }), t;
10324}
10325function ml(n2) {
10326  let e = [];
10327  for (let t = n2.length - 1; t >= 0 && e.length == 0; t--) n2[t].forEach((r, s, i, o) => e.push(i, o));
10328  return e;
10329}
10330function Cs(n2, e) {
10331  if (!n2) return null;
10332  let t = [];
10333  for (let r = 0; r < n2.length; r += 2) {
10334    let s = e.map(n2[r], 1), i = e.map(n2[r + 1], -1);
10335    s <= i && t.push(s, i);
10336  }
10337  return t;
10338}
10339function xy(n2, e, t) {
10340  let r = Wn(e), s = kt.get(e).spec.config, i = (t ? n2.undone : n2.done).popEvent(e, r);
10341  if (!i) return null;
10342  let o = i.selection.resolve(i.transform.doc), l = (t ? n2.done : n2.undone).addTransform(i.transform, e.selection.getBookmark(), s, r), a = new Ke(t ? l : i.remaining, t ? i.remaining : l, null, 0, -1);
10343  return i.transform.setSelection(o).setMeta(kt, { redo: t, historyState: a });
10344}
10345let Ms = false, gl = null;
10346function Wn(n2) {
10347  let e = n2.plugins;
10348  if (gl != e) {
10349    Ms = false, gl = e;
10350    for (let t = 0; t < e.length; t++) if (e[t].spec.historyPreserveItems) {
10351      Ms = true;
10352      break;
10353    }
10354  }
10355  return Ms;
10356}
10357const kt = new K("history"), Sy = new K("closeHistory");
10358function wy(n2 = {}) {
10359  return n2 = { depth: n2.depth || 100, newGroupDelay: n2.newGroupDelay || 500 }, new F({ key: kt, state: { init() {
10360    return new Ke(Se.empty, Se.empty, null, 0, -1);
10361  }, apply(e, t, r) {
10362    return by(t, r, e, n2);
10363  } }, config: n2, props: { handleDOMEvents: { beforeinput(e, t) {
10364    let r = t.inputType, s = r == "historyUndo" ? Yc : r == "historyRedo" ? Qc : null;
10365    return !s || !e.editable ? false : (t.preventDefault(), s(e.state, e.dispatch));
10366  } } } });
10367}
10368function Gc(n2, e) {
10369  return (t, r) => {
10370    let s = kt.getState(t);
10371    if (!s || (n2 ? s.undone : s.done).eventCount == 0) return false;
10372    if (r) {
10373      let i = xy(s, t, n2);
10374      i && r(e ? i.scrollIntoView() : i);
10375    }
10376    return true;
10377  };
10378}
10379const Yc = Gc(false, true), Qc = Gc(true, true);
10380U.create({ name: "characterCount", addOptions() {
10381  return { limit: null, mode: "textSize", textCounter: (n2) => n2.length, wordCounter: (n2) => n2.split(" ").filter((e) => e !== "").length };
10382}, addStorage() {
10383  return { characters: () => 0, words: () => 0 };
10384}, onBeforeCreate() {
10385  this.storage.characters = (n2) => {
10386    const e = (n2 == null ? void 0 : n2.node) || this.editor.state.doc;
10387    if (((n2 == null ? void 0 : n2.mode) || this.options.mode) === "textSize") {
10388      const r = e.textBetween(0, e.content.size, void 0, " ");
10389      return this.options.textCounter(r);
10390    }
10391    return e.nodeSize;
10392  }, this.storage.words = (n2) => {
10393    const e = (n2 == null ? void 0 : n2.node) || this.editor.state.doc, t = e.textBetween(0, e.content.size, " ", " ");
10394    return this.options.wordCounter(t);
10395  };
10396}, addProseMirrorPlugins() {
10397  let n2 = false;
10398  return [new F({ key: new K("characterCount"), appendTransaction: (e, t, r) => {
10399    if (n2) return;
10400    const s = this.options.limit;
10401    if (s == null || s === 0) {
10402      n2 = true;
10403      return;
10404    }
10405    const i = this.storage.characters({ node: r.doc });
10406    if (i > s) {
10407      const o = i - s, l = 0, a = o;
10408      console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);
10409      const c = r.tr.deleteRange(l, a);
10410      return n2 = true, c;
10411    }
10412    n2 = true;
10413  }, filterTransaction: (e, t) => {
10414    const r = this.options.limit;
10415    if (!e.docChanged || r === 0 || r === null || r === void 0) return true;
10416    const s = this.storage.characters({ node: t.doc }), i = this.storage.characters({ node: e.doc });
10417    if (i <= r || s > r && i > r && i <= s) return true;
10418    if (s > r && i > r && i > s || !e.getMeta("paste")) return false;
10419    const l = e.selection.$head.pos, a = i - r, c = l - a, u = l;
10420    return e.deleteRange(c, u), !(this.storage.characters({ node: e.doc }) > r);
10421  } })];
10422} });
10423var Jy = U.create({ name: "dropCursor", addOptions() {
10424  return { color: "currentColor", width: 1, class: void 0 };
10425}, addProseMirrorPlugins() {
10426  return [iy(this.options)];
10427} });
10428U.create({ name: "focus", addOptions() {
10429  return { className: "has-focus", mode: "all" };
10430}, addProseMirrorPlugins() {
10431  return [new F({ key: new K("focus"), props: { decorations: ({ doc: n2, selection: e }) => {
10432    const { isEditable: t, isFocused: r } = this.editor, { anchor: s } = e, i = [];
10433    if (!t || !r) return $.create(n2, []);
10434    let o = 0;
10435    this.options.mode === "deepest" && n2.descendants((a, c) => {
10436      if (a.isText) return;
10437      if (!(s >= c && s <= c + a.nodeSize - 1)) return false;
10438      o += 1;
10439    });
10440    let l = 0;
10441    return n2.descendants((a, c) => {
10442      if (a.isText || !(s >= c && s <= c + a.nodeSize - 1)) return false;
10443      if (l += 1, this.options.mode === "deepest" && o - l > 0 || this.options.mode === "shallowest" && l > 1) return this.options.mode === "deepest";
10444      i.push(se.node(c, c + a.nodeSize, { class: this.options.className }));
10445    }), $.create(n2, i);
10446  } } })];
10447} });
10448var Gy = U.create({ name: "gapCursor", addProseMirrorPlugins() {
10449  return [cy()];
10450}, extendNodeSchema(n2) {
10451  var e;
10452  const t = { name: n2.name, options: n2.options, storage: n2.storage };
10453  return { allowGapCursor: (e = P(v(n2, "allowGapCursor", t))) != null ? e : null };
10454} }), yl = "placeholder";
10455function Cy(n2) {
10456  return n2.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
10457}
10458var My = U.create({ name: "placeholder", addOptions() {
10459  return { emptyEditorClass: "is-editor-empty", emptyNodeClass: "is-empty", dataAttribute: yl, placeholder: "Write something \u2026", showOnlyWhenEditable: true, showOnlyCurrent: true, includeChildren: false };
10460}, addProseMirrorPlugins() {
10461  const n2 = this.options.dataAttribute ? `data-${Cy(this.options.dataAttribute)}` : `data-${yl}`;
10462  return [new F({ key: new K("placeholder"), props: { decorations: ({ doc: e, selection: t }) => {
10463    const r = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: s } = t, i = [];
10464    if (!r) return null;
10465    const o = this.editor.isEmpty;
10466    return e.descendants((l, a) => {
10467      const c = s >= a && s <= a + l.nodeSize, u = !l.isLeaf && Wr(l);
10468      if ((c || !this.options.showOnlyCurrent) && u) {
10469        const d = [this.options.emptyNodeClass];
10470        o && d.push(this.options.emptyEditorClass);
10471        const f = se.node(a, a + l.nodeSize, { class: d.join(" "), [n2]: typeof this.options.placeholder == "function" ? this.options.placeholder({ editor: this.editor, node: l, pos: a, hasAnchor: c }) : this.options.placeholder });
10472        i.push(f);
10473      }
10474      return this.options.includeChildren;
10475    }), $.create(e, i);
10476  } } })];
10477} });
10478U.create({ name: "selection", addOptions() {
10479  return { className: "selection" };
10480}, addProseMirrorPlugins() {
10481  const { editor: n2, options: e } = this;
10482  return [new F({ key: new K("selection"), props: { decorations(t) {
10483    return t.selection.empty || n2.isFocused || !n2.isEditable || jp(t.selection) || n2.view.dragging ? null : $.create(t.doc, [se.inline(t.selection.from, t.selection.to, { class: e.className })]);
10484  } } })];
10485} });
10486function bl({ types: n2, node: e }) {
10487  return e && Array.isArray(n2) && n2.includes(e.type) || (e == null ? void 0 : e.type) === n2;
10488}
10489var Yy = U.create({ name: "trailingNode", addOptions() {
10490  return { node: void 0, notAfter: [] };
10491}, addProseMirrorPlugins() {
10492  var n2;
10493  const e = new K(this.name), t = this.options.node || ((n2 = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : n2.name) || "paragraph", r = Object.entries(this.editor.schema.nodes).map(([, s]) => s).filter((s) => (this.options.notAfter || []).concat(t).includes(s.name));
10494  return [new F({ key: e, appendTransaction: (s, i, o) => {
10495    const { doc: l, tr: a, schema: c } = o, u = e.getState(o), d = l.content.size, f = c.nodes[t];
10496    if (u) return a.insert(d, f.create());
10497  }, state: { init: (s, i) => {
10498    const o = i.tr.doc.lastChild;
10499    return !bl({ node: o, types: r });
10500  }, apply: (s, i) => {
10501    if (!s.docChanged || s.getMeta("__uniqueIDTransaction")) return i;
10502    const o = s.doc.lastChild;
10503    return !bl({ node: o, types: r });
10504  } } })];
10505} }), vy = U.create({ name: "undoRedo", addOptions() {
10506  return { depth: 100, newGroupDelay: 500 };
10507}, addCommands() {
10508  return { undo: () => ({ state: n2, dispatch: e }) => Yc(n2, e), redo: () => ({ state: n2, dispatch: e }) => Qc(n2, e) };
10509}, addProseMirrorPlugins() {
10510  return [wy(this.options)];
10511}, addKeyboardShortcuts() {
10512  return { "Mod-z": () => this.editor.commands.undo(), "Shift-Mod-z": () => this.editor.commands.redo(), "Mod-y": () => this.editor.commands.redo(), "Mod-\u044F": () => this.editor.commands.undo(), "Shift-Mod-\u044F": () => this.editor.commands.redo() };
10513} });
10514function kl(n2) {
10515  return su((e, t) => ({ get() {
10516    return e(), n2;
10517  }, set(r) {
10518    n2 = r, requestAnimationFrame(() => {
10519      requestAnimationFrame(() => {
10520        t();
10521      });
10522    });
10523  } }));
10524}
10525var Ty = class extends Em {
10526  constructor(n2 = {}) {
10527    return super(n2), this.contentComponent = null, this.appContext = null, this.reactiveState = kl(this.view.state), this.reactiveExtensionStorage = kl(this.extensionStorage), this.on("beforeTransaction", ({ nextState: e }) => {
10528      this.reactiveState.value = e, this.reactiveExtensionStorage.value = this.extensionStorage;
10529    }), wl(this);
10530  }
10531  get state() {
10532    return this.reactiveState ? this.reactiveState.value : this.view.state;
10533  }
10534  get storage() {
10535    return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage;
10536  }
10537  registerPlugin(n2, e) {
10538    const t = super.registerPlugin(n2, e);
10539    return this.reactiveState && (this.reactiveState.value = t), t;
10540  }
10541  unregisterPlugin(n2) {
10542    const e = super.unregisterPlugin(n2);
10543    return this.reactiveState && e && (this.reactiveState.value = e), e;
10544  }
10545}, Ey = Zc({ name: "EditorContent", props: { editor: { default: null, type: Object } }, setup(n2) {
10546  const e = _e(), t = tu();
10547  return eu(() => {
10548    const r = n2.editor;
10549    r && r.options.element && e.value && Sl(() => {
10550      var s;
10551      if (!e.value || !((s = r.view.dom) != null && s.parentNode)) return;
10552      const i = H(e.value);
10553      e.value.append(...r.view.dom.parentNode.childNodes), r.contentComponent = t.ctx._, t && (r.appContext = { ...t.appContext, provides: t.provides }), r.setOptions({ element: i }), r.createNodeViews();
10554    });
10555  }), ei(() => {
10556    const r = n2.editor;
10557    r && (r.contentComponent = null, r.appContext = null);
10558  }), { rootEl: e };
10559}, render() {
10560  return xl("div", { ref: (n2) => {
10561    this.rootEl = n2;
10562  } });
10563} }), Ay = (n2 = {}) => {
10564  const e = ru();
10565  return Xc(() => {
10566    e.value = new Ty(n2);
10567  }), ei(() => {
10568    var t, r, s, i;
10569    const o = (r = (t = e.value) == null ? void 0 : t.view.dom) == null ? void 0 : r.parentNode, l = o == null ? void 0 : o.cloneNode(true);
10570    (s = o == null ? void 0 : o.parentNode) == null || s.replaceChild(l, o), (i = e.value) == null || i.destroy();
10571  }), e;
10572}, Qy = class {
10573  constructor(n2, { props: e = {}, editor: t }) {
10574    this.destroyed = false, this.editor = t, this.component = wl(n2), this.el = document.createElement("div"), this.props = nu(e), this.renderedComponent = this.renderComponent();
10575  }
10576  get element() {
10577    return this.renderedComponent.el;
10578  }
10579  get ref() {
10580    var n2, e, t, r;
10581    return (e = (n2 = this.renderedComponent.vNode) == null ? void 0 : n2.component) != null && e.exposed ? this.renderedComponent.vNode.component.exposed : (r = (t = this.renderedComponent.vNode) == null ? void 0 : t.component) == null ? void 0 : r.proxy;
10582  }
10583  renderComponent() {
10584    if (this.destroyed) return this.renderedComponent;
10585    let n2 = xl(this.component, this.props);
10586    return this.editor.appContext && (n2.appContext = this.editor.appContext), typeof document < "u" && this.el && Vi(n2, this.el), { vNode: n2, destroy: () => {
10587      this.el && Vi(null, this.el), this.el = null, n2 = null;
10588    }, el: this.el ? this.el.firstElementChild : null };
10589  }
10590  updateProps(n2 = {}) {
10591    this.destroyed || (Object.entries(n2).forEach(([e, t]) => {
10592      this.props[e] = t;
10593    }), this.renderComponent());
10594  }
10595  destroy() {
10596    this.destroyed || (this.destroyed = true, this.renderedComponent.destroy());
10597  }
10598};
10599const Ny = { key: 0, class: "flex overflow-x-auto [scrollbar-width:none] max-sm:overflow-visible [&::-webkit-scrollbar]:hidden" }, Oy = ["title", "aria-label", "disabled", "onClick"], Iy = { class: "rounded-md border border-gray-200 bg-white p-2 text-gray-900 shadow-sm" }, Dy = { class: "flex justify-between" }, Ry = ["placeholder", "onKeydown"], Py = { class: "ml-4" }, Ly = { class: "relative inline-flex rounded-md shadow-sm" }, By = ["disabled"], zy = ["title", "aria-label", "disabled", "onClick"], $y = ["title", "aria-label", "disabled", "onClick"], Xy = { __name: "TipTapEditor", props: { modelValue: { type: String, default: () => "" }, modelModifiers: { type: Object, default: () => ({}) }, type: { type: String, default: () => "html" }, placeholder: { type: String, default: () => "" }, editable: { type: Boolean, default: () => true }, textareaClasses: { type: [String, Array, Object], default: () => "" }, extensions: { type: Array, default: () => [] }, showButtons: { type: Boolean, default: null }, showAiButton: { type: Boolean, default: false } }
10599, emits: ["update:modelValue", "focus", "blur", "keyup.enter"], setup(n2, { expose: e, emit: t }) {
10600  const { t: r } = iu(), s = n2, i = t, o = s.type === "html", l = s.type === "json", a = _e(), { focused: c } = hu(a), u = _e(false), d = _e(null), f = _e(null), h = _e(null), p = _e(false), m = Ug.extend({ addKeyboardShortcuts() {
10601    return { "Mod-k": () => (E(), true) };
10602  } });
10603  pu(f, () => p.value = false);
10604  const g = Ay({ content: s.modelValue, extensions: [zm, jm, rg, lg, cg, hg.configure({ levels: [1] }), vy.configure({ depth: 50 }), kg, m.configure({ openOnClick: false }), Kg, qg, Yg, ey, ny, sy, My.configure({ placeholder: s.placeholder, showOnlyWhenEditable: false, showOnlyCurrent: false }), dg, ...s.extensions], editorProps: { attributes: { class: fu("prose prose-base max-w-none px-4 py-4 pb-12 focus:outline-none", s.textareaClasses) } }, editable: s.editable, onUpdate: () => {
10605    s.modelModifiers.lazy || (o && i("update:modelValue", g.value.getHTML()), l && i("update:modelValue", g.value.getJSON()));
10606  }, onBlur: () => {
10607    s.modelModifiers.lazy && (o && i("update:modelValue", g.value.getHTML()), l && i("update:modelValue", g.value.getJSON()));
10608  } }), y = () => g.value.chain().focus(), x = [{ label: r("Bold"), icon: gu, run: () => y().toggleBold().run() }, { label: r("Italic"), icon: yu, run: () => y().toggleItalic().run() }, { label: r("Underline"), icon: bu, run: () => y().toggleUnderline().run(), secondary: true }, { label: r("Strikethrough"), icon: ku, run: () => y().toggleStrike().run() }, { label: r("Toggle heading"), icon: xu, run: () => y().toggleHeading({ level: 1 }).run(), secondary: true }, { label: r("Blockquote"), icon: Su, run: () => y().toggleBlockquote().run(), secondary: true }, { label: r("Code"), icon: wu, run: () => y().toggleCodeBlock().run(), secondary: true }, { label: r("List"), icon: Cu, run: () => y().toggleBulletList().run() }, { label: r("Ordered list"), icon: Mu, run: () => y().toggleOrderedList().run() }, { label: r("Indent decrease"), icon: vu, run: () => y().liftListItem("listItem").run(), disabled: () => !g.value.can().liftListItem("listItem"), secondary: true }, { label: r("Indent increase"), icon: Tu, run: () => y().sinkListItem("listItem").run(), disabled: () => !g.value.can().sinkListItem("listItem"), secondary: true }], M = _e(s.showButtons !== null ? s.showButtons : localStorage.getItem("showEditorButtons") === "true"), E = () => {
10609    const S = g.value.getAttributes("link").href;
10610    p.value = true, Sl(() => h.value.focus()), d.value = S;
10611  }, C = () => {
10612    if (d.value !== null) {
10613      if (d.value === "") {
10614        g.value.chain().focus().extendMarkRange("link").unsetLink().run();
10615        return;
10616      }
10617      g.value.chain().focus().extendMarkRange("link").setLink({ href: d.value }).run(), p.value = false;
10618    }
10619  }, N = () => {
10620    g.value.commands.focus();
10621  };
10622  return Jr(() => s.modelValue, (S) => {
10623    let O = false;
10624    o && (O = g.value.getHTML() === S), l && (O = JSON.stringify(g.value.getJSON()) === JSON.stringify(S)), !O && g.value.commands.setContent(S, false);
10625  }), mu(c, (S) => {
10626    u.value = S;
10627  }, { debounce: 50, maxWait: 1e3 }), Jr(u, (S) => {
10628    i(S ? "focus" : "blur");
10629  }), Jr(M, (S) => {
10630    localStorage.setItem("showEditorButtons", S);
10631  }), ei(() => {
10632    g.value.destroy();
10633  }), e({ setFocus: N, editor: g, showingButtons: M }), (S, O) => (he(), Ve("div", { ref_key: "container", ref: a, class: Et(["rounded-md border shadow-sm", u.value ? "border-primary-500 ring-1 ring-primary-500" : "border-gray-300"]) }, [H(g) && M.value ? (he(), Ve("div", Ny, [(he(true), Ve(Gr, null, Yr(x.slice(0, 4), (A) => {
10634    var _a2, _b;
10635    return he(), Ve("button", { key: A.label, type: "button", class: Et(["p-1.5 text-gray-500 hover:text-gray-700 max-sm:p-2.5 [@media(hover:none)]:p-2.5", { "max-sm:hidden [@media(hover:none)]:max-lg:hidden": A.secondary, "cursor-not-allowed": (_a2 = A.disabled) == null ? void 0 : _a2.call(A) }]), title: A.label, "aria-label": A.label, tabindex: "-1", disabled: (_b = A.disabled) == null ? void 0 : _b.call(A), onClick: (L) => A.run() }, [(he(), An(Qr(A.icon), { class: "h-6 w-6" }))], 10, Oy);
10636  }), 128)), Ne(H(Ui), null, { default: lt(({ open: A }) => [Ne(H(ji), { class: Et([A ? "" : "text-opacity-90", "p-1.5 text-gray-500 hover:text-gray-700 max-sm:p-2.5 [@media(hover:none)]:p-2.5"]), title: H(r)("Link"), "aria-label": H(r)("Link"), tabindex: "-1", onClick: E }, { default: lt(() => [Ne(H(Eu), { class: "h-6 w-6" })]), _: 1 }, 8, ["class", "title", "aria-label"]), p.value ? (he(), An(ou, { key: 0, "enter-active-class": "transition duration-200 ease-out", "enter-from-class": "translate-y-1 opacity-0", "enter-to-class": "translate-y-0 opacity-100", "leave-active-class": "transition duration-150 ease-in", "leave-from-class": "translate-y-0 opacity-100", "leave-to-class": "translate-y-1 opacity-0" }, { default: lt(() => [Ne(H(Wi), { ref_key: "linkContainer", ref: f, static: "", class: "absolute left-1/2 z-10 mt-2 w-screen max-w-sm -translate-x-1/2 transform px-4 sm:px-0" }, { default: lt(() => [at("div", Iy, [at("div", Dy, [lu(at("input", { ref_key: "urlInput", ref: h, "onUpdate:modelValue": O[0] || (O[0] = (L) => d.value = L), type: "text", autocomplete: "off", placeholder: H(r)("Enter URL..."), class: "block w-full rounded-md border-gray-300 shadow-sm focus:border-primary-500 focus:ring-primary-500 sm:text-sm", onKeydown: au(cu(C, ["prevent"]), ["enter"]) }, null, 40, Ry), [[uu, d.value]]), at("div", Py, [at("span", Ly, [at("button", { type: "button", class: "relative inline-flex items-center rounded-l-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 focus:z-10 focus:border-primary-500 focus:outline-none focus:ring-1 focus:ring-primary-500", onClick: C }, Hi(H(r)("Link")), 1), at("button", { type: "button", class: Et(["relative -ml-px inline-flex items-center rounded-r-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 focus:z-10 focus:border-primary-500 focus:outline-none focus:ring-1 focus:ring-primary-500", H(g).isActive("link") ? "" : "cursor-not-allowed"]), disabled: !H(g).isActive("link"), onClick: O[1] || (O[1] = (L) => H(g).chain().focus().unsetLink().run()) }
10636, Hi(H(r)("Unlink")), 11, By)])])])])]), _: 1 }, 512)]), _: 1 })) : _i("", true)]), _: 1 }), (he(true), Ve(Gr, null, Yr(x.slice(4), (A) => {
10637    var _a2, _b;
10638    return he(), Ve("button", { key: A.label, type: "button", class: Et(["p-1.5 text-gray-500 hover:text-gray-700 max-sm:p-2.5 [@media(hover:none)]:p-2.5", { "max-sm:hidden [@media(hover:none)]:max-lg:hidden": A.secondary, "cursor-not-allowed": (_a2 = A.disabled) == null ? void 0 : _a2.call(A) }]), title: A.label, "aria-label": A.label, tabindex: "-1", disabled: (_b = A.disabled) == null ? void 0 : _b.call(A), onClick: (L) => A.run() }, [(he(), An(Qr(A.icon), { class: "h-6 w-6" }))], 10, zy);
10639  }), 128)), Ne(H(Ui), { class: "relative lg:hidden [@media(hover:hover)]:sm:hidden" }, { default: lt(({ close: A }) => [Ne(H(ji), { class: "p-2.5 text-gray-500 hover:text-gray-700", title: H(r)("More"), "aria-label": H(r)("More"), tabindex: "-1" }, { default: lt(() => [Ne(H(Au), { class: "h-6 w-6" })]), _: 1 }, 8, ["title", "aria-label"]), Ne(H(Wi), { class: "absolute right-0 top-full z-20 mt-1 flex rounded-md bg-white p-1 shadow-lg ring-1 ring-black ring-opacity-5" }, { default: lt(() => [(he(true), Ve(Gr, null, Yr(x.filter((L) => L.secondary), (L) => {
10640    var _a2, _b;
10641    return he(), Ve("button", { key: L.label, type: "button", class: Et(["p-2.5 text-gray-500 hover:text-gray-700", { "cursor-not-allowed": (_a2 = L.disabled) == null ? void 0 : _a2.call(L) }]), title: L.label, "aria-label": L.label, tabindex: "-1", disabled: (_b = L.disabled) == null ? void 0 : _b.call(L), onClick: (ot) => {
10642      L.run(), A();
10643    } }, [(he(), An(Qr(L.icon), { class: "h-6 w-6" }))], 10, $y);
10644  }), 128))]), _: 2 }, 1024)]), _: 1 })])) : _i("", true), Ne(H(Ey), { editor: H(g), class: "max-h-52 w-full overflow-y-auto p-0" }, null, 8, ["editor"]), du(S.$slots, "bottom")], 2));
10645} };
10646export {
10647  Ey as A,
10648  _m as B,
10649  og as C,
10650  $ as D,
10651  U as E,
10652  Gy as G,
10653  ug as H,
10654  bg as I,
10655  Oc as L,
10656  Wt as M,
10657  xe as N,
10658  zc as O,
10659  F as P,
10660  Zg as S,
10661  I as T,
10662  vy as U,
10663  Qy as V,
10664  Xy as _,
10665  K as a,
10666  se as b,
10667  Ce as c,
10668  Rm as d,
10669  qy as e,
10670  _t as f,
10671  Sn as g,
10672  Ky as h,
10673  jp as i,
10674  T as j,
10675  Bm as k,
10676  Nc as l,
10677  Y as m,
10678  Uy as n,
10679  ag as o,
10680  Jy as p,
10681  fg as q,
10682  Gm as r,
10683  Wg as s,
10684  Gg as t,
10685  ty as u,
10686  ry as v,
10687  Yy as w,
10688  Ay as x,
10689  Ug as y,
10690  My as z
10691};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.