@lunejs/admin-ui 0.1.4 → 0.2.0

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 (91) hide show
  1. package/dist/_virtual/index10.js +5 -2
  2. package/dist/_virtual/index11.js +4 -0
  3. package/dist/_virtual/index6.js +3 -3
  4. package/dist/_virtual/index8.js +3 -5
  5. package/dist/lib/api/fetchers/gql-fetcher.js +6 -6
  6. package/dist/lib/collections/components/collection-details/cards/general-card.js +20 -14
  7. package/dist/lib/custom-fields/components/fields/color.js +3 -3
  8. package/dist/lib/dashboard/pages/dashboard-page.js +5 -5
  9. package/dist/lib/product/components/product-details/cards/general-product-card.js +18 -12
  10. package/dist/node_modules/@tiptap/core/dist/index.js +3562 -0
  11. package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +17 -0
  12. package/dist/node_modules/@tiptap/extension-bold/dist/index.js +80 -0
  13. package/dist/node_modules/@tiptap/extension-document/dist/index.js +13 -0
  14. package/dist/node_modules/@tiptap/extension-heading/dist/index.js +64 -0
  15. package/dist/node_modules/@tiptap/extension-italic/dist/index.js +78 -0
  16. package/dist/node_modules/@tiptap/extension-link/dist/index.js +305 -0
  17. package/dist/node_modules/@tiptap/extension-list/dist/index.js +713 -0
  18. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +42 -0
  19. package/dist/node_modules/@tiptap/extension-table/dist/index.js +380 -0
  20. package/dist/node_modules/@tiptap/extension-text/dist/index.js +14 -0
  21. package/dist/node_modules/@tiptap/extension-text-style/dist/index.js +240 -0
  22. package/dist/node_modules/@tiptap/extension-underline/dist/index.js +66 -0
  23. package/dist/node_modules/@tiptap/react/dist/index.js +481 -0
  24. package/dist/node_modules/eventemitter3/index.js +1 -1
  25. package/dist/node_modules/eventemitter3/index2.js +1 -1
  26. package/dist/node_modules/fast-equals/dist/es/index.js +324 -0
  27. package/dist/node_modules/linkifyjs/dist/linkify.js +707 -0
  28. package/dist/node_modules/lucide-react/dist/esm/icons/baseline.js +10 -0
  29. package/dist/node_modules/lucide-react/dist/esm/icons/between-horizontal-end.js +10 -0
  30. package/dist/node_modules/lucide-react/dist/esm/icons/between-vertical-end.js +10 -0
  31. package/dist/node_modules/lucide-react/dist/esm/icons/bold.js +11 -0
  32. package/dist/node_modules/lucide-react/dist/esm/icons/grid-2x2-plus.js +16 -0
  33. package/dist/node_modules/lucide-react/dist/esm/icons/grid-2x2-x.js +16 -0
  34. package/dist/node_modules/lucide-react/dist/esm/icons/italic.js +10 -0
  35. package/dist/node_modules/lucide-react/dist/esm/icons/link.js +9 -0
  36. package/dist/node_modules/lucide-react/dist/esm/icons/list-ordered.js +13 -0
  37. package/dist/node_modules/lucide-react/dist/esm/icons/table-columns-split.js +18 -0
  38. package/dist/node_modules/lucide-react/dist/esm/icons/table-rows-split.js +18 -0
  39. package/dist/node_modules/lucide-react/dist/esm/icons/table.js +11 -0
  40. package/dist/node_modules/lucide-react/dist/esm/icons/underline.js +9 -0
  41. package/dist/node_modules/orderedmap/dist/index.js +103 -0
  42. package/dist/node_modules/prosemirror-commands/dist/index.js +388 -0
  43. package/dist/node_modules/prosemirror-keymap/dist/index.js +62 -0
  44. package/dist/node_modules/prosemirror-model/dist/index.js +2733 -0
  45. package/dist/node_modules/prosemirror-schema-list/dist/index.js +88 -0
  46. package/dist/node_modules/prosemirror-state/dist/index.js +822 -0
  47. package/dist/node_modules/prosemirror-tables/dist/index.js +1446 -0
  48. package/dist/node_modules/prosemirror-transform/dist/index.js +1520 -0
  49. package/dist/node_modules/prosemirror-view/dist/index.js +3772 -0
  50. package/dist/node_modules/react-is/index.js +1 -1
  51. package/dist/node_modules/recharts/es6/util/Events.js +1 -1
  52. package/dist/node_modules/recharts/es6/util/ReactUtils.js +1 -1
  53. package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
  54. package/dist/node_modules/w3c-keyname/index.js +93 -0
  55. package/dist/packages/lune-ui/dist/_virtual/index3.js +2 -5
  56. package/dist/packages/lune-ui/dist/_virtual/index6.js +5 -2
  57. package/dist/packages/lune-ui/dist/components/popover.js +15 -11
  58. package/dist/packages/lune-ui/dist/components/select.js +6 -6
  59. package/dist/packages/lune-ui/dist/form/form-date-picker.js +2 -2
  60. package/dist/packages/lune-ui/dist/form/form.js +4 -4
  61. package/dist/packages/lune-ui/dist/node_modules/@radix-ui/react-popover/dist/index.js +39 -38
  62. package/dist/packages/lune-ui/dist/node_modules/prop-types/index.js +1 -1
  63. package/dist/packages/lune-ui/dist/packages/lune-ui/node_modules/recharts/es6/util/Events.js +1 -1
  64. package/dist/shared/components/color-picker/color-picker.d.ts +2 -1
  65. package/dist/shared/components/color-picker/color-picker.js +11 -11
  66. package/dist/shared/components/data-table/data-table-filter.js +4 -4
  67. package/dist/shared/components/rich-editor/rich-editor.d.ts +6 -0
  68. package/dist/shared/components/rich-editor/rich-editor.js +93 -0
  69. package/dist/shared/components/rich-editor/toolbar/bold/rich-editor-toolbar-bold.d.ts +1 -0
  70. package/dist/shared/components/rich-editor/toolbar/bold/rich-editor-toolbar-bold.js +65 -0
  71. package/dist/shared/components/rich-editor/toolbar/color/rich-editor-toolbar-color.d.ts +1 -0
  72. package/dist/shared/components/rich-editor/toolbar/color/rich-editor-toolbar-color.js +65 -0
  73. package/dist/shared/components/rich-editor/toolbar/heading/rich-editor-toolbar-heading.d.ts +1 -0
  74. package/dist/shared/components/rich-editor/toolbar/heading/rich-editor-toolbar-heading.js +114 -0
  75. package/dist/shared/components/rich-editor/toolbar/italic/rich-editor-toolbar-italic.d.ts +1 -0
  76. package/dist/shared/components/rich-editor/toolbar/italic/rich-editor-toolbar-italic.js +65 -0
  77. package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link-form.d.ts +2 -0
  78. package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link-form.js +103 -0
  79. package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link.d.ts +1 -0
  80. package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link.js +63 -0
  81. package/dist/shared/components/rich-editor/toolbar/ol-list/rich-editor-toolbar-ul-list.d.ts +1 -0
  82. package/dist/shared/components/rich-editor/toolbar/ol-list/rich-editor-toolbar-ul-list.js +65 -0
  83. package/dist/shared/components/rich-editor/toolbar/table/rich-editor-toolbar-table.d.ts +1 -0
  84. package/dist/shared/components/rich-editor/toolbar/table/rich-editor-toolbar-table.js +107 -0
  85. package/dist/shared/components/rich-editor/toolbar/toolbar.d.ts +1 -0
  86. package/dist/shared/components/rich-editor/toolbar/toolbar.js +64 -0
  87. package/dist/shared/components/rich-editor/toolbar/ul-list/rich-editor-toolbar-ul-list.d.ts +1 -0
  88. package/dist/shared/components/rich-editor/toolbar/ul-list/rich-editor-toolbar-ul-list.js +65 -0
  89. package/dist/shared/components/rich-editor/toolbar/underline/rich-editor-toolbar-underline.d.ts +1 -0
  90. package/dist/shared/components/rich-editor/toolbar/underline/rich-editor-toolbar-underline.js +65 -0
  91. package/package.json +6 -1
