laif-ds 0.2.85 → 0.2.87

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