@nova-lab/charts 0.0.0-stage → 1.0.1-dev.32

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 (228) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +158 -2
  3. package/dist/GeometryIndex-DDQ34Jf4.js +104 -0
  4. package/dist/MarkSeries-CQCAnV4s.js +245 -0
  5. package/dist/aggregation.d.ts +6 -0
  6. package/dist/aggregation.js +124 -0
  7. package/dist/annotations.d.ts +34 -0
  8. package/dist/annotations.js +71 -0
  9. package/dist/api/camera.d.ts +8 -0
  10. package/dist/api/cartesian.d.ts +21 -0
  11. package/dist/api/events.d.ts +13 -0
  12. package/dist/api/font.d.ts +3 -0
  13. package/dist/api/handle.d.ts +5 -0
  14. package/dist/api/host.d.ts +23 -0
  15. package/dist/api/internal.d.ts +41 -0
  16. package/dist/api/map-background.d.ts +12 -0
  17. package/dist/api/mark-paint.d.ts +5 -0
  18. package/dist/api/mark-style.d.ts +4 -0
  19. package/dist/api/navigation.d.ts +4 -0
  20. package/dist/api/overlay.d.ts +7 -0
  21. package/dist/api/partition.d.ts +11 -0
  22. package/dist/api/scene.d.ts +42 -0
  23. package/dist/api/state.d.ts +34 -0
  24. package/dist/api/types.d.ts +743 -0
  25. package/dist/area.d.ts +9 -0
  26. package/dist/area.js +706 -0
  27. package/dist/bar.d.ts +9 -0
  28. package/dist/bar.js +554 -0
  29. package/dist/brush.d.ts +17 -0
  30. package/dist/brush.js +86 -0
  31. package/dist/bubble.d.ts +8 -0
  32. package/dist/bubble.js +434 -0
  33. package/dist/camera-CUJAMfpx.js +57 -0
  34. package/dist/candlestick.d.ts +8 -0
  35. package/dist/candlestick.js +42 -0
  36. package/dist/cartesian-k_WIYsGp.js +1139 -0
  37. package/dist/chart-runtime-resolver-DwwXp3X8.js +20 -0
  38. package/dist/chart-series-runtime-C0P7h8Tl.js +127 -0
  39. package/dist/charts.js +1 -0
  40. package/dist/composed.d.ts +2 -0
  41. package/dist/composed.js +4 -0
  42. package/dist/crosshair.d.ts +23 -0
  43. package/dist/crosshair.js +60 -0
  44. package/dist/donut.d.ts +5 -0
  45. package/dist/donut.js +7 -0
  46. package/dist/funnel.d.ts +5 -0
  47. package/dist/funnel.js +40 -0
  48. package/dist/graph.d.ts +6 -0
  49. package/dist/graph.js +260 -0
  50. package/dist/heatmap.d.ts +8 -0
  51. package/dist/heatmap.js +37 -0
  52. package/dist/host-DLDeDU5k.js +4373 -0
  53. package/dist/index.d.ts +1 -0
  54. package/dist/internal-I5BDhahD.js +4 -0
  55. package/dist/layout-donut-BG4ubBtU.js +39 -0
  56. package/dist/line.d.ts +9 -0
  57. package/dist/line.js +452 -0
  58. package/dist/mark-paint-CMHKGegE.js +14 -0
  59. package/dist/mark-style-Cpl-ARQM.js +10 -0
  60. package/dist/model/area/create-area-series-layout.d.ts +15 -0
  61. package/dist/model/area/hit-test-area-layout.d.ts +2 -0
  62. package/dist/model/axis/ChartAxisModel.d.ts +28 -0
  63. package/dist/model/bar/create-bar-series-layout.d.ts +19 -0
  64. package/dist/model/bar/hit-test-bar-layout.d.ts +2 -0
  65. package/dist/model/bubble/create-bubble-series-layout.d.ts +15 -0
  66. package/dist/model/bubble/hit-test-bubble-layout.d.ts +2 -0
  67. package/dist/model/cartesian/append-line-contours.d.ts +4 -0
  68. package/dist/model/cartesian/axis-line-batch.d.ts +3 -0
  69. package/dist/model/cartesian/numeric-window.d.ts +7 -0
  70. package/dist/model/cartesian/point-series.d.ts +54 -0
  71. package/dist/model/cartesian/sample-extrema.d.ts +7 -0
  72. package/dist/model/cartesian/smooth-y.d.ts +4 -0
  73. package/dist/model/cartesian/translation-window.d.ts +17 -0
  74. package/dist/model/context/nova-chart-runtime.d.ts +54 -0
  75. package/dist/model/customization/chart-customization.d.ts +47 -0
  76. package/dist/model/customization/chart-presets.d.ts +6 -0
  77. package/dist/model/customization/chart-style-sheet.d.ts +9 -0
  78. package/dist/model/data/ChartDataStore.d.ts +113 -0
  79. package/dist/model/exploration/create-graph-layout.d.ts +11 -0
  80. package/dist/model/exploration/exploration-chart.types.d.ts +150 -0
  81. package/dist/model/exploration/force-layout.d.ts +9 -0
  82. package/dist/model/exploration/presets/airplane.d.ts +2 -0
  83. package/dist/model/exploration/presets/apartment.d.ts +2 -0
  84. package/dist/model/exploration/presets/botanical-park.d.ts +2 -0
  85. package/dist/model/exploration/presets/ferry.d.ts +2 -0
  86. package/dist/model/exploration/presets/ice-arena.d.ts +2 -0
  87. package/dist/model/exploration/presets/planetarium.d.ts +2 -0
  88. package/dist/model/exploration/presets/science-museum.d.ts +2 -0
  89. package/dist/model/exploration/presets/train.d.ts +2 -0
  90. package/dist/model/exploration/route-geometry.d.ts +9 -0
  91. package/dist/model/exploration/seat-shape.d.ts +7 -0
  92. package/dist/model/interaction/GeometryIndex.d.ts +14 -0
  93. package/dist/model/line/create-line-series-layout.d.ts +15 -0
  94. package/dist/model/line/hit-test-line-layout.d.ts +2 -0
  95. package/dist/model/novel/create-novel-layout.d.ts +5 -0
  96. package/dist/model/novel/hit-test-novel-layout.d.ts +3 -0
  97. package/dist/model/novel/layout-candlestick.d.ts +3 -0
  98. package/dist/model/novel/layout-donut.d.ts +3 -0
  99. package/dist/model/novel/layout-funnel.d.ts +3 -0
  100. package/dist/model/novel/layout-heatmap.d.ts +3 -0
  101. package/dist/model/novel/layout-input.d.ts +12 -0
  102. package/dist/model/novel/layout-radar.d.ts +3 -0
  103. package/dist/model/novel/layout-tree.d.ts +3 -0
  104. package/dist/model/novel/layout-treemap.d.ts +3 -0
  105. package/dist/model/novel/layout-values.d.ts +10 -0
  106. package/dist/model/novel/novel-chart.types.d.ts +140 -0
  107. package/dist/model/novel/novel-domains.d.ts +5 -0
  108. package/dist/model/scale/BandScale.d.ts +86 -0
  109. package/dist/model/scale/ChartScaleRegistry.d.ts +45 -0
  110. package/dist/model/scale/LinearScale.d.ts +48 -0
  111. package/dist/model/scale/TimeScale.d.ts +48 -0
  112. package/dist/model/scale/create-chart-scale.d.ts +3 -0
  113. package/dist/model/scale/resolve-chart-scale.d.ts +5 -0
  114. package/dist/model/scatter/create-scatter-series-layout.d.ts +14 -0
  115. package/dist/model/scatter/hit-test-scatter-layout.d.ts +4 -0
  116. package/dist/model/time/calendar-time.d.ts +16 -0
  117. package/dist/model/types/chart-axis.types.d.ts +43 -0
  118. package/dist/model/types/chart-components.types.d.ts +1393 -0
  119. package/dist/model/types/chart-scale.types.d.ts +78 -0
  120. package/dist/model/viewport-controller/viewport-controller.d.ts +5 -0
  121. package/dist/novel-domains-DBpA_AOT.js +24 -0
  122. package/dist/partition-D-0LTCr3.js +221 -0
  123. package/dist/presets/route-map/apartment.d.ts +2 -0
  124. package/dist/presets/route-map/apartment.js +116 -0
  125. package/dist/presets/route-map/botanical-park.d.ts +2 -0
  126. package/dist/presets/route-map/botanical-park.js +116 -0
  127. package/dist/presets/route-map/science-museum.d.ts +2 -0
  128. package/dist/presets/route-map/science-museum.js +45 -0
  129. package/dist/presets/seat-map/airplane.d.ts +2 -0
  130. package/dist/presets/seat-map/airplane.js +95 -0
  131. package/dist/presets/seat-map/ferry.d.ts +2 -0
  132. package/dist/presets/seat-map/ferry.js +54 -0
  133. package/dist/presets/seat-map/ice-arena.d.ts +2 -0
  134. package/dist/presets/seat-map/ice-arena.js +67 -0
  135. package/dist/presets/seat-map/planetarium.d.ts +2 -0
  136. package/dist/presets/seat-map/planetarium.js +54 -0
  137. package/dist/presets/seat-map/train.d.ts +2 -0
  138. package/dist/presets/seat-map/train.js +66 -0
  139. package/dist/presets.d.ts +78 -0
  140. package/dist/presets.js +14 -0
  141. package/dist/public.d.ts +2 -0
  142. package/dist/radar.d.ts +5 -0
  143. package/dist/radar.js +47 -0
  144. package/dist/rose.d.ts +5 -0
  145. package/dist/rose.js +7 -0
  146. package/dist/route-map.d.ts +6 -0
  147. package/dist/route-map.js +200 -0
  148. package/dist/scatter.d.ts +8 -0
  149. package/dist/scatter.js +433 -0
  150. package/dist/scene-CPvPzTaB.js +137 -0
  151. package/dist/seat-map.d.ts +6 -0
  152. package/dist/seat-map.js +84 -0
  153. package/dist/seat-shape--kEFiUXX.js +66 -0
  154. package/dist/state-C5pICb11.js +134 -0
  155. package/dist/sync.d.ts +82 -0
  156. package/dist/sync.js +326 -0
  157. package/dist/translation-window-Ca_rCenJ.js +57 -0
  158. package/dist/tree.d.ts +6 -0
  159. package/dist/tree.js +114 -0
  160. package/dist/treemap.d.ts +5 -0
  161. package/dist/treemap.js +85 -0
  162. package/dist/ui/area-series/AreaSeries.d.ts +44 -0
  163. package/dist/ui/area-series/area-series.config.d.ts +10 -0
  164. package/dist/ui/area-series/area-series.registry.d.ts +4 -0
  165. package/dist/ui/axis/Axis.d.ts +55 -0
  166. package/dist/ui/axis/axis.config.d.ts +10 -0
  167. package/dist/ui/axis/axis.registry.d.ts +4 -0
  168. package/dist/ui/bar-chart/BarChart.d.ts +124 -0
  169. package/dist/ui/bar-chart/bar-chart.config.d.ts +10 -0
  170. package/dist/ui/bar-chart/bar-chart.registry.d.ts +2 -0
  171. package/dist/ui/bar-series/BarSeries.d.ts +102 -0
  172. package/dist/ui/bar-series/bar-series.config.d.ts +10 -0
  173. package/dist/ui/bar-series/bar-series.registry.d.ts +4 -0
  174. package/dist/ui/bubble-series/BubbleSeries.d.ts +33 -0
  175. package/dist/ui/bubble-series/bubble-series.config.d.ts +10 -0
  176. package/dist/ui/bubble-series/bubble-series.registry.d.ts +4 -0
  177. package/dist/ui/composed-chart/ComposedChart.d.ts +41 -0
  178. package/dist/ui/composed-chart/composed-chart.config.d.ts +10 -0
  179. package/dist/ui/composed-chart/composed-chart.registry.d.ts +4 -0
  180. package/dist/ui/exploration-chart/ExplorationChart.d.ts +83 -0
  181. package/dist/ui/exploration-chart/exploration-chart.config.d.ts +7 -0
  182. package/dist/ui/exploration-chart/exploration-chart.registry.d.ts +6 -0
  183. package/dist/ui/grid/Grid.d.ts +35 -0
  184. package/dist/ui/grid/grid.config.d.ts +10 -0
  185. package/dist/ui/grid/grid.registry.d.ts +4 -0
  186. package/dist/ui/interaction/Interaction.d.ts +53 -0
  187. package/dist/ui/interaction/interaction.config.d.ts +10 -0
  188. package/dist/ui/interaction/interaction.registry.d.ts +4 -0
  189. package/dist/ui/legend/Legend.d.ts +38 -0
  190. package/dist/ui/legend/legend.config.d.ts +10 -0
  191. package/dist/ui/legend/legend.registry.d.ts +2 -0
  192. package/dist/ui/line-series/LineSeries.d.ts +67 -0
  193. package/dist/ui/line-series/line-series.config.d.ts +10 -0
  194. package/dist/ui/line-series/line-series.registry.d.ts +4 -0
  195. package/dist/ui/mark-series/MarkSeries.d.ts +55 -0
  196. package/dist/ui/novel-series/NovelSeries.d.ts +34 -0
  197. package/dist/ui/novel-series/novel-series.config.d.ts +9 -0
  198. package/dist/ui/novel-series/novel-series.registry.d.ts +4 -0
  199. package/dist/ui/partition-chart/PartitionChart.d.ts +24 -0
  200. package/dist/ui/partition-chart/partition-chart.config.d.ts +7 -0
  201. package/dist/ui/partition-chart/partition-chart.registry.d.ts +9 -0
  202. package/dist/ui/plot/Plot.d.ts +64 -0
  203. package/dist/ui/plot/plot.config.d.ts +10 -0
  204. package/dist/ui/plot/plot.registry.d.ts +4 -0
  205. package/dist/ui/root/Root.d.ts +206 -0
  206. package/dist/ui/root/root.config.d.ts +10 -0
  207. package/dist/ui/root/root.registry.d.ts +5 -0
  208. package/dist/ui/scale/Scale.d.ts +55 -0
  209. package/dist/ui/scale/scale.config.d.ts +10 -0
  210. package/dist/ui/scale/scale.registry.d.ts +4 -0
  211. package/dist/ui/scatter-series/ScatterSeries.d.ts +33 -0
  212. package/dist/ui/scatter-series/scatter-series.config.d.ts +10 -0
  213. package/dist/ui/scatter-series/scatter-series.registry.d.ts +4 -0
  214. package/dist/ui/shared/chart-props.d.ts +150 -0
  215. package/dist/ui/shared/chart-runtime-resolver.d.ts +4 -0
  216. package/dist/ui/shared/chart-semantic-marks.d.ts +20 -0
  217. package/dist/ui/shared/chart-series-runtime.d.ts +48 -0
  218. package/dist/ui/shared/schema-types.d.ts +34 -0
  219. package/dist/ui/tooltip/Tooltip.d.ts +64 -0
  220. package/dist/ui/tooltip/tooltip.config.d.ts +10 -0
  221. package/dist/ui/tooltip/tooltip.registry.d.ts +4 -0
  222. package/dist/ui/viewport/Viewport.d.ts +81 -0
  223. package/dist/ui/viewport/viewport.config.d.ts +10 -0
  224. package/dist/ui/viewport/viewport.registry.d.ts +2 -0
  225. package/dist/ui/viewport-controller/ViewportController.d.ts +30 -0
  226. package/dist/ui/viewport-controller/viewport-controller.config.d.ts +10 -0
  227. package/dist/ui/viewport-controller/viewport-controller.registry.d.ts +2 -0
  228. package/package.json +179 -4
