@mechane-ai/elements 0.46.0 → 0.48.0

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 (419) hide show
  1. package/README.md +590 -34
  2. package/bin/mechane-elements-catalog.mjs +104 -12
  3. package/dist/ai.js +4 -4
  4. package/dist/article-BXZr10QQ.js +1904 -0
  5. package/dist/article.js +1 -0
  6. package/dist/catalog.json +3696 -33
  7. package/dist/categorical-values-BpVq8cFj.js +107 -0
  8. package/dist/cells-xVmnQ9oQ.js +384 -0
  9. package/dist/chart-link-AE_xuxiP.js +35 -0
  10. package/dist/chart-tones-ei3BC2AL.js +27 -0
  11. package/dist/charts/cartesian.js +1 -2958
  12. package/dist/charts/cells.js +1 -0
  13. package/dist/charts/comparison.js +1 -0
  14. package/dist/charts/distribution.js +1 -781
  15. package/dist/charts/figure.js +3404 -0
  16. package/dist/charts/graph.js +1 -655
  17. package/dist/charts/hierarchy.js +1 -121
  18. package/dist/charts/image.js +1 -0
  19. package/dist/charts/matrix.js +4 -644
  20. package/dist/charts/plot.js +15 -0
  21. package/dist/charts/relationship.js +1 -0
  22. package/dist/charts/text.js +1 -0
  23. package/dist/charts/timeline.js +1 -266
  24. package/dist/charts/transforms.js +677 -0
  25. package/dist/charts/trend.js +1 -0
  26. package/dist/charts.js +8 -3
  27. package/dist/clock-DSm5lkNE.js +16 -0
  28. package/dist/collections.js +1 -2195
  29. package/dist/color-legend-CIo7DhXB.js +62 -0
  30. package/dist/dates-Cww8UR_n.js +810 -0
  31. package/dist/describe-lesson-BmREzDpt.js +175 -0
  32. package/dist/dumbbell-plot-DQdTxDeO.js +509 -0
  33. package/dist/embedding-map-CF-J-8JW.js +1929 -0
  34. package/dist/feedback.js +1 -1
  35. package/dist/figure-format-B8kRZMlo.js +36 -0
  36. package/dist/figure-frame-BJ3REgTA.js +270 -0
  37. package/dist/forms/dates.js +1 -810
  38. package/dist/forms.js +1 -1
  39. package/dist/heatmap-scale-Zte6Ya-g.js +20 -0
  40. package/dist/image-grid-Dl2sjIMB.js +598 -0
  41. package/dist/kits/evaluation.js +431 -0
  42. package/dist/kits/interpretability.js +1033 -0
  43. package/dist/kits/operations.js +239 -0
  44. package/dist/kits/training.js +335 -0
  45. package/dist/label-place-Z0fryBZb.js +42 -0
  46. package/dist/lesson/agent.js +811 -0
  47. package/dist/lesson/spec.js +661 -0
  48. package/dist/lesson.js +5 -0
  49. package/dist/locate-Bcg3QcP4.js +11 -0
  50. package/dist/mdx.js +227 -0
  51. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +40 -21
  52. package/dist/packages/charts/src/cartesian/bar-data.d.ts +15 -4
  53. package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +7 -3
  54. package/dist/packages/charts/src/cartesian/breakdown-bar.d.ts +10 -8
  55. package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +20 -16
  56. package/dist/packages/charts/src/cartesian/bridge-data.d.ts +5 -4
  57. package/dist/packages/charts/src/cartesian/composition-bars.d.ts +8 -4
  58. package/dist/packages/charts/src/cartesian/index.d.ts +5 -5
  59. package/dist/packages/charts/src/cartesian/reference-lines.d.ts +25 -18
  60. package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +30 -25
  61. package/dist/packages/charts/src/cartesian/sparkline.d.ts +14 -2
  62. package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +3 -2
  63. package/dist/packages/charts/src/cartesian/time-series-data.d.ts +12 -2
  64. package/dist/packages/charts/src/cartesian/time-series-line.d.ts +2 -2
  65. package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +6 -4
  66. package/dist/packages/charts/src/cartesian/time-series.d.ts +60 -36
  67. package/dist/packages/charts/src/cartesian/value-labels.d.ts +22 -0
  68. package/dist/packages/charts/src/categorical-values.d.ts +1 -1
  69. package/dist/packages/charts/src/cells/bar-cell.d.ts +13 -0
  70. package/dist/packages/charts/src/cells/cell-layout.d.ts +81 -0
  71. package/dist/packages/charts/src/cells/change-cell.d.ts +17 -0
  72. package/dist/packages/charts/src/cells/heat-cell.d.ts +19 -0
  73. package/dist/packages/charts/src/cells/index.d.ts +11 -0
  74. package/dist/packages/charts/src/cells/interval-cell.d.ts +16 -0
  75. package/dist/packages/charts/src/cells/spark-cell.d.ts +22 -0
  76. package/dist/packages/charts/src/chart-frame.d.ts +14 -7
  77. package/dist/packages/charts/src/chart-grid.d.ts +19 -0
  78. package/dist/packages/charts/src/chart-input.d.ts +1 -9
  79. package/dist/packages/charts/src/chart-link.d.ts +56 -0
  80. package/dist/packages/charts/src/chart.d.ts +0 -8
  81. package/dist/packages/charts/src/comparison/bullet-bar.d.ts +34 -0
  82. package/dist/packages/charts/src/comparison/comparison-plot.d.ts +54 -0
  83. package/dist/packages/charts/src/comparison/dot-plot.d.ts +41 -0
  84. package/dist/packages/charts/src/comparison/dumbbell-plot.d.ts +33 -0
  85. package/dist/packages/charts/src/comparison/index.d.ts +6 -0
  86. package/dist/packages/charts/src/distribution/box-plot.d.ts +40 -0
  87. package/dist/packages/charts/src/distribution/distribution-input.d.ts +5 -3
  88. package/dist/packages/charts/src/distribution/distribution-plot.d.ts +28 -161
  89. package/dist/packages/charts/src/distribution/ecdf.d.ts +16 -15
  90. package/dist/packages/charts/src/distribution/group-plot-input.d.ts +35 -0
  91. package/dist/packages/charts/src/distribution/group-plot-layout.d.ts +79 -0
  92. package/dist/packages/charts/src/distribution/group-plot.d.ts +73 -0
  93. package/dist/packages/charts/src/distribution/histogram.d.ts +16 -16
  94. package/dist/packages/charts/src/distribution/index.d.ts +11 -0
  95. package/dist/packages/charts/src/distribution/interval-plot.d.ts +16 -13
  96. package/dist/packages/charts/src/distribution/ranked-bars.d.ts +17 -14
  97. package/dist/packages/charts/src/distribution/ridgeline.d.ts +34 -0
  98. package/dist/packages/charts/src/distribution/strip-plot.d.ts +37 -0
  99. package/dist/packages/charts/src/distribution/violin-plot.d.ts +34 -0
  100. package/dist/packages/charts/src/figure/figure-format.d.ts +34 -0
  101. package/dist/packages/charts/src/figure/figure-frame.d.ts +47 -0
  102. package/dist/packages/charts/src/figure/figure-props.d.ts +54 -0
  103. package/dist/packages/charts/src/figure/tone-scope.d.ts +32 -0
  104. package/dist/packages/charts/src/graph/attribution-graph.d.ts +62 -0
  105. package/dist/packages/charts/src/graph/attribution-layout.d.ts +88 -0
  106. package/dist/packages/charts/src/graph/flow-diagram.d.ts +14 -15
  107. package/dist/packages/charts/src/graph/flow-layout.d.ts +4 -2
  108. package/dist/packages/charts/src/graph/graph-canvas.d.ts +33 -0
  109. package/dist/packages/charts/src/graph/index.d.ts +6 -2
  110. package/dist/packages/charts/src/graph/relation-graph.d.ts +24 -13
  111. package/dist/packages/charts/src/graph/tree-diagram.d.ts +41 -0
  112. package/dist/packages/charts/src/graph/tree-layout.d.ts +71 -0
  113. package/dist/packages/charts/src/hierarchy/area-mark.d.ts +17 -0
  114. package/dist/packages/charts/src/hierarchy/icicle.d.ts +35 -0
  115. package/dist/packages/charts/src/hierarchy/index.d.ts +2 -0
  116. package/dist/packages/charts/src/hierarchy/partition-layout.d.ts +25 -0
  117. package/dist/packages/charts/src/hierarchy/treemap-layout.d.ts +26 -0
  118. package/dist/packages/charts/src/hierarchy/treemap.d.ts +11 -9
  119. package/dist/packages/charts/src/image/attribution-legend.d.ts +13 -0
  120. package/dist/packages/charts/src/image/attribution-overlay.d.ts +50 -0
  121. package/dist/packages/charts/src/image/attribution-ramp.d.ts +16 -0
  122. package/dist/packages/charts/src/image/image-atlas.d.ts +37 -0
  123. package/dist/packages/charts/src/image/image-fill.d.ts +9 -0
  124. package/dist/packages/charts/src/image/image-grid.d.ts +26 -0
  125. package/dist/packages/charts/src/image/image-input.d.ts +27 -0
  126. package/dist/packages/charts/src/image/image-tile.d.ts +27 -0
  127. package/dist/packages/charts/src/image/index.d.ts +7 -0
  128. package/dist/packages/charts/src/index.d.ts +15 -1
  129. package/dist/packages/charts/src/matrix/attention-matrix.d.ts +41 -0
  130. package/dist/packages/charts/src/matrix/calendar-heatmap.d.ts +37 -0
  131. package/dist/packages/charts/src/matrix/color-legend.d.ts +9 -2
  132. package/dist/packages/charts/src/matrix/confusion-matrix.d.ts +36 -0
  133. package/dist/packages/charts/src/matrix/correlation-matrix.d.ts +34 -0
  134. package/dist/packages/charts/src/matrix/heatmap-scale.d.ts +8 -2
  135. package/dist/packages/charts/src/matrix/index.d.ts +15 -3
  136. package/dist/packages/charts/src/matrix/matrix-cells.d.ts +27 -3
  137. package/dist/packages/charts/src/matrix/matrix-figure.d.ts +50 -0
  138. package/dist/packages/charts/src/matrix/matrix-mark.d.ts +34 -0
  139. package/dist/packages/charts/src/matrix/matrix-presets.d.ts +20 -0
  140. package/dist/packages/charts/src/matrix/matrix-range.d.ts +45 -0
  141. package/dist/packages/charts/src/matrix/matrix-strip.d.ts +13 -14
  142. package/dist/packages/charts/src/matrix/matrix-types.d.ts +40 -0
  143. package/dist/packages/charts/src/matrix/matrix.d.ts +13 -11
  144. package/dist/packages/charts/src/matrix/token-heatmap.d.ts +16 -10
  145. package/dist/packages/charts/src/plot/contours.d.ts +45 -0
  146. package/dist/packages/charts/src/plot/index.d.ts +49 -0
  147. package/dist/packages/charts/src/plot/label-place.d.ts +35 -0
  148. package/dist/packages/charts/src/plot/locate.d.ts +18 -0
  149. package/dist/packages/charts/src/plot/path.d.ts +39 -0
  150. package/dist/packages/charts/src/plot/plot-axes.d.ts +20 -0
  151. package/dist/packages/charts/src/plot/plot-layout.d.ts +221 -0
  152. package/dist/packages/charts/src/plot/plot-marks.d.ts +128 -0
  153. package/dist/packages/charts/src/plot/plot-surface.d.ts +32 -0
  154. package/dist/packages/charts/src/plot/render/density-layer.d.ts +17 -0
  155. package/dist/packages/charts/src/plot/render/hit-index.d.ts +37 -0
  156. package/dist/packages/charts/src/plot/render/plot-viewport.d.ts +39 -0
  157. package/dist/packages/charts/src/plot/render/point-layer.d.ts +41 -0
  158. package/dist/packages/charts/src/plot/render/theme-colors.d.ts +15 -0
  159. package/dist/packages/charts/src/plot/scale.d.ts +48 -0
  160. package/dist/packages/charts/src/plot/ticks.d.ts +34 -0
  161. package/dist/packages/charts/src/plot-width.d.ts +3 -2
  162. package/dist/packages/charts/src/relationship/contour-plot.d.ts +61 -0
  163. package/dist/packages/charts/src/relationship/density-map.d.ts +45 -0
  164. package/dist/packages/charts/src/relationship/embedding-map.d.ts +75 -0
  165. package/dist/packages/charts/src/relationship/index.d.ts +11 -0
  166. package/dist/packages/charts/src/relationship/level-legend.d.ts +11 -0
  167. package/dist/packages/charts/src/relationship/measures.d.ts +85 -0
  168. package/dist/packages/charts/src/relationship/parallel-coordinates.d.ts +30 -0
  169. package/dist/packages/charts/src/relationship/range-controls.d.ts +20 -0
  170. package/dist/packages/charts/src/relationship/scatter-matrix.d.ts +20 -0
  171. package/dist/packages/charts/src/spec/chart-guide.d.ts +21 -0
  172. package/dist/packages/charts/src/spec/figure-registry.d.ts +44 -0
  173. package/dist/packages/charts/src/spec/figure-spec.d.ts +147 -0
  174. package/dist/packages/charts/src/spec/figure-text.d.ts +8 -0
  175. package/dist/packages/charts/src/spec/figure.d.ts +12 -0
  176. package/dist/packages/charts/src/spec/guide-data.d.ts +85 -0
  177. package/dist/packages/charts/src/spec/index.d.ts +10 -0
  178. package/dist/packages/charts/src/spec/validate-figure.d.ts +15 -0
  179. package/dist/packages/charts/src/text/index.d.ts +11 -0
  180. package/dist/packages/charts/src/text/token-examples.d.ts +42 -0
  181. package/dist/packages/charts/src/text/token-grid.d.ts +47 -0
  182. package/dist/packages/charts/src/text/token-links.d.ts +49 -0
  183. package/dist/packages/charts/src/text/token-predictions.d.ts +38 -0
  184. package/dist/packages/charts/src/text/token-scale.d.ts +20 -0
  185. package/dist/packages/charts/src/text/token-text.d.ts +39 -0
  186. package/dist/packages/charts/src/timeline/event-strip.d.ts +70 -0
  187. package/dist/packages/charts/src/timeline/index.d.ts +3 -1
  188. package/dist/packages/charts/src/timeline/waterfall.d.ts +24 -13
  189. package/dist/packages/charts/src/transforms/bins.d.ts +91 -0
  190. package/dist/packages/charts/src/transforms/density.d.ts +53 -0
  191. package/dist/packages/charts/src/transforms/fits.d.ts +50 -0
  192. package/dist/packages/charts/src/transforms/index.d.ts +19 -0
  193. package/dist/packages/charts/src/transforms/matrices.d.ts +49 -0
  194. package/dist/packages/charts/src/transforms/quantiles.d.ts +96 -0
  195. package/dist/packages/charts/src/transforms/ranks.d.ts +44 -0
  196. package/dist/packages/charts/src/transforms/runs.d.ts +47 -0
  197. package/dist/packages/charts/src/transforms/sampling.d.ts +75 -0
  198. package/dist/packages/charts/src/transforms/smoothing.d.ts +41 -0
  199. package/dist/packages/charts/src/transforms/values.d.ts +70 -0
  200. package/dist/packages/charts/src/trend/bump-chart.d.ts +33 -0
  201. package/dist/packages/charts/src/trend/column-figure.d.ts +38 -0
  202. package/dist/packages/charts/src/trend/column-positions.d.ts +21 -0
  203. package/dist/packages/charts/src/trend/curve-chart.d.ts +69 -0
  204. package/dist/packages/charts/src/trend/end-labels.d.ts +40 -0
  205. package/dist/packages/charts/src/trend/horizon-chart.d.ts +37 -0
  206. package/dist/packages/charts/src/trend/index.d.ts +10 -0
  207. package/dist/packages/charts/src/trend/line-locate.d.ts +21 -0
  208. package/dist/packages/charts/src/trend/runs-chart.d.ts +50 -0
  209. package/dist/packages/charts/src/trend/slope-chart.d.ts +35 -0
  210. package/dist/packages/kits/src/evaluation/evaluation-data.d.ts +31 -0
  211. package/dist/packages/kits/src/evaluation/index.d.ts +8 -0
  212. package/dist/packages/kits/src/evaluation/leaderboard-cells.d.ts +62 -0
  213. package/dist/packages/kits/src/evaluation/leaderboard.d.ts +59 -0
  214. package/dist/packages/kits/src/evaluation/model-comparison.d.ts +59 -0
  215. package/dist/packages/kits/src/evaluation/score-breakdown.d.ts +33 -0
  216. package/dist/packages/kits/src/interpretability/attention-head-grid.d.ts +56 -0
  217. package/dist/packages/kits/src/interpretability/attribution-workbench.d.ts +29 -0
  218. package/dist/packages/kits/src/interpretability/embedding-atlas.d.ts +41 -0
  219. package/dist/packages/kits/src/interpretability/feature-card.d.ts +33 -0
  220. package/dist/packages/kits/src/interpretability/feature-list.d.ts +51 -0
  221. package/dist/packages/kits/src/interpretability/feature-logits.d.ts +23 -0
  222. package/dist/packages/kits/src/interpretability/features.d.ts +70 -0
  223. package/dist/packages/kits/src/interpretability/index.d.ts +16 -0
  224. package/dist/packages/kits/src/interpretability/kit-styles.d.ts +118 -0
  225. package/dist/packages/kits/src/interpretability/logit-lens.d.ts +50 -0
  226. package/dist/packages/kits/src/interpretability/node-panel.d.ts +32 -0
  227. package/dist/packages/kits/src/interpretability/shared-link.d.ts +8 -0
  228. package/dist/packages/kits/src/interpretability/steering-panel.d.ts +52 -0
  229. package/dist/packages/kits/src/operations/budget-board.d.ts +49 -0
  230. package/dist/packages/kits/src/operations/incident-timeline.d.ts +30 -0
  231. package/dist/packages/kits/src/operations/index.d.ts +6 -0
  232. package/dist/packages/kits/src/operations/service-health.d.ts +66 -0
  233. package/dist/packages/kits/src/training/index.d.ts +8 -0
  234. package/dist/packages/kits/src/training/run-dashboard.d.ts +49 -0
  235. package/dist/packages/kits/src/training/run-legend.d.ts +21 -0
  236. package/dist/packages/kits/src/training/run-marker.d.ts +5 -0
  237. package/dist/packages/kits/src/training/run-state.d.ts +7 -0
  238. package/dist/packages/kits/src/training/run-table.d.ts +63 -0
  239. package/dist/packages/kits/src/training/runs-overview.d.ts +20 -0
  240. package/dist/packages/kits/src/training/runs.d.ts +34 -0
  241. package/dist/packages/teaching/src/agent/index.d.ts +11 -0
  242. package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
  243. package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
  244. package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
  245. package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
  246. package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
  247. package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
  248. package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
  249. package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
  250. package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
  251. package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
  252. package/dist/packages/teaching/src/article/article.d.ts +42 -0
  253. package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
  254. package/dist/packages/teaching/src/article/beat.d.ts +16 -0
  255. package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
  256. package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
  257. package/dist/packages/teaching/src/article/figure.d.ts +51 -0
  258. package/dist/packages/teaching/src/article/index.d.ts +31 -0
  259. package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
  260. package/dist/packages/teaching/src/article/linked-target.d.ts +22 -0
  261. package/dist/packages/teaching/src/article/notes.d.ts +36 -0
  262. package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
  263. package/dist/packages/teaching/src/article/predict.d.ts +58 -0
  264. package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
  265. package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
  266. package/dist/packages/teaching/src/article/term.d.ts +35 -0
  267. package/dist/packages/teaching/src/article/tex.d.ts +12 -0
  268. package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
  269. package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
  270. package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
  271. package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
  272. package/dist/packages/teaching/src/article/walk.d.ts +34 -0
  273. package/dist/packages/teaching/src/lesson/bound-value.d.ts +29 -0
  274. package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
  275. package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
  276. package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
  277. package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
  278. package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
  279. package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
  280. package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
  281. package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
  282. package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
  283. package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
  284. package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
  285. package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
  286. package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
  287. package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
  288. package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
  289. package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
  290. package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
  291. package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
  292. package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
  293. package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
  294. package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
  295. package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
  296. package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
  297. package/dist/packages/teaching/src/scene/index.d.ts +77 -0
  298. package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
  299. package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
  300. package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
  301. package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
  302. package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
  303. package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
  304. package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
  305. package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
  306. package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
  307. package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
  308. package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
  309. package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
  310. package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
  311. package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
  312. package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
  313. package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
  314. package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
  315. package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
  316. package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
  317. package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
  318. package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
  319. package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
  320. package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
  321. package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
  322. package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
  323. package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
  324. package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
  325. package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
  326. package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
  327. package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
  328. package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
  329. package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
  330. package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
  331. package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
  332. package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
  333. package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
  334. package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
  335. package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
  336. package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
  337. package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
  338. package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
  339. package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
  340. package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
  341. package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
  342. package/dist/packages/teaching/src/spec/index.d.ts +14 -0
  343. package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
  344. package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
  345. package/dist/packages/teaching/src/time/clock.d.ts +7 -0
  346. package/dist/packages/teaching/src/time/tween.d.ts +19 -0
  347. package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
  348. package/dist/param-CqKUTHaO.js +450 -0
  349. package/dist/path-BglsXpnO.js +59 -0
  350. package/dist/plot-axes-DJkLW4wk.js +100 -0
  351. package/dist/plot-layout-CZVSJ-le.js +912 -0
  352. package/dist/plot-marks-uozcbOIX.js +229 -0
  353. package/dist/plot-surface-CbVBvgqZ.js +51 -0
  354. package/dist/plot-width-DcqtSgzb.js +124 -0
  355. package/dist/point-layer-C-EYETAt.js +655 -0
  356. package/dist/reference-lines-BDcttOp0.js +82 -0
  357. package/dist/scale-C2xgZyZN.js +63 -0
  358. package/dist/scene-0z2gbaDE.js +4938 -0
  359. package/dist/scene.js +1 -0
  360. package/dist/slope-chart-BKVEAVCs.js +1279 -0
  361. package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
  362. package/dist/{src-DVHlknB6.js → src-CExIrXPC.js} +169 -193
  363. package/dist/src-DIS0YOj0.js +44 -0
  364. package/dist/src-Dcfq8vE4.js +2195 -0
  365. package/dist/styles2.css +907 -59
  366. package/dist/time-series-BgzGNOk0.js +2670 -0
  367. package/dist/token-heatmap-BrW1OsKD.js +1354 -0
  368. package/dist/token-predictions-yerq_Oet.js +1093 -0
  369. package/dist/tone-scope-DKiSw-JR.js +32 -0
  370. package/dist/transport-BJweqDPj.js +715 -0
  371. package/dist/tree-diagram-D09BRqE-.js +1629 -0
  372. package/dist/treemap-CW4WsJNL.js +472 -0
  373. package/dist/use-tween-5HZ55_9d.js +72 -0
  374. package/dist/values-963L6n1m.js +65 -0
  375. package/dist/violin-plot-DrtPZ1-T.js +1292 -0
  376. package/dist/waterfall-DYLSnGjm.js +576 -0
  377. package/package.json +78 -4
  378. package/recipes/allocation-report.tsx +15 -7
  379. package/recipes/counting-cards.tsx +656 -0
  380. package/recipes/explorable-essay.tsx +172 -0
  381. package/skills/extend-elements/SKILL.md +81 -0
  382. package/skills/plan-lesson/SKILL.md +86 -0
  383. package/skills/plan-lesson/references/plan-format.md +114 -0
  384. package/skills/plan-lesson/references/worked-plan.md +171 -0
  385. package/skills/review-elements/SKILL.md +47 -3
  386. package/skills/review-explainer/SKILL.md +97 -0
  387. package/skills/upgrade-elements/SKILL.md +3 -1
  388. package/skills/upgrade-elements/references/releases.md +249 -0
  389. package/skills/use-elements/SKILL.md +22 -14
  390. package/skills/use-elements/references/charts.md +362 -41
  391. package/skills/use-elements/references/figures.md +173 -0
  392. package/skills/use-elements/references/kits.md +180 -0
  393. package/skills/use-elements/references/teaching.md +36 -0
  394. package/skills/write-explainer/SKILL.md +112 -0
  395. package/skills/write-explainer/references/article.md +164 -0
  396. package/skills/write-explainer/references/lesson.md +148 -0
  397. package/skills/write-explainer/references/mdx.md +78 -0
  398. package/skills/write-explainer/references/scene-parts.md +273 -0
  399. package/skills/write-explainer/references/scene.md +168 -0
  400. package/skills/write-explainer/references/tutor.md +104 -0
  401. package/skills/write-explainer/references/worked-essay.md +459 -0
  402. package/templates/essay/AGENTS.md +14 -0
  403. package/templates/essay/README.md +59 -0
  404. package/templates/essay/index.html +17 -0
  405. package/templates/essay/package.template.json +21 -0
  406. package/templates/essay/plan.json +96 -0
  407. package/templates/essay/src/essay.mdx +97 -0
  408. package/templates/essay/src/figures.tsx +92 -0
  409. package/templates/essay/src/lesson.ts +83 -0
  410. package/templates/essay/src/main.tsx +53 -0
  411. package/templates/essay/src/mdx.d.ts +7 -0
  412. package/templates/essay/tsconfig.template.json +15 -0
  413. package/templates/essay/vite.config.template.txt +8 -0
  414. package/dist/categorical-values-BXi-rJuv.js +0 -74
  415. package/dist/chart-data-CIJVWCYt.js +0 -21
  416. package/dist/chart-frame-BaxKn_MB.js +0 -236
  417. package/dist/chart-input-Bm82_9Rd.js +0 -22
  418. package/dist/chart-theme-4zprJ3rW.js +0 -404
  419. package/dist/plot-width-v2c_rA20.js +0 -63
