@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,137 @@
1
+ import { NovaNode as j } from "@nova-lab/core";
2
+ import { G as E, f as P, m as $ } from "./GeometryIndex-DDQ34Jf4.js";
3
+ import { c as q, n as F } from "./camera-CUJAMfpx.js";
4
+ import { r as C, s as N } from "./state-C5pICb11.js";
5
+ class I extends j {
6
+ constructor(n, a, c, m) {
7
+ super(n, a), this._schema = c, this._camera = m;
8
+ }
9
+ render() {
10
+ const n = this._camera(), a = P(n.zoom, 0, 0, 0, n.zoom, 0, this.width / 2 - n.center.x * n.zoom, this.height / 2 - n.center.y * n.zoom, 1);
11
+ this.renderer.save(), this.renderer.setTransform($(a, this.matrix, a)), this.renderer.schema(this._schema()), this.renderer.restore();
12
+ }
13
+ }
14
+ function H(t, n, a) {
15
+ let c = n;
16
+ const m = () => {
17
+ var e;
18
+ return { selection: [], visibility: {}, camera: { center: { x: t.width / 2, y: t.height / 2 }, zoom: 1 }, ...(e = a.defaults) == null ? void 0 : e.call(a) };
19
+ };
20
+ let s = m(), l = null, k = /* @__PURE__ */ new Map(), x = null;
21
+ const i = new I(t.nova, t.surface, () => g().schema, () => s.camera), o = a.dynamic ? new I(t.nova, t.surface, () => g().dynamic ?? [], () => s.camera) : null;
22
+ i.options({ width: t.width, height: t.height }), t.addChild(i), o && (o.options({ width: t.width, height: t.height }), t.addChild(o));
23
+ const y = (e = !0) => {
24
+ l = null, e && i.invalidate({ render: !0 }), o == null || o.invalidate({ render: !0 });
25
+ };
26
+ function g() {
27
+ return l || (l = a.plan(c, s), l.schema.contentVersion = 0, l.schema.snapshotVersion = 0, l.dynamic && (l.dynamic.contentVersion = 0, l.dynamic.snapshotVersion = 0), k = new Map(l.items.map((e) => [C(e.ref), e])), x = new E(l.items, (e) => e.bounds ?? { ...e.point ?? { x: 0, y: 0 }, width: 1, height: 1 })), l;
28
+ }
29
+ const _ = (e) => ({ x: t.width / 2 + (e.x - s.camera.center.x) * s.camera.zoom, y: t.height / 2 + (e.y - s.camera.center.y) * s.camera.zoom });
30
+ function b(e) {
31
+ return { ...e, point: e.point ? _(e.point) : void 0, bounds: e.bounds ? { ..._(e.bounds), width: e.bounds.width * s.camera.zoom, height: e.bounds.height * s.camera.zoom } : void 0 };
32
+ }
33
+ function S(e) {
34
+ var h;
35
+ g();
36
+ const r = k.get(C(e)) ?? ((h = a.lookup) == null ? void 0 : h.call(a, e));
37
+ return r ? b(r) : null;
38
+ }
39
+ return {
40
+ capabilities: a.capabilities,
41
+ defaults: m,
42
+ normalize(e) {
43
+ const r = a.normalize ? a.normalize(e) : e;
44
+ return { ...r, camera: F(r.camera ?? m().camera) };
45
+ },
46
+ configure(e) {
47
+ var r;
48
+ (r = a.configure) == null || r.call(a, e), c = e, y();
49
+ },
50
+ applyState(e, r) {
51
+ var D;
52
+ s = r, (D = a.stateChanged) == null || D.call(a, e, r);
53
+ const { camera: h, selection: p, brush: w, ...v } = e, { camera: f, selection: u, brush: d, ...z } = r;
54
+ if (N(v, z))
55
+ N(e.camera, r.camera) || (i.invalidate({ render: !0 }), o == null || o.invalidate({ render: !0 }));
56
+ else {
57
+ const { playback: G, ...M } = v, { playback: T, ...V } = z;
58
+ y(!o || !N(M, V));
59
+ }
60
+ },
61
+ dataChanged() {
62
+ var e;
63
+ (e = a.changed) == null || e.call(a), y();
64
+ },
65
+ getLegendItems: a.legend ? () => a.legend(c, s).map((e) => ({ ...e, visible: s.visibility[e.id] !== !1 })) : void 0,
66
+ getData: a.getData,
67
+ setData(e) {
68
+ a.setData(e), y();
69
+ },
70
+ getItem: S,
71
+ getVisibleItems: () => g().items.map(b).filter((e) => e.bounds ? e.bounds.x + e.bounds.width >= 0 && e.bounds.y + e.bounds.height >= 0 && e.bounds.x <= t.width && e.bounds.y <= t.height : e.point && e.point.x >= 0 && e.point.y >= 0 && e.point.x <= t.width && e.point.y <= t.height),
72
+ hitTest(e, r) {
73
+ var f;
74
+ g();
75
+ const h = { x: (e.x - t.width / 2) / s.camera.zoom + s.camera.center.x, y: (e.y - t.height / 2) / s.camera.zoom + s.camera.center.y }, p = r / s.camera.zoom;
76
+ let w = null, v = p;
77
+ for (const u of (x == null ? void 0 : x.query(h.x, h.y, p)) ?? []) {
78
+ if ((f = u.contains) != null && f.call(u, h, p))
79
+ return b(u);
80
+ if (u.contains)
81
+ continue;
82
+ const d = u.bounds;
83
+ if (d && h.x >= d.x && h.x <= d.x + d.width && h.y >= d.y && h.y <= d.y + d.height)
84
+ return b(u);
85
+ if (!u.point)
86
+ continue;
87
+ const z = Math.hypot(h.x - u.point.x, h.y - u.point.y);
88
+ z <= v && (w = u, v = z);
89
+ }
90
+ return w ? b(w) : null;
91
+ },
92
+ overlay(e, r) {
93
+ g();
94
+ const h = k.get(C(e));
95
+ if (!h)
96
+ return [];
97
+ if (h.overlay)
98
+ return h.overlay(r, _, s.camera.zoom);
99
+ const p = b(h);
100
+ return p.bounds ? [{ type: "rect", ...p.bounds, styles: { background: r.fill ?? "transparent", border: { color: r.stroke ?? "#287bc1", width: r.strokeWidth ?? 2 }, opacity: r.opacity ?? 1 } }] : [];
101
+ },
102
+ resize() {
103
+ i.options({ width: t.width, height: t.height }), o == null || o.options({ width: t.width, height: t.height }), y();
104
+ },
105
+ refresh: () => y(),
106
+ dispose() {
107
+ var e;
108
+ (e = a.dispose) == null || e.call(a), i.dispose(), o == null || o.dispose(), l = null, k.clear(), x = null;
109
+ },
110
+ extend(e, r) {
111
+ var h;
112
+ return { ...q(r, () => ({ width: t.width, height: t.height }), (p) => p.map(S).filter((w) => w !== null), () => m().camera, ["graph", "aggregation"].includes(a.capabilities.kind) ? () => g().items.map(b) : void 0), ...(h = a.extend) == null ? void 0 : h.call(a, r, y, e) };
113
+ }
114
+ };
115
+ }
116
+ function J(t, n) {
117
+ const a = /* @__PURE__ */ new Map();
118
+ for (const c of t) {
119
+ if (!(typeof c.key == "string" && c.key.trim() || typeof c.key == "number" && Number.isFinite(c.key)))
120
+ throw new Error(`[NovaCharts] ${n} requires a stable nonempty key`);
121
+ if (a.has(c.key))
122
+ throw new Error(`[NovaCharts] Duplicate ${n} key: ${String(c.key)}`);
123
+ a.set(c.key, c);
124
+ }
125
+ return a;
126
+ }
127
+ function K(t, n, a) {
128
+ if (![t.width, t.height].every((s) => Number.isFinite(s) && s > 0))
129
+ throw new Error("[NovaCharts] Map viewBox must be finite and positive");
130
+ const c = Math.min(n / t.width, a / t.height), m = { x: (n - t.width * c) / 2, y: (a - t.height * c) / 2 };
131
+ return { scale: c, project: (s) => ({ x: m.x + s.x * c, y: m.y + s.y * c }) };
132
+ }
133
+ export {
134
+ H as c,
135
+ J as k,
136
+ K as m
137
+ };
@@ -0,0 +1,6 @@
1
+ import { SeatMapHandle, SeatMapOptions } from './api/types';
2
+ export declare const SeatMapChart: {
3
+ mount: (target: string | HTMLElement, options: SeatMapOptions) => SeatMapHandle;
4
+ attach: (target: import('./api/types').ChartAttachTarget, options: SeatMapOptions) => SeatMapHandle;
5
+ };
6
+ export type { Seat, SeatMapHandle as SeatMapChartHandle, SeatMapOptions as SeatMapChartOptions, SeatSelectionRules, SeatShape } from './api/types';
@@ -0,0 +1,84 @@
1
+ import { c as z } from "./host-DLDeDU5k.js";
2
+ import { s as S, M as F, p as P } from "./seat-shape--kEFiUXX.js";
3
+ import { k as q, m as j, c as O } from "./scene-CPvPzTaB.js";
4
+ import { r as U } from "./state-C5pICb11.js";
5
+ const R = z({ rows: (a) => (k(a), a.data), key: () => "key", create: V }), L = { mount: R.mount, attach: R.attach };
6
+ function k(a) {
7
+ var y;
8
+ if (q(a.data, "seat"), j(a.viewBox, 1, 1), ((y = a.selection) == null ? void 0 : y.max) !== void 0 && (!Number.isInteger(a.selection.max) || a.selection.max < 0))
9
+ throw new Error("[NovaCharts] Seat selection max must be a nonnegative integer");
10
+ for (const c of a.data) {
11
+ if (!["available", "occupied", "premium"].includes(c.status))
12
+ throw new Error("[NovaCharts] Invalid seat status");
13
+ const s = S(c.shape);
14
+ if (!s || s.length < 3 || s.some((p) => !Number.isFinite(p.x) || !Number.isFinite(p.y)))
15
+ throw new Error("[NovaCharts] Seat requires a finite closed shape");
16
+ }
17
+ }
18
+ function V(a, y) {
19
+ const c = a.getNovaChartRuntime().dataStore;
20
+ let s = y;
21
+ const p = /* @__PURE__ */ new Map();
22
+ let x = () => {
23
+ };
24
+ const g = new F(() => x());
25
+ return g.set(s.mapBackground), c.setValidator((e) => k({ ...s, data: e })), O(a, s, {
26
+ capabilities: { kind: "seat-map", rows: !0, scales: !1, viewport: !1, camera: !0, drilldown: !1, expansion: !1, layout: !1, detail: !1, playback: !1, selection: !0, export: { image: ["png", "jpeg", "webp"], data: ["json", "csv"] } },
27
+ legend: () => [...new Set(c.getSourceData().map((e) => e.status))].map((e) => ({ id: e, label: e })),
28
+ defaults: () => ({ camera: { center: { x: s.viewBox.width / 2, y: s.viewBox.height / 2 }, zoom: j(s.viewBox, a.width, a.height).scale } }),
29
+ normalize: (e) => {
30
+ if (e.viewport || e.navigation || e.detail || e.playback || e.graph)
31
+ throw new Error("[NovaCharts] Unsupported SeatMap view state");
32
+ const t = s.selection ?? {}, d = new Set(t.allowedStatuses ?? ["available", "premium"]);
33
+ let i = e.selection.filter((o) => o.type === "seat").map((o) => c.getRow(o.key)).filter((o) => o !== void 0 && d.has(o.status));
34
+ return t.sameSection && i.length && (i = i.filter((o) => Object.is(o.section, i[0].section))), t.max !== void 0 && (i = i.slice(0, t.max)), t.validate && !t.validate(i) && (i = []), { ...e, selection: i.map((o) => ({ type: "seat", key: o.key })) };
35
+ },
36
+ getData: () => c.getSourceData(),
37
+ setData(e) {
38
+ k({ ...s, data: e }), c.setData([...e]), p.clear();
39
+ },
40
+ configure(e) {
41
+ k(e), s = e, g.set(e.mapBackground), p.clear();
42
+ },
43
+ plan(e, t) {
44
+ var I, M, B, N, C;
45
+ const d = [...g.schema(0, 0, e.viewBox.width, e.viewBox.height)], i = [], o = { available: "#88c4b1", occupied: "#cbd3da", premium: "#e8b978", selected: "#367eaf", hover: "#e3f1f7", ...e.colors };
46
+ for (const r of c.getData()) {
47
+ if (t.visibility[r.status] === !1 || t.visibility[U({ type: "seat", key: r.key })] === !1)
48
+ continue;
49
+ const m = r.shape;
50
+ let u;
51
+ if (m.type === "path" ? (p.has(m.d) || p.set(m.d, S(m)), u = p.get(m.d)) : u = S(m), !(u != null && u.length))
52
+ continue;
53
+ const v = [...u];
54
+ let h = 1 / 0, f = 1 / 0, w = -1 / 0, b = -1 / 0;
55
+ for (const l of v)
56
+ h = Math.min(h, l.x), f = Math.min(f, l.y), w = Math.max(w, l.x), b = Math.max(b, l.y);
57
+ const E = ((I = r.colors) == null ? void 0 : I[r.status]) ?? o[r.status], n = (((M = e.selection) == null ? void 0 : M.allowedStatuses) ?? ["available", "premium"]).includes(r.status) ? (C = e.styles) == null ? void 0 : C.normal : { ...(B = e.styles) == null ? void 0 : B.normal, ...(N = e.styles) == null ? void 0 : N.disabled };
58
+ d.push({ type: "polygon", points: v, styles: { background: (n == null ? void 0 : n.fill) ?? E, stroke: (n == null ? void 0 : n.stroke) ?? "#bcc7cf", lineWidth: (n == null ? void 0 : n.strokeWidth) ?? 1, opacity: (n == null ? void 0 : n.opacity) ?? 1 } }), i.push({ ref: { type: "seat", key: r.key }, row: r, label: r.label ?? String(r.key), point: { x: (h + w) / 2, y: (f + b) / 2 }, bounds: { x: h, y: f, width: w - h, height: b - f }, contains: (l) => P(l, v), overlay: (l, W) => {
59
+ var D;
60
+ return [{ type: "polygon", points: v.map(W), styles: { background: l.fill ?? "transparent", stroke: l.stroke ?? ((D = r.colors) == null ? void 0 : D.selected) ?? o.selected, lineWidth: l.strokeWidth ?? 2, opacity: l.opacity ?? 1 } }];
61
+ } });
62
+ }
63
+ return { schema: d, items: i };
64
+ },
65
+ lookup(e) {
66
+ const t = e.type === "seat" ? c.getRow(e.key) : void 0;
67
+ return t ? { ref: e, row: t, label: t.label ?? String(t.key) } : null;
68
+ },
69
+ extend(e, t, d) {
70
+ return x = t, {
71
+ getSelectionRules: () => ({ ...s.selection }),
72
+ setSelectionRules(i) {
73
+ d.setOptions({ selection: { ...i } }), e.request("selection", e.readState().selection), x();
74
+ }
75
+ };
76
+ },
77
+ dispose() {
78
+ g.dispose(), p.clear();
79
+ }
80
+ });
81
+ }
82
+ export {
83
+ L as SeatMapChart
84
+ };
@@ -0,0 +1,66 @@
1
+ var a = Object.defineProperty;
2
+ var h = (i, t, n) => t in i ? a(i, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[t] = n;
3
+ var l = (i, t, n) => h(i, typeof t != "symbol" ? t + "" : t, n);
4
+ class c {
5
+ constructor(t) {
6
+ l(this, "_image", null);
7
+ l(this, "_source");
8
+ this._invalidate = t;
9
+ }
10
+ set(t) {
11
+ const n = (t == null ? void 0 : t.type) === "svg" ? `data:image/svg+xml;charset=utf-8,${encodeURIComponent(t.content)}` : t == null ? void 0 : t.src;
12
+ if (n === this._source || (this.dispose(), this._source = n, !t))
13
+ return;
14
+ const e = new Image();
15
+ this._image = e, e.crossOrigin = "anonymous", e.onload = () => {
16
+ this._image === e && this._invalidate();
17
+ }, e.onerror = () => {
18
+ this._image === e && this._invalidate();
19
+ }, e.src = n;
20
+ }
21
+ schema(t, n, e, r) {
22
+ var s;
23
+ return (s = this._image) != null && s.complete && this._image.naturalWidth > 0 ? [{ type: "icon", icon: this._image, x: t, y: n, width: e, height: r }] : [];
24
+ }
25
+ dispose() {
26
+ this._image && (this._image.onload = null, this._image.onerror = null, this._image = null), this._source = void 0;
27
+ }
28
+ }
29
+ function y(i) {
30
+ var n;
31
+ if (i.type === "rect") {
32
+ const { x: e, y: r, width: s, height: o } = i;
33
+ return [e, r, s, o].every(Number.isFinite) && s > 0 && o > 0 ? [{ x: e, y: r }, { x: e + s, y: r }, { x: e + s, y: r + o }, { x: e, y: r + o }] : null;
34
+ }
35
+ if (i.type === "polygon")
36
+ return i.points.length >= 3 && i.points.every((e) => Number.isFinite(e.x) && Number.isFinite(e.y)) ? i.points.map((e) => ({ ...e })) : null;
37
+ if (typeof document > "u" || !/z\s*$/i.test(i.d) || (((n = i.d.match(/m/gi)) == null ? void 0 : n.length) ?? 0) !== 1)
38
+ return null;
39
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
40
+ t.setAttribute("d", i.d);
41
+ try {
42
+ const e = t.getTotalLength();
43
+ if (!Number.isFinite(e) || e <= 0)
44
+ return null;
45
+ const r = Math.min(512, Math.max(8, Math.ceil(e / 3)));
46
+ return Array.from({ length: r }, (s, o) => {
47
+ const m = t.getPointAtLength(e * o / r);
48
+ return { x: m.x, y: m.y };
49
+ });
50
+ } catch {
51
+ return null;
52
+ }
53
+ }
54
+ function g(i, t) {
55
+ let n = !1;
56
+ for (let e = 0, r = t.length - 1; e < t.length; r = e++) {
57
+ const s = t[e], o = t[r];
58
+ s.y > i.y != o.y > i.y && i.x < (o.x - s.x) * (i.y - s.y) / (o.y - s.y) + s.x && (n = !n);
59
+ }
60
+ return n;
61
+ }
62
+ export {
63
+ c as M,
64
+ g as p,
65
+ y as s
66
+ };
@@ -0,0 +1,134 @@
1
+ var y = Object.defineProperty;
2
+ var l = (e, t, s) => t in e ? y(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var d = (e, t, s) => l(e, typeof t != "symbol" ? t + "" : t, s);
4
+ class q {
5
+ constructor(t, s, r, o) {
6
+ d(this, "_value");
7
+ d(this, "_revision", 0);
8
+ d(this, "_nextRequest", 0);
9
+ d(this, "_latestRequest", 0);
10
+ d(this, "_pending", /* @__PURE__ */ new Map());
11
+ d(this, "_disposed", !1);
12
+ this._options = s, this._normalize = r, this._onCommit = o, this._value = this._normalize(c((s == null ? void 0 : s.mode) === "controlled" ? s.value : { ...t, ...s == null ? void 0 : s.initial }));
13
+ }
14
+ get revision() {
15
+ return this._revision;
16
+ }
17
+ get pendingCount() {
18
+ return this._pending.size;
19
+ }
20
+ /** Только внутренние owners; публичные getters используют отдельные snapshots. */
21
+ peek() {
22
+ return this._assertAlive(), this._value;
23
+ }
24
+ read() {
25
+ return this._assertAlive(), c(this._value);
26
+ }
27
+ /** Запрос не меняет отображение controlled-графика до setViewState. */
28
+ request(t, s, r = "api", o, i = o == null ? void 0 : o.signal) {
29
+ var f;
30
+ if (this._assertAlive(), i != null && i.aborted)
31
+ return !1;
32
+ const a = this._normalize({ ...this._value, [t]: m(t, s) });
33
+ for (const h of this._pending.keys())
34
+ this.reject(h);
35
+ if (p(a, this._value))
36
+ return;
37
+ if (((f = this._options) == null ? void 0 : f.mode) !== "controlled") {
38
+ this._commit(a, { origin: r }, o);
39
+ return;
40
+ }
41
+ const n = ++this._nextRequest;
42
+ this._latestRequest = n;
43
+ const u = {
44
+ id: n,
45
+ previous: this.read(),
46
+ current: c(a),
47
+ origin: r,
48
+ channel: t,
49
+ reject: () => this.reject(n)
50
+ }, _ = () => this.reject(n), b = new Promise((h) => {
51
+ this._pending.set(n, { request: u, settle: h, transaction: o, disposeAbort: () => i == null ? void 0 : i.removeEventListener("abort", _) });
52
+ });
53
+ if (i == null || i.addEventListener("abort", _, { once: !0 }), i != null && i.aborted)
54
+ this.reject(n);
55
+ else
56
+ try {
57
+ this._options.onRequestChange(u) === !1 && this.reject(n);
58
+ } catch (h) {
59
+ throw this.reject(n), h;
60
+ }
61
+ return b;
62
+ }
63
+ /** Устаревший запрос не может перезаписать более новое подтверждённое состояние. */
64
+ accept(t, s = {}) {
65
+ this._assertAlive();
66
+ const r = s.requestId === void 0 ? void 0 : this._pending.get(s.requestId);
67
+ if (s.requestId !== void 0 && (!r || s.requestId !== this._latestRequest))
68
+ return !1;
69
+ const o = this._normalize(c(t));
70
+ for (const i of this._pending.keys())
71
+ i !== s.requestId && this.reject(i);
72
+ r && (this._pending.delete(r.request.id), r.disposeAbort()), this._latestRequest = ++this._nextRequest;
73
+ try {
74
+ this._commit(o, { ...s, origin: (r == null ? void 0 : r.request.origin) ?? s.origin ?? "api" }, r == null ? void 0 : r.transaction);
75
+ } finally {
76
+ r == null || r.settle();
77
+ }
78
+ return !0;
79
+ }
80
+ reject(t) {
81
+ const s = this._pending.get(t);
82
+ s && (this._pending.delete(t), s.disposeAbort(), s.settle(!1));
83
+ }
84
+ dispose() {
85
+ this._disposed = !0;
86
+ for (const t of this._pending.keys())
87
+ this.reject(t);
88
+ }
89
+ _commit(t, s, r) {
90
+ if (p(t, this._value))
91
+ return;
92
+ const o = this._value;
93
+ this._value = t, this._revision++, this._onCommit(o, t, s, r);
94
+ }
95
+ _assertAlive() {
96
+ if (this._disposed)
97
+ throw new Error("[NovaCharts] State owner has been destroyed");
98
+ }
99
+ }
100
+ function m(e, t) {
101
+ return c({ selection: [], visibility: {}, [e]: t })[e];
102
+ }
103
+ function c(e) {
104
+ return {
105
+ ...e,
106
+ selection: e.selection.map((t) => ({ ...t })),
107
+ visibility: { ...e.visibility },
108
+ ...e.viewport ? { viewport: { ranges: Object.fromEntries(Object.entries(e.viewport.ranges).map(([t, s]) => [t, [...s]])), ...e.viewport.followTail ? { followTail: { ...e.viewport.followTail } } : {} } } : {},
109
+ ...e.camera ? { camera: { ...e.camera, center: { ...e.camera.center } } } : {},
110
+ ...e.navigation ? { navigation: { expanded: [...e.navigation.expanded], drilldown: [...e.navigation.drilldown] } } : {},
111
+ ...e.detail ? { detail: { ...e.detail, groups: [...e.detail.groups] } } : {},
112
+ ...e.playback ? { playback: { ...e.playback } } : {},
113
+ ...e.graph ? { graph: { positions: e.graph.positions.map((t) => ({ ...t })), pinned: [...e.graph.pinned] } } : {},
114
+ ...e.brush ? { brush: { ranges: Object.fromEntries(Object.entries(e.brush.ranges).map(([t, s]) => [t, [...s]])) } } : {}
115
+ };
116
+ }
117
+ function p(e, t) {
118
+ if (Object.is(e, t))
119
+ return !0;
120
+ if (!e || !t || typeof e != "object" || typeof t != "object" || Array.isArray(e) !== Array.isArray(t))
121
+ return !1;
122
+ const s = e, r = t, o = Object.keys(s);
123
+ return o.length === Object.keys(r).length && o.every((i) => Object.hasOwn(r, i) && p(s[i], r[i]));
124
+ }
125
+ function v(e) {
126
+ return JSON.stringify([e.type, "seriesId" in e ? e.seriesId : "", typeof e.key, e.key]);
127
+ }
128
+ export {
129
+ q as C,
130
+ m as a,
131
+ c,
132
+ v as r,
133
+ p as s
134
+ };
package/dist/sync.d.ts ADDED
@@ -0,0 +1,82 @@
1
+ import { NovaSyncParticipant, NovaSyncSchedule } from '@nova-lab/core';
2
+ import { ChartCapabilities, ChartItem } from './api/types';
3
+ export type SyncChannel = 'viewport' | 'cursor' | 'selection' | 'visibility' | 'filters' | 'drilldown' | 'camera' | 'brush' | 'playback' | 'scrollY' | 'ungroupedScrollY';
4
+ export type SyncTarget = NovaSyncParticipant | {
5
+ readonly id: string;
6
+ getCapabilities: () => ChartCapabilities;
7
+ };
8
+ export interface SyncMappingContext {
9
+ from: string;
10
+ to: string;
11
+ source: SyncTarget;
12
+ target: SyncTarget;
13
+ }
14
+ export interface SyncSelectionMapping {
15
+ match?: 'key' | 'value' | 'category' | 'business';
16
+ key?: (item: ChartItem, participant: string) => unknown;
17
+ series?: Record<string, string>;
18
+ aggregates?: 'reject' | 'members' | 'bucket';
19
+ }
20
+ export interface SyncViewportMapping {
21
+ mode?: 'range' | 'center' | 'offset' | 'relative';
22
+ /** Canonical scale name -> participant alias -> actual scale id. */
23
+ scales?: Record<string, Record<string, string>>;
24
+ toCanonical?: (value: number, participant: string, scale: string) => number;
25
+ fromCanonical?: (value: number, participant: string, scale: string) => number;
26
+ }
27
+ export interface ChartSyncLinkOptions {
28
+ id: string;
29
+ channel: SyncChannel;
30
+ participants?: ReadonlyArray<string>;
31
+ direction?: 'any' | 'leader';
32
+ leader?: string;
33
+ map?: (value: unknown, context: SyncMappingContext) => unknown;
34
+ selection?: SyncSelectionMapping;
35
+ viewport?: SyncViewportMapping;
36
+ camera?: {
37
+ mode?: 'center' | 'offset' | 'relative';
38
+ };
39
+ playback?: {
40
+ mode?: 'absolute' | 'relative';
41
+ };
42
+ }
43
+ export interface ChartSyncOptions {
44
+ participants?: Record<string, SyncTarget>;
45
+ links?: ReadonlyArray<ChartSyncLinkOptions>;
46
+ schedule?: NovaSyncSchedule;
47
+ onError?: (error: unknown) => void;
48
+ }
49
+ export interface ChartSyncLinkHandle {
50
+ readonly id: string;
51
+ getOptions: () => ChartSyncLinkOptions;
52
+ isPaused: () => boolean;
53
+ pause: () => void;
54
+ resume: () => void;
55
+ resync: (source?: string) => void;
56
+ dispose: () => void;
57
+ }
58
+ /** Один фасад для Charts и нейтральных endpoints других семейств Nova. */
59
+ export declare class ChartSync {
60
+ private readonly _options;
61
+ static create(options?: ChartSyncOptions): ChartSync;
62
+ private readonly _scope;
63
+ private readonly _members;
64
+ private readonly _links;
65
+ private _paused;
66
+ private _disposed;
67
+ constructor(_options?: ChartSyncOptions);
68
+ add(id: string, target: SyncTarget): void;
69
+ remove(id: string): void;
70
+ link(options: ChartSyncLinkOptions): ChartSyncLinkHandle;
71
+ getLinks(): ReadonlyArray<ChartSyncLinkHandle>;
72
+ pause(): void;
73
+ resume(): void;
74
+ resync(source?: string): void;
75
+ dispose(): void;
76
+ private _ids;
77
+ private _disconnect;
78
+ private _wire;
79
+ private _map;
80
+ private _resync;
81
+ private _alive;
82
+ }