@object-ui/plugin-dashboard 16.1.0 → 17.1.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
@@ -1,22 +1,22 @@
1
- import { ComponentRegistry as e, DATE_RANGE_PRESETS as t, buildChartSeries as n, buildDatasetDrillFilter as r, buildDatasetFieldHelpers as i, buildDimensionLabelMap as a, buildOptionColorMap as o, buildWidgetScopedFilter as s, compareToTrendLabelKey as c, computeDrillFilter as l, dashboardFilterVariableDefs as u, extractRecords as d, findChartSeriesRow as f, formatDimensionValue as p, formatMeasure as m, isDrillEnabled as h, mergeFilters as g, relabelDimensions as _, resolveDashboardFilterDefs as v, resolveDateMacros as y, resolveDrillTitle as b, shiftFilterByCompareTo as x } from "@object-ui/core";
2
- import { PageVariablesProvider as S, SchemaRenderer as C, SchemaRendererContext as w, useActionEngine as T, useDataScope as E, useDnd as D, useDrillNavigation as O, useHasDndProvider as k, useObjectLabel as A, usePageVariables as j } from "@object-ui/react";
3
- import { createSafeTranslation as M, resolveFieldCurrency as ee, useLocalization as te, useObjectTranslation as N, useSafeFieldLabel as ne, useSafeTranslate as P } from "@object-ui/i18n";
4
- import { Button as F, Calendar as I, Card as L, CardContent as re, CardHeader as ie, CardTitle as ae, ChartSkeleton as R, Combobox as z, ConfigPanelRenderer as oe, ConfigRow as se, DataEmptyState as ce, Dialog as le, DialogContent as ue, DialogHeader as B, DialogTitle as de, GridSkeleton as V, Input as fe, Popover as pe, PopoverContent as me, PopoverTrigger as he, RefreshIndicator as H, Select as U, SelectContent as ge, SelectItem as W, SelectTrigger as _e, SelectValue as ve, Sheet as ye, SheetContent as be, SheetHeader as xe, SheetTitle as Se, Skeleton as G, cn as K, getLazyIcon as Ce, useConfigDraft as we } from "@object-ui/components";
1
+ import { ComponentRegistry as e, DATE_RANGE_PRESETS as t, buildCategoryOrder as n, buildChartSeries as r, buildDatasetDrillFilter as i, buildDatasetFieldHelpers as a, buildDimensionLabelMap as o, buildOptionColorMap as s, buildWidgetScopedFilter as c, compareToTrendLabelKey as l, computeDrillFilter as u, dashboardFilterVariableDefs as d, extractRecords as f, findChartSeriesRow as p, formatDimensionValue as m, formatMeasure as h, isDrillEnabled as g, mergeFilters as _, relabelDimensions as v, resolveDashboardFilterDefs as y, resolveDrillTitle as b, resolveFilterPlaceholders as x, shiftFilterByCompareTo as S } from "@object-ui/core";
2
+ import { PageVariablesProvider as C, SchemaRenderer as w, SchemaRendererContext as T, useActionEngine as E, useDataScope as ee, useDnd as D, useDrillNavigation as O, useFilterScope as te, useHasDndProvider as k, useObjectLabel as ne, usePageVariables as re } from "@object-ui/react";
3
+ import { createSafeTranslation as A, resolveFieldCurrency as ie, useLocalization as j, useObjectTranslation as M, useSafeFieldLabel as ae, useSafeTranslate as N } from "@object-ui/i18n";
4
+ import { Button as P, Calendar as oe, Card as se, CardContent as F, CardHeader as ce, CardTitle as I, ChartSkeleton as le, Combobox as ue, ConfigPanelRenderer as de, ConfigRow as L, DataEmptyState as R, Dialog as z, DialogContent as fe, DialogHeader as pe, DialogTitle as me, GridSkeleton as B, Input as he, Popover as ge, PopoverContent as V, PopoverTrigger as H, RefreshIndicator as U, Select as _e, SelectContent as ve, SelectItem as W, SelectTrigger as ye, SelectValue as be, Sheet as xe, SheetContent as Se, SheetHeader as Ce, SheetTitle as we, Skeleton as G, cn as K, getLazyIcon as Te, useConfigDraft as Ee } from "@object-ui/components";
5
5
  import * as q from "react";
6
- import Te, { Fragment as Ee, forwardRef as De, useCallback as J, useContext as Oe, useEffect as Y, useMemo as X, useRef as ke, useState as Z } from "react";
7
- import { AlertCircle as Ae, AlertTriangle as je, ArrowDownIcon as Me, ArrowUpIcon as Ne, ArrowUpRight as Pe, BarChart3 as Fe, CalendarIcon as Ie, Download as Le, Edit as Re, GripVertical as ze, Loader2 as Be, MinusIcon as Ve, RefreshCw as He, RotateCcw as Ue, Save as We, Settings as Ge, X as Ke } from "lucide-react";
8
- import { DndContext as qe, PointerSensor as Je, closestCenter as Ye, useSensor as Xe, useSensors as Ze } from "@dnd-kit/core";
9
- import { SortableContext as Qe, arrayMove as $e, rectSortingStrategy as et, useSortable as tt, verticalListSortingStrategy as nt } from "@dnd-kit/sortable";
10
- import { CSS as rt } from "@dnd-kit/utilities";
11
- import { formatCurrency as it, formatDate as at, formatPercent as ot, getCellRenderer as st, resolveCellRendererType as ct } from "@object-ui/fields";
12
- import { Fragment as lt, jsx as Q, jsxs as $ } from "react/jsx-runtime";
13
- import { ResponsiveGridLayout as ut, useContainerWidth as dt } from "react-grid-layout";
6
+ import De, { Fragment as Oe, forwardRef as ke, useCallback as J, useContext as Ae, useEffect as Y, useMemo as X, useRef as je, useState as Z } from "react";
7
+ import { AlertCircle as Me, AlertTriangle as Ne, ArrowDownIcon as Pe, ArrowUpIcon as Fe, ArrowUpRight as Ie, BarChart3 as Le, CalendarIcon as Re, Download as ze, Edit as Be, GripVertical as Ve, Loader2 as He, MinusIcon as Ue, RefreshCw as We, RotateCcw as Ge, Save as Ke, Settings as qe, X as Je } from "lucide-react";
8
+ import { DndContext as Ye, PointerSensor as Xe, closestCenter as Ze, useSensor as Qe, useSensors as $e } from "@dnd-kit/core";
9
+ import { SortableContext as et, arrayMove as tt, rectSortingStrategy as nt, useSortable as rt, verticalListSortingStrategy as it } from "@dnd-kit/sortable";
10
+ import { CSS as at } from "@dnd-kit/utilities";
11
+ import { formatCurrency as ot, formatDate as st, formatPercent as ct, getCellRenderer as lt, resolveCellRendererType as ut } from "@object-ui/fields";
12
+ import { Fragment as dt, jsx as Q, jsxs as $ } from "react/jsx-runtime";
13
+ import { ResponsiveGridLayout as ft, useContainerWidth as pt } from "react-grid-layout";
14
14
  import "react-grid-layout/css/styles.css";
15
15
  //#region src/utils.ts
