@nice2dev/ui-3d 1.1.0 → 1.1.1

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