@nice2dev/ui 1.4.21 → 1.4.23

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.
@@ -1,7 +1,7 @@
1
- import { jsxs as u, jsx as n } from "react/jsx-runtime";
2
- import { useNiceTranslation as oe, NiceIcon as ce, clickOnActivationKey as pe } from "@nice2dev/ui-core";
3
- import me, { forwardRef as ue, useState as J, useCallback as X, useMemo as ae, useImperativeHandle as fe, useRef as ie, useEffect as he } from "react";
4
- const $e = [], Le = [], Ce = [], ge = [
1
+ import { jsxs as m, jsx as a } from "react/jsx-runtime";
2
+ import { useNiceTranslation as ce, NiceIcon as de, clickOnActivationKey as ue } from "@nice2dev/ui-core";
3
+ import ge, { forwardRef as ve, useState as ee, useCallback as W, useMemo as ie, useImperativeHandle as xe, useId as Se, useRef as oe, useEffect as fe } from "react";
4
+ const ze = [], Ie = [], De = [], ye = [
5
5
  "var(--nice-color-primary, #3b82f6)",
6
6
  "var(--nice-color-error, #ef4444)",
7
7
  "var(--nice-color-success, #22c55e)",
@@ -12,234 +12,263 @@ const $e = [], Le = [], Ce = [], ge = [
12
12
  "var(--nice-color-success, #10b981)",
13
13
  "var(--nice-color-warning, #f59e0b)",
14
14
  "var(--nice-color-accent, #6366f1)"
15
- ], Pe = /* @__PURE__ */ Object.assign(
16
- /* @__PURE__ */ ue((R, D) => {
17
- const { t: M } = oe(), {
18
- levels: x = Ce,
19
- initialLevelId: U,
20
- levelId: B,
21
- chartType: Q = "bar",
22
- width: L = 600,
23
- height: E = 400,
24
- showBreadcrumbs: te = !0,
25
- showBackButton: Z = !0,
26
- animationDuration: V = 300,
15
+ ], Te = /* @__PURE__ */ Object.assign(
16
+ /* @__PURE__ */ ve((E, A) => {
17
+ const { t: $ } = ce(), {
18
+ levels: b = De,
19
+ initialLevelId: H,
20
+ levelId: Y,
21
+ chartType: te = "bar",
22
+ width: k = 600,
23
+ height: O = 400,
24
+ showBreadcrumbs: ne = !0,
25
+ showBackButton: K = !0,
26
+ animationDuration: F = 300,
27
27
  onLevelChange: j,
28
- onItemClick: ne,
29
- colors: Y = ge,
30
- showValues: H = !0,
31
- showLegend: K = !0,
32
- className: _,
28
+ onItemClick: ae,
29
+ colors: X = ye,
30
+ showValues: G = !0,
31
+ showLegend: q = !0,
32
+ className: Z,
33
33
  style: T,
34
- testId: C,
35
- "data-testid": q,
36
- ...v
37
- } = R, h = B !== void 0, [f, S] = J(U || x[0]?.id), [d, O] = J([U || x[0]?.id]), I = X(
38
- (a) => {
39
- const e = [];
40
- let r = x.find((i) => i.id === a);
41
- for (; r && !e.includes(r.id); ) {
42
- e.unshift(r.id);
43
- const i = r.parentId;
44
- r = i ? x.find((p) => p.id === i) : void 0;
45
- }
46
- return e.length > 0 ? e : [a];
34
+ testId: S,
35
+ "data-testid": Q,
36
+ ...x
37
+ } = E, h = Y !== void 0, [g, z] = ee(H || b[0]?.id), [d, _] = ee([H || b[0]?.id]), P = W(
38
+ (e) => {
39
+ const n = [];
40
+ let i = b.find((c) => c.id === e);
41
+ for (; i && !n.includes(i.id); ) {
42
+ n.unshift(i.id);
43
+ const c = i.parentId;
44
+ i = c ? b.find((p) => p.id === c) : void 0;
45
+ }
46
+ return n.length > 0 ? n : [e];
47
47
  },
48
- [x]
49
- ), l = B ?? f, o = ae(
50
- () => B !== void 0 ? I(B) : d,
51
- [B, d, I]
52
- ), [g, m] = J(!1), [$, y] = J("in"), c = ae(
53
- () => x.find((a) => a.id === l),
54
- [x, l]
55
- ), z = X(
56
- (a) => {
57
- x.find((r) => r.id === a) && (y("in"), m(!0), setTimeout(() => {
58
- h || (S(a), O((r) => [...r, a])), j?.(a, h ? I(a) : [...o, a]), m(!1);
59
- }, V / 2));
48
+ [b]
49
+ ), l = Y ?? g, r = ie(
50
+ () => Y !== void 0 ? P(Y) : d,
51
+ [Y, d, P]
52
+ ), [v, u] = ee(!1), [C, w] = ee("in"), o = ie(
53
+ () => b.find((e) => e.id === l),
54
+ [b, l]
55
+ ), I = W(
56
+ (e) => {
57
+ b.find((i) => i.id === e) && (w("in"), u(!0), setTimeout(() => {
58
+ h || (z(e), _((i) => [...i, e])), j?.(e, h ? P(e) : [...r, e]), u(!1);
59
+ }, F / 2));
60
60
  },
61
- [x, o, V, j, h, I]
62
- ), N = X(() => {
63
- if (o.length <= 1)
61
+ [b, r, F, j, h, P]
62
+ ), L = W(() => {
63
+ if (r.length <= 1)
64
64
  return;
65
- y("out"), m(!0);
66
- const a = o.slice(0, -1), e = a[a.length - 1];
65
+ w("out"), u(!0);
66
+ const e = r.slice(0, -1), n = e[e.length - 1];
67
67
  setTimeout(() => {
68
- h || (S(e), O(a)), j?.(e, a), m(!1);
69
- }, V / 2);
70
- }, [o, V, j, h]), P = X(() => {
71
- const a = x[0]?.id;
72
- a && (y("out"), m(!0), setTimeout(() => {
73
- h || (S(a), O([a])), j?.(a, [a]), m(!1);
74
- }, V / 2));
75
- }, [x, V, j, h]);
76
- fe(
77
- D,
68
+ h || (z(n), _(e)), j?.(n, e), u(!1);
69
+ }, F / 2);
70
+ }, [r, F, j, h]), R = W(() => {
71
+ const e = b[0]?.id;
72
+ e && (w("out"), u(!0), setTimeout(() => {
73
+ h || (z(e), _([e])), j?.(e, [e]), u(!1);
74
+ }, F / 2));
75
+ }, [b, F, j, h]);
76
+ xe(
77
+ A,
78
78
  () => ({
79
- drillDown: z,
80
- drillUp: N,
81
- resetToRoot: P,
79
+ drillDown: I,
80
+ drillUp: L,
81
+ resetToRoot: R,
82
82
  getCurrentLevel: () => l,
83
- getPath: () => o
83
+ getPath: () => r
84
84
  }),
85
- [z, N, P, l, o]
85
+ [I, L, R, l, r]
86
86
  );
87
- const t = X(
88
- (a, e) => {
89
- ne?.(a, l);
90
- const r = x.find(
91
- (i) => i.parentId === l && i.id === a.metadata?.childLevelId
92
- );
93
- r && z(r.id);
87
+ const t = W(
88
+ (e, n) => {
89
+ ae?.(e, l);
90
+ const i = e.drillDownId ?? e.metadata?.childLevelId, c = i ? b.find((p) => p.id === i) : void 0;
91
+ c && I(c.id);
94
92
  },
95
- [l, x, z, ne]
96
- ), w = ae(
97
- () => c?.data.reduce((a, e) => a + e.value, 0) || 0,
98
- [c]
99
- ), k = ae(
100
- () => o.map((a) => x.find((e) => e.id === a)?.label || a),
101
- [o, x]
102
- ), G = () => {
103
- if (!c)
93
+ [l, b, I, ae]
94
+ ), M = ie(
95
+ () => o?.data.reduce((e, n) => e + n.value, 0) || 0,
96
+ [o]
97
+ ), N = ie(
98
+ () => r.map((e) => b.find((n) => n.id === e)?.label || e),
99
+ [r, b]
100
+ ), J = () => {
101
+ if (!o)
104
102
  return null;
105
- const a = c.data, e = Math.max(...a.map((i) => i.value)), r = Math.min(40, (E - 100) / a.length - 8);
106
- return /* @__PURE__ */ n("div", { className: "nice-drilldown-bars", children: a.map((i, p) => {
107
- const F = i.value / e * 100;
108
- return /* @__PURE__ */ u(
103
+ const e = o.data, n = Math.max(...e.map((c) => c.value)), i = Math.min(40, (O - 100) / e.length - 8);
104
+ return /* @__PURE__ */ a("div", { className: "nice-drilldown-bars", children: e.map((c, p) => {
105
+ const s = c.value / n * 100;
106
+ return /* @__PURE__ */ m(
109
107
  "div",
110
108
  {
111
109
  role: "button",
112
110
  tabIndex: 0,
113
- onKeyDown: pe,
111
+ onKeyDown: ue,
114
112
  className: "nice-drilldown-bar-row",
115
- onClick: () => t(i, p),
113
+ onClick: () => t(c, p),
116
114
  children: [
117
- /* @__PURE__ */ n("span", { className: "nice-drilldown-bar-label", children: i.label || M("charts.item", "Item {i}").replace("{i}", String(p + 1)) }),
118
- /* @__PURE__ */ n("div", { className: "nice-drilldown-bar-track", children: /* @__PURE__ */ n(
115
+ /* @__PURE__ */ a("span", { className: "nice-drilldown-bar-label", children: c.label || $("charts.item", "Item {i}").replace("{i}", String(p + 1)) }),
116
+ /* @__PURE__ */ a("div", { className: "nice-drilldown-bar-track", children: /* @__PURE__ */ a(
119
117
  "div",
120
118
  {
121
119
  className: "nice-drilldown-bar-fill",
122
120
  style: {
123
- width: `${F}%`,
124
- backgroundColor: i.color || Y[p % Y.length],
125
- height: r
121
+ width: `${s}%`,
122
+ backgroundColor: c.color || X[p % X.length],
123
+ height: i
126
124
  }
127
125
  }
128
126
  ) }),
129
- H && /* @__PURE__ */ n("span", { className: "nice-drilldown-bar-value", children: i.value.toLocaleString() })
127
+ G && /* @__PURE__ */ a("span", { className: "nice-drilldown-bar-value", children: c.value.toLocaleString() })
130
128
  ]
131
129
  },
132
130
  p
133
131
  );
134
132
  }) });
135
- }, b = () => {
136
- if (!c)
133
+ }, y = `nice-drill-gaps-${Se().replace(/[^a-zA-Z0-9_-]/g, "")}`, V = () => {
134
+ if (!o)
137
135
  return null;
138
- const a = c.data, e = L / 2, r = (E - 60) / 2 + 30, i = Math.min(e, r) - 40;
139
- let p = -90;
140
- const F = a.map((s, A) => {
141
- const ee = s.value / w * 360, re = p + ee, ve = ee > 180 ? 1 : 0, le = p * Math.PI / 180, se = re * Math.PI / 180, xe = e + i * Math.cos(le), ye = r + i * Math.sin(le), be = e + i * Math.cos(se), we = r + i * Math.sin(se), de = (p + ee / 2) * Math.PI / 180, ke = e + i * 0.7 * Math.cos(de), Me = r + i * 0.7 * Math.sin(de), Ne = `M ${e} ${r} L ${xe} ${ye} A ${i} ${i} 0 ${ve} 1 ${be} ${we} Z`;
142
- return p = re, {
143
- path: Ne,
144
- color: s.color || Y[A % Y.length],
145
- label: s.label || M("charts.item", "Item {i}").replace("{i}", String(A + 1)),
146
- value: s.value,
147
- percentage: (s.value / w * 100).toFixed(1),
148
- labelX: ke,
149
- labelY: Me,
150
- item: s,
151
- index: A
136
+ const e = o.data, n = O - 40, i = k / 2, c = n / 2, p = Math.max(10, Math.min(k, n) / 2 - 16);
137
+ let s = -90;
138
+ const B = e.map((f, re) => {
139
+ const le = f.value / M * 360, pe = s + le, be = le > 180 ? 1 : 0, se = s * Math.PI / 180, he = pe * Math.PI / 180, we = i + p * Math.cos(se), ke = c + p * Math.sin(se), Me = i + p * Math.cos(he), Ne = c + p * Math.sin(he), me = (s + le / 2) * Math.PI / 180, $e = i + p * 0.7 * Math.cos(me), Le = c + p * 0.7 * Math.sin(me), Ce = `M ${i} ${c} L ${we} ${ke} A ${p} ${p} 0 ${be} 1 ${Me} ${Ne} Z`;
140
+ return s = pe, {
141
+ path: Ce,
142
+ startRad: se,
143
+ drillable: !!(f.drillDownId ?? f.metadata?.childLevelId),
144
+ color: f.color || X[re % X.length],
145
+ label: f.label || $("charts.item", "Item {i}").replace("{i}", String(re + 1)),
146
+ value: f.value,
147
+ percentage: (f.value / M * 100).toFixed(1),
148
+ labelX: $e,
149
+ labelY: Le,
150
+ item: f,
151
+ index: re
152
152
  };
153
- });
154
- return /* @__PURE__ */ n("svg", { width: L, height: E - 40, className: "nice-drilldown-pie", children: /* @__PURE__ */ n("g", { children: F.map((s, A) => /* @__PURE__ */ u("g", { onClick: () => t(s.item, s.index), children: [
155
- /* @__PURE__ */ n(
156
- "path",
157
- {
158
- d: s.path,
159
- fill: s.color,
160
- stroke: "white",
161
- strokeWidth: 2,
162
- className: "nice-drilldown-pie-slice"
163
- }
164
- ),
165
- H && parseFloat(s.percentage) > 5 && /* @__PURE__ */ u(
166
- "text",
153
+ }), U = B.length > 1 ? B.map((f) => f.startRad) : [];
154
+ return /* @__PURE__ */ m("svg", { width: k, height: n, className: "nice-drilldown-pie", children: [
155
+ U.length > 0 && /* @__PURE__ */ a("defs", { children: /* @__PURE__ */ m(
156
+ "mask",
167
157
  {
168
- x: s.labelX,
169
- y: s.labelY,
170
- textAnchor: "middle",
171
- dominantBaseline: "middle",
172
- fill: "white",
173
- fontSize: "12",
174
- fontWeight: "600",
158
+ id: y,
159
+ maskUnits: "userSpaceOnUse",
160
+ x: 0,
161
+ y: 0,
162
+ width: k,
163
+ height: n,
175
164
  children: [
176
- s.percentage,
177
- "%"
165
+ /* @__PURE__ */ a("rect", { x: 0, y: 0, width: k, height: n, fill: "white" }),
166
+ U.map((f, re) => /* @__PURE__ */ a(
167
+ "line",
168
+ {
169
+ x1: i,
170
+ y1: c,
171
+ x2: i + (p + 2) * Math.cos(f),
172
+ y2: c + (p + 2) * Math.sin(f),
173
+ stroke: "black",
174
+ strokeWidth: 2
175
+ },
176
+ re
177
+ ))
178
178
  ]
179
179
  }
180
+ ) }),
181
+ /* @__PURE__ */ a("g", { mask: U.length > 0 ? `url(#${y})` : void 0, children: B.map((f, re) => /* @__PURE__ */ a(
182
+ "path",
183
+ {
184
+ d: f.path,
185
+ fill: f.color,
186
+ className: `nice-drilldown-pie-slice${f.drillable ? " nice-drilldown-pie-slice--drillable" : ""}`,
187
+ onClick: () => t(f.item, f.index),
188
+ children: /* @__PURE__ */ a("title", { children: `${f.label}: ${f.value} (${f.percentage}%)` })
189
+ },
190
+ re
191
+ )) }),
192
+ G && B.map(
193
+ (f, re) => parseFloat(f.percentage) > 5 ? /* @__PURE__ */ m(
194
+ "text",
195
+ {
196
+ x: f.labelX,
197
+ y: f.labelY,
198
+ textAnchor: "middle",
199
+ dominantBaseline: "middle",
200
+ className: "nice-piechart__label",
201
+ style: { fontSize: 13, pointerEvents: "none" },
202
+ children: [
203
+ f.percentage,
204
+ "%"
205
+ ]
206
+ },
207
+ re
208
+ ) : null
180
209
  )
181
- ] }, A)) }) });
182
- }, W = () => {
183
- if (!c)
210
+ ] });
211
+ }, D = () => {
212
+ if (!o)
184
213
  return null;
185
- const a = c.data, e = Math.max(...a.map((p) => p.value)), r = Math.min(60, (L - 100) / a.length - 8), i = E - 100;
186
- return /* @__PURE__ */ n("svg", { width: L, height: E - 40, className: "nice-drilldown-columns", children: /* @__PURE__ */ u("g", { transform: "translate(50, 20)", children: [
187
- [0, 0.25, 0.5, 0.75, 1].map((p, F) => /* @__PURE__ */ u("g", { children: [
188
- /* @__PURE__ */ n(
214
+ const e = o.data, n = Math.max(...e.map((p) => p.value)), i = Math.min(60, (k - 100) / e.length - 8), c = O - 100;
215
+ return /* @__PURE__ */ a("svg", { width: k, height: O - 40, className: "nice-drilldown-columns", children: /* @__PURE__ */ m("g", { transform: "translate(50, 20)", children: [
216
+ [0, 0.25, 0.5, 0.75, 1].map((p, s) => /* @__PURE__ */ m("g", { children: [
217
+ /* @__PURE__ */ a(
189
218
  "line",
190
219
  {
191
220
  x1: 0,
192
- y1: i * (1 - p),
193
- x2: L - 80,
194
- y2: i * (1 - p),
221
+ y1: c * (1 - p),
222
+ x2: k - 80,
223
+ y2: c * (1 - p),
195
224
  stroke: "var(--nice-border-color, #e5e7eb)",
196
225
  strokeDasharray: p === 0 ? void 0 : "4"
197
226
  }
198
227
  ),
199
- /* @__PURE__ */ n(
228
+ /* @__PURE__ */ a(
200
229
  "text",
201
230
  {
202
231
  x: -8,
203
- y: i * (1 - p),
232
+ y: c * (1 - p),
204
233
  textAnchor: "end",
205
234
  dominantBaseline: "middle",
206
235
  fontSize: "11",
207
236
  fill: "var(--nice-text-secondary, #6b7280)",
208
- children: Math.round(e * p).toLocaleString()
237
+ children: Math.round(n * p).toLocaleString()
209
238
  }
210
239
  )
211
- ] }, F)),
212
- a.map((p, F) => {
213
- const s = p.value / e * i, A = F * ((L - 100) / a.length) + ((L - 100) / a.length - r) / 2;
214
- return /* @__PURE__ */ u("g", { onClick: () => t(p, F), children: [
215
- /* @__PURE__ */ n(
240
+ ] }, s)),
241
+ e.map((p, s) => {
242
+ const B = p.value / n * c, U = s * ((k - 100) / e.length) + ((k - 100) / e.length - i) / 2;
243
+ return /* @__PURE__ */ m("g", { onClick: () => t(p, s), children: [
244
+ /* @__PURE__ */ a(
216
245
  "rect",
217
246
  {
218
- x: A,
219
- y: i - s,
220
- width: r,
221
- height: s,
222
- fill: p.color || Y[F % Y.length],
247
+ x: U,
248
+ y: c - B,
249
+ width: i,
250
+ height: B,
251
+ fill: p.color || X[s % X.length],
223
252
  rx: 4,
224
253
  className: "nice-drilldown-column-bar"
225
254
  }
226
255
  ),
227
- /* @__PURE__ */ n(
256
+ /* @__PURE__ */ a(
228
257
  "text",
229
258
  {
230
- x: A + r / 2,
231
- y: i + 16,
259
+ x: U + i / 2,
260
+ y: c + 16,
232
261
  textAnchor: "middle",
233
262
  fontSize: "11",
234
263
  fill: "var(--nice-text-primary, #374151)",
235
- children: (p.label || `${F + 1}`).slice(0, 10)
264
+ children: (p.label || `${s + 1}`).slice(0, 10)
236
265
  }
237
266
  ),
238
- H && /* @__PURE__ */ n(
267
+ G && /* @__PURE__ */ a(
239
268
  "text",
240
269
  {
241
- x: A + r / 2,
242
- y: i - s - 8,
270
+ x: U + i / 2,
271
+ y: c - B - 8,
243
272
  textAnchor: "middle",
244
273
  fontSize: "11",
245
274
  fill: "var(--nice-text-primary, #374151)",
@@ -247,61 +276,70 @@ const $e = [], Le = [], Ce = [], ge = [
247
276
  children: p.value.toLocaleString()
248
277
  }
249
278
  )
250
- ] }, F);
279
+ ] }, s);
251
280
  })
252
281
  ] }) });
253
282
  };
254
- return /* @__PURE__ */ u(
283
+ return /* @__PURE__ */ m(
255
284
  "div",
256
285
  {
257
- className: `nice-drilldown-chart ${g ? `animating ${$}` : ""} ${_ || ""}`,
258
- style: { width: L, ...T },
259
- "data-testid": q ?? C,
260
- ...v,
286
+ className: `nice-drilldown-chart ${v ? `animating ${C}` : ""} ${Z || ""}`,
287
+ style: { width: k, ...T },
288
+ "data-testid": Q ?? S,
289
+ ...x,
261
290
  children: [
262
- /* @__PURE__ */ u("div", { className: "nice-drilldown-header", children: [
263
- Z && o.length > 1 && /* @__PURE__ */ u("button", { className: "nice-drilldown-back", onClick: N, children: [
264
- /* @__PURE__ */ n(ce, { name: "arrow-left", size: 14 }),
265
- " ",
266
- M("charts.back", "Back")
267
- ] }),
268
- te && /* @__PURE__ */ n("div", { className: "nice-drilldown-breadcrumbs", children: k.map((a, e) => /* @__PURE__ */ u(me.Fragment, { children: [
269
- e > 0 && /* @__PURE__ */ n("span", { className: "nice-drilldown-separator", children: "/" }),
270
- /* @__PURE__ */ n(
291
+ /* @__PURE__ */ m("div", { className: "nice-drilldown-header", children: [
292
+ K && /* @__PURE__ */ m(
293
+ "button",
294
+ {
295
+ type: "button",
296
+ className: "nice-drilldown-back",
297
+ onClick: L,
298
+ disabled: r.length <= 1,
299
+ children: [
300
+ /* @__PURE__ */ a(de, { name: "arrow-left", size: 14 }),
301
+ " ",
302
+ $("charts.back", "Back")
303
+ ]
304
+ }
305
+ ),
306
+ ne && /* @__PURE__ */ a("div", { className: "nice-drilldown-breadcrumbs", children: N.map((e, n) => /* @__PURE__ */ m(ge.Fragment, { children: [
307
+ n > 0 && /* @__PURE__ */ a("span", { className: "nice-drilldown-separator", children: "/" }),
308
+ /* @__PURE__ */ a(
271
309
  "span",
272
310
  {
273
- role: e < k.length - 1 ? "button" : void 0,
274
- tabIndex: e < k.length - 1 ? 0 : void 0,
275
- "aria-current": e === k.length - 1 ? "location" : void 0,
276
- onKeyDown: e < k.length - 1 ? pe : void 0,
277
- className: `nice-drilldown-crumb ${e === k.length - 1 ? "active" : ""}`,
311
+ role: n < N.length - 1 ? "button" : void 0,
312
+ tabIndex: n < N.length - 1 ? 0 : void 0,
313
+ "aria-current": n === N.length - 1 ? "location" : void 0,
314
+ onKeyDown: n < N.length - 1 ? ue : void 0,
315
+ className: `nice-drilldown-crumb ${n === N.length - 1 ? "active" : ""}`,
278
316
  onClick: () => {
279
- if (e < k.length - 1) {
280
- const r = o.slice(0, e + 1), i = r[r.length - 1];
281
- h || (O(r), S(i)), j?.(i, r);
317
+ if (n < N.length - 1) {
318
+ const i = r.slice(0, n + 1), c = i[i.length - 1];
319
+ h || (_(i), z(c)), j?.(c, i);
282
320
  }
283
321
  },
284
- children: a
322
+ children: e
285
323
  }
286
324
  )
287
- ] }, e)) })
325
+ ] }, n)) })
288
326
  ] }),
289
- /* @__PURE__ */ u("div", { className: "nice-drilldown-content", style: { height: E - 40 }, children: [
290
- Q === "bar" && G(),
291
- Q === "pie" && b(),
292
- Q === "column" && W()
327
+ /* @__PURE__ */ m("div", { className: "nice-drilldown-content", style: { height: O - 40 }, children: [
328
+ te === "bar" && J(),
329
+ te === "pie" && V(),
330
+ te === "column" && D()
293
331
  ] }),
294
- K && c && /* @__PURE__ */ n("div", { className: "nice-drilldown-legend", children: c.data.map((a, e) => /* @__PURE__ */ u("div", { className: "nice-drilldown-legend-item", children: [
295
- /* @__PURE__ */ n(
332
+ q && o && /* @__PURE__ */ a("div", { className: "nice-drilldown-legend", children: o.data.map((e, n) => /* @__PURE__ */ m("div", { className: "nice-drilldown-legend-item", children: [
333
+ /* @__PURE__ */ a(
296
334
  "span",
297
335
  {
298
336
  className: "nice-drilldown-legend-color",
299
- style: { backgroundColor: a.color || Y[e % Y.length] }
337
+ style: { backgroundColor: e.color || X[n % X.length] }
300
338
  }
301
339
  ),
302
- /* @__PURE__ */ n("span", { className: "nice-drilldown-legend-label", children: a.label || M("charts.item", "Item {i}").replace("{i}", String(e + 1)) })
303
- ] }, e)) }),
304
- /* @__PURE__ */ n("style", { children: `
340
+ /* @__PURE__ */ a("span", { className: "nice-drilldown-legend-label", children: e.label || $("charts.item", "Item {i}").replace("{i}", String(n + 1)) })
341
+ ] }, n)) }),
342
+ /* @__PURE__ */ a("style", { children: `
305
343
  .nice-drilldown-chart {
306
344
  font-family: inherit;
307
345
  color: var(--nice-text-primary, #111827);
@@ -439,7 +477,13 @@ const $e = [], Le = [], Ce = [], ge = [
439
477
 
440
478
  .nice-drilldown-pie-slice:hover {
441
479
  opacity: 0.85;
442
- transform: scale(1.02);
480
+ }
481
+ .nice-drilldown-pie-slice--drillable {
482
+ cursor: zoom-in;
483
+ }
484
+ .nice-drilldown-back:disabled {
485
+ opacity: 0.45;
486
+ cursor: default;
443
487
  }
444
488
 
445
489
  .nice-drilldown-column-bar {
@@ -482,89 +526,89 @@ const $e = [], Le = [], Ce = [], ge = [
482
526
  );
483
527
  }),
484
528
  { displayName: "NiceDrillDownChart" }
485
- ), Se = [
529
+ ), Ae = [
486
530
  "var(--nice-info-bg, #dbeafe)",
487
531
  "var(--nice-color-primary-light, #93c5fd)",
488
532
  "var(--nice-color-primary, #3b82f6)",
489
533
  "var(--nice-color-primary-active, #1d4ed8)",
490
534
  "var(--nice-color-primary, #6366f1)"
491
- ], Ae = ({
492
- type: R = "choropleth",
493
- regions: D = [],
494
- bubbles: M = [],
495
- width: x = 800,
496
- height: U = 500,
497
- viewBox: B = "0 0 800 500",
498
- colorScale: Q,
535
+ ], Be = ({
536
+ type: E = "choropleth",
537
+ regions: A = [],
538
+ bubbles: $ = [],
539
+ width: b = 800,
540
+ height: H = 500,
541
+ viewBox: Y = "0 0 800 500",
542
+ colorScale: te,
499
543
  // The documented alias of `colorScale`. It was never destructured, so it did nothing
500
544
  // and fell through `...rest` onto the root div (React warned about an unknown prop).
501
- colorRange: L,
502
- minValue: E,
503
- maxValue: te,
504
- showTooltip: Z = !0,
505
- showLegend: V = !0,
545
+ colorRange: k,
546
+ minValue: O,
547
+ maxValue: ne,
548
+ showTooltip: K = !0,
549
+ showLegend: F = !0,
506
550
  onRegionClick: j,
507
- onBubbleClick: ne,
508
- onRegionHover: Y,
509
- title: H,
510
- mapSvg: K,
511
- zoomable: _ = !1,
551
+ onBubbleClick: ae,
552
+ onRegionHover: X,
553
+ title: G,
554
+ mapSvg: q,
555
+ zoomable: Z = !1,
512
556
  className: T,
513
- style: C,
514
- testId: q,
515
- "data-testid": v,
557
+ style: S,
558
+ testId: Q,
559
+ "data-testid": x,
516
560
  ...h
517
561
  }) => {
518
- const f = Q ?? L ?? Se, { t: S } = oe(), [d, O] = J(null), [I, l] = J(1), [o, g] = J({ x: 0, y: 0 }), m = ie(null), $ = ie(!1), y = ie({ x: 0, y: 0 }), c = E ?? Math.min(...D.map((e) => e.value), ...M.map((e) => e.value)), z = te ?? Math.max(...D.map((e) => e.value), ...M.map((e) => e.value)), N = X(
562
+ const g = te ?? k ?? Ae, { t: z } = ce(), [d, _] = ee(null), [P, l] = ee(1), [r, v] = ee({ x: 0, y: 0 }), u = oe(null), C = oe(!1), w = oe({ x: 0, y: 0 }), o = O ?? Math.min(...A.map((e) => e.value), ...$.map((e) => e.value)), I = ne ?? Math.max(...A.map((e) => e.value), ...$.map((e) => e.value)), L = W(
519
563
  (e) => {
520
- const r = (e - c) / (z - c), i = Math.min(Math.floor(r * f.length), f.length - 1);
521
- return f[Math.max(0, i)];
564
+ const n = (e - o) / (I - o), i = Math.min(Math.floor(n * g.length), g.length - 1);
565
+ return g[Math.max(0, i)];
522
566
  },
523
- [c, z, f]
524
- ), P = X(
567
+ [o, I, g]
568
+ ), R = W(
525
569
  (e) => {
526
- if (!Z || !d)
570
+ if (!K || !d)
527
571
  return;
528
- const r = m.current?.getBoundingClientRect();
529
- r && O(
530
- (i) => i ? { ...i, x: e.clientX - r.left, y: e.clientY - r.top } : null
572
+ const n = u.current?.getBoundingClientRect();
573
+ n && _(
574
+ (i) => i ? { ...i, x: e.clientX - n.left, y: e.clientY - n.top } : null
531
575
  );
532
576
  },
533
- [Z, d]
534
- ), t = X(
535
- (e, r) => {
536
- const i = m.current?.getBoundingClientRect();
537
- i && Z && O({
538
- x: r.clientX - i.left,
539
- y: r.clientY - i.top,
577
+ [K, d]
578
+ ), t = W(
579
+ (e, n) => {
580
+ const i = u.current?.getBoundingClientRect();
581
+ i && K && _({
582
+ x: n.clientX - i.left,
583
+ y: n.clientY - i.top,
540
584
  content: `${e.name}: ${e.value.toLocaleString()}`
541
- }), Y?.(e);
585
+ }), X?.(e);
542
586
  },
543
- [Z, Y]
544
- ), w = X(() => {
545
- O(null), Y?.(null);
546
- }, [Y]), k = X(
587
+ [K, X]
588
+ ), M = W(() => {
589
+ _(null), X?.(null);
590
+ }, [X]), N = W(
547
591
  (e) => {
548
- if (!_)
592
+ if (!Z)
549
593
  return;
550
594
  e.preventDefault();
551
- const r = e.deltaY > 0 ? 0.9 : 1.1;
552
- l((i) => Math.min(Math.max(i * r, 0.5), 4));
595
+ const n = e.deltaY > 0 ? 0.9 : 1.1;
596
+ l((i) => Math.min(Math.max(i * n, 0.5), 4));
553
597
  },
554
- [_]
555
- ), G = X(
598
+ [Z]
599
+ ), J = W(
556
600
  (e) => {
557
- _ && ($.current = !0, y.current = { x: e.clientX - o.x, y: e.clientY - o.y });
601
+ Z && (C.current = !0, w.current = { x: e.clientX - r.x, y: e.clientY - r.y });
558
602
  },
559
- [_, o]
560
- ), b = X(() => {
561
- $.current = !1;
562
- }, []), W = X((e) => {
563
- $.current && g({
564
- x: e.clientX - y.current.x,
565
- y: e.clientY - y.current.y
603
+ [Z, r]
604
+ ), y = W(() => {
605
+ C.current = !1;
606
+ }, []), V = W((e) => {
607
+ C.current && v({
608
+ x: e.clientX - w.current.x,
609
+ y: e.clientY - w.current.y
566
610
  });
567
- }, []), a = ae(() => D.length > 0 ? D : [
611
+ }, []), D = ie(() => A.length > 0 ? A : [
568
612
  {
569
613
  id: "mazowieckie",
570
614
  name: "Mazowieckie",
@@ -578,71 +622,71 @@ const $e = [], Le = [], Ce = [], ge = [
578
622
  value: 70,
579
623
  path: "M300,200 L350,200 L360,260 L310,270 L280,230 Z"
580
624
  }
581
- ], [D]);
582
- return /* @__PURE__ */ u(
625
+ ], [A]);
626
+ return /* @__PURE__ */ m(
583
627
  "div",
584
628
  {
585
629
  className: `nice-map-chart ${T || ""}`,
586
- style: { width: x, ...C },
587
- "data-testid": v ?? q,
630
+ style: { width: b, ...S },
631
+ "data-testid": x ?? Q,
588
632
  ...h,
589
633
  children: [
590
- H && /* @__PURE__ */ n("div", { className: "nice-map-title", children: H }),
591
- /* @__PURE__ */ n(
634
+ G && /* @__PURE__ */ a("div", { className: "nice-map-title", children: G }),
635
+ /* @__PURE__ */ a(
592
636
  "svg",
593
637
  {
594
- ref: m,
595
- width: x,
596
- height: U,
597
- viewBox: B,
638
+ ref: u,
639
+ width: b,
640
+ height: H,
641
+ viewBox: Y,
598
642
  className: "nice-map-svg",
599
- onWheel: k,
600
- onMouseDown: G,
601
- onMouseUp: b,
602
- onMouseLeave: b,
643
+ onWheel: N,
644
+ onMouseDown: J,
645
+ onMouseUp: y,
646
+ onMouseLeave: y,
603
647
  onMouseMove: (e) => {
604
- P(e), W(e);
648
+ R(e), V(e);
605
649
  },
606
- children: /* @__PURE__ */ u("g", { transform: `translate(${o.x}, ${o.y}) scale(${I})`, children: [
607
- K && /* @__PURE__ */ n("g", { dangerouslySetInnerHTML: { __html: K } }),
608
- R === "choropleth" && a.map((e) => /* @__PURE__ */ n(
650
+ children: /* @__PURE__ */ m("g", { transform: `translate(${r.x}, ${r.y}) scale(${P})`, children: [
651
+ q && /* @__PURE__ */ a("g", { dangerouslySetInnerHTML: { __html: q } }),
652
+ E === "choropleth" && D.map((e) => /* @__PURE__ */ a(
609
653
  "path",
610
654
  {
611
655
  d: e.path,
612
- fill: e.color || N(e.value),
656
+ fill: e.color || L(e.value),
613
657
  stroke: "var(--nice-bg-primary, #ffffff)",
614
658
  strokeWidth: 1,
615
659
  className: "nice-map-region",
616
660
  onClick: () => j?.(e),
617
- onMouseEnter: (r) => t(e, r),
618
- onMouseLeave: w
661
+ onMouseEnter: (n) => t(e, n),
662
+ onMouseLeave: M
619
663
  },
620
664
  e.id
621
665
  )),
622
- (R === "bubble" || M.length > 0) && M.map((e) => {
623
- const r = Math.sqrt((e.value - c) / (z - c)) * 30 + 5;
624
- return /* @__PURE__ */ n(
666
+ (E === "bubble" || $.length > 0) && $.map((e) => {
667
+ const n = Math.sqrt((e.value - o) / (I - o)) * 30 + 5;
668
+ return /* @__PURE__ */ a(
625
669
  "circle",
626
670
  {
627
671
  cx: e.lng,
628
672
  cy: e.lat,
629
- r,
673
+ r: n,
630
674
  fill: e.color || "var(--nice-color-primary, #3b82f6)",
631
675
  fillOpacity: 0.7,
632
676
  stroke: "var(--nice-bg-primary, #ffffff)",
633
677
  strokeWidth: 1,
634
678
  className: "nice-map-bubble",
635
- onClick: () => ne?.(e),
679
+ onClick: () => ae?.(e),
636
680
  onMouseEnter: (i) => {
637
- const p = m.current?.getBoundingClientRect();
638
- p && Z && O({
639
- x: i.clientX - p.left,
640
- y: i.clientY - p.top,
681
+ const c = u.current?.getBoundingClientRect();
682
+ c && K && _({
683
+ x: i.clientX - c.left,
684
+ y: i.clientY - c.top,
641
685
  content: `${e.label || e.id}: ${e.value.toLocaleString()}`
642
686
  });
643
687
  },
644
- onMouseLeave: w,
645
- children: e.label && /* @__PURE__ */ u("title", { children: [
688
+ onMouseLeave: M,
689
+ children: e.label && /* @__PURE__ */ m("title", { children: [
646
690
  e.label,
647
691
  ": ",
648
692
  e.value
@@ -654,16 +698,16 @@ const $e = [], Le = [], Ce = [], ge = [
654
698
  ] })
655
699
  }
656
700
  ),
657
- d && /* @__PURE__ */ n("div", { className: "nice-map-tooltip", style: { left: d.x + 10, top: d.y - 30 }, children: d.content }),
658
- V && /* @__PURE__ */ u("div", { className: "nice-map-legend", children: [
659
- /* @__PURE__ */ n("span", { className: "nice-map-legend-title", children: S("charts.value", "Value") }),
660
- /* @__PURE__ */ n("div", { className: "nice-map-legend-scale", children: f.map((e, r) => /* @__PURE__ */ n("div", { className: "nice-map-legend-item", style: { backgroundColor: e } }, r)) }),
661
- /* @__PURE__ */ u("div", { className: "nice-map-legend-labels", children: [
662
- /* @__PURE__ */ n("span", { children: c.toLocaleString() }),
663
- /* @__PURE__ */ n("span", { children: z.toLocaleString() })
701
+ d && /* @__PURE__ */ a("div", { className: "nice-map-tooltip", style: { left: d.x + 10, top: d.y - 30 }, children: d.content }),
702
+ F && /* @__PURE__ */ m("div", { className: "nice-map-legend", children: [
703
+ /* @__PURE__ */ a("span", { className: "nice-map-legend-title", children: z("charts.value", "Value") }),
704
+ /* @__PURE__ */ a("div", { className: "nice-map-legend-scale", children: g.map((e, n) => /* @__PURE__ */ a("div", { className: "nice-map-legend-item", style: { backgroundColor: e } }, n)) }),
705
+ /* @__PURE__ */ m("div", { className: "nice-map-legend-labels", children: [
706
+ /* @__PURE__ */ a("span", { children: o.toLocaleString() }),
707
+ /* @__PURE__ */ a("span", { children: I.toLocaleString() })
664
708
  ] })
665
709
  ] }),
666
- /* @__PURE__ */ n("style", { children: `
710
+ /* @__PURE__ */ a("style", { children: `
667
711
  .nice-map-chart {
668
712
  font-family: system-ui, -apple-system, sans-serif;
669
713
  background: var(--nice-bg-primary, #ffffff);
@@ -763,166 +807,166 @@ const $e = [], Le = [], Ce = [], ge = [
763
807
  ]
764
808
  }
765
809
  );
766
- }, Re = ({
767
- nodes: R = $e,
768
- links: D = Le,
769
- width: M = 800,
770
- height: x = 500,
771
- nodeWidth: U = 20,
772
- nodePadding: B = 10,
773
- showValues: Q = !0,
774
- showTooltip: L = !0,
775
- onNodeClick: E,
776
- onLinkClick: te,
777
- title: Z,
778
- className: V,
810
+ }, Ye = ({
811
+ nodes: E = ze,
812
+ links: A = Ie,
813
+ width: $ = 800,
814
+ height: b = 500,
815
+ nodeWidth: H = 20,
816
+ nodePadding: Y = 10,
817
+ showValues: te = !0,
818
+ showTooltip: k = !0,
819
+ onNodeClick: O,
820
+ onLinkClick: ne,
821
+ title: K,
822
+ className: F,
779
823
  style: j,
780
- testId: ne,
781
- "data-testid": Y,
782
- ...H
824
+ testId: ae,
825
+ "data-testid": X,
826
+ ...G
783
827
  }) => {
784
- const [K, _] = J(null), T = ie(null), C = ae(() => {
785
- const v = /* @__PURE__ */ new Map();
786
- R.forEach((t) => v.set(t.id, t));
787
- const h = new Set(D.map((t) => t.target)), f = new Set(D.map((t) => t.source)), S = [], d = /* @__PURE__ */ new Map(), O = R.filter((t) => f.has(t.id) && !h.has(t.id));
788
- O.length > 0 && (S.push(O.map((t) => t.id)), O.forEach((t) => d.set(t.id, 0)));
789
- const I = R.filter((t) => f.has(t.id) && h.has(t.id));
790
- I.length > 0 && (S.push(I.map((t) => t.id)), I.forEach((t) => d.set(t.id, 1)));
791
- const l = R.filter((t) => !f.has(t.id) && h.has(t.id));
792
- l.length > 0 && (S.push(l.map((t) => t.id)), l.forEach((t) => d.set(t.id, 2))), S.length === 0 && (S.push(R.map((t) => t.id)), R.forEach((t) => d.set(t.id, 0)));
793
- const o = /* @__PURE__ */ new Map();
794
- D.forEach((t) => {
795
- o.set(t.source, (o.get(t.source) || 0) + t.value), o.set(t.target, (o.get(t.target) || 0) + t.value);
828
+ const [q, Z] = ee(null), T = oe(null), S = ie(() => {
829
+ const x = /* @__PURE__ */ new Map();
830
+ E.forEach((t) => x.set(t.id, t));
831
+ const h = new Set(A.map((t) => t.target)), g = new Set(A.map((t) => t.source)), z = [], d = /* @__PURE__ */ new Map(), _ = E.filter((t) => g.has(t.id) && !h.has(t.id));
832
+ _.length > 0 && (z.push(_.map((t) => t.id)), _.forEach((t) => d.set(t.id, 0)));
833
+ const P = E.filter((t) => g.has(t.id) && h.has(t.id));
834
+ P.length > 0 && (z.push(P.map((t) => t.id)), P.forEach((t) => d.set(t.id, 1)));
835
+ const l = E.filter((t) => !g.has(t.id) && h.has(t.id));
836
+ l.length > 0 && (z.push(l.map((t) => t.id)), l.forEach((t) => d.set(t.id, 2))), z.length === 0 && (z.push(E.map((t) => t.id)), E.forEach((t) => d.set(t.id, 0)));
837
+ const r = /* @__PURE__ */ new Map();
838
+ A.forEach((t) => {
839
+ r.set(t.source, (r.get(t.source) || 0) + t.value), r.set(t.target, (r.get(t.target) || 0) + t.value);
796
840
  });
797
- const g = 40, m = M - g * 2, $ = x - g * 2, y = S.length > 1 ? m / (S.length - 1) : m, c = /* @__PURE__ */ new Map();
798
- Math.max(...Array.from(o.values())), S.forEach((t, w) => {
799
- const k = t.reduce((W, a) => W + (o.get(a) || 0), 0), G = ($ - (t.length - 1) * B) / k;
800
- let b = g;
801
- t.forEach((W) => {
802
- const e = (o.get(W) || 0) * G, r = g + w * y;
803
- c.set(W, { x: r, y: b, height: e }), b += e + B;
841
+ const v = 40, u = $ - v * 2, C = b - v * 2, w = z.length > 1 ? u / (z.length - 1) : u, o = /* @__PURE__ */ new Map();
842
+ Math.max(...Array.from(r.values())), z.forEach((t, M) => {
843
+ const N = t.reduce((V, D) => V + (r.get(D) || 0), 0), J = (C - (t.length - 1) * Y) / N;
844
+ let y = v;
845
+ t.forEach((V) => {
846
+ const e = (r.get(V) || 0) * J, n = v + M * w;
847
+ o.set(V, { x: n, y, height: e }), y += e + Y;
804
848
  });
805
849
  });
806
- const z = [], N = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map();
807
- return D.forEach((t) => {
808
- const w = c.get(t.source), k = c.get(t.target);
809
- if (!w || !k)
850
+ const I = [], L = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
851
+ return A.forEach((t) => {
852
+ const M = o.get(t.source), N = o.get(t.target);
853
+ if (!M || !N)
810
854
  return;
811
- const G = o.get(t.source) || 1;
812
- o.get(t.target);
813
- const b = t.value / G * w.height, W = w.y + (N.get(t.source) || 0), a = k.y + (P.get(t.target) || 0);
814
- N.set(t.source, (N.get(t.source) || 0) + b), P.set(t.target, (P.get(t.target) || 0) + b);
815
- const e = w.x + U, r = k.x, i = (r - e) * 0.5, p = `
816
- M ${e} ${W}
817
- C ${e + i} ${W},
818
- ${r - i} ${a},
819
- ${r} ${a}
820
- L ${r} ${a + b}
821
- C ${r - i} ${a + b},
822
- ${e + i} ${W + b},
823
- ${e} ${W + b}
855
+ const J = r.get(t.source) || 1;
856
+ r.get(t.target);
857
+ const y = t.value / J * M.height, V = M.y + (L.get(t.source) || 0), D = N.y + (R.get(t.target) || 0);
858
+ L.set(t.source, (L.get(t.source) || 0) + y), R.set(t.target, (R.get(t.target) || 0) + y);
859
+ const e = M.x + H, n = N.x, i = (n - e) * 0.5, c = `
860
+ M ${e} ${V}
861
+ C ${e + i} ${V},
862
+ ${n - i} ${D},
863
+ ${n} ${D}
864
+ L ${n} ${D + y}
865
+ C ${n - i} ${D + y},
866
+ ${e + i} ${V + y},
867
+ ${e} ${V + y}
824
868
  Z
825
869
  `;
826
- z.push({
827
- path: p,
870
+ I.push({
871
+ path: c,
828
872
  link: t,
829
- sourcePos: w,
830
- targetPos: k
873
+ sourcePos: M,
874
+ targetPos: N
831
875
  });
832
- }), { nodePositions: c, linkPaths: z, nodeMap: v, nodeValues: o };
833
- }, [R, D, M, x, U, B]), q = X(
834
- (v, h) => {
835
- const f = T.current?.getBoundingClientRect();
836
- f && L && _({
837
- x: h.clientX - f.left,
838
- y: h.clientY - f.top,
839
- content: v
876
+ }), { nodePositions: o, linkPaths: I, nodeMap: x, nodeValues: r };
877
+ }, [E, A, $, b, H, Y]), Q = W(
878
+ (x, h) => {
879
+ const g = T.current?.getBoundingClientRect();
880
+ g && k && Z({
881
+ x: h.clientX - g.left,
882
+ y: h.clientY - g.top,
883
+ content: x
840
884
  });
841
885
  },
842
- [L]
886
+ [k]
843
887
  );
844
- return /* @__PURE__ */ u(
888
+ return /* @__PURE__ */ m(
845
889
  "div",
846
890
  {
847
- className: `nice-sankey-chart ${V || ""}`,
848
- style: { width: M, ...j },
849
- "data-testid": Y ?? ne,
850
- ...H,
891
+ className: `nice-sankey-chart ${F || ""}`,
892
+ style: { width: $, ...j },
893
+ "data-testid": X ?? ae,
894
+ ...G,
851
895
  children: [
852
- Z && /* @__PURE__ */ n("div", { className: "nice-sankey-title", children: Z }),
853
- /* @__PURE__ */ u("svg", { ref: T, width: M, height: x, className: "nice-sankey-svg", children: [
854
- /* @__PURE__ */ n("defs", { children: C.linkPaths.map((v, h) => /* @__PURE__ */ u("linearGradient", { id: `sankey-gradient-${h}`, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [
855
- /* @__PURE__ */ n(
896
+ K && /* @__PURE__ */ a("div", { className: "nice-sankey-title", children: K }),
897
+ /* @__PURE__ */ m("svg", { ref: T, width: $, height: b, className: "nice-sankey-svg", children: [
898
+ /* @__PURE__ */ a("defs", { children: S.linkPaths.map((x, h) => /* @__PURE__ */ m("linearGradient", { id: `sankey-gradient-${h}`, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [
899
+ /* @__PURE__ */ a(
856
900
  "stop",
857
901
  {
858
902
  offset: "0%",
859
- stopColor: C.nodeMap.get(v.link.source)?.color || "var(--nice-color-primary, #3b82f6)"
903
+ stopColor: S.nodeMap.get(x.link.source)?.color || "var(--nice-color-primary, #3b82f6)"
860
904
  }
861
905
  ),
862
- /* @__PURE__ */ n(
906
+ /* @__PURE__ */ a(
863
907
  "stop",
864
908
  {
865
909
  offset: "100%",
866
- stopColor: C.nodeMap.get(v.link.target)?.color || "var(--nice-color-error, #ef4444)"
910
+ stopColor: S.nodeMap.get(x.link.target)?.color || "var(--nice-color-error, #ef4444)"
867
911
  }
868
912
  )
869
913
  ] }, h)) }),
870
- /* @__PURE__ */ n("g", { className: "nice-sankey-links", children: C.linkPaths.map((v, h) => /* @__PURE__ */ n(
914
+ /* @__PURE__ */ a("g", { className: "nice-sankey-links", children: S.linkPaths.map((x, h) => /* @__PURE__ */ a(
871
915
  "path",
872
916
  {
873
- d: v.path,
874
- fill: v.link.color || `url(#sankey-gradient-${h})`,
917
+ d: x.path,
918
+ fill: x.link.color || `url(#sankey-gradient-${h})`,
875
919
  fillOpacity: 0.4,
876
920
  className: "nice-sankey-link",
877
- onClick: () => te?.(v.link),
878
- onMouseEnter: (f) => q(
879
- `${C.nodeMap.get(v.link.source)?.name} → ${C.nodeMap.get(v.link.target)?.name}: ${v.link.value.toLocaleString()}`,
880
- f
921
+ onClick: () => ne?.(x.link),
922
+ onMouseEnter: (g) => Q(
923
+ `${S.nodeMap.get(x.link.source)?.name} → ${S.nodeMap.get(x.link.target)?.name}: ${x.link.value.toLocaleString()}`,
924
+ g
881
925
  ),
882
- onMouseLeave: () => _(null)
926
+ onMouseLeave: () => Z(null)
883
927
  },
884
928
  h
885
929
  )) }),
886
- /* @__PURE__ */ n("g", { className: "nice-sankey-nodes", children: Array.from(C.nodePositions.entries()).map(([v, h]) => {
887
- const f = C.nodeMap.get(v);
888
- return f ? /* @__PURE__ */ u("g", { children: [
889
- /* @__PURE__ */ n(
930
+ /* @__PURE__ */ a("g", { className: "nice-sankey-nodes", children: Array.from(S.nodePositions.entries()).map(([x, h]) => {
931
+ const g = S.nodeMap.get(x);
932
+ return g ? /* @__PURE__ */ m("g", { children: [
933
+ /* @__PURE__ */ a(
890
934
  "rect",
891
935
  {
892
936
  x: h.x,
893
937
  y: h.y,
894
- width: U,
938
+ width: H,
895
939
  height: h.height,
896
- fill: f.color || "var(--nice-color-primary, #3b82f6)",
940
+ fill: g.color || "var(--nice-color-primary, #3b82f6)",
897
941
  rx: 2,
898
942
  className: "nice-sankey-node",
899
- onClick: () => E?.(f),
900
- onMouseEnter: (S) => q(
901
- `${f.label ?? f.name ?? f.id}: ${C.nodeValues.get(v)?.toLocaleString() || 0}`,
902
- S
943
+ onClick: () => O?.(g),
944
+ onMouseEnter: (z) => Q(
945
+ `${g.label ?? g.name ?? g.id}: ${S.nodeValues.get(x)?.toLocaleString() || 0}`,
946
+ z
903
947
  ),
904
- onMouseLeave: () => _(null)
948
+ onMouseLeave: () => Z(null)
905
949
  }
906
950
  ),
907
- /* @__PURE__ */ u(
951
+ /* @__PURE__ */ m(
908
952
  "text",
909
953
  {
910
- x: h.x + U + 6,
954
+ x: h.x + H + 6,
911
955
  y: h.y + h.height / 2,
912
956
  dominantBaseline: "middle",
913
957
  fontSize: "12",
914
958
  fill: "var(--nice-text-primary, #0f172a)",
915
959
  children: [
916
- f.label ?? f.name ?? f.id,
917
- Q && ` (${C.nodeValues.get(v)?.toLocaleString() || 0})`
960
+ g.label ?? g.name ?? g.id,
961
+ te && ` (${S.nodeValues.get(x)?.toLocaleString() || 0})`
918
962
  ]
919
963
  }
920
964
  )
921
- ] }, v) : null;
965
+ ] }, x) : null;
922
966
  }) })
923
967
  ] }),
924
- K && /* @__PURE__ */ n("div", { className: "nice-sankey-tooltip", style: { left: K.x + 10, top: K.y - 30 }, children: K.content }),
925
- /* @__PURE__ */ n("style", { children: `
968
+ q && /* @__PURE__ */ a("div", { className: "nice-sankey-tooltip", style: { left: q.x + 10, top: q.y - 30 }, children: q.content }),
969
+ /* @__PURE__ */ a("style", { children: `
926
970
  .nice-sankey-chart {
927
971
  font-family: system-ui, -apple-system, sans-serif;
928
972
  background: var(--nice-bg-primary, #ffffff);
@@ -973,172 +1017,172 @@ const $e = [], Le = [], Ce = [], ge = [
973
1017
  ]
974
1018
  }
975
1019
  );
976
- }, Ee = /* @__PURE__ */ Object.assign(
977
- /* @__PURE__ */ ue((R, D) => {
978
- const { t: M } = oe(), {
979
- initialData: x,
980
- data: U,
981
- maxPoints: B = 60,
982
- updateInterval: Q = 1e3,
983
- fetchData: L,
984
- width: E = 600,
985
- height: te = 200,
986
- chartType: Z = "line",
987
- color: V = "var(--nice-color-primary, #3b82f6)",
1020
+ }, Oe = /* @__PURE__ */ Object.assign(
1021
+ /* @__PURE__ */ ve((E, A) => {
1022
+ const { t: $ } = ce(), {
1023
+ initialData: b,
1024
+ data: H,
1025
+ maxPoints: Y = 60,
1026
+ updateInterval: te = 1e3,
1027
+ fetchData: k,
1028
+ width: O = 600,
1029
+ height: ne = 200,
1030
+ chartType: K = "line",
1031
+ color: F = "var(--nice-color-primary, #3b82f6)",
988
1032
  showGrid: j = !0,
989
- showTimeAxis: ne = !0,
990
- showCurrentValue: Y = !0,
991
- title: H,
992
- valueFormatter: K = (s) => s.toFixed(2),
993
- timeFormatter: _ = (s) => new Date(s).toLocaleTimeString(),
1033
+ showTimeAxis: ae = !0,
1034
+ showCurrentValue: X = !0,
1035
+ title: G,
1036
+ valueFormatter: q = (s) => s.toFixed(2),
1037
+ timeFormatter: Z = (s) => new Date(s).toLocaleTimeString(),
994
1038
  onDataUpdate: T,
995
- paused: C,
996
- className: q,
997
- style: v,
1039
+ paused: S,
1040
+ className: Q,
1041
+ style: x,
998
1042
  testId: h,
999
- "data-testid": f,
1000
- ...S
1001
- } = R, [d, O] = J(x ?? U ?? []), [I, l] = J(C || !1), o = ie(void 0);
1002
- he(() => {
1003
- C !== void 0 && l(C);
1004
- }, [C]), he(() => {
1005
- if (I || !L)
1043
+ "data-testid": g,
1044
+ ...z
1045
+ } = E, [d, _] = ee(b ?? H ?? []), [P, l] = ee(S || !1), r = oe(void 0);
1046
+ fe(() => {
1047
+ S !== void 0 && l(S);
1048
+ }, [S]), fe(() => {
1049
+ if (P || !k)
1006
1050
  return;
1007
1051
  const s = async () => {
1008
1052
  try {
1009
- const A = await L();
1010
- O((ee) => {
1011
- const re = [...ee, A].slice(-B);
1012
- return T?.(re), re;
1053
+ const B = await k();
1054
+ _((U) => {
1055
+ const f = [...U, B].slice(-Y);
1056
+ return T?.(f), f;
1013
1057
  });
1014
- } catch (A) {
1015
- console.error("Failed to fetch realtime data:", A);
1058
+ } catch (B) {
1059
+ console.error("Failed to fetch realtime data:", B);
1016
1060
  }
1017
1061
  };
1018
- return o.current = setInterval(s, Q), () => {
1019
- o.current && clearInterval(o.current);
1062
+ return r.current = setInterval(s, te), () => {
1063
+ r.current && clearInterval(r.current);
1020
1064
  };
1021
- }, [I, L, Q, B, T]);
1022
- const g = X(
1065
+ }, [P, k, te, Y, T]);
1066
+ const v = W(
1023
1067
  (s) => {
1024
- O((A) => {
1025
- const ee = [...A, s].slice(-B);
1026
- return T?.(ee), ee;
1068
+ _((B) => {
1069
+ const U = [...B, s].slice(-Y);
1070
+ return T?.(U), U;
1027
1071
  });
1028
1072
  },
1029
- [B, T]
1030
- ), m = X(() => {
1031
- O([]), T?.([]);
1032
- }, [T]), $ = X(() => l(!0), []), y = X(() => l(!1), []);
1033
- fe(
1034
- D,
1073
+ [Y, T]
1074
+ ), u = W(() => {
1075
+ _([]), T?.([]);
1076
+ }, [T]), C = W(() => l(!0), []), w = W(() => l(!1), []);
1077
+ xe(
1078
+ A,
1035
1079
  () => ({
1036
- addDataPoint: g,
1037
- clearData: m,
1038
- pause: $,
1039
- resume: y,
1080
+ addDataPoint: v,
1081
+ clearData: u,
1082
+ pause: C,
1083
+ resume: w,
1040
1084
  getData: () => d
1041
1085
  }),
1042
- [g, m, $, y, d]
1086
+ [v, u, C, w, d]
1043
1087
  );
1044
- const c = { top: 20, right: 60, bottom: ne ? 40 : 20, left: 50 }, z = E - c.left - c.right, N = te - c.top - c.bottom, P = d.map((s) => s.value), t = P.length ? Math.min(...P) : 0, w = P.length ? Math.max(...P) : 100, G = (w - t || 1) * 0.1, b = t - G, a = w + G - b, e = (s) => {
1045
- const A = L ? B - 1 : Math.max(1, d.length - 1);
1046
- return c.left + s / A * z;
1047
- }, r = (s) => c.top + N - (s - b) / a * N, i = d.map((s, A) => `${e(A)},${r(s.value)}`).join(" "), p = d.length > 0 ? `M ${e(0)},${c.top + N} L ${i} L ${e(d.length - 1)},${c.top + N} Z` : "", F = d.length > 0 ? d[d.length - 1].value : null;
1048
- return /* @__PURE__ */ u(
1088
+ const o = { top: 20, right: 60, bottom: ae ? 40 : 20, left: 50 }, I = O - o.left - o.right, L = ne - o.top - o.bottom, R = d.map((s) => s.value), t = R.length ? Math.min(...R) : 0, M = R.length ? Math.max(...R) : 100, J = (M - t || 1) * 0.1, y = t - J, D = M + J - y, e = (s) => {
1089
+ const B = k ? Y - 1 : Math.max(1, d.length - 1);
1090
+ return o.left + s / B * I;
1091
+ }, n = (s) => o.top + L - (s - y) / D * L, i = d.map((s, B) => `${e(B)},${n(s.value)}`).join(" "), c = d.length > 0 ? `M ${e(0)},${o.top + L} L ${i} L ${e(d.length - 1)},${o.top + L} Z` : "", p = d.length > 0 ? d[d.length - 1].value : null;
1092
+ return /* @__PURE__ */ m(
1049
1093
  "div",
1050
1094
  {
1051
- className: `nice-realtime-chart ${q || ""}`,
1052
- style: { width: E, ...v },
1053
- "data-testid": f ?? h,
1054
- ...S,
1095
+ className: `nice-realtime-chart ${Q || ""}`,
1096
+ style: { width: O, ...x },
1097
+ "data-testid": g ?? h,
1098
+ ...z,
1055
1099
  children: [
1056
- /* @__PURE__ */ u("div", { className: "nice-realtime-header", children: [
1057
- /* @__PURE__ */ n("span", { className: "nice-realtime-title", children: H }),
1058
- /* @__PURE__ */ u("div", { className: "nice-realtime-controls", children: [
1059
- /* @__PURE__ */ u("span", { className: `nice-realtime-status ${I ? "paused" : "live"}`, children: [
1060
- /* @__PURE__ */ n("span", { className: "nice-realtime-status-dot" }),
1061
- /* @__PURE__ */ n("span", { children: I ? M("charts.paused", "Paused") : M("charts.live", "Live") })
1100
+ /* @__PURE__ */ m("div", { className: "nice-realtime-header", children: [
1101
+ /* @__PURE__ */ a("span", { className: "nice-realtime-title", children: G }),
1102
+ /* @__PURE__ */ m("div", { className: "nice-realtime-controls", children: [
1103
+ /* @__PURE__ */ m("span", { className: `nice-realtime-status ${P ? "paused" : "live"}`, children: [
1104
+ /* @__PURE__ */ a("span", { className: "nice-realtime-status-dot" }),
1105
+ /* @__PURE__ */ a("span", { children: P ? $("charts.paused", "Paused") : $("charts.live", "Live") })
1062
1106
  ] }),
1063
- /* @__PURE__ */ n(
1107
+ /* @__PURE__ */ a(
1064
1108
  "button",
1065
1109
  {
1066
- className: `nice-realtime-btn ${I ? "paused" : ""}`,
1067
- onClick: () => l(!I),
1068
- "aria-label": I ? M("charts.resume", "Resume") : M("charts.pause", "Pause"),
1069
- children: /* @__PURE__ */ n(ce, { name: I ? "play" : "pause", size: 14 })
1110
+ className: `nice-realtime-btn ${P ? "paused" : ""}`,
1111
+ onClick: () => l(!P),
1112
+ "aria-label": P ? $("charts.resume", "Resume") : $("charts.pause", "Pause"),
1113
+ children: /* @__PURE__ */ a(de, { name: P ? "play" : "pause", size: 14 })
1070
1114
  }
1071
1115
  ),
1072
- Y && F !== null && /* @__PURE__ */ n("span", { className: "nice-realtime-value", children: K(F) })
1116
+ X && p !== null && /* @__PURE__ */ a("span", { className: "nice-realtime-value", children: q(p) })
1073
1117
  ] })
1074
1118
  ] }),
1075
- /* @__PURE__ */ u("svg", { width: E, height: te, className: "nice-realtime-svg", children: [
1076
- j && /* @__PURE__ */ n("g", { className: "nice-realtime-grid", children: [0, 0.25, 0.5, 0.75, 1].map((s, A) => {
1077
- const ee = c.top + N * (1 - s), re = b + a * s;
1078
- return /* @__PURE__ */ u("g", { children: [
1079
- /* @__PURE__ */ n(
1119
+ /* @__PURE__ */ m("svg", { width: O, height: ne, className: "nice-realtime-svg", children: [
1120
+ j && /* @__PURE__ */ a("g", { className: "nice-realtime-grid", children: [0, 0.25, 0.5, 0.75, 1].map((s, B) => {
1121
+ const U = o.top + L * (1 - s), f = y + D * s;
1122
+ return /* @__PURE__ */ m("g", { children: [
1123
+ /* @__PURE__ */ a(
1080
1124
  "line",
1081
1125
  {
1082
- x1: c.left,
1083
- y1: ee,
1084
- x2: E - c.right,
1085
- y2: ee,
1126
+ x1: o.left,
1127
+ y1: U,
1128
+ x2: O - o.right,
1129
+ y2: U,
1086
1130
  stroke: "var(--nice-border-color, #e5e7eb)",
1087
1131
  strokeDasharray: s === 0 ? void 0 : "3"
1088
1132
  }
1089
1133
  ),
1090
- /* @__PURE__ */ n(
1134
+ /* @__PURE__ */ a(
1091
1135
  "text",
1092
1136
  {
1093
- x: c.left - 8,
1094
- y: ee,
1137
+ x: o.left - 8,
1138
+ y: U,
1095
1139
  textAnchor: "end",
1096
1140
  dominantBaseline: "middle",
1097
1141
  fontSize: "10",
1098
1142
  fill: "var(--nice-text-secondary, #6b7280)",
1099
- children: Math.round(re).toLocaleString()
1143
+ children: Math.round(f).toLocaleString()
1100
1144
  }
1101
1145
  )
1102
- ] }, A);
1146
+ ] }, B);
1103
1147
  }) }),
1104
- Z === "area" && d.length > 0 && /* @__PURE__ */ n("path", { d: p, fill: V, fillOpacity: 0.2 }),
1105
- d.length > 1 && /* @__PURE__ */ n(
1148
+ K === "area" && d.length > 0 && /* @__PURE__ */ a("path", { d: c, fill: F, fillOpacity: 0.2 }),
1149
+ d.length > 1 && /* @__PURE__ */ a(
1106
1150
  "polyline",
1107
1151
  {
1108
1152
  points: i,
1109
1153
  fill: "none",
1110
- stroke: V,
1154
+ stroke: F,
1111
1155
  strokeWidth: 2,
1112
1156
  strokeLinecap: "round",
1113
1157
  strokeLinejoin: "round"
1114
1158
  }
1115
1159
  ),
1116
- d.length > 0 && /* @__PURE__ */ n(
1160
+ d.length > 0 && /* @__PURE__ */ a(
1117
1161
  "circle",
1118
1162
  {
1119
1163
  cx: e(d.length - 1),
1120
- cy: r(d[d.length - 1].value),
1164
+ cy: n(d[d.length - 1].value),
1121
1165
  r: 3,
1122
- fill: V,
1166
+ fill: F,
1123
1167
  className: "nice-realtime-point"
1124
1168
  }
1125
1169
  ),
1126
- ne && d.length > 0 && /* @__PURE__ */ n("g", { className: "nice-realtime-time-axis", children: Array.from(
1170
+ ae && d.length > 0 && /* @__PURE__ */ a("g", { className: "nice-realtime-time-axis", children: Array.from(
1127
1171
  new Set([0, Math.floor(d.length / 2), d.length - 1].filter((s) => d[s]))
1128
- ).map((s) => /* @__PURE__ */ n(
1172
+ ).map((s) => /* @__PURE__ */ a(
1129
1173
  "text",
1130
1174
  {
1131
1175
  x: e(s),
1132
- y: te - 8,
1176
+ y: ne - 8,
1133
1177
  textAnchor: "middle",
1134
1178
  fontSize: "10",
1135
1179
  fill: "var(--nice-text-secondary, #6b7280)",
1136
- children: _(d[s].timestamp)
1180
+ children: Z(d[s].timestamp)
1137
1181
  },
1138
1182
  `tx-${s}`
1139
1183
  )) })
1140
1184
  ] }),
1141
- /* @__PURE__ */ n("style", { children: `
1185
+ /* @__PURE__ */ a("style", { children: `
1142
1186
  .nice-realtime-chart {
1143
1187
  font-family: inherit;
1144
1188
  color: var(--nice-text-primary, #111827);
@@ -1180,7 +1224,7 @@ const $e = [], Le = [], Ce = [], ge = [
1180
1224
  .nice-realtime-value {
1181
1225
  font-size: 18px;
1182
1226
  font-weight: 600;
1183
- color: ${V};
1227
+ color: ${F};
1184
1228
  font-variant-numeric: tabular-nums;
1185
1229
  }
1186
1230
 
@@ -1223,178 +1267,178 @@ const $e = [], Le = [], Ce = [], ge = [
1223
1267
  );
1224
1268
  }),
1225
1269
  { displayName: "NiceRealtimeChart" }
1226
- ), Te = ({
1227
- data: R,
1228
- width: D = 600,
1229
- height: M = 400,
1230
- showLabels: x = !0,
1231
- showValues: U = !0,
1232
- onNodeClick: B,
1233
- drilldownEnabled: Q = !0,
1234
- colors: L = ge,
1235
- tilePadding: E = 2,
1236
- className: te,
1237
- style: Z,
1238
- testId: V,
1270
+ ), Xe = ({
1271
+ data: E,
1272
+ width: A = 600,
1273
+ height: $ = 400,
1274
+ showLabels: b = !0,
1275
+ showValues: H = !0,
1276
+ onNodeClick: Y,
1277
+ drilldownEnabled: te = !0,
1278
+ colors: k = ye,
1279
+ tilePadding: O = 2,
1280
+ className: ne,
1281
+ style: K,
1282
+ testId: F,
1239
1283
  "data-testid": j,
1240
- ...ne
1284
+ ...ae
1241
1285
  }) => {
1242
- const { t: Y } = oe(), H = ae(() => Array.isArray(R) ? {
1286
+ const { t: X } = ce(), G = ie(() => Array.isArray(E) ? {
1243
1287
  id: "root",
1244
1288
  name: "Root",
1245
- value: R.reduce((l, o) => l + (o.value || 0), 0),
1246
- children: R.map((l, o) => ({
1247
- id: `${o}`,
1248
- name: l.label ?? l.name ?? `Item ${o + 1}`,
1289
+ value: E.reduce((l, r) => l + (r.value || 0), 0),
1290
+ children: E.map((l, r) => ({
1291
+ id: `${r}`,
1292
+ name: l.label ?? l.name ?? `Item ${r + 1}`,
1249
1293
  value: l.value,
1250
1294
  color: l.color
1251
1295
  }))
1252
- } : R, [R]), [K, _] = J(H), [T, C] = J([H.name]), [q, v] = J(null), h = ie(null), f = ae(() => {
1253
- const o = K.children || [];
1254
- if (o.length === 0)
1296
+ } : E, [E]), [q, Z] = ee(G), [T, S] = ee([G.name]), [Q, x] = ee(null), h = oe(null), g = ie(() => {
1297
+ const r = q.children || [];
1298
+ if (r.length === 0)
1255
1299
  return [];
1256
- const g = o.reduce((t, w) => t + w.value, 0), m = o.map((t) => ({
1300
+ const v = r.reduce((t, M) => t + M.value, 0), u = r.map((t) => ({
1257
1301
  node: t,
1258
- area: t.value / g * D * M
1302
+ area: t.value / v * A * $
1259
1303
  }));
1260
- m.sort((t, w) => w.area - t.area);
1261
- const $ = [];
1262
- let y = 0, c = 0, z = D, N = M, P = 0;
1263
- for (; P < m.length; ) {
1264
- const t = z < N;
1265
- let w = 0, k = [];
1266
- const G = t ? N : z;
1267
- for (let a = P; a < m.length; a++) {
1268
- const e = [...k, m[a]], r = e.reduce((p, F) => p + F.area, 0), i = S(e, r, G);
1269
- if (k.length === 0)
1270
- k = e, w = r;
1304
+ u.sort((t, M) => M.area - t.area);
1305
+ const C = [];
1306
+ let w = 0, o = 0, I = A, L = $, R = 0;
1307
+ for (; R < u.length; ) {
1308
+ const t = I < L;
1309
+ let M = 0, N = [];
1310
+ const J = t ? L : I;
1311
+ for (let D = R; D < u.length; D++) {
1312
+ const e = [...N, u[D]], n = e.reduce((c, p) => c + p.area, 0), i = z(e, n, J);
1313
+ if (N.length === 0)
1314
+ N = e, M = n;
1271
1315
  else {
1272
- const p = S(k, w, G);
1273
- if (i <= p)
1274
- k = e, w = r;
1316
+ const c = z(N, M, J);
1317
+ if (i <= c)
1318
+ N = e, M = n;
1275
1319
  else
1276
1320
  break;
1277
1321
  }
1278
1322
  }
1279
- const b = w / G;
1280
- let W = 0;
1281
- k.forEach((a, e) => {
1282
- const r = a.area / b;
1283
- $.push({
1284
- node: a.node,
1285
- x: t ? y : y + W,
1286
- y: t ? c + W : c,
1287
- w: t ? b : r,
1288
- h: t ? r : b,
1289
- color: a.node.color || L[(P + e) % L.length]
1290
- }), W += r;
1291
- }), t ? (y += b, z -= b) : (c += b, N -= b), P += k.length;
1323
+ const y = M / J;
1324
+ let V = 0;
1325
+ N.forEach((D, e) => {
1326
+ const n = D.area / y;
1327
+ C.push({
1328
+ node: D.node,
1329
+ x: t ? w : w + V,
1330
+ y: t ? o + V : o,
1331
+ w: t ? y : n,
1332
+ h: t ? n : y,
1333
+ color: D.node.color || k[(R + e) % k.length]
1334
+ }), V += n;
1335
+ }), t ? (w += y, I -= y) : (o += y, L -= y), R += N.length;
1292
1336
  }
1293
- return $;
1294
- }, [K, D, M, L]);
1295
- function S(l, o, g) {
1296
- const m = o / g;
1297
- let $ = 0;
1298
- for (const y of l) {
1299
- const c = y.area / m, z = Math.max(m / c, c / m);
1300
- $ = Math.max($, z);
1337
+ return C;
1338
+ }, [q, A, $, k]);
1339
+ function z(l, r, v) {
1340
+ const u = r / v;
1341
+ let C = 0;
1342
+ for (const w of l) {
1343
+ const o = w.area / u, I = Math.max(u / o, o / u);
1344
+ C = Math.max(C, I);
1301
1345
  }
1302
- return $;
1346
+ return C;
1303
1347
  }
1304
1348
  const d = (l) => {
1305
- B?.(l, [...T, l.name]), Q && l.children && l.children.length > 0 && (_(l), C((o) => [...o, l.name]));
1306
- }, O = () => {
1349
+ Y?.(l, [...T, l.name]), te && l.children && l.children.length > 0 && (Z(l), S((r) => [...r, l.name]));
1350
+ }, _ = () => {
1307
1351
  if (T.length <= 1)
1308
1352
  return;
1309
- let l = H;
1310
- const o = T.slice(0, -1);
1311
- for (let g = 1; g < o.length; g++) {
1312
- const m = l.children?.find(($) => $.name === o[g]);
1313
- m && (l = m);
1353
+ let l = G;
1354
+ const r = T.slice(0, -1);
1355
+ for (let v = 1; v < r.length; v++) {
1356
+ const u = l.children?.find((C) => C.name === r[v]);
1357
+ u && (l = u);
1314
1358
  }
1315
- _(l), C(o);
1316
- }, I = (l, o) => {
1317
- const g = h.current?.getBoundingClientRect();
1318
- g && v({
1319
- x: o.clientX - g.left,
1320
- y: o.clientY - g.top,
1359
+ Z(l), S(r);
1360
+ }, P = (l, r) => {
1361
+ const v = h.current?.getBoundingClientRect();
1362
+ v && x({
1363
+ x: r.clientX - v.left,
1364
+ y: r.clientY - v.top,
1321
1365
  content: l
1322
1366
  });
1323
1367
  };
1324
- return /* @__PURE__ */ u(
1368
+ return /* @__PURE__ */ m(
1325
1369
  "div",
1326
1370
  {
1327
- className: `nice-treemap-chart ${te || ""}`,
1328
- style: { width: D, ...Z },
1329
- "data-testid": j ?? V,
1330
- ...ne,
1371
+ className: `nice-treemap-chart ${ne || ""}`,
1372
+ style: { width: A, ...K },
1373
+ "data-testid": j ?? F,
1374
+ ...ae,
1331
1375
  children: [
1332
- /* @__PURE__ */ u("div", { className: "nice-treemap-nav", children: [
1333
- T.length > 1 && /* @__PURE__ */ u("button", { className: "nice-treemap-back", onClick: O, children: [
1334
- /* @__PURE__ */ n(ce, { name: "arrow-left", size: 14 }),
1376
+ /* @__PURE__ */ m("div", { className: "nice-treemap-nav", children: [
1377
+ T.length > 1 && /* @__PURE__ */ m("button", { className: "nice-treemap-back", onClick: _, children: [
1378
+ /* @__PURE__ */ a(de, { name: "arrow-left", size: 14 }),
1335
1379
  " ",
1336
- Y("charts.back", "Back")
1380
+ X("charts.back", "Back")
1337
1381
  ] }),
1338
- /* @__PURE__ */ n("div", { className: "nice-treemap-breadcrumbs", children: T.map((l, o) => /* @__PURE__ */ u(me.Fragment, { children: [
1339
- o > 0 && /* @__PURE__ */ n("span", { className: "nice-treemap-sep", children: "/" }),
1340
- /* @__PURE__ */ n("span", { className: o === T.length - 1 ? "current" : "", children: l })
1341
- ] }, o)) })
1382
+ /* @__PURE__ */ a("div", { className: "nice-treemap-breadcrumbs", children: T.map((l, r) => /* @__PURE__ */ m(ge.Fragment, { children: [
1383
+ r > 0 && /* @__PURE__ */ a("span", { className: "nice-treemap-sep", children: "/" }),
1384
+ /* @__PURE__ */ a("span", { className: r === T.length - 1 ? "current" : "", children: l })
1385
+ ] }, r)) })
1342
1386
  ] }),
1343
- /* @__PURE__ */ n("svg", { ref: h, width: D, height: M, className: "nice-treemap-svg", children: f.map((l, o) => {
1344
- const { node: g, x: m, y: $, w: y, h: c, color: z } = l, N = Math.min(14, Math.max(10, Math.min(y, c) / 6)), P = y > 40 && c > 30;
1345
- return /* @__PURE__ */ u(
1387
+ /* @__PURE__ */ a("svg", { ref: h, width: A, height: $, className: "nice-treemap-svg", children: g.map((l, r) => {
1388
+ const { node: v, x: u, y: C, w, h: o, color: I } = l, L = Math.min(14, Math.max(10, Math.min(w, o) / 6)), R = w > 40 && o > 30;
1389
+ return /* @__PURE__ */ m(
1346
1390
  "g",
1347
1391
  {
1348
- onClick: () => d(g),
1349
- onMouseEnter: (t) => I(`${g.name}: ${g.value.toLocaleString()}`, t),
1350
- onMouseLeave: () => v(null),
1392
+ onClick: () => d(v),
1393
+ onMouseEnter: (t) => P(`${v.name}: ${v.value.toLocaleString()}`, t),
1394
+ onMouseLeave: () => x(null),
1351
1395
  children: [
1352
- /* @__PURE__ */ n(
1396
+ /* @__PURE__ */ a(
1353
1397
  "rect",
1354
1398
  {
1355
- x: m + E / 2,
1356
- y: $ + E / 2,
1357
- width: Math.max(0, y - E),
1358
- height: Math.max(0, c - E),
1359
- fill: z,
1399
+ x: u + O / 2,
1400
+ y: C + O / 2,
1401
+ width: Math.max(0, w - O),
1402
+ height: Math.max(0, o - O),
1403
+ fill: I,
1360
1404
  rx: 4,
1361
1405
  className: "nice-treemap-tile"
1362
1406
  }
1363
1407
  ),
1364
- x && P && /* @__PURE__ */ n(
1408
+ b && R && /* @__PURE__ */ a(
1365
1409
  "text",
1366
1410
  {
1367
- x: m + y / 2,
1368
- y: $ + c / 2 - (U ? 6 : 0),
1411
+ x: u + w / 2,
1412
+ y: C + o / 2 - (H ? 6 : 0),
1369
1413
  textAnchor: "middle",
1370
1414
  dominantBaseline: "middle",
1371
- fontSize: N,
1415
+ fontSize: L,
1372
1416
  fill: "white",
1373
1417
  fontWeight: "500",
1374
1418
  style: { pointerEvents: "none" },
1375
- children: g.name.length > y / N + 2 ? g.name.slice(0, Math.floor(y / N)) + "..." : g.name
1419
+ children: v.name.length > w / L + 2 ? v.name.slice(0, Math.floor(w / L)) + "..." : v.name
1376
1420
  }
1377
1421
  ),
1378
- U && P && /* @__PURE__ */ n(
1422
+ H && R && /* @__PURE__ */ a(
1379
1423
  "text",
1380
1424
  {
1381
- x: m + y / 2,
1382
- y: $ + c / 2 + 10,
1425
+ x: u + w / 2,
1426
+ y: C + o / 2 + 10,
1383
1427
  textAnchor: "middle",
1384
1428
  dominantBaseline: "middle",
1385
- fontSize: N - 2,
1429
+ fontSize: L - 2,
1386
1430
  fill: "var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",
1387
1431
  style: { pointerEvents: "none" },
1388
- children: g.value.toLocaleString()
1432
+ children: v.value.toLocaleString()
1389
1433
  }
1390
1434
  )
1391
1435
  ]
1392
1436
  },
1393
- o
1437
+ r
1394
1438
  );
1395
1439
  }) }),
1396
- q && /* @__PURE__ */ n("div", { className: "nice-treemap-tooltip", style: { left: q.x + 10, top: q.y - 30 }, children: q.content }),
1397
- /* @__PURE__ */ n("style", { children: `
1440
+ Q && /* @__PURE__ */ a("div", { className: "nice-treemap-tooltip", style: { left: Q.x + 10, top: Q.y - 30 }, children: Q.content }),
1441
+ /* @__PURE__ */ a("style", { children: `
1398
1442
  .nice-treemap-chart {
1399
1443
  font-family: system-ui, -apple-system, sans-serif;
1400
1444
  background: var(--nice-bg-primary, #ffffff);
@@ -1469,9 +1513,9 @@ const $e = [], Le = [], Ce = [], ge = [
1469
1513
  );
1470
1514
  };
1471
1515
  export {
1472
- Pe as NiceDrillDownChart,
1473
- Ae as NiceMapChart,
1474
- Ee as NiceRealtimeChart,
1475
- Re as NiceSankeyChart,
1476
- Te as NiceTreeMapChart
1516
+ Te as NiceDrillDownChart,
1517
+ Be as NiceMapChart,
1518
+ Oe as NiceRealtimeChart,
1519
+ Ye as NiceSankeyChart,
1520
+ Xe as NiceTreeMapChart
1477
1521
  };