16
- function ft(e) {
16
+ function mt(e) {
17
17
  return typeof e == "object" && !!e && !Array.isArray(e) && e.provider === "object";
18
18
  }
19
- function pt(e, t) {
19
+ function ht(e, t) {
20
20
  if (t == null || e == null || typeof e != "number" || !Number.isFinite(e) || typeof t != "number" || !Number.isFinite(t)) return null;
21
21
  if (t === 0) return e === 0 ? {
22
22
  value: 0,
@@ -37,8 +37,59 @@ function pt(e, t) {
37
37
  };
38
38
  }
39
39
  //#endregion
40
+ //#region src/widgetDispatch.ts
41
+ var gt = {
42
+ column: "bar",
43
+ "stacked-bar": "bar",
44
+ "grouped-bar": "bar",
45
+ "bi-polar-bar": "bar",
46
+ spline: "line",
47
+ "step-line": "line",
48
+ "stacked-area": "area",
49
+ pyramid: "funnel",
50
+ bubble: "scatter"
51
+ }, _t = /* @__PURE__ */ new Set([
52
+ "bar",
53
+ "horizontal-bar",
54
+ "line",
55
+ "area",
56
+ "pie",
57
+ "donut",
58
+ "scatter",
59
+ "funnel",
60
+ "radar",
61
+ "treemap",
62
+ "sankey"
63
+ ]), vt = /* @__PURE__ */ new Set([
64
+ "metric",
65
+ "gauge",
66
+ "solid-gauge",
67
+ "kpi",
68
+ "bullet"
69
+ ]), yt = /* @__PURE__ */ new Set(["table", "list"]), bt = /* @__PURE__ */ new Set([
70
+ "sunburst",
71
+ "word-cloud",
72
+ "choropleth",
73
+ "bubble-map",
74
+ "gl-map",
75
+ "heatmap",
76
+ "waterfall",
77
+ "box-plot",
78
+ "violin",
79
+ "candlestick",
80
+ "stock"
81
+ ]);
82
+ function xt(e) {
83
+ if (!e) return { family: "passthrough" };
84
+ let t = gt[e] ?? e;
85
+ return _t.has(t) ? {
86
+ family: "series",
87
+ chartType: t
88
+ } : vt.has(e) ? { family: "metric" } : yt.has(e) ? { family: "table" } : e === "pivot" ? { family: "pivot" } : e === "custom" ? { family: "custom" } : bt.has(e) ? { family: "unsupported" } : { family: "passthrough" };
89
+ }
90
+ //#endregion
40
91
  //#region src/recordFields.tsx
41
- var mt = /* @__PURE__ */ new Set([
92
+ var St = /* @__PURE__ */ new Set([
42
93
  "id",
43
94
  "organization_id",
44
95
  "tenant_id",
@@ -52,15 +103,15 @@ var mt = /* @__PURE__ */ new Set([
52
103
  "_id",
53
104
  "__typename"
54
105
  ]);
55
- function ht(e, t) {
56
- return t && (t.isSystem === !0 || t.system === !0) ? !0 : mt.has(e);
106
+ function Ct(e, t) {
107
+ return t && (t.isSystem === !0 || t.system === !0) ? !0 : St.has(e);
57
108
  }
58
- var gt = /* @__PURE__ */ new Set([
109
+ var wt = /* @__PURE__ */ new Set([
59
110
  "select",
60
111
  "picklist",
61
112
  "dropdown",
62
113
  "status"
63
- ]), _t = /* @__PURE__ */ new Set([
114
+ ]), Tt = /* @__PURE__ */ new Set([
64
115
  "currency",
65
116
  "money",
66
117
  "number",
@@ -70,7 +121,7 @@ var gt = /* @__PURE__ */ new Set([
70
121
  "percent",
71
122
  "percentage"
72
123
  ]);
73
- function vt(e) {
124
+ function Et(e) {
74
125
  let t = {}, n = e?.fields;
75
126
  if (!n) return t;
76
127
  if (Array.isArray(n)) for (let e of n) e?.name && (t[e.name] = e);
@@ -80,9 +131,9 @@ function vt(e) {
80
131
  };
81
132
  return t;
82
133
  }
83
- function yt(e) {
134
+ function Dt(e) {
84
135
  let { accessorKey: t, label: n, def: r, objectName: i, fieldOptionLabel: a, overrides: o = {} } = e, s = o.referenceTo ?? r?.referenceTo ?? (typeof r?.reference == "string" ? r.reference : r?.reference?.to) ?? r?.target, c = o.options ?? r?.options;
85
- return i && c && a && gt.has(r?.type) && (c = c.map((e) => {
136
+ return i && c && a && wt.has(r?.type) && (c = c.map((e) => {
86
137
  if (e == null) return e;
87
138
  let n = typeof e == "object" ? e.value : e, r = typeof e == "object" && e.label || String(n);
88
139
  return {
@@ -101,10 +152,10 @@ function yt(e) {
101
152
  decimals: o.decimals ?? r?.decimals ?? r?.scale
102
153
  };
103
154
  }
104
- function bt(e) {
105
- return _t.has(e.type) || typeof e.format == "string" && /^[$¥€£]|%$|0/.test(e.format);
155
+ function Ot(e) {
156
+ return Tt.has(e.type) || typeof e.format == "string" && /^[$¥€£]|%$|0/.test(e.format);
106
157
  }
107
- function xt(e, t, n) {
158
+ function kt(e, t, n) {
108
159
  if (e == null || e === "") return "";
109
160
  let r = t.format;
110
161
  if (typeof r == "string" && /^\$|¥|€|£/.test(r) && typeof e == "number") {
@@ -114,20 +165,20 @@ function xt(e, t, n) {
114
165
  "€": "EUR",
115
166
  "£": "GBP"
116
167
  }[r[0]];
117
- return it(e, t.currency || i || n);
168
+ return ot(e, t.currency || i || n);
118
169
  }
119
170
  if (typeof r == "string" && /%/.test(r) && typeof e == "number") {
120
171
  let t = (r.match(/0\.(0+)%/) || [void 0, ""])[1].length;
121
- return ot((e > 1 ? e / 100 : e) * 100, t);
172
+ return ct((e > 1 ? e / 100 : e) * 100, t);
122
173
  }
123
- return typeof r == "string" && /[YMDHms]/.test(r) ? at(e, r) : /* @__PURE__ */ Q(st(ct(t)), {
174
+ return typeof r == "string" && /[YMDHms]/.test(r) ? st(e, r) : /* @__PURE__ */ Q(lt(ut(t)), {
124
175
  value: e,
125
176
  field: t
126
177
  });
127
178
  }
128
179
  //#endregion
129
180
  //#region src/RecordDetailDrawer.tsx
130
- var St = [
181
+ var At = [
131
182
  "name",
132
183
  "title",
133
184
  "label",
@@ -135,21 +186,21 @@ var St = [
135
186
  "display_name",
136
187
  "full_name"
137
188
  ];
138
- function Ct(e, t) {
189
+ function jt(e, t) {
139
190
  if (t && t.trim()) return t;
140
- for (let t of St) {
191
+ for (let t of At) {
141
192
  let n = e[t];
142
193
  if (typeof n == "string" && n.trim()) return n;
143
194
  }
144
195
  let n = e.id ?? e._id;
145
196
  return n == null ? "Record" : String(n);
146
197
  }
147
- var wt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, target: a = "drawer", onClose: o }) => {
148
- let { fieldLabel: s, fieldOptionLabel: c } = ne(), { currency: l } = te(), u = X(() => {
198
+ var Mt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, target: a = "drawer", onClose: o }) => {
199
+ let { fieldLabel: s, fieldOptionLabel: c } = ae(), { currency: l } = j(), u = X(() => {
149
200
  if (!e) return [];
150
- let i = vt(n), a;
151
- return a = r && r.length > 0 ? r : Object.keys(i).length > 0 ? Object.keys(i).filter((e) => !ht(e, i[e])) : Object.keys(e).filter((e) => !e.startsWith("_") && !ht(e)), a.map((n) => {
152
- let r = i[n], a = n.charAt(0).toUpperCase() + n.slice(1).replace(/([A-Z])/g, " $1").replace(/_/g, " "), o = t ? s(t, n, a) : a, u = yt({
201
+ let i = Et(n), a;
202
+ return a = r && r.length > 0 ? r : Object.keys(i).length > 0 ? Object.keys(i).filter((e) => !Ct(e, i[e])) : Object.keys(e).filter((e) => !e.startsWith("_") && !Ct(e)), a.map((n) => {
203
+ let r = i[n], a = n.charAt(0).toUpperCase() + n.slice(1).replace(/([A-Z])/g, " $1").replace(/_/g, " "), o = t ? s(t, n, a) : a, u = Dt({
153
204
  accessorKey: n,
154
205
  label: o,
155
206
  def: r,
@@ -159,8 +210,8 @@ var wt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
159
210
  return {
160
211
  key: n,
161
212
  label: o,
162
- node: xt(e[n], u, l),
163
- numeric: bt(u)
213
+ node: kt(e[n], u, l),
214
+ numeric: Ot(u)
164
215
  };
165
216
  });
166
217
  }, [
@@ -173,7 +224,7 @@ var wt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
173
224
  l
174
225
  ]);
175
226
  if (!e) return null;
176
- let d = Ct(e, i), f = /* @__PURE__ */ Q("dl", {
227
+ let d = jt(e, i), f = /* @__PURE__ */ Q("dl", {
177
228
  className: "divide-y divide-border/60",
178
229
  "data-testid": "record-detail-body",
179
230
  children: u.map((e) => /* @__PURE__ */ $("div", {
@@ -190,23 +241,23 @@ var wt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
190
241
  })]
191
242
  }, e.key))
192
243
  });
193
- return a === "dialog" ? /* @__PURE__ */ Q(le, {
244
+ return a === "dialog" ? /* @__PURE__ */ Q(z, {
194
245
  open: !0,
195
246
  onOpenChange: (e) => !e && o(),
196
- children: /* @__PURE__ */ $(ue, {
247
+ children: /* @__PURE__ */ $(fe, {
197
248
  className: "max-w-2xl",
198
- children: [/* @__PURE__ */ Q(B, { children: /* @__PURE__ */ Q(de, { children: d }) }), /* @__PURE__ */ Q("div", {
249
+ children: [/* @__PURE__ */ Q(pe, { children: /* @__PURE__ */ Q(me, { children: d }) }), /* @__PURE__ */ Q("div", {
199
250
  className: "max-h-[70vh] overflow-auto",
200
251
  children: f
201
252
  })]
202
253
  })
203
- }) : /* @__PURE__ */ Q(ye, {
254
+ }) : /* @__PURE__ */ Q(xe, {
204
255
  open: !0,
205
256
  onOpenChange: (e) => !e && o(),
206
- children: /* @__PURE__ */ $(be, {
257
+ children: /* @__PURE__ */ $(Se, {
207
258
  side: "right",
208
259
  className: "w-full sm:max-w-md md:max-w-lg flex flex-col",
209
- children: [/* @__PURE__ */ Q(xe, { children: /* @__PURE__ */ Q(Se, { children: d }) }), /* @__PURE__ */ Q("div", {
260
+ children: [/* @__PURE__ */ Q(Ce, { children: /* @__PURE__ */ Q(we, { children: d }) }), /* @__PURE__ */ Q("div", {
210
261
  className: "flex-1 overflow-auto mt-2 pr-1",
211
262
  children: f
212
263
  })]
@@ -215,13 +266,13 @@ var wt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
215
266
  };
216
267
  //#endregion
217
268
  //#region src/ObjectDataTable.tsx
218
- function Tt(e) {
269
+ function Nt(e) {
219
270
  return e.map((e) => typeof e == "string" ? {
220
271
  header: e.replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (e) => e.toUpperCase()),
221
272
  accessorKey: e
222
273
  } : e);
223
274
  }
224
- function Et(e, t) {
275
+ function Pt(e, t) {
225
276
  if (!t?.fields) return [];
226
277
  let n = {};
227
278
  if (Array.isArray(t.fields)) for (let e of t.fields) e?.name && (n[e.name] = e);
@@ -239,14 +290,14 @@ function Et(e, t) {
239
290
  } else for (let [e, t] of Object.entries(n)) r(t?.type) && a.add(e);
240
291
  return Array.from(a);
241
292
  }
242
- var Dt = ({ schema: e, dataSource: t, className: n }) => {
243
- let { currency: r } = te(), i = Oe(w), a = t || i?.dataSource, o = E(e.bind), { fieldLabel: s, fieldOptionLabel: c } = ne(), l = "No data available", u = "No data source available for", { t: f } = N(), p = f("dashboard.noDataAvailable");
293
+ var Ft = ({ schema: e, dataSource: t, className: n }) => {
294
+ let { currency: r } = j(), i = Ae(T), a = t || i?.dataSource, o = ee(e.bind), { fieldLabel: s, fieldOptionLabel: c } = ae(), l = "No data available", u = "No data source available for", { t: d } = M(), p = d("dashboard.noDataAvailable");
244
295
  p && p !== "dashboard.noDataAvailable" && (l = p);
245
- let m = f("dashboard.noDataSourceFor");
296
+ let m = d("dashboard.noDataSourceFor");
246
297
  m && m !== "dashboard.noDataSourceFor" && (u = m);
247
- let [g, _] = Z([]), [v, b] = Z(null), [x, S] = Z(() => !(Array.isArray(e.data) && e.data.length > 0) && !!e.objectName), [T, D] = Z(null), O = e.drillDown, k = h(O) && (O?.mode ?? "record") === "record", [A, j] = Z(null), M = J((e) => {
248
- j(e ?? null);
249
- }, []);
298
+ let [h, _] = Z([]), [v, y] = Z(null), [b, S] = Z(() => !(Array.isArray(e.data) && e.data.length > 0) && !!e.objectName), [C, E] = Z(null), D = e.drillDown, O = g(D) && (D?.mode ?? "record") === "record", [k, ne] = Z(null), re = J((e) => {
299
+ ne(e ?? null);
300
+ }, []), A = te();
250
301
  Y(() => {
251
302
  let t = !0;
252
303
  return e.objectName && !o && (!e.data || e.data.length === 0) ? (async () => {
@@ -254,16 +305,16 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
254
305
  t && S(!1);
255
306
  return;
256
307
  }
257
- t && (S(!0), D(null));
308
+ t && (S(!0), E(null));
258
309
  try {
259
310
  let n;
260
311
  if (typeof a.find == "function") {
261
- let t = Et(e, v), r = { $filter: y(e.filter) };
262
- t.length && (r.$expand = t), n = d(await a.find(e.objectName, r));
312
+ let t = Pt(e, v), r = { $filter: x(e.filter, A) };
313
+ t.length && (r.$expand = t), n = f(await a.find(e.objectName, r));
263
314
  } else return;
264
315
  t && _(n);
265
316
  } catch (e) {
266
- console.error("[ObjectDataTable] Fetch error:", e), t && D(e instanceof Error ? e.message : "Failed to load data");
317
+ console.error("[ObjectDataTable] Fetch error:", e), t && E(e instanceof Error ? e.message : "Failed to load data");
267
318
  } finally {
268
319
  t && S(!1);
269
320
  }
@@ -276,16 +327,17 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
276
327
  o,
277
328
  e.data,
278
329
  e.filter,
279
- v
330
+ v,
331
+ A
280
332
  ]), Y(() => {
281
333
  let t = !0;
282
334
  if (!(!a || !e.objectName || typeof a.getObjectSchema != "function")) return a.getObjectSchema(e.objectName).then((e) => {
283
- t && b(e);
335
+ t && y(e);
284
336
  }).catch(() => {}), () => {
285
337
  t = !1;
286
338
  };
287
339
  }, [e.objectName, a]);
288
- let ee = o || e.data || g, P = Array.isArray(ee) ? ee : [], F = X(() => {
340
+ let ie = o || e.data || h, N = Array.isArray(ie) ? ie : [], P = X(() => {
289
341
  let t = e.objectName, n = {};
290
342
  if (v?.fields) {
291
343
  let e = v.fields;
@@ -299,7 +351,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
299
351
  let n = e.charAt(0).toUpperCase() + e.slice(1).replace(/([A-Z])/g, " $1");
300
352
  return t ? s(t, e, n) : n;
301
353
  }, a = (e) => {
302
- let i = yt({
354
+ let i = Dt({
303
355
  accessorKey: e.accessorKey,
304
356
  label: e.header,
305
357
  def: n[e.accessorKey],
@@ -313,13 +365,13 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
313
365
  currency: e.currency,
314
366
  decimals: e.decimals
315
367
  }
316
- }), a = e.align ?? (bt(i) ? "right" : void 0);
368
+ }), a = e.align ?? (Ot(i) ? "right" : void 0);
317
369
  if (typeof e.cell == "function") return {
318
370
  ...e,
319
371
  ...i,
320
372
  align: a
321
373
  };
322
- let o = (e) => xt(e, i, r);
374
+ let o = (e) => kt(e, i, r);
323
375
  return {
324
376
  ...e,
325
377
  ...i,
@@ -328,26 +380,26 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
328
380
  };
329
381
  };
330
382
  if (e.columns && e.columns.length > 0) {
331
- let n = Tt(e.columns);
383
+ let n = Nt(e.columns);
332
384
  return (t ? n.map((e) => ({
333
385
  ...e,
334
386
  header: s(t, e.accessorKey, e.header)
335
387
  })) : n).map(a);
336
388
  }
337
- return P.length === 0 ? [] : (Object.keys(n).length > 0 ? Object.keys(n).filter((e) => !ht(e, n[e])) : Object.keys(P[0]).filter((e) => !e.startsWith("_") && !ht(e))).map((e) => a({
389
+ return N.length === 0 ? [] : (Object.keys(n).length > 0 ? Object.keys(n).filter((e) => !Ct(e, n[e])) : Object.keys(N[0]).filter((e) => !e.startsWith("_") && !Ct(e))).map((e) => a({
338
390
  header: i(e),
339
391
  accessorKey: e
340
392
  }));
341
393
  }, [
342
394
  e.columns,
343
395
  e.objectName,
344
- P,
396
+ N,
345
397
  v,
346
398
  s,
347
399
  c,
348
400
  r
349
401
  ]);
350
- if (x && P.length === 0) return /* @__PURE__ */ Q("div", {
402
+ if (b && N.length === 0) return /* @__PURE__ */ Q("div", {
351
403
  className: K("overflow-auto", n),
352
404
  "data-testid": "table-loading",
353
405
  children: /* @__PURE__ */ $("div", {
@@ -376,7 +428,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
376
428
  }, e))]
377
429
  })
378
430
  });
379
- if (T) return /* @__PURE__ */ Q("div", {
431
+ if (C) return /* @__PURE__ */ Q("div", {
380
432
  className: K("overflow-auto", n),
381
433
  "data-testid": "table-error",
382
434
  children: /* @__PURE__ */ $("div", {
@@ -412,11 +464,11 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
412
464
  ]
413
465
  }), /* @__PURE__ */ Q("p", {
414
466
  className: "text-xs",
415
- children: T
467
+ children: C
416
468
  })]
417
469
  })
418
470
  });
419
- if (!a && e.objectName && P.length === 0) return /* @__PURE__ */ Q("div", {
471
+ if (!a && e.objectName && N.length === 0) return /* @__PURE__ */ Q("div", {
420
472
  className: K("overflow-auto", n),
421
473
  children: /* @__PURE__ */ Q("div", {
422
474
  className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
@@ -431,7 +483,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
431
483
  })
432
484
  })
433
485
  });
434
- if (P.length === 0) return /* @__PURE__ */ Q("div", {
486
+ if (N.length === 0) return /* @__PURE__ */ Q("div", {
435
487
  className: K("overflow-auto", n),
436
488
  "data-testid": "table-empty-state",
437
489
  children: /* @__PURE__ */ $("div", {
@@ -473,35 +525,35 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
473
525
  })]
474
526
  })
475
527
  });
476
- let I = {
528
+ let oe = {
477
529
  ...e,
478
530
  type: "data-table",
479
- data: P,
480
- columns: F,
481
- onRowClick: e.onRowClick ?? (k ? M : void 0)
482
- }, L = O?.title && !O.title.includes("${") ? O.title : void 0;
531
+ data: N,
532
+ columns: P,
533
+ onRowClick: e.onRowClick ?? (O ? re : void 0)
534
+ }, se = D?.title && !D.title.includes("${") ? D.title : void 0;
483
535
  return /* @__PURE__ */ $("div", {
484
536
  className: K("relative", n),
485
537
  children: [
486
- /* @__PURE__ */ Q(H, { active: x && P.length > 0 }),
487
- /* @__PURE__ */ Q(C, {
488
- schema: I,
538
+ /* @__PURE__ */ Q(U, { active: b && N.length > 0 }),
539
+ /* @__PURE__ */ Q(w, {
540
+ schema: oe,
489
541
  className: n
490
542
  }),
491
- k && /* @__PURE__ */ Q(wt, {
492
- record: A,
543
+ O && /* @__PURE__ */ Q(Mt, {
544
+ record: k,
493
545
  objectName: e.objectName,
494
546
  objectSchema: v,
495
- fields: O?.columns,
496
- title: L,
497
- target: O?.target === "dialog" ? "dialog" : "drawer",
498
- onClose: () => j(null)
547
+ fields: D?.columns,
548
+ title: se,
549
+ target: D?.target === "dialog" ? "dialog" : "drawer",
550
+ onClose: () => ne(null)
499
551
  })
500
552
  ]
501
553
  });
502
- }, Ot = ({ objectName: e, filter: t, onNavigate: n, className: r }) => {
503
- let { openRecordList: i } = O(), a = P();
504
- return !i || !e ? null : /* @__PURE__ */ $(F, {
554
+ }, It = ({ objectName: e, filter: t, onNavigate: n, className: r }) => {
555
+ let { openRecordList: i } = O(), a = N();
556
+ return !i || !e ? null : /* @__PURE__ */ $(P, {
505
557
  type: "button",
506
558
  variant: "ghost",
507
559
  size: "sm",
@@ -510,14 +562,14 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
510
562
  onClick: () => {
511
563
  i(e, t), n?.();
512
564
  },
513
- children: [a("dashboard.openInList", "Open in list"), /* @__PURE__ */ Q(Pe, { className: "ml-1 h-3.5 w-3.5" })]
565
+ children: [a("dashboard.openInList", "Open in list"), /* @__PURE__ */ Q(Ie, { className: "ml-1 h-3.5 w-3.5" })]
514
566
  });
515
- }, kt = ({ open: e, onClose: t, title: n, target: r = "drawer", objectName: i, filter: a, dataSource: o, columns: s, maxRows: c, className: l, report: u }) => {
567
+ }, Lt = ({ open: e, onClose: t, title: n, target: r = "drawer", objectName: i, filter: a, dataSource: o, columns: s, maxRows: c, className: l, report: u }) => {
516
568
  let { openRecordList: d } = O(), f = u && typeof u == "object" && (Array.isArray(u.columns) || "objectName" in u), p = r === "navigate" && !!d && !f && !!i;
517
- if (Te.useEffect(() => {
569
+ if (De.useEffect(() => {
518
570
  e && p && (d(i, a), t());
519
571
  }, [e, p]), p) return null;
520
- let m = f ? null : /* @__PURE__ */ Q(Ot, {
572
+ let m = f ? null : /* @__PURE__ */ Q(It, {
521
573
  objectName: i,
522
574
  filter: a,
523
575
  onNavigate: t
@@ -526,7 +578,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
526
578
  "data-testid": "drill-down-body",
527
579
  children: f ? (() => {
528
580
  let e = u.filter, t = e ? a ? { $and: [e, a] } : e : a;
529
- return /* @__PURE__ */ Q(C, { schema: {
581
+ return /* @__PURE__ */ Q(w, { schema: {
530
582
  ...u,
531
583
  type: "spec-report",
532
584
  report: {
@@ -535,7 +587,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
535
587
  },
536
588
  filter: t
537
589
  } });
538
- })() : /* @__PURE__ */ Q(Dt, {
590
+ })() : /* @__PURE__ */ Q(Ft, {
539
591
  schema: {
540
592
  type: "object-data-table",
541
593
  objectName: i,
@@ -556,42 +608,42 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
556
608
  dataSource: o
557
609
  })
558
610
  });
559
- return r === "dialog" ? /* @__PURE__ */ Q(le, {
611
+ return r === "dialog" ? /* @__PURE__ */ Q(z, {
560
612
  open: e,
561
613
  onOpenChange: (e) => !e && t(),
562
- children: /* @__PURE__ */ $(ue, {
614
+ children: /* @__PURE__ */ $(fe, {
563
615
  className: "max-w-5xl",
564
- children: [/* @__PURE__ */ $(B, {
616
+ children: [/* @__PURE__ */ $(pe, {
565
617
  className: "flex-row items-center justify-between gap-4 pr-8",
566
- children: [/* @__PURE__ */ Q(de, { children: n }), m]
618
+ children: [/* @__PURE__ */ Q(me, { children: n }), m]
567
619
  }), h]
568
620
  })
569
- }) : /* @__PURE__ */ Q(ye, {
621
+ }) : /* @__PURE__ */ Q(xe, {
570
622
  open: e,
571
623
  onOpenChange: (e) => !e && t(),
572
- children: /* @__PURE__ */ $(be, {
624
+ children: /* @__PURE__ */ $(Se, {
573
625
  side: "right",
574
626
  className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
575
- children: [/* @__PURE__ */ $(xe, {
627
+ children: [/* @__PURE__ */ $(Ce, {
576
628
  className: "flex-row items-center justify-between gap-4 pr-8",
577
- children: [/* @__PURE__ */ Q(Se, { children: n }), m]
629
+ children: [/* @__PURE__ */ Q(we, { children: n }), m]
578
630
  }), /* @__PURE__ */ Q("div", {
579
631
  className: "flex-1 overflow-hidden mt-2",
580
632
  children: h
581
633
  })]
582
634
  })
583
635
  });
584
- }, At = r;
585
- function jt(e, t, n) {
636
+ }, Rt = i;
637
+ function zt(e, t, n) {
586
638
  let r = [], i = [], a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
587
639
  return e.forEach((e, c) => {
588
640
  let l = t.map((t) => String(e[t] ?? "∅")).join(""), u = String(e[n] ?? "∅");
589
641
  a.has(l) || (a.add(l), r.push({
590
642
  id: l,
591
- labels: t.map((t) => p(e[t]))
643
+ labels: t.map((t) => m(e[t]))
592
644
  })), o.has(u) || (o.add(u), i.push({
593
645
  id: u,
594
- label: p(e[n])
646
+ label: m(e[n])
595
647
  })), s.set(`${l} ${u}`, c);
596
648
  }), {
597
649
  rowHeaders: r,
@@ -599,26 +651,26 @@ function jt(e, t, n) {
599
651
  cellIndex: s
600
652
  };
601
653
  }
602
- function Mt(e) {
654
+ function Bt(e) {
603
655
  if (e == null) return "";
604
656
  let t = String(e);
605
657
  return /[",\n\r]/.test(t) ? `"${t.replace(/"/g, "\"\"")}"` : t;
606
658
  }
607
- function Nt(e) {
608
- return e.map((e) => e.map(Mt).join(",")).join("\r\n");
659
+ function Vt(e) {
660
+ return e.map((e) => e.map(Bt).join(",")).join("\r\n");
609
661
  }
610
- function Pt(e, t) {
662
+ function Ht(e, t) {
611
663
  if (typeof document > "u") return;
612
- let n = e && e.trim() ? e.trim() : "export", r = new Blob([`\uFEFF${Nt(t)}`], { type: "text/csv;charset=utf-8;" }), i = URL.createObjectURL(r), a = document.createElement("a");
664
+ let n = e && e.trim() ? e.trim() : "export", r = new Blob([`\uFEFF${Vt(t)}`], { type: "text/csv;charset=utf-8;" }), i = URL.createObjectURL(r), a = document.createElement("a");
613
665
  a.href = i, a.download = n.endsWith(".csv") ? n : `${n}.csv`, document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(i);
614
666
  }
615
- var Ft = /* @__PURE__ */ new Set([
667
+ var Ut = /* @__PURE__ */ new Set([
616
668
  "metric",
617
669
  "kpi",
618
670
  "gauge",
619
671
  "solid-gauge",
620
672
  "bullet"
621
- ]), It = {
673
+ ]), Wt = {
622
674
  bar: "bar",
623
675
  column: "column",
624
676
  "horizontal-bar": "horizontal-bar",
@@ -640,44 +692,47 @@ var Ft = /* @__PURE__ */ new Set([
640
692
  treemap: "treemap",
641
693
  sankey: "sankey"
642
694
  };
643
- function Lt({ widget: e, dataSource: t }) {
644
- let r = String(e?.dataset ?? ""), s = X(() => Array.isArray(e?.dimensions) ? e.dimensions.filter(Boolean) : [], [e]), c = X(() => Array.isArray(e?.values) ? e.values.filter(Boolean) : [], [e]), l = e?.compareTo && typeof e.compareTo == "object" ? e.compareTo : void 0, u = String(e?.type ?? ""), d = Ft.has(u) || s.length === 0, h = u === "table" || u === "pivot", g = u === "pivot" && s.length >= 2, v = g ? s.slice(0, -1) : [], b = g ? s[s.length - 1] : "", x = g ? [
645
- v,
695
+ function Gt({ widget: e, dataSource: t }) {
696
+ let i = String(e?.dataset ?? ""), c = X(() => Array.isArray(e?.dimensions) ? e.dimensions.filter(Boolean) : [], [e]), l = X(() => Array.isArray(e?.values) ? e.values.filter(Boolean) : [], [e]), u = e?.compareTo && typeof e.compareTo == "object" ? e.compareTo : void 0, d = String(e?.type ?? ""), f = Ut.has(d) || c.length === 0, g = d === "table" || d === "pivot", _ = d === "pivot" && c.length >= 2, y = _ ? c.slice(0, -1) : [], b = _ ? c[c.length - 1] : "", S = _ ? [
697
+ y,
646
698
  [b],
647
699
  []
648
- ] : void 0, S = P(), { fieldLabel: w } = ne(), T = e?.filter, E = X(() => T && typeof T == "object" && Object.keys(T).length > 0 ? y(T) : void 0, [T]), [D, O] = Z({
700
+ ] : void 0, C = e?.options && typeof e.options == "object" && !Array.isArray(e.options) ? e.options : {}, T = typeof C.dateGranularity == "string" ? C.dateGranularity : void 0, E = typeof C.sortBy == "string" && C.sortBy ? C.sortBy : void 0, ee = E && (c.includes(E) || l.includes(E)) ? E : void 0, D = ee ? { [ee]: C.sortOrder === "desc" ? "desc" : "asc" } : void 0, O = typeof C.limit == "number" && Number.isFinite(C.limit) && C.limit > 0 ? Math.floor(C.limit) : void 0, k = N(), { fieldLabel: ne } = ae(), re = te(), A = e?.filter, ie = X(() => A && typeof A == "object" && Object.keys(A).length > 0 ? x(A, re) : void 0, [A, re]), [j, M] = Z({
649
701
  status: "idle",
650
702
  rows: []
651
- }), [k, A] = Z(null), [j, M] = Z(null), [ee, te] = Z(null);
703
+ }), [P, oe] = Z(null), [se, F] = Z(null), [ce, I] = Z(null), [ue, de] = Z(null);
652
704
  if (Y(() => {
653
705
  let e = t;
654
706
  if (!e || typeof e.queryDataset != "function") {
655
- O({
707
+ M({
656
708
  status: "error",
657
709
  rows: [],
658
- error: S("dashboard.datasetUnsupported", "This data source does not support dataset queries.")
710
+ error: k("dashboard.datasetUnsupported", "This data source does not support dataset queries.")
659
711
  });
660
712
  return;
661
713
  }
662
- if (c.length === 0) {
663
- O({
714
+ if (l.length === 0) {
715
+ M({
664
716
  status: "idle",
665
717
  rows: []
666
718
  });
667
719
  return;
668
720
  }
669
721
  let n = !1;
670
- return O({
722
+ return M({
671
723
  status: "loading",
672
724
  rows: []
673
- }), e.queryDataset(r, {
674
- dimensions: s,
675
- measures: c,
676
- ...E ? { runtimeFilter: E } : {},
677
- ...l ? { compareTo: l } : {},
678
- ...x ? { totals: { groupings: x } } : {}
725
+ }), e.queryDataset(i, {
726
+ dimensions: c,
727
+ measures: l,
728
+ ...ie ? { runtimeFilter: ie } : {},
729
+ ...u ? { compareTo: u } : {},
730
+ ...S ? { totals: { groupings: S } } : {},
731
+ ...T ? { dateGranularity: T } : {},
732
+ ...D ? { order: D } : {},
733
+ ...O == null ? {} : { limit: O }
679
734
  }).then((e) => {
680
- n || O({
735
+ n || M({
681
736
  status: "ok",
682
737
  rows: Array.isArray(e?.rows) ? e.rows : [],
683
738
  fields: Array.isArray(e?.fields) ? e.fields : [],
@@ -688,7 +743,7 @@ function Lt({ widget: e, dataSource: t }) {
688
743
  totals: Array.isArray(e?.totals) ? e.totals : void 0
689
744
  });
690
745
  }).catch((e) => {
691
- n || O({
746
+ n || M({
692
747
  status: "error",
693
748
  rows: [],
694
749
  error: String(e?.message ?? e)
@@ -696,45 +751,45 @@ function Lt({ widget: e, dataSource: t }) {
696
751
  }), () => {
697
752
  n = !0;
698
753
  };
699
- }, [`${u}|${r}|${s.join(",")}|${c.join(",")}|${JSON.stringify(T ?? null)}|${JSON.stringify(l ?? null)}`]), Y(() => {
700
- if (d || h) {
701
- M(null), te(null);
754
+ }, [`${d}|${i}|${c.join(",")}|${l.join(",")}|${JSON.stringify(A ?? null)}|${JSON.stringify(u ?? null)}|${T ?? ""}|${JSON.stringify(D ?? null)}|${O ?? ""}`]), Y(() => {
755
+ if (f || g) {
756
+ F(null), I(null), de(null);
702
757
  return;
703
758
  }
704
- let e = D.object;
705
- if (!e || s.length === 0) {
706
- M(null), te(null);
759
+ let e = j.object;
760
+ if (!e || c.length === 0) {
761
+ F(null), I(null), de(null);
707
762
  return;
708
763
  }
709
- let t = (e) => D.dimensionFields && D.dimensionFields[e] || e, n = !1;
764
+ let t = (e) => j.dimensionFields && j.dimensionFields[e] || e, r = !1;
710
765
  return (async () => {
711
766
  try {
712
- let r = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(e)}`, {
767
+ let i = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(e)}`, {
713
768
  headers: { accept: "application/json" },
714
769
  credentials: "include"
715
- })).json().catch(() => null), i = r?.item ?? r?.data ?? r, c = o(i?.fields?.[t(s[0])]?.options), l = {};
716
- for (let e of s) {
717
- let n = a(i?.fields?.[t(e)]?.options);
718
- n && (l[e] = n);
770
+ })).json().catch(() => null), a = i?.item ?? i?.data ?? i, l = a?.fields?.[t(c[0])]?.options, u = s(l), d = {};
771
+ for (let e of c) {
772
+ let n = o(a?.fields?.[t(e)]?.options);
773
+ n && (d[e] = n);
719
774
  }
720
- n || (M(c), te(Object.keys(l).length > 0 ? l : null));
775
+ r || (F(u), I(Object.keys(d).length > 0 ? d : null), de(n(l)));
721
776
  } catch {
722
- n || (M(null), te(null));
777
+ r || (F(null), I(null), de(null));
723
778
  }
724
779
  })(), () => {
725
- n = !0;
780
+ r = !0;
726
781
  };
727
782
  }, [
728
- D.object,
729
- D.dimensionFields,
730
- s,
731
- d,
732
- h
733
- ]), c.length === 0) return /* @__PURE__ */ Q("div", {
783
+ j.object,
784
+ j.dimensionFields,
785
+ c,
786
+ f,
787
+ g
788
+ ]), l.length === 0) return /* @__PURE__ */ Q("div", {
734
789
  className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
735
- children: S("dashboard.pickMeasures", "Pick measures (values) for this dataset widget.")
790
+ children: k("dashboard.pickMeasures", "Pick measures (values) for this dataset widget.")
736
791
  });
737
- if (D.status === "loading" || D.status === "idle") return /* @__PURE__ */ $("div", {
792
+ if (j.status === "loading" || j.status === "idle") return /* @__PURE__ */ $("div", {
738
793
  className: "h-full w-full p-2",
739
794
  "data-testid": "dataset-loading",
740
795
  role: "status",
@@ -742,79 +797,79 @@ function Lt({ widget: e, dataSource: t }) {
742
797
  "aria-live": "polite",
743
798
  children: [/* @__PURE__ */ Q("span", {
744
799
  className: "sr-only",
745
- children: S("dashboard.loading", "Loading…")
746
- }), d ? /* @__PURE__ */ $("div", {
800
+ children: k("dashboard.loading", "Loading…")
801
+ }), f ? /* @__PURE__ */ $("div", {
747
802
  className: "flex h-full w-full flex-col items-start justify-center gap-2 p-2",
748
803
  children: [/* @__PURE__ */ Q(G, { className: "h-8 w-32 rounded" }), /* @__PURE__ */ Q(G, { className: "h-3 w-20 rounded" })]
749
- }) : h ? /* @__PURE__ */ Q(V, {
804
+ }) : g ? /* @__PURE__ */ Q(B, {
750
805
  className: "h-full",
751
806
  rows: 5,
752
- columns: Math.max(2, s.length + c.length)
753
- }) : /* @__PURE__ */ Q(R, { className: "h-full" })]
807
+ columns: Math.max(2, c.length + l.length)
808
+ }) : /* @__PURE__ */ Q(le, { className: "h-full" })]
754
809
  });
755
- if (D.status === "error") return /* @__PURE__ */ $("div", {
810
+ if (j.status === "error") return /* @__PURE__ */ $("div", {
756
811
  role: "alert",
757
812
  className: "flex h-full w-full items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive",
758
- children: [/* @__PURE__ */ Q(je, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ Q("span", {
813
+ children: [/* @__PURE__ */ Q(Ne, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ Q("span", {
759
814
  className: "break-words",
760
- children: D.error
815
+ children: j.error
761
816
  })]
762
817
  });
763
- if (D.rows.length === 0 && !d) return /* @__PURE__ */ $("div", {
818
+ if (j.rows.length === 0 && !f) return /* @__PURE__ */ $("div", {
764
819
  className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
765
- children: [/* @__PURE__ */ Q(Fe, { className: "mr-2 h-4 w-4" }), S("dashboard.noRows", "No rows")]
820
+ children: [/* @__PURE__ */ Q(Le, { className: "mr-2 h-4 w-4" }), k("dashboard.noRows", "No rows")]
766
821
  });
767
- let { measureField: N, headerLabel: F } = i(D.fields, D.object, w), { object: I, dimensionFields: L, drillRawRows: re, drillRanges: ie } = D, ae = L ? s.filter((e) => e in L) : [], z = !!I && (ae.length > 0 || !!ie?.length), oe = (t, n) => {
768
- if (!I) return;
769
- let r = At(re?.[t], ae, L ?? {}, E, ie?.[t]);
770
- A({
822
+ let { measureField: L, headerLabel: R } = a(j.fields, j.object, ne), { object: z, dimensionFields: fe, drillRawRows: pe, drillRanges: me } = j, he = fe ? c.filter((e) => e in fe) : [], ge = !!z && (he.length > 0 || !!me?.length), V = (t, n) => {
823
+ if (!z) return;
824
+ let r = Rt(pe?.[t], he, fe ?? {}, ie, me?.[t]);
825
+ oe({
771
826
  filter: r,
772
827
  title: n || String(e?.title ?? "")
773
828
  });
774
- }, se = k && I ? /* @__PURE__ */ Q(kt, {
829
+ }, H = P && z ? /* @__PURE__ */ Q(Lt, {
775
830
  open: !0,
776
- onClose: () => A(null),
777
- title: k.title || String(e?.title ?? S("dashboard.details", "Details")),
778
- objectName: I,
779
- filter: k.filter,
831
+ onClose: () => oe(null),
832
+ title: P.title || String(e?.title ?? k("dashboard.details", "Details")),
833
+ objectName: z,
834
+ filter: P.filter,
780
835
  dataSource: t
781
836
  }) : null;
782
- if (d) {
783
- let e = N(c[0]);
837
+ if (f) {
838
+ let e = L(l[0]);
784
839
  return /* @__PURE__ */ $("div", {
785
840
  className: "flex h-full w-full flex-col items-start justify-center gap-1 p-2",
786
841
  children: [/* @__PURE__ */ Q("span", {
787
842
  className: "text-2xl font-semibold tabular-nums",
788
- children: m(D.rows[0]?.[c[0]] ?? 0, e?.format, e?.currency)
843
+ children: h(j.rows[0]?.[l[0]] ?? 0, e?.format, e?.currency)
789
844
  }), /* @__PURE__ */ Q("span", {
790
845
  className: "text-xs text-muted-foreground",
791
- children: F(c[0])
846
+ children: R(l[0])
792
847
  })]
793
848
  });
794
849
  }
795
- if (h) {
796
- let t = [...s, ...c], n = /* @__PURE__ */ Q("button", {
850
+ if (g) {
851
+ let t = [...c, ...l], n = /* @__PURE__ */ Q("button", {
797
852
  type: "button",
798
- onClick: () => Pt(String(e?.title ?? r ?? "export"), [t.map((e) => F(e)), ...D.rows.map((e) => t.map((t) => {
853
+ onClick: () => Ht(String(e?.title ?? i ?? "export"), [t.map((e) => R(e)), ...j.rows.map((e) => t.map((t) => {
799
854
  let n = e[t];
800
855
  return n == null ? "" : typeof n == "number" ? n : String(n);
801
856
  }))]),
802
857
  "data-testid": "dataset-export",
803
- title: S("dashboard.exportCsv", "Export CSV"),
804
- "aria-label": S("dashboard.exportCsv", "Export CSV"),
858
+ title: k("dashboard.exportCsv", "Export CSV"),
859
+ "aria-label": k("dashboard.exportCsv", "Export CSV"),
805
860
  className: "absolute right-1 top-1 z-10 rounded p-1 text-muted-foreground opacity-70 hover:bg-accent/50 hover:text-foreground hover:opacity-100",
806
- children: /* @__PURE__ */ Q(Le, { className: "h-3.5 w-3.5" })
861
+ children: /* @__PURE__ */ Q(ze, { className: "h-3.5 w-3.5" })
807
862
  });
808
- if (g) {
809
- let e = jt(D.rows, v, b), t = e.colHeaders.flatMap((e) => c.map((t) => ({
863
+ if (_) {
864
+ let e = zt(j.rows, y, b), t = e.colHeaders.flatMap((e) => l.map((t) => ({
810
865
  col: e,
811
866
  measure: t,
812
- header: c.length === 1 ? e.label : `${e.label} · ${F(t)}`
813
- }))), r = (e, t) => m(e, N(t)?.format, N(t)?.currency), i = (e) => D.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows, a = /* @__PURE__ */ new Map();
814
- for (let e of i(v) ?? []) a.set(v.map((t) => String(e[t] ?? "∅")).join(""), e);
867
+ header: l.length === 1 ? e.label : `${e.label} · ${R(t)}`
868
+ }))), r = (e, t) => h(e, L(t)?.format, L(t)?.currency), i = (e) => j.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows, a = /* @__PURE__ */ new Map();
869
+ for (let e of i(y) ?? []) a.set(y.map((t) => String(e[t] ?? "∅")).join(""), e);
815
870
  let o = /* @__PURE__ */ new Map();
816
871
  for (let e of i([b]) ?? []) o.set(String(e[b] ?? "∅"), e);
817
- let s = i([])?.[0], l = a.size > 0, u = o.size > 0, d = S("dashboard.total", "Total");
872
+ let s = i([])?.[0], c = a.size > 0, u = o.size > 0, d = k("dashboard.total", "Total");
818
873
  return /* @__PURE__ */ $("div", {
819
874
  className: "relative h-full w-full overflow-auto p-1",
820
875
  "data-testid": "dataset-matrix",
@@ -825,18 +880,18 @@ function Lt({ widget: e, dataSource: t }) {
825
880
  children: [/* @__PURE__ */ Q("thead", {
826
881
  className: "bg-muted/40",
827
882
  children: /* @__PURE__ */ $("tr", { children: [
828
- v.map((e) => /* @__PURE__ */ Q("th", {
883
+ y.map((e) => /* @__PURE__ */ Q("th", {
829
884
  className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
830
- children: F(e)
885
+ children: R(e)
831
886
  }, e)),
832
887
  t.map((e) => /* @__PURE__ */ Q("th", {
833
888
  className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
834
889
  children: e.header
835
890
  }, `${e.col.id}-${e.measure}`)),
836
- l && c.map((e) => /* @__PURE__ */ Q("th", {
891
+ c && l.map((e) => /* @__PURE__ */ Q("th", {
837
892
  className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
838
893
  "data-testid": "matrix-total-col-header",
839
- children: c.length === 1 ? d : `${d} · ${F(e)}`
894
+ children: l.length === 1 ? d : `${d} · ${R(e)}`
840
895
  }, `total-${e}`))
841
896
  ] })
842
897
  }), /* @__PURE__ */ $("tbody", { children: [e.rowHeaders.map((n) => /* @__PURE__ */ $("tr", {
@@ -847,15 +902,15 @@ function Lt({ widget: e, dataSource: t }) {
847
902
  children: e
848
903
  }, t)),
849
904
  t.map((t) => {
850
- let i = e.cellIndex.get(`${n.id} ${t.col.id}`), a = i == null ? void 0 : D.rows[i], o = z && i != null, s = [...n.labels, t.col.label].filter(Boolean).join(" / ");
905
+ let i = e.cellIndex.get(`${n.id} ${t.col.id}`), a = i == null ? void 0 : j.rows[i], o = ge && i != null, s = [...n.labels, t.col.label].filter(Boolean).join(" / ");
851
906
  return /* @__PURE__ */ Q("td", {
852
907
  className: K("px-2 py-1 text-right tabular-nums whitespace-nowrap", o && "cursor-pointer hover:bg-accent/40"),
853
908
  "data-testid": o ? "dataset-drill-cell" : void 0,
854
- onClick: o ? () => oe(i, s) : void 0,
909
+ onClick: o ? () => V(i, s) : void 0,
855
910
  children: a ? r(a[t.measure], t.measure) : "—"
856
911
  }, `${t.col.id}-${t.measure}`);
857
912
  }),
858
- l && c.map((e) => /* @__PURE__ */ Q("td", {
913
+ c && l.map((e) => /* @__PURE__ */ Q("td", {
859
914
  className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
860
915
  "data-testid": "matrix-row-total",
861
916
  children: r(a.get(n.id)?.[e], e)
@@ -865,8 +920,8 @@ function Lt({ widget: e, dataSource: t }) {
865
920
  className: "border-t bg-muted/30 font-medium",
866
921
  "data-testid": "matrix-total-row",
867
922
  children: [
868
- v.length > 0 && /* @__PURE__ */ Q("td", {
869
- colSpan: v.length,
923
+ y.length > 0 && /* @__PURE__ */ Q("td", {
924
+ colSpan: y.length,
870
925
  className: "px-2 py-1 whitespace-nowrap",
871
926
  children: d
872
927
  }),
@@ -874,7 +929,7 @@ function Lt({ widget: e, dataSource: t }) {
874
929
  className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
875
930
  children: r(o.get(e.col.id)?.[e.measure], e.measure)
876
931
  }, `${e.col.id}-${e.measure}`)),
877
- l && c.map((e) => /* @__PURE__ */ Q("td", {
932
+ c && l.map((e) => /* @__PURE__ */ Q("td", {
878
933
  className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
879
934
  "data-testid": "matrix-grand-total",
880
935
  children: r(s?.[e], e)
@@ -882,11 +937,11 @@ function Lt({ widget: e, dataSource: t }) {
882
937
  ]
883
938
  })] })]
884
939
  }),
885
- se
940
+ H
886
941
  ]
887
942
  });
888
943
  }
889
- let i = [...s, ...c];
944
+ let r = [...c, ...l];
890
945
  return /* @__PURE__ */ $("div", {
891
946
  className: "relative h-full w-full overflow-auto p-1",
892
947
  children: [
@@ -895,79 +950,83 @@ function Lt({ widget: e, dataSource: t }) {
895
950
  className: "w-full text-xs",
896
951
  children: [/* @__PURE__ */ Q("thead", {
897
952
  className: "bg-muted/40",
898
- children: /* @__PURE__ */ Q("tr", { children: i.map((e) => /* @__PURE__ */ Q("th", {
953
+ children: /* @__PURE__ */ Q("tr", { children: r.map((e) => /* @__PURE__ */ Q("th", {
899
954
  className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
900
- children: F(e)
955
+ children: R(e)
901
956
  }, e)) })
902
- }), /* @__PURE__ */ Q("tbody", { children: D.rows.map((e, t) => /* @__PURE__ */ Q("tr", {
903
- className: K("border-t", z && "cursor-pointer hover:bg-accent/40"),
904
- "data-testid": z ? "dataset-drill-row" : void 0,
905
- onClick: z ? () => oe(t, ae.map((t) => p(e[t])).filter(Boolean).join(" / ")) : void 0,
906
- children: i.map((t) => /* @__PURE__ */ Q("td", {
957
+ }), /* @__PURE__ */ Q("tbody", { children: j.rows.map((e, t) => /* @__PURE__ */ Q("tr", {
958
+ className: K("border-t", ge && "cursor-pointer hover:bg-accent/40"),
959
+ "data-testid": ge ? "dataset-drill-row" : void 0,
960
+ onClick: ge ? () => V(t, he.map((t) => m(e[t])).filter(Boolean).join(" / ")) : void 0,
961
+ children: r.map((t) => /* @__PURE__ */ Q("td", {
907
962
  className: "px-2 py-1 whitespace-nowrap tabular-nums",
908
- children: c.includes(t) ? m(e[t], N(t)?.format, N(t)?.currency) : p(e[t])
963
+ children: l.includes(t) ? h(e[t], L(t)?.format, L(t)?.currency) : m(e[t])
909
964
  }, t))
910
965
  }, t)) })]
911
966
  }),
912
- se
967
+ H
913
968
  ]
914
969
  });
915
970
  }
916
- let ce = It[u] ?? "bar", le = _(D.rows, ee), { data: ue, xAxisKey: B, series: de } = n(le, s, c, D.fields), fe = z ? (e) => {
917
- let t = f(le, s, c, e?.category, e?.series);
971
+ let U = Wt[d] ?? "bar", _e = v(j.rows, ce), { data: ve, xAxisKey: W, series: ye } = r(_e, c, l, j.fields), be = (Array.isArray(C.stageOrder) ? C.stageOrder : void 0)?.flatMap((e) => {
972
+ let t = String(e), n = ce?.[c[0]]?.[t];
973
+ return n && n !== t ? [t, n] : [t];
974
+ }), xe = be?.length ? be : ue, Se = ge ? (e) => {
975
+ let t = p(_e, c, l, e?.category, e?.series);
918
976
  if (t < 0) return;
919
- let n = s.length >= 2 && c.length === 1, r = [e?.category, n ? e?.series : void 0].filter(Boolean).map(String).join(" / ");
920
- oe(t, r);
977
+ let n = c.length >= 2 && l.length === 1, r = [e?.category, n ? e?.series : void 0].filter(Boolean).map(String).join(" / ");
978
+ V(t, r);
921
979
  } : void 0;
922
980
  return /* @__PURE__ */ $("div", {
923
981
  className: K("relative h-full w-full min-h-[220px]"),
924
- children: [/* @__PURE__ */ Q(C, {
982
+ children: [/* @__PURE__ */ Q(w, {
925
983
  schema: {
926
984
  type: "chart",
927
- chartType: ce,
928
- data: ue,
929
- xAxisKey: B,
930
- series: de,
985
+ chartType: U,
986
+ data: ve,
987
+ xAxisKey: W,
988
+ series: ye,
931
989
  isAnimationActive: !1,
932
- ...j ? { categoryColors: j } : {}
990
+ ...se ? { categoryColors: se } : {},
991
+ ...xe ? { categoryOrder: xe } : {}
933
992
  },
934
- onChartClick: fe,
935
- onSegmentClick: fe
936
- }), se]
993
+ onChartClick: Se,
994
+ onSegmentClick: Se
995
+ }), H]
937
996
  });
938
997
  }
939
998
  //#endregion
940
999
  //#region src/DashboardFilterBar.tsx
941
- var Rt = "__all__", zt = "__custom__";
942
- function Bt(e, t) {
1000
+ var Kt = "__all__", qt = "__custom__";
1001
+ function Jt(e, t) {
943
1002
  if (e) {
944
1003
  if (e.preset) return t(e.preset);
945
1004
  if (e.from || e.to) return `${e.from ?? "…"} – ${e.to ?? "…"}`;
946
1005
  }
947
1006
  }
948
- function Vt(e) {
1007
+ function Yt(e) {
949
1008
  return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
950
1009
  }
951
- function Ht({ def: e, value: n, onChange: r }) {
952
- let i = P(), [a, o] = Z(!1), s = e.allowCustomRange !== !1, c = (e) => i(`dashboard.filters.range.${e}`, e.replace(/_/g, " ")), l = n?.preset ?? (n?.from || n?.to ? zt : Rt);
1010
+ function Xt({ def: e, value: n, onChange: r }) {
1011
+ let i = N(), [a, o] = Z(!1), s = e.allowCustomRange !== !1, c = (e) => i(`dashboard.filters.range.${e}`, e.replace(/_/g, " ")), l = n?.preset ?? (n?.from || n?.to ? qt : Kt);
953
1012
  return /* @__PURE__ */ $("div", {
954
1013
  className: "flex items-center gap-1",
955
1014
  "data-testid": `dashboard-filter-${e.name}`,
956
- children: [/* @__PURE__ */ $(U, {
1015
+ children: [/* @__PURE__ */ $(_e, {
957
1016
  value: l,
958
1017
  onValueChange: (e) => {
959
- e === Rt ? r(void 0) : e === zt ? o(!0) : r({ preset: e });
1018
+ e === Kt ? r(void 0) : e === qt ? o(!0) : r({ preset: e });
960
1019
  },
961
- children: [/* @__PURE__ */ $(_e, {
1020
+ children: [/* @__PURE__ */ $(ye, {
962
1021
  className: "h-8 w-auto min-w-36 gap-1",
963
1022
  "aria-label": e.label || i("dashboard.filters.dateRange", "Date range"),
964
- children: [/* @__PURE__ */ Q(Ie, { className: "size-3.5 opacity-60" }), /* @__PURE__ */ Q(ve, {
1023
+ children: [/* @__PURE__ */ Q(Re, { className: "size-3.5 opacity-60" }), /* @__PURE__ */ Q(be, {
965
1024
  placeholder: i("dashboard.filters.dateRange", "Date range"),
966
- children: Bt(n, c) ?? i("dashboard.filters.allTime", "All time")
1025
+ children: Jt(n, c) ?? i("dashboard.filters.allTime", "All time")
967
1026
  })]
968
- }), /* @__PURE__ */ $(ge, { children: [
1027
+ }), /* @__PURE__ */ $(ve, { children: [
969
1028
  /* @__PURE__ */ Q(W, {
970
- value: Rt,
1029
+ value: Kt,
971
1030
  children: i("dashboard.filters.allTime", "All time")
972
1031
  }),
973
1032
  t.map((e) => /* @__PURE__ */ Q(W, {
@@ -975,23 +1034,23 @@ function Ht({ def: e, value: n, onChange: r }) {
975
1034
  children: c(e)
976
1035
  }, e)),
977
1036
  s && /* @__PURE__ */ Q(W, {
978
- value: zt,
1037
+ value: qt,
979
1038
  children: i("dashboard.filters.custom", "Custom…")
980
1039
  })
981
1040
  ] })]
982
- }), s && /* @__PURE__ */ $(pe, {
1041
+ }), s && /* @__PURE__ */ $(ge, {
983
1042
  open: a,
984
1043
  onOpenChange: o,
985
- children: [/* @__PURE__ */ Q(he, {
1044
+ children: [/* @__PURE__ */ Q(H, {
986
1045
  asChild: !0,
987
1046
  children: /* @__PURE__ */ Q("span", {
988
1047
  "aria-hidden": !0,
989
1048
  className: "size-0"
990
1049
  })
991
- }), /* @__PURE__ */ Q(me, {
1050
+ }), /* @__PURE__ */ Q(V, {
992
1051
  className: "w-auto p-0",
993
1052
  align: "start",
994
- children: /* @__PURE__ */ Q(I, {
1053
+ children: /* @__PURE__ */ Q(oe, {
995
1054
  mode: "range",
996
1055
  numberOfMonths: 2,
997
1056
  selected: {
@@ -1004,8 +1063,8 @@ function Ht({ def: e, value: n, onChange: r }) {
1004
1063
  return;
1005
1064
  }
1006
1065
  r({
1007
- ...e?.from ? { from: Vt(e.from) } : {},
1008
- ...e?.to ? { to: Vt(e.to) } : {}
1066
+ ...e?.from ? { from: Yt(e.from) } : {},
1067
+ ...e?.to ? { to: Yt(e.to) } : {}
1009
1068
  });
1010
1069
  }
1011
1070
  })
@@ -1013,8 +1072,8 @@ function Ht({ def: e, value: n, onChange: r }) {
1013
1072
  })]
1014
1073
  });
1015
1074
  }
1016
- function Ut({ def: e, value: t, onChange: n, dataSource: r }) {
1017
- let i = P(), [a, o] = Z(null), s = e.optionsFrom;
1075
+ function Zt({ def: e, value: t, onChange: n, dataSource: r }) {
1076
+ let i = N(), [a, o] = Z(null), s = e.optionsFrom;
1018
1077
  Y(() => {
1019
1078
  if (!s || !r) return;
1020
1079
  let e = !1, t = () => {
@@ -1093,16 +1152,16 @@ function Ut({ def: e, value: t, onChange: n, dataSource: r }) {
1093
1152
  r
1094
1153
  ]);
1095
1154
  let c = X(() => e.options?.length ? e.options : a ?? [], [e.options, a]), l = e.label || e.name, u = t ? c.find((e) => e.value === String(t))?.label ?? String(t) : void 0;
1096
- return /* @__PURE__ */ $(U, {
1097
- value: t ? String(t) : Rt,
1098
- onValueChange: (e) => n(e === Rt ? void 0 : e),
1099
- children: [/* @__PURE__ */ Q(_e, {
1155
+ return /* @__PURE__ */ $(_e, {
1156
+ value: t ? String(t) : Kt,
1157
+ onValueChange: (e) => n(e === Kt ? void 0 : e),
1158
+ children: [/* @__PURE__ */ Q(ye, {
1100
1159
  className: "h-8 w-auto min-w-32",
1101
1160
  "aria-label": l,
1102
1161
  "data-testid": `dashboard-filter-${e.name}`,
1103
- children: /* @__PURE__ */ Q(ve, { children: u ?? `${l}: ${i("dashboard.filters.all", "All")}` })
1104
- }), /* @__PURE__ */ $(ge, { children: [/* @__PURE__ */ Q(W, {
1105
- value: Rt,
1162
+ children: /* @__PURE__ */ Q(be, { children: u ?? `${l}: ${i("dashboard.filters.all", "All")}` })
1163
+ }), /* @__PURE__ */ $(ve, { children: [/* @__PURE__ */ Q(W, {
1164
+ value: Kt,
1106
1165
  children: i("dashboard.filters.all", "All")
1107
1166
  }), c.map((e) => /* @__PURE__ */ Q(W, {
1108
1167
  value: e.value,
@@ -1110,7 +1169,7 @@ function Ut({ def: e, value: t, onChange: n, dataSource: r }) {
1110
1169
  }, e.value))] })]
1111
1170
  });
1112
1171
  }
1113
- function Wt({ def: e, value: t, onChange: n }) {
1172
+ function Qt({ def: e, value: t, onChange: n }) {
1114
1173
  let [r, i] = Z(t == null ? "" : String(t));
1115
1174
  Y(() => {
1116
1175
  i(t == null ? "" : String(t));
@@ -1123,7 +1182,7 @@ function Wt({ def: e, value: t, onChange: n }) {
1123
1182
  }
1124
1183
  n(e.type === "number" ? Number(t) : t);
1125
1184
  };
1126
- return /* @__PURE__ */ Q(fe, {
1185
+ return /* @__PURE__ */ Q(he, {
1127
1186
  className: "h-8 w-36",
1128
1187
  type: e.type === "number" ? "number" : "text",
1129
1188
  placeholder: e.label || e.name,
@@ -1137,8 +1196,8 @@ function Wt({ def: e, value: t, onChange: n }) {
1137
1196
  "data-testid": `dashboard-filter-${e.name}`
1138
1197
  });
1139
1198
  }
1140
- function Gt({ defs: e, values: t, onChange: n, onReset: r, dataSource: i, className: a }) {
1141
- let o = P();
1199
+ function $t({ defs: e, values: t, onChange: n, onReset: r, dataSource: i, className: a }) {
1200
+ let o = N();
1142
1201
  if (e.length === 0) return null;
1143
1202
  let s = (e) => e == null || e === "" || typeof e == "object" && Object.keys(e).length === 0, c = e.some((e) => {
1144
1203
  let n = t[e.name], r = e.defaultValue;
@@ -1151,40 +1210,40 @@ function Gt({ defs: e, values: t, onChange: n, onReset: r, dataSource: i, classN
1151
1210
  "aria-label": o("dashboard.filters.label", "Dashboard filters"),
1152
1211
  children: [e.map((e) => {
1153
1212
  let r = t[e.name], a = (t) => n(e.name, t);
1154
- return e.type === "dateRange" || e.type === "date" ? /* @__PURE__ */ Q(Ht, {
1213
+ return e.type === "dateRange" || e.type === "date" ? /* @__PURE__ */ Q(Xt, {
1155
1214
  def: e,
1156
1215
  value: r,
1157
1216
  onChange: a
1158
- }, e.name) : e.type === "select" || e.type === "lookup" ? /* @__PURE__ */ Q(Ut, {
1217
+ }, e.name) : e.type === "select" || e.type === "lookup" ? /* @__PURE__ */ Q(Zt, {
1159
1218
  def: e,
1160
1219
  value: r,
1161
1220
  onChange: a,
1162
1221
  dataSource: i
1163
- }, e.name) : /* @__PURE__ */ Q(Wt, {
1222
+ }, e.name) : /* @__PURE__ */ Q(Qt, {
1164
1223
  def: e,
1165
1224
  value: r,
1166
1225
  onChange: a
1167
1226
  }, e.name);
1168
- }), r && c && /* @__PURE__ */ $(F, {
1227
+ }), r && c && /* @__PURE__ */ $(P, {
1169
1228
  variant: "ghost",
1170
1229
  size: "sm",
1171
1230
  onClick: r,
1172
1231
  className: "text-muted-foreground",
1173
- children: [/* @__PURE__ */ Q(Ue, { className: "size-3.5" }), o("dashboard.filters.reset", "Reset")]
1232
+ children: [/* @__PURE__ */ Q(Ge, { className: "size-3.5" }), o("dashboard.filters.reset", "Reset")]
1174
1233
  })]
1175
1234
  });
1176
1235
  }
1177
1236
  //#endregion
1178
1237
  //#region src/DashboardRenderer.tsx
1179
- function Kt({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
1180
- let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } = tt({
1238
+ function en({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
1239
+ let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } = rt({
1181
1240
  id: e,
1182
1241
  disabled: t
1183
1242
  });
1184
1243
  return /* @__PURE__ */ Q("div", {
1185
1244
  ref: s,
1186
1245
  style: {
1187
- transform: rt.Transform.toString(c),
1246
+ transform: at.Transform.toString(c),
1188
1247
  transition: l,
1189
1248
  opacity: u ? .4 : 1,
1190
1249
  ...n ? {
@@ -1199,58 +1258,19 @@ function Kt({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
1199
1258
  children: i
1200
1259
  });
1201
1260
  }
1202
- function qt(e) {
1203
- return e ? Ce(e) : null;
1261
+ function tn(e) {
1262
+ return e ? Te(e) : null;
1204
1263
  }
1205
- function Jt(e) {
1264
+ function nn(e) {
1206
1265
  if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
1207
1266
  }
1208
- var Yt = [
1267
+ var rn = [
1209
1268
  "hsl(var(--chart-1))",
1210
1269
  "hsl(var(--chart-2))",
1211
1270
  "hsl(var(--chart-3))",
1212
1271
  "hsl(var(--chart-4))",
1213
1272
  "hsl(var(--chart-5))"
1214
- ], Xt = {
1215
- column: "bar",
1216
- "stacked-bar": "bar",
1217
- "grouped-bar": "bar",
1218
- "bi-polar-bar": "bar",
1219
- spline: "line",
1220
- "step-line": "line",
1221
- "stacked-area": "area",
1222
- pyramid: "funnel",
1223
- bubble: "scatter"
1224
- }, Zt = /* @__PURE__ */ new Set([
1225
- "bar",
1226
- "horizontal-bar",
1227
- "line",
1228
- "area",
1229
- "pie",
1230
- "donut",
1231
- "scatter",
1232
- "funnel",
1233
- "radar",
1234
- "treemap",
1235
- "sankey"
1236
- ]), Qt = /* @__PURE__ */ new Set([
1237
- "gauge",
1238
- "solid-gauge",
1239
- "kpi",
1240
- "bullet"
1241
- ]), $t = /* @__PURE__ */ new Set([
1242
- "sunburst",
1243
- "word-cloud",
1244
- "choropleth",
1245
- "bubble-map",
1246
- "gl-map",
1247
- "heatmap",
1248
- "waterfall",
1249
- "box-plot",
1250
- "violin",
1251
- "candlestick",
1252
- "stock"
1253
- ]), en = /* @__PURE__ */ new Set([
1273
+ ], an = /* @__PURE__ */ new Set([
1254
1274
  "bar",
1255
1275
  "horizontal-bar",
1256
1276
  "line",
@@ -1262,21 +1282,21 @@ var Yt = [
1262
1282
  "treemap",
1263
1283
  "sankey"
1264
1284
  ]);
1265
- function tn(e) {
1266
- return en.has(e) ? { enabled: !0 } : void 0;
1285
+ function on(e) {
1286
+ return an.has(e) ? { enabled: !0 } : void 0;
1267
1287
  }
1268
- var nn = /* @__PURE__ */ new Set([
1288
+ var sn = /* @__PURE__ */ new Set([
1269
1289
  "object-chart",
1270
1290
  "object-metric",
1271
1291
  "object-data-table"
1272
- ]), rn = {
1292
+ ]), cn = {
1273
1293
  type: "text",
1274
1294
  value: "This widget uses a retired data format. Edit it to bind a dataset.",
1275
1295
  variant: "caption",
1276
1296
  align: "center",
1277
1297
  className: "flex h-full w-full items-center justify-center rounded border border-dashed border-destructive/40 bg-destructive/5 p-4 text-center text-destructive"
1278
- }, an = De(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount: i, userActions: a, designMode: o, selectedWidgetId: c, onWidgetClick: l, onWidgetsReorder: u, modalHandler: d, scriptHandlers: f, hideHeaderText: p, ...m }, h) => {
1279
- let _ = (() => {
1298
+ }, ln = ke(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount: i, userActions: a, designMode: o, selectedWidgetId: s, onWidgetClick: l, onWidgetsReorder: u, modalHandler: d, scriptHandlers: f, hideHeaderText: p, ...m }, h) => {
1299
+ let g = (() => {
1280
1300
  if (e.columns != null) return e.columns;
1281
1301
  let t = e.widgets ?? [], n = 0;
1282
1302
  for (let e of t) {
@@ -1284,48 +1304,48 @@ var nn = /* @__PURE__ */ new Set([
1284
1304
  t > n && (n = t), (e.layout?.w ?? 0) > n && (n = e.layout.w);
1285
1305
  }
1286
1306
  return n > 4 ? 12 : 4;
1287
- })(), y = _, b = e.gap || 4, x = e.columns != null || _ !== 4, [S, w] = Z(!1), [E, D] = Z(!1), O = ke(null), k = X(() => v(e), [e.globalFilters, e.dateRange]), { variables: M, setVariable: ee, resetVariables: te } = j(), { executeAction: ne, engine: P } = T({ actions: X(() => (e.header?.actions ?? []).map((e) => ({
1307
+ })(), v = g, b = e.gap || 4, x = e.columns != null || g !== 4, [S, C] = Z(!1), [T, ee] = Z(!1), D = je(null), O = X(() => y(e), [e.globalFilters, e.dateRange]), { variables: te, setVariable: k, resetVariables: A } = re(), { executeAction: ie, engine: j } = E({ actions: X(() => (e.header?.actions ?? []).map((e) => ({
1288
1308
  name: e.actionUrl || e.label,
1289
1309
  type: e.actionType || "url",
1290
1310
  target: e.actionUrl,
1291
1311
  label: e.label
1292
- })), [e.header?.actions]) }), { dashboardLabel: I, dashboardDescription: R, dashboardActionLabel: z, widgetTitle: oe, widgetDescription: se, fieldLabel: ce } = A(), { t: le } = N(), ue = J((e, t, n) => n && (!t || t === "value" || t === "count" || n === "count") ? le(`report.aggregate.${n}`, { defaultValue: n }) : e ? ce(e, t, t) : t, [le, ce]), B = e.name, de = J((e) => {
1293
- if (!B) return e.label;
1312
+ })), [e.header?.actions]) }), { dashboardLabel: ae, dashboardDescription: N, dashboardActionLabel: oe, widgetTitle: le, widgetDescription: ue, fieldLabel: de } = ne(), { t: L } = M(), R = J((e, t, n) => n && (!t || t === "value" || t === "count" || n === "count") ? L(`report.aggregate.${n}`, { defaultValue: n }) : e ? de(e, t, t) : t, [L, de]), z = e.name, fe = J((e) => {
1313
+ if (!z) return e.label;
1294
1314
  let t = e.actionUrl || e.label;
1295
- return z(B, t, e.label);
1296
- }, [B, z]), V = J((e) => {
1297
- let t = Jt(e.title);
1298
- return !B || !e.id || t === void 0 ? t : oe(B, e.id, t);
1299
- }, [B, oe]), fe = J((e) => {
1300
- let t = Jt(e.description);
1301
- return !B || !e.id ? t : se(B, e.id, t);
1302
- }, [B, se]);
1315
+ return oe(z, t, e.label);
1316
+ }, [z, oe]), pe = J((e) => {
1317
+ let t = nn(e.title);
1318
+ return !z || !e.id || t === void 0 ? t : le(z, e.id, t);
1319
+ }, [z, le]), me = J((e) => {
1320
+ let t = nn(e.description);
1321
+ return !z || !e.id ? t : ue(z, e.id, t);
1322
+ }, [z, ue]);
1303
1323
  Y(() => {
1304
- let e = P.getRunner();
1324
+ let e = j.getRunner();
1305
1325
  if (d && e.setModalHandler(d), f) for (let [t, n] of Object.entries(f)) e.registerScript(t, n);
1306
1326
  }, [
1307
- P,
1327
+ j,
1308
1328
  d,
1309
1329
  f
1310
1330
  ]), Y(() => {
1311
- let e = () => D(window.innerWidth < 768);
1331
+ let e = () => ee(window.innerWidth < 768);
1312
1332
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
1313
1333
  }, []);
1314
- let pe = J(() => {
1315
- r && (w(!0), r(), setTimeout(() => w(!1), 600));
1334
+ let B = J(() => {
1335
+ r && (C(!0), r(), setTimeout(() => C(!1), 600));
1316
1336
  }, [r]);
1317
1337
  Y(() => {
1318
- if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return O.current = setInterval(pe, e.refreshInterval * 1e3), () => {
1319
- O.current && clearInterval(O.current);
1338
+ if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return D.current = setInterval(B, e.refreshInterval * 1e3), () => {
1339
+ D.current && clearInterval(D.current);
1320
1340
  };
1321
1341
  }, [
1322
1342
  e.refreshInterval,
1323
1343
  r,
1324
- pe
1344
+ B
1325
1345
  ]);
1326
- let me = J((e, t) => {
1346
+ let he = J((e, t) => {
1327
1347
  !o || !l || !t || (e.stopPropagation(), l(t));
1328
- }, [o, l]), he = J((t, n, r) => {
1348
+ }, [o, l]), ge = J((t, n, r) => {
1329
1349
  if (!o || !l) return;
1330
1350
  let i = e.widgets || [];
1331
1351
  if (t.key === "Enter" || t.key === " ") t.preventDefault(), l(n ?? null);
@@ -1342,109 +1362,107 @@ var nn = /* @__PURE__ */ new Set([
1342
1362
  o,
1343
1363
  l,
1344
1364
  e.widgets
1345
- ]), H = J((e) => {
1365
+ ]), V = J((e) => {
1346
1366
  !o || !l || e.target === e.currentTarget && l(null);
1347
- }, [o, l]), U = !!(o && u), ge = Ze(Xe(Je, { activationConstraint: { distance: 5 } })), W = J((t) => {
1348
- if (!U) return;
1367
+ }, [o, l]), H = !!(o && u), U = $e(Qe(Xe, { activationConstraint: { distance: 5 } })), _e = J((t) => {
1368
+ if (!H) return;
1349
1369
  let { active: n, over: r } = t;
1350
1370
  if (!r || n.id === r.id) return;
1351
1371
  let i = e.widgets ?? [], a = i.findIndex((e) => e.id === n.id), o = i.findIndex((e) => e.id === r.id);
1352
- a < 0 || o < 0 || u?.($e(i, a, o));
1372
+ a < 0 || o < 0 || u?.(tt(i, a, o));
1353
1373
  }, [
1354
- U,
1374
+ H,
1355
1375
  e.widgets,
1356
1376
  u
1357
- ]), _e = (e, t, r) => {
1358
- let i = e.type === "metric" || Qt.has(e.type || ""), a = x ? {
1359
- w: Math.min(i ? 3 : 6, y),
1377
+ ]), ve = (e, t, r) => {
1378
+ let i = e.type === "metric" || vt.has(e.type || ""), a = x ? {
1379
+ w: Math.min(i ? 3 : 6, v),
1360
1380
  h: i ? 2 : 4
1361
1381
  } : void 0, l = e.layout ?? a, u = l ? {
1362
1382
  ...l,
1363
- w: Math.min(l.w, y)
1383
+ w: Math.min(l.w, v)
1364
1384
  } : void 0, d = !!e.dataset, f = () => {
1365
1385
  if (e.component) return e.component;
1366
1386
  let t = e.type, n = e.options || {}, r = e.data || n.data;
1367
- if (!r && e.object) return rn;
1368
- let i = t && Xt[t] || t;
1369
- if (i && Zt.has(i)) {
1370
- let t = n.xField || "name", a = n.yField || "value";
1371
- if (ft(r)) {
1372
- let o = r.aggregate, s = o ? {
1373
- field: o.field,
1374
- function: o.function,
1375
- groupBy: o.groupBy
1376
- } : void 0, c = s?.field || a;
1387
+ if (!r && e.object) return cn;
1388
+ let i = xt(t), a = i.chartType ?? t;
1389
+ if (i.family === "series" && i.chartType) {
1390
+ let t = n.xField || "name", o = n.yField || "value";
1391
+ if (mt(r)) {
1392
+ let s = r.aggregate, c = s ? {
1393
+ field: s.field,
1394
+ function: s.function,
1395
+ groupBy: s.groupBy
1396
+ } : void 0, l = c?.field || o;
1377
1397
  return {
1378
1398
  type: "object-chart",
1379
- chartType: i,
1399
+ chartType: a,
1380
1400
  objectName: r.object,
1381
- aggregate: s,
1401
+ aggregate: c,
1382
1402
  filter: r.filter || e.filter,
1383
1403
  xAxisKey: t,
1384
1404
  series: [{
1385
- dataKey: c,
1386
- label: ue(r.object, c, s?.function)
1405
+ dataKey: l,
1406
+ label: R(r.object, l, c?.function)
1387
1407
  }],
1388
- colors: Yt,
1408
+ colors: rn,
1389
1409
  isAnimationActive: !1,
1390
- drillDown: n.drillDown ?? tn(i),
1410
+ drillDown: n.drillDown ?? on(i.chartType),
1391
1411
  compareTo: e.compareTo,
1392
1412
  className: "h-[200px] sm:h-[250px] md:h-[300px]"
1393
1413
  };
1394
1414
  }
1395
1415
  return {
1396
1416
  type: "chart",
1397
- chartType: i,
1417
+ chartType: a,
1398
1418
  data: Array.isArray(r) ? r : r?.items || [],
1399
1419
  xAxisKey: t,
1400
1420
  series: [{
1401
- dataKey: a,
1402
- label: ue(void 0, a, void 0)
1421
+ dataKey: o,
1422
+ label: R(void 0, o, void 0)
1403
1423
  }],
1404
- colors: Yt,
1424
+ colors: rn,
1405
1425
  isAnimationActive: !1,
1406
1426
  className: "h-[200px] sm:h-[250px] md:h-[300px]"
1407
1427
  };
1408
1428
  }
1409
- if (t === "table") {
1410
- if (ft(r)) {
1411
- let { data: t, ...i } = n;
1429
+ if (i.family === "metric") {
1430
+ let i = nn(e.title) || t;
1431
+ if (mt(r)) {
1432
+ let t = r.aggregate;
1412
1433
  return {
1413
- type: "object-data-table",
1414
- ...i,
1434
+ type: "object-metric",
1435
+ ...n,
1415
1436
  objectName: r.object,
1416
- dataProvider: r,
1417
- filter: r.filter || e.filter,
1418
- searchable: e.searchable ?? !1,
1419
- pagination: e.pagination ?? !1,
1420
- drillDown: n.drillDown ?? {
1421
- enabled: !0,
1422
- mode: "record"
1423
- },
1424
- className: "border-0"
1437
+ label: i,
1438
+ aggregate: t ? {
1439
+ field: t.field,
1440
+ function: t.function,
1441
+ groupBy: t.groupBy
1442
+ } : void 0,
1443
+ filter: r.filter || e.filter
1425
1444
  };
1426
1445
  }
1446
+ let a = Array.isArray(r) ? r : r?.items || [], o = n.yField || "value";
1427
1447
  return {
1428
- type: "data-table",
1448
+ type: "metric",
1429
1449
  ...n,
1430
- data: r?.items || [],
1431
- searchable: !1,
1432
- pagination: !1,
1433
- className: "border-0"
1450
+ label: i,
1451
+ value: n.value ?? a[0]?.[o] ?? "—"
1434
1452
  };
1435
1453
  }
1436
- if (t === "pivot") return rn;
1437
- if (t === "list") {
1438
- if (ft(r)) {
1439
- let { data: t, ...i } = n;
1454
+ if (i.family === "table") {
1455
+ let i = t === "list";
1456
+ if (mt(r)) {
1457
+ let { data: t, ...a } = n;
1440
1458
  return {
1441
1459
  type: "object-data-table",
1442
- ...i,
1460
+ ...a,
1443
1461
  objectName: r.object,
1444
1462
  dataProvider: r,
1445
1463
  filter: r.filter || e.filter,
1446
- searchable: !1,
1447
- pagination: !1,
1464
+ searchable: i ? !1 : e.searchable ?? !1,
1465
+ pagination: i ? !1 : e.pagination ?? !1,
1448
1466
  drillDown: n.drillDown ?? {
1449
1467
  enabled: !0,
1450
1468
  mode: "record"
@@ -1461,13 +1479,13 @@ var nn = /* @__PURE__ */ new Set([
1461
1479
  className: "border-0"
1462
1480
  };
1463
1481
  }
1464
- return t === "custom" ? {
1482
+ return i.family === "pivot" ? cn : i.family === "custom" ? {
1465
1483
  type: "text",
1466
1484
  value: "Custom widget — set `component` to a UIComponent schema.",
1467
1485
  variant: "caption",
1468
1486
  align: "center",
1469
1487
  className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground"
1470
- } : t && $t.has(t) ? {
1488
+ } : i.family === "unsupported" ? {
1471
1489
  type: "text",
1472
1490
  value: `「${t}」chart type is not supported yet`,
1473
1491
  variant: "caption",
@@ -1477,38 +1495,38 @@ var nn = /* @__PURE__ */ new Set([
1477
1495
  ...e,
1478
1496
  ...n
1479
1497
  };
1480
- }, p = k.length > 0 ? s(e, k, M) : void 0, m = (() => {
1498
+ }, p = O.length > 0 ? c(e, O, te) : void 0, m = (() => {
1481
1499
  let e = f();
1482
- return p && e && nn.has(e.type) ? {
1500
+ return p && e && sn.has(e.type) ? {
1483
1501
  ...e,
1484
- filter: g(e.filter, p)
1502
+ filter: _(e.filter, p)
1485
1503
  } : e;
1486
1504
  })(), h = p && d ? {
1487
1505
  ...e,
1488
- filter: g(e.filter, p)
1489
- } : e, _ = e.type === "metric" && !d, v = V(e), b = fe(e), S = e.id || v || `widget-${t}`, w = o && c === e.id, T = o ? {
1506
+ filter: _(e.filter, p)
1507
+ } : e, g = e.type === "metric" && !d, y = pe(e), b = me(e), S = e.id || y || `widget-${t}`, C = o && s === e.id, E = o ? {
1490
1508
  "data-testid": `dashboard-preview-widget-${e.id}`,
1491
1509
  "data-widget-id": e.id,
1492
1510
  role: "button",
1493
1511
  tabIndex: 0,
1494
- "aria-selected": w,
1495
- "aria-label": `Widget: ${v || `Widget ${t + 1}`}`,
1496
- onClick: (t) => me(t, e.id),
1497
- onKeyDown: (n) => he(n, e.id, t)
1498
- } : {}, D = o ? K("cursor-pointer rounded-lg transition-all outline-none", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", w ? "ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10" : "hover:ring-2 hover:ring-primary/40 hover:shadow-sm") : void 0, O = !E && u && !U ? {
1512
+ "aria-selected": C,
1513
+ "aria-label": `Widget: ${y || `Widget ${t + 1}`}`,
1514
+ onClick: (t) => he(t, e.id),
1515
+ onKeyDown: (n) => ge(n, e.id, t)
1516
+ } : {}, ee = o ? K("cursor-pointer rounded-lg transition-all outline-none", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", C ? "ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10" : "hover:ring-2 hover:ring-primary/40 hover:shadow-sm") : void 0, D = !T && u && !H ? {
1499
1517
  gridColumn: `span ${u.w}`,
1500
1518
  gridRow: `span ${u.h}`
1501
- } : void 0, A = _ ? /* @__PURE__ */ $("div", {
1502
- className: K("h-full w-full", o && "relative", D),
1503
- style: O,
1504
- ...T,
1519
+ } : void 0, k = g ? /* @__PURE__ */ $("div", {
1520
+ className: K("h-full w-full", o && "relative", ee),
1521
+ style: D,
1522
+ ...E,
1505
1523
  children: [d ? /* @__PURE__ */ Q("div", {
1506
1524
  className: K("h-full w-full", o && "pointer-events-none"),
1507
- children: /* @__PURE__ */ Q(Lt, {
1525
+ children: /* @__PURE__ */ Q(Gt, {
1508
1526
  widget: h,
1509
1527
  dataSource: n
1510
1528
  })
1511
- }) : /* @__PURE__ */ Q(C, {
1529
+ }) : /* @__PURE__ */ Q(w, {
1512
1530
  schema: m,
1513
1531
  className: K("h-full w-full", o && "pointer-events-none"),
1514
1532
  dataSource: n
@@ -1517,30 +1535,30 @@ var nn = /* @__PURE__ */ new Set([
1517
1535
  "aria-hidden": "true",
1518
1536
  "data-testid": "widget-click-overlay"
1519
1537
  })]
1520
- }) : /* @__PURE__ */ $(L, {
1521
- className: K("overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md", "bg-card/50 backdrop-blur-sm", r && "w-full", o && "relative", D),
1522
- style: O,
1523
- ...T,
1538
+ }) : /* @__PURE__ */ $(se, {
1539
+ className: K("overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md", "bg-card/50 backdrop-blur-sm", r && "w-full", o && "relative", ee),
1540
+ style: D,
1541
+ ...E,
1524
1542
  children: [
1525
- v && /* @__PURE__ */ $(ie, {
1543
+ y && /* @__PURE__ */ $(ce, {
1526
1544
  className: "pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6",
1527
- children: [/* @__PURE__ */ Q(ae, {
1545
+ children: [/* @__PURE__ */ Q(I, {
1528
1546
  className: "text-sm sm:text-base font-medium tracking-tight truncate",
1529
- title: v,
1530
- children: v
1547
+ title: y,
1548
+ children: y
1531
1549
  }), b && /* @__PURE__ */ Q("p", {
1532
1550
  className: "text-xs text-muted-foreground mt-0.5 line-clamp-2",
1533
1551
  children: b
1534
1552
  })]
1535
1553
  }),
1536
- /* @__PURE__ */ Q(re, {
1554
+ /* @__PURE__ */ Q(F, {
1537
1555
  className: "p-0",
1538
1556
  children: /* @__PURE__ */ Q("div", {
1539
1557
  className: K("h-full w-full", "p-3 sm:p-4 md:p-6", o && "pointer-events-none"),
1540
- children: d ? /* @__PURE__ */ Q(Lt, {
1558
+ children: d ? /* @__PURE__ */ Q(Gt, {
1541
1559
  widget: h,
1542
1560
  dataSource: n
1543
- }) : /* @__PURE__ */ Q(C, {
1561
+ }) : /* @__PURE__ */ Q(w, {
1544
1562
  schema: m,
1545
1563
  dataSource: n
1546
1564
  })
@@ -1553,36 +1571,36 @@ var nn = /* @__PURE__ */ new Set([
1553
1571
  })
1554
1572
  ]
1555
1573
  });
1556
- return U && e.id ? /* @__PURE__ */ Q(Kt, {
1574
+ return H && e.id ? /* @__PURE__ */ Q(en, {
1557
1575
  id: e.id,
1558
- gridSpan: !E && u ? {
1576
+ gridSpan: !T && u ? {
1559
1577
  w: u.w,
1560
1578
  h: u.h
1561
1579
  } : void 0,
1562
- children: A
1563
- }, S) : /* @__PURE__ */ Q(Ee, { children: A }, S);
1564
- }, ve = e.header && /* @__PURE__ */ $("div", {
1580
+ children: k
1581
+ }, S) : /* @__PURE__ */ Q(Oe, { children: k }, S);
1582
+ }, W = e.title || e.label, ye = e.header && /* @__PURE__ */ $("div", {
1565
1583
  className: "col-span-full mb-4",
1566
1584
  children: [
1567
- !p && e.header.showTitle !== !1 && e.title && /* @__PURE__ */ Q("h2", {
1585
+ !p && e.header.showTitle !== !1 && W && /* @__PURE__ */ Q("h2", {
1568
1586
  className: "text-lg font-semibold tracking-tight",
1569
- children: B ? I({
1570
- name: B,
1571
- label: Jt(e.title)
1572
- }) : Jt(e.title)
1587
+ children: z ? ae({
1588
+ name: z,
1589
+ label: nn(W)
1590
+ }) : nn(W)
1573
1591
  }),
1574
1592
  !p && e.header.showDescription !== !1 && e.description && /* @__PURE__ */ Q("p", {
1575
1593
  className: "text-sm text-muted-foreground mt-1",
1576
- children: B ? R({
1577
- name: B,
1578
- description: Jt(e.description)
1579
- }) : Jt(e.description)
1594
+ children: z ? N({
1595
+ name: z,
1596
+ description: nn(e.description)
1597
+ }) : nn(e.description)
1580
1598
  }),
1581
1599
  e.header.actions && e.header.actions.length > 0 && /* @__PURE__ */ Q("div", {
1582
1600
  className: "flex gap-2 mt-3",
1583
1601
  children: e.header.actions.map((e, t) => {
1584
- let n = qt(e.icon);
1585
- return /* @__PURE__ */ $(F, {
1602
+ let n = tn(e.icon);
1603
+ return /* @__PURE__ */ $(P, {
1586
1604
  variant: "outline",
1587
1605
  size: "sm",
1588
1606
  onClick: async () => {
@@ -1595,129 +1613,125 @@ var nn = /* @__PURE__ */ new Set([
1595
1613
  /^https?:\/\//.test(n) || n.startsWith("//") ? window.location.assign(n) : (window.history.pushState({}, "", n), window.dispatchEvent(new PopStateEvent("popstate")));
1596
1614
  return;
1597
1615
  }
1598
- if (t === "modal" || t === "script") {
1599
- let e = await ne(n || r);
1600
- e?.success || console.warn("[DashboardRenderer] action failed", e?.error);
1601
- return;
1602
- }
1603
- console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`);
1616
+ let i = await ie(n || r);
1617
+ i?.success || console.warn("[DashboardRenderer] action failed", i?.error);
1604
1618
  },
1605
- children: [n && /* @__PURE__ */ Q(n, { className: "w-4 h-4 mr-1.5" }), de(e)]
1619
+ children: [n && /* @__PURE__ */ Q(n, { className: "w-4 h-4 mr-1.5" }), fe(e)]
1606
1620
  }, t);
1607
1621
  })
1608
1622
  })
1609
1623
  ]
1610
- }), ye = k.length > 0 && /* @__PURE__ */ Q(Gt, {
1611
- defs: k,
1612
- values: M,
1613
- onChange: ee,
1614
- onReset: te,
1624
+ }), be = O.length > 0 && /* @__PURE__ */ Q($t, {
1625
+ defs: O,
1626
+ values: te,
1627
+ onChange: k,
1628
+ onReset: A,
1615
1629
  dataSource: n,
1616
1630
  className: "mb-2"
1617
- }), be = i !== void 0 && /* @__PURE__ */ $("span", {
1631
+ }), xe = i !== void 0 && /* @__PURE__ */ $("span", {
1618
1632
  className: "text-xs text-muted-foreground",
1619
1633
  children: [i.toLocaleString(), " records"]
1620
- }), xe = a ? JSON.stringify(a) : void 0, Se = r && /* @__PURE__ */ $("div", {
1621
- className: K("flex items-center justify-end gap-3 mb-2", !E && "col-span-full"),
1622
- children: [be, /* @__PURE__ */ $(F, {
1634
+ }), Se = a ? JSON.stringify(a) : void 0, Ce = r && /* @__PURE__ */ $("div", {
1635
+ className: K("flex items-center justify-end gap-3 mb-2", !T && "col-span-full"),
1636
+ children: [xe, /* @__PURE__ */ $(P, {
1623
1637
  variant: "outline",
1624
1638
  size: "sm",
1625
- onClick: pe,
1639
+ onClick: B,
1626
1640
  disabled: S,
1627
1641
  "aria-label": "Refresh dashboard",
1628
- children: [/* @__PURE__ */ Q(He, { className: K("h-4 w-4 mr-2", S && "animate-spin") }), S ? "Refreshing…" : "Refresh All"]
1642
+ children: [/* @__PURE__ */ Q(We, { className: K("h-4 w-4 mr-2", S && "animate-spin") }), S ? "Refreshing…" : "Refresh All"]
1629
1643
  })]
1630
- }), G = X(() => (e.widgets ?? []).map((e) => e.id).filter((e) => !!e), [e.widgets]), Ce = X(() => (e.widgets ?? []).filter((e) => e.type === "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]), we = X(() => (e.widgets ?? []).filter((e) => e.type !== "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]);
1631
- if (E) {
1644
+ }), we = X(() => (e.widgets ?? []).map((e) => e.id).filter((e) => !!e), [e.widgets]), G = X(() => (e.widgets ?? []).filter((e) => e.type === "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]), Te = X(() => (e.widgets ?? []).filter((e) => e.type !== "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]);
1645
+ if (T) {
1632
1646
  let n = e.widgets?.filter((e) => e.type === "metric") || [], r = e.widgets?.filter((e) => e.type !== "metric") || [], i = /* @__PURE__ */ $("div", {
1633
1647
  ref: h,
1634
1648
  className: K("flex flex-col gap-4 px-4", t),
1635
- "data-user-actions": xe,
1636
- onClick: H,
1649
+ "data-user-actions": Se,
1650
+ onClick: V,
1637
1651
  ...m,
1638
1652
  children: [
1639
- ve,
1640
1653
  ye,
1641
- Se,
1654
+ be,
1655
+ Ce,
1642
1656
  n.length > 0 && /* @__PURE__ */ Q("div", {
1643
1657
  className: "grid grid-cols-2 gap-3",
1644
- onClick: H,
1645
- children: /* @__PURE__ */ Q(Qe, {
1646
- items: Ce,
1647
- strategy: et,
1648
- disabled: !U,
1649
- children: n.map((e, t) => _e(e, t))
1658
+ onClick: V,
1659
+ children: /* @__PURE__ */ Q(et, {
1660
+ items: G,
1661
+ strategy: nt,
1662
+ disabled: !H,
1663
+ children: n.map((e, t) => ve(e, t))
1650
1664
  })
1651
1665
  }),
1652
1666
  r.length > 0 && /* @__PURE__ */ Q("div", {
1653
1667
  className: "flex flex-col gap-4",
1654
- onClick: H,
1655
- children: /* @__PURE__ */ Q(Qe, {
1656
- items: we,
1657
- strategy: nt,
1658
- disabled: !U,
1659
- children: r.map((e, t) => _e(e, t, !0))
1668
+ onClick: V,
1669
+ children: /* @__PURE__ */ Q(et, {
1670
+ items: Te,
1671
+ strategy: it,
1672
+ disabled: !H,
1673
+ children: r.map((e, t) => ve(e, t, !0))
1660
1674
  })
1661
1675
  })
1662
1676
  ]
1663
1677
  });
1664
- return U ? /* @__PURE__ */ Q(qe, {
1665
- sensors: ge,
1666
- collisionDetection: Ye,
1667
- onDragEnd: W,
1678
+ return H ? /* @__PURE__ */ Q(Ye, {
1679
+ sensors: U,
1680
+ collisionDetection: Ze,
1681
+ onDragEnd: _e,
1668
1682
  children: i
1669
1683
  }) : i;
1670
1684
  }
1671
- let q = /* @__PURE__ */ $("div", {
1685
+ let Ee = /* @__PURE__ */ $("div", {
1672
1686
  ref: h,
1673
1687
  className: K("grid", !x && "auto-rows-min grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4", t),
1674
1688
  style: {
1675
1689
  ...x && {
1676
- gridTemplateColumns: `repeat(${y}, minmax(0, 1fr))`,
1690
+ gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))`,
1677
1691
  gridAutoRows: "minmax(5rem, auto)"
1678
1692
  },
1679
1693
  gap: `${b * .25}rem`
1680
1694
  },
1681
- "data-user-actions": xe,
1682
- onClick: H,
1695
+ "data-user-actions": Se,
1696
+ onClick: V,
1683
1697
  ...m,
1684
1698
  children: [
1685
- ve,
1686
1699
  ye,
1687
- Se,
1688
- /* @__PURE__ */ Q(Qe, {
1689
- items: G,
1690
- strategy: et,
1691
- disabled: !U,
1692
- children: e.widgets?.map((e, t) => _e(e, t))
1700
+ be,
1701
+ Ce,
1702
+ /* @__PURE__ */ Q(et, {
1703
+ items: we,
1704
+ strategy: nt,
1705
+ disabled: !H,
1706
+ children: e.widgets?.map((e, t) => ve(e, t))
1693
1707
  })
1694
1708
  ]
1695
1709
  });
1696
- return U ? /* @__PURE__ */ Q(qe, {
1697
- sensors: ge,
1698
- collisionDetection: Ye,
1699
- onDragEnd: W,
1700
- children: q
1701
- }) : q;
1710
+ return H ? /* @__PURE__ */ Q(Ye, {
1711
+ sensors: U,
1712
+ collisionDetection: Ze,
1713
+ onDragEnd: _e,
1714
+ children: Ee
1715
+ }) : Ee;
1702
1716
  });
1703
- an.displayName = "DashboardRendererInner";
1704
- var on = De((e, t) => {
1705
- let { schema: n } = e, r = X(() => v(n), [n.globalFilters, n.dateRange]);
1706
- return r.length === 0 ? /* @__PURE__ */ Q(an, {
1717
+ ln.displayName = "DashboardRendererInner";
1718
+ var un = ke((e, t) => {
1719
+ let { schema: n } = e, r = X(() => y(n), [n.globalFilters, n.dateRange]);
1720
+ return r.length === 0 ? /* @__PURE__ */ Q(ln, {
1707
1721
  ref: t,
1708
1722
  ...e
1709
- }) : /* @__PURE__ */ Q(S, {
1710
- definitions: u(r),
1711
- children: /* @__PURE__ */ Q(an, {
1723
+ }) : /* @__PURE__ */ Q(C, {
1724
+ definitions: d(r),
1725
+ children: /* @__PURE__ */ Q(ln, {
1712
1726
  ref: t,
1713
1727
  ...e
1714
1728
  })
1715
1729
  });
1716
1730
  });
1717
- on.displayName = "DashboardRenderer";
1731
+ un.displayName = "DashboardRenderer";
1718
1732
  //#endregion
1719
1733
  //#region src/DashboardGridLayout.tsx
1720
- function sn({ editMode: e }) {
1734
+ function dn({ editMode: e }) {
1721
1735
  let t = D();
1722
1736
  return q.useEffect(() => {
1723
1737
  if (e) return t.startDrag({
@@ -1730,14 +1744,14 @@ function sn({ editMode: e }) {
1730
1744
  t.endDrag("dashboard");
1731
1745
  }, [e, t]), null;
1732
1746
  }
1733
- var cn = [
1747
+ var fn = [
1734
1748
  "hsl(var(--chart-1))",
1735
1749
  "hsl(var(--chart-2))",
1736
1750
  "hsl(var(--chart-3))",
1737
1751
  "hsl(var(--chart-4))",
1738
1752
  "hsl(var(--chart-5))"
1739
1753
  ];
1740
- function ln(e, t) {
1754
+ function pn(e, t) {
1741
1755
  if (!e.widgets?.length) return e;
1742
1756
  let n = new Map(t.map((e) => [e.i, e])), r = e.widgets.map((e, t) => {
1743
1757
  let r = e.id || `widget-${t}`, i = n.get(r);
@@ -1756,7 +1770,7 @@ function ln(e, t) {
1756
1770
  widgets: r
1757
1771
  };
1758
1772
  }
1759
- function un(e) {
1773
+ function mn(e) {
1760
1774
  return { lg: e.widgets?.map((e, t) => ({
1761
1775
  i: e.id || `widget-${t}`,
1762
1776
  x: e.layout?.x ?? t % 4 * 3,
@@ -1765,8 +1779,8 @@ function un(e) {
1765
1779
  h: e.layout?.h ?? 4
1766
1780
  })) || [] };
1767
1781
  }
1768
- var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRefresh: i }) => {
1769
- let { width: a, containerRef: o, mounted: s } = dt(), [c, l] = q.useState(!1), [u, d] = q.useState(!1), f = k(), p = q.useRef(null), m = q.useCallback(() => {
1782
+ var hn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRefresh: i }) => {
1783
+ let { width: a, containerRef: o, mounted: s } = pt(), [c, l] = q.useState(!1), [u, d] = q.useState(!1), f = k(), p = q.useRef(null), m = q.useCallback(() => {
1770
1784
  i && (d(!0), i(), setTimeout(() => d(!1), 600));
1771
1785
  }, [i]);
1772
1786
  q.useEffect(() => {
@@ -1778,7 +1792,7 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
1778
1792
  i,
1779
1793
  m
1780
1794
  ]);
1781
- let [h, g] = q.useState(() => un(e)), _ = q.useMemo(() => JSON.stringify(e.widgets?.map((e, t) => ({
1795
+ let [h, g] = q.useState(() => mn(e)), _ = q.useMemo(() => JSON.stringify(e.widgets?.map((e, t) => ({
1782
1796
  i: e.id || `widget-${t}`,
1783
1797
  x: e.layout?.x,
1784
1798
  y: e.layout?.y,
@@ -1786,55 +1800,81 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
1786
1800
  h: e.layout?.h
1787
1801
  })) ?? []), [e.widgets]);
1788
1802
  q.useEffect(() => {
1789
- g(un(e));
1803
+ g(mn(e));
1790
1804
  }, [_]);
1791
1805
  let v = q.useCallback((e, t) => {
1792
1806
  g(t), n?.(e);
1793
1807
  }, [n]), y = q.useCallback(() => {
1794
- r ? r(ln(e, h.lg)) : globalThis.process?.env?.NODE_ENV !== "production" && console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."), l(!1);
1808
+ r ? r(pn(e, h.lg)) : globalThis.process?.env?.NODE_ENV !== "production" && console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."), l(!1);
1795
1809
  }, [
1796
1810
  r,
1797
1811
  e,
1798
1812
  h
1799
1813
  ]), b = q.useCallback(() => {
1800
- g(un(e));
1814
+ g(mn(e));
1801
1815
  }, [e]), x = q.useCallback((e) => {
1802
1816
  if (e.component) return e.component;
1803
- let t = e.type, n = e.options || {};
1804
- if (t === "bar" || t === "horizontal-bar" || t === "line" || t === "area" || t === "pie" || t === "donut" || t === "scatter" || t === "funnel") {
1805
- let r = e.data || n.data, i = n.xField || "name", a = n.yField || "value";
1806
- if (ft(r)) {
1807
- let e = r.aggregate, n = e ? {
1817
+ let t = e.type, n = e.options || {}, r = xt(t);
1818
+ if (r.family === "series" && r.chartType) {
1819
+ let t = e.data || n.data, i = n.xField || "name", a = n.yField || "value";
1820
+ if (mt(t)) {
1821
+ let e = t.aggregate, n = e ? {
1808
1822
  field: e.field,
1809
1823
  function: e.function,
1810
1824
  groupBy: e.groupBy
1811
1825
  } : void 0, o = n?.field || a;
1812
1826
  return {
1813
1827
  type: "object-chart",
1814
- chartType: t,
1815
- objectName: r.object,
1828
+ chartType: r.chartType,
1829
+ objectName: t.object,
1816
1830
  aggregate: n,
1817
1831
  xAxisKey: i,
1818
1832
  series: [{ dataKey: o }],
1819
- colors: cn,
1833
+ colors: fn,
1820
1834
  isAnimationActive: !1,
1821
1835
  className: "h-full"
1822
1836
  };
1823
1837
  }
1838
+ let o = Array.isArray(t) ? t : t?.items || [];
1824
1839
  return {
1825
1840
  type: "chart",
1826
- chartType: t,
1827
- data: Array.isArray(r) ? r : r?.items || [],
1841
+ chartType: r.chartType,
1842
+ data: o,
1828
1843
  xAxisKey: i,
1829
1844
  series: [{ dataKey: a }],
1830
- colors: cn,
1845
+ colors: fn,
1831
1846
  isAnimationActive: !1,
1832
1847
  className: "h-full"
1833
1848
  };
1834
1849
  }
1835
- if (t === "table") {
1850
+ if (r.family === "metric") {
1851
+ let r = e.data || n.data, i = e.title || t;
1852
+ if (mt(r)) {
1853
+ let t = r.aggregate;
1854
+ return {
1855
+ type: "object-metric",
1856
+ ...n,
1857
+ objectName: r.object,
1858
+ label: i,
1859
+ aggregate: t ? {
1860
+ field: t.field,
1861
+ function: t.function,
1862
+ groupBy: t.groupBy
1863
+ } : void 0,
1864
+ filter: r.filter || e.filter
1865
+ };
1866
+ }
1867
+ let a = Array.isArray(r) ? r : r?.items || [], o = n.yField || "value";
1868
+ return {
1869
+ type: "metric",
1870
+ ...n,
1871
+ label: i,
1872
+ value: n.value ?? a[0]?.[o] ?? "—"
1873
+ };
1874
+ }
1875
+ if (r.family === "table") {
1836
1876
  let t = e.data || n.data;
1837
- if (ft(t)) {
1877
+ if (mt(t)) {
1838
1878
  let { data: e, ...r } = n;
1839
1879
  return {
1840
1880
  type: "data-table",
@@ -1856,9 +1896,9 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
1856
1896
  className: "border-0"
1857
1897
  };
1858
1898
  }
1859
- if (t === "pivot") {
1899
+ if (r.family === "pivot") {
1860
1900
  let t = e.data || n.data;
1861
- if (ft(t)) {
1901
+ if (mt(t)) {
1862
1902
  let { data: e, ...r } = n;
1863
1903
  return {
1864
1904
  type: "pivot",
@@ -1874,7 +1914,13 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
1874
1914
  data: Array.isArray(t) ? t : t?.items || []
1875
1915
  };
1876
1916
  }
1877
- return {
1917
+ return r.family === "unsupported" ? {
1918
+ type: "text",
1919
+ value: `「${t}」chart type is not supported yet`,
1920
+ variant: "caption",
1921
+ align: "center",
1922
+ className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground"
1923
+ } : {
1878
1924
  ...e,
1879
1925
  ...n
1880
1926
  };
@@ -1884,7 +1930,7 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
1884
1930
  className: K("w-full", t),
1885
1931
  "data-testid": "grid-layout",
1886
1932
  children: [
1887
- f && /* @__PURE__ */ Q(sn, { editMode: c }),
1933
+ f && /* @__PURE__ */ Q(dn, { editMode: c }),
1888
1934
  /* @__PURE__ */ $("div", {
1889
1935
  className: "mb-4 flex items-center justify-between",
1890
1936
  children: [/* @__PURE__ */ Q("h2", {
@@ -1892,41 +1938,41 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
1892
1938
  children: e.title || e.label || "Dashboard"
1893
1939
  }), /* @__PURE__ */ Q("div", {
1894
1940
  className: "flex gap-2",
1895
- children: c ? /* @__PURE__ */ $(lt, { children: [
1896
- /* @__PURE__ */ $(F, {
1941
+ children: c ? /* @__PURE__ */ $(dt, { children: [
1942
+ /* @__PURE__ */ $(P, {
1897
1943
  onClick: y,
1898
1944
  size: "sm",
1899
1945
  variant: "default",
1900
- children: [/* @__PURE__ */ Q(We, { className: "h-4 w-4 mr-2" }), "Save Layout"]
1946
+ children: [/* @__PURE__ */ Q(Ke, { className: "h-4 w-4 mr-2" }), "Save Layout"]
1901
1947
  }),
1902
- /* @__PURE__ */ $(F, {
1948
+ /* @__PURE__ */ $(P, {
1903
1949
  onClick: b,
1904
1950
  size: "sm",
1905
1951
  variant: "outline",
1906
- children: [/* @__PURE__ */ Q(Ke, { className: "h-4 w-4 mr-2" }), "Reset"]
1952
+ children: [/* @__PURE__ */ Q(Je, { className: "h-4 w-4 mr-2" }), "Reset"]
1907
1953
  }),
1908
- /* @__PURE__ */ Q(F, {
1954
+ /* @__PURE__ */ Q(P, {
1909
1955
  onClick: () => l(!1),
1910
1956
  size: "sm",
1911
1957
  variant: "ghost",
1912
1958
  children: "Cancel"
1913
1959
  })
1914
- ] }) : /* @__PURE__ */ $(lt, { children: [i && /* @__PURE__ */ $(F, {
1960
+ ] }) : /* @__PURE__ */ $(dt, { children: [i && /* @__PURE__ */ $(P, {
1915
1961
  onClick: m,
1916
1962
  size: "sm",
1917
1963
  variant: "outline",
1918
1964
  disabled: u,
1919
1965
  "aria-label": "Refresh dashboard",
1920
- children: [/* @__PURE__ */ Q(He, { className: K("h-4 w-4 mr-2", u && "animate-spin") }), u ? "Refreshing…" : "Refresh All"]
1921
- }), /* @__PURE__ */ $(F, {
1966
+ children: [/* @__PURE__ */ Q(We, { className: K("h-4 w-4 mr-2", u && "animate-spin") }), u ? "Refreshing…" : "Refresh All"]
1967
+ }), /* @__PURE__ */ $(P, {
1922
1968
  onClick: () => l(!0),
1923
1969
  size: "sm",
1924
1970
  variant: "outline",
1925
- children: [/* @__PURE__ */ Q(Re, { className: "h-4 w-4 mr-2" }), "Edit Layout"]
1971
+ children: [/* @__PURE__ */ Q(Be, { className: "h-4 w-4 mr-2" }), "Edit Layout"]
1926
1972
  })] })
1927
1973
  })]
1928
1974
  }),
1929
- s && /* @__PURE__ */ Q(ut, {
1975
+ s && /* @__PURE__ */ Q(ft, {
1930
1976
  className: "layout",
1931
1977
  width: a,
1932
1978
  layouts: h,
@@ -1959,28 +2005,28 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
1959
2005
  className: "h-full w-full relative",
1960
2006
  children: [c && /* @__PURE__ */ Q("div", {
1961
2007
  className: "drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border",
1962
- children: /* @__PURE__ */ Q(ze, { className: "h-4 w-4" })
1963
- }), /* @__PURE__ */ Q(C, {
2008
+ children: /* @__PURE__ */ Q(Ve, { className: "h-4 w-4" })
2009
+ }), /* @__PURE__ */ Q(w, {
1964
2010
  schema: r,
1965
2011
  className: "h-full w-full"
1966
2012
  })]
1967
- }) : /* @__PURE__ */ $(L, {
2013
+ }) : /* @__PURE__ */ $(se, {
1968
2014
  className: K("h-full overflow-hidden border-border/50 shadow-sm transition-all", "bg-card/50 backdrop-blur-sm", c && "ring-2 ring-primary/20"),
1969
- children: [e.title && /* @__PURE__ */ $(ie, {
2015
+ children: [e.title && /* @__PURE__ */ $(ce, {
1970
2016
  className: "pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between",
1971
- children: [/* @__PURE__ */ Q(ae, {
2017
+ children: [/* @__PURE__ */ Q(I, {
1972
2018
  className: "text-base font-medium tracking-tight truncate",
1973
2019
  title: e.title,
1974
2020
  children: e.title
1975
2021
  }), c && /* @__PURE__ */ Q("div", {
1976
2022
  className: "drag-handle cursor-move p-1 hover:bg-muted/40 rounded",
1977
- children: /* @__PURE__ */ Q(ze, { className: "h-4 w-4" })
2023
+ children: /* @__PURE__ */ Q(Ve, { className: "h-4 w-4" })
1978
2024
  })]
1979
- }), /* @__PURE__ */ Q(re, {
2025
+ }), /* @__PURE__ */ Q(F, {
1980
2026
  className: "p-0 h-full",
1981
2027
  children: /* @__PURE__ */ Q("div", {
1982
2028
  className: K("h-full w-full overflow-auto p-4"),
1983
- children: /* @__PURE__ */ Q(C, { schema: r })
2029
+ children: /* @__PURE__ */ Q(w, { schema: r })
1984
2030
  })
1985
2031
  })]
1986
2032
  })
@@ -1989,7 +2035,7 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
1989
2035
  })
1990
2036
  ]
1991
2037
  });
1992
- }, fn = M({
2038
+ }, gn = A({
1993
2039
  "dashboard.trend.vsLastQuarter": "vs last quarter",
1994
2040
  "dashboard.trend.vsLastMonth": "vs last month",
1995
2041
  "dashboard.trend.vsLastWeek": "vs last week",
@@ -1997,7 +2043,7 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
1997
2043
  "dashboard.trend.vsYesterday": "vs yesterday",
1998
2044
  "dashboard.trend.vsPreviousPeriod": "vs previous period"
1999
2045
  }, "dashboard.trend.vsLastQuarter");
2000
- function pn(e) {
2046
+ function _n(e) {
2001
2047
  switch (e.trim().toLowerCase().replace(/\s+/g, " ")) {
2002
2048
  case "vs last quarter":
2003
2049
  case "vs previous quarter": return "dashboard.trend.vsLastQuarter";
@@ -2013,11 +2059,11 @@ function pn(e) {
2013
2059
  default: return;
2014
2060
  }
2015
2061
  }
2016
- function mn(e, t, n) {
2062
+ function vn(e, t, n) {
2017
2063
  if (e == null) return "";
2018
2064
  if (typeof e == "string") {
2019
2065
  let r = Number(e);
2020
- return !isFinite(r) || e.trim() === "" ? e : mn(r, t, n);
2066
+ return !isFinite(r) || e.trim() === "" ? e : vn(r, t, n);
2021
2067
  }
2022
2068
  if (!isFinite(e)) return String(e);
2023
2069
  let r = {
@@ -2054,10 +2100,10 @@ function mn(e, t, n) {
2054
2100
  maximumFractionDigits: c
2055
2101
  }).format(e);
2056
2102
  }
2057
- function hn(e) {
2103
+ function yn(e) {
2058
2104
  if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
2059
2105
  }
2060
- var gn = {
2106
+ var bn = {
2061
2107
  default: "bg-muted text-muted-foreground",
2062
2108
  blue: "bg-blue-500/10 text-blue-600 dark:text-blue-400",
2063
2109
  teal: "bg-teal-500/10 text-teal-600 dark:text-teal-400",
@@ -2066,7 +2112,7 @@ var gn = {
2066
2112
  success: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",
2067
2113
  warning: "bg-amber-500/10 text-amber-600 dark:text-amber-400",
2068
2114
  danger: "bg-rose-500/10 text-rose-600 dark:text-rose-400"
2069
- }, _n = {
2115
+ }, xn = {
2070
2116
  default: "text-foreground",
2071
2117
  blue: "text-blue-600 dark:text-blue-400",
2072
2118
  teal: "text-teal-600 dark:text-teal-400",
@@ -2075,18 +2121,18 @@ var gn = {
2075
2121
  success: "text-emerald-600 dark:text-emerald-400",
2076
2122
  warning: "text-amber-600 dark:text-amber-400",
2077
2123
  danger: "text-rose-600 dark:text-rose-400"
2078
- }, vn = ({ label: e, value: t, trend: n, icon: r, className: i, description: a, loading: o, error: s, colorVariant: c = "default", format: l, currency: u, prefix: d, suffix: f, onClick: p, variant: m = "card", ...h }) => {
2079
- let g = gn[c] || gn.default, { t: _ } = fn(), v = X(() => {
2080
- let e = hn(a) || hn(n?.label);
2124
+ }, Sn = ({ label: e, value: t, trend: n, icon: r, className: i, description: a, loading: o, error: s, colorVariant: c = "default", format: l, currency: u, prefix: d, suffix: f, onClick: p, variant: m = "card", ...h }) => {
2125
+ let g = bn[c] || bn.default, { t: _ } = gn(), v = X(() => {
2126
+ let e = yn(a) || yn(n?.label);
2081
2127
  if (!e) return e;
2082
- let t = pn(e);
2128
+ let t = _n(e);
2083
2129
  return t ? _(t) : e;
2084
2130
  }, [
2085
2131
  a,
2086
2132
  n?.label,
2087
2133
  _
2088
2134
  ]), y = X(() => {
2089
- let e = typeof t == "number" || typeof t == "string" && t.trim() !== "" && isFinite(Number(t)) ? mn(t, l, u) : t ?? "", n = String(e);
2135
+ let e = typeof t == "number" || typeof t == "string" && t.trim() !== "" && isFinite(Number(t)) ? vn(t, l, u) : t ?? "", n = String(e);
2090
2136
  return `${d && n.startsWith(d) ? "" : d ?? ""}${n}${f && n.endsWith(f) ? "" : f ?? ""}`;
2091
2137
  }, [
2092
2138
  t,
@@ -2096,13 +2142,13 @@ var gn = {
2096
2142
  f
2097
2143
  ]), b = X(() => {
2098
2144
  if (typeof r == "string") {
2099
- let e = Ce(r);
2145
+ let e = Te(r);
2100
2146
  return e ? /* @__PURE__ */ Q(e, { className: "h-4 w-4" }) : null;
2101
2147
  }
2102
2148
  return r;
2103
2149
  }, [r]);
2104
2150
  if (m === "bare") {
2105
- let t = _n[c] || _n.default;
2151
+ let t = xn[c] || xn.default;
2106
2152
  return /* @__PURE__ */ Q("div", {
2107
2153
  className: K("flex flex-col gap-1 min-w-0", p && "cursor-pointer", i),
2108
2154
  onClick: p,
@@ -2114,7 +2160,7 @@ var gn = {
2114
2160
  children: o ? /* @__PURE__ */ $("div", {
2115
2161
  className: "flex items-center gap-2 text-muted-foreground",
2116
2162
  "data-testid": "metric-loading",
2117
- children: [/* @__PURE__ */ Q(Be, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
2163
+ children: [/* @__PURE__ */ Q(He, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
2118
2164
  className: "text-sm",
2119
2165
  children: "Loading…"
2120
2166
  })]
@@ -2122,20 +2168,20 @@ var gn = {
2122
2168
  className: "flex items-center gap-2",
2123
2169
  "data-testid": "metric-error",
2124
2170
  role: "alert",
2125
- children: [/* @__PURE__ */ Q(Ae, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
2171
+ children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
2126
2172
  className: "text-xs text-destructive truncate",
2127
2173
  children: s
2128
2174
  })]
2129
- }) : /* @__PURE__ */ $(lt, { children: [/* @__PURE__ */ Q("div", {
2175
+ }) : /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q("div", {
2130
2176
  className: K("text-[2rem] leading-none font-extrabold tabular-nums tracking-tight truncate", t),
2131
2177
  children: y
2132
2178
  }), /* @__PURE__ */ Q("div", {
2133
2179
  className: "text-xs font-medium text-muted-foreground truncate",
2134
- children: hn(e)
2180
+ children: yn(e)
2135
2181
  })] })
2136
2182
  });
2137
2183
  }
2138
- return /* @__PURE__ */ $(L, {
2184
+ return /* @__PURE__ */ $(se, {
2139
2185
  className: K("h-full overflow-hidden", p && "cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none", i),
2140
2186
  onClick: p,
2141
2187
  role: p ? "button" : void 0,
@@ -2144,19 +2190,19 @@ var gn = {
2144
2190
  (e.key === "Enter" || e.key === " ") && (e.preventDefault(), p());
2145
2191
  } : void 0,
2146
2192
  ...h,
2147
- children: [/* @__PURE__ */ $(ie, {
2193
+ children: [/* @__PURE__ */ $(ce, {
2148
2194
  className: "flex flex-row items-center justify-between space-y-0 pb-2",
2149
- children: [/* @__PURE__ */ Q(ae, {
2195
+ children: [/* @__PURE__ */ Q(I, {
2150
2196
  className: "text-sm font-medium truncate",
2151
- children: hn(e)
2197
+ children: yn(e)
2152
2198
  }), b && /* @__PURE__ */ Q("div", {
2153
2199
  className: K("flex h-8 w-8 items-center justify-center rounded-md shrink-0", g),
2154
2200
  children: b
2155
2201
  })]
2156
- }), /* @__PURE__ */ Q(re, { children: o ? /* @__PURE__ */ $("div", {
2202
+ }), /* @__PURE__ */ Q(F, { children: o ? /* @__PURE__ */ $("div", {
2157
2203
  className: "flex items-center gap-2 text-muted-foreground",
2158
2204
  "data-testid": "metric-loading",
2159
- children: [/* @__PURE__ */ Q(Be, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
2205
+ children: [/* @__PURE__ */ Q(He, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
2160
2206
  className: "text-sm",
2161
2207
  children: "Loading…"
2162
2208
  })]
@@ -2164,11 +2210,11 @@ var gn = {
2164
2210
  className: "flex items-center gap-2",
2165
2211
  "data-testid": "metric-error",
2166
2212
  role: "alert",
2167
- children: [/* @__PURE__ */ Q(Ae, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
2213
+ children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
2168
2214
  className: "text-xs text-destructive truncate",
2169
2215
  children: s
2170
2216
  })]
2171
- }) : /* @__PURE__ */ $(lt, { children: [/* @__PURE__ */ Q("div", {
2217
+ }) : /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q("div", {
2172
2218
  className: "text-2xl font-bold tabular-nums tracking-tight truncate",
2173
2219
  children: y
2174
2220
  }), (n || a) && /* @__PURE__ */ $("div", {
@@ -2176,9 +2222,9 @@ var gn = {
2176
2222
  children: [n && /* @__PURE__ */ $("span", {
2177
2223
  className: K("flex items-center shrink-0 font-medium", n.direction === "up" && "text-emerald-600 dark:text-emerald-400", n.direction === "down" && "text-rose-600 dark:text-rose-400", n.direction === "neutral" && "text-muted-foreground"),
2178
2224
  children: [
2179
- n.direction === "up" && /* @__PURE__ */ Q(Ne, { className: "h-3 w-3 mr-1" }),
2180
- n.direction === "down" && /* @__PURE__ */ Q(Me, { className: "h-3 w-3 mr-1" }),
2181
- n.direction === "neutral" && /* @__PURE__ */ Q(Ve, { className: "h-3 w-3 mr-1" }),
2225
+ n.direction === "up" && /* @__PURE__ */ Q(Fe, { className: "h-3 w-3 mr-1" }),
2226
+ n.direction === "down" && /* @__PURE__ */ Q(Pe, { className: "h-3 w-3 mr-1" }),
2227
+ n.direction === "neutral" && /* @__PURE__ */ Q(Ue, { className: "h-3 w-3 mr-1" }),
2182
2228
  n.value,
2183
2229
  "%"
2184
2230
  ]
@@ -2191,24 +2237,24 @@ var gn = {
2191
2237
  };
2192
2238
  //#endregion
2193
2239
  //#region src/MetricCard.tsx
2194
- function yn(e) {
2240
+ function Cn(e) {
2195
2241
  if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
2196
2242
  }
2197
- var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a, className: o, loading: s, error: c, ...l }) => {
2198
- let u = n ? Ce(n) : null;
2199
- return /* @__PURE__ */ $(L, {
2243
+ var wn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a, className: o, loading: s, error: c, ...l }) => {
2244
+ let u = n ? Te(n) : null;
2245
+ return /* @__PURE__ */ $(se, {
2200
2246
  className: K("h-full", o),
2201
2247
  ...l,
2202
- children: [/* @__PURE__ */ $(ie, {
2248
+ children: [/* @__PURE__ */ $(ce, {
2203
2249
  className: "flex flex-row items-center justify-between space-y-0 pb-2",
2204
- children: [/* @__PURE__ */ Q(ae, {
2250
+ children: [/* @__PURE__ */ Q(I, {
2205
2251
  className: "text-sm font-medium",
2206
- children: yn(e)
2252
+ children: Cn(e)
2207
2253
  }), u && /* @__PURE__ */ Q(u, { className: "h-4 w-4 text-muted-foreground" })]
2208
- }), /* @__PURE__ */ Q(re, { children: s ? /* @__PURE__ */ $("div", {
2254
+ }), /* @__PURE__ */ Q(F, { children: s ? /* @__PURE__ */ $("div", {
2209
2255
  className: "flex items-center gap-2 text-muted-foreground",
2210
2256
  "data-testid": "metric-card-loading",
2211
- children: [/* @__PURE__ */ Q(Be, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
2257
+ children: [/* @__PURE__ */ Q(He, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
2212
2258
  className: "text-sm",
2213
2259
  children: "Loading…"
2214
2260
  })]
@@ -2216,11 +2262,11 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
2216
2262
  className: "flex items-center gap-2",
2217
2263
  "data-testid": "metric-card-error",
2218
2264
  role: "alert",
2219
- children: [/* @__PURE__ */ Q(Ae, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
2265
+ children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
2220
2266
  className: "text-xs text-destructive truncate",
2221
2267
  children: c
2222
2268
  })]
2223
- }) : /* @__PURE__ */ $(lt, { children: [/* @__PURE__ */ Q("div", {
2269
+ }) : /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q("div", {
2224
2270
  className: "text-2xl font-bold",
2225
2271
  children: t
2226
2272
  }), (r || i || a) && /* @__PURE__ */ $("p", {
@@ -2228,47 +2274,47 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
2228
2274
  children: [r && i && /* @__PURE__ */ $("span", {
2229
2275
  className: K("flex items-center mr-2", r === "up" && "text-green-500", r === "down" && "text-red-500", r === "neutral" && "text-yellow-500"),
2230
2276
  children: [
2231
- r === "up" && /* @__PURE__ */ Q(Ne, { className: "h-3 w-3 mr-1" }),
2232
- r === "down" && /* @__PURE__ */ Q(Me, { className: "h-3 w-3 mr-1" }),
2233
- r === "neutral" && /* @__PURE__ */ Q(Ve, { className: "h-3 w-3 mr-1" }),
2277
+ r === "up" && /* @__PURE__ */ Q(Fe, { className: "h-3 w-3 mr-1" }),
2278
+ r === "down" && /* @__PURE__ */ Q(Pe, { className: "h-3 w-3 mr-1" }),
2279
+ r === "neutral" && /* @__PURE__ */ Q(Ue, { className: "h-3 w-3 mr-1" }),
2234
2280
  i
2235
2281
  ]
2236
- }), yn(a)]
2282
+ }), Cn(a)]
2237
2283
  })] }) })]
2238
2284
  });
2239
- }, xn = ({ objectName: e, aggregate: t, filter: n, label: r, fallbackValue: i, trend: a, icon: o, className: s, description: l, dataSource: u, colorVariant: d, format: f, currency: p, prefix: m, suffix: g, invert: _, drillDown: v, title: S, compareTo: T, t: E, variant: D }) => {
2240
- let O = Oe(w), k = u || O?.dataSource, [A, j] = Z(!1), [M, N] = Z(null), [ne, P] = Z(null), [F, I] = Z(!1), [L, re] = Z(null), [ie, ae] = Z(null);
2285
+ }, Tn = ({ objectName: e, aggregate: t, filter: n, label: r, fallbackValue: i, trend: a, icon: o, className: s, description: c, dataSource: u, colorVariant: d, format: f, currency: p, prefix: m, suffix: h, invert: _, drillDown: v, title: y, compareTo: C, t: E, variant: ee }) => {
2286
+ let D = Ae(T), O = u || D?.dataSource, [k, ne] = Z(!1), [re, A] = Z(null), [M, ae] = Z(null), [N, P] = Z(!1), [oe, se] = Z(null), [F, ce] = Z(null);
2241
2287
  Y(() => {
2242
2288
  let t = !0;
2243
- if (!(!k || !e || typeof k.getObjectSchema != "function")) return k.getObjectSchema(e).then((e) => {
2244
- t && ae(e);
2289
+ if (!(!O || !e || typeof O.getObjectSchema != "function")) return O.getObjectSchema(e).then((e) => {
2290
+ t && ce(e);
2245
2291
  }).catch(() => {}), () => {
2246
2292
  t = !1;
2247
2293
  };
2248
- }, [k, e]);
2249
- let R = X(() => {
2294
+ }, [O, e]);
2295
+ let I = X(() => {
2250
2296
  let e = t?.field;
2251
- if (!e || !ie?.fields) return null;
2252
- let n = ie.fields;
2297
+ if (!e || !F?.fields) return null;
2298
+ let n = F.fields;
2253
2299
  return Array.isArray(n) ? n.find((t) => t?.name === e) || null : n[e] || null;
2254
- }, [ie, t?.field]), z = X(() => {
2300
+ }, [F, t?.field]), le = X(() => {
2255
2301
  if (f) return f;
2256
- if (R) {
2257
- if (R.type === "currency") {
2258
- let e = R.scale ?? 0;
2302
+ if (I) {
2303
+ if (I.type === "currency") {
2304
+ let e = I.scale ?? 0;
2259
2305
  return e > 0 ? `0,0.${"0".repeat(e)}` : "0,0";
2260
2306
  }
2261
- if (R.type === "percent") return "0,0%";
2262
- if (R.type === "number" || R.type === "integer") return "0,0";
2307
+ if (I.type === "percent") return "0,0%";
2308
+ if (I.type === "number" || I.type === "integer") return "0,0";
2263
2309
  }
2264
- }, [f, R]), { currency: oe } = te(), se = X(() => {
2310
+ }, [f, I]), { currency: ue } = j(), de = X(() => {
2265
2311
  if (p) return p;
2266
- if (R?.type === "currency") return ee(R, oe);
2312
+ if (I?.type === "currency") return ie(I, ue);
2267
2313
  }, [
2268
2314
  p,
2269
- R,
2270
- oe
2271
- ]), ce = X(() => t ? JSON.stringify(t) : "", [t]), V = X(() => y(n), [n]), fe = X(() => V ? JSON.stringify(V) : "", [V]), pe = X(() => T ? JSON.stringify(T) : "", [T]), me = J(async (n, r) => {
2315
+ I,
2316
+ ue
2317
+ ]), L = X(() => t ? JSON.stringify(t) : "", [t]), R = te(), B = X(() => x(n, R), [n, R]), he = X(() => B ? JSON.stringify(B) : "", [B]), ge = X(() => C ? JSON.stringify(C) : "", [C]), V = J(async (n, r) => {
2272
2318
  if (t && typeof n.aggregate == "function") {
2273
2319
  let i = await n.aggregate(e, {
2274
2320
  field: t.field,
@@ -2289,43 +2335,43 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
2289
2335
  return (Array.isArray(t) ? t : t?.data || t?.records || []).length;
2290
2336
  }
2291
2337
  return null;
2292
- }, [e, ce]), he = J(async (t, r) => {
2338
+ }, [e, L]), H = J(async (t, r) => {
2293
2339
  if (!(!t || !e)) {
2294
- r.current && (I(!0), re(null));
2340
+ r.current && (P(!0), se(null));
2295
2341
  try {
2296
- let e = T ? x(n, T) : null, [i, a] = await Promise.all([me(t, V), e ? me(t, e) : Promise.resolve(null)]);
2342
+ let e = C ? S(n, C) : null, [i, a] = await Promise.all([V(t, B), e ? V(t, e) : Promise.resolve(null)]);
2297
2343
  if (i === null) return;
2298
- r.current && (N(i), P(typeof a == "number" && Number.isFinite(a) ? a : null));
2344
+ r.current && (A(i), ae(typeof a == "number" && Number.isFinite(a) ? a : null));
2299
2345
  } catch (e) {
2300
- console.error("[ObjectMetricWidget] Fetch error:", e), r.current && re(e instanceof Error ? e.message : "Failed to load metric");
2346
+ console.error("[ObjectMetricWidget] Fetch error:", e), r.current && se(e instanceof Error ? e.message : "Failed to load metric");
2301
2347
  } finally {
2302
- r.current && I(!1);
2348
+ r.current && P(!1);
2303
2349
  }
2304
2350
  }
2305
2351
  }, [
2306
2352
  e,
2307
- ce,
2308
- fe,
2309
- pe,
2310
- me
2353
+ L,
2354
+ he,
2355
+ ge,
2356
+ V
2311
2357
  ]);
2312
2358
  Y(() => {
2313
2359
  let t = { current: !0 };
2314
- return k && e ? he(k, t) : (N(null), re(null)), () => {
2360
+ return O && e ? H(O, t) : (A(null), se(null)), () => {
2315
2361
  t.current = !1;
2316
2362
  };
2317
2363
  }, [
2318
- k,
2364
+ O,
2319
2365
  e,
2320
- he
2366
+ H
2321
2367
  ]);
2322
- let H = M === null ? k ? "—" : i ?? "—" : M;
2323
- _ && typeof H == "number" && isFinite(H) && H >= 0 && H <= 1 && (H = 1 - H);
2324
- let U = X(() => {
2325
- if (!T || typeof M != "number" || !Number.isFinite(M) || ne === null) return;
2326
- let e = pt(M, ne);
2368
+ let U = re === null ? O ? "—" : i ?? "—" : re;
2369
+ _ && typeof U == "number" && isFinite(U) && U >= 0 && U <= 1 && (U = 1 - U);
2370
+ let _e = X(() => {
2371
+ if (!C || typeof re != "number" || !Number.isFinite(re) || M === null) return;
2372
+ let e = ht(re, M);
2327
2373
  if (!e) return;
2328
- let t = c(T, n), r = `dashboard.trend.${t}`, i = {
2374
+ let t = l(C, n), r = `dashboard.trend.${t}`, i = {
2329
2375
  vsPreviousPeriod: "vs previous period",
2330
2376
  vsLastWeek: "vs last week",
2331
2377
  vsLastMonth: "vs last month",
@@ -2339,30 +2385,30 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
2339
2385
  label: a
2340
2386
  };
2341
2387
  }, [
2342
- T,
2388
+ C,
2389
+ re,
2343
2390
  M,
2344
- ne,
2345
2391
  n,
2346
2392
  E
2347
- ]) ?? a, ge = h(v) && !!e && !!k, W = X(() => {
2393
+ ]) ?? a, ve = g(v) && !!e && !!O, W = X(() => {
2348
2394
  let e = typeof r == "string" ? r : r?.defaultValue || "";
2349
- return b(v, {}, (typeof S == "string" ? S : S?.defaultValue || "") || e || "Details");
2395
+ return b(v, {}, (typeof y == "string" ? y : y?.defaultValue || "") || e || "Details");
2350
2396
  }, [
2351
2397
  v,
2352
2398
  r,
2353
- S
2354
- ]), _e = X(() => {
2355
- if (!ge) return null;
2356
- let t = v?.target ?? "drawer", n = v?.report, r = n && typeof n == "object" && (Array.isArray(n.columns) || "objectName" in n), i = r ? null : /* @__PURE__ */ Q(Ot, {
2399
+ y
2400
+ ]), ye = X(() => {
2401
+ if (!ve) return null;
2402
+ let t = v?.target ?? "drawer", n = v?.report, r = n && typeof n == "object" && (Array.isArray(n.columns) || "objectName" in n), i = r ? null : /* @__PURE__ */ Q(It, {
2357
2403
  objectName: e,
2358
- filter: V,
2359
- onNavigate: () => j(!1)
2404
+ filter: B,
2405
+ onNavigate: () => ne(!1)
2360
2406
  }), a;
2361
2407
  if (r) {
2362
- let e = n.filter, t = e ? V ? { $and: [e, V] } : e : V;
2408
+ let e = n.filter, t = e ? B ? { $and: [e, B] } : e : B;
2363
2409
  a = /* @__PURE__ */ Q("div", {
2364
2410
  className: "h-full overflow-auto",
2365
- children: /* @__PURE__ */ Q(C, { schema: {
2411
+ children: /* @__PURE__ */ Q(w, { schema: {
2366
2412
  type: "spec-report",
2367
2413
  ...n,
2368
2414
  filter: t
@@ -2370,10 +2416,10 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
2370
2416
  });
2371
2417
  } else a = /* @__PURE__ */ Q("div", {
2372
2418
  className: "h-full overflow-auto",
2373
- children: /* @__PURE__ */ Q(C, { schema: {
2419
+ children: /* @__PURE__ */ Q(w, { schema: {
2374
2420
  type: "object-data-table",
2375
2421
  objectName: e,
2376
- filter: V,
2422
+ filter: B,
2377
2423
  pageSize: 25,
2378
2424
  drillDown: {
2379
2425
  enabled: !0,
@@ -2382,25 +2428,25 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
2382
2428
  }
2383
2429
  } })
2384
2430
  });
2385
- return t === "dialog" ? /* @__PURE__ */ Q(le, {
2431
+ return t === "dialog" ? /* @__PURE__ */ Q(z, {
2386
2432
  open: !0,
2387
- onOpenChange: (e) => !e && j(!1),
2388
- children: /* @__PURE__ */ $(ue, {
2433
+ onOpenChange: (e) => !e && ne(!1),
2434
+ children: /* @__PURE__ */ $(fe, {
2389
2435
  className: "max-w-5xl",
2390
- children: [/* @__PURE__ */ $(B, {
2436
+ children: [/* @__PURE__ */ $(pe, {
2391
2437
  className: "flex-row items-center justify-between gap-4 pr-8",
2392
- children: [/* @__PURE__ */ Q(de, { children: W }), i]
2438
+ children: [/* @__PURE__ */ Q(me, { children: W }), i]
2393
2439
  }), a]
2394
2440
  })
2395
- }) : /* @__PURE__ */ Q(ye, {
2441
+ }) : /* @__PURE__ */ Q(xe, {
2396
2442
  open: !0,
2397
- onOpenChange: (e) => !e && j(!1),
2398
- children: /* @__PURE__ */ $(be, {
2443
+ onOpenChange: (e) => !e && ne(!1),
2444
+ children: /* @__PURE__ */ $(Se, {
2399
2445
  side: "right",
2400
2446
  className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-5xl flex flex-col",
2401
- children: [/* @__PURE__ */ $(xe, {
2447
+ children: [/* @__PURE__ */ $(Ce, {
2402
2448
  className: "flex-row items-center justify-between gap-4 pr-8",
2403
- children: [/* @__PURE__ */ Q(Se, { children: W }), i]
2449
+ children: [/* @__PURE__ */ Q(we, { children: W }), i]
2404
2450
  }), /* @__PURE__ */ Q("div", {
2405
2451
  className: "flex-1 overflow-hidden mt-2",
2406
2452
  children: a
@@ -2408,39 +2454,39 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
2408
2454
  })
2409
2455
  });
2410
2456
  }, [
2411
- ge,
2457
+ ve,
2412
2458
  v,
2413
2459
  e,
2414
- V,
2460
+ B,
2415
2461
  W
2416
2462
  ]);
2417
- return /* @__PURE__ */ $(lt, { children: [/* @__PURE__ */ Q(vn, {
2463
+ return /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q(Sn, {
2418
2464
  label: r,
2419
- value: H,
2420
- trend: U,
2465
+ value: U,
2466
+ trend: _e,
2421
2467
  icon: o,
2422
2468
  className: s,
2423
- description: l,
2424
- loading: F,
2425
- error: L,
2469
+ description: c,
2470
+ loading: N,
2471
+ error: oe,
2426
2472
  colorVariant: d,
2427
- format: z,
2428
- currency: se,
2473
+ format: le,
2474
+ currency: de,
2429
2475
  prefix: m,
2430
- suffix: g,
2431
- variant: D,
2432
- onClick: ge ? () => j(!0) : void 0
2433
- }), A && _e] });
2476
+ suffix: h,
2477
+ variant: ee,
2478
+ onClick: ve ? () => ne(!0) : void 0
2479
+ }), k && ye] });
2434
2480
  };
2435
2481
  //#endregion
2436
2482
  //#region src/PivotTable.tsx
2437
- function Sn() {
2438
- return P()("dashboard.total", "Total");
2483
+ function En() {
2484
+ return N()("dashboard.total", "Total");
2439
2485
  }
2440
- function Cn() {
2441
- return P()("dashboard.noDataAvailable", "No data available");
2486
+ function Dn() {
2487
+ return N()("dashboard.noDataAvailable", "No data available");
2442
2488
  }
2443
- function wn(e, t) {
2489
+ function On(e, t) {
2444
2490
  if (!t) return String(e);
2445
2491
  let n = "", r = !1, i, a = t, o = a.match(/^([^0-9.,#]*)/);
2446
2492
  if (o && o[1]) {
@@ -2457,11 +2503,18 @@ function wn(e, t) {
2457
2503
  }
2458
2504
  return n + l + c;
2459
2505
  }
2460
- var Tn = "—";
2461
- function En(e, t) {
2462
- return e === "" ? Tn : t?.[e] ?? e;
2506
+ var kn = "—";
2507
+ function An(e, t) {
2508
+ return e === "" ? kn : t?.[e] ?? e;
2463
2509
  }
2464
- function Dn(e, t) {
2510
+ var jn = /* @__PURE__ */ new Set([
2511
+ "sum",
2512
+ "count",
2513
+ "avg",
2514
+ "min",
2515
+ "max"
2516
+ ]);
2517
+ function Mn(e, t) {
2465
2518
  if (e.length === 0) return 0;
2466
2519
  switch (t) {
2467
2520
  case "sum": return e.reduce((e, t) => e + t, 0);
@@ -2469,11 +2522,11 @@ function Dn(e, t) {
2469
2522
  case "avg": return e.reduce((e, t) => e + t, 0) / e.length;
2470
2523
  case "min": return Math.min(...e);
2471
2524
  case "max": return Math.max(...e);
2472
- default: return e.reduce((e, t) => e + t, 0);
2525
+ default: return NaN;
2473
2526
  }
2474
2527
  }
2475
- var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabel: i, onDrillDown: a }) => {
2476
- let { title: o, rowField: s, columnField: c, valueField: l, aggregation: u = "sum", data: d = [], showRowTotals: f = !1, showColumnTotals: p = !1, format: m, columnColors: g, drillDown: _ } = e, v = Sn(), y = Cn(), b = h(_) && typeof a == "function", x = (e) => {
2528
+ var Nn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabel: i, onDrillDown: a }) => {
2529
+ let { title: o, rowField: s, columnField: c, valueField: l, aggregation: u = "sum", data: d = [], showRowTotals: f = !1, showColumnTotals: p = !1, format: m, columnColors: h, drillDown: _ } = e, v = En(), y = Dn(), b = g(_) && typeof a == "function", x = (e) => {
2477
2530
  b && a({
2478
2531
  ...e,
2479
2532
  rowLabel: e.rowKey === void 0 ? e.rowLabel : n?.[e.rowKey] ?? e.rowKey,
@@ -2481,7 +2534,7 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2481
2534
  });
2482
2535
  }, S = (e) => (t) => {
2483
2536
  (t.key === "Enter" || t.key === " ") && (t.preventDefault(), e());
2484
- }, C = b ? "cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]" : "", w = Array.isArray(d) ? d : [], { rowKeys: T, colKeys: E, matrix: D, rowTotals: O, colTotals: k, grandTotal: A } = X(() => {
2537
+ }, C = b ? "cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]" : "", w = Array.isArray(d) ? d : [], { rowKeys: T, colKeys: E, matrix: ee, rowTotals: D, colTotals: O, grandTotal: te } = X(() => {
2485
2538
  let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = {};
2486
2539
  for (let r of w) {
2487
2540
  let i = String(r[s] ?? ""), a = String(r[c] ?? ""), o = Number(r[l]) || 0;
@@ -2492,10 +2545,10 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2492
2545
  a[e] = {};
2493
2546
  let t = [];
2494
2547
  for (let r of i) {
2495
- let i = n[e]?.[r] ?? [], o = Dn(i, u);
2548
+ let i = n[e]?.[r] ?? [], o = Mn(i, u);
2496
2549
  a[e][r] = o, t.push(...i), !d[r] && d[r];
2497
2550
  }
2498
- o[e] = Dn(t, u);
2551
+ o[e] = Mn(t, u);
2499
2552
  }
2500
2553
  for (let e of i) {
2501
2554
  let t = [];
@@ -2503,7 +2556,7 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2503
2556
  let r = n[i]?.[e] ?? [];
2504
2557
  t.push(...r);
2505
2558
  }
2506
- d[e] = Dn(t, u);
2559
+ d[e] = Mn(t, u);
2507
2560
  }
2508
2561
  let f = [];
2509
2562
  for (let e of w) f.push(Number(e[l]) || 0);
@@ -2513,7 +2566,7 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2513
2566
  matrix: a,
2514
2567
  rowTotals: o,
2515
2568
  colTotals: d,
2516
- grandTotal: Dn(f, u)
2569
+ grandTotal: Mn(f, u)
2517
2570
  };
2518
2571
  }, [
2519
2572
  w,
@@ -2521,13 +2574,13 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2521
2574
  c,
2522
2575
  l,
2523
2576
  u
2524
- ]), j = (e) => wn(e, m);
2525
- return w.length === 0 ? /* @__PURE__ */ $("div", {
2577
+ ]), k = (e) => On(e, m);
2578
+ return jn.has(u) ? w.length === 0 ? /* @__PURE__ */ $("div", {
2526
2579
  className: K("overflow-auto", t),
2527
2580
  children: [o && /* @__PURE__ */ Q("h3", {
2528
2581
  className: "text-sm font-semibold mb-2",
2529
2582
  children: o
2530
- }), /* @__PURE__ */ Q(ce, {
2583
+ }), /* @__PURE__ */ Q(R, {
2531
2584
  "data-testid": "pivot-empty-state",
2532
2585
  className: "py-8 gap-2 [&>h3]:hidden",
2533
2586
  icon: /* @__PURE__ */ $("svg", {
@@ -2592,14 +2645,14 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2592
2645
  colKey: e
2593
2646
  });
2594
2647
  return /* @__PURE__ */ Q("th", {
2595
- className: K("text-right p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70", g?.[e] ?? "text-muted-foreground", C),
2648
+ className: K("text-right p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70", h?.[e] ?? "text-muted-foreground", C),
2596
2649
  title: e === "" ? `${c}: (empty)` : `${c}: ${e}`,
2597
2650
  role: b ? "button" : void 0,
2598
2651
  tabIndex: b ? 0 : void 0,
2599
2652
  onClick: b ? t : void 0,
2600
2653
  onKeyDown: b ? S(t) : void 0,
2601
2654
  "aria-label": b ? `Drill into ${c}: ${e || "(empty)"}` : void 0,
2602
- children: En(e, r)
2655
+ children: An(e, r)
2603
2656
  }, e);
2604
2657
  }),
2605
2658
  f && /* @__PURE__ */ Q("th", {
@@ -2624,23 +2677,23 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2624
2677
  rowKey: e
2625
2678
  })) : void 0,
2626
2679
  "aria-label": b ? `Drill into ${s}: ${e || "(empty)"}` : void 0,
2627
- children: En(e, n)
2680
+ children: An(e, n)
2628
2681
  }),
2629
2682
  E.map((t) => {
2630
- let n = D[e]?.[t] ?? 0, r = () => x({
2683
+ let n = ee[e]?.[t] ?? 0, r = () => x({
2631
2684
  scope: "cell",
2632
2685
  rowKey: e,
2633
2686
  colKey: t,
2634
2687
  value: n
2635
2688
  });
2636
2689
  return /* @__PURE__ */ Q("td", {
2637
- className: K("text-right p-2 tabular-nums", g?.[t], C),
2690
+ className: K("text-right p-2 tabular-nums", h?.[t], C),
2638
2691
  role: b ? "button" : void 0,
2639
2692
  tabIndex: b ? 0 : void 0,
2640
2693
  onClick: b ? r : void 0,
2641
2694
  onKeyDown: b ? S(r) : void 0,
2642
2695
  "aria-label": b ? `Drill into ${s}=${e || "(empty)"}, ${c}=${t || "(empty)"}` : void 0,
2643
- children: j(n)
2696
+ children: k(n)
2644
2697
  }, t);
2645
2698
  }),
2646
2699
  f && /* @__PURE__ */ Q("td", {
@@ -2650,14 +2703,14 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2650
2703
  onClick: b ? () => x({
2651
2704
  scope: "row",
2652
2705
  rowKey: e,
2653
- value: O[e] ?? 0
2706
+ value: D[e] ?? 0
2654
2707
  }) : void 0,
2655
2708
  onKeyDown: b ? S(() => x({
2656
2709
  scope: "row",
2657
2710
  rowKey: e,
2658
- value: O[e] ?? 0
2711
+ value: D[e] ?? 0
2659
2712
  })) : void 0,
2660
- children: j(O[e] ?? 0)
2713
+ children: k(D[e] ?? 0)
2661
2714
  })
2662
2715
  ]
2663
2716
  }, e)) }),
@@ -2675,14 +2728,14 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2675
2728
  onClick: b ? () => x({
2676
2729
  scope: "column",
2677
2730
  colKey: e,
2678
- value: k[e] ?? 0
2731
+ value: O[e] ?? 0
2679
2732
  }) : void 0,
2680
2733
  onKeyDown: b ? S(() => x({
2681
2734
  scope: "column",
2682
2735
  colKey: e,
2683
- value: k[e] ?? 0
2736
+ value: O[e] ?? 0
2684
2737
  })) : void 0,
2685
- children: j(k[e] ?? 0)
2738
+ children: k(O[e] ?? 0)
2686
2739
  }, e)),
2687
2740
  f && /* @__PURE__ */ Q("td", {
2688
2741
  className: K("text-right p-2 tabular-nums font-bold", C),
@@ -2690,24 +2743,45 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2690
2743
  tabIndex: b ? 0 : void 0,
2691
2744
  onClick: b ? () => x({
2692
2745
  scope: "total",
2693
- value: A
2746
+ value: te
2694
2747
  }) : void 0,
2695
2748
  onKeyDown: b ? S(() => x({
2696
2749
  scope: "total",
2697
- value: A
2750
+ value: te
2698
2751
  })) : void 0,
2699
- children: j(A)
2752
+ children: k(te)
2700
2753
  })
2701
2754
  ]
2702
2755
  }) })
2703
2756
  ]
2704
2757
  })]
2758
+ }) : /* @__PURE__ */ $("div", {
2759
+ className: K("overflow-auto", t),
2760
+ "data-testid": "pivot-unsupported-aggregation",
2761
+ children: [o && /* @__PURE__ */ Q("h3", {
2762
+ className: "text-sm font-semibold mb-2",
2763
+ children: o
2764
+ }), /* @__PURE__ */ Q("div", {
2765
+ role: "alert",
2766
+ className: "flex flex-col items-center justify-center py-8 text-destructive",
2767
+ children: /* @__PURE__ */ $("p", {
2768
+ className: "text-xs",
2769
+ children: [
2770
+ "Unsupported aggregation “",
2771
+ String(u),
2772
+ "” — this pivot table renders",
2773
+ " ",
2774
+ [...jn].join(", "),
2775
+ "."
2776
+ ]
2777
+ })
2778
+ })]
2705
2779
  });
2706
- }, kn = ({ schema: e, dataSource: t, className: n }) => {
2707
- let r = Oe(w), i = t || r?.dataSource, a = E(e.bind), [o, s] = Z([]), [c, u] = Z(!1), [f, p] = Z(null), [m, g] = Z({}), [_, v] = Z({}), [x, S] = Z(null), { fieldLabel: C, fieldOptionLabel: T } = ne(), D = ke(C), O = ke(T);
2780
+ }, Pn = ({ schema: e, dataSource: t, className: n }) => {
2781
+ let r = Ae(T), i = t || r?.dataSource, a = ee(e.bind), [o, s] = Z([]), [c, l] = Z(!1), [d, p] = Z(null), [m, h] = Z({}), [_, v] = Z({}), [y, S] = Z(null), { fieldLabel: C, fieldOptionLabel: w } = ae(), E = je(C), D = je(w);
2708
2782
  Y(() => {
2709
- D.current = C, O.current = T;
2710
- }, [C, T]), Y(() => {
2783
+ E.current = C, D.current = w;
2784
+ }, [C, w]), Y(() => {
2711
2785
  if (!i || !e.objectName) return;
2712
2786
  let t = i.getObjectSchema;
2713
2787
  if (typeof t != "function") return;
@@ -2717,35 +2791,37 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2717
2791
  let r = e.objectName, i = {}, a = {};
2718
2792
  for (let [e, n] of Object.entries(t.fields)) {
2719
2793
  let t = n?.label ? String(n.label) : e;
2720
- a[e] = D.current(r, e, t);
2794
+ a[e] = E.current(r, e, t);
2721
2795
  let o = n?.options;
2722
2796
  if (Array.isArray(o) && o.length > 0) {
2723
2797
  let t = {};
2724
2798
  for (let n of o) if (n && n.value !== void 0 && n.label !== void 0) {
2725
2799
  let i = String(n.value), a = String(n.label);
2726
- t[i] = O.current(r, e, i, a);
2800
+ t[i] = D.current(r, e, i, a);
2727
2801
  }
2728
2802
  Object.keys(t).length > 0 && (i[e] = t);
2729
2803
  }
2730
2804
  }
2731
- g(i), v(a);
2805
+ h(i), v(a);
2732
2806
  }).catch(() => {}), () => {
2733
2807
  n = !1;
2734
2808
  };
2735
- }, [i, e.objectName]), Y(() => {
2809
+ }, [i, e.objectName]);
2810
+ let O = te();
2811
+ Y(() => {
2736
2812
  let t = !0;
2737
2813
  return e.objectName && !a && (!e.data || e.data.length === 0) && (async () => {
2738
2814
  if (!(!i || !e.objectName)) {
2739
- t && (u(!0), p(null));
2815
+ t && (l(!0), p(null));
2740
2816
  try {
2741
2817
  let n;
2742
- if (typeof i.find == "function") n = d(await i.find(e.objectName, { $filter: y(e.filter) }));
2818
+ if (typeof i.find == "function") n = f(await i.find(e.objectName, { $filter: x(e.filter, O) }));
2743
2819
  else return;
2744
2820
  t && s(n);
2745
2821
  } catch (e) {
2746
2822
  console.error("[ObjectPivotTable] Fetch error:", e), t && p(e instanceof Error ? e.message : "Failed to load data");
2747
2823
  } finally {
2748
- t && u(!1);
2824
+ t && l(!1);
2749
2825
  }
2750
2826
  }
2751
2827
  })(), () => {
@@ -2756,10 +2832,11 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2756
2832
  i,
2757
2833
  a,
2758
2834
  e.data,
2759
- e.filter
2835
+ e.filter,
2836
+ O
2760
2837
  ]);
2761
- let k = a || e.data || o, A = Array.isArray(k) ? k : [];
2762
- if (c && A.length === 0) return /* @__PURE__ */ $("div", {
2838
+ let k = a || e.data || o, ne = Array.isArray(k) ? k : [];
2839
+ if (c && ne.length === 0) return /* @__PURE__ */ $("div", {
2763
2840
  className: K("overflow-auto", n),
2764
2841
  "data-testid": "pivot-loading",
2765
2842
  children: [e.title && /* @__PURE__ */ Q("h3", {
@@ -2790,7 +2867,7 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2790
2867
  }, e))]
2791
2868
  })]
2792
2869
  });
2793
- if (f) return /* @__PURE__ */ $("div", {
2870
+ if (d) return /* @__PURE__ */ $("div", {
2794
2871
  className: K("overflow-auto", n),
2795
2872
  "data-testid": "pivot-error",
2796
2873
  children: [e.title && /* @__PURE__ */ Q("h3", {
@@ -2829,11 +2906,11 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2829
2906
  ]
2830
2907
  }), /* @__PURE__ */ Q("p", {
2831
2908
  className: "text-xs",
2832
- children: f
2909
+ children: d
2833
2910
  })]
2834
2911
  })]
2835
2912
  });
2836
- if (!i && e.objectName && A.length === 0) return /* @__PURE__ */ $("div", {
2913
+ if (!i && e.objectName && ne.length === 0) return /* @__PURE__ */ $("div", {
2837
2914
  className: K("overflow-auto", n),
2838
2915
  children: [e.title && /* @__PURE__ */ Q("h3", {
2839
2916
  className: "text-sm font-semibold mb-2",
@@ -2850,40 +2927,40 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
2850
2927
  })
2851
2928
  })]
2852
2929
  });
2853
- let j = {
2930
+ let re = {
2854
2931
  ...e,
2855
- data: A
2856
- }, M = e.rowField ? m[e.rowField] : void 0, ee = e.columnField ? m[e.columnField] : void 0, te = e.rowField ? _[e.rowField] : void 0, N = e.drillDown;
2857
- return /* @__PURE__ */ $(lt, { children: [/* @__PURE__ */ Q(On, {
2858
- schema: j,
2932
+ data: ne
2933
+ }, A = e.rowField ? m[e.rowField] : void 0, ie = e.columnField ? m[e.columnField] : void 0, j = e.rowField ? _[e.rowField] : void 0, M = e.drillDown;
2934
+ return /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q(Nn, {
2935
+ schema: re,
2859
2936
  className: n,
2860
- rowLabels: M,
2861
- columnLabels: ee,
2862
- rowFieldLabel: te,
2863
- onDrillDown: h(N) ? (e) => S(e) : void 0
2937
+ rowLabels: A,
2938
+ columnLabels: ie,
2939
+ rowFieldLabel: j,
2940
+ onDrillDown: g(M) ? (e) => S(e) : void 0
2864
2941
  }), (() => {
2865
- if (!x || !e.objectName) return null;
2866
- let t = l(N, x, {
2942
+ if (!y || !e.objectName) return null;
2943
+ let t = u(M, y, {
2867
2944
  rowField: e.rowField,
2868
2945
  columnField: e.columnField
2869
2946
  }), n = {
2870
2947
  ...e.filter || {},
2871
2948
  ...t
2872
2949
  };
2873
- return /* @__PURE__ */ Q(kt, {
2950
+ return /* @__PURE__ */ Q(Lt, {
2874
2951
  open: !0,
2875
2952
  onClose: () => S(null),
2876
- title: b(N, x, e.title || "Details"),
2877
- target: N?.target ?? "drawer",
2953
+ title: b(M, y, e.title || "Details"),
2954
+ target: M?.target ?? "drawer",
2878
2955
  objectName: e.objectName,
2879
2956
  filter: n,
2880
2957
  dataSource: i,
2881
- columns: N?.columns,
2882
- maxRows: N?.maxRows,
2883
- report: N?.report
2958
+ columns: M?.columns,
2959
+ maxRows: M?.maxRows,
2960
+ report: M?.report
2884
2961
  });
2885
2962
  })()] });
2886
- }, An = {
2963
+ }, Fn = {
2887
2964
  breadcrumb: ["Dashboard", "Configuration"],
2888
2965
  sections: [
2889
2966
  {
@@ -3009,12 +3086,12 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
3009
3086
  }
3010
3087
  ]
3011
3088
  };
3012
- function jn({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
3013
- let { draft: a, isDirty: o, updateField: s, discard: c } = we(n, { onUpdate: i });
3014
- return /* @__PURE__ */ Q(oe, {
3089
+ function In({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
3090
+ let { draft: a, isDirty: o, updateField: s, discard: c } = Ee(n, { onUpdate: i });
3091
+ return /* @__PURE__ */ Q(de, {
3015
3092
  open: e,
3016
3093
  onClose: t,
3017
- schema: An,
3094
+ schema: Fn,
3018
3095
  draft: a,
3019
3096
  isDirty: o,
3020
3097
  onFieldChange: s,
@@ -3024,7 +3101,7 @@ function jn({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
3024
3101
  }
3025
3102
  //#endregion
3026
3103
  //#region src/WidgetConfigPanel.tsx
3027
- var Mn = [
3104
+ var Ln = [
3028
3105
  {
3029
3106
  value: "metric",
3030
3107
  label: "Metric"
@@ -3069,7 +3146,7 @@ var Mn = [
3069
3146
  value: "pivot",
3070
3147
  label: "Pivot Table"
3071
3148
  }
3072
- ], Nn = [
3149
+ ], Rn = [
3073
3150
  {
3074
3151
  value: "default",
3075
3152
  label: "Default"
@@ -3102,7 +3179,7 @@ var Mn = [
3102
3179
  value: "danger",
3103
3180
  label: "Danger"
3104
3181
  }
3105
- ], Pn = [
3182
+ ], zn = [
3106
3183
  "bar",
3107
3184
  "horizontal-bar",
3108
3185
  "line",
@@ -3111,20 +3188,20 @@ var Mn = [
3111
3188
  "donut",
3112
3189
  "scatter",
3113
3190
  "funnel"
3114
- ], Fn = [
3191
+ ], Bn = [
3115
3192
  "metric",
3116
3193
  "gauge",
3117
3194
  "solid-gauge",
3118
3195
  "kpi",
3119
3196
  "bullet"
3120
3197
  ];
3121
- function In(e) {
3122
- return !!e && Pn.includes(e);
3198
+ function Vn(e) {
3199
+ return !!e && zn.includes(e);
3123
3200
  }
3124
- function Ln(e) {
3125
- return !!e && !Fn.includes(e);
3201
+ function Hn(e) {
3202
+ return !!e && !Bn.includes(e);
3126
3203
  }
3127
- function Rn({ names: e, options: t, placeholder: n, emptyText: r, onChange: i }) {
3204
+ function Un({ names: e, options: t, placeholder: n, emptyText: r, onChange: i }) {
3128
3205
  let [a, o] = q.useState(""), s = q.useMemo(() => new Set(e), [e]), c = q.useMemo(() => t.filter((e) => !s.has(e.value)), [t, s]), l = (t) => {
3129
3206
  let n = t.trim();
3130
3207
  !n || s.has(n) || (i([...e, n]), o(""));
@@ -3144,10 +3221,10 @@ function Rn({ names: e, options: t, placeholder: n, emptyText: r, onChange: i })
3144
3221
  "aria-label": `Remove ${e}`,
3145
3222
  className: "text-muted-foreground hover:text-foreground",
3146
3223
  onClick: () => u(e),
3147
- children: /* @__PURE__ */ Q(Ke, { className: "h-3 w-3" })
3224
+ children: /* @__PURE__ */ Q(Je, { className: "h-3 w-3" })
3148
3225
  })]
3149
3226
  }, e))
3150
- }), c.length > 0 ? /* @__PURE__ */ Q(z, {
3227
+ }), c.length > 0 ? /* @__PURE__ */ Q(ue, {
3151
3228
  options: c,
3152
3229
  value: "",
3153
3230
  onValueChange: l,
@@ -3157,7 +3234,7 @@ function Rn({ names: e, options: t, placeholder: n, emptyText: r, onChange: i })
3157
3234
  className: "h-7 w-full text-xs"
3158
3235
  }) : /* @__PURE__ */ $("div", {
3159
3236
  className: "flex items-center gap-1",
3160
- children: [/* @__PURE__ */ Q(fe, {
3237
+ children: [/* @__PURE__ */ Q(he, {
3161
3238
  value: a,
3162
3239
  onChange: (e) => o(e.target.value),
3163
3240
  onKeyDown: (e) => {
@@ -3165,7 +3242,7 @@ function Rn({ names: e, options: t, placeholder: n, emptyText: r, onChange: i })
3165
3242
  },
3166
3243
  placeholder: n,
3167
3244
  className: "h-7 flex-1 text-xs"
3168
- }), /* @__PURE__ */ Q(F, {
3245
+ }), /* @__PURE__ */ Q(P, {
3169
3246
  type: "button",
3170
3247
  size: "sm",
3171
3248
  variant: "outline",
@@ -3177,7 +3254,7 @@ function Rn({ names: e, options: t, placeholder: n, emptyText: r, onChange: i })
3177
3254
  })]
3178
3255
  });
3179
3256
  }
3180
- function zn(e, t) {
3257
+ function Wn(e, t) {
3181
3258
  let n = e ?? [], r = n.length > 0, i = n.map((e) => ({
3182
3259
  value: e.name,
3183
3260
  label: e.label && e.label !== e.name ? `${e.label} (${e.name})` : e.name
@@ -3186,11 +3263,11 @@ function zn(e, t) {
3186
3263
  label: "Dataset",
3187
3264
  type: "custom",
3188
3265
  helpText: "The semantic-layer dataset this widget binds to (ADR-0021).",
3189
- render: (e, t) => /* @__PURE__ */ Q(se, {
3266
+ render: (e, t) => /* @__PURE__ */ Q(L, {
3190
3267
  label: "Dataset",
3191
3268
  children: /* @__PURE__ */ Q("div", {
3192
3269
  "data-testid": "config-field-dataset",
3193
- children: /* @__PURE__ */ Q(z, {
3270
+ children: /* @__PURE__ */ Q(ue, {
3194
3271
  options: i,
3195
3272
  value: e ?? "",
3196
3273
  onValueChange: t,
@@ -3211,19 +3288,19 @@ function zn(e, t) {
3211
3288
  key: "dimensions",
3212
3289
  label: "Dimensions",
3213
3290
  type: "custom",
3214
- visibleWhen: (e) => Ln(e.type),
3291
+ visibleWhen: (e) => Hn(e.type),
3215
3292
  helpText: t === "pivot" ? "Group/split fields. The last dimension spreads across as columns." : "Group/split the values by these dataset dimensions.",
3216
3293
  render: (e, t, n) => {
3217
3294
  let r = (a(n.dataset)?.dimensions ?? []).map((e) => ({
3218
3295
  value: e.name,
3219
3296
  label: e.label && e.label !== e.name ? `${e.label} (${e.name})` : e.name
3220
3297
  }));
3221
- return /* @__PURE__ */ Q(se, {
3298
+ return /* @__PURE__ */ Q(L, {
3222
3299
  label: "Dimensions",
3223
3300
  children: /* @__PURE__ */ Q("div", {
3224
3301
  "data-testid": "config-field-dimensions",
3225
3302
  className: "w-40",
3226
- children: /* @__PURE__ */ Q(Rn, {
3303
+ children: /* @__PURE__ */ Q(Un, {
3227
3304
  names: Array.isArray(e) ? e : [],
3228
3305
  options: r,
3229
3306
  placeholder: "Add dimension…",
@@ -3238,7 +3315,7 @@ function zn(e, t) {
3238
3315
  breadcrumb: ["Dashboard", {
3239
3316
  pivot: "Pivot table",
3240
3317
  table: "Table"
3241
- }[t ?? ""] ?? (In(t) ? "Chart" : "Widget")],
3318
+ }[t ?? ""] ?? (Vn(t) ? "Chart" : "Widget")],
3242
3319
  sections: [
3243
3320
  {
3244
3321
  key: "general",
@@ -3260,7 +3337,7 @@ function zn(e, t) {
3260
3337
  key: "type",
3261
3338
  label: "Widget type",
3262
3339
  type: "select",
3263
- options: Mn,
3340
+ options: Ln,
3264
3341
  defaultValue: "metric"
3265
3342
  }
3266
3343
  ]
@@ -3282,12 +3359,12 @@ function zn(e, t) {
3282
3359
  value: e.name,
3283
3360
  label: e.aggregate ? `${e.label ?? e.name} · ${e.aggregate}` : e.label ?? e.name
3284
3361
  }));
3285
- return /* @__PURE__ */ Q(se, {
3362
+ return /* @__PURE__ */ Q(L, {
3286
3363
  label: "Values",
3287
3364
  children: /* @__PURE__ */ Q("div", {
3288
3365
  "data-testid": "config-field-values",
3289
3366
  className: "w-40",
3290
- children: /* @__PURE__ */ Q(Rn, {
3367
+ children: /* @__PURE__ */ Q(Un, {
3291
3368
  names: Array.isArray(e) ? e : [],
3292
3369
  options: r,
3293
3370
  placeholder: "Add measure…",
@@ -3343,14 +3420,14 @@ function zn(e, t) {
3343
3420
  key: "colorVariant",
3344
3421
  label: "Color variant",
3345
3422
  type: "select",
3346
- options: Nn,
3423
+ options: Rn,
3347
3424
  defaultValue: "default"
3348
3425
  }]
3349
3426
  }
3350
3427
  ]
3351
3428
  };
3352
3429
  }
3353
- function Bn(e) {
3430
+ function Gn(e) {
3354
3431
  if (e == null) return "";
3355
3432
  if (typeof e == "string") return e;
3356
3433
  if (typeof e == "object") {
@@ -3359,7 +3436,7 @@ function Bn(e) {
3359
3436
  }
3360
3437
  return String(e);
3361
3438
  }
3362
- var Vn = [
3439
+ var Kn = [
3363
3440
  "object",
3364
3441
  "categoryField",
3365
3442
  "categoryGranularity",
@@ -3386,32 +3463,32 @@ var Vn = [
3386
3463
  "searchable",
3387
3464
  "pagination"
3388
3465
  ];
3389
- function Hn(e) {
3466
+ function qn(e) {
3390
3467
  let t = e.type, n = { ...e };
3391
- for (let e of Vn) delete n[e];
3392
- return Ln(t) || delete n.dimensions, n;
3468
+ for (let e of Kn) delete n[e];
3469
+ return Hn(t) || delete n.dimensions, n;
3393
3470
  }
3394
- function Un({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i, headerExtra: a, datasets: o, datasetsLoading: s }) {
3395
- let { draft: c, isDirty: l, updateField: u, discard: d } = we(q.useMemo(() => ({
3471
+ function Jn({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i, headerExtra: a, datasets: o, datasetsLoading: s }) {
3472
+ let { draft: c, isDirty: l, updateField: u, discard: d } = Ee(q.useMemo(() => ({
3396
3473
  ...n,
3397
- title: typeof n.title == "object" ? Bn(n.title) : n.title,
3398
- description: typeof n.description == "object" ? Bn(n.description) : n.description
3474
+ title: typeof n.title == "object" ? Gn(n.title) : n.title,
3475
+ description: typeof n.description == "object" ? Gn(n.description) : n.description
3399
3476
  }), [n]), { onUpdate: i });
3400
- return /* @__PURE__ */ Q(oe, {
3477
+ return /* @__PURE__ */ Q(de, {
3401
3478
  open: e,
3402
3479
  onClose: t,
3403
- schema: q.useMemo(() => zn(o, c.type), [o, c.type]),
3480
+ schema: q.useMemo(() => Wn(o, c.type), [o, c.type]),
3404
3481
  draft: c,
3405
3482
  isDirty: l,
3406
3483
  onFieldChange: u,
3407
- onSave: () => r(Hn(c)),
3484
+ onSave: () => r(qn(c)),
3408
3485
  onDiscard: d,
3409
3486
  headerExtra: a
3410
3487
  });
3411
3488
  }
3412
3489
  //#endregion
3413
3490
  //#region src/DashboardWithConfig.tsx
3414
- function Wn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh: i, recordCount: a, defaultConfigOpen: o = !1, className: s, datasets: c, datasetsLoading: l }) {
3491
+ function Yn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh: i, recordCount: a, defaultConfigOpen: o = !1, className: s, datasets: c, datasetsLoading: l }) {
3415
3492
  let [u, d] = Z(o), [f, p] = Z(null), [m, h] = Z(e), [g, _] = Z(0);
3416
3493
  Y(() => {
3417
3494
  h(e), _((e) => e + 1);
@@ -3470,14 +3547,14 @@ function Wn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
3470
3547
  className: "flex-1 min-w-0 overflow-auto relative",
3471
3548
  children: [/* @__PURE__ */ Q("div", {
3472
3549
  className: "absolute top-2 right-2 z-10",
3473
- children: /* @__PURE__ */ $(F, {
3550
+ children: /* @__PURE__ */ $(P, {
3474
3551
  size: "sm",
3475
3552
  variant: u ? "default" : "outline",
3476
3553
  onClick: C,
3477
3554
  "data-testid": "dashboard-config-toggle",
3478
- children: [/* @__PURE__ */ Q(Ge, { className: "h-3.5 w-3.5 mr-1" }), "Settings"]
3555
+ children: [/* @__PURE__ */ Q(qe, { className: "h-3.5 w-3.5 mr-1" }), "Settings"]
3479
3556
  })
3480
- }), /* @__PURE__ */ Q(on, {
3557
+ }), /* @__PURE__ */ Q(un, {
3481
3558
  schema: m,
3482
3559
  onRefresh: i,
3483
3560
  recordCount: a,
@@ -3487,7 +3564,7 @@ function Wn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
3487
3564
  })]
3488
3565
  }), u && /* @__PURE__ */ Q("div", {
3489
3566
  className: "relative shrink-0",
3490
- children: f && v ? /* @__PURE__ */ Q(Un, {
3567
+ children: f && v ? /* @__PURE__ */ Q(Jn, {
3491
3568
  open: !0,
3492
3569
  onClose: b,
3493
3570
  config: v,
@@ -3495,7 +3572,7 @@ function Wn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
3495
3572
  onFieldChange: x,
3496
3573
  datasets: c,
3497
3574
  datasetsLoading: l
3498
- }) : /* @__PURE__ */ Q(jn, {
3575
+ }) : /* @__PURE__ */ Q(In, {
3499
3576
  open: !0,
3500
3577
  onClose: () => d(!1),
3501
3578
  config: t,
@@ -3504,7 +3581,7 @@ function Wn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
3504
3581
  })]
3505
3582
  });
3506
3583
  }
3507
- e.register("dashboard", on, {
3584
+ e.register("dashboard", un, {
3508
3585
  namespace: "view",
3509
3586
  label: "Dashboard",
3510
3587
  category: "Complex",
@@ -3532,7 +3609,7 @@ e.register("dashboard", on, {
3532
3609
  columns: 3,
3533
3610
  widgets: []
3534
3611
  }
3535
- }), e.register("metric", vn, {
3612
+ }), e.register("metric", Sn, {
3536
3613
  namespace: "plugin-dashboard",
3537
3614
  label: "Metric Widget",
3538
3615
  category: "Dashboard",
@@ -3545,7 +3622,7 @@ e.register("dashboard", on, {
3545
3622
  type: "string",
3546
3623
  label: "Value"
3547
3624
  }]
3548
- }), e.register("metric-card", bn, {
3625
+ }), e.register("metric-card", wn, {
3549
3626
  namespace: "plugin-dashboard",
3550
3627
  label: "Metric Card",
3551
3628
  category: "Dashboard",
@@ -3600,7 +3677,7 @@ e.register("dashboard", on, {
3600
3677
  title: "Metric",
3601
3678
  value: "0"
3602
3679
  }
3603
- }), e.register("object-metric", xn, {
3680
+ }), e.register("object-metric", Tn, {
3604
3681
  namespace: "plugin-dashboard",
3605
3682
  label: "Object Metric",
3606
3683
  category: "Dashboard",
@@ -3629,7 +3706,7 @@ e.register("dashboard", on, {
3629
3706
  }
3630
3707
  ],
3631
3708
  defaultProps: { label: "Metric" }
3632
- }), e.register("pivot", On, {
3709
+ }), e.register("pivot", Nn, {
3633
3710
  namespace: "plugin-dashboard",
3634
3711
  label: "Pivot Table",
3635
3712
  category: "Dashboard",
@@ -3708,7 +3785,7 @@ e.register("dashboard", on, {
3708
3785
  aggregation: "sum",
3709
3786
  data: []
3710
3787
  }
3711
- }), e.register("object-pivot", kn, {
3788
+ }), e.register("object-pivot", Pn, {
3712
3789
  namespace: "plugin-dashboard",
3713
3790
  label: "Object Pivot Table",
3714
3791
  category: "Dashboard",
@@ -3797,7 +3874,7 @@ e.register("dashboard", on, {
3797
3874
  valueField: "",
3798
3875
  aggregation: "sum"
3799
3876
  }
3800
- }), e.register("dashboard-grid", dn, {
3877
+ }), e.register("dashboard-grid", hn, {
3801
3878
  namespace: "plugin-dashboard",
3802
3879
  label: "Dashboard Grid (Editable)",
3803
3880
  category: "Complex",
@@ -3815,7 +3892,7 @@ e.register("dashboard", on, {
3815
3892
  title: "Dashboard",
3816
3893
  widgets: []
3817
3894
  }
3818
- }), e.register("object-data-table", Dt, {
3895
+ }), e.register("object-data-table", Ft, {
3819
3896
  namespace: "plugin-dashboard",
3820
3897
  label: "Object Data Table",
3821
3898
  category: "Dashboard",
@@ -3853,18 +3930,18 @@ e.register("dashboard", on, {
3853
3930
  pagination: !1
3854
3931
  }
3855
3932
  });
3856
- var Gn = {
3857
- DashboardRenderer: on,
3858
- DashboardGridLayout: dn,
3859
- MetricWidget: vn,
3860
- MetricCard: bn,
3861
- ObjectMetricWidget: xn,
3862
- PivotTable: On,
3863
- ObjectPivotTable: kn,
3864
- ObjectDataTable: Dt,
3865
- DashboardConfigPanel: jn,
3866
- WidgetConfigPanel: Un,
3867
- DashboardWithConfig: Wn
3933
+ var Xn = {
3934
+ DashboardRenderer: un,
3935
+ DashboardGridLayout: hn,
3936
+ MetricWidget: Sn,
3937
+ MetricCard: wn,
3938
+ ObjectMetricWidget: Tn,
3939
+ PivotTable: Nn,
3940
+ ObjectPivotTable: Pn,
3941
+ ObjectDataTable: Ft,
3942
+ DashboardConfigPanel: In,
3943
+ WidgetConfigPanel: Jn,
3944
+ DashboardWithConfig: Yn
3868
3945
  };
3869
3946
  //#endregion
3870
- export { jn as DashboardConfigPanel, dn as DashboardGridLayout, on as DashboardRenderer, Wn as DashboardWithConfig, kt as DrillDownDrawer, bn as MetricCard, vn as MetricWidget, Dt as ObjectDataTable, xn as ObjectMetricWidget, kn as ObjectPivotTable, On as PivotTable, Un as WidgetConfigPanel, Gn as dashboardComponents };
3947
+ export { In as DashboardConfigPanel, hn as DashboardGridLayout, un as DashboardRenderer, Yn as DashboardWithConfig, Lt as DrillDownDrawer, wn as MetricCard, Sn as MetricWidget, Ft as ObjectDataTable, Tn as ObjectMetricWidget, Pn as ObjectPivotTable, Nn as PivotTable, Jn as WidgetConfigPanel, Xn as dashboardComponents };