@uva-glass/component-library 1.64.0 → 1.64.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/Lexical.prod-DSqOWcE1.js +4072 -0
  2. package/dist/Lexical.prod-DSqOWcE1.js.map +1 -0
  3. package/dist/{LexicalClipboard.prod-C6LsK5E6.js → LexicalClipboard.prod-DP0us-xV.js} +107 -107
  4. package/dist/{LexicalClipboard.prod-C6LsK5E6.js.map → LexicalClipboard.prod-DP0us-xV.js.map} +1 -1
  5. package/dist/LexicalLink.prod-DWrTW8iE.js +208 -0
  6. package/dist/LexicalLink.prod-DWrTW8iE.js.map +1 -0
  7. package/dist/LexicalList.prod-Cg8npow-.js +564 -0
  8. package/dist/LexicalList.prod-Cg8npow-.js.map +1 -0
  9. package/dist/LexicalTable.prod-DEA4KRzX.js +1221 -0
  10. package/dist/LexicalTable.prod-DEA4KRzX.js.map +1 -0
  11. package/dist/{LexicalUtils.prod-BTFNWAMw.js → LexicalUtils.prod-CicP_X7u.js} +44 -35
  12. package/dist/{LexicalUtils.prod-BTFNWAMw.js.map → LexicalUtils.prod-CicP_X7u.js.map} +1 -1
  13. package/dist/RteEditor.module-BeUn7GiA.js +32 -0
  14. package/dist/RteEditor.module-BeUn7GiA.js.map +1 -0
  15. package/dist/{TablePlugin-BLzR0g93.js → TablePlugin-aDKhmuu7.js} +57 -59
  16. package/dist/{TablePlugin-BLzR0g93.js.map → TablePlugin-aDKhmuu7.js.map} +1 -1
  17. package/dist/assets/RteEditor.css +1 -1
  18. package/dist/components/CheckboxTree/CheckboxTree.js +18 -21
  19. package/dist/components/CheckboxTree/CheckboxTree.js.map +1 -1
  20. package/dist/components/FormInput/FormInput.js +12 -15
  21. package/dist/components/FormInput/FormInput.js.map +1 -1
  22. package/dist/components/InputField/InputField.stories.js +13 -16
  23. package/dist/components/InputField/InputField.stories.js.map +1 -1
  24. package/dist/components/MultiSelect/MultiSelect.js +1 -1
  25. package/dist/components/MultiSelect/MultiSelect.stories.js +1 -1
  26. package/dist/components/MultiSelect/components/MultiSelectHeader.js +3 -6
  27. package/dist/components/MultiSelect/components/MultiSelectHeader.js.map +1 -1
  28. package/dist/components/MultiSelect/index.js +1 -1
  29. package/dist/components/PeriodSelector/PeriodSelector.js +19 -22
  30. package/dist/components/PeriodSelector/PeriodSelector.js.map +1 -1
  31. package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +17 -20
  32. package/dist/components/ProgrammeCard/ProgrammeCard.stories.js.map +1 -1
  33. package/dist/components/RteEditor/EditorHeader/EditorHeader.js +4 -7
  34. package/dist/components/RteEditor/EditorHeader/EditorHeader.js.map +1 -1
  35. package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +16 -16
  36. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +27 -29
  37. package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js.map +1 -1
  38. package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +4 -7
  39. package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js.map +1 -1
  40. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +1 -1
  41. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +100 -101
  42. package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  43. package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
  44. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +35 -35
  45. package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js.map +1 -1
  46. package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +15 -15
  47. package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js.map +1 -1
  48. package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +3 -6
  49. package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js.map +1 -1
  50. package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +6 -8
  51. package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js.map +1 -1
  52. package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +12 -12
  53. package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -1
  54. package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +34 -34
  55. package/dist/components/RteEditor/Plugins/index.js +1 -1
  56. package/dist/components/RteEditor/RteEditor.js +354 -354
  57. package/dist/components/RteEditor/RteEditor.js.map +1 -1
  58. package/dist/components/RteEditor/UvaTheme/UvaTheme.js +13 -12
  59. package/dist/components/RteEditor/UvaTheme/UvaTheme.js.map +1 -1
  60. package/dist/components/RteEditor/helpers.js +27 -27
  61. package/dist/components/index.js +1 -1
  62. package/dist/helpers-BuSJOvGF.js +168 -0
  63. package/dist/{helpers-B-pdj8pq.js.map → helpers-BuSJOvGF.js.map} +1 -1
  64. package/dist/index-DPQ9bZx5.js +231 -0
  65. package/dist/index-DPQ9bZx5.js.map +1 -0
  66. package/dist/index.js +1 -1
  67. package/package.json +18 -16
  68. package/dist/LexicalTable.prod-DqzrJuYr.js +0 -1221
  69. package/dist/LexicalTable.prod-DqzrJuYr.js.map +0 -1
  70. package/dist/RteEditor.module-DcvGRx3a.js +0 -21
  71. package/dist/RteEditor.module-DcvGRx3a.js.map +0 -1
  72. package/dist/helpers-B-pdj8pq.js +0 -168
