@uva-glass/component-library 3.47.6 → 3.47.7

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 (102) hide show
  1. package/dist/{Lexical.prod-nXWuyOKD.js → Lexical.prod-DBU6xTBY.js} +1397 -1279
  2. package/dist/Lexical.prod-DBU6xTBY.js.map +1 -0
  3. package/dist/LexicalClipboard.prod-CzGBnMdD.js +272 -0
  4. package/dist/LexicalClipboard.prod-CzGBnMdD.js.map +1 -0
  5. package/dist/LexicalLink.prod-DV9kT537.js +1027 -0
  6. package/dist/LexicalLink.prod-DV9kT537.js.map +1 -0
  7. package/dist/{LexicalList.prod--mkvX0uW.js → LexicalList.prod-2UfLUgO1.js} +159 -154
  8. package/dist/LexicalList.prod-2UfLUgO1.js.map +1 -0
  9. package/dist/LexicalSelection.prod-C1JYA_go.js +114 -0
  10. package/dist/LexicalSelection.prod-C1JYA_go.js.map +1 -0
  11. package/dist/LexicalTable.prod-CZ1mYUR-.js +1802 -0
  12. package/dist/LexicalTable.prod-CZ1mYUR-.js.map +1 -0
  13. package/dist/LexicalUtils.prod-C3vvQk50.js +114 -0
  14. package/dist/LexicalUtils.prod-C3vvQk50.js.map +1 -0
  15. package/dist/{TableCellResizerPlugin-Cpbankb8.js → TableCellResizerPlugin-CxFy7dbe.js} +53 -53
  16. package/dist/TableCellResizerPlugin-CxFy7dbe.js.map +1 -0
  17. package/dist/{TablePlugin-CfXPNfT8.js → TablePlugin-CfTWvWk1.js} +59 -59
  18. package/dist/{TablePlugin-CfXPNfT8.js.map → TablePlugin-CfTWvWk1.js.map} +1 -1
  19. package/dist/client--GsCJ9Up.js +27328 -0
  20. package/dist/client--GsCJ9Up.js.map +1 -0
  21. package/dist/components/Accordion/Accordion.test.js +3 -3
  22. package/dist/components/AccordionCard/AccordionCard.test.js +3 -3
  23. package/dist/components/ActionList/ActionList.test.js +3 -3
  24. package/dist/components/AppStatusBar/AppStatusBar.test.js +2 -2
  25. package/dist/components/Attention/Attention.test.js +2 -2
  26. package/dist/components/Backdrop/Backdrop.test.js +2 -2
  27. package/dist/components/Buttons/Button.test.js +2 -2
  28. package/dist/components/Buttons/LinkButton.test.js +2 -2
  29. package/dist/components/Buttons/MenuButton.test.js +2 -2
  30. package/dist/components/Card/Card.test.js +2 -2
  31. package/dist/components/Checkbox/Checkbox.test.js +3 -3
  32. package/dist/components/CheckboxButtonBar/CheckboxButtonBar.test.js +2 -2
  33. package/dist/components/CheckboxTree/CheckboxTree.js +1 -1
  34. package/dist/components/FeedbackBar/FeedbackBar.test.js +2 -2
  35. package/dist/components/FormInput/FormInput.js +1 -1
  36. package/dist/components/InputField/InputField.stories.js +1 -1
  37. package/dist/components/Label/Label.test.js +2 -2
  38. package/dist/components/MultiSelect/MultiSelect.js +1 -1
  39. package/dist/components/MultiSelect/MultiSelect.stories.js +1 -1
  40. package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -1
  41. package/dist/components/MultiSelect/index.js +1 -1
  42. package/dist/components/MultiSelectBox/MultiSelectBox.test.js +2 -2
  43. package/dist/components/Notification/Notification.test.js +2 -2
  44. package/dist/components/PeriodSelector/PeriodSelector.js +1 -1
  45. package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +1 -1
  46. package/dist/components/RadioGroup/Radiogroup.test.js +2 -2
  47. package/dist/components/RadioTabSelector/RadioTabSelector.js +1 -1
  48. package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -1
  49. package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +7 -7
  50. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +6 -6
  51. package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +2 -2
  52. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +9 -9
  53. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +35 -35
  54. package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +9 -5
  55. package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js.map +1 -1
  56. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +40 -40
  57. package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +5 -5
  58. package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.js +4 -4
  59. package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/index.js +1 -1
  60. package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +1 -1
  61. package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +4 -4
  62. package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +25 -25
  63. package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
  64. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +19 -19
  65. package/dist/components/RteEditor/Plugins/index.js +2 -2
  66. package/dist/components/RteEditor/RteEditor.js +671 -627
  67. package/dist/components/RteEditor/RteEditor.js.map +1 -1
  68. package/dist/components/RteEditor/helpers.js +8 -8
  69. package/dist/components/RteEditor/nodes/TableWrapperNode/TableWrapperNode.js +19 -19
  70. package/dist/components/StatusBadge/StatusBadge.test.js +2 -2
  71. package/dist/components/TextArea/TextArea.test.js +2 -2
  72. package/dist/components/VarIndicator/VarIndicator.test.js +3 -3
  73. package/dist/components/index.js +1 -1
  74. package/dist/{index-D5qpMB9d.js → index-Bf2LCbD1.js} +2 -2
  75. package/dist/{index-D5qpMB9d.js.map → index-Bf2LCbD1.js.map} +1 -1
  76. package/dist/{index-rQE9MV9y.js → index-JOHbZ4si.js} +523 -523
  77. package/dist/{index-rQE9MV9y.js.map → index-JOHbZ4si.js.map} +1 -1
  78. package/dist/index.js +1 -1
  79. package/dist/{react-18-DXfB7ZX7.js → react-18-BHQltW8V.js} +2 -2
  80. package/dist/{react-18-DXfB7ZX7.js.map → react-18-BHQltW8V.js.map} +1 -1
  81. package/dist/{react.esm-D2ppoNuM.js → react.esm-Bg7Fh9lz.js} +3 -3
  82. package/dist/{react.esm-D2ppoNuM.js.map → react.esm-Bg7Fh9lz.js.map} +1 -1
  83. package/dist/setupTests.js +1 -1
  84. package/dist/storybook__react.d.js +1 -1
  85. package/package.json +20 -20
  86. package/dist/Lexical.prod-nXWuyOKD.js.map +0 -1
  87. package/dist/LexicalClipboard.prod-pXq91TBU.js +0 -276
  88. package/dist/LexicalClipboard.prod-pXq91TBU.js.map +0 -1
  89. package/dist/LexicalLink.prod-Brzpgs_K.js +0 -285
  90. package/dist/LexicalLink.prod-Brzpgs_K.js.map +0 -1
  91. package/dist/LexicalList.prod--mkvX0uW.js.map +0 -1
  92. package/dist/LexicalSelection.prod-Ct4PZOht.js +0 -119
  93. package/dist/LexicalSelection.prod-Ct4PZOht.js.map +0 -1
  94. package/dist/LexicalTable.prod-Bexd4dGG.js +0 -1763
  95. package/dist/LexicalTable.prod-Bexd4dGG.js.map +0 -1
  96. package/dist/LexicalUtils.prod-Ckfw0Hjt.js +0 -123
  97. package/dist/LexicalUtils.prod-Ckfw0Hjt.js.map +0 -1
  98. package/dist/TableCellResizerPlugin-Cpbankb8.js.map +0 -1
  99. package/dist/client-BK9NlSVR.js +0 -25208
  100. package/dist/client-BK9NlSVR.js.map +0 -1
  101. package/dist/helpers-mE437H2Y.js +0 -164
  102. package/dist/helpers-mE437H2Y.js.map +0 -1