@@ -1,2958 +1 @@
1
- import { c as e, f as t, l as n, p as r } from "../src-DVHlknB6.js";
2
- import { a as i, i as a, n as o, r as s, t as c } from "../categorical-values-BXi-rJuv.js";
3
- import { t as l } from "../chart-cursor-1mFd48Jc.js";
4
- import { t as u } from "../chart-data-CIJVWCYt.js";
5
- import { i as d, r as f, t as p } from "../chart-frame-BaxKn_MB.js";
6
- import { n as m, r as h, t as g } from "../chart-input-Bm82_9Rd.js";
7
- import { r as _ } from "../tokens.stylex-dF5CACEJ.js";
8
- import { a as v, c as y, i as b, l as ee, n as x, r as S, s as C, t as w } from "../chart-theme-4zprJ3rW.js";
9
- import { t as T } from "../plot-width-v2c_rA20.js";
10
- import { t as E } from "../label-spacing-BncjePGb.js";
11
- import { k as D } from "../src-CpdJlDhO.js";
12
- import { g as O } from "../src-1EHkSFS-.js";
13
- import * as k from "@stylexjs/stylex";
14
- import { createParts as A } from "@ui-sdk/react/primitive";
15
- import { useEffect as j, useId as M, useMemo as N, useRef as P, useState as F } from "react";
16
- import { bindDrag as I, createChange as L, createSpans as R, definePrimitive as te, dispatch as ne } from "@ui-sdk/core";
17
- import { Fragment as z, jsx as B, jsxs as V } from "react/jsx-runtime";
18
- import { scaleBand as re, scaleLinear as H } from "@visx/scale";
19
- import { Area as ie, AreaClosed as ae, Bar as oe, LinePath as se } from "@visx/shape";
20
- // packages/charts/src/chart-inspection.tsx
21
- var U = {
22
- kzqmXN: "x1xc55vz",
23
- kZKoxP: "xdk7pt",
24
- kmuXW: "x2lah0s",
25
- $$css: !0
26
- }, W = {
27
- swatch: (e) => [
28
- U,
29
- {
30
- kWkggS: e == null ? e : "xl8spv7",
31
- $$css: !0
32
- },
33
- { "--x-backgroundColor": e ?? void 0 }
34
- ],
35
- inspector: {
36
- k1xSpc: "xrvj5dj x1boff50",
37
- kOIVth: "xunmzkg",
38
- kVAEAm: "x10l6tqk",
39
- k87sOh: "x1ridm32",
40
- kB7OPa: "x9f619",
41
- kfzvcC: "x47corl",
42
- kmVPX3: "x69ldcm",
43
- kMzoRj: "xmkeg23",
44
- ksu8eU: "x1y0btm7",
45
- kVAM5u: "x1ey3b81",
46
- kaIpWk: "x1ok0vyi",
47
- kGVxlE: "x1ghndwu",
48
- kWkggS: "xpvm0e4",
49
- kMwMTN: "xbixft",
50
- kGuDYH: "xy8obcc",
51
- kLWn49: "xas2l8k",
52
- kcqcaj: "xss6m8b",
53
- kHjlTd: "xj0a0fe",
54
- $$css: !0
55
- },
56
- summaryInspector: {
57
- k1xSpc: "xrvj5dj x1xnx9c1",
58
- $$css: !0
59
- },
60
- position: (e, t) => [{
61
- kbCHJM: e == null ? e : "xgq9j65",
62
- kzqmXN: t == null ? t : "x5lhr3w",
63
- $$css: !0
64
- }, {
65
- "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
66
- "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
67
- }]
68
- }, G = 4;
69
- function K() {
70
- return /* @__PURE__ */ B("ul", {
71
- "aria-hidden": !0,
72
- inert: !0,
73
- className: "x78zum5 x1xnx9c1 xnby9oq x1a02dak x8zbtdt x1gkm1c7 x1ghz6dp x1717udv xe8uvvx x153jb6y xy8obcc xas2l8k",
74
- children: Array.from({ length: G }, (e, t) => /* @__PURE__ */ V("li", {
75
- className: "x78zum5 x1pha0wt xunmzkg xeuugli xj0a0fe x1f394nn x43dure",
76
- children: [/* @__PURE__ */ B("span", { ...k.props(W.swatch(_.line)) }), /* @__PURE__ */ V("span", {
77
- className: "x1cqoux5 xeuugli",
78
- children: [
79
- /* @__PURE__ */ B(r, {}),
80
- /* @__PURE__ */ B("span", {
81
- className: "x1s85apg xannxpe",
82
- children: /* @__PURE__ */ B(r, {})
83
- }),
84
- /* @__PURE__ */ B("span", {
85
- className: "x1s85apg xannxpe x1mqbd49 xbixft xss6m8b",
86
- children: /* @__PURE__ */ B(r, {})
87
- })
88
- ]
89
- })]
90
- }, t))
91
- });
92
- }
93
- function ce({ title: e, detail: t }) {
94
- return t === void 0 ? e : /* @__PURE__ */ V("span", {
95
- "aria-label": e,
96
- className: "x1lliihq xb3r6kr xlyipyv xuxw1ft",
97
- children: [/* @__PURE__ */ B("span", {
98
- className: "xt0psk2 x1boff50",
99
- children: e
100
- }), /* @__PURE__ */ B("span", {
101
- className: "x1s85apg xfodcyb",
102
- children: t
103
- })]
104
- });
105
- }
106
- function le({ label: e, summary: t, rows: n, notes: r = [] }) {
107
- if (e !== void 0) return [
108
- e,
109
- t,
110
- ...n.map((e) => `${e.label}: ${e.value}`),
111
- ...r
112
- ].filter((e) => e !== void 0).join(" · ");
113
- }
114
- function ue({ id: e, label: t, summary: n, legend: r, layoutLegend: i, rows: a, x: o, width: s, offset: c = 16, notes: l = [], hasSeriesSummary: u = !1, hasLegend: f = !0 }) {
115
- let p = f && !u, m = Math.min(260, s), h = o > s / 2 ? o - m - c : o + c, g = Math.max(0, Math.min(s - m, h));
116
- return /* @__PURE__ */ V("div", {
117
- className: "xeuugli",
118
- children: [
119
- p && /* @__PURE__ */ V("div", {
120
- className: "xrvj5dj xeuugli",
121
- children: [i !== void 0 && /* @__PURE__ */ B("ul", {
122
- "aria-hidden": !0,
123
- inert: !0,
124
- className: "x78zum5 x1xnx9c1 xnby9oq x1a02dak x8zbtdt x1gkm1c7 x1ghz6dp x1717udv xe8uvvx x153jb6y xy8obcc xas2l8k x15r89dc xlshs6z x47corl",
125
- children: i.map((e) => /* @__PURE__ */ V("li", {
126
- className: "x78zum5 x1pha0wt xunmzkg xeuugli xj0a0fe",
127
- children: [/* @__PURE__ */ B(d, {
128
- tone: e.tone,
129
- shape: e.shape
130
- }), /* @__PURE__ */ V("span", {
131
- className: "xeuugli",
132
- children: [e.label, /* @__PURE__ */ B("span", { className: "x1s85apg xannxpe x1mqbd49 xbixft xss6m8b" })]
133
- })]
134
- }, e.id))
135
- }), /* @__PURE__ */ B("ul", {
136
- "aria-label": "Legend",
137
- className: "x78zum5 x1xnx9c1 xnby9oq x1a02dak x8zbtdt x1gkm1c7 x1ghz6dp x1717udv xe8uvvx x153jb6y xy8obcc xas2l8k x15r89dc",
138
- children: r.map((e) => /* @__PURE__ */ V("li", {
139
- className: "x78zum5 x1pha0wt xunmzkg xeuugli xj0a0fe",
140
- children: [/* @__PURE__ */ B(d, {
141
- tone: e.tone,
142
- shape: e.shape
143
- }), /* @__PURE__ */ V("span", {
144
- className: "xeuugli",
145
- children: [e.label, /* @__PURE__ */ B("span", {
146
- className: "x1s85apg xannxpe x1mqbd49 xbixft xss6m8b",
147
- children: t === void 0 ? "" : a.find((t) => t.id === e.id)?.value ?? "—"
148
- })]
149
- })]
150
- }, e.id))
151
- })]
152
- }),
153
- /* @__PURE__ */ B("span", {
154
- id: e,
155
- className: "x10l6tqk x1i1rx1s xjm9jq1 x1717udv xb3r6kr x1hyvwdk xuxw1ft",
156
- children: le({
157
- label: t,
158
- summary: n,
159
- rows: a,
160
- notes: l
161
- })
162
- }),
163
- t !== void 0 && /* @__PURE__ */ B("div", {
164
- "aria-hidden": !0,
165
- className: "x1n2onr6 xqtp20y x1vjfegm",
166
- children: /* @__PURE__ */ V("div", {
167
- ...k.props(W.inspector, !p && W.summaryInspector, W.position(g, m)),
168
- children: [
169
- /* @__PURE__ */ V("div", {
170
- className: "x78zum5 x1qughib x1hnptsi xk4h15q",
171
- children: [/* @__PURE__ */ B("span", { children: t }), n !== void 0 && /* @__PURE__ */ B("span", { children: n })]
172
- }),
173
- /* @__PURE__ */ B("dl", {
174
- className: "xrvj5dj xunmzkg x1ghz6dp",
175
- children: a.map((e) => /* @__PURE__ */ V("div", {
176
- className: "x78zum5 x1qughib x1pha0wt x1hnptsi",
177
- children: [/* @__PURE__ */ V("dt", {
178
- className: "x78zum5 x1pha0wt xunmzkg xeuugli xj0a0fe",
179
- children: [/* @__PURE__ */ B(d, {
180
- tone: e.tone,
181
- shape: e.shape
182
- }), e.label]
183
- }), /* @__PURE__ */ B("dd", {
184
- className: "x1ghz6dp xuxw1ft",
185
- children: e.value
186
- })]
187
- }, e.id))
188
- }),
189
- l.map((e) => /* @__PURE__ */ B("span", { children: e }, e))
190
- ]
191
- })
192
- })
193
- ]
194
- });
195
- }
196
- // packages/charts/src/cartesian/bar-data.ts
197
- function de({ composition: e, series: t, categoryIds: n, domain: r }) {
198
- if (e === void 0) return;
199
- if (e.buckets.length !== n.length) return "Composition requires one explicit bucket per category.";
200
- let i = e.annotation;
201
- if (i !== void 0) {
202
- if (!n.includes(i.categoryId) || !Number.isFinite(i.value)) return "A bar annotation requires an existing category and a finite value.";
203
- if (i.value < r[0] || i.value > r[1]) return "A bar annotation must fit the supplied domain.";
204
- }
205
- for (let [n, i] of e.buckets.entries()) if (i.kind !== "gap") {
206
- if (!Number.isFinite(i.total) || i.total < r[0] || i.total > r[1]) return "Context totals must be finite and inside the supplied domain.";
207
- if (i.kind === "parts") {
208
- let e = t.map((e) => e.values[n]);
209
- if (e.some((e) => e != null && e < 0)) return "Composition parts require nonnegative reported values.";
210
- if (e.reduce((e, t) => e + (t ?? 0), 0) > r[1] || i.total < 0) return "Composition parts must fit the supplied positive domain.";
211
- }
212
- }
213
- }
214
- var q = 6;
215
- function fe(e, t) {
216
- return e === null ? !0 : e === void 0 || !Number.isFinite(e) ? !1 : e >= t[0] && e <= t[1];
217
- }
218
- function J({ marker: e, categoryCount: t, domain: n }) {
219
- let r = e.kind === "tick" ? [e.values] : [e.lower, e.upper];
220
- if (r.some((e) => e.length !== t)) return "Every bar marker requires one explicit value per category.";
221
- if (r.some((e) => e.some((e) => !fe(e, n)))) return "Bar marker values must be finite and within the supplied domain.";
222
- if (e.kind === "range") for (let [t, n] of e.lower.entries()) {
223
- let r = e.upper[t] ?? null;
224
- if (n === null != (r === null) || n !== null && r !== null && n > r) return "A range marker needs both bounds, with the lower bound at most the upper bound, or neither.";
225
- }
226
- }
227
- function Y({ markers: e, annotations: t, emphasizedCategoryIds: n, seriesIds: r, categoryIds: i, domain: a }) {
228
- if (e.length > q) return `Supply at most ${q} bar markers.`;
229
- let o = [...e, ...t];
230
- if (new Set(o.map((e) => e.id)).size !== o.length || r.some((e) => o.some((t) => t.id === e))) return "Bar series, markers, and annotations require distinct identifiers.";
231
- for (let t of e) {
232
- if (!r.includes(t.seriesId)) return "Each bar marker must refer to a supplied series.";
233
- let e = J({
234
- marker: t,
235
- categoryCount: i.length,
236
- domain: a
237
- });
238
- if (e !== void 0) return e;
239
- }
240
- for (let e of t) {
241
- let t = e.seriesId === void 0 || r.includes(e.seriesId), n = e.label.trim() !== "";
242
- if (!(i.includes(e.categoryId) && t && n)) return "Each bar annotation needs a label, a supplied category, and a supplied series when it names one.";
243
- }
244
- if (new Set(t.map((e) => JSON.stringify([e.categoryId, e.seriesId ?? null]))).size !== t.length) return "Each bar can hold one annotation.";
245
- if (new Set(n).size !== n.length || n.some((e) => !i.includes(e))) return "Emphasized categories must be unique supplied categories.";
246
- }
247
- function pe({ marker: e, index: t, formatValue: n }) {
248
- if (e.kind === "tick") {
249
- let r = e.values[t] ?? null;
250
- return r === null ? "Unavailable" : n(r);
251
- }
252
- let r = e.lower[t] ?? null, i = e.upper[t] ?? null;
253
- return r === null || i === null ? "Unavailable" : `${n(r)} – ${n(i)}`;
254
- }
255
- function me(e, t) {
256
- return e.kind === "tick" ? e.values[t] ?? null : e.upper[t] ?? null;
257
- }
258
- // packages/charts/src/cartesian/bar-overlays.tsx
259
- var he = {
260
- kU5bRw: "x5lxx2x",
261
- kREpy8: "x13efnbd",
262
- $$css: !0
263
- }, ge = { stroke: (e) => [
264
- he,
265
- {
266
- kjVXCG: e == null ? e : "x6mkzkt",
267
- $$css: !0
268
- },
269
- { "--x-stroke": e ?? void 0 }
270
- ] }, _e = 3, X = 1, ve = 1.5, Z = 3, ye = 14, be = 6.5;
271
- function Q({ path: e, color: t, width: n }) {
272
- return /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B("path", {
273
- d: e,
274
- strokeWidth: n + 4,
275
- className: "xaep1og x5lxx2x x13efnbd"
276
- }), /* @__PURE__ */ B("path", {
277
- d: e,
278
- strokeWidth: n,
279
- ...k.props(ge.stroke(t))
280
- })] });
281
- }
282
- function xe({ marker: e, index: t, span: n, base: r, y: i }) {
283
- let a = e.kind === "tick" ? e.values[t] ?? null : null;
284
- if (a !== null && r !== null && a !== r) return `M${n.x + n.width / 2},${i(r)} V${i(a)}`;
285
- }
286
- function Se({ marker: e, index: t, span: n, y: r }) {
287
- if (e.kind === "tick") {
288
- let i = e.values[t] ?? null;
289
- if (i === null) return;
290
- let a = r(i);
291
- return `M${n.x - Z},${a} H${n.x + n.width + Z}`;
292
- }
293
- let i = e.lower[t] ?? null, a = e.upper[t] ?? null;
294
- if (i === null || a === null) return;
295
- let o = n.x + n.width / 2, s = Math.min(ye, n.width * .6) / 2, c = r(i), l = r(a);
296
- return `M${o - s},${l} H${o + s} M${o},${l} V${c} M${o - s},${c} H${o + s}`;
297
- }
298
- function Ce({ markers: t, categoryIds: n, span: r, barTop: i, y: a, isReceded: o }) {
299
- return /* @__PURE__ */ B("g", { children: t.map((t) => /* @__PURE__ */ B("g", { children: n.map((n, s) => {
300
- let c = r(n, t.seriesId), l = Se({
301
- marker: t,
302
- index: s,
303
- span: c,
304
- y: a
305
- });
306
- if (l === void 0) return null;
307
- let u = e[t.tone ?? "neutral"], d = xe({
308
- marker: t,
309
- index: s,
310
- span: c,
311
- base: i(s, t.seriesId),
312
- y: a
313
- });
314
- return /* @__PURE__ */ V("g", {
315
- ...k.props(w.emphasis, o(n) && w.receded),
316
- children: [d !== void 0 && /* @__PURE__ */ B(Q, {
317
- path: d,
318
- color: u,
319
- width: X
320
- }), /* @__PURE__ */ B(Q, {
321
- path: l,
322
- color: u,
323
- width: t.kind === "tick" ? _e : ve
324
- })]
325
- }, n);
326
- }) }, t.id)) });
327
- }
328
- function we({ annotations: e, left: t, right: n }) {
329
- return /* @__PURE__ */ B("g", {
330
- "aria-hidden": !0,
331
- children: e.map((e) => {
332
- let r = e.label.length * be / 2, i = e.x - r < t, a = e.x + r > n, o = i ? "start" : a ? "end" : "middle", s = i ? t : a ? n : e.x;
333
- return /* @__PURE__ */ B("text", {
334
- x: s,
335
- y: e.y,
336
- textAnchor: o,
337
- ...k.props(w.label, w.strongLabel, w.haloLabel, w.emphasis, e.isReceded && w.receded),
338
- children: e.label
339
- }, e.id);
340
- })
341
- });
342
- }
343
- // packages/charts/src/cartesian/composition-bars.tsx
344
- var Te = { mark: {
345
- k3nNDw: "x1hj3fc7",
346
- k1ekBW: "xwcsmn1",
347
- kIyJzY: "xtitasy x12w9bfk",
348
- kAMwcw: "x1faw7qm",
349
- $$css: !0
350
- } };
351
- function Ee({ bucket: t, series: r, focusedSeries: i, index: o, x: s, width: c, y: l, isSelected: u, highlightedSeriesId: d }) {
352
- let f = i !== void 0, p = i !== void 0 && !r.some((e) => e.id === i.id) ? [...r, i] : r;
353
- function m(e, t) {
354
- let n = l(t), r = l(t + e);
355
- return `translateY(${Math.min(n, r)}px) scaleY(${Math.max(+(e === 0), Math.abs(r - n))})`;
356
- }
357
- return /* @__PURE__ */ V(z, { children: [t.kind !== "gap" && /* @__PURE__ */ B("rect", {
358
- x: s,
359
- y: 0,
360
- width: c,
361
- height: 1,
362
- vectorEffect: "non-scaling-stroke",
363
- fill: e.neutral,
364
- ...k.props(Te.mark, u && w.selected),
365
- style: {
366
- transform: m(t.total, 0),
367
- opacity: f ? .18 : +(t.kind === "total")
368
- }
369
- }), p.map((l, p) => {
370
- let h = l.values[o];
371
- if (h == null) return null;
372
- let g = i?.id === l.id, _ = f ? 0 : r.slice(0, p).reduce((e, t) => e + (t.values[o] ?? 0), 0), v = f ? g : t.kind === "parts", y = !f && d !== void 0 && d !== l.id;
373
- return /* @__PURE__ */ B("rect", {
374
- x: s,
375
- y: 0,
376
- width: c,
377
- height: 1,
378
- vectorEffect: "non-scaling-stroke",
379
- fill: e[a(l.tone, p)],
380
- stroke: n[a(l.tone, p)],
381
- ...k.props(Te.mark, w.outlined, u && w.selected),
382
- style: {
383
- transform: m(h, _),
384
- opacity: v ? y ? .3 : 1 : 0
385
- }
386
- }, l.id);
387
- })] });
388
- }
389
- // packages/charts/src/cartesian/reference-lines.tsx
390
- var De = {
391
- kfJifR: "xhr4kjn",
392
- k5rJSQ: "x1dz65qj",
393
- kREpy8: "x13efnbd",
394
- $$css: !0
395
- }, Oe = {
396
- kfJifR: "xnpr05h",
397
- kREpy8: "x13efnbd",
398
- $$css: !0
399
- }, ke = {
400
- line: (e) => [
401
- De,
402
- {
403
- kjVXCG: e == null ? e : "x6mkzkt",
404
- $$css: !0
405
- },
406
- { "--x-stroke": e ?? void 0 }
407
- ],
408
- leader: (e) => [
409
- Oe,
410
- {
411
- kjVXCG: e == null ? e : "x6mkzkt",
412
- $$css: !0
413
- },
414
- { "--x-stroke": e ?? void 0 }
415
- ]
416
- }, Ae = 30, je = 13, Me = 8, Ne = 4, Pe = 6.5, Fe = 40, Ie = 112, Le = 16, Re = 8;
417
- function ze({ lines: e, domain: t }) {
418
- if (e.length > Re) return `Supply at most ${Re} reference lines.`;
419
- if (!m(e)) return "Reference lines require unique identifiers.";
420
- for (let n of e) if (!(Number.isFinite(n.value) && n.value >= t[0] && n.value <= t[1]) || n.label.trim() === "") return "Each reference line needs a label and a finite value inside the value domain.";
421
- }
422
- function Be(e) {
423
- return e.length > Le ? `${e.slice(0, 15)}…` : e;
424
- }
425
- function Ve({ lines: e, formatValue: t }) {
426
- if (e.length === 0) return 0;
427
- let n = Math.max(...e.map((e) => Math.max(Be(e.label).length, t(e.value).length)));
428
- return Math.min(Ie, Math.max(Fe, n * Pe)) + Me;
429
- }
430
- function He({ lines: e, y: t, top: n, bottom: r }) {
431
- let i = e.map((e) => ({
432
- line: e,
433
- position: t(e.value)
434
- })).toSorted((e, t) => e.position - t.position), a = E({
435
- positions: i.map((e) => e.position),
436
- gap: Ae,
437
- start: n + Ae / 2,
438
- end: r - Ae / 2
439
- });
440
- return i.map((e, t) => ({
441
- ...e,
442
- center: a[t] ?? e.position
443
- }));
444
- }
445
- function Ue({ lines: t, y: n, left: r, right: i, top: a, bottom: o, formatValue: s }) {
446
- return /* @__PURE__ */ B("g", { children: He({
447
- lines: t,
448
- y: n,
449
- top: a,
450
- bottom: o
451
- }).map(({ line: t, position: n, center: a }) => {
452
- let o = e[t.tone ?? "neutral"], c = i + Me;
453
- return /* @__PURE__ */ V("g", { children: [
454
- /* @__PURE__ */ B("line", {
455
- x1: r,
456
- x2: i,
457
- y1: n,
458
- y2: n,
459
- ...k.props(ke.line(o))
460
- }),
461
- /* @__PURE__ */ B("path", {
462
- d: `M${i},${n} L${i + Ne},${a} H${i + Ne + 1}`,
463
- fill: "none",
464
- ...k.props(ke.leader(o))
465
- }),
466
- /* @__PURE__ */ B("text", {
467
- x: c,
468
- y: a - 2,
469
- ...k.props(w.label, w.strongLabel),
470
- children: Be(t.label)
471
- }),
472
- /* @__PURE__ */ B("text", {
473
- x: c,
474
- y: a + je - 2,
475
- ...k.props(w.label),
476
- children: s(t.value)
477
- })
478
- ] }, t.id);
479
- }) });
480
- }
481
- // packages/charts/src/cartesian/bar-chart.tsx
482
- var We = {
483
- plot: {
484
- kqGvvJ: "x1we84gm",
485
- $$css: !0
486
- },
487
- mutedMark: {
488
- kSiTet: "xuzhngd",
489
- $$css: !0
490
- }
491
- }, Ge = 200, Ke = 12, qe = 30, Je = 8, Ye = 14;
492
- function Xe({ title: e, description: t, report: n, series: r, layoutSeries: i, markerLegend: o = [], notes: s, children: c, inspectionId: l, label: d, detail: f, summary: m, rows: h = [], x: g = 0, width: _ = 0, offset: v, figure: y, data: b, isLoading: ee = !1 }) {
493
- let x = r.map((e, t) => ({
494
- id: e.id,
495
- label: e.label,
496
- tone: a(e.tone, t)
497
- })), S = i?.map((e, t) => ({
498
- id: e.id,
499
- label: e.label,
500
- tone: a(e.tone, t)
501
- })), C = ee && r.length === 0 && n?.seriesValues === void 0;
502
- return /* @__PURE__ */ V(p, {
503
- figure: y,
504
- title: /* @__PURE__ */ B(ce, {
505
- title: e,
506
- detail: f
507
- }),
508
- description: t,
509
- report: n,
510
- series: x,
511
- children: [
512
- b !== void 0 && /* @__PURE__ */ B(u, { ...b }),
513
- C ? /* @__PURE__ */ B(K, {}) : /* @__PURE__ */ B(ue, {
514
- id: l,
515
- label: d,
516
- summary: m,
517
- legend: [...x, ...o],
518
- hasSeriesSummary: n?.seriesValues !== void 0,
519
- layoutLegend: S === void 0 ? void 0 : [...S, ...o],
520
- rows: h,
521
- notes: s,
522
- x: g,
523
- width: _,
524
- offset: v
525
- }),
526
- c
527
- ]
528
- });
529
- }
530
- function Ze({ title: e = "Loading chart", description: n, report: r, series: i = [], height: a = Ge }) {
531
- let o = Qe(a), s = M();
532
- return o === void 0 ? /* @__PURE__ */ B("div", {
533
- "aria-hidden": !0,
534
- inert: !0,
535
- children: /* @__PURE__ */ B(Xe, {
536
- title: e,
537
- description: n,
538
- report: r,
539
- series: i,
540
- inspectionId: s,
541
- isLoading: !0,
542
- children: /* @__PURE__ */ B("div", {
543
- ...k.props(w.plot, We.plot),
544
- children: /* @__PURE__ */ B(t, { height: a })
545
- })
546
- })
547
- }) : /* @__PURE__ */ B(g, {
548
- title: e,
549
- description: n,
550
- report: r,
551
- message: o
552
- });
553
- }
554
- function Qe(e) {
555
- if (!Number.isFinite(e) || e < 48) return "Chart height must be at least 48 pixels.";
556
- }
557
- function $e({ categories: e, series: t, domain: n, mode: r }) {
558
- if (e.length > s.items || t.length > s.series) return `Choose a window with at most ${s.items} categories and ${s.series} series.`;
559
- if (!h(n) || n[0] > 0 || n[1] < 0) return "The bar domain must be finite, increasing, and include zero.";
560
- if (!m(e) || !m(t)) return "Bar categories and series require unique identifiers.";
561
- for (let i of t) {
562
- if (i.values.length !== e.length) return "Every series requires one explicit value per category.";
563
- for (let e of i.values) {
564
- if (e !== null && (!Number.isFinite(e) || e < n[0] || e > n[1])) return "Bar values must be finite and within the supplied domain.";
565
- if (r === "stacked" && (e === null || e < 0)) return "Stacked bars require present nonnegative values.";
566
- }
567
- }
568
- if (r === "stacked" && e.some((e, r) => t.reduce((e, t) => e + (t.values[r] ?? 0), 0) > n[1])) return "Stacked bar totals must fit the supplied domain.";
569
- }
570
- var et = {
571
- "x-default-marker": "x-default-marker",
572
- $$css: !0
573
- };
574
- function tt({ title: t, description: r, report: i, categories: o, series: s, domain: c, mode: u = "grouped", formatValue: d, formatTick: f = d, highlightedSeriesId: p, selection: m, height: h = Ge, composition: _, referenceLines: b = [], markers: S = [], annotations: C = [], emphasizedCategoryIds: E = [] }) {
575
- let D = _?.focusedSeries, O = M(), A = D === void 0 ? void 0 : $e({
576
- categories: o,
577
- series: [D],
578
- domain: c,
579
- mode: "grouped"
580
- }), j = $e({
581
- categories: o,
582
- series: s,
583
- domain: c,
584
- mode: u
585
- }) ?? A, N = o.map((e) => e.id), P = Y({
586
- markers: S,
587
- annotations: C,
588
- emphasizedCategoryIds: E,
589
- seriesIds: [...s, ...D === void 0 ? [] : [D]].map((e) => e.id),
590
- categoryIds: N,
591
- domain: c
592
- }) ?? ze({
593
- lines: b,
594
- domain: c
595
- }), F = de({
596
- composition: _,
597
- series: s,
598
- categoryIds: N,
599
- domain: c
600
- }) ?? P ?? Qe(h), I = j ?? F, L = _ === void 0 ? void 0 : {
601
- id: O,
602
- label: _.contextLabel,
603
- tone: "neutral",
604
- values: _.buckets.map((e) => e.kind === "gap" ? null : e.total)
605
- }, R = L === void 0 ? s : [
606
- L,
607
- ...s,
608
- ...D === void 0 || s.some((e) => e.id === D.id) ? [] : [D]
609
- ], te = D !== void 0 && L !== void 0 ? [D, L] : s, { ref: ne, width: z } = T(), ie = M();
610
- if (I !== void 0) return /* @__PURE__ */ B(g, {
611
- title: t,
612
- description: r,
613
- report: i,
614
- message: I
615
- });
616
- function ae(e) {
617
- let t = o[e], n = _?.buckets[e], r = D !== void 0 && L !== void 0 ? [D, L] : L === void 0 || n?.kind === "parts" ? s : [], i = n === void 0 ? void 0 : n.kind === "gap" ? "No reported value" : d(n.total), c = r.map((t, n) => {
618
- let r = t.values[e];
619
- return {
620
- id: t.id,
621
- label: t.label,
622
- tone: a(t.tone, n),
623
- value: r == null ? "Unavailable" : d(r)
624
- };
625
- }), l = S.map((t) => ({
626
- id: t.id,
627
- label: t.label,
628
- tone: t.tone ?? "neutral",
629
- shape: t.kind,
630
- value: pe({
631
- marker: t,
632
- index: e,
633
- formatValue: d
634
- })
635
- })), u = b.map((e) => ({
636
- id: e.id,
637
- label: e.label,
638
- tone: e.tone ?? "neutral",
639
- shape: "dashed",
640
- value: d(e.value)
641
- }));
642
- return {
643
- category: t,
644
- label: t?.label,
645
- summary: i,
646
- rows: t === void 0 ? [] : [
647
- ...c,
648
- ...l,
649
- ...u
650
- ],
651
- notes: C.filter((e) => e.categoryId === t?.id).map((e) => e.label)
652
- };
653
- }
654
- let se = S.map((e) => ({
655
- id: e.id,
656
- label: e.label,
657
- tone: e.tone ?? "neutral",
658
- shape: e.kind
659
- })), U = C.length > 0 ? qe : Ke, W = h - 28, G = H({
660
- domain: [...c],
661
- range: [W, U]
662
- }), K = Math.max(44, ...G.ticks(3).map((e) => f(e).length * 7 + 12)), ce = Ve({
663
- lines: b,
664
- formatValue: f
665
- }), ue = Math.max(K + 1, z - 16 - ce), q = re({
666
- domain: o.map((e) => e.id),
667
- range: [K, ue],
668
- padding: .3
669
- }), fe = re({
670
- domain: s.map((e) => e.id),
671
- range: [0, q.bandwidth()],
672
- padding: .08
673
- }), J = Math.min(120, Math.max(40, ...o.map((e) => (e.axisLabel ?? e.label).length * 7))), he = Math.max(1, Math.ceil((J + 16) / q.step())), ge = u === "stacked" || _ !== void 0;
674
- function _e(e, t) {
675
- let n = q(e) ?? K;
676
- return ge ? {
677
- x: n,
678
- width: q.bandwidth()
679
- } : {
680
- x: n + (fe(t) ?? 0),
681
- width: fe.bandwidth()
682
- };
683
- }
684
- function X(e, t) {
685
- if (!ge) return s.find((e) => e.id === t)?.values[e] ?? null;
686
- let n = s.flatMap((t) => [t.values[e] ?? null].filter((e) => e !== null));
687
- return n.length === 0 ? null : n.reduce((e, t) => e + t, 0);
688
- }
689
- function ve(e, t) {
690
- let n = (t === void 0 ? s : s.filter((e) => e.id === t)).flatMap((t) => [t.values[e] ?? null].filter((e) => e !== null)), r = ge ? n.reduce((e, t) => e + Math.max(0, t), 0) : Math.max(0, ...n), i = _?.buckets[e], a = i === void 0 || i.kind === "gap" ? 0 : i.total, o = S.filter((e) => t === void 0 || e.seriesId === t).flatMap((t) => [me(t, e)].filter((e) => e !== null));
691
- return Math.max(0, r, a, ...o);
692
- }
693
- let Z = Math.max(1, Math.floor((q.step() * he - 16) / 7));
694
- return /* @__PURE__ */ B(x, {
695
- items: o,
696
- readout: (e) => le(ae(N.indexOf(e))),
697
- locate: y({
698
- ids: N,
699
- start: K,
700
- step: q.step(),
701
- width: z
702
- }),
703
- selected: m?.selectedId ?? null,
704
- onSelect: m?.onSelect,
705
- render: (c, { inspected: g, cursor: y }) => {
706
- let x = ae(N.indexOf(g ?? ""));
707
- function T(e) {
708
- let t = E.includes(e);
709
- return E.length > 0 && !t && g !== e;
710
- }
711
- let O = C.map((e) => {
712
- let t = ve(N.indexOf(e.categoryId), e.seriesId), n = e.seriesId === void 0 ? {
713
- x: q(e.categoryId) ?? K,
714
- width: q.bandwidth()
715
- } : _e(e.categoryId, e.seriesId);
716
- return {
717
- id: e.id,
718
- label: e.label,
719
- x: n.x + n.width / 2,
720
- y: Math.max(Ye, G(t) - Je),
721
- isReceded: T(e.categoryId)
722
- };
723
- });
724
- return /* @__PURE__ */ B(Xe, {
725
- figure: c,
726
- title: t,
727
- description: r,
728
- report: i,
729
- series: te,
730
- layoutSeries: s,
731
- markerLegend: se,
732
- notes: x.notes,
733
- inspectionId: ie,
734
- label: x.label,
735
- detail: x.category === void 0 ? void 0 : [x.category.axisLabel ?? x.category.label, x.summary].filter(Boolean).join(" · "),
736
- summary: x.summary,
737
- rows: x.rows,
738
- x: (q(g ?? "") ?? K) + q.bandwidth() / 2,
739
- width: z,
740
- offset: q.bandwidth() / 2 + 8,
741
- data: {
742
- label: `${t} observations`,
743
- columns: [{
744
- id: "category",
745
- label: "Category"
746
- }, {
747
- id: "value",
748
- label: "Value"
749
- }],
750
- rows: [...o.map((e, t) => ({
751
- id: e.id,
752
- values: [e.label, [
753
- nt(R, t, d),
754
- ...S.map((e) => `${e.label}: ${pe({
755
- marker: e,
756
- index: t,
757
- formatValue: d
758
- })}`),
759
- ...C.filter((t) => t.categoryId === e.id).map((e) => e.label)
760
- ].join(" · ")]
761
- })), ...b.map((e) => ({
762
- id: `reference:${e.id}`,
763
- values: [e.label, d(e.value)]
764
- }))]
765
- },
766
- children: /* @__PURE__ */ B("div", {
767
- ref: ne,
768
- ...k.props(w.plot, We.plot),
769
- children: o.length === 0 || s.length === 0 && _ === void 0 ? /* @__PURE__ */ B("p", {
770
- className: "x153jb6y x1ghz6dp xy8obcc",
771
- children: "No categories"
772
- }) : /* @__PURE__ */ V(v, {
773
- role: "img",
774
- "aria-label": ee({
775
- title: t,
776
- marks: "categories",
777
- isSelectable: m !== void 0
778
- }),
779
- "aria-describedby": ie,
780
- viewBox: `0 0 ${z} ${h}`,
781
- height: h,
782
- ...k.props(w.svg, w.inspectable, et),
783
- children: [
784
- g !== null && /* @__PURE__ */ B("rect", {
785
- x: (q(g) ?? K) - (q.step() - q.bandwidth()) / 2,
786
- y: U,
787
- width: q.step(),
788
- height: W - U,
789
- className: "x2wnxhi"
790
- }),
791
- G.ticks(3).map((e) => /* @__PURE__ */ V("g", { children: [/* @__PURE__ */ B("line", {
792
- x1: K,
793
- x2: ue,
794
- y1: G(e),
795
- y2: G(e),
796
- ...k.props(e === 0 ? w.baseline : w.grid)
797
- }), /* @__PURE__ */ B("text", {
798
- x: K - 8,
799
- y: G(e),
800
- textAnchor: "end",
801
- dominantBaseline: "middle",
802
- ...k.props(w.label, w.tick),
803
- children: f(e)
804
- })] }, e)),
805
- _?.annotation !== void 0 && o.some((e) => e.id === _.annotation?.categoryId) && /* @__PURE__ */ B("text", {
806
- x: q(_.annotation.categoryId),
807
- y: Math.max(U, G(_.annotation.value) - 8),
808
- ...k.props(w.label),
809
- children: _.annotation.label
810
- }),
811
- o.map((t, r) => {
812
- let i = t.axisLabel ?? t.label, o = _?.buckets[r], c = m?.selectedId === t.id;
813
- return /* @__PURE__ */ V("g", { children: [/* @__PURE__ */ B("g", {
814
- ...k.props(w.emphasis, T(t.id) && w.receded),
815
- children: o === void 0 ? s.map((i, o) => {
816
- let l = i.values[r];
817
- if (l == null) return null;
818
- let d = u === "stacked" ? s.slice(0, o).reduce((e, t) => e + (t.values[r] ?? 0), 0) : 0, f = G(d), m = G(d + l);
819
- return /* @__PURE__ */ B(oe, {
820
- x: (q(t.id) ?? K) + (u === "stacked" ? 0 : fe(i.id) ?? 0),
821
- y: Math.min(f, m),
822
- width: u === "stacked" ? q.bandwidth() : fe.bandwidth(),
823
- height: Math.max(+(l === 0), Math.abs(m - f)),
824
- fill: e[a(i.tone, o)],
825
- stroke: n[a(i.tone, o)],
826
- ...k.props(w.outlined, c && w.selected, p !== void 0 && p !== i.id && We.mutedMark)
827
- }, i.id);
828
- }) : /* @__PURE__ */ B(Ee, {
829
- bucket: o,
830
- series: s,
831
- focusedSeries: D,
832
- index: r,
833
- x: q(t.id) ?? K,
834
- width: q.bandwidth(),
835
- y: G,
836
- isSelected: c,
837
- highlightedSeriesId: p
838
- })
839
- }), r % he === 0 && /* @__PURE__ */ B("text", {
840
- x: (q(t.id) ?? K) + q.bandwidth() / 2,
841
- y: h - 4,
842
- textAnchor: "middle",
843
- ...k.props(w.label, w.tick),
844
- children: i.length > Z ? `${i.slice(0, Z - 1)}…` : i
845
- })] }, t.id);
846
- }),
847
- /* @__PURE__ */ B(Ue, {
848
- lines: b,
849
- y: G,
850
- left: K,
851
- right: ue,
852
- top: U,
853
- bottom: W,
854
- formatValue: f
855
- }),
856
- /* @__PURE__ */ B(Ce, {
857
- markers: S,
858
- categoryIds: N,
859
- span: _e,
860
- barTop: X,
861
- y: G,
862
- isReceded: T
863
- }),
864
- /* @__PURE__ */ B(we, {
865
- annotations: O,
866
- left: K,
867
- right: ue
868
- }),
869
- y !== null && /* @__PURE__ */ B(l, {
870
- x: (q(y) ?? K) + q.bandwidth() / 2,
871
- top: U,
872
- bottom: W,
873
- width: Math.max(8, q.bandwidth())
874
- })
875
- ]
876
- })
877
- })
878
- });
879
- }
880
- });
881
- }
882
- function nt(e, t, n) {
883
- return e.map((e) => {
884
- let r = e.values[t];
885
- return `${e.label}: ${r == null ? "Unavailable" : n(r)}`;
886
- }).join(" · ");
887
- }
888
- // packages/charts/src/cartesian/breakdown-bar.tsx
889
- var rt = {
890
- kzqmXN: "x5lhr3w",
891
- kGVxlE: "x1iotiob",
892
- kZKoxP: "x5yr21d",
893
- $$css: !0
894
- }, it = { segment: (e, t, n) => [
895
- rt,
896
- {
897
- kWkggS: t == null ? t : "xl8spv7",
898
- $$css: !0
899
- },
900
- {
901
- "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(`${e}%`),
902
- "--x-backgroundColor": t ?? void 0,
903
- "--x-boxShadow": `inset 0 0 0 1px ${n}` == null ? void 0 : `inset 0 0 0 1px ${n}`
904
- }
905
- ] };
906
- function at({ title: t, report: r, description: s, items: l, total: u, formatValue: d, selection: f }) {
907
- let m = i(l), h = l.reduce((e, t) => e + (t.value ?? 0), 0), _ = 2 ** -52 * Math.max(h, u, 1) * l.length;
908
- if (m !== void 0) return /* @__PURE__ */ B(g, {
909
- title: t,
910
- report: r,
911
- description: s,
912
- message: m
913
- });
914
- if (!Number.isFinite(u) || u < 0 || h - u > _) return /* @__PURE__ */ B(g, {
915
- title: t,
916
- report: r,
917
- description: s,
918
- message: "The total must be finite and at least the sum of recorded values."
919
- });
920
- let v = l.map((e, t) => ({
921
- id: e.id,
922
- label: e.label,
923
- valueLabel: e.value === null ? "Unavailable" : d(e.value),
924
- tone: a(e.tone, t)
925
- }));
926
- return /* @__PURE__ */ B(x, {
927
- items: o(v),
928
- arrows: "both",
929
- selected: f?.selectedId ?? null,
930
- onSelect: f?.onSelect,
931
- render: (i, o) => /* @__PURE__ */ B(p, {
932
- figure: i,
933
- title: t,
934
- report: r,
935
- description: s,
936
- children: l.length === 0 ? /* @__PURE__ */ B("p", {
937
- className: "x153jb6y x1ghz6dp xy8obcc",
938
- children: "No values"
939
- }) : /* @__PURE__ */ V(z, { children: [
940
- /* @__PURE__ */ B("div", {
941
- "aria-hidden": !0,
942
- className: "x78zum5 x170jfvy xb3r6kr x1r7kqkb xmkeg23 x1y0btm7 x1ey3b81 x1jfksii",
943
- children: l.map((t, r) => t.value === null ? null : /* @__PURE__ */ B("span", { ...k.props(it.segment(u === 0 ? 0 : t.value / u * 100, e[a(t.tone, r)], n[a(t.tone, r)])) }, t.id))
944
- }),
945
- /* @__PURE__ */ B(c, {
946
- title: t,
947
- items: v,
948
- view: f === void 0 ? void 0 : o
949
- }),
950
- u - h > _ && /* @__PURE__ */ V("p", {
951
- className: "x153jb6y x1ghz6dp xy8obcc",
952
- children: [
953
- "Unassigned portion: ",
954
- d(u - h),
955
- " of ",
956
- d(u)
957
- ]
958
- })
959
- ] })
960
- })
961
- });
962
- }
963
- // packages/charts/src/cartesian/bridge-data.ts
964
- function ot(e) {
965
- return e.kind !== "change" || e.value === null ? "neutral" : e.value < 0 ? "negative" : "positive";
966
- }
967
- function st(e) {
968
- let t = e.map((e) => e.kind === "total" ? 0 : e.value);
969
- return e[0]?.kind !== "start" || t.includes(null) ? null : t.reduce((e, t) => e + (t ?? 0), 0);
970
- }
971
- function ct({ step: e, before: t, after: n }) {
972
- let r = e.tone ?? ot(e);
973
- switch (e.kind) {
974
- case "start": return {
975
- step: e,
976
- from: 0,
977
- to: e.value,
978
- tone: r
979
- };
980
- case "total": return {
981
- step: e,
982
- from: n === null ? null : 0,
983
- to: n,
984
- tone: r
985
- };
986
- case "change": return {
987
- step: e,
988
- from: t,
989
- to: n,
990
- tone: r
991
- };
992
- }
993
- }
994
- function lt(e) {
995
- return e.map((t, n) => ct({
996
- step: t,
997
- before: st(e.slice(0, n)),
998
- after: st(e.slice(0, n + 1))
999
- }));
1000
- }
1001
- function ut(e) {
1002
- let t = e.flatMap((e) => [e.from, e.to].filter((e) => e !== null)), n = Math.min(0, ...t), r = Math.max(0, ...t);
1003
- return n === r ? [n, n + 1] : [n, r];
1004
- }
1005
- function dt({ steps: e, domain: t }) {
1006
- if (e.length > s.items) return `Choose a bridge with at most ${s.items} steps.`;
1007
- if (!m(e)) return "Bridge steps require unique identifiers.";
1008
- if (e.length > 0 && e[0]?.kind !== "start") return "A bridge begins with one start step.";
1009
- if (e.filter((e) => e.kind === "start").length > 1) return "A bridge has exactly one start step.";
1010
- if (e.some((e) => {
1011
- let t = e.kind === "total" ? null : e.value;
1012
- return t !== null && !Number.isFinite(t);
1013
- })) return "Bridge values must be finite numbers or explicit missing changes.";
1014
- let n = ut(lt(e));
1015
- if (t === void 0) return Number.isFinite(n[0]) && Number.isFinite(n[1]) ? void 0 : "Running totals must stay finite.";
1016
- let r = t[0] <= n[0] && t[1] >= n[1];
1017
- if (!h(t) || !r) return "The bridge domain must be finite, increasing, and contain zero and every running total.";
1018
- }
1019
- // packages/charts/src/cartesian/bridge-chart.tsx
1020
- var ft = {
1021
- kfJifR: "xnpr05h",
1022
- $$css: !0
1023
- }, pt = {
1024
- plot: {
1025
- kqGvvJ: "x1we84gm",
1026
- $$css: !0
1027
- },
1028
- bar: (e, t) => [
1029
- ft,
1030
- {
1031
- kDwRjp: e == null ? e : "x19zyb68",
1032
- kjVXCG: t == null ? t : "x6mkzkt",
1033
- $$css: !0
1034
- },
1035
- {
1036
- "--x-fill": e ?? void 0,
1037
- "--x-stroke": t ?? void 0
1038
- }
1039
- ],
1040
- unknown: {
1041
- kDwRjp: "xbh8q5q",
1042
- kjVXCG: "x1crw9hw",
1043
- kfJifR: "xnpr05h",
1044
- k5rJSQ: "x1ypbokr",
1045
- kREpy8: "x13efnbd",
1046
- $$css: !0
1047
- }
1048
- }, mt = 240, ht = 24, gt = 28, _t = 6, vt = 14, yt = 12, bt = 7, xt = 14, St = 4, Ct = {
1049
- start: w.strongLabel,
1050
- change: void 0,
1051
- total: w.strongLabel
1052
- };
1053
- function wt(e) {
1054
- return (t) => t === 0 ? e(0) : `${t > 0 ? "+" : "−"}${e(Math.abs(t))}`;
1055
- }
1056
- function Tt({ level: e, formatValue: t, formatChange: n }) {
1057
- return e.step.kind === "change" && e.step.value !== null ? n(e.step.value) : e.to === null ? "—" : t(e.to);
1058
- }
1059
- function Et({ level: e, formatValue: t, formatChange: n }) {
1060
- return e.step.kind === "change" ? e.step.value === null ? "Unavailable" : n(e.step.value) : e.to === null ? "Unavailable" : t(e.to);
1061
- }
1062
- function Dt({ level: e, formatValue: t }) {
1063
- return e.from === null || e.to === null ? "Unavailable" : `${t(e.from)} → ${t(e.to)}`;
1064
- }
1065
- function Ot(e, t, n) {
1066
- if (e.from === null || e.to === null) {
1067
- let r = Math.min(n - yt, t(e.from ?? 0) - yt / 2);
1068
- return {
1069
- isKnown: !1,
1070
- top: r,
1071
- height: yt,
1072
- labelY: r - _t
1073
- };
1074
- }
1075
- let r = Math.max(e.from, e.to), i = Math.min(e.from, e.to), a = t(r), o = r <= 0 && i < 0;
1076
- return {
1077
- isKnown: !0,
1078
- top: a,
1079
- height: Math.max(1, t(i) - a),
1080
- labelY: o ? t(i) + vt : a - _t
1081
- };
1082
- }
1083
- function kt(e) {
1084
- let t = [];
1085
- for (let n of [...e.filter(({ kind: e }) => e !== "change"), ...e.filter(({ kind: e }) => e === "change")]) t.every((e) => {
1086
- let t = (n.text.length + e.text.length) * bt / 2 + St;
1087
- return Math.abs(n.x - e.x) >= t || Math.abs(n.y - e.y) >= xt;
1088
- }) && t.push(n);
1089
- return t;
1090
- }
1091
- var At = {
1092
- "x-default-marker": "x-default-marker",
1093
- $$css: !0
1094
- };
1095
- function jt({ title: e, description: t, report: n, steps: r, formatValue: i, formatChange: a = wt(i), formatTick: o = i, domain: s, referenceLines: c = [], selection: d, height: f = mt }) {
1096
- let { ref: m, width: h } = T(), _ = M(), b = !Number.isFinite(f) || f < 96 ? "Chart height must be at least 96 pixels." : void 0, S = lt(r), C = s ?? ut(S), E = b ?? dt({
1097
- steps: r,
1098
- domain: s
1099
- }) ?? ze({
1100
- lines: c,
1101
- domain: C
1102
- });
1103
- if (E !== void 0) return /* @__PURE__ */ B(g, {
1104
- title: e,
1105
- description: t,
1106
- report: n,
1107
- message: E
1108
- });
1109
- let D = c.map((e) => ({
1110
- id: e.id,
1111
- label: e.label,
1112
- tone: e.tone ?? "neutral",
1113
- shape: "dashed",
1114
- value: i(e.value)
1115
- }));
1116
- function O(e) {
1117
- let t = S.find((t) => t.step.id === e);
1118
- if (t === void 0) return {
1119
- level: t,
1120
- label: void 0,
1121
- summary: void 0,
1122
- rows: []
1123
- };
1124
- let n = t.step.kind === "change" ? [{
1125
- id: "running",
1126
- label: "Running total",
1127
- tone: "neutral",
1128
- value: Dt({
1129
- level: t,
1130
- formatValue: i
1131
- })
1132
- }] : [];
1133
- return {
1134
- level: t,
1135
- label: t.step.label,
1136
- summary: Et({
1137
- level: t,
1138
- formatValue: i,
1139
- formatChange: a
1140
- }),
1141
- rows: [...n, ...D]
1142
- };
1143
- }
1144
- let A = f - gt, j = H({
1145
- domain: [...C],
1146
- range: [A, ht]
1147
- }), N = j.ticks(4), P = Math.max(44, ...N.map((e) => o(e).length * bt + 12)), F = Ve({
1148
- lines: c,
1149
- formatValue: o
1150
- }), I = Math.max(P + 1, h - 16 - F), L = re({
1151
- domain: S.map((e) => e.step.id),
1152
- range: [P, I],
1153
- padding: .28
1154
- }), R = S.map((e) => ({
1155
- id: e.step.id,
1156
- label: e.step.label
1157
- })), te = Math.max(1, Math.floor((L.step() - 8) / bt));
1158
- function ne(e) {
1159
- let t = e.axisLabel ?? e.label;
1160
- return t.length > te ? `${t.slice(0, te - 1)}…` : t;
1161
- }
1162
- let z = kt(S.map((e) => ({
1163
- id: e.step.id,
1164
- kind: e.step.kind,
1165
- text: Tt({
1166
- level: e,
1167
- formatValue: i,
1168
- formatChange: a
1169
- }),
1170
- x: (L(e.step.id) ?? P) + L.bandwidth() / 2,
1171
- y: Ot(e, j, A).labelY
1172
- })));
1173
- return /* @__PURE__ */ B(x, {
1174
- items: R,
1175
- readout: (e) => le(O(e)),
1176
- locate: y({
1177
- ids: R.map((e) => e.id),
1178
- start: P,
1179
- step: L.step(),
1180
- width: h
1181
- }),
1182
- selected: d?.selectedId ?? null,
1183
- onSelect: d?.onSelect,
1184
- render: (r, { inspected: s, cursor: g }) => {
1185
- let y = O(s);
1186
- return /* @__PURE__ */ V(p, {
1187
- figure: r,
1188
- title: /* @__PURE__ */ B(ce, {
1189
- title: e,
1190
- detail: y.level === void 0 ? void 0 : `${y.label} · ${y.summary}`
1191
- }),
1192
- description: t,
1193
- report: n,
1194
- children: [
1195
- /* @__PURE__ */ B(u, {
1196
- label: `${e} steps`,
1197
- columns: [
1198
- {
1199
- id: "step",
1200
- label: "Step"
1201
- },
1202
- {
1203
- id: "value",
1204
- label: "Value"
1205
- },
1206
- {
1207
- id: "running",
1208
- label: "Running total"
1209
- }
1210
- ],
1211
- rows: [...S.map((e) => ({
1212
- id: e.step.id,
1213
- values: [
1214
- e.step.label,
1215
- Et({
1216
- level: e,
1217
- formatValue: i,
1218
- formatChange: a
1219
- }),
1220
- e.step.kind === "change" ? Dt({
1221
- level: e,
1222
- formatValue: i
1223
- }) : Et({
1224
- level: e,
1225
- formatValue: i,
1226
- formatChange: a
1227
- })
1228
- ]
1229
- })), ...c.map((e) => ({
1230
- id: `reference:${e.id}`,
1231
- values: [
1232
- e.label,
1233
- i(e.value),
1234
- ""
1235
- ]
1236
- }))]
1237
- }),
1238
- /* @__PURE__ */ B(ue, {
1239
- id: _,
1240
- label: y.label,
1241
- summary: y.summary,
1242
- legend: [],
1243
- hasLegend: !1,
1244
- rows: y.rows,
1245
- x: (L(s ?? "") ?? P) + L.bandwidth() / 2,
1246
- width: h,
1247
- offset: L.bandwidth() / 2 + 8
1248
- }),
1249
- /* @__PURE__ */ B("div", {
1250
- ref: m,
1251
- ...k.props(w.plot, pt.plot),
1252
- children: S.length === 0 ? /* @__PURE__ */ B("p", {
1253
- className: "x153jb6y x1ghz6dp xy8obcc",
1254
- children: "No steps"
1255
- }) : /* @__PURE__ */ V(v, {
1256
- role: "img",
1257
- "aria-label": ee({
1258
- title: e,
1259
- marks: "steps",
1260
- isSelectable: d !== void 0
1261
- }),
1262
- "aria-describedby": _,
1263
- viewBox: `0 0 ${h} ${f}`,
1264
- height: f,
1265
- ...k.props(w.svg, w.inspectable, At),
1266
- children: [
1267
- s !== null && /* @__PURE__ */ B("rect", {
1268
- x: (L(s) ?? P) - (L.step() - L.bandwidth()) / 2,
1269
- y: ht,
1270
- width: L.step(),
1271
- height: A - ht,
1272
- className: "x2wnxhi"
1273
- }),
1274
- N.map((e) => /* @__PURE__ */ V("g", { children: [/* @__PURE__ */ B("line", {
1275
- x1: P,
1276
- x2: I,
1277
- y1: j(e),
1278
- y2: j(e),
1279
- ...k.props(e === 0 ? w.baseline : w.grid)
1280
- }), /* @__PURE__ */ B("text", {
1281
- x: P - 8,
1282
- y: j(e),
1283
- textAnchor: "end",
1284
- dominantBaseline: "middle",
1285
- ...k.props(w.label, w.tick),
1286
- children: o(e)
1287
- })] }, e)),
1288
- S.map((e, t) => {
1289
- let n = S[t + 1], r = L(e.step.id) ?? P;
1290
- return n === void 0 || e.to === null || n.from === null ? null : /* @__PURE__ */ B("line", {
1291
- x1: r + L.bandwidth(),
1292
- x2: L(n.step.id) ?? r,
1293
- y1: j(e.to),
1294
- y2: j(e.to),
1295
- className: "x1crw9hw xnpr05h x1ypbokr x13efnbd"
1296
- }, `connector:${e.step.id}`);
1297
- }),
1298
- S.map((e) => /* @__PURE__ */ B(Mt, {
1299
- level: e,
1300
- x: L(e.step.id) ?? P,
1301
- width: L.bandwidth(),
1302
- y: j,
1303
- bottom: A,
1304
- height: f,
1305
- axisLabel: ne(e.step),
1306
- isSelected: d?.selectedId === e.step.id
1307
- }, e.step.id)),
1308
- /* @__PURE__ */ B(Ue, {
1309
- lines: c,
1310
- y: j,
1311
- left: P,
1312
- right: I,
1313
- top: ht,
1314
- bottom: A,
1315
- formatValue: o
1316
- }),
1317
- z.map((e) => /* @__PURE__ */ B("text", {
1318
- x: e.x,
1319
- y: e.y,
1320
- textAnchor: "middle",
1321
- ...k.props(w.label, Ct[e.kind], w.haloLabel),
1322
- children: e.text
1323
- }, e.id)),
1324
- g !== null && /* @__PURE__ */ B(l, {
1325
- x: (L(g) ?? P) + L.bandwidth() / 2,
1326
- top: ht,
1327
- bottom: A,
1328
- width: Math.max(8, L.bandwidth())
1329
- })
1330
- ]
1331
- })
1332
- })
1333
- ]
1334
- });
1335
- }
1336
- });
1337
- }
1338
- function Mt({ level: t, x: r, width: i, y: a, bottom: o, height: s, axisLabel: c, isSelected: l }) {
1339
- let u = Ot(t, a, o);
1340
- return /* @__PURE__ */ V("g", { children: [/* @__PURE__ */ B("rect", {
1341
- x: r,
1342
- y: u.top,
1343
- width: i,
1344
- height: u.height,
1345
- ...k.props(u.isKnown ? pt.bar(e[t.tone], n[t.tone]) : pt.unknown, u.isKnown && l && w.selected)
1346
- }), /* @__PURE__ */ B("text", {
1347
- x: r + i / 2,
1348
- y: s - 4,
1349
- textAnchor: "middle",
1350
- ...k.props(w.label, w.tick),
1351
- children: c
1352
- })] });
1353
- }
1354
- // packages/charts/src/cartesian/scatter-plot.tsx
1355
- var Nt = 260, Pt = 56, Ft = 20, It = 12, Lt = 1e3, Rt = {
1356
- kzqmXN: "x1xc55vz",
1357
- kZKoxP: "xdk7pt",
1358
- kaIpWk: "x16rqkct",
1359
- $$css: !0
1360
- }, zt = {
1361
- brush: {
1362
- kFalU9: "xx69xxh",
1363
- kkrTdU: "xsid9ct",
1364
- $$css: !0
1365
- },
1366
- target: {
1367
- kVAEAm: "x10l6tqk",
1368
- k1xSpc: "xrvj5dj",
1369
- kgQiWS: "x1ku5rj1",
1370
- kzqmXN: "x187nhsf",
1371
- kZKoxP: "xn3w4p2",
1372
- k3aq6I: "x11lhmoz",
1373
- kMzoRj: "xc342km",
1374
- kmVPX3: "x1717udv",
1375
- kWkggS: "xjbqb8w",
1376
- kkrTdU: "x1ypdohk",
1377
- kfzvcC: "x67bb7w",
1378
- k3XXqK: "x1t137rt",
1379
- kPJHz1: "x13qnu6",
1380
- kZs9gx: "x19rmrnh",
1381
- k7shQP: "x9v5kkp",
1382
- kiEn40: "x175ew0f",
1383
- kmCx7Z: "xwycy1x",
1384
- kJrEVn: "x15ajoc",
1385
- kLz2MD: "x13ljvab",
1386
- k1CtGv: "xzgvv12",
1387
- $$css: !0
1388
- },
1389
- location: (e, t) => [{
1390
- kbCHJM: e == null ? e : "xgq9j65",
1391
- k87sOh: t == null ? t : "xjbys53",
1392
- $$css: !0
1393
- }, {
1394
- "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
1395
- "--x-top": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
1396
- }],
1397
- dot: (e) => [
1398
- Rt,
1399
- {
1400
- kWkggS: e == null ? e : "xl8spv7",
1401
- $$css: !0
1402
- },
1403
- { "--x-backgroundColor": e ?? void 0 }
1404
- ],
1405
- selected: {
1406
- kMeerF: "x12ei19c",
1407
- kjBf7l: "xj5pgkc",
1408
- k3XXqK: "xaatb59",
1409
- kInvED: "x1ewu8gn",
1410
- $$css: !0
1411
- }
1412
- };
1413
- function Bt(t) {
1414
- let { title: n, report: r, description: i, points: a, xDomain: o, yDomain: s, xLabel: c, yLabel: l, formatX: d, formatY: m, selection: h, rangeSelection: _, emptyLabel: v } = t, y = a.map((e) => ({
1415
- id: e.id,
1416
- label: `${e.label}, ${c}: ${d(e.x)}, ${l}: ${m(e.y)}`
1417
- })), E = M(), { ref: D, width: O } = T(), A = Ut(t);
1418
- if (A !== null) return /* @__PURE__ */ B(g, {
1419
- title: n,
1420
- report: r,
1421
- description: i,
1422
- message: A
1423
- });
1424
- let j = H({
1425
- domain: [...o],
1426
- range: [Pt, Math.max(Pt, O - Ft)]
1427
- }), N = H({
1428
- domain: [...s],
1429
- range: [216, It]
1430
- }), P = new Map(a.map((e) => {
1431
- let t = j(e.x), n = N(e.y);
1432
- return [e.id, {
1433
- left: t,
1434
- top: n,
1435
- right: t,
1436
- bottom: n
1437
- }];
1438
- }));
1439
- return /* @__PURE__ */ B(x, {
1440
- items: y,
1441
- place: (e) => P.get(e),
1442
- selected: h?.selectedId ?? null,
1443
- onSelect: h?.onSelect,
1444
- render: (g, { inspected: x, cursor: T }) => /* @__PURE__ */ V(p, {
1445
- figure: g,
1446
- title: n,
1447
- report: r,
1448
- description: i,
1449
- footer: /* @__PURE__ */ B(f, {
1450
- id: E,
1451
- children: C(y, x)
1452
- }),
1453
- children: [
1454
- a.length === 0 ? /* @__PURE__ */ B("p", {
1455
- className: "x1ghz6dp x153jb6y",
1456
- children: v
1457
- }) : /* @__PURE__ */ V(b, {
1458
- ref: D,
1459
- role: "group",
1460
- "aria-label": ee({
1461
- title: n,
1462
- isSelectable: h !== void 0
1463
- }),
1464
- "aria-describedby": E,
1465
- className: "x1n2onr6 xeuugli x-default-marker",
1466
- children: [/* @__PURE__ */ B(Vt, {
1467
- width: O,
1468
- scaleX: j,
1469
- scaleY: N,
1470
- ...t
1471
- }, `${o[0]}:${o[1]}:${s[0]}:${s[1]}:${O}`), /* @__PURE__ */ B("div", {
1472
- className: "x10l6tqk x10a8y8t x1n71m9f x47corl",
1473
- children: a.map((t, n) => {
1474
- let r = h?.selectedId === t.id || x === t.id;
1475
- return /* @__PURE__ */ B(S, {
1476
- value: t.id,
1477
- render: /* @__PURE__ */ B("button", {
1478
- type: "button",
1479
- tabIndex: -1,
1480
- title: t.label,
1481
- "aria-label": y[n]?.label,
1482
- "aria-pressed": h === void 0 ? void 0 : h.selectedId === t.id
1483
- }),
1484
- ...k.props(zt.target, zt.location(j(t.x), N(t.y))),
1485
- children: /* @__PURE__ */ B("span", {
1486
- "aria-hidden": !0,
1487
- ...k.props(zt.dot(e[t.tone]), r && zt.selected, !r && T === t.id && w.cursor)
1488
- })
1489
- }, t.id);
1490
- })
1491
- })]
1492
- }),
1493
- _ !== void 0 && /* @__PURE__ */ B(Ht, {
1494
- ...t,
1495
- rangeSelection: _
1496
- }),
1497
- /* @__PURE__ */ B(u, {
1498
- label: `${n} points`,
1499
- columns: [
1500
- {
1501
- id: "point",
1502
- label: "Point"
1503
- },
1504
- {
1505
- id: "x",
1506
- label: c
1507
- },
1508
- {
1509
- id: "y",
1510
- label: l
1511
- }
1512
- ],
1513
- rows: a.map((e) => ({
1514
- id: e.id,
1515
- values: [
1516
- e.label,
1517
- d(e.x),
1518
- m(e.y)
1519
- ]
1520
- }))
1521
- })
1522
- ]
1523
- })
1524
- });
1525
- }
1526
- function Vt({ width: e, scaleX: t, scaleY: n, xLabel: r, yLabel: i, formatX: a, formatY: o, rangeSelection: s }) {
1527
- let c = M(), [l, u] = F(null), d = P(null);
1528
- j(() => () => d.current?.(), []);
1529
- let f = l === null ? s?.value : {
1530
- x: [Math.min(l.start.x, l.end.x), Math.max(l.start.x, l.end.x)],
1531
- y: [Math.min(l.start.y, l.end.y), Math.max(l.start.y, l.end.y)]
1532
- };
1533
- function p(r, i, a) {
1534
- return {
1535
- x: t.copy().clamp(!0).invert((i - r.left) / r.width * e),
1536
- y: n.copy().clamp(!0).invert((a - r.top) / r.height * Nt)
1537
- };
1538
- }
1539
- function m(t) {
1540
- let n = t.button === 0 && t.pointerType !== "touch";
1541
- if (s === void 0 || d.current !== null || !n) return;
1542
- let r = t.currentTarget.getBoundingClientRect(), i = (t.clientX - r.left) / r.width * e, a = (t.clientY - r.top) / r.height * Nt;
1543
- if (i < Pt || i > e - Ft || a < It || a > 216) return;
1544
- let o = t.currentTarget, c = o.parentElement;
1545
- if (c === null) return;
1546
- let l = p(r, t.clientX, t.clientY);
1547
- u({
1548
- start: l,
1549
- end: l
1550
- }), d.current = I(c, t.nativeEvent, {
1551
- cancelOnEscape: !0,
1552
- onMove: ({ x: e, y: t }) => u({
1553
- start: l,
1554
- end: p(o.getBoundingClientRect(), e, t)
1555
- }),
1556
- onEnd: (e, t) => {
1557
- if (d.current = null, u(null), t) return;
1558
- let n = p(o.getBoundingClientRect(), e.clientX, e.clientY), r = {
1559
- x: [Math.min(l.x, n.x), Math.max(l.x, n.x)],
1560
- y: [Math.min(l.y, n.y), Math.max(l.y, n.y)]
1561
- };
1562
- ne({ options: () => s }, "onChange", r, {
1563
- reason: "drag",
1564
- event: e
1565
- });
1566
- }
1567
- });
1568
- }
1569
- return /* @__PURE__ */ V("svg", {
1570
- width: e,
1571
- height: Nt,
1572
- viewBox: `0 0 ${e} ${Nt}`,
1573
- "aria-hidden": !0,
1574
- onPointerDown: m,
1575
- ...k.props(w.svg, s !== void 0 && zt.brush),
1576
- children: [
1577
- /* @__PURE__ */ B("defs", { children: /* @__PURE__ */ B("clipPath", {
1578
- id: c,
1579
- children: /* @__PURE__ */ B("rect", {
1580
- x: Pt,
1581
- y: It,
1582
- width: Math.max(0, e - Pt - Ft),
1583
- height: 204
1584
- })
1585
- }) }),
1586
- t.ticks(5).map((e) => /* @__PURE__ */ V("g", { children: [/* @__PURE__ */ B("line", {
1587
- x1: t(e),
1588
- x2: t(e),
1589
- y1: It,
1590
- y2: 216,
1591
- ...k.props(w.grid)
1592
- }), /* @__PURE__ */ B("text", {
1593
- x: t(e),
1594
- y: 234,
1595
- textAnchor: "middle",
1596
- ...k.props(w.label, w.tick),
1597
- children: a(e)
1598
- })] }, e)),
1599
- n.ticks(4).map((t) => /* @__PURE__ */ V("g", { children: [/* @__PURE__ */ B("line", {
1600
- x1: Pt,
1601
- x2: e - Ft,
1602
- y1: n(t),
1603
- y2: n(t),
1604
- ...k.props(w.grid)
1605
- }), /* @__PURE__ */ B("text", {
1606
- x: 48,
1607
- y: n(t) + 4,
1608
- textAnchor: "end",
1609
- ...k.props(w.label, w.tick),
1610
- children: o(t)
1611
- })] }, t)),
1612
- /* @__PURE__ */ B("text", {
1613
- x: (Pt + e - Ft) / 2,
1614
- y: 256,
1615
- textAnchor: "middle",
1616
- ...k.props(w.label, w.tick),
1617
- children: r
1618
- }),
1619
- /* @__PURE__ */ B("text", {
1620
- x: 12,
1621
- y: 108,
1622
- textAnchor: "middle",
1623
- transform: "rotate(-90 12 108)",
1624
- ...k.props(w.label),
1625
- children: i
1626
- }),
1627
- /* @__PURE__ */ B("g", {
1628
- clipPath: `url(#${c})`,
1629
- children: f != null && /* @__PURE__ */ B("rect", {
1630
- x: t(f.x[0]),
1631
- y: n(f.y[1]),
1632
- width: t(f.x[1]) - t(f.x[0]),
1633
- height: n(f.y[0]) - n(f.y[1]),
1634
- className: "x1e0kj8g xv7c1pl x1tg5nk6 xnpr05h x15lqr97 x47corl"
1635
- })
1636
- })
1637
- ]
1638
- });
1639
- }
1640
- function Ht({ rangeSelection: e, xDomain: t, yDomain: n, xLabel: r, yLabel: i, formatX: a, formatY: o }) {
1641
- let s = e.value ?? {
1642
- x: t,
1643
- y: n
1644
- };
1645
- return /* @__PURE__ */ V("fieldset", {
1646
- className: "xrvj5dj x1n8ia3y x1xxf3xd xc342km x1717udv xeuugli",
1647
- children: [
1648
- /* @__PURE__ */ B("legend", {
1649
- className: "x153jb6y xy8obcc x1jfksii",
1650
- children: "Drag with a mouse, or adjust these bounds to select a coordinate range."
1651
- }),
1652
- /* @__PURE__ */ V(O.Root, {
1653
- value: [...s.x],
1654
- format: a,
1655
- min: t[0],
1656
- max: t[1],
1657
- step: e.xStep,
1658
- locale: e.locale,
1659
- onValueChange: (t, n) => e.onChange({
1660
- x: t,
1661
- y: s.y
1662
- }, n),
1663
- children: [/* @__PURE__ */ V("div", {
1664
- className: "x78zum5 x1a02dak x1qughib x1hnptsi x153jb6y xy8obcc xj0a0fe",
1665
- children: [/* @__PURE__ */ B(O.Label, { children: r }), /* @__PURE__ */ V("span", { children: [
1666
- a(s.x[0]),
1667
- " – ",
1668
- a(s.x[1])
1669
- ] })]
1670
- }), /* @__PURE__ */ B(O.Control, { children: /* @__PURE__ */ V(O.Track, { children: [
1671
- /* @__PURE__ */ B(O.Indicator, {}),
1672
- /* @__PURE__ */ B(O.Thumb, {
1673
- index: 0,
1674
- "aria-label": `${r} minimum`
1675
- }),
1676
- /* @__PURE__ */ B(O.Thumb, {
1677
- index: 1,
1678
- "aria-label": `${r} maximum`
1679
- })
1680
- ] }) })]
1681
- }),
1682
- /* @__PURE__ */ V(O.Root, {
1683
- value: [...s.y],
1684
- format: o,
1685
- min: n[0],
1686
- max: n[1],
1687
- step: e.yStep,
1688
- locale: e.locale,
1689
- onValueChange: (t, n) => e.onChange({
1690
- x: s.x,
1691
- y: t
1692
- }, n),
1693
- children: [/* @__PURE__ */ V("div", {
1694
- className: "x78zum5 x1a02dak x1qughib x1hnptsi x153jb6y xy8obcc xj0a0fe",
1695
- children: [/* @__PURE__ */ B(O.Label, { children: i }), /* @__PURE__ */ V("span", { children: [
1696
- o(s.y[0]),
1697
- " – ",
1698
- o(s.y[1])
1699
- ] })]
1700
- }), /* @__PURE__ */ B(O.Control, { children: /* @__PURE__ */ V(O.Track, { children: [
1701
- /* @__PURE__ */ B(O.Indicator, {}),
1702
- /* @__PURE__ */ B(O.Thumb, {
1703
- index: 0,
1704
- "aria-label": `${i} minimum`
1705
- }),
1706
- /* @__PURE__ */ B(O.Thumb, {
1707
- index: 1,
1708
- "aria-label": `${i} maximum`
1709
- })
1710
- ] }) })]
1711
- }),
1712
- /* @__PURE__ */ B(D, {
1713
- type: "button",
1714
- disabled: e.value === null,
1715
- onClick: (t) => {
1716
- ne({ options: () => e }, "onChange", null, {
1717
- reason: "clear-press",
1718
- event: t.nativeEvent
1719
- });
1720
- },
1721
- children: "Clear range"
1722
- })
1723
- ]
1724
- });
1725
- }
1726
- function Ut({ points: e, xDomain: t, yDomain: n, rangeSelection: r }) {
1727
- if (!h(t) || !h(n)) return "Scatter domains must contain finite, increasing endpoints.";
1728
- if (e.length > 1e3) return `This plot exceeds the ${Lt}-point render limit. Supply a smaller, labelled sample.`;
1729
- if (!m(e)) return "Scatter points must have unique identifiers.";
1730
- if (e.some((e) => !Number.isFinite(e.x) || !Number.isFinite(e.y))) return "Scatter coordinates must be finite.";
1731
- if (e.some((e) => {
1732
- let r = e.x < t[0] || e.x > t[1], i = e.y < n[0] || e.y > n[1];
1733
- return r || i;
1734
- })) return "Scatter coordinates fall outside the declared domain. Widen the domain or supply a labelled window of points.";
1735
- if (r === void 0) return null;
1736
- let i = Number.isFinite(r.xStep) && r.xStep > 0 && r.xStep <= t[1] - t[0], a = Number.isFinite(r.yStep) && r.yStep > 0 && r.yStep <= n[1] - n[0];
1737
- if (!i || !a) return "Range selection steps must be finite, positive, and no larger than their domain span.";
1738
- let o = r.value;
1739
- return o === null ? null : !Wt(o.x, t) || !Wt(o.y, n) ? "The selected range must have finite, ordered bounds inside the declared domain." : null;
1740
- }
1741
- function Wt(e, t) {
1742
- return !e.every(Number.isFinite) || e[0] > e[1] ? !1 : e[0] >= t[0] && e[1] <= t[1];
1743
- }
1744
- // packages/charts/src/cartesian/time-series-data.ts
1745
- var $ = {
1746
- series: 12,
1747
- pointsPerSeries: 2e3,
1748
- markers: 200,
1749
- panels: 12
1750
- }, Gt = .01, Kt = [
1751
- "series1",
1752
- "series2",
1753
- "series3",
1754
- "series4",
1755
- "series5",
1756
- "series6"
1757
- ];
1758
- function qt({ series: e, isStacked: t, markers: n, timeline: r = [] }) {
1759
- let i = e[0]?.points.map((e) => e.timestamp) ?? r;
1760
- if (e.length > $.series || i.length > $.pointsPerSeries || n.length > $.markers) return `Choose a window with at most ${$.series} series, ${$.pointsPerSeries} observations per series, and ${$.markers} markers.`;
1761
- if (!m(e) || !m(n)) return "Series and markers require unique identifiers.";
1762
- for (let n of e) {
1763
- if (n.points.length !== i.length) return "Every series must supply the same observation timestamps.";
1764
- let e = Qt({
1765
- points: n.points,
1766
- timestamps: i,
1767
- isStacked: t
1768
- });
1769
- if (e !== void 0) return e;
1770
- }
1771
- for (let t of n) {
1772
- let n = Jt({
1773
- marker: t,
1774
- series: e,
1775
- timestamps: i
1776
- });
1777
- if (n !== void 0) return n;
1778
- }
1779
- let a = e.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value])), o = Math.max(0, ...a) - Math.min(0, ...a), s = (i.at(-1) ?? 0) - (i[0] ?? 0);
1780
- if (!Number.isFinite(o) || !Number.isFinite(s)) return "The elapsed-time and value ranges must be finite.";
1781
- if (t && i.some((t, n) => !Number.isFinite(e.reduce((e, t) => e + (t.points[n]?.value ?? 0), 0)))) return "Stacked observation totals must be finite.";
1782
- }
1783
- function Jt({ marker: e, series: t, timestamps: n }) {
1784
- if (e.kind === "event") {
1785
- let t = n[0] ?? 0, r = n.at(-1) ?? t, i = e.timestamp >= t && e.timestamp <= r;
1786
- return Number.isFinite(e.timestamp) && i ? void 0 : "Every event marker must fall inside the observed time range.";
1787
- }
1788
- if (!n.includes(e.timestamp)) return "Every time and point marker must align with an observation timestamp.";
1789
- if (e.kind !== "time") return t.find((t) => t.id === e.seriesId)?.points.find((t) => t.timestamp === e.timestamp)?.value === e.value ? void 0 : "Point markers must reference the recorded series value.";
1790
- }
1791
- function Yt({ series: e, markers: t, timestampUnit: n, isStacked: r }) {
1792
- return JSON.stringify([
1793
- n,
1794
- r,
1795
- e.map((e) => [
1796
- e.id,
1797
- e.label,
1798
- e.tone,
1799
- e.points.map((e) => [e.timestamp, e.value])
1800
- ]),
1801
- t.map((e) => [
1802
- e.id,
1803
- e.kind,
1804
- e.timestamp,
1805
- e.label,
1806
- e.seriesId,
1807
- e.value
1808
- ])
1809
- ]);
1810
- }
1811
- function Xt(e, t, n = !1) {
1812
- if (e !== t) return [e, t];
1813
- let r = Math.max(1, Math.abs(e) * Gt), i = n ? 0 : e - r, a = t + r;
1814
- return [Number.isFinite(i) ? i : e, Number.isFinite(a) ? a : t];
1815
- }
1816
- function Zt(e, t) {
1817
- let n = e.filter((e) => e.tone === void 0);
1818
- return e.map((r, i) => {
1819
- let a = n.findIndex((e) => e.id === r.id), o = r.tone ?? Kt[a % Kt.length] ?? "series1", s = r.points.map((n, r) => {
1820
- let a = t ? e.slice(0, i).reduce((e, t) => e + (t.points[r]?.value ?? 0), 0) : 0;
1821
- return {
1822
- ...n,
1823
- base: a
1824
- };
1825
- });
1826
- return {
1827
- id: r.id,
1828
- label: r.label,
1829
- tone: o,
1830
- points: s
1831
- };
1832
- });
1833
- }
1834
- function Qt({ points: e, timestamps: t, isStacked: n }) {
1835
- for (let [r, i] of e.entries()) {
1836
- let a = e[r - 1], o = a !== void 0 && i.timestamp <= a.timestamp;
1837
- if (!Number.isFinite(i.timestamp) || i.timestamp !== t[r] || o) return "Observation timestamps must be finite, aligned, and strictly increasing.";
1838
- if (i.value !== null && !Number.isFinite(i.value)) return "Observations must be finite numbers or explicit missing values.";
1839
- if (n && (i.value === null || i.value < 0)) return "Stacked observations must be present and nonnegative.";
1840
- }
1841
- }
1842
- // packages/charts/src/cartesian/time-series-line.tsx
1843
- function $t({ series: t, x: n, y: r, inspectedTimestamp: i, pointRadius: a = 3 }) {
1844
- let o = t.points.findLastIndex((e) => e.value !== null);
1845
- return /* @__PURE__ */ V(z, { children: [/* @__PURE__ */ B(se, {
1846
- data: [...t.points],
1847
- defined: (e) => e.value !== null,
1848
- x: (e) => n(e.timestamp),
1849
- y: (e) => r((e.value ?? 0) + e.base),
1850
- stroke: e[t.tone],
1851
- ...k.props(w.mark)
1852
- }), t.points.filter((e, n) => {
1853
- if (e.value === null) return !1;
1854
- let r = t.points[n - 1]?.value === null || t.points[n + 1]?.value === null, a = t.points.length === 1, s = n === o, c = e.timestamp === i;
1855
- return a || s ? !0 : r || c;
1856
- }).map((i) => /* @__PURE__ */ B("circle", {
1857
- cx: n(i.timestamp),
1858
- cy: r((i.value ?? 0) + i.base),
1859
- r: a,
1860
- fill: e[t.tone]
1861
- }, i.timestamp))] });
1862
- }
1863
- // packages/charts/src/cartesian/sparkline.tsx
1864
- var en = {
1865
- minimum: "Lowest",
1866
- maximum: "Highest",
1867
- last: "Latest"
1868
- }, tn = 2.5;
1869
- function nn({ points: e, marked: t }) {
1870
- let n = e.flatMap((e) => e.value === null ? [] : [{
1871
- ...e,
1872
- value: e.value
1873
- }]), r = n.map((e) => e.value), i = {
1874
- minimum: n.find((e) => e.value === Math.min(...r)),
1875
- maximum: n.find((e) => e.value === Math.max(...r)),
1876
- last: n.at(-1)
1877
- };
1878
- return t.flatMap((e) => {
1879
- let t = i[e];
1880
- return t === void 0 ? [] : [{
1881
- kind: e,
1882
- point: t
1883
- }];
1884
- });
1885
- }
1886
- function rn({ title: t, summary: n, unit: r, timestampUnit: i, series: a, valueDomain: o, markedPoints: s = [], baseline: c }) {
1887
- let l = M(), u = M(), d = an({
1888
- title: t,
1889
- summary: n,
1890
- unit: r,
1891
- series: a,
1892
- valueDomain: o,
1893
- markedPoints: s,
1894
- baseline: c
1895
- }), f = a.points.some((e) => e.value !== null);
1896
- if (d !== void 0 || !f) return /* @__PURE__ */ B("span", {
1897
- role: "img",
1898
- "aria-label": `${t}. ${n} Values in ${r}; timestamps in ${i}. ${d ?? "No recorded values. Missing observations remain unavailable."}`,
1899
- title: d ?? "No recorded values",
1900
- className: "x2pejg6 x10w6t97 x2lah0s xxymvpz x3nfvp2 x6s0dn4 xl56j7k x153jb6y x1hz01jw xy8obcc",
1901
- children: d === void 0 ? "No data" : "Invalid trend"
1902
- });
1903
- let p = a.points[0]?.timestamp ?? 0, m = a.points.at(-1)?.timestamp ?? p, h = H({
1904
- domain: [...Xt(p, m)],
1905
- range: [3, 125]
1906
- }), g = H({
1907
- domain: [...o],
1908
- range: [29, 3]
1909
- }), _ = Zt([a], !1)[0], v = e[_?.tone ?? "series1"], y = nn({
1910
- points: a.points,
1911
- marked: s
1912
- }), b = y.map(({ kind: e, point: t }) => `${en[e]}: ${t.value} ${r}.`).join(" "), ee = c === void 0 ? "" : `Reference: ${c} ${r}.`;
1913
- return /* @__PURE__ */ V("svg", {
1914
- role: "img",
1915
- "aria-labelledby": l,
1916
- "aria-describedby": u,
1917
- focusable: "false",
1918
- viewBox: "0 0 128 32",
1919
- width: 128,
1920
- height: 32,
1921
- className: "x1rg5ohu x2pejg6 x10w6t97 x2lah0s xxymvpz",
1922
- children: [
1923
- /* @__PURE__ */ B("title", {
1924
- id: l,
1925
- children: t
1926
- }),
1927
- /* @__PURE__ */ V("desc", {
1928
- id: u,
1929
- children: [
1930
- n,
1931
- " Values in ",
1932
- r,
1933
- "; timestamps in ",
1934
- i,
1935
- ". Displayed value domain: ",
1936
- o[0],
1937
- " to",
1938
- " ",
1939
- o[1],
1940
- " ",
1941
- r,
1942
- ". ",
1943
- b,
1944
- " ",
1945
- ee
1946
- ]
1947
- }),
1948
- c !== void 0 && /* @__PURE__ */ B("line", {
1949
- x1: 3,
1950
- x2: 125,
1951
- y1: g(c),
1952
- y2: g(c),
1953
- className: "x1crw9hw xnpr05h xbw2l0c x13efnbd"
1954
- }),
1955
- _ !== void 0 && /* @__PURE__ */ B($t, {
1956
- series: _,
1957
- x: h,
1958
- y: g,
1959
- pointRadius: 2
1960
- }),
1961
- y.map(({ kind: e, point: t }) => e === "last" ? /* @__PURE__ */ B("circle", {
1962
- cx: h(t.timestamp),
1963
- cy: g(t.value),
1964
- r: tn,
1965
- fill: v
1966
- }, e) : /* @__PURE__ */ B("circle", {
1967
- cx: h(t.timestamp),
1968
- cy: g(t.value),
1969
- r: tn,
1970
- stroke: v,
1971
- className: "x1fytgo2 x1r6sdyr x13efnbd"
1972
- }, e))
1973
- ]
1974
- });
1975
- }
1976
- function an({ title: e, summary: t, unit: n, series: r, valueDomain: i, markedPoints: a, baseline: o }) {
1977
- if (e.trim() === "" || t.trim() === "" || n.trim() === "") return "A trend requires a title, a readable summary, and a value unit.";
1978
- if (!h(i)) return "The displayed value domain must have finite, increasing bounds.";
1979
- let s = qt({
1980
- series: [r],
1981
- isStacked: !1,
1982
- markers: []
1983
- });
1984
- if (s !== void 0) return s;
1985
- if (r.points.some((e) => e.value !== null && (e.value < i[0] || e.value > i[1]))) return "Every recorded value must be inside the declared value domain.";
1986
- if (new Set(a).size !== a.length) return "Mark each recorded point at most once.";
1987
- if (!(o === void 0 || o >= i[0] && o <= i[1])) return "The reference value must be inside the declared value domain.";
1988
- }
1989
- // packages/charts/src/cartesian/time-series-bands.ts
1990
- var on = {
1991
- bands: 4,
1992
- crossings: 4
1993
- }, sn = [
1994
- "series1",
1995
- "series2",
1996
- "series3",
1997
- "series4",
1998
- "series5",
1999
- "series6"
2000
- ];
2001
- function cn(e) {
2002
- let t = [
2003
- e.lower,
2004
- e.center,
2005
- e.upper
2006
- ].filter((e) => e !== null);
2007
- return t.some((e) => !Number.isFinite(e)) ? "Band values must be finite numbers or explicit missing values." : e.lower === null == (e.upper === null) ? t.every((e, n) => n === 0 || (t[n - 1] ?? e) <= e) ? void 0 : "Band values must satisfy lower ≤ center ≤ upper." : "A band observation needs both bounds or neither.";
2008
- }
2009
- function ln({ bands: e, crossings: t, series: n, timestamps: r }) {
2010
- if (e.length > on.bands || t.length > on.crossings) return `Supply at most ${on.bands} bands and ${on.crossings} crossings.`;
2011
- if (!m([...n, ...e]) || !m(t)) return "Series, bands, and crossings require unique identifiers.";
2012
- for (let t of e) {
2013
- if (t.points.length !== r.length || t.points.some((e, t) => e.timestamp !== r[t])) return "Every band must supply the same observation timestamps as the series.";
2014
- let e = t.points.map(cn).find((e) => e !== void 0);
2015
- if (e !== void 0) return e;
2016
- }
2017
- let i = new Set([...n, ...e].map((e) => e.id));
2018
- for (let e of t) if (!(i.has(e.seriesId) && e.label.trim() !== "") || !Number.isFinite(e.value)) return "Each crossing needs a label, a finite value, and a supplied series or band.";
2019
- }
2020
- function un({ series: e, bands: t }) {
2021
- let n = e.filter((e) => e.tone === void 0).length, r = t.filter((e) => e.tone === void 0);
2022
- return t.map((e) => {
2023
- let t = n + r.findIndex((t) => t.id === e.id);
2024
- return {
2025
- ...e,
2026
- tone: e.tone ?? sn[t % sn.length] ?? "series1"
2027
- };
2028
- });
2029
- }
2030
- function dn({ start: e, end: t, value: n, direction: r }) {
2031
- let i = e > n && t <= n, a = e < n && t >= n;
2032
- switch (r) {
2033
- case "falling": return i;
2034
- case "rising": return a;
2035
- case void 0: return i || a;
2036
- }
2037
- }
2038
- function fn({ points: e, crossing: t }) {
2039
- let n = e.flatMap((t, n) => {
2040
- let r = e[n + 1];
2041
- return t.value === null || r === void 0 || r.value === null ? [] : [{
2042
- start: t.timestamp,
2043
- end: r.timestamp,
2044
- from: t.value,
2045
- to: r.value
2046
- }];
2047
- }).find(({ from: e, to: n }) => dn({
2048
- start: e,
2049
- end: n,
2050
- value: t.value,
2051
- direction: t.direction
2052
- }));
2053
- if (n === void 0) return;
2054
- let r = (t.value - n.from) / (n.to - n.from);
2055
- return n.start + r * (n.end - n.start);
2056
- }
2057
- function pn({ crossings: e, series: t, bands: n }) {
2058
- return e.map((e) => ({
2059
- crossing: e,
2060
- timestamp: fn({
2061
- points: t.find((t) => t.id === e.seriesId)?.points ?? n.find((t) => t.id === e.seriesId)?.points.map((e) => ({
2062
- timestamp: e.timestamp,
2063
- value: e.center
2064
- })) ?? [],
2065
- crossing: e
2066
- })
2067
- }));
2068
- }
2069
- function mn(e, t) {
2070
- let n = Math.min(...e.map((e) => Math.abs(e - t)));
2071
- return e.find((e) => Math.abs(e - t) === n);
2072
- }
2073
- function hn(e) {
2074
- return e.flatMap((e) => e.points.flatMap((e) => [
2075
- e.lower,
2076
- e.center,
2077
- e.upper
2078
- ].filter((e) => e !== null)));
2079
- }
2080
- // packages/charts/src/chart-range.tsx
2081
- var gn = "axis", _n = "selected", vn = "drawn";
2082
- function yn({ value: e }) {
2083
- return {
2084
- value: e,
2085
- spans: e === null ? [] : [{
2086
- id: _n,
2087
- track: gn,
2088
- start: e[0],
2089
- end: e[1]
2090
- }]
2091
- };
2092
- }
2093
- function bn(e, t) {
2094
- let { draft: n } = e;
2095
- return n?.action === "draw" ? t.filter((e) => e.id === n.id) : t;
2096
- }
2097
- var xn = te({
2098
- name: "chart-range",
2099
- options: {
2100
- value: "value",
2101
- onValueChange: "callback",
2102
- min: "number",
2103
- max: "number",
2104
- step: "number",
2105
- describe: "value"
2106
- },
2107
- controlled: ["value"],
2108
- state: (e) => ({
2109
- ...yn(e),
2110
- draft: null
2111
- }),
2112
- sync: yn,
2113
- api: (e) => {
2114
- let t = L(e);
2115
- function n(n, { id: r, action: i, reason: a, event: o }) {
2116
- let s = i === "delete" ? void 0 : n.find((e) => e.id === r), c = s === void 0 ? null : [s.start, s.end], l = t("value", c, o === void 0 ? { reason: a } : {
2117
- reason: a,
2118
- event: o
2119
- });
2120
- return l && i === "delete" && e.element("root")?.querySelector("[tabindex=\"0\"]:not([data-span-id])")?.focus(), l;
2121
- }
2122
- let r = R(e, {
2123
- key: "spans",
2124
- draft: "draft",
2125
- axis: "x",
2126
- min: () => e.options().min,
2127
- max: () => e.options().max,
2128
- step: () => e.options().step,
2129
- create: (e) => ({
2130
- ...e,
2131
- id: vn
2132
- }),
2133
- label: (t) => e.options().describe([t.start, t.end]),
2134
- createAutoScroll: !1,
2135
- set: (e, t) => n(e, t)
2136
- });
2137
- return {
2138
- spans: r,
2139
- shown(t) {
2140
- return bn(t, r.spans(t)).map((t) => ({
2141
- id: t.id,
2142
- label: e.options().describe([t.start, t.end])
2143
- }));
2144
- },
2145
- draw(e) {
2146
- e.button === 0 && e.pointerType !== "touch" && r.trackPointerdown(e, gn);
2147
- },
2148
- setRange(n, r) {
2149
- let { min: i, max: a, step: o } = e.options(), s = [Number(n), Number(r)].map((e) => i + Math.round((e - i) / o) * o), c = Math.max(i, Math.min(...s)), l = Math.min(a, Math.max(...s));
2150
- if (!Number.isFinite(c) || !Number.isFinite(l) || c >= l) throw Error(`Give a start and a later end between ${i} and ${a}.`);
2151
- return t("value", [c, l], { reason: "imperative" });
2152
- },
2153
- clear() {
2154
- return t("value", null, { reason: "imperative" });
2155
- }
2156
- };
2157
- },
2158
- slots: (e) => ({
2159
- root: e({
2160
- role: "group",
2161
- state: (e, { api: t }) => ({ spans: t.shown(e) }),
2162
- on: { pointerdown: (e, { api: t }) => t.draw(e) }
2163
- }),
2164
- track: e({ bind: (e, { api: t }) => t.spans.bindTrack(e, gn) }),
2165
- span: e({
2166
- role: "group",
2167
- props: { value: "string" },
2168
- attrs: (e, { api: t, key: n }) => {
2169
- let r = t.spans.spans(e).find((e) => e.id === n);
2170
- return {
2171
- ...t.spans.spanAttrs(e, n),
2172
- tabindex: "0",
2173
- style: r === void 0 ? void 0 : t.spans.spanStyle(r)
2174
- };
2175
- },
2176
- bind: (e, { api: t, key: n }) => t.spans.bindSpan(e, n),
2177
- on: {
2178
- pointerdown: (e, { api: t, key: n }) => t.spans.spanPointerdown(e, n),
2179
- keydown: (e, { api: t, key: n }) => {
2180
- t.spans.keydown(e, n);
2181
- }
2182
- }
2183
- })
2184
- }),
2185
- agent: { actions: ["setRange", "clear"] }
2186
- }), Sn = A(xn, {
2187
- root: "div",
2188
- track: "div",
2189
- span: "div"
2190
- }), Cn = Sn.Root, wn = Sn.Track, Tn = Sn.Span, En = {
2191
- kVAEAm: "x10l6tqk",
2192
- k87sOh: "x13vifvy",
2193
- kfzvcC: "x47corl",
2194
- $$css: !0
2195
- }, Dn = { track: (e, t, n) => [
2196
- En,
2197
- {
2198
- kbCHJM: e == null ? e : "xgq9j65",
2199
- kzqmXN: t == null ? t : "x5lhr3w",
2200
- kZKoxP: n == null ? n : "x16ye13r",
2201
- $$css: !0
2202
- },
2203
- {
2204
- "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
2205
- "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t),
2206
- "--x-height": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(n)
2207
- }
2208
- ] };
2209
- function On({ left: e, width: t, height: n, label: r, children: i, ...a }) {
2210
- return /* @__PURE__ */ B(Cn, {
2211
- ...a,
2212
- "aria-label": r,
2213
- className: "x1n2onr6 xeuugli",
2214
- render: (r, { spans: a }) => /* @__PURE__ */ V("div", {
2215
- ...r,
2216
- children: [i, /* @__PURE__ */ B(wn, {
2217
- ...k.props(Dn.track(e, t, n)),
2218
- children: a.map((e) => /* @__PURE__ */ V(Tn, {
2219
- value: e.id,
2220
- "aria-label": `Selected range, ${e.label}. Use arrow keys to move it, Shift and an arrow to move its end, and Delete to clear it.`,
2221
- className: "x10l6tqk x13vifvy x5yr21d x9f619 x1qatu44 x1l0rsgs x1616tdu xbsl7fq xbm8b0d x1n2ykn x1t137rt x19rmrnh x9v5kkp x13qnu6 x1bqaal",
2222
- children: [
2223
- /* @__PURE__ */ B("span", { className: "x10l6tqk x67bb7w x5ve5x3 x7it7wx x1ey2m1c xdk7pt x1jm3nie x1o753nm x1jzqe4 x3onkmb" }),
2224
- /* @__PURE__ */ B("span", {
2225
- "data-span-edge": "start",
2226
- className: "x10l6tqk x67bb7w x5ve5x3 x13vifvy x5yr21d x1fsd2vl x7eptgl x1765b1"
2227
- }),
2228
- /* @__PURE__ */ B("span", {
2229
- "data-span-edge": "end",
2230
- className: "x10l6tqk x67bb7w x5ve5x3 x13vifvy x5yr21d x1fsd2vl x7eptgl xpa5qit"
2231
- })
2232
- ]
2233
- }, e.id))
2234
- })]
2235
- })
2236
- });
2237
- }
2238
- // packages/charts/src/cartesian/time-series-overlays.tsx
2239
- var kn = {
2240
- kDd8S0: "x1bsw5e1",
2241
- kfJifR: "xnpr05h",
2242
- kDwRjp: "xbh8q5q",
2243
- $$css: !0
2244
- }, An = {
2245
- kVYP8I: "xd6etog",
2246
- $$css: !0
2247
- }, jn = {
2248
- kfJifR: "xvlca1e",
2249
- kDwRjp: "xbh8q5q",
2250
- kREpy8: "x13efnbd",
2251
- $$css: !0
2252
- }, Mn = {
2253
- bandEdge: (e) => [
2254
- kn,
2255
- {
2256
- kjVXCG: e == null ? e : "x6mkzkt",
2257
- $$css: !0
2258
- },
2259
- { "--x-stroke": e ?? void 0 }
2260
- ],
2261
- bandFill: (e) => [
2262
- An,
2263
- {
2264
- kDwRjp: e == null ? e : "x19zyb68",
2265
- $$css: !0
2266
- },
2267
- { "--x-fill": e ?? void 0 }
2268
- ],
2269
- center: (e) => [
2270
- jn,
2271
- {
2272
- kjVXCG: e == null ? e : "x6mkzkt",
2273
- $$css: !0
2274
- },
2275
- { "--x-stroke": e ?? void 0 }
2276
- ]
2277
- }, Nn = 16, Pn = 6, Fn = 6.5, In = 2.5, Ln = 4, Rn = 12;
2278
- function zn({ instants: e, x: t, right: n, ends: r }) {
2279
- let [i, ...a] = e;
2280
- if (i === void 0) return [];
2281
- let o = t(i.timestamp), s = i.label.length * Fn + Pn, c = o + s > n ? "end" : "start", l = c === "start" ? o : o - s, u = c === "start" ? o + s : o, d = r.findIndex((e) => l > e), f = d === -1 ? Math.min(r.length, 1) : d, p = [
2282
- ...r.slice(0, f),
2283
- Math.max(u, r[f] ?? u),
2284
- ...r.slice(f + 1)
2285
- ];
2286
- return [{
2287
- ...i,
2288
- lane: f,
2289
- anchor: c
2290
- }, ...zn({
2291
- instants: a,
2292
- x: t,
2293
- right: n,
2294
- ends: p
2295
- })];
2296
- }
2297
- function Bn({ instants: e, x: t, right: n }) {
2298
- return zn({
2299
- instants: e.toSorted((e, t) => e.timestamp - t.timestamp),
2300
- x: t,
2301
- right: n,
2302
- ends: []
2303
- });
2304
- }
2305
- function Vn(e) {
2306
- return Rn + Math.max(0, ...e.map((e) => e.lane + 1)) * Nn;
2307
- }
2308
- function Hn(e) {
2309
- return e.lower !== null && e.upper !== null;
2310
- }
2311
- function Un({ bands: t, x: n, y: r }) {
2312
- return /* @__PURE__ */ B("g", { children: t.map((t) => {
2313
- let i = e[t.tone], a = [...t.points];
2314
- return /* @__PURE__ */ V("g", { children: [
2315
- /* @__PURE__ */ B(ie, {
2316
- data: a,
2317
- defined: Hn,
2318
- x: (e) => n(e.timestamp),
2319
- y0: (e) => r(e.lower ?? 0),
2320
- y1: (e) => r(e.upper ?? 0),
2321
- ...k.props(Mn.bandFill(i))
2322
- }),
2323
- /* @__PURE__ */ B(se, {
2324
- data: a,
2325
- defined: Hn,
2326
- x: (e) => n(e.timestamp),
2327
- y: (e) => r(e.upper ?? 0),
2328
- ...k.props(Mn.bandEdge(i))
2329
- }),
2330
- /* @__PURE__ */ B(se, {
2331
- data: a,
2332
- defined: Hn,
2333
- x: (e) => n(e.timestamp),
2334
- y: (e) => r(e.lower ?? 0),
2335
- ...k.props(Mn.bandEdge(i))
2336
- }),
2337
- /* @__PURE__ */ B(se, {
2338
- data: a,
2339
- defined: (e) => e.center !== null,
2340
- x: (e) => n(e.timestamp),
2341
- y: (e) => r(e.center ?? 0),
2342
- ...k.props(Mn.center(i))
2343
- })
2344
- ] }, t.id);
2345
- }) });
2346
- }
2347
- function Wn({ placed: e, x: t, y: n, bottom: r }) {
2348
- return /* @__PURE__ */ B("g", {
2349
- "aria-hidden": !0,
2350
- children: e.map((e) => {
2351
- let i = t(e.timestamp), a = Rn + e.lane * Nn, o = e.anchor === "start" ? i + Pn : i - Pn;
2352
- return /* @__PURE__ */ V("g", { children: [
2353
- /* @__PURE__ */ B("line", {
2354
- x1: i,
2355
- x2: i,
2356
- y1: a,
2357
- y2: r,
2358
- className: "xhq4mlf xnpr05h x1bpwu3k x13efnbd"
2359
- }),
2360
- /* @__PURE__ */ B("circle", {
2361
- cx: i,
2362
- cy: a,
2363
- r: In,
2364
- className: "xlrhuyr"
2365
- }),
2366
- /* @__PURE__ */ B("text", {
2367
- x: o,
2368
- y: a,
2369
- textAnchor: e.anchor,
2370
- dominantBaseline: "middle",
2371
- ...k.props(w.label, w.strongLabel, w.haloLabel),
2372
- children: e.label
2373
- }),
2374
- e.value !== void 0 && /* @__PURE__ */ B("circle", {
2375
- cx: i,
2376
- cy: n(e.value),
2377
- r: Ln,
2378
- className: "x1fytgo2 x17y187c xvlca1e x13efnbd"
2379
- })
2380
- ] }, e.id);
2381
- })
2382
- });
2383
- }
2384
- // packages/charts/src/cartesian/time-series.tsx
2385
- var Gn = {
2386
- timeAxis: {
2387
- k1xSpc: "x78zum5",
2388
- kjj79g: "x1qughib",
2389
- k1C7PZ: "x8zbtdt",
2390
- keoZOQ: "x1c87qhr",
2391
- kMv6JI: "xiard35",
2392
- kGuDYH: "xy8obcc",
2393
- kLWn49: "xas2l8k",
2394
- kMwMTN: "xbixft",
2395
- kcqcaj: "xss6m8b",
2396
- $$css: !0
2397
- },
2398
- timeAxisInset: (e, t) => [{
2399
- kZCmMZ: e == null ? e : "xnvo3vl",
2400
- kwRFfy: t == null ? t : "x120eax6",
2401
- $$css: !0
2402
- }, {
2403
- "--x-paddingInlineStart": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
2404
- "--x-paddingInlineEnd": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
2405
- }]
2406
- };
2407
- function Kn({ bands: e, crossings: t }) {
2408
- return JSON.stringify([e.map((e) => [
2409
- e.id,
2410
- e.label,
2411
- e.rangeLabel,
2412
- e.tone,
2413
- e.points.map((e) => [
2414
- e.timestamp,
2415
- e.lower,
2416
- e.center,
2417
- e.upper
2418
- ])
2419
- ]), t.map((e) => [
2420
- e.id,
2421
- e.seriesId,
2422
- e.value,
2423
- e.label,
2424
- e.direction
2425
- ])]);
2426
- }
2427
- function qn({ bands: e, timestamp: t, formatValue: n }) {
2428
- return e.flatMap((e) => {
2429
- let r = e.points.find((e) => e.timestamp === t), i = r?.center ?? null, a = r?.lower !== null && r?.upper !== null && r !== void 0;
2430
- return [{
2431
- id: e.id,
2432
- label: e.label,
2433
- tone: e.tone,
2434
- shape: "band",
2435
- value: i === null ? "Unavailable" : n(i)
2436
- }, {
2437
- id: `${e.id}:range`,
2438
- label: e.rangeLabel,
2439
- tone: e.tone,
2440
- shape: "band",
2441
- value: a ? `${n(r.lower)} – ${n(r.upper)}` : "Unavailable"
2442
- }];
2443
- });
2444
- }
2445
- function Jn({ found: e, formatTimestamp: t }) {
2446
- return e.timestamp === void 0 ? `${e.crossing.label} · Not reached in this range` : `About ${t(e.timestamp)} · ${e.crossing.label}`;
2447
- }
2448
- function Yn(e) {
2449
- return /* @__PURE__ */ B(nr, {
2450
- ...e,
2451
- kind: "line",
2452
- isStacked: !1
2453
- });
2454
- }
2455
- function Xn({ isStacked: e = !1, ...t }) {
2456
- return /* @__PURE__ */ B(nr, {
2457
- ...t,
2458
- kind: "area",
2459
- isStacked: e
2460
- });
2461
- }
2462
- function Zn(e) {
2463
- return /* @__PURE__ */ B(Qn, { ...e });
2464
- }
2465
- function Qn({ title: e, description: n, series: i, actions: a, report: o, height: s = 180, showTimeAxis: c = !0 }) {
2466
- let l = M(), u = Zt(i.map((e) => ({
2467
- ...e,
2468
- points: []
2469
- })), !1);
2470
- return !Number.isFinite(s) || s < 48 ? /* @__PURE__ */ B(g, {
2471
- title: e,
2472
- description: n,
2473
- report: o,
2474
- message: "Chart height must be at least 48 pixels."
2475
- }) : /* @__PURE__ */ B("div", {
2476
- "aria-hidden": !0,
2477
- inert: !0,
2478
- className: "xeuugli",
2479
- children: /* @__PURE__ */ B(p, {
2480
- title: e,
2481
- description: n,
2482
- report: o,
2483
- series: u,
2484
- actions: a,
2485
- children: /* @__PURE__ */ V("div", {
2486
- className: "xrvj5dj x1n8ia3y",
2487
- children: [/* @__PURE__ */ B(ue, {
2488
- id: l,
2489
- label: void 0,
2490
- legend: u,
2491
- rows: [],
2492
- x: 0,
2493
- width: 0,
2494
- hasSeriesSummary: o?.seriesValues !== void 0
2495
- }), /* @__PURE__ */ V("div", {
2496
- ...k.props(w.plot),
2497
- children: [/* @__PURE__ */ B(t, { height: s - 16 }), c && /* @__PURE__ */ V("div", {
2498
- className: "x78zum5 x1qughib x8zbtdt x1c87qhr xiard35 xy8obcc xas2l8k xbixft xss6m8b",
2499
- children: [/* @__PURE__ */ B(r, { width: "8ch" }), /* @__PURE__ */ B(r, { width: "8ch" })]
2500
- })]
2501
- })]
2502
- })
2503
- })
2504
- });
2505
- }
2506
- function $n({ charts: e, ...t }) {
2507
- let n = P(null), [r, i] = F(), a = JSON.stringify(e.map((e) => [
2508
- e.id,
2509
- e.title,
2510
- Yt({
2511
- series: e.series,
2512
- markers: e.markers ?? [],
2513
- timestampUnit: t.timestampUnit,
2514
- isStacked: !1
2515
- })
2516
- ])), o = JSON.stringify(e[0]?.series[0]?.points.map((e) => e.timestamp) ?? []), s = e.every((e) => JSON.stringify(e.series[0]?.points.map((e) => e.timestamp) ?? []) === o);
2517
- if (r !== void 0 && r.signature !== a && i(void 0), !s || !m(e)) return /* @__PURE__ */ B(g, {
2518
- title: "Small multiples",
2519
- message: "Charts need unique identifiers and aligned observation timestamps."
2520
- });
2521
- if (e.length > $.panels) return /* @__PURE__ */ B(g, {
2522
- title: "Small multiples",
2523
- message: `Choose at most ${$.panels} panels.`
2524
- });
2525
- if (e.length === 0) return /* @__PURE__ */ B(p, {
2526
- title: "Small multiples",
2527
- children: /* @__PURE__ */ B("p", {
2528
- className: "x153jb6y",
2529
- children: "No charts"
2530
- })
2531
- });
2532
- let c = Math.max(52, ...e.flatMap((e) => e.series.flatMap((t) => t.points.flatMap((t) => t.value === null || !Number.isFinite(t.value) ? [] : [(e.formatTick ?? e.formatValue)(t.value).length * 7 + 12])))), l = e.every((e) => e.report !== void 0);
2533
- return /* @__PURE__ */ B("div", {
2534
- ref: n,
2535
- ...{
2536
- 0: { className: "xrvj5dj x1j825kq" },
2537
- 1: { className: "xrvj5dj xxhr3t" }
2538
- }[!!l | 0],
2539
- children: e.map((o, s) => /* @__PURE__ */ B("div", {
2540
- ...{
2541
- 0: {},
2542
- 1: { className: "x1y332i5" }
2543
- }[!!(l && s > 0) | 0],
2544
- children: /* @__PURE__ */ B(nr, {
2545
- ...t,
2546
- title: o.title,
2547
- description: o.description,
2548
- report: o.report,
2549
- series: o.series,
2550
- formatValue: o.formatValue,
2551
- formatTick: o.formatTick,
2552
- markers: o.markers,
2553
- kind: "line",
2554
- isStacked: !1,
2555
- sharedInspection: {
2556
- id: r?.signature === a ? r.id : null,
2557
- isSource: r?.chartId === o.id,
2558
- onChange: (e) => i(e === null ? void 0 : {
2559
- id: e,
2560
- signature: a,
2561
- chartId: o.id
2562
- }),
2563
- within: (e) => n.current?.contains(e) === !0
2564
- },
2565
- axisWidth: c,
2566
- showTimeAxis: s === e.length - 1
2567
- })
2568
- }, o.id))
2569
- });
2570
- }
2571
- function er({ charts: e, height: t }) {
2572
- if (!m(e) || e.length > $.panels) return /* @__PURE__ */ B(g, {
2573
- title: "Small multiples",
2574
- message: `Choose at most ${$.panels} panels with unique identifiers.`
2575
- });
2576
- let n = e.every((e) => e.report !== void 0);
2577
- return /* @__PURE__ */ B("div", {
2578
- "aria-hidden": !0,
2579
- inert: !0,
2580
- ...{
2581
- 0: { className: "xrvj5dj x1j825kq" },
2582
- 1: { className: "xrvj5dj xxhr3t" }
2583
- }[!!n | 0],
2584
- children: e.map((r, i) => /* @__PURE__ */ B("div", {
2585
- ...{
2586
- 0: {},
2587
- 1: { className: "x1y332i5" }
2588
- }[!!(n && i > 0) | 0],
2589
- children: /* @__PURE__ */ B(Qn, {
2590
- ...r,
2591
- height: t,
2592
- showTimeAxis: i === e.length - 1
2593
- })
2594
- }, r.id))
2595
- });
2596
- }
2597
- var tr = {
2598
- "x-default-marker": "x-default-marker",
2599
- $$css: !0
2600
- };
2601
- function nr({ title: t, description: n, series: r, timestampUnit: i, formatTimestamp: a, formatValue: o, formatTick: s = o, markers: c = [], height: d = 180, actions: f, report: m, kind: h, isStacked: y, sharedInspection: b, axisWidth: S, showTimeAxis: C = !0, bands: E = [], crossings: O = [], rangeSelection: A }) {
2602
- let j = E[0]?.points.map((e) => e.timestamp) ?? [], P = r[0]?.points.map((e) => e.timestamp) ?? j, F = !Number.isFinite(d) || d < 48 ? "Chart height must be at least 48 pixels." : qt({
2603
- series: r,
2604
- isStacked: y,
2605
- markers: c,
2606
- timeline: j
2607
- }) ?? ln({
2608
- bands: E,
2609
- crossings: O,
2610
- series: r,
2611
- timestamps: P
2612
- }) ?? rr({
2613
- rangeSelection: A,
2614
- timeline: P
2615
- }), I = N(() => F === void 0 ? Zt(r, y) : [], [
2616
- r,
2617
- y,
2618
- F
2619
- ]), L = N(() => F === void 0 ? un({
2620
- series: r,
2621
- bands: E
2622
- }) : [], [
2623
- r,
2624
- E,
2625
- F
2626
- ]), R = I[0]?.points ?? L[0]?.points ?? [], { ref: te, width: z } = T(), re = N(() => R.map(({ timestamp: e }) => ({
2627
- id: String(e),
2628
- label: a(e)
2629
- })), [R, a]), ie = `${Yt({
2630
- series: r,
2631
- markers: c,
2632
- timestampUnit: i,
2633
- isStacked: y
2634
- })}${Kn({
2635
- bands: E,
2636
- crossings: O
2637
- })}`, oe = [...I.map(({ id: e, label: t, tone: n }) => ({
2638
- id: e,
2639
- label: t,
2640
- tone: n
2641
- })), ...L.map(({ id: e, label: t, tone: n }) => ({
2642
- id: e,
2643
- label: t,
2644
- tone: n,
2645
- shape: "band"
2646
- }))], se = m?.seriesValues !== void 0, U = M();
2647
- if (F !== void 0) return /* @__PURE__ */ B(g, {
2648
- title: t,
2649
- description: n,
2650
- report: m,
2651
- message: F
2652
- });
2653
- if (R.length === 0) return /* @__PURE__ */ B(p, {
2654
- title: t,
2655
- description: n,
2656
- actions: f,
2657
- report: m,
2658
- series: oe,
2659
- children: /* @__PURE__ */ B("p", {
2660
- className: "x153jb6y",
2661
- children: "No observations"
2662
- })
2663
- });
2664
- let W = R.map((e) => e.timestamp), G = pn({
2665
- crossings: O,
2666
- series: r,
2667
- bands: E
2668
- }), K = [...c.flatMap((e) => e.kind === "event" ? [e] : []), ...G.flatMap(({ crossing: e, timestamp: t }) => t === void 0 ? [] : [{
2669
- id: e.id,
2670
- timestamp: t,
2671
- label: e.label,
2672
- value: e.value
2673
- }])];
2674
- function de(e) {
2675
- return {
2676
- label: e === void 0 ? void 0 : a(e),
2677
- rows: [...I.map((t) => {
2678
- let n = t.points.find((t) => t.timestamp === e);
2679
- return {
2680
- id: t.id,
2681
- label: t.label,
2682
- tone: t.tone,
2683
- value: n?.value === null || n === void 0 ? "Unavailable" : o(n.value)
2684
- };
2685
- }), ...qn({
2686
- bands: L,
2687
- timestamp: e,
2688
- formatValue: o
2689
- })],
2690
- notes: [...c.filter((t) => t.kind !== "event" && t.timestamp === e).map((e) => e.label), ...K.filter((t) => mn(W, t.timestamp) === e).map((e) => `${e.label} · ${a(e.timestamp)}`)]
2691
- };
2692
- }
2693
- let q = d - 28, fe = q + 12, J = R[0]?.timestamp ?? 0, Y = R.at(-1)?.timestamp ?? J, pe = [
2694
- ...I.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value + e.base])),
2695
- ...hn(E),
2696
- ...O.map((e) => e.value)
2697
- ], me = h === "area" ? Math.min(0, ...pe) : Math.min(...pe), he = h === "area" ? Math.max(0, ...pe) : Math.max(...pe), ge = Xt(pe.length === 0 ? 0 : me, pe.length === 0 ? 1 : he, h === "area"), _e = H({
2698
- domain: [...ge],
2699
- range: [q, 0]
2700
- }), X = S ?? Math.max(44, ..._e.ticks(3).map((e) => s(e).length * 7 + 12)), ve = Math.max(X + 1, z - 16), Z = H({
2701
- domain: [...Xt(J, Y)],
2702
- range: [X, ve]
2703
- }), ye = Bn({
2704
- instants: K,
2705
- x: Z,
2706
- right: ve
2707
- }), be = Vn(ye), Q = H({
2708
- domain: [...ge],
2709
- range: [q, be]
2710
- }), xe = Q.ticks(3);
2711
- function Se(e) {
2712
- return `${a(e[0])} to ${a(e[1])}`;
2713
- }
2714
- function Ce(e) {
2715
- let t = Z.invert(e.x / e.width * z), n = R.find((e, n) => {
2716
- let r = R[n + 1];
2717
- return r === void 0 || t <= e.timestamp + (r.timestamp - e.timestamp) / 2;
2718
- });
2719
- return n === void 0 ? void 0 : String(n.timestamp);
2720
- }
2721
- return /* @__PURE__ */ B("div", {
2722
- className: "xeuugli",
2723
- children: /* @__PURE__ */ B(x, {
2724
- items: re,
2725
- readout: (e) => le(de(Number(e))),
2726
- locate: Ce,
2727
- revision: ie,
2728
- inspected: b?.id,
2729
- onInspectedChange: b?.onChange,
2730
- within: b?.within,
2731
- render: (r, { inspected: d, cursor: g }) => {
2732
- let x = d === null ? void 0 : Number(d), S = de(b === void 0 || b.isSource ? x : void 0), T = /* @__PURE__ */ V(v, {
2733
- role: "img",
2734
- "aria-label": ee({
2735
- title: t,
2736
- marks: "observations",
2737
- isSelectable: !1
2738
- }),
2739
- "aria-describedby": U,
2740
- viewBox: `0 0 ${z} ${fe}`,
2741
- height: fe,
2742
- ...k.props(w.svg, w.inspectable, tr),
2743
- children: [
2744
- xe.map((e) => /* @__PURE__ */ V("g", { children: [/* @__PURE__ */ B("line", {
2745
- x1: X,
2746
- x2: ve,
2747
- y1: Q(e),
2748
- y2: Q(e),
2749
- ...k.props(e === 0 ? w.baseline : w.grid)
2750
- }), /* @__PURE__ */ B("text", {
2751
- x: X - 8,
2752
- y: Q(e),
2753
- textAnchor: "end",
2754
- dominantBaseline: "middle",
2755
- ...k.props(w.label, w.tick),
2756
- children: s(e)
2757
- })] }, e)),
2758
- O.map((e) => /* @__PURE__ */ B("line", {
2759
- x1: X,
2760
- x2: ve,
2761
- y1: Q(e.value),
2762
- y2: Q(e.value),
2763
- ...k.props(w.baseline)
2764
- }, e.id)),
2765
- /* @__PURE__ */ B(Un, {
2766
- bands: L,
2767
- x: Z,
2768
- y: Q
2769
- }),
2770
- I.map((t) => /* @__PURE__ */ V("g", { children: [h === "area" && /* @__PURE__ */ B(ae, {
2771
- data: [...t.points],
2772
- defined: (e) => e.value !== null,
2773
- x: (e) => Z(e.timestamp),
2774
- y0: (e) => Q(e.base),
2775
- y1: (e) => Q((e.value ?? 0) + e.base),
2776
- yScale: Q,
2777
- fill: e[t.tone],
2778
- fillOpacity: y ? .65 : .12
2779
- }), /* @__PURE__ */ B($t, {
2780
- series: t,
2781
- x: Z,
2782
- y: Q,
2783
- inspectedTimestamp: x
2784
- })] }, t.id)),
2785
- /* @__PURE__ */ B(Wn, {
2786
- placed: ye,
2787
- x: Z,
2788
- y: Q,
2789
- bottom: q
2790
- }),
2791
- c.filter((e) => e.kind !== "event").map((e) => /* @__PURE__ */ V("g", { children: [e.kind === "time" ? /* @__PURE__ */ B("line", {
2792
- x1: Z(e.timestamp),
2793
- x2: Z(e.timestamp),
2794
- y1: be,
2795
- y2: q,
2796
- className: "xhq4mlf x1ntoi03 x13efnbd"
2797
- }) : /* @__PURE__ */ B("circle", {
2798
- cx: Z(e.timestamp),
2799
- cy: Q(e.value + (I.find((t) => t.id === e.seriesId)?.points.find((t) => t.timestamp === e.timestamp)?.base ?? 0)),
2800
- r: 4,
2801
- fill: _.surface,
2802
- ...k.props(w.selected)
2803
- }), /* @__PURE__ */ B("title", { children: e.kind === "point" ? `${e.label}: ${o(e.value)}` : e.label })] }, e.id)),
2804
- x !== void 0 && /* @__PURE__ */ B("line", {
2805
- x1: Z(x),
2806
- x2: Z(x),
2807
- y1: be,
2808
- y2: q,
2809
- className: "xhq4mlf x1ntoi03 x13efnbd"
2810
- }),
2811
- g !== null && /* @__PURE__ */ B(l, {
2812
- x: Z(Number(g)),
2813
- top: be,
2814
- bottom: q,
2815
- width: Math.min(16, (ve - X) / 2)
2816
- })
2817
- ]
2818
- }), E = A === void 0 || Y === J ? T : /* @__PURE__ */ B(On, {
2819
- value: A.value,
2820
- onValueChange: A.onChange,
2821
- min: J,
2822
- max: Y,
2823
- step: A.step,
2824
- describe: Se,
2825
- label: `${t} time range`,
2826
- left: Z(J),
2827
- width: Z(Y) - Z(J),
2828
- height: q,
2829
- children: T
2830
- });
2831
- return /* @__PURE__ */ V(p, {
2832
- figure: r,
2833
- title: se ? t : /* @__PURE__ */ B(ce, {
2834
- title: t,
2835
- detail: S.label
2836
- }),
2837
- description: n,
2838
- report: m,
2839
- series: oe,
2840
- actions: f,
2841
- children: [/* @__PURE__ */ B(u, {
2842
- label: `${t} observations`,
2843
- columns: [
2844
- {
2845
- id: "time",
2846
- label: `Time (${i})`
2847
- },
2848
- ...I.map((e) => ({
2849
- id: `series:${e.id}`,
2850
- label: e.label
2851
- })),
2852
- ...L.flatMap((e) => [{
2853
- id: `band:${e.id}`,
2854
- label: e.label
2855
- }, {
2856
- id: `band-range:${e.id}`,
2857
- label: `${e.label}: ${e.rangeLabel}`
2858
- }])
2859
- ],
2860
- rows: R.map((e, t) => ({
2861
- id: e.timestamp,
2862
- values: [
2863
- a(e.timestamp),
2864
- ...I.map((e) => e.points[t]?.value === null || e.points[t]?.value === void 0 ? "Unavailable" : o(e.points[t].value)),
2865
- ...qn({
2866
- bands: L,
2867
- timestamp: e.timestamp,
2868
- formatValue: o
2869
- }).map((e) => e.value)
2870
- ]
2871
- }))
2872
- }), /* @__PURE__ */ V("div", {
2873
- className: "xrvj5dj x1n8ia3y",
2874
- children: [
2875
- /* @__PURE__ */ B(ue, {
2876
- id: U,
2877
- label: S.label,
2878
- legend: oe,
2879
- rows: S.rows,
2880
- x: Z(x ?? J),
2881
- width: z,
2882
- notes: S.notes,
2883
- hasSeriesSummary: se
2884
- }),
2885
- /* @__PURE__ */ V("div", {
2886
- ref: te,
2887
- ...k.props(w.plot),
2888
- children: [E, C && /* @__PURE__ */ V("div", {
2889
- "aria-hidden": !0,
2890
- ...k.props(Gn.timeAxis, Gn.timeAxisInset(X, Math.max(0, z - ve))),
2891
- children: [/* @__PURE__ */ B("span", {
2892
- className: "x1cqoux5 xeuugli xj0a0fe",
2893
- children: a(J)
2894
- }), Y !== J && /* @__PURE__ */ B("span", {
2895
- className: "x1cqoux5 xeuugli xj0a0fe xp4054r",
2896
- children: a(Y)
2897
- })]
2898
- })]
2899
- }),
2900
- A !== void 0 && Y !== J && /* @__PURE__ */ V("div", {
2901
- className: "x78zum5 x1a02dak x6s0dn4 x1qughib x1hnptsi x153jb6y xy8obcc xas2l8k xj0a0fe",
2902
- children: [/* @__PURE__ */ B("span", { children: A.value === null ? "Drag on the plot with a mouse to select a range of time." : `Selected range: ${Se(A.value)}` }), A.value === null ? /* @__PURE__ */ B(D, {
2903
- type: "button",
2904
- onClick: (e) => {
2905
- ne({ options: () => A }, "onChange", ir({
2906
- first: J,
2907
- last: Y,
2908
- rangeSelection: A
2909
- }), {
2910
- reason: "trigger-press",
2911
- event: e.nativeEvent
2912
- });
2913
- },
2914
- children: "Select a range"
2915
- }) : /* @__PURE__ */ B(D, {
2916
- type: "button",
2917
- onClick: (e) => {
2918
- ne({ options: () => A }, "onChange", null, {
2919
- reason: "clear-press",
2920
- event: e.nativeEvent
2921
- });
2922
- },
2923
- children: "Clear range"
2924
- })]
2925
- }),
2926
- c.length + G.length > 0 && /* @__PURE__ */ V("ul", {
2927
- className: "x78zum5 x1a02dak x1n8ia3y x1ghz6dp x1717udv xe8uvvx xy8obcc x153jb6y xj0a0fe",
2928
- children: [c.map((e) => /* @__PURE__ */ V("li", { children: [
2929
- a(e.timestamp),
2930
- " · ",
2931
- e.label,
2932
- e.kind === "point" && ` · ${o(e.value)}`
2933
- ] }, e.id)), G.map((e) => /* @__PURE__ */ B("li", { children: Jn({
2934
- found: e,
2935
- formatTimestamp: a
2936
- }) }, e.crossing.id))]
2937
- })
2938
- ]
2939
- })]
2940
- });
2941
- }
2942
- })
2943
- });
2944
- }
2945
- function rr({ rangeSelection: e, timeline: t }) {
2946
- let n = t[0], r = t.at(-1);
2947
- if (e === void 0 || n === void 0 || r === void 0) return;
2948
- let { step: i, value: a } = e, o = r - n;
2949
- if (o !== 0) {
2950
- if (!Number.isFinite(i) || i <= 0 || i > o) return "The range selection step must be finite, positive, and no longer than the observed time.";
2951
- if (a !== null && (!(a[0] >= n && a[1] <= r) || a[0] >= a[1])) return "The selected range must have ordered ends inside the observed time.";
2952
- }
2953
- }
2954
- function ir({ first: e, last: t, rangeSelection: n }) {
2955
- let r = Math.max(1, Math.round((t - e) / 4 / n.step)) * n.step, i = Math.min(e + r, t - n.step);
2956
- return [i, Math.min(t, Math.max(i + n.step, t - r))];
2957
- }
2958
- export { Xn as AreaChart, tt as BarChart, Ze as BarChartPlaceholder, at as BreakdownBar, jt as BridgeChart, Yn as LineChart, Lt as MAX_SCATTER_POINTS, Bt as ScatterPlot, $n as SmallMultiples, er as SmallMultiplesPlaceholder, rn as Sparkline, Zn as TimeSeriesChartPlaceholder, on as timeSeriesBandLimits, $ as timeSeriesLimits };
1
+ export { t as AreaChart, p as BarChart, m as BarChartPlaceholder, f as BreakdownBar, d as BridgeChart, n as LineChart, l as ScatterPlot, r as SmallMultiples, i as SmallMultiplesPlaceholder, s as Sparkline, a as TimeSeriesChartPlaceholder, u as scatterLimits, o as timeSeriesBandLimits, c as timeSeriesLimits } from "../time-series-BgzGNOk0.js";