@affino/datagrid-vue-app 0.1.45 → 0.1.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4858 @@
1
+ import { defineComponent as Pn, h as T, inject as Mr, ref as U, computed as g, watch as te, nextTick as dt, openBlock as $t, createElementBlock as On, Fragment as Jl, createElementVNode as ae, mergeProps as Xl, unref as f, toDisplayString as it, createBlock as xr, Teleport as Fr, renderList as Ar, normalizeClass as Dr, createCommentVNode as Or, onMounted as _r, onBeforeUnmount as Zl, shallowRef as Tl, defineAsyncComponent as $l, markRaw as kr, toRaw as Er, onUnmounted as Pr } from "vue";
2
+ import { resolveDataGridCellClickAction as Tr, invokeDataGridCellInteraction as zr, toggleDataGridCellValue as Hr, buildDataGridCellRenderModel as Vr, buildDataGridAdvancedFilterExpressionFromLegacyFilters as Br, useDataGridContextMenu as jr, cloneDataGridFilterSnapshot as Gr, createClientRowModel as Al } from "@affino/datagrid-vue";
3
+ import { useDataGridAppIntentHistory as Lr, createDataGridAppRowHeightMetrics as $r, useDataGridAppViewport as Kr, useDataGridAppRowSizing as Nr, useDataGridAppCellSelection as Wr, useDataGridAppRowPresentation as Ur, useDataGridAppClipboard as qr, useDataGridAppActiveCellViewport as Yr, useDataGridAppInlineEditing as Jr, useDataGridAppInteractionController as Xr, useDataGridAppHeaderResize as Zr, useDataGridAppRuntimeSync as Qr, useDataGridAppViewportLifecycle as eo, useDataGridAppColumnLayoutPanel as to } from "@affino/datagrid-vue/app";
4
+ import { useDataGridViewportContextMenuRouter as no, useDataGridContextMenuAnchor as lo, useDataGridContextMenuActionRouter as ro } from "@affino/datagrid-vue/advanced";
5
+ import { c as oo, q as ao, D as Ql, a as er, s as io } from "./DataGridGanttStageEntry-DNXWCKVs.js";
6
+ import { usePopoverController as so, useFloatingPopover as uo } from "@affino/popover-vue";
7
+ import { d as co, r as mo } from "./dataGridOverlayThemeVars-vzY74EIz.js";
8
+ import { u as fo } from "./useDataGridDraggableOverlaySurface-BgkSR_nl.js";
9
+ import { a as wo } from "./dataGridAdvancedFilter-xnME5bRa.js";
10
+ const tr = Pn({
11
+ name: "DataGridModuleHost",
12
+ props: {
13
+ modules: {
14
+ type: Array,
15
+ default: () => []
16
+ },
17
+ variant: {
18
+ type: String,
19
+ default: "standalone"
20
+ }
21
+ },
22
+ setup(e) {
23
+ return () => e.modules.length === 0 ? null : T("div", {
24
+ class: [
25
+ "datagrid-app-toolbar",
26
+ e.variant === "integrated" ? "datagrid-app-toolbar--integrated" : null
27
+ ]
28
+ }, [
29
+ T("div", { class: "datagrid-app-toolbar__group" }, e.modules.map((l) => T(l.component, {
30
+ key: l.key,
31
+ ...l.props ?? {}
32
+ })))
33
+ ]);
34
+ }
35
+ }), nr = Pn({
36
+ name: "DataGridHistoryToolbarButton",
37
+ props: {
38
+ action: {
39
+ type: String,
40
+ required: !0
41
+ },
42
+ label: {
43
+ type: String,
44
+ required: !0
45
+ },
46
+ disabled: {
47
+ type: Boolean,
48
+ default: !1
49
+ },
50
+ onTrigger: {
51
+ type: Function,
52
+ required: !0
53
+ }
54
+ },
55
+ setup(e) {
56
+ return () => T("button", {
57
+ type: "button",
58
+ class: "datagrid-app-toolbar__button",
59
+ "data-datagrid-toolbar-action": e.action,
60
+ disabled: e.disabled,
61
+ onClick: () => {
62
+ e.onTrigger();
63
+ }
64
+ }, e.label);
65
+ }
66
+ }), vr = "Columns", Be = Object.freeze({
67
+ buttonLabel: vr,
68
+ eyebrow: "Column layout",
69
+ title: "Order and visibility",
70
+ close: "Close",
71
+ cancel: "Cancel",
72
+ apply: "Apply",
73
+ moveUp: "Move up",
74
+ moveDown: "Move down"
75
+ });
76
+ function Ve(e, l) {
77
+ return typeof e == "string" && e.trim().length > 0 ? e.trim() : l;
78
+ }
79
+ function Dl(e, l) {
80
+ const a = Ve(l, Ve(e?.buttonLabel, vr));
81
+ return Object.freeze({
82
+ buttonLabel: a,
83
+ eyebrow: Ve(e?.eyebrow, Be.eyebrow),
84
+ title: Ve(e?.title, Be.title),
85
+ close: Ve(e?.close, Be.close),
86
+ cancel: Ve(e?.cancel, Be.cancel),
87
+ apply: Ve(e?.apply, Be.apply),
88
+ moveUp: Ve(e?.moveUp, Be.moveUp),
89
+ moveDown: Ve(e?.moveDown, Be.moveDown)
90
+ });
91
+ }
92
+ function ti(e) {
93
+ if (typeof e == "boolean") {
94
+ const a = Dl(void 0);
95
+ return {
96
+ enabled: e,
97
+ buttonLabel: a.buttonLabel,
98
+ labels: a
99
+ };
100
+ }
101
+ if (!e) {
102
+ const a = Dl(void 0);
103
+ return {
104
+ enabled: !1,
105
+ buttonLabel: a.buttonLabel,
106
+ labels: a
107
+ };
108
+ }
109
+ const l = Dl(e.labels, e.buttonLabel);
110
+ return {
111
+ enabled: e.enabled ?? !0,
112
+ buttonLabel: l.buttonLabel,
113
+ labels: l
114
+ };
115
+ }
116
+ const go = ["data-datagrid-overlay-dragging"], vo = { class: "datagrid-column-layout__header" }, ho = { class: "datagrid-column-layout__eyebrow" }, bo = { class: "datagrid-column-layout__title" }, yo = { class: "datagrid-column-layout__list" }, Ro = ["onDragstart", "onDragover", "onDrop"], Co = { class: "datagrid-column-layout__visibility" }, po = /* @__PURE__ */ ae("span", {
117
+ class: "datagrid-column-layout__drag-handle",
118
+ "aria-hidden": "true"
119
+ }, "::", -1), So = ["name", "checked", "onChange"], Io = { class: "datagrid-column-layout__label" }, Mo = { class: "datagrid-column-layout__move-actions" }, xo = ["disabled", "aria-label", "title", "onClick"], Fo = ["disabled", "aria-label", "title", "onClick"], Ao = { class: "datagrid-column-layout__footer" }, Do = /* @__PURE__ */ Pn({
120
+ __name: "DataGridColumnLayoutPopover",
121
+ props: {
122
+ isOpen: { type: Boolean },
123
+ items: {},
124
+ buttonLabel: {},
125
+ labels: { default: () => Be },
126
+ active: { type: Boolean, default: !1 }
127
+ },
128
+ emits: ["open", "toggle-visibility", "move-up", "move-down", "move-to-position", "apply", "cancel"],
129
+ setup(e, { emit: l }) {
130
+ const a = e, r = l, i = Mr(co, U(null)), d = U({}), w = so(
131
+ {
132
+ id: "column-layout",
133
+ role: "dialog",
134
+ closeOnEscape: !0,
135
+ closeOnInteractOutside: !0
136
+ },
137
+ {
138
+ onOpen: () => {
139
+ a.isOpen || r("open"), ne();
140
+ },
141
+ onClose: () => {
142
+ a.isOpen && r("cancel");
143
+ }
144
+ }
145
+ ), b = uo(w, {
146
+ placement: "bottom",
147
+ align: "start",
148
+ gutter: 10,
149
+ viewportPadding: 12,
150
+ zIndex: 180,
151
+ lockScroll: !1,
152
+ returnFocus: !0
153
+ }), h = fo({
154
+ surfaceId: "column-layout",
155
+ rootElementRef: i,
156
+ floating: b
157
+ }), E = g(() => w.getTriggerProps({ role: "dialog" })), O = g(() => w.getContentProps({ role: "dialog", tabIndex: -1 })), L = g(() => w.state.value.open), I = g(() => b.teleportTarget.value), C = g(() => a.labels ?? Be), F = g(() => typeof a.buttonLabel == "string" && a.buttonLabel.trim().length > 0 ? a.buttonLabel.trim() : C.value.buttonLabel), A = U(null), y = U(null), x = U(null);
158
+ te(
159
+ () => a.isOpen,
160
+ async (z) => {
161
+ if (z) {
162
+ ne(), w.state.value.open || w.open("programmatic"), await dt(), b.contentRef.value?.querySelector('input[type="checkbox"]')?.focus({ preventScroll: !0 }), await b.updatePosition();
163
+ return;
164
+ }
165
+ w.state.value.open && w.close("programmatic");
166
+ },
167
+ { immediate: !0 }
168
+ ), te(i, () => {
169
+ w.state.value.open && ne();
170
+ }), te(
171
+ () => a.items.length,
172
+ async () => {
173
+ w.state.value.open && (await dt(), await b.updatePosition());
174
+ }
175
+ );
176
+ function ne() {
177
+ d.value = mo(i.value);
178
+ }
179
+ function de(z, V) {
180
+ r("toggle-visibility", { key: z, visible: V });
181
+ }
182
+ function H(z) {
183
+ const _ = (z.currentTarget instanceof HTMLElement ? z.currentTarget : null)?.getBoundingClientRect();
184
+ return !_ || _.height <= 0 ? "after" : z.clientY < _.top + _.height / 2 ? "before" : "after";
185
+ }
186
+ function Re(z, V) {
187
+ A.value = V, y.value = null, x.value = null, z.dataTransfer && (z.dataTransfer.effectAllowed = "move", z.dataTransfer.setData("text/plain", V));
188
+ }
189
+ function $e(z, V) {
190
+ if (!A.value || A.value === V) {
191
+ y.value = null, x.value = null;
192
+ return;
193
+ }
194
+ z.preventDefault(), z.dataTransfer && (z.dataTransfer.dropEffect = "move"), y.value = V, x.value = H(z);
195
+ }
196
+ function Ct(z, V) {
197
+ if (!A.value || A.value === V) {
198
+ Je();
199
+ return;
200
+ }
201
+ z.preventDefault(), r("move-to-position", {
202
+ key: A.value,
203
+ targetKey: V,
204
+ placement: H(z)
205
+ }), Je();
206
+ }
207
+ function Je() {
208
+ A.value = null, y.value = null, x.value = null;
209
+ }
210
+ return (z, V) => ($t(), On(Jl, null, [
211
+ ae("button", Xl({
212
+ ref: f(b).triggerRef,
213
+ type: "button",
214
+ class: ["datagrid-app-toolbar__button", { "datagrid-app-toolbar__button--active": z.active }],
215
+ "data-datagrid-toolbar-action": "column-layout",
216
+ style: d.value
217
+ }, E.value), it(F.value), 17),
218
+ ($t(), xr(Fr, { to: I.value }, [
219
+ L.value ? ($t(), On("section", Xl({
220
+ key: 0,
221
+ ref: f(b).contentRef,
222
+ class: "datagrid-column-layout",
223
+ "data-datagrid-overlay-surface": "true",
224
+ "data-datagrid-overlay-surface-id": "column-layout",
225
+ "data-datagrid-overlay-dragging": f(h).dragging.value ? "true" : "false",
226
+ style: [f(h).surfaceStyle.value, d.value]
227
+ }, O.value), [
228
+ ae("header", vo, [
229
+ ae("div", {
230
+ class: "datagrid-overlay-drag-handle",
231
+ "data-datagrid-overlay-drag-handle": "true",
232
+ onPointerdown: V[0] || (V[0] = //@ts-ignore
233
+ (..._) => f(h).handlePointerDown && f(h).handlePointerDown(..._))
234
+ }, [
235
+ ae("div", ho, it(C.value.eyebrow), 1),
236
+ ae("h3", bo, it(C.value.title), 1)
237
+ ], 32),
238
+ ae("button", {
239
+ type: "button",
240
+ class: "datagrid-column-layout__ghost",
241
+ onClick: V[1] || (V[1] = (_) => r("cancel"))
242
+ }, it(C.value.close), 1)
243
+ ]),
244
+ ae("div", yo, [
245
+ ($t(!0), On(Jl, null, Ar(z.items, (_) => ($t(), On("div", {
246
+ key: _.key,
247
+ class: Dr(["datagrid-column-layout__row", {
248
+ "datagrid-column-layout__row--drag-source": A.value === _.key,
249
+ "datagrid-column-layout__row--drop-before": y.value === _.key && x.value === "before",
250
+ "datagrid-column-layout__row--drop-after": y.value === _.key && x.value === "after"
251
+ }]),
252
+ draggable: !0,
253
+ onDragstart: (oe) => Re(oe, _.key),
254
+ onDragover: (oe) => $e(oe, _.key),
255
+ onDrop: (oe) => Ct(oe, _.key),
256
+ onDragend: Je
257
+ }, [
258
+ ae("label", Co, [
259
+ po,
260
+ ae("input", {
261
+ name: `datagrid-column-layout-visible-${_.key}`,
262
+ type: "checkbox",
263
+ checked: _.visible,
264
+ onChange: (oe) => de(_.key, oe.target.checked)
265
+ }, null, 40, So),
266
+ ae("span", Io, it(_.label), 1)
267
+ ]),
268
+ ae("div", Mo, [
269
+ ae("button", {
270
+ type: "button",
271
+ class: "datagrid-column-layout__icon-button",
272
+ disabled: !_.canMoveUp,
273
+ "aria-label": `${C.value.moveUp}: ${_.label}`,
274
+ title: `${C.value.moveUp}: ${_.label}`,
275
+ onClick: (oe) => r("move-up", _.key)
276
+ }, " ↑ ", 8, xo),
277
+ ae("button", {
278
+ type: "button",
279
+ class: "datagrid-column-layout__icon-button",
280
+ disabled: !_.canMoveDown,
281
+ "aria-label": `${C.value.moveDown}: ${_.label}`,
282
+ title: `${C.value.moveDown}: ${_.label}`,
283
+ onClick: (oe) => r("move-down", _.key)
284
+ }, " ↓ ", 8, Fo)
285
+ ])
286
+ ], 42, Ro))), 128))
287
+ ]),
288
+ ae("footer", Ao, [
289
+ ae("button", {
290
+ type: "button",
291
+ class: "datagrid-column-layout__secondary",
292
+ onClick: V[2] || (V[2] = (_) => r("cancel"))
293
+ }, it(C.value.cancel), 1),
294
+ ae("button", {
295
+ type: "button",
296
+ class: "datagrid-column-layout__primary",
297
+ onClick: V[3] || (V[3] = (_) => r("apply"))
298
+ }, it(C.value.apply), 1)
299
+ ])
300
+ ], 16, go)) : Or("", !0)
301
+ ], 8, ["to"]))
302
+ ], 64));
303
+ }
304
+ }), je = ["sort", "group", "pin", "filter"], Oo = ["button", "contextmenu", "button+contextmenu"], hr = [
305
+ "sortAsc",
306
+ "sortDesc",
307
+ "clearSort",
308
+ "toggleGroup",
309
+ "pinMenu",
310
+ "pinLeft",
311
+ "pinRight",
312
+ "unpin",
313
+ "clearFilter",
314
+ "addCurrentSelectionToFilter",
315
+ "selectAllValues",
316
+ "clearAllValues",
317
+ "applyFilter",
318
+ "cancelFilter"
319
+ ], Ol = 120, zl = "button+contextmenu";
320
+ function Kl(e) {
321
+ const l = new Set(je), a = Array.isArray(e) ? e : je, r = [];
322
+ for (const i of a)
323
+ !l.has(i) || r.includes(i) || r.push(i);
324
+ return r.length > 0 ? r : [...je];
325
+ }
326
+ function Hl(e) {
327
+ if (!Array.isArray(e))
328
+ return [];
329
+ const l = new Set(je), a = [];
330
+ for (const r of e)
331
+ !l.has(r) || a.includes(r) || a.push(r);
332
+ return a;
333
+ }
334
+ function br(e) {
335
+ if (!e)
336
+ return Object.freeze({});
337
+ const l = Object.entries(e).filter(([a, r]) => je.includes(a) && typeof r == "string").map(([a, r]) => [a, r.trim()]).filter(([, a]) => a.length > 0);
338
+ return Object.freeze(Object.fromEntries(l));
339
+ }
340
+ function yr(e) {
341
+ if (!e)
342
+ return Object.freeze({});
343
+ const l = Object.entries(e).filter(([a, r]) => je.includes(a) && typeof r == "string").map(([a, r]) => [a, r.trim()]).filter(([, a]) => a.length > 0);
344
+ return Object.freeze(Object.fromEntries(l));
345
+ }
346
+ function _o(e) {
347
+ return Oo.includes(e) ? e : zl;
348
+ }
349
+ function ko(e) {
350
+ if (e === "start" || e === "end")
351
+ return !0;
352
+ if (!e.includes(":"))
353
+ return !1;
354
+ const [l, a] = e.split(":");
355
+ return (l === "before" || l === "after") && je.includes(a);
356
+ }
357
+ function Nl(e) {
358
+ if (!Array.isArray(e))
359
+ return Object.freeze([]);
360
+ const l = [], a = /* @__PURE__ */ new Set();
361
+ for (const r of e) {
362
+ const i = typeof r?.key == "string" ? r.key.trim() : "", d = typeof r?.label == "string" ? r.label.trim() : "";
363
+ if (i.length === 0 || d.length === 0 || a.has(i))
364
+ continue;
365
+ a.add(i);
366
+ const w = typeof r.placement == "string" && ko(r.placement) ? r.placement : void 0, b = {
367
+ key: i,
368
+ label: d,
369
+ ...w ? { placement: w } : {},
370
+ ...r.hidden === !0 ? { hidden: !0 } : {},
371
+ ...r.disabled === !0 ? { disabled: !0 } : {},
372
+ ...typeof r.disabledReason == "string" && r.disabledReason.trim().length > 0 ? { disabledReason: r.disabledReason.trim() } : {}
373
+ };
374
+ if (r.kind === "submenu") {
375
+ const h = Nl(r.items);
376
+ if (h.length === 0)
377
+ continue;
378
+ l.push(Object.freeze({
379
+ ...b,
380
+ kind: "submenu",
381
+ items: h
382
+ }));
383
+ continue;
384
+ }
385
+ l.push(Object.freeze({
386
+ ...b,
387
+ ...typeof r.onSelect == "function" ? { onSelect: r.onSelect } : {}
388
+ }));
389
+ }
390
+ return Object.freeze(l);
391
+ }
392
+ function Rr(e) {
393
+ if (!e)
394
+ return Object.freeze({});
395
+ const l = Object.entries(e).filter(([a, r]) => hr.includes(a) && !!r).map(([a, r]) => {
396
+ const i = r, d = {
397
+ ...i.hidden === !0 ? { hidden: !0 } : {},
398
+ ...i.disabled === !0 ? { disabled: !0 } : {},
399
+ ...typeof i.disabledReason == "string" && i.disabledReason.trim().length > 0 ? { disabledReason: i.disabledReason.trim() } : {},
400
+ ...typeof i.label == "string" && i.label.trim().length > 0 ? { label: i.label.trim() } : {}
401
+ };
402
+ return [a, Object.freeze(d)];
403
+ }).filter(([, a]) => Object.keys(a).length > 0);
404
+ return Object.freeze(Object.fromEntries(l));
405
+ }
406
+ function Eo(e) {
407
+ if (!e)
408
+ return {};
409
+ const l = Object.entries(e).filter(([a]) => a.trim().length > 0).map(([a, r]) => {
410
+ const i = r?.items ? Kl(r.items) : void 0, d = Hl(r?.hide), w = Hl(r?.disabled), b = yr(r?.disabledReasons), h = br(r?.labels), E = Rr(r?.actions), O = Nl(r?.customItems);
411
+ return [
412
+ a,
413
+ {
414
+ ...i ? { items: i } : {},
415
+ ...d.length > 0 ? { hide: d } : {},
416
+ ...w.length > 0 ? { disabled: w } : {},
417
+ ...Object.keys(b).length > 0 ? { disabledReasons: b } : {},
418
+ ...Object.keys(h).length > 0 ? { labels: h } : {},
419
+ ...Object.keys(E).length > 0 ? { actions: E } : {},
420
+ ...O.length > 0 ? { customItems: O } : {}
421
+ }
422
+ ];
423
+ });
424
+ return Object.fromEntries(l);
425
+ }
426
+ function ni(e) {
427
+ return typeof e == "boolean" ? {
428
+ enabled: e,
429
+ trigger: zl,
430
+ maxFilterValues: Ol,
431
+ items: [...je],
432
+ disabled: [],
433
+ disabledReasons: Object.freeze({}),
434
+ labels: Object.freeze({}),
435
+ actions: Object.freeze({}),
436
+ customItems: Object.freeze([]),
437
+ columns: {}
438
+ } : e ? {
439
+ enabled: e.enabled ?? !0,
440
+ trigger: _o(e.trigger),
441
+ maxFilterValues: Number.isFinite(e.maxFilterValues) ? Math.max(20, Math.trunc(e.maxFilterValues)) : Ol,
442
+ items: Kl(e.items),
443
+ disabled: Hl(e.disabled),
444
+ disabledReasons: yr(e.disabledReasons),
445
+ labels: br(e.labels),
446
+ actions: Rr(e.actions),
447
+ customItems: Nl(e.customItems),
448
+ columns: Eo(e.columns)
449
+ } : {
450
+ enabled: !1,
451
+ trigger: zl,
452
+ maxFilterValues: Ol,
453
+ items: [...je],
454
+ disabled: [],
455
+ disabledReasons: Object.freeze({}),
456
+ labels: Object.freeze({}),
457
+ actions: Object.freeze({}),
458
+ customItems: Object.freeze([]),
459
+ columns: {}
460
+ };
461
+ }
462
+ function Cr(e, l) {
463
+ const a = e.columns[l], r = a?.items ? Kl(a.items) : e.items, i = new Set(a?.hide ?? []), d = r.filter((w) => !i.has(w));
464
+ return d.length > 0 ? d : [];
465
+ }
466
+ function Po(e, l) {
467
+ const a = Cr(e, l), r = new Set(e.columns[l]?.disabled ?? []), i = new Set(e.disabled);
468
+ return a.filter((d) => i.has(d) || r.has(d));
469
+ }
470
+ function To(e, l) {
471
+ return Object.freeze({
472
+ ...e.labels,
473
+ ...e.columns[l]?.labels ?? {}
474
+ });
475
+ }
476
+ function zo(e, l) {
477
+ return Object.freeze({
478
+ ...e.disabledReasons,
479
+ ...e.columns[l]?.disabledReasons ?? {}
480
+ });
481
+ }
482
+ function Ho(e, l) {
483
+ const a = e.columns[l]?.actions ?? {}, r = hr.map((i) => {
484
+ const d = {
485
+ ...e.actions[i] ?? {},
486
+ ...a[i] ?? {}
487
+ };
488
+ return [i, Object.freeze(d)];
489
+ }).filter(([, i]) => Object.keys(i).length > 0);
490
+ return Object.freeze(Object.fromEntries(r));
491
+ }
492
+ function Vo(e, l) {
493
+ const a = /* @__PURE__ */ new Map();
494
+ for (const r of e.customItems)
495
+ a.set(r.key, r);
496
+ for (const r of e.columns[l]?.customItems ?? [])
497
+ a.set(r.key, r);
498
+ return Object.freeze(Array.from(a.values()));
499
+ }
500
+ const he = ["clipboard", "pasteSpecial", "edit"], Wl = ["cut", "copy", "paste", "pasteValues", "clear"], yt = ["insert", "clipboard", "selection"], pr = [
501
+ "insertAbove",
502
+ "insertBelow",
503
+ "cut",
504
+ "copy",
505
+ "paste",
506
+ "deleteSelected"
507
+ ];
508
+ function Tn(e, l) {
509
+ const a = new Set(l), r = Array.isArray(e) ? e : l, i = [];
510
+ for (const d of r)
511
+ !a.has(d) || i.includes(d) || i.push(d);
512
+ return i.length > 0 ? i : [...l];
513
+ }
514
+ function En(e, l) {
515
+ if (!Array.isArray(e))
516
+ return [];
517
+ const a = new Set(l), r = [];
518
+ for (const i of e)
519
+ !a.has(i) || r.includes(i) || r.push(i);
520
+ return r;
521
+ }
522
+ function Rt(e, l) {
523
+ if (!e)
524
+ return Object.freeze({});
525
+ const a = Object.entries(e).filter((r) => l.includes(r[0]) && typeof r[1] == "string").map(([r, i]) => [r, i.trim()]).filter(([, r]) => r.length > 0);
526
+ return Object.freeze(Object.fromEntries(a));
527
+ }
528
+ function Ul(e, l) {
529
+ if (!e)
530
+ return Object.freeze({});
531
+ const a = Object.entries(e).filter(([r, i]) => l.includes(r) && !!i).map(([r, i]) => {
532
+ const d = i, w = {
533
+ ...d.hidden === !0 ? { hidden: !0 } : {},
534
+ ...d.disabled === !0 ? { disabled: !0 } : {},
535
+ ...typeof d.disabledReason == "string" && d.disabledReason.trim().length > 0 ? { disabledReason: d.disabledReason.trim() } : {},
536
+ ...typeof d.label == "string" && d.label.trim().length > 0 ? { label: d.label.trim() } : {}
537
+ };
538
+ return [r, Object.freeze(w)];
539
+ }).filter(([, r]) => Object.keys(r).length > 0);
540
+ return Object.freeze(Object.fromEntries(a));
541
+ }
542
+ function Bo(e) {
543
+ if (e === "start" || e === "end")
544
+ return !0;
545
+ if (!e.includes(":"))
546
+ return !1;
547
+ const [l, a] = e.split(":");
548
+ return (l === "before" || l === "after") && he.includes(a);
549
+ }
550
+ function ql(e) {
551
+ if (!Array.isArray(e))
552
+ return Object.freeze([]);
553
+ const l = [], a = /* @__PURE__ */ new Set();
554
+ for (const r of e) {
555
+ const i = typeof r?.key == "string" ? r.key.trim() : "", d = typeof r?.label == "string" ? r.label.trim() : "";
556
+ if (i.length === 0 || d.length === 0 || a.has(i))
557
+ continue;
558
+ a.add(i);
559
+ const w = typeof r.placement == "string" && Bo(r.placement) ? r.placement : void 0, b = {
560
+ key: i,
561
+ label: d,
562
+ ...w ? { placement: w } : {},
563
+ ...r.hidden === !0 ? { hidden: !0 } : {},
564
+ ...r.disabled === !0 ? { disabled: !0 } : {},
565
+ ...typeof r.disabledReason == "string" && r.disabledReason.trim().length > 0 ? { disabledReason: r.disabledReason.trim() } : {}
566
+ };
567
+ if (r.kind === "submenu") {
568
+ const h = ql(r.items);
569
+ if (h.length === 0)
570
+ continue;
571
+ l.push(Object.freeze({
572
+ ...b,
573
+ kind: "submenu",
574
+ items: h
575
+ }));
576
+ continue;
577
+ }
578
+ l.push(Object.freeze({
579
+ ...b,
580
+ ...typeof r.onSelect == "function" ? { onSelect: r.onSelect } : {}
581
+ }));
582
+ }
583
+ return Object.freeze(l);
584
+ }
585
+ function jo(e) {
586
+ if (!e)
587
+ return {};
588
+ const l = Object.entries(e).filter(([a]) => a.trim().length > 0).map(([a, r]) => {
589
+ const i = r?.items ? Tn(r.items, he) : void 0, d = En(r?.hide, he), w = En(r?.disabled, he), b = Rt(r?.disabledReasons, he), h = Rt(r?.labels, he), E = Ul(r?.actions, Wl), O = ql(r?.customItems);
590
+ return [
591
+ a,
592
+ {
593
+ ...i ? { items: i } : {},
594
+ ...d.length > 0 ? { hide: d } : {},
595
+ ...w.length > 0 ? { disabled: w } : {},
596
+ ...Object.keys(b).length > 0 ? { disabledReasons: b } : {},
597
+ ...Object.keys(h).length > 0 ? { labels: h } : {},
598
+ ...Object.keys(E).length > 0 ? { actions: E } : {},
599
+ ...O.length > 0 ? { customItems: O } : {}
600
+ }
601
+ ];
602
+ });
603
+ return Object.freeze(Object.fromEntries(l));
604
+ }
605
+ function li(e) {
606
+ return typeof e == "boolean" ? {
607
+ enabled: e,
608
+ items: [...he],
609
+ disabled: [],
610
+ disabledReasons: Object.freeze({}),
611
+ labels: Object.freeze({}),
612
+ actions: Object.freeze({}),
613
+ customItems: Object.freeze([]),
614
+ columns: {}
615
+ } : e ? {
616
+ enabled: e.enabled ?? !0,
617
+ items: Tn(e.items, he),
618
+ disabled: En(e.disabled, he),
619
+ disabledReasons: Rt(e.disabledReasons, he),
620
+ labels: Rt(e.labels, he),
621
+ actions: Ul(e.actions, Wl),
622
+ customItems: ql(e.customItems),
623
+ columns: jo(e.columns)
624
+ } : {
625
+ enabled: !1,
626
+ items: [...he],
627
+ disabled: [],
628
+ disabledReasons: Object.freeze({}),
629
+ labels: Object.freeze({}),
630
+ actions: Object.freeze({}),
631
+ customItems: Object.freeze([]),
632
+ columns: {}
633
+ };
634
+ }
635
+ function kn(e, l) {
636
+ const a = e.columns[l], r = a?.items ? Tn(a.items, he) : e.items, i = new Set(a?.hide ?? []), d = r.filter((w) => !i.has(w));
637
+ return d.length > 0 ? d : [];
638
+ }
639
+ function Go(e, l) {
640
+ const a = kn(e, l), r = new Set(e.columns[l]?.disabled ?? []), i = new Set(e.disabled);
641
+ return a.filter((d) => i.has(d) || r.has(d));
642
+ }
643
+ function Lo(e, l) {
644
+ return Object.freeze({
645
+ ...e.labels,
646
+ ...e.columns[l]?.labels ?? {}
647
+ });
648
+ }
649
+ function $o(e, l) {
650
+ return Object.freeze({
651
+ ...e.disabledReasons,
652
+ ...e.columns[l]?.disabledReasons ?? {}
653
+ });
654
+ }
655
+ function Ko(e, l) {
656
+ const a = e.columns[l]?.actions ?? {}, r = Wl.map((i) => {
657
+ const d = {
658
+ ...e.actions[i] ?? {},
659
+ ...a[i] ?? {}
660
+ };
661
+ return [i, Object.freeze(d)];
662
+ }).filter(([, i]) => Object.keys(i).length > 0);
663
+ return Object.freeze(Object.fromEntries(r));
664
+ }
665
+ function No(e, l) {
666
+ const a = /* @__PURE__ */ new Map();
667
+ for (const r of e.customItems)
668
+ a.set(r.key, r);
669
+ for (const r of e.columns[l]?.customItems ?? [])
670
+ a.set(r.key, r);
671
+ return Object.freeze(Array.from(a.values()));
672
+ }
673
+ function ri(e) {
674
+ return typeof e == "boolean" ? {
675
+ enabled: e,
676
+ items: [...yt],
677
+ disabled: [],
678
+ disabledReasons: Object.freeze({}),
679
+ labels: Object.freeze({}),
680
+ actions: Object.freeze({})
681
+ } : e ? {
682
+ enabled: e.enabled ?? !0,
683
+ items: Tn(e.items, yt),
684
+ disabled: En(e.disabled, yt),
685
+ disabledReasons: Rt(e.disabledReasons, yt),
686
+ labels: Rt(e.labels, yt),
687
+ actions: Ul(e.actions, pr)
688
+ } : {
689
+ enabled: !1,
690
+ items: [...yt],
691
+ disabled: [],
692
+ disabledReasons: Object.freeze({}),
693
+ labels: Object.freeze({}),
694
+ actions: Object.freeze({})
695
+ };
696
+ }
697
+ function Wo(e) {
698
+ return e.items;
699
+ }
700
+ function Uo(e) {
701
+ return e.disabled;
702
+ }
703
+ function qo(e) {
704
+ return e.disabledReasons;
705
+ }
706
+ function Yo(e) {
707
+ const l = pr.map((a) => [a, Object.freeze({ ...e.actions[a] ?? {} })]).filter(([, a]) => Object.keys(a).length > 0);
708
+ return Object.freeze(Object.fromEntries(l));
709
+ }
710
+ function lr(e) {
711
+ return (l) => {
712
+ e.value = l instanceof HTMLElement ? l : null;
713
+ };
714
+ }
715
+ function Jo(e) {
716
+ const l = lr(e.headerViewportRef), a = lr(e.bodyViewportRef), r = (F) => {
717
+ e.editingCellValueRef.value = F;
718
+ }, i = g(() => ({
719
+ gridContentStyle: f(e.gridContentStyle),
720
+ mainTrackStyle: f(e.mainTrackStyle),
721
+ indexColumnStyle: f(e.indexColumnStyle),
722
+ stageStyle: f(e.stageStyle),
723
+ bodyShellStyle: f(e.bodyShellStyle),
724
+ columnStyle: f(e.columnStyle)
725
+ })), d = g(() => ({
726
+ topSpacerHeight: f(e.topSpacerHeight),
727
+ bottomSpacerHeight: f(e.bottomSpacerHeight),
728
+ viewportRowStart: f(e.viewportRowStart),
729
+ viewportRowEnd: f(e.viewportRowEnd),
730
+ virtualRowTotal: f(e.virtualRowTotal),
731
+ baseRowHeight: f(e.baseRowHeight),
732
+ resolveRowHeight: f(e.resolveRowHeight),
733
+ resolveRowOffset: f(e.resolveRowOffset),
734
+ columnWindowStart: f(e.columnWindowStart),
735
+ leftColumnSpacerWidth: f(e.leftColumnSpacerWidth),
736
+ rightColumnSpacerWidth: f(e.rightColumnSpacerWidth),
737
+ headerViewportRef: l,
738
+ bodyViewportRef: a,
739
+ handleHeaderWheel: f(e.handleHeaderWheel),
740
+ handleHeaderScroll: f(e.handleHeaderScroll),
741
+ handleViewportScroll: f(e.handleViewportScroll),
742
+ handleViewportKeydown: f(e.handleViewportKeydown)
743
+ })), w = g(() => ({
744
+ visibleColumns: f(e.visibleColumns),
745
+ renderedColumns: f(e.renderedColumns),
746
+ columnFilterTextByKey: f(e.columnFilterTextByKey),
747
+ reorderColumnsByHeader: f(e.reorderColumnsByHeader),
748
+ toggleSortForColumn: f(e.toggleSortForColumn),
749
+ handleHeaderColumnClick: f(e.handleHeaderColumnClick),
750
+ sortIndicator: f(e.sortIndicator),
751
+ setColumnFilterText: f(e.setColumnFilterText),
752
+ columnMenuEnabled: f(e.columnMenuEnabled),
753
+ columnMenuTrigger: f(e.columnMenuTrigger),
754
+ columnMenuValueFilterEnabled: f(e.columnMenuValueFilterEnabled),
755
+ columnMenuValueFilterRowLimit: f(e.columnMenuValueFilterRowLimit),
756
+ columnMenuMaxFilterValues: f(e.columnMenuMaxFilterValues),
757
+ resolveColumnMenuItems: f(e.resolveColumnMenuItems),
758
+ resolveColumnMenuDisabledItems: f(e.resolveColumnMenuDisabledItems),
759
+ resolveColumnMenuDisabledReasons: f(e.resolveColumnMenuDisabledReasons),
760
+ resolveColumnMenuLabels: f(e.resolveColumnMenuLabels),
761
+ resolveColumnMenuActionOptions: f(e.resolveColumnMenuActionOptions),
762
+ resolveColumnMenuCustomItems: f(e.resolveColumnMenuCustomItems),
763
+ isColumnFilterActive: f(e.isColumnFilterActive),
764
+ isColumnGrouped: f(e.isColumnGrouped),
765
+ resolveColumnGroupOrder: f(e.resolveColumnGroupOrder),
766
+ resolveColumnMenuSortDirection: f(e.resolveColumnMenuSortDirection),
767
+ resolveColumnMenuSelectedTokens: f(e.resolveColumnMenuSelectedTokens),
768
+ resolveColumnMenuValueEntries: f(e.resolveColumnMenuValueEntries),
769
+ applyColumnMenuSort: f(e.applyColumnMenuSort),
770
+ applyColumnMenuPin: f(e.applyColumnMenuPin),
771
+ applyColumnMenuGroupBy: f(e.applyColumnMenuGroupBy),
772
+ applyColumnMenuFilter: f(e.applyColumnMenuFilter),
773
+ clearColumnMenuFilter: f(e.clearColumnMenuFilter),
774
+ startResize: f(e.startResize),
775
+ handleResizeDoubleClick: f(e.handleResizeDoubleClick)
776
+ })), b = g(() => ({
777
+ displayRows: f(e.displayRows),
778
+ displayRowsRevision: f(e.displayRowsRevision),
779
+ runtimeRevision: f(e.runtimeRevision),
780
+ pinnedBottomRows: f(e.pinnedBottomRows),
781
+ sourceRows: f(e.sourceRows),
782
+ showRowIndex: f(e.showRowIndex),
783
+ rowHover: f(e.rowHover),
784
+ stripedRows: f(e.stripedRows),
785
+ rowClass: f(e.rowClass),
786
+ isRowAutosizeProbe: f(e.isRowAutosizeProbe),
787
+ rowStyle: f(e.rowStyle),
788
+ isRowInPendingClipboardCut: f(e.isRowInPendingClipboardCut),
789
+ isRowFocused: f(e.isRowFocused),
790
+ isRowCheckboxSelected: f(e.isRowCheckboxSelected),
791
+ allVisibleRowsSelected: f(e.allVisibleRowsSelected),
792
+ someVisibleRowsSelected: f(e.someVisibleRowsSelected),
793
+ handleRowClick: f(e.handleRowClick),
794
+ handleRowIndexClick: f(e.handleRowIndexClick),
795
+ handleRowIndexKeydown: f(e.handleRowIndexKeydown),
796
+ reorderRowsByIndex: f(e.reorderRowsByIndex),
797
+ handleToggleAllVisibleRows: f(e.handleToggleAllVisibleRows),
798
+ toggleGroupRow: f(e.toggleGroupRow),
799
+ rowIndexLabel: f(e.rowIndexLabel),
800
+ startRowResize: f(e.startRowResize),
801
+ autosizeRow: f(e.autosizeRow)
802
+ })), h = g(() => ({
803
+ selectionRange: f(e.selectionRange),
804
+ selectionRanges: f(e.selectionRanges),
805
+ selectionAnchorCell: f(e.selectionAnchorCell),
806
+ totalRowCount: f(e.totalRowCount),
807
+ fillPreviewRange: f(e.fillPreviewRange),
808
+ rangeMovePreviewRange: f(e.rangeMovePreviewRange),
809
+ fillHandleEnabled: f(e.fillHandleEnabled),
810
+ rangeMoveEnabled: f(e.rangeMoveEnabled),
811
+ isFillDragging: f(e.isFillDragging),
812
+ isRangeMoving: f(e.isRangeMoving),
813
+ fillActionAnchorCell: f(e.fillActionAnchorCell),
814
+ fillActionBehavior: f(e.fillActionBehavior),
815
+ applyFillActionBehavior: f(e.applyFillActionBehavior),
816
+ isFillHandleCell: f(e.isFillHandleCell),
817
+ startFillHandleDrag: f(e.startFillHandleDrag),
818
+ startFillHandleDoubleClick: f(e.startFillHandleDoubleClick)
819
+ })), E = g(() => ({
820
+ editingCellValue: e.editingCellValueRef.value,
821
+ editingCellInitialFilter: f(e.editingCellInitialFilter),
822
+ editingCellOpenOnMount: f(e.editingCellOpenOnMount),
823
+ isEditingCell: f(e.isEditingCell),
824
+ startInlineEdit: f(e.startInlineEdit),
825
+ updateEditingCellValue: r,
826
+ handleEditorKeydown: f(e.handleEditorKeydown),
827
+ handleEditorBlur: f(e.handleEditorBlur),
828
+ commitInlineEdit: f(e.commitInlineEdit),
829
+ cancelInlineEdit: f(e.cancelInlineEdit)
830
+ })), O = g(() => ({
831
+ cellClass: f(e.cellClass),
832
+ cellStyle: f(e.cellStyle),
833
+ isCellSelected: f(e.isCellSelected),
834
+ isSelectionAnchorCell: f(e.isSelectionAnchorCell),
835
+ shouldHighlightSelectedCell: f(e.shouldHighlightSelectedCell),
836
+ isCellOnSelectionEdge: f(e.isCellOnSelectionEdge),
837
+ isCellInFillPreview: f(e.isCellInFillPreview),
838
+ isCellInPendingClipboardRange: f(e.isCellInPendingClipboardRange),
839
+ isCellOnPendingClipboardEdge: f(e.isCellOnPendingClipboardEdge),
840
+ isCellEditable: f(e.isCellEditable),
841
+ readCell: f(e.readCell),
842
+ readDisplayCell: f(e.readDisplayCell)
843
+ })), L = g(() => ({
844
+ handleCellMouseDown: f(e.handleCellMouseDown),
845
+ handleCellClick: f(e.handleCellClick),
846
+ handleCellKeydown: f(e.handleCellKeydown)
847
+ })), I = g(() => ({
848
+ mode: f(e.mode),
849
+ rowHeightMode: f(e.rowHeightMode),
850
+ layoutMode: f(e.layoutMode),
851
+ chromeSignature: f(e.chromeSignature),
852
+ customOverlays: f(e.customOverlays),
853
+ reportCenterPaneDiagnostics: f(e.reportCenterPaneDiagnostics),
854
+ reportFillPlumbingState: f(e.reportFillPlumbingState),
855
+ reportFillPlumbingDetail: f(e.reportFillPlumbingDetail),
856
+ layout: i.value,
857
+ viewport: d.value,
858
+ columns: w.value,
859
+ rows: b.value,
860
+ selection: h.value,
861
+ editing: E.value,
862
+ cells: O.value,
863
+ interaction: L.value
864
+ })), C = oo({
865
+ mode: g(() => f(e.mode)),
866
+ rowHeightMode: g(() => f(e.rowHeightMode)),
867
+ layoutMode: g(() => f(e.layoutMode)),
868
+ layout: i,
869
+ viewport: d,
870
+ columns: w,
871
+ rows: b,
872
+ selection: h,
873
+ editing: E,
874
+ cells: O,
875
+ interaction: L
876
+ });
877
+ return {
878
+ tableStageProps: I,
879
+ tableStageContext: C,
880
+ captureHeaderViewportRef: l,
881
+ captureBodyViewportRef: a,
882
+ updateEditingCellValue: r
883
+ };
884
+ }
885
+ function Xo(e) {
886
+ const l = (d, w) => Number.isFinite(d.displayIndex) ? Math.max(0, Math.trunc(d.displayIndex)) : e.viewportRowStart.value + w;
887
+ return {
888
+ readStageCell: (d, w) => e.isRowSelectionColumnKey(w) ? e.readRowSelectionCell(d) : e.readCell(d, w),
889
+ readStageDisplayCell: (d, w) => e.isRowSelectionColumnKey(w) ? e.readRowSelectionDisplayCell(d) : e.readDisplayCell(d, w),
890
+ handleCellClick: (d, w, b, h) => {
891
+ if (e.isRowSelectionColumn(b)) {
892
+ e.toggleRowCheckboxSelected(d);
893
+ return;
894
+ }
895
+ const E = l(d, w), O = e.isCellEditableByKey(d, E, b.key, h), L = Tr({
896
+ column: b.column,
897
+ row: d.kind !== "group" ? d.data : void 0,
898
+ rowId: d.rowId,
899
+ editable: O
900
+ });
901
+ if (L === "invoke") {
902
+ zr({
903
+ column: b.column,
904
+ row: d.kind !== "group" ? d.data : void 0,
905
+ rowId: d.rowId,
906
+ editable: O,
907
+ trigger: "click"
908
+ });
909
+ return;
910
+ }
911
+ if (L !== "toggle" || d.kind === "group" || d.rowId == null)
912
+ return;
913
+ const I = e.captureHistorySnapshot(), C = e.ensureEditableRowAtIndex?.(E) ?? d;
914
+ if (C.kind === "group" || C.rowId == null)
915
+ return;
916
+ const F = C.data[b.key], A = Hr({
917
+ column: b.column,
918
+ row: C.data
919
+ });
920
+ e.runtime.api.rows.applyEdits([
921
+ {
922
+ rowId: C.rowId,
923
+ data: {
924
+ [b.key]: A
925
+ }
926
+ }
927
+ ]), e.onCellEdit?.({
928
+ rowId: C.rowId,
929
+ columnKey: b.key,
930
+ oldValue: F,
931
+ newValue: A,
932
+ patch: {
933
+ rowId: C.rowId,
934
+ data: {
935
+ [b.key]: A
936
+ }
937
+ }
938
+ }), e.recordHistoryIntentTransaction({
939
+ intent: "edit",
940
+ label: `Toggle ${b.key}`,
941
+ affectedRange: {
942
+ startRow: E,
943
+ endRow: E,
944
+ startColumn: h,
945
+ endColumn: h
946
+ }
947
+ }, I), e.syncViewport();
948
+ }
949
+ };
950
+ }
951
+ const rr = 140, _n = 108, _l = "__datagrid_row_selection__";
952
+ function Zo(e) {
953
+ const l = g(() => (e.showRowSelection?.value ?? !0) && e.runtime.api.rowSelection.hasSupport()), a = g(() => l.value ? {
954
+ key: _l,
955
+ state: {
956
+ visible: !0,
957
+ pin: "left",
958
+ width: _n
959
+ },
960
+ visible: !0,
961
+ pin: "left",
962
+ width: _n,
963
+ column: {
964
+ key: _l,
965
+ label: "",
966
+ cellType: "checkbox",
967
+ cellInteraction: {
968
+ click: !0,
969
+ keyboard: ["enter", "space"],
970
+ role: "checkbox",
971
+ label: "Toggle row selection",
972
+ checked: ({ rowId: C }) => C != null && e.runtime.api.rowSelection.isSelected(C),
973
+ onInvoke: ({ rowId: C }) => {
974
+ C == null || !e.runtime.api.rowSelection.hasSupport() || e.runtime.api.rowSelection.setSelected(
975
+ C,
976
+ !e.runtime.api.rowSelection.isSelected(C)
977
+ );
978
+ }
979
+ },
980
+ minWidth: _n,
981
+ maxWidth: _n,
982
+ capabilities: {
983
+ editable: !0,
984
+ sortable: !1,
985
+ filterable: !1,
986
+ groupable: !1,
987
+ pivotable: !1,
988
+ aggregatable: !1
989
+ },
990
+ presentation: {
991
+ align: "center",
992
+ headerAlign: "center"
993
+ },
994
+ meta: {
995
+ isSystem: !0,
996
+ rowSelection: !0
997
+ }
998
+ }
999
+ } : null), r = (C) => C === _l, i = (C) => r(C.key), d = g(() => {
1000
+ const C = a.value, F = e.visibleColumns.value.filter((x) => x.pin === "left"), A = e.visibleColumns.value.filter((x) => x.pin !== "left" && x.pin !== "right"), y = e.visibleColumns.value.filter((x) => x.pin === "right");
1001
+ return C ? [C, ...F, ...A, ...y] : [...F, ...A, ...y];
1002
+ }), w = g(() => d.value.filter((C) => C.pin !== "left" && C.pin !== "right")), b = (C) => C.width ?? rr, h = (C) => {
1003
+ const F = d.value.find((x) => x.key === C), y = `${F ? b(F) : rr}px`;
1004
+ return {
1005
+ width: y,
1006
+ minWidth: y,
1007
+ maxWidth: y
1008
+ };
1009
+ }, E = (C) => C.column.capabilities?.editable !== !1, O = (C, F, A) => i(A) ? C.kind !== "group" && C.rowId != null : C.kind === "group" || C.rowId == null || !E(A) ? !1 : e.isCellEditable ? e.isCellEditable({
1010
+ row: C.data,
1011
+ rowId: C.rowId,
1012
+ rowIndex: F,
1013
+ column: A.column,
1014
+ columnKey: A.key
1015
+ }) : !0, L = (C, F) => {
1016
+ const A = d.value[F];
1017
+ if (A?.key === C)
1018
+ return { column: A, columnIndex: F };
1019
+ const y = d.value.findIndex((x) => x.key === C);
1020
+ return y < 0 ? null : {
1021
+ column: d.value[y],
1022
+ columnIndex: y
1023
+ };
1024
+ };
1025
+ return {
1026
+ orderedVisibleColumns: d,
1027
+ centerColumns: w,
1028
+ resolveColumnWidth: b,
1029
+ stageColumnStyle: h,
1030
+ isRowSelectionColumnKey: r,
1031
+ isRowSelectionColumn: i,
1032
+ isCellEditable: O,
1033
+ isCellEditableByKey: (C, F, A, y) => {
1034
+ const x = L(A, y);
1035
+ return x ? O(C, F, x.column) : !1;
1036
+ },
1037
+ rowSelectionColumn: a
1038
+ };
1039
+ }
1040
+ function Qo(e) {
1041
+ const l = g(() => {
1042
+ const r = e.lastAppliedFill.value, i = e.selectionRange.value;
1043
+ return !r || !i || e.isFillDragging.value || r.allowBehaviorToggle === !1 || r.previewRange.startRow !== i.startRow || r.previewRange.endRow !== i.endRow || r.previewRange.startColumn !== i.startColumn || r.previewRange.endColumn !== i.endColumn ? null : {
1044
+ rowIndex: r.previewRange.endRow,
1045
+ columnIndex: r.previewRange.endColumn
1046
+ };
1047
+ }), a = g(() => e.lastAppliedFill.value?.behavior ?? null);
1048
+ return {
1049
+ fillActionAnchorCell: l,
1050
+ fillActionBehavior: a
1051
+ };
1052
+ }
1053
+ function ea(e) {
1054
+ const l = e.enabled === !1 || e.history ? null : Lr({
1055
+ runtime: e.runtime,
1056
+ cloneRowData: e.cloneRowData,
1057
+ syncViewport: e.syncViewport,
1058
+ maxHistoryDepth: e.maxHistoryDepth
1059
+ }), a = () => e.enabled === !1 ? null : e.history ? e.history.captureSnapshot() : l?.captureRowsSnapshot() ?? null, r = (O) => e.enabled === !1 ? null : e.history ? e.history.captureSnapshotForRowIds?.(O) ?? e.history.captureSnapshot() : l?.captureRowsSnapshotByIds(O) ?? null, i = (O, L, I) => {
1060
+ if (e.enabled !== !1) {
1061
+ if (e.history) {
1062
+ e.history.recordIntentTransaction(O, L, I);
1063
+ return;
1064
+ }
1065
+ l?.recordIntentTransaction(
1066
+ O,
1067
+ L,
1068
+ I
1069
+ );
1070
+ }
1071
+ }, d = (O) => {
1072
+ e.enabled !== !1 && e.history?.recordServerFillTransaction?.(O);
1073
+ }, w = () => e.enabled === !1 ? !1 : e.history ? e.history.canUndo() : l?.canUndo.value ?? !1, b = () => e.enabled === !1 ? !1 : e.history ? e.history.canRedo() : l?.canRedo.value ?? !1;
1074
+ return {
1075
+ captureHistorySnapshot: a,
1076
+ captureHistorySnapshotForRowIds: r,
1077
+ recordHistoryIntentTransaction: i,
1078
+ recordServerFillTransaction: d,
1079
+ canUndoHistory: w,
1080
+ canRedoHistory: b,
1081
+ canUndo: w,
1082
+ canRedo: b,
1083
+ runHistoryAction: (O) => e.enabled === !1 ? Promise.resolve(null) : e.history ? e.history.runHistoryAction(O) : l?.runHistoryAction(O) ?? Promise.resolve(null),
1084
+ disposeIntentHistory: () => {
1085
+ l?.dispose();
1086
+ }
1087
+ };
1088
+ }
1089
+ function ta(e) {
1090
+ const l = e.isPlaceholderRow ?? (() => !1), a = e.applyRowSelectionMutation ?? ((y) => {
1091
+ e.runtime.api.rowSelection.hasSupport() && y(e.runtime.api.rowSelection);
1092
+ }), r = g(() => new Set(e.rowSelectionSnapshot.value?.selectedRows ?? [])), i = (y) => !l(y) && y.rowId != null && e.rowSelectionSnapshot.value?.focusedRow === y.rowId, d = (y) => !l(y) && y.kind !== "group" && y.rowId != null && r.value.has(y.rowId), w = (y) => d(y), b = (y) => w(y) ? "true" : "false", h = (y) => {
1093
+ const x = e.rowSelectionColumn.value?.column;
1094
+ return !x || y.kind === "group" || l(y) ? "" : Vr({
1095
+ column: x,
1096
+ value: w(y)
1097
+ }).displayValue;
1098
+ }, E = g(() => {
1099
+ const y = e.runtime.api.rows.getCount(), x = [];
1100
+ for (let ne = 0; ne < y; ne += 1) {
1101
+ const de = e.runtime.api.rows.get(ne);
1102
+ !de || de.kind === "group" || de.rowId == null || x.push(de.rowId);
1103
+ }
1104
+ return x;
1105
+ }), O = g(() => {
1106
+ const y = E.value;
1107
+ return y.length > 0 && y.every((x) => r.value.has(x));
1108
+ }), L = g(() => E.value.some((x) => r.value.has(x))), I = (y) => {
1109
+ l(y) || y.rowId == null || !e.runtime.api.rowSelection.hasSupport() || e.runtime.api.rowSelection.setFocusedRow(y.rowId);
1110
+ };
1111
+ return {
1112
+ rowSelectionSet: r,
1113
+ isRowFocused: i,
1114
+ isRowCheckboxSelected: d,
1115
+ readRowSelectionCell: b,
1116
+ readRowSelectionDisplayCell: h,
1117
+ areAllVisibleRowsSelected: O,
1118
+ areSomeVisibleRowsSelected: L,
1119
+ focusRow: I,
1120
+ toggleRowCheckboxSelected: (y) => {
1121
+ l(y) || y.kind === "group" || y.rowId == null || !e.runtime.api.rowSelection.hasSupport() || a((x) => {
1122
+ x.setSelected(y.rowId, !r.value.has(y.rowId));
1123
+ });
1124
+ },
1125
+ toggleVisibleRowsSelected: () => {
1126
+ if (!e.runtime.api.rowSelection.hasSupport())
1127
+ return;
1128
+ const y = E.value;
1129
+ if (!O.value) {
1130
+ a((x) => {
1131
+ x.selectRows(y);
1132
+ });
1133
+ return;
1134
+ }
1135
+ a((x) => {
1136
+ x.deselectRows(y);
1137
+ });
1138
+ },
1139
+ selectRowRange: (y, x, ne) => {
1140
+ I(y);
1141
+ const de = e.orderedVisibleColumns.value.length - 1;
1142
+ if (de < 0)
1143
+ return;
1144
+ const H = e.viewportRowStart.value + x;
1145
+ if (!ne) {
1146
+ e.applySelectionRange({
1147
+ startRow: H,
1148
+ endRow: H,
1149
+ startColumn: 0,
1150
+ endColumn: de
1151
+ });
1152
+ return;
1153
+ }
1154
+ const Re = e.selectionAnchorCell.value?.rowIndex ?? H;
1155
+ e.applySelectionRange({
1156
+ startRow: Math.min(Re, H),
1157
+ endRow: Math.max(Re, H),
1158
+ startColumn: 0,
1159
+ endColumn: de
1160
+ });
1161
+ }
1162
+ };
1163
+ }
1164
+ function na(e) {
1165
+ const l = (w) => ({ target: w });
1166
+ return {
1167
+ handleWindowMouseMove: (w) => {
1168
+ if (e.isColumnResizing.value) {
1169
+ e.applyColumnResizeFromPointer(w.clientX);
1170
+ return;
1171
+ }
1172
+ e.handleInteractionWindowMouseMove(w);
1173
+ },
1174
+ handleHeaderWheel: (w) => {
1175
+ const b = e.bodyViewportRef.value;
1176
+ if (!b)
1177
+ return;
1178
+ const h = Math.abs(w.deltaX) > 0 ? w.deltaX : w.shiftKey ? w.deltaY : 0, E = h === 0 ? w.deltaY : 0;
1179
+ h === 0 && E === 0 || (w.preventDefault(), h !== 0 && (b.scrollLeft += h), E !== 0 && (b.scrollTop += E), e.syncViewport(l(b)));
1180
+ },
1181
+ handleHeaderScroll: (w) => {
1182
+ const b = w.target, h = e.bodyViewportRef.value;
1183
+ !b || !h || (h.scrollLeft !== b.scrollLeft && (h.scrollLeft = b.scrollLeft), e.syncViewport(l(h)));
1184
+ },
1185
+ handleWindowMouseUp: () => {
1186
+ e.stopColumnResize(), e.handleInteractionWindowMouseUp();
1187
+ }
1188
+ };
1189
+ }
1190
+ function la(e) {
1191
+ const l = (d) => d.ctrlKey || d.metaKey || d.altKey ? !1 : d.key.startsWith("Arrow") || d.key === "Home" || d.key === "End" || d.key === "PageUp" || d.key === "PageDown" || d.key === "Tab" || d.key === "Enter" || d.key === " " || d.key === "Spacebar" || d.key === "F2" || d.key === "Escape" || d.key.length === 1, a = (d) => (d.ctrlKey || d.metaKey) && !d.altKey && !d.shiftKey && d.key.toLowerCase() === "a", r = () => {
1192
+ const d = e.totalRows.value - 1, w = e.orderedVisibleColumns.value.length - 1;
1193
+ d < 0 || w < 0 || e.applySelectionRange({
1194
+ startRow: 0,
1195
+ endRow: d,
1196
+ startColumn: 0,
1197
+ endColumn: w
1198
+ });
1199
+ };
1200
+ return {
1201
+ handleViewportKeydown: (d) => {
1202
+ (l(d) || a(d)) && d.preventDefault();
1203
+ const w = e.selectionSnapshot.value?.activeCell;
1204
+ if (!w) {
1205
+ a(d) && r();
1206
+ return;
1207
+ }
1208
+ const b = e.runtime.getBodyRowAtIndex(w.rowIndex);
1209
+ b && e.handleCellKeydown(
1210
+ d,
1211
+ b,
1212
+ w.rowIndex - e.viewportRowStart.value,
1213
+ w.colIndex
1214
+ );
1215
+ }
1216
+ };
1217
+ }
1218
+ function ra(e) {
1219
+ const l = g(() => e.interactionSelectionRange.value ?? e.resolveCommittedSelectionRange()), a = g(() => {
1220
+ const I = e.interactionSelectionRange.value;
1221
+ return I ? [I] : e.resolveCommittedSelectionRanges();
1222
+ }), r = () => {
1223
+ const I = l.value;
1224
+ return I && I.startRow === I.endRow && I.startColumn === I.endColumn ? {
1225
+ rowIndex: I.startRow,
1226
+ columnIndex: I.startColumn
1227
+ } : e.selectionAnchorCell.value;
1228
+ }, i = () => l.value, d = () => a.value, w = () => e.mode.value === "base" && e.isFillDragging.value && !!e.fillPreviewRange.value, b = (I, C, F) => {
1229
+ const A = e.viewportRowStart.value + C;
1230
+ return A >= I.startRow && A <= I.endRow && F >= I.startColumn && F <= I.endColumn;
1231
+ }, h = (I, C) => {
1232
+ const F = r();
1233
+ return F ? F.rowIndex === e.viewportRowStart.value + I && F.columnIndex === C : e.isCommittedSelectionAnchorCell(I, C);
1234
+ };
1235
+ return {
1236
+ selectionRange: l,
1237
+ selectionRanges: a,
1238
+ isSelectionAnchorCell: h,
1239
+ isCellSelected: (I, C) => {
1240
+ if (!w())
1241
+ return d().some((A) => b(A, I, C));
1242
+ const F = i();
1243
+ return F ? b(F, I, C) : !1;
1244
+ },
1245
+ shouldHighlightSelectedCell: (I, C) => {
1246
+ if (!w()) {
1247
+ const y = d();
1248
+ return y.length === 0 || !y.some((x) => b(x, I, C)) || y.length === 1 && y[0] && y[0].startRow === y[0].endRow && y[0].startColumn === y[0].endColumn ? !1 : !h(I, C);
1249
+ }
1250
+ const F = i();
1251
+ return !F || !b(F, I, C) || F.startRow === F.endRow && F.startColumn === F.endColumn ? !1 : !h(I, C);
1252
+ },
1253
+ isCellOnSelectionEdge: (I, C, F) => {
1254
+ if (!w())
1255
+ return d().some((x) => {
1256
+ if (!b(x, I, C))
1257
+ return !1;
1258
+ const ne = e.viewportRowStart.value + I;
1259
+ switch (F) {
1260
+ case "top":
1261
+ return ne === x.startRow;
1262
+ case "right":
1263
+ return C === x.endColumn;
1264
+ case "bottom":
1265
+ return ne === x.endRow;
1266
+ case "left":
1267
+ return C === x.startColumn;
1268
+ }
1269
+ });
1270
+ const A = i();
1271
+ if (!A || !b(A, I, C))
1272
+ return !1;
1273
+ const y = e.viewportRowStart.value + I;
1274
+ switch (F) {
1275
+ case "top":
1276
+ return y === A.startRow;
1277
+ case "right":
1278
+ return C === A.endColumn;
1279
+ case "bottom":
1280
+ return y === A.endRow;
1281
+ case "left":
1282
+ return C === A.startColumn;
1283
+ }
1284
+ }
1285
+ };
1286
+ }
1287
+ const kl = 140, oa = 72, aa = 80, ia = 24, sa = 400;
1288
+ function ua(e) {
1289
+ const l = e.syncRowSelectionSnapshotFromRuntime ?? (() => {
1290
+ }), a = e.flushRowSelectionSnapshotUpdates ?? (() => {
1291
+ }), r = e.rowSelectionSnapshot ?? U(null), i = U(null), d = g(() => e.showRowIndex?.value !== !1), w = g(() => e.runtime.rowPartition.value.bodyRowCount), b = ao({
1292
+ runtime: e.runtime,
1293
+ sourceRows: e.sourceRows ?? e.rows,
1294
+ totalBodyRows: w,
1295
+ placeholderRows: e.placeholderRows,
1296
+ cloneRowData: e.cloneRowData
1297
+ }), h = g(() => Math.max(0, b.totalVisualRows.value)), E = g(() => Math.max(0, h.value + e.runtime.rowPartition.value.pinnedBottomRows.length)), O = g(() => d.value ? oa : 0), L = Zo({
1298
+ runtime: e.runtime,
1299
+ visibleColumns: e.visibleColumns,
1300
+ showRowSelection: e.showRowSelection,
1301
+ isCellEditable: e.isCellEditable
1302
+ }), {
1303
+ orderedVisibleColumns: I,
1304
+ centerColumns: C,
1305
+ resolveColumnWidth: F,
1306
+ isRowSelectionColumnKey: A,
1307
+ isRowSelectionColumn: y,
1308
+ isCellEditable: x,
1309
+ isCellEditableByKey: ne,
1310
+ rowSelectionColumn: de
1311
+ } = L, H = $r({
1312
+ totalRows: () => h.value,
1313
+ resolveBaseRowHeight: () => e.normalizedBaseRowHeight.value,
1314
+ resolveRowHeightOverride: (c) => e.runtime.api.view.getRowHeightOverride(c),
1315
+ resolveRowHeightVersion: () => e.runtime.api.view.getRowHeightVersion(),
1316
+ hasRowHeightOverrides: () => e.runtime.api.view.getRowHeightVersion() > 0,
1317
+ resolveRowHeightOverridesSnapshot: () => e.runtime.api.view.getRowHeightOverridesSnapshot?.() ?? null,
1318
+ resolveLastRowHeightMutation: () => e.runtime.api.view.getLastRowHeightMutation?.() ?? null
1319
+ }), Re = (c) => {
1320
+ const p = Math.max(0, Math.trunc(c));
1321
+ if (p <= 0)
1322
+ return 0;
1323
+ const S = H.resolveTotalHeight();
1324
+ return p <= w.value ? H.resolveRowOffset(p) : S + (p - w.value) * e.normalizedBaseRowHeight.value;
1325
+ }, $e = g(() => {
1326
+ if (e.layoutMode.value !== "auto-height")
1327
+ return null;
1328
+ let c = H.resolveTotalHeight();
1329
+ return e.minRows.value !== null && (c = Math.max(c, Re(e.minRows.value))), e.maxRows.value !== null && (c = Math.min(c, Re(e.maxRows.value))), Math.max(0, Math.trunc(c));
1330
+ }), Ct = g(() => e.layoutMode.value !== "auto-height" ? {} : {
1331
+ height: "auto"
1332
+ }), Je = g(() => {
1333
+ if (e.layoutMode.value !== "auto-height")
1334
+ return {};
1335
+ const c = $e.value ?? 0;
1336
+ return {
1337
+ height: `${c}px`,
1338
+ maxHeight: `${c}px`
1339
+ };
1340
+ });
1341
+ let z = () => !1;
1342
+ const {
1343
+ headerViewportRef: V,
1344
+ bodyViewportRef: _,
1345
+ displayRows: oe,
1346
+ displayRowsRevision: zn,
1347
+ renderedViewportRange: pt,
1348
+ pinnedBottomRows: Hn,
1349
+ renderedColumns: Vn,
1350
+ viewportRowStart: q,
1351
+ viewportRowEnd: le,
1352
+ viewportColumnStart: Nt,
1353
+ topSpacerHeight: Bn,
1354
+ bottomSpacerHeight: jn,
1355
+ leftColumnSpacerWidth: ct,
1356
+ rightColumnSpacerWidth: Gn,
1357
+ gridContentStyle: Ln,
1358
+ mainTrackStyle: $n,
1359
+ indexColumnStyle: Kn,
1360
+ columnStyle: Nn,
1361
+ handleViewportScroll: Wt,
1362
+ syncRenderedRowsInRange: Wn,
1363
+ syncViewportFromDom: ce,
1364
+ scheduleViewportSync: Ke,
1365
+ cancelScheduledViewportSync: X
1366
+ } = Kr({
1367
+ runtime: b.visualRuntime,
1368
+ mode: e.mode,
1369
+ rowRenderMode: e.rowRenderMode,
1370
+ rowVirtualizationEnabled: g(() => e.virtualization.value.rows),
1371
+ columnVirtualizationEnabled: g(() => e.virtualization.value.columns),
1372
+ totalRows: h,
1373
+ visibleColumns: C,
1374
+ sizingColumns: I,
1375
+ normalizedBaseRowHeight: e.normalizedBaseRowHeight,
1376
+ resolveColumnWidth: F,
1377
+ defaultColumnWidth: kl,
1378
+ indexColumnWidth: 0,
1379
+ flexFillOffsetWidth: O.value,
1380
+ rowOverscan: g(() => e.virtualization.value.rowOverscan),
1381
+ columnOverscan: g(() => e.virtualization.value.columnOverscan),
1382
+ measureVisibleRowHeights: () => St(),
1383
+ resolveRowHeight: H.resolveRowHeight,
1384
+ resolveRowOffset: H.resolveRowOffset,
1385
+ resolveRowIndexAtOffset: H.resolveRowIndexAtOffset,
1386
+ resolveTotalRowHeight: H.resolveTotalHeight
1387
+ }), Xe = g(() => (e.rowVersion.value, e.runtime.rowPartition.value, e.runtimeRowModel?.getSnapshot?.().revision ?? e.runtime.api.rows.getSnapshot().revision ?? null)), Ze = (c) => {
1388
+ if ("renderedViewport" in c && c.renderedViewport && (i.value = {
1389
+ startRow: Math.max(0, Math.trunc(c.renderedViewport.start)),
1390
+ endRow: Math.max(Math.max(0, Math.trunc(c.renderedViewport.start)), Math.trunc(c.renderedViewport.end))
1391
+ }, e.reportFillPlumbingDetail?.("centerPaneStoredRenderedViewport", De(i.value))), typeof c.debugJson == "string" && c.debugJson.length > 0)
1392
+ try {
1393
+ const p = JSON.parse(c.debugJson), S = p.renderedViewport?.start, D = p.renderedViewport?.end;
1394
+ i.value == null && Number.isFinite(S) && Number.isFinite(D) && (i.value = {
1395
+ startRow: Math.max(0, Math.trunc(S)),
1396
+ endRow: Math.max(Math.max(0, Math.trunc(S)), Math.trunc(D))
1397
+ }, e.reportFillPlumbingDetail?.("centerPaneStoredRenderedViewport", De(i.value)));
1398
+ } catch {
1399
+ }
1400
+ e.reportCenterPaneDiagnostics?.(c);
1401
+ }, Ut = (c) => Nn(c), Z = b.visualRuntime, Qe = Z.resolveBodyRowIndexById, qt = (c) => {
1402
+ if (!Number.isFinite(c))
1403
+ return null;
1404
+ const p = Math.max(0, Math.trunc(c));
1405
+ if (p < h.value)
1406
+ return Z.getBodyRowAtIndex(p);
1407
+ const S = p - h.value;
1408
+ return e.runtime.rowPartition.value.pinnedBottomRows[S] ?? null;
1409
+ }, {
1410
+ rowStyle: Yt,
1411
+ isRowAutosizeProbe: Un,
1412
+ measureVisibleRowHeights: St,
1413
+ startRowResize: Jt,
1414
+ autosizeRow: Xt,
1415
+ consumeRecentRowResizeInteraction: qn,
1416
+ dispose: Zt
1417
+ } = Nr({
1418
+ mode: e.mode,
1419
+ rowHeightMode: e.rowHeightMode,
1420
+ normalizedBaseRowHeight: e.normalizedBaseRowHeight,
1421
+ viewportRowStart: q,
1422
+ bodyViewportRef: _,
1423
+ runtime: e.runtime,
1424
+ minRowHeight: ia,
1425
+ syncViewport: () => ce()
1426
+ }), et = Wr({
1427
+ mode: e.mode,
1428
+ runtime: {
1429
+ api: Z.api,
1430
+ getBodyRowAtIndex: qt
1431
+ },
1432
+ totalRows: E,
1433
+ visibleColumns: I,
1434
+ viewportRowStart: q,
1435
+ resolveRowIndex: (c) => {
1436
+ const p = oe.value[c];
1437
+ return p && Number.isFinite(p.displayIndex) ? Math.max(0, Math.trunc(p.displayIndex)) : q.value + c;
1438
+ },
1439
+ selectionSnapshot: e.selectionSnapshot,
1440
+ selectionAnchor: e.selectionAnchor,
1441
+ isEditingCell: (c, p) => z(c, p)
1442
+ }), {
1443
+ normalizeRowId: It,
1444
+ normalizeCellCoord: Qt,
1445
+ resolveSelectionRange: fe,
1446
+ resolveSelectionRanges: Mt,
1447
+ resolveCurrentCellCoord: en,
1448
+ applySelectionRange: Ne,
1449
+ applyCellSelectionByCoord: mt,
1450
+ setCellSelection: Yn,
1451
+ clearCellSelection: tn,
1452
+ isCellSelected: nn
1453
+ } = et, Jn = et.isSelectionAnchorCell ?? (() => !1), Xn = et.shouldHighlightSelectedCell ?? ((c, p) => nn(c, p)), Zn = et.isCellOnSelectionEdge ?? (() => !1), xt = g(() => {
1454
+ const c = e.selectionSnapshot.value;
1455
+ if (!c || c.ranges.length === 0)
1456
+ return null;
1457
+ const p = c.activeRangeIndex ?? 0, S = c.ranges[p]?.anchor ?? c.ranges[0]?.anchor ?? null;
1458
+ return !S || typeof S.rowIndex != "number" || typeof S.colIndex != "number" || !Number.isFinite(S.rowIndex) || !Number.isFinite(S.colIndex) ? null : {
1459
+ rowIndex: Math.trunc(S.rowIndex),
1460
+ columnIndex: Math.trunc(S.colIndex)
1461
+ };
1462
+ }), ln = ta({
1463
+ runtime: e.runtime,
1464
+ isPlaceholderRow: b.isPlaceholderRow,
1465
+ rowSelectionColumn: de,
1466
+ orderedVisibleColumns: I,
1467
+ displayRows: oe,
1468
+ rowSelectionSnapshot: r,
1469
+ applyRowSelectionMutation: (c) => {
1470
+ e.runtime.api.rowSelection.hasSupport() && (c(e.runtime.api.rowSelection), l(), a());
1471
+ },
1472
+ viewportRowStart: q,
1473
+ selectionAnchorCell: xt,
1474
+ applySelectionRange: Ne
1475
+ }), {
1476
+ readRowSelectionCell: rn,
1477
+ readRowSelectionDisplayCell: Qn,
1478
+ toggleRowCheckboxSelected: el
1479
+ } = ln, tl = g(() => {
1480
+ const c = `${O.value}px`;
1481
+ return {
1482
+ ...Kn.value,
1483
+ width: c,
1484
+ minWidth: c,
1485
+ maxWidth: c
1486
+ };
1487
+ }), Ft = ea({
1488
+ runtime: e.runtime,
1489
+ cloneRowData: e.cloneRowData,
1490
+ syncViewport: () => ce(),
1491
+ enabled: e.historyEnabled?.value !== !1,
1492
+ maxHistoryDepth: e.historyMaxDepth?.value,
1493
+ history: e.history
1494
+ }), {
1495
+ captureHistorySnapshot: We,
1496
+ captureHistorySnapshotForRowIds: Ue,
1497
+ recordHistoryIntentTransaction: ke,
1498
+ canUndoHistory: nl,
1499
+ canRedoHistory: ll,
1500
+ runHistoryAction: on
1501
+ } = Ft, qe = U(null), xe = U(null), an = g(() => {
1502
+ const c = qe.value;
1503
+ return c?.affectedRange ? [{
1504
+ key: "server-fill-affected-range",
1505
+ ranges: [c.affectedRange],
1506
+ className: "grid-selection-overlay--server-fill",
1507
+ segmentClassName: "grid-selection-overlay__segment--server-fill",
1508
+ borderColor: "color-mix(in srgb, var(--datagrid-accent-strong) 72%, var(--datagrid-text-color) 28%)",
1509
+ backgroundColor: "color-mix(in srgb, var(--datagrid-accent-strong) 10%, transparent)",
1510
+ borderStyle: "solid",
1511
+ hideSingleCell: !1,
1512
+ zIndex: 7
1513
+ }] : [];
1514
+ }), {
1515
+ rowIndexLabel: At,
1516
+ readCell: Fe,
1517
+ readDisplayCell: ie,
1518
+ rowClass: sn,
1519
+ toggleGroupRow: Dt
1520
+ } = Ur({
1521
+ mode: e.mode,
1522
+ runtime: e.runtime,
1523
+ viewportRowStart: q,
1524
+ firstColumnKey: e.firstColumnKey
1525
+ }), ft = Xo({
1526
+ runtime: e.runtime,
1527
+ viewportRowStart: q,
1528
+ ensureEditableRowAtIndex: (c) => b.ensureMaterializedRowAt(c, "toggle"),
1529
+ isRowSelectionColumnKey: A,
1530
+ isRowSelectionColumn: y,
1531
+ isCellEditableByKey: ne,
1532
+ readRowSelectionCell: rn,
1533
+ readRowSelectionDisplayCell: Qn,
1534
+ readCell: Fe,
1535
+ readDisplayCell: ie,
1536
+ toggleRowCheckboxSelected: el,
1537
+ captureHistorySnapshot: We,
1538
+ captureHistorySnapshotForRowIds: Ue,
1539
+ recordHistoryIntentTransaction: ke,
1540
+ syncViewport: () => ce()
1541
+ }), {
1542
+ readStageCell: wt
1543
+ } = ft, Ot = (c, p, S) => b.isPlaceholderRow(c) ? b.isPlaceholderCellEditable(p) : S(), _t = (c, p, S, D) => Ot(
1544
+ c,
1545
+ I.value[D],
1546
+ () => ne(c, p, S, D)
1547
+ ), rl = qr({
1548
+ mode: e.mode,
1549
+ runtime: Z,
1550
+ totalRows: h,
1551
+ visibleColumns: I,
1552
+ viewportRowStart: q,
1553
+ resolveSelectionRange: fe,
1554
+ resolveSelectionRanges: Mt,
1555
+ resolveCurrentCellCoord: en,
1556
+ applySelectionRange: Ne,
1557
+ clearCellSelection: tn,
1558
+ captureRowsSnapshot: We,
1559
+ captureRowsSnapshotForRowIds: Ue,
1560
+ recordEditTransaction: (c, p, S) => {
1561
+ ke({
1562
+ intent: "edit",
1563
+ label: S ?? "Cell edit"
1564
+ }, c, p);
1565
+ },
1566
+ readCell: (c, p) => wt(c, p),
1567
+ readClipboardCell: e.readClipboardCell ? (c, p) => e.readClipboardCell?.(c, p) ?? "" : void 0,
1568
+ isCellEditable: _t,
1569
+ syncViewport: () => ce(),
1570
+ applyClipboardEdits: e.applyClipboardEdits,
1571
+ buildFillMatrixFromRange: e.buildFillMatrixFromRange,
1572
+ buildPasteSpecialMatrixFromRange: e.buildPasteSpecialMatrixFromRange,
1573
+ ensureEditableRowAtIndex: (c) => b.ensureMaterializedRowAt(c, "paste")
1574
+ }), {
1575
+ normalizeClipboardRange: Ee,
1576
+ applyClipboardEdits: tt,
1577
+ rangesEqual: un,
1578
+ buildFillMatrixFromRange: dn,
1579
+ clearPendingClipboardOperation: ol,
1580
+ copySelectedCells: cn,
1581
+ pasteSelectedCells: mn,
1582
+ cutSelectedCells: kt,
1583
+ isCellInPendingClipboardRange: al,
1584
+ isCellOnPendingClipboardEdge: Et
1585
+ } = rl, {
1586
+ ensureKeyboardActiveCellVisible: gt,
1587
+ revealCellInComfortZone: il
1588
+ } = Yr({
1589
+ bodyViewportRef: _,
1590
+ visibleColumns: I,
1591
+ resolveColumnWidth: F,
1592
+ normalizedBaseRowHeight: e.normalizedBaseRowHeight,
1593
+ resolveRowHeight: H.resolveRowHeight,
1594
+ resolveRowOffset: H.resolveRowOffset,
1595
+ indexColumnWidth: O.value,
1596
+ defaultColumnWidth: kl,
1597
+ syncViewport: () => ce()
1598
+ }), {
1599
+ editingCell: sl,
1600
+ editingCellValue: fn,
1601
+ editingCellInitialFilter: wn,
1602
+ editingCellOpenOnMount: Ae,
1603
+ isEditingCell: Pe,
1604
+ startInlineEdit: nt,
1605
+ appendInlineEditTextInput: Ce,
1606
+ commitInlineEdit: Te,
1607
+ cancelInlineEdit: vt,
1608
+ handleEditorKeydown: ul,
1609
+ handleEditorBlur: dl
1610
+ } = Jr({
1611
+ mode: e.mode,
1612
+ bodyViewportRef: _,
1613
+ visibleColumns: I,
1614
+ totalRows: h,
1615
+ runtime: Z,
1616
+ readCell: (c, p) => wt(c, p),
1617
+ resolveRowIndexById: Qe,
1618
+ applyCellSelection: (c) => {
1619
+ mt(c, !1);
1620
+ },
1621
+ ensureActiveCellVisible: (c, p) => {
1622
+ gt(c, p);
1623
+ },
1624
+ isCellEditable: _t,
1625
+ captureRowsSnapshot: We,
1626
+ captureRowsSnapshotForRowIds: Ue,
1627
+ recordEditTransaction: (c, p, S) => {
1628
+ ke({
1629
+ intent: "edit",
1630
+ label: S ?? "Cell edit"
1631
+ }, c, p);
1632
+ },
1633
+ ensureEditableRowAtIndex: (c) => b.ensureMaterializedRowAt(c, "edit"),
1634
+ onCellEdit: e.onCellEdit
1635
+ });
1636
+ z = Pe;
1637
+ const gn = g(() => sl.value);
1638
+ _r(() => {
1639
+ e.reportFillPlumbingState?.("runtime_diagnostics_alive", !0), e.reportFillPlumbingDetail?.("runtime_diagnostics_alive", "yes");
1640
+ });
1641
+ function vn() {
1642
+ const c = e.runtime.api.rows.getSnapshot();
1643
+ return {
1644
+ sortModel: c.sortModel ?? [],
1645
+ filterModel: c.filterModel ?? null,
1646
+ groupBy: c.groupBy ?? null,
1647
+ groupExpansion: c.groupExpansion ?? { expandedByDefault: !1, toggledGroupKeys: [] },
1648
+ treeData: null,
1649
+ pivot: null,
1650
+ pagination: c.pagination ?? {
1651
+ enabled: !1,
1652
+ pageSize: 0,
1653
+ currentPage: 0,
1654
+ pageCount: 0,
1655
+ totalRowCount: 0,
1656
+ startIndex: 0,
1657
+ endIndex: 0
1658
+ }
1659
+ };
1660
+ }
1661
+ function hn() {
1662
+ const c = e.runtimeRowModel?.getSnapshot?.();
1663
+ if (!c)
1664
+ return "none";
1665
+ const p = c.viewportRange;
1666
+ return [
1667
+ `rowCount=${c.rowCount}`,
1668
+ `loading=${c.loading ? "yes" : "no"}`,
1669
+ `viewport=${p.start}..${p.end}`,
1670
+ `revision=${c.revision ?? "none"}`
1671
+ ].join(" ");
1672
+ }
1673
+ function Pt(c) {
1674
+ return !c || c.kind === "group" ? "none" : String(c.row.region ?? c.data.region ?? "none");
1675
+ }
1676
+ function lt(c) {
1677
+ return c ? `${String(c.rowId)}:${Pt(c)}` : "none";
1678
+ }
1679
+ function cl() {
1680
+ const c = oe.value;
1681
+ if (c.length === 0)
1682
+ return null;
1683
+ const p = c[0], S = c[c.length - 1], D = p && Number.isFinite(p.displayIndex) ? Math.max(0, Math.trunc(p.displayIndex)) : null, re = S && Number.isFinite(S.displayIndex) ? Math.max(0, Math.trunc(S.displayIndex)) : null, Y = D ?? q.value, B = re != null ? Math.max(Y, re) : Math.max(Y, Y + c.length - 1);
1684
+ return {
1685
+ startRow: Y,
1686
+ endRow: B,
1687
+ startColumn: 0,
1688
+ endColumn: Math.max(0, e.visibleColumns.value.length - 1)
1689
+ };
1690
+ }
1691
+ function rt(c) {
1692
+ const S = Z.resolveBodyRowIndexById("srv-000025"), D = S >= 0 ? Z.getBodyRowAtIndex(S) : null, re = D && D.kind !== "group" ? String(D.row.region ?? "none") : "none", Y = [
1693
+ Z.getBodyRowAtIndex(0),
1694
+ Z.getBodyRowAtIndex(1),
1695
+ Z.getBodyRowAtIndex(2),
1696
+ Z.getBodyRowAtIndex(3),
1697
+ Z.getBodyRowAtIndex(4)
1698
+ ].filter((ge) => ge != null).map((ge) => String(ge.rowId)).join(", ");
1699
+ e.reportFillPlumbingDetail?.("runtime_viewport_range", `${q.value}..${le.value}`), e.reportFillPlumbingDetail?.("runtime_rowModel_snapshot", hn()), e.reportFillPlumbingDetail?.("runtime_visible_first5", Y || "none"), e.reportFillPlumbingDetail?.("runtime_sample_row25_visible_index", S >= 0 ? String(S) : "none"), e.reportFillPlumbingDetail?.("runtime_sample_row25_region", re);
1700
+ const B = e.runtime.getBodyRowAtIndex(1), $ = e.runtime.syncBodyRowsInRange({
1701
+ start: 0,
1702
+ end: Math.min(23, Math.max(0, e.runtime.rowPartition.value.bodyRowCount - 1))
1703
+ }), be = $.find((ge) => Math.trunc(ge.displayIndex) === 1) ?? $[1] ?? null, ue = e.runtime.getBodyRowAtIndex(1), _e = oe.value[1] ?? null;
1704
+ e.reportFillPlumbingDetail?.(
1705
+ "server_fill_row1_cache_status",
1706
+ B != null && be != null && B === be ? "cache-hit" : "pulled-fresh"
1707
+ ), e.reportFillPlumbingDetail?.("server_fill_row1_sync_value", lt(be)), e.reportFillPlumbingDetail?.("source_body_row1", lt(ue)), e.reportFillPlumbingDetail?.("source_body_row1_identity", [
1708
+ `before=${lt(B)}`,
1709
+ `sameDisplay=${ue != null && _e != null && ue === _e ? "yes" : "no"}`,
1710
+ `sameSync=${ue != null && be != null && ue === be ? "yes" : "no"}`,
1711
+ `revision=${Xe.value ?? "none"}`
1712
+ ].join(" ")), e.reportFillPlumbingDetail?.("source_sync_row1", lt(be)), e.reportFillPlumbingState?.("runtime_redraw_happened", !0), e.reportFillPlumbingDetail?.("runtime_redraw_reason", c);
1713
+ }
1714
+ async function pe(c) {
1715
+ const p = e.runtimeRowModel, S = e.runtime.api.rows, D = i.value ? {
1716
+ startRow: i.value.startRow,
1717
+ endRow: i.value.endRow,
1718
+ endColumn: Math.max(0, e.visibleColumns.value.length - 1)
1719
+ } : null, re = pt.value ? {
1720
+ startRow: pt.value.start,
1721
+ endRow: pt.value.end,
1722
+ endColumn: Math.max(0, e.visibleColumns.value.length - 1)
1723
+ } : null, Y = cl(), B = D ?? re ?? Y ?? {
1724
+ startRow: q.value,
1725
+ endRow: le.value,
1726
+ endColumn: Math.max(0, e.visibleColumns.value.length - 1)
1727
+ };
1728
+ e.reportFillPlumbingDetail?.("server_fill_latest_rendered_viewport", De(i.value)), e.reportFillPlumbingDetail?.("server_fill_runtime_rendered_viewport", ze(re)), e.reportFillPlumbingDetail?.("server_fill_displayrows_rendered_viewport", ze(Y)), e.reportFillPlumbingDetail?.("server_fill_selected_rendered_viewport", ze(B)), e.reportFillPlumbingDetail?.("server_fill_refresh_used_stored_rendered", D ? "yes" : "no");
1729
+ const $ = Tt(c) ?? Tt({
1730
+ startRow: B.startRow,
1731
+ endRow: B.endRow
1732
+ });
1733
+ e.reportFillPlumbingDetail?.("server_fill_raw_invalidation", c ? JSON.stringify(c) : "none"), e.reportFillPlumbingDetail?.("server_fill_invalidation_range", $ ? `${$.start}..${$.end}` : "none"), e.reportFillPlumbingDetail?.("server_fill_normalized_invalidation", $ ? `${$.start}..${$.end}` : "none"), e.reportFillPlumbingDetail?.("server_fill_sync_input_range", ze(B)), e.reportFillPlumbingDetail?.("server_fill_runtime_rowModel_invalidate_type", typeof p?.invalidateRange == "function" ? "function" : typeof p?.invalidateRange);
1734
+ const be = e.runtime.getBodyRowAtIndex(1);
1735
+ let ue = !1;
1736
+ $ && typeof p?.invalidateRange == "function" && (p.invalidateRange($), ue = !0);
1737
+ const _e = e.runtime.getBodyRowAtIndex(1);
1738
+ e.reportFillPlumbingState?.("server_fill_invalidation_called", ue), e.reportFillPlumbingDetail?.("server_fill_cache_row1_before_invalidation", be ? "yes" : "no"), e.reportFillPlumbingDetail?.("server_fill_cache_row1_after_invalidation", _e ? "yes" : "no"), e.reportFillPlumbingState?.("server_fill_invalidation_applied", ue), typeof S.refresh == "function" && await S.refresh(), B && (e.runtime.setViewportRange?.({
1739
+ start: B.startRow,
1740
+ end: B.endRow
1741
+ }), e.reportFillPlumbingDetail?.("server_fill_rendered_viewport", ze(B))), B ? Wn({
1742
+ start: B.startRow,
1743
+ end: B.endRow
1744
+ }) : ce(), await dt(), rt("server-fill-refresh");
1745
+ }
1746
+ function De(c) {
1747
+ return c ? `${c.startRow}..${c.endRow}` : "none";
1748
+ }
1749
+ function ze(c) {
1750
+ return c ? `${c.startRow}..${c.endRow}` : "none";
1751
+ }
1752
+ function Tt(c) {
1753
+ if (!c)
1754
+ return null;
1755
+ const p = c, S = Number.isFinite(p.startRow) ? p.startRow : p.start, D = Number.isFinite(p.endRow) ? p.endRow : p.end, re = Number(S), Y = Number(D ?? S);
1756
+ return !Number.isFinite(re) || !Number.isFinite(Y) ? null : {
1757
+ start: Math.max(0, Math.trunc(re)),
1758
+ end: Math.max(Math.max(0, Math.trunc(re)), Math.trunc(Y))
1759
+ };
1760
+ }
1761
+ function zt(c) {
1762
+ return c ? c.endRow >= q.value && c.startRow <= le.value : !1;
1763
+ }
1764
+ const bn = () => nl() || xe.value === "committed", yn = () => ll() || xe.value === "undone", Rn = (c) => {
1765
+ if (qe.value && (c === "undo" || c === "redo") && (c === "undo" && xe.value === "committed" || c === "redo" && xe.value === "undone")) {
1766
+ const S = qe.value, D = e.runtimeRowModel?.dataSource, re = vn(), Y = c === "undo" ? D?.undoFillOperation : D?.redoFillOperation;
1767
+ if (Y)
1768
+ return Promise.resolve(Y({
1769
+ operationId: S.operationId,
1770
+ revision: S.revision,
1771
+ projection: re
1772
+ })).then(async (B) => {
1773
+ const $ = B?.invalidation?.kind === "range" ? B.invalidation.range : S.affectedRange ?? null;
1774
+ return e.reportFillPlumbingDetail?.("server_fill_affected_range", ze($)), e.reportFillPlumbingDetail?.("server_fill_visible_overlap", zt($) ? "yes" : "no"), await pe($), xe.value = c === "undo" ? "undone" : "committed", S.operationId;
1775
+ });
1776
+ }
1777
+ return on(c);
1778
+ }, ml = async (c, p) => {
1779
+ const S = Ee(c), D = Ee(p);
1780
+ if (!S || !D || un(S, D))
1781
+ return !1;
1782
+ const re = dn(S), Y = S.endRow - S.startRow + 1, B = S.endColumn - S.startColumn + 1, $ = /* @__PURE__ */ new Map();
1783
+ for (let K = 0; K < Y; K += 1) {
1784
+ let G = !1;
1785
+ for (let J = 0; J < B; J += 1)
1786
+ if ((re[K]?.[J] ?? "").length > 0) {
1787
+ G = !0;
1788
+ break;
1789
+ }
1790
+ $.set(D.startRow + K, G);
1791
+ }
1792
+ const be = We(), ue = /* @__PURE__ */ new Map();
1793
+ let _e = 0, ge = 0;
1794
+ const Lt = (K) => {
1795
+ const G = ue.get(K);
1796
+ if (G)
1797
+ return G;
1798
+ const J = {};
1799
+ return ue.set(K, J), J;
1800
+ };
1801
+ for (let K = S.startRow; K <= S.endRow; K += 1) {
1802
+ const G = Z.getBodyRowAtIndex(K);
1803
+ if (!(!G || G.kind === "group" || G.rowId == null || b.isPlaceholderRow(G)))
1804
+ for (let J = S.startColumn; J <= S.endColumn; J += 1) {
1805
+ const ye = I.value[J]?.key;
1806
+ !ye || A(ye) || (Lt(G.rowId)[ye] = "");
1807
+ }
1808
+ }
1809
+ for (let K = D.startRow; K <= D.endRow; K += 1) {
1810
+ let G = Z.getBodyRowAtIndex(K);
1811
+ b.isPlaceholderRow(G) && $.get(K) === !0 && (G = b.ensureMaterializedRowAt(K, "paste"));
1812
+ for (let J = D.startColumn; J <= D.endColumn; J += 1) {
1813
+ const ye = I.value[J]?.key;
1814
+ if (!ye || A(ye))
1815
+ continue;
1816
+ const Dn = K - D.startRow, xl = J - D.startColumn, Fl = re[Dn]?.[xl] ?? "";
1817
+ if (!G || G.kind === "group" || G.rowId == null || b.isPlaceholderRow(G)) {
1818
+ _e += 1;
1819
+ continue;
1820
+ }
1821
+ Lt(G.rowId)[ye] = Fl, ge += 1;
1822
+ }
1823
+ }
1824
+ return ge <= 0 || ue.size === 0 ? !1 : (await e.runtime.api.rows.applyEdits(Array.from(ue.entries()).map(([K, G]) => ({
1825
+ rowId: K,
1826
+ data: G
1827
+ }))), Ne(D), ke({
1828
+ intent: "move",
1829
+ label: _e > 0 ? `Move ${ge} cells (blocked ${_e})` : `Move ${ge} cells`,
1830
+ affectedRange: D
1831
+ }, be), ce(), !0);
1832
+ }, fl = {
1833
+ mode: e.mode,
1834
+ enableFillHandle: e.enableFillHandle,
1835
+ enableRangeMove: e.enableRangeMove,
1836
+ runtime: Z,
1837
+ totalRows: h,
1838
+ visibleColumns: I,
1839
+ viewportRowStart: q,
1840
+ selectionSnapshot: e.selectionSnapshot,
1841
+ bodyViewportRef: _,
1842
+ indexColumnWidth: O.value,
1843
+ resolveColumnWidth: F,
1844
+ resolveRowHeight: H.resolveRowHeight,
1845
+ resolveRowIndexAtOffset: H.resolveRowIndexAtOffset,
1846
+ normalizeRowId: It,
1847
+ normalizeCellCoord: Qt,
1848
+ resolveSelectionRange: fe,
1849
+ applySelectionRange: Ne,
1850
+ applyCellSelectionByCoord: mt,
1851
+ setCellSelection: Yn,
1852
+ clearCellSelection: tn,
1853
+ readCell: (c, p) => wt(c, p),
1854
+ isCellEditable: _t,
1855
+ cloneRowData: e.cloneRowData,
1856
+ resolveRowIndexById: Qe,
1857
+ isRowMaterializedAtIndex: (c) => {
1858
+ const p = Z.getBodyRowAtIndex(c);
1859
+ return !!p && p.__placeholder !== !0;
1860
+ },
1861
+ resolveFillBoundary: (() => {
1862
+ const p = e.runtimeRowModel?.dataSource?.resolveFillBoundary;
1863
+ if (e.reportFillPlumbingState?.("stage_runtime_rowmodel", typeof p == "function"), typeof p == "function")
1864
+ return async (S) => {
1865
+ const D = e.runtime.api.rows.getSnapshot();
1866
+ return p({
1867
+ ...S,
1868
+ projection: {
1869
+ sortModel: D.sortModel ?? [],
1870
+ filterModel: D.filterModel ?? null,
1871
+ groupBy: D.groupBy ?? null,
1872
+ groupExpansion: D.groupExpansion ?? { expandedByDefault: !1, toggledGroupKeys: [] },
1873
+ treeData: null,
1874
+ pivot: null,
1875
+ pagination: D.pagination ?? {
1876
+ enabled: !1,
1877
+ pageSize: 0,
1878
+ currentPage: 0,
1879
+ pageCount: 0,
1880
+ totalRowCount: 0,
1881
+ startIndex: 0,
1882
+ endIndex: 0
1883
+ }
1884
+ }
1885
+ });
1886
+ };
1887
+ })(),
1888
+ runtimeRowModel: e.runtimeRowModel ?? null,
1889
+ reportFillWarning: e.reportFillWarning,
1890
+ reportCenterPaneDiagnostics: Ze,
1891
+ reportFillPlumbingState: e.reportFillPlumbingState,
1892
+ reportFillPlumbingDetail: e.reportFillPlumbingDetail,
1893
+ ensureEditableRowAtIndex: (c) => b.ensureMaterializedRowAt(c, "toggle"),
1894
+ captureRowsSnapshot: We,
1895
+ captureRowsSnapshotForRowIds: Ue,
1896
+ recordIntentTransaction: (c, p, S) => {
1897
+ qe.value = null, xe.value = null, ke(c, p, S);
1898
+ },
1899
+ recordServerFillTransaction: (c) => {
1900
+ Ft.recordServerFillTransaction(c), qe.value = {
1901
+ operationId: c.operationId,
1902
+ revision: c.revision,
1903
+ affectedRange: c.affectedRange ?? null,
1904
+ mode: c.mode
1905
+ }, xe.value = "committed";
1906
+ },
1907
+ clearPendingClipboardOperation: ol,
1908
+ clearExternalPendingClipboardOperation: e.clearExternalPendingClipboardOperation,
1909
+ copySelectedCells: cn,
1910
+ pasteSelectedCells: mn,
1911
+ cutSelectedCells: kt,
1912
+ normalizeClipboardRange: Ee,
1913
+ applyClipboardEdits: tt,
1914
+ rangesEqual: un,
1915
+ buildFillMatrixFromRange: dn,
1916
+ applyRangeMove: e.applyRangeMove ?? ml,
1917
+ refreshServerFillViewport: pe,
1918
+ syncViewport: () => ce(),
1919
+ editingCell: gn,
1920
+ startInlineEdit: nt,
1921
+ appendInlineEditTextInput: Ce,
1922
+ cancelInlineEdit: vt,
1923
+ commitInlineEdit: Te,
1924
+ canUndo: bn,
1925
+ canRedo: yn,
1926
+ runHistoryAction: Rn,
1927
+ ensureKeyboardActiveCellVisible: gt,
1928
+ isContextMenuVisible: e.isContextMenuVisible,
1929
+ closeContextMenu: e.closeContextMenu,
1930
+ openContextMenuFromCurrentCell: e.openContextMenuFromCurrentCell,
1931
+ runRowIndexKeyboardAction: e.runRowIndexKeyboardAction
1932
+ }, Cn = Xr(fl), {
1933
+ isPointerSelectingCells: Ht,
1934
+ isFillDragging: ot,
1935
+ fillPreviewRange: Vt,
1936
+ lastAppliedFill: pn,
1937
+ isRangeMoving: Bt,
1938
+ selectionRange: wl,
1939
+ rangeMovePreviewRange: ht,
1940
+ stopPointerSelection: bt,
1941
+ stopFillSelection: Ye,
1942
+ startFillHandleDrag: gl,
1943
+ startFillHandleDoubleClick: vl,
1944
+ applyLastFillBehavior: hl,
1945
+ handleCellMouseDown: bl,
1946
+ handleCellKeydown: we,
1947
+ handleRowIndexKeydown: yl,
1948
+ handleWindowMouseMove: Sn,
1949
+ handleWindowMouseUp: Rl,
1950
+ isCellInFillPreview: Cl,
1951
+ isFillHandleCell: jt,
1952
+ clearSelectedCells: pl,
1953
+ dispose: se
1954
+ } = Cn, Oe = g(() => Ht.value ? wl.value : null), N = la({
1955
+ runtime: Z,
1956
+ selectionSnapshot: e.selectionSnapshot,
1957
+ totalRows: h,
1958
+ orderedVisibleColumns: I,
1959
+ viewportRowStart: q,
1960
+ applySelectionRange: Ne,
1961
+ handleCellKeydown: we
1962
+ }), {
1963
+ isColumnResizing: me,
1964
+ startResize: In,
1965
+ handleResizeDoubleClick: Sl,
1966
+ applyColumnResizeFromPointer: He,
1967
+ stopColumnResize: Gt,
1968
+ dispose: Il
1969
+ } = Zr({
1970
+ visibleColumns: I,
1971
+ rows: e.rows,
1972
+ persistColumnWidth: (c, p) => {
1973
+ e.runtime.api.columns.setWidth(c, p);
1974
+ },
1975
+ defaultColumnWidth: kl,
1976
+ minColumnWidth: aa,
1977
+ autoSizeSampleLimit: sa,
1978
+ autoSizeCharWidth: 7.2,
1979
+ autoSizeHorizontalPadding: 42,
1980
+ autoSizeMaxWidth: 640,
1981
+ isFillDragging: () => ot.value,
1982
+ stopFillSelection: () => {
1983
+ Ye(!1);
1984
+ },
1985
+ isDragSelecting: () => Ht.value,
1986
+ stopDragSelection: () => {
1987
+ bt();
1988
+ },
1989
+ readCellText: (c, p) => {
1990
+ const S = c[p];
1991
+ return S == null ? "" : String(S);
1992
+ }
1993
+ }), Mn = ra({
1994
+ mode: e.mode,
1995
+ viewportRowStart: q,
1996
+ selectionAnchorCell: xt,
1997
+ fillPreviewRange: Vt,
1998
+ isFillDragging: ot,
1999
+ interactionSelectionRange: Oe,
2000
+ resolveCommittedSelectionRange: fe,
2001
+ resolveCommittedSelectionRanges: Mt,
2002
+ isCommittedSelectionAnchorCell: Jn,
2003
+ isCommittedCellSelected: nn,
2004
+ shouldHighlightCommittedSelectedCell: Xn,
2005
+ isCommittedCellOnSelectionEdge: Zn
2006
+ }), { selectionRange: xn, selectionRanges: Ml } = Mn, Se = Qo({
2007
+ lastAppliedFill: pn,
2008
+ selectionRange: xn,
2009
+ isFillDragging: ot
2010
+ }), Fn = na({
2011
+ bodyViewportRef: _,
2012
+ isColumnResizing: me,
2013
+ applyColumnResizeFromPointer: He,
2014
+ stopColumnResize: Gt,
2015
+ handleInteractionWindowMouseMove: Sn,
2016
+ handleInteractionWindowMouseUp: Rl,
2017
+ syncViewport: Wt
2018
+ }), j = {
2019
+ rowSelection: ln,
2020
+ history: Ft,
2021
+ cellIo: ft,
2022
+ viewportKeyboard: N,
2023
+ visualSelection: Mn,
2024
+ fillAction: Se,
2025
+ scrollSync: Fn
2026
+ }, {
2027
+ tableStageProps: at,
2028
+ tableStageContext: An
2029
+ } = Jo({
2030
+ mode: e.mode,
2031
+ rowHeightMode: e.rowHeightMode,
2032
+ layoutMode: e.layoutMode,
2033
+ chromeSignature: e.chromeSignature,
2034
+ visibleColumns: I,
2035
+ renderedColumns: Vn,
2036
+ displayRows: oe,
2037
+ displayRowsRevision: zn,
2038
+ runtimeRevision: Xe,
2039
+ pinnedBottomRows: Hn,
2040
+ sourceRows: e.sourceRows ?? e.rows,
2041
+ showRowIndex: d,
2042
+ rowHover: g(() => e.rowHover?.value === !0),
2043
+ stripedRows: g(() => e.stripedRows?.value === !0),
2044
+ columnFilterTextByKey: e.columnFilterTextByKey,
2045
+ gridContentStyle: Ln,
2046
+ mainTrackStyle: $n,
2047
+ indexColumnStyle: tl,
2048
+ stageStyle: Ct,
2049
+ bodyShellStyle: Je,
2050
+ topSpacerHeight: Bn,
2051
+ bottomSpacerHeight: jn,
2052
+ viewportRowStart: q,
2053
+ viewportRowEnd: le,
2054
+ virtualRowTotal: h,
2055
+ baseRowHeight: e.normalizedBaseRowHeight,
2056
+ resolveRowHeight: H.resolveRowHeight,
2057
+ resolveRowOffset: H.resolveRowOffset,
2058
+ columnWindowStart: Nt,
2059
+ leftColumnSpacerWidth: ct,
2060
+ rightColumnSpacerWidth: Gn,
2061
+ editingCellValueRef: fn,
2062
+ editingCellInitialFilter: wn,
2063
+ editingCellOpenOnMount: Ae,
2064
+ selectionRange: xn,
2065
+ selectionRanges: Ml,
2066
+ selectionAnchorCell: xt,
2067
+ totalRowCount: h,
2068
+ fillPreviewRange: Vt,
2069
+ rangeMovePreviewRange: ht,
2070
+ customOverlays: an,
2071
+ reportCenterPaneDiagnostics: Ze,
2072
+ fillHandleEnabled: g(() => e.enableFillHandle.value),
2073
+ rangeMoveEnabled: g(() => e.enableRangeMove.value),
2074
+ isFillDragging: ot,
2075
+ isRangeMoving: Bt,
2076
+ headerViewportRef: V,
2077
+ bodyViewportRef: _,
2078
+ columnStyle: Ut,
2079
+ reorderColumnsByHeader: e.reorderColumnsByHeader,
2080
+ toggleSortForColumn: e.toggleSortForColumn,
2081
+ handleHeaderColumnClick: e.handleHeaderColumnClick,
2082
+ sortIndicator: e.sortIndicator,
2083
+ setColumnFilterText: e.setColumnFilterText,
2084
+ columnMenuEnabled: e.columnMenuEnabled,
2085
+ columnMenuTrigger: e.columnMenuTrigger,
2086
+ columnMenuValueFilterEnabled: e.columnMenuValueFilterEnabled,
2087
+ columnMenuValueFilterRowLimit: e.columnMenuValueFilterRowLimit,
2088
+ columnMenuMaxFilterValues: e.columnMenuMaxFilterValues,
2089
+ resolveColumnMenuItems: e.resolveColumnMenuItems,
2090
+ resolveColumnMenuDisabledItems: e.resolveColumnMenuDisabledItems,
2091
+ resolveColumnMenuDisabledReasons: e.resolveColumnMenuDisabledReasons,
2092
+ resolveColumnMenuLabels: e.resolveColumnMenuLabels,
2093
+ resolveColumnMenuActionOptions: e.resolveColumnMenuActionOptions,
2094
+ resolveColumnMenuCustomItems: e.resolveColumnMenuCustomItems,
2095
+ isColumnFilterActive: e.isColumnFilterActive,
2096
+ isColumnGrouped: e.isColumnGrouped,
2097
+ resolveColumnGroupOrder: e.resolveColumnGroupOrder,
2098
+ resolveColumnMenuSortDirection: e.resolveColumnMenuSortDirection,
2099
+ resolveColumnMenuSelectedTokens: e.resolveColumnMenuSelectedTokens,
2100
+ resolveColumnMenuValueEntries: e.resolveColumnMenuValueEntries,
2101
+ applyColumnMenuSort: e.applyColumnMenuSort,
2102
+ applyColumnMenuPin: e.applyColumnMenuPin,
2103
+ applyColumnMenuGroupBy: e.applyColumnMenuGroupBy,
2104
+ applyColumnMenuFilter: e.applyColumnMenuFilter,
2105
+ clearColumnMenuFilter: e.clearColumnMenuFilter,
2106
+ handleHeaderWheel: j.scrollSync.handleHeaderWheel,
2107
+ handleHeaderScroll: j.scrollSync.handleHeaderScroll,
2108
+ handleViewportScroll: Wt,
2109
+ handleViewportKeydown: j.viewportKeyboard.handleViewportKeydown,
2110
+ rowClass: sn,
2111
+ isRowAutosizeProbe: Un,
2112
+ rowStyle: Yt,
2113
+ isRowInPendingClipboardCut: e.isRowInPendingClipboardCut,
2114
+ isRowFocused: j.rowSelection.isRowFocused,
2115
+ isRowCheckboxSelected: j.rowSelection.isRowCheckboxSelected,
2116
+ allVisibleRowsSelected: j.rowSelection.areAllVisibleRowsSelected,
2117
+ someVisibleRowsSelected: j.rowSelection.areSomeVisibleRowsSelected,
2118
+ handleRowClick: j.rowSelection.focusRow,
2119
+ handleRowIndexClick: j.rowSelection.selectRowRange,
2120
+ handleRowIndexKeydown: yl,
2121
+ reorderRowsByIndex: e.reorderRowsByIndex,
2122
+ handleToggleAllVisibleRows: j.rowSelection.toggleVisibleRowsSelected,
2123
+ toggleGroupRow: Dt,
2124
+ rowIndexLabel: At,
2125
+ startResize: In,
2126
+ handleResizeDoubleClick: Sl,
2127
+ startRowResize: Jt,
2128
+ autosizeRow: Xt,
2129
+ isCellSelected: j.visualSelection.isCellSelected,
2130
+ isSelectionAnchorCell: j.visualSelection.isSelectionAnchorCell,
2131
+ shouldHighlightSelectedCell: j.visualSelection.shouldHighlightSelectedCell,
2132
+ isCellOnSelectionEdge: j.visualSelection.isCellOnSelectionEdge,
2133
+ isCellInFillPreview: Cl,
2134
+ isCellInPendingClipboardRange: al,
2135
+ isCellOnPendingClipboardEdge: Et,
2136
+ isEditingCell: Pe,
2137
+ isCellEditable: (c, p, S, D) => Ot(
2138
+ c,
2139
+ S,
2140
+ () => x(c, q.value + p, S)
2141
+ ),
2142
+ handleCellMouseDown: bl,
2143
+ handleCellClick: j.cellIo.handleCellClick,
2144
+ handleCellKeydown: we,
2145
+ startInlineEdit: nt,
2146
+ isFillHandleCell: jt,
2147
+ startFillHandleDrag: gl,
2148
+ startFillHandleDoubleClick: vl,
2149
+ fillActionAnchorCell: j.fillAction.fillActionAnchorCell,
2150
+ fillActionBehavior: j.fillAction.fillActionBehavior,
2151
+ applyFillActionBehavior: hl,
2152
+ handleEditorKeydown: ul,
2153
+ handleEditorBlur: dl,
2154
+ commitInlineEdit: Te,
2155
+ cancelInlineEdit: vt,
2156
+ readCell: j.cellIo.readStageCell,
2157
+ readDisplayCell: j.cellIo.readStageDisplayCell,
2158
+ cellClass: e.cellClass ? (c, p, S, D) => e.cellClass?.(
2159
+ c,
2160
+ q.value + p,
2161
+ S,
2162
+ D
2163
+ ) : void 0,
2164
+ cellStyle: e.cellStyle ? (c, p, S, D) => e.cellStyle?.(
2165
+ c,
2166
+ q.value + p,
2167
+ S,
2168
+ D
2169
+ ) : void 0
2170
+ });
2171
+ return Qr({
2172
+ mode: e.mode,
2173
+ rows: e.rows,
2174
+ runtime: e.runtime,
2175
+ totalRows: h,
2176
+ rowVersion: e.rowVersion,
2177
+ rowHeightMode: e.rowHeightMode,
2178
+ normalizedBaseRowHeight: e.normalizedBaseRowHeight,
2179
+ syncSelectionSnapshotFromRuntime: e.syncSelectionSnapshotFromRuntime,
2180
+ syncRowSelectionSnapshotFromRuntime: l,
2181
+ syncViewport: ce,
2182
+ scheduleViewportSync: Ke,
2183
+ measureVisibleRowHeights: St,
2184
+ applyRowHeightSettings: e.applyRowHeightSettings
2185
+ }), eo({
2186
+ bodyViewportRef: _,
2187
+ syncViewport: ce,
2188
+ handleWindowMouseMove: j.scrollSync.handleWindowMouseMove,
2189
+ handleWindowMouseUp: j.scrollSync.handleWindowMouseUp,
2190
+ cancelScheduledViewportSync: X,
2191
+ onAfterMount: () => {
2192
+ e.syncSelectionSnapshotFromRuntime(), l(), dt(() => {
2193
+ e.applyRowHeightSettings(), ce();
2194
+ });
2195
+ },
2196
+ dispose: [
2197
+ Zt,
2198
+ Il,
2199
+ se,
2200
+ j.history.disposeIntentHistory
2201
+ ]
2202
+ }), {
2203
+ tableStageProps: at,
2204
+ tableStageContext: An,
2205
+ historyController: {
2206
+ canUndo: bn,
2207
+ canRedo: yn,
2208
+ runHistoryAction: Rn
2209
+ },
2210
+ syncViewportFromDom: ce,
2211
+ copySelectedCells: cn,
2212
+ pasteSelectedCells: mn,
2213
+ cutSelectedCells: kt,
2214
+ clearSelectedCells: pl,
2215
+ captureHistorySnapshot: We,
2216
+ captureHistorySnapshotForRowIds: Ue,
2217
+ recordHistoryIntentTransaction: ke,
2218
+ revealCellInComfortZone: il
2219
+ };
2220
+ }
2221
+ function Vl(e) {
2222
+ return e === "or" ? "or" : "and";
2223
+ }
2224
+ function Yl(e) {
2225
+ return e == null ? "" : e instanceof Date ? e.toISOString() : Array.isArray(e) ? e.map((l) => Yl(l)).filter((l) => l.length > 0).join(", ") : String(e);
2226
+ }
2227
+ function da(e) {
2228
+ const l = e.indexOf(":");
2229
+ if (l > 0) {
2230
+ const a = e.slice(0, l);
2231
+ if (/^[a-z-]+$/i.test(a))
2232
+ return e.slice(l + 1);
2233
+ }
2234
+ return e;
2235
+ }
2236
+ function ca(e) {
2237
+ const l = [];
2238
+ for (const [a, r] of Object.entries(e.columnFilters ?? {})) {
2239
+ if (!r)
2240
+ continue;
2241
+ if (r.kind === "valueSet") {
2242
+ const d = Array.from(new Set(
2243
+ (r.tokens ?? []).map((w) => da(String(w ?? ""))).map((w) => w.trim()).filter((w) => w.length > 0)
2244
+ ));
2245
+ if (d.length === 0)
2246
+ continue;
2247
+ l.push({
2248
+ id: l.length,
2249
+ join: "and",
2250
+ columnKey: a,
2251
+ operator: "in",
2252
+ value: d.join(", ")
2253
+ });
2254
+ continue;
2255
+ }
2256
+ const i = [r.value, r.value2].map((d) => Yl(d)).filter((d) => d.length > 0);
2257
+ i.length !== 0 && l.push({
2258
+ id: l.length,
2259
+ join: "and",
2260
+ columnKey: a,
2261
+ operator: String(r.operator ?? "contains"),
2262
+ value: i.join(", ")
2263
+ });
2264
+ }
2265
+ return l;
2266
+ }
2267
+ function Sr(e) {
2268
+ if (!e || e.kind === "not")
2269
+ return [];
2270
+ if (e.kind === "condition")
2271
+ return [{
2272
+ id: 0,
2273
+ join: "and",
2274
+ columnKey: String(e.key ?? e.field ?? ""),
2275
+ operator: String(e.operator ?? "contains"),
2276
+ value: Yl(e.value)
2277
+ }];
2278
+ const l = [];
2279
+ for (let a = 0; a < e.children.length; a += 1) {
2280
+ const r = e.children[a];
2281
+ if (!r)
2282
+ continue;
2283
+ const i = Sr(r);
2284
+ if (i.length === 0)
2285
+ continue;
2286
+ const d = i[0];
2287
+ a > 0 && d && (i[0] = {
2288
+ ...d,
2289
+ id: d.id,
2290
+ join: Vl(e.operator)
2291
+ }), l.push(...i);
2292
+ }
2293
+ return l;
2294
+ }
2295
+ function or(e) {
2296
+ if (!e)
2297
+ return [];
2298
+ const l = ca(e), a = e.advancedExpression ?? Br(e.advancedFilters), r = Sr(a ?? null);
2299
+ return [
2300
+ ...l,
2301
+ ...r.map((d, w) => l.length > 0 && w === 0 ? {
2302
+ ...d,
2303
+ join: Vl("and")
2304
+ } : d)
2305
+ ].map((d, w) => ({
2306
+ ...d,
2307
+ id: w,
2308
+ join: w === 0 ? Vl("and") : d.join
2309
+ }));
2310
+ }
2311
+ const ma = $l(() => import("./DataGridAdvancedFilterPopover-C_MjEKFo.js")), fa = $l(() => import("./DataGridAggregationsPopover-C8kdwv0O.js")), wa = $l(() => import("./DataGridFindReplacePopover-Dou8Fsm3.js")), ga = "__AFFINO_DATAGRID_PERF__", ar = 50;
2312
+ function va(e) {
2313
+ return {
2314
+ ...e,
2315
+ component: kr(Er(e.component))
2316
+ };
2317
+ }
2318
+ function st() {
2319
+ return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
2320
+ }
2321
+ function ir(e) {
2322
+ if (typeof window > "u")
2323
+ return;
2324
+ window[ga]?.push?.(e);
2325
+ }
2326
+ function El(e) {
2327
+ if (typeof window < "u" && typeof window.requestAnimationFrame == "function")
2328
+ return window.requestAnimationFrame(e);
2329
+ const l = globalThis.setTimeout(e, 0);
2330
+ return Number(l);
2331
+ }
2332
+ function ha(e) {
2333
+ if (e !== null) {
2334
+ if (typeof window < "u" && typeof window.cancelAnimationFrame == "function") {
2335
+ window.cancelAnimationFrame(e);
2336
+ return;
2337
+ }
2338
+ globalThis.clearTimeout(e);
2339
+ }
2340
+ }
2341
+ function ba(e, l) {
2342
+ if (!e)
2343
+ return l ?? null;
2344
+ if (!l)
2345
+ return e;
2346
+ const a = {}, r = (i) => {
2347
+ if (typeof i == "string") {
2348
+ for (const d of i.split(/\s+/).filter(Boolean))
2349
+ a[d] = !0;
2350
+ return;
2351
+ }
2352
+ if (Array.isArray(i)) {
2353
+ for (const d of i)
2354
+ if (typeof d == "string")
2355
+ for (const w of d.split(/\s+/).filter(Boolean))
2356
+ a[w] = !0;
2357
+ return;
2358
+ }
2359
+ for (const [d, w] of Object.entries(i))
2360
+ a[d] = w === !0 || a[d] === !0;
2361
+ };
2362
+ return r(e), r(l), Object.keys(a).length > 0 ? a : null;
2363
+ }
2364
+ function ya(e) {
2365
+ return Number.isFinite(e) ? Math.max(24, Math.trunc(e)) : 31;
2366
+ }
2367
+ function sr(e) {
2368
+ return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/\\/g, "\\\\").replace(/\"/g, '\\"');
2369
+ }
2370
+ function ur(e) {
2371
+ return (e ?? []).map((l) => ({
2372
+ key: l.key,
2373
+ direction: l.direction
2374
+ }));
2375
+ }
2376
+ function Bl() {
2377
+ return {
2378
+ columnFilters: {},
2379
+ advancedFilters: {},
2380
+ advancedExpression: null
2381
+ };
2382
+ }
2383
+ function ut(e) {
2384
+ return Gr(e ?? Bl()) ?? Bl();
2385
+ }
2386
+ function jl(e) {
2387
+ return e.startsWith("string:") ? `string:${e.slice(7).toLowerCase()}` : e;
2388
+ }
2389
+ function Ra(e) {
2390
+ const l = {};
2391
+ for (const [i, d] of Object.entries(e.columnFilters ?? {})) {
2392
+ if (d.kind === "valueSet") {
2393
+ const w = Array.from(new Set(
2394
+ (d.tokens ?? []).map((b) => jl(String(b ?? ""))).filter((b) => b.length > 0)
2395
+ ));
2396
+ if (w.length === 0)
2397
+ continue;
2398
+ l[i] = {
2399
+ kind: "valueSet",
2400
+ tokens: w
2401
+ };
2402
+ continue;
2403
+ }
2404
+ l[i] = {
2405
+ kind: "predicate",
2406
+ operator: d.operator,
2407
+ value: d.value,
2408
+ value2: d.value2,
2409
+ caseSensitive: d.caseSensitive
2410
+ };
2411
+ }
2412
+ const a = { ...e.advancedFilters ?? {} }, r = e.advancedExpression ?? null;
2413
+ return Object.keys(l).length === 0 && Object.keys(a).length === 0 && !r ? null : {
2414
+ columnFilters: l,
2415
+ advancedFilters: a,
2416
+ advancedExpression: r
2417
+ };
2418
+ }
2419
+ function Ca(e) {
2420
+ const l = {}, a = e?.columnFilters ?? {};
2421
+ for (const [r, i] of Object.entries(a))
2422
+ i?.kind === "predicate" && typeof i.value == "string" && (l[r] = i.value);
2423
+ return l;
2424
+ }
2425
+ function Me(e) {
2426
+ if (typeof globalThis.structuredClone == "function")
2427
+ try {
2428
+ return globalThis.structuredClone(e);
2429
+ } catch {
2430
+ }
2431
+ return Gl(e, /* @__PURE__ */ new WeakMap());
2432
+ }
2433
+ function Gl(e, l) {
2434
+ if (e == null || typeof e != "object")
2435
+ return e;
2436
+ if (e instanceof Date)
2437
+ return new Date(e.getTime());
2438
+ if (Array.isArray(e)) {
2439
+ if (l.has(e))
2440
+ return l.get(e);
2441
+ const a = [];
2442
+ l.set(e, a);
2443
+ for (const r of e)
2444
+ a.push(Gl(r, l));
2445
+ return a;
2446
+ }
2447
+ if (Ir(e)) {
2448
+ if (l.has(e))
2449
+ return l.get(e);
2450
+ const a = {};
2451
+ l.set(e, a);
2452
+ for (const [r, i] of Object.entries(e))
2453
+ a[r] = Gl(i, l);
2454
+ return a;
2455
+ }
2456
+ return e && typeof e == "object" ? { ...e } : e;
2457
+ }
2458
+ function Ir(e) {
2459
+ if (!e || typeof e != "object")
2460
+ return !1;
2461
+ const l = Object.getPrototypeOf(e);
2462
+ return l === Object.prototype || l === null;
2463
+ }
2464
+ function pa(e) {
2465
+ const l = /* @__PURE__ */ new WeakSet();
2466
+ try {
2467
+ return JSON.stringify(e, (a, r) => {
2468
+ if (r == null || typeof r != "object")
2469
+ return r;
2470
+ if (r instanceof Date)
2471
+ return r.toISOString();
2472
+ if (Array.isArray(r) || Ir(r))
2473
+ return l.has(r) ? void 0 : (l.add(r), r);
2474
+ });
2475
+ } catch {
2476
+ return null;
2477
+ }
2478
+ }
2479
+ function Kt(e) {
2480
+ return e ? {
2481
+ columns: e.columns.map((l) => ({ ...l })),
2482
+ basis: e.basis === "source" ? "source" : "filtered"
2483
+ } : null;
2484
+ }
2485
+ function Sa(e) {
2486
+ return e ? {
2487
+ fields: [...e.fields],
2488
+ expandedByDefault: e.expandedByDefault
2489
+ } : null;
2490
+ }
2491
+ function Ge(e) {
2492
+ return e == null ? "blank" : e instanceof Date ? e.toISOString() : typeof e == "string" ? `"${e}"` : String(e);
2493
+ }
2494
+ function Le(e, l) {
2495
+ return wo(l, e);
2496
+ }
2497
+ function Ia(e, l) {
2498
+ const a = String(e ?? "");
2499
+ if (a === "null")
2500
+ return l.blankValueLabel;
2501
+ const r = a.indexOf(":");
2502
+ if (r < 0)
2503
+ return a;
2504
+ const i = a.slice(0, r), d = a.slice(r + 1);
2505
+ return i === "string" || i === "number" || i === "boolean" || i === "bigint" || i === "date" || i === "repr" || i === "json" ? d : a;
2506
+ }
2507
+ function Ma(e, l, a) {
2508
+ return l.kind === "valueSet" ? l.tokens.length === 1 ? `${e}: ${Ia(l.tokens[0] ?? "", a)}` : `${e}: ${l.tokens.length} ${a.valuesSummaryLabel}` : l.operator === "between" ? `${e} ${Le(l.operator, a)} ${Ge(l.value)} ${a.betweenJoiner} ${Ge(l.value2)}` : l.operator === "isEmpty" || l.operator === "notEmpty" || l.operator === "isNull" || l.operator === "notNull" ? `${e} ${Le(l.operator, a)}` : `${e} ${Le(l.operator, a)} ${Ge(l.value)}`;
2509
+ }
2510
+ function xa(e, l, a) {
2511
+ const r = l.clauses.map((i, d) => {
2512
+ const w = i.join === "or" ? a.joins.or : a.joins.and, b = d === 0 ? "" : `${w} `;
2513
+ return i.operator === "between" ? `${b}${Le(i.operator, a)} ${Ge(i.value)} ${a.betweenJoiner} ${Ge(i.value2)}` : i.operator === "isEmpty" || i.operator === "notEmpty" || i.operator === "isNull" || i.operator === "notNull" ? `${b}${Le(i.operator, a)}` : `${b}${Le(i.operator, a)} ${Ge(i.value)}`;
2514
+ }).filter((i) => i.length > 0);
2515
+ return r.length === 0 ? `${e}: ${a.activeSummaryFallback}` : `${e} ${r.join(" ")}`;
2516
+ }
2517
+ function Ll(e, l, a) {
2518
+ if (e.kind === "condition") {
2519
+ const i = l(e.key);
2520
+ return e.operator === "between" ? `${i} ${Le(e.operator, a)} ${Ge(e.value)} ${a.betweenJoiner} ${Ge(e.value2)}` : e.operator === "isEmpty" || e.operator === "notEmpty" || e.operator === "isNull" || e.operator === "notNull" ? `${i} ${Le(e.operator, a)}` : `${i} ${Le(e.operator, a)} ${Ge(e.value)}`;
2521
+ }
2522
+ if (e.kind === "not")
2523
+ return `${a.notOperatorLabel} (${Ll(e.child, l, a)})`;
2524
+ const r = e.operator === "or" ? a.joins.or : a.joins.and;
2525
+ return e.children.map((i) => Ll(i, l, a)).filter((i) => i.length > 0).join(` ${r} `);
2526
+ }
2527
+ function dr(e, l) {
2528
+ return l.activeSummaryPrefix.length > 0 ? `${l.activeSummaryPrefix}: ${e}` : e;
2529
+ }
2530
+ const Fa = [
2531
+ "sum",
2532
+ "avg",
2533
+ "min",
2534
+ "max",
2535
+ "count",
2536
+ "countNonNull",
2537
+ "first",
2538
+ "last"
2539
+ ], Aa = [
2540
+ "min",
2541
+ "max",
2542
+ "count",
2543
+ "countNonNull",
2544
+ "first",
2545
+ "last"
2546
+ ], Da = [
2547
+ "count",
2548
+ "countNonNull",
2549
+ "first",
2550
+ "last"
2551
+ ];
2552
+ function Oa(e) {
2553
+ return e === "number" || e === "currency" || e === "percent" ? Fa : e === "date" || e === "datetime" ? Aa : Da;
2554
+ }
2555
+ const _a = {
2556
+ clipboard: ["cut", "copy", "paste"],
2557
+ pasteSpecial: ["paste-values"],
2558
+ edit: ["clear"]
2559
+ }, ka = {
2560
+ insert: ["insert-row-above", "insert-row-below"],
2561
+ clipboard: ["cut-row", "copy-row", "paste-row"],
2562
+ selection: ["delete-selected-rows"]
2563
+ }, cr = {
2564
+ cut: "Cut",
2565
+ copy: "Copy",
2566
+ paste: "Paste",
2567
+ "paste-values": "Values only",
2568
+ clear: "Clear values",
2569
+ "insert-row-above": "Insert above",
2570
+ "insert-row-below": "Insert below",
2571
+ "copy-row": "Copy row",
2572
+ "paste-row": "Paste row",
2573
+ "cut-row": "Cut row",
2574
+ "delete-selected-rows": "Delete selected rows",
2575
+ "sort-asc": "Sort ascending",
2576
+ "sort-desc": "Sort descending",
2577
+ "sort-clear": "Clear sort",
2578
+ filter: "Filter column",
2579
+ "auto-size": "Auto size column"
2580
+ }, Ea = {
2581
+ "insert-row-above": "Insert / Ctrl/Cmd+I",
2582
+ "copy-row": "Ctrl/Cmd+C",
2583
+ "paste-row": "Ctrl/Cmd+V",
2584
+ "cut-row": "Ctrl/Cmd+X"
2585
+ }, oi = Pn({
2586
+ name: "DataGridDefaultRenderer",
2587
+ props: {
2588
+ mode: {
2589
+ type: String,
2590
+ required: !0
2591
+ },
2592
+ rows: {
2593
+ type: Array,
2594
+ default: () => []
2595
+ },
2596
+ runtime: {
2597
+ type: Object,
2598
+ required: !0
2599
+ },
2600
+ runtimeRowModel: {
2601
+ type: Object,
2602
+ required: !0
2603
+ },
2604
+ reportFillWarning: {
2605
+ type: Function,
2606
+ default: void 0
2607
+ },
2608
+ reportCenterPaneDiagnostics: {
2609
+ type: Function,
2610
+ default: void 0
2611
+ },
2612
+ reportFillPlumbingState: {
2613
+ type: Function,
2614
+ default: void 0
2615
+ },
2616
+ reportFillPlumbingDetail: {
2617
+ type: Function,
2618
+ default: void 0
2619
+ },
2620
+ selectionSnapshot: {
2621
+ type: Object,
2622
+ required: !0
2623
+ },
2624
+ selectionAnchor: {
2625
+ type: Object,
2626
+ required: !0
2627
+ },
2628
+ rowSelectionSnapshot: {
2629
+ type: Object,
2630
+ required: !0
2631
+ },
2632
+ onCellEdit: {
2633
+ type: Function,
2634
+ default: void 0
2635
+ },
2636
+ syncSelectionSnapshotFromRuntime: {
2637
+ type: Function,
2638
+ required: !0
2639
+ },
2640
+ syncRowSelectionSnapshotFromRuntime: {
2641
+ type: Function,
2642
+ default: () => {
2643
+ }
2644
+ },
2645
+ flushRowSelectionSnapshotUpdates: {
2646
+ type: Function,
2647
+ default: () => {
2648
+ }
2649
+ },
2650
+ sortModel: {
2651
+ type: Array,
2652
+ default: void 0
2653
+ },
2654
+ filterModel: {
2655
+ type: Object,
2656
+ default: void 0
2657
+ },
2658
+ groupBy: {
2659
+ type: Object,
2660
+ default: void 0
2661
+ },
2662
+ pivotModel: {
2663
+ type: Object,
2664
+ default: void 0
2665
+ },
2666
+ renderMode: {
2667
+ type: String,
2668
+ default: "virtualization"
2669
+ },
2670
+ virtualization: {
2671
+ type: Object,
2672
+ required: !0
2673
+ },
2674
+ columnMenu: {
2675
+ type: Object,
2676
+ required: !0
2677
+ },
2678
+ cellMenu: {
2679
+ type: Object,
2680
+ required: !0
2681
+ },
2682
+ rowIndexMenu: {
2683
+ type: Object,
2684
+ required: !0
2685
+ },
2686
+ columnLayout: {
2687
+ type: Object,
2688
+ required: !0
2689
+ },
2690
+ columnReorder: {
2691
+ type: Object,
2692
+ required: !0
2693
+ },
2694
+ aggregations: {
2695
+ type: Object,
2696
+ required: !0
2697
+ },
2698
+ advancedFilter: {
2699
+ type: Object,
2700
+ required: !0
2701
+ },
2702
+ findReplace: {
2703
+ type: Object,
2704
+ required: !0
2705
+ },
2706
+ gridLines: {
2707
+ type: Object,
2708
+ required: !0
2709
+ },
2710
+ rowHeightMode: {
2711
+ type: String,
2712
+ default: "fixed"
2713
+ },
2714
+ baseRowHeight: {
2715
+ type: Number,
2716
+ default: 31
2717
+ },
2718
+ layoutMode: {
2719
+ type: String,
2720
+ default: "fill"
2721
+ },
2722
+ minRows: {
2723
+ type: Number,
2724
+ default: null
2725
+ },
2726
+ maxRows: {
2727
+ type: Number,
2728
+ default: null
2729
+ },
2730
+ placeholderRows: {
2731
+ type: Object,
2732
+ required: !0
2733
+ },
2734
+ fillHandle: {
2735
+ type: Boolean,
2736
+ default: !1
2737
+ },
2738
+ rangeMove: {
2739
+ type: Boolean,
2740
+ default: !1
2741
+ },
2742
+ rowHover: {
2743
+ type: Boolean,
2744
+ default: !1
2745
+ },
2746
+ stripedRows: {
2747
+ type: Boolean,
2748
+ default: !1
2749
+ },
2750
+ readSelectionCell: {
2751
+ type: Function,
2752
+ default: void 0
2753
+ },
2754
+ cellClass: {
2755
+ type: Function,
2756
+ default: void 0
2757
+ },
2758
+ cellStyle: {
2759
+ type: Function,
2760
+ default: void 0
2761
+ },
2762
+ showRowIndex: {
2763
+ type: Boolean,
2764
+ default: !0
2765
+ },
2766
+ rowSelection: {
2767
+ type: Boolean,
2768
+ default: !0
2769
+ },
2770
+ rowReorder: {
2771
+ type: Object,
2772
+ required: !0
2773
+ },
2774
+ isCellEditable: {
2775
+ type: Function,
2776
+ default: void 0
2777
+ },
2778
+ viewMode: {
2779
+ type: String,
2780
+ default: "table"
2781
+ },
2782
+ gantt: {
2783
+ type: [Boolean, Object],
2784
+ default: void 0
2785
+ },
2786
+ toolbarModules: {
2787
+ type: Array,
2788
+ default: () => []
2789
+ },
2790
+ customOverlays: {
2791
+ type: Array,
2792
+ default: void 0
2793
+ },
2794
+ history: {
2795
+ type: Object,
2796
+ required: !0
2797
+ },
2798
+ chrome: {
2799
+ type: Object,
2800
+ required: !0
2801
+ },
2802
+ registerHistoryController: {
2803
+ type: Function,
2804
+ default: () => {
2805
+ }
2806
+ },
2807
+ reportToolbarModules: {
2808
+ type: Function,
2809
+ default: () => {
2810
+ }
2811
+ },
2812
+ runStructuralRowAction: {
2813
+ type: Function,
2814
+ default: void 0
2815
+ },
2816
+ registerStructuralRowActionRunner: {
2817
+ type: Function,
2818
+ default: () => {
2819
+ }
2820
+ },
2821
+ inspectorPanel: {
2822
+ type: Object,
2823
+ default: null
2824
+ }
2825
+ },
2826
+ setup(e) {
2827
+ const l = g(() => ({
2828
+ "--datagrid-row-divider-size": e.gridLines.bodyRows ? "1px" : "0px",
2829
+ "--datagrid-column-divider-size": e.gridLines.bodyColumns ? "1px" : "0px",
2830
+ "--datagrid-header-column-divider-size": e.gridLines.headerColumns ? "1px" : "0px",
2831
+ "--datagrid-pinned-pane-separator-size": e.gridLines.pinnedSeparators ? "2px" : "0px",
2832
+ "--datagrid-app-layout-gap": `${e.chrome.toolbarGap}px`,
2833
+ "--datagrid-app-workspace-gap": `${e.chrome.workspaceGap}px`,
2834
+ "--datagrid-app-toolbar-gap": e.chrome.density === "compact" ? "10px" : "12px",
2835
+ "--datagrid-app-toolbar-group-gap": e.chrome.density === "compact" ? "6px" : "8px",
2836
+ "--datagrid-app-toolbar-button-gap": e.chrome.density === "compact" ? "6px" : "8px",
2837
+ "--datagrid-app-toolbar-button-height": e.chrome.density === "compact" ? "28px" : "32px",
2838
+ "--datagrid-app-toolbar-button-padding-inline": e.chrome.density === "compact" ? "10px" : "12px",
2839
+ "--datagrid-app-toolbar-button-font-size": e.chrome.density === "compact" ? "11px" : "12px",
2840
+ "--datagrid-app-toolbar-surface-padding-block": e.chrome.density === "compact" ? "8px" : "10px",
2841
+ "--datagrid-app-toolbar-surface-padding-inline": e.chrome.density === "compact" ? "10px" : "12px"
2842
+ })), a = g(() => [
2843
+ e.gridLines.body,
2844
+ e.gridLines.header,
2845
+ e.gridLines.pinnedSeparators ? "sep:1" : "sep:0"
2846
+ ].join("|")), r = U(0), i = U(ur(e.sortModel)), d = U(null);
2847
+ let w = null, b = 0;
2848
+ const h = U(ut(e.filterModel)), E = g(() => Ca(h.value));
2849
+ let O = "";
2850
+ const L = () => {
2851
+ const t = e.runtimeRowModel.getSnapshot();
2852
+ return [
2853
+ t.kind,
2854
+ t.revision ?? "",
2855
+ t.rowCount,
2856
+ t.loading ? 1 : 0,
2857
+ t.projection?.recomputeVersion ?? t.projection?.version ?? ""
2858
+ ].join("|");
2859
+ };
2860
+ O = L();
2861
+ const I = e.runtimeRowModel.subscribe(() => {
2862
+ const t = L();
2863
+ t !== O && (O = t, r.value += 1);
2864
+ });
2865
+ Zl(() => {
2866
+ I(), ke();
2867
+ }), te(
2868
+ () => e.sortModel,
2869
+ (t) => {
2870
+ i.value = ur(t);
2871
+ },
2872
+ { deep: !0 }
2873
+ ), te(
2874
+ () => e.filterModel,
2875
+ (t) => {
2876
+ h.value = ut(t);
2877
+ },
2878
+ { deep: !0 }
2879
+ ), te(
2880
+ r,
2881
+ () => {
2882
+ e.filterModel === void 0 && (h.value = ut(e.runtime.api.rows.getSnapshot().filterModel ?? null));
2883
+ },
2884
+ { immediate: !0 }
2885
+ );
2886
+ const C = g(() => e.mode), F = g(() => e.rows), A = g(() => (r.value, e.runtime.api.rows.getSnapshot().rowCount)), y = g(() => e.runtime.columnSnapshot.value.visibleColumns), x = g(() => e.runtime.columnSnapshot.value.columns ?? []), ne = g(() => y.value.filter((t) => t.visible !== !1).map((t) => ({
2887
+ key: t.key,
2888
+ label: t.column.label ?? t.key
2889
+ }))), de = g(() => x.value.map((t) => ({
2890
+ key: t.key,
2891
+ label: t.column.label ?? t.key,
2892
+ visible: t.visible !== !1
2893
+ }))), H = g(() => x.value.filter((t) => t.column.capabilities?.aggregatable === !0).map((t) => ({
2894
+ key: t.key,
2895
+ label: t.column.label ?? t.key,
2896
+ allowedOps: Oa(t.column.dataType)
2897
+ }))), Re = U(e.rowHeightMode), $e = g(() => ya(e.baseRowHeight)), Ct = g(() => y.value[0]?.key ?? "name"), Je = g(() => {
2898
+ const t = /* @__PURE__ */ new Map();
2899
+ for (const n of x.value)
2900
+ t.set(n.key, n.column.label ?? n.key);
2901
+ return t;
2902
+ }), {
2903
+ isColumnLayoutPanelOpen: z,
2904
+ columnLayoutPanelItems: V,
2905
+ openColumnLayoutPanel: _,
2906
+ cancelColumnLayoutPanel: oe,
2907
+ applyColumnLayoutPanel: zn,
2908
+ moveColumnUp: pt,
2909
+ moveColumnDown: Hn,
2910
+ moveColumnToPosition: Vn,
2911
+ updateColumnVisibility: q
2912
+ } = to({
2913
+ resolveColumns: () => de.value,
2914
+ applyColumnLayout: (t) => {
2915
+ e.runtime.api.columns.setOrder(t.order);
2916
+ for (const [n, o] of Object.entries(t.visibilityByKey))
2917
+ e.runtime.api.columns.setVisibility(n, o);
2918
+ }
2919
+ }), le = Tl(null), Nt = g(() => le.value?.isAdvancedFilterPanelOpen.value ?? !1), Bn = g(() => le.value?.advancedFilterDraftClauses.value ?? []), jn = g(() => le.value?.appliedAdvancedFilterExpression.value ?? null), ct = async () => {
2920
+ if (le.value)
2921
+ return le.value;
2922
+ const { useDataGridAppAdvancedFilterBuilder: t } = await import("@affino/datagrid-vue/app"), n = t({
2923
+ resolveColumns: () => ne.value
2924
+ });
2925
+ return n.hydrateAdvancedFilterClauses(or(h.value)), le.value = n, n;
2926
+ }, Gn = (t) => {
2927
+ le.value?.hydrateAdvancedFilterClauses(t);
2928
+ }, Ln = async () => {
2929
+ (await ct()).openAdvancedFilterPanel();
2930
+ }, $n = async () => {
2931
+ const t = le.value;
2932
+ if (t) {
2933
+ t.addAdvancedFilterClause();
2934
+ return;
2935
+ }
2936
+ (await ct()).addAdvancedFilterClause();
2937
+ }, Kn = async (t) => {
2938
+ const n = le.value;
2939
+ if (n) {
2940
+ n.removeAdvancedFilterClause(t);
2941
+ return;
2942
+ }
2943
+ (await ct()).removeAdvancedFilterClause(t);
2944
+ }, Nn = async (t) => {
2945
+ const n = le.value;
2946
+ if (n) {
2947
+ n.updateAdvancedFilterClause(t);
2948
+ return;
2949
+ }
2950
+ (await ct()).updateAdvancedFilterClause(t);
2951
+ }, Wt = () => {
2952
+ le.value?.cancelAdvancedFilterPanel();
2953
+ }, Wn = () => {
2954
+ le.value?.applyAdvancedFilterPanel();
2955
+ }, ce = () => {
2956
+ le.value?.clearAdvancedFilterPanel();
2957
+ }, Ke = U(!1), X = U(null), Xe = g(() => !!e.groupBy?.fields?.length), Ze = g(() => (r.value, Kt(e.runtime.api.rows.getAggregationModel()))), Ut = g(() => (r.value, Sa(e.runtime.api.rows.getSnapshot().groupBy))), Z = g(() => {
2958
+ const t = new Map(
2959
+ (X.value?.columns ?? []).map((n) => [n.key, n.op])
2960
+ );
2961
+ return H.value.map((n) => {
2962
+ const o = n.allowedOps[0] ?? "count", s = t.get(n.key), u = s && n.allowedOps.includes(s) ? s : o;
2963
+ return {
2964
+ key: n.key,
2965
+ label: n.label,
2966
+ enabled: t.has(n.key),
2967
+ op: u,
2968
+ allowedOps: n.allowedOps
2969
+ };
2970
+ });
2971
+ }), Qe = g(() => X.value?.basis === "source" ? "source" : "filtered");
2972
+ te(
2973
+ Ze,
2974
+ (t) => {
2975
+ Ke.value || (X.value = Kt(t));
2976
+ },
2977
+ { immediate: !0, deep: !0 }
2978
+ ), te(
2979
+ () => e.rowHeightMode,
2980
+ (t) => {
2981
+ Re.value = t;
2982
+ }
2983
+ );
2984
+ const qt = (t) => {
2985
+ const n = h.value.columnFilters?.[t];
2986
+ return n ? n.kind === "valueSet" ? n.tokens.length > 0 : !0 : !1;
2987
+ }, Yt = (t) => {
2988
+ const n = h.value.columnFilters?.[t];
2989
+ return !n || n.kind !== "valueSet" ? [] : n.tokens.map((o) => jl(String(o ?? "")));
2990
+ }, Un = (t, n) => e.runtime.api.columns.getHistogram(t, {
2991
+ ignoreSelfFilter: !0,
2992
+ orderBy: "valueAsc",
2993
+ search: n
2994
+ }), St = (t) => Cr(e.columnMenu, t), Jt = (t) => Po(e.columnMenu, t), Xt = (t) => zo(e.columnMenu, t), qn = (t) => To(e.columnMenu, t), Zt = (t) => Ho(e.columnMenu, t), et = (t) => Vo(e.columnMenu, t), It = (t) => {
2995
+ const n = Ut.value?.fields.findIndex((o) => o === t) ?? -1;
2996
+ return n >= 0 ? n : null;
2997
+ }, Qt = (t) => It(t) !== null, fe = () => {
2998
+ const t = i.value.map((M) => ({
2999
+ key: M.key,
3000
+ direction: M.direction
3001
+ })), n = h.value.advancedExpression ?? null, o = e.advancedFilter.enabled ? {
3002
+ ...h.value,
3003
+ advancedFilters: {},
3004
+ advancedExpression: n
3005
+ } : {
3006
+ ...h.value,
3007
+ advancedExpression: n
3008
+ }, s = st();
3009
+ e.runtime.api.rows.setSortAndFilterModel({
3010
+ sortModel: t,
3011
+ filterModel: Ra(o)
3012
+ });
3013
+ const u = st(), v = e.runtime.api.rows.getSnapshot(), m = v.projection, R = m?.performance?.stageTimes ?? {};
3014
+ return {
3015
+ setSortModelMs: Math.max(0, u - s),
3016
+ projectionRebuildMs: Number.isFinite(m?.performance?.totalTime) ? Math.max(0, Number(m?.performance?.totalTime)) : 0,
3017
+ projectionSortMs: Number.isFinite(R.sort) ? Math.max(0, Number(R.sort)) : 0,
3018
+ projectionFilterMs: Number.isFinite(R.filter) ? Math.max(0, Number(R.filter)) : 0,
3019
+ projectionGroupMs: Number.isFinite(R.group) ? Math.max(0, Number(R.group)) : 0,
3020
+ recomputeVersion: Number.isFinite(m?.recomputeVersion) ? Number(m?.recomputeVersion) : 0,
3021
+ rowCount: v.rowCount
3022
+ };
3023
+ }, Mt = () => {
3024
+ Gn(or(h.value));
3025
+ }, en = g(() => h.value.advancedExpression ?? null), Ne = g(() => {
3026
+ const t = (s) => Je.value.get(s) ?? s, n = e.advancedFilter.labels, o = [];
3027
+ for (const [s, u] of Object.entries(h.value.columnFilters ?? {}))
3028
+ u && o.push(Ma(t(s), u, n));
3029
+ for (const [s, u] of Object.entries(h.value.advancedFilters ?? {}))
3030
+ u && o.push(dr(
3031
+ xa(t(s), u, n),
3032
+ n
3033
+ ));
3034
+ return en.value && o.push(dr(
3035
+ Ll(en.value, t, n),
3036
+ n
3037
+ )), Object.freeze(o);
3038
+ }), mt = g(() => Ne.value.length > 0), Yn = () => {
3039
+ h.value = Bl(), ce(), fe();
3040
+ };
3041
+ te(
3042
+ h,
3043
+ () => {
3044
+ !e.advancedFilter.enabled || Nt.value || Mt();
3045
+ },
3046
+ { immediate: !0, deep: !0 }
3047
+ );
3048
+ const tn = () => {
3049
+ Mt(), Ln();
3050
+ }, nn = () => {
3051
+ Wn(), h.value = {
3052
+ ...ut(h.value),
3053
+ columnFilters: {},
3054
+ advancedFilters: {},
3055
+ advancedExpression: jn.value
3056
+ }, fe();
3057
+ }, Jn = (t, n = !1) => {
3058
+ const o = i.value.findIndex((u) => u.key === t), s = o >= 0 ? i.value[o] : null;
3059
+ if (!s) {
3060
+ const u = { key: t, direction: "asc" };
3061
+ i.value = n ? [...i.value, u] : [u], fe();
3062
+ return;
3063
+ }
3064
+ if (s.direction === "asc") {
3065
+ const u = { key: t, direction: "desc" };
3066
+ n ? i.value = i.value.map((v) => v.key === t ? u : v) : i.value = [u], fe();
3067
+ return;
3068
+ }
3069
+ i.value = n ? i.value.filter((u) => u.key !== t) : [], fe();
3070
+ }, Xn = (t) => {
3071
+ const n = i.value.findIndex((u) => u.key === t);
3072
+ if (n < 0)
3073
+ return "";
3074
+ const o = i.value[n];
3075
+ if (!o)
3076
+ return "";
3077
+ const s = o.direction === "asc" ? "↑" : "↓";
3078
+ return i.value.length > 1 ? `${s}${n + 1}` : s;
3079
+ }, Zn = (t, n) => {
3080
+ const o = ut(h.value), s = n.trim();
3081
+ s ? o.columnFilters[t] = {
3082
+ kind: "predicate",
3083
+ operator: "contains",
3084
+ value: s,
3085
+ caseSensitive: !1
3086
+ } : delete o.columnFilters[t], h.value = o, fe();
3087
+ }, xt = () => {
3088
+ e.runtime.api.view.setRowHeightMode(Re.value), e.runtime.api.view.setBaseRowHeight($e.value);
3089
+ }, ln = () => {
3090
+ X.value = Kt(Ze.value), Ke.value = !0;
3091
+ }, rn = () => {
3092
+ X.value = Kt(Ze.value), Ke.value = !1;
3093
+ };
3094
+ te(
3095
+ Xe,
3096
+ (t) => {
3097
+ t || rn();
3098
+ },
3099
+ { immediate: !0 }
3100
+ );
3101
+ const Qn = () => {
3102
+ X.value = null;
3103
+ }, el = (t) => {
3104
+ X.value = {
3105
+ basis: t,
3106
+ columns: X.value?.columns ?? []
3107
+ };
3108
+ }, tl = (t, n) => {
3109
+ const o = H.value.find((m) => m.key === t);
3110
+ if (!o)
3111
+ return;
3112
+ const s = X.value?.columns ?? [];
3113
+ if (!n) {
3114
+ const m = s.filter((R) => R.key !== t);
3115
+ X.value = m.length > 0 ? { basis: Qe.value, columns: m } : null;
3116
+ return;
3117
+ }
3118
+ const v = s.find((m) => m.key === t) ?? {
3119
+ key: t,
3120
+ op: o.allowedOps[0] ?? "count"
3121
+ };
3122
+ X.value = {
3123
+ basis: Qe.value,
3124
+ columns: [
3125
+ ...s.filter((m) => m.key !== t),
3126
+ v
3127
+ ]
3128
+ };
3129
+ }, Ft = (t, n) => {
3130
+ const o = H.value.find((u) => u.key === t);
3131
+ if (!o || !o.allowedOps.includes(n))
3132
+ return;
3133
+ const s = (X.value?.columns ?? []).map((u) => u.key !== t ? u : {
3134
+ ...u,
3135
+ op: n
3136
+ });
3137
+ X.value = {
3138
+ basis: Qe.value,
3139
+ columns: s
3140
+ };
3141
+ }, We = () => {
3142
+ const t = X.value && X.value.columns.length > 0 ? X.value : null;
3143
+ e.runtime.api.rows.setAggregationModel(t), X.value = Kt(t), Ke.value = !1;
3144
+ }, Ue = (t) => i.value.find((n) => n.key === t)?.direction ?? null;
3145
+ function ke() {
3146
+ ha(w), w = null;
3147
+ }
3148
+ const nl = (t, n, o, s, u) => {
3149
+ if (w = null, t !== b)
3150
+ return;
3151
+ const v = st();
3152
+ i.value = n.nextSortState;
3153
+ const m = fe(), R = st(), M = m.setSortModelMs, P = M > ar;
3154
+ if (ir({
3155
+ scope: "columnMenuSortApply",
3156
+ ts: Date.now(),
3157
+ totalMs: Math.max(0, R - o),
3158
+ columnKey: n.columnKey,
3159
+ direction: n.direction ?? "clear",
3160
+ handlerMs: Math.max(0, s - o),
3161
+ scheduleDelayMs: Math.max(0, v - u),
3162
+ handlerToApplyStartMs: Math.max(0, v - o),
3163
+ setSortModelMs: M,
3164
+ projectionRebuildMs: m.projectionRebuildMs,
3165
+ projectionSortMs: m.projectionSortMs,
3166
+ projectionFilterMs: m.projectionFilterMs,
3167
+ projectionGroupMs: m.projectionGroupMs,
3168
+ recomputeVersion: m.recomputeVersion,
3169
+ rowCount: m.rowCount,
3170
+ slowSort: P ? 1 : 0,
3171
+ thresholdMs: ar,
3172
+ applyStartMs: v,
3173
+ setSortModelEndMs: R
3174
+ }), !P) {
3175
+ d.value = null;
3176
+ return;
3177
+ }
3178
+ w = El(() => {
3179
+ w = null, t === b && (d.value = null);
3180
+ });
3181
+ }, ll = (t, n, o) => {
3182
+ ke();
3183
+ const s = ++b, u = st();
3184
+ d.value = t, w = El(() => {
3185
+ w = El(() => {
3186
+ nl(s, t, n, o, u);
3187
+ });
3188
+ });
3189
+ }, on = (t, n) => {
3190
+ const o = st(), s = y.value.find((m) => m.key === t);
3191
+ if (!s || s.column.capabilities?.sortable === !1)
3192
+ return;
3193
+ const u = n === null ? i.value.filter((m) => m.key !== t) : [{ key: t, direction: n }], v = st();
3194
+ ir({
3195
+ scope: "columnMenuSortRequest",
3196
+ ts: Date.now(),
3197
+ totalMs: Math.max(0, v - o),
3198
+ columnKey: t,
3199
+ direction: n ?? "clear",
3200
+ handlerStartMs: o,
3201
+ handlerEndMs: v
3202
+ }), ll({ columnKey: t, direction: n, nextSortState: u }, o, v);
3203
+ }, qe = (t, n) => {
3204
+ e.runtime.api.columns.setPin(t, n);
3205
+ }, xe = (t, n) => {
3206
+ const o = Ut.value, s = n ? Array.from(/* @__PURE__ */ new Set([...o?.fields ?? [], t])) : (o?.fields ?? []).filter((u) => u !== t);
3207
+ e.runtime.api.rows.setGroupBy(s.length > 0 ? {
3208
+ fields: s,
3209
+ expandedByDefault: o?.expandedByDefault ?? !0
3210
+ } : null);
3211
+ }, an = (t, n) => {
3212
+ const o = Array.from(new Set(
3213
+ n.map((u) => jl(String(u ?? ""))).filter((u) => u.length > 0)
3214
+ ));
3215
+ if (o.length === 0) {
3216
+ At(t);
3217
+ return;
3218
+ }
3219
+ const s = ut(h.value);
3220
+ s.columnFilters[t] = {
3221
+ kind: "valueSet",
3222
+ tokens: o
3223
+ }, h.value = s, fe();
3224
+ }, At = (t) => {
3225
+ const n = ut(h.value);
3226
+ delete n.columnFilters[t], h.value = n, fe();
3227
+ }, Fe = U(null), ie = U(null);
3228
+ let sn = 0;
3229
+ const Dt = () => {
3230
+ const t = e.selectionSnapshot.value, n = t?.ranges[t.activeRangeIndex] ?? null;
3231
+ return n ? {
3232
+ startRow: n.startRow,
3233
+ endRow: n.endRow,
3234
+ startColumn: n.startCol,
3235
+ endColumn: n.endCol
3236
+ } : null;
3237
+ }, ft = () => {
3238
+ const t = e.selectionSnapshot.value?.activeCell;
3239
+ return t ? {
3240
+ rowIndex: t.rowIndex,
3241
+ columnIndex: t.colIndex
3242
+ } : null;
3243
+ }, wt = (t) => t ? t.startRow !== t.endRow || t.startColumn !== t.endColumn : !1, Ot = (t, n) => t.rowIndex >= Math.min(n.startRow, n.endRow) && t.rowIndex <= Math.max(n.startRow, n.endRow) && t.columnIndex >= Math.min(n.startColumn, n.endColumn) && t.columnIndex <= Math.max(n.startColumn, n.endColumn), _t = (t, n) => {
3244
+ const o = e.runtime.resolveBodyRowIndexById(t), s = y.value.findIndex((u) => u.key === n);
3245
+ return o < 0 || s < 0 ? null : { rowIndex: o, columnIndex: s };
3246
+ }, rl = (t) => ({
3247
+ ranges: [{
3248
+ startRow: t.rowIndex,
3249
+ endRow: t.rowIndex,
3250
+ startCol: t.columnIndex,
3251
+ endCol: t.columnIndex,
3252
+ anchor: {
3253
+ rowIndex: t.rowIndex,
3254
+ colIndex: t.columnIndex,
3255
+ rowId: e.runtime.getBodyRowAtIndex(t.rowIndex)?.rowId ?? null
3256
+ },
3257
+ focus: {
3258
+ rowIndex: t.rowIndex,
3259
+ colIndex: t.columnIndex,
3260
+ rowId: e.runtime.getBodyRowAtIndex(t.rowIndex)?.rowId ?? null
3261
+ },
3262
+ startRowId: e.runtime.getBodyRowAtIndex(t.rowIndex)?.rowId ?? null,
3263
+ endRowId: e.runtime.getBodyRowAtIndex(t.rowIndex)?.rowId ?? null
3264
+ }],
3265
+ activeRangeIndex: 0,
3266
+ activeCell: {
3267
+ rowIndex: t.rowIndex,
3268
+ colIndex: t.columnIndex,
3269
+ rowId: e.runtime.getBodyRowAtIndex(t.rowIndex)?.rowId ?? null
3270
+ }
3271
+ }), Ee = (t, n) => {
3272
+ if (!Number.isFinite(n))
3273
+ return null;
3274
+ const o = Math.trunc(n);
3275
+ return t[o] ?? null;
3276
+ }, tt = (t) => typeof t == "string" || typeof t == "number" ? t : null, un = () => {
3277
+ const t = e.selectionSnapshot.value, n = y.value.map((u) => u.key);
3278
+ if (!t || n.length === 0)
3279
+ return null;
3280
+ const o = t.ranges.map((u) => {
3281
+ const v = Ee(n, u.startCol), m = Ee(n, u.endCol);
3282
+ if (!v || !m)
3283
+ return null;
3284
+ const R = Ee(n, u.anchor?.colIndex ?? u.startCol) ?? v, M = Ee(n, u.focus?.colIndex ?? u.endCol) ?? m;
3285
+ return {
3286
+ startRow: u.startRow,
3287
+ endRow: u.endRow,
3288
+ startColumnKey: v,
3289
+ endColumnKey: m,
3290
+ startRowId: tt(u.startRowId),
3291
+ endRowId: tt(u.endRowId),
3292
+ anchor: {
3293
+ rowIndex: u.anchor?.rowIndex ?? u.startRow,
3294
+ rowId: tt(u.anchor?.rowId),
3295
+ columnKey: R
3296
+ },
3297
+ focus: {
3298
+ rowIndex: u.focus?.rowIndex ?? u.endRow,
3299
+ rowId: tt(u.focus?.rowId),
3300
+ columnKey: M
3301
+ }
3302
+ };
3303
+ }).filter((u) => u != null);
3304
+ if (o.length === 0)
3305
+ return null;
3306
+ const s = t.activeCell ? Ee(n, t.activeCell.colIndex) : null;
3307
+ return {
3308
+ ranges: o,
3309
+ activeRangeIndex: Math.max(0, Math.trunc(t.activeRangeIndex ?? 0)),
3310
+ activeCell: t.activeCell && s ? {
3311
+ rowIndex: t.activeCell.rowIndex,
3312
+ rowId: tt(t.activeCell.rowId),
3313
+ columnKey: s
3314
+ } : null
3315
+ };
3316
+ }, dn = (t) => {
3317
+ const n = y.value.map((m) => m.key);
3318
+ if (n.length === 0)
3319
+ return null;
3320
+ const o = [];
3321
+ for (const m of t.ranges) {
3322
+ const R = n.indexOf(m.startColumnKey), M = n.indexOf(m.endColumnKey), P = n.indexOf(m.anchor.columnKey), k = n.indexOf(m.focus.columnKey);
3323
+ R < 0 || M < 0 || P < 0 || k < 0 || o.push({
3324
+ startRow: m.startRow,
3325
+ endRow: m.endRow,
3326
+ startCol: R,
3327
+ endCol: M,
3328
+ startRowId: m.startRowId,
3329
+ endRowId: m.endRowId,
3330
+ anchor: {
3331
+ rowIndex: m.anchor.rowIndex,
3332
+ colIndex: P,
3333
+ rowId: m.anchor.rowId
3334
+ },
3335
+ focus: {
3336
+ rowIndex: m.focus.rowIndex,
3337
+ colIndex: k,
3338
+ rowId: m.focus.rowId
3339
+ }
3340
+ });
3341
+ }
3342
+ if (o.length === 0)
3343
+ return null;
3344
+ const s = Math.min(o.length - 1, Math.max(0, t.activeRangeIndex)), u = o[s] ?? o[0] ?? null;
3345
+ if (!u)
3346
+ return null;
3347
+ const v = t.activeCell ? n.indexOf(t.activeCell.columnKey) : -1;
3348
+ return {
3349
+ ranges: o,
3350
+ activeRangeIndex: s,
3351
+ activeCell: v >= 0 && t.activeCell ? {
3352
+ rowIndex: t.activeCell.rowIndex,
3353
+ colIndex: v,
3354
+ rowId: t.activeCell.rowId
3355
+ } : {
3356
+ rowIndex: u.focus.rowIndex,
3357
+ colIndex: u.focus.colIndex,
3358
+ rowId: u.focus.rowId
3359
+ }
3360
+ };
3361
+ }, ol = (t) => {
3362
+ const n = t ? dn(t) : null;
3363
+ n && (e.runtime.api.selection.setSnapshot(n), e.syncSelectionSnapshotFromRuntime()), kt();
3364
+ }, cn = (t) => {
3365
+ if (t.length === 0)
3366
+ return null;
3367
+ const n = new Set(t), o = e.selectionSnapshot.value?.activeCell?.rowId;
3368
+ if (o != null) {
3369
+ const m = String(o);
3370
+ if (n.has(m))
3371
+ return m;
3372
+ }
3373
+ const u = (e.selectionSnapshot.value?.ranges[e.selectionSnapshot.value?.activeRangeIndex ?? 0] ?? null)?.anchor?.rowId;
3374
+ if (u != null) {
3375
+ const m = String(u);
3376
+ if (n.has(m))
3377
+ return m;
3378
+ }
3379
+ const v = e.rowSelectionSnapshot.value?.focusedRow;
3380
+ if (v != null) {
3381
+ const m = String(v);
3382
+ if (n.has(m))
3383
+ return m;
3384
+ }
3385
+ return t[0] ?? null;
3386
+ }, mn = (t, n) => {
3387
+ const o = y.value.length - 1;
3388
+ if (t.length === 0 || o < 0)
3389
+ return null;
3390
+ const s = t.map((R) => ({ rowId: R, rowIndex: e.runtime.resolveBodyRowIndexById(R) })).filter((R) => R.rowIndex >= 0).sort((R, M) => R.rowIndex - M.rowIndex);
3391
+ if (s.length === 0)
3392
+ return null;
3393
+ const u = s[0] ?? null, v = e.runtime.resolveBodyRowIndexById(n), m = v >= 0 ? { rowId: n, rowIndex: v } : u;
3394
+ return !m || m.rowIndex < 0 ? null : {
3395
+ ranges: [{
3396
+ startRow: s[0]?.rowIndex ?? m.rowIndex,
3397
+ endRow: s[s.length - 1]?.rowIndex ?? m.rowIndex,
3398
+ startCol: 0,
3399
+ endCol: o,
3400
+ anchor: {
3401
+ rowIndex: m.rowIndex,
3402
+ colIndex: 0,
3403
+ rowId: m.rowId
3404
+ },
3405
+ focus: {
3406
+ rowIndex: m.rowIndex,
3407
+ colIndex: 0,
3408
+ rowId: m.rowId
3409
+ },
3410
+ startRowId: s[0]?.rowId ?? m.rowId,
3411
+ endRowId: s[s.length - 1]?.rowId ?? m.rowId
3412
+ }],
3413
+ activeRangeIndex: 0,
3414
+ activeCell: {
3415
+ rowIndex: m.rowIndex,
3416
+ colIndex: 0,
3417
+ rowId: m.rowId
3418
+ }
3419
+ };
3420
+ }, kt = () => {
3421
+ const t = () => {
3422
+ const o = Fe.value?.querySelector(".grid-body-viewport");
3423
+ if (!o)
3424
+ return !1;
3425
+ try {
3426
+ o.focus({ preventScroll: !0 });
3427
+ } catch {
3428
+ o.focus();
3429
+ }
3430
+ return document.activeElement === o;
3431
+ }, n = (o) => {
3432
+ dt(() => {
3433
+ if (!(t() || o >= 3)) {
3434
+ if (typeof window < "u") {
3435
+ window.requestAnimationFrame(() => {
3436
+ n(o + 1);
3437
+ });
3438
+ return;
3439
+ }
3440
+ n(o + 1);
3441
+ }
3442
+ });
3443
+ };
3444
+ n(0);
3445
+ }, al = (t) => {
3446
+ const n = cn(t);
3447
+ if (!n)
3448
+ return;
3449
+ e.runtime.api.rowSelection.hasSupport() && (e.runtime.api.rowSelection.setFocusedRow(n), e.syncRowSelectionSnapshotFromRuntime?.(), e.flushRowSelectionSnapshotUpdates?.());
3450
+ const o = mn(t, n);
3451
+ o && (e.runtime.api.selection.setSnapshot(o), e.syncSelectionSnapshotFromRuntime()), kt();
3452
+ }, Et = (t) => {
3453
+ const n = e.runtime.api.rows.getCount();
3454
+ for (let o = 0; o < n; o += 1) {
3455
+ const s = e.runtime.api.rows.get(o);
3456
+ if (s && String(s.rowId) === t)
3457
+ return s;
3458
+ }
3459
+ return null;
3460
+ }, gt = (t) => {
3461
+ if (!e.placeholderRows.enabled || !e.placeholderRows.createRowAt || Et(t))
3462
+ return null;
3463
+ const n = `.datagrid-stage__row-index-cell[data-row-id="${sr(t)}"]`, o = Fe.value?.querySelector(n), s = Number.parseInt(o?.dataset.rowIndex ?? "", 10);
3464
+ if (!Number.isFinite(s))
3465
+ return null;
3466
+ const u = Math.max(0, Math.trunc(s));
3467
+ return u < e.runtime.api.rows.getCount() ? null : u;
3468
+ }, il = async (t) => {
3469
+ try {
3470
+ return globalThis.navigator?.clipboard?.writeText ? (await globalThis.navigator.clipboard.writeText(t), !0) : !1;
3471
+ } catch {
3472
+ return !1;
3473
+ }
3474
+ }, sl = async () => {
3475
+ try {
3476
+ return globalThis.navigator?.clipboard?.readText ? await globalThis.navigator.clipboard.readText() : "";
3477
+ } catch {
3478
+ return "";
3479
+ }
3480
+ }, fn = async () => {
3481
+ if (ie.value?.rows.length)
3482
+ return ie.value.rows.map((n) => Me(n));
3483
+ const t = (await sl()).trim();
3484
+ if (!t)
3485
+ return null;
3486
+ try {
3487
+ const n = JSON.parse(t);
3488
+ if (Array.isArray(n))
3489
+ return n.filter((o) => !!o && typeof o == "object").map((o) => Me(o));
3490
+ if (n && typeof n == "object")
3491
+ return [Me(n)];
3492
+ } catch {
3493
+ return null;
3494
+ }
3495
+ return null;
3496
+ }, wn = async (t, n, o = []) => {
3497
+ const s = t.map((v) => Me(v));
3498
+ ie.value = {
3499
+ rows: s,
3500
+ operation: n,
3501
+ sourceRowIds: o.map((v) => String(v))
3502
+ };
3503
+ const u = pa(s);
3504
+ return u && await il(u), !0;
3505
+ }, Ae = () => e.runtime.api.rows.hasInsertSupport(), Pe = () => e.runtime.api.rows.hasDataMutationSupport(), nt = (t) => !t || typeof t != "object" ? !1 : "data" in t || "row" in t || "kind" in t || "state" in t || "sourceIndex" in t || "originalIndex" in t || "displayIndex" in t, Ce = (t) => {
3506
+ const n = t;
3507
+ return n.rowId != null ? String(n.rowId) : n.id != null ? String(n.id) : null;
3508
+ }, Te = (t) => {
3509
+ for (const n of e.rows) {
3510
+ if (!n || typeof n != "object")
3511
+ continue;
3512
+ const o = n;
3513
+ if ((o.rowId != null ? String(o.rowId) : o.rowKey != null ? String(o.rowKey) : null) === t && nt(o))
3514
+ return o;
3515
+ }
3516
+ for (const n of e.rows) {
3517
+ if (!n || typeof n != "object")
3518
+ continue;
3519
+ const o = n;
3520
+ if (nt(o))
3521
+ return o;
3522
+ }
3523
+ return null;
3524
+ }, vt = () => (sn += 1, `datagrid-row-${Date.now()}-${sn}`), ul = (t) => {
3525
+ const n = Me(t), o = vt();
3526
+ let s = !1;
3527
+ return "id" in n && (n.id = o, s = !0), "rowId" in n && (n.rowId = o, s = !0), s || (n.id = o), n;
3528
+ }, dl = (t) => {
3529
+ const n = vt(), o = {};
3530
+ for (const [s, u] of Object.entries(t)) {
3531
+ if (s === "id" || s === "rowId") {
3532
+ o[s] = n;
3533
+ continue;
3534
+ }
3535
+ o[s] = typeof u == "number" ? null : "";
3536
+ }
3537
+ return !("id" in o) && !("rowId" in o) && (o.id = n), o;
3538
+ }, gn = (t, n, o) => {
3539
+ const s = vt(), u = o === "clone" ? Me(t) : Object.entries(t).reduce((m, [R, M]) => (m[R] = typeof M == "number" ? null : "", m), {});
3540
+ ("id" in u || !("rowId" in u) && !("id" in u)) && (u.id = s), "rowId" in u && (u.rowId = s), "rowKey" in u && (u.rowKey = s);
3541
+ const v = typeof n.state == "object" && n.state != null ? n.state : null;
3542
+ return {
3543
+ kind: n.kind === "group" ? "leaf" : n.kind ?? "leaf",
3544
+ rowId: s,
3545
+ rowKey: s,
3546
+ state: {
3547
+ ...v ?? {},
3548
+ selected: !1,
3549
+ group: !1,
3550
+ pinned: "none",
3551
+ expanded: !1
3552
+ },
3553
+ data: u,
3554
+ row: Me(u)
3555
+ };
3556
+ }, vn = (t, n = null) => n && nt(n) ? gn(t, n, "clone") : ul(t), hn = (t, n = null) => n && nt(n) ? gn(t, n, "blank") : dl(t), Pt = (t, n, o) => {
3557
+ if (!e.placeholderRows.enabled || !e.placeholderRows.createRowAt)
3558
+ return null;
3559
+ const s = e.placeholderRows.createRowAt({
3560
+ visualRowIndex: t,
3561
+ materializedRowCount: n,
3562
+ sourceRows: o,
3563
+ reason: "edit"
3564
+ });
3565
+ return s ? Me(s) : null;
3566
+ }, lt = (t, n) => {
3567
+ if (!Ae())
3568
+ return !1;
3569
+ const o = pe().map((m) => Me(m));
3570
+ let s = e.runtime.api.rows.getCount();
3571
+ for (; s < n; ) {
3572
+ const m = Pt(
3573
+ s,
3574
+ s,
3575
+ o
3576
+ );
3577
+ if (!m || !e.runtime.api.rows.insertDataAt(s, [m]))
3578
+ return !1;
3579
+ o.push(m), s += 1;
3580
+ }
3581
+ const u = Math.max(0, Math.min(s, Math.trunc(t))), v = Pt(
3582
+ u,
3583
+ s,
3584
+ o
3585
+ );
3586
+ return v ? e.runtime.api.rows.insertDataAt(u, [v]) : !1;
3587
+ }, cl = (t) => {
3588
+ if (!Ae())
3589
+ return null;
3590
+ const n = pe().map((u) => Me(u));
3591
+ let o = e.runtime.api.rows.getCount();
3592
+ const s = Math.max(0, Math.trunc(t));
3593
+ for (; o < s; ) {
3594
+ const u = Pt(
3595
+ o,
3596
+ o,
3597
+ n
3598
+ );
3599
+ if (!u || !e.runtime.api.rows.insertDataAt(o, [u]))
3600
+ return null;
3601
+ n.push(u), o += 1;
3602
+ }
3603
+ return n;
3604
+ }, rt = (t) => {
3605
+ const n = (m) => {
3606
+ const R = e.runtime.resolveBodyRowIndexById(m);
3607
+ if (R < 0 || R >= e.runtime.api.rows.getCount())
3608
+ return !1;
3609
+ const M = e.runtime.getBodyRowAtIndex(R);
3610
+ return M != null && M.kind !== "group" && !io(M);
3611
+ }, s = (e.rowSelectionSnapshot.value?.selectedRows ?? []).map((m) => String(m)).filter((m) => m.length > 0 && n(m));
3612
+ if (s.length > 0)
3613
+ return s;
3614
+ const u = Dt(), v = y.value.length - 1;
3615
+ if (u && v >= 0) {
3616
+ const m = Math.min(u.startColumn, u.endColumn), R = Math.max(u.startColumn, u.endColumn), M = Math.min(u.startRow, u.endRow), P = Math.max(u.startRow, u.endRow), k = t.length > 0 ? e.runtime.resolveBodyRowIndexById(t) : -1;
3617
+ if (m === 0 && R === v && (k < 0 || k >= M && k <= P)) {
3618
+ const W = [];
3619
+ for (let Q = M; Q <= P; Q += 1) {
3620
+ const ve = e.runtime.getBodyRowAtIndex(Q);
3621
+ if (!ve || ve.kind === "group" || ve.rowId == null)
3622
+ continue;
3623
+ const Ie = String(ve.rowId);
3624
+ n(Ie) && W.push(Ie);
3625
+ }
3626
+ if (W.length > 0)
3627
+ return W;
3628
+ }
3629
+ }
3630
+ return t.length > 0 && n(t) ? [t] : [];
3631
+ }, pe = () => {
3632
+ const t = [], n = e.runtime.api.rows.getCount();
3633
+ for (let o = 0; o < n; o += 1) {
3634
+ const s = e.runtime.api.rows.get(o);
3635
+ !s || s.kind === "group" || t.push(s.data);
3636
+ }
3637
+ return t;
3638
+ }, De = (t) => {
3639
+ const n = new Set(
3640
+ pe().map((o) => Ce(o)).filter((o) => o != null)
3641
+ );
3642
+ return Array.from(new Set(t.map((o) => String(o)).filter((o) => n.has(o))));
3643
+ }, ze = (t) => {
3644
+ if (t.length === 0)
3645
+ return [];
3646
+ const n = new Set(t.map((o) => String(o)));
3647
+ return pe().filter((o) => {
3648
+ const s = Ce(o);
3649
+ return s != null && n.has(s);
3650
+ });
3651
+ }, Tt = (t) => {
3652
+ if (!Pe() || t.length === 0)
3653
+ return !1;
3654
+ const n = new Set(t), o = pe().filter((s) => {
3655
+ const u = Ce(s);
3656
+ return u == null || !n.has(u);
3657
+ });
3658
+ return o.length === e.runtime.api.rows.getCount() ? !1 : (e.runtime.api.rows.replaceData(o), e.runtime.api.rowSelection.hasSupport() && (e.runtime.api.rowSelection.clearSelectedRows(), e.syncRowSelectionSnapshotFromRuntime?.()), !0);
3659
+ }, zt = (t, n) => {
3660
+ if (!Pe() || t.length === 0)
3661
+ return !1;
3662
+ const o = pe(), s = new Set(t.map((R) => String(R))), u = o.filter((R) => {
3663
+ const M = Ce(R);
3664
+ return M != null && s.has(M);
3665
+ });
3666
+ if (u.length === 0)
3667
+ return !1;
3668
+ const v = o.filter((R) => {
3669
+ const M = Ce(R);
3670
+ return M == null || !s.has(M);
3671
+ }), m = Number.isFinite(n) ? Math.max(0, Math.min(v.length, Math.trunc(n))) : v.length;
3672
+ return e.runtime.api.rows.replaceData([
3673
+ ...v.slice(0, m),
3674
+ ...u,
3675
+ ...v.slice(m)
3676
+ ]), e.runtime.api.rowSelection.hasSupport() && (e.runtime.api.rowSelection.selectRows(t), e.syncRowSelectionSnapshotFromRuntime?.()), !0;
3677
+ }, bn = (t, n) => {
3678
+ if (!Pe() || t.length === 0 || !n)
3679
+ return !1;
3680
+ const o = new Set(t.map((m) => String(m)));
3681
+ if (o.has(String(n)))
3682
+ return !1;
3683
+ const v = pe().filter((m) => {
3684
+ const R = Ce(m);
3685
+ return R == null || !o.has(R);
3686
+ }).findIndex((m) => Ce(m) === n);
3687
+ return v < 0 ? !1 : zt(t, v + 1);
3688
+ }, yn = (t) => {
3689
+ if (!Pe())
3690
+ return !1;
3691
+ const n = String(t.sourceRowId), o = String(t.targetRowId);
3692
+ if (!n || !o || n === o)
3693
+ return !1;
3694
+ const s = De(rt(n)), u = s.includes(n) ? s : De([n]);
3695
+ if (u.length === 0 || u.includes(o))
3696
+ return !1;
3697
+ const v = pe(), m = new Set(u), M = v.filter((W) => {
3698
+ const Q = Ce(W);
3699
+ return Q == null || !m.has(Q);
3700
+ }).findIndex((W) => Ce(W) === o);
3701
+ if (M < 0)
3702
+ return !1;
3703
+ const P = we(), k = zt(
3704
+ u,
3705
+ t.placement === "after" ? M + 1 : M
3706
+ );
3707
+ return k && (al(u), Se(P, u.length > 1 ? `Move ${u.length} rows` : "Move row")), k;
3708
+ }, Rn = (t) => {
3709
+ const n = String(t.sourceColumnKey), o = String(t.targetColumnKey);
3710
+ if (!n || !o || n === o)
3711
+ return !1;
3712
+ const s = x.value, u = s.find((ee) => ee.key === n), v = s.find((ee) => ee.key === o);
3713
+ if (!u || !v)
3714
+ return !1;
3715
+ const m = s.map((ee) => ee.key), R = m.indexOf(n), M = m.indexOf(o);
3716
+ if (R < 0 || M < 0)
3717
+ return !1;
3718
+ const P = m[R];
3719
+ if (!P)
3720
+ return !1;
3721
+ m.splice(R, 1);
3722
+ const k = m.indexOf(o);
3723
+ if (k < 0)
3724
+ return !1;
3725
+ const W = t.placement === "after" ? k + 1 : k;
3726
+ m.splice(W, 0, P);
3727
+ const Q = un(), ve = v.pin ?? "none";
3728
+ return (u.pin ?? "none") !== ve && e.runtime.api.columns.setPin(n, ve), e.runtime.api.columns.setOrder(m), ol(Q), !0;
3729
+ }, ml = () => ie.value ? (ie.value = null, !0) : !1, fl = (t) => {
3730
+ if (t.kind === "group")
3731
+ return !1;
3732
+ const n = ie.value;
3733
+ return n ? n.sourceRowIds.includes(String(t.rowId)) : !1;
3734
+ }, Cn = () => typeof e.runStructuralRowAction == "function";
3735
+ let Ht = () => !1, ot = () => {
3736
+ }, Vt = () => {
3737
+ };
3738
+ const pn = U(null);
3739
+ let Bt = async (t, n) => !1;
3740
+ const wl = (t, n) => {
3741
+ if (n)
3742
+ return n;
3743
+ const o = cr[t], s = Ea[t];
3744
+ return s ? `${o} (${s})` : o;
3745
+ }, {
3746
+ tableStageProps: ht,
3747
+ tableStageContext: bt,
3748
+ historyController: Ye,
3749
+ copySelectedCells: gl,
3750
+ pasteSelectedCells: vl,
3751
+ cutSelectedCells: hl,
3752
+ clearSelectedCells: bl,
3753
+ captureHistorySnapshot: we,
3754
+ captureHistorySnapshotForRowIds: yl,
3755
+ recordHistoryIntentTransaction: Sn,
3756
+ revealCellInComfortZone: Rl
3757
+ } = ua({
3758
+ mode: C,
3759
+ layoutMode: g(() => e.layoutMode),
3760
+ minRows: g(() => e.minRows),
3761
+ maxRows: g(() => e.maxRows),
3762
+ placeholderRows: g(() => e.placeholderRows),
3763
+ enableFillHandle: g(() => e.fillHandle),
3764
+ enableRangeMove: g(() => e.rangeMove),
3765
+ rows: F,
3766
+ sourceRows: F,
3767
+ runtime: e.runtime,
3768
+ runtimeRowModel: e.runtimeRowModel ?? null,
3769
+ rowVersion: r,
3770
+ totalRuntimeRows: A,
3771
+ visibleColumns: y,
3772
+ rowRenderMode: g(() => e.renderMode),
3773
+ rowHeightMode: Re,
3774
+ normalizedBaseRowHeight: $e,
3775
+ selectionSnapshot: e.selectionSnapshot,
3776
+ selectionAnchor: e.selectionAnchor,
3777
+ rowSelectionSnapshot: e.rowSelectionSnapshot,
3778
+ rowHover: g(() => e.rowHover),
3779
+ stripedRows: g(() => e.stripedRows),
3780
+ chromeSignature: a,
3781
+ onCellEdit: e.onCellEdit,
3782
+ showRowIndex: g(() => e.showRowIndex),
3783
+ showRowSelection: g(() => e.rowSelection),
3784
+ isRowInPendingClipboardCut: fl,
3785
+ syncSelectionSnapshotFromRuntime: e.syncSelectionSnapshotFromRuntime,
3786
+ syncRowSelectionSnapshotFromRuntime: e.syncRowSelectionSnapshotFromRuntime,
3787
+ flushRowSelectionSnapshotUpdates: e.flushRowSelectionSnapshotUpdates,
3788
+ clearExternalPendingClipboardOperation: ml,
3789
+ reportFillWarning: e.reportFillWarning,
3790
+ reportCenterPaneDiagnostics: e.reportCenterPaneDiagnostics,
3791
+ reportFillPlumbingState: e.reportFillPlumbingState,
3792
+ reportFillPlumbingDetail: e.reportFillPlumbingDetail,
3793
+ firstColumnKey: Ct,
3794
+ columnFilterTextByKey: E,
3795
+ virtualization: g(() => e.virtualization),
3796
+ toggleSortForColumn: Jn,
3797
+ sortIndicator: Xn,
3798
+ setColumnFilterText: Zn,
3799
+ columnMenuEnabled: g(() => e.columnMenu.enabled),
3800
+ columnMenuTrigger: g(() => e.columnMenu.trigger),
3801
+ columnMenuMaxFilterValues: g(() => e.columnMenu.maxFilterValues),
3802
+ resolveColumnMenuItems: St,
3803
+ resolveColumnMenuDisabledItems: Jt,
3804
+ resolveColumnMenuDisabledReasons: Xt,
3805
+ resolveColumnMenuLabels: qn,
3806
+ resolveColumnMenuActionOptions: Zt,
3807
+ resolveColumnMenuCustomItems: et,
3808
+ isColumnFilterActive: qt,
3809
+ isColumnGrouped: Qt,
3810
+ resolveColumnGroupOrder: It,
3811
+ resolveColumnMenuSortDirection: Ue,
3812
+ resolveColumnMenuSelectedTokens: Yt,
3813
+ resolveColumnMenuValueEntries: Un,
3814
+ applyColumnMenuSort: on,
3815
+ applyColumnMenuPin: qe,
3816
+ applyColumnMenuGroupBy: xe,
3817
+ applyColumnMenuFilter: an,
3818
+ clearColumnMenuFilter: At,
3819
+ applyRowHeightSettings: xt,
3820
+ cloneRowData: Me,
3821
+ readSelectionCell: e.readSelectionCell,
3822
+ historyEnabled: g(() => e.history.enabled),
3823
+ historyMaxDepth: g(() => e.history.depth),
3824
+ historyShortcuts: g(() => e.history.shortcuts),
3825
+ history: e.history.adapter,
3826
+ isCellEditable: e.isCellEditable,
3827
+ isContextMenuVisible: () => Ht(),
3828
+ closeContextMenu: () => ot(),
3829
+ openContextMenuFromCurrentCell: () => {
3830
+ Vt();
3831
+ },
3832
+ runRowIndexKeyboardAction: (t, n) => Bt(t, n),
3833
+ reorderColumnsByHeader: e.columnReorder.enabled ? Rn : void 0,
3834
+ reorderRowsByIndex: e.rowReorder.enabled ? yn : void 0,
3835
+ cellClass: (t, n, o, s) => {
3836
+ const u = pn.value, v = !u || t.kind === "group" || t.rowId == null || t.rowId !== u.rowId || o.key !== u.columnKey ? null : {
3837
+ "grid-cell--find-match-active": !0,
3838
+ "grid-cell--find-match-flash-a": u.flashPhase === 0,
3839
+ "grid-cell--find-match-flash-b": u.flashPhase === 1
3840
+ };
3841
+ return ba(
3842
+ v,
3843
+ e.cellClass?.(t, n, o, s)
3844
+ );
3845
+ },
3846
+ cellStyle: e.cellStyle
3847
+ });
3848
+ te(
3849
+ () => e.registerHistoryController,
3850
+ (t) => {
3851
+ t?.(Ye);
3852
+ },
3853
+ { immediate: !0 }
3854
+ ), te(
3855
+ () => e.registerStructuralRowActionRunner,
3856
+ (t) => {
3857
+ t?.(Fn);
3858
+ },
3859
+ { immediate: !0 }
3860
+ ), te(
3861
+ () => e.history.shortcuts,
3862
+ (t, n, o) => {
3863
+ if (t !== "window" || typeof window > "u")
3864
+ return;
3865
+ const s = (u) => {
3866
+ if (u.defaultPrevented || u.altKey || !(u.ctrlKey || u.metaKey))
3867
+ return;
3868
+ const v = u.key.toLowerCase(), m = v === "z" ? u.shiftKey ? "redo" : "undo" : v === "y" && !u.shiftKey ? "redo" : null;
3869
+ m && (u.preventDefault(), Ye.runHistoryAction(m));
3870
+ };
3871
+ window.addEventListener("keydown", s), o(() => {
3872
+ window.removeEventListener("keydown", s);
3873
+ });
3874
+ },
3875
+ { immediate: !0 }
3876
+ ), Zl(() => {
3877
+ e.registerHistoryController?.(null), e.registerStructuralRowActionRunner?.(null);
3878
+ });
3879
+ const Cl = g(() => ht.value.columns.visibleColumns), jt = (t) => {
3880
+ e.runtime.api.selection.setSnapshot(rl(t)), e.syncSelectionSnapshotFromRuntime();
3881
+ }, pl = (t, n, o, s) => t.kind === "group" || t.rowId == null || o.column.capabilities?.editable === !1 ? !1 : e.isCellEditable ? e.isCellEditable({
3882
+ row: t.data,
3883
+ rowId: t.rowId,
3884
+ rowIndex: n,
3885
+ column: o.column,
3886
+ columnKey: o.key
3887
+ }) : !0, se = Tl(null), Oe = async () => {
3888
+ if (se.value)
3889
+ return se.value;
3890
+ const { useDataGridAppFindReplace: t } = await import("./useDataGridAppFindReplace-DTSLds4f.js"), n = t({
3891
+ runtime: e.runtime,
3892
+ visibleColumns: y,
3893
+ stageVisibleColumns: Cl,
3894
+ resolveCurrentCellCoord: ft,
3895
+ applyActiveCell: jt,
3896
+ revealCellInComfortZone: Rl,
3897
+ captureRowsSnapshot: we,
3898
+ captureRowsSnapshotForRowIds: yl,
3899
+ recordHistoryIntentTransaction: Sn,
3900
+ isCellEditable: pl
3901
+ });
3902
+ return se.value = n, n;
3903
+ }, N = {
3904
+ isPanelOpen: g(() => se.value?.isPanelOpen.value ?? !1),
3905
+ findText: g(() => se.value?.findText.value ?? ""),
3906
+ replaceText: g(() => se.value?.replaceText.value ?? ""),
3907
+ matchCase: g(() => se.value?.matchCase.value ?? !1),
3908
+ statusText: g(() => se.value?.statusText.value ?? ""),
3909
+ active: g(() => se.value?.active.value ?? !1),
3910
+ canFind: g(() => se.value?.canFind.value ?? !1),
3911
+ canReplaceCurrent: g(() => se.value?.canReplaceCurrent.value ?? !1),
3912
+ canReplaceAll: g(() => se.value?.canReplaceAll.value ?? !1),
3913
+ highlightedCell: g(() => se.value?.highlightedCell.value ?? null),
3914
+ openPanel: async () => {
3915
+ (await Oe()).openPanel();
3916
+ },
3917
+ closePanel: () => {
3918
+ se.value?.closePanel();
3919
+ },
3920
+ updateFindText: async (t) => {
3921
+ (await Oe()).updateFindText(t);
3922
+ },
3923
+ updateReplaceText: async (t) => {
3924
+ (await Oe()).updateReplaceText(t);
3925
+ },
3926
+ updateMatchCase: async (t) => {
3927
+ (await Oe()).updateMatchCase(t);
3928
+ },
3929
+ findNext: async () => (await Oe()).findNext(),
3930
+ findPrevious: async () => (await Oe()).findPrevious(),
3931
+ replaceCurrent: async () => (await Oe()).replaceCurrent(),
3932
+ replaceAll: async () => (await Oe()).replaceAll()
3933
+ };
3934
+ te(
3935
+ () => N.highlightedCell.value,
3936
+ (t) => {
3937
+ pn.value = t;
3938
+ },
3939
+ { immediate: !0 }
3940
+ );
3941
+ const {
3942
+ contextMenu: me,
3943
+ contextMenuRef: In,
3944
+ contextMenuStyle: Sl,
3945
+ closeContextMenu: He,
3946
+ openContextMenu: Gt,
3947
+ onContextMenuKeyDown: Il
3948
+ } = jr();
3949
+ Ht = () => me.value.visible, ot = He;
3950
+ const Mn = no({
3951
+ isInteractionBlocked: () => !1,
3952
+ isRangeMoveModifierActive: () => !1,
3953
+ resolveSelectionRange: Dt,
3954
+ resolveCellCoordFromDataset: _t,
3955
+ applyCellSelection: (t) => {
3956
+ jt(t);
3957
+ },
3958
+ resolveActiveCellCoord: ft,
3959
+ setActiveCellCoord: (t) => {
3960
+ jt(t);
3961
+ },
3962
+ cellCoordsEqual: (t, n) => t?.rowIndex === n?.rowIndex && t?.columnIndex === n?.columnIndex,
3963
+ isMultiCellSelection: wt,
3964
+ isCoordInsideRange: Ot,
3965
+ openContextMenu: Gt,
3966
+ closeContextMenu: He,
3967
+ isColumnContextEnabled: (t) => e.cellMenu.enabled ? kn(e.cellMenu, t).length > 0 : !1,
3968
+ isRowIndexContextEnabled: () => e.rowIndexMenu.enabled && e.showRowIndex
3969
+ }), xn = lo({
3970
+ resolveCurrentCellCoord: ft,
3971
+ resolveViewportElement: () => Fe.value,
3972
+ resolveRowAtIndex: (t) => e.runtime.getBodyRowAtIndex(t) ?? void 0,
3973
+ resolveColumnAtIndex: (t) => y.value[t] ?? void 0,
3974
+ resolveSelectionRange: Dt,
3975
+ isMultiCellSelection: (t) => wt(t),
3976
+ isCoordInsideRange: Ot,
3977
+ openContextMenu: Gt,
3978
+ isColumnContextEnabled: (t) => e.cellMenu.enabled && kn(e.cellMenu, t.key).length > 0
3979
+ });
3980
+ Vt = () => {
3981
+ xn.openContextMenuFromCurrentCell();
3982
+ };
3983
+ const Ml = (t) => {
3984
+ if (!e.rowIndexMenu.enabled || !e.showRowIndex || !Fe.value)
3985
+ return !1;
3986
+ const n = String(t), o = `.datagrid-stage__row-index-cell[data-row-id="${sr(n)}"]`, s = Fe.value.querySelector(o);
3987
+ if (!s)
3988
+ return !1;
3989
+ const u = s.getBoundingClientRect();
3990
+ return Gt(
3991
+ u.left + Math.max(10, Math.min(u.width / 2, Math.max(10, u.width - 10))),
3992
+ u.bottom - 4,
3993
+ {
3994
+ zone: "row-index",
3995
+ rowId: n
3996
+ }
3997
+ ), !0;
3998
+ }, Se = (t, n) => {
3999
+ Sn({
4000
+ intent: "edit",
4001
+ label: n
4002
+ }, t);
4003
+ };
4004
+ async function Fn(t, n) {
4005
+ const o = String(n), s = gt(o), u = s == null ? Et(o) : null, v = De(rt(o)), m = await e.runStructuralRowAction?.({
4006
+ action: t,
4007
+ rowId: n,
4008
+ row: u && u.kind !== "group" ? u : null,
4009
+ rowIndex: s ?? e.runtime.resolveBodyRowIndexById(o),
4010
+ placeholderVisualRowIndex: s,
4011
+ selectedRowIds: v
4012
+ });
4013
+ if (typeof m == "boolean")
4014
+ return m;
4015
+ if (s != null) {
4016
+ if (t === "delete-selected-rows") {
4017
+ if (v.length === 0)
4018
+ return !1;
4019
+ const R = we(), M = Tt(v);
4020
+ return M && Se(R, v.length > 1 ? `Delete ${v.length} rows` : "Delete row"), M;
4021
+ }
4022
+ if (t === "insert-row-above") {
4023
+ const R = we(), M = lt(
4024
+ s,
4025
+ s
4026
+ );
4027
+ return M && Se(R, "Insert row above"), M;
4028
+ }
4029
+ if (t === "insert-row-below") {
4030
+ const R = we(), M = lt(
4031
+ s + 1,
4032
+ s + 1
4033
+ );
4034
+ return M && Se(R, "Insert row below"), M;
4035
+ }
4036
+ return !1;
4037
+ }
4038
+ if (!u || u.kind === "group")
4039
+ return !1;
4040
+ if (t === "delete-selected-rows") {
4041
+ if (v.length === 0)
4042
+ return !1;
4043
+ const R = we(), M = Tt(v);
4044
+ return M && Se(R, v.length > 1 ? `Delete ${v.length} rows` : "Delete row"), M;
4045
+ }
4046
+ if (t === "insert-row-above") {
4047
+ if (!Ae())
4048
+ return !1;
4049
+ const R = we(), M = e.runtime.api.rows.insertDataBefore(
4050
+ n,
4051
+ [hn(u.data, Te(o))]
4052
+ );
4053
+ return M && Se(R, "Insert row above"), M;
4054
+ }
4055
+ if (t === "insert-row-below") {
4056
+ if (!Ae())
4057
+ return !1;
4058
+ const R = we(), M = e.runtime.api.rows.insertDataAfter(
4059
+ n,
4060
+ [hn(u.data, Te(o))]
4061
+ );
4062
+ return M && Se(R, "Insert row below"), M;
4063
+ }
4064
+ return !1;
4065
+ }
4066
+ Bt = async (t, n) => {
4067
+ const o = String(n);
4068
+ if (t === "open-row-menu")
4069
+ return Ml(o);
4070
+ if (t === "insert-row-above" || t === "insert-row-below" || t === "delete-selected-rows")
4071
+ return Fn(t, n);
4072
+ const s = gt(o);
4073
+ if (s != null) {
4074
+ if (t === "paste-row") {
4075
+ if (!Ae())
4076
+ return !1;
4077
+ const v = await fn();
4078
+ if (!v || v.length === 0)
4079
+ return !1;
4080
+ const m = we(), R = ie.value?.operation === "cut" ? ie.value.sourceRowIds : [];
4081
+ if (!cl(s + 1))
4082
+ return !1;
4083
+ const P = Math.max(0, s + 1), k = Te(
4084
+ R[0] ?? o
4085
+ ) ?? Te(o), W = R.length > 0 ? zt(R, P) : e.runtime.api.rows.insertDataAt(
4086
+ P,
4087
+ v.map((Q) => vn(Q, k))
4088
+ );
4089
+ return W && ie.value?.operation === "cut" && (ie.value = null), W && Se(
4090
+ m,
4091
+ R.length > 0 ? R.length > 1 ? `Move ${R.length} rows` : "Move row" : v.length > 1 ? `Paste ${v.length} rows` : "Paste row"
4092
+ ), W;
4093
+ }
4094
+ return !1;
4095
+ }
4096
+ const u = Et(o);
4097
+ if (!u || u.kind === "group")
4098
+ return !1;
4099
+ if (t === "copy-row") {
4100
+ const v = De(rt(o)), m = ze(v);
4101
+ return wn(
4102
+ m.length > 0 ? m : [u.data],
4103
+ "copy",
4104
+ v.length > 0 ? v : [o]
4105
+ );
4106
+ }
4107
+ if (t === "cut-row") {
4108
+ const v = De(rt(o)), m = ze(v);
4109
+ return wn(
4110
+ m.length > 0 ? m : [u.data],
4111
+ "cut",
4112
+ v.length > 0 ? v : [o]
4113
+ );
4114
+ }
4115
+ if (t === "paste-row") {
4116
+ if (!Ae())
4117
+ return !1;
4118
+ const v = await fn();
4119
+ if (!v || v.length === 0)
4120
+ return !1;
4121
+ const m = we(), R = ie.value?.operation === "cut" ? ie.value.sourceRowIds : [], M = Te(
4122
+ R[0] ?? o
4123
+ ) ?? Te(o), P = R.length > 0 ? bn(R, o) : e.runtime.api.rows.insertDataAfter(
4124
+ n,
4125
+ v.map((k) => vn(k, M))
4126
+ );
4127
+ return P && ie.value?.operation === "cut" && (ie.value = null), P && Se(
4128
+ m,
4129
+ R.length > 0 ? R.length > 1 ? `Move ${R.length} rows` : "Move row" : v.length > 1 ? `Paste ${v.length} rows` : "Paste row"
4130
+ ), P;
4131
+ }
4132
+ return !1;
4133
+ };
4134
+ const j = ro({
4135
+ resolveContextMenuState: () => ({
4136
+ zone: me.value.zone,
4137
+ columnKey: me.value.columnKey,
4138
+ rowId: me.value.rowId
4139
+ }),
4140
+ runHeaderContextAction: () => !1,
4141
+ runRowIndexContextAction: Bt,
4142
+ copySelection: gl,
4143
+ pasteSelection: vl,
4144
+ cutSelection: hl,
4145
+ clearCurrentSelection: bl,
4146
+ closeContextMenu: He
4147
+ }), at = U([]), An = (t) => at.value.includes(t), c = (t) => {
4148
+ at.value = at.value.filter((n) => n !== t && !n.startsWith(`${t}/`));
4149
+ }, p = (t, n = []) => {
4150
+ if (An(t)) {
4151
+ c(t);
4152
+ return;
4153
+ }
4154
+ at.value = Array.from(/* @__PURE__ */ new Set([...n, t]));
4155
+ }, S = (t, n, o, s, u) => {
4156
+ const m = u[n === "paste-values" ? "pasteValues" : n];
4157
+ if (m?.hidden)
4158
+ return null;
4159
+ const R = o.has(t) || m?.disabled === !0;
4160
+ return {
4161
+ kind: "action",
4162
+ id: n,
4163
+ label: m?.label ?? cr[n],
4164
+ disabled: R,
4165
+ title: m?.disabledReason ?? s[t],
4166
+ actionId: n
4167
+ };
4168
+ }, D = (t, n, o) => {
4169
+ if (t.hidden === !0)
4170
+ return null;
4171
+ const s = n.length > 0 ? `${n}/${t.key}` : t.key, u = `custom:${s}`, v = t.disabledReason?.trim() || void 0;
4172
+ if (t.kind === "submenu") {
4173
+ const m = t.items.flatMap((R) => {
4174
+ const M = D(R, s, o);
4175
+ return M ? [M] : [];
4176
+ });
4177
+ return m.length === 0 ? null : {
4178
+ kind: "submenu",
4179
+ id: u,
4180
+ label: t.label,
4181
+ disabled: t.disabled === !0,
4182
+ title: v,
4183
+ entries: m
4184
+ };
4185
+ }
4186
+ return {
4187
+ kind: "action",
4188
+ id: u,
4189
+ label: t.label,
4190
+ disabled: t.disabled === !0,
4191
+ title: v,
4192
+ onSelect: async () => {
4193
+ t.disabled !== !0 && await t.onSelect?.({
4194
+ zone: o.zone,
4195
+ columnKey: o.columnKey,
4196
+ rowId: o.rowId,
4197
+ closeMenu: He
4198
+ });
4199
+ }
4200
+ };
4201
+ }, re = (t, n, o) => {
4202
+ const s = /* @__PURE__ */ new Map(), u = (m, R) => {
4203
+ if (!R)
4204
+ return;
4205
+ const M = s.get(m) ?? [];
4206
+ M.push([R]), s.set(m, M);
4207
+ };
4208
+ for (const m of n)
4209
+ u(m.placement ?? "end", D(m, "", o));
4210
+ const v = [
4211
+ ...s.get("start") ?? []
4212
+ ];
4213
+ for (const m of t)
4214
+ v.push(...s.get(`before:${m.itemKey}`) ?? []), v.push([...m.entries]), v.push(...s.get(`after:${m.itemKey}`) ?? []);
4215
+ return v.push(...s.get("end") ?? []), v.filter((m) => m.length > 0);
4216
+ }, Y = g(() => {
4217
+ if (!me.value.visible)
4218
+ return [];
4219
+ const t = me.value.zone;
4220
+ if (t === "cell" || t === "range") {
4221
+ const n = me.value.columnKey ?? "";
4222
+ if (!e.cellMenu.enabled || !n)
4223
+ return [];
4224
+ const o = kn(e.cellMenu, n), s = new Set(Go(e.cellMenu, n)), u = $o(e.cellMenu, n), v = Lo(e.cellMenu, n), m = Ko(e.cellMenu, n), R = No(e.cellMenu, n), M = [];
4225
+ for (const P of o) {
4226
+ const W = (_a[P] ?? []).flatMap((Q) => {
4227
+ const ve = S(P, Q, s, u, m);
4228
+ return ve ? [ve] : [];
4229
+ });
4230
+ if (W.length !== 0) {
4231
+ if (P === "pasteSpecial") {
4232
+ const Q = s.has(P) || W.every((ve) => ve.disabled);
4233
+ M.push({
4234
+ itemKey: P,
4235
+ entries: [{
4236
+ kind: "submenu",
4237
+ id: "paste-special-submenu",
4238
+ label: v.pasteSpecial ?? "Paste special",
4239
+ disabled: Q,
4240
+ title: u[P] ?? (W.length === 1 ? W[0]?.title : void 0),
4241
+ entries: W
4242
+ }]
4243
+ });
4244
+ continue;
4245
+ }
4246
+ M.push({
4247
+ itemKey: P,
4248
+ entries: W
4249
+ });
4250
+ }
4251
+ }
4252
+ return re(M, R, {
4253
+ zone: t,
4254
+ columnKey: n,
4255
+ rowId: me.value.rowId
4256
+ });
4257
+ }
4258
+ if (t === "row-index") {
4259
+ if (!e.rowIndexMenu.enabled)
4260
+ return [];
4261
+ const n = gt(me.value.rowId ?? ""), o = Wo(e.rowIndexMenu), s = new Set(Uo(e.rowIndexMenu)), u = qo(e.rowIndexMenu), v = Yo(e.rowIndexMenu), m = [];
4262
+ for (const R of o) {
4263
+ const P = (ka[R] ?? []).flatMap((k) => {
4264
+ const Q = v[k === "insert-row-above" ? "insertAbove" : k === "insert-row-below" ? "insertBelow" : k === "copy-row" ? "copy" : k === "paste-row" ? "paste" : k === "delete-selected-rows" ? "deleteSelected" : "cut"];
4265
+ if (Q?.hidden)
4266
+ return [];
4267
+ let Ie = s.has(R) || Q?.disabled === !0, ee = Q?.disabledReason ?? u[R];
4268
+ return n != null && k !== "delete-selected-rows" && k !== "insert-row-above" && k !== "insert-row-below" && k !== "paste-row" && (Ie = !0, ee = ee ?? "Placeholder rows must be materialized before this action is available"), (k === "insert-row-above" || k === "insert-row-below") && !Ae() && !Cn() && (Ie = !0, ee = ee ?? "Row insertion is not supported by the current row model"), k === "paste-row" && !Ae() && (Ie = !0, ee = ee ?? "Row insertion is not supported by the current row model"), k === "cut-row" && !Pe() && (Ie = !0, ee = ee ?? "Row deletion is not supported by the current row model"), k === "delete-selected-rows" && !Pe() && !Cn() && (Ie = !0, ee = ee ?? "Row deletion is not supported by the current row model"), k === "delete-selected-rows" && De(
4269
+ rt(me.value.rowId ?? "")
4270
+ ).length === 0 && (Ie = !0, ee = ee ?? "No deletable rows are selected"), [{
4271
+ kind: "action",
4272
+ id: k,
4273
+ label: wl(k, Q?.label),
4274
+ disabled: Ie,
4275
+ title: ee,
4276
+ actionId: k
4277
+ }];
4278
+ });
4279
+ P.length > 0 && m.push(P);
4280
+ }
4281
+ return m;
4282
+ }
4283
+ return [];
4284
+ }), B = (t) => {
4285
+ Mn.dispatchViewportContextMenu(t);
4286
+ }, $ = () => {
4287
+ Fe.value?.querySelector(".grid-body-viewport")?.focus({ preventScroll: !0 });
4288
+ }, be = () => {
4289
+ dt(() => {
4290
+ if (typeof window < "u") {
4291
+ window.requestAnimationFrame(() => {
4292
+ $();
4293
+ });
4294
+ return;
4295
+ }
4296
+ $();
4297
+ });
4298
+ }, ue = async (t) => {
4299
+ await j.runContextMenuAction(t) && ($(), He(), be());
4300
+ }, _e = async (t) => {
4301
+ if (!t.disabled && t.kind !== "submenu") {
4302
+ if (t.actionId) {
4303
+ await ue(t.actionId);
4304
+ return;
4305
+ }
4306
+ await t.onSelect?.();
4307
+ }
4308
+ }, ge = (t, n = [], o = 0) => t.flatMap((s) => {
4309
+ if (s.kind === "submenu") {
4310
+ const u = An(s.id), v = u ? T("div", {
4311
+ class: "datagrid-context-menu__submenu-panel",
4312
+ role: "menu",
4313
+ "data-datagrid-menu-parent-action": s.id
4314
+ }, ge(s.entries, [...n, s.id], o + 1)) : null;
4315
+ return [T("div", {
4316
+ class: [
4317
+ "datagrid-context-menu__submenu",
4318
+ u ? "datagrid-context-menu__submenu--open" : null
4319
+ ]
4320
+ }, [
4321
+ T("button", {
4322
+ type: "button",
4323
+ class: [
4324
+ "datagrid-context-menu__item",
4325
+ "datagrid-context-menu__item--submenu"
4326
+ ],
4327
+ "data-datagrid-menu-action": s.id,
4328
+ "data-datagrid-menu-depth": String(o),
4329
+ "data-datagrid-menu-open": u ? "true" : void 0,
4330
+ "aria-haspopup": "menu",
4331
+ "aria-expanded": u ? "true" : "false",
4332
+ disabled: s.disabled,
4333
+ title: s.title,
4334
+ onClick: () => {
4335
+ p(s.id, n);
4336
+ }
4337
+ }, [
4338
+ T("span", s.label),
4339
+ T("span", {
4340
+ class: "datagrid-context-menu__submenu-arrow",
4341
+ "aria-hidden": "true"
4342
+ }, ">")
4343
+ ]),
4344
+ ...v ? [v] : []
4345
+ ])];
4346
+ }
4347
+ return [T("button", {
4348
+ type: "button",
4349
+ class: "datagrid-context-menu__item",
4350
+ "data-datagrid-menu-action": s.id,
4351
+ "data-datagrid-menu-depth": String(o),
4352
+ disabled: s.disabled,
4353
+ title: s.title,
4354
+ onClick: () => {
4355
+ _e(s);
4356
+ }
4357
+ }, s.label)];
4358
+ }), Lt = () => !me.value.visible || Y.value.length === 0 ? null : T("div", {
4359
+ ref: In,
4360
+ class: "datagrid-context-menu",
4361
+ style: Sl.value,
4362
+ role: "menu",
4363
+ tabindex: -1,
4364
+ onKeydown: (t) => {
4365
+ Il(t, {
4366
+ onEscape: () => {
4367
+ $();
4368
+ }
4369
+ });
4370
+ }
4371
+ }, Y.value.flatMap((t, n) => {
4372
+ const o = [];
4373
+ return n > 0 && o.push(T("div", {
4374
+ class: "datagrid-context-menu__separator",
4375
+ "aria-hidden": "true"
4376
+ })), o.push(...ge(t)), o;
4377
+ })), K = () => d.value ? T("div", {
4378
+ class: "datagrid-app-sort-pending",
4379
+ role: "status",
4380
+ "aria-live": "polite",
4381
+ "aria-label": "Sorting"
4382
+ }, [
4383
+ T("span", {
4384
+ class: "datagrid-app-sort-pending__spinner",
4385
+ "aria-hidden": "true"
4386
+ }),
4387
+ T("span", {
4388
+ class: "datagrid-app-sort-pending__label"
4389
+ }, "Sorting")
4390
+ ]) : null;
4391
+ te(
4392
+ () => me.value.visible,
4393
+ (t, n, o) => {
4394
+ if (t || (at.value = []), !t || typeof window > "u")
4395
+ return;
4396
+ const s = (v) => {
4397
+ const m = v.target;
4398
+ m && In.value?.contains(m) || He();
4399
+ }, u = () => {
4400
+ He();
4401
+ };
4402
+ window.addEventListener("mousedown", s, !0), window.addEventListener("blur", u), o(() => {
4403
+ window.removeEventListener("mousedown", s, !0), window.removeEventListener("blur", u);
4404
+ });
4405
+ }
4406
+ );
4407
+ const G = g(() => ({
4408
+ ...ht.value,
4409
+ customOverlays: e.customOverlays,
4410
+ columns: {
4411
+ ...ht.value.columns,
4412
+ columnMenuEnabled: e.columnMenu.enabled,
4413
+ columnMenuTrigger: e.columnMenu.trigger,
4414
+ columnMenuMaxFilterValues: e.columnMenu.maxFilterValues,
4415
+ resolveColumnMenuItems: St,
4416
+ resolveColumnMenuDisabledItems: Jt,
4417
+ resolveColumnMenuDisabledReasons: Xt,
4418
+ resolveColumnMenuLabels: qn,
4419
+ resolveColumnMenuActionOptions: Zt,
4420
+ resolveColumnMenuCustomItems: et,
4421
+ isColumnFilterActive: qt,
4422
+ isColumnGrouped: Qt,
4423
+ resolveColumnGroupOrder: It,
4424
+ resolveColumnMenuSortDirection: Ue,
4425
+ resolveColumnMenuSelectedTokens: Yt,
4426
+ applyColumnMenuSort: on,
4427
+ applyColumnMenuPin: qe,
4428
+ applyColumnMenuGroupBy: xe,
4429
+ applyColumnMenuFilter: an,
4430
+ clearColumnMenuFilter: At
4431
+ },
4432
+ rows: {
4433
+ ...ht.value.rows,
4434
+ sourceRows: e.rows,
4435
+ rowHover: e.rowHover,
4436
+ stripedRows: e.stripedRows
4437
+ }
4438
+ })), J = g(() => {
4439
+ const t = [];
4440
+ return e.history.enabled && e.history.controls === "toolbar" && (t.push({
4441
+ key: "history-undo",
4442
+ component: nr,
4443
+ props: {
4444
+ action: "undo",
4445
+ label: "Undo",
4446
+ disabled: !Ye.canUndo(),
4447
+ onTrigger: () => Ye.runHistoryAction("undo")
4448
+ }
4449
+ }), t.push({
4450
+ key: "history-redo",
4451
+ component: nr,
4452
+ props: {
4453
+ action: "redo",
4454
+ label: "Redo",
4455
+ disabled: !Ye.canRedo(),
4456
+ onTrigger: () => Ye.runHistoryAction("redo")
4457
+ }
4458
+ })), e.columnLayout.enabled && t.push({
4459
+ key: "column-layout",
4460
+ component: Do,
4461
+ props: {
4462
+ isOpen: z.value,
4463
+ items: V.value,
4464
+ buttonLabel: e.columnLayout.buttonLabel,
4465
+ labels: e.columnLayout.labels,
4466
+ active: !1,
4467
+ onOpen: _,
4468
+ onToggleVisibility: q,
4469
+ onMoveUp: pt,
4470
+ onMoveDown: Hn,
4471
+ onMoveToPosition: (n) => {
4472
+ Vn(n.key, n.targetKey, n.placement);
4473
+ },
4474
+ onApply: zn,
4475
+ onCancel: oe
4476
+ }
4477
+ }), e.advancedFilter.enabled && t.push({
4478
+ key: "advanced-filter",
4479
+ component: ma,
4480
+ props: {
4481
+ isOpen: Nt.value,
4482
+ clauses: Bn.value,
4483
+ columns: ne.value,
4484
+ appliedFilterSummaryItems: Ne.value,
4485
+ hasAnyFilters: mt.value,
4486
+ buttonLabel: e.advancedFilter.buttonLabel,
4487
+ labels: e.advancedFilter.labels,
4488
+ active: mt.value,
4489
+ showActiveIcon: mt.value,
4490
+ onOpen: tn,
4491
+ onAdd: $n,
4492
+ onRemove: Kn,
4493
+ onUpdateClause: Nn,
4494
+ onApply: nn,
4495
+ onCancel: Wt,
4496
+ onResetAll: Yn
4497
+ }
4498
+ }), e.findReplace.enabled && t.push({
4499
+ key: "find-replace",
4500
+ component: wa,
4501
+ props: {
4502
+ isOpen: N.isPanelOpen.value,
4503
+ findText: N.findText.value,
4504
+ replaceText: N.replaceText.value,
4505
+ matchCase: N.matchCase.value,
4506
+ statusText: N.statusText.value,
4507
+ buttonLabel: e.findReplace.buttonLabel,
4508
+ active: N.active.value,
4509
+ canFind: N.canFind.value,
4510
+ canReplaceCurrent: N.canReplaceCurrent.value,
4511
+ canReplaceAll: N.canReplaceAll.value,
4512
+ onOpen: N.openPanel,
4513
+ onCancel: N.closePanel,
4514
+ onUpdateFindText: N.updateFindText,
4515
+ onUpdateReplaceText: N.updateReplaceText,
4516
+ onUpdateMatchCase: N.updateMatchCase,
4517
+ onFindNext: N.findNext,
4518
+ onFindPrevious: N.findPrevious,
4519
+ onReplaceCurrent: N.replaceCurrent,
4520
+ onReplaceAll: N.replaceAll
4521
+ }
4522
+ }), e.aggregations.enabled && e.mode !== "pivot" && t.push({
4523
+ key: "aggregations",
4524
+ component: fa,
4525
+ props: {
4526
+ isOpen: Ke.value,
4527
+ basis: Qe.value,
4528
+ items: Z.value,
4529
+ buttonLabel: e.aggregations.buttonLabel,
4530
+ active: Xe.value && (Ke.value || !!Ze.value?.columns.length),
4531
+ disabled: !Xe.value,
4532
+ disabledReason: Xe.value ? "" : "Aggregations require an active group-by model.",
4533
+ onOpen: ln,
4534
+ onUpdateBasis: el,
4535
+ onToggleColumn: tl,
4536
+ onUpdateOp: Ft,
4537
+ onClear: Qn,
4538
+ onApply: We,
4539
+ onCancel: rn
4540
+ }
4541
+ }), [...t, ...e.toolbarModules].map(va);
4542
+ });
4543
+ te(
4544
+ J,
4545
+ (t) => {
4546
+ e.reportToolbarModules?.(t);
4547
+ },
4548
+ { immediate: !0, flush: "post" }
4549
+ );
4550
+ const ye = g(() => e.viewMode === "gantt" && e.chrome.toolbarPlacement === "integrated" ? "stacked" : e.chrome.toolbarPlacement), Dn = g(() => J.value.length > 0 && ye.value !== "hidden"), xl = g(() => Dn.value && ye.value === "stacked"), Fl = g(() => Dn.value && ye.value === "integrated");
4551
+ return () => T("div", {
4552
+ class: [
4553
+ "datagrid-app-layout",
4554
+ `datagrid-app-layout--toolbar-${ye.value}`,
4555
+ `datagrid-app-layout--density-${e.chrome.density}`,
4556
+ e.layoutMode === "auto-height" ? "datagrid-app-layout--auto-height" : "datagrid-app-layout--fill"
4557
+ ],
4558
+ style: l.value
4559
+ }, [
4560
+ xl.value ? T(tr, {
4561
+ modules: J.value,
4562
+ variant: "standalone"
4563
+ }) : null,
4564
+ T("div", {
4565
+ class: [
4566
+ "datagrid-app-workspace",
4567
+ e.layoutMode === "auto-height" ? "datagrid-app-workspace--auto-height" : "datagrid-app-workspace--fill"
4568
+ ]
4569
+ }, [
4570
+ Fl.value ? T("div", {
4571
+ class: [
4572
+ "datagrid-app-stage-surface",
4573
+ e.layoutMode === "auto-height" ? "datagrid-app-stage-surface--auto-height" : "datagrid-app-stage-surface--fill",
4574
+ "datagrid-app-stage-surface--integrated"
4575
+ ]
4576
+ }, [
4577
+ T(tr, {
4578
+ modules: J.value,
4579
+ variant: "integrated"
4580
+ }),
4581
+ T("div", {
4582
+ class: [
4583
+ "datagrid-app-stage",
4584
+ "datagrid-app-stage--integrated",
4585
+ {
4586
+ "datagrid-app-stage--sorting-pending": d.value !== null
4587
+ },
4588
+ e.layoutMode === "auto-height" ? "datagrid-app-stage--auto-height" : "datagrid-app-stage--fill"
4589
+ ],
4590
+ ref: Fe
4591
+ }, [
4592
+ e.viewMode === "gantt" ? T(Ql, {
4593
+ stageContext: bt,
4594
+ runtime: e.runtime,
4595
+ gantt: e.gantt,
4596
+ baseRowHeight: $e.value,
4597
+ rowVersion: r.value
4598
+ }) : T(er, {
4599
+ ...G.value,
4600
+ stageContext: bt,
4601
+ onViewportContextMenu: B
4602
+ }),
4603
+ K(),
4604
+ Lt()
4605
+ ])
4606
+ ]) : T("div", {
4607
+ class: [
4608
+ "datagrid-app-stage",
4609
+ {
4610
+ "datagrid-app-stage--sorting-pending": d.value !== null
4611
+ },
4612
+ e.layoutMode === "auto-height" ? "datagrid-app-stage--auto-height" : "datagrid-app-stage--fill"
4613
+ ],
4614
+ ref: Fe
4615
+ }, [
4616
+ e.viewMode === "gantt" ? T(Ql, {
4617
+ stageContext: bt,
4618
+ runtime: e.runtime,
4619
+ gantt: e.gantt,
4620
+ baseRowHeight: $e.value,
4621
+ rowVersion: r.value
4622
+ }) : T(er, {
4623
+ ...G.value,
4624
+ stageContext: bt,
4625
+ onViewportContextMenu: B
4626
+ }),
4627
+ K(),
4628
+ Lt()
4629
+ ]),
4630
+ e.inspectorPanel ? T("aside", {
4631
+ class: "datagrid-app-inspector-shell"
4632
+ }, [
4633
+ T(e.inspectorPanel.component, {
4634
+ ...e.inspectorPanel.props ?? {}
4635
+ })
4636
+ ]) : null
4637
+ ])
4638
+ ]);
4639
+ }
4640
+ });
4641
+ function ai() {
4642
+ return (e) => e;
4643
+ }
4644
+ const Pl = /* @__PURE__ */ new WeakMap(), mr = /* @__PURE__ */ new WeakMap();
4645
+ function Pa(e) {
4646
+ if (!e)
4647
+ return;
4648
+ const l = Pl.get(e);
4649
+ if (l)
4650
+ return l;
4651
+ const a = e.initialTreeData?.expandedByDefault ?? !1;
4652
+ if (e.initialTreeData?.expandedByDefault === a)
4653
+ return Pl.set(e, e), e;
4654
+ const r = {
4655
+ ...e
4656
+ };
4657
+ return e.initialTreeData && (r.initialTreeData = {
4658
+ ...e.initialTreeData,
4659
+ expandedByDefault: a
4660
+ }), Pl.set(e, r), r;
4661
+ }
4662
+ function Ta(e) {
4663
+ return !e || e.length === 0 ? [] : e.map((l) => ({ ...l }));
4664
+ }
4665
+ function za(e) {
4666
+ return !e || e.length === 0 ? [] : e.map((l) => ({ ...l }));
4667
+ }
4668
+ function Ha(e) {
4669
+ return !e || e.length === 0 ? [] : e.map(({ formula: l, ...a }) => ({ ...a }));
4670
+ }
4671
+ function Va(e) {
4672
+ return !e || e.length === 0 ? [] : e.flatMap((l) => {
4673
+ const a = typeof l.formula == "string" ? l.formula.trim() : "";
4674
+ return a ? [{
4675
+ name: l.key,
4676
+ formula: a
4677
+ }] : [];
4678
+ });
4679
+ }
4680
+ function Ba(e, l) {
4681
+ const a = /* @__PURE__ */ new Map();
4682
+ for (const r of e)
4683
+ a.set(r.name, { ...r });
4684
+ for (const r of Ta(l))
4685
+ a.set(r.name, r);
4686
+ return Array.from(a.values());
4687
+ }
4688
+ function ii(e) {
4689
+ return Ha(e);
4690
+ }
4691
+ function si(e) {
4692
+ const l = Pa(e.clientRowModelOptions), a = e.enterpriseClientRowModelOptions, r = Va(e.columns), i = e.formulas !== void 0, d = e.computedFields !== void 0, w = e.formulaFunctions !== void 0, b = r.length > 0, h = i || b ? Ba(r, e.formulas) : void 0, E = d ? za(e.computedFields) : void 0, O = w ? e.formulaFunctions ?? {} : void 0, L = !!(b || i || d || w);
4693
+ if (!l && !L)
4694
+ return a ? {
4695
+ ...a
4696
+ } : void 0;
4697
+ if (!L) {
4698
+ if (l && !a)
4699
+ return l;
4700
+ if (!l && a)
4701
+ return a;
4702
+ if (l && a) {
4703
+ let I = mr.get(l);
4704
+ I || (I = /* @__PURE__ */ new WeakMap(), mr.set(l, I));
4705
+ const C = I.get(a);
4706
+ if (C)
4707
+ return C;
4708
+ const F = {
4709
+ ...l,
4710
+ ...a
4711
+ };
4712
+ return I.set(
4713
+ a,
4714
+ F
4715
+ ), F;
4716
+ }
4717
+ }
4718
+ return {
4719
+ ...l ?? {},
4720
+ ...d ? { initialComputedFields: E } : {},
4721
+ ...i || b ? { initialFormulaFields: h } : {},
4722
+ ...w ? { initialFormulaFunctionRegistry: O } : {},
4723
+ ...a?.computeMode ? { computeMode: a.computeMode } : {},
4724
+ ...a?.workerPatchDispatchThreshold !== void 0 ? { workerPatchDispatchThreshold: a.workerPatchDispatchThreshold } : {},
4725
+ ...a?.formulaColumnCacheMaxColumns !== void 0 ? { formulaColumnCacheMaxColumns: a.formulaColumnCacheMaxColumns } : {}
4726
+ };
4727
+ }
4728
+ const ja = "comfortable", Ga = {
4729
+ comfortable: {
4730
+ toolbarGap: 10,
4731
+ workspaceGap: 12
4732
+ },
4733
+ compact: {
4734
+ toolbarGap: 6,
4735
+ workspaceGap: 8
4736
+ }
4737
+ };
4738
+ function La(e) {
4739
+ return e === "compact" ? "compact" : ja;
4740
+ }
4741
+ function $a(e) {
4742
+ return e === "integrated" || e === "hidden" || e === "stacked" ? e : "stacked";
4743
+ }
4744
+ function fr(e, l) {
4745
+ return Number.isFinite(e) ? Math.max(0, e) : l;
4746
+ }
4747
+ function ui(e) {
4748
+ const l = typeof e == "object" && e !== null ? e : null, a = La(typeof e == "string" ? e : l?.density), r = Ga[a];
4749
+ return {
4750
+ density: a,
4751
+ toolbarPlacement: $a(l?.toolbarPlacement),
4752
+ toolbarGap: fr(l?.toolbarGap, r.toolbarGap),
4753
+ workspaceGap: fr(l?.workspaceGap, r.workspaceGap)
4754
+ };
4755
+ }
4756
+ function di(e) {
4757
+ return typeof e == "boolean" ? {
4758
+ enabled: e
4759
+ } : e ? {
4760
+ enabled: e.enabled ?? !0
4761
+ } : {
4762
+ enabled: !1
4763
+ };
4764
+ }
4765
+ function ci(e) {
4766
+ return typeof e == "boolean" ? {
4767
+ enabled: e
4768
+ } : e ? {
4769
+ enabled: e.enabled ?? !0
4770
+ } : {
4771
+ enabled: !1
4772
+ };
4773
+ }
4774
+ function wr() {
4775
+ const e = globalThis.performance;
4776
+ return e && typeof e.now == "function" ? e.now() : Date.now();
4777
+ }
4778
+ const Ka = (e, l) => {
4779
+ const a = wr();
4780
+ return {
4781
+ result: l(),
4782
+ duration: Math.max(0, wr() - a)
4783
+ };
4784
+ };
4785
+ function gr(e) {
4786
+ return {
4787
+ projectionStageTimer: Ka,
4788
+ ...e ?? {}
4789
+ };
4790
+ }
4791
+ function mi(e) {
4792
+ const l = U(0), a = Al(), r = Tl(
4793
+ e.rowModel.value ? null : Al({
4794
+ rows: e.rows.value,
4795
+ ...gr(e.clientRowModelOptions.value)
4796
+ })
4797
+ ), i = (h) => {
4798
+ !h || h === e.rowModel.value || "dispose" in h && typeof h.dispose == "function" && h.dispose();
4799
+ }, d = (h) => {
4800
+ !h || h === e.rowModel.value || dt(() => {
4801
+ i(h);
4802
+ });
4803
+ }, w = () => {
4804
+ if (e.rowModel.value)
4805
+ return;
4806
+ const h = r.value;
4807
+ r.value = Al({
4808
+ rows: e.rows.value,
4809
+ ...gr(e.clientRowModelOptions.value)
4810
+ }), l.value += 1, e.onOwnedRowModelRecreated?.(), d(h);
4811
+ }, b = g(() => e.rowModel.value ?? r.value ?? a);
4812
+ return te(
4813
+ e.rows,
4814
+ (h) => {
4815
+ r.value && r.value.setRows(h);
4816
+ },
4817
+ { deep: !1 }
4818
+ ), te(
4819
+ e.clientRowModelOptions,
4820
+ () => {
4821
+ w();
4822
+ },
4823
+ { deep: !0 }
4824
+ ), te(
4825
+ e.rowModel,
4826
+ (h) => {
4827
+ if (h) {
4828
+ const E = r.value;
4829
+ r.value = null, l.value += 1, d(E);
4830
+ return;
4831
+ }
4832
+ r.value || w();
4833
+ }
4834
+ ), Pr(() => {
4835
+ i(r.value), i(a);
4836
+ }), {
4837
+ dataGridInstanceKey: l,
4838
+ resolvedRowModel: b,
4839
+ disposeOwnedRowModel: i
4840
+ };
4841
+ }
4842
+ export {
4843
+ oi as D,
4844
+ tr as a,
4845
+ di as b,
4846
+ si as c,
4847
+ ci as d,
4848
+ Jo as e,
4849
+ ua as f,
4850
+ ni as g,
4851
+ li as h,
4852
+ ri as i,
4853
+ ti as j,
4854
+ ii as k,
4855
+ ai as l,
4856
+ ui as r,
4857
+ mi as u
4858
+ };