@@ -0,0 +1,1221 @@
1
+ import { $ as it, t as y, U as Ut, i as $t } from "./LexicalUtils.prod-CicP_X7u.js";
2
+ import { m as wt, D as tt, x as P, V as te, b as dt, d as _t, c as yt, S as ee, C as X, t as ne, M as D, e as oe, f as Q, g as re, h as se, p as le, i as ie, j as ae, k as Mt, s as ce, v as H, z as L, l as ue, w as he, n as de, q as ge, r as fe, y as me, N as pe, J as Ce, A as Se, B as nt, E as be, F as q, G as we, o as _e, u as ye, T as Ne, H as st, K as xe, L as Yt, O as ve, P as Te, Q as Ee, R as Oe, U as kt } from "./Lexical.prod-DSqOWcE1.js";
3
+ import { O as Ke, b as Fe } from "./LexicalClipboard.prod-DP0us-xV.js";
4
+ const Nt = /^(\d+(?:\.\d+)?)px$/, I = { BOTH: 3, COLUMN: 2, NO_STATUS: 0, ROW: 1 };
5
+ class at extends wt {
6
+ static getType() {
7
+ return "tablecell";
8
+ }
9
+ static clone(t) {
10
+ return new at(t.__headerState, t.__colSpan, t.__width, t.__key);
11
+ }
12
+ afterCloneFrom(t) {
13
+ super.afterCloneFrom(t), this.__rowSpan = t.__rowSpan, this.__backgroundColor = t.__backgroundColor;
14
+ }
15
+ static importDOM() {
16
+ return { td: (t) => ({ conversion: Rt, priority: 0 }), th: (t) => ({ conversion: Rt, priority: 0 }) };
17
+ }
18
+ static importJSON(t) {
19
+ const e = t.colSpan || 1, n = t.rowSpan || 1;
20
+ return xt(t.headerState, e, t.width || void 0).setRowSpan(n).setBackgroundColor(t.backgroundColor || null);
21
+ }
22
+ constructor(t = I.NO_STATUS, e = 1, n, s) {
23
+ super(s), this.__colSpan = e, this.__rowSpan = 1, this.__headerState = t, this.__width = n, this.__backgroundColor = null;
24
+ }
25
+ createDOM(t) {
26
+ const e = document.createElement(this.getTag());
27
+ return this.__width && (e.style.width = `${this.__width}px`), this.__colSpan > 1 && (e.colSpan = this.__colSpan), this.__rowSpan > 1 && (e.rowSpan = this.__rowSpan), this.__backgroundColor !== null && (e.style.backgroundColor = this.__backgroundColor), it(e, t.theme.tableCell, this.hasHeader() && t.theme.tableCellHeader), e;
28
+ }
29
+ exportDOM(t) {
30
+ const { element: e } = super.exportDOM(t);
31
+ if (e) {
32
+ const n = e;
33
+ n.style.border = "1px solid black", this.__colSpan > 1 && (n.colSpan = this.__colSpan), this.__rowSpan > 1 && (n.rowSpan = this.__rowSpan), n.style.width = `${this.getWidth() || 75}px`, n.style.verticalAlign = "top", n.style.textAlign = "start";
34
+ const s = this.getBackgroundColor();
35
+ s !== null ? n.style.backgroundColor = s : this.hasHeader() && (n.style.backgroundColor = "#f2f3f5");
36
+ }
37
+ return { element: e };
38
+ }
39
+ exportJSON() {
40
+ return { ...super.exportJSON(), backgroundColor: this.getBackgroundColor(), colSpan: this.__colSpan, headerState: this.__headerState, rowSpan: this.__rowSpan, type: "tablecell", width: this.getWidth() };
41
+ }
42
+ getColSpan() {
43
+ return this.getLatest().__colSpan;
44
+ }
45
+ setColSpan(t) {
46
+ const e = this.getWritable();
47
+ return e.__colSpan = t, e;
48
+ }
49
+ getRowSpan() {
50
+ return this.getLatest().__rowSpan;
51
+ }
52
+ setRowSpan(t) {
53
+ const e = this.getWritable();
54
+ return e.__rowSpan = t, e;
55
+ }
56
+ getTag() {
57
+ return this.hasHeader() ? "th" : "td";
58
+ }
59
+ setHeaderStyles(t, e = I.BOTH) {
60
+ const n = this.getWritable();
61
+ return n.__headerState = t & e | n.__headerState & ~e, n;
62
+ }
63
+ getHeaderStyles() {
64
+ return this.getLatest().__headerState;
65
+ }
66
+ setWidth(t) {
67
+ const e = this.getWritable();
68
+ return e.__width = t, e;
69
+ }
70
+ getWidth() {
71
+ return this.getLatest().__width;
72
+ }
73
+ getBackgroundColor() {
74
+ return this.getLatest().__backgroundColor;
75
+ }
76
+ setBackgroundColor(t) {
77
+ const e = this.getWritable();
78
+ return e.__backgroundColor = t, e;
79
+ }
80
+ toggleHeaderStyle(t) {
81
+ const e = this.getWritable();
82
+ return (e.__headerState & t) === t ? e.__headerState -= t : e.__headerState += t, e;
83
+ }
84
+ hasHeaderState(t) {
85
+ return (this.getHeaderStyles() & t) === t;
86
+ }
87
+ hasHeader() {
88
+ return this.getLatest().__headerState !== I.NO_STATUS;
89
+ }
90
+ updateDOM(t) {
91
+ return t.__headerState !== this.__headerState || t.__width !== this.__width || t.__colSpan !== this.__colSpan || t.__rowSpan !== this.__rowSpan || t.__backgroundColor !== this.__backgroundColor;
92
+ }
93
+ isShadowRoot() {
94
+ return !0;
95
+ }
96
+ collapseAtStart() {
97
+ return !0;
98
+ }
99
+ canBeEmpty() {
100
+ return !1;
101
+ }
102
+ canIndent() {
103
+ return !1;
104
+ }
105
+ }
106
+ function Rt(r) {
107
+ const t = r, e = r.nodeName.toLowerCase();
108
+ let n;
109
+ Nt.test(t.style.width) && (n = parseFloat(t.style.width));
110
+ const s = xt(e === "th" ? I.ROW : I.NO_STATUS, t.colSpan, n);
111
+ s.__rowSpan = t.rowSpan;
112
+ const o = t.style.backgroundColor;
113
+ o !== "" && (s.__backgroundColor = o);
114
+ const c = t.style, u = (c && c.textDecoration || "").split(" "), h = c.fontWeight === "700" || c.fontWeight === "bold", g = u.includes("line-through"), l = c.fontStyle === "italic", i = u.includes("underline");
115
+ return { after: (a) => (a.length === 0 && a.push(tt()), a), forChild: (a, d) => {
116
+ if (f(d) && !P(a)) {
117
+ const b = tt();
118
+ return te(a) && a.getTextContent() === `
119
+ ` ? null : (dt(a) && (h && a.toggleFormat("bold"), g && a.toggleFormat("strikethrough"), l && a.toggleFormat("italic"), i && a.toggleFormat("underline")), b.append(a), b);
120
+ }
121
+ return a;
122
+ }, node: s };
123
+ }
124
+ function xt(r, t = 1, e) {
125
+ return _t(new at(r, t, e));
126
+ }
127
+ function f(r) {
128
+ return r instanceof at;
129
+ }
130
+ const Ue = ne();
131
+ function Me(r) {
132
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
133
+ }
134
+ var x = Me(function(r) {
135
+ const t = new URLSearchParams();
136
+ t.append("code", r);
137
+ for (let e = 1; e < arguments.length; e++) t.append("v", arguments[e]);
138
+ throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${t} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);
139
+ });
140
+ const ke = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
141
+ class gt extends wt {
142
+ static getType() {
143
+ return "tablerow";
144
+ }
145
+ static clone(t) {
146
+ return new gt(t.__height, t.__key);
147
+ }
148
+ static importDOM() {
149
+ return { tr: (t) => ({ conversion: Re, priority: 0 }) };
150
+ }
151
+ static importJSON(t) {
152
+ return vt(t.height);
153
+ }
154
+ constructor(t, e) {
155
+ super(e), this.__height = t;
156
+ }
157
+ exportJSON() {
158
+ return { ...super.exportJSON(), ...this.getHeight() && { height: this.getHeight() }, type: "tablerow", version: 1 };
159
+ }
160
+ createDOM(t) {
161
+ const e = document.createElement("tr");
162
+ return this.__height && (e.style.height = `${this.__height}px`), it(e, t.theme.tableRow), e;
163
+ }
164
+ isShadowRoot() {
165
+ return !0;
166
+ }
167
+ setHeight(t) {
168
+ return this.getWritable().__height = t, this.__height;
169
+ }
170
+ getHeight() {
171
+ return this.getLatest().__height;
172
+ }
173
+ updateDOM(t) {
174
+ return t.__height !== this.__height;
175
+ }
176
+ canBeEmpty() {
177
+ return !1;
178
+ }
179
+ canIndent() {
180
+ return !1;
181
+ }
182
+ }
183
+ function Re(r) {
184
+ const t = r;
185
+ let e;
186
+ return Nt.test(t.style.height) && (e = parseFloat(t.style.height)), { node: vt(e) };
187
+ }
188
+ function vt(r) {
189
+ return _t(new gt(r));
190
+ }
191
+ function W(r) {
192
+ return r instanceof gt;
193
+ }
194
+ function Ye(r, t, e = !0) {
195
+ const n = Et();
196
+ for (let s = 0; s < r; s++) {
197
+ const o = vt();
198
+ for (let c = 0; c < t; c++) {
199
+ let u = I.NO_STATUS;
200
+ typeof e == "object" ? (s === 0 && e.rows && (u |= I.ROW), c === 0 && e.columns && (u |= I.COLUMN)) : e && (s === 0 && (u |= I.ROW), c === 0 && (u |= I.COLUMN));
201
+ const h = xt(u), g = tt();
202
+ g.append(yt()), h.append(g), o.append(h);
203
+ }
204
+ n.append(o);
205
+ }
206
+ return n;
207
+ }
208
+ function Xe(r) {
209
+ const t = y(r, (e) => f(e));
210
+ return f(t) ? t : null;
211
+ }
212
+ function Xt(r) {
213
+ const t = y(r, (e) => W(e));
214
+ if (W(t)) return t;
215
+ throw new Error("Expected table cell to be inside of table row.");
216
+ }
217
+ function Pe(r) {
218
+ const t = y(r, (e) => T(e));
219
+ if (T(t)) return t;
220
+ throw new Error("Expected table cell to be inside of table.");
221
+ }
222
+ function Je(r) {
223
+ const t = Xt(r);
224
+ return Pe(t).getChildren().findIndex((e) => e.is(t));
225
+ }
226
+ function je(r) {
227
+ return Xt(r).getChildren().findIndex((t) => t.is(r));
228
+ }
229
+ function qe(r, t) {
230
+ const e = r.getChildren();
231
+ for (let n = 0; n < e.length; n++) {
232
+ const s = e[n];
233
+ if (W(s)) {
234
+ const o = s.getChildren();
235
+ if (t >= o.length || t < 0) throw new Error("Table column target index out of range");
236
+ o[t].remove();
237
+ }
238
+ }
239
+ return r;
240
+ }
241
+ function $(r, t, e) {
242
+ const [n, s, o] = De(r, t, e);
243
+ return s === null && x(207), o === null && x(208), [n, s, o];
244
+ }
245
+ function De(r, t, e) {
246
+ const n = [];
247
+ let s = null, o = null;
248
+ function c(h) {
249
+ let g = n[h];
250
+ return g === void 0 && (n[h] = g = []), g;
251
+ }
252
+ const u = r.getChildren();
253
+ for (let h = 0; h < u.length; h++) {
254
+ const g = u[h];
255
+ W(g) || x(209);
256
+ for (let l = g.getFirstChild(), i = 0; l != null; l = l.getNextSibling()) {
257
+ f(l) || x(147);
258
+ const a = c(h);
259
+ for (; a[i] !== void 0; ) i++;
260
+ const d = { cell: l, startColumn: i, startRow: h }, { __rowSpan: b, __colSpan: w } = l;
261
+ for (let C = 0; C < b && !(h + C >= u.length); C++) {
262
+ const m = c(h + C);
263
+ for (let N = 0; N < w; N++) m[i + N] = d;
264
+ }
265
+ t !== null && s === null && t.is(l) && (s = d), e !== null && o === null && e.is(l) && (o = d);
266
+ }
267
+ }
268
+ return [n, s, o];
269
+ }
270
+ function ot(r) {
271
+ let t;
272
+ if (r instanceof at) t = r;
273
+ else if ("__type" in r) {
274
+ const s = y(r, f);
275
+ f(s) || x(148), t = s;
276
+ } else {
277
+ const s = y(r.getNode(), f);
278
+ f(s) || x(148), t = s;
279
+ }
280
+ const e = t.getParent();
281
+ W(e) || x(149);
282
+ const n = e.getParent();
283
+ return T(n) || x(210), [t, e, n];
284
+ }
285
+ function Pt(r) {
286
+ const [t, , e] = ot(r), n = e.getChildren(), s = n.length, o = n[0].getChildren().length, c = new Array(s);
287
+ for (let u = 0; u < s; u++) c[u] = new Array(o);
288
+ for (let u = 0; u < s; u++) {
289
+ const h = n[u].getChildren();
290
+ let g = 0;
291
+ for (let l = 0; l < h.length; l++) {
292
+ for (; c[u][g]; ) g++;
293
+ const i = h[l], a = i.__rowSpan || 1, d = i.__colSpan || 1;
294
+ for (let b = 0; b < a; b++) for (let w = 0; w < d; w++) c[u + b][g + w] = i;
295
+ if (t === i) return { colSpan: d, columnIndex: g, rowIndex: u, rowSpan: a };
296
+ g += d;
297
+ }
298
+ }
299
+ return null;
300
+ }
301
+ class ft {
302
+ constructor(t, e, n) {
303
+ this.anchor = e, this.focus = n, e._selection = this, n._selection = this, this._cachedNodes = null, this.dirty = !1, this.tableKey = t;
304
+ }
305
+ getStartEndPoints() {
306
+ return [this.anchor, this.focus];
307
+ }
308
+ isBackward() {
309
+ return this.focus.isBefore(this.anchor);
310
+ }
311
+ getCachedNodes() {
312
+ return this._cachedNodes;
313
+ }
314
+ setCachedNodes(t) {
315
+ this._cachedNodes = t;
316
+ }
317
+ is(t) {
318
+ return !!K(t) && this.tableKey === t.tableKey && this.anchor.is(t.anchor) && this.focus.is(t.focus);
319
+ }
320
+ set(t, e, n) {
321
+ this.dirty = !0, this.tableKey = t, this.anchor.key = e, this.focus.key = n, this._cachedNodes = null;
322
+ }
323
+ clone() {
324
+ return new ft(this.tableKey, this.anchor, this.focus);
325
+ }
326
+ isCollapsed() {
327
+ return !1;
328
+ }
329
+ extract() {
330
+ return this.getNodes();
331
+ }
332
+ insertRawText(t) {
333
+ }
334
+ insertText() {
335
+ }
336
+ hasFormat(t) {
337
+ let e = 0;
338
+ this.getNodes().filter(f).forEach((s) => {
339
+ const o = s.getFirstChild();
340
+ Yt(o) && (e |= o.getTextFormat());
341
+ });
342
+ const n = Oe[t];
343
+ return !!(e & n);
344
+ }
345
+ insertNodes(t) {
346
+ const e = this.focus.getNode();
347
+ P(e) || x(151), Te(e.select(0, e.getChildrenSize())).insertNodes(t);
348
+ }
349
+ getShape() {
350
+ const t = st(this.anchor.key);
351
+ f(t) || x(152);
352
+ const e = Pt(t);
353
+ e === null && x(153);
354
+ const n = st(this.focus.key);
355
+ f(n) || x(154);
356
+ const s = Pt(n);
357
+ s === null && x(155);
358
+ const o = Math.min(e.columnIndex, s.columnIndex), c = Math.max(e.columnIndex + e.colSpan - 1, s.columnIndex + s.colSpan - 1), u = Math.min(e.rowIndex, s.rowIndex), h = Math.max(e.rowIndex + e.rowSpan - 1, s.rowIndex + s.rowSpan - 1);
359
+ return { fromX: Math.min(o, c), fromY: Math.min(u, h), toX: Math.max(o, c), toY: Math.max(u, h) };
360
+ }
361
+ getNodes() {
362
+ const t = this._cachedNodes;
363
+ if (t !== null) return t;
364
+ const e = this.anchor.getNode(), n = this.focus.getNode(), s = y(e, f), o = y(n, f);
365
+ f(s) || x(152), f(o) || x(154);
366
+ const c = s.getParent();
367
+ W(c) || x(156);
368
+ const u = c.getParent();
369
+ T(u) || x(157);
370
+ const h = o.getParents()[1];
371
+ if (h !== u) {
372
+ if (u.isParentOf(o)) {
373
+ const S = h.getParent();
374
+ S == null && x(159), this.set(this.tableKey, o.getKey(), S.getKey());
375
+ } else {
376
+ const S = u.getParent();
377
+ S == null && x(158), this.set(this.tableKey, S.getKey(), o.getKey());
378
+ }
379
+ return this.getNodes();
380
+ }
381
+ const [g, l, i] = $(u, s, o);
382
+ let a = Math.min(l.startColumn, i.startColumn), d = Math.min(l.startRow, i.startRow), b = Math.max(l.startColumn + l.cell.__colSpan - 1, i.startColumn + i.cell.__colSpan - 1), w = Math.max(l.startRow + l.cell.__rowSpan - 1, i.startRow + i.cell.__rowSpan - 1), C = a, m = d, N = a, E = d;
383
+ function F(S) {
384
+ const { cell: _, startColumn: p, startRow: R } = S;
385
+ a = Math.min(a, p), d = Math.min(d, R), b = Math.max(b, p + _.__colSpan - 1), w = Math.max(w, R + _.__rowSpan - 1);
386
+ }
387
+ for (; a < C || d < m || b > N || w > E; ) {
388
+ if (a < C) {
389
+ const S = E - m, _ = C - 1;
390
+ for (let p = 0; p <= S; p++) F(g[m + p][_]);
391
+ C = _;
392
+ }
393
+ if (d < m) {
394
+ const S = N - C, _ = m - 1;
395
+ for (let p = 0; p <= S; p++) F(g[_][C + p]);
396
+ m = _;
397
+ }
398
+ if (b > N) {
399
+ const S = E - m, _ = N + 1;
400
+ for (let p = 0; p <= S; p++) F(g[m + p][_]);
401
+ N = _;
402
+ }
403
+ if (w > E) {
404
+ const S = N - C, _ = E + 1;
405
+ for (let p = 0; p <= S; p++) F(g[_][C + p]);
406
+ E = _;
407
+ }
408
+ }
409
+ const M = /* @__PURE__ */ new Map([[u.getKey(), u]]);
410
+ let v = null;
411
+ for (let S = d; S <= w; S++) for (let _ = a; _ <= b; _++) {
412
+ const { cell: p } = g[S][_], R = p.getParent();
413
+ W(R) || x(160), R !== v && M.set(R.getKey(), R), M.set(p.getKey(), p);
414
+ for (const B of He(p)) M.set(B.getKey(), B);
415
+ v = R;
416
+ }
417
+ const O = Array.from(M.values());
418
+ return Ee() || (this._cachedNodes = O), O;
419
+ }
420
+ getTextContent() {
421
+ const t = this.getNodes().filter((n) => f(n));
422
+ let e = "";
423
+ for (let n = 0; n < t.length; n++) {
424
+ const s = t[n], o = s.__parent, c = (t[n + 1] || {}).__parent;
425
+ e += s.getTextContent() + (c !== o ? `
426
+ ` : " ");
427
+ }
428
+ return e;
429
+ }
430
+ }
431
+ function K(r) {
432
+ return r instanceof ft;
433
+ }
434
+ function Dt() {
435
+ const r = kt("root", 0, "element"), t = kt("root", 0, "element");
436
+ return new ft("root", r, t);
437
+ }
438
+ function He(r) {
439
+ const t = [], e = [r];
440
+ for (; e.length > 0; ) {
441
+ const n = e.pop();
442
+ n === void 0 && x(112), P(n) && e.unshift(...n.getChildren()), n !== r && t.push(n);
443
+ }
444
+ return t;
445
+ }
446
+ class Be {
447
+ constructor(t, e) {
448
+ this.isHighlightingCells = !1, this.anchorX = -1, this.anchorY = -1, this.focusX = -1, this.focusY = -1, this.listenersToRemove = /* @__PURE__ */ new Set(), this.tableNodeKey = e, this.editor = t, 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.trackTable(), this.isSelecting = !1, this.abortController = new AbortController(), this.listenerOptions = { signal: this.abortController.signal };
449
+ }
450
+ getTable() {
451
+ return this.table;
452
+ }
453
+ removeListeners() {
454
+ this.abortController.abort("removeListeners"), Array.from(this.listenersToRemove).forEach((t) => t()), this.listenersToRemove.clear();
455
+ }
456
+ trackTable() {
457
+ const t = new MutationObserver((e) => {
458
+ this.editor.update(() => {
459
+ let n = !1;
460
+ for (let o = 0; o < e.length; o++) {
461
+ const c = e[o].target.nodeName;
462
+ if (c === "TABLE" || c === "TBODY" || c === "THEAD" || c === "TR") {
463
+ n = !0;
464
+ break;
465
+ }
466
+ }
467
+ if (!n) return;
468
+ const s = this.editor.getElementByKey(this.tableNodeKey);
469
+ if (!s) throw new Error("Expected to find TableElement in DOM");
470
+ this.table = lt(s);
471
+ });
472
+ });
473
+ this.editor.update(() => {
474
+ const e = this.editor.getElementByKey(this.tableNodeKey);
475
+ if (!e) throw new Error("Expected to find TableElement in DOM");
476
+ this.table = lt(e), t.observe(e, { attributes: !0, childList: !0, subtree: !0 });
477
+ });
478
+ }
479
+ clearHighlight() {
480
+ const t = this.editor;
481
+ 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(), t.update(() => {
482
+ if (!T(st(this.tableNodeKey))) throw new Error("Expected TableNode.");
483
+ const e = t.getElementByKey(this.tableNodeKey);
484
+ if (!e) throw new Error("Expected to find TableElement in DOM");
485
+ const n = lt(e);
486
+ ut(t, n, null), q(null), t.dispatchCommand(nt, void 0);
487
+ });
488
+ }
489
+ enableHighlightStyle() {
490
+ const t = this.editor;
491
+ t.update(() => {
492
+ const e = t.getElementByKey(this.tableNodeKey);
493
+ if (!e) throw new Error("Expected to find TableElement in DOM");
494
+ Ut(e, t._config.theme.tableSelection), e.classList.remove("disable-selection"), this.hasHijackedSelectionStyles = !1;
495
+ });
496
+ }
497
+ disableHighlightStyle() {
498
+ const t = this.editor;
499
+ t.update(() => {
500
+ const e = t.getElementByKey(this.tableNodeKey);
501
+ if (!e) throw new Error("Expected to find TableElement in DOM");
502
+ it(e, t._config.theme.tableSelection), this.hasHijackedSelectionStyles = !0;
503
+ });
504
+ }
505
+ updateTableTableSelection(t) {
506
+ if (t !== null && t.tableKey === this.tableNodeKey) {
507
+ const e = this.editor;
508
+ this.tableSelection = t, this.isHighlightingCells = !0, this.disableHighlightStyle(), ut(e, this.table, this.tableSelection);
509
+ } else t == null ? this.clearHighlight() : (this.tableNodeKey = t.tableKey, this.updateTableTableSelection(t));
510
+ }
511
+ setFocusCellForSelection(t, e = !1) {
512
+ const n = this.editor;
513
+ n.update(() => {
514
+ const s = st(this.tableNodeKey);
515
+ if (!T(s)) throw new Error("Expected TableNode.");
516
+ if (!n.getElementByKey(this.tableNodeKey)) throw new Error("Expected to find TableElement in DOM");
517
+ const o = t.x, c = t.y;
518
+ if (this.focusCell = t, this.anchorCell !== null) {
519
+ const u = Jt(n._window);
520
+ u && u.setBaseAndExtent(this.anchorCell.elem, 0, this.focusCell.elem, 0);
521
+ }
522
+ if (this.isHighlightingCells || this.anchorX === o && this.anchorY === c && !e) {
523
+ if (o === this.focusX && c === this.focusY) return;
524
+ } else this.isHighlightingCells = !0, this.disableHighlightStyle();
525
+ if (this.focusX = o, this.focusY = c, this.isHighlightingCells) {
526
+ const u = X(t.elem);
527
+ if (this.tableSelection != null && this.anchorCellNodeKey != null && f(u) && s.is(Z(u))) {
528
+ const h = u.getKey();
529
+ this.tableSelection = this.tableSelection.clone() || Dt(), this.focusCellNodeKey = h, this.tableSelection.set(this.tableNodeKey, this.anchorCellNodeKey, this.focusCellNodeKey), q(this.tableSelection), n.dispatchCommand(nt, void 0), ut(n, this.table, this.tableSelection);
530
+ }
531
+ }
532
+ });
533
+ }
534
+ setAnchorCellForSelection(t) {
535
+ this.isHighlightingCells = !1, this.anchorCell = t, this.anchorX = t.x, this.anchorY = t.y, this.editor.update(() => {
536
+ const e = X(t.elem);
537
+ if (f(e)) {
538
+ const n = e.getKey();
539
+ this.tableSelection = this.tableSelection != null ? this.tableSelection.clone() : Dt(), this.anchorCellNodeKey = n;
540
+ }
541
+ });
542
+ }
543
+ formatCells(t) {
544
+ this.editor.update(() => {
545
+ const e = D();
546
+ K(e) || x(11);
547
+ const n = xe(), s = n.anchor, o = n.focus, c = e.getNodes().filter(f), u = c[0].getFirstChild(), h = Yt(u) ? u.getFormatFlags(t, null) : null;
548
+ c.forEach((g) => {
549
+ s.set(g.getKey(), 0, "element"), o.set(g.getKey(), g.getChildrenSize(), "element"), n.formatText(t, h);
550
+ }), q(e), this.editor.dispatchCommand(nt, void 0);
551
+ });
552
+ }
553
+ clearText() {
554
+ const t = this.editor;
555
+ t.update(() => {
556
+ const e = st(this.tableNodeKey);
557
+ if (!T(e)) throw new Error("Expected TableNode.");
558
+ const n = D();
559
+ K(n) || x(11);
560
+ const s = n.getNodes().filter(f);
561
+ s.length !== this.table.columns * this.table.rows ? (s.forEach((o) => {
562
+ if (P(o)) {
563
+ const c = tt(), u = yt();
564
+ c.append(u), o.append(c), o.getChildren().forEach((h) => {
565
+ h !== c && h.remove();
566
+ });
567
+ }
568
+ }), ut(t, this.table, null), q(null), t.dispatchCommand(nt, void 0)) : (e.selectPrevious(), e.remove(), ve().selectStart());
569
+ });
570
+ }
571
+ }
572
+ const bt = "__lexicalTableSelection", Jt = (r) => ke ? (r || window).getSelection() : null;
573
+ function Ve(r, t, e, n) {
574
+ const s = e.getRootElement();
575
+ if (s === null) throw new Error("No root element.");
576
+ const o = new Be(e, r.getKey()), c = e._window || window;
577
+ (function(l, i) {
578
+ Ht(l) !== null && x(205), l[bt] = i;
579
+ })(t, o), o.listenersToRemove.add(() => function(l, i) {
580
+ Ht(l) === i && delete l[bt];
581
+ }(t, o));
582
+ const u = () => {
583
+ const l = () => {
584
+ o.isSelecting = !1, c.removeEventListener("mouseup", l), c.removeEventListener("mousemove", i);
585
+ }, i = (a) => {
586
+ setTimeout(() => {
587
+ if (1 & ~a.buttons && o.isSelecting) return o.isSelecting = !1, c.removeEventListener("mouseup", l), void c.removeEventListener("mousemove", i);
588
+ const d = Bt(a.target);
589
+ d === null || o.anchorX === d.x && o.anchorY === d.y || (a.preventDefault(), o.setFocusCellForSelection(d));
590
+ }, 0);
591
+ };
592
+ return { onMouseMove: i, onMouseUp: l };
593
+ };
594
+ t.addEventListener("mousedown", (l) => {
595
+ setTimeout(() => {
596
+ if (l.button !== 0 || !c) return;
597
+ const i = Bt(l.target);
598
+ i !== null && (Y(l), o.setAnchorCellForSelection(i));
599
+ const { onMouseUp: a, onMouseMove: d } = u();
600
+ o.isSelecting = !0, c.addEventListener("mouseup", a, o.listenerOptions), c.addEventListener("mousemove", d, o.listenerOptions);
601
+ }, 0);
602
+ }, o.listenerOptions), c.addEventListener("mousedown", (l) => {
603
+ l.button === 0 && e.update(() => {
604
+ const i = D(), a = l.target;
605
+ K(i) && i.tableKey === o.tableNodeKey && s.contains(a) && o.clearHighlight();
606
+ });
607
+ }, o.listenerOptions), o.listenersToRemove.add(e.registerCommand(oe, (l) => rt(e, l, "down", r, o), Q)), o.listenersToRemove.add(e.registerCommand(re, (l) => rt(e, l, "up", r, o), Q)), o.listenersToRemove.add(e.registerCommand(se, (l) => rt(e, l, "backward", r, o), Q)), o.listenersToRemove.add(e.registerCommand(le, (l) => rt(e, l, "forward", r, o), Q)), o.listenersToRemove.add(e.registerCommand(ie, (l) => {
608
+ const i = D();
609
+ if (K(i)) {
610
+ const a = y(i.focus.getNode(), f);
611
+ if (f(a)) return Y(l), a.selectEnd(), !0;
612
+ }
613
+ return !1;
614
+ }, Q)), [ae, Mt, ce].forEach((l) => {
615
+ o.listenersToRemove.add(e.registerCommand(l, /* @__PURE__ */ ((i) => () => {
616
+ const a = D();
617
+ if (!V(a, r)) return !1;
618
+ if (K(a)) return o.clearText(), !0;
619
+ if (H(a)) {
620
+ const d = y(a.anchor.getNode(), (F) => f(F));
621
+ if (!f(d)) return !1;
622
+ const b = a.anchor.getNode(), w = a.focus.getNode(), C = r.isParentOf(b), m = r.isParentOf(w);
623
+ if (C && !m || m && !C) return o.clearText(), !0;
624
+ const N = y(a.anchor.getNode(), (F) => P(F)), E = N && y(N, (F) => P(F) && f(F.getParent()));
625
+ if (!P(E) || !P(N)) return !1;
626
+ if (i === Mt && E.getPreviousSibling() === null) return !0;
627
+ }
628
+ return !1;
629
+ })(l), L));
630
+ });
631
+ const h = (l) => {
632
+ const i = D();
633
+ if (!K(i) && !H(i)) return !1;
634
+ const a = r.isParentOf(i.anchor.getNode());
635
+ if (a !== r.isParentOf(i.focus.getNode())) {
636
+ const d = a ? "anchor" : "focus", b = a ? "focus" : "anchor", { key: w, offset: C, type: m } = i[b];
637
+ return r[i[d].isBefore(i[b]) ? "selectPrevious" : "selectNext"]()[b].set(w, C, m), !1;
638
+ }
639
+ return !!K(i) && (l && (l.preventDefault(), l.stopPropagation()), o.clearText(), !0);
640
+ };
641
+ function g(l) {
642
+ const i = r.getCordsFromCellNode(l, o.table);
643
+ return r.getDOMCellFromCordsOrThrow(i.x, i.y, o.table);
644
+ }
645
+ return o.listenersToRemove.add(e.registerCommand(ue, h, L)), o.listenersToRemove.add(e.registerCommand(he, h, L)), o.listenersToRemove.add(e.registerCommand(de, (l) => {
646
+ const i = D();
647
+ if (i) {
648
+ if (!K(i) && !H(i)) return !1;
649
+ Ke(e, $t(l, ClipboardEvent) ? l : null, Fe(i));
650
+ const a = h(l);
651
+ return H(i) ? (i.removeText(), !0) : a;
652
+ }
653
+ return !1;
654
+ }, L)), o.listenersToRemove.add(e.registerCommand(ge, (l) => {
655
+ const i = D();
656
+ if (!V(i, r)) return !1;
657
+ if (K(i)) return o.formatCells(l), !0;
658
+ if (H(i)) {
659
+ const a = y(i.anchor.getNode(), (d) => f(d));
660
+ if (!f(a)) return !1;
661
+ }
662
+ return !1;
663
+ }, L)), o.listenersToRemove.add(e.registerCommand(fe, (l) => {
664
+ const i = D();
665
+ if (!K(i) || !V(i, r)) return !1;
666
+ const a = i.anchor.getNode(), d = i.focus.getNode();
667
+ if (!f(a) || !f(d)) return !1;
668
+ const [b, w, C] = $(r, a, d), m = Math.max(w.startRow, C.startRow), N = Math.max(w.startColumn, C.startColumn), E = Math.min(w.startRow, C.startRow), F = Math.min(w.startColumn, C.startColumn);
669
+ for (let M = E; M <= m; M++) for (let v = F; v <= N; v++) {
670
+ const O = b[M][v].cell;
671
+ O.setFormat(l);
672
+ const S = O.getChildren();
673
+ for (let _ = 0; _ < S.length; _++) {
674
+ const p = S[_];
675
+ P(p) && !p.isInline() && p.setFormat(l);
676
+ }
677
+ }
678
+ return !0;
679
+ }, L)), o.listenersToRemove.add(e.registerCommand(me, (l) => {
680
+ const i = D();
681
+ if (!V(i, r)) return !1;
682
+ if (K(i)) return o.clearHighlight(), !1;
683
+ if (H(i)) {
684
+ const a = y(i.anchor.getNode(), (d) => f(d));
685
+ if (!f(a)) return !1;
686
+ if (typeof l == "string") {
687
+ const d = Wt(e, i, r);
688
+ if (d) return Lt(d, r, [yt(l)]), !0;
689
+ }
690
+ }
691
+ return !1;
692
+ }, L)), n && o.listenersToRemove.add(e.registerCommand(pe, (l) => {
693
+ const i = D();
694
+ if (!H(i) || !i.isCollapsed() || !V(i, r)) return !1;
695
+ const a = St(i.anchor.getNode());
696
+ if (a === null) return !1;
697
+ Y(l);
698
+ const d = r.getCordsFromCellNode(a, o.table);
699
+ return jt(o, r, d.x, d.y, l.shiftKey ? "backward" : "forward"), !0;
700
+ }, L)), o.listenersToRemove.add(e.registerCommand(Ce, (l) => r.isSelected(), Q)), o.listenersToRemove.add(e.registerCommand(Se, (l) => {
701
+ const { nodes: i, selection: a } = l, d = a.getStartEndPoints(), b = K(a), w = H(a) && y(a.anchor.getNode(), (k) => f(k)) !== null && y(a.focus.getNode(), (k) => f(k)) !== null || b;
702
+ if (i.length !== 1 || !T(i[0]) || !w || d === null) return !1;
703
+ const [C] = d, m = i[0], N = m.getChildren(), E = m.getFirstChildOrThrow().getChildrenSize(), F = m.getChildrenSize(), M = y(C.getNode(), (k) => f(k)), v = M && y(M, (k) => W(k)), O = v && y(v, (k) => T(k));
704
+ if (!f(M) || !W(v) || !T(O)) return !1;
705
+ const S = v.getIndexWithinParent(), _ = Math.min(O.getChildrenSize() - 1, S + F - 1), p = M.getIndexWithinParent(), R = Math.min(v.getChildrenSize() - 1, p + E - 1), B = Math.min(p, R), A = Math.min(S, _), J = Math.max(p, R), z = Math.max(S, _), j = O.getChildren();
706
+ let U = 0;
707
+ for (let k = A; k <= z; k++) {
708
+ const et = j[k];
709
+ if (!W(et)) return !1;
710
+ const Ot = N[U];
711
+ if (!W(Ot)) return !1;
712
+ const Gt = et.getChildren(), Qt = Ot.getChildren();
713
+ let Kt = 0;
714
+ for (let pt = B; pt <= J; pt++) {
715
+ const ct = Gt[pt];
716
+ if (!f(ct)) return !1;
717
+ const Ft = Qt[Kt];
718
+ if (!f(Ft)) return !1;
719
+ const Zt = ct.getChildren();
720
+ Ft.getChildren().forEach((G) => {
721
+ dt(G) && tt().append(G), ct.append(G);
722
+ }), Zt.forEach((G) => G.remove()), Kt++;
723
+ }
724
+ U++;
725
+ }
726
+ return !0;
727
+ }, L)), o.listenersToRemove.add(e.registerCommand(nt, () => {
728
+ const l = D(), i = be();
729
+ if (H(l)) {
730
+ const { anchor: a, focus: d } = l, b = a.getNode(), w = d.getNode(), C = St(b), m = St(w), N = !(!C || !r.is(Z(C))), E = !(!m || !r.is(Z(m))), F = N !== E, M = N && E, v = l.isBackward();
731
+ if (F) {
732
+ const O = l.clone();
733
+ if (E) {
734
+ const [S] = $(r, m, m), _ = S[0][0].cell, p = S[S.length - 1].at(-1).cell;
735
+ O.focus.set(v ? _.getKey() : p.getKey(), v ? _.getChildrenSize() : p.getChildrenSize(), "element");
736
+ } else if (N) {
737
+ const [S] = $(r, C, C), _ = S[0][0].cell, p = S[S.length - 1].at(-1).cell;
738
+ O.anchor.set(v ? p.getKey() : _.getKey(), v ? p.getChildrenSize() : 0, "element");
739
+ }
740
+ q(O), At(e, o);
741
+ } else M && (C.is(m) || (o.setAnchorCellForSelection(g(C)), o.setFocusCellForSelection(g(m), !0), o.isSelecting || setTimeout(() => {
742
+ const { onMouseUp: O, onMouseMove: S } = u();
743
+ o.isSelecting = !0, c.addEventListener("mouseup", O), c.addEventListener("mousemove", S);
744
+ }, 0)));
745
+ } else if (l && K(l) && l.is(i) && l.tableKey === r.getKey()) {
746
+ const a = Jt(e._window);
747
+ if (a && a.anchorNode && a.focusNode) {
748
+ const d = X(a.focusNode), b = d && !r.is(Z(d)), w = X(a.anchorNode), C = w && r.is(Z(w));
749
+ if (b && C && a.rangeCount > 0) {
750
+ const m = we(a, e);
751
+ m && (m.anchor.set(r.getKey(), l.isBackward() ? r.getChildrenSize() : 0, "element"), a.removeAllRanges(), q(m));
752
+ }
753
+ }
754
+ }
755
+ return l && !l.is(i) && (K(l) || K(i)) && o.tableSelection && !o.tableSelection.is(i) ? (K(l) && l.tableKey === o.tableNodeKey ? o.updateTableTableSelection(l) : !K(l) && K(i) && i.tableKey === o.tableNodeKey && o.updateTableTableSelection(null), !1) : (o.hasHijackedSelectionStyles && !r.isSelected() ? function(a, d) {
756
+ d.enableHighlightStyle(), Tt(d.table, (b) => {
757
+ const w = b.elem;
758
+ b.highlighted = !1, Vt(a, b), w.getAttribute("style") || w.removeAttribute("style");
759
+ });
760
+ }(e, o) : !o.hasHijackedSelectionStyles && r.isSelected() && At(e, o), !1);
761
+ }, L)), o.listenersToRemove.add(e.registerCommand(_e, () => {
762
+ const l = D();
763
+ if (!H(l) || !l.isCollapsed() || !V(l, r)) return !1;
764
+ const i = Wt(e, l, r);
765
+ return !!i && (Lt(i, r), !0);
766
+ }, L)), o;
767
+ }
768
+ function Ht(r) {
769
+ return r[bt] || null;
770
+ }
771
+ function Bt(r) {
772
+ let t = r;
773
+ for (; t != null; ) {
774
+ const e = t.nodeName;
775
+ if (e === "TD" || e === "TH") {
776
+ const n = t._cell;
777
+ return n === void 0 ? null : n;
778
+ }
779
+ t = t.parentNode;
780
+ }
781
+ return null;
782
+ }
783
+ function lt(r) {
784
+ const t = [], e = { columns: 0, domRows: t, rows: 0 };
785
+ let n = r.querySelector("tr"), s = 0, o = 0;
786
+ for (t.length = 0; n != null; ) {
787
+ const c = n.nodeName;
788
+ if (c === "TD" || c === "TH") {
789
+ const g = { elem: n, hasBackgroundColor: n.style.backgroundColor !== "", highlighted: !1, x: s, y: o };
790
+ n._cell = g;
791
+ let l = t[o];
792
+ l === void 0 && (l = t[o] = []), l[s] = g;
793
+ } else {
794
+ const g = n.firstChild;
795
+ if (g != null) {
796
+ n = g;
797
+ continue;
798
+ }
799
+ }
800
+ const u = n.nextSibling;
801
+ if (u != null) {
802
+ s++, n = u;
803
+ continue;
804
+ }
805
+ const h = n.parentNode;
806
+ if (h != null) {
807
+ const g = h.nextSibling;
808
+ if (g == null) break;
809
+ o++, s = 0, n = g;
810
+ }
811
+ }
812
+ return e.columns = s + 1, e.rows = o + 1, e;
813
+ }
814
+ function ut(r, t, e) {
815
+ const n = new Set(e ? e.getNodes() : []);
816
+ Tt(t, (s, o) => {
817
+ const c = s.elem;
818
+ n.has(o) ? (s.highlighted = !0, qt(r, s)) : (s.highlighted = !1, Vt(r, s), c.getAttribute("style") || c.removeAttribute("style"));
819
+ });
820
+ }
821
+ function Tt(r, t) {
822
+ const { domRows: e } = r;
823
+ for (let n = 0; n < e.length; n++) {
824
+ const s = e[n];
825
+ if (s) for (let o = 0; o < s.length; o++) {
826
+ const c = s[o];
827
+ if (!c) continue;
828
+ const u = X(c.elem);
829
+ u !== null && t(c, u, { x: o, y: n });
830
+ }
831
+ }
832
+ }
833
+ function At(r, t) {
834
+ t.disableHighlightStyle(), Tt(t.table, (e) => {
835
+ e.highlighted = !0, qt(r, e);
836
+ });
837
+ }
838
+ const jt = (r, t, e, n, s) => {
839
+ const o = s === "forward";
840
+ switch (s) {
841
+ case "backward":
842
+ case "forward":
843
+ return e !== (o ? r.table.columns - 1 : 0) ? ht(t.getCellNodeFromCordsOrThrow(e + (o ? 1 : -1), n, r.table), o) : n !== (o ? r.table.rows - 1 : 0) ? ht(t.getCellNodeFromCordsOrThrow(o ? 0 : r.table.columns - 1, n + (o ? 1 : -1), r.table), o) : o ? t.selectNext() : t.selectPrevious(), !0;
844
+ case "up":
845
+ return n !== 0 ? ht(t.getCellNodeFromCordsOrThrow(e, n - 1, r.table), !1) : t.selectPrevious(), !0;
846
+ case "down":
847
+ return n !== r.table.rows - 1 ? ht(t.getCellNodeFromCordsOrThrow(e, n + 1, r.table), !0) : t.selectNext(), !0;
848
+ default:
849
+ return !1;
850
+ }
851
+ }, Ae = (r, t, e, n, s) => {
852
+ const o = s === "forward";
853
+ switch (s) {
854
+ case "backward":
855
+ case "forward":
856
+ return e !== (o ? r.table.columns - 1 : 0) && r.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(e + (o ? 1 : -1), n, r.table)), !0;
857
+ case "up":
858
+ return n !== 0 && (r.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(e, n - 1, r.table)), !0);
859
+ case "down":
860
+ return n !== r.table.rows - 1 && (r.setFocusCellForSelection(t.getDOMCellFromCordsOrThrow(e, n + 1, r.table)), !0);
861
+ default:
862
+ return !1;
863
+ }
864
+ };
865
+ function V(r, t) {
866
+ if (H(r) || K(r)) {
867
+ const e = t.isParentOf(r.anchor.getNode()), n = t.isParentOf(r.focus.getNode());
868
+ return e && n;
869
+ }
870
+ return !1;
871
+ }
872
+ function ht(r, t) {
873
+ t ? r.selectStart() : r.selectEnd();
874
+ }
875
+ const Ct = "172,206,247";
876
+ function qt(r, t) {
877
+ const e = t.elem, n = X(e);
878
+ f(n) || x(131), n.getBackgroundColor() === null ? e.style.setProperty("background-color", `rgb(${Ct})`) : e.style.setProperty("background-image", `linear-gradient(to right, rgba(${Ct},0.85), rgba(${Ct},0.85))`), e.style.setProperty("caret-color", "transparent");
879
+ }
880
+ function Vt(r, t) {
881
+ const e = t.elem, n = X(e);
882
+ f(n) || x(131), n.getBackgroundColor() === null && e.style.removeProperty("background-color"), e.style.removeProperty("background-image"), e.style.removeProperty("caret-color");
883
+ }
884
+ function St(r) {
885
+ const t = y(r, f);
886
+ return f(t) ? t : null;
887
+ }
888
+ function Z(r) {
889
+ const t = y(r, T);
890
+ return T(t) ? t : null;
891
+ }
892
+ function rt(r, t, e, n, s) {
893
+ if ((e === "up" || e === "down") && function(c) {
894
+ const u = c.getRootElement();
895
+ return u ? u.hasAttribute("aria-controls") && u.getAttribute("aria-controls") === "typeahead-menu" : !1;
896
+ }(r)) return !1;
897
+ const o = D();
898
+ if (!V(o, n)) {
899
+ if (H(o)) {
900
+ if (o.isCollapsed() && e === "backward") {
901
+ const c = o.anchor.type, u = o.anchor.offset;
902
+ if (c !== "element" && (c !== "text" || u !== 0)) return !1;
903
+ const h = o.anchor.getNode();
904
+ if (!h) return !1;
905
+ const g = y(h, (i) => P(i) && !i.isInline());
906
+ if (!g) return !1;
907
+ const l = g.getPreviousSibling();
908
+ return !(!l || !T(l)) && (Y(t), l.selectEnd(), !0);
909
+ }
910
+ if (t.shiftKey && (e === "up" || e === "down")) {
911
+ const c = o.focus.getNode();
912
+ if (!o.isCollapsed() && (e === "up" && !o.isBackward() || e === "down" && o.isBackward())) {
913
+ let u = y(c, (a) => T(a));
914
+ if (f(u) && (u = y(u, T)), u !== n || !u) return !1;
915
+ const h = e === "down" ? u.getNextSibling() : u.getPreviousSibling();
916
+ if (!h) return !1;
917
+ let g = 0;
918
+ e === "up" && P(h) && (g = h.getChildrenSize());
919
+ let l = h;
920
+ e === "up" && P(h) && (l = h.getLastChild() || h, g = dt(l) ? l.getTextContentSize() : 0);
921
+ const i = o.clone();
922
+ return i.focus.set(l.getKey(), g, dt(l) ? "text" : "element"), q(i), Y(t), !0;
923
+ }
924
+ if (ye(c)) {
925
+ const u = e === "up" ? o.getNodes()[o.getNodes().length - 1] : o.getNodes()[0];
926
+ if (u) {
927
+ const h = y(u, f);
928
+ if (h && n.isParentOf(h)) {
929
+ const g = n.getFirstDescendant(), l = n.getLastDescendant();
930
+ if (!g || !l) return !1;
931
+ const [i] = ot(g), [a] = ot(l), d = n.getCordsFromCellNode(i, s.table), b = n.getCordsFromCellNode(a, s.table), w = n.getDOMCellFromCordsOrThrow(d.x, d.y, s.table), C = n.getDOMCellFromCordsOrThrow(b.x, b.y, s.table);
932
+ return s.setAnchorCellForSelection(w), s.setFocusCellForSelection(C, !0), !0;
933
+ }
934
+ }
935
+ return !1;
936
+ }
937
+ {
938
+ let u = y(c, (g) => P(g) && !g.isInline());
939
+ if (f(u) && (u = y(u, T)), !u) return !1;
940
+ const h = e === "down" ? u.getNextSibling() : u.getPreviousSibling();
941
+ if (T(h) && s.tableNodeKey === h.getKey()) {
942
+ const g = h.getFirstDescendant(), l = h.getLastDescendant();
943
+ if (!g || !l) return !1;
944
+ const [i] = ot(g), [a] = ot(l), d = o.clone();
945
+ return d.focus.set((e === "up" ? i : a).getKey(), e === "up" ? 0 : a.getChildrenSize(), "element"), Y(t), q(d), !0;
946
+ }
947
+ }
948
+ }
949
+ }
950
+ return !1;
951
+ }
952
+ if (H(o) && o.isCollapsed()) {
953
+ const { anchor: c, focus: u } = o, h = y(c.getNode(), f), g = y(u.getNode(), f);
954
+ if (!f(h) || !h.is(g)) return !1;
955
+ const l = Z(h);
956
+ if (l !== n && l != null) {
957
+ const m = r.getElementByKey(l.getKey());
958
+ if (m != null) return s.table = lt(m), rt(r, t, e, l, s);
959
+ }
960
+ if (e === "backward" || e === "forward") {
961
+ const m = c.type, N = c.offset, E = c.getNode();
962
+ if (!E) return !1;
963
+ const F = o.getNodes();
964
+ return (F.length !== 1 || !Ne(F[0])) && !!function(M, v, O, S) {
965
+ return function(_, p, R) {
966
+ return _ === "element" && (R === "backward" ? p.getPreviousSibling() === null : p.getNextSibling() === null);
967
+ }(M, O, S) || function(_, p, R, B) {
968
+ const A = y(R, (z) => P(z) && !z.isInline());
969
+ if (!A) return !1;
970
+ const J = B === "backward" ? p === 0 : p === R.getTextContentSize();
971
+ return _ === "text" && J && (B === "backward" ? A.getPreviousSibling() === null : A.getNextSibling() === null);
972
+ }(M, v, O, S);
973
+ }(m, N, E, e) && function(M, v, O, S) {
974
+ const _ = y(v, f);
975
+ if (!f(_)) return !1;
976
+ const [p, R] = $(O, _, _);
977
+ if (!function(A, J, z) {
978
+ const j = A[0][0], U = A[A.length - 1][A[0].length - 1], { startColumn: k, startRow: et } = J;
979
+ return z === "backward" ? k === j.startColumn && et === j.startRow : k === U.startColumn && et === U.startRow;
980
+ }(p, R, S)) return !1;
981
+ const B = function(A, J, z) {
982
+ const j = y(A, (k) => P(k) && !k.isInline());
983
+ if (!j) return;
984
+ const U = J === "backward" ? j.getPreviousSibling() : j.getNextSibling();
985
+ return U && T(U) ? U : J === "backward" ? z.getPreviousSibling() : z.getNextSibling();
986
+ }(v, S, O);
987
+ return !B || T(B) ? !1 : (Y(M), S === "backward" ? B.selectEnd() : B.selectStart(), !0);
988
+ }(t, E, n, e);
989
+ }
990
+ const i = r.getElementByKey(h.__key), a = r.getElementByKey(c.key);
991
+ if (a == null || i == null) return !1;
992
+ let d;
993
+ if (c.type === "element") d = a.getBoundingClientRect();
994
+ else {
995
+ const m = window.getSelection();
996
+ if (m === null || m.rangeCount === 0) return !1;
997
+ d = m.getRangeAt(0).getBoundingClientRect();
998
+ }
999
+ const b = e === "up" ? h.getFirstChild() : h.getLastChild();
1000
+ if (b == null) return !1;
1001
+ const w = r.getElementByKey(b.__key);
1002
+ if (w == null) return !1;
1003
+ const C = w.getBoundingClientRect();
1004
+ if (e === "up" ? C.top > d.top - d.height : d.bottom + d.height > C.bottom) {
1005
+ Y(t);
1006
+ const m = n.getCordsFromCellNode(h, s.table);
1007
+ if (!t.shiftKey) return jt(s, n, m.x, m.y, e);
1008
+ {
1009
+ const N = n.getDOMCellFromCordsOrThrow(m.x, m.y, s.table);
1010
+ s.setAnchorCellForSelection(N), s.setFocusCellForSelection(N, !0);
1011
+ }
1012
+ return !0;
1013
+ }
1014
+ } else if (K(o)) {
1015
+ const { anchor: c, focus: u } = o, h = y(c.getNode(), f), g = y(u.getNode(), f), [l] = o.getNodes(), i = r.getElementByKey(l.getKey());
1016
+ if (!f(h) || !f(g) || !T(l) || i == null) return !1;
1017
+ s.updateTableTableSelection(o);
1018
+ const a = lt(i), d = n.getCordsFromCellNode(h, a), b = n.getDOMCellFromCordsOrThrow(d.x, d.y, a);
1019
+ if (s.setAnchorCellForSelection(b), Y(t), t.shiftKey) {
1020
+ const w = n.getCordsFromCellNode(g, a);
1021
+ return Ae(s, l, w.x, w.y, e);
1022
+ }
1023
+ return g.selectEnd(), !0;
1024
+ }
1025
+ return !1;
1026
+ }
1027
+ function Y(r) {
1028
+ r.preventDefault(), r.stopImmediatePropagation(), r.stopPropagation();
1029
+ }
1030
+ function Lt(r, t, e) {
1031
+ const n = tt();
1032
+ r === "first" ? t.insertBefore(n) : t.insertAfter(n), n.append(...e || []), n.selectEnd();
1033
+ }
1034
+ function Wt(r, t, e) {
1035
+ const n = e.getParent();
1036
+ if (!n) return;
1037
+ const s = r.getElementByKey(n.getKey());
1038
+ if (!s) return;
1039
+ const o = window.getSelection();
1040
+ if (!o || o.anchorNode !== s) return;
1041
+ const c = y(t.anchor.getNode(), (C) => f(C));
1042
+ if (!c) return;
1043
+ const u = y(c, (C) => T(C));
1044
+ if (!T(u) || !u.is(e)) return;
1045
+ const [h, g] = $(e, c, c), l = h[0][0], i = h[h.length - 1][h[0].length - 1], { startRow: a, startColumn: d } = g, b = a === l.startRow && d === l.startColumn, w = a === i.startRow && d === i.startColumn;
1046
+ return b ? "first" : w ? "last" : void 0;
1047
+ }
1048
+ function It(r, t, e, n) {
1049
+ const s = r.querySelector("colgroup");
1050
+ if (!s) return;
1051
+ const o = [];
1052
+ for (let c = 0; c < e; c++) {
1053
+ const u = document.createElement("col"), h = n && n[c];
1054
+ h && (u.style.width = `${h}px`), o.push(u);
1055
+ }
1056
+ s.replaceChildren(...o);
1057
+ }
1058
+ function zt(r, t, e) {
1059
+ e ? (it(r, t.theme.tableRowStriping), r.setAttribute("data-lexical-row-striping", "true")) : (Ut(r, t.theme.tableRowStriping), r.removeAttribute("data-lexical-row-striping"));
1060
+ }
1061
+ class mt extends wt {
1062
+ static getType() {
1063
+ return "table";
1064
+ }
1065
+ getColWidths() {
1066
+ return this.getLatest().__colWidths;
1067
+ }
1068
+ setColWidths(t) {
1069
+ const e = this.getWritable();
1070
+ return e.__colWidths = t, e;
1071
+ }
1072
+ static clone(t) {
1073
+ return new mt(t.__key);
1074
+ }
1075
+ afterCloneFrom(t) {
1076
+ super.afterCloneFrom(t), this.__colWidths = t.__colWidths, this.__rowStriping = t.__rowStriping;
1077
+ }
1078
+ static importDOM() {
1079
+ return { table: (t) => ({ conversion: Le, priority: 1 }) };
1080
+ }
1081
+ static importJSON(t) {
1082
+ const e = Et();
1083
+ return e.__rowStriping = t.rowStriping || !1, e.__colWidths = t.colWidths, e;
1084
+ }
1085
+ constructor(t) {
1086
+ super(t), this.__rowStriping = !1;
1087
+ }
1088
+ exportJSON() {
1089
+ return { ...super.exportJSON(), colWidths: this.getColWidths(), rowStriping: this.__rowStriping ? this.__rowStriping : void 0, type: "table", version: 1 };
1090
+ }
1091
+ createDOM(t, e) {
1092
+ const n = document.createElement("table"), s = document.createElement("colgroup");
1093
+ return n.appendChild(s), It(n, 0, this.getColumnCount(), this.getColWidths()), it(n, t.theme.table), this.__rowStriping && zt(n, t, !0), n;
1094
+ }
1095
+ updateDOM(t, e, n) {
1096
+ return t.__rowStriping !== this.__rowStriping && zt(e, n, this.__rowStriping), It(e, 0, this.getColumnCount(), this.getColWidths()), !1;
1097
+ }
1098
+ exportDOM(t) {
1099
+ return { ...super.exportDOM(t), after: (e) => {
1100
+ if (e) {
1101
+ const n = e.cloneNode(), s = document.createElement("colgroup"), o = document.createElement("tbody");
1102
+ if (ee(e)) {
1103
+ const c = e.querySelectorAll("col");
1104
+ s.append(...c);
1105
+ const u = e.querySelectorAll("tr");
1106
+ o.append(...u);
1107
+ }
1108
+ return n.replaceChildren(s, o), n;
1109
+ }
1110
+ } };
1111
+ }
1112
+ canBeEmpty() {
1113
+ return !1;
1114
+ }
1115
+ isShadowRoot() {
1116
+ return !0;
1117
+ }
1118
+ getCordsFromCellNode(t, e) {
1119
+ const { rows: n, domRows: s } = e;
1120
+ for (let o = 0; o < n; o++) {
1121
+ const c = s[o];
1122
+ if (c == null) continue;
1123
+ const u = c.findIndex((h) => {
1124
+ if (!h) return;
1125
+ const { elem: g } = h;
1126
+ return X(g) === t;
1127
+ });
1128
+ if (u !== -1) return { x: u, y: o };
1129
+ }
1130
+ throw new Error("Cell not found in table.");
1131
+ }
1132
+ getDOMCellFromCords(t, e, n) {
1133
+ const { domRows: s } = n, o = s[e];
1134
+ if (o == null) return null;
1135
+ const c = o[t < o.length ? t : o.length - 1];
1136
+ return c ?? null;
1137
+ }
1138
+ getDOMCellFromCordsOrThrow(t, e, n) {
1139
+ const s = this.getDOMCellFromCords(t, e, n);
1140
+ if (!s) throw new Error("Cell not found at cords.");
1141
+ return s;
1142
+ }
1143
+ getCellNodeFromCords(t, e, n) {
1144
+ const s = this.getDOMCellFromCords(t, e, n);
1145
+ if (s == null) return null;
1146
+ const o = X(s.elem);
1147
+ return f(o) ? o : null;
1148
+ }
1149
+ getCellNodeFromCordsOrThrow(t, e, n) {
1150
+ const s = this.getCellNodeFromCords(t, e, n);
1151
+ if (!s) throw new Error("Node at cords not TableCellNode.");
1152
+ return s;
1153
+ }
1154
+ getRowStriping() {
1155
+ return !!this.getLatest().__rowStriping;
1156
+ }
1157
+ setRowStriping(t) {
1158
+ this.getWritable().__rowStriping = t;
1159
+ }
1160
+ canSelectBefore() {
1161
+ return !0;
1162
+ }
1163
+ canIndent() {
1164
+ return !1;
1165
+ }
1166
+ getColumnCount() {
1167
+ const t = this.getFirstChild();
1168
+ if (!t) return 0;
1169
+ let e = 0;
1170
+ return t.getChildren().forEach((n) => {
1171
+ f(n) && (e += n.getColSpan());
1172
+ }), e;
1173
+ }
1174
+ }
1175
+ function Le(r) {
1176
+ const t = Et();
1177
+ r.hasAttribute("data-lexical-row-striping") && t.setRowStriping(!0);
1178
+ const e = r.querySelector(":scope > colgroup");
1179
+ if (e) {
1180
+ let n = [];
1181
+ for (const s of e.querySelectorAll(":scope > col")) {
1182
+ const o = s.style.width;
1183
+ if (!o || !Nt.test(o)) {
1184
+ n = void 0;
1185
+ break;
1186
+ }
1187
+ n.push(parseFloat(o));
1188
+ }
1189
+ n && t.setColWidths(n);
1190
+ }
1191
+ return { node: t };
1192
+ }
1193
+ function Et() {
1194
+ return _t(new mt());
1195
+ }
1196
+ function T(r) {
1197
+ return r instanceof mt;
1198
+ }
1199
+ export {
1200
+ je as C,
1201
+ $ as F,
1202
+ De as K,
1203
+ qe as T,
1204
+ Ve as U,
1205
+ vt as a,
1206
+ T as b,
1207
+ gt as c,
1208
+ Ye as d,
1209
+ at as e,
1210
+ Xt as f,
1211
+ Xe as g,
1212
+ W as h,
1213
+ ot as k,
1214
+ Je as m,
1215
+ xt as n,
1216
+ f as o,
1217
+ Pe as p,
1218
+ Ue as r,
1219
+ mt as u
1220
+ };
1221
+ //# sourceMappingURL=LexicalTable.prod-DEA4KRzX.js.map