@toolbox-web/grid 1.11.0 → 1.12.1

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 (96) hide show
  1. package/all.js +1224 -1110
  2. package/all.js.map +1 -1
  3. package/index.js +2000 -1700
  4. package/index.js.map +1 -1
  5. package/lib/core/grid.d.ts +21 -1
  6. package/lib/core/grid.d.ts.map +1 -1
  7. package/lib/core/internal/aria.d.ts +52 -0
  8. package/lib/core/internal/aria.d.ts.map +1 -0
  9. package/lib/core/internal/config-manager.d.ts.map +1 -1
  10. package/lib/core/internal/idle-scheduler.d.ts +0 -27
  11. package/lib/core/internal/idle-scheduler.d.ts.map +1 -1
  12. package/lib/core/internal/loading.d.ts +0 -38
  13. package/lib/core/internal/loading.d.ts.map +1 -1
  14. package/lib/core/internal/row-animation.d.ts.map +1 -1
  15. package/lib/core/internal/shell.d.ts +6 -0
  16. package/lib/core/internal/shell.d.ts.map +1 -1
  17. package/lib/core/internal/style-injector.d.ts +0 -8
  18. package/lib/core/internal/style-injector.d.ts.map +1 -1
  19. package/lib/core/internal/utils.d.ts +6 -4
  20. package/lib/core/internal/utils.d.ts.map +1 -1
  21. package/lib/core/internal/validate-config.d.ts.map +1 -1
  22. package/lib/core/internal/virtualization.d.ts +177 -23
  23. package/lib/core/internal/virtualization.d.ts.map +1 -1
  24. package/lib/core/plugin/base-plugin.d.ts +50 -0
  25. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  26. package/lib/core/plugin/plugin-manager.d.ts +18 -0
  27. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  28. package/lib/core/plugin/types.d.ts +16 -0
  29. package/lib/core/plugin/types.d.ts.map +1 -1
  30. package/lib/core/types.d.ts +56 -3
  31. package/lib/core/types.d.ts.map +1 -1
  32. package/lib/plugins/clipboard/index.js.map +1 -1
  33. package/lib/plugins/column-virtualization/index.js.map +1 -1
  34. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  35. package/lib/plugins/context-menu/index.js +1 -1
  36. package/lib/plugins/context-menu/index.js.map +1 -1
  37. package/lib/plugins/editing/EditingPlugin.d.ts +7 -5
  38. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  39. package/lib/plugins/editing/index.js +379 -278
  40. package/lib/plugins/editing/index.js.map +1 -1
  41. package/lib/plugins/editing/types.d.ts +14 -1
  42. package/lib/plugins/editing/types.d.ts.map +1 -1
  43. package/lib/plugins/export/index.js.map +1 -1
  44. package/lib/plugins/filtering/index.js.map +1 -1
  45. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +8 -1
  46. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
  47. package/lib/plugins/grouping-columns/index.js +59 -60
  48. package/lib/plugins/grouping-columns/index.js.map +1 -1
  49. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +14 -0
  50. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  51. package/lib/plugins/grouping-rows/index.js +88 -69
  52. package/lib/plugins/grouping-rows/index.js.map +1 -1
  53. package/lib/plugins/grouping-rows/types.d.ts +17 -0
  54. package/lib/plugins/grouping-rows/types.d.ts.map +1 -1
  55. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +24 -0
  56. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  57. package/lib/plugins/master-detail/index.js +203 -128
  58. package/lib/plugins/master-detail/index.js.map +1 -1
  59. package/lib/plugins/multi-sort/index.js.map +1 -1
  60. package/lib/plugins/pinned-columns/index.js.map +1 -1
  61. package/lib/plugins/pinned-rows/index.js +2 -2
  62. package/lib/plugins/pinned-rows/index.js.map +1 -1
  63. package/lib/plugins/pivot/index.js +2 -2
  64. package/lib/plugins/pivot/index.js.map +1 -1
  65. package/lib/plugins/print/index.js.map +1 -1
  66. package/lib/plugins/reorder/index.js.map +1 -1
  67. package/lib/plugins/responsive/ResponsivePlugin.d.ts +13 -0
  68. package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
  69. package/lib/plugins/responsive/index.js +65 -49
  70. package/lib/plugins/responsive/index.js.map +1 -1
  71. package/lib/plugins/row-reorder/index.js.map +1 -1
  72. package/lib/plugins/selection/index.js +5 -5
  73. package/lib/plugins/selection/index.js.map +1 -1
  74. package/lib/plugins/server-side/index.js.map +1 -1
  75. package/lib/plugins/tree/index.js.map +1 -1
  76. package/lib/plugins/undo-redo/index.js.map +1 -1
  77. package/lib/plugins/visibility/index.js.map +1 -1
  78. package/package.json +1 -1
  79. package/umd/grid.all.umd.js +27 -25
  80. package/umd/grid.all.umd.js.map +1 -1
  81. package/umd/grid.umd.js +18 -16
  82. package/umd/grid.umd.js.map +1 -1
  83. package/umd/plugins/context-menu.umd.js +1 -1
  84. package/umd/plugins/context-menu.umd.js.map +1 -1
  85. package/umd/plugins/editing.umd.js +1 -1
  86. package/umd/plugins/editing.umd.js.map +1 -1
  87. package/umd/plugins/grouping-columns.umd.js +1 -1
  88. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  89. package/umd/plugins/grouping-rows.umd.js +2 -2
  90. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  91. package/umd/plugins/master-detail.umd.js +1 -1
  92. package/umd/plugins/master-detail.umd.js.map +1 -1
  93. package/umd/plugins/responsive.umd.js +1 -1
  94. package/umd/plugins/responsive.umd.js.map +1 -1
  95. package/umd/plugins/selection.umd.js +2 -2
  96. package/umd/plugins/selection.umd.js.map +1 -1
package/all.js CHANGED
@@ -1,20 +1,20 @@
1
- import { BaseGridPlugin as _, DEFAULT_GRID_ICONS as ht, e as P, runAggregator as te, a as Je, s as et, g as ue, r as ft, getAggregator as ye, getValueAggregator as gt, c as xe, b as pt } from "./index.js";
1
+ import { BaseGridPlugin as _, DEFAULT_GRID_ICONS as ht, F as M, e as F, s as ft, c as gt, runAggregator as te, a as Je, b as et, g as ue, r as pt, getAggregator as ye, getValueAggregator as mt, d as xe, f as wt } from "./index.js";
2
2
  import { DEFAULT_ANIMATION_CONFIG as Dn, DGEvents as Mn, DataGridElement as Nn, FitModeEnum as qn, GridCSSVars as Hn, GridClasses as Kn, GridDataAttrs as zn, DataGridElement as On, GridSelectors as Gn, PLUGIN_QUERIES as Bn, PluginEvents as Vn, PluginManager as Wn, RenderPhase as $n, builtInSort as jn, createGrid as Un, defaultComparator as Yn, queryGrid as Xn } from "./index.js";
