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