wms-spreadsheet 0.1.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.
package/dist/index.js ADDED
@@ -0,0 +1,4984 @@
1
+ import { jsx as p, jsxs as W, Fragment as Sn } from "react/jsx-runtime";
2
+ import { useRef as V, useState as $, useMemo as Y, useCallback as N, useEffect as G, useSyncExternalStore as Qt, memo as Ce, createContext as lr, useContext as sr, useLayoutEffect as Ln, forwardRef as Nn, useImperativeHandle as xn } from "react";
3
+ import { createPortal as Hn } from "react-dom";
4
+ function ne(e, t) {
5
+ return `${e}:${t}`;
6
+ }
7
+ function Tn(e) {
8
+ const [t, n] = e.split(":").map(Number);
9
+ return { row: t, col: n };
10
+ }
11
+ class cr {
12
+ constructor() {
13
+ this.data = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Map();
14
+ }
15
+ getValue(t, n) {
16
+ return this.data.get(ne(t, n)) ?? "";
17
+ }
18
+ setValue(t, n, r) {
19
+ var c;
20
+ const o = ne(t, n);
21
+ (this.data.get(o) ?? "") !== r && (r === "" ? this.data.delete(o) : this.data.set(o, r), (c = this.listeners.get(o)) == null || c.forEach((s) => s()));
22
+ }
23
+ setValues(t) {
24
+ const n = /* @__PURE__ */ new Set();
25
+ for (const { row: r, col: o, value: l } of t) {
26
+ const c = ne(r, o);
27
+ (this.data.get(c) ?? "") !== l && (l === "" ? this.data.delete(c) : this.data.set(c, l), n.add(c));
28
+ }
29
+ n.forEach((r) => {
30
+ var o;
31
+ (o = this.listeners.get(r)) == null || o.forEach((l) => l());
32
+ });
33
+ }
34
+ subscribe(t, n, r) {
35
+ const o = ne(t, n);
36
+ return this.listeners.has(o) || this.listeners.set(o, /* @__PURE__ */ new Set()), this.listeners.get(o).add(r), () => {
37
+ var l;
38
+ (l = this.listeners.get(o)) == null || l.delete(r);
39
+ };
40
+ }
41
+ getAllData() {
42
+ const t = {};
43
+ return this.data.forEach((n, r) => {
44
+ t[r] = n;
45
+ }), t;
46
+ }
47
+ loadData(t) {
48
+ const n = /* @__PURE__ */ new Set();
49
+ for (const [r, o] of Object.entries(t))
50
+ (this.data.get(r) ?? "") !== o && (o === "" ? this.data.delete(r) : this.data.set(r, o), n.add(r));
51
+ n.forEach((r) => {
52
+ var o;
53
+ (o = this.listeners.get(r)) == null || o.forEach((l) => l());
54
+ });
55
+ }
56
+ clearAndLoad(t) {
57
+ const n = new Set(this.data.keys());
58
+ this.data.clear();
59
+ const r = new Set(n);
60
+ for (const [o, l] of Object.entries(t))
61
+ l !== "" && (this.data.set(o, l), r.add(o));
62
+ r.forEach((o) => {
63
+ var l;
64
+ (l = this.listeners.get(o)) == null || l.forEach((c) => c());
65
+ });
66
+ }
67
+ getKeys() {
68
+ return Array.from(this.data.keys());
69
+ }
70
+ parseKey(t) {
71
+ return Tn(t);
72
+ }
73
+ }
74
+ const ar = { type: "text" };
75
+ function on(e) {
76
+ return (e.type === void 0 || e.type === "text") && e.options === void 0 && e.dateFormat === void 0 && e.minDate === void 0 && e.maxDate === void 0 && e.customKey === void 0 && e.customProps === void 0 && e.invalid !== !0 && e.disabled !== !0;
77
+ }
78
+ class ir {
79
+ constructor() {
80
+ this.data = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Map();
81
+ }
82
+ getMeta(t, n) {
83
+ return this.data.get(ne(t, n)) ?? ar;
84
+ }
85
+ getStoredMeta(t, n) {
86
+ return this.data.get(ne(t, n)) ?? {};
87
+ }
88
+ setMeta(t, n, r) {
89
+ var s;
90
+ const o = ne(t, n), c = { ...this.data.get(o) ?? {}, ...r };
91
+ if (on(c)) {
92
+ if (!this.data.has(o)) return;
93
+ this.data.delete(o);
94
+ } else
95
+ this.data.set(o, c);
96
+ (s = this.listeners.get(o)) == null || s.forEach((a) => a());
97
+ }
98
+ setMetas(t) {
99
+ const n = /* @__PURE__ */ new Set();
100
+ for (const { row: r, col: o, meta: l } of t) {
101
+ const c = ne(r, o), a = { ...this.data.get(c) ?? {}, ...l };
102
+ on(a) ? this.data.delete(c) && n.add(c) : (this.data.set(c, a), n.add(c));
103
+ }
104
+ n.forEach((r) => {
105
+ var o;
106
+ (o = this.listeners.get(r)) == null || o.forEach((l) => l());
107
+ });
108
+ }
109
+ subscribe(t, n, r) {
110
+ const o = ne(t, n);
111
+ return this.listeners.has(o) || this.listeners.set(o, /* @__PURE__ */ new Set()), this.listeners.get(o).add(r), () => {
112
+ var l;
113
+ (l = this.listeners.get(o)) == null || l.delete(r);
114
+ };
115
+ }
116
+ }
117
+ function ur(e, t) {
118
+ return {
119
+ startRow: Math.min(e.row, t.row),
120
+ endRow: Math.max(e.row, t.row),
121
+ startCol: Math.min(e.col, t.col),
122
+ endCol: Math.max(e.col, t.col)
123
+ };
124
+ }
125
+ function et(e) {
126
+ return ur(e.anchor, e.focus);
127
+ }
128
+ function dr(e, t) {
129
+ return e.startRow === t.startRow && e.endRow === t.endRow && e.startCol === t.startCol && e.endCol === t.endCol;
130
+ }
131
+ function fr(e) {
132
+ return e.anchor.row === e.focus.row && e.anchor.col === e.focus.col;
133
+ }
134
+ function* hr(e) {
135
+ for (let t = e.startRow; t <= e.endRow; t++)
136
+ for (let n = e.startCol; n <= e.endCol; n++)
137
+ yield { row: t, col: n };
138
+ }
139
+ function _e(e) {
140
+ return { anchor: e, focus: e };
141
+ }
142
+ function ln(e, t) {
143
+ return { anchor: { row: 0, col: e }, focus: { row: t - 1, col: e } };
144
+ }
145
+ function sn(e, t) {
146
+ return { anchor: { row: e, col: 0 }, focus: { row: e, col: t - 1 } };
147
+ }
148
+ function Jt(e, t, n) {
149
+ const r = et(e), o = r.startRow === 0 && r.endRow === t - 1, l = r.startCol === 0 && r.endCol === n - 1;
150
+ return o || l;
151
+ }
152
+ function tt(e) {
153
+ return {
154
+ startRow: e.anchorRow,
155
+ endRow: e.anchorRow + e.rowSpan - 1,
156
+ startCol: e.anchorCol,
157
+ endCol: e.anchorCol + e.colSpan - 1
158
+ };
159
+ }
160
+ function pr(e) {
161
+ return {
162
+ anchorRow: e.startRow,
163
+ anchorCol: e.startCol,
164
+ rowSpan: e.endRow - e.startRow + 1,
165
+ colSpan: e.endCol - e.startCol + 1
166
+ };
167
+ }
168
+ function gr(e) {
169
+ return e.endRow > e.startRow || e.endCol > e.startCol;
170
+ }
171
+ function At(e, t) {
172
+ return !(e.endRow < t.startRow || e.startRow > t.endRow || e.endCol < t.startCol || e.startCol > t.endCol);
173
+ }
174
+ function jt(e, t) {
175
+ return e.startRow >= t.startRow && e.endRow <= t.endRow && e.startCol >= t.startCol && e.endCol <= t.endCol;
176
+ }
177
+ function wr(e, t) {
178
+ return e.startRow === t.startRow && e.endRow === t.endRow && e.startCol === t.startCol && e.endCol === t.endCol;
179
+ }
180
+ function Yt(e, t, n) {
181
+ return e >= n.startRow && e <= n.endRow && t >= n.startCol && t <= n.endCol;
182
+ }
183
+ function yr(e, t, n) {
184
+ const r = tt(n);
185
+ return Yt(e, t, r) ? e === n.anchorRow && t === n.anchorCol ? "anchor" : "covered" : "none";
186
+ }
187
+ function vr(e, t) {
188
+ let n = { ...e }, r = !0;
189
+ for (; r; ) {
190
+ r = !1;
191
+ for (const o of t) {
192
+ const l = tt(o);
193
+ if (!At(n, l) || jt(l, n)) continue;
194
+ const c = {
195
+ startRow: Math.min(n.startRow, l.startRow),
196
+ endRow: Math.max(n.endRow, l.endRow),
197
+ startCol: Math.min(n.startCol, l.startCol),
198
+ endCol: Math.max(n.endCol, l.endCol)
199
+ };
200
+ wr(c, n) || (n = c, r = !0);
201
+ }
202
+ }
203
+ return n;
204
+ }
205
+ function mr(e, t) {
206
+ for (const n of t) {
207
+ const r = tt(n);
208
+ if (At(e, r) && !(jt(r, e) || jt(e, r)))
209
+ return !0;
210
+ }
211
+ return !1;
212
+ }
213
+ function _r(e, t) {
214
+ for (const n of t)
215
+ if (At(e, tt(n)))
216
+ return !0;
217
+ return !1;
218
+ }
219
+ function br(e, t, n, r) {
220
+ const o = et(e);
221
+ return Jt(e, n, r) ? o : t.expandRange(o);
222
+ }
223
+ function Mr(e, t) {
224
+ const n = Yt(
225
+ t.anchor.row,
226
+ t.anchor.col,
227
+ e
228
+ ), r = Yt(
229
+ t.focus.row,
230
+ t.focus.col,
231
+ e
232
+ );
233
+ return {
234
+ anchor: n ? t.anchor : { row: e.startRow, col: e.startCol },
235
+ focus: r ? t.focus : { row: e.endRow, col: e.endCol }
236
+ };
237
+ }
238
+ class Cr {
239
+ constructor() {
240
+ this.anchors = /* @__PURE__ */ new Map(), this.coveredToAnchor = /* @__PURE__ */ new Map(), this.listeners = /* @__PURE__ */ new Set(), this.revision = 0;
241
+ }
242
+ getRevision() {
243
+ return this.revision;
244
+ }
245
+ subscribe(t) {
246
+ return this.listeners.add(t), () => {
247
+ this.listeners.delete(t);
248
+ };
249
+ }
250
+ notify() {
251
+ this.revision += 1, this.listeners.forEach((t) => t());
252
+ }
253
+ getAll() {
254
+ return Array.from(this.anchors.values());
255
+ }
256
+ hasAny() {
257
+ return this.anchors.size > 0;
258
+ }
259
+ getRole(t, n) {
260
+ const r = this.coveredToAnchor.get(ne(t, n));
261
+ if (!r) return "none";
262
+ const o = this.anchors.get(r);
263
+ return o ? yr(t, n, o) : "none";
264
+ }
265
+ resolveAnchor(t, n) {
266
+ const r = this.coveredToAnchor.get(ne(t, n));
267
+ if (!r) return { row: t, col: n };
268
+ const o = this.anchors.get(r);
269
+ return o ? { row: o.anchorRow, col: o.anchorCol } : { row: t, col: n };
270
+ }
271
+ getSpan(t, n) {
272
+ const r = this.anchors.get(ne(t, n));
273
+ return r ? { rowSpan: r.rowSpan, colSpan: r.colSpan } : { rowSpan: 1, colSpan: 1 };
274
+ }
275
+ getMergeAt(t, n) {
276
+ const r = this.resolveAnchor(t, n);
277
+ return this.anchors.get(ne(r.row, r.col)) ?? null;
278
+ }
279
+ rangeIntersectsMerge(t) {
280
+ return _r(t, this.getAll());
281
+ }
282
+ expandRange(t) {
283
+ return vr(t, this.getAll());
284
+ }
285
+ canMerge(t) {
286
+ if (!gr(t)) return !1;
287
+ const n = this.getAll();
288
+ if (mr(t, n)) return !1;
289
+ for (const r of n) {
290
+ const o = tt(r);
291
+ if (At(t, o)) return !1;
292
+ }
293
+ return !0;
294
+ }
295
+ merge(t, n, r) {
296
+ if (!this.canMerge(t)) return !1;
297
+ const o = pr(t), l = ne(o.anchorRow, o.anchorCol);
298
+ for (let c = t.startRow; c <= t.endRow; c++)
299
+ for (let s = t.startCol; s <= t.endCol; s++)
300
+ c === o.anchorRow && s === o.anchorCol || (n.setValue(c, s, ""), r.setMeta(c, s, {
301
+ type: "text",
302
+ disabled: !1,
303
+ invalid: !1
304
+ }), this.coveredToAnchor.set(ne(c, s), l));
305
+ return this.anchors.set(l, o), this.coveredToAnchor.set(l, l), this.notify(), !0;
306
+ }
307
+ unmerge(t, n) {
308
+ const r = this.resolveAnchor(t, n), o = ne(r.row, r.col), l = this.anchors.get(o);
309
+ if (!l) return !1;
310
+ const c = tt(l);
311
+ for (let s = c.startRow; s <= c.endRow; s++)
312
+ for (let a = c.startCol; a <= c.endCol; a++)
313
+ this.coveredToAnchor.delete(ne(s, a));
314
+ return this.anchors.delete(o), this.notify(), !0;
315
+ }
316
+ clear() {
317
+ this.anchors.size === 0 && this.coveredToAnchor.size === 0 || (this.anchors.clear(), this.coveredToAnchor.clear(), this.notify());
318
+ }
319
+ }
320
+ const Ct = "__BLANK__", kt = 28, Rr = 100, In = 20, Bn = 8, cn = 46, Dr = 28, Ar = 3, kr = 20, an = 20, Rt = 5;
321
+ function Wt(e, t) {
322
+ let n = 0;
323
+ for (let r = 0; r < t; r++)
324
+ n += e[r] ?? 0;
325
+ return n;
326
+ }
327
+ function be(e) {
328
+ return e.reduce((t, n) => t + n, 0);
329
+ }
330
+ function $e(e, t, n) {
331
+ let r = 0;
332
+ for (let o = t; o <= n; o++)
333
+ r += e[o] ?? 0;
334
+ return r;
335
+ }
336
+ function Te(e, t) {
337
+ if (e.length === 0) return 0;
338
+ let n = 0;
339
+ for (let r = 0; r < e.length; r++) {
340
+ const o = e[r];
341
+ if (t < n + o)
342
+ return r;
343
+ n += o;
344
+ }
345
+ return e.length - 1;
346
+ }
347
+ function Dt(e, t, n) {
348
+ return {
349
+ offset: Wt(e, t),
350
+ size: $e(e, t, n)
351
+ };
352
+ }
353
+ function zt(e, t, n) {
354
+ const r = e.slice(0, t);
355
+ for (; r.length < t; )
356
+ r.push(n);
357
+ return r;
358
+ }
359
+ function Er(e, t, n, r, o, l, c, s, a = 3, i = 0) {
360
+ const u = Math.max(
361
+ 0,
362
+ Te(o, e) - a
363
+ ), w = Math.min(
364
+ c - 1,
365
+ Te(o, e + n) + a
366
+ ), d = s - i;
367
+ if (d <= 0)
368
+ return {
369
+ startRow: u,
370
+ endRow: w,
371
+ startCol: 0,
372
+ endCol: Math.max(0, s - 1)
373
+ };
374
+ const g = l.slice(i), _ = Math.max(
375
+ 0,
376
+ Te(g, t) - a
377
+ ), f = Math.min(
378
+ d - 1,
379
+ Te(g, t + r) + a
380
+ );
381
+ return {
382
+ startRow: u,
383
+ endRow: w,
384
+ startCol: i + _,
385
+ endCol: i + f
386
+ };
387
+ }
388
+ function Sr(e, t) {
389
+ return e === void 0 || e <= 0 ? 0 : Math.min(Math.floor(e), t);
390
+ }
391
+ function Lr(e, t) {
392
+ return t <= 0 ? 0 : $e(e, 0, t - 1);
393
+ }
394
+ function bt(e, t, n) {
395
+ return t.getColumnLeft(e) - n;
396
+ }
397
+ function un(e, t) {
398
+ if (t <= 0)
399
+ return { frozen: null, scrollable: e };
400
+ const n = t - 1, r = e.startCol <= n ? {
401
+ startRow: e.startRow,
402
+ endRow: e.endRow,
403
+ startCol: e.startCol,
404
+ endCol: Math.min(e.endCol, n)
405
+ } : null, o = e.endCol >= t ? {
406
+ startRow: e.startRow,
407
+ endRow: e.endRow,
408
+ startCol: Math.max(e.startCol, t),
409
+ endCol: e.endCol
410
+ } : null;
411
+ return { frozen: r, scrollable: o };
412
+ }
413
+ function xe(e, t) {
414
+ return t > 0 && e < t;
415
+ }
416
+ function wt(e, t) {
417
+ const n = e.frozen !== null && e.scrollable !== null;
418
+ return {
419
+ hideLeftBorder: n && t === "scrollable",
420
+ hideRightBorder: n && t === "frozen"
421
+ };
422
+ }
423
+ function dn(e, t, n) {
424
+ return t === "frozen" ? e < n : e >= n;
425
+ }
426
+ function Nr(e) {
427
+ const {
428
+ rowCount: t,
429
+ columnCount: n,
430
+ rowHeights: r,
431
+ columnWidths: o,
432
+ overscan: l,
433
+ frozenColumnCount: c = 0
434
+ } = e, s = V(null), a = V(null), i = V({ scrollTop: 0, scrollLeft: 0 }), [u, w] = $(() => ({
435
+ scrollTop: 0,
436
+ scrollLeft: 0,
437
+ viewportWidth: 0,
438
+ viewportHeight: 0
439
+ })), d = be(o), g = Lr(o, c), _ = Math.max(0, d - g), f = be(r), b = Y(
440
+ () => Er(
441
+ u.scrollTop,
442
+ u.scrollLeft,
443
+ u.viewportHeight,
444
+ u.viewportWidth,
445
+ r,
446
+ o,
447
+ t,
448
+ n,
449
+ l,
450
+ c
451
+ ),
452
+ [
453
+ u.scrollTop,
454
+ u.scrollLeft,
455
+ u.viewportHeight,
456
+ u.viewportWidth,
457
+ r,
458
+ o,
459
+ t,
460
+ n,
461
+ l,
462
+ c
463
+ ]
464
+ ), R = N(() => {
465
+ a.current = null;
466
+ const { scrollTop: v, scrollLeft: h } = i.current;
467
+ w((m) => m.scrollTop === v && m.scrollLeft === h ? m : { ...m, scrollTop: v, scrollLeft: h });
468
+ }, []), y = N(() => {
469
+ const v = s.current;
470
+ v && (i.current = {
471
+ scrollTop: v.scrollTop,
472
+ scrollLeft: v.scrollLeft
473
+ }, a.current === null && (a.current = requestAnimationFrame(R)));
474
+ }, [R]);
475
+ return G(() => {
476
+ const v = s.current;
477
+ if (!v) return;
478
+ const h = () => {
479
+ w((M) => ({
480
+ ...M,
481
+ viewportWidth: v.clientWidth,
482
+ viewportHeight: v.clientHeight,
483
+ scrollTop: v.scrollTop,
484
+ scrollLeft: v.scrollLeft
485
+ }));
486
+ };
487
+ h();
488
+ const m = new ResizeObserver(h);
489
+ return m.observe(v), v.addEventListener("scroll", y, { passive: !0 }), () => {
490
+ m.disconnect(), v.removeEventListener("scroll", y), a.current !== null && cancelAnimationFrame(a.current);
491
+ };
492
+ }, [y]), {
493
+ scrollRef: s,
494
+ scrollTop: u.scrollTop,
495
+ scrollLeft: u.scrollLeft,
496
+ viewportWidth: u.viewportWidth,
497
+ viewportHeight: u.viewportHeight,
498
+ visibleRange: b,
499
+ totalWidth: d,
500
+ scrollableTotalWidth: _,
501
+ totalHeight: f,
502
+ frozenColumnCount: c,
503
+ frozenWidth: g
504
+ };
505
+ }
506
+ function Qe(e, t, n) {
507
+ return Math.max(t, Math.min(n, e));
508
+ }
509
+ function xr(e, t, n, r, o, l, c, s = 0, a) {
510
+ const i = be(r), u = Math.max(
511
+ 0,
512
+ be(o) - s
513
+ ), w = n.scrollLeft;
514
+ let d;
515
+ if (a && s > 0) {
516
+ const f = a.getBoundingClientRect(), b = e >= f.left && e < f.right;
517
+ if (b && w > 0)
518
+ d = s + w;
519
+ else if (b)
520
+ d = Qe(
521
+ e - f.left,
522
+ 0,
523
+ Math.max(0, s - 1)
524
+ );
525
+ else {
526
+ const R = n.getBoundingClientRect();
527
+ d = Qe(
528
+ s + w + (e - R.left),
529
+ s,
530
+ Math.max(s, s + u - 1)
531
+ );
532
+ }
533
+ } else {
534
+ const f = n.getBoundingClientRect(), b = be(o);
535
+ d = Qe(
536
+ w + (e - f.left),
537
+ 0,
538
+ Math.max(0, b - 1)
539
+ );
540
+ }
541
+ const g = n.getBoundingClientRect(), _ = Qe(
542
+ n.scrollTop + (t - g.top),
543
+ 0,
544
+ Math.max(0, i - 1)
545
+ );
546
+ return {
547
+ row: Qe(Te(r, _), 0, l - 1),
548
+ col: Qe(Te(o, d), 0, c - 1)
549
+ };
550
+ }
551
+ function Ze(e, t, n) {
552
+ return Math.max(t, Math.min(n, e));
553
+ }
554
+ function Hr(e, t, n, r, o, l = 0, c) {
555
+ const s = Math.max(
556
+ 0,
557
+ be(r) - l
558
+ );
559
+ let a;
560
+ if (c && l > 0) {
561
+ const i = c.getBoundingClientRect(), u = e >= i.left && e < i.right;
562
+ if (u && n > 0)
563
+ a = l + n;
564
+ else if (u)
565
+ a = Ze(
566
+ e - i.left,
567
+ 0,
568
+ Math.max(0, l - 1)
569
+ );
570
+ else {
571
+ const w = t.getBoundingClientRect();
572
+ a = Ze(
573
+ l + n + (e - w.left),
574
+ l,
575
+ Math.max(l, l + s - 1)
576
+ );
577
+ }
578
+ } else {
579
+ const i = t.getBoundingClientRect(), u = be(r);
580
+ a = Ze(
581
+ n + (e - i.left),
582
+ 0,
583
+ Math.max(0, u - 1)
584
+ );
585
+ }
586
+ return Ze(Te(r, a), 0, o - 1);
587
+ }
588
+ function Tr(e, t, n, r, o) {
589
+ const l = t.getBoundingClientRect(), c = be(r), s = Ze(
590
+ n + (e - l.top),
591
+ 0,
592
+ Math.max(0, c - 1)
593
+ );
594
+ return Ze(Te(r, s), 0, o - 1);
595
+ }
596
+ const it = 40, Xe = 16;
597
+ function yt(e) {
598
+ const t = 1 - e / it;
599
+ return Math.max(1, Math.round(t * Xe));
600
+ }
601
+ function Ir(e, t, n, r, o) {
602
+ let l = 0, c = 0, s = !1;
603
+ const a = t - n.top, i = n.bottom - t, u = e - n.left, w = n.right - e;
604
+ return o && (t < n.top ? (c = -Xe, s = !0) : a >= 0 && a < it && (c = -yt(a), s = !0), t > n.bottom ? (c = Xe, s = !0) : i >= 0 && i < it && (c = yt(i), s = !0)), r && (e < n.left ? (l = -Xe, s = !0) : u >= 0 && u < it && (l = -yt(u), s = !0), e > n.right ? (l = Xe, s = !0) : w >= 0 && w < it && (l = yt(w), s = !0)), { scrollDx: l, scrollDy: c, nearEdge: s };
605
+ }
606
+ function Br({
607
+ isDragging: e,
608
+ dragMode: t,
609
+ scrollRef: n,
610
+ columnHeaderRef: r,
611
+ rowHeaderRef: o,
612
+ rowHeights: l,
613
+ columnWidths: c,
614
+ rowCount: s,
615
+ columnCount: a,
616
+ frozenWidth: i = 0,
617
+ frozenColumnHeaderRef: u,
618
+ frozenBodyRef: w,
619
+ onCellFocus: d,
620
+ onColumnFocus: g,
621
+ onRowFocus: _
622
+ }) {
623
+ const f = V({ clientX: 0, clientY: 0 }), b = V(null), R = V(d), y = V(g), v = V(_), h = V(t);
624
+ G(() => {
625
+ R.current = d;
626
+ }, [d]), G(() => {
627
+ y.current = g;
628
+ }, [g]), G(() => {
629
+ v.current = _;
630
+ }, [_]), G(() => {
631
+ h.current = t;
632
+ }, [t]);
633
+ const m = N(() => {
634
+ var U, ue;
635
+ const E = n.current;
636
+ if (!E) {
637
+ b.current = null;
638
+ return;
639
+ }
640
+ const { clientX: k, clientY: B } = f.current, D = h.current;
641
+ let S = E.getBoundingClientRect(), A = !0, H = !0;
642
+ D === "column" && (r != null && r.current) ? (S = r.current.getBoundingClientRect(), A = !0, H = !1) : D === "row" && (o != null && o.current) && (S = o.current.getBoundingClientRect(), A = !1, H = !0);
643
+ let { scrollDx: q, scrollDy: ee, nearEdge: P } = Ir(
644
+ k,
645
+ B,
646
+ S,
647
+ A,
648
+ H
649
+ );
650
+ if (A && i > 0 && E.scrollLeft > 0 && k < S.left && (q = -Xe, P = !0), q !== 0 || ee !== 0) {
651
+ const re = Math.max(0, E.scrollWidth - E.clientWidth), pe = Math.max(0, E.scrollHeight - E.clientHeight);
652
+ E.scrollLeft = Math.max(
653
+ 0,
654
+ Math.min(re, E.scrollLeft + q)
655
+ ), E.scrollTop = Math.max(
656
+ 0,
657
+ Math.min(pe, E.scrollTop + ee)
658
+ );
659
+ }
660
+ if (D === "column" && (r != null && r.current)) {
661
+ const re = Hr(
662
+ k,
663
+ r.current,
664
+ E.scrollLeft,
665
+ c,
666
+ a,
667
+ i,
668
+ u == null ? void 0 : u.current
669
+ );
670
+ (U = y.current) == null || U.call(y, re);
671
+ } else if (D === "row" && (o != null && o.current)) {
672
+ const re = Tr(
673
+ B,
674
+ o.current,
675
+ E.scrollTop,
676
+ l,
677
+ s
678
+ );
679
+ (ue = v.current) == null || ue.call(v, re);
680
+ } else {
681
+ const re = xr(
682
+ k,
683
+ B,
684
+ E,
685
+ l,
686
+ c,
687
+ s,
688
+ a,
689
+ i,
690
+ w == null ? void 0 : w.current
691
+ );
692
+ R.current(re.row, re.col);
693
+ }
694
+ P ? b.current = requestAnimationFrame(m) : b.current = null;
695
+ }, [
696
+ n,
697
+ r,
698
+ o,
699
+ l,
700
+ c,
701
+ s,
702
+ a,
703
+ i,
704
+ u,
705
+ w
706
+ ]), M = N(() => {
707
+ b.current === null && (b.current = requestAnimationFrame(m));
708
+ }, [m]);
709
+ G(() => {
710
+ if (!e) {
711
+ b.current !== null && (cancelAnimationFrame(b.current), b.current = null);
712
+ return;
713
+ }
714
+ const E = (k) => {
715
+ f.current = { clientX: k.clientX, clientY: k.clientY }, M();
716
+ };
717
+ return document.addEventListener("mousemove", E), () => {
718
+ document.removeEventListener("mousemove", E), b.current !== null && (cancelAnimationFrame(b.current), b.current = null);
719
+ };
720
+ }, [e, M]);
721
+ }
722
+ function zn(e) {
723
+ return Qt(
724
+ (t) => e.subscribe(t),
725
+ () => e.getRevision(),
726
+ () => e.getRevision()
727
+ );
728
+ }
729
+ function zr(e, t, n) {
730
+ return Qt(
731
+ (r) => e.subscribe(t, n, r),
732
+ () => e.getValue(t, n),
733
+ () => e.getValue(t, n)
734
+ );
735
+ }
736
+ function Or(e, t, n) {
737
+ return Qt(
738
+ (r) => e.subscribe(t, n, r),
739
+ () => e.getMeta(t, n),
740
+ () => e.getMeta(t, n)
741
+ );
742
+ }
743
+ const Vr = { type: "text" };
744
+ function Fr(e) {
745
+ return (e == null ? void 0 : e.meta) ?? {};
746
+ }
747
+ function jr(e) {
748
+ var t;
749
+ return e.customKey ? "custom" : e.type ? e.type : (t = e.options) != null && t.length ? "select" : "text";
750
+ }
751
+ function Me(e, t, n, r) {
752
+ const o = e.getStoredMeta(t, n), l = Fr(r == null ? void 0 : r[n]), c = {
753
+ ...Vr,
754
+ ...l,
755
+ ...o
756
+ };
757
+ return c.type = jr(c), c;
758
+ }
759
+ function Et(e) {
760
+ return e.disabled === !0;
761
+ }
762
+ function On(e) {
763
+ return Et(e) ? !1 : e.type !== "boolean" && e.type !== "switch";
764
+ }
765
+ const Yr = {
766
+ left: "flex-start",
767
+ center: "center",
768
+ right: "flex-end"
769
+ }, Wr = {
770
+ top: "flex-start",
771
+ middle: "center",
772
+ bottom: "flex-end"
773
+ };
774
+ function $r(e) {
775
+ const t = (e == null ? void 0 : e.horizontalAlign) ?? "left", n = (e == null ? void 0 : e.verticalAlign) ?? "top";
776
+ return {
777
+ justifyContent: Yr[t],
778
+ alignItems: Wr[n],
779
+ textAlign: t
780
+ };
781
+ }
782
+ const qr = "_track_1ldab_17", Pr = "_trackChecked_1ldab_29", Kr = "_knob_1ldab_34", vt = {
783
+ switch: "_switch_1ldab_1",
784
+ track: qr,
785
+ trackChecked: Pr,
786
+ knob: Kr
787
+ };
788
+ function Ur({ checked: e, onChange: t, disabled: n }) {
789
+ return /* @__PURE__ */ p(
790
+ "button",
791
+ {
792
+ type: "button",
793
+ role: "switch",
794
+ "aria-checked": e,
795
+ disabled: n,
796
+ className: vt.switch,
797
+ onMouseDown: (r) => r.stopPropagation(),
798
+ onClick: (r) => {
799
+ r.stopPropagation(), n || t(!e);
800
+ },
801
+ children: /* @__PURE__ */ p(
802
+ "span",
803
+ {
804
+ className: `${vt.track} ${e ? vt.trackChecked : ""}`,
805
+ children: /* @__PURE__ */ p("span", { className: vt.knob })
806
+ }
807
+ )
808
+ }
809
+ );
810
+ }
811
+ const qe = "DD/MM/YYYY", Gr = [
812
+ "January",
813
+ "February",
814
+ "March",
815
+ "April",
816
+ "May",
817
+ "June",
818
+ "July",
819
+ "August",
820
+ "September",
821
+ "October",
822
+ "November",
823
+ "December"
824
+ ];
825
+ function fn(e) {
826
+ return String(e).padStart(2, "0");
827
+ }
828
+ function Mt(e) {
829
+ return new Date(e.getFullYear(), e.getMonth(), e.getDate());
830
+ }
831
+ function $t(e, t) {
832
+ return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
833
+ }
834
+ function Zt(e, t) {
835
+ const n = fn(e.getDate()), r = fn(e.getMonth() + 1), o = String(e.getFullYear());
836
+ return t.replace(/YYYY/g, o).replace(/MM/g, r).replace(/DD/g, n);
837
+ }
838
+ function Vn(e) {
839
+ const t = [], n = /(DD|MM|YYYY)/g;
840
+ let r;
841
+ for (; (r = n.exec(e)) !== null; )
842
+ t.push(r[1]);
843
+ return t;
844
+ }
845
+ function Fn(e) {
846
+ const t = e.match(/[^DMY]+/);
847
+ return (t == null ? void 0 : t[0]) ?? "/";
848
+ }
849
+ function ut(e, t = qe) {
850
+ const n = e.trim();
851
+ if (!n) return null;
852
+ const r = Vn(t);
853
+ if (r.length === 0) return null;
854
+ const o = Fn(t), l = n.split(o);
855
+ if (l.length < r.length) return null;
856
+ let c = 0, s = 0, a = 0;
857
+ if (r.forEach((u, w) => {
858
+ const d = Number.parseInt(l[w] ?? "", 10);
859
+ Number.isNaN(d) || (u === "DD" && (c = d), u === "MM" && (s = d), u === "YYYY" && (a = d));
860
+ }), !c || !s || !a) return null;
861
+ const i = new Date(a, s - 1, c);
862
+ return i.getFullYear() !== a || i.getMonth() !== s - 1 || i.getDate() !== c ? null : i;
863
+ }
864
+ function Qr(e, t = qe) {
865
+ const n = ut(e, t);
866
+ return n ? Zt(n, t) : e;
867
+ }
868
+ function Jr(e, t, n = Gr) {
869
+ return `${n[t]} ${e}`;
870
+ }
871
+ function Zr(e, t, n) {
872
+ const r = Mt(e).getTime();
873
+ return !(t !== null && r < Mt(t).getTime() || n !== null && r > Mt(n).getTime());
874
+ }
875
+ function Xr(e, t, n = qe) {
876
+ const r = e != null && e.trim() ? ut(e, n) : null, o = t != null && t.trim() ? ut(t, n) : null;
877
+ return { min: r, max: o };
878
+ }
879
+ function eo(e, t) {
880
+ const n = Mt(/* @__PURE__ */ new Date()), o = (new Date(e, t, 1).getDay() + 6) % 7, l = new Date(e, t + 1, 0).getDate(), c = [];
881
+ for (let s = 1; s <= l; s += 1) {
882
+ const a = new Date(e, t, s);
883
+ c.push({
884
+ date: a,
885
+ day: s,
886
+ isToday: $t(a, n)
887
+ });
888
+ }
889
+ return { leadingBlanks: o, days: c };
890
+ }
891
+ function hn(e, t, n) {
892
+ const r = new Date(e, t + n, 1);
893
+ return { year: r.getFullYear(), month: r.getMonth() };
894
+ }
895
+ function Xt(e) {
896
+ if (!e) return [];
897
+ try {
898
+ const t = JSON.parse(e);
899
+ return Array.isArray(t) ? t.filter((n) => typeof n == "string") : [];
900
+ } catch {
901
+ return [];
902
+ }
903
+ }
904
+ function jn(e) {
905
+ return e.length ? JSON.stringify(e) : "";
906
+ }
907
+ function Yn(e, t) {
908
+ if (!t.length) return [];
909
+ const n = (e == null ? void 0 : e.filter((l) => t.includes(l.id)).map((l) => ({
910
+ id: l.id,
911
+ label: l.label,
912
+ color: l.color
913
+ }))) ?? [], r = new Set(n.map((l) => l.id)), o = t.filter((l) => !r.has(l)).map((l) => ({ id: l, label: l }));
914
+ return [...n, ...o];
915
+ }
916
+ const qt = "#e8eaed", to = "_spreadsheet_unoen_1", no = "_topRow_unoen_15", ro = "_bottomRow_unoen_20", oo = "_corner_unoen_26", lo = "_frozenColumnHeaderPane_unoen_35", so = "_frozenBodyPane_unoen_44", co = "_frozenBodyPaneEditing_unoen_50", ao = "_columnHeaderPane_unoen_54", io = "_rowHeaderPane_unoen_63", uo = "_bodyScroll_unoen_72", fo = "_canvas_unoen_79", ho = "_headerCell_unoen_83", po = "_active_unoen_96", go = "_headerCellInner_unoen_101", wo = "_headerCellText_unoen_109", yo = "_filterIconBtn_unoen_117", vo = "_filterIconBtnActive_unoen_138", mo = "_rowHeaderCell_unoen_143", _o = "_cell_unoen_162", bo = "_invalid_unoen_181", Mo = "_disabled_unoen_184", Co = "_mergedAnchor_unoen_188", Ro = "_frozenActiveOverlay_unoen_192", Do = "_fillHandle_unoen_201", Ao = "_selectionOverlay_unoen_212", ko = "_selectionOverlaySingle_unoen_220", Eo = "_hideLeftBorder_unoen_223", So = "_hideRightBorder_unoen_226", Lo = "_clipboardOverlay_unoen_230", No = "_selectionHandle_unoen_245", xo = "_cellEditor_unoen_256", Ho = "_selectPill_unoen_275", To = "_selectPillLabel_unoen_291", Io = "_selectCaret_unoen_297", Bo = "_multiSelectField_unoen_304", zo = "_multiSelectChips_unoen_312", Oo = "_multiSelectChip_unoen_312", Vo = "_multiSelectChipLabel_unoen_334", Fo = "_datePill_unoen_340", jo = "_datePillLabel_unoen_355", Yo = "_dateIcon_unoen_361", Wo = "_booleanCheckbox_unoen_369", $o = "_customEditorContainer_unoen_393", qo = "_headerCanvas_unoen_400", Po = "_columnResizeHandle_unoen_404", Ko = "_resizeHandleIcon_unoen_414", Uo = "_resizeHandleHovered_unoen_436", Go = "_rowResizeHandle_unoen_440", I = {
917
+ spreadsheet: to,
918
+ topRow: no,
919
+ bottomRow: ro,
920
+ corner: oo,
921
+ frozenColumnHeaderPane: lo,
922
+ frozenBodyPane: so,
923
+ frozenBodyPaneEditing: co,
924
+ columnHeaderPane: ao,
925
+ rowHeaderPane: io,
926
+ bodyScroll: uo,
927
+ canvas: fo,
928
+ headerCell: ho,
929
+ active: po,
930
+ headerCellInner: go,
931
+ headerCellText: wo,
932
+ filterIconBtn: yo,
933
+ filterIconBtnActive: vo,
934
+ rowHeaderCell: mo,
935
+ cell: _o,
936
+ invalid: bo,
937
+ disabled: Mo,
938
+ mergedAnchor: Co,
939
+ frozenActiveOverlay: Ro,
940
+ fillHandle: Do,
941
+ selectionOverlay: Ao,
942
+ selectionOverlaySingle: ko,
943
+ hideLeftBorder: Eo,
944
+ hideRightBorder: So,
945
+ clipboardOverlay: Lo,
946
+ selectionHandle: No,
947
+ cellEditor: xo,
948
+ selectPill: Ho,
949
+ selectPillLabel: To,
950
+ selectCaret: Io,
951
+ multiSelectField: Bo,
952
+ multiSelectChips: zo,
953
+ multiSelectChip: Oo,
954
+ multiSelectChipLabel: Vo,
955
+ datePill: Fo,
956
+ datePillLabel: jo,
957
+ dateIcon: Yo,
958
+ booleanCheckbox: Wo,
959
+ customEditorContainer: $o,
960
+ headerCanvas: qo,
961
+ columnResizeHandle: Po,
962
+ resizeHandleIcon: Ko,
963
+ resizeHandleHovered: Uo,
964
+ rowResizeHandle: Go
965
+ };
966
+ function Wn(e, t) {
967
+ if (!(!(e != null && e.length) || !t))
968
+ return e.find((n) => n.id === t);
969
+ }
970
+ function Qo({ value: e }) {
971
+ return e;
972
+ }
973
+ function Jo({ value: e, meta: t }) {
974
+ const n = Wn(t.options, e), r = (n == null ? void 0 : n.label) ?? (e || "");
975
+ return /* @__PURE__ */ W(
976
+ "span",
977
+ {
978
+ className: I.selectPill,
979
+ style: n != null && n.color ? { backgroundColor: n.color } : void 0,
980
+ children: [
981
+ /* @__PURE__ */ p("span", { className: I.selectPillLabel, children: r }),
982
+ /* @__PURE__ */ p("span", { className: I.selectCaret, "aria-hidden": !0, children: "▾" })
983
+ ]
984
+ }
985
+ );
986
+ }
987
+ function Zo({ value: e, meta: t }) {
988
+ const n = Xt(e), r = Yn(t.options, n);
989
+ if (!r.length) return null;
990
+ const o = r.map((l) => l.label).join(", ");
991
+ return /* @__PURE__ */ p("span", { className: I.multiSelectField, title: o, children: /* @__PURE__ */ p("span", { className: I.multiSelectChips, children: r.map((l) => /* @__PURE__ */ p(
992
+ "span",
993
+ {
994
+ className: I.multiSelectChip,
995
+ style: {
996
+ backgroundColor: l.color ?? qt
997
+ },
998
+ children: /* @__PURE__ */ p("span", { className: I.multiSelectChipLabel, children: l.label })
999
+ },
1000
+ l.id
1001
+ )) }) });
1002
+ }
1003
+ function Xo({
1004
+ row: e,
1005
+ col: t,
1006
+ value: n,
1007
+ meta: r,
1008
+ onToggle: o
1009
+ }) {
1010
+ const l = n === "true";
1011
+ return /* @__PURE__ */ p(
1012
+ "input",
1013
+ {
1014
+ type: "checkbox",
1015
+ className: I.booleanCheckbox,
1016
+ checked: l,
1017
+ disabled: r.disabled,
1018
+ onChange: () => o(e, t, l ? "false" : "true"),
1019
+ onMouseDown: (c) => c.stopPropagation(),
1020
+ onClick: (c) => c.stopPropagation()
1021
+ }
1022
+ );
1023
+ }
1024
+ function el({
1025
+ row: e,
1026
+ col: t,
1027
+ value: n,
1028
+ meta: r,
1029
+ onToggle: o
1030
+ }) {
1031
+ return /* @__PURE__ */ p(
1032
+ Ur,
1033
+ {
1034
+ checked: n === "true",
1035
+ disabled: r.disabled,
1036
+ onChange: (c) => o(e, t, c ? "true" : "false")
1037
+ }
1038
+ );
1039
+ }
1040
+ function tl({ value: e, meta: t }) {
1041
+ const n = t.dateFormat ?? qe, r = e ? Qr(e, n) : "";
1042
+ return /* @__PURE__ */ W("span", { className: I.datePill, children: [
1043
+ /* @__PURE__ */ p("span", { className: I.datePillLabel, children: r }),
1044
+ /* @__PURE__ */ p("span", { className: I.dateIcon, "aria-hidden": !0, children: /* @__PURE__ */ W(
1045
+ "svg",
1046
+ {
1047
+ viewBox: "0 0 24 24",
1048
+ width: "14",
1049
+ height: "14",
1050
+ fill: "none",
1051
+ stroke: "currentColor",
1052
+ strokeWidth: "2",
1053
+ children: [
1054
+ /* @__PURE__ */ p("rect", { x: "3", y: "4", width: "18", height: "18", rx: "2" }),
1055
+ /* @__PURE__ */ p("line", { x1: "16", y1: "2", x2: "16", y2: "6" }),
1056
+ /* @__PURE__ */ p("line", { x1: "8", y1: "2", x2: "8", y2: "6" }),
1057
+ /* @__PURE__ */ p("line", { x1: "3", y1: "10", x2: "21", y2: "10" })
1058
+ ]
1059
+ }
1060
+ ) })
1061
+ ] });
1062
+ }
1063
+ function nl(e, t, n) {
1064
+ if (t != null && t.cellRender)
1065
+ return t.cellRender(e);
1066
+ const r = e.meta.customKey;
1067
+ return r && (n != null && n[r]) ? n[r].render(e) : e.value;
1068
+ }
1069
+ function rl({
1070
+ params: e,
1071
+ column: t,
1072
+ customCellRegistry: n,
1073
+ onBooleanToggle: r
1074
+ }) {
1075
+ switch (e.meta.type ?? "text") {
1076
+ case "select":
1077
+ return Jo(e);
1078
+ case "multiSelect":
1079
+ return Zo(e);
1080
+ case "boolean":
1081
+ return Xo({ ...e, onToggle: r });
1082
+ case "switch":
1083
+ return el({ ...e, onToggle: r });
1084
+ case "date":
1085
+ return tl(e);
1086
+ case "custom":
1087
+ return nl(e, t, n);
1088
+ default:
1089
+ return Qo(e);
1090
+ }
1091
+ }
1092
+ function ol(e, t) {
1093
+ return Wn(e, t);
1094
+ }
1095
+ const ll = Ce(function({
1096
+ store: t,
1097
+ metaStore: n,
1098
+ row: r,
1099
+ col: o,
1100
+ columns: l,
1101
+ customCellRegistry: c,
1102
+ isActive: s,
1103
+ isMerged: a = !1,
1104
+ top: i,
1105
+ left: u,
1106
+ width: w,
1107
+ height: d,
1108
+ onMouseDown: g,
1109
+ onMouseEnter: _,
1110
+ onDoubleClick: f,
1111
+ onBooleanToggle: b
1112
+ }) {
1113
+ const R = zr(t, r, o);
1114
+ Or(n, r, o);
1115
+ const y = Me(n, r, o, l), v = l == null ? void 0 : l[o], h = y.disabled ? I.disabled : y.invalid ? I.invalid : "", m = (M) => {
1116
+ M.preventDefault(), g(r, o);
1117
+ };
1118
+ return /* @__PURE__ */ p(
1119
+ "div",
1120
+ {
1121
+ className: `${I.cell} ${s ? I.active : ""} ${a ? I.mergedAnchor : ""} ${h}`,
1122
+ style: { top: i, left: u, width: w, height: d, ...$r(v) },
1123
+ onMouseDown: m,
1124
+ onMouseEnter: () => _(r, o),
1125
+ onDoubleClick: () => f(r, o),
1126
+ role: "gridcell",
1127
+ children: rl({
1128
+ params: { row: r, col: o, value: R, meta: y, isActive: s },
1129
+ column: v,
1130
+ customCellRegistry: c,
1131
+ onBooleanToggle: b
1132
+ })
1133
+ }
1134
+ );
1135
+ });
1136
+ function $n({
1137
+ store: e,
1138
+ metaStore: t,
1139
+ mergeStore: n,
1140
+ dimensions: r,
1141
+ rowStart: o,
1142
+ rowEnd: l,
1143
+ colStart: c,
1144
+ colEnd: s,
1145
+ columns: a,
1146
+ customCellRegistry: i,
1147
+ selection: u,
1148
+ activeCell: w,
1149
+ getColumnLeft: d,
1150
+ resolvePhysicalRow: g,
1151
+ getRowTop: _,
1152
+ onCellMouseDown: f,
1153
+ onCellMouseEnter: b,
1154
+ onCellDoubleClick: R,
1155
+ onBooleanToggle: y
1156
+ }) {
1157
+ const v = [];
1158
+ if (s < c) return v;
1159
+ const h = w !== void 0 ? w : u != null && u.focus ? n.resolveAnchor(u.focus.row, u.focus.col) : null;
1160
+ for (let m = o; m <= l; m++) {
1161
+ const M = g ? g(m) : m;
1162
+ if (!(M < 0))
1163
+ for (let E = c; E <= s; E++) {
1164
+ if (n.getRole(M, E) === "covered") continue;
1165
+ const { rowSpan: k, colSpan: B } = n.getSpan(M, E), D = k > 1 || B > 1, S = $e(
1166
+ r.columnWidths,
1167
+ E,
1168
+ E + B - 1
1169
+ ), A = $e(
1170
+ r.rowHeights,
1171
+ M,
1172
+ M + k - 1
1173
+ ), H = h !== null && h.row === M && h.col === E;
1174
+ v.push(
1175
+ /* @__PURE__ */ p(
1176
+ ll,
1177
+ {
1178
+ store: e,
1179
+ metaStore: t,
1180
+ row: M,
1181
+ col: E,
1182
+ columns: a,
1183
+ customCellRegistry: i,
1184
+ isActive: H,
1185
+ isMerged: D,
1186
+ top: _ ? _(m) : r.getRowTop(M),
1187
+ left: d(E),
1188
+ width: S,
1189
+ height: A,
1190
+ onMouseDown: f,
1191
+ onMouseEnter: b,
1192
+ onDoubleClick: R,
1193
+ onBooleanToggle: y
1194
+ },
1195
+ `${M}:${E}`
1196
+ )
1197
+ );
1198
+ }
1199
+ }
1200
+ return v;
1201
+ }
1202
+ function sl(e, t, n) {
1203
+ const r = new Set(t), o = [], l = /* @__PURE__ */ new Map(), c = [];
1204
+ for (const s of e) {
1205
+ if (!r.has(s)) continue;
1206
+ const a = o.length;
1207
+ o.push(s), l.set(s, a), c.push(n[s] ?? 0);
1208
+ }
1209
+ return {
1210
+ visibleRowIndices: o,
1211
+ visibleCount: o.length,
1212
+ physicalToDisplay: l,
1213
+ displayRowHeights: c
1214
+ };
1215
+ }
1216
+ function Pt(e, t) {
1217
+ let n = 0;
1218
+ for (let r = 0; r < t; r++)
1219
+ n += e.displayRowHeights[r] ?? 0;
1220
+ return n;
1221
+ }
1222
+ function cl(e) {
1223
+ return e.displayRowHeights.reduce((t, n) => t + n, 0);
1224
+ }
1225
+ function al(e, t) {
1226
+ const n = Math.min(e.startRow, e.endRow), r = Math.max(e.startRow, e.endRow);
1227
+ return t.filter(
1228
+ (o) => o >= n && o <= r
1229
+ );
1230
+ }
1231
+ function qn(e, t, n) {
1232
+ const r = Math.min(t, n), o = Math.max(t, n);
1233
+ let l = 1 / 0, c = -1 / 0;
1234
+ for (let s = 0; s < e.visibleRowIndices.length; s++) {
1235
+ const a = e.visibleRowIndices[s];
1236
+ a !== void 0 && (a < r || a > o || (l = Math.min(l, s), c = Math.max(c, s)));
1237
+ }
1238
+ return l === 1 / 0 || c < 0 ? null : {
1239
+ offset: Pt(e, l),
1240
+ size: $e(e.displayRowHeights, l, c)
1241
+ };
1242
+ }
1243
+ function pn(e) {
1244
+ return e.trim().toLowerCase();
1245
+ }
1246
+ function Kt(e) {
1247
+ return e.trim() === "";
1248
+ }
1249
+ function Ot(e) {
1250
+ return e === "isEqualTo" || e === "isNotEqualTo" || e === "beginsWith" || e === "endsWith" || e === "contains" || e === "doesNotContain";
1251
+ }
1252
+ function il(e, t, n) {
1253
+ const r = pn(e), o = pn(n ?? "");
1254
+ switch (t) {
1255
+ case "none":
1256
+ return !0;
1257
+ case "isEmpty":
1258
+ return Kt(e);
1259
+ case "isNotEmpty":
1260
+ return !Kt(e);
1261
+ case "isEqualTo":
1262
+ return r === o;
1263
+ case "isNotEqualTo":
1264
+ return r !== o;
1265
+ case "beginsWith":
1266
+ return r.startsWith(o);
1267
+ case "endsWith":
1268
+ return r.endsWith(o);
1269
+ case "contains":
1270
+ return r.includes(o);
1271
+ case "doesNotContain":
1272
+ return !r.includes(o);
1273
+ default:
1274
+ return !0;
1275
+ }
1276
+ }
1277
+ function en(e) {
1278
+ return e.condition !== "none" || e.selectedValues !== null;
1279
+ }
1280
+ function ul(e, t, n) {
1281
+ var r;
1282
+ if (t !== null) return !0;
1283
+ for (const [o, l] of e)
1284
+ if ((r = n == null ? void 0 : n[o]) != null && r.showFilter && en(l))
1285
+ return !0;
1286
+ return !1;
1287
+ }
1288
+ function dl() {
1289
+ return {
1290
+ condition: "none",
1291
+ selectedValues: null
1292
+ };
1293
+ }
1294
+ function fl(e, t, n, r) {
1295
+ const o = e.getValue(t, n);
1296
+ if (!il(o, r.condition, r.conditionValue))
1297
+ return !1;
1298
+ if (r.selectedValues === null)
1299
+ return !0;
1300
+ const l = Kt(o) ? Ct : o;
1301
+ return r.selectedValues.includes(l);
1302
+ }
1303
+ function hl(e, t, n, r) {
1304
+ const o = Array.from(r.entries()).filter(
1305
+ ([c, s]) => {
1306
+ const a = n == null ? void 0 : n[c];
1307
+ return a != null && a.showFilter ? en(s) : !1;
1308
+ }
1309
+ );
1310
+ if (o.length === 0)
1311
+ return Array.from({ length: t }, (c, s) => s);
1312
+ const l = [];
1313
+ for (let c = 0; c < t; c++) {
1314
+ let s = !0;
1315
+ for (const [a, i] of o)
1316
+ if (!fl(e, c, a, i)) {
1317
+ s = !1;
1318
+ break;
1319
+ }
1320
+ s && l.push(c);
1321
+ }
1322
+ return l;
1323
+ }
1324
+ const gn = 2;
1325
+ function pl(e, t, n) {
1326
+ const r = Math.max(n, e.width);
1327
+ let o = e.bottom + gn;
1328
+ o + t > window.innerHeight && (o = e.top - t - gn), o = Math.max(0, o);
1329
+ let l = e.left;
1330
+ return l + r > window.innerWidth && (l = Math.max(0, window.innerWidth - r)), {
1331
+ top: o,
1332
+ left: l,
1333
+ width: r
1334
+ };
1335
+ }
1336
+ const He = {
1337
+ errors: {
1338
+ mergeInvalidRange: "Please select a cell range to merge.",
1339
+ mergeOverlap: "Cannot merge: invalid or overlapping selection.",
1340
+ mergeWhileSortFilterActive: "Cannot merge cells while sorting or filtering is active.",
1341
+ filterWhileMerged: "Cannot filter while the sheet has merged cells.",
1342
+ sortWhileMerged: "Cannot sort while the sheet has merged cells.",
1343
+ copyMergedNotAllowed: "Cannot copy a range that contains merged cells.",
1344
+ pasteMergedNotAllowed: "Cannot paste into a range that contains merged cells."
1345
+ },
1346
+ filter: {
1347
+ columnAriaLabel: "Filter column",
1348
+ dialogAriaLabel: "Column filter",
1349
+ sortAsc: "Sort A-Z",
1350
+ sortDesc: "Sort Z-A",
1351
+ filterByCondition: "Filter by condition:",
1352
+ filterByValue: "Filter by value:",
1353
+ valuePlaceholder: "Value",
1354
+ searchPlaceholder: "Search",
1355
+ selectAll: "Select all",
1356
+ clear: "Clear",
1357
+ reset: "Reset",
1358
+ ok: "OK",
1359
+ cancel: "Cancel",
1360
+ blankCells: "(Blank cells)",
1361
+ conditions: {
1362
+ none: "None",
1363
+ isEmpty: "Is empty",
1364
+ isNotEmpty: "Is not empty",
1365
+ isEqualTo: "Is equal to",
1366
+ isNotEqualTo: "Is not equal to",
1367
+ beginsWith: "Begins with",
1368
+ endsWith: "Ends with",
1369
+ contains: "Contains",
1370
+ doesNotContain: "Does not contain"
1371
+ }
1372
+ },
1373
+ datepicker: {
1374
+ dialogAriaLabel: "Pick a date",
1375
+ prevMonthAriaLabel: "Previous month",
1376
+ nextMonthAriaLabel: "Next month",
1377
+ today: "Today",
1378
+ clear: "Clear",
1379
+ monthNames: [
1380
+ "January",
1381
+ "February",
1382
+ "March",
1383
+ "April",
1384
+ "May",
1385
+ "June",
1386
+ "July",
1387
+ "August",
1388
+ "September",
1389
+ "October",
1390
+ "November",
1391
+ "December"
1392
+ ],
1393
+ weekdayLabels: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
1394
+ }
1395
+ }, Pn = lr(
1396
+ He
1397
+ );
1398
+ function gl({
1399
+ locale: e,
1400
+ children: t
1401
+ }) {
1402
+ return /* @__PURE__ */ p(Pn.Provider, { value: e, children: t });
1403
+ }
1404
+ function St() {
1405
+ return sr(Pn);
1406
+ }
1407
+ const wl = "_popup_6bmj7_1", yl = "_actionButton_6bmj7_12", vl = "_actionButtonContent_6bmj7_26", ml = "_sortIndicator_6bmj7_32", _l = "_divider_6bmj7_37", bl = "_section_6bmj7_43", Ml = "_label_6bmj7_47", Cl = "_select_6bmj7_53", Rl = "_input_6bmj7_54", Dl = "_inlineActions_6bmj7_75", Al = "_linkButton_6bmj7_81", kl = "_list_6bmj7_91", El = "_option_6bmj7_100", Sl = "_footer_6bmj7_109", Ll = "_footerRight_6bmj7_117", Nl = "_primaryButton_6bmj7_122", xl = "_secondaryButton_6bmj7_123", J = {
1408
+ popup: wl,
1409
+ actionButton: yl,
1410
+ actionButtonContent: vl,
1411
+ sortIndicator: ml,
1412
+ divider: _l,
1413
+ section: bl,
1414
+ label: Ml,
1415
+ select: Cl,
1416
+ input: Rl,
1417
+ inlineActions: Dl,
1418
+ linkButton: Al,
1419
+ list: kl,
1420
+ option: El,
1421
+ footer: Sl,
1422
+ footerRight: Ll,
1423
+ primaryButton: Nl,
1424
+ secondaryButton: xl
1425
+ }, Hl = 284, Tl = 420, Il = [
1426
+ "none",
1427
+ "isEmpty",
1428
+ "isNotEmpty",
1429
+ "isEqualTo",
1430
+ "isNotEqualTo",
1431
+ "beginsWith",
1432
+ "endsWith",
1433
+ "contains",
1434
+ "doesNotContain"
1435
+ ];
1436
+ function Kn(e) {
1437
+ return e.map((t) => t.value);
1438
+ }
1439
+ function wn(e, t) {
1440
+ return e === null ? new Set(Kn(t)) : new Set(e);
1441
+ }
1442
+ function Bl({
1443
+ anchorRect: e,
1444
+ filterState: t,
1445
+ activeSortDirection: n,
1446
+ valueOptions: r,
1447
+ sortFilterDisabled: o = !1,
1448
+ onSort: l,
1449
+ onApply: c,
1450
+ onReset: s,
1451
+ onCancel: a
1452
+ }) {
1453
+ const i = St(), { filter: u } = i, w = V(null), [d, g] = $(""), [_, f] = $(t), [b, R] = $(null);
1454
+ G(() => {
1455
+ f(t), g("");
1456
+ }, [t]);
1457
+ const y = Y(() => {
1458
+ const D = d.trim().toLowerCase();
1459
+ return D ? r.filter(
1460
+ (S) => S.label.toLowerCase().includes(D)
1461
+ ) : r;
1462
+ }, [d, r]);
1463
+ Ln(() => {
1464
+ const D = () => {
1465
+ var A;
1466
+ const S = ((A = w.current) == null ? void 0 : A.offsetHeight) ?? Tl;
1467
+ R(pl(e, S, Hl));
1468
+ };
1469
+ return D(), window.addEventListener("resize", D), window.addEventListener("scroll", D, !0), () => {
1470
+ window.removeEventListener("resize", D), window.removeEventListener("scroll", D, !0);
1471
+ };
1472
+ }, [e]), G(() => {
1473
+ const D = (A) => {
1474
+ var q;
1475
+ const H = A.target;
1476
+ H && ((q = w.current) != null && q.contains(H) || a());
1477
+ }, S = (A) => {
1478
+ A.key === "Escape" && (A.preventDefault(), a());
1479
+ };
1480
+ return document.addEventListener("mousedown", D), document.addEventListener("keydown", S), () => {
1481
+ document.removeEventListener("mousedown", D), document.removeEventListener("keydown", S);
1482
+ };
1483
+ }, [a]);
1484
+ const v = Y(
1485
+ () => wn(_.selectedValues, r),
1486
+ [_.selectedValues, r]
1487
+ ), h = (D) => {
1488
+ const S = D.target.value;
1489
+ f((A) => ({
1490
+ ...A,
1491
+ condition: S,
1492
+ conditionValue: Ot(S) ? A.conditionValue ?? "" : void 0
1493
+ }));
1494
+ }, m = (D) => {
1495
+ const S = wn(_.selectedValues, r);
1496
+ S.has(D) ? S.delete(D) : S.add(D);
1497
+ const A = Kn(r), H = S.size === A.length ? null : A.filter((q) => S.has(q));
1498
+ f((q) => ({ ...q, selectedValues: H }));
1499
+ }, M = () => {
1500
+ f((D) => ({ ...D, selectedValues: null }));
1501
+ }, E = () => {
1502
+ f((D) => ({ ...D, selectedValues: [] }));
1503
+ }, k = () => {
1504
+ const D = {
1505
+ ..._,
1506
+ conditionValue: Ot(_.condition) ? _.conditionValue ?? "" : void 0
1507
+ };
1508
+ c(D);
1509
+ }, B = /* @__PURE__ */ W(
1510
+ "div",
1511
+ {
1512
+ ref: w,
1513
+ className: J.popup,
1514
+ style: b ? {
1515
+ top: b.top,
1516
+ left: b.left,
1517
+ width: b.width,
1518
+ visibility: "visible"
1519
+ } : { visibility: "hidden" },
1520
+ role: "dialog",
1521
+ "aria-label": u.dialogAriaLabel,
1522
+ onMouseDown: (D) => D.stopPropagation(),
1523
+ children: [
1524
+ /* @__PURE__ */ p(
1525
+ "button",
1526
+ {
1527
+ type: "button",
1528
+ className: J.actionButton,
1529
+ "aria-pressed": n === "asc",
1530
+ disabled: o,
1531
+ onClick: () => l("asc"),
1532
+ children: /* @__PURE__ */ W("span", { className: J.actionButtonContent, children: [
1533
+ /* @__PURE__ */ p("span", { className: J.sortIndicator, "aria-hidden": !0, children: n === "asc" ? "✓" : "" }),
1534
+ u.sortAsc
1535
+ ] })
1536
+ }
1537
+ ),
1538
+ /* @__PURE__ */ p(
1539
+ "button",
1540
+ {
1541
+ type: "button",
1542
+ className: J.actionButton,
1543
+ "aria-pressed": n === "desc",
1544
+ disabled: o,
1545
+ onClick: () => l("desc"),
1546
+ children: /* @__PURE__ */ W("span", { className: J.actionButtonContent, children: [
1547
+ /* @__PURE__ */ p("span", { className: J.sortIndicator, "aria-hidden": !0, children: n === "desc" ? "✓" : "" }),
1548
+ u.sortDesc
1549
+ ] })
1550
+ }
1551
+ ),
1552
+ /* @__PURE__ */ p("div", { className: J.divider }),
1553
+ /* @__PURE__ */ W("div", { className: J.section, children: [
1554
+ /* @__PURE__ */ p("p", { className: J.label, children: u.filterByCondition }),
1555
+ /* @__PURE__ */ p(
1556
+ "select",
1557
+ {
1558
+ className: J.select,
1559
+ value: _.condition,
1560
+ disabled: o,
1561
+ onChange: h,
1562
+ children: Il.map((D) => /* @__PURE__ */ p("option", { value: D, children: u.conditions[D] }, D))
1563
+ }
1564
+ ),
1565
+ Ot(_.condition) && /* @__PURE__ */ p(
1566
+ "input",
1567
+ {
1568
+ type: "text",
1569
+ className: J.input,
1570
+ value: _.conditionValue ?? "",
1571
+ onChange: (D) => f((S) => ({
1572
+ ...S,
1573
+ conditionValue: D.target.value
1574
+ })),
1575
+ placeholder: u.valuePlaceholder
1576
+ }
1577
+ )
1578
+ ] }),
1579
+ /* @__PURE__ */ W("div", { className: J.section, children: [
1580
+ /* @__PURE__ */ p("p", { className: J.label, children: u.filterByValue }),
1581
+ /* @__PURE__ */ p(
1582
+ "input",
1583
+ {
1584
+ type: "text",
1585
+ className: J.input,
1586
+ placeholder: u.searchPlaceholder,
1587
+ value: d,
1588
+ onChange: (D) => g(D.target.value)
1589
+ }
1590
+ ),
1591
+ /* @__PURE__ */ W("div", { className: J.inlineActions, children: [
1592
+ /* @__PURE__ */ p("button", { type: "button", className: J.linkButton, onClick: M, children: u.selectAll }),
1593
+ /* @__PURE__ */ p("button", { type: "button", className: J.linkButton, onClick: E, children: u.clear })
1594
+ ] })
1595
+ ] }),
1596
+ /* @__PURE__ */ p("div", { className: J.list, children: y.map((D) => /* @__PURE__ */ W("label", { className: J.option, children: [
1597
+ /* @__PURE__ */ p(
1598
+ "input",
1599
+ {
1600
+ type: "checkbox",
1601
+ checked: v.has(D.value),
1602
+ onChange: () => m(D.value)
1603
+ }
1604
+ ),
1605
+ /* @__PURE__ */ p("span", { children: D.label })
1606
+ ] }, D.value)) }),
1607
+ /* @__PURE__ */ W("div", { className: J.footer, children: [
1608
+ /* @__PURE__ */ p("button", { type: "button", className: J.secondaryButton, onClick: s, children: u.reset }),
1609
+ /* @__PURE__ */ W("div", { className: J.footerRight, children: [
1610
+ /* @__PURE__ */ p("button", { type: "button", className: J.primaryButton, onClick: k, children: u.ok }),
1611
+ /* @__PURE__ */ p("button", { type: "button", className: J.secondaryButton, onClick: a, children: u.cancel })
1612
+ ] })
1613
+ ] })
1614
+ ]
1615
+ }
1616
+ );
1617
+ return Hn(B, document.body);
1618
+ }
1619
+ function zl(e, t) {
1620
+ const n = [];
1621
+ let r = !1;
1622
+ for (const o of e) {
1623
+ if (o === Ct) {
1624
+ r = !0;
1625
+ continue;
1626
+ }
1627
+ n.push({ value: o, label: o });
1628
+ }
1629
+ return r && n.unshift({ value: Ct, label: t }), n;
1630
+ }
1631
+ function Ol({ colHeaderHeight: e }) {
1632
+ return /* @__PURE__ */ p("div", { className: I.corner, style: { height: e } });
1633
+ }
1634
+ function Vl(e) {
1635
+ let t = "", n = e + 1;
1636
+ for (; n > 0; )
1637
+ n -= 1, t = String.fromCharCode(65 + n % 26) + t, n = Math.floor(n / 26);
1638
+ return t;
1639
+ }
1640
+ function Fl(e, t) {
1641
+ const n = t == null ? void 0 : t[e];
1642
+ return n ? n.colRender ? n.colRender({ col: e, column: n }) : n.colText ?? n.colName : Vl(e);
1643
+ }
1644
+ const jl = Ce(function({
1645
+ col: t,
1646
+ columnLeft: n,
1647
+ columnWidth: r,
1648
+ colHeaderHeight: o,
1649
+ isActive: l,
1650
+ columns: c,
1651
+ activeFilterColumns: s,
1652
+ onColumnMouseDown: a,
1653
+ onColumnMouseEnter: i,
1654
+ onFilterIconClick: u
1655
+ }) {
1656
+ const { filter: w } = St(), d = c == null ? void 0 : c[t], g = (d == null ? void 0 : d.showFilter) === !0, _ = g ? en(
1657
+ s.get(t) ?? {
1658
+ condition: "none",
1659
+ selectedValues: null
1660
+ }
1661
+ ) : !1;
1662
+ return /* @__PURE__ */ p(
1663
+ "div",
1664
+ {
1665
+ className: `${I.headerCell}${l ? ` ${I.active}` : ""}`,
1666
+ style: {
1667
+ top: 0,
1668
+ left: n,
1669
+ width: r,
1670
+ height: o
1671
+ },
1672
+ onMouseDown: (f) => {
1673
+ f.preventDefault(), a(t);
1674
+ },
1675
+ onMouseEnter: () => i(t),
1676
+ children: /* @__PURE__ */ W("div", { className: I.headerCellInner, children: [
1677
+ /* @__PURE__ */ p("div", { className: I.headerCellText, children: Fl(t, c) }),
1678
+ g && /* @__PURE__ */ p(
1679
+ "button",
1680
+ {
1681
+ type: "button",
1682
+ className: `${I.filterIconBtn}${_ ? ` ${I.filterIconBtnActive}` : ""}`,
1683
+ onMouseDown: (f) => {
1684
+ f.preventDefault(), f.stopPropagation();
1685
+ },
1686
+ onClick: (f) => {
1687
+ f.preventDefault(), f.stopPropagation(), u(t, f.currentTarget.getBoundingClientRect());
1688
+ },
1689
+ "aria-label": w.columnAriaLabel,
1690
+ children: /* @__PURE__ */ p("svg", { viewBox: "0 0 24 24", "aria-hidden": !0, focusable: "false", children: /* @__PURE__ */ p(
1691
+ "path",
1692
+ {
1693
+ d: "M4 6h16l-6.5 7.2V18l-3 1.8v-6.6L4 6z",
1694
+ fill: "currentColor"
1695
+ }
1696
+ ) })
1697
+ }
1698
+ )
1699
+ ] })
1700
+ }
1701
+ );
1702
+ }), Yl = Ce(function({
1703
+ col: t,
1704
+ columnLeft: n,
1705
+ columnWidth: r,
1706
+ isHandleHovered: o,
1707
+ onResizeHandleMouseEnter: l,
1708
+ onResizeHandleMouseLeave: c,
1709
+ onResizeStart: s
1710
+ }) {
1711
+ return /* @__PURE__ */ p(
1712
+ "div",
1713
+ {
1714
+ className: `${I.columnResizeHandle}${o ? ` ${I.resizeHandleHovered}` : ""}`,
1715
+ style: {
1716
+ left: n + r - Rt / 2,
1717
+ width: Rt
1718
+ },
1719
+ onMouseDown: (a) => {
1720
+ a.preventDefault(), a.stopPropagation(), s(t, a.clientX);
1721
+ },
1722
+ onMouseEnter: () => l({ axis: "column", index: t }),
1723
+ onMouseLeave: c,
1724
+ children: /* @__PURE__ */ p("span", { className: I.resizeHandleIcon, "aria-hidden": !0 })
1725
+ }
1726
+ );
1727
+ });
1728
+ function yn(e, t, n) {
1729
+ if (e === null) return null;
1730
+ const r = Math.max(e.startCol, t), o = Math.min(e.endCol, n);
1731
+ return o < r ? null : { startCol: r, endCol: o };
1732
+ }
1733
+ function Wl(e, t, n, r) {
1734
+ const o = yn(e, n, r), l = yn(t, n, r);
1735
+ return o === null || l === null ? o === l : o.startCol === l.startCol && o.endCol === l.endCol;
1736
+ }
1737
+ function $l(e, t) {
1738
+ return e.colStart !== t.colStart || e.colEnd !== t.colEnd || e.colHeaderHeight !== t.colHeaderHeight || e.dimensions !== t.dimensions || e.scrollLeft !== t.scrollLeft || e.canvasWidth !== t.canvasWidth || e.frozenWidth !== t.frozenWidth || e.mode !== t.mode || e.headerPaneRef !== t.headerPaneRef || e.paneClassName !== t.paneClassName || e.withFrozenDivider !== t.withFrozenDivider || e.hoveredHandle !== t.hoveredHandle || e.columns !== t.columns || e.activeFilterColumns !== t.activeFilterColumns || e.onColumnMouseDown !== t.onColumnMouseDown || e.onColumnMouseEnter !== t.onColumnMouseEnter || e.onFilterIconClick !== t.onFilterIconClick || e.onResizeHandleMouseEnter !== t.onResizeHandleMouseEnter || e.onResizeHandleMouseLeave !== t.onResizeHandleMouseLeave || e.onResizeStart !== t.onResizeStart ? !1 : Wl(
1739
+ e.selectionRange,
1740
+ t.selectionRange,
1741
+ t.colStart,
1742
+ t.colEnd
1743
+ );
1744
+ }
1745
+ const vn = Ce(function({
1746
+ colStart: t,
1747
+ colEnd: n,
1748
+ colHeaderHeight: r,
1749
+ dimensions: o,
1750
+ scrollLeft: l,
1751
+ canvasWidth: c,
1752
+ frozenWidth: s,
1753
+ mode: a,
1754
+ selectionRange: i,
1755
+ headerPaneRef: u,
1756
+ paneClassName: w,
1757
+ withFrozenDivider: d = !1,
1758
+ hoveredHandle: g,
1759
+ columns: _,
1760
+ activeFilterColumns: f,
1761
+ onColumnMouseDown: b,
1762
+ onColumnMouseEnter: R,
1763
+ onFilterIconClick: y,
1764
+ onResizeHandleMouseEnter: v,
1765
+ onResizeHandleMouseLeave: h,
1766
+ onResizeStart: m
1767
+ }) {
1768
+ const M = [], E = [];
1769
+ if (n >= t)
1770
+ for (let B = t; B <= n; B++) {
1771
+ const D = a === "frozen" ? o.getColumnLeft(B) : bt(B, o, s), S = o.getColumnWidth(B), A = i !== null && B >= i.startCol && B <= i.endCol;
1772
+ M.push(
1773
+ /* @__PURE__ */ p(
1774
+ jl,
1775
+ {
1776
+ col: B,
1777
+ columnLeft: D,
1778
+ columnWidth: S,
1779
+ colHeaderHeight: r,
1780
+ isActive: A,
1781
+ columns: _,
1782
+ activeFilterColumns: f,
1783
+ onColumnMouseDown: b,
1784
+ onColumnMouseEnter: R,
1785
+ onFilterIconClick: y
1786
+ },
1787
+ B
1788
+ )
1789
+ );
1790
+ const H = (g == null ? void 0 : g.axis) === "column" && g.index === B;
1791
+ E.push(
1792
+ /* @__PURE__ */ p(
1793
+ Yl,
1794
+ {
1795
+ col: B,
1796
+ columnLeft: D,
1797
+ columnWidth: S,
1798
+ isHandleHovered: H,
1799
+ onResizeHandleMouseEnter: v,
1800
+ onResizeHandleMouseLeave: h,
1801
+ onResizeStart: m
1802
+ },
1803
+ `resize-${B}`
1804
+ )
1805
+ );
1806
+ }
1807
+ const k = w ?? (a === "frozen" ? I.frozenColumnHeaderPane : `${I.columnHeaderPane}${d ? ` ${I.scrollableWithFrozenDivider}` : ""}`);
1808
+ return /* @__PURE__ */ p(
1809
+ "div",
1810
+ {
1811
+ ref: u,
1812
+ className: k,
1813
+ style: { height: r },
1814
+ children: /* @__PURE__ */ W(
1815
+ "div",
1816
+ {
1817
+ className: I.headerCanvas,
1818
+ style: {
1819
+ width: c,
1820
+ height: r,
1821
+ transform: a === "scrollable" ? `translateX(${-l}px)` : void 0
1822
+ },
1823
+ children: [
1824
+ M,
1825
+ E
1826
+ ]
1827
+ }
1828
+ )
1829
+ }
1830
+ );
1831
+ }, $l);
1832
+ function mn(e, t, n) {
1833
+ if (e === null) return null;
1834
+ const r = Math.max(e.startRow, t), o = Math.min(e.endRow, n);
1835
+ return o < r ? null : { startRow: r, endRow: o };
1836
+ }
1837
+ function ql(e, t, n, r) {
1838
+ const o = mn(e, n, r), l = mn(t, n, r);
1839
+ return o === null || l === null ? o === l : o.startRow === l.startRow && o.endRow === l.endRow;
1840
+ }
1841
+ function Pl(e, t) {
1842
+ return e.visibleRange.startRow !== t.visibleRange.startRow || e.visibleRange.endRow !== t.visibleRange.endRow || e.dimensions !== t.dimensions || e.visibleRowIndices !== t.visibleRowIndices || e.getDisplayRowTop !== t.getDisplayRowTop || e.scrollTop !== t.scrollTop || e.totalHeight !== t.totalHeight || e.headerPaneRef !== t.headerPaneRef || e.hoveredHandle !== t.hoveredHandle || e.onRowMouseDown !== t.onRowMouseDown || e.onRowMouseEnter !== t.onRowMouseEnter || e.onResizeHandleMouseEnter !== t.onResizeHandleMouseEnter || e.onResizeHandleMouseLeave !== t.onResizeHandleMouseLeave || e.onResizeStart !== t.onResizeStart ? !1 : ql(
1843
+ e.selectionRange,
1844
+ t.selectionRange,
1845
+ t.visibleRange.startRow,
1846
+ t.visibleRange.endRow
1847
+ );
1848
+ }
1849
+ const Kl = Ce(function({
1850
+ visibleRange: t,
1851
+ dimensions: n,
1852
+ visibleRowIndices: r,
1853
+ getDisplayRowTop: o,
1854
+ scrollTop: l,
1855
+ totalHeight: c,
1856
+ selectionRange: s,
1857
+ headerPaneRef: a,
1858
+ hoveredHandle: i,
1859
+ onRowMouseDown: u,
1860
+ onRowMouseEnter: w,
1861
+ onResizeHandleMouseEnter: d,
1862
+ onResizeHandleMouseLeave: g,
1863
+ onResizeStart: _
1864
+ }) {
1865
+ const f = [], b = [];
1866
+ for (let R = t.startRow; R <= t.endRow; R++) {
1867
+ const y = (r == null ? void 0 : r[R]) !== void 0 ? r[R] : R, v = o ? o(R) : n.getRowTop(y), h = n.getRowHeight(y), m = s !== null && y >= s.startRow && y <= s.endRow;
1868
+ f.push(
1869
+ /* @__PURE__ */ p(
1870
+ "div",
1871
+ {
1872
+ className: `${I.rowHeaderCell}${m ? ` ${I.active}` : ""}`,
1873
+ style: {
1874
+ top: v,
1875
+ width: cn,
1876
+ height: h
1877
+ },
1878
+ onMouseDown: (E) => {
1879
+ E.preventDefault(), u(y);
1880
+ },
1881
+ onMouseEnter: () => w(y),
1882
+ children: y + 1
1883
+ },
1884
+ y
1885
+ )
1886
+ );
1887
+ const M = (i == null ? void 0 : i.axis) === "row" && i.index === y;
1888
+ b.push(
1889
+ /* @__PURE__ */ p(
1890
+ "div",
1891
+ {
1892
+ className: `${I.rowResizeHandle}${M ? ` ${I.resizeHandleHovered}` : ""}`,
1893
+ style: {
1894
+ top: v + h - Rt / 2,
1895
+ height: Rt
1896
+ },
1897
+ onMouseDown: (E) => {
1898
+ E.preventDefault(), E.stopPropagation(), _(y, E.clientY);
1899
+ },
1900
+ onMouseEnter: () => d({ axis: "row", index: y }),
1901
+ onMouseLeave: g,
1902
+ children: /* @__PURE__ */ p("span", { className: I.resizeHandleIcon, "aria-hidden": !0 })
1903
+ },
1904
+ `resize-${y}`
1905
+ )
1906
+ );
1907
+ }
1908
+ return /* @__PURE__ */ p("div", { ref: a, className: I.rowHeaderPane, children: /* @__PURE__ */ W(
1909
+ "div",
1910
+ {
1911
+ className: I.headerCanvas,
1912
+ style: {
1913
+ width: cn,
1914
+ height: c,
1915
+ transform: `translateY(${-l}px)`
1916
+ },
1917
+ children: [
1918
+ f,
1919
+ b
1920
+ ]
1921
+ }
1922
+ ) });
1923
+ }, Pl), Ul = Ce(function({
1924
+ store: t,
1925
+ metaStore: n,
1926
+ mergeStore: r,
1927
+ startRow: o,
1928
+ endRow: l,
1929
+ frozenColumnCount: c,
1930
+ dimensions: s,
1931
+ columns: a,
1932
+ customCellRegistry: i,
1933
+ resolvePhysicalRow: u,
1934
+ getRowTop: w,
1935
+ onCellMouseDown: d,
1936
+ onCellMouseEnter: g,
1937
+ onCellDoubleClick: _,
1938
+ onBooleanToggle: f
1939
+ }) {
1940
+ const b = N(
1941
+ (y) => s.getColumnLeft(y),
1942
+ [s]
1943
+ ), R = Y(
1944
+ () => $n({
1945
+ store: t,
1946
+ metaStore: n,
1947
+ mergeStore: r,
1948
+ dimensions: s,
1949
+ rowStart: o,
1950
+ rowEnd: l,
1951
+ colStart: 0,
1952
+ colEnd: c - 1,
1953
+ columns: a,
1954
+ customCellRegistry: i,
1955
+ getColumnLeft: b,
1956
+ resolvePhysicalRow: u,
1957
+ getRowTop: w,
1958
+ onCellMouseDown: d,
1959
+ onCellMouseEnter: g,
1960
+ onCellDoubleClick: _,
1961
+ onBooleanToggle: f
1962
+ }),
1963
+ [
1964
+ t,
1965
+ n,
1966
+ r,
1967
+ s.columnWidths,
1968
+ s.rowHeights,
1969
+ o,
1970
+ l,
1971
+ c,
1972
+ a,
1973
+ i,
1974
+ b,
1975
+ u,
1976
+ w,
1977
+ d,
1978
+ g,
1979
+ _,
1980
+ f
1981
+ ]
1982
+ );
1983
+ return /* @__PURE__ */ p(Sn, { children: R });
1984
+ }), Gl = Ce(function({
1985
+ bodyRef: t,
1986
+ store: n,
1987
+ metaStore: r,
1988
+ mergeStore: o,
1989
+ startRow: l,
1990
+ endRow: c,
1991
+ frozenColumnCount: s,
1992
+ dimensions: a,
1993
+ frozenWidth: i,
1994
+ scrollTop: u,
1995
+ totalHeight: w,
1996
+ isEditing: d,
1997
+ columns: g,
1998
+ customCellRegistry: _,
1999
+ resolvePhysicalRow: f,
2000
+ getRowTop: b,
2001
+ onCellMouseDown: R,
2002
+ onCellMouseEnter: y,
2003
+ onCellDoubleClick: v,
2004
+ onBooleanToggle: h,
2005
+ activeOverlay: m,
2006
+ selectionOverlay: M,
2007
+ clipboardOverlay: E,
2008
+ editor: k
2009
+ }) {
2010
+ return /* @__PURE__ */ p(
2011
+ "div",
2012
+ {
2013
+ ref: t,
2014
+ className: `${I.frozenBodyPane}${d ? ` ${I.frozenBodyPaneEditing}` : ""}`,
2015
+ style: { width: i },
2016
+ children: /* @__PURE__ */ W(
2017
+ "div",
2018
+ {
2019
+ className: I.canvas,
2020
+ style: {
2021
+ width: i,
2022
+ height: w,
2023
+ transform: `translateY(${-u}px)`
2024
+ },
2025
+ children: [
2026
+ /* @__PURE__ */ p(
2027
+ Ul,
2028
+ {
2029
+ store: n,
2030
+ metaStore: r,
2031
+ mergeStore: o,
2032
+ startRow: l,
2033
+ endRow: c,
2034
+ frozenColumnCount: s,
2035
+ dimensions: a,
2036
+ columns: g,
2037
+ customCellRegistry: _,
2038
+ resolvePhysicalRow: f,
2039
+ getRowTop: b,
2040
+ onCellMouseDown: R,
2041
+ onCellMouseEnter: y,
2042
+ onCellDoubleClick: v,
2043
+ onBooleanToggle: h
2044
+ }
2045
+ ),
2046
+ m,
2047
+ M,
2048
+ E,
2049
+ k
2050
+ ]
2051
+ }
2052
+ )
2053
+ }
2054
+ );
2055
+ });
2056
+ function Ql(e, t) {
2057
+ const r = Math.max(1, e.split(`
2058
+ `).length) * In + Bn;
2059
+ return Math.max(t, r);
2060
+ }
2061
+ function Jl({
2062
+ value: e,
2063
+ top: t,
2064
+ left: n,
2065
+ width: r,
2066
+ height: o,
2067
+ onCommit: l,
2068
+ onCancel: c
2069
+ }) {
2070
+ const s = V(null), a = V(e), i = V(!1), u = N(
2071
+ (f, b) => {
2072
+ i.current || (i.current = !0, l(f, b));
2073
+ },
2074
+ [l]
2075
+ ), w = N(() => {
2076
+ const f = s.current;
2077
+ f && (f.style.height = `${Ql(f.value, o)}px`);
2078
+ }, [o]);
2079
+ G(() => {
2080
+ const f = s.current;
2081
+ f && (a.current = e, i.current = !1, f.focus(), f.select(), w());
2082
+ }, [w, e]);
2083
+ const d = () => {
2084
+ var f;
2085
+ a.current = ((f = s.current) == null ? void 0 : f.value) ?? "", w();
2086
+ }, g = (f) => {
2087
+ var b, R;
2088
+ if (f.key === "Enter" && !f.altKey) {
2089
+ f.preventDefault();
2090
+ const y = ((b = s.current) == null ? void 0 : b.value) ?? "";
2091
+ a.current = y, u(y, "down");
2092
+ } else if (f.key === "Enter" && f.altKey) {
2093
+ f.preventDefault();
2094
+ const y = s.current;
2095
+ if (!y) return;
2096
+ const { selectionStart: v, selectionEnd: h, value: m } = y, M = m.slice(0, v) + `
2097
+ ` + m.slice(h);
2098
+ y.value = M, a.current = M;
2099
+ const E = v + 1;
2100
+ y.setSelectionRange(E, E), w();
2101
+ } else if (f.key === "Escape")
2102
+ f.preventDefault(), i.current = !0, c();
2103
+ else if (f.key === "Tab") {
2104
+ f.preventDefault();
2105
+ const y = ((R = s.current) == null ? void 0 : R.value) ?? "";
2106
+ a.current = y, u(y, "right");
2107
+ }
2108
+ }, _ = () => {
2109
+ requestAnimationFrame(() => {
2110
+ document.activeElement !== s.current && u(a.current, "stay");
2111
+ });
2112
+ };
2113
+ return /* @__PURE__ */ p(
2114
+ "textarea",
2115
+ {
2116
+ ref: s,
2117
+ className: I.cellEditor,
2118
+ style: { top: t, left: n, width: r },
2119
+ defaultValue: e,
2120
+ onInput: d,
2121
+ onKeyDown: g,
2122
+ onBlur: _
2123
+ }
2124
+ );
2125
+ }
2126
+ const Zl = "_root_151la_1", Xl = "_input_151la_7", es = "_dropdown_151la_21", ts = "_option_151la_38", ns = "_optionSelected_151la_52", rs = "_optionHighlighted_151la_59", os = "_optionEmpty_151la_66", ls = "_optionColor_151la_70", ss = "_optionLabel_151la_78", Ae = {
2127
+ root: Zl,
2128
+ input: Xl,
2129
+ dropdown: es,
2130
+ option: ts,
2131
+ optionSelected: ns,
2132
+ optionHighlighted: rs,
2133
+ optionEmpty: os,
2134
+ optionColor: ls,
2135
+ optionLabel: ss
2136
+ }, Un = {
2137
+ id: "",
2138
+ label: "—",
2139
+ isEmpty: !0
2140
+ };
2141
+ function Gn(e) {
2142
+ return [Un, ...e];
2143
+ }
2144
+ function cs(e, t) {
2145
+ const r = Gn(e).findIndex((o) => o.id === t);
2146
+ return Math.max(r, 0);
2147
+ }
2148
+ function as(e, t) {
2149
+ const n = t.trim().toLowerCase(), r = n ? e.filter(
2150
+ (o) => o.label.toLowerCase().includes(n) || o.id.toLowerCase().includes(n)
2151
+ ) : e;
2152
+ return [Un, ...r];
2153
+ }
2154
+ function is({
2155
+ value: e,
2156
+ options: t,
2157
+ top: n,
2158
+ left: r,
2159
+ width: o,
2160
+ height: l,
2161
+ initialInput: c,
2162
+ onCommit: s,
2163
+ onCancel: a
2164
+ }) {
2165
+ const i = V(null), u = V(null), w = V(!1), d = ol(t, e), [g, _] = $(
2166
+ () => c ?? (d == null ? void 0 : d.label) ?? ""
2167
+ ), [f, b] = $(
2168
+ () => c !== void 0
2169
+ ), [R, y] = $(!0), [v, h] = $(
2170
+ () => c !== void 0 ? 0 : cs(t, e)
2171
+ ), m = Y(() => f ? as(t, g) : Gn(t), [f, t, g]);
2172
+ G(() => {
2173
+ const S = u.current;
2174
+ S && (S.focus(), c !== void 0 ? S.setSelectionRange(S.value.length, S.value.length) : d != null && d.label && S.select());
2175
+ }, [c, d == null ? void 0 : d.label]), G(() => {
2176
+ f && h(0);
2177
+ }, [f, m]);
2178
+ const M = N(
2179
+ (S) => {
2180
+ w.current || (w.current = !0, s(S.id));
2181
+ },
2182
+ [s]
2183
+ ), E = (S) => {
2184
+ const A = S.target.value;
2185
+ _(A), f || (b(!0), h(0)), y(!0);
2186
+ }, k = (S, A) => {
2187
+ S.preventDefault(), M(A);
2188
+ }, B = (S) => {
2189
+ if (S.key === "ArrowDown")
2190
+ S.preventDefault(), y(!0), h(
2191
+ (A) => Math.min(A + 1, m.length - 1)
2192
+ );
2193
+ else if (S.key === "ArrowUp")
2194
+ S.preventDefault(), y(!0), h((A) => Math.max(A - 1, 0));
2195
+ else if (S.key === "Enter") {
2196
+ S.preventDefault();
2197
+ const A = m[v];
2198
+ A && M(A);
2199
+ } else if (S.key === "Tab") {
2200
+ S.preventDefault();
2201
+ const A = m[v];
2202
+ A && M(A);
2203
+ } else S.key === "Escape" && (S.preventDefault(), w.current = !0, a());
2204
+ }, D = () => {
2205
+ requestAnimationFrame(() => {
2206
+ if (w.current) return;
2207
+ const S = i.current;
2208
+ S != null && S.contains(document.activeElement) || a();
2209
+ });
2210
+ };
2211
+ return /* @__PURE__ */ W(
2212
+ "div",
2213
+ {
2214
+ ref: i,
2215
+ className: Ae.root,
2216
+ style: { top: n, left: r, width: o, height: kt },
2217
+ children: [
2218
+ /* @__PURE__ */ p(
2219
+ "input",
2220
+ {
2221
+ ref: u,
2222
+ type: "text",
2223
+ className: Ae.input,
2224
+ value: g,
2225
+ onChange: E,
2226
+ onKeyDown: B,
2227
+ onBlur: D,
2228
+ onFocus: () => y(!0),
2229
+ autoComplete: "off",
2230
+ role: "combobox",
2231
+ "aria-expanded": R,
2232
+ "aria-autocomplete": "list",
2233
+ "aria-controls": "select-cell-editor-listbox"
2234
+ }
2235
+ ),
2236
+ R && m.length > 0 && /* @__PURE__ */ p(
2237
+ "ul",
2238
+ {
2239
+ id: "select-cell-editor-listbox",
2240
+ className: Ae.dropdown,
2241
+ role: "listbox",
2242
+ children: m.map((S, A) => /* @__PURE__ */ W(
2243
+ "li",
2244
+ {
2245
+ role: "option",
2246
+ "aria-selected": f ? A === v : S.id === e,
2247
+ className: [
2248
+ Ae.option,
2249
+ !f && S.id === e ? Ae.optionSelected : "",
2250
+ A === v ? Ae.optionHighlighted : "",
2251
+ S.isEmpty ? Ae.optionEmpty : ""
2252
+ ].filter(Boolean).join(" "),
2253
+ onMouseDown: (H) => k(H, S),
2254
+ onMouseEnter: () => h(A),
2255
+ children: [
2256
+ S.color && /* @__PURE__ */ p(
2257
+ "span",
2258
+ {
2259
+ className: Ae.optionColor,
2260
+ style: { backgroundColor: S.color }
2261
+ }
2262
+ ),
2263
+ /* @__PURE__ */ p("span", { className: Ae.optionLabel, children: S.label })
2264
+ ]
2265
+ },
2266
+ S.id || "__empty__"
2267
+ ))
2268
+ }
2269
+ )
2270
+ ]
2271
+ }
2272
+ );
2273
+ }
2274
+ const us = "_root_jis1n_1", ds = "_trigger_jis1n_7", fs = "_chips_jis1n_20", hs = "_chip_jis1n_20", ps = "_chipLabel_jis1n_42", gs = "_dropdown_jis1n_48", ws = "_searchRow_jis1n_62", ys = "_searchIcon_jis1n_69", vs = "_searchInput_jis1n_77", ms = "_searchDivider_jis1n_91", _s = "_optionsList_jis1n_95", bs = "_optionRow_jis1n_103", Ms = "_optionRowHighlighted_jis1n_115", Cs = "_optionPill_jis1n_122", Rs = "_optionCheck_jis1n_137", ie = {
2275
+ root: us,
2276
+ trigger: ds,
2277
+ chips: fs,
2278
+ chip: hs,
2279
+ chipLabel: ps,
2280
+ dropdown: gs,
2281
+ searchRow: ws,
2282
+ searchIcon: ys,
2283
+ searchInput: vs,
2284
+ searchDivider: ms,
2285
+ optionsList: _s,
2286
+ optionRow: bs,
2287
+ optionRowHighlighted: Ms,
2288
+ optionPill: Cs,
2289
+ optionCheck: Rs
2290
+ };
2291
+ function Ds(e, t) {
2292
+ const n = t.trim().toLowerCase();
2293
+ return n ? e.filter(
2294
+ (r) => r.label.toLowerCase().includes(n) || r.id.toLowerCase().includes(n)
2295
+ ) : e;
2296
+ }
2297
+ function As() {
2298
+ return /* @__PURE__ */ W(
2299
+ "svg",
2300
+ {
2301
+ viewBox: "0 0 24 24",
2302
+ width: "16",
2303
+ height: "16",
2304
+ fill: "none",
2305
+ stroke: "currentColor",
2306
+ strokeWidth: "2",
2307
+ "aria-hidden": !0,
2308
+ children: [
2309
+ /* @__PURE__ */ p("circle", { cx: "11", cy: "11", r: "7" }),
2310
+ /* @__PURE__ */ p("line", { x1: "16.5", y1: "16.5", x2: "21", y2: "21" })
2311
+ ]
2312
+ }
2313
+ );
2314
+ }
2315
+ function ks({
2316
+ value: e,
2317
+ options: t,
2318
+ top: n,
2319
+ left: r,
2320
+ width: o,
2321
+ height: l,
2322
+ initialInput: c,
2323
+ onCommit: s,
2324
+ onCancel: a
2325
+ }) {
2326
+ const i = V(null), u = V(null), w = V(!1), d = Y(() => Xt(e), [e]), [g, _] = $(
2327
+ () => new Set(d)
2328
+ ), [f, b] = $(() => c ?? ""), [R, y] = $(!0), [v, h] = $(0), m = Y(
2329
+ () => Yn(t, Array.from(g)),
2330
+ [t, g]
2331
+ ), M = Y(
2332
+ () => Ds(t, f),
2333
+ [t, f]
2334
+ ), E = N(() => {
2335
+ w.current || (w.current = !0, s(jn(Array.from(g))));
2336
+ }, [s, g]);
2337
+ G(() => {
2338
+ const H = u.current;
2339
+ H && (H.focus(), c !== void 0 && H.setSelectionRange(H.value.length, H.value.length));
2340
+ }, [c]), G(() => {
2341
+ h(0);
2342
+ }, [f, M]);
2343
+ const k = N((H) => {
2344
+ _((q) => {
2345
+ const ee = new Set(q);
2346
+ return ee.has(H) ? ee.delete(H) : ee.add(H), ee;
2347
+ }), y(!0);
2348
+ }, []), B = (H) => {
2349
+ b(H.target.value), y(!0);
2350
+ }, D = (H, q) => {
2351
+ H.preventDefault(), k(q.id);
2352
+ }, S = (H) => {
2353
+ if (H.key === "ArrowDown")
2354
+ H.preventDefault(), y(!0), h(
2355
+ (q) => Math.min(q + 1, Math.max(M.length - 1, 0))
2356
+ );
2357
+ else if (H.key === "ArrowUp")
2358
+ H.preventDefault(), y(!0), h((q) => Math.max(q - 1, 0));
2359
+ else if (H.key === "Enter")
2360
+ H.preventDefault(), E();
2361
+ else if (H.key === " ") {
2362
+ H.preventDefault();
2363
+ const q = M[v];
2364
+ q && k(q.id);
2365
+ } else H.key === "Tab" ? (H.preventDefault(), E()) : H.key === "Escape" && (H.preventDefault(), w.current = !0, a());
2366
+ }, A = () => {
2367
+ requestAnimationFrame(() => {
2368
+ if (w.current) return;
2369
+ const H = i.current;
2370
+ H != null && H.contains(document.activeElement) || E();
2371
+ });
2372
+ };
2373
+ return /* @__PURE__ */ W(
2374
+ "div",
2375
+ {
2376
+ ref: i,
2377
+ className: ie.root,
2378
+ style: { top: n, left: r, width: o, height: kt },
2379
+ children: [
2380
+ /* @__PURE__ */ p(
2381
+ "div",
2382
+ {
2383
+ className: ie.trigger,
2384
+ onMouseDown: (H) => H.preventDefault(),
2385
+ children: /* @__PURE__ */ p("span", { className: ie.chips, children: m.map((H) => /* @__PURE__ */ p(
2386
+ "span",
2387
+ {
2388
+ className: ie.chip,
2389
+ style: {
2390
+ backgroundColor: H.color ?? qt
2391
+ },
2392
+ children: /* @__PURE__ */ p("span", { className: ie.chipLabel, children: H.label })
2393
+ },
2394
+ H.id
2395
+ )) })
2396
+ }
2397
+ ),
2398
+ R && /* @__PURE__ */ W("div", { className: ie.dropdown, children: [
2399
+ /* @__PURE__ */ W("div", { className: ie.searchRow, children: [
2400
+ /* @__PURE__ */ p("span", { className: ie.searchIcon, children: /* @__PURE__ */ p(As, {}) }),
2401
+ /* @__PURE__ */ p(
2402
+ "input",
2403
+ {
2404
+ ref: u,
2405
+ type: "text",
2406
+ className: ie.searchInput,
2407
+ value: f,
2408
+ onChange: B,
2409
+ onKeyDown: S,
2410
+ onBlur: A,
2411
+ onFocus: () => y(!0),
2412
+ autoComplete: "off",
2413
+ role: "combobox",
2414
+ "aria-expanded": R,
2415
+ "aria-autocomplete": "list",
2416
+ "aria-controls": "multi-select-cell-editor-listbox",
2417
+ placeholder: ""
2418
+ }
2419
+ )
2420
+ ] }),
2421
+ /* @__PURE__ */ p("div", { className: ie.searchDivider }),
2422
+ /* @__PURE__ */ p(
2423
+ "ul",
2424
+ {
2425
+ id: "multi-select-cell-editor-listbox",
2426
+ className: ie.optionsList,
2427
+ role: "listbox",
2428
+ "aria-multiselectable": !0,
2429
+ children: M.map((H, q) => {
2430
+ const ee = g.has(H.id);
2431
+ return /* @__PURE__ */ W(
2432
+ "li",
2433
+ {
2434
+ role: "option",
2435
+ "aria-selected": ee,
2436
+ className: [
2437
+ ie.optionRow,
2438
+ q === v ? ie.optionRowHighlighted : ""
2439
+ ].filter(Boolean).join(" "),
2440
+ onMouseDown: (P) => D(P, H),
2441
+ onMouseEnter: () => h(q),
2442
+ children: [
2443
+ /* @__PURE__ */ p(
2444
+ "span",
2445
+ {
2446
+ className: ie.optionPill,
2447
+ style: {
2448
+ backgroundColor: H.color ?? qt
2449
+ },
2450
+ children: H.label
2451
+ }
2452
+ ),
2453
+ /* @__PURE__ */ p("span", { className: ie.optionCheck, "aria-hidden": !0, children: ee ? "✓" : "" })
2454
+ ]
2455
+ },
2456
+ H.id
2457
+ );
2458
+ })
2459
+ }
2460
+ )
2461
+ ] })
2462
+ ]
2463
+ }
2464
+ );
2465
+ }
2466
+ function Es(e) {
2467
+ return String(e).padStart(2, "0");
2468
+ }
2469
+ function Qn(e) {
2470
+ return e === "DD" ? 31 : e === "MM" ? 12 : 9999;
2471
+ }
2472
+ function tn(e) {
2473
+ return e === "YYYY" ? 4 : 2;
2474
+ }
2475
+ function Jn(e) {
2476
+ return e === "DD" ? 3 : e === "MM" ? 1 : -1;
2477
+ }
2478
+ function Ss(e) {
2479
+ return e === "YYYY" ? "____" : "__";
2480
+ }
2481
+ function nn(e) {
2482
+ if (!e.query) return !1;
2483
+ const t = tn(e.type);
2484
+ if (e.type === "YYYY")
2485
+ return e.query.length >= t;
2486
+ const n = Jn(e.type), r = Number.parseInt(e.query, 10);
2487
+ return e.query.length >= t || e.query.length === 1 && r > n;
2488
+ }
2489
+ function Zn(e) {
2490
+ if (!e.query) return null;
2491
+ const t = Number.parseInt(e.query, 10);
2492
+ return Number.isNaN(t) ? null : t;
2493
+ }
2494
+ function Ls(e) {
2495
+ return nn(e) ? Zn(e) : null;
2496
+ }
2497
+ function Ns(e, t) {
2498
+ const n = Qn(e.type), r = tn(e.type), o = Jn(e.type), l = Number.parseInt(t, 10);
2499
+ if (e.type === "YYYY") {
2500
+ const a = e.query + t;
2501
+ return a.length >= r ? {
2502
+ section: { ...e, query: a.slice(0, r) },
2503
+ shouldAdvance: !0
2504
+ } : { section: { ...e, query: a }, shouldAdvance: !1 };
2505
+ }
2506
+ if (e.query === "")
2507
+ return l > o ? { section: { ...e, query: t }, shouldAdvance: !0 } : { section: { ...e, query: t }, shouldAdvance: !1 };
2508
+ const c = e.query + t;
2509
+ return Number.parseInt(c, 10) > n ? l > o ? { section: { ...e, query: t }, shouldAdvance: !0 } : { section: { ...e, query: t }, shouldAdvance: !1 } : c.length >= r ? { section: { ...e, query: c }, shouldAdvance: !0 } : { section: { ...e, query: c }, shouldAdvance: !1 };
2510
+ }
2511
+ function xs(e, t, n) {
2512
+ const r = new Date(e, t, 0).getDate();
2513
+ return Math.min(n, r);
2514
+ }
2515
+ function Xn(e, t = qe) {
2516
+ const n = Vn(t), r = Fn(t), o = e.trim() ? ut(e, t) : null;
2517
+ return { sections: n.map((c) => o ? c === "DD" ? { type: c, query: String(o.getDate()) } : c === "MM" ? { type: c, query: String(o.getMonth() + 1) } : { type: c, query: String(o.getFullYear()) } : { type: c, query: "" }), separator: r, activeSectionIndex: 0 };
2518
+ }
2519
+ function Hs(e, t = qe) {
2520
+ return Xn(Zt(e, t), t);
2521
+ }
2522
+ function er(e, t) {
2523
+ const n = e.activeSectionIndex, r = e.sections[n];
2524
+ if (!r)
2525
+ return { state: e, shouldAdvance: !1 };
2526
+ const { section: o, shouldAdvance: l } = Ns(
2527
+ r,
2528
+ t
2529
+ ), c = e.sections.map(
2530
+ (a, i) => i === n ? o : a
2531
+ );
2532
+ let s = n;
2533
+ return l && n < c.length - 1 && (s = n + 1), {
2534
+ state: { ...e, sections: c, activeSectionIndex: s },
2535
+ shouldAdvance: l
2536
+ };
2537
+ }
2538
+ function Ts(e) {
2539
+ const t = e.activeSectionIndex, n = e.sections[t];
2540
+ if (!n) return e;
2541
+ if (n.query === "") {
2542
+ if (t > 0) {
2543
+ const o = t - 1;
2544
+ e.sections[o];
2545
+ const l = e.sections.map(
2546
+ (c, s) => s === o ? { ...c, query: "" } : c
2547
+ );
2548
+ return { ...e, sections: l, activeSectionIndex: o };
2549
+ }
2550
+ return e;
2551
+ }
2552
+ const r = e.sections.map(
2553
+ (o, l) => l === t ? { ...o, query: "" } : o
2554
+ );
2555
+ return { ...e, sections: r };
2556
+ }
2557
+ function _n(e, t) {
2558
+ const n = e.activeSectionIndex + t;
2559
+ return n < 0 || n >= e.sections.length ? e : { ...e, activeSectionIndex: n };
2560
+ }
2561
+ function Is(e, t) {
2562
+ return t < 0 || t >= e.sections.length ? e : { ...e, activeSectionIndex: t };
2563
+ }
2564
+ function bn(e, t) {
2565
+ const n = e.activeSectionIndex, r = e.sections[n];
2566
+ if (!r) return e;
2567
+ const o = Qn(r.type), l = (r.type === "YYYY", 1);
2568
+ let c = Zn(r);
2569
+ c === null && (c = r.type === "YYYY" ? (/* @__PURE__ */ new Date()).getFullYear() : l);
2570
+ let s = c + t;
2571
+ r.type === "YYYY" ? s = Math.max(1, Math.min(o, s)) : (s < l && (s = o), s > o && (s = l));
2572
+ const a = e.sections.map(
2573
+ (i, u) => u === n ? { ...i, query: String(s) } : i
2574
+ );
2575
+ return { ...e, sections: a };
2576
+ }
2577
+ function Bs(e) {
2578
+ if (!e.query)
2579
+ return { text: Ss(e.type), isPlaceholder: !0 };
2580
+ if (e.type === "YYYY") {
2581
+ const t = tn(e.type);
2582
+ return e.query.length < t ? { text: e.query, isPlaceholder: !1 } : { text: e.query, isPlaceholder: !1 };
2583
+ }
2584
+ return nn(e) ? {
2585
+ text: Es(Number.parseInt(e.query, 10)),
2586
+ isPlaceholder: !1
2587
+ } : { text: e.query, isPlaceholder: !1 };
2588
+ }
2589
+ function zs(e) {
2590
+ return e.sections.every(nn);
2591
+ }
2592
+ function Vt(e) {
2593
+ if (!zs(e)) return null;
2594
+ let t = 0, n = 0, r = 0;
2595
+ for (const l of e.sections) {
2596
+ const c = Ls(l);
2597
+ if (c === null) return null;
2598
+ l.type === "DD" && (t = c), l.type === "MM" && (n = c), l.type === "YYYY" && (r = c);
2599
+ }
2600
+ if (!t || !n || !r) return null;
2601
+ t = xs(r, n, t);
2602
+ const o = new Date(r, n - 1, t);
2603
+ return o.getFullYear() !== r || o.getMonth() !== n - 1 || o.getDate() !== t ? null : o;
2604
+ }
2605
+ const Os = "_root_pvj8k_1", Vs = "_fieldRoot_pvj8k_7", Fs = "_section_pvj8k_26", js = "_sectionActive_pvj8k_31", Ys = "_sectionContent_pvj8k_31", Ws = "_sectionPlaceholder_pvj8k_43", $s = "_separator_pvj8k_47", qs = "_calendar_pvj8k_53", Ps = "_calendarPortal_pvj8k_62", Ks = "_header_pvj8k_68", Us = "_monthLabel_pvj8k_75", Gs = "_navButton_pvj8k_81", Qs = "_weekdays_pvj8k_100", Js = "_weekday_pvj8k_100", Zs = "_days_pvj8k_115", Xs = "_day_pvj8k_115", ec = "_dayEmpty_pvj8k_139", tc = "_dayDisabled_pvj8k_144", nc = "_dayToday_pvj8k_151", rc = "_daySelected_pvj8k_155", oc = "_dayHighlighted_pvj8k_173", lc = "_footer_pvj8k_178", sc = "_footerButton_pvj8k_187", Z = {
2606
+ root: Os,
2607
+ fieldRoot: Vs,
2608
+ section: Fs,
2609
+ sectionActive: js,
2610
+ sectionContent: Ys,
2611
+ sectionPlaceholder: Ws,
2612
+ separator: $s,
2613
+ calendar: qs,
2614
+ calendarPortal: Ps,
2615
+ header: Ks,
2616
+ monthLabel: Us,
2617
+ navButton: Gs,
2618
+ weekdays: Qs,
2619
+ weekday: Js,
2620
+ days: Zs,
2621
+ day: Xs,
2622
+ dayEmpty: ec,
2623
+ dayDisabled: tc,
2624
+ dayToday: nc,
2625
+ daySelected: rc,
2626
+ dayHighlighted: oc,
2627
+ footer: lc,
2628
+ footerButton: sc
2629
+ }, cc = Nn(function({
2630
+ fieldState: t,
2631
+ onFieldStateChange: n,
2632
+ onKeyDownExtra: r,
2633
+ onBlur: o,
2634
+ autoFocus: l = !0,
2635
+ className: c
2636
+ }, s) {
2637
+ const a = V(null);
2638
+ xn(s, () => a.current), G(() => {
2639
+ var d;
2640
+ l && ((d = a.current) == null || d.focus());
2641
+ }, [l]);
2642
+ const i = N(
2643
+ (d) => {
2644
+ var g;
2645
+ n(Is(t, d)), (g = a.current) == null || g.focus();
2646
+ },
2647
+ [t, n]
2648
+ ), u = N(
2649
+ (d) => {
2650
+ if (d.key === "Escape" || d.key === "Enter" || d.key === "Tab") {
2651
+ r == null || r(d);
2652
+ return;
2653
+ }
2654
+ if (d.key >= "0" && d.key <= "9") {
2655
+ d.preventDefault();
2656
+ const { state: g } = er(t, d.key);
2657
+ n(g);
2658
+ return;
2659
+ }
2660
+ if (d.key === "Backspace" || d.key === "Delete") {
2661
+ d.preventDefault(), n(Ts(t));
2662
+ return;
2663
+ }
2664
+ if (d.key === "ArrowLeft") {
2665
+ d.preventDefault(), n(_n(t, -1));
2666
+ return;
2667
+ }
2668
+ if (d.key === "ArrowRight") {
2669
+ d.preventDefault(), n(_n(t, 1));
2670
+ return;
2671
+ }
2672
+ if (d.key === "ArrowUp") {
2673
+ d.preventDefault(), n(bn(t, 1));
2674
+ return;
2675
+ }
2676
+ if (d.key === "ArrowDown") {
2677
+ d.preventDefault(), n(bn(t, -1));
2678
+ return;
2679
+ }
2680
+ r == null || r(d);
2681
+ },
2682
+ [t, n, r]
2683
+ ), w = N(() => {
2684
+ o == null || o();
2685
+ }, [o]);
2686
+ return /* @__PURE__ */ p(
2687
+ "div",
2688
+ {
2689
+ ref: a,
2690
+ className: [Z.fieldRoot, c].filter(Boolean).join(" "),
2691
+ tabIndex: 0,
2692
+ role: "group",
2693
+ "aria-haspopup": "dialog",
2694
+ "aria-expanded": !0,
2695
+ onKeyDown: u,
2696
+ onBlur: w,
2697
+ children: t.sections.map((d, g) => {
2698
+ const { text: _, isPlaceholder: f } = Bs(d), b = g === t.activeSectionIndex, R = f ? void 0 : Number.parseInt(d.query, 10);
2699
+ return /* @__PURE__ */ W("span", { children: [
2700
+ g > 0 && /* @__PURE__ */ p("span", { className: Z.separator, children: t.separator }),
2701
+ /* @__PURE__ */ p(
2702
+ "span",
2703
+ {
2704
+ className: [
2705
+ Z.section,
2706
+ b ? Z.sectionActive : ""
2707
+ ].filter(Boolean).join(" "),
2708
+ "data-section-index": g,
2709
+ onMouseDown: (y) => y.preventDefault(),
2710
+ onClick: () => i(g),
2711
+ children: /* @__PURE__ */ p(
2712
+ "span",
2713
+ {
2714
+ className: [
2715
+ Z.sectionContent,
2716
+ f ? Z.sectionPlaceholder : ""
2717
+ ].filter(Boolean).join(" "),
2718
+ role: "spinbutton",
2719
+ "aria-valuenow": R,
2720
+ "aria-valuetext": f ? void 0 : _,
2721
+ "aria-label": d.type,
2722
+ children: _
2723
+ }
2724
+ )
2725
+ }
2726
+ )
2727
+ ] }, `${d.type}-${g}`);
2728
+ })
2729
+ }
2730
+ );
2731
+ }), ac = 260, Mn = 2;
2732
+ function ic(e, t) {
2733
+ const n = Math.max(ac, e.width);
2734
+ let r = e.bottom + Mn;
2735
+ r + t > window.innerHeight && (r = e.top - t - Mn);
2736
+ let o = e.left;
2737
+ return o + n > window.innerWidth && (o = Math.max(0, window.innerWidth - n)), { top: r, left: o, width: n };
2738
+ }
2739
+ function Cn(e, t, n) {
2740
+ let r = Xn(e, t);
2741
+ return n && /^[0-9]$/.test(n) && (r = er(r, n).state), r;
2742
+ }
2743
+ function uc({
2744
+ value: e,
2745
+ dateFormat: t = qe,
2746
+ minDate: n,
2747
+ maxDate: r,
2748
+ top: o,
2749
+ left: l,
2750
+ width: c,
2751
+ height: s,
2752
+ initialInput: a,
2753
+ onCommit: i,
2754
+ onCancel: u
2755
+ }) {
2756
+ const { datepicker: w } = St(), d = V(null), g = V(null), _ = V(null), f = V(!1), b = Y(
2757
+ () => ut(e, t),
2758
+ [e, t]
2759
+ ), R = Y(
2760
+ () => Xr(n, r, t),
2761
+ [n, r, t]
2762
+ ), y = N(
2763
+ (C) => !Zr(C, R.min, R.max),
2764
+ [R]
2765
+ ), v = Y(() => {
2766
+ const C = b ?? /* @__PURE__ */ new Date();
2767
+ return { year: C.getFullYear(), month: C.getMonth() };
2768
+ }, [b]), [h, m] = $(
2769
+ () => Cn(e, t, a)
2770
+ ), [M, E] = $(v.year), [k, B] = $(v.month), [D, S] = $(() => Vt(
2771
+ Cn(e, t, a)
2772
+ ) ?? b), [A, H] = $(null), q = Y(
2773
+ () => Vt(h),
2774
+ [h]
2775
+ ), ee = Y(
2776
+ () => eo(M, k),
2777
+ [M, k]
2778
+ ), P = Y(
2779
+ () => y(/* @__PURE__ */ new Date()),
2780
+ [y]
2781
+ ), U = N((C) => {
2782
+ E(C.getFullYear()), B(C.getMonth());
2783
+ }, []), ue = N(() => {
2784
+ const C = g.current, F = _.current;
2785
+ if (!C) return;
2786
+ const oe = C.getBoundingClientRect(), ge = (F == null ? void 0 : F.offsetHeight) ?? 320;
2787
+ H(ic(oe, ge));
2788
+ }, []), re = N(
2789
+ (C) => {
2790
+ f.current || C && y(C) || (f.current = !0, i(C ? Zt(C, t) : ""));
2791
+ },
2792
+ [t, y, i]
2793
+ ), pe = N(
2794
+ (C) => {
2795
+ m(C);
2796
+ const F = Vt(C);
2797
+ F && (S(F), U(F));
2798
+ },
2799
+ [U]
2800
+ );
2801
+ Ln(() => {
2802
+ ue();
2803
+ }, [ue, M, k]), G(() => {
2804
+ const C = () => ue();
2805
+ return window.addEventListener("resize", C), window.addEventListener("scroll", C, !0), () => {
2806
+ window.removeEventListener("resize", C), window.removeEventListener("scroll", C, !0);
2807
+ };
2808
+ }, [ue]);
2809
+ const ke = () => {
2810
+ const C = hn(M, k, -1);
2811
+ E(C.year), B(C.month);
2812
+ }, Re = () => {
2813
+ const C = hn(M, k, 1);
2814
+ E(C.year), B(C.month);
2815
+ }, Ie = (C, F) => {
2816
+ C.preventDefault(), !y(F) && re(F);
2817
+ }, nt = () => {
2818
+ const C = /* @__PURE__ */ new Date();
2819
+ y(C) || re(C);
2820
+ }, Pe = () => {
2821
+ re(null);
2822
+ }, de = (C) => {
2823
+ if (C.key === "Escape") {
2824
+ C.preventDefault(), f.current = !0, u();
2825
+ return;
2826
+ }
2827
+ if (C.key === "Enter" || C.key === "Tab") {
2828
+ C.preventDefault();
2829
+ const F = q ?? D;
2830
+ F && !y(F) ? re(F) : (f.current = !0, u());
2831
+ }
2832
+ }, Ke = () => {
2833
+ requestAnimationFrame(() => {
2834
+ var F, oe;
2835
+ if (f.current) return;
2836
+ const C = document.activeElement;
2837
+ (F = d.current) != null && F.contains(C) || (oe = _.current) != null && oe.contains(C) || u();
2838
+ });
2839
+ }, Ee = q ?? b, j = /* @__PURE__ */ W(
2840
+ "div",
2841
+ {
2842
+ ref: _,
2843
+ className: `${Z.calendar} ${Z.calendarPortal}`,
2844
+ style: A ? {
2845
+ top: A.top,
2846
+ left: A.left,
2847
+ width: A.width,
2848
+ visibility: "visible"
2849
+ } : { visibility: "hidden" },
2850
+ role: "dialog",
2851
+ "aria-label": w.dialogAriaLabel,
2852
+ onWheel: (C) => C.stopPropagation(),
2853
+ children: [
2854
+ /* @__PURE__ */ W("div", { className: Z.header, children: [
2855
+ /* @__PURE__ */ p(
2856
+ "button",
2857
+ {
2858
+ type: "button",
2859
+ className: Z.navButton,
2860
+ onMouseDown: (C) => C.preventDefault(),
2861
+ onClick: ke,
2862
+ "aria-label": w.prevMonthAriaLabel,
2863
+ children: "‹"
2864
+ }
2865
+ ),
2866
+ /* @__PURE__ */ p("span", { className: Z.monthLabel, children: Jr(M, k, w.monthNames) }),
2867
+ /* @__PURE__ */ p(
2868
+ "button",
2869
+ {
2870
+ type: "button",
2871
+ className: Z.navButton,
2872
+ onMouseDown: (C) => C.preventDefault(),
2873
+ onClick: Re,
2874
+ "aria-label": w.nextMonthAriaLabel,
2875
+ children: "›"
2876
+ }
2877
+ )
2878
+ ] }),
2879
+ /* @__PURE__ */ p("div", { className: Z.weekdays, children: w.weekdayLabels.map((C) => /* @__PURE__ */ p("span", { className: Z.weekday, children: C }, C)) }),
2880
+ /* @__PURE__ */ W("div", { className: Z.days, children: [
2881
+ Array.from({ length: ee.leadingBlanks }, (C, F) => /* @__PURE__ */ p("span", { className: Z.dayEmpty, "aria-hidden": !0 }, `blank-${F}`)),
2882
+ ee.days.map((C) => {
2883
+ const F = y(C.date), oe = Ee !== null && $t(C.date, Ee), ge = D !== null && $t(C.date, D);
2884
+ return /* @__PURE__ */ p(
2885
+ "button",
2886
+ {
2887
+ type: "button",
2888
+ disabled: F,
2889
+ className: [
2890
+ Z.day,
2891
+ F ? Z.dayDisabled : "",
2892
+ C.isToday ? Z.dayToday : "",
2893
+ oe ? Z.daySelected : "",
2894
+ ge && !oe ? Z.dayHighlighted : ""
2895
+ ].filter(Boolean).join(" "),
2896
+ onMouseDown: (he) => Ie(he, C.date),
2897
+ onMouseEnter: () => {
2898
+ F || (S(C.date), m(Hs(C.date, t)));
2899
+ },
2900
+ children: C.day
2901
+ },
2902
+ C.date.toISOString()
2903
+ );
2904
+ })
2905
+ ] }),
2906
+ /* @__PURE__ */ W("div", { className: Z.footer, children: [
2907
+ /* @__PURE__ */ p(
2908
+ "button",
2909
+ {
2910
+ type: "button",
2911
+ className: Z.footerButton,
2912
+ disabled: P,
2913
+ onMouseDown: (C) => C.preventDefault(),
2914
+ onClick: nt,
2915
+ children: w.today
2916
+ }
2917
+ ),
2918
+ /* @__PURE__ */ p(
2919
+ "button",
2920
+ {
2921
+ type: "button",
2922
+ className: Z.footerButton,
2923
+ onMouseDown: (C) => C.preventDefault(),
2924
+ onClick: Pe,
2925
+ children: w.clear
2926
+ }
2927
+ )
2928
+ ] })
2929
+ ]
2930
+ }
2931
+ );
2932
+ return /* @__PURE__ */ W(
2933
+ "div",
2934
+ {
2935
+ ref: d,
2936
+ className: Z.root,
2937
+ style: { top: o, left: l, width: c, height: kt },
2938
+ children: [
2939
+ /* @__PURE__ */ p(
2940
+ cc,
2941
+ {
2942
+ ref: g,
2943
+ fieldState: h,
2944
+ onFieldStateChange: pe,
2945
+ onKeyDownExtra: de,
2946
+ onBlur: Ke
2947
+ }
2948
+ ),
2949
+ Hn(j, document.body)
2950
+ ]
2951
+ }
2952
+ );
2953
+ }
2954
+ function dc({
2955
+ top: e,
2956
+ left: t,
2957
+ width: n,
2958
+ height: r,
2959
+ children: o
2960
+ }) {
2961
+ return /* @__PURE__ */ p(
2962
+ "div",
2963
+ {
2964
+ className: I.customEditorContainer,
2965
+ style: { top: e, left: t, width: n, height: r },
2966
+ children: o
2967
+ }
2968
+ );
2969
+ }
2970
+ function fc(e, t, n, r, o, l, c) {
2971
+ var u;
2972
+ const s = (w) => /* @__PURE__ */ p(dc, { top: r, left: o, width: l, height: c, children: w });
2973
+ if (t != null && t.cellEditor)
2974
+ return s(t.cellEditor(e));
2975
+ const a = e.meta.customKey, i = a && ((u = n == null ? void 0 : n[a]) == null ? void 0 : u.editor);
2976
+ return i ? s(i(e)) : null;
2977
+ }
2978
+ function Rn({
2979
+ row: e,
2980
+ col: t,
2981
+ value: n,
2982
+ meta: r,
2983
+ column: o,
2984
+ customCellRegistry: l,
2985
+ top: c,
2986
+ left: s,
2987
+ width: a,
2988
+ height: i,
2989
+ initialInput: u,
2990
+ onCommit: w,
2991
+ onCancel: d
2992
+ }) {
2993
+ const g = r.type ?? "text";
2994
+ if (g === "custom") {
2995
+ const f = fc(
2996
+ {
2997
+ row: e,
2998
+ col: t,
2999
+ value: n,
3000
+ meta: r,
3001
+ isActive: !0,
3002
+ top: c,
3003
+ left: s,
3004
+ width: a,
3005
+ height: i,
3006
+ onCommit: (b, R) => w(b, R ?? "stay"),
3007
+ onCancel: d
3008
+ },
3009
+ o,
3010
+ l,
3011
+ c,
3012
+ s,
3013
+ a,
3014
+ i
3015
+ );
3016
+ if (f)
3017
+ return /* @__PURE__ */ p(Sn, { children: f });
3018
+ }
3019
+ return g === "select" ? /* @__PURE__ */ p(
3020
+ is,
3021
+ {
3022
+ value: n,
3023
+ options: r.options ?? [],
3024
+ top: c,
3025
+ left: s,
3026
+ width: a,
3027
+ height: i,
3028
+ initialInput: u,
3029
+ onCommit: (_) => w(_, "stay"),
3030
+ onCancel: d
3031
+ }
3032
+ ) : g === "multiSelect" ? /* @__PURE__ */ p(
3033
+ ks,
3034
+ {
3035
+ value: n,
3036
+ options: r.options ?? [],
3037
+ top: c,
3038
+ left: s,
3039
+ width: a,
3040
+ height: i,
3041
+ initialInput: u,
3042
+ onCommit: (_) => w(_, "stay"),
3043
+ onCancel: d
3044
+ }
3045
+ ) : g === "date" ? /* @__PURE__ */ p(
3046
+ uc,
3047
+ {
3048
+ value: n,
3049
+ dateFormat: r.dateFormat,
3050
+ minDate: r.minDate,
3051
+ maxDate: r.maxDate,
3052
+ top: c,
3053
+ left: s,
3054
+ width: a,
3055
+ height: i,
3056
+ initialInput: u,
3057
+ onCommit: (_) => w(_, "stay"),
3058
+ onCancel: d
3059
+ }
3060
+ ) : /* @__PURE__ */ p(
3061
+ Jl,
3062
+ {
3063
+ row: e,
3064
+ col: t,
3065
+ value: n,
3066
+ top: c,
3067
+ left: s,
3068
+ width: a,
3069
+ height: i,
3070
+ onCommit: w,
3071
+ onCancel: d
3072
+ }
3073
+ );
3074
+ }
3075
+ const Dn = Ce(function({
3076
+ range: t,
3077
+ dimensions: n,
3078
+ visibleRowLayout: r,
3079
+ columnLeftOffset: o = 0,
3080
+ showFillHandle: l = !1,
3081
+ hideLeftBorder: c = !1,
3082
+ hideRightBorder: s = !1,
3083
+ showHandle: a = !0
3084
+ }) {
3085
+ const i = r ? qn(
3086
+ r,
3087
+ t.startRow,
3088
+ t.endRow
3089
+ ) : Dt(
3090
+ n.rowHeights,
3091
+ t.startRow,
3092
+ t.endRow
3093
+ );
3094
+ if (i === null) return null;
3095
+ const u = Dt(
3096
+ n.columnWidths,
3097
+ t.startCol,
3098
+ t.endCol
3099
+ ), w = [
3100
+ I.selectionOverlay,
3101
+ l ? I.selectionOverlaySingle : "",
3102
+ c ? I.hideLeftBorder : "",
3103
+ s ? I.hideRightBorder : ""
3104
+ ].filter(Boolean).join(" ");
3105
+ return /* @__PURE__ */ p(
3106
+ "div",
3107
+ {
3108
+ className: w,
3109
+ style: {
3110
+ top: i.offset,
3111
+ left: u.offset - o,
3112
+ width: u.size,
3113
+ height: i.size
3114
+ },
3115
+ "aria-hidden": !0,
3116
+ children: a && (l ? /* @__PURE__ */ p("span", { className: I.fillHandle }) : /* @__PURE__ */ p("span", { className: I.selectionHandle }))
3117
+ }
3118
+ );
3119
+ }), An = Ce(function({
3120
+ range: t,
3121
+ dimensions: n,
3122
+ visibleRowLayout: r,
3123
+ columnLeftOffset: o = 0,
3124
+ hideLeftBorder: l = !1,
3125
+ hideRightBorder: c = !1
3126
+ }) {
3127
+ const s = r ? qn(
3128
+ r,
3129
+ t.startRow,
3130
+ t.endRow
3131
+ ) : Dt(
3132
+ n.rowHeights,
3133
+ t.startRow,
3134
+ t.endRow
3135
+ );
3136
+ if (s === null) return null;
3137
+ const a = Dt(
3138
+ n.columnWidths,
3139
+ t.startCol,
3140
+ t.endCol
3141
+ ), i = [
3142
+ I.clipboardOverlay,
3143
+ l ? I.hideLeftBorder : "",
3144
+ c ? I.hideRightBorder : ""
3145
+ ].filter(Boolean).join(" ");
3146
+ return /* @__PURE__ */ p(
3147
+ "div",
3148
+ {
3149
+ className: i,
3150
+ style: {
3151
+ top: s.offset,
3152
+ left: a.offset - o,
3153
+ width: a.size,
3154
+ height: s.size
3155
+ },
3156
+ "aria-hidden": !0
3157
+ }
3158
+ );
3159
+ });
3160
+ function Ft(e, t, n, r) {
3161
+ const { rowSpan: o, colSpan: l } = e.getSpan(n, r);
3162
+ return {
3163
+ width: $e(t.columnWidths, r, r + l - 1),
3164
+ height: $e(t.rowHeights, n, n + o - 1)
3165
+ };
3166
+ }
3167
+ const hc = Ce(function({
3168
+ store: t,
3169
+ metaStore: n,
3170
+ mergeStore: r,
3171
+ rowCount: o,
3172
+ columnCount: l,
3173
+ frozenColumnCount: c,
3174
+ columns: s,
3175
+ customCellRegistry: a,
3176
+ dimensions: i,
3177
+ visibleRowLayout: u,
3178
+ overscan: w,
3179
+ colHeaderHeight: d,
3180
+ selection: g,
3181
+ clipboardRange: _,
3182
+ editingCell: f,
3183
+ editingInitialInput: b,
3184
+ isDragging: R,
3185
+ dragMode: y,
3186
+ headerResize: v,
3187
+ sortFilterDisabled: h = !1,
3188
+ onCellMouseDown: m,
3189
+ onCellMouseEnter: M,
3190
+ onColumnHeaderMouseDown: E,
3191
+ onColumnHeaderMouseEnter: k,
3192
+ onOpenColumnFilter: B,
3193
+ openFilterCol: D,
3194
+ filterAnchorRect: S,
3195
+ columnFilters: A,
3196
+ columnSort: H,
3197
+ onApplyColumnFilter: q,
3198
+ onSortColumn: ee,
3199
+ onResetColumnFilter: P,
3200
+ onCloseColumnFilter: U,
3201
+ onRowHeaderMouseDown: ue,
3202
+ onRowHeaderMouseEnter: re,
3203
+ onCellDoubleClick: pe,
3204
+ onCommitEdit: ke,
3205
+ onCancelEdit: Re,
3206
+ onBooleanToggle: Ie
3207
+ }) {
3208
+ var rn;
3209
+ const { filter: nt } = St();
3210
+ zn(r);
3211
+ const Pe = V(null), de = V(null), Ke = V(null), Ee = V(null), j = Sr(
3212
+ c,
3213
+ l
3214
+ ), C = j > 0, F = Nr({
3215
+ rowCount: u.visibleCount,
3216
+ columnCount: l,
3217
+ rowHeights: u.displayRowHeights,
3218
+ columnWidths: i.columnWidths,
3219
+ overscan: w,
3220
+ frozenColumnCount: j
3221
+ }), {
3222
+ visibleRange: oe,
3223
+ scrollTop: ge,
3224
+ scrollLeft: he,
3225
+ scrollableTotalWidth: Be,
3226
+ frozenWidth: se
3227
+ } = F, { startRow: Se, endRow: ze, startCol: De, endCol: Oe } = oe, rt = Y(
3228
+ () => cl(u),
3229
+ [u]
3230
+ ), Ue = V(R);
3231
+ Ue.current = R;
3232
+ const ot = V(he);
3233
+ ot.current = he, Br({
3234
+ isDragging: R,
3235
+ dragMode: y,
3236
+ scrollRef: F.scrollRef,
3237
+ columnHeaderRef: Pe,
3238
+ rowHeaderRef: Ee,
3239
+ rowHeights: u.displayRowHeights,
3240
+ columnWidths: i.columnWidths,
3241
+ rowCount: u.visibleCount,
3242
+ columnCount: l,
3243
+ frozenWidth: C ? se : 0,
3244
+ frozenColumnHeaderRef: C ? de : void 0,
3245
+ frozenBodyRef: C ? Ke : void 0,
3246
+ onCellFocus: (L, O) => {
3247
+ const Q = u.visibleRowIndices[L];
3248
+ if (Q === void 0) return;
3249
+ const ae = r.resolveAnchor(Q, O);
3250
+ M(ae.row, ae.col);
3251
+ },
3252
+ onColumnFocus: k,
3253
+ onRowFocus: (L) => {
3254
+ const O = u.visibleRowIndices[L];
3255
+ O !== void 0 && re(O);
3256
+ }
3257
+ });
3258
+ const we = (g == null ? void 0 : g.focus) ?? null, lt = (g == null ? void 0 : g.anchor.row) ?? null, dt = (g == null ? void 0 : g.anchor.col) ?? null, Ve = (g == null ? void 0 : g.focus.row) ?? null, Fe = (g == null ? void 0 : g.focus.col) ?? null, ce = Y(
3259
+ () => g ? br(g, r, o, l) : null,
3260
+ [g, lt, dt, Ve, Fe, r, o, l]
3261
+ ), ye = Y(() => {
3262
+ if (Ve === null || Fe === null) return null;
3263
+ const L = r.resolveAnchor(Ve, Fe);
3264
+ return xe(L.col, j) ? L : null;
3265
+ }, [Ve, Fe, r, j]);
3266
+ G(() => {
3267
+ if (!we || R || g && Jt(g, o, l))
3268
+ return;
3269
+ const L = F.scrollRef.current;
3270
+ if (!L) return;
3271
+ const O = u.physicalToDisplay.get(we.row) ?? -1;
3272
+ if (O < 0) return;
3273
+ const Q = Pt(u, O), ae = Q + i.getRowHeight(we.row), me = L.scrollTop, at = me + L.clientHeight;
3274
+ if (Q < me ? L.scrollTop = Q : ae > at && (L.scrollTop = ae - L.clientHeight), !xe(we.col, j)) {
3275
+ const We = bt(
3276
+ we.col,
3277
+ i,
3278
+ se
3279
+ ), Ge = We + i.getColumnWidth(we.col), gt = L.scrollLeft, or = gt + L.clientWidth;
3280
+ We < gt ? L.scrollLeft = We : Ge > or && (L.scrollLeft = Ge - L.clientWidth);
3281
+ }
3282
+ }, [
3283
+ we,
3284
+ R,
3285
+ g,
3286
+ o,
3287
+ l,
3288
+ i,
3289
+ F.scrollRef,
3290
+ j,
3291
+ se,
3292
+ u
3293
+ ]);
3294
+ const fe = N(
3295
+ (L) => Pt(u, L),
3296
+ [u]
3297
+ ), st = N(
3298
+ (L) => u.visibleRowIndices[L] ?? -1,
3299
+ [u]
3300
+ ), Le = N(
3301
+ (L) => u.physicalToDisplay.get(L) ?? -1,
3302
+ [u]
3303
+ ), ft = N(
3304
+ (L) => i.getColumnLeft(L),
3305
+ [i]
3306
+ ), ht = N(
3307
+ (L) => bt(L, i, se),
3308
+ [i, se]
3309
+ ), Lt = N(
3310
+ (L, O) => {
3311
+ Ue.current && xe(O, j) && ot.current > 0 || M(L, O);
3312
+ },
3313
+ [j, M]
3314
+ ), Nt = N(
3315
+ (L) => {
3316
+ Ue.current && xe(L, j) && ot.current > 0 || k(L);
3317
+ },
3318
+ [j, k]
3319
+ ), xt = C ? Math.max(j, De) : De, Ht = Y(() => $n({
3320
+ store: t,
3321
+ metaStore: n,
3322
+ mergeStore: r,
3323
+ dimensions: i,
3324
+ rowStart: Se,
3325
+ rowEnd: ze,
3326
+ colStart: C ? j : De,
3327
+ colEnd: Oe,
3328
+ columns: s,
3329
+ customCellRegistry: a,
3330
+ selection: g,
3331
+ getColumnLeft: C ? ht : ft,
3332
+ resolvePhysicalRow: st,
3333
+ getRowTop: fe,
3334
+ onCellMouseDown: m,
3335
+ onCellMouseEnter: M,
3336
+ onCellDoubleClick: pe,
3337
+ onBooleanToggle: Ie
3338
+ }), [
3339
+ C,
3340
+ Se,
3341
+ ze,
3342
+ De,
3343
+ Oe,
3344
+ t,
3345
+ n,
3346
+ r,
3347
+ i,
3348
+ j,
3349
+ s,
3350
+ a,
3351
+ g,
3352
+ ht,
3353
+ ft,
3354
+ m,
3355
+ M,
3356
+ pe,
3357
+ Ie,
3358
+ st,
3359
+ fe
3360
+ ]), ct = _ !== null && ce !== null && dr(_, ce), je = g !== null && fr(g), Ye = Y(
3361
+ () => ce ? un(ce, j) : { frozen: null, scrollable: null },
3362
+ [ce, j]
3363
+ ), Ne = Y(
3364
+ () => _ ? un(_, j) : { frozen: null, scrollable: null },
3365
+ [_, j]
3366
+ ), pt = Y(() => {
3367
+ if (g === null || ct) return null;
3368
+ const L = Ye.frozen;
3369
+ if (L === null) return null;
3370
+ const { hideLeftBorder: O, hideRightBorder: Q } = wt(
3371
+ Ye,
3372
+ "frozen"
3373
+ ), ae = je && xe(g.focus.col, j), me = je ? ae : ce !== null && dn(ce.endCol, "frozen", j);
3374
+ return /* @__PURE__ */ p(
3375
+ Dn,
3376
+ {
3377
+ range: L,
3378
+ dimensions: i,
3379
+ visibleRowLayout: u,
3380
+ columnLeftOffset: 0,
3381
+ showFillHandle: ae,
3382
+ hideLeftBorder: O,
3383
+ hideRightBorder: Q,
3384
+ showHandle: me
3385
+ }
3386
+ );
3387
+ }, [
3388
+ g,
3389
+ ct,
3390
+ Ye,
3391
+ je,
3392
+ ce,
3393
+ j,
3394
+ i,
3395
+ u
3396
+ ]), Tt = Y(() => {
3397
+ if (_ === null) return null;
3398
+ const L = Ne.frozen;
3399
+ if (L === null) return null;
3400
+ const { hideLeftBorder: O, hideRightBorder: Q } = wt(
3401
+ Ne,
3402
+ "frozen"
3403
+ );
3404
+ return /* @__PURE__ */ p(
3405
+ An,
3406
+ {
3407
+ range: L,
3408
+ dimensions: i,
3409
+ visibleRowLayout: u,
3410
+ columnLeftOffset: 0,
3411
+ hideLeftBorder: O,
3412
+ hideRightBorder: Q
3413
+ }
3414
+ );
3415
+ }, [_, Ne, i, u]), It = Y(() => {
3416
+ if (f === null) return null;
3417
+ const { row: L, col: O } = f;
3418
+ if (!xe(O, j)) return null;
3419
+ const Q = Le(L);
3420
+ if (Q < 0) return null;
3421
+ const ae = Me(n, L, O, s), { width: me, height: at } = Ft(r, i, L, O);
3422
+ return /* @__PURE__ */ p(
3423
+ Rn,
3424
+ {
3425
+ row: L,
3426
+ col: O,
3427
+ value: t.getValue(L, O),
3428
+ meta: ae,
3429
+ column: s == null ? void 0 : s[O],
3430
+ customCellRegistry: a,
3431
+ top: fe(Q),
3432
+ left: i.getColumnLeft(O),
3433
+ width: me,
3434
+ height: at,
3435
+ initialInput: b,
3436
+ onCommit: (We, Ge) => ke(L, O, We, Ge),
3437
+ onCancel: Re
3438
+ }
3439
+ );
3440
+ }, [
3441
+ f,
3442
+ b,
3443
+ j,
3444
+ t,
3445
+ n,
3446
+ r,
3447
+ s,
3448
+ a,
3449
+ i,
3450
+ ke,
3451
+ Re,
3452
+ Le,
3453
+ fe
3454
+ ]), Bt = Y(() => {
3455
+ if (ye === null) return null;
3456
+ const L = Le(ye.row);
3457
+ if (L < 0) return null;
3458
+ const { width: O, height: Q } = Ft(
3459
+ r,
3460
+ i,
3461
+ ye.row,
3462
+ ye.col
3463
+ );
3464
+ return /* @__PURE__ */ p(
3465
+ "div",
3466
+ {
3467
+ className: I.frozenActiveOverlay,
3468
+ style: {
3469
+ top: fe(L),
3470
+ left: i.getColumnLeft(ye.col),
3471
+ width: O,
3472
+ height: Q
3473
+ }
3474
+ }
3475
+ );
3476
+ }, [
3477
+ ye,
3478
+ Le,
3479
+ r,
3480
+ i,
3481
+ fe
3482
+ ]), x = () => {
3483
+ if (g === null || ct) return null;
3484
+ const L = Ye.scrollable;
3485
+ if (L === null) return null;
3486
+ const { hideLeftBorder: O, hideRightBorder: Q } = wt(
3487
+ Ye,
3488
+ "scrollable"
3489
+ ), ae = je && !xe(g.focus.col, j), me = je ? ae : ce !== null && dn(
3490
+ ce.endCol,
3491
+ "scrollable",
3492
+ j
3493
+ );
3494
+ return /* @__PURE__ */ p(
3495
+ Dn,
3496
+ {
3497
+ range: L,
3498
+ dimensions: i,
3499
+ visibleRowLayout: u,
3500
+ columnLeftOffset: C ? se : 0,
3501
+ showFillHandle: ae,
3502
+ hideLeftBorder: O,
3503
+ hideRightBorder: Q,
3504
+ showHandle: me
3505
+ }
3506
+ );
3507
+ }, T = () => {
3508
+ if (_ === null) return null;
3509
+ const L = Ne.scrollable;
3510
+ if (L === null) return null;
3511
+ const { hideLeftBorder: O, hideRightBorder: Q } = wt(
3512
+ Ne,
3513
+ "scrollable"
3514
+ );
3515
+ return /* @__PURE__ */ p(
3516
+ An,
3517
+ {
3518
+ range: L,
3519
+ dimensions: i,
3520
+ visibleRowLayout: u,
3521
+ columnLeftOffset: C ? se : 0,
3522
+ hideLeftBorder: O,
3523
+ hideRightBorder: Q
3524
+ }
3525
+ );
3526
+ }, z = Y(() => {
3527
+ if (f === null) return null;
3528
+ const { row: L, col: O } = f;
3529
+ if (C && xe(O, j)) return null;
3530
+ const Q = Le(L);
3531
+ if (Q < 0) return null;
3532
+ const ae = C ? bt(O, i, se) : i.getColumnLeft(O), me = Me(n, L, O, s), { width: at, height: We } = Ft(r, i, L, O);
3533
+ return /* @__PURE__ */ p(
3534
+ Rn,
3535
+ {
3536
+ row: L,
3537
+ col: O,
3538
+ value: t.getValue(L, O),
3539
+ meta: me,
3540
+ column: s == null ? void 0 : s[O],
3541
+ customCellRegistry: a,
3542
+ top: fe(Q),
3543
+ left: ae,
3544
+ width: at,
3545
+ height: We,
3546
+ initialInput: b,
3547
+ onCommit: (Ge, gt) => ke(L, O, Ge, gt),
3548
+ onCancel: Re
3549
+ }
3550
+ );
3551
+ }, [
3552
+ f,
3553
+ b,
3554
+ C,
3555
+ j,
3556
+ t,
3557
+ n,
3558
+ r,
3559
+ s,
3560
+ a,
3561
+ i,
3562
+ se,
3563
+ ke,
3564
+ Re,
3565
+ Le,
3566
+ fe
3567
+ ]), K = N(
3568
+ (L, O) => {
3569
+ v.onResizeStart("column", L, O);
3570
+ },
3571
+ [v]
3572
+ ), X = N(
3573
+ (L, O) => {
3574
+ v.onResizeStart("row", L, O);
3575
+ },
3576
+ [v]
3577
+ ), te = N(
3578
+ (L) => {
3579
+ D !== null && (ee(D, L), U());
3580
+ },
3581
+ [D, ee, U]
3582
+ ), le = N(
3583
+ (L) => {
3584
+ D !== null && (q(D, L), U());
3585
+ },
3586
+ [D, q, U]
3587
+ ), ve = N(() => {
3588
+ D !== null && (P(D), U());
3589
+ }, [D, P, U]);
3590
+ return /* @__PURE__ */ W("div", { className: I.spreadsheet, role: "grid", children: [
3591
+ /* @__PURE__ */ W("div", { className: I.topRow, children: [
3592
+ /* @__PURE__ */ p(Ol, { colHeaderHeight: d }),
3593
+ C && /* @__PURE__ */ p(
3594
+ vn,
3595
+ {
3596
+ colStart: 0,
3597
+ colEnd: j - 1,
3598
+ colHeaderHeight: d,
3599
+ dimensions: i,
3600
+ scrollLeft: 0,
3601
+ canvasWidth: se,
3602
+ frozenWidth: se,
3603
+ mode: "frozen",
3604
+ selectionRange: ce,
3605
+ headerPaneRef: de,
3606
+ hoveredHandle: v.hoveredHandle,
3607
+ columns: s,
3608
+ onColumnMouseDown: E,
3609
+ onColumnMouseEnter: Nt,
3610
+ onFilterIconClick: B,
3611
+ activeFilterColumns: A,
3612
+ onResizeHandleMouseEnter: v.onResizeHandleMouseEnter,
3613
+ onResizeHandleMouseLeave: v.onResizeHandleMouseLeave,
3614
+ onResizeStart: K
3615
+ }
3616
+ ),
3617
+ /* @__PURE__ */ p(
3618
+ vn,
3619
+ {
3620
+ colStart: xt,
3621
+ colEnd: Oe,
3622
+ colHeaderHeight: d,
3623
+ dimensions: i,
3624
+ scrollLeft: he,
3625
+ canvasWidth: C ? Be : F.totalWidth,
3626
+ frozenWidth: se,
3627
+ mode: "scrollable",
3628
+ withFrozenDivider: C,
3629
+ selectionRange: ce,
3630
+ headerPaneRef: Pe,
3631
+ hoveredHandle: v.hoveredHandle,
3632
+ columns: s,
3633
+ onColumnMouseDown: E,
3634
+ onColumnMouseEnter: k,
3635
+ onFilterIconClick: B,
3636
+ activeFilterColumns: A,
3637
+ onResizeHandleMouseEnter: v.onResizeHandleMouseEnter,
3638
+ onResizeHandleMouseLeave: v.onResizeHandleMouseLeave,
3639
+ onResizeStart: K
3640
+ }
3641
+ )
3642
+ ] }),
3643
+ /* @__PURE__ */ W("div", { className: I.bottomRow, children: [
3644
+ /* @__PURE__ */ p(
3645
+ Kl,
3646
+ {
3647
+ visibleRange: oe,
3648
+ dimensions: i,
3649
+ visibleRowIndices: u.visibleRowIndices,
3650
+ getDisplayRowTop: fe,
3651
+ scrollTop: ge,
3652
+ totalHeight: rt,
3653
+ selectionRange: ce,
3654
+ headerPaneRef: Ee,
3655
+ hoveredHandle: v.hoveredHandle,
3656
+ onRowMouseDown: ue,
3657
+ onRowMouseEnter: re,
3658
+ onResizeHandleMouseEnter: v.onResizeHandleMouseEnter,
3659
+ onResizeHandleMouseLeave: v.onResizeHandleMouseLeave,
3660
+ onResizeStart: X
3661
+ }
3662
+ ),
3663
+ C && /* @__PURE__ */ p(
3664
+ Gl,
3665
+ {
3666
+ bodyRef: Ke,
3667
+ store: t,
3668
+ metaStore: n,
3669
+ mergeStore: r,
3670
+ startRow: Se,
3671
+ endRow: ze,
3672
+ frozenColumnCount: j,
3673
+ dimensions: i,
3674
+ frozenWidth: se,
3675
+ scrollTop: ge,
3676
+ totalHeight: rt,
3677
+ isEditing: f !== null,
3678
+ columns: s,
3679
+ customCellRegistry: a,
3680
+ resolvePhysicalRow: st,
3681
+ getRowTop: fe,
3682
+ onCellMouseDown: m,
3683
+ onCellMouseEnter: Lt,
3684
+ onCellDoubleClick: pe,
3685
+ onBooleanToggle: Ie,
3686
+ activeOverlay: Bt,
3687
+ selectionOverlay: pt,
3688
+ clipboardOverlay: Tt,
3689
+ editor: It
3690
+ }
3691
+ ),
3692
+ /* @__PURE__ */ p(
3693
+ "div",
3694
+ {
3695
+ ref: F.scrollRef,
3696
+ className: `${I.bodyScroll}${C ? ` ${I.scrollableWithFrozenDivider}` : ""}`,
3697
+ children: /* @__PURE__ */ W(
3698
+ "div",
3699
+ {
3700
+ className: I.canvas,
3701
+ style: {
3702
+ width: C ? Be : F.totalWidth,
3703
+ height: rt
3704
+ },
3705
+ children: [
3706
+ Ht,
3707
+ x(),
3708
+ T(),
3709
+ z
3710
+ ]
3711
+ }
3712
+ )
3713
+ }
3714
+ )
3715
+ ] }),
3716
+ D !== null && S !== null && ((rn = s == null ? void 0 : s[D]) == null ? void 0 : rn.showFilter) && /* @__PURE__ */ p(
3717
+ Bl,
3718
+ {
3719
+ anchorRect: S,
3720
+ filterState: A.get(D) ?? {
3721
+ condition: "none",
3722
+ selectedValues: null
3723
+ },
3724
+ activeSortDirection: (H == null ? void 0 : H.col) === D ? H.direction : void 0,
3725
+ sortFilterDisabled: h,
3726
+ valueOptions: zl(
3727
+ [
3728
+ ...new Set(
3729
+ Array.from({ length: o }, (L, O) => {
3730
+ const Q = t.getValue(O, D);
3731
+ return Q.trim() === "" ? Ct : Q;
3732
+ })
3733
+ )
3734
+ ].sort((L, O) => L.localeCompare(O)),
3735
+ nt.blankCells
3736
+ ),
3737
+ onSort: te,
3738
+ onApply: le,
3739
+ onReset: ve,
3740
+ onCancel: U
3741
+ }
3742
+ )
3743
+ ] });
3744
+ });
3745
+ function pc(e, t, n, r, o, l) {
3746
+ const c = o !== void 0 ? new Set(o) : null, s = [];
3747
+ for (const { row: a, col: i } of hr(t))
3748
+ c && !c.has(a) || (l == null ? void 0 : l.getRole(a, i)) !== "covered" && (r && !r(a, i) || e.getValue(a, i) !== "" && s.push({ row: a, col: i, value: "" }));
3749
+ s.length !== 0 && (e.setValues(s), n == null || n(s));
3750
+ }
3751
+ function gc(e) {
3752
+ return e.length === 1 && !e.startsWith("Arrow");
3753
+ }
3754
+ function wc(e, t, n, r, o, l) {
3755
+ const c = r.getMergeAt(e.row, e.col);
3756
+ if (c) {
3757
+ if (n > 0)
3758
+ return {
3759
+ row: e.row,
3760
+ col: Math.min(l - 1, c.anchorCol + c.colSpan)
3761
+ };
3762
+ if (n < 0)
3763
+ return {
3764
+ row: e.row,
3765
+ col: Math.max(0, c.anchorCol - 1)
3766
+ };
3767
+ if (t > 0)
3768
+ return {
3769
+ row: Math.min(o - 1, c.anchorRow + c.rowSpan),
3770
+ col: e.col
3771
+ };
3772
+ if (t < 0)
3773
+ return {
3774
+ row: Math.max(0, c.anchorRow - 1),
3775
+ col: e.col
3776
+ };
3777
+ }
3778
+ const s = Math.max(0, Math.min(o - 1, e.row + t)), a = Math.max(0, Math.min(l - 1, e.col + n));
3779
+ return r.resolveAnchor(s, a);
3780
+ }
3781
+ function yc({
3782
+ rowCount: e,
3783
+ columnCount: t,
3784
+ selection: n,
3785
+ editingCell: r,
3786
+ setSelection: o,
3787
+ startEditing: l,
3788
+ store: c,
3789
+ metaStore: s,
3790
+ mergeStore: a,
3791
+ columnsRef: i,
3792
+ visibleRowIndicesRef: u,
3793
+ containerRef: w,
3794
+ onChange: d,
3795
+ onCopy: g,
3796
+ onPaste: _
3797
+ }) {
3798
+ const f = N(
3799
+ (y, v) => {
3800
+ const h = (n == null ? void 0 : n.focus) ?? { row: 0, col: 0 }, m = wc(
3801
+ h,
3802
+ y,
3803
+ v,
3804
+ a,
3805
+ e,
3806
+ t
3807
+ );
3808
+ o(_e(m));
3809
+ },
3810
+ [n, e, t, o, a]
3811
+ ), b = N(
3812
+ (y, v) => {
3813
+ const h = a.resolveAnchor(y.row, y.col), m = Me(
3814
+ s,
3815
+ h.row,
3816
+ h.col,
3817
+ i.current ?? void 0
3818
+ );
3819
+ On(m) && l(h, v);
3820
+ },
3821
+ [i, s, a, l]
3822
+ ), R = N(
3823
+ (y, v) => {
3824
+ const h = a.resolveAnchor(y, v), m = Me(
3825
+ s,
3826
+ h.row,
3827
+ h.col,
3828
+ i.current ?? void 0
3829
+ );
3830
+ return !Et(m);
3831
+ },
3832
+ [i, s, a]
3833
+ );
3834
+ G(() => {
3835
+ const y = w.current;
3836
+ if (!y) return;
3837
+ const v = (h) => {
3838
+ if (!r && n)
3839
+ switch (h.key) {
3840
+ case "ArrowUp":
3841
+ h.preventDefault(), f(-1, 0);
3842
+ break;
3843
+ case "ArrowDown":
3844
+ h.preventDefault(), f(1, 0);
3845
+ break;
3846
+ case "ArrowLeft":
3847
+ h.preventDefault(), f(0, -1);
3848
+ break;
3849
+ case "ArrowRight":
3850
+ h.preventDefault(), f(0, 1);
3851
+ break;
3852
+ case "Enter":
3853
+ h.preventDefault(), b(n.focus);
3854
+ break;
3855
+ case "Tab":
3856
+ h.preventDefault(), f(0, h.shiftKey ? -1 : 1);
3857
+ break;
3858
+ case "F2":
3859
+ h.preventDefault(), b(n.focus);
3860
+ break;
3861
+ case "Delete":
3862
+ case "Backspace": {
3863
+ h.preventDefault();
3864
+ const m = u.current ?? [], M = m.length < e;
3865
+ pc(
3866
+ c,
3867
+ et(n),
3868
+ d,
3869
+ R,
3870
+ M ? m : void 0,
3871
+ a
3872
+ );
3873
+ break;
3874
+ }
3875
+ default:
3876
+ if ((h.ctrlKey || h.metaKey) && h.key === "c") {
3877
+ h.preventDefault(), g == null || g();
3878
+ break;
3879
+ }
3880
+ if ((h.ctrlKey || h.metaKey) && h.key === "v") {
3881
+ h.preventDefault(), _ == null || _();
3882
+ break;
3883
+ }
3884
+ if (gc(h.key) && !h.ctrlKey && !h.metaKey && !h.altKey) {
3885
+ if (Me(
3886
+ s,
3887
+ n.focus.row,
3888
+ n.focus.col,
3889
+ i.current ?? void 0
3890
+ ).type === "date") {
3891
+ h.key >= "0" && h.key <= "9" && (h.preventDefault(), b(n.focus, h.key));
3892
+ break;
3893
+ }
3894
+ h.preventDefault(), b(n.focus, h.key);
3895
+ }
3896
+ break;
3897
+ }
3898
+ };
3899
+ return y.addEventListener("keydown", v), () => y.removeEventListener("keydown", v);
3900
+ }, [
3901
+ n,
3902
+ r,
3903
+ f,
3904
+ b,
3905
+ R,
3906
+ w,
3907
+ c,
3908
+ d,
3909
+ g,
3910
+ _,
3911
+ e,
3912
+ u,
3913
+ a
3914
+ ]);
3915
+ }
3916
+ function vc(e, t, n) {
3917
+ const r = n !== void 0 ? al(t, n) : Array.from(
3918
+ { length: t.endRow - t.startRow + 1 },
3919
+ (s, a) => t.startRow + a
3920
+ ), o = t.endCol - t.startCol + 1, l = [];
3921
+ for (const s of r) {
3922
+ const a = [];
3923
+ for (let i = 0; i < o; i++)
3924
+ a.push(e.getValue(s, t.startCol + i));
3925
+ l.push(a);
3926
+ }
3927
+ return { range: r.length > 0 ? {
3928
+ startRow: r[0],
3929
+ endRow: r[r.length - 1],
3930
+ startCol: t.startCol,
3931
+ endCol: t.endCol
3932
+ } : t, values: l };
3933
+ }
3934
+ function mc(e) {
3935
+ return e.values.map((t) => t.join(" ")).join(`
3936
+ `);
3937
+ }
3938
+ function _c(e) {
3939
+ return e ? e.split(/\r?\n/).map((t) => t.split(" ")) : [[""]];
3940
+ }
3941
+ function bc(e, t, n, r, o, l, c, s) {
3942
+ const a = [], i = s !== void 0 && s.length < o, u = i ? s.indexOf(n) : -1;
3943
+ if (i && u < 0)
3944
+ return a;
3945
+ for (let w = 0; w < t.length; w++) {
3946
+ const d = i ? s[u + w] : n + w;
3947
+ if (d === void 0 || d >= o) break;
3948
+ const g = t[w] ?? [];
3949
+ for (let _ = 0; _ < g.length; _++) {
3950
+ const f = r + _;
3951
+ if (f >= l) break;
3952
+ if (c && !c(d, f)) continue;
3953
+ const b = g[_] ?? "";
3954
+ e.getValue(d, f) !== b && a.push({ row: d, col: f, value: b });
3955
+ }
3956
+ }
3957
+ return a.length > 0 && e.setValues(a), a;
3958
+ }
3959
+ function Mc({
3960
+ store: e,
3961
+ metaStore: t,
3962
+ mergeStore: n,
3963
+ columnsRef: r,
3964
+ rowCount: o,
3965
+ columnCount: l,
3966
+ visibleRowIndicesRef: c,
3967
+ onChange: s,
3968
+ onError: a,
3969
+ locale: i
3970
+ }) {
3971
+ const [u, w] = $(null), d = N(
3972
+ (b, R) => {
3973
+ const y = n.resolveAnchor(b, R), v = Me(
3974
+ t,
3975
+ y.row,
3976
+ y.col,
3977
+ r.current ?? void 0
3978
+ );
3979
+ return !Et(v);
3980
+ },
3981
+ [t, r, n]
3982
+ ), g = N(() => {
3983
+ w(null);
3984
+ }, []), _ = N(
3985
+ (b) => {
3986
+ var M;
3987
+ const R = et(b);
3988
+ if (n.rangeIntersectsMerge(R)) {
3989
+ a == null || a({
3990
+ code: "MERGE_COPY_NOT_ALLOWED",
3991
+ message: i.errors.copyMergedNotAllowed
3992
+ });
3993
+ return;
3994
+ }
3995
+ const y = c.current ?? [], v = y.length < o, h = vc(
3996
+ e,
3997
+ R,
3998
+ v ? y : void 0
3999
+ );
4000
+ w(h);
4001
+ const m = mc(h);
4002
+ (M = navigator.clipboard) == null || M.writeText(m).catch(() => {
4003
+ });
4004
+ },
4005
+ [e, o, c, n, a, i]
4006
+ ), f = N(
4007
+ async (b) => {
4008
+ var E;
4009
+ let R = (u == null ? void 0 : u.values) ?? null;
4010
+ if (!R)
4011
+ try {
4012
+ const k = await ((E = navigator.clipboard) == null ? void 0 : E.readText());
4013
+ k && (R = _c(k));
4014
+ } catch {
4015
+ }
4016
+ if (!R || R.length === 0) return;
4017
+ const y = n.resolveAnchor(b.row, b.col), v = {
4018
+ startRow: y.row,
4019
+ endRow: y.row + R.length - 1,
4020
+ startCol: y.col,
4021
+ endCol: y.col + Math.max(0, ...R.map((k) => k.length)) - 1
4022
+ };
4023
+ if (n.rangeIntersectsMerge(v)) {
4024
+ a == null || a({
4025
+ code: "MERGE_PASTE_NOT_ALLOWED",
4026
+ message: i.errors.pasteMergedNotAllowed
4027
+ });
4028
+ return;
4029
+ }
4030
+ const h = c.current ?? [], m = h.length < o, M = bc(
4031
+ e,
4032
+ R,
4033
+ y.row,
4034
+ y.col,
4035
+ o,
4036
+ l,
4037
+ d,
4038
+ m ? h : void 0
4039
+ );
4040
+ M.length > 0 && (s == null || s(M)), w(null);
4041
+ },
4042
+ [
4043
+ u,
4044
+ e,
4045
+ o,
4046
+ l,
4047
+ s,
4048
+ d,
4049
+ c,
4050
+ n,
4051
+ a,
4052
+ i
4053
+ ]
4054
+ );
4055
+ return { clipboard: u, handleCopy: _, handlePaste: f, clearClipboard: g };
4056
+ }
4057
+ function mt(e, t, n) {
4058
+ const r = {
4059
+ anchor: t ? t(e.anchor.row, e.anchor.col) : e.anchor,
4060
+ focus: t ? t(e.focus.row, e.focus.col) : e.focus
4061
+ };
4062
+ return n ? n(r) : r;
4063
+ }
4064
+ function Cc({
4065
+ initialCell: e = { row: 0, col: 0 },
4066
+ rowCount: t,
4067
+ columnCount: n,
4068
+ resolveCell: r,
4069
+ expandSelection: o
4070
+ }) {
4071
+ const [l, c] = $(
4072
+ () => _e(e)
4073
+ ), s = V(!1), a = V("cell"), [i, u] = $(!1), [w, d] = $("cell"), g = N(
4074
+ (h) => {
4075
+ c(
4076
+ mt(h, r, o)
4077
+ );
4078
+ },
4079
+ [r, o]
4080
+ ), _ = N(
4081
+ (h, m) => {
4082
+ a.current = "cell", d("cell"), s.current = !0, u(!0);
4083
+ const M = r ? r(h, m) : { row: h, col: m };
4084
+ c(
4085
+ mt(
4086
+ _e(M),
4087
+ r,
4088
+ o
4089
+ )
4090
+ );
4091
+ },
4092
+ [r, o]
4093
+ ), f = N(
4094
+ (h, m) => {
4095
+ if (!s.current || a.current !== "cell") return;
4096
+ const M = r ? r(h, m) : { row: h, col: m };
4097
+ c((E) => mt(
4098
+ E ? { anchor: E.anchor, focus: M } : _e(M),
4099
+ r,
4100
+ o
4101
+ ));
4102
+ },
4103
+ [r, o]
4104
+ ), b = N(
4105
+ (h) => {
4106
+ a.current = "column", d("column"), s.current = !0, u(!0), c(ln(h, t));
4107
+ },
4108
+ [t]
4109
+ ), R = N(
4110
+ (h) => {
4111
+ !s.current || a.current !== "column" || c((m) => m ? {
4112
+ anchor: m.anchor,
4113
+ focus: { row: t - 1, col: h }
4114
+ } : ln(h, t));
4115
+ },
4116
+ [t]
4117
+ ), y = N(
4118
+ (h) => {
4119
+ a.current = "row", d("row"), s.current = !0, u(!0), c(sn(h, n));
4120
+ },
4121
+ [n]
4122
+ ), v = N(
4123
+ (h) => {
4124
+ !s.current || a.current !== "row" || c((m) => m ? {
4125
+ anchor: m.anchor,
4126
+ focus: { row: h, col: n - 1 }
4127
+ } : sn(h, n));
4128
+ },
4129
+ [n]
4130
+ );
4131
+ return G(() => {
4132
+ const h = () => {
4133
+ s.current && (s.current = !1, u(!1));
4134
+ };
4135
+ return document.addEventListener("mouseup", h), () => document.removeEventListener("mouseup", h);
4136
+ }, []), {
4137
+ selection: l,
4138
+ setSelection: g,
4139
+ handleCellMouseDown: _,
4140
+ handleCellMouseEnter: f,
4141
+ handleColumnHeaderMouseDown: b,
4142
+ handleColumnHeaderMouseEnter: R,
4143
+ handleRowHeaderMouseDown: y,
4144
+ handleRowHeaderMouseEnter: v,
4145
+ isDragging: i,
4146
+ dragMode: w
4147
+ };
4148
+ }
4149
+ function Rc({
4150
+ rowCount: e,
4151
+ columnCount: t,
4152
+ defaultRowHeight: n,
4153
+ defaultColumnWidth: r,
4154
+ initialColumnWidths: o
4155
+ }) {
4156
+ const [l, c] = $(() => o != null && o.length ? zt(o, t, r) : Array.from({ length: t }, () => r)), [s, a] = $(
4157
+ () => Array.from({ length: e }, () => n)
4158
+ ), [i, u] = $(
4159
+ () => /* @__PURE__ */ new Set()
4160
+ );
4161
+ G(() => {
4162
+ c(
4163
+ (m) => zt(m, t, r)
4164
+ );
4165
+ }, [t, r]), G(() => {
4166
+ a((m) => zt(m, e, n));
4167
+ }, [e, n]);
4168
+ const w = N(
4169
+ (m) => Wt(l, m),
4170
+ [l]
4171
+ ), d = N(
4172
+ (m) => Wt(s, m),
4173
+ [s]
4174
+ ), g = N(
4175
+ (m) => l[m] ?? r,
4176
+ [l, r]
4177
+ ), _ = N(
4178
+ (m) => s[m] ?? n,
4179
+ [s, n]
4180
+ ), f = N((m, M) => {
4181
+ const E = Math.max(kr, M);
4182
+ c((k) => {
4183
+ if (k[m] === E) return k;
4184
+ const B = [...k];
4185
+ return B[m] = E, B;
4186
+ });
4187
+ }, []), b = N((m, M) => {
4188
+ const E = Math.max(an, M);
4189
+ a((k) => {
4190
+ if (k[m] === E) return k;
4191
+ const B = [...k];
4192
+ return B[m] = E, B;
4193
+ });
4194
+ }, []), R = N((m, M) => {
4195
+ const E = Math.max(an, M);
4196
+ a((k) => {
4197
+ if (k[m] === E) return k;
4198
+ const B = [...k];
4199
+ return B[m] = E, B;
4200
+ }), u((k) => {
4201
+ if (k.has(m)) return k;
4202
+ const B = new Set(k);
4203
+ return B.add(m), B;
4204
+ });
4205
+ }, []), y = N(
4206
+ (m) => i.has(m),
4207
+ [i]
4208
+ ), v = Y(() => be(l), [l]), h = Y(() => be(s), [s]);
4209
+ return Y(
4210
+ () => ({
4211
+ columnWidths: l,
4212
+ rowHeights: s,
4213
+ getColumnLeft: w,
4214
+ getRowTop: d,
4215
+ getColumnWidth: g,
4216
+ getRowHeight: _,
4217
+ totalWidth: v,
4218
+ totalHeight: h,
4219
+ setColumnWidth: f,
4220
+ setRowHeight: b,
4221
+ setRowHeightManual: R,
4222
+ isRowHeightManual: y
4223
+ }),
4224
+ [
4225
+ l,
4226
+ s,
4227
+ w,
4228
+ d,
4229
+ g,
4230
+ _,
4231
+ v,
4232
+ h,
4233
+ f,
4234
+ b,
4235
+ R,
4236
+ y
4237
+ ]
4238
+ );
4239
+ }
4240
+ function Dc({
4241
+ dimensions: e,
4242
+ onColumnResize: t,
4243
+ onRowResize: n
4244
+ }) {
4245
+ const [r, o] = $(
4246
+ null
4247
+ ), [l, c] = $(!1), s = V(null), a = V(e), i = V(t), u = V(n);
4248
+ G(() => {
4249
+ a.current = e;
4250
+ }, [e]), G(() => {
4251
+ i.current = t;
4252
+ }, [t]), G(() => {
4253
+ u.current = n;
4254
+ }, [n]);
4255
+ const w = N((_) => {
4256
+ o(_);
4257
+ }, []), d = N(() => {
4258
+ s.current || o(null);
4259
+ }, []), g = N(
4260
+ (_, f, b) => {
4261
+ const R = _ === "column" ? a.current.getColumnWidth(f) : a.current.getRowHeight(f);
4262
+ s.current = {
4263
+ axis: _,
4264
+ index: f,
4265
+ startPos: b,
4266
+ startSize: R
4267
+ }, o({ axis: _, index: f }), c(!0);
4268
+ },
4269
+ []
4270
+ );
4271
+ return G(() => {
4272
+ if (!l) return;
4273
+ const _ = (b) => {
4274
+ const R = s.current;
4275
+ if (!R) return;
4276
+ document.body.style.cursor = R.axis === "column" ? "col-resize" : "row-resize";
4277
+ const y = R.axis === "column" ? b.clientX - R.startPos : b.clientY - R.startPos, v = R.startSize + y;
4278
+ R.axis === "column" ? a.current.setColumnWidth(R.index, v) : a.current.setRowHeightManual(R.index, v);
4279
+ }, f = () => {
4280
+ var R, y;
4281
+ document.body.style.cursor = "";
4282
+ const b = s.current;
4283
+ b && (b.axis === "column" ? (R = i.current) == null || R.call(
4284
+ i,
4285
+ b.index,
4286
+ a.current.getColumnWidth(b.index)
4287
+ ) : (y = u.current) == null || y.call(
4288
+ u,
4289
+ b.index,
4290
+ a.current.getRowHeight(b.index)
4291
+ )), s.current = null, c(!1), o(null);
4292
+ };
4293
+ return document.addEventListener("mousemove", _), document.addEventListener("mouseup", f), () => {
4294
+ document.removeEventListener("mousemove", _), document.removeEventListener("mouseup", f);
4295
+ };
4296
+ }, [l]), Y(
4297
+ () => ({
4298
+ hoveredHandle: r,
4299
+ isResizing: l,
4300
+ onResizeHandleMouseEnter: w,
4301
+ onResizeHandleMouseLeave: d,
4302
+ onResizeStart: g
4303
+ }),
4304
+ [
4305
+ r,
4306
+ l,
4307
+ w,
4308
+ d,
4309
+ g
4310
+ ]
4311
+ );
4312
+ }
4313
+ const Ac = /^\d+:\d+$/;
4314
+ function kc(e) {
4315
+ return Array.isArray(e) && (e.length === 0 || Array.isArray(e[0]));
4316
+ }
4317
+ function Ec(e) {
4318
+ return Array.isArray(e) && e.length > 0 && typeof e[0] == "object" && e[0] !== null && !Array.isArray(e[0]);
4319
+ }
4320
+ function tr(e) {
4321
+ var t;
4322
+ return ((t = e == null ? void 0 : e.meta) == null ? void 0 : t.type) === "multiSelect";
4323
+ }
4324
+ function Ut(e, t) {
4325
+ return tr(t) ? Array.isArray(e) ? jn(e) : typeof e == "string" && e !== "" ? e : "" : String(e ?? "");
4326
+ }
4327
+ function Gt(e, t) {
4328
+ return tr(t) ? Xt(e) : e;
4329
+ }
4330
+ function Sc(e) {
4331
+ if (typeof e != "object" || e === null || Array.isArray(e))
4332
+ return !1;
4333
+ const t = Object.keys(e);
4334
+ return t.length === 0 || t.every((n) => Ac.test(n));
4335
+ }
4336
+ function Je(e, t, n) {
4337
+ if (e != null)
4338
+ return e;
4339
+ if (!t)
4340
+ throw new Error("colName is required when col is null");
4341
+ if (!(n != null && n.length))
4342
+ throw new Error("columns prop is required when using colName");
4343
+ const r = n.findIndex((o) => o.colName === t);
4344
+ if (r === -1)
4345
+ throw new Error(`Unknown colName: ${t}`);
4346
+ return r;
4347
+ }
4348
+ function Lc(e) {
4349
+ const t = {};
4350
+ for (let n = 0; n < e.length; n++)
4351
+ for (let r = 0; r < e[n].length; r++) {
4352
+ const o = e[n][r];
4353
+ o !== "" && (t[ne(n, r)] = o);
4354
+ }
4355
+ return t;
4356
+ }
4357
+ function Nc(e, t) {
4358
+ const n = {};
4359
+ for (let r = 0; r < e.length; r++) {
4360
+ const o = e[r];
4361
+ for (let l = 0; l < t.length; l++) {
4362
+ const c = t[l], s = o[c.colName], a = Ut(
4363
+ s ?? "",
4364
+ c
4365
+ );
4366
+ a !== "" && (n[ne(r, l)] = a);
4367
+ }
4368
+ }
4369
+ return n;
4370
+ }
4371
+ function kn(e, t) {
4372
+ if (Sc(e))
4373
+ return e;
4374
+ if (kc(e))
4375
+ return Lc(e);
4376
+ if (Ec(e)) {
4377
+ if (!(t != null && t.length))
4378
+ throw new Error(
4379
+ "columns prop is required when initialData is an object array"
4380
+ );
4381
+ return Nc(e, t);
4382
+ }
4383
+ throw new Error("Unsupported data format");
4384
+ }
4385
+ function nr(e, t, n) {
4386
+ if (!(t != null && t.length)) {
4387
+ const o = {};
4388
+ for (const l of e.getKeys()) {
4389
+ const { row: c, col: s } = Tn(l);
4390
+ if (c !== n) continue;
4391
+ const a = e.getValue(n, s);
4392
+ a !== "" && (o[l] = a);
4393
+ }
4394
+ return o;
4395
+ }
4396
+ const r = {};
4397
+ for (let o = 0; o < t.length; o++) {
4398
+ const l = t[o], c = e.getValue(n, o);
4399
+ c !== "" && (r[l.colName] = Gt(c, l));
4400
+ }
4401
+ return r;
4402
+ }
4403
+ function xc(e, t, n) {
4404
+ if (!(t != null && t.length))
4405
+ return e.getAllData();
4406
+ const r = [];
4407
+ for (let o = 0; o < n; o++) {
4408
+ const l = nr(e, t, o);
4409
+ Object.keys(l).length > 0 && r.push(l);
4410
+ }
4411
+ return r;
4412
+ }
4413
+ function rr(e, t) {
4414
+ return Math.max(e, (t == null ? void 0 : t.length) ?? 0);
4415
+ }
4416
+ function Hc(e, t, n) {
4417
+ if (!(n != null && n.length)) return;
4418
+ const r = rr(e, n);
4419
+ return Array.from(
4420
+ { length: r },
4421
+ (o, l) => {
4422
+ var c;
4423
+ return ((c = n[l]) == null ? void 0 : c.width) ?? t;
4424
+ }
4425
+ );
4426
+ }
4427
+ function Tc(e) {
4428
+ return e.trim() === "";
4429
+ }
4430
+ function En(e) {
4431
+ const t = Number(e);
4432
+ return Number.isFinite(t) ? t : null;
4433
+ }
4434
+ function Ic(e, t) {
4435
+ const n = En(e), r = En(t);
4436
+ return n !== null && r !== null ? n - r : e.localeCompare(t, void 0, { sensitivity: "base" });
4437
+ }
4438
+ function Bc(e, t, n, r) {
4439
+ const o = [], l = [];
4440
+ for (const s of r)
4441
+ Tc(e.getValue(s, t)) ? l.push(s) : o.push(s);
4442
+ const c = [...o];
4443
+ return c.sort((s, a) => {
4444
+ const i = Ic(
4445
+ e.getValue(s, t),
4446
+ e.getValue(a, t)
4447
+ );
4448
+ return i !== 0 ? n === "asc" ? i : -i : s - a;
4449
+ }), [...c, ...l];
4450
+ }
4451
+ function zc(e) {
4452
+ var t, n, r;
4453
+ return e ? {
4454
+ errors: { ...He.errors, ...e.errors },
4455
+ filter: {
4456
+ ...He.filter,
4457
+ ...e.filter,
4458
+ conditions: {
4459
+ ...He.filter.conditions,
4460
+ ...(t = e.filter) == null ? void 0 : t.conditions
4461
+ }
4462
+ },
4463
+ datepicker: {
4464
+ ...He.datepicker,
4465
+ ...e.datepicker,
4466
+ monthNames: (n = e.datepicker) != null && n.monthNames && e.datepicker.monthNames.length === 12 ? e.datepicker.monthNames : He.datepicker.monthNames,
4467
+ weekdayLabels: (r = e.datepicker) != null && r.weekdayLabels && e.datepicker.weekdayLabels.length === 7 ? e.datepicker.weekdayLabels : He.datepicker.weekdayLabels
4468
+ }
4469
+ } : He;
4470
+ }
4471
+ function _t(e) {
4472
+ return Array.from({ length: e }, (t, n) => n);
4473
+ }
4474
+ const jc = Nn(
4475
+ function(t, n) {
4476
+ const {
4477
+ rowCount: r,
4478
+ columnCount: o,
4479
+ columns: l,
4480
+ rowHeight: c = kt,
4481
+ colHeaderHeight: s = Dr,
4482
+ columnWidth: a = Rr,
4483
+ overscan: i = Ar,
4484
+ className: u,
4485
+ onChange: w,
4486
+ onError: d,
4487
+ onColumnResize: g,
4488
+ onRowResize: _,
4489
+ initialData: f,
4490
+ frozenColumnCount: b,
4491
+ customCellRegistry: R,
4492
+ locale: y
4493
+ } = t, v = Y(
4494
+ () => zc(y),
4495
+ [y]
4496
+ ), h = rr(o, l), m = Y(
4497
+ () => Hc(o, a, l),
4498
+ [o, a, l]
4499
+ ), M = V(l);
4500
+ M.current = l;
4501
+ const E = V(null);
4502
+ E.current === null && (E.current = new cr());
4503
+ const k = E.current, B = V(null);
4504
+ B.current === null && (B.current = new ir());
4505
+ const D = B.current, S = V(null);
4506
+ S.current === null && (S.current = new Cr());
4507
+ const A = S.current;
4508
+ zn(A);
4509
+ const H = N(
4510
+ (x, T) => A.resolveAnchor(x, T),
4511
+ [A]
4512
+ ), q = N(
4513
+ (x) => {
4514
+ if (Jt(x, r, h))
4515
+ return x;
4516
+ const T = A.expandRange(et(x));
4517
+ return Mr(T, x);
4518
+ },
4519
+ [A, r, h]
4520
+ ), ee = V(!1);
4521
+ G(() => {
4522
+ f && !ee.current && (k.clearAndLoad(kn(f, l)), ee.current = !0);
4523
+ }, [f, l, k]);
4524
+ const {
4525
+ selection: P,
4526
+ setSelection: U,
4527
+ handleCellMouseDown: ue,
4528
+ handleCellMouseEnter: re,
4529
+ handleColumnHeaderMouseDown: pe,
4530
+ handleColumnHeaderMouseEnter: ke,
4531
+ handleRowHeaderMouseDown: Re,
4532
+ handleRowHeaderMouseEnter: Ie,
4533
+ isDragging: nt,
4534
+ dragMode: Pe
4535
+ } = Cc({
4536
+ rowCount: r,
4537
+ columnCount: h,
4538
+ resolveCell: H,
4539
+ expandSelection: q
4540
+ }), de = Rc({
4541
+ rowCount: r,
4542
+ columnCount: h,
4543
+ defaultRowHeight: c,
4544
+ defaultColumnWidth: a,
4545
+ initialColumnWidths: m
4546
+ }), Ke = Dc({
4547
+ dimensions: de,
4548
+ onColumnResize: g,
4549
+ onRowResize: _
4550
+ }), [Ee, j] = $(null), [C, F] = $(), oe = V(null), ge = V([]), [he, Be] = $(
4551
+ () => /* @__PURE__ */ new Map()
4552
+ ), [se, Se] = $(
4553
+ () => _t(r)
4554
+ ), [ze, De] = $(null), Oe = V(_t(r)), [rt, Ue] = $(null), [ot, we] = $(null), { clipboard: lt, handleCopy: dt, handlePaste: Ve, clearClipboard: Fe } = Mc(
4555
+ {
4556
+ store: k,
4557
+ metaStore: D,
4558
+ mergeStore: A,
4559
+ columnsRef: M,
4560
+ rowCount: r,
4561
+ columnCount: h,
4562
+ visibleRowIndicesRef: ge,
4563
+ onChange: w,
4564
+ onError: d,
4565
+ locale: v
4566
+ }
4567
+ ), ce = N(
4568
+ (x) => {
4569
+ U(_e(x)), j(null), F(void 0);
4570
+ },
4571
+ [U]
4572
+ );
4573
+ xn(
4574
+ n,
4575
+ () => ({
4576
+ setCellValue(x, T, z, K) {
4577
+ var ve;
4578
+ const X = Je(
4579
+ T,
4580
+ K,
4581
+ M.current
4582
+ ), te = A.resolveAnchor(x, X), le = (ve = M.current) == null ? void 0 : ve[X];
4583
+ k.setValue(te.row, te.col, Ut(z, le));
4584
+ },
4585
+ getCellValue(x, T, z) {
4586
+ var le;
4587
+ const K = Je(
4588
+ T,
4589
+ z,
4590
+ M.current
4591
+ ), X = A.resolveAnchor(x, K), te = (le = M.current) == null ? void 0 : le[K];
4592
+ return Gt(
4593
+ k.getValue(X.row, X.col),
4594
+ te
4595
+ );
4596
+ },
4597
+ setCellValues(x) {
4598
+ k.setValues(
4599
+ x.map(({ row: T, col: z, colName: K, value: X }) => {
4600
+ var ve;
4601
+ const te = Je(
4602
+ z ?? null,
4603
+ K,
4604
+ M.current
4605
+ ), le = (ve = M.current) == null ? void 0 : ve[te];
4606
+ return {
4607
+ row: T,
4608
+ col: te,
4609
+ value: Ut(X, le)
4610
+ };
4611
+ })
4612
+ );
4613
+ },
4614
+ loadData(x) {
4615
+ k.clearAndLoad(kn(x, M.current)), A.clear();
4616
+ const T = _t(r);
4617
+ Oe.current = T, Se(T), Be(/* @__PURE__ */ new Map()), De(null);
4618
+ },
4619
+ getData() {
4620
+ return xc(k, M.current, r);
4621
+ },
4622
+ getRowData(x) {
4623
+ return nr(k, M.current, x);
4624
+ },
4625
+ getActiveCell() {
4626
+ return (P == null ? void 0 : P.anchor) ?? null;
4627
+ },
4628
+ setActiveCell(x) {
4629
+ ce(x);
4630
+ },
4631
+ getSelection() {
4632
+ return P;
4633
+ },
4634
+ setSelection(x) {
4635
+ U(x);
4636
+ },
4637
+ setCellMeta(x, T, z, K) {
4638
+ const X = Je(
4639
+ T,
4640
+ K,
4641
+ M.current
4642
+ ), te = A.resolveAnchor(x, X);
4643
+ D.setMeta(te.row, te.col, z);
4644
+ },
4645
+ getCellMeta(x, T, z) {
4646
+ const K = Je(
4647
+ T,
4648
+ z,
4649
+ M.current
4650
+ ), X = A.resolveAnchor(x, K);
4651
+ return Me(
4652
+ D,
4653
+ X.row,
4654
+ X.col,
4655
+ M.current
4656
+ );
4657
+ },
4658
+ setCellsMeta(x) {
4659
+ D.setMetas(
4660
+ x.map(({ row: T, col: z, colName: K, meta: X }) => {
4661
+ const te = Je(
4662
+ z ?? null,
4663
+ K,
4664
+ M.current
4665
+ ), le = A.resolveAnchor(T, te);
4666
+ return {
4667
+ row: le.row,
4668
+ col: le.col,
4669
+ meta: X
4670
+ };
4671
+ })
4672
+ );
4673
+ },
4674
+ mergeCells(x) {
4675
+ const T = x ?? (P ? et(P) : null);
4676
+ if (!T)
4677
+ return d == null || d({
4678
+ code: "MERGE_INVALID_RANGE",
4679
+ message: v.errors.mergeInvalidRange
4680
+ }), !1;
4681
+ if (!A.canMerge(T))
4682
+ return d == null || d({
4683
+ code: "MERGE_OVERLAP",
4684
+ message: v.errors.mergeOverlap
4685
+ }), !1;
4686
+ if (ul(
4687
+ he,
4688
+ ze,
4689
+ M.current
4690
+ ))
4691
+ return d == null || d({
4692
+ code: "MERGE_SORT_FILTER_ACTIVE",
4693
+ message: v.errors.mergeWhileSortFilterActive
4694
+ }), !1;
4695
+ const z = A.merge(T, k, D);
4696
+ return z && U(
4697
+ _e({
4698
+ row: T.startRow,
4699
+ col: T.startCol
4700
+ })
4701
+ ), z;
4702
+ },
4703
+ unmergeCells(x, T) {
4704
+ const z = x ?? (P == null ? void 0 : P.focus.row), K = T ?? (P == null ? void 0 : P.focus.col);
4705
+ if (z === void 0 || K === void 0)
4706
+ return !1;
4707
+ const X = A.unmerge(z, K);
4708
+ if (X) {
4709
+ const te = A.resolveAnchor(z, K);
4710
+ U(_e(te));
4711
+ }
4712
+ return X;
4713
+ },
4714
+ getMergedRanges() {
4715
+ return A.getAll();
4716
+ },
4717
+ hasMergedCells() {
4718
+ return A.hasAny();
4719
+ }
4720
+ }),
4721
+ [
4722
+ k,
4723
+ D,
4724
+ A,
4725
+ P,
4726
+ ce,
4727
+ U,
4728
+ r,
4729
+ d,
4730
+ he,
4731
+ ze,
4732
+ v
4733
+ ]
4734
+ ), G(() => {
4735
+ const x = _t(r);
4736
+ Oe.current = x, Se(x), Be(/* @__PURE__ */ new Map()), De(null);
4737
+ }, [r]);
4738
+ const ye = N(
4739
+ (x, T) => {
4740
+ const z = A.resolveAnchor(x.row, x.col), K = Me(
4741
+ D,
4742
+ z.row,
4743
+ z.col,
4744
+ M.current
4745
+ );
4746
+ On(K) && (Fe(), T !== void 0 ? K.type === "select" || K.type === "multiSelect" ? F(T) : (k.setValue(z.row, z.col, T), F(void 0)) : F(void 0), U(_e(z)), j(z));
4747
+ },
4748
+ [Fe, D, A, k, U]
4749
+ ), fe = N(
4750
+ (x, T) => {
4751
+ var z;
4752
+ ue(x, T), (z = oe.current) == null || z.focus();
4753
+ },
4754
+ [ue]
4755
+ ), st = N(
4756
+ (x) => {
4757
+ var T;
4758
+ pe(x), (T = oe.current) == null || T.focus();
4759
+ },
4760
+ [pe]
4761
+ ), Le = N(
4762
+ (x) => {
4763
+ var T;
4764
+ Re(x), (T = oe.current) == null || T.focus();
4765
+ },
4766
+ [Re]
4767
+ ), ft = N(
4768
+ (x, T) => {
4769
+ var z;
4770
+ ye({ row: x, col: T }), (z = oe.current) == null || z.focus();
4771
+ },
4772
+ [ye]
4773
+ ), ht = N(
4774
+ (x, T, z, K) => {
4775
+ var te;
4776
+ k.setValue(x, T, z), j(null), F(void 0);
4777
+ const X = (te = M.current) == null ? void 0 : te[T];
4778
+ if (w == null || w([
4779
+ { row: x, col: T, value: Gt(z, X) }
4780
+ ]), z.includes(`
4781
+ `) && !de.isRowHeightManual(x)) {
4782
+ const le = z.split(`
4783
+ `).length, ve = Math.max(
4784
+ c,
4785
+ le * In + Bn
4786
+ );
4787
+ de.setRowHeight(x, ve), _ == null || _(x, ve);
4788
+ }
4789
+ if (K === "down") {
4790
+ const le = {
4791
+ row: Math.min(r - 1, x + 1),
4792
+ col: T
4793
+ };
4794
+ U(_e(le));
4795
+ } else if (K === "right") {
4796
+ const le = {
4797
+ row: x,
4798
+ col: Math.min(h - 1, T + 1)
4799
+ };
4800
+ U(_e(le));
4801
+ }
4802
+ },
4803
+ [
4804
+ k,
4805
+ w,
4806
+ r,
4807
+ h,
4808
+ U,
4809
+ c,
4810
+ de,
4811
+ _
4812
+ ]
4813
+ ), Lt = N(() => {
4814
+ j(null), F(void 0);
4815
+ }, []), Nt = N(
4816
+ (x, T, z) => {
4817
+ const K = Me(
4818
+ D,
4819
+ x,
4820
+ T,
4821
+ M.current
4822
+ );
4823
+ Et(K) || (k.setValue(x, T, z), w == null || w([{ row: x, col: T, value: z }]));
4824
+ },
4825
+ [k, D, w]
4826
+ ), xt = N(
4827
+ (x, T) => {
4828
+ if (A.hasAny()) {
4829
+ d == null || d({
4830
+ code: "MERGE_SORT_FILTER_ACTIVE",
4831
+ message: v.errors.filterWhileMerged
4832
+ });
4833
+ return;
4834
+ }
4835
+ Ue(x), we(T);
4836
+ },
4837
+ [A, d, v]
4838
+ ), Ht = N(() => {
4839
+ Ue(null), we(null);
4840
+ }, []), ct = N(
4841
+ (x, T) => {
4842
+ if (A.hasAny()) {
4843
+ d == null || d({
4844
+ code: "MERGE_SORT_FILTER_ACTIVE",
4845
+ message: v.errors.filterWhileMerged
4846
+ });
4847
+ return;
4848
+ }
4849
+ Be((z) => {
4850
+ const K = new Map(z);
4851
+ return K.set(x, {
4852
+ condition: T.condition,
4853
+ conditionValue: T.conditionValue,
4854
+ selectedValues: T.selectedValues
4855
+ }), K;
4856
+ });
4857
+ },
4858
+ [A, d, v]
4859
+ ), je = N(
4860
+ (x, T) => {
4861
+ if (A.hasAny()) {
4862
+ d == null || d({
4863
+ code: "MERGE_SORT_FILTER_ACTIVE",
4864
+ message: v.errors.sortWhileMerged
4865
+ });
4866
+ return;
4867
+ }
4868
+ Se(
4869
+ (z) => Bc(k, x, T, z)
4870
+ ), De({ col: x, direction: T });
4871
+ },
4872
+ [k, A, d, v]
4873
+ ), Ye = N((x) => {
4874
+ Se(Oe.current), De(null), Be((T) => {
4875
+ const z = new Map(T);
4876
+ return z.set(x, dl()), z;
4877
+ });
4878
+ }, []), Ne = Y(
4879
+ () => hl(k, r, l, he),
4880
+ [k, r, l, he]
4881
+ ), pt = Y(
4882
+ () => sl(
4883
+ se,
4884
+ Ne,
4885
+ de.rowHeights
4886
+ ),
4887
+ [se, Ne, de.rowHeights]
4888
+ );
4889
+ ge.current = pt.visibleRowIndices;
4890
+ const Tt = N(() => {
4891
+ P && dt(P);
4892
+ }, [P, dt]), It = N(() => {
4893
+ P && Ve(P.focus);
4894
+ }, [P, Ve]);
4895
+ yc({
4896
+ rowCount: r,
4897
+ columnCount: h,
4898
+ selection: P,
4899
+ editingCell: Ee,
4900
+ setSelection: U,
4901
+ startEditing: ye,
4902
+ store: k,
4903
+ metaStore: D,
4904
+ mergeStore: A,
4905
+ columnsRef: M,
4906
+ visibleRowIndicesRef: ge,
4907
+ containerRef: oe,
4908
+ onChange: w,
4909
+ onCopy: Tt,
4910
+ onPaste: It
4911
+ });
4912
+ const Bt = A.hasAny();
4913
+ return /* @__PURE__ */ p(gl, { locale: v, children: /* @__PURE__ */ p(
4914
+ "div",
4915
+ {
4916
+ ref: oe,
4917
+ className: u,
4918
+ style: { width: "100%", height: "100%", outline: "none" },
4919
+ tabIndex: 0,
4920
+ children: /* @__PURE__ */ p(
4921
+ hc,
4922
+ {
4923
+ store: k,
4924
+ metaStore: D,
4925
+ mergeStore: A,
4926
+ rowCount: r,
4927
+ columnCount: h,
4928
+ frozenColumnCount: b,
4929
+ columns: l,
4930
+ customCellRegistry: R,
4931
+ dimensions: de,
4932
+ visibleRowLayout: pt,
4933
+ overscan: i,
4934
+ colHeaderHeight: s,
4935
+ selection: P,
4936
+ clipboardRange: (lt == null ? void 0 : lt.range) ?? null,
4937
+ editingCell: Ee,
4938
+ editingInitialInput: C,
4939
+ isDragging: nt,
4940
+ dragMode: Pe,
4941
+ headerResize: Ke,
4942
+ sortFilterDisabled: Bt,
4943
+ onCellMouseDown: fe,
4944
+ onCellMouseEnter: re,
4945
+ onColumnHeaderMouseDown: st,
4946
+ onColumnHeaderMouseEnter: ke,
4947
+ onOpenColumnFilter: xt,
4948
+ openFilterCol: rt,
4949
+ filterAnchorRect: ot,
4950
+ columnFilters: he,
4951
+ columnSort: ze,
4952
+ onApplyColumnFilter: ct,
4953
+ onSortColumn: je,
4954
+ onResetColumnFilter: Ye,
4955
+ onCloseColumnFilter: Ht,
4956
+ onRowHeaderMouseDown: Le,
4957
+ onRowHeaderMouseEnter: Ie,
4958
+ onCellDoubleClick: ft,
4959
+ onCommitEdit: ht,
4960
+ onCancelEdit: Lt,
4961
+ onBooleanToggle: Nt
4962
+ }
4963
+ )
4964
+ }
4965
+ ) });
4966
+ }
4967
+ );
4968
+ export {
4969
+ Dr as COLUMN_HEADER_HEIGHT,
4970
+ cr as CellStore,
4971
+ Rr as DEFAULT_COLUMN_WIDTH,
4972
+ qe as DEFAULT_DATE_FORMAT,
4973
+ Ar as DEFAULT_OVERSCAN,
4974
+ kt as DEFAULT_ROW_HEIGHT,
4975
+ He as DEFAULT_SPREADSHEET_LOCALE,
4976
+ Ct as FILTER_BLANK_VALUE,
4977
+ Cr as MergeStore,
4978
+ ir as MetaStore,
4979
+ cn as ROW_HEADER_WIDTH,
4980
+ jc as Spreadsheet,
4981
+ ne as cellKey,
4982
+ Vl as columnLabel,
4983
+ zc as resolveSpreadsheetLocale
4984
+ };