@nice2dev/ui-forms 1.0.11 → 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-jMNfPqOx-B06fDseE.cjs +419 -0
- package/dist/NicePinCodeInput-jMNfPqOx-DNGx8-XN.js +10660 -0
- package/dist/NiceSavedQueryPanel-BkYRk5cX-BuLBRLRh.js +6602 -0
- package/dist/NiceSavedQueryPanel-BkYRk5cX-DS9qBIkd.cjs +596 -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-P3TTpN4Q.cjs +404 -0
- package/dist/index-SnTWfHQ_.js +21479 -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 y, Fragment as Oe } from "react/jsx-runtime";
|
|
2
|
+
import Ee, { useRef as Ne, useState as he, useMemo as ue, useCallback as oe, forwardRef as _e, useEffect as Ae, useImperativeHandle as Le } from "react";
|
|
3
|
+
import { u as Xe, x as Ue, I as Ze, U as Be } from "./index-SnTWfHQ_.js";
|
|
4
|
+
const ke = [
|
|
5
|
+
"var(--color-primary, #3b82f6)",
|
|
6
|
+
"var(--color-error, #ef4444)",
|
|
7
|
+
"var(--color-success, #22c55e)",
|
|
8
|
+
"var(--color-warning, #f59e0b)",
|
|
9
|
+
"var(--color-accent, #8b5cf6)",
|
|
10
|
+
"var(--color-accent-pink, #ec4899)",
|
|
11
|
+
"var(--color-info, #06b6d4)",
|
|
12
|
+
"var(--nice-success, #84cc16)"
|
|
13
|
+
], je = ({
|
|
14
|
+
series: t,
|
|
15
|
+
categories: u,
|
|
16
|
+
width: o = 600,
|
|
17
|
+
height: m = 400,
|
|
18
|
+
title: n,
|
|
19
|
+
showLegend: g = !0,
|
|
20
|
+
showGrid: w = !0,
|
|
21
|
+
axisLabels: A = !0,
|
|
22
|
+
yAxisLabel: L,
|
|
23
|
+
xAxisLabel: c,
|
|
24
|
+
stacked: f,
|
|
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), [v, b] = he(/* @__PURE__ */ new Set()), [l, D] = he(null), [r, j] = he(null), [V, Z] = he(!1), q = Ne(null), G = ue(
|
|
37
|
+
() => t.filter((S) => !v.has(S.name)),
|
|
38
|
+
[t, v]
|
|
39
|
+
), re = oe(
|
|
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: c ? 60 : 40,
|
|
51
|
+
left: L ? 60 : 50
|
|
52
|
+
}, te = o - J.left - J.right, T = m - J.top - J.bottom, Y = (($e = G[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) ?? Y, C = de - se, I = ue(
|
|
53
|
+
() => G.map((S) => ({ ...S, data: S.data.slice(se, de) })),
|
|
54
|
+
[G, se, de]
|
|
55
|
+
), O = ue(
|
|
56
|
+
() => u == null ? void 0 : u.slice(se, de),
|
|
57
|
+
[u, se, de]
|
|
58
|
+
), { minY: H, maxY: K, yTicks: F } = ue(() => {
|
|
59
|
+
let S;
|
|
60
|
+
if (f) {
|
|
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, f]), R = (S) => T - (S - H) / (K - H || 1) * T, U = (S) => (S + 0.5) / C * te, Q = C > 0 ? te / C / (f ? 1.5 : Math.max(G.length, 1) * 1.5) : 20, B = oe(
|
|
72
|
+
(S) => {
|
|
73
|
+
if (!p)
|
|
74
|
+
return;
|
|
75
|
+
S.preventDefault();
|
|
76
|
+
const ae = r ?? { start: 0, end: Y }, 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(Y, Math.round(ee * z))), h = Math.max(0, Math.round(a - P / 2)), W = Math.min(Y, h + P);
|
|
77
|
+
j({ start: h, end: W });
|
|
78
|
+
},
|
|
79
|
+
[p, r, Y]
|
|
80
|
+
), X = oe(
|
|
81
|
+
(S) => {
|
|
82
|
+
p && (Z(!0), q.current = { x: S.clientX, range: r ?? { start: 0, end: Y } });
|
|
83
|
+
},
|
|
84
|
+
[p, r, Y]
|
|
85
|
+
), ie = oe(
|
|
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 }), V && 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 > Y && (E = Y - W), j({ start: E, end: E + W });
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[V, p, te, C, Y, J.left, J.top]
|
|
96
|
+
), ge = oe(() => {
|
|
97
|
+
Z(!1), q.current = null;
|
|
98
|
+
}, []), fe = oe(() => {
|
|
99
|
+
D(null), Z(!1), q.current = null;
|
|
100
|
+
}, []), xe = oe(() => {
|
|
101
|
+
const S = M.current;
|
|
102
|
+
if (!S)
|
|
103
|
+
return;
|
|
104
|
+
const ae = new XMLSerializer().serializeToString(S), ee = document.createElement("canvas");
|
|
105
|
+
ee.width = o, ee.height = m + (g ? 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
|
+
}, [o, m, g]), ye = m + (g ? 30 : 0), Me = I.length > 0 && I.every((S) => S.type === "radar"), we = ue(() => {
|
|
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 = o / 2, ae = (m - J.top - J.bottom) / 2 + J.top, ee = Math.min(te, m - J.top - J.bottom) / 2 - 10, a = (O == null ? void 0 : O.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__ */ y(
|
|
127
|
+
"svg",
|
|
128
|
+
{
|
|
129
|
+
ref: M,
|
|
130
|
+
viewBox: `0 0 ${o} ${ye}`,
|
|
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: o / 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 ce = 0; ce < a; ce++)
|
|
141
|
+
le.push(`${S + Math.cos(z(ce)) * ne},${ae + Math.sin(z(ce)) * 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 && (O == null ? void 0 : O.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((ce, be) => P(be, ce).join(",")).join(" ");
|
|
173
|
+
return /* @__PURE__ */ y(
|
|
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((ce, be) => {
|
|
189
|
+
const [Ie, ze] = P(be, ce);
|
|
190
|
+
return /* @__PURE__ */ e("circle", { cx: Ie, cy: ze, r: 3, fill: ne, children: /* @__PURE__ */ e("title", { children: `${W.name}: ${ce}` }) }, be);
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
},
|
|
194
|
+
W.name
|
|
195
|
+
);
|
|
196
|
+
}),
|
|
197
|
+
g && /* @__PURE__ */ e("g", { transform: `translate(${J.left}, ${m})`, children: t.map((W, E) => {
|
|
198
|
+
const ne = E * 120, le = v.has(W.name);
|
|
199
|
+
return /* @__PURE__ */ y(
|
|
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__ */ y("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__ */ y(
|
|
238
|
+
"svg",
|
|
239
|
+
{
|
|
240
|
+
ref: M,
|
|
241
|
+
viewBox: `0 0 ${o} ${ye}`,
|
|
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: X,
|
|
249
|
+
onMouseMove: ie,
|
|
250
|
+
onMouseUp: ge,
|
|
251
|
+
onMouseLeave: fe,
|
|
252
|
+
children: [
|
|
253
|
+
/* @__PURE__ */ y("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 && F.map((S) => /* @__PURE__ */ e(
|
|
256
|
+
"line",
|
|
257
|
+
{
|
|
258
|
+
x1: 0,
|
|
259
|
+
y1: R(S),
|
|
260
|
+
x2: te,
|
|
261
|
+
y2: R(S),
|
|
262
|
+
className: "nice-chart__grid-line"
|
|
263
|
+
},
|
|
264
|
+
`grid-${S}`
|
|
265
|
+
)),
|
|
266
|
+
A && F.map((S) => /* @__PURE__ */ e(
|
|
267
|
+
"text",
|
|
268
|
+
{
|
|
269
|
+
x: -8,
|
|
270
|
+
y: R(S) + 4,
|
|
271
|
+
textAnchor: "end",
|
|
272
|
+
className: "nice-chart__axis-label",
|
|
273
|
+
children: S
|
|
274
|
+
},
|
|
275
|
+
`ylabel-${S}`
|
|
276
|
+
)),
|
|
277
|
+
A && O && O.map((S, ae) => /* @__PURE__ */ e(
|
|
278
|
+
"text",
|
|
279
|
+
{
|
|
280
|
+
x: U(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
|
+
c && /* @__PURE__ */ e("text", { x: te / 2, y: T + 45, textAnchor: "middle", className: "nice-chart__axis-title", children: c }),
|
|
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 = R(S.value);
|
|
305
|
+
return /* @__PURE__ */ y("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: U(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__ */ y(Oe, { children: [
|
|
344
|
+
/* @__PURE__ */ e(
|
|
345
|
+
"line",
|
|
346
|
+
{
|
|
347
|
+
x1: l.x,
|
|
348
|
+
y1: 0,
|
|
349
|
+
x2: l.x,
|
|
350
|
+
y2: T,
|
|
351
|
+
stroke: "var(--nice-text-muted, #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: "var(--nice-text-muted, #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 (f) {
|
|
379
|
+
const le = I.slice(0, ae).reduce((ce, be) => ce + (be.data[h] || 0), 0);
|
|
380
|
+
W = R(le + P), E = R(le) - W;
|
|
381
|
+
} else
|
|
382
|
+
W = R(Math.max(0, P)), E = Math.abs(R(P) - R(0));
|
|
383
|
+
const ne = f ? U(h) - Q / 2 : U(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 ${R(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: U(h),
|
|
415
|
+
cy: R(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) => `${U(h)},${R(P)}`);
|
|
431
|
+
return /* @__PURE__ */ y(
|
|
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: `${U(0)},${R(0)} ${z.join(" ")} ${U(C - 1)},${R(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: U(h),
|
|
458
|
+
cy: R(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
|
+
g && /* @__PURE__ */ e("g", { transform: `translate(${J.left}, ${m})`, children: t.map((S, ae) => {
|
|
474
|
+
const ee = ae * 120, a = v.has(S.name);
|
|
475
|
+
return /* @__PURE__ */ y(
|
|
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
|
+
}, ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
504
|
+
__proto__: null,
|
|
505
|
+
NiceChart: je
|
|
506
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
507
|
+
function He(t) {
|
|
508
|
+
if (!t.length)
|
|
509
|
+
return { categories: [], numericFields: [], sampleValues: {} };
|
|
510
|
+
const u = t[0], o = [], m = {};
|
|
511
|
+
let n = null;
|
|
512
|
+
for (const [g, w] of Object.entries(u))
|
|
513
|
+
typeof w == "number" ? (o.push(g), m[g] = t.map((A) => Number(A[g]) || 0)) : !n && (typeof w == "string" || w instanceof Date) && (n = g);
|
|
514
|
+
return { categories: n ? t.map((g) => String(g[n] || "")) : t.map((g, w) => `Item ${w + 1}`), numericFields: o, sampleValues: m };
|
|
515
|
+
}
|
|
516
|
+
function Ge(t, u) {
|
|
517
|
+
const { categories: o, numericFields: m, sampleValues: n } = He(t);
|
|
518
|
+
return { series: m.map((g, w) => ({
|
|
519
|
+
name: g.replace(/([A-Z])/g, " $1").replace(/^./, (A) => A.toUpperCase()).trim(),
|
|
520
|
+
data: n[g],
|
|
521
|
+
type: u === "area" ? "area" : u === "line" ? "line" : "bar"
|
|
522
|
+
})), categories: o };
|
|
523
|
+
}
|
|
524
|
+
_e(
|
|
525
|
+
function(t, u) {
|
|
526
|
+
const {
|
|
527
|
+
rawData: o,
|
|
528
|
+
enableAI: m = !0,
|
|
529
|
+
aiModel: n,
|
|
530
|
+
enableAutoType: g = !0,
|
|
531
|
+
enableInsights: w = !0,
|
|
532
|
+
dataDescription: A,
|
|
533
|
+
onChartSuggestion: L,
|
|
534
|
+
onInsights: c,
|
|
535
|
+
showAIToolbar: f = !0,
|
|
536
|
+
showInsightsOnLoad: x = !1,
|
|
537
|
+
series: p,
|
|
538
|
+
categories: N,
|
|
539
|
+
...$
|
|
540
|
+
} = t, [i, d] = he("bar"), [s, k] = he(null), [_, M] = he([]), [v, b] = he(x), [l, D] = he(null), { t: r } = Xe(), j = Ue(), {
|
|
541
|
+
suggestChartType: V,
|
|
542
|
+
generateInsights: Z,
|
|
543
|
+
isLoading: q
|
|
544
|
+
} = Ze(), G = m && j.isConfigured, { series: re, categories: J } = o ? Ge(o, l || i) : { series: p || [], categories: N }, te = oe(async () => {
|
|
545
|
+
if (!G || !g)
|
|
546
|
+
return { type: "bar", reason: "Default", config: {} };
|
|
547
|
+
const C = o || (p != null && p.length ? p.flatMap((I) => I.data.map((O, H) => ({ [I.name]: O, index: H }))) : []);
|
|
548
|
+
try {
|
|
549
|
+
const I = await V(C, A), O = {
|
|
550
|
+
type: I.type,
|
|
551
|
+
reason: I.reason,
|
|
552
|
+
config: I.config
|
|
553
|
+
};
|
|
554
|
+
return k(O), d(O.type), L == null || L(O), O;
|
|
555
|
+
} catch {
|
|
556
|
+
return { type: "bar", reason: "Default fallback", config: {} };
|
|
557
|
+
}
|
|
558
|
+
}, [
|
|
559
|
+
G,
|
|
560
|
+
g,
|
|
561
|
+
o,
|
|
562
|
+
p,
|
|
563
|
+
A,
|
|
564
|
+
V,
|
|
565
|
+
L
|
|
566
|
+
]), T = oe(async () => {
|
|
567
|
+
if (!G || !w)
|
|
568
|
+
return [];
|
|
569
|
+
const C = o || (p != null && p.length ? p.flatMap(
|
|
570
|
+
(I) => I.data.map((O, H) => ({ [I.name]: O, category: (N == null ? void 0 : N[H]) || H }))
|
|
571
|
+
) : []);
|
|
572
|
+
try {
|
|
573
|
+
const I = await Z(C, l || i);
|
|
574
|
+
return M(I), c == null || c(I), I;
|
|
575
|
+
} catch {
|
|
576
|
+
return [];
|
|
577
|
+
}
|
|
578
|
+
}, [
|
|
579
|
+
G,
|
|
580
|
+
w,
|
|
581
|
+
o,
|
|
582
|
+
p,
|
|
583
|
+
N,
|
|
584
|
+
i,
|
|
585
|
+
l,
|
|
586
|
+
Z,
|
|
587
|
+
c
|
|
588
|
+
]), Y = oe(
|
|
589
|
+
() => l || i,
|
|
590
|
+
[l, i]
|
|
591
|
+
);
|
|
592
|
+
Ae(() => {
|
|
593
|
+
G && g && (o != null && o.length || p != null && p.length) && te();
|
|
594
|
+
}, [G, g, o, p]), Le(u, () => ({
|
|
595
|
+
getSuggestion: te,
|
|
596
|
+
generateInsights: T,
|
|
597
|
+
getCurrentType: Y
|
|
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__ */ y("div", { className: "nice-chart-ai", "data-testid": t["data-testid"], children: [
|
|
608
|
+
f && G && /* @__PURE__ */ y("div", { className: "nice-chart-ai__toolbar", children: [
|
|
609
|
+
/* @__PURE__ */ y("div", { className: "nice-chart-ai__toolbar-left", children: [
|
|
610
|
+
/* @__PURE__ */ e("span", { className: "nice-chart-ai__badge", children: "AI" }),
|
|
611
|
+
s && /* @__PURE__ */ y("div", { className: "nice-chart-ai__suggestion", children: [
|
|
612
|
+
/* @__PURE__ */ e("span", { className: "nice-chart-ai__suggestion-icon", children: "💡" }),
|
|
613
|
+
/* @__PURE__ */ y("span", { className: "nice-chart-ai__suggestion-text", children: [
|
|
614
|
+
r("chartAI.suggestedType", "Suggested:"),
|
|
615
|
+
" ",
|
|
616
|
+
s.type
|
|
617
|
+
] }),
|
|
618
|
+
/* @__PURE__ */ y("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: O }) => /* @__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: O,
|
|
633
|
+
children: I
|
|
634
|
+
},
|
|
635
|
+
C
|
|
636
|
+
)) }) }),
|
|
637
|
+
/* @__PURE__ */ y("div", { className: "nice-chart-ai__toolbar-right", children: [
|
|
638
|
+
/* @__PURE__ */ y(
|
|
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__ */ y(
|
|
653
|
+
"button",
|
|
654
|
+
{
|
|
655
|
+
type: "button",
|
|
656
|
+
className: "nice-chart-ai__insights-btn",
|
|
657
|
+
onClick: () => {
|
|
658
|
+
_.length || T(), b(!v);
|
|
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(je, { series: re, categories: J, ...$ }) }),
|
|
671
|
+
v && _.length > 0 && /* @__PURE__ */ y("div", { className: "nice-chart-ai__insights", children: [
|
|
672
|
+
/* @__PURE__ */ y("div", { className: "nice-chart-ai__insights-header", children: [
|
|
673
|
+
/* @__PURE__ */ y("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__ */ y("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__ */ y(
|
|
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
|
+
v && q && /* @__PURE__ */ e("div", { className: "nice-chart-ai__insights nice-chart-ai__insights--loading", children: /* @__PURE__ */ y("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 Ye(t, u) {
|
|
713
|
+
const o = t ? typeof t == "number" ? new Date(t) : new Date(t) : /* @__PURE__ */ new Date(), m = (L) => L.toString().padStart(2, "0"), n = m(o.getHours()), g = m(o.getMinutes()), w = m(o.getSeconds()), A = o.getMilliseconds().toString().padStart(3, "0");
|
|
714
|
+
switch (u) {
|
|
715
|
+
case "HH:mm:ss":
|
|
716
|
+
return `${n}:${g}:${w}`;
|
|
717
|
+
case "HH:mm":
|
|
718
|
+
return `${n}:${g}`;
|
|
719
|
+
case "mm:ss":
|
|
720
|
+
return `${g}:${w}`;
|
|
721
|
+
case "ss.SSS":
|
|
722
|
+
return `${w}.${A}`;
|
|
723
|
+
case "ISO":
|
|
724
|
+
return o.toISOString();
|
|
725
|
+
default:
|
|
726
|
+
return `${n}:${g}:${w}`;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
function Re(t) {
|
|
730
|
+
if (t.length === 0)
|
|
731
|
+
return null;
|
|
732
|
+
const u = Math.min(...t), o = Math.max(...t), m = t.reduce((g, w) => g + w, 0) / t.length, n = t[t.length - 1];
|
|
733
|
+
return { min: u, max: o, avg: m, current: n, count: t.length };
|
|
734
|
+
}
|
|
735
|
+
const qe = _e(
|
|
736
|
+
({
|
|
737
|
+
series: t,
|
|
738
|
+
maxPoints: u = 100,
|
|
739
|
+
slidingWindow: o = !0,
|
|
740
|
+
refreshRate: m = 16,
|
|
741
|
+
dataSource: n,
|
|
742
|
+
width: g = 600,
|
|
743
|
+
height: w = 400,
|
|
744
|
+
title: A,
|
|
745
|
+
showLegend: L = !0,
|
|
746
|
+
showGrid: c = !0,
|
|
747
|
+
yAxisLabel: f,
|
|
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: v = !1,
|
|
759
|
+
onDataReceived: b,
|
|
760
|
+
onDataDropped: l,
|
|
761
|
+
timeFormat: D = "HH:mm:ss",
|
|
762
|
+
showStats: r,
|
|
763
|
+
thresholds: j = [],
|
|
764
|
+
className: V,
|
|
765
|
+
style: Z
|
|
766
|
+
}, q) => {
|
|
767
|
+
const [G, re] = he(() => {
|
|
768
|
+
var X;
|
|
769
|
+
const B = /* @__PURE__ */ new Map();
|
|
770
|
+
for (const ie of t)
|
|
771
|
+
B.set(ie.name, ((X = ie.initialData) == null ? void 0 : X.slice()) ?? []);
|
|
772
|
+
return B;
|
|
773
|
+
}), [J, te] = he([]), [T, Y] = he(v), [se, de] = he(!1), C = Ne([]), I = Ne(Date.now()), O = Ne(null), H = oe(() => {
|
|
774
|
+
const B = C.current;
|
|
775
|
+
B.length !== 0 && (C.current = [], re((X) => {
|
|
776
|
+
const ie = new Map(X);
|
|
777
|
+
for (const ge of B) {
|
|
778
|
+
const fe = ie.get(ge.series);
|
|
779
|
+
if (!fe)
|
|
780
|
+
continue;
|
|
781
|
+
const xe = [...fe, ge.value];
|
|
782
|
+
if (o && xe.length > u) {
|
|
783
|
+
const ye = xe.length - u;
|
|
784
|
+
l == null || l(ye, ge.series), xe.splice(0, ye);
|
|
785
|
+
}
|
|
786
|
+
ie.set(ge.series, xe);
|
|
787
|
+
}
|
|
788
|
+
return ie;
|
|
789
|
+
}), B.length > 0 && te((X) => {
|
|
790
|
+
const ie = [...X];
|
|
791
|
+
for (const ge of B) {
|
|
792
|
+
const fe = ge.category ?? Ye(ge.timestamp, D);
|
|
793
|
+
ie.push(fe);
|
|
794
|
+
}
|
|
795
|
+
return o && ie.length > u && ie.splice(0, ie.length - u), ie;
|
|
796
|
+
}));
|
|
797
|
+
}, [o, u, D, l]), K = oe(() => {
|
|
798
|
+
const B = Date.now();
|
|
799
|
+
B - I.current >= m && (H(), I.current = B), O.current = requestAnimationFrame(K);
|
|
800
|
+
}, [m, H]);
|
|
801
|
+
Ae(() => (T || (O.current = requestAnimationFrame(K)), () => {
|
|
802
|
+
O.current !== null && (cancelAnimationFrame(O.current), O.current = null);
|
|
803
|
+
}), [T, K]);
|
|
804
|
+
const F = oe(
|
|
805
|
+
(B) => {
|
|
806
|
+
if (T)
|
|
807
|
+
return;
|
|
808
|
+
const X = "points" in B ? B.points : [B];
|
|
809
|
+
for (const ie of X)
|
|
810
|
+
G.has(ie.series) && (C.current.push(ie), b == null || b(ie));
|
|
811
|
+
},
|
|
812
|
+
[T, G, b]
|
|
813
|
+
);
|
|
814
|
+
Ae(() => {
|
|
815
|
+
if (!n)
|
|
816
|
+
return;
|
|
817
|
+
const B = n.subscribe(F);
|
|
818
|
+
let X;
|
|
819
|
+
return n.onStatusChange ? X = n.onStatusChange(de) : de(!0), n.fetchHistory && n.fetchHistory(u).then((ie) => {
|
|
820
|
+
for (const ge of ie)
|
|
821
|
+
C.current.push(ge);
|
|
822
|
+
H();
|
|
823
|
+
}), () => {
|
|
824
|
+
B(), X == null || X();
|
|
825
|
+
};
|
|
826
|
+
}, [n, F, u, H]);
|
|
827
|
+
const R = ue(() => t.map((B) => ({
|
|
828
|
+
name: B.name,
|
|
829
|
+
color: B.color,
|
|
830
|
+
type: B.type,
|
|
831
|
+
data: G.get(B.name) ?? []
|
|
832
|
+
})), [t, G]), U = ue(() => {
|
|
833
|
+
const B = [...i];
|
|
834
|
+
for (const X of j)
|
|
835
|
+
B.push({
|
|
836
|
+
type: "line",
|
|
837
|
+
value: X.value,
|
|
838
|
+
color: X.color,
|
|
839
|
+
label: X.label,
|
|
840
|
+
dash: X.style === "dashed" ? "5,5" : X.style === "dotted" ? "2,2" : void 0
|
|
841
|
+
});
|
|
842
|
+
return B;
|
|
843
|
+
}, [i, j]);
|
|
844
|
+
Le(
|
|
845
|
+
q,
|
|
846
|
+
() => ({
|
|
847
|
+
pause() {
|
|
848
|
+
Y(!0);
|
|
849
|
+
},
|
|
850
|
+
resume() {
|
|
851
|
+
Y(!1);
|
|
852
|
+
},
|
|
853
|
+
isPaused() {
|
|
854
|
+
return T;
|
|
855
|
+
},
|
|
856
|
+
clear() {
|
|
857
|
+
re((B) => {
|
|
858
|
+
const X = new Map(B);
|
|
859
|
+
for (const ie of X.keys())
|
|
860
|
+
X.set(ie, []);
|
|
861
|
+
return X;
|
|
862
|
+
}), te([]), C.current = [];
|
|
863
|
+
},
|
|
864
|
+
addPoint(B) {
|
|
865
|
+
F(B);
|
|
866
|
+
},
|
|
867
|
+
addPoints(B) {
|
|
868
|
+
F({ points: B });
|
|
869
|
+
},
|
|
870
|
+
getData(B) {
|
|
871
|
+
return G.get(B) ?? [];
|
|
872
|
+
},
|
|
873
|
+
getCategories() {
|
|
874
|
+
return J;
|
|
875
|
+
},
|
|
876
|
+
exportData() {
|
|
877
|
+
return { series: R, categories: J };
|
|
878
|
+
},
|
|
879
|
+
getStats(B) {
|
|
880
|
+
const X = G.get(B);
|
|
881
|
+
return X ? Re(X) : null;
|
|
882
|
+
}
|
|
883
|
+
}),
|
|
884
|
+
[T, G, J, R, F]
|
|
885
|
+
);
|
|
886
|
+
const Q = ue(() => {
|
|
887
|
+
if (!r)
|
|
888
|
+
return null;
|
|
889
|
+
const B = {};
|
|
890
|
+
for (const [X, ie] of G)
|
|
891
|
+
B[X] = Re(ie);
|
|
892
|
+
return B;
|
|
893
|
+
}, [r, G]);
|
|
894
|
+
return /* @__PURE__ */ y("div", { className: V, style: { position: "relative", ...Z }, children: [
|
|
895
|
+
M && /* @__PURE__ */ y(
|
|
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: () => Y((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: "var(--nice-overlay-light-90, 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, X]) => X ? /* @__PURE__ */ y("div", { style: { marginBottom: 4 }, children: [
|
|
970
|
+
/* @__PURE__ */ e("strong", { children: B }),
|
|
971
|
+
/* @__PURE__ */ y("div", { children: [
|
|
972
|
+
"Min: ",
|
|
973
|
+
X.min.toFixed(2),
|
|
974
|
+
" | Max: ",
|
|
975
|
+
X.max.toFixed(2)
|
|
976
|
+
] }),
|
|
977
|
+
/* @__PURE__ */ y("div", { children: [
|
|
978
|
+
"Avg: ",
|
|
979
|
+
X.avg.toFixed(2),
|
|
980
|
+
" | Now: ",
|
|
981
|
+
X.current.toFixed(2)
|
|
982
|
+
] })
|
|
983
|
+
] }, B) : null
|
|
984
|
+
)
|
|
985
|
+
}
|
|
986
|
+
),
|
|
987
|
+
/* @__PURE__ */ e(
|
|
988
|
+
je,
|
|
989
|
+
{
|
|
990
|
+
series: R,
|
|
991
|
+
categories: J,
|
|
992
|
+
width: g,
|
|
993
|
+
height: w,
|
|
994
|
+
title: A,
|
|
995
|
+
showLegend: L,
|
|
996
|
+
showGrid: c,
|
|
997
|
+
yAxisLabel: f,
|
|
998
|
+
xAxisLabel: x,
|
|
999
|
+
stacked: p,
|
|
1000
|
+
zoomable: N,
|
|
1001
|
+
crosshair: $,
|
|
1002
|
+
annotations: U,
|
|
1003
|
+
legendInteractive: d,
|
|
1004
|
+
onDataPointClick: s,
|
|
1005
|
+
exportable: k
|
|
1006
|
+
}
|
|
1007
|
+
)
|
|
1008
|
+
] });
|
|
1009
|
+
}
|
|
1010
|
+
);
|
|
1011
|
+
qe.displayName = "NiceLiveChart";
|
|
1012
|
+
const ve = ["#3b82f6", "#ef4444", "#22c55e", "#f59e0b", "#8b5cf6", "#ec4899", "#06b6d4", "#84cc16"], gt = ({
|
|
1013
|
+
data: t,
|
|
1014
|
+
width: u = 400,
|
|
1015
|
+
height: o = 400,
|
|
1016
|
+
innerRadius: m = 0,
|
|
1017
|
+
title: n,
|
|
1018
|
+
showLegend: g = !0,
|
|
1019
|
+
showLabels: w = !0,
|
|
1020
|
+
className: A,
|
|
1021
|
+
style: L
|
|
1022
|
+
}) => {
|
|
1023
|
+
const c = u / 2, f = (o - (g ? 30 : 0)) / 2 + (n ? 10 : 0), x = Math.min(c, f) - 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, v = c + x * Math.cos(k), b = f + x * Math.sin(k), l = c + x * Math.cos(_), D = f + x * Math.sin(_), r = s > Math.PI ? 1 : 0, j = i.color || ve[d % ve.length];
|
|
1029
|
+
let V;
|
|
1030
|
+
if (m > 0) {
|
|
1031
|
+
const re = c + m * Math.cos(k), J = f + m * Math.sin(k), te = c + m * Math.cos(_), T = f + m * Math.sin(_);
|
|
1032
|
+
V = `M${v},${b} A${x},${x} 0 ${r},1 ${l},${D} L${te},${T} A${m},${m} 0 ${r},0 ${re},${J} Z`;
|
|
1033
|
+
} else
|
|
1034
|
+
V = `M${c},${f} L${v},${b} A${x},${x} 0 ${r},1 ${l},${D} Z`;
|
|
1035
|
+
const Z = c + x * 0.7 * Math.cos(M), q = f + x * 0.7 * Math.sin(M), G = p > 0 ? Math.round(i.value / p * 100) : 0;
|
|
1036
|
+
return { ...i, path: V, labelX: Z, labelY: q, pct: G, color: j };
|
|
1037
|
+
});
|
|
1038
|
+
return /* @__PURE__ */ e("div", { className: `nice-piechart ${A || ""}`, style: L, children: /* @__PURE__ */ y(
|
|
1039
|
+
"svg",
|
|
1040
|
+
{
|
|
1041
|
+
viewBox: `0 0 ${u} ${o}`,
|
|
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: c, y: 20, textAnchor: "middle", className: "nice-chart__title", children: n }),
|
|
1049
|
+
$.map((i, d) => /* @__PURE__ */ y("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__ */ y(
|
|
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
|
+
g && /* @__PURE__ */ e("g", { transform: `translate(10, ${o - 25})`, children: t.map((i, d) => /* @__PURE__ */ y("g", { transform: `translate(${d * 100}, 0)`, children: [
|
|
1067
|
+
/* @__PURE__ */ e("rect", { width: 10, height: 10, rx: 2, fill: i.color || ve[d % ve.length] }),
|
|
1068
|
+
/* @__PURE__ */ e("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: i.label })
|
|
1069
|
+
] }, d)) })
|
|
1070
|
+
]
|
|
1071
|
+
}
|
|
1072
|
+
) });
|
|
1073
|
+
}, ft = ({
|
|
1074
|
+
series: t,
|
|
1075
|
+
categories: u,
|
|
1076
|
+
width: o = 400,
|
|
1077
|
+
height: m = 400,
|
|
1078
|
+
maxValue: n,
|
|
1079
|
+
title: g,
|
|
1080
|
+
showLegend: w = !0,
|
|
1081
|
+
className: A,
|
|
1082
|
+
style: L
|
|
1083
|
+
}) => {
|
|
1084
|
+
const c = o / 2, f = (m - (w ? 30 : 0)) / 2 + (g ? 10 : 0), x = Math.min(c, f) - 60, p = u.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: c + M * Math.cos(_), y: f + M * Math.sin(_) };
|
|
1087
|
+
};
|
|
1088
|
+
return /* @__PURE__ */ e("div", { className: `nice-polarchart ${A || ""}`, style: L, children: /* @__PURE__ */ y("svg", { width: o, height: m, className: "nice-polarchart__svg", children: [
|
|
1089
|
+
g && /* @__PURE__ */ e("text", { x: c, y: 20, textAnchor: "middle", className: "nice-chart__title", children: g }),
|
|
1090
|
+
Array.from({ length: i }, (s, k) => {
|
|
1091
|
+
const _ = x * ((k + 1) / i);
|
|
1092
|
+
return /* @__PURE__ */ e(
|
|
1093
|
+
"circle",
|
|
1094
|
+
{
|
|
1095
|
+
cx: c,
|
|
1096
|
+
cy: f,
|
|
1097
|
+
r: _,
|
|
1098
|
+
fill: "none",
|
|
1099
|
+
stroke: "var(--border-color, #ddd)",
|
|
1100
|
+
strokeWidth: 0.5
|
|
1101
|
+
},
|
|
1102
|
+
k
|
|
1103
|
+
);
|
|
1104
|
+
}),
|
|
1105
|
+
u.map((s, k) => {
|
|
1106
|
+
const _ = d(k, N), M = d(k, N * 1.22), v = k * $ - Math.PI / 2, b = Math.cos(v), l = Math.sin(v), D = b > 0.2 ? "start" : b < -0.2 ? "end" : "middle", r = l > 0.2 ? "hanging" : l < -0.2 ? "auto" : "middle";
|
|
1107
|
+
return /* @__PURE__ */ y("g", { children: [
|
|
1108
|
+
/* @__PURE__ */ e(
|
|
1109
|
+
"line",
|
|
1110
|
+
{
|
|
1111
|
+
x1: c,
|
|
1112
|
+
y1: f,
|
|
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 || ve[k % ve.length], M = s.data.map((v, b) => {
|
|
1134
|
+
const l = d(b, v);
|
|
1135
|
+
return `${l.x},${l.y}`;
|
|
1136
|
+
}).join(" ");
|
|
1137
|
+
return /* @__PURE__ */ y("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((v, b) => {
|
|
1149
|
+
const l = d(b, v);
|
|
1150
|
+
return /* @__PURE__ */ e("circle", { cx: l.x, cy: l.y, r: 3, fill: _, children: /* @__PURE__ */ e("title", { children: `${s.name} - ${u[b]}: ${v}` }) }, b);
|
|
1151
|
+
})
|
|
1152
|
+
] }, s.name);
|
|
1153
|
+
}),
|
|
1154
|
+
w && /* @__PURE__ */ e("g", { transform: `translate(10, ${m - 25})`, children: t.map((s, k) => /* @__PURE__ */ y("g", { transform: `translate(${k * 100}, 0)`, children: [
|
|
1155
|
+
/* @__PURE__ */ e("rect", { width: 10, height: 10, rx: 2, fill: s.color || ve[k % ve.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: u = 0,
|
|
1162
|
+
max: o = 100,
|
|
1163
|
+
width: m = 200,
|
|
1164
|
+
height: n = 200,
|
|
1165
|
+
startAngle: g = 225,
|
|
1166
|
+
endAngle: w = -45,
|
|
1167
|
+
color: A = "var(--color-primary, #3b82f6)",
|
|
1168
|
+
trackColor: L,
|
|
1169
|
+
label: c,
|
|
1170
|
+
formatValue: f,
|
|
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 - u) / (o - u || 1))), k = (r) => r * Math.PI / 180, _ = (g - w + 360) % 360 || 360, M = (r) => ({
|
|
1176
|
+
x: $ + d * Math.cos(k(r)),
|
|
1177
|
+
y: i - d * Math.sin(k(r))
|
|
1178
|
+
}), v = (r, j) => {
|
|
1179
|
+
const V = M(r), Z = M(j), q = (r - j + 360) % 360 > 180 ? 1 : 0;
|
|
1180
|
+
return `M${V.x},${V.y} A${d},${d} 0 ${q},1 ${Z.x},${Z.y}`;
|
|
1181
|
+
}, b = g - 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__ */ y("svg", { width: m, height: n, children: [
|
|
1191
|
+
/* @__PURE__ */ e(
|
|
1192
|
+
"path",
|
|
1193
|
+
{
|
|
1194
|
+
d: v(g, 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: v(g, 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: f ? f(t) : t }),
|
|
1225
|
+
c && /* @__PURE__ */ e("text", { x: $, y: i + d * 0.95, textAnchor: "middle", className: "nice-gauge__label", children: c })
|
|
1226
|
+
] }) });
|
|
1227
|
+
}, xt = ({
|
|
1228
|
+
value: t,
|
|
1229
|
+
min: u = 0,
|
|
1230
|
+
max: o = 100,
|
|
1231
|
+
width: m = 300,
|
|
1232
|
+
height: n = 60,
|
|
1233
|
+
orientation: g = "horizontal",
|
|
1234
|
+
color: w = "var(--color-primary, #3b82f6)",
|
|
1235
|
+
label: A,
|
|
1236
|
+
formatValue: L,
|
|
1237
|
+
ranges: c,
|
|
1238
|
+
showTicks: f = !0,
|
|
1239
|
+
tickCount: x = 5,
|
|
1240
|
+
className: p,
|
|
1241
|
+
style: N
|
|
1242
|
+
}) => {
|
|
1243
|
+
const $ = g === "horizontal", i = $ ? m - 40 : n - 40, d = Math.max(0, Math.min(1, (t - u) / (o - u || 1))), s = 10;
|
|
1244
|
+
let k = w;
|
|
1245
|
+
if (c) {
|
|
1246
|
+
for (const M of c)
|
|
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, v) => u + (o - u) * (v / (x - 1))
|
|
1255
|
+
);
|
|
1256
|
+
return $ ? /* @__PURE__ */ e("div", { className: `nice-gauge nice-gauge--linear ${p || ""}`, style: N, children: /* @__PURE__ */ y("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
|
+
f && _.map((M, v) => {
|
|
1298
|
+
const b = 20 + (M - u) / (o - u) * 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
|
+
v
|
|
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__ */ y("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
|
+
}, vt = ({
|
|
1346
|
+
items: t,
|
|
1347
|
+
min: u = 0,
|
|
1348
|
+
max: o = 100,
|
|
1349
|
+
width: m = 300,
|
|
1350
|
+
height: n = 300,
|
|
1351
|
+
startAngle: g = 225,
|
|
1352
|
+
endAngle: w = -45,
|
|
1353
|
+
formatValue: A,
|
|
1354
|
+
title: L,
|
|
1355
|
+
className: c,
|
|
1356
|
+
style: f
|
|
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 = (g - w + 360) % 360 || 360, k = (_, M, v) => {
|
|
1359
|
+
const b = x + _ * Math.cos(d(M)), l = p - _ * Math.sin(d(M)), D = x + _ * Math.cos(d(v)), r = p - _ * Math.sin(d(v)), j = (M - v + 360) % 360;
|
|
1360
|
+
return `M${b},${l} A${_},${_} 0 ${j > 180 ? 1 : 0},1 ${D},${r}`;
|
|
1361
|
+
};
|
|
1362
|
+
return /* @__PURE__ */ e("div", { className: `nice-bargauge ${c || ""}`, style: f, children: /* @__PURE__ */ y("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 v = N - M * ($ + i), b = Math.max(0, Math.min(1, (_.value - u) / (o - u || 1))), l = g - b * s, D = _.color || ve[M % ve.length];
|
|
1366
|
+
return /* @__PURE__ */ y("g", { children: [
|
|
1367
|
+
/* @__PURE__ */ e(
|
|
1368
|
+
"path",
|
|
1369
|
+
{
|
|
1370
|
+
d: k(v, g, 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(v, g, 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__ */ y(
|
|
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: u = 120,
|
|
1409
|
+
height: o = 30,
|
|
1410
|
+
type: m = "line",
|
|
1411
|
+
color: n = "var(--color-primary, #3b82f6)",
|
|
1412
|
+
showMinMax: g,
|
|
1413
|
+
showLastPoint: w = !0,
|
|
1414
|
+
className: A,
|
|
1415
|
+
style: L
|
|
1416
|
+
}) => {
|
|
1417
|
+
if (t.length === 0)
|
|
1418
|
+
return null;
|
|
1419
|
+
const c = 2, f = Math.min(...t), x = Math.max(...t), p = x - f || 1, N = u - c * 2, $ = o - c * 2, i = (v) => c + v / (t.length - 1 || 1) * N, d = (v) => c + $ - (v - f) / p * $;
|
|
1420
|
+
if (m === "bar") {
|
|
1421
|
+
const v = Math.max(1, N / t.length - 1);
|
|
1422
|
+
return /* @__PURE__ */ e(
|
|
1423
|
+
"svg",
|
|
1424
|
+
{
|
|
1425
|
+
width: u,
|
|
1426
|
+
height: o,
|
|
1427
|
+
className: `nice-sparkline ${A || ""}`,
|
|
1428
|
+
style: L,
|
|
1429
|
+
children: t.map((b, l) => /* @__PURE__ */ e(
|
|
1430
|
+
"rect",
|
|
1431
|
+
{
|
|
1432
|
+
x: c + l / t.length * N,
|
|
1433
|
+
y: d(b),
|
|
1434
|
+
width: v,
|
|
1435
|
+
height: $ - (d(b) - c),
|
|
1436
|
+
fill: n,
|
|
1437
|
+
rx: 1
|
|
1438
|
+
},
|
|
1439
|
+
l
|
|
1440
|
+
))
|
|
1441
|
+
}
|
|
1442
|
+
);
|
|
1443
|
+
}
|
|
1444
|
+
const s = t.map((v, b) => `${i(b)},${d(v)}`).join(" "), k = t.indexOf(f), _ = t.indexOf(x), M = t.length - 1;
|
|
1445
|
+
return /* @__PURE__ */ y(
|
|
1446
|
+
"svg",
|
|
1447
|
+
{
|
|
1448
|
+
width: u,
|
|
1449
|
+
height: o,
|
|
1450
|
+
className: `nice-sparkline ${A || ""}`,
|
|
1451
|
+
style: L,
|
|
1452
|
+
children: [
|
|
1453
|
+
m === "area" && /* @__PURE__ */ e(
|
|
1454
|
+
"polygon",
|
|
1455
|
+
{
|
|
1456
|
+
points: `${i(0)},${c + $} ${s} ${i(M)},${c + $}`,
|
|
1457
|
+
fill: n,
|
|
1458
|
+
opacity: 0.15
|
|
1459
|
+
}
|
|
1460
|
+
),
|
|
1461
|
+
/* @__PURE__ */ e("polyline", { points: s, fill: "none", stroke: n, strokeWidth: 1.5 }),
|
|
1462
|
+
g && /* @__PURE__ */ e("circle", { cx: i(k), cy: d(f), r: 2, fill: "var(--nice-danger, #ef4444)" }),
|
|
1463
|
+
g && /* @__PURE__ */ e("circle", { cx: i(_), cy: d(x), r: 2, fill: "var(--nice-success, #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
|
+
}, yt = ({
|
|
1473
|
+
value: t,
|
|
1474
|
+
target: u,
|
|
1475
|
+
min: o = 0,
|
|
1476
|
+
max: m = 100,
|
|
1477
|
+
width: n,
|
|
1478
|
+
height: g,
|
|
1479
|
+
color: w = "var(--color-primary, #3b82f6)",
|
|
1480
|
+
targetColor: A = "var(--color-error, #ef4444)",
|
|
1481
|
+
size: L = "md",
|
|
1482
|
+
label: c,
|
|
1483
|
+
labelPlacement: f = "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 = g ?? k.height, v = k.fontSize, b = 4, l = _ - b * 2, D = M - b * 2, r = Math.max(0, Math.min(1, (t - o) / (m - o || 1))), j = u != null ? Math.max(0, Math.min(1, (u - o) / (m - o || 1))) : null, V = () => $ === "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: v,
|
|
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__ */ y(
|
|
1527
|
+
"svg",
|
|
1528
|
+
{
|
|
1529
|
+
width: _,
|
|
1530
|
+
height: M,
|
|
1531
|
+
role: "img",
|
|
1532
|
+
"aria-label": typeof c == "string" ? c : 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
|
+
j != null && /* @__PURE__ */ e(
|
|
1537
|
+
"line",
|
|
1538
|
+
{
|
|
1539
|
+
x1: b + l * j,
|
|
1540
|
+
y1: b + 2,
|
|
1541
|
+
x2: b + l * j,
|
|
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: v,
|
|
1556
|
+
fill: l * r > 24 ? "var(--nice-bg, #fff)" : "var(--text-primary)",
|
|
1557
|
+
fontWeight: 600,
|
|
1558
|
+
children: N(t)
|
|
1559
|
+
}
|
|
1560
|
+
),
|
|
1561
|
+
p && j != null && /* @__PURE__ */ y(
|
|
1562
|
+
"text",
|
|
1563
|
+
{
|
|
1564
|
+
x: b + l * j,
|
|
1565
|
+
y: b - 1,
|
|
1566
|
+
textAnchor: "middle",
|
|
1567
|
+
fontSize: v - 1,
|
|
1568
|
+
fill: A,
|
|
1569
|
+
fontWeight: 600,
|
|
1570
|
+
children: [
|
|
1571
|
+
"▼",
|
|
1572
|
+
N(u)
|
|
1573
|
+
]
|
|
1574
|
+
}
|
|
1575
|
+
)
|
|
1576
|
+
]
|
|
1577
|
+
}
|
|
1578
|
+
);
|
|
1579
|
+
if (f === "none" || !c)
|
|
1580
|
+
return /* @__PURE__ */ y("div", { className: `nice-bullet ${d || ""}`, style: s, children: [
|
|
1581
|
+
V(),
|
|
1582
|
+
/* @__PURE__ */ e("style", { children: Fe })
|
|
1583
|
+
] });
|
|
1584
|
+
const Z = f === "top" || f === "bottom", q = /* @__PURE__ */ e(
|
|
1585
|
+
"span",
|
|
1586
|
+
{
|
|
1587
|
+
className: "nice-bullet__label",
|
|
1588
|
+
style: {
|
|
1589
|
+
fontSize: v,
|
|
1590
|
+
fontWeight: 600,
|
|
1591
|
+
color: "var(--text-primary)",
|
|
1592
|
+
...Z ? {
|
|
1593
|
+
marginBottom: f === "top" ? 4 : 0,
|
|
1594
|
+
marginTop: f === "bottom" ? 4 : 0
|
|
1595
|
+
} : {},
|
|
1596
|
+
...f === "left" ? { marginRight: 8 } : {},
|
|
1597
|
+
...f === "right" ? { marginLeft: 8 } : {}
|
|
1598
|
+
},
|
|
1599
|
+
children: c
|
|
1600
|
+
}
|
|
1601
|
+
);
|
|
1602
|
+
return /* @__PURE__ */ y(
|
|
1603
|
+
"div",
|
|
1604
|
+
{
|
|
1605
|
+
className: `nice-bullet nice-bullet--${f} ${d || ""}`,
|
|
1606
|
+
style: {
|
|
1607
|
+
display: "inline-flex",
|
|
1608
|
+
flexDirection: Z ? "column" : "row",
|
|
1609
|
+
alignItems: Z ? "flex-start" : "center",
|
|
1610
|
+
...s
|
|
1611
|
+
},
|
|
1612
|
+
children: [
|
|
1613
|
+
(f === "top" || f === "left") && q,
|
|
1614
|
+
V(),
|
|
1615
|
+
(f === "bottom" || f === "right") && q,
|
|
1616
|
+
/* @__PURE__ */ e("style", { children: Fe })
|
|
1617
|
+
]
|
|
1618
|
+
}
|
|
1619
|
+
);
|
|
1620
|
+
}, Fe = `
|
|
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: u = 400,
|
|
1628
|
+
height: o = 300,
|
|
1629
|
+
inverted: m,
|
|
1630
|
+
showLabels: n = !0,
|
|
1631
|
+
showValues: g = !0,
|
|
1632
|
+
title: w,
|
|
1633
|
+
className: A,
|
|
1634
|
+
style: L
|
|
1635
|
+
}) => {
|
|
1636
|
+
const c = { top: w ? 30 : 10, bottom: 10, x: 40 }, f = u - c.x * 2, x = o - c.top - c.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__ */ y("svg", { width: u, height: o, children: [
|
|
1638
|
+
w && /* @__PURE__ */ e("text", { x: u / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: w }),
|
|
1639
|
+
p.map((i, d) => {
|
|
1640
|
+
const s = i.value / N * f, k = d < p.length - 1 ? p[d + 1].value / N * f : s * 0.3, _ = c.top + d * $, M = _ + $, v = u / 2, b = `${v - s / 2},${_} ${v + s / 2},${_} ${v + k / 2},${M} ${v - k / 2},${M}`, l = i.color || ve[d % ve.length];
|
|
1641
|
+
return /* @__PURE__ */ y("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: v,
|
|
1656
|
+
y: _ + $ / 2 - (g ? 4 : 0),
|
|
1657
|
+
textAnchor: "middle",
|
|
1658
|
+
dominantBaseline: "middle",
|
|
1659
|
+
className: "nice-funnel__label",
|
|
1660
|
+
children: i.label
|
|
1661
|
+
}
|
|
1662
|
+
),
|
|
1663
|
+
g && /* @__PURE__ */ e(
|
|
1664
|
+
"text",
|
|
1665
|
+
{
|
|
1666
|
+
x: v,
|
|
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: u,
|
|
1680
|
+
width: o = 600,
|
|
1681
|
+
height: m = 400,
|
|
1682
|
+
nodeWidth: n = 20,
|
|
1683
|
+
nodePadding: g = 10,
|
|
1684
|
+
title: w,
|
|
1685
|
+
className: A,
|
|
1686
|
+
style: L
|
|
1687
|
+
}) => {
|
|
1688
|
+
const c = { top: w ? 40 : 20, bottom: 20, left: 20, right: 20 }, f = o - c.left - c.right, x = m - c.top - c.bottom, p = new Set(u.map((r) => r.source)), N = new Set(u.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 j = u.filter((Z) => Z.source === r.id).reduce((Z, q) => Z + q.value, 0), V = u.filter((Z) => Z.target === r.id).reduce((Z, q) => Z + q.value, 0);
|
|
1693
|
+
_.set(r.id, Math.max(j, V));
|
|
1694
|
+
});
|
|
1695
|
+
const M = s.map(
|
|
1696
|
+
(r) => r.reduce((j, V) => j + (_.get(V.id) || 0), 0) + (r.length - 1) * g
|
|
1697
|
+
), v = Math.max(...M, 1), b = /* @__PURE__ */ new Map();
|
|
1698
|
+
s.forEach((r, j) => {
|
|
1699
|
+
const V = c.left + j / (k - 1 || 1) * (f - n);
|
|
1700
|
+
let Z = 0;
|
|
1701
|
+
r.forEach((q) => {
|
|
1702
|
+
const G = (_.get(q.id) || 0) / v * x;
|
|
1703
|
+
b.set(q.id, { x: V, y: c.top + Z, h: G }), Z += G + g;
|
|
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__ */ y("svg", { width: o, height: m, children: [
|
|
1710
|
+
w && /* @__PURE__ */ e("text", { x: o / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: w }),
|
|
1711
|
+
u.map((r, j) => {
|
|
1712
|
+
var C;
|
|
1713
|
+
const V = b.get(r.source), Z = b.get(r.target);
|
|
1714
|
+
if (!V || !Z)
|
|
1715
|
+
return null;
|
|
1716
|
+
const q = l.get(r.source) || 0, G = D.get(r.target) || 0, re = r.value / v * x;
|
|
1717
|
+
l.set(r.source, q + re), D.set(r.target, G + re);
|
|
1718
|
+
const J = V.x + n, te = V.y + q, T = Z.x, Y = Z.y + G, se = (J + T) / 2, de = ((C = t.find((I) => I.id === r.source)) == null ? void 0 : C.color) || ve[j % ve.length];
|
|
1719
|
+
return /* @__PURE__ */ e(
|
|
1720
|
+
"path",
|
|
1721
|
+
{
|
|
1722
|
+
d: `M${J},${te} C${se},${te} ${se},${Y} ${T},${Y} L${T},${Y + re} C${se},${Y + 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
|
+
j
|
|
1731
|
+
);
|
|
1732
|
+
}),
|
|
1733
|
+
t.map((r, j) => {
|
|
1734
|
+
const V = b.get(r.id);
|
|
1735
|
+
if (!V)
|
|
1736
|
+
return null;
|
|
1737
|
+
const Z = r.color || ve[j % ve.length];
|
|
1738
|
+
return /* @__PURE__ */ y("g", { children: [
|
|
1739
|
+
/* @__PURE__ */ e(
|
|
1740
|
+
"rect",
|
|
1741
|
+
{
|
|
1742
|
+
x: V.x,
|
|
1743
|
+
y: V.y,
|
|
1744
|
+
width: n,
|
|
1745
|
+
height: Math.max(V.h, 2),
|
|
1746
|
+
fill: Z,
|
|
1747
|
+
rx: 2
|
|
1748
|
+
}
|
|
1749
|
+
),
|
|
1750
|
+
/* @__PURE__ */ e(
|
|
1751
|
+
"text",
|
|
1752
|
+
{
|
|
1753
|
+
x: V.x < f / 2 ? V.x + n + 4 : V.x - 4,
|
|
1754
|
+
y: V.y + V.h / 2,
|
|
1755
|
+
textAnchor: V.x < f / 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: u,
|
|
1770
|
+
max: o,
|
|
1771
|
+
start: m,
|
|
1772
|
+
end: n,
|
|
1773
|
+
onChange: g,
|
|
1774
|
+
width: w = 500,
|
|
1775
|
+
height: A = 100,
|
|
1776
|
+
step: L = 1,
|
|
1777
|
+
formatValue: c,
|
|
1778
|
+
chartColor: f = "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 = (v) => N.left + (v - u) / (o - u || 1) * $, s = (v) => {
|
|
1783
|
+
const b = Math.max(0, Math.min(1, (v - N.left) / $)), l = u + b * (o - u);
|
|
1784
|
+
return Math.round(l / L) * L;
|
|
1785
|
+
}, k = (v, b) => {
|
|
1786
|
+
b.preventDefault();
|
|
1787
|
+
const l = b.target.closest("svg");
|
|
1788
|
+
if (!l)
|
|
1789
|
+
return;
|
|
1790
|
+
const D = (j) => {
|
|
1791
|
+
const V = l.getBoundingClientRect(), Z = s(j.clientX - V.left);
|
|
1792
|
+
v === "start" ? g(Math.min(Z, n), n) : g(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__ */ y("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((v, b) => `${N.left + b / (t.length - 1) * $},${N.top + i - (v - _) / M * i}`).join(" ")} ${N.left + $},${N.top + i}`,
|
|
1803
|
+
fill: f,
|
|
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: f,
|
|
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: f,
|
|
1848
|
+
rx: 2,
|
|
1849
|
+
cursor: "ew-resize",
|
|
1850
|
+
onPointerDown: (v) => k("start", v)
|
|
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: f,
|
|
1861
|
+
rx: 2,
|
|
1862
|
+
cursor: "ew-resize",
|
|
1863
|
+
onPointerDown: (v) => k("end", v)
|
|
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: c ? c(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: c ? c(n) : n
|
|
1884
|
+
}
|
|
1885
|
+
)
|
|
1886
|
+
] }) });
|
|
1887
|
+
}, Je = ({
|
|
1888
|
+
regions: t,
|
|
1889
|
+
width: u = 600,
|
|
1890
|
+
height: o = 400,
|
|
1891
|
+
viewBox: m = "0 0 1000 600",
|
|
1892
|
+
colorRange: n = ["var(--info-bg, #dbeafe)", "var(--color-primary-active, #1d4ed8)"],
|
|
1893
|
+
maxValue: g,
|
|
1894
|
+
onRegionClick: w,
|
|
1895
|
+
selectedRegionId: A,
|
|
1896
|
+
title: L,
|
|
1897
|
+
showTooltip: c = !0,
|
|
1898
|
+
className: f,
|
|
1899
|
+
style: x
|
|
1900
|
+
}) => {
|
|
1901
|
+
const p = g ?? 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, v] = i(n[1]), b = Math.round(d + (_ - d) * $), l = Math.round(s + (M - s) * $), D = Math.round(k + (v - k) * $);
|
|
1907
|
+
return `rgb(${b},${l},${D})`;
|
|
1908
|
+
};
|
|
1909
|
+
return /* @__PURE__ */ y("div", { className: `nice-vectormap ${f || ""}`, style: x, children: [
|
|
1910
|
+
L && /* @__PURE__ */ e("div", { className: "nice-vectormap__title", children: L }),
|
|
1911
|
+
/* @__PURE__ */ e("svg", { width: u, height: o, 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: c && /* @__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: var(--nice-radius-lg, 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: var(--nice-radius-md, 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: var(--nice-danger, #ef4444);
|
|
2080
|
+
stroke-width: 2;
|
|
2081
|
+
stroke-dasharray: 8, 4;
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2084
|
+
.nice-forecast-chart__cash-runway-label-bg {
|
|
2085
|
+
fill: var(--nice-danger, #ef4444);
|
|
2086
|
+
rx: 4;
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
.nice-forecast-chart__cash-runway-label {
|
|
2090
|
+
font-size: 0.6875rem;
|
|
2091
|
+
font-weight: 600;
|
|
2092
|
+
fill: var(--nice-bg, #FFFFFF);
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
.nice-forecast-chart__cash-runway-date {
|
|
2096
|
+
font-size: 0.625rem;
|
|
2097
|
+
fill: var(--nice-danger, #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: var(--nice-radius-lg, 0.5rem);
|
|
2109
|
+
box-shadow: 0 4px 12px var(--nice-overlay-10, 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: var(--nice-radius-sm, 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: var(--nice-radius-xs, 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
|
+
`, Ve = [
|
|
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
|
+
"var(--nice-warning, #f97316)"
|
|
2233
|
+
// orange
|
|
2234
|
+
];
|
|
2235
|
+
function pe(t) {
|
|
2236
|
+
return t instanceof Date ? t : new Date(t);
|
|
2237
|
+
}
|
|
2238
|
+
function We(t, u = "pl-PL") {
|
|
2239
|
+
return t.toLocaleDateString(u, {
|
|
2240
|
+
year: "numeric",
|
|
2241
|
+
month: "short",
|
|
2242
|
+
day: "numeric"
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
function De(t, u = "pl-PL") {
|
|
2246
|
+
return new Intl.NumberFormat(u, {
|
|
2247
|
+
minimumFractionDigits: 0,
|
|
2248
|
+
maximumFractionDigits: 2
|
|
2249
|
+
}).format(t);
|
|
2250
|
+
}
|
|
2251
|
+
_e(
|
|
2252
|
+
function(t, u) {
|
|
2253
|
+
var ae, ee;
|
|
2254
|
+
const {
|
|
2255
|
+
scenarios: o,
|
|
2256
|
+
data: m,
|
|
2257
|
+
annotations: n = [],
|
|
2258
|
+
referenceLines: g = [],
|
|
2259
|
+
forecastStartDate: w,
|
|
2260
|
+
cashRunway: A,
|
|
2261
|
+
xAxis: L,
|
|
2262
|
+
yAxis: c,
|
|
2263
|
+
confidenceBands: f = [{ 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: v,
|
|
2275
|
+
responsive: b = !0,
|
|
2276
|
+
onPointClick: l,
|
|
2277
|
+
onAnnotationClick: D,
|
|
2278
|
+
onScenarioToggle: r,
|
|
2279
|
+
onViewportChange: j,
|
|
2280
|
+
size: V = "medium",
|
|
2281
|
+
disabled: Z = !1,
|
|
2282
|
+
labels: q = {},
|
|
2283
|
+
locale: G = "pl-PL",
|
|
2284
|
+
className: re,
|
|
2285
|
+
style: J
|
|
2286
|
+
} = t, te = o && o.length > 0 ? o : m ? [
|
|
2287
|
+
{
|
|
2288
|
+
id: "default",
|
|
2289
|
+
name: "Series",
|
|
2290
|
+
data: m
|
|
2291
|
+
}
|
|
2292
|
+
] : [], T = {
|
|
2293
|
+
...p,
|
|
2294
|
+
enabled: v ?? p.enabled
|
|
2295
|
+
}, [Y, se] = he(
|
|
2296
|
+
() => te.map((a, z) => ({
|
|
2297
|
+
...a,
|
|
2298
|
+
color: a.color ?? Ve[z % Ve.length],
|
|
2299
|
+
visible: a.visible !== !1
|
|
2300
|
+
}))
|
|
2301
|
+
), [de, C] = he(null), [I, O] = he({ x: 0, y: 0 }), H = Ne(null), K = Ne(null), F = { top: 20, right: 30, bottom: 40, left: 60 }, [R, U] = 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
|
+
U((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: X, minY: ie, maxY: ge } = ue(() => {
|
|
2324
|
+
const a = Y.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 = (c == null ? void 0 : c.min) ?? Math.min(...W) * 0.95, ne = (c == null ? void 0 : c.max) ?? Math.max(...W) * 1.05, le = R.width - F.left - F.right, ce = R.height - F.top - F.bottom, be = (me) => {
|
|
2328
|
+
const Pe = typeof me == "number" ? me : me.getTime();
|
|
2329
|
+
return F.left + (Pe - P) / (h - P) * le;
|
|
2330
|
+
}, Ie = (me) => F.top + ce - (me - E) / (ne - E) * ce, 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
|
+
}, [Y, R, F, c]), fe = w ? pe(w) : null, xe = ue(() => {
|
|
2339
|
+
if (!(A != null && A.enabled))
|
|
2340
|
+
return null;
|
|
2341
|
+
const a = A.threshold ?? 0, z = A.scenarioId ? Y.find((h) => h.id === A.scenarioId && h.visible !== !1) : Y.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 ce = (ne - a) / (ne - le), be = pe(W.date).getTime(), Ie = pe(E.date).getTime(), ze = be + ce * (Ie - be);
|
|
2351
|
+
return new Date(ze);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
return null;
|
|
2355
|
+
}, [A, Y]), ye = oe(
|
|
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 = oe(
|
|
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 = oe(
|
|
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 X) {
|
|
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 = Y.filter((le) => le.visible !== !1).map((le) => {
|
|
2386
|
+
const ce = le.data.find((be) => pe(be.date).getTime() === h.getTime());
|
|
2387
|
+
return {
|
|
2388
|
+
scenario: le,
|
|
2389
|
+
value: ce == null ? void 0 : ce.value,
|
|
2390
|
+
forecast: ce == null ? void 0 : ce.forecast,
|
|
2391
|
+
lowerBound: ce == null ? void 0 : ce.lowerBound,
|
|
2392
|
+
upperBound: ce == null ? void 0 : ce.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 }), O({ x: a.clientX - z.left + 10, y: a.clientY - z.top - 10 });
|
|
2398
|
+
} else
|
|
2399
|
+
C(null);
|
|
2400
|
+
},
|
|
2401
|
+
[Q, X, Y, n, x]
|
|
2402
|
+
), $e = oe(
|
|
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 = Y.find((P) => P.id === a);
|
|
2408
|
+
z && (r == null || r(a, !z.visible));
|
|
2409
|
+
},
|
|
2410
|
+
[T.interactive, Y, r]
|
|
2411
|
+
);
|
|
2412
|
+
Le(
|
|
2413
|
+
u,
|
|
2414
|
+
() => ({
|
|
2415
|
+
getScenarios: () => Y,
|
|
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 = Y.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
|
+
[Y, n, $e]
|
|
2450
|
+
), R.width - F.left - F.right;
|
|
2451
|
+
const Ce = R.height - F.top - F.bottom, Se = ue(() => {
|
|
2452
|
+
const a = (c == null ? void 0 : c.tickCount) ?? 5, z = [], P = (ge - ie) / (a - 1);
|
|
2453
|
+
for (let h = 0; h < a; h++)
|
|
2454
|
+
z.push(ie + P * h);
|
|
2455
|
+
return z;
|
|
2456
|
+
}, [ie, ge, c == null ? void 0 : c.tickCount]), S = ue(() => {
|
|
2457
|
+
const a = (L == null ? void 0 : L.tickCount) ?? 6;
|
|
2458
|
+
if (X.length === 0)
|
|
2459
|
+
return [];
|
|
2460
|
+
const z = Math.max(1, Math.floor(X.length / (a - 1)));
|
|
2461
|
+
return X.filter((P, h) => h % z === 0 || h === X.length - 1);
|
|
2462
|
+
}, [X, L == null ? void 0 : L.tickCount]);
|
|
2463
|
+
return Y.length === 0 || Y.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__ */ y("div", { className: `nice-forecast-chart ${re ?? ""}`, style: { ...J, height: N }, children: [
|
|
2464
|
+
/* @__PURE__ */ y("div", { ref: H, className: "nice-forecast-chart__container", children: [
|
|
2465
|
+
/* @__PURE__ */ y(
|
|
2466
|
+
"svg",
|
|
2467
|
+
{
|
|
2468
|
+
ref: K,
|
|
2469
|
+
className: "nice-forecast-chart__svg",
|
|
2470
|
+
width: R.width,
|
|
2471
|
+
height: R.height,
|
|
2472
|
+
onMouseMove: we,
|
|
2473
|
+
onMouseLeave: () => C(null),
|
|
2474
|
+
children: [
|
|
2475
|
+
(c == null ? void 0 : c.showGrid) !== !1 && Se.map((a) => /* @__PURE__ */ e(
|
|
2476
|
+
"line",
|
|
2477
|
+
{
|
|
2478
|
+
className: "nice-forecast-chart__grid-line",
|
|
2479
|
+
x1: F.left,
|
|
2480
|
+
x2: R.width - F.right,
|
|
2481
|
+
y1: B(a),
|
|
2482
|
+
y2: B(a)
|
|
2483
|
+
},
|
|
2484
|
+
a
|
|
2485
|
+
)),
|
|
2486
|
+
$ && fe && /* @__PURE__ */ e(
|
|
2487
|
+
"rect",
|
|
2488
|
+
{
|
|
2489
|
+
className: "nice-forecast-chart__forecast-region",
|
|
2490
|
+
x: Q(fe),
|
|
2491
|
+
y: F.top,
|
|
2492
|
+
width: R.width - F.right - Q(fe),
|
|
2493
|
+
height: Ce
|
|
2494
|
+
}
|
|
2495
|
+
),
|
|
2496
|
+
g.map((a) => /* @__PURE__ */ y("g", { children: [
|
|
2497
|
+
/* @__PURE__ */ e(
|
|
2498
|
+
"line",
|
|
2499
|
+
{
|
|
2500
|
+
className: "nice-forecast-chart__reference-line",
|
|
2501
|
+
x1: F.left,
|
|
2502
|
+
x2: R.width - F.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: R.width - F.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__ */ y("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: F.top,
|
|
2528
|
+
y2: R.height - F.bottom,
|
|
2529
|
+
stroke: A.color ?? "var(--color-error, #ef4444)"
|
|
2530
|
+
}
|
|
2531
|
+
),
|
|
2532
|
+
A.showLabel !== !1 && /* @__PURE__ */ y(Oe, { children: [
|
|
2533
|
+
/* @__PURE__ */ e(
|
|
2534
|
+
"rect",
|
|
2535
|
+
{
|
|
2536
|
+
className: "nice-forecast-chart__cash-runway-label-bg",
|
|
2537
|
+
x: Q(xe) - 60,
|
|
2538
|
+
y: F.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: F.top + 12,
|
|
2551
|
+
textAnchor: "middle",
|
|
2552
|
+
fill: "var(--nice-bg, #fff)",
|
|
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: F.top + 26,
|
|
2562
|
+
textAnchor: "middle",
|
|
2563
|
+
fill: "var(--nice-bg, #fff)",
|
|
2564
|
+
style: { fontSize: "0.625rem", opacity: 0.9 },
|
|
2565
|
+
children: We(xe, G)
|
|
2566
|
+
}
|
|
2567
|
+
)
|
|
2568
|
+
] })
|
|
2569
|
+
] }),
|
|
2570
|
+
Y.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
|
+
Y.filter((a) => a.visible !== !1).map((a) => {
|
|
2580
|
+
const z = fe ? a.data.filter((h) => pe(h.date) < fe) : a.data.filter((h) => h.value != null), P = fe ? a.data.filter((h) => pe(h.date) >= fe) : a.data.filter((h) => h.forecast != null);
|
|
2581
|
+
return /* @__PURE__ */ y("g", { children: [
|
|
2582
|
+
/* @__PURE__ */ e(
|
|
2583
|
+
"path",
|
|
2584
|
+
{
|
|
2585
|
+
className: "nice-forecast-chart__historical-line",
|
|
2586
|
+
d: ye(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: ye(P, fe ? "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: ye(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__ */ y(
|
|
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: F.top,
|
|
2641
|
+
y2: R.height - F.bottom,
|
|
2642
|
+
stroke: a.color ?? "var(--text-muted, #9ca3af)"
|
|
2643
|
+
}
|
|
2644
|
+
),
|
|
2645
|
+
/* @__PURE__ */ e(
|
|
2646
|
+
"circle",
|
|
2647
|
+
{
|
|
2648
|
+
cx: z,
|
|
2649
|
+
cy: F.top + 10,
|
|
2650
|
+
r: 8,
|
|
2651
|
+
fill: a.color ?? "var(--text-muted, #9ca3af)"
|
|
2652
|
+
}
|
|
2653
|
+
),
|
|
2654
|
+
/* @__PURE__ */ e("text", { x: z, y: F.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: F.left,
|
|
2665
|
+
x2: F.left,
|
|
2666
|
+
y1: F.top,
|
|
2667
|
+
y2: R.height - F.bottom
|
|
2668
|
+
}
|
|
2669
|
+
),
|
|
2670
|
+
/* @__PURE__ */ e(
|
|
2671
|
+
"line",
|
|
2672
|
+
{
|
|
2673
|
+
className: "nice-forecast-chart__axis-line",
|
|
2674
|
+
x1: F.left,
|
|
2675
|
+
x2: R.width - F.right,
|
|
2676
|
+
y1: R.height - F.bottom,
|
|
2677
|
+
y2: R.height - F.bottom
|
|
2678
|
+
}
|
|
2679
|
+
),
|
|
2680
|
+
Se.map((a) => /* @__PURE__ */ e(
|
|
2681
|
+
"text",
|
|
2682
|
+
{
|
|
2683
|
+
className: "nice-forecast-chart__axis-label",
|
|
2684
|
+
x: F.left - 8,
|
|
2685
|
+
y: B(a) + 4,
|
|
2686
|
+
textAnchor: "end",
|
|
2687
|
+
children: c != null && c.format ? c.format(a) : De(a, G)
|
|
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: R.height - F.bottom + 16,
|
|
2697
|
+
textAnchor: "middle",
|
|
2698
|
+
children: L != null && L.format ? L.format(a) : We(a, G)
|
|
2699
|
+
},
|
|
2700
|
+
a.getTime()
|
|
2701
|
+
)),
|
|
2702
|
+
(c == null ? void 0 : c.title) && /* @__PURE__ */ e(
|
|
2703
|
+
"text",
|
|
2704
|
+
{
|
|
2705
|
+
className: "nice-forecast-chart__axis-title",
|
|
2706
|
+
x: 15,
|
|
2707
|
+
y: R.height / 2,
|
|
2708
|
+
textAnchor: "middle",
|
|
2709
|
+
transform: `rotate(-90, 15, ${R.height / 2})`,
|
|
2710
|
+
children: c.title
|
|
2711
|
+
}
|
|
2712
|
+
)
|
|
2713
|
+
]
|
|
2714
|
+
}
|
|
2715
|
+
),
|
|
2716
|
+
de && /* @__PURE__ */ y(
|
|
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, G) }),
|
|
2723
|
+
de.values.map((a) => {
|
|
2724
|
+
const z = a.value ?? a.forecast;
|
|
2725
|
+
return z == null ? null : /* @__PURE__ */ y("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, G) })
|
|
2735
|
+
] }, a.scenario.id);
|
|
2736
|
+
}),
|
|
2737
|
+
de.values.some((a) => a.lowerBound != null) && /* @__PURE__ */ y("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, G),
|
|
2742
|
+
" –",
|
|
2743
|
+
" ",
|
|
2744
|
+
De(((ee = de.values[0]) == null ? void 0 : ee.upperBound) ?? 0, G)
|
|
2745
|
+
] })
|
|
2746
|
+
]
|
|
2747
|
+
}
|
|
2748
|
+
)
|
|
2749
|
+
] }),
|
|
2750
|
+
T.enabled && /* @__PURE__ */ e("div", { className: "nice-forecast-chart__legend", children: Y.map((a) => /* @__PURE__ */ y(
|
|
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
|
+
"var(--nice-success, #84cc16)",
|
|
2780
|
+
"var(--nice-warning, #f97316)",
|
|
2781
|
+
"var(--color-accent, #6366f1)"
|
|
2782
|
+
], tt = _e(
|
|
2783
|
+
(t, u) => {
|
|
2784
|
+
var se, de;
|
|
2785
|
+
const {
|
|
2786
|
+
levels: o,
|
|
2787
|
+
initialLevelId: m,
|
|
2788
|
+
chartType: n = "bar",
|
|
2789
|
+
width: g = 600,
|
|
2790
|
+
height: w = 400,
|
|
2791
|
+
showBreadcrumbs: A = !0,
|
|
2792
|
+
showBackButton: L = !0,
|
|
2793
|
+
animationDuration: c = 300,
|
|
2794
|
+
onLevelChange: f,
|
|
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 = o[0]) == null ? void 0 : se.id)), [M, v] = he([m || ((de = o[0]) == null ? void 0 : de.id)]), [b, l] = he(!1), [D, r] = he("in"), j = ue(
|
|
2803
|
+
() => o.find((C) => C.id === k),
|
|
2804
|
+
[o, k]
|
|
2805
|
+
), V = oe(
|
|
2806
|
+
(C) => {
|
|
2807
|
+
o.find((I) => I.id === C) && (r("in"), l(!0), setTimeout(() => {
|
|
2808
|
+
_(C), v((I) => [...I, C]), f == null || f(C, [...M, C]), l(!1);
|
|
2809
|
+
}, c / 2));
|
|
2810
|
+
},
|
|
2811
|
+
[o, M, c, f]
|
|
2812
|
+
), Z = oe(() => {
|
|
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), v(C), f == null || f(I, C), l(!1);
|
|
2819
|
+
}, c / 2);
|
|
2820
|
+
}, [M, c, f]), q = oe(() => {
|
|
2821
|
+
var I;
|
|
2822
|
+
const C = (I = o[0]) == null ? void 0 : I.id;
|
|
2823
|
+
C && (r("out"), l(!0), setTimeout(() => {
|
|
2824
|
+
_(C), v([C]), f == null || f(C, [C]), l(!1);
|
|
2825
|
+
}, c / 2));
|
|
2826
|
+
}, [o, c, f]);
|
|
2827
|
+
Le(
|
|
2828
|
+
u,
|
|
2829
|
+
() => ({
|
|
2830
|
+
drillDown: V,
|
|
2831
|
+
drillUp: Z,
|
|
2832
|
+
resetToRoot: q,
|
|
2833
|
+
getCurrentLevel: () => k,
|
|
2834
|
+
getPath: () => M
|
|
2835
|
+
}),
|
|
2836
|
+
[V, Z, q, k, M]
|
|
2837
|
+
);
|
|
2838
|
+
const G = oe(
|
|
2839
|
+
(C, I) => {
|
|
2840
|
+
x == null || x(C, k);
|
|
2841
|
+
const O = o.find(
|
|
2842
|
+
(H) => {
|
|
2843
|
+
var K;
|
|
2844
|
+
return H.parentId === k && H.id === ((K = C.metadata) == null ? void 0 : K.childLevelId);
|
|
2845
|
+
}
|
|
2846
|
+
);
|
|
2847
|
+
O && V(O.id);
|
|
2848
|
+
},
|
|
2849
|
+
[k, o, V, x]
|
|
2850
|
+
), re = ue(
|
|
2851
|
+
() => (j == null ? void 0 : j.data.reduce((C, I) => C + I.value, 0)) || 0,
|
|
2852
|
+
[j]
|
|
2853
|
+
), J = ue(
|
|
2854
|
+
() => M.map((C) => {
|
|
2855
|
+
var I;
|
|
2856
|
+
return ((I = o.find((O) => O.id === C)) == null ? void 0 : I.label) || C;
|
|
2857
|
+
}),
|
|
2858
|
+
[M, o]
|
|
2859
|
+
), te = () => {
|
|
2860
|
+
if (!j)
|
|
2861
|
+
return null;
|
|
2862
|
+
const C = j.data, I = Math.max(...C.map((H) => H.value)), O = Math.min(40, (w - 100) / C.length - 8);
|
|
2863
|
+
return /* @__PURE__ */ e("div", { className: "nice-drilldown-bars", children: C.map((H, K) => {
|
|
2864
|
+
const F = H.value / I * 100;
|
|
2865
|
+
return /* @__PURE__ */ y(
|
|
2866
|
+
"div",
|
|
2867
|
+
{
|
|
2868
|
+
className: "nice-drilldown-bar-row",
|
|
2869
|
+
onClick: () => G(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: `${F}%`,
|
|
2878
|
+
backgroundColor: H.color || p[K % p.length],
|
|
2879
|
+
height: O
|
|
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 (!j)
|
|
2891
|
+
return null;
|
|
2892
|
+
const C = j.data, I = g / 2, O = (w - 60) / 2 + 30, H = Math.min(I, O) - 40;
|
|
2893
|
+
let K = -90;
|
|
2894
|
+
const F = C.map((R, U) => {
|
|
2895
|
+
const Q = R.value / re * 360, B = K + Q, X = Q > 180 ? 1 : 0, ie = K * Math.PI / 180, ge = B * Math.PI / 180, fe = I + H * Math.cos(ie), xe = O + H * Math.sin(ie), ye = I + H * Math.cos(ge), Me = O + H * Math.sin(ge), we = (K + Q / 2) * Math.PI / 180, $e = I + H * 0.7 * Math.cos(we), Ce = O + H * 0.7 * Math.sin(we), Se = `M ${I} ${O} L ${fe} ${xe} A ${H} ${H} 0 ${X} 1 ${ye} ${Me} Z`;
|
|
2896
|
+
return K = B, {
|
|
2897
|
+
path: Se,
|
|
2898
|
+
color: R.color || p[U % p.length],
|
|
2899
|
+
label: R.label || `Item ${U + 1}`,
|
|
2900
|
+
value: R.value,
|
|
2901
|
+
percentage: (R.value / re * 100).toFixed(1),
|
|
2902
|
+
labelX: $e,
|
|
2903
|
+
labelY: Ce,
|
|
2904
|
+
item: R,
|
|
2905
|
+
index: U
|
|
2906
|
+
};
|
|
2907
|
+
});
|
|
2908
|
+
return /* @__PURE__ */ e("svg", { width: g, height: w - 40, className: "nice-drilldown-pie", children: /* @__PURE__ */ e("g", { children: F.map((R, U) => /* @__PURE__ */ y("g", { onClick: () => G(R.item, R.index), children: [
|
|
2909
|
+
/* @__PURE__ */ e(
|
|
2910
|
+
"path",
|
|
2911
|
+
{
|
|
2912
|
+
d: R.path,
|
|
2913
|
+
fill: R.color,
|
|
2914
|
+
stroke: "white",
|
|
2915
|
+
strokeWidth: 2,
|
|
2916
|
+
className: "nice-drilldown-pie-slice"
|
|
2917
|
+
}
|
|
2918
|
+
),
|
|
2919
|
+
N && parseFloat(R.percentage) > 5 && /* @__PURE__ */ y(
|
|
2920
|
+
"text",
|
|
2921
|
+
{
|
|
2922
|
+
x: R.labelX,
|
|
2923
|
+
y: R.labelY,
|
|
2924
|
+
textAnchor: "middle",
|
|
2925
|
+
dominantBaseline: "middle",
|
|
2926
|
+
fill: "white",
|
|
2927
|
+
fontSize: "12",
|
|
2928
|
+
fontWeight: "600",
|
|
2929
|
+
children: [
|
|
2930
|
+
R.percentage,
|
|
2931
|
+
"%"
|
|
2932
|
+
]
|
|
2933
|
+
}
|
|
2934
|
+
)
|
|
2935
|
+
] }, U)) }) });
|
|
2936
|
+
}, Y = () => {
|
|
2937
|
+
if (!j)
|
|
2938
|
+
return null;
|
|
2939
|
+
const C = j.data, I = Math.max(...C.map((K) => K.value)), O = Math.min(60, (g - 100) / C.length - 8), H = w - 100;
|
|
2940
|
+
return /* @__PURE__ */ e("svg", { width: g, height: w - 40, className: "nice-drilldown-columns", children: /* @__PURE__ */ y("g", { transform: "translate(50, 20)", children: [
|
|
2941
|
+
[0, 0.25, 0.5, 0.75, 1].map((K, F) => /* @__PURE__ */ y("g", { children: [
|
|
2942
|
+
/* @__PURE__ */ e(
|
|
2943
|
+
"line",
|
|
2944
|
+
{
|
|
2945
|
+
x1: 0,
|
|
2946
|
+
y1: H * (1 - K),
|
|
2947
|
+
x2: g - 80,
|
|
2948
|
+
y2: H * (1 - K),
|
|
2949
|
+
stroke: "var(--nice-border, #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: "var(--nice-text-secondary, #6b7280)",
|
|
2962
|
+
children: Math.round(I * K).toLocaleString()
|
|
2963
|
+
}
|
|
2964
|
+
)
|
|
2965
|
+
] }, F)),
|
|
2966
|
+
C.map((K, F) => {
|
|
2967
|
+
const R = K.value / I * H, U = F * ((g - 100) / C.length) + ((g - 100) / C.length - O) / 2;
|
|
2968
|
+
return /* @__PURE__ */ y("g", { onClick: () => G(K, F), children: [
|
|
2969
|
+
/* @__PURE__ */ e(
|
|
2970
|
+
"rect",
|
|
2971
|
+
{
|
|
2972
|
+
x: U,
|
|
2973
|
+
y: H - R,
|
|
2974
|
+
width: O,
|
|
2975
|
+
height: R,
|
|
2976
|
+
fill: K.color || p[F % p.length],
|
|
2977
|
+
rx: 4,
|
|
2978
|
+
className: "nice-drilldown-column-bar"
|
|
2979
|
+
}
|
|
2980
|
+
),
|
|
2981
|
+
/* @__PURE__ */ e(
|
|
2982
|
+
"text",
|
|
2983
|
+
{
|
|
2984
|
+
x: U + O / 2,
|
|
2985
|
+
y: H + 16,
|
|
2986
|
+
textAnchor: "middle",
|
|
2987
|
+
fontSize: "11",
|
|
2988
|
+
fill: "var(--nice-text, #374151)",
|
|
2989
|
+
children: (K.label || `${F + 1}`).slice(0, 10)
|
|
2990
|
+
}
|
|
2991
|
+
),
|
|
2992
|
+
N && /* @__PURE__ */ e(
|
|
2993
|
+
"text",
|
|
2994
|
+
{
|
|
2995
|
+
x: U + O / 2,
|
|
2996
|
+
y: H - R - 8,
|
|
2997
|
+
textAnchor: "middle",
|
|
2998
|
+
fontSize: "11",
|
|
2999
|
+
fill: "var(--nice-text, #374151)",
|
|
3000
|
+
fontWeight: "500",
|
|
3001
|
+
children: K.value.toLocaleString()
|
|
3002
|
+
}
|
|
3003
|
+
)
|
|
3004
|
+
] }, F);
|
|
3005
|
+
})
|
|
3006
|
+
] }) });
|
|
3007
|
+
};
|
|
3008
|
+
return /* @__PURE__ */ y(
|
|
3009
|
+
"div",
|
|
3010
|
+
{
|
|
3011
|
+
className: `nice-drilldown-chart ${b ? `animating ${D}` : ""} ${i || ""}`,
|
|
3012
|
+
style: { width: g, ...d },
|
|
3013
|
+
...s,
|
|
3014
|
+
children: [
|
|
3015
|
+
/* @__PURE__ */ y("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__ */ y(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 O = M.slice(0, I + 1);
|
|
3026
|
+
v(O), _(O[O.length - 1]);
|
|
3027
|
+
}
|
|
3028
|
+
},
|
|
3029
|
+
children: C
|
|
3030
|
+
}
|
|
3031
|
+
)
|
|
3032
|
+
] }, I)) })
|
|
3033
|
+
] }),
|
|
3034
|
+
/* @__PURE__ */ y("div", { className: "nice-drilldown-content", style: { height: w - 40 }, children: [
|
|
3035
|
+
n === "bar" && te(),
|
|
3036
|
+
n === "pie" && T(),
|
|
3037
|
+
n === "column" && Y()
|
|
3038
|
+
] }),
|
|
3039
|
+
$ && j && /* @__PURE__ */ e("div", { className: "nice-drilldown-legend", children: j.data.map((C, I) => /* @__PURE__ */ y("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: var(--nice-radius-lg, 8px);
|
|
3054
|
+
overflow: hidden;
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
.nice-drilldown-header {
|
|
3058
|
+
display: flex;
|
|
3059
|
+
align-items: center;
|
|
3060
|
+
gap: var(--nice-space-3, 12px);
|
|
3061
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
|
|
3062
|
+
border-bottom: 1px solid var(--border-color, #e5e7eb);
|
|
3063
|
+
min-height: 40px;
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
.nice-drilldown-back {
|
|
3067
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
3068
|
+
border: none;
|
|
3069
|
+
padding: var(--nice-space-1-5, 6px) var(--nice-space-3, 12px);
|
|
3070
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
3071
|
+
cursor: pointer;
|
|
3072
|
+
font-size: 13px;
|
|
3073
|
+
color: var(--nice-text, #374151);
|
|
3074
|
+
transition: background 0.2s;
|
|
3075
|
+
}
|
|
3076
|
+
|
|
3077
|
+
.nice-drilldown-back:hover {
|
|
3078
|
+
background: var(--nice-border, #e5e7eb);
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
.nice-drilldown-breadcrumbs {
|
|
3082
|
+
display: flex;
|
|
3083
|
+
align-items: center;
|
|
3084
|
+
gap: var(--nice-space-1, 4px);
|
|
3085
|
+
font-size: 13px;
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
.nice-drilldown-separator {
|
|
3089
|
+
color: var(--nice-text-muted, #9ca3af);
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3092
|
+
.nice-drilldown-crumb {
|
|
3093
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
3094
|
+
cursor: pointer;
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
.nice-drilldown-crumb:hover:not(.active) {
|
|
3098
|
+
color: var(--nice-primary, #3b82f6);
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3101
|
+
.nice-drilldown-crumb.active {
|
|
3102
|
+
color: var(--nice-text, #111827);
|
|
3103
|
+
font-weight: 500;
|
|
3104
|
+
cursor: default;
|
|
3105
|
+
}
|
|
3106
|
+
|
|
3107
|
+
.nice-drilldown-content {
|
|
3108
|
+
padding: var(--nice-space-4, 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: var(--nice-space-2, 8px);
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
.nice-drilldown-bar-row {
|
|
3131
|
+
display: flex;
|
|
3132
|
+
align-items: center;
|
|
3133
|
+
gap: var(--nice-space-3, 12px);
|
|
3134
|
+
cursor: pointer;
|
|
3135
|
+
padding: var(--nice-space-1, 4px) var(--nice-space-2, 8px);
|
|
3136
|
+
margin: -4px -8px;
|
|
3137
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
3138
|
+
transition: background 0.2s;
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
.nice-drilldown-bar-row:hover {
|
|
3142
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3145
|
+
.nice-drilldown-bar-label {
|
|
3146
|
+
width: 120px;
|
|
3147
|
+
font-size: 13px;
|
|
3148
|
+
color: var(--nice-text, #374151);
|
|
3149
|
+
overflow: hidden;
|
|
3150
|
+
text-overflow: ellipsis;
|
|
3151
|
+
white-space: nowrap;
|
|
3152
|
+
}
|
|
3153
|
+
|
|
3154
|
+
.nice-drilldown-bar-track {
|
|
3155
|
+
flex: 1;
|
|
3156
|
+
background: var(--nice-bg-secondary, #f3f4f6);
|
|
3157
|
+
border-radius: var(--nice-radius-md, 6px);
|
|
3158
|
+
overflow: hidden;
|
|
3159
|
+
}
|
|
3160
|
+
|
|
3161
|
+
.nice-drilldown-bar-fill {
|
|
3162
|
+
transition: width 0.3s ease;
|
|
3163
|
+
border-radius: var(--nice-radius-md, 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: var(--nice-text, #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: var(--nice-space-4, 16px);
|
|
3198
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 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: var(--nice-space-1-5, 6px);
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
.nice-drilldown-legend-color {
|
|
3209
|
+
width: 12px;
|
|
3210
|
+
height: 12px;
|
|
3211
|
+
border-radius: var(--nice-radius-sm, 3px);
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
.nice-drilldown-legend-label {
|
|
3215
|
+
font-size: 12px;
|
|
3216
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
3217
|
+
}
|
|
3218
|
+
` })
|
|
3219
|
+
]
|
|
3220
|
+
}
|
|
3221
|
+
);
|
|
3222
|
+
}
|
|
3223
|
+
);
|
|
3224
|
+
tt.displayName = "NiceDrillDownChart";
|
|
3225
|
+
const at = _e(
|
|
3226
|
+
(t, u) => {
|
|
3227
|
+
const {
|
|
3228
|
+
initialData: o,
|
|
3229
|
+
data: m,
|
|
3230
|
+
maxPoints: n = 60,
|
|
3231
|
+
updateInterval: g = 1e3,
|
|
3232
|
+
fetchData: w,
|
|
3233
|
+
width: A = 600,
|
|
3234
|
+
height: L = 200,
|
|
3235
|
+
chartType: c = "line",
|
|
3236
|
+
color: f = "var(--color-primary, #3b82f6)",
|
|
3237
|
+
showGrid: x = !0,
|
|
3238
|
+
showTimeAxis: p = !0,
|
|
3239
|
+
showCurrentValue: N = !0,
|
|
3240
|
+
title: $,
|
|
3241
|
+
valueFormatter: i = (U) => U.toFixed(2),
|
|
3242
|
+
timeFormatter: d = (U) => new Date(U).toLocaleTimeString(),
|
|
3243
|
+
onDataUpdate: s,
|
|
3244
|
+
paused: k,
|
|
3245
|
+
className: _,
|
|
3246
|
+
style: M,
|
|
3247
|
+
...v
|
|
3248
|
+
} = t, [b, l] = he(o ?? m ?? []), [D, r] = he(k || !1), j = Ne();
|
|
3249
|
+
Ae(() => {
|
|
3250
|
+
k !== void 0 && r(k);
|
|
3251
|
+
}, [k]), Ae(() => {
|
|
3252
|
+
if (D || !w)
|
|
3253
|
+
return;
|
|
3254
|
+
const U = async () => {
|
|
3255
|
+
try {
|
|
3256
|
+
const Q = await w();
|
|
3257
|
+
l((B) => {
|
|
3258
|
+
const X = [...B, Q].slice(-n);
|
|
3259
|
+
return s == null || s(X), X;
|
|
3260
|
+
});
|
|
3261
|
+
} catch (Q) {
|
|
3262
|
+
console.error("Failed to fetch realtime data:", Q);
|
|
3263
|
+
}
|
|
3264
|
+
};
|
|
3265
|
+
return j.current = setInterval(U, g), () => {
|
|
3266
|
+
j.current && clearInterval(j.current);
|
|
3267
|
+
};
|
|
3268
|
+
}, [D, w, g, n, s]);
|
|
3269
|
+
const V = oe(
|
|
3270
|
+
(U) => {
|
|
3271
|
+
l((Q) => {
|
|
3272
|
+
const B = [...Q, U].slice(-n);
|
|
3273
|
+
return s == null || s(B), B;
|
|
3274
|
+
});
|
|
3275
|
+
},
|
|
3276
|
+
[n, s]
|
|
3277
|
+
), Z = oe(() => {
|
|
3278
|
+
l([]), s == null || s([]);
|
|
3279
|
+
}, [s]), q = oe(() => r(!0), []), G = oe(() => r(!1), []);
|
|
3280
|
+
Le(
|
|
3281
|
+
u,
|
|
3282
|
+
() => ({
|
|
3283
|
+
addDataPoint: V,
|
|
3284
|
+
clearData: Z,
|
|
3285
|
+
pause: q,
|
|
3286
|
+
resume: G,
|
|
3287
|
+
getData: () => b
|
|
3288
|
+
}),
|
|
3289
|
+
[V, 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((U) => U.value), Y = T.length ? Math.min(...T) : 0, se = T.length ? Math.max(...T) : 100, de = (se - Y || 1) * 0.1, C = Y - de, I = se + de - C, O = (U) => {
|
|
3292
|
+
const Q = w ? n - 1 : Math.max(1, b.length - 1);
|
|
3293
|
+
return re.left + U / Q * J;
|
|
3294
|
+
}, H = (U) => re.top + te - (U - C) / I * te, K = b.map((U, Q) => `${O(Q)},${H(U.value)}`).join(" "), F = b.length > 0 ? `M ${O(0)},${re.top + te} L ${K} L ${O(b.length - 1)},${re.top + te} Z` : "", R = b.length > 0 ? b[b.length - 1].value : null;
|
|
3295
|
+
return /* @__PURE__ */ y(
|
|
3296
|
+
"div",
|
|
3297
|
+
{
|
|
3298
|
+
className: `nice-realtime-chart ${_ || ""}`,
|
|
3299
|
+
style: { width: A, ...M },
|
|
3300
|
+
...v,
|
|
3301
|
+
children: [
|
|
3302
|
+
$ && /* @__PURE__ */ y("div", { className: "nice-realtime-header", children: [
|
|
3303
|
+
/* @__PURE__ */ e("span", { className: "nice-realtime-title", children: $ }),
|
|
3304
|
+
/* @__PURE__ */ y("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 && R !== null && /* @__PURE__ */ e("span", { className: "nice-realtime-value", children: i(R) })
|
|
3314
|
+
] })
|
|
3315
|
+
] }),
|
|
3316
|
+
/* @__PURE__ */ y("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((U, Q) => {
|
|
3318
|
+
const B = re.top + te * (1 - U), X = C + I * U;
|
|
3319
|
+
return /* @__PURE__ */ y("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: "var(--nice-border, #e5e7eb)",
|
|
3328
|
+
strokeDasharray: U === 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: "var(--nice-text-secondary, #6b7280)",
|
|
3340
|
+
children: i(X)
|
|
3341
|
+
}
|
|
3342
|
+
)
|
|
3343
|
+
] }, Q);
|
|
3344
|
+
}) }),
|
|
3345
|
+
c === "area" && b.length > 0 && /* @__PURE__ */ e("path", { d: F, fill: f, fillOpacity: 0.2 }),
|
|
3346
|
+
b.length > 1 && /* @__PURE__ */ e(
|
|
3347
|
+
"polyline",
|
|
3348
|
+
{
|
|
3349
|
+
points: K,
|
|
3350
|
+
fill: "none",
|
|
3351
|
+
stroke: f,
|
|
3352
|
+
strokeWidth: 2,
|
|
3353
|
+
strokeLinecap: "round",
|
|
3354
|
+
strokeLinejoin: "round"
|
|
3355
|
+
}
|
|
3356
|
+
),
|
|
3357
|
+
b.length > 0 && /* @__PURE__ */ e(
|
|
3358
|
+
"circle",
|
|
3359
|
+
{
|
|
3360
|
+
cx: O(b.length - 1),
|
|
3361
|
+
cy: H(b[b.length - 1].value),
|
|
3362
|
+
r: 4,
|
|
3363
|
+
fill: f,
|
|
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((U) => b[U]).map((U) => /* @__PURE__ */ e(
|
|
3368
|
+
"text",
|
|
3369
|
+
{
|
|
3370
|
+
x: O(U),
|
|
3371
|
+
y: L - 8,
|
|
3372
|
+
textAnchor: "middle",
|
|
3373
|
+
fontSize: "10",
|
|
3374
|
+
fill: "var(--nice-text-secondary, #6b7280)",
|
|
3375
|
+
children: d(b[U].timestamp)
|
|
3376
|
+
},
|
|
3377
|
+
U
|
|
3378
|
+
)) })
|
|
3379
|
+
] }),
|
|
3380
|
+
/* @__PURE__ */ y("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: var(--nice-radius-lg, 8px);
|
|
3389
|
+
position: relative;
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
.nice-realtime-header {
|
|
3393
|
+
display: flex;
|
|
3394
|
+
justify-content: space-between;
|
|
3395
|
+
align-items: center;
|
|
3396
|
+
padding: var(--nice-space-3, 12px) var(--nice-space-4, 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: var(--nice-text, #111827);
|
|
3404
|
+
}
|
|
3405
|
+
|
|
3406
|
+
.nice-realtime-controls {
|
|
3407
|
+
display: flex;
|
|
3408
|
+
align-items: center;
|
|
3409
|
+
gap: var(--nice-space-3, 12px);
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3412
|
+
.nice-realtime-btn {
|
|
3413
|
+
background: none;
|
|
3414
|
+
border: none;
|
|
3415
|
+
cursor: pointer;
|
|
3416
|
+
font-size: 16px;
|
|
3417
|
+
padding: var(--nice-space-1, 4px);
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
.nice-realtime-value {
|
|
3421
|
+
font-size: 18px;
|
|
3422
|
+
font-weight: 600;
|
|
3423
|
+
color: ${f};
|
|
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: var(--nice-space-1-5, 6px);
|
|
3444
|
+
font-size: 11px;
|
|
3445
|
+
color: var(--nice-text-secondary, #6b7280);
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
.nice-realtime-status-dot {
|
|
3449
|
+
width: 8px;
|
|
3450
|
+
height: 8px;
|
|
3451
|
+
border-radius: var(--nice-radius-full, 50%);
|
|
3452
|
+
background: var(--nice-success, #22c55e);
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
.nice-realtime-status.paused .nice-realtime-status-dot {
|
|
3456
|
+
background: var(--nice-warning, #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: u,
|
|
3478
|
+
selectable: o,
|
|
3479
|
+
selectedKey: m,
|
|
3480
|
+
onSelect: n,
|
|
3481
|
+
direction: g = "top-down",
|
|
3482
|
+
collapsible: w = !0,
|
|
3483
|
+
className: A,
|
|
3484
|
+
style: L,
|
|
3485
|
+
id: c
|
|
3486
|
+
}, f) => {
|
|
3487
|
+
const x = Be(c), [p, N] = he(/* @__PURE__ */ new Set()), $ = oe((s) => {
|
|
3488
|
+
N((k) => {
|
|
3489
|
+
const _ = new Set(k);
|
|
3490
|
+
return _.has(s) ? _.delete(s) : _.add(s), _;
|
|
3491
|
+
});
|
|
3492
|
+
}, []), i = oe(
|
|
3493
|
+
(s) => {
|
|
3494
|
+
o && (n == null || n(s));
|
|
3495
|
+
},
|
|
3496
|
+
[o, n]
|
|
3497
|
+
), d = oe(
|
|
3498
|
+
(s) => {
|
|
3499
|
+
const k = p.has(s.key), _ = s.children && s.children.length > 0;
|
|
3500
|
+
return /* @__PURE__ */ y("li", { className: "nice-org-chart__item", children: [
|
|
3501
|
+
/* @__PURE__ */ y(
|
|
3502
|
+
"div",
|
|
3503
|
+
{
|
|
3504
|
+
className: `nice-org-chart__node${m === s.key ? " nice-org-chart__node--selected" : ""}`,
|
|
3505
|
+
onClick: () => i(s.key),
|
|
3506
|
+
role: o ? "button" : void 0,
|
|
3507
|
+
children: [
|
|
3508
|
+
u ? u(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, u, o, w, i, $]
|
|
3528
|
+
);
|
|
3529
|
+
return /* @__PURE__ */ e(
|
|
3530
|
+
"div",
|
|
3531
|
+
{
|
|
3532
|
+
ref: f,
|
|
3533
|
+
id: x,
|
|
3534
|
+
className: `nice-org-chart nice-org-chart--${g} ${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, u, o) {
|
|
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, g, w] = m(t), [A, L, c] = m(u), f = Math.round(n + (A - n) * o), x = Math.round(g + (L - g) * o), p = Math.round(w + (c - w) * o);
|
|
3551
|
+
return `rgb(${f},${x},${p})`;
|
|
3552
|
+
}
|
|
3553
|
+
const it = _e(
|
|
3554
|
+
({
|
|
3555
|
+
data: t,
|
|
3556
|
+
xLabels: u,
|
|
3557
|
+
yLabels: o,
|
|
3558
|
+
colors: m = ["var(--nice-primary-bg, #e0f2fe)", "var(--color-primary-active, #1d4ed8)"],
|
|
3559
|
+
onCellClick: n,
|
|
3560
|
+
cellSize: g = 40,
|
|
3561
|
+
showValues: w = !0,
|
|
3562
|
+
className: A,
|
|
3563
|
+
style: L,
|
|
3564
|
+
id: c
|
|
3565
|
+
}, f) => {
|
|
3566
|
+
const x = Be(c), { minVal: p, maxVal: N } = ue(() => {
|
|
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]), $ = oe(
|
|
3573
|
+
(i) => N === p ? 0.5 : (i - p) / (N - p),
|
|
3574
|
+
[p, N]
|
|
3575
|
+
);
|
|
3576
|
+
return /* @__PURE__ */ e("div", { ref: f, id: x, className: `nice-heatmap ${A || ""}`, style: L, children: /* @__PURE__ */ y("table", { className: "nice-heatmap__table", children: [
|
|
3577
|
+
u && /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ y("tr", { children: [
|
|
3578
|
+
o && /* @__PURE__ */ e("th", {}),
|
|
3579
|
+
u.map((i, d) => /* @__PURE__ */ e("th", { className: "nice-heatmap__header", children: i }, d))
|
|
3580
|
+
] }) }),
|
|
3581
|
+
/* @__PURE__ */ e("tbody", { children: t.map((i, d) => /* @__PURE__ */ y("tr", { children: [
|
|
3582
|
+
o && /* @__PURE__ */ e("th", { className: "nice-heatmap__row-label", children: o[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: g,
|
|
3590
|
+
height: g,
|
|
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, u) {
|
|
3607
|
+
const o = t.reduce((c, f) => c + f.value, 0);
|
|
3608
|
+
if (o === 0 || t.length === 0)
|
|
3609
|
+
return [];
|
|
3610
|
+
const m = [];
|
|
3611
|
+
let { x: n, y: g, w, h: A } = u;
|
|
3612
|
+
const L = [...t].sort((c, f) => f.value - c.value);
|
|
3613
|
+
for (const c of L) {
|
|
3614
|
+
const f = c.value / o;
|
|
3615
|
+
if (w >= A) {
|
|
3616
|
+
const x = w * f;
|
|
3617
|
+
m.push({ x: n, y: g, w: x, h: A, node: c }), n += x, w -= x;
|
|
3618
|
+
} else {
|
|
3619
|
+
const x = A * f;
|
|
3620
|
+
m.push({ x: n, y: g, w, h: x, node: c }), g += x, A -= x;
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
return m;
|
|
3624
|
+
}
|
|
3625
|
+
const ct = [
|
|
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
|
+
"var(--nice-success, #84cc16)"
|
|
3634
|
+
], ot = _e(
|
|
3635
|
+
({ data: t, width: u = 600, height: o = 400, onNodeClick: m, colors: n = ct, className: g, style: w, id: A }, L) => {
|
|
3636
|
+
const c = Be(A), f = ue(() => {
|
|
3637
|
+
const x = t.children ?? [t];
|
|
3638
|
+
return lt(x, { x: 0, y: 0, w: u, h: o });
|
|
3639
|
+
}, [t, u, o]);
|
|
3640
|
+
return /* @__PURE__ */ e("div", { ref: L, id: c, className: `nice-treemap ${g || ""}`, style: w, children: /* @__PURE__ */ e("svg", { width: u, height: o, className: "nice-treemap__svg", children: f.map((x, p) => /* @__PURE__ */ y(
|
|
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: "var(--nice-bg, #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
|
+
ot.displayName = "NiceTreeMap";
|
|
3677
|
+
const st = _e(
|
|
3678
|
+
({
|
|
3679
|
+
data: t,
|
|
3680
|
+
type: u = "candlestick",
|
|
3681
|
+
showVolume: o = !0,
|
|
3682
|
+
width: m = 800,
|
|
3683
|
+
height: n = 400,
|
|
3684
|
+
bullColor: g = "var(--color-success, #22c55e)",
|
|
3685
|
+
bearColor: w = "var(--color-error, #ef4444)",
|
|
3686
|
+
className: A,
|
|
3687
|
+
style: L,
|
|
3688
|
+
id: c
|
|
3689
|
+
}, f) => {
|
|
3690
|
+
const x = Be(c), p = { top: 20, right: 20, bottom: o ? 80 : 30, left: 60 }, N = m - p.left - p.right, $ = o ? 50 : 0, i = n - p.top - p.bottom - $, { minP: d, maxP: s, maxVol: k } = ue(() => {
|
|
3691
|
+
let l = 1 / 0, D = -1 / 0, r = 0;
|
|
3692
|
+
for (const j of t)
|
|
3693
|
+
j.low < l && (l = j.low), j.high > D && (D = j.high), j.volume && j.volume > r && (r = j.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), v = (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: f, id: x, className: `nice-stock-chart ${A || ""}`, style: L, children: /* @__PURE__ */ y("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__ */ y("g", { children: [
|
|
3700
|
+
/* @__PURE__ */ e(
|
|
3701
|
+
"line",
|
|
3702
|
+
{
|
|
3703
|
+
x1: p.left,
|
|
3704
|
+
x2: m - p.right,
|
|
3705
|
+
y1: v(D),
|
|
3706
|
+
y2: v(D),
|
|
3707
|
+
stroke: "var(--nice-border, #e5e7eb)",
|
|
3708
|
+
strokeDasharray: "2,2"
|
|
3709
|
+
}
|
|
3710
|
+
),
|
|
3711
|
+
/* @__PURE__ */ e("text", { x: p.left - 4, y: v(D) + 4, textAnchor: "end", fontSize: 10, fill: "var(--nice-text-secondary, #888)", children: D.toFixed(2) })
|
|
3712
|
+
] }, l);
|
|
3713
|
+
}),
|
|
3714
|
+
u === "line" ? /* @__PURE__ */ e(
|
|
3715
|
+
"polyline",
|
|
3716
|
+
{
|
|
3717
|
+
points: t.map((l, D) => `${M(D)},${v(l.close)}`).join(" "),
|
|
3718
|
+
fill: "none",
|
|
3719
|
+
stroke: g,
|
|
3720
|
+
strokeWidth: 1.5
|
|
3721
|
+
}
|
|
3722
|
+
) : t.map((l, D) => {
|
|
3723
|
+
const r = l.close >= l.open, j = r ? g : w, V = M(D);
|
|
3724
|
+
if (u === "ohlc")
|
|
3725
|
+
return /* @__PURE__ */ y("g", { children: [
|
|
3726
|
+
/* @__PURE__ */ e(
|
|
3727
|
+
"line",
|
|
3728
|
+
{
|
|
3729
|
+
x1: V,
|
|
3730
|
+
x2: V,
|
|
3731
|
+
y1: v(l.high),
|
|
3732
|
+
y2: v(l.low),
|
|
3733
|
+
stroke: j,
|
|
3734
|
+
strokeWidth: 1
|
|
3735
|
+
}
|
|
3736
|
+
),
|
|
3737
|
+
/* @__PURE__ */ e(
|
|
3738
|
+
"line",
|
|
3739
|
+
{
|
|
3740
|
+
x1: V - _ / 2,
|
|
3741
|
+
x2: V,
|
|
3742
|
+
y1: v(l.open),
|
|
3743
|
+
y2: v(l.open),
|
|
3744
|
+
stroke: j,
|
|
3745
|
+
strokeWidth: 1.5
|
|
3746
|
+
}
|
|
3747
|
+
),
|
|
3748
|
+
/* @__PURE__ */ e(
|
|
3749
|
+
"line",
|
|
3750
|
+
{
|
|
3751
|
+
x1: V,
|
|
3752
|
+
x2: V + _ / 2,
|
|
3753
|
+
y1: v(l.close),
|
|
3754
|
+
y2: v(l.close),
|
|
3755
|
+
stroke: j,
|
|
3756
|
+
strokeWidth: 1.5
|
|
3757
|
+
}
|
|
3758
|
+
)
|
|
3759
|
+
] }, D);
|
|
3760
|
+
const Z = v(Math.max(l.open, l.close)), q = v(Math.min(l.open, l.close));
|
|
3761
|
+
return /* @__PURE__ */ y("g", { children: [
|
|
3762
|
+
/* @__PURE__ */ e(
|
|
3763
|
+
"line",
|
|
3764
|
+
{
|
|
3765
|
+
x1: V,
|
|
3766
|
+
x2: V,
|
|
3767
|
+
y1: v(l.high),
|
|
3768
|
+
y2: v(l.low),
|
|
3769
|
+
stroke: j,
|
|
3770
|
+
strokeWidth: 1
|
|
3771
|
+
}
|
|
3772
|
+
),
|
|
3773
|
+
/* @__PURE__ */ e(
|
|
3774
|
+
"rect",
|
|
3775
|
+
{
|
|
3776
|
+
x: V - _ / 2,
|
|
3777
|
+
y: Z,
|
|
3778
|
+
width: _,
|
|
3779
|
+
height: Math.max(q - Z, 1),
|
|
3780
|
+
fill: r ? "transparent" : j,
|
|
3781
|
+
stroke: j,
|
|
3782
|
+
strokeWidth: 1
|
|
3783
|
+
}
|
|
3784
|
+
)
|
|
3785
|
+
] }, D);
|
|
3786
|
+
}),
|
|
3787
|
+
o && 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 ? g : 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: "var(--nice-text-secondary, #888)",
|
|
3812
|
+
children: l.date
|
|
3813
|
+
},
|
|
3814
|
+
`l${D}`
|
|
3815
|
+
))
|
|
3816
|
+
] }) });
|
|
3817
|
+
}
|
|
3818
|
+
);
|
|
3819
|
+
st.displayName = "NiceStockChart";
|
|
3820
|
+
export {
|
|
3821
|
+
ut as A,
|
|
3822
|
+
wt as B,
|
|
3823
|
+
ve as C,
|
|
3824
|
+
kt as D,
|
|
3825
|
+
Je as N,
|
|
3826
|
+
$t as a,
|
|
3827
|
+
rt as b,
|
|
3828
|
+
st as c,
|
|
3829
|
+
ot as d,
|
|
3830
|
+
it as e,
|
|
3831
|
+
Qe as f,
|
|
3832
|
+
_t as g,
|
|
3833
|
+
yt as h,
|
|
3834
|
+
bt as i,
|
|
3835
|
+
vt as j,
|
|
3836
|
+
xt as k,
|
|
3837
|
+
pt as l,
|
|
3838
|
+
ft as m,
|
|
3839
|
+
gt as n,
|
|
3840
|
+
je as o,
|
|
3841
|
+
tt as q,
|
|
3842
|
+
qe as s,
|
|
3843
|
+
at as u
|
|
3844
|
+
};
|