@uva-glass/component-library 2.6.1 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/Lexical.prod-BAr6tzpa.js +4236 -0
  2. package/dist/Lexical.prod-BAr6tzpa.js.map +1 -0
  3. package/dist/{LexicalClipboard.prod-Dg23ixPD.js → LexicalClipboard.prod-CLCBYtDj.js} +56 -56
  4. package/dist/LexicalClipboard.prod-CLCBYtDj.js.map +1 -0
  5. package/dist/LexicalLink.prod-CBgZ4B3x.js +263 -0
  6. package/dist/LexicalLink.prod-CBgZ4B3x.js.map +1 -0
  7. package/dist/LexicalList.prod-haeqjypw.js +576 -0
  8. package/dist/LexicalList.prod-haeqjypw.js.map +1 -0
  9. package/dist/{LexicalSelection.prod-CNWFGVlh.js → LexicalSelection.prod-C8x7KK4L.js} +38 -38
  10. package/dist/LexicalSelection.prod-C8x7KK4L.js.map +1 -0
  11. package/dist/LexicalTable.prod-8RqiGUG-.js +1447 -0
  12. package/dist/LexicalTable.prod-8RqiGUG-.js.map +1 -0
  13. package/dist/LexicalUtils.prod-Dsec_Kl-.js +122 -0
  14. package/dist/LexicalUtils.prod-Dsec_Kl-.js.map +1 -0
  15. package/dist/{TablePlugin-E6UFlCgy.js → TablePlugin-sPSGmCno.js} +69 -69
  16. package/dist/{TablePlugin-E6UFlCgy.js.map → TablePlugin-sPSGmCno.js.map} +1 -1
  17. package/dist/components/CheckboxTree/CheckboxTree.js +1 -1
  18. package/dist/components/FormInput/FormInput.js +1 -1
  19. package/dist/components/InputField/InputField.stories.js +1 -1
  20. package/dist/components/MultiSelect/MultiSelect.js +1 -1
  21. package/dist/components/MultiSelect/MultiSelect.stories.js +1 -1
  22. package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -1
  23. package/dist/components/MultiSelect/index.js +1 -1
  24. package/dist/components/OverlayStepBar/OverlayStepBar.js +1 -1
  25. package/dist/components/PeriodSelector/PeriodSelector.js +1 -1
  26. package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +1 -1
  27. package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -1
  28. package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +3 -3
  29. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +2 -2
  30. package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +2 -2
  31. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +1 -1
  32. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +37 -37
  33. package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
  34. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +23 -23
  35. package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +13 -13
  36. package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +1 -1
  37. package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +3 -3
  38. package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +26 -26
  39. package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
  40. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +17 -17
  41. package/dist/components/RteEditor/Plugins/index.js +1 -1
  42. package/dist/components/RteEditor/RteEditor.js +501 -557
  43. package/dist/components/RteEditor/RteEditor.js.map +1 -1
  44. package/dist/components/RteEditor/helpers.js +11 -11
  45. package/dist/components/index.js +1 -1
  46. package/dist/{helpers-BVGma1u6.js → helpers-DHHQR5ys.js} +44 -44
  47. package/dist/{helpers-BVGma1u6.js.map → helpers-DHHQR5ys.js.map} +1 -1
  48. package/dist/index.js +1 -1
  49. package/package.json +14 -14
  50. package/dist/Lexical.prod-Bzma_w4s.js +0 -4216
  51. package/dist/Lexical.prod-Bzma_w4s.js.map +0 -1
  52. package/dist/LexicalClipboard.prod-Dg23ixPD.js.map +0 -1
  53. package/dist/LexicalLink.prod-C1RDJLfo.js +0 -208
  54. package/dist/LexicalLink.prod-C1RDJLfo.js.map +0 -1
  55. package/dist/LexicalList.prod-BGzfDPU0.js +0 -568
  56. package/dist/LexicalList.prod-BGzfDPU0.js.map +0 -1
  57. package/dist/LexicalSelection.prod-CNWFGVlh.js.map +0 -1
  58. package/dist/LexicalTable.prod-D-4NN9o5.js +0 -1366
  59. package/dist/LexicalTable.prod-D-4NN9o5.js.map +0 -1
  60. package/dist/LexicalUtils.prod-Cg2siy-c.js +0 -94
  61. package/dist/LexicalUtils.prod-Cg2siy-c.js.map +0 -1
