@nice2dev/ui 1.0.19 → 1.0.21

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 (120) hide show
  1. package/CHANGELOG.md +105 -0
  2. package/dist/NiceErrorBoundary-B9UWIYPz.js +770 -0
  3. package/dist/NiceErrorBoundary-Bzx-bOeb.cjs +1 -0
  4. package/dist/NiceErrorBoundary-CFJh1FyM.js +770 -0
  5. package/dist/NiceErrorBoundary-DvA00DOz.cjs +1 -0
  6. package/dist/NiceErrorBoundary-XNceAa-3.cjs +1 -0
  7. package/dist/NiceErrorBoundary-eTwBEuSH.js +770 -0
  8. package/dist/NiceErrorBoundary-qp4IJ18o.js +770 -0
  9. package/dist/NiceErrorBoundary-uT48n_F7.cjs +1 -0
  10. package/dist/NiceForm-B1Okz7SW.cjs +382 -0
  11. package/dist/NiceForm-BE8vt5k6.js +5383 -0
  12. package/dist/NiceForm-BXHPoTcH.cjs +382 -0
  13. package/dist/NiceForm-BzKlOWJa.js +5383 -0
  14. package/dist/NiceForm-DL7Kxsi2.js +5383 -0
  15. package/dist/NiceForm-DYPj-XoP.cjs +382 -0
  16. package/dist/NiceForm-DZ8jwtA8.cjs +382 -0
  17. package/dist/NiceForm-D_XZxq3a.js +5383 -0
  18. package/dist/NiceForm.css +1 -1
  19. package/dist/NiceModal-0Sg2HxIb.cjs +1 -0
  20. package/dist/NiceModal-BOkmGqPj.cjs +1 -0
  21. package/dist/NiceModal-BRih_XEH.js +95 -0
  22. package/dist/NiceModal-C-yKNnig.cjs +1 -0
  23. package/dist/NiceModal-C4HIsjrn.js +95 -0
  24. package/dist/NiceModal-DSabJ81z.js +95 -0
  25. package/dist/NiceModal-DieswZtd.cjs +1 -0
  26. package/dist/NiceModal-DjN1yXgw.js +95 -0
  27. package/dist/NiceModuleLifecyclePanel-95lS8pXO.cjs +1 -0
  28. package/dist/NiceModuleLifecyclePanel-C4jlm9tl.cjs +1 -0
  29. package/dist/NiceModuleLifecyclePanel-CEfeJxw_.cjs +1 -0
  30. package/dist/NiceModuleLifecyclePanel-D4xWUswk.js +6777 -0
  31. package/dist/NiceModuleLifecyclePanel-L5FNYzF9.js +6781 -0
  32. package/dist/NiceModuleLifecyclePanel-LdYOMLA6.js +6777 -0
  33. package/dist/NiceModuleLifecyclePanel-jDzEfvDM.js +6553 -0
  34. package/dist/NiceModuleLifecyclePanel-sBJLlhJp.cjs +1 -0
  35. package/dist/NiceModuleLifecyclePanel.css +1 -1
  36. package/dist/NicePagination-B2TC6MTL.cjs +1 -0
  37. package/dist/NicePagination-BAywVGwT.js +171 -0
  38. package/dist/NicePagination-BT8UWXYG.js +171 -0
  39. package/dist/NicePagination-CJqksuAl.cjs +1 -0
  40. package/dist/NicePagination-CiWxbXT9.cjs +1 -0
  41. package/dist/NicePagination-DnnypBiE.js +171 -0
  42. package/dist/NicePagination-F8NyMfgc.cjs +1 -0
  43. package/dist/NicePagination-d6vm1ce3.js +171 -0
  44. package/dist/NicePinCodeInput-BY_tgKaU.cjs +419 -0
  45. package/dist/NicePinCodeInput-Bo8Ahkae.js +12240 -0
  46. package/dist/NicePinCodeInput-CpPtHZsK.js +12240 -0
  47. package/dist/NicePinCodeInput-Cpa01Yfg.cjs +419 -0
  48. package/dist/NicePinCodeInput-DDK6qqFW.js +12240 -0
  49. package/dist/NicePinCodeInput-DdXTdocN.js +12240 -0
  50. package/dist/NicePinCodeInput-JvYd_LB_.cjs +419 -0
  51. package/dist/NicePinCodeInput-qAO9tRhm.cjs +419 -0
  52. package/dist/NiceSavedQueryPanel-BOBULytX.js +6455 -0
  53. package/dist/NiceSavedQueryPanel-CTfC-qwV.cjs +596 -0
  54. package/dist/NiceSavedQueryPanel-CpcjQZDl.cjs +596 -0
  55. package/dist/NiceSavedQueryPanel-Dryck7pv.js +6584 -0
  56. package/dist/NiceSavedQueryPanel-DtgcsEls.js +6584 -0
  57. package/dist/NiceSavedQueryPanel-DuonbEem.js +6584 -0
  58. package/dist/NiceSavedQueryPanel-MdKdGYNg.cjs +596 -0
  59. package/dist/NiceSavedQueryPanel-TUoWkvpW.cjs +596 -0
  60. package/dist/NiceTabs-BjBtazRn.cjs +1 -0
  61. package/dist/NiceTabs-C-VQXNIa.cjs +1 -0
  62. package/dist/NiceTabs-CJ8G2t0-.js +1657 -0
  63. package/dist/NiceTabs-D91-vW_P.js +1657 -0
  64. package/dist/NiceTabs-DirTIQjD.cjs +1 -0
  65. package/dist/NiceTabs-dwNCzbJ2.cjs +1 -0
  66. package/dist/NiceTabs-nQEYYbsV.js +1657 -0
  67. package/dist/NiceTabs-v7HfeXIw.js +1657 -0
  68. package/dist/NiceWindow-BMiF-so6.cjs +1 -0
  69. package/dist/NiceWindow-C677O__r.js +1418 -0
  70. package/dist/NiceWindow-CmgJGE4d.js +1418 -0
  71. package/dist/NiceWindow-CysIgnn3.js +1418 -0
  72. package/dist/NiceWindow-D6SjpDc4.cjs +1 -0
  73. package/dist/NiceWindow-DUTRQOaP.js +1418 -0
  74. package/dist/NiceWindow-D_h01zyu.cjs +1 -0
  75. package/dist/NiceWindow-fcTJOlYf.cjs +1 -0
  76. package/dist/charts-8Bqzj1TE.js +4657 -0
  77. package/dist/charts-CFn-7PzC.cjs +761 -0
  78. package/dist/charts-CJlMAHJG.cjs +761 -0
  79. package/dist/charts-CLbJ4Zjq.js +4657 -0
  80. package/dist/charts-CUMpSAQe.cjs +761 -0
  81. package/dist/charts-CX4jiyVh.cjs +761 -0
  82. package/dist/charts-CYpqDxHd.js +4657 -0
  83. package/dist/charts-P6qura0j.js +4657 -0
  84. package/dist/charts.cjs +1 -1
  85. package/dist/charts.mjs +1 -1
  86. package/dist/core-BFu5opn6.js +23131 -0
  87. package/dist/core-BfeyB9A8.cjs +96 -0
  88. package/dist/core-BgGSTko-.js +22401 -0
  89. package/dist/core-Bit5kLWQ.cjs +96 -0
  90. package/dist/core-D0ElqRZA.cjs +96 -0
  91. package/dist/core-DDJKu5LZ.cjs +96 -0
  92. package/dist/core-DICON6Z7.js +23129 -0
  93. package/dist/core-XsWxyBHD.js +22767 -0
  94. package/dist/data.cjs +1 -1
  95. package/dist/data.mjs +1 -1
  96. package/dist/editors.cjs +1 -1
  97. package/dist/editors.mjs +3 -3
  98. package/dist/feedback.cjs +1 -1
  99. package/dist/feedback.mjs +2 -2
  100. package/dist/index-B-WxtREy.js +65040 -0
  101. package/dist/index-ByDRtfrm.js +65050 -0
  102. package/dist/index-CQIDqjZp.cjs +5194 -0
  103. package/dist/index-CXVXf_HY.cjs +5194 -0
  104. package/dist/index-CtikFbFa.js +64337 -0
  105. package/dist/index-DnfPyuXA.cjs +5194 -0
  106. package/dist/index-DxO61OUF.cjs +5194 -0
  107. package/dist/index-xVJiF843.js +65040 -0
  108. package/dist/index.cjs +1 -1
  109. package/dist/index.css +1 -1
  110. package/dist/index.d.ts +294 -5
  111. package/dist/index.mjs +875 -861
  112. package/dist/lazy.cjs +1 -1
  113. package/dist/lazy.mjs +3 -3
  114. package/dist/navigation.cjs +1 -1
  115. package/dist/navigation.d.ts +35 -2
  116. package/dist/navigation.mjs +22 -22
  117. package/dist/overlays.cjs +1 -1
  118. package/dist/overlays.mjs +2 -2
  119. package/dist/style.css +3 -3
  120. package/package.json +3 -3