@@ -0,0 +1,1446 @@
1
+ import { PluginKey as Z, Selection as M, SelectionRange as ye, TextSelection as E, Plugin as fe, NodeSelection as Se } from "../../prosemirror-state/dist/index.js";
2
+ import { Fragment as R, Slice as N } from "../../prosemirror-model/dist/index.js";
3
+ import { DecorationSet as X, Decoration as q } from "../../prosemirror-view/dist/index.js";
4
+ import { keydownHandler as Ae } from "../../prosemirror-keymap/dist/index.js";
5
+ import { Transform as Re } from "../../prosemirror-transform/dist/index.js";
6
+ let U, J;
7
+ if (typeof WeakMap < "u") {
8
+ let t = /* @__PURE__ */ new WeakMap();
9
+ U = (e) => t.get(e), J = (e, o) => (t.set(e, o), o);
10
+ } else {
11
+ const t = [];
12
+ let o = 0;
13
+ U = (n) => {
14
+ for (let l = 0; l < t.length; l += 2) if (t[l] == n) return t[l + 1];
15
+ }, J = (n, l) => (o == 10 && (o = 0), t[o++] = n, t[o++] = l);
16
+ }
17
+ var C = class {
18
+ constructor(t, e, o, n) {
19
+ this.width = t, this.height = e, this.map = o, this.problems = n;
20
+ }
21
+ findCell(t) {
22
+ for (let e = 0; e < this.map.length; e++) {
23
+ const o = this.map[e];
24
+ if (o != t) continue;
25
+ const n = e % this.width, l = e / this.width | 0;
26
+ let r = n + 1, s = l + 1;
27
+ for (let c = 1; r < this.width && this.map[e + c] == o; c++) r++;
28
+ for (let c = 1; s < this.height && this.map[e + this.width * c] == o; c++) s++;
29
+ return {
30
+ left: n,
31
+ top: l,
32
+ right: r,
33
+ bottom: s
34
+ };
35
+ }
36
+ throw new RangeError(`No cell with offset ${t} found`);
37
+ }
38
+ colCount(t) {
39
+ for (let e = 0; e < this.map.length; e++) if (this.map[e] == t) return e % this.width;
40
+ throw new RangeError(`No cell with offset ${t} found`);
41
+ }
42
+ nextCell(t, e, o) {
43
+ const { left: n, right: l, top: r, bottom: s } = this.findCell(t);
44
+ return e == "horiz" ? (o < 0 ? n == 0 : l == this.width) ? null : this.map[r * this.width + (o < 0 ? n - 1 : l)] : (o < 0 ? r == 0 : s == this.height) ? null : this.map[n + this.width * (o < 0 ? r - 1 : s)];
45
+ }
46
+ rectBetween(t, e) {
47
+ const { left: o, right: n, top: l, bottom: r } = this.findCell(t), { left: s, right: c, top: i, bottom: a } = this.findCell(e);
48
+ return {
49
+ left: Math.min(o, s),
50
+ top: Math.min(l, i),
51
+ right: Math.max(n, c),
52
+ bottom: Math.max(r, a)
53
+ };
54
+ }
55
+ cellsInRect(t) {
56
+ const e = [], o = {};
57
+ for (let n = t.top; n < t.bottom; n++) for (let l = t.left; l < t.right; l++) {
58
+ const r = n * this.width + l, s = this.map[r];
59
+ o[s] || (o[s] = !0, !(l == t.left && l && this.map[r - 1] == s || n == t.top && n && this.map[r - this.width] == s) && e.push(s));
60
+ }
61
+ return e;
62
+ }
63
+ positionAt(t, e, o) {
64
+ for (let n = 0, l = 0; ; n++) {
65
+ const r = l + o.child(n).nodeSize;
66
+ if (n == t) {
67
+ let s = e + t * this.width;
68
+ const c = (t + 1) * this.width;
69
+ for (; s < c && this.map[s] < l; ) s++;
70
+ return s == c ? r - 1 : this.map[s];
71
+ }
72
+ l = r;
73
+ }
74
+ }
75
+ static get(t) {
76
+ return U(t) || J(t, xe(t));
77
+ }
78
+ };
79
+ function xe(t) {
80
+ if (t.type.spec.tableRole != "table") throw new RangeError("Not a table node: " + t.type.name);
81
+ const e = ve(t), o = t.childCount, n = [];
82
+ let l = 0, r = null;
83
+ const s = [];
84
+ for (let a = 0, d = e * o; a < d; a++) n[a] = 0;
85
+ for (let a = 0, d = 0; a < o; a++) {
86
+ const f = t.child(a);
87
+ d++;
88
+ for (let p = 0; ; p++) {
89
+ for (; l < n.length && n[l] != 0; ) l++;
90
+ if (p == f.childCount) break;
91
+ const m = f.child(p), { colspan: g, rowspan: b, colwidth: B } = m.attrs;
92
+ for (let H = 0; H < b; H++) {
93
+ if (H + a >= o) {
94
+ (r || (r = [])).push({
95
+ type: "overlong_rowspan",
96
+ pos: d,
97
+ n: b - H
98
+ });
99
+ break;
100
+ }
101
+ const j = l + H * e;
102
+ for (let k = 0; k < g; k++) {
103
+ n[j + k] == 0 ? n[j + k] = d : (r || (r = [])).push({
104
+ type: "collision",
105
+ row: a,
106
+ pos: d,
107
+ n: g - k
108
+ });
109
+ const $ = B && B[k];
110
+ if ($) {
111
+ const L = (j + k) % e * 2, K = s[L];
112
+ K == null || K != $ && s[L + 1] == 1 ? (s[L] = $, s[L + 1] = 1) : K == $ && s[L + 1]++;
113
+ }
114
+ }
115
+ }
116
+ l += g, d += m.nodeSize;
117
+ }
118
+ const u = (a + 1) * e;
119
+ let h = 0;
120
+ for (; l < u; ) n[l++] == 0 && h++;
121
+ h && (r || (r = [])).push({
122
+ type: "missing",
123
+ row: a,
124
+ n: h
125
+ }), d++;
126
+ }
127
+ (e === 0 || o === 0) && (r || (r = [])).push({ type: "zero_sized" });
128
+ const c = new C(e, o, n, r);
129
+ let i = !1;
130
+ for (let a = 0; !i && a < s.length; a += 2) s[a] != null && s[a + 1] < o && (i = !0);
131
+ return i && Me(c, s, t), c;
132
+ }
133
+ function ve(t) {
134
+ let e = -1, o = !1;
135
+ for (let n = 0; n < t.childCount; n++) {
136
+ const l = t.child(n);
137
+ let r = 0;
138
+ if (o) for (let s = 0; s < n; s++) {
139
+ const c = t.child(s);
140
+ for (let i = 0; i < c.childCount; i++) {
141
+ const a = c.child(i);
142
+ s + a.attrs.rowspan > n && (r += a.attrs.colspan);
143
+ }
144
+ }
145
+ for (let s = 0; s < l.childCount; s++) {
146
+ const c = l.child(s);
147
+ r += c.attrs.colspan, c.attrs.rowspan > 1 && (o = !0);
148
+ }
149
+ e == -1 ? e = r : e != r && (e = Math.max(e, r));
150
+ }
151
+ return e;
152
+ }
153
+ function Me(t, e, o) {
154
+ t.problems || (t.problems = []);
155
+ const n = {};
156
+ for (let l = 0; l < t.map.length; l++) {
157
+ const r = t.map[l];
158
+ if (n[r]) continue;
159
+ n[r] = !0;
160
+ const s = o.nodeAt(r);
161
+ if (!s) throw new RangeError(`No cell with offset ${r} found`);
162
+ let c = null;
163
+ const i = s.attrs;
164
+ for (let a = 0; a < i.colspan; a++) {
165
+ const d = e[(l + a) % t.width * 2];
166
+ d != null && (!i.colwidth || i.colwidth[a] != d) && ((c || (c = ze(i)))[a] = d);
167
+ }
168
+ c && t.problems.unshift({
169
+ type: "colwidth mismatch",
170
+ pos: r,
171
+ colwidth: c
172
+ });
173
+ }
174
+ }
175
+ function ze(t) {
176
+ if (t.colwidth) return t.colwidth.slice();
177
+ const e = [];
178
+ for (let o = 0; o < t.colspan; o++) e.push(0);
179
+ return e;
180
+ }
181
+ function y(t) {
182
+ let e = t.cached.tableNodeTypes;
183
+ if (!e) {
184
+ e = t.cached.tableNodeTypes = {};
185
+ for (const o in t.nodes) {
186
+ const n = t.nodes[o], l = n.spec.tableRole;
187
+ l && (e[l] = n);
188
+ }
189
+ }
190
+ return e;
191
+ }
192
+ const z = new Z("selectingCells");
193
+ function T(t) {
194
+ for (let e = t.depth - 1; e > 0; e--) if (t.node(e).type.spec.tableRole == "row") return t.node(0).resolve(t.before(e + 1));
195
+ return null;
196
+ }
197
+ function Ne(t) {
198
+ for (let e = t.depth; e > 0; e--) {
199
+ const o = t.node(e).type.spec.tableRole;
200
+ if (o === "cell" || o === "header_cell") return t.node(e);
201
+ }
202
+ return null;
203
+ }
204
+ function A(t) {
205
+ const e = t.selection.$head;
206
+ for (let o = e.depth; o > 0; o--) if (e.node(o).type.spec.tableRole == "row") return !0;
207
+ return !1;
208
+ }
209
+ function O(t) {
210
+ const e = t.selection;
211
+ if ("$anchorCell" in e && e.$anchorCell) return e.$anchorCell.pos > e.$headCell.pos ? e.$anchorCell : e.$headCell;
212
+ if ("node" in e && e.node && e.node.type.spec.tableRole == "cell") return e.$anchor;
213
+ const o = T(e.$head) || ke(e.$head);
214
+ if (o) return o;
215
+ throw new RangeError(`No cell found around position ${e.head}`);
216
+ }
217
+ function ke(t) {
218
+ for (let e = t.nodeAfter, o = t.pos; e; e = e.firstChild, o++) {
219
+ const n = e.type.spec.tableRole;
220
+ if (n == "cell" || n == "header_cell") return t.doc.resolve(o);
221
+ }
222
+ for (let e = t.nodeBefore, o = t.pos; e; e = e.lastChild, o--) {
223
+ const n = e.type.spec.tableRole;
224
+ if (n == "cell" || n == "header_cell") return t.doc.resolve(o - e.nodeSize);
225
+ }
226
+ }
227
+ function Y(t) {
228
+ return t.parent.type.spec.tableRole == "row" && !!t.nodeAfter;
229
+ }
230
+ function Ee(t) {
231
+ return t.node(0).resolve(t.pos + t.nodeAfter.nodeSize);
232
+ }
233
+ function ee(t, e) {
234
+ return t.depth == e.depth && t.pos >= e.start(-1) && t.pos <= e.end(-1);
235
+ }
236
+ function ue(t, e, o) {
237
+ const n = t.node(-1), l = C.get(n), r = t.start(-1), s = l.nextCell(t.pos - r, e, o);
238
+ return s == null ? null : t.node(0).resolve(r + s);
239
+ }
240
+ function D(t, e, o = 1) {
241
+ const n = {
242
+ ...t,
243
+ colspan: t.colspan - o
244
+ };
245
+ return n.colwidth && (n.colwidth = n.colwidth.slice(), n.colwidth.splice(e, o), n.colwidth.some((l) => l > 0) || (n.colwidth = null)), n;
246
+ }
247
+ function he(t, e, o = 1) {
248
+ const n = {
249
+ ...t,
250
+ colspan: t.colspan + o
251
+ };
252
+ if (n.colwidth) {
253
+ n.colwidth = n.colwidth.slice();
254
+ for (let l = 0; l < o; l++) n.colwidth.splice(e, 0, 0);
255
+ }
256
+ return n;
257
+ }
258
+ function Te(t, e, o) {
259
+ const n = y(e.type.schema).header_cell;
260
+ for (let l = 0; l < t.height; l++) if (e.nodeAt(t.map[o + l * t.width]).type != n) return !1;
261
+ return !0;
262
+ }
263
+ var w = class v extends M {
264
+ constructor(e, o = e) {
265
+ const n = e.node(-1), l = C.get(n), r = e.start(-1), s = l.rectBetween(e.pos - r, o.pos - r), c = e.node(0), i = l.cellsInRect(s).filter((d) => d != o.pos - r);
266
+ i.unshift(o.pos - r);
267
+ const a = i.map((d) => {
268
+ const f = n.nodeAt(d);
269
+ if (!f) throw new RangeError(`No cell with offset ${d} found`);
270
+ const u = r + d + 1;
271
+ return new ye(c.resolve(u), c.resolve(u + f.content.size));
272
+ });
273
+ super(a[0].$from, a[0].$to, a), this.$anchorCell = e, this.$headCell = o;
274
+ }
275
+ map(e, o) {
276
+ const n = e.resolve(o.map(this.$anchorCell.pos)), l = e.resolve(o.map(this.$headCell.pos));
277
+ if (Y(n) && Y(l) && ee(n, l)) {
278
+ const r = this.$anchorCell.node(-1) != n.node(-1);
279
+ return r && this.isRowSelection() ? v.rowSelection(n, l) : r && this.isColSelection() ? v.colSelection(n, l) : new v(n, l);
280
+ }
281
+ return E.between(n, l);
282
+ }
283
+ content() {
284
+ const e = this.$anchorCell.node(-1), o = C.get(e), n = this.$anchorCell.start(-1), l = o.rectBetween(this.$anchorCell.pos - n, this.$headCell.pos - n), r = {}, s = [];
285
+ for (let i = l.top; i < l.bottom; i++) {
286
+ const a = [];
287
+ for (let d = i * o.width + l.left, f = l.left; f < l.right; f++, d++) {
288
+ const u = o.map[d];
289
+ if (r[u]) continue;
290
+ r[u] = !0;
291
+ const h = o.findCell(u);
292
+ let p = e.nodeAt(u);
293
+ if (!p) throw new RangeError(`No cell with offset ${u} found`);
294
+ const m = l.left - h.left, g = h.right - l.right;
295
+ if (m > 0 || g > 0) {
296
+ let b = p.attrs;
297
+ if (m > 0 && (b = D(b, 0, m)), g > 0 && (b = D(b, b.colspan - g, g)), h.left < l.left) {
298
+ if (p = p.type.createAndFill(b), !p) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`);
299
+ } else p = p.type.create(b, p.content);
300
+ }
301
+ if (h.top < l.top || h.bottom > l.bottom) {
302
+ const b = {
303
+ ...p.attrs,
304
+ rowspan: Math.min(h.bottom, l.bottom) - Math.max(h.top, l.top)
305
+ };
306
+ h.top < l.top ? p = p.type.createAndFill(b) : p = p.type.create(b, p.content);
307
+ }
308
+ a.push(p);
309
+ }
310
+ s.push(e.child(i).copy(R.from(a)));
311
+ }
312
+ const c = this.isColSelection() && this.isRowSelection() ? e : s;
313
+ return new N(R.from(c), 1, 1);
314
+ }
315
+ replace(e, o = N.empty) {
316
+ const n = e.steps.length, l = this.ranges;
317
+ for (let s = 0; s < l.length; s++) {
318
+ const { $from: c, $to: i } = l[s], a = e.mapping.slice(n);
319
+ e.replace(a.map(c.pos), a.map(i.pos), s ? N.empty : o);
320
+ }
321
+ const r = M.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)), -1);
322
+ r && e.setSelection(r);
323
+ }
324
+ replaceWith(e, o) {
325
+ this.replace(e, new N(R.from(o), 0, 0));
326
+ }
327
+ forEachCell(e) {
328
+ const o = this.$anchorCell.node(-1), n = C.get(o), l = this.$anchorCell.start(-1), r = n.cellsInRect(n.rectBetween(this.$anchorCell.pos - l, this.$headCell.pos - l));
329
+ for (let s = 0; s < r.length; s++) e(o.nodeAt(r[s]), l + r[s]);
330
+ }
331
+ isColSelection() {
332
+ const e = this.$anchorCell.index(-1), o = this.$headCell.index(-1);
333
+ if (Math.min(e, o) > 0) return !1;
334
+ const n = e + this.$anchorCell.nodeAfter.attrs.rowspan, l = o + this.$headCell.nodeAfter.attrs.rowspan;
335
+ return Math.max(n, l) == this.$headCell.node(-1).childCount;
336
+ }
337
+ static colSelection(e, o = e) {
338
+ const n = e.node(-1), l = C.get(n), r = e.start(-1), s = l.findCell(e.pos - r), c = l.findCell(o.pos - r), i = e.node(0);
339
+ return s.top <= c.top ? (s.top > 0 && (e = i.resolve(r + l.map[s.left])), c.bottom < l.height && (o = i.resolve(r + l.map[l.width * (l.height - 1) + c.right - 1]))) : (c.top > 0 && (o = i.resolve(r + l.map[c.left])), s.bottom < l.height && (e = i.resolve(r + l.map[l.width * (l.height - 1) + s.right - 1]))), new v(e, o);
340
+ }
341
+ isRowSelection() {
342
+ const e = this.$anchorCell.node(-1), o = C.get(e), n = this.$anchorCell.start(-1), l = o.colCount(this.$anchorCell.pos - n), r = o.colCount(this.$headCell.pos - n);
343
+ if (Math.min(l, r) > 0) return !1;
344
+ const s = l + this.$anchorCell.nodeAfter.attrs.colspan, c = r + this.$headCell.nodeAfter.attrs.colspan;
345
+ return Math.max(s, c) == o.width;
346
+ }
347
+ eq(e) {
348
+ return e instanceof v && e.$anchorCell.pos == this.$anchorCell.pos && e.$headCell.pos == this.$headCell.pos;
349
+ }
350
+ static rowSelection(e, o = e) {
351
+ const n = e.node(-1), l = C.get(n), r = e.start(-1), s = l.findCell(e.pos - r), c = l.findCell(o.pos - r), i = e.node(0);
352
+ return s.left <= c.left ? (s.left > 0 && (e = i.resolve(r + l.map[s.top * l.width])), c.right < l.width && (o = i.resolve(r + l.map[l.width * (c.top + 1) - 1]))) : (c.left > 0 && (o = i.resolve(r + l.map[c.top * l.width])), s.right < l.width && (e = i.resolve(r + l.map[l.width * (s.top + 1) - 1]))), new v(e, o);
353
+ }
354
+ toJSON() {
355
+ return {
356
+ type: "cell",
357
+ anchor: this.$anchorCell.pos,
358
+ head: this.$headCell.pos
359
+ };
360
+ }
361
+ static fromJSON(e, o) {
362
+ return new v(e.resolve(o.anchor), e.resolve(o.head));
363
+ }
364
+ static create(e, o, n = o) {
365
+ return new v(e.resolve(o), e.resolve(n));
366
+ }
367
+ getBookmark() {
368
+ return new De(this.$anchorCell.pos, this.$headCell.pos);
369
+ }
370
+ };
371
+ w.prototype.visible = !1;
372
+ M.jsonID("cell", w);
373
+ var De = class pe {
374
+ constructor(e, o) {
375
+ this.anchor = e, this.head = o;
376
+ }
377
+ map(e) {
378
+ return new pe(e.map(this.anchor), e.map(this.head));
379
+ }
380
+ resolve(e) {
381
+ const o = e.resolve(this.anchor), n = e.resolve(this.head);
382
+ return o.parent.type.spec.tableRole == "row" && n.parent.type.spec.tableRole == "row" && o.index() < o.parent.childCount && n.index() < n.parent.childCount && ee(o, n) ? new w(o, n) : M.near(n, 1);
383
+ }
384
+ };
385
+ function Be(t) {
386
+ if (!(t.selection instanceof w)) return null;
387
+ const e = [];
388
+ return t.selection.forEachCell((o, n) => {
389
+ e.push(q.node(n, n + o.nodeSize, { class: "selectedCell" }));
390
+ }), X.create(t.doc, e);
391
+ }
392
+ function He({ $from: t, $to: e }) {
393
+ if (t.pos == e.pos || t.pos < e.pos - 6) return !1;
394
+ let o = t.pos, n = e.pos, l = t.depth;
395
+ for (; l >= 0 && !(t.after(l + 1) < t.end(l)); l--, o++) ;
396
+ for (let r = e.depth; r >= 0 && !(e.before(r + 1) > e.start(r)); r--, n--) ;
397
+ return o == n && /row|table/.test(t.node(l).type.spec.tableRole);
398
+ }
399
+ function Le({ $from: t, $to: e }) {
400
+ let o, n;
401
+ for (let l = t.depth; l > 0; l--) {
402
+ const r = t.node(l);
403
+ if (r.type.spec.tableRole === "cell" || r.type.spec.tableRole === "header_cell") {
404
+ o = r;
405
+ break;
406
+ }
407
+ }
408
+ for (let l = e.depth; l > 0; l--) {
409
+ const r = e.node(l);
410
+ if (r.type.spec.tableRole === "cell" || r.type.spec.tableRole === "header_cell") {
411
+ n = r;
412
+ break;
413
+ }
414
+ }
415
+ return o !== n && e.parentOffset === 0;
416
+ }
417
+ function $e(t, e, o) {
418
+ const n = (e || t).selection, l = (e || t).doc;
419
+ let r, s;
420
+ if (n instanceof Se && (s = n.node.type.spec.tableRole)) {
421
+ if (s == "cell" || s == "header_cell") r = w.create(l, n.from);
422
+ else if (s == "row") {
423
+ const c = l.resolve(n.from + 1);
424
+ r = w.rowSelection(c, c);
425
+ } else if (!o) {
426
+ const c = C.get(n.node), i = n.from + 1, a = i + c.map[c.width * c.height - 1];
427
+ r = w.create(l, i + 1, a);
428
+ }
429
+ } else n instanceof E && He(n) ? r = E.create(l, n.from) : n instanceof E && Le(n) && (r = E.create(l, n.$from.start(), n.$from.end()));
430
+ return r && (e || (e = t.tr)).setSelection(r), e;
431
+ }
432
+ const Fe = new Z("fix-tables");
433
+ function me(t, e, o, n) {
434
+ const l = t.childCount, r = e.childCount;
435
+ e: for (let s = 0, c = 0; s < r; s++) {
436
+ const i = e.child(s);
437
+ for (let a = c, d = Math.min(l, s + 3); a < d; a++) if (t.child(a) == i) {
438
+ c = a + 1, o += i.nodeSize;
439
+ continue e;
440
+ }
441
+ n(i, o), c < l && t.child(c).sameMarkup(i) ? me(t.child(c), i, o + 1, n) : i.nodesBetween(0, i.content.size, n, o + 1), o += i.nodeSize;
442
+ }
443
+ }
444
+ function Pe(t, e) {
445
+ let o;
446
+ const n = (l, r) => {
447
+ l.type.spec.tableRole == "table" && (o = We(t, l, r, o));
448
+ };
449
+ return e ? e.doc != t.doc && me(e.doc, t.doc, 0, n) : t.doc.descendants(n), o;
450
+ }
451
+ function We(t, e, o, n) {
452
+ const l = C.get(e);
453
+ if (!l.problems) return n;
454
+ n || (n = t.tr);
455
+ const r = [];
456
+ for (let i = 0; i < l.height; i++) r.push(0);
457
+ for (let i = 0; i < l.problems.length; i++) {
458
+ const a = l.problems[i];
459
+ if (a.type == "collision") {
460
+ const d = e.nodeAt(a.pos);
461
+ if (!d) continue;
462
+ const f = d.attrs;
463
+ for (let u = 0; u < f.rowspan; u++) r[a.row + u] += a.n;
464
+ n.setNodeMarkup(n.mapping.map(o + 1 + a.pos), null, D(f, f.colspan - a.n, a.n));
465
+ } else if (a.type == "missing") r[a.row] += a.n;
466
+ else if (a.type == "overlong_rowspan") {
467
+ const d = e.nodeAt(a.pos);
468
+ if (!d) continue;
469
+ n.setNodeMarkup(n.mapping.map(o + 1 + a.pos), null, {
470
+ ...d.attrs,
471
+ rowspan: d.attrs.rowspan - a.n
472
+ });
473
+ } else if (a.type == "colwidth mismatch") {
474
+ const d = e.nodeAt(a.pos);
475
+ if (!d) continue;
476
+ n.setNodeMarkup(n.mapping.map(o + 1 + a.pos), null, {
477
+ ...d.attrs,
478
+ colwidth: a.colwidth
479
+ });
480
+ } else if (a.type == "zero_sized") {
481
+ const d = n.mapping.map(o);
482
+ n.delete(d, d + e.nodeSize);
483
+ }
484
+ }
485
+ let s, c;
486
+ for (let i = 0; i < r.length; i++) r[i] && (s == null && (s = i), c = i);
487
+ for (let i = 0, a = o + 1; i < l.height; i++) {
488
+ const d = e.child(i), f = a + d.nodeSize, u = r[i];
489
+ if (u > 0) {
490
+ let h = "cell";
491
+ d.firstChild && (h = d.firstChild.type.spec.tableRole);
492
+ const p = [];
493
+ for (let g = 0; g < u; g++) {
494
+ const b = y(t.schema)[h].createAndFill();
495
+ b && p.push(b);
496
+ }
497
+ const m = (i == 0 || s == i - 1) && c == i ? a + 1 : f - 1;
498
+ n.insert(n.mapping.map(m), p);
499
+ }
500
+ a = f;
501
+ }
502
+ return n.setMeta(Fe, { fixTables: !0 });
503
+ }
504
+ function x(t) {
505
+ const e = t.selection, o = O(t), n = o.node(-1), l = o.start(-1), r = C.get(n);
506
+ return {
507
+ ...e instanceof w ? r.rectBetween(e.$anchorCell.pos - l, e.$headCell.pos - l) : r.findCell(o.pos - l),
508
+ tableStart: l,
509
+ map: r,
510
+ table: n
511
+ };
512
+ }
513
+ function ge(t, { map: e, tableStart: o, table: n }, l) {
514
+ let r = l > 0 ? -1 : 0;
515
+ Te(e, n, l + r) && (r = l == 0 || l == e.width ? null : 0);
516
+ for (let s = 0; s < e.height; s++) {
517
+ const c = s * e.width + l;
518
+ if (l > 0 && l < e.width && e.map[c - 1] == e.map[c]) {
519
+ const i = e.map[c], a = n.nodeAt(i);
520
+ t.setNodeMarkup(t.mapping.map(o + i), null, he(a.attrs, l - e.colCount(i))), s += a.attrs.rowspan - 1;
521
+ } else {
522
+ const i = r == null ? y(n.type.schema).cell : n.nodeAt(e.map[c + r]).type, a = e.positionAt(s, l, n);
523
+ t.insert(t.mapping.map(o + a), i.createAndFill());
524
+ }
525
+ }
526
+ return t;
527
+ }
528
+ function gt(t, e) {
529
+ if (!A(t)) return !1;
530
+ if (e) {
531
+ const o = x(t);
532
+ e(ge(t.tr, o, o.left));
533
+ }
534
+ return !0;
535
+ }
536
+ function wt(t, e) {
537
+ if (!A(t)) return !1;
538
+ if (e) {
539
+ const o = x(t);
540
+ e(ge(t.tr, o, o.right));
541
+ }
542
+ return !0;
543
+ }
544
+ function Ie(t, { map: e, table: o, tableStart: n }, l) {
545
+ const r = t.mapping.maps.length;
546
+ for (let s = 0; s < e.height; ) {
547
+ const c = s * e.width + l, i = e.map[c], a = o.nodeAt(i), d = a.attrs;
548
+ if (l > 0 && e.map[c - 1] == i || l < e.width - 1 && e.map[c + 1] == i) t.setNodeMarkup(t.mapping.slice(r).map(n + i), null, D(d, l - e.colCount(i)));
549
+ else {
550
+ const f = t.mapping.slice(r).map(n + i);
551
+ t.delete(f, f + a.nodeSize);
552
+ }
553
+ s += d.rowspan;
554
+ }
555
+ }
556
+ function Ct(t, e) {
557
+ if (!A(t)) return !1;
558
+ if (e) {
559
+ const o = x(t), n = t.tr;
560
+ if (o.left == 0 && o.right == o.map.width) return !1;
561
+ for (let l = o.right - 1; Ie(n, o, l), l != o.left; l--) {
562
+ const r = o.tableStart ? n.doc.nodeAt(o.tableStart - 1) : n.doc;
563
+ if (!r) throw new RangeError("No table found");
564
+ o.table = r, o.map = C.get(r);
565
+ }
566
+ e(n);
567
+ }
568
+ return !0;
569
+ }
570
+ function _e(t, e, o) {
571
+ var n;
572
+ const l = y(e.type.schema).header_cell;
573
+ for (let r = 0; r < t.width; r++) if (((n = e.nodeAt(t.map[r + o * t.width])) === null || n === void 0 ? void 0 : n.type) != l) return !1;
574
+ return !0;
575
+ }
576
+ function we(t, { map: e, tableStart: o, table: n }, l) {
577
+ let r = o;
578
+ for (let a = 0; a < l; a++) r += n.child(a).nodeSize;
579
+ const s = [];
580
+ let c = l > 0 ? -1 : 0;
581
+ _e(e, n, l + c) && (c = l == 0 || l == e.height ? null : 0);
582
+ for (let a = 0, d = e.width * l; a < e.width; a++, d++) if (l > 0 && l < e.height && e.map[d] == e.map[d - e.width]) {
583
+ const f = e.map[d], u = n.nodeAt(f).attrs;
584
+ t.setNodeMarkup(o + f, null, {
585
+ ...u,
586
+ rowspan: u.rowspan + 1
587
+ }), a += u.colspan - 1;
588
+ } else {
589
+ var i;
590
+ const f = c == null ? y(n.type.schema).cell : (i = n.nodeAt(e.map[d + c * e.width])) === null || i === void 0 ? void 0 : i.type, u = f?.createAndFill();
591
+ u && s.push(u);
592
+ }
593
+ return t.insert(r, y(n.type.schema).row.create(null, s)), t;
594
+ }
595
+ function bt(t, e) {
596
+ if (!A(t)) return !1;
597
+ if (e) {
598
+ const o = x(t);
599
+ e(we(t.tr, o, o.top));
600
+ }
601
+ return !0;
602
+ }
603
+ function yt(t, e) {
604
+ if (!A(t)) return !1;
605
+ if (e) {
606
+ const o = x(t);
607
+ e(we(t.tr, o, o.bottom));
608
+ }
609
+ return !0;
610
+ }
611
+ function Oe(t, { map: e, table: o, tableStart: n }, l) {
612
+ let r = 0;
613
+ for (let a = 0; a < l; a++) r += o.child(a).nodeSize;
614
+ const s = r + o.child(l).nodeSize, c = t.mapping.maps.length;
615
+ t.delete(r + n, s + n);
616
+ const i = /* @__PURE__ */ new Set();
617
+ for (let a = 0, d = l * e.width; a < e.width; a++, d++) {
618
+ const f = e.map[d];
619
+ if (!i.has(f)) {
620
+ if (i.add(f), l > 0 && f == e.map[d - e.width]) {
621
+ const u = o.nodeAt(f).attrs;
622
+ t.setNodeMarkup(t.mapping.slice(c).map(f + n), null, {
623
+ ...u,
624
+ rowspan: u.rowspan - 1
625
+ }), a += u.colspan - 1;
626
+ } else if (l < e.height && f == e.map[d + e.width]) {
627
+ const u = o.nodeAt(f), h = u.attrs, p = u.type.create({
628
+ ...h,
629
+ rowspan: u.attrs.rowspan - 1
630
+ }, u.content), m = e.positionAt(l + 1, a, o);
631
+ t.insert(t.mapping.slice(c).map(n + m), p), a += h.colspan - 1;
632
+ }
633
+ }
634
+ }
635
+ }
636
+ function St(t, e) {
637
+ if (!A(t)) return !1;
638
+ if (e) {
639
+ const o = x(t), n = t.tr;
640
+ if (o.top == 0 && o.bottom == o.map.height) return !1;
641
+ for (let l = o.bottom - 1; Oe(n, o, l), l != o.top; l--) {
642
+ const r = o.tableStart ? n.doc.nodeAt(o.tableStart - 1) : n.doc;
643
+ if (!r) throw new RangeError("No table found");
644
+ o.table = r, o.map = C.get(o.table);
645
+ }
646
+ e(n);
647
+ }
648
+ return !0;
649
+ }
650
+ function oe(t) {
651
+ const e = t.content;
652
+ return e.childCount == 1 && e.child(0).isTextblock && e.child(0).childCount == 0;
653
+ }
654
+ function je({ width: t, height: e, map: o }, n) {
655
+ let l = n.top * t + n.left, r = l, s = (n.bottom - 1) * t + n.left, c = l + (n.right - n.left - 1);
656
+ for (let i = n.top; i < n.bottom; i++) {
657
+ if (n.left > 0 && o[r] == o[r - 1] || n.right < t && o[c] == o[c + 1]) return !0;
658
+ r += t, c += t;
659
+ }
660
+ for (let i = n.left; i < n.right; i++) {
661
+ if (n.top > 0 && o[l] == o[l - t] || n.bottom < e && o[s] == o[s + t]) return !0;
662
+ l++, s++;
663
+ }
664
+ return !1;
665
+ }
666
+ function At(t, e) {
667
+ const o = t.selection;
668
+ if (!(o instanceof w) || o.$anchorCell.pos == o.$headCell.pos) return !1;
669
+ const n = x(t), { map: l } = n;
670
+ if (je(l, n)) return !1;
671
+ if (e) {
672
+ const r = t.tr, s = {};
673
+ let c = R.empty, i, a;
674
+ for (let d = n.top; d < n.bottom; d++) for (let f = n.left; f < n.right; f++) {
675
+ const u = l.map[d * l.width + f], h = n.table.nodeAt(u);
676
+ if (!(s[u] || !h))
677
+ if (s[u] = !0, i == null)
678
+ i = u, a = h;
679
+ else {
680
+ oe(h) || (c = c.append(h.content));
681
+ const p = r.mapping.map(u + n.tableStart);
682
+ r.delete(p, p + h.nodeSize);
683
+ }
684
+ }
685
+ if (i == null || a == null) return !0;
686
+ if (r.setNodeMarkup(i + n.tableStart, null, {
687
+ ...he(a.attrs, a.attrs.colspan, n.right - n.left - a.attrs.colspan),
688
+ rowspan: n.bottom - n.top
689
+ }), c.size > 0) {
690
+ const d = i + 1 + a.content.size, f = oe(a) ? i + 1 : d;
691
+ r.replaceWith(f + n.tableStart, d + n.tableStart, c);
692
+ }
693
+ r.setSelection(new w(r.doc.resolve(i + n.tableStart))), e(r);
694
+ }
695
+ return !0;
696
+ }
697
+ function Rt(t, e) {
698
+ const o = y(t.schema);
699
+ return Ke(({ node: n }) => o[n.type.spec.tableRole])(t, e);
700
+ }
701
+ function Ke(t) {
702
+ return (e, o) => {
703
+ const n = e.selection;
704
+ let l, r;
705
+ if (n instanceof w) {
706
+ if (n.$anchorCell.pos != n.$headCell.pos) return !1;
707
+ l = n.$anchorCell.nodeAfter, r = n.$anchorCell.pos;
708
+ } else {
709
+ var s;
710
+ if (l = Ne(n.$from), !l) return !1;
711
+ r = (s = T(n.$from)) === null || s === void 0 ? void 0 : s.pos;
712
+ }
713
+ if (l == null || r == null || l.attrs.colspan == 1 && l.attrs.rowspan == 1) return !1;
714
+ if (o) {
715
+ let c = l.attrs;
716
+ const i = [], a = c.colwidth;
717
+ c.rowspan > 1 && (c = {
718
+ ...c,
719
+ rowspan: 1
720
+ }), c.colspan > 1 && (c = {
721
+ ...c,
722
+ colspan: 1
723
+ });
724
+ const d = x(e), f = e.tr;
725
+ for (let h = 0; h < d.right - d.left; h++) i.push(a ? {
726
+ ...c,
727
+ colwidth: a && a[h] ? [a[h]] : null
728
+ } : c);
729
+ let u;
730
+ for (let h = d.top; h < d.bottom; h++) {
731
+ let p = d.map.positionAt(h, d.left, d.table);
732
+ h == d.top && (p += l.nodeSize);
733
+ for (let m = d.left, g = 0; m < d.right; m++, g++)
734
+ m == d.left && h == d.top || f.insert(u = f.mapping.map(p + d.tableStart, 1), t({
735
+ node: l,
736
+ row: h,
737
+ col: m
738
+ }).createAndFill(i[g]));
739
+ }
740
+ f.setNodeMarkup(r, t({
741
+ node: l,
742
+ row: d.top,
743
+ col: d.left
744
+ }), i[0]), n instanceof w && f.setSelection(new w(f.doc.resolve(n.$anchorCell.pos), u ? f.doc.resolve(u) : void 0)), o(f);
745
+ }
746
+ return !0;
747
+ };
748
+ }
749
+ function xt(t, e) {
750
+ return function(o, n) {
751
+ if (!A(o)) return !1;
752
+ const l = O(o);
753
+ if (l.nodeAfter.attrs[t] === e) return !1;
754
+ if (n) {
755
+ const r = o.tr;
756
+ o.selection instanceof w ? o.selection.forEachCell((s, c) => {
757
+ s.attrs[t] !== e && r.setNodeMarkup(c, null, {
758
+ ...s.attrs,
759
+ [t]: e
760
+ });
761
+ }) : r.setNodeMarkup(l.pos, null, {
762
+ ...l.nodeAfter.attrs,
763
+ [t]: e
764
+ }), n(r);
765
+ }
766
+ return !0;
767
+ };
768
+ }
769
+ function Ve(t) {
770
+ return function(e, o) {
771
+ if (!A(e)) return !1;
772
+ if (o) {
773
+ const n = y(e.schema), l = x(e), r = e.tr, s = l.map.cellsInRect(t == "column" ? {
774
+ left: l.left,
775
+ top: 0,
776
+ right: l.right,
777
+ bottom: l.map.height
778
+ } : t == "row" ? {
779
+ left: 0,
780
+ top: l.top,
781
+ right: l.map.width,
782
+ bottom: l.bottom
783
+ } : l), c = s.map((i) => l.table.nodeAt(i));
784
+ for (let i = 0; i < s.length; i++) c[i].type == n.header_cell && r.setNodeMarkup(l.tableStart + s[i], n.cell, c[i].attrs);
785
+ if (r.steps.length === 0) for (let i = 0; i < s.length; i++) r.setNodeMarkup(l.tableStart + s[i], n.header_cell, c[i].attrs);
786
+ o(r);
787
+ }
788
+ return !0;
789
+ };
790
+ }
791
+ function ne(t, e, o) {
792
+ const n = e.map.cellsInRect({
793
+ left: 0,
794
+ top: 0,
795
+ right: t == "row" ? e.map.width : 1,
796
+ bottom: t == "column" ? e.map.height : 1
797
+ });
798
+ for (let l = 0; l < n.length; l++) {
799
+ const r = e.table.nodeAt(n[l]);
800
+ if (r && r.type !== o.header_cell) return !1;
801
+ }
802
+ return !0;
803
+ }
804
+ function te(t, e) {
805
+ return e = e || { useDeprecatedLogic: !1 }, e.useDeprecatedLogic ? Ve(t) : function(o, n) {
806
+ if (!A(o)) return !1;
807
+ if (n) {
808
+ const l = y(o.schema), r = x(o), s = o.tr, c = ne("row", r, l), i = ne("column", r, l), a = (t === "column" ? c : t === "row" && i) ? 1 : 0, d = t == "column" ? {
809
+ left: 0,
810
+ top: a,
811
+ right: 1,
812
+ bottom: r.map.height
813
+ } : t == "row" ? {
814
+ left: a,
815
+ top: 0,
816
+ right: r.map.width,
817
+ bottom: 1
818
+ } : r, f = t == "column" ? i ? l.cell : l.header_cell : t == "row" ? c ? l.cell : l.header_cell : l.cell;
819
+ r.map.cellsInRect(d).forEach((u) => {
820
+ const h = u + r.tableStart, p = s.doc.nodeAt(h);
821
+ p && s.setNodeMarkup(h, f, p.attrs);
822
+ }), n(s);
823
+ }
824
+ return !0;
825
+ };
826
+ }
827
+ te("row", { useDeprecatedLogic: !0 });
828
+ te("column", { useDeprecatedLogic: !0 });
829
+ const vt = te("cell", { useDeprecatedLogic: !0 });
830
+ function Xe(t, e) {
831
+ if (e < 0) {
832
+ const o = t.nodeBefore;
833
+ if (o) return t.pos - o.nodeSize;
834
+ for (let n = t.index(-1) - 1, l = t.before(); n >= 0; n--) {
835
+ const r = t.node(-1).child(n), s = r.lastChild;
836
+ if (s) return l - 1 - s.nodeSize;
837
+ l -= r.nodeSize;
838
+ }
839
+ } else {
840
+ if (t.index() < t.parent.childCount - 1) return t.pos + t.nodeAfter.nodeSize;
841
+ const o = t.node(-1);
842
+ for (let n = t.indexAfter(-1), l = t.after(); n < o.childCount; n++) {
843
+ const r = o.child(n);
844
+ if (r.childCount) return l + 1;
845
+ l += r.nodeSize;
846
+ }
847
+ }
848
+ return null;
849
+ }
850
+ function Mt(t) {
851
+ return function(e, o) {
852
+ if (!A(e)) return !1;
853
+ const n = Xe(O(e), t);
854
+ if (n == null) return !1;
855
+ if (o) {
856
+ const l = e.doc.resolve(n);
857
+ o(e.tr.setSelection(E.between(l, Ee(l))).scrollIntoView());
858
+ }
859
+ return !0;
860
+ };
861
+ }
862
+ function zt(t, e) {
863
+ const o = t.selection.$anchor;
864
+ for (let n = o.depth; n > 0; n--) if (o.node(n).type.spec.tableRole == "table")
865
+ return e && e(t.tr.delete(o.before(n), o.after(n)).scrollIntoView()), !0;
866
+ return !1;
867
+ }
868
+ function F(t, e) {
869
+ const o = t.selection;
870
+ if (!(o instanceof w)) return !1;
871
+ if (e) {
872
+ const n = t.tr, l = y(t.schema).cell.createAndFill().content;
873
+ o.forEachCell((r, s) => {
874
+ r.content.eq(l) || n.replace(n.mapping.map(s + 1), n.mapping.map(s + r.nodeSize - 1), new N(l, 0, 0));
875
+ }), n.docChanged && e(n);
876
+ }
877
+ return !0;
878
+ }
879
+ function qe(t) {
880
+ if (t.size === 0) return null;
881
+ let { content: e, openStart: o, openEnd: n } = t;
882
+ for (; e.childCount == 1 && (o > 0 && n > 0 || e.child(0).type.spec.tableRole == "table"); )
883
+ o--, n--, e = e.child(0).content;
884
+ const l = e.child(0), r = l.type.spec.tableRole, s = l.type.schema, c = [];
885
+ if (r == "row") for (let i = 0; i < e.childCount; i++) {
886
+ let a = e.child(i).content;
887
+ const d = i ? 0 : Math.max(0, o - 1), f = i < e.childCount - 1 ? 0 : Math.max(0, n - 1);
888
+ (d || f) && (a = G(y(s).row, new N(a, d, f)).content), c.push(a);
889
+ }
890
+ else if (r == "cell" || r == "header_cell") c.push(o || n ? G(y(s).row, new N(e, o, n)).content : e);
891
+ else return null;
892
+ return Ue(s, c);
893
+ }
894
+ function Ue(t, e) {
895
+ const o = [];
896
+ for (let l = 0; l < e.length; l++) {
897
+ const r = e[l];
898
+ for (let s = r.childCount - 1; s >= 0; s--) {
899
+ const { rowspan: c, colspan: i } = r.child(s).attrs;
900
+ for (let a = l; a < l + c; a++) o[a] = (o[a] || 0) + i;
901
+ }
902
+ }
903
+ let n = 0;
904
+ for (let l = 0; l < o.length; l++) n = Math.max(n, o[l]);
905
+ for (let l = 0; l < o.length; l++)
906
+ if (l >= e.length && e.push(R.empty), o[l] < n) {
907
+ const r = y(t).cell.createAndFill(), s = [];
908
+ for (let c = o[l]; c < n; c++) s.push(r);
909
+ e[l] = e[l].append(R.from(s));
910
+ }
911
+ return {
912
+ height: e.length,
913
+ width: n,
914
+ rows: e
915
+ };
916
+ }
917
+ function G(t, e) {
918
+ const o = t.createAndFill();
919
+ return new Re(o).replace(0, o.content.size, e).doc;
920
+ }
921
+ function Je({ width: t, height: e, rows: o }, n, l) {
922
+ if (t != n) {
923
+ const r = [], s = [];
924
+ for (let c = 0; c < o.length; c++) {
925
+ const i = o[c], a = [];
926
+ for (let d = r[c] || 0, f = 0; d < n; f++) {
927
+ let u = i.child(f % i.childCount);
928
+ d + u.attrs.colspan > n && (u = u.type.createChecked(D(u.attrs, u.attrs.colspan, d + u.attrs.colspan - n), u.content)), a.push(u), d += u.attrs.colspan;
929
+ for (let h = 1; h < u.attrs.rowspan; h++) r[c + h] = (r[c + h] || 0) + u.attrs.colspan;
930
+ }
931
+ s.push(R.from(a));
932
+ }
933
+ o = s, t = n;
934
+ }
935
+ if (e != l) {
936
+ const r = [];
937
+ for (let s = 0, c = 0; s < l; s++, c++) {
938
+ const i = [], a = o[c % e];
939
+ for (let d = 0; d < a.childCount; d++) {
940
+ let f = a.child(d);
941
+ s + f.attrs.rowspan > l && (f = f.type.create({
942
+ ...f.attrs,
943
+ rowspan: Math.max(1, l - f.attrs.rowspan)
944
+ }, f.content)), i.push(f);
945
+ }
946
+ r.push(R.from(i));
947
+ }
948
+ o = r, e = l;
949
+ }
950
+ return {
951
+ width: t,
952
+ height: e,
953
+ rows: o
954
+ };
955
+ }
956
+ function Ye(t, e, o, n, l, r, s) {
957
+ const c = t.doc.type.schema, i = y(c);
958
+ let a, d;
959
+ if (l > e.width) for (let f = 0, u = 0; f < e.height; f++) {
960
+ const h = o.child(f);
961
+ u += h.nodeSize;
962
+ const p = [];
963
+ let m;
964
+ h.lastChild == null || h.lastChild.type == i.cell ? m = a || (a = i.cell.createAndFill()) : m = d || (d = i.header_cell.createAndFill());
965
+ for (let g = e.width; g < l; g++) p.push(m);
966
+ t.insert(t.mapping.slice(s).map(u - 1 + n), p);
967
+ }
968
+ if (r > e.height) {
969
+ const f = [];
970
+ for (let p = 0, m = (e.height - 1) * e.width; p < Math.max(e.width, l); p++) {
971
+ const g = p >= e.width ? !1 : o.nodeAt(e.map[m + p]).type == i.header_cell;
972
+ f.push(g ? d || (d = i.header_cell.createAndFill()) : a || (a = i.cell.createAndFill()));
973
+ }
974
+ const u = i.row.create(null, R.from(f)), h = [];
975
+ for (let p = e.height; p < r; p++) h.push(u);
976
+ t.insert(t.mapping.slice(s).map(n + o.nodeSize - 2), h);
977
+ }
978
+ return !!(a || d);
979
+ }
980
+ function le(t, e, o, n, l, r, s, c) {
981
+ if (s == 0 || s == e.height) return !1;
982
+ let i = !1;
983
+ for (let a = l; a < r; a++) {
984
+ const d = s * e.width + a, f = e.map[d];
985
+ if (e.map[d - e.width] == f) {
986
+ i = !0;
987
+ const u = o.nodeAt(f), { top: h, left: p } = e.findCell(f);
988
+ t.setNodeMarkup(t.mapping.slice(c).map(f + n), null, {
989
+ ...u.attrs,
990
+ rowspan: s - h
991
+ }), t.insert(t.mapping.slice(c).map(e.positionAt(s, p, o)), u.type.createAndFill({
992
+ ...u.attrs,
993
+ rowspan: h + u.attrs.rowspan - s
994
+ })), a += u.attrs.colspan - 1;
995
+ }
996
+ }
997
+ return i;
998
+ }
999
+ function re(t, e, o, n, l, r, s, c) {
1000
+ if (s == 0 || s == e.width) return !1;
1001
+ let i = !1;
1002
+ for (let a = l; a < r; a++) {
1003
+ const d = a * e.width + s, f = e.map[d];
1004
+ if (e.map[d - 1] == f) {
1005
+ i = !0;
1006
+ const u = o.nodeAt(f), h = e.colCount(f), p = t.mapping.slice(c).map(f + n);
1007
+ t.setNodeMarkup(p, null, D(u.attrs, s - h, u.attrs.colspan - (s - h))), t.insert(p + u.nodeSize, u.type.createAndFill(D(u.attrs, 0, s - h))), a += u.attrs.rowspan - 1;
1008
+ }
1009
+ }
1010
+ return i;
1011
+ }
1012
+ function se(t, e, o, n, l) {
1013
+ let r = o ? t.doc.nodeAt(o - 1) : t.doc;
1014
+ if (!r) throw new Error("No table found");
1015
+ let s = C.get(r);
1016
+ const { top: c, left: i } = n, a = i + l.width, d = c + l.height, f = t.tr;
1017
+ let u = 0;
1018
+ function h() {
1019
+ if (r = o ? f.doc.nodeAt(o - 1) : f.doc, !r) throw new Error("No table found");
1020
+ s = C.get(r), u = f.mapping.maps.length;
1021
+ }
1022
+ Ye(f, s, r, o, a, d, u) && h(), le(f, s, r, o, i, a, c, u) && h(), le(f, s, r, o, i, a, d, u) && h(), re(f, s, r, o, c, d, i, u) && h(), re(f, s, r, o, c, d, a, u) && h();
1023
+ for (let p = c; p < d; p++) {
1024
+ const m = s.positionAt(p, i, r), g = s.positionAt(p, a, r);
1025
+ f.replace(f.mapping.slice(u).map(m + o), f.mapping.slice(u).map(g + o), new N(l.rows[p - c], 0, 0));
1026
+ }
1027
+ h(), f.setSelection(new w(f.doc.resolve(o + s.positionAt(c, i, r)), f.doc.resolve(o + s.positionAt(d - 1, a - 1, r)))), e(f);
1028
+ }
1029
+ const Ge = Ae({
1030
+ ArrowLeft: P("horiz", -1),
1031
+ ArrowRight: P("horiz", 1),
1032
+ ArrowUp: P("vert", -1),
1033
+ ArrowDown: P("vert", 1),
1034
+ "Shift-ArrowLeft": W("horiz", -1),
1035
+ "Shift-ArrowRight": W("horiz", 1),
1036
+ "Shift-ArrowUp": W("vert", -1),
1037
+ "Shift-ArrowDown": W("vert", 1),
1038
+ Backspace: F,
1039
+ "Mod-Backspace": F,
1040
+ Delete: F,
1041
+ "Mod-Delete": F
1042
+ });
1043
+ function I(t, e, o) {
1044
+ return o.eq(t.selection) ? !1 : (e && e(t.tr.setSelection(o).scrollIntoView()), !0);
1045
+ }
1046
+ function P(t, e) {
1047
+ return (o, n, l) => {
1048
+ if (!l) return !1;
1049
+ const r = o.selection;
1050
+ if (r instanceof w) return I(o, n, M.near(r.$headCell, e));
1051
+ if (t != "horiz" && !r.empty) return !1;
1052
+ const s = Ce(l, t, e);
1053
+ if (s == null) return !1;
1054
+ if (t == "horiz") return I(o, n, M.near(o.doc.resolve(r.head + e), e));
1055
+ {
1056
+ const c = o.doc.resolve(s), i = ue(c, t, e);
1057
+ let a;
1058
+ return i ? a = M.near(i, 1) : e < 0 ? a = M.near(o.doc.resolve(c.before(-1)), -1) : a = M.near(o.doc.resolve(c.after(-1)), 1), I(o, n, a);
1059
+ }
1060
+ };
1061
+ }
1062
+ function W(t, e) {
1063
+ return (o, n, l) => {
1064
+ if (!l) return !1;
1065
+ const r = o.selection;
1066
+ let s;
1067
+ if (r instanceof w) s = r;
1068
+ else {
1069
+ const i = Ce(l, t, e);
1070
+ if (i == null) return !1;
1071
+ s = new w(o.doc.resolve(i));
1072
+ }
1073
+ const c = ue(s.$headCell, t, e);
1074
+ return c ? I(o, n, new w(s.$anchorCell, c)) : !1;
1075
+ };
1076
+ }
1077
+ function Qe(t, e) {
1078
+ const o = t.state.doc, n = T(o.resolve(e));
1079
+ return n ? (t.dispatch(t.state.tr.setSelection(new w(n))), !0) : !1;
1080
+ }
1081
+ function Ze(t, e, o) {
1082
+ if (!A(t.state)) return !1;
1083
+ let n = qe(o);
1084
+ const l = t.state.selection;
1085
+ if (l instanceof w) {
1086
+ n || (n = {
1087
+ width: 1,
1088
+ height: 1,
1089
+ rows: [R.from(G(y(t.state.schema).cell, o))]
1090
+ });
1091
+ const r = l.$anchorCell.node(-1), s = l.$anchorCell.start(-1), c = C.get(r).rectBetween(l.$anchorCell.pos - s, l.$headCell.pos - s);
1092
+ return n = Je(n, c.right - c.left, c.bottom - c.top), se(t.state, t.dispatch, s, c, n), !0;
1093
+ } else if (n) {
1094
+ const r = O(t.state), s = r.start(-1);
1095
+ return se(t.state, t.dispatch, s, C.get(r.node(-1)).findCell(r.pos - s), n), !0;
1096
+ } else return !1;
1097
+ }
1098
+ function et(t, e) {
1099
+ var o;
1100
+ if (e.button != 0 || e.ctrlKey || e.metaKey) return;
1101
+ const n = ie(t, e.target);
1102
+ let l;
1103
+ if (e.shiftKey && t.state.selection instanceof w)
1104
+ r(t.state.selection.$anchorCell, e), e.preventDefault();
1105
+ else if (e.shiftKey && n && (l = T(t.state.selection.$anchor)) != null && ((o = V(t, e)) === null || o === void 0 ? void 0 : o.pos) != l.pos)
1106
+ r(l, e), e.preventDefault();
1107
+ else if (!n) return;
1108
+ function r(i, a) {
1109
+ let d = V(t, a);
1110
+ const f = z.getState(t.state) == null;
1111
+ if (!d || !ee(i, d)) if (f) d = i;
1112
+ else return;
1113
+ const u = new w(i, d);
1114
+ if (f || !t.state.selection.eq(u)) {
1115
+ const h = t.state.tr.setSelection(u);
1116
+ f && h.setMeta(z, i.pos), t.dispatch(h);
1117
+ }
1118
+ }
1119
+ function s() {
1120
+ t.root.removeEventListener("mouseup", s), t.root.removeEventListener("dragstart", s), t.root.removeEventListener("mousemove", c), z.getState(t.state) != null && t.dispatch(t.state.tr.setMeta(z, -1));
1121
+ }
1122
+ function c(i) {
1123
+ const a = i, d = z.getState(t.state);
1124
+ let f;
1125
+ if (d != null) f = t.state.doc.resolve(d);
1126
+ else if (ie(t, a.target) != n && (f = V(t, e), !f))
1127
+ return s();
1128
+ f && r(f, a);
1129
+ }
1130
+ t.root.addEventListener("mouseup", s), t.root.addEventListener("dragstart", s), t.root.addEventListener("mousemove", c);
1131
+ }
1132
+ function Ce(t, e, o) {
1133
+ if (!(t.state.selection instanceof E)) return null;
1134
+ const { $head: n } = t.state.selection;
1135
+ for (let l = n.depth - 1; l >= 0; l--) {
1136
+ const r = n.node(l);
1137
+ if ((o < 0 ? n.index(l) : n.indexAfter(l)) != (o < 0 ? 0 : r.childCount)) return null;
1138
+ if (r.type.spec.tableRole == "cell" || r.type.spec.tableRole == "header_cell") {
1139
+ const s = n.before(l), c = e == "vert" ? o > 0 ? "down" : "up" : o > 0 ? "right" : "left";
1140
+ return t.endOfTextblock(c) ? s : null;
1141
+ }
1142
+ }
1143
+ return null;
1144
+ }
1145
+ function ie(t, e) {
1146
+ for (; e && e != t.dom; e = e.parentNode) if (e.nodeName == "TD" || e.nodeName == "TH") return e;
1147
+ return null;
1148
+ }
1149
+ function V(t, e) {
1150
+ const o = t.posAtCoords({
1151
+ left: e.clientX,
1152
+ top: e.clientY
1153
+ });
1154
+ if (!o) return null;
1155
+ let { inside: n, pos: l } = o;
1156
+ return n >= 0 && T(t.state.doc.resolve(n)) || T(t.state.doc.resolve(l));
1157
+ }
1158
+ var tt = class {
1159
+ constructor(t, e) {
1160
+ this.node = t, this.defaultCellMinWidth = e, this.dom = document.createElement("div"), this.dom.className = "tableWrapper", this.table = this.dom.appendChild(document.createElement("table")), this.table.style.setProperty("--default-cell-min-width", `${e}px`), this.colgroup = this.table.appendChild(document.createElement("colgroup")), Q(t, this.colgroup, this.table, e), this.contentDOM = this.table.appendChild(document.createElement("tbody"));
1161
+ }
1162
+ update(t) {
1163
+ return t.type != this.node.type ? !1 : (this.node = t, Q(t, this.colgroup, this.table, this.defaultCellMinWidth), !0);
1164
+ }
1165
+ ignoreMutation(t) {
1166
+ return t.type == "attributes" && (t.target == this.table || this.colgroup.contains(t.target));
1167
+ }
1168
+ };
1169
+ function Q(t, e, o, n, l, r) {
1170
+ let s = 0, c = !0, i = e.firstChild;
1171
+ const a = t.firstChild;
1172
+ if (a) {
1173
+ for (let f = 0, u = 0; f < a.childCount; f++) {
1174
+ const { colspan: h, colwidth: p } = a.child(f).attrs;
1175
+ for (let m = 0; m < h; m++, u++) {
1176
+ const g = l == u ? r : p && p[m], b = g ? g + "px" : "";
1177
+ if (s += g || n, g || (c = !1), i)
1178
+ i.style.width != b && (i.style.width = b), i = i.nextSibling;
1179
+ else {
1180
+ const B = document.createElement("col");
1181
+ B.style.width = b, e.appendChild(B);
1182
+ }
1183
+ }
1184
+ }
1185
+ for (; i; ) {
1186
+ var d;
1187
+ const f = i.nextSibling;
1188
+ (d = i.parentNode) === null || d === void 0 || d.removeChild(i), i = f;
1189
+ }
1190
+ c ? (o.style.width = s + "px", o.style.minWidth = "") : (o.style.width = "", o.style.minWidth = s + "px");
1191
+ }
1192
+ }
1193
+ const S = new Z("tableColumnResizing");
1194
+ function Nt({ handleWidth: t = 5, cellMinWidth: e = 25, defaultCellMinWidth: o = 100, View: n = tt, lastColumnResizable: l = !0 } = {}) {
1195
+ const r = new fe({
1196
+ key: S,
1197
+ state: {
1198
+ init(s, c) {
1199
+ var i;
1200
+ const a = (i = r.spec) === null || i === void 0 || (i = i.props) === null || i === void 0 ? void 0 : i.nodeViews, d = y(c.schema).table.name;
1201
+ return n && a && (a[d] = (f, u) => new n(f, o, u)), new ot(-1, !1);
1202
+ },
1203
+ apply(s, c) {
1204
+ return c.apply(s);
1205
+ }
1206
+ },
1207
+ props: {
1208
+ attributes: (s) => {
1209
+ const c = S.getState(s);
1210
+ return c && c.activeHandle > -1 ? { class: "resize-cursor" } : {};
1211
+ },
1212
+ handleDOMEvents: {
1213
+ mousemove: (s, c) => {
1214
+ nt(s, c, t, l);
1215
+ },
1216
+ mouseleave: (s) => {
1217
+ lt(s);
1218
+ },
1219
+ mousedown: (s, c) => {
1220
+ rt(s, c, e, o);
1221
+ }
1222
+ },
1223
+ decorations: (s) => {
1224
+ const c = S.getState(s);
1225
+ if (c && c.activeHandle > -1) return dt(s, c.activeHandle);
1226
+ },
1227
+ nodeViews: {}
1228
+ }
1229
+ });
1230
+ return r;
1231
+ }
1232
+ var ot = class _ {
1233
+ constructor(e, o) {
1234
+ this.activeHandle = e, this.dragging = o;
1235
+ }
1236
+ apply(e) {
1237
+ const o = this, n = e.getMeta(S);
1238
+ if (n && n.setHandle != null) return new _(n.setHandle, !1);
1239
+ if (n && n.setDragging !== void 0) return new _(o.activeHandle, n.setDragging);
1240
+ if (o.activeHandle > -1 && e.docChanged) {
1241
+ let l = e.mapping.map(o.activeHandle, -1);
1242
+ return Y(e.doc.resolve(l)) || (l = -1), new _(l, o.dragging);
1243
+ }
1244
+ return o;
1245
+ }
1246
+ };
1247
+ function nt(t, e, o, n) {
1248
+ if (!t.editable) return;
1249
+ const l = S.getState(t.state);
1250
+ if (l && !l.dragging) {
1251
+ const r = it(e.target);
1252
+ let s = -1;
1253
+ if (r) {
1254
+ const { left: c, right: i } = r.getBoundingClientRect();
1255
+ e.clientX - c <= o ? s = ce(t, e, "left", o) : i - e.clientX <= o && (s = ce(t, e, "right", o));
1256
+ }
1257
+ if (s != l.activeHandle) {
1258
+ if (!n && s !== -1) {
1259
+ const c = t.state.doc.resolve(s), i = c.node(-1), a = C.get(i), d = c.start(-1);
1260
+ if (a.colCount(c.pos - d) + c.nodeAfter.attrs.colspan - 1 == a.width - 1) return;
1261
+ }
1262
+ be(t, s);
1263
+ }
1264
+ }
1265
+ }
1266
+ function lt(t) {
1267
+ if (!t.editable) return;
1268
+ const e = S.getState(t.state);
1269
+ e && e.activeHandle > -1 && !e.dragging && be(t, -1);
1270
+ }
1271
+ function rt(t, e, o, n) {
1272
+ var l;
1273
+ if (!t.editable) return !1;
1274
+ const r = (l = t.dom.ownerDocument.defaultView) !== null && l !== void 0 ? l : window, s = S.getState(t.state);
1275
+ if (!s || s.activeHandle == -1 || s.dragging) return !1;
1276
+ const c = t.state.doc.nodeAt(s.activeHandle), i = st(t, s.activeHandle, c.attrs);
1277
+ t.dispatch(t.state.tr.setMeta(S, { setDragging: {
1278
+ startX: e.clientX,
1279
+ startWidth: i
1280
+ } }));
1281
+ function a(f) {
1282
+ r.removeEventListener("mouseup", a), r.removeEventListener("mousemove", d);
1283
+ const u = S.getState(t.state);
1284
+ u?.dragging && (ct(t, u.activeHandle, ae(u.dragging, f, o)), t.dispatch(t.state.tr.setMeta(S, { setDragging: null })));
1285
+ }
1286
+ function d(f) {
1287
+ if (!f.which) return a(f);
1288
+ const u = S.getState(t.state);
1289
+ if (u && u.dragging) {
1290
+ const h = ae(u.dragging, f, o);
1291
+ de(t, u.activeHandle, h, n);
1292
+ }
1293
+ }
1294
+ return de(t, s.activeHandle, i, n), r.addEventListener("mouseup", a), r.addEventListener("mousemove", d), e.preventDefault(), !0;
1295
+ }
1296
+ function st(t, e, { colspan: o, colwidth: n }) {
1297
+ const l = n && n[n.length - 1];
1298
+ if (l) return l;
1299
+ const r = t.domAtPos(e);
1300
+ let s = r.node.childNodes[r.offset].offsetWidth, c = o;
1301
+ if (n)
1302
+ for (let i = 0; i < o; i++) n[i] && (s -= n[i], c--);
1303
+ return s / c;
1304
+ }
1305
+ function it(t) {
1306
+ for (; t && t.nodeName != "TD" && t.nodeName != "TH"; ) t = t.classList && t.classList.contains("ProseMirror") ? null : t.parentNode;
1307
+ return t;
1308
+ }
1309
+ function ce(t, e, o, n) {
1310
+ const l = o == "right" ? -n : n, r = t.posAtCoords({
1311
+ left: e.clientX + l,
1312
+ top: e.clientY
1313
+ });
1314
+ if (!r) return -1;
1315
+ const { pos: s } = r, c = T(t.state.doc.resolve(s));
1316
+ if (!c) return -1;
1317
+ if (o == "right") return c.pos;
1318
+ const i = C.get(c.node(-1)), a = c.start(-1), d = i.map.indexOf(c.pos - a);
1319
+ return d % i.width == 0 ? -1 : a + i.map[d - 1];
1320
+ }
1321
+ function ae(t, e, o) {
1322
+ const n = e.clientX - t.startX;
1323
+ return Math.max(o, t.startWidth + n);
1324
+ }
1325
+ function be(t, e) {
1326
+ t.dispatch(t.state.tr.setMeta(S, { setHandle: e }));
1327
+ }
1328
+ function ct(t, e, o) {
1329
+ const n = t.state.doc.resolve(e), l = n.node(-1), r = C.get(l), s = n.start(-1), c = r.colCount(n.pos - s) + n.nodeAfter.attrs.colspan - 1, i = t.state.tr;
1330
+ for (let a = 0; a < r.height; a++) {
1331
+ const d = a * r.width + c;
1332
+ if (a && r.map[d] == r.map[d - r.width]) continue;
1333
+ const f = r.map[d], u = l.nodeAt(f).attrs, h = u.colspan == 1 ? 0 : c - r.colCount(f);
1334
+ if (u.colwidth && u.colwidth[h] == o) continue;
1335
+ const p = u.colwidth ? u.colwidth.slice() : at(u.colspan);
1336
+ p[h] = o, i.setNodeMarkup(s + f, null, {
1337
+ ...u,
1338
+ colwidth: p
1339
+ });
1340
+ }
1341
+ i.docChanged && t.dispatch(i);
1342
+ }
1343
+ function de(t, e, o, n) {
1344
+ const l = t.state.doc.resolve(e), r = l.node(-1), s = l.start(-1), c = C.get(r).colCount(l.pos - s) + l.nodeAfter.attrs.colspan - 1;
1345
+ let i = t.domAtPos(l.start(-1)).node;
1346
+ for (; i && i.nodeName != "TABLE"; ) i = i.parentNode;
1347
+ i && Q(r, i.firstChild, i, n, c, o);
1348
+ }
1349
+ function at(t) {
1350
+ return Array(t).fill(0);
1351
+ }
1352
+ function dt(t, e) {
1353
+ const o = [], n = t.doc.resolve(e), l = n.node(-1);
1354
+ if (!l) return X.empty;
1355
+ const r = C.get(l), s = n.start(-1), c = r.colCount(n.pos - s) + n.nodeAfter.attrs.colspan - 1;
1356
+ for (let a = 0; a < r.height; a++) {
1357
+ const d = c + a * r.width;
1358
+ if ((c == r.width - 1 || r.map[d] != r.map[d + 1]) && (a == 0 || r.map[d] != r.map[d - r.width])) {
1359
+ var i;
1360
+ const f = r.map[d], u = s + f + l.nodeAt(f).nodeSize - 1, h = document.createElement("div");
1361
+ h.className = "column-resize-handle", !((i = S.getState(t)) === null || i === void 0) && i.dragging && o.push(q.node(s + f, s + f + l.nodeAt(f).nodeSize, { class: "column-resize-dragging" })), o.push(q.widget(u, h));
1362
+ }
1363
+ }
1364
+ return X.create(t.doc, o);
1365
+ }
1366
+ function kt({ allowTableNodeSelection: t = !1 } = {}) {
1367
+ return new fe({
1368
+ key: z,
1369
+ state: {
1370
+ init() {
1371
+ return null;
1372
+ },
1373
+ apply(e, o) {
1374
+ const n = e.getMeta(z);
1375
+ if (n != null) return n == -1 ? null : n;
1376
+ if (o == null || !e.docChanged) return o;
1377
+ const { deleted: l, pos: r } = e.mapping.mapResult(o);
1378
+ return l ? null : r;
1379
+ }
1380
+ },
1381
+ props: {
1382
+ decorations: Be,
1383
+ handleDOMEvents: { mousedown: et },
1384
+ createSelectionBetween(e) {
1385
+ return z.getState(e.state) != null ? e.state.selection : null;
1386
+ },
1387
+ handleTripleClick: Qe,
1388
+ handleKeyDown: Ge,
1389
+ handlePaste: Ze
1390
+ },
1391
+ appendTransaction(e, o, n) {
1392
+ return $e(n, Pe(n, o), t);
1393
+ }
1394
+ });
1395
+ }
1396
+ export {
1397
+ De as CellBookmark,
1398
+ w as CellSelection,
1399
+ ot as ResizeState,
1400
+ C as TableMap,
1401
+ tt as TableView,
1402
+ Je as __clipCells,
1403
+ se as __insertCells,
1404
+ qe as __pastedCells,
1405
+ he as addColSpan,
1406
+ ge as addColumn,
1407
+ wt as addColumnAfter,
1408
+ gt as addColumnBefore,
1409
+ we as addRow,
1410
+ yt as addRowAfter,
1411
+ bt as addRowBefore,
1412
+ T as cellAround,
1413
+ ke as cellNear,
1414
+ Te as columnIsHeader,
1415
+ Nt as columnResizing,
1416
+ S as columnResizingPluginKey,
1417
+ F as deleteCellSelection,
1418
+ Ct as deleteColumn,
1419
+ St as deleteRow,
1420
+ zt as deleteTable,
1421
+ Pe as fixTables,
1422
+ Fe as fixTablesKey,
1423
+ Mt as goToNextCell,
1424
+ Ze as handlePaste,
1425
+ ee as inSameTable,
1426
+ A as isInTable,
1427
+ At as mergeCells,
1428
+ Ee as moveCellForward,
1429
+ ue as nextCell,
1430
+ Y as pointsAtCell,
1431
+ D as removeColSpan,
1432
+ Ie as removeColumn,
1433
+ Oe as removeRow,
1434
+ _e as rowIsHeader,
1435
+ x as selectedRect,
1436
+ O as selectionCell,
1437
+ xt as setCellAttr,
1438
+ Rt as splitCell,
1439
+ Ke as splitCellWithType,
1440
+ kt as tableEditing,
1441
+ z as tableEditingKey,
1442
+ y as tableNodeTypes,
1443
+ te as toggleHeader,
1444
+ vt as toggleHeaderCell,
1445
+ Q as updateColumnsOnResize
1446
+ };