@nice2dev/ui-3d 1.0.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/cjs/core/i18n.js +3 -3
  2. package/dist/cjs/dance/DanceBridge.js +13 -13
  3. package/dist/cjs/dance/DanceScoreEngine.js +8 -8
  4. package/dist/cjs/dance/PoseDetector.js +20 -20
  5. package/dist/cjs/material/NiceMaterialEditor.js +19 -19
  6. package/dist/cjs/model/ModelEditorLeftPanel.js +5 -5
  7. package/dist/cjs/model/ModelEditorMenuBar.js +6 -6
  8. package/dist/cjs/model/ModelEditorRightPanel.js +19 -19
  9. package/dist/cjs/model/ModelEditorSubComponents.js +10 -10
  10. package/dist/cjs/model/ModelEditorTimeline.js +6 -6
  11. package/dist/cjs/model/ModelEditorToolbar.js +4 -4
  12. package/dist/cjs/model/ModelEditorViewport.js +2 -2
  13. package/dist/cjs/model/ModelViewer.js +14 -14
  14. package/dist/cjs/model/NiceArmatureEditor.js +18 -18
  15. package/dist/cjs/model/NiceMorphTargetEditor.js +18 -18
  16. package/dist/cjs/model/NiceOctree.js +16 -16
  17. package/dist/cjs/model/NicePhysicsSimulation.js +24 -24
  18. package/dist/cjs/model/NiceProceduralGeometry.js +8 -8
  19. package/dist/cjs/model/NiceTerrainEditor.js +19 -19
  20. package/dist/cjs/model/NiceWeightPainter.js +14 -14
  21. package/dist/cjs/model/NiceXRPreview.js +18 -18
  22. package/dist/cjs/model/useModelEditor.js +127 -127
  23. package/dist/cjs/model/useModelViewer.js +61 -61
  24. package/dist/cjs/particle/NiceParticleEditor.js +11 -11
  25. package/dist/cjs/rendering/NiceCascadedShadows.js +12 -12
  26. package/dist/cjs/rendering/NiceRenderExport.js +5 -5
  27. package/dist/cjs/rendering/NiceSSAO.js +18 -18
  28. package/dist/cjs/rendering/NiceSSR.js +14 -14
  29. package/dist/cjs/rendering/NiceWebGPURenderer.js +21 -21
  30. package/dist/cjs/ui/dist/NiceButton-D9l39Rs7.js +598 -0
  31. package/dist/cjs/ui/dist/NiceButton-D9l39Rs7.js.map +1 -0
  32. package/dist/cjs/ui/dist/NiceErrorBoundary-niMx1aSJ.js +647 -0
  33. package/dist/cjs/ui/dist/NiceErrorBoundary-niMx1aSJ.js.map +1 -0
  34. package/dist/cjs/ui/dist/NiceModuleLifecyclePanel-I_TXRiiY.js +5048 -0
  35. package/dist/cjs/ui/dist/NiceModuleLifecyclePanel-I_TXRiiY.js.map +1 -0
  36. package/dist/cjs/ui/dist/NicePinCodeInput-CrMfdxxc.js +13081 -0
  37. package/dist/cjs/ui/dist/NicePinCodeInput-CrMfdxxc.js.map +1 -0
  38. package/dist/cjs/ui/dist/NiceSavedQueryPanel-CUAsdOjJ.js +6054 -0
  39. package/dist/cjs/ui/dist/NiceSavedQueryPanel-CUAsdOjJ.js.map +1 -0
  40. package/dist/cjs/ui/dist/NiceToggle-CaY1u82g.js +280 -0
  41. package/dist/cjs/ui/dist/NiceToggle-CaY1u82g.js.map +1 -0
  42. package/dist/cjs/ui/dist/NiceWindow-SiCaREbq.js +806 -0
  43. package/dist/cjs/ui/dist/NiceWindow-SiCaREbq.js.map +1 -0
  44. package/dist/cjs/ui/dist/charts-Bx_kNBsE.js +3508 -0
  45. package/dist/cjs/ui/dist/charts-Bx_kNBsE.js.map +1 -0
  46. package/dist/cjs/ui/dist/core-BpghV7Ls.js +10249 -0
  47. package/dist/cjs/ui/dist/core-BpghV7Ls.js.map +1 -0
  48. package/dist/cjs/ui/dist/index-CIl98Vbm.js +40039 -0
  49. package/dist/cjs/ui/dist/index-CIl98Vbm.js.map +1 -0
  50. package/dist/cjs/uv/NiceUVEditor.js +24 -24
  51. package/dist/esm/model/ModelEditorLeftPanel.js +4 -4
  52. package/dist/esm/model/ModelEditorMenuBar.js +4 -4
  53. package/dist/esm/model/ModelEditorRightPanel.js +5 -5
  54. package/dist/esm/model/ModelEditorSubComponents.js +2 -2
  55. package/dist/esm/model/ModelEditorTimeline.js +5 -5
  56. package/dist/esm/model/ModelEditorToolbar.js +3 -3
  57. package/dist/esm/model/ModelEditorViewport.js +2 -2
  58. package/dist/esm/model/ModelViewer.js +2 -2
  59. package/dist/esm/ui/dist/NiceButton-D9l39Rs7.js +593 -0
  60. package/dist/esm/ui/dist/NiceButton-D9l39Rs7.js.map +1 -0
  61. package/dist/esm/ui/dist/NiceErrorBoundary-niMx1aSJ.js +637 -0
  62. package/dist/esm/ui/dist/NiceErrorBoundary-niMx1aSJ.js.map +1 -0
  63. package/dist/esm/ui/dist/NiceModuleLifecyclePanel-I_TXRiiY.js +5007 -0
  64. package/dist/esm/ui/dist/NiceModuleLifecyclePanel-I_TXRiiY.js.map +1 -0
  65. package/dist/esm/ui/dist/NicePinCodeInput-CrMfdxxc.js +13011 -0
  66. package/dist/esm/ui/dist/NicePinCodeInput-CrMfdxxc.js.map +1 -0
  67. package/dist/esm/ui/dist/NiceSavedQueryPanel-CUAsdOjJ.js +6037 -0
  68. package/dist/esm/ui/dist/NiceSavedQueryPanel-CUAsdOjJ.js.map +1 -0
  69. package/dist/esm/ui/dist/NiceToggle-CaY1u82g.js +276 -0
  70. package/dist/esm/ui/dist/NiceToggle-CaY1u82g.js.map +1 -0
  71. package/dist/esm/ui/dist/NiceWindow-SiCaREbq.js +795 -0
  72. package/dist/esm/ui/dist/NiceWindow-SiCaREbq.js.map +1 -0
  73. package/dist/esm/ui/dist/charts-Bx_kNBsE.js +3483 -0
  74. package/dist/esm/ui/dist/charts-Bx_kNBsE.js.map +1 -0
  75. package/dist/esm/ui/dist/core-BpghV7Ls.js +10071 -0
  76. package/dist/esm/ui/dist/core-BpghV7Ls.js.map +1 -0
  77. package/dist/esm/ui/dist/index-CIl98Vbm.js +39917 -0
  78. package/dist/esm/ui/dist/index-CIl98Vbm.js.map +1 -0
  79. package/package.json +1 -1