3
- const tt = "__tbw_expander", mt = 32;
4
- function pe(a) {
5
- return a.field === tt;
3
+ const tt = "__tbw_expander", bt = 32;
4
+ function pe(s) {
5
+ return s.field === tt;
6
6
  }
7
- function q(a) {
8
- return a.meta?.utility === !0;
7
+ function H(s) {
8
+ return s.meta?.utility === !0;
9
9
  }
10
- function wt(a) {
11
- return a.find(pe);
10
+ function vt(s) {
11
+ return s.find(pe);
12
12
  }
13
- function bt(a) {
13
+ function yt(s) {
14
14
  return {
15
15
  field: tt,
16
16
  header: "",
17
- width: mt,
17
+ width: bt,
18
18
  resizable: !1,
19
19
  sortable: !1,
20
20
  filterable: !1,
@@ -22,44 +22,44 @@ function bt(a) {
22
22
  lockPosition: !0,
23
23
  suppressMovable: !0,
24
24
  expanderColumn: !0,
25
- expanderPlugin: a,
25
+ expanderPlugin: s,
26
26
  utility: !0
27
27
  }
28
28
  };
29
29
  }
30
- async function ie(a) {
30
+ async function ie(s) {
31
31
  try {
32
- return await navigator.clipboard.writeText(a), !0;
32
+ return await navigator.clipboard.writeText(s), !0;
33
33
  } catch {
34
34
  const e = document.createElement("textarea");
35
- e.value = a, e.style.position = "fixed", e.style.opacity = "0", e.style.pointerEvents = "none", document.body.appendChild(e), e.select();
35
+ e.value = s, e.style.position = "fixed", e.style.opacity = "0", e.style.pointerEvents = "none", document.body.appendChild(e), e.select();
36
36
  const t = document.execCommand("copy");
37
37
  return document.body.removeChild(e), t;
38
38
  }
39
39
  }
40
- function Ce(a, e) {
40
+ function Ce(s, e) {
41
41
  const t = e.delimiter ?? " ", i = e.newline ?? `
42
- `, n = a.replace(/\r\n/g, `
42
+ `, n = s.replace(/\r\n/g, `
43
43
  `).replace(/\r/g, `
44
44
  `), r = [];
45
- let o = [], s = "", l = !1;
45
+ let o = [], a = "", l = !1;
46
46
  for (let d = 0; d < n.length; d++) {
47
47
  const c = n[d];
48
- c === '"' && !l ? l = !0 : c === '"' && l ? n[d + 1] === '"' ? (s += '"', d++) : l = !1 : c === t && !l ? (o.push(s), s = "") : c === i && !l ? (o.push(s), s = "", (o.length > 1 || o.some((u) => u.trim() !== "")) && r.push(o), o = []) : s += c;
48
+ c === '"' && !l ? l = !0 : c === '"' && l ? n[d + 1] === '"' ? (a += '"', d++) : l = !1 : c === t && !l ? (o.push(a), a = "") : c === i && !l ? (o.push(a), a = "", (o.length > 1 || o.some((u) => u.trim() !== "")) && r.push(o), o = []) : a += c;
49
49
  }
50
- return o.push(s), (o.length > 1 || o.some((d) => d.trim() !== "")) && r.push(o), r;
50
+ return o.push(a), (o.length > 1 || o.some((d) => d.trim() !== "")) && r.push(o), r;
51
51
  }
52
- async function vt() {
52
+ async function xt() {
53
53
  try {
54
54
  return await navigator.clipboard.readText();
55
55
  } catch {
56
56
  return "";
57
57
  }
58
58
  }
59
- function yt(a, e) {
60
- const { rows: t, target: i, fields: n } = a;
59
+ function Ct(s, e) {
60
+ const { rows: t, target: i, fields: n } = s;
61
61
  if (!i) return;
62
- const r = e.rows, o = e.effectiveConfig.columns ?? [], s = o.map((u) => u.field), l = /* @__PURE__ */ new Map();
62
+ const r = e.rows, o = e.effectiveConfig.columns ?? [], a = o.map((u) => u.field), l = /* @__PURE__ */ new Map();
63
63
  o.forEach((u) => {
64
64
  l.set(u.field, u.editable === !0);
65
65
  });
@@ -72,7 +72,7 @@ function yt(a, e) {
72
72
  return;
73
73
  } else for (; f >= d.length; ) {
74
74
  const g = {};
75
- s.forEach((p) => g[p] = ""), d.push(g);
75
+ a.forEach((p) => g[p] = ""), d.push(g);
76
76
  }
77
77
  d[f] = { ...d[f] }, u.forEach((g, p) => {
78
78
  const w = n[p];
@@ -99,7 +99,7 @@ class pn extends _ {
99
99
  attach(e) {
100
100
  super.attach(e), e.addEventListener(
101
101
  "paste",
102
- (t) => this.#t(t),
102
+ (t) => this.#e(t),
103
103
  { signal: this.disconnectSignal }
104
104
  );
105
105
  }
@@ -107,14 +107,14 @@ class pn extends _ {
107
107
  this.lastCopied = null;
108
108
  }
109
109
  onKeyDown(e) {
110
- return (e.ctrlKey || e.metaKey) && e.key === "c" ? (this.#e(e.target), !0) : !1;
110
+ return (e.ctrlKey || e.metaKey) && e.key === "c" ? (this.#t(e.target), !0) : !1;
111
111
  }
112
- #e(e) {
113
- const t = this.#n(), i = this.columns.length - 1, n = this.rows.length - 1;
112
+ #t(e) {
113
+ const t = this.#o(), i = this.columns.length - 1, n = this.rows.length - 1;
114
114
  let r;
115
115
  if (t && t.ranges.length > 0) {
116
- const { mode: s, ranges: l } = t, d = l[l.length - 1];
117
- s === "row" ? r = {
116
+ const { mode: a, ranges: l } = t, d = l[l.length - 1];
117
+ a === "row" ? r = {
118
118
  startRow: d.from.row,
119
119
  startCol: 0,
120
120
  endRow: d.to.row,
@@ -128,9 +128,9 @@ class pn extends _ {
128
128
  } else if (!t)
129
129
  r = { startRow: 0, startCol: 0, endRow: n, endCol: i };
130
130
  else {
131
- const s = this.#s(e);
132
- if (!s) return;
133
- r = { startRow: s.row, startCol: s.col, endRow: s.row, endCol: s.col };
131
+ const a = this.#n(e);
132
+ if (!a) return;
133
+ r = { startRow: a.row, startCol: a.col, endRow: a.row, endCol: a.col };
134
134
  }
135
135
  const o = this.#i(r);
136
136
  ie(o.text).then(() => {
@@ -141,61 +141,61 @@ class pn extends _ {
141
141
  });
142
142
  });
143
143
  }
144
- #t(e) {
144
+ #e(e) {
145
145
  const t = e.clipboardData?.getData("text/plain");
146
146
  if (!t) return;
147
147
  e.preventDefault();
148
- const i = Ce(t, this.config), n = this.#n(), r = n?.ranges?.[0], o = r?.from.row ?? 0, s = r?.from.col ?? 0, d = r && (n?.mode === "range" || n?.mode === "row") && (r.from.row !== r.to.row || r.from.col !== r.to.col) ? { endRow: r.to.row, endCol: r.to.col } : null, c = d?.endCol ?? this.columns.length - 1, u = this.columns[s], h = u ? { row: o, col: s, field: u.field, bounds: d } : null, f = [], g = i[0]?.length ?? 0;
149
- for (let w = 0; w < g && s + w <= c; w++) {
150
- const b = this.columns[s + w];
148
+ const i = Ce(t, this.config), n = this.#o(), r = n?.ranges?.[0], o = r?.from.row ?? 0, a = r?.from.col ?? 0, d = r && (n?.mode === "range" || n?.mode === "row") && (r.from.row !== r.to.row || r.from.col !== r.to.col) ? { endRow: r.to.row, endCol: r.to.col } : null, c = d?.endCol ?? this.columns.length - 1, u = this.columns[a], h = u ? { row: o, col: a, field: u.field, bounds: d } : null, f = [], g = i[0]?.length ?? 0;
149
+ for (let w = 0; w < g && a + w <= c; w++) {
150
+ const b = this.columns[a + w];
151
151
  b && !b.hidden && f.push(b.field);
152
152
  }
153
153
  const p = { rows: i, text: t, target: h, fields: f };
154
- this.emit("paste", p), this.#a(p);
154
+ this.emit("paste", p), this.#s(p);
155
155
  }
156
- #a(e) {
156
+ #s(e) {
157
157
  if (!this.grid) return;
158
158
  const { pasteHandler: t } = this.config;
159
159
  if (t === null) return;
160
- (t ?? yt)(e, this.grid);
160
+ (t ?? Ct)(e, this.grid);
161
161
  }
162
- #n() {
162
+ #o() {
163
163
  return this.grid?.query("getSelection", void 0)?.[0];
164
164
  }
165
165
  #i(e) {
166
- const { startRow: t, startCol: i, endRow: n, endCol: r } = e, o = Math.min(t, n), s = Math.max(t, n), l = Math.min(i, r), d = Math.max(i, r), c = this.config.delimiter ?? " ", u = this.config.newline ?? `
167
- `, h = [], f = this.columns.slice(l, d + 1).filter((g) => !q(g));
166
+ const { startRow: t, startCol: i, endRow: n, endCol: r } = e, o = Math.min(t, n), a = Math.max(t, n), l = Math.min(i, r), d = Math.max(i, r), c = this.config.delimiter ?? " ", u = this.config.newline ?? `
167
+ `, h = [], f = this.columns.slice(l, d + 1).filter((g) => !H(g));
168
168
  if (this.config.includeHeaders) {
169
169
  const g = f.map((p) => p.header || p.field);
170
170
  h.push(g.join(c));
171
171
  }
172
- for (let g = o; g <= s; g++) {
172
+ for (let g = o; g <= a; g++) {
173
173
  const p = this.rows[g];
174
174
  if (!p) continue;
175
175
  const w = f.map((b) => {
176
- const v = p[b.field];
177
- return v == null ? "" : v instanceof Date ? v.toISOString() : String(v);
176
+ const y = p[b.field];
177
+ return y == null ? "" : y instanceof Date ? y.toISOString() : String(y);
178
178
  });
179
179
  h.push(w.join(c));
180
180
  }
181
181
  return {
182
182
  text: h.join(u),
183
- rowCount: s - o + 1,
183
+ rowCount: a - o + 1,
184
184
  columnCount: d - l + 1
185
185
  };
186
186
  }
187
- #s(e) {
187
+ #n(e) {
188
188
  const t = e.closest("[data-field-cache]");
189
189
  if (!t) return null;
190
190
  const i = t.dataset.fieldCache, n = t.dataset.row;
191
191
  if (!i || !n) return null;
192
192
  const r = parseInt(n, 10);
193
193
  if (isNaN(r)) return null;
194
- const o = this.columns.findIndex((s) => s.field === i);
194
+ const o = this.columns.findIndex((a) => a.field === i);
195
195
  return o === -1 ? null : { row: r, col: o };
196
196
  }
197
197
  async copy() {
198
- const e = this.#n(), t = this.columns.length - 1;
198
+ const e = this.#o(), t = this.columns.length - 1;
199
199
  let i = { startRow: 0, startCol: 0, endRow: this.rows.length - 1, endCol: t };
200
200
  if (e && e.ranges.length > 0) {
201
201
  const r = e.ranges[e.ranges.length - 1];
@@ -211,7 +211,7 @@ class pn extends _ {
211
211
  }
212
212
  async copyRows(e) {
213
213
  if (e.length === 0) return "";
214
- const t = [...e].sort((o, s) => o - s), i = this.columns.length - 1, n = {
214
+ const t = [...e].sort((o, a) => o - a), i = this.columns.length - 1, n = {
215
215
  startRow: t[0],
216
216
  startCol: 0,
217
217
  endRow: t[t.length - 1],
@@ -220,7 +220,7 @@ class pn extends _ {
220
220
  return await ie(r.text), this.lastCopied = { text: r.text, timestamp: Date.now() }, r.text;
221
221
  }
222
222
  async paste() {
223
- const e = await vt();
223
+ const e = await xt();
224
224
  return e ? Ce(e, this.config) : null;
225
225
  }
226
226
  getLastCopied() {
@@ -228,37 +228,37 @@ class pn extends _ {
228
228
  }
229
229
  }
230
230
  const Ee = 100;
231
- function me(a) {
232
- if (a == null)
231
+ function me(s) {
232
+ if (s == null)
233
233
  return Ee;
234
- if (typeof a == "number")
235
- return a;
236
- const e = parseFloat(a);
234
+ if (typeof s == "number")
235
+ return s;
236
+ const e = parseFloat(s);
237
237
  return isNaN(e) ? Ee : e;
238
238
  }
239
- function Re(a) {
240
- return a.map((e) => me(e.width));
239
+ function Re(s) {
240
+ return s.map((e) => me(e.width));
241
241
  }
242
- function Se(a) {
242
+ function Se(s) {
243
243
  const e = [];
244
244
  let t = 0;
245
- for (const i of a)
245
+ for (const i of s)
246
246
  e.push(t), t += me(i.width);
247
247
  return e;
248
248
  }
249
- function ke(a) {
250
- return a.reduce((e, t) => e + me(t.width), 0);
249
+ function ke(s) {
250
+ return s.reduce((e, t) => e + me(t.width), 0);
251
251
  }
252
- function xt(a, e, t, i, n) {
252
+ function Et(s, e, t, i, n) {
253
253
  const r = t.length;
254
254
  if (r === 0)
255
255
  return { startCol: 0, endCol: 0, visibleColumns: [] };
256
- let o = Ct(a, t, i);
256
+ let o = Rt(s, t, i);
257
257
  o = Math.max(0, o - n);
258
- const s = a + e;
258
+ const a = s + e;
259
259
  let l = o;
260
260
  for (let c = o; c < r; c++) {
261
- if (t[c] >= s) {
261
+ if (t[c] >= a) {
262
262
  l = c - 1;
263
263
  break;
264
264
  }
@@ -270,16 +270,16 @@ function xt(a, e, t, i, n) {
270
270
  d.push(c);
271
271
  return { startCol: o, endCol: l, visibleColumns: d };
272
272
  }
273
- function Ct(a, e, t) {
273
+ function Rt(s, e, t) {
274
274
  let i = 0, n = e.length - 1;
275
275
  for (; i < n; ) {
276
276
  const r = Math.floor((i + n) / 2);
277
- e[r] + t[r] <= a ? i = r + 1 : n = r;
277
+ e[r] + t[r] <= s ? i = r + 1 : n = r;
278
278
  }
279
279
  return i;
280
280
  }
281
- function Et(a, e, t) {
282
- return t ? a > e : !1;
281
+ function St(s, e, t) {
282
+ return t ? s > e : !1;
283
283
  }
284
284
  class mn extends _ {
285
285
  name = "columnVirtualization";
@@ -304,9 +304,9 @@ class mn extends _ {
304
304
  this.columnWidths = Re(t), this.columnOffsets = Se(t), this.totalWidth = ke(t), this.endCol = t.length - 1;
305
305
  }
306
306
  detach() {
307
- this.#e(), this.columnWidths = [], this.columnOffsets = [], this.originalColumns = [], this.isVirtualized = !1, this.startCol = 0, this.endCol = 0, this.scrollLeft = 0, this.totalWidth = 0;
307
+ this.#t(), this.columnWidths = [], this.columnOffsets = [], this.originalColumns = [], this.isVirtualized = !1, this.startCol = 0, this.endCol = 0, this.scrollLeft = 0, this.totalWidth = 0;
308
308
  }
309
- #e() {
309
+ #t() {
310
310
  const e = this.gridElement;
311
311
  if (!e) return;
312
312
  const t = e.querySelector(".header-row");
@@ -320,29 +320,29 @@ class mn extends _ {
320
320
  }
321
321
  processColumns(e) {
322
322
  (this.originalColumns.length === 0 || e.length > this.originalColumns.length) && (this.originalColumns = e, this.columnWidths = Re(e), this.columnOffsets = Se(e), this.totalWidth = ke(e));
323
- const i = this.originalColumns, n = Et(
323
+ const i = this.originalColumns, n = St(
324
324
  i.length,
325
325
  this.config.threshold ?? 30,
326
326
  this.config.autoEnable ?? !0
327
327
  );
328
328
  if (this.isVirtualized = n ?? !1, !n)
329
329
  return this.startCol = 0, this.endCol = i.length - 1, [...i];
330
- const r = this.grid.clientWidth || 800, o = xt(
330
+ const r = this.grid.clientWidth || 800, o = Et(
331
331
  this.scrollLeft,
332
332
  r,
333
333
  this.columnOffsets,
334
334
  this.columnWidths,
335
335
  this.config.overscan ?? 3
336
336
  );
337
- return this.startCol = o.startCol, this.endCol = o.endCol, o.visibleColumns.map((s) => i[s]);
337
+ return this.startCol = o.startCol, this.endCol = o.endCol, o.visibleColumns.map((a) => i[a]);
338
338
  }
339
339
  afterRender() {
340
340
  if (!this.isVirtualized) return;
341
341
  const e = this.gridElement;
342
342
  if (!e) return;
343
343
  const t = this.columnOffsets[this.startCol] ?? 0, i = e.querySelector(".header-row"), n = e.querySelectorAll(".data-grid-row");
344
- i && (i.style.paddingLeft = `${t}px`, i.style.minWidth = `${this.totalWidth}px`), n.forEach((s) => {
345
- s.style.paddingLeft = `${t}px`;
344
+ i && (i.style.paddingLeft = `${t}px`, i.style.minWidth = `${this.totalWidth}px`), n.forEach((a) => {
345
+ a.style.paddingLeft = `${t}px`;
346
346
  });
347
347
  const r = e.querySelector(".rows-viewport .rows");
348
348
  r && (r.style.width = `${this.totalWidth}px`);
@@ -370,16 +370,16 @@ class mn extends _ {
370
370
  }
371
371
  }
372
372
  const ne = "@layer tbw-plugins{.tbw-context-menu{position:fixed;background:var(--tbw-context-menu-bg, var(--tbw-color-panel-bg));color:var(--tbw-context-menu-fg, var(--tbw-color-fg));border:1px solid var(--tbw-context-menu-border, var(--tbw-color-border));border-radius:var(--tbw-context-menu-radius, var(--tbw-border-radius));box-shadow:var(--tbw-context-menu-shadow, 0 2px 10px var(--tbw-color-shadow));min-width:var(--tbw-context-menu-min-width, var(--tbw-menu-min-width));padding:var(--tbw-spacing-xs) 0;z-index:10000;font-size:var(--tbw-context-menu-font-size, var(--tbw-font-size-sm));font-family:var(--tbw-context-menu-font-family, var(--tbw-font-family))}.tbw-context-menu-item{display:flex;align-items:center;padding:var(--tbw-context-menu-item-padding, var(--tbw-menu-item-padding));cursor:pointer;gap:var(--tbw-context-menu-item-gap, var(--tbw-menu-item-gap))}.tbw-context-menu-item:hover:not(.disabled){background:var(--tbw-context-menu-hover, var(--tbw-color-row-hover))}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:var(--tbw-context-menu-danger, var(--tbw-color-danger))}.tbw-context-menu-icon{width:var(--tbw-context-menu-icon-size, var(--tbw-icon-size));text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted));font-size:var(--tbw-context-menu-shortcut-size, var(--tbw-font-size-xs))}.tbw-context-menu-arrow{font-size:var(--tbw-context-menu-arrow-size, var(--tbw-font-size-2xs));color:var(--tbw-context-menu-muted, var(--tbw-color-fg-muted))}.tbw-context-menu-separator{height:1px;background:var(--tbw-context-menu-border, var(--tbw-color-border));margin:var(--tbw-spacing-xs) 0}}";
373
- function he(a, e) {
374
- return (typeof a == "function" ? a(e) : a).filter((i) => !(i.hidden === !0 || typeof i.hidden == "function" && i.hidden(e)));
373
+ function he(s, e) {
374
+ return (typeof s == "function" ? s(e) : s).filter((i) => !(i.hidden === !0 || typeof i.hidden == "function" && i.hidden(e)));
375
375
  }
376
- function Rt(a, e) {
377
- return a.disabled === !0 ? !0 : typeof a.disabled == "function" ? a.disabled(e) : !1;
376
+ function kt(s, e) {
377
+ return s.disabled === !0 ? !0 : typeof s.disabled == "function" ? s.disabled(e) : !1;
378
378
  }
379
- function fe(a, e, t, i = ht.submenuArrow) {
379
+ function fe(s, e, t, i = ht.submenuArrow) {
380
380
  const n = document.createElement("div");
381
381
  n.className = "tbw-context-menu", n.setAttribute("role", "menu");
382
- for (const r of a) {
382
+ for (const r of s) {
383
383
  if (r.separator) {
384
384
  const d = document.createElement("div");
385
385
  d.className = "tbw-context-menu-separator", d.setAttribute("role", "separator"), n.appendChild(d);
@@ -387,8 +387,8 @@ function fe(a, e, t, i = ht.submenuArrow) {
387
387
  }
388
388
  const o = document.createElement("div");
389
389
  o.className = "tbw-context-menu-item", r.cssClass && o.classList.add(r.cssClass), o.setAttribute("role", "menuitem"), o.setAttribute("data-id", r.id);
390
- const s = Rt(r, e);
391
- if (s && (o.classList.add("disabled"), o.setAttribute("aria-disabled", "true")), r.icon) {
390
+ const a = kt(r, e);
391
+ if (a && (o.classList.add("disabled"), o.setAttribute("aria-disabled", "true")), r.icon) {
392
392
  const d = document.createElement("span");
393
393
  d.className = "tbw-context-menu-icon", d.innerHTML = r.icon, o.appendChild(d);
394
394
  }
@@ -408,34 +408,34 @@ function fe(a, e, t, i = ht.submenuArrow) {
408
408
  c && c.remove();
409
409
  });
410
410
  }
411
- !s && r.action && !r.subMenu && o.addEventListener("click", (d) => {
411
+ !a && r.action && !r.subMenu && o.addEventListener("click", (d) => {
412
412
  d.stopPropagation(), t(r);
413
413
  }), n.appendChild(o);
414
414
  }
415
415
  return n;
416
416
  }
417
- function Ae(a, e, t) {
418
- a.style.position = "fixed", a.style.left = `${e}px`, a.style.top = `${t}px`, a.style.visibility = "hidden", a.style.zIndex = "10000";
419
- const i = a.getBoundingClientRect(), n = window.innerWidth, r = window.innerHeight;
420
- let o = e, s = t;
421
- e + i.width > n && (o = e - i.width), t + i.height > r && (s = t - i.height), o = Math.max(0, o), s = Math.max(0, s), a.style.left = `${o}px`, a.style.top = `${s}px`, a.style.visibility = "visible";
417
+ function Ae(s, e, t) {
418
+ s.style.position = "fixed", s.style.left = `${e}px`, s.style.top = `${t}px`, s.style.visibility = "hidden", s.style.zIndex = "10000";
419
+ const i = s.getBoundingClientRect(), n = window.innerWidth, r = window.innerHeight;
420
+ let o = e, a = t;
421
+ e + i.width > n && (o = e - i.width), t + i.height > r && (a = t - i.height), o = Math.max(0, o), a = Math.max(0, a), s.style.left = `${o}px`, s.style.top = `${a}px`, s.style.visibility = "visible";
422
422
  }
423
- let z = null, O = null, M = null, re = 0;
423
+ let O = null, G = null, N = null, re = 0;
424
424
  const oe = [
425
425
  {
426
426
  id: "copy",
427
427
  name: "Copy",
428
428
  shortcut: "Ctrl+C",
429
- action: (a) => {
430
- a.grid?.plugins?.clipboard?.copy?.();
429
+ action: (s) => {
430
+ s.grid?.plugins?.clipboard?.copy?.();
431
431
  }
432
432
  },
433
433
  { separator: !0, id: "sep1", name: "" },
434
434
  {
435
435
  id: "export-csv",
436
436
  name: "Export CSV",
437
- action: (a) => {
438
- a.grid?.plugins?.export?.exportCsv?.();
437
+ action: (s) => {
438
+ s.grid?.plugins?.export?.exportCsv?.();
439
439
  }
440
440
  }
441
441
  ];
@@ -497,8 +497,8 @@ class it extends _ {
497
497
  const i = getComputedStyle(t), n = [], r = i.getPropertyValue("color-scheme").trim();
498
498
  r && n.push(`color-scheme: ${r}`);
499
499
  for (const o of it.CSS_VARS_TO_COPY) {
500
- const s = i.getPropertyValue(o).trim();
501
- s && n.push(`${o}: ${s}`);
500
+ const a = i.getPropertyValue(o).trim();
501
+ a && n.push(`${o}: ${a}`);
502
502
  }
503
503
  if (n.length > 0) {
504
504
  const o = e.getAttribute("style") || "";
@@ -506,23 +506,23 @@ class it extends _ {
506
506
  }
507
507
  }
508
508
  installGlobalHandlers() {
509
- !M && typeof document < "u" && typeof ne == "string" && ne && (M = document.createElement("style"), M.id = "tbw-context-menu-styles", M.textContent = ne, document.head.appendChild(M)), z || (z = () => {
509
+ !N && typeof document < "u" && typeof ne == "string" && ne && (N = document.createElement("style"), N.id = "tbw-context-menu-styles", N.textContent = ne, document.head.appendChild(N)), O || (O = () => {
510
510
  document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
511
- }, document.addEventListener("click", z)), O || (O = (e) => {
511
+ }, document.addEventListener("click", O)), G || (G = (e) => {
512
512
  e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((i) => i.remove());
513
- }, document.addEventListener("keydown", O));
513
+ }, document.addEventListener("keydown", G));
514
514
  }
515
515
  uninstallGlobalHandlers() {
516
- re--, !(re > 0) && (z && (document.removeEventListener("click", z), z = null), O && (document.removeEventListener("keydown", O), O = null), M && (M.remove(), M = null));
516
+ re--, !(re > 0) && (O && (document.removeEventListener("click", O), O = null), G && (document.removeEventListener("keydown", G), G = null), N && (N.remove(), N = null));
517
517
  }
518
518
  afterRender() {
519
519
  const e = this.gridElement;
520
520
  if (!e) return;
521
- const t = e.children[0];
521
+ const t = e.querySelector(".tbw-grid-root");
522
522
  t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (i) => {
523
523
  const n = i;
524
524
  n.preventDefault();
525
- const r = n.target, o = r.closest("[data-row][data-col]"), s = r.closest(".header-cell");
525
+ const r = n.target, o = r.closest("[data-row][data-col]"), a = r.closest(".header-cell");
526
526
  let l;
527
527
  if (o) {
528
528
  const c = parseInt(o.getAttribute("data-row") ?? "-1", 10), u = parseInt(o.getAttribute("data-col") ?? "-1", 10), h = this.columns[u], f = this.rows[c];
@@ -536,8 +536,8 @@ class it extends _ {
536
536
  isHeader: !1,
537
537
  event: n
538
538
  };
539
- } else if (s) {
540
- const c = parseInt(s.getAttribute("data-col") ?? "-1", 10), u = this.columns[c];
539
+ } else if (a) {
540
+ const c = parseInt(a.getAttribute("data-col") ?? "-1", 10), u = this.columns[c];
541
541
  l = {
542
542
  row: null,
543
543
  rowIndex: -1,
@@ -589,14 +589,14 @@ class it extends _ {
589
589
  return this.isOpen;
590
590
  }
591
591
  }
592
- const St = "@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;.data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}.data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}.data-grid-row>.cell.editing input:not([type=checkbox]),.data-grid-row>.cell.editing select,.data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}.tbw-editor-host{display:contents}--tbw-invalid-bg: light-dark(#fef2f2, #450a0a);--tbw-invalid-border-color: light-dark(#ef4444, #f87171);.data-grid-row>.cell[data-invalid=true]{background:var(--tbw-invalid-bg);outline:1px solid var(--tbw-invalid-border-color);outline-offset:-1px}}}";
593
- function kt(a) {
594
- const e = a.options;
592
+ const At = "@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;&:not(.tbw-grid-mode) .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}.data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}.data-grid-row>.cell.editing input:not([type=checkbox]),.data-grid-row>.cell.editing select,.data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}.tbw-editor-host{display:contents}--tbw-invalid-bg: light-dark(#fef2f2, #450a0a);--tbw-invalid-border-color: light-dark(#ef4444, #f87171);.data-grid-row>.cell[data-invalid=true]{background:var(--tbw-invalid-bg);outline:1px solid var(--tbw-invalid-border-color);outline-offset:-1px}}}";
593
+ function _t(s) {
594
+ const e = s.options;
595
595
  return e ? typeof e == "function" ? e() : e : [];
596
596
  }
597
- function At(a) {
597
+ function Tt(s) {
598
598
  return (e) => {
599
- const t = a.editorParams, i = document.createElement("input");
599
+ const t = s.editorParams, i = document.createElement("input");
600
600
  i.type = "number", i.value = e.value != null ? String(e.value) : "", t?.min !== void 0 && (i.min = String(t.min)), t?.max !== void 0 && (i.max = String(t.max)), t?.step !== void 0 && (i.step = String(t.step)), t?.placeholder && (i.placeholder = t.placeholder);
601
601
  const n = () => e.commit(i.value === "" ? null : Number(i.value));
602
602
  return i.addEventListener("blur", n), i.addEventListener("keydown", (r) => {
@@ -604,15 +604,15 @@ function At(a) {
604
604
  }), i;
605
605
  };
606
606
  }
607
- function _t() {
608
- return (a) => {
607
+ function Lt() {
608
+ return (s) => {
609
609
  const e = document.createElement("input");
610
- return e.type = "checkbox", e.checked = !!a.value, e.addEventListener("change", () => a.commit(e.checked)), e;
610
+ return e.type = "checkbox", e.checked = !!s.value, e.addEventListener("change", () => s.commit(e.checked)), e;
611
611
  };
612
612
  }
613
- function Tt(a) {
613
+ function It(s) {
614
614
  return (e) => {
615
- const t = a.editorParams, i = document.createElement("input");
615
+ const t = s.editorParams, i = document.createElement("input");
616
616
  i.type = "date", e.value instanceof Date ? i.valueAsDate = e.value : typeof e.value == "string" && e.value && (i.value = e.value.split("T")[0]), t?.min && (i.min = t.min), t?.max && (i.max = t.max), t?.placeholder && (i.placeholder = t.placeholder);
617
617
  const n = () => {
618
618
  typeof e.value == "string" ? e.commit(i.value) : e.commit(i.valueAsDate);
@@ -622,20 +622,20 @@ function Tt(a) {
622
622
  }), i;
623
623
  };
624
624
  }
625
- function Lt(a) {
625
+ function Ft(s) {
626
626
  return (e) => {
627
- const t = a.editorParams, i = document.createElement("select");
628
- if (a.multi && (i.multiple = !0), t?.includeEmpty) {
627
+ const t = s.editorParams, i = document.createElement("select");
628
+ if (s.multi && (i.multiple = !0), t?.includeEmpty) {
629
629
  const o = document.createElement("option");
630
630
  o.value = "", o.textContent = t.emptyLabel ?? "", i.appendChild(o);
631
631
  }
632
- kt(a).forEach((o) => {
633
- const s = document.createElement("option");
634
- s.value = String(o.value), s.textContent = o.label, (a.multi && Array.isArray(e.value) && e.value.includes(o.value) || !a.multi && e.value === o.value) && (s.selected = !0), i.appendChild(s);
632
+ _t(s).forEach((o) => {
633
+ const a = document.createElement("option");
634
+ a.value = String(o.value), a.textContent = o.label, (s.multi && Array.isArray(e.value) && e.value.includes(o.value) || !s.multi && e.value === o.value) && (a.selected = !0), i.appendChild(a);
635
635
  });
636
636
  const r = () => {
637
- if (a.multi) {
638
- const o = Array.from(i.selectedOptions).map((s) => s.value);
637
+ if (s.multi) {
638
+ const o = Array.from(i.selectedOptions).map((a) => a.value);
639
639
  e.commit(o);
640
640
  } else
641
641
  e.commit(i.value);
@@ -645,9 +645,9 @@ function Lt(a) {
645
645
  }), i;
646
646
  };
647
647
  }
648
- function It(a) {
648
+ function Pt(s) {
649
649
  return (e) => {
650
- const t = a.editorParams, i = document.createElement("input");
650
+ const t = s.editorParams, i = document.createElement("input");
651
651
  i.type = "text", i.value = e.value != null ? String(e.value) : "", t?.maxLength !== void 0 && (i.maxLength = t.maxLength), t?.pattern && (i.pattern = t.pattern), t?.placeholder && (i.placeholder = t.placeholder);
652
652
  const n = () => {
653
653
  const r = i.value;
@@ -658,55 +658,54 @@ function It(a) {
658
658
  }), i;
659
659
  };
660
660
  }
661
- function Ft(a) {
662
- switch (a.type) {
661
+ function Dt(s) {
662
+ switch (s.type) {
663
663
  case "number":
664
- return At(a);
664
+ return Tt(s);
665
665
  case "boolean":
666
- return _t();
666
+ return Lt();
667
667
  case "date":
668
- return Tt(a);
668
+ return It(s);
669
669
  case "select":
670
- return Lt(a);
670
+ return Ft(s);
671
671
  default:
672
- return It(a);
672
+ return Pt(s);
673
673
  }
674
674
  }
675
- const Z = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
676
- function Pt(a, e) {
675
+ function Mt(s, e) {
677
676
  if (e.editor) return e.editor;
678
677
  if (e.__editorTemplate) return "template";
679
678
  if (!e.type) return;
680
- const i = a.effectiveConfig?.typeDefaults;
679
+ const i = s.effectiveConfig?.typeDefaults;
681
680
  if (i?.[e.type]?.editor)
682
681
  return i[e.type].editor;
683
- const n = a.__frameworkAdapter;
682
+ const n = s.__frameworkAdapter;
684
683
  if (n?.getTypeDefault) {
685
684
  const r = n.getTypeDefault(e.type);
686
685
  if (r?.editor)
687
686
  return r.editor;
688
687
  }
689
688
  }
690
- function $(a) {
691
- return !(typeof a != "string" || a === "__proto__" || a === "constructor" || a === "prototype");
689
+ function U(s) {
690
+ return !(typeof s != "string" || s === "__proto__" || s === "constructor" || s === "prototype");
692
691
  }
693
- function Dt(a) {
694
- const e = (a.__editingCellCount ?? 0) + 1;
695
- a.__editingCellCount = e, a.setAttribute("data-has-editing", "");
692
+ function Nt(s) {
693
+ const e = (s.__editingCellCount ?? 0) + 1;
694
+ s.__editingCellCount = e, s.setAttribute("data-has-editing", "");
696
695
  }
697
- function Mt(a) {
698
- a.__editingCellCount = 0, a.removeAttribute("data-has-editing");
696
+ function qt(s) {
697
+ s.__editingCellCount = 0, s.removeAttribute("data-has-editing");
699
698
  }
700
- function U(a, e, t) {
701
- return a instanceof HTMLInputElement ? a.type === "checkbox" ? a.checked : a.type === "number" ? a.value === "" ? null : Number(a.value) : a.type === "date" ? typeof t == "string" ? a.value : a.valueAsDate : typeof t == "number" ? a.value === "" ? null : Number(a.value) : t == null && a.value === "" ? t : a.value : e?.type === "number" && a.value !== "" || typeof t == "number" && a.value !== "" ? Number(a.value) : t == null && a.value === "" ? t : a.value;
699
+ function W(s, e, t) {
700
+ return s instanceof HTMLInputElement ? s.type === "checkbox" ? s.checked : s.type === "number" ? s.value === "" ? null : Number(s.value) : s.type === "date" ? typeof t == "string" ? s.value : s.valueAsDate : typeof t == "number" ? s.value === "" ? null : Number(s.value) : t == null && s.value === "" ? t : s.value : e?.type === "number" && s.value !== "" || typeof t == "number" && s.value !== "" ? Number(s.value) : t == null && s.value === "" ? t : s.value;
702
701
  }
703
- function _e(a) {
702
+ function _e(s) {
704
703
  }
705
- function Nt(a, e, t, i) {
706
- const n = a.querySelector("input,textarea,select");
704
+ function Ht(s, e, t, i) {
705
+ const n = s.querySelector("input,textarea,select");
707
706
  n && (n.addEventListener("blur", () => {
708
- t(U(n, e, i));
709
- }), n instanceof HTMLInputElement && n.type === "checkbox" ? n.addEventListener("change", () => t(n.checked)) : n instanceof HTMLSelectElement && n.addEventListener("change", () => t(U(n, e, i))));
707
+ t(W(n, e, i));
708
+ }), n instanceof HTMLInputElement && n.type === "checkbox" ? n.addEventListener("change", () => t(n.checked)) : n instanceof HTMLSelectElement && n.addEventListener("change", () => t(W(n, e, i))));
710
709
  }
711
710
  class wn extends _ {
712
711
  static manifest = {
@@ -742,20 +741,26 @@ class wn extends _ {
742
741
  ]
743
742
  };
744
743
  name = "editing";
745
- styles = St;
744
+ styles = At;
746
745
  get defaultConfig() {
747
746
  return {
747
+ mode: "row",
748
748
  editOn: "click"
749
749
  };
750
750
  }
751
+ get #t() {
752
+ return this.config.mode === "grid";
753
+ }
751
754
  #e = -1;
752
- #t = -1;
753
- #a = /* @__PURE__ */ new Map();
754
- #n = /* @__PURE__ */ new Set();
755
+ #s = -1;
756
+ #o = /* @__PURE__ */ new Map();
755
757
  #i = /* @__PURE__ */ new Set();
756
- #s = !1;
757
- #d = -1;
758
+ #n = /* @__PURE__ */ new Set();
759
+ #u = !1;
760
+ #l = -1;
758
761
  #r = /* @__PURE__ */ new Map();
762
+ #d = !1;
763
+ #f = !1;
759
764
  attach(e) {
760
765
  super.attach(e);
761
766
  const t = this.disconnectSignal, i = e;
@@ -770,54 +775,98 @@ class wn extends _ {
770
775
  }, document.addEventListener(
771
776
  "keydown",
772
777
  (n) => {
773
- if (n.key === "Escape" && this.#e !== -1) {
778
+ if (!this.#t && n.key === "Escape" && this.#e !== -1) {
774
779
  if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(n) === !1)
775
780
  return;
776
- this.#o(this.#e, !0);
781
+ this.#a(this.#e, !0);
777
782
  }
778
783
  },
779
784
  { capture: !0, signal: t }
780
785
  ), document.addEventListener(
781
786
  "mousedown",
782
787
  (n) => {
783
- if (this.#e === -1) return;
788
+ if (this.#t || this.#e === -1) return;
784
789
  const r = i.findRenderedRowElement?.(this.#e);
785
790
  !r || (n.composedPath && n.composedPath() || []).includes(r) || this.config.onBeforeEditClose && this.config.onBeforeEditClose(n) === !1 || queueMicrotask(() => {
786
- this.#e !== -1 && this.#o(this.#e, !1);
791
+ this.#e !== -1 && this.#a(this.#e, !1);
787
792
  });
788
793
  },
789
794
  { signal: t }
790
- );
795
+ ), this.#t && (this.gridElement.classList.add("tbw-grid-mode"), this.requestRender(), this.gridElement.addEventListener(
796
+ "focusin",
797
+ (n) => {
798
+ const r = n.target;
799
+ if (r.matches(M)) {
800
+ if (this.#f) {
801
+ r.blur(), this.gridElement.focus();
802
+ return;
803
+ }
804
+ this.#d = !0;
805
+ }
806
+ },
807
+ { signal: t }
808
+ ), this.gridElement.addEventListener(
809
+ "focusout",
810
+ (n) => {
811
+ const r = n.relatedTarget;
812
+ (!r || !this.gridElement.contains(r) || !r.matches(M)) && (this.#d = !1);
813
+ },
814
+ { signal: t }
815
+ ), this.gridElement.addEventListener(
816
+ "keydown",
817
+ (n) => {
818
+ if (n.key === "Escape" && this.#d) {
819
+ const r = document.activeElement;
820
+ r && this.gridElement.contains(r) && (r.blur(), this.gridElement.focus()), this.#d = !1, this.#f = !0, n.preventDefault(), n.stopPropagation();
821
+ }
822
+ },
823
+ { capture: !0, signal: t }
824
+ ), this.gridElement.addEventListener(
825
+ "mousedown",
826
+ (n) => {
827
+ n.target.matches(M) && (this.#f = !1);
828
+ },
829
+ { signal: t }
830
+ ));
791
831
  }
792
832
  detach() {
793
- this.#e = -1, this.#t = -1, this.#a.clear(), this.#n.clear(), this.#i.clear(), super.detach();
833
+ this.gridElement.classList.remove("tbw-grid-mode"), this.#e = -1, this.#s = -1, this.#o.clear(), this.#i.clear(), this.#n.clear(), this.#d = !1, this.#f = !1, super.detach();
794
834
  }
795
835
  handleQuery(e) {
796
836
  if (e.type === "isEditing")
797
- return this.#e !== -1;
837
+ return this.#t || this.#e !== -1;
798
838
  }
799
839
  onCellClick(e) {
840
+ if (this.#t) return !1;
800
841
  const t = this.grid, i = this.config.editOn ?? t.effectiveConfig?.editOn;
801
842
  if (i === !1 || i === "manual" || i !== "click" && i !== "dblclick") return !1;
802
843
  const n = e.originalEvent.type === "dblclick";
803
844
  if (i === "click" && n || i === "dblclick" && !n) return !1;
804
845
  const { rowIndex: r } = e;
805
- return t._columns?.some((s) => s.editable) ? (e.originalEvent.stopPropagation(), this.beginBulkEdit(r), !0) : !1;
846
+ return t._columns?.some((a) => a.editable) ? (e.originalEvent.stopPropagation(), this.beginBulkEdit(r), !0) : !1;
806
847
  }
807
848
  onKeyDown(e) {
808
849
  const t = this.grid;
809
- if (e.key === "Escape" && this.#e !== -1)
810
- return this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1 || this.#o(this.#e, !0), !0;
811
- if ((e.key === "ArrowUp" || e.key === "ArrowDown") && this.#e !== -1) {
850
+ if (e.key === "Escape") {
851
+ if (this.#t && this.#d) {
852
+ const i = document.activeElement;
853
+ return i && this.gridElement.contains(i) && i.blur(), this.#d = !1, this.requestAfterRender(), !0;
854
+ }
855
+ if (this.#e !== -1 && !this.#t)
856
+ return this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1 || this.#a(this.#e, !0), !0;
857
+ }
858
+ if (this.#t && !this.#d && (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight"))
859
+ return !1;
860
+ if ((e.key === "ArrowUp" || e.key === "ArrowDown") && this.#e !== -1 && !this.#t) {
812
861
  if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1)
813
862
  return !0;
814
863
  const i = t._rows.length - 1, n = this.#e;
815
- return this.#o(n, !1), e.key === "ArrowDown" ? t._focusRow = Math.min(i, t._focusRow + 1) : t._focusRow = Math.max(0, t._focusRow - 1), e.preventDefault(), P(t), this.requestAfterRender(), !0;
864
+ return this.#a(n, !1), e.key === "ArrowDown" ? t._focusRow = Math.min(i, t._focusRow + 1) : t._focusRow = Math.max(0, t._focusRow - 1), e.preventDefault(), F(t), this.requestAfterRender(), !0;
816
865
  }
817
- if (e.key === "Tab" && this.#e !== -1) {
866
+ if (e.key === "Tab" && (this.#e !== -1 || this.#t)) {
818
867
  e.preventDefault();
819
868
  const i = !e.shiftKey;
820
- return this.#g(i), !0;
869
+ return this.#w(i), !0;
821
870
  }
822
871
  if (e.key === " " || e.key === "Spacebar") {
823
872
  if (this.#e !== -1)
@@ -826,23 +875,25 @@ class wn extends _ {
826
875
  if (i >= 0 && n >= 0) {
827
876
  const r = t._visibleColumns[n], o = t._rows[i];
828
877
  if (r?.editable && r.type === "boolean" && o) {
829
- const s = r.field;
830
- if ($(s)) {
831
- const d = !o[s];
832
- return this.#f(i, r, d, o), e.preventDefault(), this.requestRender(), !0;
878
+ const a = r.field;
879
+ if (U(a)) {
880
+ const d = !o[a];
881
+ return this.#b(i, r, d, o), e.preventDefault(), this.requestRender(), !0;
833
882
  }
834
883
  }
835
884
  }
836
885
  return !1;
837
886
  }
838
887
  if (e.key === "Enter" && !e.shiftKey) {
888
+ if (this.#t && !this.#d)
889
+ return this.#h(), !0;
839
890
  if (this.#e !== -1)
840
891
  return !!(this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1);
841
892
  const i = this.config.editOn ?? t.effectiveConfig?.editOn;
842
893
  if (i === !1 || i === "manual") return !1;
843
894
  const n = t._focusRow, r = t._focusCol;
844
- if (n >= 0 && t._columns?.some((s) => s.editable)) {
845
- const s = t._visibleColumns[r], l = t._rows[n], d = s?.field ?? "", c = d && l ? l[d] : void 0, u = this.gridElement.querySelector(`[data-row="${n}"][data-col="${r}"]`), h = new CustomEvent("cell-activate", {
895
+ if (n >= 0 && t._columns?.some((a) => a.editable)) {
896
+ const a = t._visibleColumns[r], l = t._rows[n], d = a?.field ?? "", c = d && l ? l[d] : void 0, u = this.gridElement.querySelector(`[data-row="${n}"][data-col="${r}"]`), h = new CustomEvent("cell-activate", {
846
897
  cancelable: !0,
847
898
  bubbles: !0,
848
899
  detail: {
@@ -874,8 +925,8 @@ class wn extends _ {
874
925
  if (!r.type) return r;
875
926
  let o;
876
927
  if (i?.[r.type]?.editorParams && (o = i[r.type].editorParams), !o && n?.getTypeDefault) {
877
- const s = n.getTypeDefault(r.type);
878
- s?.editorParams && (o = s.editorParams);
928
+ const a = n.getTypeDefault(r.type);
929
+ a?.editorParams && (o = a.editorParams);
879
930
  }
880
931
  return o ? {
881
932
  ...r,
@@ -885,78 +936,83 @@ class wn extends _ {
885
936
  }
886
937
  afterRender() {
887
938
  const e = this.grid;
888
- if (this.#s && (this.#s = !1, this.#b(e)), this.#d !== -1) {
889
- const t = this.#d;
890
- this.#d = -1, e.animateRow?.(t, "change");
891
- }
892
- if (this.#i.size !== 0)
893
- for (const t of this.#i) {
894
- const [i, n] = t.split(":"), r = parseInt(i, 10), o = parseInt(n, 10), s = e.findRenderedRowElement?.(r);
895
- if (!s) continue;
896
- const l = s.querySelector(`.cell[data-col="${o}"]`);
939
+ if (this.#u && (this.#u = !1, this.#x(e)), this.#l !== -1) {
940
+ const t = this.#l;
941
+ this.#l = -1, e.animateRow?.(t, "change");
942
+ }
943
+ if (!this.#t && this.#n.size !== 0)
944
+ for (const t of this.#n) {
945
+ const [i, n] = t.split(":"), r = parseInt(i, 10), o = parseInt(n, 10), a = e.findRenderedRowElement?.(r);
946
+ if (!a) continue;
947
+ const l = a.querySelector(`.cell[data-col="${o}"]`);
897
948
  if (!l || l.classList.contains("editing")) continue;
898
949
  const d = e._rows[r], c = e._visibleColumns[o];
899
- d && c && this.#l(d, r, c, o, l, !0);
950
+ d && c && this.#m(d, r, c, o, l, !0);
900
951
  }
901
952
  }
953
+ afterCellRender(e) {
954
+ if (!this.#t) return;
955
+ const { row: t, rowIndex: i, column: n, colIndex: r, cellElement: o } = e;
956
+ n.editable && (o.classList.contains("editing") || this.#m(t, i, n, r, o, !0));
957
+ }
902
958
  onScrollRender() {
903
959
  this.afterRender();
904
960
  }
905
961
  get changedRows() {
906
962
  const e = [];
907
- for (const t of this.#n) {
963
+ for (const t of this.#i) {
908
964
  const i = this.grid.getRow(t);
909
965
  i && e.push(i);
910
966
  }
911
967
  return e;
912
968
  }
913
969
  get changedRowIds() {
914
- return Array.from(this.#n);
970
+ return Array.from(this.#i);
915
971
  }
916
972
  get activeEditRow() {
917
973
  return this.#e;
918
974
  }
919
975
  get activeEditCol() {
920
- return this.#t;
976
+ return this.#s;
921
977
  }
922
978
  isRowEditing(e) {
923
979
  return this.#e === e;
924
980
  }
925
981
  isCellEditing(e, t) {
926
- return this.#i.has(`${e}:${t}`);
982
+ return this.#n.has(`${e}:${t}`);
927
983
  }
928
984
  isRowChanged(e) {
929
985
  const t = this.grid, i = t._rows[e];
930
986
  if (!i) return !1;
931
987
  try {
932
988
  const n = t.getRowId?.(i);
933
- return n ? this.#n.has(n) : !1;
989
+ return n ? this.#i.has(n) : !1;
934
990
  } catch {
935
991
  return !1;
936
992
  }
937
993
  }
938
994
  isRowChangedById(e) {
939
- return this.#n.has(e);
995
+ return this.#i.has(e);
940
996
  }
941
997
  setInvalid(e, t, i = "") {
942
998
  let n = this.#r.get(e);
943
- n || (n = /* @__PURE__ */ new Map(), this.#r.set(e, n)), n.set(t, i), this.#c(e, t, !0);
999
+ n || (n = /* @__PURE__ */ new Map(), this.#r.set(e, n)), n.set(t, i), this.#p(e, t, !0);
944
1000
  }
945
1001
  clearInvalid(e, t) {
946
1002
  const i = this.#r.get(e);
947
- i && (i.delete(t), i.size === 0 && this.#r.delete(e)), this.#c(e, t, !1);
1003
+ i && (i.delete(t), i.size === 0 && this.#r.delete(e)), this.#p(e, t, !1);
948
1004
  }
949
1005
  clearRowInvalid(e) {
950
1006
  const t = this.#r.get(e);
951
1007
  if (t) {
952
1008
  const i = Array.from(t.keys());
953
- this.#r.delete(e), i.forEach((n) => this.#c(e, n, !1));
1009
+ this.#r.delete(e), i.forEach((n) => this.#p(e, n, !1));
954
1010
  }
955
1011
  }
956
1012
  clearAllInvalid() {
957
1013
  const e = Array.from(this.#r.entries());
958
1014
  this.#r.clear(), e.forEach(([t, i]) => {
959
- i.forEach((n, r) => this.#c(t, r, !1));
1015
+ i.forEach((n, r) => this.#p(t, r, !1));
960
1016
  });
961
1017
  }
962
1018
  isCellInvalid(e, t) {
@@ -972,18 +1028,18 @@ class wn extends _ {
972
1028
  getInvalidFields(e) {
973
1029
  return new Map(this.#r.get(e) ?? []);
974
1030
  }
975
- #c(e, t, i) {
1031
+ #p(e, t, i) {
976
1032
  const n = this.grid, r = n._visibleColumns?.findIndex((c) => c.field === t);
977
1033
  if (r === -1 || r === void 0) return;
978
- const s = n._rows?.findIndex((c) => {
1034
+ const a = n._rows?.findIndex((c) => {
979
1035
  try {
980
1036
  return n.getRowId?.(c) === e;
981
1037
  } catch {
982
1038
  return !1;
983
1039
  }
984
1040
  });
985
- if (s === -1 || s === void 0) return;
986
- const d = n.findRenderedRowElement?.(s)?.querySelector(`.cell[data-col="${r}"]`);
1041
+ if (a === -1 || a === void 0) return;
1042
+ const d = n.findRenderedRowElement?.(a)?.querySelector(`.cell[data-col="${r}"]`);
987
1043
  if (d)
988
1044
  if (i) {
989
1045
  d.setAttribute("data-invalid", "true");
@@ -994,30 +1050,30 @@ class wn extends _ {
994
1050
  }
995
1051
  resetChangedRows(e) {
996
1052
  const t = this.changedRows, i = this.changedRowIds;
997
- this.#n.clear(), this.#h(), e || this.emit("changed-rows-reset", { rows: t, ids: i }), this.grid._rowPool?.forEach((r) => r.classList.remove("changed"));
1053
+ this.#i.clear(), this.#c(), e || this.emit("changed-rows-reset", { rows: t, ids: i }), this.grid._rowPool?.forEach((r) => r.classList.remove("changed"));
998
1054
  }
999
1055
  beginCellEdit(e, t) {
1000
1056
  const i = this.grid, n = i._visibleColumns.findIndex((l) => l.field === t);
1001
1057
  if (n === -1 || !i._visibleColumns[n]?.editable) return;
1002
- const s = i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${n}"]`);
1003
- s && this.#m(e, n, s);
1058
+ const a = i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${n}"]`);
1059
+ a && this.#v(e, n, a);
1004
1060
  }
1005
1061
  beginBulkEdit(e) {
1006
1062
  const t = this.grid;
1007
- if ((this.config.editOn ?? t.effectiveConfig?.editOn) === !1 || !t._columns?.some((s) => s.editable)) return;
1063
+ if ((this.config.editOn ?? t.effectiveConfig?.editOn) === !1 || !t._columns?.some((a) => a.editable)) return;
1008
1064
  const r = t.findRenderedRowElement?.(e);
1009
1065
  if (!r) return;
1010
1066
  const o = t._rows[e];
1011
- this.#p(e, o), Array.from(r.children).forEach((s, l) => {
1067
+ this.#g(e, o), Array.from(r.children).forEach((a, l) => {
1012
1068
  const d = t._visibleColumns[l];
1013
1069
  if (d?.editable) {
1014
- const c = s;
1015
- c.classList.contains("editing") || this.#l(o, e, d, l, c, !0);
1070
+ const c = a;
1071
+ c.classList.contains("editing") || this.#m(o, e, d, l, c, !0);
1016
1072
  }
1017
1073
  }), setTimeout(() => {
1018
- let s = r.querySelector(`.cell[data-col="${t._focusCol}"]`);
1019
- if (s?.classList.contains("editing") || (s = r.querySelector(".cell.editing")), s?.classList.contains("editing")) {
1020
- const l = s.querySelector(Z);
1074
+ let a = r.querySelector(`.cell[data-col="${t._focusCol}"]`);
1075
+ if (a?.classList.contains("editing") || (a = r.querySelector(".cell.editing")), a?.classList.contains("editing")) {
1076
+ const l = a.querySelector(M);
1021
1077
  try {
1022
1078
  l?.focus({ preventScroll: !0 });
1023
1079
  } catch {
@@ -1026,42 +1082,54 @@ class wn extends _ {
1026
1082
  }, 0);
1027
1083
  }
1028
1084
  commitActiveRowEdit() {
1029
- this.#e !== -1 && this.#o(this.#e, !1);
1085
+ this.#e !== -1 && this.#a(this.#e, !1);
1030
1086
  }
1031
1087
  cancelActiveRowEdit() {
1032
- this.#e !== -1 && this.#o(this.#e, !0);
1088
+ this.#e !== -1 && this.#a(this.#e, !0);
1033
1089
  }
1034
- #m(e, t, i) {
1090
+ #v(e, t, i) {
1035
1091
  const n = this.grid, r = n._rows[e], o = n._visibleColumns[t];
1036
- !r || !o?.editable || i.classList.contains("editing") || (this.#e !== e && this.#p(e, r), this.#t = t, this.#l(r, e, o, t, i, !1));
1092
+ !r || !o?.editable || i.classList.contains("editing") || (this.#e !== e && this.#g(e, r), this.#s = t, this.#m(r, e, o, t, i, !1));
1093
+ }
1094
+ #h() {
1095
+ const e = this.grid, t = e._focusRow, i = e._focusCol;
1096
+ if (t < 0 || i < 0) return;
1097
+ const r = e.findRenderedRowElement?.(t)?.querySelector(`.cell[data-col="${i}"]`);
1098
+ if (r?.classList.contains("editing")) {
1099
+ const o = r.querySelector(M);
1100
+ o && (this.#f = !1, o.focus(), this.#d = !0, o instanceof HTMLInputElement && (o.type === "text" || o.type === "number") && o.select());
1101
+ }
1037
1102
  }
1038
- #g(e) {
1039
- const t = this.grid, i = t._rows, n = this.#e, r = t._visibleColumns.map((d, c) => d.editable ? c : -1).filter((d) => d >= 0);
1103
+ #w(e) {
1104
+ const t = this.grid, i = t._rows, n = this.#t ? t._focusRow : this.#e, r = t._visibleColumns.map((d, c) => d.editable ? c : -1).filter((d) => d >= 0);
1040
1105
  if (r.length === 0) return;
1041
- const s = r.indexOf(t._focusCol) + (e ? 1 : -1);
1042
- if (s >= 0 && s < r.length) {
1043
- t._focusCol = r[s];
1044
- const c = t.findRenderedRowElement?.(n)?.querySelector(`.cell[data-col="${r[s]}"]`);
1045
- c?.classList.contains("editing") && c.querySelector(Z)?.focus({ preventScroll: !0 }), P(t, { forceHorizontalScroll: !0 });
1106
+ const a = r.indexOf(t._focusCol) + (e ? 1 : -1);
1107
+ if (a >= 0 && a < r.length) {
1108
+ t._focusCol = r[a];
1109
+ const c = t.findRenderedRowElement?.(n)?.querySelector(`.cell[data-col="${r[a]}"]`);
1110
+ c?.classList.contains("editing") && c.querySelector(M)?.focus({ preventScroll: !0 }), F(t, { forceHorizontalScroll: !0 });
1046
1111
  return;
1047
1112
  }
1048
1113
  const l = n + (e ? 1 : -1);
1049
- l >= 0 && l < i.length && (this.#o(n, !1), t._focusRow = l, t._focusCol = e ? r[0] : r[r.length - 1], this.beginBulkEdit(l), P(t, { forceHorizontalScroll: !0 }));
1114
+ l >= 0 && l < i.length && (this.#t ? (t._focusRow = l, t._focusCol = e ? r[0] : r[r.length - 1], F(t, { forceHorizontalScroll: !0 }), this.requestAfterRender(), setTimeout(() => {
1115
+ const c = t.findRenderedRowElement?.(l)?.querySelector(`.cell[data-col="${t._focusCol}"]`);
1116
+ c?.classList.contains("editing") && c.querySelector(M)?.focus({ preventScroll: !0 });
1117
+ }, 0)) : (this.#a(n, !1), t._focusRow = l, t._focusCol = e ? r[0] : r[r.length - 1], this.beginBulkEdit(l), F(t, { forceHorizontalScroll: !0 })));
1050
1118
  }
1051
- #h() {
1119
+ #c() {
1052
1120
  const e = this.grid;
1053
- e._activeEditRows = this.#e, e._rowEditSnapshots = this.#a;
1121
+ e._activeEditRows = this.#e, e._rowEditSnapshots = this.#o;
1054
1122
  }
1055
- #p(e, t) {
1056
- this.#e !== e && (this.#a.set(e, { ...t }), this.#e = e, this.#h());
1123
+ #g(e, t) {
1124
+ this.#e !== e && (this.#o.set(e, { ...t }), this.#e = e, this.#c());
1057
1125
  }
1058
- #o(e, t) {
1126
+ #a(e, t) {
1059
1127
  if (this.#e !== e) return;
1060
- const i = this.grid, n = this.#a.get(e), r = i._rows[e], o = i.findRenderedRowElement?.(e);
1061
- let s;
1128
+ const i = this.grid, n = this.#o.get(e), r = i._rows[e], o = i.findRenderedRowElement?.(e);
1129
+ let a;
1062
1130
  if (r)
1063
1131
  try {
1064
- s = i.getRowId?.(r);
1132
+ a = i.getRowId?.(r);
1065
1133
  } catch {
1066
1134
  }
1067
1135
  if (!t && o && r && o.querySelectorAll(".cell.editing").forEach((d) => {
@@ -1072,17 +1140,17 @@ class wn extends _ {
1072
1140
  return;
1073
1141
  const h = d.querySelector("input,textarea,select");
1074
1142
  if (h) {
1075
- const f = u.field, g = r[f], p = U(h, u, g);
1076
- g !== p && this.#f(e, u, p, r);
1143
+ const f = u.field, g = r[f], p = W(h, u, g);
1144
+ g !== p && this.#b(e, u, p, r);
1077
1145
  }
1078
1146
  }), t && n && r)
1079
1147
  Object.keys(n).forEach((l) => {
1080
1148
  r[l] = n[l];
1081
- }), s && (this.#n.delete(s), this.clearRowInvalid(s));
1149
+ }), a && (this.#i.delete(a), this.clearRowInvalid(a));
1082
1150
  else if (!t && r) {
1083
- const l = this.#w(n, r), d = s ? this.#n.has(s) : l, c = this.emitCancelable("row-commit", {
1151
+ const l = this.#C(n, r), d = a ? this.#i.has(a) : l, c = this.emitCancelable("row-commit", {
1084
1152
  rowIndex: e,
1085
- rowId: s ?? "",
1153
+ rowId: a ?? "",
1086
1154
  row: r,
1087
1155
  oldValue: n,
1088
1156
  newValue: r,
@@ -1092,27 +1160,27 @@ class wn extends _ {
1092
1160
  });
1093
1161
  c && n ? (Object.keys(n).forEach((u) => {
1094
1162
  r[u] = n[u];
1095
- }), s && (this.#n.delete(s), this.clearRowInvalid(s))) : !c && l && this.isAnimationEnabled && (this.#d = e);
1163
+ }), a && (this.#i.delete(a), this.clearRowInvalid(a))) : !c && l && this.isAnimationEnabled && (this.#l = e);
1096
1164
  }
1097
- this.#a.delete(e), this.#e = -1, this.#t = -1, this.#h();
1098
- for (const l of this.#i)
1099
- l.startsWith(`${e}:`) && this.#i.delete(l);
1165
+ this.#o.delete(e), this.#e = -1, this.#s = -1, this.#c();
1166
+ for (const l of this.#n)
1167
+ l.startsWith(`${e}:`) && this.#n.delete(l);
1100
1168
  o && (o.querySelectorAll(".cell.editing").forEach((l) => {
1101
- l.classList.remove("editing"), Mt(l.parentElement);
1102
- }), this.requestRender()), this.#s = !0, o || (this.#b(i), this.#s = !1);
1169
+ l.classList.remove("editing"), qt(l.parentElement);
1170
+ }), this.requestRender()), this.#u = !0, o || (this.#x(i), this.#u = !1);
1103
1171
  }
1104
- #f(e, t, i, n) {
1172
+ #b(e, t, i, n) {
1105
1173
  const r = t.field;
1106
- if (!$(r)) return;
1174
+ if (!U(r)) return;
1107
1175
  const o = n[r];
1108
1176
  if (o === i) return;
1109
- const s = this.grid;
1177
+ const a = this.grid;
1110
1178
  let l;
1111
1179
  try {
1112
1180
  l = this.grid.getRowId(n);
1113
1181
  } catch {
1114
1182
  }
1115
- const d = l ? !this.#n.has(l) : !0, c = l ? (p) => this.grid.updateRow(l, p, "cascade") : _e;
1183
+ const d = l ? !this.#i.has(l) : !0, c = l ? (p) => this.grid.updateRow(l, p, "cascade") : _e;
1116
1184
  let u = !1;
1117
1185
  const h = l ? (p) => {
1118
1186
  u = !0, this.setInvalid(l, r, p ?? "");
@@ -1131,73 +1199,83 @@ class wn extends _ {
1131
1199
  updateRow: c,
1132
1200
  setInvalid: h
1133
1201
  })) return;
1134
- l && !u && this.isCellInvalid(l, r) && this.clearInvalid(l, r), n[r] = i, l && this.#n.add(l), this.#h(), this.emitPluginEvent("cell-edit-committed", {
1202
+ l && !u && this.isCellInvalid(l, r) && this.clearInvalid(l, r), n[r] = i, l && this.#i.add(l), this.#c(), this.emitPluginEvent("cell-edit-committed", {
1135
1203
  rowIndex: e,
1136
1204
  field: r,
1137
1205
  oldValue: o,
1138
1206
  newValue: i
1139
1207
  });
1140
- const g = s.findRenderedRowElement?.(e);
1208
+ const g = a.findRenderedRowElement?.(e);
1141
1209
  g && g.classList.add("changed");
1142
1210
  }
1143
- #l(e, t, i, n, r, o) {
1211
+ #m(e, t, i, n, r, o) {
1144
1212
  if (!i.editable || r.classList.contains("editing")) return;
1145
- let s;
1213
+ let a;
1146
1214
  try {
1147
- s = this.grid.getRowId(e);
1215
+ a = this.grid.getRowId(e);
1148
1216
  } catch {
1149
1217
  }
1150
- const l = s ? (x) => this.grid.updateRow(s, x, "cascade") : _e, d = $(i.field) ? e[i.field] : void 0;
1151
- r.classList.add("editing"), this.#i.add(`${t}:${n}`);
1218
+ const l = a ? (v) => this.grid.updateRow(a, v, "cascade") : _e, d = U(i.field) ? e[i.field] : void 0;
1219
+ r.classList.add("editing"), this.#n.add(`${t}:${n}`);
1152
1220
  const c = r.parentElement;
1153
- c && Dt(c);
1221
+ c && Nt(c);
1154
1222
  let u = !1;
1155
- const h = (x) => {
1156
- u || this.#e === -1 || this.#f(t, i, x, e);
1223
+ const h = (v) => {
1224
+ u || !this.#t && this.#e === -1 || this.#b(t, i, v, e);
1157
1225
  }, f = () => {
1158
- u = !0, $(i.field) && (e[i.field] = d);
1226
+ u = !0, U(i.field) && (e[i.field] = d);
1159
1227
  }, g = document.createElement("div");
1160
- g.className = "tbw-editor-host", r.innerHTML = "", r.appendChild(g), g.addEventListener("keydown", (x) => {
1161
- if (x.key === "Enter") {
1162
- if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(x) === !1)
1228
+ g.className = "tbw-editor-host", r.innerHTML = "", r.appendChild(g), g.addEventListener("keydown", (v) => {
1229
+ if (v.key === "Enter") {
1230
+ if (this.#t) {
1231
+ v.stopPropagation(), v.preventDefault();
1232
+ const E = g.querySelector("input,textarea,select");
1233
+ E && h(W(E, i, d));
1234
+ return;
1235
+ }
1236
+ if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(v) === !1)
1163
1237
  return;
1164
- x.stopPropagation(), x.preventDefault(), u = !0, this.#o(t, !1);
1238
+ v.stopPropagation(), v.preventDefault(), u = !0, this.#a(t, !1);
1165
1239
  }
1166
- if (x.key === "Escape") {
1167
- if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(x) === !1)
1240
+ if (v.key === "Escape") {
1241
+ if (this.#t) {
1242
+ v.stopPropagation(), v.preventDefault();
1243
+ return;
1244
+ }
1245
+ if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(v) === !1)
1168
1246
  return;
1169
- x.stopPropagation(), x.preventDefault(), f(), this.#o(t, !0);
1247
+ v.stopPropagation(), v.preventDefault(), f(), this.#a(t, !0);
1170
1248
  }
1171
1249
  });
1172
- const p = i, w = p.__editorTemplate, b = Pt(this.grid, p) ?? Ft(i), v = d;
1250
+ const p = i, w = p.__editorTemplate, b = Mt(this.grid, p) ?? Dt(i), y = d;
1173
1251
  if (b === "template" && w)
1174
- this.#u(g, p, e, d, h, f, o, t);
1252
+ this.#y(g, p, e, d, h, f, o, t);
1175
1253
  else if (typeof b == "string") {
1176
- const x = document.createElement(b);
1177
- x.value = v, x.addEventListener("change", () => h(x.value)), g.appendChild(x), o || queueMicrotask(() => {
1178
- g.querySelector(Z)?.focus({ preventScroll: !0 });
1254
+ const v = document.createElement(b);
1255
+ v.value = y, v.addEventListener("change", () => h(v.value)), g.appendChild(v), o || queueMicrotask(() => {
1256
+ g.querySelector(M)?.focus({ preventScroll: !0 });
1179
1257
  });
1180
1258
  } else if (typeof b == "function") {
1181
- const x = {
1259
+ const v = {
1182
1260
  row: e,
1183
- rowId: s ?? "",
1184
- value: v,
1261
+ rowId: a ?? "",
1262
+ value: y,
1185
1263
  field: i.field,
1186
1264
  column: i,
1187
1265
  commit: h,
1188
1266
  cancel: f,
1189
1267
  updateRow: l
1190
- }, R = b(x);
1191
- typeof R == "string" ? (g.innerHTML = R, Nt(g, i, h, d)) : R instanceof Node && (g.appendChild(R), R instanceof HTMLInputElement || R instanceof HTMLSelectElement || R instanceof HTMLTextAreaElement || r.setAttribute("data-editor-managed", "")), o || queueMicrotask(() => {
1192
- g.querySelector(Z)?.focus({ preventScroll: !0 });
1268
+ }, E = b(v);
1269
+ typeof E == "string" ? (g.innerHTML = E, Ht(g, i, h, d)) : E instanceof Node && (g.appendChild(E), E instanceof HTMLInputElement || E instanceof HTMLSelectElement || E instanceof HTMLTextAreaElement || r.setAttribute("data-editor-managed", "")), o || queueMicrotask(() => {
1270
+ g.querySelector(M)?.focus({ preventScroll: !0 });
1193
1271
  });
1194
1272
  } else if (b && typeof b == "object") {
1195
- const x = document.createElement("div");
1196
- x.setAttribute("data-external-editor", ""), x.setAttribute("data-field", i.field), g.appendChild(x), r.setAttribute("data-editor-managed", "");
1197
- const R = {
1273
+ const v = document.createElement("div");
1274
+ v.setAttribute("data-external-editor", ""), v.setAttribute("data-field", i.field), g.appendChild(v), r.setAttribute("data-editor-managed", "");
1275
+ const E = {
1198
1276
  row: e,
1199
- rowId: s ?? "",
1200
- value: v,
1277
+ rowId: a ?? "",
1278
+ value: y,
1201
1279
  field: i.field,
1202
1280
  column: i,
1203
1281
  commit: h,
@@ -1206,17 +1284,17 @@ class wn extends _ {
1206
1284
  };
1207
1285
  if (b.mount)
1208
1286
  try {
1209
- b.mount({ placeholder: x, context: R, spec: b });
1210
- } catch (E) {
1211
- console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`, E);
1287
+ b.mount({ placeholder: v, context: E, spec: b });
1288
+ } catch (R) {
1289
+ console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`, R);
1212
1290
  }
1213
1291
  else
1214
1292
  this.grid.dispatchEvent(
1215
- new CustomEvent("mount-external-editor", { detail: { placeholder: x, spec: b, context: R } })
1293
+ new CustomEvent("mount-external-editor", { detail: { placeholder: v, spec: b, context: E } })
1216
1294
  );
1217
1295
  }
1218
1296
  }
1219
- #u(e, t, i, n, r, o, s, l) {
1297
+ #y(e, t, i, n, r, o, a, l) {
1220
1298
  const d = t.__editorTemplate;
1221
1299
  if (!d) return;
1222
1300
  const c = d.cloneNode(!0), u = t.__compiledEditor;
@@ -1229,7 +1307,7 @@ class wn extends _ {
1229
1307
  cancel: o
1230
1308
  }) : c.querySelectorAll("*").forEach((f) => {
1231
1309
  f.childNodes.length === 1 && f.firstChild?.nodeType === Node.TEXT_NODE && (f.textContent = f.textContent?.replace(/{{\s*value\s*}}/g, n == null ? "" : String(n)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (g, p) => {
1232
- if (!$(p)) return "";
1310
+ if (!U(p)) return "";
1233
1311
  const w = i[p];
1234
1312
  return w == null ? "" : String(w);
1235
1313
  }) || "");
@@ -1241,24 +1319,24 @@ class wn extends _ {
1241
1319
  h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!n : h.value = String(n ?? "");
1242
1320
  let f = !1;
1243
1321
  h.addEventListener("blur", () => {
1244
- f || r(U(h, t, n));
1322
+ f || r(W(h, t, n));
1245
1323
  }), h.addEventListener("keydown", (g) => {
1246
1324
  const p = g;
1247
1325
  if (p.key === "Enter") {
1248
1326
  if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(p) === !1)
1249
1327
  return;
1250
- p.stopPropagation(), p.preventDefault(), f = !0, r(U(h, t, n)), this.#o(l, !1);
1328
+ p.stopPropagation(), p.preventDefault(), f = !0, r(W(h, t, n)), this.#a(l, !1);
1251
1329
  }
1252
1330
  if (p.key === "Escape") {
1253
1331
  if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(p) === !1)
1254
1332
  return;
1255
- p.stopPropagation(), p.preventDefault(), o(), this.#o(l, !0);
1333
+ p.stopPropagation(), p.preventDefault(), o(), this.#a(l, !0);
1256
1334
  }
1257
- }), h instanceof HTMLInputElement && h.type === "checkbox" && h.addEventListener("change", () => r(h.checked)), s || setTimeout(() => h.focus({ preventScroll: !0 }), 0);
1335
+ }), h instanceof HTMLInputElement && h.type === "checkbox" && h.addEventListener("change", () => r(h.checked)), a || setTimeout(() => h.focus({ preventScroll: !0 }), 0);
1258
1336
  }
1259
1337
  e.appendChild(c);
1260
1338
  }
1261
- #w(e, t) {
1339
+ #C(e, t) {
1262
1340
  if (!e) return !1;
1263
1341
  const i = e, n = t, r = /* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(n)]);
1264
1342
  for (const o of r)
@@ -1266,7 +1344,7 @@ class wn extends _ {
1266
1344
  return !0;
1267
1345
  return !1;
1268
1346
  }
1269
- #b(e) {
1347
+ #x(e) {
1270
1348
  queueMicrotask(() => {
1271
1349
  try {
1272
1350
  const t = e._focusRow, i = e._focusCol, n = e.findRenderedRowElement?.(t);
@@ -1282,17 +1360,17 @@ class wn extends _ {
1282
1360
  });
1283
1361
  }
1284
1362
  }
1285
- function Te(a, e = !0) {
1286
- if (a == null) return "";
1287
- if (a instanceof Date) return a.toISOString();
1288
- if (typeof a == "object") return JSON.stringify(a);
1289
- const t = String(a);
1363
+ function Te(s, e = !0) {
1364
+ if (s == null) return "";
1365
+ if (s instanceof Date) return s.toISOString();
1366
+ if (typeof s == "object") return JSON.stringify(s);
1367
+ const t = String(s);
1290
1368
  return e && (t.includes(",") || t.includes('"') || t.includes(`
1291
1369
  `) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
1292
1370
  }
1293
- function qt(a, e, t, i = {}) {
1371
+ function Kt(s, e, t, i = {}) {
1294
1372
  const n = i.delimiter ?? ",", r = i.newline ?? `
1295
- `, o = [], s = i.bom ? "\uFEFF" : "";
1373
+ `, o = [], a = i.bom ? "\uFEFF" : "";
1296
1374
  if (t.includeHeaders !== !1) {
1297
1375
  const l = e.map((d) => {
1298
1376
  const c = d.header || d.field, u = t.processHeader ? t.processHeader(c, d.field) : c;
@@ -1300,27 +1378,27 @@ function qt(a, e, t, i = {}) {
1300
1378
  });
1301
1379
  o.push(l.join(n));
1302
1380
  }
1303
- for (const l of a) {
1381
+ for (const l of s) {
1304
1382
  const d = e.map((c) => {
1305
1383
  let u = l[c.field];
1306
1384
  return t.processCell && (u = t.processCell(u, c.field, l)), Te(u);
1307
1385
  });
1308
1386
  o.push(d.join(n));
1309
1387
  }
1310
- return s + o.join(r);
1388
+ return a + o.join(r);
1311
1389
  }
1312
- function we(a, e) {
1313
- const t = URL.createObjectURL(a), i = document.createElement("a");
1390
+ function we(s, e) {
1391
+ const t = URL.createObjectURL(s), i = document.createElement("a");
1314
1392
  i.href = t, i.download = e, i.style.display = "none", document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(t);
1315
1393
  }
1316
- function Ht(a, e) {
1317
- const t = new Blob([a], { type: "text/csv;charset=utf-8;" });
1394
+ function zt(s, e) {
1395
+ const t = new Blob([s], { type: "text/csv;charset=utf-8;" });
1318
1396
  we(t, e);
1319
1397
  }
1320
- function Le(a) {
1321
- return a.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
1398
+ function Le(s) {
1399
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
1322
1400
  }
1323
- function Kt(a, e, t) {
1401
+ function Ot(s, e, t) {
1324
1402
  let i = `<?xml version="1.0" encoding="UTF-8"?>
1325
1403
  <?mso-application progid="Excel.Sheet"?>
1326
1404
  <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
@@ -1336,14 +1414,14 @@ function Kt(a, e, t) {
1336
1414
  }
1337
1415
  i += "</Row>";
1338
1416
  }
1339
- for (const n of a) {
1417
+ for (const n of s) {
1340
1418
  i += `
1341
1419
  <Row>`;
1342
1420
  for (const r of e) {
1343
1421
  let o = n[r.field];
1344
1422
  t.processCell && (o = t.processCell(o, r.field, n));
1345
- let s = "String", l = "";
1346
- o == null ? l = "" : typeof o == "number" && !isNaN(o) ? (s = "Number", l = String(o)) : o instanceof Date ? (s = "DateTime", l = o.toISOString()) : l = Le(String(o)), i += `<Cell><Data ss:Type="${s}">${l}</Data></Cell>`;
1423
+ let a = "String", l = "";
1424
+ o == null ? l = "" : typeof o == "number" && !isNaN(o) ? (a = "Number", l = String(o)) : o instanceof Date ? (a = "DateTime", l = o.toISOString()) : l = Le(String(o)), i += `<Cell><Data ss:Type="${a}">${l}</Data></Cell>`;
1347
1425
  }
1348
1426
  i += "</Row>";
1349
1427
  }
@@ -1352,8 +1430,8 @@ function Kt(a, e, t) {
1352
1430
  </Worksheet>
1353
1431
  </Workbook>`, i;
1354
1432
  }
1355
- function zt(a, e) {
1356
- const t = e.endsWith(".xls") ? e : `${e}.xls`, i = new Blob([a], {
1433
+ function Gt(s, e) {
1434
+ const t = e.endsWith(".xls") ? e : `${e}.xls`, i = new Blob([s], {
1357
1435
  type: "application/vnd.ms-excel;charset=utf-8;"
1358
1436
  });
1359
1437
  we(i, t);
@@ -1391,17 +1469,17 @@ class bn extends _ {
1391
1469
  l?.selected?.size && (o = [...l.selected].sort((c, u) => c - u).map((c) => this.rows[c]).filter(Boolean));
1392
1470
  }
1393
1471
  t?.rowIndices && (o = t.rowIndices.map((l) => this.rows[l]).filter(Boolean)), this.isExportingFlag = !0;
1394
- let s = n.fileName;
1472
+ let a = n.fileName;
1395
1473
  try {
1396
1474
  switch (e) {
1397
1475
  case "csv": {
1398
- const l = qt(o, r, n, { bom: !0 });
1399
- s = s.endsWith(".csv") ? s : `${s}.csv`, Ht(l, s);
1476
+ const l = Kt(o, r, n, { bom: !0 });
1477
+ a = a.endsWith(".csv") ? a : `${a}.csv`, zt(l, a);
1400
1478
  break;
1401
1479
  }
1402
1480
  case "excel": {
1403
- const l = Kt(o, r, n);
1404
- s = s.endsWith(".xls") ? s : `${s}.xls`, zt(l, s);
1481
+ const l = Ot(o, r, n);
1482
+ a = a.endsWith(".xls") ? a : `${a}.xls`, Gt(l, a);
1405
1483
  break;
1406
1484
  }
1407
1485
  case "json": {
@@ -1413,15 +1491,15 @@ class bn extends _ {
1413
1491
  }
1414
1492
  return h;
1415
1493
  }), d = JSON.stringify(l, null, 2);
1416
- s = s.endsWith(".json") ? s : `${s}.json`;
1494
+ a = a.endsWith(".json") ? a : `${a}.json`;
1417
1495
  const c = new Blob([d], { type: "application/json" });
1418
- we(c, s);
1496
+ we(c, a);
1419
1497
  break;
1420
1498
  }
1421
1499
  }
1422
1500
  this.lastExportInfo = { format: e, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
1423
1501
  format: e,
1424
- fileName: s,
1502
+ fileName: a,
1425
1503
  rowCount: o.length,
1426
1504
  columnCount: r.length
1427
1505
  });
@@ -1452,23 +1530,8 @@ class bn extends _ {
1452
1530
  return this.lastExportInfo;
1453
1531
  }
1454
1532
  }
1455
- function Ot(a) {
1456
- const { totalRows: e, viewportHeight: t, scrollTop: i, rowHeight: n, overscan: r } = a, o = Math.ceil(t / n);
1457
- let s = Math.floor(i / n) - r;
1458
- s < 0 && (s = 0);
1459
- let l = s + o + r * 2;
1460
- return l > e && (l = e), l === e && s > 0 && (s = Math.max(0, l - o - r * 2)), {
1461
- start: s,
1462
- end: l,
1463
- offsetY: s * n,
1464
- totalHeight: e * n
1465
- };
1466
- }
1467
- function Gt(a, e) {
1468
- return a <= e;
1469
- }
1470
- function Bt(a, e, t = !1) {
1471
- const i = a[e.field];
1533
+ function Bt(s, e, t = !1) {
1534
+ const i = s[e.field];
1472
1535
  if (e.operator === "blank")
1473
1536
  return i == null || i === "";
1474
1537
  if (e.operator === "notBlank")
@@ -1506,12 +1569,12 @@ function Bt(a, e, t = !1) {
1506
1569
  return !0;
1507
1570
  }
1508
1571
  }
1509
- function Vt(a, e, t = !1) {
1510
- return e.length ? a.filter((i) => e.every((n) => Bt(i, n, t))) : a;
1572
+ function Vt(s, e, t = !1) {
1573
+ return e.length ? s.filter((i) => e.every((n) => Bt(i, n, t))) : s;
1511
1574
  }
1512
- function Wt(a) {
1575
+ function Wt(s) {
1513
1576
  return JSON.stringify(
1514
- a.map((e) => ({
1577
+ s.map((e) => ({
1515
1578
  field: e.field,
1516
1579
  operator: e.operator,
1517
1580
  value: e.value,
@@ -1519,16 +1582,16 @@ function Wt(a) {
1519
1582
  }))
1520
1583
  );
1521
1584
  }
1522
- function Ie(a, e) {
1585
+ function Ie(s, e) {
1523
1586
  const t = /* @__PURE__ */ new Set();
1524
- for (const i of a) {
1587
+ for (const i of s) {
1525
1588
  const n = i[e];
1526
1589
  n != null && t.add(n);
1527
1590
  }
1528
1591
  return [...t].sort((i, n) => typeof i == "number" && typeof n == "number" ? i - n : String(i).localeCompare(String(n)));
1529
1592
  }
1530
1593
  const $t = '@layer tbw-plugins{tbw-grid{.tbw-quick-filter-input{flex:1;max-width:300px;height:var(--tbw-input-height, 1.75rem);padding:var(--tbw-input-padding, 0 .5rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:var(--tbw-font-size-sm, .8125rem);&:focus{outline:none;border-color:var(--tbw-color-accent)}}.header-cell.filtered:before{content:"";position:absolute;top:var(--tbw-spacing-xs, .25rem);right:var(--tbw-spacing-xs, .25rem);width:var(--tbw-indicator-size, .375rem);height:var(--tbw-indicator-size, .375rem);background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}.tbw-filter-btn{display:var(--tbw-filter-btn-display, inline-flex);visibility:var(--tbw-filter-btn-visibility, visible);align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:var(--tbw-spacing-xs, .25rem);opacity:.4;transition:opacity .15s,visibility 0s,display 0s allow-discrete;color:inherit;vertical-align:middle;transition-behavior:allow-discrete;&:hover,&.active{opacity:1;visibility:visible;display:inline-flex}&.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}}.header-row .cell:hover .tbw-filter-btn,.header-row .cell.filtered .tbw-filter-btn{display:inline-flex;visibility:visible}}}', jt = "@layer tbw-plugins{.tbw-filter-panel{position:fixed;background:var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));color:var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));border:1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-panel-radius, var(--tbw-border-radius, .25rem));box-shadow:0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3))));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));z-index:10000;min-width:200px;max-width:280px;max-height:350px;display:flex;flex-direction:column;font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-font-size, .8125rem);transform-origin:top center}.tbw-filter-panel.tbw-filter-panel-above{transform-origin:bottom center}.tbw-filter-panel.tbw-filter-panel-animated{animation:tbw-filter-panel-enter var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}.tbw-filter-panel.tbw-filter-panel-above.tbw-filter-panel-animated{animation:tbw-filter-panel-enter-above var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}@keyframes tbw-filter-panel-enter{0%{opacity:0;transform:scaleY(.3) translateY(-10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@keyframes tbw-filter-panel-enter-above{0%{opacity:0;transform:scaleY(.3) translateY(10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@supports (anchor-name: --test){.tbw-filter-panel{position-anchor:--tbw-filter-anchor;top:anchor(bottom);left:anchor(left);margin-top:4px;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.tbw-filter-search{margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-search-input{height:var(--tbw-filter-item-height, 28px);width:100%;padding:var(--tbw-filter-search-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-search-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-actions{display:flex;padding:var(--tbw-button-padding-sm, .25rem .125rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-bottom:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-action-btn{background:transparent;border:none;color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));cursor:pointer;font-size:var(--tbw-font-size-xs, .75rem);padding:2px 0}.tbw-filter-action-btn:hover{text-decoration:underline}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));max-height:180px;position:relative}.tbw-filter-values-spacer{width:1px}.tbw-filter-values-content{position:absolute;top:0;left:0;right:0}.tbw-filter-value-item{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding-sm, .25rem .125rem);cursor:pointer;border-radius:3px;height:var(--tbw-filter-item-height, 28px)}.tbw-filter-value-item:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-checkbox{margin:0;cursor:pointer;accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}.tbw-filter-no-match{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem)) 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding-top:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));color:var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));border:none;border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:transparent;color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-range-inputs,.tbw-filter-date-range{display:flex;align-items:flex-end;gap:var(--tbw-spacing-sm, .375rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-range-group,.tbw-filter-date-group{display:flex;flex-direction:column;gap:var(--tbw-spacing-xs, .25rem);flex:1}.tbw-filter-range-label{font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)))}.tbw-filter-range-input,.tbw-filter-date-input{width:100%;height:var(--tbw-filter-item-height, 28px);padding:var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-sm, .375rem);background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-range-input:focus,.tbw-filter-date-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-range-separator{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding-bottom:var(--tbw-spacing-xs, .25rem)}.tbw-filter-range-slider{position:relative;height:24px;margin:var(--tbw-spacing-md, .5rem) 0 var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-range-track{position:absolute;top:50%;left:0;right:0;height:4px;background:var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:2px;transform:translateY(-50%)}.tbw-filter-range-fill{position:absolute;top:50%;height:4px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:2px;transform:translateY(-50%)}.tbw-filter-range-thumb{position:absolute;top:0;width:100%;height:100%;background:none;pointer-events:none;-webkit-appearance:none;appearance:none}.tbw-filter-range-thumb::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border:2px solid var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));border-radius:50%;cursor:pointer;pointer-events:all;box-shadow:0 1px 3px #0003}.tbw-filter-range-thumb::-moz-range-thumb{width:16px;height:16px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border:2px solid var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));border-radius:50%;cursor:pointer;pointer-events:all;box-shadow:0 1px 3px #0003}.tbw-filter-range-thumb::-webkit-slider-thumb:hover{transform:scale(1.1)}.tbw-filter-range-thumb::-moz-range-thumb:hover{transform:scale(1.1)}}";
1531
- class N extends _ {
1594
+ class q extends _ {
1532
1595
  static manifest = {
1533
1596
  events: [
1534
1597
  {
@@ -1575,7 +1638,7 @@ class N extends _ {
1575
1638
  return t;
1576
1639
  }
1577
1640
  }
1578
- return N.DEFAULT_LIST_ITEM_HEIGHT;
1641
+ return q.DEFAULT_LIST_ITEM_HEIGHT;
1579
1642
  }
1580
1643
  syncExcludedValues(e, t) {
1581
1644
  t ? t.type === "set" && t.operator === "notIn" && Array.isArray(t.value) ? this.excludedValues.set(e, new Set(t.value)) : t.type === "set" && this.excludedValues.delete(e) : this.excludedValues.delete(e);
@@ -1604,22 +1667,22 @@ class N extends _ {
1604
1667
  const n = i.getAttribute("data-col");
1605
1668
  if (n === null) return;
1606
1669
  const r = this.visibleColumns[parseInt(n, 10)];
1607
- if (!r || !this.isColumnFilterable(r) || q(r)) return;
1670
+ if (!r || !this.isColumnFilterable(r) || H(r)) return;
1608
1671
  const o = r.field;
1609
1672
  if (!o) return;
1610
- const s = this.filters.has(o);
1673
+ const a = this.filters.has(o);
1611
1674
  let l = i.querySelector(".tbw-filter-btn");
1612
1675
  if (l) {
1613
1676
  const u = l.classList.contains("active");
1614
- if (l.classList.toggle("active", s), i.classList.toggle("filtered", s), u !== s) {
1615
- const h = s ? "filterActive" : "filter";
1677
+ if (l.classList.toggle("active", a), i.classList.toggle("filtered", a), u !== a) {
1678
+ const h = a ? "filterActive" : "filter";
1616
1679
  this.setIcon(l, this.resolveIcon(h));
1617
1680
  }
1618
1681
  return;
1619
1682
  }
1620
1683
  l = document.createElement("button"), l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${r.header ?? o}`);
1621
- const d = s ? "filterActive" : "filter";
1622
- this.setIcon(l, this.resolveIcon(d)), s && (l.classList.add("active"), i.classList.add("filtered")), l.addEventListener("click", (u) => {
1684
+ const d = a ? "filterActive" : "filter";
1685
+ this.setIcon(l, this.resolveIcon(d)), a && (l.classList.add("active"), i.classList.add("filtered")), l.addEventListener("click", (u) => {
1623
1686
  u.stopPropagation(), this.toggleFilterPanel(o, r, l);
1624
1687
  });
1625
1688
  const c = i.querySelector(".resize-handle");
@@ -1710,7 +1773,7 @@ class N extends _ {
1710
1773
  renderPanelContent(e, t, i, n) {
1711
1774
  let r = this.excludedValues.get(e);
1712
1775
  r || (r = /* @__PURE__ */ new Set(), this.excludedValues.set(e, r));
1713
- const o = this.searchText.get(e) ?? "", s = {
1776
+ const o = this.searchText.get(e) ?? "", a = {
1714
1777
  field: e,
1715
1778
  column: t,
1716
1779
  uniqueValues: n,
@@ -1728,13 +1791,13 @@ class N extends _ {
1728
1791
  closePanel: () => this.closeFilterPanel()
1729
1792
  };
1730
1793
  let l = !1;
1731
- if (this.config.filterPanelRenderer && (this.config.filterPanelRenderer(i, s), l = i.children.length > 0), !l && t.type) {
1794
+ if (this.config.filterPanelRenderer && (this.config.filterPanelRenderer(i, a), l = i.children.length > 0), !l && t.type) {
1732
1795
  const d = this.grid.effectiveConfig.typeDefaults?.[t.type];
1733
- d?.filterPanelRenderer && (d.filterPanelRenderer(i, s), l = i.children.length > 0);
1796
+ d?.filterPanelRenderer && (d.filterPanelRenderer(i, a), l = i.children.length > 0);
1734
1797
  }
1735
1798
  if (!l) {
1736
1799
  const d = t.type;
1737
- d === "number" ? this.renderNumberFilterPanel(i, s, n) : d === "date" ? this.renderDateFilterPanel(i, s, n) : this.renderDefaultFilterPanel(i, s, n, r);
1800
+ d === "number" ? this.renderNumberFilterPanel(i, a, n) : d === "date" ? this.renderDateFilterPanel(i, a, n) : this.renderDefaultFilterPanel(i, a, n, r);
1738
1801
  }
1739
1802
  }
1740
1803
  setupPanelCloseHandler(e, t) {
@@ -1754,14 +1817,14 @@ class N extends _ {
1754
1817
  }
1755
1818
  static supportsAnchorPositioning = null;
1756
1819
  static checkAnchorPositioningSupport() {
1757
- return N.supportsAnchorPositioning === null && (N.supportsAnchorPositioning = CSS.supports("anchor-name", "--test")), N.supportsAnchorPositioning;
1820
+ return q.supportsAnchorPositioning === null && (q.supportsAnchorPositioning = CSS.supports("anchor-name", "--test")), q.supportsAnchorPositioning;
1758
1821
  }
1759
1822
  positionPanel(e, t) {
1760
1823
  const n = t.closest(".cell") ?? t;
1761
- if (n.style.anchorName = "--tbw-filter-anchor", this.panelAnchorElement = n, N.checkAnchorPositioningSupport()) {
1824
+ if (n.style.anchorName = "--tbw-filter-anchor", this.panelAnchorElement = n, q.checkAnchorPositioningSupport()) {
1762
1825
  requestAnimationFrame(() => {
1763
- const o = e.getBoundingClientRect(), s = n.getBoundingClientRect();
1764
- o.top < s.top && e.classList.add("tbw-filter-panel-above");
1826
+ const o = e.getBoundingClientRect(), a = n.getBoundingClientRect();
1827
+ o.top < a.top && e.classList.add("tbw-filter-panel-above");
1765
1828
  });
1766
1829
  return;
1767
1830
  }
@@ -1772,10 +1835,10 @@ class N extends _ {
1772
1835
  });
1773
1836
  }
1774
1837
  renderDefaultFilterPanel(e, t, i, n) {
1775
- const { field: r } = t, o = this.getListItemHeight(), s = document.createElement("div");
1776
- s.className = "tbw-filter-search";
1838
+ const { field: r } = t, o = this.getListItemHeight(), a = document.createElement("div");
1839
+ a.className = "tbw-filter-search";
1777
1840
  const l = document.createElement("input");
1778
- l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(r) ?? "", s.appendChild(l), e.appendChild(s);
1841
+ l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(r) ?? "", a.appendChild(l), e.appendChild(a);
1779
1842
  const d = document.createElement("div");
1780
1843
  d.className = "tbw-filter-actions";
1781
1844
  const c = document.createElement("label");
@@ -1792,7 +1855,7 @@ class N extends _ {
1792
1855
  const C = u.checked;
1793
1856
  for (const k of b.keys())
1794
1857
  b.set(k, C);
1795
- f(), R();
1858
+ f(), E();
1796
1859
  }), e.appendChild(d);
1797
1860
  const g = document.createElement("div");
1798
1861
  g.className = "tbw-filter-values";
@@ -1805,107 +1868,107 @@ class N extends _ {
1805
1868
  const k = C == null ? "__null__" : String(C);
1806
1869
  b.set(k, !n.has(C));
1807
1870
  }), f();
1808
- let v = [];
1809
- const x = (C, k) => {
1810
- const T = C == null ? "(Blank)" : String(C), m = C == null ? "__null__" : String(C), y = document.createElement("label");
1811
- y.className = "tbw-filter-value-item", y.style.position = "absolute", y.style.top = `calc(var(--tbw-filter-item-height, 28px) * ${k})`, y.style.left = "0", y.style.right = "0", y.style.boxSizing = "border-box";
1871
+ let y = [];
1872
+ const v = (C, k) => {
1873
+ const T = C == null ? "(Blank)" : String(C), m = C == null ? "__null__" : String(C), x = document.createElement("label");
1874
+ x.className = "tbw-filter-value-item", x.style.position = "absolute", x.style.top = `calc(var(--tbw-filter-item-height, 28px) * ${k})`, x.style.left = "0", x.style.right = "0", x.style.boxSizing = "border-box";
1812
1875
  const L = document.createElement("input");
1813
1876
  L.type = "checkbox", L.className = "tbw-filter-checkbox", L.checked = b.get(m) ?? !0, L.dataset.value = m, L.addEventListener("change", () => {
1814
1877
  b.set(m, L.checked), f();
1815
1878
  });
1816
- const H = document.createElement("span");
1817
- return H.textContent = T, y.appendChild(L), y.appendChild(H), y;
1818
- }, R = () => {
1819
- const C = v.length, k = g.clientHeight, T = g.scrollTop;
1820
- if (p.style.height = `${C * o}px`, Gt(C, N.LIST_BYPASS_THRESHOLD / 3)) {
1821
- w.innerHTML = "", w.style.transform = "translateY(0px)", v.forEach((y, L) => {
1822
- w.appendChild(x(y, L));
1879
+ const K = document.createElement("span");
1880
+ return K.textContent = T, x.appendChild(L), x.appendChild(K), x;
1881
+ }, E = () => {
1882
+ const C = y.length, k = g.clientHeight, T = g.scrollTop;
1883
+ if (p.style.height = `${C * o}px`, ft(C, q.LIST_BYPASS_THRESHOLD / 3)) {
1884
+ w.innerHTML = "", w.style.transform = "translateY(0px)", y.forEach((x, L) => {
1885
+ w.appendChild(v(x, L));
1823
1886
  });
1824
1887
  return;
1825
1888
  }
1826
- const m = Ot({
1889
+ const m = gt({
1827
1890
  totalRows: C,
1828
1891
  viewportHeight: k,
1829
1892
  scrollTop: T,
1830
1893
  rowHeight: o,
1831
- overscan: N.LIST_OVERSCAN
1894
+ overscan: q.LIST_OVERSCAN
1832
1895
  });
1833
1896
  w.style.transform = `translateY(${m.offsetY}px)`, w.innerHTML = "";
1834
- for (let y = m.start; y < m.end; y++)
1835
- w.appendChild(x(v[y], y - m.start));
1836
- }, E = (C) => {
1897
+ for (let x = m.start; x < m.end; x++)
1898
+ w.appendChild(v(y[x], x - m.start));
1899
+ }, R = (C) => {
1837
1900
  const k = this.config.caseSensitive ?? !1, T = k ? C : C.toLowerCase();
1838
- if (v = i.filter((m) => {
1839
- const y = m == null ? "(Blank)" : String(m), L = k ? y : y.toLowerCase();
1901
+ if (y = i.filter((m) => {
1902
+ const x = m == null ? "(Blank)" : String(m), L = k ? x : x.toLowerCase();
1840
1903
  return !C || L.includes(T);
1841
- }), v.length === 0) {
1904
+ }), y.length === 0) {
1842
1905
  p.style.height = "0px", w.innerHTML = "";
1843
1906
  const m = document.createElement("div");
1844
1907
  m.className = "tbw-filter-no-match", m.textContent = "No matching values", w.appendChild(m);
1845
1908
  return;
1846
1909
  }
1847
- R();
1910
+ E();
1848
1911
  };
1849
1912
  g.addEventListener(
1850
1913
  "scroll",
1851
1914
  () => {
1852
- v.length > 0 && R();
1915
+ y.length > 0 && E();
1853
1916
  },
1854
1917
  { passive: !0 }
1855
- ), E(l.value), e.appendChild(g);
1918
+ ), R(l.value), e.appendChild(g);
1856
1919
  let D;
1857
1920
  l.addEventListener("input", () => {
1858
1921
  clearTimeout(D), D = setTimeout(() => {
1859
- this.searchText.set(r, l.value), E(l.value);
1922
+ this.searchText.set(r, l.value), R(l.value);
1860
1923
  }, this.config.debounceMs ?? 150);
1861
1924
  });
1862
1925
  const I = document.createElement("div");
1863
1926
  I.className = "tbw-filter-buttons";
1864
- const F = document.createElement("button");
1865
- F.className = "tbw-filter-apply-btn", F.textContent = "Apply", F.addEventListener("click", () => {
1927
+ const P = document.createElement("button");
1928
+ P.className = "tbw-filter-apply-btn", P.textContent = "Apply", P.addEventListener("click", () => {
1866
1929
  const C = [];
1867
1930
  for (const [k, T] of b)
1868
1931
  if (!T)
1869
1932
  if (k === "__null__")
1870
1933
  C.push(null);
1871
1934
  else {
1872
- const m = i.find((y) => String(y) === k);
1935
+ const m = i.find((x) => String(x) === k);
1873
1936
  C.push(m !== void 0 ? m : k);
1874
1937
  }
1875
1938
  t.applySetFilter(C);
1876
- }), I.appendChild(F);
1939
+ }), I.appendChild(P);
1877
1940
  const S = document.createElement("button");
1878
1941
  S.className = "tbw-filter-clear-btn", S.textContent = "Clear Filter", S.addEventListener("click", () => {
1879
1942
  t.clearFilter();
1880
1943
  }), I.appendChild(S), e.appendChild(I);
1881
1944
  }
1882
1945
  renderNumberFilterPanel(e, t, i) {
1883
- const { field: n, column: r } = t, o = r.filterParams, s = r.editorParams, l = (A, K) => {
1946
+ const { field: n, column: r } = t, o = r.filterParams, a = r.editorParams, l = (A, z) => {
1884
1947
  if (typeof A == "number") return A;
1885
1948
  if (typeof A == "string") {
1886
- const W = parseFloat(A);
1887
- return isNaN(W) ? K : W;
1949
+ const j = parseFloat(A);
1950
+ return isNaN(j) ? z : j;
1888
1951
  }
1889
- return K;
1890
- }, d = i.filter((A) => typeof A == "number" && !isNaN(A)), c = d.length > 0 ? Math.min(...d) : 0, u = d.length > 0 ? Math.max(...d) : 100, h = l(o?.min ?? s?.min, c), f = l(o?.max ?? s?.max, u), g = o?.step ?? s?.step ?? 1, p = this.filters.get(n);
1952
+ return z;
1953
+ }, d = i.filter((A) => typeof A == "number" && !isNaN(A)), c = d.length > 0 ? Math.min(...d) : 0, u = d.length > 0 ? Math.max(...d) : 100, h = l(o?.min ?? a?.min, c), f = l(o?.max ?? a?.max, u), g = o?.step ?? a?.step ?? 1, p = this.filters.get(n);
1891
1954
  let w = h, b = f;
1892
1955
  p?.operator === "between" ? (w = l(p.value, h), b = l(p.valueTo, f)) : p?.operator === "greaterThanOrEqual" ? w = l(p.value, h) : p?.operator === "lessThanOrEqual" && (b = l(p.value, f));
1956
+ const y = document.createElement("div");
1957
+ y.className = "tbw-filter-range-inputs";
1893
1958
  const v = document.createElement("div");
1894
- v.className = "tbw-filter-range-inputs";
1895
- const x = document.createElement("div");
1896
- x.className = "tbw-filter-range-group";
1897
- const R = document.createElement("label");
1898
- R.textContent = "Min", R.className = "tbw-filter-range-label";
1899
- const E = document.createElement("input");
1900
- E.type = "number", E.className = "tbw-filter-range-input", E.min = String(h), E.max = String(f), E.step = String(g), E.value = String(w), x.appendChild(R), x.appendChild(E), v.appendChild(x);
1959
+ v.className = "tbw-filter-range-group";
1960
+ const E = document.createElement("label");
1961
+ E.textContent = "Min", E.className = "tbw-filter-range-label";
1962
+ const R = document.createElement("input");
1963
+ R.type = "number", R.className = "tbw-filter-range-input", R.min = String(h), R.max = String(f), R.step = String(g), R.value = String(w), v.appendChild(E), v.appendChild(R), y.appendChild(v);
1901
1964
  const D = document.createElement("span");
1902
- D.className = "tbw-filter-range-separator", D.textContent = "–", v.appendChild(D);
1965
+ D.className = "tbw-filter-range-separator", D.textContent = "–", y.appendChild(D);
1903
1966
  const I = document.createElement("div");
1904
1967
  I.className = "tbw-filter-range-group";
1905
- const F = document.createElement("label");
1906
- F.textContent = "Max", F.className = "tbw-filter-range-label";
1968
+ const P = document.createElement("label");
1969
+ P.textContent = "Max", P.className = "tbw-filter-range-label";
1907
1970
  const S = document.createElement("input");
1908
- S.type = "number", S.className = "tbw-filter-range-input", S.min = String(h), S.max = String(f), S.step = String(g), S.value = String(b), I.appendChild(F), I.appendChild(S), v.appendChild(I), e.appendChild(v);
1971
+ S.type = "number", S.className = "tbw-filter-range-input", S.min = String(h), S.max = String(f), S.step = String(g), S.value = String(b), I.appendChild(P), I.appendChild(S), y.appendChild(I), e.appendChild(y);
1909
1972
  const C = document.createElement("div");
1910
1973
  C.className = "tbw-filter-range-slider";
1911
1974
  const k = document.createElement("div");
@@ -1914,63 +1977,63 @@ class N extends _ {
1914
1977
  T.className = "tbw-filter-range-fill";
1915
1978
  const m = document.createElement("input");
1916
1979
  m.type = "range", m.className = "tbw-filter-range-thumb tbw-filter-range-thumb-min", m.min = String(h), m.max = String(f), m.step = String(g), m.value = String(w);
1917
- const y = document.createElement("input");
1918
- y.type = "range", y.className = "tbw-filter-range-thumb tbw-filter-range-thumb-max", y.min = String(h), y.max = String(f), y.step = String(g), y.value = String(b), C.appendChild(k), C.appendChild(T), C.appendChild(m), C.appendChild(y), e.appendChild(C);
1980
+ const x = document.createElement("input");
1981
+ x.type = "range", x.className = "tbw-filter-range-thumb tbw-filter-range-thumb-max", x.min = String(h), x.max = String(f), x.step = String(g), x.value = String(b), C.appendChild(k), C.appendChild(T), C.appendChild(m), C.appendChild(x), e.appendChild(C);
1919
1982
  const L = () => {
1920
- const A = parseFloat(m.value), K = parseFloat(y.value), W = f - h, ve = (A - h) / W * 100, ut = (K - h) / W * 100;
1983
+ const A = parseFloat(m.value), z = parseFloat(x.value), j = f - h, ve = (A - h) / j * 100, ut = (z - h) / j * 100;
1921
1984
  T.style.left = `${ve}%`, T.style.width = `${ut - ve}%`;
1922
1985
  };
1923
1986
  m.addEventListener("input", () => {
1924
- const A = Math.min(parseFloat(m.value), parseFloat(y.value));
1925
- m.value = String(A), E.value = String(A), L();
1926
- }), y.addEventListener("input", () => {
1927
- const A = Math.max(parseFloat(y.value), parseFloat(m.value));
1928
- y.value = String(A), S.value = String(A), L();
1929
- }), E.addEventListener("input", () => {
1930
- let A = parseFloat(E.value) || h;
1987
+ const A = Math.min(parseFloat(m.value), parseFloat(x.value));
1988
+ m.value = String(A), R.value = String(A), L();
1989
+ }), x.addEventListener("input", () => {
1990
+ const A = Math.max(parseFloat(x.value), parseFloat(m.value));
1991
+ x.value = String(A), S.value = String(A), L();
1992
+ }), R.addEventListener("input", () => {
1993
+ let A = parseFloat(R.value) || h;
1931
1994
  A = Math.max(h, Math.min(A, parseFloat(S.value))), m.value = String(A), L();
1932
1995
  }), S.addEventListener("input", () => {
1933
1996
  let A = parseFloat(S.value) || f;
1934
- A = Math.min(f, Math.max(A, parseFloat(E.value))), y.value = String(A), L();
1997
+ A = Math.min(f, Math.max(A, parseFloat(R.value))), x.value = String(A), L();
1935
1998
  }), L();
1936
- const H = document.createElement("div");
1937
- H.className = "tbw-filter-buttons";
1938
- const Y = document.createElement("button");
1939
- Y.className = "tbw-filter-apply-btn", Y.textContent = "Apply", Y.addEventListener("click", () => {
1940
- const A = parseFloat(E.value), K = parseFloat(S.value);
1941
- t.applyTextFilter("between", A, K);
1942
- }), H.appendChild(Y);
1999
+ const K = document.createElement("div");
2000
+ K.className = "tbw-filter-buttons";
1943
2001
  const X = document.createElement("button");
1944
- X.className = "tbw-filter-clear-btn", X.textContent = "Clear Filter", X.addEventListener("click", () => {
2002
+ X.className = "tbw-filter-apply-btn", X.textContent = "Apply", X.addEventListener("click", () => {
2003
+ const A = parseFloat(R.value), z = parseFloat(S.value);
2004
+ t.applyTextFilter("between", A, z);
2005
+ }), K.appendChild(X);
2006
+ const Z = document.createElement("button");
2007
+ Z.className = "tbw-filter-clear-btn", Z.textContent = "Clear Filter", Z.addEventListener("click", () => {
1945
2008
  t.clearFilter();
1946
- }), H.appendChild(X), e.appendChild(H);
2009
+ }), K.appendChild(Z), e.appendChild(K);
1947
2010
  }
1948
2011
  renderDateFilterPanel(e, t, i) {
1949
- const { field: n, column: r } = t, o = r.filterParams, s = r.editorParams, l = i.filter((m) => m instanceof Date || typeof m == "string" && !isNaN(Date.parse(m))).map((m) => m instanceof Date ? m : new Date(m)).filter((m) => !isNaN(m.getTime())), d = l.length > 0 ? new Date(Math.min(...l.map((m) => m.getTime()))) : null, c = l.length > 0 ? new Date(Math.max(...l.map((m) => m.getTime()))) : null, u = (m) => m ? m.toISOString().split("T")[0] : "", h = (m) => m ? typeof m == "string" ? m : typeof m == "number" ? u(new Date(m)) : "" : "", f = h(o?.min) || h(s?.min) || u(d), g = h(o?.max) || h(s?.max) || u(c), p = this.filters.get(n);
2012
+ const { field: n, column: r } = t, o = r.filterParams, a = r.editorParams, l = i.filter((m) => m instanceof Date || typeof m == "string" && !isNaN(Date.parse(m))).map((m) => m instanceof Date ? m : new Date(m)).filter((m) => !isNaN(m.getTime())), d = l.length > 0 ? new Date(Math.min(...l.map((m) => m.getTime()))) : null, c = l.length > 0 ? new Date(Math.max(...l.map((m) => m.getTime()))) : null, u = (m) => m ? m.toISOString().split("T")[0] : "", h = (m) => m ? typeof m == "string" ? m : typeof m == "number" ? u(new Date(m)) : "" : "", f = h(o?.min) || h(a?.min) || u(d), g = h(o?.max) || h(a?.max) || u(c), p = this.filters.get(n);
1950
2013
  let w = "", b = "";
1951
2014
  p?.operator === "between" ? (w = h(p.value) || "", b = h(p.valueTo) || "") : p?.operator === "greaterThanOrEqual" ? w = h(p.value) || "" : p?.operator === "lessThanOrEqual" && (b = h(p.value) || "");
2015
+ const y = document.createElement("div");
2016
+ y.className = "tbw-filter-date-range";
1952
2017
  const v = document.createElement("div");
1953
- v.className = "tbw-filter-date-range";
1954
- const x = document.createElement("div");
1955
- x.className = "tbw-filter-date-group";
1956
- const R = document.createElement("label");
1957
- R.textContent = "From", R.className = "tbw-filter-range-label";
1958
- const E = document.createElement("input");
1959
- E.type = "date", E.className = "tbw-filter-date-input", f && (E.min = f), g && (E.max = g), E.value = w, x.appendChild(R), x.appendChild(E), v.appendChild(x);
2018
+ v.className = "tbw-filter-date-group";
2019
+ const E = document.createElement("label");
2020
+ E.textContent = "From", E.className = "tbw-filter-range-label";
2021
+ const R = document.createElement("input");
2022
+ R.type = "date", R.className = "tbw-filter-date-input", f && (R.min = f), g && (R.max = g), R.value = w, v.appendChild(E), v.appendChild(R), y.appendChild(v);
1960
2023
  const D = document.createElement("span");
1961
- D.className = "tbw-filter-range-separator", D.textContent = "–", v.appendChild(D);
2024
+ D.className = "tbw-filter-range-separator", D.textContent = "–", y.appendChild(D);
1962
2025
  const I = document.createElement("div");
1963
2026
  I.className = "tbw-filter-date-group";
1964
- const F = document.createElement("label");
1965
- F.textContent = "To", F.className = "tbw-filter-range-label";
2027
+ const P = document.createElement("label");
2028
+ P.textContent = "To", P.className = "tbw-filter-range-label";
1966
2029
  const S = document.createElement("input");
1967
- S.type = "date", S.className = "tbw-filter-date-input", f && (S.min = f), g && (S.max = g), S.value = b, I.appendChild(F), I.appendChild(S), v.appendChild(I), e.appendChild(v);
2030
+ S.type = "date", S.className = "tbw-filter-date-input", f && (S.min = f), g && (S.max = g), S.value = b, I.appendChild(P), I.appendChild(S), y.appendChild(I), e.appendChild(y);
1968
2031
  const C = document.createElement("div");
1969
2032
  C.className = "tbw-filter-buttons";
1970
2033
  const k = document.createElement("button");
1971
2034
  k.className = "tbw-filter-apply-btn", k.textContent = "Apply", k.addEventListener("click", () => {
1972
- const m = E.value, y = S.value;
1973
- m && y ? t.applyTextFilter("between", m, y) : m ? t.applyTextFilter("greaterThanOrEqual", m) : y ? t.applyTextFilter("lessThanOrEqual", y) : t.clearFilter();
2035
+ const m = R.value, x = S.value;
2036
+ m && x ? t.applyTextFilter("between", m, x) : m ? t.applyTextFilter("greaterThanOrEqual", m) : x ? t.applyTextFilter("lessThanOrEqual", x) : t.clearFilter();
1974
2037
  }), C.appendChild(k);
1975
2038
  const T = document.createElement("button");
1976
2039
  T.className = "tbw-filter-clear-btn", T.textContent = "Clear Filter", T.addEventListener("click", () => {
@@ -2041,28 +2104,28 @@ class N extends _ {
2041
2104
  this.filters.set(e, i), this.cachedResult = null, this.cacheKey = null;
2042
2105
  }
2043
2106
  }
2044
- function Fe(a) {
2045
- if (!a.length) return [];
2046
- const e = /* @__PURE__ */ new Map(), t = [], i = (o, s) => {
2047
- if (!s.length) return;
2107
+ function Fe(s) {
2108
+ if (!s.length) return [];
2109
+ const e = /* @__PURE__ */ new Map(), t = [], i = (o, a) => {
2110
+ if (!a.length) return;
2048
2111
  const l = t[t.length - 1];
2049
2112
  if (l && l.implicit && l.firstIndex + l.columns.length === o) {
2050
- l.columns.push(...s);
2113
+ l.columns.push(...a);
2051
2114
  return;
2052
2115
  }
2053
2116
  t.push({
2054
2117
  id: "__implicit__" + o,
2055
2118
  label: void 0,
2056
- columns: s,
2119
+ columns: a,
2057
2120
  firstIndex: o,
2058
2121
  implicit: !0
2059
2122
  });
2060
2123
  };
2061
2124
  let n = [], r = 0;
2062
- return a.forEach((o, s) => {
2125
+ return s.forEach((o, a) => {
2063
2126
  const l = o.group;
2064
2127
  if (!l) {
2065
- n.length === 0 && (r = s), n.push(o);
2128
+ n.length === 0 && (r = a), n.push(o);
2066
2129
  return;
2067
2130
  }
2068
2131
  n.length && (i(r, n.slice()), n = []);
@@ -2072,40 +2135,40 @@ function Fe(a) {
2072
2135
  id: d,
2073
2136
  label: typeof l == "string" ? void 0 : l.label,
2074
2137
  columns: [],
2075
- firstIndex: s
2138
+ firstIndex: a
2076
2139
  }, e.set(d, c), t.push(c)), c.columns.push(o);
2077
- }), n.length && i(r, n), t.length === 1 && t[0].implicit && t[0].columns.length === a.length ? [] : t;
2140
+ }), n.length && i(r, n), t.length === 1 && t[0].implicit && t[0].columns.length === s.length ? [] : t;
2078
2141
  }
2079
- function Ut(a, e, t) {
2080
- if (!e.length || !a) return;
2142
+ function Ut(s, e, t) {
2143
+ if (!e.length || !s) return;
2081
2144
  const i = /* @__PURE__ */ new Map();
2082
2145
  for (const r of e)
2083
2146
  for (const o of r.columns)
2084
2147
  o.field && i.set(o.field, r.id);
2085
- const n = Array.from(a.querySelectorAll(".cell[data-field]"));
2148
+ const n = Array.from(s.querySelectorAll(".cell[data-field]"));
2086
2149
  n.forEach((r) => {
2087
- const o = r.getAttribute("data-field") || "", s = i.get(o);
2088
- s && (r.classList.add("grouped"), r.getAttribute("data-group") || r.setAttribute("data-group", s));
2150
+ const o = r.getAttribute("data-field") || "", a = i.get(o);
2151
+ a && (r.classList.add("grouped"), r.getAttribute("data-group") || r.setAttribute("data-group", a));
2089
2152
  });
2090
2153
  for (const r of e) {
2091
- const o = r.columns[r.columns.length - 1], s = n.find((l) => l.getAttribute("data-field") === o.field);
2092
- s && s.classList.add("group-end");
2154
+ const o = r.columns[r.columns.length - 1], a = n.find((l) => l.getAttribute("data-field") === o.field);
2155
+ a && a.classList.add("group-end");
2093
2156
  }
2094
2157
  }
2095
- function Yt(a, e) {
2096
- if (a.length === 0) return null;
2158
+ function Yt(s, e) {
2159
+ if (s.length === 0) return null;
2097
2160
  const t = document.createElement("div");
2098
2161
  t.className = "header-group-row", t.setAttribute("role", "row");
2099
- for (const i of a) {
2162
+ for (const i of s) {
2100
2163
  const n = i.columns[0], r = n ? e.findIndex((d) => d.field === n.field) : -1;
2101
2164
  if (r === -1) continue;
2102
- const o = String(i.id).startsWith("__implicit__"), s = o ? "" : i.label || i.id, l = document.createElement("div");
2103
- l.className = "cell header-group-cell", o && l.classList.add("implicit-group"), l.setAttribute("data-group", String(i.id)), l.style.gridColumn = `${r + 1} / span ${i.columns.length}`, l.textContent = s, t.appendChild(l);
2165
+ const o = String(i.id).startsWith("__implicit__"), a = o ? "" : i.label || i.id, l = document.createElement("div");
2166
+ l.className = "cell header-group-cell", o && l.classList.add("implicit-group"), l.setAttribute("data-group", String(i.id)), l.style.gridColumn = `${r + 1} / span ${i.columns.length}`, l.textContent = a, t.appendChild(l);
2104
2167
  }
2105
2168
  return t;
2106
2169
  }
2107
- function Xt(a) {
2108
- return a.some((e) => e.group != null);
2170
+ function Xt(s) {
2171
+ return s.some((e) => e.group != null);
2109
2172
  }
2110
2173
  const Zt = "@layer tbw-plugins{.header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:var(--tbw-button-padding-sm, .25rem .5rem);font-weight:600;font-size:var(--tbw-font-size-sm, .9em);text-transform:uppercase;letter-spacing:.5px;border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-row .cell.group-end:last-child{border-right:none}.rows .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.rows .cell.group-end:last-child{border-right:none}.header-group-row.no-borders{border-bottom:none}.header-group-row.no-borders .header-group-cell{border-right:none}.header-row.no-group-borders .cell.group-end{border-right:1px solid var(--tbw-color-border)}}";
2111
2174
  class vn extends _ {
@@ -2133,8 +2196,9 @@ class vn extends _ {
2133
2196
  }
2134
2197
  groups = [];
2135
2198
  isActive = !1;
2199
+ #t = /* @__PURE__ */ new Set();
2136
2200
  detach() {
2137
- this.groups = [], this.isActive = !1;
2201
+ this.groups = [], this.isActive = !1, this.#t.clear();
2138
2202
  }
2139
2203
  static detect(e, t) {
2140
2204
  if (t?.columnGroups && Array.isArray(t.columnGroups) && t.columnGroups.length > 0)
@@ -2148,16 +2212,23 @@ class vn extends _ {
2148
2212
  if (t && Array.isArray(t) && t.length > 0) {
2149
2213
  const r = /* @__PURE__ */ new Map();
2150
2214
  for (const o of t)
2151
- for (const s of o.children)
2152
- r.set(s, { id: o.id, label: o.header });
2215
+ for (const a of o.children)
2216
+ r.set(a, { id: o.id, label: o.header });
2153
2217
  i = e.map((o) => {
2154
- const s = r.get(o.field);
2155
- return s && !o.group ? { ...o, group: s } : o;
2218
+ const a = r.get(o.field);
2219
+ return a && !o.group ? { ...o, group: a } : o;
2156
2220
  });
2157
2221
  } else
2158
2222
  i = [...e];
2159
2223
  const n = Fe(i);
2160
- return n.length === 0 ? (this.isActive = !1, this.groups = [], i) : (this.isActive = !0, this.groups = n, i);
2224
+ if (n.length === 0)
2225
+ return this.isActive = !1, this.groups = [], i;
2226
+ this.isActive = !0, this.groups = n, this.#t.clear();
2227
+ for (const r of n) {
2228
+ const o = r.columns[r.columns.length - 1];
2229
+ o?.field && this.#t.add(o.field);
2230
+ }
2231
+ return i;
2161
2232
  }
2162
2233
  afterRender() {
2163
2234
  if (!this.isActive) {
@@ -2174,26 +2245,14 @@ class vn extends _ {
2174
2245
  const r = Yt(n, i);
2175
2246
  if (r) {
2176
2247
  r.classList.toggle("no-borders", !this.config.showGroupBorders);
2177
- const s = e.querySelector(".header-row");
2178
- s ? e.insertBefore(r, s) : e.appendChild(r);
2248
+ const a = e.querySelector(".header-row");
2249
+ a ? e.insertBefore(r, a) : e.appendChild(r);
2179
2250
  }
2180
2251
  const o = e.querySelector(".header-row");
2181
- o && (o.classList.toggle("no-group-borders", !this.config.showGroupBorders), Ut(o, n)), this.#e(n);
2252
+ o && (o.classList.toggle("no-group-borders", !this.config.showGroupBorders), Ut(o, n));
2182
2253
  }
2183
- #e(e) {
2184
- if (!this.config.showGroupBorders) return;
2185
- const t = this.gridElement;
2186
- if (!t) return;
2187
- const i = /* @__PURE__ */ new Set();
2188
- for (const r of e) {
2189
- const o = r.columns[r.columns.length - 1];
2190
- o?.field && i.add(o.field);
2191
- }
2192
- const n = t.querySelectorAll(".rows .cell[data-field]");
2193
- for (const r of n) {
2194
- const o = r.getAttribute("data-field");
2195
- o && i.has(o) ? r.classList.add("group-end") : r.classList.remove("group-end");
2196
- }
2254
+ afterCellRender(e) {
2255
+ !this.isActive || !this.config.showGroupBorders || e.cellElement.classList.toggle("group-end", this.#t.has(e.column.field));
2197
2256
  }
2198
2257
  isGroupingActive() {
2199
2258
  return this.isActive;
@@ -2209,12 +2268,12 @@ class vn extends _ {
2209
2268
  this.requestRender();
2210
2269
  }
2211
2270
  }
2212
- function Pe({ rows: a, config: e, expanded: t, initialExpanded: i }) {
2271
+ function Pe({ rows: s, config: e, expanded: t, initialExpanded: i }) {
2213
2272
  const n = e.groupOn;
2214
2273
  if (typeof n != "function")
2215
2274
  return [];
2216
2275
  const r = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
2217
- if (a.forEach((d) => {
2276
+ if (s.forEach((d) => {
2218
2277
  let c = n(d);
2219
2278
  c == null || c === !1 ? c = ["__ungrouped__"] : Array.isArray(c) || (c = [c]);
2220
2279
  let u = r;
@@ -2223,54 +2282,54 @@ function Pe({ rows: a, config: e, expanded: t, initialExpanded: i }) {
2223
2282
  let w = u.children.get(g);
2224
2283
  w || (w = { key: p, value: h, depth: f, rows: [], children: /* @__PURE__ */ new Map(), parent: u }, u.children.set(g, w)), u = w;
2225
2284
  }), u.rows.push(d);
2226
- }), r.children.size === 1 && r.children.has("__ungrouped__") && r.children.get("__ungrouped__").rows.length === a.length)
2285
+ }), r.children.size === 1 && r.children.has("__ungrouped__") && r.children.get("__ungrouped__").rows.length === s.length)
2227
2286
  return [];
2228
- const o = /* @__PURE__ */ new Set([...t, ...i ?? []]), s = [], l = (d) => {
2287
+ const o = /* @__PURE__ */ new Set([...t, ...i ?? []]), a = [], l = (d) => {
2229
2288
  if (d === r) {
2230
2289
  d.children.forEach((u) => l(u));
2231
2290
  return;
2232
2291
  }
2233
2292
  const c = o.has(d.key);
2234
- s.push({
2293
+ a.push({
2235
2294
  kind: "group",
2236
2295
  key: d.key,
2237
2296
  value: d.value,
2238
2297
  depth: d.depth,
2239
2298
  rows: d.rows,
2240
2299
  expanded: c
2241
- }), c && (d.children.size ? d.children.forEach((u) => l(u)) : d.rows.forEach((u) => s.push({ kind: "data", row: u, rowIndex: a.indexOf(u) })));
2300
+ }), c && (d.children.size ? d.children.forEach((u) => l(u)) : d.rows.forEach((u) => a.push({ kind: "data", row: u, rowIndex: s.indexOf(u) })));
2242
2301
  };
2243
- return l(r), s;
2302
+ return l(r), a;
2244
2303
  }
2245
- function Qt(a, e) {
2246
- const t = new Set(a);
2304
+ function Qt(s, e) {
2305
+ const t = new Set(s);
2247
2306
  return t.has(e) ? t.delete(e) : t.add(e), t;
2248
2307
  }
2249
- function Jt(a) {
2308
+ function Jt(s) {
2250
2309
  const e = /* @__PURE__ */ new Set();
2251
- for (const t of a)
2310
+ for (const t of s)
2252
2311
  t.kind === "group" && e.add(t.key);
2253
2312
  return e;
2254
2313
  }
2255
2314
  function ei() {
2256
2315
  return /* @__PURE__ */ new Set();
2257
2316
  }
2258
- function ti(a, e) {
2259
- if (a === !0)
2317
+ function ti(s, e) {
2318
+ if (s === !0)
2260
2319
  return new Set(e);
2261
- if (a === !1 || a == null)
2320
+ if (s === !1 || s == null)
2262
2321
  return /* @__PURE__ */ new Set();
2263
- if (typeof a == "number") {
2264
- const t = e[a];
2322
+ if (typeof s == "number") {
2323
+ const t = e[s];
2265
2324
  return t ? /* @__PURE__ */ new Set([t]) : /* @__PURE__ */ new Set();
2266
2325
  }
2267
- return typeof a == "string" ? /* @__PURE__ */ new Set([a]) : Array.isArray(a) ? new Set(a) : /* @__PURE__ */ new Set();
2326
+ return typeof s == "string" ? /* @__PURE__ */ new Set([s]) : Array.isArray(s) ? new Set(s) : /* @__PURE__ */ new Set();
2268
2327
  }
2269
- function ii(a) {
2270
- return a.filter((e) => e.kind === "group").map((e) => e.key);
2328
+ function ii(s) {
2329
+ return s.filter((e) => e.kind === "group").map((e) => e.key);
2271
2330
  }
2272
- function ni(a) {
2273
- return a.kind !== "group" ? 0 : a.rows.length;
2331
+ function ni(s) {
2332
+ return s.kind !== "group" ? 0 : s.rows.length;
2274
2333
  }
2275
2334
  const ri = "@layer tbw-plugins{.group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}.group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, .125rem .5rem)}.group-row:hover{background:var(--tbw-grouping-rows-bg-hover, var(--tbw-color-row-hover))}.group-toggle{cursor:pointer;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toggle-size, 1.25rem);height:var(--tbw-toggle-size, 1.25rem);margin-right:.25rem;background:none;border:0;font:inherit}.group-toggle:hover{background:var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));border-radius:var(--tbw-border-radius, .125rem)}.group-label{display:inline-flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.group-count{color:var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));font-size:var(--tbw-font-size-xs, .85em);font-weight:400}.group-aggregates{display:inline-flex;align-items:center;gap:var(--tbw-spacing-lg, 1rem);margin-left:var(--tbw-spacing-lg, 1rem);font-weight:400;font-size:var(--tbw-font-size-sm, .875em);color:var(--tbw-grouping-rows-aggregate-color, var(--tbw-color-fg-muted))}.group-aggregate{white-space:nowrap}.group-row{padding-left:calc(var(--tbw-group-depth, 0) * var(--tbw-group-indent-width, 1.25em))}.data-grid-row.tbw-group-slide-in{animation:tbw-group-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-group-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.data-grid-row.tbw-group-fade-in{animation:tbw-group-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-group-fade-in{0%{opacity:0}to{opacity:1}}}";
2276
2335
  class yn extends _ {
@@ -2323,6 +2382,10 @@ class yn extends _ {
2323
2382
  detach() {
2324
2383
  this.expandedKeys.clear(), this.flattenedRows = [], this.isActive = !1, this.previousVisibleKeys.clear(), this.keysToAnimate.clear(), this.hasAppliedDefaultExpanded = !1;
2325
2384
  }
2385
+ getRowHeight(e, t) {
2386
+ if (this.config.groupRowHeight != null && e.__isGroupRow === !0)
2387
+ return this.config.groupRowHeight;
2388
+ }
2326
2389
  handleQuery(e) {
2327
2390
  if (e.type === "canMoveRow" && e.context?.__isGroupRow === !0)
2328
2391
  return !1;
@@ -2343,8 +2406,8 @@ class yn extends _ {
2343
2406
  return this.isActive = !1, this.flattenedRows = [], [...e];
2344
2407
  let n;
2345
2408
  if (!this.hasAppliedDefaultExpanded && this.expandedKeys.size === 0 && t.defaultExpanded !== !1) {
2346
- const s = ii(i);
2347
- n = ti(t.defaultExpanded ?? !1, s), n.size > 0 && (this.expandedKeys = new Set(n), this.hasAppliedDefaultExpanded = !0);
2409
+ const a = ii(i);
2410
+ n = ti(t.defaultExpanded ?? !1, a), n.size > 0 && (this.expandedKeys = new Set(n), this.hasAppliedDefaultExpanded = !0);
2348
2411
  }
2349
2412
  const r = Pe({
2350
2413
  rows: [...e],
@@ -2354,20 +2417,21 @@ class yn extends _ {
2354
2417
  });
2355
2418
  this.isActive = !0, this.flattenedRows = r, this.keysToAnimate.clear();
2356
2419
  const o = /* @__PURE__ */ new Set();
2357
- return r.forEach((s, l) => {
2358
- if (s.kind === "data") {
2420
+ return r.forEach((a, l) => {
2421
+ if (a.kind === "data") {
2359
2422
  const d = `data-${l}`;
2360
2423
  o.add(d), this.previousVisibleKeys.has(d) || this.keysToAnimate.add(d);
2361
2424
  }
2362
- }), this.previousVisibleKeys = o, r.map((s) => s.kind === "group" ? {
2425
+ }), this.previousVisibleKeys = o, r.map((a) => a.kind === "group" ? {
2363
2426
  __isGroupRow: !0,
2364
- __groupKey: s.key,
2365
- __groupValue: s.value,
2366
- __groupDepth: s.depth,
2367
- __groupRows: s.rows,
2368
- __groupExpanded: s.expanded,
2369
- __groupRowCount: ni(s)
2370
- } : s.row);
2427
+ __groupKey: a.key,
2428
+ __groupValue: a.value,
2429
+ __groupDepth: a.depth,
2430
+ __groupRows: a.rows,
2431
+ __groupExpanded: a.expanded,
2432
+ __groupRowCount: ni(a),
2433
+ __rowCacheKey: `group:${a.key}`
2434
+ } : a.row);
2371
2435
  }
2372
2436
  onCellClick(e) {
2373
2437
  const t = e.row;
@@ -2385,7 +2449,7 @@ class yn extends _ {
2385
2449
  return !1;
2386
2450
  const n = this.config;
2387
2451
  if (n.groupRowRenderer) {
2388
- const s = () => {
2452
+ const a = () => {
2389
2453
  this.toggle(e.__groupKey);
2390
2454
  }, l = n.groupRowRenderer({
2391
2455
  key: e.__groupKey,
@@ -2393,7 +2457,7 @@ class yn extends _ {
2393
2457
  depth: e.__groupDepth,
2394
2458
  rows: e.__groupRows,
2395
2459
  expanded: e.__groupExpanded,
2396
- toggleExpand: s
2460
+ toggleExpand: a
2397
2461
  });
2398
2462
  if (l)
2399
2463
  return t.className = "data-grid-row group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), typeof l == "string" ? t.innerHTML = l : (t.innerHTML = "", t.appendChild(l)), !0;
@@ -2426,12 +2490,12 @@ class yn extends _ {
2426
2490
  return n.formatLabel ? n.formatLabel(e, t, i) : String(e);
2427
2491
  }
2428
2492
  renderFullWidthGroupRow(e, t, i) {
2429
- const n = this.config, r = n.aggregators ?? {}, o = e.__groupRows ?? [], s = document.createElement("div");
2430
- s.className = "cell group-full", s.style.gridColumn = "1 / -1", s.setAttribute("role", "gridcell"), s.setAttribute("data-col", "0"), s.appendChild(this.createToggleButton(e.__groupExpanded, i));
2493
+ const n = this.config, r = n.aggregators ?? {}, o = e.__groupRows ?? [], a = document.createElement("div");
2494
+ a.className = "cell group-full", a.style.gridColumn = "1 / -1", a.setAttribute("role", "gridcell"), a.setAttribute("data-col", "0"), a.appendChild(this.createToggleButton(e.__groupExpanded, i));
2431
2495
  const l = document.createElement("span");
2432
- if (l.className = "group-label", l.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey), s.appendChild(l), n.showRowCount !== !1) {
2496
+ if (l.className = "group-label", l.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey), a.appendChild(l), n.showRowCount !== !1) {
2433
2497
  const c = document.createElement("span");
2434
- c.className = "group-count", c.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, s.appendChild(c);
2498
+ c.className = "group-count", c.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, a.appendChild(c);
2435
2499
  }
2436
2500
  const d = Object.entries(r);
2437
2501
  if (d.length > 0) {
@@ -2446,12 +2510,12 @@ class yn extends _ {
2446
2510
  p.textContent = `${w}: ${g}`, c.appendChild(p);
2447
2511
  }
2448
2512
  }
2449
- c.children.length > 0 && s.appendChild(c);
2513
+ c.children.length > 0 && a.appendChild(c);
2450
2514
  }
2451
- t.appendChild(s);
2515
+ t.appendChild(a);
2452
2516
  }
2453
2517
  renderPerColumnGroupRow(e, t, i) {
2454
- const n = this.config, r = n.aggregators ?? {}, o = this.columns, s = e.__groupRows ?? [], d = this.gridElement?.querySelector(".body")?.style.gridTemplateColumns || "";
2518
+ const n = this.config, r = n.aggregators ?? {}, o = this.columns, a = e.__groupRows ?? [], d = this.gridElement?.querySelector(".body")?.style.gridTemplateColumns || "";
2455
2519
  d && (t.style.display = "grid", t.style.gridTemplateColumns = d);
2456
2520
  let c = !1;
2457
2521
  o.forEach((u, h) => {
@@ -2463,7 +2527,7 @@ class yn extends _ {
2463
2527
  if (c) {
2464
2528
  const g = r[u.field];
2465
2529
  if (g) {
2466
- const p = te(g, s, u.field, u);
2530
+ const p = te(g, a, u.field, u);
2467
2531
  f.textContent = p != null ? String(p) : "";
2468
2532
  } else
2469
2533
  f.textContent = "";
@@ -2471,13 +2535,13 @@ class yn extends _ {
2471
2535
  c = !0, f.appendChild(this.createToggleButton(e.__groupExpanded, i));
2472
2536
  const g = document.createElement("span"), p = r[u.field];
2473
2537
  if (p) {
2474
- const w = te(p, s, u.field, u);
2538
+ const w = te(p, a, u.field, u);
2475
2539
  g.textContent = w != null ? String(w) : String(e.__groupValue);
2476
2540
  } else
2477
2541
  g.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey);
2478
2542
  if (f.appendChild(g), n.showRowCount !== !1) {
2479
2543
  const w = document.createElement("span");
2480
- w.className = "group-count", w.textContent = ` (${s.length})`, f.appendChild(w);
2544
+ w.className = "group-count", w.textContent = ` (${a.length})`, f.appendChild(w);
2481
2545
  }
2482
2546
  }
2483
2547
  t.appendChild(f);
@@ -2497,8 +2561,8 @@ class yn extends _ {
2497
2561
  if (e.startsWith(o + "||") || o.startsWith(e + "||"))
2498
2562
  e.startsWith(o + "||") && r.add(o);
2499
2563
  else {
2500
- const s = this.flattenedRows.find((l) => l.kind === "group" && l.key === o);
2501
- s && s.depth !== n.depth && r.add(o);
2564
+ const a = this.flattenedRows.find((l) => l.kind === "group" && l.key === o);
2565
+ a && a.depth !== n.depth && r.add(o);
2502
2566
  }
2503
2567
  r.add(e), this.expandedKeys = r;
2504
2568
  } else
@@ -2552,27 +2616,27 @@ class yn extends _ {
2552
2616
  this.config.groupOn = e, this.requestRender();
2553
2617
  }
2554
2618
  }
2555
- function De(a, e) {
2556
- const t = new Set(a);
2619
+ function De(s, e) {
2620
+ const t = new Set(s);
2557
2621
  return t.has(e) ? t.delete(e) : t.add(e), t;
2558
2622
  }
2559
- function oi(a, e) {
2560
- const t = new Set(a);
2623
+ function oi(s, e) {
2624
+ const t = new Set(s);
2561
2625
  return t.add(e), t;
2562
2626
  }
2563
- function si(a, e) {
2564
- const t = new Set(a);
2627
+ function si(s, e) {
2628
+ const t = new Set(s);
2565
2629
  return t.delete(e), t;
2566
2630
  }
2567
- function ai(a, e) {
2568
- return a.has(e);
2631
+ function ai(s, e) {
2632
+ return s.has(e);
2569
2633
  }
2570
- function li(a, e, t, i) {
2634
+ function li(s, e, t, i) {
2571
2635
  const n = document.createElement("div");
2572
2636
  n.className = "master-detail-row", n.setAttribute("data-detail-for", String(e)), n.setAttribute("role", "row");
2573
2637
  const r = document.createElement("div");
2574
2638
  r.className = "master-detail-cell", r.setAttribute("role", "cell"), r.style.gridColumn = `1 / ${i + 1}`;
2575
- const o = t(a, e);
2639
+ const o = t(s, e);
2576
2640
  return typeof o == "string" ? r.innerHTML = o : o instanceof HTMLElement && r.appendChild(o), n.appendChild(r), n;
2577
2641
  }
2578
2642
  const di = "@layer tbw-plugins{tbw-grid{.cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:center}.header-row .cell[data-field=__tbw_expander]{display:none}.header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}.master-detail-expander{display:flex;align-items:center;justify-content:center;width:100%;height:100%}.master-detail-toggle{cursor:pointer;opacity:.7;user-select:none;display:inline-flex;align-items:center;justify-content:center}.master-detail-toggle:hover{opacity:1}.master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border));overflow:hidden}.master-detail-cell{padding:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem));overflow:auto}.master-detail-row.tbw-expanding{animation:tbw-detail-expand var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}.master-detail-row.tbw-collapsing{animation:tbw-detail-collapse var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}}@keyframes tbw-detail-expand{0%{opacity:0;max-height:0;padding-top:0;padding-bottom:0}to{opacity:1;max-height:var(--tbw-detail-max-height, 31.25rem);padding-top:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem));padding-bottom:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem))}}@keyframes tbw-detail-collapse{0%{opacity:1;max-height:var(--tbw-detail-max-height, 31.25rem)}to{opacity:0;max-height:0}}}";
@@ -2603,8 +2667,8 @@ class nt extends _ {
2603
2667
  return;
2604
2668
  }
2605
2669
  }
2606
- const n = t.getAttribute("animation"), r = t.getAttribute("show-expand-column"), o = t.getAttribute("expand-on-row-click"), s = t.getAttribute("collapse-on-click-outside"), l = t.getAttribute("height"), d = {};
2607
- n !== null && (d.animation = n === "false" ? !1 : n), r !== null && (d.showExpandColumn = r !== "false"), o !== null && (d.expandOnRowClick = o === "true"), s !== null && (d.collapseOnClickOutside = s === "true"), l !== null && (d.detailHeight = l === "auto" ? "auto" : parseInt(l, 10));
2670
+ const n = t.getAttribute("animation"), r = t.getAttribute("show-expand-column"), o = t.getAttribute("expand-on-row-click"), a = t.getAttribute("collapse-on-click-outside"), l = t.getAttribute("height"), d = {};
2671
+ n !== null && (d.animation = n === "false" ? !1 : n), r !== null && (d.showExpandColumn = r !== "false"), o !== null && (d.expandOnRowClick = o === "true"), a !== null && (d.collapseOnClickOutside = a === "true"), l !== null && (d.detailHeight = l === "auto" ? "auto" : parseInt(l, 10));
2608
2672
  const c = t.innerHTML.trim();
2609
2673
  c && !this.config.detailRenderer && (d.detailRenderer = (u, h) => {
2610
2674
  const f = Je(c, { value: u, row: u });
@@ -2614,14 +2678,14 @@ class nt extends _ {
2614
2678
  get animationStyle() {
2615
2679
  return this.isAnimationEnabled ? this.config.animation ?? "slide" : !1;
2616
2680
  }
2617
- animateExpand(e) {
2618
- !this.isAnimationEnabled || this.animationStyle === !1 || (e.classList.add("tbw-expanding"), e.addEventListener(
2619
- "animationend",
2620
- () => {
2621
- e.classList.remove("tbw-expanding");
2622
- },
2623
- { once: !0 }
2624
- ));
2681
+ animateExpand(e, t, i) {
2682
+ if (!this.isAnimationEnabled || this.animationStyle === !1) return !1;
2683
+ e.classList.add("tbw-expanding");
2684
+ let n = !1;
2685
+ const r = () => {
2686
+ n || (n = !0, e.classList.remove("tbw-expanding"), t !== void 0 && i !== void 0 && this.#t(e, t, i));
2687
+ };
2688
+ return e.addEventListener("animationend", r, { once: !0 }), setTimeout(r, this.animationDuration + 50), !0;
2625
2689
  }
2626
2690
  animateCollapse(e, t) {
2627
2691
  if (!this.isAnimationEnabled || this.animationStyle === !1) {
@@ -2634,32 +2698,50 @@ class nt extends _ {
2634
2698
  };
2635
2699
  e.addEventListener("animationend", i, { once: !0 }), setTimeout(i, this.animationDuration + 50);
2636
2700
  }
2701
+ #t(e, t, i) {
2702
+ if (!e.isConnected) return;
2703
+ const n = e.offsetHeight;
2704
+ if (n > 0) {
2705
+ const r = this.measuredDetailHeights.get(t);
2706
+ this.measuredDetailHeights.set(t, n), r !== n && this.grid.invalidateRowHeight(i);
2707
+ }
2708
+ }
2637
2709
  expandedRows = /* @__PURE__ */ new Set();
2638
2710
  detailElements = /* @__PURE__ */ new Map();
2711
+ measuredDetailHeights = /* @__PURE__ */ new Map();
2712
+ rowsToAnimate = /* @__PURE__ */ new Set();
2639
2713
  static DEFAULT_DETAIL_HEIGHT = 150;
2640
2714
  getDetailHeight(e) {
2641
2715
  const t = this.detailElements.get(e);
2642
- return t ? t.offsetHeight : typeof this.config?.detailHeight == "number" ? this.config.detailHeight : nt.DEFAULT_DETAIL_HEIGHT;
2716
+ if (t && !(t.classList.contains("tbw-expanding") || t.classList.contains("tbw-collapsing"))) {
2717
+ const r = t.offsetHeight;
2718
+ if (r > 0)
2719
+ return this.measuredDetailHeights.set(e, r), r;
2720
+ }
2721
+ const i = this.measuredDetailHeights.get(e);
2722
+ return i && i > 0 ? i : typeof this.config?.detailHeight == "number" ? this.config.detailHeight : nt.DEFAULT_DETAIL_HEIGHT;
2643
2723
  }
2644
2724
  toggleAndEmit(e, t) {
2645
- this.expandedRows = De(this.expandedRows, e), this.emit("detail-expand", {
2725
+ this.expandedRows = De(this.expandedRows, e);
2726
+ const i = this.expandedRows.has(e);
2727
+ i && this.rowsToAnimate.add(e), this.emit("detail-expand", {
2646
2728
  rowIndex: t,
2647
2729
  row: e,
2648
- expanded: this.expandedRows.has(e)
2730
+ expanded: i
2649
2731
  }), this.requestRender();
2650
2732
  }
2651
2733
  detach() {
2652
- this.expandedRows.clear(), this.detailElements.clear();
2734
+ this.expandedRows.clear(), this.detailElements.clear(), this.measuredDetailHeights.clear(), this.rowsToAnimate.clear();
2653
2735
  }
2654
2736
  processColumns(e) {
2655
2737
  if (!(this.config.showExpandColumn === !0 || this.config.showExpandColumn !== !1 && !!this.config.detailRenderer))
2656
2738
  return [...e];
2657
2739
  const i = [...e];
2658
- if (wt(i))
2740
+ if (vt(i))
2659
2741
  return i;
2660
- const r = bt(this.name);
2742
+ const r = yt(this.name);
2661
2743
  return r.viewRenderer = (o) => {
2662
- const { row: s } = o, l = this.expandedRows.has(s), d = document.createElement("span");
2744
+ const { row: a } = o, l = this.expandedRows.has(a), d = document.createElement("span");
2663
2745
  d.className = "master-detail-expander expander-cell";
2664
2746
  const c = document.createElement("span");
2665
2747
  return c.className = `master-detail-toggle${l ? " expanded" : ""}`, this.setIcon(c, this.resolveIcon(l ? "collapse" : "expand")), c.setAttribute("role", "button"), c.setAttribute("tabindex", "0"), c.setAttribute("aria-expanded", String(l)), c.setAttribute("aria-label", l ? "Collapse details" : "Expand details"), d.appendChild(c), d;
@@ -2692,26 +2774,38 @@ class nt extends _ {
2692
2774
  if (!this.config.detailRenderer) return;
2693
2775
  const e = this.gridElement?.querySelector(".rows");
2694
2776
  if (!e) return;
2695
- const t = /* @__PURE__ */ new Map(), i = e.querySelectorAll(".data-grid-row"), n = this.columns.length;
2696
- for (const o of i) {
2697
- const s = o.querySelector(".cell[data-row]"), l = s ? parseInt(s.getAttribute("data-row") ?? "-1", 10) : -1;
2698
- l >= 0 && t.set(l, o);
2699
- }
2700
- const r = e.querySelectorAll(".master-detail-row");
2701
- for (const o of r) {
2702
- const s = parseInt(o.getAttribute("data-detail-for") ?? "-1", 10), l = s >= 0 ? this.rows[s] : void 0, d = l && this.expandedRows.has(l), c = t.has(s);
2703
- (!d || !c) && (o.remove(), l && this.detailElements.delete(l));
2704
- }
2705
- for (const [o, s] of t) {
2706
- const l = this.rows[o];
2707
- if (!l || !this.expandedRows.has(l)) continue;
2708
- const d = this.detailElements.get(l);
2709
- if (d) {
2710
- d.previousElementSibling !== s && s.after(d);
2777
+ const t = this.grid, i = t._rowPool, n = t._virtualization?.start ?? 0, r = t._virtualization?.end ?? 0, o = this.columns.length, a = n, l = r, d = /* @__PURE__ */ new Map();
2778
+ if (i) {
2779
+ const c = Math.min(i.length, l - a);
2780
+ for (let u = 0; u < c; u++) {
2781
+ const h = i[u];
2782
+ h.parentNode === e && d.set(a + u, h);
2783
+ }
2784
+ } else {
2785
+ const c = e.querySelectorAll(".data-grid-row");
2786
+ for (const u of c) {
2787
+ const h = u.querySelector(".cell[data-row]"), f = h ? parseInt(h.getAttribute("data-row") ?? "-1", 10) : -1;
2788
+ f >= 0 && d.set(f, u);
2789
+ }
2790
+ }
2791
+ for (const [c, u] of this.detailElements) {
2792
+ const h = this.rows.indexOf(c), f = this.expandedRows.has(c), g = h >= 0 && d.has(h);
2793
+ (!f || !g) && (u.parentNode && u.remove(), this.detailElements.delete(c));
2794
+ }
2795
+ for (const [c, u] of d) {
2796
+ const h = this.rows[c];
2797
+ if (!h || !this.expandedRows.has(h)) continue;
2798
+ const f = this.detailElements.get(h);
2799
+ if (f) {
2800
+ f.previousElementSibling !== u && u.after(f);
2711
2801
  continue;
2712
2802
  }
2713
- const c = li(l, o, this.config.detailRenderer, n);
2714
- typeof this.config.detailHeight == "number" && (c.style.height = `${this.config.detailHeight}px`), s.after(c), this.detailElements.set(l, c), this.animateExpand(c);
2803
+ const g = li(h, c, this.config.detailRenderer, o);
2804
+ typeof this.config.detailHeight == "number" && (g.style.height = `${this.config.detailHeight}px`), u.after(g), this.detailElements.set(h, g);
2805
+ const p = this.rowsToAnimate.has(h);
2806
+ p && this.rowsToAnimate.delete(h), p && this.animateExpand(g, h, c) || requestAnimationFrame(() => {
2807
+ this.#t(g, h, c);
2808
+ });
2715
2809
  }
2716
2810
  }
2717
2811
  getExtraHeight() {
@@ -2728,24 +2822,40 @@ class nt extends _ {
2728
2822
  }
2729
2823
  return t;
2730
2824
  }
2825
+ getRowHeight(e, t) {
2826
+ if (!this.expandedRows.has(e))
2827
+ return;
2828
+ const n = this.grid.defaultRowHeight ?? 28, r = this.getDetailHeight(e);
2829
+ return n + r;
2830
+ }
2731
2831
  adjustVirtualStart(e, t, i) {
2732
2832
  if (this.expandedRows.size === 0) return e;
2733
- const n = [];
2734
- for (const s of this.expandedRows) {
2735
- const l = this.rows.indexOf(s);
2736
- l >= 0 && n.push({ index: l, row: s });
2737
- }
2738
- n.sort((s, l) => s.index - l.index);
2739
- let r = e, o = 0;
2740
- for (const { index: s, row: l } of n) {
2741
- const d = s * i + o, c = this.getDetailHeight(l), u = d + i + c;
2742
- o += c, !(s >= e) && u > t && s < r && (r = s);
2833
+ const n = this.grid?._virtualization?.positionCache;
2834
+ let r = e;
2835
+ if (n && n.length > 0)
2836
+ for (const o of this.expandedRows) {
2837
+ const a = this.rows.indexOf(o);
2838
+ if (a < 0 || a >= e) continue;
2839
+ n[a].offset + n[a].height > t && a < r && (r = a);
2840
+ }
2841
+ else {
2842
+ const o = [];
2843
+ for (const l of this.expandedRows) {
2844
+ const d = this.rows.indexOf(l);
2845
+ d >= 0 && o.push({ index: d, row: l });
2846
+ }
2847
+ o.sort((l, d) => l.index - d.index);
2848
+ let a = 0;
2849
+ for (const { index: l, row: d } of o) {
2850
+ const c = l * i + a, u = this.getDetailHeight(d), h = c + i + u;
2851
+ a += u, !(l >= e) && h > t && l < r && (r = l);
2852
+ }
2743
2853
  }
2744
2854
  return r;
2745
2855
  }
2746
2856
  expand(e) {
2747
2857
  const t = this.rows[e];
2748
- t && (this.expandedRows = oi(this.expandedRows, t), this.requestRender());
2858
+ t && (this.rowsToAnimate.add(t), this.expandedRows = oi(this.expandedRows, t), this.requestRender());
2749
2859
  }
2750
2860
  collapse(e) {
2751
2861
  const t = this.rows[e];
@@ -2753,7 +2863,7 @@ class nt extends _ {
2753
2863
  }
2754
2864
  toggle(e) {
2755
2865
  const t = this.rows[e];
2756
- t && (this.expandedRows = De(this.expandedRows, t), this.requestRender());
2866
+ t && (this.expandedRows = De(this.expandedRows, t), this.expandedRows.has(t) && this.rowsToAnimate.add(t), this.requestRender());
2757
2867
  }
2758
2868
  isExpanded(e) {
2759
2869
  const t = this.rows[e];
@@ -2761,7 +2871,7 @@ class nt extends _ {
2761
2871
  }
2762
2872
  expandAll() {
2763
2873
  for (const e of this.rows)
2764
- this.expandedRows.add(e);
2874
+ this.rowsToAnimate.add(e), this.expandedRows.add(e);
2765
2875
  this.requestRender();
2766
2876
  }
2767
2877
  collapseAll() {
@@ -2787,29 +2897,29 @@ class nt extends _ {
2787
2897
  }
2788
2898
  }
2789
2899
  }
2790
- function ci(a, e, t) {
2791
- return e.length ? [...a].sort((i, n) => {
2900
+ function ci(s, e, t) {
2901
+ return e.length ? [...s].sort((i, n) => {
2792
2902
  for (const r of e) {
2793
- const s = t.find((u) => u.field === r.field)?.sortComparator ?? ui, l = i[r.field], d = n[r.field], c = s(l, d, i, n);
2903
+ const a = t.find((u) => u.field === r.field)?.sortComparator ?? ui, l = i[r.field], d = n[r.field], c = a(l, d, i, n);
2794
2904
  if (c !== 0)
2795
2905
  return r.direction === "asc" ? c : -c;
2796
2906
  }
2797
2907
  return 0;
2798
- }) : [...a];
2908
+ }) : [...s];
2799
2909
  }
2800
- function ui(a, e) {
2801
- return a == null && e == null ? 0 : a == null ? 1 : e == null ? -1 : typeof a == "number" && typeof e == "number" ? a - e : a instanceof Date && e instanceof Date ? a.getTime() - e.getTime() : typeof a == "boolean" && typeof e == "boolean" ? a === e ? 0 : a ? -1 : 1 : String(a).localeCompare(String(e));
2910
+ function ui(s, e) {
2911
+ return s == null && e == null ? 0 : s == null ? 1 : e == null ? -1 : typeof s == "number" && typeof e == "number" ? s - e : s instanceof Date && e instanceof Date ? s.getTime() - e.getTime() : typeof s == "boolean" && typeof e == "boolean" ? s === e ? 0 : s ? -1 : 1 : String(s).localeCompare(String(e));
2802
2912
  }
2803
- function hi(a, e, t, i) {
2804
- const n = a.find((r) => r.field === e);
2805
- return t ? n ? n.direction === "asc" ? a.map((r) => r.field === e ? { ...r, direction: "desc" } : r) : a.filter((r) => r.field !== e) : a.length < i ? [...a, { field: e, direction: "asc" }] : a : n?.direction === "asc" ? [{ field: e, direction: "desc" }] : n?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
2913
+ function hi(s, e, t, i) {
2914
+ const n = s.find((r) => r.field === e);
2915
+ return t ? n ? n.direction === "asc" ? s.map((r) => r.field === e ? { ...r, direction: "desc" } : r) : s.filter((r) => r.field !== e) : s.length < i ? [...s, { field: e, direction: "asc" }] : s : n?.direction === "asc" ? [{ field: e, direction: "desc" }] : n?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
2806
2916
  }
2807
- function Me(a, e) {
2808
- const t = a.findIndex((i) => i.field === e);
2917
+ function Me(s, e) {
2918
+ const t = s.findIndex((i) => i.field === e);
2809
2919
  return t >= 0 ? t + 1 : void 0;
2810
2920
  }
2811
- function Ne(a, e) {
2812
- return a.find((t) => t.field === e)?.direction;
2921
+ function Ne(s, e) {
2922
+ return s.find((t) => t.field === e)?.direction;
2813
2923
  }
2814
2924
  const fi = '@layer tbw-plugins{.header-cell[data-sort=asc]:after{content:"↑";margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.sort-indicator{margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.sort-index{font-size:var(--tbw-font-size-2xs, .7em);background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:var(--tbw-multi-sort-badge-size, 1em);height:var(--tbw-multi-sort-badge-size, 1em);display:inline-flex;align-items:center;justify-content:center;margin-left:var(--tbw-spacing-xs, .125em);font-weight:600}}';
2815
2925
  class xn extends _ {
@@ -2840,11 +2950,11 @@ class xn extends _ {
2840
2950
  e.querySelectorAll(".header-row .cell[data-field]").forEach((n) => {
2841
2951
  const r = n.getAttribute("data-field");
2842
2952
  if (!r) return;
2843
- const o = Me(this.sortModel, r), s = Ne(this.sortModel, r);
2844
- if (n.querySelector(".sort-index")?.remove(), s) {
2845
- n.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), n.setAttribute("data-sort", s);
2953
+ const o = Me(this.sortModel, r), a = Ne(this.sortModel, r);
2954
+ if (n.querySelector(".sort-index")?.remove(), a) {
2955
+ n.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), n.setAttribute("data-sort", a);
2846
2956
  const c = document.createElement("span");
2847
- c.className = "sort-indicator", this.setIcon(c, this.resolveIcon(s === "asc" ? "sortAsc" : "sortDesc"));
2957
+ c.className = "sort-indicator", this.setIcon(c, this.resolveIcon(a === "asc" ? "sortAsc" : "sortDesc"));
2848
2958
  const u = n.querySelector(".tbw-filter-btn"), h = n.querySelector(".resize-handle"), f = u ?? h;
2849
2959
  if (f ? n.insertBefore(c, f) : n.appendChild(c), t && this.sortModel.length > 1 && o !== void 0) {
2850
2960
  const g = document.createElement("span");
@@ -2890,54 +3000,54 @@ class xn extends _ {
2890
3000
  i !== -1 ? this.sortModel[i] = n : this.sortModel.splice(t.sort.priority, 0, n);
2891
3001
  }
2892
3002
  }
2893
- function rt(a, e) {
2894
- return ft(a, e);
3003
+ function rt(s, e) {
3004
+ return pt(s, e);
2895
3005
  }
2896
- function ot(a, e) {
2897
- const t = a.sticky;
3006
+ function ot(s, e) {
3007
+ const t = s.sticky;
2898
3008
  return t ? rt(t, e) === "left" : !1;
2899
3009
  }
2900
- function st(a, e) {
2901
- const t = a.sticky;
3010
+ function st(s, e) {
3011
+ const t = s.sticky;
2902
3012
  return t ? rt(t, e) === "right" : !1;
2903
3013
  }
2904
- function gi(a, e = "ltr") {
2905
- return a.filter((t) => ot(t, e));
3014
+ function gi(s, e = "ltr") {
3015
+ return s.filter((t) => ot(t, e));
2906
3016
  }
2907
- function pi(a, e = "ltr") {
2908
- return a.filter((t) => st(t, e));
3017
+ function pi(s, e = "ltr") {
3018
+ return s.filter((t) => st(t, e));
2909
3019
  }
2910
- function se(a) {
2911
- return a.some(
3020
+ function se(s) {
3021
+ return s.some(
2912
3022
  (e) => e.sticky === "left" || e.sticky === "right" || e.sticky === "start" || e.sticky === "end"
2913
3023
  );
2914
3024
  }
2915
- function qe(a, e) {
2916
- const t = Array.from(a.querySelectorAll(".header-row .cell"));
3025
+ function qe(s, e) {
3026
+ const t = Array.from(s.querySelectorAll(".header-row .cell"));
2917
3027
  if (!t.length) return;
2918
- const i = ue(a), n = /* @__PURE__ */ new Map();
2919
- e.forEach((s, l) => {
2920
- s.field && n.set(s.field, l);
3028
+ const i = ue(s), n = /* @__PURE__ */ new Map();
3029
+ e.forEach((a, l) => {
3030
+ a.field && n.set(a.field, l);
2921
3031
  });
2922
3032
  let r = 0;
2923
- for (const s of e)
2924
- if (ot(s, i)) {
2925
- const l = n.get(s.field), d = t.find((c) => c.getAttribute("data-field") === s.field);
2926
- d && (d.classList.add("sticky-left"), d.style.position = "sticky", d.style.left = r + "px", l !== void 0 && a.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach((c) => {
3033
+ for (const a of e)
3034
+ if (ot(a, i)) {
3035
+ const l = n.get(a.field), d = t.find((c) => c.getAttribute("data-field") === a.field);
3036
+ d && (d.classList.add("sticky-left"), d.style.position = "sticky", d.style.left = r + "px", l !== void 0 && s.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach((c) => {
2927
3037
  c.classList.add("sticky-left"), c.style.position = "sticky", c.style.left = r + "px";
2928
3038
  }), r += d.offsetWidth);
2929
3039
  }
2930
3040
  let o = 0;
2931
- for (const s of [...e].reverse())
2932
- if (st(s, i)) {
2933
- const l = n.get(s.field), d = t.find((c) => c.getAttribute("data-field") === s.field);
2934
- d && (d.classList.add("sticky-right"), d.style.position = "sticky", d.style.right = o + "px", l !== void 0 && a.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach((c) => {
3041
+ for (const a of [...e].reverse())
3042
+ if (st(a, i)) {
3043
+ const l = n.get(a.field), d = t.find((c) => c.getAttribute("data-field") === a.field);
3044
+ d && (d.classList.add("sticky-right"), d.style.position = "sticky", d.style.right = o + "px", l !== void 0 && s.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach((c) => {
2935
3045
  c.classList.add("sticky-right"), c.style.position = "sticky", c.style.right = o + "px";
2936
3046
  }), o += d.offsetWidth);
2937
3047
  }
2938
3048
  }
2939
- function He(a) {
2940
- a.querySelectorAll(".sticky-left, .sticky-right").forEach((t) => {
3049
+ function He(s) {
3050
+ s.querySelectorAll(".sticky-left, .sticky-right").forEach((t) => {
2941
3051
  t.classList.remove("sticky-left", "sticky-right"), t.style.position = "", t.style.left = "", t.style.right = "";
2942
3052
  });
2943
3053
  }
@@ -3030,10 +3140,10 @@ class Cn extends _ {
3030
3140
  return;
3031
3141
  let i = 0, n = 0;
3032
3142
  if (e) {
3033
- const o = e.querySelectorAll(".sticky-left"), s = e.querySelectorAll(".sticky-right");
3143
+ const o = e.querySelectorAll(".sticky-left"), a = e.querySelectorAll(".sticky-right");
3034
3144
  o.forEach((l) => {
3035
3145
  i += l.offsetWidth;
3036
- }), s.forEach((l) => {
3146
+ }), a.forEach((l) => {
3037
3147
  n += l.offsetWidth;
3038
3148
  });
3039
3149
  } else
@@ -3044,10 +3154,10 @@ class Cn extends _ {
3044
3154
  return { left: i, right: n, skipScroll: r };
3045
3155
  }
3046
3156
  }
3047
- function mi(a) {
3048
- return typeof a == "object" && a !== null && "aggFunc" in a;
3157
+ function mi(s) {
3158
+ return typeof s == "object" && s !== null && "aggFunc" in s;
3049
3159
  }
3050
- function ae(a, e) {
3160
+ function ae(s, e) {
3051
3161
  const t = document.createElement("div");
3052
3162
  t.className = "tbw-pinned-rows", t.setAttribute("role", "presentation"), t.setAttribute("aria-live", "polite");
3053
3163
  const i = document.createElement("div");
@@ -3055,41 +3165,41 @@ function ae(a, e) {
3055
3165
  const n = document.createElement("div");
3056
3166
  n.className = "tbw-pinned-rows-center";
3057
3167
  const r = document.createElement("div");
3058
- if (r.className = "tbw-pinned-rows-right", a.showRowCount !== !1) {
3168
+ if (r.className = "tbw-pinned-rows-right", s.showRowCount !== !1) {
3059
3169
  const o = document.createElement("span");
3060
3170
  o.className = "tbw-status-panel tbw-status-panel-row-count", o.textContent = `Total: ${e.totalRows} rows`, i.appendChild(o);
3061
3171
  }
3062
- if (a.showFilteredCount && e.filteredRows !== e.totalRows) {
3172
+ if (s.showFilteredCount && e.filteredRows !== e.totalRows) {
3063
3173
  const o = document.createElement("span");
3064
3174
  o.className = "tbw-status-panel tbw-status-panel-filtered-count", o.textContent = `Filtered: ${e.filteredRows}`, i.appendChild(o);
3065
3175
  }
3066
- if (a.showSelectedCount && e.selectedRows > 0) {
3176
+ if (s.showSelectedCount && e.selectedRows > 0) {
3067
3177
  const o = document.createElement("span");
3068
3178
  o.className = "tbw-status-panel tbw-status-panel-selected-count", o.textContent = `Selected: ${e.selectedRows}`, r.appendChild(o);
3069
3179
  }
3070
- if (a.customPanels)
3071
- for (const o of a.customPanels) {
3072
- const s = wi(o, e);
3180
+ if (s.customPanels)
3181
+ for (const o of s.customPanels) {
3182
+ const a = wi(o, e);
3073
3183
  switch (o.position) {
3074
3184
  case "left":
3075
- i.appendChild(s);
3185
+ i.appendChild(a);
3076
3186
  break;
3077
3187
  case "center":
3078
- n.appendChild(s);
3188
+ n.appendChild(a);
3079
3189
  break;
3080
3190
  case "right":
3081
- r.appendChild(s);
3191
+ r.appendChild(a);
3082
3192
  break;
3083
3193
  }
3084
3194
  }
3085
3195
  return t.appendChild(i), t.appendChild(n), t.appendChild(r), t;
3086
3196
  }
3087
- function ze(a) {
3197
+ function ze(s) {
3088
3198
  const e = document.createElement("div");
3089
- return e.className = `tbw-aggregation-rows tbw-aggregation-rows-${a}`, e.setAttribute("role", "presentation"), e;
3199
+ return e.className = `tbw-aggregation-rows tbw-aggregation-rows-${s}`, e.setAttribute("role", "presentation"), e;
3090
3200
  }
3091
- function Oe(a, e, t, i) {
3092
- a.innerHTML = "";
3201
+ function Oe(s, e, t, i) {
3202
+ s.innerHTML = "";
3093
3203
  for (const n of e) {
3094
3204
  const r = document.createElement("div");
3095
3205
  if (r.className = "tbw-aggregation-row", r.setAttribute("role", "presentation"), n.id && r.setAttribute("data-aggregation-id", n.id), n.fullWidth) {
@@ -3097,8 +3207,8 @@ function Oe(a, e, t, i) {
3097
3207
  o.className = "tbw-aggregation-cell tbw-aggregation-cell-full", o.style.gridColumn = "1 / -1", o.textContent = n.label || "", r.appendChild(o);
3098
3208
  } else
3099
3209
  for (const o of t) {
3100
- const s = document.createElement("div");
3101
- s.className = "tbw-aggregation-cell", s.setAttribute("data-field", o.field);
3210
+ const a = document.createElement("div");
3211
+ a.className = "tbw-aggregation-cell", a.setAttribute("data-field", o.field);
3102
3212
  let l, d;
3103
3213
  const c = n.aggregators?.[o.field];
3104
3214
  if (c)
@@ -3113,24 +3223,24 @@ function Oe(a, e, t, i) {
3113
3223
  const u = n.cells[o.field];
3114
3224
  typeof u == "function" ? l = u(i, o.field, o) : l = u;
3115
3225
  }
3116
- l != null ? s.textContent = d ? d(l, o.field, o) : String(l) : s.textContent = "", r.appendChild(s);
3226
+ l != null ? a.textContent = d ? d(l, o.field, o) : String(l) : a.textContent = "", r.appendChild(a);
3117
3227
  }
3118
- a.appendChild(r);
3228
+ s.appendChild(r);
3119
3229
  }
3120
3230
  }
3121
- function wi(a, e) {
3231
+ function wi(s, e) {
3122
3232
  const t = document.createElement("div");
3123
- t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${a.id}`;
3124
- const i = a.render(e);
3233
+ t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${s.id}`;
3234
+ const i = s.render(e);
3125
3235
  return typeof i == "string" ? t.innerHTML = i : t.appendChild(i), t;
3126
3236
  }
3127
- function Ge(a, e, t, i, n) {
3237
+ function Ge(s, e, t, i, n) {
3128
3238
  return {
3129
- totalRows: a.length,
3130
- filteredRows: n?.cachedResult?.length ?? a.length,
3239
+ totalRows: s.length,
3240
+ filteredRows: n?.cachedResult?.length ?? s.length,
3131
3241
  selectedRows: i?.selected?.size ?? 0,
3132
3242
  columns: e,
3133
- rows: a,
3243
+ rows: s,
3134
3244
  grid: t
3135
3245
  };
3136
3246
  }
@@ -3165,8 +3275,8 @@ class En extends _ {
3165
3275
  this.grid,
3166
3276
  i,
3167
3277
  n
3168
- ), o = this.config.aggregationRows || [], s = o.filter((h) => h.position === "top"), l = o.filter((h) => h.position !== "top");
3169
- if (s.length > 0) {
3278
+ ), o = this.config.aggregationRows || [], a = o.filter((h) => h.position === "top"), l = o.filter((h) => h.position !== "top");
3279
+ if (a.length > 0) {
3170
3280
  if (!this.topAggregationContainer) {
3171
3281
  this.topAggregationContainer = ze("top");
3172
3282
  const h = e.querySelector(".header");
@@ -3174,7 +3284,7 @@ class En extends _ {
3174
3284
  }
3175
3285
  Oe(
3176
3286
  this.topAggregationContainer,
3177
- s,
3287
+ a,
3178
3288
  this.visibleColumns,
3179
3289
  this.sourceRows
3180
3290
  );
@@ -3241,63 +3351,63 @@ class En extends _ {
3241
3351
  this.config.aggregationRows && (this.config.aggregationRows = this.config.aggregationRows.filter((t) => t.id !== e), this.requestRender());
3242
3352
  }
3243
3353
  }
3244
- const vi = gt;
3245
- function yi(a) {
3354
+ const vi = mt;
3355
+ function yi(s) {
3246
3356
  const e = [];
3247
- return !a.rowGroupFields?.length && !a.columnGroupFields?.length && e.push("At least one row or column group field is required"), a.valueFields?.length || e.push("At least one value field is required"), e;
3357
+ return !s.rowGroupFields?.length && !s.columnGroupFields?.length && e.push("At least one row or column group field is required"), s.valueFields?.length || e.push("At least one value field is required"), e;
3248
3358
  }
3249
- function be(a, e) {
3250
- return [...a, e].join("|");
3359
+ function be(s, e) {
3360
+ return [...s, e].join("|");
3251
3361
  }
3252
- function xi(a, e) {
3253
- const t = e.rowGroupFields ?? [], i = e.columnGroupFields ?? [], n = e.valueFields ?? [], r = Ci(a, i), o = at(
3254
- a,
3362
+ function xi(s, e) {
3363
+ const t = e.rowGroupFields ?? [], i = e.columnGroupFields ?? [], n = e.valueFields ?? [], r = Ci(s, i), o = at(
3364
+ s,
3255
3365
  t,
3256
3366
  i,
3257
3367
  r,
3258
3368
  n,
3259
3369
  0,
3260
3370
  ""
3261
- ), s = Ri(o, r, n), l = Object.values(s).reduce((d, c) => d + c, 0);
3371
+ ), a = Ri(o, r, n), l = Object.values(a).reduce((d, c) => d + c, 0);
3262
3372
  return {
3263
3373
  rows: o,
3264
3374
  columnKeys: r,
3265
- totals: s,
3375
+ totals: a,
3266
3376
  grandTotal: l
3267
3377
  };
3268
3378
  }
3269
- function Ci(a, e) {
3379
+ function Ci(s, e) {
3270
3380
  if (e.length === 0) return ["value"];
3271
3381
  const t = /* @__PURE__ */ new Set();
3272
- for (const i of a) {
3382
+ for (const i of s) {
3273
3383
  const n = e.map((r) => String(i[r] ?? "")).join("|");
3274
3384
  t.add(n);
3275
3385
  }
3276
3386
  return [...t].sort();
3277
3387
  }
3278
- function Ei(a, e) {
3388
+ function Ei(s, e) {
3279
3389
  const t = /* @__PURE__ */ new Map();
3280
- for (const i of a) {
3390
+ for (const i of s) {
3281
3391
  const n = String(i[e] ?? ""), r = t.get(n);
3282
3392
  r ? r.push(i) : t.set(n, [i]);
3283
3393
  }
3284
3394
  return t;
3285
3395
  }
3286
- function at(a, e, t, i, n, r, o) {
3287
- const s = [];
3396
+ function at(s, e, t, i, n, r, o) {
3397
+ const a = [];
3288
3398
  if (e.length === 0) {
3289
- const h = Be(a, t, i, n), f = Ve(h);
3290
- return s.push({
3399
+ const h = Be(s, t, i, n), f = Ve(h);
3400
+ return a.push({
3291
3401
  rowKey: o || "all",
3292
3402
  rowLabel: o || "All",
3293
3403
  depth: r,
3294
3404
  values: h,
3295
3405
  total: f,
3296
3406
  isGroup: !1,
3297
- rowCount: a.length
3298
- }), s;
3407
+ rowCount: s.length
3408
+ }), a;
3299
3409
  }
3300
- const l = e[0], d = e.slice(1), c = d.length > 0, u = Ei(a, l);
3410
+ const l = e[0], d = e.slice(1), c = d.length > 0, u = Ei(s, l);
3301
3411
  for (const [h, f] of u) {
3302
3412
  const g = o ? `${o}|${h}` : h, p = Be(f, t, i, n), w = Ve(p);
3303
3413
  let b;
@@ -3309,7 +3419,7 @@ function at(a, e, t, i, n, r, o) {
3309
3419
  n,
3310
3420
  r + 1,
3311
3421
  g
3312
- )), s.push({
3422
+ )), a.push({
3313
3423
  rowKey: g,
3314
3424
  rowLabel: h || "(blank)",
3315
3425
  depth: r,
@@ -3320,90 +3430,90 @@ function at(a, e, t, i, n, r, o) {
3320
3430
  rowCount: f.length
3321
3431
  });
3322
3432
  }
3323
- return s;
3433
+ return a;
3324
3434
  }
3325
- function Be(a, e, t, i) {
3435
+ function Be(s, e, t, i) {
3326
3436
  const n = {};
3327
3437
  for (const r of t)
3328
3438
  for (const o of i) {
3329
- const l = (e.length > 0 ? a.filter((h) => e.map((f) => String(h[f] ?? "")).join("|") === r) : a).map((h) => Number(h[o.field]) || 0), d = vi(o.aggFunc), c = l.length > 0 ? d(l) : null, u = be([r], o.field);
3439
+ const l = (e.length > 0 ? s.filter((h) => e.map((f) => String(h[f] ?? "")).join("|") === r) : s).map((h) => Number(h[o.field]) || 0), d = vi(o.aggFunc), c = l.length > 0 ? d(l) : null, u = be([r], o.field);
3330
3440
  n[u] = c;
3331
3441
  }
3332
3442
  return n;
3333
3443
  }
3334
- function Ve(a) {
3444
+ function Ve(s) {
3335
3445
  let e = 0;
3336
- for (const t of Object.values(a))
3446
+ for (const t of Object.values(s))
3337
3447
  e += t ?? 0;
3338
3448
  return e;
3339
3449
  }
3340
- function Ri(a, e, t) {
3450
+ function Ri(s, e, t) {
3341
3451
  const i = {};
3342
3452
  function n(r) {
3343
3453
  for (const o of r)
3344
3454
  if (!o.isGroup || !o.children?.length)
3345
- for (const s of e)
3455
+ for (const a of e)
3346
3456
  for (const l of t) {
3347
- const d = be([s], l.field);
3457
+ const d = be([a], l.field);
3348
3458
  i[d] = (i[d] ?? 0) + (o.values[d] ?? 0);
3349
3459
  }
3350
3460
  else o.children && n(o.children);
3351
3461
  }
3352
- return n(a), i;
3462
+ return n(s), i;
3353
3463
  }
3354
- function Si(a, e, t = !0) {
3464
+ function Si(s, e, t = !0) {
3355
3465
  const i = [];
3356
3466
  function n(r) {
3357
3467
  i.push(r);
3358
3468
  const o = e ? e.has(r.rowKey) : t;
3359
3469
  if (r.children && o)
3360
- for (const s of r.children)
3361
- n(s);
3470
+ for (const a of r.children)
3471
+ n(a);
3362
3472
  }
3363
- for (const r of a)
3473
+ for (const r of s)
3364
3474
  n(r);
3365
3475
  return i;
3366
3476
  }
3367
- function ki(a) {
3477
+ function ki(s) {
3368
3478
  const e = [];
3369
3479
  function t(i) {
3370
3480
  if (i.isGroup && e.push(i.rowKey), i.children)
3371
3481
  for (const n of i.children)
3372
3482
  t(n);
3373
3483
  }
3374
- for (const i of a)
3484
+ for (const i of s)
3375
3485
  t(i);
3376
3486
  return e;
3377
3487
  }
3378
3488
  const Ai = ["sum", "avg", "count", "min", "max", "first", "last"];
3379
- function _i(a, e, t, i) {
3489
+ function _i(s, e, t, i) {
3380
3490
  const n = new AbortController(), r = { config: e, callbacks: i, signal: n.signal }, o = document.createElement("div");
3381
- return o.className = "tbw-pivot-panel", o.appendChild(j("Options", () => Pi(t, r))), o.appendChild(j("Row Groups", () => We("rowGroups", r))), o.appendChild(j("Column Groups", () => We("columnGroups", r))), o.appendChild(j("Values", () => Li(r))), o.appendChild(j("Available Fields", () => Fi(r))), a.appendChild(o), () => {
3491
+ return o.className = "tbw-pivot-panel", o.appendChild(Y("Options", () => Pi(t, r))), o.appendChild(Y("Row Groups", () => We("rowGroups", r))), o.appendChild(Y("Column Groups", () => We("columnGroups", r))), o.appendChild(Y("Values", () => Li(r))), o.appendChild(Y("Available Fields", () => Fi(r))), s.appendChild(o), () => {
3382
3492
  n.abort(), o.remove();
3383
3493
  };
3384
3494
  }
3385
- function j(a, e) {
3495
+ function Y(s, e) {
3386
3496
  const t = document.createElement("div");
3387
3497
  t.className = "tbw-pivot-section";
3388
3498
  const i = document.createElement("div");
3389
- i.className = "tbw-pivot-section-header", i.textContent = a;
3499
+ i.className = "tbw-pivot-section-header", i.textContent = s;
3390
3500
  const n = document.createElement("div");
3391
3501
  return n.className = "tbw-pivot-section-content", n.appendChild(e()), t.appendChild(i), t.appendChild(n), t;
3392
3502
  }
3393
- function We(a, e) {
3503
+ function We(s, e) {
3394
3504
  const { config: t, callbacks: i, signal: n } = e, r = document.createElement("div");
3395
- r.className = "tbw-pivot-drop-zone", r.setAttribute("data-zone", a);
3396
- const o = a === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
3505
+ r.className = "tbw-pivot-drop-zone", r.setAttribute("data-zone", s);
3506
+ const o = s === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
3397
3507
  if (o.length === 0) {
3398
- const s = document.createElement("div");
3399
- s.className = "tbw-pivot-placeholder", s.textContent = "Drag fields here or click to add", r.appendChild(s);
3508
+ const a = document.createElement("div");
3509
+ a.className = "tbw-pivot-placeholder", a.textContent = "Drag fields here or click to add", r.appendChild(a);
3400
3510
  } else
3401
- for (const s of o)
3402
- r.appendChild(Ti(s, a, e));
3511
+ for (const a of o)
3512
+ r.appendChild(Ti(a, s, e));
3403
3513
  return r.addEventListener(
3404
3514
  "dragover",
3405
- (s) => {
3406
- s.preventDefault(), r.classList.add("drag-over");
3515
+ (a) => {
3516
+ a.preventDefault(), r.classList.add("drag-over");
3407
3517
  },
3408
3518
  { signal: n }
3409
3519
  ), r.addEventListener(
@@ -3414,30 +3524,30 @@ function We(a, e) {
3414
3524
  { signal: n }
3415
3525
  ), r.addEventListener(
3416
3526
  "drop",
3417
- (s) => {
3418
- s.preventDefault(), r.classList.remove("drag-over");
3419
- const l = s.dataTransfer?.getData("text/plain");
3420
- l && i.onAddFieldToZone(l, a);
3527
+ (a) => {
3528
+ a.preventDefault(), r.classList.remove("drag-over");
3529
+ const l = a.dataTransfer?.getData("text/plain");
3530
+ l && i.onAddFieldToZone(l, s);
3421
3531
  },
3422
3532
  { signal: n }
3423
3533
  ), r;
3424
3534
  }
3425
- function Ti(a, e, t) {
3535
+ function Ti(s, e, t) {
3426
3536
  const { callbacks: i, signal: n } = t, r = document.createElement("div");
3427
3537
  r.className = "tbw-pivot-field-chip", r.draggable = !0;
3428
- const o = i.getAvailableFields().find((d) => d.field === a), s = document.createElement("span");
3429
- s.className = "tbw-pivot-chip-label", s.textContent = o?.header ?? a;
3538
+ const o = i.getAvailableFields().find((d) => d.field === s), a = document.createElement("span");
3539
+ a.className = "tbw-pivot-chip-label", a.textContent = o?.header ?? s;
3430
3540
  const l = document.createElement("button");
3431
3541
  return l.className = "tbw-pivot-chip-remove", l.innerHTML = "×", l.title = "Remove field", l.addEventListener(
3432
3542
  "click",
3433
3543
  (d) => {
3434
- d.stopPropagation(), i.onRemoveFieldFromZone(a, e);
3544
+ d.stopPropagation(), i.onRemoveFieldFromZone(s, e);
3435
3545
  },
3436
3546
  { signal: n }
3437
- ), r.appendChild(s), r.appendChild(l), r.addEventListener(
3547
+ ), r.appendChild(a), r.appendChild(l), r.addEventListener(
3438
3548
  "dragstart",
3439
3549
  (d) => {
3440
- d.dataTransfer?.setData("text/plain", a), d.dataTransfer?.setData("source-zone", e), r.classList.add("dragging");
3550
+ d.dataTransfer?.setData("text/plain", s), d.dataTransfer?.setData("source-zone", e), r.classList.add("dragging");
3441
3551
  },
3442
3552
  { signal: n }
3443
3553
  ), r.addEventListener(
@@ -3448,8 +3558,8 @@ function Ti(a, e, t) {
3448
3558
  { signal: n }
3449
3559
  ), r;
3450
3560
  }
3451
- function Li(a) {
3452
- const { config: e, callbacks: t, signal: i } = a, n = document.createElement("div");
3561
+ function Li(s) {
3562
+ const { config: e, callbacks: t, signal: i } = s, n = document.createElement("div");
3453
3563
  n.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", n.setAttribute("data-zone", "values");
3454
3564
  const r = e.valueFields ?? [];
3455
3565
  if (r.length === 0) {
@@ -3457,7 +3567,7 @@ function Li(a) {
3457
3567
  o.className = "tbw-pivot-placeholder", o.textContent = "Drag numeric fields here for aggregation", n.appendChild(o);
3458
3568
  } else
3459
3569
  for (const o of r)
3460
- n.appendChild(Ii(o, a));
3570
+ n.appendChild(Ii(o, s));
3461
3571
  return n.addEventListener(
3462
3572
  "dragover",
3463
3573
  (o) => {
@@ -3474,29 +3584,29 @@ function Li(a) {
3474
3584
  "drop",
3475
3585
  (o) => {
3476
3586
  o.preventDefault(), n.classList.remove("drag-over");
3477
- const s = o.dataTransfer?.getData("text/plain");
3478
- s && t.onAddValueField(s, "sum");
3587
+ const a = o.dataTransfer?.getData("text/plain");
3588
+ a && t.onAddValueField(a, "sum");
3479
3589
  },
3480
3590
  { signal: i }
3481
3591
  ), n;
3482
3592
  }
3483
- function Ii(a, e) {
3593
+ function Ii(s, e) {
3484
3594
  const { callbacks: t, signal: i } = e, n = document.createElement("div");
3485
3595
  n.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
3486
- const r = t.getAvailableFields().find((c) => c.field === a.field), o = document.createElement("div");
3596
+ const r = t.getAvailableFields().find((c) => c.field === s.field), o = document.createElement("div");
3487
3597
  o.className = "tbw-pivot-value-label-wrapper";
3488
- const s = document.createElement("span");
3489
- s.className = "tbw-pivot-chip-label", s.textContent = r?.header ?? a.field;
3598
+ const a = document.createElement("span");
3599
+ a.className = "tbw-pivot-chip-label", a.textContent = r?.header ?? s.field;
3490
3600
  const l = document.createElement("select");
3491
3601
  l.className = "tbw-pivot-agg-select", l.title = "Aggregation function";
3492
3602
  for (const c of Ai) {
3493
3603
  const u = document.createElement("option");
3494
- u.value = c, u.textContent = c.toUpperCase(), u.selected = c === a.aggFunc, l.appendChild(u);
3604
+ u.value = c, u.textContent = c.toUpperCase(), u.selected = c === s.aggFunc, l.appendChild(u);
3495
3605
  }
3496
3606
  l.addEventListener(
3497
3607
  "change",
3498
3608
  () => {
3499
- t.onUpdateValueAggFunc(a.field, l.value);
3609
+ t.onUpdateValueAggFunc(s.field, l.value);
3500
3610
  },
3501
3611
  { signal: i }
3502
3612
  );
@@ -3504,24 +3614,24 @@ function Ii(a, e) {
3504
3614
  return d.className = "tbw-pivot-chip-remove", d.innerHTML = "×", d.title = "Remove value field", d.addEventListener(
3505
3615
  "click",
3506
3616
  (c) => {
3507
- c.stopPropagation(), t.onRemoveValueField(a.field);
3617
+ c.stopPropagation(), t.onRemoveValueField(s.field);
3508
3618
  },
3509
3619
  { signal: i }
3510
- ), o.appendChild(s), o.appendChild(l), n.appendChild(o), n.appendChild(d), n;
3620
+ ), o.appendChild(a), o.appendChild(l), n.appendChild(o), n.appendChild(d), n;
3511
3621
  }
3512
- function Fi(a) {
3513
- const { config: e, callbacks: t, signal: i } = a, n = document.createElement("div");
3622
+ function Fi(s) {
3623
+ const { config: e, callbacks: t, signal: i } = s, n = document.createElement("div");
3514
3624
  n.className = "tbw-pivot-available-fields";
3515
3625
  const r = t.getAvailableFields(), o = /* @__PURE__ */ new Set([
3516
3626
  ...e.rowGroupFields ?? [],
3517
3627
  ...e.columnGroupFields ?? [],
3518
3628
  ...e.valueFields?.map((l) => l.field) ?? []
3519
- ]), s = r.filter((l) => !o.has(l.field));
3520
- if (s.length === 0) {
3629
+ ]), a = r.filter((l) => !o.has(l.field));
3630
+ if (a.length === 0) {
3521
3631
  const l = document.createElement("div");
3522
3632
  l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use", n.appendChild(l);
3523
3633
  } else
3524
- for (const l of s) {
3634
+ for (const l of a) {
3525
3635
  const d = document.createElement("div");
3526
3636
  d.className = "tbw-pivot-field-chip available", d.textContent = l.header, d.draggable = !0, d.title = `Drag to add "${l.field}" to a zone`, d.addEventListener(
3527
3637
  "dragstart",
@@ -3539,12 +3649,12 @@ function Fi(a) {
3539
3649
  }
3540
3650
  return n;
3541
3651
  }
3542
- function Pi(a, e) {
3652
+ function Pi(s, e) {
3543
3653
  const { config: t, callbacks: i, signal: n } = e, r = document.createElement("div");
3544
3654
  return r.className = "tbw-pivot-options", r.appendChild(
3545
3655
  le(
3546
3656
  "Enable Pivot View",
3547
- a,
3657
+ s,
3548
3658
  (o) => {
3549
3659
  i.onTogglePivot(o);
3550
3660
  },
@@ -3570,65 +3680,65 @@ function Pi(a, e) {
3570
3680
  )
3571
3681
  ), r;
3572
3682
  }
3573
- function le(a, e, t, i) {
3683
+ function le(s, e, t, i) {
3574
3684
  const n = document.createElement("label");
3575
3685
  n.className = "tbw-pivot-checkbox";
3576
3686
  const r = document.createElement("input");
3577
3687
  r.type = "checkbox", r.checked = e, r.addEventListener("change", () => t(r.checked), { signal: i });
3578
3688
  const o = document.createElement("span");
3579
- return o.textContent = a, n.appendChild(r), n.appendChild(o), n;
3689
+ return o.textContent = s, n.appendChild(r), n.appendChild(o), n;
3580
3690
  }
3581
- function Di(a, e, t) {
3582
- return e.className = "data-grid-row pivot-group-row", e.setAttribute("data-pivot-depth", String(a.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(a.__pivotRowKey ?? "")), e.setAttribute("role", "row"), e.innerHTML = "", t.columns.forEach((i, n) => {
3691
+ function Di(s, e, t) {
3692
+ return e.className = "data-grid-row pivot-group-row", e.setAttribute("data-pivot-depth", String(s.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(s.__pivotRowKey ?? "")), e.setAttribute("role", "row"), e.innerHTML = "", t.columns.forEach((i, n) => {
3583
3693
  const r = document.createElement("div");
3584
3694
  if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("data-row", String(t.rowIndex)), r.setAttribute("role", "gridcell"), n === 0) {
3585
- const o = Number(a.__pivotIndent) || 0;
3695
+ const o = Number(s.__pivotIndent) || 0;
3586
3696
  r.style.paddingLeft = `${o}px`;
3587
- const s = String(a.__pivotRowKey), l = document.createElement("button");
3588
- l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label", a.__pivotExpanded ? "Collapse group" : "Expand group"), t.setIcon(l, t.resolveIcon(a.__pivotExpanded ? "collapse" : "expand")), l.addEventListener("click", (u) => {
3589
- u.stopPropagation(), t.onToggle(s);
3697
+ const a = String(s.__pivotRowKey), l = document.createElement("button");
3698
+ l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label", s.__pivotExpanded ? "Collapse group" : "Expand group"), t.setIcon(l, t.resolveIcon(s.__pivotExpanded ? "collapse" : "expand")), l.addEventListener("click", (u) => {
3699
+ u.stopPropagation(), t.onToggle(a);
3590
3700
  }), r.appendChild(l);
3591
3701
  const d = document.createElement("span");
3592
- d.className = "pivot-label", d.textContent = String(a.__pivotLabel ?? ""), r.appendChild(d);
3702
+ d.className = "pivot-label", d.textContent = String(s.__pivotLabel ?? ""), r.appendChild(d);
3593
3703
  const c = document.createElement("span");
3594
- c.className = "pivot-count", c.textContent = ` (${Number(a.__pivotRowCount) || 0})`, r.appendChild(c);
3704
+ c.className = "pivot-count", c.textContent = ` (${Number(s.__pivotRowCount) || 0})`, r.appendChild(c);
3595
3705
  } else {
3596
- const o = a[i.field];
3706
+ const o = s[i.field];
3597
3707
  r.textContent = o != null ? String(o) : "";
3598
3708
  }
3599
3709
  e.appendChild(r);
3600
3710
  }), !0;
3601
3711
  }
3602
- function Mi(a, e, t, i) {
3603
- return e.className = "data-grid-row pivot-leaf-row", e.setAttribute("data-pivot-depth", String(a.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(a.__pivotRowKey ?? "")), e.innerHTML = "", t.forEach((n, r) => {
3712
+ function Mi(s, e, t, i) {
3713
+ return e.className = "data-grid-row pivot-leaf-row", e.setAttribute("data-pivot-depth", String(s.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(s.__pivotRowKey ?? "")), e.innerHTML = "", t.forEach((n, r) => {
3604
3714
  const o = document.createElement("div");
3605
3715
  if (o.className = "cell", o.setAttribute("data-col", String(r)), o.setAttribute("data-row", String(i)), o.setAttribute("role", "gridcell"), r === 0) {
3606
- const s = Number(a.__pivotIndent) || 0;
3607
- o.style.paddingLeft = `${s + 20}px`;
3716
+ const a = Number(s.__pivotIndent) || 0;
3717
+ o.style.paddingLeft = `${a + 20}px`;
3608
3718
  const l = document.createElement("span");
3609
- l.className = "pivot-label", l.textContent = String(a.__pivotLabel ?? ""), o.appendChild(l);
3719
+ l.className = "pivot-label", l.textContent = String(s.__pivotLabel ?? ""), o.appendChild(l);
3610
3720
  } else {
3611
- const s = a[n.field];
3612
- o.textContent = s != null ? String(s) : "";
3721
+ const a = s[n.field];
3722
+ o.textContent = a != null ? String(a) : "";
3613
3723
  }
3614
3724
  e.appendChild(o);
3615
3725
  }), !0;
3616
3726
  }
3617
- function Ni(a, e, t) {
3727
+ function Ni(s, e, t) {
3618
3728
  return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((i, n) => {
3619
3729
  const r = document.createElement("div");
3620
3730
  if (r.className = "cell", r.setAttribute("data-col", String(n)), n === 0) {
3621
3731
  const o = document.createElement("span");
3622
3732
  o.className = "pivot-label", o.textContent = "Grand Total", r.appendChild(o);
3623
3733
  } else {
3624
- const o = a[i.field];
3734
+ const o = s[i.field];
3625
3735
  r.textContent = o != null ? String(o) : "";
3626
3736
  }
3627
3737
  e.appendChild(r);
3628
3738
  }), !0;
3629
3739
  }
3630
3740
  const qi = '@layer tbw-plugins{.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-pivot-toggle-size, var(--tbw-toggle-size, 1.25em));height:var(--tbw-pivot-toggle-size, var(--tbw-toggle-size, 1.25em));margin-right:var(--tbw-spacing-sm, .375em);border:none;background:transparent;cursor:pointer;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background var(--tbw-transition-duration, .12s) var(--tbw-transition-ease, ease),color var(--tbw-transition-duration, .12s) var(--tbw-transition-ease, ease)}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));height:100%;overflow-y:auto;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-toggle-label input{width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:var(--tbw-spacing-sm, .375rem);padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:var(--tbw-font-size-xs, .75rem);transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:var(--tbw-font-size-sm, .875rem);font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem))}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;min-width:0}.tbw-pivot-agg-select{padding:var(--tbw-spacing-xs, .125rem) var(--tbw-spacing-xs, .25rem);font-size:var(--tbw-font-size-xs, .6875rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-checkbox{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-checkbox input{width:var(--tbw-icon-size-sm, .875rem);height:var(--tbw-icon-size-sm, .875rem);cursor:pointer}.pivot-group-row.tbw-pivot-slide-in,.pivot-leaf-row.tbw-pivot-slide-in{animation:tbw-pivot-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.pivot-group-row.tbw-pivot-fade-in,.pivot-leaf-row.tbw-pivot-fade-in{animation:tbw-pivot-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-fade-in{0%{opacity:0}to{opacity:1}}}';
3631
- class G extends _ {
3741
+ class B extends _ {
3632
3742
  name = "pivot";
3633
3743
  styles = qi;
3634
3744
  static PANEL_ID = "pivot";
@@ -3665,7 +3775,7 @@ class G extends _ {
3665
3775
  getToolPanel() {
3666
3776
  if ((this.config?.showToolPanel ?? this.userConfig?.showToolPanel ?? !0) !== !1)
3667
3777
  return {
3668
- id: G.PANEL_ID,
3778
+ id: B.PANEL_ID,
3669
3779
  title: "Pivot",
3670
3780
  icon: "⊞",
3671
3781
  tooltip: "Configure pivot table",
@@ -3699,8 +3809,8 @@ class G extends _ {
3699
3809
  this.keysToAnimate.clear();
3700
3810
  const r = /* @__PURE__ */ new Set();
3701
3811
  for (const o of n) {
3702
- const s = o.__pivotRowKey;
3703
- r.add(s), !this.previousVisibleKeys.has(s) && o.__pivotDepth > 0 && this.keysToAnimate.add(s);
3812
+ const a = o.__pivotRowKey;
3813
+ r.add(a), !this.previousVisibleKeys.has(a) && o.__pivotDepth > 0 && this.keysToAnimate.add(a);
3704
3814
  }
3705
3815
  return this.previousVisibleKeys = r, n;
3706
3816
  }
@@ -3715,10 +3825,10 @@ class G extends _ {
3715
3825
  });
3716
3826
  for (const n of this.pivotResult.columnKeys)
3717
3827
  for (const r of this.config.valueFields ?? []) {
3718
- const o = be([n], r.field), s = r.header || this.fieldHeaderMap.get(r.field) || r.field;
3828
+ const o = be([n], r.field), a = r.header || this.fieldHeaderMap.get(r.field) || r.field;
3719
3829
  t.push({
3720
3830
  field: o,
3721
- header: `${n} - ${s} (${r.aggFunc})`,
3831
+ header: `${n} - ${a} (${r.aggFunc})`,
3722
3832
  width: 120,
3723
3833
  type: "number"
3724
3834
  });
@@ -3830,16 +3940,16 @@ class G extends _ {
3830
3940
  this.pivotResult = null, this.requestRender();
3831
3941
  }
3832
3942
  showPanel() {
3833
- this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(G.PANEL_ID) || this.grid.toggleToolPanelSection(G.PANEL_ID);
3943
+ this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(B.PANEL_ID) || this.grid.toggleToolPanelSection(B.PANEL_ID);
3834
3944
  }
3835
3945
  hidePanel() {
3836
3946
  this.grid.closeToolPanel();
3837
3947
  }
3838
3948
  togglePanel() {
3839
- this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(G.PANEL_ID);
3949
+ this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(B.PANEL_ID);
3840
3950
  }
3841
3951
  isPanelVisible() {
3842
- return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(G.PANEL_ID);
3952
+ return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(B.PANEL_ID);
3843
3953
  }
3844
3954
  get gridColumns() {
3845
3955
  return this.grid.columns ?? [];
@@ -3917,18 +4027,18 @@ class G extends _ {
3917
4027
  }
3918
4028
  }
3919
4029
  const J = "tbw-print-isolation-style";
3920
- function Hi(a, e) {
4030
+ function Hi(s, e) {
3921
4031
  const t = document.createElement("style");
3922
4032
  return t.id = J, t.textContent = `
3923
4033
  /* Print isolation: hide everything except the target grid */
3924
4034
  @media print {
3925
4035
  /* Hide all body children by default */
3926
- body > *:not(#${a}) {
4036
+ body > *:not(#${s}) {
3927
4037
  display: none !important;
3928
4038
  }
3929
4039
 
3930
4040
  /* But show the grid and ensure it's not hidden by ancestor rules */
3931
- #${a} {
4041
+ #${s} {
3932
4042
  display: block !important;
3933
4043
  position: static !important;
3934
4044
  visibility: visible !important;
@@ -3943,14 +4053,14 @@ function Hi(a, e) {
3943
4053
  }
3944
4054
 
3945
4055
  /* If grid is nested, we need to show its ancestors too */
3946
- #${a},
3947
- #${a} * {
4056
+ #${s},
4057
+ #${s} * {
3948
4058
  visibility: visible !important;
3949
4059
  }
3950
4060
 
3951
4061
  /* Walk up the DOM and show all ancestors of the grid */
3952
- body *:has(> #${a}),
3953
- body *:has(#${a}) {
4062
+ body *:has(> #${s}),
4063
+ body *:has(#${s}) {
3954
4064
  display: block !important;
3955
4065
  visibility: visible !important;
3956
4066
  opacity: 1 !important;
@@ -3965,7 +4075,7 @@ function Hi(a, e) {
3965
4075
  }
3966
4076
 
3967
4077
  /* Hide siblings of ancestors (everything that's not in the path to the grid) */
3968
- body *:has(#${a}) > *:not(:has(#${a})):not(#${a}) {
4078
+ body *:has(#${s}) > *:not(:has(#${s})):not(#${s}) {
3969
4079
  display: none !important;
3970
4080
  }
3971
4081
 
@@ -3991,18 +4101,18 @@ function Hi(a, e) {
3991
4101
  }
3992
4102
  `, t;
3993
4103
  }
3994
- async function Ki(a, e = {}) {
3995
- const { orientation: t = "landscape" } = e, i = a.id;
4104
+ async function Ki(s, e = {}) {
4105
+ const { orientation: t = "landscape" } = e, i = s.id;
3996
4106
  document.querySelectorAll(`#${CSS.escape(i)}`).length > 1 && console.warn(
3997
4107
  `[tbw-grid:print] Multiple elements found with id="${i}". Print isolation may not work correctly. Ensure each grid has a unique ID.`
3998
4108
  ), document.getElementById(J)?.remove();
3999
4109
  const r = Hi(i, t);
4000
4110
  return document.head.appendChild(r), new Promise((o) => {
4001
- const s = () => {
4002
- window.removeEventListener("afterprint", s), document.getElementById(J)?.remove(), o();
4111
+ const a = () => {
4112
+ window.removeEventListener("afterprint", a), document.getElementById(J)?.remove(), o();
4003
4113
  };
4004
- window.addEventListener("afterprint", s), window.print(), setTimeout(() => {
4005
- window.removeEventListener("afterprint", s), document.getElementById(J)?.remove(), o();
4114
+ window.addEventListener("afterprint", a), window.print(), setTimeout(() => {
4115
+ window.removeEventListener("afterprint", a), document.getElementById(J)?.remove(), o();
4006
4116
  }, 5e3);
4007
4117
  });
4008
4118
  }
@@ -4020,21 +4130,21 @@ class Rn extends _ {
4020
4130
  name = "print";
4021
4131
  version = "1.0.0";
4022
4132
  styles = zi;
4023
- #e = !1;
4024
- #t = null;
4025
- #a = null;
4026
- #n = null;
4027
- #i = null;
4133
+ #t = !1;
4134
+ #e = null;
4028
4135
  #s = null;
4029
- #d = null;
4030
- get #r() {
4136
+ #o = null;
4137
+ #i = null;
4138
+ #n = null;
4139
+ #u = null;
4140
+ get #l() {
4031
4141
  return this.grid;
4032
4142
  }
4033
4143
  isPrinting() {
4034
- return this.#e;
4144
+ return this.#t;
4035
4145
  }
4036
4146
  async print(e) {
4037
- if (this.#e) {
4147
+ if (this.#t) {
4038
4148
  console.warn("[PrintPlugin] Print already in progress");
4039
4149
  return;
4040
4150
  }
@@ -4044,7 +4154,7 @@ class Rn extends _ {
4044
4154
  return;
4045
4155
  }
4046
4156
  const i = { ...Oi, ...this.config, ...e }, r = this.rows.length;
4047
- let o = r, s = !1;
4157
+ let o = r, a = !1;
4048
4158
  if (i.warnThreshold > 0 && r > i.warnThreshold) {
4049
4159
  const d = i.maxRows > 0 ? `
4050
4160
 
@@ -4056,18 +4166,18 @@ Click OK to continue, or Cancel to abort.`
4056
4166
  ))
4057
4167
  return;
4058
4168
  }
4059
- i.maxRows > 0 && r > i.maxRows && (o = i.maxRows, s = !0), this.#e = !0;
4169
+ i.maxRows > 0 && r > i.maxRows && (o = i.maxRows, a = !0), this.#t = !0;
4060
4170
  const l = performance.now();
4061
4171
  this.emit("print-start", {
4062
4172
  rowCount: o,
4063
- limitApplied: s,
4173
+ limitApplied: a,
4064
4174
  originalRowCount: r
4065
4175
  });
4066
4176
  try {
4067
- const d = this.#r;
4068
- this.#a = {
4177
+ const d = this.#l;
4178
+ this.#s = {
4069
4179
  bypassThreshold: d._virtualization?.bypassThreshold ?? 24
4070
- }, this.#p(), s && (this.#n = this.sourceRows, this.grid.rows = this.sourceRows.slice(0, o), await new Promise((c) => setTimeout(c, 50))), (i.includeTitle || i.includeTimestamp) && this.#c(i), await this.#m(), await new Promise((c) => requestAnimationFrame(c)), await new Promise((c) => requestAnimationFrame(c)), t.classList.add(`print-${i.orientation}`), await new Promise((c) => requestAnimationFrame(c)), await new Promise((c) => requestAnimationFrame(c)), i.isolate ? await this.#h(i) : await this.#g(), this.emit("print-complete", {
4180
+ }, this.#v(), a && (this.#o = this.sourceRows, this.grid.rows = this.sourceRows.slice(0, o), await new Promise((c) => setTimeout(c, 50))), (i.includeTitle || i.includeTimestamp) && this.#r(i), await this.#d(), await new Promise((c) => requestAnimationFrame(c)), await new Promise((c) => requestAnimationFrame(c)), t.classList.add(`print-${i.orientation}`), await new Promise((c) => requestAnimationFrame(c)), await new Promise((c) => requestAnimationFrame(c)), i.isolate ? await this.#p(i) : await this.#f(), this.emit("print-complete", {
4071
4181
  success: !0,
4072
4182
  rowCount: o,
4073
4183
  duration: Math.round(performance.now() - l)
@@ -4079,10 +4189,10 @@ Click OK to continue, or Cancel to abort.`
4079
4189
  duration: Math.round(performance.now() - l)
4080
4190
  });
4081
4191
  } finally {
4082
- this.#f(), this.#e = !1;
4192
+ this.#w(), this.#t = !1;
4083
4193
  }
4084
4194
  }
4085
- #c(e) {
4195
+ #r(e) {
4086
4196
  const t = this.gridElement;
4087
4197
  if (t) {
4088
4198
  if (this.#i = document.createElement("div"), this.#i.className = "tbw-print-header", e.includeTitle) {
@@ -4093,16 +4203,16 @@ Click OK to continue, or Cancel to abort.`
4093
4203
  const i = document.createElement("div");
4094
4204
  i.className = "tbw-print-header-timestamp", i.textContent = `Printed: ${(/* @__PURE__ */ new Date()).toLocaleString()}`, this.#i.appendChild(i);
4095
4205
  }
4096
- t.insertBefore(this.#i, t.firstChild), this.#s = document.createElement("div"), this.#s.className = "tbw-print-footer", this.#s.textContent = `Page generated from ${window.location.hostname}`, t.appendChild(this.#s);
4206
+ t.insertBefore(this.#i, t.firstChild), this.#n = document.createElement("div"), this.#n.className = "tbw-print-footer", this.#n.textContent = `Page generated from ${window.location.hostname}`, t.appendChild(this.#n);
4097
4207
  }
4098
4208
  }
4099
- async #m() {
4100
- const e = this.#r;
4209
+ async #d() {
4210
+ const e = this.#l;
4101
4211
  if (!e._virtualization) return;
4102
4212
  const t = this.rows.length;
4103
4213
  e._virtualization.bypassThreshold = t + 100, e.refreshVirtualWindow(!0), await new Promise((i) => setTimeout(i, 100));
4104
4214
  }
4105
- async #g() {
4215
+ async #f() {
4106
4216
  return new Promise((e) => {
4107
4217
  const t = () => {
4108
4218
  window.removeEventListener("afterprint", t), e();
@@ -4112,40 +4222,40 @@ Click OK to continue, or Cancel to abort.`
4112
4222
  }, 1e3);
4113
4223
  });
4114
4224
  }
4115
- async #h(e) {
4225
+ async #p(e) {
4116
4226
  const t = this.gridElement;
4117
4227
  t && await Ki(t, {
4118
4228
  orientation: e.orientation
4119
4229
  });
4120
4230
  }
4121
- #p() {
4231
+ #v() {
4122
4232
  const e = this.columns;
4123
4233
  if (e) {
4124
- this.#t = /* @__PURE__ */ new Map();
4234
+ this.#e = /* @__PURE__ */ new Map();
4125
4235
  for (const t of e)
4126
- t.printHidden && t.field && (this.#t.set(t.field, !t.hidden), this.grid.setColumnVisible(t.field, !1));
4236
+ t.printHidden && t.field && (this.#e.set(t.field, !t.hidden), this.grid.setColumnVisible(t.field, !1));
4127
4237
  }
4128
4238
  }
4129
- #o() {
4130
- if (this.#t) {
4131
- for (const [e, t] of this.#t)
4239
+ #h() {
4240
+ if (this.#e) {
4241
+ for (const [e, t] of this.#e)
4132
4242
  this.grid.setColumnVisible(e, t);
4133
- this.#t = null;
4243
+ this.#e = null;
4134
4244
  }
4135
4245
  }
4136
- #f() {
4246
+ #w() {
4137
4247
  const e = this.gridElement;
4138
4248
  if (!e) return;
4139
- this.#o(), e.classList.remove("print-portrait", "print-landscape"), this.#d !== null && (e.style.transform = "", e.style.transformOrigin = "", e.style.width = "", this.#d = null), this.#i && (this.#i.remove(), this.#i = null), this.#s && (this.#s.remove(), this.#s = null);
4140
- const t = this.#r;
4141
- this.#a && t._virtualization && (t._virtualization.bypassThreshold = this.#a.bypassThreshold, t.refreshVirtualWindow(!0), this.#a = null), this.#n !== null && (this.grid.rows = this.#n, this.#n = null);
4249
+ this.#h(), e.classList.remove("print-portrait", "print-landscape"), this.#u !== null && (e.style.transform = "", e.style.transformOrigin = "", e.style.width = "", this.#u = null), this.#i && (this.#i.remove(), this.#i = null), this.#n && (this.#n.remove(), this.#n = null);
4250
+ const t = this.#l;
4251
+ this.#s && t._virtualization && (t._virtualization.bypassThreshold = this.#s.bypassThreshold, t.refreshVirtualWindow(!0), this.#s = null), this.#o !== null && (this.grid.rows = this.#o, this.#o = null);
4142
4252
  }
4143
4253
  afterRender() {
4144
- this.config?.button && !this.#l && (this.#u(), this.#l = !0);
4254
+ this.config?.button && !this.#c && (this.#g(), this.#c = !0);
4145
4255
  }
4146
- #l = !1;
4147
- #u() {
4148
- this.#r.registerToolbarContent?.({
4256
+ #c = !1;
4257
+ #g() {
4258
+ this.#l.registerToolbarContent?.({
4149
4259
  id: "print-button",
4150
4260
  order: 900,
4151
4261
  render: (t) => {
@@ -4163,13 +4273,13 @@ Click OK to continue, or Cancel to abort.`
4163
4273
  });
4164
4274
  }
4165
4275
  }
4166
- function Gi(a) {
4167
- const e = a.meta ?? {};
4276
+ function Gi(s) {
4277
+ const e = s.meta ?? {};
4168
4278
  return e.lockPosition !== !0 && e.suppressMovable !== !0;
4169
4279
  }
4170
- function $e(a, e, t) {
4171
- if (e === t || e < 0 || e >= a.length || t < 0 || t > a.length) return a;
4172
- const i = [...a], [n] = i.splice(e, 1);
4280
+ function $e(s, e, t) {
4281
+ if (e === t || e < 0 || e >= s.length || t < 0 || t > s.length) return s;
4282
+ const i = [...s], [n] = i.splice(e, 1);
4173
4283
  return i.splice(t, 0, n), i;
4174
4284
  }
4175
4285
  const Bi = '@layer tbw-plugins{.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';
@@ -4218,24 +4328,24 @@ class Sn extends _ {
4218
4328
  e.querySelectorAll(".header-row > .cell").forEach((i) => {
4219
4329
  const n = i, r = n.getAttribute("data-field");
4220
4330
  if (!r) return;
4221
- const o = this.columns.find((s) => s.field === r);
4331
+ const o = this.columns.find((a) => a.field === r);
4222
4332
  if (!this.canMoveColumnWithPlugins(o)) {
4223
4333
  n.draggable = !1;
4224
4334
  return;
4225
4335
  }
4226
- n.draggable = !0, !n.getAttribute("data-dragstart-bound") && (n.setAttribute("data-dragstart-bound", "true"), n.addEventListener("dragstart", (s) => {
4336
+ n.draggable = !0, !n.getAttribute("data-dragstart-bound") && (n.setAttribute("data-dragstart-bound", "true"), n.addEventListener("dragstart", (a) => {
4227
4337
  const d = this.getColumnOrder().indexOf(r);
4228
- this.isDragging = !0, this.draggedField = r, this.draggedIndex = d, s.dataTransfer && (s.dataTransfer.effectAllowed = "move", s.dataTransfer.setData("text/plain", r)), n.classList.add("dragging");
4338
+ this.isDragging = !0, this.draggedField = r, this.draggedIndex = d, a.dataTransfer && (a.dataTransfer.effectAllowed = "move", a.dataTransfer.setData("text/plain", r)), n.classList.add("dragging");
4229
4339
  }), n.addEventListener("dragend", () => {
4230
4340
  this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses();
4231
- }), n.addEventListener("dragover", (s) => {
4232
- if (s.preventDefault(), !this.isDragging || this.draggedField === r) return;
4341
+ }), n.addEventListener("dragover", (a) => {
4342
+ if (a.preventDefault(), !this.isDragging || this.draggedField === r) return;
4233
4343
  const l = n.getBoundingClientRect(), d = l.left + l.width / 2, u = this.getColumnOrder().indexOf(r);
4234
- this.dropIndex = s.clientX < d ? u : u + 1, n.classList.add("drop-target"), n.classList.toggle("drop-before", s.clientX < d), n.classList.toggle("drop-after", s.clientX >= d);
4344
+ this.dropIndex = a.clientX < d ? u : u + 1, n.classList.add("drop-target"), n.classList.toggle("drop-before", a.clientX < d), n.classList.toggle("drop-after", a.clientX >= d);
4235
4345
  }), n.addEventListener("dragleave", () => {
4236
4346
  n.classList.remove("drop-target", "drop-before", "drop-after");
4237
- }), n.addEventListener("drop", (s) => {
4238
- s.preventDefault();
4347
+ }), n.addEventListener("drop", (a) => {
4348
+ a.preventDefault();
4239
4349
  const l = this.draggedField, d = this.draggedIndex, c = this.dropIndex;
4240
4350
  if (!this.isDragging || l === null || d === null || c === null)
4241
4351
  return;
@@ -4256,13 +4366,13 @@ class Sn extends _ {
4256
4366
  if (i < 0 || i >= n.length) return;
4257
4367
  const r = n[i];
4258
4368
  if (!this.canMoveColumnWithPlugins(r)) return;
4259
- const o = this.getColumnOrder(), s = o.indexOf(r.field);
4260
- if (s === -1) return;
4261
- const l = e.key === "ArrowLeft" ? s - 1 : s + 1;
4369
+ const o = this.getColumnOrder(), a = o.indexOf(r.field);
4370
+ if (a === -1) return;
4371
+ const l = e.key === "ArrowLeft" ? a - 1 : a + 1;
4262
4372
  if (l < 0 || l >= o.length) return;
4263
4373
  const d = n.find((c) => c.field === o[l]);
4264
4374
  if (this.canMoveColumnWithPlugins(d))
4265
- return this.moveColumn(r.field, l), t._focusCol = l, P(this.grid), e.preventDefault(), e.stopPropagation(), !0;
4375
+ return this.moveColumn(r.field, l), t._focusCol = l, F(this.grid), e.preventDefault(), e.stopPropagation(), !0;
4266
4376
  }
4267
4377
  getColumnOrder() {
4268
4378
  return this.grid.getColumnOrder();
@@ -4297,19 +4407,19 @@ class Sn extends _ {
4297
4407
  if (!t || e.size === 0) return;
4298
4408
  const i = /* @__PURE__ */ new Map();
4299
4409
  if (t.querySelectorAll(".header-row > .cell[data-field]").forEach((o) => {
4300
- const s = o.getAttribute("data-field");
4301
- if (!s) return;
4302
- const l = e.get(s);
4410
+ const a = o.getAttribute("data-field");
4411
+ if (!a) return;
4412
+ const l = e.get(a);
4303
4413
  if (l === void 0) return;
4304
4414
  const d = l - o.getBoundingClientRect().left;
4305
- Math.abs(d) > 1 && i.set(s, d);
4415
+ Math.abs(d) > 1 && i.set(a, d);
4306
4416
  }), i.size === 0) return;
4307
4417
  const n = [];
4308
4418
  if (t.querySelectorAll(".cell[data-field]").forEach((o) => {
4309
- const s = i.get(o.getAttribute("data-field") ?? "");
4310
- if (s !== void 0) {
4419
+ const a = i.get(o.getAttribute("data-field") ?? "");
4420
+ if (a !== void 0) {
4311
4421
  const l = o;
4312
- l.style.transform = `translateX(${s}px)`, n.push(l);
4422
+ l.style.transform = `translateX(${a}px)`, n.push(l);
4313
4423
  }
4314
4424
  }), n.length === 0) return;
4315
4425
  this.gridElement.offsetHeight;
@@ -4333,25 +4443,25 @@ class Sn extends _ {
4333
4443
  const i = this.captureHeaderPositions();
4334
4444
  e();
4335
4445
  const n = /* @__PURE__ */ new Set();
4336
- if (t.querySelectorAll(".header-row > .cell[data-field]").forEach((s) => {
4337
- const l = s.getAttribute("data-field");
4446
+ if (t.querySelectorAll(".header-row > .cell[data-field]").forEach((a) => {
4447
+ const l = a.getAttribute("data-field");
4338
4448
  if (!l) return;
4339
4449
  const d = i.get(l);
4340
4450
  if (d === void 0) return;
4341
- const c = s.getBoundingClientRect().left;
4451
+ const c = a.getBoundingClientRect().left;
4342
4452
  Math.abs(d - c) > 1 && n.add(l);
4343
4453
  }), n.size === 0) return;
4344
4454
  const r = [];
4345
- if (t.querySelectorAll(".cell[data-field]").forEach((s) => {
4346
- const l = s.getAttribute("data-field");
4455
+ if (t.querySelectorAll(".cell[data-field]").forEach((a) => {
4456
+ const l = a.getAttribute("data-field");
4347
4457
  if (l && n.has(l)) {
4348
- const d = s;
4458
+ const d = a;
4349
4459
  d.classList.add("fade-animating"), r.push(d);
4350
4460
  }
4351
4461
  }), r.length === 0) return;
4352
4462
  const o = this.animationDuration;
4353
4463
  setTimeout(() => {
4354
- r.forEach((s) => s.classList.remove("fade-animating"));
4464
+ r.forEach((a) => a.classList.remove("fade-animating"));
4355
4465
  }, o + 50);
4356
4466
  }
4357
4467
  updateColumnOrder(e) {
@@ -4384,46 +4494,46 @@ class kn extends _ {
4384
4494
  }
4385
4495
  ]
4386
4496
  };
4387
- #e;
4388
- #t = !1;
4389
- #a;
4390
- #n = !1;
4497
+ #t;
4498
+ #e = !1;
4499
+ #s;
4500
+ #o = !1;
4391
4501
  #i = 0;
4392
- #s = /* @__PURE__ */ new Set();
4393
- #d = /* @__PURE__ */ new Set();
4394
- #r = null;
4395
- #c = [];
4502
+ #n = /* @__PURE__ */ new Set();
4503
+ #u = /* @__PURE__ */ new Set();
4504
+ #l = null;
4505
+ #r = [];
4396
4506
  isResponsive() {
4397
- return this.#t;
4507
+ return this.#e;
4398
4508
  }
4399
4509
  setResponsive(e) {
4400
- e !== this.#t && (this.#t = e, this.#f(), this.emit("responsive-change", {
4510
+ e !== this.#e && (this.#e = e, this.#w(), this.emit("responsive-change", {
4401
4511
  isResponsive: e,
4402
4512
  width: this.#i,
4403
4513
  breakpoint: this.config.breakpoint ?? 0
4404
4514
  }));
4405
4515
  }
4406
4516
  setBreakpoint(e) {
4407
- this.config.breakpoint = e, this.#h(this.#i);
4517
+ this.config.breakpoint = e, this.#p(this.#i);
4408
4518
  }
4409
4519
  setCardRenderer(e) {
4410
- this.config.cardRenderer = e, this.#t && this.requestRender();
4520
+ this.config.cardRenderer = e, this.#e && this.requestRender();
4411
4521
  }
4412
4522
  getWidth() {
4413
4523
  return this.#i;
4414
4524
  }
4415
4525
  getActiveBreakpoint() {
4416
- return this.#r;
4526
+ return this.#l;
4417
4527
  }
4418
4528
  attach(e) {
4419
- super.attach(e), this.#m(), this.#g(this.config.hiddenColumns), this.config.breakpoints?.length && (this.#c = [...this.config.breakpoints].sort((t, i) => i.maxWidth - t.maxWidth)), this.#e = new ResizeObserver((t) => {
4529
+ super.attach(e), this.#d(), this.#f(this.config.hiddenColumns), this.config.breakpoints?.length && (this.#r = [...this.config.breakpoints].sort((t, i) => i.maxWidth - t.maxWidth)), this.#t = new ResizeObserver((t) => {
4420
4530
  const i = t[0]?.contentRect.width ?? 0;
4421
- this.#i = i, clearTimeout(this.#a), this.#a = setTimeout(() => {
4422
- this.#h(i);
4531
+ this.#i = i, clearTimeout(this.#s), this.#s = setTimeout(() => {
4532
+ this.#p(i);
4423
4533
  }, this.config.debounceMs ?? 100);
4424
- }), this.#e.observe(this.gridElement);
4534
+ }), this.#t.observe(this.gridElement);
4425
4535
  }
4426
- #m() {
4536
+ #d() {
4427
4537
  const e = this.grid;
4428
4538
  if (!e || typeof e.querySelector != "function") return;
4429
4539
  const t = e.querySelector("tbw-grid-responsive-card");
@@ -4433,12 +4543,12 @@ class kn extends _ {
4433
4543
  const u = i.__frameworkAdapter.parseResponsiveCardElement(t);
4434
4544
  u && (this.config = { ...this.config, cardRenderer: u });
4435
4545
  }
4436
- const n = t.getAttribute("breakpoint"), r = t.getAttribute("card-row-height"), o = t.getAttribute("hidden-columns"), s = t.getAttribute("hide-header"), l = t.getAttribute("debounce-ms"), d = {};
4546
+ const n = t.getAttribute("breakpoint"), r = t.getAttribute("card-row-height"), o = t.getAttribute("hidden-columns"), a = t.getAttribute("hide-header"), l = t.getAttribute("debounce-ms"), d = {};
4437
4547
  if (n !== null) {
4438
4548
  const u = parseInt(n, 10);
4439
4549
  isNaN(u) || (d.breakpoint = u);
4440
4550
  }
4441
- if (r !== null && (d.cardRowHeight = r === "auto" ? "auto" : parseInt(r, 10)), o !== null && (d.hiddenColumns = o.split(",").map((u) => u.trim()).filter((u) => u.length > 0)), s !== null && (d.hideHeader = s !== "false"), l !== null) {
4551
+ if (r !== null && (d.cardRowHeight = r === "auto" ? "auto" : parseInt(r, 10)), o !== null && (d.hiddenColumns = o.split(",").map((u) => u.trim()).filter((u) => u.length > 0)), a !== null && (d.hideHeader = a !== "false"), l !== null) {
4442
4552
  const u = parseInt(l, 10);
4443
4553
  isNaN(u) || (d.debounceMs = u);
4444
4554
  }
@@ -4448,79 +4558,79 @@ class kn extends _ {
4448
4558
  return g.className = "tbw-responsive-card-content", g.innerHTML = f, g;
4449
4559
  }), Object.keys(d).length > 0 && (this.config = { ...this.config, ...d });
4450
4560
  }
4451
- #g(e) {
4452
- if (this.#s.clear(), this.#d.clear(), !!e)
4561
+ #f(e) {
4562
+ if (this.#n.clear(), this.#u.clear(), !!e)
4453
4563
  for (const t of e)
4454
- typeof t == "string" ? this.#s.add(t) : t.showValue ? this.#d.add(t.field) : this.#s.add(t.field);
4564
+ typeof t == "string" ? this.#n.add(t) : t.showValue ? this.#u.add(t.field) : this.#n.add(t.field);
4455
4565
  }
4456
4566
  detach() {
4457
- this.#e?.disconnect(), this.#e = void 0, clearTimeout(this.#a), this.#a = void 0, this.gridElement && this.gridElement.removeAttribute("data-responsive"), super.detach();
4567
+ this.#t?.disconnect(), this.#t = void 0, clearTimeout(this.#s), this.#s = void 0, this.gridElement && this.gridElement.removeAttribute("data-responsive"), super.detach();
4458
4568
  }
4459
4569
  handleQuery(e) {
4460
4570
  if (e.type === "isCardMode")
4461
- return this.#t;
4571
+ return this.#e;
4462
4572
  }
4463
4573
  afterRender() {
4464
- if (this.#R(), !(this.#c.length > 0 ? this.#r !== null : this.#t))
4574
+ if (this.#R(), !(this.#r.length > 0 ? this.#l !== null : this.#e))
4465
4575
  return;
4466
- const t = this.#s.size > 0, i = this.#d.size > 0;
4576
+ const t = this.#n.size > 0, i = this.#u.size > 0;
4467
4577
  if (!t && !i)
4468
4578
  return;
4469
4579
  const n = this.gridElement.querySelectorAll(".cell[data-field]");
4470
4580
  for (const r of n) {
4471
4581
  const o = r.getAttribute("data-field");
4472
- o && (this.#s.has(o) ? (r.setAttribute("data-responsive-hidden", ""), r.removeAttribute("data-responsive-value-only")) : this.#d.has(o) ? (r.setAttribute("data-responsive-value-only", ""), r.removeAttribute("data-responsive-hidden")) : (r.removeAttribute("data-responsive-hidden"), r.removeAttribute("data-responsive-value-only")));
4582
+ o && (this.#n.has(o) ? (r.setAttribute("data-responsive-hidden", ""), r.removeAttribute("data-responsive-value-only")) : this.#u.has(o) ? (r.setAttribute("data-responsive-value-only", ""), r.removeAttribute("data-responsive-hidden")) : (r.removeAttribute("data-responsive-hidden"), r.removeAttribute("data-responsive-value-only")));
4473
4583
  }
4474
4584
  }
4475
- #h(e) {
4476
- if (this.#c.length > 0) {
4477
- this.#p(e);
4585
+ #p(e) {
4586
+ if (this.#r.length > 0) {
4587
+ this.#v(e);
4478
4588
  return;
4479
4589
  }
4480
4590
  const t = this.config.breakpoint ?? 0;
4481
- t === 0 && !this.#n && (this.#n = !0, console.warn(
4591
+ t === 0 && !this.#o && (this.#o = !0, console.warn(
4482
4592
  "[tbw-grid:ResponsivePlugin] No breakpoint configured. Responsive mode is disabled. Set a breakpoint based on your grid's column count."
4483
4593
  ));
4484
4594
  const i = t > 0 && e < t;
4485
- i !== this.#t && (this.#t = i, this.#f(), this.emit("responsive-change", {
4595
+ i !== this.#e && (this.#e = i, this.#w(), this.emit("responsive-change", {
4486
4596
  isResponsive: i,
4487
4597
  width: e,
4488
4598
  breakpoint: t
4489
4599
  }), this.requestRender());
4490
4600
  }
4491
- #p(e) {
4601
+ #v(e) {
4492
4602
  let t = null;
4493
- for (const n of this.#c)
4603
+ for (const n of this.#r)
4494
4604
  e <= n.maxWidth && (t = n);
4495
- if (t !== this.#r) {
4496
- this.#r = t, t?.hiddenColumns ? this.#g(t.hiddenColumns) : this.#g(this.config.hiddenColumns);
4605
+ if (t !== this.#l) {
4606
+ this.#l = t, t?.hiddenColumns ? this.#f(t.hiddenColumns) : this.#f(this.config.hiddenColumns);
4497
4607
  const n = t?.cardLayout === !0;
4498
- n !== this.#t && (this.#t = n, this.#f()), this.emit("responsive-change", {
4499
- isResponsive: this.#t,
4608
+ n !== this.#e && (this.#e = n, this.#w()), this.emit("responsive-change", {
4609
+ isResponsive: this.#e,
4500
4610
  width: e,
4501
4611
  breakpoint: t?.maxWidth ?? 0
4502
4612
  }), this.requestRender();
4503
4613
  }
4504
4614
  }
4505
- #o;
4506
- #f() {
4507
- this.gridElement.toggleAttribute("data-responsive", this.#t);
4615
+ #h;
4616
+ #w() {
4617
+ this.gridElement.toggleAttribute("data-responsive", this.#e);
4508
4618
  const e = this.config.animate !== !1;
4509
4619
  this.gridElement.toggleAttribute("data-responsive-animate", e), this.config.animationDuration && this.gridElement.style.setProperty("--tbw-responsive-duration", `${this.config.animationDuration}ms`);
4510
4620
  const t = this.grid;
4511
- if (this.#t) {
4512
- t._virtualization && (this.#o = t._virtualization.rowHeight);
4621
+ if (this.#e) {
4622
+ t._virtualization && (this.#h = t._virtualization.rowHeight);
4513
4623
  const i = this.gridElement.querySelector(".tbw-scroll-area");
4514
4624
  i && (i.scrollLeft = 0);
4515
4625
  } else {
4516
4626
  const i = this.gridElement.querySelectorAll(".data-grid-row");
4517
4627
  for (const n of i)
4518
4628
  n.style.height = "", n.classList.remove("responsive-card");
4519
- this.#o && this.#o > 0 && t._virtualization && (t._virtualization.rowHeight = this.#o, this.#o = void 0), this.#l = void 0, this.#u = void 0, this.#w = void 0;
4629
+ this.#h && this.#h > 0 && t._virtualization && (t._virtualization.rowHeight = this.#h, this.#h = void 0), this.#c = void 0, this.#g = void 0, this.#a = void 0;
4520
4630
  }
4521
4631
  }
4522
4632
  renderRow(e, t, i) {
4523
- if (!this.#t || !this.config.cardRenderer || e.__isGroupRow)
4633
+ if (!this.#e || !this.config.cardRenderer || e.__isGroupRow)
4524
4634
  return;
4525
4635
  t.replaceChildren();
4526
4636
  const n = this.config.cardRenderer(e, i);
@@ -4529,46 +4639,46 @@ class kn extends _ {
4529
4639
  return r !== "auto" ? t.style.height = `${r}px` : t.style.height = "auto", t.appendChild(n), !0;
4530
4640
  }
4531
4641
  onKeyDown(e) {
4532
- if (!this.#t || this.config.cardRenderer && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key))
4642
+ if (!this.#e || this.config.cardRenderer && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(e.key))
4533
4643
  return !1;
4534
4644
  const t = this.rows.length - 1, i = this.visibleColumns.length - 1;
4535
4645
  switch (e.key) {
4536
4646
  case "ArrowDown":
4537
4647
  if (this.grid._focusCol < i)
4538
- return this.grid._focusCol += 1, e.preventDefault(), P(this.grid), !0;
4648
+ return this.grid._focusCol += 1, e.preventDefault(), F(this.grid), !0;
4539
4649
  if (this.grid._focusRow < t)
4540
- return this.grid._focusRow += 1, this.grid._focusCol = 0, e.preventDefault(), P(this.grid), !0;
4650
+ return this.grid._focusRow += 1, this.grid._focusCol = 0, e.preventDefault(), F(this.grid), !0;
4541
4651
  break;
4542
4652
  case "ArrowUp":
4543
4653
  if (this.grid._focusCol > 0)
4544
- return this.grid._focusCol -= 1, e.preventDefault(), P(this.grid), !0;
4654
+ return this.grid._focusCol -= 1, e.preventDefault(), F(this.grid), !0;
4545
4655
  if (this.grid._focusRow > 0)
4546
- return this.grid._focusRow -= 1, this.grid._focusCol = i, e.preventDefault(), P(this.grid), !0;
4656
+ return this.grid._focusRow -= 1, this.grid._focusCol = i, e.preventDefault(), F(this.grid), !0;
4547
4657
  break;
4548
4658
  case "ArrowRight":
4549
4659
  if (this.grid._focusRow < t)
4550
- return this.grid._focusRow += 1, e.preventDefault(), P(this.grid), !0;
4660
+ return this.grid._focusRow += 1, e.preventDefault(), F(this.grid), !0;
4551
4661
  break;
4552
4662
  case "ArrowLeft":
4553
4663
  if (this.grid._focusRow > 0)
4554
- return this.grid._focusRow -= 1, e.preventDefault(), P(this.grid), !0;
4664
+ return this.grid._focusRow -= 1, e.preventDefault(), F(this.grid), !0;
4555
4665
  break;
4556
4666
  }
4557
4667
  return !1;
4558
4668
  }
4559
- #l;
4560
- #u;
4561
- #w;
4669
+ #c;
4670
+ #g;
4671
+ #a;
4562
4672
  #b() {
4563
- if (this.#l && this.#l > 0)
4564
- return this.#l;
4673
+ if (this.#c && this.#c > 0)
4674
+ return this.#c;
4565
4675
  const e = this.config.cardRowHeight;
4566
4676
  return typeof e == "number" && e > 0 ? e : 80;
4567
4677
  }
4568
- #x() {
4569
- return this.#u && this.#u > 0 ? this.#u : this.#o ?? 28;
4678
+ #m() {
4679
+ return this.#g && this.#g > 0 ? this.#g : this.#h ?? 28;
4570
4680
  }
4571
- #v() {
4681
+ #y() {
4572
4682
  for (const e of this.rows)
4573
4683
  if (e.__isGroupRow)
4574
4684
  return !0;
@@ -4581,47 +4691,51 @@ class kn extends _ {
4581
4691
  return { groupCount: e, cardCount: t };
4582
4692
  }
4583
4693
  getExtraHeight() {
4584
- if (!this.#t || !this.config.cardRenderer || !this.#v())
4694
+ if (!this.#e || !this.config.cardRenderer || !this.#y())
4585
4695
  return 0;
4586
- const e = this.#o ?? 28, t = this.#x(), i = this.#b(), { groupCount: n, cardCount: r } = this.#C(), o = n * Math.max(0, t - e), s = r * Math.max(0, i - e);
4587
- return o + s;
4696
+ const e = this.#h ?? 28, t = this.#m(), i = this.#b(), { groupCount: n, cardCount: r } = this.#C(), o = n * Math.max(0, t - e), a = r * Math.max(0, i - e);
4697
+ return o + a;
4588
4698
  }
4589
4699
  getExtraHeightBefore(e) {
4590
- if (!this.#t || !this.config.cardRenderer || !this.#v())
4700
+ if (!this.#e || !this.config.cardRenderer || !this.#y())
4591
4701
  return 0;
4592
- const t = this.#o ?? 28, i = this.#x(), n = this.#b(), r = Math.max(0, i - t), o = Math.max(0, n - t);
4593
- let s = 0, l = 0;
4702
+ const t = this.#h ?? 28, i = this.#m(), n = this.#b(), r = Math.max(0, i - t), o = Math.max(0, n - t);
4703
+ let a = 0, l = 0;
4594
4704
  const d = this.rows, c = Math.min(e, d.length);
4595
4705
  for (let u = 0; u < c; u++)
4596
- d[u].__isGroupRow ? s++ : l++;
4597
- return s * r + l * o;
4706
+ d[u].__isGroupRow ? a++ : l++;
4707
+ return a * r + l * o;
4598
4708
  }
4599
- #E() {
4709
+ getRowHeight(e, t) {
4710
+ if (!(!this.#e || !this.config.cardRenderer))
4711
+ return e.__isGroupRow ? this.#m() : this.#b();
4712
+ }
4713
+ #x() {
4600
4714
  let e = 0;
4601
4715
  for (const t of this.rows)
4602
4716
  t.__isGroupRow || e++;
4603
4717
  return e;
4604
4718
  }
4605
- #y = !1;
4719
+ #E = !1;
4606
4720
  #R() {
4607
- if (!this.#t || !this.config.cardRenderer)
4721
+ if (!this.#e || !this.config.cardRenderer)
4608
4722
  return;
4609
4723
  let e = !1;
4610
- const t = this.grid, i = this.#v(), n = this.#E();
4611
- if (n !== this.#w && (this.#w = n, e = !0), i) {
4724
+ const t = this.grid, i = this.#y(), n = this.#x();
4725
+ if (n !== this.#a && (this.#a = n, e = !0), i) {
4612
4726
  const o = this.gridElement.querySelector(".data-grid-row.group-row");
4613
4727
  if (o) {
4614
- const s = o.getBoundingClientRect().height;
4615
- s > 0 && s !== this.#u && (this.#u = s, e = !0);
4728
+ const a = o.getBoundingClientRect().height;
4729
+ a > 0 && a !== this.#g && (this.#g = a, e = !0);
4616
4730
  }
4617
4731
  }
4618
4732
  const r = this.gridElement.querySelector(".data-grid-row.responsive-card");
4619
4733
  if (r) {
4620
4734
  const o = r.getBoundingClientRect().height;
4621
- o > 0 && o !== this.#l && (this.#l = o, e = !0, !i && t._virtualization && (t._virtualization.rowHeight = o));
4735
+ o > 0 && o !== this.#c && (this.#c = o, e = !0, !i && t._virtualization && (t._virtualization.rowHeight = o));
4622
4736
  }
4623
- e && !this.#y && (this.#y = !0, queueMicrotask(() => {
4624
- this.#y = !1, this.grid && this.#t && this.grid.refreshVirtualWindow?.(!0, !0);
4737
+ e && !this.#E && (this.#E = !0, queueMicrotask(() => {
4738
+ this.#E = !1, this.grid && this.#e && this.grid.refreshVirtualWindow?.(!0, !0);
4625
4739
  }));
4626
4740
  }
4627
4741
  }
@@ -4695,9 +4809,9 @@ class An extends _ {
4695
4809
  if (i < 0 || i >= n.length) return;
4696
4810
  const r = e.key === "ArrowUp" ? "up" : "down", o = r === "up" ? i - 1 : i + 1;
4697
4811
  if (o < 0 || o >= n.length) return;
4698
- const s = n[i];
4699
- if (!(this.config.canMove && !this.config.canMove(s, i, o, r)))
4700
- return this.handleKeyboardMove(s, i, o, r, t._focusCol), e.preventDefault(), e.stopPropagation(), !0;
4812
+ const a = n[i];
4813
+ if (!(this.config.canMove && !this.config.canMove(a, i, o, r)))
4814
+ return this.handleKeyboardMove(a, i, o, r, t._focusCol), e.preventDefault(), e.stopPropagation(), !0;
4701
4815
  }
4702
4816
  onCellClick() {
4703
4817
  this.flushPendingMove();
@@ -4737,8 +4851,8 @@ class An extends _ {
4737
4851
  const i = this.draggedRowIndex;
4738
4852
  let n = this.dropRowIndex;
4739
4853
  if (!(!this.isDragging || i === null || n === null) && (n > i && n--, i !== n)) {
4740
- const o = this.sourceRows[i], s = n < i ? "up" : "down";
4741
- (!this.config.canMove || this.config.canMove(o, i, n, s)) && this.executeMove(o, i, n, "drag");
4854
+ const o = this.sourceRows[i], a = n < i ? "up" : "down";
4855
+ (!this.config.canMove || this.config.canMove(o, i, n, a)) && this.executeMove(o, i, n, "drag");
4742
4856
  }
4743
4857
  });
4744
4858
  }
@@ -4748,8 +4862,8 @@ class An extends _ {
4748
4862
  currentIndex: i,
4749
4863
  row: e
4750
4864
  }, this.lastFocusCol = r;
4751
- const o = this.grid, s = [...o._rows ?? this.sourceRows], [l] = s.splice(t, 1);
4752
- s.splice(i, 0, l), o._rows = s, o._focusRow = i, o._focusCol = r, o.refreshVirtualWindow(!0), P(o), this.clearDebounceTimer(), this.debounceTimer = setTimeout(() => {
4865
+ const o = this.grid, a = [...o._rows ?? this.sourceRows], [l] = a.splice(t, 1);
4866
+ a.splice(i, 0, l), o._rows = a, o._focusRow = i, o._focusCol = r, o.refreshVirtualWindow(!0), F(o), this.clearDebounceTimer(), this.debounceTimer = setTimeout(() => {
4753
4867
  this.flushPendingMove();
4754
4868
  }, this.config.debounceMs ?? 300);
4755
4869
  }
@@ -4765,23 +4879,23 @@ class An extends _ {
4765
4879
  source: "keyboard"
4766
4880
  };
4767
4881
  if (this.emitCancelable("row-move", n)) {
4768
- const o = [...this.sourceRows], [s] = o.splice(t, 1);
4769
- o.splice(e, 0, s);
4882
+ const o = [...this.sourceRows], [a] = o.splice(t, 1);
4883
+ o.splice(e, 0, a);
4770
4884
  const l = this.grid;
4771
- l._rows = o, l._focusRow = e, l._focusCol = this.lastFocusCol, l.refreshVirtualWindow(!0), P(l);
4885
+ l._rows = o, l._focusRow = e, l._focusCol = this.lastFocusCol, l.refreshVirtualWindow(!0), F(l);
4772
4886
  }
4773
4887
  }
4774
4888
  executeMove(e, t, i, n) {
4775
4889
  const r = [...this.sourceRows], [o] = r.splice(t, 1);
4776
4890
  r.splice(i, 0, o);
4777
- const s = {
4891
+ const a = {
4778
4892
  row: e,
4779
4893
  fromIndex: t,
4780
4894
  toIndex: i,
4781
4895
  rows: r,
4782
4896
  source: n
4783
4897
  };
4784
- if (!this.emitCancelable("row-move", s))
4898
+ if (!this.emitCancelable("row-move", a))
4785
4899
  if (this.animationType === "flip" && this.gridElement) {
4786
4900
  const d = this.captureRowPositions();
4787
4901
  this.grid.rows = r, requestAnimationFrame(() => {
@@ -4800,7 +4914,7 @@ class An extends _ {
4800
4914
  animateFLIP(e, t, i) {
4801
4915
  const n = this.gridElement;
4802
4916
  if (!n || e.size === 0) return;
4803
- const r = Math.min(t, i), o = Math.max(t, i), s = [];
4917
+ const r = Math.min(t, i), o = Math.max(t, i), a = [];
4804
4918
  if (n.querySelectorAll(".data-grid-row").forEach((d) => {
4805
4919
  const c = d, u = this.getRowIndex(c);
4806
4920
  if (u < 0 || u < r || u > o) return;
@@ -4809,17 +4923,17 @@ class An extends _ {
4809
4923
  const f = e.get(h);
4810
4924
  if (f === void 0) return;
4811
4925
  const g = c.getBoundingClientRect().top, p = f - g;
4812
- Math.abs(p) > 1 && s.push({ el: c, deltaY: p });
4813
- }), s.length === 0) return;
4814
- s.forEach(({ el: d, deltaY: c }) => {
4926
+ Math.abs(p) > 1 && a.push({ el: c, deltaY: p });
4927
+ }), a.length === 0) return;
4928
+ a.forEach(({ el: d, deltaY: c }) => {
4815
4929
  d.style.transform = `translateY(${c}px)`;
4816
4930
  }), n.offsetHeight;
4817
4931
  const l = this.animationDuration;
4818
4932
  requestAnimationFrame(() => {
4819
- s.forEach(({ el: d }) => {
4933
+ a.forEach(({ el: d }) => {
4820
4934
  d.classList.add("flip-animating"), d.style.transform = "";
4821
4935
  }), setTimeout(() => {
4822
- s.forEach(({ el: d }) => {
4936
+ a.forEach(({ el: d }) => {
4823
4937
  d.style.transform = "", d.classList.remove("flip-animating");
4824
4938
  });
4825
4939
  }, l + 50);
@@ -4838,62 +4952,62 @@ class An extends _ {
4838
4952
  this.debounceTimer && (clearTimeout(this.debounceTimer), this.debounceTimer = null);
4839
4953
  }
4840
4954
  }
4841
- function V(a) {
4955
+ function $(s) {
4842
4956
  return {
4843
- startRow: Math.min(a.startRow, a.endRow),
4844
- startCol: Math.min(a.startCol, a.endCol),
4845
- endRow: Math.max(a.startRow, a.endRow),
4846
- endCol: Math.max(a.startCol, a.endCol)
4957
+ startRow: Math.min(s.startRow, s.endRow),
4958
+ startCol: Math.min(s.startCol, s.endCol),
4959
+ endRow: Math.max(s.startRow, s.endRow),
4960
+ endCol: Math.max(s.startCol, s.endCol)
4847
4961
  };
4848
4962
  }
4849
- function ji(a) {
4850
- const e = V(a);
4963
+ function ji(s) {
4964
+ const e = $(s);
4851
4965
  return {
4852
4966
  from: { row: e.startRow, col: e.startCol },
4853
4967
  to: { row: e.endRow, col: e.endCol }
4854
4968
  };
4855
4969
  }
4856
- function lt(a) {
4857
- return a.map(ji);
4970
+ function lt(s) {
4971
+ return s.map(ji);
4858
4972
  }
4859
- function Ui(a, e, t) {
4860
- const i = V(t);
4861
- return a >= i.startRow && a <= i.endRow && e >= i.startCol && e <= i.endCol;
4973
+ function Ui(s, e, t) {
4974
+ const i = $(t);
4975
+ return s >= i.startRow && s <= i.endRow && e >= i.startCol && e <= i.endCol;
4862
4976
  }
4863
- function je(a, e, t) {
4864
- return t.some((i) => Ui(a, e, i));
4977
+ function je(s, e, t) {
4978
+ return t.some((i) => Ui(s, e, i));
4865
4979
  }
4866
- function Yi(a) {
4867
- const e = [], t = V(a);
4980
+ function Yi(s) {
4981
+ const e = [], t = $(s);
4868
4982
  for (let i = t.startRow; i <= t.endRow; i++)
4869
4983
  for (let n = t.startCol; n <= t.endCol; n++)
4870
4984
  e.push({ row: i, col: n });
4871
4985
  return e;
4872
4986
  }
4873
- function Xi(a) {
4987
+ function Xi(s) {
4874
4988
  const e = /* @__PURE__ */ new Map();
4875
- for (const t of a)
4989
+ for (const t of s)
4876
4990
  for (const i of Yi(t))
4877
4991
  e.set(`${i.row},${i.col}`, i);
4878
4992
  return [...e.values()];
4879
4993
  }
4880
- function de(a, e) {
4994
+ function de(s, e) {
4881
4995
  return {
4882
- startRow: a.row,
4883
- startCol: a.col,
4996
+ startRow: s.row,
4997
+ startCol: s.col,
4884
4998
  endRow: e.row,
4885
4999
  endCol: e.col
4886
5000
  };
4887
5001
  }
4888
- function Q(a, e) {
4889
- const t = V(a), i = V(e);
5002
+ function Q(s, e) {
5003
+ const t = $(s), i = $(e);
4890
5004
  return t.startRow === i.startRow && t.startCol === i.startCol && t.endRow === i.endRow && t.endCol === i.endCol;
4891
5005
  }
4892
- const Zi = "@layer tbw-plugins{tbw-grid{&.selecting .data-grid-row>.cell{user-select:none}&:has(.selection){user-select:none}&[data-has-focus] .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}&[data-selection-mode=row] .cell-focus{outline:none}.data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg);&.top{border-top:2px solid var(--tbw-range-border-color)}&.bottom{border-bottom:2px solid var(--tbw-range-border-color)}&.first{border-left:2px solid var(--tbw-range-border-color)}&.last{border-right:2px solid var(--tbw-range-border-color)}}.data-grid-row[data-selectable=false]{cursor:not-allowed;opacity:.6;&.row-focus{background-color:var(--tbw-color-row-alt)}}.data-grid-row>.cell[data-selectable=false]{cursor:not-allowed;opacity:.6;&.selected{background-color:var(--tbw-selection-warning-bg, rgba(from var(--tbw-color-error) r g b / 50%))}}.tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}}";
4893
- function Qi(a, e, t) {
4894
- if (a === "cell" && e.selectedCell)
5006
+ const Zi = "@layer tbw-plugins{tbw-grid{&.selecting .data-grid-row>.cell{user-select:none}&:has(.selection){user-select:none}&[data-has-focus] .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}&[data-selection-mode=row] .cell-focus{outline:none}.data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg);&.top{border-top:2px solid var(--tbw-range-border-color);padding-top:calc(var(--tbw-cell-padding, 2px 8px) - 2px)}&.bottom{border-bottom:2px solid var(--tbw-range-border-color);padding-bottom:calc(var(--tbw-cell-padding, 2px 8px) - 2px)}&.first{border-left:2px solid var(--tbw-range-border-color);padding-left:calc(var(--tbw-cell-padding, 2px 8px) - 2px)}&.last{border-right:2px solid var(--tbw-range-border-color);padding-right:calc(var(--tbw-cell-padding, 2px 8px) - 2px)}}.data-grid-row[data-selectable=false]{cursor:not-allowed;opacity:.6;&.row-focus{background-color:var(--tbw-color-row-alt)}}.data-grid-row>.cell[data-selectable=false]{cursor:not-allowed;opacity:.6;&.selected{background-color:var(--tbw-selection-warning-bg, rgba(from var(--tbw-color-error) r g b / 50%))}}.tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}}";
5007
+ function Qi(s, e, t) {
5008
+ if (s === "cell" && e.selectedCell)
4895
5009
  return {
4896
- mode: a,
5010
+ mode: s,
4897
5011
  ranges: [
4898
5012
  {
4899
5013
  from: { row: e.selectedCell.row, col: e.selectedCell.col },
@@ -4901,14 +5015,14 @@ function Qi(a, e, t) {
4901
5015
  }
4902
5016
  ]
4903
5017
  };
4904
- if (a === "row" && e.selected.size > 0) {
5018
+ if (s === "row" && e.selected.size > 0) {
4905
5019
  const i = [...e.selected].map((n) => ({
4906
5020
  from: { row: n, col: 0 },
4907
5021
  to: { row: n, col: t - 1 }
4908
5022
  }));
4909
- return { mode: a, ranges: i };
5023
+ return { mode: s, ranges: i };
4910
5024
  }
4911
- return a === "range" && e.ranges.length > 0 ? { mode: a, ranges: lt(e.ranges) } : { mode: a, ranges: [] };
5025
+ return s === "range" && e.ranges.length > 0 ? { mode: s, ranges: lt(e.ranges) } : { mode: s, ranges: [] };
4912
5026
  }
4913
5027
  class _n extends _ {
4914
5028
  static manifest = {
@@ -4977,15 +5091,15 @@ class _n extends _ {
4977
5091
  const { rowIndex: t, colIndex: i, originalEvent: n } = e, { mode: r, triggerOn: o = "click" } = this.config;
4978
5092
  if (n.type !== o)
4979
5093
  return !1;
4980
- const s = this.columns[i], l = s && q(s);
5094
+ const a = this.columns[i], l = a && H(a);
4981
5095
  if (r === "cell") {
4982
5096
  if (l || !this.isCellSelectable(t, i))
4983
5097
  return !1;
4984
5098
  const d = this.selectedCell;
4985
- return d && d.row === t && d.col === i || (this.selectedCell = { row: t, col: i }, this.emit("selection-change", this.#t()), this.requestAfterRender()), !1;
5099
+ return d && d.row === t && d.col === i || (this.selectedCell = { row: t, col: i }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
4986
5100
  }
4987
5101
  if (r === "row")
4988
- return !this.isRowSelectable(t) || this.selected.size === 1 && this.selected.has(t) || (this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#t()), this.requestAfterRender()), !1;
5102
+ return !this.isRowSelectable(t) || this.selected.size === 1 && this.selected.has(t) || (this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
4989
5103
  if (r === "range") {
4990
5104
  if (l || !this.isCellSelectable(t, i))
4991
5105
  return !1;
@@ -5014,7 +5128,7 @@ class _n extends _ {
5014
5128
  return !1;
5015
5129
  this.ranges = [u], this.activeRange = u, this.cellAnchor = { row: t, col: i };
5016
5130
  }
5017
- return this.emit("selection-change", this.#t()), this.requestAfterRender(), !1;
5131
+ return this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
5018
5132
  }
5019
5133
  return !1;
5020
5134
  }
@@ -5022,16 +5136,16 @@ class _n extends _ {
5022
5136
  if (!this.isSelectionEnabled()) return !1;
5023
5137
  const { mode: t } = this.config, n = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
5024
5138
  if (e.key === "Escape")
5025
- return t === "cell" ? this.selectedCell = null : t === "row" ? (this.selected.clear(), this.anchor = null) : t === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
5139
+ return t === "cell" ? this.selectedCell = null : t === "row" ? (this.selected.clear(), this.anchor = null) : t === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
5026
5140
  if (t === "cell" && n)
5027
5141
  return queueMicrotask(() => {
5028
5142
  const r = this.grid._focusRow, o = this.grid._focusCol;
5029
- this.isCellSelectable(r, o) ? this.selectedCell = { row: r, col: o } : this.selectedCell = null, this.emit("selection-change", this.#t()), this.requestAfterRender();
5143
+ this.isCellSelectable(r, o) ? this.selectedCell = { row: r, col: o } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
5030
5144
  }), !1;
5031
5145
  if (t === "row" && (e.key === "ArrowUp" || e.key === "ArrowDown"))
5032
5146
  return queueMicrotask(() => {
5033
5147
  const r = this.grid._focusRow;
5034
- this.isRowSelectable(r) ? (this.selected.clear(), this.selected.add(r), this.lastSelected = r) : this.selected.clear(), this.emit("selection-change", this.#t()), this.requestAfterRender();
5148
+ this.isRowSelectable(r) ? (this.selected.clear(), this.selected.add(r), this.lastSelected = r) : this.selected.clear(), this.emit("selection-change", this.#e()), this.requestAfterRender();
5035
5149
  }), !1;
5036
5150
  if (t === "range" && n) {
5037
5151
  const r = e.key === "Tab", o = e.shiftKey && !r;
@@ -5041,13 +5155,13 @@ class _n extends _ {
5041
5155
  const r = this.rows.length, o = this.columns.length;
5042
5156
  if (r > 0 && o > 0) {
5043
5157
  e.preventDefault(), e.stopPropagation();
5044
- const s = {
5158
+ const a = {
5045
5159
  startRow: 0,
5046
5160
  startCol: 0,
5047
5161
  endRow: r - 1,
5048
5162
  endCol: o - 1
5049
5163
  };
5050
- return this.ranges = [s], this.activeRange = s, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
5164
+ return this.ranges = [a], this.activeRange = a, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
5051
5165
  }
5052
5166
  }
5053
5167
  return !1;
@@ -5055,7 +5169,7 @@ class _n extends _ {
5055
5169
  onCellMouseDown(e) {
5056
5170
  if (!this.isSelectionEnabled() || this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
5057
5171
  const t = this.columns[e.colIndex];
5058
- if (t && q(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
5172
+ if (t && H(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
5059
5173
  return;
5060
5174
  this.isDragging = !0;
5061
5175
  const i = e.rowIndex, n = e.colIndex, r = e.originalEvent.ctrlKey || e.originalEvent.metaKey, o = {
@@ -5064,24 +5178,24 @@ class _n extends _ {
5064
5178
  endRow: i,
5065
5179
  endCol: n
5066
5180
  };
5067
- return !r && this.ranges.length === 1 && Q(this.ranges[0], o) ? (this.cellAnchor = { row: i, col: n }, !0) : (this.cellAnchor = { row: i, col: n }, r || (this.ranges = []), this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0);
5181
+ return !r && this.ranges.length === 1 && Q(this.ranges[0], o) ? (this.cellAnchor = { row: i, col: n }, !0) : (this.cellAnchor = { row: i, col: n }, r || (this.ranges = []), this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0);
5068
5182
  }
5069
5183
  onCellMouseMove(e) {
5070
5184
  if (!this.isSelectionEnabled() || this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
5071
5185
  let t = e.colIndex;
5072
5186
  const i = this.columns[t];
5073
- if (i && q(i)) {
5074
- const o = this.columns.findIndex((s) => !q(s));
5187
+ if (i && H(i)) {
5188
+ const o = this.columns.findIndex((a) => !H(a));
5075
5189
  o >= 0 && (t = o);
5076
5190
  }
5077
5191
  const n = de(this.cellAnchor, { row: e.rowIndex, col: t }), r = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
5078
- return r && Q(r, n) || (this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = n : this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#t()), this.requestAfterRender()), !0;
5192
+ return r && Q(r, n) || (this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = n : this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#e()), this.requestAfterRender()), !0;
5079
5193
  }
5080
5194
  onCellMouseUp(e) {
5081
5195
  if (this.isSelectionEnabled() && this.config.mode === "range" && this.isDragging)
5082
5196
  return this.isDragging = !1, !0;
5083
5197
  }
5084
- #e() {
5198
+ #t() {
5085
5199
  const e = this.gridElement;
5086
5200
  if (!e) return;
5087
5201
  const { mode: t } = this.config, i = !!this.config.isSelectable;
@@ -5092,23 +5206,23 @@ class _n extends _ {
5092
5206
  if (r.forEach((o) => {
5093
5207
  o.classList.remove("selected", "row-focus"), i && o.removeAttribute("data-selectable");
5094
5208
  }), t === "row" && (xe(e), r.forEach((o) => {
5095
- const s = o.querySelector(".cell[data-row]"), l = pt(s);
5209
+ const a = o.querySelector(".cell[data-row]"), l = wt(a);
5096
5210
  l >= 0 && (i && !this.isRowSelectable(l) && o.setAttribute("data-selectable", "false"), this.selected.has(l) && o.classList.add("selected", "row-focus"));
5097
- })), (t === "cell" || t === "range") && i && e.querySelectorAll(".cell[data-row][data-col]").forEach((s) => {
5098
- const l = parseInt(s.getAttribute("data-row") ?? "-1", 10), d = parseInt(s.getAttribute("data-col") ?? "-1", 10);
5099
- l >= 0 && d >= 0 && (this.isCellSelectable(l, d) || s.setAttribute("data-selectable", "false"));
5211
+ })), (t === "cell" || t === "range") && i && e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
5212
+ const l = parseInt(a.getAttribute("data-row") ?? "-1", 10), d = parseInt(a.getAttribute("data-col") ?? "-1", 10);
5213
+ l >= 0 && d >= 0 && (this.isCellSelectable(l, d) || a.setAttribute("data-selectable", "false"));
5100
5214
  }), t === "range" && this.ranges.length > 0) {
5101
5215
  xe(e);
5102
- const o = this.activeRange ? V(this.activeRange) : null, s = this.columns.findIndex((d) => !q(d));
5216
+ const o = this.activeRange ? $(this.activeRange) : null, a = this.columns.findIndex((d) => !H(d));
5103
5217
  this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((d) => {
5104
5218
  const c = parseInt(d.getAttribute("data-row") ?? "-1", 10), u = parseInt(d.getAttribute("data-col") ?? "-1", 10);
5105
5219
  if (c >= 0 && u >= 0) {
5106
5220
  const h = this.columns[u];
5107
- if (h && q(h))
5221
+ if (h && H(h))
5108
5222
  return;
5109
5223
  if (je(c, u, this.ranges) && (d.classList.add("selected"), o)) {
5110
5224
  c === o.startRow && d.classList.add("top"), c === o.endRow && d.classList.add("bottom");
5111
- const g = Math.max(o.startCol, s);
5225
+ const g = Math.max(o.startCol, a);
5112
5226
  u === g && d.classList.add("first"), u === o.endCol && d.classList.add("last");
5113
5227
  }
5114
5228
  }
@@ -5125,20 +5239,20 @@ class _n extends _ {
5125
5239
  this.pendingKeyboardUpdate = null;
5126
5240
  const r = this.grid._focusRow, o = this.grid._focusCol;
5127
5241
  if (n && this.cellAnchor) {
5128
- const s = de(this.cellAnchor, { row: r, col: o });
5129
- this.ranges = [s], this.activeRange = s;
5242
+ const a = de(this.cellAnchor, { row: r, col: o });
5243
+ this.ranges = [a], this.activeRange = a;
5130
5244
  } else n || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: r, col: o });
5131
- this.emit("selection-change", this.#t());
5245
+ this.emit("selection-change", this.#e());
5132
5246
  }
5133
- this.grid.setAttribute("data-selection-mode", i), t && t.classList.toggle("selecting", this.isDragging), this.#e();
5247
+ this.grid.setAttribute("data-selection-mode", i), t && t.classList.toggle("selecting", this.isDragging), this.#t();
5134
5248
  }
5135
5249
  onScrollRender() {
5136
- this.isSelectionEnabled() && this.#e();
5250
+ this.isSelectionEnabled() && this.#t();
5137
5251
  }
5138
5252
  getSelection() {
5139
5253
  return {
5140
5254
  mode: this.config.mode,
5141
- ranges: this.#t().ranges,
5255
+ ranges: this.#e().ranges,
5142
5256
  anchor: this.cellAnchor
5143
5257
  };
5144
5258
  }
@@ -5162,7 +5276,7 @@ class _n extends _ {
5162
5276
  ranges: lt(this.ranges)
5163
5277
  }), this.requestAfterRender();
5164
5278
  }
5165
- #t() {
5279
+ #e() {
5166
5280
  return Qi(
5167
5281
  this.config.mode,
5168
5282
  {
@@ -5174,34 +5288,34 @@ class _n extends _ {
5174
5288
  );
5175
5289
  }
5176
5290
  }
5177
- function ee(a, e) {
5178
- return Math.floor(a / e);
5291
+ function ee(s, e) {
5292
+ return Math.floor(s / e);
5179
5293
  }
5180
- function Ji(a, e) {
5294
+ function Ji(s, e) {
5181
5295
  return {
5182
- start: a * e,
5183
- end: (a + 1) * e
5296
+ start: s * e,
5297
+ end: (s + 1) * e
5184
5298
  };
5185
5299
  }
5186
- function en(a, e, t) {
5187
- const i = ee(a, t), n = ee(e - 1, t), r = [];
5300
+ function en(s, e, t) {
5301
+ const i = ee(s, t), n = ee(e - 1, t), r = [];
5188
5302
  for (let o = i; o <= n; o++)
5189
5303
  r.push(o);
5190
5304
  return r;
5191
5305
  }
5192
- async function Ue(a, e, t, i) {
5306
+ async function Ue(s, e, t, i) {
5193
5307
  const n = Ji(e, t);
5194
- return a.getRows({
5308
+ return s.getRows({
5195
5309
  startRow: n.start,
5196
5310
  endRow: n.end,
5197
5311
  sortModel: i.sortModel,
5198
5312
  filterModel: i.filterModel
5199
5313
  });
5200
5314
  }
5201
- function tn(a, e, t) {
5202
- const i = ee(a, e), n = t.get(i);
5315
+ function tn(s, e, t) {
5316
+ const i = ee(s, e), n = t.get(i);
5203
5317
  if (!n) return;
5204
- const r = a % e;
5318
+ const r = s % e;
5205
5319
  return n[r];
5206
5320
  }
5207
5321
  const nn = 100;
@@ -5275,17 +5389,17 @@ class Tn extends _ {
5275
5389
  return this.loadedBlocks.size;
5276
5390
  }
5277
5391
  }
5278
- function dt(a, e, t) {
5279
- return a.id !== void 0 ? String(a.id) : t ? `${t}-${e}` : String(e);
5392
+ function dt(s, e, t) {
5393
+ return s.id !== void 0 ? String(s.id) : t ? `${t}-${e}` : String(e);
5280
5394
  }
5281
- function ce(a, e) {
5282
- const t = new Set(a);
5395
+ function ce(s, e) {
5396
+ const t = new Set(s);
5283
5397
  return t.has(e) ? t.delete(e) : t.add(e), t;
5284
5398
  }
5285
- function ge(a, e, t = null, i = 0) {
5399
+ function ge(s, e, t = null, i = 0) {
5286
5400
  const n = e.childrenField ?? "children", r = /* @__PURE__ */ new Set();
5287
- for (let o = 0; o < a.length; o++) {
5288
- const s = a[o], l = dt(s, o, t), d = s[n];
5401
+ for (let o = 0; o < s.length; o++) {
5402
+ const a = s[o], l = dt(a, o, t), d = a[n];
5289
5403
  if (Array.isArray(d) && d.length > 0) {
5290
5404
  r.add(l);
5291
5405
  const c = ge(d, e, l, i + 1);
@@ -5297,13 +5411,13 @@ function ge(a, e, t = null, i = 0) {
5297
5411
  function rn() {
5298
5412
  return /* @__PURE__ */ new Set();
5299
5413
  }
5300
- function ct(a, e, t, i = null, n = 0) {
5414
+ function ct(s, e, t, i = null, n = 0) {
5301
5415
  const r = t.childrenField ?? "children";
5302
- for (let o = 0; o < a.length; o++) {
5303
- const s = a[o], l = dt(s, o, i);
5416
+ for (let o = 0; o < s.length; o++) {
5417
+ const a = s[o], l = dt(a, o, i);
5304
5418
  if (l === e)
5305
5419
  return [l];
5306
- const d = s[r];
5420
+ const d = a[r];
5307
5421
  if (Array.isArray(d) && d.length > 0) {
5308
5422
  const c = ct(d, e, t, l, n + 1);
5309
5423
  if (c)
@@ -5312,17 +5426,17 @@ function ct(a, e, t, i = null, n = 0) {
5312
5426
  }
5313
5427
  return null;
5314
5428
  }
5315
- function on(a, e, t, i) {
5316
- const n = ct(a, e, t);
5429
+ function on(s, e, t, i) {
5430
+ const n = ct(s, e, t);
5317
5431
  if (!n) return i;
5318
5432
  const r = new Set(i);
5319
5433
  for (let o = 0; o < n.length - 1; o++)
5320
5434
  r.add(n[o]);
5321
5435
  return r;
5322
5436
  }
5323
- function Ye(a, e = "children") {
5324
- if (!Array.isArray(a) || a.length === 0) return !1;
5325
- for (const t of a) {
5437
+ function Ye(s, e = "children") {
5438
+ if (!Array.isArray(s) || s.length === 0) return !1;
5439
+ for (const t of s) {
5326
5440
  if (!t) continue;
5327
5441
  const i = t[e];
5328
5442
  if (Array.isArray(i) && i.length > 0)
@@ -5330,10 +5444,10 @@ function Ye(a, e = "children") {
5330
5444
  }
5331
5445
  return !1;
5332
5446
  }
5333
- function sn(a) {
5334
- if (!Array.isArray(a) || a.length === 0) return null;
5447
+ function sn(s) {
5448
+ if (!Array.isArray(s) || s.length === 0) return null;
5335
5449
  const e = ["children", "items", "nodes", "subRows", "nested"];
5336
- for (const t of a)
5450
+ for (const t of s)
5337
5451
  if (!(!t || typeof t != "object"))
5338
5452
  for (const i of e) {
5339
5453
  const n = t[i];
@@ -5415,11 +5529,11 @@ class Ln extends _ {
5415
5529
  withStableKeys(e, t = null) {
5416
5530
  const i = this.config.childrenField ?? "children";
5417
5531
  return e.map((n, r) => {
5418
- const o = n.__stableKey, s = n.id !== void 0 ? String(n.id) : o ?? (t ? `${t}-${r}` : String(r)), l = n[i], d = Array.isArray(l) && l.length > 0;
5532
+ const o = n.__stableKey, a = n.id !== void 0 ? String(n.id) : o ?? (t ? `${t}-${r}` : String(r)), l = n[i], d = Array.isArray(l) && l.length > 0;
5419
5533
  return {
5420
5534
  ...n,
5421
- __stableKey: s,
5422
- ...d ? { [i]: this.withStableKeys(l, s) } : {}
5535
+ __stableKey: a,
5536
+ ...d ? { [i]: this.withStableKeys(l, a) } : {}
5423
5537
  };
5424
5538
  });
5425
5539
  }
@@ -5440,32 +5554,32 @@ class Ln extends _ {
5440
5554
  }
5441
5555
  sortTree(e, t, i) {
5442
5556
  const n = this.config.childrenField ?? "children";
5443
- return [...e].sort((o, s) => {
5444
- const l = o[t], d = s[t];
5557
+ return [...e].sort((o, a) => {
5558
+ const l = o[t], d = a[t];
5445
5559
  return l == null && d == null ? 0 : l == null ? -1 : d == null ? 1 : l > d ? i : l < d ? -i : 0;
5446
5560
  }).map((o) => {
5447
- const s = o[n];
5448
- return Array.isArray(s) && s.length > 0 ? { ...o, [n]: this.sortTree(s, t, i) } : o;
5561
+ const a = o[n];
5562
+ return Array.isArray(a) && a.length > 0 ? { ...o, [n]: this.sortTree(a, t, i) } : o;
5449
5563
  });
5450
5564
  }
5451
5565
  processColumns(e) {
5452
5566
  if (this.flattenedRows.length === 0) return [...e];
5453
5567
  const t = [...e];
5454
5568
  if (t.length === 0) return t;
5455
- const i = t[0], n = i.viewRenderer, r = () => this.config, o = this.setIcon.bind(this), s = this.resolveIcon.bind(this), l = (d) => {
5569
+ const i = t[0], n = i.viewRenderer, r = () => this.config, o = this.setIcon.bind(this), a = this.resolveIcon.bind(this), l = (d) => {
5456
5570
  const { row: c, value: u } = d, { showExpandIcons: h = !0, indentWidth: f } = r(), g = c, p = g.__treeDepth ?? 0, w = document.createElement("span");
5457
5571
  if (w.className = "tree-cell-wrapper", w.style.setProperty("--tbw-tree-depth", String(p)), f !== void 0 && w.style.setProperty("--tbw-tree-indent-width", `${f}px`), h)
5458
5572
  if (g.__treeHasChildren) {
5459
- const v = document.createElement("span");
5460
- v.className = `tree-toggle${g.__treeExpanded ? " expanded" : ""}`, o(v, s(g.__treeExpanded ? "collapse" : "expand")), v.setAttribute("data-tree-key", String(g.__treeKey ?? "")), w.appendChild(v);
5573
+ const y = document.createElement("span");
5574
+ y.className = `tree-toggle${g.__treeExpanded ? " expanded" : ""}`, o(y, a(g.__treeExpanded ? "collapse" : "expand")), y.setAttribute("data-tree-key", String(g.__treeKey ?? "")), w.appendChild(y);
5461
5575
  } else {
5462
- const v = document.createElement("span");
5463
- v.className = "tree-spacer", w.appendChild(v);
5576
+ const y = document.createElement("span");
5577
+ y.className = "tree-spacer", w.appendChild(y);
5464
5578
  }
5465
5579
  const b = document.createElement("span");
5466
5580
  if (b.className = "tree-content", n) {
5467
- const v = n(d);
5468
- v instanceof Node ? b.appendChild(v) : typeof v == "string" && (b.innerHTML = v);
5581
+ const y = n(d);
5582
+ y instanceof Node ? b.appendChild(y) : typeof y == "string" && (b.innerHTML = y);
5469
5583
  } else
5470
5584
  b.textContent = u != null ? String(u) : "";
5471
5585
  return w.appendChild(b), w;
@@ -5510,8 +5624,8 @@ class Ln extends _ {
5510
5624
  if (!t) return;
5511
5625
  const i = e === "fade" ? "tbw-tree-fade-in" : "tbw-tree-slide-in";
5512
5626
  for (const n of t.querySelectorAll(".data-grid-row")) {
5513
- const r = n.querySelector(".cell[data-row]"), o = r ? parseInt(r.getAttribute("data-row") ?? "-1", 10) : -1, s = this.flattenedRows[o]?.key;
5514
- s && this.keysToAnimate.has(s) && (n.classList.add(i), n.addEventListener("animationend", () => n.classList.remove(i), { once: !0 }));
5627
+ const r = n.querySelector(".cell[data-row]"), o = r ? parseInt(r.getAttribute("data-row") ?? "-1", 10) : -1, a = this.flattenedRows[o]?.key;
5628
+ a && this.keysToAnimate.has(a) && (n.classList.add(i), n.addEventListener("animationend", () => n.classList.remove(i), { once: !0 }));
5515
5629
  }
5516
5630
  this.keysToAnimate.clear();
5517
5631
  }
@@ -5546,8 +5660,8 @@ class Ln extends _ {
5546
5660
  this.expandedKeys = on(this.rows, e, this.config, this.expandedKeys), this.requestRender();
5547
5661
  }
5548
5662
  }
5549
- function ln(a, e, t) {
5550
- const i = [...a.undoStack, e];
5663
+ function ln(s, e, t) {
5664
+ const i = [...s.undoStack, e];
5551
5665
  for (; i.length > t; )
5552
5666
  i.shift();
5553
5667
  return {
@@ -5555,43 +5669,43 @@ function ln(a, e, t) {
5555
5669
  redoStack: []
5556
5670
  };
5557
5671
  }
5558
- function Xe(a) {
5559
- if (a.undoStack.length === 0)
5560
- return { newState: a, action: null };
5561
- const e = [...a.undoStack], t = e.pop();
5672
+ function Xe(s) {
5673
+ if (s.undoStack.length === 0)
5674
+ return { newState: s, action: null };
5675
+ const e = [...s.undoStack], t = e.pop();
5562
5676
  return t ? {
5563
5677
  newState: {
5564
5678
  undoStack: e,
5565
- redoStack: [...a.redoStack, t]
5679
+ redoStack: [...s.redoStack, t]
5566
5680
  },
5567
5681
  action: t
5568
- } : { newState: a, action: null };
5682
+ } : { newState: s, action: null };
5569
5683
  }
5570
- function Ze(a) {
5571
- if (a.redoStack.length === 0)
5572
- return { newState: a, action: null };
5573
- const e = [...a.redoStack], t = e.pop();
5684
+ function Ze(s) {
5685
+ if (s.redoStack.length === 0)
5686
+ return { newState: s, action: null };
5687
+ const e = [...s.redoStack], t = e.pop();
5574
5688
  return t ? {
5575
5689
  newState: {
5576
- undoStack: [...a.undoStack, t],
5690
+ undoStack: [...s.undoStack, t],
5577
5691
  redoStack: e
5578
5692
  },
5579
5693
  action: t
5580
- } : { newState: a, action: null };
5694
+ } : { newState: s, action: null };
5581
5695
  }
5582
- function dn(a) {
5583
- return a.undoStack.length > 0;
5696
+ function dn(s) {
5697
+ return s.undoStack.length > 0;
5584
5698
  }
5585
- function cn(a) {
5586
- return a.redoStack.length > 0;
5699
+ function cn(s) {
5700
+ return s.redoStack.length > 0;
5587
5701
  }
5588
5702
  function un() {
5589
5703
  return { undoStack: [], redoStack: [] };
5590
5704
  }
5591
- function hn(a, e, t, i) {
5705
+ function hn(s, e, t, i) {
5592
5706
  return {
5593
5707
  type: "cell-edit",
5594
- rowIndex: a,
5708
+ rowIndex: s,
5595
5709
  field: e,
5596
5710
  oldValue: t,
5597
5711
  newValue: i,
@@ -5689,11 +5803,11 @@ class In extends _ {
5689
5803
  }
5690
5804
  }
5691
5805
  const fn = '@layer tbw-plugins{.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem))}.tbw-visibility-row{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-menu-item-padding, .375rem .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);border-radius:var(--tbw-border-radius, .25rem);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted);font-size:var(--tbw-font-size-2xs, .625rem);letter-spacing:-2px;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg)}.tbw-visibility-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-visibility-indicator, var(--tbw-color-accent))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-visibility-indicator, var(--tbw-color-accent))}.tbw-visibility-show-all{margin:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding, .5rem .75rem);border:1px solid var(--tbw-visibility-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius, .25rem);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg));color:var(--tbw-color-fg);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover))}}';
5692
- function Qe(a) {
5693
- const e = a.meta ?? {};
5806
+ function Qe(s) {
5807
+ const e = s.meta ?? {};
5694
5808
  return e.lockPosition !== !0 && e.suppressMovable !== !0;
5695
5809
  }
5696
- class B extends _ {
5810
+ class V extends _ {
5697
5811
  static dependencies = [
5698
5812
  { name: "reorder", required: !1, reason: "Enables drag-to-reorder columns in visibility panel" }
5699
5813
  ];
@@ -5720,7 +5834,7 @@ class B extends _ {
5720
5834
  }
5721
5835
  getToolPanel() {
5722
5836
  return {
5723
- id: B.PANEL_ID,
5837
+ id: V.PANEL_ID,
5724
5838
  title: "Columns",
5725
5839
  icon: "☰",
5726
5840
  tooltip: "Column visibility",
@@ -5729,13 +5843,13 @@ class B extends _ {
5729
5843
  };
5730
5844
  }
5731
5845
  show() {
5732
- this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(B.PANEL_ID) || this.grid.toggleToolPanelSection(B.PANEL_ID);
5846
+ this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(V.PANEL_ID) || this.grid.toggleToolPanelSection(V.PANEL_ID);
5733
5847
  }
5734
5848
  hide() {
5735
5849
  this.grid.closeToolPanel();
5736
5850
  }
5737
5851
  toggle() {
5738
- this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(B.PANEL_ID);
5852
+ this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(V.PANEL_ID);
5739
5853
  }
5740
5854
  isColumnVisible(e) {
5741
5855
  return this.grid.isColumnVisible(e);
@@ -5765,7 +5879,7 @@ class B extends _ {
5765
5879
  return this.grid.getAllColumns();
5766
5880
  }
5767
5881
  isPanelVisible() {
5768
- return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(B.PANEL_ID);
5882
+ return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(V.PANEL_ID);
5769
5883
  }
5770
5884
  renderPanelContent(e) {
5771
5885
  const t = document.createElement("div");
@@ -5788,8 +5902,8 @@ class B extends _ {
5788
5902
  e.innerHTML = "";
5789
5903
  const i = this.grid.getAllColumns().filter((n) => !n.utility);
5790
5904
  for (let n = 0; n < i.length; n++) {
5791
- const r = i[n], o = r.header || r.field, s = document.createElement("div");
5792
- s.className = r.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", s.setAttribute("data-field", r.field), s.setAttribute("data-index", String(n)), t && Qe(r) && (s.draggable = !0, s.classList.add("reorderable"), this.setupDragListeners(s, r.field, n, e));
5905
+ const r = i[n], o = r.header || r.field, a = document.createElement("div");
5906
+ a.className = r.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", r.field), a.setAttribute("data-index", String(n)), t && Qe(r) && (a.draggable = !0, a.classList.add("reorderable"), this.setupDragListeners(a, r.field, n, e));
5793
5907
  const l = document.createElement("label");
5794
5908
  l.className = "tbw-visibility-label";
5795
5909
  const d = document.createElement("input");
@@ -5799,9 +5913,9 @@ class B extends _ {
5799
5913
  const c = document.createElement("span");
5800
5914
  if (c.textContent = o, l.appendChild(d), l.appendChild(c), t && Qe(r)) {
5801
5915
  const u = document.createElement("span");
5802
- u.className = "tbw-visibility-handle", this.setIcon(u, this.resolveIcon("dragHandle")), u.title = "Drag to reorder", s.appendChild(u);
5916
+ u.className = "tbw-visibility-handle", this.setIcon(u, this.resolveIcon("dragHandle")), u.title = "Drag to reorder", a.appendChild(u);
5803
5917
  }
5804
- s.appendChild(l), e.appendChild(s);
5918
+ a.appendChild(l), e.appendChild(a);
5805
5919
  }
5806
5920
  }
5807
5921
  setupDragListeners(e, t, i, n) {
@@ -5811,22 +5925,22 @@ class B extends _ {
5811
5925
  this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses(n);
5812
5926
  }), e.addEventListener("dragover", (r) => {
5813
5927
  if (r.preventDefault(), !this.isDragging || this.draggedField === t) return;
5814
- const o = e.getBoundingClientRect(), s = o.top + o.height / 2;
5815
- this.dropIndex = r.clientY < s ? i : i + 1, n.querySelectorAll(".tbw-visibility-row").forEach((l) => {
5928
+ const o = e.getBoundingClientRect(), a = o.top + o.height / 2;
5929
+ this.dropIndex = r.clientY < a ? i : i + 1, n.querySelectorAll(".tbw-visibility-row").forEach((l) => {
5816
5930
  l !== e && l.classList.remove("drop-target", "drop-before", "drop-after");
5817
- }), e.classList.add("drop-target"), e.classList.toggle("drop-before", r.clientY < s), e.classList.toggle("drop-after", r.clientY >= s);
5931
+ }), e.classList.add("drop-target"), e.classList.toggle("drop-before", r.clientY < a), e.classList.toggle("drop-after", r.clientY >= a);
5818
5932
  }), e.addEventListener("dragleave", () => {
5819
5933
  e.classList.remove("drop-target", "drop-before", "drop-after");
5820
5934
  }), e.addEventListener("drop", (r) => {
5821
5935
  r.preventDefault();
5822
- const o = this.draggedField, s = this.draggedIndex, l = this.dropIndex;
5823
- if (!this.isDragging || o === null || s === null || l === null)
5936
+ const o = this.draggedField, a = this.draggedIndex, l = this.dropIndex;
5937
+ if (!this.isDragging || o === null || a === null || l === null)
5824
5938
  return;
5825
- const d = l > s ? l - 1 : l;
5826
- if (d !== s) {
5939
+ const d = l > a ? l - 1 : l;
5940
+ if (d !== a) {
5827
5941
  const c = this.grid.getAllColumns(), h = c.filter((p) => !p.utility)[d]?.field, f = h ? c.findIndex((p) => p.field === h) : c.length, g = {
5828
5942
  field: o,
5829
- fromIndex: s,
5943
+ fromIndex: a,
5830
5944
  toIndex: f
5831
5945
  };
5832
5946
  this.emit("column-reorder-request", g), setTimeout(() => {
@@ -5847,7 +5961,7 @@ export {
5847
5961
  Nn as DataGridElement,
5848
5962
  wn as EditingPlugin,
5849
5963
  bn as ExportPlugin,
5850
- N as FilteringPlugin,
5964
+ q as FilteringPlugin,
5851
5965
  qn as FitModeEnum,
5852
5966
  Hn as GridCSSVars,
5853
5967
  Kn as GridClasses,
@@ -5861,7 +5975,7 @@ export {
5861
5975
  Bn as PLUGIN_QUERIES,
5862
5976
  Cn as PinnedColumnsPlugin,
5863
5977
  En as PinnedRowsPlugin,
5864
- G as PivotPlugin,
5978
+ B as PivotPlugin,
5865
5979
  Vn as PluginEvents,
5866
5980
  Wn as PluginManager,
5867
5981
  Rn as PrintPlugin,
@@ -5874,12 +5988,12 @@ export {
5874
5988
  Tn as ServerSidePlugin,
5875
5989
  Ln as TreePlugin,
5876
5990
  In as UndoRedoPlugin,
5877
- B as VisibilityPlugin,
5991
+ V as VisibilityPlugin,
5878
5992
  jn as builtInSort,
5879
5993
  Un as createGrid,
5880
5994
  Yn as defaultComparator,
5881
- Ft as defaultEditorFor,
5882
- yt as defaultPasteHandler,
5995
+ Dt as defaultEditorFor,
5996
+ Ct as defaultPasteHandler,
5883
5997
  Ki as printGridIsolated,
5884
5998
  Xn as queryGrid
5885
5999
  };