@@ -0,0 +1,4657 @@
1
+ import { jsx as e, jsxs as $, Fragment as Pe } from "react/jsx-runtime";
2
+ import Fe, { useRef as be, useState as oe, useMemo as pe, useCallback as ae, forwardRef as Ne, useEffect as Ce, useImperativeHandle as Ae } from "react";
3
+ import { J as Ve, i as Xe, $ as Ze, H as ze } from "./core-BFu5opn6.js";
4
+ const ke = [
5
+ "var(--color-primary, #3b82f6)",
6
+ "var(--color-error, #ef4444)",
7
+ "var(--color-success, #22c55e)",
8
+ "var(--color-warning, #f59e0b)",
9
+ "var(--color-accent, #8b5cf6)",
10
+ "var(--color-accent-pink, #ec4899)",
11
+ "var(--color-info, #06b6d4)",
12
+ "var(--nice-success, #84cc16)"
13
+ ], Re = ({
14
+ series: t,
15
+ categories: o,
16
+ width: i = 600,
17
+ height: s = 400,
18
+ title: c,
19
+ showLegend: v = !0,
20
+ showGrid: p = !0,
21
+ axisLabels: I = !0,
22
+ yAxisLabel: T,
23
+ xAxisLabel: w,
24
+ stacked: f,
25
+ animated: N,
26
+ zoomable: z,
27
+ crosshair: C,
28
+ annotations: k,
29
+ legendInteractive: l,
30
+ onDataPointClick: d,
31
+ exportable: u,
32
+ className: S,
33
+ style: g
34
+ }) => {
35
+ const x = be(null), [y, b] = oe(/* @__PURE__ */ new Set()), [h, D] = oe(null), [a, _] = oe(null), [A, O] = oe(!1), U = be(null), V = pe(
36
+ () => t.filter((B) => !y.has(B.name)),
37
+ [t, y]
38
+ ), j = ae(
39
+ (B) => {
40
+ l && b((re) => {
41
+ const ce = new Set(re);
42
+ return ce.has(B) ? ce.delete(B) : ce.add(B), ce;
43
+ });
44
+ },
45
+ [l]
46
+ ), G = {
47
+ top: c ? 40 : 20,
48
+ right: 20,
49
+ bottom: w ? 60 : 40,
50
+ left: T ? 60 : 50
51
+ }, Q = i - G.left - G.right, q = s - G.top - G.bottom, J = V[0]?.data.length ?? t[0]?.data.length ?? 0, n = a?.start ?? 0, X = a?.end ?? J, H = X - n, W = pe(
52
+ () => V.map((B) => ({ ...B, data: B.data.slice(n, X) })),
53
+ [V, n, X]
54
+ ), m = pe(
55
+ () => o?.slice(n, X),
56
+ [o, n, X]
57
+ ), { minY: F, maxY: Y, yTicks: ee } = pe(() => {
58
+ let B;
59
+ if (f) {
60
+ B = [];
61
+ for (let M = 0; M < H; M++)
62
+ B.push(W.reduce((K, ie) => K + (ie.data[M] || 0), 0));
63
+ } else
64
+ B = W.flatMap((M) => M.data);
65
+ B.length === 0 && (B = [0]);
66
+ const re = Math.min(0, ...B), ce = Math.max(0, ...B), se = ce - re || 1, de = Math.pow(10, Math.floor(Math.log10(se))) || 1, r = Math.floor(re / de) * de, R = Math.ceil(ce / de) * de, E = [];
67
+ for (let M = r; M <= R; M += de)
68
+ E.push(Math.round(M * 1e6) / 1e6);
69
+ return E.length < 2 && E.push(R), { minY: r, maxY: R, yTicks: E };
70
+ }, [W, H, f]), P = (B) => q - (B - F) / (Y - F || 1) * q, te = (B) => (B + 0.5) / H * Q, fe = H > 0 ? Q / H / (f ? 1.5 : Math.max(V.length, 1) * 1.5) : 20, L = ae(
71
+ (B) => {
72
+ if (!z)
73
+ return;
74
+ B.preventDefault();
75
+ const re = a ?? { start: 0, end: J }, ce = re.end - re.start, se = (re.start + re.end) / 2, de = B.deltaY > 0 ? 1.2 : 0.8, r = Math.max(2, Math.min(J, Math.round(ce * de))), R = Math.max(0, Math.round(se - r / 2)), E = Math.min(J, R + r);
76
+ _({ start: R, end: E });
77
+ },
78
+ [z, a, J]
79
+ ), Z = ae(
80
+ (B) => {
81
+ z && (O(!0), U.current = { x: B.clientX, range: a ?? { start: 0, end: J } });
82
+ },
83
+ [z, a, J]
84
+ ), ne = ae(
85
+ (B) => {
86
+ const re = x.current?.getBoundingClientRect();
87
+ if (re && D({ x: B.clientX - re.left - G.left, y: B.clientY - re.top - G.top }), A && U.current && z) {
88
+ const ce = B.clientX - U.current.x, se = Q / H, de = -Math.round(ce / se), r = U.current.range, R = r.end - r.start;
89
+ let E = r.start + de;
90
+ E < 0 && (E = 0), E + R > J && (E = J - R), _({ start: E, end: E + R });
91
+ }
92
+ },
93
+ [A, z, Q, H, J, G.left, G.top]
94
+ ), ue = ae(() => {
95
+ O(!1), U.current = null;
96
+ }, []), _e = ae(() => {
97
+ D(null), O(!1), U.current = null;
98
+ }, []), ge = ae(() => {
99
+ const B = x.current;
100
+ if (!B)
101
+ return;
102
+ const re = new XMLSerializer().serializeToString(B), ce = document.createElement("canvas");
103
+ ce.width = i, ce.height = s + (v ? 30 : 0);
104
+ const se = ce.getContext("2d");
105
+ if (!se)
106
+ return;
107
+ const de = new Image();
108
+ de.onload = () => {
109
+ se.fillStyle = "var(--bg-primary, #fff)", se.fillRect(0, 0, ce.width, ce.height), se.drawImage(de, 0, 0);
110
+ const r = document.createElement("a");
111
+ r.download = "chart.png", r.href = ce.toDataURL("image/png"), r.click();
112
+ }, de.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(re);
113
+ }, [i, s, v]), ye = s + (v ? 30 : 0), $e = W.length > 0 && W.every((B) => B.type === "radar"), Se = pe(() => {
114
+ if (!$e)
115
+ return 1;
116
+ const B = W.flatMap((re) => re.data);
117
+ return Math.max(1, ...B);
118
+ }, [$e, W]);
119
+ if ($e) {
120
+ const B = i / 2, re = (s - G.top - G.bottom) / 2 + G.top, ce = Math.min(Q, s - G.top - G.bottom) / 2 - 10, se = m?.length ?? W[0]?.data.length ?? 0, de = (E) => E / se * Math.PI * 2 - Math.PI / 2, r = (E, M) => {
121
+ const K = M / Se * ce;
122
+ return [B + Math.cos(de(E)) * K, re + Math.sin(de(E)) * K];
123
+ }, R = 4;
124
+ return /* @__PURE__ */ e("div", { className: `nice-chart nice-chart--radar ${S || ""}`, style: g, children: /* @__PURE__ */ $(
125
+ "svg",
126
+ {
127
+ ref: x,
128
+ viewBox: `0 0 ${i} ${ye}`,
129
+ preserveAspectRatio: "xMidYMid meet",
130
+ width: "100%",
131
+ height: "100%",
132
+ className: "nice-chart__svg",
133
+ style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
134
+ children: [
135
+ c && /* @__PURE__ */ e("text", { x: i / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: c }),
136
+ p && Array.from({ length: R }, (E, M) => {
137
+ const K = (M + 1) / R * ce, ie = [];
138
+ for (let le = 0; le < se; le++)
139
+ ie.push(`${B + Math.cos(de(le)) * K},${re + Math.sin(de(le)) * K}`);
140
+ return /* @__PURE__ */ e(
141
+ "polygon",
142
+ {
143
+ points: ie.join(" "),
144
+ fill: "none",
145
+ className: "nice-chart__grid-line"
146
+ },
147
+ M
148
+ );
149
+ }),
150
+ Array.from({ length: se }, (E, M) => {
151
+ const [K, ie] = r(M, Se);
152
+ return /* @__PURE__ */ e("line", { x1: B, y1: re, x2: K, y2: ie, className: "nice-chart__grid-line" }, M);
153
+ }),
154
+ I && m?.map((E, M) => {
155
+ const [K, ie] = r(M, Se * 1.12);
156
+ return /* @__PURE__ */ e(
157
+ "text",
158
+ {
159
+ x: K,
160
+ y: ie,
161
+ textAnchor: "middle",
162
+ dominantBaseline: "middle",
163
+ className: "nice-chart__axis-label",
164
+ children: E
165
+ },
166
+ M
167
+ );
168
+ }),
169
+ W.map((E, M) => {
170
+ const K = E.color || ke[M % ke.length], ie = E.data.map((le, he) => r(he, le).join(",")).join(" ");
171
+ return /* @__PURE__ */ $(
172
+ "g",
173
+ {
174
+ className: N ? "nice-chart__series nice-chart__series--radar nice-chart__series--anim" : "nice-chart__series nice-chart__series--radar",
175
+ children: [
176
+ /* @__PURE__ */ e(
177
+ "polygon",
178
+ {
179
+ points: ie,
180
+ fill: K,
181
+ fillOpacity: 0.2,
182
+ stroke: K,
183
+ strokeWidth: 2
184
+ }
185
+ ),
186
+ E.data.map((le, he) => {
187
+ const [we, Me] = r(he, le);
188
+ return /* @__PURE__ */ e("circle", { cx: we, cy: Me, r: 3, fill: K, children: /* @__PURE__ */ e("title", { children: `${E.name}: ${le}` }) }, he);
189
+ })
190
+ ]
191
+ },
192
+ E.name
193
+ );
194
+ }),
195
+ v && /* @__PURE__ */ e("g", { transform: `translate(${G.left}, ${s})`, children: t.map((E, M) => {
196
+ const K = M * 120, ie = y.has(E.name);
197
+ return /* @__PURE__ */ $(
198
+ "g",
199
+ {
200
+ transform: `translate(${K}, 10)`,
201
+ style: l ? { cursor: "pointer" } : void 0,
202
+ onClick: () => j(E.name),
203
+ opacity: ie ? 0.35 : 1,
204
+ children: [
205
+ /* @__PURE__ */ e(
206
+ "rect",
207
+ {
208
+ width: 12,
209
+ height: 12,
210
+ rx: 2,
211
+ fill: E.color || ke[M % ke.length]
212
+ }
213
+ ),
214
+ /* @__PURE__ */ e("text", { x: 16, y: 10, className: "nice-chart__legend-text", children: E.name })
215
+ ]
216
+ },
217
+ E.name
218
+ );
219
+ }) })
220
+ ]
221
+ }
222
+ ) });
223
+ }
224
+ return /* @__PURE__ */ $("div", { className: `nice-chart ${S || ""}`, style: g, children: [
225
+ u && /* @__PURE__ */ e(
226
+ "button",
227
+ {
228
+ type: "button",
229
+ className: "nice-chart__export-btn",
230
+ onClick: ge,
231
+ title: "Export PNG",
232
+ children: "📷"
233
+ }
234
+ ),
235
+ /* @__PURE__ */ $(
236
+ "svg",
237
+ {
238
+ ref: x,
239
+ viewBox: `0 0 ${i} ${ye}`,
240
+ preserveAspectRatio: "xMidYMid meet",
241
+ width: "100%",
242
+ height: "100%",
243
+ style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
244
+ className: "nice-chart__svg",
245
+ onWheel: L,
246
+ onMouseDown: Z,
247
+ onMouseMove: ne,
248
+ onMouseUp: ue,
249
+ onMouseLeave: _e,
250
+ children: [
251
+ /* @__PURE__ */ $("g", { transform: `translate(${G.left},${G.top})`, children: [
252
+ c && /* @__PURE__ */ e("text", { x: Q / 2, y: -10, textAnchor: "middle", className: "nice-chart__title", children: c }),
253
+ p && ee.map((B) => /* @__PURE__ */ e(
254
+ "line",
255
+ {
256
+ x1: 0,
257
+ y1: P(B),
258
+ x2: Q,
259
+ y2: P(B),
260
+ className: "nice-chart__grid-line"
261
+ },
262
+ `grid-${B}`
263
+ )),
264
+ I && ee.map((B) => /* @__PURE__ */ e(
265
+ "text",
266
+ {
267
+ x: -8,
268
+ y: P(B) + 4,
269
+ textAnchor: "end",
270
+ className: "nice-chart__axis-label",
271
+ children: B
272
+ },
273
+ `ylabel-${B}`
274
+ )),
275
+ I && m && m.map((B, re) => /* @__PURE__ */ e(
276
+ "text",
277
+ {
278
+ x: te(re),
279
+ y: q + 20,
280
+ textAnchor: "middle",
281
+ className: "nice-chart__axis-label",
282
+ children: B
283
+ },
284
+ re
285
+ )),
286
+ T && /* @__PURE__ */ e(
287
+ "text",
288
+ {
289
+ x: -G.left + 14,
290
+ y: q / 2,
291
+ textAnchor: "middle",
292
+ transform: `rotate(-90, -${G.left - 14}, ${q / 2})`,
293
+ className: "nice-chart__axis-title",
294
+ children: T
295
+ }
296
+ ),
297
+ w && /* @__PURE__ */ e("text", { x: Q / 2, y: q + 45, textAnchor: "middle", className: "nice-chart__axis-title", children: w }),
298
+ /* @__PURE__ */ e("line", { x1: 0, y1: 0, x2: 0, y2: q, className: "nice-chart__axis" }),
299
+ /* @__PURE__ */ e("line", { x1: 0, y1: q, x2: Q, y2: q, className: "nice-chart__axis" }),
300
+ k?.map((B, re) => {
301
+ if (B.type === "line") {
302
+ const ce = P(B.value);
303
+ return /* @__PURE__ */ $("g", { children: [
304
+ /* @__PURE__ */ e(
305
+ "line",
306
+ {
307
+ x1: 0,
308
+ y1: ce,
309
+ x2: Q,
310
+ y2: ce,
311
+ stroke: B.color || "var(--color-error, #ef4444)",
312
+ strokeWidth: 1.5,
313
+ strokeDasharray: B.dash || "6,3"
314
+ }
315
+ ),
316
+ B.label && /* @__PURE__ */ e(
317
+ "text",
318
+ {
319
+ x: Q + 4,
320
+ y: ce + 4,
321
+ className: "nice-chart__annotation-label",
322
+ fill: B.color || "var(--color-error, #ef4444)",
323
+ children: B.label
324
+ }
325
+ )
326
+ ] }, re);
327
+ }
328
+ return /* @__PURE__ */ e(
329
+ "text",
330
+ {
331
+ x: te(B.value),
332
+ y: -4,
333
+ textAnchor: "middle",
334
+ className: "nice-chart__annotation-label",
335
+ fill: B.color || "var(--text-muted, #6b7280)",
336
+ children: B.label
337
+ },
338
+ re
339
+ );
340
+ }),
341
+ C && h && h.x >= 0 && h.x <= Q && h.y >= 0 && h.y <= q && /* @__PURE__ */ $(Pe, { children: [
342
+ /* @__PURE__ */ e(
343
+ "line",
344
+ {
345
+ x1: h.x,
346
+ y1: 0,
347
+ x2: h.x,
348
+ y2: q,
349
+ stroke: "var(--nice-text-muted, #9ca3af)",
350
+ strokeWidth: 1,
351
+ strokeDasharray: "4,2"
352
+ }
353
+ ),
354
+ /* @__PURE__ */ e(
355
+ "line",
356
+ {
357
+ x1: 0,
358
+ y1: h.y,
359
+ x2: Q,
360
+ y2: h.y,
361
+ stroke: "var(--nice-text-muted, #9ca3af)",
362
+ strokeWidth: 1,
363
+ strokeDasharray: "4,2"
364
+ }
365
+ )
366
+ ] }),
367
+ W.map((B, re) => {
368
+ const ce = B.color || ke[re % ke.length], se = B.type || "bar";
369
+ if (se === "bar")
370
+ return /* @__PURE__ */ e(
371
+ "g",
372
+ {
373
+ className: N ? "nice-chart__series nice-chart__series--bar nice-chart__series--anim" : "nice-chart__series nice-chart__series--bar",
374
+ children: B.data.map((r, R) => {
375
+ let E, M;
376
+ if (f) {
377
+ const ie = W.slice(0, re).reduce((le, he) => le + (he.data[R] || 0), 0);
378
+ E = P(ie + r), M = P(ie) - E;
379
+ } else
380
+ E = P(Math.max(0, r)), M = Math.abs(P(r) - P(0));
381
+ const K = f ? te(R) - fe / 2 : te(R) - W.length * fe / 2 + re * fe;
382
+ return /* @__PURE__ */ e(
383
+ "rect",
384
+ {
385
+ x: K,
386
+ y: E,
387
+ width: fe * 0.9,
388
+ height: Math.max(0, M),
389
+ fill: ce,
390
+ rx: 2,
391
+ style: {
392
+ transformOrigin: `${K + fe * 0.9 / 2}px ${P(0)}px`,
393
+ ...d ? { cursor: "pointer" } : {}
394
+ },
395
+ onClick: d ? () => d(B.name, n + R, r) : void 0,
396
+ children: /* @__PURE__ */ e("title", { children: `${B.name}: ${r}` })
397
+ },
398
+ R
399
+ );
400
+ })
401
+ },
402
+ B.name
403
+ );
404
+ if (se === "scatter")
405
+ return /* @__PURE__ */ e(
406
+ "g",
407
+ {
408
+ className: N ? "nice-chart__series nice-chart__series--scatter nice-chart__series--anim" : "nice-chart__series nice-chart__series--scatter",
409
+ children: B.data.map((r, R) => /* @__PURE__ */ e(
410
+ "circle",
411
+ {
412
+ cx: te(R),
413
+ cy: P(r),
414
+ r: 5,
415
+ fill: ce,
416
+ fillOpacity: 0.7,
417
+ stroke: ce,
418
+ strokeWidth: 1.5,
419
+ style: d ? { cursor: "pointer" } : void 0,
420
+ onClick: d ? () => d(B.name, n + R, r) : void 0,
421
+ children: /* @__PURE__ */ e("title", { children: `${B.name}: ${r}` })
422
+ },
423
+ R
424
+ ))
425
+ },
426
+ B.name
427
+ );
428
+ const de = B.data.map((r, R) => `${te(R)},${P(r)}`);
429
+ return /* @__PURE__ */ $(
430
+ "g",
431
+ {
432
+ className: N ? `nice-chart__series nice-chart__series--${se} nice-chart__series--anim` : `nice-chart__series nice-chart__series--${se}`,
433
+ children: [
434
+ se === "area" && /* @__PURE__ */ e(
435
+ "polygon",
436
+ {
437
+ points: `${te(0)},${P(0)} ${de.join(" ")} ${te(H - 1)},${P(0)}`,
438
+ fill: ce,
439
+ opacity: 0.15
440
+ }
441
+ ),
442
+ /* @__PURE__ */ e(
443
+ "polyline",
444
+ {
445
+ points: de.join(" "),
446
+ fill: "none",
447
+ stroke: ce,
448
+ strokeWidth: 2,
449
+ className: N ? "nice-chart__line" : void 0
450
+ }
451
+ ),
452
+ B.data.map((r, R) => /* @__PURE__ */ e(
453
+ "circle",
454
+ {
455
+ cx: te(R),
456
+ cy: P(r),
457
+ r: 3,
458
+ fill: ce,
459
+ style: d ? { cursor: "pointer" } : void 0,
460
+ onClick: d ? () => d(B.name, n + R, r) : void 0,
461
+ children: /* @__PURE__ */ e("title", { children: `${B.name}: ${r}` })
462
+ },
463
+ R
464
+ ))
465
+ ]
466
+ },
467
+ B.name
468
+ );
469
+ })
470
+ ] }),
471
+ v && /* @__PURE__ */ e("g", { transform: `translate(${G.left}, ${s})`, children: t.map((B, re) => {
472
+ const ce = re * 120, se = y.has(B.name);
473
+ return /* @__PURE__ */ $(
474
+ "g",
475
+ {
476
+ transform: `translate(${ce}, 10)`,
477
+ style: l ? { cursor: "pointer" } : void 0,
478
+ onClick: () => j(B.name),
479
+ opacity: se ? 0.35 : 1,
480
+ children: [
481
+ /* @__PURE__ */ e("rect", { width: 12, height: 12, rx: 2, fill: B.color || ke[re % ke.length] }),
482
+ /* @__PURE__ */ e(
483
+ "text",
484
+ {
485
+ x: 16,
486
+ y: 10,
487
+ className: "nice-chart__legend-text",
488
+ style: se ? { textDecoration: "line-through" } : void 0,
489
+ children: B.name
490
+ }
491
+ )
492
+ ]
493
+ },
494
+ B.name
495
+ );
496
+ }) })
497
+ ]
498
+ }
499
+ )
500
+ ] });
501
+ }, mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
502
+ __proto__: null,
503
+ NiceChart: Re
504
+ }, Symbol.toStringTag, { value: "Module" }));
505
+ function Ue(t) {
506
+ if (!t.length)
507
+ return { categories: [], numericFields: [], sampleValues: {} };
508
+ const o = t[0], i = [], s = {};
509
+ let c = null;
510
+ for (const [p, I] of Object.entries(o))
511
+ typeof I == "number" ? (i.push(p), s[p] = t.map((T) => Number(T[p]) || 0)) : !c && (typeof I == "string" || I instanceof Date) && (c = p);
512
+ return { categories: c ? t.map((p) => String(p[c] || "")) : t.map((p, I) => `Item ${I + 1}`), numericFields: i, sampleValues: s };
513
+ }
514
+ function Ge(t, o) {
515
+ const { categories: i, numericFields: s, sampleValues: c } = Ue(t);
516
+ return { series: s.map((p, I) => ({
517
+ name: p.replace(/([A-Z])/g, " $1").replace(/^./, (T) => T.toUpperCase()).trim(),
518
+ data: c[p],
519
+ type: o === "area" ? "area" : o === "line" ? "line" : "bar"
520
+ })), categories: i };
521
+ }
522
+ const pt = Ne(
523
+ function(o, i) {
524
+ const {
525
+ rawData: s,
526
+ enableAI: c = !0,
527
+ aiModel: v,
528
+ enableAutoType: p = !0,
529
+ enableInsights: I = !0,
530
+ dataDescription: T,
531
+ onChartSuggestion: w,
532
+ onInsights: f,
533
+ showAIToolbar: N = !0,
534
+ showInsightsOnLoad: z = !1,
535
+ series: C,
536
+ categories: k,
537
+ ...l
538
+ } = o, [d, u] = oe("bar"), [S, g] = oe(null), [x, y] = oe([]), [b, h] = oe(z), [D, a] = oe(null), { t: _ } = Ve(), A = Xe(), {
539
+ suggestChartType: O,
540
+ generateInsights: U,
541
+ isLoading: V
542
+ } = Ze(), j = c && A.isConfigured, { series: G, categories: Q } = s ? Ge(s, D || d) : { series: C || [], categories: k }, q = ae(async () => {
543
+ if (!j || !p)
544
+ return { type: "bar", reason: "Default", config: {} };
545
+ const W = s || (C?.length ? C.flatMap((m) => m.data.map((F, Y) => ({ [m.name]: F, index: Y }))) : []);
546
+ try {
547
+ const m = await O(W, T), F = {
548
+ type: m.type,
549
+ reason: m.reason,
550
+ config: m.config
551
+ };
552
+ return g(F), u(F.type), w?.(F), F;
553
+ } catch {
554
+ return { type: "bar", reason: "Default fallback", config: {} };
555
+ }
556
+ }, [
557
+ j,
558
+ p,
559
+ s,
560
+ C,
561
+ T,
562
+ O,
563
+ w
564
+ ]), J = ae(async () => {
565
+ if (!j || !I)
566
+ return [];
567
+ const W = s || (C?.length ? C.flatMap(
568
+ (m) => m.data.map((F, Y) => ({ [m.name]: F, category: k?.[Y] || Y }))
569
+ ) : []);
570
+ try {
571
+ const m = await U(W, D || d);
572
+ return y(m), f?.(m), m;
573
+ } catch {
574
+ return [];
575
+ }
576
+ }, [
577
+ j,
578
+ I,
579
+ s,
580
+ C,
581
+ k,
582
+ d,
583
+ D,
584
+ U,
585
+ f
586
+ ]), n = ae(
587
+ () => D || d,
588
+ [D, d]
589
+ );
590
+ Ce(() => {
591
+ j && p && (s?.length || C?.length) && q();
592
+ }, [j, p, s, C]), Ae(i, () => ({
593
+ getSuggestion: q,
594
+ generateInsights: J,
595
+ getCurrentType: n
596
+ }));
597
+ const X = [
598
+ { type: "bar", icon: "📊", label: "Bar" },
599
+ { type: "line", icon: "📈", label: "Line" },
600
+ { type: "area", icon: "🏔️", label: "Area" },
601
+ { type: "pie", icon: "🥧", label: "Pie" },
602
+ { type: "donut", icon: "🍩", label: "Donut" },
603
+ { type: "scatter", icon: "⭐", label: "Scatter" }
604
+ ], H = D || d;
605
+ return /* @__PURE__ */ $("div", { className: "nice-chart-ai", "data-testid": o["data-testid"], children: [
606
+ N && j && /* @__PURE__ */ $("div", { className: "nice-chart-ai__toolbar", children: [
607
+ /* @__PURE__ */ $("div", { className: "nice-chart-ai__toolbar-left", children: [
608
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__badge", children: "AI" }),
609
+ S && /* @__PURE__ */ $("div", { className: "nice-chart-ai__suggestion", children: [
610
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__suggestion-icon", children: "💡" }),
611
+ /* @__PURE__ */ $("span", { className: "nice-chart-ai__suggestion-text", children: [
612
+ _("chartAI.suggestedType", "Suggested:"),
613
+ " ",
614
+ S.type
615
+ ] }),
616
+ /* @__PURE__ */ $("span", { className: "nice-chart-ai__suggestion-reason", title: S.reason, children: [
617
+ "(",
618
+ S.reason,
619
+ ")"
620
+ ] })
621
+ ] }),
622
+ V && /* @__PURE__ */ e("span", { className: "nice-chart-ai__loading", children: _("chartAI.analyzing", "Analyzing...") })
623
+ ] }),
624
+ /* @__PURE__ */ e("div", { className: "nice-chart-ai__toolbar-center", children: /* @__PURE__ */ e("div", { className: "nice-chart-ai__type-selector", children: X.filter((W) => ["bar", "line", "area"].includes(W.type)).map(({ type: W, icon: m, label: F }) => /* @__PURE__ */ e(
625
+ "button",
626
+ {
627
+ type: "button",
628
+ className: `nice-chart-ai__type-btn ${H === W ? "nice-chart-ai__type-btn--active" : ""}`,
629
+ onClick: () => a(W),
630
+ title: F,
631
+ children: m
632
+ },
633
+ W
634
+ )) }) }),
635
+ /* @__PURE__ */ $("div", { className: "nice-chart-ai__toolbar-right", children: [
636
+ /* @__PURE__ */ $(
637
+ "button",
638
+ {
639
+ type: "button",
640
+ className: "nice-chart-ai__auto-btn",
641
+ onClick: () => q(),
642
+ disabled: V,
643
+ title: _("chartAI.autoDetect", "Auto-detect best chart type"),
644
+ children: [
645
+ "🔮 ",
646
+ _("chartAI.auto", "Auto")
647
+ ]
648
+ }
649
+ ),
650
+ I && /* @__PURE__ */ $(
651
+ "button",
652
+ {
653
+ type: "button",
654
+ className: "nice-chart-ai__insights-btn",
655
+ onClick: () => {
656
+ x.length || J(), h(!b);
657
+ },
658
+ disabled: V,
659
+ title: _("chartAI.showInsights", "Show data insights"),
660
+ children: [
661
+ "💡 ",
662
+ _("chartAI.insights", "Insights")
663
+ ]
664
+ }
665
+ )
666
+ ] })
667
+ ] }),
668
+ /* @__PURE__ */ e("div", { className: "nice-chart-ai__chart-wrapper", children: /* @__PURE__ */ e(Re, { series: G, categories: Q, ...l }) }),
669
+ b && x.length > 0 && /* @__PURE__ */ $("div", { className: "nice-chart-ai__insights", children: [
670
+ /* @__PURE__ */ $("div", { className: "nice-chart-ai__insights-header", children: [
671
+ /* @__PURE__ */ $("h4", { children: [
672
+ "💡 ",
673
+ _("chartAI.dataInsights", "Data Insights")
674
+ ] }),
675
+ /* @__PURE__ */ e(
676
+ "button",
677
+ {
678
+ type: "button",
679
+ className: "nice-chart-ai__insights-close",
680
+ onClick: () => h(!1),
681
+ children: "✕"
682
+ }
683
+ )
684
+ ] }),
685
+ /* @__PURE__ */ e("ul", { className: "nice-chart-ai__insights-list", children: x.map((W, m) => /* @__PURE__ */ $("li", { className: "nice-chart-ai__insight", children: [
686
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__insight-icon", children: "•" }),
687
+ W
688
+ ] }, m)) }),
689
+ /* @__PURE__ */ e("div", { className: "nice-chart-ai__insights-footer", children: /* @__PURE__ */ $(
690
+ "button",
691
+ {
692
+ type: "button",
693
+ className: "nice-chart-ai__refresh",
694
+ onClick: () => J(),
695
+ disabled: V,
696
+ children: [
697
+ "🔄 ",
698
+ _("chartAI.refresh", "Refresh")
699
+ ]
700
+ }
701
+ ) })
702
+ ] }),
703
+ b && V && /* @__PURE__ */ e("div", { className: "nice-chart-ai__insights nice-chart-ai__insights--loading", children: /* @__PURE__ */ $("div", { className: "nice-chart-ai__loading-content", children: [
704
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__spinner" }),
705
+ _("chartAI.generatingInsights", "Generating insights...")
706
+ ] }) })
707
+ ] });
708
+ }
709
+ );
710
+ function qe(t, o) {
711
+ const i = t ? typeof t == "number" ? new Date(t) : new Date(t) : /* @__PURE__ */ new Date(), s = (T) => T.toString().padStart(2, "0"), c = s(i.getHours()), v = s(i.getMinutes()), p = s(i.getSeconds()), I = i.getMilliseconds().toString().padStart(3, "0");
712
+ switch (o) {
713
+ case "HH:mm:ss":
714
+ return `${c}:${v}:${p}`;
715
+ case "HH:mm":
716
+ return `${c}:${v}`;
717
+ case "mm:ss":
718
+ return `${v}:${p}`;
719
+ case "ss.SSS":
720
+ return `${p}.${I}`;
721
+ case "ISO":
722
+ return i.toISOString();
723
+ default:
724
+ return `${c}:${v}:${p}`;
725
+ }
726
+ }
727
+ function We(t) {
728
+ if (t.length === 0)
729
+ return null;
730
+ const o = Math.min(...t), i = Math.max(...t), s = t.reduce((v, p) => v + p, 0) / t.length, c = t[t.length - 1];
731
+ return { min: o, max: i, avg: s, current: c, count: t.length };
732
+ }
733
+ const Je = Ne(
734
+ ({
735
+ series: t,
736
+ maxPoints: o = 100,
737
+ slidingWindow: i = !0,
738
+ refreshRate: s = 16,
739
+ dataSource: c,
740
+ width: v = 600,
741
+ height: p = 400,
742
+ title: I,
743
+ showLegend: T = !0,
744
+ showGrid: w = !0,
745
+ yAxisLabel: f,
746
+ xAxisLabel: N,
747
+ stacked: z,
748
+ zoomable: C,
749
+ crosshair: k,
750
+ annotations: l = [],
751
+ legendInteractive: d,
752
+ onDataPointClick: u,
753
+ exportable: S,
754
+ showControls: g = !0,
755
+ showStatus: x = !0,
756
+ initialPaused: y = !1,
757
+ onDataReceived: b,
758
+ onDataDropped: h,
759
+ timeFormat: D = "HH:mm:ss",
760
+ showStats: a,
761
+ thresholds: _ = [],
762
+ className: A,
763
+ style: O
764
+ }, U) => {
765
+ const [V, j] = oe(() => {
766
+ const L = /* @__PURE__ */ new Map();
767
+ for (const Z of t)
768
+ L.set(Z.name, Z.initialData?.slice() ?? []);
769
+ return L;
770
+ }), [G, Q] = oe([]), [q, J] = oe(y), [n, X] = oe(!1), H = be([]), W = be(Date.now()), m = be(null), F = ae(() => {
771
+ const L = H.current;
772
+ L.length !== 0 && (H.current = [], j((Z) => {
773
+ const ne = new Map(Z);
774
+ for (const ue of L) {
775
+ const _e = ne.get(ue.series);
776
+ if (!_e)
777
+ continue;
778
+ const ge = [..._e, ue.value];
779
+ if (i && ge.length > o) {
780
+ const ye = ge.length - o;
781
+ h?.(ye, ue.series), ge.splice(0, ye);
782
+ }
783
+ ne.set(ue.series, ge);
784
+ }
785
+ return ne;
786
+ }), L.length > 0 && Q((Z) => {
787
+ const ne = [...Z];
788
+ for (const ue of L) {
789
+ const _e = ue.category ?? qe(ue.timestamp, D);
790
+ ne.push(_e);
791
+ }
792
+ return i && ne.length > o && ne.splice(0, ne.length - o), ne;
793
+ }));
794
+ }, [i, o, D, h]), Y = ae(() => {
795
+ const L = Date.now();
796
+ L - W.current >= s && (F(), W.current = L), m.current = requestAnimationFrame(Y);
797
+ }, [s, F]);
798
+ Ce(() => (q || (m.current = requestAnimationFrame(Y)), () => {
799
+ m.current !== null && (cancelAnimationFrame(m.current), m.current = null);
800
+ }), [q, Y]);
801
+ const ee = ae(
802
+ (L) => {
803
+ if (q)
804
+ return;
805
+ const Z = "points" in L ? L.points : [L];
806
+ for (const ne of Z)
807
+ V.has(ne.series) && (H.current.push(ne), b?.(ne));
808
+ },
809
+ [q, V, b]
810
+ );
811
+ Ce(() => {
812
+ if (!c)
813
+ return;
814
+ const L = c.subscribe(ee);
815
+ let Z;
816
+ return c.onStatusChange ? Z = c.onStatusChange(X) : X(!0), c.fetchHistory && c.fetchHistory(o).then((ne) => {
817
+ for (const ue of ne)
818
+ H.current.push(ue);
819
+ F();
820
+ }), () => {
821
+ L(), Z?.();
822
+ };
823
+ }, [c, ee, o, F]);
824
+ const P = pe(() => t.map((L) => ({
825
+ name: L.name,
826
+ color: L.color,
827
+ type: L.type,
828
+ data: V.get(L.name) ?? []
829
+ })), [t, V]), te = pe(() => {
830
+ const L = [...l];
831
+ for (const Z of _)
832
+ L.push({
833
+ type: "line",
834
+ value: Z.value,
835
+ color: Z.color,
836
+ label: Z.label,
837
+ dash: Z.style === "dashed" ? "5,5" : Z.style === "dotted" ? "2,2" : void 0
838
+ });
839
+ return L;
840
+ }, [l, _]);
841
+ Ae(
842
+ U,
843
+ () => ({
844
+ pause() {
845
+ J(!0);
846
+ },
847
+ resume() {
848
+ J(!1);
849
+ },
850
+ isPaused() {
851
+ return q;
852
+ },
853
+ clear() {
854
+ j((L) => {
855
+ const Z = new Map(L);
856
+ for (const ne of Z.keys())
857
+ Z.set(ne, []);
858
+ return Z;
859
+ }), Q([]), H.current = [];
860
+ },
861
+ addPoint(L) {
862
+ ee(L);
863
+ },
864
+ addPoints(L) {
865
+ ee({ points: L });
866
+ },
867
+ getData(L) {
868
+ return V.get(L) ?? [];
869
+ },
870
+ getCategories() {
871
+ return G;
872
+ },
873
+ exportData() {
874
+ return { series: P, categories: G };
875
+ },
876
+ getStats(L) {
877
+ const Z = V.get(L);
878
+ return Z ? We(Z) : null;
879
+ }
880
+ }),
881
+ [q, V, G, P, ee]
882
+ );
883
+ const fe = pe(() => {
884
+ if (!a)
885
+ return null;
886
+ const L = {};
887
+ for (const [Z, ne] of V)
888
+ L[Z] = We(ne);
889
+ return L;
890
+ }, [a, V]);
891
+ return /* @__PURE__ */ $("div", { className: A, style: { position: "relative", ...O }, children: [
892
+ x && /* @__PURE__ */ $(
893
+ "div",
894
+ {
895
+ style: {
896
+ position: "absolute",
897
+ top: 8,
898
+ right: 8,
899
+ display: "flex",
900
+ alignItems: "center",
901
+ gap: 4,
902
+ fontSize: 12,
903
+ color: n ? "var(--color-success, #22c55e)" : "var(--color-error, #ef4444)",
904
+ zIndex: 10
905
+ },
906
+ children: [
907
+ /* @__PURE__ */ e(
908
+ "span",
909
+ {
910
+ style: {
911
+ width: 8,
912
+ height: 8,
913
+ borderRadius: "50%",
914
+ backgroundColor: n ? "var(--color-success, #22c55e)" : "var(--color-error, #ef4444)"
915
+ }
916
+ }
917
+ ),
918
+ n ? "Live" : "Disconnected"
919
+ ]
920
+ }
921
+ ),
922
+ g && /* @__PURE__ */ e(
923
+ "div",
924
+ {
925
+ style: {
926
+ position: "absolute",
927
+ top: 8,
928
+ left: 8,
929
+ display: "flex",
930
+ gap: 4,
931
+ zIndex: 10
932
+ },
933
+ children: /* @__PURE__ */ e(
934
+ "button",
935
+ {
936
+ onClick: () => J((L) => !L),
937
+ style: {
938
+ padding: "4px 8px",
939
+ fontSize: 12,
940
+ border: "1px solid var(--border-color, #ddd)",
941
+ borderRadius: 4,
942
+ background: q ? "var(--warning-bg, #fef3c7)" : "var(--bg-primary, #fff)",
943
+ cursor: "pointer"
944
+ },
945
+ title: q ? "Resume" : "Pause",
946
+ children: q ? "▶" : "⏸"
947
+ }
948
+ )
949
+ }
950
+ ),
951
+ a && fe && /* @__PURE__ */ e(
952
+ "div",
953
+ {
954
+ style: {
955
+ position: "absolute",
956
+ bottom: 50,
957
+ right: 8,
958
+ background: "var(--nice-overlay-light-90, rgba(255, 255, 255, 0.9))",
959
+ border: "1px solid var(--border-color, #ddd)",
960
+ borderRadius: 4,
961
+ padding: 8,
962
+ fontSize: 11,
963
+ zIndex: 10
964
+ },
965
+ children: Object.entries(fe).map(
966
+ ([L, Z]) => Z ? /* @__PURE__ */ $("div", { style: { marginBottom: 4 }, children: [
967
+ /* @__PURE__ */ e("strong", { children: L }),
968
+ /* @__PURE__ */ $("div", { children: [
969
+ "Min: ",
970
+ Z.min.toFixed(2),
971
+ " | Max: ",
972
+ Z.max.toFixed(2)
973
+ ] }),
974
+ /* @__PURE__ */ $("div", { children: [
975
+ "Avg: ",
976
+ Z.avg.toFixed(2),
977
+ " | Now: ",
978
+ Z.current.toFixed(2)
979
+ ] })
980
+ ] }, L) : null
981
+ )
982
+ }
983
+ ),
984
+ /* @__PURE__ */ e(
985
+ Re,
986
+ {
987
+ series: P,
988
+ categories: G,
989
+ width: v,
990
+ height: p,
991
+ title: I,
992
+ showLegend: T,
993
+ showGrid: w,
994
+ yAxisLabel: f,
995
+ xAxisLabel: N,
996
+ stacked: z,
997
+ zoomable: C,
998
+ crosshair: k,
999
+ annotations: te,
1000
+ legendInteractive: d,
1001
+ onDataPointClick: u,
1002
+ exportable: S
1003
+ }
1004
+ )
1005
+ ] });
1006
+ }
1007
+ );
1008
+ Je.displayName = "NiceLiveChart";
1009
+ function ft(t) {
1010
+ const {
1011
+ hubConnection: o,
1012
+ eventName: i = "DataPoint",
1013
+ subscribeMethod: s = "SubscribeToMetrics",
1014
+ historyMethod: c = "GetMetricHistory",
1015
+ metricName: v
1016
+ } = t;
1017
+ return {
1018
+ subscribe(p) {
1019
+ const I = (T) => {
1020
+ p(T);
1021
+ };
1022
+ return o.on(i, I), o.state === "Connected" && o.invoke(s, v).catch(() => {
1023
+ }), () => {
1024
+ o.off(i, I);
1025
+ };
1026
+ },
1027
+ async fetchHistory(p) {
1028
+ try {
1029
+ return await o.invoke(c, v, p);
1030
+ } catch {
1031
+ return [];
1032
+ }
1033
+ },
1034
+ onStatusChange(p) {
1035
+ const I = () => p(o.state === "Connected");
1036
+ return o.onclose(() => p(!1)), o.onreconnected(() => p(!0)), I(), () => {
1037
+ };
1038
+ }
1039
+ };
1040
+ }
1041
+ function gt(t) {
1042
+ const {
1043
+ url: o,
1044
+ autoReconnect: i = !0,
1045
+ reconnectDelay: s = 3e3,
1046
+ parseMessage: c = (f) => JSON.parse(f)
1047
+ } = t;
1048
+ let v = null, p = null, I = null, T = null;
1049
+ const w = () => {
1050
+ v = new WebSocket(o), v.onopen = () => {
1051
+ p?.(!0);
1052
+ }, v.onclose = () => {
1053
+ p?.(!1), i && (T = setTimeout(w, s));
1054
+ }, v.onerror = () => {
1055
+ v?.close();
1056
+ }, v.onmessage = (f) => {
1057
+ try {
1058
+ const N = c(f.data);
1059
+ N && I && I(N);
1060
+ } catch {
1061
+ }
1062
+ };
1063
+ };
1064
+ return {
1065
+ subscribe(f) {
1066
+ return I = f, w(), () => {
1067
+ I = null, T && clearTimeout(T), v?.close(), v = null;
1068
+ };
1069
+ },
1070
+ onStatusChange(f) {
1071
+ return p = f, () => {
1072
+ p = null;
1073
+ };
1074
+ }
1075
+ };
1076
+ }
1077
+ function xt(t) {
1078
+ const { seriesNames: o, interval: i = 1e3, generateValue: s = () => Math.random() * 100 } = t;
1079
+ let c = null, v = 0;
1080
+ return {
1081
+ subscribe(p) {
1082
+ return c = setInterval(() => {
1083
+ for (const I of o)
1084
+ p({
1085
+ series: I,
1086
+ value: s(I, v),
1087
+ timestamp: Date.now()
1088
+ });
1089
+ v++;
1090
+ }, i), () => {
1091
+ c && clearInterval(c);
1092
+ };
1093
+ },
1094
+ onStatusChange(p) {
1095
+ return p(!0), () => {
1096
+ };
1097
+ }
1098
+ };
1099
+ }
1100
+ const ve = ["#3b82f6", "#ef4444", "#22c55e", "#f59e0b", "#8b5cf6", "#ec4899", "#06b6d4", "#84cc16"], yt = ({
1101
+ data: t,
1102
+ width: o = 400,
1103
+ height: i = 400,
1104
+ innerRadius: s = 0,
1105
+ title: c,
1106
+ showLegend: v = !0,
1107
+ showLabels: p = !0,
1108
+ className: I,
1109
+ style: T
1110
+ }) => {
1111
+ const w = o / 2, f = (i - (v ? 30 : 0)) / 2 + (c ? 10 : 0), N = Math.min(w, f) - 40, z = t.reduce((l, d) => l + d.value, 0);
1112
+ let C = -Math.PI / 2;
1113
+ const k = t.map((l, d) => {
1114
+ const u = l.value / (z || 1) * Math.PI * 2, S = C;
1115
+ C += u;
1116
+ const g = C, x = (S + g) / 2, y = w + N * Math.cos(S), b = f + N * Math.sin(S), h = w + N * Math.cos(g), D = f + N * Math.sin(g), a = u > Math.PI ? 1 : 0, _ = l.color || ve[d % ve.length];
1117
+ let A;
1118
+ if (s > 0) {
1119
+ const j = w + s * Math.cos(S), G = f + s * Math.sin(S), Q = w + s * Math.cos(g), q = f + s * Math.sin(g);
1120
+ A = `M${y},${b} A${N},${N} 0 ${a},1 ${h},${D} L${Q},${q} A${s},${s} 0 ${a},0 ${j},${G} Z`;
1121
+ } else
1122
+ A = `M${w},${f} L${y},${b} A${N},${N} 0 ${a},1 ${h},${D} Z`;
1123
+ const O = w + N * 0.7 * Math.cos(x), U = f + N * 0.7 * Math.sin(x), V = z > 0 ? Math.round(l.value / z * 100) : 0;
1124
+ return { ...l, path: A, labelX: O, labelY: U, pct: V, color: _ };
1125
+ });
1126
+ return /* @__PURE__ */ e("div", { className: `nice-piechart ${I || ""}`, style: T, children: /* @__PURE__ */ $(
1127
+ "svg",
1128
+ {
1129
+ viewBox: `0 0 ${o} ${i}`,
1130
+ preserveAspectRatio: "xMidYMid meet",
1131
+ width: "100%",
1132
+ height: "100%",
1133
+ style: { display: "block", maxWidth: "100%", maxHeight: "100%" },
1134
+ className: "nice-piechart__svg",
1135
+ children: [
1136
+ c && /* @__PURE__ */ e("text", { x: w, y: 20, textAnchor: "middle", className: "nice-chart__title", children: c }),
1137
+ k.map((l, d) => /* @__PURE__ */ $("g", { children: [
1138
+ /* @__PURE__ */ e("path", { d: l.path, fill: l.color, stroke: "var(--bg-primary, #fff)", strokeWidth: 2, children: /* @__PURE__ */ e("title", { children: `${l.label}: ${l.value} (${l.pct}%)` }) }),
1139
+ p && l.pct >= 5 && /* @__PURE__ */ $(
1140
+ "text",
1141
+ {
1142
+ x: l.labelX,
1143
+ y: l.labelY,
1144
+ textAnchor: "middle",
1145
+ dominantBaseline: "middle",
1146
+ className: "nice-piechart__label",
1147
+ children: [
1148
+ l.pct,
1149
+ "%"
1150
+ ]
1151
+ }
1152
+ )
1153
+ ] }, d)),
1154
+ v && /* @__PURE__ */ e("g", { transform: `translate(10, ${i - 25})`, children: t.map((l, d) => /* @__PURE__ */ $("g", { transform: `translate(${d * 100}, 0)`, children: [
1155
+ /* @__PURE__ */ e("rect", { width: 10, height: 10, rx: 2, fill: l.color || ve[d % ve.length] }),
1156
+ /* @__PURE__ */ e("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: l.label })
1157
+ ] }, d)) })
1158
+ ]
1159
+ }
1160
+ ) });
1161
+ }, vt = ({
1162
+ series: t,
1163
+ categories: o,
1164
+ width: i = 400,
1165
+ height: s = 400,
1166
+ maxValue: c,
1167
+ title: v,
1168
+ showLegend: p = !0,
1169
+ className: I,
1170
+ style: T
1171
+ }) => {
1172
+ const w = i / 2, f = (s - (p ? 30 : 0)) / 2 + (v ? 10 : 0), N = Math.min(w, f) - 60, z = o.length, C = c ?? Math.max(...t.flatMap((u) => u.data), 1), k = Math.PI * 2 / z, l = 5, d = (u, S) => {
1173
+ const g = u * k - Math.PI / 2, x = S / C * N;
1174
+ return { x: w + x * Math.cos(g), y: f + x * Math.sin(g) };
1175
+ };
1176
+ return /* @__PURE__ */ e("div", { className: `nice-polarchart ${I || ""}`, style: T, children: /* @__PURE__ */ $("svg", { width: i, height: s, className: "nice-polarchart__svg", children: [
1177
+ v && /* @__PURE__ */ e("text", { x: w, y: 20, textAnchor: "middle", className: "nice-chart__title", children: v }),
1178
+ Array.from({ length: l }, (u, S) => {
1179
+ const g = N * ((S + 1) / l);
1180
+ return /* @__PURE__ */ e(
1181
+ "circle",
1182
+ {
1183
+ cx: w,
1184
+ cy: f,
1185
+ r: g,
1186
+ fill: "none",
1187
+ stroke: "var(--border-color, #ddd)",
1188
+ strokeWidth: 0.5
1189
+ },
1190
+ S
1191
+ );
1192
+ }),
1193
+ o.map((u, S) => {
1194
+ const g = d(S, C), x = d(S, C * 1.22), y = S * k - Math.PI / 2, b = Math.cos(y), h = Math.sin(y), D = b > 0.2 ? "start" : b < -0.2 ? "end" : "middle", a = h > 0.2 ? "hanging" : h < -0.2 ? "auto" : "middle";
1195
+ return /* @__PURE__ */ $("g", { children: [
1196
+ /* @__PURE__ */ e(
1197
+ "line",
1198
+ {
1199
+ x1: w,
1200
+ y1: f,
1201
+ x2: g.x,
1202
+ y2: g.y,
1203
+ stroke: "var(--border-color, #ddd)",
1204
+ strokeWidth: 0.5
1205
+ }
1206
+ ),
1207
+ /* @__PURE__ */ e(
1208
+ "text",
1209
+ {
1210
+ x: x.x,
1211
+ y: x.y,
1212
+ textAnchor: D,
1213
+ dominantBaseline: a,
1214
+ className: "nice-chart__axis-label nice-chart__axis-label--polar",
1215
+ children: u
1216
+ }
1217
+ )
1218
+ ] }, S);
1219
+ }),
1220
+ t.map((u, S) => {
1221
+ const g = u.color || ve[S % ve.length], x = u.data.map((y, b) => {
1222
+ const h = d(b, y);
1223
+ return `${h.x},${h.y}`;
1224
+ }).join(" ");
1225
+ return /* @__PURE__ */ $("g", { children: [
1226
+ /* @__PURE__ */ e(
1227
+ "polygon",
1228
+ {
1229
+ points: x,
1230
+ fill: u.fill !== !1 ? g : "none",
1231
+ fillOpacity: 0.15,
1232
+ stroke: g,
1233
+ strokeWidth: 2
1234
+ }
1235
+ ),
1236
+ u.data.map((y, b) => {
1237
+ const h = d(b, y);
1238
+ return /* @__PURE__ */ e("circle", { cx: h.x, cy: h.y, r: 3, fill: g, children: /* @__PURE__ */ e("title", { children: `${u.name} - ${o[b]}: ${y}` }) }, b);
1239
+ })
1240
+ ] }, u.name);
1241
+ }),
1242
+ p && /* @__PURE__ */ e("g", { transform: `translate(10, ${s - 25})`, children: t.map((u, S) => /* @__PURE__ */ $("g", { transform: `translate(${S * 100}, 0)`, children: [
1243
+ /* @__PURE__ */ e("rect", { width: 10, height: 10, rx: 2, fill: u.color || ve[S % ve.length] }),
1244
+ /* @__PURE__ */ e("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: u.name })
1245
+ ] }, S)) })
1246
+ ] }) });
1247
+ }, bt = ({
1248
+ value: t,
1249
+ min: o = 0,
1250
+ max: i = 100,
1251
+ width: s = 200,
1252
+ height: c = 200,
1253
+ startAngle: v = 225,
1254
+ endAngle: p = -45,
1255
+ color: I = "var(--color-primary, #3b82f6)",
1256
+ trackColor: T,
1257
+ label: w,
1258
+ formatValue: f,
1259
+ ranges: N,
1260
+ className: z,
1261
+ style: C
1262
+ }) => {
1263
+ const k = s / 2, l = c / 2, d = Math.min(k, l) - 20, u = Math.max(0, Math.min(1, (t - o) / (i - o || 1))), S = (a) => a * Math.PI / 180, g = (v - p + 360) % 360 || 360, x = (a) => ({
1264
+ x: k + d * Math.cos(S(a)),
1265
+ y: l - d * Math.sin(S(a))
1266
+ }), y = (a, _) => {
1267
+ const A = x(a), O = x(_), V = (a - _ + 360) % 360 > 180 ? 1 : 0;
1268
+ return `M${A.x},${A.y} A${d},${d} 0 ${V},1 ${O.x},${O.y}`;
1269
+ }, b = v - u * g, h = x(b);
1270
+ let D = I;
1271
+ if (N) {
1272
+ for (const a of N)
1273
+ if (t >= a.start && t <= a.end) {
1274
+ D = a.color;
1275
+ break;
1276
+ }
1277
+ }
1278
+ return /* @__PURE__ */ e("div", { className: `nice-gauge nice-gauge--circular ${z || ""}`, style: C, children: /* @__PURE__ */ $("svg", { width: s, height: c, children: [
1279
+ /* @__PURE__ */ e(
1280
+ "path",
1281
+ {
1282
+ d: y(v, p),
1283
+ fill: "none",
1284
+ stroke: T || "var(--border-color, #e2e8f0)",
1285
+ strokeWidth: 12,
1286
+ strokeLinecap: "round"
1287
+ }
1288
+ ),
1289
+ u > 0 && /* @__PURE__ */ e(
1290
+ "path",
1291
+ {
1292
+ d: y(v, b),
1293
+ fill: "none",
1294
+ stroke: D,
1295
+ strokeWidth: 12,
1296
+ strokeLinecap: "round"
1297
+ }
1298
+ ),
1299
+ /* @__PURE__ */ e(
1300
+ "line",
1301
+ {
1302
+ x1: k,
1303
+ y1: l,
1304
+ x2: h.x,
1305
+ y2: h.y,
1306
+ stroke: "var(--text-primary, #333)",
1307
+ strokeWidth: 2,
1308
+ strokeLinecap: "round"
1309
+ }
1310
+ ),
1311
+ /* @__PURE__ */ e("circle", { cx: k, cy: l, r: 4, fill: "var(--text-primary, #333)" }),
1312
+ /* @__PURE__ */ e("text", { x: k, y: l + d * 0.6, textAnchor: "middle", className: "nice-gauge__value", children: f ? f(t) : t }),
1313
+ w && /* @__PURE__ */ e("text", { x: k, y: l + d * 0.95, textAnchor: "middle", className: "nice-gauge__label", children: w })
1314
+ ] }) });
1315
+ }, _t = ({
1316
+ value: t,
1317
+ min: o = 0,
1318
+ max: i = 100,
1319
+ width: s = 300,
1320
+ height: c = 60,
1321
+ orientation: v = "horizontal",
1322
+ color: p = "var(--color-primary, #3b82f6)",
1323
+ label: I,
1324
+ formatValue: T,
1325
+ ranges: w,
1326
+ showTicks: f = !0,
1327
+ tickCount: N = 5,
1328
+ className: z,
1329
+ style: C
1330
+ }) => {
1331
+ const k = v === "horizontal", l = k ? s - 40 : c - 40, d = Math.max(0, Math.min(1, (t - o) / (i - o || 1))), u = 10;
1332
+ let S = p;
1333
+ if (w) {
1334
+ for (const x of w)
1335
+ if (t >= x.start && t <= x.end) {
1336
+ S = x.color;
1337
+ break;
1338
+ }
1339
+ }
1340
+ const g = Array.from(
1341
+ { length: N },
1342
+ (x, y) => o + (i - o) * (y / (N - 1))
1343
+ );
1344
+ return k ? /* @__PURE__ */ e("div", { className: `nice-gauge nice-gauge--linear ${z || ""}`, style: C, children: /* @__PURE__ */ $("svg", { width: s, height: c, children: [
1345
+ /* @__PURE__ */ e(
1346
+ "text",
1347
+ {
1348
+ x: 20 + l * d,
1349
+ y: 14,
1350
+ textAnchor: "middle",
1351
+ className: "nice-gauge__value",
1352
+ style: { fontSize: 12 },
1353
+ children: T ? T(t) : t
1354
+ }
1355
+ ),
1356
+ /* @__PURE__ */ e(
1357
+ "rect",
1358
+ {
1359
+ x: 20,
1360
+ y: c / 2 - u / 2,
1361
+ width: l,
1362
+ height: u,
1363
+ rx: 5,
1364
+ fill: "var(--border-color, #e2e8f0)"
1365
+ }
1366
+ ),
1367
+ /* @__PURE__ */ e(
1368
+ "rect",
1369
+ {
1370
+ x: 20,
1371
+ y: c / 2 - u / 2,
1372
+ width: l * d,
1373
+ height: u,
1374
+ rx: 5,
1375
+ fill: S
1376
+ }
1377
+ ),
1378
+ /* @__PURE__ */ e(
1379
+ "polygon",
1380
+ {
1381
+ points: `${20 + l * d},${c / 2 - u / 2 - 2} ${20 + l * d - 5},${c / 2 - u / 2 - 8} ${20 + l * d + 5},${c / 2 - u / 2 - 8}`,
1382
+ fill: "var(--text-primary, #333)"
1383
+ }
1384
+ ),
1385
+ f && g.map((x, y) => {
1386
+ const b = 20 + (x - o) / (i - o) * l;
1387
+ return /* @__PURE__ */ e(
1388
+ "text",
1389
+ {
1390
+ x: b,
1391
+ y: c / 2 + u / 2 + 12,
1392
+ textAnchor: "middle",
1393
+ className: "nice-gauge__tick",
1394
+ children: x
1395
+ },
1396
+ y
1397
+ );
1398
+ }),
1399
+ I && /* @__PURE__ */ e("text", { x: s / 2, y: c - 2, textAnchor: "middle", className: "nice-gauge__label", children: I })
1400
+ ] }) }) : /* @__PURE__ */ e(
1401
+ "div",
1402
+ {
1403
+ className: `nice-gauge nice-gauge--linear nice-gauge--vertical ${z || ""}`,
1404
+ style: C,
1405
+ children: /* @__PURE__ */ $("svg", { width: s, height: c, children: [
1406
+ /* @__PURE__ */ e(
1407
+ "rect",
1408
+ {
1409
+ x: s / 2 - u / 2,
1410
+ y: 20,
1411
+ width: u,
1412
+ height: l,
1413
+ rx: 5,
1414
+ fill: "var(--border-color, #e2e8f0)"
1415
+ }
1416
+ ),
1417
+ /* @__PURE__ */ e(
1418
+ "rect",
1419
+ {
1420
+ x: s / 2 - u / 2,
1421
+ y: 20 + l * (1 - d),
1422
+ width: u,
1423
+ height: l * d,
1424
+ rx: 5,
1425
+ fill: S
1426
+ }
1427
+ ),
1428
+ /* @__PURE__ */ e("text", { x: s / 2, y: 14, textAnchor: "middle", className: "nice-gauge__value", children: T ? T(t) : t }),
1429
+ I && /* @__PURE__ */ e("text", { x: s / 2, y: c - 4, textAnchor: "middle", className: "nice-gauge__label", children: I })
1430
+ ] })
1431
+ }
1432
+ );
1433
+ }, wt = ({
1434
+ items: t,
1435
+ min: o = 0,
1436
+ max: i = 100,
1437
+ width: s = 300,
1438
+ height: c = 300,
1439
+ startAngle: v = 225,
1440
+ endAngle: p = -45,
1441
+ formatValue: I,
1442
+ title: T,
1443
+ className: w,
1444
+ style: f
1445
+ }) => {
1446
+ const N = s / 2, z = c / 2, C = Math.min(N, z) - 30, k = Math.min(20, C / (t.length + 1)), l = 4, d = (g) => g * Math.PI / 180, u = (v - p + 360) % 360 || 360, S = (g, x, y) => {
1447
+ const b = N + g * Math.cos(d(x)), h = z - g * Math.sin(d(x)), D = N + g * Math.cos(d(y)), a = z - g * Math.sin(d(y)), _ = (x - y + 360) % 360;
1448
+ return `M${b},${h} A${g},${g} 0 ${_ > 180 ? 1 : 0},1 ${D},${a}`;
1449
+ };
1450
+ return /* @__PURE__ */ e("div", { className: `nice-bargauge ${w || ""}`, style: f, children: /* @__PURE__ */ $("svg", { width: s, height: c, children: [
1451
+ T && /* @__PURE__ */ e("text", { x: N, y: 20, textAnchor: "middle", className: "nice-chart__title", children: T }),
1452
+ t.map((g, x) => {
1453
+ const y = C - x * (k + l), b = Math.max(0, Math.min(1, (g.value - o) / (i - o || 1))), h = v - b * u, D = g.color || ve[x % ve.length];
1454
+ return /* @__PURE__ */ $("g", { children: [
1455
+ /* @__PURE__ */ e(
1456
+ "path",
1457
+ {
1458
+ d: S(y, v, p),
1459
+ fill: "none",
1460
+ stroke: "var(--border-color, #e2e8f0)",
1461
+ strokeWidth: k,
1462
+ strokeLinecap: "round"
1463
+ }
1464
+ ),
1465
+ b > 0 && /* @__PURE__ */ e(
1466
+ "path",
1467
+ {
1468
+ d: S(y, v, h),
1469
+ fill: "none",
1470
+ stroke: D,
1471
+ strokeWidth: k,
1472
+ strokeLinecap: "round"
1473
+ }
1474
+ )
1475
+ ] }, x);
1476
+ }),
1477
+ /* @__PURE__ */ e("g", { children: t.map((g, x) => /* @__PURE__ */ $(
1478
+ "text",
1479
+ {
1480
+ x: N,
1481
+ y: z - ((t.length - 1) / 2 - x) * 16,
1482
+ textAnchor: "middle",
1483
+ dominantBaseline: "middle",
1484
+ className: "nice-gauge__value",
1485
+ style: { fontSize: 12 },
1486
+ children: [
1487
+ g.label ? `${g.label}: ` : "",
1488
+ I ? I(g.value) : g.value
1489
+ ]
1490
+ },
1491
+ x
1492
+ )) })
1493
+ ] }) });
1494
+ }, $t = ({
1495
+ data: t,
1496
+ width: o = 120,
1497
+ height: i = 30,
1498
+ type: s = "line",
1499
+ color: c = "var(--color-primary, #3b82f6)",
1500
+ showMinMax: v,
1501
+ showLastPoint: p = !0,
1502
+ className: I,
1503
+ style: T
1504
+ }) => {
1505
+ if (t.length === 0)
1506
+ return null;
1507
+ const w = 2, f = Math.min(...t), N = Math.max(...t), z = N - f || 1, C = o - w * 2, k = i - w * 2, l = (y) => w + y / (t.length - 1 || 1) * C, d = (y) => w + k - (y - f) / z * k;
1508
+ if (s === "bar") {
1509
+ const y = Math.max(1, C / t.length - 1);
1510
+ return /* @__PURE__ */ e(
1511
+ "svg",
1512
+ {
1513
+ width: o,
1514
+ height: i,
1515
+ className: `nice-sparkline ${I || ""}`,
1516
+ style: T,
1517
+ children: t.map((b, h) => /* @__PURE__ */ e(
1518
+ "rect",
1519
+ {
1520
+ x: w + h / t.length * C,
1521
+ y: d(b),
1522
+ width: y,
1523
+ height: k - (d(b) - w),
1524
+ fill: c,
1525
+ rx: 1
1526
+ },
1527
+ h
1528
+ ))
1529
+ }
1530
+ );
1531
+ }
1532
+ const u = t.map((y, b) => `${l(b)},${d(y)}`).join(" "), S = t.indexOf(f), g = t.indexOf(N), x = t.length - 1;
1533
+ return /* @__PURE__ */ $(
1534
+ "svg",
1535
+ {
1536
+ width: o,
1537
+ height: i,
1538
+ className: `nice-sparkline ${I || ""}`,
1539
+ style: T,
1540
+ children: [
1541
+ s === "area" && /* @__PURE__ */ e(
1542
+ "polygon",
1543
+ {
1544
+ points: `${l(0)},${w + k} ${u} ${l(x)},${w + k}`,
1545
+ fill: c,
1546
+ opacity: 0.15
1547
+ }
1548
+ ),
1549
+ /* @__PURE__ */ e("polyline", { points: u, fill: "none", stroke: c, strokeWidth: 1.5 }),
1550
+ v && /* @__PURE__ */ e("circle", { cx: l(S), cy: d(f), r: 2, fill: "var(--nice-danger, #ef4444)" }),
1551
+ v && /* @__PURE__ */ e("circle", { cx: l(g), cy: d(N), r: 2, fill: "var(--nice-success, #22c55e)" }),
1552
+ p && /* @__PURE__ */ e("circle", { cx: l(x), cy: d(t[x]), r: 2, fill: c })
1553
+ ]
1554
+ }
1555
+ );
1556
+ }, Ke = {
1557
+ sm: { width: 160, height: 22, fontSize: 11 },
1558
+ md: { width: 220, height: 32, fontSize: 12 },
1559
+ lg: { width: 320, height: 44, fontSize: 14 }
1560
+ }, Mt = ({
1561
+ value: t,
1562
+ target: o,
1563
+ min: i = 0,
1564
+ max: s = 100,
1565
+ width: c,
1566
+ height: v,
1567
+ color: p = "var(--color-primary, #3b82f6)",
1568
+ targetColor: I = "var(--color-error, #ef4444)",
1569
+ size: T = "md",
1570
+ label: w,
1571
+ labelPlacement: f = "top",
1572
+ showValue: N = !1,
1573
+ showTarget: z = !1,
1574
+ formatValue: C = (S) => String(S),
1575
+ state: k = "normal",
1576
+ errorMessage: l,
1577
+ className: d,
1578
+ style: u
1579
+ }) => {
1580
+ const S = Ke[T], g = c ?? S.width, x = v ?? S.height, y = S.fontSize, b = 4, h = g - b * 2, D = z && o != null ? y + 4 : b, a = z && o != null ? x + (D - b) : x, _ = a - D - b, A = Math.max(0, Math.min(1, (t - i) / (s - i || 1))), O = o != null ? Math.max(0, Math.min(1, (o - i) / (s - i || 1))) : null, U = () => k === "error" ? /* @__PURE__ */ e(
1581
+ "div",
1582
+ {
1583
+ role: "alert",
1584
+ style: {
1585
+ width: g,
1586
+ height: a,
1587
+ display: "flex",
1588
+ alignItems: "center",
1589
+ justifyContent: "center",
1590
+ border: "1px dashed var(--color-error, #ef4444)",
1591
+ borderRadius: 4,
1592
+ color: "var(--color-error, #ef4444)",
1593
+ fontSize: y,
1594
+ padding: "0 8px",
1595
+ boxSizing: "border-box"
1596
+ },
1597
+ children: l ?? "Error"
1598
+ }
1599
+ ) : k === "loading" ? /* @__PURE__ */ e(
1600
+ "div",
1601
+ {
1602
+ role: "status",
1603
+ "aria-label": "Loading",
1604
+ className: "nice-bullet__skeleton",
1605
+ style: {
1606
+ width: g,
1607
+ height: a,
1608
+ borderRadius: 4,
1609
+ background: "linear-gradient(90deg, var(--bg-tertiary, #e5e7eb) 25%, var(--bg-secondary, #f3f4f6) 50%, var(--bg-tertiary, #e5e7eb) 75%)",
1610
+ backgroundSize: "200% 100%",
1611
+ animation: "nice-bullet-shimmer 1.4s linear infinite"
1612
+ }
1613
+ }
1614
+ ) : /* @__PURE__ */ $(
1615
+ "svg",
1616
+ {
1617
+ width: g,
1618
+ height: a,
1619
+ role: "img",
1620
+ "aria-label": typeof w == "string" ? w : void 0,
1621
+ children: [
1622
+ /* @__PURE__ */ e(
1623
+ "rect",
1624
+ {
1625
+ x: b,
1626
+ y: D,
1627
+ width: h,
1628
+ height: _,
1629
+ rx: 3,
1630
+ fill: "var(--border-color, #e2e8f0)"
1631
+ }
1632
+ ),
1633
+ /* @__PURE__ */ e(
1634
+ "rect",
1635
+ {
1636
+ x: b,
1637
+ y: D + _ * 0.2,
1638
+ width: h * A,
1639
+ height: _ * 0.6,
1640
+ rx: 2,
1641
+ fill: p
1642
+ }
1643
+ ),
1644
+ O != null && /* @__PURE__ */ e(
1645
+ "line",
1646
+ {
1647
+ x1: b + h * O,
1648
+ y1: D + 2,
1649
+ x2: b + h * O,
1650
+ y2: D + _ - 2,
1651
+ stroke: I,
1652
+ strokeWidth: 2
1653
+ }
1654
+ ),
1655
+ N && /* @__PURE__ */ e(
1656
+ "text",
1657
+ {
1658
+ x: b + Math.max(h * A, 4),
1659
+ y: D + _ / 2,
1660
+ dx: h * A > 24 ? -4 : 4,
1661
+ textAnchor: h * A > 24 ? "end" : "start",
1662
+ dominantBaseline: "middle",
1663
+ fontSize: y,
1664
+ fill: h * A > 24 ? "var(--text-on-primary, #ffffff)" : "var(--text-primary)",
1665
+ fontWeight: 600,
1666
+ children: C(t)
1667
+ }
1668
+ ),
1669
+ z && O != null && /* @__PURE__ */ $(
1670
+ "text",
1671
+ {
1672
+ x: b + h * O,
1673
+ y: D - 2,
1674
+ textAnchor: "middle",
1675
+ fontSize: y - 1,
1676
+ fill: I,
1677
+ fontWeight: 600,
1678
+ children: [
1679
+ "▼",
1680
+ C(o)
1681
+ ]
1682
+ }
1683
+ )
1684
+ ]
1685
+ }
1686
+ );
1687
+ if (f === "none" || !w)
1688
+ return /* @__PURE__ */ $("div", { className: `nice-bullet ${d || ""}`, style: u, children: [
1689
+ U(),
1690
+ /* @__PURE__ */ e("style", { children: Ee })
1691
+ ] });
1692
+ const V = f === "top" || f === "bottom", j = /* @__PURE__ */ e(
1693
+ "span",
1694
+ {
1695
+ className: "nice-bullet__label",
1696
+ style: {
1697
+ fontSize: y,
1698
+ fontWeight: 600,
1699
+ color: "var(--text-primary)",
1700
+ ...V ? {
1701
+ marginBottom: f === "top" ? 4 : 0,
1702
+ marginTop: f === "bottom" ? 4 : 0
1703
+ } : {},
1704
+ ...f === "left" ? { marginRight: 8 } : {},
1705
+ ...f === "right" ? { marginLeft: 8 } : {}
1706
+ },
1707
+ children: w
1708
+ }
1709
+ );
1710
+ return /* @__PURE__ */ $(
1711
+ "div",
1712
+ {
1713
+ className: `nice-bullet nice-bullet--${f} ${d || ""}`,
1714
+ style: {
1715
+ display: "inline-flex",
1716
+ flexDirection: V ? "column" : "row",
1717
+ alignItems: V ? "flex-start" : "center",
1718
+ ...u
1719
+ },
1720
+ children: [
1721
+ (f === "top" || f === "left") && j,
1722
+ U(),
1723
+ (f === "bottom" || f === "right") && j,
1724
+ /* @__PURE__ */ e("style", { children: Ee })
1725
+ ]
1726
+ }
1727
+ );
1728
+ }, Ee = `
1729
+ @keyframes nice-bullet-shimmer {
1730
+ 0% { background-position: 200% 0; }
1731
+ 100% { background-position: -200% 0; }
1732
+ }
1733
+ `, Nt = ({
1734
+ data: t,
1735
+ width: o = 400,
1736
+ height: i = 300,
1737
+ inverted: s,
1738
+ showLabels: c = !0,
1739
+ showValues: v = !0,
1740
+ title: p,
1741
+ className: I,
1742
+ style: T
1743
+ }) => {
1744
+ const w = { top: p ? 30 : 10, bottom: 10, x: 40 }, f = o - w.x * 2, N = i - w.top - w.bottom, z = s ? [...t].reverse() : t, C = Math.max(...z.map((l) => l.value), 1), k = N / z.length;
1745
+ return /* @__PURE__ */ e("div", { className: `nice-funnel ${I || ""}`, style: T, children: /* @__PURE__ */ $("svg", { width: o, height: i, children: [
1746
+ p && /* @__PURE__ */ e("text", { x: o / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: p }),
1747
+ z.map((l, d) => {
1748
+ const u = l.value / C * f, S = d < z.length - 1 ? z[d + 1].value / C * f : u * 0.3, g = w.top + d * k, x = g + k, y = o / 2, b = `${y - u / 2},${g} ${y + u / 2},${g} ${y + S / 2},${x} ${y - S / 2},${x}`, h = l.color || ve[d % ve.length];
1749
+ return /* @__PURE__ */ $("g", { children: [
1750
+ /* @__PURE__ */ e(
1751
+ "polygon",
1752
+ {
1753
+ points: b,
1754
+ fill: h,
1755
+ stroke: "var(--bg-primary, #fff)",
1756
+ strokeWidth: 1,
1757
+ children: /* @__PURE__ */ e("title", { children: `${l.label}: ${l.value}` })
1758
+ }
1759
+ ),
1760
+ c && /* @__PURE__ */ e(
1761
+ "text",
1762
+ {
1763
+ x: y,
1764
+ y: g + k / 2 - (v ? 4 : 0),
1765
+ textAnchor: "middle",
1766
+ dominantBaseline: "middle",
1767
+ className: "nice-funnel__label",
1768
+ children: l.label
1769
+ }
1770
+ ),
1771
+ v && /* @__PURE__ */ e(
1772
+ "text",
1773
+ {
1774
+ x: y,
1775
+ y: g + k / 2 + 10,
1776
+ textAnchor: "middle",
1777
+ dominantBaseline: "middle",
1778
+ className: "nice-funnel__value",
1779
+ children: l.value
1780
+ }
1781
+ )
1782
+ ] }, d);
1783
+ })
1784
+ ] }) });
1785
+ }, Qe = ({
1786
+ nodes: t,
1787
+ links: o,
1788
+ width: i = 600,
1789
+ height: s = 400,
1790
+ nodeWidth: c = 20,
1791
+ nodePadding: v = 10,
1792
+ title: p,
1793
+ className: I,
1794
+ style: T
1795
+ }) => {
1796
+ const w = { top: p ? 40 : 20, bottom: 20, left: 20, right: 20 }, f = i - w.left - w.right, N = s - w.top - w.bottom, z = new Set(o.map((a) => a.source)), C = new Set(o.map((a) => a.target)), k = t.filter((a) => z.has(a.id) && !C.has(a.id)), l = t.filter((a) => C.has(a.id)), d = t.filter((a) => z.has(a.id) && C.has(a.id)), u = [k, ...d.length ? [d] : [], l].filter(
1797
+ (a) => a.length > 0
1798
+ ), S = u.length, g = /* @__PURE__ */ new Map();
1799
+ t.forEach((a) => {
1800
+ const _ = o.filter((O) => O.source === a.id).reduce((O, U) => O + U.value, 0), A = o.filter((O) => O.target === a.id).reduce((O, U) => O + U.value, 0);
1801
+ g.set(a.id, Math.max(_, A));
1802
+ });
1803
+ const x = u.map(
1804
+ (a) => a.reduce((_, A) => _ + (g.get(A.id) || 0), 0) + (a.length - 1) * v
1805
+ ), y = Math.max(...x, 1), b = /* @__PURE__ */ new Map();
1806
+ u.forEach((a, _) => {
1807
+ const A = w.left + _ / (S - 1 || 1) * (f - c);
1808
+ let O = 0;
1809
+ a.forEach((U) => {
1810
+ const V = (g.get(U.id) || 0) / y * N;
1811
+ b.set(U.id, { x: A, y: w.top + O, h: V }), O += V + v;
1812
+ });
1813
+ });
1814
+ const h = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map();
1815
+ return t.forEach((a) => {
1816
+ h.set(a.id, 0), D.set(a.id, 0);
1817
+ }), /* @__PURE__ */ e("div", { className: `nice-sankey ${I || ""}`, style: T, children: /* @__PURE__ */ $("svg", { width: i, height: s, children: [
1818
+ p && /* @__PURE__ */ e("text", { x: i / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: p }),
1819
+ o.map((a, _) => {
1820
+ const A = b.get(a.source), O = b.get(a.target);
1821
+ if (!A || !O)
1822
+ return null;
1823
+ const U = h.get(a.source) || 0, V = D.get(a.target) || 0, j = a.value / y * N;
1824
+ h.set(a.source, U + j), D.set(a.target, V + j);
1825
+ const G = A.x + c, Q = A.y + U, q = O.x, J = O.y + V, n = (G + q) / 2, H = t.find((W) => W.id === a.source)?.color || ve[_ % ve.length];
1826
+ return /* @__PURE__ */ e(
1827
+ "path",
1828
+ {
1829
+ d: `M${G},${Q} C${n},${Q} ${n},${J} ${q},${J} L${q},${J + j} C${n},${J + j} ${n},${Q + j} ${G},${Q + j} Z`,
1830
+ fill: H,
1831
+ fillOpacity: 0.3,
1832
+ stroke: H,
1833
+ strokeOpacity: 0.5,
1834
+ strokeWidth: 0.5,
1835
+ children: /* @__PURE__ */ e("title", { children: `${a.source} → ${a.target}: ${a.value}` })
1836
+ },
1837
+ _
1838
+ );
1839
+ }),
1840
+ t.map((a, _) => {
1841
+ const A = b.get(a.id);
1842
+ if (!A)
1843
+ return null;
1844
+ const O = a.color || ve[_ % ve.length];
1845
+ return /* @__PURE__ */ $("g", { children: [
1846
+ /* @__PURE__ */ e(
1847
+ "rect",
1848
+ {
1849
+ x: A.x,
1850
+ y: A.y,
1851
+ width: c,
1852
+ height: Math.max(A.h, 2),
1853
+ fill: O,
1854
+ rx: 2
1855
+ }
1856
+ ),
1857
+ /* @__PURE__ */ e(
1858
+ "text",
1859
+ {
1860
+ x: A.x < f / 2 ? A.x + c + 4 : A.x - 4,
1861
+ y: A.y + A.h / 2,
1862
+ textAnchor: A.x < f / 2 ? "start" : "end",
1863
+ dominantBaseline: "middle",
1864
+ className: "nice-chart__legend-text",
1865
+ children: a.label
1866
+ }
1867
+ )
1868
+ ] }, a.id);
1869
+ })
1870
+ ] }) });
1871
+ }, kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1872
+ __proto__: null,
1873
+ NiceSankey: Qe
1874
+ }, Symbol.toStringTag, { value: "Module" })), St = ({
1875
+ data: t,
1876
+ min: o,
1877
+ max: i,
1878
+ start: s,
1879
+ end: c,
1880
+ onChange: v,
1881
+ width: p = 500,
1882
+ height: I = 100,
1883
+ step: T = 1,
1884
+ formatValue: w,
1885
+ chartColor: f = "var(--color-primary, #3b82f6)",
1886
+ className: N,
1887
+ style: z
1888
+ }) => {
1889
+ const C = { top: 10, bottom: 30, left: 10, right: 10 }, k = p - C.left - C.right, l = I - C.top - C.bottom, d = (b) => C.left + (b - o) / (i - o || 1) * k, u = (b) => {
1890
+ const h = Math.max(0, Math.min(1, (b - C.left) / k)), D = o + h * (i - o);
1891
+ return Math.round(D / T) * T;
1892
+ }, S = (b, h) => {
1893
+ h.preventDefault();
1894
+ const D = h.target.closest("svg");
1895
+ if (!D)
1896
+ return;
1897
+ const a = (A) => {
1898
+ const O = D.getBoundingClientRect(), U = u(A.clientX - O.left);
1899
+ b === "start" ? v(Math.min(U, c), c) : v(s, Math.max(U, s));
1900
+ }, _ = () => {
1901
+ document.removeEventListener("pointermove", a), document.removeEventListener("pointerup", _);
1902
+ };
1903
+ document.addEventListener("pointermove", a), document.addEventListener("pointerup", _);
1904
+ }, g = t ? Math.min(...t) : 0, y = (t ? Math.max(...t) : 1) - g || 1;
1905
+ return /* @__PURE__ */ e("div", { className: `nice-rangeselector ${N || ""}`, style: z, children: /* @__PURE__ */ $("svg", { width: p, height: I, children: [
1906
+ t && t.length > 1 && /* @__PURE__ */ e(
1907
+ "polygon",
1908
+ {
1909
+ points: `${C.left},${C.top + l} ${t.map((b, h) => `${C.left + h / (t.length - 1) * k},${C.top + l - (b - g) / y * l}`).join(" ")} ${C.left + k},${C.top + l}`,
1910
+ fill: f,
1911
+ opacity: 0.15
1912
+ }
1913
+ ),
1914
+ /* @__PURE__ */ e(
1915
+ "rect",
1916
+ {
1917
+ x: d(s),
1918
+ y: C.top,
1919
+ width: d(c) - d(s),
1920
+ height: l,
1921
+ fill: f,
1922
+ opacity: 0.1
1923
+ }
1924
+ ),
1925
+ /* @__PURE__ */ e(
1926
+ "rect",
1927
+ {
1928
+ x: C.left,
1929
+ y: C.top,
1930
+ width: d(s) - C.left,
1931
+ height: l,
1932
+ fill: "var(--bg-secondary, #f5f5f5)",
1933
+ opacity: 0.6
1934
+ }
1935
+ ),
1936
+ /* @__PURE__ */ e(
1937
+ "rect",
1938
+ {
1939
+ x: d(c),
1940
+ y: C.top,
1941
+ width: C.left + k - d(c),
1942
+ height: l,
1943
+ fill: "var(--bg-secondary, #f5f5f5)",
1944
+ opacity: 0.6
1945
+ }
1946
+ ),
1947
+ /* @__PURE__ */ e(
1948
+ "rect",
1949
+ {
1950
+ x: d(s) - 4,
1951
+ y: C.top,
1952
+ width: 8,
1953
+ height: l,
1954
+ fill: f,
1955
+ rx: 2,
1956
+ cursor: "ew-resize",
1957
+ onPointerDown: (b) => S("start", b)
1958
+ }
1959
+ ),
1960
+ /* @__PURE__ */ e(
1961
+ "rect",
1962
+ {
1963
+ x: d(c) - 4,
1964
+ y: C.top,
1965
+ width: 8,
1966
+ height: l,
1967
+ fill: f,
1968
+ rx: 2,
1969
+ cursor: "ew-resize",
1970
+ onPointerDown: (b) => S("end", b)
1971
+ }
1972
+ ),
1973
+ /* @__PURE__ */ e(
1974
+ "text",
1975
+ {
1976
+ x: d(s),
1977
+ y: C.top + l + 18,
1978
+ textAnchor: "middle",
1979
+ className: "nice-chart__axis-label",
1980
+ children: w ? w(s) : s
1981
+ }
1982
+ ),
1983
+ /* @__PURE__ */ e(
1984
+ "text",
1985
+ {
1986
+ x: d(c),
1987
+ y: C.top + l + 18,
1988
+ textAnchor: "middle",
1989
+ className: "nice-chart__axis-label",
1990
+ children: w ? w(c) : c
1991
+ }
1992
+ )
1993
+ ] }) });
1994
+ }, et = ({
1995
+ regions: t,
1996
+ width: o = 600,
1997
+ height: i = 400,
1998
+ viewBox: s = "0 0 1000 600",
1999
+ colorRange: c = ["var(--info-bg, #dbeafe)", "var(--color-primary-active, #1d4ed8)"],
2000
+ maxValue: v,
2001
+ onRegionClick: p,
2002
+ selectedRegionId: I,
2003
+ title: T,
2004
+ showTooltip: w = !0,
2005
+ className: f,
2006
+ style: N
2007
+ }) => {
2008
+ const z = v ?? Math.max(...t.map((k) => k.value ?? 0), 1), C = (k) => {
2009
+ const l = (a) => [
2010
+ parseInt(a.slice(1, 3), 16),
2011
+ parseInt(a.slice(3, 5), 16),
2012
+ parseInt(a.slice(5, 7), 16)
2013
+ ], [d, u, S] = l(c[0]), [g, x, y] = l(c[1]), b = Math.round(d + (g - d) * k), h = Math.round(u + (x - u) * k), D = Math.round(S + (y - S) * k);
2014
+ return `rgb(${b},${h},${D})`;
2015
+ };
2016
+ return /* @__PURE__ */ $("div", { className: `nice-vectormap ${f || ""}`, style: N, children: [
2017
+ T && /* @__PURE__ */ e("div", { className: "nice-vectormap__title", children: T }),
2018
+ /* @__PURE__ */ e("svg", { width: o, height: i, viewBox: s, children: t.map((k) => {
2019
+ const l = k.value != null ? Math.max(0, Math.min(1, k.value / z)) : 0, d = k.value != null ? C(l) : "var(--bg-tertiary, #e5e7eb)", u = k.id === I;
2020
+ return /* @__PURE__ */ e(
2021
+ "path",
2022
+ {
2023
+ d: k.path,
2024
+ fill: d,
2025
+ stroke: u ? "var(--color-primary, #3b82f6)" : "var(--border-color, #d1d5db)",
2026
+ strokeWidth: u ? 2 : 0.5,
2027
+ cursor: p ? "pointer" : void 0,
2028
+ onClick: () => p?.(k),
2029
+ children: w && /* @__PURE__ */ e("title", { children: `${k.name}${k.value != null ? `: ${k.value}` : ""}` })
2030
+ },
2031
+ k.id
2032
+ );
2033
+ }) })
2034
+ ] });
2035
+ }, Ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2036
+ __proto__: null,
2037
+ NiceVectorMap: et
2038
+ }, Symbol.toStringTag, { value: "Module" })), tt = `
2039
+ .nice-forecast-chart {
2040
+ display: flex;
2041
+ flex-direction: column;
2042
+ background: var(--nice-bg-primary, #ffffff);
2043
+ border: 1px solid var(--nice-border-color, #e5e7eb);
2044
+ border-radius: var(--nice-radius-lg, 0.5rem);
2045
+ overflow: hidden;
2046
+ }
2047
+
2048
+ .nice-forecast-chart__header {
2049
+ display: flex;
2050
+ align-items: center;
2051
+ justify-content: space-between;
2052
+ padding: 0.75rem 1rem;
2053
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
2054
+ }
2055
+
2056
+ .nice-forecast-chart__title {
2057
+ font-size: 1rem;
2058
+ font-weight: 600;
2059
+ color: var(--nice-text-primary);
2060
+ margin: 0;
2061
+ }
2062
+
2063
+ .nice-forecast-chart__actions {
2064
+ display: flex;
2065
+ gap: 0.5rem;
2066
+ }
2067
+
2068
+ .nice-forecast-chart__btn {
2069
+ display: inline-flex;
2070
+ align-items: center;
2071
+ justify-content: center;
2072
+ width: 2rem;
2073
+ height: 2rem;
2074
+ font-size: 1rem;
2075
+ border-radius: var(--nice-radius-md, 0.375rem);
2076
+ cursor: pointer;
2077
+ transition: all 0.15s ease;
2078
+ border: 1px solid var(--nice-border-color, #d1d5db);
2079
+ background: var(--nice-bg-primary, #ffffff);
2080
+ color: var(--nice-text-secondary);
2081
+ }
2082
+
2083
+ .nice-forecast-chart__btn:hover {
2084
+ background: var(--nice-bg-hover, #f3f4f6);
2085
+ color: var(--nice-text-primary);
2086
+ }
2087
+
2088
+ .nice-forecast-chart__btn:disabled {
2089
+ opacity: 0.5;
2090
+ cursor: not-allowed;
2091
+ }
2092
+
2093
+ .nice-forecast-chart__container {
2094
+ position: relative;
2095
+ width: 100%;
2096
+ padding: 1rem;
2097
+ }
2098
+
2099
+ .nice-forecast-chart__svg {
2100
+ width: 100%;
2101
+ overflow: visible;
2102
+ }
2103
+
2104
+ .nice-forecast-chart__grid-line {
2105
+ stroke: var(--nice-border-divider, #f3f4f6);
2106
+ stroke-width: 1;
2107
+ }
2108
+
2109
+ .nice-forecast-chart__axis-line {
2110
+ stroke: var(--nice-border-color, #e5e7eb);
2111
+ stroke-width: 1;
2112
+ }
2113
+
2114
+ .nice-forecast-chart__axis-label {
2115
+ font-size: 0.6875rem;
2116
+ fill: var(--nice-text-secondary);
2117
+ }
2118
+
2119
+ .nice-forecast-chart__axis-title {
2120
+ font-size: 0.75rem;
2121
+ font-weight: 500;
2122
+ fill: var(--nice-text-primary);
2123
+ }
2124
+
2125
+ .nice-forecast-chart__historical-line {
2126
+ fill: none;
2127
+ stroke-width: 2;
2128
+ stroke-linecap: round;
2129
+ stroke-linejoin: round;
2130
+ }
2131
+
2132
+ .nice-forecast-chart__forecast-line {
2133
+ fill: none;
2134
+ stroke-width: 2;
2135
+ stroke-linecap: round;
2136
+ stroke-linejoin: round;
2137
+ stroke-dasharray: 6, 4;
2138
+ }
2139
+
2140
+ .nice-forecast-chart__confidence-band {
2141
+ opacity: 0.2;
2142
+ }
2143
+
2144
+ .nice-forecast-chart__forecast-region {
2145
+ fill: var(--nice-bg-secondary, #f9fafb);
2146
+ opacity: 0.5;
2147
+ }
2148
+
2149
+ .nice-forecast-chart__point {
2150
+ cursor: pointer;
2151
+ transition: r 0.15s ease;
2152
+ }
2153
+
2154
+ .nice-forecast-chart__point:hover {
2155
+ r: 6;
2156
+ }
2157
+
2158
+ .nice-forecast-chart__annotation-line {
2159
+ stroke-dasharray: 4, 2;
2160
+ stroke-width: 1;
2161
+ }
2162
+
2163
+ .nice-forecast-chart__annotation-marker {
2164
+ cursor: pointer;
2165
+ transition: transform 0.15s ease;
2166
+ }
2167
+
2168
+ .nice-forecast-chart__annotation-marker:hover {
2169
+ transform: scale(1.2);
2170
+ }
2171
+
2172
+ .nice-forecast-chart__reference-line {
2173
+ stroke-width: 1;
2174
+ }
2175
+
2176
+ .nice-forecast-chart__reference-label {
2177
+ font-size: 0.625rem;
2178
+ fill: var(--nice-text-secondary);
2179
+ }
2180
+
2181
+ .nice-forecast-chart__cash-runway {
2182
+ pointer-events: none;
2183
+ }
2184
+
2185
+ .nice-forecast-chart__cash-runway-line {
2186
+ stroke: var(--nice-danger, #ef4444);
2187
+ stroke-width: 2;
2188
+ stroke-dasharray: 8, 4;
2189
+ }
2190
+
2191
+ .nice-forecast-chart__cash-runway-label-bg {
2192
+ fill: var(--nice-danger, #ef4444);
2193
+ rx: 4;
2194
+ }
2195
+
2196
+ .nice-forecast-chart__cash-runway-label {
2197
+ font-size: 0.6875rem;
2198
+ font-weight: 600;
2199
+ fill: var(--nice-bg, #FFFFFF);
2200
+ }
2201
+
2202
+ .nice-forecast-chart__cash-runway-date {
2203
+ font-size: 0.625rem;
2204
+ fill: var(--nice-danger, #ef4444);
2205
+ font-weight: 500;
2206
+ }
2207
+
2208
+ .nice-forecast-chart__tooltip {
2209
+ position: absolute;
2210
+ pointer-events: none;
2211
+ z-index: 100;
2212
+ padding: 0.75rem;
2213
+ background: var(--nice-bg-primary, #ffffff);
2214
+ border: 1px solid var(--nice-border-color, #e5e7eb);
2215
+ border-radius: var(--nice-radius-lg, 0.5rem);
2216
+ box-shadow: 0 4px 12px var(--nice-overlay-10, rgba(0, 0, 0, 0.1));
2217
+ font-size: 0.8125rem;
2218
+ max-width: 250px;
2219
+ }
2220
+
2221
+ .nice-forecast-chart__tooltip-date {
2222
+ font-weight: 600;
2223
+ color: var(--nice-text-primary);
2224
+ margin-bottom: 0.5rem;
2225
+ padding-bottom: 0.5rem;
2226
+ border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
2227
+ }
2228
+
2229
+ .nice-forecast-chart__tooltip-item {
2230
+ display: flex;
2231
+ align-items: center;
2232
+ gap: 0.5rem;
2233
+ margin-bottom: 0.25rem;
2234
+ }
2235
+
2236
+ .nice-forecast-chart__tooltip-color {
2237
+ width: 10px;
2238
+ height: 10px;
2239
+ border-radius: var(--nice-radius-sm, 2px);
2240
+ flex-shrink: 0;
2241
+ }
2242
+
2243
+ .nice-forecast-chart__tooltip-label {
2244
+ color: var(--nice-text-secondary);
2245
+ flex: 1;
2246
+ }
2247
+
2248
+ .nice-forecast-chart__tooltip-value {
2249
+ font-weight: 600;
2250
+ color: var(--nice-text-primary);
2251
+ font-variant-numeric: tabular-nums;
2252
+ }
2253
+
2254
+ .nice-forecast-chart__tooltip-confidence {
2255
+ font-size: 0.75rem;
2256
+ color: var(--nice-text-tertiary);
2257
+ }
2258
+
2259
+ .nice-forecast-chart__legend {
2260
+ display: flex;
2261
+ flex-wrap: wrap;
2262
+ gap: 1rem;
2263
+ padding: 0.75rem 1rem;
2264
+ border-top: 1px solid var(--nice-border-color, #e5e7eb);
2265
+ }
2266
+
2267
+ .nice-forecast-chart__legend-item {
2268
+ display: flex;
2269
+ align-items: center;
2270
+ gap: 0.375rem;
2271
+ font-size: 0.8125rem;
2272
+ color: var(--nice-text-secondary);
2273
+ cursor: pointer;
2274
+ user-select: none;
2275
+ transition: opacity 0.15s ease;
2276
+ }
2277
+
2278
+ .nice-forecast-chart__legend-item:hover {
2279
+ color: var(--nice-text-primary);
2280
+ }
2281
+
2282
+ .nice-forecast-chart__legend-item--hidden {
2283
+ opacity: 0.4;
2284
+ }
2285
+
2286
+ .nice-forecast-chart__legend-color {
2287
+ width: 16px;
2288
+ height: 3px;
2289
+ border-radius: var(--nice-radius-xs, 1px);
2290
+ }
2291
+
2292
+ .nice-forecast-chart__legend-color--dashed {
2293
+ background: repeating-linear-gradient(
2294
+ 90deg,
2295
+ currentColor,
2296
+ currentColor 4px,
2297
+ transparent 4px,
2298
+ transparent 6px
2299
+ );
2300
+ }
2301
+
2302
+ .nice-forecast-chart__empty {
2303
+ display: flex;
2304
+ align-items: center;
2305
+ justify-content: center;
2306
+ height: 300px;
2307
+ color: var(--nice-text-secondary);
2308
+ }
2309
+
2310
+ /* Dark mode */
2311
+ .dark .nice-forecast-chart {
2312
+ background: var(--nice-bg-primary-dark, #111827);
2313
+ border-color: var(--nice-border-color-dark, #374151);
2314
+ }
2315
+
2316
+ .dark .nice-forecast-chart__tooltip {
2317
+ background: var(--nice-bg-secondary-dark, #1f2937);
2318
+ border-color: var(--nice-border-color-dark, #374151);
2319
+ }
2320
+
2321
+ .dark .nice-forecast-chart__forecast-region {
2322
+ fill: var(--nice-bg-secondary-dark, #1f2937);
2323
+ }
2324
+ `, Oe = [
2325
+ "var(--color-primary, #3b82f6)",
2326
+ // blue
2327
+ "var(--color-success, #10b981)",
2328
+ // green
2329
+ "var(--color-warning, #f59e0b)",
2330
+ // amber
2331
+ "var(--color-error, #ef4444)",
2332
+ // red
2333
+ "var(--color-accent, #8b5cf6)",
2334
+ // purple
2335
+ "var(--color-accent-pink, #ec4899)",
2336
+ // pink
2337
+ "var(--color-info, #06b6d4)",
2338
+ // cyan
2339
+ "var(--nice-warning, #f97316)"
2340
+ // orange
2341
+ ];
2342
+ function xe(t) {
2343
+ return t instanceof Date ? t : new Date(t);
2344
+ }
2345
+ function Be(t, o = "pl-PL") {
2346
+ return t.toLocaleDateString(o, {
2347
+ year: "numeric",
2348
+ month: "short",
2349
+ day: "numeric"
2350
+ });
2351
+ }
2352
+ function Ie(t, o = "pl-PL") {
2353
+ return new Intl.NumberFormat(o, {
2354
+ minimumFractionDigits: 0,
2355
+ maximumFractionDigits: 2
2356
+ }).format(t);
2357
+ }
2358
+ const At = Ne(
2359
+ function(o, i) {
2360
+ const {
2361
+ scenarios: s,
2362
+ data: c,
2363
+ annotations: v = [],
2364
+ referenceLines: p = [],
2365
+ forecastStartDate: I,
2366
+ cashRunway: T,
2367
+ xAxis: w,
2368
+ yAxis: f,
2369
+ confidenceBands: N = [
2370
+ { level: 95, color: "var(--color-primary, #3b82f6)", opacity: 0.15 }
2371
+ ],
2372
+ tooltip: z,
2373
+ legend: C = { enabled: !0, position: "bottom", interactive: !0 },
2374
+ height: k = 350,
2375
+ showForecastRegion: l = !0,
2376
+ lineWidth: d = 2,
2377
+ showPoints: u = !1,
2378
+ pointRadius: S = 4,
2379
+ enableZoom: g = !1,
2380
+ zoomEnabled: x,
2381
+ animationDuration: y = 300,
2382
+ showLegend: b,
2383
+ responsive: h = !0,
2384
+ onPointClick: D,
2385
+ onAnnotationClick: a,
2386
+ onScenarioToggle: _,
2387
+ onViewportChange: A,
2388
+ size: O = "medium",
2389
+ disabled: U = !1,
2390
+ labels: V = {},
2391
+ locale: j = "pl-PL",
2392
+ className: G,
2393
+ style: Q
2394
+ } = o, q = s && s.length > 0 ? s : c ? [
2395
+ {
2396
+ id: "default",
2397
+ name: "Series",
2398
+ data: c
2399
+ }
2400
+ ] : [], J = {
2401
+ ...C,
2402
+ enabled: b ?? C.enabled
2403
+ }, [n, X] = oe(
2404
+ () => q.map((r, R) => ({
2405
+ ...r,
2406
+ color: r.color ?? Oe[R % Oe.length],
2407
+ visible: r.visible !== !1
2408
+ }))
2409
+ ), [H, W] = oe(null), [m, F] = oe({ x: 0, y: 0 }), Y = be(null), ee = be(null), P = { top: 20, right: 30, bottom: 40, left: 60 }, [te, fe] = oe({
2410
+ width: 600,
2411
+ height: typeof k == "number" ? k : 350
2412
+ });
2413
+ Ce(() => {
2414
+ if (!h || !Y.current)
2415
+ return;
2416
+ const r = new ResizeObserver((R) => {
2417
+ for (const E of R)
2418
+ fe((M) => ({
2419
+ width: E.contentRect.width,
2420
+ height: M.height
2421
+ }));
2422
+ });
2423
+ return r.observe(Y.current), () => r.disconnect();
2424
+ }, [h]), Ce(() => {
2425
+ const r = "nice-forecast-chart-styles";
2426
+ if (!document.getElementById(r)) {
2427
+ const R = document.createElement("style");
2428
+ R.id = r, R.textContent = tt, document.head.appendChild(R);
2429
+ }
2430
+ }, []);
2431
+ const { xScale: L, yScale: Z, allDates: ne, minY: ue, maxY: _e } = pe(() => {
2432
+ const R = n.filter((me) => me.visible !== !1).flatMap((me) => me.data);
2433
+ if (R.length === 0)
2434
+ return { xScale: () => 0, yScale: () => 0, allDates: [], minY: 0, maxY: 100 };
2435
+ const E = R.map((me) => xe(me.date).getTime()), M = Math.min(...E), K = Math.max(...E), ie = R.flatMap((me) => [me.value, me.forecast, me.lowerBound, me.upperBound]).filter((me) => me != null), le = f?.min ?? Math.min(...ie) * 0.95, he = f?.max ?? Math.max(...ie) * 1.05, we = te.width - P.left - P.right, Me = te.height - P.top - P.bottom, Le = (me) => {
2436
+ const Te = typeof me == "number" ? me : me.getTime();
2437
+ return P.left + (Te - M) / (K - M) * we;
2438
+ }, De = (me) => P.top + Me - (me - le) / (he - le) * Me, He = [...new Set(E)].sort((me, Te) => me - Te).map((me) => new Date(me));
2439
+ return {
2440
+ xScale: Le,
2441
+ yScale: De,
2442
+ allDates: He,
2443
+ minY: le,
2444
+ maxY: he
2445
+ };
2446
+ }, [n, te, P, f]), ge = I ? xe(I) : null, ye = pe(() => {
2447
+ if (!T?.enabled)
2448
+ return null;
2449
+ const r = T.threshold ?? 0, R = T.scenarioId ? n.find((M) => M.id === T.scenarioId && M.visible !== !1) : n.find((M) => M.visible !== !1);
2450
+ if (!R)
2451
+ return null;
2452
+ const E = R.data.sort(
2453
+ (M, K) => xe(M.date).getTime() - xe(K.date).getTime()
2454
+ );
2455
+ for (let M = 1; M < E.length; M++) {
2456
+ const K = E[M - 1], ie = E[M], le = K.forecast ?? K.value, he = ie.forecast ?? ie.value;
2457
+ if (le != null && he != null && le > r && he <= r) {
2458
+ const we = (le - r) / (le - he), Me = xe(K.date).getTime(), Le = xe(ie.date).getTime(), De = Me + we * (Le - Me);
2459
+ return new Date(De);
2460
+ }
2461
+ }
2462
+ return null;
2463
+ }, [T, n]), $e = ae(
2464
+ (r, R) => {
2465
+ const E = r.filter((M) => M[R] != null).map((M) => ({ x: L(xe(M.date)), y: Z(M[R]) }));
2466
+ return E.length === 0 ? "" : `M ${E.map((M) => `${M.x},${M.y}`).join(" L ")}`;
2467
+ },
2468
+ [L, Z]
2469
+ ), Se = ae(
2470
+ (r) => {
2471
+ const R = r.filter((K) => K.lowerBound != null && K.upperBound != null);
2472
+ if (R.length === 0)
2473
+ return "";
2474
+ const E = R.map((K) => ({
2475
+ x: L(xe(K.date)),
2476
+ y: Z(K.upperBound)
2477
+ })), M = R.map((K) => ({ x: L(xe(K.date)), y: Z(K.lowerBound) })).reverse();
2478
+ return `M ${E.map((K) => `${K.x},${K.y}`).join(" L ")} L ${M.map((K) => `${K.x},${K.y}`).join(" L ")} Z`;
2479
+ },
2480
+ [L, Z]
2481
+ ), B = ae(
2482
+ (r) => {
2483
+ if (!ee.current || z?.enabled === !1)
2484
+ return;
2485
+ const R = ee.current.getBoundingClientRect(), E = r.clientX - R.left;
2486
+ r.clientY - R.top;
2487
+ let M = null, K = 1 / 0;
2488
+ for (const ie of ne) {
2489
+ const le = L(ie), he = Math.abs(le - E);
2490
+ he < K && (K = he, M = ie);
2491
+ }
2492
+ if (M && K < 50) {
2493
+ const ie = n.filter((he) => he.visible !== !1).map((he) => {
2494
+ const we = he.data.find((Me) => xe(Me.date).getTime() === M.getTime());
2495
+ return {
2496
+ scenario: he,
2497
+ value: we?.value,
2498
+ forecast: we?.forecast,
2499
+ lowerBound: we?.lowerBound,
2500
+ upperBound: we?.upperBound
2501
+ };
2502
+ }), le = v.filter(
2503
+ (he) => Math.abs(xe(he.date).getTime() - M.getTime()) < 864e5
2504
+ );
2505
+ W({ date: M, values: ie, annotations: le }), F({ x: r.clientX - R.left + 10, y: r.clientY - R.top - 10 });
2506
+ } else
2507
+ W(null);
2508
+ },
2509
+ [L, ne, n, v, z]
2510
+ ), re = ae(
2511
+ (r) => {
2512
+ if (!J.interactive)
2513
+ return;
2514
+ X((E) => E.map((M) => M.id === r ? { ...M, visible: !M.visible } : M));
2515
+ const R = n.find((E) => E.id === r);
2516
+ R && _?.(r, !R.visible);
2517
+ },
2518
+ [J.interactive, n, _]
2519
+ );
2520
+ Ae(
2521
+ i,
2522
+ () => ({
2523
+ getScenarios: () => n,
2524
+ updateScenario: (r, R) => {
2525
+ X((E) => E.map((M) => M.id === r ? { ...M, data: R } : M));
2526
+ },
2527
+ toggleScenario: re,
2528
+ setZoomRange: () => {
2529
+ },
2530
+ // Would need pan/zoom implementation
2531
+ resetZoom: () => {
2532
+ },
2533
+ exportImage: (r) => {
2534
+ if (!ee.current)
2535
+ return null;
2536
+ const R = ee.current, M = new XMLSerializer().serializeToString(R);
2537
+ return `data:image/svg+xml;base64,${btoa(M)}`;
2538
+ },
2539
+ getDataAtDate: (r) => {
2540
+ const R = n.filter((E) => E.visible !== !1).map((E) => {
2541
+ const M = E.data.find((K) => xe(K.date).getTime() === r.getTime());
2542
+ return {
2543
+ scenario: E,
2544
+ value: M?.value,
2545
+ forecast: M?.forecast,
2546
+ lowerBound: M?.lowerBound,
2547
+ upperBound: M?.upperBound
2548
+ };
2549
+ });
2550
+ return {
2551
+ date: r,
2552
+ values: R,
2553
+ annotations: v.filter((E) => xe(E.date).getTime() === r.getTime())
2554
+ };
2555
+ }
2556
+ }),
2557
+ [n, v, re]
2558
+ ), te.width - P.left - P.right;
2559
+ const ce = te.height - P.top - P.bottom, se = pe(() => {
2560
+ const r = f?.tickCount ?? 5, R = [], E = (_e - ue) / (r - 1);
2561
+ for (let M = 0; M < r; M++)
2562
+ R.push(ue + E * M);
2563
+ return R;
2564
+ }, [ue, _e, f?.tickCount]), de = pe(() => {
2565
+ const r = w?.tickCount ?? 6;
2566
+ if (ne.length === 0)
2567
+ return [];
2568
+ const R = Math.max(1, Math.floor(ne.length / (r - 1)));
2569
+ return ne.filter((E, M) => M % R === 0 || M === ne.length - 1);
2570
+ }, [ne, w?.tickCount]);
2571
+ return n.length === 0 || n.every((r) => r.data.length === 0) ? /* @__PURE__ */ e("div", { className: `nice-forecast-chart ${G ?? ""}`, style: Q, children: /* @__PURE__ */ e("div", { className: "nice-forecast-chart__empty", children: V.noData ?? "No data available" }) }) : /* @__PURE__ */ $("div", { className: `nice-forecast-chart ${G ?? ""}`, style: { ...Q, height: k }, children: [
2572
+ /* @__PURE__ */ $("div", { ref: Y, className: "nice-forecast-chart__container", children: [
2573
+ /* @__PURE__ */ $(
2574
+ "svg",
2575
+ {
2576
+ ref: ee,
2577
+ className: "nice-forecast-chart__svg",
2578
+ width: te.width,
2579
+ height: te.height,
2580
+ onMouseMove: B,
2581
+ onMouseLeave: () => W(null),
2582
+ children: [
2583
+ f?.showGrid !== !1 && se.map((r) => /* @__PURE__ */ e(
2584
+ "line",
2585
+ {
2586
+ className: "nice-forecast-chart__grid-line",
2587
+ x1: P.left,
2588
+ x2: te.width - P.right,
2589
+ y1: Z(r),
2590
+ y2: Z(r)
2591
+ },
2592
+ r
2593
+ )),
2594
+ l && ge && /* @__PURE__ */ e(
2595
+ "rect",
2596
+ {
2597
+ className: "nice-forecast-chart__forecast-region",
2598
+ x: L(ge),
2599
+ y: P.top,
2600
+ width: te.width - P.right - L(ge),
2601
+ height: ce
2602
+ }
2603
+ ),
2604
+ p.map((r) => /* @__PURE__ */ $("g", { children: [
2605
+ /* @__PURE__ */ e(
2606
+ "line",
2607
+ {
2608
+ className: "nice-forecast-chart__reference-line",
2609
+ x1: P.left,
2610
+ x2: te.width - P.right,
2611
+ y1: Z(r.value),
2612
+ y2: Z(r.value),
2613
+ stroke: r.color ?? "var(--text-muted, #9ca3af)",
2614
+ strokeDasharray: r.dashArray ?? "4,2"
2615
+ }
2616
+ ),
2617
+ r.label && /* @__PURE__ */ e(
2618
+ "text",
2619
+ {
2620
+ className: "nice-forecast-chart__reference-label",
2621
+ x: te.width - P.right - 4,
2622
+ y: Z(r.value) - 4,
2623
+ textAnchor: "end",
2624
+ children: r.label
2625
+ }
2626
+ )
2627
+ ] }, r.id)),
2628
+ ye && T?.enabled && /* @__PURE__ */ $("g", { className: "nice-forecast-chart__cash-runway", children: [
2629
+ /* @__PURE__ */ e(
2630
+ "line",
2631
+ {
2632
+ className: "nice-forecast-chart__cash-runway-line",
2633
+ x1: L(ye),
2634
+ x2: L(ye),
2635
+ y1: P.top,
2636
+ y2: te.height - P.bottom,
2637
+ stroke: T.color ?? "var(--color-error, #ef4444)"
2638
+ }
2639
+ ),
2640
+ T.showLabel !== !1 && /* @__PURE__ */ $(Pe, { children: [
2641
+ /* @__PURE__ */ e(
2642
+ "rect",
2643
+ {
2644
+ className: "nice-forecast-chart__cash-runway-label-bg",
2645
+ x: L(ye) - 60,
2646
+ y: P.top - 2,
2647
+ width: 120,
2648
+ height: T.showDate !== !1 ? 32 : 20,
2649
+ fill: T.color ?? "var(--color-error, #ef4444)",
2650
+ rx: 4
2651
+ }
2652
+ ),
2653
+ /* @__PURE__ */ e(
2654
+ "text",
2655
+ {
2656
+ className: "nice-forecast-chart__cash-runway-label",
2657
+ x: L(ye),
2658
+ y: P.top + 12,
2659
+ textAnchor: "middle",
2660
+ fill: "var(--nice-bg, #fff)",
2661
+ children: T.label ?? V.cashRunsOut ?? "💰 Cash runs out"
2662
+ }
2663
+ ),
2664
+ T.showDate !== !1 && /* @__PURE__ */ e(
2665
+ "text",
2666
+ {
2667
+ className: "nice-forecast-chart__cash-runway-label",
2668
+ x: L(ye),
2669
+ y: P.top + 26,
2670
+ textAnchor: "middle",
2671
+ fill: "var(--nice-bg, #fff)",
2672
+ style: { fontSize: "0.625rem", opacity: 0.9 },
2673
+ children: Be(ye, j)
2674
+ }
2675
+ )
2676
+ ] })
2677
+ ] }),
2678
+ n.filter((r) => r.visible !== !1 && r.showConfidenceBand).map((r) => /* @__PURE__ */ e(
2679
+ "path",
2680
+ {
2681
+ className: "nice-forecast-chart__confidence-band",
2682
+ d: Se(r.data),
2683
+ fill: r.color
2684
+ },
2685
+ `band-${r.id}`
2686
+ )),
2687
+ n.filter((r) => r.visible !== !1).map((r) => {
2688
+ const R = ge ? r.data.filter((M) => xe(M.date) < ge) : r.data.filter((M) => M.value != null), E = ge ? r.data.filter((M) => xe(M.date) >= ge) : r.data.filter((M) => M.forecast != null);
2689
+ return /* @__PURE__ */ $("g", { children: [
2690
+ /* @__PURE__ */ e(
2691
+ "path",
2692
+ {
2693
+ className: "nice-forecast-chart__historical-line",
2694
+ d: $e(R, "value"),
2695
+ stroke: r.color,
2696
+ strokeWidth: d
2697
+ }
2698
+ ),
2699
+ /* @__PURE__ */ e(
2700
+ "path",
2701
+ {
2702
+ className: "nice-forecast-chart__forecast-line",
2703
+ d: $e(E, ge ? "value" : "forecast"),
2704
+ stroke: r.color,
2705
+ strokeWidth: d
2706
+ }
2707
+ ),
2708
+ E.length > 0 && r.data.some((M) => M.forecast != null) && /* @__PURE__ */ e(
2709
+ "path",
2710
+ {
2711
+ className: "nice-forecast-chart__forecast-line",
2712
+ d: $e(r.data, "forecast"),
2713
+ stroke: r.color,
2714
+ strokeWidth: d
2715
+ }
2716
+ ),
2717
+ u && r.data.map((M, K) => {
2718
+ const ie = M.value ?? M.forecast;
2719
+ return ie == null ? null : /* @__PURE__ */ e(
2720
+ "circle",
2721
+ {
2722
+ className: "nice-forecast-chart__point",
2723
+ cx: L(xe(M.date)),
2724
+ cy: Z(ie),
2725
+ r: S,
2726
+ fill: r.color,
2727
+ onClick: () => D?.(M, r)
2728
+ },
2729
+ K
2730
+ );
2731
+ })
2732
+ ] }, r.id);
2733
+ }),
2734
+ v.map((r) => {
2735
+ const R = L(xe(r.date));
2736
+ return /* @__PURE__ */ $(
2737
+ "g",
2738
+ {
2739
+ className: "nice-forecast-chart__annotation-marker",
2740
+ onClick: () => a?.(r),
2741
+ children: [
2742
+ r.showLine !== !1 && /* @__PURE__ */ e(
2743
+ "line",
2744
+ {
2745
+ className: "nice-forecast-chart__annotation-line",
2746
+ x1: R,
2747
+ x2: R,
2748
+ y1: P.top,
2749
+ y2: te.height - P.bottom,
2750
+ stroke: r.color ?? "var(--text-muted, #9ca3af)"
2751
+ }
2752
+ ),
2753
+ /* @__PURE__ */ e(
2754
+ "circle",
2755
+ {
2756
+ cx: R,
2757
+ cy: P.top + 10,
2758
+ r: 8,
2759
+ fill: r.color ?? "var(--text-muted, #9ca3af)"
2760
+ }
2761
+ ),
2762
+ /* @__PURE__ */ e("text", { x: R, y: P.top + 14, textAnchor: "middle", fill: "white", fontSize: "10", children: r.icon ?? "!" })
2763
+ ]
2764
+ },
2765
+ r.id
2766
+ );
2767
+ }),
2768
+ /* @__PURE__ */ e(
2769
+ "line",
2770
+ {
2771
+ className: "nice-forecast-chart__axis-line",
2772
+ x1: P.left,
2773
+ x2: P.left,
2774
+ y1: P.top,
2775
+ y2: te.height - P.bottom
2776
+ }
2777
+ ),
2778
+ /* @__PURE__ */ e(
2779
+ "line",
2780
+ {
2781
+ className: "nice-forecast-chart__axis-line",
2782
+ x1: P.left,
2783
+ x2: te.width - P.right,
2784
+ y1: te.height - P.bottom,
2785
+ y2: te.height - P.bottom
2786
+ }
2787
+ ),
2788
+ se.map((r) => /* @__PURE__ */ e(
2789
+ "text",
2790
+ {
2791
+ className: "nice-forecast-chart__axis-label",
2792
+ x: P.left - 8,
2793
+ y: Z(r) + 4,
2794
+ textAnchor: "end",
2795
+ children: f?.format ? f.format(r) : Ie(r, j)
2796
+ },
2797
+ r
2798
+ )),
2799
+ de.map((r) => /* @__PURE__ */ e(
2800
+ "text",
2801
+ {
2802
+ className: "nice-forecast-chart__axis-label",
2803
+ x: L(r),
2804
+ y: te.height - P.bottom + 16,
2805
+ textAnchor: "middle",
2806
+ children: w?.format ? w.format(r) : Be(r, j)
2807
+ },
2808
+ r.getTime()
2809
+ )),
2810
+ f?.title && /* @__PURE__ */ e(
2811
+ "text",
2812
+ {
2813
+ className: "nice-forecast-chart__axis-title",
2814
+ x: 15,
2815
+ y: te.height / 2,
2816
+ textAnchor: "middle",
2817
+ transform: `rotate(-90, 15, ${te.height / 2})`,
2818
+ children: f.title
2819
+ }
2820
+ )
2821
+ ]
2822
+ }
2823
+ ),
2824
+ H && /* @__PURE__ */ $(
2825
+ "div",
2826
+ {
2827
+ className: "nice-forecast-chart__tooltip",
2828
+ style: { left: m.x, top: m.y },
2829
+ children: [
2830
+ /* @__PURE__ */ e("div", { className: "nice-forecast-chart__tooltip-date", children: Be(H.date, j) }),
2831
+ H.values.map((r) => {
2832
+ const R = r.value ?? r.forecast;
2833
+ return R == null ? null : /* @__PURE__ */ $("div", { className: "nice-forecast-chart__tooltip-item", children: [
2834
+ /* @__PURE__ */ e(
2835
+ "span",
2836
+ {
2837
+ className: "nice-forecast-chart__tooltip-color",
2838
+ style: { background: r.scenario.color }
2839
+ }
2840
+ ),
2841
+ /* @__PURE__ */ e("span", { className: "nice-forecast-chart__tooltip-label", children: r.scenario.name }),
2842
+ /* @__PURE__ */ e("span", { className: "nice-forecast-chart__tooltip-value", children: Ie(R, j) })
2843
+ ] }, r.scenario.id);
2844
+ }),
2845
+ H.values.some((r) => r.lowerBound != null) && /* @__PURE__ */ $("div", { className: "nice-forecast-chart__tooltip-confidence", children: [
2846
+ V.confidence ?? "CI",
2847
+ ":",
2848
+ " ",
2849
+ Ie(H.values[0]?.lowerBound ?? 0, j),
2850
+ " –",
2851
+ " ",
2852
+ Ie(H.values[0]?.upperBound ?? 0, j)
2853
+ ] })
2854
+ ]
2855
+ }
2856
+ )
2857
+ ] }),
2858
+ J.enabled && /* @__PURE__ */ e("div", { className: "nice-forecast-chart__legend", children: n.map((r) => /* @__PURE__ */ $(
2859
+ "div",
2860
+ {
2861
+ className: `nice-forecast-chart__legend-item ${r.visible === !1 ? "nice-forecast-chart__legend-item--hidden" : ""}`,
2862
+ onClick: () => re(r.id),
2863
+ children: [
2864
+ /* @__PURE__ */ e(
2865
+ "span",
2866
+ {
2867
+ className: `nice-forecast-chart__legend-color ${r.isBase ? "" : "nice-forecast-chart__legend-color--dashed"}`,
2868
+ style: { background: r.color }
2869
+ }
2870
+ ),
2871
+ r.name
2872
+ ]
2873
+ },
2874
+ r.id
2875
+ )) })
2876
+ ] });
2877
+ }
2878
+ ), Ye = [
2879
+ "var(--color-primary, #3b82f6)",
2880
+ "var(--color-error, #ef4444)",
2881
+ "var(--color-success, #22c55e)",
2882
+ "var(--color-warning, #f59e0b)",
2883
+ "var(--color-accent, #8b5cf6)",
2884
+ "var(--color-accent-pink, #ec4899)",
2885
+ "var(--color-info, #06b6d4)",
2886
+ "var(--color-success, #10b981)",
2887
+ "var(--color-warning, #f59e0b)",
2888
+ "var(--color-accent, #6366f1)"
2889
+ ], nt = Ne(
2890
+ (t, o) => {
2891
+ const {
2892
+ levels: i,
2893
+ initialLevelId: s,
2894
+ chartType: c = "bar",
2895
+ width: v = 600,
2896
+ height: p = 400,
2897
+ showBreadcrumbs: I = !0,
2898
+ showBackButton: T = !0,
2899
+ animationDuration: w = 300,
2900
+ onLevelChange: f,
2901
+ onItemClick: N,
2902
+ colors: z = Ye,
2903
+ showValues: C = !0,
2904
+ showLegend: k = !0,
2905
+ className: l,
2906
+ style: d,
2907
+ ...u
2908
+ } = t, [S, g] = oe(s || i[0]?.id), [x, y] = oe([s || i[0]?.id]), [b, h] = oe(!1), [D, a] = oe("in"), _ = pe(
2909
+ () => i.find((n) => n.id === S),
2910
+ [i, S]
2911
+ ), A = ae(
2912
+ (n) => {
2913
+ i.find((H) => H.id === n) && (a("in"), h(!0), setTimeout(() => {
2914
+ g(n), y((H) => [...H, n]), f?.(n, [...x, n]), h(!1);
2915
+ }, w / 2));
2916
+ },
2917
+ [i, x, w, f]
2918
+ ), O = ae(() => {
2919
+ if (x.length <= 1)
2920
+ return;
2921
+ a("out"), h(!0);
2922
+ const n = x.slice(0, -1), X = n[n.length - 1];
2923
+ setTimeout(() => {
2924
+ g(X), y(n), f?.(X, n), h(!1);
2925
+ }, w / 2);
2926
+ }, [x, w, f]), U = ae(() => {
2927
+ const n = i[0]?.id;
2928
+ n && (a("out"), h(!0), setTimeout(() => {
2929
+ g(n), y([n]), f?.(n, [n]), h(!1);
2930
+ }, w / 2));
2931
+ }, [i, w, f]);
2932
+ Ae(
2933
+ o,
2934
+ () => ({
2935
+ drillDown: A,
2936
+ drillUp: O,
2937
+ resetToRoot: U,
2938
+ getCurrentLevel: () => S,
2939
+ getPath: () => x
2940
+ }),
2941
+ [A, O, U, S, x]
2942
+ );
2943
+ const V = ae(
2944
+ (n, X) => {
2945
+ N?.(n, S);
2946
+ const H = i.find(
2947
+ (W) => W.parentId === S && W.id === n.metadata?.childLevelId
2948
+ );
2949
+ H && A(H.id);
2950
+ },
2951
+ [S, i, A, N]
2952
+ ), j = pe(
2953
+ () => _?.data.reduce((n, X) => n + X.value, 0) || 0,
2954
+ [_]
2955
+ ), G = pe(
2956
+ () => x.map((n) => i.find((X) => X.id === n)?.label || n),
2957
+ [x, i]
2958
+ ), Q = () => {
2959
+ if (!_)
2960
+ return null;
2961
+ const n = _.data, X = Math.max(...n.map((W) => W.value)), H = Math.min(40, (p - 100) / n.length - 8);
2962
+ return /* @__PURE__ */ e("div", { className: "nice-drilldown-bars", children: n.map((W, m) => {
2963
+ const F = W.value / X * 100;
2964
+ return /* @__PURE__ */ $(
2965
+ "div",
2966
+ {
2967
+ className: "nice-drilldown-bar-row",
2968
+ onClick: () => V(W, m),
2969
+ children: [
2970
+ /* @__PURE__ */ e("span", { className: "nice-drilldown-bar-label", children: W.label || `Item ${m + 1}` }),
2971
+ /* @__PURE__ */ e("div", { className: "nice-drilldown-bar-track", children: /* @__PURE__ */ e(
2972
+ "div",
2973
+ {
2974
+ className: "nice-drilldown-bar-fill",
2975
+ style: {
2976
+ width: `${F}%`,
2977
+ backgroundColor: W.color || z[m % z.length],
2978
+ height: H
2979
+ }
2980
+ }
2981
+ ) }),
2982
+ C && /* @__PURE__ */ e("span", { className: "nice-drilldown-bar-value", children: W.value.toLocaleString() })
2983
+ ]
2984
+ },
2985
+ m
2986
+ );
2987
+ }) });
2988
+ }, q = () => {
2989
+ if (!_)
2990
+ return null;
2991
+ const n = _.data, X = v / 2, H = (p - 60) / 2 + 30, W = Math.min(X, H) - 40;
2992
+ let m = -90;
2993
+ const F = n.map((Y, ee) => {
2994
+ const P = Y.value / j * 360, te = m + P, fe = P > 180 ? 1 : 0, L = m * Math.PI / 180, Z = te * Math.PI / 180, ne = X + W * Math.cos(L), ue = H + W * Math.sin(L), _e = X + W * Math.cos(Z), ge = H + W * Math.sin(Z), ye = (m + P / 2) * Math.PI / 180, $e = X + W * 0.7 * Math.cos(ye), Se = H + W * 0.7 * Math.sin(ye), B = `M ${X} ${H} L ${ne} ${ue} A ${W} ${W} 0 ${fe} 1 ${_e} ${ge} Z`;
2995
+ return m = te, {
2996
+ path: B,
2997
+ color: Y.color || z[ee % z.length],
2998
+ label: Y.label || `Item ${ee + 1}`,
2999
+ value: Y.value,
3000
+ percentage: (Y.value / j * 100).toFixed(1),
3001
+ labelX: $e,
3002
+ labelY: Se,
3003
+ item: Y,
3004
+ index: ee
3005
+ };
3006
+ });
3007
+ return /* @__PURE__ */ e("svg", { width: v, height: p - 40, className: "nice-drilldown-pie", children: /* @__PURE__ */ e("g", { children: F.map((Y, ee) => /* @__PURE__ */ $("g", { onClick: () => V(Y.item, Y.index), children: [
3008
+ /* @__PURE__ */ e(
3009
+ "path",
3010
+ {
3011
+ d: Y.path,
3012
+ fill: Y.color,
3013
+ stroke: "white",
3014
+ strokeWidth: 2,
3015
+ className: "nice-drilldown-pie-slice"
3016
+ }
3017
+ ),
3018
+ C && parseFloat(Y.percentage) > 5 && /* @__PURE__ */ $(
3019
+ "text",
3020
+ {
3021
+ x: Y.labelX,
3022
+ y: Y.labelY,
3023
+ textAnchor: "middle",
3024
+ dominantBaseline: "middle",
3025
+ fill: "white",
3026
+ fontSize: "12",
3027
+ fontWeight: "600",
3028
+ children: [
3029
+ Y.percentage,
3030
+ "%"
3031
+ ]
3032
+ }
3033
+ )
3034
+ ] }, ee)) }) });
3035
+ }, J = () => {
3036
+ if (!_)
3037
+ return null;
3038
+ const n = _.data, X = Math.max(...n.map((m) => m.value)), H = Math.min(60, (v - 100) / n.length - 8), W = p - 100;
3039
+ return /* @__PURE__ */ e("svg", { width: v, height: p - 40, className: "nice-drilldown-columns", children: /* @__PURE__ */ $("g", { transform: "translate(50, 20)", children: [
3040
+ [0, 0.25, 0.5, 0.75, 1].map((m, F) => /* @__PURE__ */ $("g", { children: [
3041
+ /* @__PURE__ */ e(
3042
+ "line",
3043
+ {
3044
+ x1: 0,
3045
+ y1: W * (1 - m),
3046
+ x2: v - 80,
3047
+ y2: W * (1 - m),
3048
+ stroke: "var(--border-color, #e5e7eb)",
3049
+ strokeDasharray: m === 0 ? void 0 : "4"
3050
+ }
3051
+ ),
3052
+ /* @__PURE__ */ e(
3053
+ "text",
3054
+ {
3055
+ x: -8,
3056
+ y: W * (1 - m),
3057
+ textAnchor: "end",
3058
+ dominantBaseline: "middle",
3059
+ fontSize: "11",
3060
+ fill: "var(--text-secondary, #6b7280)",
3061
+ children: Math.round(X * m).toLocaleString()
3062
+ }
3063
+ )
3064
+ ] }, F)),
3065
+ n.map((m, F) => {
3066
+ const Y = m.value / X * W, ee = F * ((v - 100) / n.length) + ((v - 100) / n.length - H) / 2;
3067
+ return /* @__PURE__ */ $("g", { onClick: () => V(m, F), children: [
3068
+ /* @__PURE__ */ e(
3069
+ "rect",
3070
+ {
3071
+ x: ee,
3072
+ y: W - Y,
3073
+ width: H,
3074
+ height: Y,
3075
+ fill: m.color || z[F % z.length],
3076
+ rx: 4,
3077
+ className: "nice-drilldown-column-bar"
3078
+ }
3079
+ ),
3080
+ /* @__PURE__ */ e(
3081
+ "text",
3082
+ {
3083
+ x: ee + H / 2,
3084
+ y: W + 16,
3085
+ textAnchor: "middle",
3086
+ fontSize: "11",
3087
+ fill: "var(--text-primary, #374151)",
3088
+ children: (m.label || `${F + 1}`).slice(0, 10)
3089
+ }
3090
+ ),
3091
+ C && /* @__PURE__ */ e(
3092
+ "text",
3093
+ {
3094
+ x: ee + H / 2,
3095
+ y: W - Y - 8,
3096
+ textAnchor: "middle",
3097
+ fontSize: "11",
3098
+ fill: "var(--text-primary, #374151)",
3099
+ fontWeight: "500",
3100
+ children: m.value.toLocaleString()
3101
+ }
3102
+ )
3103
+ ] }, F);
3104
+ })
3105
+ ] }) });
3106
+ };
3107
+ return /* @__PURE__ */ $(
3108
+ "div",
3109
+ {
3110
+ className: `nice-drilldown-chart ${b ? `animating ${D}` : ""} ${l || ""}`,
3111
+ style: { width: v, ...d },
3112
+ ...u,
3113
+ children: [
3114
+ /* @__PURE__ */ $("div", { className: "nice-drilldown-header", children: [
3115
+ T && x.length > 1 && /* @__PURE__ */ e("button", { className: "nice-drilldown-back", onClick: O, children: "← Wstecz" }),
3116
+ I && /* @__PURE__ */ e("div", { className: "nice-drilldown-breadcrumbs", children: G.map((n, X) => /* @__PURE__ */ $(Fe.Fragment, { children: [
3117
+ X > 0 && /* @__PURE__ */ e("span", { className: "nice-drilldown-separator", children: "/" }),
3118
+ /* @__PURE__ */ e(
3119
+ "span",
3120
+ {
3121
+ className: `nice-drilldown-crumb ${X === G.length - 1 ? "active" : ""}`,
3122
+ onClick: () => {
3123
+ if (X < G.length - 1) {
3124
+ const H = x.slice(0, X + 1);
3125
+ y(H), g(H[H.length - 1]);
3126
+ }
3127
+ },
3128
+ children: n
3129
+ }
3130
+ )
3131
+ ] }, X)) })
3132
+ ] }),
3133
+ /* @__PURE__ */ $("div", { className: "nice-drilldown-content", style: { height: p - 40 }, children: [
3134
+ c === "bar" && Q(),
3135
+ c === "pie" && q(),
3136
+ c === "column" && J()
3137
+ ] }),
3138
+ k && _ && /* @__PURE__ */ e("div", { className: "nice-drilldown-legend", children: _.data.map((n, X) => /* @__PURE__ */ $("div", { className: "nice-drilldown-legend-item", children: [
3139
+ /* @__PURE__ */ e(
3140
+ "span",
3141
+ {
3142
+ className: "nice-drilldown-legend-color",
3143
+ style: { backgroundColor: n.color || z[X % z.length] }
3144
+ }
3145
+ ),
3146
+ /* @__PURE__ */ e("span", { className: "nice-drilldown-legend-label", children: n.label || `Item ${X + 1}` })
3147
+ ] }, X)) }),
3148
+ /* @__PURE__ */ e("style", { children: `
3149
+ .nice-drilldown-chart {
3150
+ font-family: inherit;
3151
+ color: var(--text-primary, #111827);
3152
+ background: var(--bg-elevated, #ffffff);
3153
+ border-radius: 8px;
3154
+ overflow: hidden;
3155
+ }
3156
+
3157
+ .nice-drilldown-header {
3158
+ display: flex;
3159
+ align-items: center;
3160
+ gap: 12px;
3161
+ padding: 12px 16px;
3162
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
3163
+ min-height: 40px;
3164
+ }
3165
+
3166
+ .nice-drilldown-back {
3167
+ background: var(--bg-secondary, #f3f4f6);
3168
+ border: none;
3169
+ padding: 6px 12px;
3170
+ border-radius: 6px;
3171
+ cursor: pointer;
3172
+ font-size: 13px;
3173
+ font-family: inherit;
3174
+ color: var(--text-primary, #374151);
3175
+ transition: background 0.2s;
3176
+ }
3177
+
3178
+ .nice-drilldown-back:hover {
3179
+ background: var(--hover-bg, #e5e7eb);
3180
+ }
3181
+
3182
+ .nice-drilldown-breadcrumbs {
3183
+ display: flex;
3184
+ align-items: center;
3185
+ gap: 4px;
3186
+ font-size: 13px;
3187
+ font-family: inherit;
3188
+ }
3189
+
3190
+ .nice-drilldown-separator {
3191
+ color: var(--text-muted, #9ca3af);
3192
+ }
3193
+
3194
+ .nice-drilldown-crumb {
3195
+ color: var(--text-secondary, #6b7280);
3196
+ cursor: pointer;
3197
+ }
3198
+
3199
+ .nice-drilldown-crumb:hover:not(.active) {
3200
+ color: var(--color-primary, #3b82f6);
3201
+ }
3202
+
3203
+ .nice-drilldown-crumb.active {
3204
+ color: var(--text-primary, #111827);
3205
+ font-weight: 500;
3206
+ cursor: default;
3207
+ }
3208
+
3209
+ .nice-drilldown-content {
3210
+ padding: 16px;
3211
+ transition: opacity 0.15s, transform 0.15s;
3212
+ }
3213
+
3214
+ .nice-drilldown-chart.animating .nice-drilldown-content {
3215
+ opacity: 0;
3216
+ }
3217
+
3218
+ .nice-drilldown-chart.animating.in .nice-drilldown-content {
3219
+ transform: translateX(20px);
3220
+ }
3221
+
3222
+ .nice-drilldown-chart.animating.out .nice-drilldown-content {
3223
+ transform: translateX(-20px);
3224
+ }
3225
+
3226
+ .nice-drilldown-bars {
3227
+ display: flex;
3228
+ flex-direction: column;
3229
+ gap: 8px;
3230
+ }
3231
+
3232
+ .nice-drilldown-bar-row {
3233
+ display: flex;
3234
+ align-items: center;
3235
+ gap: 12px;
3236
+ cursor: pointer;
3237
+ padding: 4px 8px;
3238
+ margin: -4px -8px;
3239
+ border-radius: 6px;
3240
+ transition: background 0.2s;
3241
+ }
3242
+
3243
+ .nice-drilldown-bar-row:hover {
3244
+ background: var(--hover-bg, #f9fafb);
3245
+ }
3246
+
3247
+ .nice-drilldown-bar-label {
3248
+ width: 120px;
3249
+ font-size: 13px;
3250
+ font-family: inherit;
3251
+ color: var(--text-primary, #374151);
3252
+ overflow: hidden;
3253
+ text-overflow: ellipsis;
3254
+ white-space: nowrap;
3255
+ }
3256
+
3257
+ .nice-drilldown-bar-track {
3258
+ flex: 1;
3259
+ background: var(--bg-tertiary, #f3f4f6);
3260
+ border-radius: 6px;
3261
+ overflow: hidden;
3262
+ }
3263
+
3264
+ .nice-drilldown-bar-fill {
3265
+ transition: width 0.3s ease;
3266
+ border-radius: 6px;
3267
+ }
3268
+
3269
+ .nice-drilldown-bar-value {
3270
+ width: 80px;
3271
+ text-align: right;
3272
+ font-size: 13px;
3273
+ font-family: inherit;
3274
+ font-weight: 500;
3275
+ color: var(--text-primary, #111827);
3276
+ }
3277
+
3278
+ .nice-drilldown-pie-slice {
3279
+ cursor: pointer;
3280
+ transition: transform 0.2s, opacity 0.2s;
3281
+ transform-origin: center;
3282
+ }
3283
+
3284
+ .nice-drilldown-pie-slice:hover {
3285
+ opacity: 0.85;
3286
+ transform: scale(1.02);
3287
+ }
3288
+
3289
+ .nice-drilldown-column-bar {
3290
+ cursor: pointer;
3291
+ transition: opacity 0.2s;
3292
+ }
3293
+
3294
+ .nice-drilldown-column-bar:hover {
3295
+ opacity: 0.8;
3296
+ }
3297
+
3298
+ .nice-drilldown-legend {
3299
+ display: flex;
3300
+ flex-wrap: wrap;
3301
+ gap: 16px;
3302
+ padding: 12px 16px;
3303
+ border-top: 1px solid var(--border-color, #e5e7eb);
3304
+ }
3305
+
3306
+ .nice-drilldown-legend-item {
3307
+ display: flex;
3308
+ align-items: center;
3309
+ gap: 6px;
3310
+ }
3311
+
3312
+ .nice-drilldown-legend-color {
3313
+ width: 12px;
3314
+ height: 12px;
3315
+ border-radius: 3px;
3316
+ }
3317
+
3318
+ .nice-drilldown-legend-label {
3319
+ font-size: 12px;
3320
+ font-family: inherit;
3321
+ color: var(--text-secondary, #6b7280);
3322
+ }
3323
+ ` })
3324
+ ]
3325
+ }
3326
+ );
3327
+ }
3328
+ );
3329
+ nt.displayName = "NiceDrillDownChart";
3330
+ const It = ({
3331
+ type: t = "choropleth",
3332
+ regions: o = [],
3333
+ bubbles: i = [],
3334
+ width: s = 800,
3335
+ height: c = 500,
3336
+ viewBox: v = "0 0 800 500",
3337
+ colorScale: p = [
3338
+ "var(--info-bg, #dbeafe)",
3339
+ "var(--color-primary-light, #93c5fd)",
3340
+ "var(--color-primary, #3b82f6)",
3341
+ "var(--color-primary-active, #1d4ed8)",
3342
+ "var(--color-primary, #6366f1)"
3343
+ ],
3344
+ minValue: I,
3345
+ maxValue: T,
3346
+ showTooltip: w = !0,
3347
+ showLegend: f = !0,
3348
+ onRegionClick: N,
3349
+ onBubbleClick: z,
3350
+ onRegionHover: C,
3351
+ title: k,
3352
+ mapSvg: l,
3353
+ zoomable: d = !1,
3354
+ className: u,
3355
+ style: S,
3356
+ ...g
3357
+ }) => {
3358
+ const [x, y] = oe(null), [b, h] = oe(1), [D, a] = oe({ x: 0, y: 0 }), _ = be(null), A = be(!1), O = be({ x: 0, y: 0 }), U = I ?? Math.min(...o.map((m) => m.value), ...i.map((m) => m.value)), V = T ?? Math.max(...o.map((m) => m.value), ...i.map((m) => m.value)), j = ae(
3359
+ (m) => {
3360
+ const F = (m - U) / (V - U), Y = Math.min(Math.floor(F * p.length), p.length - 1);
3361
+ return p[Math.max(0, Y)];
3362
+ },
3363
+ [U, V, p]
3364
+ ), G = ae(
3365
+ (m) => {
3366
+ if (!w || !x)
3367
+ return;
3368
+ const F = _.current?.getBoundingClientRect();
3369
+ F && y(
3370
+ (Y) => Y ? { ...Y, x: m.clientX - F.left, y: m.clientY - F.top } : null
3371
+ );
3372
+ },
3373
+ [w, x]
3374
+ ), Q = ae(
3375
+ (m, F) => {
3376
+ const Y = _.current?.getBoundingClientRect();
3377
+ Y && w && y({
3378
+ x: F.clientX - Y.left,
3379
+ y: F.clientY - Y.top,
3380
+ content: `${m.name}: ${m.value.toLocaleString()}`
3381
+ }), C?.(m);
3382
+ },
3383
+ [w, C]
3384
+ ), q = ae(() => {
3385
+ y(null), C?.(null);
3386
+ }, [C]), J = ae(
3387
+ (m) => {
3388
+ if (!d)
3389
+ return;
3390
+ m.preventDefault();
3391
+ const F = m.deltaY > 0 ? 0.9 : 1.1;
3392
+ h((Y) => Math.min(Math.max(Y * F, 0.5), 4));
3393
+ },
3394
+ [d]
3395
+ ), n = ae(
3396
+ (m) => {
3397
+ d && (A.current = !0, O.current = { x: m.clientX - D.x, y: m.clientY - D.y });
3398
+ },
3399
+ [d, D]
3400
+ ), X = ae(() => {
3401
+ A.current = !1;
3402
+ }, []), H = ae((m) => {
3403
+ A.current && a({
3404
+ x: m.clientX - O.current.x,
3405
+ y: m.clientY - O.current.y
3406
+ });
3407
+ }, []), W = pe(() => o.length > 0 ? o : [
3408
+ {
3409
+ id: "mazowieckie",
3410
+ name: "Mazowieckie",
3411
+ value: 100,
3412
+ path: "M400,200 L450,200 L460,250 L420,280 L380,250 Z"
3413
+ },
3414
+ { id: "slaskie", name: "Śląskie", value: 80, path: "M350,280 L400,280 L390,330 L340,320 Z" },
3415
+ {
3416
+ id: "wielkopolskie",
3417
+ name: "Wielkopolskie",
3418
+ value: 70,
3419
+ path: "M300,200 L350,200 L360,260 L310,270 L280,230 Z"
3420
+ }
3421
+ ], [o]);
3422
+ return /* @__PURE__ */ $("div", { className: `nice-map-chart ${u || ""}`, style: { width: s, ...S }, ...g, children: [
3423
+ k && /* @__PURE__ */ e("div", { className: "nice-map-title", children: k }),
3424
+ /* @__PURE__ */ e(
3425
+ "svg",
3426
+ {
3427
+ ref: _,
3428
+ width: s,
3429
+ height: c,
3430
+ viewBox: v,
3431
+ className: "nice-map-svg",
3432
+ onWheel: J,
3433
+ onMouseDown: n,
3434
+ onMouseUp: X,
3435
+ onMouseLeave: X,
3436
+ onMouseMove: (m) => {
3437
+ G(m), H(m);
3438
+ },
3439
+ children: /* @__PURE__ */ $("g", { transform: `translate(${D.x}, ${D.y}) scale(${b})`, children: [
3440
+ l && /* @__PURE__ */ e("g", { dangerouslySetInnerHTML: { __html: l } }),
3441
+ t === "choropleth" && W.map((m) => /* @__PURE__ */ e(
3442
+ "path",
3443
+ {
3444
+ d: m.path,
3445
+ fill: m.color || j(m.value),
3446
+ stroke: "var(--bg-primary, #ffffff)",
3447
+ strokeWidth: 1,
3448
+ className: "nice-map-region",
3449
+ onClick: () => N?.(m),
3450
+ onMouseEnter: (F) => Q(m, F),
3451
+ onMouseLeave: q
3452
+ },
3453
+ m.id
3454
+ )),
3455
+ (t === "bubble" || i.length > 0) && i.map((m) => {
3456
+ const F = Math.sqrt((m.value - U) / (V - U)) * 30 + 5;
3457
+ return /* @__PURE__ */ e(
3458
+ "circle",
3459
+ {
3460
+ cx: m.lng,
3461
+ cy: m.lat,
3462
+ r: F,
3463
+ fill: m.color || "var(--color-primary, #3b82f6)",
3464
+ fillOpacity: 0.7,
3465
+ stroke: "var(--bg-primary, #ffffff)",
3466
+ strokeWidth: 1,
3467
+ className: "nice-map-bubble",
3468
+ onClick: () => z?.(m),
3469
+ onMouseEnter: (Y) => {
3470
+ const ee = _.current?.getBoundingClientRect();
3471
+ ee && w && y({
3472
+ x: Y.clientX - ee.left,
3473
+ y: Y.clientY - ee.top,
3474
+ content: `${m.label || m.id}: ${m.value.toLocaleString()}`
3475
+ });
3476
+ },
3477
+ onMouseLeave: q,
3478
+ children: m.label && /* @__PURE__ */ $("title", { children: [
3479
+ m.label,
3480
+ ": ",
3481
+ m.value
3482
+ ] })
3483
+ },
3484
+ m.id
3485
+ );
3486
+ })
3487
+ ] })
3488
+ }
3489
+ ),
3490
+ x && /* @__PURE__ */ e("div", { className: "nice-map-tooltip", style: { left: x.x + 10, top: x.y - 30 }, children: x.content }),
3491
+ f && /* @__PURE__ */ $("div", { className: "nice-map-legend", children: [
3492
+ /* @__PURE__ */ e("span", { className: "nice-map-legend-title", children: "Wartość" }),
3493
+ /* @__PURE__ */ e("div", { className: "nice-map-legend-scale", children: p.map((m, F) => /* @__PURE__ */ e("div", { className: "nice-map-legend-item", style: { backgroundColor: m } }, F)) }),
3494
+ /* @__PURE__ */ $("div", { className: "nice-map-legend-labels", children: [
3495
+ /* @__PURE__ */ e("span", { children: U.toLocaleString() }),
3496
+ /* @__PURE__ */ e("span", { children: V.toLocaleString() })
3497
+ ] })
3498
+ ] }),
3499
+ /* @__PURE__ */ e("style", { children: `
3500
+ .nice-map-chart {
3501
+ font-family: system-ui, -apple-system, sans-serif;
3502
+ background: white;
3503
+ border-radius: var(--nice-radius-lg, 8px);
3504
+ overflow: hidden;
3505
+ position: relative;
3506
+ }
3507
+
3508
+ .nice-map-title {
3509
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
3510
+ font-size: 16px;
3511
+ font-weight: 600;
3512
+ color: var(--text-primary, #0f172a);
3513
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
3514
+ }
3515
+
3516
+ .nice-map-svg {
3517
+ display: block;
3518
+ cursor: grab;
3519
+ }
3520
+
3521
+ .nice-map-svg:active {
3522
+ cursor: grabbing;
3523
+ }
3524
+
3525
+ .nice-map-region {
3526
+ cursor: pointer;
3527
+ transition: opacity 0.2s, stroke-width 0.2s;
3528
+ }
3529
+
3530
+ .nice-map-region:hover {
3531
+ opacity: 0.8;
3532
+ stroke-width: 2;
3533
+ }
3534
+
3535
+ .nice-map-bubble {
3536
+ cursor: pointer;
3537
+ transition: transform 0.2s, opacity 0.2s;
3538
+ }
3539
+
3540
+ .nice-map-bubble:hover {
3541
+ opacity: 1;
3542
+ transform: scale(1.1);
3543
+ }
3544
+
3545
+ .nice-map-tooltip {
3546
+ position: absolute;
3547
+ background: var(--text-primary, #0f172a);
3548
+ color: white;
3549
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
3550
+ border-radius: var(--nice-radius-sm, 4px);
3551
+ font-size: 12px;
3552
+ pointer-events: none;
3553
+ z-index: 10;
3554
+ white-space: nowrap;
3555
+ }
3556
+
3557
+ .nice-map-legend {
3558
+ position: absolute;
3559
+ right: 16px;
3560
+ bottom: 16px;
3561
+ background: white;
3562
+ padding: var(--nice-space-3, 12px);
3563
+ border-radius: var(--nice-radius-md, 6px);
3564
+ box-shadow: 0 2px 8px var(--nice-overlay-10, color-mix(in srgb, var(--text-primary, #000) 10%, transparent));
3565
+ }
3566
+
3567
+ .nice-map-legend-title {
3568
+ display: block;
3569
+ font-size: 11px;
3570
+ color: var(--text-secondary, #475569);
3571
+ margin-bottom: var(--nice-space-1-5, 6px);
3572
+ }
3573
+
3574
+ .nice-map-legend-scale {
3575
+ display: flex;
3576
+ height: 12px;
3577
+ border-radius: var(--nice-radius-sm, 2px);
3578
+ overflow: hidden;
3579
+ }
3580
+
3581
+ .nice-map-legend-item {
3582
+ flex: 1;
3583
+ min-width: 24px;
3584
+ }
3585
+
3586
+ .nice-map-legend-labels {
3587
+ display: flex;
3588
+ justify-content: space-between;
3589
+ font-size: 10px;
3590
+ color: var(--text-secondary, #475569);
3591
+ margin-top: var(--nice-space-1, 4px);
3592
+ }
3593
+ ` })
3594
+ ] });
3595
+ }, zt = ({
3596
+ nodes: t,
3597
+ links: o,
3598
+ width: i = 800,
3599
+ height: s = 500,
3600
+ nodeWidth: c = 20,
3601
+ nodePadding: v = 10,
3602
+ showValues: p = !0,
3603
+ showTooltip: I = !0,
3604
+ onNodeClick: T,
3605
+ onLinkClick: w,
3606
+ title: f,
3607
+ className: N,
3608
+ style: z,
3609
+ ...C
3610
+ }) => {
3611
+ const [k, l] = oe(null), d = be(null), u = pe(() => {
3612
+ const g = /* @__PURE__ */ new Map();
3613
+ t.forEach((n) => g.set(n.id, n));
3614
+ const x = new Set(o.map((n) => n.target)), y = new Set(o.map((n) => n.source)), b = [], h = /* @__PURE__ */ new Map(), D = t.filter((n) => y.has(n.id) && !x.has(n.id));
3615
+ D.length > 0 && (b.push(D.map((n) => n.id)), D.forEach((n) => h.set(n.id, 0)));
3616
+ const a = t.filter((n) => y.has(n.id) && x.has(n.id));
3617
+ a.length > 0 && (b.push(a.map((n) => n.id)), a.forEach((n) => h.set(n.id, 1)));
3618
+ const _ = t.filter((n) => !y.has(n.id) && x.has(n.id));
3619
+ _.length > 0 && (b.push(_.map((n) => n.id)), _.forEach((n) => h.set(n.id, 2))), b.length === 0 && (b.push(t.map((n) => n.id)), t.forEach((n) => h.set(n.id, 0)));
3620
+ const A = /* @__PURE__ */ new Map();
3621
+ o.forEach((n) => {
3622
+ A.set(n.source, (A.get(n.source) || 0) + n.value), A.set(n.target, (A.get(n.target) || 0) + n.value);
3623
+ });
3624
+ const O = 40, U = i - O * 2, V = s - O * 2, j = b.length > 1 ? U / (b.length - 1) : U, G = /* @__PURE__ */ new Map();
3625
+ Math.max(...Array.from(A.values())), b.forEach((n, X) => {
3626
+ const H = n.reduce((F, Y) => F + (A.get(Y) || 0), 0), W = (V - (n.length - 1) * v) / H;
3627
+ let m = O;
3628
+ n.forEach((F) => {
3629
+ const ee = (A.get(F) || 0) * W, P = O + X * j;
3630
+ G.set(F, { x: P, y: m, height: ee }), m += ee + v;
3631
+ });
3632
+ });
3633
+ const Q = [], q = /* @__PURE__ */ new Map(), J = /* @__PURE__ */ new Map();
3634
+ return o.forEach((n) => {
3635
+ const X = G.get(n.source), H = G.get(n.target);
3636
+ if (!X || !H)
3637
+ return;
3638
+ const W = A.get(n.source) || 1;
3639
+ A.get(n.target);
3640
+ const m = n.value / W * X.height, F = X.y + (q.get(n.source) || 0), Y = H.y + (J.get(n.target) || 0);
3641
+ q.set(n.source, (q.get(n.source) || 0) + m), J.set(n.target, (J.get(n.target) || 0) + m);
3642
+ const ee = X.x + c, P = H.x, te = (P - ee) * 0.5, fe = `
3643
+ M ${ee} ${F}
3644
+ C ${ee + te} ${F},
3645
+ ${P - te} ${Y},
3646
+ ${P} ${Y}
3647
+ L ${P} ${Y + m}
3648
+ C ${P - te} ${Y + m},
3649
+ ${ee + te} ${F + m},
3650
+ ${ee} ${F + m}
3651
+ Z
3652
+ `;
3653
+ Q.push({
3654
+ path: fe,
3655
+ link: n,
3656
+ sourcePos: X,
3657
+ targetPos: H
3658
+ });
3659
+ }), { nodePositions: G, linkPaths: Q, nodeMap: g, nodeValues: A };
3660
+ }, [t, o, i, s, c, v]), S = ae(
3661
+ (g, x) => {
3662
+ const y = d.current?.getBoundingClientRect();
3663
+ y && I && l({
3664
+ x: x.clientX - y.left,
3665
+ y: x.clientY - y.top,
3666
+ content: g
3667
+ });
3668
+ },
3669
+ [I]
3670
+ );
3671
+ return /* @__PURE__ */ $("div", { className: `nice-sankey-chart ${N || ""}`, style: { width: i, ...z }, ...C, children: [
3672
+ f && /* @__PURE__ */ e("div", { className: "nice-sankey-title", children: f }),
3673
+ /* @__PURE__ */ $("svg", { ref: d, width: i, height: s, className: "nice-sankey-svg", children: [
3674
+ /* @__PURE__ */ e("defs", { children: u.linkPaths.map((g, x) => /* @__PURE__ */ $("linearGradient", { id: `sankey-gradient-${x}`, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [
3675
+ /* @__PURE__ */ e(
3676
+ "stop",
3677
+ {
3678
+ offset: "0%",
3679
+ stopColor: u.nodeMap.get(g.link.source)?.color || "var(--color-primary, #3b82f6)"
3680
+ }
3681
+ ),
3682
+ /* @__PURE__ */ e(
3683
+ "stop",
3684
+ {
3685
+ offset: "100%",
3686
+ stopColor: u.nodeMap.get(g.link.target)?.color || "var(--color-error, #ef4444)"
3687
+ }
3688
+ )
3689
+ ] }, x)) }),
3690
+ /* @__PURE__ */ e("g", { className: "nice-sankey-links", children: u.linkPaths.map((g, x) => /* @__PURE__ */ e(
3691
+ "path",
3692
+ {
3693
+ d: g.path,
3694
+ fill: g.link.color || `url(#sankey-gradient-${x})`,
3695
+ fillOpacity: 0.4,
3696
+ className: "nice-sankey-link",
3697
+ onClick: () => w?.(g.link),
3698
+ onMouseEnter: (y) => S(
3699
+ `${u.nodeMap.get(g.link.source)?.name} → ${u.nodeMap.get(g.link.target)?.name}: ${g.link.value.toLocaleString()}`,
3700
+ y
3701
+ ),
3702
+ onMouseLeave: () => l(null)
3703
+ },
3704
+ x
3705
+ )) }),
3706
+ /* @__PURE__ */ e("g", { className: "nice-sankey-nodes", children: Array.from(u.nodePositions.entries()).map(([g, x]) => {
3707
+ const y = u.nodeMap.get(g);
3708
+ return y ? /* @__PURE__ */ $("g", { children: [
3709
+ /* @__PURE__ */ e(
3710
+ "rect",
3711
+ {
3712
+ x: x.x,
3713
+ y: x.y,
3714
+ width: c,
3715
+ height: x.height,
3716
+ fill: y.color || "var(--color-primary, #3b82f6)",
3717
+ rx: 2,
3718
+ className: "nice-sankey-node",
3719
+ onClick: () => T?.(y),
3720
+ onMouseEnter: (b) => S(
3721
+ `${y.label ?? y.name ?? y.id}: ${u.nodeValues.get(g)?.toLocaleString() || 0}`,
3722
+ b
3723
+ ),
3724
+ onMouseLeave: () => l(null)
3725
+ }
3726
+ ),
3727
+ /* @__PURE__ */ $(
3728
+ "text",
3729
+ {
3730
+ x: x.x + c + 6,
3731
+ y: x.y + x.height / 2,
3732
+ dominantBaseline: "middle",
3733
+ fontSize: "12",
3734
+ fill: "var(--text-primary, #0f172a)",
3735
+ children: [
3736
+ y.label ?? y.name ?? y.id,
3737
+ p && ` (${u.nodeValues.get(g)?.toLocaleString() || 0})`
3738
+ ]
3739
+ }
3740
+ )
3741
+ ] }, g) : null;
3742
+ }) })
3743
+ ] }),
3744
+ k && /* @__PURE__ */ e("div", { className: "nice-sankey-tooltip", style: { left: k.x + 10, top: k.y - 30 }, children: k.content }),
3745
+ /* @__PURE__ */ e("style", { children: `
3746
+ .nice-sankey-chart {
3747
+ font-family: system-ui, -apple-system, sans-serif;
3748
+ background: white;
3749
+ border-radius: var(--nice-radius-lg, 8px);
3750
+ position: relative;
3751
+ }
3752
+
3753
+ .nice-sankey-title {
3754
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
3755
+ font-size: 16px;
3756
+ font-weight: 600;
3757
+ color: var(--text-primary, #0f172a);
3758
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
3759
+ }
3760
+
3761
+ .nice-sankey-link {
3762
+ cursor: pointer;
3763
+ transition: fill-opacity 0.2s;
3764
+ }
3765
+
3766
+ .nice-sankey-link:hover {
3767
+ fill-opacity: 0.7;
3768
+ }
3769
+
3770
+ .nice-sankey-node {
3771
+ cursor: pointer;
3772
+ transition: opacity 0.2s;
3773
+ }
3774
+
3775
+ .nice-sankey-node:hover {
3776
+ opacity: 0.8;
3777
+ }
3778
+
3779
+ .nice-sankey-tooltip {
3780
+ position: absolute;
3781
+ background: var(--text-primary, #0f172a);
3782
+ color: white;
3783
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
3784
+ border-radius: var(--nice-radius-sm, 4px);
3785
+ font-size: 12px;
3786
+ pointer-events: none;
3787
+ z-index: 10;
3788
+ white-space: nowrap;
3789
+ }
3790
+ ` })
3791
+ ] });
3792
+ }, rt = Ne(
3793
+ (t, o) => {
3794
+ const {
3795
+ initialData: i,
3796
+ data: s,
3797
+ maxPoints: c = 60,
3798
+ updateInterval: v = 1e3,
3799
+ fetchData: p,
3800
+ width: I = 600,
3801
+ height: T = 200,
3802
+ chartType: w = "line",
3803
+ color: f = "var(--color-primary, #3b82f6)",
3804
+ showGrid: N = !0,
3805
+ showTimeAxis: z = !0,
3806
+ showCurrentValue: C = !0,
3807
+ title: k,
3808
+ valueFormatter: l = (L) => L.toFixed(2),
3809
+ timeFormatter: d = (L) => new Date(L).toLocaleTimeString(),
3810
+ onDataUpdate: u,
3811
+ paused: S,
3812
+ className: g,
3813
+ style: x,
3814
+ ...y
3815
+ } = t, [b, h] = oe(i ?? s ?? []), [D, a] = oe(S || !1), _ = be();
3816
+ Ce(() => {
3817
+ S !== void 0 && a(S);
3818
+ }, [S]), Ce(() => {
3819
+ if (D || !p)
3820
+ return;
3821
+ const L = async () => {
3822
+ try {
3823
+ const Z = await p();
3824
+ h((ne) => {
3825
+ const ue = [...ne, Z].slice(-c);
3826
+ return u?.(ue), ue;
3827
+ });
3828
+ } catch (Z) {
3829
+ console.error("Failed to fetch realtime data:", Z);
3830
+ }
3831
+ };
3832
+ return _.current = setInterval(L, v), () => {
3833
+ _.current && clearInterval(_.current);
3834
+ };
3835
+ }, [D, p, v, c, u]);
3836
+ const A = ae(
3837
+ (L) => {
3838
+ h((Z) => {
3839
+ const ne = [...Z, L].slice(-c);
3840
+ return u?.(ne), ne;
3841
+ });
3842
+ },
3843
+ [c, u]
3844
+ ), O = ae(() => {
3845
+ h([]), u?.([]);
3846
+ }, [u]), U = ae(() => a(!0), []), V = ae(() => a(!1), []);
3847
+ Ae(
3848
+ o,
3849
+ () => ({
3850
+ addDataPoint: A,
3851
+ clearData: O,
3852
+ pause: U,
3853
+ resume: V,
3854
+ getData: () => b
3855
+ }),
3856
+ [A, O, b]
3857
+ );
3858
+ const j = { top: 20, right: 60, bottom: z ? 40 : 20, left: 50 }, G = I - j.left - j.right, Q = T - j.top - j.bottom, q = b.map((L) => L.value), J = q.length ? Math.min(...q) : 0, n = q.length ? Math.max(...q) : 100, H = (n - J || 1) * 0.1, W = J - H, F = n + H - W, Y = (L) => {
3859
+ const Z = p ? c - 1 : Math.max(1, b.length - 1);
3860
+ return j.left + L / Z * G;
3861
+ }, ee = (L) => j.top + Q - (L - W) / F * Q, P = b.map((L, Z) => `${Y(Z)},${ee(L.value)}`).join(" "), te = b.length > 0 ? `M ${Y(0)},${j.top + Q} L ${P} L ${Y(b.length - 1)},${j.top + Q} Z` : "", fe = b.length > 0 ? b[b.length - 1].value : null;
3862
+ return /* @__PURE__ */ $(
3863
+ "div",
3864
+ {
3865
+ className: `nice-realtime-chart ${g || ""}`,
3866
+ style: { width: I, ...x },
3867
+ ...y,
3868
+ children: [
3869
+ /* @__PURE__ */ $("div", { className: "nice-realtime-header", children: [
3870
+ /* @__PURE__ */ e("span", { className: "nice-realtime-title", children: k }),
3871
+ /* @__PURE__ */ $("div", { className: "nice-realtime-controls", children: [
3872
+ /* @__PURE__ */ $("span", { className: `nice-realtime-status ${D ? "paused" : "live"}`, children: [
3873
+ /* @__PURE__ */ e("span", { className: "nice-realtime-status-dot" }),
3874
+ /* @__PURE__ */ e("span", { children: D ? "Wstrzymano" : "Na żywo" })
3875
+ ] }),
3876
+ /* @__PURE__ */ e(
3877
+ "button",
3878
+ {
3879
+ className: `nice-realtime-btn ${D ? "paused" : ""}`,
3880
+ onClick: () => a(!D),
3881
+ children: D ? "▶️" : "⏸️"
3882
+ }
3883
+ ),
3884
+ C && fe !== null && /* @__PURE__ */ e("span", { className: "nice-realtime-value", children: l(fe) })
3885
+ ] })
3886
+ ] }),
3887
+ /* @__PURE__ */ $("svg", { width: I, height: T, className: "nice-realtime-svg", children: [
3888
+ N && /* @__PURE__ */ e("g", { className: "nice-realtime-grid", children: [0, 0.25, 0.5, 0.75, 1].map((L, Z) => {
3889
+ const ne = j.top + Q * (1 - L), ue = W + F * L;
3890
+ return /* @__PURE__ */ $("g", { children: [
3891
+ /* @__PURE__ */ e(
3892
+ "line",
3893
+ {
3894
+ x1: j.left,
3895
+ y1: ne,
3896
+ x2: I - j.right,
3897
+ y2: ne,
3898
+ stroke: "var(--border-color, #e5e7eb)",
3899
+ strokeDasharray: L === 0 ? void 0 : "3"
3900
+ }
3901
+ ),
3902
+ /* @__PURE__ */ e(
3903
+ "text",
3904
+ {
3905
+ x: j.left - 8,
3906
+ y: ne,
3907
+ textAnchor: "end",
3908
+ dominantBaseline: "middle",
3909
+ fontSize: "10",
3910
+ fill: "var(--text-secondary, #6b7280)",
3911
+ children: Math.round(ue).toLocaleString()
3912
+ }
3913
+ )
3914
+ ] }, Z);
3915
+ }) }),
3916
+ w === "area" && b.length > 0 && /* @__PURE__ */ e("path", { d: te, fill: f, fillOpacity: 0.2 }),
3917
+ b.length > 1 && /* @__PURE__ */ e(
3918
+ "polyline",
3919
+ {
3920
+ points: P,
3921
+ fill: "none",
3922
+ stroke: f,
3923
+ strokeWidth: 2,
3924
+ strokeLinecap: "round",
3925
+ strokeLinejoin: "round"
3926
+ }
3927
+ ),
3928
+ b.length > 0 && /* @__PURE__ */ e(
3929
+ "circle",
3930
+ {
3931
+ cx: Y(b.length - 1),
3932
+ cy: ee(b[b.length - 1].value),
3933
+ r: 3,
3934
+ fill: f,
3935
+ className: "nice-realtime-point"
3936
+ }
3937
+ ),
3938
+ z && b.length > 0 && /* @__PURE__ */ e("g", { className: "nice-realtime-time-axis", children: Array.from(
3939
+ new Set([0, Math.floor(b.length / 2), b.length - 1].filter((L) => b[L]))
3940
+ ).map((L) => /* @__PURE__ */ e(
3941
+ "text",
3942
+ {
3943
+ x: Y(L),
3944
+ y: T - 8,
3945
+ textAnchor: "middle",
3946
+ fontSize: "10",
3947
+ fill: "var(--text-secondary, #6b7280)",
3948
+ children: d(b[L].timestamp)
3949
+ },
3950
+ `tx-${L}`
3951
+ )) })
3952
+ ] }),
3953
+ /* @__PURE__ */ e("style", { children: `
3954
+ .nice-realtime-chart {
3955
+ font-family: inherit;
3956
+ color: var(--text-primary, #111827);
3957
+ background: var(--bg-elevated, #ffffff);
3958
+ border-radius: 8px;
3959
+ position: relative;
3960
+ }
3961
+
3962
+ .nice-realtime-header {
3963
+ display: flex;
3964
+ justify-content: space-between;
3965
+ align-items: center;
3966
+ padding: 12px 16px;
3967
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
3968
+ }
3969
+
3970
+ .nice-realtime-title {
3971
+ font-size: 14px;
3972
+ font-weight: 600;
3973
+ color: var(--text-primary, #111827);
3974
+ }
3975
+
3976
+ .nice-realtime-controls {
3977
+ display: flex;
3978
+ align-items: center;
3979
+ gap: 12px;
3980
+ }
3981
+
3982
+ .nice-realtime-btn {
3983
+ background: none;
3984
+ border: none;
3985
+ cursor: pointer;
3986
+ font-size: 16px;
3987
+ padding: 4px;
3988
+ font-family: inherit;
3989
+ color: inherit;
3990
+ }
3991
+
3992
+ .nice-realtime-value {
3993
+ font-size: 18px;
3994
+ font-weight: 600;
3995
+ color: ${f};
3996
+ font-variant-numeric: tabular-nums;
3997
+ }
3998
+
3999
+ /* Static current-value dot — no pulsing animation (was distracting) */
4000
+
4001
+ .nice-realtime-status {
4002
+ display: inline-flex;
4003
+ align-items: center;
4004
+ gap: 6px;
4005
+ font-size: 11px;
4006
+ font-family: inherit;
4007
+ color: var(--text-secondary, #6b7280);
4008
+ background: var(--bg-secondary, #f3f4f6);
4009
+ padding: 2px 10px;
4010
+ border-radius: 999px;
4011
+ }
4012
+
4013
+ .nice-realtime-status-dot {
4014
+ width: 8px;
4015
+ height: 8px;
4016
+ border-radius: 50%;
4017
+ background: var(--color-success, #22c55e);
4018
+ }
4019
+
4020
+ .nice-realtime-status.paused .nice-realtime-status-dot {
4021
+ background: var(--color-warning, #f59e0b);
4022
+ }
4023
+
4024
+ .nice-realtime-status.live .nice-realtime-status-dot {
4025
+ animation: live-pulse 2s ease-in-out infinite;
4026
+ }
4027
+
4028
+ @keyframes live-pulse {
4029
+ 0%, 100% { opacity: 1; }
4030
+ 50% { opacity: 0.4; }
4031
+ }
4032
+ ` })
4033
+ ]
4034
+ }
4035
+ );
4036
+ }
4037
+ );
4038
+ rt.displayName = "NiceRealtimeChart";
4039
+ const Lt = ({
4040
+ data: t,
4041
+ width: o = 600,
4042
+ height: i = 400,
4043
+ showLabels: s = !0,
4044
+ showValues: c = !0,
4045
+ onNodeClick: v,
4046
+ drilldownEnabled: p = !0,
4047
+ colors: I = Ye,
4048
+ tilePadding: T = 2,
4049
+ className: w,
4050
+ style: f,
4051
+ ...N
4052
+ }) => {
4053
+ const z = pe(() => Array.isArray(t) ? {
4054
+ id: "root",
4055
+ name: "Root",
4056
+ value: t.reduce((a, _) => a + (_.value || 0), 0),
4057
+ children: t.map((a, _) => ({
4058
+ id: `${_}`,
4059
+ name: a.label ?? a.name ?? `Item ${_ + 1}`,
4060
+ value: a.value,
4061
+ color: a.color
4062
+ }))
4063
+ } : t, [t]), [C, k] = oe(z), [l, d] = oe([z.name]), [u, S] = oe(null), g = be(null), x = pe(() => {
4064
+ const _ = C.children || [];
4065
+ if (_.length === 0)
4066
+ return [];
4067
+ const A = _.reduce((J, n) => J + n.value, 0), O = _.map((J) => ({
4068
+ node: J,
4069
+ area: J.value / A * o * i
4070
+ }));
4071
+ O.sort((J, n) => n.area - J.area);
4072
+ const U = [];
4073
+ let V = 0, j = 0, G = o, Q = i, q = 0;
4074
+ for (; q < O.length; ) {
4075
+ const J = G < Q;
4076
+ let n = 0, X = [];
4077
+ const H = J ? Q : G;
4078
+ for (let F = q; F < O.length; F++) {
4079
+ const Y = [...X, O[F]], ee = Y.reduce((te, fe) => te + fe.area, 0), P = y(Y, ee, H);
4080
+ if (X.length === 0)
4081
+ X = Y, n = ee;
4082
+ else {
4083
+ const te = y(X, n, H);
4084
+ if (P <= te)
4085
+ X = Y, n = ee;
4086
+ else
4087
+ break;
4088
+ }
4089
+ }
4090
+ const W = n / H;
4091
+ let m = 0;
4092
+ X.forEach((F, Y) => {
4093
+ const ee = F.area / W;
4094
+ U.push({
4095
+ node: F.node,
4096
+ x: J ? V : V + m,
4097
+ y: J ? j + m : j,
4098
+ w: J ? W : ee,
4099
+ h: J ? ee : W,
4100
+ color: F.node.color || I[(q + Y) % I.length]
4101
+ }), m += ee;
4102
+ }), J ? (V += W, G -= W) : (j += W, Q -= W), q += X.length;
4103
+ }
4104
+ return U;
4105
+ }, [C, o, i, I]);
4106
+ function y(a, _, A) {
4107
+ const O = _ / A;
4108
+ let U = 0;
4109
+ for (const V of a) {
4110
+ const j = V.area / O, G = Math.max(O / j, j / O);
4111
+ U = Math.max(U, G);
4112
+ }
4113
+ return U;
4114
+ }
4115
+ const b = (a) => {
4116
+ v?.(a, [...l, a.name]), p && a.children && a.children.length > 0 && (k(a), d((_) => [..._, a.name]));
4117
+ }, h = () => {
4118
+ if (l.length <= 1)
4119
+ return;
4120
+ let a = z;
4121
+ const _ = l.slice(0, -1);
4122
+ for (let A = 1; A < _.length; A++) {
4123
+ const O = a.children?.find((U) => U.name === _[A]);
4124
+ O && (a = O);
4125
+ }
4126
+ k(a), d(_);
4127
+ }, D = (a, _) => {
4128
+ const A = g.current?.getBoundingClientRect();
4129
+ A && S({
4130
+ x: _.clientX - A.left,
4131
+ y: _.clientY - A.top,
4132
+ content: a
4133
+ });
4134
+ };
4135
+ return /* @__PURE__ */ $("div", { className: `nice-treemap-chart ${w || ""}`, style: { width: o, ...f }, ...N, children: [
4136
+ /* @__PURE__ */ $("div", { className: "nice-treemap-nav", children: [
4137
+ l.length > 1 && /* @__PURE__ */ e("button", { className: "nice-treemap-back", onClick: h, children: "← Wstecz" }),
4138
+ /* @__PURE__ */ e("div", { className: "nice-treemap-breadcrumbs", children: l.map((a, _) => /* @__PURE__ */ $(Fe.Fragment, { children: [
4139
+ _ > 0 && /* @__PURE__ */ e("span", { className: "nice-treemap-sep", children: "/" }),
4140
+ /* @__PURE__ */ e("span", { className: _ === l.length - 1 ? "current" : "", children: a })
4141
+ ] }, _)) })
4142
+ ] }),
4143
+ /* @__PURE__ */ e("svg", { ref: g, width: o, height: i, className: "nice-treemap-svg", children: x.map((a, _) => {
4144
+ const { node: A, x: O, y: U, w: V, h: j, color: G } = a, Q = Math.min(14, Math.max(10, Math.min(V, j) / 6)), q = V > 40 && j > 30;
4145
+ return /* @__PURE__ */ $(
4146
+ "g",
4147
+ {
4148
+ onClick: () => b(A),
4149
+ onMouseEnter: (J) => D(`${A.name}: ${A.value.toLocaleString()}`, J),
4150
+ onMouseLeave: () => S(null),
4151
+ children: [
4152
+ /* @__PURE__ */ e(
4153
+ "rect",
4154
+ {
4155
+ x: O + T / 2,
4156
+ y: U + T / 2,
4157
+ width: Math.max(0, V - T),
4158
+ height: Math.max(0, j - T),
4159
+ fill: G,
4160
+ rx: 4,
4161
+ className: "nice-treemap-tile"
4162
+ }
4163
+ ),
4164
+ s && q && /* @__PURE__ */ e(
4165
+ "text",
4166
+ {
4167
+ x: O + V / 2,
4168
+ y: U + j / 2 - (c ? 6 : 0),
4169
+ textAnchor: "middle",
4170
+ dominantBaseline: "middle",
4171
+ fontSize: Q,
4172
+ fill: "white",
4173
+ fontWeight: "500",
4174
+ style: { pointerEvents: "none" },
4175
+ children: A.name.length > V / Q + 2 ? A.name.slice(0, Math.floor(V / Q)) + "..." : A.name
4176
+ }
4177
+ ),
4178
+ c && q && /* @__PURE__ */ e(
4179
+ "text",
4180
+ {
4181
+ x: O + V / 2,
4182
+ y: U + j / 2 + 10,
4183
+ textAnchor: "middle",
4184
+ dominantBaseline: "middle",
4185
+ fontSize: Q - 2,
4186
+ fill: "var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",
4187
+ style: { pointerEvents: "none" },
4188
+ children: A.value.toLocaleString()
4189
+ }
4190
+ )
4191
+ ]
4192
+ },
4193
+ _
4194
+ );
4195
+ }) }),
4196
+ u && /* @__PURE__ */ e("div", { className: "nice-treemap-tooltip", style: { left: u.x + 10, top: u.y - 30 }, children: u.content }),
4197
+ /* @__PURE__ */ e("style", { children: `
4198
+ .nice-treemap-chart {
4199
+ font-family: system-ui, -apple-system, sans-serif;
4200
+ background: white;
4201
+ border-radius: var(--nice-radius-lg, 8px);
4202
+ position: relative;
4203
+ }
4204
+
4205
+ .nice-treemap-nav {
4206
+ display: flex;
4207
+ align-items: center;
4208
+ gap: var(--nice-space-3, 12px);
4209
+ padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
4210
+ border-bottom: 1px solid var(--border-color, #e5e7eb);
4211
+ }
4212
+
4213
+ .nice-treemap-back {
4214
+ background: var(--bg-secondary, #f8fafc);
4215
+ border: none;
4216
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
4217
+ border-radius: var(--nice-radius-md, 6px);
4218
+ cursor: pointer;
4219
+ font-size: 13px;
4220
+ }
4221
+
4222
+ .nice-treemap-back:hover {
4223
+ background: var(--border-color, #e5e7eb);
4224
+ }
4225
+
4226
+ .nice-treemap-breadcrumbs {
4227
+ display: flex;
4228
+ align-items: center;
4229
+ gap: var(--nice-space-1, 4px);
4230
+ font-size: 13px;
4231
+ color: var(--text-secondary, #475569);
4232
+ }
4233
+
4234
+ .nice-treemap-breadcrumbs .current {
4235
+ color: var(--text-primary, #0f172a);
4236
+ font-weight: 500;
4237
+ }
4238
+
4239
+ .nice-treemap-sep {
4240
+ color: var(--text-muted, #94a3b8);
4241
+ }
4242
+
4243
+ .nice-treemap-tile {
4244
+ cursor: pointer;
4245
+ transition: opacity 0.2s, transform 0.1s;
4246
+ }
4247
+
4248
+ .nice-treemap-tile:hover {
4249
+ opacity: 0.85;
4250
+ }
4251
+
4252
+ .nice-treemap-tooltip {
4253
+ position: absolute;
4254
+ background: var(--text-primary, #0f172a);
4255
+ color: white;
4256
+ padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
4257
+ border-radius: var(--nice-radius-sm, 4px);
4258
+ font-size: 12px;
4259
+ pointer-events: none;
4260
+ z-index: 10;
4261
+ white-space: nowrap;
4262
+ }
4263
+ ` })
4264
+ ] });
4265
+ }, at = Ne(
4266
+ ({
4267
+ data: t,
4268
+ renderNode: o,
4269
+ selectable: i,
4270
+ selectedKey: s,
4271
+ onSelect: c,
4272
+ direction: v = "top-down",
4273
+ collapsible: p = !0,
4274
+ className: I,
4275
+ style: T,
4276
+ id: w
4277
+ }, f) => {
4278
+ const N = ze(w), [z, C] = oe(/* @__PURE__ */ new Set()), k = ae((u) => {
4279
+ C((S) => {
4280
+ const g = new Set(S);
4281
+ return g.has(u) ? g.delete(u) : g.add(u), g;
4282
+ });
4283
+ }, []), l = ae(
4284
+ (u) => {
4285
+ i && c?.(u);
4286
+ },
4287
+ [i, c]
4288
+ ), d = ae(
4289
+ (u) => {
4290
+ const S = z.has(u.key), g = u.children && u.children.length > 0;
4291
+ return /* @__PURE__ */ $("li", { className: "nice-org-chart__item", children: [
4292
+ /* @__PURE__ */ $(
4293
+ "div",
4294
+ {
4295
+ className: `nice-org-chart__node${s === u.key ? " nice-org-chart__node--selected" : ""}`,
4296
+ onClick: () => l(u.key),
4297
+ role: i ? "button" : void 0,
4298
+ children: [
4299
+ o ? o(u) : /* @__PURE__ */ e("span", { children: u.label }),
4300
+ p && g && /* @__PURE__ */ e(
4301
+ "button",
4302
+ {
4303
+ type: "button",
4304
+ className: "nice-org-chart__toggle",
4305
+ onClick: (x) => {
4306
+ x.stopPropagation(), k(u.key);
4307
+ },
4308
+ "aria-label": S ? "Expand" : "Collapse",
4309
+ children: S ? "+" : "−"
4310
+ }
4311
+ )
4312
+ ]
4313
+ }
4314
+ ),
4315
+ g && !S && /* @__PURE__ */ e("ul", { className: "nice-org-chart__children", children: u.children.map((x) => d(x)) })
4316
+ ] }, u.key);
4317
+ },
4318
+ [z, s, o, i, p, l, k]
4319
+ );
4320
+ return /* @__PURE__ */ e(
4321
+ "div",
4322
+ {
4323
+ ref: f,
4324
+ id: N,
4325
+ className: `nice-org-chart nice-org-chart--${v} ${I || ""}`,
4326
+ style: T,
4327
+ children: /* @__PURE__ */ e("ul", { className: "nice-org-chart__root", children: d(t) })
4328
+ }
4329
+ );
4330
+ }
4331
+ );
4332
+ at.displayName = "NiceOrganizationChart";
4333
+ function ct(t, o, i) {
4334
+ const s = (C) => {
4335
+ const k = C.replace("#", "");
4336
+ return [
4337
+ parseInt(k.slice(0, 2), 16),
4338
+ parseInt(k.slice(2, 4), 16),
4339
+ parseInt(k.slice(4, 6), 16)
4340
+ ];
4341
+ }, [c, v, p] = s(t), [I, T, w] = s(o), f = Math.round(c + (I - c) * i), N = Math.round(v + (T - v) * i), z = Math.round(p + (w - p) * i);
4342
+ return `rgb(${f},${N},${z})`;
4343
+ }
4344
+ const ot = Ne(
4345
+ ({
4346
+ data: t,
4347
+ xLabels: o,
4348
+ yLabels: i,
4349
+ colors: s = ["var(--nice-primary-bg, #e0f2fe)", "var(--color-primary-active, #1d4ed8)"],
4350
+ onCellClick: c,
4351
+ cellSize: v = 40,
4352
+ showValues: p = !0,
4353
+ className: I,
4354
+ style: T,
4355
+ id: w
4356
+ }, f) => {
4357
+ const N = ze(w), { minVal: z, maxVal: C } = pe(() => {
4358
+ let l = 1 / 0, d = -1 / 0;
4359
+ for (const u of t)
4360
+ for (const S of u)
4361
+ S < l && (l = S), S > d && (d = S);
4362
+ return { minVal: l, maxVal: d };
4363
+ }, [t]), k = ae(
4364
+ (l) => C === z ? 0.5 : (l - z) / (C - z),
4365
+ [z, C]
4366
+ );
4367
+ return /* @__PURE__ */ e("div", { ref: f, id: N, className: `nice-heatmap ${I || ""}`, style: T, children: /* @__PURE__ */ $("table", { className: "nice-heatmap__table", children: [
4368
+ o && /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ $("tr", { children: [
4369
+ i && /* @__PURE__ */ e("th", {}),
4370
+ o.map((l, d) => /* @__PURE__ */ e("th", { className: "nice-heatmap__header", children: l }, d))
4371
+ ] }) }),
4372
+ /* @__PURE__ */ e("tbody", { children: t.map((l, d) => /* @__PURE__ */ $("tr", { children: [
4373
+ i && /* @__PURE__ */ e("th", { className: "nice-heatmap__row-label", children: i[d] }),
4374
+ l.map((u, S) => /* @__PURE__ */ e(
4375
+ "td",
4376
+ {
4377
+ className: "nice-heatmap__cell",
4378
+ style: {
4379
+ background: ct(s[0], s[1], k(u)),
4380
+ width: v,
4381
+ height: v,
4382
+ textAlign: "center",
4383
+ color: k(u) > 0.6 ? "var(--bg-primary, #fff)" : "var(--bg-tertiary, #333)",
4384
+ cursor: c ? "pointer" : void 0
4385
+ },
4386
+ onClick: () => c?.(d, S, u),
4387
+ title: String(u),
4388
+ children: p ? u : ""
4389
+ },
4390
+ S
4391
+ ))
4392
+ ] }, d)) })
4393
+ ] }) });
4394
+ }
4395
+ );
4396
+ ot.displayName = "NiceHeatMap";
4397
+ function it(t, o) {
4398
+ const i = t.reduce((w, f) => w + f.value, 0);
4399
+ if (i === 0 || t.length === 0)
4400
+ return [];
4401
+ const s = [];
4402
+ let { x: c, y: v, w: p, h: I } = o;
4403
+ const T = [...t].sort((w, f) => f.value - w.value);
4404
+ for (const w of T) {
4405
+ const f = w.value / i;
4406
+ if (p >= I) {
4407
+ const N = p * f;
4408
+ s.push({ x: c, y: v, w: N, h: I, node: w }), c += N, p -= N;
4409
+ } else {
4410
+ const N = I * f;
4411
+ s.push({ x: c, y: v, w: p, h: N, node: w }), v += N, I -= N;
4412
+ }
4413
+ }
4414
+ return s;
4415
+ }
4416
+ const st = [
4417
+ "var(--color-primary, #3b82f6)",
4418
+ "var(--color-success, #10b981)",
4419
+ "var(--color-warning, #f59e0b)",
4420
+ "var(--color-error, #ef4444)",
4421
+ "var(--color-accent, #8b5cf6)",
4422
+ "var(--color-info, #06b6d4)",
4423
+ "var(--color-accent-pink, #ec4899)",
4424
+ "var(--nice-success, #84cc16)"
4425
+ ], je = Ne(
4426
+ ({ data: t, width: o = 600, height: i = 400, onNodeClick: s, colors: c = st, className: v, style: p, id: I }, T) => {
4427
+ const w = ze(I), f = pe(() => {
4428
+ const N = t.children ?? [t];
4429
+ return it(N, { x: 0, y: 0, w: o, h: i });
4430
+ }, [t, o, i]);
4431
+ return /* @__PURE__ */ e("div", { ref: T, id: w, className: `nice-treemap ${v || ""}`, style: p, children: /* @__PURE__ */ e("svg", { width: o, height: i, className: "nice-treemap__svg", children: f.map((N, z) => /* @__PURE__ */ $(
4432
+ "g",
4433
+ {
4434
+ onClick: () => s?.(N.node),
4435
+ style: { cursor: s ? "pointer" : void 0 },
4436
+ children: [
4437
+ /* @__PURE__ */ e(
4438
+ "rect",
4439
+ {
4440
+ x: N.x,
4441
+ y: N.y,
4442
+ width: Math.max(N.w - 1, 0),
4443
+ height: Math.max(N.h - 1, 0),
4444
+ fill: N.node.color ?? c[z % c.length],
4445
+ rx: 2
4446
+ }
4447
+ ),
4448
+ N.w > 40 && N.h > 20 && /* @__PURE__ */ e(
4449
+ "text",
4450
+ {
4451
+ x: N.x + N.w / 2,
4452
+ y: N.y + N.h / 2,
4453
+ textAnchor: "middle",
4454
+ dominantBaseline: "central",
4455
+ fill: "var(--nice-bg, #fff)",
4456
+ fontSize: Math.min(12, N.w / 6),
4457
+ className: "nice-treemap__label",
4458
+ children: N.node.label
4459
+ }
4460
+ )
4461
+ ]
4462
+ },
4463
+ N.node.key
4464
+ )) }) });
4465
+ }
4466
+ );
4467
+ je.displayName = "NiceTreeMap";
4468
+ const Dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4469
+ __proto__: null,
4470
+ NiceTreeMap: je
4471
+ }, Symbol.toStringTag, { value: "Module" })), lt = Ne(
4472
+ ({
4473
+ data: t,
4474
+ type: o = "candlestick",
4475
+ showVolume: i = !0,
4476
+ width: s = 800,
4477
+ height: c = 400,
4478
+ bullColor: v = "var(--color-success, #22c55e)",
4479
+ bearColor: p = "var(--color-error, #ef4444)",
4480
+ className: I,
4481
+ style: T,
4482
+ id: w
4483
+ }, f) => {
4484
+ const N = ze(w), z = { top: 20, right: 20, bottom: i ? 80 : 30, left: 60 }, C = s - z.left - z.right, k = i ? 50 : 0, l = c - z.top - z.bottom - k, { minP: d, maxP: u, maxVol: S } = pe(() => {
4485
+ let h = 1 / 0, D = -1 / 0, a = 0;
4486
+ for (const _ of t)
4487
+ _.low < h && (h = _.low), _.high > D && (D = _.high), _.volume && _.volume > a && (a = _.volume);
4488
+ return { minP: h, maxP: D, maxVol: a };
4489
+ }, [t]), g = Math.max(1, C / t.length * 0.7), x = (h) => z.left + (h + 0.5) * (C / t.length), y = (h) => z.top + l - (h - d) / (u - d || 1) * l, b = (h) => c - z.bottom - k + k * (1 - h / (S || 1));
4490
+ return /* @__PURE__ */ e("div", { ref: f, id: N, className: `nice-stock-chart ${I || ""}`, style: T, children: /* @__PURE__ */ $("svg", { width: s, height: c, className: "nice-stock-chart__svg", children: [
4491
+ [0, 0.25, 0.5, 0.75, 1].map((h) => {
4492
+ const D = d + h * (u - d);
4493
+ return /* @__PURE__ */ $("g", { children: [
4494
+ /* @__PURE__ */ e(
4495
+ "line",
4496
+ {
4497
+ x1: z.left,
4498
+ x2: s - z.right,
4499
+ y1: y(D),
4500
+ y2: y(D),
4501
+ stroke: "var(--nice-border, #e5e7eb)",
4502
+ strokeDasharray: "2,2"
4503
+ }
4504
+ ),
4505
+ /* @__PURE__ */ e(
4506
+ "text",
4507
+ {
4508
+ x: z.left - 4,
4509
+ y: y(D) + 4,
4510
+ textAnchor: "end",
4511
+ fontSize: 10,
4512
+ fill: "var(--nice-text-secondary, #888)",
4513
+ children: D.toFixed(2)
4514
+ }
4515
+ )
4516
+ ] }, h);
4517
+ }),
4518
+ o === "line" ? /* @__PURE__ */ e(
4519
+ "polyline",
4520
+ {
4521
+ points: t.map((h, D) => `${x(D)},${y(h.close)}`).join(" "),
4522
+ fill: "none",
4523
+ stroke: v,
4524
+ strokeWidth: 1.5
4525
+ }
4526
+ ) : t.map((h, D) => {
4527
+ const a = h.close >= h.open, _ = a ? v : p, A = x(D);
4528
+ if (o === "ohlc")
4529
+ return /* @__PURE__ */ $("g", { children: [
4530
+ /* @__PURE__ */ e(
4531
+ "line",
4532
+ {
4533
+ x1: A,
4534
+ x2: A,
4535
+ y1: y(h.high),
4536
+ y2: y(h.low),
4537
+ stroke: _,
4538
+ strokeWidth: 1
4539
+ }
4540
+ ),
4541
+ /* @__PURE__ */ e(
4542
+ "line",
4543
+ {
4544
+ x1: A - g / 2,
4545
+ x2: A,
4546
+ y1: y(h.open),
4547
+ y2: y(h.open),
4548
+ stroke: _,
4549
+ strokeWidth: 1.5
4550
+ }
4551
+ ),
4552
+ /* @__PURE__ */ e(
4553
+ "line",
4554
+ {
4555
+ x1: A,
4556
+ x2: A + g / 2,
4557
+ y1: y(h.close),
4558
+ y2: y(h.close),
4559
+ stroke: _,
4560
+ strokeWidth: 1.5
4561
+ }
4562
+ )
4563
+ ] }, D);
4564
+ const O = y(Math.max(h.open, h.close)), U = y(Math.min(h.open, h.close));
4565
+ return /* @__PURE__ */ $("g", { children: [
4566
+ /* @__PURE__ */ e(
4567
+ "line",
4568
+ {
4569
+ x1: A,
4570
+ x2: A,
4571
+ y1: y(h.high),
4572
+ y2: y(h.low),
4573
+ stroke: _,
4574
+ strokeWidth: 1
4575
+ }
4576
+ ),
4577
+ /* @__PURE__ */ e(
4578
+ "rect",
4579
+ {
4580
+ x: A - g / 2,
4581
+ y: O,
4582
+ width: g,
4583
+ height: Math.max(U - O, 1),
4584
+ fill: a ? "transparent" : _,
4585
+ stroke: _,
4586
+ strokeWidth: 1
4587
+ }
4588
+ )
4589
+ ] }, D);
4590
+ }),
4591
+ i && t.map((h, D) => {
4592
+ if (!h.volume)
4593
+ return null;
4594
+ const a = h.close >= h.open;
4595
+ return /* @__PURE__ */ e(
4596
+ "rect",
4597
+ {
4598
+ x: x(D) - g / 2,
4599
+ y: b(h.volume),
4600
+ width: g,
4601
+ height: c - z.bottom - b(h.volume),
4602
+ fill: a ? v : p,
4603
+ opacity: 0.3
4604
+ },
4605
+ `v${D}`
4606
+ );
4607
+ }),
4608
+ t.map((h, D) => D % Math.max(1, Math.floor(t.length / 8)) !== 0 ? null : /* @__PURE__ */ e(
4609
+ "text",
4610
+ {
4611
+ x: x(D),
4612
+ y: c - z.bottom + k + 14,
4613
+ textAnchor: "middle",
4614
+ fontSize: 9,
4615
+ fill: "var(--nice-text-secondary, #888)",
4616
+ children: h.date
4617
+ },
4618
+ `l${D}`
4619
+ ))
4620
+ ] }) });
4621
+ }
4622
+ );
4623
+ lt.displayName = "NiceStockChart";
4624
+ export {
4625
+ mt as A,
4626
+ kt as B,
4627
+ ve as C,
4628
+ Ct as D,
4629
+ Dt as E,
4630
+ et as N,
4631
+ St as a,
4632
+ at as b,
4633
+ lt as c,
4634
+ je as d,
4635
+ ot as e,
4636
+ Qe as f,
4637
+ Nt as g,
4638
+ Mt as h,
4639
+ $t as i,
4640
+ wt as j,
4641
+ _t as k,
4642
+ bt as l,
4643
+ vt as m,
4644
+ yt as n,
4645
+ Re as o,
4646
+ pt as p,
4647
+ nt as q,
4648
+ At as r,
4649
+ Je as s,
4650
+ It as t,
4651
+ rt as u,
4652
+ zt as v,
4653
+ Lt as w,
4654
+ xt as x,
4655
+ ft as y,
4656
+ gt as z
4657
+ };