@nice2dev/ui 1.0.5 → 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.
Files changed (130) hide show
  1. package/README.md +253 -207
  2. package/dist/NiceAPIFlow.doc-DnQLPUie.js +30 -0
  3. package/dist/NiceAPIFlow.doc-Dx4qw1lm.cjs +6 -0
  4. package/dist/NiceBranchManager.doc-BXjiENlD.cjs +6 -0
  5. package/dist/NiceBranchManager.doc-xLB82YwU.js +30 -0
  6. package/dist/NiceButton-B5RXLDwI.cjs +1 -0
  7. package/dist/NiceButton-CDiS45Ya.cjs +1 -0
  8. package/dist/NiceButton-D9l39Rs7.js +595 -0
  9. package/dist/NiceButton-DmTHNHet.js +450 -0
  10. package/dist/NiceCodeTemplate.doc-BWxTE4C_.cjs +6 -0
  11. package/dist/NiceCodeTemplate.doc-CA2U5F-v.js +30 -0
  12. package/dist/NiceDataBranchGraph.doc-CkitupWc.js +29 -0
  13. package/dist/NiceDataBranchGraph.doc-DDUgipqH.cjs +5 -0
  14. package/dist/NiceDataBranchManager.doc-B0ODKOs4.js +30 -0
  15. package/dist/NiceDataBranchManager.doc-CC5o8ihs.cjs +6 -0
  16. package/dist/NiceDataConflictResolver.doc-CdzScNie.cjs +5 -0
  17. package/dist/NiceDataConflictResolver.doc-V8vxYAeo.js +29 -0
  18. package/dist/NiceDataDiffViewer.doc-CR14Bq3A.cjs +6 -0
  19. package/dist/NiceDataDiffViewer.doc-w2I2QjhX.js +30 -0
  20. package/dist/NiceDataMapper.doc-C7jSyHRM.js +30 -0
  21. package/dist/NiceDataMapper.doc-DXjQHz87.cjs +6 -0
  22. package/dist/NiceDataMergeBuilder.doc-CV32WC_w.cjs +6 -0
  23. package/dist/NiceDataMergeBuilder.doc-DtuYb3nx.js +30 -0
  24. package/dist/NiceDataSnapshot.doc-CFLkY3ry.js +30 -0
  25. package/dist/NiceDataSnapshot.doc-CpZyQ17u.cjs +6 -0
  26. package/dist/NiceErrorBoundary-BAeqfoSc.cjs +1 -0
  27. package/dist/NiceErrorBoundary-D1hh5GGe.js +732 -0
  28. package/dist/NiceErrorBoundary-Dta4TGee.cjs +1 -0
  29. package/dist/NiceErrorBoundary-niMx1aSJ.js +837 -0
  30. package/dist/NiceEventOrchestrator.doc-C4SJfIDV.js +30 -0
  31. package/dist/NiceEventOrchestrator.doc-CxjsLxBG.cjs +6 -0
  32. package/dist/NiceGitBlame.doc-BG3_K9_0.cjs +6 -0
  33. package/dist/NiceGitBlame.doc-DrJABEat.js +30 -0
  34. package/dist/NiceGitConflictResolver.doc-BK7hAfz6.js +30 -0
  35. package/dist/NiceGitConflictResolver.doc-CgroGM9_.cjs +6 -0
  36. package/dist/NiceGitDiffViewer.doc-BAwgcY_3.cjs +6 -0
  37. package/dist/NiceGitDiffViewer.doc-BXKJeP-E.js +30 -0
  38. package/dist/NiceGitGraph.doc-B-WtGuzn.cjs +5 -0
  39. package/dist/NiceGitGraph.doc-DxnDPCgC.js +29 -0
  40. package/dist/NiceGitHooks.doc-BrEizvMp.js +29 -0
  41. package/dist/NiceGitHooks.doc-C4EdV5zj.cjs +5 -0
  42. package/dist/NiceMergeRequestBuilder.doc-C5p8mYuh.cjs +6 -0
  43. package/dist/NiceMergeRequestBuilder.doc-Ct9RCmU8.js +30 -0
  44. package/dist/NiceModuleLifecyclePanel-BapdidD6.js +4776 -0
  45. package/dist/NiceModuleLifecyclePanel-Brg1RLwi.cjs +1 -0
  46. package/dist/NiceModuleLifecyclePanel-CsFsm534.cjs +1 -0
  47. package/dist/NiceModuleLifecyclePanel-I_TXRiiY.js +5053 -0
  48. package/dist/NicePinCodeInput-4q8yULuo.js +13359 -0
  49. package/dist/NicePinCodeInput-CrMfdxxc.js +15287 -0
  50. package/dist/NicePinCodeInput-D0aF9MK8.cjs +692 -0
  51. package/dist/NicePinCodeInput-eD2q8nGa.cjs +692 -0
  52. package/dist/NicePinCodeInput.css +1 -0
  53. package/dist/NicePipelineEditor.doc-0eGt8zbX.cjs +5 -0
  54. package/dist/NicePipelineEditor.doc-DTmaOebn.js +29 -0
  55. package/dist/NicePipelineMonitor.doc-67CmsRcf.cjs +5 -0
  56. package/dist/NicePipelineMonitor.doc-mSMdhuG8.js +29 -0
  57. package/dist/NiceSavedQueryPanel-BZNvqSQW.cjs +596 -0
  58. package/dist/NiceSavedQueryPanel-CUAsdOjJ.js +6190 -0
  59. package/dist/NiceSavedQueryPanel-DUw8plYP.js +5666 -0
  60. package/dist/NiceSavedQueryPanel-xpk09zy1.cjs +596 -0
  61. package/dist/NiceSavedQueryPanel.css +1 -0
  62. package/dist/NiceStateDesigner.doc-B36u0hNU.js +29 -0
  63. package/dist/NiceStateDesigner.doc-MPmvNHSx.cjs +5 -0
  64. package/dist/NiceStockChart-CHlOnWzN.cjs +287 -0
  65. package/dist/NiceStockChart-Cpmv9_Cc.js +2341 -0
  66. package/dist/NiceStockChart.css +1 -0
  67. package/dist/NiceTestBuilder.doc-BFInj8GJ.js +30 -0
  68. package/dist/NiceTestBuilder.doc-CB03U_uR.cjs +6 -0
  69. package/dist/NiceToggle-C1UKGXmJ.js +209 -0
  70. package/dist/NiceToggle-CaY1u82g.js +277 -0
  71. package/dist/NiceToggle-DFJFQv_Z.cjs +1 -0
  72. package/dist/NiceToggle-lVi-ETi0.cjs +1 -0
  73. package/dist/NiceWindow-D1awkyFl.js +1636 -0
  74. package/dist/NiceWindow-IdHAcP70.cjs +1 -0
  75. package/dist/NiceWindow-SiCaREbq.js +1408 -0
  76. package/dist/NiceWindow-yARTUJsg.cjs +1 -0
  77. package/dist/charts-Bx_kNBsE.js +4280 -0
  78. package/dist/charts-DECVsCHX.cjs +754 -0
  79. package/dist/charts.cjs +1 -0
  80. package/dist/charts.css +1 -0
  81. package/dist/charts.d.ts +1043 -0
  82. package/dist/charts.mjs +23 -0
  83. package/dist/core-BZBTsGWN.cjs +96 -0
  84. package/dist/core-BpghV7Ls.js +17555 -0
  85. package/dist/core-CfXsl755.js +16305 -0
  86. package/dist/core-DGJSUW64.cjs +96 -0
  87. package/dist/data-branching-De4ExX-S.cjs +1 -0
  88. package/dist/data-branching-DiRfob1f.js +6071 -0
  89. package/dist/data-branching.cjs +1 -0
  90. package/dist/data-branching.d.ts +401 -0
  91. package/dist/data-branching.mjs +9 -0
  92. package/dist/data.cjs +1 -0
  93. package/dist/data.d.ts +2003 -0
  94. package/dist/data.mjs +21 -0
  95. package/dist/devops-BnYinjkT.cjs +17 -0
  96. package/dist/devops-Ckh57eti.js +7198 -0
  97. package/dist/devops.cjs +1 -0
  98. package/dist/devops.d.ts +758 -0
  99. package/dist/devops.mjs +12 -0
  100. package/dist/editors.cjs +1 -0
  101. package/dist/editors.d.ts +2728 -0
  102. package/dist/editors.mjs +66 -0
  103. package/dist/feedback.cjs +1 -0
  104. package/dist/feedback.d.ts +339 -0
  105. package/dist/feedback.mjs +16 -0
  106. package/dist/index-C853adw1.cjs +6199 -0
  107. package/dist/index-CBIZ6mTQ.cjs +5734 -0
  108. package/dist/index-CIl98Vbm.js +72951 -0
  109. package/dist/index-CNwVELPJ.js +62857 -0
  110. package/dist/index-CUx_-gKK.cjs +1 -0
  111. package/dist/index-x8mRM4Jc.js +17 -0
  112. package/dist/index.cjs +1 -7866
  113. package/dist/index.css +1 -0
  114. package/dist/index.d.ts +4888 -180
  115. package/dist/index.mjs +1021 -105889
  116. package/dist/lazy.cjs +1 -0
  117. package/dist/lazy.d.ts +1880 -0
  118. package/dist/lazy.mjs +98 -0
  119. package/dist/navigation.cjs +1 -0
  120. package/dist/navigation.d.ts +1862 -0
  121. package/dist/navigation.mjs +576 -0
  122. package/dist/no-code-BCuadkm4.cjs +332 -0
  123. package/dist/no-code-TL7PyulA.js +7005 -0
  124. package/dist/no-code.cjs +1 -0
  125. package/dist/no-code.d.ts +870 -0
  126. package/dist/no-code.mjs +13 -0
  127. package/dist/overlays.cjs +1 -0
  128. package/dist/overlays.d.ts +706 -0
  129. package/dist/overlays.mjs +482 -0
  130. package/package.json +51 -1
