@hot-updater/console 0.27.1 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/.output/nitro.json +17 -0
  2. package/.output/public/apple-touch-icon.png +0 -0
  3. package/.output/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  4. package/.output/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  5. package/.output/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  6. package/.output/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  7. package/.output/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  8. package/.output/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  9. package/.output/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  10. package/.output/public/assets/main-Dlx8-qN-.js +61 -0
  11. package/.output/public/assets/routes-DB0tWmiJ.js +10 -0
  12. package/.output/public/assets/styles-Bfxg4M1x.css +2 -0
  13. package/.output/public/favicon-16x16.png +0 -0
  14. package/.output/public/favicon-32x32.png +0 -0
  15. package/.output/public/favicon.ico +0 -0
  16. package/.output/public/logo.svg +1 -0
  17. package/.output/public/manifest.json +30 -0
  18. package/.output/public/robots.txt +3 -0
  19. package/.output/server/_chunks/ssr-renderer.mjs +15 -0
  20. package/.output/server/_libs/@floating-ui/core+[...].mjs +698 -0
  21. package/.output/server/_libs/@floating-ui/dom+[...].mjs +644 -0
  22. package/.output/server/_libs/@floating-ui/react-dom+[...].mjs +839 -0
  23. package/.output/server/_libs/@radix-ui/react-alert-dialog+[...].mjs +2093 -0
  24. package/.output/server/_libs/@radix-ui/react-popper+[...].mjs +287 -0
  25. package/.output/server/_libs/@radix-ui/react-select+[...].mjs +1003 -0
  26. package/.output/server/_libs/@tanstack/devtools-event-client+[...].mjs +196 -0
  27. package/.output/server/_libs/@tanstack/form-core+[...].mjs +2396 -0
  28. package/.output/server/_libs/@tanstack/react-form+[...].mjs +298 -0
  29. package/.output/server/_libs/@tanstack/react-router+[...].mjs +13068 -0
  30. package/.output/server/_libs/@tanstack/react-table+[...].mjs +2372 -0
  31. package/.output/server/_libs/chownr.mjs +60 -0
  32. package/.output/server/_libs/class-variance-authority+clsx.mjs +69 -0
  33. package/.output/server/_libs/core-util-is.mjs +67 -0
  34. package/.output/server/_libs/dayjs.mjs +408 -0
  35. package/.output/server/_libs/h3+rou3+srvx.mjs +1158 -0
  36. package/.output/server/_libs/hookable.mjs +41 -0
  37. package/.output/server/_libs/immediate.mjs +57 -0
  38. package/.output/server/_libs/inherits.mjs +39 -0
  39. package/.output/server/_libs/isaacs__fs-minipass+minipass.mjs +1120 -0
  40. package/.output/server/_libs/isarray.mjs +10 -0
  41. package/.output/server/_libs/jszip+[...].mjs +8311 -0
  42. package/.output/server/_libs/lucide-react.mjs +371 -0
  43. package/.output/server/_libs/minizlib.mjs +345 -0
  44. package/.output/server/_libs/next-themes.mjs +49 -0
  45. package/.output/server/_libs/radix-ui__number.mjs +6 -0
  46. package/.output/server/_libs/radix-ui__primitive.mjs +9 -0
  47. package/.output/server/_libs/radix-ui__react-arrow.mjs +23 -0
  48. package/.output/server/_libs/radix-ui__react-collection.mjs +78 -0
  49. package/.output/server/_libs/radix-ui__react-direction.mjs +11 -0
  50. package/.output/server/_libs/radix-ui__react-label.mjs +22 -0
  51. package/.output/server/_libs/radix-ui__react-separator.mjs +31 -0
  52. package/.output/server/_libs/radix-ui__react-slider.mjs +451 -0
  53. package/.output/server/_libs/radix-ui__react-switch.mjs +118 -0
  54. package/.output/server/_libs/radix-ui__react-tooltip.mjs +491 -0
  55. package/.output/server/_libs/semver.mjs +1339 -0
  56. package/.output/server/_libs/sonner.mjs +908 -0
  57. package/.output/server/_libs/tailwind-merge.mjs +1962 -0
  58. package/.output/server/_libs/tanstack__history.mjs +322 -0
  59. package/.output/server/_libs/tanstack__query-core.mjs +2073 -0
  60. package/.output/server/_libs/tanstack__react-query.mjs +146 -0
  61. package/.output/server/_libs/tanstack__router-core.mjs +6 -0
  62. package/.output/server/_libs/tar.mjs +1996 -0
  63. package/.output/server/_libs/ufo.mjs +64 -0
  64. package/.output/server/_runtime.mjs +26 -0
  65. package/.output/server/_ssr/api-rpc-D3ZehMIN.mjs +217 -0
  66. package/.output/server/_ssr/config.server-JUYQ7UbI.mjs +26 -0
  67. package/.output/server/_ssr/deleteBundle-DWUxu9-K.mjs +22 -0
  68. package/.output/server/_ssr/extract-timestamp-from-uuidv7-B90UBADU.mjs +24 -0
  69. package/.output/server/_ssr/promoteBundle-DtMHuubR.mjs +1571 -0
  70. package/.output/server/_ssr/router-pgc7NX76.mjs +250 -0
  71. package/.output/server/_ssr/routes-PqTTQSoI.mjs +1833 -0
  72. package/.output/server/_ssr/sidebar-DXng0IOP.mjs +439 -0
  73. package/.output/server/_ssr/ssr.mjs +5050 -0
  74. package/.output/server/_ssr/start-DQK0r85G.mjs +4 -0
  75. package/.output/server/_tanstack-start-manifest_v-DTbQVOpU.mjs +17 -0
  76. package/.output/server/index.mjs +417 -0
  77. package/.output/server/node_modules/tslib/modules/index.js +70 -0
  78. package/.output/server/node_modules/tslib/modules/package.json +3 -0
  79. package/.output/server/node_modules/tslib/package.json +47 -0
  80. package/.output/server/node_modules/tslib/tslib.js +484 -0
  81. package/.output/server/package.json +9 -0
  82. package/README.md +191 -2
  83. package/package.json +77 -50
  84. package/dist/.gitkeep +0 -0
  85. package/dist/assets/favicon-BkwcEHsj.ico +0 -0
  86. package/dist/assets/index-DUlKsori.css +0 -1
  87. package/dist/assets/index-ijmIcyn1.js +0 -27
  88. package/dist/assets/logo-BYNFyja1.png +0 -0
  89. package/dist/index.cjs +0 -2129
  90. package/dist/index.d.cts +0 -218
  91. package/dist/index.d.ts +0 -218
  92. package/dist/index.html +0 -14
  93. package/dist/index.js +0 -2125
