@easyv/biz-components 2.1.5 → 2.1.6

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