@fileflow/sdk 0.1.19 → 0.1.21

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.
@@ -0,0 +1,3309 @@
1
+ import { jsx as c, jsxs as w, Fragment as ee } from "react/jsx-runtime";
2
+ import * as _e from "react";
3
+ import vt, { useCallback as Pe, useState as j, useMemo as Be, useEffect as Ke } from "react";
4
+ import { h as T, j as wt, k as Ct, X as ce, m as W, U as Ze, n as ke, T as Fe, q as yt, p as Ee, o as qe, t as St, d as Rt, V as je, g as re, S as pe, L as ae } from "./index-DJ8UbzFt.mjs";
5
+ /**
6
+ * @license lucide-react v0.563.0 - ISC
7
+ *
8
+ * This source code is licensed under the ISC license.
9
+ * See the LICENSE file in the root directory of this source tree.
10
+ */
11
+ const xt = [
12
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
13
+ ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
14
+ ], _t = T("arrow-right", xt);
15
+ /**
16
+ * @license lucide-react v0.563.0 - ISC
17
+ *
18
+ * This source code is licensed under the ISC license.
19
+ * See the LICENSE file in the root directory of this source tree.
20
+ */
21
+ const Ft = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], It = T("check", Ft);
22
+ /**
23
+ * @license lucide-react v0.563.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */
28
+ const $t = [["path", { d: "m15 18-6-6 6-6", key: "1wnfg3" }]], Nt = T("chevron-left", $t);
29
+ /**
30
+ * @license lucide-react v0.563.0 - ISC
31
+ *
32
+ * This source code is licensed under the ISC license.
33
+ * See the LICENSE file in the root directory of this source tree.
34
+ */
35
+ const Mt = [
36
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
37
+ ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
38
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
39
+ ], Vt = T("circle-question-mark", Mt);
40
+ /**
41
+ * @license lucide-react v0.563.0 - ISC
42
+ *
43
+ * This source code is licensed under the ISC license.
44
+ * See the LICENSE file in the root directory of this source tree.
45
+ */
46
+ const Pt = [
47
+ [
48
+ "path",
49
+ {
50
+ d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
51
+ key: "1nclc0"
52
+ }
53
+ ],
54
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
55
+ ], kt = T("eye", Pt);
56
+ /**
57
+ * @license lucide-react v0.563.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */
62
+ const Et = [
63
+ [
64
+ "path",
65
+ {
66
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
67
+ key: "1oefj6"
68
+ }
69
+ ],
70
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
71
+ ["path", { d: "M8 13h2", key: "yr2amv" }],
72
+ ["path", { d: "M14 13h2", key: "un5t4a" }],
73
+ ["path", { d: "M8 17h2", key: "2yhykz" }],
74
+ ["path", { d: "M14 17h2", key: "10kma7" }]
75
+ ], bt = T("file-spreadsheet", Et);
76
+ /**
77
+ * @license lucide-react v0.563.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */
82
+ const Dt = [
83
+ [
84
+ "path",
85
+ {
86
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
87
+ key: "1oefj6"
88
+ }
89
+ ],
90
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
91
+ ], Lt = T("file", Dt);
92
+ /**
93
+ * @license lucide-react v0.563.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */
98
+ const zt = [
99
+ ["line", { x1: "6", x2: "6", y1: "3", y2: "15", key: "17qcm7" }],
100
+ ["circle", { cx: "18", cy: "6", r: "3", key: "1h7g24" }],
101
+ ["circle", { cx: "6", cy: "18", r: "3", key: "fqmcym" }],
102
+ ["path", { d: "M18 9a9 9 0 0 1-9 9", key: "n2h4wq" }]
103
+ ], Ht = T("git-branch", zt);
104
+ /**
105
+ * @license lucide-react v0.563.0 - ISC
106
+ *
107
+ * This source code is licensed under the ISC license.
108
+ * See the LICENSE file in the root directory of this source tree.
109
+ */
110
+ const At = [
111
+ [
112
+ "path",
113
+ {
114
+ d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
115
+ key: "1a8usu"
116
+ }
117
+ ]
118
+ ], Gt = T("pen", At);
119
+ /**
120
+ * @license lucide-react v0.563.0 - ISC
121
+ *
122
+ * This source code is licensed under the ISC license.
123
+ * See the LICENSE file in the root directory of this source tree.
124
+ */
125
+ const Ot = [
126
+ [
127
+ "path",
128
+ { d: "M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344", key: "2acyp4" }
129
+ ],
130
+ ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
131
+ ], Tt = T("square-check-big", Ot);
132
+ /**
133
+ * @license lucide-react v0.563.0 - ISC
134
+ *
135
+ * This source code is licensed under the ISC license.
136
+ * See the LICENSE file in the root directory of this source tree.
137
+ */
138
+ const Bt = [
139
+ ["path", { d: "M10 11v6", key: "nco0om" }],
140
+ ["path", { d: "M14 11v6", key: "outv1u" }],
141
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
142
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
143
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
144
+ ], Kt = T("trash-2", Bt), Ue = {
145
+ sessionId: null,
146
+ status: "idle",
147
+ step: "upload",
148
+ schema: null,
149
+ file: null,
150
+ fileName: null,
151
+ fileSize: null,
152
+ headers: [],
153
+ rows: [],
154
+ totalRows: 0,
155
+ sampleRows: [],
156
+ mappings: [],
157
+ unmappedSource: [],
158
+ unmappedTarget: [],
159
+ validationResults: null,
160
+ errorsByRow: /* @__PURE__ */ new Map(),
161
+ isLoading: !1,
162
+ error: null,
163
+ editingCell: null,
164
+ editedRows: /* @__PURE__ */ new Set()
165
+ };
166
+ function qt(e, r) {
167
+ const t = [], n = (e == null ? void 0 : e.trim()) || "";
168
+ if (r.required && !n)
169
+ return t.push({
170
+ rowIndex: 0,
171
+ // will be set by caller
172
+ columnKey: r.key,
173
+ value: n,
174
+ severity: "error",
175
+ validatorType: "required",
176
+ message: `${r.label} is required`
177
+ }), t;
178
+ if (!n) return t;
179
+ switch (r.type) {
180
+ case "email":
181
+ /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(n) || t.push({
182
+ rowIndex: 0,
183
+ columnKey: r.key,
184
+ value: n,
185
+ severity: "error",
186
+ validatorType: "type",
187
+ message: "Invalid email format"
188
+ });
189
+ break;
190
+ case "url":
191
+ /^https?:\/\/.+/.test(n) || t.push({
192
+ rowIndex: 0,
193
+ columnKey: r.key,
194
+ value: n,
195
+ severity: "error",
196
+ validatorType: "type",
197
+ message: "Invalid URL format"
198
+ });
199
+ break;
200
+ case "integer":
201
+ /^-?\d+$/.test(n) || t.push({
202
+ rowIndex: 0,
203
+ columnKey: r.key,
204
+ value: n,
205
+ severity: "error",
206
+ validatorType: "type",
207
+ message: "Must be a whole number"
208
+ });
209
+ break;
210
+ case "number":
211
+ case "float":
212
+ /^-?\d+(\.\d+)?$/.test(n) || t.push({
213
+ rowIndex: 0,
214
+ columnKey: r.key,
215
+ value: n,
216
+ severity: "error",
217
+ validatorType: "type",
218
+ message: "Must be a valid number"
219
+ });
220
+ break;
221
+ case "phone":
222
+ n.replace(/\D/g, "").length < 10 && t.push({
223
+ rowIndex: 0,
224
+ columnKey: r.key,
225
+ value: n,
226
+ severity: "warning",
227
+ validatorType: "type",
228
+ message: "Invalid phone number"
229
+ });
230
+ break;
231
+ }
232
+ if (r.validators)
233
+ for (const o of r.validators) {
234
+ const l = o.severity === "info" ? "warning" : o.severity || "error", s = o.params || {};
235
+ switch (o.type) {
236
+ case "minLength": {
237
+ const i = s.value ?? 0;
238
+ n.length < i && t.push({
239
+ rowIndex: 0,
240
+ columnKey: r.key,
241
+ value: n,
242
+ severity: l,
243
+ validatorType: o.type,
244
+ message: o.message || `Must be at least ${i} characters`
245
+ });
246
+ break;
247
+ }
248
+ case "maxLength": {
249
+ const i = s.value ?? 1 / 0;
250
+ n.length > i && t.push({
251
+ rowIndex: 0,
252
+ columnKey: r.key,
253
+ value: n,
254
+ severity: l,
255
+ validatorType: o.type,
256
+ message: o.message || `Must be at most ${i} characters`
257
+ });
258
+ break;
259
+ }
260
+ case "min": {
261
+ const i = parseFloat(n), u = s.value ?? -1 / 0;
262
+ !isNaN(i) && i < u && t.push({
263
+ rowIndex: 0,
264
+ columnKey: r.key,
265
+ value: n,
266
+ severity: l,
267
+ validatorType: o.type,
268
+ message: o.message || `Must be at least ${u}`
269
+ });
270
+ break;
271
+ }
272
+ case "max": {
273
+ const i = parseFloat(n), u = s.value ?? 1 / 0;
274
+ !isNaN(i) && i > u && t.push({
275
+ rowIndex: 0,
276
+ columnKey: r.key,
277
+ value: n,
278
+ severity: l,
279
+ validatorType: o.type,
280
+ message: o.message || `Must be at most ${u}`
281
+ });
282
+ break;
283
+ }
284
+ case "pattern": {
285
+ const i = s.regex ?? s.pattern ?? ".*";
286
+ new RegExp(i).test(n) || t.push({
287
+ rowIndex: 0,
288
+ columnKey: r.key,
289
+ value: n,
290
+ severity: l,
291
+ validatorType: o.type,
292
+ message: o.message || "Format is invalid"
293
+ });
294
+ break;
295
+ }
296
+ case "enum": {
297
+ const i = s.values || [];
298
+ i.map((f) => f.toLowerCase()).includes(n.toLowerCase()) || t.push({
299
+ rowIndex: 0,
300
+ columnKey: r.key,
301
+ value: n,
302
+ severity: l,
303
+ validatorType: o.type,
304
+ message: o.message || `Must be one of: ${i.slice(0, 5).join(", ")}${i.length > 5 ? "..." : ""}`
305
+ });
306
+ break;
307
+ }
308
+ case "custom": {
309
+ const i = s.validatorName;
310
+ if (i === "commaSeparatedEnum") {
311
+ const u = s.allowedValues || [], f = n.split(",").map((d) => d.trim().toLowerCase()).filter((d) => d), g = u.map((d) => d.toLowerCase()), p = f.filter((d) => !g.includes(d));
312
+ p.length > 0 && t.push({
313
+ rowIndex: 0,
314
+ columnKey: r.key,
315
+ value: n,
316
+ severity: l,
317
+ validatorType: o.type,
318
+ message: o.message || `Invalid values: ${p.join(", ")}. Must be comma-separated values from: ${u.slice(0, 5).join(", ")}${u.length > 5 ? "..." : ""}`
319
+ });
320
+ }
321
+ if (i === "commaSeparatedEmails") {
322
+ const f = n.split(",").map((g) => g.trim()).filter((g) => g).filter((g) => !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(g));
323
+ f.length > 0 && t.push({
324
+ rowIndex: 0,
325
+ columnKey: r.key,
326
+ value: n,
327
+ severity: l,
328
+ validatorType: o.type,
329
+ message: `Invalid email(s): ${f.join(", ")}`
330
+ });
331
+ }
332
+ break;
333
+ }
334
+ }
335
+ }
336
+ return t;
337
+ }
338
+ function me(e, r, t) {
339
+ var C;
340
+ const n = [];
341
+ for (const v of e)
342
+ for (const y of t) {
343
+ if (!y.targetKey) continue;
344
+ const x = r.columns.find((P) => P.key === y.targetKey);
345
+ if (!x) continue;
346
+ const $ = v.data[y.targetKey] || v.data[y.sourceColumn] || "", F = qt(String($), x);
347
+ for (const P of F)
348
+ n.push({ ...P, rowIndex: v.rowIndex });
349
+ }
350
+ const o = ((C = r.options) == null ? void 0 : C.uniqueKeys) || [];
351
+ for (const v of o) {
352
+ const y = t.find(($) => $.targetKey === v);
353
+ if (!y) continue;
354
+ const x = /* @__PURE__ */ new Map();
355
+ for (const $ of e) {
356
+ const F = String($.data[v] || $.data[y.sourceColumn] || "").toLowerCase().trim();
357
+ if (!F) continue;
358
+ const P = x.get(F) || [];
359
+ P.push($.rowIndex), x.set(F, P);
360
+ }
361
+ for (const [$, F] of x.entries())
362
+ if (F.length > 1)
363
+ for (const P of F.slice(1))
364
+ n.push({
365
+ rowIndex: P,
366
+ columnKey: v,
367
+ value: $,
368
+ severity: "warning",
369
+ validatorType: "unique",
370
+ message: `Duplicate ${v} value`
371
+ });
372
+ }
373
+ const l = /* @__PURE__ */ new Map();
374
+ for (const v of n) {
375
+ const y = l.get(v.rowIndex) || [];
376
+ y.push(v), l.set(v.rowIndex, y);
377
+ }
378
+ const s = n.filter((v) => v.severity === "error").length, i = n.filter((v) => v.severity === "warning").length, u = n.filter((v) => v.severity === "info").length, f = new Set(n.filter((v) => v.severity === "error").map((v) => v.rowIndex)), g = e.length, p = g - f.size, d = {};
379
+ for (const v of n) {
380
+ d[v.columnKey] || (d[v.columnKey] = {
381
+ columnKey: v.columnKey,
382
+ errorCount: 0,
383
+ warningCount: 0,
384
+ infoCount: 0,
385
+ mostCommonError: void 0
386
+ });
387
+ const y = d[v.columnKey];
388
+ v.severity === "error" ? y.errorCount++ : v.severity === "warning" ? y.warningCount++ : y.infoCount++, y.mostCommonError || (y.mostCommonError = v.message);
389
+ }
390
+ const a = {};
391
+ for (const v of n)
392
+ a[v.validatorType] = (a[v.validatorType] || 0) + 1;
393
+ const m = [];
394
+ for (const v of o) {
395
+ const y = t.find(($) => $.targetKey === v);
396
+ if (!y) continue;
397
+ const x = /* @__PURE__ */ new Map();
398
+ for (const $ of e) {
399
+ const F = String($.data[v] || $.data[y.sourceColumn] || "").toLowerCase().trim();
400
+ if (!F) continue;
401
+ const P = x.get(F) || [];
402
+ P.push($.rowIndex), x.set(F, P);
403
+ }
404
+ for (const [$, F] of x.entries())
405
+ F.length > 1 && m.push({ columnKey: v, value: $, rowIndices: F });
406
+ }
407
+ const h = {
408
+ byColumn: d,
409
+ byType: a,
410
+ duplicates: m.length > 0 ? m : void 0
411
+ };
412
+ return {
413
+ validationResults: {
414
+ isValid: s === 0,
415
+ totalRows: g,
416
+ validRows: p,
417
+ errorCount: s,
418
+ warningCount: i,
419
+ infoCount: u,
420
+ errors: n,
421
+ summary: h
422
+ },
423
+ errorsByRow: l
424
+ };
425
+ }
426
+ const te = wt((e, r) => ({
427
+ ...Ue,
428
+ setSchema: (t) => e({ schema: t }),
429
+ setSessionId: (t) => e({ sessionId: t }),
430
+ setFile: (t) => e({
431
+ file: t,
432
+ fileName: t.name,
433
+ fileSize: t.size,
434
+ error: null
435
+ }),
436
+ setParsedData: (t) => e({
437
+ headers: t.headers,
438
+ rows: t.rows,
439
+ totalRows: t.totalRows,
440
+ sampleRows: t.sampleRows
441
+ }),
442
+ setMappings: (t) => e({ mappings: t }),
443
+ updateMapping: (t, n) => e((o) => ({ mappings: o.mappings.map(
444
+ (s) => s.sourceColumn === t ? { ...s, targetKey: n, isAutoMapped: !1 } : s
445
+ ) })),
446
+ setUnmapped: (t, n) => e({
447
+ unmappedSource: t,
448
+ unmappedTarget: n
449
+ }),
450
+ setValidationResults: (t) => {
451
+ const n = /* @__PURE__ */ new Map();
452
+ for (const o of t.errors) {
453
+ const l = n.get(o.rowIndex) || [];
454
+ l.push(o), n.set(o.rowIndex, l);
455
+ }
456
+ e({ validationResults: t, errorsByRow: n });
457
+ },
458
+ revalidate: () => {
459
+ const t = r();
460
+ if (!t.schema || !t.validationResults) return;
461
+ const { validationResults: n, errorsByRow: o } = me(
462
+ t.rows,
463
+ t.schema,
464
+ t.mappings
465
+ );
466
+ e({ validationResults: n, errorsByRow: o });
467
+ },
468
+ setStep: (t) => e({ step: t }),
469
+ nextStep: () => {
470
+ const t = ["upload", "mapping", "validation", "review", "complete"], n = t.indexOf(r().step);
471
+ n < t.length - 1 && e({ step: t[n + 1] });
472
+ },
473
+ previousStep: () => {
474
+ const t = ["upload", "mapping", "validation", "review", "complete"], n = t.indexOf(r().step);
475
+ n > 0 && e({ step: t[n - 1] });
476
+ },
477
+ startEditing: (t, n) => e({
478
+ editingCell: { rowIndex: t, columnKey: n }
479
+ }),
480
+ stopEditing: () => e({ editingCell: null }),
481
+ updateCell: (t, n, o) => {
482
+ const l = r(), s = [...l.rows], i = s.find((f) => f.rowIndex === t);
483
+ i && (i.data = { ...i.data, [n]: String(o) });
484
+ const u = new Set(l.editedRows);
485
+ if (u.add(t), e({ rows: s, editedRows: u, editingCell: null }), l.schema && l.validationResults) {
486
+ const { validationResults: f, errorsByRow: g } = me(
487
+ s,
488
+ l.schema,
489
+ l.mappings
490
+ );
491
+ e({ validationResults: f, errorsByRow: g });
492
+ }
493
+ },
494
+ deleteRow: (t) => {
495
+ const n = r(), l = n.rows.filter((s) => s.rowIndex !== t).map((s, i) => ({ ...s, rowIndex: i }));
496
+ if (e({
497
+ rows: l,
498
+ totalRows: l.length
499
+ }), n.schema && n.validationResults) {
500
+ const { validationResults: s, errorsByRow: i } = me(
501
+ l,
502
+ n.schema,
503
+ n.mappings
504
+ );
505
+ e({ validationResults: s, errorsByRow: i });
506
+ }
507
+ },
508
+ setStatus: (t) => e({ status: t }),
509
+ setLoading: (t) => e({ isLoading: t }),
510
+ setError: (t) => e({ error: t }),
511
+ reset: () => e(Ue)
512
+ })), jt = ({
513
+ onFileSelect: e,
514
+ maxSize: r = 50 * 1024 * 1024,
515
+ // 50MB
516
+ acceptedTypes: t = [".csv", ".xlsx", ".xls"]
517
+ }) => {
518
+ const { file: n, fileName: o, fileSize: l, setFile: s, error: i, setError: u, isLoading: f } = te(), g = Pe(
519
+ (C, v) => {
520
+ if (v.length > 0) {
521
+ u("Invalid file type or file too large");
522
+ return;
523
+ }
524
+ if (C.length > 0) {
525
+ const y = C[0];
526
+ s(y), e == null || e(y);
527
+ }
528
+ },
529
+ [e, s, u]
530
+ ), { getRootProps: p, getInputProps: d, isDragActive: a } = Ct({
531
+ onDrop: g,
532
+ accept: {
533
+ "text/csv": [".csv"],
534
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
535
+ "application/vnd.ms-excel": [".xls"]
536
+ },
537
+ maxSize: r,
538
+ multiple: !1,
539
+ disabled: f
540
+ }), m = (C) => C < 1024 ? `${C} B` : C < 1024 * 1024 ? `${(C / 1024).toFixed(1)} KB` : `${(C / (1024 * 1024)).toFixed(1)} MB`, h = (C) => {
541
+ C.stopPropagation(), te.getState().reset();
542
+ };
543
+ return n ? /* @__PURE__ */ c("div", { className: "ff-p-4 ff-rounded-xl ff-border", style: { backgroundColor: "var(--ff-success-light)", borderColor: "var(--ff-success)" }, children: /* @__PURE__ */ w("div", { className: "ff-flex ff-items-center ff-gap-3", children: [
544
+ /* @__PURE__ */ c("div", { className: "ff-p-2 ff-rounded-lg", style: { backgroundColor: "rgba(41, 142, 51, 0.15)" }, children: /* @__PURE__ */ c(Lt, { className: "ff-w-6 ff-h-6", style: { color: "var(--ff-success)" } }) }),
545
+ /* @__PURE__ */ w("div", { className: "ff-flex-1 ff-min-w-0", children: [
546
+ /* @__PURE__ */ c("p", { className: "ff-font-medium ff-truncate", style: { color: "var(--ff-success-dark)" }, children: o }),
547
+ /* @__PURE__ */ c("p", { className: "ff-text-sm", style: { color: "var(--ff-success)" }, children: m(l || 0) })
548
+ ] }),
549
+ /* @__PURE__ */ c(
550
+ "button",
551
+ {
552
+ onClick: h,
553
+ className: "ff-p-1.5 ff-rounded-full ff-transition-colors",
554
+ style: { color: "var(--ff-success)" },
555
+ "aria-label": "Remove file",
556
+ children: /* @__PURE__ */ c(ce, { className: "ff-w-5 ff-h-5" })
557
+ }
558
+ )
559
+ ] }) }) : /* @__PURE__ */ w("div", { className: "ff-space-y-6", children: [
560
+ /* @__PURE__ */ w(
561
+ "div",
562
+ {
563
+ ...p(),
564
+ className: W(
565
+ "ff-dropzone",
566
+ a && "ff-dropzone-active",
567
+ f && "ff-opacity-50 ff-cursor-not-allowed"
568
+ ),
569
+ children: [
570
+ /* @__PURE__ */ c("input", { ...d() }),
571
+ /* @__PURE__ */ c("div", { className: "ff-dropzone-icon-wrapper", children: /* @__PURE__ */ c(Ze, { className: "ff-dropzone-icon" }) }),
572
+ /* @__PURE__ */ c("h3", { className: "ff-dropzone-text", children: a ? "Drop your file here" : "Upload your file" }),
573
+ /* @__PURE__ */ c("p", { className: "ff-dropzone-hint", children: "Drag and drop or click to select" }),
574
+ /* @__PURE__ */ c("label", { className: "ff-inline-block", children: /* @__PURE__ */ c("span", { className: W(
575
+ "ff-btn ff-btn-primary",
576
+ f && "ff-opacity-50 ff-cursor-wait"
577
+ ), children: f ? "Processing..." : "Choose file" }) }),
578
+ /* @__PURE__ */ w("p", { className: "ff-dropzone-formats", children: [
579
+ "Supports ",
580
+ t.join(", "),
581
+ " up to ",
582
+ m(r)
583
+ ] })
584
+ ]
585
+ }
586
+ ),
587
+ i && /* @__PURE__ */ w("div", { className: "ff-flex ff-items-center ff-gap-2 ff-p-4 ff-rounded-lg ff-text-sm", style: { backgroundColor: "var(--ff-error-light)", color: "var(--ff-error)" }, children: [
588
+ /* @__PURE__ */ c(ke, { className: "ff-w-4 ff-h-4 ff-flex-shrink-0" }),
589
+ /* @__PURE__ */ c("p", { children: i })
590
+ ] })
591
+ ] });
592
+ }, Ut = ({ onMappingChange: e }) => {
593
+ const { mappings: r, schema: t, unmappedSource: n, updateMapping: o } = te(), l = (t == null ? void 0 : t.columns) || [], s = (p, d) => {
594
+ const a = d === "" ? null : d;
595
+ o(p, a), e == null || e(p, a);
596
+ }, i = (p) => p >= 0.85 ? "var(--ff-success)" : p >= 0.6 ? "var(--ff-warning)" : "var(--ff-error)", u = (p) => p >= 0.85 ? "High" : p >= 0.6 ? "Medium" : "Low", g = new Set(
597
+ r.filter((p) => p.targetKey !== null).map((p) => p.targetKey)
598
+ );
599
+ return /* @__PURE__ */ w("div", { className: "ff-space-y-4", children: [
600
+ /* @__PURE__ */ w("div", { className: "ff-mapping-header", children: [
601
+ /* @__PURE__ */ w("div", { children: [
602
+ /* @__PURE__ */ c("h3", { className: "ff-mapping-title", children: "Column Mapping" }),
603
+ /* @__PURE__ */ c("p", { className: "ff-mapping-subtitle", children: "Match your file columns to the expected fields" })
604
+ ] }),
605
+ /* @__PURE__ */ w("div", { className: "ff-mapping-legend", children: [
606
+ /* @__PURE__ */ w("span", { className: "ff-mapping-legend-item", children: [
607
+ /* @__PURE__ */ c("span", { className: "ff-mapping-legend-dot", style: { backgroundColor: "var(--ff-success)" } }),
608
+ /* @__PURE__ */ c("span", { style: { color: "var(--ff-text-secondary)" }, children: "Mapped" })
609
+ ] }),
610
+ /* @__PURE__ */ w("span", { className: "ff-mapping-legend-item", children: [
611
+ /* @__PURE__ */ c("span", { className: "ff-mapping-legend-dot", style: { backgroundColor: "var(--ff-warning)" } }),
612
+ /* @__PURE__ */ c("span", { style: { color: "var(--ff-text-secondary)" }, children: "Review" })
613
+ ] }),
614
+ /* @__PURE__ */ w("span", { className: "ff-mapping-legend-item", children: [
615
+ /* @__PURE__ */ c("span", { className: "ff-mapping-legend-dot", style: { backgroundColor: "var(--ff-gray-70)" } }),
616
+ /* @__PURE__ */ c("span", { style: { color: "var(--ff-text-secondary)" }, children: "Unmapped" })
617
+ ] })
618
+ ] })
619
+ ] }),
620
+ /* @__PURE__ */ c("div", { className: "ff-space-y-2", children: r.map((p) => {
621
+ l.find((m) => m.key === p.targetKey);
622
+ const d = p.targetKey !== null, a = p.confidence >= 0.85;
623
+ return /* @__PURE__ */ w(
624
+ "div",
625
+ {
626
+ className: W(
627
+ "ff-mapping-row",
628
+ d && a && "ff-mapping-row-success",
629
+ d && !a && "ff-mapping-row-warning"
630
+ ),
631
+ children: [
632
+ /* @__PURE__ */ c("div", { className: "ff-flex-1", children: /* @__PURE__ */ c("div", { className: "ff-mapping-source", children: p.sourceColumn }) }),
633
+ /* @__PURE__ */ c("div", { className: "ff-mapping-arrow", children: /* @__PURE__ */ c(_t, { className: "ff-w-5 ff-h-5" }) }),
634
+ /* @__PURE__ */ c("div", { className: "ff-flex-1 ff-mapping-target", children: /* @__PURE__ */ w(
635
+ "select",
636
+ {
637
+ value: p.targetKey || "",
638
+ onChange: (m) => s(p.sourceColumn, m.target.value),
639
+ className: "ff-input",
640
+ children: [
641
+ /* @__PURE__ */ c("option", { value: "", children: "-- Do not import --" }),
642
+ l.map((m) => /* @__PURE__ */ w(
643
+ "option",
644
+ {
645
+ value: m.key,
646
+ disabled: g.has(m.key) && p.targetKey !== m.key,
647
+ children: [
648
+ m.label,
649
+ " (",
650
+ m.type,
651
+ ")",
652
+ m.required ? " *" : ""
653
+ ]
654
+ },
655
+ m.key
656
+ ))
657
+ ]
658
+ }
659
+ ) }),
660
+ /* @__PURE__ */ c("div", { className: "ff-mapping-status", children: d ? a ? /* @__PURE__ */ c(It, { className: "ff-w-5 ff-h-5", style: { color: "var(--ff-success)" } }) : /* @__PURE__ */ c(Vt, { className: "ff-w-5 ff-h-5", style: { color: "var(--ff-warning)" } }) : /* @__PURE__ */ c("span", { className: "ff-w-5 ff-h-5" }) }),
661
+ p.confidence > 0 && /* @__PURE__ */ w("div", { className: "ff-confidence", style: { color: i(p.confidence) }, children: [
662
+ /* @__PURE__ */ w("span", { children: [
663
+ Math.round(p.confidence * 100),
664
+ "%"
665
+ ] }),
666
+ /* @__PURE__ */ w("span", { style: { color: "var(--ff-text-muted)" }, children: [
667
+ "(",
668
+ u(p.confidence),
669
+ ")"
670
+ ] })
671
+ ] })
672
+ ]
673
+ },
674
+ p.sourceColumn
675
+ );
676
+ }) }),
677
+ (() => {
678
+ const p = l.filter(
679
+ (d) => d.required && !g.has(d.key)
680
+ );
681
+ return p.length > 0 ? /* @__PURE__ */ w("div", { className: "ff-flex ff-items-start ff-gap-2 ff-p-4 ff-rounded-lg", style: { backgroundColor: "var(--ff-warning-light)", borderColor: "var(--ff-warning)" }, children: [
682
+ /* @__PURE__ */ c(ke, { className: "ff-w-5 ff-h-5 ff-flex-shrink-0 ff-mt-0.5", style: { color: "var(--ff-warning)" } }),
683
+ /* @__PURE__ */ w("div", { children: [
684
+ /* @__PURE__ */ c("p", { className: "ff-text-sm ff-font-medium", style: { color: "var(--ff-warning-dark)" }, children: "Required fields not mapped" }),
685
+ /* @__PURE__ */ c("p", { className: "ff-text-sm ff-mt-1", style: { color: "var(--ff-warning)" }, children: p.map((d) => d.label).join(", ") })
686
+ ] })
687
+ ] }) : null;
688
+ })()
689
+ ] });
690
+ };
691
+ /**
692
+ * table-core
693
+ *
694
+ * Copyright (c) TanStack
695
+ *
696
+ * This source code is licensed under the MIT license found in the
697
+ * LICENSE.md file in the root directory of this source tree.
698
+ *
699
+ * @license MIT
700
+ */
701
+ function Xt() {
702
+ return {
703
+ accessor: (e, r) => typeof e == "function" ? {
704
+ ...r,
705
+ accessorFn: e
706
+ } : {
707
+ ...r,
708
+ accessorKey: e
709
+ },
710
+ display: (e) => e,
711
+ group: (e) => e
712
+ };
713
+ }
714
+ function X(e, r) {
715
+ return typeof e == "function" ? e(r) : e;
716
+ }
717
+ function L(e, r) {
718
+ return (t) => {
719
+ r.setState((n) => ({
720
+ ...n,
721
+ [e]: X(t, n[e])
722
+ }));
723
+ };
724
+ }
725
+ function ge(e) {
726
+ return e instanceof Function;
727
+ }
728
+ function Wt(e) {
729
+ return Array.isArray(e) && e.every((r) => typeof r == "number");
730
+ }
731
+ function Qt(e, r) {
732
+ const t = [], n = (o) => {
733
+ o.forEach((l) => {
734
+ t.push(l);
735
+ const s = r(l);
736
+ s != null && s.length && n(s);
737
+ });
738
+ };
739
+ return n(e), t;
740
+ }
741
+ function S(e, r, t) {
742
+ let n = [], o;
743
+ return (l) => {
744
+ let s;
745
+ t.key && t.debug && (s = Date.now());
746
+ const i = e(l);
747
+ if (!(i.length !== n.length || i.some((g, p) => n[p] !== g)))
748
+ return o;
749
+ n = i;
750
+ let f;
751
+ if (t.key && t.debug && (f = Date.now()), o = r(...i), t == null || t.onChange == null || t.onChange(o), t.key && t.debug && t != null && t.debug()) {
752
+ const g = Math.round((Date.now() - s) * 100) / 100, p = Math.round((Date.now() - f) * 100) / 100, d = p / 16, a = (m, h) => {
753
+ for (m = String(m); m.length < h; )
754
+ m = " " + m;
755
+ return m;
756
+ };
757
+ console.info(`%c⏱ ${a(p, 5)} /${a(g, 5)} ms`, `
758
+ font-size: .6rem;
759
+ font-weight: bold;
760
+ color: hsl(${Math.max(0, Math.min(120 - 120 * d, 120))}deg 100% 31%);`, t == null ? void 0 : t.key);
761
+ }
762
+ return o;
763
+ };
764
+ }
765
+ function R(e, r, t, n) {
766
+ return {
767
+ debug: () => {
768
+ var o;
769
+ return (o = e == null ? void 0 : e.debugAll) != null ? o : e[r];
770
+ },
771
+ key: process.env.NODE_ENV === "development" && t,
772
+ onChange: n
773
+ };
774
+ }
775
+ function Yt(e, r, t, n) {
776
+ const o = () => {
777
+ var s;
778
+ return (s = l.getValue()) != null ? s : e.options.renderFallbackValue;
779
+ }, l = {
780
+ id: `${r.id}_${t.id}`,
781
+ row: r,
782
+ column: t,
783
+ getValue: () => r.getValue(n),
784
+ renderValue: o,
785
+ getContext: S(() => [e, t, r, l], (s, i, u, f) => ({
786
+ table: s,
787
+ column: i,
788
+ row: u,
789
+ cell: f,
790
+ getValue: f.getValue,
791
+ renderValue: f.renderValue
792
+ }), R(e.options, "debugCells", "cell.getContext"))
793
+ };
794
+ return e._features.forEach((s) => {
795
+ s.createCell == null || s.createCell(l, t, r, e);
796
+ }, {}), l;
797
+ }
798
+ function Jt(e, r, t, n) {
799
+ var o, l;
800
+ const i = {
801
+ ...e._getDefaultColumnDef(),
802
+ ...r
803
+ }, u = i.accessorKey;
804
+ let f = (o = (l = i.id) != null ? l : u ? typeof String.prototype.replaceAll == "function" ? u.replaceAll(".", "_") : u.replace(/\./g, "_") : void 0) != null ? o : typeof i.header == "string" ? i.header : void 0, g;
805
+ if (i.accessorFn ? g = i.accessorFn : u && (u.includes(".") ? g = (d) => {
806
+ let a = d;
807
+ for (const h of u.split(".")) {
808
+ var m;
809
+ a = (m = a) == null ? void 0 : m[h], process.env.NODE_ENV !== "production" && a === void 0 && console.warn(`"${h}" in deeply nested key "${u}" returned undefined.`);
810
+ }
811
+ return a;
812
+ } : g = (d) => d[i.accessorKey]), !f)
813
+ throw process.env.NODE_ENV !== "production" ? new Error(i.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header") : new Error();
814
+ let p = {
815
+ id: `${String(f)}`,
816
+ accessorFn: g,
817
+ parent: n,
818
+ depth: t,
819
+ columnDef: i,
820
+ columns: [],
821
+ getFlatColumns: S(() => [!0], () => {
822
+ var d;
823
+ return [p, ...(d = p.columns) == null ? void 0 : d.flatMap((a) => a.getFlatColumns())];
824
+ }, R(e.options, "debugColumns", "column.getFlatColumns")),
825
+ getLeafColumns: S(() => [e._getOrderColumnsFn()], (d) => {
826
+ var a;
827
+ if ((a = p.columns) != null && a.length) {
828
+ let m = p.columns.flatMap((h) => h.getLeafColumns());
829
+ return d(m);
830
+ }
831
+ return [p];
832
+ }, R(e.options, "debugColumns", "column.getLeafColumns"))
833
+ };
834
+ for (const d of e._features)
835
+ d.createColumn == null || d.createColumn(p, e);
836
+ return p;
837
+ }
838
+ const E = "debugHeaders";
839
+ function Xe(e, r, t) {
840
+ var n;
841
+ let l = {
842
+ id: (n = t.id) != null ? n : r.id,
843
+ column: r,
844
+ index: t.index,
845
+ isPlaceholder: !!t.isPlaceholder,
846
+ placeholderId: t.placeholderId,
847
+ depth: t.depth,
848
+ subHeaders: [],
849
+ colSpan: 0,
850
+ rowSpan: 0,
851
+ headerGroup: null,
852
+ getLeafHeaders: () => {
853
+ const s = [], i = (u) => {
854
+ u.subHeaders && u.subHeaders.length && u.subHeaders.map(i), s.push(u);
855
+ };
856
+ return i(l), s;
857
+ },
858
+ getContext: () => ({
859
+ table: e,
860
+ header: l,
861
+ column: r
862
+ })
863
+ };
864
+ return e._features.forEach((s) => {
865
+ s.createHeader == null || s.createHeader(l, e);
866
+ }), l;
867
+ }
868
+ const Zt = {
869
+ createTable: (e) => {
870
+ e.getHeaderGroups = S(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.left, e.getState().columnPinning.right], (r, t, n, o) => {
871
+ var l, s;
872
+ const i = (l = n == null ? void 0 : n.map((p) => t.find((d) => d.id === p)).filter(Boolean)) != null ? l : [], u = (s = o == null ? void 0 : o.map((p) => t.find((d) => d.id === p)).filter(Boolean)) != null ? s : [], f = t.filter((p) => !(n != null && n.includes(p.id)) && !(o != null && o.includes(p.id)));
873
+ return ue(r, [...i, ...f, ...u], e);
874
+ }, R(e.options, E, "getHeaderGroups")), e.getCenterHeaderGroups = S(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.left, e.getState().columnPinning.right], (r, t, n, o) => (t = t.filter((l) => !(n != null && n.includes(l.id)) && !(o != null && o.includes(l.id))), ue(r, t, e, "center")), R(e.options, E, "getCenterHeaderGroups")), e.getLeftHeaderGroups = S(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.left], (r, t, n) => {
875
+ var o;
876
+ const l = (o = n == null ? void 0 : n.map((s) => t.find((i) => i.id === s)).filter(Boolean)) != null ? o : [];
877
+ return ue(r, l, e, "left");
878
+ }, R(e.options, E, "getLeftHeaderGroups")), e.getRightHeaderGroups = S(() => [e.getAllColumns(), e.getVisibleLeafColumns(), e.getState().columnPinning.right], (r, t, n) => {
879
+ var o;
880
+ const l = (o = n == null ? void 0 : n.map((s) => t.find((i) => i.id === s)).filter(Boolean)) != null ? o : [];
881
+ return ue(r, l, e, "right");
882
+ }, R(e.options, E, "getRightHeaderGroups")), e.getFooterGroups = S(() => [e.getHeaderGroups()], (r) => [...r].reverse(), R(e.options, E, "getFooterGroups")), e.getLeftFooterGroups = S(() => [e.getLeftHeaderGroups()], (r) => [...r].reverse(), R(e.options, E, "getLeftFooterGroups")), e.getCenterFooterGroups = S(() => [e.getCenterHeaderGroups()], (r) => [...r].reverse(), R(e.options, E, "getCenterFooterGroups")), e.getRightFooterGroups = S(() => [e.getRightHeaderGroups()], (r) => [...r].reverse(), R(e.options, E, "getRightFooterGroups")), e.getFlatHeaders = S(() => [e.getHeaderGroups()], (r) => r.map((t) => t.headers).flat(), R(e.options, E, "getFlatHeaders")), e.getLeftFlatHeaders = S(() => [e.getLeftHeaderGroups()], (r) => r.map((t) => t.headers).flat(), R(e.options, E, "getLeftFlatHeaders")), e.getCenterFlatHeaders = S(() => [e.getCenterHeaderGroups()], (r) => r.map((t) => t.headers).flat(), R(e.options, E, "getCenterFlatHeaders")), e.getRightFlatHeaders = S(() => [e.getRightHeaderGroups()], (r) => r.map((t) => t.headers).flat(), R(e.options, E, "getRightFlatHeaders")), e.getCenterLeafHeaders = S(() => [e.getCenterFlatHeaders()], (r) => r.filter((t) => {
883
+ var n;
884
+ return !((n = t.subHeaders) != null && n.length);
885
+ }), R(e.options, E, "getCenterLeafHeaders")), e.getLeftLeafHeaders = S(() => [e.getLeftFlatHeaders()], (r) => r.filter((t) => {
886
+ var n;
887
+ return !((n = t.subHeaders) != null && n.length);
888
+ }), R(e.options, E, "getLeftLeafHeaders")), e.getRightLeafHeaders = S(() => [e.getRightFlatHeaders()], (r) => r.filter((t) => {
889
+ var n;
890
+ return !((n = t.subHeaders) != null && n.length);
891
+ }), R(e.options, E, "getRightLeafHeaders")), e.getLeafHeaders = S(() => [e.getLeftHeaderGroups(), e.getCenterHeaderGroups(), e.getRightHeaderGroups()], (r, t, n) => {
892
+ var o, l, s, i, u, f;
893
+ return [...(o = (l = r[0]) == null ? void 0 : l.headers) != null ? o : [], ...(s = (i = t[0]) == null ? void 0 : i.headers) != null ? s : [], ...(u = (f = n[0]) == null ? void 0 : f.headers) != null ? u : []].map((g) => g.getLeafHeaders()).flat();
894
+ }, R(e.options, E, "getLeafHeaders"));
895
+ }
896
+ };
897
+ function ue(e, r, t, n) {
898
+ var o, l;
899
+ let s = 0;
900
+ const i = function(d, a) {
901
+ a === void 0 && (a = 1), s = Math.max(s, a), d.filter((m) => m.getIsVisible()).forEach((m) => {
902
+ var h;
903
+ (h = m.columns) != null && h.length && i(m.columns, a + 1);
904
+ }, 0);
905
+ };
906
+ i(e);
907
+ let u = [];
908
+ const f = (d, a) => {
909
+ const m = {
910
+ depth: a,
911
+ id: [n, `${a}`].filter(Boolean).join("_"),
912
+ headers: []
913
+ }, h = [];
914
+ d.forEach((C) => {
915
+ const v = [...h].reverse()[0], y = C.column.depth === m.depth;
916
+ let x, $ = !1;
917
+ if (y && C.column.parent ? x = C.column.parent : (x = C.column, $ = !0), v && (v == null ? void 0 : v.column) === x)
918
+ v.subHeaders.push(C);
919
+ else {
920
+ const F = Xe(t, x, {
921
+ id: [n, a, x.id, C == null ? void 0 : C.id].filter(Boolean).join("_"),
922
+ isPlaceholder: $,
923
+ placeholderId: $ ? `${h.filter((P) => P.column === x).length}` : void 0,
924
+ depth: a,
925
+ index: h.length
926
+ });
927
+ F.subHeaders.push(C), h.push(F);
928
+ }
929
+ m.headers.push(C), C.headerGroup = m;
930
+ }), u.push(m), a > 0 && f(h, a - 1);
931
+ }, g = r.map((d, a) => Xe(t, d, {
932
+ depth: s,
933
+ index: a
934
+ }));
935
+ f(g, s - 1), u.reverse();
936
+ const p = (d) => d.filter((m) => m.column.getIsVisible()).map((m) => {
937
+ let h = 0, C = 0, v = [0];
938
+ m.subHeaders && m.subHeaders.length ? (v = [], p(m.subHeaders).forEach((x) => {
939
+ let {
940
+ colSpan: $,
941
+ rowSpan: F
942
+ } = x;
943
+ h += $, v.push(F);
944
+ })) : h = 1;
945
+ const y = Math.min(...v);
946
+ return C = C + y, m.colSpan = h, m.rowSpan = C, {
947
+ colSpan: h,
948
+ rowSpan: C
949
+ };
950
+ });
951
+ return p((o = (l = u[0]) == null ? void 0 : l.headers) != null ? o : []), u;
952
+ }
953
+ const be = (e, r, t, n, o, l, s) => {
954
+ let i = {
955
+ id: r,
956
+ index: n,
957
+ original: t,
958
+ depth: o,
959
+ parentId: s,
960
+ _valuesCache: {},
961
+ _uniqueValuesCache: {},
962
+ getValue: (u) => {
963
+ if (i._valuesCache.hasOwnProperty(u))
964
+ return i._valuesCache[u];
965
+ const f = e.getColumn(u);
966
+ if (f != null && f.accessorFn)
967
+ return i._valuesCache[u] = f.accessorFn(i.original, n), i._valuesCache[u];
968
+ },
969
+ getUniqueValues: (u) => {
970
+ if (i._uniqueValuesCache.hasOwnProperty(u))
971
+ return i._uniqueValuesCache[u];
972
+ const f = e.getColumn(u);
973
+ if (f != null && f.accessorFn)
974
+ return f.columnDef.getUniqueValues ? (i._uniqueValuesCache[u] = f.columnDef.getUniqueValues(i.original, n), i._uniqueValuesCache[u]) : (i._uniqueValuesCache[u] = [i.getValue(u)], i._uniqueValuesCache[u]);
975
+ },
976
+ renderValue: (u) => {
977
+ var f;
978
+ return (f = i.getValue(u)) != null ? f : e.options.renderFallbackValue;
979
+ },
980
+ subRows: [],
981
+ getLeafRows: () => Qt(i.subRows, (u) => u.subRows),
982
+ getParentRow: () => i.parentId ? e.getRow(i.parentId, !0) : void 0,
983
+ getParentRows: () => {
984
+ let u = [], f = i;
985
+ for (; ; ) {
986
+ const g = f.getParentRow();
987
+ if (!g) break;
988
+ u.push(g), f = g;
989
+ }
990
+ return u.reverse();
991
+ },
992
+ getAllCells: S(() => [e.getAllLeafColumns()], (u) => u.map((f) => Yt(e, i, f, f.id)), R(e.options, "debugRows", "getAllCells")),
993
+ _getAllCellsByColumnId: S(() => [i.getAllCells()], (u) => u.reduce((f, g) => (f[g.column.id] = g, f), {}), R(e.options, "debugRows", "getAllCellsByColumnId"))
994
+ };
995
+ for (let u = 0; u < e._features.length; u++) {
996
+ const f = e._features[u];
997
+ f == null || f.createRow == null || f.createRow(i, e);
998
+ }
999
+ return i;
1000
+ }, en = {
1001
+ createColumn: (e, r) => {
1002
+ e._getFacetedRowModel = r.options.getFacetedRowModel && r.options.getFacetedRowModel(r, e.id), e.getFacetedRowModel = () => e._getFacetedRowModel ? e._getFacetedRowModel() : r.getPreFilteredRowModel(), e._getFacetedUniqueValues = r.options.getFacetedUniqueValues && r.options.getFacetedUniqueValues(r, e.id), e.getFacetedUniqueValues = () => e._getFacetedUniqueValues ? e._getFacetedUniqueValues() : /* @__PURE__ */ new Map(), e._getFacetedMinMaxValues = r.options.getFacetedMinMaxValues && r.options.getFacetedMinMaxValues(r, e.id), e.getFacetedMinMaxValues = () => {
1003
+ if (e._getFacetedMinMaxValues)
1004
+ return e._getFacetedMinMaxValues();
1005
+ };
1006
+ }
1007
+ }, et = (e, r, t) => {
1008
+ var n, o;
1009
+ const l = t == null || (n = t.toString()) == null ? void 0 : n.toLowerCase();
1010
+ return !!(!((o = e.getValue(r)) == null || (o = o.toString()) == null || (o = o.toLowerCase()) == null) && o.includes(l));
1011
+ };
1012
+ et.autoRemove = (e) => O(e);
1013
+ const tt = (e, r, t) => {
1014
+ var n;
1015
+ return !!(!((n = e.getValue(r)) == null || (n = n.toString()) == null) && n.includes(t));
1016
+ };
1017
+ tt.autoRemove = (e) => O(e);
1018
+ const nt = (e, r, t) => {
1019
+ var n;
1020
+ return ((n = e.getValue(r)) == null || (n = n.toString()) == null ? void 0 : n.toLowerCase()) === (t == null ? void 0 : t.toLowerCase());
1021
+ };
1022
+ nt.autoRemove = (e) => O(e);
1023
+ const rt = (e, r, t) => {
1024
+ var n;
1025
+ return (n = e.getValue(r)) == null ? void 0 : n.includes(t);
1026
+ };
1027
+ rt.autoRemove = (e) => O(e);
1028
+ const ot = (e, r, t) => !t.some((n) => {
1029
+ var o;
1030
+ return !((o = e.getValue(r)) != null && o.includes(n));
1031
+ });
1032
+ ot.autoRemove = (e) => O(e) || !(e != null && e.length);
1033
+ const lt = (e, r, t) => t.some((n) => {
1034
+ var o;
1035
+ return (o = e.getValue(r)) == null ? void 0 : o.includes(n);
1036
+ });
1037
+ lt.autoRemove = (e) => O(e) || !(e != null && e.length);
1038
+ const st = (e, r, t) => e.getValue(r) === t;
1039
+ st.autoRemove = (e) => O(e);
1040
+ const it = (e, r, t) => e.getValue(r) == t;
1041
+ it.autoRemove = (e) => O(e);
1042
+ const De = (e, r, t) => {
1043
+ let [n, o] = t;
1044
+ const l = e.getValue(r);
1045
+ return l >= n && l <= o;
1046
+ };
1047
+ De.resolveFilterValue = (e) => {
1048
+ let [r, t] = e, n = typeof r != "number" ? parseFloat(r) : r, o = typeof t != "number" ? parseFloat(t) : t, l = r === null || Number.isNaN(n) ? -1 / 0 : n, s = t === null || Number.isNaN(o) ? 1 / 0 : o;
1049
+ if (l > s) {
1050
+ const i = l;
1051
+ l = s, s = i;
1052
+ }
1053
+ return [l, s];
1054
+ };
1055
+ De.autoRemove = (e) => O(e) || O(e[0]) && O(e[1]);
1056
+ const q = {
1057
+ includesString: et,
1058
+ includesStringSensitive: tt,
1059
+ equalsString: nt,
1060
+ arrIncludes: rt,
1061
+ arrIncludesAll: ot,
1062
+ arrIncludesSome: lt,
1063
+ equals: st,
1064
+ weakEquals: it,
1065
+ inNumberRange: De
1066
+ };
1067
+ function O(e) {
1068
+ return e == null || e === "";
1069
+ }
1070
+ const tn = {
1071
+ getDefaultColumnDef: () => ({
1072
+ filterFn: "auto"
1073
+ }),
1074
+ getInitialState: (e) => ({
1075
+ columnFilters: [],
1076
+ ...e
1077
+ }),
1078
+ getDefaultOptions: (e) => ({
1079
+ onColumnFiltersChange: L("columnFilters", e),
1080
+ filterFromLeafRows: !1,
1081
+ maxLeafRowFilterDepth: 100
1082
+ }),
1083
+ createColumn: (e, r) => {
1084
+ e.getAutoFilterFn = () => {
1085
+ const t = r.getCoreRowModel().flatRows[0], n = t == null ? void 0 : t.getValue(e.id);
1086
+ return typeof n == "string" ? q.includesString : typeof n == "number" ? q.inNumberRange : typeof n == "boolean" || n !== null && typeof n == "object" ? q.equals : Array.isArray(n) ? q.arrIncludes : q.weakEquals;
1087
+ }, e.getFilterFn = () => {
1088
+ var t, n;
1089
+ return ge(e.columnDef.filterFn) ? e.columnDef.filterFn : e.columnDef.filterFn === "auto" ? e.getAutoFilterFn() : (
1090
+ // @ts-ignore
1091
+ (t = (n = r.options.filterFns) == null ? void 0 : n[e.columnDef.filterFn]) != null ? t : q[e.columnDef.filterFn]
1092
+ );
1093
+ }, e.getCanFilter = () => {
1094
+ var t, n, o;
1095
+ return ((t = e.columnDef.enableColumnFilter) != null ? t : !0) && ((n = r.options.enableColumnFilters) != null ? n : !0) && ((o = r.options.enableFilters) != null ? o : !0) && !!e.accessorFn;
1096
+ }, e.getIsFiltered = () => e.getFilterIndex() > -1, e.getFilterValue = () => {
1097
+ var t;
1098
+ return (t = r.getState().columnFilters) == null || (t = t.find((n) => n.id === e.id)) == null ? void 0 : t.value;
1099
+ }, e.getFilterIndex = () => {
1100
+ var t, n;
1101
+ return (t = (n = r.getState().columnFilters) == null ? void 0 : n.findIndex((o) => o.id === e.id)) != null ? t : -1;
1102
+ }, e.setFilterValue = (t) => {
1103
+ r.setColumnFilters((n) => {
1104
+ const o = e.getFilterFn(), l = n == null ? void 0 : n.find((g) => g.id === e.id), s = X(t, l ? l.value : void 0);
1105
+ if (We(o, s, e)) {
1106
+ var i;
1107
+ return (i = n == null ? void 0 : n.filter((g) => g.id !== e.id)) != null ? i : [];
1108
+ }
1109
+ const u = {
1110
+ id: e.id,
1111
+ value: s
1112
+ };
1113
+ if (l) {
1114
+ var f;
1115
+ return (f = n == null ? void 0 : n.map((g) => g.id === e.id ? u : g)) != null ? f : [];
1116
+ }
1117
+ return n != null && n.length ? [...n, u] : [u];
1118
+ });
1119
+ };
1120
+ },
1121
+ createRow: (e, r) => {
1122
+ e.columnFilters = {}, e.columnFiltersMeta = {};
1123
+ },
1124
+ createTable: (e) => {
1125
+ e.setColumnFilters = (r) => {
1126
+ const t = e.getAllLeafColumns(), n = (o) => {
1127
+ var l;
1128
+ return (l = X(r, o)) == null ? void 0 : l.filter((s) => {
1129
+ const i = t.find((u) => u.id === s.id);
1130
+ if (i) {
1131
+ const u = i.getFilterFn();
1132
+ if (We(u, s.value, i))
1133
+ return !1;
1134
+ }
1135
+ return !0;
1136
+ });
1137
+ };
1138
+ e.options.onColumnFiltersChange == null || e.options.onColumnFiltersChange(n);
1139
+ }, e.resetColumnFilters = (r) => {
1140
+ var t, n;
1141
+ e.setColumnFilters(r ? [] : (t = (n = e.initialState) == null ? void 0 : n.columnFilters) != null ? t : []);
1142
+ }, e.getPreFilteredRowModel = () => e.getCoreRowModel(), e.getFilteredRowModel = () => (!e._getFilteredRowModel && e.options.getFilteredRowModel && (e._getFilteredRowModel = e.options.getFilteredRowModel(e)), e.options.manualFiltering || !e._getFilteredRowModel ? e.getPreFilteredRowModel() : e._getFilteredRowModel());
1143
+ }
1144
+ };
1145
+ function We(e, r, t) {
1146
+ return (e && e.autoRemove ? e.autoRemove(r, t) : !1) || typeof r > "u" || typeof r == "string" && !r;
1147
+ }
1148
+ const nn = (e, r, t) => t.reduce((n, o) => {
1149
+ const l = o.getValue(e);
1150
+ return n + (typeof l == "number" ? l : 0);
1151
+ }, 0), rn = (e, r, t) => {
1152
+ let n;
1153
+ return t.forEach((o) => {
1154
+ const l = o.getValue(e);
1155
+ l != null && (n > l || n === void 0 && l >= l) && (n = l);
1156
+ }), n;
1157
+ }, on = (e, r, t) => {
1158
+ let n;
1159
+ return t.forEach((o) => {
1160
+ const l = o.getValue(e);
1161
+ l != null && (n < l || n === void 0 && l >= l) && (n = l);
1162
+ }), n;
1163
+ }, ln = (e, r, t) => {
1164
+ let n, o;
1165
+ return t.forEach((l) => {
1166
+ const s = l.getValue(e);
1167
+ s != null && (n === void 0 ? s >= s && (n = o = s) : (n > s && (n = s), o < s && (o = s)));
1168
+ }), [n, o];
1169
+ }, sn = (e, r) => {
1170
+ let t = 0, n = 0;
1171
+ if (r.forEach((o) => {
1172
+ let l = o.getValue(e);
1173
+ l != null && (l = +l) >= l && (++t, n += l);
1174
+ }), t) return n / t;
1175
+ }, an = (e, r) => {
1176
+ if (!r.length)
1177
+ return;
1178
+ const t = r.map((l) => l.getValue(e));
1179
+ if (!Wt(t))
1180
+ return;
1181
+ if (t.length === 1)
1182
+ return t[0];
1183
+ const n = Math.floor(t.length / 2), o = t.sort((l, s) => l - s);
1184
+ return t.length % 2 !== 0 ? o[n] : (o[n - 1] + o[n]) / 2;
1185
+ }, un = (e, r) => Array.from(new Set(r.map((t) => t.getValue(e))).values()), fn = (e, r) => new Set(r.map((t) => t.getValue(e))).size, dn = (e, r) => r.length, he = {
1186
+ sum: nn,
1187
+ min: rn,
1188
+ max: on,
1189
+ extent: ln,
1190
+ mean: sn,
1191
+ median: an,
1192
+ unique: un,
1193
+ uniqueCount: fn,
1194
+ count: dn
1195
+ }, cn = {
1196
+ getDefaultColumnDef: () => ({
1197
+ aggregatedCell: (e) => {
1198
+ var r, t;
1199
+ return (r = (t = e.getValue()) == null || t.toString == null ? void 0 : t.toString()) != null ? r : null;
1200
+ },
1201
+ aggregationFn: "auto"
1202
+ }),
1203
+ getInitialState: (e) => ({
1204
+ grouping: [],
1205
+ ...e
1206
+ }),
1207
+ getDefaultOptions: (e) => ({
1208
+ onGroupingChange: L("grouping", e),
1209
+ groupedColumnMode: "reorder"
1210
+ }),
1211
+ createColumn: (e, r) => {
1212
+ e.toggleGrouping = () => {
1213
+ r.setGrouping((t) => t != null && t.includes(e.id) ? t.filter((n) => n !== e.id) : [...t ?? [], e.id]);
1214
+ }, e.getCanGroup = () => {
1215
+ var t, n;
1216
+ return ((t = e.columnDef.enableGrouping) != null ? t : !0) && ((n = r.options.enableGrouping) != null ? n : !0) && (!!e.accessorFn || !!e.columnDef.getGroupingValue);
1217
+ }, e.getIsGrouped = () => {
1218
+ var t;
1219
+ return (t = r.getState().grouping) == null ? void 0 : t.includes(e.id);
1220
+ }, e.getGroupedIndex = () => {
1221
+ var t;
1222
+ return (t = r.getState().grouping) == null ? void 0 : t.indexOf(e.id);
1223
+ }, e.getToggleGroupingHandler = () => {
1224
+ const t = e.getCanGroup();
1225
+ return () => {
1226
+ t && e.toggleGrouping();
1227
+ };
1228
+ }, e.getAutoAggregationFn = () => {
1229
+ const t = r.getCoreRowModel().flatRows[0], n = t == null ? void 0 : t.getValue(e.id);
1230
+ if (typeof n == "number")
1231
+ return he.sum;
1232
+ if (Object.prototype.toString.call(n) === "[object Date]")
1233
+ return he.extent;
1234
+ }, e.getAggregationFn = () => {
1235
+ var t, n;
1236
+ if (!e)
1237
+ throw new Error();
1238
+ return ge(e.columnDef.aggregationFn) ? e.columnDef.aggregationFn : e.columnDef.aggregationFn === "auto" ? e.getAutoAggregationFn() : (t = (n = r.options.aggregationFns) == null ? void 0 : n[e.columnDef.aggregationFn]) != null ? t : he[e.columnDef.aggregationFn];
1239
+ };
1240
+ },
1241
+ createTable: (e) => {
1242
+ e.setGrouping = (r) => e.options.onGroupingChange == null ? void 0 : e.options.onGroupingChange(r), e.resetGrouping = (r) => {
1243
+ var t, n;
1244
+ e.setGrouping(r ? [] : (t = (n = e.initialState) == null ? void 0 : n.grouping) != null ? t : []);
1245
+ }, e.getPreGroupedRowModel = () => e.getFilteredRowModel(), e.getGroupedRowModel = () => (!e._getGroupedRowModel && e.options.getGroupedRowModel && (e._getGroupedRowModel = e.options.getGroupedRowModel(e)), e.options.manualGrouping || !e._getGroupedRowModel ? e.getPreGroupedRowModel() : e._getGroupedRowModel());
1246
+ },
1247
+ createRow: (e, r) => {
1248
+ e.getIsGrouped = () => !!e.groupingColumnId, e.getGroupingValue = (t) => {
1249
+ if (e._groupingValuesCache.hasOwnProperty(t))
1250
+ return e._groupingValuesCache[t];
1251
+ const n = r.getColumn(t);
1252
+ return n != null && n.columnDef.getGroupingValue ? (e._groupingValuesCache[t] = n.columnDef.getGroupingValue(e.original), e._groupingValuesCache[t]) : e.getValue(t);
1253
+ }, e._groupingValuesCache = {};
1254
+ },
1255
+ createCell: (e, r, t, n) => {
1256
+ e.getIsGrouped = () => r.getIsGrouped() && r.id === t.groupingColumnId, e.getIsPlaceholder = () => !e.getIsGrouped() && r.getIsGrouped(), e.getIsAggregated = () => {
1257
+ var o;
1258
+ return !e.getIsGrouped() && !e.getIsPlaceholder() && !!((o = t.subRows) != null && o.length);
1259
+ };
1260
+ }
1261
+ };
1262
+ function gn(e, r, t) {
1263
+ if (!(r != null && r.length) || !t)
1264
+ return e;
1265
+ const n = e.filter((l) => !r.includes(l.id));
1266
+ return t === "remove" ? n : [...r.map((l) => e.find((s) => s.id === l)).filter(Boolean), ...n];
1267
+ }
1268
+ const pn = {
1269
+ getInitialState: (e) => ({
1270
+ columnOrder: [],
1271
+ ...e
1272
+ }),
1273
+ getDefaultOptions: (e) => ({
1274
+ onColumnOrderChange: L("columnOrder", e)
1275
+ }),
1276
+ createColumn: (e, r) => {
1277
+ e.getIndex = S((t) => [le(r, t)], (t) => t.findIndex((n) => n.id === e.id), R(r.options, "debugColumns", "getIndex")), e.getIsFirstColumn = (t) => {
1278
+ var n;
1279
+ return ((n = le(r, t)[0]) == null ? void 0 : n.id) === e.id;
1280
+ }, e.getIsLastColumn = (t) => {
1281
+ var n;
1282
+ const o = le(r, t);
1283
+ return ((n = o[o.length - 1]) == null ? void 0 : n.id) === e.id;
1284
+ };
1285
+ },
1286
+ createTable: (e) => {
1287
+ e.setColumnOrder = (r) => e.options.onColumnOrderChange == null ? void 0 : e.options.onColumnOrderChange(r), e.resetColumnOrder = (r) => {
1288
+ var t;
1289
+ e.setColumnOrder(r ? [] : (t = e.initialState.columnOrder) != null ? t : []);
1290
+ }, e._getOrderColumnsFn = S(() => [e.getState().columnOrder, e.getState().grouping, e.options.groupedColumnMode], (r, t, n) => (o) => {
1291
+ let l = [];
1292
+ if (!(r != null && r.length))
1293
+ l = o;
1294
+ else {
1295
+ const s = [...r], i = [...o];
1296
+ for (; i.length && s.length; ) {
1297
+ const u = s.shift(), f = i.findIndex((g) => g.id === u);
1298
+ f > -1 && l.push(i.splice(f, 1)[0]);
1299
+ }
1300
+ l = [...l, ...i];
1301
+ }
1302
+ return gn(l, t, n);
1303
+ }, R(e.options, "debugTable", "_getOrderColumnsFn"));
1304
+ }
1305
+ }, ve = () => ({
1306
+ left: [],
1307
+ right: []
1308
+ }), mn = {
1309
+ getInitialState: (e) => ({
1310
+ columnPinning: ve(),
1311
+ ...e
1312
+ }),
1313
+ getDefaultOptions: (e) => ({
1314
+ onColumnPinningChange: L("columnPinning", e)
1315
+ }),
1316
+ createColumn: (e, r) => {
1317
+ e.pin = (t) => {
1318
+ const n = e.getLeafColumns().map((o) => o.id).filter(Boolean);
1319
+ r.setColumnPinning((o) => {
1320
+ var l, s;
1321
+ if (t === "right") {
1322
+ var i, u;
1323
+ return {
1324
+ left: ((i = o == null ? void 0 : o.left) != null ? i : []).filter((p) => !(n != null && n.includes(p))),
1325
+ right: [...((u = o == null ? void 0 : o.right) != null ? u : []).filter((p) => !(n != null && n.includes(p))), ...n]
1326
+ };
1327
+ }
1328
+ if (t === "left") {
1329
+ var f, g;
1330
+ return {
1331
+ left: [...((f = o == null ? void 0 : o.left) != null ? f : []).filter((p) => !(n != null && n.includes(p))), ...n],
1332
+ right: ((g = o == null ? void 0 : o.right) != null ? g : []).filter((p) => !(n != null && n.includes(p)))
1333
+ };
1334
+ }
1335
+ return {
1336
+ left: ((l = o == null ? void 0 : o.left) != null ? l : []).filter((p) => !(n != null && n.includes(p))),
1337
+ right: ((s = o == null ? void 0 : o.right) != null ? s : []).filter((p) => !(n != null && n.includes(p)))
1338
+ };
1339
+ });
1340
+ }, e.getCanPin = () => e.getLeafColumns().some((n) => {
1341
+ var o, l, s;
1342
+ return ((o = n.columnDef.enablePinning) != null ? o : !0) && ((l = (s = r.options.enableColumnPinning) != null ? s : r.options.enablePinning) != null ? l : !0);
1343
+ }), e.getIsPinned = () => {
1344
+ const t = e.getLeafColumns().map((i) => i.id), {
1345
+ left: n,
1346
+ right: o
1347
+ } = r.getState().columnPinning, l = t.some((i) => n == null ? void 0 : n.includes(i)), s = t.some((i) => o == null ? void 0 : o.includes(i));
1348
+ return l ? "left" : s ? "right" : !1;
1349
+ }, e.getPinnedIndex = () => {
1350
+ var t, n;
1351
+ const o = e.getIsPinned();
1352
+ return o ? (t = (n = r.getState().columnPinning) == null || (n = n[o]) == null ? void 0 : n.indexOf(e.id)) != null ? t : -1 : 0;
1353
+ };
1354
+ },
1355
+ createRow: (e, r) => {
1356
+ e.getCenterVisibleCells = S(() => [e._getAllVisibleCells(), r.getState().columnPinning.left, r.getState().columnPinning.right], (t, n, o) => {
1357
+ const l = [...n ?? [], ...o ?? []];
1358
+ return t.filter((s) => !l.includes(s.column.id));
1359
+ }, R(r.options, "debugRows", "getCenterVisibleCells")), e.getLeftVisibleCells = S(() => [e._getAllVisibleCells(), r.getState().columnPinning.left], (t, n) => (n ?? []).map((l) => t.find((s) => s.column.id === l)).filter(Boolean).map((l) => ({
1360
+ ...l,
1361
+ position: "left"
1362
+ })), R(r.options, "debugRows", "getLeftVisibleCells")), e.getRightVisibleCells = S(() => [e._getAllVisibleCells(), r.getState().columnPinning.right], (t, n) => (n ?? []).map((l) => t.find((s) => s.column.id === l)).filter(Boolean).map((l) => ({
1363
+ ...l,
1364
+ position: "right"
1365
+ })), R(r.options, "debugRows", "getRightVisibleCells"));
1366
+ },
1367
+ createTable: (e) => {
1368
+ e.setColumnPinning = (r) => e.options.onColumnPinningChange == null ? void 0 : e.options.onColumnPinningChange(r), e.resetColumnPinning = (r) => {
1369
+ var t, n;
1370
+ return e.setColumnPinning(r ? ve() : (t = (n = e.initialState) == null ? void 0 : n.columnPinning) != null ? t : ve());
1371
+ }, e.getIsSomeColumnsPinned = (r) => {
1372
+ var t;
1373
+ const n = e.getState().columnPinning;
1374
+ if (!r) {
1375
+ var o, l;
1376
+ return !!((o = n.left) != null && o.length || (l = n.right) != null && l.length);
1377
+ }
1378
+ return !!((t = n[r]) != null && t.length);
1379
+ }, e.getLeftLeafColumns = S(() => [e.getAllLeafColumns(), e.getState().columnPinning.left], (r, t) => (t ?? []).map((n) => r.find((o) => o.id === n)).filter(Boolean), R(e.options, "debugColumns", "getLeftLeafColumns")), e.getRightLeafColumns = S(() => [e.getAllLeafColumns(), e.getState().columnPinning.right], (r, t) => (t ?? []).map((n) => r.find((o) => o.id === n)).filter(Boolean), R(e.options, "debugColumns", "getRightLeafColumns")), e.getCenterLeafColumns = S(() => [e.getAllLeafColumns(), e.getState().columnPinning.left, e.getState().columnPinning.right], (r, t, n) => {
1380
+ const o = [...t ?? [], ...n ?? []];
1381
+ return r.filter((l) => !o.includes(l.id));
1382
+ }, R(e.options, "debugColumns", "getCenterLeafColumns"));
1383
+ }
1384
+ };
1385
+ function hn(e) {
1386
+ return e || (typeof document < "u" ? document : null);
1387
+ }
1388
+ const fe = {
1389
+ size: 150,
1390
+ minSize: 20,
1391
+ maxSize: Number.MAX_SAFE_INTEGER
1392
+ }, we = () => ({
1393
+ startOffset: null,
1394
+ startSize: null,
1395
+ deltaOffset: null,
1396
+ deltaPercentage: null,
1397
+ isResizingColumn: !1,
1398
+ columnSizingStart: []
1399
+ }), vn = {
1400
+ getDefaultColumnDef: () => fe,
1401
+ getInitialState: (e) => ({
1402
+ columnSizing: {},
1403
+ columnSizingInfo: we(),
1404
+ ...e
1405
+ }),
1406
+ getDefaultOptions: (e) => ({
1407
+ columnResizeMode: "onEnd",
1408
+ columnResizeDirection: "ltr",
1409
+ onColumnSizingChange: L("columnSizing", e),
1410
+ onColumnSizingInfoChange: L("columnSizingInfo", e)
1411
+ }),
1412
+ createColumn: (e, r) => {
1413
+ e.getSize = () => {
1414
+ var t, n, o;
1415
+ const l = r.getState().columnSizing[e.id];
1416
+ return Math.min(Math.max((t = e.columnDef.minSize) != null ? t : fe.minSize, (n = l ?? e.columnDef.size) != null ? n : fe.size), (o = e.columnDef.maxSize) != null ? o : fe.maxSize);
1417
+ }, e.getStart = S((t) => [t, le(r, t), r.getState().columnSizing], (t, n) => n.slice(0, e.getIndex(t)).reduce((o, l) => o + l.getSize(), 0), R(r.options, "debugColumns", "getStart")), e.getAfter = S((t) => [t, le(r, t), r.getState().columnSizing], (t, n) => n.slice(e.getIndex(t) + 1).reduce((o, l) => o + l.getSize(), 0), R(r.options, "debugColumns", "getAfter")), e.resetSize = () => {
1418
+ r.setColumnSizing((t) => {
1419
+ let {
1420
+ [e.id]: n,
1421
+ ...o
1422
+ } = t;
1423
+ return o;
1424
+ });
1425
+ }, e.getCanResize = () => {
1426
+ var t, n;
1427
+ return ((t = e.columnDef.enableResizing) != null ? t : !0) && ((n = r.options.enableColumnResizing) != null ? n : !0);
1428
+ }, e.getIsResizing = () => r.getState().columnSizingInfo.isResizingColumn === e.id;
1429
+ },
1430
+ createHeader: (e, r) => {
1431
+ e.getSize = () => {
1432
+ let t = 0;
1433
+ const n = (o) => {
1434
+ if (o.subHeaders.length)
1435
+ o.subHeaders.forEach(n);
1436
+ else {
1437
+ var l;
1438
+ t += (l = o.column.getSize()) != null ? l : 0;
1439
+ }
1440
+ };
1441
+ return n(e), t;
1442
+ }, e.getStart = () => {
1443
+ if (e.index > 0) {
1444
+ const t = e.headerGroup.headers[e.index - 1];
1445
+ return t.getStart() + t.getSize();
1446
+ }
1447
+ return 0;
1448
+ }, e.getResizeHandler = (t) => {
1449
+ const n = r.getColumn(e.column.id), o = n == null ? void 0 : n.getCanResize();
1450
+ return (l) => {
1451
+ if (!n || !o || (l.persist == null || l.persist(), Ce(l) && l.touches && l.touches.length > 1))
1452
+ return;
1453
+ const s = e.getSize(), i = e ? e.getLeafHeaders().map((v) => [v.column.id, v.column.getSize()]) : [[n.id, n.getSize()]], u = Ce(l) ? Math.round(l.touches[0].clientX) : l.clientX, f = {}, g = (v, y) => {
1454
+ typeof y == "number" && (r.setColumnSizingInfo((x) => {
1455
+ var $, F;
1456
+ const P = r.options.columnResizeDirection === "rtl" ? -1 : 1, Y = (y - (($ = x == null ? void 0 : x.startOffset) != null ? $ : 0)) * P, k = Math.max(Y / ((F = x == null ? void 0 : x.startSize) != null ? F : 0), -0.999999);
1457
+ return x.columnSizingStart.forEach((G) => {
1458
+ let [K, D] = G;
1459
+ f[K] = Math.round(Math.max(D + D * k, 0) * 100) / 100;
1460
+ }), {
1461
+ ...x,
1462
+ deltaOffset: Y,
1463
+ deltaPercentage: k
1464
+ };
1465
+ }), (r.options.columnResizeMode === "onChange" || v === "end") && r.setColumnSizing((x) => ({
1466
+ ...x,
1467
+ ...f
1468
+ })));
1469
+ }, p = (v) => g("move", v), d = (v) => {
1470
+ g("end", v), r.setColumnSizingInfo((y) => ({
1471
+ ...y,
1472
+ isResizingColumn: !1,
1473
+ startOffset: null,
1474
+ startSize: null,
1475
+ deltaOffset: null,
1476
+ deltaPercentage: null,
1477
+ columnSizingStart: []
1478
+ }));
1479
+ }, a = hn(t), m = {
1480
+ moveHandler: (v) => p(v.clientX),
1481
+ upHandler: (v) => {
1482
+ a == null || a.removeEventListener("mousemove", m.moveHandler), a == null || a.removeEventListener("mouseup", m.upHandler), d(v.clientX);
1483
+ }
1484
+ }, h = {
1485
+ moveHandler: (v) => (v.cancelable && (v.preventDefault(), v.stopPropagation()), p(v.touches[0].clientX), !1),
1486
+ upHandler: (v) => {
1487
+ var y;
1488
+ a == null || a.removeEventListener("touchmove", h.moveHandler), a == null || a.removeEventListener("touchend", h.upHandler), v.cancelable && (v.preventDefault(), v.stopPropagation()), d((y = v.touches[0]) == null ? void 0 : y.clientX);
1489
+ }
1490
+ }, C = wn() ? {
1491
+ passive: !1
1492
+ } : !1;
1493
+ Ce(l) ? (a == null || a.addEventListener("touchmove", h.moveHandler, C), a == null || a.addEventListener("touchend", h.upHandler, C)) : (a == null || a.addEventListener("mousemove", m.moveHandler, C), a == null || a.addEventListener("mouseup", m.upHandler, C)), r.setColumnSizingInfo((v) => ({
1494
+ ...v,
1495
+ startOffset: u,
1496
+ startSize: s,
1497
+ deltaOffset: 0,
1498
+ deltaPercentage: 0,
1499
+ columnSizingStart: i,
1500
+ isResizingColumn: n.id
1501
+ }));
1502
+ };
1503
+ };
1504
+ },
1505
+ createTable: (e) => {
1506
+ e.setColumnSizing = (r) => e.options.onColumnSizingChange == null ? void 0 : e.options.onColumnSizingChange(r), e.setColumnSizingInfo = (r) => e.options.onColumnSizingInfoChange == null ? void 0 : e.options.onColumnSizingInfoChange(r), e.resetColumnSizing = (r) => {
1507
+ var t;
1508
+ e.setColumnSizing(r ? {} : (t = e.initialState.columnSizing) != null ? t : {});
1509
+ }, e.resetHeaderSizeInfo = (r) => {
1510
+ var t;
1511
+ e.setColumnSizingInfo(r ? we() : (t = e.initialState.columnSizingInfo) != null ? t : we());
1512
+ }, e.getTotalSize = () => {
1513
+ var r, t;
1514
+ return (r = (t = e.getHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, o) => n + o.getSize(), 0)) != null ? r : 0;
1515
+ }, e.getLeftTotalSize = () => {
1516
+ var r, t;
1517
+ return (r = (t = e.getLeftHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, o) => n + o.getSize(), 0)) != null ? r : 0;
1518
+ }, e.getCenterTotalSize = () => {
1519
+ var r, t;
1520
+ return (r = (t = e.getCenterHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, o) => n + o.getSize(), 0)) != null ? r : 0;
1521
+ }, e.getRightTotalSize = () => {
1522
+ var r, t;
1523
+ return (r = (t = e.getRightHeaderGroups()[0]) == null ? void 0 : t.headers.reduce((n, o) => n + o.getSize(), 0)) != null ? r : 0;
1524
+ };
1525
+ }
1526
+ };
1527
+ let de = null;
1528
+ function wn() {
1529
+ if (typeof de == "boolean") return de;
1530
+ let e = !1;
1531
+ try {
1532
+ const r = {
1533
+ get passive() {
1534
+ return e = !0, !1;
1535
+ }
1536
+ }, t = () => {
1537
+ };
1538
+ window.addEventListener("test", t, r), window.removeEventListener("test", t);
1539
+ } catch {
1540
+ e = !1;
1541
+ }
1542
+ return de = e, de;
1543
+ }
1544
+ function Ce(e) {
1545
+ return e.type === "touchstart";
1546
+ }
1547
+ const Cn = {
1548
+ getInitialState: (e) => ({
1549
+ columnVisibility: {},
1550
+ ...e
1551
+ }),
1552
+ getDefaultOptions: (e) => ({
1553
+ onColumnVisibilityChange: L("columnVisibility", e)
1554
+ }),
1555
+ createColumn: (e, r) => {
1556
+ e.toggleVisibility = (t) => {
1557
+ e.getCanHide() && r.setColumnVisibility((n) => ({
1558
+ ...n,
1559
+ [e.id]: t ?? !e.getIsVisible()
1560
+ }));
1561
+ }, e.getIsVisible = () => {
1562
+ var t, n;
1563
+ const o = e.columns;
1564
+ return (t = o.length ? o.some((l) => l.getIsVisible()) : (n = r.getState().columnVisibility) == null ? void 0 : n[e.id]) != null ? t : !0;
1565
+ }, e.getCanHide = () => {
1566
+ var t, n;
1567
+ return ((t = e.columnDef.enableHiding) != null ? t : !0) && ((n = r.options.enableHiding) != null ? n : !0);
1568
+ }, e.getToggleVisibilityHandler = () => (t) => {
1569
+ e.toggleVisibility == null || e.toggleVisibility(t.target.checked);
1570
+ };
1571
+ },
1572
+ createRow: (e, r) => {
1573
+ e._getAllVisibleCells = S(() => [e.getAllCells(), r.getState().columnVisibility], (t) => t.filter((n) => n.column.getIsVisible()), R(r.options, "debugRows", "_getAllVisibleCells")), e.getVisibleCells = S(() => [e.getLeftVisibleCells(), e.getCenterVisibleCells(), e.getRightVisibleCells()], (t, n, o) => [...t, ...n, ...o], R(r.options, "debugRows", "getVisibleCells"));
1574
+ },
1575
+ createTable: (e) => {
1576
+ const r = (t, n) => S(() => [n(), n().filter((o) => o.getIsVisible()).map((o) => o.id).join("_")], (o) => o.filter((l) => l.getIsVisible == null ? void 0 : l.getIsVisible()), R(e.options, "debugColumns", t));
1577
+ e.getVisibleFlatColumns = r("getVisibleFlatColumns", () => e.getAllFlatColumns()), e.getVisibleLeafColumns = r("getVisibleLeafColumns", () => e.getAllLeafColumns()), e.getLeftVisibleLeafColumns = r("getLeftVisibleLeafColumns", () => e.getLeftLeafColumns()), e.getRightVisibleLeafColumns = r("getRightVisibleLeafColumns", () => e.getRightLeafColumns()), e.getCenterVisibleLeafColumns = r("getCenterVisibleLeafColumns", () => e.getCenterLeafColumns()), e.setColumnVisibility = (t) => e.options.onColumnVisibilityChange == null ? void 0 : e.options.onColumnVisibilityChange(t), e.resetColumnVisibility = (t) => {
1578
+ var n;
1579
+ e.setColumnVisibility(t ? {} : (n = e.initialState.columnVisibility) != null ? n : {});
1580
+ }, e.toggleAllColumnsVisible = (t) => {
1581
+ var n;
1582
+ t = (n = t) != null ? n : !e.getIsAllColumnsVisible(), e.setColumnVisibility(e.getAllLeafColumns().reduce((o, l) => ({
1583
+ ...o,
1584
+ [l.id]: t || !(l.getCanHide != null && l.getCanHide())
1585
+ }), {}));
1586
+ }, e.getIsAllColumnsVisible = () => !e.getAllLeafColumns().some((t) => !(t.getIsVisible != null && t.getIsVisible())), e.getIsSomeColumnsVisible = () => e.getAllLeafColumns().some((t) => t.getIsVisible == null ? void 0 : t.getIsVisible()), e.getToggleAllColumnsVisibilityHandler = () => (t) => {
1587
+ var n;
1588
+ e.toggleAllColumnsVisible((n = t.target) == null ? void 0 : n.checked);
1589
+ };
1590
+ }
1591
+ };
1592
+ function le(e, r) {
1593
+ return r ? r === "center" ? e.getCenterVisibleLeafColumns() : r === "left" ? e.getLeftVisibleLeafColumns() : e.getRightVisibleLeafColumns() : e.getVisibleLeafColumns();
1594
+ }
1595
+ const yn = {
1596
+ createTable: (e) => {
1597
+ e._getGlobalFacetedRowModel = e.options.getFacetedRowModel && e.options.getFacetedRowModel(e, "__global__"), e.getGlobalFacetedRowModel = () => e.options.manualFiltering || !e._getGlobalFacetedRowModel ? e.getPreFilteredRowModel() : e._getGlobalFacetedRowModel(), e._getGlobalFacetedUniqueValues = e.options.getFacetedUniqueValues && e.options.getFacetedUniqueValues(e, "__global__"), e.getGlobalFacetedUniqueValues = () => e._getGlobalFacetedUniqueValues ? e._getGlobalFacetedUniqueValues() : /* @__PURE__ */ new Map(), e._getGlobalFacetedMinMaxValues = e.options.getFacetedMinMaxValues && e.options.getFacetedMinMaxValues(e, "__global__"), e.getGlobalFacetedMinMaxValues = () => {
1598
+ if (e._getGlobalFacetedMinMaxValues)
1599
+ return e._getGlobalFacetedMinMaxValues();
1600
+ };
1601
+ }
1602
+ }, Sn = {
1603
+ getInitialState: (e) => ({
1604
+ globalFilter: void 0,
1605
+ ...e
1606
+ }),
1607
+ getDefaultOptions: (e) => ({
1608
+ onGlobalFilterChange: L("globalFilter", e),
1609
+ globalFilterFn: "auto",
1610
+ getColumnCanGlobalFilter: (r) => {
1611
+ var t;
1612
+ const n = (t = e.getCoreRowModel().flatRows[0]) == null || (t = t._getAllCellsByColumnId()[r.id]) == null ? void 0 : t.getValue();
1613
+ return typeof n == "string" || typeof n == "number";
1614
+ }
1615
+ }),
1616
+ createColumn: (e, r) => {
1617
+ e.getCanGlobalFilter = () => {
1618
+ var t, n, o, l;
1619
+ return ((t = e.columnDef.enableGlobalFilter) != null ? t : !0) && ((n = r.options.enableGlobalFilter) != null ? n : !0) && ((o = r.options.enableFilters) != null ? o : !0) && ((l = r.options.getColumnCanGlobalFilter == null ? void 0 : r.options.getColumnCanGlobalFilter(e)) != null ? l : !0) && !!e.accessorFn;
1620
+ };
1621
+ },
1622
+ createTable: (e) => {
1623
+ e.getGlobalAutoFilterFn = () => q.includesString, e.getGlobalFilterFn = () => {
1624
+ var r, t;
1625
+ const {
1626
+ globalFilterFn: n
1627
+ } = e.options;
1628
+ return ge(n) ? n : n === "auto" ? e.getGlobalAutoFilterFn() : (r = (t = e.options.filterFns) == null ? void 0 : t[n]) != null ? r : q[n];
1629
+ }, e.setGlobalFilter = (r) => {
1630
+ e.options.onGlobalFilterChange == null || e.options.onGlobalFilterChange(r);
1631
+ }, e.resetGlobalFilter = (r) => {
1632
+ e.setGlobalFilter(r ? void 0 : e.initialState.globalFilter);
1633
+ };
1634
+ }
1635
+ }, Rn = {
1636
+ getInitialState: (e) => ({
1637
+ expanded: {},
1638
+ ...e
1639
+ }),
1640
+ getDefaultOptions: (e) => ({
1641
+ onExpandedChange: L("expanded", e),
1642
+ paginateExpandedRows: !0
1643
+ }),
1644
+ createTable: (e) => {
1645
+ let r = !1, t = !1;
1646
+ e._autoResetExpanded = () => {
1647
+ var n, o;
1648
+ if (!r) {
1649
+ e._queue(() => {
1650
+ r = !0;
1651
+ });
1652
+ return;
1653
+ }
1654
+ if ((n = (o = e.options.autoResetAll) != null ? o : e.options.autoResetExpanded) != null ? n : !e.options.manualExpanding) {
1655
+ if (t) return;
1656
+ t = !0, e._queue(() => {
1657
+ e.resetExpanded(), t = !1;
1658
+ });
1659
+ }
1660
+ }, e.setExpanded = (n) => e.options.onExpandedChange == null ? void 0 : e.options.onExpandedChange(n), e.toggleAllRowsExpanded = (n) => {
1661
+ n ?? !e.getIsAllRowsExpanded() ? e.setExpanded(!0) : e.setExpanded({});
1662
+ }, e.resetExpanded = (n) => {
1663
+ var o, l;
1664
+ e.setExpanded(n ? {} : (o = (l = e.initialState) == null ? void 0 : l.expanded) != null ? o : {});
1665
+ }, e.getCanSomeRowsExpand = () => e.getPrePaginationRowModel().flatRows.some((n) => n.getCanExpand()), e.getToggleAllRowsExpandedHandler = () => (n) => {
1666
+ n.persist == null || n.persist(), e.toggleAllRowsExpanded();
1667
+ }, e.getIsSomeRowsExpanded = () => {
1668
+ const n = e.getState().expanded;
1669
+ return n === !0 || Object.values(n).some(Boolean);
1670
+ }, e.getIsAllRowsExpanded = () => {
1671
+ const n = e.getState().expanded;
1672
+ return typeof n == "boolean" ? n === !0 : !(!Object.keys(n).length || e.getRowModel().flatRows.some((o) => !o.getIsExpanded()));
1673
+ }, e.getExpandedDepth = () => {
1674
+ let n = 0;
1675
+ return (e.getState().expanded === !0 ? Object.keys(e.getRowModel().rowsById) : Object.keys(e.getState().expanded)).forEach((l) => {
1676
+ const s = l.split(".");
1677
+ n = Math.max(n, s.length);
1678
+ }), n;
1679
+ }, e.getPreExpandedRowModel = () => e.getSortedRowModel(), e.getExpandedRowModel = () => (!e._getExpandedRowModel && e.options.getExpandedRowModel && (e._getExpandedRowModel = e.options.getExpandedRowModel(e)), e.options.manualExpanding || !e._getExpandedRowModel ? e.getPreExpandedRowModel() : e._getExpandedRowModel());
1680
+ },
1681
+ createRow: (e, r) => {
1682
+ e.toggleExpanded = (t) => {
1683
+ r.setExpanded((n) => {
1684
+ var o;
1685
+ const l = n === !0 ? !0 : !!(n != null && n[e.id]);
1686
+ let s = {};
1687
+ if (n === !0 ? Object.keys(r.getRowModel().rowsById).forEach((i) => {
1688
+ s[i] = !0;
1689
+ }) : s = n, t = (o = t) != null ? o : !l, !l && t)
1690
+ return {
1691
+ ...s,
1692
+ [e.id]: !0
1693
+ };
1694
+ if (l && !t) {
1695
+ const {
1696
+ [e.id]: i,
1697
+ ...u
1698
+ } = s;
1699
+ return u;
1700
+ }
1701
+ return n;
1702
+ });
1703
+ }, e.getIsExpanded = () => {
1704
+ var t;
1705
+ const n = r.getState().expanded;
1706
+ return !!((t = r.options.getIsRowExpanded == null ? void 0 : r.options.getIsRowExpanded(e)) != null ? t : n === !0 || n != null && n[e.id]);
1707
+ }, e.getCanExpand = () => {
1708
+ var t, n, o;
1709
+ return (t = r.options.getRowCanExpand == null ? void 0 : r.options.getRowCanExpand(e)) != null ? t : ((n = r.options.enableExpanding) != null ? n : !0) && !!((o = e.subRows) != null && o.length);
1710
+ }, e.getIsAllParentsExpanded = () => {
1711
+ let t = !0, n = e;
1712
+ for (; t && n.parentId; )
1713
+ n = r.getRow(n.parentId, !0), t = n.getIsExpanded();
1714
+ return t;
1715
+ }, e.getToggleExpandedHandler = () => {
1716
+ const t = e.getCanExpand();
1717
+ return () => {
1718
+ t && e.toggleExpanded();
1719
+ };
1720
+ };
1721
+ }
1722
+ }, Ie = 0, $e = 10, ye = () => ({
1723
+ pageIndex: Ie,
1724
+ pageSize: $e
1725
+ }), xn = {
1726
+ getInitialState: (e) => ({
1727
+ ...e,
1728
+ pagination: {
1729
+ ...ye(),
1730
+ ...e == null ? void 0 : e.pagination
1731
+ }
1732
+ }),
1733
+ getDefaultOptions: (e) => ({
1734
+ onPaginationChange: L("pagination", e)
1735
+ }),
1736
+ createTable: (e) => {
1737
+ let r = !1, t = !1;
1738
+ e._autoResetPageIndex = () => {
1739
+ var n, o;
1740
+ if (!r) {
1741
+ e._queue(() => {
1742
+ r = !0;
1743
+ });
1744
+ return;
1745
+ }
1746
+ if ((n = (o = e.options.autoResetAll) != null ? o : e.options.autoResetPageIndex) != null ? n : !e.options.manualPagination) {
1747
+ if (t) return;
1748
+ t = !0, e._queue(() => {
1749
+ e.resetPageIndex(), t = !1;
1750
+ });
1751
+ }
1752
+ }, e.setPagination = (n) => {
1753
+ const o = (l) => X(n, l);
1754
+ return e.options.onPaginationChange == null ? void 0 : e.options.onPaginationChange(o);
1755
+ }, e.resetPagination = (n) => {
1756
+ var o;
1757
+ e.setPagination(n ? ye() : (o = e.initialState.pagination) != null ? o : ye());
1758
+ }, e.setPageIndex = (n) => {
1759
+ e.setPagination((o) => {
1760
+ let l = X(n, o.pageIndex);
1761
+ const s = typeof e.options.pageCount > "u" || e.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : e.options.pageCount - 1;
1762
+ return l = Math.max(0, Math.min(l, s)), {
1763
+ ...o,
1764
+ pageIndex: l
1765
+ };
1766
+ });
1767
+ }, e.resetPageIndex = (n) => {
1768
+ var o, l;
1769
+ e.setPageIndex(n ? Ie : (o = (l = e.initialState) == null || (l = l.pagination) == null ? void 0 : l.pageIndex) != null ? o : Ie);
1770
+ }, e.resetPageSize = (n) => {
1771
+ var o, l;
1772
+ e.setPageSize(n ? $e : (o = (l = e.initialState) == null || (l = l.pagination) == null ? void 0 : l.pageSize) != null ? o : $e);
1773
+ }, e.setPageSize = (n) => {
1774
+ e.setPagination((o) => {
1775
+ const l = Math.max(1, X(n, o.pageSize)), s = o.pageSize * o.pageIndex, i = Math.floor(s / l);
1776
+ return {
1777
+ ...o,
1778
+ pageIndex: i,
1779
+ pageSize: l
1780
+ };
1781
+ });
1782
+ }, e.setPageCount = (n) => e.setPagination((o) => {
1783
+ var l;
1784
+ let s = X(n, (l = e.options.pageCount) != null ? l : -1);
1785
+ return typeof s == "number" && (s = Math.max(-1, s)), {
1786
+ ...o,
1787
+ pageCount: s
1788
+ };
1789
+ }), e.getPageOptions = S(() => [e.getPageCount()], (n) => {
1790
+ let o = [];
1791
+ return n && n > 0 && (o = [...new Array(n)].fill(null).map((l, s) => s)), o;
1792
+ }, R(e.options, "debugTable", "getPageOptions")), e.getCanPreviousPage = () => e.getState().pagination.pageIndex > 0, e.getCanNextPage = () => {
1793
+ const {
1794
+ pageIndex: n
1795
+ } = e.getState().pagination, o = e.getPageCount();
1796
+ return o === -1 ? !0 : o === 0 ? !1 : n < o - 1;
1797
+ }, e.previousPage = () => e.setPageIndex((n) => n - 1), e.nextPage = () => e.setPageIndex((n) => n + 1), e.firstPage = () => e.setPageIndex(0), e.lastPage = () => e.setPageIndex(e.getPageCount() - 1), e.getPrePaginationRowModel = () => e.getExpandedRowModel(), e.getPaginationRowModel = () => (!e._getPaginationRowModel && e.options.getPaginationRowModel && (e._getPaginationRowModel = e.options.getPaginationRowModel(e)), e.options.manualPagination || !e._getPaginationRowModel ? e.getPrePaginationRowModel() : e._getPaginationRowModel()), e.getPageCount = () => {
1798
+ var n;
1799
+ return (n = e.options.pageCount) != null ? n : Math.ceil(e.getRowCount() / e.getState().pagination.pageSize);
1800
+ }, e.getRowCount = () => {
1801
+ var n;
1802
+ return (n = e.options.rowCount) != null ? n : e.getPrePaginationRowModel().rows.length;
1803
+ };
1804
+ }
1805
+ }, Se = () => ({
1806
+ top: [],
1807
+ bottom: []
1808
+ }), _n = {
1809
+ getInitialState: (e) => ({
1810
+ rowPinning: Se(),
1811
+ ...e
1812
+ }),
1813
+ getDefaultOptions: (e) => ({
1814
+ onRowPinningChange: L("rowPinning", e)
1815
+ }),
1816
+ createRow: (e, r) => {
1817
+ e.pin = (t, n, o) => {
1818
+ const l = n ? e.getLeafRows().map((u) => {
1819
+ let {
1820
+ id: f
1821
+ } = u;
1822
+ return f;
1823
+ }) : [], s = o ? e.getParentRows().map((u) => {
1824
+ let {
1825
+ id: f
1826
+ } = u;
1827
+ return f;
1828
+ }) : [], i = /* @__PURE__ */ new Set([...s, e.id, ...l]);
1829
+ r.setRowPinning((u) => {
1830
+ var f, g;
1831
+ if (t === "bottom") {
1832
+ var p, d;
1833
+ return {
1834
+ top: ((p = u == null ? void 0 : u.top) != null ? p : []).filter((h) => !(i != null && i.has(h))),
1835
+ bottom: [...((d = u == null ? void 0 : u.bottom) != null ? d : []).filter((h) => !(i != null && i.has(h))), ...Array.from(i)]
1836
+ };
1837
+ }
1838
+ if (t === "top") {
1839
+ var a, m;
1840
+ return {
1841
+ top: [...((a = u == null ? void 0 : u.top) != null ? a : []).filter((h) => !(i != null && i.has(h))), ...Array.from(i)],
1842
+ bottom: ((m = u == null ? void 0 : u.bottom) != null ? m : []).filter((h) => !(i != null && i.has(h)))
1843
+ };
1844
+ }
1845
+ return {
1846
+ top: ((f = u == null ? void 0 : u.top) != null ? f : []).filter((h) => !(i != null && i.has(h))),
1847
+ bottom: ((g = u == null ? void 0 : u.bottom) != null ? g : []).filter((h) => !(i != null && i.has(h)))
1848
+ };
1849
+ });
1850
+ }, e.getCanPin = () => {
1851
+ var t;
1852
+ const {
1853
+ enableRowPinning: n,
1854
+ enablePinning: o
1855
+ } = r.options;
1856
+ return typeof n == "function" ? n(e) : (t = n ?? o) != null ? t : !0;
1857
+ }, e.getIsPinned = () => {
1858
+ const t = [e.id], {
1859
+ top: n,
1860
+ bottom: o
1861
+ } = r.getState().rowPinning, l = t.some((i) => n == null ? void 0 : n.includes(i)), s = t.some((i) => o == null ? void 0 : o.includes(i));
1862
+ return l ? "top" : s ? "bottom" : !1;
1863
+ }, e.getPinnedIndex = () => {
1864
+ var t, n;
1865
+ const o = e.getIsPinned();
1866
+ if (!o) return -1;
1867
+ const l = (t = o === "top" ? r.getTopRows() : r.getBottomRows()) == null ? void 0 : t.map((s) => {
1868
+ let {
1869
+ id: i
1870
+ } = s;
1871
+ return i;
1872
+ });
1873
+ return (n = l == null ? void 0 : l.indexOf(e.id)) != null ? n : -1;
1874
+ };
1875
+ },
1876
+ createTable: (e) => {
1877
+ e.setRowPinning = (r) => e.options.onRowPinningChange == null ? void 0 : e.options.onRowPinningChange(r), e.resetRowPinning = (r) => {
1878
+ var t, n;
1879
+ return e.setRowPinning(r ? Se() : (t = (n = e.initialState) == null ? void 0 : n.rowPinning) != null ? t : Se());
1880
+ }, e.getIsSomeRowsPinned = (r) => {
1881
+ var t;
1882
+ const n = e.getState().rowPinning;
1883
+ if (!r) {
1884
+ var o, l;
1885
+ return !!((o = n.top) != null && o.length || (l = n.bottom) != null && l.length);
1886
+ }
1887
+ return !!((t = n[r]) != null && t.length);
1888
+ }, e._getPinnedRows = (r, t, n) => {
1889
+ var o;
1890
+ return ((o = e.options.keepPinnedRows) == null || o ? (
1891
+ //get all rows that are pinned even if they would not be otherwise visible
1892
+ //account for expanded parent rows, but not pagination or filtering
1893
+ (t ?? []).map((s) => {
1894
+ const i = e.getRow(s, !0);
1895
+ return i.getIsAllParentsExpanded() ? i : null;
1896
+ })
1897
+ ) : (
1898
+ //else get only visible rows that are pinned
1899
+ (t ?? []).map((s) => r.find((i) => i.id === s))
1900
+ )).filter(Boolean).map((s) => ({
1901
+ ...s,
1902
+ position: n
1903
+ }));
1904
+ }, e.getTopRows = S(() => [e.getRowModel().rows, e.getState().rowPinning.top], (r, t) => e._getPinnedRows(r, t, "top"), R(e.options, "debugRows", "getTopRows")), e.getBottomRows = S(() => [e.getRowModel().rows, e.getState().rowPinning.bottom], (r, t) => e._getPinnedRows(r, t, "bottom"), R(e.options, "debugRows", "getBottomRows")), e.getCenterRows = S(() => [e.getRowModel().rows, e.getState().rowPinning.top, e.getState().rowPinning.bottom], (r, t, n) => {
1905
+ const o = /* @__PURE__ */ new Set([...t ?? [], ...n ?? []]);
1906
+ return r.filter((l) => !o.has(l.id));
1907
+ }, R(e.options, "debugRows", "getCenterRows"));
1908
+ }
1909
+ }, Fn = {
1910
+ getInitialState: (e) => ({
1911
+ rowSelection: {},
1912
+ ...e
1913
+ }),
1914
+ getDefaultOptions: (e) => ({
1915
+ onRowSelectionChange: L("rowSelection", e),
1916
+ enableRowSelection: !0,
1917
+ enableMultiRowSelection: !0,
1918
+ enableSubRowSelection: !0
1919
+ // enableGroupingRowSelection: false,
1920
+ // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
1921
+ // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
1922
+ }),
1923
+ createTable: (e) => {
1924
+ e.setRowSelection = (r) => e.options.onRowSelectionChange == null ? void 0 : e.options.onRowSelectionChange(r), e.resetRowSelection = (r) => {
1925
+ var t;
1926
+ return e.setRowSelection(r ? {} : (t = e.initialState.rowSelection) != null ? t : {});
1927
+ }, e.toggleAllRowsSelected = (r) => {
1928
+ e.setRowSelection((t) => {
1929
+ r = typeof r < "u" ? r : !e.getIsAllRowsSelected();
1930
+ const n = {
1931
+ ...t
1932
+ }, o = e.getPreGroupedRowModel().flatRows;
1933
+ return r ? o.forEach((l) => {
1934
+ l.getCanSelect() && (n[l.id] = !0);
1935
+ }) : o.forEach((l) => {
1936
+ delete n[l.id];
1937
+ }), n;
1938
+ });
1939
+ }, e.toggleAllPageRowsSelected = (r) => e.setRowSelection((t) => {
1940
+ const n = typeof r < "u" ? r : !e.getIsAllPageRowsSelected(), o = {
1941
+ ...t
1942
+ };
1943
+ return e.getRowModel().rows.forEach((l) => {
1944
+ Ne(o, l.id, n, !0, e);
1945
+ }), o;
1946
+ }), e.getPreSelectedRowModel = () => e.getCoreRowModel(), e.getSelectedRowModel = S(() => [e.getState().rowSelection, e.getCoreRowModel()], (r, t) => Object.keys(r).length ? Re(e, t) : {
1947
+ rows: [],
1948
+ flatRows: [],
1949
+ rowsById: {}
1950
+ }, R(e.options, "debugTable", "getSelectedRowModel")), e.getFilteredSelectedRowModel = S(() => [e.getState().rowSelection, e.getFilteredRowModel()], (r, t) => Object.keys(r).length ? Re(e, t) : {
1951
+ rows: [],
1952
+ flatRows: [],
1953
+ rowsById: {}
1954
+ }, R(e.options, "debugTable", "getFilteredSelectedRowModel")), e.getGroupedSelectedRowModel = S(() => [e.getState().rowSelection, e.getSortedRowModel()], (r, t) => Object.keys(r).length ? Re(e, t) : {
1955
+ rows: [],
1956
+ flatRows: [],
1957
+ rowsById: {}
1958
+ }, R(e.options, "debugTable", "getGroupedSelectedRowModel")), e.getIsAllRowsSelected = () => {
1959
+ const r = e.getFilteredRowModel().flatRows, {
1960
+ rowSelection: t
1961
+ } = e.getState();
1962
+ let n = !!(r.length && Object.keys(t).length);
1963
+ return n && r.some((o) => o.getCanSelect() && !t[o.id]) && (n = !1), n;
1964
+ }, e.getIsAllPageRowsSelected = () => {
1965
+ const r = e.getPaginationRowModel().flatRows.filter((o) => o.getCanSelect()), {
1966
+ rowSelection: t
1967
+ } = e.getState();
1968
+ let n = !!r.length;
1969
+ return n && r.some((o) => !t[o.id]) && (n = !1), n;
1970
+ }, e.getIsSomeRowsSelected = () => {
1971
+ var r;
1972
+ const t = Object.keys((r = e.getState().rowSelection) != null ? r : {}).length;
1973
+ return t > 0 && t < e.getFilteredRowModel().flatRows.length;
1974
+ }, e.getIsSomePageRowsSelected = () => {
1975
+ const r = e.getPaginationRowModel().flatRows;
1976
+ return e.getIsAllPageRowsSelected() ? !1 : r.filter((t) => t.getCanSelect()).some((t) => t.getIsSelected() || t.getIsSomeSelected());
1977
+ }, e.getToggleAllRowsSelectedHandler = () => (r) => {
1978
+ e.toggleAllRowsSelected(r.target.checked);
1979
+ }, e.getToggleAllPageRowsSelectedHandler = () => (r) => {
1980
+ e.toggleAllPageRowsSelected(r.target.checked);
1981
+ };
1982
+ },
1983
+ createRow: (e, r) => {
1984
+ e.toggleSelected = (t, n) => {
1985
+ const o = e.getIsSelected();
1986
+ r.setRowSelection((l) => {
1987
+ var s;
1988
+ if (t = typeof t < "u" ? t : !o, e.getCanSelect() && o === t)
1989
+ return l;
1990
+ const i = {
1991
+ ...l
1992
+ };
1993
+ return Ne(i, e.id, t, (s = n == null ? void 0 : n.selectChildren) != null ? s : !0, r), i;
1994
+ });
1995
+ }, e.getIsSelected = () => {
1996
+ const {
1997
+ rowSelection: t
1998
+ } = r.getState();
1999
+ return Le(e, t);
2000
+ }, e.getIsSomeSelected = () => {
2001
+ const {
2002
+ rowSelection: t
2003
+ } = r.getState();
2004
+ return Me(e, t) === "some";
2005
+ }, e.getIsAllSubRowsSelected = () => {
2006
+ const {
2007
+ rowSelection: t
2008
+ } = r.getState();
2009
+ return Me(e, t) === "all";
2010
+ }, e.getCanSelect = () => {
2011
+ var t;
2012
+ return typeof r.options.enableRowSelection == "function" ? r.options.enableRowSelection(e) : (t = r.options.enableRowSelection) != null ? t : !0;
2013
+ }, e.getCanSelectSubRows = () => {
2014
+ var t;
2015
+ return typeof r.options.enableSubRowSelection == "function" ? r.options.enableSubRowSelection(e) : (t = r.options.enableSubRowSelection) != null ? t : !0;
2016
+ }, e.getCanMultiSelect = () => {
2017
+ var t;
2018
+ return typeof r.options.enableMultiRowSelection == "function" ? r.options.enableMultiRowSelection(e) : (t = r.options.enableMultiRowSelection) != null ? t : !0;
2019
+ }, e.getToggleSelectedHandler = () => {
2020
+ const t = e.getCanSelect();
2021
+ return (n) => {
2022
+ var o;
2023
+ t && e.toggleSelected((o = n.target) == null ? void 0 : o.checked);
2024
+ };
2025
+ };
2026
+ }
2027
+ }, Ne = (e, r, t, n, o) => {
2028
+ var l;
2029
+ const s = o.getRow(r, !0);
2030
+ t ? (s.getCanMultiSelect() || Object.keys(e).forEach((i) => delete e[i]), s.getCanSelect() && (e[r] = !0)) : delete e[r], n && (l = s.subRows) != null && l.length && s.getCanSelectSubRows() && s.subRows.forEach((i) => Ne(e, i.id, t, n, o));
2031
+ };
2032
+ function Re(e, r) {
2033
+ const t = e.getState().rowSelection, n = [], o = {}, l = function(s, i) {
2034
+ return s.map((u) => {
2035
+ var f;
2036
+ const g = Le(u, t);
2037
+ if (g && (n.push(u), o[u.id] = u), (f = u.subRows) != null && f.length && (u = {
2038
+ ...u,
2039
+ subRows: l(u.subRows)
2040
+ }), g)
2041
+ return u;
2042
+ }).filter(Boolean);
2043
+ };
2044
+ return {
2045
+ rows: l(r.rows),
2046
+ flatRows: n,
2047
+ rowsById: o
2048
+ };
2049
+ }
2050
+ function Le(e, r) {
2051
+ var t;
2052
+ return (t = r[e.id]) != null ? t : !1;
2053
+ }
2054
+ function Me(e, r, t) {
2055
+ var n;
2056
+ if (!((n = e.subRows) != null && n.length)) return !1;
2057
+ let o = !0, l = !1;
2058
+ return e.subRows.forEach((s) => {
2059
+ if (!(l && !o) && (s.getCanSelect() && (Le(s, r) ? l = !0 : o = !1), s.subRows && s.subRows.length)) {
2060
+ const i = Me(s, r);
2061
+ i === "all" ? l = !0 : (i === "some" && (l = !0), o = !1);
2062
+ }
2063
+ }), o ? "all" : l ? "some" : !1;
2064
+ }
2065
+ const Ve = /([0-9]+)/gm, In = (e, r, t) => at(Q(e.getValue(t)).toLowerCase(), Q(r.getValue(t)).toLowerCase()), $n = (e, r, t) => at(Q(e.getValue(t)), Q(r.getValue(t))), Nn = (e, r, t) => ze(Q(e.getValue(t)).toLowerCase(), Q(r.getValue(t)).toLowerCase()), Mn = (e, r, t) => ze(Q(e.getValue(t)), Q(r.getValue(t))), Vn = (e, r, t) => {
2066
+ const n = e.getValue(t), o = r.getValue(t);
2067
+ return n > o ? 1 : n < o ? -1 : 0;
2068
+ }, Pn = (e, r, t) => ze(e.getValue(t), r.getValue(t));
2069
+ function ze(e, r) {
2070
+ return e === r ? 0 : e > r ? 1 : -1;
2071
+ }
2072
+ function Q(e) {
2073
+ return typeof e == "number" ? isNaN(e) || e === 1 / 0 || e === -1 / 0 ? "" : String(e) : typeof e == "string" ? e : "";
2074
+ }
2075
+ function at(e, r) {
2076
+ const t = e.split(Ve).filter(Boolean), n = r.split(Ve).filter(Boolean);
2077
+ for (; t.length && n.length; ) {
2078
+ const o = t.shift(), l = n.shift(), s = parseInt(o, 10), i = parseInt(l, 10), u = [s, i].sort();
2079
+ if (isNaN(u[0])) {
2080
+ if (o > l)
2081
+ return 1;
2082
+ if (l > o)
2083
+ return -1;
2084
+ continue;
2085
+ }
2086
+ if (isNaN(u[1]))
2087
+ return isNaN(s) ? -1 : 1;
2088
+ if (s > i)
2089
+ return 1;
2090
+ if (i > s)
2091
+ return -1;
2092
+ }
2093
+ return t.length - n.length;
2094
+ }
2095
+ const oe = {
2096
+ alphanumeric: In,
2097
+ alphanumericCaseSensitive: $n,
2098
+ text: Nn,
2099
+ textCaseSensitive: Mn,
2100
+ datetime: Vn,
2101
+ basic: Pn
2102
+ }, kn = {
2103
+ getInitialState: (e) => ({
2104
+ sorting: [],
2105
+ ...e
2106
+ }),
2107
+ getDefaultColumnDef: () => ({
2108
+ sortingFn: "auto",
2109
+ sortUndefined: 1
2110
+ }),
2111
+ getDefaultOptions: (e) => ({
2112
+ onSortingChange: L("sorting", e),
2113
+ isMultiSortEvent: (r) => r.shiftKey
2114
+ }),
2115
+ createColumn: (e, r) => {
2116
+ e.getAutoSortingFn = () => {
2117
+ const t = r.getFilteredRowModel().flatRows.slice(10);
2118
+ let n = !1;
2119
+ for (const o of t) {
2120
+ const l = o == null ? void 0 : o.getValue(e.id);
2121
+ if (Object.prototype.toString.call(l) === "[object Date]")
2122
+ return oe.datetime;
2123
+ if (typeof l == "string" && (n = !0, l.split(Ve).length > 1))
2124
+ return oe.alphanumeric;
2125
+ }
2126
+ return n ? oe.text : oe.basic;
2127
+ }, e.getAutoSortDir = () => {
2128
+ const t = r.getFilteredRowModel().flatRows[0];
2129
+ return typeof (t == null ? void 0 : t.getValue(e.id)) == "string" ? "asc" : "desc";
2130
+ }, e.getSortingFn = () => {
2131
+ var t, n;
2132
+ if (!e)
2133
+ throw new Error();
2134
+ return ge(e.columnDef.sortingFn) ? e.columnDef.sortingFn : e.columnDef.sortingFn === "auto" ? e.getAutoSortingFn() : (t = (n = r.options.sortingFns) == null ? void 0 : n[e.columnDef.sortingFn]) != null ? t : oe[e.columnDef.sortingFn];
2135
+ }, e.toggleSorting = (t, n) => {
2136
+ const o = e.getNextSortingOrder(), l = typeof t < "u" && t !== null;
2137
+ r.setSorting((s) => {
2138
+ const i = s == null ? void 0 : s.find((a) => a.id === e.id), u = s == null ? void 0 : s.findIndex((a) => a.id === e.id);
2139
+ let f = [], g, p = l ? t : o === "desc";
2140
+ if (s != null && s.length && e.getCanMultiSort() && n ? i ? g = "toggle" : g = "add" : s != null && s.length && u !== s.length - 1 ? g = "replace" : i ? g = "toggle" : g = "replace", g === "toggle" && (l || o || (g = "remove")), g === "add") {
2141
+ var d;
2142
+ f = [...s, {
2143
+ id: e.id,
2144
+ desc: p
2145
+ }], f.splice(0, f.length - ((d = r.options.maxMultiSortColCount) != null ? d : Number.MAX_SAFE_INTEGER));
2146
+ } else g === "toggle" ? f = s.map((a) => a.id === e.id ? {
2147
+ ...a,
2148
+ desc: p
2149
+ } : a) : g === "remove" ? f = s.filter((a) => a.id !== e.id) : f = [{
2150
+ id: e.id,
2151
+ desc: p
2152
+ }];
2153
+ return f;
2154
+ });
2155
+ }, e.getFirstSortDir = () => {
2156
+ var t, n;
2157
+ return ((t = (n = e.columnDef.sortDescFirst) != null ? n : r.options.sortDescFirst) != null ? t : e.getAutoSortDir() === "desc") ? "desc" : "asc";
2158
+ }, e.getNextSortingOrder = (t) => {
2159
+ var n, o;
2160
+ const l = e.getFirstSortDir(), s = e.getIsSorted();
2161
+ return s ? s !== l && ((n = r.options.enableSortingRemoval) == null || n) && // If enableSortRemove, enable in general
2162
+ (!(t && (o = r.options.enableMultiRemove) != null) || o) ? !1 : s === "desc" ? "asc" : "desc" : l;
2163
+ }, e.getCanSort = () => {
2164
+ var t, n;
2165
+ return ((t = e.columnDef.enableSorting) != null ? t : !0) && ((n = r.options.enableSorting) != null ? n : !0) && !!e.accessorFn;
2166
+ }, e.getCanMultiSort = () => {
2167
+ var t, n;
2168
+ return (t = (n = e.columnDef.enableMultiSort) != null ? n : r.options.enableMultiSort) != null ? t : !!e.accessorFn;
2169
+ }, e.getIsSorted = () => {
2170
+ var t;
2171
+ const n = (t = r.getState().sorting) == null ? void 0 : t.find((o) => o.id === e.id);
2172
+ return n ? n.desc ? "desc" : "asc" : !1;
2173
+ }, e.getSortIndex = () => {
2174
+ var t, n;
2175
+ return (t = (n = r.getState().sorting) == null ? void 0 : n.findIndex((o) => o.id === e.id)) != null ? t : -1;
2176
+ }, e.clearSorting = () => {
2177
+ r.setSorting((t) => t != null && t.length ? t.filter((n) => n.id !== e.id) : []);
2178
+ }, e.getToggleSortingHandler = () => {
2179
+ const t = e.getCanSort();
2180
+ return (n) => {
2181
+ t && (n.persist == null || n.persist(), e.toggleSorting == null || e.toggleSorting(void 0, e.getCanMultiSort() ? r.options.isMultiSortEvent == null ? void 0 : r.options.isMultiSortEvent(n) : !1));
2182
+ };
2183
+ };
2184
+ },
2185
+ createTable: (e) => {
2186
+ e.setSorting = (r) => e.options.onSortingChange == null ? void 0 : e.options.onSortingChange(r), e.resetSorting = (r) => {
2187
+ var t, n;
2188
+ e.setSorting(r ? [] : (t = (n = e.initialState) == null ? void 0 : n.sorting) != null ? t : []);
2189
+ }, e.getPreSortedRowModel = () => e.getGroupedRowModel(), e.getSortedRowModel = () => (!e._getSortedRowModel && e.options.getSortedRowModel && (e._getSortedRowModel = e.options.getSortedRowModel(e)), e.options.manualSorting || !e._getSortedRowModel ? e.getPreSortedRowModel() : e._getSortedRowModel());
2190
+ }
2191
+ }, En = [
2192
+ Zt,
2193
+ Cn,
2194
+ pn,
2195
+ mn,
2196
+ en,
2197
+ tn,
2198
+ yn,
2199
+ //depends on ColumnFaceting
2200
+ Sn,
2201
+ //depends on ColumnFiltering
2202
+ kn,
2203
+ cn,
2204
+ //depends on RowSorting
2205
+ Rn,
2206
+ xn,
2207
+ _n,
2208
+ Fn,
2209
+ vn
2210
+ ];
2211
+ function bn(e) {
2212
+ var r, t;
2213
+ process.env.NODE_ENV !== "production" && (e.debugAll || e.debugTable) && console.info("Creating Table Instance...");
2214
+ const n = [...En, ...(r = e._features) != null ? r : []];
2215
+ let o = {
2216
+ _features: n
2217
+ };
2218
+ const l = o._features.reduce((d, a) => Object.assign(d, a.getDefaultOptions == null ? void 0 : a.getDefaultOptions(o)), {}), s = (d) => o.options.mergeOptions ? o.options.mergeOptions(l, d) : {
2219
+ ...l,
2220
+ ...d
2221
+ };
2222
+ let u = {
2223
+ ...{},
2224
+ ...(t = e.initialState) != null ? t : {}
2225
+ };
2226
+ o._features.forEach((d) => {
2227
+ var a;
2228
+ u = (a = d.getInitialState == null ? void 0 : d.getInitialState(u)) != null ? a : u;
2229
+ });
2230
+ const f = [];
2231
+ let g = !1;
2232
+ const p = {
2233
+ _features: n,
2234
+ options: {
2235
+ ...l,
2236
+ ...e
2237
+ },
2238
+ initialState: u,
2239
+ _queue: (d) => {
2240
+ f.push(d), g || (g = !0, Promise.resolve().then(() => {
2241
+ for (; f.length; )
2242
+ f.shift()();
2243
+ g = !1;
2244
+ }).catch((a) => setTimeout(() => {
2245
+ throw a;
2246
+ })));
2247
+ },
2248
+ reset: () => {
2249
+ o.setState(o.initialState);
2250
+ },
2251
+ setOptions: (d) => {
2252
+ const a = X(d, o.options);
2253
+ o.options = s(a);
2254
+ },
2255
+ getState: () => o.options.state,
2256
+ setState: (d) => {
2257
+ o.options.onStateChange == null || o.options.onStateChange(d);
2258
+ },
2259
+ _getRowId: (d, a, m) => {
2260
+ var h;
2261
+ return (h = o.options.getRowId == null ? void 0 : o.options.getRowId(d, a, m)) != null ? h : `${m ? [m.id, a].join(".") : a}`;
2262
+ },
2263
+ getCoreRowModel: () => (o._getCoreRowModel || (o._getCoreRowModel = o.options.getCoreRowModel(o)), o._getCoreRowModel()),
2264
+ // The final calls start at the bottom of the model,
2265
+ // expanded rows, which then work their way up
2266
+ getRowModel: () => o.getPaginationRowModel(),
2267
+ //in next version, we should just pass in the row model as the optional 2nd arg
2268
+ getRow: (d, a) => {
2269
+ let m = (a ? o.getPrePaginationRowModel() : o.getRowModel()).rowsById[d];
2270
+ if (!m && (m = o.getCoreRowModel().rowsById[d], !m))
2271
+ throw process.env.NODE_ENV !== "production" ? new Error(`getRow could not find row with ID: ${d}`) : new Error();
2272
+ return m;
2273
+ },
2274
+ _getDefaultColumnDef: S(() => [o.options.defaultColumn], (d) => {
2275
+ var a;
2276
+ return d = (a = d) != null ? a : {}, {
2277
+ header: (m) => {
2278
+ const h = m.header.column.columnDef;
2279
+ return h.accessorKey ? h.accessorKey : h.accessorFn ? h.id : null;
2280
+ },
2281
+ // footer: props => props.header.column.id,
2282
+ cell: (m) => {
2283
+ var h, C;
2284
+ return (h = (C = m.renderValue()) == null || C.toString == null ? void 0 : C.toString()) != null ? h : null;
2285
+ },
2286
+ ...o._features.reduce((m, h) => Object.assign(m, h.getDefaultColumnDef == null ? void 0 : h.getDefaultColumnDef()), {}),
2287
+ ...d
2288
+ };
2289
+ }, R(e, "debugColumns", "_getDefaultColumnDef")),
2290
+ _getColumnDefs: () => o.options.columns,
2291
+ getAllColumns: S(() => [o._getColumnDefs()], (d) => {
2292
+ const a = function(m, h, C) {
2293
+ return C === void 0 && (C = 0), m.map((v) => {
2294
+ const y = Jt(o, v, C, h), x = v;
2295
+ return y.columns = x.columns ? a(x.columns, y, C + 1) : [], y;
2296
+ });
2297
+ };
2298
+ return a(d);
2299
+ }, R(e, "debugColumns", "getAllColumns")),
2300
+ getAllFlatColumns: S(() => [o.getAllColumns()], (d) => d.flatMap((a) => a.getFlatColumns()), R(e, "debugColumns", "getAllFlatColumns")),
2301
+ _getAllFlatColumnsById: S(() => [o.getAllFlatColumns()], (d) => d.reduce((a, m) => (a[m.id] = m, a), {}), R(e, "debugColumns", "getAllFlatColumnsById")),
2302
+ getAllLeafColumns: S(() => [o.getAllColumns(), o._getOrderColumnsFn()], (d, a) => {
2303
+ let m = d.flatMap((h) => h.getLeafColumns());
2304
+ return a(m);
2305
+ }, R(e, "debugColumns", "getAllLeafColumns")),
2306
+ getColumn: (d) => {
2307
+ const a = o._getAllFlatColumnsById()[d];
2308
+ return process.env.NODE_ENV !== "production" && !a && console.error(`[Table] Column with id '${d}' does not exist.`), a;
2309
+ }
2310
+ };
2311
+ Object.assign(o, p);
2312
+ for (let d = 0; d < o._features.length; d++) {
2313
+ const a = o._features[d];
2314
+ a == null || a.createTable == null || a.createTable(o);
2315
+ }
2316
+ return o;
2317
+ }
2318
+ function Dn() {
2319
+ return (e) => S(() => [e.options.data], (r) => {
2320
+ const t = {
2321
+ rows: [],
2322
+ flatRows: [],
2323
+ rowsById: {}
2324
+ }, n = function(o, l, s) {
2325
+ l === void 0 && (l = 0);
2326
+ const i = [];
2327
+ for (let f = 0; f < o.length; f++) {
2328
+ const g = be(e, e._getRowId(o[f], f, s), o[f], f, l, void 0, s == null ? void 0 : s.id);
2329
+ if (t.flatRows.push(g), t.rowsById[g.id] = g, i.push(g), e.options.getSubRows) {
2330
+ var u;
2331
+ g.originalSubRows = e.options.getSubRows(o[f], f), (u = g.originalSubRows) != null && u.length && (g.subRows = n(g.originalSubRows, l + 1, g));
2332
+ }
2333
+ }
2334
+ return i;
2335
+ };
2336
+ return t.rows = n(r), t;
2337
+ }, R(e.options, "debugTable", "getRowModel", () => e._autoResetPageIndex()));
2338
+ }
2339
+ function Ln(e) {
2340
+ const r = [], t = (n) => {
2341
+ var o;
2342
+ r.push(n), (o = n.subRows) != null && o.length && n.getIsExpanded() && n.subRows.forEach(t);
2343
+ };
2344
+ return e.rows.forEach(t), {
2345
+ rows: r,
2346
+ flatRows: e.flatRows,
2347
+ rowsById: e.rowsById
2348
+ };
2349
+ }
2350
+ function zn(e, r, t) {
2351
+ return t.options.filterFromLeafRows ? Hn(e, r, t) : An(e, r, t);
2352
+ }
2353
+ function Hn(e, r, t) {
2354
+ var n;
2355
+ const o = [], l = {}, s = (n = t.options.maxLeafRowFilterDepth) != null ? n : 100, i = function(u, f) {
2356
+ f === void 0 && (f = 0);
2357
+ const g = [];
2358
+ for (let d = 0; d < u.length; d++) {
2359
+ var p;
2360
+ let a = u[d];
2361
+ const m = be(t, a.id, a.original, a.index, a.depth, void 0, a.parentId);
2362
+ if (m.columnFilters = a.columnFilters, (p = a.subRows) != null && p.length && f < s) {
2363
+ if (m.subRows = i(a.subRows, f + 1), a = m, r(a) && !m.subRows.length) {
2364
+ g.push(a), l[a.id] = a, o.push(a);
2365
+ continue;
2366
+ }
2367
+ if (r(a) || m.subRows.length) {
2368
+ g.push(a), l[a.id] = a, o.push(a);
2369
+ continue;
2370
+ }
2371
+ } else
2372
+ a = m, r(a) && (g.push(a), l[a.id] = a, o.push(a));
2373
+ }
2374
+ return g;
2375
+ };
2376
+ return {
2377
+ rows: i(e),
2378
+ flatRows: o,
2379
+ rowsById: l
2380
+ };
2381
+ }
2382
+ function An(e, r, t) {
2383
+ var n;
2384
+ const o = [], l = {}, s = (n = t.options.maxLeafRowFilterDepth) != null ? n : 100, i = function(u, f) {
2385
+ f === void 0 && (f = 0);
2386
+ const g = [];
2387
+ for (let d = 0; d < u.length; d++) {
2388
+ let a = u[d];
2389
+ if (r(a)) {
2390
+ var p;
2391
+ if ((p = a.subRows) != null && p.length && f < s) {
2392
+ const h = be(t, a.id, a.original, a.index, a.depth, void 0, a.parentId);
2393
+ h.subRows = i(a.subRows, f + 1), a = h;
2394
+ }
2395
+ g.push(a), o.push(a), l[a.id] = a;
2396
+ }
2397
+ }
2398
+ return g;
2399
+ };
2400
+ return {
2401
+ rows: i(e),
2402
+ flatRows: o,
2403
+ rowsById: l
2404
+ };
2405
+ }
2406
+ function Gn() {
2407
+ return (e) => S(() => [e.getPreFilteredRowModel(), e.getState().columnFilters, e.getState().globalFilter], (r, t, n) => {
2408
+ if (!r.rows.length || !(t != null && t.length) && !n) {
2409
+ for (let d = 0; d < r.flatRows.length; d++)
2410
+ r.flatRows[d].columnFilters = {}, r.flatRows[d].columnFiltersMeta = {};
2411
+ return r;
2412
+ }
2413
+ const o = [], l = [];
2414
+ (t ?? []).forEach((d) => {
2415
+ var a;
2416
+ const m = e.getColumn(d.id);
2417
+ if (!m)
2418
+ return;
2419
+ const h = m.getFilterFn();
2420
+ if (!h) {
2421
+ process.env.NODE_ENV !== "production" && console.warn(`Could not find a valid 'column.filterFn' for column with the ID: ${m.id}.`);
2422
+ return;
2423
+ }
2424
+ o.push({
2425
+ id: d.id,
2426
+ filterFn: h,
2427
+ resolvedValue: (a = h.resolveFilterValue == null ? void 0 : h.resolveFilterValue(d.value)) != null ? a : d.value
2428
+ });
2429
+ });
2430
+ const s = (t ?? []).map((d) => d.id), i = e.getGlobalFilterFn(), u = e.getAllLeafColumns().filter((d) => d.getCanGlobalFilter());
2431
+ n && i && u.length && (s.push("__global__"), u.forEach((d) => {
2432
+ var a;
2433
+ l.push({
2434
+ id: d.id,
2435
+ filterFn: i,
2436
+ resolvedValue: (a = i.resolveFilterValue == null ? void 0 : i.resolveFilterValue(n)) != null ? a : n
2437
+ });
2438
+ }));
2439
+ let f, g;
2440
+ for (let d = 0; d < r.flatRows.length; d++) {
2441
+ const a = r.flatRows[d];
2442
+ if (a.columnFilters = {}, o.length)
2443
+ for (let m = 0; m < o.length; m++) {
2444
+ f = o[m];
2445
+ const h = f.id;
2446
+ a.columnFilters[h] = f.filterFn(a, h, f.resolvedValue, (C) => {
2447
+ a.columnFiltersMeta[h] = C;
2448
+ });
2449
+ }
2450
+ if (l.length) {
2451
+ for (let m = 0; m < l.length; m++) {
2452
+ g = l[m];
2453
+ const h = g.id;
2454
+ if (g.filterFn(a, h, g.resolvedValue, (C) => {
2455
+ a.columnFiltersMeta[h] = C;
2456
+ })) {
2457
+ a.columnFilters.__global__ = !0;
2458
+ break;
2459
+ }
2460
+ }
2461
+ a.columnFilters.__global__ !== !0 && (a.columnFilters.__global__ = !1);
2462
+ }
2463
+ }
2464
+ const p = (d) => {
2465
+ for (let a = 0; a < s.length; a++)
2466
+ if (d.columnFilters[s[a]] === !1)
2467
+ return !1;
2468
+ return !0;
2469
+ };
2470
+ return zn(r.rows, p, e);
2471
+ }, R(e.options, "debugTable", "getFilteredRowModel", () => e._autoResetPageIndex()));
2472
+ }
2473
+ function On(e) {
2474
+ return (r) => S(() => [r.getState().pagination, r.getPrePaginationRowModel(), r.options.paginateExpandedRows ? void 0 : r.getState().expanded], (t, n) => {
2475
+ if (!n.rows.length)
2476
+ return n;
2477
+ const {
2478
+ pageSize: o,
2479
+ pageIndex: l
2480
+ } = t;
2481
+ let {
2482
+ rows: s,
2483
+ flatRows: i,
2484
+ rowsById: u
2485
+ } = n;
2486
+ const f = o * l, g = f + o;
2487
+ s = s.slice(f, g);
2488
+ let p;
2489
+ r.options.paginateExpandedRows ? p = {
2490
+ rows: s,
2491
+ flatRows: i,
2492
+ rowsById: u
2493
+ } : p = Ln({
2494
+ rows: s,
2495
+ flatRows: i,
2496
+ rowsById: u
2497
+ }), p.flatRows = [];
2498
+ const d = (a) => {
2499
+ p.flatRows.push(a), a.subRows.length && a.subRows.forEach(d);
2500
+ };
2501
+ return p.rows.forEach(d), p;
2502
+ }, R(r.options, "debugTable", "getPaginationRowModel"));
2503
+ }
2504
+ function Tn() {
2505
+ return (e) => S(() => [e.getState().sorting, e.getPreSortedRowModel()], (r, t) => {
2506
+ if (!t.rows.length || !(r != null && r.length))
2507
+ return t;
2508
+ const n = e.getState().sorting, o = [], l = n.filter((u) => {
2509
+ var f;
2510
+ return (f = e.getColumn(u.id)) == null ? void 0 : f.getCanSort();
2511
+ }), s = {};
2512
+ l.forEach((u) => {
2513
+ const f = e.getColumn(u.id);
2514
+ f && (s[u.id] = {
2515
+ sortUndefined: f.columnDef.sortUndefined,
2516
+ invertSorting: f.columnDef.invertSorting,
2517
+ sortingFn: f.getSortingFn()
2518
+ });
2519
+ });
2520
+ const i = (u) => {
2521
+ const f = u.map((g) => ({
2522
+ ...g
2523
+ }));
2524
+ return f.sort((g, p) => {
2525
+ for (let a = 0; a < l.length; a += 1) {
2526
+ var d;
2527
+ const m = l[a], h = s[m.id], C = h.sortUndefined, v = (d = m == null ? void 0 : m.desc) != null ? d : !1;
2528
+ let y = 0;
2529
+ if (C) {
2530
+ const x = g.getValue(m.id), $ = p.getValue(m.id), F = x === void 0, P = $ === void 0;
2531
+ if (F || P) {
2532
+ if (C === "first") return F ? -1 : 1;
2533
+ if (C === "last") return F ? 1 : -1;
2534
+ y = F && P ? 0 : F ? C : -C;
2535
+ }
2536
+ }
2537
+ if (y === 0 && (y = h.sortingFn(g, p, m.id)), y !== 0)
2538
+ return v && (y *= -1), h.invertSorting && (y *= -1), y;
2539
+ }
2540
+ return g.index - p.index;
2541
+ }), f.forEach((g) => {
2542
+ var p;
2543
+ o.push(g), (p = g.subRows) != null && p.length && (g.subRows = i(g.subRows));
2544
+ }), f;
2545
+ };
2546
+ return {
2547
+ rows: i(t.rows),
2548
+ flatRows: o,
2549
+ rowsById: t.rowsById
2550
+ };
2551
+ }, R(e.options, "debugTable", "getSortedRowModel", () => e._autoResetPageIndex()));
2552
+ }
2553
+ /**
2554
+ * react-table
2555
+ *
2556
+ * Copyright (c) TanStack
2557
+ *
2558
+ * This source code is licensed under the MIT license found in the
2559
+ * LICENSE.md file in the root directory of this source tree.
2560
+ *
2561
+ * @license MIT
2562
+ */
2563
+ function Qe(e, r) {
2564
+ return e ? Bn(e) ? /* @__PURE__ */ _e.createElement(e, r) : e : null;
2565
+ }
2566
+ function Bn(e) {
2567
+ return Kn(e) || typeof e == "function" || qn(e);
2568
+ }
2569
+ function Kn(e) {
2570
+ return typeof e == "function" && (() => {
2571
+ const r = Object.getPrototypeOf(e);
2572
+ return r.prototype && r.prototype.isReactComponent;
2573
+ })();
2574
+ }
2575
+ function qn(e) {
2576
+ return typeof e == "object" && typeof e.$$typeof == "symbol" && ["react.memo", "react.forward_ref"].includes(e.$$typeof.description);
2577
+ }
2578
+ function jn(e) {
2579
+ const r = {
2580
+ state: {},
2581
+ // Dummy state
2582
+ onStateChange: () => {
2583
+ },
2584
+ // noop
2585
+ renderFallbackValue: null,
2586
+ ...e
2587
+ }, [t] = _e.useState(() => ({
2588
+ current: bn(r)
2589
+ })), [n, o] = _e.useState(() => t.current.initialState);
2590
+ return t.current.setOptions((l) => ({
2591
+ ...l,
2592
+ ...e,
2593
+ state: {
2594
+ ...n,
2595
+ ...e.state
2596
+ },
2597
+ // Similarly, we'll maintain both our internal state and any user-provided
2598
+ // state.
2599
+ onStateChange: (s) => {
2600
+ o(s), e.onStateChange == null || e.onStateChange(s);
2601
+ }
2602
+ })), t.current;
2603
+ }
2604
+ const Ye = ({
2605
+ editable: e = !0,
2606
+ deletable: r = !0,
2607
+ pageSize: t = 25,
2608
+ onCellEdit: n,
2609
+ onRowDelete: o
2610
+ }) => {
2611
+ const {
2612
+ rows: l,
2613
+ schema: s,
2614
+ mappings: i,
2615
+ errorsByRow: u,
2616
+ editingCell: f,
2617
+ startEditing: g,
2618
+ stopEditing: p,
2619
+ updateCell: d,
2620
+ deleteRow: a
2621
+ } = te(), [m, h] = j([]), [C, v] = j(""), [y, x] = j(""), $ = Be(() => i.filter((_) => _.targetKey !== null).map((_) => {
2622
+ const I = s == null ? void 0 : s.columns.find((M) => M.key === _.targetKey);
2623
+ return {
2624
+ sourceColumn: _.sourceColumn,
2625
+ targetKey: _.targetKey,
2626
+ label: (I == null ? void 0 : I.label) || _.targetKey,
2627
+ type: (I == null ? void 0 : I.type) || "string"
2628
+ };
2629
+ }), [i, s]), F = Pe(
2630
+ (_, I) => {
2631
+ const M = u.get(_);
2632
+ return M == null ? void 0 : M.find((H) => H.columnKey === I);
2633
+ },
2634
+ [u]
2635
+ ), P = (_, I, M) => {
2636
+ x(M), g(_, I);
2637
+ }, Y = () => {
2638
+ f && (d(f.rowIndex, f.columnKey, y), n == null || n(f.rowIndex, f.columnKey, y)), p();
2639
+ }, k = () => {
2640
+ x(""), p();
2641
+ }, G = (_) => {
2642
+ a(_), o == null || o(_);
2643
+ }, K = Xt(), D = Be(
2644
+ () => [
2645
+ K.accessor("rowIndex", {
2646
+ header: "#",
2647
+ size: 60,
2648
+ cell: (_) => /* @__PURE__ */ c("span", { className: "ff-font-mono ff-text-xs", style: { color: "var(--ff-text-muted)" }, children: _.getValue() + 1 })
2649
+ }),
2650
+ ...$.map(
2651
+ (_) => K.accessor((I) => I.data[_.targetKey] || I.data[_.sourceColumn], {
2652
+ id: _.targetKey,
2653
+ header: _.label,
2654
+ cell: (I) => {
2655
+ const M = I.row.original.rowIndex, H = String(I.getValue() ?? ""), b = F(M, _.targetKey);
2656
+ return (f == null ? void 0 : f.rowIndex) === M && (f == null ? void 0 : f.columnKey) === _.targetKey ? /* @__PURE__ */ w("div", { className: "ff-flex ff-items-center ff-gap-2 ff-min-w-[280px]", children: [
2657
+ /* @__PURE__ */ c(
2658
+ "input",
2659
+ {
2660
+ type: "text",
2661
+ value: y,
2662
+ onChange: (J) => x(J.target.value),
2663
+ onKeyDown: (J) => {
2664
+ J.key === "Enter" && Y(), J.key === "Escape" && k();
2665
+ },
2666
+ className: "ff-input ff-py-2 ff-px-3 ff-text-sm ff-flex-1 ff-min-w-[160px]",
2667
+ autoFocus: !0
2668
+ }
2669
+ ),
2670
+ /* @__PURE__ */ c(
2671
+ "button",
2672
+ {
2673
+ onClick: Y,
2674
+ className: "ff-btn ff-btn-primary ff-btn-sm ff-flex-shrink-0",
2675
+ children: "Save"
2676
+ }
2677
+ ),
2678
+ /* @__PURE__ */ c(
2679
+ "button",
2680
+ {
2681
+ onClick: k,
2682
+ className: "ff-btn ff-btn-secondary ff-btn-sm ff-flex-shrink-0",
2683
+ children: "Cancel"
2684
+ }
2685
+ )
2686
+ ] }) : /* @__PURE__ */ w(
2687
+ "div",
2688
+ {
2689
+ className: W(
2690
+ "ff-group ff-flex ff-items-center ff-gap-2",
2691
+ (b == null ? void 0 : b.severity) === "error" && "ff-cell-error",
2692
+ (b == null ? void 0 : b.severity) === "warning" && "ff-cell-warning"
2693
+ ),
2694
+ children: [
2695
+ /* @__PURE__ */ c("span", { className: "ff-flex-1 ff-truncate", children: H || /* @__PURE__ */ c("span", { style: { color: "var(--ff-text-muted)" }, children: "—" }) }),
2696
+ b && /* @__PURE__ */ w("div", { className: "ff-relative ff-group/tooltip", children: [
2697
+ b.severity === "error" ? /* @__PURE__ */ c(ke, { className: "ff-w-4 ff-h-4", style: { color: "var(--ff-error)" } }) : /* @__PURE__ */ c(Fe, { className: "ff-w-4 ff-h-4", style: { color: "var(--ff-warning)" } }),
2698
+ /* @__PURE__ */ w("div", { className: "ff-tooltip ff-bottom-full ff-left-1/2 ff-transform ff--translate-x-1/2 ff-mb-2 ff-w-48 group-hover/tooltip:ff-tooltip-visible", children: [
2699
+ b.message,
2700
+ b.suggestion && /* @__PURE__ */ c("span", { className: "ff-block ff-mt-1", style: { color: "var(--ff-text-muted)" }, children: b.suggestion })
2701
+ ] })
2702
+ ] }),
2703
+ e && /* @__PURE__ */ c(
2704
+ "button",
2705
+ {
2706
+ onClick: () => P(M, _.targetKey, H),
2707
+ className: "ff-opacity-0 group-hover:ff-opacity-100 ff-p-1 ff-rounded ff-transition-opacity ff-edit-btn",
2708
+ children: /* @__PURE__ */ c(Gt, { className: "ff-w-3 ff-h-3" })
2709
+ }
2710
+ )
2711
+ ]
2712
+ }
2713
+ );
2714
+ }
2715
+ })
2716
+ ),
2717
+ // Actions column (delete)
2718
+ ...r ? [
2719
+ K.display({
2720
+ id: "actions",
2721
+ header: "",
2722
+ size: 50,
2723
+ cell: (_) => {
2724
+ const I = _.row.original.rowIndex;
2725
+ return /* @__PURE__ */ c(
2726
+ "button",
2727
+ {
2728
+ onClick: () => G(I),
2729
+ title: "Delete row",
2730
+ style: {
2731
+ display: "flex",
2732
+ alignItems: "center",
2733
+ justifyContent: "center",
2734
+ padding: "6px",
2735
+ borderRadius: "6px",
2736
+ cursor: "pointer",
2737
+ color: "#8e8d89",
2738
+ background: "transparent",
2739
+ border: "none",
2740
+ transition: "color 0.15s, background-color 0.15s"
2741
+ },
2742
+ onMouseEnter: (M) => {
2743
+ M.currentTarget.style.color = "#d43338", M.currentTarget.style.backgroundColor = "#fcdede";
2744
+ },
2745
+ onMouseLeave: (M) => {
2746
+ M.currentTarget.style.color = "#8e8d89", M.currentTarget.style.backgroundColor = "transparent";
2747
+ },
2748
+ children: /* @__PURE__ */ c(Kt, { style: { width: "16px", height: "16px", display: "block" } })
2749
+ }
2750
+ );
2751
+ }
2752
+ })
2753
+ ] : []
2754
+ ],
2755
+ [$, f, y, e, r, F, K]
2756
+ ), z = jn({
2757
+ data: l,
2758
+ columns: D,
2759
+ state: {
2760
+ sorting: m,
2761
+ globalFilter: C
2762
+ },
2763
+ onSortingChange: h,
2764
+ onGlobalFilterChange: v,
2765
+ getCoreRowModel: Dn(),
2766
+ getPaginationRowModel: On(),
2767
+ getSortedRowModel: Tn(),
2768
+ getFilteredRowModel: Gn(),
2769
+ initialState: {
2770
+ pagination: {
2771
+ pageSize: t
2772
+ }
2773
+ }
2774
+ });
2775
+ return /* @__PURE__ */ w("div", { className: "ff-space-y-4", children: [
2776
+ /* @__PURE__ */ w("div", { className: "ff-flex ff-items-center ff-justify-between", children: [
2777
+ /* @__PURE__ */ c(
2778
+ "input",
2779
+ {
2780
+ type: "text",
2781
+ value: C,
2782
+ onChange: (_) => v(_.target.value),
2783
+ placeholder: "Search all columns...",
2784
+ className: "ff-input ff-max-w-xs"
2785
+ }
2786
+ ),
2787
+ /* @__PURE__ */ w("div", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: [
2788
+ z.getFilteredRowModel().rows.length,
2789
+ " rows"
2790
+ ] })
2791
+ ] }),
2792
+ /* @__PURE__ */ c("div", { className: "ff-table-container ff-max-h-[500px]", children: /* @__PURE__ */ w("table", { className: "ff-table", children: [
2793
+ /* @__PURE__ */ c("thead", { children: z.getHeaderGroups().map((_) => /* @__PURE__ */ c("tr", { children: _.headers.map((I) => /* @__PURE__ */ c(
2794
+ "th",
2795
+ {
2796
+ style: { width: I.getSize() },
2797
+ onClick: I.column.getToggleSortingHandler(),
2798
+ className: W(
2799
+ I.column.getCanSort() && "ff-cursor-pointer ff-select-none"
2800
+ ),
2801
+ children: /* @__PURE__ */ w("div", { className: "ff-flex ff-items-center ff-gap-1", children: [
2802
+ Qe(I.column.columnDef.header, I.getContext()),
2803
+ I.column.getIsSorted() && /* @__PURE__ */ c("span", { children: I.column.getIsSorted() === "asc" ? "↑" : "↓" })
2804
+ ] })
2805
+ },
2806
+ I.id
2807
+ )) }, _.id)) }),
2808
+ /* @__PURE__ */ c("tbody", { children: z.getRowModel().rows.map((_) => {
2809
+ const I = u.has(_.original.rowIndex);
2810
+ return /* @__PURE__ */ c(
2811
+ "tr",
2812
+ {
2813
+ className: W(I && "ff-row-error"),
2814
+ children: _.getVisibleCells().map((M) => /* @__PURE__ */ c("td", { children: Qe(M.column.columnDef.cell, M.getContext()) }, M.id))
2815
+ },
2816
+ _.id
2817
+ );
2818
+ }) })
2819
+ ] }) }),
2820
+ /* @__PURE__ */ w("div", { className: "ff-flex ff-items-center ff-justify-between ff-px-2", children: [
2821
+ /* @__PURE__ */ w("div", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: [
2822
+ "Page ",
2823
+ z.getState().pagination.pageIndex + 1,
2824
+ " of ",
2825
+ z.getPageCount()
2826
+ ] }),
2827
+ /* @__PURE__ */ w("div", { className: "ff-flex ff-items-center ff-gap-2", children: [
2828
+ /* @__PURE__ */ w(
2829
+ "button",
2830
+ {
2831
+ onClick: () => z.previousPage(),
2832
+ disabled: !z.getCanPreviousPage(),
2833
+ className: "ff-btn ff-btn-secondary ff-btn-sm",
2834
+ children: [
2835
+ /* @__PURE__ */ c(Nt, { className: "ff-w-4 ff-h-4" }),
2836
+ "Previous"
2837
+ ]
2838
+ }
2839
+ ),
2840
+ /* @__PURE__ */ w(
2841
+ "button",
2842
+ {
2843
+ onClick: () => z.nextPage(),
2844
+ disabled: !z.getCanNextPage(),
2845
+ className: "ff-btn ff-btn-secondary ff-btn-sm",
2846
+ children: [
2847
+ "Next",
2848
+ /* @__PURE__ */ c(yt, { className: "ff-w-4 ff-h-4" })
2849
+ ]
2850
+ }
2851
+ )
2852
+ ] })
2853
+ ] })
2854
+ ] });
2855
+ }, Je = ({
2856
+ showDetails: e = !0
2857
+ }) => {
2858
+ const { validationResults: r } = te();
2859
+ if (!r)
2860
+ return null;
2861
+ const { isValid: t, totalRows: n, validRows: o, errorCount: l, warningCount: s, infoCount: i, summary: u } = r, f = Math.round(o / n * 100);
2862
+ return /* @__PURE__ */ w("div", { className: "ff-space-y-4", children: [
2863
+ /* @__PURE__ */ w(
2864
+ "div",
2865
+ {
2866
+ className: "ff-flex ff-items-center ff-gap-4 ff-p-4 ff-rounded-lg ff-border",
2867
+ style: {
2868
+ backgroundColor: t ? "var(--ff-success-light)" : "var(--ff-error-light)",
2869
+ borderColor: t ? "var(--ff-success)" : "var(--ff-error)"
2870
+ },
2871
+ children: [
2872
+ t ? /* @__PURE__ */ c(Ee, { className: "ff-w-8 ff-h-8", style: { color: "var(--ff-success)" } }) : /* @__PURE__ */ c(qe, { className: "ff-w-8 ff-h-8", style: { color: "var(--ff-error)" } }),
2873
+ /* @__PURE__ */ w("div", { children: [
2874
+ /* @__PURE__ */ c(
2875
+ "h3",
2876
+ {
2877
+ className: "ff-text-lg ff-font-semibold",
2878
+ style: { color: t ? "var(--ff-success-dark)" : "var(--ff-error-dark)" },
2879
+ children: t ? "Validation Passed" : "Validation Failed"
2880
+ }
2881
+ ),
2882
+ /* @__PURE__ */ w("p", { className: "ff-text-sm", style: { color: t ? "var(--ff-success)" : "var(--ff-error)" }, children: [
2883
+ o,
2884
+ " of ",
2885
+ n,
2886
+ " rows are valid (",
2887
+ f,
2888
+ "%)"
2889
+ ] })
2890
+ ] })
2891
+ ]
2892
+ }
2893
+ ),
2894
+ /* @__PURE__ */ w("div", { className: "ff-grid ff-grid-cols-4 ff-gap-4", children: [
2895
+ /* @__PURE__ */ w("div", { className: "ff-border ff-rounded-lg ff-p-4 ff-text-center", style: { backgroundColor: "var(--ff-bg-primary)", borderColor: "var(--ff-border-light)" }, children: [
2896
+ /* @__PURE__ */ c("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-text-primary)" }, children: n }),
2897
+ /* @__PURE__ */ c("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: "Total Rows" })
2898
+ ] }),
2899
+ /* @__PURE__ */ w("div", { className: "ff-border ff-rounded-lg ff-p-4 ff-text-center", style: { backgroundColor: "var(--ff-success-light)", borderColor: "var(--ff-success)" }, children: [
2900
+ /* @__PURE__ */ c("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-success-dark)" }, children: o }),
2901
+ /* @__PURE__ */ c("p", { className: "ff-text-sm", style: { color: "var(--ff-success)" }, children: "Valid Rows" })
2902
+ ] }),
2903
+ /* @__PURE__ */ w("div", { className: "ff-border ff-rounded-lg ff-p-4 ff-text-center", style: { backgroundColor: "var(--ff-error-light)", borderColor: "var(--ff-error)" }, children: [
2904
+ /* @__PURE__ */ c("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-error-dark)" }, children: l }),
2905
+ /* @__PURE__ */ c("p", { className: "ff-text-sm", style: { color: "var(--ff-error)" }, children: "Errors" })
2906
+ ] }),
2907
+ /* @__PURE__ */ w("div", { className: "ff-border ff-rounded-lg ff-p-4 ff-text-center", style: { backgroundColor: "var(--ff-warning-light)", borderColor: "var(--ff-warning)" }, children: [
2908
+ /* @__PURE__ */ c("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-warning-dark)" }, children: s }),
2909
+ /* @__PURE__ */ c("p", { className: "ff-text-sm", style: { color: "var(--ff-warning)" }, children: "Warnings" })
2910
+ ] })
2911
+ ] }),
2912
+ e && u.byColumn && Object.keys(u.byColumn).length > 0 && /* @__PURE__ */ w("div", { className: "ff-border ff-rounded-xl ff-overflow-hidden", style: { backgroundColor: "var(--ff-bg-primary)", borderColor: "var(--ff-border-light)" }, children: [
2913
+ /* @__PURE__ */ c("div", { className: "ff-px-4 ff-py-3", style: { backgroundColor: "var(--ff-bg-secondary)" }, children: /* @__PURE__ */ c("h4", { className: "ff-font-medium ff-text-sm", style: { color: "var(--ff-text-secondary)" }, children: "Issues by Column" }) }),
2914
+ /* @__PURE__ */ c("div", { children: Object.entries(u.byColumn).filter(([, g]) => g.errorCount > 0 || g.warningCount > 0).map(([g, p], d, a) => /* @__PURE__ */ w(
2915
+ "div",
2916
+ {
2917
+ className: "ff-flex ff-items-center ff-justify-between ff-px-4 ff-py-3",
2918
+ style: {
2919
+ borderTop: d > 0 ? "1px solid var(--ff-border-light)" : void 0
2920
+ },
2921
+ children: [
2922
+ /* @__PURE__ */ w("div", { className: "ff-flex-1 ff-min-w-0 ff-mr-4", children: [
2923
+ /* @__PURE__ */ c("p", { className: "ff-font-medium ff-text-sm", style: { color: "var(--ff-text-primary)" }, children: p.columnKey }),
2924
+ p.mostCommonError && /* @__PURE__ */ c("p", { className: "ff-text-sm ff-truncate", style: { color: "var(--ff-text-muted)" }, children: p.mostCommonError })
2925
+ ] }),
2926
+ /* @__PURE__ */ w("div", { className: "ff-flex ff-items-center ff-gap-2 ff-flex-shrink-0", children: [
2927
+ p.errorCount > 0 && /* @__PURE__ */ w("span", { className: "ff-badge ff-badge-error ff-whitespace-nowrap", children: [
2928
+ /* @__PURE__ */ c(qe, { className: "ff-w-3 ff-h-3 ff-mr-1" }),
2929
+ p.errorCount,
2930
+ " ",
2931
+ p.errorCount === 1 ? "error" : "errors"
2932
+ ] }),
2933
+ p.warningCount > 0 && /* @__PURE__ */ w("span", { className: "ff-badge ff-badge-warning ff-whitespace-nowrap", children: [
2934
+ /* @__PURE__ */ c(Fe, { className: "ff-w-3 ff-h-3 ff-mr-1" }),
2935
+ p.warningCount,
2936
+ " ",
2937
+ p.warningCount === 1 ? "warning" : "warnings"
2938
+ ] })
2939
+ ] })
2940
+ ]
2941
+ },
2942
+ g
2943
+ )) })
2944
+ ] }),
2945
+ e && u.duplicates && u.duplicates.length > 0 && /* @__PURE__ */ c("div", { className: "ff-border ff-rounded-lg ff-p-4", style: { backgroundColor: "var(--ff-warning-light)", borderColor: "var(--ff-warning)" }, children: /* @__PURE__ */ w("div", { className: "ff-flex ff-items-start ff-gap-3", children: [
2946
+ /* @__PURE__ */ c(Fe, { className: "ff-w-5 ff-h-5 ff-flex-shrink-0 ff-mt-0.5", style: { color: "var(--ff-warning)" } }),
2947
+ /* @__PURE__ */ w("div", { children: [
2948
+ /* @__PURE__ */ c("h4", { className: "ff-font-medium", style: { color: "var(--ff-warning-dark)" }, children: "Duplicate Values Found" }),
2949
+ /* @__PURE__ */ w("ul", { className: "ff-mt-2 ff-space-y-1 ff-text-sm", style: { color: "var(--ff-warning-dark)" }, children: [
2950
+ u.duplicates.slice(0, 5).map((g, p) => /* @__PURE__ */ w("li", { children: [
2951
+ /* @__PURE__ */ c("span", { className: "ff-font-mono", children: g.columnKey }),
2952
+ ': "',
2953
+ String(g.value),
2954
+ '" appears',
2955
+ " ",
2956
+ g.rowIndices.length,
2957
+ " times (rows",
2958
+ " ",
2959
+ g.rowIndices.slice(0, 3).map((d) => d + 1).join(", "),
2960
+ g.rowIndices.length > 3 ? "..." : "",
2961
+ ")"
2962
+ ] }, p)),
2963
+ u.duplicates.length > 5 && /* @__PURE__ */ w("li", { style: { color: "var(--ff-warning)" }, children: [
2964
+ "... and ",
2965
+ u.duplicates.length - 5,
2966
+ " more duplicate groups"
2967
+ ] })
2968
+ ] })
2969
+ ] })
2970
+ ] }) })
2971
+ ] });
2972
+ }, xe = ["upload", "mapping", "validation", "complete"], Un = [
2973
+ { key: "upload", label: "Upload", icon: Ze },
2974
+ { key: "mapping", label: "Map Columns", icon: Ht },
2975
+ { key: "validation", label: "Validate", icon: Tt },
2976
+ { key: "review", label: "Review", icon: kt },
2977
+ { key: "complete", label: "Complete", icon: Ee }
2978
+ ], Jn = ({
2979
+ template: e,
2980
+ schema: r,
2981
+ mode: t = "modal",
2982
+ theme: n,
2983
+ useShadowDom: o = !1,
2984
+ onComplete: l,
2985
+ onCancel: s,
2986
+ onError: i
2987
+ }) => {
2988
+ const {
2989
+ step: u,
2990
+ sessionId: f,
2991
+ file: g,
2992
+ mappings: p,
2993
+ validationResults: d,
2994
+ isLoading: a,
2995
+ error: m,
2996
+ setSchema: h,
2997
+ setSessionId: C,
2998
+ setParsedData: v,
2999
+ setMappings: y,
3000
+ setUnmapped: x,
3001
+ setValidationResults: $,
3002
+ setStep: F,
3003
+ nextStep: P,
3004
+ previousStep: Y,
3005
+ setLoading: k,
3006
+ setError: G,
3007
+ reset: K
3008
+ } = te(), [D, z] = j(null), [_, I] = j(null), [M, H] = j(0), [b, U] = j("");
3009
+ Ke(() => {
3010
+ if (I(null), e)
3011
+ if (St(e)) {
3012
+ const N = Rt(e);
3013
+ N ? z(N) : (I(`Failed to load template "${e}"`), i == null || i(new Error(`Failed to load template "${e}"`)));
3014
+ } else {
3015
+ const N = `Template "${e}" not found. Available templates: ${je.join(", ")}`;
3016
+ I(N), i == null || i(new Error(N));
3017
+ }
3018
+ else if (r)
3019
+ z(r);
3020
+ else {
3021
+ const N = `No template or schema provided. Please specify a template (${je.join(", ")}) or provide a custom schema.`;
3022
+ I(N), i == null || i(new Error(N));
3023
+ }
3024
+ }, [e, r, i]), Ke(() => {
3025
+ D && (h(D), J(D));
3026
+ }, [D]);
3027
+ const J = async (N) => {
3028
+ try {
3029
+ k(!0);
3030
+ const B = await re().createImportSession(N);
3031
+ C(B.sessionId);
3032
+ } catch (V) {
3033
+ const B = V;
3034
+ G(B.message), i == null || i(B);
3035
+ } finally {
3036
+ k(!1);
3037
+ }
3038
+ }, ut = Pe(async (N) => {
3039
+ if (f)
3040
+ try {
3041
+ k(!0), G(null), H(10), U("Uploading file...");
3042
+ const V = re();
3043
+ H(30), U("Parsing file data...");
3044
+ const B = await V.uploadFile(f, N);
3045
+ H(60), U("Processing rows...");
3046
+ const Te = (Z, ht) => ({
3047
+ rowIndex: Z.rowIndex ?? ht,
3048
+ data: Z.data ?? Z,
3049
+ rawData: Z.rawData ?? Object.values(Z.data ?? Z)
3050
+ });
3051
+ v({
3052
+ headers: B.data.headers,
3053
+ rows: B.data.sampleRows.map(Te),
3054
+ totalRows: B.data.totalRows,
3055
+ sampleRows: B.data.sampleRows.map(Te)
3056
+ }), H(80), U("Matching columns..."), P(), await ft(), H(100), U("Done");
3057
+ } catch (V) {
3058
+ G(`Failed to process the uploaded file: ${V.message}`);
3059
+ } finally {
3060
+ k(!1), H(0), U("");
3061
+ }
3062
+ }, [f]), ft = async () => {
3063
+ if (f)
3064
+ try {
3065
+ k(!0);
3066
+ const V = await re().matchColumns(f);
3067
+ y(V.mappings), x(V.unmappedSource, V.unmappedTarget);
3068
+ } catch (N) {
3069
+ G(`Column matching failed: ${N.message}`);
3070
+ } finally {
3071
+ k(!1);
3072
+ }
3073
+ }, dt = async () => {
3074
+ if (f)
3075
+ try {
3076
+ k(!0), G(null);
3077
+ const V = await re().validateImport(f);
3078
+ $(V.validation), P();
3079
+ } catch (N) {
3080
+ G(`Validation failed: ${N.message}`);
3081
+ } finally {
3082
+ k(!1);
3083
+ }
3084
+ }, [He, se] = j(null), [A, Ae] = j(null), ct = async () => {
3085
+ if (f)
3086
+ try {
3087
+ k(!0), G(null), se(null);
3088
+ const V = await re().completeImport(f, {
3089
+ skipInvalidRows: !0,
3090
+ acknowledgeWarnings: !0
3091
+ });
3092
+ Ae(V), F("complete"), l == null || l(V);
3093
+ } catch (N) {
3094
+ se(N.message), F("complete");
3095
+ } finally {
3096
+ k(!1);
3097
+ }
3098
+ }, ie = () => {
3099
+ K(), s == null || s();
3100
+ }, Ge = () => {
3101
+ se(null), Ae(null), H(0), U(""), K(), D && (h(D), J(D));
3102
+ }, gt = () => Un.findIndex((N) => N.key === u), pt = () => {
3103
+ switch (u) {
3104
+ case "upload":
3105
+ return g !== null;
3106
+ case "mapping":
3107
+ return p.length > 0 && p.some((N) => N.targetKey !== null);
3108
+ case "validation":
3109
+ return d !== null;
3110
+ case "review":
3111
+ return d !== null && (d.isValid || d.errorCount === 0);
3112
+ default:
3113
+ return !1;
3114
+ }
3115
+ }, mt = async () => {
3116
+ switch (u) {
3117
+ case "mapping":
3118
+ await dt();
3119
+ break;
3120
+ case "validation":
3121
+ P();
3122
+ break;
3123
+ case "review":
3124
+ await ct();
3125
+ break;
3126
+ default:
3127
+ P();
3128
+ }
3129
+ };
3130
+ if (_)
3131
+ return /* @__PURE__ */ c(pe, { theme: n, useShadowDom: o, children: /* @__PURE__ */ c("div", { className: "ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6", children: /* @__PURE__ */ w("div", { className: "ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8", children: [
3132
+ /* @__PURE__ */ c("div", { className: "ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4", style: { backgroundColor: "var(--ff-error-light)" }, children: /* @__PURE__ */ c(ce, { className: "ff-w-10 ff-h-10", style: { color: "var(--ff-error)" } }) }),
3133
+ /* @__PURE__ */ c("h3", { className: "ff-text-xl ff-font-semibold ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: "Configuration Error" }),
3134
+ /* @__PURE__ */ c("p", { className: "ff-text-center ff-max-w-md ff-mb-4", style: { color: "var(--ff-text-muted)" }, children: _ }),
3135
+ s && /* @__PURE__ */ c("button", { onClick: ie, className: "ff-btn ff-btn-secondary", children: "Close" })
3136
+ ] }) }) });
3137
+ if (!D)
3138
+ return /* @__PURE__ */ c(pe, { theme: n, useShadowDom: o, children: /* @__PURE__ */ c("div", { className: "ff-container ff-bg-white ff-rounded-xl ff-shadow-xl ff-overflow-hidden ff-p-6", children: /* @__PURE__ */ w("div", { className: "ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8", children: [
3139
+ /* @__PURE__ */ c(ae, { className: "ff-w-10 ff-h-10 ff-animate-spin ff-mb-4", style: { color: "var(--ff-primary-90)" } }),
3140
+ /* @__PURE__ */ c("p", { style: { color: "var(--ff-text-muted)" }, children: "Loading template..." })
3141
+ ] }) }) });
3142
+ const ne = () => {
3143
+ const N = u === "review" ? "validation" : u;
3144
+ return xe.indexOf(N);
3145
+ }, Oe = /* @__PURE__ */ c(ee, { children: /* @__PURE__ */ w("div", { className: t === "embed" ? "ff-container ff-embed" : "ff-container ff-modal", children: [
3146
+ /* @__PURE__ */ w("div", { className: "ff-modal-header", children: [
3147
+ /* @__PURE__ */ w("div", { className: "ff-modal-header-left", children: [
3148
+ /* @__PURE__ */ w("div", { className: "ff-flex ff-items-center ff-gap-3", children: [
3149
+ /* @__PURE__ */ c("div", { className: "ff-modal-icon", children: /* @__PURE__ */ c(bt, {}) }),
3150
+ /* @__PURE__ */ c("h2", { className: "ff-modal-title", children: "Import Data" })
3151
+ ] }),
3152
+ /* @__PURE__ */ c("div", { className: "ff-steps ff-ml-4", children: xe.map((N, V) => /* @__PURE__ */ w(vt.Fragment, { children: [
3153
+ /* @__PURE__ */ c(
3154
+ "div",
3155
+ {
3156
+ className: W(
3157
+ "ff-step",
3158
+ ne() === V && "ff-step-active",
3159
+ ne() > V && "ff-step-complete",
3160
+ ne() < V && "ff-step-pending"
3161
+ ),
3162
+ children: ne() > V ? "✓" : V + 1
3163
+ }
3164
+ ),
3165
+ V < xe.length - 1 && /* @__PURE__ */ c("div", { className: W(
3166
+ "ff-step-connector",
3167
+ ne() > V && "ff-step-connector-complete"
3168
+ ) })
3169
+ ] }, N)) })
3170
+ ] }),
3171
+ /* @__PURE__ */ c(
3172
+ "button",
3173
+ {
3174
+ onClick: ie,
3175
+ className: "ff-modal-close",
3176
+ children: /* @__PURE__ */ c(ce, { className: "ff-w-5 ff-h-5" })
3177
+ }
3178
+ )
3179
+ ] }),
3180
+ /* @__PURE__ */ w("div", { className: "ff-modal-body", children: [
3181
+ m && /* @__PURE__ */ c("div", { className: "ff-mb-4 ff-p-4 ff-border ff-rounded-lg ff-text-sm", style: { backgroundColor: "var(--ff-error-light)", borderColor: "var(--ff-error)", color: "var(--ff-error)" }, children: m }),
3182
+ u === "upload" && /* @__PURE__ */ c("div", { className: "ff-py-4", children: /* @__PURE__ */ c("div", { className: "ff-max-w-xl ff-mx-auto", children: a && M > 0 ? /* @__PURE__ */ w("div", { className: "ff-p-8 ff-text-center", children: [
3183
+ /* @__PURE__ */ c(ae, { className: "ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4", style: { color: "var(--ff-primary-90)" } }),
3184
+ /* @__PURE__ */ c("p", { className: "ff-font-medium ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: b }),
3185
+ /* @__PURE__ */ c("div", { className: "ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2", children: /* @__PURE__ */ c(
3186
+ "div",
3187
+ {
3188
+ className: "ff-progress-bar",
3189
+ style: { width: `${M}%`, transition: "width 0.3s ease" }
3190
+ }
3191
+ ) }),
3192
+ /* @__PURE__ */ w("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: [
3193
+ M,
3194
+ "% complete"
3195
+ ] })
3196
+ ] }) : /* @__PURE__ */ c(jt, { onFileSelect: ut }) }) }),
3197
+ u === "mapping" && (a && M > 0 ? /* @__PURE__ */ w("div", { className: "ff-py-12 ff-text-center", children: [
3198
+ /* @__PURE__ */ c(ae, { className: "ff-w-10 ff-h-10 ff-animate-spin ff-mx-auto ff-mb-4", style: { color: "var(--ff-primary-90)" } }),
3199
+ /* @__PURE__ */ c("p", { className: "ff-font-medium ff-mb-3", style: { color: "var(--ff-text-primary)" }, children: b }),
3200
+ /* @__PURE__ */ c("div", { className: "ff-progress ff-w-full ff-max-w-xs ff-mx-auto ff-mb-2", children: /* @__PURE__ */ c(
3201
+ "div",
3202
+ {
3203
+ className: "ff-progress-bar",
3204
+ style: { width: `${M}%`, transition: "width 0.3s ease" }
3205
+ }
3206
+ ) }),
3207
+ /* @__PURE__ */ w("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: [
3208
+ M,
3209
+ "% complete"
3210
+ ] })
3211
+ ] }) : /* @__PURE__ */ c(Ut, {})),
3212
+ u === "validation" && /* @__PURE__ */ w("div", { className: "ff-space-y-6", children: [
3213
+ /* @__PURE__ */ c(Je, {}),
3214
+ /* @__PURE__ */ c(Ye, { editable: !0 })
3215
+ ] }),
3216
+ u === "review" && /* @__PURE__ */ w("div", { className: "ff-space-y-6", children: [
3217
+ /* @__PURE__ */ c(Je, { showDetails: !1 }),
3218
+ /* @__PURE__ */ c(Ye, { editable: !1, pageSize: 10 })
3219
+ ] }),
3220
+ u === "complete" && /* @__PURE__ */ c("div", { className: "ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-8", children: He ? /* @__PURE__ */ w(ee, { children: [
3221
+ /* @__PURE__ */ c("div", { className: "ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4", style: { backgroundColor: "var(--ff-error-light)" }, children: /* @__PURE__ */ c(ce, { className: "ff-w-10 ff-h-10", style: { color: "var(--ff-error)" } }) }),
3222
+ /* @__PURE__ */ c("h3", { className: "ff-text-xl ff-font-semibold ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: "Import Failed" }),
3223
+ /* @__PURE__ */ c("p", { className: "ff-text-center ff-max-w-md ff-mb-4", style: { color: "var(--ff-text-muted)" }, children: He }),
3224
+ /* @__PURE__ */ w("div", { className: "ff-flex ff-gap-3", children: [
3225
+ /* @__PURE__ */ c(
3226
+ "button",
3227
+ {
3228
+ onClick: () => {
3229
+ se(null), F("review");
3230
+ },
3231
+ className: "ff-btn ff-btn-secondary",
3232
+ children: "Back to Review"
3233
+ }
3234
+ ),
3235
+ s && /* @__PURE__ */ c("button", { onClick: ie, className: "ff-btn ff-btn-secondary", children: "Close" })
3236
+ ] })
3237
+ ] }) : /* @__PURE__ */ w(ee, { children: [
3238
+ /* @__PURE__ */ c("div", { className: "ff-w-20 ff-h-20 ff-rounded-2xl ff-flex ff-items-center ff-justify-center ff-mb-6", style: { backgroundColor: "var(--ff-success-light)" }, children: /* @__PURE__ */ c(Ee, { className: "ff-w-10 ff-h-10", style: { color: "var(--ff-success)" } }) }),
3239
+ /* @__PURE__ */ c("h3", { className: "ff-text-xl ff-font-semibold ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: "Import Complete!" }),
3240
+ /* @__PURE__ */ c("p", { className: "ff-mb-6", style: { color: "var(--ff-text-muted)" }, children: "Your data has been successfully imported." }),
3241
+ /* @__PURE__ */ w("div", { className: "ff-flex ff-gap-6 ff-mb-6", children: [
3242
+ /* @__PURE__ */ w("div", { className: "ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border", style: { borderColor: "var(--ff-border-light)", backgroundColor: "var(--ff-bg-primary)" }, children: [
3243
+ /* @__PURE__ */ c("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-text-primary)" }, children: (A == null ? void 0 : A.totalRows) ?? (d == null ? void 0 : d.totalRows) ?? 0 }),
3244
+ /* @__PURE__ */ c("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: "Total Rows" })
3245
+ ] }),
3246
+ /* @__PURE__ */ w("div", { className: "ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border", style: { borderColor: "var(--ff-success)", backgroundColor: "var(--ff-success-light)" }, children: [
3247
+ /* @__PURE__ */ c("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-success-dark)" }, children: (A == null ? void 0 : A.importedRows) ?? (d == null ? void 0 : d.validRows) ?? 0 }),
3248
+ /* @__PURE__ */ c("p", { className: "ff-text-sm", style: { color: "var(--ff-success)" }, children: "Imported" })
3249
+ ] }),
3250
+ ((A == null ? void 0 : A.skippedRows) ?? 0) > 0 && /* @__PURE__ */ w("div", { className: "ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border", style: { borderColor: "var(--ff-warning)", backgroundColor: "var(--ff-warning-light)" }, children: [
3251
+ /* @__PURE__ */ c("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-warning-dark)" }, children: (A == null ? void 0 : A.skippedRows) ?? 0 }),
3252
+ /* @__PURE__ */ c("p", { className: "ff-text-sm", style: { color: "var(--ff-warning)" }, children: "Skipped" })
3253
+ ] }),
3254
+ /* @__PURE__ */ w("div", { className: "ff-text-center ff-px-6 ff-py-3 ff-rounded-xl ff-border", style: { borderColor: "var(--ff-border-light)", backgroundColor: "var(--ff-bg-primary)" }, children: [
3255
+ /* @__PURE__ */ c("p", { className: "ff-text-2xl ff-font-bold", style: { color: "var(--ff-text-primary)" }, children: p.filter((N) => N.targetKey !== null).length }),
3256
+ /* @__PURE__ */ c("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: "Columns Mapped" })
3257
+ ] })
3258
+ ] }),
3259
+ /* @__PURE__ */ w("div", { className: "ff-flex ff-gap-3", children: [
3260
+ /* @__PURE__ */ c(
3261
+ "button",
3262
+ {
3263
+ onClick: Ge,
3264
+ className: "ff-btn ff-btn-primary",
3265
+ children: "Start New Import"
3266
+ }
3267
+ ),
3268
+ s && /* @__PURE__ */ c("button", { onClick: ie, className: "ff-btn ff-btn-secondary", children: "Close" })
3269
+ ] })
3270
+ ] }) })
3271
+ ] }),
3272
+ /* @__PURE__ */ c("div", { className: "ff-modal-footer", children: u === "complete" ? /* @__PURE__ */ w(ee, { children: [
3273
+ /* @__PURE__ */ c("div", {}),
3274
+ /* @__PURE__ */ c("button", { onClick: Ge, className: "ff-btn ff-btn-primary", children: "Start New Import" })
3275
+ ] }) : /* @__PURE__ */ w(ee, { children: [
3276
+ /* @__PURE__ */ c(
3277
+ "button",
3278
+ {
3279
+ onClick: Y,
3280
+ disabled: gt() === 0 || a,
3281
+ className: "ff-btn ff-btn-ghost",
3282
+ children: "Back"
3283
+ }
3284
+ ),
3285
+ /* @__PURE__ */ c(
3286
+ "button",
3287
+ {
3288
+ onClick: mt,
3289
+ disabled: !pt() || a,
3290
+ className: "ff-btn ff-btn-primary",
3291
+ children: a ? /* @__PURE__ */ w(ee, { children: [
3292
+ /* @__PURE__ */ c(ae, { className: "ff-w-4 ff-h-4 ff-animate-spin" }),
3293
+ "Processing..."
3294
+ ] }) : u === "review" ? "Complete Import" : "Continue"
3295
+ }
3296
+ )
3297
+ ] }) })
3298
+ ] }) });
3299
+ return /* @__PURE__ */ c(pe, { theme: n, useShadowDom: o, children: t === "modal" ? /* @__PURE__ */ c("div", { className: "ff-overlay", children: Oe }) : Oe });
3300
+ };
3301
+ export {
3302
+ Ut as C,
3303
+ Ye as D,
3304
+ jt as F,
3305
+ Jn as I,
3306
+ Je as V,
3307
+ te as u
3308
+ };
3309
+ //# sourceMappingURL=ImportWizard-Dececv65.mjs.map