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