@@ -0,0 +1,4236 @@
1
+ function lo(n) {
2
+ return {};
3
+ }
4
+ const Nn = {}, ao = {}, Ws = {}, Se = {}, me = {}, Zn = {}, Ht = {}, Ur = {}, tr = {}, Ce = {}, Te = {}, wt = {}, $r = {}, jr = {}, Rs = {}, Ks = {}, Js = {}, Us = {}, $s = {}, js = {}, Vs = {}, gn = {}, Hs = {}, qs = {}, Gs = {}, Qs = {}, Xs = {}, co = {}, uo = {}, fo = {}, Ys = {}, ho = {}, Zs = {}, ti = {}, ei = {}, Vr = {}, Hr = {}, er = {}, go = {}, _o = {}, po = {}, yo = {}, ni = {}, ri = {}, si = {}, st = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, ii = st && "documentMode" in document ? document.documentMode : null, tt = st && /Mac|iPod|iPhone|iPad/.test(navigator.platform), vt = st && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent), ke = !(!st || !("InputEvent" in window) || ii) && "getTargetRanges" in new window.InputEvent("input"), ze = st && /Version\/[\d.]+.*Safari/.test(navigator.userAgent), re = st && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream, oi = st && /Android/.test(navigator.userAgent), qr = st && /^(?=.*Chrome).*/i.test(navigator.userAgent), li = st && oi && qr, En = st && /AppleWebKit\/[\d.]+/.test(navigator.userAgent) && !qr, ai = 1, ci = 3, ui = 9, fi = 11, Et = 0, Gr = 1, zt = 2, di = 0, hi = 1, gi = 2, be = 4, we = 8, Fn = 128, _i = 1792 | (112 | (3 | be | we) | Fn), Pn = 1, On = 2, Ln = 3, Dn = 4, Mn = 5, In = 6, We = ze || re || En ? " " : "​", ct = `
5
+
6
+ `, pi = vt ? " " : We, Qr = "֑-߿יִ-﷽ﹰ-ﻼ", Xr = "A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿", yi = new RegExp("^[^" + Xr + "]*[" + Qr + "]"), mi = new RegExp("^[^" + Qr + "]*[" + Xr + "]"), V = { bold: 1, capitalize: 1024, code: 16, highlight: Fn, italic: 2, lowercase: 256, strikethrough: be, subscript: 32, superscript: 64, underline: we, uppercase: 512 }, xi = { directionless: 1, unmergeable: 2 }, nr = { center: On, end: In, justify: Dn, left: Pn, right: Ln, start: Mn }, vi = { [On]: "center", [In]: "end", [Dn]: "justify", [Pn]: "left", [Ln]: "right", [Mn]: "start" }, Si = { normal: 0, segmented: 2, token: 1 }, Ci = { [di]: "normal", [gi]: "segmented", [hi]: "token" };
7
+ function Ti(n) {
8
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
9
+ }
10
+ var T = Ti(function(n) {
11
+ const t = new URLSearchParams();
12
+ t.append("code", n);
13
+ for (let e = 1; e < arguments.length; e++) t.append("v", arguments[e]);
14
+ throw Error(`Minified Lexical error #${n}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
15
+ });
16
+ function Ne(...n) {
17
+ const t = [];
18
+ for (const e of n) if (e && typeof e == "string") for (const [r] of e.matchAll(/\S+/g)) t.push(r);
19
+ return t;
20
+ }
21
+ const ki = 100;
22
+ let _n = !1, An = 0;
23
+ function bi(n) {
24
+ An = n.timeStamp;
25
+ }
26
+ function rn(n, t, e) {
27
+ const r = n.nodeName === "BR", s = t.__lexicalLineBreak;
28
+ return s && (n === s || r && n.previousSibling === s) || r && Je(n, e) !== void 0;
29
+ }
30
+ function wi(n, t, e) {
31
+ const r = ft(e._window);
32
+ let s = null, i = null;
33
+ r !== null && r.anchorNode === n && (s = r.anchorOffset, i = r.focusOffset);
34
+ const o = n.nodeValue;
35
+ o !== null && Kn(t, o, s, i, !1);
36
+ }
37
+ function Ni(n, t, e) {
38
+ if (P(n)) {
39
+ const r = n.anchor.getNode();
40
+ if (r.is(e) && n.format !== r.getFormat()) return !1;
41
+ }
42
+ return dt(t) && e.isAttached();
43
+ }
44
+ function Ei(n, t, e, r) {
45
+ for (let s = n; s && !Ji(s); s = se(s)) {
46
+ const i = Je(s, t);
47
+ if (i !== void 0) {
48
+ const o = j(i, e);
49
+ if (o) return I(o) || !X(s) ? void 0 : [s, o];
50
+ } else if (s === r) return [r, os(e)];
51
+ }
52
+ }
53
+ function Yr(n, t, e) {
54
+ _n = !0;
55
+ const r = performance.now() - An > ki;
56
+ try {
57
+ Y(n, () => {
58
+ const s = M() || function(f) {
59
+ return f.getEditorState().read(() => {
60
+ const d = M();
61
+ return d !== null ? d.clone() : null;
62
+ });
63
+ }(n), i = /* @__PURE__ */ new Map(), o = n.getRootElement(), l = n._editorState, a = n._blockCursorElement;
64
+ let c = !1, u = "";
65
+ for (let f = 0; f < t.length; f++) {
66
+ const d = t[f], g = d.type, _ = d.target, p = Ei(_, n, l, o);
67
+ if (!p) continue;
68
+ const [m, y] = p;
69
+ if (g === "characterData") r && E(y) && dt(_) && Ni(s, _, y) && wi(_, y, n);
70
+ else if (g === "childList") {
71
+ c = !0;
72
+ const x = d.addedNodes;
73
+ for (let v = 0; v < x.length; v++) {
74
+ const F = x[v], C = ss(F), N = F.parentNode;
75
+ if (N != null && F !== a && C === null && !rn(F, N, n)) {
76
+ if (vt) {
77
+ const O = (X(F) ? F.innerText : null) || F.nodeValue;
78
+ O && (u += O);
79
+ }
80
+ N.removeChild(F);
81
+ }
82
+ }
83
+ const b = d.removedNodes, k = b.length;
84
+ if (k > 0) {
85
+ let v = 0;
86
+ for (let F = 0; F < k; F++) {
87
+ const C = b[F];
88
+ (rn(C, _, n) || a === C) && (_.appendChild(C), v++);
89
+ }
90
+ k !== v && i.set(m, y);
91
+ }
92
+ }
93
+ }
94
+ if (i.size > 0) for (const [f, d] of i) d.reconcileObservedMutation(f, n);
95
+ const h = e.takeRecords();
96
+ if (h.length > 0) {
97
+ for (let f = 0; f < h.length; f++) {
98
+ const d = h[f], g = d.addedNodes, _ = d.target;
99
+ for (let p = 0; p < g.length; p++) {
100
+ const m = g[p], y = m.parentNode;
101
+ y == null || m.nodeName !== "BR" || rn(m, _, n) || y.removeChild(m);
102
+ }
103
+ }
104
+ e.takeRecords();
105
+ }
106
+ s !== null && (c && (s.dirty = !0, ut(s)), vt && us(n) && s.insertRawText(u));
107
+ });
108
+ } finally {
109
+ _n = !1;
110
+ }
111
+ }
112
+ function Zr(n) {
113
+ const t = n._observer;
114
+ t !== null && Yr(n, t.takeRecords(), t);
115
+ }
116
+ function ts(n) {
117
+ (function(t) {
118
+ An === 0 && $e(t).addEventListener("textInput", bi, !0);
119
+ })(n), n._observer = new MutationObserver((t, e) => {
120
+ Yr(n, t, e);
121
+ });
122
+ }
123
+ function rr(n, t) {
124
+ const e = n.__mode, r = n.__format, s = n.__style, i = t.__mode, o = t.__format, l = t.__style;
125
+ return !(e !== null && e !== i || r !== null && r !== o || s !== null && s !== l);
126
+ }
127
+ function sr(n, t) {
128
+ const e = n.mergeWithSibling(t), r = A()._normalizedNodes;
129
+ return r.add(n.__key), r.add(t.__key), e;
130
+ }
131
+ function ir(n) {
132
+ let t, e, r = n;
133
+ if (r.__text !== "" || !r.isSimpleText() || r.isUnmergeable()) {
134
+ for (; (t = r.getPreviousSibling()) !== null && E(t) && t.isSimpleText() && !t.isUnmergeable(); ) {
135
+ if (t.__text !== "") {
136
+ if (rr(t, r)) {
137
+ r = sr(t, r);
138
+ break;
139
+ }
140
+ break;
141
+ }
142
+ t.remove();
143
+ }
144
+ for (; (e = r.getNextSibling()) !== null && E(e) && e.isSimpleText() && !e.isUnmergeable(); ) {
145
+ if (e.__text !== "") {
146
+ if (rr(r, e)) {
147
+ r = sr(r, e);
148
+ break;
149
+ }
150
+ break;
151
+ }
152
+ e.remove();
153
+ }
154
+ } else r.remove();
155
+ }
156
+ function or(n) {
157
+ return lr(n.anchor), lr(n.focus), n;
158
+ }
159
+ function lr(n) {
160
+ for (; n.type === "element"; ) {
161
+ const t = n.getNode(), e = n.offset;
162
+ let r, s;
163
+ if (e === t.getChildrenSize() ? (r = t.getChildAtIndex(e - 1), s = !0) : (r = t.getChildAtIndex(e), s = !1), E(r)) {
164
+ n.set(r.__key, s ? r.getTextContentSize() : 0, "text");
165
+ break;
166
+ }
167
+ if (!S(r)) break;
168
+ n.set(r.__key, s ? r.getChildrenSize() : 0, "element");
169
+ }
170
+ }
171
+ let Fi = 1;
172
+ const Pi = typeof queueMicrotask == "function" ? queueMicrotask : (n) => {
173
+ Promise.resolve().then(n);
174
+ };
175
+ function es(n) {
176
+ const t = document.activeElement;
177
+ if (!X(t)) return !1;
178
+ const e = t.nodeName;
179
+ return I(zn(n)) && (e === "INPUT" || e === "TEXTAREA" || t.contentEditable === "true" && Ke(t) == null);
180
+ }
181
+ function Re(n, t, e) {
182
+ const r = n.getRootElement();
183
+ try {
184
+ return r !== null && r.contains(t) && r.contains(e) && t !== null && !es(t) && ns(t) === n;
185
+ } catch {
186
+ return !1;
187
+ }
188
+ }
189
+ function Bn(n) {
190
+ return n instanceof Ye;
191
+ }
192
+ function ns(n) {
193
+ let t = n;
194
+ for (; t != null; ) {
195
+ const e = Ke(t);
196
+ if (Bn(e)) return e;
197
+ t = se(t);
198
+ }
199
+ return null;
200
+ }
201
+ function Ke(n) {
202
+ return n ? n.__lexicalEditor : null;
203
+ }
204
+ function bt(n) {
205
+ return n.isToken() || n.isSegmented();
206
+ }
207
+ function dt(n) {
208
+ return ie(n) && n.nodeType === ci;
209
+ }
210
+ function Oi(n) {
211
+ return ie(n) && n.nodeType === ui;
212
+ }
213
+ function Ee(n) {
214
+ let t = n;
215
+ for (; t != null; ) {
216
+ if (dt(t)) return t;
217
+ t = t.firstChild;
218
+ }
219
+ return null;
220
+ }
221
+ function Fe(n, t, e) {
222
+ const r = V[t];
223
+ if (e !== null && (n & r) == (e & r)) return n;
224
+ let s = n ^ r;
225
+ return t === "subscript" ? s &= ~V.superscript : t === "superscript" ? s &= ~V.subscript : t === "lowercase" ? (s &= ~V.uppercase, s &= ~V.capitalize) : t === "uppercase" ? (s &= ~V.lowercase, s &= ~V.capitalize) : t === "capitalize" && (s &= ~V.lowercase, s &= ~V.uppercase), s;
226
+ }
227
+ function mo(n) {
228
+ return E(n) || Bt(n) || I(n);
229
+ }
230
+ function rs(n, t) {
231
+ if (t != null) return void (n.__key = t);
232
+ G(), Os();
233
+ const e = A(), r = Tt(), s = "" + Fi++;
234
+ r._nodeMap.set(s, n), S(n) ? e._dirtyElements.set(s, !0) : e._dirtyLeaves.add(s), e._cloneNotNeeded.add(s), e._dirtyType = Gr, n.__key = s;
235
+ }
236
+ function Nt(n) {
237
+ const t = n.getParent();
238
+ if (t !== null) {
239
+ const e = n.getWritable(), r = t.getWritable(), s = n.getPreviousSibling(), i = n.getNextSibling();
240
+ if (s === null) if (i !== null) {
241
+ const o = i.getWritable();
242
+ r.__first = i.__key, o.__prev = null;
243
+ } else r.__first = null;
244
+ else {
245
+ const o = s.getWritable();
246
+ if (i !== null) {
247
+ const l = i.getWritable();
248
+ l.__prev = o.__key, o.__next = l.__key;
249
+ } else o.__next = null;
250
+ e.__prev = null;
251
+ }
252
+ if (i === null) if (s !== null) {
253
+ const o = s.getWritable();
254
+ r.__last = s.__key, o.__next = null;
255
+ } else r.__last = null;
256
+ else {
257
+ const o = i.getWritable();
258
+ if (s !== null) {
259
+ const l = s.getWritable();
260
+ l.__next = o.__key, o.__prev = l.__key;
261
+ } else o.__prev = null;
262
+ e.__next = null;
263
+ }
264
+ r.__size--, e.__parent = null;
265
+ }
266
+ }
267
+ function Pe(n) {
268
+ Os();
269
+ const t = n.getLatest(), e = t.__parent, r = Tt(), s = A(), i = r._nodeMap, o = s._dirtyElements;
270
+ e !== null && function(a, c, u) {
271
+ let h = a;
272
+ for (; h !== null; ) {
273
+ if (u.has(h)) return;
274
+ const f = c.get(h);
275
+ if (f === void 0) break;
276
+ u.set(h, !1), h = f.__parent;
277
+ }
278
+ }(e, i, o);
279
+ const l = t.__key;
280
+ s._dirtyType = Gr, S(n) ? o.set(l, !0) : s._dirtyLeaves.add(l);
281
+ }
282
+ function $(n) {
283
+ G();
284
+ const t = A(), e = t._compositionKey;
285
+ if (n !== e) {
286
+ if (t._compositionKey = n, e !== null) {
287
+ const r = j(e);
288
+ r !== null && r.getWritable();
289
+ }
290
+ if (n !== null) {
291
+ const r = j(n);
292
+ r !== null && r.getWritable();
293
+ }
294
+ }
295
+ }
296
+ function mt() {
297
+ return ce() ? null : A()._compositionKey;
298
+ }
299
+ function j(n, t) {
300
+ const e = (t || Tt())._nodeMap.get(n);
301
+ return e === void 0 ? null : e;
302
+ }
303
+ function ss(n, t) {
304
+ const e = Je(n, A());
305
+ return e !== void 0 ? j(e, t) : null;
306
+ }
307
+ function Je(n, t) {
308
+ return n[`__lexicalKey_${t._key}`];
309
+ }
310
+ function zn(n, t) {
311
+ let e = n;
312
+ for (; e != null; ) {
313
+ const r = ss(e, t);
314
+ if (r !== null) return r;
315
+ e = se(e);
316
+ }
317
+ return null;
318
+ }
319
+ function is(n) {
320
+ const t = n._decorators, e = Object.assign({}, t);
321
+ return n._pendingDecorators = e, e;
322
+ }
323
+ function ar(n) {
324
+ return n.read(() => rt().getTextContent());
325
+ }
326
+ function rt() {
327
+ return os(Tt());
328
+ }
329
+ function os(n) {
330
+ return n._nodeMap.get("root");
331
+ }
332
+ function ut(n) {
333
+ G();
334
+ const t = Tt();
335
+ n !== null && (n.dirty = !0, n.setCachedNodes(null)), t._selection = n;
336
+ }
337
+ function Mt(n) {
338
+ const t = A(), e = function(r, s) {
339
+ let i = r;
340
+ for (; i != null; ) {
341
+ const o = Je(i, s);
342
+ if (o !== void 0) return o;
343
+ i = se(i);
344
+ }
345
+ return null;
346
+ }(n, t);
347
+ return e === null ? n === t.getRootElement() ? j("root") : null : j(e);
348
+ }
349
+ function cr(n, t) {
350
+ return t ? n.getTextContentSize() : 0;
351
+ }
352
+ function ls(n) {
353
+ return /[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(n);
354
+ }
355
+ function Wn(n) {
356
+ const t = [];
357
+ let e = n;
358
+ for (; e !== null; ) t.push(e), e = e._parentEditor;
359
+ return t;
360
+ }
361
+ function as() {
362
+ return Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 5);
363
+ }
364
+ function cs(n) {
365
+ return dt(n) ? n.nodeValue : null;
366
+ }
367
+ function Rn(n, t, e) {
368
+ const r = ft(t._window);
369
+ if (r === null) return;
370
+ const s = r.anchorNode;
371
+ let { anchorOffset: i, focusOffset: o } = r;
372
+ if (s !== null) {
373
+ let l = cs(s);
374
+ const a = zn(s);
375
+ if (l !== null && E(a)) {
376
+ if (l === We && e) {
377
+ const c = e.length;
378
+ l = e, i = c, o = c;
379
+ }
380
+ l !== null && Kn(a, l, i, o, n);
381
+ }
382
+ }
383
+ }
384
+ function Kn(n, t, e, r, s) {
385
+ let i = n;
386
+ if (i.isAttached() && (s || !i.isDirty())) {
387
+ const o = i.isComposing();
388
+ let l = t;
389
+ (o || s) && t[t.length - 1] === We && (l = t.slice(0, -1));
390
+ const a = i.getTextContent();
391
+ if (s || l !== a) {
392
+ if (l === "") {
393
+ if ($(null), ze || re || En) i.remove();
394
+ else {
395
+ const _ = A();
396
+ setTimeout(() => {
397
+ _.update(() => {
398
+ i.isAttached() && i.remove();
399
+ });
400
+ }, 20);
401
+ }
402
+ return;
403
+ }
404
+ const c = i.getParent(), u = ae(), h = i.getTextContentSize(), f = mt(), d = i.getKey();
405
+ if (i.isToken() || f !== null && d === f && !o || P(u) && (c !== null && !c.canInsertTextBefore() && u.anchor.offset === 0 || u.anchor.key === n.__key && u.anchor.offset === 0 && !i.canInsertTextBefore() && !o || u.focus.key === n.__key && u.focus.offset === h && !i.canInsertTextAfter() && !o)) return void i.markDirty();
406
+ const g = M();
407
+ if (!P(g) || e === null || r === null) return void i.setTextContent(l);
408
+ if (g.setTextNodeRange(i, e, i, r), i.isSegmented()) {
409
+ const _ = U(i.getTextContent());
410
+ i.replace(_), i = _;
411
+ }
412
+ i.setTextContent(l);
413
+ }
414
+ }
415
+ }
416
+ function Li(n, t) {
417
+ if (t.isSegmented()) return !0;
418
+ if (!n.isCollapsed()) return !1;
419
+ const e = n.anchor.offset, r = t.getParentOrThrow(), s = t.isToken();
420
+ return e === 0 ? !t.canInsertTextBefore() || !r.canInsertTextBefore() && !t.isComposing() || s || function(i) {
421
+ const o = i.getPreviousSibling();
422
+ return (E(o) || S(o) && o.isInline()) && !o.canInsertTextAfter();
423
+ }(t) : e === t.getTextContentSize() && (!t.canInsertTextAfter() || !r.canInsertTextAfter() && !t.isComposing() || s);
424
+ }
425
+ function ur(n) {
426
+ return n === "ArrowLeft";
427
+ }
428
+ function fr(n) {
429
+ return n === "ArrowRight";
430
+ }
431
+ function jt(n, t) {
432
+ return tt ? n : t;
433
+ }
434
+ function dr(n) {
435
+ return n === "Enter";
436
+ }
437
+ function Kt(n) {
438
+ return n === "Backspace";
439
+ }
440
+ function Jt(n) {
441
+ return n === "Delete";
442
+ }
443
+ function hr(n, t, e) {
444
+ return n.toLowerCase() === "a" && jt(t, e);
445
+ }
446
+ function xo(n) {
447
+ const t = rt();
448
+ if (P(n)) {
449
+ const e = n.anchor, r = n.focus, s = e.getNode().getTopLevelElementOrThrow().getParentOrThrow();
450
+ return e.set(s.getKey(), 0, "element"), r.set(s.getKey(), s.getChildrenSize(), "element"), or(n), n;
451
+ }
452
+ {
453
+ const e = t.select(0, t.getChildrenSize());
454
+ return ut(or(e)), e;
455
+ }
456
+ }
457
+ function It(n, t) {
458
+ n.__lexicalClassNameCache === void 0 && (n.__lexicalClassNameCache = {});
459
+ const e = n.__lexicalClassNameCache, r = e[t];
460
+ if (r !== void 0) return r;
461
+ const s = n[t];
462
+ if (typeof s == "string") {
463
+ const i = Ne(s);
464
+ return e[t] = i, i;
465
+ }
466
+ return s;
467
+ }
468
+ function Jn(n, t, e, r, s) {
469
+ if (e.size === 0) return;
470
+ const i = r.__type, o = r.__key, l = t.get(i);
471
+ l === void 0 && T(33, i);
472
+ const a = l.klass;
473
+ let c = n.get(a);
474
+ c === void 0 && (c = /* @__PURE__ */ new Map(), n.set(a, c));
475
+ const u = c.get(o), h = u === "destroyed" && s === "created";
476
+ (u === void 0 || h) && c.set(o, h ? "updated" : s);
477
+ }
478
+ function gr(n, t, e) {
479
+ const r = n.getParent();
480
+ let s = e, i = n;
481
+ return r !== null && (t && e === 0 ? (s = i.getIndexWithinParent(), i = r) : t || e !== i.getChildrenSize() || (s = i.getIndexWithinParent() + 1, i = r)), i.getChildAtIndex(t ? s - 1 : s);
482
+ }
483
+ function _r(n, t) {
484
+ const e = n.offset;
485
+ if (n.type === "element")
486
+ return gr(n.getNode(), t, e);
487
+ {
488
+ const r = n.getNode();
489
+ if (t && e === 0 || !t && e === r.getTextContentSize()) {
490
+ const s = t ? r.getPreviousSibling() : r.getNextSibling();
491
+ return s === null ? gr(r.getParentOrThrow(), t, r.getIndexWithinParent() + (t ? 0 : 1)) : s;
492
+ }
493
+ }
494
+ return null;
495
+ }
496
+ function us(n) {
497
+ const t = $e(n).event, e = t && t.inputType;
498
+ return e === "insertFromPaste" || e === "insertFromPasteAsQuotation";
499
+ }
500
+ function w(n, t, e) {
501
+ return Ms(n, t, e);
502
+ }
503
+ function Ue(n) {
504
+ return !Z(n) && !n.isLastChild() && !n.isInline();
505
+ }
506
+ function Oe(n, t) {
507
+ const e = n._keyToDOMMap.get(t);
508
+ return e === void 0 && T(75, t), e;
509
+ }
510
+ function se(n) {
511
+ const t = n.assignedSlot || n.parentElement;
512
+ return Bi(t) ? t.host : t;
513
+ }
514
+ function fs(n) {
515
+ return Oi(n) ? n : X(n) ? n.ownerDocument : null;
516
+ }
517
+ function qt(n, t) {
518
+ let e = n.getParent();
519
+ for (; e !== null; ) {
520
+ if (e.is(t)) return !0;
521
+ e = e.getParent();
522
+ }
523
+ return !1;
524
+ }
525
+ function Un(n) {
526
+ const t = fs(n);
527
+ return t ? t.defaultView : null;
528
+ }
529
+ function $e(n) {
530
+ const t = n._window;
531
+ return t === null && T(78), t;
532
+ }
533
+ function Di(n) {
534
+ let t = n.getParentOrThrow();
535
+ for (; t !== null; ) {
536
+ if (Ft(t)) return t;
537
+ t = t.getParentOrThrow();
538
+ }
539
+ return t;
540
+ }
541
+ function Ft(n) {
542
+ return Z(n) || S(n) && n.isShadowRoot();
543
+ }
544
+ function Mi(n) {
545
+ const t = n.constructor.clone(n);
546
+ return rs(t, null), t;
547
+ }
548
+ function je(n) {
549
+ const t = A(), e = n.constructor.getType(), r = t._nodes.get(e);
550
+ r === void 0 && T(200, n.constructor.name, e);
551
+ const { replace: s, replaceWithKlass: i } = r;
552
+ if (s !== null) {
553
+ const o = s(n), l = o.constructor;
554
+ return i !== null ? o instanceof i || T(201, i.name, i.getType(), l.name, l.getType(), n.constructor.name, e) : o instanceof n.constructor && l !== n.constructor || T(202, l.name, l.getType(), n.constructor.name, e), o.__key === n.__key && T(203, n.constructor.name, e, l.name, l.getType()), o;
555
+ }
556
+ return n;
557
+ }
558
+ function sn(n, t) {
559
+ !Z(n.getParent()) || S(t) || I(t) || T(99);
560
+ }
561
+ function on(n) {
562
+ return (I(n) || S(n) && !n.canBeEmpty()) && !n.isInline();
563
+ }
564
+ function $n(n, t, e) {
565
+ e.style.removeProperty("caret-color"), t._blockCursorElement = null;
566
+ const r = n.parentElement;
567
+ r !== null && r.removeChild(n);
568
+ }
569
+ function Ii(n, t, e) {
570
+ let r = n._blockCursorElement;
571
+ if (P(e) && e.isCollapsed() && e.anchor.type === "element" && t.contains(document.activeElement)) {
572
+ const s = e.anchor, i = s.getNode(), o = s.offset;
573
+ let l = !1, a = null;
574
+ if (o === i.getChildrenSize())
575
+ on(i.getChildAtIndex(o - 1)) && (l = !0);
576
+ else {
577
+ const c = i.getChildAtIndex(o);
578
+ if (c !== null && on(c)) {
579
+ const u = c.getPreviousSibling();
580
+ (u === null || on(u)) && (l = !0, a = n.getElementByKey(c.__key));
581
+ }
582
+ }
583
+ if (l) {
584
+ const c = n.getElementByKey(i.__key);
585
+ return r === null && (n._blockCursorElement = r = function(u) {
586
+ const h = u.theme, f = document.createElement("div");
587
+ f.contentEditable = "false", f.setAttribute("data-lexical-cursor", "true");
588
+ let d = h.blockCursor;
589
+ if (d !== void 0) {
590
+ if (typeof d == "string") {
591
+ const g = Ne(d);
592
+ d = h.blockCursor = g;
593
+ }
594
+ d !== void 0 && f.classList.add(...d);
595
+ }
596
+ return f;
597
+ }(n._config)), t.style.caretColor = "transparent", void (a === null ? c.appendChild(r) : c.insertBefore(r, a));
598
+ }
599
+ }
600
+ r !== null && $n(r, n, t);
601
+ }
602
+ function ft(n) {
603
+ return st ? (n || window).getSelection() : null;
604
+ }
605
+ function Ai(n) {
606
+ const t = Un(n);
607
+ return t ? t.getSelection() : null;
608
+ }
609
+ function vo(n, t) {
610
+ let e = n.getChildAtIndex(t);
611
+ e == null && (e = n), Ft(n) && T(102);
612
+ const r = (o) => {
613
+ const l = o.getParentOrThrow(), a = Ft(l), c = o !== e || a ? Mi(o) : o;
614
+ if (a) return S(o) && S(c) || T(133), o.insertAfter(c), [o, c, c];
615
+ {
616
+ const [u, h, f] = r(l), d = o.getNextSiblings();
617
+ return f.append(c, ...d), [u, h, c];
618
+ }
619
+ }, [s, i] = r(e);
620
+ return [s, i];
621
+ }
622
+ function So(n) {
623
+ return X(n) && n.tagName === "A";
624
+ }
625
+ function X(n) {
626
+ return ie(n) && n.nodeType === ai;
627
+ }
628
+ function ie(n) {
629
+ return typeof n == "object" && n !== null && "nodeType" in n && typeof n.nodeType == "number";
630
+ }
631
+ function Bi(n) {
632
+ return ie(n) && n.nodeType === fi;
633
+ }
634
+ function zi(n) {
635
+ const t = new RegExp(/^(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|#text)$/, "i");
636
+ return n.nodeName.match(t) !== null;
637
+ }
638
+ function pr(n) {
639
+ const t = new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/, "i");
640
+ return n.nodeName.match(t) !== null;
641
+ }
642
+ function pt(n) {
643
+ if (I(n) && !n.isInline()) return !0;
644
+ if (!S(n) || Ft(n)) return !1;
645
+ const t = n.getFirstChild(), e = t === null || Bt(t) || E(t) || t.isInline();
646
+ return !n.isInline() && n.canBeEmpty() !== !1 && e;
647
+ }
648
+ function Ut(n, t) {
649
+ let e = n;
650
+ for (; e !== null && e.getParent() !== null && !t(e); ) e = e.getParentOrThrow();
651
+ return t(e) ? e : null;
652
+ }
653
+ function Co() {
654
+ return A();
655
+ }
656
+ const yr = /* @__PURE__ */ new WeakMap(), Wi = /* @__PURE__ */ new Map();
657
+ function mr(n) {
658
+ if (!n._readOnly && n.isEmpty()) return Wi;
659
+ n._readOnly || T(192);
660
+ let t = yr.get(n);
661
+ return t || (t = function(e) {
662
+ const r = /* @__PURE__ */ new Map();
663
+ for (const [s, i] of e._nodeMap) {
664
+ const o = i.__type;
665
+ let l = r.get(o);
666
+ l || (l = /* @__PURE__ */ new Map(), r.set(o, l)), l.set(s, i);
667
+ }
668
+ return r;
669
+ }(n), yr.set(n, t)), t;
670
+ }
671
+ function Ri(n) {
672
+ const t = n.constructor.clone(n);
673
+ return t.afterCloneFrom(n), t;
674
+ }
675
+ function Ki(n, t) {
676
+ const e = (parseInt(n.style.paddingInlineStart, 10) || 0) / 40;
677
+ t.setIndent(e);
678
+ }
679
+ function To(n) {
680
+ n.__lexicalUnmanaged = !0;
681
+ }
682
+ function Ji(n) {
683
+ return n.__lexicalUnmanaged === !0;
684
+ }
685
+ function ds(n, t, e, r, s, i) {
686
+ let o = n.getFirstChild();
687
+ for (; o !== null; ) {
688
+ const l = o.__key;
689
+ o.__parent === t && (S(o) && ds(o, l, e, r, s, i), e.has(l) || i.delete(l), s.push(l)), o = o.getNextSibling();
690
+ }
691
+ }
692
+ let Ct, q, Zt, Ve, pn, yn, Pt, nt, mn, te, W = "", H = "", it = null, et = "", at = "", hs = !1, ee = !1, xe = null;
693
+ function Le(n, t) {
694
+ const e = Pt.get(n);
695
+ if (t !== null) {
696
+ const r = Sn(n);
697
+ r.parentNode === t && t.removeChild(r);
698
+ }
699
+ if (nt.has(n) || q._keyToDOMMap.delete(n), S(e)) {
700
+ const r = Me(e, Pt);
701
+ xn(r, 0, r.length - 1, null);
702
+ }
703
+ e !== void 0 && Jn(te, Zt, Ve, e, "destroyed");
704
+ }
705
+ function xn(n, t, e, r) {
706
+ let s = t;
707
+ for (; s <= e; ++s) {
708
+ const i = n[s];
709
+ i !== void 0 && Le(i, r);
710
+ }
711
+ }
712
+ function kt(n, t) {
713
+ n.setProperty("text-align", t);
714
+ }
715
+ const Ui = "40px";
716
+ function gs(n, t) {
717
+ const e = Ct.theme.indent;
718
+ if (typeof e == "string") {
719
+ const s = n.classList.contains(e);
720
+ t > 0 && !s ? n.classList.add(e) : t < 1 && s && n.classList.remove(e);
721
+ }
722
+ const r = getComputedStyle(n).getPropertyValue("--lexical-indent-base-value") || Ui;
723
+ n.style.setProperty("padding-inline-start", t === 0 ? "" : `calc(${t} * ${r})`);
724
+ }
725
+ function _s(n, t) {
726
+ const e = n.style;
727
+ t === 0 ? kt(e, "") : t === Pn ? kt(e, "left") : t === On ? kt(e, "center") : t === Ln ? kt(e, "right") : t === Dn ? kt(e, "justify") : t === Mn ? kt(e, "start") : t === In && kt(e, "end");
728
+ }
729
+ function De(n, t) {
730
+ const e = nt.get(n);
731
+ e === void 0 && T(60);
732
+ const r = e.createDOM(Ct, q);
733
+ if (function(s, i, o) {
734
+ const l = o._keyToDOMMap;
735
+ (function(a, c, u) {
736
+ a[`__lexicalKey_${c._key}`] = u;
737
+ })(i, o, s), l.set(s, i);
738
+ }(n, r, q), E(e) ? r.setAttribute("data-lexical-text", "true") : I(e) && r.setAttribute("data-lexical-decorator", "true"), S(e)) {
739
+ const s = e.__indent, i = e.__size;
740
+ if (s !== 0 && gs(r, s), i !== 0) {
741
+ const l = i - 1;
742
+ (function(a, c, u, h) {
743
+ const f = H;
744
+ H = "", vn(a, u, 0, c, u.getDOMSlot(h)), ys(u, h), H = f;
745
+ })(Me(e, nt), l, e, r);
746
+ }
747
+ const o = e.__format;
748
+ o !== 0 && _s(r, o), e.isInline() || ps(null, e, r), Ue(e) && (W += ct, at += ct);
749
+ } else {
750
+ const s = e.getTextContent();
751
+ if (I(e)) {
752
+ const i = e.decorate(q, Ct);
753
+ i !== null && ms(n, i), r.contentEditable = "false";
754
+ } else E(e) && (e.isDirectionless() || (H += s));
755
+ W += s, at += s;
756
+ }
757
+ return t !== null && t.insertChild(r), Jn(te, Zt, Ve, e, "created"), r;
758
+ }
759
+ function vn(n, t, e, r, s) {
760
+ const i = W;
761
+ W = "";
762
+ let o = e;
763
+ for (; o <= r; ++o) {
764
+ De(n[o], s);
765
+ const l = nt.get(n[o]);
766
+ l !== null && E(l) && (it === null && (it = l.getFormat()), et === "" && (et = l.getStyle()));
767
+ }
768
+ Ue(t) && (W += ct), s.element.__lexicalTextContent = W, W = i + W;
769
+ }
770
+ function xr(n, t) {
771
+ if (n) {
772
+ const e = n.__last;
773
+ if (e) {
774
+ const r = t.get(e);
775
+ if (r) return Bt(r) ? "line-break" : I(r) && r.isInline() ? "decorator" : null;
776
+ }
777
+ return "empty";
778
+ }
779
+ return null;
780
+ }
781
+ function ps(n, t, e) {
782
+ const r = xr(n, Pt), s = xr(t, nt);
783
+ r !== s && t.getDOMSlot(e).setManagedLineBreak(s);
784
+ }
785
+ function ys(n, t) {
786
+ const e = t.__lexicalDirTextContent || "", r = t.__lexicalDir || "";
787
+ if (e !== H || r !== xe) {
788
+ const i = H === "", o = i ? xe : (s = H, yi.test(s) ? "rtl" : mi.test(s) ? "ltr" : null);
789
+ if (o !== r) {
790
+ const l = t.classList, a = Ct.theme;
791
+ let c = r !== null ? a[r] : void 0, u = o !== null ? a[o] : void 0;
792
+ if (c !== void 0) {
793
+ if (typeof c == "string") {
794
+ const h = Ne(c);
795
+ c = a[r] = h;
796
+ }
797
+ l.remove(...c);
798
+ }
799
+ if (o === null || i && o === "ltr") t.removeAttribute("dir");
800
+ else {
801
+ if (u !== void 0) {
802
+ if (typeof u == "string") {
803
+ const h = Ne(u);
804
+ u = a[o] = h;
805
+ }
806
+ u !== void 0 && l.add(...u);
807
+ }
808
+ t.dir = o;
809
+ }
810
+ ee || (n.getWritable().__dir = o);
811
+ }
812
+ xe = o, t.__lexicalDirTextContent = H, t.__lexicalDir = o;
813
+ }
814
+ var s;
815
+ }
816
+ function $i(n, t, e) {
817
+ const r = H;
818
+ var s;
819
+ H = "", it = null, et = "", function(i, o, l) {
820
+ const a = W, c = i.__size, u = o.__size;
821
+ W = "";
822
+ const h = l.element;
823
+ if (c === 1 && u === 1) {
824
+ const f = i.__first, d = o.__first;
825
+ if (f === d) Vt(f, h);
826
+ else {
827
+ const _ = Sn(f), p = De(d, null);
828
+ try {
829
+ h.replaceChild(p, _);
830
+ } catch (m) {
831
+ if (typeof m == "object" && m != null) {
832
+ const y = `${m.toString()} Parent: ${h.tagName}, new child: {tag: ${p.tagName} key: ${d}}, old child: {tag: ${_.tagName}, key: ${f}}.`;
833
+ throw new Error(y);
834
+ }
835
+ throw m;
836
+ }
837
+ Le(f, null);
838
+ }
839
+ const g = nt.get(d);
840
+ E(g) && (it === null && (it = g.getFormat()), et === "" && (et = g.getStyle()));
841
+ } else {
842
+ const f = Me(i, Pt), d = Me(o, nt);
843
+ if (f.length !== c && T(227), d.length !== u && T(228), c === 0) u !== 0 && vn(d, o, 0, u - 1, l);
844
+ else if (u === 0) {
845
+ if (c !== 0) {
846
+ const g = l.after == null && l.before == null && l.element.__lexicalLineBreak == null;
847
+ xn(f, 0, c - 1, g ? null : h), g && (h.textContent = "");
848
+ }
849
+ } else (function(g, _, p, m, y, x) {
850
+ const b = m - 1, k = y - 1;
851
+ let v, F, C = x.getFirstChild(), N = 0, O = 0;
852
+ for (; N <= b && O <= k; ) {
853
+ const L = _[N], R = p[O];
854
+ if (L === R) C = ln(Vt(R, x.element)), N++, O++;
855
+ else {
856
+ v === void 0 && (v = new Set(_)), F === void 0 && (F = new Set(p));
857
+ const ht = F.has(L), Lt = v.has(R);
858
+ if (ht) if (Lt) {
859
+ const de = Oe(q, R);
860
+ de === C ? C = ln(Vt(R, x.element)) : (x.withBefore(C).insertChild(de), Vt(R, x.element)), N++, O++;
861
+ } else De(R, x.withBefore(C)), O++;
862
+ else C = ln(Sn(L)), Le(L, x.element), N++;
863
+ }
864
+ const z = nt.get(R);
865
+ z !== null && E(z) && (it === null && (it = z.getFormat()), et === "" && (et = z.getStyle()));
866
+ }
867
+ const D = N > b, B = O > k;
868
+ if (D && !B) {
869
+ const L = p[k + 1], R = L === void 0 ? null : q.getElementByKey(L);
870
+ vn(p, g, O, k, x.withBefore(R));
871
+ } else B && !D && xn(_, N, b, x.element);
872
+ })(o, f, d, c, u, l);
873
+ }
874
+ Ue(o) && (W += ct), h.__lexicalTextContent = W, W = a + W;
875
+ }(n, t, t.getDOMSlot(e)), ys(t, e), s = t, it == null || it === s.__textFormat || ee || (s.setTextFormat(it), s.setTextStyle(et)), function(i) {
876
+ et === "" || et === i.__textStyle || ee || i.setTextStyle(et);
877
+ }(t), H = r;
878
+ }
879
+ function Me(n, t) {
880
+ const e = [];
881
+ let r = n.__first;
882
+ for (; r !== null; ) {
883
+ const s = t.get(r);
884
+ s === void 0 && T(101), e.push(r), r = s.__next;
885
+ }
886
+ return e;
887
+ }
888
+ function Vt(n, t) {
889
+ const e = Pt.get(n);
890
+ let r = nt.get(n);
891
+ e !== void 0 && r !== void 0 || T(61);
892
+ const s = hs || yn.has(n) || pn.has(n), i = Oe(q, n);
893
+ if (e === r && !s) {
894
+ if (S(e)) {
895
+ const o = i.__lexicalTextContent;
896
+ o !== void 0 && (W += o, at += o);
897
+ const l = i.__lexicalDirTextContent;
898
+ l !== void 0 && (H += l);
899
+ } else {
900
+ const o = e.getTextContent();
901
+ E(e) && !e.isDirectionless() && (H += o), at += o, W += o;
902
+ }
903
+ return i;
904
+ }
905
+ if (e !== r && s && Jn(te, Zt, Ve, r, "updated"), r.updateDOM(e, i, Ct)) {
906
+ const o = De(n, null);
907
+ return t === null && T(62), t.replaceChild(o, i), Le(n, null), o;
908
+ }
909
+ if (S(e) && S(r)) {
910
+ const o = r.__indent;
911
+ o !== e.__indent && gs(i, o);
912
+ const l = r.__format;
913
+ l !== e.__format && _s(i, l), s && ($i(e, r, i), Z(r) || r.isInline() || ps(e, r, i)), Ue(r) && (W += ct, at += ct);
914
+ } else {
915
+ const o = r.getTextContent();
916
+ if (I(r)) {
917
+ const l = r.decorate(q, Ct);
918
+ l !== null && ms(n, l);
919
+ } else E(r) && !r.isDirectionless() && (H += o);
920
+ W += o, at += o;
921
+ }
922
+ if (!ee && Z(r) && r.__cachedText !== at) {
923
+ const o = r.getWritable();
924
+ o.__cachedText = at, r = o;
925
+ }
926
+ return i;
927
+ }
928
+ function ms(n, t) {
929
+ let e = q._pendingDecorators;
930
+ const r = q._decorators;
931
+ if (e === null) {
932
+ if (r[n] === t) return;
933
+ e = is(q);
934
+ }
935
+ e[n] = t;
936
+ }
937
+ function ln(n) {
938
+ let t = n.nextSibling;
939
+ return t !== null && t === q._blockCursorElement && (t = t.nextSibling), t;
940
+ }
941
+ function ji(n, t, e, r, s, i) {
942
+ W = "", at = "", H = "", hs = r === zt, xe = null, q = e, Ct = e._config, Zt = e._nodes, Ve = q._listeners.mutation, pn = s, yn = i, Pt = n._nodeMap, nt = t._nodeMap, ee = t._readOnly, mn = new Map(e._keyToDOMMap);
943
+ const o = /* @__PURE__ */ new Map();
944
+ return te = o, Vt("root", null), q = void 0, Zt = void 0, pn = void 0, yn = void 0, Pt = void 0, nt = void 0, Ct = void 0, mn = void 0, te = void 0, o;
945
+ }
946
+ function Sn(n) {
947
+ const t = mn.get(n);
948
+ return t === void 0 && T(75, n), t;
949
+ }
950
+ const lt = Object.freeze({}), Cn = 30, Tn = [["keydown", function(n, t) {
951
+ if (Gt = n.timeStamp, xs = n.key, t.isComposing()) return;
952
+ const { key: e, shiftKey: r, ctrlKey: s, metaKey: i, altKey: o } = n;
953
+ if (!w(t, Rs, n) && e != null) {
954
+ if (function(l, a, c, u) {
955
+ return fr(l) && !a && !u && !c;
956
+ }(e, s, o, i)) w(t, Ks, n);
957
+ else if (function(l, a, c, u, h) {
958
+ return fr(l) && !u && !c && (a || h);
959
+ }(e, s, r, o, i)) w(t, Js, n);
960
+ else if (function(l, a, c, u) {
961
+ return ur(l) && !a && !u && !c;
962
+ }(e, s, o, i)) w(t, Us, n);
963
+ else if (function(l, a, c, u, h) {
964
+ return ur(l) && !u && !c && (a || h);
965
+ }(e, s, r, o, i)) w(t, $s, n);
966
+ else if (/* @__PURE__ */ function(l, a, c) {
967
+ return /* @__PURE__ */ function(u) {
968
+ return u === "ArrowUp";
969
+ }(l) && !a && !c;
970
+ }(e, s, i)) w(t, js, n);
971
+ else if (/* @__PURE__ */ function(l, a, c) {
972
+ return /* @__PURE__ */ function(u) {
973
+ return u === "ArrowDown";
974
+ }(l) && !a && !c;
975
+ }(e, s, i)) w(t, Vs, n);
976
+ else if (function(l, a) {
977
+ return dr(l) && a;
978
+ }(e, r)) Qt = !0, w(t, gn, n);
979
+ else if (/* @__PURE__ */ function(l) {
980
+ return l === " ";
981
+ }(e)) w(t, Hs, n);
982
+ else if (function(l, a) {
983
+ return tt && a && l.toLowerCase() === "o";
984
+ }(e, s)) n.preventDefault(), Qt = !0, w(t, me, !0);
985
+ else if (function(l, a) {
986
+ return dr(l) && !a;
987
+ }(e, r)) Qt = !1, w(t, gn, n);
988
+ else if (function(l, a, c, u) {
989
+ return tt ? !a && !c && (Kt(l) || l.toLowerCase() === "h" && u) : !(u || a || c) && Kt(l);
990
+ }(e, o, i, s)) Kt(e) ? w(t, qs, n) : (n.preventDefault(), w(t, Se, !0));
991
+ else if (/* @__PURE__ */ function(l) {
992
+ return l === "Escape";
993
+ }(e)) w(t, Gs, n);
994
+ else if (function(l, a, c, u, h) {
995
+ return tt ? !(c || u || h) && (Jt(l) || l.toLowerCase() === "d" && a) : !(a || u || h) && Jt(l);
996
+ }(e, s, r, o, i)) Jt(e) ? w(t, Qs, n) : (n.preventDefault(), w(t, Se, !1));
997
+ else if (function(l, a, c) {
998
+ return Kt(l) && (tt ? a : c);
999
+ }(e, o, s)) n.preventDefault(), w(t, Ce, !0);
1000
+ else if (function(l, a, c) {
1001
+ return Jt(l) && (tt ? a : c);
1002
+ }(e, o, s)) n.preventDefault(), w(t, Ce, !1);
1003
+ else if (function(l, a) {
1004
+ return tt && a && Kt(l);
1005
+ }(e, i)) n.preventDefault(), w(t, Te, !0);
1006
+ else if (function(l, a) {
1007
+ return tt && a && Jt(l);
1008
+ }(e, i)) n.preventDefault(), w(t, Te, !1);
1009
+ else if (function(l, a, c, u) {
1010
+ return l.toLowerCase() === "b" && !a && jt(c, u);
1011
+ }(e, o, i, s)) n.preventDefault(), w(t, wt, "bold");
1012
+ else if (function(l, a, c, u) {
1013
+ return l.toLowerCase() === "u" && !a && jt(c, u);
1014
+ }(e, o, i, s)) n.preventDefault(), w(t, wt, "underline");
1015
+ else if (function(l, a, c, u) {
1016
+ return l.toLowerCase() === "i" && !a && jt(c, u);
1017
+ }(e, o, i, s)) n.preventDefault(), w(t, wt, "italic");
1018
+ else if (/* @__PURE__ */ function(l, a, c, u) {
1019
+ return l === "Tab" && !a && !c && !u;
1020
+ }(e, o, s, i)) w(t, Xs, n);
1021
+ else if (function(l, a, c, u) {
1022
+ return l.toLowerCase() === "z" && !a && jt(c, u);
1023
+ }(e, r, i, s)) n.preventDefault(), w(t, $r, void 0);
1024
+ else if (function(l, a, c, u) {
1025
+ return tt ? l.toLowerCase() === "z" && c && a : l.toLowerCase() === "y" && u || l.toLowerCase() === "z" && u && a;
1026
+ }(e, r, i, s)) n.preventDefault(), w(t, jr, void 0);
1027
+ else {
1028
+ const l = t._editorState._selection;
1029
+ l === null || P(l) ? !vt && hr(e, i, s) && (n.preventDefault(), w(t, er, n)) : function(a, c, u, h) {
1030
+ return !c && a.toLowerCase() === "c" && (tt ? u : h);
1031
+ }(e, r, i, s) ? (n.preventDefault(), w(t, Vr, n)) : function(a, c, u, h) {
1032
+ return !c && a.toLowerCase() === "x" && (tt ? u : h);
1033
+ }(e, r, i, s) ? (n.preventDefault(), w(t, Hr, n)) : hr(e, i, s) && (n.preventDefault(), w(t, er, n));
1034
+ }
1035
+ /* @__PURE__ */ (function(l, a, c, u) {
1036
+ return l || a || c || u;
1037
+ })(s, r, o, i) && w(t, si, n);
1038
+ }
1039
+ }], ["pointerdown", function(n, t) {
1040
+ const e = n.target, r = n.pointerType;
1041
+ ie(e) && r !== "touch" && n.button === 0 && Y(t, () => {
1042
+ I(zn(e)) || (bn = !0);
1043
+ });
1044
+ }], ["compositionstart", function(n, t) {
1045
+ Y(t, () => {
1046
+ const e = M();
1047
+ if (P(e) && !t.isComposing()) {
1048
+ const r = e.anchor, s = e.anchor.getNode();
1049
+ $(r.key), (n.timeStamp < Gt + Cn || r.type === "element" || !e.isCollapsed() || s.getFormat() !== e.format || E(s) && s.getStyle() !== e.style) && w(t, Ht, pi);
1050
+ }
1051
+ });
1052
+ }], ["compositionend", function(n, t) {
1053
+ vt ? $t = !0 : Y(t, () => {
1054
+ an(t, n.data);
1055
+ });
1056
+ }], ["input", function(n, t) {
1057
+ n.stopPropagation(), Y(t, () => {
1058
+ const e = M(), r = n.data, s = Ts(n);
1059
+ if (r != null && P(e) && Cs(e, s, r, n.timeStamp, !1)) {
1060
+ $t && (an(t, r), $t = !1);
1061
+ const i = e.anchor.getNode(), o = ft(t._window);
1062
+ if (o === null) return;
1063
+ const l = e.isBackward(), a = l ? e.anchor.offset : e.focus.offset, c = l ? e.focus.offset : e.anchor.offset;
1064
+ ke && !e.isCollapsed() && E(i) && o.anchorNode !== null && i.getTextContent().slice(0, a) + r + i.getTextContent().slice(a + c) === cs(o.anchorNode) || w(t, Ht, r);
1065
+ const u = r.length;
1066
+ vt && u > 1 && n.inputType === "insertCompositionText" && !t.isComposing() && (e.anchor.offset -= u), ze || re || En || !t.isComposing() || (Gt = 0, $(null));
1067
+ } else
1068
+ Rn(!1, t, r !== null ? r : void 0), $t && (an(t, r || void 0), $t = !1);
1069
+ G(), Zr(A());
1070
+ }), Dt = null;
1071
+ }], ["click", function(n, t) {
1072
+ Y(t, () => {
1073
+ const e = M(), r = ft(t._window), s = ae();
1074
+ if (r) {
1075
+ if (P(e)) {
1076
+ const i = e.anchor, o = i.getNode();
1077
+ i.type === "element" && i.offset === 0 && e.isCollapsed() && !Z(o) && rt().getChildrenSize() === 1 && o.getTopLevelElementOrThrow().isEmpty() && s !== null && e.is(s) ? (r.removeAllRanges(), e.dirty = !0) : n.detail === 3 && !e.isCollapsed() && o !== e.focus.getNode() && (S(o) ? o.select(0) : o.getParentOrThrow().select(0));
1078
+ } else if (n.pointerType === "touch") {
1079
+ const i = r.anchorNode;
1080
+ (X(i) || dt(i)) && ut(Ge(s, r, t, n));
1081
+ }
1082
+ }
1083
+ w(t, Ws, n);
1084
+ });
1085
+ }], ["cut", lt], ["copy", lt], ["dragstart", lt], ["dragover", lt], ["dragend", lt], ["paste", lt], ["focus", lt], ["blur", lt], ["drop", lt]];
1086
+ ke && Tn.push(["beforeinput", (n, t) => function(e, r) {
1087
+ const s = e.inputType, i = Ts(e);
1088
+ s === "deleteCompositionText" || vt && us(r) || s !== "insertCompositionText" && Y(r, () => {
1089
+ const o = M();
1090
+ if (s === "deleteContentBackward") {
1091
+ if (o === null) {
1092
+ const d = ae();
1093
+ if (!P(d)) return;
1094
+ ut(d.clone());
1095
+ }
1096
+ if (P(o)) {
1097
+ const d = o.anchor.key === o.focus.key;
1098
+ if (l = e.timeStamp, xs === "MediaLast" && l < Gt + Cn && r.isComposing() && d) {
1099
+ if ($(null), Gt = 0, setTimeout(() => {
1100
+ Y(r, () => {
1101
+ $(null);
1102
+ });
1103
+ }, Cn), P(o)) {
1104
+ const g = o.anchor.getNode();
1105
+ g.markDirty(), o.format = g.getFormat(), E(g) || T(142), o.style = g.getStyle();
1106
+ }
1107
+ } else {
1108
+ $(null), e.preventDefault();
1109
+ const g = o.anchor.getNode(), _ = g.getTextContent(), p = g.canInsertTextAfter(), m = o.anchor.offset === 0 && o.focus.offset === _.length;
1110
+ li && d && !m && p || w(r, Se, !0);
1111
+ }
1112
+ return;
1113
+ }
1114
+ }
1115
+ var l;
1116
+ if (!P(o)) return;
1117
+ const a = e.data;
1118
+ Dt !== null && Rn(!1, r, Dt), o.dirty && Dt === null || !o.isCollapsed() || Z(o.anchor.getNode()) || i === null || o.applyDOMRange(i), Dt = null;
1119
+ const c = o.anchor, u = o.focus, h = c.getNode(), f = u.getNode();
1120
+ if (s !== "insertText" && s !== "insertTranspose") switch (e.preventDefault(), s) {
1121
+ case "insertFromYank":
1122
+ case "insertFromDrop":
1123
+ case "insertReplacementText":
1124
+ w(r, Ht, e);
1125
+ break;
1126
+ case "insertFromComposition":
1127
+ $(null), w(r, Ht, e);
1128
+ break;
1129
+ case "insertLineBreak":
1130
+ $(null), w(r, me, !1);
1131
+ break;
1132
+ case "insertParagraph":
1133
+ $(null), Qt && !re ? (Qt = !1, w(r, me, !1)) : w(r, Zn, void 0);
1134
+ break;
1135
+ case "insertFromPaste":
1136
+ case "insertFromPasteAsQuotation":
1137
+ w(r, Ur, e);
1138
+ break;
1139
+ case "deleteByComposition":
1140
+ (function(d, g) {
1141
+ return d !== g || S(d) || S(g) || !d.isToken() || !g.isToken();
1142
+ })(h, f) && w(r, tr, e);
1143
+ break;
1144
+ case "deleteByDrag":
1145
+ case "deleteByCut":
1146
+ w(r, tr, e);
1147
+ break;
1148
+ case "deleteContent":
1149
+ w(r, Se, !1);
1150
+ break;
1151
+ case "deleteWordBackward":
1152
+ w(r, Ce, !0);
1153
+ break;
1154
+ case "deleteWordForward":
1155
+ w(r, Ce, !1);
1156
+ break;
1157
+ case "deleteHardLineBackward":
1158
+ case "deleteSoftLineBackward":
1159
+ w(r, Te, !0);
1160
+ break;
1161
+ case "deleteContentForward":
1162
+ case "deleteHardLineForward":
1163
+ case "deleteSoftLineForward":
1164
+ w(r, Te, !1);
1165
+ break;
1166
+ case "formatStrikeThrough":
1167
+ w(r, wt, "strikethrough");
1168
+ break;
1169
+ case "formatBold":
1170
+ w(r, wt, "bold");
1171
+ break;
1172
+ case "formatItalic":
1173
+ w(r, wt, "italic");
1174
+ break;
1175
+ case "formatUnderline":
1176
+ w(r, wt, "underline");
1177
+ break;
1178
+ case "historyUndo":
1179
+ w(r, $r, void 0);
1180
+ break;
1181
+ case "historyRedo":
1182
+ w(r, jr, void 0);
1183
+ }
1184
+ else {
1185
+ if (a === `
1186
+ `) e.preventDefault(), w(r, me, !1);
1187
+ else if (a === ct) e.preventDefault(), w(r, Zn, void 0);
1188
+ else if (a == null && e.dataTransfer) {
1189
+ const d = e.dataTransfer.getData("text/plain");
1190
+ e.preventDefault(), o.insertRawText(d);
1191
+ } else a != null && Cs(o, i, a, e.timeStamp, !0) ? (e.preventDefault(), w(r, Ht, a)) : Dt = a;
1192
+ vs = e.timeStamp;
1193
+ }
1194
+ });
1195
+ }(n, t)]);
1196
+ let Gt = 0, xs = null, vs = 0, Dt = null;
1197
+ const Ie = /* @__PURE__ */ new WeakMap();
1198
+ let kn = !1, bn = !1, Qt = !1, $t = !1, Ss = [0, "", 0, "root", 0];
1199
+ function Cs(n, t, e, r, s) {
1200
+ const i = n.anchor, o = n.focus, l = i.getNode(), a = A(), c = ft(a._window), u = c !== null ? c.anchorNode : null, h = i.key, f = a.getElementByKey(h), d = e.length;
1201
+ return h !== o.key || !E(l) || (!s && (!ke || vs < r + 50) || l.isDirty() && d < 2 || ls(e)) && i.offset !== o.offset && !l.isComposing() || bt(l) || l.isDirty() && d > 1 || (s || !ke) && f !== null && !l.isComposing() && u !== Ee(f) || c !== null && t !== null && (!t.collapsed || t.startContainer !== c.anchorNode || t.startOffset !== c.anchorOffset) || l.getFormat() !== n.format || l.getStyle() !== n.style || Li(n, l);
1202
+ }
1203
+ function vr(n, t) {
1204
+ return dt(n) && n.nodeValue !== null && t !== 0 && t !== n.nodeValue.length;
1205
+ }
1206
+ function Sr(n, t, e) {
1207
+ const { anchorNode: r, anchorOffset: s, focusNode: i, focusOffset: o } = n;
1208
+ kn && (kn = !1, vr(r, s) && vr(i, o)) || Y(t, () => {
1209
+ if (!e) return void ut(null);
1210
+ if (!Re(t, r, i)) return;
1211
+ const l = M();
1212
+ if (P(l)) {
1213
+ const a = l.anchor, c = a.getNode();
1214
+ if (l.isCollapsed()) {
1215
+ n.type === "Range" && n.anchorNode === n.focusNode && (l.dirty = !0);
1216
+ const u = $e(t).event, h = u ? u.timeStamp : performance.now(), [f, d, g, _, p] = Ss, m = rt(), y = t.isComposing() === !1 && m.getTextContent() === "";
1217
+ if (h < p + 200 && a.offset === g && a.key === _) l.format = f, l.style = d;
1218
+ else if (a.type === "text") E(c) || T(141), l.format = c.getFormat(), l.style = c.getStyle();
1219
+ else if (a.type === "element" && !y) {
1220
+ S(c) || T(259);
1221
+ const x = a.getNode();
1222
+ l.style = "", x.isEmpty() ? (l.format = x.getTextFormat(), l.style = x.getTextStyle()) : l.format = 0;
1223
+ }
1224
+ } else {
1225
+ const u = a.key, h = l.focus.key, f = l.getNodes(), d = f.length, g = l.isBackward(), _ = g ? o : s, p = g ? s : o, m = g ? h : u, y = g ? u : h;
1226
+ let x = _i, b = !1;
1227
+ for (let k = 0; k < d; k++) {
1228
+ const v = f[k], F = v.getTextContentSize();
1229
+ if (E(v) && F !== 0 && !(k === 0 && v.__key === m && _ === F || k === d - 1 && v.__key === y && p === 0) && (b = !0, x &= v.getFormat(), x === 0)) break;
1230
+ }
1231
+ l.format = b ? x : 0;
1232
+ }
1233
+ }
1234
+ w(t, Nn, void 0);
1235
+ });
1236
+ }
1237
+ function Ts(n) {
1238
+ if (!n.getTargetRanges) return null;
1239
+ const t = n.getTargetRanges();
1240
+ return t.length === 0 ? null : t[0];
1241
+ }
1242
+ function an(n, t) {
1243
+ const e = n._compositionKey;
1244
+ if ($(null), e !== null && t != null) {
1245
+ if (t === "") {
1246
+ const r = j(e), s = Ee(n.getElementByKey(e));
1247
+ return void (s !== null && s.nodeValue !== null && E(r) && Kn(r, s.nodeValue, null, null, !0));
1248
+ }
1249
+ if (t[t.length - 1] === `
1250
+ `) {
1251
+ const r = M();
1252
+ if (P(r)) {
1253
+ const s = r.focus;
1254
+ return r.anchor.set(s.key, s.offset, s.type), void w(n, gn, null);
1255
+ }
1256
+ }
1257
+ }
1258
+ Rn(!0, n, t);
1259
+ }
1260
+ function ks(n) {
1261
+ let t = n.__lexicalEventHandles;
1262
+ return t === void 0 && (t = [], n.__lexicalEventHandles = t), t;
1263
+ }
1264
+ const At = /* @__PURE__ */ new Map();
1265
+ function bs(n) {
1266
+ const t = Ai(n.target);
1267
+ if (t === null) return;
1268
+ const e = ns(t.anchorNode);
1269
+ if (e === null) return;
1270
+ bn && (bn = !1, Y(e, () => {
1271
+ const a = ae(), c = t.anchorNode;
1272
+ (X(c) || dt(c)) && ut(Ge(a, t, e, n));
1273
+ }));
1274
+ const r = Wn(e), s = r[r.length - 1], i = s._key, o = At.get(i), l = o || s;
1275
+ l !== e && Sr(t, l, !1), Sr(t, e, !0), e !== s ? At.set(i, e) : o && At.delete(i);
1276
+ }
1277
+ function Cr(n) {
1278
+ n._lexicalHandled = !0;
1279
+ }
1280
+ function Tr(n) {
1281
+ return n._lexicalHandled === !0;
1282
+ }
1283
+ function Vi(n) {
1284
+ const t = n.ownerDocument, e = Ie.get(t);
1285
+ e === void 0 && T(162);
1286
+ const r = e - 1;
1287
+ r >= 0 || T(164), Ie.set(t, r), r === 0 && t.removeEventListener("selectionchange", bs);
1288
+ const s = Ke(n);
1289
+ Bn(s) ? (function(o) {
1290
+ if (o._parentEditor !== null) {
1291
+ const l = Wn(o), a = l[l.length - 1]._key;
1292
+ At.get(a) === o && At.delete(a);
1293
+ } else At.delete(o._key);
1294
+ }(s), n.__lexicalEditor = null) : s && T(198);
1295
+ const i = ks(n);
1296
+ for (let o = 0; o < i.length; o++) i[o]();
1297
+ n.__lexicalEventHandles = [];
1298
+ }
1299
+ function wn(n, t, e) {
1300
+ G();
1301
+ const r = n.__key, s = n.getParent();
1302
+ if (s === null) return;
1303
+ const i = function(l) {
1304
+ const a = M();
1305
+ if (!P(a) || !S(l)) return a;
1306
+ const { anchor: c, focus: u } = a, h = c.getNode(), f = u.getNode();
1307
+ return qt(h, l) && c.set(l.__key, 0, "element"), qt(f, l) && u.set(l.__key, 0, "element"), a;
1308
+ }(n);
1309
+ let o = !1;
1310
+ if (P(i) && t) {
1311
+ const l = i.anchor, a = i.focus;
1312
+ l.key === r && (Be(l, n, s, n.getPreviousSibling(), n.getNextSibling()), o = !0), a.key === r && (Be(a, n, s, n.getPreviousSibling(), n.getNextSibling()), o = !0);
1313
+ } else Hn(i) && t && n.isSelected() && n.selectPrevious();
1314
+ if (P(i) && t && !o) {
1315
+ const l = n.getIndexWithinParent();
1316
+ Nt(n), Ae(i, s, l, -1);
1317
+ } else Nt(n);
1318
+ e || Ft(s) || s.canBeEmpty() || !s.isEmpty() || wn(s, t), t && Z(s) && s.isEmpty() && s.selectEnd();
1319
+ }
1320
+ class He {
1321
+ static getType() {
1322
+ T(64, this.name);
1323
+ }
1324
+ static clone(t) {
1325
+ T(65, this.name);
1326
+ }
1327
+ afterCloneFrom(t) {
1328
+ this.__parent = t.__parent, this.__next = t.__next, this.__prev = t.__prev;
1329
+ }
1330
+ constructor(t) {
1331
+ this.__type = this.constructor.getType(), this.__parent = null, this.__prev = null, this.__next = null, rs(this, t);
1332
+ }
1333
+ getType() {
1334
+ return this.__type;
1335
+ }
1336
+ isInline() {
1337
+ T(137, this.constructor.name);
1338
+ }
1339
+ isAttached() {
1340
+ let t = this.__key;
1341
+ for (; t !== null; ) {
1342
+ if (t === "root") return !0;
1343
+ const e = j(t);
1344
+ if (e === null) break;
1345
+ t = e.__parent;
1346
+ }
1347
+ return !1;
1348
+ }
1349
+ isSelected(t) {
1350
+ const e = t || M();
1351
+ if (e == null) return !1;
1352
+ const r = e.getNodes().some((s) => s.__key === this.__key);
1353
+ if (E(this)) return r;
1354
+ if (P(e) && e.anchor.type === "element" && e.focus.type === "element") {
1355
+ if (e.isCollapsed()) return !1;
1356
+ const s = this.getParent();
1357
+ if (I(this) && this.isInline() && s) {
1358
+ const i = e.isBackward() ? e.focus : e.anchor, o = i.getNode();
1359
+ if (i.offset === o.getChildrenSize() && o.is(s) && o.getLastChildOrThrow().is(this)) return !1;
1360
+ }
1361
+ }
1362
+ return r;
1363
+ }
1364
+ getKey() {
1365
+ return this.__key;
1366
+ }
1367
+ getIndexWithinParent() {
1368
+ const t = this.getParent();
1369
+ if (t === null) return -1;
1370
+ let e = t.getFirstChild(), r = 0;
1371
+ for (; e !== null; ) {
1372
+ if (this.is(e)) return r;
1373
+ r++, e = e.getNextSibling();
1374
+ }
1375
+ return -1;
1376
+ }
1377
+ getParent() {
1378
+ const t = this.getLatest().__parent;
1379
+ return t === null ? null : j(t);
1380
+ }
1381
+ getParentOrThrow() {
1382
+ const t = this.getParent();
1383
+ return t === null && T(66, this.__key), t;
1384
+ }
1385
+ getTopLevelElement() {
1386
+ let t = this;
1387
+ for (; t !== null; ) {
1388
+ const e = t.getParent();
1389
+ if (Ft(e)) return S(t) || t === this && I(t) || T(194), t;
1390
+ t = e;
1391
+ }
1392
+ return null;
1393
+ }
1394
+ getTopLevelElementOrThrow() {
1395
+ const t = this.getTopLevelElement();
1396
+ return t === null && T(67, this.__key), t;
1397
+ }
1398
+ getParents() {
1399
+ const t = [];
1400
+ let e = this.getParent();
1401
+ for (; e !== null; ) t.push(e), e = e.getParent();
1402
+ return t;
1403
+ }
1404
+ getParentKeys() {
1405
+ const t = [];
1406
+ let e = this.getParent();
1407
+ for (; e !== null; ) t.push(e.__key), e = e.getParent();
1408
+ return t;
1409
+ }
1410
+ getPreviousSibling() {
1411
+ const t = this.getLatest().__prev;
1412
+ return t === null ? null : j(t);
1413
+ }
1414
+ getPreviousSiblings() {
1415
+ const t = [], e = this.getParent();
1416
+ if (e === null) return t;
1417
+ let r = e.getFirstChild();
1418
+ for (; r !== null && !r.is(this); ) t.push(r), r = r.getNextSibling();
1419
+ return t;
1420
+ }
1421
+ getNextSibling() {
1422
+ const t = this.getLatest().__next;
1423
+ return t === null ? null : j(t);
1424
+ }
1425
+ getNextSiblings() {
1426
+ const t = [];
1427
+ let e = this.getNextSibling();
1428
+ for (; e !== null; ) t.push(e), e = e.getNextSibling();
1429
+ return t;
1430
+ }
1431
+ getCommonAncestor(t) {
1432
+ const e = this.getParents(), r = t.getParents();
1433
+ S(this) && e.unshift(this), S(t) && r.unshift(t);
1434
+ const s = e.length, i = r.length;
1435
+ if (s === 0 || i === 0 || e[s - 1] !== r[i - 1]) return null;
1436
+ const o = new Set(r);
1437
+ for (let l = 0; l < s; l++) {
1438
+ const a = e[l];
1439
+ if (o.has(a)) return a;
1440
+ }
1441
+ return null;
1442
+ }
1443
+ is(t) {
1444
+ return t != null && this.__key === t.__key;
1445
+ }
1446
+ isBefore(t) {
1447
+ if (this === t) return !1;
1448
+ if (t.isParentOf(this)) return !0;
1449
+ if (this.isParentOf(t)) return !1;
1450
+ const e = this.getCommonAncestor(t);
1451
+ let r = 0, s = 0, i = this;
1452
+ for (; ; ) {
1453
+ const o = i.getParentOrThrow();
1454
+ if (o === e) {
1455
+ r = i.getIndexWithinParent();
1456
+ break;
1457
+ }
1458
+ i = o;
1459
+ }
1460
+ for (i = t; ; ) {
1461
+ const o = i.getParentOrThrow();
1462
+ if (o === e) {
1463
+ s = i.getIndexWithinParent();
1464
+ break;
1465
+ }
1466
+ i = o;
1467
+ }
1468
+ return r < s;
1469
+ }
1470
+ isParentOf(t) {
1471
+ const e = this.__key;
1472
+ if (e === t.__key) return !1;
1473
+ let r = t;
1474
+ for (; r !== null; ) {
1475
+ if (r.__key === e) return !0;
1476
+ r = r.getParent();
1477
+ }
1478
+ return !1;
1479
+ }
1480
+ getNodesBetween(t) {
1481
+ const e = this.isBefore(t), r = [], s = /* @__PURE__ */ new Set();
1482
+ let i = this;
1483
+ for (; i !== null; ) {
1484
+ const o = i.__key;
1485
+ if (s.has(o) || (s.add(o), r.push(i)), i === t) break;
1486
+ const l = S(i) ? e ? i.getFirstChild() : i.getLastChild() : null;
1487
+ if (l !== null) {
1488
+ i = l;
1489
+ continue;
1490
+ }
1491
+ const a = e ? i.getNextSibling() : i.getPreviousSibling();
1492
+ if (a !== null) {
1493
+ i = a;
1494
+ continue;
1495
+ }
1496
+ const c = i.getParentOrThrow();
1497
+ if (s.has(c.__key) || r.push(c), c === t) break;
1498
+ let u = null, h = c;
1499
+ do {
1500
+ if (h === null && T(68), u = e ? h.getNextSibling() : h.getPreviousSibling(), h = h.getParent(), h === null) break;
1501
+ u !== null || s.has(h.__key) || r.push(h);
1502
+ } while (u === null);
1503
+ i = u;
1504
+ }
1505
+ return e || r.reverse(), r;
1506
+ }
1507
+ isDirty() {
1508
+ const t = A()._dirtyLeaves;
1509
+ return t !== null && t.has(this.__key);
1510
+ }
1511
+ getLatest() {
1512
+ const t = j(this.__key);
1513
+ return t === null && T(113), t;
1514
+ }
1515
+ getWritable() {
1516
+ G();
1517
+ const t = Tt(), e = A(), r = t._nodeMap, s = this.__key, i = this.getLatest(), o = e._cloneNotNeeded, l = M();
1518
+ if (l !== null && l.setCachedNodes(null), o.has(s)) return Pe(i), i;
1519
+ const a = Ri(i);
1520
+ return o.add(s), Pe(a), r.set(s, a), a;
1521
+ }
1522
+ getTextContent() {
1523
+ return "";
1524
+ }
1525
+ getTextContentSize() {
1526
+ return this.getTextContent().length;
1527
+ }
1528
+ createDOM(t, e) {
1529
+ T(70);
1530
+ }
1531
+ updateDOM(t, e, r) {
1532
+ T(71);
1533
+ }
1534
+ exportDOM(t) {
1535
+ return { element: this.createDOM(t._config, t) };
1536
+ }
1537
+ exportJSON() {
1538
+ return { type: this.__type, version: 1 };
1539
+ }
1540
+ static importJSON(t) {
1541
+ T(18, this.name);
1542
+ }
1543
+ updateFromJSON(t) {
1544
+ return this;
1545
+ }
1546
+ static transform() {
1547
+ return null;
1548
+ }
1549
+ remove(t) {
1550
+ wn(this, !0, t);
1551
+ }
1552
+ replace(t, e) {
1553
+ G();
1554
+ let r = M();
1555
+ r !== null && (r = r.clone()), sn(this, t);
1556
+ const s = this.getLatest(), i = this.__key, o = t.__key, l = t.getWritable(), a = this.getParentOrThrow().getWritable(), c = a.__size;
1557
+ Nt(l);
1558
+ const u = s.getPreviousSibling(), h = s.getNextSibling(), f = s.__prev, d = s.__next, g = s.__parent;
1559
+ if (wn(s, !1, !0), u === null ? a.__first = o : u.getWritable().__next = o, l.__prev = f, h === null ? a.__last = o : h.getWritable().__prev = o, l.__next = d, l.__parent = g, a.__size = c, e && (S(this) && S(l) || T(139), this.getChildren().forEach((_) => {
1560
+ l.append(_);
1561
+ })), P(r)) {
1562
+ ut(r);
1563
+ const _ = r.anchor, p = r.focus;
1564
+ _.key === i && Nr(_, l), p.key === i && Nr(p, l);
1565
+ }
1566
+ return mt() === i && $(o), l;
1567
+ }
1568
+ insertAfter(t, e = !0) {
1569
+ G(), sn(this, t);
1570
+ const r = this.getWritable(), s = t.getWritable(), i = s.getParent(), o = M();
1571
+ let l = !1, a = !1;
1572
+ if (i !== null) {
1573
+ const d = t.getIndexWithinParent();
1574
+ if (Nt(s), P(o)) {
1575
+ const g = i.__key, _ = o.anchor, p = o.focus;
1576
+ l = _.type === "element" && _.key === g && _.offset === d + 1, a = p.type === "element" && p.key === g && p.offset === d + 1;
1577
+ }
1578
+ }
1579
+ const c = this.getNextSibling(), u = this.getParentOrThrow().getWritable(), h = s.__key, f = r.__next;
1580
+ if (c === null ? u.__last = h : c.getWritable().__prev = h, u.__size++, r.__next = h, s.__next = f, s.__prev = r.__key, s.__parent = r.__parent, e && P(o)) {
1581
+ const d = this.getIndexWithinParent();
1582
+ Ae(o, u, d + 1);
1583
+ const g = u.__key;
1584
+ l && o.anchor.set(g, d + 2, "element"), a && o.focus.set(g, d + 2, "element");
1585
+ }
1586
+ return t;
1587
+ }
1588
+ insertBefore(t, e = !0) {
1589
+ G(), sn(this, t);
1590
+ const r = this.getWritable(), s = t.getWritable(), i = s.__key;
1591
+ Nt(s);
1592
+ const o = this.getPreviousSibling(), l = this.getParentOrThrow().getWritable(), a = r.__prev, c = this.getIndexWithinParent();
1593
+ o === null ? l.__first = i : o.getWritable().__next = i, l.__size++, r.__prev = i, s.__prev = a, s.__next = r.__key, s.__parent = r.__parent;
1594
+ const u = M();
1595
+ return e && P(u) && Ae(u, this.getParentOrThrow(), c), t;
1596
+ }
1597
+ isParentRequired() {
1598
+ return !1;
1599
+ }
1600
+ createParentElementNode() {
1601
+ return St();
1602
+ }
1603
+ selectStart() {
1604
+ return this.selectPrevious();
1605
+ }
1606
+ selectEnd() {
1607
+ return this.selectNext(0, 0);
1608
+ }
1609
+ selectPrevious(t, e) {
1610
+ G();
1611
+ const r = this.getPreviousSibling(), s = this.getParentOrThrow();
1612
+ if (r === null) return s.select(0, 0);
1613
+ if (S(r)) return r.select();
1614
+ if (!E(r)) {
1615
+ const i = r.getIndexWithinParent() + 1;
1616
+ return s.select(i, i);
1617
+ }
1618
+ return r.select(t, e);
1619
+ }
1620
+ selectNext(t, e) {
1621
+ G();
1622
+ const r = this.getNextSibling(), s = this.getParentOrThrow();
1623
+ if (r === null) return s.select();
1624
+ if (S(r)) return r.select(0, 0);
1625
+ if (!E(r)) {
1626
+ const i = r.getIndexWithinParent();
1627
+ return s.select(i, i);
1628
+ }
1629
+ return r.select(t, e);
1630
+ }
1631
+ markDirty() {
1632
+ this.getWritable();
1633
+ }
1634
+ reconcileObservedMutation(t, e) {
1635
+ this.markDirty();
1636
+ }
1637
+ }
1638
+ class oe extends He {
1639
+ static getType() {
1640
+ return "linebreak";
1641
+ }
1642
+ static clone(t) {
1643
+ return new oe(t.__key);
1644
+ }
1645
+ constructor(t) {
1646
+ super(t);
1647
+ }
1648
+ getTextContent() {
1649
+ return `
1650
+ `;
1651
+ }
1652
+ createDOM() {
1653
+ return document.createElement("br");
1654
+ }
1655
+ updateDOM() {
1656
+ return !1;
1657
+ }
1658
+ static importDOM() {
1659
+ return { br: (t) => function(e) {
1660
+ const r = e.parentElement;
1661
+ if (r !== null && pr(r)) {
1662
+ const s = r.firstChild;
1663
+ if (s === e || s.nextSibling === e && pe(s)) {
1664
+ const i = r.lastChild;
1665
+ if (i === e || i.previousSibling === e && pe(i)) return !0;
1666
+ }
1667
+ }
1668
+ return !1;
1669
+ }(t) || function(e) {
1670
+ const r = e.parentElement;
1671
+ if (r !== null && pr(r)) {
1672
+ const s = r.firstChild;
1673
+ if (s === e || s.nextSibling === e && pe(s)) return !1;
1674
+ const i = r.lastChild;
1675
+ if (i === e || i.previousSibling === e && pe(i)) return !0;
1676
+ }
1677
+ return !1;
1678
+ }(t) ? null : { conversion: Hi, priority: 0 } };
1679
+ }
1680
+ static importJSON(t) {
1681
+ return ne().updateFromJSON(t);
1682
+ }
1683
+ }
1684
+ function Hi(n) {
1685
+ return { node: ne() };
1686
+ }
1687
+ function ne() {
1688
+ return je(new oe());
1689
+ }
1690
+ function Bt(n) {
1691
+ return n instanceof oe;
1692
+ }
1693
+ function pe(n) {
1694
+ return dt(n) && /^( |\t|\r?\n)+$/.test(n.textContent || "");
1695
+ }
1696
+ function cn(n, t) {
1697
+ return 16 & t ? "code" : t & Fn ? "mark" : 32 & t ? "sub" : 64 & t ? "sup" : null;
1698
+ }
1699
+ function un(n, t) {
1700
+ return 1 & t ? "strong" : 2 & t ? "em" : "span";
1701
+ }
1702
+ function ws(n, t, e, r, s) {
1703
+ const i = r.classList;
1704
+ let o = It(s, "base");
1705
+ o !== void 0 && i.add(...o), o = It(s, "underlineStrikethrough");
1706
+ let l = !1;
1707
+ const a = t & we && t & be;
1708
+ o !== void 0 && (e & we && e & be ? (l = !0, a || i.add(...o)) : a && i.remove(...o));
1709
+ for (const c in V) {
1710
+ const u = V[c];
1711
+ if (o = It(s, c), o !== void 0) if (e & u) {
1712
+ if (l && (c === "underline" || c === "strikethrough")) {
1713
+ t & u && i.remove(...o);
1714
+ continue;
1715
+ }
1716
+ t & u && (!a || c !== "underline") && c !== "strikethrough" || i.add(...o);
1717
+ } else t & u && i.remove(...o);
1718
+ }
1719
+ }
1720
+ function Ns(n, t, e) {
1721
+ const r = t.firstChild, s = e.isComposing(), i = n + (s ? We : "");
1722
+ if (r == null) t.textContent = i;
1723
+ else {
1724
+ const o = r.nodeValue;
1725
+ if (o !== i) if (s || vt) {
1726
+ const [l, a, c] = function(u, h) {
1727
+ const f = u.length, d = h.length;
1728
+ let g = 0, _ = 0;
1729
+ for (; g < f && g < d && u[g] === h[g]; ) g++;
1730
+ for (; _ + g < f && _ + g < d && u[f - _ - 1] === h[d - _ - 1]; ) _++;
1731
+ return [g, f - g - _, h.slice(g, d - _)];
1732
+ }(o, i);
1733
+ a !== 0 && r.deleteData(l, a), r.insertData(l, c);
1734
+ } else r.nodeValue = i;
1735
+ }
1736
+ }
1737
+ function kr(n, t, e, r, s, i) {
1738
+ Ns(s, n, t);
1739
+ const o = i.theme.text;
1740
+ o !== void 0 && ws(0, 0, r, n, o);
1741
+ }
1742
+ function ye(n, t) {
1743
+ const e = document.createElement(t);
1744
+ return e.appendChild(n), e;
1745
+ }
1746
+ class Wt extends He {
1747
+ static getType() {
1748
+ return "text";
1749
+ }
1750
+ static clone(t) {
1751
+ return new Wt(t.__text, t.__key);
1752
+ }
1753
+ afterCloneFrom(t) {
1754
+ super.afterCloneFrom(t), this.__text = t.__text, this.__format = t.__format, this.__style = t.__style, this.__mode = t.__mode, this.__detail = t.__detail;
1755
+ }
1756
+ constructor(t = "", e) {
1757
+ super(e), this.__text = t, this.__format = 0, this.__style = "", this.__mode = 0, this.__detail = 0;
1758
+ }
1759
+ getFormat() {
1760
+ return this.getLatest().__format;
1761
+ }
1762
+ getDetail() {
1763
+ return this.getLatest().__detail;
1764
+ }
1765
+ getMode() {
1766
+ const t = this.getLatest();
1767
+ return Ci[t.__mode];
1768
+ }
1769
+ getStyle() {
1770
+ return this.getLatest().__style;
1771
+ }
1772
+ isToken() {
1773
+ return this.getLatest().__mode === 1;
1774
+ }
1775
+ isComposing() {
1776
+ return this.__key === mt();
1777
+ }
1778
+ isSegmented() {
1779
+ return this.getLatest().__mode === 2;
1780
+ }
1781
+ isDirectionless() {
1782
+ return !!(1 & this.getLatest().__detail);
1783
+ }
1784
+ isUnmergeable() {
1785
+ return !!(2 & this.getLatest().__detail);
1786
+ }
1787
+ hasFormat(t) {
1788
+ const e = V[t];
1789
+ return !!(this.getFormat() & e);
1790
+ }
1791
+ isSimpleText() {
1792
+ return this.__type === "text" && this.__mode === 0;
1793
+ }
1794
+ getTextContent() {
1795
+ return this.getLatest().__text;
1796
+ }
1797
+ getFormatFlags(t, e) {
1798
+ return Fe(this.getLatest().__format, t, e);
1799
+ }
1800
+ canHaveFormat() {
1801
+ return !0;
1802
+ }
1803
+ createDOM(t, e) {
1804
+ const r = this.__format, s = cn(0, r), i = un(0, r), o = s === null ? i : s, l = document.createElement(o);
1805
+ let a = l;
1806
+ this.hasFormat("code") && l.setAttribute("spellcheck", "false"), s !== null && (a = document.createElement(i), l.appendChild(a)), kr(a, this, 0, r, this.__text, t);
1807
+ const c = this.__style;
1808
+ return c !== "" && (l.style.cssText = c), l;
1809
+ }
1810
+ updateDOM(t, e, r) {
1811
+ const s = this.__text, i = t.__format, o = this.__format, l = cn(0, i), a = cn(0, o), c = un(0, i), u = un(0, o);
1812
+ if ((l === null ? c : l) !== (a === null ? u : a)) return !0;
1813
+ if (l === a && c !== u) {
1814
+ const _ = e.firstChild;
1815
+ _ == null && T(48);
1816
+ const p = document.createElement(u);
1817
+ return kr(p, this, 0, o, s, r), e.replaceChild(p, _), !1;
1818
+ }
1819
+ let h = e;
1820
+ a !== null && l !== null && (h = e.firstChild, h == null && T(49)), Ns(s, h, this);
1821
+ const f = r.theme.text;
1822
+ f !== void 0 && i !== o && ws(0, i, o, h, f);
1823
+ const d = t.__style, g = this.__style;
1824
+ return d !== g && (e.style.cssText = g), !1;
1825
+ }
1826
+ static importDOM() {
1827
+ return { "#text": () => ({ conversion: Xi, priority: 0 }), b: () => ({ conversion: Gi, priority: 0 }), code: () => ({ conversion: _t, priority: 0 }), em: () => ({ conversion: _t, priority: 0 }), i: () => ({ conversion: _t, priority: 0 }), s: () => ({ conversion: _t, priority: 0 }), span: () => ({ conversion: qi, priority: 0 }), strong: () => ({ conversion: _t, priority: 0 }), sub: () => ({ conversion: _t, priority: 0 }), sup: () => ({ conversion: _t, priority: 0 }), u: () => ({ conversion: _t, priority: 0 }) };
1828
+ }
1829
+ static importJSON(t) {
1830
+ return U().updateFromJSON(t);
1831
+ }
1832
+ updateFromJSON(t) {
1833
+ return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style);
1834
+ }
1835
+ exportDOM(t) {
1836
+ let { element: e } = super.exportDOM(t);
1837
+ return X(e) || T(132), e.style.whiteSpace = "pre-wrap", this.hasFormat("bold") && (e = ye(e, "b")), this.hasFormat("italic") && (e = ye(e, "i")), this.hasFormat("strikethrough") && (e = ye(e, "s")), this.hasFormat("underline") && (e = ye(e, "u")), { element: e };
1838
+ }
1839
+ exportJSON() {
1840
+ return { detail: this.getDetail(), format: this.getFormat(), mode: this.getMode(), style: this.getStyle(), text: this.getTextContent(), ...super.exportJSON() };
1841
+ }
1842
+ selectionTransform(t, e) {
1843
+ }
1844
+ setFormat(t) {
1845
+ const e = this.getWritable();
1846
+ return e.__format = typeof t == "string" ? V[t] : t, e;
1847
+ }
1848
+ setDetail(t) {
1849
+ const e = this.getWritable();
1850
+ return e.__detail = typeof t == "string" ? xi[t] : t, e;
1851
+ }
1852
+ setStyle(t) {
1853
+ const e = this.getWritable();
1854
+ return e.__style = t, e;
1855
+ }
1856
+ toggleFormat(t) {
1857
+ const e = Fe(this.getFormat(), t, null);
1858
+ return this.setFormat(e);
1859
+ }
1860
+ toggleDirectionless() {
1861
+ const t = this.getWritable();
1862
+ return t.__detail ^= 1, t;
1863
+ }
1864
+ toggleUnmergeable() {
1865
+ const t = this.getWritable();
1866
+ return t.__detail ^= 2, t;
1867
+ }
1868
+ setMode(t) {
1869
+ const e = Si[t];
1870
+ if (this.__mode === e) return this;
1871
+ const r = this.getWritable();
1872
+ return r.__mode = e, r;
1873
+ }
1874
+ setTextContent(t) {
1875
+ if (this.__text === t) return this;
1876
+ const e = this.getWritable();
1877
+ return e.__text = t, e;
1878
+ }
1879
+ select(t, e) {
1880
+ G();
1881
+ let r = t, s = e;
1882
+ const i = M(), o = this.getTextContent(), l = this.__key;
1883
+ if (typeof o == "string") {
1884
+ const a = o.length;
1885
+ r === void 0 && (r = a), s === void 0 && (s = a);
1886
+ } else r = 0, s = 0;
1887
+ if (!P(i)) return Ps(l, r, l, s, "text", "text");
1888
+ {
1889
+ const a = mt();
1890
+ a !== i.anchor.key && a !== i.focus.key || $(l), i.setTextNodeRange(this, r, this, s);
1891
+ }
1892
+ return i;
1893
+ }
1894
+ selectStart() {
1895
+ return this.select(0, 0);
1896
+ }
1897
+ selectEnd() {
1898
+ const t = this.getTextContentSize();
1899
+ return this.select(t, t);
1900
+ }
1901
+ spliceText(t, e, r, s) {
1902
+ const i = this.getWritable(), o = i.__text, l = r.length;
1903
+ let a = t;
1904
+ a < 0 && (a = l + a, a < 0 && (a = 0));
1905
+ const c = M();
1906
+ if (s && P(c)) {
1907
+ const h = t + l;
1908
+ c.setTextNodeRange(i, h, i, h);
1909
+ }
1910
+ const u = o.slice(0, a) + r + o.slice(a + e);
1911
+ return i.__text = u, i;
1912
+ }
1913
+ canInsertTextBefore() {
1914
+ return !0;
1915
+ }
1916
+ canInsertTextAfter() {
1917
+ return !0;
1918
+ }
1919
+ splitText(...t) {
1920
+ G();
1921
+ const e = this.getLatest(), r = e.getTextContent(), s = e.__key, i = mt(), o = new Set(t), l = [], a = r.length;
1922
+ let c = "";
1923
+ for (let k = 0; k < a; k++) c !== "" && o.has(k) && (l.push(c), c = ""), c += r[k];
1924
+ c !== "" && l.push(c);
1925
+ const u = l.length;
1926
+ if (u === 0) return [];
1927
+ if (l[0] === r) return [e];
1928
+ const h = l[0], f = e.getParent();
1929
+ let d;
1930
+ const g = e.getFormat(), _ = e.getStyle(), p = e.__detail;
1931
+ let m = !1;
1932
+ e.isSegmented() ? (d = U(h), d.__format = g, d.__style = _, d.__detail = p, m = !0) : (d = e.getWritable(), d.__text = h);
1933
+ const y = M(), x = [d];
1934
+ let b = h.length;
1935
+ for (let k = 1; k < u; k++) {
1936
+ const v = l[k], F = v.length, C = U(v).getWritable();
1937
+ C.__format = g, C.__style = _, C.__detail = p;
1938
+ const N = C.__key, O = b + F;
1939
+ if (P(y)) {
1940
+ const D = y.anchor, B = y.focus;
1941
+ D.key === s && D.type === "text" && D.offset > b && D.offset <= O && (D.key = N, D.offset -= b, y.dirty = !0), B.key === s && B.type === "text" && B.offset > b && B.offset <= O && (B.key = N, B.offset -= b, y.dirty = !0);
1942
+ }
1943
+ i === s && $(N), b = O, x.push(C);
1944
+ }
1945
+ if (f !== null) {
1946
+ (function(F) {
1947
+ const C = F.getPreviousSibling(), N = F.getNextSibling();
1948
+ C !== null && Pe(C), N !== null && Pe(N);
1949
+ })(this);
1950
+ const k = f.getWritable(), v = this.getIndexWithinParent();
1951
+ m ? (k.splice(v, 0, x), this.remove()) : k.splice(v, 1, x), P(y) && Ae(y, f, v, u - 1);
1952
+ }
1953
+ return x;
1954
+ }
1955
+ mergeWithSibling(t) {
1956
+ const e = t === this.getPreviousSibling();
1957
+ e || t === this.getNextSibling() || T(50);
1958
+ const r = this.__key, s = t.__key, i = this.__text, o = i.length;
1959
+ mt() === s && $(r);
1960
+ const l = M();
1961
+ if (P(l)) {
1962
+ const h = l.anchor, f = l.focus;
1963
+ h !== null && h.key === s && (Ir(h, e, r, t, o), l.dirty = !0), f !== null && f.key === s && (Ir(f, e, r, t, o), l.dirty = !0);
1964
+ }
1965
+ const a = t.__text, c = e ? a + i : i + a;
1966
+ this.setTextContent(c);
1967
+ const u = this.getWritable();
1968
+ return t.remove(), u;
1969
+ }
1970
+ isTextEntity() {
1971
+ return !1;
1972
+ }
1973
+ }
1974
+ function qi(n) {
1975
+ return { forChild: jn(n.style), node: null };
1976
+ }
1977
+ function Gi(n) {
1978
+ const t = n, e = t.style.fontWeight === "normal";
1979
+ return { forChild: jn(t.style, e ? void 0 : "bold"), node: null };
1980
+ }
1981
+ const br = /* @__PURE__ */ new WeakMap();
1982
+ function Qi(n) {
1983
+ if (!X(n)) return !1;
1984
+ if (n.nodeName === "PRE") return !0;
1985
+ const t = n.style.whiteSpace;
1986
+ return typeof t == "string" && t.startsWith("pre");
1987
+ }
1988
+ function Xi(n) {
1989
+ const t = n;
1990
+ n.parentElement === null && T(129);
1991
+ let e = t.textContent || "";
1992
+ if (function(r) {
1993
+ let s, i = r.parentNode;
1994
+ const o = [r];
1995
+ for (; i !== null && (s = br.get(i)) === void 0 && !Qi(i); ) o.push(i), i = i.parentNode;
1996
+ const l = s === void 0 ? i : s;
1997
+ for (let a = 0; a < o.length; a++) br.set(o[a], l);
1998
+ return l;
1999
+ }(t) !== null) {
2000
+ const r = e.split(/(\r?\n|\t)/), s = [], i = r.length;
2001
+ for (let o = 0; o < i; o++) {
2002
+ const l = r[o];
2003
+ l === `
2004
+ ` || l === `\r
2005
+ ` ? s.push(ne()) : l === " " ? s.push(Vn()) : l !== "" && s.push(U(l));
2006
+ }
2007
+ return { node: s };
2008
+ }
2009
+ if (e = e.replace(/\r/g, "").replace(/[ \t\n]+/g, " "), e === "") return { node: null };
2010
+ if (e[0] === " ") {
2011
+ let r = t, s = !0;
2012
+ for (; r !== null && (r = wr(r, !1)) !== null; ) {
2013
+ const i = r.textContent || "";
2014
+ if (i.length > 0) {
2015
+ /[ \t\n]$/.test(i) && (e = e.slice(1)), s = !1;
2016
+ break;
2017
+ }
2018
+ }
2019
+ s && (e = e.slice(1));
2020
+ }
2021
+ if (e[e.length - 1] === " ") {
2022
+ let r = t, s = !0;
2023
+ for (; r !== null && (r = wr(r, !0)) !== null; )
2024
+ if ((r.textContent || "").replace(/^( |\t|\r?\n)+/, "").length > 0) {
2025
+ s = !1;
2026
+ break;
2027
+ }
2028
+ s && (e = e.slice(0, e.length - 1));
2029
+ }
2030
+ return e === "" ? { node: null } : { node: U(e) };
2031
+ }
2032
+ function wr(n, t) {
2033
+ let e = n;
2034
+ for (; ; ) {
2035
+ let r;
2036
+ for (; (r = t ? e.nextSibling : e.previousSibling) === null; ) {
2037
+ const i = e.parentElement;
2038
+ if (i === null) return null;
2039
+ e = i;
2040
+ }
2041
+ if (e = r, X(e)) {
2042
+ const i = e.style.display;
2043
+ if (i === "" && !zi(e) || i !== "" && !i.startsWith("inline")) return null;
2044
+ }
2045
+ let s = e;
2046
+ for (; (s = t ? e.firstChild : e.lastChild) !== null; ) e = s;
2047
+ if (dt(e)) return e;
2048
+ if (e.nodeName === "BR") return null;
2049
+ }
2050
+ }
2051
+ const Yi = { code: "code", em: "italic", i: "italic", s: "strikethrough", strong: "bold", sub: "subscript", sup: "superscript", u: "underline" };
2052
+ function _t(n) {
2053
+ const t = Yi[n.nodeName.toLowerCase()];
2054
+ return t === void 0 ? { node: null } : { forChild: jn(n.style, t), node: null };
2055
+ }
2056
+ function U(n = "") {
2057
+ return je(new Wt(n));
2058
+ }
2059
+ function E(n) {
2060
+ return n instanceof Wt;
2061
+ }
2062
+ function jn(n, t) {
2063
+ const e = n.fontWeight, r = n.textDecoration.split(" "), s = e === "700" || e === "bold", i = r.includes("line-through"), o = n.fontStyle === "italic", l = r.includes("underline"), a = n.verticalAlign;
2064
+ return (c) => (E(c) && (s && !c.hasFormat("bold") && c.toggleFormat("bold"), i && !c.hasFormat("strikethrough") && c.toggleFormat("strikethrough"), o && !c.hasFormat("italic") && c.toggleFormat("italic"), l && !c.hasFormat("underline") && c.toggleFormat("underline"), a !== "sub" || c.hasFormat("subscript") || c.toggleFormat("subscript"), a !== "super" || c.hasFormat("superscript") || c.toggleFormat("superscript"), t && !c.hasFormat(t) && c.toggleFormat(t)), c);
2065
+ }
2066
+ class le extends Wt {
2067
+ static getType() {
2068
+ return "tab";
2069
+ }
2070
+ static clone(t) {
2071
+ return new le(t.__key);
2072
+ }
2073
+ constructor(t) {
2074
+ super(" ", t), this.__detail = 2;
2075
+ }
2076
+ static importDOM() {
2077
+ return null;
2078
+ }
2079
+ createDOM(t) {
2080
+ const e = super.createDOM(t), r = It(t.theme, "tab");
2081
+ return r !== void 0 && e.classList.add(...r), e;
2082
+ }
2083
+ static importJSON(t) {
2084
+ return Vn().updateFromJSON(t);
2085
+ }
2086
+ setTextContent(t) {
2087
+ return t !== " " && t !== "" && T(126), super.setTextContent(t);
2088
+ }
2089
+ setDetail(t) {
2090
+ return t !== 2 && T(127), this;
2091
+ }
2092
+ setMode(t) {
2093
+ return t === "normal" && T(128), this;
2094
+ }
2095
+ canInsertTextBefore() {
2096
+ return !1;
2097
+ }
2098
+ canInsertTextAfter() {
2099
+ return !1;
2100
+ }
2101
+ }
2102
+ function Vn() {
2103
+ return je(new le());
2104
+ }
2105
+ function Zi(n) {
2106
+ return n instanceof le;
2107
+ }
2108
+ class to {
2109
+ constructor(t, e, r) {
2110
+ this._selection = null, this.key = t, this.offset = e, this.type = r;
2111
+ }
2112
+ is(t) {
2113
+ return this.key === t.key && this.offset === t.offset && this.type === t.type;
2114
+ }
2115
+ isBefore(t) {
2116
+ let e = this.getNode(), r = t.getNode();
2117
+ const s = this.offset, i = t.offset;
2118
+ if (S(e)) {
2119
+ const o = e.getDescendantByIndex(s);
2120
+ e = o ?? e;
2121
+ }
2122
+ if (S(r)) {
2123
+ const o = r.getDescendantByIndex(i);
2124
+ r = o ?? r;
2125
+ }
2126
+ return e === r ? s < i : e.isBefore(r);
2127
+ }
2128
+ getNode() {
2129
+ const t = j(this.key);
2130
+ return t === null && T(20), t;
2131
+ }
2132
+ set(t, e, r) {
2133
+ const s = this._selection, i = this.key;
2134
+ this.key = t, this.offset = e, this.type = r, ce() || (mt() === i && $(t), s !== null && (s.setCachedNodes(null), s.dirty = !0));
2135
+ }
2136
+ }
2137
+ function ot(n, t, e) {
2138
+ return new to(n, t, e);
2139
+ }
2140
+ function fn(n, t) {
2141
+ let e = t.__key, r = n.offset, s = "element";
2142
+ if (E(t)) {
2143
+ s = "text";
2144
+ const i = t.getTextContentSize();
2145
+ r > i && (r = i);
2146
+ } else if (!S(t)) {
2147
+ const i = t.getNextSibling();
2148
+ if (E(i)) e = i.__key, r = 0, s = "text";
2149
+ else {
2150
+ const o = t.getParent();
2151
+ o && (e = o.__key, r = t.getIndexWithinParent() + 1);
2152
+ }
2153
+ }
2154
+ n.set(e, r, s);
2155
+ }
2156
+ function Nr(n, t) {
2157
+ if (S(t)) {
2158
+ const e = t.getLastDescendant();
2159
+ S(e) || E(e) ? fn(n, e) : fn(n, t);
2160
+ } else fn(n, t);
2161
+ }
2162
+ function yt(n, t, e, r) {
2163
+ n.key = t, n.offset = e, n.type = r;
2164
+ }
2165
+ class qe {
2166
+ constructor(t) {
2167
+ this._cachedNodes = null, this._nodes = t, this.dirty = !1;
2168
+ }
2169
+ getCachedNodes() {
2170
+ return this._cachedNodes;
2171
+ }
2172
+ setCachedNodes(t) {
2173
+ this._cachedNodes = t;
2174
+ }
2175
+ is(t) {
2176
+ if (!Hn(t)) return !1;
2177
+ const e = this._nodes, r = t._nodes;
2178
+ return e.size === r.size && Array.from(e).every((s) => r.has(s));
2179
+ }
2180
+ isCollapsed() {
2181
+ return !1;
2182
+ }
2183
+ isBackward() {
2184
+ return !1;
2185
+ }
2186
+ getStartEndPoints() {
2187
+ return null;
2188
+ }
2189
+ add(t) {
2190
+ this.dirty = !0, this._nodes.add(t), this._cachedNodes = null;
2191
+ }
2192
+ delete(t) {
2193
+ this.dirty = !0, this._nodes.delete(t), this._cachedNodes = null;
2194
+ }
2195
+ clear() {
2196
+ this.dirty = !0, this._nodes.clear(), this._cachedNodes = null;
2197
+ }
2198
+ has(t) {
2199
+ return this._nodes.has(t);
2200
+ }
2201
+ clone() {
2202
+ return new qe(new Set(this._nodes));
2203
+ }
2204
+ extract() {
2205
+ return this.getNodes();
2206
+ }
2207
+ insertRawText(t) {
2208
+ }
2209
+ insertText() {
2210
+ }
2211
+ insertNodes(t) {
2212
+ const e = this.getNodes(), r = e.length, s = e[r - 1];
2213
+ let i;
2214
+ if (E(s)) i = s.select();
2215
+ else {
2216
+ const o = s.getIndexWithinParent() + 1;
2217
+ i = s.getParentOrThrow().select(o, o);
2218
+ }
2219
+ i.insertNodes(t);
2220
+ for (let o = 0; o < r; o++) e[o].remove();
2221
+ }
2222
+ getNodes() {
2223
+ const t = this._cachedNodes;
2224
+ if (t !== null) return t;
2225
+ const e = this._nodes, r = [];
2226
+ for (const s of e) {
2227
+ const i = j(s);
2228
+ i !== null && r.push(i);
2229
+ }
2230
+ return ce() || (this._cachedNodes = r), r;
2231
+ }
2232
+ getTextContent() {
2233
+ const t = this.getNodes();
2234
+ let e = "";
2235
+ for (let r = 0; r < t.length; r++) e += t[r].getTextContent();
2236
+ return e;
2237
+ }
2238
+ }
2239
+ function P(n) {
2240
+ return n instanceof Ot;
2241
+ }
2242
+ class Ot {
2243
+ constructor(t, e, r, s) {
2244
+ this.anchor = t, this.focus = e, t._selection = this, e._selection = this, this._cachedNodes = null, this.format = r, this.style = s, this.dirty = !1;
2245
+ }
2246
+ getCachedNodes() {
2247
+ return this._cachedNodes;
2248
+ }
2249
+ setCachedNodes(t) {
2250
+ this._cachedNodes = t;
2251
+ }
2252
+ is(t) {
2253
+ return !!P(t) && this.anchor.is(t.anchor) && this.focus.is(t.focus) && this.format === t.format && this.style === t.style;
2254
+ }
2255
+ isCollapsed() {
2256
+ return this.anchor.is(this.focus);
2257
+ }
2258
+ getNodes() {
2259
+ const t = this._cachedNodes;
2260
+ if (t !== null) return t;
2261
+ const e = this.anchor, r = this.focus, s = e.isBefore(r), i = s ? e : r, o = s ? r : e;
2262
+ let l = i.getNode(), a = o.getNode();
2263
+ const c = S(l) && i.offset > 0 && i.offset >= l.getChildrenSize(), u = i.offset, h = o.offset;
2264
+ if (S(l)) {
2265
+ const d = l.getDescendantByIndex(u);
2266
+ l = d ?? l;
2267
+ }
2268
+ if (S(a)) {
2269
+ let d = a.getDescendantByIndex(h);
2270
+ d !== null && d !== l && a.getChildAtIndex(h) === d && (d = d.getPreviousSibling()), a = d ?? a;
2271
+ }
2272
+ let f;
2273
+ if (l.is(a)) f = S(l) && l.getChildrenSize() > 0 ? [] : [l];
2274
+ else if (f = l.getNodesBetween(a), c) {
2275
+ const d = f.findIndex((g) => !g.is(l) && !g.isBefore(l));
2276
+ f.splice(0, d);
2277
+ }
2278
+ return ce() || (this._cachedNodes = f), f;
2279
+ }
2280
+ setTextNodeRange(t, e, r, s) {
2281
+ yt(this.anchor, t.__key, e, "text"), yt(this.focus, r.__key, s, "text"), this._cachedNodes = null, this.dirty = !0;
2282
+ }
2283
+ getTextContent() {
2284
+ const t = this.getNodes();
2285
+ if (t.length === 0) return "";
2286
+ const e = t[0], r = t[t.length - 1], s = this.anchor, i = this.focus, o = s.isBefore(i), [l, a] = Fr(this);
2287
+ let c = "", u = !0;
2288
+ for (let h = 0; h < t.length; h++) {
2289
+ const f = t[h];
2290
+ if (S(f) && !f.isInline()) u || (c += `
2291
+ `), u = !f.isEmpty();
2292
+ else if (u = !1, E(f)) {
2293
+ let d = f.getTextContent();
2294
+ f === e ? f === r ? s.type === "element" && i.type === "element" && i.offset !== s.offset || (d = l < a ? d.slice(l, a) : d.slice(a, l)) : d = o ? d.slice(l) : d.slice(a) : f === r && (d = o ? d.slice(0, a) : d.slice(0, l)), c += d;
2295
+ } else !I(f) && !Bt(f) || f === r && this.isCollapsed() || (c += f.getTextContent());
2296
+ }
2297
+ return c;
2298
+ }
2299
+ applyDOMRange(t) {
2300
+ const e = A(), r = e.getEditorState()._selection, s = Fs(t.startContainer, t.startOffset, t.endContainer, t.endOffset, e, r);
2301
+ if (s === null) return;
2302
+ const [i, o] = s;
2303
+ yt(this.anchor, i.key, i.offset, i.type), yt(this.focus, o.key, o.offset, o.type), this._cachedNodes = null;
2304
+ }
2305
+ clone() {
2306
+ const t = this.anchor, e = this.focus;
2307
+ return new Ot(ot(t.key, t.offset, t.type), ot(e.key, e.offset, e.type), this.format, this.style);
2308
+ }
2309
+ toggleFormat(t) {
2310
+ this.format = Fe(this.format, t, null), this.dirty = !0;
2311
+ }
2312
+ setStyle(t) {
2313
+ this.style = t, this.dirty = !0;
2314
+ }
2315
+ hasFormat(t) {
2316
+ const e = V[t];
2317
+ return !!(this.format & e);
2318
+ }
2319
+ insertRawText(t) {
2320
+ const e = t.split(/(\r?\n|\t)/), r = [], s = e.length;
2321
+ for (let i = 0; i < s; i++) {
2322
+ const o = e[i];
2323
+ o === `
2324
+ ` || o === `\r
2325
+ ` ? r.push(ne()) : o === " " ? r.push(Vn()) : r.push(U(o));
2326
+ }
2327
+ this.insertNodes(r);
2328
+ }
2329
+ insertText(t) {
2330
+ const e = this.anchor, r = this.focus, s = this.format, i = this.style;
2331
+ let o = e, l = r;
2332
+ !this.isCollapsed() && r.isBefore(e) && (o = r, l = e), o.type === "element" && function(p, m, y, x) {
2333
+ const b = p.getNode(), k = b.getChildAtIndex(p.offset), v = U(), F = Z(b) ? St().append(v) : v;
2334
+ v.setFormat(y), v.setStyle(x), k === null ? b.append(F) : k.insertBefore(F), p.is(m) && m.set(v.__key, 0, "text"), p.set(v.__key, 0, "text");
2335
+ }(o, l, s, i);
2336
+ const a = o.offset;
2337
+ let c = l.offset;
2338
+ const u = this.getNodes(), h = u.length;
2339
+ let f = u[0];
2340
+ E(f) || T(26);
2341
+ const d = f.getTextContent().length, g = f.getParentOrThrow();
2342
+ let _ = u[h - 1];
2343
+ if (h === 1 && l.type === "element" && (c = d, l.set(o.key, c, "text")), this.isCollapsed() && a === d && (f.isSegmented() || f.isToken() || !f.canInsertTextAfter() || !g.canInsertTextAfter() && f.getNextSibling() === null)) {
2344
+ let p = f.getNextSibling();
2345
+ if (E(p) && p.canInsertTextBefore() && !bt(p) || (p = U(), p.setFormat(s), p.setStyle(i), g.canInsertTextAfter() ? f.insertAfter(p) : g.insertAfter(p)), p.select(0, 0), f = p, t !== "") return void this.insertText(t);
2346
+ } else if (this.isCollapsed() && a === 0 && (f.isSegmented() || f.isToken() || !f.canInsertTextBefore() || !g.canInsertTextBefore() && f.getPreviousSibling() === null)) {
2347
+ let p = f.getPreviousSibling();
2348
+ if (E(p) && !bt(p) || (p = U(), p.setFormat(s), g.canInsertTextBefore() ? f.insertBefore(p) : g.insertBefore(p)), p.select(), f = p, t !== "") return void this.insertText(t);
2349
+ } else if (f.isSegmented() && a !== d) {
2350
+ const p = U(f.getTextContent());
2351
+ p.setFormat(s), f.replace(p), f = p;
2352
+ } else if (!this.isCollapsed() && t !== "") {
2353
+ const p = _.getParent();
2354
+ if (!g.canInsertTextBefore() || !g.canInsertTextAfter() || S(p) && (!p.canInsertTextBefore() || !p.canInsertTextAfter())) return this.insertText(""), Es(this.anchor, this.focus, null), void this.insertText(t);
2355
+ }
2356
+ if (h === 1) {
2357
+ if (f.isToken()) {
2358
+ const x = U(t);
2359
+ return x.select(), void f.replace(x);
2360
+ }
2361
+ const p = f.getFormat(), m = f.getStyle();
2362
+ if (a !== c || p === s && m === i) {
2363
+ if (Zi(f)) {
2364
+ const x = U(t);
2365
+ return x.setFormat(s), x.setStyle(i), x.select(), void f.replace(x);
2366
+ }
2367
+ } else {
2368
+ if (f.getTextContent() !== "") {
2369
+ const x = U(t);
2370
+ if (x.setFormat(s), x.setStyle(i), x.select(), a === 0) f.insertBefore(x, !1);
2371
+ else {
2372
+ const [b] = f.splitText(a);
2373
+ b.insertAfter(x, !1);
2374
+ }
2375
+ return void (x.isComposing() && this.anchor.type === "text" && (this.anchor.offset -= t.length));
2376
+ }
2377
+ f.setFormat(s), f.setStyle(i);
2378
+ }
2379
+ const y = c - a;
2380
+ f = f.spliceText(a, y, t, !0), f.getTextContent() === "" ? f.remove() : this.anchor.type === "text" && (f.isComposing() ? this.anchor.offset -= t.length : (this.format = p, this.style = m));
2381
+ } else {
2382
+ const p = /* @__PURE__ */ new Set([...f.getParentKeys(), ..._.getParentKeys()]), m = S(f) ? f : f.getParentOrThrow();
2383
+ let y = S(_) ? _ : _.getParentOrThrow(), x = _;
2384
+ if (!m.is(y) && y.isInline()) do
2385
+ x = y, y = y.getParentOrThrow();
2386
+ while (y.isInline());
2387
+ if (l.type === "text" && (c !== 0 || _.getTextContent() === "") || l.type === "element" && _.getIndexWithinParent() < c) if (E(_) && !_.isToken() && c !== _.getTextContentSize()) {
2388
+ if (_.isSegmented()) {
2389
+ const C = U(_.getTextContent());
2390
+ _.replace(C), _ = C;
2391
+ }
2392
+ Z(l.getNode()) || l.type !== "text" || (_ = _.spliceText(0, c, "")), p.add(_.__key);
2393
+ } else {
2394
+ const C = _.getParentOrThrow();
2395
+ C.canBeEmpty() || C.getChildrenSize() !== 1 ? _.remove() : C.remove();
2396
+ }
2397
+ else p.add(_.__key);
2398
+ const b = y.getChildren(), k = new Set(u), v = m.is(y), F = m.isInline() && f.getNextSibling() === null ? m : f;
2399
+ for (let C = b.length - 1; C >= 0; C--) {
2400
+ const N = b[C];
2401
+ if (N.is(f) || S(N) && N.isParentOf(f)) break;
2402
+ N.isAttached() && (!k.has(N) || N.is(x) ? v || F.insertAfter(N, !1) : N.remove());
2403
+ }
2404
+ if (!v) {
2405
+ let C = y, N = null;
2406
+ for (; C !== null; ) {
2407
+ const O = C.getChildren(), D = O.length;
2408
+ (D === 0 || O[D - 1].is(N)) && (p.delete(C.__key), N = C), C = C.getParent();
2409
+ }
2410
+ }
2411
+ if (f.isToken()) if (a === d) f.select();
2412
+ else {
2413
+ const C = U(t);
2414
+ C.select(), f.replace(C);
2415
+ }
2416
+ else f = f.spliceText(a, d - a, t, !0), f.getTextContent() === "" ? f.remove() : f.isComposing() && this.anchor.type === "text" && (this.anchor.offset -= t.length);
2417
+ for (let C = 1; C < h; C++) {
2418
+ const N = u[C], O = N.__key;
2419
+ p.has(O) || N.remove();
2420
+ }
2421
+ }
2422
+ }
2423
+ removeText() {
2424
+ if (this.isCollapsed()) return;
2425
+ const { anchor: t, focus: e } = this, r = this.getNodes(), s = this.isBackward() ? e : t, i = this.isBackward() ? t : e;
2426
+ let o = s.getNode(), l = i.getNode();
2427
+ const a = Ut(o, pt), c = Ut(l, pt);
2428
+ E(o) && o.isToken() && s.offset < o.getTextContentSize() && (s.offset = 0), i.offset > 0 && E(l) && l.isToken() && (i.offset = l.getTextContentSize());
2429
+ for (const h of r) qt(o, h) || qt(l, h) || h.getKey() === o.getKey() || h.getKey() === l.getKey() || h.remove();
2430
+ const u = (h, f) => {
2431
+ if (h.getTextContent() === "") h.remove();
2432
+ else if (f !== 0 && bt(h)) {
2433
+ const d = U(h.getTextContent());
2434
+ return d.setFormat(h.getFormat()), d.setStyle(h.getStyle()), h.replace(d);
2435
+ }
2436
+ };
2437
+ if (o === l && E(o)) {
2438
+ const h = Math.abs(e.offset - t.offset);
2439
+ return o.spliceText(s.offset, h, "", !0), void u(o, h);
2440
+ }
2441
+ if (E(o)) {
2442
+ const h = o.getTextContentSize() - s.offset;
2443
+ o.spliceText(s.offset, h, ""), o = u(o, h) || o;
2444
+ }
2445
+ E(l) && (l.spliceText(0, i.offset, ""), l = u(l, i.offset) || l), o.isAttached() && E(o) ? o.selectEnd() : l.isAttached() && E(l) && l.selectStart(), S(a) && S(c) && a !== c && (a.append(...c.getChildren()), c.remove(), i.set(s.key, s.offset, s.type));
2446
+ }
2447
+ formatText(t, e = null) {
2448
+ if (this.isCollapsed()) return this.toggleFormat(t), void $(null);
2449
+ const r = this.getNodes(), s = [];
2450
+ for (const b of r) E(b) && s.push(b);
2451
+ const i = (b) => {
2452
+ r.forEach((k) => {
2453
+ if (S(k)) {
2454
+ const v = k.getFormatFlags(t, b);
2455
+ k.setTextFormat(v);
2456
+ }
2457
+ });
2458
+ }, o = s.length;
2459
+ if (o === 0) return this.toggleFormat(t), $(null), void i(e);
2460
+ const l = this.anchor, a = this.focus, c = this.isBackward(), u = c ? a : l, h = c ? l : a;
2461
+ let f = 0, d = s[0], g = u.type === "element" ? 0 : u.offset;
2462
+ if (u.type === "text" && g === d.getTextContentSize() && (f = 1, d = s[1], g = 0), d == null) return;
2463
+ const _ = d.getFormatFlags(t, e);
2464
+ i(_);
2465
+ const p = o - 1;
2466
+ let m = s[p];
2467
+ const y = h.type === "text" ? h.offset : m.getTextContentSize();
2468
+ if (d.is(m)) {
2469
+ if (g === y) return;
2470
+ if (bt(d) || g === 0 && y === d.getTextContentSize()) d.setFormat(_);
2471
+ else {
2472
+ const b = d.splitText(g, y), k = g === 0 ? b[0] : b[1];
2473
+ k.setFormat(_), u.type === "text" && u.set(k.__key, 0, "text"), h.type === "text" && h.set(k.__key, y - g, "text");
2474
+ }
2475
+ return void (this.format = _);
2476
+ }
2477
+ g === 0 || bt(d) || ([, d] = d.splitText(g), g = 0), d.setFormat(_);
2478
+ const x = m.getFormatFlags(t, _);
2479
+ y > 0 && (y === m.getTextContentSize() || bt(m) || ([m] = m.splitText(y)), m.setFormat(x));
2480
+ for (let b = f + 1; b < p; b++) {
2481
+ const k = s[b], v = k.getFormatFlags(t, x);
2482
+ k.setFormat(v);
2483
+ }
2484
+ u.type === "text" && u.set(d.__key, g, "text"), h.type === "text" && h.set(m.__key, y, "text"), this.format = _ | x;
2485
+ }
2486
+ insertNodes(t) {
2487
+ if (t.length === 0) return;
2488
+ if (this.anchor.key === "root") {
2489
+ this.insertParagraph();
2490
+ const g = M();
2491
+ return P(g) || T(134), g.insertNodes(t);
2492
+ }
2493
+ const e = (this.isBackward() ? this.focus : this.anchor).getNode(), r = Ut(e, pt), s = t[t.length - 1];
2494
+ if (S(r) && "__language" in r) {
2495
+ if ("__language" in t[0]) this.insertText(t[0].getTextContent());
2496
+ else {
2497
+ const g = dn(this);
2498
+ r.splice(g, 0, t), s.selectEnd();
2499
+ }
2500
+ return;
2501
+ }
2502
+ if (!t.some((g) => (S(g) || I(g)) && !g.isInline())) {
2503
+ S(r) || T(211, e.constructor.name, e.getType());
2504
+ const g = dn(this);
2505
+ return r.splice(g, 0, t), void s.selectEnd();
2506
+ }
2507
+ const i = function(g) {
2508
+ const _ = St();
2509
+ let p = null;
2510
+ for (let m = 0; m < g.length; m++) {
2511
+ const y = g[m], x = Bt(y);
2512
+ if (x || I(y) && y.isInline() || S(y) && y.isInline() || E(y) || y.isParentRequired()) {
2513
+ if (p === null && (p = y.createParentElementNode(), _.append(p), x)) continue;
2514
+ p !== null && p.append(y);
2515
+ } else _.append(y), p = null;
2516
+ }
2517
+ return _;
2518
+ }(t), o = i.getLastDescendant(), l = i.getChildren(), a = !S(r) || !r.isEmpty() ? this.insertParagraph() : null, c = l[l.length - 1];
2519
+ let u = l[0];
2520
+ var h;
2521
+ S(h = u) && pt(h) && !h.isEmpty() && S(r) && (!r.isEmpty() || r.canMergeWhenEmpty()) && (S(r) || T(211, e.constructor.name, e.getType()), r.append(...u.getChildren()), u = l[1]), u && (r === null && T(212, e.constructor.name, e.getType()), function(g, _, p) {
2522
+ const m = _.getParentOrThrow().getLastChild();
2523
+ let y = _;
2524
+ const x = [_];
2525
+ for (; y !== m; ) y.getNextSibling() || T(140), y = y.getNextSibling(), x.push(y);
2526
+ let b = g;
2527
+ for (const k of x) b = b.insertAfter(k);
2528
+ }(r, u));
2529
+ const f = Ut(o, pt);
2530
+ a && S(f) && (a.canMergeWhenEmpty() || pt(c)) && (f.append(...a.getChildren()), a.remove()), S(r) && r.isEmpty() && r.remove(), o.selectEnd();
2531
+ const d = S(r) ? r.getLastChild() : null;
2532
+ Bt(d) && f !== r && d.remove();
2533
+ }
2534
+ insertParagraph() {
2535
+ if (this.anchor.key === "root") {
2536
+ const o = St();
2537
+ return rt().splice(this.anchor.offset, 0, [o]), o.select(), o;
2538
+ }
2539
+ const t = dn(this), e = Ut(this.anchor.getNode(), pt);
2540
+ S(e) || T(213);
2541
+ const r = e.getChildAtIndex(t), s = r ? [r, ...r.getNextSiblings()] : [], i = e.insertNewAfter(this, !1);
2542
+ return i ? (i.append(...s), i.selectStart(), i) : null;
2543
+ }
2544
+ insertLineBreak(t) {
2545
+ const e = ne();
2546
+ if (this.insertNodes([e]), t) {
2547
+ const r = e.getParentOrThrow(), s = e.getIndexWithinParent();
2548
+ r.select(s, s);
2549
+ }
2550
+ }
2551
+ extract() {
2552
+ const t = this.getNodes(), e = t.length, r = e - 1, s = this.anchor, i = this.focus;
2553
+ let o = t[0], l = t[r];
2554
+ const [a, c] = Fr(this);
2555
+ if (e === 0) return [];
2556
+ if (e === 1) {
2557
+ if (E(o) && !this.isCollapsed()) {
2558
+ const h = a > c ? c : a, f = a > c ? a : c, d = o.splitText(h, f), g = h === 0 ? d[0] : d[1];
2559
+ return g != null ? [g] : [];
2560
+ }
2561
+ return [o];
2562
+ }
2563
+ const u = s.isBefore(i);
2564
+ if (E(o)) {
2565
+ const h = u ? a : c;
2566
+ h === o.getTextContentSize() ? t.shift() : h !== 0 && ([, o] = o.splitText(h), t[0] = o);
2567
+ }
2568
+ if (E(l)) {
2569
+ const h = l.getTextContent().length, f = u ? c : a;
2570
+ f === 0 ? t.pop() : f !== h && ([l] = l.splitText(f), t[r] = l);
2571
+ }
2572
+ return t;
2573
+ }
2574
+ modify(t, e, r) {
2575
+ const s = this.focus, i = this.anchor, o = t === "move", l = _r(s, e);
2576
+ if (I(l) && !l.isIsolated()) {
2577
+ if (o && l.isKeyboardSelectable()) {
2578
+ const d = Dr();
2579
+ return d.add(l.__key), void ut(d);
2580
+ }
2581
+ const f = e ? l.getPreviousSibling() : l.getNextSibling();
2582
+ if (E(f)) {
2583
+ const d = f.__key, g = e ? f.getTextContent().length : 0;
2584
+ return s.set(d, g, "text"), void (o && i.set(d, g, "text"));
2585
+ }
2586
+ {
2587
+ const d = l.getParentOrThrow();
2588
+ let g, _;
2589
+ return S(f) ? (_ = f.__key, g = e ? f.getChildrenSize() : 0) : (g = l.getIndexWithinParent(), _ = d.__key, e || g++), s.set(_, g, "element"), void (o && i.set(_, g, "element"));
2590
+ }
2591
+ }
2592
+ const a = A(), c = ft(a._window);
2593
+ if (!c) return;
2594
+ const u = a._blockCursorElement, h = a._rootElement;
2595
+ if (h === null || u === null || !S(l) || l.isInline() || l.canBeEmpty() || $n(u, a, h), function(f, d, g, _) {
2596
+ f.modify(d, g, _);
2597
+ }(c, t, e ? "backward" : "forward", r), c.rangeCount > 0) {
2598
+ const f = c.getRangeAt(0), d = this.anchor.getNode(), g = Z(d) ? d : Di(d);
2599
+ if (this.applyDOMRange(f), this.dirty = !0, !o) {
2600
+ const _ = this.getNodes(), p = [];
2601
+ let m = !1;
2602
+ for (let y = 0; y < _.length; y++) {
2603
+ const x = _[y];
2604
+ qt(x, g) ? p.push(x) : m = !0;
2605
+ }
2606
+ if (m && p.length > 0) if (e) {
2607
+ const y = p[0];
2608
+ S(y) ? y.selectStart() : y.getParentOrThrow().selectStart();
2609
+ } else {
2610
+ const y = p[p.length - 1];
2611
+ S(y) ? y.selectEnd() : y.getParentOrThrow().selectEnd();
2612
+ }
2613
+ c.anchorNode === f.startContainer && c.anchorOffset === f.startOffset || function(y) {
2614
+ const x = y.focus, b = y.anchor, k = b.key, v = b.offset, F = b.type;
2615
+ yt(b, x.key, x.offset, x.type), yt(x, k, v, F), y._cachedNodes = null;
2616
+ }(this);
2617
+ }
2618
+ }
2619
+ }
2620
+ forwardDeletion(t, e, r) {
2621
+ if (!r && (t.type === "element" && S(e) && t.offset === e.getChildrenSize() || t.type === "text" && t.offset === e.getTextContentSize())) {
2622
+ const s = e.getParent(), i = e.getNextSibling() || (s === null ? null : s.getNextSibling());
2623
+ if (S(i) && i.isShadowRoot()) return !0;
2624
+ }
2625
+ return !1;
2626
+ }
2627
+ deleteCharacter(t) {
2628
+ const e = this.isCollapsed();
2629
+ if (this.isCollapsed()) {
2630
+ const r = this.anchor;
2631
+ let s = r.getNode();
2632
+ if (this.forwardDeletion(r, s, t)) return;
2633
+ const i = this.focus, o = _r(i, t);
2634
+ if (I(o) && !o.isIsolated()) {
2635
+ if (o.isKeyboardSelectable() && S(s) && s.getChildrenSize() === 0) {
2636
+ s.remove();
2637
+ const l = Dr();
2638
+ l.add(o.__key), ut(l);
2639
+ } else
2640
+ o.remove(), A().dispatchCommand(Nn, void 0);
2641
+ return;
2642
+ }
2643
+ if (!t && S(o) && S(s) && s.isEmpty()) return s.remove(), void o.selectStart();
2644
+ if (this.modify("extend", t, "character"), this.isCollapsed()) {
2645
+ if (t && r.offset === 0 && (r.type === "element" ? r.getNode() : r.getNode().getParentOrThrow()).collapseAtStart(this))
2646
+ return;
2647
+ } else {
2648
+ const l = i.type === "text" ? i.getNode() : null;
2649
+ if (s = r.type === "text" ? r.getNode() : null, l !== null && l.isSegmented()) {
2650
+ const a = i.offset, c = l.getTextContentSize();
2651
+ if (l.is(s) || t && a !== c || !t && a !== 0) return void Pr(l, t, a);
2652
+ } else if (s !== null && s.isSegmented()) {
2653
+ const a = r.offset, c = s.getTextContentSize();
2654
+ if (s.is(l) || t && a !== 0 || !t && a !== c) return void Pr(s, t, a);
2655
+ }
2656
+ (function(a, c) {
2657
+ const u = a.anchor, h = a.focus, f = u.getNode(), d = h.getNode();
2658
+ if (f === d && u.type === "text" && h.type === "text") {
2659
+ const g = u.offset, _ = h.offset, p = g < _, m = p ? g : _, y = p ? _ : g, x = y - 1;
2660
+ m !== x && (ls(f.getTextContent().slice(m, y)) || (c ? h.offset = x : u.offset = x));
2661
+ }
2662
+ })(this, t);
2663
+ }
2664
+ }
2665
+ if (this.removeText(), t && !e && this.isCollapsed() && this.anchor.type === "element" && this.anchor.offset === 0) {
2666
+ const r = this.anchor.getNode();
2667
+ r.isEmpty() && Z(r.getParent()) && r.getIndexWithinParent() === 0 && r.collapseAtStart(this);
2668
+ }
2669
+ }
2670
+ deleteLine(t) {
2671
+ if (this.isCollapsed()) {
2672
+ const e = this.anchor.type === "element";
2673
+ if (e && this.insertText(" "), this.modify("extend", t, "lineboundary"), this.isCollapsed() && this.anchor.offset === 0 && this.modify("extend", t, "character"), e) {
2674
+ const r = t ? this.anchor : this.focus;
2675
+ r.set(r.key, r.offset + 1, r.type);
2676
+ }
2677
+ }
2678
+ this.removeText();
2679
+ }
2680
+ deleteWord(t) {
2681
+ if (this.isCollapsed()) {
2682
+ const e = this.anchor, r = e.getNode();
2683
+ if (this.forwardDeletion(e, r, t)) return;
2684
+ this.modify("extend", t, "word");
2685
+ }
2686
+ this.removeText();
2687
+ }
2688
+ isBackward() {
2689
+ return this.focus.isBefore(this.anchor);
2690
+ }
2691
+ getStartEndPoints() {
2692
+ return [this.anchor, this.focus];
2693
+ }
2694
+ }
2695
+ function Hn(n) {
2696
+ return n instanceof qe;
2697
+ }
2698
+ function Er(n) {
2699
+ const t = n.offset;
2700
+ if (n.type === "text") return t;
2701
+ const e = n.getNode();
2702
+ return t === e.getChildrenSize() ? e.getTextContent().length : 0;
2703
+ }
2704
+ function Fr(n) {
2705
+ const t = n.getStartEndPoints();
2706
+ if (t === null) return [0, 0];
2707
+ const [e, r] = t;
2708
+ return e.type === "element" && r.type === "element" && e.key === r.key && e.offset === r.offset ? [0, 0] : [Er(e), Er(r)];
2709
+ }
2710
+ function Pr(n, t, e) {
2711
+ const r = n, s = r.getTextContent().split(/(?=\s)/g), i = s.length;
2712
+ let o = 0, l = 0;
2713
+ for (let c = 0; c < i; c++) {
2714
+ const u = c === i - 1;
2715
+ if (l = o, o += s[c].length, t && o === e || o > e || u) {
2716
+ s.splice(c, 1), u && (l = void 0);
2717
+ break;
2718
+ }
2719
+ }
2720
+ const a = s.join("").trim();
2721
+ a === "" ? r.remove() : (r.setTextContent(a), r.select(l, l));
2722
+ }
2723
+ function Or(n, t, e, r) {
2724
+ let s, i = t;
2725
+ if (X(n)) {
2726
+ let o = !1;
2727
+ const l = n.childNodes, a = l.length, c = r._blockCursorElement;
2728
+ i === a && (o = !0, i = a - 1);
2729
+ let u = l[i], h = !1;
2730
+ if (u === c) u = l[i + 1], h = !0;
2731
+ else if (c !== null) {
2732
+ const f = c.parentNode;
2733
+ n === f && t > Array.prototype.indexOf.call(f.children, c) && i--;
2734
+ }
2735
+ if (s = Mt(u), E(s)) i = cr(s, o);
2736
+ else {
2737
+ let f = Mt(n);
2738
+ if (f === null) return null;
2739
+ if (S(f)) {
2740
+ const d = r.getElementByKey(f.getKey());
2741
+ d === null && T(214), [f, i] = f.getDOMSlot(d).resolveChildIndex(f, d, n, t), S(f) || T(215), o && i >= f.getChildrenSize() && (i = Math.max(0, f.getChildrenSize() - 1));
2742
+ let _ = f.getChildAtIndex(i);
2743
+ if (S(_) && function(p, m, y) {
2744
+ const x = p.getParent();
2745
+ return y === null || x === null || !x.canBeEmpty() || x !== y.getNode();
2746
+ }(_, 0, e)) {
2747
+ const p = o ? _.getLastDescendant() : _.getFirstDescendant();
2748
+ p === null ? f = _ : (_ = p, f = S(_) ? _ : _.getParentOrThrow()), i = 0;
2749
+ }
2750
+ E(_) ? (s = _, f = null, i = cr(_, o)) : _ !== f && o && !h && (S(f) || T(216), i = Math.min(f.getChildrenSize(), i + 1));
2751
+ } else {
2752
+ const d = f.getIndexWithinParent();
2753
+ i = t === 0 && I(f) && Mt(n) === f ? d : d + 1, f = f.getParentOrThrow();
2754
+ }
2755
+ if (S(f)) return ot(f.__key, i, "element");
2756
+ }
2757
+ } else s = Mt(n);
2758
+ return E(s) ? ot(s.__key, i, "text") : null;
2759
+ }
2760
+ function Lr(n, t, e) {
2761
+ const r = n.offset, s = n.getNode();
2762
+ if (r === 0) {
2763
+ const i = s.getPreviousSibling(), o = s.getParent();
2764
+ if (t) {
2765
+ if ((e || !t) && i === null && S(o) && o.isInline()) {
2766
+ const l = o.getPreviousSibling();
2767
+ E(l) && (n.key = l.__key, n.offset = l.getTextContent().length);
2768
+ }
2769
+ } else S(i) && !e && i.isInline() ? (n.key = i.__key, n.offset = i.getChildrenSize(), n.type = "element") : E(i) && (n.key = i.__key, n.offset = i.getTextContent().length);
2770
+ } else if (r === s.getTextContent().length) {
2771
+ const i = s.getNextSibling(), o = s.getParent();
2772
+ if (t && S(i) && i.isInline()) n.key = i.__key, n.offset = 0, n.type = "element";
2773
+ else if ((e || t) && i === null && S(o) && o.isInline() && !o.canInsertTextAfter()) {
2774
+ const l = o.getNextSibling();
2775
+ E(l) && (n.key = l.__key, n.offset = 0);
2776
+ }
2777
+ }
2778
+ }
2779
+ function Es(n, t, e) {
2780
+ if (n.type === "text" && t.type === "text") {
2781
+ const r = n.isBefore(t), s = n.is(t);
2782
+ Lr(n, r, s), Lr(t, !r, s), s && (t.key = n.key, t.offset = n.offset, t.type = n.type);
2783
+ const i = A();
2784
+ if (i.isComposing() && i._compositionKey !== n.key && P(e)) {
2785
+ const o = e.anchor, l = e.focus;
2786
+ yt(n, o.key, o.offset, o.type), yt(t, l.key, l.offset, l.type);
2787
+ }
2788
+ }
2789
+ }
2790
+ function Fs(n, t, e, r, s, i) {
2791
+ if (n === null || e === null || !Re(s, n, e)) return null;
2792
+ const o = Or(n, t, P(i) ? i.anchor : null, s);
2793
+ if (o === null) return null;
2794
+ const l = Or(e, r, P(i) ? i.focus : null, s);
2795
+ if (l === null) return null;
2796
+ if (o.type === "element" && l.type === "element") {
2797
+ const a = Mt(n), c = Mt(e);
2798
+ if (I(a) && I(c)) return null;
2799
+ }
2800
+ return Es(o, l, i), [o, l];
2801
+ }
2802
+ function ko(n) {
2803
+ return S(n) && !n.isInline();
2804
+ }
2805
+ function Ps(n, t, e, r, s, i) {
2806
+ const o = Tt(), l = new Ot(ot(n, t, s), ot(e, r, i), 0, "");
2807
+ return l.dirty = !0, o._selection = l, l;
2808
+ }
2809
+ function bo() {
2810
+ const n = ot("root", 0, "element"), t = ot("root", 0, "element");
2811
+ return new Ot(n, t, 0, "");
2812
+ }
2813
+ function Dr() {
2814
+ return new qe(/* @__PURE__ */ new Set());
2815
+ }
2816
+ function wo(n, t) {
2817
+ return Ge(null, n, t, null);
2818
+ }
2819
+ function Ge(n, t, e, r) {
2820
+ const s = e._window;
2821
+ if (s === null) return null;
2822
+ const i = r || s.event, o = i ? i.type : void 0, l = o === "selectionchange", a = !_n && (l || o === "beforeinput" || o === "compositionstart" || o === "compositionend" || o === "click" && i && i.detail === 3 || o === "drop" || o === void 0);
2823
+ let c, u, h, f;
2824
+ if (P(n) && !a) return n.clone();
2825
+ if (t === null) return null;
2826
+ if (c = t.anchorNode, u = t.focusNode, h = t.anchorOffset, f = t.focusOffset, l && P(n) && !Re(e, c, u)) return n.clone();
2827
+ const d = Fs(c, h, u, f, e, n);
2828
+ if (d === null) return null;
2829
+ const [g, _] = d;
2830
+ return new Ot(g, _, P(n) ? n.format : 0, P(n) ? n.style : "");
2831
+ }
2832
+ function M() {
2833
+ return Tt()._selection;
2834
+ }
2835
+ function ae() {
2836
+ return A()._editorState._selection;
2837
+ }
2838
+ function Ae(n, t, e, r = 1) {
2839
+ const s = n.anchor, i = n.focus, o = s.getNode(), l = i.getNode();
2840
+ if (!t.is(o) && !t.is(l)) return;
2841
+ const a = t.__key;
2842
+ if (n.isCollapsed()) {
2843
+ const c = s.offset;
2844
+ if (e <= c && r > 0 || e < c && r < 0) {
2845
+ const u = Math.max(0, c + r);
2846
+ s.set(a, u, "element"), i.set(a, u, "element"), Mr(n);
2847
+ }
2848
+ } else {
2849
+ const c = n.isBackward(), u = c ? i : s, h = u.getNode(), f = c ? s : i, d = f.getNode();
2850
+ if (t.is(h)) {
2851
+ const g = u.offset;
2852
+ (e <= g && r > 0 || e < g && r < 0) && u.set(a, Math.max(0, g + r), "element");
2853
+ }
2854
+ if (t.is(d)) {
2855
+ const g = f.offset;
2856
+ (e <= g && r > 0 || e < g && r < 0) && f.set(a, Math.max(0, g + r), "element");
2857
+ }
2858
+ }
2859
+ Mr(n);
2860
+ }
2861
+ function Mr(n) {
2862
+ const t = n.anchor, e = t.offset, r = n.focus, s = r.offset, i = t.getNode(), o = r.getNode();
2863
+ if (n.isCollapsed()) {
2864
+ if (!S(i)) return;
2865
+ const l = i.getChildrenSize(), a = e >= l, c = a ? i.getChildAtIndex(l - 1) : i.getChildAtIndex(e);
2866
+ if (E(c)) {
2867
+ let u = 0;
2868
+ a && (u = c.getTextContentSize()), t.set(c.__key, u, "text"), r.set(c.__key, u, "text");
2869
+ }
2870
+ } else {
2871
+ if (S(i)) {
2872
+ const l = i.getChildrenSize(), a = e >= l, c = a ? i.getChildAtIndex(l - 1) : i.getChildAtIndex(e);
2873
+ if (E(c)) {
2874
+ let u = 0;
2875
+ a && (u = c.getTextContentSize()), t.set(c.__key, u, "text");
2876
+ }
2877
+ }
2878
+ if (S(o)) {
2879
+ const l = o.getChildrenSize(), a = s >= l, c = a ? o.getChildAtIndex(l - 1) : o.getChildAtIndex(s);
2880
+ if (E(c)) {
2881
+ let u = 0;
2882
+ a && (u = c.getTextContentSize()), r.set(c.__key, u, "text");
2883
+ }
2884
+ }
2885
+ }
2886
+ }
2887
+ function Be(n, t, e, r, s) {
2888
+ let i = null, o = 0, l = null;
2889
+ r !== null ? (i = r.__key, E(r) ? (o = r.getTextContentSize(), l = "text") : S(r) && (o = r.getChildrenSize(), l = "element")) : s !== null && (i = s.__key, E(s) ? l = "text" : S(s) && (l = "element")), i !== null && l !== null ? n.set(i, o, l) : (o = t.getIndexWithinParent(), o === -1 && (o = e.getChildrenSize()), n.set(e.__key, o, "element"));
2890
+ }
2891
+ function Ir(n, t, e, r, s) {
2892
+ n.type === "text" ? (n.key = e, t || (n.offset += s)) : n.offset > r.getIndexWithinParent() && (n.offset -= 1);
2893
+ }
2894
+ function eo(n, t, e, r, s, i, o) {
2895
+ const l = r.anchorNode, a = r.focusNode, c = r.anchorOffset, u = r.focusOffset, h = document.activeElement;
2896
+ if (s.has("collaboration") && h !== i || h !== null && es(h)) return;
2897
+ if (!P(t)) return void (n !== null && Re(e, l, a) && r.removeAllRanges());
2898
+ const f = t.anchor, d = t.focus, g = f.key, _ = d.key, p = Oe(e, g), m = Oe(e, _), y = f.offset, x = d.offset, b = t.format, k = t.style, v = t.isCollapsed();
2899
+ let F = p, C = m, N = !1;
2900
+ if (f.type === "text") {
2901
+ F = Ee(p);
2902
+ const z = f.getNode();
2903
+ N = z.getFormat() !== b || z.getStyle() !== k;
2904
+ } else P(n) && n.anchor.type === "text" && (N = !0);
2905
+ var O, D, B, L, R;
2906
+ if (d.type === "text" && (C = Ee(m)), F !== null && C !== null && (v && (n === null || N || P(n) && (n.format !== b || n.style !== k)) && (O = b, D = k, B = y, L = g, R = performance.now(), Ss = [O, D, B, L, R]), c !== y || u !== x || l !== F || a !== C || r.type === "Range" && v || (h !== null && i.contains(h) || i.focus({ preventScroll: !0 }), f.type === "element"))) {
2907
+ try {
2908
+ r.setBaseAndExtent(F, y, C, x);
2909
+ } catch {
2910
+ }
2911
+ if (!s.has("skip-scroll-into-view") && t.isCollapsed() && i !== null && i === document.activeElement) {
2912
+ const z = P(t) && t.anchor.type === "element" ? F.childNodes[y] || null : r.rangeCount > 0 ? r.getRangeAt(0) : null;
2913
+ if (z !== null) {
2914
+ let ht;
2915
+ if (z instanceof Text) {
2916
+ const Lt = document.createRange();
2917
+ Lt.selectNode(z), ht = Lt.getBoundingClientRect();
2918
+ } else ht = z.getBoundingClientRect();
2919
+ (function(Lt, de, Qn) {
2920
+ const Ze = fs(Qn), Xn = Un(Ze);
2921
+ if (Ze === null || Xn === null) return;
2922
+ let { top: tn, bottom: en } = de, he = 0, ge = 0, gt = Qn;
2923
+ for (; gt !== null; ) {
2924
+ const nn = gt === Ze.body;
2925
+ if (nn) he = 0, ge = $e(Lt).innerHeight;
2926
+ else {
2927
+ const _e = gt.getBoundingClientRect();
2928
+ he = _e.top, ge = _e.bottom;
2929
+ }
2930
+ let Rt = 0;
2931
+ if (tn < he ? Rt = -(he - tn) : en > ge && (Rt = en - ge), Rt !== 0) if (nn) Xn.scrollBy(0, Rt);
2932
+ else {
2933
+ const _e = gt.scrollTop;
2934
+ gt.scrollTop += Rt;
2935
+ const Yn = gt.scrollTop - _e;
2936
+ tn -= Yn, en -= Yn;
2937
+ }
2938
+ if (nn) break;
2939
+ gt = se(gt);
2940
+ }
2941
+ })(e, ht, i);
2942
+ }
2943
+ }
2944
+ kn = !0;
2945
+ }
2946
+ }
2947
+ function No(n) {
2948
+ let t = M() || ae();
2949
+ t === null && (t = rt().selectEnd()), t.insertNodes(n);
2950
+ }
2951
+ function dn(n) {
2952
+ let t = n;
2953
+ n.isCollapsed() || t.removeText();
2954
+ const e = M();
2955
+ P(e) && (t = e), P(t) || T(161);
2956
+ const r = t.anchor;
2957
+ let s = r.getNode(), i = r.offset;
2958
+ for (; !pt(s); ) [s, i] = no(s, i);
2959
+ return i;
2960
+ }
2961
+ function no(n, t) {
2962
+ const e = n.getParent();
2963
+ if (!e) {
2964
+ const s = St();
2965
+ return rt().append(s), s.select(), [rt(), 0];
2966
+ }
2967
+ if (E(n)) {
2968
+ const s = n.splitText(t);
2969
+ if (s.length === 0) return [e, n.getIndexWithinParent()];
2970
+ const i = t === 0 ? 0 : 1;
2971
+ return [e, s[0].getIndexWithinParent() + i];
2972
+ }
2973
+ if (!S(n) || t === 0) return [e, n.getIndexWithinParent()];
2974
+ const r = n.getChildAtIndex(t);
2975
+ if (r) {
2976
+ const s = new Ot(ot(n.__key, t, "element"), ot(n.__key, t, "element"), 0, ""), i = n.insertNewAfter(s);
2977
+ i && i.append(r, ...r.getNextSiblings());
2978
+ }
2979
+ return [e, n.getIndexWithinParent() + 1];
2980
+ }
2981
+ let K = null, J = null, Q = !1, hn = !1, ve = 0;
2982
+ const Ar = { characterData: !0, childList: !0, subtree: !0 };
2983
+ function ce() {
2984
+ return Q || K !== null && K._readOnly;
2985
+ }
2986
+ function G() {
2987
+ Q && T(13);
2988
+ }
2989
+ function Os() {
2990
+ ve > 99 && T(14);
2991
+ }
2992
+ function Tt() {
2993
+ return K === null && T(195, Ls()), K;
2994
+ }
2995
+ function A() {
2996
+ return J === null && T(196, Ls()), J;
2997
+ }
2998
+ function Ls() {
2999
+ let n = 0;
3000
+ const t = /* @__PURE__ */ new Set(), e = Ye.version;
3001
+ if (typeof window < "u") for (const s of document.querySelectorAll("[contenteditable]")) {
3002
+ const i = Ke(s);
3003
+ if (Bn(i)) n++;
3004
+ else if (i) {
3005
+ let o = String(i.constructor.version || "<0.17.1");
3006
+ o === e && (o += " (separately built, likely a bundler configuration issue)"), t.add(o);
3007
+ }
3008
+ }
3009
+ let r = ` Detected on the page: ${n} compatible editor(s) with version ${e}`;
3010
+ return t.size && (r += ` and incompatible editors with versions ${Array.from(t).join(", ")}`), r;
3011
+ }
3012
+ function ro() {
3013
+ return J;
3014
+ }
3015
+ function Br(n, t, e) {
3016
+ const r = t.__type, s = function(l, a) {
3017
+ const c = l._nodes.get(a);
3018
+ return c === void 0 && T(30, a), c;
3019
+ }(n, r);
3020
+ let i = e.get(r);
3021
+ i === void 0 && (i = Array.from(s.transforms), e.set(r, i));
3022
+ const o = i.length;
3023
+ for (let l = 0; l < o && (i[l](t), t.isAttached()); l++) ;
3024
+ }
3025
+ function zr(n, t) {
3026
+ return n !== void 0 && n.__key !== t && n.isAttached();
3027
+ }
3028
+ function Ds(n, t) {
3029
+ if (!t) return;
3030
+ const e = n._updateTags;
3031
+ let r = t;
3032
+ Array.isArray(t) || (r = [t]);
3033
+ for (const s of r) e.add(s);
3034
+ }
3035
+ function Eo(n) {
3036
+ return qn(n, A()._nodes);
3037
+ }
3038
+ function qn(n, t) {
3039
+ const e = n.type, r = t.get(e);
3040
+ r === void 0 && T(17, e);
3041
+ const s = r.klass;
3042
+ n.type !== s.getType() && T(18, s.name);
3043
+ const i = s.importJSON(n), o = n.children;
3044
+ if (S(i) && Array.isArray(o)) for (let l = 0; l < o.length; l++) {
3045
+ const a = qn(o[l], t);
3046
+ i.append(a);
3047
+ }
3048
+ return i;
3049
+ }
3050
+ function Wr(n, t, e) {
3051
+ const r = K, s = Q, i = J;
3052
+ K = t, Q = !0, J = n;
3053
+ try {
3054
+ return e();
3055
+ } finally {
3056
+ K = r, Q = s, J = i;
3057
+ }
3058
+ }
3059
+ function xt(n, t) {
3060
+ const e = n._pendingEditorState, r = n._rootElement, s = n._headless || r === null;
3061
+ if (e === null) return;
3062
+ const i = n._editorState, o = i._selection, l = e._selection, a = n._dirtyType !== Et, c = K, u = Q, h = J, f = n._updating, d = n._observer;
3063
+ let g = null;
3064
+ if (n._pendingEditorState = null, n._editorState = e, !s && a && d !== null) {
3065
+ J = n, K = e, Q = !1, n._updating = !0;
3066
+ try {
3067
+ const v = n._dirtyType, F = n._dirtyElements, C = n._dirtyLeaves;
3068
+ d.disconnect(), g = ji(i, e, n, v, F, C);
3069
+ } catch (v) {
3070
+ if (v instanceof Error && n._onError(v), hn) throw v;
3071
+ return zs(n, null, r, e), ts(n), n._dirtyType = zt, hn = !0, xt(n, i), void (hn = !1);
3072
+ } finally {
3073
+ d.observe(r, Ar), n._updating = f, K = c, Q = u, J = h;
3074
+ }
3075
+ }
3076
+ e._readOnly || (e._readOnly = !0);
3077
+ const _ = n._dirtyLeaves, p = n._dirtyElements, m = n._normalizedNodes, y = n._updateTags, x = n._deferred;
3078
+ a && (n._dirtyType = Et, n._cloneNotNeeded.clear(), n._dirtyLeaves = /* @__PURE__ */ new Set(), n._dirtyElements = /* @__PURE__ */ new Map(), n._normalizedNodes = /* @__PURE__ */ new Set(), n._updateTags = /* @__PURE__ */ new Set()), function(v, F) {
3079
+ const C = v._decorators;
3080
+ let N = v._pendingDecorators || C;
3081
+ const O = F._nodeMap;
3082
+ let D;
3083
+ for (D in N) O.has(D) || (N === C && (N = is(v)), delete N[D]);
3084
+ }(n, e);
3085
+ const b = s ? null : ft(n._window);
3086
+ if (n._editable && b !== null && (a || l === null || l.dirty) && r !== null && !y.has("skip-dom-selection")) {
3087
+ J = n, K = e;
3088
+ try {
3089
+ if (d !== null && d.disconnect(), a || l === null || l.dirty) {
3090
+ const v = n._blockCursorElement;
3091
+ v !== null && $n(v, n, r), eo(o, l, n, b, y, r);
3092
+ }
3093
+ Ii(n, r, l), d !== null && d.observe(r, Ar);
3094
+ } finally {
3095
+ J = h, K = c;
3096
+ }
3097
+ }
3098
+ g !== null && function(v, F, C, N, O) {
3099
+ const D = Array.from(v._listeners.mutation), B = D.length;
3100
+ for (let L = 0; L < B; L++) {
3101
+ const [R, z] = D[L], ht = F.get(z);
3102
+ ht !== void 0 && R(ht, { dirtyLeaves: N, prevEditorState: O, updateTags: C });
3103
+ }
3104
+ }(n, g, y, _, i), P(l) || l === null || o !== null && o.is(l) || n.dispatchCommand(Nn, void 0);
3105
+ const k = n._pendingDecorators;
3106
+ k !== null && (n._decorators = k, n._pendingDecorators = null, Xt("decorator", n, !0, k)), function(v, F, C) {
3107
+ const N = ar(F), O = ar(C);
3108
+ N !== O && Xt("textcontent", v, !0, O);
3109
+ }(n, t || i, e), Xt("update", n, !0, { dirtyElements: p, dirtyLeaves: _, editorState: e, normalizedNodes: m, prevEditorState: t || i, tags: y }), function(v, F) {
3110
+ if (v._deferred = [], F.length !== 0) {
3111
+ const C = v._updating;
3112
+ v._updating = !0;
3113
+ try {
3114
+ for (let N = 0; N < F.length; N++) F[N]();
3115
+ } finally {
3116
+ v._updating = C;
3117
+ }
3118
+ }
3119
+ }(n, x), function(v) {
3120
+ const F = v._updates;
3121
+ if (F.length !== 0) {
3122
+ const C = F.shift();
3123
+ if (C) {
3124
+ const [N, O] = C;
3125
+ Is(v, N, O);
3126
+ }
3127
+ }
3128
+ }(n);
3129
+ }
3130
+ function Xt(n, t, e, ...r) {
3131
+ const s = t._updating;
3132
+ t._updating = e;
3133
+ try {
3134
+ const i = Array.from(t._listeners[n]);
3135
+ for (let o = 0; o < i.length; o++) i[o].apply(null, r);
3136
+ } finally {
3137
+ t._updating = s;
3138
+ }
3139
+ }
3140
+ function Ms(n, t, e) {
3141
+ if (n._updating === !1 || J !== n) {
3142
+ let s = !1;
3143
+ return n.update(() => {
3144
+ s = Ms(n, t, e);
3145
+ }), s;
3146
+ }
3147
+ const r = Wn(n);
3148
+ for (let s = 4; s >= 0; s--) for (let i = 0; i < r.length; i++) {
3149
+ const o = r[i]._commands.get(t);
3150
+ if (o !== void 0) {
3151
+ const l = o[s];
3152
+ if (l !== void 0) {
3153
+ const a = Array.from(l), c = a.length;
3154
+ for (let u = 0; u < c; u++) if (a[u](e, n) === !0) return !0;
3155
+ }
3156
+ }
3157
+ }
3158
+ return !1;
3159
+ }
3160
+ function Rr(n, t) {
3161
+ const e = n._updates;
3162
+ let r = t || !1;
3163
+ for (; e.length !== 0; ) {
3164
+ const s = e.shift();
3165
+ if (s) {
3166
+ const [i, o] = s;
3167
+ let l;
3168
+ if (o !== void 0) {
3169
+ if (l = o.onUpdate, o.skipTransforms && (r = !0), o.discrete) {
3170
+ const a = n._pendingEditorState;
3171
+ a === null && T(191), a._flushSync = !0;
3172
+ }
3173
+ l && n._deferred.push(l), Ds(n, o.tag);
3174
+ }
3175
+ i();
3176
+ }
3177
+ }
3178
+ return r;
3179
+ }
3180
+ function Is(n, t, e) {
3181
+ const r = n._updateTags;
3182
+ let s, i = !1, o = !1;
3183
+ e !== void 0 && (s = e.onUpdate, Ds(n, e.tag), i = e.skipTransforms || !1, o = e.discrete || !1), s && n._deferred.push(s);
3184
+ const l = n._editorState;
3185
+ let a = n._pendingEditorState, c = !1;
3186
+ (a === null || a._readOnly) && (a = n._pendingEditorState = As(a || l), c = !0), a._flushSync = o;
3187
+ const u = K, h = Q, f = J, d = n._updating;
3188
+ K = a, Q = !1, n._updating = !0, J = n;
3189
+ try {
3190
+ c && (n._headless ? l._selection !== null && (a._selection = l._selection.clone()) : a._selection = function(m) {
3191
+ const y = m.getEditorState()._selection, x = ft(m._window);
3192
+ return P(y) || y == null ? Ge(y, x, m, null) : y.clone();
3193
+ }(n));
3194
+ const _ = n._compositionKey;
3195
+ t(), i = Rr(n, i), function(m, y) {
3196
+ const x = y.getEditorState()._selection, b = m._selection;
3197
+ if (P(b)) {
3198
+ const k = b.anchor, v = b.focus;
3199
+ let F;
3200
+ if (k.type === "text" && (F = k.getNode(), F.selectionTransform(x, b)), v.type === "text") {
3201
+ const C = v.getNode();
3202
+ F !== C && C.selectionTransform(x, b);
3203
+ }
3204
+ }
3205
+ }(a, n), n._dirtyType !== Et && (i ? function(m, y) {
3206
+ const x = y._dirtyLeaves, b = m._nodeMap;
3207
+ for (const k of x) {
3208
+ const v = b.get(k);
3209
+ E(v) && v.isAttached() && v.isSimpleText() && !v.isUnmergeable() && ir(v);
3210
+ }
3211
+ }(a, n) : function(m, y) {
3212
+ const x = y._dirtyLeaves, b = y._dirtyElements, k = m._nodeMap, v = mt(), F = /* @__PURE__ */ new Map();
3213
+ let C = x, N = C.size, O = b, D = O.size;
3214
+ for (; N > 0 || D > 0; ) {
3215
+ if (N > 0) {
3216
+ y._dirtyLeaves = /* @__PURE__ */ new Set();
3217
+ for (const B of C) {
3218
+ const L = k.get(B);
3219
+ E(L) && L.isAttached() && L.isSimpleText() && !L.isUnmergeable() && ir(L), L !== void 0 && zr(L, v) && Br(y, L, F), x.add(B);
3220
+ }
3221
+ if (C = y._dirtyLeaves, N = C.size, N > 0) {
3222
+ ve++;
3223
+ continue;
3224
+ }
3225
+ }
3226
+ y._dirtyLeaves = /* @__PURE__ */ new Set(), y._dirtyElements = /* @__PURE__ */ new Map();
3227
+ for (const B of O) {
3228
+ const L = B[0], R = B[1];
3229
+ if (L !== "root" && !R) continue;
3230
+ const z = k.get(L);
3231
+ z !== void 0 && zr(z, v) && Br(y, z, F), b.set(L, R);
3232
+ }
3233
+ C = y._dirtyLeaves, N = C.size, O = y._dirtyElements, D = O.size, ve++;
3234
+ }
3235
+ y._dirtyLeaves = x, y._dirtyElements = b;
3236
+ }(a, n), Rr(n), function(m, y, x, b) {
3237
+ const k = m._nodeMap, v = y._nodeMap, F = [];
3238
+ for (const [C] of b) {
3239
+ const N = v.get(C);
3240
+ N !== void 0 && (N.isAttached() || (S(N) && ds(N, C, k, v, F, b), k.has(C) || b.delete(C), F.push(C)));
3241
+ }
3242
+ for (const C of F) v.delete(C);
3243
+ for (const C of x) {
3244
+ const N = v.get(C);
3245
+ N === void 0 || N.isAttached() || (k.has(C) || x.delete(C), v.delete(C));
3246
+ }
3247
+ }(l, a, n._dirtyLeaves, n._dirtyElements)), _ !== n._compositionKey && (a._flushSync = !0);
3248
+ const p = a._selection;
3249
+ if (P(p)) {
3250
+ const m = a._nodeMap, y = p.anchor.key, x = p.focus.key;
3251
+ m.get(y) !== void 0 && m.get(x) !== void 0 || T(19);
3252
+ } else Hn(p) && p._nodes.size === 0 && (a._selection = null);
3253
+ } catch (_) {
3254
+ return _ instanceof Error && n._onError(_), n._pendingEditorState = l, n._dirtyType = zt, n._cloneNotNeeded.clear(), n._dirtyLeaves = /* @__PURE__ */ new Set(), n._dirtyElements.clear(), void xt(n);
3255
+ } finally {
3256
+ K = u, Q = h, J = f, n._updating = d, ve = 0;
3257
+ }
3258
+ n._dirtyType !== Et || n._deferred.length > 0 || function(_, p) {
3259
+ const m = p.getEditorState()._selection, y = _._selection;
3260
+ if (y !== null) {
3261
+ if (y.dirty || !y.is(m)) return !0;
3262
+ } else if (m !== null) return !0;
3263
+ return !1;
3264
+ }(a, n) ? a._flushSync ? (a._flushSync = !1, xt(n)) : c && Pi(() => {
3265
+ xt(n);
3266
+ }) : (a._flushSync = !1, c && (r.clear(), n._deferred = [], n._pendingEditorState = null));
3267
+ }
3268
+ function Y(n, t, e) {
3269
+ n._updating ? n._updates.push([t, e]) : Is(n, t, e);
3270
+ }
3271
+ class Yt {
3272
+ constructor(t, e, r) {
3273
+ this.element = t, this.before = e || null, this.after = r || null;
3274
+ }
3275
+ withBefore(t) {
3276
+ return new Yt(this.element, t, this.after);
3277
+ }
3278
+ withAfter(t) {
3279
+ return new Yt(this.element, this.before, t);
3280
+ }
3281
+ withElement(t) {
3282
+ return new Yt(t, this.before, this.after);
3283
+ }
3284
+ insertChild(t) {
3285
+ const e = this.before || this.getManagedLineBreak();
3286
+ return e !== null && e.parentElement !== this.element && T(222), this.element.insertBefore(t, e), this;
3287
+ }
3288
+ removeChild(t) {
3289
+ return t.parentElement !== this.element && T(223), this.element.removeChild(t), this;
3290
+ }
3291
+ replaceChild(t, e) {
3292
+ return e.parentElement !== this.element && T(224), this.element.replaceChild(t, e), this;
3293
+ }
3294
+ getFirstChild() {
3295
+ const t = this.after ? this.after.nextSibling : this.element.firstChild;
3296
+ return t === this.before || t === this.getManagedLineBreak() ? null : t;
3297
+ }
3298
+ getManagedLineBreak() {
3299
+ return this.element.__lexicalLineBreak || null;
3300
+ }
3301
+ setManagedLineBreak(t) {
3302
+ if (t === null) this.removeManagedLineBreak();
3303
+ else {
3304
+ const e = t === "decorator" && (re || ze);
3305
+ this.insertManagedLineBreak(e);
3306
+ }
3307
+ }
3308
+ removeManagedLineBreak() {
3309
+ const t = this.getManagedLineBreak();
3310
+ if (t) {
3311
+ const e = this.element, r = t.nodeName === "IMG" ? t.nextSibling : null;
3312
+ r && e.removeChild(r), e.removeChild(t), e.__lexicalLineBreak = void 0;
3313
+ }
3314
+ }
3315
+ insertManagedLineBreak(t) {
3316
+ const e = this.getManagedLineBreak();
3317
+ if (e) {
3318
+ if (t === (e.nodeName === "IMG")) return;
3319
+ this.removeManagedLineBreak();
3320
+ }
3321
+ const r = this.element, s = this.before, i = document.createElement("br");
3322
+ if (r.insertBefore(i, s), t) {
3323
+ const o = document.createElement("img");
3324
+ o.setAttribute("data-lexical-linebreak", "true"), o.style.cssText = "display: inline !important; border: 0px !important; margin: 0px !important;", o.alt = "", r.insertBefore(o, i), r.__lexicalLineBreak = o;
3325
+ } else r.__lexicalLineBreak = i;
3326
+ }
3327
+ getFirstChildOffset() {
3328
+ let t = 0;
3329
+ for (let e = this.after; e !== null; e = e.previousSibling) t++;
3330
+ return t;
3331
+ }
3332
+ resolveChildIndex(t, e, r, s) {
3333
+ if (r === this.element) {
3334
+ const a = this.getFirstChildOffset();
3335
+ return [t, Math.min(a + t.getChildrenSize(), Math.max(a, s))];
3336
+ }
3337
+ const i = Kr(e, r);
3338
+ i.push(s);
3339
+ const o = Kr(e, this.element);
3340
+ let l = t.getIndexWithinParent();
3341
+ for (let a = 0; a < o.length; a++) {
3342
+ const c = i[a], u = o[a];
3343
+ if (c === void 0 || c < u) break;
3344
+ if (c > u) {
3345
+ l += 1;
3346
+ break;
3347
+ }
3348
+ }
3349
+ return [t.getParentOrThrow(), l];
3350
+ }
3351
+ }
3352
+ function Kr(n, t) {
3353
+ const e = [];
3354
+ let r = t;
3355
+ for (; r !== n && r !== null; r = t.parentNode) {
3356
+ let s = 0;
3357
+ for (let i = r.previousSibling; i !== null; i = r.previousSibling) s++;
3358
+ e.push(s);
3359
+ }
3360
+ return r !== n && T(225), e.reverse();
3361
+ }
3362
+ class Qe extends He {
3363
+ constructor(t) {
3364
+ super(t), this.__first = null, this.__last = null, this.__size = 0, this.__format = 0, this.__style = "", this.__indent = 0, this.__dir = null, this.__textFormat = 0, this.__textStyle = "";
3365
+ }
3366
+ afterCloneFrom(t) {
3367
+ super.afterCloneFrom(t), this.__first = t.__first, this.__last = t.__last, this.__size = t.__size, this.__indent = t.__indent, this.__format = t.__format, this.__style = t.__style, this.__dir = t.__dir, this.__textFormat = t.__textFormat, this.__textStyle = t.__textStyle;
3368
+ }
3369
+ getFormat() {
3370
+ return this.getLatest().__format;
3371
+ }
3372
+ getFormatType() {
3373
+ const t = this.getFormat();
3374
+ return vi[t] || "";
3375
+ }
3376
+ getStyle() {
3377
+ return this.getLatest().__style;
3378
+ }
3379
+ getIndent() {
3380
+ return this.getLatest().__indent;
3381
+ }
3382
+ getChildren() {
3383
+ const t = [];
3384
+ let e = this.getFirstChild();
3385
+ for (; e !== null; ) t.push(e), e = e.getNextSibling();
3386
+ return t;
3387
+ }
3388
+ getChildrenKeys() {
3389
+ const t = [];
3390
+ let e = this.getFirstChild();
3391
+ for (; e !== null; ) t.push(e.__key), e = e.getNextSibling();
3392
+ return t;
3393
+ }
3394
+ getChildrenSize() {
3395
+ return this.getLatest().__size;
3396
+ }
3397
+ isEmpty() {
3398
+ return this.getChildrenSize() === 0;
3399
+ }
3400
+ isDirty() {
3401
+ const t = A()._dirtyElements;
3402
+ return t !== null && t.has(this.__key);
3403
+ }
3404
+ isLastChild() {
3405
+ const t = this.getLatest(), e = this.getParentOrThrow().getLastChild();
3406
+ return e !== null && e.is(t);
3407
+ }
3408
+ getAllTextNodes() {
3409
+ const t = [];
3410
+ let e = this.getFirstChild();
3411
+ for (; e !== null; ) {
3412
+ if (E(e) && t.push(e), S(e)) {
3413
+ const r = e.getAllTextNodes();
3414
+ t.push(...r);
3415
+ }
3416
+ e = e.getNextSibling();
3417
+ }
3418
+ return t;
3419
+ }
3420
+ getFirstDescendant() {
3421
+ let t = this.getFirstChild();
3422
+ for (; S(t); ) {
3423
+ const e = t.getFirstChild();
3424
+ if (e === null) break;
3425
+ t = e;
3426
+ }
3427
+ return t;
3428
+ }
3429
+ getLastDescendant() {
3430
+ let t = this.getLastChild();
3431
+ for (; S(t); ) {
3432
+ const e = t.getLastChild();
3433
+ if (e === null) break;
3434
+ t = e;
3435
+ }
3436
+ return t;
3437
+ }
3438
+ getDescendantByIndex(t) {
3439
+ const e = this.getChildren(), r = e.length;
3440
+ if (t >= r) {
3441
+ const i = e[r - 1];
3442
+ return S(i) && i.getLastDescendant() || i || null;
3443
+ }
3444
+ const s = e[t];
3445
+ return S(s) && s.getFirstDescendant() || s || null;
3446
+ }
3447
+ getFirstChild() {
3448
+ const t = this.getLatest().__first;
3449
+ return t === null ? null : j(t);
3450
+ }
3451
+ getFirstChildOrThrow() {
3452
+ const t = this.getFirstChild();
3453
+ return t === null && T(45, this.__key), t;
3454
+ }
3455
+ getLastChild() {
3456
+ const t = this.getLatest().__last;
3457
+ return t === null ? null : j(t);
3458
+ }
3459
+ getLastChildOrThrow() {
3460
+ const t = this.getLastChild();
3461
+ return t === null && T(96, this.__key), t;
3462
+ }
3463
+ getChildAtIndex(t) {
3464
+ const e = this.getChildrenSize();
3465
+ let r, s;
3466
+ if (t < e / 2) {
3467
+ for (r = this.getFirstChild(), s = 0; r !== null && s <= t; ) {
3468
+ if (s === t) return r;
3469
+ r = r.getNextSibling(), s++;
3470
+ }
3471
+ return null;
3472
+ }
3473
+ for (r = this.getLastChild(), s = e - 1; r !== null && s >= t; ) {
3474
+ if (s === t) return r;
3475
+ r = r.getPreviousSibling(), s--;
3476
+ }
3477
+ return null;
3478
+ }
3479
+ getTextContent() {
3480
+ let t = "";
3481
+ const e = this.getChildren(), r = e.length;
3482
+ for (let s = 0; s < r; s++) {
3483
+ const i = e[s];
3484
+ t += i.getTextContent(), S(i) && s !== r - 1 && !i.isInline() && (t += ct);
3485
+ }
3486
+ return t;
3487
+ }
3488
+ getTextContentSize() {
3489
+ let t = 0;
3490
+ const e = this.getChildren(), r = e.length;
3491
+ for (let s = 0; s < r; s++) {
3492
+ const i = e[s];
3493
+ t += i.getTextContentSize(), S(i) && s !== r - 1 && !i.isInline() && (t += ct.length);
3494
+ }
3495
+ return t;
3496
+ }
3497
+ getDirection() {
3498
+ return this.getLatest().__dir;
3499
+ }
3500
+ getTextFormat() {
3501
+ return this.getLatest().__textFormat;
3502
+ }
3503
+ hasFormat(t) {
3504
+ if (t !== "") {
3505
+ const e = nr[t];
3506
+ return !!(this.getFormat() & e);
3507
+ }
3508
+ return !1;
3509
+ }
3510
+ hasTextFormat(t) {
3511
+ const e = V[t];
3512
+ return !!(this.getTextFormat() & e);
3513
+ }
3514
+ getFormatFlags(t, e) {
3515
+ return Fe(this.getLatest().__textFormat, t, e);
3516
+ }
3517
+ getTextStyle() {
3518
+ return this.getLatest().__textStyle;
3519
+ }
3520
+ select(t, e) {
3521
+ G();
3522
+ const r = M();
3523
+ let s = t, i = e;
3524
+ const o = this.getChildrenSize();
3525
+ if (!this.canBeEmpty()) {
3526
+ if (t === 0 && e === 0) {
3527
+ const a = this.getFirstChild();
3528
+ if (E(a) || S(a)) return a.select(0, 0);
3529
+ } else if (!(t !== void 0 && t !== o || e !== void 0 && e !== o)) {
3530
+ const a = this.getLastChild();
3531
+ if (E(a) || S(a)) return a.select();
3532
+ }
3533
+ }
3534
+ s === void 0 && (s = o), i === void 0 && (i = o);
3535
+ const l = this.__key;
3536
+ return P(r) ? (r.anchor.set(l, s, "element"), r.focus.set(l, i, "element"), r.dirty = !0, r) : Ps(l, s, l, i, "element", "element");
3537
+ }
3538
+ selectStart() {
3539
+ const t = this.getFirstDescendant();
3540
+ return t ? t.selectStart() : this.select();
3541
+ }
3542
+ selectEnd() {
3543
+ const t = this.getLastDescendant();
3544
+ return t ? t.selectEnd() : this.select();
3545
+ }
3546
+ clear() {
3547
+ const t = this.getWritable();
3548
+ return this.getChildren().forEach((e) => e.remove()), t;
3549
+ }
3550
+ append(...t) {
3551
+ return this.splice(this.getChildrenSize(), 0, t);
3552
+ }
3553
+ setDirection(t) {
3554
+ const e = this.getWritable();
3555
+ return e.__dir = t, e;
3556
+ }
3557
+ setFormat(t) {
3558
+ return this.getWritable().__format = t !== "" ? nr[t] : 0, this;
3559
+ }
3560
+ setStyle(t) {
3561
+ return this.getWritable().__style = t || "", this;
3562
+ }
3563
+ setTextFormat(t) {
3564
+ const e = this.getWritable();
3565
+ return e.__textFormat = t, e;
3566
+ }
3567
+ setTextStyle(t) {
3568
+ const e = this.getWritable();
3569
+ return e.__textStyle = t, e;
3570
+ }
3571
+ setIndent(t) {
3572
+ return this.getWritable().__indent = t, this;
3573
+ }
3574
+ splice(t, e, r) {
3575
+ const s = r.length, i = this.getChildrenSize(), o = this.getWritable();
3576
+ t + e <= i || T(226, String(t), String(e), String(i));
3577
+ const l = o.__key, a = [], c = [], u = this.getChildAtIndex(t + e);
3578
+ let h = null, f = i - e + s;
3579
+ if (t !== 0) if (t === i) h = this.getLastChild();
3580
+ else {
3581
+ const g = this.getChildAtIndex(t);
3582
+ g !== null && (h = g.getPreviousSibling());
3583
+ }
3584
+ if (e > 0) {
3585
+ let g = h === null ? this.getFirstChild() : h.getNextSibling();
3586
+ for (let _ = 0; _ < e; _++) {
3587
+ g === null && T(100);
3588
+ const p = g.getNextSibling(), m = g.__key;
3589
+ Nt(g.getWritable()), c.push(m), g = p;
3590
+ }
3591
+ }
3592
+ let d = h;
3593
+ for (let g = 0; g < s; g++) {
3594
+ const _ = r[g];
3595
+ d !== null && _.is(d) && (h = d = d.getPreviousSibling());
3596
+ const p = _.getWritable();
3597
+ p.__parent === l && f--, Nt(p);
3598
+ const m = _.__key;
3599
+ if (d === null) o.__first = m, p.__prev = null;
3600
+ else {
3601
+ const y = d.getWritable();
3602
+ y.__next = m, p.__prev = y.__key;
3603
+ }
3604
+ _.__key === l && T(76), p.__parent = l, a.push(m), d = _;
3605
+ }
3606
+ if (t + e === i)
3607
+ d !== null && (d.getWritable().__next = null, o.__last = d.__key);
3608
+ else if (u !== null) {
3609
+ const g = u.getWritable();
3610
+ if (d !== null) {
3611
+ const _ = d.getWritable();
3612
+ g.__prev = d.__key, _.__next = u.__key;
3613
+ } else g.__prev = null;
3614
+ }
3615
+ if (o.__size = f, c.length) {
3616
+ const g = M();
3617
+ if (P(g)) {
3618
+ const _ = new Set(c), p = new Set(a), { anchor: m, focus: y } = g;
3619
+ Jr(m, _, p) && Be(m, m.getNode(), this, h, u), Jr(y, _, p) && Be(y, y.getNode(), this, h, u), f !== 0 || this.canBeEmpty() || Ft(this) || this.remove();
3620
+ }
3621
+ }
3622
+ return o;
3623
+ }
3624
+ getDOMSlot(t) {
3625
+ return new Yt(t);
3626
+ }
3627
+ exportDOM(t) {
3628
+ const { element: e } = super.exportDOM(t);
3629
+ if (X(e)) {
3630
+ const r = this.getIndent();
3631
+ r > 0 && (e.style.paddingInlineStart = 40 * r + "px");
3632
+ }
3633
+ return { element: e };
3634
+ }
3635
+ exportJSON() {
3636
+ const t = { children: [], direction: this.getDirection(), format: this.getFormatType(), indent: this.getIndent(), ...super.exportJSON() }, e = this.getTextFormat(), r = this.getTextStyle();
3637
+ return e !== 0 && (t.textFormat = e), r !== "" && (t.textStyle = r), t;
3638
+ }
3639
+ updateFromJSON(t) {
3640
+ return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat || 0).setTextStyle(t.textStyle || "");
3641
+ }
3642
+ insertNewAfter(t, e) {
3643
+ return null;
3644
+ }
3645
+ canIndent() {
3646
+ return !0;
3647
+ }
3648
+ collapseAtStart(t) {
3649
+ return !1;
3650
+ }
3651
+ excludeFromCopy(t) {
3652
+ return !1;
3653
+ }
3654
+ canReplaceWith(t) {
3655
+ return !0;
3656
+ }
3657
+ canInsertAfter(t) {
3658
+ return !0;
3659
+ }
3660
+ canBeEmpty() {
3661
+ return !0;
3662
+ }
3663
+ canInsertTextBefore() {
3664
+ return !0;
3665
+ }
3666
+ canInsertTextAfter() {
3667
+ return !0;
3668
+ }
3669
+ isInline() {
3670
+ return !1;
3671
+ }
3672
+ isShadowRoot() {
3673
+ return !1;
3674
+ }
3675
+ canMergeWith(t) {
3676
+ return !1;
3677
+ }
3678
+ extractWithChild(t, e, r) {
3679
+ return !1;
3680
+ }
3681
+ canMergeWhenEmpty() {
3682
+ return !1;
3683
+ }
3684
+ reconcileObservedMutation(t, e) {
3685
+ const r = this.getDOMSlot(t);
3686
+ let s = r.getFirstChild();
3687
+ for (let i = this.getFirstChild(); i; i = i.getNextSibling()) {
3688
+ const o = e.getElementByKey(i.getKey());
3689
+ o !== null && (s == null ? (r.insertChild(o), s = o) : s !== o && r.replaceChild(o, s), s = s.nextSibling);
3690
+ }
3691
+ }
3692
+ }
3693
+ function S(n) {
3694
+ return n instanceof Qe;
3695
+ }
3696
+ function Jr(n, t, e) {
3697
+ let r = n.getNode();
3698
+ for (; r; ) {
3699
+ const s = r.__key;
3700
+ if (t.has(s) && !e.has(s)) return !0;
3701
+ r = r.getParent();
3702
+ }
3703
+ return !1;
3704
+ }
3705
+ class so extends He {
3706
+ decorate(t, e) {
3707
+ T(47);
3708
+ }
3709
+ isIsolated() {
3710
+ return !1;
3711
+ }
3712
+ isInline() {
3713
+ return !0;
3714
+ }
3715
+ isKeyboardSelectable() {
3716
+ return !0;
3717
+ }
3718
+ }
3719
+ function I(n) {
3720
+ return n instanceof so;
3721
+ }
3722
+ class ue extends Qe {
3723
+ static getType() {
3724
+ return "root";
3725
+ }
3726
+ static clone() {
3727
+ return new ue();
3728
+ }
3729
+ constructor() {
3730
+ super("root"), this.__cachedText = null;
3731
+ }
3732
+ getTopLevelElementOrThrow() {
3733
+ T(51);
3734
+ }
3735
+ getTextContent() {
3736
+ const t = this.__cachedText;
3737
+ return !ce() && A()._dirtyType !== Et || t === null ? super.getTextContent() : t;
3738
+ }
3739
+ remove() {
3740
+ T(52);
3741
+ }
3742
+ replace(t) {
3743
+ T(53);
3744
+ }
3745
+ insertBefore(t) {
3746
+ T(54);
3747
+ }
3748
+ insertAfter(t) {
3749
+ T(55);
3750
+ }
3751
+ updateDOM(t, e) {
3752
+ return !1;
3753
+ }
3754
+ append(...t) {
3755
+ for (let e = 0; e < t.length; e++) {
3756
+ const r = t[e];
3757
+ S(r) || I(r) || T(56);
3758
+ }
3759
+ return super.append(...t);
3760
+ }
3761
+ static importJSON(t) {
3762
+ return rt().updateFromJSON(t);
3763
+ }
3764
+ collapseAtStart() {
3765
+ return !0;
3766
+ }
3767
+ }
3768
+ function Z(n) {
3769
+ return n instanceof ue;
3770
+ }
3771
+ function As(n) {
3772
+ return new Xe(new Map(n._nodeMap));
3773
+ }
3774
+ function Gn() {
3775
+ return new Xe(/* @__PURE__ */ new Map([["root", new ue()]]));
3776
+ }
3777
+ function Bs(n) {
3778
+ const t = n.exportJSON(), e = n.constructor;
3779
+ if (t.type !== e.getType() && T(130, e.name), S(n)) {
3780
+ const r = t.children;
3781
+ Array.isArray(r) || T(59, e.name);
3782
+ const s = n.getChildren();
3783
+ for (let i = 0; i < s.length; i++) {
3784
+ const o = Bs(s[i]);
3785
+ r.push(o);
3786
+ }
3787
+ }
3788
+ return t;
3789
+ }
3790
+ class Xe {
3791
+ constructor(t, e) {
3792
+ this._nodeMap = t, this._selection = e || null, this._flushSync = !1, this._readOnly = !1;
3793
+ }
3794
+ isEmpty() {
3795
+ return this._nodeMap.size === 1 && this._selection === null;
3796
+ }
3797
+ read(t, e) {
3798
+ return Wr(e && e.editor || null, this, t);
3799
+ }
3800
+ clone(t) {
3801
+ const e = new Xe(this._nodeMap, t === void 0 ? this._selection : t);
3802
+ return e._readOnly = !0, e;
3803
+ }
3804
+ toJSON() {
3805
+ return Wr(null, this, () => ({ root: Bs(rt()) }));
3806
+ }
3807
+ }
3808
+ class io extends Qe {
3809
+ static getType() {
3810
+ return "artificial";
3811
+ }
3812
+ createDOM(t) {
3813
+ return document.createElement("div");
3814
+ }
3815
+ }
3816
+ class fe extends Qe {
3817
+ static getType() {
3818
+ return "paragraph";
3819
+ }
3820
+ static clone(t) {
3821
+ return new fe(t.__key);
3822
+ }
3823
+ createDOM(t) {
3824
+ const e = document.createElement("p"), r = It(t.theme, "paragraph");
3825
+ return r !== void 0 && e.classList.add(...r), e;
3826
+ }
3827
+ updateDOM(t, e, r) {
3828
+ return !1;
3829
+ }
3830
+ static importDOM() {
3831
+ return { p: (t) => ({ conversion: oo, priority: 0 }) };
3832
+ }
3833
+ exportDOM(t) {
3834
+ const { element: e } = super.exportDOM(t);
3835
+ if (X(e)) {
3836
+ this.isEmpty() && e.append(document.createElement("br"));
3837
+ const r = this.getFormatType();
3838
+ e.style.textAlign = r;
3839
+ const s = this.getDirection();
3840
+ s && (e.dir = s);
3841
+ }
3842
+ return { element: e };
3843
+ }
3844
+ static importJSON(t) {
3845
+ return St().updateFromJSON(t);
3846
+ }
3847
+ exportJSON() {
3848
+ return { ...super.exportJSON(), textFormat: this.getTextFormat(), textStyle: this.getTextStyle() };
3849
+ }
3850
+ insertNewAfter(t, e) {
3851
+ const r = St();
3852
+ r.setTextFormat(t.format), r.setTextStyle(t.style);
3853
+ const s = this.getDirection();
3854
+ return r.setDirection(s), r.setFormat(this.getFormatType()), r.setStyle(this.getTextStyle()), this.insertAfter(r, e), r;
3855
+ }
3856
+ collapseAtStart() {
3857
+ const t = this.getChildren();
3858
+ if (t.length === 0 || E(t[0]) && t[0].getTextContent().trim() === "") {
3859
+ if (this.getNextSibling() !== null) return this.selectNext(), this.remove(), !0;
3860
+ if (this.getPreviousSibling() !== null) return this.selectPrevious(), this.remove(), !0;
3861
+ }
3862
+ return !1;
3863
+ }
3864
+ }
3865
+ function oo(n) {
3866
+ const t = St();
3867
+ return n.style && (t.setFormat(n.style.textAlign), Ki(n, t)), { node: t };
3868
+ }
3869
+ function St() {
3870
+ return je(new fe());
3871
+ }
3872
+ function Fo(n) {
3873
+ return n instanceof fe;
3874
+ }
3875
+ const Po = 0, Oo = 1, Lo = 3, Do = 4;
3876
+ function zs(n, t, e, r) {
3877
+ const s = n._keyToDOMMap;
3878
+ s.clear(), n._editorState = Gn(), n._pendingEditorState = r, n._compositionKey = null, n._dirtyType = Et, n._cloneNotNeeded.clear(), n._dirtyLeaves = /* @__PURE__ */ new Set(), n._dirtyElements.clear(), n._normalizedNodes = /* @__PURE__ */ new Set(), n._updateTags = /* @__PURE__ */ new Set(), n._updates = [], n._blockCursorElement = null;
3879
+ const i = n._observer;
3880
+ i !== null && (i.disconnect(), n._observer = null), t !== null && (t.textContent = ""), e !== null && (e.textContent = "", s.set("root", e));
3881
+ }
3882
+ function Mo(n) {
3883
+ const t = n || {}, e = ro(), r = t.theme || {}, s = n === void 0 ? e : t.parentEditor || null, i = t.disableEvents || !1, o = Gn(), l = t.namespace || (s !== null ? s._config.namespace : as()), a = t.editorState, c = [ue, Wt, oe, le, fe, io, ...t.nodes || []], { onError: u, html: h } = t, f = t.editable === void 0 || t.editable;
3884
+ let d;
3885
+ if (n === void 0 && e !== null) d = e._nodes;
3886
+ else {
3887
+ d = /* @__PURE__ */ new Map();
3888
+ for (let _ = 0; _ < c.length; _++) {
3889
+ let p = c[_], m = null, y = null;
3890
+ if (typeof p != "function") {
3891
+ const v = p;
3892
+ p = v.replace, m = v.with, y = v.withKlass || null;
3893
+ }
3894
+ const x = p.getType(), b = p.transform(), k = /* @__PURE__ */ new Set();
3895
+ b !== null && k.add(b), d.set(x, { exportDOM: h && h.export ? h.export.get(p) : void 0, klass: p, replace: m, replaceWithKlass: y, transforms: k });
3896
+ }
3897
+ }
3898
+ const g = new Ye(o, s, d, { disableEvents: i, namespace: l, theme: r }, u || console.error, function(_, p) {
3899
+ const m = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), x = (b) => {
3900
+ Object.keys(b).forEach((k) => {
3901
+ let v = m.get(k);
3902
+ v === void 0 && (v = [], m.set(k, v)), v.push(b[k]);
3903
+ });
3904
+ };
3905
+ return _.forEach((b) => {
3906
+ const k = b.klass.importDOM;
3907
+ if (k == null || y.has(k)) return;
3908
+ y.add(k);
3909
+ const v = k.call(b.klass);
3910
+ v !== null && x(v);
3911
+ }), p && x(p), m;
3912
+ }(d, h ? h.import : void 0), f);
3913
+ return a !== void 0 && (g._pendingEditorState = a, g._dirtyType = zt), g;
3914
+ }
3915
+ class Ye {
3916
+ constructor(t, e, r, s, i, o, l) {
3917
+ this._parentEditor = e, this._rootElement = null, this._editorState = t, this._pendingEditorState = null, this._compositionKey = null, this._deferred = [], this._keyToDOMMap = /* @__PURE__ */ new Map(), this._updates = [], this._updating = !1, this._listeners = { decorator: /* @__PURE__ */ new Set(), editable: /* @__PURE__ */ new Set(), mutation: /* @__PURE__ */ new Map(), root: /* @__PURE__ */ new Set(), textcontent: /* @__PURE__ */ new Set(), update: /* @__PURE__ */ new Set() }, this._commands = /* @__PURE__ */ new Map(), this._config = s, this._nodes = r, this._decorators = {}, this._pendingDecorators = null, this._dirtyType = Et, this._cloneNotNeeded = /* @__PURE__ */ new Set(), this._dirtyLeaves = /* @__PURE__ */ new Set(), this._dirtyElements = /* @__PURE__ */ new Map(), this._normalizedNodes = /* @__PURE__ */ new Set(), this._updateTags = /* @__PURE__ */ new Set(), this._observer = null, this._key = as(), this._onError = i, this._htmlConversions = o, this._editable = l, this._headless = e !== null && e._headless, this._window = null, this._blockCursorElement = null;
3918
+ }
3919
+ isComposing() {
3920
+ return this._compositionKey != null;
3921
+ }
3922
+ registerUpdateListener(t) {
3923
+ const e = this._listeners.update;
3924
+ return e.add(t), () => {
3925
+ e.delete(t);
3926
+ };
3927
+ }
3928
+ registerEditableListener(t) {
3929
+ const e = this._listeners.editable;
3930
+ return e.add(t), () => {
3931
+ e.delete(t);
3932
+ };
3933
+ }
3934
+ registerDecoratorListener(t) {
3935
+ const e = this._listeners.decorator;
3936
+ return e.add(t), () => {
3937
+ e.delete(t);
3938
+ };
3939
+ }
3940
+ registerTextContentListener(t) {
3941
+ const e = this._listeners.textcontent;
3942
+ return e.add(t), () => {
3943
+ e.delete(t);
3944
+ };
3945
+ }
3946
+ registerRootListener(t) {
3947
+ const e = this._listeners.root;
3948
+ return t(this._rootElement, null), e.add(t), () => {
3949
+ t(null, this._rootElement), e.delete(t);
3950
+ };
3951
+ }
3952
+ registerCommand(t, e, r) {
3953
+ r === void 0 && T(35);
3954
+ const s = this._commands;
3955
+ s.has(t) || s.set(t, [/* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set()]);
3956
+ const i = s.get(t);
3957
+ i === void 0 && T(36, String(t));
3958
+ const o = i[r];
3959
+ return o.add(e), () => {
3960
+ o.delete(e), i.every((l) => l.size === 0) && s.delete(t);
3961
+ };
3962
+ }
3963
+ registerMutationListener(t, e, r) {
3964
+ const s = this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass, i = this._listeners.mutation;
3965
+ i.set(e, s);
3966
+ const o = r && r.skipInitialization;
3967
+ return o !== void 0 && o || this.initializeMutationListener(e, s), () => {
3968
+ i.delete(e);
3969
+ };
3970
+ }
3971
+ getRegisteredNode(t) {
3972
+ const e = this._nodes.get(t.getType());
3973
+ return e === void 0 && T(37, t.name), e;
3974
+ }
3975
+ resolveRegisteredNodeAfterReplacements(t) {
3976
+ for (; t.replaceWithKlass; ) t = this.getRegisteredNode(t.replaceWithKlass);
3977
+ return t;
3978
+ }
3979
+ initializeMutationListener(t, e) {
3980
+ const r = this._editorState, s = mr(r).get(e.getType());
3981
+ if (!s) return;
3982
+ const i = /* @__PURE__ */ new Map();
3983
+ for (const o of s.keys()) i.set(o, "created");
3984
+ i.size > 0 && t(i, { dirtyLeaves: /* @__PURE__ */ new Set(), prevEditorState: r, updateTags: /* @__PURE__ */ new Set(["registerMutationListener"]) });
3985
+ }
3986
+ registerNodeTransformToKlass(t, e) {
3987
+ const r = this.getRegisteredNode(t);
3988
+ return r.transforms.add(e), r;
3989
+ }
3990
+ registerNodeTransform(t, e) {
3991
+ const r = this.registerNodeTransformToKlass(t, e), s = [r], i = r.replaceWithKlass;
3992
+ if (i != null) {
3993
+ const o = this.registerNodeTransformToKlass(i, e);
3994
+ s.push(o);
3995
+ }
3996
+ return function(o, l) {
3997
+ const a = mr(o.getEditorState()), c = [];
3998
+ for (const u of l) {
3999
+ const h = a.get(u);
4000
+ h && c.push(h);
4001
+ }
4002
+ c.length !== 0 && o.update(() => {
4003
+ for (const u of c) for (const h of u.keys()) {
4004
+ const f = j(h);
4005
+ f && f.markDirty();
4006
+ }
4007
+ }, o._pendingEditorState === null ? { tag: "history-merge" } : void 0);
4008
+ }(this, s.map((o) => o.klass.getType())), () => {
4009
+ s.forEach((o) => o.transforms.delete(e));
4010
+ };
4011
+ }
4012
+ hasNode(t) {
4013
+ return this._nodes.has(t.getType());
4014
+ }
4015
+ hasNodes(t) {
4016
+ return t.every(this.hasNode.bind(this));
4017
+ }
4018
+ dispatchCommand(t, e) {
4019
+ return w(this, t, e);
4020
+ }
4021
+ getDecorators() {
4022
+ return this._decorators;
4023
+ }
4024
+ getRootElement() {
4025
+ return this._rootElement;
4026
+ }
4027
+ getKey() {
4028
+ return this._key;
4029
+ }
4030
+ setRootElement(t) {
4031
+ const e = this._rootElement;
4032
+ if (t !== e) {
4033
+ const r = It(this._config.theme, "root"), s = this._pendingEditorState || this._editorState;
4034
+ if (this._rootElement = t, zs(this, e, t, s), e !== null && (this._config.disableEvents || Vi(e), r != null && e.classList.remove(...r)), t !== null) {
4035
+ const i = Un(t), o = t.style;
4036
+ o.userSelect = "text", o.whiteSpace = "pre-wrap", o.wordBreak = "break-word", t.setAttribute("data-lexical-editor", "true"), this._window = i, this._dirtyType = zt, ts(this), this._updateTags.add("history-merge"), xt(this), this._config.disableEvents || function(l, a) {
4037
+ const c = l.ownerDocument, u = Ie.get(c);
4038
+ (u === void 0 || u < 1) && c.addEventListener("selectionchange", bs), Ie.set(c, (u || 0) + 1), l.__lexicalEditor = a;
4039
+ const h = ks(l);
4040
+ for (let f = 0; f < Tn.length; f++) {
4041
+ const [d, g] = Tn[f], _ = typeof g == "function" ? (p) => {
4042
+ Tr(p) || (Cr(p), (a.isEditable() || d === "click") && g(p, a));
4043
+ } : (p) => {
4044
+ if (Tr(p)) return;
4045
+ Cr(p);
4046
+ const m = a.isEditable();
4047
+ switch (d) {
4048
+ case "cut":
4049
+ return m && w(a, Hr, p);
4050
+ case "copy":
4051
+ return w(a, Vr, p);
4052
+ case "paste":
4053
+ return m && w(a, Ur, p);
4054
+ case "dragstart":
4055
+ return m && w(a, Zs, p);
4056
+ case "dragover":
4057
+ return m && w(a, ti, p);
4058
+ case "dragend":
4059
+ return m && w(a, ei, p);
4060
+ case "focus":
4061
+ return m && w(a, ni, p);
4062
+ case "blur":
4063
+ return m && w(a, ri, p);
4064
+ case "drop":
4065
+ return m && w(a, Ys, p);
4066
+ }
4067
+ };
4068
+ l.addEventListener(d, _), h.push(() => {
4069
+ l.removeEventListener(d, _);
4070
+ });
4071
+ }
4072
+ }(t, this), r != null && t.classList.add(...r);
4073
+ } else this._editorState = s, this._pendingEditorState = null, this._window = null;
4074
+ Xt("root", this, !1, t, e);
4075
+ }
4076
+ }
4077
+ getElementByKey(t) {
4078
+ return this._keyToDOMMap.get(t) || null;
4079
+ }
4080
+ getEditorState() {
4081
+ return this._editorState;
4082
+ }
4083
+ setEditorState(t, e) {
4084
+ t.isEmpty() && T(38);
4085
+ let r = t;
4086
+ r._readOnly && (r = As(t), r._selection = t._selection ? t._selection.clone() : null), Zr(this);
4087
+ const s = this._pendingEditorState, i = this._updateTags, o = e !== void 0 ? e.tag : null;
4088
+ s === null || s.isEmpty() || (o != null && i.add(o), xt(this)), this._pendingEditorState = r, this._dirtyType = zt, this._dirtyElements.set("root", !1), this._compositionKey = null, o != null && i.add(o), this._updating || xt(this);
4089
+ }
4090
+ parseEditorState(t, e) {
4091
+ return function(r, s, i) {
4092
+ const o = Gn(), l = K, a = Q, c = J, u = s._dirtyElements, h = s._dirtyLeaves, f = s._cloneNotNeeded, d = s._dirtyType;
4093
+ s._dirtyElements = /* @__PURE__ */ new Map(), s._dirtyLeaves = /* @__PURE__ */ new Set(), s._cloneNotNeeded = /* @__PURE__ */ new Set(), s._dirtyType = 0, K = o, Q = !1, J = s;
4094
+ try {
4095
+ const g = s._nodes;
4096
+ qn(r.root, g), i && i(), o._readOnly = !0;
4097
+ } catch (g) {
4098
+ g instanceof Error && s._onError(g);
4099
+ } finally {
4100
+ s._dirtyElements = u, s._dirtyLeaves = h, s._cloneNotNeeded = f, s._dirtyType = d, K = l, Q = a, J = c;
4101
+ }
4102
+ return o;
4103
+ }(typeof t == "string" ? JSON.parse(t) : t, this, e);
4104
+ }
4105
+ read(t) {
4106
+ return xt(this), this.getEditorState().read(t, { editor: this });
4107
+ }
4108
+ update(t, e) {
4109
+ Y(this, t, e);
4110
+ }
4111
+ focus(t, e = {}) {
4112
+ const r = this._rootElement;
4113
+ r !== null && (r.setAttribute("autocapitalize", "off"), Y(this, () => {
4114
+ const s = M(), i = rt();
4115
+ s !== null ? s.dirty = !0 : i.getChildrenSize() !== 0 && (e.defaultSelection === "rootStart" ? i.selectStart() : i.selectEnd());
4116
+ }, { onUpdate: () => {
4117
+ r.removeAttribute("autocapitalize"), t && t();
4118
+ }, tag: "focus" }), this._pendingEditorState === null && r.removeAttribute("autocapitalize"));
4119
+ }
4120
+ blur() {
4121
+ const t = this._rootElement;
4122
+ t !== null && t.blur();
4123
+ const e = ft(this._window);
4124
+ e !== null && e.removeAllRanges();
4125
+ }
4126
+ isEditable() {
4127
+ return this._editable;
4128
+ }
4129
+ setEditable(t) {
4130
+ this._editable !== t && (this._editable = t, Xt("editable", this, !0, t));
4131
+ }
4132
+ toJSON() {
4133
+ return { editorState: this._editorState.toJSON() };
4134
+ }
4135
+ }
4136
+ Ye.version = "0.23.0+prod.esm";
4137
+ export {
4138
+ ni as $,
4139
+ Co as A,
4140
+ Hr as B,
4141
+ Us as C,
4142
+ Ks as D,
4143
+ So as E,
4144
+ ie as F,
4145
+ Ce as G,
4146
+ M as H,
4147
+ I,
4148
+ To as J,
4149
+ Te as K,
4150
+ S as L,
4151
+ ut as M,
4152
+ Xs as N,
4153
+ Qe as O,
4154
+ X as P,
4155
+ Lo as Q,
4156
+ Se as R,
4157
+ Vs as S,
4158
+ qs as T,
4159
+ Qs as U,
4160
+ St as V,
4161
+ ot as W,
4162
+ Do as X,
4163
+ ce as Y,
4164
+ V as Z,
4165
+ fe as _,
4166
+ P as a,
4167
+ Wt as a0,
4168
+ Ur as a1,
4169
+ rt as a2,
4170
+ vo as a3,
4171
+ Fr as a4,
4172
+ _r as a5,
4173
+ Z as a6,
4174
+ Rs as a7,
4175
+ Ws as a8,
4176
+ yo as a9,
4177
+ uo as aA,
4178
+ co as aB,
4179
+ No as aC,
4180
+ tr as aD,
4181
+ ns as aE,
4182
+ _o as aF,
4183
+ go as aG,
4184
+ po as aa,
4185
+ $r as ab,
4186
+ jr as ac,
4187
+ io as ad,
4188
+ ne as ae,
4189
+ Ri as af,
4190
+ Bi as ag,
4191
+ ko as ah,
4192
+ pr as ai,
4193
+ zi as aj,
4194
+ Vn as ak,
4195
+ Eo as al,
4196
+ Vr as am,
4197
+ Re as an,
4198
+ Hn as ao,
4199
+ Mo as ap,
4200
+ Hs as aq,
4201
+ es as ar,
4202
+ er as as,
4203
+ xo as at,
4204
+ ti as au,
4205
+ Zs as av,
4206
+ Ys as aw,
4207
+ gn as ax,
4208
+ me as ay,
4209
+ fo as az,
4210
+ U as b,
4211
+ mo as c,
4212
+ zn as d,
4213
+ lo as e,
4214
+ Po as f,
4215
+ j as g,
4216
+ ae as h,
4217
+ or as i,
4218
+ Fo as j,
4219
+ Gs as k,
4220
+ wt as l,
4221
+ ho as m,
4222
+ Bt as n,
4223
+ Zn as o,
4224
+ Ht as p,
4225
+ Oo as q,
4226
+ ao as r,
4227
+ ft as s,
4228
+ Nn as t,
4229
+ wo as u,
4230
+ E as v,
4231
+ bo as w,
4232
+ je as x,
4233
+ Ft as y,
4234
+ js as z
4235
+ };
4236
+ //# sourceMappingURL=Lexical.prod-BAr6tzpa.js.map