@@ -0,0 +1,1802 @@
1
+ import { l as Q, u as me, k as Tt, U as jt, N as Vt, B as Ft, A as Zt, L as Qt } from "./LexicalUtils.prod-C3vvQk50.js";
2
+ import { b as R, g as tt, d as ve, a as L, f as $, r as nt, j as Gt, e as Ce, K as dt, M as U, t as ot, T as en, m as Kt, l as re, u as ie, n as ke, O as rt, _ as D, y as tn, q as nn, L as on, p as rn, A as De, s as At, Z as ln, v as Ne, w as Ue, C as sn, z as an, B as cn, D as un, F as Ie, E as hn, G as dn, I as Ot, J as fn, N as V, Q as gn, R as mn, S as pn, V as _n, W as Cn, X as Sn, Y as wn, $ as yn, a0 as ge, a1 as ne, a2 as $e, a3 as bn, o as kt, a4 as Nn, a5 as vn, c as xn, a6 as Rn, a7 as Tn, a8 as ft, a9 as Fn, aa as gt, H as Kn, ab as mt, x as pt, h as Fe, ac as An } from "./Lexical.prod-DBU6xTBY.js";
3
+ import { F as On, J as kn } from "./LexicalClipboard.prod-CzGBnMdD.js";
4
+ const lt = /^(\d+(?:\.\d+)?)px$/, W = { BOTH: 3, COLUMN: 2, NO_STATUS: 0, ROW: 1 };
5
+ class ue extends tt {
6
+ __colSpan;
7
+ __rowSpan;
8
+ __headerState;
9
+ __width;
10
+ __backgroundColor;
11
+ __verticalAlign;
12
+ static getType() {
13
+ return "tablecell";
14
+ }
15
+ static clone(e) {
16
+ return new ue(e.__headerState, e.__colSpan, e.__width, e.__key);
17
+ }
18
+ afterCloneFrom(e) {
19
+ super.afterCloneFrom(e), this.__rowSpan = e.__rowSpan, this.__backgroundColor = e.__backgroundColor, this.__verticalAlign = e.__verticalAlign;
20
+ }
21
+ static importDOM() {
22
+ return { td: (e) => ({ conversion: _t, priority: 0 }), th: (e) => ({ conversion: _t, priority: 0 }) };
23
+ }
24
+ static importJSON(e) {
25
+ return Y().updateFromJSON(e);
26
+ }
27
+ updateFromJSON(e) {
28
+ 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);
29
+ }
30
+ constructor(e = W.NO_STATUS, t = 1, o, r) {
31
+ super(r), this.__colSpan = t, this.__rowSpan = 1, this.__headerState = e, this.__width = o, this.__backgroundColor = null, this.__verticalAlign = void 0;
32
+ }
33
+ createDOM(e) {
34
+ const t = document.createElement(this.getTag());
35
+ return this.__width && (t.style.width = `${this.__width}px`), this.__colSpan > 1 && (t.colSpan = this.__colSpan), this.__rowSpan > 1 && (t.rowSpan = this.__rowSpan), this.__backgroundColor !== null && (t.style.backgroundColor = this.__backgroundColor), Xe(this.__verticalAlign) && (t.style.verticalAlign = this.__verticalAlign), Q(t, e.theme.tableCell, this.hasHeader() && e.theme.tableCellHeader), t;
36
+ }
37
+ exportDOM(e) {
38
+ const t = super.exportDOM(e);
39
+ if (ve(t.element)) {
40
+ const o = t.element;
41
+ o.setAttribute("data-temporary-table-cell-lexical-key", this.getKey()), o.style.border = "1px solid black", this.__colSpan > 1 && (o.colSpan = this.__colSpan), this.__rowSpan > 1 && (o.rowSpan = this.__rowSpan), o.style.width = `${this.getWidth() || 75}px`, o.style.verticalAlign = this.getVerticalAlign() || "top", o.style.textAlign = "start", this.__backgroundColor === null && this.hasHeader() && (o.style.backgroundColor = "#f2f3f5");
42
+ }
43
+ return t;
44
+ }
45
+ exportJSON() {
46
+ return { ...super.exportJSON(), ...Xe(this.__verticalAlign) && { verticalAlign: this.__verticalAlign }, backgroundColor: this.getBackgroundColor(), colSpan: this.__colSpan, headerState: this.__headerState, rowSpan: this.__rowSpan, width: this.getWidth() };
47
+ }
48
+ getColSpan() {
49
+ return this.getLatest().__colSpan;
50
+ }
51
+ setColSpan(e) {
52
+ const t = this.getWritable();
53
+ return t.__colSpan = e, t;
54
+ }
55
+ getRowSpan() {
56
+ return this.getLatest().__rowSpan;
57
+ }
58
+ setRowSpan(e) {
59
+ const t = this.getWritable();
60
+ return t.__rowSpan = e, t;
61
+ }
62
+ getTag() {
63
+ return this.hasHeader() ? "th" : "td";
64
+ }
65
+ setHeaderStyles(e, t = W.BOTH) {
66
+ const o = this.getWritable();
67
+ return o.__headerState = e & t | o.__headerState & ~t, o;
68
+ }
69
+ getHeaderStyles() {
70
+ return this.getLatest().__headerState;
71
+ }
72
+ setWidth(e) {
73
+ const t = this.getWritable();
74
+ return t.__width = e, t;
75
+ }
76
+ getWidth() {
77
+ return this.getLatest().__width;
78
+ }
79
+ getBackgroundColor() {
80
+ return this.getLatest().__backgroundColor;
81
+ }
82
+ setBackgroundColor(e) {
83
+ const t = this.getWritable();
84
+ return t.__backgroundColor = e, t;
85
+ }
86
+ getVerticalAlign() {
87
+ return this.getLatest().__verticalAlign;
88
+ }
89
+ setVerticalAlign(e) {
90
+ const t = this.getWritable();
91
+ return t.__verticalAlign = e || void 0, t;
92
+ }
93
+ toggleHeaderStyle(e) {
94
+ const t = this.getWritable();
95
+ return (t.__headerState & e) === e ? t.__headerState -= e : t.__headerState += e, t;
96
+ }
97
+ hasHeaderState(e) {
98
+ return (this.getHeaderStyles() & e) === e;
99
+ }
100
+ hasHeader() {
101
+ return this.getLatest().__headerState !== W.NO_STATUS;
102
+ }
103
+ updateDOM(e) {
104
+ 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;
105
+ }
106
+ isShadowRoot() {
107
+ return !0;
108
+ }
109
+ collapseAtStart() {
110
+ return !0;
111
+ }
112
+ canBeEmpty() {
113
+ return !1;
114
+ }
115
+ canIndent() {
116
+ return !1;
117
+ }
118
+ }
119
+ function Xe(n) {
120
+ return n === "middle" || n === "bottom";
121
+ }
122
+ function _t(n) {
123
+ const e = n, t = n.nodeName.toLowerCase();
124
+ let o;
125
+ lt.test(e.style.width) && (o = parseFloat(e.style.width));
126
+ const r = Y(t === "th" ? W.ROW : W.NO_STATUS, e.colSpan, o);
127
+ r.__rowSpan = e.rowSpan;
128
+ const s = e.style.backgroundColor;
129
+ s !== "" && (r.__backgroundColor = s);
130
+ const l = e.style.verticalAlign;
131
+ Xe(l) && (r.__verticalAlign = l);
132
+ const i = e.style, u = (i && i.textDecoration || "").split(" "), f = i.fontWeight === "700" || i.fontWeight === "bold", h = u.includes("line-through"), p = i.fontStyle === "italic", _ = u.includes("underline");
133
+ return { after: (a) => {
134
+ const c = [];
135
+ let g = null;
136
+ const d = () => {
137
+ if (g) {
138
+ const m = g.getFirstChild();
139
+ dt(m) && g.getChildrenSize() === 1 && m.remove();
140
+ }
141
+ };
142
+ for (const m of a) Gt(m) || Ce(m) || dt(m) ? (Ce(m) && (f && m.toggleFormat("bold"), h && m.toggleFormat("strikethrough"), p && m.toggleFormat("italic"), _ && m.toggleFormat("underline")), g ? g.append(m) : (g = U().append(m), c.push(g))) : (c.push(m), d(), g = null);
143
+ return d(), c.length === 0 && c.push(U()), c;
144
+ }, node: r };
145
+ }
146
+ function Y(n = W.NO_STATUS, e = 1, t) {
147
+ return nt(new ue(n, e, t));
148
+ }
149
+ function y(n) {
150
+ return n instanceof ue;
151
+ }
152
+ const En = ln("INSERT_TABLE_COMMAND");
153
+ function w(n, ...e) {
154
+ const t = new URL("https://lexical.dev/docs/error"), o = new URLSearchParams();
155
+ o.append("code", n);
156
+ for (const r of e) o.append("v", r);
157
+ throw t.search = o.toString(), Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
158
+ }
159
+ class Te extends tt {
160
+ __height;
161
+ static getType() {
162
+ return "tablerow";
163
+ }
164
+ static clone(e) {
165
+ return new Te(e.__height, e.__key);
166
+ }
167
+ static importDOM() {
168
+ return { tr: (e) => ({ conversion: Mn, priority: 0 }) };
169
+ }
170
+ static importJSON(e) {
171
+ return Re().updateFromJSON(e);
172
+ }
173
+ updateFromJSON(e) {
174
+ return super.updateFromJSON(e).setHeight(e.height);
175
+ }
176
+ constructor(e, t) {
177
+ super(t), this.__height = e;
178
+ }
179
+ exportJSON() {
180
+ const e = this.getHeight();
181
+ return { ...super.exportJSON(), ...e === void 0 ? void 0 : { height: e } };
182
+ }
183
+ createDOM(e) {
184
+ const t = document.createElement("tr");
185
+ return this.__height && (t.style.height = `${this.__height}px`), Q(t, e.theme.tableRow), t;
186
+ }
187
+ extractWithChild(e, t, o) {
188
+ return o === "html";
189
+ }
190
+ isShadowRoot() {
191
+ return !0;
192
+ }
193
+ setHeight(e) {
194
+ const t = this.getWritable();
195
+ return t.__height = e, t;
196
+ }
197
+ getHeight() {
198
+ return this.getLatest().__height;
199
+ }
200
+ updateDOM(e) {
201
+ return e.__height !== this.__height;
202
+ }
203
+ canBeEmpty() {
204
+ return !1;
205
+ }
206
+ canIndent() {
207
+ return !1;
208
+ }
209
+ }
210
+ function Mn(n) {
211
+ const e = n;
212
+ let t;
213
+ return lt.test(e.style.height) && (t = parseFloat(e.style.height)), { after: (o) => Tt(o, y), node: Re(t) };
214
+ }
215
+ function Re(n) {
216
+ return nt(new Te(n));
217
+ }
218
+ function E(n) {
219
+ return n instanceof Te;
220
+ }
221
+ const st = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0, $n = st && "documentMode" in document ? document.documentMode : null, Ct = st && /^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);
222
+ function zn(n, e, t = !0) {
223
+ const o = ct();
224
+ for (let r = 0; r < n; r++) {
225
+ const s = Re();
226
+ for (let l = 0; l < e; l++) {
227
+ let i = W.NO_STATUS;
228
+ typeof t == "object" ? (r === 0 && t.rows && (i |= W.ROW), l === 0 && t.columns && (i |= W.COLUMN)) : t && (r === 0 && (i |= W.ROW), l === 0 && (i |= W.COLUMN));
229
+ const u = Y(i), f = U();
230
+ f.append(ot()), u.append(f), s.append(u);
231
+ }
232
+ o.append(s);
233
+ }
234
+ return o;
235
+ }
236
+ function so(n) {
237
+ const e = R(n, (t) => y(t));
238
+ return y(e) ? e : null;
239
+ }
240
+ function Et(n) {
241
+ const e = R(n, (t) => E(t));
242
+ if (E(e)) return e;
243
+ throw new Error("Expected table cell to be inside of table row.");
244
+ }
245
+ function Mt(n) {
246
+ const e = R(n, (t) => M(t));
247
+ if (M(e)) return e;
248
+ throw new Error("Expected table cell to be inside of table.");
249
+ }
250
+ function io(n) {
251
+ const e = Et(n);
252
+ return Mt(e).getChildren().findIndex((t) => t.is(e));
253
+ }
254
+ function ao(n) {
255
+ return Et(n).getChildren().findIndex((e) => e.is(n));
256
+ }
257
+ st && "InputEvent" in window && !$n && new window.InputEvent("input");
258
+ const Ye = (n, e) => n === W.BOTH || n === e ? e : W.NO_STATUS;
259
+ function co(n = !0) {
260
+ const e = L();
261
+ $(e) || K(e) || w(188);
262
+ const t = e.anchor.getNode(), o = e.focus.getNode(), [r] = I(t), [s, , l] = I(o), [, i, u] = J(l, s, r), { startRow: f } = u, { startRow: h } = i;
263
+ return n ? qe(f + r.__rowSpan > h + s.__rowSpan ? r : s, !0) : qe(h < f ? s : r, !1);
264
+ }
265
+ function qe(n, e = !0) {
266
+ const [, , t] = I(n), [o, r] = J(t, n, n), s = o[0].length, { startRow: l } = r;
267
+ let i = null;
268
+ if (e) {
269
+ const u = l + n.__rowSpan - 1, f = o[u], h = Re();
270
+ for (let _ = 0; _ < s; _++) {
271
+ const { cell: a, startRow: c } = f[_];
272
+ if (c + a.__rowSpan - 1 <= u) {
273
+ const g = f[_].cell.__headerState, d = Ye(g, W.COLUMN);
274
+ h.append(Y(d).append(U()));
275
+ } else a.setRowSpan(a.__rowSpan + 1);
276
+ }
277
+ const p = t.getChildAtIndex(u);
278
+ E(p) || w(256), p.insertAfter(h), i = h;
279
+ } else {
280
+ const u = l, f = o[u], h = Re();
281
+ for (let _ = 0; _ < s; _++) {
282
+ const { cell: a, startRow: c } = f[_];
283
+ if (c === u) {
284
+ const g = f[_].cell.__headerState, d = Ye(g, W.COLUMN);
285
+ h.append(Y(d).append(U()));
286
+ } else a.setRowSpan(a.__rowSpan + 1);
287
+ }
288
+ const p = t.getChildAtIndex(u);
289
+ E(p) || w(257), p.insertBefore(h), i = h;
290
+ }
291
+ return i;
292
+ }
293
+ function uo(n = !0) {
294
+ const e = L();
295
+ $(e) || K(e) || w(188);
296
+ const t = e.anchor.getNode(), o = e.focus.getNode(), [r] = I(t), [s, , l] = I(o), [, i, u] = J(l, s, r), { startColumn: f } = u, { startColumn: h } = i;
297
+ return n ? je(f + r.__colSpan > h + s.__colSpan ? r : s, !0) : je(h < f ? s : r, !1);
298
+ }
299
+ function je(n, e = !0, t = !0) {
300
+ const [, , o] = I(n), [r, s] = J(o, n, n), l = r.length, { startColumn: i } = s, u = e ? i + n.__colSpan - 1 : i - 1, f = o.getFirstChild();
301
+ E(f) || w(120);
302
+ let h = null;
303
+ function p(c = W.NO_STATUS) {
304
+ const g = Y(c).append(U());
305
+ return h === null && (h = g), g;
306
+ }
307
+ let _ = f;
308
+ e: for (let c = 0; c < l; c++) {
309
+ if (c !== 0) {
310
+ const b = _.getNextSibling();
311
+ E(b) || w(121), _ = b;
312
+ }
313
+ const g = r[c], d = g[u < 0 ? 0 : u].cell.__headerState, m = Ye(d, W.ROW);
314
+ if (u < 0) {
315
+ $t(_, p(m));
316
+ continue;
317
+ }
318
+ const { cell: C, startColumn: S, startRow: N } = g[u];
319
+ if (S + C.__colSpan - 1 <= u) {
320
+ let b = C, v = N, T = u;
321
+ for (; v !== c && b.__rowSpan > 1; ) {
322
+ if (T -= C.__colSpan, !(T >= 0)) {
323
+ _.append(p(m));
324
+ continue e;
325
+ }
326
+ {
327
+ const { cell: k, startRow: O } = g[T];
328
+ b = k, v = O;
329
+ }
330
+ }
331
+ b.insertAfter(p(m));
332
+ } else C.setColSpan(C.__colSpan + 1);
333
+ }
334
+ h !== null && t && Ve(h);
335
+ const a = o.getColWidths();
336
+ if (a) {
337
+ const c = [...a], g = u < 0 ? 0 : u, d = c[g];
338
+ c.splice(g, 0, d), o.setColWidths(c);
339
+ }
340
+ return h;
341
+ }
342
+ function ho() {
343
+ const n = L();
344
+ $(n) || K(n) || w(188);
345
+ const e = n.anchor.getNode(), t = n.focus.getNode(), [o, , r] = I(e), [s] = I(t), [l, i, u] = J(r, o, s), { startColumn: f } = i, { startRow: h, startColumn: p } = u, _ = Math.min(f, p), a = Math.max(f + o.__colSpan - 1, p + s.__colSpan - 1), c = a - _ + 1;
346
+ if (l[0].length === a - _ + 1) return r.selectPrevious(), void r.remove();
347
+ const g = l.length;
348
+ for (let S = 0; S < g; S++) for (let N = _; N <= a; N++) {
349
+ const { cell: b, startColumn: v } = l[S][N];
350
+ if (v < _) {
351
+ if (N === _) {
352
+ const T = _ - v;
353
+ b.setColSpan(b.__colSpan - Math.min(c, b.__colSpan - T));
354
+ }
355
+ } else if (v + b.__colSpan - 1 > a) {
356
+ if (N === a) {
357
+ const T = a - v + 1;
358
+ b.setColSpan(b.__colSpan - T);
359
+ }
360
+ } else b.remove();
361
+ }
362
+ const d = l[h], m = f > p ? d[f + o.__colSpan] : d[p + s.__colSpan];
363
+ if (m !== void 0) {
364
+ const { cell: S } = m;
365
+ Ve(S);
366
+ } else {
367
+ const S = p < f ? d[p - 1] : d[f - 1], { cell: N } = S;
368
+ Ve(N);
369
+ }
370
+ const C = r.getColWidths();
371
+ if (C) {
372
+ const S = [...C];
373
+ S.splice(_, c), r.setColWidths(S);
374
+ }
375
+ }
376
+ function Ve(n) {
377
+ const e = n.getFirstDescendant();
378
+ e == null ? n.selectStart() : e.getParentOrThrow().selectStart();
379
+ }
380
+ function $t(n, e) {
381
+ const t = n.getFirstChild();
382
+ t !== null ? t.insertBefore(e) : n.append(e);
383
+ }
384
+ function Ln(n) {
385
+ if (n.length === 0) return null;
386
+ const e = Mt(n[0]), [t] = oe(e, null, null);
387
+ let o = 1 / 0, r = -1 / 0, s = 1 / 0, l = -1 / 0;
388
+ const i = /* @__PURE__ */ new Set();
389
+ for (const a of t) for (const c of a) {
390
+ if (!c || !c.cell) continue;
391
+ const g = c.cell.getKey();
392
+ if (!i.has(g) && n.some((d) => d.is(c.cell))) {
393
+ i.add(g);
394
+ const d = c.startRow, m = c.startColumn, C = c.cell.__rowSpan || 1, S = c.cell.__colSpan || 1;
395
+ o = Math.min(o, d), r = Math.max(r, d + C - 1), s = Math.min(s, m), l = Math.max(l, m + S - 1);
396
+ }
397
+ }
398
+ if (o === 1 / 0 || s === 1 / 0) return null;
399
+ const u = r - o + 1, f = l - s + 1, h = t[o][s];
400
+ if (!h.cell) return null;
401
+ const p = h.cell;
402
+ p.setColSpan(f), p.setRowSpan(u);
403
+ const _ = /* @__PURE__ */ new Set([p.getKey()]);
404
+ for (let a = o; a <= r; a++) for (let c = s; c <= l; c++) {
405
+ const g = t[a][c];
406
+ if (!g.cell) continue;
407
+ const d = g.cell, m = d.getKey();
408
+ _.has(m) || (_.add(m), Wn(d) || p.append(...d.getChildren()), d.remove());
409
+ }
410
+ return p.getChildrenSize() === 0 && p.append(U()), p;
411
+ }
412
+ function Wn(n) {
413
+ if (n.getChildrenSize() !== 1) return !1;
414
+ const e = n.getFirstChildOrThrow();
415
+ return !(!rt(e) || !e.isEmpty());
416
+ }
417
+ function Hn(n) {
418
+ const [e, t, o] = I(n), r = e.__colSpan, s = e.__rowSpan;
419
+ if (r === 1 && s === 1) return;
420
+ const [l, i] = J(o, e, e), { startColumn: u, startRow: f } = i, h = e.__headerState & W.COLUMN, p = Array.from({ length: r }, (c, g) => {
421
+ let d = h;
422
+ for (let m = 0; d !== 0 && m < l.length; m++) d &= l[m][g + u].cell.__headerState;
423
+ return d;
424
+ }), _ = e.__headerState & W.ROW, a = Array.from({ length: s }, (c, g) => {
425
+ let d = _;
426
+ for (let m = 0; d !== 0 && m < l[0].length; m++) d &= l[g + f][m].cell.__headerState;
427
+ return d;
428
+ });
429
+ if (r > 1) {
430
+ for (let c = 1; c < r; c++) e.insertAfter(Y(p[c] | a[0]).append(U()));
431
+ e.setColSpan(1);
432
+ }
433
+ if (s > 1) {
434
+ let c;
435
+ for (let g = 1; g < s; g++) {
436
+ const d = f + g, m = l[d];
437
+ c = (c || t).getNextSibling(), E(c) || w(125);
438
+ let C = null;
439
+ for (let S = 0; S < u; S++) {
440
+ const N = m[S], b = N.cell;
441
+ N.startRow === d && (C = b), b.__colSpan > 1 && (S += b.__colSpan - 1);
442
+ }
443
+ if (C === null) for (let S = r - 1; S >= 0; S--) $t(c, Y(p[S] | a[g]).append(U()));
444
+ else for (let S = r - 1; S >= 0; S--) C.insertAfter(Y(p[S] | a[g]).append(U()));
445
+ }
446
+ e.setRowSpan(1);
447
+ }
448
+ }
449
+ function J(n, e, t) {
450
+ const [o, r, s] = oe(n, e, t);
451
+ return r === null && w(207), s === null && w(208), [o, r, s];
452
+ }
453
+ function oe(n, e, t) {
454
+ const o = [];
455
+ let r = null, s = null;
456
+ function l(u) {
457
+ let f = o[u];
458
+ return f === void 0 && (o[u] = f = []), f;
459
+ }
460
+ const i = n.getChildren();
461
+ for (let u = 0; u < i.length; u++) {
462
+ const f = i[u];
463
+ E(f) || w(209);
464
+ const h = l(u);
465
+ for (let p = f.getFirstChild(), _ = 0; p != null; p = p.getNextSibling()) {
466
+ for (y(p) || w(147); h[_] !== void 0; ) _++;
467
+ const a = { cell: p, startColumn: _, startRow: u }, { __rowSpan: c, __colSpan: g } = p;
468
+ for (let d = 0; d < c && !(u + d >= i.length); d++) {
469
+ const m = l(u + d);
470
+ for (let C = 0; C < g; C++) m[_ + C] = a;
471
+ }
472
+ e !== null && r === null && e.is(p) && (r = a), t !== null && s === null && t.is(p) && (s = a);
473
+ }
474
+ }
475
+ return [o, r, s];
476
+ }
477
+ function I(n) {
478
+ let e;
479
+ if (n instanceof ue) e = n;
480
+ else if ("__type" in n) {
481
+ const r = R(n, y);
482
+ y(r) || w(148), e = r;
483
+ } else {
484
+ const r = R(n.getNode(), y);
485
+ y(r) || w(148), e = r;
486
+ }
487
+ const t = e.getParent();
488
+ E(t) || w(149);
489
+ const o = t.getParent();
490
+ return M(o) || w(210), [e, t, o];
491
+ }
492
+ function Ee(n, e, t) {
493
+ let o, r = Math.min(e.startColumn, t.startColumn), s = Math.min(e.startRow, t.startRow), l = Math.max(e.startColumn + e.cell.__colSpan - 1, t.startColumn + t.cell.__colSpan - 1), i = Math.max(e.startRow + e.cell.__rowSpan - 1, t.startRow + t.cell.__rowSpan - 1);
494
+ do {
495
+ o = !1;
496
+ for (let u = 0; u < n.length; u++) for (let f = 0; f < n[0].length; f++) {
497
+ const h = n[u][f];
498
+ if (!h) continue;
499
+ const p = h.startColumn + h.cell.__colSpan - 1, _ = h.startRow + h.cell.__rowSpan - 1, a = h.startColumn <= l && p >= r, c = h.startRow <= i && _ >= s;
500
+ if (a && c) {
501
+ const g = Math.min(r, h.startColumn), d = Math.max(l, p), m = Math.min(s, h.startRow), C = Math.max(i, _);
502
+ g === r && d === l && m === s && C === i || (r = g, l = d, s = m, i = C, o = !0);
503
+ }
504
+ }
505
+ } while (o);
506
+ return { maxColumn: l, maxRow: i, minColumn: r, minRow: s };
507
+ }
508
+ function St(n) {
509
+ const [e, , t] = I(n), o = t.getChildren(), r = o.length, s = o[0].getChildren().length, l = new Array(r);
510
+ for (let i = 0; i < r; i++) l[i] = new Array(s);
511
+ for (let i = 0; i < r; i++) {
512
+ const u = o[i].getChildren();
513
+ let f = 0;
514
+ for (let h = 0; h < u.length; h++) {
515
+ for (; l[i][f]; ) f++;
516
+ const p = u[h], _ = p.__rowSpan || 1, a = p.__colSpan || 1;
517
+ for (let c = 0; c < _; c++) for (let g = 0; g < a; g++) l[i + c][f + g] = p;
518
+ if (e === p) return { colSpan: a, columnIndex: f, rowIndex: i, rowSpan: _ };
519
+ f += a;
520
+ }
521
+ }
522
+ return null;
523
+ }
524
+ function wt(n) {
525
+ const [[e, t, o, r], [s, l, i, u]] = ["anchor", "focus"].map((f) => {
526
+ const h = n[f].getNode(), p = R(h, y);
527
+ y(p) || w(238, f, h.getKey(), h.getType());
528
+ const _ = p.getParent();
529
+ E(_) || w(239, f);
530
+ const a = _.getParent();
531
+ return M(a) || w(240, f), [h, p, _, a];
532
+ });
533
+ return r.is(u) || w(241), { anchorCell: t, anchorNode: e, anchorRow: o, anchorTable: r, focusCell: l, focusNode: s, focusRow: i, focusTable: u };
534
+ }
535
+ class ze {
536
+ tableKey;
537
+ anchor;
538
+ focus;
539
+ _cachedNodes;
540
+ dirty;
541
+ constructor(e, t, o) {
542
+ this.anchor = t, this.focus = o, t._selection = this, o._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = e;
543
+ }
544
+ getStartEndPoints() {
545
+ return [this.anchor, this.focus];
546
+ }
547
+ isValid() {
548
+ if (this.tableKey === "root" || this.anchor.key === "root" || this.anchor.type !== "element" || this.focus.key === "root" || this.focus.type !== "element") return !1;
549
+ const e = ie(this.tableKey), t = ie(this.anchor.key), o = ie(this.focus.key);
550
+ return e !== null && t !== null && o !== null;
551
+ }
552
+ isBackward() {
553
+ return this.focus.isBefore(this.anchor);
554
+ }
555
+ getCachedNodes() {
556
+ return this._cachedNodes;
557
+ }
558
+ setCachedNodes(e) {
559
+ this._cachedNodes = e;
560
+ }
561
+ is(e) {
562
+ return K(e) && this.tableKey === e.tableKey && this.anchor.is(e.anchor) && this.focus.is(e.focus);
563
+ }
564
+ set(e, t, o) {
565
+ this.dirty = this.dirty || e !== this.tableKey || t !== this.anchor.key || o !== this.focus.key, this.tableKey = e, this.anchor.key = t, this.focus.key = o, this._cachedNodes = null;
566
+ }
567
+ clone() {
568
+ return new ze(this.tableKey, ke(this.anchor.key, this.anchor.offset, this.anchor.type), ke(this.focus.key, this.focus.offset, this.focus.type));
569
+ }
570
+ isCollapsed() {
571
+ return !1;
572
+ }
573
+ extract() {
574
+ return this.getNodes();
575
+ }
576
+ insertRawText(e) {
577
+ }
578
+ insertText() {
579
+ }
580
+ hasFormat(e) {
581
+ let t = 0;
582
+ this.getNodes().filter(y).forEach((r) => {
583
+ const s = r.getFirstChild();
584
+ rt(s) && (t |= s.getTextFormat());
585
+ });
586
+ const o = on[e];
587
+ return (t & o) !== 0;
588
+ }
589
+ insertNodes(e) {
590
+ const t = this.focus.getNode();
591
+ D(t) || w(151), tn(t.select(0, t.getChildrenSize())).insertNodes(e);
592
+ }
593
+ getShape() {
594
+ const { anchorCell: e, focusCell: t } = wt(this), o = St(e);
595
+ o === null && w(153);
596
+ const r = St(t);
597
+ r === null && w(155);
598
+ const s = Math.min(o.columnIndex, r.columnIndex), l = Math.max(o.columnIndex + o.colSpan - 1, r.columnIndex + r.colSpan - 1), i = Math.min(o.rowIndex, r.rowIndex), u = Math.max(o.rowIndex + o.rowSpan - 1, r.rowIndex + r.rowSpan - 1);
599
+ return { fromX: Math.min(s, l), fromY: Math.min(i, u), toX: Math.max(s, l), toY: Math.max(i, u) };
600
+ }
601
+ getNodes() {
602
+ if (!this.isValid()) return [];
603
+ const e = this._cachedNodes;
604
+ if (e !== null) return e;
605
+ const { anchorTable: t, anchorCell: o, focusCell: r } = wt(this), s = r.getParents()[1];
606
+ if (s !== t) {
607
+ if (t.isParentOf(r)) {
608
+ const d = s.getParent();
609
+ d == null && w(159), this.set(this.tableKey, r.getKey(), d.getKey());
610
+ } else {
611
+ const d = t.getParent();
612
+ d == null && w(158), this.set(this.tableKey, d.getKey(), r.getKey());
613
+ }
614
+ return this.getNodes();
615
+ }
616
+ const [l, i, u] = J(t, o, r), { minColumn: f, maxColumn: h, minRow: p, maxRow: _ } = Ee(l, i, u), a = /* @__PURE__ */ new Map([[t.getKey(), t]]);
617
+ let c = null;
618
+ for (let d = p; d <= _; d++) for (let m = f; m <= h; m++) {
619
+ const { cell: C } = l[d][m], S = C.getParent();
620
+ E(S) || w(160), S !== c && (a.set(S.getKey(), S), c = S), a.has(C.getKey()) || Bn(C, (N) => {
621
+ a.set(N.getKey(), N);
622
+ });
623
+ }
624
+ const g = Array.from(a.values());
625
+ return nn() || (this._cachedNodes = g), g;
626
+ }
627
+ getTextContent() {
628
+ const e = this.getNodes().filter((o) => y(o));
629
+ let t = "";
630
+ for (let o = 0; o < e.length; o++) {
631
+ const r = e[o], s = r.__parent, l = (e[o + 1] || {}).__parent;
632
+ t += r.getTextContent() + (l !== s ? `
633
+ ` : " ");
634
+ }
635
+ return t;
636
+ }
637
+ }
638
+ function K(n) {
639
+ return n instanceof ze;
640
+ }
641
+ function zt() {
642
+ const n = ke("root", 0, "element"), e = ke("root", 0, "element");
643
+ return new ze("root", n, e);
644
+ }
645
+ function Pn(n, e, t) {
646
+ n.getKey(), e.getKey(), t.getKey();
647
+ const o = L(), r = K(o) ? o.clone() : zt();
648
+ return r.set(n.getKey(), e.getKey(), t.getKey()), r;
649
+ }
650
+ function Bn(n, e) {
651
+ const t = [[n]];
652
+ for (let o = t.at(-1); o !== void 0 && t.length > 0; o = t.at(-1)) {
653
+ const r = o.pop();
654
+ r === void 0 ? t.pop() : e(r) !== !1 && D(r) && t.push(r.getChildren());
655
+ }
656
+ }
657
+ function Lt(n, e = Kt()) {
658
+ const t = ie(n);
659
+ M(t) || w(231, n);
660
+ const o = ae(t, e.getElementByKey(n));
661
+ return o === null && w(232, n), { tableElement: o, tableNode: t };
662
+ }
663
+ class Dn {
664
+ focusX;
665
+ focusY;
666
+ listenersToRemove;
667
+ table;
668
+ isHighlightingCells;
669
+ anchorX;
670
+ anchorY;
671
+ tableNodeKey;
672
+ anchorCell;
673
+ focusCell;
674
+ anchorCellNodeKey;
675
+ focusCellNodeKey;
676
+ editor;
677
+ tableSelection;
678
+ hasHijackedSelectionStyles;
679
+ isSelecting;
680
+ pointerType;
681
+ shouldCheckSelection;
682
+ abortController;
683
+ listenerOptions;
684
+ nextFocus;
685
+ constructor(e, t) {
686
+ 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 = { columns: 0, domRows: [], rows: 0 }, 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.shouldCheckSelection = !1, this.abortController = new AbortController(), this.listenerOptions = { signal: this.abortController.signal }, this.nextFocus = null, this.trackTable();
687
+ }
688
+ getTable() {
689
+ return this.table;
690
+ }
691
+ removeListeners() {
692
+ this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach((e) => e()), this.listenersToRemove.clear();
693
+ }
694
+ $lookup() {
695
+ return Lt(this.tableNodeKey, this.editor);
696
+ }
697
+ trackTable() {
698
+ const e = new MutationObserver((t) => {
699
+ this.editor.getEditorState().read(() => {
700
+ let o = !1;
701
+ for (let l = 0; l < t.length; l++) {
702
+ const i = t[l].target.nodeName;
703
+ if (i === "TABLE" || i === "TBODY" || i === "THEAD" || i === "TR") {
704
+ o = !0;
705
+ break;
706
+ }
707
+ }
708
+ if (!o) return;
709
+ const { tableNode: r, tableElement: s } = this.$lookup();
710
+ this.table = pe(r, s);
711
+ }, { editor: this.editor });
712
+ });
713
+ this.editor.getEditorState().read(() => {
714
+ const { tableNode: t, tableElement: o } = this.$lookup();
715
+ this.table = pe(t, o), e.observe(o, { attributes: !0, childList: !0, subtree: !0 });
716
+ }, { editor: this.editor });
717
+ }
718
+ $clearHighlight() {
719
+ const e = this.editor;
720
+ 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();
721
+ const { tableNode: t, tableElement: o } = this.$lookup();
722
+ Ke(e, pe(t, o), null), L() !== null && (ne(null), e.dispatchCommand(ge, void 0));
723
+ }
724
+ $enableHighlightStyle() {
725
+ const e = this.editor, { tableElement: t } = this.$lookup();
726
+ me(t, e._config.theme.tableSelection), t.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1;
727
+ }
728
+ $disableHighlightStyle() {
729
+ const { tableElement: e } = this.$lookup();
730
+ Q(e, this.editor._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0;
731
+ }
732
+ $updateTableTableSelection(e) {
733
+ if (e !== null) {
734
+ e.tableKey !== this.tableNodeKey && w(233, e.tableKey, this.tableNodeKey);
735
+ const t = this.editor;
736
+ this.tableSelection = e, this.isHighlightingCells = !0, this.$disableHighlightStyle(), this.updateDOMSelection(), Ke(t, this.table, this.tableSelection);
737
+ } else this.$clearHighlight();
738
+ }
739
+ setShouldCheckSelection() {
740
+ this.shouldCheckSelection = !0;
741
+ }
742
+ getAndClearShouldCheckSelection() {
743
+ return !!this.shouldCheckSelection && (this.shouldCheckSelection = !1, !0);
744
+ }
745
+ setNextFocus(e) {
746
+ this.nextFocus = e;
747
+ }
748
+ getAndClearNextFocus() {
749
+ const { nextFocus: e } = this;
750
+ return e !== null && (this.nextFocus = null), e;
751
+ }
752
+ updateDOMSelection() {
753
+ if (this.anchorCell !== null && this.focusCell !== null) {
754
+ const e = $e(this.editor._window);
755
+ e && e.rangeCount > 0 && e.removeAllRanges();
756
+ }
757
+ }
758
+ $setFocusCellForSelection(e, t = !1) {
759
+ const o = this.editor, { tableNode: r } = this.$lookup(), s = e.x, l = e.y;
760
+ if (this.focusCell = e, this.isHighlightingCells || this.anchorX === s && this.anchorY === l && !t) {
761
+ if (s === this.focusX && l === this.focusY) return !1;
762
+ } else this.isHighlightingCells = !0, this.$disableHighlightStyle();
763
+ if (this.focusX = s, this.focusY = l, this.isHighlightingCells) {
764
+ const i = Qe(r, e.elem);
765
+ if (this.tableSelection != null && this.anchorCellNodeKey != null && i !== null) return this.focusCellNodeKey = i.getKey(), this.tableSelection = Pn(r, this.$getAnchorTableCellOrThrow(), i), ne(this.tableSelection), o.dispatchCommand(ge, void 0), Ke(o, this.table, this.tableSelection), !0;
766
+ }
767
+ return !1;
768
+ }
769
+ $getAnchorTableCell() {
770
+ return this.anchorCellNodeKey ? ie(this.anchorCellNodeKey) : null;
771
+ }
772
+ $getAnchorTableCellOrThrow() {
773
+ const e = this.$getAnchorTableCell();
774
+ return e === null && w(234), e;
775
+ }
776
+ $getFocusTableCell() {
777
+ return this.focusCellNodeKey ? ie(this.focusCellNodeKey) : null;
778
+ }
779
+ $getFocusTableCellOrThrow() {
780
+ const e = this.$getFocusTableCell();
781
+ return e === null && w(235), e;
782
+ }
783
+ $setAnchorCellForSelection(e) {
784
+ this.isHighlightingCells = !1, this.anchorCell = e, this.anchorX = e.x, this.anchorY = e.y;
785
+ const { tableNode: t } = this.$lookup(), o = Qe(t, e.elem);
786
+ if (o !== null) {
787
+ const r = o.getKey();
788
+ this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : zt(), this.anchorCellNodeKey = r;
789
+ }
790
+ }
791
+ $formatCells(e) {
792
+ const t = L();
793
+ K(t) || w(236);
794
+ const o = Nn(), r = o.anchor, s = o.focus, l = t.getNodes().filter(y);
795
+ l.length > 0 || w(237);
796
+ const i = l[0].getFirstChild(), u = rt(i) ? i.getFormatFlags(e, null) : null;
797
+ l.forEach((f) => {
798
+ r.set(f.getKey(), 0, "element"), s.set(f.getKey(), f.getChildrenSize(), "element"), o.formatText(e, u);
799
+ }), ne(t), this.editor.dispatchCommand(ge, void 0);
800
+ }
801
+ $clearText() {
802
+ const { editor: e } = this, t = ie(this.tableNodeKey);
803
+ if (!M(t)) throw new Error("Expected TableNode.");
804
+ const o = L();
805
+ K(o) || w(253);
806
+ const r = o.getNodes().filter(y), s = t.getFirstChild(), l = t.getLastChild();
807
+ if (r.length > 0 && s !== null && l !== null && E(s) && E(l) && r[0] === s.getFirstChild() && r[r.length - 1] === l.getLastChild()) {
808
+ t.selectPrevious();
809
+ const i = t.getParent();
810
+ return t.remove(), void (vn(i) && i.isEmpty() && e.dispatchCommand(kt, void 0));
811
+ }
812
+ r.forEach((i) => {
813
+ if (D(i)) {
814
+ const u = U(), f = ot();
815
+ u.append(f), i.append(u), i.getChildren().forEach((h) => {
816
+ h !== u && h.remove();
817
+ });
818
+ }
819
+ }), Ke(e, this.table, null), ne(null), e.dispatchCommand(ge, void 0);
820
+ }
821
+ }
822
+ const Ze = "__lexicalTableSelection";
823
+ function fe(n) {
824
+ return ve(n) && n.nodeName === "TABLE";
825
+ }
826
+ function ae(n, e) {
827
+ if (!e) return e;
828
+ const t = fe(e) ? e : n.getDOMSlot(e).element;
829
+ return t.nodeName !== "TABLE" && w(245, e.nodeName), t;
830
+ }
831
+ function it(n) {
832
+ return n._window;
833
+ }
834
+ function xe(n, e) {
835
+ for (let t = e, o = null; t !== null; t = t.getParent()) {
836
+ if (n.is(t)) return o;
837
+ y(t) && (o = t);
838
+ }
839
+ return null;
840
+ }
841
+ const In = [[sn, "down"], [an, "up"], [cn, "backward"], [un, "forward"]], Jn = [dn, Ot, fn], Un = [gn, mn];
842
+ function Xn(n, e, t, o) {
843
+ const r = t.getRootElement(), s = it(t);
844
+ r !== null && s !== null || w(246);
845
+ const l = new Dn(t, n.getKey()), i = ae(n, e);
846
+ (function(a, c) {
847
+ yt(a) !== null && w(205), a[Ze] = c;
848
+ })(i, l), l.listenersToRemove.add(() => (function(a, c) {
849
+ yt(a) === c && delete a[Ze];
850
+ })(i, l));
851
+ const u = (a) => {
852
+ if (l.pointerType = a.pointerType, a.button !== 0 || !Ne(a.target) || !s) return;
853
+ const c = Me(a.target);
854
+ c !== null && t.update(() => {
855
+ const g = Ue();
856
+ if (Ct && a.shiftKey && Z(g, n) && ($(g) || K(g))) {
857
+ const d = g.anchor.getNode(), m = xe(n, g.anchor.getNode());
858
+ m ? (l.$setAnchorCellForSelection(se(l, m)), l.$setFocusCellForSelection(c), ee(a)) : (n.isBefore(d) ? n.selectStart() : n.selectEnd()).anchor.set(g.anchor.key, g.anchor.offset, g.anchor.type);
859
+ } else a.pointerType !== "touch" && l.$setAnchorCellForSelection(c);
860
+ }), (() => {
861
+ if (l.isSelecting) return;
862
+ const g = () => {
863
+ l.isSelecting = !1, s.removeEventListener("pointerup", g), s.removeEventListener("pointermove", d);
864
+ }, d = (m) => {
865
+ if (1 & ~m.buttons && l.isSelecting) return l.isSelecting = !1, s.removeEventListener("pointerup", g), void s.removeEventListener("pointermove", d);
866
+ if (!Ne(m.target)) return;
867
+ let C = null;
868
+ const S = !(Ct || i.contains(m.target));
869
+ if (S) C = bt(i, m.target);
870
+ else for (const N of document.elementsFromPoint(m.clientX, m.clientY)) if (C = bt(i, N), C) break;
871
+ !C || l.focusCell !== null && C.elem === l.focusCell.elem || (l.setNextFocus({ focusCell: C, override: S }), t.dispatchCommand(ge, void 0));
872
+ };
873
+ l.isSelecting = !0, s.addEventListener("pointerup", g, l.listenerOptions), s.addEventListener("pointermove", d, l.listenerOptions);
874
+ })();
875
+ };
876
+ i.addEventListener("pointerdown", u, l.listenerOptions), l.listenersToRemove.add(() => {
877
+ i.removeEventListener("pointerdown", u);
878
+ });
879
+ const f = (a) => {
880
+ a.detail >= 3 && Ne(a.target) && Me(a.target) !== null && a.preventDefault();
881
+ };
882
+ i.addEventListener("mousedown", f, l.listenerOptions), l.listenersToRemove.add(() => {
883
+ i.removeEventListener("mousedown", f);
884
+ });
885
+ const h = (a) => {
886
+ const c = a.target;
887
+ a.button === 0 && Ne(c) && t.update(() => {
888
+ const g = L();
889
+ K(g) && g.tableKey === l.tableNodeKey && r.contains(c) && l.$clearHighlight();
890
+ });
891
+ };
892
+ s.addEventListener("pointerdown", h, l.listenerOptions), l.listenersToRemove.add(() => {
893
+ s.removeEventListener("pointerdown", h);
894
+ });
895
+ for (const [a, c] of In) l.listenersToRemove.add(t.registerCommand(a, (g) => Pt(t, g, c, n, l), Ie));
896
+ l.listenersToRemove.add(t.registerCommand(hn, (a) => {
897
+ const c = L();
898
+ if (K(c)) {
899
+ const g = xe(n, c.focus.getNode());
900
+ if (g !== null) return ee(a), g.selectEnd(), !0;
901
+ }
902
+ return !1;
903
+ }, Ie));
904
+ const p = (a) => () => {
905
+ const c = L();
906
+ if (!Z(c, n)) return !1;
907
+ if (K(c)) return l.$clearText(), !0;
908
+ if ($(c)) {
909
+ if (!y(xe(n, c.anchor.getNode()))) return !1;
910
+ const g = c.anchor.getNode(), d = c.focus.getNode(), m = n.isParentOf(g), C = n.isParentOf(d);
911
+ if (m && !C || C && !m) return l.$clearText(), !0;
912
+ const S = R(c.anchor.getNode(), (b) => D(b)), N = S && R(S, (b) => D(b) && y(b.getParent()));
913
+ if (!D(N) || !D(S)) return !1;
914
+ if (a === Ot && N.getPreviousSibling() === null) return !0;
915
+ }
916
+ return !1;
917
+ };
918
+ for (const a of Jn) l.listenersToRemove.add(t.registerCommand(a, p(a), V));
919
+ const _ = (a) => {
920
+ const c = L();
921
+ if (!K(c) && !$(c)) return !1;
922
+ const g = n.isParentOf(c.anchor.getNode());
923
+ if (g !== n.isParentOf(c.focus.getNode())) {
924
+ const d = g ? "anchor" : "focus", m = g ? "focus" : "anchor", { key: C, offset: S, type: N } = c[m];
925
+ return n[c[d].isBefore(c[m]) ? "selectPrevious" : "selectNext"]()[m].set(C, S, N), !1;
926
+ }
927
+ return !!Z(c, n) && !!K(c) && (a && (a.preventDefault(), a.stopPropagation()), l.$clearText(), !0);
928
+ };
929
+ for (const a of Un) l.listenersToRemove.add(t.registerCommand(a, _, V));
930
+ return l.listenersToRemove.add(t.registerCommand(pn, (a) => {
931
+ const c = L();
932
+ if (c) {
933
+ if (!K(c) && !$(c)) return !1;
934
+ On(t, Qt(a, ClipboardEvent) ? a : null, kn(c));
935
+ const g = _(a);
936
+ return $(c) ? (c.removeText(), !0) : g;
937
+ }
938
+ return !1;
939
+ }, V)), l.listenersToRemove.add(t.registerCommand(_n, (a) => {
940
+ const c = L();
941
+ if (!Z(c, n)) return !1;
942
+ if (K(c)) return l.$formatCells(a), !0;
943
+ if ($(c)) {
944
+ const g = R(c.anchor.getNode(), (d) => y(d));
945
+ if (!y(g)) return !1;
946
+ }
947
+ return !1;
948
+ }, V)), l.listenersToRemove.add(t.registerCommand(Cn, (a) => {
949
+ const c = L();
950
+ if (!K(c) || !Z(c, n)) return !1;
951
+ const g = c.anchor.getNode(), d = c.focus.getNode();
952
+ if (!y(g) || !y(d)) return !1;
953
+ if ((function(O, z) {
954
+ if (K(O)) {
955
+ const F = O.anchor.getNode(), A = O.focus.getNode();
956
+ if (z && F && A) {
957
+ const [H] = J(z, F, A);
958
+ return F.getKey() === H[0][0].cell.getKey() && A.getKey() === H[H.length - 1].at(-1).cell.getKey();
959
+ }
960
+ }
961
+ return !1;
962
+ })(c, n)) return n.setFormat(a), !0;
963
+ const [m, C, S] = J(n, g, d), N = Math.max(C.startRow + C.cell.__rowSpan - 1, S.startRow + S.cell.__rowSpan - 1), b = Math.max(C.startColumn + C.cell.__colSpan - 1, S.startColumn + S.cell.__colSpan - 1), v = Math.min(C.startRow, S.startRow), T = Math.min(C.startColumn, S.startColumn), k = /* @__PURE__ */ new Set();
964
+ for (let O = v; O <= N; O++) for (let z = T; z <= b; z++) {
965
+ const F = m[O][z].cell;
966
+ if (k.has(F)) continue;
967
+ k.add(F), F.setFormat(a);
968
+ const A = F.getChildren();
969
+ for (let H = 0; H < A.length; H++) {
970
+ const B = A[H];
971
+ D(B) && !B.isInline() && B.setFormat(a);
972
+ }
973
+ }
974
+ return !0;
975
+ }, V)), l.listenersToRemove.add(t.registerCommand(Sn, (a) => {
976
+ const c = L();
977
+ if (!Z(c, n)) return !1;
978
+ if (K(c)) return l.$clearHighlight(), !1;
979
+ if ($(c)) {
980
+ const g = R(c.anchor.getNode(), (d) => y(d));
981
+ if (!y(g)) return !1;
982
+ if (typeof a == "string") {
983
+ const d = xt(t, c, n);
984
+ if (d) return vt(d, n, [ot(a)]), !0;
985
+ }
986
+ }
987
+ return !1;
988
+ }, V)), o && l.listenersToRemove.add(t.registerCommand(wn, (a) => {
989
+ const c = L();
990
+ if (!$(c) || !c.isCollapsed() || !Z(c, n)) return !1;
991
+ const g = be(c.anchor.getNode());
992
+ return !(g === null || !n.is(_e(g))) && (ee(a), (function(d, m) {
993
+ const C = m === "next" ? "getNextSibling" : "getPreviousSibling", S = m === "next" ? "getFirstChild" : "getLastChild", N = d[C]();
994
+ if (D(N)) return N.selectEnd();
995
+ const b = R(d, E);
996
+ b === null && w(247);
997
+ for (let T = b[C](); E(T); T = T[C]()) {
998
+ const k = T[S]();
999
+ if (D(k)) return k.selectEnd();
1000
+ }
1001
+ const v = R(b, M);
1002
+ v === null && w(248), m === "next" ? v.selectNext() : v.selectPrevious();
1003
+ })(g, a.shiftKey ? "previous" : "next"), !0);
1004
+ }, V)), l.listenersToRemove.add(t.registerCommand(yn, (a) => n.isSelected(), Ie)), l.listenersToRemove.add(t.registerCommand(At, (a, c) => {
1005
+ if (t !== c) return !1;
1006
+ const { nodes: g, selection: d } = a, m = d.getStartEndPoints(), C = K(d), S = $(d) && R(d.anchor.getNode(), (x) => y(x)) !== null && R(d.focus.getNode(), (x) => y(x)) !== null || C;
1007
+ if (g.length !== 1 || !M(g[0]) || !S || m === null) return !1;
1008
+ const [N, b] = m, [v, T, k] = I(N), O = R(b.getNode(), (x) => y(x));
1009
+ if (!(y(v) && y(O) && E(T) && M(k))) return !1;
1010
+ const z = g[0], [F, A, H] = J(k, v, O), [B] = oe(z, null, null), te = F.length, Se = te > 0 ? F[0].length : 0;
1011
+ let q = A.startRow, P = A.startColumn, le = B.length, he = le > 0 ? B[0].length : 0;
1012
+ if (C) {
1013
+ const x = Ee(F, A, H), X = x.maxRow - x.minRow + 1, j = x.maxColumn - x.minColumn + 1;
1014
+ q = x.minRow, P = x.minColumn, le = Math.min(le, X), he = Math.min(he, j);
1015
+ }
1016
+ let Le = !1;
1017
+ const Bt = Math.min(te, q + le) - 1, Dt = Math.min(Se, P + he) - 1, ut = /* @__PURE__ */ new Set();
1018
+ for (let x = q; x <= Bt; x++) for (let X = P; X <= Dt; X++) {
1019
+ const j = F[x][X];
1020
+ ut.has(j.cell.getKey()) || j.cell.__rowSpan === 1 && j.cell.__colSpan === 1 || (Hn(j.cell), ut.add(j.cell.getKey()), Le = !0);
1021
+ }
1022
+ let [we] = oe(k.getWritable(), null, null);
1023
+ const It = le - te + q;
1024
+ for (let x = 0; x < It; x++)
1025
+ qe(we[te - 1][0].cell);
1026
+ const Jt = he - Se + P;
1027
+ for (let x = 0; x < Jt; x++)
1028
+ je(we[0][Se - 1].cell, !0, !1);
1029
+ [we] = oe(k.getWritable(), null, null);
1030
+ for (let x = q; x < q + le; x++) for (let X = P; X < P + he; X++) {
1031
+ const j = x - q, ht = X - P, We = B[j][ht];
1032
+ if (We.startRow !== j || We.startColumn !== ht) continue;
1033
+ const ye = We.cell;
1034
+ if (ye.__rowSpan !== 1 || ye.__colSpan !== 1) {
1035
+ const G = [], Xt = Math.min(x + ye.__rowSpan, q + le) - 1, Yt = Math.min(X + ye.__colSpan, P + he) - 1;
1036
+ for (let Pe = x; Pe <= Xt; Pe++) for (let Be = X; Be <= Yt; Be++) {
1037
+ const qt = we[Pe][Be];
1038
+ G.push(qt.cell);
1039
+ }
1040
+ Ln(G), Le = !0;
1041
+ }
1042
+ const { cell: He } = we[x][X], Ut = He.getChildren();
1043
+ ye.getChildren().forEach((G) => {
1044
+ Ce(G) && U().append(G), He.append(G);
1045
+ }), Ut.forEach((G) => G.remove());
1046
+ }
1047
+ if (C && Le) {
1048
+ const [x] = oe(k.getWritable(), null, null);
1049
+ x[A.startRow][A.startColumn].cell.selectEnd();
1050
+ }
1051
+ return !0;
1052
+ }, V)), l.listenersToRemove.add(t.registerCommand(ge, () => {
1053
+ const a = L(), c = Ue(), g = l.getAndClearNextFocus();
1054
+ if (g !== null) {
1055
+ const { focusCell: d } = g;
1056
+ if (K(a) && a.tableKey === l.tableNodeKey) return (d.x !== l.focusX || d.y !== l.focusY) && (l.$setFocusCellForSelection(d), !0);
1057
+ if (d !== l.anchorCell && Z(a, n)) return l.$setFocusCellForSelection(d), !0;
1058
+ }
1059
+ if (l.getAndClearShouldCheckSelection() && $(c) && $(a) && a.isCollapsed()) {
1060
+ const d = a.anchor.getNode(), m = n.getFirstChild(), C = be(d);
1061
+ if (C !== null && E(m)) {
1062
+ const S = m.getFirstChild();
1063
+ if (y(S) && n.is(R(C, (N) => N.is(n) || N.is(S)))) return S.selectStart(), !0;
1064
+ }
1065
+ }
1066
+ if ($(a)) {
1067
+ const { anchor: d, focus: m } = a, C = d.getNode(), S = m.getNode(), N = be(C), b = be(S), v = !(!N || !n.is(_e(N))), T = !(!b || !n.is(_e(b))), k = v !== T, O = v && T, z = a.isBackward();
1068
+ if (k) {
1069
+ const F = a.clone();
1070
+ if (T) {
1071
+ const [A] = J(n, b, b), H = A[0][0].cell, B = A[A.length - 1].at(-1).cell;
1072
+ F.focus.set(z ? H.getKey() : B.getKey(), z ? H.getChildrenSize() : B.getChildrenSize(), "element");
1073
+ } else if (v) {
1074
+ const [A] = J(n, N, N), H = A[0][0].cell, B = A[A.length - 1].at(-1).cell;
1075
+ F.anchor.set(z ? B.getKey() : H.getKey(), z ? B.getChildrenSize() : 0, "element");
1076
+ }
1077
+ ne(F), Nt(t, l);
1078
+ } else if (O && (N.is(b) || (l.$setAnchorCellForSelection(se(l, N)), l.$setFocusCellForSelection(se(l, b), !0)), l.pointerType === "touch" && l.isSelecting && a.isCollapsed() && $(c) && c.isCollapsed())) {
1079
+ const F = be(c.anchor.getNode());
1080
+ F && !F.is(b) && (l.$setAnchorCellForSelection(se(l, F)), l.$setFocusCellForSelection(se(l, b), !0), l.pointerType = null);
1081
+ }
1082
+ } else if (a && K(a) && a.is(c) && a.tableKey === n.getKey()) {
1083
+ const d = $e(s);
1084
+ if (d && d.anchorNode && d.focusNode) {
1085
+ const m = re(d.focusNode), C = m && !n.isParentOf(m), S = re(d.anchorNode), N = S && n.isParentOf(S);
1086
+ if (C && N && d.rangeCount > 0) {
1087
+ const b = bn(d, t);
1088
+ b && (b.anchor.set(n.getKey(), a.isBackward() ? n.getChildrenSize() : 0, "element"), d.removeAllRanges(), ne(b));
1089
+ }
1090
+ }
1091
+ }
1092
+ return a && !a.is(c) && (K(a) || K(c)) && l.tableSelection && !l.tableSelection.is(c) ? (K(a) && a.tableKey === l.tableNodeKey ? l.$updateTableTableSelection(a) : !K(a) && K(c) && c.tableKey === l.tableNodeKey && l.$updateTableTableSelection(null), !1) : (l.hasHijackedSelectionStyles && !n.isSelected() ? (function(d, m) {
1093
+ m.$enableHighlightStyle(), at(m.table, (C) => {
1094
+ const S = C.elem;
1095
+ C.highlighted = !1, Ht(d, C), S.getAttribute("style") || S.removeAttribute("style");
1096
+ });
1097
+ })(t, l) : !l.hasHijackedSelectionStyles && n.isSelected() && Nt(t, l), !1);
1098
+ }, V)), l.listenersToRemove.add(t.registerCommand(kt, () => {
1099
+ const a = L();
1100
+ if (!$(a) || !a.isCollapsed() || !Z(a, n)) return !1;
1101
+ const c = xt(t, a, n);
1102
+ return !!c && (vt(c, n), !0);
1103
+ }, V)), l;
1104
+ }
1105
+ function yt(n) {
1106
+ return n[Ze] || null;
1107
+ }
1108
+ function Me(n) {
1109
+ let e = n;
1110
+ for (; e != null; ) {
1111
+ const t = e.nodeName;
1112
+ if (t === "TD" || t === "TH") {
1113
+ const o = e._cell;
1114
+ return o === void 0 ? null : o;
1115
+ }
1116
+ e = e.parentNode;
1117
+ }
1118
+ return null;
1119
+ }
1120
+ function bt(n, e) {
1121
+ if (!n.contains(e)) return null;
1122
+ let t = null;
1123
+ for (let o = e; o != null; o = o.parentNode) {
1124
+ if (o === n) return t;
1125
+ const r = o.nodeName;
1126
+ r !== "TD" && r !== "TH" || (t = o._cell || null);
1127
+ }
1128
+ return null;
1129
+ }
1130
+ function pe(n, e) {
1131
+ const t = [], o = { columns: 0, domRows: t, rows: 0 };
1132
+ let r = ae(n, e).querySelector("tr"), s = 0, l = 0;
1133
+ for (t.length = 0; r != null; ) {
1134
+ const i = r.nodeName;
1135
+ if (i === "TD" || i === "TH") {
1136
+ const h = { elem: r, hasBackgroundColor: r.style.backgroundColor !== "", highlighted: !1, x: s, y: l };
1137
+ r._cell = h;
1138
+ let p = t[l];
1139
+ p === void 0 && (p = t[l] = []), p[s] = h;
1140
+ } else {
1141
+ const h = r.firstChild;
1142
+ if (h != null) {
1143
+ r = h;
1144
+ continue;
1145
+ }
1146
+ }
1147
+ const u = r.nextSibling;
1148
+ if (u != null) {
1149
+ s++, r = u;
1150
+ continue;
1151
+ }
1152
+ const f = r.parentNode;
1153
+ if (f != null) {
1154
+ const h = f.nextSibling;
1155
+ if (h == null) break;
1156
+ l++, s = 0, r = h;
1157
+ }
1158
+ }
1159
+ return o.columns = s + 1, o.rows = l + 1, o;
1160
+ }
1161
+ function Ke(n, e, t) {
1162
+ const o = new Set(t ? t.getNodes() : []);
1163
+ at(e, (r, s) => {
1164
+ const l = r.elem;
1165
+ o.has(s) ? (r.highlighted = !0, Wt(n, r)) : (r.highlighted = !1, Ht(n, r), l.getAttribute("style") || l.removeAttribute("style"));
1166
+ });
1167
+ }
1168
+ function at(n, e) {
1169
+ const { domRows: t } = n;
1170
+ for (let o = 0; o < t.length; o++) {
1171
+ const r = t[o];
1172
+ if (r) for (let s = 0; s < r.length; s++) {
1173
+ const l = r[s];
1174
+ if (!l) continue;
1175
+ const i = re(l.elem);
1176
+ i !== null && e(l, i, { x: s, y: o });
1177
+ }
1178
+ }
1179
+ }
1180
+ function Nt(n, e) {
1181
+ e.$disableHighlightStyle(), at(e.table, (t) => {
1182
+ t.highlighted = !0, Wt(n, t);
1183
+ });
1184
+ }
1185
+ const Yn = (n, e, t, o, r) => {
1186
+ const s = r === "forward";
1187
+ switch (r) {
1188
+ case "backward":
1189
+ case "forward":
1190
+ return t !== (s ? n.table.columns - 1 : 0) ? Oe(e.getCellNodeFromCordsOrThrow(t + (s ? 1 : -1), o, n.table), s) : o !== (s ? n.table.rows - 1 : 0) ? Oe(e.getCellNodeFromCordsOrThrow(s ? 0 : n.table.columns - 1, o + (s ? 1 : -1), n.table), s) : s ? e.selectNext() : e.selectPrevious(), !0;
1191
+ case "up":
1192
+ return o !== 0 ? Oe(e.getCellNodeFromCordsOrThrow(t, o - 1, n.table), !1) : e.selectPrevious(), !0;
1193
+ case "down":
1194
+ return o !== n.table.rows - 1 ? Oe(e.getCellNodeFromCordsOrThrow(t, o + 1, n.table), !0) : e.selectNext(), !0;
1195
+ default:
1196
+ return !1;
1197
+ }
1198
+ };
1199
+ function Je(n, e) {
1200
+ let t, o;
1201
+ if (e.startColumn === n.minColumn) t = "minColumn";
1202
+ else {
1203
+ if (e.startColumn + e.cell.__colSpan - 1 !== n.maxColumn) return null;
1204
+ t = "maxColumn";
1205
+ }
1206
+ if (e.startRow === n.minRow) o = "minRow";
1207
+ else {
1208
+ if (e.startRow + e.cell.__rowSpan - 1 !== n.maxRow) return null;
1209
+ o = "maxRow";
1210
+ }
1211
+ return [t, o];
1212
+ }
1213
+ function Ae([n, e]) {
1214
+ return [n === "minColumn" ? "maxColumn" : "minColumn", e === "minRow" ? "maxRow" : "minRow"];
1215
+ }
1216
+ function de(n, e, [t, o]) {
1217
+ const r = e[o], s = n[r];
1218
+ s === void 0 && w(250, o, String(r));
1219
+ const l = e[t], i = s[l];
1220
+ return i === void 0 && w(250, t, String(l)), i;
1221
+ }
1222
+ function qn(n, e, t, o, r) {
1223
+ const s = Ee(e, t, o), l = (function(v, T) {
1224
+ const { minColumn: k, maxColumn: O, minRow: z, maxRow: F } = T;
1225
+ let A = 1, H = 1, B = 1, te = 1;
1226
+ const Se = v[z], q = v[F];
1227
+ for (let P = k; P <= O; P++) A = Math.max(A, Se[P].cell.__rowSpan), te = Math.max(te, q[P].cell.__rowSpan);
1228
+ for (let P = z; P <= F; P++) H = Math.max(H, v[P][k].cell.__colSpan), B = Math.max(B, v[P][O].cell.__colSpan);
1229
+ return { bottomSpan: te, leftSpan: H, rightSpan: B, topSpan: A };
1230
+ })(e, s), { topSpan: i, leftSpan: u, bottomSpan: f, rightSpan: h } = l, p = (function(v, T) {
1231
+ const k = Je(v, T);
1232
+ return k === null && w(249, T.cell.getKey()), k;
1233
+ })(s, t), [_, a] = Ae(p);
1234
+ let c = s[_], g = s[a];
1235
+ r === "forward" ? c += _ === "maxColumn" ? 1 : u : r === "backward" ? c -= _ === "minColumn" ? 1 : h : r === "down" ? g += a === "maxRow" ? 1 : i : r === "up" && (g -= a === "minRow" ? 1 : f);
1236
+ const d = e[g];
1237
+ if (d === void 0) return !1;
1238
+ const m = d[c];
1239
+ if (m === void 0) return !1;
1240
+ const [C, S] = (function(v, T, k) {
1241
+ const O = Ee(v, T, k), z = Je(O, T);
1242
+ if (z) return [de(v, O, z), de(v, O, Ae(z))];
1243
+ const F = Je(O, k);
1244
+ if (F) return [de(v, O, Ae(F)), de(v, O, F)];
1245
+ const A = ["minColumn", "minRow"];
1246
+ return [de(v, O, A), de(v, O, Ae(A))];
1247
+ })(e, t, m), N = se(n, C.cell), b = se(n, S.cell);
1248
+ return n.$setAnchorCellForSelection(N), n.$setFocusCellForSelection(b, !0), !0;
1249
+ }
1250
+ function Z(n, e) {
1251
+ if ($(n) || K(n)) {
1252
+ const t = e.isParentOf(n.anchor.getNode()), o = e.isParentOf(n.focus.getNode());
1253
+ return t && o;
1254
+ }
1255
+ return !1;
1256
+ }
1257
+ function Oe(n, e) {
1258
+ e ? n.selectStart() : n.selectEnd();
1259
+ }
1260
+ function Wt(n, e) {
1261
+ const t = e.elem, o = n._config.theme;
1262
+ y(re(t)) || w(131), Q(t, o.tableCellSelected);
1263
+ }
1264
+ function Ht(n, e) {
1265
+ const t = e.elem;
1266
+ y(re(t)) || w(131);
1267
+ const o = n._config.theme;
1268
+ me(t, o.tableCellSelected);
1269
+ }
1270
+ function be(n) {
1271
+ const e = R(n, y);
1272
+ return y(e) ? e : null;
1273
+ }
1274
+ function _e(n) {
1275
+ const e = R(n, M);
1276
+ return M(e) ? e : null;
1277
+ }
1278
+ function jn(n, e, t, o, r, s, l) {
1279
+ const i = Rn(t.focus, r ? "previous" : "next");
1280
+ if (Tn(i)) return !1;
1281
+ let u = i;
1282
+ for (const d of ft(i).iterNodeCarets("shadowRoot")) {
1283
+ if (!Fn(d) || !D(d.origin)) return !1;
1284
+ u = d;
1285
+ }
1286
+ const f = u.getParentAtCaret();
1287
+ if (!y(f)) return !1;
1288
+ const h = f, p = (function(d) {
1289
+ for (const m of ft(d).iterNodeCarets("root")) {
1290
+ const { origin: C } = m;
1291
+ if (y(C)) {
1292
+ if (gt(m)) return Kn(C, d.direction);
1293
+ } else if (!E(C)) break;
1294
+ }
1295
+ return null;
1296
+ })(mt(h, u.direction)), _ = R(h, M);
1297
+ if (!_ || !_.is(s)) return !1;
1298
+ const a = n.getElementByKey(h.getKey()), c = Me(a);
1299
+ if (!a || !c) return !1;
1300
+ const g = Vn(n, _);
1301
+ if (l.table = g, p) if (o === "extend") {
1302
+ const d = Me(n.getElementByKey(p.origin.getKey()));
1303
+ if (!d) return !1;
1304
+ l.$setAnchorCellForSelection(c), l.$setFocusCellForSelection(d, !0);
1305
+ } else {
1306
+ const d = pt(p);
1307
+ Fe(t.anchor, d), Fe(t.focus, d);
1308
+ }
1309
+ else if (o === "extend") l.$setAnchorCellForSelection(c), l.$setFocusCellForSelection(c, !0);
1310
+ else {
1311
+ const d = (function(m) {
1312
+ const C = An(m);
1313
+ return gt(C) ? pt(C) : m;
1314
+ })(mt(_, i.direction));
1315
+ Fe(t.anchor, d), Fe(t.focus, d);
1316
+ }
1317
+ return ee(e), !0;
1318
+ }
1319
+ function Pt(n, e, t, o, r) {
1320
+ if ((t === "up" || t === "down") && (function(l) {
1321
+ const i = l.getRootElement();
1322
+ return i ? i.hasAttribute("aria-controls") && i.getAttribute("aria-controls") === "typeahead-menu" : !1;
1323
+ })(n)) return !1;
1324
+ const s = L();
1325
+ if (!Z(s, o)) {
1326
+ if ($(s)) {
1327
+ if (t === "backward") {
1328
+ if (s.focus.offset > 0) return !1;
1329
+ const l = (function(u) {
1330
+ for (let f = u, h = u; h !== null; f = h, h = h.getParent()) if (D(h)) {
1331
+ if (h !== f && h.getFirstChild() !== f) return null;
1332
+ if (!h.isInline()) return h;
1333
+ }
1334
+ return null;
1335
+ })(s.focus.getNode());
1336
+ if (!l) return !1;
1337
+ const i = l.getPreviousSibling();
1338
+ return !!M(i) && (ee(e), e.shiftKey ? s.focus.set(i.getParentOrThrow().getKey(), i.getIndexWithinParent(), "element") : i.selectEnd(), !0);
1339
+ }
1340
+ if (e.shiftKey && (t === "up" || t === "down")) {
1341
+ const l = s.focus.getNode();
1342
+ if (!s.isCollapsed() && (t === "up" && !s.isBackward() || t === "down" && s.isBackward())) {
1343
+ let i = R(l, (_) => M(_));
1344
+ if (y(i) && (i = R(i, M)), i !== o || !i) return !1;
1345
+ const u = t === "down" ? i.getNextSibling() : i.getPreviousSibling();
1346
+ if (!u) return !1;
1347
+ let f = 0;
1348
+ t === "up" && D(u) && (f = u.getChildrenSize());
1349
+ let h = u;
1350
+ t === "up" && D(u) && (h = u.getLastChild() || u, f = Ce(h) ? h.getTextContentSize() : 0);
1351
+ const p = s.clone();
1352
+ return p.focus.set(h.getKey(), f, Ce(h) ? "text" : "element"), ne(p), ee(e), !0;
1353
+ }
1354
+ if (xn(l)) {
1355
+ const i = t === "up" ? s.getNodes()[s.getNodes().length - 1] : s.getNodes()[0];
1356
+ if (i && xe(o, i) !== null) {
1357
+ const u = o.getFirstDescendant(), f = o.getLastDescendant();
1358
+ if (!u || !f) return !1;
1359
+ const [h] = I(u), [p] = I(f), _ = o.getCordsFromCellNode(h, r.table), a = o.getCordsFromCellNode(p, r.table), c = o.getDOMCellFromCordsOrThrow(_.x, _.y, r.table), g = o.getDOMCellFromCordsOrThrow(a.x, a.y, r.table);
1360
+ return r.$setAnchorCellForSelection(c), r.$setFocusCellForSelection(g, !0), !0;
1361
+ }
1362
+ return !1;
1363
+ }
1364
+ {
1365
+ let i = R(l, (f) => D(f) && !f.isInline());
1366
+ if (y(i) && (i = R(i, M)), !i) return !1;
1367
+ const u = t === "down" ? i.getNextSibling() : i.getPreviousSibling();
1368
+ if (M(u) && r.tableNodeKey === u.getKey()) {
1369
+ const f = u.getFirstDescendant(), h = u.getLastDescendant();
1370
+ if (!f || !h) return !1;
1371
+ const [p] = I(f), [_] = I(h), a = s.clone();
1372
+ return a.focus.set((t === "up" ? p : _).getKey(), t === "up" ? 0 : _.getChildrenSize(), "element"), ee(e), ne(a), !0;
1373
+ }
1374
+ }
1375
+ }
1376
+ }
1377
+ return t === "down" && et(n) && r.setShouldCheckSelection(), !1;
1378
+ }
1379
+ if ($(s)) {
1380
+ if (t === "backward" || t === "forward")
1381
+ return jn(n, e, s, e.shiftKey ? "extend" : "move", t === "backward", o, r);
1382
+ if (s.isCollapsed()) {
1383
+ const { anchor: l, focus: i } = s, u = R(l.getNode(), y), f = R(i.getNode(), y);
1384
+ if (!y(u) || !u.is(f)) return !1;
1385
+ const h = _e(u);
1386
+ if (h !== o && h != null) {
1387
+ const m = ae(h, n.getElementByKey(h.getKey()));
1388
+ if (m != null) return r.table = pe(h, m), Pt(n, e, t, h, r);
1389
+ }
1390
+ const p = n.getElementByKey(u.__key), _ = n.getElementByKey(l.key);
1391
+ if (_ == null || p == null) return !1;
1392
+ let a;
1393
+ if (l.type === "element") a = _.getBoundingClientRect();
1394
+ else {
1395
+ const m = $e(it(n));
1396
+ if (m === null || m.rangeCount === 0) return !1;
1397
+ a = m.getRangeAt(0).getBoundingClientRect();
1398
+ }
1399
+ const c = t === "up" ? u.getFirstChild() : u.getLastChild();
1400
+ if (c == null) return !1;
1401
+ const g = n.getElementByKey(c.__key);
1402
+ if (g == null) return !1;
1403
+ const d = g.getBoundingClientRect();
1404
+ if (t === "up" ? d.top > a.top - a.height : a.bottom + a.height > d.bottom) {
1405
+ ee(e);
1406
+ const m = o.getCordsFromCellNode(u, r.table);
1407
+ if (!e.shiftKey) return Yn(r, o, m.x, m.y, t);
1408
+ {
1409
+ const C = o.getDOMCellFromCordsOrThrow(m.x, m.y, r.table);
1410
+ r.$setAnchorCellForSelection(C), r.$setFocusCellForSelection(C, !0);
1411
+ }
1412
+ return !0;
1413
+ }
1414
+ }
1415
+ } else if (K(s)) {
1416
+ const { anchor: l, focus: i } = s, u = R(l.getNode(), y), f = R(i.getNode(), y), [h] = s.getNodes();
1417
+ M(h) || w(251);
1418
+ const p = ae(h, n.getElementByKey(h.getKey()));
1419
+ if (!y(u) || !y(f) || !M(h) || p == null) return !1;
1420
+ r.$updateTableTableSelection(s);
1421
+ const _ = pe(h, p), a = o.getCordsFromCellNode(u, _), c = o.getDOMCellFromCordsOrThrow(a.x, a.y, _);
1422
+ if (r.$setAnchorCellForSelection(c), ee(e), e.shiftKey) {
1423
+ const [g, d, m] = J(o, u, f);
1424
+ return qn(r, g, d, m, t);
1425
+ }
1426
+ return f.selectEnd(), !0;
1427
+ }
1428
+ return !1;
1429
+ }
1430
+ function ee(n) {
1431
+ n.preventDefault(), n.stopImmediatePropagation(), n.stopPropagation();
1432
+ }
1433
+ function vt(n, e, t) {
1434
+ const o = U();
1435
+ n === "first" ? e.insertBefore(o) : e.insertAfter(o), o.append(...t || []), o.selectEnd();
1436
+ }
1437
+ function xt(n, e, t) {
1438
+ const o = t.getParent();
1439
+ if (!o) return;
1440
+ const r = $e(it(n));
1441
+ if (!r) return;
1442
+ const s = r.anchorNode, l = n.getElementByKey(o.getKey()), i = ae(t, n.getElementByKey(t.getKey()));
1443
+ if (!s || !l || !i || !l.contains(s) || i.contains(s)) return;
1444
+ const u = R(e.anchor.getNode(), (C) => y(C));
1445
+ if (!u) return;
1446
+ const f = R(u, (C) => M(C));
1447
+ if (!M(f) || !f.is(t)) return;
1448
+ const [h, p] = J(t, u, u), _ = h[0][0], a = h[h.length - 1][h[0].length - 1], { startRow: c, startColumn: g } = p, d = c === _.startRow && g === _.startColumn, m = c === a.startRow && g === a.startColumn;
1449
+ return d ? "first" : m ? "last" : void 0;
1450
+ }
1451
+ function se(n, e) {
1452
+ const { tableNode: t } = n.$lookup(), o = t.getCordsFromCellNode(e, n.table);
1453
+ return t.getDOMCellFromCordsOrThrow(o.x, o.y, n.table);
1454
+ }
1455
+ function Qe(n, e, t) {
1456
+ return xe(n, re(e, t));
1457
+ }
1458
+ function Rt(n, e, t) {
1459
+ if (!e.theme.tableAlignment) return;
1460
+ const o = [], r = [];
1461
+ for (const s of ["center", "right"]) {
1462
+ const l = e.theme.tableAlignment[s];
1463
+ l && (s === t ? r : o).push(l);
1464
+ }
1465
+ me(n, ...o), Q(n, ...r);
1466
+ }
1467
+ const Ge = /* @__PURE__ */ new WeakSet();
1468
+ function et(n = Kt()) {
1469
+ return Ge.has(n);
1470
+ }
1471
+ function fo(n, e) {
1472
+ e ? Ge.add(n) : Ge.delete(n);
1473
+ }
1474
+ class ce extends tt {
1475
+ __rowStriping;
1476
+ __frozenColumnCount;
1477
+ __frozenRowCount;
1478
+ __colWidths;
1479
+ static getType() {
1480
+ return "table";
1481
+ }
1482
+ getColWidths() {
1483
+ return this.getLatest().__colWidths;
1484
+ }
1485
+ setColWidths(e) {
1486
+ const t = this.getWritable();
1487
+ return t.__colWidths = e, t;
1488
+ }
1489
+ static clone(e) {
1490
+ return new ce(e.__key);
1491
+ }
1492
+ afterCloneFrom(e) {
1493
+ super.afterCloneFrom(e), this.__colWidths = e.__colWidths, this.__rowStriping = e.__rowStriping, this.__frozenColumnCount = e.__frozenColumnCount, this.__frozenRowCount = e.__frozenRowCount;
1494
+ }
1495
+ static importDOM() {
1496
+ return { table: (e) => ({ conversion: Zn, priority: 1 }) };
1497
+ }
1498
+ static importJSON(e) {
1499
+ return ct().updateFromJSON(e);
1500
+ }
1501
+ updateFromJSON(e) {
1502
+ return super.updateFromJSON(e).setRowStriping(e.rowStriping || !1).setFrozenColumns(e.frozenColumnCount || 0).setFrozenRows(e.frozenRowCount || 0).setColWidths(e.colWidths);
1503
+ }
1504
+ constructor(e) {
1505
+ super(e), this.__rowStriping = !1, this.__frozenColumnCount = 0, this.__frozenRowCount = 0;
1506
+ }
1507
+ exportJSON() {
1508
+ return { ...super.exportJSON(), colWidths: this.getColWidths(), frozenColumnCount: this.__frozenColumnCount ? this.__frozenColumnCount : void 0, frozenRowCount: this.__frozenRowCount ? this.__frozenRowCount : void 0, rowStriping: this.__rowStriping ? this.__rowStriping : void 0 };
1509
+ }
1510
+ extractWithChild(e, t, o) {
1511
+ return o === "html";
1512
+ }
1513
+ getDOMSlot(e) {
1514
+ const t = fe(e) ? e : e.querySelector("table");
1515
+ return fe(t) || w(229), super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"));
1516
+ }
1517
+ createDOM(e, t) {
1518
+ const o = document.createElement("table");
1519
+ this.__style && (o.style.cssText = this.__style);
1520
+ const r = document.createElement("colgroup");
1521
+ if (o.appendChild(r), en(r), Q(o, e.theme.table), this.updateTableElement(null, o, e), et(t)) {
1522
+ const s = document.createElement("div"), l = e.theme.tableScrollableWrapper;
1523
+ return l ? Q(s, l) : s.style.cssText = "overflow-x: auto;", s.appendChild(o), this.updateTableWrapper(null, s, o, e), s;
1524
+ }
1525
+ return o;
1526
+ }
1527
+ updateTableWrapper(e, t, o, r) {
1528
+ this.__frozenColumnCount !== (e ? e.__frozenColumnCount : 0) && (function(s, l, i, u) {
1529
+ u > 0 ? (Q(s, i.theme.tableFrozenColumn), l.setAttribute("data-lexical-frozen-column", "true")) : (me(s, i.theme.tableFrozenColumn), l.removeAttribute("data-lexical-frozen-column"));
1530
+ })(t, o, r, this.__frozenColumnCount), this.__frozenRowCount !== (e ? e.__frozenRowCount : 0) && (function(s, l, i, u) {
1531
+ u > 0 ? (Q(s, i.theme.tableFrozenRow), l.setAttribute("data-lexical-frozen-row", "true")) : (me(s, i.theme.tableFrozenRow), l.removeAttribute("data-lexical-frozen-row"));
1532
+ })(t, o, r, this.__frozenRowCount);
1533
+ }
1534
+ updateTableElement(e, t, o) {
1535
+ this.__style !== (e ? e.__style : "") && (t.style.cssText = this.__style), this.__rowStriping !== (!!e && e.__rowStriping) && (function(r, s, l) {
1536
+ l ? (Q(r, s.theme.tableRowStriping), r.setAttribute("data-lexical-row-striping", "true")) : (me(r, s.theme.tableRowStriping), r.removeAttribute("data-lexical-row-striping"));
1537
+ })(t, o, this.__rowStriping), (function(r, s, l, i) {
1538
+ const u = r.querySelector("colgroup");
1539
+ if (!u) return;
1540
+ const f = [];
1541
+ for (let h = 0; h < l; h++) {
1542
+ const p = document.createElement("col"), _ = i && i[h];
1543
+ _ && (p.style.width = `${_}px`), f.push(p);
1544
+ }
1545
+ u.replaceChildren(...f);
1546
+ })(t, 0, this.getColumnCount(), this.getColWidths()), Rt(t, o, this.getFormatType());
1547
+ }
1548
+ updateDOM(e, t, o) {
1549
+ const r = this.getDOMSlot(t).element;
1550
+ return t === r === et() || (ve(s = t) && s.nodeName === "DIV" && this.updateTableWrapper(e, t, r, o), this.updateTableElement(e, r, o), !1);
1551
+ var s;
1552
+ }
1553
+ exportDOM(e) {
1554
+ const t = super.exportDOM(e), { element: o } = t;
1555
+ return { after: (r) => {
1556
+ if (t.after && (r = t.after(r)), !fe(r) && ve(r) && (r = r.querySelector("table")), !fe(r)) return null;
1557
+ Rt(r, e._config, this.getFormatType());
1558
+ const [s] = oe(this, null, null), l = /* @__PURE__ */ new Map();
1559
+ for (const h of s) for (const p of h) {
1560
+ const _ = p.cell.getKey();
1561
+ l.has(_) || l.set(_, { colSpan: p.cell.getColSpan(), startColumn: p.startColumn });
1562
+ }
1563
+ const i = /* @__PURE__ */ new Set();
1564
+ for (const h of r.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")) {
1565
+ const p = h.getAttribute("data-temporary-table-cell-lexical-key");
1566
+ if (p) {
1567
+ const _ = l.get(p);
1568
+ if (h.removeAttribute("data-temporary-table-cell-lexical-key"), _) {
1569
+ l.delete(p);
1570
+ for (let a = 0; a < _.colSpan; a++) i.add(a + _.startColumn);
1571
+ }
1572
+ }
1573
+ }
1574
+ const u = r.querySelector(":scope > colgroup");
1575
+ if (u) {
1576
+ const h = Array.from(r.querySelectorAll(":scope > colgroup > col")).filter((p, _) => i.has(_));
1577
+ u.replaceChildren(...h);
1578
+ }
1579
+ const f = r.querySelectorAll(":scope > tr");
1580
+ if (f.length > 0) {
1581
+ const h = document.createElement("tbody");
1582
+ for (const p of f) h.appendChild(p);
1583
+ r.append(h);
1584
+ }
1585
+ return r;
1586
+ }, element: !fe(o) && ve(o) ? o.querySelector("table") : o };
1587
+ }
1588
+ canBeEmpty() {
1589
+ return !1;
1590
+ }
1591
+ isShadowRoot() {
1592
+ return !0;
1593
+ }
1594
+ getCordsFromCellNode(e, t) {
1595
+ const { rows: o, domRows: r } = t;
1596
+ for (let s = 0; s < o; s++) {
1597
+ const l = r[s];
1598
+ if (l != null) for (let i = 0; i < l.length; i++) {
1599
+ const u = l[i];
1600
+ if (u == null) continue;
1601
+ const { elem: f } = u, h = Qe(this, f);
1602
+ if (h !== null && e.is(h)) return { x: i, y: s };
1603
+ }
1604
+ }
1605
+ throw new Error("Cell not found in table.");
1606
+ }
1607
+ getDOMCellFromCords(e, t, o) {
1608
+ const { domRows: r } = o, s = r[t];
1609
+ if (s == null) return null;
1610
+ const l = s[e < s.length ? e : s.length - 1];
1611
+ return l ?? null;
1612
+ }
1613
+ getDOMCellFromCordsOrThrow(e, t, o) {
1614
+ const r = this.getDOMCellFromCords(e, t, o);
1615
+ if (!r) throw new Error("Cell not found at cords.");
1616
+ return r;
1617
+ }
1618
+ getCellNodeFromCords(e, t, o) {
1619
+ const r = this.getDOMCellFromCords(e, t, o);
1620
+ if (r == null) return null;
1621
+ const s = re(r.elem);
1622
+ return y(s) ? s : null;
1623
+ }
1624
+ getCellNodeFromCordsOrThrow(e, t, o) {
1625
+ const r = this.getCellNodeFromCords(e, t, o);
1626
+ if (!r) throw new Error("Node at cords not TableCellNode.");
1627
+ return r;
1628
+ }
1629
+ getRowStriping() {
1630
+ return !!this.getLatest().__rowStriping;
1631
+ }
1632
+ setRowStriping(e) {
1633
+ const t = this.getWritable();
1634
+ return t.__rowStriping = e, t;
1635
+ }
1636
+ setFrozenColumns(e) {
1637
+ const t = this.getWritable();
1638
+ return t.__frozenColumnCount = e, t;
1639
+ }
1640
+ getFrozenColumns() {
1641
+ return this.getLatest().__frozenColumnCount;
1642
+ }
1643
+ setFrozenRows(e) {
1644
+ const t = this.getWritable();
1645
+ return t.__frozenRowCount = e, t;
1646
+ }
1647
+ getFrozenRows() {
1648
+ return this.getLatest().__frozenRowCount;
1649
+ }
1650
+ canSelectBefore() {
1651
+ return !0;
1652
+ }
1653
+ canIndent() {
1654
+ return !1;
1655
+ }
1656
+ getColumnCount() {
1657
+ const e = this.getFirstChild();
1658
+ if (!e) return 0;
1659
+ let t = 0;
1660
+ return e.getChildren().forEach((o) => {
1661
+ y(o) && (t += o.getColSpan());
1662
+ }), t;
1663
+ }
1664
+ }
1665
+ function Vn(n, e) {
1666
+ const t = n.getElementByKey(e.getKey());
1667
+ return t === null && w(230), pe(e, t);
1668
+ }
1669
+ function Zn(n) {
1670
+ const e = ct();
1671
+ n.hasAttribute("data-lexical-row-striping") && e.setRowStriping(!0), n.hasAttribute("data-lexical-frozen-column") && e.setFrozenColumns(1), n.hasAttribute("data-lexical-frozen-row") && e.setFrozenRows(1);
1672
+ const t = n.querySelector(":scope > colgroup");
1673
+ if (t) {
1674
+ let o = [];
1675
+ for (const r of t.querySelectorAll(":scope > col")) {
1676
+ let s = r.style.width || "";
1677
+ if (!lt.test(s) && (s = r.getAttribute("width") || "", !/^\d+$/.test(s))) {
1678
+ o = void 0;
1679
+ break;
1680
+ }
1681
+ o.push(parseFloat(s));
1682
+ }
1683
+ o && e.setColWidths(o);
1684
+ }
1685
+ return { after: (o) => Tt(o, E), node: e };
1686
+ }
1687
+ function ct() {
1688
+ return nt(new ce());
1689
+ }
1690
+ function M(n) {
1691
+ return n instanceof ce;
1692
+ }
1693
+ function Qn({ rows: n, columns: e, includeHeaders: t }) {
1694
+ const o = L() || Ue();
1695
+ if (!o || !$(o) || _e(o.anchor.getNode())) return !1;
1696
+ const r = zn(Number(n), Number(e), t);
1697
+ Zt(r);
1698
+ const s = r.getFirstDescendant();
1699
+ return Ce(s) && s.select(), !0;
1700
+ }
1701
+ function Gn(n) {
1702
+ E(n.getParent()) ? n.isEmpty() && n.append(U()) : n.remove();
1703
+ }
1704
+ function eo(n) {
1705
+ M(n.getParent()) ? Ft(n, y) : n.remove();
1706
+ }
1707
+ function to(n) {
1708
+ Ft(n, E);
1709
+ const [e] = oe(n, null, null), t = e.reduce((r, s) => Math.max(r, s.length), 0), o = n.getChildren();
1710
+ for (let r = 0; r < e.length; ++r) {
1711
+ const s = o[r];
1712
+ if (!s) continue;
1713
+ E(s) || w(254, s.constructor.name, s.getType());
1714
+ const l = e[r].reduce((i, u) => u ? 1 + i : i, 0);
1715
+ if (l !== t) for (let i = l; i < t; ++i) {
1716
+ const u = Y();
1717
+ u.append(U()), s.append(u);
1718
+ }
1719
+ }
1720
+ }
1721
+ function no(n) {
1722
+ if (n.detail < 3 || !Ne(n.target)) return !1;
1723
+ const e = re(n.target);
1724
+ if (e === null) return !1;
1725
+ const t = R(e, (o) => D(o) && !o.isInline());
1726
+ return t === null ? !1 : !!y(t.getParent()) && (t.select(0), !0);
1727
+ }
1728
+ function go(n) {
1729
+ return n.registerNodeTransform(ue, (e) => {
1730
+ if (e.getColSpan() > 1 || e.getRowSpan() > 1) {
1731
+ const [, , t] = I(e), [o] = J(t, e, e), r = o.length, s = o[0].length;
1732
+ let l = t.getFirstChild();
1733
+ E(l) || w(175);
1734
+ const i = [];
1735
+ for (let u = 0; u < r; u++) {
1736
+ u !== 0 && (l = l.getNextSibling(), E(l) || w(175));
1737
+ let f = null;
1738
+ for (let h = 0; h < s; h++) {
1739
+ const p = o[u][h], _ = p.cell;
1740
+ if (p.startRow === u && p.startColumn === h) f = _, i.push(_);
1741
+ else if (_.getColSpan() > 1 || _.getRowSpan() > 1) {
1742
+ y(_) || w(176);
1743
+ const a = Y(_.__headerState);
1744
+ f !== null ? f.insertAfter(a) : Vt(l, a);
1745
+ }
1746
+ }
1747
+ }
1748
+ for (const u of i) u.setColSpan(1), u.setRowSpan(1);
1749
+ }
1750
+ });
1751
+ }
1752
+ function mo(n, e = !0) {
1753
+ const t = /* @__PURE__ */ new Map(), o = (s, l, i) => {
1754
+ const u = ae(s, i), f = Xn(s, u, n, e);
1755
+ t.set(l, [f, u]);
1756
+ }, r = n.registerMutationListener(ce, (s) => {
1757
+ n.getEditorState().read(() => {
1758
+ for (const [l, i] of s) {
1759
+ const u = t.get(l);
1760
+ if (i === "created" || i === "updated") {
1761
+ const { tableNode: f, tableElement: h } = Lt(l);
1762
+ u === void 0 ? o(f, l, h) : h !== u[1] && (u[0].removeListeners(), t.delete(l), o(f, l, h));
1763
+ } else i === "destroyed" && u !== void 0 && (u[0].removeListeners(), t.delete(l));
1764
+ }
1765
+ }, { editor: n });
1766
+ }, { skipInitialization: !1 });
1767
+ return () => {
1768
+ r();
1769
+ for (const [, [s]] of t) s.removeListeners();
1770
+ };
1771
+ }
1772
+ function po(n) {
1773
+ return n.hasNodes([ce]) || w(255), jt(n.registerCommand(En, Qn, De), n.registerCommand(At, ({ nodes: e, selection: t }, o) => n !== o || !$(t) ? !1 : _e(t.anchor.getNode()) !== null && e.some(M), De), n.registerCommand(rn, no, De), n.registerNodeTransform(ce, to), n.registerNodeTransform(Te, eo), n.registerNodeTransform(ue, Gn));
1774
+ }
1775
+ export {
1776
+ Re as $,
1777
+ y as A,
1778
+ zn as B,
1779
+ Et as D,
1780
+ Me as H,
1781
+ Mt as I,
1782
+ ao as J,
1783
+ mo as N,
1784
+ Y as O,
1785
+ so as P,
1786
+ ue as T,
1787
+ io as U,
1788
+ co as V,
1789
+ _e as Z,
1790
+ ae as a,
1791
+ ce as d,
1792
+ uo as e,
1793
+ fo as h,
1794
+ Te as k,
1795
+ oe as m,
1796
+ ho as s,
1797
+ et as u,
1798
+ po as v,
1799
+ go as y,
1800
+ E as z
1801
+ };
1802
+ //# sourceMappingURL=LexicalTable.prod-CZ1mYUR-.js.map