@@ -0,0 +1,2341 @@
1
+ import { jsxs as k, jsx as e, Fragment as Be } from "react/jsx-runtime";
2
+ import { useRef as be, useState as ie, useMemo as me, useCallback as te, forwardRef as ve, useEffect as $e, useImperativeHandle as Ie } from "react";
3
+ import { k as Le, n as We, u as ke } from "./core-CfXsl755.js";
4
+ import { N as Pe } from "./index-x8mRM4Jc.js";
5
+ const Ne = ["#3b82f6", "#ef4444", "#22c55e", "#f59e0b", "#8b5cf6", "#ec4899", "#06b6d4", "#84cc16"], De = ({
6
+ series: t,
7
+ categories: a,
8
+ width: d = 600,
9
+ height: c = 400,
10
+ title: r,
11
+ showLegend: u = !0,
12
+ showGrid: i = !0,
13
+ yAxisLabel: m,
14
+ xAxisLabel: C,
15
+ stacked: l,
16
+ zoomable: v,
17
+ crosshair: f,
18
+ annotations: S,
19
+ legendInteractive: y,
20
+ onDataPointClick: p,
21
+ exportable: o,
22
+ className: s,
23
+ style: h
24
+ }) => {
25
+ const w = be(null), [b, A] = ie(/* @__PURE__ */ new Set()), [N, I] = ie(null), [g, T] = ie(null), [x, O] = ie(!1), B = be(null), R = me(
26
+ () => t.filter(($) => !b.has($.name)),
27
+ [t, b]
28
+ ), G = te(($) => {
29
+ y && A((E) => {
30
+ const Y = new Set(E);
31
+ return Y.has($) ? Y.delete($) : Y.add($), Y;
32
+ });
33
+ }, [y]), j = { top: r ? 40 : 20, right: 20, bottom: C ? 60 : 40, left: m ? 60 : 50 }, W = d - j.left - j.right, U = c - j.top - j.bottom, Z = R[0]?.data.length ?? t[0]?.data.length ?? 0, X = g?.start ?? 0, K = g?.end ?? Z, ee = K - X, he = me(
34
+ () => R.map(($) => ({ ...$, data: $.data.slice(X, K) })),
35
+ [R, X, K]
36
+ ), ne = me(
37
+ () => a?.slice(X, K),
38
+ [a, X, K]
39
+ ), { minY: D, maxY: P, yTicks: re } = me(() => {
40
+ let $;
41
+ if (l) {
42
+ $ = [];
43
+ for (let _ = 0; _ < ee; _++)
44
+ $.push(he.reduce((V, ae) => V + (ae.data[_] || 0), 0));
45
+ } else
46
+ $ = he.flatMap((_) => _.data);
47
+ $.length === 0 && ($ = [0]);
48
+ const E = Math.min(0, ...$), Y = Math.max(0, ...$), ce = Y - E || 1, oe = Math.pow(10, Math.floor(Math.log10(ce))) || 1, n = Math.floor(E / oe) * oe, M = Math.ceil(Y / oe) * oe, z = [];
49
+ for (let _ = n; _ <= M; _ += oe) z.push(Math.round(_ * 1e6) / 1e6);
50
+ return z.length < 2 && z.push(M), { minY: n, maxY: M, yTicks: z };
51
+ }, [he, ee, l]), F = ($) => U - ($ - D) / (P - D || 1) * U, q = ($) => ($ + 0.5) / ee * W, de = ee > 0 ? W / ee / (l ? 1.5 : Math.max(R.length, 1) * 1.5) : 20, xe = te(($) => {
52
+ if (!v) return;
53
+ $.preventDefault();
54
+ const E = g ?? { start: 0, end: Z }, Y = E.end - E.start, ce = (E.start + E.end) / 2, oe = $.deltaY > 0 ? 1.2 : 0.8, n = Math.max(2, Math.min(Z, Math.round(Y * oe))), M = Math.max(0, Math.round(ce - n / 2)), z = Math.min(Z, M + n);
55
+ T({ start: M, end: z });
56
+ }, [v, g, Z]), ye = te(($) => {
57
+ v && (O(!0), B.current = { x: $.clientX, range: g ?? { start: 0, end: Z } });
58
+ }, [v, g, Z]), L = te(($) => {
59
+ const E = w.current?.getBoundingClientRect();
60
+ if (E && I({ x: $.clientX - E.left - j.left, y: $.clientY - E.top - j.top }), x && B.current && v) {
61
+ const Y = $.clientX - B.current.x, ce = W / ee, oe = -Math.round(Y / ce), n = B.current.range, M = n.end - n.start;
62
+ let z = n.start + oe;
63
+ z < 0 && (z = 0), z + M > Z && (z = Z - M), T({ start: z, end: z + M });
64
+ }
65
+ }, [x, v, W, ee, Z, j.left, j.top]), H = te(() => {
66
+ O(!1), B.current = null;
67
+ }, []), J = te(() => {
68
+ I(null), O(!1), B.current = null;
69
+ }, []), pe = te(() => {
70
+ const $ = w.current;
71
+ if (!$) return;
72
+ const E = new XMLSerializer().serializeToString($), Y = document.createElement("canvas");
73
+ Y.width = d, Y.height = c + (u ? 30 : 0);
74
+ const ce = Y.getContext("2d");
75
+ if (!ce) return;
76
+ const oe = new Image();
77
+ oe.onload = () => {
78
+ ce.fillStyle = "#fff", ce.fillRect(0, 0, Y.width, Y.height), ce.drawImage(oe, 0, 0);
79
+ const n = document.createElement("a");
80
+ n.download = "chart.png", n.href = Y.toDataURL("image/png"), n.click();
81
+ }, oe.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(E);
82
+ }, [d, c, u]);
83
+ return /* @__PURE__ */ k("div", { className: `nice-chart ${s || ""}`, style: h, children: [
84
+ o && /* @__PURE__ */ e("button", { type: "button", className: "nice-chart__export-btn", onClick: pe, title: "Export PNG", children: "📷" }),
85
+ /* @__PURE__ */ k(
86
+ "svg",
87
+ {
88
+ ref: w,
89
+ width: d,
90
+ height: c + (u ? 30 : 0),
91
+ className: "nice-chart__svg",
92
+ onWheel: xe,
93
+ onMouseDown: ye,
94
+ onMouseMove: L,
95
+ onMouseUp: H,
96
+ onMouseLeave: J,
97
+ children: [
98
+ /* @__PURE__ */ k("g", { transform: `translate(${j.left},${j.top})`, children: [
99
+ r && /* @__PURE__ */ e("text", { x: W / 2, y: -10, textAnchor: "middle", className: "nice-chart__title", children: r }),
100
+ i && re.map(($) => /* @__PURE__ */ k("g", { children: [
101
+ /* @__PURE__ */ e("line", { x1: 0, y1: F($), x2: W, y2: F($), className: "nice-chart__grid-line" }),
102
+ /* @__PURE__ */ e("text", { x: -8, y: F($) + 4, textAnchor: "end", className: "nice-chart__axis-label", children: $ })
103
+ ] }, $)),
104
+ ne && ne.map(($, E) => /* @__PURE__ */ e("text", { x: q(E), y: U + 20, textAnchor: "middle", className: "nice-chart__axis-label", children: $ }, E)),
105
+ m && /* @__PURE__ */ e("text", { x: -j.left + 14, y: U / 2, textAnchor: "middle", transform: `rotate(-90, -${j.left - 14}, ${U / 2})`, className: "nice-chart__axis-title", children: m }),
106
+ C && /* @__PURE__ */ e("text", { x: W / 2, y: U + 45, textAnchor: "middle", className: "nice-chart__axis-title", children: C }),
107
+ /* @__PURE__ */ e("line", { x1: 0, y1: 0, x2: 0, y2: U, className: "nice-chart__axis" }),
108
+ /* @__PURE__ */ e("line", { x1: 0, y1: U, x2: W, y2: U, className: "nice-chart__axis" }),
109
+ S?.map(($, E) => {
110
+ if ($.type === "line") {
111
+ const Y = F($.value);
112
+ return /* @__PURE__ */ k("g", { children: [
113
+ /* @__PURE__ */ e("line", { x1: 0, y1: Y, x2: W, y2: Y, stroke: $.color || "#ef4444", strokeWidth: 1.5, strokeDasharray: $.dash || "6,3" }),
114
+ $.label && /* @__PURE__ */ e("text", { x: W + 4, y: Y + 4, className: "nice-chart__annotation-label", fill: $.color || "#ef4444", children: $.label })
115
+ ] }, E);
116
+ }
117
+ return /* @__PURE__ */ e("text", { x: q($.value), y: -4, textAnchor: "middle", className: "nice-chart__annotation-label", fill: $.color || "#6b7280", children: $.label }, E);
118
+ }),
119
+ f && N && N.x >= 0 && N.x <= W && N.y >= 0 && N.y <= U && /* @__PURE__ */ k(Be, { children: [
120
+ /* @__PURE__ */ e("line", { x1: N.x, y1: 0, x2: N.x, y2: U, stroke: "#9ca3af", strokeWidth: 1, strokeDasharray: "4,2" }),
121
+ /* @__PURE__ */ e("line", { x1: 0, y1: N.y, x2: W, y2: N.y, stroke: "#9ca3af", strokeWidth: 1, strokeDasharray: "4,2" })
122
+ ] }),
123
+ he.map(($, E) => {
124
+ const Y = $.color || Ne[E % Ne.length], ce = $.type || "bar";
125
+ if (ce === "bar")
126
+ return /* @__PURE__ */ e("g", { children: $.data.map((n, M) => {
127
+ let z, _;
128
+ if (l) {
129
+ const ae = he.slice(0, E).reduce((ue, se) => ue + (se.data[M] || 0), 0);
130
+ z = F(ae + n), _ = F(ae) - z;
131
+ } else
132
+ z = F(Math.max(0, n)), _ = Math.abs(F(n) - F(0));
133
+ const V = l ? q(M) - de / 2 : q(M) - he.length * de / 2 + E * de;
134
+ return /* @__PURE__ */ e(
135
+ "rect",
136
+ {
137
+ x: V,
138
+ y: z,
139
+ width: de * 0.9,
140
+ height: Math.max(0, _),
141
+ fill: Y,
142
+ rx: 2,
143
+ style: p ? { cursor: "pointer" } : void 0,
144
+ onClick: p ? () => p($.name, X + M, n) : void 0,
145
+ children: /* @__PURE__ */ e("title", { children: `${$.name}: ${n}` })
146
+ },
147
+ M
148
+ );
149
+ }) }, $.name);
150
+ const oe = $.data.map((n, M) => `${q(M)},${F(n)}`);
151
+ return /* @__PURE__ */ k("g", { children: [
152
+ ce === "area" && /* @__PURE__ */ e(
153
+ "polygon",
154
+ {
155
+ points: `${q(0)},${F(0)} ${oe.join(" ")} ${q(ee - 1)},${F(0)}`,
156
+ fill: Y,
157
+ opacity: 0.15
158
+ }
159
+ ),
160
+ /* @__PURE__ */ e("polyline", { points: oe.join(" "), fill: "none", stroke: Y, strokeWidth: 2 }),
161
+ $.data.map((n, M) => /* @__PURE__ */ e(
162
+ "circle",
163
+ {
164
+ cx: q(M),
165
+ cy: F(n),
166
+ r: 3,
167
+ fill: Y,
168
+ style: p ? { cursor: "pointer" } : void 0,
169
+ onClick: p ? () => p($.name, X + M, n) : void 0,
170
+ children: /* @__PURE__ */ e("title", { children: `${$.name}: ${n}` })
171
+ },
172
+ M
173
+ ))
174
+ ] }, $.name);
175
+ })
176
+ ] }),
177
+ u && /* @__PURE__ */ e("g", { transform: `translate(${j.left}, ${c})`, children: t.map(($, E) => {
178
+ const Y = E * 120, ce = b.has($.name);
179
+ return /* @__PURE__ */ k(
180
+ "g",
181
+ {
182
+ transform: `translate(${Y}, 10)`,
183
+ style: y ? { cursor: "pointer" } : void 0,
184
+ onClick: () => G($.name),
185
+ opacity: ce ? 0.35 : 1,
186
+ children: [
187
+ /* @__PURE__ */ e("rect", { width: 12, height: 12, rx: 2, fill: $.color || Ne[E % Ne.length] }),
188
+ /* @__PURE__ */ e(
189
+ "text",
190
+ {
191
+ x: 16,
192
+ y: 10,
193
+ className: "nice-chart__legend-text",
194
+ style: ce ? { textDecoration: "line-through" } : void 0,
195
+ children: $.name
196
+ }
197
+ )
198
+ ]
199
+ },
200
+ $.name
201
+ );
202
+ }) })
203
+ ]
204
+ }
205
+ )
206
+ ] });
207
+ }, rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
208
+ __proto__: null,
209
+ NiceChart: De
210
+ }, Symbol.toStringTag, { value: "Module" }));
211
+ function Re(t) {
212
+ if (!t.length)
213
+ return { categories: [], numericFields: [], sampleValues: {} };
214
+ const a = t[0], d = [], c = {};
215
+ let r = null;
216
+ for (const [i, m] of Object.entries(a))
217
+ typeof m == "number" ? (d.push(i), c[i] = t.map((C) => Number(C[i]) || 0)) : !r && (typeof m == "string" || m instanceof Date) && (r = i);
218
+ return { categories: r ? t.map((i) => String(i[r] || "")) : t.map((i, m) => `Item ${m + 1}`), numericFields: d, sampleValues: c };
219
+ }
220
+ function je(t, a) {
221
+ const { categories: d, numericFields: c, sampleValues: r } = Re(t);
222
+ return { series: c.map((i, m) => ({
223
+ name: i.replace(/([A-Z])/g, " $1").replace(/^./, (C) => C.toUpperCase()).trim(),
224
+ data: r[i],
225
+ type: a === "area" ? "area" : a === "line" ? "line" : "bar"
226
+ })), categories: d };
227
+ }
228
+ const ct = ve(function(a, d) {
229
+ const {
230
+ rawData: c,
231
+ enableAI: r = !0,
232
+ aiModel: u,
233
+ enableAutoType: i = !0,
234
+ enableInsights: m = !0,
235
+ dataDescription: C,
236
+ onChartSuggestion: l,
237
+ onInsights: v,
238
+ showAIToolbar: f = !0,
239
+ showInsightsOnLoad: S = !1,
240
+ series: y,
241
+ categories: p,
242
+ ...o
243
+ } = a, [s, h] = ie("bar"), [w, b] = ie(null), [A, N] = ie([]), [I, g] = ie(S), [T, x] = ie(null), { t: O } = Pe(), B = Le(), { suggestChartType: R, generateInsights: G, isLoading: j } = We(), W = r && B.isConfigured, { series: U, categories: Z } = c ? je(c, T || s) : { series: y || [], categories: p }, X = te(async () => {
244
+ if (!W || !i)
245
+ return { type: "bar", reason: "Default", config: {} };
246
+ const D = c || (y?.length ? y.flatMap((P) => P.data.map((re, F) => ({ [P.name]: re, index: F }))) : []);
247
+ try {
248
+ const P = await R(D, C), re = {
249
+ type: P.type,
250
+ reason: P.reason,
251
+ config: P.config
252
+ };
253
+ return b(re), h(re.type), l?.(re), re;
254
+ } catch {
255
+ return { type: "bar", reason: "Default fallback", config: {} };
256
+ }
257
+ }, [W, i, c, y, C, R, l]), K = te(async () => {
258
+ if (!W || !m) return [];
259
+ const D = c || (y?.length ? y.flatMap((P) => P.data.map((re, F) => ({ [P.name]: re, category: p?.[F] || F }))) : []);
260
+ try {
261
+ const P = await G(D, T || s);
262
+ return N(P), v?.(P), P;
263
+ } catch {
264
+ return [];
265
+ }
266
+ }, [W, m, c, y, p, s, T, G, v]), ee = te(() => T || s, [T, s]);
267
+ $e(() => {
268
+ W && i && (c?.length || y?.length) && X();
269
+ }, [W, i, c, y]), Ie(d, () => ({
270
+ getSuggestion: X,
271
+ generateInsights: K,
272
+ getCurrentType: ee
273
+ }));
274
+ const he = [
275
+ { type: "bar", icon: "📊", label: "Bar" },
276
+ { type: "line", icon: "📈", label: "Line" },
277
+ { type: "area", icon: "🏔️", label: "Area" },
278
+ { type: "pie", icon: "🥧", label: "Pie" },
279
+ { type: "donut", icon: "🍩", label: "Donut" },
280
+ { type: "scatter", icon: "⭐", label: "Scatter" }
281
+ ], ne = T || s;
282
+ return /* @__PURE__ */ k("div", { className: "nice-chart-ai", "data-testid": a["data-testid"], children: [
283
+ f && W && /* @__PURE__ */ k("div", { className: "nice-chart-ai__toolbar", children: [
284
+ /* @__PURE__ */ k("div", { className: "nice-chart-ai__toolbar-left", children: [
285
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__badge", children: "AI" }),
286
+ w && /* @__PURE__ */ k("div", { className: "nice-chart-ai__suggestion", children: [
287
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__suggestion-icon", children: "💡" }),
288
+ /* @__PURE__ */ k("span", { className: "nice-chart-ai__suggestion-text", children: [
289
+ O("chartAI.suggestedType", "Suggested:"),
290
+ " ",
291
+ w.type
292
+ ] }),
293
+ /* @__PURE__ */ k("span", { className: "nice-chart-ai__suggestion-reason", title: w.reason, children: [
294
+ "(",
295
+ w.reason,
296
+ ")"
297
+ ] })
298
+ ] }),
299
+ j && /* @__PURE__ */ e("span", { className: "nice-chart-ai__loading", children: O("chartAI.analyzing", "Analyzing...") })
300
+ ] }),
301
+ /* @__PURE__ */ e("div", { className: "nice-chart-ai__toolbar-center", children: /* @__PURE__ */ e("div", { className: "nice-chart-ai__type-selector", children: he.filter((D) => ["bar", "line", "area"].includes(D.type)).map(({ type: D, icon: P, label: re }) => /* @__PURE__ */ e(
302
+ "button",
303
+ {
304
+ type: "button",
305
+ className: `nice-chart-ai__type-btn ${ne === D ? "nice-chart-ai__type-btn--active" : ""}`,
306
+ onClick: () => x(D),
307
+ title: re,
308
+ children: P
309
+ },
310
+ D
311
+ )) }) }),
312
+ /* @__PURE__ */ k("div", { className: "nice-chart-ai__toolbar-right", children: [
313
+ /* @__PURE__ */ k(
314
+ "button",
315
+ {
316
+ type: "button",
317
+ className: "nice-chart-ai__auto-btn",
318
+ onClick: () => X(),
319
+ disabled: j,
320
+ title: O("chartAI.autoDetect", "Auto-detect best chart type"),
321
+ children: [
322
+ "🔮 ",
323
+ O("chartAI.auto", "Auto")
324
+ ]
325
+ }
326
+ ),
327
+ m && /* @__PURE__ */ k(
328
+ "button",
329
+ {
330
+ type: "button",
331
+ className: "nice-chart-ai__insights-btn",
332
+ onClick: () => {
333
+ A.length || K(), g(!I);
334
+ },
335
+ disabled: j,
336
+ title: O("chartAI.showInsights", "Show data insights"),
337
+ children: [
338
+ "💡 ",
339
+ O("chartAI.insights", "Insights")
340
+ ]
341
+ }
342
+ )
343
+ ] })
344
+ ] }),
345
+ /* @__PURE__ */ e("div", { className: "nice-chart-ai__chart-wrapper", children: /* @__PURE__ */ e(
346
+ De,
347
+ {
348
+ series: U,
349
+ categories: Z,
350
+ ...o
351
+ }
352
+ ) }),
353
+ I && A.length > 0 && /* @__PURE__ */ k("div", { className: "nice-chart-ai__insights", children: [
354
+ /* @__PURE__ */ k("div", { className: "nice-chart-ai__insights-header", children: [
355
+ /* @__PURE__ */ k("h4", { children: [
356
+ "💡 ",
357
+ O("chartAI.dataInsights", "Data Insights")
358
+ ] }),
359
+ /* @__PURE__ */ e(
360
+ "button",
361
+ {
362
+ type: "button",
363
+ className: "nice-chart-ai__insights-close",
364
+ onClick: () => g(!1),
365
+ children: "✕"
366
+ }
367
+ )
368
+ ] }),
369
+ /* @__PURE__ */ e("ul", { className: "nice-chart-ai__insights-list", children: A.map((D, P) => /* @__PURE__ */ k("li", { className: "nice-chart-ai__insight", children: [
370
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__insight-icon", children: "•" }),
371
+ D
372
+ ] }, P)) }),
373
+ /* @__PURE__ */ e("div", { className: "nice-chart-ai__insights-footer", children: /* @__PURE__ */ k(
374
+ "button",
375
+ {
376
+ type: "button",
377
+ className: "nice-chart-ai__refresh",
378
+ onClick: () => K(),
379
+ disabled: j,
380
+ children: [
381
+ "🔄 ",
382
+ O("chartAI.refresh", "Refresh")
383
+ ]
384
+ }
385
+ ) })
386
+ ] }),
387
+ I && j && /* @__PURE__ */ e("div", { className: "nice-chart-ai__insights nice-chart-ai__insights--loading", children: /* @__PURE__ */ k("div", { className: "nice-chart-ai__loading-content", children: [
388
+ /* @__PURE__ */ e("span", { className: "nice-chart-ai__spinner" }),
389
+ O("chartAI.generatingInsights", "Generating insights...")
390
+ ] }) })
391
+ ] });
392
+ });
393
+ function He(t, a) {
394
+ const d = t ? typeof t == "number" ? new Date(t) : new Date(t) : /* @__PURE__ */ new Date(), c = (C) => C.toString().padStart(2, "0"), r = c(d.getHours()), u = c(d.getMinutes()), i = c(d.getSeconds()), m = d.getMilliseconds().toString().padStart(3, "0");
395
+ switch (a) {
396
+ case "HH:mm:ss":
397
+ return `${r}:${u}:${i}`;
398
+ case "HH:mm":
399
+ return `${r}:${u}`;
400
+ case "mm:ss":
401
+ return `${u}:${i}`;
402
+ case "ss.SSS":
403
+ return `${i}.${m}`;
404
+ case "ISO":
405
+ return d.toISOString();
406
+ default:
407
+ return `${r}:${u}:${i}`;
408
+ }
409
+ }
410
+ function Te(t) {
411
+ if (t.length === 0) return null;
412
+ const a = Math.min(...t), d = Math.max(...t), c = t.reduce((u, i) => u + i, 0) / t.length, r = t[t.length - 1];
413
+ return { min: a, max: d, avg: c, current: r, count: t.length };
414
+ }
415
+ const Fe = ve(
416
+ ({
417
+ series: t,
418
+ maxPoints: a = 100,
419
+ slidingWindow: d = !0,
420
+ refreshRate: c = 16,
421
+ dataSource: r,
422
+ width: u = 600,
423
+ height: i = 400,
424
+ title: m,
425
+ showLegend: C = !0,
426
+ showGrid: l = !0,
427
+ yAxisLabel: v,
428
+ xAxisLabel: f,
429
+ stacked: S,
430
+ zoomable: y,
431
+ crosshair: p,
432
+ annotations: o = [],
433
+ legendInteractive: s,
434
+ onDataPointClick: h,
435
+ exportable: w,
436
+ showControls: b = !0,
437
+ showStatus: A = !0,
438
+ initialPaused: N = !1,
439
+ onDataReceived: I,
440
+ onDataDropped: g,
441
+ timeFormat: T = "HH:mm:ss",
442
+ showStats: x,
443
+ thresholds: O = [],
444
+ className: B,
445
+ style: R
446
+ }, G) => {
447
+ const [j, W] = ie(() => {
448
+ const L = /* @__PURE__ */ new Map();
449
+ for (const H of t)
450
+ L.set(H.name, H.initialData?.slice() ?? []);
451
+ return L;
452
+ }), [U, Z] = ie([]), [X, K] = ie(N), [ee, he] = ie(!1), ne = be([]), D = be(Date.now()), P = be(null), re = te(() => {
453
+ const L = ne.current;
454
+ L.length !== 0 && (ne.current = [], W((H) => {
455
+ const J = new Map(H);
456
+ for (const pe of L) {
457
+ const $ = J.get(pe.series);
458
+ if (!$) continue;
459
+ const E = [...$, pe.value];
460
+ if (d && E.length > a) {
461
+ const Y = E.length - a;
462
+ g?.(Y, pe.series), E.splice(0, Y);
463
+ }
464
+ J.set(pe.series, E);
465
+ }
466
+ return J;
467
+ }), L.length > 0 && Z((H) => {
468
+ const J = [...H];
469
+ for (const pe of L) {
470
+ const $ = pe.category ?? He(pe.timestamp, T);
471
+ J.push($);
472
+ }
473
+ return d && J.length > a && J.splice(0, J.length - a), J;
474
+ }));
475
+ }, [d, a, T, g]), F = te(() => {
476
+ const L = Date.now();
477
+ L - D.current >= c && (re(), D.current = L), P.current = requestAnimationFrame(F);
478
+ }, [c, re]);
479
+ $e(() => (X || (P.current = requestAnimationFrame(F)), () => {
480
+ P.current !== null && (cancelAnimationFrame(P.current), P.current = null);
481
+ }), [X, F]);
482
+ const q = te(
483
+ (L) => {
484
+ if (X) return;
485
+ const H = "points" in L ? L.points : [L];
486
+ for (const J of H)
487
+ j.has(J.series) && (ne.current.push(J), I?.(J));
488
+ },
489
+ [X, j, I]
490
+ );
491
+ $e(() => {
492
+ if (!r) return;
493
+ const L = r.subscribe(q);
494
+ let H;
495
+ return r.onStatusChange ? H = r.onStatusChange(he) : he(!0), r.fetchHistory && r.fetchHistory(a).then((J) => {
496
+ for (const pe of J)
497
+ ne.current.push(pe);
498
+ re();
499
+ }), () => {
500
+ L(), H?.();
501
+ };
502
+ }, [r, q, a, re]);
503
+ const de = me(() => t.map((L) => ({
504
+ name: L.name,
505
+ color: L.color,
506
+ type: L.type,
507
+ data: j.get(L.name) ?? []
508
+ })), [t, j]), xe = me(() => {
509
+ const L = [...o];
510
+ for (const H of O)
511
+ L.push({
512
+ type: "line",
513
+ value: H.value,
514
+ color: H.color,
515
+ label: H.label,
516
+ dash: H.style === "dashed" ? "5,5" : H.style === "dotted" ? "2,2" : void 0
517
+ });
518
+ return L;
519
+ }, [o, O]);
520
+ Ie(
521
+ G,
522
+ () => ({
523
+ pause() {
524
+ K(!0);
525
+ },
526
+ resume() {
527
+ K(!1);
528
+ },
529
+ isPaused() {
530
+ return X;
531
+ },
532
+ clear() {
533
+ W((L) => {
534
+ const H = new Map(L);
535
+ for (const J of H.keys())
536
+ H.set(J, []);
537
+ return H;
538
+ }), Z([]), ne.current = [];
539
+ },
540
+ addPoint(L) {
541
+ q(L);
542
+ },
543
+ addPoints(L) {
544
+ q({ points: L });
545
+ },
546
+ getData(L) {
547
+ return j.get(L) ?? [];
548
+ },
549
+ getCategories() {
550
+ return U;
551
+ },
552
+ exportData() {
553
+ return { series: de, categories: U };
554
+ },
555
+ getStats(L) {
556
+ const H = j.get(L);
557
+ return H ? Te(H) : null;
558
+ }
559
+ }),
560
+ [X, j, U, de, q]
561
+ );
562
+ const ye = me(() => {
563
+ if (!x) return null;
564
+ const L = {};
565
+ for (const [H, J] of j)
566
+ L[H] = Te(J);
567
+ return L;
568
+ }, [x, j]);
569
+ return /* @__PURE__ */ k("div", { className: B, style: { position: "relative", ...R }, children: [
570
+ A && /* @__PURE__ */ k(
571
+ "div",
572
+ {
573
+ style: {
574
+ position: "absolute",
575
+ top: 8,
576
+ right: 8,
577
+ display: "flex",
578
+ alignItems: "center",
579
+ gap: 4,
580
+ fontSize: 12,
581
+ color: ee ? "#22c55e" : "#ef4444",
582
+ zIndex: 10
583
+ },
584
+ children: [
585
+ /* @__PURE__ */ e(
586
+ "span",
587
+ {
588
+ style: {
589
+ width: 8,
590
+ height: 8,
591
+ borderRadius: "50%",
592
+ backgroundColor: ee ? "#22c55e" : "#ef4444"
593
+ }
594
+ }
595
+ ),
596
+ ee ? "Live" : "Disconnected"
597
+ ]
598
+ }
599
+ ),
600
+ b && /* @__PURE__ */ e(
601
+ "div",
602
+ {
603
+ style: {
604
+ position: "absolute",
605
+ top: 8,
606
+ left: 8,
607
+ display: "flex",
608
+ gap: 4,
609
+ zIndex: 10
610
+ },
611
+ children: /* @__PURE__ */ e(
612
+ "button",
613
+ {
614
+ onClick: () => K((L) => !L),
615
+ style: {
616
+ padding: "4px 8px",
617
+ fontSize: 12,
618
+ border: "1px solid #ddd",
619
+ borderRadius: 4,
620
+ background: X ? "#fef3c7" : "#fff",
621
+ cursor: "pointer"
622
+ },
623
+ title: X ? "Resume" : "Pause",
624
+ children: X ? "▶" : "⏸"
625
+ }
626
+ )
627
+ }
628
+ ),
629
+ x && ye && /* @__PURE__ */ e(
630
+ "div",
631
+ {
632
+ style: {
633
+ position: "absolute",
634
+ bottom: 50,
635
+ right: 8,
636
+ background: "rgba(255,255,255,0.9)",
637
+ border: "1px solid #ddd",
638
+ borderRadius: 4,
639
+ padding: 8,
640
+ fontSize: 11,
641
+ zIndex: 10
642
+ },
643
+ children: Object.entries(ye).map(
644
+ ([L, H]) => H ? /* @__PURE__ */ k("div", { style: { marginBottom: 4 }, children: [
645
+ /* @__PURE__ */ e("strong", { children: L }),
646
+ /* @__PURE__ */ k("div", { children: [
647
+ "Min: ",
648
+ H.min.toFixed(2),
649
+ " | Max: ",
650
+ H.max.toFixed(2)
651
+ ] }),
652
+ /* @__PURE__ */ k("div", { children: [
653
+ "Avg: ",
654
+ H.avg.toFixed(2),
655
+ " | Now: ",
656
+ H.current.toFixed(2)
657
+ ] })
658
+ ] }, L) : null
659
+ )
660
+ }
661
+ ),
662
+ /* @__PURE__ */ e(
663
+ De,
664
+ {
665
+ series: de,
666
+ categories: U,
667
+ width: u,
668
+ height: i,
669
+ title: m,
670
+ showLegend: C,
671
+ showGrid: l,
672
+ yAxisLabel: v,
673
+ xAxisLabel: f,
674
+ stacked: S,
675
+ zoomable: y,
676
+ crosshair: p,
677
+ annotations: xe,
678
+ legendInteractive: s,
679
+ onDataPointClick: h,
680
+ exportable: w
681
+ }
682
+ )
683
+ ] });
684
+ }
685
+ );
686
+ Fe.displayName = "NiceLiveChart";
687
+ function at(t) {
688
+ const {
689
+ hubConnection: a,
690
+ eventName: d = "DataPoint",
691
+ subscribeMethod: c = "SubscribeToMetrics",
692
+ historyMethod: r = "GetMetricHistory",
693
+ metricName: u
694
+ } = t;
695
+ return {
696
+ subscribe(i) {
697
+ const m = (C) => {
698
+ i(C);
699
+ };
700
+ return a.on(d, m), a.state === "Connected" && a.invoke(c, u).catch(() => {
701
+ }), () => {
702
+ a.off(d, m);
703
+ };
704
+ },
705
+ async fetchHistory(i) {
706
+ try {
707
+ return await a.invoke(r, u, i);
708
+ } catch {
709
+ return [];
710
+ }
711
+ },
712
+ onStatusChange(i) {
713
+ const m = () => i(a.state === "Connected");
714
+ return a.onclose(() => i(!1)), a.onreconnected(() => i(!0)), m(), () => {
715
+ };
716
+ }
717
+ };
718
+ }
719
+ function ot(t) {
720
+ const {
721
+ url: a,
722
+ autoReconnect: d = !0,
723
+ reconnectDelay: c = 3e3,
724
+ parseMessage: r = (v) => JSON.parse(v)
725
+ } = t;
726
+ let u = null, i = null, m = null, C = null;
727
+ const l = () => {
728
+ u = new WebSocket(a), u.onopen = () => {
729
+ i?.(!0);
730
+ }, u.onclose = () => {
731
+ i?.(!1), d && (C = setTimeout(l, c));
732
+ }, u.onerror = () => {
733
+ u?.close();
734
+ }, u.onmessage = (v) => {
735
+ try {
736
+ const f = r(v.data);
737
+ f && m && m(f);
738
+ } catch {
739
+ }
740
+ };
741
+ };
742
+ return {
743
+ subscribe(v) {
744
+ return m = v, l(), () => {
745
+ m = null, C && clearTimeout(C), u?.close(), u = null;
746
+ };
747
+ },
748
+ onStatusChange(v) {
749
+ return i = v, () => {
750
+ i = null;
751
+ };
752
+ }
753
+ };
754
+ }
755
+ function st(t) {
756
+ const {
757
+ seriesNames: a,
758
+ interval: d = 1e3,
759
+ generateValue: c = () => Math.random() * 100
760
+ } = t;
761
+ let r = null, u = 0;
762
+ return {
763
+ subscribe(i) {
764
+ return r = setInterval(() => {
765
+ for (const m of a)
766
+ i({
767
+ series: m,
768
+ value: c(m, u),
769
+ timestamp: Date.now()
770
+ });
771
+ u++;
772
+ }, d), () => {
773
+ r && clearInterval(r);
774
+ };
775
+ },
776
+ onStatusChange(i) {
777
+ return i(!0), () => {
778
+ };
779
+ }
780
+ };
781
+ }
782
+ const fe = ["#3b82f6", "#ef4444", "#22c55e", "#f59e0b", "#8b5cf6", "#ec4899", "#06b6d4", "#84cc16"], it = ({
783
+ data: t,
784
+ width: a = 400,
785
+ height: d = 400,
786
+ innerRadius: c = 0,
787
+ title: r,
788
+ showLegend: u = !0,
789
+ showLabels: i = !0,
790
+ className: m,
791
+ style: C
792
+ }) => {
793
+ const l = a / 2, v = (d - (u ? 30 : 0)) / 2 + (r ? 10 : 0), f = Math.min(l, v) - 40, S = t.reduce((o, s) => o + s.value, 0);
794
+ let y = -Math.PI / 2;
795
+ const p = t.map((o, s) => {
796
+ const h = o.value / (S || 1) * Math.PI * 2, w = y;
797
+ y += h;
798
+ const b = y, A = (w + b) / 2, N = l + f * Math.cos(w), I = v + f * Math.sin(w), g = l + f * Math.cos(b), T = v + f * Math.sin(b), x = h > Math.PI ? 1 : 0, O = o.color || fe[s % fe.length];
799
+ let B;
800
+ if (c > 0) {
801
+ const W = l + c * Math.cos(w), U = v + c * Math.sin(w), Z = l + c * Math.cos(b), X = v + c * Math.sin(b);
802
+ B = `M${N},${I} A${f},${f} 0 ${x},1 ${g},${T} L${Z},${X} A${c},${c} 0 ${x},0 ${W},${U} Z`;
803
+ } else
804
+ B = `M${l},${v} L${N},${I} A${f},${f} 0 ${x},1 ${g},${T} Z`;
805
+ const R = l + f * 0.7 * Math.cos(A), G = v + f * 0.7 * Math.sin(A), j = S > 0 ? Math.round(o.value / S * 100) : 0;
806
+ return { ...o, path: B, labelX: R, labelY: G, pct: j, color: O };
807
+ });
808
+ return /* @__PURE__ */ e("div", { className: `nice-piechart ${m || ""}`, style: C, children: /* @__PURE__ */ k("svg", { width: a, height: d, className: "nice-piechart__svg", children: [
809
+ r && /* @__PURE__ */ e("text", { x: l, y: 20, textAnchor: "middle", className: "nice-chart__title", children: r }),
810
+ p.map((o, s) => /* @__PURE__ */ k("g", { children: [
811
+ /* @__PURE__ */ e("path", { d: o.path, fill: o.color, stroke: "var(--bg-primary, #fff)", strokeWidth: 2, children: /* @__PURE__ */ e("title", { children: `${o.label}: ${o.value} (${o.pct}%)` }) }),
812
+ i && o.pct >= 5 && /* @__PURE__ */ k("text", { x: o.labelX, y: o.labelY, textAnchor: "middle", dominantBaseline: "middle", className: "nice-piechart__label", children: [
813
+ o.pct,
814
+ "%"
815
+ ] })
816
+ ] }, s)),
817
+ u && /* @__PURE__ */ e("g", { transform: `translate(10, ${d - 25})`, children: t.map((o, s) => /* @__PURE__ */ k("g", { transform: `translate(${s * 100}, 0)`, children: [
818
+ /* @__PURE__ */ e("rect", { width: 10, height: 10, rx: 2, fill: o.color || fe[s % fe.length] }),
819
+ /* @__PURE__ */ e("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: o.label })
820
+ ] }, s)) })
821
+ ] }) });
822
+ }, lt = ({
823
+ series: t,
824
+ categories: a,
825
+ width: d = 400,
826
+ height: c = 400,
827
+ maxValue: r,
828
+ title: u,
829
+ showLegend: i = !0,
830
+ className: m,
831
+ style: C
832
+ }) => {
833
+ const l = d / 2, v = (c - (i ? 30 : 0)) / 2 + (u ? 10 : 0), f = Math.min(l, v) - 40, S = a.length, y = r ?? Math.max(...t.flatMap((h) => h.data), 1), p = Math.PI * 2 / S, o = 5, s = (h, w) => {
834
+ const b = h * p - Math.PI / 2, A = w / y * f;
835
+ return { x: l + A * Math.cos(b), y: v + A * Math.sin(b) };
836
+ };
837
+ return /* @__PURE__ */ e("div", { className: `nice-polarchart ${m || ""}`, style: C, children: /* @__PURE__ */ k("svg", { width: d, height: c, className: "nice-polarchart__svg", children: [
838
+ u && /* @__PURE__ */ e("text", { x: l, y: 20, textAnchor: "middle", className: "nice-chart__title", children: u }),
839
+ Array.from({ length: o }, (h, w) => {
840
+ const b = f * ((w + 1) / o);
841
+ return /* @__PURE__ */ e("circle", { cx: l, cy: v, r: b, fill: "none", stroke: "var(--border-color, #ddd)", strokeWidth: 0.5 }, w);
842
+ }),
843
+ a.map((h, w) => {
844
+ const b = s(w, y), A = s(w, y * 1.12);
845
+ return /* @__PURE__ */ k("g", { children: [
846
+ /* @__PURE__ */ e("line", { x1: l, y1: v, x2: b.x, y2: b.y, stroke: "var(--border-color, #ddd)", strokeWidth: 0.5 }),
847
+ /* @__PURE__ */ e("text", { x: A.x, y: A.y, textAnchor: "middle", dominantBaseline: "middle", className: "nice-chart__axis-label", children: h })
848
+ ] }, w);
849
+ }),
850
+ t.map((h, w) => {
851
+ const b = h.color || fe[w % fe.length], A = h.data.map((N, I) => {
852
+ const g = s(I, N);
853
+ return `${g.x},${g.y}`;
854
+ }).join(" ");
855
+ return /* @__PURE__ */ k("g", { children: [
856
+ /* @__PURE__ */ e("polygon", { points: A, fill: h.fill !== !1 ? b : "none", fillOpacity: 0.15, stroke: b, strokeWidth: 2 }),
857
+ h.data.map((N, I) => {
858
+ const g = s(I, N);
859
+ return /* @__PURE__ */ e("circle", { cx: g.x, cy: g.y, r: 3, fill: b, children: /* @__PURE__ */ e("title", { children: `${h.name} - ${a[I]}: ${N}` }) }, I);
860
+ })
861
+ ] }, h.name);
862
+ }),
863
+ i && /* @__PURE__ */ e("g", { transform: `translate(10, ${c - 25})`, children: t.map((h, w) => /* @__PURE__ */ k("g", { transform: `translate(${w * 100}, 0)`, children: [
864
+ /* @__PURE__ */ e("rect", { width: 10, height: 10, rx: 2, fill: h.color || fe[w % fe.length] }),
865
+ /* @__PURE__ */ e("text", { x: 14, y: 9, className: "nice-chart__legend-text", children: h.name })
866
+ ] }, w)) })
867
+ ] }) });
868
+ }, ht = ({
869
+ value: t,
870
+ min: a = 0,
871
+ max: d = 100,
872
+ width: c = 200,
873
+ height: r = 200,
874
+ startAngle: u = 225,
875
+ endAngle: i = -45,
876
+ color: m = "#3b82f6",
877
+ trackColor: C,
878
+ label: l,
879
+ formatValue: v,
880
+ ranges: f,
881
+ className: S,
882
+ style: y
883
+ }) => {
884
+ const p = c / 2, o = r / 2, s = Math.min(p, o) - 20, h = Math.max(0, Math.min(1, (t - a) / (d - a || 1))), w = (x) => x * Math.PI / 180, b = (u - i + 360) % 360 || 360, A = (x) => ({
885
+ x: p + s * Math.cos(w(x)),
886
+ y: o - s * Math.sin(w(x))
887
+ }), N = (x, O) => {
888
+ const B = A(x), R = A(O), j = (x - O + 360) % 360 > 180 ? 1 : 0;
889
+ return `M${B.x},${B.y} A${s},${s} 0 ${j},1 ${R.x},${R.y}`;
890
+ }, I = u - h * b, g = A(I);
891
+ let T = m;
892
+ if (f) {
893
+ for (const x of f)
894
+ if (t >= x.start && t <= x.end) {
895
+ T = x.color;
896
+ break;
897
+ }
898
+ }
899
+ return /* @__PURE__ */ e("div", { className: `nice-gauge nice-gauge--circular ${S || ""}`, style: y, children: /* @__PURE__ */ k("svg", { width: c, height: r, children: [
900
+ /* @__PURE__ */ e("path", { d: N(u, i), fill: "none", stroke: C || "var(--border-color, #e2e8f0)", strokeWidth: 12, strokeLinecap: "round" }),
901
+ h > 0 && /* @__PURE__ */ e("path", { d: N(u, I), fill: "none", stroke: T, strokeWidth: 12, strokeLinecap: "round" }),
902
+ /* @__PURE__ */ e("line", { x1: p, y1: o, x2: g.x, y2: g.y, stroke: "var(--text-primary, #333)", strokeWidth: 2, strokeLinecap: "round" }),
903
+ /* @__PURE__ */ e("circle", { cx: p, cy: o, r: 4, fill: "var(--text-primary, #333)" }),
904
+ /* @__PURE__ */ e("text", { x: p, y: o + s * 0.35, textAnchor: "middle", className: "nice-gauge__value", children: v ? v(t) : t }),
905
+ l && /* @__PURE__ */ e("text", { x: p, y: o + s * 0.55, textAnchor: "middle", className: "nice-gauge__label", children: l })
906
+ ] }) });
907
+ }, dt = ({
908
+ value: t,
909
+ min: a = 0,
910
+ max: d = 100,
911
+ width: c = 300,
912
+ height: r = 60,
913
+ orientation: u = "horizontal",
914
+ color: i = "#3b82f6",
915
+ label: m,
916
+ formatValue: C,
917
+ ranges: l,
918
+ showTicks: v = !0,
919
+ tickCount: f = 5,
920
+ className: S,
921
+ style: y
922
+ }) => {
923
+ const p = u === "horizontal", o = p ? c - 40 : r - 40, s = Math.max(0, Math.min(1, (t - a) / (d - a || 1))), h = 10;
924
+ let w = i;
925
+ if (l) {
926
+ for (const A of l)
927
+ if (t >= A.start && t <= A.end) {
928
+ w = A.color;
929
+ break;
930
+ }
931
+ }
932
+ const b = Array.from({ length: f }, (A, N) => a + (d - a) * (N / (f - 1)));
933
+ return p ? /* @__PURE__ */ e("div", { className: `nice-gauge nice-gauge--linear ${S || ""}`, style: y, children: /* @__PURE__ */ k("svg", { width: c, height: r, children: [
934
+ m && /* @__PURE__ */ e("text", { x: c / 2, y: 14, textAnchor: "middle", className: "nice-gauge__label", children: m }),
935
+ /* @__PURE__ */ e("rect", { x: 20, y: r / 2 - h / 2, width: o, height: h, rx: 5, fill: "var(--border-color, #e2e8f0)" }),
936
+ /* @__PURE__ */ e("rect", { x: 20, y: r / 2 - h / 2, width: o * s, height: h, rx: 5, fill: w }),
937
+ /* @__PURE__ */ e("polygon", { points: `${20 + o * s},${r / 2 - h / 2 - 2} ${20 + o * s - 5},${r / 2 - h / 2 - 10} ${20 + o * s + 5},${r / 2 - h / 2 - 10}`, fill: "var(--text-primary, #333)" }),
938
+ /* @__PURE__ */ e("text", { x: 20 + o * s, y: r / 2 - h / 2 - 12, textAnchor: "middle", className: "nice-gauge__value", style: { fontSize: 11 }, children: C ? C(t) : t }),
939
+ v && b.map((A, N) => {
940
+ const I = 20 + (A - a) / (d - a) * o;
941
+ return /* @__PURE__ */ e("text", { x: I, y: r / 2 + h / 2 + 14, textAnchor: "middle", className: "nice-gauge__tick", children: A }, N);
942
+ })
943
+ ] }) }) : /* @__PURE__ */ e("div", { className: `nice-gauge nice-gauge--linear nice-gauge--vertical ${S || ""}`, style: y, children: /* @__PURE__ */ k("svg", { width: c, height: r, children: [
944
+ /* @__PURE__ */ e("rect", { x: c / 2 - h / 2, y: 20, width: h, height: o, rx: 5, fill: "var(--border-color, #e2e8f0)" }),
945
+ /* @__PURE__ */ e("rect", { x: c / 2 - h / 2, y: 20 + o * (1 - s), width: h, height: o * s, rx: 5, fill: w }),
946
+ /* @__PURE__ */ e("text", { x: c / 2, y: 14, textAnchor: "middle", className: "nice-gauge__value", children: C ? C(t) : t }),
947
+ m && /* @__PURE__ */ e("text", { x: c / 2, y: r - 4, textAnchor: "middle", className: "nice-gauge__label", children: m })
948
+ ] }) });
949
+ }, ft = ({
950
+ items: t,
951
+ min: a = 0,
952
+ max: d = 100,
953
+ width: c = 300,
954
+ height: r = 300,
955
+ startAngle: u = 225,
956
+ endAngle: i = -45,
957
+ formatValue: m,
958
+ title: C,
959
+ className: l,
960
+ style: v
961
+ }) => {
962
+ const f = c / 2, S = r / 2, y = Math.min(f, S) - 30, p = Math.min(20, y / (t.length + 1)), o = 4, s = (b) => b * Math.PI / 180, h = (u - i + 360) % 360 || 360, w = (b, A, N) => {
963
+ const I = f + b * Math.cos(s(A)), g = S - b * Math.sin(s(A)), T = f + b * Math.cos(s(N)), x = S - b * Math.sin(s(N)), O = (A - N + 360) % 360;
964
+ return `M${I},${g} A${b},${b} 0 ${O > 180 ? 1 : 0},1 ${T},${x}`;
965
+ };
966
+ return /* @__PURE__ */ e("div", { className: `nice-bargauge ${l || ""}`, style: v, children: /* @__PURE__ */ k("svg", { width: c, height: r, children: [
967
+ C && /* @__PURE__ */ e("text", { x: f, y: 20, textAnchor: "middle", className: "nice-chart__title", children: C }),
968
+ t.map((b, A) => {
969
+ const N = y - A * (p + o), I = Math.max(0, Math.min(1, (b.value - a) / (d - a || 1))), g = u - I * h, T = b.color || fe[A % fe.length];
970
+ return /* @__PURE__ */ k("g", { children: [
971
+ /* @__PURE__ */ e("path", { d: w(N, u, i), fill: "none", stroke: "var(--border-color, #e2e8f0)", strokeWidth: p, strokeLinecap: "round" }),
972
+ I > 0 && /* @__PURE__ */ e("path", { d: w(N, u, g), fill: "none", stroke: T, strokeWidth: p, strokeLinecap: "round" })
973
+ ] }, A);
974
+ }),
975
+ /* @__PURE__ */ e("g", { children: t.map((b, A) => /* @__PURE__ */ k("text", { x: f, y: S - ((t.length - 1) / 2 - A) * 16, textAnchor: "middle", dominantBaseline: "middle", className: "nice-gauge__value", style: { fontSize: 12 }, children: [
976
+ b.label ? `${b.label}: ` : "",
977
+ m ? m(b.value) : b.value
978
+ ] }, A)) })
979
+ ] }) });
980
+ }, ut = ({
981
+ data: t,
982
+ width: a = 120,
983
+ height: d = 30,
984
+ type: c = "line",
985
+ color: r = "#3b82f6",
986
+ showMinMax: u,
987
+ showLastPoint: i = !0,
988
+ className: m,
989
+ style: C
990
+ }) => {
991
+ if (t.length === 0) return null;
992
+ const l = 2, v = Math.min(...t), f = Math.max(...t), S = f - v || 1, y = a - l * 2, p = d - l * 2, o = (N) => l + N / (t.length - 1 || 1) * y, s = (N) => l + p - (N - v) / S * p;
993
+ if (c === "bar") {
994
+ const N = Math.max(1, y / t.length - 1);
995
+ return /* @__PURE__ */ e("svg", { width: a, height: d, className: `nice-sparkline ${m || ""}`, style: C, children: t.map((I, g) => /* @__PURE__ */ e("rect", { x: l + g / t.length * y, y: s(I), width: N, height: p - (s(I) - l), fill: r, rx: 1 }, g)) });
996
+ }
997
+ const h = t.map((N, I) => `${o(I)},${s(N)}`).join(" "), w = t.indexOf(v), b = t.indexOf(f), A = t.length - 1;
998
+ return /* @__PURE__ */ k("svg", { width: a, height: d, className: `nice-sparkline ${m || ""}`, style: C, children: [
999
+ c === "area" && /* @__PURE__ */ e("polygon", { points: `${o(0)},${l + p} ${h} ${o(A)},${l + p}`, fill: r, opacity: 0.15 }),
1000
+ /* @__PURE__ */ e("polyline", { points: h, fill: "none", stroke: r, strokeWidth: 1.5 }),
1001
+ u && /* @__PURE__ */ e("circle", { cx: o(w), cy: s(v), r: 2, fill: "#ef4444" }),
1002
+ u && /* @__PURE__ */ e("circle", { cx: o(b), cy: s(f), r: 2, fill: "#22c55e" }),
1003
+ i && /* @__PURE__ */ e("circle", { cx: o(A), cy: s(t[A]), r: 2, fill: r })
1004
+ ] });
1005
+ }, mt = ({
1006
+ value: t,
1007
+ target: a,
1008
+ min: d = 0,
1009
+ max: c = 100,
1010
+ width: r = 200,
1011
+ height: u = 30,
1012
+ color: i = "#3b82f6",
1013
+ targetColor: m = "#ef4444",
1014
+ className: C,
1015
+ style: l
1016
+ }) => {
1017
+ const f = r - 8, S = u - 8, y = Math.max(0, Math.min(1, (t - d) / (c - d || 1))), p = a != null ? Math.max(0, Math.min(1, (a - d) / (c - d || 1))) : null;
1018
+ return /* @__PURE__ */ k("svg", { width: r, height: u, className: `nice-bullet ${C || ""}`, style: l, children: [
1019
+ /* @__PURE__ */ e("rect", { x: 4, y: 4, width: f, height: S, rx: 3, fill: "var(--border-color, #e2e8f0)" }),
1020
+ /* @__PURE__ */ e("rect", { x: 4, y: 4 + S * 0.2, width: f * y, height: S * 0.6, rx: 2, fill: i }),
1021
+ p != null && /* @__PURE__ */ e("line", { x1: 4 + f * p, y1: 6, x2: 4 + f * p, y2: 4 + S - 2, stroke: m, strokeWidth: 2 })
1022
+ ] });
1023
+ }, pt = ({
1024
+ data: t,
1025
+ width: a = 400,
1026
+ height: d = 300,
1027
+ inverted: c,
1028
+ showLabels: r = !0,
1029
+ showValues: u = !0,
1030
+ title: i,
1031
+ className: m,
1032
+ style: C
1033
+ }) => {
1034
+ const l = { top: i ? 30 : 10, bottom: 10, x: 40 }, v = a - l.x * 2, f = d - l.top - l.bottom, S = c ? [...t].reverse() : t, y = Math.max(...S.map((o) => o.value), 1), p = f / S.length;
1035
+ return /* @__PURE__ */ e("div", { className: `nice-funnel ${m || ""}`, style: C, children: /* @__PURE__ */ k("svg", { width: a, height: d, children: [
1036
+ i && /* @__PURE__ */ e("text", { x: a / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: i }),
1037
+ S.map((o, s) => {
1038
+ const h = o.value / y * v, w = s < S.length - 1 ? S[s + 1].value / y * v : h * 0.3, b = l.top + s * p, A = b + p, N = a / 2, I = `${N - h / 2},${b} ${N + h / 2},${b} ${N + w / 2},${A} ${N - w / 2},${A}`, g = o.color || fe[s % fe.length];
1039
+ return /* @__PURE__ */ k("g", { children: [
1040
+ /* @__PURE__ */ e("polygon", { points: I, fill: g, stroke: "var(--bg-primary, #fff)", strokeWidth: 1, children: /* @__PURE__ */ e("title", { children: `${o.label}: ${o.value}` }) }),
1041
+ r && /* @__PURE__ */ e("text", { x: N, y: b + p / 2 - (u ? 4 : 0), textAnchor: "middle", dominantBaseline: "middle", className: "nice-funnel__label", children: o.label }),
1042
+ u && /* @__PURE__ */ e("text", { x: N, y: b + p / 2 + 10, textAnchor: "middle", dominantBaseline: "middle", className: "nice-funnel__value", children: o.value })
1043
+ ] }, s);
1044
+ })
1045
+ ] }) });
1046
+ }, Ee = ({
1047
+ nodes: t,
1048
+ links: a,
1049
+ width: d = 600,
1050
+ height: c = 400,
1051
+ nodeWidth: r = 20,
1052
+ nodePadding: u = 10,
1053
+ title: i,
1054
+ className: m,
1055
+ style: C
1056
+ }) => {
1057
+ const l = { top: i ? 40 : 20, bottom: 20, left: 20, right: 20 }, v = d - l.left - l.right, f = c - l.top - l.bottom, S = new Set(a.map((x) => x.source)), y = new Set(a.map((x) => x.target)), p = t.filter((x) => S.has(x.id) && !y.has(x.id)), o = t.filter((x) => y.has(x.id)), s = t.filter((x) => S.has(x.id) && y.has(x.id)), h = [p, ...s.length ? [s] : [], o].filter((x) => x.length > 0), w = h.length, b = /* @__PURE__ */ new Map();
1058
+ t.forEach((x) => {
1059
+ const O = a.filter((R) => R.source === x.id).reduce((R, G) => R + G.value, 0), B = a.filter((R) => R.target === x.id).reduce((R, G) => R + G.value, 0);
1060
+ b.set(x.id, Math.max(O, B));
1061
+ });
1062
+ const A = h.map((x) => x.reduce((O, B) => O + (b.get(B.id) || 0), 0) + (x.length - 1) * u), N = Math.max(...A, 1), I = /* @__PURE__ */ new Map();
1063
+ h.forEach((x, O) => {
1064
+ const B = l.left + O / (w - 1 || 1) * (v - r);
1065
+ let R = 0;
1066
+ x.forEach((G) => {
1067
+ const j = (b.get(G.id) || 0) / N * f;
1068
+ I.set(G.id, { x: B, y: l.top + R, h: j }), R += j + u;
1069
+ });
1070
+ });
1071
+ const g = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map();
1072
+ return t.forEach((x) => {
1073
+ g.set(x.id, 0), T.set(x.id, 0);
1074
+ }), /* @__PURE__ */ e("div", { className: `nice-sankey ${m || ""}`, style: C, children: /* @__PURE__ */ k("svg", { width: d, height: c, children: [
1075
+ i && /* @__PURE__ */ e("text", { x: d / 2, y: 20, textAnchor: "middle", className: "nice-chart__title", children: i }),
1076
+ a.map((x, O) => {
1077
+ const B = I.get(x.source), R = I.get(x.target);
1078
+ if (!B || !R) return null;
1079
+ const G = g.get(x.source) || 0, j = T.get(x.target) || 0, W = x.value / N * f;
1080
+ g.set(x.source, G + W), T.set(x.target, j + W);
1081
+ const U = B.x + r, Z = B.y + G, X = R.x, K = R.y + j, ee = (U + X) / 2, ne = t.find((D) => D.id === x.source)?.color || fe[O % fe.length];
1082
+ return /* @__PURE__ */ e(
1083
+ "path",
1084
+ {
1085
+ d: `M${U},${Z} C${ee},${Z} ${ee},${K} ${X},${K} L${X},${K + W} C${ee},${K + W} ${ee},${Z + W} ${U},${Z + W} Z`,
1086
+ fill: ne,
1087
+ fillOpacity: 0.3,
1088
+ stroke: ne,
1089
+ strokeOpacity: 0.5,
1090
+ strokeWidth: 0.5,
1091
+ children: /* @__PURE__ */ e("title", { children: `${x.source} → ${x.target}: ${x.value}` })
1092
+ },
1093
+ O
1094
+ );
1095
+ }),
1096
+ t.map((x, O) => {
1097
+ const B = I.get(x.id);
1098
+ if (!B) return null;
1099
+ const R = x.color || fe[O % fe.length];
1100
+ return /* @__PURE__ */ k("g", { children: [
1101
+ /* @__PURE__ */ e("rect", { x: B.x, y: B.y, width: r, height: Math.max(B.h, 2), fill: R, rx: 2 }),
1102
+ /* @__PURE__ */ e(
1103
+ "text",
1104
+ {
1105
+ x: B.x < v / 2 ? B.x + r + 4 : B.x - 4,
1106
+ y: B.y + B.h / 2,
1107
+ textAnchor: B.x < v / 2 ? "start" : "end",
1108
+ dominantBaseline: "middle",
1109
+ className: "nice-chart__legend-text",
1110
+ children: x.label
1111
+ }
1112
+ )
1113
+ ] }, x.id);
1114
+ })
1115
+ ] }) });
1116
+ }, gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1117
+ __proto__: null,
1118
+ NiceSankey: Ee
1119
+ }, Symbol.toStringTag, { value: "Module" })), xt = ({
1120
+ data: t,
1121
+ min: a,
1122
+ max: d,
1123
+ start: c,
1124
+ end: r,
1125
+ onChange: u,
1126
+ width: i = 500,
1127
+ height: m = 100,
1128
+ step: C = 1,
1129
+ formatValue: l,
1130
+ chartColor: v = "#3b82f6",
1131
+ className: f,
1132
+ style: S
1133
+ }) => {
1134
+ const y = { top: 10, bottom: 30, left: 10, right: 10 }, p = i - y.left - y.right, o = m - y.top - y.bottom, s = (I) => y.left + (I - a) / (d - a || 1) * p, h = (I) => {
1135
+ const g = Math.max(0, Math.min(1, (I - y.left) / p)), T = a + g * (d - a);
1136
+ return Math.round(T / C) * C;
1137
+ }, w = (I, g) => {
1138
+ g.preventDefault();
1139
+ const T = g.target.closest("svg");
1140
+ if (!T) return;
1141
+ const x = (B) => {
1142
+ const R = T.getBoundingClientRect(), G = h(B.clientX - R.left);
1143
+ I === "start" ? u(Math.min(G, r), r) : u(c, Math.max(G, c));
1144
+ }, O = () => {
1145
+ document.removeEventListener("pointermove", x), document.removeEventListener("pointerup", O);
1146
+ };
1147
+ document.addEventListener("pointermove", x), document.addEventListener("pointerup", O);
1148
+ }, b = t ? Math.min(...t) : 0, N = (t ? Math.max(...t) : 1) - b || 1;
1149
+ return /* @__PURE__ */ e("div", { className: `nice-rangeselector ${f || ""}`, style: S, children: /* @__PURE__ */ k("svg", { width: i, height: m, children: [
1150
+ t && t.length > 1 && /* @__PURE__ */ e(
1151
+ "polygon",
1152
+ {
1153
+ points: `${y.left},${y.top + o} ${t.map((I, g) => `${y.left + g / (t.length - 1) * p},${y.top + o - (I - b) / N * o}`).join(" ")} ${y.left + p},${y.top + o}`,
1154
+ fill: v,
1155
+ opacity: 0.15
1156
+ }
1157
+ ),
1158
+ /* @__PURE__ */ e("rect", { x: s(c), y: y.top, width: s(r) - s(c), height: o, fill: v, opacity: 0.1 }),
1159
+ /* @__PURE__ */ e("rect", { x: y.left, y: y.top, width: s(c) - y.left, height: o, fill: "var(--bg-secondary, #f5f5f5)", opacity: 0.6 }),
1160
+ /* @__PURE__ */ e("rect", { x: s(r), y: y.top, width: y.left + p - s(r), height: o, fill: "var(--bg-secondary, #f5f5f5)", opacity: 0.6 }),
1161
+ /* @__PURE__ */ e(
1162
+ "rect",
1163
+ {
1164
+ x: s(c) - 4,
1165
+ y: y.top,
1166
+ width: 8,
1167
+ height: o,
1168
+ fill: v,
1169
+ rx: 2,
1170
+ cursor: "ew-resize",
1171
+ onPointerDown: (I) => w("start", I)
1172
+ }
1173
+ ),
1174
+ /* @__PURE__ */ e(
1175
+ "rect",
1176
+ {
1177
+ x: s(r) - 4,
1178
+ y: y.top,
1179
+ width: 8,
1180
+ height: o,
1181
+ fill: v,
1182
+ rx: 2,
1183
+ cursor: "ew-resize",
1184
+ onPointerDown: (I) => w("end", I)
1185
+ }
1186
+ ),
1187
+ /* @__PURE__ */ e("text", { x: s(c), y: y.top + o + 18, textAnchor: "middle", className: "nice-chart__axis-label", children: l ? l(c) : c }),
1188
+ /* @__PURE__ */ e("text", { x: s(r), y: y.top + o + 18, textAnchor: "middle", className: "nice-chart__axis-label", children: l ? l(r) : r })
1189
+ ] }) });
1190
+ }, Ye = ({
1191
+ regions: t,
1192
+ width: a = 600,
1193
+ height: d = 400,
1194
+ viewBox: c = "0 0 1000 600",
1195
+ colorRange: r = ["#dbeafe", "#1d4ed8"],
1196
+ maxValue: u,
1197
+ onRegionClick: i,
1198
+ selectedRegionId: m,
1199
+ title: C,
1200
+ showTooltip: l = !0,
1201
+ className: v,
1202
+ style: f
1203
+ }) => {
1204
+ const S = u ?? Math.max(...t.map((p) => p.value ?? 0), 1), y = (p) => {
1205
+ const o = (x) => [parseInt(x.slice(1, 3), 16), parseInt(x.slice(3, 5), 16), parseInt(x.slice(5, 7), 16)], [s, h, w] = o(r[0]), [b, A, N] = o(r[1]), I = Math.round(s + (b - s) * p), g = Math.round(h + (A - h) * p), T = Math.round(w + (N - w) * p);
1206
+ return `rgb(${I},${g},${T})`;
1207
+ };
1208
+ return /* @__PURE__ */ k("div", { className: `nice-vectormap ${v || ""}`, style: f, children: [
1209
+ C && /* @__PURE__ */ e("div", { className: "nice-vectormap__title", children: C }),
1210
+ /* @__PURE__ */ e("svg", { width: a, height: d, viewBox: c, children: t.map((p) => {
1211
+ const o = p.value != null ? Math.max(0, Math.min(1, p.value / S)) : 0, s = p.value != null ? y(o) : "var(--bg-tertiary, #e5e7eb)", h = p.id === m;
1212
+ return /* @__PURE__ */ e(
1213
+ "path",
1214
+ {
1215
+ d: p.path,
1216
+ fill: s,
1217
+ stroke: h ? "var(--color-primary, #3b82f6)" : "var(--border-color, #d1d5db)",
1218
+ strokeWidth: h ? 2 : 0.5,
1219
+ cursor: i ? "pointer" : void 0,
1220
+ onClick: () => i?.(p),
1221
+ children: l && /* @__PURE__ */ e("title", { children: `${p.name}${p.value != null ? `: ${p.value}` : ""}` })
1222
+ },
1223
+ p.id
1224
+ );
1225
+ }) })
1226
+ ] });
1227
+ }, yt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1228
+ __proto__: null,
1229
+ NiceVectorMap: Ye
1230
+ }, Symbol.toStringTag, { value: "Module" })), Ve = `
1231
+ .nice-forecast-chart {
1232
+ display: flex;
1233
+ flex-direction: column;
1234
+ background: var(--nice-bg-primary, #ffffff);
1235
+ border: 1px solid var(--nice-border-color, #e5e7eb);
1236
+ border-radius: 0.5rem;
1237
+ overflow: hidden;
1238
+ }
1239
+
1240
+ .nice-forecast-chart__header {
1241
+ display: flex;
1242
+ align-items: center;
1243
+ justify-content: space-between;
1244
+ padding: 0.75rem 1rem;
1245
+ border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
1246
+ }
1247
+
1248
+ .nice-forecast-chart__title {
1249
+ font-size: 1rem;
1250
+ font-weight: 600;
1251
+ color: var(--nice-text-primary);
1252
+ margin: 0;
1253
+ }
1254
+
1255
+ .nice-forecast-chart__actions {
1256
+ display: flex;
1257
+ gap: 0.5rem;
1258
+ }
1259
+
1260
+ .nice-forecast-chart__btn {
1261
+ display: inline-flex;
1262
+ align-items: center;
1263
+ justify-content: center;
1264
+ width: 2rem;
1265
+ height: 2rem;
1266
+ font-size: 1rem;
1267
+ border-radius: 0.375rem;
1268
+ cursor: pointer;
1269
+ transition: all 0.15s ease;
1270
+ border: 1px solid var(--nice-border-color, #d1d5db);
1271
+ background: var(--nice-bg-primary, #ffffff);
1272
+ color: var(--nice-text-secondary);
1273
+ }
1274
+
1275
+ .nice-forecast-chart__btn:hover {
1276
+ background: var(--nice-bg-hover, #f3f4f6);
1277
+ color: var(--nice-text-primary);
1278
+ }
1279
+
1280
+ .nice-forecast-chart__btn:disabled {
1281
+ opacity: 0.5;
1282
+ cursor: not-allowed;
1283
+ }
1284
+
1285
+ .nice-forecast-chart__container {
1286
+ position: relative;
1287
+ width: 100%;
1288
+ padding: 1rem;
1289
+ }
1290
+
1291
+ .nice-forecast-chart__svg {
1292
+ width: 100%;
1293
+ overflow: visible;
1294
+ }
1295
+
1296
+ .nice-forecast-chart__grid-line {
1297
+ stroke: var(--nice-border-divider, #f3f4f6);
1298
+ stroke-width: 1;
1299
+ }
1300
+
1301
+ .nice-forecast-chart__axis-line {
1302
+ stroke: var(--nice-border-color, #e5e7eb);
1303
+ stroke-width: 1;
1304
+ }
1305
+
1306
+ .nice-forecast-chart__axis-label {
1307
+ font-size: 0.6875rem;
1308
+ fill: var(--nice-text-secondary);
1309
+ }
1310
+
1311
+ .nice-forecast-chart__axis-title {
1312
+ font-size: 0.75rem;
1313
+ font-weight: 500;
1314
+ fill: var(--nice-text-primary);
1315
+ }
1316
+
1317
+ .nice-forecast-chart__historical-line {
1318
+ fill: none;
1319
+ stroke-width: 2;
1320
+ stroke-linecap: round;
1321
+ stroke-linejoin: round;
1322
+ }
1323
+
1324
+ .nice-forecast-chart__forecast-line {
1325
+ fill: none;
1326
+ stroke-width: 2;
1327
+ stroke-linecap: round;
1328
+ stroke-linejoin: round;
1329
+ stroke-dasharray: 6, 4;
1330
+ }
1331
+
1332
+ .nice-forecast-chart__confidence-band {
1333
+ opacity: 0.2;
1334
+ }
1335
+
1336
+ .nice-forecast-chart__forecast-region {
1337
+ fill: var(--nice-bg-secondary, #f9fafb);
1338
+ opacity: 0.5;
1339
+ }
1340
+
1341
+ .nice-forecast-chart__point {
1342
+ cursor: pointer;
1343
+ transition: r 0.15s ease;
1344
+ }
1345
+
1346
+ .nice-forecast-chart__point:hover {
1347
+ r: 6;
1348
+ }
1349
+
1350
+ .nice-forecast-chart__annotation-line {
1351
+ stroke-dasharray: 4, 2;
1352
+ stroke-width: 1;
1353
+ }
1354
+
1355
+ .nice-forecast-chart__annotation-marker {
1356
+ cursor: pointer;
1357
+ transition: transform 0.15s ease;
1358
+ }
1359
+
1360
+ .nice-forecast-chart__annotation-marker:hover {
1361
+ transform: scale(1.2);
1362
+ }
1363
+
1364
+ .nice-forecast-chart__reference-line {
1365
+ stroke-width: 1;
1366
+ }
1367
+
1368
+ .nice-forecast-chart__reference-label {
1369
+ font-size: 0.625rem;
1370
+ fill: var(--nice-text-secondary);
1371
+ }
1372
+
1373
+ .nice-forecast-chart__cash-runway {
1374
+ pointer-events: none;
1375
+ }
1376
+
1377
+ .nice-forecast-chart__cash-runway-line {
1378
+ stroke: #ef4444;
1379
+ stroke-width: 2;
1380
+ stroke-dasharray: 8, 4;
1381
+ }
1382
+
1383
+ .nice-forecast-chart__cash-runway-label-bg {
1384
+ fill: #ef4444;
1385
+ rx: 4;
1386
+ }
1387
+
1388
+ .nice-forecast-chart__cash-runway-label {
1389
+ font-size: 0.6875rem;
1390
+ font-weight: 600;
1391
+ fill: #ffffff;
1392
+ }
1393
+
1394
+ .nice-forecast-chart__cash-runway-date {
1395
+ font-size: 0.625rem;
1396
+ fill: #ef4444;
1397
+ font-weight: 500;
1398
+ }
1399
+
1400
+ .nice-forecast-chart__tooltip {
1401
+ position: absolute;
1402
+ pointer-events: none;
1403
+ z-index: 100;
1404
+ padding: 0.75rem;
1405
+ background: var(--nice-bg-primary, #ffffff);
1406
+ border: 1px solid var(--nice-border-color, #e5e7eb);
1407
+ border-radius: 0.5rem;
1408
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
1409
+ font-size: 0.8125rem;
1410
+ max-width: 250px;
1411
+ }
1412
+
1413
+ .nice-forecast-chart__tooltip-date {
1414
+ font-weight: 600;
1415
+ color: var(--nice-text-primary);
1416
+ margin-bottom: 0.5rem;
1417
+ padding-bottom: 0.5rem;
1418
+ border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
1419
+ }
1420
+
1421
+ .nice-forecast-chart__tooltip-item {
1422
+ display: flex;
1423
+ align-items: center;
1424
+ gap: 0.5rem;
1425
+ margin-bottom: 0.25rem;
1426
+ }
1427
+
1428
+ .nice-forecast-chart__tooltip-color {
1429
+ width: 10px;
1430
+ height: 10px;
1431
+ border-radius: 2px;
1432
+ flex-shrink: 0;
1433
+ }
1434
+
1435
+ .nice-forecast-chart__tooltip-label {
1436
+ color: var(--nice-text-secondary);
1437
+ flex: 1;
1438
+ }
1439
+
1440
+ .nice-forecast-chart__tooltip-value {
1441
+ font-weight: 600;
1442
+ color: var(--nice-text-primary);
1443
+ font-variant-numeric: tabular-nums;
1444
+ }
1445
+
1446
+ .nice-forecast-chart__tooltip-confidence {
1447
+ font-size: 0.75rem;
1448
+ color: var(--nice-text-tertiary);
1449
+ }
1450
+
1451
+ .nice-forecast-chart__legend {
1452
+ display: flex;
1453
+ flex-wrap: wrap;
1454
+ gap: 1rem;
1455
+ padding: 0.75rem 1rem;
1456
+ border-top: 1px solid var(--nice-border-color, #e5e7eb);
1457
+ }
1458
+
1459
+ .nice-forecast-chart__legend-item {
1460
+ display: flex;
1461
+ align-items: center;
1462
+ gap: 0.375rem;
1463
+ font-size: 0.8125rem;
1464
+ color: var(--nice-text-secondary);
1465
+ cursor: pointer;
1466
+ user-select: none;
1467
+ transition: opacity 0.15s ease;
1468
+ }
1469
+
1470
+ .nice-forecast-chart__legend-item:hover {
1471
+ color: var(--nice-text-primary);
1472
+ }
1473
+
1474
+ .nice-forecast-chart__legend-item--hidden {
1475
+ opacity: 0.4;
1476
+ }
1477
+
1478
+ .nice-forecast-chart__legend-color {
1479
+ width: 16px;
1480
+ height: 3px;
1481
+ border-radius: 1px;
1482
+ }
1483
+
1484
+ .nice-forecast-chart__legend-color--dashed {
1485
+ background: repeating-linear-gradient(
1486
+ 90deg,
1487
+ currentColor,
1488
+ currentColor 4px,
1489
+ transparent 4px,
1490
+ transparent 6px
1491
+ );
1492
+ }
1493
+
1494
+ .nice-forecast-chart__empty {
1495
+ display: flex;
1496
+ align-items: center;
1497
+ justify-content: center;
1498
+ height: 300px;
1499
+ color: var(--nice-text-secondary);
1500
+ }
1501
+
1502
+ /* Dark mode */
1503
+ .dark .nice-forecast-chart {
1504
+ background: var(--nice-bg-primary-dark, #111827);
1505
+ border-color: var(--nice-border-color-dark, #374151);
1506
+ }
1507
+
1508
+ .dark .nice-forecast-chart__tooltip {
1509
+ background: var(--nice-bg-secondary-dark, #1f2937);
1510
+ border-color: var(--nice-border-color-dark, #374151);
1511
+ }
1512
+
1513
+ .dark .nice-forecast-chart__forecast-region {
1514
+ fill: var(--nice-bg-secondary-dark, #1f2937);
1515
+ }
1516
+ `, ze = [
1517
+ "#3b82f6",
1518
+ // blue
1519
+ "#10b981",
1520
+ // green
1521
+ "#f59e0b",
1522
+ // amber
1523
+ "#ef4444",
1524
+ // red
1525
+ "#8b5cf6",
1526
+ // purple
1527
+ "#ec4899",
1528
+ // pink
1529
+ "#06b6d4",
1530
+ // cyan
1531
+ "#f97316"
1532
+ // orange
1533
+ ];
1534
+ function le(t) {
1535
+ return t instanceof Date ? t : new Date(t);
1536
+ }
1537
+ function Ae(t, a = "pl-PL") {
1538
+ return t.toLocaleDateString(a, {
1539
+ year: "numeric",
1540
+ month: "short",
1541
+ day: "numeric"
1542
+ });
1543
+ }
1544
+ function Me(t, a = "pl-PL") {
1545
+ return new Intl.NumberFormat(a, {
1546
+ minimumFractionDigits: 0,
1547
+ maximumFractionDigits: 2
1548
+ }).format(t);
1549
+ }
1550
+ const _t = ve(
1551
+ function(a, d) {
1552
+ const {
1553
+ scenarios: c,
1554
+ annotations: r = [],
1555
+ referenceLines: u = [],
1556
+ forecastStartDate: i,
1557
+ cashRunway: m,
1558
+ xAxis: C,
1559
+ yAxis: l,
1560
+ confidenceBands: v = [{ level: 95, color: "#3b82f6", opacity: 0.15 }],
1561
+ tooltip: f,
1562
+ legend: S = { enabled: !0, position: "bottom", interactive: !0 },
1563
+ height: y = 350,
1564
+ showForecastRegion: p = !0,
1565
+ lineWidth: o = 2,
1566
+ showPoints: s = !1,
1567
+ pointRadius: h = 4,
1568
+ enableZoom: w = !1,
1569
+ animationDuration: b = 300,
1570
+ responsive: A = !0,
1571
+ onPointClick: N,
1572
+ onAnnotationClick: I,
1573
+ onScenarioToggle: g,
1574
+ onViewportChange: T,
1575
+ size: x = "medium",
1576
+ disabled: O = !1,
1577
+ labels: B = {},
1578
+ locale: R = "pl-PL",
1579
+ className: G,
1580
+ style: j
1581
+ } = a, [W, U] = ie(
1582
+ () => c.map((n, M) => ({
1583
+ ...n,
1584
+ color: n.color ?? ze[M % ze.length],
1585
+ visible: n.visible !== !1
1586
+ }))
1587
+ ), [Z, X] = ie(null), [K, ee] = ie({ x: 0, y: 0 }), he = be(null), ne = be(null), D = { top: 20, right: 30, bottom: 40, left: 60 }, [P, re] = ie({
1588
+ width: 600,
1589
+ height: typeof y == "number" ? y : 350
1590
+ });
1591
+ $e(() => {
1592
+ if (!A || !he.current) return;
1593
+ const n = new ResizeObserver((M) => {
1594
+ for (const z of M)
1595
+ re((_) => ({
1596
+ width: z.contentRect.width,
1597
+ height: _.height
1598
+ }));
1599
+ });
1600
+ return n.observe(he.current), () => n.disconnect();
1601
+ }, [A]), $e(() => {
1602
+ const n = "nice-forecast-chart-styles";
1603
+ if (!document.getElementById(n)) {
1604
+ const M = document.createElement("style");
1605
+ M.id = n, M.textContent = Ve, document.head.appendChild(M);
1606
+ }
1607
+ }, []);
1608
+ const { xScale: F, yScale: q, allDates: de, minY: xe, maxY: ye } = me(() => {
1609
+ const M = W.filter((Q) => Q.visible !== !1).flatMap((Q) => Q.data);
1610
+ if (M.length === 0)
1611
+ return { xScale: () => 0, yScale: () => 0, allDates: [], minY: 0, maxY: 100 };
1612
+ const z = M.map((Q) => le(Q.date).getTime()), _ = Math.min(...z), V = Math.max(...z), ae = M.flatMap((Q) => [Q.value, Q.forecast, Q.lowerBound, Q.upperBound]).filter((Q) => Q != null), ue = l?.min ?? Math.min(...ae) * 0.95, se = l?.max ?? Math.max(...ae) * 1.05, ge = P.width - D.left - D.right, _e = P.height - D.top - D.bottom, we = (Q) => {
1613
+ const Ce = typeof Q == "number" ? Q : Q.getTime();
1614
+ return D.left + (Ce - _) / (V - _) * ge;
1615
+ }, Se = (Q) => D.top + _e - (Q - ue) / (se - ue) * _e, Oe = [...new Set(z)].sort((Q, Ce) => Q - Ce).map((Q) => new Date(Q));
1616
+ return {
1617
+ xScale: we,
1618
+ yScale: Se,
1619
+ allDates: Oe,
1620
+ minY: ue,
1621
+ maxY: se
1622
+ };
1623
+ }, [W, P, D, l]), L = i ? le(i) : null, H = me(() => {
1624
+ if (!m?.enabled) return null;
1625
+ const n = m.threshold ?? 0, M = m.scenarioId ? W.find((_) => _.id === m.scenarioId && _.visible !== !1) : W.find((_) => _.visible !== !1);
1626
+ if (!M) return null;
1627
+ const z = M.data.sort(
1628
+ (_, V) => le(_.date).getTime() - le(V.date).getTime()
1629
+ );
1630
+ for (let _ = 1; _ < z.length; _++) {
1631
+ const V = z[_ - 1], ae = z[_], ue = V.forecast ?? V.value, se = ae.forecast ?? ae.value;
1632
+ if (ue != null && se != null && ue > n && se <= n) {
1633
+ const ge = (ue - n) / (ue - se), _e = le(V.date).getTime(), we = le(ae.date).getTime(), Se = _e + ge * (we - _e);
1634
+ return new Date(Se);
1635
+ }
1636
+ }
1637
+ return null;
1638
+ }, [m, W]), J = te(
1639
+ (n, M) => {
1640
+ const z = n.filter((_) => _[M] != null).map((_) => ({ x: F(le(_.date)), y: q(_[M]) }));
1641
+ return z.length === 0 ? "" : `M ${z.map((_) => `${_.x},${_.y}`).join(" L ")}`;
1642
+ },
1643
+ [F, q]
1644
+ ), pe = te(
1645
+ (n) => {
1646
+ const M = n.filter((V) => V.lowerBound != null && V.upperBound != null);
1647
+ if (M.length === 0) return "";
1648
+ const z = M.map((V) => ({
1649
+ x: F(le(V.date)),
1650
+ y: q(V.upperBound)
1651
+ })), _ = M.map((V) => ({ x: F(le(V.date)), y: q(V.lowerBound) })).reverse();
1652
+ return `M ${z.map((V) => `${V.x},${V.y}`).join(" L ")} L ${_.map((V) => `${V.x},${V.y}`).join(" L ")} Z`;
1653
+ },
1654
+ [F, q]
1655
+ ), $ = te(
1656
+ (n) => {
1657
+ if (!ne.current || f?.enabled === !1) return;
1658
+ const M = ne.current.getBoundingClientRect(), z = n.clientX - M.left;
1659
+ n.clientY - M.top;
1660
+ let _ = null, V = 1 / 0;
1661
+ for (const ae of de) {
1662
+ const ue = F(ae), se = Math.abs(ue - z);
1663
+ se < V && (V = se, _ = ae);
1664
+ }
1665
+ if (_ && V < 50) {
1666
+ const ae = W.filter((se) => se.visible !== !1).map((se) => {
1667
+ const ge = se.data.find((_e) => le(_e.date).getTime() === _.getTime());
1668
+ return {
1669
+ scenario: se,
1670
+ value: ge?.value,
1671
+ forecast: ge?.forecast,
1672
+ lowerBound: ge?.lowerBound,
1673
+ upperBound: ge?.upperBound
1674
+ };
1675
+ }), ue = r.filter(
1676
+ (se) => Math.abs(le(se.date).getTime() - _.getTime()) < 864e5
1677
+ );
1678
+ X({ date: _, values: ae, annotations: ue }), ee({ x: n.clientX - M.left + 10, y: n.clientY - M.top - 10 });
1679
+ } else
1680
+ X(null);
1681
+ },
1682
+ [F, de, W, r, f]
1683
+ ), E = te(
1684
+ (n) => {
1685
+ if (!S.interactive) return;
1686
+ U((z) => z.map((_) => _.id === n ? { ..._, visible: !_.visible } : _));
1687
+ const M = W.find((z) => z.id === n);
1688
+ M && g?.(n, !M.visible);
1689
+ },
1690
+ [S.interactive, W, g]
1691
+ );
1692
+ Ie(
1693
+ d,
1694
+ () => ({
1695
+ getScenarios: () => W,
1696
+ updateScenario: (n, M) => {
1697
+ U((z) => z.map((_) => _.id === n ? { ..._, data: M } : _));
1698
+ },
1699
+ toggleScenario: E,
1700
+ setZoomRange: () => {
1701
+ },
1702
+ // Would need pan/zoom implementation
1703
+ resetZoom: () => {
1704
+ },
1705
+ exportImage: (n) => {
1706
+ if (!ne.current) return null;
1707
+ const M = ne.current, _ = new XMLSerializer().serializeToString(M);
1708
+ return `data:image/svg+xml;base64,${btoa(_)}`;
1709
+ },
1710
+ getDataAtDate: (n) => {
1711
+ const M = W.filter((z) => z.visible !== !1).map((z) => {
1712
+ const _ = z.data.find((V) => le(V.date).getTime() === n.getTime());
1713
+ return {
1714
+ scenario: z,
1715
+ value: _?.value,
1716
+ forecast: _?.forecast,
1717
+ lowerBound: _?.lowerBound,
1718
+ upperBound: _?.upperBound
1719
+ };
1720
+ });
1721
+ return {
1722
+ date: n,
1723
+ values: M,
1724
+ annotations: r.filter((z) => le(z.date).getTime() === n.getTime())
1725
+ };
1726
+ }
1727
+ }),
1728
+ [W, r, E]
1729
+ ), P.width - D.left - D.right;
1730
+ const Y = P.height - D.top - D.bottom, ce = me(() => {
1731
+ const n = l?.tickCount ?? 5, M = [], z = (ye - xe) / (n - 1);
1732
+ for (let _ = 0; _ < n; _++)
1733
+ M.push(xe + z * _);
1734
+ return M;
1735
+ }, [xe, ye, l?.tickCount]), oe = me(() => {
1736
+ const n = C?.tickCount ?? 6;
1737
+ if (de.length === 0) return [];
1738
+ const M = Math.max(1, Math.floor(de.length / (n - 1)));
1739
+ return de.filter((z, _) => _ % M === 0 || _ === de.length - 1);
1740
+ }, [de, C?.tickCount]);
1741
+ return W.length === 0 || W.every((n) => n.data.length === 0) ? /* @__PURE__ */ e("div", { className: `nice-forecast-chart ${G ?? ""}`, style: j, children: /* @__PURE__ */ e("div", { className: "nice-forecast-chart__empty", children: B.noData ?? "No data available" }) }) : /* @__PURE__ */ k("div", { className: `nice-forecast-chart ${G ?? ""}`, style: { ...j, height: y }, children: [
1742
+ /* @__PURE__ */ k("div", { ref: he, className: "nice-forecast-chart__container", children: [
1743
+ /* @__PURE__ */ k(
1744
+ "svg",
1745
+ {
1746
+ ref: ne,
1747
+ className: "nice-forecast-chart__svg",
1748
+ width: P.width,
1749
+ height: P.height,
1750
+ onMouseMove: $,
1751
+ onMouseLeave: () => X(null),
1752
+ children: [
1753
+ l?.showGrid !== !1 && ce.map((n) => /* @__PURE__ */ e(
1754
+ "line",
1755
+ {
1756
+ className: "nice-forecast-chart__grid-line",
1757
+ x1: D.left,
1758
+ x2: P.width - D.right,
1759
+ y1: q(n),
1760
+ y2: q(n)
1761
+ },
1762
+ n
1763
+ )),
1764
+ p && L && /* @__PURE__ */ e(
1765
+ "rect",
1766
+ {
1767
+ className: "nice-forecast-chart__forecast-region",
1768
+ x: F(L),
1769
+ y: D.top,
1770
+ width: P.width - D.right - F(L),
1771
+ height: Y
1772
+ }
1773
+ ),
1774
+ u.map((n) => /* @__PURE__ */ k("g", { children: [
1775
+ /* @__PURE__ */ e(
1776
+ "line",
1777
+ {
1778
+ className: "nice-forecast-chart__reference-line",
1779
+ x1: D.left,
1780
+ x2: P.width - D.right,
1781
+ y1: q(n.value),
1782
+ y2: q(n.value),
1783
+ stroke: n.color ?? "#9ca3af",
1784
+ strokeDasharray: n.dashArray ?? "4,2"
1785
+ }
1786
+ ),
1787
+ n.label && /* @__PURE__ */ e(
1788
+ "text",
1789
+ {
1790
+ className: "nice-forecast-chart__reference-label",
1791
+ x: P.width - D.right - 4,
1792
+ y: q(n.value) - 4,
1793
+ textAnchor: "end",
1794
+ children: n.label
1795
+ }
1796
+ )
1797
+ ] }, n.id)),
1798
+ H && m?.enabled && /* @__PURE__ */ k("g", { className: "nice-forecast-chart__cash-runway", children: [
1799
+ /* @__PURE__ */ e(
1800
+ "line",
1801
+ {
1802
+ className: "nice-forecast-chart__cash-runway-line",
1803
+ x1: F(H),
1804
+ x2: F(H),
1805
+ y1: D.top,
1806
+ y2: P.height - D.bottom,
1807
+ stroke: m.color ?? "#ef4444"
1808
+ }
1809
+ ),
1810
+ m.showLabel !== !1 && /* @__PURE__ */ k(Be, { children: [
1811
+ /* @__PURE__ */ e(
1812
+ "rect",
1813
+ {
1814
+ className: "nice-forecast-chart__cash-runway-label-bg",
1815
+ x: F(H) - 60,
1816
+ y: D.top - 2,
1817
+ width: 120,
1818
+ height: m.showDate !== !1 ? 32 : 20,
1819
+ fill: m.color ?? "#ef4444",
1820
+ rx: 4
1821
+ }
1822
+ ),
1823
+ /* @__PURE__ */ e(
1824
+ "text",
1825
+ {
1826
+ className: "nice-forecast-chart__cash-runway-label",
1827
+ x: F(H),
1828
+ y: D.top + 12,
1829
+ textAnchor: "middle",
1830
+ fill: "#ffffff",
1831
+ children: m.label ?? B.cashRunsOut ?? "💰 Cash runs out"
1832
+ }
1833
+ ),
1834
+ m.showDate !== !1 && /* @__PURE__ */ e(
1835
+ "text",
1836
+ {
1837
+ className: "nice-forecast-chart__cash-runway-label",
1838
+ x: F(H),
1839
+ y: D.top + 26,
1840
+ textAnchor: "middle",
1841
+ fill: "#ffffff",
1842
+ style: { fontSize: "0.625rem", opacity: 0.9 },
1843
+ children: Ae(H, R)
1844
+ }
1845
+ )
1846
+ ] })
1847
+ ] }),
1848
+ W.filter((n) => n.visible !== !1 && n.showConfidenceBand).map((n) => /* @__PURE__ */ e(
1849
+ "path",
1850
+ {
1851
+ className: "nice-forecast-chart__confidence-band",
1852
+ d: pe(n.data),
1853
+ fill: n.color
1854
+ },
1855
+ `band-${n.id}`
1856
+ )),
1857
+ W.filter((n) => n.visible !== !1).map((n) => {
1858
+ const M = L ? n.data.filter((_) => le(_.date) < L) : n.data.filter((_) => _.value != null), z = L ? n.data.filter((_) => le(_.date) >= L) : n.data.filter((_) => _.forecast != null);
1859
+ return /* @__PURE__ */ k("g", { children: [
1860
+ /* @__PURE__ */ e(
1861
+ "path",
1862
+ {
1863
+ className: "nice-forecast-chart__historical-line",
1864
+ d: J(M, "value"),
1865
+ stroke: n.color,
1866
+ strokeWidth: o
1867
+ }
1868
+ ),
1869
+ /* @__PURE__ */ e(
1870
+ "path",
1871
+ {
1872
+ className: "nice-forecast-chart__forecast-line",
1873
+ d: J(z, L ? "value" : "forecast"),
1874
+ stroke: n.color,
1875
+ strokeWidth: o
1876
+ }
1877
+ ),
1878
+ z.length > 0 && n.data.some((_) => _.forecast != null) && /* @__PURE__ */ e(
1879
+ "path",
1880
+ {
1881
+ className: "nice-forecast-chart__forecast-line",
1882
+ d: J(n.data, "forecast"),
1883
+ stroke: n.color,
1884
+ strokeWidth: o
1885
+ }
1886
+ ),
1887
+ s && n.data.map((_, V) => {
1888
+ const ae = _.value ?? _.forecast;
1889
+ return ae == null ? null : /* @__PURE__ */ e(
1890
+ "circle",
1891
+ {
1892
+ className: "nice-forecast-chart__point",
1893
+ cx: F(le(_.date)),
1894
+ cy: q(ae),
1895
+ r: h,
1896
+ fill: n.color,
1897
+ onClick: () => N?.(_, n)
1898
+ },
1899
+ V
1900
+ );
1901
+ })
1902
+ ] }, n.id);
1903
+ }),
1904
+ r.map((n) => {
1905
+ const M = F(le(n.date));
1906
+ return /* @__PURE__ */ k(
1907
+ "g",
1908
+ {
1909
+ className: "nice-forecast-chart__annotation-marker",
1910
+ onClick: () => I?.(n),
1911
+ children: [
1912
+ n.showLine !== !1 && /* @__PURE__ */ e(
1913
+ "line",
1914
+ {
1915
+ className: "nice-forecast-chart__annotation-line",
1916
+ x1: M,
1917
+ x2: M,
1918
+ y1: D.top,
1919
+ y2: P.height - D.bottom,
1920
+ stroke: n.color ?? "#9ca3af"
1921
+ }
1922
+ ),
1923
+ /* @__PURE__ */ e("circle", { cx: M, cy: D.top + 10, r: 8, fill: n.color ?? "#9ca3af" }),
1924
+ /* @__PURE__ */ e("text", { x: M, y: D.top + 14, textAnchor: "middle", fill: "white", fontSize: "10", children: n.icon ?? "!" })
1925
+ ]
1926
+ },
1927
+ n.id
1928
+ );
1929
+ }),
1930
+ /* @__PURE__ */ e(
1931
+ "line",
1932
+ {
1933
+ className: "nice-forecast-chart__axis-line",
1934
+ x1: D.left,
1935
+ x2: D.left,
1936
+ y1: D.top,
1937
+ y2: P.height - D.bottom
1938
+ }
1939
+ ),
1940
+ /* @__PURE__ */ e(
1941
+ "line",
1942
+ {
1943
+ className: "nice-forecast-chart__axis-line",
1944
+ x1: D.left,
1945
+ x2: P.width - D.right,
1946
+ y1: P.height - D.bottom,
1947
+ y2: P.height - D.bottom
1948
+ }
1949
+ ),
1950
+ ce.map((n) => /* @__PURE__ */ e(
1951
+ "text",
1952
+ {
1953
+ className: "nice-forecast-chart__axis-label",
1954
+ x: D.left - 8,
1955
+ y: q(n) + 4,
1956
+ textAnchor: "end",
1957
+ children: l?.format ? l.format(n) : Me(n, R)
1958
+ },
1959
+ n
1960
+ )),
1961
+ oe.map((n) => /* @__PURE__ */ e(
1962
+ "text",
1963
+ {
1964
+ className: "nice-forecast-chart__axis-label",
1965
+ x: F(n),
1966
+ y: P.height - D.bottom + 16,
1967
+ textAnchor: "middle",
1968
+ children: C?.format ? C.format(n) : Ae(n, R)
1969
+ },
1970
+ n.getTime()
1971
+ )),
1972
+ l?.title && /* @__PURE__ */ e(
1973
+ "text",
1974
+ {
1975
+ className: "nice-forecast-chart__axis-title",
1976
+ x: 15,
1977
+ y: P.height / 2,
1978
+ textAnchor: "middle",
1979
+ transform: `rotate(-90, 15, ${P.height / 2})`,
1980
+ children: l.title
1981
+ }
1982
+ )
1983
+ ]
1984
+ }
1985
+ ),
1986
+ Z && /* @__PURE__ */ k(
1987
+ "div",
1988
+ {
1989
+ className: "nice-forecast-chart__tooltip",
1990
+ style: { left: K.x, top: K.y },
1991
+ children: [
1992
+ /* @__PURE__ */ e("div", { className: "nice-forecast-chart__tooltip-date", children: Ae(Z.date, R) }),
1993
+ Z.values.map((n) => {
1994
+ const M = n.value ?? n.forecast;
1995
+ return M == null ? null : /* @__PURE__ */ k("div", { className: "nice-forecast-chart__tooltip-item", children: [
1996
+ /* @__PURE__ */ e(
1997
+ "span",
1998
+ {
1999
+ className: "nice-forecast-chart__tooltip-color",
2000
+ style: { background: n.scenario.color }
2001
+ }
2002
+ ),
2003
+ /* @__PURE__ */ e("span", { className: "nice-forecast-chart__tooltip-label", children: n.scenario.name }),
2004
+ /* @__PURE__ */ e("span", { className: "nice-forecast-chart__tooltip-value", children: Me(M, R) })
2005
+ ] }, n.scenario.id);
2006
+ }),
2007
+ Z.values.some((n) => n.lowerBound != null) && /* @__PURE__ */ k("div", { className: "nice-forecast-chart__tooltip-confidence", children: [
2008
+ B.confidence ?? "CI",
2009
+ ":",
2010
+ " ",
2011
+ Me(Z.values[0]?.lowerBound ?? 0, R),
2012
+ " –",
2013
+ " ",
2014
+ Me(Z.values[0]?.upperBound ?? 0, R)
2015
+ ] })
2016
+ ]
2017
+ }
2018
+ )
2019
+ ] }),
2020
+ S.enabled && /* @__PURE__ */ e("div", { className: "nice-forecast-chart__legend", children: W.map((n) => /* @__PURE__ */ k(
2021
+ "div",
2022
+ {
2023
+ className: `nice-forecast-chart__legend-item ${n.visible === !1 ? "nice-forecast-chart__legend-item--hidden" : ""}`,
2024
+ onClick: () => E(n.id),
2025
+ children: [
2026
+ /* @__PURE__ */ e(
2027
+ "span",
2028
+ {
2029
+ className: `nice-forecast-chart__legend-color ${n.isBase ? "" : "nice-forecast-chart__legend-color--dashed"}`,
2030
+ style: { background: n.color }
2031
+ }
2032
+ ),
2033
+ n.name
2034
+ ]
2035
+ },
2036
+ n.id
2037
+ )) })
2038
+ ] });
2039
+ }
2040
+ ), Xe = ve(({
2041
+ data: t,
2042
+ renderNode: a,
2043
+ selectable: d,
2044
+ selectedKey: c,
2045
+ onSelect: r,
2046
+ direction: u = "top-down",
2047
+ collapsible: i = !0,
2048
+ className: m,
2049
+ style: C,
2050
+ id: l
2051
+ }, v) => {
2052
+ const f = ke(l), [S, y] = ie(/* @__PURE__ */ new Set()), p = te((h) => {
2053
+ y((w) => {
2054
+ const b = new Set(w);
2055
+ return b.has(h) ? b.delete(h) : b.add(h), b;
2056
+ });
2057
+ }, []), o = te((h) => {
2058
+ d && r?.(h);
2059
+ }, [d, r]), s = te((h) => {
2060
+ const w = S.has(h.key), b = h.children && h.children.length > 0;
2061
+ return /* @__PURE__ */ k("li", { className: "nice-org-chart__item", children: [
2062
+ /* @__PURE__ */ k(
2063
+ "div",
2064
+ {
2065
+ className: `nice-org-chart__node${c === h.key ? " nice-org-chart__node--selected" : ""}`,
2066
+ onClick: () => o(h.key),
2067
+ role: d ? "button" : void 0,
2068
+ children: [
2069
+ a ? a(h) : /* @__PURE__ */ e("span", { children: h.label }),
2070
+ i && b && /* @__PURE__ */ e(
2071
+ "button",
2072
+ {
2073
+ type: "button",
2074
+ className: "nice-org-chart__toggle",
2075
+ onClick: (A) => {
2076
+ A.stopPropagation(), p(h.key);
2077
+ },
2078
+ "aria-label": w ? "Expand" : "Collapse",
2079
+ children: w ? "+" : "−"
2080
+ }
2081
+ )
2082
+ ]
2083
+ }
2084
+ ),
2085
+ b && !w && /* @__PURE__ */ e("ul", { className: "nice-org-chart__children", children: h.children.map((A) => s(A)) })
2086
+ ] }, h.key);
2087
+ }, [S, c, a, d, i, o, p]);
2088
+ return /* @__PURE__ */ e(
2089
+ "div",
2090
+ {
2091
+ ref: v,
2092
+ id: f,
2093
+ className: `nice-org-chart nice-org-chart--${u} ${m || ""}`,
2094
+ style: C,
2095
+ children: /* @__PURE__ */ e("ul", { className: "nice-org-chart__root", children: s(t) })
2096
+ }
2097
+ );
2098
+ });
2099
+ Xe.displayName = "NiceOrganizationChart";
2100
+ function Ze(t, a, d) {
2101
+ const c = (y) => {
2102
+ const p = y.replace("#", "");
2103
+ return [parseInt(p.slice(0, 2), 16), parseInt(p.slice(2, 4), 16), parseInt(p.slice(4, 6), 16)];
2104
+ }, [r, u, i] = c(t), [m, C, l] = c(a), v = Math.round(r + (m - r) * d), f = Math.round(u + (C - u) * d), S = Math.round(i + (l - i) * d);
2105
+ return `rgb(${v},${f},${S})`;
2106
+ }
2107
+ const Ge = ve(({
2108
+ data: t,
2109
+ xLabels: a,
2110
+ yLabels: d,
2111
+ colors: c = ["#e0f2fe", "#1d4ed8"],
2112
+ onCellClick: r,
2113
+ cellSize: u = 40,
2114
+ showValues: i = !0,
2115
+ className: m,
2116
+ style: C,
2117
+ id: l
2118
+ }, v) => {
2119
+ const f = ke(l), { minVal: S, maxVal: y } = me(() => {
2120
+ let o = 1 / 0, s = -1 / 0;
2121
+ for (const h of t) for (const w of h)
2122
+ w < o && (o = w), w > s && (s = w);
2123
+ return { minVal: o, maxVal: s };
2124
+ }, [t]), p = te((o) => y === S ? 0.5 : (o - S) / (y - S), [S, y]);
2125
+ return /* @__PURE__ */ e("div", { ref: v, id: f, className: `nice-heatmap ${m || ""}`, style: C, children: /* @__PURE__ */ k("table", { className: "nice-heatmap__table", children: [
2126
+ a && /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ k("tr", { children: [
2127
+ d && /* @__PURE__ */ e("th", {}),
2128
+ a.map((o, s) => /* @__PURE__ */ e("th", { className: "nice-heatmap__header", children: o }, s))
2129
+ ] }) }),
2130
+ /* @__PURE__ */ e("tbody", { children: t.map((o, s) => /* @__PURE__ */ k("tr", { children: [
2131
+ d && /* @__PURE__ */ e("th", { className: "nice-heatmap__row-label", children: d[s] }),
2132
+ o.map((h, w) => /* @__PURE__ */ e(
2133
+ "td",
2134
+ {
2135
+ className: "nice-heatmap__cell",
2136
+ style: {
2137
+ background: Ze(c[0], c[1], p(h)),
2138
+ width: u,
2139
+ height: u,
2140
+ textAlign: "center",
2141
+ color: p(h) > 0.6 ? "#fff" : "#333",
2142
+ cursor: r ? "pointer" : void 0
2143
+ },
2144
+ onClick: () => r?.(s, w, h),
2145
+ title: String(h),
2146
+ children: i ? h : ""
2147
+ },
2148
+ w
2149
+ ))
2150
+ ] }, s)) })
2151
+ ] }) });
2152
+ });
2153
+ Ge.displayName = "NiceHeatMap";
2154
+ function Ue(t, a) {
2155
+ const d = t.reduce((l, v) => l + v.value, 0);
2156
+ if (d === 0 || t.length === 0) return [];
2157
+ const c = [];
2158
+ let { x: r, y: u, w: i, h: m } = a;
2159
+ const C = [...t].sort((l, v) => v.value - l.value);
2160
+ for (const l of C) {
2161
+ const v = l.value / d;
2162
+ if (i >= m) {
2163
+ const f = i * v;
2164
+ c.push({ x: r, y: u, w: f, h: m, node: l }), r += f, i -= f;
2165
+ } else {
2166
+ const f = m * v;
2167
+ c.push({ x: r, y: u, w: i, h: f, node: l }), u += f, m -= f;
2168
+ }
2169
+ }
2170
+ return c;
2171
+ }
2172
+ const qe = ["#3b82f6", "#10b981", "#f59e0b", "#ef4444", "#8b5cf6", "#06b6d4", "#ec4899", "#84cc16"], Je = ve(({
2173
+ data: t,
2174
+ width: a = 600,
2175
+ height: d = 400,
2176
+ onNodeClick: c,
2177
+ colors: r = qe,
2178
+ className: u,
2179
+ style: i,
2180
+ id: m
2181
+ }, C) => {
2182
+ const l = ke(m), v = me(() => {
2183
+ const f = t.children ?? [t];
2184
+ return Ue(f, { x: 0, y: 0, w: a, h: d });
2185
+ }, [t, a, d]);
2186
+ return /* @__PURE__ */ e("div", { ref: C, id: l, className: `nice-treemap ${u || ""}`, style: i, children: /* @__PURE__ */ e("svg", { width: a, height: d, className: "nice-treemap__svg", children: v.map((f, S) => /* @__PURE__ */ k("g", { onClick: () => c?.(f.node), style: { cursor: c ? "pointer" : void 0 }, children: [
2187
+ /* @__PURE__ */ e(
2188
+ "rect",
2189
+ {
2190
+ x: f.x,
2191
+ y: f.y,
2192
+ width: Math.max(f.w - 1, 0),
2193
+ height: Math.max(f.h - 1, 0),
2194
+ fill: f.node.color ?? r[S % r.length],
2195
+ rx: 2
2196
+ }
2197
+ ),
2198
+ f.w > 40 && f.h > 20 && /* @__PURE__ */ e(
2199
+ "text",
2200
+ {
2201
+ x: f.x + f.w / 2,
2202
+ y: f.y + f.h / 2,
2203
+ textAnchor: "middle",
2204
+ dominantBaseline: "central",
2205
+ fill: "#fff",
2206
+ fontSize: Math.min(12, f.w / 6),
2207
+ className: "nice-treemap__label",
2208
+ children: f.node.label
2209
+ }
2210
+ )
2211
+ ] }, f.node.key)) }) });
2212
+ });
2213
+ Je.displayName = "NiceTreeMap";
2214
+ const Qe = ve(({
2215
+ data: t,
2216
+ type: a = "candlestick",
2217
+ showVolume: d = !0,
2218
+ width: c = 800,
2219
+ height: r = 400,
2220
+ bullColor: u = "#22c55e",
2221
+ bearColor: i = "#ef4444",
2222
+ className: m,
2223
+ style: C,
2224
+ id: l
2225
+ }, v) => {
2226
+ const f = ke(l), S = { top: 20, right: 20, bottom: d ? 80 : 30, left: 60 }, y = c - S.left - S.right, p = d ? 50 : 0, o = r - S.top - S.bottom - p, { minP: s, maxP: h, maxVol: w } = me(() => {
2227
+ let g = 1 / 0, T = -1 / 0, x = 0;
2228
+ for (const O of t)
2229
+ O.low < g && (g = O.low), O.high > T && (T = O.high), O.volume && O.volume > x && (x = O.volume);
2230
+ return { minP: g, maxP: T, maxVol: x };
2231
+ }, [t]), b = Math.max(1, y / t.length * 0.7), A = (g) => S.left + (g + 0.5) * (y / t.length), N = (g) => S.top + o - (g - s) / (h - s || 1) * o, I = (g) => r - S.bottom - p + p * (1 - g / (w || 1));
2232
+ return /* @__PURE__ */ e("div", { ref: v, id: f, className: `nice-stock-chart ${m || ""}`, style: C, children: /* @__PURE__ */ k("svg", { width: c, height: r, className: "nice-stock-chart__svg", children: [
2233
+ [0, 0.25, 0.5, 0.75, 1].map((g) => {
2234
+ const T = s + g * (h - s);
2235
+ return /* @__PURE__ */ k("g", { children: [
2236
+ /* @__PURE__ */ e(
2237
+ "line",
2238
+ {
2239
+ x1: S.left,
2240
+ x2: c - S.right,
2241
+ y1: N(T),
2242
+ y2: N(T),
2243
+ stroke: "#e5e7eb",
2244
+ strokeDasharray: "2,2"
2245
+ }
2246
+ ),
2247
+ /* @__PURE__ */ e("text", { x: S.left - 4, y: N(T) + 4, textAnchor: "end", fontSize: 10, fill: "#888", children: T.toFixed(2) })
2248
+ ] }, g);
2249
+ }),
2250
+ a === "line" ? /* @__PURE__ */ e(
2251
+ "polyline",
2252
+ {
2253
+ points: t.map((g, T) => `${A(T)},${N(g.close)}`).join(" "),
2254
+ fill: "none",
2255
+ stroke: u,
2256
+ strokeWidth: 1.5
2257
+ }
2258
+ ) : t.map((g, T) => {
2259
+ const x = g.close >= g.open, O = x ? u : i, B = A(T);
2260
+ if (a === "ohlc")
2261
+ return /* @__PURE__ */ k("g", { children: [
2262
+ /* @__PURE__ */ e("line", { x1: B, x2: B, y1: N(g.high), y2: N(g.low), stroke: O, strokeWidth: 1 }),
2263
+ /* @__PURE__ */ e("line", { x1: B - b / 2, x2: B, y1: N(g.open), y2: N(g.open), stroke: O, strokeWidth: 1.5 }),
2264
+ /* @__PURE__ */ e("line", { x1: B, x2: B + b / 2, y1: N(g.close), y2: N(g.close), stroke: O, strokeWidth: 1.5 })
2265
+ ] }, T);
2266
+ const R = N(Math.max(g.open, g.close)), G = N(Math.min(g.open, g.close));
2267
+ return /* @__PURE__ */ k("g", { children: [
2268
+ /* @__PURE__ */ e("line", { x1: B, x2: B, y1: N(g.high), y2: N(g.low), stroke: O, strokeWidth: 1 }),
2269
+ /* @__PURE__ */ e(
2270
+ "rect",
2271
+ {
2272
+ x: B - b / 2,
2273
+ y: R,
2274
+ width: b,
2275
+ height: Math.max(G - R, 1),
2276
+ fill: x ? "transparent" : O,
2277
+ stroke: O,
2278
+ strokeWidth: 1
2279
+ }
2280
+ )
2281
+ ] }, T);
2282
+ }),
2283
+ d && t.map((g, T) => {
2284
+ if (!g.volume) return null;
2285
+ const x = g.close >= g.open;
2286
+ return /* @__PURE__ */ e(
2287
+ "rect",
2288
+ {
2289
+ x: A(T) - b / 2,
2290
+ y: I(g.volume),
2291
+ width: b,
2292
+ height: r - S.bottom - I(g.volume),
2293
+ fill: x ? u : i,
2294
+ opacity: 0.3
2295
+ },
2296
+ `v${T}`
2297
+ );
2298
+ }),
2299
+ t.map((g, T) => T % Math.max(1, Math.floor(t.length / 8)) !== 0 ? null : /* @__PURE__ */ e(
2300
+ "text",
2301
+ {
2302
+ x: A(T),
2303
+ y: r - S.bottom + p + 14,
2304
+ textAnchor: "middle",
2305
+ fontSize: 9,
2306
+ fill: "#888",
2307
+ children: g.date
2308
+ },
2309
+ `l${T}`
2310
+ ))
2311
+ ] }) });
2312
+ });
2313
+ Qe.displayName = "NiceStockChart";
2314
+ export {
2315
+ fe as C,
2316
+ ft as N,
2317
+ mt as a,
2318
+ De as b,
2319
+ ct as c,
2320
+ ht as d,
2321
+ _t as e,
2322
+ pt as f,
2323
+ Ge as g,
2324
+ dt as h,
2325
+ Fe as i,
2326
+ Xe as j,
2327
+ it as k,
2328
+ lt as l,
2329
+ xt as m,
2330
+ Ee as n,
2331
+ ut as o,
2332
+ Qe as p,
2333
+ Je as q,
2334
+ Ye as r,
2335
+ st as s,
2336
+ at as t,
2337
+ ot as u,
2338
+ rt as v,
2339
+ gt as w,
2340
+ yt as x
2341
+ };