@mx-space/cli 0.14.0 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/{Lexical.dev-DTxuYHmG.mjs → Lexical.dev-CtGmYDoh.mjs} +770 -271
  2. package/dist/{Lexical.node-BlCLnfA6.mjs → Lexical.node-8sRFmq2X.mjs} +15 -5
  3. package/dist/Lexical.prod-D-VfeKDz.mjs +7200 -0
  4. package/dist/{LexicalClipboard.dev-CdFkLR_D.mjs → LexicalClipboard.dev-CzQ15z6E.mjs} +6 -6
  5. package/dist/{LexicalClipboard.node-ktUajxsv.mjs → LexicalClipboard.node-D4gMGws6.mjs} +2 -2
  6. package/dist/{LexicalClipboard.prod-DliyLofW.mjs → LexicalClipboard.prod-CltkQpzS.mjs} +10 -8
  7. package/dist/{LexicalCodeCore.dev-CL9tHWJX.mjs → LexicalCodeCore.dev-DkYBZRGB.mjs} +11 -9
  8. package/dist/{LexicalCodeCore.prod-BoMSJc29.mjs → LexicalCodeCore.prod-COc3_QL8.mjs} +178 -167
  9. package/dist/{LexicalDragon.dev-CqW7Aq5H.mjs → LexicalDragon.dev-Dv5_WUae.mjs} +3 -3
  10. package/dist/{LexicalDragon.node-DLXctJyy.mjs → LexicalDragon.node-DgjrmWkd.mjs} +2 -2
  11. package/dist/{LexicalDragon.prod-DHI3T6n5.mjs → LexicalDragon.prod-DnpbDe-_.mjs} +5 -4
  12. package/dist/{LexicalExtension.dev-BP-18zns.mjs → LexicalExtension.dev-JMH_6-OZ.mjs} +73 -52
  13. package/dist/{LexicalExtension.node-BWH6xbzG.mjs → LexicalExtension.node-BUozzx4t.mjs} +4 -2
  14. package/dist/{LexicalExtension.prod-Cs6OgrDn.mjs → LexicalExtension.prod-UiyDgmou.mjs} +370 -347
  15. package/dist/{LexicalHeadless.dev-DJp__UcP.mjs → LexicalHeadless.dev-BfLGciiX.mjs} +2 -2
  16. package/dist/{LexicalHeadless.prod-o0v9cIu5.mjs → LexicalHeadless.prod-CWF7edmQ.mjs} +2 -2
  17. package/dist/{LexicalHtml.dev-DoymwFpG.mjs → LexicalHtml.dev-D5EF5PGW.mjs} +13 -11
  18. package/dist/{LexicalHtml.node-CVkbWtUA.mjs → LexicalHtml.node-BYbzHNVe.mjs} +4 -4
  19. package/dist/{LexicalHtml.prod-C2b3z99k.mjs → LexicalHtml.prod-D_FfkvVD.mjs} +330 -299
  20. package/dist/{LexicalLink.dev-7cgLOLIe.mjs → LexicalLink.dev-D3Pgh6ik.mjs} +53 -23
  21. package/dist/{LexicalLink.prod-DWFgoXHR.mjs → LexicalLink.prod-XZoAYVYD.mjs} +217 -198
  22. package/dist/{LexicalList.dev-Ci2iOxFx.mjs → LexicalList.dev-B5d3ObhB.mjs} +49 -44
  23. package/dist/LexicalList.prod-OQDpVAEb.mjs +967 -0
  24. package/dist/{LexicalMarkdown.dev-C0ZYCyuR.mjs → LexicalMarkdown.dev-BkM8G3DG.mjs} +61 -42
  25. package/dist/{LexicalMarkdown.prod-0M-Nc-rh.mjs → LexicalMarkdown.prod-DcVXCex6.mjs} +254 -202
  26. package/dist/{LexicalRichText.dev-Cnr1kDym.mjs → LexicalRichText.dev-DppD7IrA.mjs} +337 -52
  27. package/dist/{LexicalRichText.node-BUJZAiap.mjs → LexicalRichText.node-CPSn7dkg.mjs} +12 -8
  28. package/dist/LexicalRichText.prod-h7JPxFNp.mjs +718 -0
  29. package/dist/{LexicalSelection.dev-C4L7l8OB.mjs → LexicalSelection.dev-CD0SLbxP.mjs} +48 -17
  30. package/dist/{LexicalSelection.node-CLKroUMQ.mjs → LexicalSelection.node-CGlJgUlZ.mjs} +5 -4
  31. package/dist/{LexicalSelection.prod-DzFqpTlw.mjs → LexicalSelection.prod-DbVZN5AV.mjs} +101 -92
  32. package/dist/{LexicalTable.dev-Cc9-zqKa.mjs → LexicalTable.dev-D0HU14UV.mjs} +340 -138
  33. package/dist/LexicalTable.prod-BcPNSrxP.mjs +2468 -0
  34. package/dist/{LexicalUtils.dev-BRgK0L6G.mjs → LexicalUtils.dev-iKy_TrRT.mjs} +15 -19
  35. package/dist/{LexicalUtils.node-BVAwOkL4.mjs → LexicalUtils.node-CIgMS8cG.mjs} +6 -6
  36. package/dist/{LexicalUtils.prod-C1gtvVDP.mjs → LexicalUtils.prod-DIAsKJzu.mjs} +155 -159
  37. package/dist/bin/mxs.mjs +1 -1
  38. package/dist/esm-CH7CrOvh.mjs +2 -0
  39. package/dist/{esm-BNu4sUWV.mjs → esm-CwXl1N0a.mjs} +1801 -6013
  40. package/dist/index.d.mts +57 -62
  41. package/dist/index.mjs +1 -1
  42. package/dist/{mxs-BUqt-N3N.mjs → mxs-iW9DgqSZ.mjs} +14960 -9235
  43. package/dist/rolldown-runtime-JspESFgx.mjs +35 -0
  44. package/dist/vendor/litexml/cli.mjs +6693 -5762
  45. package/dist/vendor/litexml/litexml-html-preview-client.js +11912 -8698
  46. package/package.json +31 -30
  47. package/LICENSE +0 -33
  48. package/dist/Lexical.prod-CeB9UQuo.mjs +0 -6816
  49. package/dist/LexicalList.prod-D0xX5d3G.mjs +0 -944
  50. package/dist/LexicalRichText.prod-BfbMQ9uM.mjs +0 -538
  51. package/dist/LexicalTable.prod-BgO4nCxy.mjs +0 -2336
  52. package/dist/esm-jbwcVZth.mjs +0 -2
