@object-ui/plugin-charts 17.3.0 → 17.6.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,87 +1,87 @@
1
- import { ComponentRegistry as e, buildCategoryRank as t, buildChartSeries as n, buildDimensionLabelMap as r, buildOptionColorMap as i, compareToTrendLabelKey as a, computeDrillFilter as o, extractRecords as s, isDrillEnabled as c, relabelDimensions as l, resolveContextTokens as u, resolveDrillTitle as d, resolveFilterPlaceholders as f, shiftFilterByCompareTo as p } from "@object-ui/core";
2
- import * as m from "react";
3
- import h, { Suspense as g, useCallback as ee, useContext as te, useEffect as ne, useMemo as _, useRef as re, useState as v } from "react";
4
- import { Button as ie, ChartSkeleton as y, Dialog as ae, DialogContent as b, DialogHeader as x, DialogTitle as S, RefreshIndicator as C, Sheet as oe, SheetContent as se, SheetHeader as ce, SheetTitle as le, Skeleton as ue } from "@object-ui/components";
5
- import { Fragment as de, jsx as w, jsxs as T } from "react/jsx-runtime";
6
- import { Area as fe, AreaChart as pe, Bar as me, BarChart as E, Brush as he, CartesianGrid as ge, Cell as D, ComposedChart as _e, Funnel as ve, FunnelChart as O, LabelList as k, Legend as A, Line as ye, LineChart as be, Pie as xe, PieChart as Se, PolarAngleAxis as Ce, PolarGrid as we, PolarRadiusAxis as Te, Radar as Ee, RadarChart as De, ReferenceArea as Oe, ReferenceLine as ke, ResponsiveContainer as Ae, Sankey as je, Scatter as Me, ScatterChart as j, Tooltip as M, Treemap as N, XAxis as P, YAxis as F, ZAxis as Ne } from "recharts";
7
- import { SchemaRenderer as Pe, SchemaRendererContext as Fe, useDataScope as Ie, useDrillNavigation as Le, useFilterScope as Re } from "@object-ui/react";
8
- import { AlertCircle as ze, ArrowUpRight as Be } from "lucide-react";
9
- import { useSafeFieldLabel as Ve, useSafeTranslate as I } from "@object-ui/i18n";
1
+ import { ComponentRegistry as e, buildCategoryRank as t, buildChartSeries as n, buildOptionColorMap as r, chartRowBucketId as i, compareToTrendLabelKey as a, computeDrillFilter as o, deriveDimensionLabelMaps as s, dimensionOptionTranslator as c, extractRecords as l, humanizeLabel as u, isDrillEnabled as d, loadDimensionFieldMeta as f, localizeFieldOptions as p, relabelDimensions as m, resolveContextTokens as ee, resolveDrillTitle as te, resolveFilterPlaceholders as ne, shiftFilterByCompareTo as re } from "@object-ui/core";
2
+ import * as h from "react";
3
+ import g, { Suspense as _, useCallback as ie, useContext as ae, useEffect as oe, useMemo as v, useState as y } from "react";
4
+ import { Button as b, ChartSkeleton as x, Dialog as S, DialogContent as C, DialogHeader as se, DialogTitle as ce, RefreshIndicator as le, Sheet as ue, SheetContent as de, SheetHeader as fe, SheetTitle as pe, Skeleton as w } from "@object-ui/components";
5
+ import { Fragment as me, jsx as T, jsxs as E } from "react/jsx-runtime";
6
+ import { Area as he, AreaChart as ge, Bar as _e, BarChart as D, Brush as ve, CartesianGrid as ye, Cell as be, ComposedChart as O, Funnel as xe, FunnelChart as Se, LabelList as Ce, Legend as k, Line as we, LineChart as Te, Pie as Ee, PieChart as De, PolarAngleAxis as Oe, PolarGrid as ke, PolarRadiusAxis as Ae, Radar as je, RadarChart as Me, ReferenceArea as Ne, ReferenceLine as Pe, ResponsiveContainer as Fe, Sankey as A, Scatter as j, ScatterChart as M, Tooltip as Ie, Treemap as Le, XAxis as N, YAxis as P, ZAxis as Re } from "recharts";
7
+ import { ElementDataSourceGate as F, SchemaRenderer as ze, SchemaRendererContext as Be, useDataScope as Ve, useDrillNavigation as He, useFilterScope as Ue } from "@object-ui/react";
8
+ import { AlertCircle as We, ArrowUpRight as Ge } from "lucide-react";
9
+ import { useSafeFieldLabel as Ke, useSafeTranslate as qe } from "@object-ui/i18n";
10
10
  //#region \0rolldown/runtime.js
