@object-ui/plugin-report 4.2.1 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,57 +2,57 @@ import { ComponentRegistry as e } from "@object-ui/core";
2
2
  import * as t from "react";
3
3
  import n, { useCallback as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
4
4
  import { isJoinedSpecReport as c, isSpecReport as l } from "@object-ui/types";
5
- import { Badge as u, Button as d, Card as f, CardContent as p, CardDescription as m, CardHeader as h, CardTitle as g, Checkbox as _, ConfigPanelRenderer as v, Input as y, Label as b, Skeleton as x, SortBuilder as S, Tabs as C, TabsContent as w, TabsList as T, TabsTrigger as E, useConfigDraft as D } from "@object-ui/components";
6
- import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
7
- import { useTranslation as j } from "react-i18next";
8
- import { ObjectGrid as M } from "@object-ui/plugin-grid";
9
- import { useSafeFieldLabel as ee } from "@object-ui/i18n";
10
- import { SchemaRenderer as N } from "@object-ui/react";
11
- import { Calendar as P, Clock as F, Download as I, Filter as te, Layers as ne, Mail as re, Plus as L, Printer as R, RefreshCw as ie, Save as ae, Settings as oe, Trash2 as z } from "lucide-react";
12
- import { getCellRenderer as se, resolveCellRendererType as ce } from "@object-ui/fields";
5
+ import { Badge as u, Button as d, Card as f, CardContent as p, CardDescription as m, CardHeader as h, CardTitle as g, Checkbox as _, ConfigPanelRenderer as v, Dialog as y, DialogContent as b, DialogDescription as x, DialogFooter as S, DialogHeader as C, DialogTitle as w, DialogTrigger as T, Input as E, Label as D, Skeleton as O, Tabs as k, TabsContent as A, TabsList as j, TabsTrigger as M, useConfigDraft as ee } from "@object-ui/components";
6
+ import { Fragment as N, jsx as P, jsxs as F } from "react/jsx-runtime";
7
+ import { useTranslation as I } from "react-i18next";
8
+ import { ObjectGrid as L } from "@object-ui/plugin-grid";
9
+ import { useSafeFieldLabel as R } from "@object-ui/i18n";
10
+ import { SchemaRenderer as z } from "@object-ui/react";
11
+ import { AlertTriangle as B, ArrowDown as V, ArrowUp as te, Calendar as ne, ChevronDown as H, ChevronRight as re, Clock as ie, Download as ae, Filter as oe, Layers as se, Mail as ce, Plus as U, Printer as le, RefreshCw as ue, Save as de, Search as fe, Settings as pe, Trash2 as W } from "lucide-react";
12
+ import { getCellRenderer as me, resolveCellRendererType as he } from "@object-ui/fields";
13
13
  //#region src/LegacyReportRenderer.tsx
14
- var B = ({ schema: t }) => {
14
+ var ge = ({ schema: t }) => {
15
15
  let { title: n, description: r, data: i, columns: a } = t;
16
16
  t.chart?.type;
17
17
  let o = !!t.chart;
18
- return /* @__PURE__ */ A(f, {
18
+ return /* @__PURE__ */ F(f, {
19
19
  className: `h-full flex flex-col ${t.className || ""}`,
20
- children: [/* @__PURE__ */ A(h, { children: [n && /* @__PURE__ */ k(g, { children: n }), r && /* @__PURE__ */ k(m, { children: r })] }), /* @__PURE__ */ A(p, {
20
+ children: [/* @__PURE__ */ F(h, { children: [n && /* @__PURE__ */ P(g, { children: n }), r && /* @__PURE__ */ P(m, { children: r })] }), /* @__PURE__ */ F(p, {
21
21
  className: "flex-1 overflow-auto space-y-4",
22
22
  children: [o && (() => {
23
23
  let n = t.chart?.type, r = n ? e.get(n) : null;
24
- return r ||= e.get("chart"), r ? /* @__PURE__ */ k("div", {
24
+ return r ||= e.get("chart"), r ? /* @__PURE__ */ P("div", {
25
25
  className: "min-h-[300px] border rounded-lg p-4 bg-background/50",
26
- children: /* @__PURE__ */ k(r, { schema: {
26
+ children: /* @__PURE__ */ P(r, { schema: {
27
27
  ...t.chart,
28
28
  data: t.chart.data || i
29
29
  } })
30
- }) : /* @__PURE__ */ A("div", {
30
+ }) : /* @__PURE__ */ F("div", {
31
31
  className: "min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center",
32
32
  children: ["Unknown component type: ", n || "chart"]
33
33
  });
34
- })(), i && i.length > 0 && /* @__PURE__ */ k("div", {
34
+ })(), i && i.length > 0 && /* @__PURE__ */ P("div", {
35
35
  className: "border rounded-lg",
36
36
  children: (() => {
37
37
  let t = e.get("aggrid") || e.get("table");
38
- return t ? /* @__PURE__ */ k(t, { schema: {
38
+ return t ? /* @__PURE__ */ P(t, { schema: {
39
39
  type: "aggrid",
40
40
  rowData: i,
41
41
  columnDefs: a,
42
42
  domLayout: "autoHeight"
43
- } }) : /* @__PURE__ */ k("div", {
43
+ } }) : /* @__PURE__ */ P("div", {
44
44
  className: "overflow-x-auto",
45
- children: /* @__PURE__ */ A("table", {
45
+ children: /* @__PURE__ */ F("table", {
46
46
  className: "w-full text-sm text-left",
47
- children: [/* @__PURE__ */ k("thead", {
47
+ children: [/* @__PURE__ */ P("thead", {
48
48
  className: "text-xs uppercase bg-muted",
49
- children: /* @__PURE__ */ k("tr", { children: a?.map((e) => /* @__PURE__ */ k("th", {
49
+ children: /* @__PURE__ */ P("tr", { children: a?.map((e) => /* @__PURE__ */ P("th", {
50
50
  className: "px-6 py-3",
51
51
  children: e.headerName || e.label || e.field
52
52
  }, e.field)) })
53
- }), /* @__PURE__ */ k("tbody", { children: i.map((e, t) => /* @__PURE__ */ k("tr", {
53
+ }), /* @__PURE__ */ P("tbody", { children: i.map((e, t) => /* @__PURE__ */ P("tr", {
54
54
  className: "bg-background border-b",
55
- children: a?.map((t) => /* @__PURE__ */ k("td", {
55
+ children: a?.map((t) => /* @__PURE__ */ P("td", {
56
56
  className: "px-6 py-4",
57
57
  children: e[t.field]
58
58
  }, t.field))
@@ -66,10 +66,10 @@ var B = ({ schema: t }) => {
66
66
  };
67
67
  //#endregion
68
68
  //#region src/hooks/useReportData.ts
69
- function V(e) {
69
+ function G(e) {
70
70
  return e.aggregate ? `${e.field}__${e.aggregate}` : e.field;
71
71
  }
72
- function H(e, t) {
72
+ function _e(e, t) {
73
73
  if (e == null) return null;
74
74
  let n = e instanceof Date ? e : new Date(String(e));
75
75
  if (Number.isNaN(n.getTime())) return null;
@@ -88,33 +88,33 @@ function H(e, t) {
88
88
  default: return String(e);
89
89
  }
90
90
  }
91
- function U(e, t) {
91
+ function K(e, t) {
92
92
  let n = e[t.field];
93
- return t.dateGranularity ? H(n, t.dateGranularity) ?? "(empty)" : n == null || n === "" ? "(empty)" : String(n);
93
+ return t.dateGranularity ? _e(n, t.dateGranularity) ?? "(empty)" : n == null || n === "" ? "(empty)" : String(n);
94
94
  }
95
- function W(e, t) {
95
+ function q(e, t) {
96
96
  let n = {};
97
97
  for (let r of t) {
98
98
  if (!r.aggregate) {
99
99
  let t = e.find((e) => e[r.field] != null);
100
- n[V(r)] = t ? t[r.field] : null;
100
+ n[G(r)] = t ? t[r.field] : null;
101
101
  continue;
102
102
  }
103
103
  let t = e.map((e) => e[r.field]);
104
104
  switch (r.aggregate) {
105
105
  case "count":
106
- n[V(r)] = t.length;
106
+ n[G(r)] = t.length;
107
107
  break;
108
108
  case "unique": {
109
109
  let e = /* @__PURE__ */ new Set();
110
110
  for (let n of t) n != null && e.add(n);
111
- n[V(r)] = e.size;
111
+ n[G(r)] = e.size;
112
112
  break;
113
113
  }
114
114
  case "sum": {
115
115
  let e = 0;
116
116
  for (let n of t) e += Number(n) || 0;
117
- n[V(r)] = e;
117
+ n[G(r)] = e;
118
118
  break;
119
119
  }
120
120
  case "avg": {
@@ -124,7 +124,7 @@ function W(e, t) {
124
124
  let t = Number(n);
125
125
  Number.isNaN(t) || (e += t, i += 1);
126
126
  }
127
- n[V(r)] = i === 0 ? null : e / i;
127
+ n[G(r)] = i === 0 ? null : e / i;
128
128
  break;
129
129
  }
130
130
  case "min": {
@@ -134,7 +134,7 @@ function W(e, t) {
134
134
  let t = Number(n);
135
135
  Number.isNaN(t) || (e === null || t < e) && (e = t);
136
136
  }
137
- n[V(r)] = e;
137
+ n[G(r)] = e;
138
138
  break;
139
139
  }
140
140
  case "max": {
@@ -144,19 +144,19 @@ function W(e, t) {
144
144
  let t = Number(n);
145
145
  Number.isNaN(t) || (e === null || t > e) && (e = t);
146
146
  }
147
- n[V(r)] = e;
147
+ n[G(r)] = e;
148
148
  break;
149
149
  }
150
- default: n[V(r)] = null;
150
+ default: n[G(r)] = null;
151
151
  }
152
152
  }
153
153
  return n;
154
154
  }
155
- function le(e, t, n, r = {}, i = []) {
155
+ function ve(e, t, n, r = {}, i = []) {
156
156
  if (t.length === 0) return [];
157
157
  let [a, ...o] = t, s = /* @__PURE__ */ new Map();
158
158
  for (let t of e) {
159
- let e = U(t, a), n = s.get(e);
159
+ let e = K(t, a), n = s.get(e);
160
160
  n || (n = [], s.set(e, n)), n.push(t);
161
161
  }
162
162
  let c = [];
@@ -164,7 +164,7 @@ function le(e, t, n, r = {}, i = []) {
164
164
  let s = {
165
165
  ...r,
166
166
  [a.field]: e
167
- }, l = [...i, e], u = W(t, n), d = o.length > 0 ? le(t, o, n, s, l) : void 0;
167
+ }, l = [...i, e], u = q(t, n), d = o.length > 0 ? ve(t, o, n, s, l) : void 0;
168
168
  c.push({
169
169
  groupKey: s,
170
170
  groupPath: l,
@@ -179,20 +179,20 @@ function le(e, t, n, r = {}, i = []) {
179
179
  return n.localeCompare(r) * l;
180
180
  }), typeof a.limit == "number" && a.limit > 0 ? c.slice(0, a.limit) : c;
181
181
  }
182
- function ue(e, t, n, r) {
183
- let i = de(e, n), a = de(e, r), o = {}, s = {}, c = {};
182
+ function ye(e, t, n, r) {
183
+ let i = be(e, n), a = be(e, r), o = {}, s = {}, c = {};
184
184
  for (let c of i) {
185
185
  o[c.id] = {};
186
- let i = fe(e, c.key, n);
187
- s[c.id] = W(i, t);
186
+ let i = xe(e, c.key, n);
187
+ s[c.id] = q(i, t);
188
188
  for (let e of a) {
189
- let n = fe(i, e.key, r);
190
- n.length !== 0 && (o[c.id][e.id] = W(n, t));
189
+ let n = xe(i, e.key, r);
190
+ n.length !== 0 && (o[c.id][e.id] = q(n, t));
191
191
  }
192
192
  }
193
193
  for (let n of a) {
194
- let i = fe(e, n.key, r);
195
- c[n.id] = W(i, t);
194
+ let i = xe(e, n.key, r);
195
+ c[n.id] = q(i, t);
196
196
  }
197
197
  return {
198
198
  rowHeaders: i,
@@ -200,13 +200,13 @@ function ue(e, t, n, r) {
200
200
  cells: o,
201
201
  rowTotals: s,
202
202
  colTotals: c,
203
- grandTotal: W(e, t),
203
+ grandTotal: q(e, t),
204
204
  columns: t,
205
205
  downGroupings: n,
206
206
  acrossGroupings: r
207
207
  };
208
208
  }
209
- function de(e, t) {
209
+ function be(e, t) {
210
210
  if (t.length === 0) return [{
211
211
  key: {},
212
212
  path: [],
@@ -216,7 +216,7 @@ function de(e, t) {
216
216
  for (let r of e) {
217
217
  let e = [], i = {};
218
218
  for (let n of t) {
219
- let t = U(r, n);
219
+ let t = K(r, n);
220
220
  e.push(t), i[n.field] = t;
221
221
  }
222
222
  let a = e.join("");
@@ -242,7 +242,7 @@ function de(e, t) {
242
242
  }
243
243
  return r;
244
244
  }
245
- function fe(e, t, n) {
245
+ function xe(e, t, n) {
246
246
  let r = Object.entries(t);
247
247
  if (r.length === 0) return e;
248
248
  let i = /* @__PURE__ */ new Map();
@@ -250,16 +250,16 @@ function fe(e, t, n) {
250
250
  return e.filter((e) => {
251
251
  for (let [t, n] of r) {
252
252
  let r = i.get(t);
253
- if ((r ? U(e, r) : e[t] == null ? "(null)" : String(e[t])) !== String(n)) return !1;
253
+ if ((r ? K(e, r) : e[t] == null ? "(null)" : String(e[t])) !== String(n)) return !1;
254
254
  }
255
255
  return !0;
256
256
  });
257
257
  }
258
- function G(e, t) {
258
+ function J(e, t) {
259
259
  let n = {};
260
260
  for (let r of t) {
261
261
  if (!r.aggregate) continue;
262
- let t = V(r), i = 0, a = 0, o = null, s = null;
262
+ let t = G(r), i = 0, a = 0, o = null, s = null;
263
263
  for (let n of e) {
264
264
  let e = n[t];
265
265
  typeof e == "number" && (i += e, a += 1, (o == null || e < o) && (o = e), (s == null || e > s) && (s = e));
@@ -268,27 +268,27 @@ function G(e, t) {
268
268
  }
269
269
  return n;
270
270
  }
271
- function pe(e, t, n, r) {
272
- let i = me(e, n), a = me(e, r), o = {}, s = {}, c = {};
271
+ function Se(e, t, n, r) {
272
+ let i = Ce(e, n), a = Ce(e, r), o = {}, s = {}, c = {};
273
273
  for (let n of i) {
274
274
  o[n.id] = {};
275
- let r = e.filter((e) => he(e, n.key));
276
- s[n.id] = G(r, t);
275
+ let r = e.filter((e) => we(e, n.key));
276
+ s[n.id] = J(r, t);
277
277
  for (let e of a) {
278
- let i = r.filter((t) => he(t, e.key));
278
+ let i = r.filter((t) => we(t, e.key));
279
279
  if (i.length === 0) continue;
280
280
  let a = {};
281
281
  for (let e of t) {
282
282
  if (!e.aggregate) continue;
283
- let t = V(e);
283
+ let t = G(e);
284
284
  a[t] = i[0][t];
285
285
  }
286
286
  o[n.id][e.id] = a;
287
287
  }
288
288
  }
289
289
  for (let n of a) {
290
- let r = e.filter((e) => he(e, n.key));
291
- c[n.id] = G(r, t);
290
+ let r = e.filter((e) => we(e, n.key));
291
+ c[n.id] = J(r, t);
292
292
  }
293
293
  return {
294
294
  rowHeaders: i,
@@ -296,13 +296,13 @@ function pe(e, t, n, r) {
296
296
  cells: o,
297
297
  rowTotals: s,
298
298
  colTotals: c,
299
- grandTotal: G(e, t),
299
+ grandTotal: J(e, t),
300
300
  columns: t,
301
301
  downGroupings: n,
302
302
  acrossGroupings: r
303
303
  };
304
304
  }
305
- function me(e, t) {
305
+ function Ce(e, t) {
306
306
  if (t.length === 0) return [{
307
307
  key: {},
308
308
  path: [],
@@ -331,17 +331,17 @@ function me(e, t) {
331
331
  return 0;
332
332
  }), r;
333
333
  }
334
- function he(e, t) {
334
+ function we(e, t) {
335
335
  for (let [n, r] of Object.entries(t)) if ((e[n] == null ? "(null)" : String(e[n])) !== String(r)) return !1;
336
336
  return !0;
337
337
  }
338
- function K(e, t) {
338
+ function Y(e, t) {
339
339
  let n = e && Object.keys(e).length > 0, r = t && Object.keys(t).length > 0;
340
340
  if (n && r) return { $and: [e, t] };
341
341
  if (n) return e;
342
342
  if (r) return t;
343
343
  }
344
- function ge(e) {
344
+ function Te(e) {
345
345
  let t = /* @__PURE__ */ new Set();
346
346
  for (let n of e.groupingsDown ?? []) t.add(n.field);
347
347
  for (let n of e.groupingsAcross ?? []) t.add(n.field);
@@ -349,7 +349,7 @@ function ge(e) {
349
349
  for (let n of e.sort ?? []) t.add(n.field);
350
350
  return Array.from(t);
351
351
  }
352
- function _e(e, t, n) {
352
+ function Ee(e, t, n) {
353
353
  let r = [...e.groupingsDown ?? [], ...e.groupingsAcross ?? []], i = (e.columns ?? []).filter((e) => !!e.aggregate);
354
354
  if (r.length === 0 && i.length === 0) return null;
355
355
  let a = r.map((e) => e.dateGranularity ? {
@@ -358,38 +358,38 @@ function _e(e, t, n) {
358
358
  } : e.field), o = i.map((e) => ({
359
359
  function: e.aggregate === "unique" ? "count_distinct" : e.aggregate,
360
360
  field: e.field,
361
- alias: V(e)
362
- })), s = K(e.filter, t), c = {
361
+ alias: G(e)
362
+ })), s = Y(e.filter, t), c = {
363
363
  object: e.objectName,
364
364
  limit: n
365
365
  };
366
366
  return a.length > 0 && (c.groupBy = a), o.length > 0 && (c.aggregations = o), s && (c.where = s), c;
367
367
  }
368
- function ve(e, t, n) {
368
+ function De(e, t, n) {
369
369
  for (let [r, i] of Object.entries(t)) {
370
370
  let t = n.find((e) => e.field === r);
371
- if ((t ? U(e, t) : String(e[r] ?? "(empty)")) !== String(i)) return !1;
371
+ if ((t ? K(e, t) : String(e[r] ?? "(empty)")) !== String(i)) return !1;
372
372
  }
373
373
  return !0;
374
374
  }
375
- var q = [];
376
- function ye(e, t = {}) {
377
- let { dataSource: n, runtimeFilter: c, maxRows: l = 5e3, enabled: u = !0, rows: d, preferServerAggregation: f = !0 } = t, [p, m] = s(d ?? q), [h, g] = s(!1), [_, v] = s(!1), [y, b] = s(null), x = o(0), S = r(async () => {
375
+ var X = [];
376
+ function Oe(e, t = {}) {
377
+ let { dataSource: n, runtimeFilter: c, maxRows: l = 5e3, enabled: u = !0, rows: d, preferServerAggregation: f = !0 } = t, [p, m] = s(d ?? X), [h, g] = s(!1), [_, v] = s(!1), [y, b] = s(null), x = o(0), S = r(async () => {
378
378
  if (!e || !u) return;
379
379
  if (d) {
380
380
  m(d), g(!1);
381
381
  return;
382
382
  }
383
383
  if (!n) {
384
- m(q);
384
+ m(X);
385
385
  return;
386
386
  }
387
387
  let t = ++x.current;
388
388
  v(!0), b(null);
389
389
  try {
390
- let r = f ? _e(e, c, l) : null;
390
+ let r = f ? Ee(e, c, l) : null;
391
391
  if (r && typeof n.aggregate == "function") try {
392
- let i = be(await n.aggregate(e.objectName, r));
392
+ let i = ke(await n.aggregate(e.objectName, r));
393
393
  if (t !== x.current) return;
394
394
  m(i), g(!0);
395
395
  return;
@@ -397,17 +397,17 @@ function ye(e, t = {}) {
397
397
  typeof console < "u" && console.warn && console.warn("[useReportData] dataSource.aggregate() failed, falling back to find():", e);
398
398
  }
399
399
  if (typeof n.find != "function") {
400
- m(q), g(!1);
400
+ m(X), g(!1);
401
401
  return;
402
402
  }
403
- let i = K(e.filter, c), a = ge(e), o = { $top: l };
403
+ let i = Y(e.filter, c), a = Te(e), o = { $top: l };
404
404
  i && (o.$filter = i), a.length > 0 && (o.$select = a), e.sort && e.sort.length > 0 && (o.$orderBy = e.sort.map((e) => `${e.field} ${e.direction ?? "asc"}`).join(","));
405
- let s = be(await n.find(e.objectName, o));
405
+ let s = ke(await n.find(e.objectName, o));
406
406
  if (t !== x.current) return;
407
407
  m(s), g(!1);
408
408
  } catch (e) {
409
409
  if (t !== x.current) return;
410
- b(e instanceof Error ? e : Error(String(e))), m(q), g(!1);
410
+ b(e instanceof Error ? e : Error(String(e))), m(X), g(!1);
411
411
  } finally {
412
412
  t === x.current && v(!1);
413
413
  }
@@ -445,7 +445,7 @@ function ye(e, t = {}) {
445
445
  values: i,
446
446
  count: 1
447
447
  };
448
- }), o = G(p, r), s = i ? pe(p, r, t, n) : null;
448
+ }), o = J(p, r), s = i ? Se(p, r, t, n) : null;
449
449
  return {
450
450
  rows: i && s ? s.rowHeaders.map((e) => ({
451
451
  groupKey: e.key,
@@ -459,14 +459,14 @@ function ye(e, t = {}) {
459
459
  }
460
460
  let a = i ? t : [...t, ...n];
461
461
  return {
462
- rows: a.length > 0 ? le(p, a, r) : p.map((e) => ({
462
+ rows: a.length > 0 ? ve(p, a, r) : p.map((e) => ({
463
463
  groupKey: {},
464
464
  groupPath: [],
465
- values: r.length > 0 ? W([e], r) : { ...e },
465
+ values: r.length > 0 ? q([e], r) : { ...e },
466
466
  count: 1
467
467
  })),
468
- totals: W(p, r),
469
- pivot: i ? ue(p, r, t, n) : null
468
+ totals: q(p, r),
469
+ pivot: i ? ye(p, r, t, n) : null
470
470
  };
471
471
  }, [
472
472
  e,
@@ -485,11 +485,11 @@ function ye(e, t = {}) {
485
485
  drillDown: r((t) => {
486
486
  if (!e) return [];
487
487
  let n = [...e.groupingsDown ?? [], ...e.groupingsAcross ?? []];
488
- return p.filter((e) => ve(e, t, n));
488
+ return p.filter((e) => De(e, t, n));
489
489
  }, [e, p])
490
490
  };
491
491
  }
492
- function be(e) {
492
+ function ke(e) {
493
493
  if (Array.isArray(e)) return e;
494
494
  if (e && typeof e == "object") {
495
495
  let t = e;
@@ -498,20 +498,20 @@ function be(e) {
498
498
  if (Array.isArray(t.results)) return t.results;
499
499
  if (Array.isArray(t.value)) return t.value;
500
500
  }
501
- return q;
501
+ return X;
502
502
  }
503
503
  //#endregion
504
504
  //#region src/buildChartData.ts
505
- function xe(e) {
505
+ function Ae(e) {
506
506
  return e.aggregate ? `${e.field}__${e.aggregate}` : e.field;
507
507
  }
508
- function Se(e) {
508
+ function je(e) {
509
509
  let t = [], n = (e) => {
510
510
  e.children && e.children.length > 0 ? e.children.forEach(n) : t.push(e);
511
511
  };
512
512
  return e.forEach(n), t;
513
513
  }
514
- function Ce({ report: e, rows: t, labels: n }) {
514
+ function Me({ report: e, rows: t, labels: n }) {
515
515
  let r = e.chart;
516
516
  if (!r || !r.type) return { schema: null };
517
517
  let i = e.groupingsDown ?? [], a = r.xAxis || (i.length > 0 ? i[0]?.field : void 0);
@@ -522,9 +522,9 @@ function Ce({ report: e, rows: t, labels: n }) {
522
522
  let o = e.columns ?? [], s = r.yAxis, c = "count", l = "Count", u = !0;
523
523
  if (s) {
524
524
  let e = o.find((e) => e.field === s && e.aggregate);
525
- e ? (c = xe(e), l = n?.resolveColumnLabel?.(e) ?? (typeof e.label == "string" ? e.label : `${e.aggregate}(${e.field})`), u = !1) : (c = "count", l = n?.resolveCountLabel?.(s) ?? `Count of ${s}`);
525
+ e ? (c = Ae(e), l = n?.resolveColumnLabel?.(e) ?? (typeof e.label == "string" ? e.label : `${e.aggregate}(${e.field})`), u = !1) : (c = "count", l = n?.resolveCountLabel?.(s) ?? `Count of ${s}`);
526
526
  }
527
- let d = Se(t), f = /* @__PURE__ */ new Map();
527
+ let d = je(t), f = /* @__PURE__ */ new Map();
528
528
  for (let e of d) {
529
529
  let t = e.groupKey[a];
530
530
  if (t === void 0) continue;
@@ -558,8 +558,8 @@ function Ce({ report: e, rows: t, labels: n }) {
558
558
  }
559
559
  //#endregion
560
560
  //#region src/drill.ts
561
- function we(e, t, n = {}) {
562
- let r = K(K(e.filter, n.runtimeFilter), Object.keys(t).length > 0 ? t : void 0);
561
+ function Ne(e, t, n = {}) {
562
+ let r = Y(Y(e.filter, n.runtimeFilter), Object.keys(t).length > 0 ? t : void 0);
563
563
  return {
564
564
  type: "drill",
565
565
  name: `drill-${e.name}`,
@@ -570,12 +570,12 @@ function we(e, t, n = {}) {
570
570
  openIn: n.openIn ?? "current"
571
571
  };
572
572
  }
573
- function Te(e) {
573
+ function Pe(e) {
574
574
  return !!e && e.type === "drill";
575
575
  }
576
- function Ee(e) {
576
+ function Fe(e) {
577
577
  return async (t) => {
578
- if (!Te(t)) return {
578
+ if (!Pe(t)) return {
579
579
  success: !1,
580
580
  error: "drill handler invoked with non-drill action"
581
581
  };
@@ -595,35 +595,35 @@ function Ee(e) {
595
595
  }
596
596
  };
597
597
  }
598
- function De(e, t) {
599
- return e.registerHandler("drill", Ee(t)), () => e.unregisterHandler("drill");
598
+ function Ie(e, t) {
599
+ return e.registerHandler("drill", Fe(t)), () => e.unregisterHandler("drill");
600
600
  }
601
601
  //#endregion
602
602
  //#region src/SpecReportGrid.tsx
603
- function Oe(e) {
603
+ function Le(e) {
604
604
  return e ? e === "unique" ? "count_distinct" : e : null;
605
605
  }
606
- function ke(e) {
606
+ function Re(e) {
607
607
  if (!(!e || e.length === 0)) return { fields: e.map((e) => ({
608
608
  field: e.field,
609
609
  order: e.sort ?? "asc",
610
610
  collapsed: !1
611
611
  })) };
612
612
  }
613
- function Ae(e) {
613
+ function ze(e) {
614
614
  return (e.columns ?? []).map((e) => {
615
615
  let t = { field: e.field };
616
616
  return e.label && (t.label = typeof e.label == "string" ? e.label : String(e.label)), e.format && (t.format = e.format), e.width && (t.width = e.width), t;
617
617
  });
618
618
  }
619
- var je = {
619
+ var Be = {
620
620
  padding: "12px 16px",
621
621
  border: "1px dashed rgb(203 213 225)",
622
622
  borderRadius: 8,
623
623
  color: "rgb(100 116 139)",
624
624
  fontSize: 14
625
- }, Me = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onDrillDown: a, actionRunner: o, drillView: s, drillOpenIn: c, className: l }) => {
626
- let u = e.type ?? "tabular", { t: d } = j(), { fieldLabel: f, translateOptions: p } = ee(), [m, h] = t.useState(null);
625
+ }, Ve = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onDrillDown: a, actionRunner: o, drillView: s, drillOpenIn: c, className: l }) => {
626
+ let u = e.type ?? "tabular", { t: d } = I(), { fieldLabel: f, translateOptions: p } = R(), [m, h] = t.useState(null);
627
627
  t.useEffect(() => {
628
628
  let t = n;
629
629
  if (!t || typeof t.getObjectSchema != "function" || !e.objectName) return;
@@ -653,17 +653,17 @@ var je = {
653
653
  m,
654
654
  e.objectName,
655
655
  p
656
- ]), { rawRows: v, rows: y, totals: b, serverAggregated: x, loading: S, error: C, drillDown: w } = ye(e, {
656
+ ]), { rawRows: v, rows: y, totals: b, serverAggregated: x, loading: S, error: C, drillDown: w } = Oe(e, {
657
657
  dataSource: n,
658
658
  rows: r,
659
659
  runtimeFilter: i
660
660
  });
661
- if (u === "matrix" || u === "joined") return /* @__PURE__ */ A("div", {
661
+ if (u === "matrix" || u === "joined") return /* @__PURE__ */ F("div", {
662
662
  className: l,
663
- style: je,
663
+ style: Be,
664
664
  children: [
665
665
  "Report type ",
666
- /* @__PURE__ */ k("code", { children: u }),
666
+ /* @__PURE__ */ P("code", { children: u }),
667
667
  " is not yet supported by SpecReportGrid. It will be rendered by a dedicated component in M2 (matrix) / M3 (joined)."
668
668
  ]
669
669
  });
@@ -673,7 +673,7 @@ var je = {
673
673
  field: e.field,
674
674
  label: e.field.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase())
675
675
  })), n = (e.columns ?? []).filter((e) => e.aggregate).map((e) => ({
676
- field: V(e),
676
+ field: G(e),
677
677
  label: `${(typeof e.label == "string" ? e.label : null) ?? e.field} (${e.aggregate})`,
678
678
  ...e.format ? { format: e.format } : {}
679
679
  }));
@@ -683,8 +683,8 @@ var je = {
683
683
  columns: [...t, ...n]
684
684
  };
685
685
  }
686
- let t = u === "summary" ? ke(e.groupingsDown) : void 0, n = (e.columns ?? []).map((e) => {
687
- let t = Oe(e.aggregate);
686
+ let t = u === "summary" ? Re(e.groupingsDown) : void 0, n = (e.columns ?? []).map((e) => {
687
+ let t = Le(e.aggregate);
688
688
  return t ? {
689
689
  field: e.field,
690
690
  type: t
@@ -693,7 +693,7 @@ var je = {
693
693
  return {
694
694
  type: "object-grid",
695
695
  objectName: e.objectName,
696
- columns: Ae(e),
696
+ columns: ze(e),
697
697
  grouping: t,
698
698
  aggregations: n.length > 0 ? n : void 0
699
699
  };
@@ -705,7 +705,7 @@ var je = {
705
705
  let n = e.groupingsDown ?? [], r = {};
706
706
  for (let e of n) r[e.field] = t[e.field];
707
707
  if (o) {
708
- let t = we(e, r, {
708
+ let t = Ne(e, r, {
709
709
  runtimeFilter: i,
710
710
  view: s,
711
711
  openIn: c
@@ -721,7 +721,7 @@ var je = {
721
721
  a,
722
722
  e,
723
723
  i
724
- ]), O = !!a || !!o, P = (e.columns ?? []).filter((e) => e.aggregate), F = P.length > 0 && b && Object.keys(b).length > 0, I = t.useMemo(() => u !== "summary" || !e.chart || !e.chart.type ? null : Ce({
724
+ ]), O = !!a || !!o, k = (e.columns ?? []).filter((e) => e.aggregate), A = k.length > 0 && b && Object.keys(b).length > 0, j = t.useMemo(() => u !== "summary" || !e.chart || !e.chart.type ? null : Me({
725
725
  report: e,
726
726
  rows: y,
727
727
  labels: {
@@ -742,46 +742,46 @@ var je = {
742
742
  f,
743
743
  d
744
744
  ]);
745
- return /* @__PURE__ */ A("div", {
745
+ return /* @__PURE__ */ F("div", {
746
746
  className: l,
747
747
  "data-testid": "spec-report-grid",
748
748
  "aria-busy": S || void 0,
749
749
  children: [
750
- C ? /* @__PURE__ */ k("div", {
750
+ C ? /* @__PURE__ */ P("div", {
751
751
  role: "alert",
752
752
  style: {
753
- ...je,
753
+ ...Be,
754
754
  color: "rgb(190 18 60)"
755
755
  },
756
756
  children: C.message
757
757
  }) : null,
758
- F ? /* @__PURE__ */ A("div", {
758
+ A ? /* @__PURE__ */ F("div", {
759
759
  "data-testid": "spec-report-totals",
760
760
  className: "mb-3 flex flex-wrap items-baseline gap-x-6 gap-y-1 rounded-md border bg-muted/40 px-3 py-2 text-sm",
761
- children: [/* @__PURE__ */ k("span", {
761
+ children: [/* @__PURE__ */ P("span", {
762
762
  className: "text-xs font-medium uppercase tracking-wide text-muted-foreground",
763
763
  children: d("report.totals", "Totals")
764
- }), P.map((e) => {
765
- let t = V(e), n = b[t], r = g(e), i = typeof n == "number" ? n.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(n ?? "—");
766
- return /* @__PURE__ */ A("span", {
764
+ }), k.map((e) => {
765
+ let t = G(e), n = b[t], r = g(e), i = typeof n == "number" ? n.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(n ?? "—");
766
+ return /* @__PURE__ */ F("span", {
767
767
  "data-testid": `spec-report-total-${t}`,
768
768
  className: "inline-flex items-baseline gap-1.5",
769
- children: [/* @__PURE__ */ A("span", {
769
+ children: [/* @__PURE__ */ F("span", {
770
770
  className: "text-muted-foreground",
771
771
  children: [r, ":"]
772
- }), /* @__PURE__ */ k("span", {
772
+ }), /* @__PURE__ */ P("span", {
773
773
  className: "font-mono font-medium tabular-nums",
774
774
  children: i
775
775
  })]
776
776
  }, t);
777
777
  })]
778
778
  }) : null,
779
- I ? /* @__PURE__ */ k("div", {
779
+ j ? /* @__PURE__ */ P("div", {
780
780
  className: "mb-4",
781
781
  "data-testid": "spec-report-chart",
782
- children: /* @__PURE__ */ k(N, { schema: I })
782
+ children: /* @__PURE__ */ P(z, { schema: j })
783
783
  }) : null,
784
- /* @__PURE__ */ k(M, {
784
+ /* @__PURE__ */ P(L, {
785
785
  schema: T,
786
786
  data: E,
787
787
  dataSource: n,
@@ -790,14 +790,14 @@ var je = {
790
790
  ]
791
791
  });
792
792
  };
793
- Me.displayName = "SpecReportGrid";
793
+ Ve.displayName = "SpecReportGrid";
794
794
  //#endregion
795
795
  //#region src/MatrixRenderer.tsx
796
- var Ne = "—";
797
- function Pe(e) {
798
- return e == null ? Ne : typeof e == "number" ? e.toLocaleString() : String(e);
796
+ var He = "—";
797
+ function Ue(e) {
798
+ return e == null ? He : typeof e == "number" ? e.toLocaleString() : String(e);
799
799
  }
800
- function Fe(e, t, n) {
800
+ function We(e, t, n) {
801
801
  if (e == null || e === "" || e === "(null)") return n;
802
802
  let r = t?.options;
803
803
  if (r) {
@@ -806,18 +806,18 @@ function Fe(e, t, n) {
806
806
  }
807
807
  return e;
808
808
  }
809
- function Ie({ header: e, groupings: t, metaByField: n, fallback: r, emptyLabel: i }) {
810
- return e.path.length === 0 ? /* @__PURE__ */ k(O, { children: r }) : /* @__PURE__ */ k(O, { children: e.path.map((e, r) => {
809
+ function Ge({ header: e, groupings: t, metaByField: n, fallback: r, emptyLabel: i }) {
810
+ return e.path.length === 0 ? /* @__PURE__ */ P(N, { children: r }) : /* @__PURE__ */ P(N, { children: e.path.map((e, r) => {
811
811
  let a = t[r]?.field;
812
- return Fe(e, a ? n.get(a) : void 0, i);
812
+ return We(e, a ? n.get(a) : void 0, i);
813
813
  }).join(" / ") });
814
814
  }
815
- var Le = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onCellClick: a, actionRunner: o, drillView: s, drillOpenIn: c, className: l, emptyCellText: u = Ne }) => {
816
- let { pivot: d, loading: f, error: p } = ye(e, {
815
+ var Ke = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onCellClick: a, actionRunner: o, drillView: s, drillOpenIn: c, className: l, emptyCellText: u = He }) => {
816
+ let { pivot: d, loading: f, error: p } = Oe(e, {
817
817
  dataSource: n,
818
818
  rows: r,
819
819
  runtimeFilter: i
820
- }), m = e.columns ?? [], h = m.length > 1, { fieldLabel: g, translateOptions: _ } = ee(), { t: v } = j(), y = v("report.emptyLabel", "(Empty)"), b = v("report.allLabel", "(All)"), [x, S] = t.useState(null);
820
+ }), m = e.columns ?? [], h = m.length > 1, { fieldLabel: g, translateOptions: _ } = R(), { t: v } = I(), y = v("report.emptyLabel", "(Empty)"), b = v("report.allLabel", "(All)"), [x, S] = t.useState(null);
821
821
  t.useEffect(() => {
822
822
  let t = n;
823
823
  if (!t || typeof t.getObjectSchema != "function" || !e.objectName) return;
@@ -853,7 +853,7 @@ var Le = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onCellClick: a,
853
853
  ]), E = t.useMemo(() => {
854
854
  let t = /* @__PURE__ */ new Map(), n = x?.fields ?? {};
855
855
  for (let r of m) {
856
- let i = V(r);
856
+ let i = G(r);
857
857
  if (r.label) {
858
858
  t.set(i, String(r.label));
859
859
  continue;
@@ -877,7 +877,7 @@ var Le = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onCellClick: a,
877
877
  ...n.key
878
878
  };
879
879
  if (o) {
880
- let t = we(e, l, {
880
+ let t = Ne(e, l, {
881
881
  runtimeFilter: i,
882
882
  view: s,
883
883
  openIn: c
@@ -898,25 +898,25 @@ var Le = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onCellClick: a,
898
898
  e,
899
899
  i
900
900
  ]);
901
- if (p) return /* @__PURE__ */ k("div", {
901
+ if (p) return /* @__PURE__ */ P("div", {
902
902
  className: l,
903
903
  role: "alert",
904
904
  "data-testid": "matrix-error",
905
905
  children: v("report.failedToLoad", "Failed to load matrix: {{message}}", { message: p.message })
906
906
  });
907
- if (!d) return /* @__PURE__ */ k("div", {
907
+ if (!d) return /* @__PURE__ */ P("div", {
908
908
  className: l,
909
909
  "aria-busy": f || void 0,
910
910
  "data-testid": "matrix-empty",
911
911
  children: f ? v("report.loading", "Loading…") : v("report.needsAcross", "Matrix report requires at least one `groupingsAcross` field.")
912
912
  });
913
- let O = !!a || !!o, M = C.map((e) => T.get(e.field)?.fieldLabel ?? e.field).join(" / ") || v("report.rowsLabel", "Row"), N = w.map((e) => T.get(e.field)?.fieldLabel ?? e.field).join(" / ") || v("report.columnsLabel", "Column");
914
- return /* @__PURE__ */ k("div", {
913
+ let O = !!a || !!o, k = C.map((e) => T.get(e.field)?.fieldLabel ?? e.field).join(" / ") || v("report.rowsLabel", "Row"), A = w.map((e) => T.get(e.field)?.fieldLabel ?? e.field).join(" / ") || v("report.columnsLabel", "Column");
914
+ return /* @__PURE__ */ P("div", {
915
915
  className: l,
916
916
  "data-testid": "matrix-renderer",
917
917
  "aria-busy": f || void 0,
918
918
  style: { overflow: "auto" },
919
- children: /* @__PURE__ */ A("table", {
919
+ children: /* @__PURE__ */ F("table", {
920
920
  role: "table",
921
921
  style: {
922
922
  borderCollapse: "collapse",
@@ -924,24 +924,24 @@ var Le = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onCellClick: a,
924
924
  fontSize: 13
925
925
  },
926
926
  children: [
927
- /* @__PURE__ */ k("thead", { children: /* @__PURE__ */ A("tr", { children: [
928
- /* @__PURE__ */ A("th", {
927
+ /* @__PURE__ */ P("thead", { children: /* @__PURE__ */ F("tr", { children: [
928
+ /* @__PURE__ */ F("th", {
929
929
  scope: "col",
930
- style: Y({
930
+ style: Z({
931
931
  header: !0,
932
932
  bold: !0
933
933
  }),
934
- "aria-label": `${M} \u2192 ${N}`,
934
+ "aria-label": `${k} \u2192 ${A}`,
935
935
  children: [
936
- M,
936
+ k,
937
937
  " \\ ",
938
- N
938
+ A
939
939
  ]
940
940
  }),
941
- d.colHeaders.map((e) => /* @__PURE__ */ k("th", {
941
+ d.colHeaders.map((e) => /* @__PURE__ */ P("th", {
942
942
  scope: "col",
943
- style: Y({ header: !0 }),
944
- children: /* @__PURE__ */ k(Ie, {
943
+ style: Z({ header: !0 }),
944
+ children: /* @__PURE__ */ P(Ge, {
945
945
  header: e,
946
946
  groupings: w,
947
947
  metaByField: T,
@@ -949,20 +949,20 @@ var Le = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onCellClick: a,
949
949
  emptyLabel: y
950
950
  })
951
951
  }, `col-${e.id}`)),
952
- /* @__PURE__ */ k("th", {
952
+ /* @__PURE__ */ P("th", {
953
953
  scope: "col",
954
- style: Y({
954
+ style: Z({
955
955
  header: !0,
956
956
  total: !0
957
957
  }),
958
958
  children: v("report.rowTotal", "Row Total")
959
959
  })
960
960
  ] }) }),
961
- /* @__PURE__ */ k("tbody", { children: d.rowHeaders.map((e) => /* @__PURE__ */ A("tr", { children: [
962
- /* @__PURE__ */ k("th", {
961
+ /* @__PURE__ */ P("tbody", { children: d.rowHeaders.map((e) => /* @__PURE__ */ F("tr", { children: [
962
+ /* @__PURE__ */ P("th", {
963
963
  scope: "row",
964
- style: Y({ header: !0 }),
965
- children: /* @__PURE__ */ k(Ie, {
964
+ style: Z({ header: !0 }),
965
+ children: /* @__PURE__ */ P(Ge, {
966
966
  header: e,
967
967
  groupings: C,
968
968
  metaByField: T,
@@ -972,71 +972,71 @@ var Le = ({ report: e, dataSource: n, rows: r, runtimeFilter: i, onCellClick: a,
972
972
  }),
973
973
  d.colHeaders.map((t) => {
974
974
  let n = d.cells[e.id]?.[t.id], r = !n;
975
- return /* @__PURE__ */ k("td", {
976
- style: Y({
975
+ return /* @__PURE__ */ P("td", {
976
+ style: Z({
977
977
  interactive: O && !r,
978
978
  empty: r
979
979
  }),
980
980
  onClick: O && !r ? () => D(e, t, n) : void 0,
981
981
  "data-row": e.id,
982
982
  "data-col": t.id,
983
- children: r ? u : J(m, n, h, E)
983
+ children: r ? u : qe(m, n, h, E)
984
984
  }, `cell-${e.id}-${t.id}`);
985
985
  }),
986
- /* @__PURE__ */ k("td", {
987
- style: Y({ total: !0 }),
988
- children: J(m, d.rowTotals[e.id] ?? {}, h, E)
986
+ /* @__PURE__ */ P("td", {
987
+ style: Z({ total: !0 }),
988
+ children: qe(m, d.rowTotals[e.id] ?? {}, h, E)
989
989
  })
990
990
  ] }, `row-${e.id}`)) }),
991
- /* @__PURE__ */ k("tfoot", { children: /* @__PURE__ */ A("tr", { children: [
992
- /* @__PURE__ */ k("th", {
991
+ /* @__PURE__ */ P("tfoot", { children: /* @__PURE__ */ F("tr", { children: [
992
+ /* @__PURE__ */ P("th", {
993
993
  scope: "row",
994
- style: Y({
994
+ style: Z({
995
995
  header: !0,
996
996
  total: !0
997
997
  }),
998
998
  children: v("report.columnTotal", "Column Total")
999
999
  }),
1000
- d.colHeaders.map((e) => /* @__PURE__ */ k("td", {
1001
- style: Y({ total: !0 }),
1002
- children: J(m, d.colTotals[e.id] ?? {}, h, E)
1000
+ d.colHeaders.map((e) => /* @__PURE__ */ P("td", {
1001
+ style: Z({ total: !0 }),
1002
+ children: qe(m, d.colTotals[e.id] ?? {}, h, E)
1003
1003
  }, `coltotal-${e.id}`)),
1004
- /* @__PURE__ */ k("td", {
1005
- style: Y({
1004
+ /* @__PURE__ */ P("td", {
1005
+ style: Z({
1006
1006
  total: !0,
1007
1007
  grand: !0
1008
1008
  }),
1009
- children: J(m, d.grandTotal, h, E)
1009
+ children: qe(m, d.grandTotal, h, E)
1010
1010
  })
1011
1011
  ] }) })
1012
1012
  ]
1013
1013
  })
1014
1014
  });
1015
1015
  };
1016
- function J(e, t, n, r) {
1017
- return e.length ? n ? /* @__PURE__ */ k("div", {
1016
+ function qe(e, t, n, r) {
1017
+ return e.length ? n ? /* @__PURE__ */ P("div", {
1018
1018
  style: {
1019
1019
  display: "flex",
1020
1020
  flexDirection: "column",
1021
1021
  gap: 2
1022
1022
  },
1023
1023
  children: e.map((e) => {
1024
- let n = V(e);
1025
- return /* @__PURE__ */ A("div", {
1024
+ let n = G(e);
1025
+ return /* @__PURE__ */ F("div", {
1026
1026
  style: {
1027
1027
  display: "flex",
1028
1028
  justifyContent: "space-between",
1029
1029
  gap: 8
1030
1030
  },
1031
- children: [/* @__PURE__ */ k("span", {
1031
+ children: [/* @__PURE__ */ P("span", {
1032
1032
  style: { color: "var(--color-muted-foreground, #71717a)" },
1033
1033
  children: r?.get(n) ?? e.label ?? n
1034
- }), /* @__PURE__ */ k("span", { children: Pe(t[n]) })]
1034
+ }), /* @__PURE__ */ P("span", { children: Ue(t[n]) })]
1035
1035
  }, n);
1036
1036
  })
1037
- }) : Pe(t[V(e[0])]) : Ne;
1037
+ }) : Ue(t[G(e[0])]) : He;
1038
1038
  }
1039
- function Y(e) {
1039
+ function Z(e) {
1040
1040
  return {
1041
1041
  border: "1px solid var(--color-border, #e4e4e7)",
1042
1042
  padding: "6px 10px",
@@ -1050,19 +1050,19 @@ function Y(e) {
1050
1050
  }
1051
1051
  //#endregion
1052
1052
  //#region src/JoinedReportRenderer.tsx
1053
- function Re(e, t) {
1053
+ function Je(e, t) {
1054
1054
  return e ? typeof e == "string" ? e : typeof e == "object" && typeof e.default == "string" ? e.default : t : t;
1055
1055
  }
1056
- function ze(e, t) {
1056
+ function Ye(e, t) {
1057
1057
  if (!t || Object.keys(t).length === 0) return e;
1058
- let n = K(t, e.filter);
1058
+ let n = Y(t, e.filter);
1059
1059
  return {
1060
1060
  ...e,
1061
1061
  filter: n
1062
1062
  };
1063
1063
  }
1064
- var Be = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillView: i, drillOpenIn: a, className: o, renderBlock: s }) => {
1065
- if (!c(e)) return /* @__PURE__ */ A("div", {
1064
+ var Xe = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillView: i, drillOpenIn: a, className: o, renderBlock: s }) => {
1065
+ if (!c(e)) return /* @__PURE__ */ F("div", {
1066
1066
  className: o,
1067
1067
  "data-testid": "joined-report-invalid",
1068
1068
  style: {
@@ -1072,14 +1072,14 @@ var Be = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillVi
1072
1072
  },
1073
1073
  children: [
1074
1074
  "JoinedReportRenderer requires a report with ",
1075
- /* @__PURE__ */ k("code", { children: "type: 'joined'" }),
1075
+ /* @__PURE__ */ P("code", { children: "type: 'joined'" }),
1076
1076
  " and a ",
1077
- /* @__PURE__ */ k("code", { children: "blocks" }),
1077
+ /* @__PURE__ */ P("code", { children: "blocks" }),
1078
1078
  " array."
1079
1079
  ]
1080
1080
  });
1081
1081
  let l = e.blocks ?? [], u = e.filter, d = e.objectName;
1082
- return /* @__PURE__ */ k("div", {
1082
+ return /* @__PURE__ */ P("div", {
1083
1083
  className: o,
1084
1084
  "data-testid": "joined-report",
1085
1085
  "data-report-name": e.name,
@@ -1089,12 +1089,12 @@ var Be = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillVi
1089
1089
  gap: 24
1090
1090
  },
1091
1091
  children: l.map((e, o) => {
1092
- let c = e.objectName ?? d ?? "", l = ze({
1092
+ let c = e.objectName ?? d ?? "", l = Ye({
1093
1093
  ...e,
1094
1094
  objectName: c,
1095
1095
  type: e.type ?? "tabular",
1096
1096
  columns: e.columns ?? []
1097
- }, u), f = Re(e.label, e.name), p = e.description ? Re(e.description, "") : "", m = e.name ?? `block-${o}`, h = /* @__PURE__ */ A("section", {
1097
+ }, u), f = Je(e.label, e.name), p = e.description ? Je(e.description, "") : "", m = e.name ?? `block-${o}`, h = /* @__PURE__ */ F("section", {
1098
1098
  "data-testid": "joined-report-block",
1099
1099
  "data-block-id": m,
1100
1100
  style: {
@@ -1106,20 +1106,20 @@ var Be = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillVi
1106
1106
  padding: 16,
1107
1107
  background: "var(--color-card, #ffffff)"
1108
1108
  },
1109
- children: [/* @__PURE__ */ A("header", {
1109
+ children: [/* @__PURE__ */ F("header", {
1110
1110
  style: {
1111
1111
  display: "flex",
1112
1112
  flexDirection: "column",
1113
1113
  gap: 2
1114
1114
  },
1115
- children: [/* @__PURE__ */ k("h3", {
1115
+ children: [/* @__PURE__ */ P("h3", {
1116
1116
  style: {
1117
1117
  margin: 0,
1118
1118
  fontSize: 16,
1119
1119
  fontWeight: 600
1120
1120
  },
1121
1121
  children: f
1122
- }), p ? /* @__PURE__ */ k("p", {
1122
+ }), p ? /* @__PURE__ */ P("p", {
1123
1123
  style: {
1124
1124
  margin: 0,
1125
1125
  fontSize: 13,
@@ -1127,7 +1127,7 @@ var Be = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillVi
1127
1127
  },
1128
1128
  children: p
1129
1129
  }) : null]
1130
- }), /* @__PURE__ */ k(X, {
1130
+ }), /* @__PURE__ */ P(Qe, {
1131
1131
  schema: l,
1132
1132
  dataSource: t,
1133
1133
  runtimeFilter: n,
@@ -1139,18 +1139,18 @@ var Be = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillVi
1139
1139
  return s ? s(e, o, h) : h;
1140
1140
  })
1141
1141
  });
1142
- }, Ve = {
1142
+ }, Ze = {
1143
1143
  border: "1px dashed var(--color-border, #d4d4d8)",
1144
1144
  borderRadius: 8,
1145
1145
  padding: 16,
1146
1146
  color: "var(--color-muted-foreground, #71717a)",
1147
1147
  background: "var(--color-muted, #f4f4f5)",
1148
1148
  fontSize: 13
1149
- }, X = (e) => {
1149
+ }, Qe = (e) => {
1150
1150
  let { dataSource: t, rows: n, runtimeFilter: r, actionRunner: i, drillView: a, drillOpenIn: o, className: s } = e, u = e.schema;
1151
1151
  if (u && typeof u == "object" && u.type === "spec-report" && u.report && typeof u.report == "object" && (u = u.report), l(u)) {
1152
1152
  let e = u.type ?? "tabular";
1153
- return e === "matrix" ? /* @__PURE__ */ k(Le, {
1153
+ return e === "matrix" ? /* @__PURE__ */ P(Ke, {
1154
1154
  report: u,
1155
1155
  dataSource: t,
1156
1156
  rows: n,
@@ -1159,7 +1159,7 @@ var Be = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillVi
1159
1159
  drillView: a,
1160
1160
  drillOpenIn: o,
1161
1161
  className: s
1162
- }) : e === "joined" ? c(u) ? /* @__PURE__ */ k(Be, {
1162
+ }) : e === "joined" ? c(u) ? /* @__PURE__ */ P(Xe, {
1163
1163
  report: u,
1164
1164
  dataSource: t,
1165
1165
  runtimeFilter: r,
@@ -1167,18 +1167,18 @@ var Be = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillVi
1167
1167
  drillView: a,
1168
1168
  drillOpenIn: o,
1169
1169
  className: s
1170
- }) : /* @__PURE__ */ A("div", {
1170
+ }) : /* @__PURE__ */ F("div", {
1171
1171
  className: s,
1172
- style: Ve,
1172
+ style: Ze,
1173
1173
  "data-testid": "report-joined-placeholder",
1174
1174
  children: [
1175
1175
  "Joined report (",
1176
- /* @__PURE__ */ k("code", { children: u.name }),
1176
+ /* @__PURE__ */ P("code", { children: u.name }),
1177
1177
  ") is missing a ",
1178
- /* @__PURE__ */ k("code", { children: "blocks" }),
1178
+ /* @__PURE__ */ P("code", { children: "blocks" }),
1179
1179
  " array."
1180
1180
  ]
1181
- }) : /* @__PURE__ */ k(Me, {
1181
+ }) : /* @__PURE__ */ P(Ve, {
1182
1182
  report: u,
1183
1183
  dataSource: t,
1184
1184
  rows: n,
@@ -1189,33 +1189,33 @@ var Be = ({ report: e, dataSource: t, runtimeFilter: n, actionRunner: r, drillVi
1189
1189
  className: s
1190
1190
  });
1191
1191
  }
1192
- return /* @__PURE__ */ k(B, { schema: u });
1192
+ return /* @__PURE__ */ P(ge, { schema: u });
1193
1193
  };
1194
1194
  //#endregion
1195
1195
  //#region src/ReportExportEngine.ts
1196
- function He(e, t, n) {
1196
+ function $e(e, t, n) {
1197
1197
  let r = e.fields || [], i = r.map((e) => e.label || e.name), a = t.map((e) => r.map((t) => {
1198
1198
  let n = e[t.name];
1199
- return n = Je(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
1199
+ return n = at(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
1200
1200
  }));
1201
- Q([...n?.includeHeaders === !1 ? [] : [i.join(",")], ...a.map((e) => e.join(","))].join("\n"), n?.filename || `${e.title || "report"}.csv`, "text/csv");
1201
+ ct([...n?.includeHeaders === !1 ? [] : [i.join(",")], ...a.map((e) => e.join(","))].join("\n"), n?.filename || `${e.title || "report"}.csv`, "text/csv");
1202
1202
  }
1203
- function Ue(e, t, n) {
1203
+ function et(e, t, n) {
1204
1204
  let r = {
1205
1205
  title: e.title,
1206
1206
  description: e.description,
1207
1207
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1208
1208
  data: t
1209
1209
  };
1210
- Q(JSON.stringify(r, null, 2), n?.filename || `${e.title || "report"}.json`, "application/json");
1210
+ ct(JSON.stringify(r, null, 2), n?.filename || `${e.title || "report"}.json`, "application/json");
1211
1211
  }
1212
- function We(e, t, n) {
1213
- let r = e.fields || [], i = Xe(n?.orientation), a = Ye(n?.pageSize);
1214
- Q(`<!DOCTYPE html>
1212
+ function tt(e, t, n) {
1213
+ let r = e.fields || [], i = st(n?.orientation), a = ot(n?.pageSize);
1214
+ ct(`<!DOCTYPE html>
1215
1215
  <html>
1216
1216
  <head>
1217
1217
  <meta charset="utf-8">
1218
- <title>${Z(e.title || "Report")}</title>
1218
+ <title>${Q(e.title || "Report")}</title>
1219
1219
  <style>
1220
1220
  @page { size: ${a} ${i}; margin: 20mm; }
1221
1221
  body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
@@ -1229,20 +1229,20 @@ function We(e, t, n) {
1229
1229
  </style>
1230
1230
  </head>
1231
1231
  <body>
1232
- <h1>${Z(e.title || "Report")}</h1>
1233
- ${e.description ? `<p class="description">${Z(e.description)}</p>` : ""}
1232
+ <h1>${Q(e.title || "Report")}</h1>
1233
+ ${e.description ? `<p class="description">${Q(e.description)}</p>` : ""}
1234
1234
  <p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
1235
1235
  <table>
1236
- <thead><tr>${r.map((e) => `<th>${Z(e.label || e.name)}</th>`).join("")}</tr></thead>
1237
- <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${Z(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
1236
+ <thead><tr>${r.map((e) => `<th>${Q(e.label || e.name)}</th>`).join("")}</tr></thead>
1237
+ <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${Q(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
1238
1238
  </table>
1239
1239
  </body>
1240
1240
  </html>`, n?.filename || `${e.title || "report"}.html`, "text/html");
1241
1241
  }
1242
- function Ge(e, t, n) {
1243
- let r = e.fields || [], i = Xe(n?.orientation), a = Ye(n?.pageSize), o = window.open("", "_blank");
1242
+ function nt(e, t, n) {
1243
+ let r = e.fields || [], i = st(n?.orientation), a = ot(n?.pageSize), o = window.open("", "_blank");
1244
1244
  if (!o) {
1245
- We(e, t, {
1245
+ tt(e, t, {
1246
1246
  ...n,
1247
1247
  format: "html",
1248
1248
  filename: n?.filename?.replace(/\.pdf$/, ".html") || `${e.title || "report"}.html`
@@ -1253,7 +1253,7 @@ function Ge(e, t, n) {
1253
1253
  <html>
1254
1254
  <head>
1255
1255
  <meta charset="utf-8">
1256
- <title>${Z(e.title || "Report")}</title>
1256
+ <title>${Q(e.title || "Report")}</title>
1257
1257
  <style>
1258
1258
  @page { size: ${a} ${i}; margin: 20mm; }
1259
1259
  @media print { .no-print { display: none; } }
@@ -1268,56 +1268,56 @@ function Ge(e, t, n) {
1268
1268
  </style>
1269
1269
  </head>
1270
1270
  <body>
1271
- <h1>${Z(e.title || "Report")}</h1>
1272
- ${e.description ? `<p class="description">${Z(e.description)}</p>` : ""}
1271
+ <h1>${Q(e.title || "Report")}</h1>
1272
+ ${e.description ? `<p class="description">${Q(e.description)}</p>` : ""}
1273
1273
  <p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
1274
1274
  <table>
1275
- <thead><tr>${r.map((e) => `<th>${Z(e.label || e.name)}</th>`).join("")}</tr></thead>
1276
- <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${Z(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
1275
+ <thead><tr>${r.map((e) => `<th>${Q(e.label || e.name)}</th>`).join("")}</tr></thead>
1276
+ <tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${Q(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
1277
1277
  </table>
1278
1278
  </body>
1279
1279
  </html>`), o.document.close(), o.onload = () => {
1280
1280
  o.print();
1281
1281
  };
1282
1282
  }
1283
- function Ke(e, t, n) {
1283
+ function rt(e, t, n) {
1284
1284
  let r = e.fields || [], i = r.map((e) => e.label || e.name), a = t.map((e) => r.map((t) => {
1285
1285
  let n = e[t.name];
1286
- return n = Je(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n") || n.includes(" ")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
1286
+ return n = at(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n") || n.includes(" ")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
1287
1287
  }));
1288
- Q("" + [...n?.includeHeaders === !1 ? [] : [i.join(" ")], ...a.map((e) => e.join(" "))].join("\n"), n?.filename || `${e.title || "report"}.tsv`, "text/tab-separated-values");
1288
+ ct("" + [...n?.includeHeaders === !1 ? [] : [i.join(" ")], ...a.map((e) => e.join(" "))].join("\n"), n?.filename || `${e.title || "report"}.tsv`, "text/tab-separated-values");
1289
1289
  }
1290
- function qe(e, t, n, r) {
1290
+ function it(e, t, n, r) {
1291
1291
  switch (e) {
1292
1292
  case "csv":
1293
- He(t, n, r);
1293
+ $e(t, n, r);
1294
1294
  break;
1295
1295
  case "json":
1296
- Ue(t, n, r);
1296
+ et(t, n, r);
1297
1297
  break;
1298
1298
  case "html":
1299
- We(t, n, r);
1299
+ tt(t, n, r);
1300
1300
  break;
1301
1301
  case "pdf":
1302
- Ge(t, n, r);
1302
+ nt(t, n, r);
1303
1303
  break;
1304
1304
  case "excel":
1305
- Ke(t, n, r);
1305
+ rt(t, n, r);
1306
1306
  break;
1307
1307
  default: console.warn(`Unsupported export format: ${e}`);
1308
1308
  }
1309
1309
  }
1310
- function Z(e) {
1310
+ function Q(e) {
1311
1311
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
1312
1312
  }
1313
- function Je(e) {
1313
+ function at(e) {
1314
1314
  if (typeof e == "string" && e.length > 0) {
1315
1315
  let t = e.charAt(0);
1316
1316
  if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `\t${e}`;
1317
1317
  }
1318
1318
  return e;
1319
1319
  }
1320
- function Ye(e) {
1320
+ function ot(e) {
1321
1321
  return [
1322
1322
  "A4",
1323
1323
  "A3",
@@ -1325,19 +1325,19 @@ function Ye(e) {
1325
1325
  "Legal"
1326
1326
  ].includes(e || "") ? e : "A4";
1327
1327
  }
1328
- function Xe(e) {
1328
+ function st(e) {
1329
1329
  return e === "landscape" ? "landscape" : "portrait";
1330
1330
  }
1331
- function Q(e, t, n) {
1331
+ function ct(e, t, n) {
1332
1332
  let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
1333
1333
  a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
1334
1334
  }
1335
1335
  //#endregion
1336
1336
  //#region src/formatValue.ts
1337
- function $(e, t) {
1337
+ function lt(e, t) {
1338
1338
  if (e == null || e === "") return "";
1339
1339
  let n = t?.type, r = t?.format;
1340
- if (n === "date" || r === "date" || Ze(e)) return Qe(e);
1340
+ if (n === "date" || r === "date" || ut(e)) return dt(e);
1341
1341
  if (n === "number" || typeof e == "number") {
1342
1342
  let t = typeof e == "number" ? e : Number(e);
1343
1343
  return isNaN(t) ? String(e) : r === "currency" || r === "currency_cny" ? `¥${t.toLocaleString("en-US", {
@@ -1353,10 +1353,10 @@ function $(e, t) {
1353
1353
  }
1354
1354
  return String(e);
1355
1355
  }
1356
- function Ze(e) {
1356
+ function ut(e) {
1357
1357
  return typeof e == "string" ? /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e) : !1;
1358
1358
  }
1359
- function Qe(e) {
1359
+ function dt(e) {
1360
1360
  try {
1361
1361
  let t = new Date(e);
1362
1362
  return isNaN(t.getTime()) ? String(e) : `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}-${String(t.getDate()).padStart(2, "0")}`;
@@ -1366,7 +1366,7 @@ function Qe(e) {
1366
1366
  }
1367
1367
  //#endregion
1368
1368
  //#region src/ReportViewer.tsx
1369
- function $e(e, t) {
1369
+ function ft(e, t) {
1370
1370
  if (!t || t.length === 0 || !e || e.length === 0) return null;
1371
1371
  let n = t[0], r = n.field, i = /* @__PURE__ */ new Map();
1372
1372
  for (let t of e) {
@@ -1382,13 +1382,13 @@ function $e(e, t) {
1382
1382
  let o = n.sort === "desc" ? -1 : 1;
1383
1383
  return a.sort((e, t) => e.key.localeCompare(t.key) * o), a;
1384
1384
  }
1385
- var et = ({ schema: t, onRefresh: r }) => {
1385
+ var pt = ({ schema: t, onRefresh: r }) => {
1386
1386
  let { report: i, data: a, showToolbar: o = !0, allowExport: s = !0, allowPrint: c = !0, loading: l = !1 } = t, _ = (e) => {
1387
1387
  if (!i) {
1388
1388
  console.warn("ReportViewer: Cannot export, no report defined");
1389
1389
  return;
1390
1390
  }
1391
- qe(e, i, a || [], i.exportConfigs?.[e]);
1391
+ it(e, i, a || [], i.exportConfigs?.[e]);
1392
1392
  }, v = () => {
1393
1393
  window.print();
1394
1394
  }, y = () => {
@@ -1404,7 +1404,7 @@ var et = ({ schema: t, onRefresh: r }) => {
1404
1404
  case "max": return n.length > 0 ? Math.max(...n) : 0;
1405
1405
  default: return "";
1406
1406
  }
1407
- }, S = (e, t) => {
1407
+ }, x = (e, t) => {
1408
1408
  let n = i?.conditionalFormatting;
1409
1409
  if (!(!n || !Array.isArray(n))) for (let r of n) {
1410
1410
  if (r.field !== e) continue;
@@ -1431,127 +1431,127 @@ var et = ({ schema: t, onRefresh: r }) => {
1431
1431
  return r.backgroundColor && (e.backgroundColor = r.backgroundColor), r.textColor && (e.color = r.textColor), e;
1432
1432
  }
1433
1433
  }
1434
- }, C = (e, t) => {
1434
+ }, S = (e, t) => {
1435
1435
  if (e == null || e === "") return "";
1436
- if (t.renderAs === "badge" && (!t.type || t.type === "string" || t.type === "text")) return /* @__PURE__ */ k(u, {
1436
+ if (t.renderAs === "badge" && (!t.type || t.type === "string" || t.type === "text")) return /* @__PURE__ */ P(u, {
1437
1437
  className: t.colorMap?.[String(e)] || "",
1438
1438
  children: String(e)
1439
1439
  });
1440
- if (t.aggregation) return $(e, t);
1440
+ if (t.aggregation) return lt(e, t);
1441
1441
  if (t.type) {
1442
1442
  let n = { ...t };
1443
1443
  return t.colorMap && !n.options && (n.options = Object.entries(t.colorMap).map(([e, t]) => ({
1444
1444
  value: e,
1445
1445
  label: e,
1446
1446
  color: t
1447
- }))), /* @__PURE__ */ k(se(ce(n)), {
1447
+ }))), /* @__PURE__ */ P(me(he(n)), {
1448
1448
  value: e,
1449
1449
  field: n
1450
1450
  });
1451
1451
  }
1452
- return $(e, t);
1452
+ return lt(e, t);
1453
1453
  };
1454
- return i ? /* @__PURE__ */ A("div", {
1454
+ return i ? /* @__PURE__ */ F("div", {
1455
1455
  className: "space-y-4",
1456
- children: [o && /* @__PURE__ */ A("div", {
1456
+ children: [o && /* @__PURE__ */ F("div", {
1457
1457
  className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border",
1458
- children: [/* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("h2", {
1458
+ children: [/* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("h2", {
1459
1459
  className: "text-lg font-semibold",
1460
1460
  children: i.title
1461
- }), i.description && /* @__PURE__ */ k("p", {
1461
+ }), i.description && /* @__PURE__ */ P("p", {
1462
1462
  className: "text-sm text-muted-foreground",
1463
1463
  children: i.description
1464
- })] }), /* @__PURE__ */ A("div", {
1464
+ })] }), /* @__PURE__ */ F("div", {
1465
1465
  className: "flex items-center gap-2",
1466
1466
  children: [
1467
- i.refreshInterval && /* @__PURE__ */ A(d, {
1467
+ i.refreshInterval && /* @__PURE__ */ F(d, {
1468
1468
  variant: "outline",
1469
1469
  size: "sm",
1470
1470
  onClick: y,
1471
- children: [/* @__PURE__ */ k(ie, { className: "h-4 w-4 mr-2" }), "Refresh"]
1471
+ children: [/* @__PURE__ */ P(ue, { className: "h-4 w-4 mr-2" }), "Refresh"]
1472
1472
  }),
1473
- c && /* @__PURE__ */ A(d, {
1473
+ c && /* @__PURE__ */ F(d, {
1474
1474
  variant: "outline",
1475
1475
  size: "sm",
1476
1476
  onClick: v,
1477
- children: [/* @__PURE__ */ k(R, { className: "h-4 w-4 mr-2" }), "Print"]
1477
+ children: [/* @__PURE__ */ P(le, { className: "h-4 w-4 mr-2" }), "Print"]
1478
1478
  }),
1479
- s && i.showExportButtons && /* @__PURE__ */ A("div", {
1479
+ s && i.showExportButtons && /* @__PURE__ */ F("div", {
1480
1480
  className: "flex items-center gap-1",
1481
1481
  children: [
1482
- /* @__PURE__ */ A(d, {
1482
+ /* @__PURE__ */ F(d, {
1483
1483
  variant: "outline",
1484
1484
  size: "sm",
1485
1485
  onClick: () => _("pdf"),
1486
- children: [/* @__PURE__ */ k(I, { className: "h-4 w-4 mr-2" }), "PDF"]
1486
+ children: [/* @__PURE__ */ P(ae, { className: "h-4 w-4 mr-2" }), "PDF"]
1487
1487
  }),
1488
- /* @__PURE__ */ A(d, {
1488
+ /* @__PURE__ */ F(d, {
1489
1489
  variant: "outline",
1490
1490
  size: "sm",
1491
1491
  onClick: () => _("excel"),
1492
- children: [/* @__PURE__ */ k(I, { className: "h-4 w-4 mr-2" }), "Excel"]
1492
+ children: [/* @__PURE__ */ P(ae, { className: "h-4 w-4 mr-2" }), "Excel"]
1493
1493
  }),
1494
- /* @__PURE__ */ A(d, {
1494
+ /* @__PURE__ */ F(d, {
1495
1495
  variant: "outline",
1496
1496
  size: "sm",
1497
1497
  onClick: () => _("csv"),
1498
- children: [/* @__PURE__ */ k(I, { className: "h-4 w-4 mr-2" }), "CSV"]
1498
+ children: [/* @__PURE__ */ P(ae, { className: "h-4 w-4 mr-2" }), "CSV"]
1499
1499
  })
1500
1500
  ]
1501
1501
  })
1502
1502
  ]
1503
1503
  })]
1504
- }), /* @__PURE__ */ A(f, { children: [/* @__PURE__ */ A(h, { children: [!o && i.title && /* @__PURE__ */ k(g, { children: i.title }), !o && i.description && /* @__PURE__ */ k(m, { children: i.description })] }), /* @__PURE__ */ A(p, {
1504
+ }), /* @__PURE__ */ F(f, { children: [/* @__PURE__ */ F(h, { children: [!o && i.title && /* @__PURE__ */ P(g, { children: i.title }), !o && i.description && /* @__PURE__ */ P(m, { children: i.description })] }), /* @__PURE__ */ F(p, {
1505
1505
  className: "space-y-6",
1506
1506
  children: [
1507
- l && /* @__PURE__ */ A("div", {
1507
+ l && /* @__PURE__ */ F("div", {
1508
1508
  className: "space-y-6",
1509
- children: [/* @__PURE__ */ k("div", {
1509
+ children: [/* @__PURE__ */ P("div", {
1510
1510
  className: "grid grid-cols-1 md:grid-cols-3 gap-4",
1511
1511
  children: [
1512
1512
  1,
1513
1513
  2,
1514
1514
  3
1515
- ].map((e) => /* @__PURE__ */ k(f, { children: /* @__PURE__ */ A(p, {
1515
+ ].map((e) => /* @__PURE__ */ P(f, { children: /* @__PURE__ */ F(p, {
1516
1516
  className: "p-4 space-y-2",
1517
- children: [/* @__PURE__ */ k(x, { className: "h-4 w-20" }), /* @__PURE__ */ k(x, { className: "h-8 w-28" })]
1517
+ children: [/* @__PURE__ */ P(O, { className: "h-4 w-20" }), /* @__PURE__ */ P(O, { className: "h-8 w-28" })]
1518
1518
  }) }, e))
1519
- }), /* @__PURE__ */ A("div", {
1519
+ }), /* @__PURE__ */ F("div", {
1520
1520
  className: "space-y-2",
1521
- children: [/* @__PURE__ */ k(x, { className: "h-10 w-full" }), [
1521
+ children: [/* @__PURE__ */ P(O, { className: "h-10 w-full" }), [
1522
1522
  1,
1523
1523
  2,
1524
1524
  3,
1525
1525
  4,
1526
1526
  5
1527
- ].map((e) => /* @__PURE__ */ k(x, { className: "h-8 w-full" }, e))]
1527
+ ].map((e) => /* @__PURE__ */ P(O, { className: "h-8 w-full" }, e))]
1528
1528
  })]
1529
1529
  }),
1530
- !l && i.sections?.map((t, r) => t.visible === !1 ? null : /* @__PURE__ */ A("div", {
1530
+ !l && i.sections?.map((t, r) => t.visible === !1 ? null : /* @__PURE__ */ F("div", {
1531
1531
  className: "space-y-2",
1532
1532
  children: [
1533
- t.title && t.type !== "header" && /* @__PURE__ */ k("h3", {
1533
+ t.title && t.type !== "header" && /* @__PURE__ */ P("h3", {
1534
1534
  className: "text-lg font-semibold border-b pb-2",
1535
1535
  children: t.title
1536
1536
  }),
1537
- t.type === "header" && t.title && /* @__PURE__ */ k("div", {
1537
+ t.type === "header" && t.title && /* @__PURE__ */ P("div", {
1538
1538
  className: "text-2xl font-bold py-4",
1539
1539
  children: t.title
1540
1540
  }),
1541
- t.type === "summary" && /* @__PURE__ */ k("div", {
1541
+ t.type === "summary" && /* @__PURE__ */ P("div", {
1542
1542
  className: "grid grid-cols-1 md:grid-cols-3 gap-4",
1543
- children: i.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */ k(f, { children: /* @__PURE__ */ A(p, {
1543
+ children: i.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */ P(f, { children: /* @__PURE__ */ F(p, {
1544
1544
  className: "p-4",
1545
- children: [/* @__PURE__ */ k("div", {
1545
+ children: [/* @__PURE__ */ P("div", {
1546
1546
  className: "text-sm text-muted-foreground",
1547
1547
  children: e.label || e.name
1548
- }), /* @__PURE__ */ k("div", {
1548
+ }), /* @__PURE__ */ P("div", {
1549
1549
  className: "text-2xl font-bold",
1550
- children: $(b(e.name, e.aggregation), e)
1550
+ children: lt(b(e.name, e.aggregation), e)
1551
1551
  })]
1552
1552
  }) }, t))
1553
1553
  }),
1554
- t.type === "chart" && t.chart && /* @__PURE__ */ k("div", {
1554
+ t.type === "chart" && t.chart && /* @__PURE__ */ P("div", {
1555
1555
  className: "min-h-[300px]",
1556
1556
  children: (() => {
1557
1557
  let n = t.chart.type, r = !!t.chart.chartType;
@@ -1561,7 +1561,7 @@ var et = ({ schema: t, onRefresh: r }) => {
1561
1561
  series: t.chart.series || (t.chart.yAxisFields ? t.chart.yAxisFields.map((e) => ({ dataKey: e })) : []),
1562
1562
  chartType: t.chart.chartType || "bar"
1563
1563
  } : {};
1564
- return /* @__PURE__ */ k(N, { schema: {
1564
+ return /* @__PURE__ */ P(z, { schema: {
1565
1565
  ...t.chart,
1566
1566
  type: n,
1567
1567
  ...i,
@@ -1570,21 +1570,21 @@ var et = ({ schema: t, onRefresh: r }) => {
1570
1570
  } });
1571
1571
  })()
1572
1572
  }),
1573
- t.type === "table" && /* @__PURE__ */ k("div", {
1573
+ t.type === "table" && /* @__PURE__ */ P("div", {
1574
1574
  className: "border rounded-lg overflow-x-auto",
1575
- children: /* @__PURE__ */ A("table", {
1575
+ children: /* @__PURE__ */ F("table", {
1576
1576
  className: "w-full text-sm min-w-[600px]",
1577
- children: [/* @__PURE__ */ k("thead", {
1577
+ children: [/* @__PURE__ */ P("thead", {
1578
1578
  className: "bg-muted",
1579
- children: /* @__PURE__ */ k("tr", { children: t.columns?.map((e, t) => /* @__PURE__ */ k("th", {
1579
+ children: /* @__PURE__ */ P("tr", { children: t.columns?.map((e, t) => /* @__PURE__ */ P("th", {
1580
1580
  className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
1581
1581
  children: e.label || e.name
1582
1582
  }, t)) })
1583
- }), /* @__PURE__ */ k("tbody", { children: (() => {
1584
- let e = $e(a || [], i.groupBy || []);
1585
- return e ? e.map((e) => /* @__PURE__ */ A(n.Fragment, { children: [/* @__PURE__ */ k("tr", {
1583
+ }), /* @__PURE__ */ P("tbody", { children: (() => {
1584
+ let e = ft(a || [], i.groupBy || []);
1585
+ return e ? e.map((e) => /* @__PURE__ */ F(n.Fragment, { children: [/* @__PURE__ */ P("tr", {
1586
1586
  className: "bg-muted/60",
1587
- children: /* @__PURE__ */ A("td", {
1587
+ children: /* @__PURE__ */ F("td", {
1588
1588
  colSpan: t.columns?.length || 1,
1589
1589
  className: "px-4 py-2 font-semibold text-sm",
1590
1590
  children: [
@@ -1594,59 +1594,59 @@ var et = ({ schema: t, onRefresh: r }) => {
1594
1594
  ")"
1595
1595
  ]
1596
1596
  })
1597
- }), e.rows.map((e, n) => /* @__PURE__ */ k("tr", {
1597
+ }), e.rows.map((e, n) => /* @__PURE__ */ P("tr", {
1598
1598
  className: "border-t hover:bg-muted/50 even:bg-muted/20",
1599
- children: t.columns?.map((t, n) => /* @__PURE__ */ k("td", {
1599
+ children: t.columns?.map((t, n) => /* @__PURE__ */ P("td", {
1600
1600
  className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
1601
- style: S(t.name, e[t.name]),
1602
- children: C(e[t.name], t)
1601
+ style: x(t.name, e[t.name]),
1602
+ children: S(e[t.name], t)
1603
1603
  }, n))
1604
- }, n))] }, e.key)) : a?.map((e, n) => /* @__PURE__ */ k("tr", {
1604
+ }, n))] }, e.key)) : a?.map((e, n) => /* @__PURE__ */ P("tr", {
1605
1605
  className: "border-t hover:bg-muted/50 even:bg-muted/20",
1606
- children: t.columns?.map((t, n) => /* @__PURE__ */ k("td", {
1606
+ children: t.columns?.map((t, n) => /* @__PURE__ */ P("td", {
1607
1607
  className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
1608
- style: S(t.name, e[t.name]),
1609
- children: C(e[t.name], t)
1608
+ style: x(t.name, e[t.name]),
1609
+ children: S(e[t.name], t)
1610
1610
  }, n))
1611
1611
  }, n));
1612
1612
  })() })]
1613
1613
  })
1614
1614
  }),
1615
- t.type === "text" && t.text && /* @__PURE__ */ k("div", {
1615
+ t.type === "text" && t.text && /* @__PURE__ */ P("div", {
1616
1616
  className: "prose max-w-none",
1617
- children: /* @__PURE__ */ k("p", { children: t.text })
1617
+ children: /* @__PURE__ */ P("p", { children: t.text })
1618
1618
  }),
1619
- t.type === "page-break" && /* @__PURE__ */ k("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
1620
- t.content && /* @__PURE__ */ k(N, { schema: t.content })
1619
+ t.type === "page-break" && /* @__PURE__ */ P("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
1620
+ t.content && /* @__PURE__ */ P(z, { schema: t.content })
1621
1621
  ]
1622
1622
  }, r)),
1623
- !i.sections && a && a.length > 0 && /* @__PURE__ */ k("div", {
1623
+ !i.sections && a && a.length > 0 && /* @__PURE__ */ P("div", {
1624
1624
  className: "border rounded-lg overflow-x-auto",
1625
- children: /* @__PURE__ */ A("table", {
1625
+ children: /* @__PURE__ */ F("table", {
1626
1626
  className: "w-full text-sm min-w-[600px]",
1627
- children: [/* @__PURE__ */ k("thead", {
1627
+ children: [/* @__PURE__ */ P("thead", {
1628
1628
  className: "bg-muted",
1629
- children: /* @__PURE__ */ k("tr", { children: i.fields?.map((e, t) => /* @__PURE__ */ k("th", {
1629
+ children: /* @__PURE__ */ P("tr", { children: i.fields?.map((e, t) => /* @__PURE__ */ P("th", {
1630
1630
  className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
1631
1631
  children: e.label || e.name
1632
1632
  }, t)) })
1633
- }), /* @__PURE__ */ k("tbody", { children: a.map((e, t) => /* @__PURE__ */ k("tr", {
1633
+ }), /* @__PURE__ */ P("tbody", { children: a.map((e, t) => /* @__PURE__ */ P("tr", {
1634
1634
  className: "border-t hover:bg-muted/50 even:bg-muted/20",
1635
- children: i.fields?.map((t, n) => /* @__PURE__ */ k("td", {
1635
+ children: i.fields?.map((t, n) => /* @__PURE__ */ P("td", {
1636
1636
  className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
1637
- style: S(t.name, e[t.name]),
1638
- children: C(e[t.name], t)
1637
+ style: x(t.name, e[t.name]),
1638
+ children: S(e[t.name], t)
1639
1639
  }, n))
1640
1640
  }, t)) })]
1641
1641
  })
1642
1642
  })
1643
1643
  ]
1644
1644
  })] })]
1645
- }) : /* @__PURE__ */ k(f, { children: /* @__PURE__ */ k(p, {
1645
+ }) : /* @__PURE__ */ P(f, { children: /* @__PURE__ */ P(p, {
1646
1646
  className: "p-8 text-center text-muted-foreground",
1647
1647
  children: "No report to display"
1648
1648
  }) });
1649
- }, tt = ({ schedule: e, onChange: t }) => {
1649
+ }, mt = ({ schedule: e, onChange: t }) => {
1650
1650
  let [n, r] = s(e || {
1651
1651
  enabled: !1,
1652
1652
  frequency: "weekly",
@@ -1661,27 +1661,27 @@ var et = ({ schema: t, onRefresh: r }) => {
1661
1661
  };
1662
1662
  r(i), t?.(i);
1663
1663
  };
1664
- return /* @__PURE__ */ A(f, { children: [/* @__PURE__ */ k(h, { children: /* @__PURE__ */ A(g, {
1664
+ return /* @__PURE__ */ F(f, { children: [/* @__PURE__ */ P(h, { children: /* @__PURE__ */ F(g, {
1665
1665
  className: "flex items-center gap-2",
1666
- children: [/* @__PURE__ */ k(P, { className: "h-5 w-5" }), "Schedule Configuration"]
1667
- }) }), /* @__PURE__ */ A(p, {
1666
+ children: [/* @__PURE__ */ P(ne, { className: "h-5 w-5" }), "Schedule Configuration"]
1667
+ }) }), /* @__PURE__ */ F(p, {
1668
1668
  className: "space-y-4",
1669
- children: [/* @__PURE__ */ A("div", {
1669
+ children: [/* @__PURE__ */ F("div", {
1670
1670
  className: "flex items-center gap-2",
1671
- children: [/* @__PURE__ */ k("input", {
1671
+ children: [/* @__PURE__ */ P("input", {
1672
1672
  type: "checkbox",
1673
1673
  id: "schedule-enabled",
1674
1674
  checked: n.enabled || !1,
1675
1675
  onChange: (e) => i({ enabled: e.target.checked }),
1676
1676
  className: "rounded"
1677
- }), /* @__PURE__ */ k(b, {
1677
+ }), /* @__PURE__ */ P(D, {
1678
1678
  htmlFor: "schedule-enabled",
1679
1679
  children: "Enable Scheduled Report"
1680
1680
  })]
1681
- }), n.enabled && /* @__PURE__ */ A(O, { children: [
1682
- /* @__PURE__ */ A("div", {
1681
+ }), n.enabled && /* @__PURE__ */ F(N, { children: [
1682
+ /* @__PURE__ */ F("div", {
1683
1683
  className: "space-y-2",
1684
- children: [/* @__PURE__ */ k(b, { children: "Frequency" }), /* @__PURE__ */ k("select", {
1684
+ children: [/* @__PURE__ */ P(D, { children: "Frequency" }), /* @__PURE__ */ P("select", {
1685
1685
  className: "w-full border rounded-md p-2 bg-background",
1686
1686
  value: n.frequency || "weekly",
1687
1687
  onChange: (e) => i({ frequency: e.target.value }),
@@ -1710,15 +1710,15 @@ var et = ({ schema: t, onRefresh: r }) => {
1710
1710
  value: "yearly",
1711
1711
  label: "Yearly"
1712
1712
  }
1713
- ].map((e) => /* @__PURE__ */ k("option", {
1713
+ ].map((e) => /* @__PURE__ */ P("option", {
1714
1714
  value: e.value,
1715
1715
  children: e.label
1716
1716
  }, e.value))
1717
1717
  })]
1718
1718
  }),
1719
- n.frequency === "weekly" && /* @__PURE__ */ A("div", {
1719
+ n.frequency === "weekly" && /* @__PURE__ */ F("div", {
1720
1720
  className: "space-y-2",
1721
- children: [/* @__PURE__ */ k(b, { children: "Day of Week" }), /* @__PURE__ */ k("select", {
1721
+ children: [/* @__PURE__ */ P(D, { children: "Day of Week" }), /* @__PURE__ */ P("select", {
1722
1722
  className: "w-full border rounded-md p-2 bg-background",
1723
1723
  value: n.dayOfWeek ?? 1,
1724
1724
  onChange: (e) => i({ dayOfWeek: Number(e.target.value) }),
@@ -1751,15 +1751,15 @@ var et = ({ schema: t, onRefresh: r }) => {
1751
1751
  value: 6,
1752
1752
  label: "Saturday"
1753
1753
  }
1754
- ].map((e) => /* @__PURE__ */ k("option", {
1754
+ ].map((e) => /* @__PURE__ */ P("option", {
1755
1755
  value: e.value,
1756
1756
  children: e.label
1757
1757
  }, e.value))
1758
1758
  })]
1759
1759
  }),
1760
- n.frequency === "monthly" && /* @__PURE__ */ A("div", {
1760
+ n.frequency === "monthly" && /* @__PURE__ */ F("div", {
1761
1761
  className: "space-y-2",
1762
- children: [/* @__PURE__ */ k(b, { children: "Day of Month" }), /* @__PURE__ */ k(y, {
1762
+ children: [/* @__PURE__ */ P(D, { children: "Day of Month" }), /* @__PURE__ */ P(E, {
1763
1763
  type: "number",
1764
1764
  min: 1,
1765
1765
  max: 31,
@@ -1767,28 +1767,28 @@ var et = ({ schema: t, onRefresh: r }) => {
1767
1767
  onChange: (e) => i({ dayOfMonth: Number(e.target.value) })
1768
1768
  })]
1769
1769
  }),
1770
- /* @__PURE__ */ A("div", {
1770
+ /* @__PURE__ */ F("div", {
1771
1771
  className: "space-y-2",
1772
- children: [/* @__PURE__ */ A(b, {
1772
+ children: [/* @__PURE__ */ F(D, {
1773
1773
  className: "flex items-center gap-2",
1774
- children: [/* @__PURE__ */ k(F, { className: "h-4 w-4" }), "Time"]
1775
- }), /* @__PURE__ */ k(y, {
1774
+ children: [/* @__PURE__ */ P(ie, { className: "h-4 w-4" }), "Time"]
1775
+ }), /* @__PURE__ */ P(E, {
1776
1776
  type: "time",
1777
1777
  value: n.time || "09:00",
1778
1778
  onChange: (e) => i({ time: e.target.value })
1779
1779
  })]
1780
1780
  }),
1781
- /* @__PURE__ */ A("div", {
1781
+ /* @__PURE__ */ F("div", {
1782
1782
  className: "space-y-2",
1783
- children: [/* @__PURE__ */ k(b, { children: "Timezone" }), /* @__PURE__ */ k(y, {
1783
+ children: [/* @__PURE__ */ P(D, { children: "Timezone" }), /* @__PURE__ */ P(E, {
1784
1784
  value: n.timezone || "",
1785
1785
  onChange: (e) => i({ timezone: e.target.value }),
1786
1786
  placeholder: "e.g. America/New_York"
1787
1787
  })]
1788
1788
  }),
1789
- /* @__PURE__ */ A("div", {
1789
+ /* @__PURE__ */ F("div", {
1790
1790
  className: "space-y-2",
1791
- children: [/* @__PURE__ */ k(b, { children: "Export Formats" }), /* @__PURE__ */ k("div", {
1791
+ children: [/* @__PURE__ */ P(D, { children: "Export Formats" }), /* @__PURE__ */ P("div", {
1792
1792
  className: "flex flex-wrap gap-2",
1793
1793
  children: [
1794
1794
  {
@@ -1807,9 +1807,9 @@ var et = ({ schema: t, onRefresh: r }) => {
1807
1807
  value: "html",
1808
1808
  label: "HTML"
1809
1809
  }
1810
- ].map((e) => /* @__PURE__ */ A("label", {
1810
+ ].map((e) => /* @__PURE__ */ F("label", {
1811
1811
  className: "flex items-center gap-1.5 px-3 py-1.5 border rounded-md cursor-pointer hover:bg-muted/50",
1812
- children: [/* @__PURE__ */ k("input", {
1812
+ children: [/* @__PURE__ */ P("input", {
1813
1813
  type: "checkbox",
1814
1814
  checked: n.formats?.includes(e.value) || !1,
1815
1815
  onChange: (t) => {
@@ -1817,27 +1817,27 @@ var et = ({ schema: t, onRefresh: r }) => {
1817
1817
  i({ formats: t.target.checked ? [...r, e.value] : r.filter((t) => t !== e.value) });
1818
1818
  },
1819
1819
  className: "rounded"
1820
- }), /* @__PURE__ */ k("span", {
1820
+ }), /* @__PURE__ */ P("span", {
1821
1821
  className: "text-sm",
1822
1822
  children: e.label
1823
1823
  })]
1824
1824
  }, e.value))
1825
1825
  })]
1826
1826
  }),
1827
- /* @__PURE__ */ A("div", {
1827
+ /* @__PURE__ */ F("div", {
1828
1828
  className: "space-y-2",
1829
- children: [/* @__PURE__ */ A(b, {
1829
+ children: [/* @__PURE__ */ F(D, {
1830
1830
  className: "flex items-center gap-2",
1831
- children: [/* @__PURE__ */ k(re, { className: "h-4 w-4" }), "Email Recipients"]
1832
- }), /* @__PURE__ */ k(y, {
1831
+ children: [/* @__PURE__ */ P(ce, { className: "h-4 w-4" }), "Email Recipients"]
1832
+ }), /* @__PURE__ */ P(E, {
1833
1833
  placeholder: "email1@example.com, email2@example.com",
1834
1834
  value: n.recipients?.join(", ") || "",
1835
1835
  onChange: (e) => i({ recipients: e.target.value.split(",").map((e) => e.trim()).filter(Boolean) })
1836
1836
  })]
1837
1837
  }),
1838
- /* @__PURE__ */ A("div", {
1838
+ /* @__PURE__ */ F("div", {
1839
1839
  className: "space-y-2",
1840
- children: [/* @__PURE__ */ k(b, { children: "Email Subject" }), /* @__PURE__ */ k(y, {
1840
+ children: [/* @__PURE__ */ P(D, { children: "Email Subject" }), /* @__PURE__ */ P(E, {
1841
1841
  value: n.subject || "",
1842
1842
  onChange: (e) => i({ subject: e.target.value }),
1843
1843
  placeholder: "Scheduled Report: {report_title}"
@@ -1845,7 +1845,7 @@ var et = ({ schema: t, onRefresh: r }) => {
1845
1845
  })
1846
1846
  ] })]
1847
1847
  })] });
1848
- }, nt = ({ schema: e }) => {
1848
+ }, ht = ({ schema: e }) => {
1849
1849
  let { report: t, dataSources: n = [], availableFields: r = [], showPreview: i = !0, onSave: a, onCancel: o } = e, [c, l] = s(t || {
1850
1850
  type: "report",
1851
1851
  title: "New Report",
@@ -1855,7 +1855,7 @@ var et = ({ schema: t, onRefresh: r }) => {
1855
1855
  sections: [],
1856
1856
  showExportButtons: !0,
1857
1857
  showPrintButton: !0
1858
- }), [u, _] = s(c.fields || []), [v, x] = s(c.filters || []), [S, D] = s(c.groupBy || []), [j, M] = s(c.sections || []), ee = () => {
1858
+ }), [u, _] = s(c.fields || []), [v, y] = s(c.filters || []), [b, x] = s(c.groupBy || []), [S, C] = s(c.sections || []), w = () => {
1859
1859
  if (r.length > 0 && u.length < r.length) {
1860
1860
  let e = r.find((e) => !u.some((t) => t.name === e.name));
1861
1861
  if (e) {
@@ -1866,130 +1866,130 @@ var et = ({ schema: t, onRefresh: r }) => {
1866
1866
  });
1867
1867
  }
1868
1868
  }
1869
- }, N = (e) => {
1869
+ }, T = (e) => {
1870
1870
  let t = u.filter((t, n) => n !== e);
1871
1871
  _(t), l({
1872
1872
  ...c,
1873
1873
  fields: t
1874
1874
  });
1875
- }, F = (e, t) => {
1875
+ }, O = (e, t) => {
1876
1876
  let n = [...u];
1877
1877
  n[e] = t, _(n), l({
1878
1878
  ...c,
1879
1879
  fields: n
1880
1880
  });
1881
- }, I = () => {
1881
+ }, ee = () => {
1882
1882
  let e = {
1883
1883
  field: r[0]?.name || "",
1884
1884
  operator: "equals",
1885
1885
  value: ""
1886
1886
  }, t = [...v, e];
1887
- x(t), l({
1887
+ y(t), l({
1888
1888
  ...c,
1889
1889
  filters: t
1890
1890
  });
1891
- }, re = (e) => {
1891
+ }, I = (e) => {
1892
1892
  let t = v.filter((t, n) => n !== e);
1893
- x(t), l({
1893
+ y(t), l({
1894
1894
  ...c,
1895
1895
  filters: t
1896
1896
  });
1897
- }, R = (e, t) => {
1897
+ }, L = (e, t) => {
1898
1898
  let n = [...v];
1899
- n[e] = t, x(n), l({
1899
+ n[e] = t, y(n), l({
1900
1900
  ...c,
1901
1901
  filters: n
1902
1902
  });
1903
- }, ie = () => {
1903
+ }, R = () => {
1904
1904
  let e = {
1905
1905
  field: r[0]?.name || "",
1906
1906
  sort: "asc"
1907
- }, t = [...S, e];
1908
- D(t), l({
1907
+ }, t = [...b, e];
1908
+ x(t), l({
1909
1909
  ...c,
1910
1910
  groupBy: t
1911
1911
  });
1912
- }, se = (e) => {
1913
- let t = S.filter((t, n) => n !== e);
1914
- D(t), l({
1912
+ }, z = (e) => {
1913
+ let t = b.filter((t, n) => n !== e);
1914
+ x(t), l({
1915
1915
  ...c,
1916
1916
  groupBy: t
1917
1917
  });
1918
- }, ce = (e, t) => {
1919
- let n = [...S];
1920
- n[e] = t, D(n), l({
1918
+ }, B = (e, t) => {
1919
+ let n = [...b];
1920
+ n[e] = t, x(n), l({
1921
1921
  ...c,
1922
1922
  groupBy: n
1923
1923
  });
1924
- }, B = (e) => {
1924
+ }, V = (e) => {
1925
1925
  let t = {
1926
1926
  type: e,
1927
1927
  title: `New ${e} Section`
1928
- }, n = [...j, t];
1929
- M(n), l({
1928
+ }, n = [...S, t];
1929
+ C(n), l({
1930
1930
  ...c,
1931
1931
  sections: n
1932
1932
  });
1933
- }, V = (e) => {
1934
- let t = j.filter((t, n) => n !== e);
1935
- M(t), l({
1933
+ }, te = (e) => {
1934
+ let t = S.filter((t, n) => n !== e);
1935
+ C(t), l({
1936
1936
  ...c,
1937
1937
  sections: t
1938
1938
  });
1939
1939
  }, H = (e, t) => {
1940
- let n = [...j];
1941
- n[e] = t, M(n), l({
1940
+ let n = [...S];
1941
+ n[e] = t, C(n), l({
1942
1942
  ...c,
1943
1943
  sections: n
1944
1944
  });
1945
1945
  };
1946
- return /* @__PURE__ */ A("div", {
1946
+ return /* @__PURE__ */ F("div", {
1947
1947
  className: "space-y-4",
1948
- children: [/* @__PURE__ */ A(f, { children: [/* @__PURE__ */ A(h, { children: [/* @__PURE__ */ k(g, { children: "Report Builder" }), /* @__PURE__ */ k(m, { children: "Configure your report settings, fields, filters, and sections" })] }), /* @__PURE__ */ A(p, { children: [/* @__PURE__ */ A(C, {
1948
+ children: [/* @__PURE__ */ F(f, { children: [/* @__PURE__ */ F(h, { children: [/* @__PURE__ */ P(g, { children: "Report Builder" }), /* @__PURE__ */ P(m, { children: "Configure your report settings, fields, filters, and sections" })] }), /* @__PURE__ */ F(p, { children: [/* @__PURE__ */ F(k, {
1949
1949
  defaultValue: "basic",
1950
1950
  className: "w-full",
1951
1951
  children: [
1952
- /* @__PURE__ */ A(T, {
1952
+ /* @__PURE__ */ F(j, {
1953
1953
  className: "grid w-full grid-cols-6",
1954
1954
  children: [
1955
- /* @__PURE__ */ A(E, {
1955
+ /* @__PURE__ */ F(M, {
1956
1956
  value: "basic",
1957
- children: [/* @__PURE__ */ k(oe, { className: "h-4 w-4 mr-2" }), "Basic"]
1957
+ children: [/* @__PURE__ */ P(pe, { className: "h-4 w-4 mr-2" }), "Basic"]
1958
1958
  }),
1959
- /* @__PURE__ */ A(E, {
1959
+ /* @__PURE__ */ F(M, {
1960
1960
  value: "fields",
1961
- children: [/* @__PURE__ */ k(ne, { className: "h-4 w-4 mr-2" }), "Fields"]
1961
+ children: [/* @__PURE__ */ P(se, { className: "h-4 w-4 mr-2" }), "Fields"]
1962
1962
  }),
1963
- /* @__PURE__ */ A(E, {
1963
+ /* @__PURE__ */ F(M, {
1964
1964
  value: "filters",
1965
- children: [/* @__PURE__ */ k(te, { className: "h-4 w-4 mr-2" }), "Filters"]
1965
+ children: [/* @__PURE__ */ P(oe, { className: "h-4 w-4 mr-2" }), "Filters"]
1966
1966
  }),
1967
- /* @__PURE__ */ A(E, {
1967
+ /* @__PURE__ */ F(M, {
1968
1968
  value: "grouping",
1969
- children: [/* @__PURE__ */ k(ne, { className: "h-4 w-4 mr-2" }), "Group By"]
1969
+ children: [/* @__PURE__ */ P(se, { className: "h-4 w-4 mr-2" }), "Group By"]
1970
1970
  }),
1971
- /* @__PURE__ */ A(E, {
1971
+ /* @__PURE__ */ F(M, {
1972
1972
  value: "sections",
1973
- children: [/* @__PURE__ */ k(ne, { className: "h-4 w-4 mr-2" }), "Sections"]
1973
+ children: [/* @__PURE__ */ P(se, { className: "h-4 w-4 mr-2" }), "Sections"]
1974
1974
  }),
1975
- /* @__PURE__ */ A(E, {
1975
+ /* @__PURE__ */ F(M, {
1976
1976
  value: "schedule",
1977
- children: [/* @__PURE__ */ k(P, { className: "h-4 w-4 mr-2" }), "Schedule"]
1977
+ children: [/* @__PURE__ */ P(ne, { className: "h-4 w-4 mr-2" }), "Schedule"]
1978
1978
  })
1979
1979
  ]
1980
1980
  }),
1981
- /* @__PURE__ */ k(w, {
1981
+ /* @__PURE__ */ P(A, {
1982
1982
  value: "basic",
1983
1983
  className: "space-y-4 mt-4",
1984
- children: /* @__PURE__ */ A("div", {
1984
+ children: /* @__PURE__ */ F("div", {
1985
1985
  className: "space-y-4",
1986
1986
  children: [
1987
- /* @__PURE__ */ A("div", {
1987
+ /* @__PURE__ */ F("div", {
1988
1988
  className: "space-y-2",
1989
- children: [/* @__PURE__ */ k(b, {
1989
+ children: [/* @__PURE__ */ P(D, {
1990
1990
  htmlFor: "report-title",
1991
1991
  children: "Report Title"
1992
- }), /* @__PURE__ */ k(y, {
1992
+ }), /* @__PURE__ */ P(E, {
1993
1993
  id: "report-title",
1994
1994
  value: c.title || "",
1995
1995
  onChange: (e) => l({
@@ -1999,12 +1999,12 @@ var et = ({ schema: t, onRefresh: r }) => {
1999
1999
  placeholder: "Enter report title"
2000
2000
  })]
2001
2001
  }),
2002
- /* @__PURE__ */ A("div", {
2002
+ /* @__PURE__ */ F("div", {
2003
2003
  className: "space-y-2",
2004
- children: [/* @__PURE__ */ k(b, {
2004
+ children: [/* @__PURE__ */ P(D, {
2005
2005
  htmlFor: "report-description",
2006
2006
  children: "Description"
2007
- }), /* @__PURE__ */ k(y, {
2007
+ }), /* @__PURE__ */ P(E, {
2008
2008
  id: "report-description",
2009
2009
  value: c.description || "",
2010
2010
  onChange: (e) => l({
@@ -2014,58 +2014,58 @@ var et = ({ schema: t, onRefresh: r }) => {
2014
2014
  placeholder: "Enter report description"
2015
2015
  })]
2016
2016
  }),
2017
- n.length > 0 && /* @__PURE__ */ A("div", {
2017
+ n.length > 0 && /* @__PURE__ */ F("div", {
2018
2018
  className: "space-y-2",
2019
- children: [/* @__PURE__ */ k(b, { children: "Data Source" }), /* @__PURE__ */ A("select", {
2019
+ children: [/* @__PURE__ */ P(D, { children: "Data Source" }), /* @__PURE__ */ F("select", {
2020
2020
  className: "w-full border rounded-md p-2",
2021
- children: [/* @__PURE__ */ k("option", {
2021
+ children: [/* @__PURE__ */ P("option", {
2022
2022
  value: "",
2023
2023
  children: "Select a data source"
2024
- }), n.map((e, t) => /* @__PURE__ */ A("option", {
2024
+ }), n.map((e, t) => /* @__PURE__ */ F("option", {
2025
2025
  value: t,
2026
2026
  children: ["Data Source ", t + 1]
2027
2027
  }, t))]
2028
2028
  })]
2029
2029
  }),
2030
- /* @__PURE__ */ A("div", {
2030
+ /* @__PURE__ */ F("div", {
2031
2031
  className: "space-y-2",
2032
- children: [/* @__PURE__ */ k(b, { children: "Export Options" }), /* @__PURE__ */ A("div", {
2032
+ children: [/* @__PURE__ */ P(D, { children: "Export Options" }), /* @__PURE__ */ F("div", {
2033
2033
  className: "flex items-center gap-4",
2034
- children: [/* @__PURE__ */ A("label", {
2034
+ children: [/* @__PURE__ */ F("label", {
2035
2035
  className: "flex items-center gap-2",
2036
- children: [/* @__PURE__ */ k("input", {
2036
+ children: [/* @__PURE__ */ P("input", {
2037
2037
  type: "checkbox",
2038
2038
  checked: c.showExportButtons || !1,
2039
2039
  onChange: (e) => l({
2040
2040
  ...c,
2041
2041
  showExportButtons: e.target.checked
2042
2042
  })
2043
- }), /* @__PURE__ */ k("span", {
2043
+ }), /* @__PURE__ */ P("span", {
2044
2044
  className: "text-sm",
2045
2045
  children: "Show Export Buttons"
2046
2046
  })]
2047
- }), /* @__PURE__ */ A("label", {
2047
+ }), /* @__PURE__ */ F("label", {
2048
2048
  className: "flex items-center gap-2",
2049
- children: [/* @__PURE__ */ k("input", {
2049
+ children: [/* @__PURE__ */ P("input", {
2050
2050
  type: "checkbox",
2051
2051
  checked: c.showPrintButton || !1,
2052
2052
  onChange: (e) => l({
2053
2053
  ...c,
2054
2054
  showPrintButton: e.target.checked
2055
2055
  })
2056
- }), /* @__PURE__ */ k("span", {
2056
+ }), /* @__PURE__ */ P("span", {
2057
2057
  className: "text-sm",
2058
2058
  children: "Show Print Button"
2059
2059
  })]
2060
2060
  })]
2061
2061
  })]
2062
2062
  }),
2063
- /* @__PURE__ */ A("div", {
2063
+ /* @__PURE__ */ F("div", {
2064
2064
  className: "space-y-2",
2065
- children: [/* @__PURE__ */ k(b, {
2065
+ children: [/* @__PURE__ */ P(D, {
2066
2066
  htmlFor: "export-format",
2067
2067
  children: "Default Export Format"
2068
- }), /* @__PURE__ */ A("select", {
2068
+ }), /* @__PURE__ */ F("select", {
2069
2069
  id: "export-format",
2070
2070
  className: "w-full border rounded-md p-2",
2071
2071
  value: c.defaultExportFormat || "pdf",
@@ -2074,23 +2074,23 @@ var et = ({ schema: t, onRefresh: r }) => {
2074
2074
  defaultExportFormat: e.target.value
2075
2075
  }),
2076
2076
  children: [
2077
- /* @__PURE__ */ k("option", {
2077
+ /* @__PURE__ */ P("option", {
2078
2078
  value: "pdf",
2079
2079
  children: "PDF"
2080
2080
  }),
2081
- /* @__PURE__ */ k("option", {
2081
+ /* @__PURE__ */ P("option", {
2082
2082
  value: "excel",
2083
2083
  children: "Excel"
2084
2084
  }),
2085
- /* @__PURE__ */ k("option", {
2085
+ /* @__PURE__ */ P("option", {
2086
2086
  value: "csv",
2087
2087
  children: "CSV"
2088
2088
  }),
2089
- /* @__PURE__ */ k("option", {
2089
+ /* @__PURE__ */ P("option", {
2090
2090
  value: "json",
2091
2091
  children: "JSON"
2092
2092
  }),
2093
- /* @__PURE__ */ k("option", {
2093
+ /* @__PURE__ */ P("option", {
2094
2094
  value: "html",
2095
2095
  children: "HTML"
2096
2096
  })
@@ -2100,305 +2100,305 @@ var et = ({ schema: t, onRefresh: r }) => {
2100
2100
  ]
2101
2101
  })
2102
2102
  }),
2103
- /* @__PURE__ */ A(w, {
2103
+ /* @__PURE__ */ F(A, {
2104
2104
  value: "fields",
2105
2105
  className: "space-y-4 mt-4",
2106
- children: [/* @__PURE__ */ A("div", {
2106
+ children: [/* @__PURE__ */ F("div", {
2107
2107
  className: "flex items-center justify-between",
2108
- children: [/* @__PURE__ */ k(b, { children: "Report Fields" }), /* @__PURE__ */ A(d, {
2108
+ children: [/* @__PURE__ */ P(D, { children: "Report Fields" }), /* @__PURE__ */ F(d, {
2109
2109
  size: "sm",
2110
2110
  variant: "outline",
2111
- onClick: ee,
2111
+ onClick: w,
2112
2112
  disabled: u.length >= r.length,
2113
- children: [/* @__PURE__ */ k(L, { className: "h-4 w-4 mr-2" }), "Add Field"]
2113
+ children: [/* @__PURE__ */ P(U, { className: "h-4 w-4 mr-2" }), "Add Field"]
2114
2114
  })]
2115
- }), /* @__PURE__ */ A("div", {
2115
+ }), /* @__PURE__ */ F("div", {
2116
2116
  className: "space-y-2",
2117
- children: [u.map((e, t) => /* @__PURE__ */ k("div", {
2117
+ children: [u.map((e, t) => /* @__PURE__ */ P("div", {
2118
2118
  className: "flex items-center gap-2 p-3 border rounded-lg",
2119
- children: /* @__PURE__ */ A("div", {
2119
+ children: /* @__PURE__ */ F("div", {
2120
2120
  className: "flex-1 grid grid-cols-4 gap-2",
2121
2121
  children: [
2122
- /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2122
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2123
2123
  className: "text-xs",
2124
2124
  children: "Field Name"
2125
- }), /* @__PURE__ */ k("div", {
2125
+ }), /* @__PURE__ */ P("div", {
2126
2126
  className: "text-sm font-medium",
2127
2127
  children: e.name
2128
2128
  })] }),
2129
- /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2129
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2130
2130
  className: "text-xs",
2131
2131
  children: "Label"
2132
- }), /* @__PURE__ */ k(y, {
2132
+ }), /* @__PURE__ */ P(E, {
2133
2133
  className: "h-8 text-sm",
2134
2134
  value: e.label || e.name,
2135
- onChange: (n) => F(t, {
2135
+ onChange: (n) => O(t, {
2136
2136
  ...e,
2137
2137
  label: n.target.value
2138
2138
  })
2139
2139
  })] }),
2140
- /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2140
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2141
2141
  className: "text-xs",
2142
2142
  children: "Aggregation"
2143
- }), /* @__PURE__ */ A("select", {
2143
+ }), /* @__PURE__ */ F("select", {
2144
2144
  className: "w-full border rounded-md h-8 text-sm px-2",
2145
2145
  value: e.aggregation || "",
2146
- onChange: (n) => F(t, {
2146
+ onChange: (n) => O(t, {
2147
2147
  ...e,
2148
2148
  aggregation: n.target.value
2149
2149
  }),
2150
2150
  children: [
2151
- /* @__PURE__ */ k("option", {
2151
+ /* @__PURE__ */ P("option", {
2152
2152
  value: "",
2153
2153
  children: "None"
2154
2154
  }),
2155
- /* @__PURE__ */ k("option", {
2155
+ /* @__PURE__ */ P("option", {
2156
2156
  value: "sum",
2157
2157
  children: "Sum"
2158
2158
  }),
2159
- /* @__PURE__ */ k("option", {
2159
+ /* @__PURE__ */ P("option", {
2160
2160
  value: "count",
2161
2161
  children: "Count"
2162
2162
  }),
2163
- /* @__PURE__ */ k("option", {
2163
+ /* @__PURE__ */ P("option", {
2164
2164
  value: "avg",
2165
2165
  children: "Average"
2166
2166
  }),
2167
- /* @__PURE__ */ k("option", {
2167
+ /* @__PURE__ */ P("option", {
2168
2168
  value: "min",
2169
2169
  children: "Min"
2170
2170
  }),
2171
- /* @__PURE__ */ k("option", {
2171
+ /* @__PURE__ */ P("option", {
2172
2172
  value: "max",
2173
2173
  children: "Max"
2174
2174
  })
2175
2175
  ]
2176
2176
  })] }),
2177
- /* @__PURE__ */ k("div", {
2177
+ /* @__PURE__ */ P("div", {
2178
2178
  className: "flex items-end justify-end",
2179
- children: /* @__PURE__ */ k(d, {
2179
+ children: /* @__PURE__ */ P(d, {
2180
2180
  size: "sm",
2181
2181
  variant: "ghost",
2182
2182
  className: "text-red-500 hover:text-red-700 hover:bg-red-50",
2183
- onClick: () => N(t),
2184
- children: /* @__PURE__ */ k(z, { className: "h-4 w-4" })
2183
+ onClick: () => T(t),
2184
+ children: /* @__PURE__ */ P(W, { className: "h-4 w-4" })
2185
2185
  })
2186
2186
  })
2187
2187
  ]
2188
2188
  })
2189
- }, t)), u.length === 0 && /* @__PURE__ */ k("div", {
2189
+ }, t)), u.length === 0 && /* @__PURE__ */ P("div", {
2190
2190
  className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",
2191
2191
  children: "No fields selected. Click \"Add Field\" to begin."
2192
2192
  })]
2193
2193
  })]
2194
2194
  }),
2195
- /* @__PURE__ */ A(w, {
2195
+ /* @__PURE__ */ F(A, {
2196
2196
  value: "filters",
2197
2197
  className: "space-y-4 mt-4",
2198
- children: [/* @__PURE__ */ A("div", {
2198
+ children: [/* @__PURE__ */ F("div", {
2199
2199
  className: "flex items-center justify-between",
2200
- children: [/* @__PURE__ */ k(b, { children: "Report Filters" }), /* @__PURE__ */ A(d, {
2200
+ children: [/* @__PURE__ */ P(D, { children: "Report Filters" }), /* @__PURE__ */ F(d, {
2201
2201
  size: "sm",
2202
2202
  variant: "outline",
2203
- onClick: I,
2204
- children: [/* @__PURE__ */ k(L, { className: "h-4 w-4 mr-2" }), "Add Filter"]
2203
+ onClick: ee,
2204
+ children: [/* @__PURE__ */ P(U, { className: "h-4 w-4 mr-2" }), "Add Filter"]
2205
2205
  })]
2206
- }), /* @__PURE__ */ A("div", {
2206
+ }), /* @__PURE__ */ F("div", {
2207
2207
  className: "space-y-2",
2208
- children: [v.map((e, t) => /* @__PURE__ */ A("div", {
2208
+ children: [v.map((e, t) => /* @__PURE__ */ F("div", {
2209
2209
  className: "flex items-center gap-2 p-3 border rounded-lg",
2210
- children: [/* @__PURE__ */ A("div", {
2210
+ children: [/* @__PURE__ */ F("div", {
2211
2211
  className: "flex-1 grid grid-cols-3 gap-2",
2212
2212
  children: [
2213
- /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2213
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2214
2214
  className: "text-xs",
2215
2215
  children: "Field"
2216
- }), /* @__PURE__ */ k("select", {
2216
+ }), /* @__PURE__ */ P("select", {
2217
2217
  className: "w-full border rounded-md h-8 text-sm px-2",
2218
2218
  value: e.field,
2219
- onChange: (n) => R(t, {
2219
+ onChange: (n) => L(t, {
2220
2220
  ...e,
2221
2221
  field: n.target.value
2222
2222
  }),
2223
- children: r.map((e, t) => /* @__PURE__ */ k("option", {
2223
+ children: r.map((e, t) => /* @__PURE__ */ P("option", {
2224
2224
  value: e.name,
2225
2225
  children: e.label || e.name
2226
2226
  }, t))
2227
2227
  })] }),
2228
- /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2228
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2229
2229
  className: "text-xs",
2230
2230
  children: "Operator"
2231
- }), /* @__PURE__ */ A("select", {
2231
+ }), /* @__PURE__ */ F("select", {
2232
2232
  className: "w-full border rounded-md h-8 text-sm px-2",
2233
2233
  value: e.operator,
2234
- onChange: (n) => R(t, {
2234
+ onChange: (n) => L(t, {
2235
2235
  ...e,
2236
2236
  operator: n.target.value
2237
2237
  }),
2238
2238
  children: [
2239
- /* @__PURE__ */ k("option", {
2239
+ /* @__PURE__ */ P("option", {
2240
2240
  value: "equals",
2241
2241
  children: "Equals"
2242
2242
  }),
2243
- /* @__PURE__ */ k("option", {
2243
+ /* @__PURE__ */ P("option", {
2244
2244
  value: "contains",
2245
2245
  children: "Contains"
2246
2246
  }),
2247
- /* @__PURE__ */ k("option", {
2247
+ /* @__PURE__ */ P("option", {
2248
2248
  value: "gt",
2249
2249
  children: "Greater Than"
2250
2250
  }),
2251
- /* @__PURE__ */ k("option", {
2251
+ /* @__PURE__ */ P("option", {
2252
2252
  value: "lt",
2253
2253
  children: "Less Than"
2254
2254
  }),
2255
- /* @__PURE__ */ k("option", {
2255
+ /* @__PURE__ */ P("option", {
2256
2256
  value: "between",
2257
2257
  children: "Between"
2258
2258
  })
2259
2259
  ]
2260
2260
  })] }),
2261
- /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2261
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2262
2262
  className: "text-xs",
2263
2263
  children: "Value"
2264
- }), /* @__PURE__ */ k(y, {
2264
+ }), /* @__PURE__ */ P(E, {
2265
2265
  className: "h-8 text-sm",
2266
2266
  value: String(e.value),
2267
- onChange: (n) => R(t, {
2267
+ onChange: (n) => L(t, {
2268
2268
  ...e,
2269
2269
  value: n.target.value
2270
2270
  })
2271
2271
  })] })
2272
2272
  ]
2273
- }), /* @__PURE__ */ k(d, {
2273
+ }), /* @__PURE__ */ P(d, {
2274
2274
  size: "sm",
2275
2275
  variant: "ghost",
2276
2276
  className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
2277
- onClick: () => re(t),
2278
- children: /* @__PURE__ */ k(z, { className: "h-4 w-4" })
2277
+ onClick: () => I(t),
2278
+ children: /* @__PURE__ */ P(W, { className: "h-4 w-4" })
2279
2279
  })]
2280
- }, t)), v.length === 0 && /* @__PURE__ */ k("div", {
2280
+ }, t)), v.length === 0 && /* @__PURE__ */ P("div", {
2281
2281
  className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",
2282
2282
  children: "No filters defined."
2283
2283
  })]
2284
2284
  })]
2285
2285
  }),
2286
- /* @__PURE__ */ A(w, {
2286
+ /* @__PURE__ */ F(A, {
2287
2287
  value: "grouping",
2288
2288
  className: "space-y-4 mt-4",
2289
- children: [/* @__PURE__ */ A("div", {
2289
+ children: [/* @__PURE__ */ F("div", {
2290
2290
  className: "flex items-center justify-between",
2291
- children: [/* @__PURE__ */ k(b, { children: "Grouping Rules" }), /* @__PURE__ */ A(d, {
2291
+ children: [/* @__PURE__ */ P(D, { children: "Grouping Rules" }), /* @__PURE__ */ F(d, {
2292
2292
  size: "sm",
2293
2293
  variant: "outline",
2294
- onClick: ie,
2295
- children: [/* @__PURE__ */ k(L, { className: "h-4 w-4 mr-2" }), "Add Group"]
2294
+ onClick: R,
2295
+ children: [/* @__PURE__ */ P(U, { className: "h-4 w-4 mr-2" }), "Add Group"]
2296
2296
  })]
2297
- }), /* @__PURE__ */ A("div", {
2297
+ }), /* @__PURE__ */ F("div", {
2298
2298
  className: "space-y-2",
2299
- children: [S.map((e, t) => /* @__PURE__ */ A("div", {
2299
+ children: [b.map((e, t) => /* @__PURE__ */ F("div", {
2300
2300
  className: "flex items-center gap-2 p-3 border rounded-lg",
2301
- children: [/* @__PURE__ */ A("div", {
2301
+ children: [/* @__PURE__ */ F("div", {
2302
2302
  className: "flex-1 grid grid-cols-2 gap-2",
2303
- children: [/* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2303
+ children: [/* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2304
2304
  className: "text-xs",
2305
2305
  children: "Field"
2306
- }), /* @__PURE__ */ k("select", {
2306
+ }), /* @__PURE__ */ P("select", {
2307
2307
  className: "w-full border rounded-md h-8 text-sm px-2",
2308
2308
  value: e.field,
2309
- onChange: (n) => ce(t, {
2309
+ onChange: (n) => B(t, {
2310
2310
  ...e,
2311
2311
  field: n.target.value
2312
2312
  }),
2313
- children: r.map((e, t) => /* @__PURE__ */ k("option", {
2313
+ children: r.map((e, t) => /* @__PURE__ */ P("option", {
2314
2314
  value: e.name,
2315
2315
  children: e.label || e.name
2316
2316
  }, t))
2317
- })] }), /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2317
+ })] }), /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2318
2318
  className: "text-xs",
2319
2319
  children: "Sort Order"
2320
- }), /* @__PURE__ */ A("select", {
2320
+ }), /* @__PURE__ */ F("select", {
2321
2321
  className: "w-full border rounded-md h-8 text-sm px-2",
2322
2322
  value: e.sort || "asc",
2323
- onChange: (n) => ce(t, {
2323
+ onChange: (n) => B(t, {
2324
2324
  ...e,
2325
2325
  sort: n.target.value
2326
2326
  }),
2327
- children: [/* @__PURE__ */ k("option", {
2327
+ children: [/* @__PURE__ */ P("option", {
2328
2328
  value: "asc",
2329
2329
  children: "Ascending"
2330
- }), /* @__PURE__ */ k("option", {
2330
+ }), /* @__PURE__ */ P("option", {
2331
2331
  value: "desc",
2332
2332
  children: "Descending"
2333
2333
  })]
2334
2334
  })] })]
2335
- }), /* @__PURE__ */ k(d, {
2335
+ }), /* @__PURE__ */ P(d, {
2336
2336
  size: "sm",
2337
2337
  variant: "ghost",
2338
2338
  className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
2339
- onClick: () => se(t),
2340
- children: /* @__PURE__ */ k(z, { className: "h-4 w-4" })
2339
+ onClick: () => z(t),
2340
+ children: /* @__PURE__ */ P(W, { className: "h-4 w-4" })
2341
2341
  })]
2342
- }, t)), S.length === 0 && /* @__PURE__ */ k("div", {
2342
+ }, t)), b.length === 0 && /* @__PURE__ */ P("div", {
2343
2343
  className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",
2344
2344
  children: "No grouping rules applied."
2345
2345
  })]
2346
2346
  })]
2347
2347
  }),
2348
- /* @__PURE__ */ A(w, {
2348
+ /* @__PURE__ */ F(A, {
2349
2349
  value: "sections",
2350
2350
  className: "space-y-4 mt-4",
2351
- children: [/* @__PURE__ */ A("div", {
2351
+ children: [/* @__PURE__ */ F("div", {
2352
2352
  className: "flex items-center justify-between",
2353
- children: [/* @__PURE__ */ k(b, { children: "Report Sections" }), /* @__PURE__ */ A("div", {
2353
+ children: [/* @__PURE__ */ P(D, { children: "Report Sections" }), /* @__PURE__ */ F("div", {
2354
2354
  className: "flex gap-2",
2355
2355
  children: [
2356
- /* @__PURE__ */ A(d, {
2356
+ /* @__PURE__ */ F(d, {
2357
2357
  size: "sm",
2358
2358
  variant: "outline",
2359
- onClick: () => B("header"),
2360
- children: [/* @__PURE__ */ k(L, { className: "h-4 w-4 mr-2" }), "Header"]
2359
+ onClick: () => V("header"),
2360
+ children: [/* @__PURE__ */ P(U, { className: "h-4 w-4 mr-2" }), "Header"]
2361
2361
  }),
2362
- /* @__PURE__ */ A(d, {
2362
+ /* @__PURE__ */ F(d, {
2363
2363
  size: "sm",
2364
2364
  variant: "outline",
2365
- onClick: () => B("chart"),
2366
- children: [/* @__PURE__ */ k(L, { className: "h-4 w-4 mr-2" }), "Chart"]
2365
+ onClick: () => V("chart"),
2366
+ children: [/* @__PURE__ */ P(U, { className: "h-4 w-4 mr-2" }), "Chart"]
2367
2367
  }),
2368
- /* @__PURE__ */ A(d, {
2368
+ /* @__PURE__ */ F(d, {
2369
2369
  size: "sm",
2370
2370
  variant: "outline",
2371
- onClick: () => B("table"),
2372
- children: [/* @__PURE__ */ k(L, { className: "h-4 w-4 mr-2" }), "Table"]
2371
+ onClick: () => V("table"),
2372
+ children: [/* @__PURE__ */ P(U, { className: "h-4 w-4 mr-2" }), "Table"]
2373
2373
  })
2374
2374
  ]
2375
2375
  })]
2376
- }), /* @__PURE__ */ A("div", {
2376
+ }), /* @__PURE__ */ F("div", {
2377
2377
  className: "space-y-2",
2378
- children: [j.map((e, t) => /* @__PURE__ */ A("div", {
2378
+ children: [S.map((e, t) => /* @__PURE__ */ F("div", {
2379
2379
  className: "p-3 border rounded-lg space-y-2",
2380
- children: [/* @__PURE__ */ A("div", {
2380
+ children: [/* @__PURE__ */ F("div", {
2381
2381
  className: "flex items-center justify-between",
2382
- children: [/* @__PURE__ */ A("div", {
2382
+ children: [/* @__PURE__ */ F("div", {
2383
2383
  className: "font-medium flex items-center gap-2",
2384
- children: [/* @__PURE__ */ k("div", {
2384
+ children: [/* @__PURE__ */ P("div", {
2385
2385
  className: "text-xs bg-muted px-2 py-0.5 rounded uppercase",
2386
2386
  children: e.type
2387
2387
  }), e.title]
2388
- }), /* @__PURE__ */ k(d, {
2388
+ }), /* @__PURE__ */ P(d, {
2389
2389
  size: "sm",
2390
2390
  variant: "ghost",
2391
2391
  className: "text-red-500 hover:text-red-700 hover:bg-red-50",
2392
- onClick: () => V(t),
2393
- children: /* @__PURE__ */ k(z, { className: "h-4 w-4" })
2392
+ onClick: () => te(t),
2393
+ children: /* @__PURE__ */ P(W, { className: "h-4 w-4" })
2394
2394
  })]
2395
- }), /* @__PURE__ */ A("div", {
2395
+ }), /* @__PURE__ */ F("div", {
2396
2396
  className: "grid grid-cols-2 gap-2",
2397
2397
  children: [
2398
- /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2398
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2399
2399
  className: "text-xs",
2400
2400
  children: "Title"
2401
- }), /* @__PURE__ */ k(y, {
2401
+ }), /* @__PURE__ */ P(E, {
2402
2402
  className: "h-8 text-sm",
2403
2403
  value: e.title || "",
2404
2404
  onChange: (n) => H(t, {
@@ -2406,12 +2406,12 @@ var et = ({ schema: t, onRefresh: r }) => {
2406
2406
  title: n.target.value
2407
2407
  })
2408
2408
  })] }),
2409
- e.type === "text" && /* @__PURE__ */ A("div", {
2409
+ e.type === "text" && /* @__PURE__ */ F("div", {
2410
2410
  className: "col-span-2",
2411
- children: [/* @__PURE__ */ k(b, {
2411
+ children: [/* @__PURE__ */ P(D, {
2412
2412
  className: "text-xs",
2413
2413
  children: "Content"
2414
- }), /* @__PURE__ */ k(y, {
2414
+ }), /* @__PURE__ */ P(E, {
2415
2415
  className: "h-8 text-sm",
2416
2416
  value: e.text || "",
2417
2417
  onChange: (n) => H(t, {
@@ -2420,20 +2420,20 @@ var et = ({ schema: t, onRefresh: r }) => {
2420
2420
  })
2421
2421
  })]
2422
2422
  }),
2423
- e.type === "chart" && /* @__PURE__ */ A("div", {
2423
+ e.type === "chart" && /* @__PURE__ */ F("div", {
2424
2424
  className: "col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded",
2425
2425
  children: [
2426
- /* @__PURE__ */ k("div", {
2426
+ /* @__PURE__ */ P("div", {
2427
2427
  className: "col-span-2",
2428
- children: /* @__PURE__ */ k(b, {
2428
+ children: /* @__PURE__ */ P(D, {
2429
2429
  className: "text-xs font-semibold",
2430
2430
  children: "Chart Configuration"
2431
2431
  })
2432
2432
  }),
2433
- /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2433
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2434
2434
  className: "text-xs",
2435
2435
  children: "Chart Type"
2436
- }), /* @__PURE__ */ A("select", {
2436
+ }), /* @__PURE__ */ F("select", {
2437
2437
  className: "flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2438
2438
  value: e.chart?.chartType || "bar",
2439
2439
  onChange: (n) => H(t, {
@@ -2445,28 +2445,28 @@ var et = ({ schema: t, onRefresh: r }) => {
2445
2445
  }
2446
2446
  }),
2447
2447
  children: [
2448
- /* @__PURE__ */ k("option", {
2448
+ /* @__PURE__ */ P("option", {
2449
2449
  value: "bar",
2450
2450
  children: "Bar"
2451
2451
  }),
2452
- /* @__PURE__ */ k("option", {
2452
+ /* @__PURE__ */ P("option", {
2453
2453
  value: "line",
2454
2454
  children: "Line"
2455
2455
  }),
2456
- /* @__PURE__ */ k("option", {
2456
+ /* @__PURE__ */ P("option", {
2457
2457
  value: "area",
2458
2458
  children: "Area"
2459
2459
  }),
2460
- /* @__PURE__ */ k("option", {
2460
+ /* @__PURE__ */ P("option", {
2461
2461
  value: "pie",
2462
2462
  children: "Pie"
2463
2463
  })
2464
2464
  ]
2465
2465
  })] }),
2466
- /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k(b, {
2466
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P(D, {
2467
2467
  className: "text-xs",
2468
2468
  children: "X-Axis Field"
2469
- }), /* @__PURE__ */ A("select", {
2469
+ }), /* @__PURE__ */ F("select", {
2470
2470
  className: "flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2471
2471
  value: e.chart?.xAxisField || "",
2472
2472
  onChange: (n) => H(t, {
@@ -2478,29 +2478,29 @@ var et = ({ schema: t, onRefresh: r }) => {
2478
2478
  }
2479
2479
  }),
2480
2480
  children: [
2481
- /* @__PURE__ */ k("option", {
2481
+ /* @__PURE__ */ P("option", {
2482
2482
  value: "",
2483
2483
  children: "Select Field..."
2484
2484
  }),
2485
- r.map((e) => /* @__PURE__ */ k("option", {
2485
+ r.map((e) => /* @__PURE__ */ P("option", {
2486
2486
  value: e.name,
2487
2487
  children: e.label || e.name
2488
2488
  }, e.name)),
2489
- r.length === 0 && /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k("option", {
2489
+ r.length === 0 && /* @__PURE__ */ F(N, { children: [/* @__PURE__ */ P("option", {
2490
2490
  value: "name",
2491
2491
  children: "Name"
2492
- }), /* @__PURE__ */ k("option", {
2492
+ }), /* @__PURE__ */ P("option", {
2493
2493
  value: "month",
2494
2494
  children: "Month"
2495
2495
  })] })
2496
2496
  ]
2497
2497
  })] }),
2498
- /* @__PURE__ */ A("div", {
2498
+ /* @__PURE__ */ F("div", {
2499
2499
  className: "col-span-2",
2500
- children: [/* @__PURE__ */ k(b, {
2500
+ children: [/* @__PURE__ */ P(D, {
2501
2501
  className: "text-xs",
2502
2502
  children: "Y-Axis Fields (comma separated)"
2503
- }), /* @__PURE__ */ k(y, {
2503
+ }), /* @__PURE__ */ P(E, {
2504
2504
  className: "h-8 text-sm",
2505
2505
  placeholder: "e.g. value, count",
2506
2506
  value: e.chart?.yAxisFields?.join(", ") || "",
@@ -2518,16 +2518,16 @@ var et = ({ schema: t, onRefresh: r }) => {
2518
2518
  })
2519
2519
  ]
2520
2520
  })]
2521
- }, t)), j.length === 0 && /* @__PURE__ */ k("div", {
2521
+ }, t)), S.length === 0 && /* @__PURE__ */ P("div", {
2522
2522
  className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",
2523
2523
  children: "No customized sections. The default report layout will be used."
2524
2524
  })]
2525
2525
  })]
2526
2526
  }),
2527
- /* @__PURE__ */ k(w, {
2527
+ /* @__PURE__ */ P(A, {
2528
2528
  value: "schedule",
2529
2529
  className: "space-y-4 mt-4",
2530
- children: /* @__PURE__ */ k(tt, {
2530
+ children: /* @__PURE__ */ P(mt, {
2531
2531
  schedule: c.schedule,
2532
2532
  onChange: (e) => l({
2533
2533
  ...c,
@@ -2536,38 +2536,38 @@ var et = ({ schema: t, onRefresh: r }) => {
2536
2536
  })
2537
2537
  })
2538
2538
  ]
2539
- }), /* @__PURE__ */ A("div", {
2539
+ }), /* @__PURE__ */ F("div", {
2540
2540
  className: "flex items-center justify-end gap-2 mt-6 pt-4 border-t",
2541
- children: [/* @__PURE__ */ k(d, {
2541
+ children: [/* @__PURE__ */ P(d, {
2542
2542
  variant: "outline",
2543
2543
  onClick: () => {
2544
2544
  o && console.log("Report cancelled:", o);
2545
2545
  },
2546
2546
  children: "Cancel"
2547
- }), /* @__PURE__ */ A(d, {
2547
+ }), /* @__PURE__ */ F(d, {
2548
2548
  onClick: () => {
2549
2549
  console.log("Saving report:", c), a && alert("Report saved! (Handler: " + a + ")");
2550
2550
  },
2551
- children: [/* @__PURE__ */ k(ae, { className: "h-4 w-4 mr-2" }), "Save Report"]
2551
+ children: [/* @__PURE__ */ P(de, { className: "h-4 w-4 mr-2" }), "Save Report"]
2552
2552
  })]
2553
- })] })] }), i && /* @__PURE__ */ A(f, {
2553
+ })] })] }), i && /* @__PURE__ */ F(f, {
2554
2554
  className: "mt-8 border-2 border-blue-100",
2555
- children: [/* @__PURE__ */ k(h, {
2555
+ children: [/* @__PURE__ */ P(h, {
2556
2556
  className: "bg-blue-50/50",
2557
- children: /* @__PURE__ */ k(g, {
2557
+ children: /* @__PURE__ */ P(g, {
2558
2558
  className: "text-blue-900 text-sm uppercase tracking-wide",
2559
2559
  children: "Live Preview"
2560
2560
  })
2561
- }), /* @__PURE__ */ k(p, {
2561
+ }), /* @__PURE__ */ P(p, {
2562
2562
  className: "pt-6",
2563
- children: /* @__PURE__ */ k(et, { schema: {
2563
+ children: /* @__PURE__ */ P(pt, { schema: {
2564
2564
  type: "report-viewer",
2565
2565
  report: {
2566
2566
  ...c,
2567
2567
  fields: u,
2568
2568
  filters: v,
2569
- groupBy: S,
2570
- sections: j
2569
+ groupBy: b,
2570
+ sections: S
2571
2571
  },
2572
2572
  data: [
2573
2573
  {
@@ -2593,676 +2593,1478 @@ var et = ({ schema: t, onRefresh: r }) => {
2593
2593
  })]
2594
2594
  })]
2595
2595
  });
2596
- }, rt = [
2597
- {
2598
- value: "",
2599
- label: "None"
2600
- },
2601
- {
2602
- value: "sum",
2603
- label: "Sum"
2604
- },
2605
- {
2606
- value: "count",
2607
- label: "Count"
2608
- },
2609
- {
2610
- value: "avg",
2611
- label: "Average"
2612
- },
2613
- {
2614
- value: "min",
2615
- label: "Min"
2616
- },
2617
- {
2618
- value: "max",
2619
- label: "Max"
2620
- }
2596
+ }, gt = [
2597
+ "tabular",
2598
+ "summary",
2599
+ "matrix"
2621
2600
  ];
2622
- function it({ availableFields: e, value: t, onChange: n }) {
2623
- let r = Array.isArray(t) ? t.map((e) => typeof e == "string" ? {
2601
+ function _t(e) {
2602
+ let t = e.length + 1, n = new Set(e.map((e) => e.name).filter(Boolean)), r = `block_${t}`;
2603
+ for (; n.has(r);) t += 1, r = `block_${t}`;
2604
+ return {
2605
+ name: r,
2606
+ type: "tabular",
2607
+ columns: []
2608
+ };
2609
+ }
2610
+ function vt(e) {
2611
+ return typeof e.label == "string" ? e.label : e.label && typeof e.label == "object" ? e.label.default ?? "" : "";
2612
+ }
2613
+ function yt(e) {
2614
+ return typeof e.description == "string" ? e.description : e.description && typeof e.description == "object" ? e.description.default ?? "" : "";
2615
+ }
2616
+ function bt({ block: e, index: n, total: r, availableFields: i, t: a, duplicateName: o, onChange: s, onRemove: c, onMove: l }) {
2617
+ let [u, f] = t.useState(n === 0), p = e.type ?? "tabular", m = p === "summary", h = p === "matrix", g = m || h, _ = !e.name || !e.name.trim(), v = _ || o, y = (t) => s({
2618
+ ...e,
2619
+ ...t
2620
+ });
2621
+ return /* @__PURE__ */ F("div", {
2622
+ className: "border rounded-md bg-card text-card-foreground",
2623
+ "data-testid": `joined-block-${n}`,
2624
+ children: [
2625
+ /* @__PURE__ */ F("div", {
2626
+ className: "flex items-center gap-1 p-1.5 border-b bg-muted/30",
2627
+ children: [
2628
+ /* @__PURE__ */ P(d, {
2629
+ type: "button",
2630
+ size: "sm",
2631
+ variant: "ghost",
2632
+ className: "h-6 w-6 p-0 shrink-0",
2633
+ onClick: () => f((e) => !e),
2634
+ "aria-label": u ? "Collapse block" : "Expand block",
2635
+ "aria-expanded": u,
2636
+ "data-testid": `joined-block-toggle-${n}`,
2637
+ children: P(u ? H : re, { className: "h-3.5 w-3.5" })
2638
+ }),
2639
+ /* @__PURE__ */ P("input", {
2640
+ type: "text",
2641
+ className: `h-6 text-xs border rounded px-1.5 bg-background flex-1 min-w-0 ${v ? "border-destructive" : ""}`,
2642
+ value: e.name ?? "",
2643
+ onChange: (e) => y({ name: e.target.value }),
2644
+ placeholder: a("report.editor.blockNamePlaceholder"),
2645
+ "aria-label": a("report.editor.blockName"),
2646
+ "aria-invalid": v,
2647
+ "data-testid": `joined-block-name-${n}`
2648
+ }),
2649
+ /* @__PURE__ */ P("select", {
2650
+ className: "h-6 text-xs border rounded px-1 bg-background shrink-0",
2651
+ value: p,
2652
+ onChange: (e) => y({ type: e.target.value }),
2653
+ "aria-label": a("report.editor.type"),
2654
+ "data-testid": `joined-block-type-${n}`,
2655
+ children: gt.map((e) => /* @__PURE__ */ P("option", {
2656
+ value: e,
2657
+ children: a(`report.editor.type${e.charAt(0).toUpperCase()}${e.slice(1)}`)
2658
+ }, e))
2659
+ }),
2660
+ /* @__PURE__ */ F("div", {
2661
+ className: "flex flex-col gap-0.5 shrink-0",
2662
+ children: [/* @__PURE__ */ P("button", {
2663
+ type: "button",
2664
+ className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
2665
+ disabled: n === 0,
2666
+ onClick: () => l(-1),
2667
+ "aria-label": "Move block up",
2668
+ children: /* @__PURE__ */ P(te, { className: "h-2.5 w-2.5" })
2669
+ }), /* @__PURE__ */ P("button", {
2670
+ type: "button",
2671
+ className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
2672
+ disabled: n === r - 1,
2673
+ onClick: () => l(1),
2674
+ "aria-label": "Move block down",
2675
+ children: /* @__PURE__ */ P(V, { className: "h-2.5 w-2.5" })
2676
+ })]
2677
+ }),
2678
+ /* @__PURE__ */ P(d, {
2679
+ type: "button",
2680
+ size: "sm",
2681
+ variant: "ghost",
2682
+ className: "h-6 w-6 p-0 shrink-0 text-destructive hover:text-destructive",
2683
+ onClick: c,
2684
+ "aria-label": a("report.editor.removeBlock"),
2685
+ "data-testid": `joined-block-remove-${n}`,
2686
+ children: /* @__PURE__ */ P(W, { className: "h-3 w-3" })
2687
+ })
2688
+ ]
2689
+ }),
2690
+ v && /* @__PURE__ */ F("div", {
2691
+ className: "flex items-center gap-1 px-2 py-1 text-[10px] text-destructive bg-destructive/5 border-b",
2692
+ children: [/* @__PURE__ */ P(B, { className: "h-3 w-3" }), a(_ ? "report.editor.validationBlockNameRequired" : "report.editor.validationBlockNameDuplicate")]
2693
+ }),
2694
+ u && /* @__PURE__ */ F("div", {
2695
+ className: "p-2 space-y-2 text-xs",
2696
+ children: [
2697
+ /* @__PURE__ */ F("div", {
2698
+ className: "grid grid-cols-2 gap-2",
2699
+ children: [/* @__PURE__ */ F("label", {
2700
+ className: "flex flex-col gap-0.5",
2701
+ children: [/* @__PURE__ */ P("span", {
2702
+ className: "text-[10px] text-muted-foreground",
2703
+ children: a("report.editor.blockLabel")
2704
+ }), /* @__PURE__ */ P("input", {
2705
+ type: "text",
2706
+ className: "h-6 text-xs border rounded px-1.5 bg-background",
2707
+ value: vt(e),
2708
+ onChange: (e) => y({ label: e.target.value || void 0 }),
2709
+ placeholder: a("report.editor.blockLabelPlaceholder"),
2710
+ "data-testid": `joined-block-label-${n}`
2711
+ })]
2712
+ }), /* @__PURE__ */ F("label", {
2713
+ className: "flex flex-col gap-0.5",
2714
+ children: [/* @__PURE__ */ P("span", {
2715
+ className: "text-[10px] text-muted-foreground",
2716
+ children: a("report.editor.objectName")
2717
+ }), /* @__PURE__ */ P("input", {
2718
+ type: "text",
2719
+ className: "h-6 text-xs border rounded px-1.5 bg-background",
2720
+ value: e.objectName ?? "",
2721
+ onChange: (e) => y({ objectName: e.target.value || void 0 }),
2722
+ placeholder: a("report.editor.objectNamePlaceholder"),
2723
+ "data-testid": `joined-block-object-${n}`
2724
+ })]
2725
+ })]
2726
+ }),
2727
+ /* @__PURE__ */ F("label", {
2728
+ className: "flex flex-col gap-0.5",
2729
+ children: [/* @__PURE__ */ P("span", {
2730
+ className: "text-[10px] text-muted-foreground",
2731
+ children: a("report.editor.blockDescription")
2732
+ }), /* @__PURE__ */ P("textarea", {
2733
+ className: "text-xs border rounded px-1.5 py-1 bg-background resize-y min-h-[2rem]",
2734
+ rows: 2,
2735
+ value: yt(e),
2736
+ onChange: (e) => y({ description: e.target.value || void 0 }),
2737
+ placeholder: a("report.editor.blockDescriptionPlaceholder"),
2738
+ "data-testid": `joined-block-description-${n}`
2739
+ })]
2740
+ }),
2741
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("div", {
2742
+ className: "text-[10px] text-muted-foreground mb-0.5",
2743
+ children: a("report.editor.columns")
2744
+ }), /* @__PURE__ */ P(zt, {
2745
+ availableFields: i,
2746
+ value: e.columns,
2747
+ onChange: (e) => y({ columns: e }),
2748
+ t: a
2749
+ })] }),
2750
+ (m || h) && /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("div", {
2751
+ className: "text-[10px] text-muted-foreground mb-0.5",
2752
+ children: a("report.editor.rows")
2753
+ }), /* @__PURE__ */ P(Bt, {
2754
+ availableFields: i,
2755
+ value: e.groupingsDown,
2756
+ onChange: (e) => y({ groupingsDown: e }),
2757
+ t: a
2758
+ })] }),
2759
+ h && /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("div", {
2760
+ className: "text-[10px] text-muted-foreground mb-0.5",
2761
+ children: a("report.editor.columnsAxis")
2762
+ }), /* @__PURE__ */ P(Bt, {
2763
+ availableFields: i,
2764
+ value: e.groupingsAcross,
2765
+ onChange: (e) => y({ groupingsAcross: e }),
2766
+ t: a
2767
+ })] }),
2768
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("div", {
2769
+ className: "text-[10px] text-muted-foreground mb-0.5",
2770
+ children: a("report.editor.filters")
2771
+ }), /* @__PURE__ */ P(Mt, {
2772
+ availableFields: i,
2773
+ value: e.filter,
2774
+ onChange: (e) => y({ filter: e }),
2775
+ t: a
2776
+ })] }),
2777
+ g && /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("div", {
2778
+ className: "text-[10px] text-muted-foreground mb-0.5",
2779
+ children: a("report.editor.chart")
2780
+ }), /* @__PURE__ */ P(Vt, {
2781
+ availableFields: i,
2782
+ columns: Rt(e.columns),
2783
+ value: e.chart,
2784
+ onChange: (e) => y({ chart: e }),
2785
+ t: a
2786
+ })] })
2787
+ ]
2788
+ })
2789
+ ]
2790
+ });
2791
+ }
2792
+ function xt(e) {
2793
+ return Array.isArray(e) ? e.map((e) => {
2794
+ let t = e ?? {};
2795
+ return {
2796
+ name: t.name ?? "",
2797
+ type: t.type ?? "tabular",
2798
+ columns: Array.isArray(t.columns) ? t.columns : [],
2799
+ ...t
2800
+ };
2801
+ }) : [];
2802
+ }
2803
+ function St({ value: e, onChange: t, availableFields: n, getFieldsForObject: r, containerObjectName: i, t: a }) {
2804
+ let o = xt(e), s = (e) => r ? r(e.objectName ?? i) ?? n : n, c = {};
2805
+ for (let e of o) e.name && (c[e.name] = (c[e.name] ?? 0) + 1);
2806
+ let l = (e, n) => {
2807
+ t(o.map((t, r) => r === e ? n : t));
2808
+ }, u = (e) => {
2809
+ t(o.filter((t, n) => n !== e));
2810
+ }, f = (e, n) => {
2811
+ let r = e + n;
2812
+ if (r < 0 || r >= o.length) return;
2813
+ let i = [...o];
2814
+ [i[e], i[r]] = [i[r], i[e]], t(i);
2815
+ };
2816
+ return /* @__PURE__ */ F("div", {
2817
+ className: "space-y-2",
2818
+ "data-testid": "joined-blocks-editor",
2819
+ children: [
2820
+ o.length === 0 && /* @__PURE__ */ P("div", {
2821
+ className: "text-[10px] text-muted-foreground italic px-1",
2822
+ children: a("report.editor.validationJoinedNeedsBlocks")
2823
+ }),
2824
+ o.map((e, t) => /* @__PURE__ */ P(bt, {
2825
+ block: e,
2826
+ index: t,
2827
+ total: o.length,
2828
+ availableFields: s(e),
2829
+ t: a,
2830
+ duplicateName: !!e.name && (c[e.name] ?? 0) > 1,
2831
+ onChange: (e) => l(t, e),
2832
+ onRemove: () => u(t),
2833
+ onMove: (e) => f(t, e)
2834
+ }, t)),
2835
+ /* @__PURE__ */ F(d, {
2836
+ type: "button",
2837
+ size: "sm",
2838
+ variant: "outline",
2839
+ className: "h-7 text-xs w-full",
2840
+ onClick: () => {
2841
+ t([...o, _t(o)]);
2842
+ },
2843
+ "data-testid": "joined-block-add",
2844
+ children: [/* @__PURE__ */ P(U, { className: "h-3 w-3 mr-1" }), a("report.editor.addBlock")]
2845
+ })
2846
+ ]
2847
+ });
2848
+ }
2849
+ function Ct(e, t) {
2850
+ let n = [];
2851
+ if (!Array.isArray(e) || e.length === 0) return n.push(t("report.editor.validationJoinedNeedsBlocks")), n;
2852
+ let r = /* @__PURE__ */ new Map(), i = !1, a = !1, o = !1;
2853
+ for (let t of e) {
2854
+ let e = t ?? {};
2855
+ if (!e.name || !String(e.name).trim()) i = !0;
2856
+ else {
2857
+ let t = (r.get(e.name) ?? 0) + 1;
2858
+ r.set(e.name, t), t === 2 && (a = !0);
2859
+ }
2860
+ (!Array.isArray(e.columns) || e.columns.length === 0) && (o = !0);
2861
+ }
2862
+ return i && n.push(t("report.editor.validationBlockNameRequired")), a && n.push(t("report.editor.validationBlockNameDuplicate")), o && n.push(t("report.editor.validationBlockNeedsColumns")), n;
2863
+ }
2864
+ //#endregion
2865
+ //#region src/specFilterAdapter.tsx
2866
+ var wt = {
2867
+ $eq: "equals",
2868
+ $ne: "notEquals",
2869
+ $gt: "greaterThan",
2870
+ $gte: "greaterOrEqual",
2871
+ $lt: "lessThan",
2872
+ $lte: "lessOrEqual",
2873
+ $in: "in",
2874
+ $nin: "notIn",
2875
+ $contains: "contains",
2876
+ $notContains: "notContains",
2877
+ $exists: "isNotEmpty"
2878
+ }, Tt = {
2879
+ equals: "$eq",
2880
+ notEquals: "$ne",
2881
+ greaterThan: "$gt",
2882
+ greaterOrEqual: "$gte",
2883
+ lessThan: "$lt",
2884
+ lessOrEqual: "$lte",
2885
+ in: "$in",
2886
+ notIn: "$nin",
2887
+ contains: "$contains",
2888
+ notContains: "$notContains"
2889
+ }, Et = () => ({
2890
+ id: "root",
2891
+ logic: "and",
2892
+ conditions: []
2893
+ });
2894
+ function Dt(e) {
2895
+ return !!e && typeof e == "object" && !Array.isArray(e);
2896
+ }
2897
+ function $() {
2898
+ return Math.random().toString(36).slice(2, 10);
2899
+ }
2900
+ function Ot(e, t) {
2901
+ if (typeof t != "object" || !t || Array.isArray(t)) return [{
2902
+ id: $(),
2903
+ field: e,
2904
+ operator: Array.isArray(t) ? "in" : "equals",
2905
+ value: t
2906
+ }];
2907
+ let n = [];
2908
+ for (let [r, i] of Object.entries(t)) {
2909
+ if (r === "$exists") {
2910
+ n.push({
2911
+ id: $(),
2912
+ field: e,
2913
+ operator: i === !1 ? "isEmpty" : "isNotEmpty",
2914
+ value: ""
2915
+ });
2916
+ continue;
2917
+ }
2918
+ if (r === "$null") {
2919
+ n.push({
2920
+ id: $(),
2921
+ field: e,
2922
+ operator: i === !1 ? "isNotEmpty" : "isEmpty",
2923
+ value: ""
2924
+ });
2925
+ continue;
2926
+ }
2927
+ let t = wt[r];
2928
+ if (!t || Dt(i) && "$field" in i) return null;
2929
+ n.push({
2930
+ id: $(),
2931
+ field: e,
2932
+ operator: t,
2933
+ value: i
2934
+ });
2935
+ }
2936
+ return n.length > 0 ? n : null;
2937
+ }
2938
+ function kt(e) {
2939
+ if (e == null) return {
2940
+ group: Et(),
2941
+ complex: !1
2942
+ };
2943
+ if (!Dt(e)) return {
2944
+ group: Et(),
2945
+ complex: !0
2946
+ };
2947
+ let t = Object.keys(e);
2948
+ if (t.length === 1 && (t[0] === "$and" || t[0] === "$or")) {
2949
+ let n = t[0] === "$or" ? "or" : "and", r = e[t[0]];
2950
+ if (!Array.isArray(r)) return {
2951
+ group: Et(),
2952
+ complex: !0
2953
+ };
2954
+ let i = [], a = !1;
2955
+ for (let e of r) {
2956
+ if (!Dt(e)) {
2957
+ a = !0;
2958
+ continue;
2959
+ }
2960
+ if (Object.keys(e).some((e) => e === "$and" || e === "$or" || e === "$not")) {
2961
+ a = !0;
2962
+ continue;
2963
+ }
2964
+ for (let [t, n] of Object.entries(e)) {
2965
+ let e = Ot(t, n);
2966
+ e ? i.push(...e) : a = !0;
2967
+ }
2968
+ }
2969
+ return {
2970
+ group: {
2971
+ id: "root",
2972
+ logic: n,
2973
+ conditions: i
2974
+ },
2975
+ complex: a
2976
+ };
2977
+ }
2978
+ if (t.includes("$not") || t.includes("$and") || t.includes("$or")) return {
2979
+ group: Et(),
2980
+ complex: !0
2981
+ };
2982
+ let n = [], r = !1;
2983
+ for (let [t, i] of Object.entries(e)) {
2984
+ let e = Ot(t, i);
2985
+ e ? n.push(...e) : r = !0;
2986
+ }
2987
+ return {
2988
+ group: {
2989
+ id: "root",
2990
+ logic: "and",
2991
+ conditions: n
2992
+ },
2993
+ complex: r
2994
+ };
2995
+ }
2996
+ function At(e) {
2997
+ if (!e || !Array.isArray(e.conditions) || e.conditions.length === 0) return;
2998
+ let t = e.conditions.filter((e) => e.field).map((e) => jt(e));
2999
+ if (t.length !== 0) return t.length === 1 ? t[0] : { [e.logic === "or" ? "$or" : "$and"]: t };
3000
+ }
3001
+ function jt(e) {
3002
+ let { field: t, operator: n, value: r } = e;
3003
+ if (n === "isEmpty") return { [t]: { $exists: !1 } };
3004
+ if (n === "isNotEmpty") return { [t]: { $exists: !0 } };
3005
+ if (n === "equals") return { [t]: r };
3006
+ let i = Tt[n];
3007
+ return i ? { [t]: { [i]: r } } : { [t]: r };
3008
+ }
3009
+ function Mt({ availableFields: e, value: n, onChange: r, t: i }) {
3010
+ let a = t.useMemo(() => JSON.stringify(n ?? null), [n]), o = t.useMemo(() => kt(n), [a]), [s, c] = t.useState(o.group), l = t.useRef(a);
3011
+ t.useEffect(() => {
3012
+ l.current !== a && (c(o.group), l.current = a);
3013
+ }, [a, o.group]);
3014
+ let u = (e) => {
3015
+ c(e);
3016
+ let t = At(e);
3017
+ l.current = JSON.stringify(t ?? null), r(t);
3018
+ };
3019
+ if (o.complex) return /* @__PURE__ */ F("div", {
3020
+ className: "flex items-start gap-2 p-2 rounded border border-amber-300 bg-amber-50 text-amber-900 text-[11px]",
3021
+ children: [/* @__PURE__ */ P(B, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ P("span", { children: i("report.editor.filtersComplex") })]
3022
+ });
3023
+ let f = () => {
3024
+ u({
3025
+ ...s,
3026
+ conditions: [...s.conditions, {
3027
+ id: $(),
3028
+ field: e[0]?.value ?? "",
3029
+ operator: "equals",
3030
+ value: ""
3031
+ }]
3032
+ });
3033
+ }, p = (e) => {
3034
+ u({
3035
+ ...s,
3036
+ conditions: s.conditions.filter((t) => t.id !== e)
3037
+ });
3038
+ }, m = (e, t) => {
3039
+ u({
3040
+ ...s,
3041
+ conditions: s.conditions.map((n) => n.id === e ? {
3042
+ ...n,
3043
+ ...t
3044
+ } : n)
3045
+ });
3046
+ }, h = [
3047
+ {
3048
+ value: "equals",
3049
+ label: "="
3050
+ },
3051
+ {
3052
+ value: "notEquals",
3053
+ label: "≠"
3054
+ },
3055
+ {
3056
+ value: "greaterThan",
3057
+ label: ">"
3058
+ },
3059
+ {
3060
+ value: "greaterOrEqual",
3061
+ label: "≥"
3062
+ },
3063
+ {
3064
+ value: "lessThan",
3065
+ label: "<"
3066
+ },
3067
+ {
3068
+ value: "lessOrEqual",
3069
+ label: "≤"
3070
+ },
3071
+ {
3072
+ value: "contains",
3073
+ label: i("report.editor.opContains", "contains")
3074
+ },
3075
+ {
3076
+ value: "in",
3077
+ label: "in"
3078
+ },
3079
+ {
3080
+ value: "notIn",
3081
+ label: "not in"
3082
+ },
3083
+ {
3084
+ value: "isEmpty",
3085
+ label: i("report.editor.opIsEmpty", "is empty")
3086
+ },
3087
+ {
3088
+ value: "isNotEmpty",
3089
+ label: i("report.editor.opIsNotEmpty", "is not empty")
3090
+ }
3091
+ ];
3092
+ return /* @__PURE__ */ F("div", {
3093
+ className: "space-y-1.5 py-1",
3094
+ "data-testid": "spec-filter-adapter",
3095
+ children: [
3096
+ s.conditions.length > 1 && /* @__PURE__ */ F("div", {
3097
+ className: "flex items-center gap-2 text-[10px] text-muted-foreground",
3098
+ children: [/* @__PURE__ */ P("span", { children: i("report.editor.combineLogic", "Combine with") }), /* @__PURE__ */ F("select", {
3099
+ className: "h-5 text-[10px] border rounded px-1 bg-background",
3100
+ value: s.logic,
3101
+ onChange: (e) => u({
3102
+ ...s,
3103
+ logic: e.target.value
3104
+ }),
3105
+ "data-testid": "filter-logic-select",
3106
+ children: [/* @__PURE__ */ P("option", {
3107
+ value: "and",
3108
+ children: "AND"
3109
+ }), /* @__PURE__ */ P("option", {
3110
+ value: "or",
3111
+ children: "OR"
3112
+ })]
3113
+ })]
3114
+ }),
3115
+ s.conditions.map((t) => /* @__PURE__ */ F("div", {
3116
+ className: "flex items-center gap-1 text-[10px] p-1 border rounded bg-muted/20",
3117
+ children: [
3118
+ /* @__PURE__ */ P("select", {
3119
+ className: "h-5 text-[10px] border rounded px-1 bg-background flex-1 min-w-0",
3120
+ value: t.field,
3121
+ onChange: (e) => m(t.id, { field: e.target.value }),
3122
+ "data-testid": `filter-field-${t.id}`,
3123
+ children: e.map((e) => /* @__PURE__ */ P("option", {
3124
+ value: e.value,
3125
+ children: e.label
3126
+ }, e.value))
3127
+ }),
3128
+ /* @__PURE__ */ P("select", {
3129
+ className: "h-5 text-[10px] border rounded px-1 bg-background w-20 shrink-0",
3130
+ value: t.operator,
3131
+ onChange: (e) => m(t.id, { operator: e.target.value }),
3132
+ "data-testid": `filter-op-${t.id}`,
3133
+ children: h.map((e) => /* @__PURE__ */ P("option", {
3134
+ value: e.value,
3135
+ children: e.label
3136
+ }, e.value))
3137
+ }),
3138
+ t.operator !== "isEmpty" && t.operator !== "isNotEmpty" && /* @__PURE__ */ P("input", {
3139
+ className: "h-5 text-[10px] border rounded px-1 bg-background w-24 shrink-0",
3140
+ value: Array.isArray(t.value) ? t.value.join(",") : (t.value ?? "").toString(),
3141
+ placeholder: "value",
3142
+ onChange: (e) => {
3143
+ let n = e.target.value, r = t.operator === "in" || t.operator === "notIn" ? n.split(",").map((e) => e.trim()).filter(Boolean) : n;
3144
+ m(t.id, { value: r });
3145
+ },
3146
+ "data-testid": `filter-value-${t.id}`
3147
+ }),
3148
+ /* @__PURE__ */ P(d, {
3149
+ type: "button",
3150
+ size: "sm",
3151
+ variant: "ghost",
3152
+ className: "h-5 w-5 p-0 shrink-0",
3153
+ onClick: () => p(t.id),
3154
+ "data-testid": `filter-remove-${t.id}`,
3155
+ children: /* @__PURE__ */ P(W, { className: "h-3 w-3" })
3156
+ })
3157
+ ]
3158
+ }, t.id)),
3159
+ /* @__PURE__ */ F(d, {
3160
+ type: "button",
3161
+ size: "sm",
3162
+ variant: "outline",
3163
+ className: "h-6 text-[10px] w-full",
3164
+ onClick: f,
3165
+ disabled: e.length === 0,
3166
+ "data-testid": "filter-add",
3167
+ children: [/* @__PURE__ */ P(U, { className: "h-3 w-3 mr-1" }), i("report.editor.addCondition", "Add condition")]
3168
+ })
3169
+ ]
3170
+ });
3171
+ }
3172
+ //#endregion
3173
+ //#region src/editorTypes.ts
3174
+ var Nt = new Set([
3175
+ "date",
3176
+ "datetime",
3177
+ "time"
3178
+ ]), Pt = new Set([
3179
+ "number",
3180
+ "currency",
3181
+ "percent",
3182
+ "rating",
3183
+ "integer"
3184
+ ]);
3185
+ //#endregion
3186
+ //#region src/FieldPickerDialog.tsx
3187
+ function Ft({ availableFields: e, selectedValues: n, onAdd: r, t: i, triggerLabel: a, title: o, description: s, testIdPrefix: c = "field-picker", singleSelect: l = !1, commitOnSelect: u = !1, disabled: f = !1, triggerClassName: p, trigger: m }) {
3188
+ let [h, g] = t.useState(!1), [v, E] = t.useState(""), [D, O] = t.useState(/* @__PURE__ */ new Set()), k = t.useMemo(() => new Set(n), [n]);
3189
+ t.useEffect(() => {
3190
+ h && (E(""), O(/* @__PURE__ */ new Set()));
3191
+ }, [h]);
3192
+ let A = v.trim().toLowerCase(), j = e.filter((e) => !k.has(e.value)), M = A ? j.filter((e) => e.label.toLowerCase().includes(A) || e.value.toLowerCase().includes(A)) : j, ee = (e) => {
3193
+ if (l && u) {
3194
+ r([e]), g(!1);
3195
+ return;
3196
+ }
3197
+ O((t) => {
3198
+ let n = new Set(l ? [] : t);
3199
+ return t.has(e) ? n.delete(e) : n.add(e), n;
3200
+ });
3201
+ }, N = () => {
3202
+ if (D.size === 0) {
3203
+ g(!1);
3204
+ return;
3205
+ }
3206
+ r(j.map((e) => e.value).filter((e) => D.has(e))), g(!1);
3207
+ }, I = () => {
3208
+ g(!1);
3209
+ }, L = e.length === 0, R = !L && j.length === 0, z = a ?? i("report.editor.addColumns", "Add fields"), B = o ?? i("report.editor.fieldPickerTitle", "Select fields"), V = s ?? i("report.editor.fieldPickerDescription", "Pick one or more fields to add. Use the search box to narrow the list.");
3210
+ return /* @__PURE__ */ F(y, {
3211
+ open: h,
3212
+ onOpenChange: g,
3213
+ children: [/* @__PURE__ */ P(T, {
3214
+ asChild: !0,
3215
+ children: m ?? /* @__PURE__ */ F(d, {
3216
+ type: "button",
3217
+ variant: "outline",
3218
+ size: "sm",
3219
+ className: p ?? "h-8 gap-1.5",
3220
+ disabled: f || L || R,
3221
+ "data-testid": `${c}-trigger`,
3222
+ children: [/* @__PURE__ */ P(U, { className: "h-3.5 w-3.5" }), /* @__PURE__ */ P("span", { children: z })]
3223
+ })
3224
+ }), /* @__PURE__ */ F(b, {
3225
+ className: "sm:max-w-md max-w-[92vw] gap-3",
3226
+ "data-testid": `${c}-dialog`,
3227
+ children: [
3228
+ /* @__PURE__ */ F(C, { children: [/* @__PURE__ */ P(w, { children: B }), /* @__PURE__ */ P(x, { children: V })] }),
3229
+ /* @__PURE__ */ F("div", {
3230
+ className: "relative",
3231
+ children: [/* @__PURE__ */ P(fe, { className: "pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" }), /* @__PURE__ */ P("input", {
3232
+ type: "text",
3233
+ className: "h-9 w-full text-sm border rounded pl-7 pr-2 bg-background",
3234
+ placeholder: i("report.editor.searchFields", "Search fields…"),
3235
+ value: v,
3236
+ onChange: (e) => E(e.target.value),
3237
+ "data-testid": `${c}-search`,
3238
+ autoFocus: !0
3239
+ })]
3240
+ }),
3241
+ /* @__PURE__ */ F("div", {
3242
+ className: "text-[11px] text-muted-foreground flex items-center justify-between",
3243
+ children: [/* @__PURE__ */ F("span", { children: [
3244
+ M.length,
3245
+ "/",
3246
+ j.length,
3247
+ D.size > 0 ? ` · ${i("report.editor.fieldPickerSelected", "{n} selected").replace("{n}", String(D.size))}` : ""
3248
+ ] }), D.size > 0 && /* @__PURE__ */ P("button", {
3249
+ type: "button",
3250
+ className: "text-[11px] underline-offset-2 hover:underline text-muted-foreground",
3251
+ onClick: () => O(/* @__PURE__ */ new Set()),
3252
+ "data-testid": `${c}-clear`,
3253
+ children: i("report.editor.fieldPickerClear", "Clear selection")
3254
+ })]
3255
+ }),
3256
+ /* @__PURE__ */ P("div", {
3257
+ className: "max-h-72 overflow-auto border rounded bg-background/40 p-1 space-y-0.5",
3258
+ "data-testid": `${c}-list`,
3259
+ children: L ? /* @__PURE__ */ P("div", {
3260
+ className: "text-xs text-muted-foreground px-2 py-3 text-center",
3261
+ children: i("report.editor.noFields", "No fields available — pick a data source first.")
3262
+ }) : R ? /* @__PURE__ */ P("div", {
3263
+ className: "text-xs text-muted-foreground px-2 py-3 text-center",
3264
+ children: i("report.editor.noFieldsAvailable", "All fields already added.")
3265
+ }) : M.length === 0 ? /* @__PURE__ */ P("div", {
3266
+ className: "text-xs text-muted-foreground px-2 py-3 text-center",
3267
+ children: i("report.editor.noMatchingFields", "No fields match your search.")
3268
+ }) : M.map((e) => {
3269
+ let t = D.has(e.value);
3270
+ return /* @__PURE__ */ F("label", {
3271
+ className: "flex items-center gap-2 px-2 py-1.5 rounded hover:bg-muted/50 text-sm cursor-pointer",
3272
+ "data-testid": `${c}-row-${e.value}`,
3273
+ children: [
3274
+ /* @__PURE__ */ P(_, {
3275
+ checked: t,
3276
+ onCheckedChange: () => ee(e.value),
3277
+ "data-testid": `${c}-toggle-${e.value}`
3278
+ }),
3279
+ /* @__PURE__ */ P("span", {
3280
+ className: "flex-1 truncate",
3281
+ title: e.label,
3282
+ children: e.label
3283
+ }),
3284
+ e.type && /* @__PURE__ */ P("span", {
3285
+ className: "text-[10px] text-muted-foreground shrink-0",
3286
+ children: e.type
3287
+ })
3288
+ ]
3289
+ }, e.value);
3290
+ })
3291
+ }),
3292
+ !(l && u) && /* @__PURE__ */ F(S, {
3293
+ className: "gap-2 sm:gap-2",
3294
+ children: [/* @__PURE__ */ P(d, {
3295
+ type: "button",
3296
+ variant: "ghost",
3297
+ size: "sm",
3298
+ onClick: I,
3299
+ "data-testid": `${c}-cancel`,
3300
+ children: i("common.cancel", "Cancel")
3301
+ }), /* @__PURE__ */ P(d, {
3302
+ type: "button",
3303
+ size: "sm",
3304
+ onClick: N,
3305
+ disabled: D.size === 0,
3306
+ "data-testid": `${c}-confirm`,
3307
+ children: D.size > 0 ? i("report.editor.fieldPickerAddN", "Add {n}").replace("{n}", String(D.size)) : i("report.editor.fieldPickerAdd", "Add")
3308
+ })]
3309
+ })
3310
+ ]
3311
+ })]
3312
+ });
3313
+ }
3314
+ //#endregion
3315
+ //#region src/ColumnsEditor.tsx
3316
+ function It(e) {
3317
+ return [
3318
+ {
3319
+ value: "",
3320
+ label: e("report.editor.noneOption")
3321
+ },
3322
+ {
3323
+ value: "sum",
3324
+ label: e("report.aggregate.sum")
3325
+ },
3326
+ {
3327
+ value: "count",
3328
+ label: e("report.aggregate.count")
3329
+ },
3330
+ {
3331
+ value: "unique",
3332
+ label: e("report.aggregate.countDistinct")
3333
+ },
3334
+ {
3335
+ value: "avg",
3336
+ label: e("report.aggregate.avg")
3337
+ },
3338
+ {
3339
+ value: "min",
3340
+ label: e("report.aggregate.min")
3341
+ },
3342
+ {
3343
+ value: "max",
3344
+ label: e("report.aggregate.max")
3345
+ }
3346
+ ];
3347
+ }
3348
+ function Lt(e) {
3349
+ return [
3350
+ {
3351
+ value: "",
3352
+ label: e("report.editor.formatAuto", "Auto")
3353
+ },
3354
+ {
3355
+ value: "currency",
3356
+ label: e("report.editor.formatCurrency", "Currency")
3357
+ },
3358
+ {
3359
+ value: "percent",
3360
+ label: e("report.editor.formatPercent", "Percent")
3361
+ },
3362
+ {
3363
+ value: "integer",
3364
+ label: e("report.editor.formatInteger", "Integer")
3365
+ },
3366
+ {
3367
+ value: "date",
3368
+ label: e("report.editor.formatDate", "Date")
3369
+ },
3370
+ {
3371
+ value: "datetime",
3372
+ label: e("report.editor.formatDatetime", "Date & time")
3373
+ }
3374
+ ];
3375
+ }
3376
+ function Rt(e) {
3377
+ return Array.isArray(e) ? e.map((e) => typeof e == "string" ? {
2624
3378
  field: e,
2625
3379
  label: e,
2626
3380
  type: "string"
2627
3381
  } : {
2628
3382
  field: e.field || e.name || e.value,
2629
- label: e.label || e.name || e.field || "",
3383
+ label: e.label,
2630
3384
  type: e.type || "string",
2631
- aggregate: e.aggregate ?? e.aggregation
2632
- }) : [], i = r.map((e) => e.field), a = (t) => {
2633
- let a = i.includes(t), o;
2634
- if (a) o = r.filter((e) => e.field !== t);
2635
- else {
3385
+ aggregate: e.aggregate ?? e.aggregation,
3386
+ format: e.format
3387
+ }) : [];
3388
+ }
3389
+ function zt({ availableFields: e, value: t, onChange: n, t: r }) {
3390
+ let i = Rt(t), a = new Set(i.map((e) => e.field)), o = It(r), s = Lt(r), c = (t) => {
3391
+ if (t.length === 0) return;
3392
+ let r = t.filter((e) => !a.has(e)).map((t) => {
2636
3393
  let n = e.find((e) => e.value === t);
2637
- o = [...r, {
3394
+ return {
2638
3395
  field: t,
2639
- label: n?.label || t,
3396
+ label: n?.label,
2640
3397
  type: n?.type || "string"
2641
- }];
2642
- }
2643
- n(o);
2644
- }, o = (e, t) => {
2645
- n(r.map((n) => n.field === e ? {
3398
+ };
3399
+ });
3400
+ r.length !== 0 && n([...i, ...r]);
3401
+ }, l = (e) => {
3402
+ n(i.filter((t) => t.field !== e));
3403
+ }, u = (e, t) => {
3404
+ n(i.map((n) => n.field === e ? {
2646
3405
  ...n,
2647
- aggregate: t || void 0
3406
+ ...t
2648
3407
  } : n));
3408
+ }, f = (e, t) => {
3409
+ let r = [...i], a = e + t;
3410
+ a < 0 || a >= r.length || ([r[e], r[a]] = [r[a], r[e]], n(r));
2649
3411
  };
2650
- return e.length === 0 ? /* @__PURE__ */ k("div", {
3412
+ return e.length === 0 ? /* @__PURE__ */ P("div", {
2651
3413
  className: "text-xs text-muted-foreground py-2",
2652
- "data-testid": "field-picker-empty",
2653
- children: "No fields available"
2654
- }) : /* @__PURE__ */ k("div", {
2655
- className: "space-y-1 py-1",
2656
- "data-testid": "field-picker",
2657
- children: e.map((e) => {
2658
- let t = i.includes(e.value), n = r.find((t) => t.field === e.value);
2659
- return /* @__PURE__ */ A("div", {
2660
- className: "flex items-center gap-2 px-1 py-0.5 rounded hover:bg-muted/50 text-xs",
2661
- children: [/* @__PURE__ */ A("label", {
2662
- className: "flex items-center gap-2 flex-1 cursor-pointer",
3414
+ "data-testid": "columns-editor-empty",
3415
+ children: r("report.editor.noFields", "No fields available — pick a data source first.")
3416
+ }) : /* @__PURE__ */ F("div", {
3417
+ className: "space-y-2 py-1",
3418
+ "data-testid": "columns-editor",
3419
+ children: [i.length > 0 && /* @__PURE__ */ P("div", {
3420
+ className: "space-y-1.5",
3421
+ "data-testid": "columns-selected",
3422
+ children: i.map((t, n) => {
3423
+ let a = e.find((e) => e.value === t.field);
3424
+ return /* @__PURE__ */ F("div", {
3425
+ className: "grid grid-cols-[auto_1fr_auto] gap-1.5 p-1.5 border rounded bg-muted/30 text-xs",
3426
+ "data-testid": `column-row-${t.field}`,
2663
3427
  children: [
2664
- /* @__PURE__ */ k(_, {
2665
- checked: t,
2666
- onCheckedChange: () => a(e.value),
2667
- "data-testid": `field-picker-${e.value}`
3428
+ /* @__PURE__ */ F("div", {
3429
+ className: "row-span-2 flex flex-col items-center justify-center gap-0.5",
3430
+ children: [/* @__PURE__ */ P("button", {
3431
+ type: "button",
3432
+ className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
3433
+ disabled: n === 0,
3434
+ onClick: () => f(n, -1),
3435
+ "aria-label": "Move up",
3436
+ "data-testid": `column-up-${t.field}`,
3437
+ children: /* @__PURE__ */ P(te, { className: "h-3 w-3" })
3438
+ }), /* @__PURE__ */ P("button", {
3439
+ type: "button",
3440
+ className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
3441
+ disabled: n === i.length - 1,
3442
+ onClick: () => f(n, 1),
3443
+ "aria-label": "Move down",
3444
+ "data-testid": `column-down-${t.field}`,
3445
+ children: /* @__PURE__ */ P(V, { className: "h-3 w-3" })
3446
+ })]
2668
3447
  }),
2669
- /* @__PURE__ */ k("span", {
2670
- className: "flex-1",
2671
- children: e.label
3448
+ /* @__PURE__ */ P("input", {
3449
+ className: "h-7 text-xs border rounded px-2 bg-background min-w-0 w-full",
3450
+ value: t.label ?? "",
3451
+ placeholder: a?.label ?? t.field,
3452
+ onChange: (e) => u(t.field, { label: e.target.value || void 0 }),
3453
+ "data-testid": `column-label-${t.field}`,
3454
+ title: a?.label ?? t.field
2672
3455
  }),
2673
- e.type && /* @__PURE__ */ k("span", {
2674
- className: "text-[10px] text-muted-foreground",
2675
- children: e.type
3456
+ /* @__PURE__ */ P(d, {
3457
+ type: "button",
3458
+ size: "sm",
3459
+ variant: "ghost",
3460
+ className: "row-span-2 h-7 w-7 p-0 shrink-0 self-start",
3461
+ onClick: () => l(t.field),
3462
+ "data-testid": `column-remove-${t.field}`,
3463
+ "aria-label": "Remove column",
3464
+ children: /* @__PURE__ */ P(W, { className: "h-3.5 w-3.5" })
3465
+ }),
3466
+ /* @__PURE__ */ F("div", {
3467
+ className: "grid grid-cols-2 gap-1.5",
3468
+ children: [/* @__PURE__ */ F("label", {
3469
+ className: "flex flex-col gap-0.5 min-w-0",
3470
+ children: [/* @__PURE__ */ P("span", {
3471
+ className: "text-[10px] text-muted-foreground uppercase tracking-wide",
3472
+ children: r("report.editor.aggregateColumn", "Aggregate")
3473
+ }), /* @__PURE__ */ P("select", {
3474
+ className: "h-7 text-xs border rounded px-1 bg-background w-full min-w-0",
3475
+ value: t.aggregate ?? "",
3476
+ onChange: (e) => u(t.field, { aggregate: e.target.value === "" ? void 0 : e.target.value }),
3477
+ "data-testid": `column-agg-${t.field}`,
3478
+ children: o.map((e) => /* @__PURE__ */ P("option", {
3479
+ value: e.value,
3480
+ children: e.label
3481
+ }, e.value))
3482
+ })]
3483
+ }), /* @__PURE__ */ F("label", {
3484
+ className: "flex flex-col gap-0.5 min-w-0",
3485
+ children: [/* @__PURE__ */ P("span", {
3486
+ className: "text-[10px] text-muted-foreground uppercase tracking-wide",
3487
+ children: r("report.editor.formatColumn", "Format")
3488
+ }), /* @__PURE__ */ P("select", {
3489
+ className: "h-7 text-xs border rounded px-1 bg-background w-full min-w-0",
3490
+ value: t.format ?? "",
3491
+ onChange: (e) => u(t.field, { format: e.target.value === "" ? void 0 : e.target.value }),
3492
+ "data-testid": `column-fmt-${t.field}`,
3493
+ children: s.map((e) => /* @__PURE__ */ P("option", {
3494
+ value: e.value,
3495
+ children: e.label
3496
+ }, e.value))
3497
+ })]
3498
+ })]
2676
3499
  })
2677
3500
  ]
2678
- }), t && /* @__PURE__ */ k("select", {
2679
- className: "h-5 text-[10px] border rounded px-1 bg-background",
2680
- value: n?.aggregate || "",
2681
- onChange: (t) => o(e.value, t.target.value),
2682
- "data-testid": `field-agg-${e.value}`,
2683
- children: rt.map((e) => /* @__PURE__ */ k("option", {
2684
- value: e.value,
2685
- children: e.label
2686
- }, e.value))
2687
- })]
2688
- }, e.value);
2689
- })
3501
+ }, t.field);
3502
+ })
3503
+ }), /* @__PURE__ */ F("div", {
3504
+ className: "flex items-center justify-between gap-2 pt-1",
3505
+ children: [/* @__PURE__ */ P("div", {
3506
+ className: "text-xs text-muted-foreground",
3507
+ children: i.length > 0 ? r("report.editor.columnsCount", "{n} column(s) selected").replace("{n}", String(i.length)) : r("report.editor.columnsEmpty", "No columns selected yet.")
3508
+ }), /* @__PURE__ */ P(Ft, {
3509
+ availableFields: e,
3510
+ selectedValues: i.map((e) => e.field),
3511
+ onAdd: c,
3512
+ t: r,
3513
+ testIdPrefix: "columns-picker",
3514
+ triggerLabel: r("report.editor.addColumns", "Add fields")
3515
+ })]
3516
+ })]
2690
3517
  });
2691
3518
  }
2692
- var at = [
2693
- {
2694
- value: "",
2695
- label: "None"
2696
- },
2697
- {
2698
- value: "bar",
2699
- label: "Bar Chart"
2700
- },
2701
- {
2702
- value: "line",
2703
- label: "Line Chart"
2704
- },
2705
- {
2706
- value: "pie",
2707
- label: "Pie Chart"
2708
- },
2709
- {
2710
- value: "area",
2711
- label: "Area Chart"
2712
- },
2713
- {
2714
- value: "donut",
2715
- label: "Donut Chart"
2716
- },
2717
- {
2718
- value: "scatter",
2719
- label: "Scatter Plot"
2720
- }
2721
- ];
2722
- function ot({ availableFields: e, value: t, onChange: n }) {
2723
- let r = t || {}, i = r.type ?? r.chartType ?? "", a = r.xAxis ?? r.xAxisField ?? "", o = r.yAxis ?? r.yAxisFields?.[0] ?? "", s = (e) => {
3519
+ //#endregion
3520
+ //#region src/GroupingsBuilder.tsx
3521
+ function Bt({ availableFields: e, value: t, onChange: n, t: r, testIdPrefix: i = "grouping" }) {
3522
+ let a = Array.isArray(t) ? t.map((e) => ({
3523
+ field: e.field ?? "",
3524
+ sortOrder: e.sortOrder ?? e.sort ?? "asc",
3525
+ dateGranularity: e.dateGranularity
3526
+ })) : [], o = [
3527
+ {
3528
+ value: "",
3529
+ label: r("report.editor.dateGranularityNone")
3530
+ },
3531
+ {
3532
+ value: "day",
3533
+ label: r("report.editor.day")
3534
+ },
3535
+ {
3536
+ value: "week",
3537
+ label: r("report.editor.week")
3538
+ },
3539
+ {
3540
+ value: "month",
3541
+ label: r("report.editor.month")
3542
+ },
3543
+ {
3544
+ value: "quarter",
3545
+ label: r("report.editor.quarter")
3546
+ },
3547
+ {
3548
+ value: "year",
3549
+ label: r("report.editor.year")
3550
+ }
3551
+ ], s = a.map((e) => e.field).filter(Boolean), c = (e) => {
3552
+ n(a.filter((t, n) => n !== e));
3553
+ }, l = (e, t) => {
3554
+ n(a.map((n, r) => r === e ? {
3555
+ ...n,
3556
+ ...t
3557
+ } : n));
3558
+ }, u = (e, t) => {
3559
+ let r = [...a], i = e + t;
3560
+ i < 0 || i >= r.length || ([r[e], r[i]] = [r[i], r[e]], n(r));
3561
+ }, f = (e) => {
3562
+ if (e.length === 0) return;
3563
+ let t = e.map((e) => ({
3564
+ field: e,
3565
+ sortOrder: "asc"
3566
+ }));
3567
+ n([...a, ...t]);
3568
+ }, p = (t, n) => {
3569
+ let r = n[0];
3570
+ if (!r) return;
3571
+ let i = e.find((e) => e.value === r);
3572
+ l(t, {
3573
+ field: r,
3574
+ dateGranularity: i && Nt.has(i.type ?? "") ? a[t]?.dateGranularity : void 0
3575
+ });
3576
+ };
3577
+ return /* @__PURE__ */ F("div", {
3578
+ className: "space-y-1.5 py-1",
3579
+ "data-testid": `${i}s-builder`,
3580
+ children: [a.map((t, n) => {
3581
+ let f = e.find((e) => e.value === t.field), m = f && Nt.has(f.type ?? ""), h = f?.label ?? t.field ?? r("report.editor.fieldPickerEmpty", "(pick field)");
3582
+ return /* @__PURE__ */ F("div", {
3583
+ className: "flex items-center gap-1.5 p-1.5 border rounded bg-muted/20 text-xs",
3584
+ "data-testid": `${i}-row-${n}`,
3585
+ children: [
3586
+ /* @__PURE__ */ F("div", {
3587
+ className: "flex flex-col gap-0.5 shrink-0",
3588
+ children: [/* @__PURE__ */ P("button", {
3589
+ type: "button",
3590
+ className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
3591
+ disabled: n === 0,
3592
+ onClick: () => u(n, -1),
3593
+ "aria-label": "Move up",
3594
+ "data-testid": `${i}-up-${n}`,
3595
+ children: /* @__PURE__ */ P(te, { className: "h-3 w-3" })
3596
+ }), /* @__PURE__ */ P("button", {
3597
+ type: "button",
3598
+ className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
3599
+ disabled: n === a.length - 1,
3600
+ onClick: () => u(n, 1),
3601
+ "aria-label": "Move down",
3602
+ "data-testid": `${i}-down-${n}`,
3603
+ children: /* @__PURE__ */ P(V, { className: "h-3 w-3" })
3604
+ })]
3605
+ }),
3606
+ /* @__PURE__ */ P(Ft, {
3607
+ availableFields: e,
3608
+ selectedValues: s.filter((e) => e !== t.field),
3609
+ onAdd: (e) => p(n, e),
3610
+ t: r,
3611
+ singleSelect: !0,
3612
+ commitOnSelect: !0,
3613
+ testIdPrefix: `${i}-field-picker-${n}`,
3614
+ title: r("report.editor.fieldPickerChangeTitle", "Change field"),
3615
+ trigger: /* @__PURE__ */ F("button", {
3616
+ type: "button",
3617
+ className: "h-7 flex-1 min-w-0 text-left text-xs border rounded px-2 bg-background hover:bg-muted/40 inline-flex items-center justify-between gap-1.5",
3618
+ "data-testid": `${i}-field-${n}`,
3619
+ title: h,
3620
+ children: [/* @__PURE__ */ P("span", {
3621
+ className: "truncate",
3622
+ children: h
3623
+ }), /* @__PURE__ */ P(H, { className: "h-3 w-3 text-muted-foreground shrink-0" })]
3624
+ })
3625
+ }),
3626
+ /* @__PURE__ */ F("select", {
3627
+ className: "h-7 text-xs border rounded px-1.5 bg-background w-20 shrink-0",
3628
+ value: t.sortOrder ?? "asc",
3629
+ onChange: (e) => l(n, { sortOrder: e.target.value }),
3630
+ "data-testid": `${i}-sort-${n}`,
3631
+ children: [/* @__PURE__ */ P("option", {
3632
+ value: "asc",
3633
+ children: r("report.editor.sortAsc")
3634
+ }), /* @__PURE__ */ P("option", {
3635
+ value: "desc",
3636
+ children: r("report.editor.sortDesc")
3637
+ })]
3638
+ }),
3639
+ m && /* @__PURE__ */ P("select", {
3640
+ className: "h-7 text-xs border rounded px-1.5 bg-background w-24 shrink-0",
3641
+ value: t.dateGranularity ?? "",
3642
+ onChange: (e) => l(n, { dateGranularity: e.target.value || void 0 }),
3643
+ "data-testid": `${i}-granularity-${n}`,
3644
+ children: o.map((e) => /* @__PURE__ */ P("option", {
3645
+ value: e.value,
3646
+ children: e.label
3647
+ }, e.value))
3648
+ }),
3649
+ /* @__PURE__ */ P(d, {
3650
+ type: "button",
3651
+ size: "sm",
3652
+ variant: "ghost",
3653
+ className: "h-7 w-7 p-0 shrink-0",
3654
+ onClick: () => c(n),
3655
+ "aria-label": "Remove grouping",
3656
+ "data-testid": `${i}-remove-${n}`,
3657
+ children: /* @__PURE__ */ P(W, { className: "h-3.5 w-3.5" })
3658
+ })
3659
+ ]
3660
+ }, n);
3661
+ }), /* @__PURE__ */ P(Ft, {
3662
+ availableFields: e,
3663
+ selectedValues: s,
3664
+ onAdd: f,
3665
+ t: r,
3666
+ singleSelect: !0,
3667
+ commitOnSelect: !0,
3668
+ testIdPrefix: `${i}-add-picker`,
3669
+ triggerLabel: r("report.editor.addGrouping"),
3670
+ title: r("report.editor.fieldPickerAddGroupingTitle", "Add grouping"),
3671
+ triggerClassName: "h-8 w-full justify-center gap-1.5"
3672
+ })]
3673
+ });
3674
+ }
3675
+ //#endregion
3676
+ //#region src/ChartConfig.tsx
3677
+ function Vt({ availableFields: e, columns: t, value: n, onChange: r, t: i }) {
3678
+ let a = n || {}, o = a.type ?? a.chartType ?? "", s = a.xAxis ?? a.xAxisField ?? "", c = a.yAxis ?? a.yAxisFields?.[0] ?? "", l = (e) => {
2724
3679
  let t = {
2725
- ...r,
3680
+ ...a,
2726
3681
  ...e
2727
3682
  };
2728
- "type" in e && delete t.chartType, "xAxis" in e && delete t.xAxisField, "yAxis" in e && delete t.yAxisFields, n(t);
2729
- };
2730
- return /* @__PURE__ */ A("div", {
3683
+ if ("type" in e && delete t.chartType, "xAxis" in e && delete t.xAxisField, "yAxis" in e && delete t.yAxisFields, !e.type && e.type === "") return r(void 0);
3684
+ r(t);
3685
+ }, u = () => r(void 0), d = [
3686
+ {
3687
+ value: "",
3688
+ label: i("report.editor.chartNone")
3689
+ },
3690
+ {
3691
+ value: "bar",
3692
+ label: i("report.editor.chartBar")
3693
+ },
3694
+ {
3695
+ value: "line",
3696
+ label: i("report.editor.chartLine")
3697
+ },
3698
+ {
3699
+ value: "area",
3700
+ label: i("report.editor.chartArea")
3701
+ },
3702
+ {
3703
+ value: "pie",
3704
+ label: i("report.editor.chartPie")
3705
+ },
3706
+ {
3707
+ value: "donut",
3708
+ label: i("report.editor.chartDonut")
3709
+ },
3710
+ {
3711
+ value: "funnel",
3712
+ label: i("report.editor.chartFunnel")
3713
+ }
3714
+ ], f = t.filter((e) => e.aggregate).map((e) => e.field), p = e.filter((e) => Pt.has(e.type ?? "")).map((e) => e.value), m = new Set([...f, ...p]), h = e.filter((e) => m.has(e.value));
3715
+ return /* @__PURE__ */ F("div", {
2731
3716
  className: "space-y-2 py-1",
2732
3717
  "data-testid": "chart-config",
2733
- children: [/* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("label", {
2734
- className: "text-[10px] text-muted-foreground",
2735
- children: "Chart type"
2736
- }), /* @__PURE__ */ k("select", {
2737
- className: "w-full h-7 text-xs border rounded px-2 bg-background",
2738
- value: i,
2739
- onChange: (e) => s({ type: e.target.value || void 0 }),
2740
- "data-testid": "chart-type-select",
2741
- children: at.map((e) => /* @__PURE__ */ k("option", {
2742
- value: e.value,
2743
- children: e.label
2744
- }, e.value))
2745
- })] }), i && /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("label", {
3718
+ children: [/* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("label", {
2746
3719
  className: "text-[10px] text-muted-foreground",
2747
- children: "X-axis field"
2748
- }), /* @__PURE__ */ A("select", {
2749
- className: "w-full h-7 text-xs border rounded px-2 bg-background",
2750
- value: a,
2751
- onChange: (e) => s({ xAxis: e.target.value || void 0 }),
2752
- "data-testid": "chart-x-field",
2753
- children: [/* @__PURE__ */ k("option", {
2754
- value: "",
2755
- children: "Select field…"
2756
- }), e.map((e) => /* @__PURE__ */ k("option", {
2757
- value: e.value,
2758
- children: e.label
2759
- }, e.value))]
2760
- })] }), /* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("label", {
2761
- className: "text-[10px] text-muted-foreground",
2762
- children: "Y-axis field"
2763
- }), /* @__PURE__ */ A("select", {
3720
+ children: i("report.editor.chartType")
3721
+ }), /* @__PURE__ */ P("select", {
2764
3722
  className: "w-full h-7 text-xs border rounded px-2 bg-background",
2765
3723
  value: o,
2766
- onChange: (e) => s({ yAxis: e.target.value || void 0 }),
2767
- "data-testid": "chart-y-field",
2768
- children: [/* @__PURE__ */ k("option", {
2769
- value: "",
2770
- children: "Select field…"
2771
- }), e.filter((e) => e.type === "number").map((e) => /* @__PURE__ */ k("option", {
3724
+ onChange: (e) => {
3725
+ let t = e.target.value;
3726
+ t ? l({ type: t }) : u();
3727
+ },
3728
+ "data-testid": "chart-type-select",
3729
+ children: d.map((e) => /* @__PURE__ */ P("option", {
2772
3730
  value: e.value,
2773
3731
  children: e.label
2774
- }, e.value))]
2775
- })] })] })]
2776
- });
2777
- }
2778
- var st = [
2779
- {
2780
- value: "equals",
2781
- label: "="
2782
- },
2783
- {
2784
- value: "not_equals",
2785
- label: "≠"
2786
- },
2787
- {
2788
- value: "greater_than",
2789
- label: ">"
2790
- },
2791
- {
2792
- value: "less_than",
2793
- label: "<"
2794
- },
2795
- {
2796
- value: "contains",
2797
- label: "Contains"
2798
- }
2799
- ];
2800
- function ct({ availableFields: e, value: t, onChange: n }) {
2801
- let r = Array.isArray(t) ? t : [], i = () => {
2802
- n([...r, {
2803
- field: e[0]?.value || "",
2804
- operator: "equals",
2805
- value: "",
2806
- backgroundColor: "#fef9c3",
2807
- textColor: ""
2808
- }]);
2809
- }, a = (e) => {
2810
- n(r.filter((t, n) => n !== e));
2811
- }, o = (e, t) => {
2812
- n(r.map((n, r) => r === e ? {
2813
- ...n,
2814
- ...t
2815
- } : n));
2816
- };
2817
- return /* @__PURE__ */ A("div", {
2818
- className: "space-y-2 py-1",
2819
- "data-testid": "conditional-format-rules",
2820
- children: [r.map((t, n) => /* @__PURE__ */ A("div", {
2821
- className: "flex items-center gap-1 text-[10px] p-1 border rounded bg-muted/20",
2822
- children: [
2823
- /* @__PURE__ */ k("select", {
2824
- className: "h-5 text-[10px] border rounded px-1 bg-background flex-1",
2825
- value: t.field,
2826
- onChange: (e) => o(n, { field: e.target.value }),
2827
- "data-testid": `cf-rule-field-${n}`,
2828
- children: e.map((e) => /* @__PURE__ */ k("option", {
2829
- value: e.value,
2830
- children: e.label
2831
- }, e.value))
2832
- }),
2833
- /* @__PURE__ */ k("select", {
2834
- className: "h-5 text-[10px] border rounded px-1 bg-background w-12",
2835
- value: t.operator,
2836
- onChange: (e) => o(n, { operator: e.target.value }),
2837
- children: st.map((e) => /* @__PURE__ */ k("option", {
2838
- value: e.value,
2839
- children: e.label
2840
- }, e.value))
2841
- }),
2842
- /* @__PURE__ */ k("input", {
2843
- className: "h-5 text-[10px] border rounded px-1 bg-background w-16",
2844
- value: t.value,
2845
- placeholder: "value",
2846
- onChange: (e) => o(n, { value: e.target.value }),
2847
- "data-testid": `cf-rule-value-${n}`
2848
- }),
2849
- /* @__PURE__ */ k("input", {
2850
- type: "color",
2851
- className: "h-5 w-5 rounded border cursor-pointer",
2852
- value: t.backgroundColor || "#fef9c3",
2853
- onChange: (e) => o(n, { backgroundColor: e.target.value }),
2854
- title: "Background color"
2855
- }),
2856
- /* @__PURE__ */ k(d, {
2857
- type: "button",
2858
- size: "sm",
2859
- variant: "ghost",
2860
- className: "h-5 w-5 p-0",
2861
- onClick: () => a(n),
2862
- "data-testid": `cf-rule-remove-${n}`,
2863
- children: /* @__PURE__ */ k(z, { className: "h-3 w-3" })
2864
- })
2865
- ]
2866
- }, n)), /* @__PURE__ */ A(d, {
2867
- type: "button",
2868
- size: "sm",
2869
- variant: "outline",
2870
- className: "h-6 text-[10px] w-full",
2871
- onClick: i,
2872
- "data-testid": "cf-add-rule",
2873
- children: [/* @__PURE__ */ k(L, { className: "h-3 w-3 mr-1" }), "Add Rule"]
2874
- })]
2875
- });
2876
- }
2877
- var lt = [
2878
- {
2879
- value: "header",
2880
- label: "Header"
2881
- },
2882
- {
2883
- value: "summary",
2884
- label: "Summary"
2885
- },
2886
- {
2887
- value: "table",
2888
- label: "Table"
2889
- },
2890
- {
2891
- value: "chart",
2892
- label: "Chart"
2893
- },
2894
- {
2895
- value: "text",
2896
- label: "Text"
2897
- }
2898
- ];
2899
- function ut({ value: e, onChange: t }) {
2900
- let n = Array.isArray(e) ? e : [], r = (e) => {
2901
- t([...n, {
2902
- type: e,
2903
- title: `New ${e}`,
2904
- visible: !0
2905
- }]);
2906
- }, i = (e) => {
2907
- t(n.filter((t, n) => n !== e));
2908
- }, a = (e, r) => {
2909
- t(n.map((t, n) => n === e ? {
2910
- ...t,
2911
- ...r
2912
- } : t));
2913
- }, o = (e, r) => {
2914
- let i = e + r;
2915
- if (i < 0 || i >= n.length) return;
2916
- let a = [...n];
2917
- [a[e], a[i]] = [a[i], a[e]], t(a);
2918
- };
2919
- return /* @__PURE__ */ A("div", {
2920
- className: "space-y-2 py-1",
2921
- "data-testid": "section-manager",
2922
- children: [n.map((e, t) => /* @__PURE__ */ A("div", {
2923
- className: "flex items-center gap-1 text-[10px] p-1.5 border rounded bg-muted/20",
2924
- children: [
2925
- /* @__PURE__ */ A("div", {
2926
- className: "flex flex-col gap-0.5 mr-1",
2927
- children: [/* @__PURE__ */ k("button", {
2928
- type: "button",
2929
- className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
2930
- disabled: t === 0,
2931
- onClick: () => o(t, -1),
2932
- "data-testid": `section-up-${t}`,
2933
- children: "▲"
2934
- }), /* @__PURE__ */ k("button", {
2935
- type: "button",
2936
- className: "text-muted-foreground hover:text-foreground disabled:opacity-30",
2937
- disabled: t === n.length - 1,
2938
- onClick: () => o(t, 1),
2939
- "data-testid": `section-down-${t}`,
2940
- children: "▼"
2941
- })]
2942
- }),
2943
- /* @__PURE__ */ k("span", {
2944
- className: "text-[9px] bg-muted px-1.5 py-0.5 rounded uppercase font-medium shrink-0",
2945
- children: e.type
2946
- }),
2947
- /* @__PURE__ */ k("input", {
2948
- className: "h-5 text-[10px] border rounded px-1 bg-background flex-1 min-w-0",
2949
- value: e.title || "",
2950
- placeholder: "Section title",
2951
- onChange: (e) => a(t, { title: e.target.value }),
2952
- "data-testid": `section-title-${t}`
2953
- }),
2954
- /* @__PURE__ */ k(d, {
2955
- type: "button",
2956
- size: "sm",
2957
- variant: "ghost",
2958
- className: "h-5 w-5 p-0 shrink-0",
2959
- onClick: () => i(t),
2960
- "data-testid": `section-remove-${t}`,
2961
- children: /* @__PURE__ */ k(z, { className: "h-3 w-3" })
2962
- })
2963
- ]
2964
- }, t)), /* @__PURE__ */ k("div", {
2965
- className: "flex gap-1 flex-wrap",
2966
- children: lt.map((e) => /* @__PURE__ */ A(d, {
2967
- type: "button",
2968
- size: "sm",
2969
- variant: "outline",
2970
- className: "h-6 text-[10px]",
2971
- onClick: () => r(e.value),
2972
- "data-testid": `section-add-${e.value}`,
2973
- children: [/* @__PURE__ */ k(L, { className: "h-3 w-3 mr-0.5" }), e.label]
2974
3732
  }, e.value))
2975
- })]
3733
+ })] }), o && /* @__PURE__ */ F(N, { children: [
3734
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("label", {
3735
+ className: "text-[10px] text-muted-foreground",
3736
+ children: i("report.editor.chartTitle")
3737
+ }), /* @__PURE__ */ P("input", {
3738
+ className: "w-full h-7 text-xs border rounded px-2 bg-background",
3739
+ value: a.title ?? "",
3740
+ placeholder: i("report.editor.chartTitlePlaceholder"),
3741
+ onChange: (e) => l({ title: e.target.value || void 0 }),
3742
+ "data-testid": "chart-title"
3743
+ })] }),
3744
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("label", {
3745
+ className: "text-[10px] text-muted-foreground",
3746
+ children: i("report.editor.chartXAxis")
3747
+ }), /* @__PURE__ */ F("select", {
3748
+ className: "w-full h-7 text-xs border rounded px-2 bg-background",
3749
+ value: s,
3750
+ onChange: (e) => l({ xAxis: e.target.value || void 0 }),
3751
+ "data-testid": "chart-x-field",
3752
+ children: [/* @__PURE__ */ P("option", {
3753
+ value: "",
3754
+ children: "—"
3755
+ }), e.map((e) => /* @__PURE__ */ P("option", {
3756
+ value: e.value,
3757
+ children: e.label
3758
+ }, e.value))]
3759
+ })] }),
3760
+ /* @__PURE__ */ F("div", { children: [/* @__PURE__ */ P("label", {
3761
+ className: "text-[10px] text-muted-foreground",
3762
+ children: i("report.editor.chartYAxis")
3763
+ }), /* @__PURE__ */ F("select", {
3764
+ className: "w-full h-7 text-xs border rounded px-2 bg-background",
3765
+ value: c,
3766
+ onChange: (e) => l({ yAxis: e.target.value || void 0 }),
3767
+ "data-testid": "chart-y-field",
3768
+ children: [/* @__PURE__ */ P("option", {
3769
+ value: "",
3770
+ children: "—"
3771
+ }), (h.length > 0 ? h : e).map((e) => /* @__PURE__ */ P("option", {
3772
+ value: e.value,
3773
+ children: e.label
3774
+ }, e.value))]
3775
+ })] }),
3776
+ /* @__PURE__ */ F("label", {
3777
+ className: "flex items-center gap-2 text-[10px]",
3778
+ children: [/* @__PURE__ */ P(_, {
3779
+ checked: a.showLegend !== !1,
3780
+ onCheckedChange: (e) => l({ showLegend: e === !0 }),
3781
+ "data-testid": "chart-show-legend"
3782
+ }), /* @__PURE__ */ P("span", { children: i("report.editor.chartShowLegend") })]
3783
+ }),
3784
+ /* @__PURE__ */ F("label", {
3785
+ className: "flex items-center gap-2 text-[10px]",
3786
+ children: [/* @__PURE__ */ P(_, {
3787
+ checked: !!a.showDataLabels,
3788
+ onCheckedChange: (e) => l({ showDataLabels: e === !0 }),
3789
+ "data-testid": "chart-show-data-labels"
3790
+ }), /* @__PURE__ */ P("span", { children: i("report.editor.chartShowDataLabels") })]
3791
+ })
3792
+ ] })]
2976
3793
  });
2977
3794
  }
2978
- function dt(e = []) {
2979
- return {
2980
- breadcrumb: ["Report", "Configuration"],
2981
- sections: [
2982
- {
2983
- key: "basic",
2984
- title: "Basic",
2985
- fields: [
2986
- {
2987
- key: "label",
2988
- label: "Title",
2989
- type: "input",
2990
- placeholder: "Report title"
2991
- },
2992
- {
2993
- key: "description",
2994
- label: "Description",
2995
- type: "input",
2996
- placeholder: "Report description"
2997
- },
2998
- {
2999
- key: "type",
3000
- label: "Report type",
3001
- type: "select",
3002
- defaultValue: "tabular",
3003
- options: [
3004
- {
3005
- value: "tabular",
3006
- label: "Tabular"
3007
- },
3008
- {
3009
- value: "summary",
3010
- label: "Summary"
3011
- },
3012
- {
3013
- value: "matrix",
3014
- label: "Matrix"
3015
- }
3016
- ],
3017
- helpText: "Tabular: flat table. Summary: grouped with subtotals. Matrix: pivot table (planned)."
3018
- }
3019
- ]
3020
- },
3021
- {
3022
- key: "data",
3023
- title: "Data",
3024
- collapsible: !0,
3025
- fields: [{
3026
- key: "objectName",
3027
- label: "Data source",
3028
- type: "input",
3029
- placeholder: "e.g. opportunity",
3030
- helpText: "Object name to query data from"
3031
- }, {
3032
- key: "limit",
3033
- label: "Row limit",
3795
+ //#endregion
3796
+ //#region src/ReportConfigPanel.tsx
3797
+ function Ht(e, t, n) {
3798
+ let r = (e) => e.type === "summary", i = (e) => e.type === "matrix", a = (e) => e.type === "summary" || e.type === "matrix", o = [
3799
+ {
3800
+ key: "basic",
3801
+ title: t("report.editor.basic"),
3802
+ fields: [
3803
+ {
3804
+ key: "label",
3805
+ label: t("report.editor.title"),
3034
3806
  type: "input",
3035
- defaultValue: "100",
3036
- placeholder: "e.g. 100"
3037
- }]
3038
- },
3039
- {
3040
- key: "columns",
3041
- title: "Columns",
3042
- collapsible: !0,
3043
- hint: "Select fields to display as report columns. Set aggregation per column for summary reports.",
3044
- fields: [{
3045
- key: "columns",
3046
- label: "Report columns",
3047
- type: "custom",
3048
- render: (t, n) => /* @__PURE__ */ k(it, {
3049
- availableFields: e,
3050
- value: t,
3051
- onChange: n
3052
- })
3053
- }]
3054
- },
3055
- {
3056
- key: "filters",
3057
- title: "Filters",
3058
- collapsible: !0,
3059
- hint: "Define filter conditions for the report data",
3060
- fields: [{
3061
- key: "filter",
3062
- label: "Conditions",
3063
- type: "filter",
3064
- fields: e
3065
- }]
3066
- },
3067
- {
3068
- key: "groupBy",
3069
- title: "Group By",
3070
- collapsible: !0,
3071
- hint: "Group report data and compute aggregations",
3072
- fields: [{
3073
- key: "groupingsDown",
3074
- label: "Grouping",
3075
- type: "custom",
3076
- render: (t, n) => /* @__PURE__ */ k(S, {
3077
- fields: e,
3078
- value: Array.isArray(t) ? t.map((e) => ({
3079
- ...e,
3080
- order: e.order ?? e.sortOrder ?? "asc"
3081
- })) : [],
3082
- onChange: (e) => n(e.map((e) => {
3083
- let { id: t, order: n, ...r } = e;
3084
- return {
3085
- ...r,
3086
- sortOrder: n ?? "asc"
3087
- };
3088
- }))
3089
- })
3090
- }]
3091
- },
3092
- {
3093
- key: "chart",
3094
- title: "Chart",
3095
- collapsible: !0,
3096
- hint: "Add a chart visualization to the report",
3097
- fields: [{
3098
- key: "chart",
3099
- label: "Chart",
3100
- type: "custom",
3101
- render: (t, n) => /* @__PURE__ */ k(ot, {
3102
- availableFields: e,
3103
- value: t,
3104
- onChange: n
3105
- })
3106
- }]
3107
- },
3108
- {
3109
- key: "conditionalFormatting",
3110
- title: "Conditional Format",
3111
- collapsible: !0,
3112
- defaultCollapsed: !0,
3113
- hint: "Highlight cells based on field value conditions",
3114
- fields: [{
3115
- key: "conditionalFormatting",
3116
- label: "Rules",
3117
- type: "custom",
3118
- render: (t, n) => /* @__PURE__ */ k(ct, {
3119
- availableFields: e,
3120
- value: t,
3121
- onChange: n
3122
- })
3123
- }]
3124
- },
3125
- {
3126
- key: "sections",
3127
- title: "Sections",
3128
- collapsible: !0,
3129
- defaultCollapsed: !0,
3130
- hint: "Manage report layout blocks (header, table, chart, summary)",
3131
- fields: [{
3132
- key: "sections",
3133
- label: "Report sections",
3134
- type: "custom",
3135
- render: (e, t) => /* @__PURE__ */ k(ut, {
3136
- value: e,
3137
- onChange: t
3138
- })
3139
- }]
3140
- },
3141
- {
3142
- key: "export",
3143
- title: "Export",
3144
- collapsible: !0,
3145
- defaultCollapsed: !0,
3146
- fields: [
3147
- {
3148
- key: "showExportButtons",
3149
- label: "Show export buttons",
3150
- type: "switch",
3151
- defaultValue: !0
3152
- },
3153
- {
3154
- key: "showPrintButton",
3155
- label: "Show print button",
3156
- type: "switch",
3157
- defaultValue: !0
3158
- },
3159
- {
3160
- key: "defaultExportFormat",
3161
- label: "Default export format",
3162
- type: "select",
3163
- defaultValue: "pdf",
3164
- options: [
3165
- {
3166
- value: "pdf",
3167
- label: "PDF"
3168
- },
3169
- {
3170
- value: "excel",
3171
- label: "Excel"
3172
- },
3173
- {
3174
- value: "csv",
3175
- label: "CSV"
3176
- },
3177
- {
3178
- value: "json",
3179
- label: "JSON"
3180
- },
3181
- {
3182
- value: "html",
3183
- label: "HTML"
3184
- }
3185
- ]
3186
- }
3187
- ]
3188
- },
3189
- {
3190
- key: "schedule",
3191
- title: "Schedule",
3192
- collapsible: !0,
3193
- defaultCollapsed: !0,
3194
- fields: [{
3195
- key: "schedule",
3196
- label: "Schedule",
3197
- type: "custom",
3198
- render: (e, t) => /* @__PURE__ */ k(tt, {
3199
- schedule: e,
3200
- onChange: t
3201
- })
3202
- }]
3203
- },
3204
- {
3205
- key: "appearance",
3206
- title: "Appearance",
3207
- collapsible: !0,
3208
- defaultCollapsed: !0,
3209
- fields: [{
3210
- key: "showToolbar",
3211
- label: "Show toolbar",
3212
- type: "switch",
3213
- defaultValue: !0
3214
- }, {
3215
- key: "refreshInterval",
3216
- label: "Refresh interval",
3807
+ placeholder: t("report.editor.titlePlaceholder")
3808
+ },
3809
+ {
3810
+ key: "description",
3811
+ label: t("report.editor.description"),
3812
+ type: "textarea",
3813
+ placeholder: t("report.editor.descriptionPlaceholder")
3814
+ },
3815
+ {
3816
+ key: "type",
3817
+ label: t("report.editor.type"),
3217
3818
  type: "select",
3218
- defaultValue: "0",
3819
+ defaultValue: "tabular",
3219
3820
  options: [
3220
3821
  {
3221
- value: "0",
3222
- label: "Manual"
3822
+ value: "tabular",
3823
+ label: t("report.editor.typeTabular")
3223
3824
  },
3224
3825
  {
3225
- value: "30",
3226
- label: "30s"
3826
+ value: "summary",
3827
+ label: t("report.editor.typeSummary")
3227
3828
  },
3228
3829
  {
3229
- value: "60",
3230
- label: "1 min"
3830
+ value: "matrix",
3831
+ label: t("report.editor.typeMatrix")
3231
3832
  },
3232
3833
  {
3233
- value: "300",
3234
- label: "5 min"
3834
+ value: "joined",
3835
+ label: t("report.editor.typeJoined")
3235
3836
  }
3236
- ]
3237
- }]
3238
- }
3239
- ]
3837
+ ],
3838
+ helpText: t("report.editor.typeHelp")
3839
+ }
3840
+ ]
3841
+ },
3842
+ {
3843
+ key: "data",
3844
+ title: t("report.editor.data"),
3845
+ collapsible: !0,
3846
+ fields: [{
3847
+ key: "objectName",
3848
+ label: t("report.editor.objectName"),
3849
+ type: "input",
3850
+ placeholder: t("report.editor.objectNamePlaceholder"),
3851
+ helpText: t("report.editor.objectNameHelp")
3852
+ }, {
3853
+ key: "limit",
3854
+ label: t("report.editor.limit"),
3855
+ type: "input",
3856
+ placeholder: t("report.editor.limitPlaceholder")
3857
+ }]
3858
+ },
3859
+ {
3860
+ key: "rows",
3861
+ title: t("report.editor.rows"),
3862
+ collapsible: !0,
3863
+ hint: t("report.editor.rowsHint"),
3864
+ visibleWhen: (e) => r(e) || i(e),
3865
+ fields: [{
3866
+ key: "groupingsDown",
3867
+ label: t("report.editor.grouping"),
3868
+ type: "custom",
3869
+ render: (n, r) => /* @__PURE__ */ P(Bt, {
3870
+ availableFields: e,
3871
+ value: n,
3872
+ onChange: r,
3873
+ t,
3874
+ testIdPrefix: "rows-grouping"
3875
+ })
3876
+ }]
3877
+ },
3878
+ {
3879
+ key: "columnsAxis",
3880
+ title: t("report.editor.columnsAxis"),
3881
+ collapsible: !0,
3882
+ hint: t("report.editor.columnsAxisHint"),
3883
+ visibleWhen: (e) => i(e),
3884
+ fields: [{
3885
+ key: "groupingsAcross",
3886
+ label: t("report.editor.grouping"),
3887
+ type: "custom",
3888
+ render: (n, r) => /* @__PURE__ */ P(Bt, {
3889
+ availableFields: e,
3890
+ value: n,
3891
+ onChange: r,
3892
+ t,
3893
+ testIdPrefix: "cols-grouping"
3894
+ })
3895
+ }]
3896
+ },
3897
+ {
3898
+ key: "tabular-columns",
3899
+ title: t("report.editor.columns"),
3900
+ collapsible: !0,
3901
+ hint: t("report.editor.columnsHint"),
3902
+ visibleWhen: (e) => e.type !== "joined" && !r(e) && !i(e),
3903
+ fields: [{
3904
+ key: "columns",
3905
+ label: t("report.editor.columns"),
3906
+ type: "custom",
3907
+ render: (n, r) => /* @__PURE__ */ P(zt, {
3908
+ availableFields: e,
3909
+ value: n,
3910
+ onChange: r,
3911
+ t
3912
+ })
3913
+ }]
3914
+ },
3915
+ {
3916
+ key: "values",
3917
+ title: t("report.editor.values"),
3918
+ collapsible: !0,
3919
+ hint: t("report.editor.valuesHint"),
3920
+ visibleWhen: (e) => r(e) || i(e),
3921
+ fields: [{
3922
+ key: "columns",
3923
+ label: t("report.editor.values"),
3924
+ type: "custom",
3925
+ render: (n, r) => /* @__PURE__ */ P(zt, {
3926
+ availableFields: e,
3927
+ value: n,
3928
+ onChange: r,
3929
+ t
3930
+ })
3931
+ }]
3932
+ },
3933
+ {
3934
+ key: "filters",
3935
+ title: t("report.editor.filters"),
3936
+ collapsible: !0,
3937
+ hint: t("report.editor.filtersHint"),
3938
+ visibleWhen: (e) => e.type !== "joined",
3939
+ fields: [{
3940
+ key: "filter",
3941
+ label: t("report.editor.filters"),
3942
+ type: "custom",
3943
+ render: (n, r) => /* @__PURE__ */ P(Mt, {
3944
+ availableFields: e,
3945
+ value: n,
3946
+ onChange: r,
3947
+ t
3948
+ })
3949
+ }]
3950
+ },
3951
+ {
3952
+ key: "blocks",
3953
+ title: t("report.editor.blocks"),
3954
+ collapsible: !0,
3955
+ hint: t("report.editor.blocksHint"),
3956
+ visibleWhen: (e) => e.type === "joined",
3957
+ fields: [{
3958
+ key: "blocks",
3959
+ label: t("report.editor.blocks"),
3960
+ type: "custom",
3961
+ render: (r, i, a) => /* @__PURE__ */ P(St, {
3962
+ value: r,
3963
+ onChange: i,
3964
+ availableFields: e,
3965
+ getFieldsForObject: n,
3966
+ containerObjectName: a?.objectName,
3967
+ t
3968
+ })
3969
+ }]
3970
+ },
3971
+ {
3972
+ key: "chart",
3973
+ title: t("report.editor.chart"),
3974
+ collapsible: !0,
3975
+ defaultCollapsed: !0,
3976
+ hint: t("report.editor.chartHint"),
3977
+ visibleWhen: (e) => a(e),
3978
+ fields: [{
3979
+ key: "chart",
3980
+ label: t("report.editor.chart"),
3981
+ type: "custom",
3982
+ render: (n, r, i) => /* @__PURE__ */ P(Vt, {
3983
+ availableFields: e,
3984
+ columns: Rt(i.columns),
3985
+ value: n,
3986
+ onChange: r,
3987
+ t
3988
+ })
3989
+ }]
3990
+ }
3991
+ ];
3992
+ return {
3993
+ breadcrumb: [t("report.editor.breadcrumb", "Configuration")],
3994
+ sections: o
3240
3995
  };
3241
3996
  }
3242
- function ft({ open: e, onClose: n, config: r, onSave: i, onFieldChange: a, availableFields: o }) {
3243
- let { draft: s, isDirty: c, updateField: l, discard: u, undo: d, redo: f, canUndo: p, canRedo: m } = D(r, { onUpdate: a });
3244
- return /* @__PURE__ */ k(v, {
3997
+ function Ut(e, t) {
3998
+ let n = [], r = e.type ?? "tabular", i = Array.isArray(e.groupingsDown) ? e.groupingsDown.length : 0, a = Array.isArray(e.groupingsAcross) ? e.groupingsAcross.length : 0, o = Array.isArray(e.columns) ? e.columns.length : 0;
3999
+ if (e.objectName || n.push({
4000
+ level: o > 0 ? "error" : "warning",
4001
+ message: t("report.editor.validationNeedsObject")
4002
+ }), r === "matrix" && (i === 0 || a === 0) && n.push({
4003
+ level: "error",
4004
+ message: t("report.editor.validationMatrixNeedsRowsCols")
4005
+ }), r === "summary" && i === 0 && n.push({
4006
+ level: "error",
4007
+ message: t("report.editor.validationSummaryNeedsRows")
4008
+ }), r === "joined") for (let r of Ct(e.blocks, t)) n.push({
4009
+ level: "error",
4010
+ message: r
4011
+ });
4012
+ return n;
4013
+ }
4014
+ function Wt({ problems: e }) {
4015
+ return e.length === 0 ? null : /* @__PURE__ */ P("div", {
4016
+ className: "space-y-1 p-2 border-b",
4017
+ "data-testid": "report-validation-banner",
4018
+ children: e.map((e, t) => /* @__PURE__ */ F("div", {
4019
+ className: "flex items-start gap-2 text-[11px] rounded px-2 py-1 " + (e.level === "error" ? "bg-red-50 border border-red-200 text-red-900" : "bg-amber-50 border border-amber-200 text-amber-900"),
4020
+ children: [/* @__PURE__ */ P(B, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ P("span", { children: e.message })]
4021
+ }, t))
4022
+ });
4023
+ }
4024
+ function Gt({ open: e, onClose: n, config: r, onSave: i, onFieldChange: a, availableFields: o, getFieldsForObject: s }) {
4025
+ let { t: c } = I(), l = t.useCallback((e, t, n) => t === void 0 ? c(e, n) : c(e, {
4026
+ defaultValue: t,
4027
+ ...n || {}
4028
+ }), [c]), u = o ?? [], d = t.useMemo(() => Ht(u, l, s), [
4029
+ u,
4030
+ l,
4031
+ s
4032
+ ]), { draft: f, isDirty: p, updateField: m, discard: h } = ee(t.useMemo(() => r ?? {}, [r])), g = t.useCallback((e, t) => {
4033
+ m(e, t), a?.(e, t, {
4034
+ ...f,
4035
+ [e]: t
4036
+ });
4037
+ }, [
4038
+ m,
4039
+ a,
4040
+ f
4041
+ ]), _ = t.useCallback(() => {
4042
+ i(f), n();
4043
+ }, [
4044
+ f,
4045
+ i,
4046
+ n
4047
+ ]), y = t.useMemo(() => Ut(f, l), [f, l]);
4048
+ return e ? /* @__PURE__ */ P(v, {
3245
4049
  open: e,
3246
4050
  onClose: n,
3247
- schema: t.useMemo(() => dt(o), [o]),
3248
- draft: s,
3249
- isDirty: c,
3250
- onFieldChange: l,
3251
- onSave: () => i(s),
3252
- onDiscard: u,
3253
- onUndo: d,
3254
- onRedo: f,
3255
- canUndo: p,
3256
- canRedo: m
3257
- });
4051
+ schema: d,
4052
+ draft: f,
4053
+ isDirty: p,
4054
+ onFieldChange: g,
4055
+ onSave: _,
4056
+ onDiscard: h,
4057
+ headerExtra: /* @__PURE__ */ P(Wt, { problems: y }),
4058
+ style: { "--config-panel-width": "440px" }
4059
+ }) : null;
3258
4060
  }
3259
4061
  //#endregion
3260
4062
  //#region src/LiveReportExporter.ts
3261
- async function pt(e, t) {
4063
+ async function Kt(e, t) {
3262
4064
  let { dataSource: n, resource: r, queryParams: i, format: a, exportConfig: o } = t, s = a || e.defaultExportFormat || "pdf";
3263
4065
  try {
3264
4066
  let t = (await n.find(r, i)).data || [];
3265
- return qe(s, e, t, {
4067
+ return it(s, e, t, {
3266
4068
  format: s,
3267
4069
  ...e.exportConfigs?.[s],
3268
4070
  ...o
@@ -3280,17 +4082,17 @@ async function pt(e, t) {
3280
4082
  };
3281
4083
  }
3282
4084
  }
3283
- function mt(e, t, n = {}) {
3284
- let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(gt), s = o.map((e) => e.header), c = t.map((e, t) => o.map((n) => {
4085
+ function qt(e, t, n = {}) {
4086
+ let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(Yt), s = o.map((e) => e.header), c = t.map((e, t) => o.map((n) => {
3285
4087
  if (n.formula) return n.formula.replace(/\{ROW\}/g, String(t + 2));
3286
4088
  let r = e[n.name];
3287
- return _t(r, n.numberFormat);
4089
+ return Xt(r, n.numberFormat);
3288
4090
  }));
3289
4091
  if (a && t.length > 0) {
3290
4092
  let n = o.map((n, r) => {
3291
4093
  let i = (e.fields || []).find((e) => e.name === n.name);
3292
4094
  if (i?.aggregation) {
3293
- let e = yt(r), n = t.length + 1;
4095
+ let e = Qt(r), n = t.length + 1;
3294
4096
  switch (i.aggregation) {
3295
4097
  case "sum": return `=SUM(${e}2:${e}${n})`;
3296
4098
  case "avg": return `=AVERAGE(${e}2:${e}${n})`;
@@ -3304,15 +4106,15 @@ function mt(e, t, n = {}) {
3304
4106
  });
3305
4107
  c.push(n);
3306
4108
  }
3307
- xt("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
4109
+ en("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
3308
4110
  }
3309
- function ht(e, t, n, r) {
4111
+ function Jt(e, t, n, r) {
3310
4112
  return async () => {
3311
4113
  let i = e.schedule;
3312
4114
  if (!i?.enabled) return [];
3313
4115
  let a = i.formats || [e.defaultExportFormat || "pdf"], o = [];
3314
4116
  for (let r of a) {
3315
- let i = await pt(e, {
4117
+ let i = await Kt(e, {
3316
4118
  dataSource: t,
3317
4119
  resource: n,
3318
4120
  format: r
@@ -3322,16 +4124,16 @@ function ht(e, t, n, r) {
3322
4124
  return r(e, i), o;
3323
4125
  };
3324
4126
  }
3325
- function gt(e) {
4127
+ function Yt(e) {
3326
4128
  return {
3327
4129
  name: e.name,
3328
4130
  header: e.label || e.name
3329
4131
  };
3330
4132
  }
3331
- function _t(e, t) {
3332
- return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US", vt(t)) : bt(String(e));
4133
+ function Xt(e, t) {
4134
+ return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US", Zt(t)) : $t(String(e));
3333
4135
  }
3334
- function vt(e) {
4136
+ function Zt(e) {
3335
4137
  if (e.includes("%")) return {
3336
4138
  style: "percent",
3337
4139
  minimumFractionDigits: 0
@@ -3342,23 +4144,23 @@ function vt(e) {
3342
4144
  maximumFractionDigits: Math.max(0, t - 1)
3343
4145
  };
3344
4146
  }
3345
- function yt(e) {
4147
+ function Qt(e) {
3346
4148
  let t = "", n = e;
3347
4149
  for (; n >= 0;) t = String.fromCharCode(n % 26 + 65) + t, n = Math.floor(n / 26) - 1;
3348
4150
  return t;
3349
4151
  }
3350
- function bt(e) {
4152
+ function $t(e) {
3351
4153
  if (e.length > 0) {
3352
4154
  let t = e.charAt(0);
3353
4155
  if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `'${e}`;
3354
4156
  }
3355
4157
  return e;
3356
4158
  }
3357
- function xt(e, t, n) {
4159
+ function en(e, t, n) {
3358
4160
  let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
3359
4161
  a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
3360
4162
  }
3361
- e.register("report", X, {
4163
+ e.register("report", Qe, {
3362
4164
  namespace: "report",
3363
4165
  label: "Report",
3364
4166
  category: "Report",
@@ -3379,7 +4181,7 @@ e.register("report", X, {
3379
4181
  label: "Chart Configuration"
3380
4182
  }
3381
4183
  ]
3382
- }), e.register("spec-report", X, {
4184
+ }), e.register("spec-report", Qe, {
3383
4185
  namespace: "report",
3384
4186
  label: "Spec Report",
3385
4187
  category: "Report",
@@ -3392,7 +4194,7 @@ e.register("report", X, {
3392
4194
  type: "string",
3393
4195
  label: "Report Type"
3394
4196
  }]
3395
- }), e.register("report-viewer", et, {
4197
+ }), e.register("report-viewer", pt, {
3396
4198
  namespace: "report",
3397
4199
  label: "Report Viewer",
3398
4200
  category: "Report",
@@ -3405,7 +4207,7 @@ e.register("report", X, {
3405
4207
  type: "boolean",
3406
4208
  label: "Show Toolbar"
3407
4209
  }]
3408
- }), e.register("report-builder", nt, {
4210
+ }), e.register("report-builder", ht, {
3409
4211
  namespace: "report",
3410
4212
  label: "Report Builder",
3411
4213
  category: "Report",
@@ -3416,4 +4218,4 @@ e.register("report", X, {
3416
4218
  }]
3417
4219
  });
3418
4220
  //#endregion
3419
- export { Be as JoinedReportRenderer, B as LegacyReportRenderer, Le as MatrixRenderer, nt as ReportBuilder, ft as ReportConfigPanel, X as ReportRenderer, et as ReportViewer, tt as ScheduleConfig, Me as SpecReportGrid, W as aggregateRows, H as bucketDate, _e as buildAggregateQuery, we as buildDrillAction, ge as collectFields, V as columnKey, Ee as createDrillHandler, ht as createScheduleTrigger, He as exportAsCSV, Ke as exportAsExcel, We as exportAsHTML, Ue as exportAsJSON, Ge as exportAsPDF, mt as exportExcelWithFormulas, qe as exportReport, pt as exportWithLiveData, $ as formatValue, le as groupAndAggregate, U as groupingValue, Te as isDrillAction, K as mergeFilters, ue as pivotRows, De as registerDrillHandler, ye as useReportData };
4221
+ export { St as JoinedBlocksEditor, Xe as JoinedReportRenderer, ge as LegacyReportRenderer, Ke as MatrixRenderer, ht as ReportBuilder, Gt as ReportConfigPanel, Qe as ReportRenderer, pt as ReportViewer, mt as ScheduleConfig, Ve as SpecReportGrid, q as aggregateRows, _e as bucketDate, Ee as buildAggregateQuery, Ne as buildDrillAction, Te as collectFields, G as columnKey, Fe as createDrillHandler, Jt as createScheduleTrigger, $e as exportAsCSV, rt as exportAsExcel, tt as exportAsHTML, et as exportAsJSON, nt as exportAsPDF, qt as exportExcelWithFormulas, it as exportReport, Kt as exportWithLiveData, lt as formatValue, ve as groupAndAggregate, K as groupingValue, Pe as isDrillAction, Y as mergeFilters, ye as pivotRows, Ie as registerDrillHandler, Oe as useReportData, Ct as validateJoinedBlocks };