@@ -0,0 +1,2372 @@
1
+ import { r as __toESM } from "../../_runtime.mjs";
2
+ import { u as require_react } from "../@floating-ui/react-dom+[...].mjs";
3
+ //#region ../../node_modules/.pnpm/@tanstack+table-core@8.21.3/node_modules/@tanstack/table-core/build/lib/index.mjs
4
+ /**
5
+ * table-core
6
+ *
7
+ * Copyright (c) TanStack
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE.md file in the root directory of this source tree.
11
+ *
12
+ * @license MIT
13
+ */
14
+ function createColumnHelper() {
15
+ return {
16
+ accessor: (accessor, column) => {
17
+ return typeof accessor === "function" ? {
18
+ ...column,
19
+ accessorFn: accessor
20
+ } : {
21
+ ...column,
22
+ accessorKey: accessor
23
+ };
24
+ },
25
+ display: (column) => column,
26
+ group: (column) => column
27
+ };
28
+ }
29
+ function functionalUpdate(updater, input) {
30
+ return typeof updater === "function" ? updater(input) : updater;
31
+ }
32
+ function makeStateUpdater(key, instance) {
33
+ return (updater) => {
34
+ instance.setState((old) => {
35
+ return {
36
+ ...old,
37
+ [key]: functionalUpdate(updater, old[key])
38
+ };
39
+ });
40
+ };
41
+ }
42
+ function isFunction(d) {
43
+ return d instanceof Function;
44
+ }
45
+ function isNumberArray(d) {
46
+ return Array.isArray(d) && d.every((val) => typeof val === "number");
47
+ }
48
+ function flattenBy(arr, getChildren) {
49
+ const flat = [];
50
+ const recurse = (subArr) => {
51
+ subArr.forEach((item) => {
52
+ flat.push(item);
53
+ const children = getChildren(item);
54
+ if (children != null && children.length) recurse(children);
55
+ });
56
+ };
57
+ recurse(arr);
58
+ return flat;
59
+ }
60
+ function memo(getDeps, fn, opts) {
61
+ let deps = [];
62
+ let result;
63
+ return (depArgs) => {
64
+ let depTime;
65
+ if (opts.key && opts.debug) depTime = Date.now();
66
+ const newDeps = getDeps(depArgs);
67
+ if (!(newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep))) return result;
68
+ deps = newDeps;
69
+ let resultTime;
70
+ if (opts.key && opts.debug) resultTime = Date.now();
71
+ result = fn(...newDeps);
72
+ opts == null || opts.onChange == null || opts.onChange(result);
73
+ if (opts.key && opts.debug) {
74
+ if (opts != null && opts.debug()) {
75
+ const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
76
+ const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
77
+ const resultFpsPercentage = resultEndTime / 16;
78
+ const pad = (str, num) => {
79
+ str = String(str);
80
+ while (str.length < num) str = " " + str;
81
+ return str;
82
+ };
83
+ console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
84
+ font-size: .6rem;
85
+ font-weight: bold;
86
+ color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
87
+ }
88
+ }
89
+ return result;
90
+ };
91
+ }
92
+ function getMemoOptions(tableOptions, debugLevel, key, onChange) {
93
+ return {
94
+ debug: () => {
95
+ var _tableOptions$debugAl;
96
+ return (_tableOptions$debugAl = tableOptions == null ? void 0 : tableOptions.debugAll) != null ? _tableOptions$debugAl : tableOptions[debugLevel];
97
+ },
98
+ key: false,
99
+ onChange
100
+ };
101
+ }
102
+ function createCell(table, row, column, columnId) {
103
+ const getRenderValue = () => {
104
+ var _cell$getValue;
105
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : table.options.renderFallbackValue;
106
+ };
107
+ const cell = {
108
+ id: `${row.id}_${column.id}`,
109
+ row,
110
+ column,
111
+ getValue: () => row.getValue(columnId),
112
+ renderValue: getRenderValue,
113
+ getContext: memo(() => [
114
+ table,
115
+ column,
116
+ row,
117
+ cell
118
+ ], (table, column, row, cell) => ({
119
+ table,
120
+ column,
121
+ row,
122
+ cell,
123
+ getValue: cell.getValue,
124
+ renderValue: cell.renderValue
125
+ }), getMemoOptions(table.options, "debugCells", "cell.getContext"))
126
+ };
127
+ table._features.forEach((feature) => {
128
+ feature.createCell == null || feature.createCell(cell, column, row, table);
129
+ }, {});
130
+ return cell;
131
+ }
132
+ function createColumn(table, columnDef, depth, parent) {
133
+ var _ref, _resolvedColumnDef$id;
134
+ const resolvedColumnDef = {
135
+ ...table._getDefaultColumnDef(),
136
+ ...columnDef
137
+ };
138
+ const accessorKey = resolvedColumnDef.accessorKey;
139
+ let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? typeof String.prototype.replaceAll === "function" ? accessorKey.replaceAll(".", "_") : accessorKey.replace(/\./g, "_") : void 0) != null ? _ref : typeof resolvedColumnDef.header === "string" ? resolvedColumnDef.header : void 0;
140
+ let accessorFn;
141
+ if (resolvedColumnDef.accessorFn) accessorFn = resolvedColumnDef.accessorFn;
142
+ else if (accessorKey) if (accessorKey.includes(".")) accessorFn = (originalRow) => {
143
+ let result = originalRow;
144
+ for (const key of accessorKey.split(".")) {
145
+ var _result;
146
+ result = (_result = result) == null ? void 0 : _result[key];
147
+ }
148
+ return result;
149
+ };
150
+ else accessorFn = (originalRow) => originalRow[resolvedColumnDef.accessorKey];
151
+ if (!id) throw new Error();
152
+ let column = {
153
+ id: `${String(id)}`,
154
+ accessorFn,
155
+ parent,
156
+ depth,
157
+ columnDef: resolvedColumnDef,
158
+ columns: [],
159
+ getFlatColumns: memo(() => [true], () => {
160
+ var _column$columns;
161
+ return [column, ...(_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap((d) => d.getFlatColumns())];
162
+ }, getMemoOptions(table.options, "debugColumns", "column.getFlatColumns")),
163
+ getLeafColumns: memo(() => [table._getOrderColumnsFn()], (orderColumns) => {
164
+ var _column$columns2;
165
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) return orderColumns(column.columns.flatMap((column) => column.getLeafColumns()));
166
+ return [column];
167
+ }, getMemoOptions(table.options, "debugColumns", "column.getLeafColumns"))
168
+ };
169
+ for (const feature of table._features) feature.createColumn == null || feature.createColumn(column, table);
170
+ return column;
171
+ }
172
+ var debug = "debugHeaders";
173
+ function createHeader(table, column, options) {
174
+ var _options$id;
175
+ let header = {
176
+ id: (_options$id = options.id) != null ? _options$id : column.id,
177
+ column,
178
+ index: options.index,
179
+ isPlaceholder: !!options.isPlaceholder,
180
+ placeholderId: options.placeholderId,
181
+ depth: options.depth,
182
+ subHeaders: [],
183
+ colSpan: 0,
184
+ rowSpan: 0,
185
+ headerGroup: null,
186
+ getLeafHeaders: () => {
187
+ const leafHeaders = [];
188
+ const recurseHeader = (h) => {
189
+ if (h.subHeaders && h.subHeaders.length) h.subHeaders.map(recurseHeader);
190
+ leafHeaders.push(h);
191
+ };
192
+ recurseHeader(header);
193
+ return leafHeaders;
194
+ },
195
+ getContext: () => ({
196
+ table,
197
+ header,
198
+ column
199
+ })
200
+ };
201
+ table._features.forEach((feature) => {
202
+ feature.createHeader == null || feature.createHeader(header, table);
203
+ });
204
+ return header;
205
+ }
206
+ var Headers = { createTable: (table) => {
207
+ table.getHeaderGroups = memo(() => [
208
+ table.getAllColumns(),
209
+ table.getVisibleLeafColumns(),
210
+ table.getState().columnPinning.left,
211
+ table.getState().columnPinning.right
212
+ ], (allColumns, leafColumns, left, right) => {
213
+ var _left$map$filter, _right$map$filter;
214
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
215
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
216
+ const centerColumns = leafColumns.filter((column) => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
217
+ return buildHeaderGroups(allColumns, [
218
+ ...leftColumns,
219
+ ...centerColumns,
220
+ ...rightColumns
221
+ ], table);
222
+ }, getMemoOptions(table.options, debug, "getHeaderGroups"));
223
+ table.getCenterHeaderGroups = memo(() => [
224
+ table.getAllColumns(),
225
+ table.getVisibleLeafColumns(),
226
+ table.getState().columnPinning.left,
227
+ table.getState().columnPinning.right
228
+ ], (allColumns, leafColumns, left, right) => {
229
+ leafColumns = leafColumns.filter((column) => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
230
+ return buildHeaderGroups(allColumns, leafColumns, table, "center");
231
+ }, getMemoOptions(table.options, debug, "getCenterHeaderGroups"));
232
+ table.getLeftHeaderGroups = memo(() => [
233
+ table.getAllColumns(),
234
+ table.getVisibleLeafColumns(),
235
+ table.getState().columnPinning.left
236
+ ], (allColumns, leafColumns, left) => {
237
+ var _left$map$filter2;
238
+ return buildHeaderGroups(allColumns, (_left$map$filter2 = left == null ? void 0 : left.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [], table, "left");
239
+ }, getMemoOptions(table.options, debug, "getLeftHeaderGroups"));
240
+ table.getRightHeaderGroups = memo(() => [
241
+ table.getAllColumns(),
242
+ table.getVisibleLeafColumns(),
243
+ table.getState().columnPinning.right
244
+ ], (allColumns, leafColumns, right) => {
245
+ var _right$map$filter2;
246
+ return buildHeaderGroups(allColumns, (_right$map$filter2 = right == null ? void 0 : right.map((columnId) => leafColumns.find((d) => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [], table, "right");
247
+ }, getMemoOptions(table.options, debug, "getRightHeaderGroups"));
248
+ table.getFooterGroups = memo(() => [table.getHeaderGroups()], (headerGroups) => {
249
+ return [...headerGroups].reverse();
250
+ }, getMemoOptions(table.options, debug, "getFooterGroups"));
251
+ table.getLeftFooterGroups = memo(() => [table.getLeftHeaderGroups()], (headerGroups) => {
252
+ return [...headerGroups].reverse();
253
+ }, getMemoOptions(table.options, debug, "getLeftFooterGroups"));
254
+ table.getCenterFooterGroups = memo(() => [table.getCenterHeaderGroups()], (headerGroups) => {
255
+ return [...headerGroups].reverse();
256
+ }, getMemoOptions(table.options, debug, "getCenterFooterGroups"));
257
+ table.getRightFooterGroups = memo(() => [table.getRightHeaderGroups()], (headerGroups) => {
258
+ return [...headerGroups].reverse();
259
+ }, getMemoOptions(table.options, debug, "getRightFooterGroups"));
260
+ table.getFlatHeaders = memo(() => [table.getHeaderGroups()], (headerGroups) => {
261
+ return headerGroups.map((headerGroup) => {
262
+ return headerGroup.headers;
263
+ }).flat();
264
+ }, getMemoOptions(table.options, debug, "getFlatHeaders"));
265
+ table.getLeftFlatHeaders = memo(() => [table.getLeftHeaderGroups()], (left) => {
266
+ return left.map((headerGroup) => {
267
+ return headerGroup.headers;
268
+ }).flat();
269
+ }, getMemoOptions(table.options, debug, "getLeftFlatHeaders"));
270
+ table.getCenterFlatHeaders = memo(() => [table.getCenterHeaderGroups()], (left) => {
271
+ return left.map((headerGroup) => {
272
+ return headerGroup.headers;
273
+ }).flat();
274
+ }, getMemoOptions(table.options, debug, "getCenterFlatHeaders"));
275
+ table.getRightFlatHeaders = memo(() => [table.getRightHeaderGroups()], (left) => {
276
+ return left.map((headerGroup) => {
277
+ return headerGroup.headers;
278
+ }).flat();
279
+ }, getMemoOptions(table.options, debug, "getRightFlatHeaders"));
280
+ table.getCenterLeafHeaders = memo(() => [table.getCenterFlatHeaders()], (flatHeaders) => {
281
+ return flatHeaders.filter((header) => {
282
+ var _header$subHeaders;
283
+ return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
284
+ });
285
+ }, getMemoOptions(table.options, debug, "getCenterLeafHeaders"));
286
+ table.getLeftLeafHeaders = memo(() => [table.getLeftFlatHeaders()], (flatHeaders) => {
287
+ return flatHeaders.filter((header) => {
288
+ var _header$subHeaders2;
289
+ return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
290
+ });
291
+ }, getMemoOptions(table.options, debug, "getLeftLeafHeaders"));
292
+ table.getRightLeafHeaders = memo(() => [table.getRightFlatHeaders()], (flatHeaders) => {
293
+ return flatHeaders.filter((header) => {
294
+ var _header$subHeaders3;
295
+ return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
296
+ });
297
+ }, getMemoOptions(table.options, debug, "getRightLeafHeaders"));
298
+ table.getLeafHeaders = memo(() => [
299
+ table.getLeftHeaderGroups(),
300
+ table.getCenterHeaderGroups(),
301
+ table.getRightHeaderGroups()
302
+ ], (left, center, right) => {
303
+ var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
304
+ return [
305
+ ...(_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : [],
306
+ ...(_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : [],
307
+ ...(_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : []
308
+ ].map((header) => {
309
+ return header.getLeafHeaders();
310
+ }).flat();
311
+ }, getMemoOptions(table.options, debug, "getLeafHeaders"));
312
+ } };
313
+ function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
314
+ var _headerGroups$0$heade, _headerGroups$;
315
+ let maxDepth = 0;
316
+ const findMaxDepth = function(columns, depth) {
317
+ if (depth === void 0) depth = 1;
318
+ maxDepth = Math.max(maxDepth, depth);
319
+ columns.filter((column) => column.getIsVisible()).forEach((column) => {
320
+ var _column$columns;
321
+ if ((_column$columns = column.columns) != null && _column$columns.length) findMaxDepth(column.columns, depth + 1);
322
+ }, 0);
323
+ };
324
+ findMaxDepth(allColumns);
325
+ let headerGroups = [];
326
+ const createHeaderGroup = (headersToGroup, depth) => {
327
+ const headerGroup = {
328
+ depth,
329
+ id: [headerFamily, `${depth}`].filter(Boolean).join("_"),
330
+ headers: []
331
+ };
332
+ const pendingParentHeaders = [];
333
+ headersToGroup.forEach((headerToGroup) => {
334
+ const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0];
335
+ const isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
336
+ let column;
337
+ let isPlaceholder = false;
338
+ if (isLeafHeader && headerToGroup.column.parent) column = headerToGroup.column.parent;
339
+ else {
340
+ column = headerToGroup.column;
341
+ isPlaceholder = true;
342
+ }
343
+ if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) latestPendingParentHeader.subHeaders.push(headerToGroup);
344
+ else {
345
+ const header = createHeader(table, column, {
346
+ id: [
347
+ headerFamily,
348
+ depth,
349
+ column.id,
350
+ headerToGroup == null ? void 0 : headerToGroup.id
351
+ ].filter(Boolean).join("_"),
352
+ isPlaceholder,
353
+ placeholderId: isPlaceholder ? `${pendingParentHeaders.filter((d) => d.column === column).length}` : void 0,
354
+ depth,
355
+ index: pendingParentHeaders.length
356
+ });
357
+ header.subHeaders.push(headerToGroup);
358
+ pendingParentHeaders.push(header);
359
+ }
360
+ headerGroup.headers.push(headerToGroup);
361
+ headerToGroup.headerGroup = headerGroup;
362
+ });
363
+ headerGroups.push(headerGroup);
364
+ if (depth > 0) createHeaderGroup(pendingParentHeaders, depth - 1);
365
+ };
366
+ createHeaderGroup(columnsToGroup.map((column, index) => createHeader(table, column, {
367
+ depth: maxDepth,
368
+ index
369
+ })), maxDepth - 1);
370
+ headerGroups.reverse();
371
+ const recurseHeadersForSpans = (headers) => {
372
+ return headers.filter((header) => header.column.getIsVisible()).map((header) => {
373
+ let colSpan = 0;
374
+ let rowSpan = 0;
375
+ let childRowSpans = [0];
376
+ if (header.subHeaders && header.subHeaders.length) {
377
+ childRowSpans = [];
378
+ recurseHeadersForSpans(header.subHeaders).forEach((_ref) => {
379
+ let { colSpan: childColSpan, rowSpan: childRowSpan } = _ref;
380
+ colSpan += childColSpan;
381
+ childRowSpans.push(childRowSpan);
382
+ });
383
+ } else colSpan = 1;
384
+ const minChildRowSpan = Math.min(...childRowSpans);
385
+ rowSpan = rowSpan + minChildRowSpan;
386
+ header.colSpan = colSpan;
387
+ header.rowSpan = rowSpan;
388
+ return {
389
+ colSpan,
390
+ rowSpan
391
+ };
392
+ });
393
+ };
394
+ recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
395
+ return headerGroups;
396
+ }
397
+ var createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
398
+ let row = {
399
+ id,
400
+ index: rowIndex,
401
+ original,
402
+ depth,
403
+ parentId,
404
+ _valuesCache: {},
405
+ _uniqueValuesCache: {},
406
+ getValue: (columnId) => {
407
+ if (row._valuesCache.hasOwnProperty(columnId)) return row._valuesCache[columnId];
408
+ const column = table.getColumn(columnId);
409
+ if (!(column != null && column.accessorFn)) return;
410
+ row._valuesCache[columnId] = column.accessorFn(row.original, rowIndex);
411
+ return row._valuesCache[columnId];
412
+ },
413
+ getUniqueValues: (columnId) => {
414
+ if (row._uniqueValuesCache.hasOwnProperty(columnId)) return row._uniqueValuesCache[columnId];
415
+ const column = table.getColumn(columnId);
416
+ if (!(column != null && column.accessorFn)) return;
417
+ if (!column.columnDef.getUniqueValues) {
418
+ row._uniqueValuesCache[columnId] = [row.getValue(columnId)];
419
+ return row._uniqueValuesCache[columnId];
420
+ }
421
+ row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(row.original, rowIndex);
422
+ return row._uniqueValuesCache[columnId];
423
+ },
424
+ renderValue: (columnId) => {
425
+ var _row$getValue;
426
+ return (_row$getValue = row.getValue(columnId)) != null ? _row$getValue : table.options.renderFallbackValue;
427
+ },
428
+ subRows: subRows != null ? subRows : [],
429
+ getLeafRows: () => flattenBy(row.subRows, (d) => d.subRows),
430
+ getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : void 0,
431
+ getParentRows: () => {
432
+ let parentRows = [];
433
+ let currentRow = row;
434
+ while (true) {
435
+ const parentRow = currentRow.getParentRow();
436
+ if (!parentRow) break;
437
+ parentRows.push(parentRow);
438
+ currentRow = parentRow;
439
+ }
440
+ return parentRows.reverse();
441
+ },
442
+ getAllCells: memo(() => [table.getAllLeafColumns()], (leafColumns) => {
443
+ return leafColumns.map((column) => {
444
+ return createCell(table, row, column, column.id);
445
+ });
446
+ }, getMemoOptions(table.options, "debugRows", "getAllCells")),
447
+ _getAllCellsByColumnId: memo(() => [row.getAllCells()], (allCells) => {
448
+ return allCells.reduce((acc, cell) => {
449
+ acc[cell.column.id] = cell;
450
+ return acc;
451
+ }, {});
452
+ }, getMemoOptions(table.options, "debugRows", "getAllCellsByColumnId"))
453
+ };
454
+ for (let i = 0; i < table._features.length; i++) {
455
+ const feature = table._features[i];
456
+ feature == null || feature.createRow == null || feature.createRow(row, table);
457
+ }
458
+ return row;
459
+ };
460
+ var ColumnFaceting = { createColumn: (column, table) => {
461
+ column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
462
+ column.getFacetedRowModel = () => {
463
+ if (!column._getFacetedRowModel) return table.getPreFilteredRowModel();
464
+ return column._getFacetedRowModel();
465
+ };
466
+ column._getFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, column.id);
467
+ column.getFacetedUniqueValues = () => {
468
+ if (!column._getFacetedUniqueValues) return /* @__PURE__ */ new Map();
469
+ return column._getFacetedUniqueValues();
470
+ };
471
+ column._getFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, column.id);
472
+ column.getFacetedMinMaxValues = () => {
473
+ if (!column._getFacetedMinMaxValues) return;
474
+ return column._getFacetedMinMaxValues();
475
+ };
476
+ } };
477
+ var includesString = (row, columnId, filterValue) => {
478
+ var _filterValue$toString, _row$getValue;
479
+ const search = filterValue == null || (_filterValue$toString = filterValue.toString()) == null ? void 0 : _filterValue$toString.toLowerCase();
480
+ return Boolean((_row$getValue = row.getValue(columnId)) == null || (_row$getValue = _row$getValue.toString()) == null || (_row$getValue = _row$getValue.toLowerCase()) == null ? void 0 : _row$getValue.includes(search));
481
+ };
482
+ includesString.autoRemove = (val) => testFalsey(val);
483
+ var includesStringSensitive = (row, columnId, filterValue) => {
484
+ var _row$getValue2;
485
+ return Boolean((_row$getValue2 = row.getValue(columnId)) == null || (_row$getValue2 = _row$getValue2.toString()) == null ? void 0 : _row$getValue2.includes(filterValue));
486
+ };
487
+ includesStringSensitive.autoRemove = (val) => testFalsey(val);
488
+ var equalsString = (row, columnId, filterValue) => {
489
+ var _row$getValue3;
490
+ return ((_row$getValue3 = row.getValue(columnId)) == null || (_row$getValue3 = _row$getValue3.toString()) == null ? void 0 : _row$getValue3.toLowerCase()) === (filterValue == null ? void 0 : filterValue.toLowerCase());
491
+ };
492
+ equalsString.autoRemove = (val) => testFalsey(val);
493
+ var arrIncludes = (row, columnId, filterValue) => {
494
+ var _row$getValue4;
495
+ return (_row$getValue4 = row.getValue(columnId)) == null ? void 0 : _row$getValue4.includes(filterValue);
496
+ };
497
+ arrIncludes.autoRemove = (val) => testFalsey(val);
498
+ var arrIncludesAll = (row, columnId, filterValue) => {
499
+ return !filterValue.some((val) => {
500
+ var _row$getValue5;
501
+ return !((_row$getValue5 = row.getValue(columnId)) != null && _row$getValue5.includes(val));
502
+ });
503
+ };
504
+ arrIncludesAll.autoRemove = (val) => testFalsey(val) || !(val != null && val.length);
505
+ var arrIncludesSome = (row, columnId, filterValue) => {
506
+ return filterValue.some((val) => {
507
+ var _row$getValue6;
508
+ return (_row$getValue6 = row.getValue(columnId)) == null ? void 0 : _row$getValue6.includes(val);
509
+ });
510
+ };
511
+ arrIncludesSome.autoRemove = (val) => testFalsey(val) || !(val != null && val.length);
512
+ var equals = (row, columnId, filterValue) => {
513
+ return row.getValue(columnId) === filterValue;
514
+ };
515
+ equals.autoRemove = (val) => testFalsey(val);
516
+ var weakEquals = (row, columnId, filterValue) => {
517
+ return row.getValue(columnId) == filterValue;
518
+ };
519
+ weakEquals.autoRemove = (val) => testFalsey(val);
520
+ var inNumberRange = (row, columnId, filterValue) => {
521
+ let [min, max] = filterValue;
522
+ const rowValue = row.getValue(columnId);
523
+ return rowValue >= min && rowValue <= max;
524
+ };
525
+ inNumberRange.resolveFilterValue = (val) => {
526
+ let [unsafeMin, unsafeMax] = val;
527
+ let parsedMin = typeof unsafeMin !== "number" ? parseFloat(unsafeMin) : unsafeMin;
528
+ let parsedMax = typeof unsafeMax !== "number" ? parseFloat(unsafeMax) : unsafeMax;
529
+ let min = unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin;
530
+ let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax;
531
+ if (min > max) {
532
+ const temp = min;
533
+ min = max;
534
+ max = temp;
535
+ }
536
+ return [min, max];
537
+ };
538
+ inNumberRange.autoRemove = (val) => testFalsey(val) || testFalsey(val[0]) && testFalsey(val[1]);
539
+ var filterFns = {
540
+ includesString,
541
+ includesStringSensitive,
542
+ equalsString,
543
+ arrIncludes,
544
+ arrIncludesAll,
545
+ arrIncludesSome,
546
+ equals,
547
+ weakEquals,
548
+ inNumberRange
549
+ };
550
+ function testFalsey(val) {
551
+ return val === void 0 || val === null || val === "";
552
+ }
553
+ var ColumnFiltering = {
554
+ getDefaultColumnDef: () => {
555
+ return { filterFn: "auto" };
556
+ },
557
+ getInitialState: (state) => {
558
+ return {
559
+ columnFilters: [],
560
+ ...state
561
+ };
562
+ },
563
+ getDefaultOptions: (table) => {
564
+ return {
565
+ onColumnFiltersChange: makeStateUpdater("columnFilters", table),
566
+ filterFromLeafRows: false,
567
+ maxLeafRowFilterDepth: 100
568
+ };
569
+ },
570
+ createColumn: (column, table) => {
571
+ column.getAutoFilterFn = () => {
572
+ const firstRow = table.getCoreRowModel().flatRows[0];
573
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
574
+ if (typeof value === "string") return filterFns.includesString;
575
+ if (typeof value === "number") return filterFns.inNumberRange;
576
+ if (typeof value === "boolean") return filterFns.equals;
577
+ if (value !== null && typeof value === "object") return filterFns.equals;
578
+ if (Array.isArray(value)) return filterFns.arrIncludes;
579
+ return filterFns.weakEquals;
580
+ };
581
+ column.getFilterFn = () => {
582
+ var _table$options$filter, _table$options$filter2;
583
+ return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === "auto" ? column.getAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[column.columnDef.filterFn]) != null ? _table$options$filter : filterFns[column.columnDef.filterFn];
584
+ };
585
+ column.getCanFilter = () => {
586
+ var _column$columnDef$ena, _table$options$enable, _table$options$enable2;
587
+ return ((_column$columnDef$ena = column.columnDef.enableColumnFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnFilters) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && !!column.accessorFn;
588
+ };
589
+ column.getIsFiltered = () => column.getFilterIndex() > -1;
590
+ column.getFilterValue = () => {
591
+ var _table$getState$colum;
592
+ return (_table$getState$colum = table.getState().columnFilters) == null || (_table$getState$colum = _table$getState$colum.find((d) => d.id === column.id)) == null ? void 0 : _table$getState$colum.value;
593
+ };
594
+ column.getFilterIndex = () => {
595
+ var _table$getState$colum2, _table$getState$colum3;
596
+ return (_table$getState$colum2 = (_table$getState$colum3 = table.getState().columnFilters) == null ? void 0 : _table$getState$colum3.findIndex((d) => d.id === column.id)) != null ? _table$getState$colum2 : -1;
597
+ };
598
+ column.setFilterValue = (value) => {
599
+ table.setColumnFilters((old) => {
600
+ const filterFn = column.getFilterFn();
601
+ const previousFilter = old == null ? void 0 : old.find((d) => d.id === column.id);
602
+ const newFilter = functionalUpdate(value, previousFilter ? previousFilter.value : void 0);
603
+ if (shouldAutoRemoveFilter(filterFn, newFilter, column)) {
604
+ var _old$filter;
605
+ return (_old$filter = old == null ? void 0 : old.filter((d) => d.id !== column.id)) != null ? _old$filter : [];
606
+ }
607
+ const newFilterObj = {
608
+ id: column.id,
609
+ value: newFilter
610
+ };
611
+ if (previousFilter) {
612
+ var _old$map;
613
+ return (_old$map = old == null ? void 0 : old.map((d) => {
614
+ if (d.id === column.id) return newFilterObj;
615
+ return d;
616
+ })) != null ? _old$map : [];
617
+ }
618
+ if (old != null && old.length) return [...old, newFilterObj];
619
+ return [newFilterObj];
620
+ });
621
+ };
622
+ },
623
+ createRow: (row, _table) => {
624
+ row.columnFilters = {};
625
+ row.columnFiltersMeta = {};
626
+ },
627
+ createTable: (table) => {
628
+ table.setColumnFilters = (updater) => {
629
+ const leafColumns = table.getAllLeafColumns();
630
+ const updateFn = (old) => {
631
+ var _functionalUpdate;
632
+ return (_functionalUpdate = functionalUpdate(updater, old)) == null ? void 0 : _functionalUpdate.filter((filter) => {
633
+ const column = leafColumns.find((d) => d.id === filter.id);
634
+ if (column) {
635
+ if (shouldAutoRemoveFilter(column.getFilterFn(), filter.value, column)) return false;
636
+ }
637
+ return true;
638
+ });
639
+ };
640
+ table.options.onColumnFiltersChange == null || table.options.onColumnFiltersChange(updateFn);
641
+ };
642
+ table.resetColumnFilters = (defaultState) => {
643
+ var _table$initialState$c, _table$initialState;
644
+ table.setColumnFilters(defaultState ? [] : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnFilters) != null ? _table$initialState$c : []);
645
+ };
646
+ table.getPreFilteredRowModel = () => table.getCoreRowModel();
647
+ table.getFilteredRowModel = () => {
648
+ if (!table._getFilteredRowModel && table.options.getFilteredRowModel) table._getFilteredRowModel = table.options.getFilteredRowModel(table);
649
+ if (table.options.manualFiltering || !table._getFilteredRowModel) return table.getPreFilteredRowModel();
650
+ return table._getFilteredRowModel();
651
+ };
652
+ }
653
+ };
654
+ function shouldAutoRemoveFilter(filterFn, value, column) {
655
+ return (filterFn && filterFn.autoRemove ? filterFn.autoRemove(value, column) : false) || typeof value === "undefined" || typeof value === "string" && !value;
656
+ }
657
+ var sum = (columnId, _leafRows, childRows) => {
658
+ return childRows.reduce((sum, next) => {
659
+ const nextValue = next.getValue(columnId);
660
+ return sum + (typeof nextValue === "number" ? nextValue : 0);
661
+ }, 0);
662
+ };
663
+ var min = (columnId, _leafRows, childRows) => {
664
+ let min;
665
+ childRows.forEach((row) => {
666
+ const value = row.getValue(columnId);
667
+ if (value != null && (min > value || min === void 0 && value >= value)) min = value;
668
+ });
669
+ return min;
670
+ };
671
+ var max = (columnId, _leafRows, childRows) => {
672
+ let max;
673
+ childRows.forEach((row) => {
674
+ const value = row.getValue(columnId);
675
+ if (value != null && (max < value || max === void 0 && value >= value)) max = value;
676
+ });
677
+ return max;
678
+ };
679
+ var extent = (columnId, _leafRows, childRows) => {
680
+ let min;
681
+ let max;
682
+ childRows.forEach((row) => {
683
+ const value = row.getValue(columnId);
684
+ if (value != null) if (min === void 0) {
685
+ if (value >= value) min = max = value;
686
+ } else {
687
+ if (min > value) min = value;
688
+ if (max < value) max = value;
689
+ }
690
+ });
691
+ return [min, max];
692
+ };
693
+ var mean = (columnId, leafRows) => {
694
+ let count = 0;
695
+ let sum = 0;
696
+ leafRows.forEach((row) => {
697
+ let value = row.getValue(columnId);
698
+ if (value != null && (value = +value) >= value) ++count, sum += value;
699
+ });
700
+ if (count) return sum / count;
701
+ };
702
+ var median = (columnId, leafRows) => {
703
+ if (!leafRows.length) return;
704
+ const values = leafRows.map((row) => row.getValue(columnId));
705
+ if (!isNumberArray(values)) return;
706
+ if (values.length === 1) return values[0];
707
+ const mid = Math.floor(values.length / 2);
708
+ const nums = values.sort((a, b) => a - b);
709
+ return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
710
+ };
711
+ var unique = (columnId, leafRows) => {
712
+ return Array.from(new Set(leafRows.map((d) => d.getValue(columnId))).values());
713
+ };
714
+ var uniqueCount = (columnId, leafRows) => {
715
+ return new Set(leafRows.map((d) => d.getValue(columnId))).size;
716
+ };
717
+ var count = (_columnId, leafRows) => {
718
+ return leafRows.length;
719
+ };
720
+ var aggregationFns = {
721
+ sum,
722
+ min,
723
+ max,
724
+ extent,
725
+ mean,
726
+ median,
727
+ unique,
728
+ uniqueCount,
729
+ count
730
+ };
731
+ var ColumnGrouping = {
732
+ getDefaultColumnDef: () => {
733
+ return {
734
+ aggregatedCell: (props) => {
735
+ var _toString, _props$getValue;
736
+ return (_toString = (_props$getValue = props.getValue()) == null || _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _toString : null;
737
+ },
738
+ aggregationFn: "auto"
739
+ };
740
+ },
741
+ getInitialState: (state) => {
742
+ return {
743
+ grouping: [],
744
+ ...state
745
+ };
746
+ },
747
+ getDefaultOptions: (table) => {
748
+ return {
749
+ onGroupingChange: makeStateUpdater("grouping", table),
750
+ groupedColumnMode: "reorder"
751
+ };
752
+ },
753
+ createColumn: (column, table) => {
754
+ column.toggleGrouping = () => {
755
+ table.setGrouping((old) => {
756
+ if (old != null && old.includes(column.id)) return old.filter((d) => d !== column.id);
757
+ return [...old != null ? old : [], column.id];
758
+ });
759
+ };
760
+ column.getCanGroup = () => {
761
+ var _column$columnDef$ena, _table$options$enable;
762
+ return ((_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGrouping) != null ? _table$options$enable : true) && (!!column.accessorFn || !!column.columnDef.getGroupingValue);
763
+ };
764
+ column.getIsGrouped = () => {
765
+ var _table$getState$group;
766
+ return (_table$getState$group = table.getState().grouping) == null ? void 0 : _table$getState$group.includes(column.id);
767
+ };
768
+ column.getGroupedIndex = () => {
769
+ var _table$getState$group2;
770
+ return (_table$getState$group2 = table.getState().grouping) == null ? void 0 : _table$getState$group2.indexOf(column.id);
771
+ };
772
+ column.getToggleGroupingHandler = () => {
773
+ const canGroup = column.getCanGroup();
774
+ return () => {
775
+ if (!canGroup) return;
776
+ column.toggleGrouping();
777
+ };
778
+ };
779
+ column.getAutoAggregationFn = () => {
780
+ const firstRow = table.getCoreRowModel().flatRows[0];
781
+ const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
782
+ if (typeof value === "number") return aggregationFns.sum;
783
+ if (Object.prototype.toString.call(value) === "[object Date]") return aggregationFns.extent;
784
+ };
785
+ column.getAggregationFn = () => {
786
+ var _table$options$aggreg, _table$options$aggreg2;
787
+ if (!column) throw new Error();
788
+ return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === "auto" ? column.getAutoAggregationFn() : (_table$options$aggreg = (_table$options$aggreg2 = table.options.aggregationFns) == null ? void 0 : _table$options$aggreg2[column.columnDef.aggregationFn]) != null ? _table$options$aggreg : aggregationFns[column.columnDef.aggregationFn];
789
+ };
790
+ },
791
+ createTable: (table) => {
792
+ table.setGrouping = (updater) => table.options.onGroupingChange == null ? void 0 : table.options.onGroupingChange(updater);
793
+ table.resetGrouping = (defaultState) => {
794
+ var _table$initialState$g, _table$initialState;
795
+ table.setGrouping(defaultState ? [] : (_table$initialState$g = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.grouping) != null ? _table$initialState$g : []);
796
+ };
797
+ table.getPreGroupedRowModel = () => table.getFilteredRowModel();
798
+ table.getGroupedRowModel = () => {
799
+ if (!table._getGroupedRowModel && table.options.getGroupedRowModel) table._getGroupedRowModel = table.options.getGroupedRowModel(table);
800
+ if (table.options.manualGrouping || !table._getGroupedRowModel) return table.getPreGroupedRowModel();
801
+ return table._getGroupedRowModel();
802
+ };
803
+ },
804
+ createRow: (row, table) => {
805
+ row.getIsGrouped = () => !!row.groupingColumnId;
806
+ row.getGroupingValue = (columnId) => {
807
+ if (row._groupingValuesCache.hasOwnProperty(columnId)) return row._groupingValuesCache[columnId];
808
+ const column = table.getColumn(columnId);
809
+ if (!(column != null && column.columnDef.getGroupingValue)) return row.getValue(columnId);
810
+ row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(row.original);
811
+ return row._groupingValuesCache[columnId];
812
+ };
813
+ row._groupingValuesCache = {};
814
+ },
815
+ createCell: (cell, column, row, table) => {
816
+ cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
817
+ cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
818
+ cell.getIsAggregated = () => {
819
+ var _row$subRows;
820
+ return !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
821
+ };
822
+ }
823
+ };
824
+ function orderColumns(leafColumns, grouping, groupedColumnMode) {
825
+ if (!(grouping != null && grouping.length) || !groupedColumnMode) return leafColumns;
826
+ const nonGroupingColumns = leafColumns.filter((col) => !grouping.includes(col.id));
827
+ if (groupedColumnMode === "remove") return nonGroupingColumns;
828
+ return [...grouping.map((g) => leafColumns.find((col) => col.id === g)).filter(Boolean), ...nonGroupingColumns];
829
+ }
830
+ var ColumnOrdering = {
831
+ getInitialState: (state) => {
832
+ return {
833
+ columnOrder: [],
834
+ ...state
835
+ };
836
+ },
837
+ getDefaultOptions: (table) => {
838
+ return { onColumnOrderChange: makeStateUpdater("columnOrder", table) };
839
+ },
840
+ createColumn: (column, table) => {
841
+ column.getIndex = memo((position) => [_getVisibleLeafColumns(table, position)], (columns) => columns.findIndex((d) => d.id === column.id), getMemoOptions(table.options, "debugColumns", "getIndex"));
842
+ column.getIsFirstColumn = (position) => {
843
+ var _columns$;
844
+ return ((_columns$ = _getVisibleLeafColumns(table, position)[0]) == null ? void 0 : _columns$.id) === column.id;
845
+ };
846
+ column.getIsLastColumn = (position) => {
847
+ var _columns;
848
+ const columns = _getVisibleLeafColumns(table, position);
849
+ return ((_columns = columns[columns.length - 1]) == null ? void 0 : _columns.id) === column.id;
850
+ };
851
+ },
852
+ createTable: (table) => {
853
+ table.setColumnOrder = (updater) => table.options.onColumnOrderChange == null ? void 0 : table.options.onColumnOrderChange(updater);
854
+ table.resetColumnOrder = (defaultState) => {
855
+ var _table$initialState$c;
856
+ table.setColumnOrder(defaultState ? [] : (_table$initialState$c = table.initialState.columnOrder) != null ? _table$initialState$c : []);
857
+ };
858
+ table._getOrderColumnsFn = memo(() => [
859
+ table.getState().columnOrder,
860
+ table.getState().grouping,
861
+ table.options.groupedColumnMode
862
+ ], (columnOrder, grouping, groupedColumnMode) => (columns) => {
863
+ let orderedColumns = [];
864
+ if (!(columnOrder != null && columnOrder.length)) orderedColumns = columns;
865
+ else {
866
+ const columnOrderCopy = [...columnOrder];
867
+ const columnsCopy = [...columns];
868
+ while (columnsCopy.length && columnOrderCopy.length) {
869
+ const targetColumnId = columnOrderCopy.shift();
870
+ const foundIndex = columnsCopy.findIndex((d) => d.id === targetColumnId);
871
+ if (foundIndex > -1) orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]);
872
+ }
873
+ orderedColumns = [...orderedColumns, ...columnsCopy];
874
+ }
875
+ return orderColumns(orderedColumns, grouping, groupedColumnMode);
876
+ }, getMemoOptions(table.options, "debugTable", "_getOrderColumnsFn"));
877
+ }
878
+ };
879
+ var getDefaultColumnPinningState = () => ({
880
+ left: [],
881
+ right: []
882
+ });
883
+ var ColumnPinning = {
884
+ getInitialState: (state) => {
885
+ return {
886
+ columnPinning: getDefaultColumnPinningState(),
887
+ ...state
888
+ };
889
+ },
890
+ getDefaultOptions: (table) => {
891
+ return { onColumnPinningChange: makeStateUpdater("columnPinning", table) };
892
+ },
893
+ createColumn: (column, table) => {
894
+ column.pin = (position) => {
895
+ const columnIds = column.getLeafColumns().map((d) => d.id).filter(Boolean);
896
+ table.setColumnPinning((old) => {
897
+ var _old$left3, _old$right3;
898
+ if (position === "right") {
899
+ var _old$left, _old$right;
900
+ return {
901
+ left: ((_old$left = old == null ? void 0 : old.left) != null ? _old$left : []).filter((d) => !(columnIds != null && columnIds.includes(d))),
902
+ right: [...((_old$right = old == null ? void 0 : old.right) != null ? _old$right : []).filter((d) => !(columnIds != null && columnIds.includes(d))), ...columnIds]
903
+ };
904
+ }
905
+ if (position === "left") {
906
+ var _old$left2, _old$right2;
907
+ return {
908
+ left: [...((_old$left2 = old == null ? void 0 : old.left) != null ? _old$left2 : []).filter((d) => !(columnIds != null && columnIds.includes(d))), ...columnIds],
909
+ right: ((_old$right2 = old == null ? void 0 : old.right) != null ? _old$right2 : []).filter((d) => !(columnIds != null && columnIds.includes(d)))
910
+ };
911
+ }
912
+ return {
913
+ left: ((_old$left3 = old == null ? void 0 : old.left) != null ? _old$left3 : []).filter((d) => !(columnIds != null && columnIds.includes(d))),
914
+ right: ((_old$right3 = old == null ? void 0 : old.right) != null ? _old$right3 : []).filter((d) => !(columnIds != null && columnIds.includes(d)))
915
+ };
916
+ });
917
+ };
918
+ column.getCanPin = () => {
919
+ return column.getLeafColumns().some((d) => {
920
+ var _d$columnDef$enablePi, _ref, _table$options$enable;
921
+ return ((_d$columnDef$enablePi = d.columnDef.enablePinning) != null ? _d$columnDef$enablePi : true) && ((_ref = (_table$options$enable = table.options.enableColumnPinning) != null ? _table$options$enable : table.options.enablePinning) != null ? _ref : true);
922
+ });
923
+ };
924
+ column.getIsPinned = () => {
925
+ const leafColumnIds = column.getLeafColumns().map((d) => d.id);
926
+ const { left, right } = table.getState().columnPinning;
927
+ const isLeft = leafColumnIds.some((d) => left == null ? void 0 : left.includes(d));
928
+ const isRight = leafColumnIds.some((d) => right == null ? void 0 : right.includes(d));
929
+ return isLeft ? "left" : isRight ? "right" : false;
930
+ };
931
+ column.getPinnedIndex = () => {
932
+ var _table$getState$colum, _table$getState$colum2;
933
+ const position = column.getIsPinned();
934
+ return position ? (_table$getState$colum = (_table$getState$colum2 = table.getState().columnPinning) == null || (_table$getState$colum2 = _table$getState$colum2[position]) == null ? void 0 : _table$getState$colum2.indexOf(column.id)) != null ? _table$getState$colum : -1 : 0;
935
+ };
936
+ },
937
+ createRow: (row, table) => {
938
+ row.getCenterVisibleCells = memo(() => [
939
+ row._getAllVisibleCells(),
940
+ table.getState().columnPinning.left,
941
+ table.getState().columnPinning.right
942
+ ], (allCells, left, right) => {
943
+ const leftAndRight = [...left != null ? left : [], ...right != null ? right : []];
944
+ return allCells.filter((d) => !leftAndRight.includes(d.column.id));
945
+ }, getMemoOptions(table.options, "debugRows", "getCenterVisibleCells"));
946
+ row.getLeftVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.left], (allCells, left) => {
947
+ return (left != null ? left : []).map((columnId) => allCells.find((cell) => cell.column.id === columnId)).filter(Boolean).map((d) => ({
948
+ ...d,
949
+ position: "left"
950
+ }));
951
+ }, getMemoOptions(table.options, "debugRows", "getLeftVisibleCells"));
952
+ row.getRightVisibleCells = memo(() => [row._getAllVisibleCells(), table.getState().columnPinning.right], (allCells, right) => {
953
+ return (right != null ? right : []).map((columnId) => allCells.find((cell) => cell.column.id === columnId)).filter(Boolean).map((d) => ({
954
+ ...d,
955
+ position: "right"
956
+ }));
957
+ }, getMemoOptions(table.options, "debugRows", "getRightVisibleCells"));
958
+ },
959
+ createTable: (table) => {
960
+ table.setColumnPinning = (updater) => table.options.onColumnPinningChange == null ? void 0 : table.options.onColumnPinningChange(updater);
961
+ table.resetColumnPinning = (defaultState) => {
962
+ var _table$initialState$c, _table$initialState;
963
+ return table.setColumnPinning(defaultState ? getDefaultColumnPinningState() : (_table$initialState$c = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.columnPinning) != null ? _table$initialState$c : getDefaultColumnPinningState());
964
+ };
965
+ table.getIsSomeColumnsPinned = (position) => {
966
+ var _pinningState$positio;
967
+ const pinningState = table.getState().columnPinning;
968
+ if (!position) {
969
+ var _pinningState$left, _pinningState$right;
970
+ return Boolean(((_pinningState$left = pinningState.left) == null ? void 0 : _pinningState$left.length) || ((_pinningState$right = pinningState.right) == null ? void 0 : _pinningState$right.length));
971
+ }
972
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
973
+ };
974
+ table.getLeftLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.left], (allColumns, left) => {
975
+ return (left != null ? left : []).map((columnId) => allColumns.find((column) => column.id === columnId)).filter(Boolean);
976
+ }, getMemoOptions(table.options, "debugColumns", "getLeftLeafColumns"));
977
+ table.getRightLeafColumns = memo(() => [table.getAllLeafColumns(), table.getState().columnPinning.right], (allColumns, right) => {
978
+ return (right != null ? right : []).map((columnId) => allColumns.find((column) => column.id === columnId)).filter(Boolean);
979
+ }, getMemoOptions(table.options, "debugColumns", "getRightLeafColumns"));
980
+ table.getCenterLeafColumns = memo(() => [
981
+ table.getAllLeafColumns(),
982
+ table.getState().columnPinning.left,
983
+ table.getState().columnPinning.right
984
+ ], (allColumns, left, right) => {
985
+ const leftAndRight = [...left != null ? left : [], ...right != null ? right : []];
986
+ return allColumns.filter((d) => !leftAndRight.includes(d.id));
987
+ }, getMemoOptions(table.options, "debugColumns", "getCenterLeafColumns"));
988
+ }
989
+ };
990
+ function safelyAccessDocument(_document) {
991
+ return _document || (typeof document !== "undefined" ? document : null);
992
+ }
993
+ var defaultColumnSizing = {
994
+ size: 150,
995
+ minSize: 20,
996
+ maxSize: Number.MAX_SAFE_INTEGER
997
+ };
998
+ var getDefaultColumnSizingInfoState = () => ({
999
+ startOffset: null,
1000
+ startSize: null,
1001
+ deltaOffset: null,
1002
+ deltaPercentage: null,
1003
+ isResizingColumn: false,
1004
+ columnSizingStart: []
1005
+ });
1006
+ var ColumnSizing = {
1007
+ getDefaultColumnDef: () => {
1008
+ return defaultColumnSizing;
1009
+ },
1010
+ getInitialState: (state) => {
1011
+ return {
1012
+ columnSizing: {},
1013
+ columnSizingInfo: getDefaultColumnSizingInfoState(),
1014
+ ...state
1015
+ };
1016
+ },
1017
+ getDefaultOptions: (table) => {
1018
+ return {
1019
+ columnResizeMode: "onEnd",
1020
+ columnResizeDirection: "ltr",
1021
+ onColumnSizingChange: makeStateUpdater("columnSizing", table),
1022
+ onColumnSizingInfoChange: makeStateUpdater("columnSizingInfo", table)
1023
+ };
1024
+ },
1025
+ createColumn: (column, table) => {
1026
+ column.getSize = () => {
1027
+ var _column$columnDef$min, _ref, _column$columnDef$max;
1028
+ const columnSize = table.getState().columnSizing[column.id];
1029
+ return Math.min(Math.max((_column$columnDef$min = column.columnDef.minSize) != null ? _column$columnDef$min : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.columnDef.size) != null ? _ref : defaultColumnSizing.size), (_column$columnDef$max = column.columnDef.maxSize) != null ? _column$columnDef$max : defaultColumnSizing.maxSize);
1030
+ };
1031
+ column.getStart = memo((position) => [
1032
+ position,
1033
+ _getVisibleLeafColumns(table, position),
1034
+ table.getState().columnSizing
1035
+ ], (position, columns) => columns.slice(0, column.getIndex(position)).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, "debugColumns", "getStart"));
1036
+ column.getAfter = memo((position) => [
1037
+ position,
1038
+ _getVisibleLeafColumns(table, position),
1039
+ table.getState().columnSizing
1040
+ ], (position, columns) => columns.slice(column.getIndex(position) + 1).reduce((sum, column) => sum + column.getSize(), 0), getMemoOptions(table.options, "debugColumns", "getAfter"));
1041
+ column.resetSize = () => {
1042
+ table.setColumnSizing((_ref2) => {
1043
+ let { [column.id]: _, ...rest } = _ref2;
1044
+ return rest;
1045
+ });
1046
+ };
1047
+ column.getCanResize = () => {
1048
+ var _column$columnDef$ena, _table$options$enable;
1049
+ return ((_column$columnDef$ena = column.columnDef.enableResizing) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableColumnResizing) != null ? _table$options$enable : true);
1050
+ };
1051
+ column.getIsResizing = () => {
1052
+ return table.getState().columnSizingInfo.isResizingColumn === column.id;
1053
+ };
1054
+ },
1055
+ createHeader: (header, table) => {
1056
+ header.getSize = () => {
1057
+ let sum = 0;
1058
+ const recurse = (header) => {
1059
+ if (header.subHeaders.length) header.subHeaders.forEach(recurse);
1060
+ else {
1061
+ var _header$column$getSiz;
1062
+ sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
1063
+ }
1064
+ };
1065
+ recurse(header);
1066
+ return sum;
1067
+ };
1068
+ header.getStart = () => {
1069
+ if (header.index > 0) {
1070
+ const prevSiblingHeader = header.headerGroup.headers[header.index - 1];
1071
+ return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
1072
+ }
1073
+ return 0;
1074
+ };
1075
+ header.getResizeHandler = (_contextDocument) => {
1076
+ const column = table.getColumn(header.column.id);
1077
+ const canResize = column == null ? void 0 : column.getCanResize();
1078
+ return (e) => {
1079
+ if (!column || !canResize) return;
1080
+ e.persist == null || e.persist();
1081
+ if (isTouchStartEvent(e)) {
1082
+ if (e.touches && e.touches.length > 1) return;
1083
+ }
1084
+ const startSize = header.getSize();
1085
+ const columnSizingStart = header ? header.getLeafHeaders().map((d) => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
1086
+ const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
1087
+ const newColumnSizing = {};
1088
+ const updateOffset = (eventType, clientXPos) => {
1089
+ if (typeof clientXPos !== "number") return;
1090
+ table.setColumnSizingInfo((old) => {
1091
+ var _old$startOffset, _old$startSize;
1092
+ const deltaDirection = table.options.columnResizeDirection === "rtl" ? -1 : 1;
1093
+ const deltaOffset = (clientXPos - ((_old$startOffset = old == null ? void 0 : old.startOffset) != null ? _old$startOffset : 0)) * deltaDirection;
1094
+ const deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -.999999);
1095
+ old.columnSizingStart.forEach((_ref3) => {
1096
+ let [columnId, headerSize] = _ref3;
1097
+ newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
1098
+ });
1099
+ return {
1100
+ ...old,
1101
+ deltaOffset,
1102
+ deltaPercentage
1103
+ };
1104
+ });
1105
+ if (table.options.columnResizeMode === "onChange" || eventType === "end") table.setColumnSizing((old) => ({
1106
+ ...old,
1107
+ ...newColumnSizing
1108
+ }));
1109
+ };
1110
+ const onMove = (clientXPos) => updateOffset("move", clientXPos);
1111
+ const onEnd = (clientXPos) => {
1112
+ updateOffset("end", clientXPos);
1113
+ table.setColumnSizingInfo((old) => ({
1114
+ ...old,
1115
+ isResizingColumn: false,
1116
+ startOffset: null,
1117
+ startSize: null,
1118
+ deltaOffset: null,
1119
+ deltaPercentage: null,
1120
+ columnSizingStart: []
1121
+ }));
1122
+ };
1123
+ const contextDocument = safelyAccessDocument(_contextDocument);
1124
+ const mouseEvents = {
1125
+ moveHandler: (e) => onMove(e.clientX),
1126
+ upHandler: (e) => {
1127
+ contextDocument?.removeEventListener("mousemove", mouseEvents.moveHandler);
1128
+ contextDocument?.removeEventListener("mouseup", mouseEvents.upHandler);
1129
+ onEnd(e.clientX);
1130
+ }
1131
+ };
1132
+ const touchEvents = {
1133
+ moveHandler: (e) => {
1134
+ if (e.cancelable) {
1135
+ e.preventDefault();
1136
+ e.stopPropagation();
1137
+ }
1138
+ onMove(e.touches[0].clientX);
1139
+ return false;
1140
+ },
1141
+ upHandler: (e) => {
1142
+ var _e$touches$;
1143
+ contextDocument?.removeEventListener("touchmove", touchEvents.moveHandler);
1144
+ contextDocument?.removeEventListener("touchend", touchEvents.upHandler);
1145
+ if (e.cancelable) {
1146
+ e.preventDefault();
1147
+ e.stopPropagation();
1148
+ }
1149
+ onEnd((_e$touches$ = e.touches[0]) == null ? void 0 : _e$touches$.clientX);
1150
+ }
1151
+ };
1152
+ const passiveIfSupported = passiveEventSupported() ? { passive: false } : false;
1153
+ if (isTouchStartEvent(e)) {
1154
+ contextDocument?.addEventListener("touchmove", touchEvents.moveHandler, passiveIfSupported);
1155
+ contextDocument?.addEventListener("touchend", touchEvents.upHandler, passiveIfSupported);
1156
+ } else {
1157
+ contextDocument?.addEventListener("mousemove", mouseEvents.moveHandler, passiveIfSupported);
1158
+ contextDocument?.addEventListener("mouseup", mouseEvents.upHandler, passiveIfSupported);
1159
+ }
1160
+ table.setColumnSizingInfo((old) => ({
1161
+ ...old,
1162
+ startOffset: clientX,
1163
+ startSize,
1164
+ deltaOffset: 0,
1165
+ deltaPercentage: 0,
1166
+ columnSizingStart,
1167
+ isResizingColumn: column.id
1168
+ }));
1169
+ };
1170
+ };
1171
+ },
1172
+ createTable: (table) => {
1173
+ table.setColumnSizing = (updater) => table.options.onColumnSizingChange == null ? void 0 : table.options.onColumnSizingChange(updater);
1174
+ table.setColumnSizingInfo = (updater) => table.options.onColumnSizingInfoChange == null ? void 0 : table.options.onColumnSizingInfoChange(updater);
1175
+ table.resetColumnSizing = (defaultState) => {
1176
+ var _table$initialState$c;
1177
+ table.setColumnSizing(defaultState ? {} : (_table$initialState$c = table.initialState.columnSizing) != null ? _table$initialState$c : {});
1178
+ };
1179
+ table.resetHeaderSizeInfo = (defaultState) => {
1180
+ var _table$initialState$c2;
1181
+ table.setColumnSizingInfo(defaultState ? getDefaultColumnSizingInfoState() : (_table$initialState$c2 = table.initialState.columnSizingInfo) != null ? _table$initialState$c2 : getDefaultColumnSizingInfoState());
1182
+ };
1183
+ table.getTotalSize = () => {
1184
+ var _table$getHeaderGroup, _table$getHeaderGroup2;
1185
+ return (_table$getHeaderGroup = (_table$getHeaderGroup2 = table.getHeaderGroups()[0]) == null ? void 0 : _table$getHeaderGroup2.headers.reduce((sum, header) => {
1186
+ return sum + header.getSize();
1187
+ }, 0)) != null ? _table$getHeaderGroup : 0;
1188
+ };
1189
+ table.getLeftTotalSize = () => {
1190
+ var _table$getLeftHeaderG, _table$getLeftHeaderG2;
1191
+ return (_table$getLeftHeaderG = (_table$getLeftHeaderG2 = table.getLeftHeaderGroups()[0]) == null ? void 0 : _table$getLeftHeaderG2.headers.reduce((sum, header) => {
1192
+ return sum + header.getSize();
1193
+ }, 0)) != null ? _table$getLeftHeaderG : 0;
1194
+ };
1195
+ table.getCenterTotalSize = () => {
1196
+ var _table$getCenterHeade, _table$getCenterHeade2;
1197
+ return (_table$getCenterHeade = (_table$getCenterHeade2 = table.getCenterHeaderGroups()[0]) == null ? void 0 : _table$getCenterHeade2.headers.reduce((sum, header) => {
1198
+ return sum + header.getSize();
1199
+ }, 0)) != null ? _table$getCenterHeade : 0;
1200
+ };
1201
+ table.getRightTotalSize = () => {
1202
+ var _table$getRightHeader, _table$getRightHeader2;
1203
+ return (_table$getRightHeader = (_table$getRightHeader2 = table.getRightHeaderGroups()[0]) == null ? void 0 : _table$getRightHeader2.headers.reduce((sum, header) => {
1204
+ return sum + header.getSize();
1205
+ }, 0)) != null ? _table$getRightHeader : 0;
1206
+ };
1207
+ }
1208
+ };
1209
+ var passiveSupported = null;
1210
+ function passiveEventSupported() {
1211
+ if (typeof passiveSupported === "boolean") return passiveSupported;
1212
+ let supported = false;
1213
+ try {
1214
+ const options = { get passive() {
1215
+ supported = true;
1216
+ return false;
1217
+ } };
1218
+ const noop = () => {};
1219
+ window.addEventListener("test", noop, options);
1220
+ window.removeEventListener("test", noop);
1221
+ } catch (err) {
1222
+ supported = false;
1223
+ }
1224
+ passiveSupported = supported;
1225
+ return passiveSupported;
1226
+ }
1227
+ function isTouchStartEvent(e) {
1228
+ return e.type === "touchstart";
1229
+ }
1230
+ var ColumnVisibility = {
1231
+ getInitialState: (state) => {
1232
+ return {
1233
+ columnVisibility: {},
1234
+ ...state
1235
+ };
1236
+ },
1237
+ getDefaultOptions: (table) => {
1238
+ return { onColumnVisibilityChange: makeStateUpdater("columnVisibility", table) };
1239
+ },
1240
+ createColumn: (column, table) => {
1241
+ column.toggleVisibility = (value) => {
1242
+ if (column.getCanHide()) table.setColumnVisibility((old) => ({
1243
+ ...old,
1244
+ [column.id]: value != null ? value : !column.getIsVisible()
1245
+ }));
1246
+ };
1247
+ column.getIsVisible = () => {
1248
+ var _ref, _table$getState$colum;
1249
+ const childColumns = column.columns;
1250
+ return (_ref = childColumns.length ? childColumns.some((c) => c.getIsVisible()) : (_table$getState$colum = table.getState().columnVisibility) == null ? void 0 : _table$getState$colum[column.id]) != null ? _ref : true;
1251
+ };
1252
+ column.getCanHide = () => {
1253
+ var _column$columnDef$ena, _table$options$enable;
1254
+ return ((_column$columnDef$ena = column.columnDef.enableHiding) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableHiding) != null ? _table$options$enable : true);
1255
+ };
1256
+ column.getToggleVisibilityHandler = () => {
1257
+ return (e) => {
1258
+ column.toggleVisibility == null || column.toggleVisibility(e.target.checked);
1259
+ };
1260
+ };
1261
+ },
1262
+ createRow: (row, table) => {
1263
+ row._getAllVisibleCells = memo(() => [row.getAllCells(), table.getState().columnVisibility], (cells) => {
1264
+ return cells.filter((cell) => cell.column.getIsVisible());
1265
+ }, getMemoOptions(table.options, "debugRows", "_getAllVisibleCells"));
1266
+ row.getVisibleCells = memo(() => [
1267
+ row.getLeftVisibleCells(),
1268
+ row.getCenterVisibleCells(),
1269
+ row.getRightVisibleCells()
1270
+ ], (left, center, right) => [
1271
+ ...left,
1272
+ ...center,
1273
+ ...right
1274
+ ], getMemoOptions(table.options, "debugRows", "getVisibleCells"));
1275
+ },
1276
+ createTable: (table) => {
1277
+ const makeVisibleColumnsMethod = (key, getColumns) => {
1278
+ return memo(() => [getColumns(), getColumns().filter((d) => d.getIsVisible()).map((d) => d.id).join("_")], (columns) => {
1279
+ return columns.filter((d) => d.getIsVisible == null ? void 0 : d.getIsVisible());
1280
+ }, getMemoOptions(table.options, "debugColumns", key));
1281
+ };
1282
+ table.getVisibleFlatColumns = makeVisibleColumnsMethod("getVisibleFlatColumns", () => table.getAllFlatColumns());
1283
+ table.getVisibleLeafColumns = makeVisibleColumnsMethod("getVisibleLeafColumns", () => table.getAllLeafColumns());
1284
+ table.getLeftVisibleLeafColumns = makeVisibleColumnsMethod("getLeftVisibleLeafColumns", () => table.getLeftLeafColumns());
1285
+ table.getRightVisibleLeafColumns = makeVisibleColumnsMethod("getRightVisibleLeafColumns", () => table.getRightLeafColumns());
1286
+ table.getCenterVisibleLeafColumns = makeVisibleColumnsMethod("getCenterVisibleLeafColumns", () => table.getCenterLeafColumns());
1287
+ table.setColumnVisibility = (updater) => table.options.onColumnVisibilityChange == null ? void 0 : table.options.onColumnVisibilityChange(updater);
1288
+ table.resetColumnVisibility = (defaultState) => {
1289
+ var _table$initialState$c;
1290
+ table.setColumnVisibility(defaultState ? {} : (_table$initialState$c = table.initialState.columnVisibility) != null ? _table$initialState$c : {});
1291
+ };
1292
+ table.toggleAllColumnsVisible = (value) => {
1293
+ var _value;
1294
+ value = (_value = value) != null ? _value : !table.getIsAllColumnsVisible();
1295
+ table.setColumnVisibility(table.getAllLeafColumns().reduce((obj, column) => ({
1296
+ ...obj,
1297
+ [column.id]: !value ? !(column.getCanHide != null && column.getCanHide()) : value
1298
+ }), {}));
1299
+ };
1300
+ table.getIsAllColumnsVisible = () => !table.getAllLeafColumns().some((column) => !(column.getIsVisible != null && column.getIsVisible()));
1301
+ table.getIsSomeColumnsVisible = () => table.getAllLeafColumns().some((column) => column.getIsVisible == null ? void 0 : column.getIsVisible());
1302
+ table.getToggleAllColumnsVisibilityHandler = () => {
1303
+ return (e) => {
1304
+ var _target;
1305
+ table.toggleAllColumnsVisible((_target = e.target) == null ? void 0 : _target.checked);
1306
+ };
1307
+ };
1308
+ }
1309
+ };
1310
+ function _getVisibleLeafColumns(table, position) {
1311
+ return !position ? table.getVisibleLeafColumns() : position === "center" ? table.getCenterVisibleLeafColumns() : position === "left" ? table.getLeftVisibleLeafColumns() : table.getRightVisibleLeafColumns();
1312
+ }
1313
+ var GlobalFaceting = { createTable: (table) => {
1314
+ table._getGlobalFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, "__global__");
1315
+ table.getGlobalFacetedRowModel = () => {
1316
+ if (table.options.manualFiltering || !table._getGlobalFacetedRowModel) return table.getPreFilteredRowModel();
1317
+ return table._getGlobalFacetedRowModel();
1318
+ };
1319
+ table._getGlobalFacetedUniqueValues = table.options.getFacetedUniqueValues && table.options.getFacetedUniqueValues(table, "__global__");
1320
+ table.getGlobalFacetedUniqueValues = () => {
1321
+ if (!table._getGlobalFacetedUniqueValues) return /* @__PURE__ */ new Map();
1322
+ return table._getGlobalFacetedUniqueValues();
1323
+ };
1324
+ table._getGlobalFacetedMinMaxValues = table.options.getFacetedMinMaxValues && table.options.getFacetedMinMaxValues(table, "__global__");
1325
+ table.getGlobalFacetedMinMaxValues = () => {
1326
+ if (!table._getGlobalFacetedMinMaxValues) return;
1327
+ return table._getGlobalFacetedMinMaxValues();
1328
+ };
1329
+ } };
1330
+ var GlobalFiltering = {
1331
+ getInitialState: (state) => {
1332
+ return {
1333
+ globalFilter: void 0,
1334
+ ...state
1335
+ };
1336
+ },
1337
+ getDefaultOptions: (table) => {
1338
+ return {
1339
+ onGlobalFilterChange: makeStateUpdater("globalFilter", table),
1340
+ globalFilterFn: "auto",
1341
+ getColumnCanGlobalFilter: (column) => {
1342
+ var _table$getCoreRowMode;
1343
+ const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null || (_table$getCoreRowMode = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode.getValue();
1344
+ return typeof value === "string" || typeof value === "number";
1345
+ }
1346
+ };
1347
+ },
1348
+ createColumn: (column, table) => {
1349
+ column.getCanGlobalFilter = () => {
1350
+ var _column$columnDef$ena, _table$options$enable, _table$options$enable2, _table$options$getCol;
1351
+ return ((_column$columnDef$ena = column.columnDef.enableGlobalFilter) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGlobalFilter) != null ? _table$options$enable : true) && ((_table$options$enable2 = table.options.enableFilters) != null ? _table$options$enable2 : true) && ((_table$options$getCol = table.options.getColumnCanGlobalFilter == null ? void 0 : table.options.getColumnCanGlobalFilter(column)) != null ? _table$options$getCol : true) && !!column.accessorFn;
1352
+ };
1353
+ },
1354
+ createTable: (table) => {
1355
+ table.getGlobalAutoFilterFn = () => {
1356
+ return filterFns.includesString;
1357
+ };
1358
+ table.getGlobalFilterFn = () => {
1359
+ var _table$options$filter, _table$options$filter2;
1360
+ const { globalFilterFn } = table.options;
1361
+ return isFunction(globalFilterFn) ? globalFilterFn : globalFilterFn === "auto" ? table.getGlobalAutoFilterFn() : (_table$options$filter = (_table$options$filter2 = table.options.filterFns) == null ? void 0 : _table$options$filter2[globalFilterFn]) != null ? _table$options$filter : filterFns[globalFilterFn];
1362
+ };
1363
+ table.setGlobalFilter = (updater) => {
1364
+ table.options.onGlobalFilterChange == null || table.options.onGlobalFilterChange(updater);
1365
+ };
1366
+ table.resetGlobalFilter = (defaultState) => {
1367
+ table.setGlobalFilter(defaultState ? void 0 : table.initialState.globalFilter);
1368
+ };
1369
+ }
1370
+ };
1371
+ var RowExpanding = {
1372
+ getInitialState: (state) => {
1373
+ return {
1374
+ expanded: {},
1375
+ ...state
1376
+ };
1377
+ },
1378
+ getDefaultOptions: (table) => {
1379
+ return {
1380
+ onExpandedChange: makeStateUpdater("expanded", table),
1381
+ paginateExpandedRows: true
1382
+ };
1383
+ },
1384
+ createTable: (table) => {
1385
+ let registered = false;
1386
+ let queued = false;
1387
+ table._autoResetExpanded = () => {
1388
+ var _ref, _table$options$autoRe;
1389
+ if (!registered) {
1390
+ table._queue(() => {
1391
+ registered = true;
1392
+ });
1393
+ return;
1394
+ }
1395
+ if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetExpanded) != null ? _ref : !table.options.manualExpanding) {
1396
+ if (queued) return;
1397
+ queued = true;
1398
+ table._queue(() => {
1399
+ table.resetExpanded();
1400
+ queued = false;
1401
+ });
1402
+ }
1403
+ };
1404
+ table.setExpanded = (updater) => table.options.onExpandedChange == null ? void 0 : table.options.onExpandedChange(updater);
1405
+ table.toggleAllRowsExpanded = (expanded) => {
1406
+ if (expanded != null ? expanded : !table.getIsAllRowsExpanded()) table.setExpanded(true);
1407
+ else table.setExpanded({});
1408
+ };
1409
+ table.resetExpanded = (defaultState) => {
1410
+ var _table$initialState$e, _table$initialState;
1411
+ table.setExpanded(defaultState ? {} : (_table$initialState$e = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.expanded) != null ? _table$initialState$e : {});
1412
+ };
1413
+ table.getCanSomeRowsExpand = () => {
1414
+ return table.getPrePaginationRowModel().flatRows.some((row) => row.getCanExpand());
1415
+ };
1416
+ table.getToggleAllRowsExpandedHandler = () => {
1417
+ return (e) => {
1418
+ e.persist == null || e.persist();
1419
+ table.toggleAllRowsExpanded();
1420
+ };
1421
+ };
1422
+ table.getIsSomeRowsExpanded = () => {
1423
+ const expanded = table.getState().expanded;
1424
+ return expanded === true || Object.values(expanded).some(Boolean);
1425
+ };
1426
+ table.getIsAllRowsExpanded = () => {
1427
+ const expanded = table.getState().expanded;
1428
+ if (typeof expanded === "boolean") return expanded === true;
1429
+ if (!Object.keys(expanded).length) return false;
1430
+ if (table.getRowModel().flatRows.some((row) => !row.getIsExpanded())) return false;
1431
+ return true;
1432
+ };
1433
+ table.getExpandedDepth = () => {
1434
+ let maxDepth = 0;
1435
+ (table.getState().expanded === true ? Object.keys(table.getRowModel().rowsById) : Object.keys(table.getState().expanded)).forEach((id) => {
1436
+ const splitId = id.split(".");
1437
+ maxDepth = Math.max(maxDepth, splitId.length);
1438
+ });
1439
+ return maxDepth;
1440
+ };
1441
+ table.getPreExpandedRowModel = () => table.getSortedRowModel();
1442
+ table.getExpandedRowModel = () => {
1443
+ if (!table._getExpandedRowModel && table.options.getExpandedRowModel) table._getExpandedRowModel = table.options.getExpandedRowModel(table);
1444
+ if (table.options.manualExpanding || !table._getExpandedRowModel) return table.getPreExpandedRowModel();
1445
+ return table._getExpandedRowModel();
1446
+ };
1447
+ },
1448
+ createRow: (row, table) => {
1449
+ row.toggleExpanded = (expanded) => {
1450
+ table.setExpanded((old) => {
1451
+ var _expanded;
1452
+ const exists = old === true ? true : !!(old != null && old[row.id]);
1453
+ let oldExpanded = {};
1454
+ if (old === true) Object.keys(table.getRowModel().rowsById).forEach((rowId) => {
1455
+ oldExpanded[rowId] = true;
1456
+ });
1457
+ else oldExpanded = old;
1458
+ expanded = (_expanded = expanded) != null ? _expanded : !exists;
1459
+ if (!exists && expanded) return {
1460
+ ...oldExpanded,
1461
+ [row.id]: true
1462
+ };
1463
+ if (exists && !expanded) {
1464
+ const { [row.id]: _, ...rest } = oldExpanded;
1465
+ return rest;
1466
+ }
1467
+ return old;
1468
+ });
1469
+ };
1470
+ row.getIsExpanded = () => {
1471
+ var _table$options$getIsR;
1472
+ const expanded = table.getState().expanded;
1473
+ return !!((_table$options$getIsR = table.options.getIsRowExpanded == null ? void 0 : table.options.getIsRowExpanded(row)) != null ? _table$options$getIsR : expanded === true || (expanded == null ? void 0 : expanded[row.id]));
1474
+ };
1475
+ row.getCanExpand = () => {
1476
+ var _table$options$getRow, _table$options$enable, _row$subRows;
1477
+ return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
1478
+ };
1479
+ row.getIsAllParentsExpanded = () => {
1480
+ let isFullyExpanded = true;
1481
+ let currentRow = row;
1482
+ while (isFullyExpanded && currentRow.parentId) {
1483
+ currentRow = table.getRow(currentRow.parentId, true);
1484
+ isFullyExpanded = currentRow.getIsExpanded();
1485
+ }
1486
+ return isFullyExpanded;
1487
+ };
1488
+ row.getToggleExpandedHandler = () => {
1489
+ const canExpand = row.getCanExpand();
1490
+ return () => {
1491
+ if (!canExpand) return;
1492
+ row.toggleExpanded();
1493
+ };
1494
+ };
1495
+ }
1496
+ };
1497
+ var defaultPageIndex = 0;
1498
+ var defaultPageSize = 10;
1499
+ var getDefaultPaginationState = () => ({
1500
+ pageIndex: defaultPageIndex,
1501
+ pageSize: defaultPageSize
1502
+ });
1503
+ var RowPagination = {
1504
+ getInitialState: (state) => {
1505
+ return {
1506
+ ...state,
1507
+ pagination: {
1508
+ ...getDefaultPaginationState(),
1509
+ ...state == null ? void 0 : state.pagination
1510
+ }
1511
+ };
1512
+ },
1513
+ getDefaultOptions: (table) => {
1514
+ return { onPaginationChange: makeStateUpdater("pagination", table) };
1515
+ },
1516
+ createTable: (table) => {
1517
+ let registered = false;
1518
+ let queued = false;
1519
+ table._autoResetPageIndex = () => {
1520
+ var _ref, _table$options$autoRe;
1521
+ if (!registered) {
1522
+ table._queue(() => {
1523
+ registered = true;
1524
+ });
1525
+ return;
1526
+ }
1527
+ if ((_ref = (_table$options$autoRe = table.options.autoResetAll) != null ? _table$options$autoRe : table.options.autoResetPageIndex) != null ? _ref : !table.options.manualPagination) {
1528
+ if (queued) return;
1529
+ queued = true;
1530
+ table._queue(() => {
1531
+ table.resetPageIndex();
1532
+ queued = false;
1533
+ });
1534
+ }
1535
+ };
1536
+ table.setPagination = (updater) => {
1537
+ const safeUpdater = (old) => {
1538
+ return functionalUpdate(updater, old);
1539
+ };
1540
+ return table.options.onPaginationChange == null ? void 0 : table.options.onPaginationChange(safeUpdater);
1541
+ };
1542
+ table.resetPagination = (defaultState) => {
1543
+ var _table$initialState$p;
1544
+ table.setPagination(defaultState ? getDefaultPaginationState() : (_table$initialState$p = table.initialState.pagination) != null ? _table$initialState$p : getDefaultPaginationState());
1545
+ };
1546
+ table.setPageIndex = (updater) => {
1547
+ table.setPagination((old) => {
1548
+ let pageIndex = functionalUpdate(updater, old.pageIndex);
1549
+ const maxPageIndex = typeof table.options.pageCount === "undefined" || table.options.pageCount === -1 ? Number.MAX_SAFE_INTEGER : table.options.pageCount - 1;
1550
+ pageIndex = Math.max(0, Math.min(pageIndex, maxPageIndex));
1551
+ return {
1552
+ ...old,
1553
+ pageIndex
1554
+ };
1555
+ });
1556
+ };
1557
+ table.resetPageIndex = (defaultState) => {
1558
+ var _table$initialState$p2, _table$initialState;
1559
+ table.setPageIndex(defaultState ? defaultPageIndex : (_table$initialState$p2 = (_table$initialState = table.initialState) == null || (_table$initialState = _table$initialState.pagination) == null ? void 0 : _table$initialState.pageIndex) != null ? _table$initialState$p2 : defaultPageIndex);
1560
+ };
1561
+ table.resetPageSize = (defaultState) => {
1562
+ var _table$initialState$p3, _table$initialState2;
1563
+ table.setPageSize(defaultState ? defaultPageSize : (_table$initialState$p3 = (_table$initialState2 = table.initialState) == null || (_table$initialState2 = _table$initialState2.pagination) == null ? void 0 : _table$initialState2.pageSize) != null ? _table$initialState$p3 : defaultPageSize);
1564
+ };
1565
+ table.setPageSize = (updater) => {
1566
+ table.setPagination((old) => {
1567
+ const pageSize = Math.max(1, functionalUpdate(updater, old.pageSize));
1568
+ const topRowIndex = old.pageSize * old.pageIndex;
1569
+ const pageIndex = Math.floor(topRowIndex / pageSize);
1570
+ return {
1571
+ ...old,
1572
+ pageIndex,
1573
+ pageSize
1574
+ };
1575
+ });
1576
+ };
1577
+ table.setPageCount = (updater) => table.setPagination((old) => {
1578
+ var _table$options$pageCo;
1579
+ let newPageCount = functionalUpdate(updater, (_table$options$pageCo = table.options.pageCount) != null ? _table$options$pageCo : -1);
1580
+ if (typeof newPageCount === "number") newPageCount = Math.max(-1, newPageCount);
1581
+ return {
1582
+ ...old,
1583
+ pageCount: newPageCount
1584
+ };
1585
+ });
1586
+ table.getPageOptions = memo(() => [table.getPageCount()], (pageCount) => {
1587
+ let pageOptions = [];
1588
+ if (pageCount && pageCount > 0) pageOptions = [...new Array(pageCount)].fill(null).map((_, i) => i);
1589
+ return pageOptions;
1590
+ }, getMemoOptions(table.options, "debugTable", "getPageOptions"));
1591
+ table.getCanPreviousPage = () => table.getState().pagination.pageIndex > 0;
1592
+ table.getCanNextPage = () => {
1593
+ const { pageIndex } = table.getState().pagination;
1594
+ const pageCount = table.getPageCount();
1595
+ if (pageCount === -1) return true;
1596
+ if (pageCount === 0) return false;
1597
+ return pageIndex < pageCount - 1;
1598
+ };
1599
+ table.previousPage = () => {
1600
+ return table.setPageIndex((old) => old - 1);
1601
+ };
1602
+ table.nextPage = () => {
1603
+ return table.setPageIndex((old) => {
1604
+ return old + 1;
1605
+ });
1606
+ };
1607
+ table.firstPage = () => {
1608
+ return table.setPageIndex(0);
1609
+ };
1610
+ table.lastPage = () => {
1611
+ return table.setPageIndex(table.getPageCount() - 1);
1612
+ };
1613
+ table.getPrePaginationRowModel = () => table.getExpandedRowModel();
1614
+ table.getPaginationRowModel = () => {
1615
+ if (!table._getPaginationRowModel && table.options.getPaginationRowModel) table._getPaginationRowModel = table.options.getPaginationRowModel(table);
1616
+ if (table.options.manualPagination || !table._getPaginationRowModel) return table.getPrePaginationRowModel();
1617
+ return table._getPaginationRowModel();
1618
+ };
1619
+ table.getPageCount = () => {
1620
+ var _table$options$pageCo2;
1621
+ return (_table$options$pageCo2 = table.options.pageCount) != null ? _table$options$pageCo2 : Math.ceil(table.getRowCount() / table.getState().pagination.pageSize);
1622
+ };
1623
+ table.getRowCount = () => {
1624
+ var _table$options$rowCou;
1625
+ return (_table$options$rowCou = table.options.rowCount) != null ? _table$options$rowCou : table.getPrePaginationRowModel().rows.length;
1626
+ };
1627
+ }
1628
+ };
1629
+ var getDefaultRowPinningState = () => ({
1630
+ top: [],
1631
+ bottom: []
1632
+ });
1633
+ var RowPinning = {
1634
+ getInitialState: (state) => {
1635
+ return {
1636
+ rowPinning: getDefaultRowPinningState(),
1637
+ ...state
1638
+ };
1639
+ },
1640
+ getDefaultOptions: (table) => {
1641
+ return { onRowPinningChange: makeStateUpdater("rowPinning", table) };
1642
+ },
1643
+ createRow: (row, table) => {
1644
+ row.pin = (position, includeLeafRows, includeParentRows) => {
1645
+ const leafRowIds = includeLeafRows ? row.getLeafRows().map((_ref) => {
1646
+ let { id } = _ref;
1647
+ return id;
1648
+ }) : [];
1649
+ const parentRowIds = includeParentRows ? row.getParentRows().map((_ref2) => {
1650
+ let { id } = _ref2;
1651
+ return id;
1652
+ }) : [];
1653
+ const rowIds = new Set([
1654
+ ...parentRowIds,
1655
+ row.id,
1656
+ ...leafRowIds
1657
+ ]);
1658
+ table.setRowPinning((old) => {
1659
+ var _old$top3, _old$bottom3;
1660
+ if (position === "bottom") {
1661
+ var _old$top, _old$bottom;
1662
+ return {
1663
+ top: ((_old$top = old == null ? void 0 : old.top) != null ? _old$top : []).filter((d) => !(rowIds != null && rowIds.has(d))),
1664
+ bottom: [...((_old$bottom = old == null ? void 0 : old.bottom) != null ? _old$bottom : []).filter((d) => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)]
1665
+ };
1666
+ }
1667
+ if (position === "top") {
1668
+ var _old$top2, _old$bottom2;
1669
+ return {
1670
+ top: [...((_old$top2 = old == null ? void 0 : old.top) != null ? _old$top2 : []).filter((d) => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)],
1671
+ bottom: ((_old$bottom2 = old == null ? void 0 : old.bottom) != null ? _old$bottom2 : []).filter((d) => !(rowIds != null && rowIds.has(d)))
1672
+ };
1673
+ }
1674
+ return {
1675
+ top: ((_old$top3 = old == null ? void 0 : old.top) != null ? _old$top3 : []).filter((d) => !(rowIds != null && rowIds.has(d))),
1676
+ bottom: ((_old$bottom3 = old == null ? void 0 : old.bottom) != null ? _old$bottom3 : []).filter((d) => !(rowIds != null && rowIds.has(d)))
1677
+ };
1678
+ });
1679
+ };
1680
+ row.getCanPin = () => {
1681
+ var _ref3;
1682
+ const { enableRowPinning, enablePinning } = table.options;
1683
+ if (typeof enableRowPinning === "function") return enableRowPinning(row);
1684
+ return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
1685
+ };
1686
+ row.getIsPinned = () => {
1687
+ const rowIds = [row.id];
1688
+ const { top, bottom } = table.getState().rowPinning;
1689
+ const isTop = rowIds.some((d) => top == null ? void 0 : top.includes(d));
1690
+ const isBottom = rowIds.some((d) => bottom == null ? void 0 : bottom.includes(d));
1691
+ return isTop ? "top" : isBottom ? "bottom" : false;
1692
+ };
1693
+ row.getPinnedIndex = () => {
1694
+ var _ref4, _visiblePinnedRowIds$;
1695
+ const position = row.getIsPinned();
1696
+ if (!position) return -1;
1697
+ const visiblePinnedRowIds = (_ref4 = position === "top" ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map((_ref5) => {
1698
+ let { id } = _ref5;
1699
+ return id;
1700
+ });
1701
+ return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
1702
+ };
1703
+ },
1704
+ createTable: (table) => {
1705
+ table.setRowPinning = (updater) => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
1706
+ table.resetRowPinning = (defaultState) => {
1707
+ var _table$initialState$r, _table$initialState;
1708
+ return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
1709
+ };
1710
+ table.getIsSomeRowsPinned = (position) => {
1711
+ var _pinningState$positio;
1712
+ const pinningState = table.getState().rowPinning;
1713
+ if (!position) {
1714
+ var _pinningState$top, _pinningState$bottom;
1715
+ return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
1716
+ }
1717
+ return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
1718
+ };
1719
+ table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
1720
+ var _table$options$keepPi;
1721
+ return (((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ? (pinnedRowIds != null ? pinnedRowIds : []).map((rowId) => {
1722
+ const row = table.getRow(rowId, true);
1723
+ return row.getIsAllParentsExpanded() ? row : null;
1724
+ }) : (pinnedRowIds != null ? pinnedRowIds : []).map((rowId) => visibleRows.find((row) => row.id === rowId))).filter(Boolean).map((d) => ({
1725
+ ...d,
1726
+ position
1727
+ }));
1728
+ };
1729
+ table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, "top"), getMemoOptions(table.options, "debugRows", "getTopRows"));
1730
+ table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, "bottom"), getMemoOptions(table.options, "debugRows", "getBottomRows"));
1731
+ table.getCenterRows = memo(() => [
1732
+ table.getRowModel().rows,
1733
+ table.getState().rowPinning.top,
1734
+ table.getState().rowPinning.bottom
1735
+ ], (allRows, top, bottom) => {
1736
+ const topAndBottom = new Set([...top != null ? top : [], ...bottom != null ? bottom : []]);
1737
+ return allRows.filter((d) => !topAndBottom.has(d.id));
1738
+ }, getMemoOptions(table.options, "debugRows", "getCenterRows"));
1739
+ }
1740
+ };
1741
+ var RowSelection = {
1742
+ getInitialState: (state) => {
1743
+ return {
1744
+ rowSelection: {},
1745
+ ...state
1746
+ };
1747
+ },
1748
+ getDefaultOptions: (table) => {
1749
+ return {
1750
+ onRowSelectionChange: makeStateUpdater("rowSelection", table),
1751
+ enableRowSelection: true,
1752
+ enableMultiRowSelection: true,
1753
+ enableSubRowSelection: true
1754
+ };
1755
+ },
1756
+ createTable: (table) => {
1757
+ table.setRowSelection = (updater) => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater);
1758
+ table.resetRowSelection = (defaultState) => {
1759
+ var _table$initialState$r;
1760
+ return table.setRowSelection(defaultState ? {} : (_table$initialState$r = table.initialState.rowSelection) != null ? _table$initialState$r : {});
1761
+ };
1762
+ table.toggleAllRowsSelected = (value) => {
1763
+ table.setRowSelection((old) => {
1764
+ value = typeof value !== "undefined" ? value : !table.getIsAllRowsSelected();
1765
+ const rowSelection = { ...old };
1766
+ const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
1767
+ if (value) preGroupedFlatRows.forEach((row) => {
1768
+ if (!row.getCanSelect()) return;
1769
+ rowSelection[row.id] = true;
1770
+ });
1771
+ else preGroupedFlatRows.forEach((row) => {
1772
+ delete rowSelection[row.id];
1773
+ });
1774
+ return rowSelection;
1775
+ });
1776
+ };
1777
+ table.toggleAllPageRowsSelected = (value) => table.setRowSelection((old) => {
1778
+ const resolvedValue = typeof value !== "undefined" ? value : !table.getIsAllPageRowsSelected();
1779
+ const rowSelection = { ...old };
1780
+ table.getRowModel().rows.forEach((row) => {
1781
+ mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
1782
+ });
1783
+ return rowSelection;
1784
+ });
1785
+ table.getPreSelectedRowModel = () => table.getCoreRowModel();
1786
+ table.getSelectedRowModel = memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
1787
+ if (!Object.keys(rowSelection).length) return {
1788
+ rows: [],
1789
+ flatRows: [],
1790
+ rowsById: {}
1791
+ };
1792
+ return selectRowsFn(table, rowModel);
1793
+ }, getMemoOptions(table.options, "debugTable", "getSelectedRowModel"));
1794
+ table.getFilteredSelectedRowModel = memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
1795
+ if (!Object.keys(rowSelection).length) return {
1796
+ rows: [],
1797
+ flatRows: [],
1798
+ rowsById: {}
1799
+ };
1800
+ return selectRowsFn(table, rowModel);
1801
+ }, getMemoOptions(table.options, "debugTable", "getFilteredSelectedRowModel"));
1802
+ table.getGroupedSelectedRowModel = memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
1803
+ if (!Object.keys(rowSelection).length) return {
1804
+ rows: [],
1805
+ flatRows: [],
1806
+ rowsById: {}
1807
+ };
1808
+ return selectRowsFn(table, rowModel);
1809
+ }, getMemoOptions(table.options, "debugTable", "getGroupedSelectedRowModel"));
1810
+ table.getIsAllRowsSelected = () => {
1811
+ const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
1812
+ const { rowSelection } = table.getState();
1813
+ let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
1814
+ if (isAllRowsSelected) {
1815
+ if (preGroupedFlatRows.some((row) => row.getCanSelect() && !rowSelection[row.id])) isAllRowsSelected = false;
1816
+ }
1817
+ return isAllRowsSelected;
1818
+ };
1819
+ table.getIsAllPageRowsSelected = () => {
1820
+ const paginationFlatRows = table.getPaginationRowModel().flatRows.filter((row) => row.getCanSelect());
1821
+ const { rowSelection } = table.getState();
1822
+ let isAllPageRowsSelected = !!paginationFlatRows.length;
1823
+ if (isAllPageRowsSelected && paginationFlatRows.some((row) => !rowSelection[row.id])) isAllPageRowsSelected = false;
1824
+ return isAllPageRowsSelected;
1825
+ };
1826
+ table.getIsSomeRowsSelected = () => {
1827
+ var _table$getState$rowSe;
1828
+ const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
1829
+ return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
1830
+ };
1831
+ table.getIsSomePageRowsSelected = () => {
1832
+ const paginationFlatRows = table.getPaginationRowModel().flatRows;
1833
+ return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter((row) => row.getCanSelect()).some((d) => d.getIsSelected() || d.getIsSomeSelected());
1834
+ };
1835
+ table.getToggleAllRowsSelectedHandler = () => {
1836
+ return (e) => {
1837
+ table.toggleAllRowsSelected(e.target.checked);
1838
+ };
1839
+ };
1840
+ table.getToggleAllPageRowsSelectedHandler = () => {
1841
+ return (e) => {
1842
+ table.toggleAllPageRowsSelected(e.target.checked);
1843
+ };
1844
+ };
1845
+ },
1846
+ createRow: (row, table) => {
1847
+ row.toggleSelected = (value, opts) => {
1848
+ const isSelected = row.getIsSelected();
1849
+ table.setRowSelection((old) => {
1850
+ var _opts$selectChildren;
1851
+ value = typeof value !== "undefined" ? value : !isSelected;
1852
+ if (row.getCanSelect() && isSelected === value) return old;
1853
+ const selectedRowIds = { ...old };
1854
+ mutateRowIsSelected(selectedRowIds, row.id, value, (_opts$selectChildren = opts == null ? void 0 : opts.selectChildren) != null ? _opts$selectChildren : true, table);
1855
+ return selectedRowIds;
1856
+ });
1857
+ };
1858
+ row.getIsSelected = () => {
1859
+ const { rowSelection } = table.getState();
1860
+ return isRowSelected(row, rowSelection);
1861
+ };
1862
+ row.getIsSomeSelected = () => {
1863
+ const { rowSelection } = table.getState();
1864
+ return isSubRowSelected(row, rowSelection) === "some";
1865
+ };
1866
+ row.getIsAllSubRowsSelected = () => {
1867
+ const { rowSelection } = table.getState();
1868
+ return isSubRowSelected(row, rowSelection) === "all";
1869
+ };
1870
+ row.getCanSelect = () => {
1871
+ var _table$options$enable;
1872
+ if (typeof table.options.enableRowSelection === "function") return table.options.enableRowSelection(row);
1873
+ return (_table$options$enable = table.options.enableRowSelection) != null ? _table$options$enable : true;
1874
+ };
1875
+ row.getCanSelectSubRows = () => {
1876
+ var _table$options$enable2;
1877
+ if (typeof table.options.enableSubRowSelection === "function") return table.options.enableSubRowSelection(row);
1878
+ return (_table$options$enable2 = table.options.enableSubRowSelection) != null ? _table$options$enable2 : true;
1879
+ };
1880
+ row.getCanMultiSelect = () => {
1881
+ var _table$options$enable3;
1882
+ if (typeof table.options.enableMultiRowSelection === "function") return table.options.enableMultiRowSelection(row);
1883
+ return (_table$options$enable3 = table.options.enableMultiRowSelection) != null ? _table$options$enable3 : true;
1884
+ };
1885
+ row.getToggleSelectedHandler = () => {
1886
+ const canSelect = row.getCanSelect();
1887
+ return (e) => {
1888
+ var _target;
1889
+ if (!canSelect) return;
1890
+ row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
1891
+ };
1892
+ };
1893
+ }
1894
+ };
1895
+ var mutateRowIsSelected = (selectedRowIds, id, value, includeChildren, table) => {
1896
+ var _row$subRows;
1897
+ const row = table.getRow(id, true);
1898
+ if (value) {
1899
+ if (!row.getCanMultiSelect()) Object.keys(selectedRowIds).forEach((key) => delete selectedRowIds[key]);
1900
+ if (row.getCanSelect()) selectedRowIds[id] = true;
1901
+ } else delete selectedRowIds[id];
1902
+ if (includeChildren && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) row.subRows.forEach((row) => mutateRowIsSelected(selectedRowIds, row.id, value, includeChildren, table));
1903
+ };
1904
+ function selectRowsFn(table, rowModel) {
1905
+ const rowSelection = table.getState().rowSelection;
1906
+ const newSelectedFlatRows = [];
1907
+ const newSelectedRowsById = {};
1908
+ const recurseRows = function(rows, depth) {
1909
+ return rows.map((row) => {
1910
+ var _row$subRows2;
1911
+ const isSelected = isRowSelected(row, rowSelection);
1912
+ if (isSelected) {
1913
+ newSelectedFlatRows.push(row);
1914
+ newSelectedRowsById[row.id] = row;
1915
+ }
1916
+ if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) row = {
1917
+ ...row,
1918
+ subRows: recurseRows(row.subRows)
1919
+ };
1920
+ if (isSelected) return row;
1921
+ }).filter(Boolean);
1922
+ };
1923
+ return {
1924
+ rows: recurseRows(rowModel.rows),
1925
+ flatRows: newSelectedFlatRows,
1926
+ rowsById: newSelectedRowsById
1927
+ };
1928
+ }
1929
+ function isRowSelected(row, selection) {
1930
+ var _selection$row$id;
1931
+ return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
1932
+ }
1933
+ function isSubRowSelected(row, selection, table) {
1934
+ var _row$subRows3;
1935
+ if (!((_row$subRows3 = row.subRows) != null && _row$subRows3.length)) return false;
1936
+ let allChildrenSelected = true;
1937
+ let someSelected = false;
1938
+ row.subRows.forEach((subRow) => {
1939
+ if (someSelected && !allChildrenSelected) return;
1940
+ if (subRow.getCanSelect()) if (isRowSelected(subRow, selection)) someSelected = true;
1941
+ else allChildrenSelected = false;
1942
+ if (subRow.subRows && subRow.subRows.length) {
1943
+ const subRowChildrenSelected = isSubRowSelected(subRow, selection);
1944
+ if (subRowChildrenSelected === "all") someSelected = true;
1945
+ else if (subRowChildrenSelected === "some") {
1946
+ someSelected = true;
1947
+ allChildrenSelected = false;
1948
+ } else allChildrenSelected = false;
1949
+ }
1950
+ });
1951
+ return allChildrenSelected ? "all" : someSelected ? "some" : false;
1952
+ }
1953
+ var reSplitAlphaNumeric = /([0-9]+)/gm;
1954
+ var alphanumeric = (rowA, rowB, columnId) => {
1955
+ return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
1956
+ };
1957
+ var alphanumericCaseSensitive = (rowA, rowB, columnId) => {
1958
+ return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
1959
+ };
1960
+ var text = (rowA, rowB, columnId) => {
1961
+ return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
1962
+ };
1963
+ var textCaseSensitive = (rowA, rowB, columnId) => {
1964
+ return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
1965
+ };
1966
+ var datetime = (rowA, rowB, columnId) => {
1967
+ const a = rowA.getValue(columnId);
1968
+ const b = rowB.getValue(columnId);
1969
+ return a > b ? 1 : a < b ? -1 : 0;
1970
+ };
1971
+ var basic = (rowA, rowB, columnId) => {
1972
+ return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
1973
+ };
1974
+ function compareBasic(a, b) {
1975
+ return a === b ? 0 : a > b ? 1 : -1;
1976
+ }
1977
+ function toString(a) {
1978
+ if (typeof a === "number") {
1979
+ if (isNaN(a) || a === Infinity || a === -Infinity) return "";
1980
+ return String(a);
1981
+ }
1982
+ if (typeof a === "string") return a;
1983
+ return "";
1984
+ }
1985
+ function compareAlphanumeric(aStr, bStr) {
1986
+ const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
1987
+ const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
1988
+ while (a.length && b.length) {
1989
+ const aa = a.shift();
1990
+ const bb = b.shift();
1991
+ const an = parseInt(aa, 10);
1992
+ const bn = parseInt(bb, 10);
1993
+ const combo = [an, bn].sort();
1994
+ if (isNaN(combo[0])) {
1995
+ if (aa > bb) return 1;
1996
+ if (bb > aa) return -1;
1997
+ continue;
1998
+ }
1999
+ if (isNaN(combo[1])) return isNaN(an) ? -1 : 1;
2000
+ if (an > bn) return 1;
2001
+ if (bn > an) return -1;
2002
+ }
2003
+ return a.length - b.length;
2004
+ }
2005
+ var sortingFns = {
2006
+ alphanumeric,
2007
+ alphanumericCaseSensitive,
2008
+ text,
2009
+ textCaseSensitive,
2010
+ datetime,
2011
+ basic
2012
+ };
2013
+ var builtInFeatures = [
2014
+ Headers,
2015
+ ColumnVisibility,
2016
+ ColumnOrdering,
2017
+ ColumnPinning,
2018
+ ColumnFaceting,
2019
+ ColumnFiltering,
2020
+ GlobalFaceting,
2021
+ GlobalFiltering,
2022
+ {
2023
+ getInitialState: (state) => {
2024
+ return {
2025
+ sorting: [],
2026
+ ...state
2027
+ };
2028
+ },
2029
+ getDefaultColumnDef: () => {
2030
+ return {
2031
+ sortingFn: "auto",
2032
+ sortUndefined: 1
2033
+ };
2034
+ },
2035
+ getDefaultOptions: (table) => {
2036
+ return {
2037
+ onSortingChange: makeStateUpdater("sorting", table),
2038
+ isMultiSortEvent: (e) => {
2039
+ return e.shiftKey;
2040
+ }
2041
+ };
2042
+ },
2043
+ createColumn: (column, table) => {
2044
+ column.getAutoSortingFn = () => {
2045
+ const firstRows = table.getFilteredRowModel().flatRows.slice(10);
2046
+ let isString = false;
2047
+ for (const row of firstRows) {
2048
+ const value = row == null ? void 0 : row.getValue(column.id);
2049
+ if (Object.prototype.toString.call(value) === "[object Date]") return sortingFns.datetime;
2050
+ if (typeof value === "string") {
2051
+ isString = true;
2052
+ if (value.split(reSplitAlphaNumeric).length > 1) return sortingFns.alphanumeric;
2053
+ }
2054
+ }
2055
+ if (isString) return sortingFns.text;
2056
+ return sortingFns.basic;
2057
+ };
2058
+ column.getAutoSortDir = () => {
2059
+ const firstRow = table.getFilteredRowModel().flatRows[0];
2060
+ if (typeof (firstRow == null ? void 0 : firstRow.getValue(column.id)) === "string") return "asc";
2061
+ return "desc";
2062
+ };
2063
+ column.getSortingFn = () => {
2064
+ var _table$options$sortin, _table$options$sortin2;
2065
+ if (!column) throw new Error();
2066
+ return isFunction(column.columnDef.sortingFn) ? column.columnDef.sortingFn : column.columnDef.sortingFn === "auto" ? column.getAutoSortingFn() : (_table$options$sortin = (_table$options$sortin2 = table.options.sortingFns) == null ? void 0 : _table$options$sortin2[column.columnDef.sortingFn]) != null ? _table$options$sortin : sortingFns[column.columnDef.sortingFn];
2067
+ };
2068
+ column.toggleSorting = (desc, multi) => {
2069
+ const nextSortingOrder = column.getNextSortingOrder();
2070
+ const hasManualValue = typeof desc !== "undefined" && desc !== null;
2071
+ table.setSorting((old) => {
2072
+ const existingSorting = old == null ? void 0 : old.find((d) => d.id === column.id);
2073
+ const existingIndex = old == null ? void 0 : old.findIndex((d) => d.id === column.id);
2074
+ let newSorting = [];
2075
+ let sortAction;
2076
+ let nextDesc = hasManualValue ? desc : nextSortingOrder === "desc";
2077
+ if (old != null && old.length && column.getCanMultiSort() && multi) if (existingSorting) sortAction = "toggle";
2078
+ else sortAction = "add";
2079
+ else if (old != null && old.length && existingIndex !== old.length - 1) sortAction = "replace";
2080
+ else if (existingSorting) sortAction = "toggle";
2081
+ else sortAction = "replace";
2082
+ if (sortAction === "toggle") {
2083
+ if (!hasManualValue) {
2084
+ if (!nextSortingOrder) sortAction = "remove";
2085
+ }
2086
+ }
2087
+ if (sortAction === "add") {
2088
+ var _table$options$maxMul;
2089
+ newSorting = [...old, {
2090
+ id: column.id,
2091
+ desc: nextDesc
2092
+ }];
2093
+ newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
2094
+ } else if (sortAction === "toggle") newSorting = old.map((d) => {
2095
+ if (d.id === column.id) return {
2096
+ ...d,
2097
+ desc: nextDesc
2098
+ };
2099
+ return d;
2100
+ });
2101
+ else if (sortAction === "remove") newSorting = old.filter((d) => d.id !== column.id);
2102
+ else newSorting = [{
2103
+ id: column.id,
2104
+ desc: nextDesc
2105
+ }];
2106
+ return newSorting;
2107
+ });
2108
+ };
2109
+ column.getFirstSortDir = () => {
2110
+ var _ref, _column$columnDef$sor;
2111
+ return ((_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === "desc") ? "desc" : "asc";
2112
+ };
2113
+ column.getNextSortingOrder = (multi) => {
2114
+ var _table$options$enable, _table$options$enable2;
2115
+ const firstSortDirection = column.getFirstSortDir();
2116
+ const isSorted = column.getIsSorted();
2117
+ if (!isSorted) return firstSortDirection;
2118
+ if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && (multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true)) return false;
2119
+ return isSorted === "desc" ? "asc" : "desc";
2120
+ };
2121
+ column.getCanSort = () => {
2122
+ var _column$columnDef$ena, _table$options$enable3;
2123
+ return ((_column$columnDef$ena = column.columnDef.enableSorting) != null ? _column$columnDef$ena : true) && ((_table$options$enable3 = table.options.enableSorting) != null ? _table$options$enable3 : true) && !!column.accessorFn;
2124
+ };
2125
+ column.getCanMultiSort = () => {
2126
+ var _ref2, _column$columnDef$ena2;
2127
+ return (_ref2 = (_column$columnDef$ena2 = column.columnDef.enableMultiSort) != null ? _column$columnDef$ena2 : table.options.enableMultiSort) != null ? _ref2 : !!column.accessorFn;
2128
+ };
2129
+ column.getIsSorted = () => {
2130
+ var _table$getState$sorti;
2131
+ const columnSort = (_table$getState$sorti = table.getState().sorting) == null ? void 0 : _table$getState$sorti.find((d) => d.id === column.id);
2132
+ return !columnSort ? false : columnSort.desc ? "desc" : "asc";
2133
+ };
2134
+ column.getSortIndex = () => {
2135
+ var _table$getState$sorti2, _table$getState$sorti3;
2136
+ return (_table$getState$sorti2 = (_table$getState$sorti3 = table.getState().sorting) == null ? void 0 : _table$getState$sorti3.findIndex((d) => d.id === column.id)) != null ? _table$getState$sorti2 : -1;
2137
+ };
2138
+ column.clearSorting = () => {
2139
+ table.setSorting((old) => old != null && old.length ? old.filter((d) => d.id !== column.id) : []);
2140
+ };
2141
+ column.getToggleSortingHandler = () => {
2142
+ const canSort = column.getCanSort();
2143
+ return (e) => {
2144
+ if (!canSort) return;
2145
+ e.persist == null || e.persist();
2146
+ column.toggleSorting == null || column.toggleSorting(void 0, column.getCanMultiSort() ? table.options.isMultiSortEvent == null ? void 0 : table.options.isMultiSortEvent(e) : false);
2147
+ };
2148
+ };
2149
+ },
2150
+ createTable: (table) => {
2151
+ table.setSorting = (updater) => table.options.onSortingChange == null ? void 0 : table.options.onSortingChange(updater);
2152
+ table.resetSorting = (defaultState) => {
2153
+ var _table$initialState$s, _table$initialState;
2154
+ table.setSorting(defaultState ? [] : (_table$initialState$s = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.sorting) != null ? _table$initialState$s : []);
2155
+ };
2156
+ table.getPreSortedRowModel = () => table.getGroupedRowModel();
2157
+ table.getSortedRowModel = () => {
2158
+ if (!table._getSortedRowModel && table.options.getSortedRowModel) table._getSortedRowModel = table.options.getSortedRowModel(table);
2159
+ if (table.options.manualSorting || !table._getSortedRowModel) return table.getPreSortedRowModel();
2160
+ return table._getSortedRowModel();
2161
+ };
2162
+ }
2163
+ },
2164
+ ColumnGrouping,
2165
+ RowExpanding,
2166
+ RowPagination,
2167
+ RowPinning,
2168
+ RowSelection,
2169
+ ColumnSizing
2170
+ ];
2171
+ function createTable(options) {
2172
+ var _options$_features, _options$initialState;
2173
+ const _features = [...builtInFeatures, ...(_options$_features = options._features) != null ? _options$_features : []];
2174
+ let table = { _features };
2175
+ const defaultOptions = table._features.reduce((obj, feature) => {
2176
+ return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(table));
2177
+ }, {});
2178
+ const mergeOptions = (options) => {
2179
+ if (table.options.mergeOptions) return table.options.mergeOptions(defaultOptions, options);
2180
+ return {
2181
+ ...defaultOptions,
2182
+ ...options
2183
+ };
2184
+ };
2185
+ let initialState = { ...(_options$initialState = options.initialState) != null ? _options$initialState : {} };
2186
+ table._features.forEach((feature) => {
2187
+ var _feature$getInitialSt;
2188
+ initialState = (_feature$getInitialSt = feature.getInitialState == null ? void 0 : feature.getInitialState(initialState)) != null ? _feature$getInitialSt : initialState;
2189
+ });
2190
+ const queued = [];
2191
+ let queuedTimeout = false;
2192
+ const coreInstance = {
2193
+ _features,
2194
+ options: {
2195
+ ...defaultOptions,
2196
+ ...options
2197
+ },
2198
+ initialState,
2199
+ _queue: (cb) => {
2200
+ queued.push(cb);
2201
+ if (!queuedTimeout) {
2202
+ queuedTimeout = true;
2203
+ Promise.resolve().then(() => {
2204
+ while (queued.length) queued.shift()();
2205
+ queuedTimeout = false;
2206
+ }).catch((error) => setTimeout(() => {
2207
+ throw error;
2208
+ }));
2209
+ }
2210
+ },
2211
+ reset: () => {
2212
+ table.setState(table.initialState);
2213
+ },
2214
+ setOptions: (updater) => {
2215
+ table.options = mergeOptions(functionalUpdate(updater, table.options));
2216
+ },
2217
+ getState: () => {
2218
+ return table.options.state;
2219
+ },
2220
+ setState: (updater) => {
2221
+ table.options.onStateChange == null || table.options.onStateChange(updater);
2222
+ },
2223
+ _getRowId: (row, index, parent) => {
2224
+ var _table$options$getRow;
2225
+ return (_table$options$getRow = table.options.getRowId == null ? void 0 : table.options.getRowId(row, index, parent)) != null ? _table$options$getRow : `${parent ? [parent.id, index].join(".") : index}`;
2226
+ },
2227
+ getCoreRowModel: () => {
2228
+ if (!table._getCoreRowModel) table._getCoreRowModel = table.options.getCoreRowModel(table);
2229
+ return table._getCoreRowModel();
2230
+ },
2231
+ getRowModel: () => {
2232
+ return table.getPaginationRowModel();
2233
+ },
2234
+ getRow: (id, searchAll) => {
2235
+ let row = (searchAll ? table.getPrePaginationRowModel() : table.getRowModel()).rowsById[id];
2236
+ if (!row) {
2237
+ row = table.getCoreRowModel().rowsById[id];
2238
+ if (!row) throw new Error();
2239
+ }
2240
+ return row;
2241
+ },
2242
+ _getDefaultColumnDef: memo(() => [table.options.defaultColumn], (defaultColumn) => {
2243
+ var _defaultColumn;
2244
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
2245
+ return {
2246
+ header: (props) => {
2247
+ const resolvedColumnDef = props.header.column.columnDef;
2248
+ if (resolvedColumnDef.accessorKey) return resolvedColumnDef.accessorKey;
2249
+ if (resolvedColumnDef.accessorFn) return resolvedColumnDef.id;
2250
+ return null;
2251
+ },
2252
+ cell: (props) => {
2253
+ var _props$renderValue$to, _props$renderValue;
2254
+ return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null || _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
2255
+ },
2256
+ ...table._features.reduce((obj, feature) => {
2257
+ return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
2258
+ }, {}),
2259
+ ...defaultColumn
2260
+ };
2261
+ }, getMemoOptions(options, "debugColumns", "_getDefaultColumnDef")),
2262
+ _getColumnDefs: () => table.options.columns,
2263
+ getAllColumns: memo(() => [table._getColumnDefs()], (columnDefs) => {
2264
+ const recurseColumns = function(columnDefs, parent, depth) {
2265
+ if (depth === void 0) depth = 0;
2266
+ return columnDefs.map((columnDef) => {
2267
+ const column = createColumn(table, columnDef, depth, parent);
2268
+ const groupingColumnDef = columnDef;
2269
+ column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
2270
+ return column;
2271
+ });
2272
+ };
2273
+ return recurseColumns(columnDefs);
2274
+ }, getMemoOptions(options, "debugColumns", "getAllColumns")),
2275
+ getAllFlatColumns: memo(() => [table.getAllColumns()], (allColumns) => {
2276
+ return allColumns.flatMap((column) => {
2277
+ return column.getFlatColumns();
2278
+ });
2279
+ }, getMemoOptions(options, "debugColumns", "getAllFlatColumns")),
2280
+ _getAllFlatColumnsById: memo(() => [table.getAllFlatColumns()], (flatColumns) => {
2281
+ return flatColumns.reduce((acc, column) => {
2282
+ acc[column.id] = column;
2283
+ return acc;
2284
+ }, {});
2285
+ }, getMemoOptions(options, "debugColumns", "getAllFlatColumnsById")),
2286
+ getAllLeafColumns: memo(() => [table.getAllColumns(), table._getOrderColumnsFn()], (allColumns, orderColumns) => {
2287
+ return orderColumns(allColumns.flatMap((column) => column.getLeafColumns()));
2288
+ }, getMemoOptions(options, "debugColumns", "getAllLeafColumns")),
2289
+ getColumn: (columnId) => {
2290
+ return table._getAllFlatColumnsById()[columnId];
2291
+ }
2292
+ };
2293
+ Object.assign(table, coreInstance);
2294
+ for (let index = 0; index < table._features.length; index++) {
2295
+ const feature = table._features[index];
2296
+ feature == null || feature.createTable == null || feature.createTable(table);
2297
+ }
2298
+ return table;
2299
+ }
2300
+ function getCoreRowModel() {
2301
+ return (table) => memo(() => [table.options.data], (data) => {
2302
+ const rowModel = {
2303
+ rows: [],
2304
+ flatRows: [],
2305
+ rowsById: {}
2306
+ };
2307
+ const accessRows = function(originalRows, depth, parentRow) {
2308
+ if (depth === void 0) depth = 0;
2309
+ const rows = [];
2310
+ for (let i = 0; i < originalRows.length; i++) {
2311
+ const row = createRow(table, table._getRowId(originalRows[i], i, parentRow), originalRows[i], i, depth, void 0, parentRow == null ? void 0 : parentRow.id);
2312
+ rowModel.flatRows.push(row);
2313
+ rowModel.rowsById[row.id] = row;
2314
+ rows.push(row);
2315
+ if (table.options.getSubRows) {
2316
+ var _row$originalSubRows;
2317
+ row.originalSubRows = table.options.getSubRows(originalRows[i], i);
2318
+ if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) row.subRows = accessRows(row.originalSubRows, depth + 1, row);
2319
+ }
2320
+ }
2321
+ return rows;
2322
+ };
2323
+ rowModel.rows = accessRows(data);
2324
+ return rowModel;
2325
+ }, getMemoOptions(table.options, "debugTable", "getRowModel", () => table._autoResetPageIndex()));
2326
+ }
2327
+ //#endregion
2328
+ //#region ../../node_modules/.pnpm/@tanstack+react-table@8.21.3_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@tanstack/react-table/build/lib/index.mjs
2329
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
2330
+ /**
2331
+ * If rendering headers, cells, or footers with custom markup, use flexRender instead of `cell.getValue()` or `cell.renderValue()`.
2332
+ */
2333
+ function flexRender(Comp, props) {
2334
+ return !Comp ? null : isReactComponent(Comp) ? /* @__PURE__ */ import_react.createElement(Comp, props) : Comp;
2335
+ }
2336
+ function isReactComponent(component) {
2337
+ return isClassComponent(component) || typeof component === "function" || isExoticComponent(component);
2338
+ }
2339
+ function isClassComponent(component) {
2340
+ return typeof component === "function" && (() => {
2341
+ const proto = Object.getPrototypeOf(component);
2342
+ return proto.prototype && proto.prototype.isReactComponent;
2343
+ })();
2344
+ }
2345
+ function isExoticComponent(component) {
2346
+ return typeof component === "object" && typeof component.$$typeof === "symbol" && ["react.memo", "react.forward_ref"].includes(component.$$typeof.description);
2347
+ }
2348
+ function useReactTable(options) {
2349
+ const resolvedOptions = {
2350
+ state: {},
2351
+ onStateChange: () => {},
2352
+ renderFallbackValue: null,
2353
+ ...options
2354
+ };
2355
+ const [tableRef] = import_react.useState(() => ({ current: createTable(resolvedOptions) }));
2356
+ const [state, setState] = import_react.useState(() => tableRef.current.initialState);
2357
+ tableRef.current.setOptions((prev) => ({
2358
+ ...prev,
2359
+ ...options,
2360
+ state: {
2361
+ ...state,
2362
+ ...options.state
2363
+ },
2364
+ onStateChange: (updater) => {
2365
+ setState(updater);
2366
+ options.onStateChange == null || options.onStateChange(updater);
2367
+ }
2368
+ }));
2369
+ return tableRef.current;
2370
+ }
2371
+ //#endregion
2372
+ export { getCoreRowModel as i, useReactTable as n, createColumnHelper as r, flexRender as t };