@@ -0,0 +1,4373 @@
1
+ var Gt = Object.defineProperty;
2
+ var Ht = (e, i, t) => i in e ? Gt(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
3
+ var C = (e, i, t) => Ht(e, typeof i != "symbol" ? i + "" : i, t);
4
+ import { Nova as Mt, reconcileNovaTemplateChildren as Yt, NovaNode as Xt, RaphSchedulerType as Zt, RendererType as je } from "@nova-lab/core";
5
+ import { normalizeCommonProps as ke, finiteNumber as R, NOVA_UI_COMMON_FIELD_DEFINITIONS as Jt, NOVA_UI_COMMON_DIRTY_POLICY as dt, commonMeasureBounds as Qt, NovaUiComponentNode as ei, buildBoxSchema as ti, Root as ii, normalizeRootProps as ri } from "@nova-lab/ui-kit";
6
+ import { toZonedTime as Ft, fromZonedTime as ni } from "date-fns-tz";
7
+ import { c as ut } from "./internal-I5BDhahD.js";
8
+ import { C as ai, c as ht, s as he, a as Ke, r as V } from "./state-C5pICb11.js";
9
+ const si = Mt.createContextToken("NovaCharts.Runtime");
10
+ function nn(e) {
11
+ return typeof e == "object" && e !== null && typeof e.getNovaChartRuntime == "function";
12
+ }
13
+ const oi = [
14
+ "#2563eb",
15
+ "#16a34a",
16
+ "#f59e0b",
17
+ "#dc2626",
18
+ "#7c3aed",
19
+ "#0891b2",
20
+ "#db2777",
21
+ "#475569"
22
+ ], li = {
23
+ dashboard: be({
24
+ name: "dashboard",
25
+ tokens: {
26
+ background: "#ffffff",
27
+ surface: "#f8fafc",
28
+ axisColor: "#94a3b8",
29
+ gridColor: "#e2e8f0",
30
+ textColor: "#334155",
31
+ tooltipBackground: "#0f172a",
32
+ tooltipText: "#f8fafc",
33
+ legendText: "#475569",
34
+ viewportTrack: "rgba(148,163,184,0.24)",
35
+ viewportThumb: "rgba(71,85,105,0.72)",
36
+ selection: "#2563eb",
37
+ mutedOpacity: 0.28,
38
+ palette: [...oi]
39
+ },
40
+ styles: {
41
+ "BarSeries::bar": { borderRadius: 3 },
42
+ "LineSeries::segment": { strokeWidth: 2 },
43
+ "AreaSeries::fill": { opacity: 0.28 },
44
+ "ScatterSeries::point": { opacity: 0.88 },
45
+ "BubbleSeries::bubble": { opacity: 0.54 }
46
+ }
47
+ }),
48
+ editorial: be({
49
+ name: "editorial",
50
+ tokens: {
51
+ background: "#fbfbf8",
52
+ surface: "#f1f0ea",
53
+ axisColor: "#6b7280",
54
+ gridColor: "#dedbd1",
55
+ textColor: "#1f2937",
56
+ tooltipBackground: "#1f2937",
57
+ tooltipText: "#ffffff",
58
+ legendText: "#374151",
59
+ viewportTrack: "rgba(107,114,128,0.16)",
60
+ viewportThumb: "rgba(31,41,55,0.58)",
61
+ selection: "#b45309",
62
+ mutedOpacity: 0.3,
63
+ palette: ["#b45309", "#1f766d", "#7c2d12", "#4338ca", "#be123c", "#365314", "#0f766e", "#4b5563"]
64
+ },
65
+ styles: {
66
+ "BarSeries::bar": { borderRadius: 1 },
67
+ "LineSeries::segment": { strokeWidth: 2.5 },
68
+ "AreaSeries::fill": { opacity: 0.24 }
69
+ }
70
+ }),
71
+ financial: be({
72
+ name: "financial",
73
+ tokens: {
74
+ background: "#ffffff",
75
+ surface: "#f8fafc",
76
+ axisColor: "#64748b",
77
+ gridColor: "#dbe4ef",
78
+ textColor: "#0f172a",
79
+ tooltipBackground: "#0f172a",
80
+ tooltipText: "#f8fafc",
81
+ legendText: "#334155",
82
+ viewportTrack: "rgba(15,23,42,0.08)",
83
+ viewportThumb: "rgba(15,23,42,0.62)",
84
+ selection: "#0284c7",
85
+ mutedOpacity: 0.22,
86
+ palette: ["#16a34a", "#dc2626", "#0284c7", "#ca8a04", "#475569", "#7c3aed", "#0f766e", "#be123c"]
87
+ },
88
+ styles: {
89
+ "BarSeries::bar": { borderRadius: 0 },
90
+ "LineSeries::segment": { strokeWidth: 1.75 },
91
+ "AreaSeries::fill": { opacity: 0.18 },
92
+ "Grid::line": { opacity: 0.74 }
93
+ }
94
+ }),
95
+ scientific: be({
96
+ name: "scientific",
97
+ tokens: {
98
+ background: "#ffffff",
99
+ surface: "#f4f7fb",
100
+ axisColor: "#475569",
101
+ gridColor: "#cbd5e1",
102
+ textColor: "#111827",
103
+ tooltipBackground: "#111827",
104
+ tooltipText: "#ffffff",
105
+ legendText: "#1f2937",
106
+ viewportTrack: "rgba(71,85,105,0.14)",
107
+ viewportThumb: "rgba(37,99,235,0.68)",
108
+ selection: "#7c3aed",
109
+ mutedOpacity: 0.2,
110
+ palette: ["#2563eb", "#dc2626", "#16a34a", "#9333ea", "#ea580c", "#0891b2", "#be123c", "#4b5563"]
111
+ },
112
+ styles: {
113
+ "LineSeries::segment": { strokeWidth: 1.5 },
114
+ "ScatterSeries::point": { radius: 3.5, opacity: 0.78 },
115
+ "BubbleSeries::bubble": { opacity: 0.42 }
116
+ }
117
+ }),
118
+ minimal: be({
119
+ name: "minimal",
120
+ tokens: {
121
+ background: "#ffffff",
122
+ surface: "#ffffff",
123
+ axisColor: "#cbd5e1",
124
+ gridColor: "#eef2f7",
125
+ textColor: "#475569",
126
+ tooltipBackground: "#111827",
127
+ tooltipText: "#ffffff",
128
+ legendText: "#64748b",
129
+ viewportTrack: "rgba(203,213,225,0.36)",
130
+ viewportThumb: "rgba(100,116,139,0.48)",
131
+ selection: "#111827",
132
+ mutedOpacity: 0.18,
133
+ palette: ["#111827", "#64748b", "#94a3b8", "#2563eb", "#16a34a", "#f59e0b", "#dc2626", "#7c3aed"]
134
+ },
135
+ styles: {
136
+ "BarSeries::bar": { borderRadius: 2, opacity: 0.86 },
137
+ "Grid::line": { opacity: 0.48 },
138
+ "Legend::item": { opacity: 0.8 }
139
+ }
140
+ }),
141
+ contrast: be({
142
+ name: "contrast",
143
+ tokens: {
144
+ background: "#0b1020",
145
+ surface: "#111827",
146
+ axisColor: "#cbd5e1",
147
+ gridColor: "rgba(226,232,240,0.22)",
148
+ textColor: "#f8fafc",
149
+ tooltipBackground: "#f8fafc",
150
+ tooltipText: "#0f172a",
151
+ legendText: "#f8fafc",
152
+ viewportTrack: "rgba(248,250,252,0.18)",
153
+ viewportThumb: "rgba(248,250,252,0.78)",
154
+ selection: "#facc15",
155
+ mutedOpacity: 0.2,
156
+ palette: ["#facc15", "#38bdf8", "#fb7185", "#4ade80", "#c084fc", "#f97316", "#2dd4bf", "#f8fafc"]
157
+ },
158
+ styles: {
159
+ "BarSeries::bar": { borderRadius: 2 },
160
+ "LineSeries::segment": { strokeWidth: 2.5 },
161
+ "AreaSeries::fill": { opacity: 0.32 },
162
+ "ScatterSeries::point": { opacity: 0.96 }
163
+ }
164
+ })
165
+ }, ft = new Map(Object.entries(li));
166
+ function be(e) {
167
+ var i;
168
+ return {
169
+ ...e,
170
+ tokens: {
171
+ ...e.tokens ?? {},
172
+ palette: (i = e.tokens) != null && i.palette ? [...e.tokens.palette] : void 0
173
+ },
174
+ styles: { ...e.styles ?? {} }
175
+ };
176
+ }
177
+ function mt(e) {
178
+ const i = ft.get(e ?? "dashboard") ?? ft.get("dashboard");
179
+ return be(i);
180
+ }
181
+ const ci = {
182
+ hover: "hovered",
183
+ hovered: "hovered",
184
+ selected: "selected",
185
+ muted: "muted",
186
+ focused: "focused",
187
+ focus: "focused",
188
+ disabled: "disabled"
189
+ }, di = {
190
+ background: "background",
191
+ fill: "fill",
192
+ color: "color",
193
+ stroke: "stroke",
194
+ "stroke-color": "strokeColor",
195
+ strokecolor: "strokeColor",
196
+ "stroke-width": "strokeWidth",
197
+ strokewidth: "strokeWidth",
198
+ "line-width": "lineWidth",
199
+ linewidth: "lineWidth",
200
+ width: "width",
201
+ opacity: "opacity",
202
+ radius: "radius",
203
+ "border-radius": "borderRadius",
204
+ borderradius: "borderRadius",
205
+ "dash-pattern": "dashPattern",
206
+ dashpattern: "dashPattern",
207
+ "font-family": "fontFamily",
208
+ fontfamily: "fontFamily",
209
+ "font-size": "fontSize",
210
+ fontsize: "fontSize",
211
+ "font-weight": "fontWeight",
212
+ fontweight: "fontWeight",
213
+ "line-height": "lineHeight",
214
+ lineheight: "lineHeight"
215
+ }, ui = {
216
+ BarSeries: { label: "barLabel" },
217
+ LineSeries: { segment: "lineSegment", marker: "lineMarker" },
218
+ AreaSeries: {
219
+ fill: "areaFill",
220
+ outline: "areaOutline",
221
+ marker: "areaMarker"
222
+ },
223
+ ScatterSeries: { point: "scatterPoint" },
224
+ Axis: { tick: "axisTick", label: "axisLabel" },
225
+ Grid: { line: "gridLine" },
226
+ Legend: { item: "legendItem", swatch: "legendSwatch", label: "legendLabel" },
227
+ Tooltip: { surface: "tooltipSurface", content: "tooltipContent" },
228
+ Viewport: { track: "viewportTrack", thumb: "viewportThumb" }
229
+ };
230
+ class gt {
231
+ constructor(i) {
232
+ C(this, "_rules");
233
+ C(this, "_cache", /* @__PURE__ */ new Map());
234
+ this._rules = hi(i ?? "");
235
+ }
236
+ resolve(i) {
237
+ if (this._rules.length === 0)
238
+ return {};
239
+ const t = _i(i), r = this._cache.get(t);
240
+ if (r)
241
+ return r;
242
+ const n = this._rules.filter((o) => yi(o.selector, i)).sort((o, s) => o.specificity - s.specificity || o.order - s.order), a = {};
243
+ for (const o of n)
244
+ Object.assign(a, bi(o.style, i));
245
+ return this._cache.set(t, a), a;
246
+ }
247
+ }
248
+ function hi(e) {
249
+ const i = e.replace(/\/\*[\s\S]*?\*\//g, ""), t = [];
250
+ let r = 0;
251
+ const n = /([^{}]+)\{([^{}]+)\}/g;
252
+ for (let a = n.exec(i); a !== null; a = n.exec(i)) {
253
+ const o = (a[1] ?? "").split(",").map((c) => c.trim()).filter(Boolean), s = mi(a[2] ?? "");
254
+ for (const c of o) {
255
+ const d = fi(c);
256
+ d && t.push({
257
+ selector: d,
258
+ style: s,
259
+ specificity: Si(d),
260
+ order: r++
261
+ });
262
+ }
263
+ }
264
+ return t;
265
+ }
266
+ function fi(e) {
267
+ const i = { classes: [], attrs: {} }, t = /\[([^\]=\s]+)(?:=(["']?)([^\]"']+)\2)?\]/g;
268
+ let r = e.trim();
269
+ for (let c = t.exec(e); c !== null; c = t.exec(e)) {
270
+ const d = c[1];
271
+ d && (i.attrs[d] = c[3] ?? !0);
272
+ }
273
+ r = r.replace(t, "");
274
+ const n = /\.([\w-]+)/g;
275
+ for (let c = n.exec(r); c !== null; c = n.exec(r))
276
+ c[1] && i.classes.push(c[1]);
277
+ r = r.replace(n, "");
278
+ const a = r.match(/#([\w:-]+)/);
279
+ a && (i.id = a[1], r = r.replace(a[0], ""));
280
+ const o = r.lastIndexOf(":");
281
+ if (o >= 0 && r[o - 1] !== ":") {
282
+ const c = r.slice(o + 1);
283
+ c && (i.state = ci[c], r = r.slice(0, o));
284
+ }
285
+ const s = r.trim();
286
+ if (s.includes("::")) {
287
+ const [c, d] = s.split("::"), f = c == null ? void 0 : c.trim(), g = d == null ? void 0 : d.trim();
288
+ f && (i.component = Xe(f)), g && (i.part = xi(i.component, g));
289
+ } else s && (i.component = Xe(s));
290
+ return i.component || i.part || i.id || i.classes.length || Object.keys(i.attrs).length ? i : null;
291
+ }
292
+ function mi(e) {
293
+ const i = {};
294
+ for (const t of e.split(";")) {
295
+ const [r, ...n] = t.split(":"), a = n.join(":").trim();
296
+ if (!r || !a)
297
+ continue;
298
+ const o = di[r.trim().toLowerCase()];
299
+ o && (i[o] = gi(
300
+ o,
301
+ a
302
+ ));
303
+ }
304
+ return i;
305
+ }
306
+ function gi(e, i) {
307
+ const t = i.trim();
308
+ if (t.startsWith("var("))
309
+ return t;
310
+ if (e === "dashPattern")
311
+ return t.split(/[,\s]+/).map(Number).filter(Number.isFinite);
312
+ if (e === "opacity" || e === "radius" || e === "borderRadius" || e === "strokeWidth" || e === "lineWidth" || e === "width" || e === "fontSize" || e === "lineHeight") {
313
+ const r = Number(t.replace(/px$/, ""));
314
+ return Number.isFinite(r) ? r : void 0;
315
+ }
316
+ return t.replace(/^["']|["']$/g, "");
317
+ }
318
+ function yi(e, i) {
319
+ var r;
320
+ if (e.component && Xe(i.componentName) !== e.component || e.part && e.part !== i.part || e.state && e.state !== i.state || e.id && e.id !== i.componentId)
321
+ return !1;
322
+ const t = new Set(Nt(i.className));
323
+ for (const n of e.classes)
324
+ if (!t.has(n))
325
+ return !1;
326
+ for (const [n, a] of Object.entries(e.attrs)) {
327
+ const o = (r = i.attrs) == null ? void 0 : r[n];
328
+ if (a === !0) {
329
+ if (o === void 0 || o === !1 || o === null)
330
+ return !1;
331
+ continue;
332
+ }
333
+ if (String(o) !== a)
334
+ return !1;
335
+ }
336
+ return !0;
337
+ }
338
+ function bi(e, i) {
339
+ const t = {};
340
+ for (const [r, n] of Object.entries(e))
341
+ t[r] = typeof n == "string" ? vi(n, i) : n;
342
+ return t;
343
+ }
344
+ function vi(e, i) {
345
+ var c;
346
+ const t = e.match(/^var\((--[\w-]+)(?:,(.+))?\)$/);
347
+ if (!t)
348
+ return e;
349
+ const r = t[1] ?? "", a = r.replace(/^--nova-chart-/, "").replace(/-([a-z])/g, (d, f) => f.toUpperCase()), o = (c = t[2]) == null ? void 0 : c.trim().replace(/^["']|["']$/g, ""), s = i.tokens[a] ?? i.tokens[r];
350
+ return typeof s == "string" ? s : o ?? e;
351
+ }
352
+ function Si(e) {
353
+ return (e.id ? 100 : 0) + e.classes.length * 10 + Object.keys(e.attrs).length * 10 + (e.state ? 10 : 0) + (e.component ? 1 : 0) + (e.part ? 1 : 0);
354
+ }
355
+ function _i(e) {
356
+ return [
357
+ e.componentName,
358
+ e.componentId,
359
+ e.part,
360
+ e.state,
361
+ Nt(e.className).join("."),
362
+ Object.entries(e.attrs ?? {}).map(([i, t]) => `${i}=${String(t)}`).sort().join("&"),
363
+ JSON.stringify(e.tokens)
364
+ ].join("|");
365
+ }
366
+ function Xe(e) {
367
+ if (e)
368
+ return e.replace(/^NovaCharts\./, "");
369
+ }
370
+ function xi(e, i) {
371
+ var t;
372
+ return ((t = ui[e ?? ""]) == null ? void 0 : t[i]) ?? i;
373
+ }
374
+ function Nt(e) {
375
+ return Array.isArray(e) ? e.flatMap((i) => i.split(/\s+/)).filter(Boolean) : (e == null ? void 0 : e.split(/\s+/).filter(Boolean)) ?? [];
376
+ }
377
+ class pi {
378
+ constructor(i, t) {
379
+ C(this, "_cleanupPlugins", []);
380
+ C(this, "_styleSheet", new gt());
381
+ C(this, "_bridge");
382
+ C(this, "visualPreset", mt());
383
+ C(this, "tokens", { ...this.visualPreset.tokens ?? {} });
384
+ C(this, "plugins", []);
385
+ C(this, "contextualStyles", !1);
386
+ C(this, "revision", 0);
387
+ this._bridge = t, this.configure(i, t);
388
+ }
389
+ configure(i, t) {
390
+ var r, n;
391
+ this.dispose(), this.revision++, this._bridge = t, this.visualPreset = mt(i.visualPreset), this.tokens = { ...this.visualPreset.tokens ?? {} }, this._styleSheet = new gt(i.styleSheet), this.plugins = [...i.plugins ?? []].sort(
392
+ (a, o) => (a.order ?? 0) - (o.order ?? 0)
393
+ ), this.contextualStyles = !!((r = i.styleSheet) != null && r.trim() || this.plugins.some((a) => a.resolveMarkStyle)) || Object.values(this.visualPreset.styles ?? {}).some((a) => typeof a == "function" || Object.values(a).some((o) => typeof o == "function"));
394
+ for (const a of this.plugins) {
395
+ const o = (n = a.setup) == null ? void 0 : n.call(a, {
396
+ runtime: this._bridge,
397
+ tokens: this.tokens
398
+ });
399
+ typeof o == "function" && this._cleanupPlugins.push(o);
400
+ }
401
+ }
402
+ resolveMarkStyle(i, t = {}) {
403
+ var a;
404
+ const r = {}, n = this._resolvePresetPartStyle(i);
405
+ de(r, fe(t.defaults, i)), de(r, n), de(
406
+ r,
407
+ this._styleSheet.resolve({ ...i, tokens: this.tokens })
408
+ ), de(r, fe(t.legacy, i)), de(r, fe(t.part, i)), de(r, wi(t.series, i)), de(r, fe(t.state, i)), de(r, fe(t.datum, i));
409
+ for (const o of this.plugins) {
410
+ const s = (a = o.resolveMarkStyle) == null ? void 0 : a.call(
411
+ o,
412
+ { ...i, tokens: this.tokens },
413
+ { ...r }
414
+ );
415
+ de(r, fe(s, i));
416
+ }
417
+ return r;
418
+ }
419
+ renderPluginLayer(i, t) {
420
+ var n, a;
421
+ const r = [];
422
+ for (const o of this.plugins) {
423
+ const s = i === "underlay" ? (n = o.renderUnderlay) == null ? void 0 : n.call(o, { ...t, tokens: this.tokens }) : (a = o.renderOverlay) == null ? void 0 : a.call(o, { ...t, tokens: this.tokens });
424
+ Dt(r, s);
425
+ }
426
+ return r;
427
+ }
428
+ decorateTooltip(i, t) {
429
+ var n;
430
+ let r = t;
431
+ for (const a of this.plugins)
432
+ r = ((n = a.decorateTooltip) == null ? void 0 : n.call(a, i, r)) ?? r;
433
+ return r;
434
+ }
435
+ decorateLegend(i) {
436
+ var r;
437
+ let t = i;
438
+ for (const n of this.plugins)
439
+ t = ((r = n.decorateLegend) == null ? void 0 : r.call(n, t)) ?? t;
440
+ return t;
441
+ }
442
+ notifyInteraction(i) {
443
+ var t;
444
+ for (const r of this.plugins)
445
+ (t = r.onInteractionState) == null || t.call(r, i);
446
+ }
447
+ dispose() {
448
+ for (const i of this._cleanupPlugins.splice(0))
449
+ i();
450
+ }
451
+ _resolvePresetPartStyle(i) {
452
+ const t = this.visualPreset.styles ?? {};
453
+ return fe(
454
+ t[`${i.componentName}::${i.part}`] ?? t[`NovaCharts.${i.componentName}::${i.part}`] ?? t[`*::${i.part}`] ?? t[i.part],
455
+ i
456
+ );
457
+ }
458
+ }
459
+ function an(e, i, t) {
460
+ var r, n, a, o, s, c, d;
461
+ return t.disabled ? "disabled" : ((r = t.attrs) == null ? void 0 : r.focused) === !0 || ((n = t.attrs) == null ? void 0 : n["data-state"]) === "focused" ? "focused" : ((a = t.attrs) == null ? void 0 : a.selected) === !0 || ((o = t.attrs) == null ? void 0 : o["data-state"]) === "selected" ? "selected" : ((s = t.attrs) == null ? void 0 : s.muted) === !0 || ((c = t.attrs) == null ? void 0 : c["data-state"]) === "muted" ? "muted" : ((d = t.hovered) == null ? void 0 : d.seriesId) === e && (!i || t.hovered.key === i) ? "hovered" : "normal";
462
+ }
463
+ function Dt(e, i) {
464
+ i && (Array.isArray(i) ? e.push(...i) : e.push(i));
465
+ }
466
+ function sn(e, i, t, r) {
467
+ if (!i) {
468
+ e.push(r);
469
+ return;
470
+ }
471
+ const n = i({ ...t, defaultSchema: r });
472
+ n !== null && Dt(e, n ?? r);
473
+ }
474
+ function wi(e, i) {
475
+ if (!e)
476
+ return {};
477
+ const { datum: t, ...r } = e;
478
+ return fe(r, i);
479
+ }
480
+ function fe(e, i) {
481
+ if (!e)
482
+ return {};
483
+ const t = {};
484
+ for (const [r, n] of Object.entries(e))
485
+ r === "datum" || n === void 0 || (t[r] = ki(
486
+ n,
487
+ i
488
+ ));
489
+ return t;
490
+ }
491
+ function ki(e, i) {
492
+ return typeof e == "function" ? e(
493
+ i
494
+ ) : e;
495
+ }
496
+ function de(e, i) {
497
+ if (i)
498
+ for (const [t, r] of Object.entries(i))
499
+ r !== void 0 && (e[t] = r);
500
+ }
501
+ class Ci {
502
+ /**
503
+ * Создает экземпляр ChartDataStore и подготавливает базовое состояние.
504
+ */
505
+ constructor(i = {}) {
506
+ C(this, "_rows");
507
+ C(this, "_keyField");
508
+ C(this, "_keyIndex", /* @__PURE__ */ new Map());
509
+ C(this, "_rowKeys", []);
510
+ C(this, "_validator");
511
+ C(this, "_fieldCache", /* @__PURE__ */ new Map());
512
+ C(this, "_revision", 0);
513
+ C(this, "_filters", []);
514
+ C(this, "_filterOwners", /* @__PURE__ */ new Map());
515
+ C(this, "_filteredRows", null);
516
+ this._rows = i.data ? [...i.data] : [], this._keyField = i.keyField, this._rebuildKeyIndex();
517
+ }
518
+ /**
519
+ * Возвращает revision для ChartDataStore.
520
+ */
521
+ get revision() {
522
+ return this._revision;
523
+ }
524
+ /**
525
+ * Возвращает row Count для ChartDataStore.
526
+ */
527
+ get rowCount() {
528
+ return this.getData().length;
529
+ }
530
+ /**
531
+ * Возвращает значение состояния ChartDataStore.
532
+ */
533
+ getData() {
534
+ return this._filters.length ? (this._filteredRows ?? (this._filteredRows = this._rows.filter((i) => this._filters.every((t) => t(i)))), this._filteredRows) : this._rows;
535
+ }
536
+ /** Фильтры меняют производное представление, сохраняя исходные записи и ключи. */
537
+ setFilters(i, t = "user") {
538
+ i.length ? this._filterOwners.set(t, [...i]) : this._filterOwners.delete(t), this._filters = [...this._filterOwners.values()].flat(), this._invalidate();
539
+ }
540
+ getSourceData() {
541
+ return this._rows;
542
+ }
543
+ /** Семейные ограничения проверяются до фиксации любой row-операции. */
544
+ setValidator(i) {
545
+ i(this._rows), this._validator = i;
546
+ }
547
+ /** Возвращает исходную запись за постоянное время по стабильному ключу. */
548
+ getRow(i) {
549
+ const t = this._keyIndex.get(i);
550
+ return t === void 0 ? void 0 : this._rows[t];
551
+ }
552
+ /** Добавляет полные записи; проверка ключей происходит до изменения данных. */
553
+ appendRows(i, t) {
554
+ const r = this._validateRows(i);
555
+ for (const o of r)
556
+ if (this._keyIndex.has(o))
557
+ throw new Error(`[NovaCharts] Duplicate key: ${String(o)}`);
558
+ if (t !== void 0 && (!Number.isInteger(t) || t < 0))
559
+ throw new RangeError("[NovaCharts] maxRows must be a nonnegative integer");
560
+ const n = this._rows.length;
561
+ if (this._validator) {
562
+ const o = [...this._rows, ...i];
563
+ this._validator(t === void 0 ? o : t === 0 ? [] : o.slice(-t));
564
+ }
565
+ i.forEach((o, s) => {
566
+ this._rows.push(o), this._keyIndex.set(r[s], n + s), this._rowKeys.push(r[s]);
567
+ });
568
+ const a = t !== void 0 && this._rows.length > t;
569
+ a && (this._rows = this._rows.slice(-t || this._rows.length), this._rebuildKeyIndex()), (i.length || a) && this._invalidate();
570
+ }
571
+ /** Изменяет только существующие записи и запрещает смену их идентичности. */
572
+ patchRows(i) {
573
+ const t = /* @__PURE__ */ new Set(), r = i.map(({ key: a, changes: o }) => {
574
+ if (t.has(a))
575
+ throw new Error(`[NovaCharts] Duplicate patch key: ${String(a)}`);
576
+ t.add(a);
577
+ const s = this._keyIndex.get(a);
578
+ if (s === void 0)
579
+ throw new Error(`[NovaCharts] Unknown row key: ${String(a)}`);
580
+ const c = { ...this._rows[s], ...o };
581
+ if (this._requiredKey(c, s) !== a)
582
+ throw new Error("[NovaCharts] patchRows cannot change a key");
583
+ return { index: s, row: c, fields: Object.keys(o) };
584
+ }), n = /* @__PURE__ */ new Set();
585
+ if (this._validator && r.length) {
586
+ const a = [...this._rows];
587
+ for (const o of r)
588
+ a[o.index] = o.row;
589
+ this._validator(a);
590
+ }
591
+ for (const a of r) {
592
+ this._rows[a.index] = a.row;
593
+ for (const o of a.fields)
594
+ n.add(o);
595
+ }
596
+ if (r.length) {
597
+ this._revision++, this._filteredRows = null;
598
+ for (const a of this._fieldCache.keys())
599
+ if (this._filters.length || typeof a == "function")
600
+ this._fieldCache.delete(a);
601
+ else if (n.has(String(a))) {
602
+ const o = this._fieldCache.get(a);
603
+ if (!o.column) {
604
+ this._fieldCache.delete(a);
605
+ continue;
606
+ }
607
+ const { values: s } = o.column;
608
+ for (const c of r) {
609
+ const d = this.readField(c.row, c.index, a), f = s[c.index], g = d == null ? NaN : Number(d);
610
+ o.column.invalidCount += +!Number.isFinite(g) - +!Number.isFinite(f), s[c.index] = g, (!Number.isFinite(g) || c.index > 0 && g < s[c.index - 1] || c.index + 1 < s.length && g > s[c.index + 1]) && (o.column.ordered = !1);
611
+ }
612
+ o.numericExtent = void 0, o.categoryDomain = void 0, o.categoryIndices = void 0;
613
+ }
614
+ }
615
+ }
616
+ /** Заменяет существующие записи полными и добавляет отсутствующие. */
617
+ upsertRows(i) {
618
+ const t = this._validateRows(i);
619
+ if (this._validator && i.length) {
620
+ const r = new Map(this._rows.map((n) => [this._requiredKey(n, 0), n]));
621
+ i.forEach((n, a) => r.set(t[a], n)), this._validator([...r.values()]);
622
+ }
623
+ i.forEach((r, n) => {
624
+ const a = t[n], o = this._keyIndex.get(a);
625
+ o !== void 0 ? this._rows[o] = r : (this._keyIndex.set(a, this._rows.length), this._rows.push(r), this._rowKeys.push(a));
626
+ }), i.length && this._invalidate();
627
+ }
628
+ /**
629
+ * Обновляет значение состояния ChartDataStore.
630
+ */
631
+ setData(i, t = this._keyField) {
632
+ var a, o;
633
+ let r = t === this._keyField && i.length === this._rowKeys.length;
634
+ if (r) {
635
+ for (let s = 0; s < i.length; s++)
636
+ if ((typeof t == "function" ? t(i[s], s) : t === void 0 ? s : (a = i[s]) == null ? void 0 : a[String(t)]) !== this._rowKeys[s]) {
637
+ r = !1;
638
+ break;
639
+ }
640
+ }
641
+ const n = r ? this._keyIndex : this._createKeyIndex(i, t);
642
+ (o = this._validator) == null || o.call(this, i), this._rows = [...i], this._keyField = t, this._invalidate(), this._keyIndex = n, r || (this._rowKeys = [...n.keys()]);
643
+ }
644
+ /**
645
+ * Обновляет runtime-состояние ChartDataStore.
646
+ */
647
+ updateRows(i) {
648
+ if (i.length === 0)
649
+ return;
650
+ const t = [];
651
+ for (const r of i) {
652
+ const n = this._readPatchKey(r), a = n === void 0 ? -1 : this._keyIndex.get(n) ?? -1;
653
+ if (a >= 0) {
654
+ this._rows[a] = {
655
+ ...this._rows[a],
656
+ ...r
657
+ };
658
+ continue;
659
+ }
660
+ t.push(r);
661
+ }
662
+ t.length > 0 && this._rows.push(...t), this._invalidate(), this._rebuildKeyIndex();
663
+ }
664
+ /**
665
+ * Удаляет сущность из runtime-коллекции ChartDataStore.
666
+ */
667
+ removeRows(i) {
668
+ var n;
669
+ if (i.length === 0)
670
+ return;
671
+ const t = new Set(i), r = this._rows.filter((a, o) => !t.has(this.getRowKey(a, o)));
672
+ (n = this._validator) == null || n.call(this, r), this._rows = r, this._invalidate(), this._rebuildKeyIndex();
673
+ }
674
+ /**
675
+ * Возвращает значение состояния ChartDataStore.
676
+ */
677
+ getRowKey(i, t) {
678
+ const r = this._keyField ? this.readField(i, t, this._keyField) : void 0;
679
+ return typeof r == "string" || typeof r == "number" ? r : t;
680
+ }
681
+ /**
682
+ * Выполняет действие readField в рамках ответственности ChartDataStore.
683
+ */
684
+ readField(i, t, r) {
685
+ if (typeof r == "function")
686
+ return r(i, t);
687
+ if (i && typeof i == "object" && r in i)
688
+ return i[String(r)];
689
+ }
690
+ /**
691
+ * Выполняет действие numericExtent в рамках ответственности ChartDataStore.
692
+ */
693
+ numericExtent(i) {
694
+ var s;
695
+ const t = this._getFieldCache(i);
696
+ if (t.numericExtent)
697
+ return t.numericExtent;
698
+ if (!t.column && typeof i != "function")
699
+ return this.numericColumn(i), t.numericExtent;
700
+ let r = Number.POSITIVE_INFINITY, n = Number.NEGATIVE_INFINITY;
701
+ const a = (s = t.column) == null ? void 0 : s.values, o = this.getData();
702
+ for (let c = 0; c < o.length; c++) {
703
+ const d = a ? a[c] : this.readField(o[c], c, i), f = Number(d);
704
+ d == null || !Number.isFinite(f) || (f < r && (r = f), f > n && (n = f));
705
+ }
706
+ return t.numericExtent = r === Number.POSITIVE_INFINITY ? [0, 1] : [r, n], t.numericExtent;
707
+ }
708
+ /** Типизированная колонка принадлежит store; viewport читает её без новых row objects. */
709
+ numericColumn(i) {
710
+ const t = this._getFieldCache(i);
711
+ if (t.column)
712
+ return t.column;
713
+ const r = this.getData(), n = new Float64Array(r.length), a = String(i);
714
+ let o = !0, s = 0, c = 1 / 0, d = -1 / 0;
715
+ for (let f = 0; f < r.length; f++) {
716
+ const g = typeof i == "function" ? i(r[f], f) : r[f][a], y = g == null ? NaN : Number(g);
717
+ n[f] = y, (!Number.isFinite(y) || f > 0 && y < n[f - 1]) && (o = !1), Number.isFinite(y) ? (y < c && (c = y), y > d && (d = y)) : s++;
718
+ }
719
+ return t.numericExtent = Number.isFinite(c) ? [c, d] : [0, 1], t.column = { values: n, ordered: o, invalidCount: s }, t.column;
720
+ }
721
+ /**
722
+ * Выполняет действие categoryDomain в рамках ответственности ChartDataStore.
723
+ */
724
+ categoryDomain(i) {
725
+ const t = this._getFieldCache(i);
726
+ if (t.categoryDomain)
727
+ return t.categoryDomain;
728
+ const r = /* @__PURE__ */ new Set(), n = [];
729
+ return this.getData().forEach((a, o) => {
730
+ const s = String(this.readField(a, o, i) ?? "");
731
+ r.has(s) || (r.add(s), n.push(s));
732
+ }), t.categoryDomain = n, n;
733
+ }
734
+ /**
735
+ * Выполняет действие categoryIndices в рамках ответственности ChartDataStore.
736
+ */
737
+ categoryIndices(i) {
738
+ const t = this._getFieldCache(i);
739
+ if (t.categoryIndices)
740
+ return t.categoryIndices;
741
+ const r = /* @__PURE__ */ new Map();
742
+ return this.getData().forEach((n, a) => {
743
+ const o = String(this.readField(n, a, i) ?? "");
744
+ let s = r.get(o);
745
+ s || (s = [], r.set(o, s)), s.push(a);
746
+ }), t.categoryIndices = r, r;
747
+ }
748
+ /**
749
+ * Выполняет действие visibleRowsByCategoryRange в рамках ответственности ChartDataStore.
750
+ */
751
+ visibleRowsByCategoryRange(i, t, r, n) {
752
+ if (n < r)
753
+ return [];
754
+ const a = this.categoryIndices(i), o = [], s = Math.max(0, r), c = Math.min(t.length - 1, n);
755
+ for (let d = s; d <= c; d += 1) {
756
+ const f = t[d], g = f === void 0 ? void 0 : a.get(f);
757
+ g && o.push(...g);
758
+ }
759
+ return o;
760
+ }
761
+ /**
762
+ * Выполняет внутренний шаг readPatchKey для ChartDataStore.
763
+ */
764
+ _readPatchKey(i) {
765
+ if (!this._keyField)
766
+ return;
767
+ if (typeof this._keyField == "function") {
768
+ const r = this._keyField(i, -1);
769
+ return typeof r == "string" || typeof r == "number" ? r : void 0;
770
+ }
771
+ const t = i[String(this._keyField)];
772
+ return typeof t == "string" || typeof t == "number" ? t : void 0;
773
+ }
774
+ /**
775
+ * Выполняет внутренний шаг rebuildKeyIndex для ChartDataStore.
776
+ */
777
+ _rebuildKeyIndex() {
778
+ this._keyIndex = this._createKeyIndex(this._rows, this._keyField), this._rowKeys = [...this._keyIndex.keys()];
779
+ }
780
+ _createKeyIndex(i, t = this._keyField) {
781
+ const r = /* @__PURE__ */ new Map();
782
+ for (let n = 0; n < i.length; n++) {
783
+ const a = t ? this._requiredKey(i[n], n, t) : n;
784
+ if (r.has(a))
785
+ throw new Error(`[NovaCharts] Duplicate key: ${String(a)}`);
786
+ r.set(a, n);
787
+ }
788
+ return r;
789
+ }
790
+ /**
791
+ * Помечает runtime-состояние как требующее обновления ChartDataStore.
792
+ */
793
+ _invalidate() {
794
+ this._revision += 1, this._filteredRows = null, this._fieldCache.clear();
795
+ }
796
+ /**
797
+ * Возвращает значение состояния ChartDataStore.
798
+ */
799
+ _getFieldCache(i) {
800
+ let t = this._fieldCache.get(i);
801
+ return t || (t = {}, this._fieldCache.set(i, t)), t;
802
+ }
803
+ /** Проверяет все ключи, не меняя текущий индекс при невалидных данных. */
804
+ _validateRows(i, t = this._keyField) {
805
+ const r = /* @__PURE__ */ new Set();
806
+ return i.map((n, a) => {
807
+ const o = this._requiredKey(n, a, t);
808
+ if (r.has(o))
809
+ throw new Error(`[NovaCharts] Duplicate key: ${String(o)}`);
810
+ return r.add(o), o;
811
+ });
812
+ }
813
+ _requiredKey(i, t, r = this._keyField) {
814
+ if (!r)
815
+ throw new Error("[NovaCharts] A stable key accessor is required");
816
+ const n = this.readField(i, t, r);
817
+ if ((typeof n != "string" || n.length === 0) && (typeof n != "number" || !Number.isFinite(n)))
818
+ throw new Error(`[NovaCharts] Invalid stable key at row ${t}`);
819
+ return n;
820
+ }
821
+ }
822
+ class Ii {
823
+ constructor() {
824
+ C(this, "_scales", /* @__PURE__ */ new Map());
825
+ C(this, "_revision", 0);
826
+ }
827
+ get revision() {
828
+ return this._revision;
829
+ }
830
+ /**
831
+ * Регистрирует шкалу или заменяет существующую с тем же id.
832
+ */
833
+ register(i) {
834
+ this._scales.get(i.id) !== i && this._revision++, this._scales.set(i.id, i);
835
+ }
836
+ /**
837
+ * Удаляет шкалу по id.
838
+ */
839
+ unregister(i) {
840
+ this._scales.delete(i) && this._revision++;
841
+ }
842
+ /**
843
+ * Проверяет наличие шкалы.
844
+ */
845
+ has(i) {
846
+ return this._scales.has(i);
847
+ }
848
+ /**
849
+ * Возвращает шкалу или undefined.
850
+ */
851
+ get(i) {
852
+ return this._scales.get(i);
853
+ }
854
+ /**
855
+ * Возвращает шкалу или бросает явную ошибку конфигурации.
856
+ */
857
+ require(i) {
858
+ const t = this.get(i);
859
+ if (!t)
860
+ throw new Error(`[NovaCharts] Scale "${i}" is not registered`);
861
+ return t;
862
+ }
863
+ /**
864
+ * Возвращает все шкалы в порядке регистрации.
865
+ */
866
+ list() {
867
+ return Array.from(this._scales.values());
868
+ }
869
+ /**
870
+ * Обновляет домен зарегистрированной шкалы.
871
+ */
872
+ setDomain(i, t) {
873
+ const r = this.require(i), n = r.getDomain();
874
+ return n.length === t.length && n.every((a, o) => Object.is(a, t[o])) ? !1 : (r.setDomain(t), this._revision++, !0);
875
+ }
876
+ /**
877
+ * Обновляет пиксельный диапазон зарегистрированной шкалы.
878
+ */
879
+ setRange(i, t) {
880
+ const r = this.require(i), n = r.getRange();
881
+ return n[0] === t[0] && n[1] === t[1] ? !1 : (r.setRange(t), this._revision++, !0);
882
+ }
883
+ /**
884
+ * Очищает registry.
885
+ */
886
+ clear() {
887
+ this._scales.size && this._revision++, this._scales.clear();
888
+ }
889
+ }
890
+ const Mi = [0, 1];
891
+ class G {
892
+ /**
893
+ * Создает категориальную шкалу с band geometry.
894
+ */
895
+ constructor(i, t) {
896
+ C(this, "type", "band");
897
+ C(this, "_domain");
898
+ C(this, "_range");
899
+ C(this, "_indexByValue", /* @__PURE__ */ new Map());
900
+ C(this, "_paddingInner");
901
+ C(this, "_paddingOuter");
902
+ this.id = i, this._domain = t.domain, this._range = t.range ?? Mi, this._paddingInner = t.paddingInner ?? 0, this._paddingOuter = t.paddingOuter ?? 0, this._rebuildIndex();
903
+ }
904
+ /**
905
+ * Возвращает текущий список категорий.
906
+ */
907
+ getDomain() {
908
+ return this._domain;
909
+ }
910
+ /**
911
+ * Возвращает текущий пиксельный диапазон.
912
+ */
913
+ getRange() {
914
+ return this._range;
915
+ }
916
+ /**
917
+ * Заменяет список категорий.
918
+ */
919
+ setDomain(i) {
920
+ if (!i.every((t) => typeof t == "string"))
921
+ throw new Error(`[NovaCharts] Band scale "${this.id}" expects string domain`);
922
+ this._domain = i, this._rebuildIndex();
923
+ }
924
+ /**
925
+ * Заменяет пиксельный диапазон.
926
+ */
927
+ setRange(i) {
928
+ this._range = i;
929
+ }
930
+ /**
931
+ * Возвращает левую или верхнюю координату полосы категории.
932
+ */
933
+ toPx(i) {
934
+ const t = this._indexByValue.get(i) ?? -1;
935
+ return t === -1 ? Number.NaN : this._bandStart(t);
936
+ }
937
+ /**
938
+ * Возвращает категорию, которая находится под пикселем.
939
+ */
940
+ fromPx(i) {
941
+ if (this._domain.length === 0)
942
+ return "";
943
+ const t = this._step();
944
+ if (t === 0)
945
+ return this._domain[0] ?? "";
946
+ const [r] = this._range, n = Math.floor((i - r - t * this._paddingOuter) / t);
947
+ return this._domain[Math.max(0, Math.min(this._domain.length - 1, n))] ?? "";
948
+ }
949
+ /**
950
+ * Возвращает ширину или высоту одной полосы.
951
+ */
952
+ bandwidth() {
953
+ return Math.abs(this._step() * (1 - this._paddingInner));
954
+ }
955
+ /**
956
+ * Возвращает центр полосы категории.
957
+ */
958
+ center(i) {
959
+ return this.toPx(i) + this.bandwidth() / 2;
960
+ }
961
+ /**
962
+ * Строит ticks по центрам категорий.
963
+ */
964
+ ticks(i = {}) {
965
+ var f;
966
+ if ((f = i.values) != null && f.length)
967
+ return Fi(this, i.values, i);
968
+ const t = i.maxCount ?? Number.POSITIVE_INFINITY, r = i.minStepPx ?? 0, n = Math.abs(this._step()), a = r > 0 && n > 0 ? Math.ceil(r / n) : 1, o = Number.isFinite(t) && t > 0 ? Math.ceil(this._domain.length / t) : 1, s = Math.max(1, Math.trunc(i.categoryStep ?? 1)), c = Math.max(1, a, o, s), d = [];
969
+ for (let g = 0; g < this._domain.length; g += c) {
970
+ const y = this._domain[g];
971
+ y !== void 0 && d.push({
972
+ value: y,
973
+ position: this.center(y),
974
+ label: Rt(y, i),
975
+ major: !0
976
+ });
977
+ }
978
+ return d;
979
+ }
980
+ /**
981
+ * Возвращает полный шаг между соседними категориями.
982
+ */
983
+ stepSize() {
984
+ return Math.abs(this._step());
985
+ }
986
+ /**
987
+ * Возвращает индекс категории за O(1).
988
+ */
989
+ indexOf(i) {
990
+ return this._indexByValue.get(i) ?? -1;
991
+ }
992
+ /**
993
+ * Возвращает категорию по индексу.
994
+ */
995
+ valueAt(i) {
996
+ return this._domain[i];
997
+ }
998
+ /**
999
+ * Возвращает индексный диапазон категорий, пересекающих pixel window.
1000
+ */
1001
+ visibleIndexRange(i, t) {
1002
+ if (this._domain.length === 0)
1003
+ return { startIndex: 0, endIndex: -1 };
1004
+ const [r] = this._range, n = this._step();
1005
+ if (n === 0)
1006
+ return { startIndex: 0, endIndex: this._domain.length - 1 };
1007
+ const a = Math.min(i, t), o = Math.max(i, t), s = Math.floor((a - r - n * this._paddingOuter) / n) - 1, c = Math.ceil((o - r - n * this._paddingOuter) / n) + 1;
1008
+ return {
1009
+ startIndex: Math.max(0, Math.min(this._domain.length - 1, s)),
1010
+ endIndex: Math.max(0, Math.min(this._domain.length - 1, c))
1011
+ };
1012
+ }
1013
+ /**
1014
+ * Возвращает полный шаг между соседними категориями.
1015
+ */
1016
+ _step() {
1017
+ if (this._domain.length === 0)
1018
+ return 0;
1019
+ const [i, t] = this._range, r = t - i, n = Math.max(1, this._domain.length - this._paddingInner + this._paddingOuter * 2);
1020
+ return r / n;
1021
+ }
1022
+ /**
1023
+ * Возвращает старт полосы по индексу категории.
1024
+ */
1025
+ _bandStart(i) {
1026
+ const [t] = this._range, r = this._step();
1027
+ return t + r * this._paddingOuter + r * i;
1028
+ }
1029
+ /**
1030
+ * Пересобирает индекс категорий для больших domain.
1031
+ */
1032
+ _rebuildIndex() {
1033
+ this._indexByValue = /* @__PURE__ */ new Map(), this._domain.forEach((i, t) => {
1034
+ this._indexByValue.set(i, t);
1035
+ });
1036
+ }
1037
+ }
1038
+ function Fi(e, i, t) {
1039
+ return i.flatMap((r) => {
1040
+ const n = Ni(r);
1041
+ if (typeof n != "string")
1042
+ return [];
1043
+ const a = e.center(n);
1044
+ return Number.isFinite(a) ? [{
1045
+ value: n,
1046
+ position: a,
1047
+ label: Di(r) ?? Rt(n, t),
1048
+ major: Ri(r)
1049
+ }] : [];
1050
+ });
1051
+ }
1052
+ function Ni(e) {
1053
+ return typeof e == "object" ? e.value : e;
1054
+ }
1055
+ function Di(e) {
1056
+ return typeof e == "object" ? e.label : void 0;
1057
+ }
1058
+ function Ri(e) {
1059
+ return typeof e == "object" ? e.major ?? !0 : !0;
1060
+ }
1061
+ function Rt(e, i) {
1062
+ var t, r;
1063
+ return ((t = i.labels) == null ? void 0 : t[e]) ?? ((r = i.formatter) == null ? void 0 : r.call(i, e)) ?? e;
1064
+ }
1065
+ const Ti = [0, 1];
1066
+ class Tt {
1067
+ /**
1068
+ * Создает числовую шкалу с доменом данных и пиксельным диапазоном.
1069
+ */
1070
+ constructor(i, t) {
1071
+ C(this, "type", "linear");
1072
+ C(this, "_domain");
1073
+ C(this, "_range");
1074
+ C(this, "_clampValues");
1075
+ this.id = i, this._domain = t.domain, this._range = t.range ?? Ti, this._clampValues = t.clamp ?? !1;
1076
+ }
1077
+ /**
1078
+ * Возвращает текущий домен данных.
1079
+ */
1080
+ getDomain() {
1081
+ return this._domain;
1082
+ }
1083
+ /**
1084
+ * Возвращает текущий пиксельный диапазон.
1085
+ */
1086
+ getRange() {
1087
+ return this._range;
1088
+ }
1089
+ /**
1090
+ * Заменяет домен данных.
1091
+ */
1092
+ setDomain(i) {
1093
+ if (!$i(i))
1094
+ throw new Error(`[NovaCharts] Linear scale "${this.id}" expects numeric domain`);
1095
+ this._domain = i;
1096
+ }
1097
+ /**
1098
+ * Заменяет пиксельный диапазон.
1099
+ */
1100
+ setRange(i) {
1101
+ this._range = i;
1102
+ }
1103
+ /**
1104
+ * Переводит значение данных в пиксель.
1105
+ */
1106
+ toPx(i) {
1107
+ const [t, r] = this._domain, [n, a] = this._range, o = r - t;
1108
+ if (o === 0)
1109
+ return n;
1110
+ const s = (i - t) / o, c = this._clampValues ? yt(s, 0, 1) : s;
1111
+ return n + c * (a - n);
1112
+ }
1113
+ /**
1114
+ * Переводит пиксель обратно в значение данных.
1115
+ */
1116
+ fromPx(i) {
1117
+ const [t, r] = this._domain, [n, a] = this._range, o = a - n;
1118
+ if (o === 0)
1119
+ return t;
1120
+ const s = (i - n) / o, c = this._clampValues ? yt(s, 0, 1) : s;
1121
+ return t + c * (r - t);
1122
+ }
1123
+ /**
1124
+ * Строит человекочитаемые числовые ticks с шагом 1/2/5 * 10^n.
1125
+ */
1126
+ ticks(i = {}) {
1127
+ var k;
1128
+ if ((k = i.values) != null && k.length)
1129
+ return Ei(this, i.values, i);
1130
+ const [t, r] = this._domain, [n, a] = this._range, o = Math.abs(a - n), s = i.minStepPx ?? 48, c = Math.max(1, Math.floor(o / s)), d = Math.max(1, Math.min(i.maxCount ?? 12, c)), f = Li(t, r, d), g = Math.ceil(Math.min(t, r) / f) * f, y = Math.max(t, r), S = [];
1131
+ for (let x = g; x <= y + f / 2; x += f) {
1132
+ const m = Vi(x);
1133
+ S.push({
1134
+ value: m,
1135
+ position: this.toPx(m),
1136
+ label: Et(m, i),
1137
+ major: !0
1138
+ });
1139
+ }
1140
+ return S;
1141
+ }
1142
+ }
1143
+ function Ei(e, i, t) {
1144
+ return i.flatMap((r) => {
1145
+ const n = Pi(r);
1146
+ return typeof n != "number" || !Number.isFinite(n) ? [] : [{
1147
+ value: n,
1148
+ position: e.toPx(n),
1149
+ label: zi(r) ?? Et(n, t),
1150
+ major: Ai(r)
1151
+ }];
1152
+ });
1153
+ }
1154
+ function Pi(e) {
1155
+ return typeof e == "object" ? e.value : e;
1156
+ }
1157
+ function zi(e) {
1158
+ return typeof e == "object" ? e.label : void 0;
1159
+ }
1160
+ function Ai(e) {
1161
+ return typeof e == "object" ? e.major ?? !0 : !0;
1162
+ }
1163
+ function Et(e, i) {
1164
+ var t, r;
1165
+ return ((t = i.labels) == null ? void 0 : t[String(e)]) ?? ((r = i.formatter) == null ? void 0 : r.call(i, e)) ?? String(e);
1166
+ }
1167
+ function $i(e) {
1168
+ return e.length === 2 && typeof e[0] == "number" && typeof e[1] == "number";
1169
+ }
1170
+ function yt(e, i, t) {
1171
+ return Math.max(i, Math.min(t, e));
1172
+ }
1173
+ function Li(e, i, t) {
1174
+ const r = Math.abs(i - e);
1175
+ if (r === 0)
1176
+ return 1;
1177
+ const n = r / Math.max(1, t), a = 10 ** Math.floor(Math.log10(n)), o = n / a;
1178
+ return o <= 1 ? a : o <= 2 ? 2 * a : o <= 5 ? 5 * a : 10 * a;
1179
+ }
1180
+ function Vi(e) {
1181
+ return Number.parseFloat(e.toPrecision(12));
1182
+ }
1183
+ const Oi = [
1184
+ "millisecond",
1185
+ "second",
1186
+ "minute",
1187
+ "hour",
1188
+ "day",
1189
+ "week",
1190
+ "month",
1191
+ "quarter",
1192
+ "year"
1193
+ ], bt = {
1194
+ millisecond: 1,
1195
+ second: 1e3,
1196
+ minute: 6e4,
1197
+ hour: 36e5,
1198
+ day: 864e5,
1199
+ week: 6048e5,
1200
+ month: 2592e6,
1201
+ quarter: 7776e6,
1202
+ year: 31536e6
1203
+ };
1204
+ function vt(e) {
1205
+ return Oi.indexOf(e);
1206
+ }
1207
+ function St(e, i, t = "UTC", r = 1) {
1208
+ const n = zt(e, t);
1209
+ if (i === "year") {
1210
+ const o = Math.floor(n.year / r) * r;
1211
+ return ae({ year: o, month: 1, day: 1, hour: 0, minute: 0, second: 0, millisecond: 0 }, t);
1212
+ }
1213
+ if (i === "quarter") {
1214
+ const o = Math.floor((n.month - 1) / (r * 3)) * r * 3 + 1;
1215
+ return ae({ ...n, month: o, day: 1, hour: 0, minute: 0, second: 0, millisecond: 0 }, t);
1216
+ }
1217
+ if (i === "month") {
1218
+ const o = Math.floor((n.month - 1) / r) * r + 1;
1219
+ return ae({ ...n, month: o, day: 1, hour: 0, minute: 0, second: 0, millisecond: 0 }, t);
1220
+ }
1221
+ if (i === "week") {
1222
+ const o = ae({ ...n, hour: 0, minute: 0, second: 0, millisecond: 0 }, t), s = Ft(o, t).getDay(), c = s === 0 ? 6 : s - 1;
1223
+ return Pt(o, "day", -c, t);
1224
+ }
1225
+ if (i === "day")
1226
+ return ae({ ...n, hour: 0, minute: 0, second: 0, millisecond: 0 }, t);
1227
+ if (i === "hour") {
1228
+ const o = Math.floor(n.hour / r) * r;
1229
+ return ae({ ...n, hour: o, minute: 0, second: 0, millisecond: 0 }, t);
1230
+ }
1231
+ if (i === "minute") {
1232
+ const o = Math.floor(n.minute / r) * r;
1233
+ return ae({ ...n, minute: o, second: 0, millisecond: 0 }, t);
1234
+ }
1235
+ if (i === "second") {
1236
+ const o = Math.floor(n.second / r) * r;
1237
+ return ae({ ...n, second: o, millisecond: 0 }, t);
1238
+ }
1239
+ const a = Math.floor(n.millisecond / r) * r;
1240
+ return ae({ ...n, millisecond: a }, t);
1241
+ }
1242
+ function Pt(e, i, t, r = "UTC") {
1243
+ const n = zt(e, r), a = new Date(Date.UTC(
1244
+ n.year,
1245
+ n.month - 1,
1246
+ n.day,
1247
+ n.hour,
1248
+ n.minute,
1249
+ n.second,
1250
+ n.millisecond
1251
+ ));
1252
+ return i === "year" && a.setUTCFullYear(a.getUTCFullYear() + t), i === "quarter" && a.setUTCMonth(a.getUTCMonth() + t * 3), i === "month" && a.setUTCMonth(a.getUTCMonth() + t), i === "week" && a.setUTCDate(a.getUTCDate() + t * 7), i === "day" && a.setUTCDate(a.getUTCDate() + t), i === "hour" && a.setUTCHours(a.getUTCHours() + t), i === "minute" && a.setUTCMinutes(a.getUTCMinutes() + t), i === "second" && a.setUTCSeconds(a.getUTCSeconds() + t), i === "millisecond" && a.setUTCMilliseconds(a.getUTCMilliseconds() + t), ae({
1253
+ year: a.getUTCFullYear(),
1254
+ month: a.getUTCMonth() + 1,
1255
+ day: a.getUTCDate(),
1256
+ hour: a.getUTCHours(),
1257
+ minute: a.getUTCMinutes(),
1258
+ second: a.getUTCSeconds(),
1259
+ millisecond: a.getUTCMilliseconds()
1260
+ }, r);
1261
+ }
1262
+ function zt(e, i = "UTC") {
1263
+ const t = Ft(new Date(e), i);
1264
+ return {
1265
+ year: t.getFullYear(),
1266
+ month: t.getMonth() + 1,
1267
+ day: t.getDate(),
1268
+ hour: t.getHours(),
1269
+ minute: t.getMinutes(),
1270
+ second: t.getSeconds(),
1271
+ millisecond: t.getMilliseconds()
1272
+ };
1273
+ }
1274
+ function ae(e, i = "UTC") {
1275
+ const t = [
1276
+ `${e.year}`.padStart(4, "0"),
1277
+ "-",
1278
+ `${e.month}`.padStart(2, "0"),
1279
+ "-",
1280
+ `${e.day}`.padStart(2, "0"),
1281
+ "T",
1282
+ `${e.hour}`.padStart(2, "0"),
1283
+ ":",
1284
+ `${e.minute}`.padStart(2, "0"),
1285
+ ":",
1286
+ `${e.second}`.padStart(2, "0"),
1287
+ ".",
1288
+ `${e.millisecond}`.padStart(3, "0")
1289
+ ].join("");
1290
+ return ni(t, i).getTime();
1291
+ }
1292
+ const Bi = [0, 1], ji = [
1293
+ { unit: "second", step: 1 },
1294
+ { unit: "second", step: 5 },
1295
+ { unit: "second", step: 15 },
1296
+ { unit: "second", step: 30 },
1297
+ { unit: "minute", step: 1 },
1298
+ { unit: "minute", step: 5 },
1299
+ { unit: "minute", step: 15 },
1300
+ { unit: "minute", step: 30 },
1301
+ { unit: "hour", step: 1 },
1302
+ { unit: "hour", step: 3 },
1303
+ { unit: "hour", step: 6 },
1304
+ { unit: "hour", step: 12 },
1305
+ { unit: "day", step: 1 },
1306
+ { unit: "week", step: 1 },
1307
+ { unit: "month", step: 1 },
1308
+ { unit: "quarter", step: 1 },
1309
+ { unit: "year", step: 1 }
1310
+ ];
1311
+ class Ki extends Tt {
1312
+ /**
1313
+ * Создает временную шкалу с IANA timezone для форматирования и календарных шагов.
1314
+ */
1315
+ constructor(t, r) {
1316
+ super(t, {
1317
+ domain: r.domain,
1318
+ range: r.range ?? Bi,
1319
+ clamp: r.clamp
1320
+ });
1321
+ C(this, "type", "time");
1322
+ C(this, "_timezone");
1323
+ C(this, "_locale");
1324
+ this._timezone = r.timezone ?? "UTC", this._locale = r.locale ?? "ru-RU";
1325
+ }
1326
+ /**
1327
+ * Заменяет домен данных.
1328
+ */
1329
+ setDomain(t) {
1330
+ super.setDomain(t);
1331
+ }
1332
+ /**
1333
+ * Строит ticks по календарным единицам без приближения месяца к 30 дням.
1334
+ */
1335
+ ticks(t = {}) {
1336
+ var k;
1337
+ if ((k = t.values) != null && k.length)
1338
+ return this._createExplicitTicks(t.values, t);
1339
+ const [r, n] = this.getDomain(), a = this._resolveTickUnit(t), o = t.timezone ?? this._timezone, s = this._createFormatter(t, a.unit), c = this._createMajorFormatter(t, a.unit), d = [], f = St(Math.min(r, n), a.unit, o, a.step), g = Math.max(r, n);
1340
+ let y = f, S = 0;
1341
+ for (; y <= g && S < 1e4; ) {
1342
+ if (y >= Math.min(r, n)) {
1343
+ const x = this._isMajorTick(y, a.unit, t.majorUnit, o);
1344
+ d.push({
1345
+ value: y,
1346
+ position: this.toPx(y),
1347
+ label: x ? c(y) : s(y),
1348
+ major: x
1349
+ });
1350
+ }
1351
+ y = Pt(y, a.unit, a.step, o), S += 1;
1352
+ }
1353
+ return d;
1354
+ }
1355
+ /**
1356
+ * Строит ticks из явно переданного списка values/labels.
1357
+ */
1358
+ _createExplicitTicks(t, r) {
1359
+ const n = this._createFormatter(r, r.unit && r.unit !== "auto" ? r.unit : "day");
1360
+ return t.flatMap((a) => {
1361
+ var s, c;
1362
+ const o = typeof a == "object" ? a.value : a;
1363
+ return typeof o != "number" || !Number.isFinite(o) ? [] : [{
1364
+ value: o,
1365
+ position: this.toPx(o),
1366
+ label: typeof a == "object" && a.label ? a.label : ((s = r.labels) == null ? void 0 : s[String(o)]) ?? ((c = r.formatter) == null ? void 0 : c.call(r, o)) ?? n(o),
1367
+ major: typeof a == "object" ? a.major ?? !0 : !0
1368
+ }];
1369
+ });
1370
+ }
1371
+ /**
1372
+ * Выбирает единицу и шаг tick для текущего масштаба.
1373
+ */
1374
+ _resolveTickUnit(t) {
1375
+ if (t.unit && t.unit !== "auto")
1376
+ return {
1377
+ unit: t.unit,
1378
+ step: t.step ?? 1
1379
+ };
1380
+ const [r, n] = this.getDomain(), [a, o] = this.getRange(), s = Math.abs(n - r), c = Math.max(1, Math.abs(o - a)), d = t.minStepPx ?? 64, f = t.maxCount ?? Math.max(1, Math.floor(c / d));
1381
+ for (const y of ji) {
1382
+ const S = s / (bt[y.unit] * y.step), k = c / Math.max(1, S);
1383
+ if (S <= f && k >= d)
1384
+ return y;
1385
+ }
1386
+ return { unit: "year", step: Math.max(1, Math.ceil(s / bt.year / f)) };
1387
+ }
1388
+ /**
1389
+ * Создает formatter обычного tick label.
1390
+ */
1391
+ _createFormatter(t, r) {
1392
+ if (typeof t.format == "function")
1393
+ return t.format;
1394
+ const n = t.format ?? Ui(r), a = new Intl.DateTimeFormat(t.locale ?? this._locale, {
1395
+ ...n,
1396
+ timeZone: t.timezone ?? this._timezone
1397
+ });
1398
+ return (o) => a.format(new Date(o));
1399
+ }
1400
+ /**
1401
+ * Создает formatter major tick label.
1402
+ */
1403
+ _createMajorFormatter(t, r) {
1404
+ if (typeof t.majorFormat == "function")
1405
+ return t.majorFormat;
1406
+ const n = t.majorFormat ?? qi(r), a = new Intl.DateTimeFormat(t.locale ?? this._locale, {
1407
+ ...n,
1408
+ timeZone: t.timezone ?? this._timezone
1409
+ });
1410
+ return (o) => a.format(new Date(o));
1411
+ }
1412
+ /**
1413
+ * Определяет, является ли tick крупной границей периода.
1414
+ */
1415
+ _isMajorTick(t, r, n, a) {
1416
+ const o = n ?? Wi(r);
1417
+ return vt(o) <= vt(r) ? !0 : St(t, o, a, 1) === t;
1418
+ }
1419
+ }
1420
+ function Ui(e) {
1421
+ return e === "year" ? { year: "numeric" } : e === "month" || e === "quarter" ? { month: "short", year: "numeric" } : e === "week" || e === "day" ? { day: "2-digit", month: "short" } : e === "hour" ? { hour: "2-digit", minute: "2-digit" } : e === "minute" ? { hour: "2-digit", minute: "2-digit" } : { minute: "2-digit", second: "2-digit" };
1422
+ }
1423
+ function qi(e) {
1424
+ return e === "year" ? { year: "numeric" } : e === "month" || e === "quarter" ? { year: "numeric" } : e === "week" || e === "day" ? { month: "long", year: "numeric" } : { day: "2-digit", month: "short", year: "numeric" };
1425
+ }
1426
+ function Wi(e) {
1427
+ return e === "millisecond" || e === "second" || e === "minute" ? "hour" : e === "hour" ? "day" : e === "day" || e === "week" ? "month" : "year";
1428
+ }
1429
+ function Ue(e) {
1430
+ return e.type === "linear" ? new Tt(e.id, e) : e.type === "time" ? new Ki(e.id, e) : new G(e.id, e);
1431
+ }
1432
+ function on(e, i, t) {
1433
+ const r = At(i, t);
1434
+ return i.scaleType === "band" ? Ue({
1435
+ id: e,
1436
+ type: "band",
1437
+ domain: r,
1438
+ paddingInner: i.paddingInner,
1439
+ paddingOuter: i.paddingOuter
1440
+ }) : i.scaleType === "time" ? Ue({
1441
+ id: e,
1442
+ type: "time",
1443
+ domain: r,
1444
+ clamp: i.clamp,
1445
+ locale: i.locale,
1446
+ timezone: i.timezone
1447
+ }) : Ue({
1448
+ id: e,
1449
+ type: "linear",
1450
+ domain: r,
1451
+ clamp: i.clamp
1452
+ });
1453
+ }
1454
+ function At(e, i) {
1455
+ if (e.domain)
1456
+ return e.domain;
1457
+ if (e.scaleType === "band")
1458
+ return e.field ? i.categoryDomain(e.field) : [];
1459
+ const t = e.field ? i.numericExtent(e.field) : [0, 1];
1460
+ let [r, n] = t;
1461
+ if (e.zero && (r = Math.min(0, r), n = Math.max(0, n)), e.nice) {
1462
+ const a = Gi(r, n);
1463
+ r = a[0], n = a[1];
1464
+ }
1465
+ return r === n && (r -= 1, n += 1), [r, n];
1466
+ }
1467
+ function Gi(e, i) {
1468
+ if (!Number.isFinite(e) || !Number.isFinite(i))
1469
+ return [0, 1];
1470
+ const t = Math.abs(i - e);
1471
+ if (t === 0)
1472
+ return [Math.floor(e), Math.ceil(i + 1)];
1473
+ const n = 10 ** Math.floor(Math.log10(t)) / 2;
1474
+ return [
1475
+ Math.floor(e / n) * n,
1476
+ Math.ceil(i / n) * n
1477
+ ];
1478
+ }
1479
+ const Fe = {
1480
+ enabled: !0,
1481
+ overscanPx: 64,
1482
+ minBarWidthPx: 1,
1483
+ maxRenderedBars: 2e4,
1484
+ aggregation: "auto"
1485
+ };
1486
+ function ln(e) {
1487
+ const i = xe(), t = xe(), { props: r, dataStore: n } = e, a = Ne(e), o = n.getData(), s = $t(a), c = ar(a, Re(e), r.virtualization.overscanPx), d = Math.max(0, c.endIndex - c.startIndex + 1), f = Qi(e, o), g = xe() - t, y = xe();
1488
+ let S = "direct", k = 0, x = o.length, m;
1489
+ const N = r.mode === "single" && !r.seriesField;
1490
+ if (!r.virtualization.enabled)
1491
+ m = _t(e, o.map((L, D) => D), f);
1492
+ else {
1493
+ const L = a instanceof G ? a.bandwidth() : Number.POSITIVE_INFINITY, D = Math.min(o.length, d * Math.max(1, f.length));
1494
+ if (N && (L < r.virtualization.minBarWidthPx || D > r.virtualization.maxRenderedBars)) {
1495
+ S = "aggregated";
1496
+ const A = Zi(e, s, c, f);
1497
+ m = A.items, k = A.bucketCount, x = A.visibleRows;
1498
+ } else {
1499
+ const A = n.visibleRowsByCategoryRange(
1500
+ r.categoryField,
1501
+ s,
1502
+ c.startIndex,
1503
+ c.endIndex
1504
+ );
1505
+ S = A.length < o.length ? "windowed" : "direct", x = A.length, m = _t(e, A, f);
1506
+ }
1507
+ }
1508
+ if (r.virtualization.enabled && m.length > r.virtualization.maxRenderedBars) {
1509
+ const L = Math.ceil(m.length / r.virtualization.maxRenderedBars);
1510
+ m = m.filter((D, U) => U % L === 0), S = S === "direct" ? "windowed" : S;
1511
+ }
1512
+ const E = xe() - y, q = {
1513
+ kind: "bar",
1514
+ inputRows: o.length,
1515
+ visibleRows: x,
1516
+ renderedBars: m.length,
1517
+ aggregatedBuckets: k,
1518
+ mode: S,
1519
+ domainMs: g,
1520
+ layoutMs: E,
1521
+ schemaMs: 0,
1522
+ totalMs: xe() - i
1523
+ };
1524
+ return {
1525
+ items: m,
1526
+ orientation: r.orientation,
1527
+ mode: r.mode,
1528
+ categories: [...s],
1529
+ series: f,
1530
+ diagnostics: q
1531
+ };
1532
+ }
1533
+ function _t(e, i, t) {
1534
+ const r = Ji(e, i);
1535
+ return e.props.mode === "stacked" ? Xi(e, r, t) : e.props.mode === "grouped" ? Yi(e, r, t) : Hi(e, r, t);
1536
+ }
1537
+ function Hi(e, i, t) {
1538
+ const r = Ne(e), n = De(e), a = we(n, 0), o = r instanceof G ? Math.max(0, r.bandwidth()) : Math.max(1, Re(e) / Math.max(1, i.length));
1539
+ return i.map((s) => {
1540
+ const c = r.toPx(s.category);
1541
+ return Le(e, s, t, c, o, a, s.value, 0);
1542
+ }).filter(Je);
1543
+ }
1544
+ function Yi(e, i, t) {
1545
+ const r = Ne(e), n = De(e), a = we(n, 0), o = r instanceof G ? Math.max(0, r.bandwidth()) : Math.max(1, Re(e) / Math.max(1, i.length)), s = Math.min(3, Math.max(0, o * 0.08)), c = Math.max(1, (o - s * Math.max(0, t.length - 1)) / Math.max(1, t.length)), d = new Map(t.map((f, g) => [f.id, g]));
1546
+ return i.map((f) => {
1547
+ const g = d.get(f.seriesKey) ?? 0, y = r.toPx(f.category) + g * (c + s);
1548
+ return Le(e, f, t, y, c, a, f.value, 0);
1549
+ }).filter(Je);
1550
+ }
1551
+ function Xi(e, i, t) {
1552
+ const r = Ne(e), n = De(e), a = we(n, 0), o = r instanceof G ? Math.max(0, r.bandwidth()) : Math.max(1, Re(e) / Math.max(1, i.length)), s = /* @__PURE__ */ new Map(), c = [];
1553
+ for (const d of i) {
1554
+ let f = s.get(d.category);
1555
+ f || (f = { positive: 0, negative: 0 }, s.set(d.category, f));
1556
+ const g = d.value >= 0 ? f.positive : f.negative;
1557
+ d.value >= 0 ? f.positive += d.value : f.negative += d.value;
1558
+ const y = r.toPx(d.category), S = Le(e, d, t, y, o, a, g + d.value, g);
1559
+ Je(S) && c.push(S);
1560
+ }
1561
+ return c;
1562
+ }
1563
+ function Le(e, i, t, r, n, a, o, s) {
1564
+ const { props: c } = e, d = De(e), f = we(d, s), g = we(d, o), y = t.find((E) => E.id === i.seriesKey) ?? t[0], S = er(e, i, y), k = Math.max(c.minBarSize, Math.abs(f - g)), x = i.category, m = tr(e, i);
1565
+ if (c.orientation === "horizontal") {
1566
+ const E = o >= s ? Math.min(f, g) : Math.min(g, a);
1567
+ return {
1568
+ key: i.key,
1569
+ row: i.row,
1570
+ value: o,
1571
+ rawValue: i.value,
1572
+ category: x,
1573
+ seriesKey: i.seriesKey,
1574
+ seriesLabel: i.seriesLabel,
1575
+ color: S,
1576
+ labelText: m,
1577
+ x: E,
1578
+ y: r,
1579
+ width: k,
1580
+ height: n,
1581
+ label: m ?? x
1582
+ };
1583
+ }
1584
+ const N = o >= s ? Math.min(f, g) : Math.min(g, a);
1585
+ return {
1586
+ key: i.key,
1587
+ row: i.row,
1588
+ value: o,
1589
+ rawValue: i.value,
1590
+ category: x,
1591
+ seriesKey: i.seriesKey,
1592
+ seriesLabel: i.seriesLabel,
1593
+ color: S,
1594
+ labelText: m,
1595
+ x: r,
1596
+ y: N,
1597
+ width: n,
1598
+ height: k,
1599
+ label: m ?? x
1600
+ };
1601
+ }
1602
+ function Zi(e, i, t, r) {
1603
+ const { props: n, dataStore: a } = e, o = Ne(e), s = De(e), c = Math.max(0, t.endIndex - t.startIndex + 1);
1604
+ if (c === 0)
1605
+ return { items: [], bucketCount: 0, visibleRows: 0 };
1606
+ const d = Math.max(1, Math.floor(Re(e) / Math.max(1, n.virtualization.minBarWidthPx))), f = Math.min(n.virtualization.maxRenderedBars, d, c), g = Math.max(1, Math.ceil(c / f)), y = ir(f), S = a.getData();
1607
+ let k = 0;
1608
+ o instanceof G && S.forEach((N, E) => {
1609
+ const q = String(a.readField(N, E, n.categoryField) ?? ""), L = o.indexOf(q);
1610
+ if (L < t.startIndex || L > t.endIndex)
1611
+ return;
1612
+ const D = Math.min(f - 1, Math.floor((L - t.startIndex) / g)), U = Number(a.readField(N, E, n.valueField));
1613
+ if (!Number.isFinite(U))
1614
+ return;
1615
+ k += 1;
1616
+ const A = y[D];
1617
+ A && rr(A, U);
1618
+ });
1619
+ const x = we(s, 0), m = [];
1620
+ for (let N = 0; N < f; N += 1) {
1621
+ const E = t.startIndex + N * g;
1622
+ if (E > t.endIndex)
1623
+ break;
1624
+ const q = Math.min(t.endIndex, E + g - 1), L = y[N], D = L ? nr(L, n.virtualization.aggregation) : null;
1625
+ if (D === null)
1626
+ continue;
1627
+ const U = i[E] ?? "", A = i[q] ?? U, $ = o.toPx(U), z = o instanceof G ? o.toPx(A) + o.bandwidth() : $ + 1, Y = {
1628
+ row: void 0,
1629
+ rowIndex: -1,
1630
+ key: `bucket:${E}:${q}`,
1631
+ category: `${E + 1}-${q + 1}`,
1632
+ value: D,
1633
+ seriesKey: "__default",
1634
+ seriesLabel: "Value"
1635
+ }, J = Le(e, Y, r, $, Math.max(1, z - $), x, D, 0);
1636
+ J.row = void 0, J.label = Y.category, m.push(J);
1637
+ }
1638
+ return { items: m, bucketCount: m.length, visibleRows: k };
1639
+ }
1640
+ function Ji(e, i) {
1641
+ const { props: t, dataStore: r } = e, n = r.getData();
1642
+ return i.flatMap((a) => {
1643
+ const o = n[a], s = Number(r.readField(o, a, t.valueField));
1644
+ if (!Number.isFinite(s))
1645
+ return [];
1646
+ const c = String(r.readField(o, a, t.categoryField) ?? ""), d = t.seriesField ? r.readField(o, a, t.seriesField) : void 0, f = d == null ? "__default" : String(d), g = t.labelField ? r.readField(o, a, t.labelField) : void 0;
1647
+ return [{
1648
+ row: o,
1649
+ rowIndex: a,
1650
+ key: String(r.getRowKey(o, a)),
1651
+ category: c,
1652
+ value: s,
1653
+ seriesKey: f,
1654
+ seriesLabel: g === void 0 ? f : String(g)
1655
+ }];
1656
+ });
1657
+ }
1658
+ function Qi(e, i) {
1659
+ const { props: t, dataStore: r } = e, n = /* @__PURE__ */ new Set(), a = [];
1660
+ return i.forEach((o, s) => {
1661
+ const c = t.seriesField ? r.readField(o, s, t.seriesField) : void 0, d = c == null ? "__default" : String(c);
1662
+ n.has(d) || (n.add(d), a.push({
1663
+ id: d,
1664
+ kind: "bar",
1665
+ scaleIds: {
1666
+ x: t.xScaleId,
1667
+ y: t.yScaleId
1668
+ },
1669
+ label: d === "__default" ? "Value" : d,
1670
+ color: t.colors.palette[a.length % t.colors.palette.length] ?? t.fill,
1671
+ visible: !0
1672
+ }));
1673
+ }), a.length > 0 ? a : [{
1674
+ id: "__default",
1675
+ kind: "bar",
1676
+ scaleIds: {
1677
+ x: t.xScaleId,
1678
+ y: t.yScaleId
1679
+ },
1680
+ label: "Value",
1681
+ color: t.fill,
1682
+ visible: !0
1683
+ }];
1684
+ }
1685
+ function er(e, i, t) {
1686
+ const { props: r, dataStore: n } = e;
1687
+ if (typeof r.colors.fill == "function") {
1688
+ const a = {
1689
+ row: i.row,
1690
+ key: i.key,
1691
+ value: i.value,
1692
+ category: i.category,
1693
+ seriesKey: i.seriesKey
1694
+ };
1695
+ return r.colors.fill(a);
1696
+ }
1697
+ if (typeof r.colors.fill == "string")
1698
+ return r.colors.fill;
1699
+ if (r.colors.colorField && i.row) {
1700
+ const a = n.readField(i.row, i.rowIndex, r.colors.colorField);
1701
+ if (typeof a == "string" && a)
1702
+ return a;
1703
+ }
1704
+ return (t == null ? void 0 : t.color) ?? r.fill;
1705
+ }
1706
+ function tr(e, i) {
1707
+ var n, a;
1708
+ const { props: t } = e;
1709
+ if (!t.labels.visible)
1710
+ return;
1711
+ const r = {
1712
+ row: i.row,
1713
+ key: i.key,
1714
+ value: i.value,
1715
+ category: i.category,
1716
+ seriesKey: i.seriesKey,
1717
+ seriesLabel: i.seriesLabel
1718
+ };
1719
+ return ((a = (n = t.labels).formatter) == null ? void 0 : a.call(n, r)) ?? sr(i.value);
1720
+ }
1721
+ function ir(e) {
1722
+ return Array.from({ length: e }, () => ({
1723
+ count: 0,
1724
+ sum: 0,
1725
+ min: Number.POSITIVE_INFINITY,
1726
+ max: Number.NEGATIVE_INFINITY
1727
+ }));
1728
+ }
1729
+ function rr(e, i) {
1730
+ e.count += 1, e.sum += i, i < e.min && (e.min = i), i > e.max && (e.max = i);
1731
+ }
1732
+ function nr(e, i) {
1733
+ return e.count === 0 ? null : i === "min" ? e.min : i === "max" ? e.max : i === "sum" ? e.sum : e.sum / e.count;
1734
+ }
1735
+ function Ne(e) {
1736
+ return e.props.orientation === "horizontal" ? e.yScale : e.xScale;
1737
+ }
1738
+ function De(e) {
1739
+ return e.props.orientation === "horizontal" ? e.xScale : e.yScale;
1740
+ }
1741
+ function Re(e) {
1742
+ return e.props.orientation === "horizontal" ? e.height : e.width;
1743
+ }
1744
+ function $t(e) {
1745
+ const i = e.getDomain();
1746
+ return i.every((t) => typeof t == "string") ? i : [];
1747
+ }
1748
+ function ar(e, i, t) {
1749
+ return e instanceof G ? e.visibleIndexRange(-t, i + t) : { startIndex: 0, endIndex: $t(e).length - 1 };
1750
+ }
1751
+ function we(e, i) {
1752
+ return e.toPx(i);
1753
+ }
1754
+ function Je(e) {
1755
+ return Number.isFinite(e.x) && Number.isFinite(e.y) && e.width > 0 && e.height > 0;
1756
+ }
1757
+ function sr(e) {
1758
+ return Number.isFinite(e) ? e.toLocaleString("en-US", { maximumFractionDigits: 2 }) : "-";
1759
+ }
1760
+ function xe() {
1761
+ return typeof performance < "u" ? performance.now() : Date.now();
1762
+ }
1763
+ function Lt(e, i, t = !0) {
1764
+ if (e.length <= i)
1765
+ return [...e];
1766
+ if (!t) {
1767
+ const a = [];
1768
+ let o = 0;
1769
+ for (; o < e.length && a.length < i; ) {
1770
+ let s = o + 1;
1771
+ for (; s < e.length && e[s].seriesKey === e[o].seriesKey; )
1772
+ s++;
1773
+ const c = Math.min(s - o, i - a.length, Math.max(1, Math.round((i - a.length) * (s - o) / (e.length - o))));
1774
+ let d = o, f = o;
1775
+ for (let y = o + 1; y < s; y++)
1776
+ e[y].y < e[d].y && (d = y), e[y].y > e[f].y && (f = y);
1777
+ const g = new Set(c >= 2 ? [d, f] : [o]);
1778
+ for (let y = 0; g.size < c; y++)
1779
+ g.add(o + Math.floor(y * (s - o - 1) / Math.max(1, c - 1)));
1780
+ for (const y of [...g].sort((S, k) => S - k))
1781
+ a.push(e[y]);
1782
+ o = s;
1783
+ }
1784
+ return a;
1785
+ }
1786
+ const r = [];
1787
+ let n = 0;
1788
+ for (; n < e.length; ) {
1789
+ let a = n + 1;
1790
+ const o = (f) => e[f].seriesKey === e[n].seriesKey && (!t || e[f].segmentGroup === e[n].segmentGroup);
1791
+ for (; a < e.length && o(a); )
1792
+ a++;
1793
+ const s = a - n, c = Math.max(1, Math.floor(i * s / e.length / 4)), d = Math.max(1, Math.ceil(s / c));
1794
+ for (let f = n; f < a; f += d) {
1795
+ const g = Math.min(a, f + d);
1796
+ let y = f, S = f;
1797
+ for (let m = f + 1; m < g; m++)
1798
+ e[m].y < e[y].y && (y = m), e[m].y > e[S].y && (S = m);
1799
+ const k = [f, y, S, g - 1].sort((m, N) => m - N);
1800
+ let x = -1;
1801
+ for (const m of k)
1802
+ m !== x && (r.push(e[m]), x = m);
1803
+ }
1804
+ n = a;
1805
+ }
1806
+ return r;
1807
+ }
1808
+ const qe = {
1809
+ enabled: !0,
1810
+ overscanPx: 64,
1811
+ maxRenderedPoints: 5e4
1812
+ };
1813
+ function or(e, i = e.dataStore.getData()) {
1814
+ if (!e.seriesField)
1815
+ return [{ id: "__default", kind: e.kind, scaleIds: { x: e.xScaleId, y: e.yScaleId }, label: e.fallbackLabel, color: e.palette[0] ?? e.defaultColor, visible: !0 }];
1816
+ const t = /* @__PURE__ */ new Set(), r = [];
1817
+ return i.forEach((n, a) => {
1818
+ const o = e.seriesField ? e.dataStore.readField(n, a, e.seriesField) : void 0, s = o == null ? "__default" : String(o);
1819
+ t.has(s) || (t.add(s), r.push({
1820
+ id: s,
1821
+ kind: e.kind,
1822
+ scaleIds: {
1823
+ x: e.xScaleId,
1824
+ y: e.yScaleId
1825
+ },
1826
+ label: s === "__default" ? e.fallbackLabel : s,
1827
+ color: e.palette[r.length % e.palette.length] ?? e.defaultColor,
1828
+ visible: !0
1829
+ }));
1830
+ }), r.length > 0 ? r : [{
1831
+ id: "__default",
1832
+ kind: e.kind,
1833
+ scaleIds: {
1834
+ x: e.xScaleId,
1835
+ y: e.yScaleId
1836
+ },
1837
+ label: e.fallbackLabel,
1838
+ color: e.defaultColor,
1839
+ visible: !0
1840
+ }];
1841
+ }
1842
+ function cn(e) {
1843
+ const i = e.dataStore.getData();
1844
+ if (e.xScale instanceof G) {
1845
+ const t = /* @__PURE__ */ new Set(), r = [];
1846
+ return i.forEach((n, a) => {
1847
+ const o = String(e.dataStore.readField(n, a, e.xField) ?? "");
1848
+ t.has(o) || (t.add(o), r.push(o));
1849
+ }), r;
1850
+ }
1851
+ return [...e.dataStore.numericExtent(e.xField)];
1852
+ }
1853
+ function dn(e) {
1854
+ return [...e.dataStore.numericExtent(e.yField)];
1855
+ }
1856
+ function un(e, i = e.dataStore.getData()) {
1857
+ const t = [], r = or(e, i), n = new Map(r.map((o) => [o.id, o])), a = /* @__PURE__ */ new Map();
1858
+ return i.forEach((o, s) => {
1859
+ const c = e.dataStore.readField(o, s, e.yField), d = c == null ? NaN : Number(c), f = cr(e, o, s), g = e.seriesField ? e.dataStore.readField(o, s, e.seriesField) : void 0, y = g == null ? "__default" : String(g), S = e.labelField ? e.dataStore.readField(o, s, e.labelField) : void 0, k = S == null ? y : String(S), x = {
1860
+ row: o,
1861
+ rowIndex: s,
1862
+ key: String(e.dataStore.getRowKey(o, s)),
1863
+ xValue: f,
1864
+ yValue: d,
1865
+ seriesKey: y,
1866
+ seriesLabel: k
1867
+ };
1868
+ if (!hr(e, x)) {
1869
+ e.connectNulls || a.set(y, (a.get(y) ?? 0) + 1);
1870
+ return;
1871
+ }
1872
+ const m = dr(e.xScale, f), N = Number(e.yScale.toPx(d));
1873
+ if (!Number.isFinite(m) || !Number.isFinite(N)) {
1874
+ e.connectNulls || a.set(y, (a.get(y) ?? 0) + 1);
1875
+ return;
1876
+ }
1877
+ const E = n.get(y);
1878
+ t.push({
1879
+ key: x.key,
1880
+ row: o,
1881
+ rowIndex: s,
1882
+ xValue: f,
1883
+ yValue: d,
1884
+ rawValue: d,
1885
+ seriesKey: y,
1886
+ seriesLabel: k,
1887
+ color: fr(e, x, E),
1888
+ x: m,
1889
+ y: N,
1890
+ order: ur(e.xScale, f, s),
1891
+ visible: mr(e, m, N),
1892
+ segmentGroup: a.get(y) ?? 0
1893
+ });
1894
+ }), t.sort(vr);
1895
+ }
1896
+ function hn(e, i) {
1897
+ const t = e.virtualization.enabled ? i.filter((n) => n.visible) : i, r = gr(t, e.virtualization.maxRenderedPoints, e.virtualization.sampling, e.kind === "area");
1898
+ return {
1899
+ visibleCandidates: t,
1900
+ renderedCandidates: r,
1901
+ mode: br(e, t.length, r.length)
1902
+ };
1903
+ }
1904
+ function fn(e, i) {
1905
+ const t = [], r = /* @__PURE__ */ new Map();
1906
+ for (const n of e) {
1907
+ const a = r.get(n.seriesKey) ?? [];
1908
+ a.push(n), r.set(n.seriesKey, a);
1909
+ }
1910
+ for (const [n, a] of r)
1911
+ for (let o = 1; o < a.length; o += 1) {
1912
+ const s = a[o - 1], c = a[o];
1913
+ if (!(!s || !c) && s.segmentGroup === c.segmentGroup) {
1914
+ if (i === "step") {
1915
+ const d = `${s.key}:${c.key}:step`;
1916
+ t.push({
1917
+ key: `${d}:h`,
1918
+ seriesKey: n,
1919
+ color: s.color,
1920
+ x1: s.x,
1921
+ y1: s.y,
1922
+ x2: c.x,
1923
+ y2: s.y
1924
+ }), t.push({
1925
+ key: `${d}:v`,
1926
+ seriesKey: n,
1927
+ color: c.color,
1928
+ x1: c.x,
1929
+ y1: s.y,
1930
+ x2: c.x,
1931
+ y2: c.y
1932
+ });
1933
+ continue;
1934
+ }
1935
+ t.push({
1936
+ key: `${s.key}:${c.key}`,
1937
+ seriesKey: n,
1938
+ color: s.color,
1939
+ x1: s.x,
1940
+ y1: s.y,
1941
+ x2: c.x,
1942
+ y2: c.y
1943
+ });
1944
+ }
1945
+ }
1946
+ return t.filter((n) => Number.isFinite(n.x1) && Number.isFinite(n.y1) && Number.isFinite(n.x2) && Number.isFinite(n.y2));
1947
+ }
1948
+ function lr(e, i) {
1949
+ return e instanceof G ? e.center(String(i)) : Number(e.toPx(i));
1950
+ }
1951
+ function mn(e) {
1952
+ let i = Number.POSITIVE_INFINITY, t = Number.NEGATIVE_INFINITY;
1953
+ for (const r of e)
1954
+ Number.isFinite(r) && (r < i && (i = r), r > t && (t = r));
1955
+ return i === Number.POSITIVE_INFINITY ? [0, 1] : [i, t];
1956
+ }
1957
+ function cr(e, i, t) {
1958
+ const r = e.dataStore.readField(i, t, e.xField);
1959
+ return e.xScale instanceof G ? String(r ?? "") : Number(r);
1960
+ }
1961
+ function dr(e, i) {
1962
+ return lr(e, i);
1963
+ }
1964
+ function ur(e, i, t) {
1965
+ if (e instanceof G) {
1966
+ const n = e.indexOf(String(i));
1967
+ return n >= 0 ? n : t;
1968
+ }
1969
+ const r = Number(i);
1970
+ return Number.isFinite(r) ? r : t;
1971
+ }
1972
+ function hr(e, i) {
1973
+ var t;
1974
+ return !Number.isFinite(i.yValue) || typeof i.xValue == "number" && !Number.isFinite(i.xValue) ? !1 : ((t = e.defined) == null ? void 0 : t.call(e, i)) ?? !0;
1975
+ }
1976
+ function fr(e, i, t) {
1977
+ var n;
1978
+ const r = (n = e.resolveColor) == null ? void 0 : n.call(e, i, t);
1979
+ if (r)
1980
+ return r;
1981
+ if (e.colorField && i.row) {
1982
+ const a = e.dataStore.readField(i.row, i.rowIndex ?? -1, e.colorField);
1983
+ if (typeof a == "string" && a)
1984
+ return a;
1985
+ }
1986
+ return (t == null ? void 0 : t.color) ?? e.defaultColor;
1987
+ }
1988
+ function mr(e, i, t) {
1989
+ const r = e.virtualization.overscanPx;
1990
+ return i >= -r && i <= e.width + r && t >= -r && t <= e.height + r;
1991
+ }
1992
+ function gr(e, i, t, r) {
1993
+ if (e.length <= i)
1994
+ return e;
1995
+ if (t === "lttb") {
1996
+ const n = /* @__PURE__ */ new Map();
1997
+ for (const o of e) {
1998
+ const s = `${o.seriesKey}\0${o.segmentGroup}`, c = n.get(s) ?? [];
1999
+ c.push(o), n.set(s, c);
2000
+ }
2001
+ const a = /* @__PURE__ */ new Set();
2002
+ for (const o of n.values()) {
2003
+ const s = Math.max(3, Math.round(i * o.length / e.length));
2004
+ for (const c of yr(o, s))
2005
+ a.add(c);
2006
+ }
2007
+ return e.filter((o) => a.has(o));
2008
+ }
2009
+ return Lt(e, i, r);
2010
+ }
2011
+ function yr(e, i) {
2012
+ if (e.length <= i)
2013
+ return e;
2014
+ const t = [e[0]], r = (e.length - 2) / (i - 2);
2015
+ let n = 0;
2016
+ for (let a = 0; a < i - 2; a++) {
2017
+ const o = Math.floor(a * r) + 1, s = Math.min(e.length - 1, Math.floor((a + 1) * r) + 1), c = Math.floor((a + 1) * r) + 1, d = Math.min(e.length, Math.floor((a + 2) * r) + 1);
2018
+ let f = 0, g = 0;
2019
+ for (let x = c; x < d; x++)
2020
+ f += e[x].x, g += e[x].y;
2021
+ const y = Math.max(1, d - c);
2022
+ f /= y, g /= y;
2023
+ const S = e[n];
2024
+ let k = -1;
2025
+ for (let x = o; x < s; x++) {
2026
+ const m = e[x], N = Math.abs((S.x - f) * (m.y - S.y) - (S.x - m.x) * (g - S.y));
2027
+ N > k && (k = N, n = x);
2028
+ }
2029
+ t.push(e[n]);
2030
+ }
2031
+ return t.push(e[e.length - 1]), t;
2032
+ }
2033
+ function br(e, i, t) {
2034
+ return e.virtualization.enabled ? t < i ? "sampled" : i < e.dataStore.rowCount ? "windowed" : "direct" : "direct";
2035
+ }
2036
+ function vr(e, i) {
2037
+ return e.seriesKey !== i.seriesKey ? e.seriesKey.localeCompare(i.seriesKey) : e.segmentGroup !== i.segmentGroup ? e.segmentGroup - i.segmentGroup : e.order - i.order || e.rowIndex - i.rowIndex;
2038
+ }
2039
+ function Sr(e, i) {
2040
+ if (!e.virtualization.enabled || e.xScale instanceof G || e.seriesField || e.labelField || e.defined || e.colorField || typeof e.xField == "function" || typeof e.yField == "function")
2041
+ return null;
2042
+ const t = e.dataStore.numericColumn(e.xField);
2043
+ if (!t.ordered)
2044
+ return null;
2045
+ const r = e.dataStore.numericColumn(e.yField), n = r.values, a = e.dataStore.getData(), o = e.xScale.getDomain(), s = Math.abs(o[1] - o[0]) * e.virtualization.overscanPx / Math.max(1, e.width), c = Math.max(0, xt(t.values, o[0] - s) - 1), d = Math.min(a.length, xt(t.values, o[1] + s) + 1), f = Math.max(4, e.virtualization.maxRenderedPoints), g = Math.max(1, Math.ceil((d - c) / Math.max(1, Math.floor(f / 4)))), y = [];
2046
+ let S = 0, k = 0, x = -1, m = -1, N = -1, E = -1;
2047
+ const q = (D) => {
2048
+ const U = a[D], A = t.values[D], $ = n[D];
2049
+ y.push({ row: U, rowIndex: D, key: String(e.dataStore.getRowKey(U, D)), xValue: A, yValue: $, rawValue: $, seriesKey: "__default", seriesLabel: "__default", color: i, x: Number(e.xScale.toPx(A)), y: Number(e.yScale.toPx($)), order: A, visible: !0, segmentGroup: S });
2050
+ }, L = () => {
2051
+ if (x < 0)
2052
+ return;
2053
+ q(x);
2054
+ const D = Math.min(N, E), U = Math.max(N, E);
2055
+ D !== x && D !== m && q(D), U !== x && U !== m && U !== D && q(U), m !== x && q(m), x = m = N = E = -1;
2056
+ };
2057
+ for (let D = c; D < d; D += g) {
2058
+ const U = Math.min(d, D + g);
2059
+ for (let A = D; A < U; A++) {
2060
+ const $ = n[A];
2061
+ if (!Number.isFinite($)) {
2062
+ e.connectNulls || (L(), S++);
2063
+ continue;
2064
+ }
2065
+ k++, x < 0 && (x = N = E = A), m = A, $ < n[N] && (N = A), $ > n[E] && (E = A);
2066
+ }
2067
+ L();
2068
+ }
2069
+ return { points: y, visibleCount: k, skippedCount: r.invalidCount };
2070
+ }
2071
+ function xt(e, i) {
2072
+ let t = 0, r = e.length;
2073
+ for (; t < r; ) {
2074
+ const n = t + r >>> 1;
2075
+ e[n] < i ? t = n + 1 : r = n;
2076
+ }
2077
+ return t;
2078
+ }
2079
+ function _r(e, i, t) {
2080
+ const r = e[i], n = e[i + 1], a = e[Math.max(0, i - 1)], o = e[Math.min(e.length - 1, i + 2)], s = n.x - r.x;
2081
+ if (s <= 0)
2082
+ return r.y + (n.y - r.y) * t;
2083
+ const c = (n.y - a.y) / Math.max(1, n.x - a.x), d = (o.y - r.y) / Math.max(1, o.x - r.x), f = (2 * t ** 3 - 3 * t ** 2 + 1) * r.y + (t ** 3 - 2 * t ** 2 + t) * s * c + (-2 * t ** 3 + 3 * t ** 2) * n.y + (t ** 3 - t ** 2) * s * d;
2084
+ return Math.max(Math.min(r.y, n.y), Math.min(Math.max(r.y, n.y), f));
2085
+ }
2086
+ const We = {
2087
+ enabled: !0,
2088
+ overscanPx: 64,
2089
+ maxRenderedPoints: 5e4
2090
+ };
2091
+ function gn(e) {
2092
+ const i = pe(), t = pe(), r = e.dataStore.getData(), n = Vt(e, r), a = pe() - t, o = pe(), s = typeof e.props.colors.stroke == "function" ? null : Sr({ ...e, ...e.props, virtualization: { ...e.props.virtualization, sampling: "stride" }, palette: e.props.colors.palette, defaultColor: e.props.stroke, colorField: e.props.colors.colorField }, e.props.colors.stroke ?? n[0].color), c = (s == null ? void 0 : s.points) ?? xr(e, r), d = e.props.virtualization.enabled ? c.filter((x) => x.visible) : c, g = (s || !e.props.virtualization.enabled ? c : Dr(d, e.props.virtualization.maxRenderedPoints)).filter(Tr), y = pr(e, g), S = pe() - o, k = {
2093
+ kind: "line",
2094
+ inputRows: r.length,
2095
+ visibleRows: (s == null ? void 0 : s.visibleCount) ?? d.length,
2096
+ renderedPoints: g.length,
2097
+ renderedSegments: y.length,
2098
+ skippedRows: (s == null ? void 0 : s.skippedCount) ?? r.length - c.length,
2099
+ seriesCount: n.length,
2100
+ mode: Rr(e, (s == null ? void 0 : s.visibleCount) ?? d.length, g.length),
2101
+ domainMs: a,
2102
+ layoutMs: S,
2103
+ schemaMs: 0,
2104
+ totalMs: pe() - i
2105
+ };
2106
+ return {
2107
+ points: g,
2108
+ segments: y,
2109
+ series: n,
2110
+ diagnostics: k
2111
+ };
2112
+ }
2113
+ function yn(e) {
2114
+ const i = e.dataStore.getData();
2115
+ if (e.xScale instanceof G) {
2116
+ const t = /* @__PURE__ */ new Set(), r = [];
2117
+ return i.forEach((n, a) => {
2118
+ const o = String(e.dataStore.readField(n, a, e.props.xField) ?? "");
2119
+ t.has(o) || (t.add(o), r.push(o));
2120
+ }), r;
2121
+ }
2122
+ return [...e.dataStore.numericExtent(e.props.xField)];
2123
+ }
2124
+ function bn(e) {
2125
+ return [...e.dataStore.numericExtent(e.props.yField)];
2126
+ }
2127
+ function xr(e, i) {
2128
+ const t = [], r = wr(Vt(e, i)), n = /* @__PURE__ */ new Map();
2129
+ return i.forEach((a, o) => {
2130
+ const s = e.dataStore.readField(a, o, e.props.yField), c = s == null ? NaN : Number(s), d = kr(e, a, o), f = e.props.seriesField ? e.dataStore.readField(a, o, e.props.seriesField) : void 0, g = f == null ? "__default" : String(f), y = e.props.labelField ? e.dataStore.readField(a, o, e.props.labelField) : void 0, S = y == null ? g : String(y), k = {
2131
+ row: a,
2132
+ rowIndex: o,
2133
+ key: String(e.dataStore.getRowKey(a, o)),
2134
+ xValue: d,
2135
+ yValue: c,
2136
+ seriesKey: g,
2137
+ seriesLabel: S
2138
+ };
2139
+ if (!Mr(e, k)) {
2140
+ e.props.connectNulls || n.set(g, (n.get(g) ?? 0) + 1);
2141
+ return;
2142
+ }
2143
+ const x = Cr(e.xScale, d), m = Number(e.yScale.toPx(c));
2144
+ if (!Number.isFinite(x) || !Number.isFinite(m)) {
2145
+ e.props.connectNulls || n.set(g, (n.get(g) ?? 0) + 1);
2146
+ return;
2147
+ }
2148
+ t.push({
2149
+ key: k.key,
2150
+ row: a,
2151
+ rowIndex: o,
2152
+ xValue: d,
2153
+ yValue: c,
2154
+ rawValue: c,
2155
+ seriesKey: g,
2156
+ seriesLabel: S,
2157
+ color: Fr(e, k, r.get(g)),
2158
+ x,
2159
+ y: m,
2160
+ order: Ir(e.xScale, d, o),
2161
+ visible: Nr(e, x, m),
2162
+ segmentGroup: n.get(g) ?? 0
2163
+ });
2164
+ }), t.sort((a, o) => a.seriesKey !== o.seriesKey ? a.seriesKey.localeCompare(o.seriesKey) : a.segmentGroup !== o.segmentGroup ? a.segmentGroup - o.segmentGroup : a.order - o.order || a.rowIndex - o.rowIndex);
2165
+ }
2166
+ function pr(e, i) {
2167
+ const t = [];
2168
+ let r = [i];
2169
+ if (e.props.seriesField || e.props.curve === "smooth") {
2170
+ const n = /* @__PURE__ */ new Map();
2171
+ for (const a of i) {
2172
+ const o = `${a.seriesKey}:${Ge(a)}`, s = n.get(o) ?? [];
2173
+ s.push(a), n.set(o, s);
2174
+ }
2175
+ r = n.values();
2176
+ }
2177
+ for (const n of r) {
2178
+ if (!n.length)
2179
+ continue;
2180
+ const a = n[0].seriesKey;
2181
+ for (let o = 1; o < n.length; o += 1) {
2182
+ const s = n[o - 1], c = n[o];
2183
+ if (!(!s || !c) && Ge(s) === Ge(c)) {
2184
+ if (e.props.curve === "smooth") {
2185
+ let d = s.x, f = s.y;
2186
+ for (let g = 1; g <= 5; g++) {
2187
+ const y = g / 5, S = s.x + (c.x - s.x) * y, k = _r(n, o - 1, y);
2188
+ t.push({ key: `${s.key}:${c.key}:smooth:${g}`, seriesKey: a, color: s.color, x1: d, y1: f, x2: S, y2: k }), d = S, f = k;
2189
+ }
2190
+ continue;
2191
+ }
2192
+ if (e.props.curve === "step") {
2193
+ const d = `${s.key}:${c.key}:step`;
2194
+ t.push({
2195
+ key: `${d}:h`,
2196
+ seriesKey: a,
2197
+ color: s.color,
2198
+ x1: s.x,
2199
+ y1: s.y,
2200
+ x2: c.x,
2201
+ y2: s.y
2202
+ }), t.push({
2203
+ key: `${d}:v`,
2204
+ seriesKey: a,
2205
+ color: c.color,
2206
+ x1: c.x,
2207
+ y1: s.y,
2208
+ x2: c.x,
2209
+ y2: c.y
2210
+ });
2211
+ continue;
2212
+ }
2213
+ t.push({
2214
+ key: `${s.key}:${c.key}`,
2215
+ seriesKey: a,
2216
+ color: s.color,
2217
+ x1: s.x,
2218
+ y1: s.y,
2219
+ x2: c.x,
2220
+ y2: c.y
2221
+ });
2222
+ }
2223
+ }
2224
+ }
2225
+ return t.filter(Er);
2226
+ }
2227
+ function Vt(e, i) {
2228
+ if (!e.props.seriesField)
2229
+ return [{ id: "__default", kind: "line", scaleIds: { x: e.props.xScaleId, y: e.props.yScaleId }, label: "Line", color: e.props.colors.palette[0] ?? e.props.stroke, visible: !0 }];
2230
+ const t = /* @__PURE__ */ new Set(), r = [];
2231
+ return i.forEach((n, a) => {
2232
+ const o = e.props.seriesField ? e.dataStore.readField(n, a, e.props.seriesField) : void 0, s = o == null ? "__default" : String(o);
2233
+ t.has(s) || (t.add(s), r.push({
2234
+ id: s,
2235
+ kind: "line",
2236
+ scaleIds: {
2237
+ x: e.props.xScaleId,
2238
+ y: e.props.yScaleId
2239
+ },
2240
+ label: s === "__default" ? "Line" : s,
2241
+ color: e.props.colors.palette[r.length % e.props.colors.palette.length] ?? e.props.stroke,
2242
+ visible: !0
2243
+ }));
2244
+ }), r.length > 0 ? r : [{
2245
+ id: "__default",
2246
+ kind: "line",
2247
+ scaleIds: {
2248
+ x: e.props.xScaleId,
2249
+ y: e.props.yScaleId
2250
+ },
2251
+ label: "Line",
2252
+ color: e.props.stroke,
2253
+ visible: !0
2254
+ }];
2255
+ }
2256
+ function wr(e) {
2257
+ return new Map(e.map((i) => [i.id, i]));
2258
+ }
2259
+ function kr(e, i, t) {
2260
+ const r = e.dataStore.readField(i, t, e.props.xField);
2261
+ return e.xScale instanceof G ? String(r ?? "") : Number(r);
2262
+ }
2263
+ function Cr(e, i) {
2264
+ return e instanceof G ? e.center(String(i)) : Number(e.toPx(i));
2265
+ }
2266
+ function Ir(e, i, t) {
2267
+ if (e instanceof G) {
2268
+ const n = e.indexOf(String(i));
2269
+ return n >= 0 ? n : t;
2270
+ }
2271
+ const r = Number(i);
2272
+ return Number.isFinite(r) ? r : t;
2273
+ }
2274
+ function Mr(e, i) {
2275
+ var t, r;
2276
+ return !Number.isFinite(i.yValue) || typeof i.xValue == "number" && !Number.isFinite(i.xValue) ? !1 : ((r = (t = e.props).defined) == null ? void 0 : r.call(t, i)) ?? !0;
2277
+ }
2278
+ function Fr(e, i, t) {
2279
+ if (typeof e.props.colors.stroke == "function")
2280
+ return e.props.colors.stroke(i);
2281
+ if (typeof e.props.colors.stroke == "string")
2282
+ return e.props.colors.stroke;
2283
+ if (e.props.colors.colorField && i.row) {
2284
+ const r = e.dataStore.readField(i.row, i.rowIndex ?? -1, e.props.colors.colorField);
2285
+ if (typeof r == "string" && r)
2286
+ return r;
2287
+ }
2288
+ return (t == null ? void 0 : t.color) ?? e.props.stroke;
2289
+ }
2290
+ function Ge(e) {
2291
+ return e.segmentGroup ?? 0;
2292
+ }
2293
+ function Nr(e, i, t) {
2294
+ const r = e.props.virtualization.overscanPx;
2295
+ return i >= -r && i <= e.width + r && t >= -r && t <= e.height + r;
2296
+ }
2297
+ function Dr(e, i) {
2298
+ return e.length <= i ? e : Lt(e, i);
2299
+ }
2300
+ function Rr(e, i, t) {
2301
+ return e.props.virtualization.enabled ? t < i ? "sampled" : i < e.dataStore.rowCount ? "windowed" : "direct" : "direct";
2302
+ }
2303
+ function Tr(e) {
2304
+ return Number.isFinite(e.x) && Number.isFinite(e.y);
2305
+ }
2306
+ function Er(e) {
2307
+ return Number.isFinite(e.x1) && Number.isFinite(e.y1) && Number.isFinite(e.x2) && Number.isFinite(e.y2);
2308
+ }
2309
+ function pe() {
2310
+ return typeof performance < "u" ? performance.now() : Date.now();
2311
+ }
2312
+ const Pr = {
2313
+ ...Jt,
2314
+ styleSheet: { type: "string" },
2315
+ visualPreset: { type: "string" },
2316
+ plugins: { type: "array" },
2317
+ accessibility: { type: "record" },
2318
+ states: { type: "record" },
2319
+ parts: { type: "record" },
2320
+ renderers: { type: "record" }
2321
+ }, zr = {
2322
+ ...dt,
2323
+ render: [
2324
+ ...dt.render ?? [],
2325
+ "styleSheet",
2326
+ "visualPreset",
2327
+ "plugins",
2328
+ "accessibility",
2329
+ "states",
2330
+ "parts",
2331
+ "renderers"
2332
+ ]
2333
+ };
2334
+ function Te(e, i) {
2335
+ const { motion: t, style: r, ...n } = e;
2336
+ return ke(n, i);
2337
+ }
2338
+ function Ze(e = {}) {
2339
+ return {
2340
+ ...ke(e, {
2341
+ width: 720,
2342
+ height: 420,
2343
+ background: "#ffffff",
2344
+ clip: !1
2345
+ }),
2346
+ data: e.data ? [...e.data] : [],
2347
+ keyField: e.keyField,
2348
+ refScope: e.refScope,
2349
+ styleSheet: e.styleSheet,
2350
+ visualPreset: e.visualPreset,
2351
+ plugins: e.plugins ? [...e.plugins] : void 0,
2352
+ accessibility: Ar(e.accessibility)
2353
+ };
2354
+ }
2355
+ function vn(e) {
2356
+ return {
2357
+ ...ke(e, { width: 0, height: 0, clip: !1 }),
2358
+ scaleId: e.scaleId,
2359
+ scaleType: e.scaleType,
2360
+ field: e.field,
2361
+ domain: e.domain,
2362
+ zero: e.zero ?? e.scaleType !== "band",
2363
+ nice: e.nice ?? e.scaleType !== "band",
2364
+ clamp: e.clamp ?? !1,
2365
+ paddingInner: R(e.paddingInner, 0.18),
2366
+ paddingOuter: R(e.paddingOuter, 0.08),
2367
+ locale: e.locale ?? "ru-RU",
2368
+ timezone: e.timezone ?? "UTC"
2369
+ };
2370
+ }
2371
+ function Sn(e = {}) {
2372
+ return {
2373
+ ...ke(e, {
2374
+ width: 560,
2375
+ height: 300,
2376
+ clip: !0
2377
+ }),
2378
+ chartRef: e.chartRef,
2379
+ xScaleId: e.xScaleId,
2380
+ yScaleId: e.yScaleId,
2381
+ xScaleIds: e.xScaleIds ? [...e.xScaleIds] : void 0,
2382
+ yScaleIds: e.yScaleIds ? [...e.yScaleIds] : void 0
2383
+ };
2384
+ }
2385
+ function _n(e) {
2386
+ return {
2387
+ ...ke(e, {
2388
+ width: 560,
2389
+ height: 36,
2390
+ clip: !0,
2391
+ fontSize: 11,
2392
+ lineHeight: 14
2393
+ }),
2394
+ chartRef: e.chartRef,
2395
+ scaleId: e.scaleId,
2396
+ orientation: e.orientation,
2397
+ tickSide: e.tickSide ?? "end",
2398
+ labelSide: e.labelSide ?? e.tickSide ?? "end",
2399
+ labelRotation: e.labelRotation ?? 0,
2400
+ tickSize: R(e.tickSize, 5),
2401
+ labelPadding: R(e.labelPadding, 5),
2402
+ ticks: e.ticks,
2403
+ lineColor: e.lineColor ?? "#d5deea",
2404
+ tickColor: e.tickColor ?? "#ccd6e3",
2405
+ labelColor: e.labelColor ?? "#64748b"
2406
+ };
2407
+ }
2408
+ function xn(e = {}) {
2409
+ return {
2410
+ ...ke(e, {
2411
+ width: 560,
2412
+ height: 300,
2413
+ clip: !0
2414
+ }),
2415
+ chartRef: e.chartRef,
2416
+ xScaleId: e.xScaleId,
2417
+ yScaleId: e.yScaleId,
2418
+ xTicks: e.xTicks,
2419
+ yTicks: e.yTicks,
2420
+ lineColor: e.lineColor ?? "#eef2f7"
2421
+ };
2422
+ }
2423
+ function pn(e) {
2424
+ var n, a, o, s, c, d, f, g, y, S, k, x, m, N, E, q, L, D, U, A, $, z, Y, J, se, ve, ie, O, Z, X, j;
2425
+ const i = e.orientation ?? "vertical", t = e.categoryField ?? e.xField, r = e.valueField ?? e.yField;
2426
+ if (!t)
2427
+ throw new Error("[NovaCharts] BarSeries requires categoryField or xField");
2428
+ if (!r)
2429
+ throw new Error("[NovaCharts] BarSeries requires valueField or yField");
2430
+ return {
2431
+ ...Te(e, {
2432
+ width: 560,
2433
+ height: 300,
2434
+ clip: !0
2435
+ }),
2436
+ chartRef: e.chartRef,
2437
+ xScaleId: e.xScaleId,
2438
+ yScaleId: e.yScaleId,
2439
+ xField: e.xField,
2440
+ yField: e.yField,
2441
+ categoryField: t,
2442
+ valueField: r,
2443
+ seriesField: e.seriesField,
2444
+ labelField: e.labelField,
2445
+ orientation: i,
2446
+ mode: e.mode ?? (e.seriesField ? "grouped" : "single"),
2447
+ fill: e.fill ?? "#2563eb",
2448
+ radius: Math.max(0, R(e.radius, 2)),
2449
+ minBarSize: Math.max(0, R(e.minBarSize, 1)),
2450
+ virtualization: {
2451
+ enabled: ((n = e.virtualization) == null ? void 0 : n.enabled) ?? Fe.enabled,
2452
+ overscanPx: R((a = e.virtualization) == null ? void 0 : a.overscanPx, Fe.overscanPx),
2453
+ minBarWidthPx: R((o = e.virtualization) == null ? void 0 : o.minBarWidthPx, Fe.minBarWidthPx),
2454
+ maxRenderedBars: Math.max(1, Math.trunc(R(
2455
+ (s = e.virtualization) == null ? void 0 : s.maxRenderedBars,
2456
+ Fe.maxRenderedBars
2457
+ ))),
2458
+ aggregation: ((c = e.virtualization) == null ? void 0 : c.aggregation) ?? Fe.aggregation
2459
+ },
2460
+ highlight: {
2461
+ enabled: ((d = e.highlight) == null ? void 0 : d.enabled) ?? ((g = (f = e.colors) == null ? void 0 : f.highlight) == null ? void 0 : g.enabled) ?? !0,
2462
+ fill: ((y = e.highlight) == null ? void 0 : y.fill) ?? ((k = (S = e.colors) == null ? void 0 : S.highlight) == null ? void 0 : k.fill) ?? "#1d4ed8",
2463
+ strokeColor: ((x = e.highlight) == null ? void 0 : x.strokeColor) ?? ((N = (m = e.colors) == null ? void 0 : m.highlight) == null ? void 0 : N.strokeColor) ?? "#1e40af",
2464
+ strokeWidth: Math.max(0, R((E = e.highlight) == null ? void 0 : E.strokeWidth, ((L = (q = e.colors) == null ? void 0 : q.highlight) == null ? void 0 : L.strokeWidth) ?? 0)),
2465
+ opacity: Math.max(0, Math.min(1, R((D = e.highlight) == null ? void 0 : D.opacity, ((A = (U = e.colors) == null ? void 0 : U.highlight) == null ? void 0 : A.opacity) ?? 1)))
2466
+ },
2467
+ labels: {
2468
+ visible: (($ = e.labels) == null ? void 0 : $.visible) ?? !1,
2469
+ position: ((z = e.labels) == null ? void 0 : z.position) ?? "outside",
2470
+ color: ((Y = e.labels) == null ? void 0 : Y.color) ?? "#0f172a",
2471
+ fontSize: Math.max(8, R((J = e.labels) == null ? void 0 : J.fontSize, 11)),
2472
+ fontWeight: ((se = e.labels) == null ? void 0 : se.fontWeight) ?? "700",
2473
+ formatter: (ve = e.labels) == null ? void 0 : ve.formatter
2474
+ },
2475
+ colors: {
2476
+ palette: (O = (ie = e.colors) == null ? void 0 : ie.palette) != null && O.length ? [...e.colors.palette] : [
2477
+ "#2563eb",
2478
+ "#16a34a",
2479
+ "#f59e0b",
2480
+ "#dc2626",
2481
+ "#7c3aed",
2482
+ "#0891b2",
2483
+ "#db2777",
2484
+ "#475569"
2485
+ ],
2486
+ colorField: (Z = e.colors) == null ? void 0 : Z.colorField,
2487
+ fill: (X = e.colors) == null ? void 0 : X.fill,
2488
+ highlight: (j = e.colors) == null ? void 0 : j.highlight
2489
+ },
2490
+ style: e.style,
2491
+ states: e.states ? { ...e.states } : void 0,
2492
+ parts: e.parts ? { ...e.parts } : void 0,
2493
+ renderers: e.renderers ? { ...e.renderers } : void 0,
2494
+ motion: e.motion
2495
+ };
2496
+ }
2497
+ function wn(e) {
2498
+ var i, t, r, n, a, o, s, c, d, f, g, y, S;
2499
+ return {
2500
+ ...Te(e, {
2501
+ width: 560,
2502
+ height: 300,
2503
+ clip: !0
2504
+ }),
2505
+ chartRef: e.chartRef,
2506
+ xScaleId: e.xScaleId,
2507
+ yScaleId: e.yScaleId,
2508
+ xField: e.xField,
2509
+ yField: e.yField,
2510
+ seriesField: e.seriesField,
2511
+ labelField: e.labelField,
2512
+ curve: e.curve ?? "linear",
2513
+ stroke: e.stroke ?? "#ea580c",
2514
+ strokeWidth: Math.max(1, R(e.strokeWidth, 2)),
2515
+ opacity: Math.max(0, Math.min(1, R(e.opacity, 1))),
2516
+ dashPattern: e.dashPattern ? [...e.dashPattern] : void 0,
2517
+ referenceLines: ((i = e.referenceLines) == null ? void 0 : i.filter(Number.isFinite)) ?? [],
2518
+ markers: {
2519
+ visible: ((t = e.markers) == null ? void 0 : t.visible) ?? !1,
2520
+ radius: ((r = e.markers) == null ? void 0 : r.radius) ?? 3,
2521
+ fill: (n = e.markers) == null ? void 0 : n.fill,
2522
+ strokeColor: (a = e.markers) == null ? void 0 : a.strokeColor,
2523
+ strokeWidth: Math.max(0, R((o = e.markers) == null ? void 0 : o.strokeWidth, 1.5))
2524
+ },
2525
+ colors: {
2526
+ palette: (c = (s = e.colors) == null ? void 0 : s.palette) != null && c.length ? [...e.colors.palette] : [
2527
+ "#ea580c",
2528
+ "#0ea5e9",
2529
+ "#16a34a",
2530
+ "#7c3aed",
2531
+ "#dc2626",
2532
+ "#0891b2",
2533
+ "#db2777",
2534
+ "#475569"
2535
+ ],
2536
+ colorField: (d = e.colors) == null ? void 0 : d.colorField,
2537
+ stroke: (f = e.colors) == null ? void 0 : f.stroke
2538
+ },
2539
+ defined: e.defined,
2540
+ connectNulls: e.connectNulls ?? !1,
2541
+ hitRadiusPx: Math.max(0, R(e.hitRadiusPx, 12)),
2542
+ virtualization: {
2543
+ enabled: ((g = e.virtualization) == null ? void 0 : g.enabled) ?? We.enabled,
2544
+ overscanPx: R((y = e.virtualization) == null ? void 0 : y.overscanPx, We.overscanPx),
2545
+ maxRenderedPoints: Math.max(2, Math.trunc(R(
2546
+ (S = e.virtualization) == null ? void 0 : S.maxRenderedPoints,
2547
+ We.maxRenderedPoints
2548
+ )))
2549
+ },
2550
+ style: e.style,
2551
+ states: e.states ? { ...e.states } : void 0,
2552
+ parts: e.parts ? { ...e.parts } : void 0,
2553
+ renderers: e.renderers ? { ...e.renderers } : void 0,
2554
+ motion: e.motion
2555
+ };
2556
+ }
2557
+ function kn(e) {
2558
+ var t, r, n, a, o, s, c, d, f, g;
2559
+ const i = Math.max(0, R(e.strokeWidth, 1));
2560
+ return {
2561
+ ...Te(e, {
2562
+ width: 560,
2563
+ height: 300,
2564
+ clip: !0
2565
+ }),
2566
+ chartRef: e.chartRef,
2567
+ xScaleId: e.xScaleId,
2568
+ yScaleId: e.yScaleId,
2569
+ xField: e.xField,
2570
+ yField: e.yField,
2571
+ seriesField: e.seriesField,
2572
+ labelField: e.labelField,
2573
+ radius: e.radius ?? 4,
2574
+ fill: e.fill,
2575
+ strokeColor: e.strokeColor,
2576
+ strokeWidth: i,
2577
+ opacity: Math.max(0, Math.min(1, R(e.opacity, 0.9))),
2578
+ colors: {
2579
+ palette: (r = (t = e.colors) == null ? void 0 : t.palette) != null && r.length ? [...e.colors.palette] : [
2580
+ "#2563eb",
2581
+ "#16a34a",
2582
+ "#f59e0b",
2583
+ "#dc2626",
2584
+ "#7c3aed",
2585
+ "#0891b2",
2586
+ "#db2777",
2587
+ "#475569"
2588
+ ],
2589
+ colorField: (n = e.colors) == null ? void 0 : n.colorField,
2590
+ fill: (a = e.colors) == null ? void 0 : a.fill
2591
+ },
2592
+ highlight: {
2593
+ enabled: ((o = e.highlight) == null ? void 0 : o.enabled) ?? !0,
2594
+ fill: ((s = e.highlight) == null ? void 0 : s.fill) ?? "#1d4ed8",
2595
+ strokeColor: ((c = e.highlight) == null ? void 0 : c.strokeColor) ?? "#1e40af",
2596
+ strokeWidth: Math.max(0, R((d = e.highlight) == null ? void 0 : d.strokeWidth, i)),
2597
+ opacity: Math.max(0, Math.min(1, R((f = e.highlight) == null ? void 0 : f.opacity, 1))),
2598
+ radiusDelta: R((g = e.highlight) == null ? void 0 : g.radiusDelta, 0)
2599
+ },
2600
+ hitRadiusPx: Math.max(0, R(e.hitRadiusPx, 12)),
2601
+ virtualization: Qe(e.virtualization),
2602
+ style: e.style,
2603
+ states: e.states ? { ...e.states } : void 0,
2604
+ parts: e.parts ? { ...e.parts } : void 0,
2605
+ renderers: e.renderers ? { ...e.renderers } : void 0,
2606
+ motion: e.motion
2607
+ };
2608
+ }
2609
+ function Cn(e) {
2610
+ var i, t, r, n, a, o, s, c, d, f;
2611
+ return {
2612
+ ...Te(e, {
2613
+ width: 560,
2614
+ height: 300,
2615
+ clip: !0
2616
+ }),
2617
+ chartRef: e.chartRef,
2618
+ xScaleId: e.xScaleId,
2619
+ yScaleId: e.yScaleId,
2620
+ xField: e.xField,
2621
+ yField: e.yField,
2622
+ seriesField: e.seriesField,
2623
+ labelField: e.labelField,
2624
+ curve: e.curve ?? "linear",
2625
+ baselineValue: R(e.baselineValue, 0),
2626
+ baselineField: e.baselineField,
2627
+ mode: e.mode ?? "single",
2628
+ fill: e.fill ?? "#bfdbfe",
2629
+ stroke: e.stroke ?? "#2563eb",
2630
+ strokeWidth: Math.max(0, R(e.strokeWidth, 2)),
2631
+ opacity: Math.max(0, Math.min(1, R(e.opacity, 0.32))),
2632
+ gradientTo: e.gradientTo,
2633
+ gradientSteps: Math.max(2, Math.min(24, Math.trunc(R(e.gradientSteps, 10)))),
2634
+ focusOnHover: e.focusOnHover ?? !1,
2635
+ colors: {
2636
+ palette: (t = (i = e.colors) == null ? void 0 : i.palette) != null && t.length ? [...e.colors.palette] : [
2637
+ "#2563eb",
2638
+ "#16a34a",
2639
+ "#f59e0b",
2640
+ "#dc2626",
2641
+ "#7c3aed",
2642
+ "#0891b2",
2643
+ "#db2777",
2644
+ "#475569"
2645
+ ],
2646
+ colorField: (r = e.colors) == null ? void 0 : r.colorField,
2647
+ fill: (n = e.colors) == null ? void 0 : n.fill,
2648
+ stroke: (a = e.colors) == null ? void 0 : a.stroke
2649
+ },
2650
+ markers: {
2651
+ visible: ((o = e.markers) == null ? void 0 : o.visible) ?? !1,
2652
+ radius: ((s = e.markers) == null ? void 0 : s.radius) ?? 3,
2653
+ fill: (c = e.markers) == null ? void 0 : c.fill,
2654
+ strokeColor: (d = e.markers) == null ? void 0 : d.strokeColor,
2655
+ strokeWidth: Math.max(0, R((f = e.markers) == null ? void 0 : f.strokeWidth, 1.5))
2656
+ },
2657
+ defined: e.defined,
2658
+ connectNulls: e.connectNulls ?? !1,
2659
+ hitRadiusPx: Math.max(0, R(e.hitRadiusPx, 12)),
2660
+ virtualization: Qe(e.virtualization),
2661
+ style: e.style,
2662
+ states: e.states ? { ...e.states } : void 0,
2663
+ parts: e.parts ? { ...e.parts } : void 0,
2664
+ renderers: e.renderers ? { ...e.renderers } : void 0,
2665
+ motion: e.motion
2666
+ };
2667
+ }
2668
+ function In(e) {
2669
+ var a, o, s, c, d, f, g, y, S, k;
2670
+ const i = e.radiusRange ?? [e.minRadius ?? 4, e.maxRadius ?? 18], t = Math.max(0, R(e.minRadius, i[0])), r = Math.max(t, R(e.maxRadius, i[1])), n = Math.max(0, R(e.strokeWidth, 1));
2671
+ return {
2672
+ ...Te(e, {
2673
+ width: 560,
2674
+ height: 300,
2675
+ clip: !0
2676
+ }),
2677
+ chartRef: e.chartRef,
2678
+ xScaleId: e.xScaleId,
2679
+ yScaleId: e.yScaleId,
2680
+ xField: e.xField,
2681
+ yField: e.yField,
2682
+ sizeField: e.sizeField,
2683
+ seriesField: e.seriesField,
2684
+ labelField: e.labelField,
2685
+ radiusRange: [t, r],
2686
+ sizeScale: e.sizeScale ?? "sqrt",
2687
+ minRadius: t,
2688
+ maxRadius: r,
2689
+ fill: e.fill,
2690
+ strokeColor: e.strokeColor,
2691
+ strokeWidth: n,
2692
+ opacity: Math.max(0, Math.min(1, R(e.opacity, 0.58))),
2693
+ colors: {
2694
+ palette: (o = (a = e.colors) == null ? void 0 : a.palette) != null && o.length ? [...e.colors.palette] : [
2695
+ "#0ea5e9",
2696
+ "#f97316",
2697
+ "#16a34a",
2698
+ "#7c3aed",
2699
+ "#dc2626",
2700
+ "#0891b2",
2701
+ "#db2777",
2702
+ "#475569"
2703
+ ],
2704
+ colorField: (s = e.colors) == null ? void 0 : s.colorField,
2705
+ fill: (c = e.colors) == null ? void 0 : c.fill
2706
+ },
2707
+ highlight: {
2708
+ enabled: ((d = e.highlight) == null ? void 0 : d.enabled) ?? !0,
2709
+ fill: ((f = e.highlight) == null ? void 0 : f.fill) ?? "#0284c7",
2710
+ strokeColor: ((g = e.highlight) == null ? void 0 : g.strokeColor) ?? "#0f172a",
2711
+ strokeWidth: Math.max(0, R((y = e.highlight) == null ? void 0 : y.strokeWidth, n)),
2712
+ opacity: Math.max(0, Math.min(1, R((S = e.highlight) == null ? void 0 : S.opacity, 0.82))),
2713
+ radiusDelta: R((k = e.highlight) == null ? void 0 : k.radiusDelta, 0)
2714
+ },
2715
+ hitRadiusPx: Math.max(0, R(e.hitRadiusPx, 8)),
2716
+ virtualization: Qe(e.virtualization),
2717
+ style: e.style,
2718
+ states: e.states ? { ...e.states } : void 0,
2719
+ parts: e.parts ? { ...e.parts } : void 0,
2720
+ renderers: e.renderers ? { ...e.renderers } : void 0,
2721
+ motion: e.motion
2722
+ };
2723
+ }
2724
+ function Qe(e) {
2725
+ return {
2726
+ enabled: (e == null ? void 0 : e.enabled) ?? qe.enabled,
2727
+ overscanPx: R(e == null ? void 0 : e.overscanPx, qe.overscanPx),
2728
+ maxRenderedPoints: Math.max(2, Math.trunc(R(
2729
+ e == null ? void 0 : e.maxRenderedPoints,
2730
+ qe.maxRenderedPoints
2731
+ ))),
2732
+ sampling: (e == null ? void 0 : e.sampling) === "lttb" ? "lttb" : "stride"
2733
+ };
2734
+ }
2735
+ function Ar(e) {
2736
+ return e === !1 ? !1 : {
2737
+ label: e == null ? void 0 : e.label,
2738
+ description: e == null ? void 0 : e.description,
2739
+ dataSummary: e == null ? void 0 : e.dataSummary,
2740
+ includeVisibleMarks: (e == null ? void 0 : e.includeVisibleMarks) ?? !1,
2741
+ maxMarks: Math.max(0, Math.trunc(R(e == null ? void 0 : e.maxMarks, 80))),
2742
+ keyboardNavigation: (e == null ? void 0 : e.keyboardNavigation) ?? !0,
2743
+ exposeTooltip: (e == null ? void 0 : e.exposeTooltip) ?? !0,
2744
+ exposeLegend: (e == null ? void 0 : e.exposeLegend) ?? !0
2745
+ };
2746
+ }
2747
+ const $r = "NovaCharts.Root";
2748
+ function Lr(e) {
2749
+ return {
2750
+ type: $r,
2751
+ name: "NovaCharts.Root",
2752
+ title: "NovaCharts.Root",
2753
+ version: "0.2.0",
2754
+ kind: "node-component",
2755
+ dirtyPolicy: zr,
2756
+ fields: {
2757
+ ...Pr,
2758
+ data: { type: "array" },
2759
+ keyField: { type: "field" },
2760
+ refScope: { type: "record" }
2761
+ },
2762
+ normalize: (t) => Ze(t.props),
2763
+ measureBounds: (t, r) => Qt(r, Ze)
2764
+ };
2765
+ }
2766
+ const Vr = Lr();
2767
+ class Or extends ei {
2768
+ /**
2769
+ * Создает экземпляр ChartRoot и подготавливает базовое состояние.
2770
+ */
2771
+ constructor(t, r, n, a = {}, o = Vr) {
2772
+ super(t, r, o, n, { componentId: a.componentId });
2773
+ C(this, "_dataStore");
2774
+ C(this, "_scales", new Ii());
2775
+ C(this, "_managedChildren", []);
2776
+ C(this, "_scaleRegistrations", /* @__PURE__ */ new Map());
2777
+ C(this, "_scaleSourceDomains", /* @__PURE__ */ new Map());
2778
+ C(this, "_viewportDomains", /* @__PURE__ */ new Map());
2779
+ C(this, "_scaleDomainContributions", /* @__PURE__ */ new Map());
2780
+ C(this, "_seriesDiagnostics", /* @__PURE__ */ new Map());
2781
+ C(this, "_seriesMetadata", /* @__PURE__ */ new Map());
2782
+ C(this, "_interactiveSeries", /* @__PURE__ */ new Map());
2783
+ C(this, "_listeners", /* @__PURE__ */ new Set());
2784
+ C(this, "_interactionListeners", /* @__PURE__ */ new Set());
2785
+ C(this, "_customization");
2786
+ C(this, "_api");
2787
+ C(this, "_runtime");
2788
+ C(this, "_interactionState", {
2789
+ pointer: null,
2790
+ hovered: null,
2791
+ tooltipVisible: !1,
2792
+ revision: 0
2793
+ });
2794
+ C(this, "_lastEvent", "init");
2795
+ C(this, "_disposeListeners", /* @__PURE__ */ new Set());
2796
+ this._dataStore = new Ci({
2797
+ data: n.data,
2798
+ keyField: n.keyField
2799
+ }), this._customization = new pi(n, {
2800
+ id: this.componentId,
2801
+ getData: () => this._dataStore.getData(),
2802
+ getScale: (s) => this._getScale(s),
2803
+ getSeriesMetadata: () => this._getSeriesMetadata(),
2804
+ getInteractionState: () => this._getInteractionState()
2805
+ }), this._api = {
2806
+ setData: (s) => this.setData(s),
2807
+ getData: () => this._dataStore.getData(),
2808
+ updateRows: (s) => this.updateRows(s),
2809
+ removeRows: (s) => this.removeRows(s),
2810
+ getScale: (s) => this._getScale(s),
2811
+ requireScale: (s) => this._requireScale(s),
2812
+ setScaleDomain: (s, c) => this._setScaleDomain(s, c),
2813
+ setScaleRange: (s, c) => this._setScaleRange(s, c),
2814
+ getScaleSourceDomain: (s) => this._getScaleSourceDomain(s),
2815
+ setScaleDomainContribution: (s) => this._setScaleDomainContribution(s),
2816
+ removeScaleDomainContribution: (s) => this._removeScaleDomainContribution(s),
2817
+ getScaleDomainContributions: (s) => this._getScaleDomainContributions(s),
2818
+ refresh: () => this._refresh("api.refresh"),
2819
+ getDiagnostics: () => this._getDiagnostics(),
2820
+ getInteractionState: () => this._getInteractionState(),
2821
+ setInteractionState: (s) => this._setInteractionState(s),
2822
+ setChildren: (s) => this.setChildren(s),
2823
+ exportChart: (s) => this._exportChart(s),
2824
+ getSemanticSnapshot: (s) => this._getSemanticSnapshot(s),
2825
+ subscribe: (s) => this._subscribe(s),
2826
+ subscribeInteraction: (s) => this._subscribeInteraction(s)
2827
+ }, this._runtime = {
2828
+ id: this.componentId,
2829
+ props: this.props,
2830
+ dataStore: this._dataStore,
2831
+ scales: this._scales,
2832
+ customization: this._customization,
2833
+ refScope: this.props.refScope,
2834
+ registerScale: (s) => this._registerScale(s),
2835
+ unregisterScale: (s) => this._unregisterScale(s),
2836
+ refreshScale: (s) => this._refreshScale(s),
2837
+ refreshScales: () => this._refreshScales(),
2838
+ getScale: (s) => this._getScale(s),
2839
+ requireScale: (s) => this._requireScale(s),
2840
+ setScaleDomain: (s, c) => this._setScaleDomain(s, c),
2841
+ setScaleRange: (s, c) => this._setScaleRange(s, c),
2842
+ getScaleSourceDomain: (s) => this._getScaleSourceDomain(s),
2843
+ setScaleDomainContribution: (s) => this._setScaleDomainContribution(s),
2844
+ removeScaleDomainContribution: (s) => this._removeScaleDomainContribution(s),
2845
+ getScaleDomainContributions: (s) => this._getScaleDomainContributions(s),
2846
+ setChildren: (s) => this.setChildren(s),
2847
+ refresh: (s) => this._refresh(s),
2848
+ registerInteractiveSeries: (s) => this._registerInteractiveSeries(s),
2849
+ unregisterInteractiveSeries: (s) => this._unregisterInteractiveSeries(s),
2850
+ getInteractiveSeries: () => this._getInteractiveSeries(),
2851
+ getInteractionState: () => this._getInteractionState(),
2852
+ setInteractionState: (s) => this._setInteractionState(s),
2853
+ subscribeInteraction: (s) => this._subscribeInteraction(s),
2854
+ setSeriesDiagnostics: (s, c) => this._setSeriesDiagnostics(s, c),
2855
+ removeSeriesDiagnostics: (s) => this._removeSeriesDiagnostics(s),
2856
+ setSeriesMetadata: (s, c) => this._setSeriesMetadata(s, c),
2857
+ removeSeriesMetadata: (s) => this._removeSeriesMetadata(s),
2858
+ getSeriesMetadata: () => this._getSeriesMetadata(),
2859
+ publishSemanticRegions: (s, c) => this._publishSemanticRegions(s, c),
2860
+ clearSemanticRegions: (s) => this._clearSemanticRegions(s),
2861
+ getDiagnostics: () => this._getDiagnostics(),
2862
+ subscribe: (s) => this._subscribe(s),
2863
+ getApi: () => this._api
2864
+ }, this.provide(si, this._runtime), this.setChildren(a.children ?? []);
2865
+ }
2866
+ /** Подписывает владельца handle на уничтожение корня общим NovaApp. */
2867
+ onDispose(t) {
2868
+ return this._disposeListeners.add(t), () => {
2869
+ this._disposeListeners.delete(t);
2870
+ };
2871
+ }
2872
+ dispose() {
2873
+ if (this.disposed)
2874
+ return;
2875
+ const t = [];
2876
+ try {
2877
+ super.dispose();
2878
+ } catch (n) {
2879
+ t.push(n);
2880
+ }
2881
+ const r = [...this._disposeListeners];
2882
+ this._disposeListeners.clear();
2883
+ for (const n of r)
2884
+ try {
2885
+ n();
2886
+ } catch (a) {
2887
+ t.push(a);
2888
+ }
2889
+ if (t.length === 1)
2890
+ throw t[0];
2891
+ if (t.length)
2892
+ throw new AggregateError(t, "[NovaCharts] Root cleanup failed");
2893
+ }
2894
+ /**
2895
+ * Обновляет значение состояния ChartRoot.
2896
+ */
2897
+ setProps(t) {
2898
+ return super.setProps(t);
2899
+ }
2900
+ /**
2901
+ * Возвращает значение состояния ChartRoot.
2902
+ */
2903
+ getApi() {
2904
+ return this._api;
2905
+ }
2906
+ /**
2907
+ * Возвращает значение состояния ChartRoot.
2908
+ */
2909
+ getNovaChartRuntime() {
2910
+ return this._runtime;
2911
+ }
2912
+ /**
2913
+ * Применяет подготовленное состояние ChartRoot.
2914
+ */
2915
+ applyLayoutRect(t) {
2916
+ const r = super.applyLayoutRect(t);
2917
+ return r && this._applyChildrenRect(), r;
2918
+ }
2919
+ /**
2920
+ * Обновляет runtime-состояние ChartRoot.
2921
+ */
2922
+ update() {
2923
+ this._applyChildrenRect();
2924
+ }
2925
+ /**
2926
+ * Выполняет отрисовку ChartRoot.
2927
+ */
2928
+ render() {
2929
+ const t = ti(this.props, this.width, this.height);
2930
+ t.length > 0 && this.renderer.schema(t), this.props.clip && this.renderer.clip(0, 0, this.width, this.height), this._syncRootSemantics();
2931
+ }
2932
+ /**
2933
+ * Обновляет значение состояния ChartRoot.
2934
+ */
2935
+ setChildren(t) {
2936
+ const r = Yt(this, this._managedChildren, t, this.props.refScope);
2937
+ this._managedChildren.length = 0, this._managedChildren.push(...r.nodes), this._applyChildrenRect(), this._refresh("children");
2938
+ }
2939
+ /**
2940
+ * Обновляет значение состояния ChartRoot.
2941
+ */
2942
+ setData(t) {
2943
+ this._dataStore.setData(t, this.props.keyField), this._refreshScales(), this._refresh("setData");
2944
+ }
2945
+ /**
2946
+ * Обновляет runtime-состояние ChartRoot.
2947
+ */
2948
+ updateRows(t) {
2949
+ this._dataStore.updateRows(t), this._refreshScales(), this._refresh("updateRows");
2950
+ }
2951
+ /**
2952
+ * Удаляет сущность из runtime-коллекции ChartRoot.
2953
+ */
2954
+ removeRows(t) {
2955
+ this._dataStore.removeRows(t), this._refreshScales(), this._refresh("removeRows");
2956
+ }
2957
+ /**
2958
+ * Регистрирует сущность в runtime-слое ChartRoot.
2959
+ */
2960
+ _registerScale(t) {
2961
+ this._scaleRegistrations.set(t.id, t);
2962
+ const r = this._resolveScaleSourceDomain(t);
2963
+ t.scale.setDomain(r);
2964
+ const n = this._viewportDomains.get(t.id);
2965
+ n && t.scale.setDomain(n), this._scaleSourceDomains.set(t.id, [...r]), this._scales.register(t.scale), this._refresh("scale.register");
2966
+ }
2967
+ /**
2968
+ * Удаляет регистрацию сущности из runtime-слоя ChartRoot.
2969
+ */
2970
+ _unregisterScale(t) {
2971
+ this._scaleRegistrations.delete(t), this._scales.unregister(t), this._scaleSourceDomains.delete(t), this._viewportDomains.delete(t);
2972
+ for (const r of this._getScaleDomainContributions(t))
2973
+ this._scaleDomainContributions.delete(r.id);
2974
+ this._refresh("scale.unregister");
2975
+ }
2976
+ /**
2977
+ * Синхронизирует актуальное состояние ChartRoot.
2978
+ */
2979
+ _refreshScale(t) {
2980
+ const r = this._scaleRegistrations.get(t);
2981
+ if (!r)
2982
+ return;
2983
+ const n = this._resolveScaleSourceDomain(r), a = this._scales.setDomain(t, this._viewportDomains.get(t) ?? n);
2984
+ this._scaleSourceDomains.set(t, [...n]), this._scales.register(r.scale), a && this._refresh("scale.refresh", t);
2985
+ }
2986
+ /**
2987
+ * Синхронизирует актуальное состояние ChartRoot.
2988
+ */
2989
+ _refreshScales() {
2990
+ for (const t of this._scaleRegistrations.keys())
2991
+ this._refreshScale(t);
2992
+ }
2993
+ /**
2994
+ * Возвращает значение состояния ChartRoot.
2995
+ */
2996
+ _getScale(t) {
2997
+ return this._scales.get(t);
2998
+ }
2999
+ /**
3000
+ * Выполняет внутренний шаг requireScale для ChartRoot.
3001
+ */
3002
+ _requireScale(t) {
3003
+ return this._scales.require(t);
3004
+ }
3005
+ /**
3006
+ * Обновляет значение состояния ChartRoot.
3007
+ */
3008
+ _setScaleDomain(t, r) {
3009
+ this._viewportDomains.set(t, [...r]), this._scales.setDomain(t, r) && this._refresh("scale.domain", t);
3010
+ }
3011
+ /**
3012
+ * Обновляет значение состояния ChartRoot.
3013
+ */
3014
+ _setScaleRange(t, r) {
3015
+ this._scales.setRange(t, r) && this._refresh("scale.range", t);
3016
+ }
3017
+ /**
3018
+ * Возвращает исходный домен шкалы до viewport-среза.
3019
+ */
3020
+ _getScaleSourceDomain(t) {
3021
+ const r = this._scaleSourceDomains.get(t);
3022
+ return r ? [...r] : void 0;
3023
+ }
3024
+ /**
3025
+ * Публикует вклад series в source domain общей шкалы.
3026
+ */
3027
+ _setScaleDomainContribution(t) {
3028
+ const r = pt(t), n = this._scaleDomainContributions.get(r.id);
3029
+ n && n.scaleId === r.scaleId && wt(n.domain) === wt(r.domain) || (this._scaleDomainContributions.set(r.id, r), this._refreshScale(r.scaleId));
3030
+ }
3031
+ /**
3032
+ * Удаляет вклад series из source domain шкалы.
3033
+ */
3034
+ _removeScaleDomainContribution(t) {
3035
+ const r = this._scaleDomainContributions.get(t);
3036
+ r && (this._scaleDomainContributions.delete(t), this._refreshScale(r.scaleId));
3037
+ }
3038
+ /**
3039
+ * Возвращает contributions для scale-first mixed charts.
3040
+ */
3041
+ _getScaleDomainContributions(t) {
3042
+ return Array.from(this._scaleDomainContributions.values()).filter((r) => t === void 0 || r.scaleId === t).map(pt);
3043
+ }
3044
+ _exportChart(t = {}) {
3045
+ return this.nova.exportImage({
3046
+ ...t,
3047
+ includeSemanticSnapshot: t.includeSemanticSnapshot ?? !0
3048
+ });
3049
+ }
3050
+ _getSemanticSnapshot(t = {}) {
3051
+ return this.nova.semantics.snapshot({
3052
+ scope: this.componentId,
3053
+ ...t
3054
+ });
3055
+ }
3056
+ /**
3057
+ * Обновляет значение состояния ChartRoot.
3058
+ */
3059
+ _setSeriesDiagnostics(t, r) {
3060
+ this._seriesDiagnostics.set(t, r);
3061
+ }
3062
+ /**
3063
+ * Удаляет diagnostics series из runtime.
3064
+ */
3065
+ _removeSeriesDiagnostics(t) {
3066
+ this._seriesDiagnostics.delete(t);
3067
+ }
3068
+ /**
3069
+ * Обновляет metadata серий для legend и high-level chart shell.
3070
+ */
3071
+ _setSeriesMetadata(t, r) {
3072
+ this._seriesMetadata.set(t, r.map((n) => ({ ...n }))), this._syncRootSemantics();
3073
+ }
3074
+ /**
3075
+ * Удаляет metadata series из runtime.
3076
+ */
3077
+ _removeSeriesMetadata(t) {
3078
+ this._seriesMetadata.delete(t), this._syncRootSemantics();
3079
+ }
3080
+ /**
3081
+ * Возвращает metadata всех зарегистрированных серий.
3082
+ */
3083
+ _getSeriesMetadata() {
3084
+ return Array.from(this._seriesMetadata.values()).flat().map((t) => ({ ...t }));
3085
+ }
3086
+ /**
3087
+ * Регистрирует сущность в runtime-слое ChartRoot.
3088
+ */
3089
+ _registerInteractiveSeries(t) {
3090
+ this._interactiveSeries.set(t.id, t);
3091
+ }
3092
+ /**
3093
+ * Удаляет регистрацию сущности из runtime-слоя ChartRoot.
3094
+ */
3095
+ _unregisterInteractiveSeries(t) {
3096
+ var r;
3097
+ this._interactiveSeries.delete(t), ((r = this._interactionState.hovered) == null ? void 0 : r.seriesId) === t && this._setInteractionState({ hovered: null, tooltipVisible: !1 });
3098
+ }
3099
+ /**
3100
+ * Возвращает значение состояния ChartRoot.
3101
+ */
3102
+ _getInteractiveSeries() {
3103
+ return [...this._interactiveSeries.values()];
3104
+ }
3105
+ /**
3106
+ * Возвращает значение состояния ChartRoot.
3107
+ */
3108
+ _getInteractionState() {
3109
+ return {
3110
+ ...this._interactionState,
3111
+ pointer: this._interactionState.pointer ? { ...this._interactionState.pointer } : null,
3112
+ hovered: this._interactionState.hovered ? {
3113
+ ...this._interactionState.hovered,
3114
+ bounds: this._interactionState.hovered.bounds ? { ...this._interactionState.hovered.bounds } : void 0,
3115
+ point: this._interactionState.hovered.point ? { ...this._interactionState.hovered.point } : void 0
3116
+ } : null
3117
+ };
3118
+ }
3119
+ /**
3120
+ * Обновляет значение состояния ChartRoot.
3121
+ */
3122
+ _setInteractionState(t) {
3123
+ var f, g, y, S, k, x, m, N, E, q, L;
3124
+ const r = (f = this._interactionState.hovered) == null ? void 0 : f.key, n = (g = this._interactionState.hovered) == null ? void 0 : g.seriesId, a = {
3125
+ ...this._interactionState,
3126
+ ...t,
3127
+ revision: this._interactionState.revision + 1
3128
+ }, o = (y = a.hovered) == null ? void 0 : y.key, s = (S = a.hovered) == null ? void 0 : S.seriesId;
3129
+ if (!(r !== o || n !== s || ((k = this._interactionState.pointer) == null ? void 0 : k.plotX) !== ((x = a.pointer) == null ? void 0 : x.plotX) || ((m = this._interactionState.pointer) == null ? void 0 : m.plotY) !== ((N = a.pointer) == null ? void 0 : N.plotY) || this._interactionState.tooltipVisible !== a.tooltipVisible))
3130
+ return;
3131
+ this._interactionState = a;
3132
+ const d = r !== o || n !== s;
3133
+ d && n && n !== s && ((E = this._interactiveSeries.get(n)) == null || E.requestRender()), d && s ? (q = this._interactiveSeries.get(s)) == null || q.requestRender() : d && n && ((L = this._interactiveSeries.get(n)) == null || L.requestRender());
3134
+ for (const D of this._interactionListeners)
3135
+ D(this._getInteractionState());
3136
+ this._customization.notifyInteraction(this._getInteractionState()), this._syncRootSemantics();
3137
+ }
3138
+ _publishSemanticRegions(t, r) {
3139
+ const n = this._semanticSourceKey(t);
3140
+ if (this.props.accessibility === !1) {
3141
+ this.nova.semantics.clearSource(n);
3142
+ return;
3143
+ }
3144
+ this.nova.semantics.syncSource(n, r.map((a) => ({
3145
+ ...a,
3146
+ scope: a.scope ?? this.componentId
3147
+ })));
3148
+ }
3149
+ _clearSemanticRegions(t) {
3150
+ this.nova.semantics.clearSource(this._semanticSourceKey(t));
3151
+ }
3152
+ _syncRootSemantics() {
3153
+ var c;
3154
+ const t = this.props.accessibility;
3155
+ if (t === !1) {
3156
+ this.nova.semantics.clearScope(this.componentId);
3157
+ return;
3158
+ }
3159
+ const r = this._dataStore.getData(), n = typeof t.dataSummary == "function" ? t.dataSummary(r) : t.dataSummary, a = [
3160
+ {
3161
+ id: `${this.componentId}:chart`,
3162
+ role: "chart",
3163
+ label: t.label ?? "Nova chart",
3164
+ description: t.description,
3165
+ scope: this.componentId,
3166
+ bounds: this.getWorldBounds(),
3167
+ focusable: t.keyboardNavigation,
3168
+ order: 0,
3169
+ data: {
3170
+ rowCount: this._dataStore.rowCount,
3171
+ scaleCount: this._scales.list().length,
3172
+ seriesCount: this._getSeriesMetadata().length,
3173
+ summary: n
3174
+ },
3175
+ source: {
3176
+ type: "synthetic",
3177
+ componentId: this.componentId,
3178
+ part: "root"
3179
+ }
3180
+ }
3181
+ ];
3182
+ let o = 20;
3183
+ for (const d of this._scaleRegistrations.values())
3184
+ a.push({
3185
+ id: `${this.componentId}:scale:${d.id}`,
3186
+ role: "axis",
3187
+ label: `${d.id} scale`,
3188
+ scope: this.componentId,
3189
+ focusable: !1,
3190
+ order: o++,
3191
+ data: {
3192
+ scaleId: d.id,
3193
+ scaleType: d.props.scaleType,
3194
+ sourceDomain: this._getScaleSourceDomain(d.id),
3195
+ visibleDomain: (c = this._getScale(d.id)) == null ? void 0 : c.getDomain()
3196
+ },
3197
+ source: {
3198
+ type: "synthetic",
3199
+ componentId: this.componentId,
3200
+ part: "axis"
3201
+ }
3202
+ });
3203
+ o = 100;
3204
+ for (const d of this._getSeriesMetadata())
3205
+ a.push({
3206
+ id: `${this.componentId}:series:${d.sourceSeriesId ?? d.id}`,
3207
+ role: "series",
3208
+ label: d.label ?? d.id,
3209
+ scope: this.componentId,
3210
+ focusable: t.keyboardNavigation,
3211
+ order: o++,
3212
+ state: {
3213
+ hidden: d.visible === !1
3214
+ },
3215
+ data: {
3216
+ id: d.id,
3217
+ kind: d.kind,
3218
+ color: d.color,
3219
+ scaleIds: d.scaleIds
3220
+ },
3221
+ source: {
3222
+ type: "synthetic",
3223
+ componentId: this.componentId,
3224
+ part: "series"
3225
+ }
3226
+ });
3227
+ const s = this._interactionState.hovered;
3228
+ t.includeVisibleMarks && s && a.push({
3229
+ id: `${this.componentId}:hovered:${s.seriesId}:${s.key}`,
3230
+ role: "mark",
3231
+ label: Br(s),
3232
+ scope: this.componentId,
3233
+ bounds: s.bounds ?? jr(s.point),
3234
+ focusable: t.keyboardNavigation,
3235
+ order: 900,
3236
+ state: {
3237
+ hovered: !0
3238
+ },
3239
+ data: Kr(s),
3240
+ source: {
3241
+ type: "synthetic",
3242
+ componentId: this.componentId,
3243
+ part: "mark"
3244
+ }
3245
+ }), this.nova.semantics.syncSource(this._semanticSourceKey("root"), a);
3246
+ }
3247
+ _semanticSourceKey(t) {
3248
+ return `${this.componentId}:semantic:${t}`;
3249
+ }
3250
+ /**
3251
+ * Подписывает обработчик на изменения ChartRoot.
3252
+ */
3253
+ _subscribe(t) {
3254
+ return this._listeners.add(t), () => {
3255
+ this._listeners.delete(t);
3256
+ };
3257
+ }
3258
+ /**
3259
+ * Подписывает обработчик на изменения ChartRoot.
3260
+ */
3261
+ _subscribeInteraction(t) {
3262
+ return this._interactionListeners.add(t), () => {
3263
+ this._interactionListeners.delete(t);
3264
+ };
3265
+ }
3266
+ /**
3267
+ * Возвращает значение состояния ChartRoot.
3268
+ */
3269
+ _getDiagnostics() {
3270
+ return {
3271
+ rowCount: this._dataStore.rowCount,
3272
+ scaleCount: this._scales.list().length,
3273
+ componentCount: this._managedChildren.length,
3274
+ dataRevision: this._dataStore.revision,
3275
+ scalesRevision: this._scaleRegistrations.size,
3276
+ lastEvent: this._lastEvent,
3277
+ series: Object.fromEntries(this._seriesDiagnostics)
3278
+ };
3279
+ }
3280
+ /**
3281
+ * Собирает полный source domain шкалы из base domain и contributions.
3282
+ */
3283
+ _resolveScaleSourceDomain(t) {
3284
+ const r = At(t.props, this._dataStore);
3285
+ if (t.props.domain)
3286
+ return [...r];
3287
+ const n = this._getScaleDomainContributions(t.id).map((o) => o.domain);
3288
+ if (n.length === 0)
3289
+ return [...r];
3290
+ if (t.props.scaleType === "band")
3291
+ return Wr(r, n);
3292
+ const a = t.props.field ? [r, ...n] : n;
3293
+ return Gr(a, t.props.zero, t.props.nice);
3294
+ }
3295
+ /**
3296
+ * Синхронизирует актуальное состояние ChartRoot.
3297
+ */
3298
+ _refresh(t = "refresh", r) {
3299
+ if (this._lastEvent = t, this.runtime.batch(() => {
3300
+ this._pulseChildren(r), r || this.invalidate({ update: !0, render: !0 });
3301
+ }), this._listeners.size) {
3302
+ const n = this._getDiagnostics();
3303
+ for (const a of this._listeners)
3304
+ a(n);
3305
+ }
3306
+ }
3307
+ /**
3308
+ * Применяет подготовленное состояние ChartRoot.
3309
+ */
3310
+ _applyChildrenRect() {
3311
+ const t = {
3312
+ x: 0,
3313
+ y: 0,
3314
+ width: this.width,
3315
+ height: this.height
3316
+ };
3317
+ for (const r of this._managedChildren)
3318
+ Ur(r, t);
3319
+ }
3320
+ /**
3321
+ * Активирует фазы внутреннего subtree ChartRoot.
3322
+ */
3323
+ _pulseChildren(t) {
3324
+ for (const r of this._managedChildren)
3325
+ qr(r, t);
3326
+ }
3327
+ /**
3328
+ * Обрабатывает входящее событие ChartRoot.
3329
+ */
3330
+ onPropsChanged(t) {
3331
+ this.applyCommonPropsChanged(t), (t.includes("data") || t.includes("keyField")) && (this._dataStore.setData(this.props.data, this.props.keyField), this._refreshScales(), this._refresh("props.data")), t.includes("refScope") && (this._runtime.refScope = this.props.refScope), (t.includes("styleSheet") || t.includes("visualPreset") || t.includes("plugins")) && (this._customization.configure(this.props, {
3332
+ id: this.componentId,
3333
+ getData: () => this._dataStore.getData(),
3334
+ getScale: (r) => this._getScale(r),
3335
+ getSeriesMetadata: () => this._getSeriesMetadata(),
3336
+ getInteractionState: () => this._getInteractionState()
3337
+ }), this._refresh("props.customization")), t.includes("accessibility") && this._syncRootSemantics();
3338
+ }
3339
+ onUnmount() {
3340
+ this.nova.semantics.clearScope(this.componentId), this._customization.dispose(), super.onUnmount();
3341
+ }
3342
+ }
3343
+ function Br(e) {
3344
+ if (!e)
3345
+ return "Chart mark";
3346
+ const i = e.seriesLabel ?? e.seriesKey ?? e.seriesId, t = e.label ?? e.category ?? e.xValue, r = e.yValue ?? e.value;
3347
+ return `${i}: ${t ?? e.key} ${r ?? ""}`.trim();
3348
+ }
3349
+ function jr(e) {
3350
+ if (!(!e || !Number.isFinite(e.x) || !Number.isFinite(e.y)))
3351
+ return {
3352
+ x: e.x - 6,
3353
+ y: e.y - 6,
3354
+ width: 12,
3355
+ height: 12
3356
+ };
3357
+ }
3358
+ function Kr(e) {
3359
+ return {
3360
+ seriesId: e.seriesId,
3361
+ seriesKind: e.seriesKind,
3362
+ key: e.key,
3363
+ value: e.value,
3364
+ rawValue: e.rawValue,
3365
+ category: e.category,
3366
+ xValue: e.xValue,
3367
+ yValue: e.yValue,
3368
+ seriesKey: e.seriesKey,
3369
+ seriesLabel: e.seriesLabel,
3370
+ color: e.color
3371
+ };
3372
+ }
3373
+ function Ur(e, i) {
3374
+ typeof e.applyLayoutRect == "function" && e.applyLayoutRect(i);
3375
+ }
3376
+ function qr(e, i) {
3377
+ e.disposed || e.runtime.disposed || e.traverseAll((t) => {
3378
+ if (!(t.disposed || t.runtime.disposed)) {
3379
+ if (i) {
3380
+ const r = t.props;
3381
+ if (r && !["scaleId", "xScaleId", "yScaleId"].some((n) => r[n] === i) && !["xScaleIds", "yScaleIds"].some((n) => Array.isArray(r[n]) && r[n].includes(i)))
3382
+ return;
3383
+ }
3384
+ t.invalidate({ update: !0, render: !0 });
3385
+ }
3386
+ });
3387
+ }
3388
+ function pt(e) {
3389
+ return {
3390
+ ...e,
3391
+ domain: [...e.domain]
3392
+ };
3393
+ }
3394
+ function Wr(e, i) {
3395
+ const t = /* @__PURE__ */ new Set(), r = [];
3396
+ for (const n of [e, ...i])
3397
+ for (const a of n) {
3398
+ const o = String(a);
3399
+ t.has(o) || (t.add(o), r.push(o));
3400
+ }
3401
+ return r;
3402
+ }
3403
+ function Gr(e, i, t) {
3404
+ let r = Number.POSITIVE_INFINITY, n = Number.NEGATIVE_INFINITY;
3405
+ for (const a of e) {
3406
+ if (a.length < 2)
3407
+ continue;
3408
+ const o = Number(a[0]), s = Number(a[a.length - 1]);
3409
+ !Number.isFinite(o) || !Number.isFinite(s) || (r = Math.min(r, o, s), n = Math.max(n, o, s));
3410
+ }
3411
+ if ((r === Number.POSITIVE_INFINITY || n === Number.NEGATIVE_INFINITY) && (r = 0, n = 1), i && (r = Math.min(0, r), n = Math.max(0, n)), t) {
3412
+ const a = Hr(r, n);
3413
+ r = a[0], n = a[1];
3414
+ }
3415
+ return r === n && (r -= 1, n += 1), [r, n];
3416
+ }
3417
+ function Hr(e, i) {
3418
+ if (!Number.isFinite(e) || !Number.isFinite(i))
3419
+ return [0, 1];
3420
+ const t = Math.abs(i - e);
3421
+ if (t === 0)
3422
+ return [Math.floor(e), Math.ceil(i + 1)];
3423
+ const n = 10 ** Math.floor(Math.log10(t)) / 2;
3424
+ return [
3425
+ Math.floor(e / n) * n,
3426
+ Math.ceil(i / n) * n
3427
+ ];
3428
+ }
3429
+ function wt(e) {
3430
+ return e.map((i) => String(i)).join("");
3431
+ }
3432
+ function Ot(e) {
3433
+ if ((e == null ? void 0 : e.size) !== void 0 && (!Number.isFinite(e.size) || e.size <= 0))
3434
+ throw new RangeError("[NovaCharts] Font size must be finite and positive");
3435
+ if ((e == null ? void 0 : e.family) !== void 0 && (typeof e.family != "string" || !e.family.trim()))
3436
+ throw new TypeError("[NovaCharts] Font family must be a nonempty string");
3437
+ if ((e == null ? void 0 : e.weight) !== void 0 && !["normal", "bold", "100", "200", "300", "400", "500", "600", "700", "800", "900"].includes(e.weight))
3438
+ throw new TypeError("[NovaCharts] Invalid font weight");
3439
+ }
3440
+ class Yr {
3441
+ constructor() {
3442
+ C(this, "_listeners", /* @__PURE__ */ new Map());
3443
+ C(this, "_queued", /* @__PURE__ */ new Map());
3444
+ C(this, "_depth", 0);
3445
+ }
3446
+ get size() {
3447
+ let i = 0;
3448
+ for (const t of this._listeners.values())
3449
+ i += t.size;
3450
+ return i;
3451
+ }
3452
+ has(i) {
3453
+ var t;
3454
+ return (((t = this._listeners.get(i)) == null ? void 0 : t.size) ?? 0) > 0;
3455
+ }
3456
+ on(i, t) {
3457
+ let r = this._listeners.get(i);
3458
+ r || (r = /* @__PURE__ */ new Set(), this._listeners.set(i, r));
3459
+ const n = t;
3460
+ return r.add(n), () => {
3461
+ r == null || r.delete(n), r != null && r.size || this._listeners.delete(i);
3462
+ };
3463
+ }
3464
+ emit(i, t) {
3465
+ if (this._depth) {
3466
+ const n = this._queued.get(i);
3467
+ this._queued.set(i, { ...t, previous: n ? n.previous : t.previous });
3468
+ return;
3469
+ }
3470
+ const r = [];
3471
+ for (const n of [...this._listeners.get(i) ?? []])
3472
+ try {
3473
+ n(t);
3474
+ } catch (a) {
3475
+ r.push(a);
3476
+ }
3477
+ if (r.length)
3478
+ throw new AggregateError(r, `[NovaCharts] Event listener failed: ${i}`);
3479
+ }
3480
+ batch(i) {
3481
+ this._depth++;
3482
+ let t;
3483
+ const r = [];
3484
+ try {
3485
+ t = i();
3486
+ } catch (n) {
3487
+ r.push(n);
3488
+ }
3489
+ if (this._depth--, !this._depth) {
3490
+ const n = [...this._queued];
3491
+ this._queued.clear();
3492
+ for (const [a, o] of n)
3493
+ try {
3494
+ this.emit(a, o);
3495
+ } catch (s) {
3496
+ r.push(s);
3497
+ }
3498
+ }
3499
+ if (r.length === 1)
3500
+ throw r[0];
3501
+ if (r.length)
3502
+ throw new AggregateError(r, "[NovaCharts] Batch and event listeners failed");
3503
+ return t;
3504
+ }
3505
+ dispose() {
3506
+ this._listeners.clear(), this._queued.clear();
3507
+ }
3508
+ }
3509
+ function He(e, i) {
3510
+ const t = e.surface.renderPolicy.cache === "texture", r = t ? e.nova.createSurface(`${e.componentId}:overlay`) : e.surface;
3511
+ t && r.options({ zIndex: e.surface.weight + 100 });
3512
+ class n extends Xt {
3513
+ render() {
3514
+ e.visible && (t && (this.renderer.setTransform(e.matrix), this.renderer.clip(0, 0, e.width, e.height)), this.renderer.schema(i()));
3515
+ }
3516
+ }
3517
+ const a = new n(e.nova, r);
3518
+ a.options({ zIndex: 100, width: e.width, height: e.height, interactive: !1 }), (t ? r : e).addChild(a);
3519
+ let o = !1;
3520
+ const s = () => {
3521
+ o || ((a.width !== e.width || a.height !== e.height) && a.options({ width: e.width, height: e.height }), a.invalidate({ render: !0 }));
3522
+ }, c = t ? ["matrix", "width", "height", "visible"].map((d) => e.watch(e.runtime.path(d), "render", s, { initial: "none" })) : [];
3523
+ return {
3524
+ invalidate: s,
3525
+ dispose: () => {
3526
+ if (!o) {
3527
+ o = !0;
3528
+ for (const d of c)
3529
+ d();
3530
+ a.dispose(), t && (e.nova.removeSurface(r), r.dispose());
3531
+ }
3532
+ }
3533
+ };
3534
+ }
3535
+ function Xr(e, i, t, r) {
3536
+ let n, a;
3537
+ const o = {}, s = e.root.getNovaChartRuntime(), c = s.dataStore, d = new Yr(), f = /* @__PURE__ */ new Map(), g = [], y = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
3538
+ let m = { ...t }, N = !1, E = !1, q = 0, L = !1, D = !1, U = 0, A = { type: "ready" }, $ = null, z = null, Y = { item: null, visible: !1 }, J, se, ve = {};
3539
+ const ie = /* @__PURE__ */ new Map(), O = e.canvas, Z = O.ownerDocument, X = O.parentElement, j = Z.createElement("div");
3540
+ j.style.cssText = "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap", j.setAttribute("role", "listbox"), j.setAttribute("aria-multiselectable", "true"), j.tabIndex = 0;
3541
+ const Ee = Z.createElement("p"), oe = Z.createElement("div");
3542
+ oe.setAttribute("role", "option"), oe.tabIndex = -1, oe.id = `${e.root.componentId}:active-item`, j.setAttribute("aria-activedescendant", oe.id), j.append(Ee, oe), X == null || X.append(j);
3543
+ const Q = Z.createElement("div");
3544
+ Q.id = `${e.root.componentId}:tooltip`, Q.setAttribute("role", "tooltip"), Q.style.cssText = "position:absolute;pointer-events:none;z-index:2;padding:6px 9px;border-radius:4px;background:#152133;color:white;font:12px Arial;max-width:280px;display:none", X == null || X.append(Q);
3545
+ const le = Z.createElement("div");
3546
+ le.setAttribute("aria-live", "polite"), le.style.cssText = "position:absolute;inset:0;pointer-events:none;align-items:center;justify-content:center;font:14px Arial;display:none", X == null || X.append(le);
3547
+ const ue = /* @__PURE__ */ new Set();
3548
+ let me;
3549
+ const W = Z.createElement("div");
3550
+ W.setAttribute("role", "group"), W.setAttribute("aria-label", "Легенда диаграммы"), W.style.cssText = "position:absolute;display:flex;gap:8px;flex-wrap:wrap;z-index:1;max-height:72px;overflow:auto;font:12px Arial", X == null || X.append(W);
3551
+ function et() {
3552
+ var l, u, h;
3553
+ for (const v of [Q, W, le])
3554
+ v.style.fontFamily = ((l = m.font) == null ? void 0 : l.family) ?? "Arial", v.style.fontSize = `${((u = m.font) == null ? void 0 : u.size) ?? (v === le ? 14 : 12)}px`, v.style.fontWeight = ((h = m.font) == null ? void 0 : h.weight) ?? "normal";
3555
+ }
3556
+ et();
3557
+ let re, ce = 0, ge, tt = new Intl.NumberFormat(m.locale ?? "ru-RU");
3558
+ g.push(e.app.onFrameSubmitted(() => {
3559
+ !N && E && (U++, Ce());
3560
+ }));
3561
+ const it = () => {
3562
+ if (N)
3563
+ throw new Error(`[NovaCharts] Instance "${e.root.componentId}" has been destroyed`);
3564
+ }, Pe = (l) => typeof r == "function" ? r(l) : l[r], ee = (l, u, h, v = {}) => {
3565
+ d.has(String(l)) && (l === "dataChange" || !he(u, h)) && d.emit(String(l), { previous: u, current: h, origin: v.origin ?? "api" });
3566
+ }, Se = (l, u) => {
3567
+ for (const h of [...S])
3568
+ h(l, u);
3569
+ }, P = new ai(i.defaults(), m.state, (l) => {
3570
+ const u = i.normalize(l);
3571
+ if (!l.brush)
3572
+ return u;
3573
+ const h = Object.fromEntries(Object.entries(l.brush.ranges).map(([v, p]) => {
3574
+ if (p.length && typeof p[0] == "number") {
3575
+ if (p.length !== 2 || !p.every(Number.isFinite) || p[0] > Number(p[1]))
3576
+ throw new Error("[NovaCharts] Brush range must be finite and ordered");
3577
+ return [v, [Number(p[0]), Number(p[1])]];
3578
+ }
3579
+ if (!p.every((T) => typeof T == "string"))
3580
+ throw new Error("[NovaCharts] Brush categories must be strings");
3581
+ return [v, [...p]];
3582
+ }));
3583
+ return { ...u, brush: { ranges: h } };
3584
+ }, (l, u, h, v) => {
3585
+ i.applyState(l, u), D = !0, d.batch(() => {
3586
+ d.has("viewStateChange") && d.emit("viewStateChange", { previous: ht(l), current: ht(u), origin: h.origin ?? "api", requestId: h.requestId });
3587
+ for (const [p, T] of Object.entries({ selection: "selectionChange", visibility: "visibilityChange", viewport: "viewportChange", camera: "cameraChange", navigation: "drilldownChange", playback: "playbackChange", detail: "detailChange", graph: "graphChange", brush: "brushChange" })) {
3588
+ const _ = p;
3589
+ he(l[_], u[_]) || (d.has(T) && d.emit(T, { previous: Ke(_, l[_]), current: Ke(_, u[_]), origin: h.origin ?? "api", requestId: h.requestId }), Se(p, v));
3590
+ }
3591
+ te();
3592
+ });
3593
+ }), rt = {
3594
+ root: e.root,
3595
+ store: c,
3596
+ readState: () => P.peek(),
3597
+ keyOf: Pe,
3598
+ request: (l, u, h, v, p) => P.request(l, u, h, v, p),
3599
+ invalidate: (l = !1) => {
3600
+ L || (L = l), D = !0, te();
3601
+ },
3602
+ reportError: (l) => {
3603
+ ee("error", void 0, l), n.setStatus({ type: "error", message: l instanceof Error ? l.message : String(l) });
3604
+ }
3605
+ };
3606
+ function te() {
3607
+ var l;
3608
+ if (!(q || N)) {
3609
+ if (L) {
3610
+ L = !1, s.refreshScales(), i.dataChanged();
3611
+ const u = P.peek();
3612
+ if (he(i.normalize(u), u) || P.request("selection", u.selection), (l = u.viewport) != null && l.followTail) {
3613
+ const { scaleId: h, span: v } = u.viewport.followTail, p = s.getScaleSourceDomain(h);
3614
+ p && typeof p[1] == "number" && P.request("viewport", { ...u.viewport, ranges: { ...u.viewport.ranges, [h]: [p[1] - v, p[1]] } });
3615
+ }
3616
+ $ && !i.getItem($) && n.clearHover(), z && !i.getItem(z) && n.focus(null), Y.item && !i.getItem(Y.item) && n.hideTooltip();
3617
+ for (const [h, v] of ie) {
3618
+ const p = v.filter((T) => i.getItem(T));
3619
+ p.length !== v.length && n.highlight(h, p);
3620
+ }
3621
+ s.refresh("data.change"), jt(), D = !0;
3622
+ }
3623
+ D && (D = !1, Ce(), Oe(), st(), se == null || se.invalidate());
3624
+ }
3625
+ }
3626
+ function Ce(l = !1) {
3627
+ var M, F, B;
3628
+ if (at(), j.hidden = m.accessibility === !1, m.accessibility === !1 && !l) {
3629
+ if (ue.size || j.childNodes.length !== 2 || j.lastChild !== oe) {
3630
+ for (const K of ue)
3631
+ e.app.semantics.remove(K);
3632
+ ue.clear(), j.replaceChildren(Ee, oe);
3633
+ }
3634
+ me = void 0;
3635
+ return;
3636
+ }
3637
+ const u = `${P.revision}:${c.revision}:${s.scales.revision}:${e.root.width}:${e.root.height}:${Array.from(e.root.matrix).join(",")}:${z ? V(z) : ""}`;
3638
+ if (!l && (me == null ? void 0 : me.options) === m && me.key === u)
3639
+ return;
3640
+ j.setAttribute("aria-label", ((M = m.accessibility || void 0) == null ? void 0 : M.name) ?? m.title ?? "Диаграмма"), Ee.textContent = `${((F = m.accessibility || void 0) == null ? void 0 : F.description) ?? m.description ?? ""} Записей: ${c.getSourceData().length}. Выбрано: ${P.peek().selection.length}.`;
3641
+ const h = z ? i.getItem(z) : null;
3642
+ oe.textContent = (h == null ? void 0 : h.label) ?? "Выберите элемент стрелками", oe.setAttribute("aria-selected", String(!!(z && P.peek().selection.some((K) => V(K) === V(z)))));
3643
+ const v = P.peek(), p = Math.max(1, Math.floor(((B = m.accessibility || void 0) == null ? void 0 : B.maxItems) ?? 80)), T = i.getVisibleItems(), _ = z ? T.findIndex((K) => V(K.ref) === V(z)) : -1, w = Math.max(0, Math.min(T.length - p, _ - Math.floor(p / 2))), I = /* @__PURE__ */ new Set(), b = Z.createDocumentFragment();
3644
+ for (let K = w; K < Math.min(T.length, w + p); K++) {
3645
+ const H = T[K], ye = `${n.id}:semantic:${encodeURIComponent(V(H.ref))}`, Me = v.selection.some(($e) => V($e) === V(H.ref));
3646
+ I.add(ye), e.app.semantics.register({ id: ye, role: "mark", label: Ie(H), bounds: H.bounds, scope: n.id, order: K + 1, focusable: !0, state: { selected: Me, focused: z !== null && V(z) === V(H.ref) }, source: { type: "synthetic", componentId: n.id, part: "public-item" }, data: { ref: H.ref, value: H.value } });
3647
+ const ne = Z.createElement("div");
3648
+ ne.id = ye, ne.setAttribute("role", "option"), ne.setAttribute("aria-selected", String(Me)), ne.setAttribute("aria-posinset", String(K + 1)), ne.setAttribute("aria-setsize", String(T.length)), ne.textContent = Ie(H), z && V(z) === V(H.ref) && j.setAttribute("aria-activedescendant", ye), b.append(ne);
3649
+ }
3650
+ for (const K of ue)
3651
+ I.has(K) || e.app.semantics.remove(K);
3652
+ ue.clear();
3653
+ for (const K of I)
3654
+ ue.add(K);
3655
+ j.replaceChildren(Ee, b), (!z || !I.has(`${n.id}:semantic:${encodeURIComponent(V(z))}`)) && j.removeAttribute("aria-activedescendant"), me = { options: m, key: u };
3656
+ }
3657
+ function jt() {
3658
+ var u;
3659
+ if (!E || !m.motion || m.motion.respectReducedMotion !== !1 && ((u = globalThis.matchMedia) != null && u.call(globalThis, "(prefers-reduced-motion: reduce)").matches))
3660
+ return;
3661
+ const l = m.motion.duration ?? 180;
3662
+ if (!Number.isFinite(l) || l < 0)
3663
+ throw new RangeError("[NovaCharts] Motion duration must be finite and nonnegative");
3664
+ e.app.motion.cancel(e.root), l && e.app.motion.to(e.root, { opacity: 1 }, { duration: l, from: { opacity: 0.65 } });
3665
+ }
3666
+ function Ie(l) {
3667
+ var u, h;
3668
+ return ((h = (u = m.formatters) == null ? void 0 : u.label) == null ? void 0 : h.call(u, l)) ?? l.label;
3669
+ }
3670
+ function Kt() {
3671
+ var u;
3672
+ if (i.getLegendItems)
3673
+ return i.getLegendItems();
3674
+ const l = ((u = a.getSeries) == null ? void 0 : u.call(a)) ?? [];
3675
+ return l.length ? l.map((h) => ({ id: h.id, label: h.id, visible: h.visible })) : i.getData() && Array.isArray(i.getData()) ? i.getData().map((h) => {
3676
+ const v = n.kind === "tree" ? { type: "node", key: Pe(h) } : { type: "datum", seriesId: "main", key: Pe(h) }, p = i.getItem(v);
3677
+ return { id: V(v), label: p ? Ie(p) : String(Pe(h)), visible: P.peek().visibility[V(v)] !== !1 };
3678
+ }) : [];
3679
+ }
3680
+ function nt() {
3681
+ const l = P.peek().visibility;
3682
+ return (!ge || ge.dataRevision !== c.revision || ge.options !== m || !he(ge.visibility, l)) && (ge = { dataRevision: c.revision, options: m, visibility: l, items: Kt() }), ge.items;
3683
+ }
3684
+ function at() {
3685
+ var b;
3686
+ const l = m.legend === !1 || !m.legend;
3687
+ if ((W.hidden !== l || !W.style.display) && (W.hidden = l, W.style.display = l ? "none" : "flex"), W.hidden)
3688
+ return;
3689
+ const u = nt(), h = Math.max(1, Math.ceil(u.length / 100));
3690
+ ce = Math.min(ce, h - 1);
3691
+ const v = u.slice(ce * 100, (ce + 1) * 100), p = m.legend && m.legend.position || "bottom", T = p === "left" || p === "right", _ = T ? Math.min(180, e.root.width / 3) : Math.max(1, e.root.width - 16), w = Be({ x: p === "right" ? e.root.width - _ - 8 : 8, y: p === "bottom" ? Math.max(0, e.root.height - 72) : 8 });
3692
+ if (re && re.items === u && re.page === ce && re.options === m && re.x === w[0] && re.y === w[1] && re.width === e.root.width && re.height === e.root.height)
3693
+ return;
3694
+ re = { items: u, page: ce, options: m, x: w[0], y: w[1], width: e.root.width, height: e.root.height }, W.style.flexDirection = T ? "column" : "row", W.style.maxHeight = `${T ? Math.max(1, e.root.height - 16) : 72}px`, W.style.color = m.theme === "dark" ? "#d5dee8" : "#243447", W.style.left = `${w[0]}px`, W.style.top = `${w[1]}px`, W.style.maxWidth = `${_}px`;
3695
+ const I = Z.createDocumentFragment();
3696
+ for (const M of v) {
3697
+ const F = Z.createElement("button");
3698
+ F.type = "button", F.textContent = M.label, F.setAttribute("aria-pressed", String(M.visible)), F.disabled = m.legend !== !1 && ((b = m.legend) == null ? void 0 : b.interactive) === !1, F.style.cssText = "border:0;background:transparent;color:inherit;padding:3px;cursor:pointer", F.style.opacity = M.visible ? "1" : ".4", F.onclick = () => {
3699
+ N || P.request("visibility", { ...P.peek().visibility, [M.id]: !M.visible }, "user");
3700
+ }, I.append(F);
3701
+ }
3702
+ if (h > 1)
3703
+ for (const [M, F] of [["Назад", -1], ["Далее", 1]]) {
3704
+ const B = Z.createElement("button");
3705
+ B.type = "button", B.textContent = M, B.setAttribute("aria-label", `${M}: страницы легенды`), B.disabled = ce + F < 0 || ce + F >= h, B.onclick = () => {
3706
+ ce += F, at();
3707
+ }, I.append(B);
3708
+ }
3709
+ W.replaceChildren(I);
3710
+ }
3711
+ function _e(l) {
3712
+ const u = /* @__PURE__ */ new Set();
3713
+ return l.map((h) => {
3714
+ if (!i.getItem(h))
3715
+ throw new Error(`[NovaCharts] Unknown ${h.type} key: ${String(h.key)}`);
3716
+ const v = V(h);
3717
+ if (u.has(v))
3718
+ throw new Error(`[NovaCharts] Duplicate item reference: ${v}`);
3719
+ return u.add(v), { ...h };
3720
+ });
3721
+ }
3722
+ n = {
3723
+ id: e.root.componentId,
3724
+ kind: i.capabilities.kind,
3725
+ canvas: O,
3726
+ target: e.target,
3727
+ getData: () => i.getData(),
3728
+ setData(l, u) {
3729
+ const h = i.getData();
3730
+ i.setData(l), L = !0, ee("dataChange", h, i.getData(), u), te();
3731
+ },
3732
+ getOptions: () => ({ ...m, data: i.getData(), plugins: [...x.values()].map((l) => l.plugin) }),
3733
+ setOptions(l, u) {
3734
+ if (l.id !== void 0 && l.id !== n.id)
3735
+ throw new Error("[NovaCharts] Instance id is immutable");
3736
+ if (l.state !== void 0)
3737
+ throw new Error("[NovaCharts] Use setViewState to commit state");
3738
+ if ("key" in l && l.key !== r)
3739
+ throw new Error("[NovaCharts] Stable key accessor is immutable");
3740
+ for (const _ of ["renderer", "maxDpr"])
3741
+ if (l[_] !== void 0 && l[_] !== m[_])
3742
+ throw new Error(`[NovaCharts] ${_} is fixed at mount; create a new chart to change it`);
3743
+ for (const _ of [l.width, l.height])
3744
+ if (_ !== void 0 && (!Number.isFinite(_) || _ <= 0))
3745
+ throw new RangeError("[NovaCharts] Dimensions must be finite and positive");
3746
+ const h = n.getOptions(), v = Bt(m, l);
3747
+ Ot(v.font);
3748
+ const p = /* @__PURE__ */ new Set(["id", "data", "tooltip", "legend", "motion", "interaction", "accessibility", "title", "description", "events", "plugins"]), T = Object.keys(l).some((_) => !p.has(_));
3749
+ if (T && i.configure(v), m = v, et(), tt = new Intl.NumberFormat(m.locale ?? "ru-RU"), Object.hasOwn(l, "events") && ot(), m.motion === !1 && (e.app.motion.cancel(e.root), e.root.options({ opacity: 1 })), m.tooltip === !1 && n.hideTooltip(), Object.hasOwn(l, "plugins")) {
3750
+ const _ = new Map((v.plugins ?? []).map((w) => [w.id, w]));
3751
+ for (const [w, I] of [...x])
3752
+ _.get(w) !== I.plugin && I.dispose();
3753
+ for (const w of _.values())
3754
+ x.has(w.id) || n.use(w);
3755
+ }
3756
+ l.data !== void 0 && n.setData(l.data, u), T && e.root.setProps({ background: m.background ?? (m.theme === "dark" ? "#141d28" : "#ffffff"), styleSheet: m.styleSheet }), (l.width !== void 0 || l.height !== void 0) && (e.resize({ width: l.width, height: l.height }), i.resize()), ee("optionsChange", h, n.getOptions(), u), L || (L = T), D = !0, te();
3757
+ },
3758
+ batch(l) {
3759
+ return it(), q++, d.batch(() => {
3760
+ try {
3761
+ return e.root.runtime.batch(() => l(n));
3762
+ } finally {
3763
+ q--, te();
3764
+ }
3765
+ });
3766
+ },
3767
+ resize(l) {
3768
+ for (const u of Object.values(l ?? {}))
3769
+ if (!Number.isFinite(u) || u <= 0)
3770
+ throw new RangeError("[NovaCharts] Dimensions must be finite and positive");
3771
+ e.resize(l), i.resize(), D = !0, te();
3772
+ },
3773
+ refresh() {
3774
+ var l;
3775
+ me = void 0, ge = void 0, re = void 0, (l = i.refresh) == null || l.call(i), s.refresh("api.refresh"), D = !0, te();
3776
+ },
3777
+ setStatus(l) {
3778
+ const u = A;
3779
+ A = { ...l }, le.textContent = l.message ?? (l.type === "loading" ? "Загрузка…" : l.type === "error" ? "Не удалось построить диаграмму" : ""), le.style.display = l.type === "ready" ? "none" : "flex", le.setAttribute("role", l.type === "error" ? "alert" : "status"), j.setAttribute("aria-busy", String(l.type === "loading")), ee("statusChange", { ...u }, { ...A });
3780
+ },
3781
+ destroy() {
3782
+ if (!N)
3783
+ try {
3784
+ lt();
3785
+ } finally {
3786
+ e.destroy();
3787
+ }
3788
+ },
3789
+ getViewState: () => P.read(),
3790
+ setViewState: (l, u) => P.accept(l, u),
3791
+ getCapabilities: () => ({ ...i.capabilities, export: { ...i.capabilities.export } }),
3792
+ getDiagnostics: () => ({
3793
+ kind: n.kind,
3794
+ status: { ...A },
3795
+ dataRevision: c.revision,
3796
+ stateRevision: P.revision,
3797
+ renderedItems: i.getVisibleItems().length,
3798
+ sourceItems: c.getSourceData().length,
3799
+ renderCount: U,
3800
+ pendingRequests: P.pendingCount,
3801
+ listeners: d.size,
3802
+ destroyed: N,
3803
+ phases: Object.fromEntries(Object.entries(s.getDiagnostics().series).map(([l, u]) => [l, u.totalMs]))
3804
+ }),
3805
+ getItem: (l) => i.getItem(l),
3806
+ hitTest: (l, u) => i.hitTest(l, (u == null ? void 0 : u.radius) ?? 12),
3807
+ getSelection: () => P.peek().selection.map((l) => ({ ...l })),
3808
+ setSelection: (l, u) => {
3809
+ P.request("selection", _e(l), u == null ? void 0 : u.origin);
3810
+ },
3811
+ select(l, u) {
3812
+ const h = new Map(P.peek().selection.map((v) => [V(v), v]));
3813
+ for (const v of _e(l))
3814
+ h.set(V(v), v);
3815
+ P.request("selection", [...h.values()], u == null ? void 0 : u.origin);
3816
+ },
3817
+ unselect(l, u) {
3818
+ const h = new Set(l.map(V));
3819
+ P.request("selection", P.peek().selection.filter((v) => !h.has(V(v))), u == null ? void 0 : u.origin);
3820
+ },
3821
+ toggleSelection(l, u) {
3822
+ P.peek().selection.some((h) => V(h) === V(l)) ? n.unselect([l], u) : n.select([l], u);
3823
+ },
3824
+ clearSelection: (l) => {
3825
+ P.request("selection", [], l == null ? void 0 : l.origin);
3826
+ },
3827
+ getLegendItems: () => nt().map((l) => ({ ...l })),
3828
+ getVisibility: () => ({ ...P.peek().visibility }),
3829
+ setVisibility: (l, u) => {
3830
+ if (Object.entries(l).some(([h, v]) => !h.trim() || typeof v != "boolean"))
3831
+ throw new Error("[NovaCharts] Visibility requires nonempty keys and boolean values");
3832
+ P.request("visibility", { ...l }, u == null ? void 0 : u.origin);
3833
+ },
3834
+ getHover: () => $ ? { ...$ } : null,
3835
+ setHover(l, u) {
3836
+ if (he(l, $))
3837
+ return;
3838
+ l && _e([l]);
3839
+ const h = $;
3840
+ $ = l ? { ...l } : null, ee("hoverChange", h ? { ...h } : null, $ ? { ...$ } : null, u), Oe(), Se("cursor");
3841
+ },
3842
+ clearHover: (l) => n.setHover(null, l),
3843
+ getFocus: () => z ? { ...z } : null,
3844
+ focus(l, u) {
3845
+ l && _e([l]);
3846
+ const h = z;
3847
+ z = l ? { ...l } : null, ee("focusChange", h ? { ...h } : null, z ? { ...z } : null, u), D = !0, te(), l && m.accessibility !== !1 && j.focus({ preventScroll: !0 });
3848
+ },
3849
+ getHighlights: () => Object.fromEntries([...ie].map(([l, u]) => [l, u.map((h) => ({ ...h }))])),
3850
+ highlight(l, u, h) {
3851
+ if (!l.trim())
3852
+ throw new Error("[NovaCharts] Highlight name must be nonempty");
3853
+ const v = n.getHighlights();
3854
+ ie.set(l, _e(u)), ee("highlightChange", v, n.getHighlights(), h), D = !0, te();
3855
+ },
3856
+ clearHighlight(l, u) {
3857
+ const h = n.getHighlights();
3858
+ l === void 0 ? ie.clear() : ie.delete(l), ee("highlightChange", h, n.getHighlights(), u), D = !0, te();
3859
+ },
3860
+ showTooltip(l, u, h) {
3861
+ var w, I;
3862
+ const v = i.getItem(_e([l])[0]), p = Y;
3863
+ Y = { item: { ...l }, visible: !0 }, Q.textContent = m.tooltip && m.tooltip.format ? m.tooltip.format(v) : `${Ie(v)}${v.value === void 0 ? "" : `: ${((I = (w = m.formatters) == null ? void 0 : w.value) == null ? void 0 : I.call(w, v.value, v)) ?? tt.format(v.value)}`}`;
3864
+ const T = u ?? v.point ?? { x: 0, y: 0 }, _ = Be(T);
3865
+ Q.style.left = `${_[0] + 12}px`, Q.style.top = `${_[1] + 12}px`, Q.style.display = "block", j.setAttribute("aria-describedby", Q.id), ee("tooltipChange", { ...p, item: p.item ? { ...p.item } : null }, { ...Y, item: { ...l } }, h);
3866
+ },
3867
+ hideTooltip(l) {
3868
+ if (!Y.visible)
3869
+ return;
3870
+ const u = Y;
3871
+ Y = { item: null, visible: !1 }, Q.style.display = "none", j.removeAttribute("aria-describedby"), ee("tooltipChange", { ...u, item: u.item ? { ...u.item } : null }, { ...Y }, l);
3872
+ },
3873
+ setTheme: (l) => n.setOptions({ theme: l }),
3874
+ setPalette: (l) => n.setOptions({ palette: l }),
3875
+ async exportChart(l = {}) {
3876
+ e.app.raph.run();
3877
+ const u = Be({ x: 0, y: 0 }), h = await e.app.exportImage({ ...l, preferBlob: !0, rect: { x: u[0], y: u[1], width: e.root.width, height: e.root.height } });
3878
+ if (!h.blob)
3879
+ throw new Error("[NovaCharts] Renderer did not return an image Blob");
3880
+ return h.blob;
3881
+ },
3882
+ exportData(l = {}) {
3883
+ const u = l.scope ?? "source", h = l.format ?? "json";
3884
+ if (!i.capabilities.export.data.includes(h))
3885
+ throw new Error(`[NovaCharts] ${n.kind} does not support ${h} export`);
3886
+ const v = /* @__PURE__ */ new Set(), p = (I) => I.flatMap((b) => {
3887
+ if (!b)
3888
+ return [];
3889
+ if (b.members) {
3890
+ if (!l.aggregates || l.aggregates === "reject")
3891
+ throw new Error("[NovaCharts] Aggregate export requires aggregates: members or bucket");
3892
+ return l.aggregates === "bucket" ? [{ ref: b.ref, members: [...b.members], label: b.label, value: b.value }] : b.members.flatMap((M) => {
3893
+ const F = c.getRow(M);
3894
+ return F === void 0 || v.has(F) ? [] : (v.add(F), [F]);
3895
+ });
3896
+ }
3897
+ return b.row === void 0 || v.has(b.row) ? [] : (v.add(b.row), [b.row]);
3898
+ }), T = u === "source" ? i.getData() : u === "filtered" ? c.getData() : p(u === "visible" ? i.getVisibleItems() : P.peek().selection.map((I) => i.getItem(I)));
3899
+ if (l.format !== "csv")
3900
+ return new Blob([JSON.stringify(T)], { type: "application/json;charset=utf-8" });
3901
+ if (!Array.isArray(T))
3902
+ throw new TypeError("[NovaCharts] CSV requires tabular data; choose JSON for scene data");
3903
+ const _ = l.fields ?? Object.keys(T[0] ?? {}), w = [_.map(kt).join(","), ...T.map((I) => _.map((b) => kt(I[b])).join(","))];
3904
+ return new Blob([w.join(`\r
3905
+ `)], { type: "text/csv;charset=utf-8" });
3906
+ },
3907
+ getSemanticSnapshot: () => {
3908
+ Ce(!0);
3909
+ const l = e.app.semantics.snapshot({ scope: n.id, includeData: !0 });
3910
+ return m.accessibility === !1 && Ce(), l;
3911
+ },
3912
+ on: (l, u) => d.on(String(l), u),
3913
+ use(l) {
3914
+ if (!l.id.trim() || x.has(l.id))
3915
+ throw new Error("[NovaCharts] Plugin id must be nonempty and unique per chart");
3916
+ const u = [], h = {
3917
+ chart: a,
3918
+ size: () => ({ width: e.root.width, height: e.root.height }),
3919
+ plotBounds: () => {
3920
+ var _;
3921
+ return ((_ = i.plotBounds) == null ? void 0 : _.call(i)) ?? { x: 0, y: 0, width: e.root.width, height: e.root.height };
3922
+ },
3923
+ overlay(_) {
3924
+ const w = He(e.root, _);
3925
+ return u.push(w.dispose), w;
3926
+ },
3927
+ pointer(_) {
3928
+ const w = (M) => {
3929
+ const F = M, B = e.app.events.getCanvasMousePosition(F), [K, H] = e.root.toLocal(B.x, B.y);
3930
+ _(F, { x: K, y: H });
3931
+ }, I = ["pointerdown", "pointermove", "pointerup", "pointercancel", "pointerleave"];
3932
+ for (const M of I)
3933
+ O.addEventListener(M, w, { capture: !0, passive: !1 });
3934
+ const b = () => {
3935
+ for (const M of I)
3936
+ O.removeEventListener(M, w, !0);
3937
+ };
3938
+ return u.push(b), b;
3939
+ },
3940
+ map(_, w) {
3941
+ var b;
3942
+ const I = (b = a.getScale) == null ? void 0 : b.call(a, _);
3943
+ if (!I)
3944
+ throw new Error("[NovaCharts] Plugin requires a Cartesian scale");
3945
+ return I.map(w);
3946
+ },
3947
+ invert(_, w) {
3948
+ var b;
3949
+ const I = (b = a.getScale) == null ? void 0 : b.call(a, _);
3950
+ if (!I)
3951
+ throw new Error("[NovaCharts] Plugin requires a Cartesian scale");
3952
+ return I.invert(w);
3953
+ },
3954
+ axis(_) {
3955
+ var I;
3956
+ const w = (I = a.getScale) == null ? void 0 : I.call(a, _);
3957
+ if (!w)
3958
+ throw new Error("[NovaCharts] Plugin requires a Cartesian scale");
3959
+ return w.getAxis();
3960
+ },
3961
+ request: rt.request,
3962
+ notify: Se,
3963
+ port(_, w) {
3964
+ const I = o[_];
3965
+ if (I && _ !== "cursor")
3966
+ throw new Error(`[NovaCharts] Sync port ${_} already exists`);
3967
+ o[_] = w, Se("@ports");
3968
+ const b = () => {
3969
+ o[_] === w && (I ? o[_] = I : delete o[_], Se("@ports"));
3970
+ };
3971
+ return u.push(b), b;
3972
+ }
3973
+ };
3974
+ let v;
3975
+ try {
3976
+ v = l.attach(h);
3977
+ } catch (_) {
3978
+ for (const w of u.reverse())
3979
+ w();
3980
+ throw _;
3981
+ }
3982
+ let p = !0;
3983
+ const T = () => {
3984
+ if (!p)
3985
+ return;
3986
+ p = !1, x.delete(l.id);
3987
+ const _ = [];
3988
+ for (const w of [v, ...u.reverse()])
3989
+ try {
3990
+ w();
3991
+ } catch (I) {
3992
+ _.push(I);
3993
+ }
3994
+ if (_.length)
3995
+ throw new AggregateError(_, "[NovaCharts] Plugin cleanup failed");
3996
+ };
3997
+ return x.set(l.id, { plugin: l, dispose: T }), T;
3998
+ }
3999
+ };
4000
+ const ze = {
4001
+ getRow: (l) => c.getRow(l),
4002
+ appendRows: (l, u) => Ae(() => c.appendRows(l, u == null ? void 0 : u.maxRows)),
4003
+ patchRows: (l) => Ae(() => c.patchRows(l)),
4004
+ upsertRows: (l) => Ae(() => c.upsertRows(l)),
4005
+ removeRows: (l) => Ae(() => c.removeRows([...l])),
4006
+ getFilters: () => Object.fromEntries(k),
4007
+ setFilter(l, u, h) {
4008
+ if (!l.trim())
4009
+ throw new Error("[NovaCharts] Filter name must be nonempty");
4010
+ k.set(l, u), Ve(h);
4011
+ },
4012
+ removeFilter: (l, u) => {
4013
+ k.delete(l), Ve(u);
4014
+ },
4015
+ clearFilters: (l) => {
4016
+ k.clear(), Ve(l);
4017
+ }
4018
+ };
4019
+ function Ae(l) {
4020
+ const u = i.getData(), h = d.has("dataChange") && Array.isArray(u) ? [...u] : u;
4021
+ l(), L = !0, ee("dataChange", h, i.getData()), te();
4022
+ }
4023
+ function Ve(l) {
4024
+ const u = ve;
4025
+ ve = Object.fromEntries(k), c.setFilters([...k.values()].map((h) => (v) => {
4026
+ if (h.type === "predicate")
4027
+ return h.test(v);
4028
+ const p = typeof h.field == "function" ? h.field(v) : v[h.field];
4029
+ return h.type === "in" ? h.values.some((T) => Object.is(T, p)) : p != null && Number.isFinite(Number(p)) && (h.min === void 0 || Number(p) >= h.min) && (h.max === void 0 || Number(p) <= h.max);
4030
+ })), L = !0, ee("filtersChange", u, ve, l), Se("filters"), te();
4031
+ }
4032
+ const Ut = i.defaults();
4033
+ for (const l of ["selection", "visibility", "viewport", "camera", "navigation", "playback", "detail", "graph"])
4034
+ Ut[l] !== void 0 && (o[l] = { read: () => Ke(l, P.peek()[l]), write: (u, h) => P.request(l, u, "sync", h), equals: he, meta: { kind: i.capabilities.kind, getItem: i.getItem, getItems: i.getVisibleItems } });
4035
+ o.cursor = { read: () => $ ? { ...$ } : null, write: (l) => n.setHover(l, { origin: "sync" }), equals: he }, i.capabilities.rows && (o.filters = { read: () => ze.getFilters(), write: (l) => n.batch(() => {
4036
+ ze.clearFilters({ origin: "sync" });
4037
+ for (const [u, h] of Object.entries(l))
4038
+ ze.setFilter(u, h, { origin: "sync" });
4039
+ }), equals: he });
4040
+ const qt = {
4041
+ id: n.id,
4042
+ ports: o,
4043
+ subscribe(l) {
4044
+ return S.add(l), () => {
4045
+ S.delete(l);
4046
+ };
4047
+ },
4048
+ onDispose(l) {
4049
+ return y.add(l), () => {
4050
+ y.delete(l);
4051
+ };
4052
+ }
4053
+ };
4054
+ a = Object.assign(n, i.capabilities.rows ? ze : {}, i.extend(n, rt));
4055
+ function Oe() {
4056
+ !J && ($ || z || P.peek().selection.length || [...ie.values()].some((l) => l.length)) && (J = He(e.root, () => {
4057
+ var h, v, p, T;
4058
+ const l = [], u = /* @__PURE__ */ new Map();
4059
+ for (const _ of [...ie.values()].flat())
4060
+ u.set(V(_), { ref: _, style: { stroke: "#e9a23b", strokeWidth: 2, opacity: 0.9, ...(h = m.styles) == null ? void 0 : h.highlighted } });
4061
+ for (const _ of P.peek().selection)
4062
+ u.set(V(_), { ref: _, style: { stroke: "#287bc1", strokeWidth: 2.5, ...(v = m.styles) == null ? void 0 : v.selected } });
4063
+ $ && u.set(V($), { ref: $, style: { stroke: "#378ebc", strokeWidth: 2, ...(p = m.styles) == null ? void 0 : p.hovered } }), z && u.set(V(z), { ref: z, style: { stroke: "#7c4db6", strokeWidth: 3, ...(T = m.styles) == null ? void 0 : T.focused } });
4064
+ for (const { ref: _, style: w } of u.values()) {
4065
+ if (i.overlay) {
4066
+ l.push(...i.overlay(_, w));
4067
+ continue;
4068
+ }
4069
+ const I = i.getItem(_);
4070
+ I != null && I.bounds ? l.push({ type: "rect", ...I.bounds, styles: { background: w.fill ?? "transparent", border: { color: w.stroke ?? "#287bc1", width: w.strokeWidth ?? 2 }, opacity: w.opacity ?? 1 } }) : I != null && I.point && l.push({ type: "circle", ...I.point, radius: w.radius ?? 6, styles: { border: { color: w.stroke ?? "#287bc1", width: w.strokeWidth ?? 2 }, opacity: w.opacity ?? 1 } });
4071
+ }
4072
+ return l;
4073
+ }), g.push(J.dispose)), J == null || J.invalidate();
4074
+ }
4075
+ Oe();
4076
+ function st() {
4077
+ var l;
4078
+ se || !((l = m.labels) != null && l.visible) || ["donut", "rose", "treemap", "funnel", "radar", "tree", "graph"].includes(n.kind) || (se = He(e.root, () => {
4079
+ var u;
4080
+ return (u = m.labels) != null && u.visible ? i.getVisibleItems().flatMap((h) => {
4081
+ var v, p, T, _, w, I, b;
4082
+ return h.point ? [{ type: "text", text: ((p = (v = m.labels) == null ? void 0 : v.format) == null ? void 0 : p.call(v, h)) ?? Ie(h), x: h.point.x + 5, y: h.point.y - (((T = m.font) == null ? void 0 : T.size) ?? 12) * 1.5, width: 120, height: Math.max(14, (((_ = m.font) == null ? void 0 : _.size) ?? 12) * 1.3), styles: { color: m.theme === "dark" ? "#c6d0dc" : "#475569", font: { size: ((w = m.font) == null ? void 0 : w.size) ?? 12, family: ((I = m.font) == null ? void 0 : I.family) ?? "Arial", weight: (b = m.font) == null ? void 0 : b.weight } } }] : [];
4083
+ }) : [];
4084
+ }), g.push(se.dispose));
4085
+ }
4086
+ st();
4087
+ for (const [l, u] of Object.entries(a)) {
4088
+ if (typeof u != "function" || l === "destroy")
4089
+ continue;
4090
+ const h = !l.startsWith("get") && !l.startsWith("export") && l !== "hitTest" && l !== "on";
4091
+ Object.assign(a, { [l]: (...v) => (it(), h ? d.batch(() => Reflect.apply(u, a, v)) : Reflect.apply(u, a, v)) });
4092
+ }
4093
+ ut.set(a, qt), i.applyState(i.defaults(), P.peek()), g.push(e.root.onDispose(lt)), Wt(), ot(), g.push(() => {
4094
+ for (const l of f.values())
4095
+ l();
4096
+ f.clear();
4097
+ }), Ce();
4098
+ for (const l of t.plugins ?? [])
4099
+ a.use(l);
4100
+ return E = !0, a;
4101
+ function ot() {
4102
+ for (const l of f.values())
4103
+ l();
4104
+ f.clear();
4105
+ for (const [l, u] of Object.entries(m.events ?? {}))
4106
+ u && f.set(l, d.on(l, u));
4107
+ }
4108
+ function lt() {
4109
+ if (N)
4110
+ return;
4111
+ N = !0, P.dispose(), e.app.motion.cancel(e.root);
4112
+ const l = [];
4113
+ for (const u of [...x.values()])
4114
+ try {
4115
+ u.dispose();
4116
+ } catch (h) {
4117
+ l.push(h);
4118
+ }
4119
+ for (const u of g.splice(0).reverse())
4120
+ try {
4121
+ u();
4122
+ } catch (h) {
4123
+ l.push(h);
4124
+ }
4125
+ for (const u of [...y])
4126
+ try {
4127
+ u();
4128
+ } catch (h) {
4129
+ l.push(h);
4130
+ }
4131
+ y.clear(), S.clear(), ut.delete(a);
4132
+ try {
4133
+ i.dispose();
4134
+ } catch (u) {
4135
+ l.push(u);
4136
+ }
4137
+ for (const u of ue)
4138
+ e.app.semantics.remove(u);
4139
+ ue.clear(), j.remove(), Q.remove(), le.remove(), W.remove();
4140
+ try {
4141
+ d.emit("destroy", { previous: !1, current: !0, origin: "api" });
4142
+ } catch (u) {
4143
+ l.push(u);
4144
+ } finally {
4145
+ d.dispose();
4146
+ }
4147
+ if (l.length)
4148
+ throw new AggregateError(l, "[NovaCharts] Cleanup failed");
4149
+ }
4150
+ function Be(l) {
4151
+ const u = e.root.matrix;
4152
+ return [u[0] * l.x + u[3] * l.y + u[6], u[1] * l.x + u[4] * l.y + u[7]];
4153
+ }
4154
+ function Wt() {
4155
+ const l = (b) => {
4156
+ const M = e.app.events.getCanvasMousePosition(b), [F, B] = e.root.toLocal(M.x, M.y);
4157
+ return { x: F, y: B };
4158
+ }, u = (b) => b.x >= 0 && b.x <= e.root.width && b.y >= 0 && b.y <= e.root.height;
4159
+ let h = null;
4160
+ g.push(() => {
4161
+ var b;
4162
+ h && ((b = O.hasPointerCapture) != null && b.call(O, h.id)) && O.releasePointerCapture(h.id), h = null;
4163
+ });
4164
+ const v = (b) => {
4165
+ var B, K;
4166
+ const M = l(b);
4167
+ if (h && h.id === b.pointerId && (Math.hypot(M.x - h.start.x, M.y - h.start.y) > 3 && (h.moved = !0), h.moved && ((B = m.interaction) == null ? void 0 : B.pan) !== !1 && "panBy" in a && a.panBy({ x: M.x - h.point.x, y: M.y - h.point.y }, { origin: "user" }), h.point = M), !u(M)) {
4168
+ n.clearHover({ origin: "user" }), n.hideTooltip({ origin: "user" });
4169
+ return;
4170
+ }
4171
+ if (((K = m.interaction) == null ? void 0 : K.hover) === !1)
4172
+ return;
4173
+ const F = i.hitTest(M, b.pointerType === "touch" ? 24 : 12);
4174
+ n.setHover((F == null ? void 0 : F.ref) ?? null, { origin: "user" }), F && m.tooltip !== !1 ? n.showTooltip(F.ref, M, { origin: "user" }) : n.hideTooltip({ origin: "user" });
4175
+ }, p = (b) => {
4176
+ var F;
4177
+ const M = l(b);
4178
+ b.defaultPrevented || !u(M) || b.button !== 0 || (h = { point: M, start: M, moved: !1, id: b.pointerId }, (F = O.setPointerCapture) == null || F.call(O, b.pointerId));
4179
+ }, T = (b) => {
4180
+ var M, F;
4181
+ if (!(!h || h.id !== b.pointerId)) {
4182
+ if (!h.moved && ((M = m.interaction) == null ? void 0 : M.selection) !== !1) {
4183
+ const B = i.hitTest(l(b), 24);
4184
+ B && (n.toggleSelection(B.ref, { origin: "user" }), n.focus(B.ref, { origin: "user" }));
4185
+ }
4186
+ (F = O.releasePointerCapture) == null || F.call(O, b.pointerId), h = null;
4187
+ }
4188
+ }, _ = (b) => {
4189
+ var M, F;
4190
+ ((b == null ? void 0 : b.type) !== "pointerleave" || !h || !((M = O.hasPointerCapture) != null && M.call(O, h.id))) && (h && ((F = O.hasPointerCapture) != null && F.call(O, h.id)) && O.releasePointerCapture(h.id), h = null), n.clearHover({ origin: "user" }), n.hideTooltip({ origin: "user" });
4191
+ }, w = (b) => {
4192
+ var ye, Me, ne, $e, ct;
4193
+ const M = l(b), F = ((ye = m.interaction) == null ? void 0 : ye.wheel) ?? "modified";
4194
+ if (!u(M) || F === "none" || !("zoomAt" in a) || F === "modified" && !b.ctrlKey && !b.metaKey)
4195
+ return;
4196
+ const B = ((Me = m.interaction) == null ? void 0 : Me.preventDefault) ?? "handled";
4197
+ B === "always" && b.preventDefault();
4198
+ const K = P.revision, H = b.deltaY * (b.deltaMode === 1 ? 16 : b.deltaMode === 2 ? e.root.height : 1);
4199
+ F === "pan" && ((ne = m.interaction) == null ? void 0 : ne.pan) !== !1 ? a.panBy({ x: -b.deltaX, y: -H }, { origin: "user" }) : (($e = m.interaction) == null ? void 0 : $e.zoom) !== !1 && a.zoomAt(Math.exp(-Math.max(-300, Math.min(300, H)) * 2e-3 * (((ct = m.interaction) == null ? void 0 : ct.speed) ?? 1)), M, { origin: "user" }), (P.revision !== K || P.pendingCount > 0) && B === "handled" && b.preventDefault();
4200
+ }, I = (b) => {
4201
+ var M;
4202
+ if (!(m.accessibility === !1 || ((M = m.accessibility) == null ? void 0 : M.keyboard) === !1)) {
4203
+ if (b.key === "Escape")
4204
+ n.clearSelection({ origin: "user" }), n.hideTooltip({ origin: "user" });
4205
+ else if ((b.key === "Enter" || b.key === " ") && z)
4206
+ n.toggleSelection(z, { origin: "user" });
4207
+ else if (["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Home", "End"].includes(b.key)) {
4208
+ const F = i.getVisibleItems();
4209
+ if (!F.length)
4210
+ return;
4211
+ const B = z ? F.findIndex((H) => V(H.ref) === V(z)) : -1, K = b.key === "Home" ? 0 : b.key === "End" ? F.length - 1 : Math.max(0, Math.min(F.length - 1, B + (b.key === "ArrowLeft" || b.key === "ArrowUp" ? -1 : 1)));
4212
+ n.focus(F[K].ref, { origin: "user" });
4213
+ } else
4214
+ return;
4215
+ b.preventDefault();
4216
+ }
4217
+ };
4218
+ for (const [b, M] of [["pointermove", v], ["pointerdown", p], ["pointerup", T], ["pointercancel", _], ["pointerleave", _], ["wheel", w]])
4219
+ O.addEventListener(b, M, { passive: !1 }), g.push(() => O.removeEventListener(b, M));
4220
+ j.addEventListener("keydown", I), g.push(() => j.removeEventListener("keydown", I));
4221
+ }
4222
+ }
4223
+ function Bt(e, i) {
4224
+ const t = { ...e };
4225
+ for (const [r, n] of Object.entries(i))
4226
+ if (n !== void 0 && typeof n == "object" && n !== null && !Array.isArray(n)) {
4227
+ const a = e[r];
4228
+ t[r] = a && typeof a == "object" && !Array.isArray(a) ? Bt(a, n) : n;
4229
+ } else
4230
+ t[r] = n;
4231
+ return t;
4232
+ }
4233
+ function kt(e) {
4234
+ return `"${String(e ?? "").replaceAll('"', '""')}"`;
4235
+ }
4236
+ let Ct = 0;
4237
+ const Ye = /* @__PURE__ */ new WeakMap();
4238
+ function Mn(e) {
4239
+ const i = (t, r, n) => {
4240
+ var f, g;
4241
+ Ot(r.font);
4242
+ const a = r.id ?? `nova-chart-${++Ct}`;
4243
+ if (!a.trim())
4244
+ throw new Error("[NovaCharts] Chart id must be nonempty");
4245
+ const o = r.width ?? t.app.width, s = r.height ?? t.app.height, c = new Or(t.app, t.surface, Ze({
4246
+ width: o,
4247
+ height: s,
4248
+ data: [...e.rows(r)],
4249
+ keyField: e.key(r),
4250
+ background: r.background ?? (r.theme === "dark" ? "#141d28" : "#ffffff"),
4251
+ styleSheet: r.styleSheet,
4252
+ accessibility: r.accessibility === !1 ? !1 : { label: ((f = r.accessibility) == null ? void 0 : f.name) ?? r.title ?? "Диаграмма", description: ((g = r.accessibility) == null ? void 0 : g.description) ?? r.description }
4253
+ }), { componentId: a });
4254
+ let d = null;
4255
+ try {
4256
+ if (!(t.parent ?? t.surface).addChild(c))
4257
+ throw new Error(`[NovaCharts] Cannot attach chart ${a}`);
4258
+ c.applyLayoutRect({ x: 0, y: 0, width: o, height: s }), d = e.create(c, r);
4259
+ const y = {
4260
+ app: t.app,
4261
+ root: c,
4262
+ canvas: (n == null ? void 0 : n.canvas) ?? t.app.canvas.element,
4263
+ target: (n == null ? void 0 : n.target) ?? null,
4264
+ owned: !!n,
4265
+ resize: (n == null ? void 0 : n.resize) ?? ((k = {}) => {
4266
+ c.applyLayoutRect({ x: c.x, y: c.y, width: k.width ?? c.width, height: k.height ?? c.height });
4267
+ }),
4268
+ destroy: (n == null ? void 0 : n.destroy) ?? (() => c.dispose())
4269
+ }, S = Xr(y, d, r, e.key(r));
4270
+ return t.app.raph.run(), { handle: S, root: c, driver: d };
4271
+ } catch (y) {
4272
+ throw d == null || d.dispose(), c.dispose(), y;
4273
+ }
4274
+ };
4275
+ return {
4276
+ attach: (t, r) => i(t, r).handle,
4277
+ mount(t, r) {
4278
+ const n = typeof t == "string" ? document.querySelector(t) : t;
4279
+ if (!(n instanceof HTMLElement))
4280
+ throw new TypeError(`[NovaCharts] Mount target was not found: ${String(t)}`);
4281
+ if (Ye.has(n))
4282
+ throw new Error("[NovaCharts] Mount target already owns a chart");
4283
+ const a = document.createElement("div");
4284
+ a.style.cssText = "position:relative;overflow:hidden;width:100%;height:100%", r.width !== void 0 && (a.style.width = `${r.width}px`), r.height !== void 0 && (a.style.height = `${r.height}px`);
4285
+ const o = document.createElement("canvas");
4286
+ o.style.cssText = "display:block;width:100%;height:100%;touch-action:none", a.append(o), n.append(a);
4287
+ let s = null, c = null, d = !1;
4288
+ const f = (g = {}) => ({
4289
+ width: It(g.width ?? a.clientWidth, n.clientWidth, r.width, 720),
4290
+ height: It(g.height ?? a.clientHeight, n.clientHeight, r.height, 420)
4291
+ });
4292
+ try {
4293
+ s = Mt.createApp({
4294
+ target: o,
4295
+ size: { ...f(), maxDpr: r.maxDpr ?? 2 },
4296
+ renderer: { main: r.renderer === "webgl" ? je.WebGL : je.Web2D },
4297
+ scheduler: { type: Zt.AnimationFrame, loop: !1 },
4298
+ sound: { enabled: !1 },
4299
+ input: { pointer: { enabled: !0, capture: !0 }, keyboard: { enabled: !0, scope: "focused", preventDefault: "handled", ignoreEditableTargets: !0 } },
4300
+ debug: { enabled: !1, telemetry: !1 }
4301
+ });
4302
+ const g = s.createSurface(`charts:${r.id ?? Ct + 1}`);
4303
+ s.mainRendererType === je.Web2D && (g.renderPolicy = { cache: "texture" });
4304
+ const y = g.createNode(ii, ri(f()));
4305
+ let S;
4306
+ S = i({ app: s, surface: g, parent: y }, r, { target: n, canvas: o, resize: (N = {}) => {
4307
+ N.width !== void 0 && (a.style.width = `${N.width}px`), N.height !== void 0 && (a.style.height = `${N.height}px`);
4308
+ const E = f(N);
4309
+ s == null || s.options(E), y.applyLayoutRect({ x: 0, y: 0, ...E }), S == null || S.root.applyLayoutRect({ x: 0, y: 0, ...E }), y.relayout();
4310
+ }, destroy: () => {
4311
+ if (!d) {
4312
+ d = !0, c == null || c.disconnect(), c = null, Ye.delete(n);
4313
+ try {
4314
+ s == null || s.destroy();
4315
+ } finally {
4316
+ a.remove();
4317
+ }
4318
+ }
4319
+ } });
4320
+ const m = S.handle;
4321
+ return y.relayout(), typeof ResizeObserver < "u" && (c = new ResizeObserver(() => m.resize()), c.observe(a)), Ye.set(n, m), m;
4322
+ } catch (g) {
4323
+ c == null || c.disconnect();
4324
+ try {
4325
+ s == null || s.destroy();
4326
+ } finally {
4327
+ a.remove();
4328
+ }
4329
+ throw g;
4330
+ }
4331
+ }
4332
+ };
4333
+ }
4334
+ function It(...e) {
4335
+ for (const i of e)
4336
+ if (i !== void 0 && Number.isFinite(i) && i > 0)
4337
+ return Math.floor(i);
4338
+ return 1;
4339
+ }
4340
+ export {
4341
+ xn as A,
4342
+ G as B,
4343
+ Sn as C,
4344
+ vn as D,
4345
+ on as E,
4346
+ si as N,
4347
+ Pr as a,
4348
+ zr as b,
4349
+ Mn as c,
4350
+ ln as d,
4351
+ Dt as e,
4352
+ an as f,
4353
+ wn as g,
4354
+ yn as h,
4355
+ nn as i,
4356
+ bn as j,
4357
+ gn as k,
4358
+ Cn as l,
4359
+ cn as m,
4360
+ pn as n,
4361
+ mn as o,
4362
+ or as p,
4363
+ Sr as q,
4364
+ sn as r,
4365
+ un as s,
4366
+ fn as t,
4367
+ _r as u,
4368
+ In as v,
4369
+ hn as w,
4370
+ dn as x,
4371
+ kn as y,
4372
+ _n as z
4373
+ };