11
- var L = Object.defineProperty, R = (e, t, n) => () => {
11
+ var I = Object.defineProperty, L = (e, t, n) => () => {
12
12
  if (n) throw n[0];
13
13
  try {
14
14
  return e && (t = e(e = 0)), t;
15
15
  } catch (e) {
16
16
  throw n = [e], e;
17
17
  }
18
- }, z = (e, t) => {
18
+ }, R = (e, t) => {
19
19
  let n = {};
20
- for (var r in e) L(n, r, {
20
+ for (var r in e) I(n, r, {
21
21
  get: e[r],
22
22
  enumerable: !0
23
23
  });
24
- return t || L(n, Symbol.toStringTag, { value: "Module" }), n;
24
+ return t || I(n, Symbol.toStringTag, { value: "Module" }), n;
25
25
  };
26
26
  //#endregion
27
27
  //#region src/normalizeChartSchema.ts
28
- function B(e) {
29
- let t = G(e);
28
+ function z(e) {
29
+ let t = W(e);
30
30
  if (t) return t;
31
- if (W(e)) return Object.values(e).find((e) => typeof e == "string" && e);
31
+ if (U(e)) return Object.values(e).find((e) => typeof e == "string" && e);
32
32
  }
33
- function V(e) {
34
- if (!W(e)) return;
35
- let t = {}, n = G(e.field);
33
+ function B(e) {
34
+ if (!U(e)) return;
35
+ let t = {}, n = W(e.field);
36
36
  n && (t.field = n);
37
- let r = G(e.format);
37
+ let r = W(e.format);
38
38
  r && (t.format = r);
39
- let i = K(e.min);
39
+ let i = G(e.min);
40
40
  i !== void 0 && (t.min = i);
41
- let a = K(e.max);
41
+ let a = G(e.max);
42
42
  a !== void 0 && (t.max = a);
43
- let o = K(e.stepSize);
43
+ let o = G(e.stepSize);
44
44
  o !== void 0 && o > 0 && (t.stepSize = o), typeof e.showGridLines == "boolean" && (t.showGridLines = e.showGridLines), typeof e.logarithmic == "boolean" && (t.logarithmic = e.logarithmic);
45
- let s = G(e.position);
45
+ let s = W(e.position);
46
46
  (s === "left" || s === "right" || s === "top" || s === "bottom") && (t.position = s);
47
- let c = B(e.title);
47
+ let c = z(e.title);
48
48
  return c && (t.title = c), t;
49
49
  }
50
- function H(e) {
51
- if (!W(e)) {
52
- let t = G(e);
50
+ function V(e) {
51
+ if (!U(e)) {
52
+ let t = W(e);
53
53
  return t ? { dataKey: t } : void 0;
54
54
  }
55
- let t = G(e.dataKey) ?? G(e.name);
55
+ let t = W(e.dataKey) ?? W(e.name);
56
56
  if (!t) return;
57
- let n = { dataKey: t }, r = B(e.label);
57
+ let n = { dataKey: t }, r = z(e.label);
58
58
  r && (n.label = r);
59
- let i = G(e.chartType) ?? G(e.type);
59
+ let i = W(e.chartType) ?? W(e.type);
60
60
  (i === "bar" || i === "line" || i === "area") && (n.chartType = i);
61
- let a = G(e.variant);
61
+ let a = W(e.variant);
62
62
  (a === "comparison" || a === "current" || a === "primary") && (n.variant = a);
63
- let o = K(e.opacity);
63
+ let o = G(e.opacity);
64
64
  o !== void 0 && (n.opacity = o);
65
- let s = G(e.dashArray);
65
+ let s = W(e.dashArray);
66
66
  s && (n.dashArray = s);
67
- let c = G(e.stack);
67
+ let c = W(e.stack);
68
68
  c && (n.stack = c);
69
- let l = G(e.yAxis);
69
+ let l = W(e.yAxis);
70
70
  (l === "left" || l === "right") && (n.yAxis = l);
71
- let u = G(e.color);
71
+ let u = W(e.color);
72
72
  return u && (n.color = u), n;
73
73
  }
74
- function He(e) {
75
- if (!W(e)) return {};
76
- let t = {}, n = G(e.type), r = G(e.chartType) ?? G(e.specType) ?? (n && Xe.has(n) ? n : void 0);
77
- r && qe.has(r) && (t.chartType = r);
78
- let i = e.xAxis, a = V(i);
74
+ function H(e) {
75
+ if (!U(e)) return {};
76
+ let t = {}, n = W(e.type), r = W(e.chartType) ?? W(e.specType) ?? (n && nt.has(n) ? n : void 0);
77
+ r && $e.has(r) && (t.chartType = r);
78
+ let i = e.xAxis, a = B(i);
79
79
  a && (a.format || a.title || a.showGridLines !== void 0) && (t.xAxis = a);
80
- let o = G(e.xAxisKey) ?? a?.field ?? G(i);
80
+ let o = W(e.xAxisKey) ?? a?.field ?? W(i);
81
81
  o && (t.xAxisKey = o);
82
- let s = (Array.isArray(e.yAxis) ? e.yAxis : e.yAxis === void 0 ? [] : [e.yAxis]).map((e) => V(e) ?? (G(e) ? { field: G(e) } : void 0)).filter((e) => !!e);
82
+ let s = (Array.isArray(e.yAxis) ? e.yAxis : e.yAxis === void 0 ? [] : [e.yAxis]).map((e) => B(e) ?? (W(e) ? { field: W(e) } : void 0)).filter((e) => !!e);
83
83
  s.length && (t.yAxes = s);
84
- let c = (Array.isArray(e.series) ? e.series : Array.isArray(e.categories) ? e.categories : void 0)?.map(H).filter((e) => !!e);
84
+ let c = (Array.isArray(e.series) ? e.series : Array.isArray(e.categories) ? e.categories : void 0)?.map(V).filter((e) => !!e);
85
85
  if (!c?.length) {
86
86
  let e = s.filter((e) => e.field).map((e, t) => ({
87
87
  dataKey: e.field,
@@ -91,28 +91,28 @@ function He(e) {
91
91
  e.length && (c = e);
92
92
  }
93
93
  c?.length && (t.series = c), typeof e.showLegend == "boolean" && (t.showLegend = e.showLegend), typeof e.showDataLabels == "boolean" && (t.showDataLabels = e.showDataLabels);
94
- let l = B(e.title);
94
+ let l = z(e.title);
95
95
  l && (t.title = l);
96
- let u = B(e.subtitle);
96
+ let u = z(e.subtitle);
97
97
  u && (t.subtitle = u);
98
- let d = B(e.description);
98
+ let d = z(e.description);
99
99
  d && (t.description = d);
100
- let f = K(e.height);
101
- return f !== void 0 && f > 0 && (t.height = f), Array.isArray(e.annotations) && e.annotations.length && (t.annotations = e.annotations.filter(W)), W(e.interaction) && (t.interaction = e.interaction), t;
100
+ let f = G(e.height);
101
+ return f !== void 0 && f > 0 && (t.height = f), Array.isArray(e.annotations) && e.annotations.length && (t.annotations = e.annotations.filter(U)), U(e.interaction) && (t.interaction = e.interaction), t;
102
102
  }
103
- function Ue(e) {
103
+ function Je(e) {
104
104
  if (e === "bar" || e === "column") return "bar";
105
105
  if (e === "line") return "line";
106
106
  if (e === "area") return "area";
107
107
  }
108
- function We(e, t) {
108
+ function Ye(e, t) {
109
109
  if (e === "combo") return "combo";
110
- let n = Ue(e);
110
+ let n = Je(e);
111
111
  if (!n || !t || t.length < 2) return e;
112
112
  let r = t.map((e) => e.chartType ?? n);
113
113
  return new Set(r).size > 1 ? "combo" : e;
114
114
  }
115
- function U(e) {
115
+ function Xe(e) {
116
116
  if (!e) return;
117
117
  let t = e.includes("%"), n = /^([$£€¥₹])/.exec(e), r = e.includes(","), i = /\.(0+)/.exec(e)?.[1].length ?? 0, a = {
118
118
  $: "USD",
@@ -137,24 +137,24 @@ function U(e) {
137
137
  }
138
138
  };
139
139
  }
140
- function Ge(e, t) {
140
+ function Ze(e, t) {
141
141
  let n = e?.stepSize;
142
142
  if (!n || n <= 0) return;
143
143
  let r = t.filter((e) => Number.isFinite(e)), i = r.length ? Math.min(...r) : void 0, a = r.length ? Math.max(...r) : void 0, o = e.min ?? Math.min(0, i ?? 0), s = e.max ?? a;
144
144
  if (s === void 0 || !Number.isFinite(o) || !Number.isFinite(s) || s < o) return;
145
145
  let c = Math.floor(o / n) * n, l = e.max === void 0 ? Math.ceil(s / n) * n : e.max, u = Math.floor((l - c) / n + 1e-9) + 1;
146
- if (u < 1 || u > Ze) return;
146
+ if (u < 1 || u > K) return;
147
147
  let d = [];
148
148
  for (let e = 0; e < u; e++) d.push(Number((c + e * n).toPrecision(12)));
149
149
  return e.max !== void 0 && d[d.length - 1] < e.max && d.push(e.max), d;
150
150
  }
151
- function Ke(e) {
151
+ function Qe(e) {
152
152
  if (!e) return;
153
153
  let { min: t, max: n } = e;
154
154
  if (t !== void 0 || n !== void 0) return [t ?? "auto", n ?? "auto"];
155
155
  }
156
- var qe, Je, Ye, Xe, W, G, K, Ze, Qe = R((() => {
157
- qe = /* @__PURE__ */ new Set([
156
+ var $e, et, tt, nt, U, W, G, K, rt = L((() => {
157
+ $e = /* @__PURE__ */ new Set([
158
158
  "bar",
159
159
  "column",
160
160
  "horizontal-bar",
@@ -168,44 +168,44 @@ var qe, Je, Ye, Xe, W, G, K, Ze, Qe = R((() => {
168
168
  "treemap",
169
169
  "sankey",
170
170
  "combo"
171
- ]), Je = /* @__PURE__ */ new Set([
171
+ ]), et = /* @__PURE__ */ new Set([
172
172
  "gauge",
173
173
  "solid-gauge",
174
174
  "metric",
175
175
  "kpi",
176
176
  "bullet"
177
- ]), Ye = /* @__PURE__ */ new Set(["table", "pivot"]), Xe = /* @__PURE__ */ new Set([
178
- ...qe,
179
- ...Je,
180
- ...Ye
181
- ]), W = (e) => !!e && typeof e == "object" && !Array.isArray(e), G = (e) => typeof e == "string" && e ? e : void 0, K = (e) => typeof e == "number" && Number.isFinite(e) ? e : void 0, Ze = 200;
182
- })), $e = /* @__PURE__ */ z({ default: () => tt });
183
- function et(e, t = 14) {
177
+ ]), tt = /* @__PURE__ */ new Set(["table", "pivot"]), nt = /* @__PURE__ */ new Set([
178
+ ...$e,
179
+ ...et,
180
+ ...tt
181
+ ]), U = (e) => !!e && typeof e == "object" && !Array.isArray(e), W = (e) => typeof e == "string" && e ? e : void 0, G = (e) => typeof e == "number" && Number.isFinite(e) ? e : void 0, K = 200;
182
+ })), it = /* @__PURE__ */ R({ default: () => st });
183
+ function at(e, t = 14) {
184
184
  return e.length > t ? `${e.slice(0, t - 1)}…` : e;
185
185
  }
186
- function q({ x: e, y: t, payload: n }) {
187
- let r = String(n?.value ?? ""), i = et(r);
188
- return /* @__PURE__ */ w("g", {
186
+ function ot({ x: e, y: t, payload: n }) {
187
+ let r = String(n?.value ?? ""), i = at(r);
188
+ return /* @__PURE__ */ T("g", {
189
189
  transform: `translate(${e},${t})`,
190
- children: /* @__PURE__ */ T("text", {
190
+ children: /* @__PURE__ */ E("text", {
191
191
  dy: 10,
192
192
  textAnchor: "end",
193
193
  transform: "rotate(-32)",
194
194
  fill: "hsl(var(--muted-foreground))",
195
195
  fontSize: 11,
196
196
  fontFamily: "monospace",
197
- children: [r !== i && /* @__PURE__ */ w("title", { children: r }), i]
197
+ children: [r !== i && /* @__PURE__ */ T("title", { children: r }), i]
198
198
  })
199
199
  });
200
200
  }
201
- function tt({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
201
+ function st({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
202
202
  let o = e.map((e) => String(e?.[n] ?? "")), s = o.length > 4 || o.some((e) => e.length > 8);
203
- return /* @__PURE__ */ w("div", {
203
+ return /* @__PURE__ */ T("div", {
204
204
  className: `p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${i}`,
205
- children: /* @__PURE__ */ w(Ae, {
205
+ children: /* @__PURE__ */ T(Fe, {
206
206
  width: "100%",
207
207
  height: r,
208
- children: /* @__PURE__ */ T(E, {
208
+ children: /* @__PURE__ */ E(D, {
209
209
  data: e,
210
210
  margin: {
211
211
  top: 10,
@@ -214,66 +214,66 @@ function tt({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
214
214
  bottom: s ? 24 : 5
215
215
  },
216
216
  children: [
217
- /* @__PURE__ */ T("defs", { children: [/* @__PURE__ */ T("linearGradient", {
217
+ /* @__PURE__ */ E("defs", { children: [/* @__PURE__ */ E("linearGradient", {
218
218
  id: "barGradient",
219
219
  x1: "0",
220
220
  y1: "0",
221
221
  x2: "0",
222
222
  y2: "1",
223
223
  children: [
224
- /* @__PURE__ */ w("stop", {
224
+ /* @__PURE__ */ T("stop", {
225
225
  offset: "0%",
226
226
  stopColor: a,
227
227
  stopOpacity: 1
228
228
  }),
229
- /* @__PURE__ */ w("stop", {
229
+ /* @__PURE__ */ T("stop", {
230
230
  offset: "90%",
231
231
  stopColor: a,
232
232
  stopOpacity: .6
233
233
  }),
234
- /* @__PURE__ */ w("stop", {
234
+ /* @__PURE__ */ T("stop", {
235
235
  offset: "100%",
236
236
  stopColor: a,
237
237
  stopOpacity: .3
238
238
  })
239
239
  ]
240
- }), /* @__PURE__ */ T("filter", {
240
+ }), /* @__PURE__ */ E("filter", {
241
241
  id: "glow",
242
242
  height: "130%",
243
243
  children: [
244
- /* @__PURE__ */ w("feGaussianBlur", {
244
+ /* @__PURE__ */ T("feGaussianBlur", {
245
245
  in: "SourceAlpha",
246
246
  stdDeviation: "3",
247
247
  result: "blur"
248
248
  }),
249
- /* @__PURE__ */ w("feOffset", {
249
+ /* @__PURE__ */ T("feOffset", {
250
250
  in: "blur",
251
251
  dx: "0",
252
252
  dy: "0",
253
253
  result: "offsetBlur"
254
254
  }),
255
- /* @__PURE__ */ w("feFlood", {
255
+ /* @__PURE__ */ T("feFlood", {
256
256
  floodColor: a,
257
257
  floodOpacity: "0.5",
258
258
  result: "offsetColor"
259
259
  }),
260
- /* @__PURE__ */ w("feComposite", {
260
+ /* @__PURE__ */ T("feComposite", {
261
261
  in: "offsetColor",
262
262
  in2: "offsetBlur",
263
263
  operator: "in",
264
264
  result: "offsetBlur"
265
265
  }),
266
- /* @__PURE__ */ T("feMerge", { children: [/* @__PURE__ */ w("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ w("feMergeNode", { in: "SourceGraphic" })] })
266
+ /* @__PURE__ */ E("feMerge", { children: [/* @__PURE__ */ T("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ T("feMergeNode", { in: "SourceGraphic" })] })
267
267
  ]
268
268
  })] }),
269
- /* @__PURE__ */ w(ge, {
269
+ /* @__PURE__ */ T(ye, {
270
270
  strokeDasharray: "3 3",
271
271
  stroke: "hsl(var(--border))",
272
272
  vertical: !1
273
273
  }),
274
- /* @__PURE__ */ w(P, {
274
+ /* @__PURE__ */ T(N, {
275
275
  dataKey: n,
276
- tick: s ? /* @__PURE__ */ w(q, {}) : {
276
+ tick: s ? /* @__PURE__ */ T(ot, {}) : {
277
277
  fill: "hsl(var(--muted-foreground))",
278
278
  fontSize: 12,
279
279
  fontFamily: "monospace"
@@ -284,7 +284,7 @@ function tt({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
284
284
  height: s ? 56 : void 0,
285
285
  dy: s ? void 0 : 10
286
286
  }),
287
- /* @__PURE__ */ w(F, {
287
+ /* @__PURE__ */ T(P, {
288
288
  tick: {
289
289
  fill: "hsl(var(--muted-foreground))",
290
290
  fontSize: 12,
@@ -293,7 +293,7 @@ function tt({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
293
293
  tickLine: !1,
294
294
  axisLine: !1
295
295
  }),
296
- /* @__PURE__ */ w(M, {
296
+ /* @__PURE__ */ T(Ie, {
297
297
  cursor: {
298
298
  fill: "hsl(var(--muted))",
299
299
  opacity: .2
@@ -308,11 +308,11 @@ function tt({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
308
308
  },
309
309
  itemStyle: { color: "hsl(var(--primary))" }
310
310
  }),
311
- /* @__PURE__ */ w(A, { wrapperStyle: {
311
+ /* @__PURE__ */ T(k, { wrapperStyle: {
312
312
  paddingTop: "20px",
313
313
  fontFamily: "monospace"
314
314
  } }),
315
- /* @__PURE__ */ w(me, {
315
+ /* @__PURE__ */ T(_e, {
316
316
  dataKey: t,
317
317
  fill: "url(#barGradient)",
318
318
  radius: [
@@ -329,62 +329,65 @@ function tt({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
329
329
  })
330
330
  });
331
331
  }
332
- var nt = R((() => {}));
332
+ var ct = L((() => {}));
333
333
  //#endregion
334
334
  //#region src/ChartContainerImpl.tsx
335
- function rt() {
336
- let e = m.useContext(st);
335
+ function q() {
336
+ let e = h.useContext(pt);
337
337
  if (!e) throw Error("useChart must be used within a <ChartContainer />");
338
338
  return e;
339
339
  }
340
- function J({ id: e, className: t, children: n, config: r, disableSettleRemount: i, ...a }) {
341
- let o = m.useId(), s = `chart-${e || o.replace(/:/g, "")}`, c = m.useRef(null), [l, u] = m.useState(0);
342
- return m.useEffect(() => {
340
+ function J({ id: e, className: t, children: n, config: r, disableSettleRemount: i, style: a, ...o }) {
341
+ let s = h.useId(), c = `chart-${e || s.replace(/:/g, "")}`, l = h.useRef(null), [u, d] = h.useState(0);
342
+ h.useEffect(() => {
343
343
  if (i) return;
344
- let e = c.current;
344
+ let e = l.current;
345
345
  if (e == null || typeof ResizeObserver > "u") return;
346
346
  let t = !1, n, r = new ResizeObserver((e) => {
347
347
  if (t) return;
348
348
  let i = e[0]?.contentRect;
349
349
  i == null || i.width <= 0 || i.height <= 0 || (n != null && clearTimeout(n), n = setTimeout(() => {
350
- t = !0, r.disconnect(), u((e) => e + 1);
350
+ t = !0, r.disconnect(), d((e) => e + 1);
351
351
  }, 80));
352
352
  });
353
353
  return r.observe(e), () => {
354
354
  t = !0, n != null && clearTimeout(n), r.disconnect();
355
355
  };
356
- }, [i]), /* @__PURE__ */ w(st.Provider, {
356
+ }, [i]);
357
+ let f = a?.height != null || a?.minHeight != null, p = a?.width != null || a?.minWidth != null, m = {
358
+ ...f ? {} : { minHeight: mt },
359
+ ...p ? {} : { minWidth: 0 },
360
+ ...a
361
+ };
362
+ return /* @__PURE__ */ T(pt.Provider, {
357
363
  value: { config: r },
358
- children: /* @__PURE__ */ T("div", {
359
- ref: c,
364
+ children: /* @__PURE__ */ E("div", {
365
+ ref: l,
360
366
  "data-slot": "chart",
361
- "data-chart": s,
367
+ "data-chart": c,
362
368
  className: Y("block w-full h-[350px] text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
363
- style: {
364
- minHeight: 280,
365
- minWidth: 0,
366
- ...a.style
367
- },
368
- ...a,
369
- children: [/* @__PURE__ */ w(ct, {
370
- id: s,
369
+ style: m,
370
+ ...o,
371
+ children: [/* @__PURE__ */ T(X, {
372
+ id: c,
371
373
  config: r
372
- }), /* @__PURE__ */ w(Ae, {
374
+ }), /* @__PURE__ */ T(Fe, {
373
375
  width: "100%",
374
376
  height: "100%",
377
+ ...f ? {} : { minHeight: mt },
375
378
  children: n
376
- }, l)]
379
+ }, u)]
377
380
  })
378
381
  });
379
382
  }
380
- function it({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: c, formatter: l, color: u, nameKey: d, labelKey: f }) {
381
- let { config: p } = rt(), h = m.useMemo(() => {
383
+ function lt({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: c, formatter: l, color: u, nameKey: d, labelKey: f }) {
384
+ let { config: p } = q(), m = h.useMemo(() => {
382
385
  if (i || !t?.length) return null;
383
- let [e] = t, n = `${f || e?.dataKey || e?.name || "value"}`, r = ot(p, e, n), a = !f && typeof o == "string" ? p[o]?.label || o : r?.label;
384
- return s ? /* @__PURE__ */ w("div", {
386
+ let [e] = t, n = `${f || e?.dataKey || e?.name || "value"}`, r = dt(p, e, n), a = !f && typeof o == "string" ? p[o]?.label || o : r?.label;
387
+ return s ? /* @__PURE__ */ T("div", {
385
388
  className: Y("font-medium", c),
386
389
  children: s(a, t)
387
- }) : a ? /* @__PURE__ */ w("div", {
390
+ }) : a ? /* @__PURE__ */ T("div", {
388
391
  className: Y("font-medium", c),
389
392
  children: a
390
393
  }) : null;
@@ -398,30 +401,30 @@ function it({ active: e, payload: t, className: n, indicator: r = "dot", hideLab
398
401
  f
399
402
  ]);
400
403
  if (!e || !t?.length) return null;
401
- let g = t.length === 1 && r !== "dot";
402
- return /* @__PURE__ */ T("div", {
404
+ let ee = t.length === 1 && r !== "dot";
405
+ return /* @__PURE__ */ E("div", {
403
406
  className: Y("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl", n),
404
- children: [g ? null : h, /* @__PURE__ */ w("div", {
407
+ children: [ee ? null : m, /* @__PURE__ */ T("div", {
405
408
  className: "grid gap-1.5",
406
409
  children: t.filter((e) => e.type !== "none").map((e, t) => {
407
- let n = `${d || e.name || e.dataKey || "value"}`, i = ot(p, e, n), o = u || e.payload.fill || e.color;
408
- return /* @__PURE__ */ w("div", {
410
+ let n = `${d || e.name || e.dataKey || "value"}`, i = dt(p, e, n), o = u || e.payload.fill || e.color;
411
+ return /* @__PURE__ */ T("div", {
409
412
  className: Y("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5", r === "dot" ? "items-center" : ""),
410
- children: l && e?.value !== void 0 && e.name ? l(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ T(de, { children: [i?.icon ? /* @__PURE__ */ w(i.icon, {}) : !a && /* @__PURE__ */ w("div", {
411
- className: Y("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", r === "dot" ? "h-2.5 w-2.5" : "", r === "line" ? "w-1" : "", r === "dashed" ? "w-0 border-[1.5px] border-dashed bg-transparent" : "", g && r === "dashed" ? "my-0.5" : ""),
413
+ children: l && e?.value !== void 0 && e.name ? l(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ E(me, { children: [i?.icon ? /* @__PURE__ */ T(i.icon, {}) : !a && /* @__PURE__ */ T("div", {
414
+ className: Y("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", r === "dot" ? "h-2.5 w-2.5" : "", r === "line" ? "w-1" : "", r === "dashed" ? "w-0 border-[1.5px] border-dashed bg-transparent" : "", ee && r === "dashed" ? "my-0.5" : ""),
412
415
  style: {
413
416
  "--color-bg": o,
414
417
  "--color-border": o
415
418
  }
416
- }), /* @__PURE__ */ T("div", {
417
- className: Y("flex flex-1 justify-between leading-none", g ? "items-end" : "items-center"),
418
- children: [/* @__PURE__ */ T("div", {
419
+ }), /* @__PURE__ */ E("div", {
420
+ className: Y("flex flex-1 justify-between leading-none", ee ? "items-end" : "items-center"),
421
+ children: [/* @__PURE__ */ E("div", {
419
422
  className: "grid gap-1.5",
420
- children: [g ? h : null, /* @__PURE__ */ w("span", {
423
+ children: [ee ? m : null, /* @__PURE__ */ T("span", {
421
424
  className: "text-muted-foreground",
422
425
  children: i?.label || e.name
423
426
  })]
424
- }), e.value && /* @__PURE__ */ w("span", {
427
+ }), e.value && /* @__PURE__ */ T("span", {
425
428
  className: "text-foreground font-mono font-medium tabular-nums",
426
429
  children: e.value.toLocaleString()
427
430
  })]
@@ -431,15 +434,15 @@ function it({ active: e, payload: t, className: n, indicator: r = "dot", hideLab
431
434
  })]
432
435
  });
433
436
  }
434
- function at({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
435
- let { config: a } = rt();
436
- return n?.length ? /* @__PURE__ */ w("div", {
437
+ function ut({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
438
+ let { config: a } = q();
439
+ return n?.length ? /* @__PURE__ */ T("div", {
437
440
  className: Y("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
438
441
  children: n.filter((e) => e.type !== "none").map((e) => {
439
- let n = `${i || e.dataKey || "value"}`, r = ot(a, e, n);
440
- return /* @__PURE__ */ T("div", {
442
+ let n = `${i || e.dataKey || "value"}`, r = dt(a, e, n);
443
+ return /* @__PURE__ */ E("div", {
441
444
  className: Y("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
442
- children: [r?.icon && !t ? /* @__PURE__ */ w(r.icon, {}) : /* @__PURE__ */ w("div", {
445
+ children: [r?.icon && !t ? /* @__PURE__ */ T(r.icon, {}) : /* @__PURE__ */ T("div", {
443
446
  className: "h-2 w-2 shrink-0 rounded-[2px]",
444
447
  style: { backgroundColor: e.color }
445
448
  }), r?.label]
@@ -447,18 +450,18 @@ function at({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bo
447
450
  })
448
451
  }) : null;
449
452
  }
450
- function ot(e, t, n) {
453
+ function dt(e, t, n) {
451
454
  if (typeof t != "object" || !t) return;
452
455
  let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
453
456
  return r && n in r && typeof r[n] == "string" ? i = r[n] : n in t && typeof t[n] == "string" && (i = t[n]), i in e ? e[i] : e[n];
454
457
  }
455
- var Y, X, st, ct, Z, lt, ut = R((() => {
456
- Y = (...e) => e.filter(Boolean).join(" "), X = {
458
+ var Y, ft, pt, mt, X, Z, ht, gt = L((() => {
459
+ Y = (...e) => e.filter(Boolean).join(" "), ft = {
457
460
  light: "",
458
461
  dark: ".dark"
459
- }, st = m.createContext(null), ct = ({ id: e, config: t }) => {
462
+ }, pt = h.createContext(null), mt = 280, X = ({ id: e, config: t }) => {
460
463
  let n = Object.entries(t).filter(([, e]) => e.theme || e.color);
461
- return n.length ? /* @__PURE__ */ w("style", { dangerouslySetInnerHTML: { __html: Object.entries(X).map(([t, r]) => `
464
+ return n.length ? /* @__PURE__ */ T("style", { dangerouslySetInnerHTML: { __html: Object.entries(ft).map(([t, r]) => `
462
465
  ${r} [data-chart=${e}] {
463
466
  ${n.map(([e, n]) => {
464
467
  let r = n.theme?.[t] || n.color;
@@ -466,48 +469,48 @@ ${n.map(([e, n]) => {
466
469
  }).join("\n")}
467
470
  }
468
471
  `).join("\n") } }) : null;
469
- }, Z = M, lt = A;
472
+ }, Z = Ie, ht = k;
470
473
  }));
471
474
  //#endregion
472
475
  //#region src/chartDrillEvents.ts
473
- function dt(e) {
476
+ function _t(e) {
474
477
  return e?.[0]?.dataKey || "value";
475
478
  }
476
- function ft(e, t, n) {
479
+ function vt(e, t, n) {
477
480
  if (!e) return null;
478
481
  let r = e.payload ?? e, i = r?.[t];
479
482
  if (i == null) return null;
480
- let a = dt(n);
483
+ let a = _t(n);
481
484
  return {
482
485
  category: String(i),
483
486
  series: a,
484
487
  value: typeof r?.[a] == "number" ? r[a] : void 0
485
488
  };
486
489
  }
487
- function pt(e, t) {
490
+ function yt(e, t) {
488
491
  if (!e) return null;
489
492
  let n = e.name ?? e.payload?.name ?? e.root?.name;
490
493
  if (n == null) return null;
491
494
  let r = e.value ?? e.size ?? e.payload?.size;
492
495
  return {
493
496
  category: String(n),
494
- series: dt(t),
497
+ series: _t(t),
495
498
  value: typeof r == "number" ? r : void 0
496
499
  };
497
500
  }
498
- function mt(e, t) {
501
+ function bt(e, t) {
499
502
  if (!e) return null;
500
503
  let n = e.payload ?? e, r = n?.name;
501
504
  return r == null || n?.depth === 0 ? null : {
502
505
  category: String(r),
503
- series: dt(t),
506
+ series: _t(t),
504
507
  value: typeof n?.value == "number" ? n.value : void 0
505
508
  };
506
509
  }
507
- var ht = R((() => {})), gt = /* @__PURE__ */ z({ default: () => xt });
508
- function _t(e) {
510
+ var xt = L((() => {})), St = /* @__PURE__ */ R({ default: () => kt });
511
+ function Ct(e) {
509
512
  let { x: t, y: n, width: r, height: i, name: a, fill: o } = e;
510
- return r <= 0 || i <= 0 ? null : /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("rect", {
513
+ return r <= 0 || i <= 0 ? null : /* @__PURE__ */ E("g", { children: [/* @__PURE__ */ T("rect", {
511
514
  x: t,
512
515
  y: n,
513
516
  width: r,
@@ -515,7 +518,7 @@ function _t(e) {
515
518
  fill: o,
516
519
  stroke: "hsl(var(--background))",
517
520
  strokeWidth: 2
518
- }), r > 48 && i > 18 ? /* @__PURE__ */ w("text", {
521
+ }), r > 48 && i > 18 ? /* @__PURE__ */ T("text", {
519
522
  x: t + 6,
520
523
  y: n + 18,
521
524
  fill: "#fff",
@@ -524,102 +527,127 @@ function _t(e) {
524
527
  children: a
525
528
  }) : null] });
526
529
  }
527
- function vt({ title: e, subtitle: t, children: n }) {
528
- return !e && !t ? /* @__PURE__ */ w(de, { children: n }) : /* @__PURE__ */ T("div", {
530
+ function wt({ title: e, subtitle: t, children: n }) {
531
+ return !e && !t ? /* @__PURE__ */ T(me, { children: n }) : /* @__PURE__ */ E("div", {
529
532
  className: "flex h-full w-full flex-col",
530
- children: [/* @__PURE__ */ T("div", {
533
+ children: [/* @__PURE__ */ E("div", {
531
534
  className: "mb-2 shrink-0",
532
- children: [e ? /* @__PURE__ */ w("div", {
535
+ children: [e ? /* @__PURE__ */ T("div", {
533
536
  className: "text-sm font-medium leading-tight text-foreground",
534
537
  children: e
535
- }) : null, t ? /* @__PURE__ */ w("div", {
538
+ }) : null, t ? /* @__PURE__ */ T("div", {
536
539
  className: "text-xs leading-tight text-muted-foreground",
537
540
  children: t
538
541
  }) : null]
539
- }), /* @__PURE__ */ w("div", {
542
+ }), /* @__PURE__ */ T("div", {
540
543
  className: "min-h-0 flex-1",
541
544
  children: n
542
545
  })]
543
546
  });
544
547
  }
545
- function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i = "name", series: a = [], className: o = "", colors: s, categoryColors: c, categoryOrder: l, onChartClick: u, isAnimationActive: d, xAxis: f, yAxes: p, showLegend: h, showDataLabels: g, title: ee, subtitle: te, description: ne, height: _, annotations: re, interaction: v }) {
546
- let ie = e === "column" ? "bar" : e, y = We(ie, a), ae = Ue(ie), b = Array.isArray(n) ? n : [], x = d === !1 ? { isAnimationActive: !1 } : {}, S = {
547
- ...d === !1 ? { disableSettleRemount: !0 } : {},
548
+ function Tt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: a = "name", series: o = [], className: s = "", colors: c, categoryColors: l, categoryOrder: u, onChartClick: d, isAnimationActive: f, xAxis: p, yAxes: m, showLegend: ee, showDataLabels: te, title: ne, subtitle: re, description: g, height: _, annotations: ie, interaction: ae }) {
549
+ let oe = e === "column" ? "bar" : e, v = Ye(oe, o), y = Je(oe), b = Array.isArray(n) ? n : [], x = f === !1 ? { isAnimationActive: !1 } : {}, S = {
550
+ ...f === !1 ? { disableSettleRemount: !0 } : {},
548
551
  ..._ ? { style: { height: _ } } : {},
549
- ...ne ? {
552
+ ...g ? {
550
553
  role: "img",
551
- "aria-label": ne
554
+ "aria-label": g
552
555
  } : {}
553
- }, [C, oe] = m.useState(!1), se = m.useCallback((e) => {
554
- if (!u || !e) return;
555
- let t = Array.isArray(e.activePayload) ? e.activePayload[0] : void 0;
556
- u({
556
+ }, [C, se] = h.useState(!1), ce = h.useRef(null), le = h.useCallback((e) => (...t) => {
557
+ let n = Ft(t);
558
+ n !== void 0 && (ce.current = {
559
+ gesture: n,
560
+ dataKey: String(e.dataKey)
561
+ });
562
+ }, []), ue = d ? (e) => ({ onClick: le(e) }) : () => ({}), de = h.useCallback((e, t, n) => {
563
+ if (!d || !e) return;
564
+ let r = e.activeTooltipIndex ?? e.activeIndex, a = r == null ? NaN : Number(r), s = Number.isInteger(a) && a >= 0 ? b[a] : void 0, c = ce.current;
565
+ ce.current = null;
566
+ let l = Pt(t), u = c != null && l !== void 0 && c.gesture === l;
567
+ if (n && !u) return;
568
+ let f = u ? c.dataKey : Nt(e.activeDataKey, o), p = f != null && s ? s[f] : void 0;
569
+ d({
557
570
  category: e.activeLabel == null ? void 0 : String(e.activeLabel),
558
- series: t?.dataKey ? String(t.dataKey) : void 0,
559
- value: typeof t?.value == "number" ? t.value : void 0
571
+ categoryId: i(s),
572
+ series: f,
573
+ seriesLabel: It(f, o),
574
+ value: typeof p == "number" ? p : void 0
560
575
  });
561
- }, [u]), ce = m.useCallback((e) => {
562
- if (!u || !e) return;
563
- let t = e.payload?.[i], n = a[0]?.dataKey || "value";
564
- u({
576
+ }, [
577
+ d,
578
+ b,
579
+ o
580
+ ]), fe = h.useCallback((e, t) => {
581
+ de(e, t, !1);
582
+ }, [de]), pe = h.useCallback((e, t) => {
583
+ de(e, t, !0);
584
+ }, [de]), w = h.useCallback((e) => {
585
+ if (!d || !e) return;
586
+ let t = e.payload?.[a], n = o[0]?.dataKey || "value";
587
+ d({
565
588
  category: t == null ? void 0 : String(t),
589
+ categoryId: i(e.payload),
566
590
  series: n,
591
+ seriesLabel: It(n, o),
567
592
  value: typeof e.payload?.[n] == "number" ? e.payload[n] : void 0
568
593
  });
569
594
  }, [
570
- u,
571
- i,
572
- a
573
- ]), le = u ? {
574
- onClick: se,
595
+ d,
596
+ a,
597
+ o
598
+ ]), k = d ? {
599
+ onClick: fe,
575
600
  style: { cursor: "pointer" }
576
- } : {}, ue = u ? {
577
- onClick: ce,
601
+ } : {}, Fe = d ? { onClick: pe } : {}, F = d ? (e) => ({
602
+ ...ue(e),
603
+ cursor: "pointer"
604
+ }) : () => ({}), ze = d ? {
605
+ onClick: w,
578
606
  style: { cursor: "pointer" }
579
- } : {}, A = m.useCallback((e, t, n) => c && c[e == null ? "" : String(e)] || n[t % n.length], [c]), Ae = m.useCallback((e) => {
580
- if (!u) return;
581
- let t = ft(e, i, a);
582
- t && u(t);
607
+ } : {}, Be = h.useCallback((e, t, n) => l && l[e == null ? "" : String(e)] || n[t % n.length], [l]), Ve = h.useCallback((e) => {
608
+ if (!d) return;
609
+ let t = vt(e, a, o);
610
+ t && d(t);
583
611
  }, [
584
- u,
585
- i,
586
- a
587
- ]), Pe = m.useCallback((e) => {
588
- if (!u) return;
589
- let t = pt(e, a);
590
- t && u(t);
591
- }, [u, a]), Fe = m.useCallback((e) => {
592
- if (!u) return;
593
- let t = mt(e, a);
594
- t && u(t);
595
- }, [u, a]), Ie = u ? {
596
- onClick: Ae,
612
+ d,
613
+ a,
614
+ o
615
+ ]), He = h.useCallback((e) => {
616
+ if (!d) return;
617
+ let t = yt(e, o);
618
+ t && d(t);
619
+ }, [d, o]), Ue = h.useCallback((e) => {
620
+ if (!d) return;
621
+ let t = bt(e, o);
622
+ t && d(t);
623
+ }, [d, o]), We = d ? {
624
+ onClick: Ve,
597
625
  cursor: "pointer"
598
- } : {}, Le = u ? {
599
- onClick: Pe,
626
+ } : {}, Ge = d ? {
627
+ onClick: He,
600
628
  style: { cursor: "pointer" }
601
- } : {}, Re = u ? {
602
- onClick: Fe,
629
+ } : {}, Ke = d ? {
630
+ onClick: Ue,
603
631
  style: { cursor: "pointer" }
604
632
  } : {};
605
- m.useEffect(() => {
606
- let e = () => oe(window.innerWidth < 640);
633
+ h.useEffect(() => {
634
+ let e = () => se(window.innerWidth < 640);
607
635
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
608
636
  }, []);
609
- let ze = {
610
- bar: E,
611
- "horizontal-bar": E,
612
- line: be,
613
- area: pe,
614
- pie: Se,
615
- donut: Se,
616
- radar: De,
617
- scatter: j,
618
- funnel: O,
619
- combo: _e,
620
- treemap: E,
621
- sankey: E
622
- }[y] || E, Be = m.useCallback((e) => {
637
+ let qe = {
638
+ bar: D,
639
+ "horizontal-bar": D,
640
+ line: Te,
641
+ area: ge,
642
+ pie: De,
643
+ donut: De,
644
+ radar: Me,
645
+ scatter: M,
646
+ funnel: Se,
647
+ combo: O,
648
+ treemap: D,
649
+ sankey: D
650
+ }[v] || D, I = h.useCallback((e) => {
623
651
  if (e == null || e === "") return "";
624
652
  let t = r?.[String(e)]?.label;
625
653
  if (t != null) return String(t);
@@ -627,7 +655,7 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
627
655
  if (/^\d{4}-\d{2}-\d{2}/.test(n)) {
628
656
  let e = new Date(n);
629
657
  if (!Number.isNaN(e.getTime())) {
630
- let t = (b.length > 1 ? Math.abs(new Date(String(b[b.length - 1][i] ?? "")).getTime() - new Date(String(b[0][i] ?? "")).getTime()) : 0) / 864e5;
658
+ let t = (b.length > 1 ? Math.abs(new Date(String(b[b.length - 1][a] ?? "")).getTime() - new Date(String(b[0][a] ?? "")).getTime()) : 0) / 864e5;
631
659
  try {
632
660
  return t <= 62 ? e.toLocaleDateString(void 0, {
633
661
  month: "short",
@@ -644,16 +672,16 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
644
672
  return C && n.length > 8 ? n.slice(0, 8) + "…" : n;
645
673
  }, [
646
674
  b,
647
- i,
675
+ a,
648
676
  C,
649
677
  r
650
- ]), Ve = m.useMemo(() => b.some((e) => String(e[i] || "").length > 5), [b, i]), I = () => Array.isArray(s) && s.length > 0 ? s : [
678
+ ]), L = h.useMemo(() => b.some((e) => String(e[a] || "").length > 5), [b, a]), R = () => Array.isArray(c) && c.length > 0 ? c : [
651
679
  "hsl(var(--chart-1))",
652
680
  "hsl(var(--chart-2))",
653
681
  "hsl(var(--chart-3))",
654
682
  "hsl(var(--chart-4))",
655
683
  "hsl(var(--chart-5))"
656
- ], L = m.useCallback((e) => {
684
+ ], z = h.useCallback((e) => {
657
685
  if (e == null || e === "") return "";
658
686
  let t = typeof e == "number" ? e : Number(e);
659
687
  if (!Number.isFinite(t)) return String(e);
@@ -665,8 +693,8 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
665
693
  } catch {
666
694
  return String(t);
667
695
  }
668
- }, []), R = p?.[0], z = p && p.length > 1 ? p[1] : R?.position === "right" ? R : void 0, B = !!p && p.length > 1, V = m.useMemo(() => U(f?.format) ?? Be, [f?.format, Be]), H = m.useMemo(() => U(R?.format) ?? L, [R?.format, L]), He = m.useMemo(() => U(z?.format) ?? L, [z?.format, L]), Xe = m.useCallback((e) => {
669
- let t = a.filter((t) => B ? (t.yAxis === "right" ? "right" : "left") === e : e === "left").map((e) => e.dataKey), n = [];
696
+ }, []), B = m?.[0], V = m && m.length > 1 ? m[1] : B?.position === "right" ? B : void 0, H = !!m && m.length > 1, nt = h.useMemo(() => Xe(p?.format) ?? I, [p?.format, I]), U = h.useMemo(() => Xe(B?.format) ?? z, [B?.format, z]), W = h.useMemo(() => Xe(V?.format) ?? z, [V?.format, z]), G = h.useCallback((e) => {
697
+ let t = o.filter((t) => H ? (t.yAxis === "right" ? "right" : "left") === e : e === "left").map((e) => e.dataKey), n = [];
670
698
  for (let e of b) for (let r of t) {
671
699
  let t = Number(e?.[r]);
672
700
  Number.isFinite(t) && n.push(t);
@@ -674,11 +702,11 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
674
702
  return n;
675
703
  }, [
676
704
  b,
677
- a,
678
- B
679
- ]), W = m.useCallback((e, t = "left") => {
705
+ o,
706
+ H
707
+ ]), K = h.useCallback((e, t = "left") => {
680
708
  if (!e) return {};
681
- let n = Ke(e), r = Ge(e, Xe(t));
709
+ let n = Qe(e), r = Ze(e, G(t));
682
710
  return {
683
711
  ...r ? { ticks: r } : {},
684
712
  ...n ? { domain: n } : {},
@@ -693,17 +721,17 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
693
721
  position: "insideLeft"
694
722
  } } : {}
695
723
  };
696
- }, [Xe]), G = R?.showGridLines !== !1, K = {
697
- vertical: f?.showGridLines === !0,
698
- horizontal: G
699
- }, Ze = h !== !1, Qe = m.useMemo(() => {
700
- if (!Array.isArray(re) || re.length === 0) return null;
724
+ }, [G]), rt = B?.showGridLines !== !1, it = {
725
+ vertical: p?.showGridLines === !0,
726
+ horizontal: rt
727
+ }, at = ee !== !1, ot = h.useMemo(() => {
728
+ if (!Array.isArray(ie) || ie.length === 0) return null;
701
729
  let e = {
702
730
  solid: void 0,
703
731
  dashed: "4 4",
704
732
  dotted: "1 4"
705
733
  };
706
- return re.map((t, n) => {
734
+ return ie.map((t, n) => {
707
735
  let r = t?.axis === "x", i = Q(String(t?.color || "hsl(var(--muted-foreground))")), a = e[String(t?.style ?? "dashed")], o = typeof t?.label == "string" ? t.label : void 0, s = o ? { label: {
708
736
  value: o,
709
737
  position: "insideTopRight",
@@ -718,9 +746,9 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
718
746
  y1: t.value,
719
747
  y2: t.endValue
720
748
  };
721
- return /* @__PURE__ */ w(Oe, {
749
+ return /* @__PURE__ */ T(Ne, {
722
750
  ...e,
723
- ...B && !r ? { yAxisId: "left" } : {},
751
+ ...H && !r ? { yAxisId: "left" } : {},
724
752
  fill: i,
725
753
  fillOpacity: .12,
726
754
  stroke: i,
@@ -728,198 +756,199 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
728
756
  ...s
729
757
  }, `ann-${n}`);
730
758
  }
731
- return /* @__PURE__ */ w(ke, {
759
+ return /* @__PURE__ */ T(Pe, {
732
760
  ...r ? { x: t?.value } : { y: t?.value },
733
- ...B && !r ? { yAxisId: "left" } : {},
761
+ ...H && !r ? { yAxisId: "left" } : {},
734
762
  stroke: i,
735
763
  strokeDasharray: a,
736
764
  ...s
737
765
  }, `ann-${n}`);
738
766
  });
739
- }, [re, B]), $e = v?.tooltips !== !1, et = v?.brush === !0 ? /* @__PURE__ */ w(he, {
740
- dataKey: i,
767
+ }, [ie, H]), st = ae?.tooltips !== !1, ct = ae?.brush === !0 ? /* @__PURE__ */ T(ve, {
768
+ dataKey: a,
741
769
  height: 24,
742
770
  travellerWidth: 8,
743
771
  stroke: "hsl(var(--muted-foreground))"
744
- }) : null, q = (e) => g ? /* @__PURE__ */ w(k, {
772
+ }) : null, q = (e) => te ? /* @__PURE__ */ T(Ce, {
745
773
  position: "top",
746
774
  className: "fill-foreground",
747
775
  fontSize: 11,
748
776
  ...e ? { formatter: e } : {}
749
- }) : null, tt = m.useMemo(() => ({
777
+ }) : null, dt = h.useMemo(() => ({
750
778
  tickLine: !1,
751
779
  tickMargin: 10,
752
780
  axisLine: !1,
753
781
  interval: "preserveStartEnd",
754
782
  minTickGap: C ? 32 : 48,
755
- tickFormatter: V,
756
- ...f?.title ? { label: {
757
- value: f.title,
783
+ tickFormatter: nt,
784
+ ...p?.title ? { label: {
785
+ value: p.title,
758
786
  position: "insideBottom",
759
787
  offset: -4
760
788
  } } : {},
761
- ...!C && Ve && {
789
+ ...!C && L && {
762
790
  angle: -35,
763
791
  textAnchor: "end",
764
792
  height: 60
765
793
  }
766
794
  }), [
767
795
  C,
768
- Ve,
769
- V,
770
- f?.title
796
+ L,
797
+ nt,
798
+ p?.title
771
799
  ]);
772
- if (y && Je.has(y)) {
773
- let e = a[0]?.dataKey || "value", t = b[0]?.[e], n = typeof t == "number" ? t : Number(t), i = a[0]?.label ?? r?.[e]?.label ?? e;
774
- return /* @__PURE__ */ w("div", {
775
- className: o,
800
+ if (v && et.has(v)) {
801
+ let e = o[0]?.dataKey || "value", t = b[0]?.[e], n = typeof t == "number" ? t : Number(t), i = o[0]?.label ?? r?.[e]?.label ?? e;
802
+ return /* @__PURE__ */ T("div", {
803
+ className: s,
776
804
  "data-testid": "advanced-chart-single-value",
777
- children: /* @__PURE__ */ T("div", {
805
+ children: /* @__PURE__ */ E("div", {
778
806
  className: "flex flex-col gap-1 py-4",
779
- children: [/* @__PURE__ */ w("span", {
807
+ children: [/* @__PURE__ */ T("span", {
780
808
  className: "text-3xl font-semibold tabular-nums",
781
809
  children: Number.isFinite(n) ? new Intl.NumberFormat().format(n) : String(t ?? "—")
782
- }), /* @__PURE__ */ w("span", {
810
+ }), /* @__PURE__ */ T("span", {
783
811
  className: "text-xs text-muted-foreground",
784
812
  children: String(i)
785
813
  })]
786
814
  })
787
815
  });
788
816
  }
789
- if (y && Ye.has(y)) return /* @__PURE__ */ T("div", {
790
- className: `rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${o ?? ""}`,
817
+ if (v && tt.has(v)) return /* @__PURE__ */ E("div", {
818
+ className: `rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${s ?? ""}`,
791
819
  "data-testid": "advanced-chart-tabular-notice",
792
820
  role: "note",
793
821
  children: [
794
822
  "Chart type “",
795
- y,
823
+ v,
796
824
  "” is tabular — render it with the data-table / pivot components; a chart block draws series charts."
797
825
  ]
798
826
  });
799
- if (y && !qe.has(y)) return /* @__PURE__ */ T("div", {
800
- className: `rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${o ?? ""}`,
827
+ if (v && !$e.has(v)) return /* @__PURE__ */ E("div", {
828
+ className: `rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground ${s ?? ""}`,
801
829
  "data-testid": "advanced-chart-unknown-type",
802
830
  role: "note",
803
831
  children: [
804
832
  "Chart type “",
805
- y,
833
+ v,
806
834
  "” is not a spec chart type — nothing was drawn."
807
835
  ]
808
836
  });
809
- if (y === "pie" || y === "donut") {
810
- let e = y === "donut" ? "52%" : 0, t = I(), n = { ...r };
837
+ if (v === "pie" || v === "donut") {
838
+ let e = v === "donut" ? "52%" : 0, t = R(), n = { ...r };
811
839
  return b.forEach((e, r) => {
812
- let a = e?.[i];
813
- if (a == null || a === "") return;
814
- let o = String(a);
840
+ let i = e?.[a];
841
+ if (i == null || i === "") return;
842
+ let o = String(i);
815
843
  n[o] || (n[o] = {
816
844
  label: o,
817
- color: A(a, r, t)
845
+ color: Be(i, r, t)
818
846
  });
819
- }), /* @__PURE__ */ w(J, {
847
+ }), /* @__PURE__ */ T(J, {
820
848
  config: n,
821
- className: o,
849
+ className: s,
822
850
  ...S,
823
- children: /* @__PURE__ */ T(Se, { children: [
824
- /* @__PURE__ */ w(Z, {
851
+ children: /* @__PURE__ */ E(De, { children: [
852
+ /* @__PURE__ */ T(Z, {
825
853
  cursor: !1,
826
- content: /* @__PURE__ */ w(it, { hideLabel: !0 })
854
+ content: /* @__PURE__ */ T(lt, { hideLabel: !0 })
827
855
  }),
828
- /* @__PURE__ */ w(xe, {
856
+ /* @__PURE__ */ T(Ee, {
829
857
  data: b,
830
- dataKey: a[0]?.dataKey || "value",
831
- nameKey: i || "name",
858
+ dataKey: o[0]?.dataKey || "value",
859
+ nameKey: a || "name",
832
860
  innerRadius: e,
833
861
  strokeWidth: 5,
834
862
  paddingAngle: 2,
835
863
  outerRadius: "85%",
836
864
  ...x,
837
- ...ue,
865
+ ...ze,
838
866
  children: b.map((e, n) => {
839
- let r = A(e?.[i], n, t);
840
- return /* @__PURE__ */ w(D, { fill: Q(r) }, `cell-${n}`);
867
+ let r = Be(e?.[a], n, t);
868
+ return /* @__PURE__ */ T(be, { fill: Q(r) }, `cell-${n}`);
841
869
  })
842
870
  }),
843
- Ze ? /* @__PURE__ */ w(lt, {
871
+ at ? /* @__PURE__ */ T(ht, {
844
872
  verticalAlign: "bottom",
845
873
  wrapperStyle: {
846
874
  fontSize: C ? "11px" : "12px",
847
875
  paddingTop: "8px"
848
876
  },
849
- content: /* @__PURE__ */ w(at, {
850
- nameKey: i,
877
+ content: /* @__PURE__ */ T(ut, {
878
+ nameKey: a,
851
879
  className: "flex-wrap"
852
880
  })
853
881
  }) : null
854
882
  ] })
855
883
  });
856
884
  }
857
- if (y === "funnel") {
858
- let e = a[0]?.dataKey || "value", n = I(), s = u ? (t) => {
859
- t && u({
860
- category: t?.payload?.[i] ?? t?.[i],
885
+ if (v === "funnel") {
886
+ let e = o[0]?.dataKey || "value", n = R(), c = d ? (t) => {
887
+ t && d({
888
+ category: t?.payload?.[a] ?? t?.[a],
889
+ categoryId: i(t?.payload) ?? i(t),
861
890
  value: t?.payload?.[e] ?? t?.[e]
862
891
  });
863
- } : void 0, c = s ? {
864
- onClick: s,
892
+ } : void 0, l = c ? {
893
+ onClick: c,
865
894
  style: { cursor: "pointer" }
866
- } : {}, d = t(l), f = d ? [...b].sort((e, t) => (d.get(String(e?.[i] ?? "")) ?? 2 ** 53 - 1) - (d.get(String(t?.[i] ?? "")) ?? 2 ** 53 - 1)) : [...b].sort((t, n) => {
895
+ } : {}, f = t(u), p = f ? [...b].sort((e, t) => (f.get(String(e?.[a] ?? "")) ?? 2 ** 53 - 1) - (f.get(String(t?.[a] ?? "")) ?? 2 ** 53 - 1)) : [...b].sort((t, n) => {
867
896
  let r = Number(t?.[e] ?? 0);
868
897
  return Number(n?.[e] ?? 0) - r;
869
898
  });
870
- return /* @__PURE__ */ w(J, {
899
+ return /* @__PURE__ */ T(J, {
871
900
  config: r,
872
- className: o,
901
+ className: s,
873
902
  ...S,
874
- children: /* @__PURE__ */ T(O, { children: [/* @__PURE__ */ w(Z, { content: /* @__PURE__ */ w(it, {}) }), /* @__PURE__ */ T(ve, {
903
+ children: /* @__PURE__ */ E(Se, { children: [/* @__PURE__ */ T(Z, { content: /* @__PURE__ */ T(lt, {}) }), /* @__PURE__ */ E(xe, {
875
904
  dataKey: e,
876
- data: f,
877
- nameKey: i,
905
+ data: p,
906
+ nameKey: a,
878
907
  ...x,
879
- ...c,
880
- children: [/* @__PURE__ */ w(k, {
908
+ ...l,
909
+ children: [/* @__PURE__ */ T(Ce, {
881
910
  position: "right",
882
911
  fill: "hsl(var(--foreground))",
883
912
  stroke: "none",
884
- dataKey: i
885
- }), f.map((e, t) => /* @__PURE__ */ w(D, { fill: Q(n[t % n.length]) }, `funnel-cell-${t}`))]
913
+ dataKey: a
914
+ }), p.map((e, t) => /* @__PURE__ */ T(be, { fill: Q(n[t % n.length]) }, `funnel-cell-${t}`))]
886
915
  })] })
887
916
  });
888
917
  }
889
- if (y === "treemap") {
890
- let e = a[0]?.dataKey || "value", t = I(), n = b.map((n, r) => ({
891
- name: String(n?.[i] ?? ""),
918
+ if (v === "treemap") {
919
+ let e = o[0]?.dataKey || "value", t = R(), n = b.map((n, r) => ({
920
+ name: String(n?.[a] ?? ""),
892
921
  size: Number(n?.[e]) || 0,
893
922
  fill: Q(t[r % t.length])
894
923
  }));
895
- return /* @__PURE__ */ w(J, {
924
+ return /* @__PURE__ */ T(J, {
896
925
  config: r,
897
- className: o,
926
+ className: s,
898
927
  ...S,
899
- children: /* @__PURE__ */ w(N, {
928
+ children: /* @__PURE__ */ T(Le, {
900
929
  data: n,
901
930
  dataKey: "size",
902
931
  nameKey: "name",
903
932
  ...x,
904
- content: /* @__PURE__ */ w(_t, {}),
905
- ...Le,
906
- children: /* @__PURE__ */ w(M, {})
933
+ content: /* @__PURE__ */ T(Ct, {}),
934
+ ...Ge,
935
+ children: /* @__PURE__ */ T(Ie, {})
907
936
  })
908
937
  });
909
938
  }
910
- if (y === "sankey") {
911
- let e = a[0]?.dataKey || "value", t = a[0]?.label || e, n = b.filter((t) => (Number(t?.[e]) || 0) > 0), s = [{ name: t }, ...n.map((e) => ({ name: String(e?.[i] ?? "") }))], c = n.map((t, n) => ({
939
+ if (v === "sankey") {
940
+ let e = o[0]?.dataKey || "value", t = o[0]?.label || e, n = b.filter((t) => (Number(t?.[e]) || 0) > 0), i = [{ name: t }, ...n.map((e) => ({ name: String(e?.[a] ?? "") }))], c = n.map((t, n) => ({
912
941
  source: 0,
913
942
  target: n + 1,
914
943
  value: Number(t?.[e]) || 0
915
944
  }));
916
- return c.length === 0 ? /* @__PURE__ */ w("div", { className: o }) : /* @__PURE__ */ w(J, {
945
+ return c.length === 0 ? /* @__PURE__ */ T("div", { className: s }) : /* @__PURE__ */ T(J, {
917
946
  config: r,
918
- className: o,
947
+ className: s,
919
948
  ...S,
920
- children: /* @__PURE__ */ w(je, {
949
+ children: /* @__PURE__ */ T(A, {
921
950
  data: {
922
- nodes: s,
951
+ nodes: i,
923
952
  links: c
924
953
  },
925
954
  nodePadding: 24,
@@ -928,24 +957,24 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
928
957
  strokeOpacity: .25
929
958
  },
930
959
  node: { fill: "hsl(var(--chart-1))" },
931
- ...Re,
932
- children: /* @__PURE__ */ w(M, {})
960
+ ...Ke,
961
+ children: /* @__PURE__ */ T(Ie, {})
933
962
  })
934
963
  });
935
964
  }
936
- if (y === "radar") return /* @__PURE__ */ w(J, {
965
+ if (v === "radar") return /* @__PURE__ */ T(J, {
937
966
  config: r,
938
- className: o,
967
+ className: s,
939
968
  ...S,
940
- children: /* @__PURE__ */ T(De, {
969
+ children: /* @__PURE__ */ E(Me, {
941
970
  data: b,
942
971
  children: [
943
- /* @__PURE__ */ w(we, {}),
944
- /* @__PURE__ */ w(Ce, { dataKey: i }),
945
- /* @__PURE__ */ w(Te, {}),
946
- /* @__PURE__ */ w(Z, { content: /* @__PURE__ */ w(it, {}) }),
947
- /* @__PURE__ */ w(lt, {
948
- content: /* @__PURE__ */ w(at, {}),
972
+ /* @__PURE__ */ T(ke, {}),
973
+ /* @__PURE__ */ T(Oe, { dataKey: a }),
974
+ /* @__PURE__ */ T(Ae, {}),
975
+ /* @__PURE__ */ T(Z, { content: /* @__PURE__ */ T(lt, {}) }),
976
+ /* @__PURE__ */ T(ht, {
977
+ content: /* @__PURE__ */ T(ut, {}),
949
978
  ...C && {
950
979
  verticalAlign: "bottom",
951
980
  wrapperStyle: {
@@ -954,9 +983,9 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
954
983
  }
955
984
  }
956
985
  }),
957
- a.map((e) => {
958
- let t = Q(r[e.dataKey]?.color || St);
959
- return /* @__PURE__ */ w(Ee, {
986
+ o.map((e) => {
987
+ let t = Q(r[e.dataKey]?.color || At);
988
+ return /* @__PURE__ */ T(je, {
960
989
  dataKey: e.dataKey,
961
990
  stroke: t,
962
991
  fill: t,
@@ -967,36 +996,36 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
967
996
  ]
968
997
  })
969
998
  });
970
- if (y === "scatter") return /* @__PURE__ */ w(J, {
999
+ if (v === "scatter") return /* @__PURE__ */ T(J, {
971
1000
  config: r,
972
- className: o,
1001
+ className: s,
973
1002
  ...S,
974
- children: /* @__PURE__ */ T(j, { children: [
975
- /* @__PURE__ */ w(ge, { vertical: !1 }),
976
- /* @__PURE__ */ w(P, {
1003
+ children: /* @__PURE__ */ E(M, { children: [
1004
+ /* @__PURE__ */ T(ye, { vertical: !1 }),
1005
+ /* @__PURE__ */ T(N, {
977
1006
  type: "number",
978
- dataKey: i,
979
- name: String(r[i]?.label || i),
1007
+ dataKey: a,
1008
+ name: String(r[a]?.label || a),
980
1009
  tickLine: !1,
981
1010
  axisLine: !1,
982
1011
  minTickGap: C ? 32 : 48
983
1012
  }),
984
- /* @__PURE__ */ w(F, {
1013
+ /* @__PURE__ */ T(P, {
985
1014
  type: "number",
986
- dataKey: a[0]?.dataKey || "value",
987
- name: String(r[a[0]?.dataKey]?.label || a[0]?.dataKey),
1015
+ dataKey: o[0]?.dataKey || "value",
1016
+ name: String(r[o[0]?.dataKey]?.label || o[0]?.dataKey),
988
1017
  tickLine: !1,
989
1018
  axisLine: !1,
990
- tickFormatter: L,
1019
+ tickFormatter: z,
991
1020
  width: 48
992
1021
  }),
993
- /* @__PURE__ */ w(Ne, {
1022
+ /* @__PURE__ */ T(Re, {
994
1023
  type: "number",
995
1024
  range: [60, 400]
996
1025
  }),
997
- /* @__PURE__ */ w(Z, { content: /* @__PURE__ */ w(it, {}) }),
998
- /* @__PURE__ */ w(lt, {
999
- content: /* @__PURE__ */ w(at, {}),
1026
+ /* @__PURE__ */ T(Z, { content: /* @__PURE__ */ T(lt, {}) }),
1027
+ /* @__PURE__ */ T(ht, {
1028
+ content: /* @__PURE__ */ T(ut, {}),
1000
1029
  ...C && {
1001
1030
  verticalAlign: "bottom",
1002
1031
  wrapperStyle: {
@@ -1005,54 +1034,55 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1005
1034
  }
1006
1035
  }
1007
1036
  }),
1008
- a.map((e, t) => {
1009
- let n = I(), i = Q(r[e.dataKey]?.color || n[t % n.length]), a = wt(e, "scatter");
1010
- return /* @__PURE__ */ w(Me, {
1037
+ o.map((e, t) => {
1038
+ let n = R(), i = Q(r[e.dataKey]?.color || n[t % n.length]), a = Mt(e, "scatter");
1039
+ return /* @__PURE__ */ T(j, {
1011
1040
  name: r[e.dataKey]?.label || e.dataKey,
1012
1041
  data: b,
1013
1042
  fill: i,
1014
1043
  fillOpacity: a?.fillOpacity,
1015
1044
  ...x,
1016
- ...Ie
1045
+ ...We
1017
1046
  }, e.dataKey);
1018
1047
  })
1019
1048
  ] })
1020
1049
  });
1021
- if (y === "combo") return /* @__PURE__ */ w(vt, {
1022
- title: ee,
1023
- subtitle: te,
1024
- children: /* @__PURE__ */ w(J, {
1050
+ if (v === "combo") return /* @__PURE__ */ T(wt, {
1051
+ title: ne,
1052
+ subtitle: re,
1053
+ children: /* @__PURE__ */ T(J, {
1025
1054
  config: r,
1026
- className: o,
1055
+ className: s,
1027
1056
  ...S,
1028
- children: /* @__PURE__ */ T(_e, {
1057
+ children: /* @__PURE__ */ E(O, {
1029
1058
  data: b,
1059
+ ...Fe,
1030
1060
  children: [
1031
- /* @__PURE__ */ w(ge, { ...K }),
1032
- /* @__PURE__ */ w(P, {
1033
- dataKey: i,
1034
- ...tt
1061
+ /* @__PURE__ */ T(ye, { ...it }),
1062
+ /* @__PURE__ */ T(N, {
1063
+ dataKey: a,
1064
+ ...dt
1035
1065
  }),
1036
- /* @__PURE__ */ w(F, {
1066
+ /* @__PURE__ */ T(P, {
1037
1067
  yAxisId: "left",
1038
1068
  tickLine: !1,
1039
1069
  axisLine: !1,
1040
- tickFormatter: H,
1070
+ tickFormatter: U,
1041
1071
  width: 48,
1042
- ...W(R)
1072
+ ...K(B)
1043
1073
  }),
1044
- /* @__PURE__ */ w(F, {
1074
+ /* @__PURE__ */ T(P, {
1045
1075
  yAxisId: "right",
1046
1076
  orientation: "right",
1047
1077
  tickLine: !1,
1048
1078
  axisLine: !1,
1049
- tickFormatter: He,
1079
+ tickFormatter: W,
1050
1080
  width: 48,
1051
- ...W(z, "right")
1081
+ ...K(V, "right")
1052
1082
  }),
1053
- $e ? /* @__PURE__ */ w(Z, { content: /* @__PURE__ */ w(it, {}) }) : null,
1054
- Ze ? /* @__PURE__ */ w(lt, {
1055
- content: /* @__PURE__ */ w(at, {}),
1083
+ st ? /* @__PURE__ */ T(Z, { content: /* @__PURE__ */ T(lt, {}) }) : null,
1084
+ at ? /* @__PURE__ */ T(ht, {
1085
+ content: /* @__PURE__ */ T(ut, {}),
1056
1086
  ...C && {
1057
1087
  verticalAlign: "bottom",
1058
1088
  wrapperStyle: {
@@ -1061,11 +1091,11 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1061
1091
  }
1062
1092
  }
1063
1093
  }) : null,
1064
- Qe,
1065
- et,
1066
- a.map((e, t) => {
1067
- let n = Q(r[e.dataKey]?.color || St), i = e.chartType || ae || (t === 0 ? "bar" : "line"), a = e.yAxis === "right" || e.yAxis === "left" ? e.yAxis : ae || i === "bar" ? "left" : "right", o = wt(e, i), s = e.stack ? { stackId: String(e.stack) } : {}, c = U((a === "right" ? z : R)?.format);
1068
- return i === "line" ? /* @__PURE__ */ w(ye, {
1094
+ ot,
1095
+ ct,
1096
+ o.map((e, t) => {
1097
+ let n = Q(r[e.dataKey]?.color || At), i = e.chartType || y || (t === 0 ? "bar" : "line"), a = e.yAxis === "right" || e.yAxis === "left" ? e.yAxis : y || i === "bar" ? "left" : "right", o = Mt(e, i), s = e.stack ? { stackId: String(e.stack) } : {}, c = Xe((a === "right" ? V : B)?.format);
1098
+ return i === "line" ? /* @__PURE__ */ T(we, {
1069
1099
  yAxisId: a,
1070
1100
  type: "monotone",
1071
1101
  dataKey: e.dataKey,
@@ -1075,8 +1105,9 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1075
1105
  strokeOpacity: o?.strokeOpacity,
1076
1106
  strokeDasharray: o?.strokeDasharray,
1077
1107
  ...x,
1108
+ ...F(e),
1078
1109
  children: q(c)
1079
- }, e.dataKey) : i === "area" ? /* @__PURE__ */ w(fe, {
1110
+ }, e.dataKey) : i === "area" ? /* @__PURE__ */ T(he, {
1080
1111
  yAxisId: a,
1081
1112
  type: "monotone",
1082
1113
  dataKey: e.dataKey,
@@ -1087,8 +1118,9 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1087
1118
  strokeDasharray: o?.strokeDasharray,
1088
1119
  ...s,
1089
1120
  ...x,
1121
+ ...F(e),
1090
1122
  children: q(c)
1091
- }, e.dataKey) : /* @__PURE__ */ w(me, {
1123
+ }, e.dataKey) : /* @__PURE__ */ T(_e, {
1092
1124
  yAxisId: a,
1093
1125
  dataKey: e.dataKey,
1094
1126
  fill: n,
@@ -1096,6 +1128,7 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1096
1128
  fillOpacity: o?.fillOpacity,
1097
1129
  ...s,
1098
1130
  ...x,
1131
+ ...F(e),
1099
1132
  children: q(c)
1100
1133
  }, e.dataKey);
1101
1134
  })
@@ -1103,94 +1136,94 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1103
1136
  })
1104
1137
  })
1105
1138
  });
1106
- let nt = y === "horizontal-bar", rt = I(), ot = c ? Object.values(c).map((e) => Q(String(e))) : [], Y = Array.from(/* @__PURE__ */ new Set([
1107
- ...rt,
1108
- ...ot,
1109
- ...a.map((e, t) => Q(r[e.dataKey]?.color || rt[t % rt.length] || St))
1139
+ let Y = v === "horizontal-bar", ft = R(), pt = l ? Object.values(l).map((e) => Q(String(e))) : [], mt = Array.from(/* @__PURE__ */ new Set([
1140
+ ...ft,
1141
+ ...pt,
1142
+ ...o.map((e, t) => Q(r[e.dataKey]?.color || ft[t % ft.length] || At))
1110
1143
  ])), X = (e) => "g" + e.replace(/[^a-zA-Z0-9]/g, "");
1111
- return /* @__PURE__ */ w(vt, {
1112
- title: ee,
1113
- subtitle: te,
1114
- children: /* @__PURE__ */ w(J, {
1144
+ return /* @__PURE__ */ T(wt, {
1145
+ title: ne,
1146
+ subtitle: re,
1147
+ children: /* @__PURE__ */ T(J, {
1115
1148
  config: r,
1116
- className: o,
1149
+ className: s,
1117
1150
  ...S,
1118
- children: /* @__PURE__ */ T(ze, {
1151
+ children: /* @__PURE__ */ E(qe, {
1119
1152
  data: b,
1120
- layout: nt ? "vertical" : "horizontal",
1121
- ...le,
1153
+ layout: Y ? "vertical" : "horizontal",
1154
+ ...k,
1122
1155
  children: [
1123
- /* @__PURE__ */ w("defs", { children: Y.map((e) => /* @__PURE__ */ T(m.Fragment, { children: [/* @__PURE__ */ T("linearGradient", {
1156
+ /* @__PURE__ */ T("defs", { children: mt.map((e) => /* @__PURE__ */ E(h.Fragment, { children: [/* @__PURE__ */ E("linearGradient", {
1124
1157
  id: `bg-${X(e)}`,
1125
1158
  x1: "0",
1126
1159
  y1: "0",
1127
1160
  x2: "0",
1128
1161
  y2: "1",
1129
- children: [/* @__PURE__ */ w("stop", {
1162
+ children: [/* @__PURE__ */ T("stop", {
1130
1163
  offset: "0%",
1131
1164
  style: { stopColor: e },
1132
1165
  stopOpacity: .95
1133
- }), /* @__PURE__ */ w("stop", {
1166
+ }), /* @__PURE__ */ T("stop", {
1134
1167
  offset: "100%",
1135
1168
  style: { stopColor: e },
1136
1169
  stopOpacity: .5
1137
1170
  })]
1138
- }), /* @__PURE__ */ T("linearGradient", {
1171
+ }), /* @__PURE__ */ E("linearGradient", {
1139
1172
  id: `ag-${X(e)}`,
1140
1173
  x1: "0",
1141
1174
  y1: "0",
1142
1175
  x2: "0",
1143
1176
  y2: "1",
1144
- children: [/* @__PURE__ */ w("stop", {
1177
+ children: [/* @__PURE__ */ T("stop", {
1145
1178
  offset: "0%",
1146
1179
  style: { stopColor: e },
1147
1180
  stopOpacity: .5
1148
- }), /* @__PURE__ */ w("stop", {
1181
+ }), /* @__PURE__ */ T("stop", {
1149
1182
  offset: "95%",
1150
1183
  style: { stopColor: e },
1151
1184
  stopOpacity: .05
1152
1185
  })]
1153
1186
  })] }, X(e))) }),
1154
- /* @__PURE__ */ w(ge, { ...K }),
1155
- nt ? /* @__PURE__ */ T(de, { children: [/* @__PURE__ */ w(P, {
1187
+ /* @__PURE__ */ T(ye, { ...it }),
1188
+ Y ? /* @__PURE__ */ E(me, { children: [/* @__PURE__ */ T(N, {
1156
1189
  type: "number",
1157
1190
  tickLine: !1,
1158
1191
  axisLine: !1,
1159
- tickFormatter: H,
1160
- ...W(R)
1161
- }), /* @__PURE__ */ w(F, {
1192
+ tickFormatter: U,
1193
+ ...K(B)
1194
+ }), /* @__PURE__ */ T(P, {
1162
1195
  type: "category",
1163
- dataKey: i,
1196
+ dataKey: a,
1164
1197
  tickLine: !1,
1165
1198
  axisLine: !1,
1166
- width: Math.min(140, Math.max(60, Math.max(...b.map((e) => String(e[i] ?? "").length)) * 7)),
1167
- tickFormatter: V
1168
- })] }) : /* @__PURE__ */ T(de, { children: [
1169
- /* @__PURE__ */ w(P, {
1170
- dataKey: i,
1171
- ...tt
1199
+ width: Math.min(140, Math.max(60, Math.max(...b.map((e) => String(e[a] ?? "").length)) * 7)),
1200
+ tickFormatter: nt
1201
+ })] }) : /* @__PURE__ */ E(me, { children: [
1202
+ /* @__PURE__ */ T(N, {
1203
+ dataKey: a,
1204
+ ...dt
1172
1205
  }),
1173
- /* @__PURE__ */ w(F, {
1174
- ...B ? { yAxisId: "left" } : {},
1206
+ /* @__PURE__ */ T(P, {
1207
+ ...H ? { yAxisId: "left" } : {},
1175
1208
  tickLine: !1,
1176
1209
  axisLine: !1,
1177
- tickFormatter: H,
1210
+ tickFormatter: U,
1178
1211
  width: 48,
1179
- ...W(R)
1212
+ ...K(B)
1180
1213
  }),
1181
- B ? /* @__PURE__ */ w(F, {
1214
+ H ? /* @__PURE__ */ T(P, {
1182
1215
  yAxisId: "right",
1183
1216
  orientation: "right",
1184
1217
  tickLine: !1,
1185
1218
  axisLine: !1,
1186
- tickFormatter: He,
1219
+ tickFormatter: W,
1187
1220
  width: 48,
1188
- ...W(z, "right")
1221
+ ...K(V, "right")
1189
1222
  }) : null
1190
1223
  ] }),
1191
- $e ? /* @__PURE__ */ w(Z, { content: /* @__PURE__ */ w(it, {}) }) : null,
1192
- Ze ? /* @__PURE__ */ w(lt, {
1193
- content: /* @__PURE__ */ w(at, {}),
1224
+ st ? /* @__PURE__ */ T(Z, { content: /* @__PURE__ */ T(lt, {}) }) : null,
1225
+ at ? /* @__PURE__ */ T(ht, {
1226
+ content: /* @__PURE__ */ T(ut, {}),
1194
1227
  ...C && {
1195
1228
  verticalAlign: "bottom",
1196
1229
  wrapperStyle: {
@@ -1199,13 +1232,13 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1199
1232
  }
1200
1233
  }
1201
1234
  }) : null,
1202
- Qe,
1203
- et,
1204
- a.map((e, t) => {
1205
- let n = I(), o = e.variant === "comparison", s = o ? a.slice(0, t).find((e) => e.variant !== "comparison") || a[0] : e, c = o ? a.indexOf(s) : t, l = Q(r[s.dataKey]?.color || n[c % n.length] || St), u = B ? { yAxisId: e.yAxis === "right" ? "right" : "left" } : {}, d = e.stack ? { stackId: String(e.stack) } : {}, f = U((e.yAxis === "right" ? z : R)?.format);
1206
- if (y === "bar" || y === "horizontal-bar") {
1207
- let t = a.filter((e) => e.variant !== "comparison").length === 1 && !o && a.length === 1 && b.length > 1, r = wt(e, "bar");
1208
- return /* @__PURE__ */ T(me, {
1235
+ ot,
1236
+ ct,
1237
+ o.map((e, t) => {
1238
+ let n = R(), i = e.variant === "comparison", s = i ? o.slice(0, t).find((e) => e.variant !== "comparison") || o[0] : e, c = i ? o.indexOf(s) : t, l = Q(r[s.dataKey]?.color || n[c % n.length] || At), u = H ? { yAxisId: e.yAxis === "right" ? "right" : "left" } : {}, d = e.stack ? { stackId: String(e.stack) } : {}, f = Xe((e.yAxis === "right" ? V : B)?.format);
1239
+ if (v === "bar" || v === "horizontal-bar") {
1240
+ let t = o.filter((e) => e.variant !== "comparison").length === 1 && !i && o.length === 1 && b.length > 1, r = Mt(e, "bar");
1241
+ return /* @__PURE__ */ E(_e, {
1209
1242
  dataKey: e.dataKey,
1210
1243
  fill: `url(#bg-${X(l)})`,
1211
1244
  radius: 4,
@@ -1213,12 +1246,13 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1213
1246
  ...d,
1214
1247
  ...u,
1215
1248
  ...x,
1216
- children: [t && b.map((e, t) => /* @__PURE__ */ w(D, { fill: `url(#bg-${X(Q(A(e?.[i], t, n)))})` }, `cell-${t}`)), q(f)]
1249
+ ...ue(e),
1250
+ children: [t && b.map((e, t) => /* @__PURE__ */ T(be, { fill: `url(#bg-${X(Q(Be(e?.[a], t, n)))})` }, `cell-${t}`)), q(f)]
1217
1251
  }, e.dataKey);
1218
1252
  }
1219
- if (y === "line") {
1220
- let t = wt(e, "line");
1221
- return /* @__PURE__ */ w(ye, {
1253
+ if (v === "line") {
1254
+ let t = Mt(e, "line");
1255
+ return /* @__PURE__ */ T(we, {
1222
1256
  type: "monotone",
1223
1257
  dataKey: e.dataKey,
1224
1258
  stroke: l,
@@ -1228,12 +1262,13 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1228
1262
  strokeDasharray: t?.strokeDasharray,
1229
1263
  ...u,
1230
1264
  ...x,
1265
+ ...ue(e),
1231
1266
  children: q(f)
1232
1267
  }, e.dataKey);
1233
1268
  }
1234
- if (y === "area") {
1235
- let t = wt(e, "area");
1236
- return /* @__PURE__ */ w(fe, {
1269
+ if (v === "area") {
1270
+ let t = Mt(e, "area");
1271
+ return /* @__PURE__ */ T(he, {
1237
1272
  type: "monotone",
1238
1273
  dataKey: e.dataKey,
1239
1274
  fill: `url(#ag-${X(l)})`,
@@ -1245,6 +1280,7 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1245
1280
  ...d,
1246
1281
  ...u,
1247
1282
  ...x,
1283
+ ...ue(e),
1248
1284
  children: q(f)
1249
1285
  }, e.dataKey);
1250
1286
  }
@@ -1255,35 +1291,64 @@ function yt({ chartType: e = "bar", data: n = [], config: r = {}, xAxisKey: i =
1255
1291
  })
1256
1292
  });
1257
1293
  }
1258
- function bt(e) {
1294
+ function Et(e) {
1259
1295
  let t = e.chartType === "column" ? "bar" : e.chartType ?? "bar", n = Array.isArray(e.data) ? e.data : [], r = e.xAxisKey ?? "name";
1260
- return Tt.has(t) && n.length > 0 && !n.some((e) => typeof e == "object" && !!e && r in e);
1296
+ return Lt.has(t) && n.length > 0 && !n.some((e) => typeof e == "object" && !!e && r in e);
1297
+ }
1298
+ function Dt(e) {
1299
+ let t = e.chartType === "column" ? "bar" : e.chartType ?? "bar", n = Array.isArray(e.data) ? e.data : [];
1300
+ return Rt.has(t) && n.length > 0 && Array.isArray(e.series) && e.series.length === 0;
1301
+ }
1302
+ function Ot({ code: e, className: t, children: n }) {
1303
+ return /* @__PURE__ */ T("div", {
1304
+ className: `flex h-full min-h-[120px] w-full items-center justify-center p-4 text-center text-sm text-muted-foreground ${t ?? ""}`,
1305
+ role: "status",
1306
+ "data-chart-error": e,
1307
+ children: /* @__PURE__ */ T("span", { children: n })
1308
+ });
1261
1309
  }
1262
- function xt(e) {
1263
- let t = bt(e), n = e.xAxisKey ?? "name", r = m.useMemo(() => Object.keys((Array.isArray(e.data) ? e.data[0] : void 0) ?? {}), [e.data]);
1264
- return m.useEffect(() => {
1265
- t && console.warn(`[chart] no row has the category key "${n}" — rendering an explanatory placeholder instead of an empty axis. Row keys: ${JSON.stringify(r)}. A dataset query must PROJECT the dimension it groups by (framework#4033).`);
1310
+ function kt(e) {
1311
+ let t = Et(e), n = !t && Dt(e), r = e.xAxisKey ?? "name", i = h.useMemo(() => Object.keys((Array.isArray(e.data) ? e.data[0] : void 0) ?? {}), [e.data]);
1312
+ return h.useEffect(() => {
1313
+ t && console.warn(`[chart] no row has the category key "${r}" — rendering an explanatory placeholder instead of an empty axis. Row keys: ${JSON.stringify(i)}. A dataset query must PROJECT the dimension it groups by (framework#4033).`);
1266
1314
  }, [
1267
1315
  t,
1316
+ r,
1317
+ i
1318
+ ]), h.useEffect(() => {
1319
+ n && console.warn(`[chart] no series to plot against the category axis "${r}" — rendering an explanatory placeholder instead of an empty frame. Row keys: ${JSON.stringify(i)}. A grouped chart's SECOND dimension must be PROJECTED by the dataset query, and a chart with no measure selected has nothing to draw either (objectui#4683, framework#4033).`);
1320
+ }, [
1268
1321
  n,
1269
- r
1270
- ]), t ? /* @__PURE__ */ w("div", {
1271
- className: `flex h-full min-h-[120px] w-full items-center justify-center p-4 text-center text-sm text-muted-foreground ${e.className ?? ""}`,
1272
- role: "status",
1273
- "data-chart-error": "missing-category-key",
1274
- children: /* @__PURE__ */ T("span", { children: [
1322
+ r,
1323
+ i
1324
+ ]), t ? /* @__PURE__ */ E(Ot, {
1325
+ code: "missing-category-key",
1326
+ className: e.className,
1327
+ children: [
1275
1328
  "This chart cannot plot its category axis: no row has a",
1276
1329
  " ",
1277
- /* @__PURE__ */ w("code", {
1330
+ /* @__PURE__ */ T("code", {
1278
1331
  className: "font-mono",
1279
- children: n
1332
+ children: r
1280
1333
  }),
1281
1334
  " field."
1282
- ] })
1283
- }) : /* @__PURE__ */ w(yt, { ...e });
1335
+ ]
1336
+ }) : n ? /* @__PURE__ */ E(Ot, {
1337
+ code: "no-plottable-series",
1338
+ className: e.className,
1339
+ children: [
1340
+ "This chart cannot plot any series: no measure or group reached its",
1341
+ " ",
1342
+ /* @__PURE__ */ T("code", {
1343
+ className: "font-mono",
1344
+ children: r
1345
+ }),
1346
+ " axis."
1347
+ ]
1348
+ }) : /* @__PURE__ */ T(Tt, { ...e });
1284
1349
  }
1285
- var St, Ct, Q, wt, Tt, Et = R((() => {
1286
- ut(), ht(), Qe(), St = "hsl(var(--primary))", Ct = {
1350
+ var At, jt, Q, Mt, Nt, Pt, Ft, It, Lt, Rt, zt = L((() => {
1351
+ gt(), xt(), rt(), At = "hsl(var(--primary))", jt = {
1287
1352
  slate: "#64748b",
1288
1353
  gray: "#6b7280",
1289
1354
  zinc: "#71717a",
@@ -1306,11 +1371,31 @@ var St, Ct, Q, wt, Tt, Et = R((() => {
1306
1371
  fuchsia: "#d946ef",
1307
1372
  pink: "#ec4899",
1308
1373
  rose: "#f43f5e"
1309
- }, Q = (e) => Ct[e] || e, wt = (e, t) => e?.variant === "comparison" ? {
1374
+ }, Q = (e) => jt[e] || e, Mt = (e, t) => e?.variant === "comparison" ? {
1310
1375
  strokeOpacity: typeof e.opacity == "number" ? e.opacity : t === "line" || t === "scatter" ? .5 : .6,
1311
1376
  fillOpacity: typeof e.opacity == "number" ? e.opacity : t === "bar" ? .4 : t === "area" ? .2 : .5,
1312
1377
  strokeDasharray: e.dashArray ?? (t === "line" || t === "area" ? "4 4" : void 0)
1313
- } : null, Tt = /* @__PURE__ */ new Set([
1378
+ } : null, Nt = (e, t) => {
1379
+ if (typeof e == "string" || typeof e == "number") {
1380
+ let t = String(e);
1381
+ if (t !== "") return t;
1382
+ }
1383
+ if (t.length === 1) {
1384
+ let e = t[0]?.dataKey;
1385
+ if (e != null && String(e) !== "") return String(e);
1386
+ }
1387
+ }, Pt = (e) => {
1388
+ if (e && typeof e == "object" && "nativeEvent" in e) return e.nativeEvent;
1389
+ }, Ft = (e) => {
1390
+ for (let t = e.length - 1; t >= 0; --t) {
1391
+ let n = Pt(e[t]);
1392
+ if (n !== void 0) return n;
1393
+ }
1394
+ }, It = (e, t) => {
1395
+ if (e == null) return;
1396
+ let n = t.find((t) => String(t.dataKey) === e);
1397
+ return typeof n?.label == "string" ? n.label : void 0;
1398
+ }, Lt = /* @__PURE__ */ new Set([
1314
1399
  "bar",
1315
1400
  "horizontal-bar",
1316
1401
  "line",
@@ -1320,14 +1405,20 @@ var St, Ct, Q, wt, Tt, Et = R((() => {
1320
1405
  "radar",
1321
1406
  "funnel",
1322
1407
  "combo"
1408
+ ]), Rt = /* @__PURE__ */ new Set([
1409
+ "bar",
1410
+ "horizontal-bar",
1411
+ "line",
1412
+ "area",
1413
+ "combo"
1323
1414
  ]);
1324
1415
  }));
1325
1416
  //#endregion
1326
1417
  //#region src/ChartRenderer.tsx
1327
- Qe();
1328
- var Dt = h.lazy(() => Promise.resolve().then(() => (nt(), $e))), Ot = h.lazy(() => Promise.resolve().then(() => (Et(), gt))), kt = ({ schema: e }) => /* @__PURE__ */ w(g, {
1329
- fallback: /* @__PURE__ */ w(ue, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
1330
- children: /* @__PURE__ */ w(Dt, {
1418
+ rt();
1419
+ var Bt = g.lazy(() => Promise.resolve().then(() => (ct(), it))), Vt = g.lazy(() => Promise.resolve().then(() => (zt(), St))), Ht = ({ schema: e }) => /* @__PURE__ */ T(_, {
1420
+ fallback: /* @__PURE__ */ T(w, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
1421
+ children: /* @__PURE__ */ T(Bt, {
1331
1422
  data: e.data,
1332
1423
  dataKey: e.dataKey,
1333
1424
  xAxisKey: e.xAxisKey,
@@ -1336,8 +1427,8 @@ var Dt = h.lazy(() => Promise.resolve().then(() => (nt(), $e))), Ot = h.lazy(()
1336
1427
  color: e.color
1337
1428
  })
1338
1429
  }), $ = ({ schema: e, onChartClick: t }) => {
1339
- let n = h.useMemo(() => {
1340
- let t = He(e), n = Array.isArray(e.series) ? e.series : void 0, r = (n?.length && n.every((e) => !!e && typeof e == "object" && "dataKey" in e) ? n : t.series) ?? n, i = e.xAxisKey ?? t.xAxisKey, a = e.config;
1430
+ let n = g.useMemo(() => {
1431
+ let t = H(e), n = Array.isArray(e.series) ? e.series : void 0, r = (n?.length && n.every((e) => !!e && typeof e == "object" && "dataKey" in e) ? n : t.series) ?? n, i = e.xAxisKey ?? t.xAxisKey, a = e.config;
1341
1432
  if (i || (e.index ? i = e.index : e.category && (i = e.category)), r || (e.categories ? r = e.categories.map((e) => ({ dataKey: e })) : e.value && (r = [{ dataKey: e.value }])), !a && r) {
1342
1433
  let t = e.colors || [
1343
1434
  "hsl(var(--chart-1))",
@@ -1361,9 +1452,9 @@ var Dt = h.lazy(() => Promise.resolve().then(() => (nt(), $e))), Ot = h.lazy(()
1361
1452
  spec: t
1362
1453
  };
1363
1454
  }, [e]);
1364
- return /* @__PURE__ */ w(g, {
1365
- fallback: /* @__PURE__ */ w(ue, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
1366
- children: /* @__PURE__ */ w(Ot, {
1455
+ return /* @__PURE__ */ T(_, {
1456
+ fallback: /* @__PURE__ */ T(w, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
1457
+ children: /* @__PURE__ */ T(Vt, {
1367
1458
  chartType: n.chartType,
1368
1459
  data: n.data,
1369
1460
  config: n.config,
@@ -1390,15 +1481,12 @@ var Dt = h.lazy(() => Promise.resolve().then(() => (nt(), $e))), Ot = h.lazy(()
1390
1481
  };
1391
1482
  //#endregion
1392
1483
  //#region src/ObjectChart.tsx
1393
- function At(e) {
1394
- return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
1395
- }
1396
- function jt(e) {
1484
+ function Ut(e) {
1397
1485
  return e.field || e.function || "count";
1398
1486
  }
1399
- var Mt = "__comparison";
1400
- function Nt(e, t) {
1401
- let { field: n, function: r, groupBy: i } = t, a = jt(t), o = {};
1487
+ var Wt = "__comparison";
1488
+ function Gt(e, t) {
1489
+ let { field: n, function: r, groupBy: i } = t, a = Ut(t), o = {};
1402
1490
  for (let t of e) {
1403
1491
  let e = String(t[i] ?? "Unknown");
1404
1492
  o[e] || (o[e] = []), o[e].push(t);
@@ -1426,13 +1514,13 @@ function Nt(e, t) {
1426
1514
  };
1427
1515
  });
1428
1516
  }
1429
- async function Pt(e, t, n, r, i) {
1517
+ async function Kt(e, t, n, r, i) {
1430
1518
  if (!e.length || !t) return e;
1431
- let a = i || ((e, t) => t), o = `__raw_${t}`, c = n?.fields?.[t];
1432
- if (!c) {
1519
+ let a = i || ((e, t) => t), o = `__raw_${t}`, s = n?.fields?.[t];
1520
+ if (!s) {
1433
1521
  let n = /^\d{4}-\d{2}-\d{2}/;
1434
1522
  return e.map((e) => {
1435
- let r = e[t], i = String(r ?? ""), s = n.test(i) ? i : At(i);
1523
+ let r = e[t], i = String(r ?? ""), s = n.test(i) ? i : u(i);
1436
1524
  return {
1437
1525
  ...e,
1438
1526
  [t]: a(i, s),
@@ -1440,11 +1528,11 @@ async function Pt(e, t, n, r, i) {
1440
1528
  };
1441
1529
  });
1442
1530
  }
1443
- let l = c.type;
1444
- if (l === "select" || l === "picklist" || l === "dropdown") {
1445
- let n = c.options || [];
1531
+ let c = s.type;
1532
+ if (c === "select" || c === "picklist" || c === "dropdown") {
1533
+ let n = s.options || [];
1446
1534
  if (n.length === 0) return e.map((e) => {
1447
- let n = e[t], r = String(n ?? ""), i = At(r);
1535
+ let n = e[t], r = String(n ?? ""), i = u(r);
1448
1536
  return {
1449
1537
  ...e,
1450
1538
  [t]: a(r, i),
@@ -1454,7 +1542,7 @@ async function Pt(e, t, n, r, i) {
1454
1542
  let r = {};
1455
1543
  for (let e of n) typeof e == "string" ? r[e] = e : e && typeof e == "object" && (r[String(e.value)] = e.label || String(e.value));
1456
1544
  return e.map((e) => {
1457
- let n = e[t], i = String(n ?? ""), s = r[i] || At(i);
1545
+ let n = e[t], i = String(n ?? ""), s = r[i] || u(i);
1458
1546
  return {
1459
1547
  ...e,
1460
1548
  [t]: a(i, s),
@@ -1462,8 +1550,8 @@ async function Pt(e, t, n, r, i) {
1462
1550
  };
1463
1551
  });
1464
1552
  }
1465
- if (l === "lookup" || l === "master_detail") {
1466
- let n = c.reference_to || c.reference;
1553
+ if (c === "lookup" || c === "master_detail") {
1554
+ let n = s.reference_to || s.reference;
1467
1555
  if (!n || !r || typeof r.find != "function") return e.map((e) => ({
1468
1556
  ...e,
1469
1557
  [o]: e[t]
@@ -1473,12 +1561,12 @@ async function Pt(e, t, n, r, i) {
1473
1561
  ...e,
1474
1562
  [o]: e[t]
1475
1563
  }));
1476
- let a = c.id_field || "id";
1564
+ let a = s.id_field || "id";
1477
1565
  try {
1478
- let l = await r.find(n, {
1566
+ let c = await r.find(n, {
1479
1567
  $filter: { [a]: { $in: i } },
1480
1568
  $top: i.length
1481
- }), u = s(l), d = c.reference_field || c.display_field || "name", f = {};
1569
+ }), u = l(c), d = s.reference_field || s.display_field || "name", f = {};
1482
1570
  for (let e of u) {
1483
1571
  let t = String(e[a] ?? e.id ?? e._id ?? ""), n = e[d] || e.name || e.label || e.title || t;
1484
1572
  t && (f[t] = String(n));
@@ -1498,26 +1586,22 @@ async function Pt(e, t, n, r, i) {
1498
1586
  }));
1499
1587
  }
1500
1588
  }
1501
- if (l === "date" || l === "datetime" || l === "date_time" || l === "timestamp" || l === "time") return e.map((e) => ({
1589
+ if (c === "date" || c === "datetime" || c === "date_time" || c === "timestamp" || c === "time") return e.map((e) => ({
1502
1590
  ...e,
1503
1591
  [o]: e[t]
1504
1592
  }));
1505
- let u = /^\d{4}-\d{2}-\d{2}/;
1593
+ let d = /^\d{4}-\d{2}-\d{2}/;
1506
1594
  return e.map((e) => {
1507
1595
  let n = e[t], r = String(n ?? "");
1508
1596
  return {
1509
1597
  ...e,
1510
- [t]: u.test(r) ? r : At(r),
1598
+ [t]: d.test(r) ? r : u(r),
1511
1599
  [o]: n
1512
1600
  };
1513
1601
  });
1514
1602
  }
1515
- var Ft = (e) => {
1516
- let { schema: t } = e, m = e.onSegmentClick, h = te(Fe), g = e.dataSource || h?.dataSource, ue = Ie(t.bind), { fieldOptionLabel: de } = Ve(), fe = re(de);
1517
- ne(() => {
1518
- fe.current = de;
1519
- }, [de]);
1520
- let [pe, me] = v([]), [E, he] = v(null), [ge, D] = v(() => !(Array.isArray(t.data) && t.data.length > 0) && (!!t.objectName || !!t.dataset)), [_e, ve] = v(null), [O, k] = v(null), [A, ye] = v(null), [be, xe] = v(null), { openRecordList: Se } = Le(), Ce = I(), we = _(() => t.aggregate ? JSON.stringify(t.aggregate) : "", [t.aggregate]), Te = _(() => t.filter ? JSON.stringify(t.filter) : "", [t.filter]), Ee = _(() => t.compareTo ? JSON.stringify(t.compareTo) : "", [t.compareTo]), De = _(() => t.dataset ? JSON.stringify({
1603
+ var qt = (e) => {
1604
+ let { schema: t } = e, i = e.onSegmentClick, u = ae(Be), h = e.dataSource || u?.dataSource, g = u?.apiFetch, _ = Ve(t.bind), { fieldOptionLabel: w } = Ke(), [me, he] = y([]), [ge, _e] = y(null), [D, ve] = y(() => !(Array.isArray(t.data) && t.data.length > 0) && (!!t.objectName || !!t.dataset)), [ye, be] = y(null), [O, xe] = y(null), [Se, Ce] = y(null), { openRecordList: k } = He(), we = qe(), Te = v(() => t.aggregate ? JSON.stringify(t.aggregate) : "", [t.aggregate]), Ee = v(() => t.filter ? JSON.stringify(t.filter) : "", [t.filter]), De = v(() => t.compareTo ? JSON.stringify(t.compareTo) : "", [t.compareTo]), Oe = v(() => t.dataset ? JSON.stringify({
1521
1605
  d: t.dataset,
1522
1606
  dim: t.dimensions ?? [],
1523
1607
  val: t.values ?? []
@@ -1525,36 +1609,37 @@ var Ft = (e) => {
1525
1609
  t.dataset,
1526
1610
  t.dimensions,
1527
1611
  t.values
1528
- ]), Oe = (e) => e !== "pie" && e !== "donut" && e !== "funnel";
1529
- ne(() => {
1612
+ ]), ke = (e) => e !== "pie" && e !== "donut" && e !== "funnel";
1613
+ oe(() => {
1530
1614
  let e = !1;
1531
1615
  return (async () => {
1532
1616
  try {
1533
- let n = {
1617
+ let n = g ?? fetch, r = {
1534
1618
  headers: { accept: "application/json" },
1535
1619
  credentials: "include"
1536
- }, a = t.objectName, o, s = null, c = t.aggregate?.groupBy;
1537
- if (a) o = c && typeof c == "object" && !Array.isArray(c) ? c.field : typeof c == "string" ? c : t.xAxisKey;
1620
+ }, i = t.objectName, a, o = null, s = t.aggregate?.groupBy;
1621
+ if (i) a = s && typeof s == "object" && !Array.isArray(s) ? s.field : typeof s == "string" ? s : t.xAxisKey;
1538
1622
  else if (t.dataset) {
1539
- let e = Array.isArray(t.dimensions) && t.dimensions.length ? t.dimensions[0] : void 0, r = await (await fetch(`/api/v1/meta/dataset/${encodeURIComponent(t.dataset)}`, n)).json().catch(() => null);
1540
- s = r?.item ?? r?.data ?? r, a = s?.object, o = ((s?.dimensions || []).find((t) => t?.name === e) ?? (s?.dimensions || [])[0])?.field ?? e;
1623
+ let e = Array.isArray(t.dimensions) && t.dimensions.length ? t.dimensions[0] : void 0, s = await (await n(`/api/v1/meta/dataset/${encodeURIComponent(t.dataset)}`, r)).json().catch(() => null);
1624
+ o = s?.item ?? s?.data ?? s, i = o?.object, a = ((o?.dimensions || []).find((t) => t?.name === e) ?? (o?.dimensions || [])[0])?.field ?? e;
1541
1625
  }
1542
- if (!a || !o) {
1543
- e || (ye(null), xe(null));
1626
+ if (!i || !a) {
1627
+ e || Ce(null);
1544
1628
  return;
1545
1629
  }
1546
- let l = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(a)}`, n)).json().catch(() => null), u = l?.item ?? l?.data ?? l, d = i(u?.fields?.[o]?.options), f = null;
1547
- if (t.dataset && Array.isArray(t.dimensions)) {
1548
- let e = {};
1549
- for (let n of t.dimensions) {
1550
- let t = (s?.dimensions || []).find((e) => e?.name === n)?.field ?? n, i = r(u?.fields?.[t]?.options);
1551
- i && (e[n] = i);
1552
- }
1553
- Object.keys(e).length > 0 && (f = e);
1554
- }
1555
- e || (ye(d), xe(f));
1630
+ let c = async (e) => {
1631
+ let t = await (await n(`/api/v1/meta/object/${encodeURIComponent(e)}`, r)).json().catch(() => null);
1632
+ return t?.item ?? t?.data ?? t;
1633
+ }, l = {};
1634
+ if (t.dataset && Array.isArray(t.dimensions)) for (let e of t.dimensions) l[e] = (o?.dimensions || []).find((t) => t?.name === e)?.field ?? e;
1635
+ let u = await f(c, i, [a, ...Object.values(l)]);
1636
+ e || Ce({
1637
+ metaByPath: u,
1638
+ colorPath: a,
1639
+ fieldByDim: t.dataset && Array.isArray(t.dimensions) ? l : null
1640
+ });
1556
1641
  } catch {
1557
- e || (ye(null), xe(null));
1642
+ e || Ce(null);
1558
1643
  }
1559
1644
  })(), () => {
1560
1645
  e = !0;
@@ -1562,17 +1647,31 @@ var Ft = (e) => {
1562
1647
  }, [
1563
1648
  t.objectName,
1564
1649
  t.dataset,
1565
- De,
1566
- we,
1567
- t.xAxisKey
1650
+ Oe,
1651
+ Te,
1652
+ t.xAxisKey,
1653
+ g
1568
1654
  ]);
1569
- let ke = ee(async (e, n) => {
1655
+ let { fieldOptionColors: Ae, dimensionLabels: je } = v(() => {
1656
+ if (!Se) return {
1657
+ fieldOptionColors: null,
1658
+ dimensionLabels: null
1659
+ };
1660
+ let { metaByPath: e, colorPath: t, fieldByDim: n } = Se, i = p(e[t]?.options, c(e[t], w)), a = s(e, n ? Object.entries(n).map(([e, t]) => ({
1661
+ dim: e,
1662
+ path: t
1663
+ })) : null, w);
1664
+ return {
1665
+ fieldOptionColors: r(i),
1666
+ dimensionLabels: a
1667
+ };
1668
+ }, [Se, w]), Me = ie(async (e, n) => {
1570
1669
  if (t.aggregate && typeof e.aggregate == "function") {
1571
1670
  let r = t.aggregate.groupBy;
1572
1671
  if (r && typeof r == "object" && !Array.isArray(r)) {
1573
1672
  let i = t.aggregate.field, a = t.aggregate.function, o = {
1574
1673
  function: a,
1575
- alias: jt(t.aggregate)
1674
+ alias: Ut(t.aggregate)
1576
1675
  };
1577
1676
  a !== "count" && i && (o.field = i);
1578
1677
  let s = await e.aggregate(t.objectName, {
@@ -1591,29 +1690,29 @@ var Ft = (e) => {
1591
1690
  return Array.isArray(i) ? i : [];
1592
1691
  }
1593
1692
  if (typeof e.find == "function") {
1594
- let r = await e.find(t.objectName, { $filter: n }), i = s(r);
1595
- return t.aggregate && i.length > 0 && (i = Nt(i, t.aggregate)), i;
1693
+ let r = await e.find(t.objectName, { $filter: n }), i = l(r);
1694
+ return t.aggregate && i.length > 0 && (i = Gt(i, t.aggregate)), i;
1596
1695
  }
1597
1696
  return [];
1598
- }, [t.objectName, we]), Ae = Re(), je = ee(async (e, n) => {
1697
+ }, [t.objectName, Te]), Ne = Ue(), Pe = ie(async (e, n) => {
1599
1698
  if (!e || !t.objectName && !t.dataset) {
1600
- n.current && D(!1);
1699
+ n.current && ve(!1);
1601
1700
  return;
1602
1701
  }
1603
- n.current && (D(!0), ve(null));
1702
+ n.current && (ve(!0), be(null));
1604
1703
  try {
1605
1704
  if (t.dataset && typeof e.queryDataset == "function") {
1606
- let r = f(t.filter, Ae), i = await e.queryDataset(t.dataset, {
1705
+ let r = ne(t.filter, Ne), i = await e.queryDataset(t.dataset, {
1607
1706
  dimensions: Array.isArray(t.dimensions) ? t.dimensions : [],
1608
1707
  measures: Array.isArray(t.values) ? t.values : [],
1609
1708
  ...r ? { runtimeFilter: r } : {}
1610
1709
  });
1611
- n.current && (me(Array.isArray(i?.rows) ? i.rows : []), he(Array.isArray(i?.fields) ? i.fields : null));
1710
+ n.current && (he(Array.isArray(i?.rows) ? i.rows : []), _e(Array.isArray(i?.fields) ? i.fields : null));
1612
1711
  return;
1613
1712
  }
1614
- let r = f(t.filter, Ae), i = t.compareTo, a = !!i && Oe(t.chartType), o = a ? u(p(t.filter, i), Ae) : null, [s, c] = await Promise.all([ke(e, r), o ? ke(e, o) : Promise.resolve([])]), l = s, d = t.aggregate?.groupBy, m = d && typeof d == "object" && !Array.isArray(d) ? d.alias || d.field : d || t.xAxisKey;
1713
+ let r = ne(t.filter, Ne), i = t.compareTo, a = !!i && ke(t.chartType), o = a ? ee(re(t.filter, i), Ne) : null, [s, c] = await Promise.all([Me(e, r), o ? Me(e, o) : Promise.resolve([])]), l = s, u = t.aggregate?.groupBy, d = u && typeof u == "object" && !Array.isArray(u) ? u.alias || u.field : u || t.xAxisKey;
1615
1714
  if (a && c.length > 0 && t.aggregate) {
1616
- let e = t.aggregate.field, n = t.aggregate.function, r = jt(t.aggregate), i = (t) => {
1715
+ let e = t.aggregate.field, n = t.aggregate.function, r = Ut(t.aggregate), i = (t) => {
1617
1716
  if (t == null) return null;
1618
1717
  if (e) {
1619
1718
  let r = `${e}_${n}`;
@@ -1621,7 +1720,7 @@ var Ft = (e) => {
1621
1720
  if (n === "count" && `${e}_count` in t) return Number(t[`${e}_count`]);
1622
1721
  }
1623
1722
  return r in t ? Number(t[r]) : "value" in t ? Number(t.value) : "count" in t ? Number(t.count) : null;
1624
- }, a = `${r}${Mt}`, o = m;
1723
+ }, a = `${r}${Wt}`, o = d;
1625
1724
  if (o && l.some((e) => e[o] != null) && c.some((e) => e[o] != null)) {
1626
1725
  let e = /* @__PURE__ */ new Map();
1627
1726
  for (let t of c) {
@@ -1655,138 +1754,139 @@ var Ft = (e) => {
1655
1754
  l = t;
1656
1755
  }
1657
1756
  }
1658
- if (m && typeof e.getObjectSchema == "function") try {
1757
+ if (d && typeof e.getObjectSchema == "function") try {
1659
1758
  let n = await e.getObjectSchema(t.objectName);
1660
- l = await Pt(l, m, n, e, (e, n) => fe.current(t.objectName, m, e, n));
1759
+ l = await Kt(l, d, n, e, (e, n) => w(t.objectName, d, e, n));
1661
1760
  } catch {}
1662
- n.current && me(l);
1761
+ n.current && he(l);
1663
1762
  } catch (e) {
1664
- console.error("[ObjectChart] Fetch error:", e), n.current && ve(e instanceof Error ? e.message : "Failed to load chart data");
1763
+ console.error("[ObjectChart] Fetch error:", e), n.current && be(e instanceof Error ? e.message : "Failed to load chart data");
1665
1764
  } finally {
1666
- n.current && D(!1);
1765
+ n.current && ve(!1);
1667
1766
  }
1668
1767
  }, [
1669
1768
  t.objectName,
1670
- De,
1671
- we,
1769
+ Oe,
1672
1770
  Te,
1673
1771
  Ee,
1772
+ De,
1674
1773
  t.xAxisKey,
1675
1774
  t.chartType,
1676
- ke,
1677
- Ae
1775
+ Me,
1776
+ Ne,
1777
+ w
1678
1778
  ]);
1679
- ne(() => {
1779
+ oe(() => {
1680
1780
  let e = { current: !0 };
1681
- return (t.objectName || t.dataset) && !ue && !t.data ? je(g, e) : e.current && D(!1), () => {
1781
+ return (t.objectName || t.dataset) && !_ && !t.data ? Pe(h, e) : e.current && ve(!1), () => {
1682
1782
  e.current = !1;
1683
1783
  };
1684
1784
  }, [
1685
1785
  t.objectName,
1686
- De,
1687
- g,
1688
- ue,
1786
+ Oe,
1787
+ h,
1788
+ _,
1689
1789
  t.data,
1690
- Te,
1691
- we,
1692
1790
  Ee,
1693
- je
1791
+ Te,
1792
+ De,
1793
+ Pe
1694
1794
  ]);
1695
- let Me = ue || t.data || pe, j = Array.isArray(Me) ? Me : [], M = t.drillDown, N = t.aggregate?.groupBy || t.xAxisKey, P = _(() => {
1696
- if (!N) return /* @__PURE__ */ new Map();
1697
- let e = /* @__PURE__ */ new Map(), t = `__raw_${N}`;
1698
- for (let n of j) {
1699
- let r = n?.[N];
1795
+ let Fe = _ || t.data || me, A = Array.isArray(Fe) ? Fe : [], j = t.drillDown, M = t.aggregate?.groupBy || t.xAxisKey, Ie = v(() => {
1796
+ if (!M) return /* @__PURE__ */ new Map();
1797
+ let e = /* @__PURE__ */ new Map(), t = `__raw_${M}`;
1798
+ for (let n of A) {
1799
+ let r = n?.[M];
1700
1800
  if (r == null) continue;
1701
1801
  let i = t in (n || {}) ? n[t] : r;
1702
1802
  e.set(String(r), i);
1703
1803
  }
1704
1804
  return e;
1705
- }, [j, N]), F = _(() => {
1805
+ }, [A, M]), Le = v(() => {
1706
1806
  if (O) return {
1707
1807
  ...t.filter || {},
1708
- ...o(M, O, { groupByField: N })
1808
+ ...o(j, O, { groupByField: M })
1709
1809
  };
1710
1810
  }, [
1711
1811
  O,
1812
+ j,
1712
1813
  M,
1713
- N,
1714
- Te
1715
- ]), Ne = !m && !!O && !!t.objectName && M?.target === "navigate" && !!Se;
1716
- ne(() => {
1717
- Ne && (Se(t.objectName, F), k(null));
1718
- }, [Ne]);
1719
- let L = t.compareTo, R = t.aggregate ? jt(t.aggregate) : void 0, z = R ? `${R}${Mt}` : void 0, B = !!L && Oe(t.chartType) && !!z && j.some((e) => e[z] != null), V = _(() => {
1814
+ Ee
1815
+ ]), N = !i && !!O && !!t.objectName && j?.target === "navigate" && !!k;
1816
+ oe(() => {
1817
+ N && (k(t.objectName, Le), xe(null));
1818
+ }, [N]);
1819
+ let P = t.compareTo, Re = t.aggregate ? Ut(t.aggregate) : void 0, F = Re ? `${Re}${Wt}` : void 0, I = !!P && ke(t.chartType) && !!F && A.some((e) => e[F] != null), L = v(() => {
1720
1820
  let e = Array.isArray(t.series) ? t.series : null;
1721
- if (!B) return e;
1722
- let n = e || [{ dataKey: R }], r = {
1821
+ if (!I) return e;
1822
+ let n = e || [{ dataKey: Re }], r = {
1723
1823
  vsLastWeek: "Previous week",
1724
1824
  vsLastMonth: "Previous month",
1725
1825
  vsLastQuarter: "Previous quarter",
1726
1826
  vsLastYear: "Previous year",
1727
1827
  vsYesterday: "Yesterday",
1728
1828
  vsPreviousPeriod: "Previous period"
1729
- }[a(L, t.filter)] || "Previous period";
1829
+ }[a(P, t.filter)] || "Previous period";
1730
1830
  return [...n.map((e) => ({
1731
1831
  ...e,
1732
1832
  variant: e.variant || "current"
1733
1833
  })), {
1734
- dataKey: z,
1834
+ dataKey: F,
1735
1835
  label: r,
1736
1836
  variant: "comparison"
1737
1837
  }];
1738
1838
  }, [
1739
- B,
1839
+ I,
1740
1840
  t.series,
1741
- R,
1742
- z,
1841
+ Re,
1842
+ F,
1743
1843
  t.filter,
1744
- L
1745
- ]), H = t.dataset ? n(l(j, be), t.dimensions, t.values, E) : null, He = H ? {
1844
+ P
1845
+ ]), R = t.dataset ? n(m(A, je), t.dimensions, t.values, ge, { nullCategoryLabel: we("chart.nullCategory", "(None)") }) : null, z = R ? {
1746
1846
  ...t,
1747
- data: H.data,
1748
- xAxisKey: H.xAxisKey,
1749
- series: H.series
1847
+ data: R.data,
1848
+ xAxisKey: R.xAxisKey,
1849
+ series: R.series
1750
1850
  } : {
1751
1851
  ...t,
1752
- data: j,
1753
- ...V ? { series: V } : {}
1754
- }, Ue = t.colors && !Array.isArray(t.colors) && typeof t.colors == "object" ? t.colors : null, We = Array.isArray(t.colors) ? t.colors : void 0, U = A || Ue ? {
1755
- ...A || {},
1756
- ...Ue || {}
1757
- } : void 0, Ge = {
1758
- ...He,
1759
- colors: We,
1760
- ...U ? { categoryColors: U } : {}
1852
+ data: A,
1853
+ ...L ? { series: L } : {}
1854
+ }, B = t.colors && !Array.isArray(t.colors) && typeof t.colors == "object" ? t.colors : null, V = Array.isArray(t.colors) ? t.colors : void 0, H = Ae || B ? {
1855
+ ...Ae || {},
1856
+ ...B || {}
1857
+ } : void 0, Je = {
1858
+ ...z,
1859
+ colors: V,
1860
+ ...H ? { categoryColors: H } : {}
1761
1861
  };
1762
- if (ge && j.length === 0) return /* @__PURE__ */ T("div", {
1862
+ if (D && A.length === 0) return /* @__PURE__ */ E("div", {
1763
1863
  className: "p-2 " + (t.className || ""),
1764
1864
  "data-testid": "chart-loading",
1765
1865
  role: "status",
1766
1866
  "aria-busy": "true",
1767
1867
  "aria-live": "polite",
1768
- children: [/* @__PURE__ */ w("span", {
1868
+ children: [/* @__PURE__ */ T("span", {
1769
1869
  className: "sr-only",
1770
1870
  children: "Loading chart data…"
1771
- }), /* @__PURE__ */ w(y, { className: "h-full" })]
1871
+ }), /* @__PURE__ */ T(x, { className: "h-full" })]
1772
1872
  });
1773
- if (_e) return /* @__PURE__ */ T("div", {
1873
+ if (ye) return /* @__PURE__ */ E("div", {
1774
1874
  className: "flex flex-col items-center justify-center gap-2 p-4 " + (t.className || ""),
1775
1875
  "data-testid": "chart-error",
1776
1876
  role: "alert",
1777
1877
  children: [
1778
- /* @__PURE__ */ w(ze, { className: "h-6 w-6 text-destructive opacity-60" }),
1779
- /* @__PURE__ */ w("p", {
1878
+ /* @__PURE__ */ T(We, { className: "h-6 w-6 text-destructive opacity-60" }),
1879
+ /* @__PURE__ */ T("p", {
1780
1880
  className: "text-xs text-destructive font-medium",
1781
1881
  children: "Failed to load chart data"
1782
1882
  }),
1783
- /* @__PURE__ */ w("p", {
1883
+ /* @__PURE__ */ T("p", {
1784
1884
  className: "text-xs text-muted-foreground max-w-xs text-center",
1785
- children: _e
1885
+ children: ye
1786
1886
  })
1787
1887
  ]
1788
1888
  });
1789
- if (!g && t.objectName && j.length === 0) return /* @__PURE__ */ T("div", {
1889
+ if (!h && t.objectName && A.length === 0) return /* @__PURE__ */ E("div", {
1790
1890
  className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (t.className || ""),
1791
1891
  "data-testid": "chart-no-datasource",
1792
1892
  children: [
@@ -1795,22 +1895,22 @@ var Ft = (e) => {
1795
1895
  "”"
1796
1896
  ]
1797
1897
  });
1798
- let Ke = c(M) ? (e) => {
1799
- let t = e.category, n = t != null && P.has(String(t)) ? P.get(String(t)) : t;
1800
- k({
1898
+ let Ye = d(j) ? (e) => {
1899
+ let t = e.category, n = t != null && Ie.has(String(t)) ? Ie.get(String(t)) : t;
1900
+ xe({
1801
1901
  ...e,
1802
1902
  category: n,
1803
1903
  categoryLabel: t,
1804
1904
  scope: "cell"
1805
1905
  });
1806
- } : void 0, qe = m ?? Ke, Je = !m && O && t.objectName && !Ne ? (() => {
1807
- let e = F ?? {}, n = d(M, O, t.title || "Details"), r = M?.target ?? "drawer", i = {
1906
+ } : void 0, Xe = i ?? Ye, Ze = !i && O && t.objectName && !N ? (() => {
1907
+ let e = Le ?? {}, n = te(j, O, t.title || "Details"), r = j?.target ?? "drawer", i = {
1808
1908
  type: "object-data-table",
1809
1909
  objectName: t.objectName,
1810
1910
  filter: e,
1811
1911
  pagination: !0,
1812
- pageSize: M?.maxRows,
1813
- columns: M?.columns?.map((e) => ({
1912
+ pageSize: j?.maxRows,
1913
+ columns: j?.columns?.map((e) => ({
1814
1914
  accessorKey: e,
1815
1915
  header: e
1816
1916
  })),
@@ -1819,63 +1919,75 @@ var Ft = (e) => {
1819
1919
  mode: "record",
1820
1920
  target: "dialog"
1821
1921
  }
1822
- }, a = /* @__PURE__ */ w("div", {
1922
+ }, a = /* @__PURE__ */ T("div", {
1823
1923
  className: "overflow-auto",
1824
1924
  "data-testid": "chart-drill-body",
1825
- children: /* @__PURE__ */ w(Pe, {
1925
+ children: /* @__PURE__ */ T(ze, {
1826
1926
  schema: i,
1827
- dataSource: g
1927
+ dataSource: h
1828
1928
  })
1829
- }), o = Se && t.objectName ? /* @__PURE__ */ T(ie, {
1929
+ }), o = k && t.objectName ? /* @__PURE__ */ E(b, {
1830
1930
  type: "button",
1831
1931
  variant: "ghost",
1832
1932
  size: "sm",
1833
1933
  "data-testid": "drill-open-in-list",
1834
1934
  onClick: () => {
1835
- Se(t.objectName, e), k(null);
1935
+ k(t.objectName, e), xe(null);
1836
1936
  },
1837
- children: [Ce("dashboard.openInList", "Open in list"), /* @__PURE__ */ w(Be, { className: "ml-1 h-3.5 w-3.5" })]
1937
+ children: [we("dashboard.openInList", "Open in list"), /* @__PURE__ */ T(Ge, { className: "ml-1 h-3.5 w-3.5" })]
1838
1938
  }) : null;
1839
- return r === "dialog" ? /* @__PURE__ */ w(ae, {
1939
+ return r === "dialog" ? /* @__PURE__ */ T(S, {
1840
1940
  open: !0,
1841
- onOpenChange: (e) => !e && k(null),
1842
- children: /* @__PURE__ */ T(b, {
1941
+ onOpenChange: (e) => !e && xe(null),
1942
+ children: /* @__PURE__ */ E(C, {
1843
1943
  className: "max-w-4xl",
1844
- children: [/* @__PURE__ */ T(x, {
1944
+ children: [/* @__PURE__ */ E(se, {
1845
1945
  className: "flex-row items-center justify-between gap-4 pr-8",
1846
- children: [/* @__PURE__ */ w(S, { children: n }), o]
1946
+ children: [/* @__PURE__ */ T(ce, { children: n }), o]
1847
1947
  }), a]
1848
1948
  })
1849
- }) : /* @__PURE__ */ w(oe, {
1949
+ }) : /* @__PURE__ */ T(ue, {
1850
1950
  open: !0,
1851
- onOpenChange: (e) => !e && k(null),
1852
- children: /* @__PURE__ */ T(se, {
1951
+ onOpenChange: (e) => !e && xe(null),
1952
+ children: /* @__PURE__ */ E(de, {
1853
1953
  side: "right",
1854
1954
  className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
1855
- children: [/* @__PURE__ */ T(ce, {
1955
+ children: [/* @__PURE__ */ E(fe, {
1856
1956
  className: "flex-row items-center justify-between gap-4 pr-8",
1857
- children: [/* @__PURE__ */ w(le, { children: n }), o]
1858
- }), /* @__PURE__ */ w("div", {
1957
+ children: [/* @__PURE__ */ T(pe, { children: n }), o]
1958
+ }), /* @__PURE__ */ T("div", {
1859
1959
  className: "flex-1 overflow-hidden mt-2",
1860
1960
  children: a
1861
1961
  })]
1862
1962
  })
1863
1963
  });
1864
1964
  })() : null;
1865
- return /* @__PURE__ */ T("div", {
1866
- className: "relative",
1965
+ return /* @__PURE__ */ E("div", {
1966
+ className: "relative h-full",
1867
1967
  children: [
1868
- /* @__PURE__ */ w(C, { active: ge && j.length > 0 }),
1869
- /* @__PURE__ */ w($, {
1968
+ /* @__PURE__ */ T(le, { active: D && A.length > 0 }),
1969
+ /* @__PURE__ */ T($, {
1870
1970
  ...e,
1871
- schema: Ge,
1872
- onChartClick: qe
1971
+ schema: Je,
1972
+ onChartClick: Xe
1873
1973
  }),
1874
- Je
1974
+ Ze
1875
1975
  ]
1876
1976
  });
1877
- };
1878
- e.register("object-chart", Ft, {
1977
+ }, Jt = { filter: !0 }, Yt = (e) => /* @__PURE__ */ T(F, {
1978
+ schema: e.schema,
1979
+ mapping: Jt,
1980
+ dataSource: e.dataSource,
1981
+ testId: "object-chart",
1982
+ errorTitle: "This chart’s data source could not be resolved",
1983
+ children: (t) => /* @__PURE__ */ T(qt, {
1984
+ ...e,
1985
+ schema: t
1986
+ })
1987
+ });
1988
+ //#endregion
1989
+ //#region src/index.tsx
1990
+ e.register("object-chart", Yt, {
1879
1991
  namespace: "plugin-charts",
1880
1992
  label: "Object Chart",
1881
1993
  category: "view",
@@ -1910,14 +2022,12 @@ e.register("object-chart", Ft, {
1910
2022
  description: "Segment drill config: { enabled?, filter?, title?, target?: 'drawer' | 'dialog', columns?, maxRows? }. Present = on; {} is enough. Clicking a segment opens the underlying records filtered by the clicked category."
1911
2023
  }
1912
2024
  ]
1913
- });
1914
- //#endregion
1915
- //#region src/index.tsx
1916
- var It = {
1917
- "bar-chart": kt,
2025
+ }), rt();
2026
+ var Xt = {
2027
+ "bar-chart": Ht,
1918
2028
  chart: $
1919
2029
  };
1920
- e.register("bar-chart", kt, {
2030
+ e.register("bar-chart", Ht, {
1921
2031
  namespace: "plugin-charts",
1922
2032
  label: "Bar Chart",
1923
2033
  category: "plugin",
@@ -1981,7 +2091,7 @@ e.register("bar-chart", kt, {
1981
2091
  height: 400,
1982
2092
  color: "#8884d8"
1983
2093
  }
1984
- }), e.register("chart", Ft, {
2094
+ }), e.register("chart", Yt, {
1985
2095
  namespace: "view",
1986
2096
  category: "view",
1987
2097
  label: "Chart",
@@ -2148,4 +2258,4 @@ e.register("bar-chart", kt, {
2148
2258
  defaultProps: { chartType: "scatter" }
2149
2259
  });
2150
2260
  //#endregion
2151
- export { kt as ChartBarRenderer, $ as ChartRenderer, Ft as ObjectChart, It as chartComponents };
2261
+ export { Ht as ChartBarRenderer, $ as ChartRenderer, qt as ObjectChart, Yt as ObjectChartBlock, Xt as chartComponents, H as normalizeChartSchema };