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