@uva-glass/component-library 3.53.13 → 3.53.15

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