@@ -0,0 +1,3508 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var ke = require('react');
5
+ var coreBpghV7Ls = require('./core-BpghV7Ls.js');
6
+
7
+ const Fe = (t, o) => o, He = ke.createContext(Fe);
8
+ function Ve() {
9
+ return { t: ke.useContext(He) };
10
+ }
11
+ ke.createContext({
12
+ dir: "ltr",
13
+ isRTL: false,
14
+ flip: (t) => t,
15
+ value: (t) => t.ltr
16
+ });
17
+ ke.createContext(null);
18
+ ke.createContext(null);
19
+ const Me = [
20
+ "#3b82f6",
21
+ "#ef4444",
22
+ "#22c55e",
23
+ "#f59e0b",
24
+ "#8b5cf6",
25
+ "#ec4899",
26
+ "#06b6d4",
27
+ "#84cc16"
28
+ ], ze = ({
29
+ series: t,
30
+ categories: o,
31
+ width: l = 600,
32
+ height: i = 400,
33
+ title: c,
34
+ showLegend: b = true,
35
+ showGrid: f = true,
36
+ yAxisLabel: w,
37
+ xAxisLabel: B,
38
+ stacked: p,
39
+ zoomable: S,
40
+ crosshair: N,
41
+ annotations: z,
42
+ legendInteractive: M,
43
+ onDataPointClick: v,
44
+ exportable: u,
45
+ className: h,
46
+ style: m
47
+ }) => {
48
+ const L = ke.useRef(null), [x, y] = ke.useState(/* @__PURE__ */ new Set()), [s, T] = ke.useState(null), [g, C] = ke.useState(null), [d, $] = ke.useState(false), A = ke.useRef(null), O = ke.useMemo(
49
+ () => t.filter((P) => !x.has(P.name)),
50
+ [t, x]
51
+ ), X = ke.useCallback(
52
+ (P) => {
53
+ M && y((K) => {
54
+ const ne = new Set(K);
55
+ return ne.has(P) ? ne.delete(P) : ne.add(P), ne;
56
+ });
57
+ },
58
+ [M]
59
+ ), R = {
60
+ top: c ? 40 : 20,
61
+ right: 20,
62
+ bottom: B ? 60 : 40,
63
+ left: w ? 60 : 50
64
+ }, Y = l - R.left - R.right, q = i - R.top - R.bottom, J = O[0]?.data.length ?? t[0]?.data.length ?? 0, V = g?.start ?? 0, Q = g?.end ?? J, r = Q - V, F = ke.useMemo(
65
+ () => O.map((P) => ({ ...P, data: P.data.slice(V, Q) })),
66
+ [O, V, Q]
67
+ ), H = ke.useMemo(
68
+ () => o?.slice(V, Q),
69
+ [o, V, Q]
70
+ ), { minY: k, maxY: n, yTicks: E } = ke.useMemo(() => {
71
+ let P;
72
+ if (p) {
73
+ P = [];
74
+ for (let D = 0; D < r; D++)
75
+ P.push(F.reduce((re, ue) => re + (ue.data[D] || 0), 0));
76
+ } else
77
+ P = F.flatMap((D) => D.data);
78
+ P.length === 0 && (P = [0]);
79
+ const K = Math.min(0, ...P), ne = Math.max(0, ...P), se = ne - K || 1, de = Math.pow(10, Math.floor(Math.log10(se))) || 1, a = Math.floor(K / de) * de, W = Math.ceil(ne / de) * de, U = [];
80
+ for (let D = a; D <= W; D += de)
81
+ U.push(Math.round(D * 1e6) / 1e6);
82
+ return U.length < 2 && U.push(W), { minY: a, maxY: W, yTicks: U };
83
+ }, [F, r, p]), I = (P) => q - (P - k) / (n - k || 1) * q, Z = (P) => (P + 0.5) / r * Y, ae = r > 0 ? Y / r / (p ? 1.5 : Math.max(O.length, 1) * 1.5) : 20, le = ke.useCallback(
84
+ (P) => {
85
+ if (!S)
86
+ return;
87
+ P.preventDefault();
88
+ const K = g ?? { start: 0, end: J }, ne = K.end - K.start, se = (K.start + K.end) / 2, de = P.deltaY > 0 ? 1.2 : 0.8, a = Math.max(2, Math.min(J, Math.round(ne * de))), W = Math.max(0, Math.round(se - a / 2)), U = Math.min(J, W + a);
89
+ C({ start: W, end: U });
90
+ },
91
+ [S, g, J]
92
+ ), te = ke.useCallback(
93
+ (P) => {
94
+ S && ($(true), A.current = { x: P.clientX, range: g ?? { start: 0, end: J } });
95
+ },
96
+ [S, g, J]
97
+ ), j = ke.useCallback(
98
+ (P) => {
99
+ const K = L.current?.getBoundingClientRect();
100
+ if (K && T({ x: P.clientX - K.left - R.left, y: P.clientY - K.top - R.top }), d && A.current && S) {
101
+ const ne = P.clientX - A.current.x, se = Y / r, de = -Math.round(ne / se), a = A.current.range, W = a.end - a.start;
102
+ let U = a.start + de;
103
+ U < 0 && (U = 0), U + W > J && (U = J - W), C({ start: U, end: U + W });
104
+ }
105
+ },
106
+ [d, S, Y, r, J, R.left, R.top]
107
+ ), G = ke.useCallback(() => {
108
+ $(false), A.current = null;
109
+ }, []), ce = ke.useCallback(() => {
110
+ T(null), $(false), A.current = null;
111
+ }, []), ge = ke.useCallback(() => {
112
+ const P = L.current;
113
+ if (!P)
114
+ return;
115
+ const K = new XMLSerializer().serializeToString(P), ne = document.createElement("canvas");
116
+ ne.width = l, ne.height = i + (b ? 30 : 0);
117
+ const se = ne.getContext("2d");
118
+ if (!se)
119
+ return;
120
+ const de = new Image();
121
+ de.onload = () => {
122
+ se.fillStyle = "#fff", se.fillRect(0, 0, ne.width, ne.height), se.drawImage(de, 0, 0);
123
+ const a = document.createElement("a");
124
+ a.download = "chart.png", a.href = ne.toDataURL("image/png"), a.click();
125
+ }, de.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(K);
126
+ }, [l, i, b]);
127
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `nice-chart ${h || ""}`, style: m, children: [
128
+ u && /* @__PURE__ */ jsxRuntime.jsx(
129
+ "button",
130
+ {
131
+ type: "button",
132
+ className: "nice-chart__export-btn",
133
+ onClick: ge,
134
+ title: "Export PNG",
135
+ children: "📷"
136
+ }
137
+ ),
138
+ /* @__PURE__ */ jsxRuntime.jsxs(
139
+ "svg",
140
+ {
141
+ ref: L,
142
+ width: l,
143
+ height: i + (b ? 30 : 0),
144
+ className: "nice-chart__svg",
145
+ onWheel: le,
146
+ onMouseDown: te,
147
+ onMouseMove: j,
148
+ onMouseUp: G,
149
+ onMouseLeave: ce,
150
+ children: [
151
+ /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${R.left},${R.top})`, children: [
152
+ c && /* @__PURE__ */ jsxRuntime.jsx("text", { x: Y / 2, y: -10, textAnchor: "middle", className: "nice-chart__title", children: c }),
153
+ f && E.map((P) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
154
+ /* @__PURE__ */ jsxRuntime.jsx(
155
+ "line",
156
+ {
157
+ x1: 0,
158
+ y1: I(P),
159
+ x2: Y,
160
+ y2: I(P),
161
+ className: "nice-chart__grid-line"
162
+ }
163
+ ),
164
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: -8, y: I(P) + 4, textAnchor: "end", className: "nice-chart__axis-label", children: P })
165
+ ] }, P)),
166
+ H && H.map((P, K) => /* @__PURE__ */ jsxRuntime.jsx(
167
+ "text",
168
+ {
169
+ x: Z(K),
170
+ y: q + 20,
171
+ textAnchor: "middle",
172
+ className: "nice-chart__axis-label",
173
+ children: P
174
+ },
175
+ K
176
+ )),
177
+ w && /* @__PURE__ */ jsxRuntime.jsx(
178
+ "text",
179
+ {
180
+ x: -R.left + 14,
181
+ y: q / 2,
182
+ textAnchor: "middle",
183
+ transform: `rotate(-90, -${R.left - 14}, ${q / 2})`,
184
+ className: "nice-chart__axis-title",
185
+ children: w
186
+ }
187
+ ),
188
+ B && /* @__PURE__ */ jsxRuntime.jsx("text", { x: Y / 2, y: q + 45, textAnchor: "middle", className: "nice-chart__axis-title", children: B }),
189
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: 0, y1: 0, x2: 0, y2: q, className: "nice-chart__axis" }),
190
+ /* @__PURE__ */ jsxRuntime.jsx("line", { x1: 0, y1: q, x2: Y, y2: q, className: "nice-chart__axis" }),
191
+ z?.map((P, K) => {
192
+ if (P.type === "line") {
193
+ const ne = I(P.value);
194
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
195
+ /* @__PURE__ */ jsxRuntime.jsx(
196
+ "line",
197
+ {
198
+ x1: 0,
199
+ y1: ne,
200
+ x2: Y,
201
+ y2: ne,
202
+ stroke: P.color || "#ef4444",
203
+ strokeWidth: 1.5,
204
+ strokeDasharray: P.dash || "6,3"
205
+ }
206
+ ),
207
+ P.label && /* @__PURE__ */ jsxRuntime.jsx(
208
+ "text",
209
+ {
210
+ x: Y + 4,
211
+ y: ne + 4,
212
+ className: "nice-chart__annotation-label",
213
+ fill: P.color || "#ef4444",
214
+ children: P.label
215
+ }
216
+ )
217
+ ] }, K);
218
+ }
219
+ return /* @__PURE__ */ jsxRuntime.jsx(
220
+ "text",
221
+ {
222
+ x: Z(P.value),
223
+ y: -4,
224
+ textAnchor: "middle",
225
+ className: "nice-chart__annotation-label",
226
+ fill: P.color || "#6b7280",
227
+ children: P.label
228
+ },
229
+ K
230
+ );
231
+ }),
232
+ N && s && s.x >= 0 && s.x <= Y && s.y >= 0 && s.y <= q && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
233
+ /* @__PURE__ */ jsxRuntime.jsx(
234
+ "line",
235
+ {
236
+ x1: s.x,
237
+ y1: 0,
238
+ x2: s.x,
239
+ y2: q,
240
+ stroke: "#9ca3af",
241
+ strokeWidth: 1,
242
+ strokeDasharray: "4,2"
243
+ }
244
+ ),
245
+ /* @__PURE__ */ jsxRuntime.jsx(
246
+ "line",
247
+ {
248
+ x1: 0,
249
+ y1: s.y,
250
+ x2: Y,
251
+ y2: s.y,
252
+ stroke: "#9ca3af",
253
+ strokeWidth: 1,
254
+ strokeDasharray: "4,2"
255
+ }
256
+ )
257
+ ] }),
258
+ F.map((P, K) => {
259
+ const ne = P.color || Me[K % Me.length], se = P.type || "bar";
260
+ if (se === "bar")
261
+ return /* @__PURE__ */ jsxRuntime.jsx("g", { children: P.data.map((a, W) => {
262
+ let U, D;
263
+ if (p) {
264
+ const ue = F.slice(0, K).reduce((xe, fe) => xe + (fe.data[W] || 0), 0);
265
+ U = I(ue + a), D = I(ue) - U;
266
+ } else
267
+ U = I(Math.max(0, a)), D = Math.abs(I(a) - I(0));
268
+ const re = p ? Z(W) - ae / 2 : Z(W) - F.length * ae / 2 + K * ae;
269
+ return /* @__PURE__ */ jsxRuntime.jsx(
270
+ "rect",
271
+ {
272
+ x: re,
273
+ y: U,
274
+ width: ae * 0.9,
275
+ height: Math.max(0, D),
276
+ fill: ne,
277
+ rx: 2,
278
+ style: v ? { cursor: "pointer" } : void 0,
279
+ onClick: v ? () => v(P.name, V + W, a) : void 0,
280
+ children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${P.name}: ${a}` })
281
+ },
282
+ W
283
+ );
284
+ }) }, P.name);
285
+ const de = P.data.map((a, W) => `${Z(W)},${I(a)}`);
286
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
287
+ se === "area" && /* @__PURE__ */ jsxRuntime.jsx(
288
+ "polygon",
289
+ {
290
+ points: `${Z(0)},${I(0)} ${de.join(" ")} ${Z(r - 1)},${I(0)}`,
291
+ fill: ne,
292
+ opacity: 0.15
293
+ }
294
+ ),
295
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: de.join(" "), fill: "none", stroke: ne, strokeWidth: 2 }),
296
+ P.data.map((a, W) => /* @__PURE__ */ jsxRuntime.jsx(
297
+ "circle",
298
+ {
299
+ cx: Z(W),
300
+ cy: I(a),
301
+ r: 3,
302
+ fill: ne,
303
+ style: v ? { cursor: "pointer" } : void 0,
304
+ onClick: v ? () => v(P.name, V + W, a) : void 0,
305
+ children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${P.name}: ${a}` })
306
+ },
307
+ W
308
+ ))
309
+ ] }, P.name);
310
+ })
311
+ ] }),
312
+ b && /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(${R.left}, ${i})`, children: t.map((P, K) => {
313
+ const ne = K * 120, se = x.has(P.name);
314
+ return /* @__PURE__ */ jsxRuntime.jsxs(
315
+ "g",
316
+ {
317
+ transform: `translate(${ne}, 10)`,
318
+ style: M ? { cursor: "pointer" } : void 0,
319
+ onClick: () => X(P.name),
320
+ opacity: se ? 0.35 : 1,
321
+ children: [
322
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: 12, height: 12, rx: 2, fill: P.color || Me[K % Me.length] }),
323
+ /* @__PURE__ */ jsxRuntime.jsx(
324
+ "text",
325
+ {
326
+ x: 16,
327
+ y: 10,
328
+ className: "nice-chart__legend-text",
329
+ style: se ? { textDecoration: "line-through" } : void 0,
330
+ children: P.name
331
+ }
332
+ )
333
+ ]
334
+ },
335
+ P.name
336
+ );
337
+ }) })
338
+ ]
339
+ }
340
+ )
341
+ ] });
342
+ }, dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
343
+ __proto__: null,
344
+ NiceChart: ze
345
+ }, Symbol.toStringTag, { value: "Module" }));
346
+ function Xe(t) {
347
+ if (!t.length)
348
+ return { categories: [], numericFields: [], sampleValues: {} };
349
+ const o = t[0], l = [], i = {};
350
+ let c = null;
351
+ for (const [f, w] of Object.entries(o))
352
+ typeof w == "number" ? (l.push(f), i[f] = t.map((B) => Number(B[f]) || 0)) : !c && (typeof w == "string" || w instanceof Date) && (c = f);
353
+ return { categories: c ? t.map((f) => String(f[c] || "")) : t.map((f, w) => `Item ${w + 1}`), numericFields: l, sampleValues: i };
354
+ }
355
+ function Ze(t, o) {
356
+ const { categories: l, numericFields: i, sampleValues: c } = Xe(t);
357
+ return { series: i.map((f, w) => ({
358
+ name: f.replace(/([A-Z])/g, " $1").replace(/^./, (B) => B.toUpperCase()).trim(),
359
+ data: c[f],
360
+ type: o === "area" ? "area" : o === "line" ? "line" : "bar"
361
+ })), categories: l };
362
+ }
363
+ ke.forwardRef(
364
+ function(o, l) {
365
+ const {
366
+ rawData: i,
367
+ enableAI: c = true,
368
+ aiModel: b,
369
+ enableAutoType: f = true,
370
+ enableInsights: w = true,
371
+ dataDescription: B,
372
+ onChartSuggestion: p,
373
+ onInsights: S,
374
+ showAIToolbar: N = true,
375
+ showInsightsOnLoad: z = false,
376
+ series: M,
377
+ categories: v,
378
+ ...u
379
+ } = o, [h, m] = ke.useState("bar"), [L, x] = ke.useState(null), [y, s] = ke.useState([]), [T, g] = ke.useState(z), [C, d] = ke.useState(null), { t: $ } = Ve(), A = coreBpghV7Ls.u(), {
380
+ suggestChartType: O,
381
+ generateInsights: X,
382
+ isLoading: R
383
+ } = coreBpghV7Ls.a(), Y = c && A.isConfigured, { series: q, categories: J } = i ? Ze(i, C || h) : { series: M || [], categories: v }, V = ke.useCallback(async () => {
384
+ if (!Y || !f)
385
+ return { type: "bar", reason: "Default", config: {} };
386
+ const k = i || (M?.length ? M.flatMap((n) => n.data.map((E, I) => ({ [n.name]: E, index: I }))) : []);
387
+ try {
388
+ const n = await O(k, B), E = {
389
+ type: n.type,
390
+ reason: n.reason,
391
+ config: n.config
392
+ };
393
+ return x(E), m(E.type), p?.(E), E;
394
+ } catch {
395
+ return { type: "bar", reason: "Default fallback", config: {} };
396
+ }
397
+ }, [
398
+ Y,
399
+ f,
400
+ i,
401
+ M,
402
+ B,
403
+ O,
404
+ p
405
+ ]), Q = ke.useCallback(async () => {
406
+ if (!Y || !w)
407
+ return [];
408
+ const k = i || (M?.length ? M.flatMap(
409
+ (n) => n.data.map((E, I) => ({ [n.name]: E, category: v?.[I] || I }))
410
+ ) : []);
411
+ try {
412
+ const n = await X(k, C || h);
413
+ return s(n), S?.(n), n;
414
+ } catch {
415
+ return [];
416
+ }
417
+ }, [
418
+ Y,
419
+ w,
420
+ i,
421
+ M,
422
+ v,
423
+ h,
424
+ C,
425
+ X,
426
+ S
427
+ ]), r = ke.useCallback(
428
+ () => C || h,
429
+ [C, h]
430
+ );
431
+ ke.useEffect(() => {
432
+ Y && f && (i?.length || M?.length) && V();
433
+ }, [Y, f, i, M]), ke.useImperativeHandle(l, () => ({
434
+ getSuggestion: V,
435
+ generateInsights: Q,
436
+ getCurrentType: r
437
+ }));
438
+ const F = [
439
+ { type: "bar", icon: "📊", label: "Bar" },
440
+ { type: "line", icon: "📈", label: "Line" },
441
+ { type: "area", icon: "🏔️", label: "Area" },
442
+ { type: "pie", icon: "🥧", label: "Pie" },
443
+ { type: "donut", icon: "🍩", label: "Donut" },
444
+ { type: "scatter", icon: "⭐", label: "Scatter" }
445
+ ], H = C || h;
446
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai", "data-testid": o["data-testid"], children: [
447
+ N && Y && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__toolbar", children: [
448
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__toolbar-left", children: [
449
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__badge", children: "AI" }),
450
+ L && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__suggestion", children: [
451
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__suggestion-icon", children: "💡" }),
452
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "nice-chart-ai__suggestion-text", children: [
453
+ $("chartAI.suggestedType", "Suggested:"),
454
+ " ",
455
+ L.type
456
+ ] }),
457
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "nice-chart-ai__suggestion-reason", title: L.reason, children: [
458
+ "(",
459
+ L.reason,
460
+ ")"
461
+ ] })
462
+ ] }),
463
+ R && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__loading", children: $("chartAI.analyzing", "Analyzing...") })
464
+ ] }),
465
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__toolbar-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__type-selector", children: F.filter((k) => ["bar", "line", "area"].includes(k.type)).map(({ type: k, icon: n, label: E }) => /* @__PURE__ */ jsxRuntime.jsx(
466
+ "button",
467
+ {
468
+ type: "button",
469
+ className: `nice-chart-ai__type-btn ${H === k ? "nice-chart-ai__type-btn--active" : ""}`,
470
+ onClick: () => d(k),
471
+ title: E,
472
+ children: n
473
+ },
474
+ k
475
+ )) }) }),
476
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__toolbar-right", children: [
477
+ /* @__PURE__ */ jsxRuntime.jsxs(
478
+ "button",
479
+ {
480
+ type: "button",
481
+ className: "nice-chart-ai__auto-btn",
482
+ onClick: () => V(),
483
+ disabled: R,
484
+ title: $("chartAI.autoDetect", "Auto-detect best chart type"),
485
+ children: [
486
+ "🔮 ",
487
+ $("chartAI.auto", "Auto")
488
+ ]
489
+ }
490
+ ),
491
+ w && /* @__PURE__ */ jsxRuntime.jsxs(
492
+ "button",
493
+ {
494
+ type: "button",
495
+ className: "nice-chart-ai__insights-btn",
496
+ onClick: () => {
497
+ y.length || Q(), g(!T);
498
+ },
499
+ disabled: R,
500
+ title: $("chartAI.showInsights", "Show data insights"),
501
+ children: [
502
+ "💡 ",
503
+ $("chartAI.insights", "Insights")
504
+ ]
505
+ }
506
+ )
507
+ ] })
508
+ ] }),
509
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__chart-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(ze, { series: q, categories: J, ...u }) }),
510
+ T && y.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__insights", children: [
511
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__insights-header", children: [
512
+ /* @__PURE__ */ jsxRuntime.jsxs("h4", { children: [
513
+ "💡 ",
514
+ $("chartAI.dataInsights", "Data Insights")
515
+ ] }),
516
+ /* @__PURE__ */ jsxRuntime.jsx(
517
+ "button",
518
+ {
519
+ type: "button",
520
+ className: "nice-chart-ai__insights-close",
521
+ onClick: () => g(false),
522
+ children: "✕"
523
+ }
524
+ )
525
+ ] }),
526
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "nice-chart-ai__insights-list", children: y.map((k, n) => /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "nice-chart-ai__insight", children: [
527
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__insight-icon", children: "•" }),
528
+ k
529
+ ] }, n)) }),
530
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__insights-footer", children: /* @__PURE__ */ jsxRuntime.jsxs(
531
+ "button",
532
+ {
533
+ type: "button",
534
+ className: "nice-chart-ai__refresh",
535
+ onClick: () => Q(),
536
+ disabled: R,
537
+ children: [
538
+ "🔄 ",
539
+ $("chartAI.refresh", "Refresh")
540
+ ]
541
+ }
542
+ ) })
543
+ ] }),
544
+ T && R && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-chart-ai__insights nice-chart-ai__insights--loading", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-chart-ai__loading-content", children: [
545
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-chart-ai__spinner" }),
546
+ $("chartAI.generatingInsights", "Generating insights...")
547
+ ] }) })
548
+ ] });
549
+ }
550
+ );
551
+ function Ue(t, o) {
552
+ const l = t ? typeof t == "number" ? new Date(t) : new Date(t) : /* @__PURE__ */ new Date(), i = (B) => B.toString().padStart(2, "0"), c = i(l.getHours()), b = i(l.getMinutes()), f = i(l.getSeconds()), w = l.getMilliseconds().toString().padStart(3, "0");
553
+ switch (o) {
554
+ case "HH:mm:ss":
555
+ return `${c}:${b}:${f}`;
556
+ case "HH:mm":
557
+ return `${c}:${b}`;
558
+ case "mm:ss":
559
+ return `${b}:${f}`;
560
+ case "ss.SSS":
561
+ return `${f}.${w}`;
562
+ case "ISO":
563
+ return l.toISOString();
564
+ default:
565
+ return `${c}:${b}:${f}`;
566
+ }
567
+ }
568
+ function De(t) {
569
+ if (t.length === 0)
570
+ return null;
571
+ const o = Math.min(...t), l = Math.max(...t), i = t.reduce((b, f) => b + f, 0) / t.length, c = t[t.length - 1];
572
+ return { min: o, max: l, avg: i, current: c, count: t.length };
573
+ }
574
+ const Ge = ke.forwardRef(
575
+ ({
576
+ series: t,
577
+ maxPoints: o = 100,
578
+ slidingWindow: l = true,
579
+ refreshRate: i = 16,
580
+ dataSource: c,
581
+ width: b = 600,
582
+ height: f = 400,
583
+ title: w,
584
+ showLegend: B = true,
585
+ showGrid: p = true,
586
+ yAxisLabel: S,
587
+ xAxisLabel: N,
588
+ stacked: z,
589
+ zoomable: M,
590
+ crosshair: v,
591
+ annotations: u = [],
592
+ legendInteractive: h,
593
+ onDataPointClick: m,
594
+ exportable: L,
595
+ showControls: x = true,
596
+ showStatus: y = true,
597
+ initialPaused: s = false,
598
+ onDataReceived: T,
599
+ onDataDropped: g,
600
+ timeFormat: C = "HH:mm:ss",
601
+ showStats: d,
602
+ thresholds: $ = [],
603
+ className: A,
604
+ style: O
605
+ }, X) => {
606
+ const [R, Y] = ke.useState(() => {
607
+ const j = /* @__PURE__ */ new Map();
608
+ for (const G of t)
609
+ j.set(G.name, G.initialData?.slice() ?? []);
610
+ return j;
611
+ }), [q, J] = ke.useState([]), [V, Q] = ke.useState(s), [r, F] = ke.useState(false), H = ke.useRef([]), k = ke.useRef(Date.now()), n = ke.useRef(null), E = ke.useCallback(() => {
612
+ const j = H.current;
613
+ j.length !== 0 && (H.current = [], Y((G) => {
614
+ const ce = new Map(G);
615
+ for (const ge of j) {
616
+ const P = ce.get(ge.series);
617
+ if (!P)
618
+ continue;
619
+ const K = [...P, ge.value];
620
+ if (l && K.length > o) {
621
+ const ne = K.length - o;
622
+ g?.(ne, ge.series), K.splice(0, ne);
623
+ }
624
+ ce.set(ge.series, K);
625
+ }
626
+ return ce;
627
+ }), j.length > 0 && J((G) => {
628
+ const ce = [...G];
629
+ for (const ge of j) {
630
+ const P = ge.category ?? Ue(ge.timestamp, C);
631
+ ce.push(P);
632
+ }
633
+ return l && ce.length > o && ce.splice(0, ce.length - o), ce;
634
+ }));
635
+ }, [l, o, C, g]), I = ke.useCallback(() => {
636
+ const j = Date.now();
637
+ j - k.current >= i && (E(), k.current = j), n.current = requestAnimationFrame(I);
638
+ }, [i, E]);
639
+ ke.useEffect(() => (V || (n.current = requestAnimationFrame(I)), () => {
640
+ n.current !== null && (cancelAnimationFrame(n.current), n.current = null);
641
+ }), [V, I]);
642
+ const Z = ke.useCallback(
643
+ (j) => {
644
+ if (V)
645
+ return;
646
+ const G = "points" in j ? j.points : [j];
647
+ for (const ce of G)
648
+ R.has(ce.series) && (H.current.push(ce), T?.(ce));
649
+ },
650
+ [V, R, T]
651
+ );
652
+ ke.useEffect(() => {
653
+ if (!c)
654
+ return;
655
+ const j = c.subscribe(Z);
656
+ let G;
657
+ return c.onStatusChange ? G = c.onStatusChange(F) : F(true), c.fetchHistory && c.fetchHistory(o).then((ce) => {
658
+ for (const ge of ce)
659
+ H.current.push(ge);
660
+ E();
661
+ }), () => {
662
+ j(), G?.();
663
+ };
664
+ }, [c, Z, o, E]);
665
+ const ae = ke.useMemo(() => t.map((j) => ({
666
+ name: j.name,
667
+ color: j.color,
668
+ type: j.type,
669
+ data: R.get(j.name) ?? []
670
+ })), [t, R]), le = ke.useMemo(() => {
671
+ const j = [...u];
672
+ for (const G of $)
673
+ j.push({
674
+ type: "line",
675
+ value: G.value,
676
+ color: G.color,
677
+ label: G.label,
678
+ dash: G.style === "dashed" ? "5,5" : G.style === "dotted" ? "2,2" : void 0
679
+ });
680
+ return j;
681
+ }, [u, $]);
682
+ ke.useImperativeHandle(
683
+ X,
684
+ () => ({
685
+ pause() {
686
+ Q(true);
687
+ },
688
+ resume() {
689
+ Q(false);
690
+ },
691
+ isPaused() {
692
+ return V;
693
+ },
694
+ clear() {
695
+ Y((j) => {
696
+ const G = new Map(j);
697
+ for (const ce of G.keys())
698
+ G.set(ce, []);
699
+ return G;
700
+ }), J([]), H.current = [];
701
+ },
702
+ addPoint(j) {
703
+ Z(j);
704
+ },
705
+ addPoints(j) {
706
+ Z({ points: j });
707
+ },
708
+ getData(j) {
709
+ return R.get(j) ?? [];
710
+ },
711
+ getCategories() {
712
+ return q;
713
+ },
714
+ exportData() {
715
+ return { series: ae, categories: q };
716
+ },
717
+ getStats(j) {
718
+ const G = R.get(j);
719
+ return G ? De(G) : null;
720
+ }
721
+ }),
722
+ [V, R, q, ae, Z]
723
+ );
724
+ const te = ke.useMemo(() => {
725
+ if (!d)
726
+ return null;
727
+ const j = {};
728
+ for (const [G, ce] of R)
729
+ j[G] = De(ce);
730
+ return j;
731
+ }, [d, R]);
732
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: A, style: { position: "relative", ...O }, children: [
733
+ y && /* @__PURE__ */ jsxRuntime.jsxs(
734
+ "div",
735
+ {
736
+ style: {
737
+ position: "absolute",
738
+ top: 8,
739
+ right: 8,
740
+ display: "flex",
741
+ alignItems: "center",
742
+ gap: 4,
743
+ fontSize: 12,
744
+ color: r ? "#22c55e" : "#ef4444",
745
+ zIndex: 10
746
+ },
747
+ children: [
748
+ /* @__PURE__ */ jsxRuntime.jsx(
749
+ "span",
750
+ {
751
+ style: {
752
+ width: 8,
753
+ height: 8,
754
+ borderRadius: "50%",
755
+ backgroundColor: r ? "#22c55e" : "#ef4444"
756
+ }
757
+ }
758
+ ),
759
+ r ? "Live" : "Disconnected"
760
+ ]
761
+ }
762
+ ),
763
+ x && /* @__PURE__ */ jsxRuntime.jsx(
764
+ "div",
765
+ {
766
+ style: {
767
+ position: "absolute",
768
+ top: 8,
769
+ left: 8,
770
+ display: "flex",
771
+ gap: 4,
772
+ zIndex: 10
773
+ },
774
+ children: /* @__PURE__ */ jsxRuntime.jsx(
775
+ "button",
776
+ {
777
+ onClick: () => Q((j) => !j),
778
+ style: {
779
+ padding: "4px 8px",
780
+ fontSize: 12,
781
+ border: "1px solid #ddd",
782
+ borderRadius: 4,
783
+ background: V ? "#fef3c7" : "#fff",
784
+ cursor: "pointer"
785
+ },
786
+ title: V ? "Resume" : "Pause",
787
+ children: V ? "▶" : "⏸"
788
+ }
789
+ )
790
+ }
791
+ ),
792
+ d && te && /* @__PURE__ */ jsxRuntime.jsx(
793
+ "div",
794
+ {
795
+ style: {
796
+ position: "absolute",
797
+ bottom: 50,
798
+ right: 8,
799
+ background: "rgba(255,255,255,0.9)",
800
+ border: "1px solid #ddd",
801
+ borderRadius: 4,
802
+ padding: 8,
803
+ fontSize: 11,
804
+ zIndex: 10
805
+ },
806
+ children: Object.entries(te).map(
807
+ ([j, G]) => G ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: 4 }, children: [
808
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: j }),
809
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
810
+ "Min: ",
811
+ G.min.toFixed(2),
812
+ " | Max: ",
813
+ G.max.toFixed(2)
814
+ ] }),
815
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
816
+ "Avg: ",
817
+ G.avg.toFixed(2),
818
+ " | Now: ",
819
+ G.current.toFixed(2)
820
+ ] })
821
+ ] }, j) : null
822
+ )
823
+ }
824
+ ),
825
+ /* @__PURE__ */ jsxRuntime.jsx(
826
+ ze,
827
+ {
828
+ series: ae,
829
+ categories: q,
830
+ width: b,
831
+ height: f,
832
+ title: w,
833
+ showLegend: B,
834
+ showGrid: p,
835
+ yAxisLabel: S,
836
+ xAxisLabel: N,
837
+ stacked: z,
838
+ zoomable: M,
839
+ crosshair: v,
840
+ annotations: le,
841
+ legendInteractive: h,
842
+ onDataPointClick: m,
843
+ exportable: L
844
+ }
845
+ )
846
+ ] });
847
+ }
848
+ );
849
+ Ge.displayName = "NiceLiveChart";
850
+ const me = ["#3b82f6", "#ef4444", "#22c55e", "#f59e0b", "#8b5cf6", "#ec4899", "#06b6d4", "#84cc16"], mt = ({
851
+ data: t,
852
+ width: o = 400,
853
+ height: l = 400,
854
+ innerRadius: i = 0,
855
+ title: c,
856
+ showLegend: b = true,
857
+ showLabels: f = true,
858
+ className: w,
859
+ style: B
860
+ }) => {
861
+ const p = o / 2, S = (l - (b ? 30 : 0)) / 2 + (c ? 10 : 0), N = Math.min(p, S) - 40, z = t.reduce((u, h) => u + h.value, 0);
862
+ let M = -Math.PI / 2;
863
+ const v = t.map((u, h) => {
864
+ const m = u.value / (z || 1) * Math.PI * 2, L = M;
865
+ M += m;
866
+ const x = M, y = (L + x) / 2, s = p + N * Math.cos(L), T = S + N * Math.sin(L), g = p + N * Math.cos(x), C = S + N * Math.sin(x), d = m > Math.PI ? 1 : 0, $ = u.color || me[h % me.length];
867
+ let A;
868
+ if (i > 0) {
869
+ const Y = p + i * Math.cos(L), q = S + i * Math.sin(L), J = p + i * Math.cos(x), V = S + i * Math.sin(x);
870
+ A = `M${s},${T} A${N},${N} 0 ${d},1 ${g},${C} L${J},${V} A${i},${i} 0 ${d},0 ${Y},${q} Z`;
871
+ } else
872
+ A = `M${p},${S} L${s},${T} A${N},${N} 0 ${d},1 ${g},${C} Z`;
873
+ const O = p + N * 0.7 * Math.cos(y), X = S + N * 0.7 * Math.sin(y), R = z > 0 ? Math.round(u.value / z * 100) : 0;
874
+ return { ...u, path: A, labelX: O, labelY: X, pct: R, color: $ };
875
+ });
876
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-piechart ${w || ""}`, style: B, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: o, height: l, className: "nice-piechart__svg", children: [
877
+ c && /* @__PURE__ */ jsxRuntime.jsx("text", { x: p, y: 20, textAnchor: "middle", className: "nice-chart__title", children: c }),
878
+ v.map((u, h) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
879
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: u.path, fill: u.color, stroke: "var(--bg-primary, #fff)", strokeWidth: 2, children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${u.label}: ${u.value} (${u.pct}%)` }) }),
880
+ f && u.pct >= 5 && /* @__PURE__ */ jsxRuntime.jsxs(
881
+ "text",
882
+ {
883
+ x: u.labelX,
884
+ y: u.labelY,
885
+ textAnchor: "middle",
886
+ dominantBaseline: "middle",
887
+ className: "nice-piechart__label",
888
+ children: [
889
+ u.pct,
890
+ "%"
891
+ ]
892
+ }
893
+ )
894
+ ] }, h)),
895
+ b && /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(10, ${l - 25})`, children: t.map((u, h) => /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${h * 100}, 0)`, children: [
896
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: 10, height: 10, rx: 2, fill: u.color || me[h % me.length] }),
897
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: u.label })
898
+ ] }, h)) })
899
+ ] }) });
900
+ }, gt = ({
901
+ series: t,
902
+ categories: o,
903
+ width: l = 400,
904
+ height: i = 400,
905
+ maxValue: c,
906
+ title: b,
907
+ showLegend: f = true,
908
+ className: w,
909
+ style: B
910
+ }) => {
911
+ const p = l / 2, S = (i - (f ? 30 : 0)) / 2 + (b ? 10 : 0), N = Math.min(p, S) - 40, z = o.length, M = c ?? Math.max(...t.flatMap((m) => m.data), 1), v = Math.PI * 2 / z, u = 5, h = (m, L) => {
912
+ const x = m * v - Math.PI / 2, y = L / M * N;
913
+ return { x: p + y * Math.cos(x), y: S + y * Math.sin(x) };
914
+ };
915
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-polarchart ${w || ""}`, style: B, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: l, height: i, className: "nice-polarchart__svg", children: [
916
+ b && /* @__PURE__ */ jsxRuntime.jsx("text", { x: p, y: 20, textAnchor: "middle", className: "nice-chart__title", children: b }),
917
+ Array.from({ length: u }, (m, L) => {
918
+ const x = N * ((L + 1) / u);
919
+ return /* @__PURE__ */ jsxRuntime.jsx(
920
+ "circle",
921
+ {
922
+ cx: p,
923
+ cy: S,
924
+ r: x,
925
+ fill: "none",
926
+ stroke: "var(--border-color, #ddd)",
927
+ strokeWidth: 0.5
928
+ },
929
+ L
930
+ );
931
+ }),
932
+ o.map((m, L) => {
933
+ const x = h(L, M), y = h(L, M * 1.12);
934
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
935
+ /* @__PURE__ */ jsxRuntime.jsx(
936
+ "line",
937
+ {
938
+ x1: p,
939
+ y1: S,
940
+ x2: x.x,
941
+ y2: x.y,
942
+ stroke: "var(--border-color, #ddd)",
943
+ strokeWidth: 0.5
944
+ }
945
+ ),
946
+ /* @__PURE__ */ jsxRuntime.jsx(
947
+ "text",
948
+ {
949
+ x: y.x,
950
+ y: y.y,
951
+ textAnchor: "middle",
952
+ dominantBaseline: "middle",
953
+ className: "nice-chart__axis-label",
954
+ children: m
955
+ }
956
+ )
957
+ ] }, L);
958
+ }),
959
+ t.map((m, L) => {
960
+ const x = m.color || me[L % me.length], y = m.data.map((s, T) => {
961
+ const g = h(T, s);
962
+ return `${g.x},${g.y}`;
963
+ }).join(" ");
964
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
965
+ /* @__PURE__ */ jsxRuntime.jsx(
966
+ "polygon",
967
+ {
968
+ points: y,
969
+ fill: m.fill !== false ? x : "none",
970
+ fillOpacity: 0.15,
971
+ stroke: x,
972
+ strokeWidth: 2
973
+ }
974
+ ),
975
+ m.data.map((s, T) => {
976
+ const g = h(T, s);
977
+ return /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: g.x, cy: g.y, r: 3, fill: x, children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${m.name} - ${o[T]}: ${s}` }) }, T);
978
+ })
979
+ ] }, m.name);
980
+ }),
981
+ f && /* @__PURE__ */ jsxRuntime.jsx("g", { transform: `translate(10, ${i - 25})`, children: t.map((m, L) => /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: `translate(${L * 100}, 0)`, children: [
982
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { width: 10, height: 10, rx: 2, fill: m.color || me[L % me.length] }),
983
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: m.name })
984
+ ] }, L)) })
985
+ ] }) });
986
+ }, xt = ({
987
+ value: t,
988
+ min: o = 0,
989
+ max: l = 100,
990
+ width: i = 200,
991
+ height: c = 200,
992
+ startAngle: b = 225,
993
+ endAngle: f = -45,
994
+ color: w = "#3b82f6",
995
+ trackColor: B,
996
+ label: p,
997
+ formatValue: S,
998
+ ranges: N,
999
+ className: z,
1000
+ style: M
1001
+ }) => {
1002
+ const v = i / 2, u = c / 2, h = Math.min(v, u) - 20, m = Math.max(0, Math.min(1, (t - o) / (l - o || 1))), L = (d) => d * Math.PI / 180, x = (b - f + 360) % 360 || 360, y = (d) => ({
1003
+ x: v + h * Math.cos(L(d)),
1004
+ y: u - h * Math.sin(L(d))
1005
+ }), s = (d, $) => {
1006
+ const A = y(d), O = y($), R = (d - $ + 360) % 360 > 180 ? 1 : 0;
1007
+ return `M${A.x},${A.y} A${h},${h} 0 ${R},1 ${O.x},${O.y}`;
1008
+ }, T = b - m * x, g = y(T);
1009
+ let C = w;
1010
+ if (N) {
1011
+ for (const d of N)
1012
+ if (t >= d.start && t <= d.end) {
1013
+ C = d.color;
1014
+ break;
1015
+ }
1016
+ }
1017
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-gauge nice-gauge--circular ${z || ""}`, style: M, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: i, height: c, children: [
1018
+ /* @__PURE__ */ jsxRuntime.jsx(
1019
+ "path",
1020
+ {
1021
+ d: s(b, f),
1022
+ fill: "none",
1023
+ stroke: B || "var(--border-color, #e2e8f0)",
1024
+ strokeWidth: 12,
1025
+ strokeLinecap: "round"
1026
+ }
1027
+ ),
1028
+ m > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1029
+ "path",
1030
+ {
1031
+ d: s(b, T),
1032
+ fill: "none",
1033
+ stroke: C,
1034
+ strokeWidth: 12,
1035
+ strokeLinecap: "round"
1036
+ }
1037
+ ),
1038
+ /* @__PURE__ */ jsxRuntime.jsx(
1039
+ "line",
1040
+ {
1041
+ x1: v,
1042
+ y1: u,
1043
+ x2: g.x,
1044
+ y2: g.y,
1045
+ stroke: "var(--text-primary, #333)",
1046
+ strokeWidth: 2,
1047
+ strokeLinecap: "round"
1048
+ }
1049
+ ),
1050
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: v, cy: u, r: 4, fill: "var(--text-primary, #333)" }),
1051
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: v, y: u + h * 0.35, textAnchor: "middle", className: "nice-gauge__value", children: S ? S(t) : t }),
1052
+ p && /* @__PURE__ */ jsxRuntime.jsx("text", { x: v, y: u + h * 0.55, textAnchor: "middle", className: "nice-gauge__label", children: p })
1053
+ ] }) });
1054
+ }, yt = ({
1055
+ value: t,
1056
+ min: o = 0,
1057
+ max: l = 100,
1058
+ width: i = 300,
1059
+ height: c = 60,
1060
+ orientation: b = "horizontal",
1061
+ color: f = "#3b82f6",
1062
+ label: w,
1063
+ formatValue: B,
1064
+ ranges: p,
1065
+ showTicks: S = true,
1066
+ tickCount: N = 5,
1067
+ className: z,
1068
+ style: M
1069
+ }) => {
1070
+ const v = b === "horizontal", u = v ? i - 40 : c - 40, h = Math.max(0, Math.min(1, (t - o) / (l - o || 1))), m = 10;
1071
+ let L = f;
1072
+ if (p) {
1073
+ for (const y of p)
1074
+ if (t >= y.start && t <= y.end) {
1075
+ L = y.color;
1076
+ break;
1077
+ }
1078
+ }
1079
+ const x = Array.from(
1080
+ { length: N },
1081
+ (y, s) => o + (l - o) * (s / (N - 1))
1082
+ );
1083
+ return v ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-gauge nice-gauge--linear ${z || ""}`, style: M, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: i, height: c, children: [
1084
+ w && /* @__PURE__ */ jsxRuntime.jsx("text", { x: i / 2, y: 14, textAnchor: "middle", className: "nice-gauge__label", children: w }),
1085
+ /* @__PURE__ */ jsxRuntime.jsx(
1086
+ "rect",
1087
+ {
1088
+ x: 20,
1089
+ y: c / 2 - m / 2,
1090
+ width: u,
1091
+ height: m,
1092
+ rx: 5,
1093
+ fill: "var(--border-color, #e2e8f0)"
1094
+ }
1095
+ ),
1096
+ /* @__PURE__ */ jsxRuntime.jsx(
1097
+ "rect",
1098
+ {
1099
+ x: 20,
1100
+ y: c / 2 - m / 2,
1101
+ width: u * h,
1102
+ height: m,
1103
+ rx: 5,
1104
+ fill: L
1105
+ }
1106
+ ),
1107
+ /* @__PURE__ */ jsxRuntime.jsx(
1108
+ "polygon",
1109
+ {
1110
+ points: `${20 + u * h},${c / 2 - m / 2 - 2} ${20 + u * h - 5},${c / 2 - m / 2 - 10} ${20 + u * h + 5},${c / 2 - m / 2 - 10}`,
1111
+ fill: "var(--text-primary, #333)"
1112
+ }
1113
+ ),
1114
+ /* @__PURE__ */ jsxRuntime.jsx(
1115
+ "text",
1116
+ {
1117
+ x: 20 + u * h,
1118
+ y: c / 2 - m / 2 - 12,
1119
+ textAnchor: "middle",
1120
+ className: "nice-gauge__value",
1121
+ style: { fontSize: 11 },
1122
+ children: B ? B(t) : t
1123
+ }
1124
+ ),
1125
+ S && x.map((y, s) => {
1126
+ const T = 20 + (y - o) / (l - o) * u;
1127
+ return /* @__PURE__ */ jsxRuntime.jsx(
1128
+ "text",
1129
+ {
1130
+ x: T,
1131
+ y: c / 2 + m / 2 + 14,
1132
+ textAnchor: "middle",
1133
+ className: "nice-gauge__tick",
1134
+ children: y
1135
+ },
1136
+ s
1137
+ );
1138
+ })
1139
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
1140
+ "div",
1141
+ {
1142
+ className: `nice-gauge nice-gauge--linear nice-gauge--vertical ${z || ""}`,
1143
+ style: M,
1144
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: i, height: c, children: [
1145
+ /* @__PURE__ */ jsxRuntime.jsx(
1146
+ "rect",
1147
+ {
1148
+ x: i / 2 - m / 2,
1149
+ y: 20,
1150
+ width: m,
1151
+ height: u,
1152
+ rx: 5,
1153
+ fill: "var(--border-color, #e2e8f0)"
1154
+ }
1155
+ ),
1156
+ /* @__PURE__ */ jsxRuntime.jsx(
1157
+ "rect",
1158
+ {
1159
+ x: i / 2 - m / 2,
1160
+ y: 20 + u * (1 - h),
1161
+ width: m,
1162
+ height: u * h,
1163
+ rx: 5,
1164
+ fill: L
1165
+ }
1166
+ ),
1167
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: i / 2, y: 14, textAnchor: "middle", className: "nice-gauge__value", children: B ? B(t) : t }),
1168
+ w && /* @__PURE__ */ jsxRuntime.jsx("text", { x: i / 2, y: c - 4, textAnchor: "middle", className: "nice-gauge__label", children: w })
1169
+ ] })
1170
+ }
1171
+ );
1172
+ }, bt = ({
1173
+ items: t,
1174
+ min: o = 0,
1175
+ max: l = 100,
1176
+ width: i = 300,
1177
+ height: c = 300,
1178
+ startAngle: b = 225,
1179
+ endAngle: f = -45,
1180
+ formatValue: w,
1181
+ title: B,
1182
+ className: p,
1183
+ style: S
1184
+ }) => {
1185
+ const N = i / 2, z = c / 2, M = Math.min(N, z) - 30, v = Math.min(20, M / (t.length + 1)), u = 4, h = (x) => x * Math.PI / 180, m = (b - f + 360) % 360 || 360, L = (x, y, s) => {
1186
+ const T = N + x * Math.cos(h(y)), g = z - x * Math.sin(h(y)), C = N + x * Math.cos(h(s)), d = z - x * Math.sin(h(s)), $ = (y - s + 360) % 360;
1187
+ return `M${T},${g} A${x},${x} 0 ${$ > 180 ? 1 : 0},1 ${C},${d}`;
1188
+ };
1189
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-bargauge ${p || ""}`, style: S, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: i, height: c, children: [
1190
+ B && /* @__PURE__ */ jsxRuntime.jsx("text", { x: N, y: 20, textAnchor: "middle", className: "nice-chart__title", children: B }),
1191
+ t.map((x, y) => {
1192
+ const s = M - y * (v + u), T = Math.max(0, Math.min(1, (x.value - o) / (l - o || 1))), g = b - T * m, C = x.color || me[y % me.length];
1193
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
1194
+ /* @__PURE__ */ jsxRuntime.jsx(
1195
+ "path",
1196
+ {
1197
+ d: L(s, b, f),
1198
+ fill: "none",
1199
+ stroke: "var(--border-color, #e2e8f0)",
1200
+ strokeWidth: v,
1201
+ strokeLinecap: "round"
1202
+ }
1203
+ ),
1204
+ T > 0 && /* @__PURE__ */ jsxRuntime.jsx(
1205
+ "path",
1206
+ {
1207
+ d: L(s, b, g),
1208
+ fill: "none",
1209
+ stroke: C,
1210
+ strokeWidth: v,
1211
+ strokeLinecap: "round"
1212
+ }
1213
+ )
1214
+ ] }, y);
1215
+ }),
1216
+ /* @__PURE__ */ jsxRuntime.jsx("g", { children: t.map((x, y) => /* @__PURE__ */ jsxRuntime.jsxs(
1217
+ "text",
1218
+ {
1219
+ x: N,
1220
+ y: z - ((t.length - 1) / 2 - y) * 16,
1221
+ textAnchor: "middle",
1222
+ dominantBaseline: "middle",
1223
+ className: "nice-gauge__value",
1224
+ style: { fontSize: 12 },
1225
+ children: [
1226
+ x.label ? `${x.label}: ` : "",
1227
+ w ? w(x.value) : x.value
1228
+ ]
1229
+ },
1230
+ y
1231
+ )) })
1232
+ ] }) });
1233
+ }, vt = ({
1234
+ data: t,
1235
+ width: o = 120,
1236
+ height: l = 30,
1237
+ type: i = "line",
1238
+ color: c = "#3b82f6",
1239
+ showMinMax: b,
1240
+ showLastPoint: f = true,
1241
+ className: w,
1242
+ style: B
1243
+ }) => {
1244
+ if (t.length === 0)
1245
+ return null;
1246
+ const p = 2, S = Math.min(...t), N = Math.max(...t), z = N - S || 1, M = o - p * 2, v = l - p * 2, u = (s) => p + s / (t.length - 1 || 1) * M, h = (s) => p + v - (s - S) / z * v;
1247
+ if (i === "bar") {
1248
+ const s = Math.max(1, M / t.length - 1);
1249
+ return /* @__PURE__ */ jsxRuntime.jsx(
1250
+ "svg",
1251
+ {
1252
+ width: o,
1253
+ height: l,
1254
+ className: `nice-sparkline ${w || ""}`,
1255
+ style: B,
1256
+ children: t.map((T, g) => /* @__PURE__ */ jsxRuntime.jsx(
1257
+ "rect",
1258
+ {
1259
+ x: p + g / t.length * M,
1260
+ y: h(T),
1261
+ width: s,
1262
+ height: v - (h(T) - p),
1263
+ fill: c,
1264
+ rx: 1
1265
+ },
1266
+ g
1267
+ ))
1268
+ }
1269
+ );
1270
+ }
1271
+ const m = t.map((s, T) => `${u(T)},${h(s)}`).join(" "), L = t.indexOf(S), x = t.indexOf(N), y = t.length - 1;
1272
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1273
+ "svg",
1274
+ {
1275
+ width: o,
1276
+ height: l,
1277
+ className: `nice-sparkline ${w || ""}`,
1278
+ style: B,
1279
+ children: [
1280
+ i === "area" && /* @__PURE__ */ jsxRuntime.jsx(
1281
+ "polygon",
1282
+ {
1283
+ points: `${u(0)},${p + v} ${m} ${u(y)},${p + v}`,
1284
+ fill: c,
1285
+ opacity: 0.15
1286
+ }
1287
+ ),
1288
+ /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: m, fill: "none", stroke: c, strokeWidth: 1.5 }),
1289
+ b && /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: u(L), cy: h(S), r: 2, fill: "#ef4444" }),
1290
+ b && /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: u(x), cy: h(N), r: 2, fill: "#22c55e" }),
1291
+ f && /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: u(y), cy: h(t[y]), r: 2, fill: c })
1292
+ ]
1293
+ }
1294
+ );
1295
+ }, _t = ({
1296
+ value: t,
1297
+ target: o,
1298
+ min: l = 0,
1299
+ max: i = 100,
1300
+ width: c = 200,
1301
+ height: b = 30,
1302
+ color: f = "#3b82f6",
1303
+ targetColor: w = "#ef4444",
1304
+ className: B,
1305
+ style: p
1306
+ }) => {
1307
+ const N = c - 8, z = b - 8, M = Math.max(0, Math.min(1, (t - l) / (i - l || 1))), v = o != null ? Math.max(0, Math.min(1, (o - l) / (i - l || 1))) : null;
1308
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: c, height: b, className: `nice-bullet ${B || ""}`, style: p, children: [
1309
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: 4, y: 4, width: N, height: z, rx: 3, fill: "var(--border-color, #e2e8f0)" }),
1310
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: 4, y: 4 + z * 0.2, width: N * M, height: z * 0.6, rx: 2, fill: f }),
1311
+ v != null && /* @__PURE__ */ jsxRuntime.jsx(
1312
+ "line",
1313
+ {
1314
+ x1: 4 + N * v,
1315
+ y1: 6,
1316
+ x2: 4 + N * v,
1317
+ y2: 4 + z - 2,
1318
+ stroke: w,
1319
+ strokeWidth: 2
1320
+ }
1321
+ )
1322
+ ] });
1323
+ }, wt = ({
1324
+ data: t,
1325
+ width: o = 400,
1326
+ height: l = 300,
1327
+ inverted: i,
1328
+ showLabels: c = true,
1329
+ showValues: b = true,
1330
+ title: f,
1331
+ className: w,
1332
+ style: B
1333
+ }) => {
1334
+ const p = { top: f ? 30 : 10, bottom: 10, x: 40 }, S = o - p.x * 2, N = l - p.top - p.bottom, z = i ? [...t].reverse() : t, M = Math.max(...z.map((u) => u.value), 1), v = N / z.length;
1335
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-funnel ${w || ""}`, style: B, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: o, height: l, children: [
1336
+ f && /* @__PURE__ */ jsxRuntime.jsx("text", { x: o / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: f }),
1337
+ z.map((u, h) => {
1338
+ const m = u.value / M * S, L = h < z.length - 1 ? z[h + 1].value / M * S : m * 0.3, x = p.top + h * v, y = x + v, s = o / 2, T = `${s - m / 2},${x} ${s + m / 2},${x} ${s + L / 2},${y} ${s - L / 2},${y}`, g = u.color || me[h % me.length];
1339
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
1340
+ /* @__PURE__ */ jsxRuntime.jsx(
1341
+ "polygon",
1342
+ {
1343
+ points: T,
1344
+ fill: g,
1345
+ stroke: "var(--bg-primary, #fff)",
1346
+ strokeWidth: 1,
1347
+ children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${u.label}: ${u.value}` })
1348
+ }
1349
+ ),
1350
+ c && /* @__PURE__ */ jsxRuntime.jsx(
1351
+ "text",
1352
+ {
1353
+ x: s,
1354
+ y: x + v / 2 - (b ? 4 : 0),
1355
+ textAnchor: "middle",
1356
+ dominantBaseline: "middle",
1357
+ className: "nice-funnel__label",
1358
+ children: u.label
1359
+ }
1360
+ ),
1361
+ b && /* @__PURE__ */ jsxRuntime.jsx(
1362
+ "text",
1363
+ {
1364
+ x: s,
1365
+ y: x + v / 2 + 10,
1366
+ textAnchor: "middle",
1367
+ dominantBaseline: "middle",
1368
+ className: "nice-funnel__value",
1369
+ children: u.value
1370
+ }
1371
+ )
1372
+ ] }, h);
1373
+ })
1374
+ ] }) });
1375
+ }, qe = ({
1376
+ nodes: t,
1377
+ links: o,
1378
+ width: l = 600,
1379
+ height: i = 400,
1380
+ nodeWidth: c = 20,
1381
+ nodePadding: b = 10,
1382
+ title: f,
1383
+ className: w,
1384
+ style: B
1385
+ }) => {
1386
+ const p = { top: f ? 40 : 20, bottom: 20, left: 20, right: 20 }, S = l - p.left - p.right, N = i - p.top - p.bottom, z = new Set(o.map((d) => d.source)), M = new Set(o.map((d) => d.target)), v = t.filter((d) => z.has(d.id) && !M.has(d.id)), u = t.filter((d) => M.has(d.id)), h = t.filter((d) => z.has(d.id) && M.has(d.id)), m = [v, ...h.length ? [h] : [], u].filter(
1387
+ (d) => d.length > 0
1388
+ ), L = m.length, x = /* @__PURE__ */ new Map();
1389
+ t.forEach((d) => {
1390
+ const $ = o.filter((O) => O.source === d.id).reduce((O, X) => O + X.value, 0), A = o.filter((O) => O.target === d.id).reduce((O, X) => O + X.value, 0);
1391
+ x.set(d.id, Math.max($, A));
1392
+ });
1393
+ const y = m.map(
1394
+ (d) => d.reduce(($, A) => $ + (x.get(A.id) || 0), 0) + (d.length - 1) * b
1395
+ ), s = Math.max(...y, 1), T = /* @__PURE__ */ new Map();
1396
+ m.forEach((d, $) => {
1397
+ const A = p.left + $ / (L - 1 || 1) * (S - c);
1398
+ let O = 0;
1399
+ d.forEach((X) => {
1400
+ const R = (x.get(X.id) || 0) / s * N;
1401
+ T.set(X.id, { x: A, y: p.top + O, h: R }), O += R + b;
1402
+ });
1403
+ });
1404
+ const g = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map();
1405
+ return t.forEach((d) => {
1406
+ g.set(d.id, 0), C.set(d.id, 0);
1407
+ }), /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-sankey ${w || ""}`, style: B, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: l, height: i, children: [
1408
+ f && /* @__PURE__ */ jsxRuntime.jsx("text", { x: l / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: f }),
1409
+ o.map((d, $) => {
1410
+ const A = T.get(d.source), O = T.get(d.target);
1411
+ if (!A || !O)
1412
+ return null;
1413
+ const X = g.get(d.source) || 0, R = C.get(d.target) || 0, Y = d.value / s * N;
1414
+ g.set(d.source, X + Y), C.set(d.target, R + Y);
1415
+ const q = A.x + c, J = A.y + X, V = O.x, Q = O.y + R, r = (q + V) / 2, H = t.find((k) => k.id === d.source)?.color || me[$ % me.length];
1416
+ return /* @__PURE__ */ jsxRuntime.jsx(
1417
+ "path",
1418
+ {
1419
+ d: `M${q},${J} C${r},${J} ${r},${Q} ${V},${Q} L${V},${Q + Y} C${r},${Q + Y} ${r},${J + Y} ${q},${J + Y} Z`,
1420
+ fill: H,
1421
+ fillOpacity: 0.3,
1422
+ stroke: H,
1423
+ strokeOpacity: 0.5,
1424
+ strokeWidth: 0.5,
1425
+ children: /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${d.source} → ${d.target}: ${d.value}` })
1426
+ },
1427
+ $
1428
+ );
1429
+ }),
1430
+ t.map((d, $) => {
1431
+ const A = T.get(d.id);
1432
+ if (!A)
1433
+ return null;
1434
+ const O = d.color || me[$ % me.length];
1435
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
1436
+ /* @__PURE__ */ jsxRuntime.jsx(
1437
+ "rect",
1438
+ {
1439
+ x: A.x,
1440
+ y: A.y,
1441
+ width: c,
1442
+ height: Math.max(A.h, 2),
1443
+ fill: O,
1444
+ rx: 2
1445
+ }
1446
+ ),
1447
+ /* @__PURE__ */ jsxRuntime.jsx(
1448
+ "text",
1449
+ {
1450
+ x: A.x < S / 2 ? A.x + c + 4 : A.x - 4,
1451
+ y: A.y + A.h / 2,
1452
+ textAnchor: A.x < S / 2 ? "start" : "end",
1453
+ dominantBaseline: "middle",
1454
+ className: "nice-chart__legend-text",
1455
+ children: d.label
1456
+ }
1457
+ )
1458
+ ] }, d.id);
1459
+ })
1460
+ ] }) });
1461
+ }, Nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1462
+ __proto__: null,
1463
+ NiceSankey: qe
1464
+ }, Symbol.toStringTag, { value: "Module" })), Mt = ({
1465
+ data: t,
1466
+ min: o,
1467
+ max: l,
1468
+ start: i,
1469
+ end: c,
1470
+ onChange: b,
1471
+ width: f = 500,
1472
+ height: w = 100,
1473
+ step: B = 1,
1474
+ formatValue: p,
1475
+ chartColor: S = "#3b82f6",
1476
+ className: N,
1477
+ style: z
1478
+ }) => {
1479
+ const M = { top: 10, bottom: 30, left: 10, right: 10 }, v = f - M.left - M.right, u = w - M.top - M.bottom, h = (T) => M.left + (T - o) / (l - o || 1) * v, m = (T) => {
1480
+ const g = Math.max(0, Math.min(1, (T - M.left) / v)), C = o + g * (l - o);
1481
+ return Math.round(C / B) * B;
1482
+ }, L = (T, g) => {
1483
+ g.preventDefault();
1484
+ const C = g.target.closest("svg");
1485
+ if (!C)
1486
+ return;
1487
+ const d = (A) => {
1488
+ const O = C.getBoundingClientRect(), X = m(A.clientX - O.left);
1489
+ T === "start" ? b(Math.min(X, c), c) : b(i, Math.max(X, i));
1490
+ }, $ = () => {
1491
+ document.removeEventListener("pointermove", d), document.removeEventListener("pointerup", $);
1492
+ };
1493
+ document.addEventListener("pointermove", d), document.addEventListener("pointerup", $);
1494
+ }, x = t ? Math.min(...t) : 0, s = (t ? Math.max(...t) : 1) - x || 1;
1495
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-rangeselector ${N || ""}`, style: z, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: f, height: w, children: [
1496
+ t && t.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
1497
+ "polygon",
1498
+ {
1499
+ points: `${M.left},${M.top + u} ${t.map((T, g) => `${M.left + g / (t.length - 1) * v},${M.top + u - (T - x) / s * u}`).join(" ")} ${M.left + v},${M.top + u}`,
1500
+ fill: S,
1501
+ opacity: 0.15
1502
+ }
1503
+ ),
1504
+ /* @__PURE__ */ jsxRuntime.jsx(
1505
+ "rect",
1506
+ {
1507
+ x: h(i),
1508
+ y: M.top,
1509
+ width: h(c) - h(i),
1510
+ height: u,
1511
+ fill: S,
1512
+ opacity: 0.1
1513
+ }
1514
+ ),
1515
+ /* @__PURE__ */ jsxRuntime.jsx(
1516
+ "rect",
1517
+ {
1518
+ x: M.left,
1519
+ y: M.top,
1520
+ width: h(i) - M.left,
1521
+ height: u,
1522
+ fill: "var(--bg-secondary, #f5f5f5)",
1523
+ opacity: 0.6
1524
+ }
1525
+ ),
1526
+ /* @__PURE__ */ jsxRuntime.jsx(
1527
+ "rect",
1528
+ {
1529
+ x: h(c),
1530
+ y: M.top,
1531
+ width: M.left + v - h(c),
1532
+ height: u,
1533
+ fill: "var(--bg-secondary, #f5f5f5)",
1534
+ opacity: 0.6
1535
+ }
1536
+ ),
1537
+ /* @__PURE__ */ jsxRuntime.jsx(
1538
+ "rect",
1539
+ {
1540
+ x: h(i) - 4,
1541
+ y: M.top,
1542
+ width: 8,
1543
+ height: u,
1544
+ fill: S,
1545
+ rx: 2,
1546
+ cursor: "ew-resize",
1547
+ onPointerDown: (T) => L("start", T)
1548
+ }
1549
+ ),
1550
+ /* @__PURE__ */ jsxRuntime.jsx(
1551
+ "rect",
1552
+ {
1553
+ x: h(c) - 4,
1554
+ y: M.top,
1555
+ width: 8,
1556
+ height: u,
1557
+ fill: S,
1558
+ rx: 2,
1559
+ cursor: "ew-resize",
1560
+ onPointerDown: (T) => L("end", T)
1561
+ }
1562
+ ),
1563
+ /* @__PURE__ */ jsxRuntime.jsx(
1564
+ "text",
1565
+ {
1566
+ x: h(i),
1567
+ y: M.top + u + 18,
1568
+ textAnchor: "middle",
1569
+ className: "nice-chart__axis-label",
1570
+ children: p ? p(i) : i
1571
+ }
1572
+ ),
1573
+ /* @__PURE__ */ jsxRuntime.jsx(
1574
+ "text",
1575
+ {
1576
+ x: h(c),
1577
+ y: M.top + u + 18,
1578
+ textAnchor: "middle",
1579
+ className: "nice-chart__axis-label",
1580
+ children: p ? p(c) : c
1581
+ }
1582
+ )
1583
+ ] }) });
1584
+ }, Je = ({
1585
+ regions: t,
1586
+ width: o = 600,
1587
+ height: l = 400,
1588
+ viewBox: i = "0 0 1000 600",
1589
+ colorRange: c = ["#dbeafe", "#1d4ed8"],
1590
+ maxValue: b,
1591
+ onRegionClick: f,
1592
+ selectedRegionId: w,
1593
+ title: B,
1594
+ showTooltip: p = true,
1595
+ className: S,
1596
+ style: N
1597
+ }) => {
1598
+ const z = b ?? Math.max(...t.map((v) => v.value ?? 0), 1), M = (v) => {
1599
+ const u = (d) => [
1600
+ parseInt(d.slice(1, 3), 16),
1601
+ parseInt(d.slice(3, 5), 16),
1602
+ parseInt(d.slice(5, 7), 16)
1603
+ ], [h, m, L] = u(c[0]), [x, y, s] = u(c[1]), T = Math.round(h + (x - h) * v), g = Math.round(m + (y - m) * v), C = Math.round(L + (s - L) * v);
1604
+ return `rgb(${T},${g},${C})`;
1605
+ };
1606
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `nice-vectormap ${S || ""}`, style: N, children: [
1607
+ B && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-vectormap__title", children: B }),
1608
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { width: o, height: l, viewBox: i, children: t.map((v) => {
1609
+ const u = v.value != null ? Math.max(0, Math.min(1, v.value / z)) : 0, h = v.value != null ? M(u) : "var(--bg-tertiary, #e5e7eb)", m = v.id === w;
1610
+ return /* @__PURE__ */ jsxRuntime.jsx(
1611
+ "path",
1612
+ {
1613
+ d: v.path,
1614
+ fill: h,
1615
+ stroke: m ? "var(--color-primary, #3b82f6)" : "var(--border-color, #d1d5db)",
1616
+ strokeWidth: m ? 2 : 0.5,
1617
+ cursor: f ? "pointer" : void 0,
1618
+ onClick: () => f?.(v),
1619
+ children: p && /* @__PURE__ */ jsxRuntime.jsx("title", { children: `${v.name}${v.value != null ? `: ${v.value}` : ""}` })
1620
+ },
1621
+ v.id
1622
+ );
1623
+ }) })
1624
+ ] });
1625
+ }, $t = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1626
+ __proto__: null,
1627
+ NiceVectorMap: Je
1628
+ }, Symbol.toStringTag, { value: "Module" })), Qe = `
1629
+ .nice-forecast-chart {
1630
+ display: flex;
1631
+ flex-direction: column;
1632
+ background: var(--nice-bg-primary, #ffffff);
1633
+ border: 1px solid var(--nice-border-color, #e5e7eb);
1634
+ border-radius: 0.5rem;
1635
+ overflow: hidden;
1636
+ }
1637
+
1638
+ .nice-forecast-chart__header {
1639
+ display: flex;
1640
+ align-items: center;
1641
+ justify-content: space-between;
1642
+ padding: 0.75rem 1rem;
1643
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
1644
+ }
1645
+
1646
+ .nice-forecast-chart__title {
1647
+ font-size: 1rem;
1648
+ font-weight: 600;
1649
+ color: var(--nice-text-primary);
1650
+ margin: 0;
1651
+ }
1652
+
1653
+ .nice-forecast-chart__actions {
1654
+ display: flex;
1655
+ gap: 0.5rem;
1656
+ }
1657
+
1658
+ .nice-forecast-chart__btn {
1659
+ display: inline-flex;
1660
+ align-items: center;
1661
+ justify-content: center;
1662
+ width: 2rem;
1663
+ height: 2rem;
1664
+ font-size: 1rem;
1665
+ border-radius: 0.375rem;
1666
+ cursor: pointer;
1667
+ transition: all 0.15s ease;
1668
+ border: 1px solid var(--nice-border-color, #d1d5db);
1669
+ background: var(--nice-bg-primary, #ffffff);
1670
+ color: var(--nice-text-secondary);
1671
+ }
1672
+
1673
+ .nice-forecast-chart__btn:hover {
1674
+ background: var(--nice-bg-hover, #f3f4f6);
1675
+ color: var(--nice-text-primary);
1676
+ }
1677
+
1678
+ .nice-forecast-chart__btn:disabled {
1679
+ opacity: 0.5;
1680
+ cursor: not-allowed;
1681
+ }
1682
+
1683
+ .nice-forecast-chart__container {
1684
+ position: relative;
1685
+ width: 100%;
1686
+ padding: 1rem;
1687
+ }
1688
+
1689
+ .nice-forecast-chart__svg {
1690
+ width: 100%;
1691
+ overflow: visible;
1692
+ }
1693
+
1694
+ .nice-forecast-chart__grid-line {
1695
+ stroke: var(--nice-border-divider, #f3f4f6);
1696
+ stroke-width: 1;
1697
+ }
1698
+
1699
+ .nice-forecast-chart__axis-line {
1700
+ stroke: var(--nice-border-color, #e5e7eb);
1701
+ stroke-width: 1;
1702
+ }
1703
+
1704
+ .nice-forecast-chart__axis-label {
1705
+ font-size: 0.6875rem;
1706
+ fill: var(--nice-text-secondary);
1707
+ }
1708
+
1709
+ .nice-forecast-chart__axis-title {
1710
+ font-size: 0.75rem;
1711
+ font-weight: 500;
1712
+ fill: var(--nice-text-primary);
1713
+ }
1714
+
1715
+ .nice-forecast-chart__historical-line {
1716
+ fill: none;
1717
+ stroke-width: 2;
1718
+ stroke-linecap: round;
1719
+ stroke-linejoin: round;
1720
+ }
1721
+
1722
+ .nice-forecast-chart__forecast-line {
1723
+ fill: none;
1724
+ stroke-width: 2;
1725
+ stroke-linecap: round;
1726
+ stroke-linejoin: round;
1727
+ stroke-dasharray: 6, 4;
1728
+ }
1729
+
1730
+ .nice-forecast-chart__confidence-band {
1731
+ opacity: 0.2;
1732
+ }
1733
+
1734
+ .nice-forecast-chart__forecast-region {
1735
+ fill: var(--nice-bg-secondary, #f9fafb);
1736
+ opacity: 0.5;
1737
+ }
1738
+
1739
+ .nice-forecast-chart__point {
1740
+ cursor: pointer;
1741
+ transition: r 0.15s ease;
1742
+ }
1743
+
1744
+ .nice-forecast-chart__point:hover {
1745
+ r: 6;
1746
+ }
1747
+
1748
+ .nice-forecast-chart__annotation-line {
1749
+ stroke-dasharray: 4, 2;
1750
+ stroke-width: 1;
1751
+ }
1752
+
1753
+ .nice-forecast-chart__annotation-marker {
1754
+ cursor: pointer;
1755
+ transition: transform 0.15s ease;
1756
+ }
1757
+
1758
+ .nice-forecast-chart__annotation-marker:hover {
1759
+ transform: scale(1.2);
1760
+ }
1761
+
1762
+ .nice-forecast-chart__reference-line {
1763
+ stroke-width: 1;
1764
+ }
1765
+
1766
+ .nice-forecast-chart__reference-label {
1767
+ font-size: 0.625rem;
1768
+ fill: var(--nice-text-secondary);
1769
+ }
1770
+
1771
+ .nice-forecast-chart__cash-runway {
1772
+ pointer-events: none;
1773
+ }
1774
+
1775
+ .nice-forecast-chart__cash-runway-line {
1776
+ stroke: #ef4444;
1777
+ stroke-width: 2;
1778
+ stroke-dasharray: 8, 4;
1779
+ }
1780
+
1781
+ .nice-forecast-chart__cash-runway-label-bg {
1782
+ fill: #ef4444;
1783
+ rx: 4;
1784
+ }
1785
+
1786
+ .nice-forecast-chart__cash-runway-label {
1787
+ font-size: 0.6875rem;
1788
+ font-weight: 600;
1789
+ fill: #ffffff;
1790
+ }
1791
+
1792
+ .nice-forecast-chart__cash-runway-date {
1793
+ font-size: 0.625rem;
1794
+ fill: #ef4444;
1795
+ font-weight: 500;
1796
+ }
1797
+
1798
+ .nice-forecast-chart__tooltip {
1799
+ position: absolute;
1800
+ pointer-events: none;
1801
+ z-index: 100;
1802
+ padding: 0.75rem;
1803
+ background: var(--nice-bg-primary, #ffffff);
1804
+ border: 1px solid var(--nice-border-color, #e5e7eb);
1805
+ border-radius: 0.5rem;
1806
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
1807
+ font-size: 0.8125rem;
1808
+ max-width: 250px;
1809
+ }
1810
+
1811
+ .nice-forecast-chart__tooltip-date {
1812
+ font-weight: 600;
1813
+ color: var(--nice-text-primary);
1814
+ margin-bottom: 0.5rem;
1815
+ padding-bottom: 0.5rem;
1816
+ border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
1817
+ }
1818
+
1819
+ .nice-forecast-chart__tooltip-item {
1820
+ display: flex;
1821
+ align-items: center;
1822
+ gap: 0.5rem;
1823
+ margin-bottom: 0.25rem;
1824
+ }
1825
+
1826
+ .nice-forecast-chart__tooltip-color {
1827
+ width: 10px;
1828
+ height: 10px;
1829
+ border-radius: 2px;
1830
+ flex-shrink: 0;
1831
+ }
1832
+
1833
+ .nice-forecast-chart__tooltip-label {
1834
+ color: var(--nice-text-secondary);
1835
+ flex: 1;
1836
+ }
1837
+
1838
+ .nice-forecast-chart__tooltip-value {
1839
+ font-weight: 600;
1840
+ color: var(--nice-text-primary);
1841
+ font-variant-numeric: tabular-nums;
1842
+ }
1843
+
1844
+ .nice-forecast-chart__tooltip-confidence {
1845
+ font-size: 0.75rem;
1846
+ color: var(--nice-text-tertiary);
1847
+ }
1848
+
1849
+ .nice-forecast-chart__legend {
1850
+ display: flex;
1851
+ flex-wrap: wrap;
1852
+ gap: 1rem;
1853
+ padding: 0.75rem 1rem;
1854
+ border-top: 1px solid var(--nice-border-color, #e5e7eb);
1855
+ }
1856
+
1857
+ .nice-forecast-chart__legend-item {
1858
+ display: flex;
1859
+ align-items: center;
1860
+ gap: 0.375rem;
1861
+ font-size: 0.8125rem;
1862
+ color: var(--nice-text-secondary);
1863
+ cursor: pointer;
1864
+ user-select: none;
1865
+ transition: opacity 0.15s ease;
1866
+ }
1867
+
1868
+ .nice-forecast-chart__legend-item:hover {
1869
+ color: var(--nice-text-primary);
1870
+ }
1871
+
1872
+ .nice-forecast-chart__legend-item--hidden {
1873
+ opacity: 0.4;
1874
+ }
1875
+
1876
+ .nice-forecast-chart__legend-color {
1877
+ width: 16px;
1878
+ height: 3px;
1879
+ border-radius: 1px;
1880
+ }
1881
+
1882
+ .nice-forecast-chart__legend-color--dashed {
1883
+ background: repeating-linear-gradient(
1884
+ 90deg,
1885
+ currentColor,
1886
+ currentColor 4px,
1887
+ transparent 4px,
1888
+ transparent 6px
1889
+ );
1890
+ }
1891
+
1892
+ .nice-forecast-chart__empty {
1893
+ display: flex;
1894
+ align-items: center;
1895
+ justify-content: center;
1896
+ height: 300px;
1897
+ color: var(--nice-text-secondary);
1898
+ }
1899
+
1900
+ /* Dark mode */
1901
+ .dark .nice-forecast-chart {
1902
+ background: var(--nice-bg-primary-dark, #111827);
1903
+ border-color: var(--nice-border-color-dark, #374151);
1904
+ }
1905
+
1906
+ .dark .nice-forecast-chart__tooltip {
1907
+ background: var(--nice-bg-secondary-dark, #1f2937);
1908
+ border-color: var(--nice-border-color-dark, #374151);
1909
+ }
1910
+
1911
+ .dark .nice-forecast-chart__forecast-region {
1912
+ fill: var(--nice-bg-secondary-dark, #1f2937);
1913
+ }
1914
+ `, Te = [
1915
+ "#3b82f6",
1916
+ // blue
1917
+ "#10b981",
1918
+ // green
1919
+ "#f59e0b",
1920
+ // amber
1921
+ "#ef4444",
1922
+ // red
1923
+ "#8b5cf6",
1924
+ // purple
1925
+ "#ec4899",
1926
+ // pink
1927
+ "#06b6d4",
1928
+ // cyan
1929
+ "#f97316"
1930
+ // orange
1931
+ ];
1932
+ function pe(t) {
1933
+ return t instanceof Date ? t : new Date(t);
1934
+ }
1935
+ function Le(t, o = "pl-PL") {
1936
+ return t.toLocaleDateString(o, {
1937
+ year: "numeric",
1938
+ month: "short",
1939
+ day: "numeric"
1940
+ });
1941
+ }
1942
+ function $e(t, o = "pl-PL") {
1943
+ return new Intl.NumberFormat(o, {
1944
+ minimumFractionDigits: 0,
1945
+ maximumFractionDigits: 2
1946
+ }).format(t);
1947
+ }
1948
+ ke.forwardRef(
1949
+ function(o, l) {
1950
+ const {
1951
+ scenarios: i,
1952
+ annotations: c = [],
1953
+ referenceLines: b = [],
1954
+ forecastStartDate: f,
1955
+ cashRunway: w,
1956
+ xAxis: B,
1957
+ yAxis: p,
1958
+ confidenceBands: S = [{ level: 95, color: "#3b82f6", opacity: 0.15 }],
1959
+ tooltip: N,
1960
+ legend: z = { enabled: true, position: "bottom", interactive: true },
1961
+ height: M = 350,
1962
+ showForecastRegion: v = true,
1963
+ lineWidth: u = 2,
1964
+ showPoints: h = false,
1965
+ pointRadius: m = 4,
1966
+ enableZoom: L = false,
1967
+ animationDuration: x = 300,
1968
+ responsive: y = true,
1969
+ onPointClick: s,
1970
+ onAnnotationClick: T,
1971
+ onScenarioToggle: g,
1972
+ onViewportChange: C,
1973
+ size: d = "medium",
1974
+ disabled: $ = false,
1975
+ labels: A = {},
1976
+ locale: O = "pl-PL",
1977
+ className: X,
1978
+ style: R
1979
+ } = o, [Y, q] = ke.useState(
1980
+ () => i.map((a, W) => ({
1981
+ ...a,
1982
+ color: a.color ?? Te[W % Te.length],
1983
+ visible: a.visible !== false
1984
+ }))
1985
+ ), [J, V] = ke.useState(null), [Q, r] = ke.useState({ x: 0, y: 0 }), F = ke.useRef(null), H = ke.useRef(null), k = { top: 20, right: 30, bottom: 40, left: 60 }, [n, E] = ke.useState({
1986
+ width: 600,
1987
+ height: typeof M == "number" ? M : 350
1988
+ });
1989
+ ke.useEffect(() => {
1990
+ if (!y || !F.current)
1991
+ return;
1992
+ const a = new ResizeObserver((W) => {
1993
+ for (const U of W)
1994
+ E((D) => ({
1995
+ width: U.contentRect.width,
1996
+ height: D.height
1997
+ }));
1998
+ });
1999
+ return a.observe(F.current), () => a.disconnect();
2000
+ }, [y]), ke.useEffect(() => {
2001
+ const a = "nice-forecast-chart-styles";
2002
+ if (!document.getElementById(a)) {
2003
+ const W = document.createElement("style");
2004
+ W.id = a, W.textContent = Qe, document.head.appendChild(W);
2005
+ }
2006
+ }, []);
2007
+ const { xScale: I, yScale: Z, allDates: ae, minY: le, maxY: te } = ke.useMemo(() => {
2008
+ const W = Y.filter((ie) => ie.visible !== false).flatMap((ie) => ie.data);
2009
+ if (W.length === 0)
2010
+ return { xScale: () => 0, yScale: () => 0, allDates: [], minY: 0, maxY: 100 };
2011
+ const U = W.map((ie) => pe(ie.date).getTime()), D = Math.min(...U), re = Math.max(...U), ue = W.flatMap((ie) => [ie.value, ie.forecast, ie.lowerBound, ie.upperBound]).filter((ie) => ie != null), xe = p?.min ?? Math.min(...ue) * 0.95, fe = p?.max ?? Math.max(...ue) * 1.05, ve = n.width - k.left - k.right, _e = n.height - k.top - k.bottom, Ce = (ie) => {
2012
+ const Ie = typeof ie == "number" ? ie : ie.getTime();
2013
+ return k.left + (Ie - D) / (re - D) * ve;
2014
+ }, Ae = (ie) => k.top + _e - (ie - xe) / (fe - xe) * _e, Oe = [...new Set(U)].sort((ie, Ie) => ie - Ie).map((ie) => new Date(ie));
2015
+ return {
2016
+ xScale: Ce,
2017
+ yScale: Ae,
2018
+ allDates: Oe,
2019
+ minY: xe,
2020
+ maxY: fe
2021
+ };
2022
+ }, [Y, n, k, p]), j = f ? pe(f) : null, G = ke.useMemo(() => {
2023
+ if (!w?.enabled)
2024
+ return null;
2025
+ const a = w.threshold ?? 0, W = w.scenarioId ? Y.find((D) => D.id === w.scenarioId && D.visible !== false) : Y.find((D) => D.visible !== false);
2026
+ if (!W)
2027
+ return null;
2028
+ const U = W.data.sort(
2029
+ (D, re) => pe(D.date).getTime() - pe(re.date).getTime()
2030
+ );
2031
+ for (let D = 1; D < U.length; D++) {
2032
+ const re = U[D - 1], ue = U[D], xe = re.forecast ?? re.value, fe = ue.forecast ?? ue.value;
2033
+ if (xe != null && fe != null && xe > a && fe <= a) {
2034
+ const ve = (xe - a) / (xe - fe), _e = pe(re.date).getTime(), Ce = pe(ue.date).getTime(), Ae = _e + ve * (Ce - _e);
2035
+ return new Date(Ae);
2036
+ }
2037
+ }
2038
+ return null;
2039
+ }, [w, Y]), ce = ke.useCallback(
2040
+ (a, W) => {
2041
+ const U = a.filter((D) => D[W] != null).map((D) => ({ x: I(pe(D.date)), y: Z(D[W]) }));
2042
+ return U.length === 0 ? "" : `M ${U.map((D) => `${D.x},${D.y}`).join(" L ")}`;
2043
+ },
2044
+ [I, Z]
2045
+ ), ge = ke.useCallback(
2046
+ (a) => {
2047
+ const W = a.filter((re) => re.lowerBound != null && re.upperBound != null);
2048
+ if (W.length === 0)
2049
+ return "";
2050
+ const U = W.map((re) => ({
2051
+ x: I(pe(re.date)),
2052
+ y: Z(re.upperBound)
2053
+ })), D = W.map((re) => ({ x: I(pe(re.date)), y: Z(re.lowerBound) })).reverse();
2054
+ return `M ${U.map((re) => `${re.x},${re.y}`).join(" L ")} L ${D.map((re) => `${re.x},${re.y}`).join(" L ")} Z`;
2055
+ },
2056
+ [I, Z]
2057
+ ), P = ke.useCallback(
2058
+ (a) => {
2059
+ if (!H.current || N?.enabled === false)
2060
+ return;
2061
+ const W = H.current.getBoundingClientRect(), U = a.clientX - W.left;
2062
+ a.clientY - W.top;
2063
+ let D = null, re = 1 / 0;
2064
+ for (const ue of ae) {
2065
+ const xe = I(ue), fe = Math.abs(xe - U);
2066
+ fe < re && (re = fe, D = ue);
2067
+ }
2068
+ if (D && re < 50) {
2069
+ const ue = Y.filter((fe) => fe.visible !== false).map((fe) => {
2070
+ const ve = fe.data.find((_e) => pe(_e.date).getTime() === D.getTime());
2071
+ return {
2072
+ scenario: fe,
2073
+ value: ve?.value,
2074
+ forecast: ve?.forecast,
2075
+ lowerBound: ve?.lowerBound,
2076
+ upperBound: ve?.upperBound
2077
+ };
2078
+ }), xe = c.filter(
2079
+ (fe) => Math.abs(pe(fe.date).getTime() - D.getTime()) < 864e5
2080
+ );
2081
+ V({ date: D, values: ue, annotations: xe }), r({ x: a.clientX - W.left + 10, y: a.clientY - W.top - 10 });
2082
+ } else
2083
+ V(null);
2084
+ },
2085
+ [I, ae, Y, c, N]
2086
+ ), K = ke.useCallback(
2087
+ (a) => {
2088
+ if (!z.interactive)
2089
+ return;
2090
+ q((U) => U.map((D) => D.id === a ? { ...D, visible: !D.visible } : D));
2091
+ const W = Y.find((U) => U.id === a);
2092
+ W && g?.(a, !W.visible);
2093
+ },
2094
+ [z.interactive, Y, g]
2095
+ );
2096
+ ke.useImperativeHandle(
2097
+ l,
2098
+ () => ({
2099
+ getScenarios: () => Y,
2100
+ updateScenario: (a, W) => {
2101
+ q((U) => U.map((D) => D.id === a ? { ...D, data: W } : D));
2102
+ },
2103
+ toggleScenario: K,
2104
+ setZoomRange: () => {
2105
+ },
2106
+ // Would need pan/zoom implementation
2107
+ resetZoom: () => {
2108
+ },
2109
+ exportImage: (a) => {
2110
+ if (!H.current)
2111
+ return null;
2112
+ const W = H.current, D = new XMLSerializer().serializeToString(W);
2113
+ return `data:image/svg+xml;base64,${btoa(D)}`;
2114
+ },
2115
+ getDataAtDate: (a) => {
2116
+ const W = Y.filter((U) => U.visible !== false).map((U) => {
2117
+ const D = U.data.find((re) => pe(re.date).getTime() === a.getTime());
2118
+ return {
2119
+ scenario: U,
2120
+ value: D?.value,
2121
+ forecast: D?.forecast,
2122
+ lowerBound: D?.lowerBound,
2123
+ upperBound: D?.upperBound
2124
+ };
2125
+ });
2126
+ return {
2127
+ date: a,
2128
+ values: W,
2129
+ annotations: c.filter((U) => pe(U.date).getTime() === a.getTime())
2130
+ };
2131
+ }
2132
+ }),
2133
+ [Y, c, K]
2134
+ ), n.width - k.left - k.right;
2135
+ const ne = n.height - k.top - k.bottom, se = ke.useMemo(() => {
2136
+ const a = p?.tickCount ?? 5, W = [], U = (te - le) / (a - 1);
2137
+ for (let D = 0; D < a; D++)
2138
+ W.push(le + U * D);
2139
+ return W;
2140
+ }, [le, te, p?.tickCount]), de = ke.useMemo(() => {
2141
+ const a = B?.tickCount ?? 6;
2142
+ if (ae.length === 0)
2143
+ return [];
2144
+ const W = Math.max(1, Math.floor(ae.length / (a - 1)));
2145
+ return ae.filter((U, D) => D % W === 0 || D === ae.length - 1);
2146
+ }, [ae, B?.tickCount]);
2147
+ return Y.length === 0 || Y.every((a) => a.data.length === 0) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: `nice-forecast-chart ${X ?? ""}`, style: R, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-forecast-chart__empty", children: A.noData ?? "No data available" }) }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `nice-forecast-chart ${X ?? ""}`, style: { ...R, height: M }, children: [
2148
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: F, className: "nice-forecast-chart__container", children: [
2149
+ /* @__PURE__ */ jsxRuntime.jsxs(
2150
+ "svg",
2151
+ {
2152
+ ref: H,
2153
+ className: "nice-forecast-chart__svg",
2154
+ width: n.width,
2155
+ height: n.height,
2156
+ onMouseMove: P,
2157
+ onMouseLeave: () => V(null),
2158
+ children: [
2159
+ p?.showGrid !== false && se.map((a) => /* @__PURE__ */ jsxRuntime.jsx(
2160
+ "line",
2161
+ {
2162
+ className: "nice-forecast-chart__grid-line",
2163
+ x1: k.left,
2164
+ x2: n.width - k.right,
2165
+ y1: Z(a),
2166
+ y2: Z(a)
2167
+ },
2168
+ a
2169
+ )),
2170
+ v && j && /* @__PURE__ */ jsxRuntime.jsx(
2171
+ "rect",
2172
+ {
2173
+ className: "nice-forecast-chart__forecast-region",
2174
+ x: I(j),
2175
+ y: k.top,
2176
+ width: n.width - k.right - I(j),
2177
+ height: ne
2178
+ }
2179
+ ),
2180
+ b.map((a) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
2181
+ /* @__PURE__ */ jsxRuntime.jsx(
2182
+ "line",
2183
+ {
2184
+ className: "nice-forecast-chart__reference-line",
2185
+ x1: k.left,
2186
+ x2: n.width - k.right,
2187
+ y1: Z(a.value),
2188
+ y2: Z(a.value),
2189
+ stroke: a.color ?? "#9ca3af",
2190
+ strokeDasharray: a.dashArray ?? "4,2"
2191
+ }
2192
+ ),
2193
+ a.label && /* @__PURE__ */ jsxRuntime.jsx(
2194
+ "text",
2195
+ {
2196
+ className: "nice-forecast-chart__reference-label",
2197
+ x: n.width - k.right - 4,
2198
+ y: Z(a.value) - 4,
2199
+ textAnchor: "end",
2200
+ children: a.label
2201
+ }
2202
+ )
2203
+ ] }, a.id)),
2204
+ G && w?.enabled && /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "nice-forecast-chart__cash-runway", children: [
2205
+ /* @__PURE__ */ jsxRuntime.jsx(
2206
+ "line",
2207
+ {
2208
+ className: "nice-forecast-chart__cash-runway-line",
2209
+ x1: I(G),
2210
+ x2: I(G),
2211
+ y1: k.top,
2212
+ y2: n.height - k.bottom,
2213
+ stroke: w.color ?? "#ef4444"
2214
+ }
2215
+ ),
2216
+ w.showLabel !== false && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2217
+ /* @__PURE__ */ jsxRuntime.jsx(
2218
+ "rect",
2219
+ {
2220
+ className: "nice-forecast-chart__cash-runway-label-bg",
2221
+ x: I(G) - 60,
2222
+ y: k.top - 2,
2223
+ width: 120,
2224
+ height: w.showDate !== false ? 32 : 20,
2225
+ fill: w.color ?? "#ef4444",
2226
+ rx: 4
2227
+ }
2228
+ ),
2229
+ /* @__PURE__ */ jsxRuntime.jsx(
2230
+ "text",
2231
+ {
2232
+ className: "nice-forecast-chart__cash-runway-label",
2233
+ x: I(G),
2234
+ y: k.top + 12,
2235
+ textAnchor: "middle",
2236
+ fill: "#ffffff",
2237
+ children: w.label ?? A.cashRunsOut ?? "💰 Cash runs out"
2238
+ }
2239
+ ),
2240
+ w.showDate !== false && /* @__PURE__ */ jsxRuntime.jsx(
2241
+ "text",
2242
+ {
2243
+ className: "nice-forecast-chart__cash-runway-label",
2244
+ x: I(G),
2245
+ y: k.top + 26,
2246
+ textAnchor: "middle",
2247
+ fill: "#ffffff",
2248
+ style: { fontSize: "0.625rem", opacity: 0.9 },
2249
+ children: Le(G, O)
2250
+ }
2251
+ )
2252
+ ] })
2253
+ ] }),
2254
+ Y.filter((a) => a.visible !== false && a.showConfidenceBand).map((a) => /* @__PURE__ */ jsxRuntime.jsx(
2255
+ "path",
2256
+ {
2257
+ className: "nice-forecast-chart__confidence-band",
2258
+ d: ge(a.data),
2259
+ fill: a.color
2260
+ },
2261
+ `band-${a.id}`
2262
+ )),
2263
+ Y.filter((a) => a.visible !== false).map((a) => {
2264
+ const W = j ? a.data.filter((D) => pe(D.date) < j) : a.data.filter((D) => D.value != null), U = j ? a.data.filter((D) => pe(D.date) >= j) : a.data.filter((D) => D.forecast != null);
2265
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
2266
+ /* @__PURE__ */ jsxRuntime.jsx(
2267
+ "path",
2268
+ {
2269
+ className: "nice-forecast-chart__historical-line",
2270
+ d: ce(W, "value"),
2271
+ stroke: a.color,
2272
+ strokeWidth: u
2273
+ }
2274
+ ),
2275
+ /* @__PURE__ */ jsxRuntime.jsx(
2276
+ "path",
2277
+ {
2278
+ className: "nice-forecast-chart__forecast-line",
2279
+ d: ce(U, j ? "value" : "forecast"),
2280
+ stroke: a.color,
2281
+ strokeWidth: u
2282
+ }
2283
+ ),
2284
+ U.length > 0 && a.data.some((D) => D.forecast != null) && /* @__PURE__ */ jsxRuntime.jsx(
2285
+ "path",
2286
+ {
2287
+ className: "nice-forecast-chart__forecast-line",
2288
+ d: ce(a.data, "forecast"),
2289
+ stroke: a.color,
2290
+ strokeWidth: u
2291
+ }
2292
+ ),
2293
+ h && a.data.map((D, re) => {
2294
+ const ue = D.value ?? D.forecast;
2295
+ return ue == null ? null : /* @__PURE__ */ jsxRuntime.jsx(
2296
+ "circle",
2297
+ {
2298
+ className: "nice-forecast-chart__point",
2299
+ cx: I(pe(D.date)),
2300
+ cy: Z(ue),
2301
+ r: m,
2302
+ fill: a.color,
2303
+ onClick: () => s?.(D, a)
2304
+ },
2305
+ re
2306
+ );
2307
+ })
2308
+ ] }, a.id);
2309
+ }),
2310
+ c.map((a) => {
2311
+ const W = I(pe(a.date));
2312
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2313
+ "g",
2314
+ {
2315
+ className: "nice-forecast-chart__annotation-marker",
2316
+ onClick: () => T?.(a),
2317
+ children: [
2318
+ a.showLine !== false && /* @__PURE__ */ jsxRuntime.jsx(
2319
+ "line",
2320
+ {
2321
+ className: "nice-forecast-chart__annotation-line",
2322
+ x1: W,
2323
+ x2: W,
2324
+ y1: k.top,
2325
+ y2: n.height - k.bottom,
2326
+ stroke: a.color ?? "#9ca3af"
2327
+ }
2328
+ ),
2329
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: W, cy: k.top + 10, r: 8, fill: a.color ?? "#9ca3af" }),
2330
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: W, y: k.top + 14, textAnchor: "middle", fill: "white", fontSize: "10", children: a.icon ?? "!" })
2331
+ ]
2332
+ },
2333
+ a.id
2334
+ );
2335
+ }),
2336
+ /* @__PURE__ */ jsxRuntime.jsx(
2337
+ "line",
2338
+ {
2339
+ className: "nice-forecast-chart__axis-line",
2340
+ x1: k.left,
2341
+ x2: k.left,
2342
+ y1: k.top,
2343
+ y2: n.height - k.bottom
2344
+ }
2345
+ ),
2346
+ /* @__PURE__ */ jsxRuntime.jsx(
2347
+ "line",
2348
+ {
2349
+ className: "nice-forecast-chart__axis-line",
2350
+ x1: k.left,
2351
+ x2: n.width - k.right,
2352
+ y1: n.height - k.bottom,
2353
+ y2: n.height - k.bottom
2354
+ }
2355
+ ),
2356
+ se.map((a) => /* @__PURE__ */ jsxRuntime.jsx(
2357
+ "text",
2358
+ {
2359
+ className: "nice-forecast-chart__axis-label",
2360
+ x: k.left - 8,
2361
+ y: Z(a) + 4,
2362
+ textAnchor: "end",
2363
+ children: p?.format ? p.format(a) : $e(a, O)
2364
+ },
2365
+ a
2366
+ )),
2367
+ de.map((a) => /* @__PURE__ */ jsxRuntime.jsx(
2368
+ "text",
2369
+ {
2370
+ className: "nice-forecast-chart__axis-label",
2371
+ x: I(a),
2372
+ y: n.height - k.bottom + 16,
2373
+ textAnchor: "middle",
2374
+ children: B?.format ? B.format(a) : Le(a, O)
2375
+ },
2376
+ a.getTime()
2377
+ )),
2378
+ p?.title && /* @__PURE__ */ jsxRuntime.jsx(
2379
+ "text",
2380
+ {
2381
+ className: "nice-forecast-chart__axis-title",
2382
+ x: 15,
2383
+ y: n.height / 2,
2384
+ textAnchor: "middle",
2385
+ transform: `rotate(-90, 15, ${n.height / 2})`,
2386
+ children: p.title
2387
+ }
2388
+ )
2389
+ ]
2390
+ }
2391
+ ),
2392
+ J && /* @__PURE__ */ jsxRuntime.jsxs(
2393
+ "div",
2394
+ {
2395
+ className: "nice-forecast-chart__tooltip",
2396
+ style: { left: Q.x, top: Q.y },
2397
+ children: [
2398
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-forecast-chart__tooltip-date", children: Le(J.date, O) }),
2399
+ J.values.map((a) => {
2400
+ const W = a.value ?? a.forecast;
2401
+ return W == null ? null : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-forecast-chart__tooltip-item", children: [
2402
+ /* @__PURE__ */ jsxRuntime.jsx(
2403
+ "span",
2404
+ {
2405
+ className: "nice-forecast-chart__tooltip-color",
2406
+ style: { background: a.scenario.color }
2407
+ }
2408
+ ),
2409
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-forecast-chart__tooltip-label", children: a.scenario.name }),
2410
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-forecast-chart__tooltip-value", children: $e(W, O) })
2411
+ ] }, a.scenario.id);
2412
+ }),
2413
+ J.values.some((a) => a.lowerBound != null) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-forecast-chart__tooltip-confidence", children: [
2414
+ A.confidence ?? "CI",
2415
+ ":",
2416
+ " ",
2417
+ $e(J.values[0]?.lowerBound ?? 0, O),
2418
+ " –",
2419
+ " ",
2420
+ $e(J.values[0]?.upperBound ?? 0, O)
2421
+ ] })
2422
+ ]
2423
+ }
2424
+ )
2425
+ ] }),
2426
+ z.enabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-forecast-chart__legend", children: Y.map((a) => /* @__PURE__ */ jsxRuntime.jsxs(
2427
+ "div",
2428
+ {
2429
+ className: `nice-forecast-chart__legend-item ${a.visible === false ? "nice-forecast-chart__legend-item--hidden" : ""}`,
2430
+ onClick: () => K(a.id),
2431
+ children: [
2432
+ /* @__PURE__ */ jsxRuntime.jsx(
2433
+ "span",
2434
+ {
2435
+ className: `nice-forecast-chart__legend-color ${a.isBase ? "" : "nice-forecast-chart__legend-color--dashed"}`,
2436
+ style: { background: a.color }
2437
+ }
2438
+ ),
2439
+ a.name
2440
+ ]
2441
+ },
2442
+ a.id
2443
+ )) })
2444
+ ] });
2445
+ }
2446
+ ); const Pe = [
2447
+ "#3b82f6",
2448
+ "#ef4444",
2449
+ "#22c55e",
2450
+ "#f59e0b",
2451
+ "#8b5cf6",
2452
+ "#ec4899",
2453
+ "#06b6d4",
2454
+ "#84cc16",
2455
+ "#f97316",
2456
+ "#6366f1"
2457
+ ], Ke = ke.forwardRef(
2458
+ (t, o) => {
2459
+ const {
2460
+ levels: l,
2461
+ initialLevelId: i,
2462
+ chartType: c = "bar",
2463
+ width: b = 600,
2464
+ height: f = 400,
2465
+ showBreadcrumbs: w = true,
2466
+ showBackButton: B = true,
2467
+ animationDuration: p = 300,
2468
+ onLevelChange: S,
2469
+ onItemClick: N,
2470
+ colors: z = Pe,
2471
+ showValues: M = true,
2472
+ showLegend: v = true,
2473
+ className: u,
2474
+ style: h,
2475
+ ...m
2476
+ } = t, [L, x] = ke.useState(i || l[0]?.id), [y, s] = ke.useState([i || l[0]?.id]), [T, g] = ke.useState(false), [C, d] = ke.useState("in"), $ = ke.useMemo(
2477
+ () => l.find((r) => r.id === L),
2478
+ [l, L]
2479
+ ), A = ke.useCallback(
2480
+ (r) => {
2481
+ l.find((H) => H.id === r) && (d("in"), g(true), setTimeout(() => {
2482
+ x(r), s((H) => [...H, r]), S?.(r, [...y, r]), g(false);
2483
+ }, p / 2));
2484
+ },
2485
+ [l, y, p, S]
2486
+ ), O = ke.useCallback(() => {
2487
+ if (y.length <= 1)
2488
+ return;
2489
+ d("out"), g(true);
2490
+ const r = y.slice(0, -1), F = r[r.length - 1];
2491
+ setTimeout(() => {
2492
+ x(F), s(r), S?.(F, r), g(false);
2493
+ }, p / 2);
2494
+ }, [y, p, S]), X = ke.useCallback(() => {
2495
+ const r = l[0]?.id;
2496
+ r && (d("out"), g(true), setTimeout(() => {
2497
+ x(r), s([r]), S?.(r, [r]), g(false);
2498
+ }, p / 2));
2499
+ }, [l, p, S]);
2500
+ ke.useImperativeHandle(
2501
+ o,
2502
+ () => ({
2503
+ drillDown: A,
2504
+ drillUp: O,
2505
+ resetToRoot: X,
2506
+ getCurrentLevel: () => L,
2507
+ getPath: () => y
2508
+ }),
2509
+ [A, O, X, L, y]
2510
+ );
2511
+ const R = ke.useCallback(
2512
+ (r, F) => {
2513
+ N?.(r, L);
2514
+ const H = l.find(
2515
+ (k) => k.parentId === L && k.id === r.metadata?.childLevelId
2516
+ );
2517
+ H && A(H.id);
2518
+ },
2519
+ [L, l, A, N]
2520
+ ), Y = ke.useMemo(
2521
+ () => $?.data.reduce((r, F) => r + F.value, 0) || 0,
2522
+ [$]
2523
+ ), q = ke.useMemo(
2524
+ () => y.map((r) => l.find((F) => F.id === r)?.label || r),
2525
+ [y, l]
2526
+ ), J = () => {
2527
+ if (!$)
2528
+ return null;
2529
+ const r = $.data, F = Math.max(...r.map((k) => k.value)), H = Math.min(40, (f - 100) / r.length - 8);
2530
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-drilldown-bars", children: r.map((k, n) => {
2531
+ const E = k.value / F * 100;
2532
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2533
+ "div",
2534
+ {
2535
+ className: "nice-drilldown-bar-row",
2536
+ onClick: () => R(k, n),
2537
+ children: [
2538
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-drilldown-bar-label", children: k.label || `Item ${n + 1}` }),
2539
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-drilldown-bar-track", children: /* @__PURE__ */ jsxRuntime.jsx(
2540
+ "div",
2541
+ {
2542
+ className: "nice-drilldown-bar-fill",
2543
+ style: {
2544
+ width: `${E}%`,
2545
+ backgroundColor: k.color || z[n % z.length],
2546
+ height: H
2547
+ }
2548
+ }
2549
+ ) }),
2550
+ M && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-drilldown-bar-value", children: k.value.toLocaleString() })
2551
+ ]
2552
+ },
2553
+ n
2554
+ );
2555
+ }) });
2556
+ }, V = () => {
2557
+ if (!$)
2558
+ return null;
2559
+ const r = $.data, F = b / 2, H = (f - 60) / 2 + 30, k = Math.min(F, H) - 40;
2560
+ let n = -90;
2561
+ const E = r.map((I, Z) => {
2562
+ const ae = I.value / Y * 360, le = n + ae, te = ae > 180 ? 1 : 0, j = n * Math.PI / 180, G = le * Math.PI / 180, ce = F + k * Math.cos(j), ge = H + k * Math.sin(j), P = F + k * Math.cos(G), K = H + k * Math.sin(G), ne = (n + ae / 2) * Math.PI / 180, se = F + k * 0.7 * Math.cos(ne), de = H + k * 0.7 * Math.sin(ne), a = `M ${F} ${H} L ${ce} ${ge} A ${k} ${k} 0 ${te} 1 ${P} ${K} Z`;
2563
+ return n = le, {
2564
+ path: a,
2565
+ color: I.color || z[Z % z.length],
2566
+ label: I.label || `Item ${Z + 1}`,
2567
+ value: I.value,
2568
+ percentage: (I.value / Y * 100).toFixed(1),
2569
+ labelX: se,
2570
+ labelY: de,
2571
+ item: I,
2572
+ index: Z
2573
+ };
2574
+ });
2575
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: b, height: f - 40, className: "nice-drilldown-pie", children: /* @__PURE__ */ jsxRuntime.jsx("g", { children: E.map((I, Z) => /* @__PURE__ */ jsxRuntime.jsxs("g", { onClick: () => R(I.item, I.index), children: [
2576
+ /* @__PURE__ */ jsxRuntime.jsx(
2577
+ "path",
2578
+ {
2579
+ d: I.path,
2580
+ fill: I.color,
2581
+ stroke: "white",
2582
+ strokeWidth: 2,
2583
+ className: "nice-drilldown-pie-slice"
2584
+ }
2585
+ ),
2586
+ M && parseFloat(I.percentage) > 5 && /* @__PURE__ */ jsxRuntime.jsxs(
2587
+ "text",
2588
+ {
2589
+ x: I.labelX,
2590
+ y: I.labelY,
2591
+ textAnchor: "middle",
2592
+ dominantBaseline: "middle",
2593
+ fill: "white",
2594
+ fontSize: "12",
2595
+ fontWeight: "600",
2596
+ children: [
2597
+ I.percentage,
2598
+ "%"
2599
+ ]
2600
+ }
2601
+ )
2602
+ ] }, Z)) }) });
2603
+ }, Q = () => {
2604
+ if (!$)
2605
+ return null;
2606
+ const r = $.data, F = Math.max(...r.map((n) => n.value)), H = Math.min(60, (b - 100) / r.length - 8), k = f - 100;
2607
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: b, height: f - 40, className: "nice-drilldown-columns", children: /* @__PURE__ */ jsxRuntime.jsxs("g", { transform: "translate(50, 20)", children: [
2608
+ [0, 0.25, 0.5, 0.75, 1].map((n, E) => /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
2609
+ /* @__PURE__ */ jsxRuntime.jsx(
2610
+ "line",
2611
+ {
2612
+ x1: 0,
2613
+ y1: k * (1 - n),
2614
+ x2: b - 80,
2615
+ y2: k * (1 - n),
2616
+ stroke: "#e5e7eb",
2617
+ strokeDasharray: n === 0 ? void 0 : "4"
2618
+ }
2619
+ ),
2620
+ /* @__PURE__ */ jsxRuntime.jsx(
2621
+ "text",
2622
+ {
2623
+ x: -8,
2624
+ y: k * (1 - n),
2625
+ textAnchor: "end",
2626
+ dominantBaseline: "middle",
2627
+ fontSize: "11",
2628
+ fill: "#6b7280",
2629
+ children: Math.round(F * n).toLocaleString()
2630
+ }
2631
+ )
2632
+ ] }, E)),
2633
+ r.map((n, E) => {
2634
+ const I = n.value / F * k, Z = E * ((b - 100) / r.length) + ((b - 100) / r.length - H) / 2;
2635
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { onClick: () => R(n, E), children: [
2636
+ /* @__PURE__ */ jsxRuntime.jsx(
2637
+ "rect",
2638
+ {
2639
+ x: Z,
2640
+ y: k - I,
2641
+ width: H,
2642
+ height: I,
2643
+ fill: n.color || z[E % z.length],
2644
+ rx: 4,
2645
+ className: "nice-drilldown-column-bar"
2646
+ }
2647
+ ),
2648
+ /* @__PURE__ */ jsxRuntime.jsx(
2649
+ "text",
2650
+ {
2651
+ x: Z + H / 2,
2652
+ y: k + 16,
2653
+ textAnchor: "middle",
2654
+ fontSize: "11",
2655
+ fill: "#374151",
2656
+ children: (n.label || `${E + 1}`).slice(0, 10)
2657
+ }
2658
+ ),
2659
+ M && /* @__PURE__ */ jsxRuntime.jsx(
2660
+ "text",
2661
+ {
2662
+ x: Z + H / 2,
2663
+ y: k - I - 8,
2664
+ textAnchor: "middle",
2665
+ fontSize: "11",
2666
+ fill: "#374151",
2667
+ fontWeight: "500",
2668
+ children: n.value.toLocaleString()
2669
+ }
2670
+ )
2671
+ ] }, E);
2672
+ })
2673
+ ] }) });
2674
+ };
2675
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2676
+ "div",
2677
+ {
2678
+ className: `nice-drilldown-chart ${T ? `animating ${C}` : ""} ${u || ""}`,
2679
+ style: { width: b, ...h },
2680
+ ...m,
2681
+ children: [
2682
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-drilldown-header", children: [
2683
+ B && y.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("button", { className: "nice-drilldown-back", onClick: O, children: "← Wstecz" }),
2684
+ w && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-drilldown-breadcrumbs", children: q.map((r, F) => /* @__PURE__ */ jsxRuntime.jsxs(ke.Fragment, { children: [
2685
+ F > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-drilldown-separator", children: "/" }),
2686
+ /* @__PURE__ */ jsxRuntime.jsx(
2687
+ "span",
2688
+ {
2689
+ className: `nice-drilldown-crumb ${F === q.length - 1 ? "active" : ""}`,
2690
+ onClick: () => {
2691
+ if (F < q.length - 1) {
2692
+ const H = y.slice(0, F + 1);
2693
+ s(H), x(H[H.length - 1]);
2694
+ }
2695
+ },
2696
+ children: r
2697
+ }
2698
+ )
2699
+ ] }, F)) })
2700
+ ] }),
2701
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-drilldown-content", style: { height: f - 40 }, children: [
2702
+ c === "bar" && J(),
2703
+ c === "pie" && V(),
2704
+ c === "column" && Q()
2705
+ ] }),
2706
+ v && $ && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "nice-drilldown-legend", children: $.data.map((r, F) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-drilldown-legend-item", children: [
2707
+ /* @__PURE__ */ jsxRuntime.jsx(
2708
+ "span",
2709
+ {
2710
+ className: "nice-drilldown-legend-color",
2711
+ style: { backgroundColor: r.color || z[F % z.length] }
2712
+ }
2713
+ ),
2714
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-drilldown-legend-label", children: r.label || `Item ${F + 1}` })
2715
+ ] }, F)) }),
2716
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
2717
+ .nice-drilldown-chart {
2718
+ font-family: system-ui, -apple-system, sans-serif;
2719
+ background: white;
2720
+ border-radius: 8px;
2721
+ overflow: hidden;
2722
+ }
2723
+
2724
+ .nice-drilldown-header {
2725
+ display: flex;
2726
+ align-items: center;
2727
+ gap: 12px;
2728
+ padding: 12px 16px;
2729
+ border-bottom: 1px solid #e5e7eb;
2730
+ min-height: 40px;
2731
+ }
2732
+
2733
+ .nice-drilldown-back {
2734
+ background: #f3f4f6;
2735
+ border: none;
2736
+ padding: 6px 12px;
2737
+ border-radius: 6px;
2738
+ cursor: pointer;
2739
+ font-size: 13px;
2740
+ color: #374151;
2741
+ transition: background 0.2s;
2742
+ }
2743
+
2744
+ .nice-drilldown-back:hover {
2745
+ background: #e5e7eb;
2746
+ }
2747
+
2748
+ .nice-drilldown-breadcrumbs {
2749
+ display: flex;
2750
+ align-items: center;
2751
+ gap: 4px;
2752
+ font-size: 13px;
2753
+ }
2754
+
2755
+ .nice-drilldown-separator {
2756
+ color: #9ca3af;
2757
+ }
2758
+
2759
+ .nice-drilldown-crumb {
2760
+ color: #6b7280;
2761
+ cursor: pointer;
2762
+ }
2763
+
2764
+ .nice-drilldown-crumb:hover:not(.active) {
2765
+ color: #3b82f6;
2766
+ }
2767
+
2768
+ .nice-drilldown-crumb.active {
2769
+ color: #111827;
2770
+ font-weight: 500;
2771
+ cursor: default;
2772
+ }
2773
+
2774
+ .nice-drilldown-content {
2775
+ padding: 16px;
2776
+ transition: opacity 0.15s, transform 0.15s;
2777
+ }
2778
+
2779
+ .nice-drilldown-chart.animating .nice-drilldown-content {
2780
+ opacity: 0;
2781
+ }
2782
+
2783
+ .nice-drilldown-chart.animating.in .nice-drilldown-content {
2784
+ transform: translateX(20px);
2785
+ }
2786
+
2787
+ .nice-drilldown-chart.animating.out .nice-drilldown-content {
2788
+ transform: translateX(-20px);
2789
+ }
2790
+
2791
+ .nice-drilldown-bars {
2792
+ display: flex;
2793
+ flex-direction: column;
2794
+ gap: 8px;
2795
+ }
2796
+
2797
+ .nice-drilldown-bar-row {
2798
+ display: flex;
2799
+ align-items: center;
2800
+ gap: 12px;
2801
+ cursor: pointer;
2802
+ padding: 4px 8px;
2803
+ margin: -4px -8px;
2804
+ border-radius: 6px;
2805
+ transition: background 0.2s;
2806
+ }
2807
+
2808
+ .nice-drilldown-bar-row:hover {
2809
+ background: #f9fafb;
2810
+ }
2811
+
2812
+ .nice-drilldown-bar-label {
2813
+ width: 120px;
2814
+ font-size: 13px;
2815
+ color: #374151;
2816
+ overflow: hidden;
2817
+ text-overflow: ellipsis;
2818
+ white-space: nowrap;
2819
+ }
2820
+
2821
+ .nice-drilldown-bar-track {
2822
+ flex: 1;
2823
+ background: #f3f4f6;
2824
+ border-radius: 6px;
2825
+ overflow: hidden;
2826
+ }
2827
+
2828
+ .nice-drilldown-bar-fill {
2829
+ transition: width 0.3s ease;
2830
+ border-radius: 6px;
2831
+ }
2832
+
2833
+ .nice-drilldown-bar-value {
2834
+ width: 80px;
2835
+ text-align: right;
2836
+ font-size: 13px;
2837
+ font-weight: 500;
2838
+ color: #111827;
2839
+ }
2840
+
2841
+ .nice-drilldown-pie-slice {
2842
+ cursor: pointer;
2843
+ transition: transform 0.2s, opacity 0.2s;
2844
+ transform-origin: center;
2845
+ }
2846
+
2847
+ .nice-drilldown-pie-slice:hover {
2848
+ opacity: 0.85;
2849
+ transform: scale(1.02);
2850
+ }
2851
+
2852
+ .nice-drilldown-column-bar {
2853
+ cursor: pointer;
2854
+ transition: opacity 0.2s;
2855
+ }
2856
+
2857
+ .nice-drilldown-column-bar:hover {
2858
+ opacity: 0.8;
2859
+ }
2860
+
2861
+ .nice-drilldown-legend {
2862
+ display: flex;
2863
+ flex-wrap: wrap;
2864
+ gap: 16px;
2865
+ padding: 12px 16px;
2866
+ border-top: 1px solid #e5e7eb;
2867
+ }
2868
+
2869
+ .nice-drilldown-legend-item {
2870
+ display: flex;
2871
+ align-items: center;
2872
+ gap: 6px;
2873
+ }
2874
+
2875
+ .nice-drilldown-legend-color {
2876
+ width: 12px;
2877
+ height: 12px;
2878
+ border-radius: 3px;
2879
+ }
2880
+
2881
+ .nice-drilldown-legend-label {
2882
+ font-size: 12px;
2883
+ color: #6b7280;
2884
+ }
2885
+ ` })
2886
+ ]
2887
+ }
2888
+ );
2889
+ }
2890
+ );
2891
+ Ke.displayName = "NiceDrillDownChart";
2892
+ const et = ke.forwardRef(
2893
+ (t, o) => {
2894
+ const {
2895
+ initialData: l = [],
2896
+ maxPoints: i = 60,
2897
+ updateInterval: c = 1e3,
2898
+ fetchData: b,
2899
+ width: f = 600,
2900
+ height: w = 200,
2901
+ chartType: B = "line",
2902
+ color: p = "#3b82f6",
2903
+ showGrid: S = true,
2904
+ showTimeAxis: N = true,
2905
+ showCurrentValue: z = true,
2906
+ title: M,
2907
+ valueFormatter: v = (te) => te.toFixed(2),
2908
+ timeFormatter: u = (te) => new Date(te).toLocaleTimeString(),
2909
+ onDataUpdate: h,
2910
+ paused: m,
2911
+ className: L,
2912
+ style: x,
2913
+ ...y
2914
+ } = t, [s, T] = ke.useState(l), [g, C] = ke.useState(m || false), d = ke.useRef();
2915
+ ke.useEffect(() => {
2916
+ m !== void 0 && C(m);
2917
+ }, [m]), ke.useEffect(() => {
2918
+ if (g || !b)
2919
+ return;
2920
+ const te = async () => {
2921
+ try {
2922
+ const j = await b();
2923
+ T((G) => {
2924
+ const ce = [...G, j].slice(-i);
2925
+ return h?.(ce), ce;
2926
+ });
2927
+ } catch (j) {
2928
+ console.error("Failed to fetch realtime data:", j);
2929
+ }
2930
+ };
2931
+ return d.current = setInterval(te, c), () => {
2932
+ d.current && clearInterval(d.current);
2933
+ };
2934
+ }, [g, b, c, i, h]);
2935
+ const $ = ke.useCallback(
2936
+ (te) => {
2937
+ T((j) => {
2938
+ const G = [...j, te].slice(-i);
2939
+ return h?.(G), G;
2940
+ });
2941
+ },
2942
+ [i, h]
2943
+ ), A = ke.useCallback(() => {
2944
+ T([]), h?.([]);
2945
+ }, [h]), O = ke.useCallback(() => C(true), []), X = ke.useCallback(() => C(false), []);
2946
+ ke.useImperativeHandle(
2947
+ o,
2948
+ () => ({
2949
+ addDataPoint: $,
2950
+ clearData: A,
2951
+ pause: O,
2952
+ resume: X,
2953
+ getData: () => s
2954
+ }),
2955
+ [$, A, s]
2956
+ );
2957
+ const R = { top: 20, right: 60, bottom: N ? 40 : 20, left: 50 }, Y = f - R.left - R.right, q = w - R.top - R.bottom, J = s.map((te) => te.value), V = J.length ? Math.min(...J) : 0, Q = J.length ? Math.max(...J) : 100, F = (Q - V || 1) * 0.1, H = V - F, n = Q + F - H, E = (te) => R.left + te / (i - 1) * Y, I = (te) => R.top + q - (te - H) / n * q, Z = s.map((te, j) => `${E(j)},${I(te.value)}`).join(" "), ae = s.length > 0 ? `M ${E(0)},${R.top + q} L ${Z} L ${E(s.length - 1)},${R.top + q} Z` : "", le = s.length > 0 ? s[s.length - 1].value : null;
2958
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2959
+ "div",
2960
+ {
2961
+ className: `nice-realtime-chart ${L || ""}`,
2962
+ style: { width: f, ...x },
2963
+ ...y,
2964
+ children: [
2965
+ M && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-realtime-header", children: [
2966
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-realtime-title", children: M }),
2967
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-realtime-controls", children: [
2968
+ /* @__PURE__ */ jsxRuntime.jsx(
2969
+ "button",
2970
+ {
2971
+ className: `nice-realtime-btn ${g ? "paused" : ""}`,
2972
+ onClick: () => C(!g),
2973
+ children: g ? "▶️" : "⏸️"
2974
+ }
2975
+ ),
2976
+ z && le !== null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-realtime-value", children: v(le) })
2977
+ ] })
2978
+ ] }),
2979
+ /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: f, height: w, className: "nice-realtime-svg", children: [
2980
+ S && /* @__PURE__ */ jsxRuntime.jsx("g", { className: "nice-realtime-grid", children: [0, 0.25, 0.5, 0.75, 1].map((te, j) => {
2981
+ const G = R.top + q * (1 - te), ce = H + n * te;
2982
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
2983
+ /* @__PURE__ */ jsxRuntime.jsx(
2984
+ "line",
2985
+ {
2986
+ x1: R.left,
2987
+ y1: G,
2988
+ x2: f - R.right,
2989
+ y2: G,
2990
+ stroke: "#e5e7eb",
2991
+ strokeDasharray: te === 0 ? void 0 : "3"
2992
+ }
2993
+ ),
2994
+ /* @__PURE__ */ jsxRuntime.jsx(
2995
+ "text",
2996
+ {
2997
+ x: R.left - 8,
2998
+ y: G,
2999
+ textAnchor: "end",
3000
+ dominantBaseline: "middle",
3001
+ fontSize: "10",
3002
+ fill: "#6b7280",
3003
+ children: v(ce)
3004
+ }
3005
+ )
3006
+ ] }, j);
3007
+ }) }),
3008
+ B === "area" && s.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("path", { d: ae, fill: p, fillOpacity: 0.2 }),
3009
+ s.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
3010
+ "polyline",
3011
+ {
3012
+ points: Z,
3013
+ fill: "none",
3014
+ stroke: p,
3015
+ strokeWidth: 2,
3016
+ strokeLinecap: "round",
3017
+ strokeLinejoin: "round"
3018
+ }
3019
+ ),
3020
+ s.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
3021
+ "circle",
3022
+ {
3023
+ cx: E(s.length - 1),
3024
+ cy: I(s[s.length - 1].value),
3025
+ r: 4,
3026
+ fill: p,
3027
+ className: "nice-realtime-point"
3028
+ }
3029
+ ),
3030
+ N && s.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("g", { className: "nice-realtime-time-axis", children: [0, Math.floor(s.length / 2), s.length - 1].filter((te) => s[te]).map((te) => /* @__PURE__ */ jsxRuntime.jsx(
3031
+ "text",
3032
+ {
3033
+ x: E(te),
3034
+ y: w - 8,
3035
+ textAnchor: "middle",
3036
+ fontSize: "10",
3037
+ fill: "#6b7280",
3038
+ children: u(s[te].timestamp)
3039
+ },
3040
+ te
3041
+ )) })
3042
+ ] }),
3043
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `nice-realtime-status ${g ? "paused" : "live"}`, children: [
3044
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "nice-realtime-status-dot" }),
3045
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: g ? "Wstrzymano" : "Na żywo" })
3046
+ ] }),
3047
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
3048
+ .nice-realtime-chart {
3049
+ font-family: system-ui, -apple-system, sans-serif;
3050
+ background: white;
3051
+ border-radius: 8px;
3052
+ position: relative;
3053
+ }
3054
+
3055
+ .nice-realtime-header {
3056
+ display: flex;
3057
+ justify-content: space-between;
3058
+ align-items: center;
3059
+ padding: 12px 16px;
3060
+ border-bottom: 1px solid #e5e7eb;
3061
+ }
3062
+
3063
+ .nice-realtime-title {
3064
+ font-size: 14px;
3065
+ font-weight: 600;
3066
+ color: #111827;
3067
+ }
3068
+
3069
+ .nice-realtime-controls {
3070
+ display: flex;
3071
+ align-items: center;
3072
+ gap: 12px;
3073
+ }
3074
+
3075
+ .nice-realtime-btn {
3076
+ background: none;
3077
+ border: none;
3078
+ cursor: pointer;
3079
+ font-size: 16px;
3080
+ padding: 4px;
3081
+ }
3082
+
3083
+ .nice-realtime-value {
3084
+ font-size: 18px;
3085
+ font-weight: 600;
3086
+ color: ${p};
3087
+ font-variant-numeric: tabular-nums;
3088
+ }
3089
+
3090
+ .nice-realtime-point {
3091
+ animation: realtime-pulse 1s ease-out infinite;
3092
+ }
3093
+
3094
+ @keyframes realtime-pulse {
3095
+ 0% { opacity: 1; transform: scale(1); }
3096
+ 50% { opacity: 0.5; transform: scale(1.5); }
3097
+ 100% { opacity: 1; transform: scale(1); }
3098
+ }
3099
+
3100
+ .nice-realtime-status {
3101
+ position: absolute;
3102
+ bottom: 8px;
3103
+ right: 8px;
3104
+ display: flex;
3105
+ align-items: center;
3106
+ gap: 6px;
3107
+ font-size: 11px;
3108
+ color: #6b7280;
3109
+ }
3110
+
3111
+ .nice-realtime-status-dot {
3112
+ width: 8px;
3113
+ height: 8px;
3114
+ border-radius: 50%;
3115
+ background: #22c55e;
3116
+ }
3117
+
3118
+ .nice-realtime-status.paused .nice-realtime-status-dot {
3119
+ background: #f59e0b;
3120
+ }
3121
+
3122
+ .nice-realtime-status.live .nice-realtime-status-dot {
3123
+ animation: live-pulse 2s ease-in-out infinite;
3124
+ }
3125
+
3126
+ @keyframes live-pulse {
3127
+ 0%, 100% { opacity: 1; }
3128
+ 50% { opacity: 0.4; }
3129
+ }
3130
+ ` })
3131
+ ]
3132
+ }
3133
+ );
3134
+ }
3135
+ );
3136
+ et.displayName = "NiceRealtimeChart";
3137
+ const tt = ke.forwardRef(
3138
+ ({
3139
+ data: t,
3140
+ renderNode: o,
3141
+ selectable: l,
3142
+ selectedKey: i,
3143
+ onSelect: c,
3144
+ direction: b = "top-down",
3145
+ collapsible: f = true,
3146
+ className: w,
3147
+ style: B,
3148
+ id: p
3149
+ }, S) => {
3150
+ const N = coreBpghV7Ls.b(p), [z, M] = ke.useState(/* @__PURE__ */ new Set()), v = ke.useCallback((m) => {
3151
+ M((L) => {
3152
+ const x = new Set(L);
3153
+ return x.has(m) ? x.delete(m) : x.add(m), x;
3154
+ });
3155
+ }, []), u = ke.useCallback(
3156
+ (m) => {
3157
+ l && c?.(m);
3158
+ },
3159
+ [l, c]
3160
+ ), h = ke.useCallback(
3161
+ (m) => {
3162
+ const L = z.has(m.key), x = m.children && m.children.length > 0;
3163
+ return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: "nice-org-chart__item", children: [
3164
+ /* @__PURE__ */ jsxRuntime.jsxs(
3165
+ "div",
3166
+ {
3167
+ className: `nice-org-chart__node${i === m.key ? " nice-org-chart__node--selected" : ""}`,
3168
+ onClick: () => u(m.key),
3169
+ role: l ? "button" : void 0,
3170
+ children: [
3171
+ o ? o(m) : /* @__PURE__ */ jsxRuntime.jsx("span", { children: m.label }),
3172
+ f && x && /* @__PURE__ */ jsxRuntime.jsx(
3173
+ "button",
3174
+ {
3175
+ type: "button",
3176
+ className: "nice-org-chart__toggle",
3177
+ onClick: (y) => {
3178
+ y.stopPropagation(), v(m.key);
3179
+ },
3180
+ "aria-label": L ? "Expand" : "Collapse",
3181
+ children: L ? "+" : "−"
3182
+ }
3183
+ )
3184
+ ]
3185
+ }
3186
+ ),
3187
+ x && !L && /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "nice-org-chart__children", children: m.children.map((y) => h(y)) })
3188
+ ] }, m.key);
3189
+ },
3190
+ [z, i, o, l, f, u, v]
3191
+ );
3192
+ return /* @__PURE__ */ jsxRuntime.jsx(
3193
+ "div",
3194
+ {
3195
+ ref: S,
3196
+ id: N,
3197
+ className: `nice-org-chart nice-org-chart--${b} ${w || ""}`,
3198
+ style: B,
3199
+ children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "nice-org-chart__root", children: h(t) })
3200
+ }
3201
+ );
3202
+ }
3203
+ );
3204
+ tt.displayName = "NiceOrganizationChart";
3205
+ function nt(t, o, l) {
3206
+ const i = (M) => {
3207
+ const v = M.replace("#", "");
3208
+ return [
3209
+ parseInt(v.slice(0, 2), 16),
3210
+ parseInt(v.slice(2, 4), 16),
3211
+ parseInt(v.slice(4, 6), 16)
3212
+ ];
3213
+ }, [c, b, f] = i(t), [w, B, p] = i(o), S = Math.round(c + (w - c) * l), N = Math.round(b + (B - b) * l), z = Math.round(f + (p - f) * l);
3214
+ return `rgb(${S},${N},${z})`;
3215
+ }
3216
+ const at = ke.forwardRef(
3217
+ ({
3218
+ data: t,
3219
+ xLabels: o,
3220
+ yLabels: l,
3221
+ colors: i = ["#e0f2fe", "#1d4ed8"],
3222
+ onCellClick: c,
3223
+ cellSize: b = 40,
3224
+ showValues: f = true,
3225
+ className: w,
3226
+ style: B,
3227
+ id: p
3228
+ }, S) => {
3229
+ const N = coreBpghV7Ls.b(p), { minVal: z, maxVal: M } = ke.useMemo(() => {
3230
+ let u = 1 / 0, h = -1 / 0;
3231
+ for (const m of t)
3232
+ for (const L of m)
3233
+ L < u && (u = L), L > h && (h = L);
3234
+ return { minVal: u, maxVal: h };
3235
+ }, [t]), v = ke.useCallback(
3236
+ (u) => M === z ? 0.5 : (u - z) / (M - z),
3237
+ [z, M]
3238
+ );
3239
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: S, id: N, className: `nice-heatmap ${w || ""}`, style: B, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "nice-heatmap__table", children: [
3240
+ o && /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
3241
+ l && /* @__PURE__ */ jsxRuntime.jsx("th", {}),
3242
+ o.map((u, h) => /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-heatmap__header", children: u }, h))
3243
+ ] }) }),
3244
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: t.map((u, h) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
3245
+ l && /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-heatmap__row-label", children: l[h] }),
3246
+ u.map((m, L) => /* @__PURE__ */ jsxRuntime.jsx(
3247
+ "td",
3248
+ {
3249
+ className: "nice-heatmap__cell",
3250
+ style: {
3251
+ background: nt(i[0], i[1], v(m)),
3252
+ width: b,
3253
+ height: b,
3254
+ textAlign: "center",
3255
+ color: v(m) > 0.6 ? "#fff" : "#333",
3256
+ cursor: c ? "pointer" : void 0
3257
+ },
3258
+ onClick: () => c?.(h, L, m),
3259
+ title: String(m),
3260
+ children: f ? m : ""
3261
+ },
3262
+ L
3263
+ ))
3264
+ ] }, h)) })
3265
+ ] }) });
3266
+ }
3267
+ );
3268
+ at.displayName = "NiceHeatMap";
3269
+ function rt(t, o) {
3270
+ const l = t.reduce((p, S) => p + S.value, 0);
3271
+ if (l === 0 || t.length === 0)
3272
+ return [];
3273
+ const i = [];
3274
+ let { x: c, y: b, w: f, h: w } = o;
3275
+ const B = [...t].sort((p, S) => S.value - p.value);
3276
+ for (const p of B) {
3277
+ const S = p.value / l;
3278
+ if (f >= w) {
3279
+ const N = f * S;
3280
+ i.push({ x: c, y: b, w: N, h: w, node: p }), c += N, f -= N;
3281
+ } else {
3282
+ const N = w * S;
3283
+ i.push({ x: c, y: b, w: f, h: N, node: p }), b += N, w -= N;
3284
+ }
3285
+ }
3286
+ return i;
3287
+ }
3288
+ const ct = [
3289
+ "#3b82f6",
3290
+ "#10b981",
3291
+ "#f59e0b",
3292
+ "#ef4444",
3293
+ "#8b5cf6",
3294
+ "#06b6d4",
3295
+ "#ec4899",
3296
+ "#84cc16"
3297
+ ], We = ke.forwardRef(
3298
+ ({ data: t, width: o = 600, height: l = 400, onNodeClick: i, colors: c = ct, className: b, style: f, id: w }, B) => {
3299
+ const p = coreBpghV7Ls.b(w), S = ke.useMemo(() => {
3300
+ const N = t.children ?? [t];
3301
+ return rt(N, { x: 0, y: 0, w: o, h: l });
3302
+ }, [t, o, l]);
3303
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: B, id: p, className: `nice-treemap ${b || ""}`, style: f, children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: o, height: l, className: "nice-treemap__svg", children: S.map((N, z) => /* @__PURE__ */ jsxRuntime.jsxs(
3304
+ "g",
3305
+ {
3306
+ onClick: () => i?.(N.node),
3307
+ style: { cursor: i ? "pointer" : void 0 },
3308
+ children: [
3309
+ /* @__PURE__ */ jsxRuntime.jsx(
3310
+ "rect",
3311
+ {
3312
+ x: N.x,
3313
+ y: N.y,
3314
+ width: Math.max(N.w - 1, 0),
3315
+ height: Math.max(N.h - 1, 0),
3316
+ fill: N.node.color ?? c[z % c.length],
3317
+ rx: 2
3318
+ }
3319
+ ),
3320
+ N.w > 40 && N.h > 20 && /* @__PURE__ */ jsxRuntime.jsx(
3321
+ "text",
3322
+ {
3323
+ x: N.x + N.w / 2,
3324
+ y: N.y + N.h / 2,
3325
+ textAnchor: "middle",
3326
+ dominantBaseline: "central",
3327
+ fill: "#fff",
3328
+ fontSize: Math.min(12, N.w / 6),
3329
+ className: "nice-treemap__label",
3330
+ children: N.node.label
3331
+ }
3332
+ )
3333
+ ]
3334
+ },
3335
+ N.node.key
3336
+ )) }) });
3337
+ }
3338
+ );
3339
+ We.displayName = "NiceTreeMap";
3340
+ const ot = ke.forwardRef(
3341
+ ({
3342
+ data: t,
3343
+ type: o = "candlestick",
3344
+ showVolume: l = true,
3345
+ width: i = 800,
3346
+ height: c = 400,
3347
+ bullColor: b = "#22c55e",
3348
+ bearColor: f = "#ef4444",
3349
+ className: w,
3350
+ style: B,
3351
+ id: p
3352
+ }, S) => {
3353
+ const N = coreBpghV7Ls.b(p), z = { top: 20, right: 20, bottom: l ? 80 : 30, left: 60 }, M = i - z.left - z.right, v = l ? 50 : 0, u = c - z.top - z.bottom - v, { minP: h, maxP: m, maxVol: L } = ke.useMemo(() => {
3354
+ let g = 1 / 0, C = -1 / 0, d = 0;
3355
+ for (const $ of t)
3356
+ $.low < g && (g = $.low), $.high > C && (C = $.high), $.volume && $.volume > d && (d = $.volume);
3357
+ return { minP: g, maxP: C, maxVol: d };
3358
+ }, [t]), x = Math.max(1, M / t.length * 0.7), y = (g) => z.left + (g + 0.5) * (M / t.length), s = (g) => z.top + u - (g - h) / (m - h || 1) * u, T = (g) => c - z.bottom - v + v * (1 - g / (L || 1));
3359
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: S, id: N, className: `nice-stock-chart ${w || ""}`, style: B, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: i, height: c, className: "nice-stock-chart__svg", children: [
3360
+ [0, 0.25, 0.5, 0.75, 1].map((g) => {
3361
+ const C = h + g * (m - h);
3362
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3363
+ /* @__PURE__ */ jsxRuntime.jsx(
3364
+ "line",
3365
+ {
3366
+ x1: z.left,
3367
+ x2: i - z.right,
3368
+ y1: s(C),
3369
+ y2: s(C),
3370
+ stroke: "#e5e7eb",
3371
+ strokeDasharray: "2,2"
3372
+ }
3373
+ ),
3374
+ /* @__PURE__ */ jsxRuntime.jsx("text", { x: z.left - 4, y: s(C) + 4, textAnchor: "end", fontSize: 10, fill: "#888", children: C.toFixed(2) })
3375
+ ] }, g);
3376
+ }),
3377
+ o === "line" ? /* @__PURE__ */ jsxRuntime.jsx(
3378
+ "polyline",
3379
+ {
3380
+ points: t.map((g, C) => `${y(C)},${s(g.close)}`).join(" "),
3381
+ fill: "none",
3382
+ stroke: b,
3383
+ strokeWidth: 1.5
3384
+ }
3385
+ ) : t.map((g, C) => {
3386
+ const d = g.close >= g.open, $ = d ? b : f, A = y(C);
3387
+ if (o === "ohlc")
3388
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3389
+ /* @__PURE__ */ jsxRuntime.jsx(
3390
+ "line",
3391
+ {
3392
+ x1: A,
3393
+ x2: A,
3394
+ y1: s(g.high),
3395
+ y2: s(g.low),
3396
+ stroke: $,
3397
+ strokeWidth: 1
3398
+ }
3399
+ ),
3400
+ /* @__PURE__ */ jsxRuntime.jsx(
3401
+ "line",
3402
+ {
3403
+ x1: A - x / 2,
3404
+ x2: A,
3405
+ y1: s(g.open),
3406
+ y2: s(g.open),
3407
+ stroke: $,
3408
+ strokeWidth: 1.5
3409
+ }
3410
+ ),
3411
+ /* @__PURE__ */ jsxRuntime.jsx(
3412
+ "line",
3413
+ {
3414
+ x1: A,
3415
+ x2: A + x / 2,
3416
+ y1: s(g.close),
3417
+ y2: s(g.close),
3418
+ stroke: $,
3419
+ strokeWidth: 1.5
3420
+ }
3421
+ )
3422
+ ] }, C);
3423
+ const O = s(Math.max(g.open, g.close)), X = s(Math.min(g.open, g.close));
3424
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { children: [
3425
+ /* @__PURE__ */ jsxRuntime.jsx(
3426
+ "line",
3427
+ {
3428
+ x1: A,
3429
+ x2: A,
3430
+ y1: s(g.high),
3431
+ y2: s(g.low),
3432
+ stroke: $,
3433
+ strokeWidth: 1
3434
+ }
3435
+ ),
3436
+ /* @__PURE__ */ jsxRuntime.jsx(
3437
+ "rect",
3438
+ {
3439
+ x: A - x / 2,
3440
+ y: O,
3441
+ width: x,
3442
+ height: Math.max(X - O, 1),
3443
+ fill: d ? "transparent" : $,
3444
+ stroke: $,
3445
+ strokeWidth: 1
3446
+ }
3447
+ )
3448
+ ] }, C);
3449
+ }),
3450
+ l && t.map((g, C) => {
3451
+ if (!g.volume)
3452
+ return null;
3453
+ const d = g.close >= g.open;
3454
+ return /* @__PURE__ */ jsxRuntime.jsx(
3455
+ "rect",
3456
+ {
3457
+ x: y(C) - x / 2,
3458
+ y: T(g.volume),
3459
+ width: x,
3460
+ height: c - z.bottom - T(g.volume),
3461
+ fill: d ? b : f,
3462
+ opacity: 0.3
3463
+ },
3464
+ `v${C}`
3465
+ );
3466
+ }),
3467
+ t.map((g, C) => C % Math.max(1, Math.floor(t.length / 8)) !== 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(
3468
+ "text",
3469
+ {
3470
+ x: y(C),
3471
+ y: c - z.bottom + v + 14,
3472
+ textAnchor: "middle",
3473
+ fontSize: 9,
3474
+ fill: "#888",
3475
+ children: g.date
3476
+ },
3477
+ `l${C}`
3478
+ ))
3479
+ ] }) });
3480
+ }
3481
+ );
3482
+ ot.displayName = "NiceStockChart";
3483
+
3484
+ exports.A = dt;
3485
+ exports.B = Nt;
3486
+ exports.C = me;
3487
+ exports.D = $t;
3488
+ exports.N = Je;
3489
+ exports.R = Ve;
3490
+ exports.a = Mt;
3491
+ exports.b = tt;
3492
+ exports.c = ot;
3493
+ exports.d = We;
3494
+ exports.e = at;
3495
+ exports.f = qe;
3496
+ exports.g = wt;
3497
+ exports.h = _t;
3498
+ exports.i = vt;
3499
+ exports.j = bt;
3500
+ exports.k = yt;
3501
+ exports.l = xt;
3502
+ exports.m = gt;
3503
+ exports.n = mt;
3504
+ exports.o = ze;
3505
+ exports.q = Ke;
3506
+ exports.s = Ge;
3507
+ exports.u = et;
3508
+ //# sourceMappingURL=charts-Bx_kNBsE.js.map