@@ -0,0 +1,2468 @@
1
+ import { f as namedSignals, l as effect, p as signal } from "./LexicalExtension.node-BUozzx4t.mjs";
2
+ import { $r as isHTMLElement, $t as COMMAND_PRIORITY_LOW, A as $getChildCaret, Ar as getComposedEventTarget, B as $getNodeByKey, Dt as $normalizeSelection__EXPERIMENTAL, Et as $normalizeCaret, Ft as $setSelection, G as $getSelection, Gn as KEY_ARROW_RIGHT_COMMAND, Gr as isCurrentlyReadOnlyMode, Hn as IS_UNDERLINE, I as $getDocument, Jn as KEY_DELETE_COMMAND, Jr as isDOMShadowRoot, K as $getSiblingCaret, Kn as KEY_ARROW_UP_COMMAND, Kr as isDOMDocumentNode, Kt as CLICK_COMMAND, L as $getEditor, Ln as IS_ITALIC, Mr as getDOMSelectionPoints, Nr as getDOMSelectionRange, Or as getActiveElement, Pn as IS_FIREFOX, Pt as $setPointFromCaret, Qn as KEY_TAB_COMMAND, Qt as COMMAND_PRIORITY_HIGH, S as $fullReconcile, St as $isTextNode, Tr as defineExtension, U as $getPreviousSelection, Un as KEY_ARROW_DOWN_COMMAND, V as $getNodeByKeyOrThrow, W as $getRoot, Wn as KEY_ARROW_LEFT_COMMAND, Xn as KEY_ESCAPE_COMMAND, Zt as COMMAND_PRIORITY_EDITOR, _n as FORMAT_ELEMENT_COMMAND, an as CUT_COMMAND, b as $findMatchingParent, br as configExtension, ci as mergeRegister, cn as DELETE_CHARACTER_COMMAND, cr as SELECTION_CHANGE_COMMAND, ct as $isInlineElementOrDecoratorNode, dt as $isLineBreakNode, ei as isHTMLTableRowElement, fi as removeClassNamesFromElement, g as $createRangeSelectionFromDom, gn as FOCUS_COMMAND, gt as $isRootOrShadowRoot, h as $createRangeSelection, hi as setDOMUnmanaged, hn as ElementNode, hr as TEXT_TYPE_TO_FORMAT, ht as $isRootNode, i as $caretFromPoint, in as COPY_COMMAND, jn as IS_BOLD, jr as getDOMSelection, ln as DELETE_LINE_COMMAND, lr as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, m as $createPoint, mi as setDOMStyleFromCSS, mt as $isRangeSelection, n as $applyNodeReplacement, ot as $isElementNode, p as $createParagraphNode, pi as safeCast, pt as $isParagraphNode, qn as KEY_BACKSPACE_COMMAND, qr as isDOMNode, rn as CONTROLLED_TEXT_INSERTION_COMMAND, rr as PASTE_COMMAND, rt as $isChildCaret, st as $isExtendableTextPointCaret, ui as registerEventListener, un as DELETE_WORD_COMMAND, ur as SELECT_ALL_COMMAND, v as $createTextNode, vn as FORMAT_TEXT_COMMAND, vr as addClassNamesToElement, w as $getAdjacentChildCaret, wn as INSERT_PARAGRAPH_COMMAND, xr as createCommand, y as $extendCaretToRange, yt as $isSiblingCaret, z as $getNearestNodeFromDOMNode, zn as IS_STRIKETHROUGH } from "./Lexical.node-8sRFmq2X.mjs";
3
+ import { c as CoreImportExtension, g as defineImportRule, h as contextValue, l as DOMImportExtension, m as ImportTextStyle, o as $propagateTextAlignToBlockChildren, p as ImportTextFormat, y as sel } from "./LexicalHtml.node-BYbzHNVe.mjs";
4
+ import { d as $unwrapAndFilterDescendants, m as objectKlassEquals, n as $dfs, o as $insertFirst, s as $insertNodeToNearestRoot, t as $descendantsMatching } from "./LexicalUtils.node-CIgMS8cG.mjs";
5
+ import { o as copyToClipboard, t as $getClipboardDataFromSelection } from "./LexicalClipboard.node-D4gMGws6.mjs";
6
+ //#region ../../node_modules/.pnpm/@lexical+table@0.48.0_typescript@6.0.3/node_modules/@lexical/table/dist/LexicalTable.prod.mjs
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ */
14
+ const tt = /^(\d+(?:\.\d+)?)px$/;
15
+ const nt = {
16
+ BOTH: 3,
17
+ COLUMN: 2,
18
+ NO_STATUS: 0,
19
+ ROW: 1
20
+ };
21
+ var ot = class ot extends ElementNode {
22
+ __colSpan;
23
+ __rowSpan;
24
+ __headerState;
25
+ __width;
26
+ __backgroundColor;
27
+ __verticalAlign;
28
+ static getType() {
29
+ return "tablecell";
30
+ }
31
+ static clone(e) {
32
+ return new ot(e.__headerState, e.__colSpan, e.__width, e.__key);
33
+ }
34
+ afterCloneFrom(e) {
35
+ super.afterCloneFrom(e), this.__rowSpan = e.__rowSpan, this.__backgroundColor = e.__backgroundColor, this.__verticalAlign = e.__verticalAlign, this.__colSpan = e.__colSpan, this.__headerState = e.__headerState, this.__width = e.__width;
36
+ }
37
+ static importDOM() {
38
+ return {
39
+ td: (e) => ({
40
+ conversion: rt,
41
+ priority: 0
42
+ }),
43
+ th: (e) => ({
44
+ conversion: rt,
45
+ priority: 0
46
+ })
47
+ };
48
+ }
49
+ static importJSON(e) {
50
+ return st().updateFromJSON(e);
51
+ }
52
+ updateFromJSON(e) {
53
+ return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan || 1).setRowSpan(e.rowSpan || 1).setWidth(e.width || void 0).setBackgroundColor(e.backgroundColor || null).setVerticalAlign(e.verticalAlign || void 0);
54
+ }
55
+ constructor(e = nt.NO_STATUS, t = 1, n, o) {
56
+ super(o), this.__colSpan = t, this.__rowSpan = 1, this.__headerState = e, this.__width = n, this.__backgroundColor = null, this.__verticalAlign = void 0;
57
+ }
58
+ createDOM(e) {
59
+ const o = $getDocument().createElement(this.getTag());
60
+ return this.__width && (o.style.width = `${this.__width}px`), this.__colSpan > 1 && (o.colSpan = this.__colSpan), this.__rowSpan > 1 && (o.rowSpan = this.__rowSpan), null !== this.__backgroundColor && (o.style.backgroundColor = this.__backgroundColor), lt(this.__verticalAlign) && (o.style.verticalAlign = this.__verticalAlign), addClassNamesToElement(o, e.theme.tableCell, this.hasHeader() && e.theme.tableCellHeader), o;
61
+ }
62
+ exportDOM(e) {
63
+ const t = super.exportDOM(e);
64
+ if (isHTMLElement(t.element)) {
65
+ const e = t.element;
66
+ e.setAttribute("data-temporary-table-cell-lexical-key", this.getKey()), e.style.border = "1px solid black", this.__colSpan > 1 && (e.colSpan = this.__colSpan), this.__rowSpan > 1 && (e.rowSpan = this.__rowSpan), e.style.width = `${this.getWidth() || 75}px`, e.style.verticalAlign = this.getVerticalAlign() || "top", e.style.textAlign = "start", null === this.__backgroundColor && this.hasHeader() && (e.style.backgroundColor = "#f2f3f5");
67
+ }
68
+ return t;
69
+ }
70
+ exportJSON() {
71
+ return {
72
+ ...super.exportJSON(),
73
+ ...lt(this.__verticalAlign) && { verticalAlign: this.__verticalAlign },
74
+ backgroundColor: this.getBackgroundColor(),
75
+ colSpan: this.__colSpan,
76
+ headerState: this.__headerState,
77
+ rowSpan: this.__rowSpan,
78
+ width: this.getWidth()
79
+ };
80
+ }
81
+ getColSpan() {
82
+ return this.getLatest().__colSpan;
83
+ }
84
+ setColSpan(e) {
85
+ const t = this.getWritable();
86
+ return t.__colSpan = e, t;
87
+ }
88
+ getRowSpan() {
89
+ return this.getLatest().__rowSpan;
90
+ }
91
+ setRowSpan(e) {
92
+ const t = this.getWritable();
93
+ return t.__rowSpan = e, t;
94
+ }
95
+ getTag() {
96
+ return this.hasHeader() ? "th" : "td";
97
+ }
98
+ setHeaderStyles(e, t = nt.BOTH) {
99
+ const n = this.getWritable();
100
+ return n.__headerState = e & t | n.__headerState & ~t, n;
101
+ }
102
+ getHeaderStyles() {
103
+ return this.getLatest().__headerState;
104
+ }
105
+ setWidth(e) {
106
+ const t = this.getWritable();
107
+ return t.__width = e, t;
108
+ }
109
+ getWidth() {
110
+ return this.getLatest().__width;
111
+ }
112
+ getBackgroundColor() {
113
+ return this.getLatest().__backgroundColor;
114
+ }
115
+ setBackgroundColor(e) {
116
+ const t = this.getWritable();
117
+ return t.__backgroundColor = e, t;
118
+ }
119
+ getVerticalAlign() {
120
+ return this.getLatest().__verticalAlign;
121
+ }
122
+ setVerticalAlign(e) {
123
+ const t = this.getWritable();
124
+ return t.__verticalAlign = e || void 0, t;
125
+ }
126
+ toggleHeaderStyle(e) {
127
+ const t = this.getWritable();
128
+ return (t.__headerState & e) === e ? t.__headerState -= e : t.__headerState += e, t;
129
+ }
130
+ hasHeaderState(e) {
131
+ return (this.getHeaderStyles() & e) === e;
132
+ }
133
+ hasHeader() {
134
+ return this.getLatest().__headerState !== nt.NO_STATUS;
135
+ }
136
+ updateDOM(e) {
137
+ return e.__headerState !== this.__headerState || e.__width !== this.__width || e.__colSpan !== this.__colSpan || e.__rowSpan !== this.__rowSpan || e.__backgroundColor !== this.__backgroundColor || e.__verticalAlign !== this.__verticalAlign;
138
+ }
139
+ isShadowRoot() {
140
+ return !0;
141
+ }
142
+ collapseAtStart() {
143
+ return !0;
144
+ }
145
+ canBeEmpty() {
146
+ return !1;
147
+ }
148
+ canIndent() {
149
+ return !1;
150
+ }
151
+ };
152
+ function lt(e) {
153
+ return "middle" === e || "bottom" === e;
154
+ }
155
+ function rt(e) {
156
+ const t = e, n = e.nodeName.toLowerCase();
157
+ let c;
158
+ tt.test(t.style.width) && (c = parseFloat(t.style.width));
159
+ let a = nt.NO_STATUS;
160
+ if ("th" === n) {
161
+ const e = t.getAttribute("scope");
162
+ if ("col" === e) a = nt.COLUMN;
163
+ else if ("row" === e) a = nt.ROW;
164
+ else {
165
+ const e = t.parentElement, n = isHTMLElement(e) && "tr" === e.nodeName.toLowerCase() && isHTMLElement(e.parentElement) && ("thead" === e.parentElement.nodeName.toLowerCase() || 0 === e.rowIndex), l = 0 === t.cellIndex;
166
+ n && (a |= nt.ROW), l && (a |= nt.COLUMN), a === nt.NO_STATUS && (a = nt.ROW);
167
+ }
168
+ }
169
+ const u = st(a, t.colSpan, c);
170
+ u.__rowSpan = t.rowSpan;
171
+ const h = t.style.backgroundColor;
172
+ "" !== h && (u.__backgroundColor = h);
173
+ const d = t.style.verticalAlign;
174
+ lt(d) && (u.__verticalAlign = d);
175
+ const f = t.style, g = (f && f.textDecoration || "").split(" "), m = "700" === f.fontWeight || "bold" === f.fontWeight, p = g.includes("line-through"), C = "italic" === f.fontStyle, _ = g.includes("underline"), S = f.color;
176
+ return {
177
+ after: (e) => {
178
+ const t = [];
179
+ let n = null;
180
+ const o = () => {
181
+ if (n) {
182
+ const e = n.getFirstChild();
183
+ $isLineBreakNode(e) && 1 === n.getChildrenSize() && e.remove();
184
+ }
185
+ };
186
+ for (const c of e) if ($isInlineElementOrDecoratorNode(c) || $isTextNode(c) || $isLineBreakNode(c)) {
187
+ if ($isTextNode(c) && (m && c.toggleFormat("bold"), p && c.toggleFormat("strikethrough"), C && c.toggleFormat("italic"), _ && c.toggleFormat("underline"), S)) {
188
+ const e = c.getStyle();
189
+ e.includes("color:") || c.setStyle(e + `color: ${S};`);
190
+ }
191
+ n ? n.append(c) : (n = $createParagraphNode().append(c), t.push(n));
192
+ } else t.push(c), o(), n = null;
193
+ return o(), 0 === t.length && t.push($createParagraphNode()), t;
194
+ },
195
+ node: u
196
+ };
197
+ }
198
+ function st(e = nt.NO_STATUS, t = 1, n) {
199
+ return $applyNodeReplacement(new ot(e, t, n));
200
+ }
201
+ function it(e) {
202
+ return e instanceof ot;
203
+ }
204
+ const ct = /* @__PURE__ */ createCommand("INSERT_TABLE_COMMAND");
205
+ function at(e, ...t) {
206
+ const n = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams();
207
+ o.append("code", e);
208
+ for (const e of t) o.append("v", e);
209
+ throw n.search = o.toString(), Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
210
+ }
211
+ var ut = class ut extends ElementNode {
212
+ __height;
213
+ static getType() {
214
+ return "tablerow";
215
+ }
216
+ static clone(e) {
217
+ return new ut(e.__height, e.__key);
218
+ }
219
+ afterCloneFrom(e) {
220
+ super.afterCloneFrom(e), this.__height = e.__height;
221
+ }
222
+ static importDOM() {
223
+ return { tr: (e) => ({
224
+ conversion: ht,
225
+ priority: 0
226
+ }) };
227
+ }
228
+ static importJSON(e) {
229
+ return dt().updateFromJSON(e);
230
+ }
231
+ updateFromJSON(e) {
232
+ return super.updateFromJSON(e).setHeight(e.height);
233
+ }
234
+ constructor(e, t) {
235
+ super(t), this.__height = e;
236
+ }
237
+ exportJSON() {
238
+ const e = this.getHeight();
239
+ return {
240
+ ...super.exportJSON(),
241
+ ...void 0 === e ? void 0 : { height: e }
242
+ };
243
+ }
244
+ createDOM(e) {
245
+ const o = $getDocument().createElement("tr");
246
+ return this.__height && (o.style.height = `${this.__height}px`), addClassNamesToElement(o, e.theme.tableRow), o;
247
+ }
248
+ extractWithChild(e, t, n) {
249
+ return "html" === n;
250
+ }
251
+ isShadowRoot() {
252
+ return !0;
253
+ }
254
+ setHeight(e) {
255
+ const t = this.getWritable();
256
+ return t.__height = e, t;
257
+ }
258
+ getHeight() {
259
+ return this.getLatest().__height;
260
+ }
261
+ updateDOM(e) {
262
+ return e.__height !== this.__height;
263
+ }
264
+ canBeEmpty() {
265
+ return !1;
266
+ }
267
+ canIndent() {
268
+ return !1;
269
+ }
270
+ };
271
+ function ht(e) {
272
+ const t = e;
273
+ let n;
274
+ return tt.test(t.style.height) && (n = parseFloat(t.style.height)), {
275
+ after: (e) => $descendantsMatching(e, it),
276
+ node: dt(n)
277
+ };
278
+ }
279
+ function dt(e) {
280
+ return $applyNodeReplacement(new ut(e));
281
+ }
282
+ function ft(e) {
283
+ return e instanceof ut;
284
+ }
285
+ function gt(e, t, n = !0) {
286
+ const o = no();
287
+ for (let l = 0; l < e; l++) {
288
+ const e = dt();
289
+ for (let o = 0; o < t; o++) {
290
+ let t = nt.NO_STATUS;
291
+ "object" == typeof n ? (0 === l && n.rows && (t |= nt.ROW), 0 === o && n.columns && (t |= nt.COLUMN)) : n && (0 === l && (t |= nt.ROW), 0 === o && (t |= nt.COLUMN));
292
+ const r = st(t), s = $createParagraphNode();
293
+ s.append($createTextNode()), r.append(s), e.append(r);
294
+ }
295
+ o.append(e);
296
+ }
297
+ return o;
298
+ }
299
+ function mt(e) {
300
+ const t = $findMatchingParent(e, (e) => it(e));
301
+ return it(t) ? t : null;
302
+ }
303
+ function pt(e) {
304
+ const t = $findMatchingParent(e, (e) => ft(e));
305
+ if (ft(t)) return t;
306
+ throw new Error("Expected table cell to be inside of table row.");
307
+ }
308
+ function Ct(e) {
309
+ const t = $findMatchingParent(e, (e) => oo(e));
310
+ if (oo(t)) return t;
311
+ throw new Error("Expected table cell to be inside of table.");
312
+ }
313
+ function _t(e) {
314
+ const t = pt(e);
315
+ return Ct(t).getChildren().findIndex((e) => e.is(t));
316
+ }
317
+ function St(e) {
318
+ return pt(e).getChildren().findIndex((t) => t.is(e));
319
+ }
320
+ function bt(e, t) {
321
+ const n = Ct(e), { x: o, y: l } = n.getCordsFromCellNode(e, t);
322
+ return {
323
+ above: n.getCellNodeFromCords(o, l - 1, t),
324
+ below: n.getCellNodeFromCords(o, l + 1, t),
325
+ left: n.getCellNodeFromCords(o - 1, l, t),
326
+ right: n.getCellNodeFromCords(o + 1, l, t)
327
+ };
328
+ }
329
+ function wt(e, t) {
330
+ const n = e.getChildren();
331
+ if (t >= n.length || t < 0) throw new Error("Expected table cell to be inside of table row.");
332
+ return n[t].remove(), e;
333
+ }
334
+ function yt(e, t, n = !0, o, l) {
335
+ const r = e.getChildren();
336
+ if (t >= r.length || t < 0) throw new Error("Table row target index out of range");
337
+ const s = r[t];
338
+ if (!ft(s)) throw new Error("Row before insertion index does not exist.");
339
+ for (let e = 0; e < o; e++) {
340
+ const e = s.getChildren(), t = e.length, o = dt();
341
+ for (let n = 0; n < t; n++) {
342
+ const t = e[n];
343
+ it(t) || at(12);
344
+ const { above: r, below: s } = bt(t, l);
345
+ let c = nt.NO_STATUS;
346
+ const a = r && r.getWidth() || s && s.getWidth() || void 0;
347
+ (r && r.hasHeaderState(nt.COLUMN) || s && s.hasHeaderState(nt.COLUMN)) && (c |= nt.COLUMN);
348
+ const u = st(c, 1, a);
349
+ u.append($createParagraphNode()), o.append(u);
350
+ }
351
+ n ? s.insertAfter(o) : s.insertBefore(o);
352
+ }
353
+ return e;
354
+ }
355
+ const Nt = (e, t) => e === nt.BOTH || e === t ? t : nt.NO_STATUS;
356
+ function xt(e = !0) {
357
+ const t = $getSelection();
358
+ $isRangeSelection(t) || tn(t) || at(188);
359
+ const n = t.anchor.getNode(), o = t.focus.getNode(), [l] = Ut(n), [r, , s] = Ut(o), [, i, c] = Dt(s, r, l), { startRow: a } = c, { startRow: u } = i;
360
+ return e ? Tt(a + l.__rowSpan > u + r.__rowSpan ? l : r, !0) : Tt(u < a ? r : l, !1);
361
+ }
362
+ const vt = xt;
363
+ function Tt(e, t = !0) {
364
+ const [, , n] = Ut(e), [o, l] = Dt(n, e, e), r = o[0].length, { startRow: s } = l;
365
+ let c = null;
366
+ if (t) {
367
+ const t = s + e.__rowSpan - 1, l = o[t], a = dt();
368
+ for (let e = 0; e < r; e++) {
369
+ const { cell: n, startRow: o } = l[e];
370
+ if (o + n.__rowSpan - 1 <= t) {
371
+ const t = l[e].cell.__headerState, n = Nt(t, nt.COLUMN);
372
+ a.append(st(n).append($createParagraphNode()));
373
+ } else n.setRowSpan(n.__rowSpan + 1);
374
+ }
375
+ const u = n.getChildAtIndex(t);
376
+ ft(u) || at(256), u.insertAfter(a), c = a;
377
+ } else {
378
+ const e = s, t = o[e], l = dt();
379
+ for (let n = 0; n < r; n++) {
380
+ const { cell: o, startRow: r } = t[n];
381
+ if (r === e) {
382
+ const e = t[n].cell.__headerState, o = Nt(e, nt.COLUMN);
383
+ l.append(st(o).append($createParagraphNode()));
384
+ } else o.setRowSpan(o.__rowSpan + 1);
385
+ }
386
+ const a = n.getChildAtIndex(e);
387
+ ft(a) || at(257), a.insertBefore(l), c = l;
388
+ }
389
+ return c;
390
+ }
391
+ function Rt(e, t, n = !0, o, l) {
392
+ const r = e.getChildren(), s = [];
393
+ for (let e = 0; e < r.length; e++) {
394
+ const n = r[e];
395
+ if (ft(n)) for (let e = 0; e < o; e++) {
396
+ const e = n.getChildren();
397
+ if (t >= e.length || t < 0) throw new Error("Table column target index out of range");
398
+ const o = e[t];
399
+ it(o) || at(12);
400
+ const { left: r, right: c } = bt(o, l);
401
+ let a = nt.NO_STATUS;
402
+ (r && r.hasHeaderState(nt.ROW) || c && c.hasHeaderState(nt.ROW)) && (a |= nt.ROW);
403
+ const u = st(a);
404
+ u.append($createParagraphNode()), s.push({
405
+ newTableCell: u,
406
+ targetCell: o
407
+ });
408
+ }
409
+ }
410
+ return s.forEach(({ newTableCell: e, targetCell: t }) => {
411
+ n ? t.insertAfter(e) : t.insertBefore(e);
412
+ }), e;
413
+ }
414
+ function Ft(e = !0) {
415
+ const t = $getSelection();
416
+ $isRangeSelection(t) || tn(t) || at(188);
417
+ const n = t.anchor.getNode(), o = t.focus.getNode(), [l] = Ut(n), [r, , s] = Ut(o), [, i, c] = Dt(s, r, l), { startColumn: a } = c, { startColumn: u } = i;
418
+ return e ? At(a + l.__colSpan > u + r.__colSpan ? l : r, !0) : At(u < a ? r : l, !1);
419
+ }
420
+ const Ot = Ft;
421
+ function At(e, t = !0, n = !0) {
422
+ const [, , o] = Ut(e), [l, r] = Dt(o, e, e), s = l.length, { startColumn: c } = r, a = t ? c + e.__colSpan - 1 : c - 1, u = o.getFirstChild();
423
+ ft(u) || at(120);
424
+ let h = null;
425
+ function d(e = nt.NO_STATUS) {
426
+ const t = st(e).append($createParagraphNode());
427
+ return null === h && (h = t), t;
428
+ }
429
+ let f = u;
430
+ e: for (let e = 0; e < s; e++) {
431
+ if (0 !== e) {
432
+ const e = f.getNextSibling();
433
+ ft(e) || at(121), f = e;
434
+ }
435
+ const t = l[e], n = t[a < 0 ? 0 : a].cell.__headerState, o = Nt(n, nt.ROW);
436
+ if (a < 0) {
437
+ zt(f, d(o));
438
+ continue;
439
+ }
440
+ const { cell: r, startColumn: s, startRow: i } = t[a];
441
+ if (s + r.__colSpan - 1 <= a) {
442
+ let n = r, l = i, s = a;
443
+ for (; l !== e && n.__rowSpan > 1;) {
444
+ if (s -= r.__colSpan, !(s >= 0)) {
445
+ f.append(d(o));
446
+ continue e;
447
+ }
448
+ {
449
+ const { cell: e, startRow: o } = t[s];
450
+ n = e, l = o;
451
+ }
452
+ }
453
+ n.insertAfter(d(o));
454
+ } else r.setColSpan(r.__colSpan + 1);
455
+ }
456
+ null !== h && n && Wt(h);
457
+ const g = o.getColWidths();
458
+ if (g) {
459
+ const e = [...g], t = a < 0 ? 0 : a, n = e[t];
460
+ e.splice(t, 0, n), o.setColWidths(e);
461
+ }
462
+ return h;
463
+ }
464
+ function Kt(e, t) {
465
+ const n = e.getChildren();
466
+ for (let e = 0; e < n.length; e++) {
467
+ const o = n[e];
468
+ if (ft(o)) {
469
+ const e = o.getChildren();
470
+ if (t >= e.length || t < 0) throw new Error("Table column target index out of range");
471
+ e[t].remove();
472
+ }
473
+ }
474
+ return e;
475
+ }
476
+ function kt() {
477
+ const e = $getSelection();
478
+ $isRangeSelection(e) || tn(e) || at(188);
479
+ const [t, n] = e.isBackward() ? [e.focus.getNode(), e.anchor.getNode()] : [e.anchor.getNode(), e.focus.getNode()], [o, , l] = Ut(t), [r] = Ut(n), [s, i, c] = Dt(l, o, r), { startRow: a } = i, { startRow: u } = c, f = u + r.__rowSpan - 1;
480
+ if (s.length === f - a + 1) return void l.remove();
481
+ const g = s[0].length, m = s[f + 1], p = l.getChildAtIndex(f + 1);
482
+ for (let e = f; e >= a; e--) {
483
+ for (let t = g - 1; t >= 0; t--) {
484
+ const { cell: n, startRow: o, startColumn: l } = s[e][t];
485
+ if (l === t) {
486
+ if (o < a || o + n.__rowSpan - 1 > f) {
487
+ const e = Math.max(o, a), t = Math.min(n.__rowSpan + o - 1, f), l = e <= t ? t - e + 1 : 0;
488
+ n.setRowSpan(n.__rowSpan - l);
489
+ }
490
+ if (o >= a && o + n.__rowSpan - 1 > f && e === f) {
491
+ ft(p) || at(387);
492
+ let o = null;
493
+ for (let n = 0; n < t; n++) {
494
+ const t = m[n], l = t.cell;
495
+ t.startRow === e + 1 && (o = l), l.__colSpan > 1 && (n += l.__colSpan - 1);
496
+ }
497
+ null === o ? zt(p, n) : o.insertAfter(n);
498
+ }
499
+ }
500
+ }
501
+ const t = l.getChildAtIndex(e);
502
+ ft(t) || at(206, String(e)), t.remove();
503
+ }
504
+ if (void 0 !== m) {
505
+ const { cell: e } = m[0];
506
+ Wt(e);
507
+ } else {
508
+ const { cell: t } = s[a - 1][0];
509
+ Wt(t);
510
+ }
511
+ }
512
+ const Mt = kt;
513
+ function Et() {
514
+ const e = $getSelection();
515
+ $isRangeSelection(e) || tn(e) || at(188);
516
+ const t = e.anchor.getNode(), n = e.focus.getNode(), [o, , l] = Ut(t), [r] = Ut(n), [s, i, c] = Dt(l, o, r), { startColumn: a } = i, { startRow: u, startColumn: f } = c, g = Math.min(a, f), m = Math.max(a + o.__colSpan - 1, f + r.__colSpan - 1), p = m - g + 1;
517
+ if (s[0].length === m - g + 1) return l.selectPrevious(), void l.remove();
518
+ const C = s.length;
519
+ for (let e = 0; e < C; e++) for (let t = g; t <= m; t++) {
520
+ const { cell: n, startColumn: o } = s[e][t];
521
+ if (o < g) {
522
+ if (t === g) {
523
+ const e = g - o;
524
+ n.setColSpan(n.__colSpan - Math.min(p, n.__colSpan - e));
525
+ }
526
+ } else if (o + n.__colSpan - 1 > m) {
527
+ if (t === m) {
528
+ const e = m - o + 1;
529
+ n.setColSpan(n.__colSpan - e);
530
+ }
531
+ } else n.remove();
532
+ }
533
+ const _ = s[u], S = a > f ? _[a + o.__colSpan] : _[f + r.__colSpan];
534
+ if (void 0 !== S) {
535
+ const { cell: e } = S;
536
+ Wt(e);
537
+ } else {
538
+ const { cell: t } = f < a ? _[f - 1] : _[a - 1];
539
+ Wt(t);
540
+ }
541
+ const b = l.getColWidths();
542
+ if (b) {
543
+ const e = [...b];
544
+ e.splice(g, p), l.setColWidths(e);
545
+ }
546
+ }
547
+ const $t = Et;
548
+ function Wt(e) {
549
+ const t = e.getFirstDescendant();
550
+ null == t ? e.selectStart() : t.getParentOrThrow().selectStart();
551
+ }
552
+ function zt(e, t) {
553
+ const n = e.getFirstChild();
554
+ null !== n ? n.insertBefore(t) : e.append(t);
555
+ }
556
+ function Ht(e) {
557
+ if (0 === e.length) return null;
558
+ const [n] = It(Ct(e[0]), null, null);
559
+ let o = Infinity, l = -Infinity, r = Infinity, s = -Infinity;
560
+ const c = /* @__PURE__ */ new Set();
561
+ for (const t of n) for (const n of t) {
562
+ if (!n || !n.cell) continue;
563
+ const t = n.cell.getKey();
564
+ if (!c.has(t) && e.some((e) => e.is(n.cell))) {
565
+ c.add(t);
566
+ const e = n.startRow, i = n.startColumn, a = n.cell.__rowSpan || 1, u = n.cell.__colSpan || 1;
567
+ o = Math.min(o, e), l = Math.max(l, e + a - 1), r = Math.min(r, i), s = Math.max(s, i + u - 1);
568
+ }
569
+ }
570
+ if (o === Infinity || r === Infinity) return null;
571
+ const a = l - o + 1, u = s - r + 1, h = n[o][r];
572
+ if (!h.cell) return null;
573
+ const d = h.cell;
574
+ d.setColSpan(u), d.setRowSpan(a);
575
+ const f = /* @__PURE__ */ new Set([d.getKey()]);
576
+ for (let e = o; e <= l; e++) for (let t = r; t <= s; t++) {
577
+ const o = n[e][t];
578
+ if (!o.cell) continue;
579
+ const l = o.cell, r = l.getKey();
580
+ if (!f.has(r)) {
581
+ f.add(r);
582
+ Bt(l) || d.append(...l.getChildren()), l.remove();
583
+ }
584
+ }
585
+ return 0 === d.getChildrenSize() && d.append($createParagraphNode()), d;
586
+ }
587
+ function Bt(e) {
588
+ if (1 !== e.getChildrenSize()) return !1;
589
+ const t = e.getFirstChildOrThrow();
590
+ return !(!$isParagraphNode(t) || !t.isEmpty());
591
+ }
592
+ function Lt() {
593
+ const e = $getSelection();
594
+ $isRangeSelection(e) || tn(e) || at(188);
595
+ const n = $findMatchingParent(e.anchor.getNode(), it);
596
+ return it(n) || at(148), Pt(n);
597
+ }
598
+ function Pt(e) {
599
+ const [t, n, o] = Ut(e), l = t.__colSpan, r = t.__rowSpan;
600
+ if (1 === l && 1 === r) return;
601
+ const [s, c] = Dt(o, t, t), { startColumn: a, startRow: u } = c, h = t.__headerState & nt.COLUMN, d = Array.from({ length: l }, (e, t) => {
602
+ let n = h;
603
+ for (let e = 0; 0 !== n && e < s.length; e++) n &= s[e][t + a].cell.__headerState;
604
+ return n;
605
+ }), f = t.__headerState & nt.ROW, g = Array.from({ length: r }, (e, t) => {
606
+ let n = f;
607
+ for (let e = 0; 0 !== n && e < s[0].length; e++) n &= s[t + u][e].cell.__headerState;
608
+ return n;
609
+ });
610
+ if (l > 1) {
611
+ for (let e = 1; e < l; e++) t.insertAfter(st(d[e] | g[0]).append($createParagraphNode()));
612
+ t.setColSpan(1);
613
+ }
614
+ if (r > 1) {
615
+ let e;
616
+ for (let t = 1; t < r; t++) {
617
+ const o = u + t, r = s[o];
618
+ e = (e || n).getNextSibling(), ft(e) || at(125);
619
+ let c = null;
620
+ for (let e = 0; e < a; e++) {
621
+ const t = r[e], n = t.cell;
622
+ t.startRow === o && (c = n), n.__colSpan > 1 && (e += n.__colSpan - 1);
623
+ }
624
+ if (null === c) for (let n = l - 1; n >= 0; n--) zt(e, st(d[n] | g[t]).append($createParagraphNode()));
625
+ else for (let e = l - 1; e >= 0; e--) c.insertAfter(st(d[e] | g[t]).append($createParagraphNode()));
626
+ }
627
+ t.setRowSpan(1);
628
+ }
629
+ }
630
+ function Dt(e, t, n) {
631
+ const [o, l, r] = It(e, t, n);
632
+ return null === l && at(207), null === r && at(208), [
633
+ o,
634
+ l,
635
+ r
636
+ ];
637
+ }
638
+ function It(e, t, n) {
639
+ const o = [];
640
+ let l = null, r = null;
641
+ function s(e) {
642
+ let t = o[e];
643
+ return void 0 === t && (o[e] = t = []), t;
644
+ }
645
+ const i = e.getChildren();
646
+ for (let e = 0; e < i.length; e++) {
647
+ const o = i[e];
648
+ ft(o) || at(209);
649
+ const c = s(e);
650
+ for (let a = o.getFirstChild(), u = 0; null != a; a = a.getNextSibling()) {
651
+ for (it(a) || at(147); void 0 !== c[u];) u++;
652
+ const o = {
653
+ cell: a,
654
+ startColumn: u,
655
+ startRow: e
656
+ }, { __rowSpan: h, __colSpan: d } = a;
657
+ for (let t = 0; t < h && !(e + t >= i.length); t++) {
658
+ const n = s(e + t);
659
+ for (let e = 0; e < d; e++) n[u + e] = o;
660
+ }
661
+ null !== t && null === l && t.is(a) && (l = o), null !== n && null === r && n.is(a) && (r = o);
662
+ }
663
+ }
664
+ return [
665
+ o,
666
+ l,
667
+ r
668
+ ];
669
+ }
670
+ function Ut(e) {
671
+ let t;
672
+ if (e instanceof ot) t = e;
673
+ else if ("__type" in e) {
674
+ const n = $findMatchingParent(e, it);
675
+ it(n) || at(148), t = n;
676
+ } else {
677
+ const n = $findMatchingParent(e.getNode(), it);
678
+ it(n) || at(148), t = n;
679
+ }
680
+ const n = t.getParent();
681
+ ft(n) || at(149);
682
+ const o = n.getParent();
683
+ return oo(o) || at(210), [
684
+ t,
685
+ n,
686
+ o
687
+ ];
688
+ }
689
+ function Xt(e, t, n) {
690
+ let o, l = Math.min(t.startColumn, n.startColumn), r = Math.min(t.startRow, n.startRow), s = Math.max(t.startColumn + t.cell.__colSpan - 1, n.startColumn + n.cell.__colSpan - 1), i = Math.max(t.startRow + t.cell.__rowSpan - 1, n.startRow + n.cell.__rowSpan - 1);
691
+ do {
692
+ o = !1;
693
+ for (let t = 0; t < e.length; t++) for (let n = 0; n < e[0].length; n++) {
694
+ const c = e[t][n];
695
+ if (!c) continue;
696
+ const a = c.startColumn + c.cell.__colSpan - 1, u = c.startRow + c.cell.__rowSpan - 1, h = c.startColumn <= s && a >= l, d = c.startRow <= i && u >= r;
697
+ if (h && d) {
698
+ const e = Math.min(l, c.startColumn), t = Math.max(s, a), n = Math.min(r, c.startRow), h = Math.max(i, u);
699
+ e === l && t === s && n === r && h === i || (l = e, s = t, r = n, i = h, o = !0);
700
+ }
701
+ }
702
+ } while (o);
703
+ return {
704
+ maxColumn: s,
705
+ maxRow: i,
706
+ minColumn: l,
707
+ minRow: r
708
+ };
709
+ }
710
+ function Yt(e) {
711
+ const t = e.getChildren();
712
+ let n = null;
713
+ for (const e of t) {
714
+ if (!ft(e)) return !1;
715
+ if (null === n && (n = e.getChildrenSize()), e.getChildrenSize() !== n) return !1;
716
+ const t = e.getChildren();
717
+ for (const e of t) if (!it(e) || 1 !== e.getRowSpan() || 1 !== e.getColSpan()) return !1;
718
+ }
719
+ return (n || 0) > 0;
720
+ }
721
+ function Jt(e, t, n) {
722
+ if (t === n) return;
723
+ const o = e.getColumnCount();
724
+ if (t < 0 || t >= o || n < 0 || n >= o) return;
725
+ if (!Yt(e)) return;
726
+ e.getChildren().filter(ft).forEach((e) => {
727
+ const o = e.getChildren(), [l] = o.splice(t, 1);
728
+ o.splice(n, 0, l), e.splice(0, o.length, o);
729
+ });
730
+ const l = e.getColWidths();
731
+ if (l && l.length === o) {
732
+ const o = [...l], [r] = o.splice(t, 1);
733
+ o.splice(n, 0, r), e.setColWidths(o);
734
+ }
735
+ }
736
+ function qt(e, t, n) {
737
+ if (t === n) return;
738
+ const o = e.getChildren().filter(ft), l = o.length;
739
+ if (t < 0 || t >= l || n < 0 || n >= l) return;
740
+ if (!Yt(e)) return;
741
+ const r = o[t], s = o[n];
742
+ n > t ? s.insertAfter(r) : s.insertBefore(r);
743
+ }
744
+ function jt(e) {
745
+ const [t, , n] = Ut(e), o = n.getChildren().filter(ft), l = o.length, r = o[0].getChildren().length, s = new Array(l);
746
+ for (let e = 0; e < l; e++) s[e] = new Array(r);
747
+ for (let e = 0; e < l; e++) {
748
+ const n = o[e].getChildren().filter(it);
749
+ let l = 0;
750
+ for (let o = 0; o < n.length; o++) {
751
+ for (; s[e][l];) l++;
752
+ const r = n[o], i = r.__rowSpan || 1, c = r.__colSpan || 1;
753
+ for (let t = 0; t < i; t++) for (let n = 0; n < c; n++) s[e + t][l + n] = r;
754
+ if (t === r) return {
755
+ colSpan: c,
756
+ columnIndex: l,
757
+ rowIndex: e,
758
+ rowSpan: i
759
+ };
760
+ l += c;
761
+ }
762
+ }
763
+ return null;
764
+ }
765
+ function Vt(e, t) {
766
+ const n = t.getStartEndPoints(), o = tn(t);
767
+ if (null === n) return !1;
768
+ const [l, s] = n, [c, a, u] = Ut(l), h = $findMatchingParent(s.getNode(), (e) => it(e));
769
+ if (!(it(c) && it(h) && ft(a) && oo(u))) return !1;
770
+ const [d, g, m] = Dt(u, c, h), [p] = It(e, null, null), C = d.length, _ = C > 0 ? d[0].length : 0;
771
+ let S = g.startRow, b = g.startColumn, w = p.length, y = w > 0 ? p[0].length : 0;
772
+ if (o) {
773
+ const e = Xt(d, g, m), t = e.maxRow - e.minRow + 1, n = e.maxColumn - e.minColumn + 1;
774
+ S = e.minRow, b = e.minColumn, w = Math.min(w, t), y = Math.min(y, n);
775
+ }
776
+ let N = !1;
777
+ const x = Math.min(C, S + w) - 1, v = Math.min(_, b + y) - 1, T = /* @__PURE__ */ new Set();
778
+ for (let e = S; e <= x; e++) for (let t = b; t <= v; t++) {
779
+ const n = d[e][t];
780
+ T.has(n.cell.getKey()) || 1 === n.cell.__rowSpan && 1 === n.cell.__colSpan || (Pt(n.cell), T.add(n.cell.getKey()), N = !0);
781
+ }
782
+ let [R] = It(u.getWritable(), null, null);
783
+ const F = w - C + S;
784
+ for (let e = 0; e < F; e++) Tt(R[C - 1][0].cell);
785
+ const O = y - _ + b;
786
+ for (let e = 0; e < O; e++) At(R[0][_ - 1].cell, !0, !1);
787
+ [R] = It(u.getWritable(), null, null);
788
+ for (let e = S; e < S + w; e++) for (let t = b; t < b + y; t++) {
789
+ const n = e - S, o = t - b, l = p[n][o];
790
+ if (l.startRow !== n || l.startColumn !== o) continue;
791
+ const s = l.cell;
792
+ if (1 !== s.__rowSpan || 1 !== s.__colSpan) {
793
+ const n = [], o = Math.min(e + s.__rowSpan, S + w) - 1, l = Math.min(t + s.__colSpan, b + y) - 1;
794
+ for (let r = e; r <= o; r++) for (let e = t; e <= l; e++) {
795
+ const t = R[r][e];
796
+ n.push(t.cell);
797
+ }
798
+ Ht(n), N = !0;
799
+ }
800
+ const { cell: c } = R[e][t], a = s.getBackgroundColor();
801
+ null != a && c.setBackgroundColor(a);
802
+ const u = c.getChildren();
803
+ s.getChildren().forEach((e) => {
804
+ if ($isTextNode(e)) $createParagraphNode().append(e), c.append(e);
805
+ else c.append(e);
806
+ }), u.forEach((e) => e.remove());
807
+ }
808
+ if (o && N) {
809
+ const [e] = It(u.getWritable(), null, null);
810
+ e[g.startRow][g.startColumn].cell.selectEnd();
811
+ }
812
+ return !0;
813
+ }
814
+ function Gt(e, t, n) {
815
+ const [o] = It(e, null, null);
816
+ t >= 0 && t < o.length || at(396, String(t));
817
+ const l = o[t], r = n ? nt.ROW : nt.NO_STATUS, s = /* @__PURE__ */ new Set();
818
+ for (let e = 0; e < l.length; e++) {
819
+ const t = l[e];
820
+ null != t && (s.has(t.cell) || (s.add(t.cell), t.cell.setHeaderStyles(r, nt.ROW)));
821
+ }
822
+ }
823
+ function Qt(e, t, n) {
824
+ const [o] = It(e, null, null);
825
+ o.length > 0 && t >= 0 && t < o[0].length || at(397, String(t));
826
+ const l = n ? nt.COLUMN : nt.NO_STATUS, r = /* @__PURE__ */ new Set();
827
+ for (let e = 0; e < o.length; e++) {
828
+ const n = o[e][t];
829
+ null != n && (r.has(n.cell) || (r.add(n.cell), n.cell.setHeaderStyles(l, nt.COLUMN)));
830
+ }
831
+ }
832
+ function Zt(e) {
833
+ const [[t, n, o, l], [r, s, i, c]] = ["anchor", "focus"].map((t) => {
834
+ const n = e[t].getNode(), o = $findMatchingParent(n, it);
835
+ it(o) || at(238, t, n.getKey(), n.getType());
836
+ const l = o.getParent();
837
+ ft(l) || at(239, t);
838
+ const r = l.getParent();
839
+ return oo(r) || at(240, t), [
840
+ n,
841
+ o,
842
+ l,
843
+ r
844
+ ];
845
+ });
846
+ return l.is(c) || at(241), {
847
+ anchorCell: n,
848
+ anchorNode: t,
849
+ anchorRow: o,
850
+ anchorTable: l,
851
+ focusCell: s,
852
+ focusNode: r,
853
+ focusRow: i,
854
+ focusTable: c
855
+ };
856
+ }
857
+ var en = class en {
858
+ tableKey;
859
+ anchor;
860
+ focus;
861
+ _cachedNodes;
862
+ dirty;
863
+ constructor(e, t, n) {
864
+ this.anchor = t, this.focus = n, t._selection = this, n._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = e;
865
+ }
866
+ getStartEndPoints() {
867
+ return [this.anchor, this.focus];
868
+ }
869
+ isValid() {
870
+ if ("root" === this.tableKey || "root" === this.anchor.key || "element" !== this.anchor.type || "root" === this.focus.key || "element" !== this.focus.type) return !1;
871
+ const e = $getNodeByKey(this.tableKey), t = $getNodeByKey(this.anchor.key), n = $getNodeByKey(this.focus.key);
872
+ return null !== e && null !== t && null !== n;
873
+ }
874
+ isBackward() {
875
+ return this.focus.isBefore(this.anchor);
876
+ }
877
+ getCachedNodes() {
878
+ return this._cachedNodes;
879
+ }
880
+ setCachedNodes(e) {
881
+ this._cachedNodes = e;
882
+ }
883
+ is(e) {
884
+ return tn(e) && this.tableKey === e.tableKey && this.anchor.is(e.anchor) && this.focus.is(e.focus);
885
+ }
886
+ set(e, t, n) {
887
+ this.dirty = this.dirty || e !== this.tableKey || t !== this.anchor.key || n !== this.focus.key, this.tableKey = e, this.anchor.key = t, this.focus.key = n, this._cachedNodes = null;
888
+ }
889
+ clone() {
890
+ return new en(this.tableKey, $createPoint(this.anchor.key, this.anchor.offset, this.anchor.type), $createPoint(this.focus.key, this.focus.offset, this.focus.type));
891
+ }
892
+ isCollapsed() {
893
+ return !1;
894
+ }
895
+ extract() {
896
+ return this.getNodes();
897
+ }
898
+ insertRawText(e) {
899
+ if ("" === e) return;
900
+ const t = (e.endsWith("\n") ? e.slice(0, -1) : e).split("\n").map((e) => e.split(" ")), n = no();
901
+ for (const e of t) {
902
+ const t = dt();
903
+ for (const n of e) {
904
+ const e = st(nt.NO_STATUS), o = $createParagraphNode();
905
+ n && o.append($createTextNode(n)), e.append(o), t.append(e);
906
+ }
907
+ n.append(t);
908
+ }
909
+ const { anchorCell: o } = Zt(this);
910
+ Vt(n, o.select(0, o.getChildrenSize()));
911
+ }
912
+ insertText() {}
913
+ hasFormat(e) {
914
+ let t = 0;
915
+ this.getNodes().filter(it).forEach((e) => {
916
+ const n = e.getFirstChild();
917
+ $isParagraphNode(n) && (t |= n.getTextFormat());
918
+ });
919
+ const n = TEXT_TYPE_TO_FORMAT[e];
920
+ return 0 !== (t & n);
921
+ }
922
+ insertNodes(e) {
923
+ const t = this.focus.getNode();
924
+ $isElementNode(t) || at(151);
925
+ $normalizeSelection__EXPERIMENTAL(t.select(0, t.getChildrenSize())).insertNodes(e);
926
+ }
927
+ getShape() {
928
+ const { anchorCell: e, focusCell: t } = Zt(this), n = jt(e);
929
+ null === n && at(153);
930
+ const o = jt(t);
931
+ null === o && at(155);
932
+ const l = Math.min(n.columnIndex, o.columnIndex), r = Math.max(n.columnIndex + n.colSpan - 1, o.columnIndex + o.colSpan - 1), s = Math.min(n.rowIndex, o.rowIndex), i = Math.max(n.rowIndex + n.rowSpan - 1, o.rowIndex + o.rowSpan - 1);
933
+ return {
934
+ fromX: Math.min(l, r),
935
+ fromY: Math.min(s, i),
936
+ toX: Math.max(l, r),
937
+ toY: Math.max(s, i)
938
+ };
939
+ }
940
+ getNodes() {
941
+ if (!this.isValid()) return [];
942
+ const e = this._cachedNodes;
943
+ if (null !== e) return e;
944
+ const { anchorTable: t, anchorCell: n, focusCell: o } = Zt(this), l = o.getParents()[1];
945
+ if (l !== t) {
946
+ if (t.isParentOf(o)) {
947
+ const e = l.getParent();
948
+ e ?? at(159), this.set(this.tableKey, o.getKey(), e.getKey());
949
+ } else {
950
+ const e = t.getParent();
951
+ e ?? at(158), this.set(this.tableKey, e.getKey(), o.getKey());
952
+ }
953
+ return this.getNodes();
954
+ }
955
+ const [r, s, i] = Dt(t, n, o), { minColumn: c, maxColumn: a, minRow: u, maxRow: h } = Xt(r, s, i), d = /* @__PURE__ */ new Map([[t.getKey(), t]]);
956
+ let f = null;
957
+ for (let e = u; e <= h; e++) for (let t = c; t <= a; t++) {
958
+ const { cell: n } = r[e][t], o = n.getParent();
959
+ ft(o) || at(160), o !== f && (d.set(o.getKey(), o), f = o), d.has(n.getKey()) || ln(n, (e) => {
960
+ d.set(e.getKey(), e);
961
+ });
962
+ }
963
+ const g = Array.from(d.values());
964
+ return isCurrentlyReadOnlyMode() || (this._cachedNodes = g), g;
965
+ }
966
+ getTextContent() {
967
+ const e = this.getNodes().filter((e) => it(e));
968
+ let t = "";
969
+ for (let n = 0; n < e.length; n++) {
970
+ const o = e[n], l = o.__parent, r = (e[n + 1] || {}).__parent;
971
+ t += o.getTextContent() + (r !== l ? "\n" : " ");
972
+ }
973
+ return t;
974
+ }
975
+ };
976
+ function tn(e) {
977
+ return e instanceof en;
978
+ }
979
+ function nn() {
980
+ return new en("root", $createPoint("root", 0, "element"), $createPoint("root", 0, "element"));
981
+ }
982
+ function on(e, t, n) {
983
+ e.getKey(), t.getKey(), n.getKey();
984
+ const o = $getSelection(), l = tn(o) ? o.clone() : nn();
985
+ return l.set(e.getKey(), t.getKey(), n.getKey()), l;
986
+ }
987
+ function ln(e, t) {
988
+ const n = [[e]];
989
+ for (let e = n.at(-1); void 0 !== e && n.length > 0; e = n.at(-1)) {
990
+ const o = e.pop();
991
+ void 0 === o ? n.pop() : !1 !== t(o) && $isElementNode(o) && n.push(o.getChildren());
992
+ }
993
+ }
994
+ function rn(e, t = $getEditor()) {
995
+ const n = $getNodeByKey(e);
996
+ oo(n) || at(231, e);
997
+ const o = gn(n, t.getElementByKey(e));
998
+ return null === o && at(232, e), {
999
+ tableElement: o,
1000
+ tableNode: n
1001
+ };
1002
+ }
1003
+ var sn = class {
1004
+ observers;
1005
+ nextFocus;
1006
+ shouldCheckSelectionForTable;
1007
+ constructor() {
1008
+ this.observers = /* @__PURE__ */ new Map(), this.nextFocus = null, this.shouldCheckSelectionForTable = null;
1009
+ }
1010
+ setNextFocus(e) {
1011
+ this.nextFocus = e;
1012
+ }
1013
+ getAndClearNextFocus() {
1014
+ const { nextFocus: e } = this;
1015
+ return null !== e && (this.nextFocus = null), e;
1016
+ }
1017
+ setShouldCheckSelectionForTable(e) {
1018
+ this.shouldCheckSelectionForTable = e;
1019
+ }
1020
+ getAndClearShouldCheckSelectionForTable() {
1021
+ const { shouldCheckSelectionForTable: e } = this;
1022
+ return e ? (this.shouldCheckSelectionForTable = null, e) : null;
1023
+ }
1024
+ removeObserver(e) {
1025
+ const t = this.observers.get(e);
1026
+ return void 0 !== t && (t[0].removeListeners(), this.observers.delete(e), !0);
1027
+ }
1028
+ removeAllObservers() {
1029
+ for (const e of Array.from(this.observers.keys())) this.removeObserver(e);
1030
+ }
1031
+ $getTableNodesAndObservers() {
1032
+ const e = [];
1033
+ for (const [t, [n]] of Array.from(this.observers.entries())) {
1034
+ const o = $getNodeByKey(t);
1035
+ oo(o) ? e.push([o, n]) : this.removeObserver(t);
1036
+ }
1037
+ return e;
1038
+ }
1039
+ };
1040
+ var cn = class {
1041
+ focusX;
1042
+ focusY;
1043
+ listenersToRemove;
1044
+ table;
1045
+ isHighlightingCells;
1046
+ anchorX;
1047
+ anchorY;
1048
+ tableNodeKey;
1049
+ anchorCell;
1050
+ focusCell;
1051
+ anchorCellNodeKey;
1052
+ focusCellNodeKey;
1053
+ editor;
1054
+ tableSelection;
1055
+ hasHijackedSelectionStyles;
1056
+ isSelecting;
1057
+ pointerType;
1058
+ abortController;
1059
+ listenerOptions;
1060
+ constructor(e, t) {
1061
+ this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.listenersToRemove = /* @__PURE__ */ new Set(), this.tableNodeKey = t, this.editor = e, this.table = {
1062
+ columns: 0,
1063
+ domRows: [],
1064
+ rows: 0
1065
+ }, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.isSelecting = !1, this.pointerType = null, this.abortController = new AbortController(), this.listenerOptions = { signal: this.abortController.signal }, this.trackTable();
1066
+ }
1067
+ getTable() {
1068
+ return this.table;
1069
+ }
1070
+ removeListeners() {
1071
+ this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach((e) => e()), this.listenersToRemove.clear();
1072
+ }
1073
+ $lookup() {
1074
+ return rn(this.tableNodeKey, this.editor);
1075
+ }
1076
+ trackTable() {
1077
+ const e = new MutationObserver((e) => {
1078
+ this.editor.read("latest", () => {
1079
+ let t = !1;
1080
+ for (let n = 0; n < e.length; n++) {
1081
+ const o = e[n].target.nodeName;
1082
+ if ("TABLE" === o || "TBODY" === o || "THEAD" === o || "TR" === o) {
1083
+ t = !0;
1084
+ break;
1085
+ }
1086
+ }
1087
+ if (!t) return;
1088
+ const { tableNode: n, tableElement: o } = this.$lookup();
1089
+ this.table = Rn(n, o);
1090
+ });
1091
+ });
1092
+ this.editor.read("latest", () => {
1093
+ const { tableNode: t, tableElement: n } = this.$lookup();
1094
+ this.table = Rn(t, n), e.observe(n, {
1095
+ attributes: !0,
1096
+ childList: !0,
1097
+ subtree: !0
1098
+ });
1099
+ });
1100
+ }
1101
+ $clearHighlight(e = !0) {
1102
+ const t = this.editor;
1103
+ this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.tableSelection = null, this.anchorCellNodeKey = null, this.focusCellNodeKey = null, this.anchorCell = null, this.focusCell = null, this.hasHijackedSelectionStyles = !1, this.$enableHighlightStyle();
1104
+ const { tableNode: n, tableElement: o } = this.$lookup();
1105
+ Fn(t, Rn(n, o), null), e && null !== $getSelection() && ($setSelection(null), t.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0));
1106
+ }
1107
+ $enableHighlightStyle() {
1108
+ const e = this.editor, { tableElement: t } = this.$lookup();
1109
+ removeClassNamesFromElement(t, e._config.theme.tableSelection), t.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1;
1110
+ }
1111
+ $disableHighlightStyle() {
1112
+ const { tableElement: e } = this.$lookup();
1113
+ addClassNamesToElement(e, this.editor._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0;
1114
+ }
1115
+ $updateTableTableSelection(e) {
1116
+ if (null !== e) {
1117
+ e.tableKey !== this.tableNodeKey && at(233, e.tableKey, this.tableNodeKey);
1118
+ const t = this.editor;
1119
+ this.tableSelection = e, this.isHighlightingCells = !0, this.$disableHighlightStyle(), this.updateDOMSelection(), Fn(t, this.table, this.tableSelection);
1120
+ } else this.$clearHighlight();
1121
+ }
1122
+ updateDOMSelection() {
1123
+ if (null !== this.anchorCell && null !== this.focusCell) {
1124
+ const e = getDOMSelection(this.editor._window);
1125
+ e && e.rangeCount > 0 && e.removeAllRanges();
1126
+ }
1127
+ }
1128
+ $setFocusCellForSelection(e, t = !1) {
1129
+ const n = this.editor, { tableNode: o } = this.$lookup(), l = e.x, r = e.y;
1130
+ if (this.focusCell = e, !this.isHighlightingCells) (t || this.anchorX !== l || this.anchorY !== r || null != this.tableSelection && null != this.anchorCellNodeKey) && (this.isHighlightingCells = !0, this.$disableHighlightStyle());
1131
+ if (-1 !== this.focusX && -1 !== this.focusY && l === this.focusX && r === this.focusY) return !1;
1132
+ if (this.focusX = l, this.focusY = r, this.isHighlightingCells) {
1133
+ const s = Jn(o, e.elem);
1134
+ if (null != this.tableSelection && null != this.anchorCellNodeKey) {
1135
+ let e = s;
1136
+ if (null === e && t && (e = o.getCellNodeFromCords(l, r, this.table)), null !== e) {
1137
+ const t = this.$getAnchorTableCellOrThrow();
1138
+ return this.focusCellNodeKey = e.getKey(), this.tableSelection = on(o, t, e), $setSelection(this.tableSelection), n.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0), Fn(n, this.table, this.tableSelection), !0;
1139
+ }
1140
+ }
1141
+ }
1142
+ return !1;
1143
+ }
1144
+ $getAnchorTableCell() {
1145
+ const e = this.anchorCellNodeKey ? $getNodeByKey(this.anchorCellNodeKey) : null;
1146
+ return it(e) ? e : null;
1147
+ }
1148
+ $getAnchorTableCellOrThrow() {
1149
+ const e = this.$getAnchorTableCell();
1150
+ return null === e && at(234), e;
1151
+ }
1152
+ $getFocusTableCell() {
1153
+ const e = this.focusCellNodeKey ? $getNodeByKey(this.focusCellNodeKey) : null;
1154
+ return it(e) ? e : null;
1155
+ }
1156
+ $getFocusTableCellOrThrow() {
1157
+ const e = this.$getFocusTableCell();
1158
+ return null === e && at(235), e;
1159
+ }
1160
+ $setAnchorCellForSelection(e) {
1161
+ this.isHighlightingCells = !1, this.anchorCell = e, this.anchorX = e.x, this.anchorY = e.y, this.focusX = -1, this.focusY = -1, this.focusCell = null, this.focusCellNodeKey = null;
1162
+ const { tableNode: t } = this.$lookup(), n = Jn(t, e.elem);
1163
+ if (null !== n) {
1164
+ const e = n.getKey();
1165
+ null != this.tableSelection ? (this.tableSelection = this.tableSelection.clone(), this.tableSelection.set(t.getKey(), e, e)) : this.tableSelection = on(t, n, n), this.anchorCellNodeKey = e;
1166
+ }
1167
+ }
1168
+ $formatCells(e) {
1169
+ const t = $getSelection();
1170
+ tn(t) || at(236);
1171
+ const n = $createRangeSelection(), o = n.anchor, l = n.focus, r = t.getNodes().filter(it);
1172
+ r.length > 0 || at(237);
1173
+ const s = r[0].getFirstChild(), i = $isParagraphNode(s) ? s.getFormatFlags(e, null) : null;
1174
+ r.forEach((t) => {
1175
+ o.set(t.getKey(), 0, "element"), l.set(t.getKey(), t.getChildrenSize(), "element"), n.formatText(e, i);
1176
+ }), $setSelection(t), this.editor.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0);
1177
+ }
1178
+ $clearText() {
1179
+ const { editor: e } = this, t = $getNodeByKey(this.tableNodeKey);
1180
+ if (!oo(t)) throw new Error("Expected TableNode.");
1181
+ const n = $getSelection();
1182
+ tn(n) || at(253);
1183
+ const o = n.getNodes().filter(it), l = t.getFirstChild(), r = t.getLastChild();
1184
+ if (o.length > 0 && null !== l && null !== r && ft(l) && ft(r) && o[0] === l.getFirstChild() && o[o.length - 1] === r.getLastChild()) {
1185
+ t.selectPrevious();
1186
+ const n = t.getParent();
1187
+ t.remove(), $isRootNode(n) && n.isEmpty() && e.dispatchCommand(INSERT_PARAGRAPH_COMMAND, void 0);
1188
+ return;
1189
+ }
1190
+ o.forEach((e) => {
1191
+ if ($isElementNode(e)) {
1192
+ const t = $createParagraphNode(), n = $createTextNode();
1193
+ t.append(n), e.append(t), e.getChildren().forEach((e) => {
1194
+ e !== t && e.remove();
1195
+ });
1196
+ }
1197
+ }), Fn(e, this.table, null), $setSelection(null), e.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0);
1198
+ }
1199
+ };
1200
+ const an = "__lexicalTableSelection";
1201
+ function un(e) {
1202
+ const t = $getNodeByKeyOrThrow(e);
1203
+ return oo(t) || at(386, e), t;
1204
+ }
1205
+ const hn = 40;
1206
+ function dn(e, t, n) {
1207
+ const o = (e) => Math.max(1, Math.ceil(Math.min(hn, e) / hn * 18));
1208
+ return e <= t + hn ? -o(t + hn - e) : e >= n - hn ? o(e - (n - hn)) : 0;
1209
+ }
1210
+ function fn(e) {
1211
+ return isHTMLElement(e) && "TABLE" === e.nodeName;
1212
+ }
1213
+ function gn(e, t) {
1214
+ if (!t) return t;
1215
+ const n = fn(t) ? t : t.querySelector("table");
1216
+ return fn(n) || at(341, e.constructor.name, e.getType(), e.getKey(), t.nodeName), n;
1217
+ }
1218
+ function mn(e) {
1219
+ return e._window;
1220
+ }
1221
+ function pn(e, t) {
1222
+ for (let n = t, o = null; null !== n; n = n.getParent()) {
1223
+ if (e.is(n)) return o;
1224
+ it(n) && (o = n);
1225
+ }
1226
+ return null;
1227
+ }
1228
+ const Cn = [
1229
+ [KEY_ARROW_DOWN_COMMAND, "down"],
1230
+ [KEY_ARROW_UP_COMMAND, "up"],
1231
+ [KEY_ARROW_LEFT_COMMAND, "backward"],
1232
+ [KEY_ARROW_RIGHT_COMMAND, "forward"]
1233
+ ];
1234
+ const _n = [
1235
+ DELETE_WORD_COMMAND,
1236
+ DELETE_LINE_COMMAND,
1237
+ DELETE_CHARACTER_COMMAND
1238
+ ];
1239
+ const Sn = [KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND];
1240
+ function bn(e, t) {
1241
+ return e.registerRootListener((n) => {
1242
+ if (null === n) return;
1243
+ const o = e._window;
1244
+ if (null === o) return;
1245
+ return registerEventListener(o, "pointerdown", (o) => {
1246
+ const l = getComposedEventTarget(o);
1247
+ if (0 !== o.button || !isDOMNode(l) || !n.contains(l)) return;
1248
+ const r = function(e) {
1249
+ const t = vn(e);
1250
+ if (null === t) return null;
1251
+ let n = t.elem;
1252
+ for (; null != n;) {
1253
+ if ("TABLE" === n.nodeName && an in n && n[an]) return {
1254
+ cellElement: t,
1255
+ tableElement: n,
1256
+ tableObserver: n[an]
1257
+ };
1258
+ n = n.parentNode;
1259
+ }
1260
+ return null;
1261
+ }(l);
1262
+ e.update(() => {
1263
+ if (tn($getSelection())) {
1264
+ for (const [e] of t.observers.values()) e.$clearHighlight(!1);
1265
+ $setSelection(null), e.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0);
1266
+ }
1267
+ if (!r) return;
1268
+ const { tableObserver: n, tableElement: l, cellElement: s } = r;
1269
+ (function(e, t, n, o, l, r) {
1270
+ const s = e._window;
1271
+ if (!s) return;
1272
+ const i = (n) => {
1273
+ if (l.isSelecting) return;
1274
+ l.isSelecting = !0, null !== n && null === l.anchorCell && e.update(() => {
1275
+ l.$setAnchorCellForSelection(n);
1276
+ });
1277
+ let i = t.clientX, c = t.clientY, a = null;
1278
+ const u = () => {
1279
+ l.isSelecting = !1, null !== a && (s.cancelAnimationFrame(a), a = null), s.removeEventListener("pointerup", S), s.removeEventListener("pointermove", b);
1280
+ }, h = (e, t) => {
1281
+ const n = o.getRootNode();
1282
+ if (!isDOMDocumentNode(n) && !isDOMShadowRoot(n)) return null;
1283
+ for (const l of n.elementsFromPoint(e, t)) {
1284
+ const e = Tn(o, l);
1285
+ if (e) return e;
1286
+ }
1287
+ return null;
1288
+ }, d = (t, n) => {
1289
+ null === l.anchorCell && e.update(() => {
1290
+ l.$setAnchorCellForSelection(t);
1291
+ }), null !== l.focusCell && t.elem === l.focusCell.elem || (r.setNextFocus({
1292
+ focusCell: t,
1293
+ override: n,
1294
+ tableKey: l.tableNodeKey
1295
+ }), e.dispatchCommand(SELECTION_CHANGE_COMMAND, void 0));
1296
+ }, f = (e) => {
1297
+ for (let t = o.parentElement; t; t = t.parentElement) if ("x" === e ? t.scrollWidth > t.clientWidth : t.scrollHeight > t.clientHeight) {
1298
+ const n = s.getComputedStyle(t), o = "x" === e ? n.overflowX : n.overflowY;
1299
+ if ("auto" === o || "scroll" === o) return t;
1300
+ }
1301
+ return null;
1302
+ }, g = (e, t, n) => {
1303
+ let o, l;
1304
+ if (null === e) o = 0, l = "x" === n ? s.innerWidth : s.innerHeight;
1305
+ else {
1306
+ const t = e.getBoundingClientRect();
1307
+ o = "x" === n ? t.left : t.top, l = "x" === n ? t.right : t.bottom;
1308
+ }
1309
+ const r = dn(t, o, l);
1310
+ if (0 === r) return !1;
1311
+ if (null === e) {
1312
+ const e = "x" === n ? s.scrollX : s.scrollY;
1313
+ return s.scrollBy("x" === n ? r : 0, "x" === n ? 0 : r), ("x" === n ? s.scrollX : s.scrollY) !== e;
1314
+ }
1315
+ if ("x" === n) {
1316
+ const t = e.scrollLeft;
1317
+ return e.scrollLeft += r, e.scrollLeft !== t;
1318
+ }
1319
+ const i = e.scrollTop;
1320
+ return e.scrollTop += r, e.scrollTop !== i;
1321
+ }, m = (e, t) => {
1322
+ let n = i, o = c;
1323
+ if (null === e) n = Math.min(Math.max(n, 1), s.innerWidth - 1);
1324
+ else {
1325
+ const t = e.getBoundingClientRect();
1326
+ n = Math.min(Math.max(n, t.left + 1), t.right - 1);
1327
+ }
1328
+ if (null === t) o = Math.min(Math.max(o, 1), s.innerHeight - 1);
1329
+ else {
1330
+ const e = t.getBoundingClientRect();
1331
+ o = Math.min(Math.max(o, e.top + 1), e.bottom - 1);
1332
+ }
1333
+ return [n, o];
1334
+ }, p = () => {
1335
+ const e = f("x");
1336
+ if (null !== e) {
1337
+ const t = e.getBoundingClientRect();
1338
+ if (0 !== dn(i, t.left, t.right)) return !0;
1339
+ }
1340
+ const t = f("y"), n = null === t ? 0 : t.getBoundingClientRect().top, o = null === t ? s.innerHeight : t.getBoundingClientRect().bottom;
1341
+ return 0 !== dn(c, n, o);
1342
+ }, C = () => {
1343
+ if (a = null, !l.isSelecting) return;
1344
+ const e = f("x"), t = f("y"), n = null !== e && g(e, i, "x"), o = g(t, c, "y");
1345
+ if (n || o) {
1346
+ const [n, o] = m(e, t), l = h(n, o);
1347
+ l && d(l, !1), a = s.requestAnimationFrame(C);
1348
+ }
1349
+ }, _ = () => {
1350
+ null === a && "touch" !== l.pointerType && p() && (a = s.requestAnimationFrame(C));
1351
+ }, S = () => {
1352
+ u();
1353
+ }, b = (e) => {
1354
+ if (!((e) => !(1 & ~e.buttons))(e) && l.isSelecting) return void u();
1355
+ const t = getComposedEventTarget(e);
1356
+ if (!isDOMNode(t)) return;
1357
+ i = e.clientX, c = e.clientY;
1358
+ let n = null;
1359
+ const r = !(IS_FIREFOX || o.contains(t));
1360
+ n = r ? Tn(o, t) : h(e.clientX, e.clientY), n && d(n, r), _();
1361
+ };
1362
+ s.addEventListener("pointerup", S, l.listenerOptions), s.addEventListener("pointermove", b, l.listenerOptions);
1363
+ };
1364
+ l.pointerType = t.pointerType;
1365
+ const c = un(l.tableNodeKey), a = $getPreviousSelection();
1366
+ if (IS_FIREFOX && t.shiftKey && $n(a, c) && ($isRangeSelection(a) || tn(a))) {
1367
+ const e = a.anchor.getNode(), o = pn(c, a.anchor.getNode());
1368
+ if (o) l.$setAnchorCellForSelection(Yn(l, o)), l.$setFocusCellForSelection(n), In(t);
1369
+ else (c.isBefore(e) ? c.selectStart() : c.selectEnd()).anchor.set(a.anchor.key, a.anchor.offset, a.anchor.type);
1370
+ } else "touch" !== t.pointerType && l.$setAnchorCellForSelection(n);
1371
+ i(n);
1372
+ })(e, o, s, l, n, t);
1373
+ });
1374
+ });
1375
+ });
1376
+ }
1377
+ function wn(e, t, n, o, l) {
1378
+ const r = n.getRootElement(), s = mn(n);
1379
+ null !== r && null !== s || at(246);
1380
+ const i = new cn(n, e.getKey()), c = gn(e, t);
1381
+ (function(e, t) {
1382
+ null !== xn(e) && at(205);
1383
+ e[an] = t;
1384
+ })(c, i), i.listenersToRemove.add(() => function(e, t) {
1385
+ xn(e) === t && delete e[an];
1386
+ }(c, i));
1387
+ i.listenersToRemove.add(registerEventListener(c, "mousedown", (e) => {
1388
+ const t = getComposedEventTarget(e);
1389
+ if (e.detail >= 3 && isDOMNode(t)) null !== vn(t) && e.preventDefault();
1390
+ }, i.listenerOptions));
1391
+ for (const [t, o] of Cn) i.listenersToRemove.add(n.registerCommand(t, (t) => Dn(n, t, o, e, i, l), COMMAND_PRIORITY_HIGH));
1392
+ i.listenersToRemove.add(n.registerCommand(KEY_ESCAPE_COMMAND, (t) => {
1393
+ const n = $getSelection();
1394
+ if (tn(n)) {
1395
+ const o = pn(e, n.focus.getNode());
1396
+ if (null !== o) return In(t), o.selectEnd(), !0;
1397
+ }
1398
+ return !1;
1399
+ }, COMMAND_PRIORITY_HIGH));
1400
+ const a = (t) => () => {
1401
+ const n = $getSelection();
1402
+ if (!$n(n, e)) return !1;
1403
+ if (tn(n)) return i.$clearText(), !0;
1404
+ if ($isRangeSelection(n)) {
1405
+ if (!it(pn(e, n.anchor.getNode()))) return !1;
1406
+ const o = n.anchor.getNode(), l = n.focus.getNode(), r = e.isParentOf(o), s = e.isParentOf(l);
1407
+ if (r && !s || s && !r) return i.$clearText(), !0;
1408
+ const c = $findMatchingParent(n.anchor.getNode(), (e) => $isElementNode(e)), a = c && $findMatchingParent(c, (e) => $isElementNode(e) && it(e.getParent()));
1409
+ if (!$isElementNode(a) || !$isElementNode(c)) return !1;
1410
+ if (t === DELETE_LINE_COMMAND && null === a.getPreviousSibling()) return !0;
1411
+ }
1412
+ return !1;
1413
+ };
1414
+ for (const e of _n) i.listenersToRemove.add(n.registerCommand(e, a(e), COMMAND_PRIORITY_HIGH));
1415
+ const g = (t) => {
1416
+ const n = $getSelection();
1417
+ if (!tn(n) && !$isRangeSelection(n)) return !1;
1418
+ const o = e.isParentOf(n.anchor.getNode());
1419
+ if (o !== e.isParentOf(n.focus.getNode())) {
1420
+ const t = o ? "anchor" : "focus", l = o ? "focus" : "anchor", { key: r, offset: s, type: i } = n[l];
1421
+ return e[n[t].isBefore(n[l]) ? "selectPrevious" : "selectNext"]()[l].set(r, s, i), !1;
1422
+ }
1423
+ return !!$n(n, e) && !!tn(n) && (t && (t.preventDefault(), t.stopPropagation()), i.$clearText(), !0);
1424
+ };
1425
+ for (const e of Sn) i.listenersToRemove.add(n.registerCommand(e, g, COMMAND_PRIORITY_HIGH));
1426
+ i.listenersToRemove.add(n.registerCommand(CUT_COMMAND, (e) => {
1427
+ const t = $getSelection();
1428
+ if (t) {
1429
+ if (!tn(t) && !$isRangeSelection(t)) return !1;
1430
+ copyToClipboard(n, objectKlassEquals(e, ClipboardEvent) ? e : null, $getClipboardDataFromSelection(t));
1431
+ const o = g(e);
1432
+ return $isRangeSelection(t) ? (t.removeText(), !0) : o;
1433
+ }
1434
+ return !1;
1435
+ }, COMMAND_PRIORITY_HIGH));
1436
+ const m = r.ownerDocument;
1437
+ return i.listenersToRemove.add(registerEventListener(m, "paste", (t) => {
1438
+ if (t.defaultPrevented) return;
1439
+ n.read("latest", () => {
1440
+ const t = $getSelection();
1441
+ return r.contains(m.activeElement) && tn(t) && $n(t, e);
1442
+ }) && (t.preventDefault(), n.dispatchCommand(PASTE_COMMAND, t));
1443
+ })), i.listenersToRemove.add(registerEventListener(m, "copy", (t) => {
1444
+ if (t.defaultPrevented) return;
1445
+ const o = getComposedEventTarget(t);
1446
+ if (o === r || isDOMNode(o) && r.contains(o)) return;
1447
+ n.read("latest", () => {
1448
+ const t = $getSelection();
1449
+ return r.contains(getActiveElement(r)) && tn(t) && $n(t, e);
1450
+ }) && (t.preventDefault(), n.dispatchCommand(COPY_COMMAND, t));
1451
+ })), i.listenersToRemove.add(n.registerCommand(FORMAT_TEXT_COMMAND, (t) => {
1452
+ const n = $getSelection();
1453
+ if (!$n(n, e)) return !1;
1454
+ if (tn(n)) return i.$formatCells(t), !0;
1455
+ if ($isRangeSelection(n)) {
1456
+ if (!it($findMatchingParent(n.anchor.getNode(), (e) => it(e)))) return !1;
1457
+ }
1458
+ return !1;
1459
+ }, COMMAND_PRIORITY_HIGH)), i.listenersToRemove.add(n.registerCommand(FORMAT_ELEMENT_COMMAND, (t) => {
1460
+ const n = $getSelection();
1461
+ if (!tn(n) || !$n(n, e)) return !1;
1462
+ const o = n.anchor.getNode(), l = n.focus.getNode();
1463
+ if (!it(o) || !it(l)) return !1;
1464
+ if (function(e, t) {
1465
+ if (tn(e)) {
1466
+ const n = e.anchor.getNode(), o = e.focus.getNode();
1467
+ if (t && n && o) {
1468
+ const [e] = Dt(t, n, o);
1469
+ return n.getKey() === e[0][0].cell.getKey() && o.getKey() === e[e.length - 1].at(-1).cell.getKey();
1470
+ }
1471
+ }
1472
+ return !1;
1473
+ }(n, e)) return e.setFormat(t), !0;
1474
+ const [r, s, i] = Dt(e, o, l), c = Math.max(s.startRow + s.cell.__rowSpan - 1, i.startRow + i.cell.__rowSpan - 1), a = Math.max(s.startColumn + s.cell.__colSpan - 1, i.startColumn + i.cell.__colSpan - 1), u = Math.min(s.startRow, i.startRow), d = Math.min(s.startColumn, i.startColumn), f = /* @__PURE__ */ new Set();
1475
+ for (let e = u; e <= c; e++) for (let n = d; n <= a; n++) {
1476
+ const o = r[e][n].cell;
1477
+ if (f.has(o)) continue;
1478
+ f.add(o), o.setFormat(t);
1479
+ const l = o.getChildren();
1480
+ for (let e = 0; e < l.length; e++) {
1481
+ const n = l[e];
1482
+ $isElementNode(n) && !n.isInline() && n.setFormat(t);
1483
+ }
1484
+ }
1485
+ return !0;
1486
+ }, COMMAND_PRIORITY_HIGH)), i.listenersToRemove.add(n.registerCommand(CONTROLLED_TEXT_INSERTION_COMMAND, (t) => {
1487
+ const o = $getSelection();
1488
+ if (!$n(o, e)) return !1;
1489
+ if (tn(o)) return i.$clearHighlight(), !1;
1490
+ if ($isRangeSelection(o)) {
1491
+ if (!it($findMatchingParent(o.anchor.getNode(), (e) => it(e)))) return !1;
1492
+ if ("string" == typeof t) {
1493
+ const l = Xn(n, o, e);
1494
+ if (l) return Un(l, e, [$createTextNode(t)]), !0;
1495
+ }
1496
+ }
1497
+ return !1;
1498
+ }, COMMAND_PRIORITY_HIGH)), o && i.listenersToRemove.add(n.registerCommand(KEY_TAB_COMMAND, (t) => {
1499
+ const n = $getSelection();
1500
+ if (!$isRangeSelection(n) || !n.isCollapsed() || !$n(n, e)) return !1;
1501
+ const o = Bn(n.anchor.getNode());
1502
+ return !(null === o || !e.is(Ln(o))) && (In(t), function(e, t) {
1503
+ const n = "next" === t ? "getNextSibling" : "getPreviousSibling", o = "next" === t ? "getFirstChild" : "getLastChild", l = e[n]();
1504
+ if ($isElementNode(l)) return l.selectEnd();
1505
+ const r = $findMatchingParent(e, ft);
1506
+ null === r && at(247);
1507
+ for (let e = r[n](); ft(e); e = e[n]()) {
1508
+ const t = e[o]();
1509
+ if ($isElementNode(t)) return t.selectEnd();
1510
+ }
1511
+ const s = $findMatchingParent(r, oo);
1512
+ null === s && at(248);
1513
+ "next" === t ? s.selectNext() : s.selectPrevious();
1514
+ }(o, t.shiftKey ? "previous" : "next"), !0);
1515
+ }, COMMAND_PRIORITY_HIGH)), i.listenersToRemove.add(n.registerCommand(FOCUS_COMMAND, (t) => e.isSelected(), COMMAND_PRIORITY_HIGH)), i.listenersToRemove.add(n.registerCommand(INSERT_PARAGRAPH_COMMAND, () => {
1516
+ const t = $getSelection();
1517
+ if (!$isRangeSelection(t) || !t.isCollapsed() || !$n(t, e)) return !1;
1518
+ const o = Xn(n, t, e);
1519
+ return !!o && (Un(o, e), !0);
1520
+ }, COMMAND_PRIORITY_HIGH)), i;
1521
+ }
1522
+ function yn(e, t) {
1523
+ const n = $getSelection(), o = $getPreviousSelection(), l = e.getAndClearNextFocus();
1524
+ if (null !== l) {
1525
+ const { tableKey: t, focusCell: o } = l, r = e.observers.get(t);
1526
+ r || at(335, t);
1527
+ const [s] = r;
1528
+ if (tn(n) && n.tableKey === s.tableNodeKey) return (o.x !== s.focusX || o.y !== s.focusY) && (s.$setFocusCellForSelection(o), !0);
1529
+ if (null !== s.anchorCell && null !== s.anchorCellNodeKey && o.elem !== s.anchorCell.elem && null !== s.tableSelection) return s.$setFocusCellForSelection(o, !0), !0;
1530
+ }
1531
+ const r = e.getAndClearShouldCheckSelectionForTable();
1532
+ if (r && $isRangeSelection(o) && $isRangeSelection(n) && n.isCollapsed()) {
1533
+ const e = $getNodeByKey(r);
1534
+ if (oo(e)) {
1535
+ const t = n.anchor.getNode(), o = e.getFirstChild(), l = Bn(t);
1536
+ if (null !== l && ft(o)) {
1537
+ const t = o.getFirstChild();
1538
+ if (it(t) && e.is($findMatchingParent(l, (n) => n.is(e) || n.is(t)))) return t.selectStart(), !0;
1539
+ }
1540
+ }
1541
+ }
1542
+ tn(n) && function(e, t) {
1543
+ const n = mn(e), o = $getPreviousSelection();
1544
+ if (!t.is(o)) return;
1545
+ const l = un(t.tableKey), r = getDOMSelection(n), s = r && getDOMSelectionPoints(r, e.getRootElement());
1546
+ if (r && s && s.anchorNode && s.focusNode) {
1547
+ const n = $getNearestNodeFromDOMNode(s.focusNode), o = n && !l.isParentOf(n), i = $getNearestNodeFromDOMNode(s.anchorNode), c = i && l.isParentOf(i);
1548
+ if (o && c && r.rangeCount > 0) {
1549
+ const n = $createRangeSelectionFromDom(r, e);
1550
+ n && (n.anchor.set(l.getKey(), t.isBackward() ? l.getChildrenSize() : 0, "element"), r.removeAllRanges(), $setSelection(n));
1551
+ }
1552
+ }
1553
+ }(t, n), $isRangeSelection(n) && function(e, t) {
1554
+ const n = $getPreviousSelection(), { anchor: o, focus: l } = e, r = o.getNode(), s = l.getNode(), i = Bn(r), c = Bn(s), a = i ? Ln(i) : null, u = c ? Ln(c) : null, h = e.isBackward(), f = i && c && a && u && a.is(u), g = u && (!a || a.isParentOf(u)), m = a && (!u || u.isParentOf(a));
1555
+ if (g) {
1556
+ const t = e.clone(), [n] = Dt(u, c, c), o = n[0][0].cell, l = n[n.length - 1].at(-1).cell;
1557
+ t.focus.set(h ? o.getKey() : l.getKey(), h ? 0 : l.getChildrenSize(), "element"), $setSelection(t);
1558
+ } else if (m) {
1559
+ const t = e.clone(), [n] = Dt(a, i, i), o = n[0][0].cell, l = n[n.length - 1].at(-1).cell;
1560
+ t.anchor.set(h ? l.getKey() : o.getKey(), h ? l.getChildrenSize() : 0, "element"), $setSelection(t);
1561
+ } else if (f) {
1562
+ const o = t.observers.get(a.getKey());
1563
+ o || at(335, a.getKey());
1564
+ const [l] = o;
1565
+ if (i.is(c) || (l.$setAnchorCellForSelection(Yn(l, i)), l.$setFocusCellForSelection(Yn(l, c), !0)), "touch" === l.pointerType && l.isSelecting && e.isCollapsed() && $isRangeSelection(n) && n.isCollapsed()) {
1566
+ const e = Bn(n.anchor.getNode());
1567
+ e && !e.is(c) && (l.$setAnchorCellForSelection(Yn(l, e)), l.$setFocusCellForSelection(Yn(l, c), !0), l.pointerType = null);
1568
+ }
1569
+ }
1570
+ }(n, e);
1571
+ for (const [n, o] of e.$getTableNodesAndObservers()) Nn(t, n, o);
1572
+ return !1;
1573
+ }
1574
+ function Nn(e, t, n) {
1575
+ const o = $getSelection(), l = $getPreviousSelection();
1576
+ o && !o.is(l) && (tn(o) || tn(l)) && n.tableSelection && !n.tableSelection.is(l) && (tn(o) && o.tableKey === n.tableNodeKey ? n.$updateTableTableSelection(o) : !tn(o) && tn(l) && l.tableKey === n.tableNodeKey && n.$updateTableTableSelection(null)), n.hasHijackedSelectionStyles && !t.isSelected() ? function(e, t) {
1577
+ t.$enableHighlightStyle(), On(t.table, (t) => {
1578
+ const n = t.elem;
1579
+ t.highlighted = !1, Hn(e, t), n.getAttribute("style") || n.removeAttribute("style");
1580
+ });
1581
+ }(e, n) : !n.hasHijackedSelectionStyles && t.isSelected() && function(e, t) {
1582
+ t.$disableHighlightStyle(), On(t.table, (t) => {
1583
+ t.highlighted = !0, zn(e, t);
1584
+ });
1585
+ }(e, n);
1586
+ }
1587
+ function xn(e) {
1588
+ return e[an] || null;
1589
+ }
1590
+ function vn(e) {
1591
+ let t = e;
1592
+ for (; null != t;) {
1593
+ const e = t.nodeName;
1594
+ if ("TD" === e || "TH" === e) {
1595
+ const e = t._cell;
1596
+ return void 0 === e ? null : e;
1597
+ }
1598
+ t = t.parentNode;
1599
+ }
1600
+ return null;
1601
+ }
1602
+ function Tn(e, t) {
1603
+ if (!e.contains(t)) return null;
1604
+ let n = null;
1605
+ for (let o = t; null != o; o = o.parentNode) {
1606
+ if (o === e) return n;
1607
+ const t = o.nodeName;
1608
+ "TD" !== t && "TH" !== t || (n = o._cell || null);
1609
+ }
1610
+ return null;
1611
+ }
1612
+ function Rn(e, t) {
1613
+ const n = [], o = {
1614
+ columns: 0,
1615
+ domRows: n,
1616
+ rows: 0
1617
+ };
1618
+ let l = gn(e, t).querySelector("tr"), r = 0, s = 0;
1619
+ for (n.length = 0; null != l;) {
1620
+ const e = l.nodeName;
1621
+ if ("TD" === e || "TH" === e) {
1622
+ const e = {
1623
+ elem: l,
1624
+ hasBackgroundColor: "" !== l.style.backgroundColor,
1625
+ highlighted: !1,
1626
+ x: r,
1627
+ y: s
1628
+ };
1629
+ l._cell = e;
1630
+ let t = n[s];
1631
+ void 0 === t && (t = n[s] = []), t[r] = e;
1632
+ } else {
1633
+ const e = l.firstChild;
1634
+ if (null != e) {
1635
+ l = e;
1636
+ continue;
1637
+ }
1638
+ }
1639
+ const t = l.nextSibling;
1640
+ if (null != t) {
1641
+ r++, l = t;
1642
+ continue;
1643
+ }
1644
+ const o = l.parentNode;
1645
+ if (null != o) {
1646
+ const e = o.nextSibling;
1647
+ if (null == e) break;
1648
+ s++, r = 0, l = e;
1649
+ }
1650
+ }
1651
+ return o.columns = r + 1, o.rows = s + 1, o;
1652
+ }
1653
+ function Fn(e, t, n) {
1654
+ const o = new Set(n ? n.getNodes() : []);
1655
+ On(t, (t, n) => {
1656
+ const l = t.elem;
1657
+ o.has(n) ? (t.highlighted = !0, zn(e, t)) : (t.highlighted = !1, Hn(e, t), l.getAttribute("style") || l.removeAttribute("style"));
1658
+ });
1659
+ }
1660
+ function On(e, t) {
1661
+ const { domRows: n } = e;
1662
+ for (let e = 0; e < n.length; e++) {
1663
+ const o = n[e];
1664
+ if (o) for (let n = 0; n < o.length; n++) {
1665
+ const l = o[n];
1666
+ if (!l) continue;
1667
+ const r = $getNearestNodeFromDOMNode(l.elem);
1668
+ null !== r && t(l, r, {
1669
+ x: n,
1670
+ y: e
1671
+ });
1672
+ }
1673
+ }
1674
+ }
1675
+ const An = (e, t, n, o, l) => {
1676
+ const r = "forward" === l;
1677
+ switch (l) {
1678
+ case "backward":
1679
+ case "forward": return n !== (r ? e.table.columns - 1 : 0) ? Wn(t.getCellNodeFromCordsOrThrow(n + (r ? 1 : -1), o, e.table), r) : o !== (r ? e.table.rows - 1 : 0) ? Wn(t.getCellNodeFromCordsOrThrow(r ? 0 : e.table.columns - 1, o + (r ? 1 : -1), e.table), r) : r ? t.selectNext() : t.selectPrevious(), !0;
1680
+ case "up": return 0 !== o ? Wn(t.getCellNodeFromCordsOrThrow(n, o - 1, e.table), !1) : t.selectPrevious(), !0;
1681
+ case "down": return o !== e.table.rows - 1 ? Wn(t.getCellNodeFromCordsOrThrow(n, o + 1, e.table), !0) : t.selectNext(), !0;
1682
+ default: return !1;
1683
+ }
1684
+ };
1685
+ function Kn(e, t) {
1686
+ let n, o;
1687
+ if (t.startColumn === e.minColumn) n = "minColumn";
1688
+ else {
1689
+ if (t.startColumn + t.cell.__colSpan - 1 !== e.maxColumn) return null;
1690
+ n = "maxColumn";
1691
+ }
1692
+ if (t.startRow === e.minRow) o = "minRow";
1693
+ else {
1694
+ if (t.startRow + t.cell.__rowSpan - 1 !== e.maxRow) return null;
1695
+ o = "maxRow";
1696
+ }
1697
+ return [n, o];
1698
+ }
1699
+ function kn([e, t]) {
1700
+ return ["minColumn" === e ? "maxColumn" : "minColumn", "minRow" === t ? "maxRow" : "minRow"];
1701
+ }
1702
+ function Mn(e, t, [n, o]) {
1703
+ const l = t[o], r = e[l];
1704
+ void 0 === r && at(250, o, String(l));
1705
+ const s = t[n], i = r[s];
1706
+ return void 0 === i && at(250, n, String(s)), i;
1707
+ }
1708
+ function En(e, t, n, o, l) {
1709
+ const r = Xt(t, n, o), { topSpan: i, leftSpan: c, bottomSpan: a, rightSpan: u } = function(e, t) {
1710
+ const { minColumn: n, maxColumn: o, minRow: l, maxRow: r } = t;
1711
+ let s = 1, i = 1, c = 1, a = 1;
1712
+ const u = e[l], h = e[r];
1713
+ for (let e = n; e <= o; e++) s = Math.max(s, u[e].cell.__rowSpan), a = Math.max(a, h[e].cell.__rowSpan);
1714
+ for (let t = l; t <= r; t++) i = Math.max(i, e[t][n].cell.__colSpan), c = Math.max(c, e[t][o].cell.__colSpan);
1715
+ return {
1716
+ bottomSpan: a,
1717
+ leftSpan: i,
1718
+ rightSpan: c,
1719
+ topSpan: s
1720
+ };
1721
+ }(t, r), [d, f] = kn(function(e, t) {
1722
+ const n = Kn(e, t);
1723
+ return null === n && at(249, t.cell.getKey()), n;
1724
+ }(r, n));
1725
+ let g = r[d], m = r[f];
1726
+ "forward" === l ? g += "maxColumn" === d ? 1 : c : "backward" === l ? g -= "minColumn" === d ? 1 : u : "down" === l ? m += "maxRow" === f ? 1 : i : "up" === l && (m -= "minRow" === f ? 1 : a);
1727
+ const p = t[m];
1728
+ if (void 0 === p) return !1;
1729
+ const C = p[g];
1730
+ if (void 0 === C) return !1;
1731
+ const [_, S] = function(e, t, n) {
1732
+ const o = Xt(e, t, n), l = Kn(o, t);
1733
+ if (l) return [Mn(e, o, l), Mn(e, o, kn(l))];
1734
+ const r = Kn(o, n);
1735
+ if (r) return [Mn(e, o, kn(r)), Mn(e, o, r)];
1736
+ const s = ["minColumn", "minRow"];
1737
+ return [Mn(e, o, s), Mn(e, o, kn(s))];
1738
+ }(t, n, C), b = Yn(e, _.cell), w = Yn(e, S.cell);
1739
+ return e.$setAnchorCellForSelection(b), e.$setFocusCellForSelection(w, !0), !0;
1740
+ }
1741
+ function $n(e, t) {
1742
+ if ($isRangeSelection(e) || tn(e)) {
1743
+ const n = t.isParentOf(e.anchor.getNode()), o = t.isParentOf(e.focus.getNode());
1744
+ return n && o;
1745
+ }
1746
+ return !1;
1747
+ }
1748
+ function Wn(e, t) {
1749
+ t ? e.selectStart() : e.selectEnd();
1750
+ }
1751
+ function zn(e, t) {
1752
+ const o = t.elem, l = e._config.theme;
1753
+ it($getNearestNodeFromDOMNode(o)) || at(131), addClassNamesToElement(o, l.tableCellSelected);
1754
+ }
1755
+ function Hn(e, t) {
1756
+ const n = t.elem;
1757
+ it($getNearestNodeFromDOMNode(n)) || at(131);
1758
+ const o = e._config.theme;
1759
+ removeClassNamesFromElement(n, o.tableCellSelected);
1760
+ }
1761
+ function Bn(e) {
1762
+ const t = $findMatchingParent(e, it);
1763
+ return it(t) ? t : null;
1764
+ }
1765
+ function Ln(e) {
1766
+ const t = $findMatchingParent(e, oo);
1767
+ return oo(t) ? t : null;
1768
+ }
1769
+ function Pn(e, t, n, o, l, r, s) {
1770
+ const i = $caretFromPoint(n.focus, l ? "previous" : "next");
1771
+ if ($isExtendableTextPointCaret(i)) return !1;
1772
+ let c = i;
1773
+ for (const e of $extendCaretToRange(i).iterNodeCarets("shadowRoot")) {
1774
+ if (!$isSiblingCaret(e) || !$isElementNode(e.origin)) return !1;
1775
+ c = e;
1776
+ }
1777
+ const a = c.getParentAtCaret();
1778
+ if (!it(a)) return !1;
1779
+ const u = a, h = function(e) {
1780
+ for (const t of $extendCaretToRange(e).iterNodeCarets("root")) {
1781
+ const { origin: n } = t;
1782
+ if (it(n)) {
1783
+ if ($isChildCaret(t)) return $getChildCaret(n, e.direction);
1784
+ } else if (!ft(n)) break;
1785
+ }
1786
+ return null;
1787
+ }($getSiblingCaret(u, c.direction)), d = $findMatchingParent(u, oo);
1788
+ if (!d || !d.is(r)) return !1;
1789
+ const g = e.getElementByKey(u.getKey()), m = vn(g);
1790
+ if (!g || !m) return !1;
1791
+ if (s.table = eo(e, d), h) if ("extend" === o) {
1792
+ const t = vn(e.getElementByKey(h.origin.getKey()));
1793
+ if (!t) return !1;
1794
+ s.$setAnchorCellForSelection(m), s.$setFocusCellForSelection(t, !0);
1795
+ } else {
1796
+ const e = $normalizeCaret(h);
1797
+ $setPointFromCaret(n.anchor, e), $setPointFromCaret(n.focus, e);
1798
+ }
1799
+ else if ("extend" === o) s.$setAnchorCellForSelection(m), s.$setFocusCellForSelection(m, !0);
1800
+ else {
1801
+ const e = function(e) {
1802
+ const t = $getAdjacentChildCaret(e);
1803
+ return $isChildCaret(t) ? $normalizeCaret(t) : e;
1804
+ }($getSiblingCaret(d, i.direction));
1805
+ $setPointFromCaret(n.anchor, e), $setPointFromCaret(n.focus, e);
1806
+ }
1807
+ return In(t), !0;
1808
+ }
1809
+ function Dn(e, t, n, o, l, s) {
1810
+ if (("up" === n || "down" === n) && function(e) {
1811
+ const t = e.getRootElement();
1812
+ if (!t) return !1;
1813
+ return t.hasAttribute("aria-controls") && "typeahead-menu" === t.getAttribute("aria-controls");
1814
+ }(e)) return !1;
1815
+ const i = $getSelection();
1816
+ if (!$n(i, o)) {
1817
+ if ($isRangeSelection(i)) {
1818
+ if ("backward" === n) {
1819
+ if (i.focus.offset > 0) return !1;
1820
+ const e = function(e) {
1821
+ for (let t = e, n = e; null !== n; t = n, n = n.getParent()) if ($isElementNode(n)) {
1822
+ if (n !== t && n.getFirstChild() !== t) return null;
1823
+ if (!n.isInline()) return n;
1824
+ }
1825
+ return null;
1826
+ }(i.focus.getNode());
1827
+ if (!e) return !1;
1828
+ const n = e.getPreviousSibling();
1829
+ return !!oo(n) && (In(t), t.shiftKey ? i.focus.set(n.getParentOrThrow().getKey(), n.getIndexWithinParent(), "element") : n.selectEnd(), !0);
1830
+ }
1831
+ if (t.shiftKey && ("up" === n || "down" === n)) {
1832
+ const e = i.focus.getNode();
1833
+ if (!i.isCollapsed() && ("up" === n && !i.isBackward() || "down" === n && i.isBackward())) {
1834
+ let l = $findMatchingParent(e, (e) => oo(e));
1835
+ if (it(l) && (l = $findMatchingParent(l, oo)), l !== o) return !1;
1836
+ if (!l) return !1;
1837
+ const s = "down" === n ? l.getNextSibling() : l.getPreviousSibling();
1838
+ if (!s) return !1;
1839
+ let c = 0;
1840
+ "up" === n && $isElementNode(s) && (c = s.getChildrenSize());
1841
+ let a = s;
1842
+ if ("up" === n && $isElementNode(s)) a = s.getLastChild() || s, c = $isTextNode(a) ? a.getTextContentSize() : 0;
1843
+ const u = i.clone();
1844
+ return u.focus.set(a.getKey(), c, $isTextNode(a) ? "text" : "element"), $setSelection(u), In(t), !0;
1845
+ }
1846
+ if ($isRootOrShadowRoot(e)) {
1847
+ const e = "up" === n ? i.getNodes()[i.getNodes().length - 1] : i.getNodes()[0];
1848
+ if (e) {
1849
+ if (null !== pn(o, e)) {
1850
+ const e = o.getFirstDescendant(), t = o.getLastDescendant();
1851
+ if (!e || !t) return !1;
1852
+ const [n] = Ut(e), [r] = Ut(t), s = o.getCordsFromCellNode(n, l.table), i = o.getCordsFromCellNode(r, l.table), c = o.getDOMCellFromCordsOrThrow(s.x, s.y, l.table), a = o.getDOMCellFromCordsOrThrow(i.x, i.y, l.table);
1853
+ return l.$setAnchorCellForSelection(c), l.$setFocusCellForSelection(a, !0), !0;
1854
+ }
1855
+ }
1856
+ return !1;
1857
+ }
1858
+ {
1859
+ let o = $findMatchingParent(e, (e) => $isElementNode(e) && !e.isInline());
1860
+ if (it(o) && (o = $findMatchingParent(o, oo)), !o) return !1;
1861
+ const r = "down" === n ? o.getNextSibling() : o.getPreviousSibling();
1862
+ if (oo(r) && l.tableNodeKey === r.getKey()) {
1863
+ const e = r.getFirstDescendant(), o = r.getLastDescendant();
1864
+ if (!e || !o) return !1;
1865
+ const [l] = Ut(e), [s] = Ut(o), c = i.clone();
1866
+ return c.focus.set(("up" === n ? l : s).getKey(), "up" === n ? 0 : s.getChildrenSize(), "element"), In(t), $setSelection(c), !0;
1867
+ }
1868
+ }
1869
+ }
1870
+ }
1871
+ return "down" === n && Gn(e) && s.setShouldCheckSelectionForTable(o.getKey()), !1;
1872
+ }
1873
+ if ($isRangeSelection(i)) {
1874
+ if ("backward" === n || "forward" === n) return Pn(e, t, i, t.shiftKey ? "extend" : "move", "backward" === n, o, l);
1875
+ if (i.isCollapsed()) {
1876
+ const { anchor: r, focus: c } = i, a = $findMatchingParent(r.getNode(), it), u = $findMatchingParent(c.getNode(), it);
1877
+ if (!it(a) || !a.is(u)) return !1;
1878
+ const h = Ln(a);
1879
+ if (h !== o && null != h) {
1880
+ const o = gn(h, e.getElementByKey(h.getKey()));
1881
+ if (null != o) return l.table = Rn(h, o), Dn(e, t, n, h, l, s);
1882
+ }
1883
+ const d = e.getElementByKey(a.__key), g = e.getElementByKey(r.key);
1884
+ if (null == g || null == d) return !1;
1885
+ let m;
1886
+ if ("element" === r.type) m = g.getBoundingClientRect();
1887
+ else {
1888
+ const t = getDOMSelection(mn(e));
1889
+ if (null === t || 0 === t.rangeCount) return !1;
1890
+ const n = getDOMSelectionRange(t, e.getRootElement());
1891
+ if (null === n) return !1;
1892
+ m = n.getBoundingClientRect();
1893
+ }
1894
+ const p = "up" === n ? a.getFirstChild() : a.getLastChild();
1895
+ if (null == p) return !1;
1896
+ const C = e.getElementByKey(p.__key);
1897
+ if (null == C) return !1;
1898
+ const _ = C.getBoundingClientRect();
1899
+ if ("up" === n ? _.top > m.top - m.height : m.bottom + m.height > _.bottom) {
1900
+ In(t);
1901
+ const e = o.getCordsFromCellNode(a, l.table);
1902
+ if (!t.shiftKey) return An(l, o, e.x, e.y, n);
1903
+ {
1904
+ const t = o.getDOMCellFromCordsOrThrow(e.x, e.y, l.table);
1905
+ l.$setAnchorCellForSelection(t), l.$setFocusCellForSelection(t, !0);
1906
+ }
1907
+ return !0;
1908
+ }
1909
+ }
1910
+ } else if (tn(i)) {
1911
+ const { anchor: r, focus: s, tableKey: c } = i;
1912
+ if (c !== o.getKey()) return !1;
1913
+ const a = $findMatchingParent(r.getNode(), it), u = $findMatchingParent(s.getNode(), it), [h] = i.getNodes();
1914
+ oo(h) || at(251);
1915
+ const d = gn(h, e.getElementByKey(h.getKey()));
1916
+ if (!it(a) || !it(u) || !oo(h) || null == d) return !1;
1917
+ l.$updateTableTableSelection(i);
1918
+ const g = Rn(h, d), m = o.getCordsFromCellNode(a, g), p = o.getDOMCellFromCordsOrThrow(m.x, m.y, g);
1919
+ if (l.$setAnchorCellForSelection(p), In(t), t.shiftKey) {
1920
+ const [e, t, r] = Dt(o, a, u);
1921
+ return En(l, e, t, r, n);
1922
+ }
1923
+ return u.selectEnd(), !0;
1924
+ }
1925
+ return !1;
1926
+ }
1927
+ function In(e) {
1928
+ e.preventDefault(), e.stopImmediatePropagation(), e.stopPropagation();
1929
+ }
1930
+ function Un(e, t, n) {
1931
+ const o = $createParagraphNode();
1932
+ "first" === e ? t.insertBefore(o) : t.insertAfter(o), o.append(...n || []), o.selectEnd();
1933
+ }
1934
+ function Xn(e, t, n) {
1935
+ const o = n.getParent();
1936
+ if (!o) return;
1937
+ const l = getDOMSelection(mn(e));
1938
+ if (!l) return;
1939
+ const r = getDOMSelectionPoints(l, e.getRootElement()).anchorNode, s = e.getElementByKey(o.getKey()), i = gn(n, e.getElementByKey(n.getKey()));
1940
+ if (!r || !s || !i || !s.contains(r) || i.contains(r)) return;
1941
+ const c = $findMatchingParent(t.anchor.getNode(), (e) => it(e));
1942
+ if (!c) return;
1943
+ const a = $findMatchingParent(c, (e) => oo(e));
1944
+ if (!oo(a) || !a.is(n)) return;
1945
+ const [u, h] = Dt(n, c, c), d = u[0][0], g = u[u.length - 1][u[0].length - 1], { startRow: m, startColumn: p } = h, C = m === d.startRow && p === d.startColumn, _ = m === g.startRow && p === g.startColumn;
1946
+ return C ? "first" : _ ? "last" : void 0;
1947
+ }
1948
+ function Yn(e, t) {
1949
+ const { tableNode: n } = e.$lookup(), o = n.getCordsFromCellNode(t, e.table);
1950
+ return n.getDOMCellFromCordsOrThrow(o.x, o.y, e.table);
1951
+ }
1952
+ function Jn(e, t, n) {
1953
+ return pn(e, $getNearestNodeFromDOMNode(t, n));
1954
+ }
1955
+ function qn(e, n, o) {
1956
+ const l = e.querySelector("colgroup");
1957
+ if (!l) return;
1958
+ const r = [];
1959
+ for (let e = 0; e < n; e++) {
1960
+ const n = $getDocument().createElement("col"), l = o && o[e];
1961
+ l && (n.style.width = `${l}px`), r.push(n);
1962
+ }
1963
+ l.replaceChildren(...r);
1964
+ }
1965
+ function jn(e, t, o) {
1966
+ if (!t.theme.tableAlignment) return;
1967
+ const l = [], r = [];
1968
+ for (const e of ["center", "right"]) {
1969
+ const n = t.theme.tableAlignment[e];
1970
+ n && (e === o ? r : l).push(n);
1971
+ }
1972
+ removeClassNamesFromElement(e, ...l), addClassNamesToElement(e, ...r);
1973
+ }
1974
+ const Vn = /* @__PURE__ */ new WeakSet();
1975
+ function Gn(e = $getEditor()) {
1976
+ return Vn.has(e);
1977
+ }
1978
+ function Qn(e, t) {
1979
+ t ? Vn.add(e) : Vn.delete(e);
1980
+ }
1981
+ var Zn = class Zn extends ElementNode {
1982
+ __rowStriping;
1983
+ __frozenColumnCount;
1984
+ __frozenRowCount;
1985
+ __colWidths;
1986
+ static getType() {
1987
+ return "table";
1988
+ }
1989
+ getColWidths() {
1990
+ return this.getLatest().__colWidths;
1991
+ }
1992
+ setColWidths(e) {
1993
+ const t = this.getWritable();
1994
+ return t.__colWidths = e, t;
1995
+ }
1996
+ static clone(e) {
1997
+ return new Zn(e.__key);
1998
+ }
1999
+ afterCloneFrom(e) {
2000
+ super.afterCloneFrom(e), this.__colWidths = e.__colWidths, this.__rowStriping = e.__rowStriping, this.__frozenColumnCount = e.__frozenColumnCount, this.__frozenRowCount = e.__frozenRowCount;
2001
+ }
2002
+ static importDOM() {
2003
+ return { table: (e) => ({
2004
+ conversion: to,
2005
+ priority: 1
2006
+ }) };
2007
+ }
2008
+ static importJSON(e) {
2009
+ return no().updateFromJSON(e);
2010
+ }
2011
+ updateFromJSON(e) {
2012
+ return super.updateFromJSON(e).setRowStriping(e.rowStriping || !1).setFrozenColumns(e.frozenColumnCount || 0).setFrozenRows(e.frozenRowCount || 0).setColWidths(e.colWidths);
2013
+ }
2014
+ constructor(e) {
2015
+ super(e), this.__rowStriping = !1, this.__frozenColumnCount = 0, this.__frozenRowCount = 0, this.__colWidths = void 0;
2016
+ }
2017
+ exportJSON() {
2018
+ return {
2019
+ ...super.exportJSON(),
2020
+ colWidths: this.getColWidths(),
2021
+ frozenColumnCount: this.__frozenColumnCount ? this.__frozenColumnCount : void 0,
2022
+ frozenRowCount: this.__frozenRowCount ? this.__frozenRowCount : void 0,
2023
+ rowStriping: this.__rowStriping ? this.__rowStriping : void 0
2024
+ };
2025
+ }
2026
+ extractWithChild(e, t, n) {
2027
+ return "html" === n;
2028
+ }
2029
+ getDOMSlot(e) {
2030
+ const t = fn(e) ? e : e.querySelector("table");
2031
+ return fn(t) || at(229), super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"));
2032
+ }
2033
+ createDOM(e, o) {
2034
+ const l = $getDocument().createElement("table");
2035
+ this.__style && setDOMStyleFromCSS(l.style, this.__style);
2036
+ const r = $getDocument().createElement("colgroup");
2037
+ if (l.appendChild(r), setDOMUnmanaged(r), addClassNamesToElement(l, e.theme.table), this.updateTableElement(null, l, e), Gn(o)) {
2038
+ const o = $getDocument().createElement("div"), r = e.theme.tableScrollableWrapper;
2039
+ return r ? addClassNamesToElement(o, r) : o.style.overflowX = "auto", o.appendChild(l), this.updateTableWrapper(null, o, l, e), o;
2040
+ }
2041
+ return l;
2042
+ }
2043
+ updateTableWrapper(e, t, o, l) {
2044
+ this.__frozenColumnCount !== (e ? e.__frozenColumnCount : 0) && function(e, t, o, l) {
2045
+ l > 0 ? (addClassNamesToElement(e, o.theme.tableFrozenColumn), t.setAttribute("data-lexical-frozen-column", "true")) : (removeClassNamesFromElement(e, o.theme.tableFrozenColumn), t.removeAttribute("data-lexical-frozen-column"));
2046
+ }(t, o, l, this.__frozenColumnCount), this.__frozenRowCount !== (e ? e.__frozenRowCount : 0) && function(e, t, o, l) {
2047
+ l > 0 ? (addClassNamesToElement(e, o.theme.tableFrozenRow), t.setAttribute("data-lexical-frozen-row", "true")) : (removeClassNamesFromElement(e, o.theme.tableFrozenRow), t.removeAttribute("data-lexical-frozen-row"));
2048
+ }(t, o, l, this.__frozenRowCount);
2049
+ }
2050
+ updateTableElement(e, t, o) {
2051
+ this.__style !== (e ? e.__style : "") && setDOMStyleFromCSS(t.style, this.__style, e ? e.__style : ""), this.__rowStriping !== (!!e && e.__rowStriping) && function(e, t, o) {
2052
+ o ? (addClassNamesToElement(e, t.theme.tableRowStriping), e.setAttribute("data-lexical-row-striping", "true")) : (removeClassNamesFromElement(e, t.theme.tableRowStriping), e.removeAttribute("data-lexical-row-striping"));
2053
+ }(t, o, this.__rowStriping);
2054
+ const l = e ? e.getColumnCount() : 0, r = e ? e.__colWidths : void 0;
2055
+ this.getColumnCount() === l && this.getColWidths() === r || qn(t, this.getColumnCount(), this.getColWidths()), jn(t, o, this.getFormatType());
2056
+ }
2057
+ updateDOM(e, t, n) {
2058
+ const l = gn(this, t);
2059
+ return t === l === Gn() || (isHTMLElement(r = t) && "DIV" === r.nodeName && this.updateTableWrapper(e, t, l, n), this.updateTableElement(e, l, n), !1);
2060
+ var r;
2061
+ }
2062
+ scaleDOMColWidths(e, t) {
2063
+ const n = this.getColWidths();
2064
+ if (!n) return;
2065
+ qn(gn(this, e), this.getColumnCount(), n.map((e) => e * t));
2066
+ }
2067
+ exportDOM(e) {
2068
+ const n = super.exportDOM(e), { element: l } = n;
2069
+ return {
2070
+ after: (l) => {
2071
+ if (n.after && (l = n.after(l)), !fn(l) && isHTMLElement(l) && (l = l.querySelector("table")), !fn(l)) return null;
2072
+ jn(l, e._config, this.getFormatType());
2073
+ const [r] = It(this, null, null), s = /* @__PURE__ */ new Map();
2074
+ for (const e of r) for (const t of e) {
2075
+ const e = t.cell.getKey();
2076
+ s.has(e) || s.set(e, {
2077
+ colSpan: t.cell.getColSpan(),
2078
+ startColumn: t.startColumn
2079
+ });
2080
+ }
2081
+ const i = /* @__PURE__ */ new Set();
2082
+ for (const e of l.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")) {
2083
+ const t = e.getAttribute("data-temporary-table-cell-lexical-key");
2084
+ if (t) {
2085
+ const n = s.get(t);
2086
+ if (e.removeAttribute("data-temporary-table-cell-lexical-key"), n) {
2087
+ s.delete(t);
2088
+ for (let e = 0; e < n.colSpan; e++) i.add(e + n.startColumn);
2089
+ }
2090
+ }
2091
+ }
2092
+ const c = l.querySelector(":scope > colgroup");
2093
+ if (c) {
2094
+ const e = Array.from(l.querySelectorAll(":scope > colgroup > col")).filter((e, t) => i.has(t));
2095
+ c.replaceChildren(...e);
2096
+ }
2097
+ const a = l.querySelectorAll(":scope > tr");
2098
+ if (a.length > 0) {
2099
+ const e = $getDocument().createElement("tbody");
2100
+ for (const t of a) e.appendChild(t);
2101
+ l.append(e);
2102
+ }
2103
+ return l;
2104
+ },
2105
+ element: !fn(l) && isHTMLElement(l) ? l.querySelector("table") : l
2106
+ };
2107
+ }
2108
+ canBeEmpty() {
2109
+ return !1;
2110
+ }
2111
+ isShadowRoot() {
2112
+ return !0;
2113
+ }
2114
+ getCordsFromCellNode(e, t) {
2115
+ const { rows: n, domRows: o } = t;
2116
+ for (let t = 0; t < n; t++) {
2117
+ const n = o[t];
2118
+ if (null != n) for (let o = 0; o < n.length; o++) {
2119
+ const l = n[o];
2120
+ if (null == l) continue;
2121
+ const { elem: r } = l, s = Jn(this, r);
2122
+ if (null !== s && e.is(s)) return {
2123
+ x: o,
2124
+ y: t
2125
+ };
2126
+ }
2127
+ }
2128
+ throw new Error("Cell not found in table.");
2129
+ }
2130
+ getDOMCellFromCords(e, t, n) {
2131
+ const { domRows: o } = n, l = o[t];
2132
+ if (null == l) return null;
2133
+ const r = l[e < l.length ? e : l.length - 1];
2134
+ return null == r ? null : r;
2135
+ }
2136
+ getDOMCellFromCordsOrThrow(e, t, n) {
2137
+ const o = this.getDOMCellFromCords(e, t, n);
2138
+ if (!o) throw new Error("Cell not found at cords.");
2139
+ return o;
2140
+ }
2141
+ getCellNodeFromCords(e, t, n) {
2142
+ const o = this.getDOMCellFromCords(e, t, n);
2143
+ if (null == o) return null;
2144
+ const l = $getNearestNodeFromDOMNode(o.elem);
2145
+ return it(l) ? l : null;
2146
+ }
2147
+ getCellNodeFromCordsOrThrow(e, t, n) {
2148
+ const o = this.getCellNodeFromCords(e, t, n);
2149
+ if (!o) throw new Error("Node at cords not TableCellNode.");
2150
+ return o;
2151
+ }
2152
+ getRowStriping() {
2153
+ return Boolean(this.getLatest().__rowStriping);
2154
+ }
2155
+ setRowStriping(e) {
2156
+ const t = this.getWritable();
2157
+ return t.__rowStriping = e, t;
2158
+ }
2159
+ setFrozenColumns(e) {
2160
+ const t = this.getWritable();
2161
+ return t.__frozenColumnCount = e, t;
2162
+ }
2163
+ getFrozenColumns() {
2164
+ return this.getLatest().__frozenColumnCount;
2165
+ }
2166
+ setFrozenRows(e) {
2167
+ const t = this.getWritable();
2168
+ return t.__frozenRowCount = e, t;
2169
+ }
2170
+ getFrozenRows() {
2171
+ return this.getLatest().__frozenRowCount;
2172
+ }
2173
+ canSelectBefore() {
2174
+ return !0;
2175
+ }
2176
+ canIndent() {
2177
+ return !1;
2178
+ }
2179
+ getColumnCount() {
2180
+ const e = this.getFirstChild();
2181
+ if (!ft(e)) return 0;
2182
+ let t = 0;
2183
+ return e.getChildren().forEach((e) => {
2184
+ it(e) && (t += e.getColSpan());
2185
+ }), t;
2186
+ }
2187
+ };
2188
+ function eo(e, t) {
2189
+ const n = e.getElementByKey(t.getKey());
2190
+ return null === n && at(230), Rn(t, n);
2191
+ }
2192
+ function to(e) {
2193
+ const t = no();
2194
+ e.hasAttribute("data-lexical-row-striping") && t.setRowStriping(!0), e.hasAttribute("data-lexical-frozen-column") && t.setFrozenColumns(1), e.hasAttribute("data-lexical-frozen-row") && t.setFrozenRows(1);
2195
+ const n = e.querySelector(":scope > colgroup");
2196
+ if (n) {
2197
+ let e = [];
2198
+ for (const t of n.querySelectorAll(":scope > col")) {
2199
+ let n = t.style.width || "";
2200
+ if (!tt.test(n) && (n = t.getAttribute("width") || "", !/^\d+$/.test(n))) {
2201
+ e = void 0;
2202
+ break;
2203
+ }
2204
+ e.push(parseFloat(n));
2205
+ }
2206
+ e && t.setColWidths(e);
2207
+ }
2208
+ return {
2209
+ after: (e) => $descendantsMatching(e, ft),
2210
+ node: t
2211
+ };
2212
+ }
2213
+ function no() {
2214
+ return $applyNodeReplacement(new Zn());
2215
+ }
2216
+ function oo(e) {
2217
+ return e instanceof Zn;
2218
+ }
2219
+ function lo(e) {
2220
+ ft(e.getParent()) ? e.isEmpty() && e.append($createParagraphNode()) : e.remove();
2221
+ }
2222
+ function ro(e) {
2223
+ oo(e.getParent()) ? $unwrapAndFilterDescendants(e, it) : e.remove();
2224
+ }
2225
+ function so(e) {
2226
+ $unwrapAndFilterDescendants(e, ft);
2227
+ const [t] = It(e, null, null), n = t.reduce((e, t) => Math.max(e, t.length), 0), o = e.getChildren();
2228
+ for (let e = 0; e < t.length; ++e) {
2229
+ const l = o[e];
2230
+ if (!l) continue;
2231
+ ft(l) || at(254, l.constructor.name, l.getType());
2232
+ const r = t[e].reduce((e, t) => t ? 1 + e : e, 0);
2233
+ if (r !== n) for (let e = r; e < n; ++e) {
2234
+ const e = st();
2235
+ e.append($createParagraphNode()), l.append(e);
2236
+ }
2237
+ }
2238
+ const l = e.getColWidths(), r = e.getColumnCount();
2239
+ if (l && l.length !== r) {
2240
+ let t;
2241
+ if (r < l.length) t = l.slice(0, r);
2242
+ else if (l.length > 0) {
2243
+ const e = l[l.length - 1];
2244
+ t = [...l, ...Array(r - l.length).fill(e)];
2245
+ }
2246
+ e.setColWidths(t);
2247
+ }
2248
+ }
2249
+ function io(e) {
2250
+ if (e.detail < 3 || !isDOMNode(e.target)) return !1;
2251
+ const t = $getNearestNodeFromDOMNode(e.target);
2252
+ if (null === t) return !1;
2253
+ const n = $findMatchingParent(t, (e) => $isElementNode(e) && !e.isInline());
2254
+ if (null === n) return !1;
2255
+ return !!it(n.getParent()) && (n.select(0), !0);
2256
+ }
2257
+ function co() {
2258
+ const e = $getSelection();
2259
+ if (!$isRangeSelection(e)) return !1;
2260
+ const t = Ln(e.anchor.getNode());
2261
+ if (null === t) return !1;
2262
+ const n = $getRoot();
2263
+ if (!n.is(t.getParent()) || 1 !== n.getChildrenSize()) return !1;
2264
+ const [o] = It(t, null, null);
2265
+ if (0 === o.length || 0 === o[0].length) return !1;
2266
+ const l = o[0][0];
2267
+ if (!l || !l.cell) return !1;
2268
+ const r = o[o.length - 1], s = r[r.length - 1];
2269
+ if (!s || !s.cell) return !1;
2270
+ return $setSelection(on(t, l.cell, s.cell)), !0;
2271
+ }
2272
+ function ao(e) {
2273
+ return e.registerNodeTransform(ot, (e) => {
2274
+ if (e.getColSpan() > 1 || e.getRowSpan() > 1) {
2275
+ const [, , t] = Ut(e), [n] = Dt(t, e, e), o = n.length, l = n[0].length;
2276
+ let r = t.getFirstChild();
2277
+ ft(r) || at(175);
2278
+ const s = [];
2279
+ for (let e = 0; e < o; e++) {
2280
+ 0 !== e && (r = r.getNextSibling(), ft(r) || at(175));
2281
+ let t = null;
2282
+ for (let o = 0; o < l; o++) {
2283
+ const l = n[e][o], i = l.cell;
2284
+ if (l.startRow === e && l.startColumn === o) t = i, s.push(i);
2285
+ else if (i.getColSpan() > 1 || i.getRowSpan() > 1) {
2286
+ it(i) || at(176);
2287
+ const e = st(i.__headerState);
2288
+ null !== t ? t.insertAfter(e) : $insertFirst(r, e);
2289
+ }
2290
+ }
2291
+ }
2292
+ for (const e of s) e.setColSpan(1), e.setRowSpan(1);
2293
+ }
2294
+ });
2295
+ }
2296
+ function uo(e, t = !0) {
2297
+ const n = new sn(), o = (o, l, r) => {
2298
+ const s = gn(o, r), i = wn(o, s, e, t, n);
2299
+ n.observers.set(l, [i, s]);
2300
+ };
2301
+ return mergeRegister(bn(e, n), e.registerCommand(SELECTION_CHANGE_COMMAND, () => yn(n, e), COMMAND_PRIORITY_HIGH), e.registerMutationListener(Zn, (t) => {
2302
+ e.read("latest", () => {
2303
+ for (const [e, l] of t) {
2304
+ const t = n.observers.get(e);
2305
+ if ("created" === l || "updated" === l) {
2306
+ const { tableNode: l, tableElement: r } = rn(e);
2307
+ void 0 === t ? o(l, e, r) : r !== t[1] && (n.removeObserver(e), o(l, e, r));
2308
+ } else "destroyed" === l && n.removeObserver(e);
2309
+ }
2310
+ });
2311
+ }, { skipInitialization: !1 }), () => {
2312
+ n.removeAllObservers();
2313
+ });
2314
+ }
2315
+ function ho(e, t) {
2316
+ e.hasNodes([Zn]) || at(255);
2317
+ const { hasNestedTables: n = signal(!1) } = t ?? {};
2318
+ return mergeRegister(e.registerCommand(ct, (e) => function({ rows: e, columns: t, includeHeaders: n }, o) {
2319
+ const l = $getSelection() || $getPreviousSelection();
2320
+ if (!l || !$isRangeSelection(l)) return !1;
2321
+ if (!o && Ln(l.anchor.getNode())) return !1;
2322
+ const s = gt(Number(e), Number(t), n);
2323
+ $insertNodeToNearestRoot(s);
2324
+ const i = s.getFirstDescendant();
2325
+ return $isTextNode(i) && i.select(), !0;
2326
+ }(e, n.peek()), COMMAND_PRIORITY_EDITOR), e.registerCommand(SELECTION_INSERT_CLIPBOARD_NODES_COMMAND, (t, o) => e === o && function(e, t) {
2327
+ const { nodes: n, selection: o } = e;
2328
+ if (!n.some((e) => oo(e) || $dfs(e).some((e) => oo(e.node)))) {
2329
+ if (tn(o)) {
2330
+ let e = "", t = !1;
2331
+ for (const o of n) {
2332
+ const n = $isElementNode(o) && !o.isInline();
2333
+ e.length > 0 && (n || t) && (e += "\n"), e += o.getTextContent(), t = n;
2334
+ }
2335
+ return o.insertRawText(e), !0;
2336
+ }
2337
+ return !1;
2338
+ }
2339
+ const l = tn(o), r = $isRangeSelection(o);
2340
+ if (!(r && null !== $findMatchingParent(o.anchor.getNode(), (e) => it(e)) && null !== $findMatchingParent(o.focus.getNode(), (e) => it(e)) || l)) return !1;
2341
+ if (1 === n.length && oo(n[0])) return Vt(n[0], o);
2342
+ if (r && t.peek() && !function(e) {
2343
+ if (tn(e) && !e.focus.getNode().is(e.anchor.getNode())) return !0;
2344
+ if ($isRangeSelection(e) && it(e.anchor.getNode()) && !e.anchor.getNode().is(e.focus.getNode())) return !0;
2345
+ return !1;
2346
+ }(o)) return !1;
2347
+ return !0;
2348
+ }(t, n), COMMAND_PRIORITY_EDITOR), e.registerCommand(SELECT_ALL_COMMAND, co, COMMAND_PRIORITY_LOW), e.registerCommand(CLICK_COMMAND, io, COMMAND_PRIORITY_EDITOR), e.registerNodeTransform(Zn, so), e.registerNodeTransform(ut, ro), e.registerNodeTransform(ot, lo));
2349
+ }
2350
+ const fo = {
2351
+ $accepts: ft,
2352
+ $packageRun: (e) => e.every(it) ? [dt().splice(0, 0, e)] : [],
2353
+ name: "TableSchema"
2354
+ };
2355
+ const go = {
2356
+ $accepts: it,
2357
+ name: "TableRowSchema"
2358
+ };
2359
+ const mo = [
2360
+ /* @__PURE__ */ defineImportRule({
2361
+ $import: (e, t) => {
2362
+ const n = no();
2363
+ t.hasAttribute("data-lexical-row-striping") && n.setRowStriping(!0), t.hasAttribute("data-lexical-frozen-column") && n.setFrozenColumns(1), t.hasAttribute("data-lexical-frozen-row") && n.setFrozenRows(1);
2364
+ const o = t.querySelector(":scope > colgroup");
2365
+ if (o) {
2366
+ let e = [];
2367
+ for (const t of o.querySelectorAll(":scope > col")) {
2368
+ let n = t.style.width || "";
2369
+ if (!tt.test(n) && (n = t.getAttribute("width") || "", !/^\d+$/.test(n))) {
2370
+ e = void 0;
2371
+ break;
2372
+ }
2373
+ e.push(parseFloat(n));
2374
+ }
2375
+ e && n.setColWidths(e);
2376
+ }
2377
+ return [n.splice(0, 0, $descendantsMatching(e.$importChildren(t), ft))];
2378
+ },
2379
+ match: sel.tag("table"),
2380
+ name: "@lexical/table/table"
2381
+ }),
2382
+ /* @__PURE__ */ defineImportRule({
2383
+ $import: (e, t) => [dt(tt.test(t.style.height) ? parseFloat(t.style.height) : void 0).splice(0, 0, $descendantsMatching(e.$importChildren(t), it))],
2384
+ match: sel.tag("tr"),
2385
+ name: "@lexical/table/tr"
2386
+ }),
2387
+ /* @__PURE__ */ defineImportRule({
2388
+ $import: (e, t) => {
2389
+ const n = "TH" === t.nodeName, o = tt.test(t.style.width) ? parseFloat(t.style.width) : void 0;
2390
+ let c = nt.NO_STATUS;
2391
+ if (n) {
2392
+ const e = t.getAttribute("scope");
2393
+ if ("col" === e) c = nt.COLUMN;
2394
+ else if ("row" === e) c = nt.ROW;
2395
+ else {
2396
+ const e = t.parentElement, n = isHTMLTableRowElement(e) && (e.parentElement && "THEAD" === e.parentElement.nodeName || 0 === e.rowIndex), o = 0 === t.cellIndex;
2397
+ n && (c |= nt.ROW), o && (c |= nt.COLUMN), c === nt.NO_STATUS && (c = nt.ROW);
2398
+ }
2399
+ }
2400
+ const a = st(c, t.colSpan, o);
2401
+ a.__rowSpan = t.rowSpan;
2402
+ const u = t.style.backgroundColor;
2403
+ "" !== u && (a.__backgroundColor = u);
2404
+ const h = t.style.verticalAlign;
2405
+ (function(e) {
2406
+ return "middle" === e || "bottom" === e;
2407
+ })(h) && (a.__verticalAlign = h);
2408
+ const d = e.get(ImportTextFormat), f = d | function(e) {
2409
+ let t = 0;
2410
+ const n = e.fontWeight;
2411
+ "700" !== n && "bold" !== n || (t |= IS_BOLD), "italic" === e.fontStyle && (t |= IS_ITALIC);
2412
+ const o = (e.textDecoration || "").split(" ");
2413
+ return o.includes("underline") && (t |= IS_UNDERLINE), o.includes("line-through") && (t |= IS_STRIKETHROUGH), t;
2414
+ }(t.style), g = e.get(ImportTextStyle), m = t.style.color, p = m ? {
2415
+ ...g,
2416
+ color: m
2417
+ } : g, C = [];
2418
+ f !== d && C.push(contextValue(ImportTextFormat, f)), p !== g && C.push(contextValue(ImportTextStyle, p));
2419
+ const _ = function(e) {
2420
+ const t = [];
2421
+ let n = null;
2422
+ const o = () => {
2423
+ if (null !== n) {
2424
+ const e = n.getFirstChild();
2425
+ $isLineBreakNode(e) && 1 === n.getChildrenSize() && e.remove();
2426
+ }
2427
+ };
2428
+ for (const c of e) $isInlineElementOrDecoratorNode(c) || $isTextNode(c) || $isLineBreakNode(c) ? null !== n ? n.append(c) : (n = $createParagraphNode().append(c), t.push(n)) : (o(), n = null, t.push(c));
2429
+ return o(), 0 === t.length && t.push($createParagraphNode()), t;
2430
+ }(e.$importChildren(t, { context: C })), S = n ? _ : $propagateTextAlignToBlockChildren(_, t);
2431
+ return [a.splice(0, 0, S)];
2432
+ },
2433
+ match: sel.tag("td", "th"),
2434
+ name: "@lexical/table/cell"
2435
+ })
2436
+ ];
2437
+ const po = /* @__PURE__ */ defineExtension({
2438
+ build: (e, t, n) => namedSignals(t),
2439
+ config: /* @__PURE__ */ safeCast({
2440
+ hasCellBackgroundColor: !0,
2441
+ hasCellMerge: !0,
2442
+ hasHorizontalScroll: !0,
2443
+ hasNestedTables: !1,
2444
+ hasTabHandler: !0
2445
+ }),
2446
+ dependencies: [CoreImportExtension, /* @__PURE__ */ configExtension(DOMImportExtension, { rules: mo })],
2447
+ name: "@lexical/table/Table",
2448
+ nodes: () => [
2449
+ Zn,
2450
+ ut,
2451
+ ot
2452
+ ],
2453
+ register(e, t, n) {
2454
+ const o = n.getOutput();
2455
+ return mergeRegister(effect(() => {
2456
+ const t = o.hasHorizontalScroll.value;
2457
+ Gn(e) !== t && (Qn(e, t), e.update($fullReconcile));
2458
+ }), ho(e, o), effect(() => uo(e, o.hasTabHandler.value)), effect(() => o.hasCellMerge.value ? void 0 : ao(e)), effect(() => o.hasCellBackgroundColor.value ? void 0 : e.registerNodeTransform(ot, (e) => {
2459
+ null !== e.getBackgroundColor() && e.setBackgroundColor(null);
2460
+ })));
2461
+ }
2462
+ });
2463
+ const Co = /* @__PURE__ */ defineExtension({
2464
+ dependencies: [po],
2465
+ name: "@lexical/table/Import"
2466
+ });
2467
+ //#endregion
2468
+ export { Dt as $computeTableMap, It as $computeTableMapSkipCellCheck, st as $createTableCellNode, no as $createTableNode, gt as $createTableNodeWithDimensions, dt as $createTableRowNode, nn as $createTableSelection, on as $createTableSelectionFrom, Kt as $deleteTableColumn, Et as $deleteTableColumnAtSelection, $t as $deleteTableColumn__EXPERIMENTAL, kt as $deleteTableRowAtSelection, Mt as $deleteTableRow__EXPERIMENTAL, Bn as $findCellNode, Ln as $findTableNode, eo as $getElementForTableNode, Ut as $getNodeTriplet, rn as $getTableAndElementByKey, mt as $getTableCellNodeFromLexicalNode, jt as $getTableCellNodeRect, St as $getTableColumnIndexFromTableCellNode, Ct as $getTableNodeFromLexicalNodeOrThrow, _t as $getTableRowIndexFromTableCellNode, pt as $getTableRowNodeFromTableCellNodeOrThrow, Rt as $insertTableColumn, At as $insertTableColumnAtNode, Ft as $insertTableColumnAtSelection, Ot as $insertTableColumn__EXPERIMENTAL, yt as $insertTableRow, Tt as $insertTableRowAtNode, xt as $insertTableRowAtSelection, vt as $insertTableRow__EXPERIMENTAL, Gn as $isScrollableTablesActive, Yt as $isSimpleTable, it as $isTableCellNode, oo as $isTableNode, ft as $isTableRowNode, tn as $isTableSelection, Ht as $mergeCells, Jt as $moveTableColumn, qt as $moveTableRow, wt as $removeTableRowAtIndex, Qt as $setTableColumnIsHeader, Gt as $setTableRowIsHeader, Lt as $unmergeCell, Pt as $unmergeCellNode, ct as INSERT_TABLE_COMMAND, nt as TableCellHeaderStates, ot as TableCellNode, po as TableExtension, Co as TableImportExtension, mo as TableImportRules, Zn as TableNode, cn as TableObserver, ut as TableRowNode, go as TableRowSchema, fo as TableSchema, wn as applyTableHandlers, vn as getDOMCellFromTarget, gn as getTableElement, xn as getTableObserverFromTableElement, ao as registerTableCellUnmergeTransform, ho as registerTablePlugin, uo as registerTableSelectionObserver, Qn as setScrollableTablesActive };