@altertable/data-app 0.67.0 → 0.69.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 (183) hide show
  1. package/AGENTS.md +6 -0
  2. package/CONTRIBUTING.md +27 -1
  3. package/README.md +18 -21
  4. package/THIRD_PARTY_NOTICES +18 -0
  5. package/dist/chunks/index-22d576sn.js +153 -0
  6. package/dist/chunks/index-22d576sn.js.map +11 -0
  7. package/dist/chunks/{index-ktmvs916.js → index-2sbp9h2b.js} +37 -21
  8. package/dist/chunks/index-2sbp9h2b.js.map +13 -0
  9. package/dist/chunks/{index-23dktynd.js → index-ap60vggk.js} +4 -4
  10. package/dist/chunks/{index-m6n8ctfc.js → index-cv36cyna.js} +4 -4
  11. package/dist/chunks/index-cv36cyna.js.map +10 -0
  12. package/dist/chunks/{index-ag0cgnvq.js → index-k766wwwr.js} +13 -9
  13. package/dist/chunks/index-k766wwwr.js.map +13 -0
  14. package/dist/chunks/{index-mt93ff2b.js → index-kwnqycjt.js} +2 -2
  15. package/dist/chunks/index-kwnqycjt.js.map +10 -0
  16. package/dist/chunks/index-m0gbxtgp.js +355 -0
  17. package/dist/chunks/index-m0gbxtgp.js.map +13 -0
  18. package/dist/chunks/{index-8qfxv0h5.js → index-qhzdzca2.js} +3951 -2242
  19. package/dist/chunks/index-qhzdzca2.js.map +118 -0
  20. package/dist/chunks/{index-x69p7cv7.js → index-r7b1ftwy.js} +3 -3
  21. package/dist/chunks/index-r7b1ftwy.js.map +10 -0
  22. package/dist/chunks/{index-ev2b5aaf.js → index-sx488hvs.js} +4 -4
  23. package/dist/chunks/{index-f5cnbrjz.js → index-wss3gd3h.js} +39 -9
  24. package/dist/chunks/index-wss3gd3h.js.map +13 -0
  25. package/dist/chunks/{index-qd5xgx6y.js → index-zcqxfwdq.js} +5 -12
  26. package/dist/chunks/index-zcqxfwdq.js.map +13 -0
  27. package/dist/client/index.js +6 -6
  28. package/dist/core/appearance.js +1 -1
  29. package/dist/core/config.js +3 -3
  30. package/dist/core/contract.js +3 -3
  31. package/dist/core/format.js +10 -2
  32. package/dist/core/format.js.map +1 -1
  33. package/dist/embed/index.js +26 -25
  34. package/dist/embed/index.js.map +4 -4
  35. package/dist/index.js +3 -3
  36. package/dist/local.js +166 -144
  37. package/dist/local.js.map +8 -7
  38. package/dist/preview.js +1456 -0
  39. package/dist/preview.js.map +17 -0
  40. package/dist/react/embed/index.js +1 -1
  41. package/dist/react/index.js +272 -103
  42. package/dist/react/index.js.map +10 -11
  43. package/dist/react/ui/index.js +2124 -1254
  44. package/dist/react/ui/index.js.map +20 -13
  45. package/dist/server.js +68 -57
  46. package/dist/server.js.map +7 -6
  47. package/dist/types/client/download.d.ts +5 -0
  48. package/dist/types/client/iframe.d.ts +4 -2
  49. package/dist/types/client/logger.d.ts +10 -2
  50. package/dist/types/core/annotations.d.ts +5 -0
  51. package/dist/types/core/appearance.d.ts +2 -0
  52. package/dist/types/core/bridge-endpoint.d.ts +2 -2
  53. package/dist/types/core/bridge.d.ts +22 -0
  54. package/dist/types/core/config.d.ts +5 -0
  55. package/dist/types/core/contract.d.ts +3 -1
  56. package/dist/types/core/date-format.d.ts +24 -0
  57. package/dist/types/core/dimension.d.ts +2 -1
  58. package/dist/types/core/filters.d.ts +4 -3
  59. package/dist/types/core/format.d.ts +5 -3
  60. package/dist/types/core/messages.d.ts +3 -1
  61. package/dist/types/core/operation-types.d.ts +7 -7
  62. package/dist/types/core/time-interval.d.ts +96 -0
  63. package/dist/types/core/variables.d.ts +13 -4
  64. package/dist/types/embed/host.d.ts +4 -4
  65. package/dist/types/react/annotations/annotation-editor-state.d.ts +2 -0
  66. package/dist/types/react/annotations/annotation-targets.d.ts +1 -0
  67. package/dist/types/react/annotations/getAnnotationProps.d.ts +5 -3
  68. package/dist/types/react/annotations/useAnnotationGeometry.d.ts +2 -2
  69. package/dist/types/react/bindings.d.ts +26 -3
  70. package/dist/types/react/date-formatting.d.ts +12 -0
  71. package/dist/types/react/hooks.d.ts +10 -9
  72. package/dist/types/react/index.d.ts +7 -2
  73. package/dist/types/react/search-suggestions.d.ts +8 -0
  74. package/dist/types/react/style-contract.d.ts +13 -5
  75. package/dist/types/react/ui/ChartLegend.d.ts +4 -3
  76. package/dist/types/react/ui/ChoicePicker.d.ts +2 -0
  77. package/dist/types/react/ui/ComposedChart.d.ts +1 -1
  78. package/dist/types/react/ui/DataApp.d.ts +5 -4
  79. package/dist/types/react/ui/DataAppFrame.d.ts +14 -3
  80. package/dist/types/react/ui/DataTable.d.ts +6 -4
  81. package/dist/types/react/ui/DataWidget.d.ts +4 -0
  82. package/dist/types/react/ui/DateDisplay.d.ts +9 -0
  83. package/dist/types/react/ui/DateRangePicker.d.ts +3 -1
  84. package/dist/types/react/ui/DateTimeTooltip.d.ts +3 -2
  85. package/dist/types/react/ui/DimensionPicker.d.ts +3 -1
  86. package/dist/types/react/ui/EmptyState.d.ts +1 -1
  87. package/dist/types/react/ui/FunnelChart.d.ts +20 -0
  88. package/dist/types/react/ui/GradientScroll.d.ts +8 -0
  89. package/dist/types/react/ui/Grid.d.ts +1 -1
  90. package/dist/types/react/ui/JourneyChart.d.ts +10 -0
  91. package/dist/types/react/ui/MetricWidget.d.ts +2 -0
  92. package/dist/types/react/ui/NumberFilterPicker.d.ts +3 -1
  93. package/dist/types/react/ui/PeriodSummary.d.ts +2 -1
  94. package/dist/types/react/ui/PickerField.d.ts +15 -0
  95. package/dist/types/react/ui/PopoverSurface.d.ts +5 -0
  96. package/dist/types/react/ui/RequestHint.d.ts +2 -2
  97. package/dist/types/react/ui/RetentionChart.d.ts +27 -0
  98. package/dist/types/react/ui/SearchField.d.ts +3 -1
  99. package/dist/types/react/ui/SearchTypeahead.d.ts +15 -0
  100. package/dist/types/react/ui/SectionHeading.d.ts +8 -0
  101. package/dist/types/react/ui/Select.d.ts +5 -1
  102. package/dist/types/react/ui/Sheet.d.ts +3 -1
  103. package/dist/types/react/ui/TableWidget.d.ts +8 -0
  104. package/dist/types/react/ui/Tabs.d.ts +4 -3
  105. package/dist/types/react/ui/VariableBar.d.ts +1 -1
  106. package/dist/types/react/ui/VisualizationWidget.d.ts +1 -1
  107. package/dist/types/react/ui/chart-data.d.ts +9 -0
  108. package/dist/types/react/ui/chart-date-axis.d.ts +15 -0
  109. package/dist/types/react/ui/chart-interaction.d.ts +21 -0
  110. package/dist/types/react/ui/chart-primitives.d.ts +7 -5
  111. package/dist/types/react/ui/chart-time.d.ts +16 -0
  112. package/dist/types/react/ui/chartColor.d.ts +1 -0
  113. package/dist/types/react/ui/icons.d.ts +3 -1
  114. package/dist/types/react/ui/index.d.ts +15 -4
  115. package/dist/types/react/ui/journey-flow.d.ts +49 -0
  116. package/dist/types/react/ui/metric-comparison.d.ts +2 -2
  117. package/dist/types/react/ui/metric.d.ts +2 -2
  118. package/dist/types/react/ui/presentation.d.ts +2 -0
  119. package/dist/types/react/ui/searchItems.d.ts +2 -0
  120. package/dist/types/react/ui/useSvgId.d.ts +2 -0
  121. package/dist/types/react/ui/variables.d.ts +1 -1
  122. package/dist/types/react/view-control-bar.d.ts +16 -0
  123. package/dist/types/react/view-controls.d.ts +3 -2
  124. package/dist/types/react/view-runtime.d.ts +3 -1
  125. package/dist/types/react/view.d.ts +14 -2
  126. package/dist/types/server/local.d.ts +3 -1
  127. package/dist/types/server/preview/host.d.ts +1 -0
  128. package/dist/types/server/preview/index.d.ts +16 -0
  129. package/dist/types/server/reload-channel.d.ts +6 -0
  130. package/dist/types/server/request-body.d.ts +4 -0
  131. package/dist/worker.js +2 -2
  132. package/docs/app-authoring.md +17 -9
  133. package/docs/client.md +1 -1
  134. package/docs/contract.md +10 -10
  135. package/docs/embed.md +11 -3
  136. package/docs/formatting-and-appearance.md +36 -5
  137. package/docs/layout.md +31 -8
  138. package/docs/react-embed.md +4 -4
  139. package/docs/react.md +1 -1
  140. package/docs/server-bun.md +25 -0
  141. package/docs/server.md +1 -1
  142. package/docs/styling.md +7 -28
  143. package/docs/ui.md +33 -12
  144. package/docs/variables.md +92 -15
  145. package/docs/views.md +13 -36
  146. package/docs/widgets.md +38 -23
  147. package/docs/worker.md +2 -1
  148. package/examples/starter-data-app/index.tsx +0 -1
  149. package/examples/starter-local-data-app/.bun-version +1 -0
  150. package/examples/starter-local-data-app/.node-version +1 -0
  151. package/examples/starter-local-data-app/.oxfmtrc.json +4 -0
  152. package/examples/starter-local-data-app/.oxlintrc.json +33 -0
  153. package/examples/starter-local-data-app/AGENTS.md +22 -0
  154. package/examples/starter-local-data-app/README.md +54 -0
  155. package/examples/starter-local-data-app/app.ts +22 -0
  156. package/examples/starter-local-data-app/bunfig.toml +2 -0
  157. package/examples/starter-local-data-app/package.json +33 -0
  158. package/examples/starter-local-data-app/src/App.tsx +8 -0
  159. package/examples/starter-local-data-app/src/assets.d.ts +1 -0
  160. package/examples/starter-local-data-app/src/data-context.ts +21 -0
  161. package/examples/starter-local-data-app/src/favicon.svg +13 -0
  162. package/examples/starter-local-data-app/src/index.html +14 -0
  163. package/examples/starter-local-data-app/src/main.tsx +7 -0
  164. package/examples/starter-local-data-app/src/operations.ts +6 -0
  165. package/examples/starter-local-data-app/src/server.ts +6 -0
  166. package/examples/starter-local-data-app/tsconfig.json +15 -0
  167. package/package.json +13 -3
  168. package/dist/chunks/index-8qfxv0h5.js.map +0 -108
  169. package/dist/chunks/index-ag0cgnvq.js.map +0 -13
  170. package/dist/chunks/index-dq7b35fn.js +0 -307
  171. package/dist/chunks/index-dq7b35fn.js.map +0 -13
  172. package/dist/chunks/index-f5cnbrjz.js.map +0 -13
  173. package/dist/chunks/index-ktmvs916.js.map +0 -13
  174. package/dist/chunks/index-m6n8ctfc.js.map +0 -10
  175. package/dist/chunks/index-mev09s5v.js +0 -77
  176. package/dist/chunks/index-mev09s5v.js.map +0 -10
  177. package/dist/chunks/index-mt93ff2b.js.map +0 -10
  178. package/dist/chunks/index-qd5xgx6y.js.map +0 -13
  179. package/dist/chunks/index-x69p7cv7.js.map +0 -10
  180. package/dist/types/react/shellStyles.d.ts +0 -3
  181. package/dist/types/react/ui/DataAppSkeleton.d.ts +0 -7
  182. /package/dist/chunks/{index-23dktynd.js.map → index-ap60vggk.js.map} +0 -0
  183. /package/dist/chunks/{index-ev2b5aaf.js.map → index-sx488hvs.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
- injectStyles,
3
2
  injectDataAppStyles2,
3
+ useDateFormatting2,
4
4
  AppIcon2,
5
5
  classNames,
6
6
  Button2,
@@ -10,8 +10,8 @@ import {
10
10
  Tooltip2,
11
11
  GradientScroll2,
12
12
  Sheet2,
13
- TabList2,
14
13
  TabPanels2,
14
+ TabList2,
15
15
  Tab2,
16
16
  TabPanel2,
17
17
  Tabs2,
@@ -19,17 +19,21 @@ import {
19
19
  AboutData2,
20
20
  DataAppProvider2,
21
21
  useDeclaredResult,
22
+ HelpPopover2,
23
+ DateDisplay2,
22
24
  validateChoiceOptions,
23
25
  useAppVariables2,
26
+ SearchField2,
27
+ SearchMatch2,
28
+ matchSearchText2,
29
+ searchItems2,
30
+ SearchTypeahead2,
24
31
  Select2,
25
32
  FilterActions2,
33
+ VariableBar2,
26
34
  NumberField2,
27
35
  NumberRangeField2,
28
36
  NumberFilterPicker2,
29
- SearchField2,
30
- Skeleton2,
31
- SearchMatch2,
32
- searchItems2,
33
37
  ChoicePicker2,
34
38
  CheckboxGroupContext,
35
39
  Checkbox2,
@@ -46,13 +50,10 @@ import {
46
50
  MenuSeparator2,
47
51
  LiveControl2,
48
52
  PresentStory2,
49
- VariableBar2,
50
53
  DataAppFrame,
51
- Grid2,
52
54
  DataWidget2,
53
55
  VisualizationWidget2,
54
56
  MetricWidget2,
55
- HelpPopover2,
56
57
  DataTable2,
57
58
  DataTableShare2,
58
59
  DataTableEmptyRow2,
@@ -60,755 +61,28 @@ import {
60
61
  TableWidget2,
61
62
  TextWidget2,
62
63
  DataValue2,
63
- createDataContext2
64
- } from "../../chunks/index-8qfxv0h5.js";
65
- import"../../chunks/index-mev09s5v.js";
66
- import"../../chunks/index-ag0cgnvq.js";
67
- import"../../chunks/index-mt93ff2b.js";
68
- import"../../chunks/index-m6n8ctfc.js";
64
+ chartBarFill,
65
+ createDataContext2,
66
+ SectionHeading2
67
+ } from "../../chunks/index-qhzdzca2.js";
68
+ import {
69
+ formatDate2,
70
+ parseDateTime2,
71
+ formatDateTime2,
72
+ formatNumber2,
73
+ formatPercent2
74
+ } from "../../chunks/index-22d576sn.js";
75
+ import"../../chunks/index-k766wwwr.js";
76
+ import"../../chunks/index-kwnqycjt.js";
77
+ import"../../chunks/index-cv36cyna.js";
69
78
  import {
70
79
  createDataClient2
71
- } from "../../chunks/index-23dktynd.js";
72
- import"../../chunks/index-x69p7cv7.js";
73
- import"../../chunks/index-ev2b5aaf.js";
80
+ } from "../../chunks/index-ap60vggk.js";
81
+ import"../../chunks/index-r7b1ftwy.js";
82
+ import"../../chunks/index-sx488hvs.js";
74
83
  import {
75
84
  invariant
76
- } from "../../chunks/index-qd5xgx6y.js";
77
-
78
- // src/react/shellStyles.ts
79
- function injectDataAppShellStyles(options = {}) {
80
- return injectStyles({
81
- name: "injectDataAppShellStyles",
82
- attribute: "data-altertable-shell-styles",
83
- css: `/* src/react/tokens.css */
84
- @layer atbl.tokens {
85
- :root {
86
- --atbl-control-text-size: var(--atbl-type-body-size);
87
- --atbl-background: var(--atbl-palette-background);
88
- --atbl-surface: var(--atbl-palette-surface);
89
- --atbl-subtle: var(--atbl-palette-subtle);
90
- --atbl-backdrop: #0f171e38;
91
- --atbl-text: var(--atbl-palette-text);
92
- --atbl-muted: var(--atbl-palette-muted);
93
- --atbl-border: var(--atbl-palette-border);
94
- --atbl-accent: var(--atbl-input-accent, #405d47);
95
- --atbl-on-accent: var(--atbl-input-on-accent, #fff);
96
- --atbl-danger: #b42318;
97
- --atbl-danger-subtle: color-mix(in srgb, var(--atbl-danger) 9%, var(--atbl-surface));
98
- --atbl-code-surface: #f4f6f9;
99
- --atbl-code-text: #273242;
100
- --atbl-mono-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
101
- --atbl-focus-ring-offset: 2px;
102
- --atbl-focus-ring-inset: -1px;
103
- --atbl-font: var(--atbl-input-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, ui-sans-serif, sans-serif);
104
- --atbl-space-xs: 5px;
105
- --atbl-space-sm: 10px;
106
- --atbl-space-md: 16px;
107
- --atbl-space-lg: 24px;
108
- --atbl-space-xl: 32px;
109
- --atbl-content-width: 960px;
110
- --atbl-control-height: 2.375rem;
111
- --atbl-control-compact-height: 1.875rem;
112
- --atbl-control-icon-size: 1rem;
113
- --atbl-control-padding-inline: .75rem;
114
- --atbl-control-padding-block: .375rem;
115
- --atbl-control-gap: .5rem;
116
- --atbl-control-disabled-opacity: .5;
117
- --atbl-radius-control: 7px;
118
- --atbl-radius-surface: 12px;
119
- --atbl-radius-overlay: 16px;
120
- --atbl-shadow-surface: 0 3px 16px #141c280d;
121
- --atbl-shadow-overlay: 0 18px 50px #00000029;
122
- --atbl-shadow-control: 0 1px 3px #0000001a;
123
- --atbl-cursor-action: pointer;
124
- --atbl-cursor-disabled: default;
125
- --atbl-cursor-help: help;
126
- --atbl-cursor-busy: progress;
127
- --atbl-duration-fast: .12s;
128
- --atbl-duration-normal: .18s;
129
- --atbl-duration-slow: .24s;
130
- --atbl-ease-standard: ease;
131
- --atbl-ease-enter: cubic-bezier(.2, .7, .2, 1);
132
- --atbl-chart-1: color-mix(in srgb, var(--atbl-input-chart-1, #285fc0) var(--atbl-chart-strength), white);
133
- --atbl-chart-2: color-mix(in srgb, var(--atbl-input-chart-2, #a95319) var(--atbl-chart-strength), white);
134
- --atbl-chart-3: color-mix(in srgb, var(--atbl-input-chart-3, #147862) var(--atbl-chart-strength), white);
135
- --atbl-chart-4: color-mix(in srgb, var(--atbl-input-chart-4, #7243aa) var(--atbl-chart-strength), white);
136
- --atbl-chart-5: color-mix(in srgb, var(--atbl-input-chart-5, #aa3958) var(--atbl-chart-strength), white);
137
- --atbl-chart-6: color-mix(in srgb, var(--atbl-input-chart-6, #475569) var(--atbl-chart-strength), white);
138
- --atbl-chart-7: color-mix(in srgb, var(--atbl-input-chart-7, #285fc0) var(--atbl-chart-strength), white);
139
- --atbl-chart-8: color-mix(in srgb, var(--atbl-input-chart-8, #a95319) var(--atbl-chart-strength), white);
140
- --atbl-type-emphasis-weight: 680;
141
- --atbl-type-meta-weight: 500;
142
- --atbl-type-page-size: clamp(1.375rem, 2.4vw, 1.75rem);
143
- --atbl-type-section-size: 1.25rem;
144
- --atbl-type-widget-size: 1.0625rem;
145
- --atbl-type-body-size: .875rem;
146
- --atbl-type-label-size: .8125rem;
147
- --atbl-type-meta-size: .75rem;
148
- --atbl-type-metric-size: clamp(1.625rem, 3vw, 2.125rem);
149
- --atbl-type-heading-weight: 650;
150
- --atbl-type-label-weight: 600;
151
- --atbl-type-body-leading: 1.65;
152
- --atbl-type-label-leading: 1.4;
153
- --atbl-type-heading-leading: 1.3;
154
- --atbl-type-metric-leading: 1.08;
155
- --atbl-text-measure: 70ch;
156
- }
157
- }
158
-
159
- /* src/react/appearance.css */
160
- @layer atbl.tokens {
161
- :root {
162
- --atbl-palette-background: #fff;
163
- --atbl-palette-surface: #fff;
164
- --atbl-palette-subtle: #f6f7f7;
165
- --atbl-palette-text: #202124;
166
- --atbl-palette-muted: #687078;
167
- --atbl-palette-border: #e3e6e8;
168
- --atbl-chart-strength: 100%;
169
- --atbl-accent-subtle-strength: 12%;
170
- }
171
-
172
- :root[data-atbl-theme="dark"] {
173
- --atbl-palette-background: #151719;
174
- --atbl-palette-surface: #202326;
175
- --atbl-palette-subtle: #292d31;
176
- --atbl-palette-text: #f2f3f4;
177
- --atbl-palette-muted: #aeb5bc;
178
- --atbl-palette-border: #3b4248;
179
- }
180
-
181
- :root[data-atbl-base-color="slate"] {
182
- --atbl-palette-background: #f8fafc;
183
- --atbl-palette-surface: #fff;
184
- --atbl-palette-subtle: #f1f5f9;
185
- --atbl-palette-text: #17212f;
186
- --atbl-palette-muted: #607083;
187
- --atbl-palette-border: #dce3ea;
188
- }
189
-
190
- :root[data-atbl-base-color="slate"][data-atbl-theme="dark"] {
191
- --atbl-palette-background: #111820;
192
- --atbl-palette-surface: #1b2530;
193
- --atbl-palette-subtle: #263340;
194
- --atbl-palette-text: #f0f4f8;
195
- --atbl-palette-muted: #a8b5c3;
196
- --atbl-palette-border: #3a4857;
197
- }
198
-
199
- :root[data-atbl-base-color="warm"] {
200
- --atbl-palette-background: #fbfaf8;
201
- --atbl-palette-surface: #fff;
202
- --atbl-palette-subtle: #f5f2ed;
203
- --atbl-palette-text: #292723;
204
- --atbl-palette-muted: #736e66;
205
- --atbl-palette-border: #e8e2da;
206
- }
207
-
208
- :root[data-atbl-base-color="warm"][data-atbl-theme="dark"] {
209
- --atbl-palette-background: #1b1916;
210
- --atbl-palette-surface: #25221e;
211
- --atbl-palette-subtle: #302c27;
212
- --atbl-palette-text: #f5f1eb;
213
- --atbl-palette-muted: #bcb3a8;
214
- --atbl-palette-border: #494239;
215
- }
216
-
217
- :root[data-atbl-theme="dark"] {
218
- --atbl-accent: var(--atbl-input-dark-accent, color-mix(in srgb, var(--atbl-input-accent, #405d47) 50%, white));
219
- --atbl-accent-subtle-strength: 22%;
220
- --atbl-on-accent: var(--atbl-input-on-accent, var(--atbl-background));
221
- --atbl-danger: #f97066;
222
- --atbl-backdrop: #0000008c;
223
- --atbl-code-surface: #242a31;
224
- --atbl-code-text: #e5e9ef;
225
- --atbl-chart-strength: 60%;
226
- }
227
-
228
- :root[data-atbl-density="compact"] {
229
- --atbl-control-height: 2.125rem;
230
- --atbl-control-padding-inline: .625rem;
231
- --atbl-control-padding-block: .25rem;
232
- --atbl-space-xs: 4px;
233
- --atbl-space-sm: 8px;
234
- --atbl-space-md: 12px;
235
- --atbl-space-lg: 18px;
236
- --atbl-space-xl: 24px;
237
- }
238
-
239
- :root[data-atbl-density="spacious"] {
240
- --atbl-control-height: 2.625rem;
241
- --atbl-control-padding-inline: 1rem;
242
- --atbl-control-padding-block: .5rem;
243
- --atbl-space-xs: 6px;
244
- --atbl-space-sm: 12px;
245
- --atbl-space-md: 20px;
246
- --atbl-space-lg: 30px;
247
- --atbl-space-xl: 40px;
248
- }
249
-
250
- :root[data-atbl-radius="none"] {
251
- --atbl-radius-control: 0px;
252
- --atbl-radius-surface: 0px;
253
- --atbl-radius-overlay: 0px;
254
- }
255
-
256
- :root[data-atbl-radius="small"] {
257
- --atbl-radius-control: 4px;
258
- --atbl-radius-surface: 7px;
259
- --atbl-radius-overlay: 9px;
260
- }
261
-
262
- :root[data-atbl-radius="large"] {
263
- --atbl-radius-control: 10px;
264
- --atbl-radius-surface: 18px;
265
- --atbl-radius-overlay: 24px;
266
- }
267
-
268
- :root[data-atbl-elevation="flat"] {
269
- --atbl-shadow-surface: none;
270
- --atbl-shadow-overlay: none;
271
- --atbl-shadow-control: none;
272
- }
273
-
274
- :root[data-atbl-elevation="raised"] {
275
- --atbl-shadow-surface: 0 8px 28px #141c281a;
276
- --atbl-shadow-overlay: 0 24px 72px #0000003d;
277
- }
278
-
279
- @media (forced-colors: active) {
280
- :root {
281
- --atbl-focus-color: Highlight !important;
282
- --atbl-on-accent: HighlightText !important;
283
- }
284
- }
285
- }
286
-
287
- /* src/react/base.css */
288
- @layer atbl.base {
289
- :where([class^="altertable-"], [class*=" altertable-"]) {
290
- box-sizing: border-box;
291
- }
292
-
293
- :where([class^="altertable-"], [class*=" altertable-"]) * {
294
- box-sizing: border-box;
295
- }
296
-
297
- :where([class^="starter-"], [class*=" starter-"]) * {
298
- box-sizing: border-box;
299
- }
300
-
301
- :where([class^="altertable-"], [class*=" altertable-"]) button {
302
- font: inherit;
303
- }
304
-
305
- :root[data-atbl-appearance] {
306
- scrollbar-gutter: stable;
307
- font-family: var(--atbl-font);
308
- color: var(--atbl-text);
309
- background: var(--atbl-background);
310
- font-synthesis: none;
311
- -webkit-font-smoothing: antialiased;
312
- text-rendering: optimizeLegibility;
313
- }
314
-
315
- :root[data-atbl-theme="light"] {
316
- --buncss-light: initial;
317
- --buncss-dark: ;
318
- color-scheme: light;
319
- }
320
-
321
- :root[data-atbl-theme="dark"] {
322
- --buncss-light: ;
323
- --buncss-dark: initial;
324
- color-scheme: dark;
325
- }
326
-
327
- :root[data-atbl-appearance] body, :root[data-atbl-appearance] #root {
328
- margin: 0;
329
- }
330
-
331
- .altertable-sr-only {
332
- position: fixed;
333
- overflow: hidden;
334
- clip: rect(0, 0, 0, 0);
335
- clip-path: inset(50%);
336
- white-space: nowrap;
337
- border: 0;
338
- width: 1px;
339
- height: 1px;
340
- margin: -1px;
341
- padding: 0;
342
- }
343
- }
344
-
345
- /* src/react/ui/Skeleton.css */
346
- @layer atbl.components {
347
- .altertable-skeleton {
348
- display: block;
349
- border-radius: var(--atbl-radius-control);
350
- background: var(--atbl-subtle);
351
- opacity: 0;
352
- animation: altertable-skeleton-in .2s var(--atbl-ease-standard) .2s forwards, altertable-skeleton-pulse 1.4s ease-in-out .4s infinite alternate;
353
- }
354
-
355
- .altertable-skeleton[data-inline] {
356
- display: inline-block;
357
- vertical-align: middle;
358
- width: 8ch;
359
- height: 1em;
360
- }
361
-
362
- @keyframes altertable-skeleton-in {
363
- to {
364
- opacity: 1;
365
- }
366
- }
367
-
368
- @keyframes altertable-skeleton-pulse {
369
- to {
370
- opacity: .5;
371
- }
372
- }
373
-
374
- @media (prefers-reduced-motion: reduce) {
375
- .altertable-skeleton {
376
- animation: 1ms .2s forwards altertable-skeleton-in;
377
- }
378
- }
379
- }
380
-
381
- /* src/react/ui/Grid.css */
382
- @layer atbl.components {
383
- .altertable-grid {
384
- display: grid;
385
- container: altertable-grid / inline-size;
386
- --atbl-grid-gap: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
387
- --atbl-grid-min-item-width: 240px;
388
- --atbl-grid-column-width: 100%;
389
- --atbl-grid-max-columns: 1;
390
- align-content: start;
391
- align-items: start;
392
- gap: var(--atbl-grid-gap);
393
- grid-template-columns: repeat(auto-fit, minmax(min(100%, max(var(--atbl-grid-min-item-width), var(--atbl-grid-column-width))), 1fr));
394
- min-width: 0;
395
- }
396
-
397
- .altertable-grid > * {
398
- min-width: 0;
399
- min-height: 0;
400
- margin: 0;
401
- }
402
-
403
- .altertable-grid[data-align="stretch"] {
404
- align-items: stretch;
405
- }
406
-
407
- .altertable-grid[data-gap="sm"] {
408
- --atbl-grid-gap: var(--atbl-space-sm);
409
- }
410
-
411
- .altertable-grid[data-gap="md"] {
412
- --atbl-grid-gap: var(--atbl-space-md);
413
- }
414
-
415
- .altertable-grid[data-gap="lg"] {
416
- --atbl-grid-gap: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
417
- }
418
-
419
- .altertable-grid[data-min-item-width="compact"] {
420
- --atbl-grid-min-item-width: 192px;
421
- }
422
-
423
- .altertable-grid[data-min-item-width="wide"] {
424
- --atbl-grid-min-item-width: 320px;
425
- }
426
-
427
- .altertable-grid[data-columns="2"] {
428
- --atbl-grid-max-columns: 2;
429
- --atbl-grid-column-width: calc((100% - var(--atbl-grid-gap)) / 2);
430
- }
431
-
432
- .altertable-grid[data-columns="3"] {
433
- --atbl-grid-max-columns: 3;
434
- --atbl-grid-column-width: calc((100% - var(--atbl-grid-gap) - var(--atbl-grid-gap)) / 3);
435
- }
436
-
437
- .altertable-grid[data-columns="4"] {
438
- --atbl-grid-max-columns: 4;
439
- --atbl-grid-column-width: calc((100% - var(--atbl-grid-gap) - var(--atbl-grid-gap) - var(--atbl-grid-gap)) / 4);
440
- }
441
-
442
- .altertable-grid-item {
443
- min-width: 0;
444
- min-height: 0;
445
- }
446
-
447
- .altertable-grid > * {
448
- --atbl-grid-fitting-columns: clamp(1, round(down, tan(atan2(100cqw + var(--atbl-grid-gap) + .001px, var(--atbl-grid-min-item-width) + var(--atbl-grid-gap))), 1), var(--atbl-grid-max-columns));
449
- }
450
-
451
- .altertable-grid > .altertable-grid-item[data-span="2"] {
452
- grid-column: span min(2, var(--atbl-grid-fitting-columns));
453
- }
454
-
455
- .altertable-grid[data-columns="3"]:has( > .altertable-grid-item[data-span="2"]) > :not(.altertable-grid-item[data-span="2"]) {
456
- grid-column: span clamp(1, (3 - var(--atbl-grid-fitting-columns)) * 2, var(--atbl-grid-fitting-columns));
457
- }
458
-
459
- .altertable-grid[data-columns="3"]:not(:has( > .altertable-grid-item[data-span="2"])) > :last-child:nth-child(odd) {
460
- grid-column: span clamp(1, (3 - var(--atbl-grid-fitting-columns)) * 2, var(--atbl-grid-fitting-columns));
461
- }
462
- }
463
-
464
- /* src/react/ui/DataWidget.css */
465
- @layer atbl.components {
466
- .altertable-data-widget {
467
- border: 1px solid var(--atbl-border);
468
- border-radius: calc(var(--atbl-radius-surface) * 1.5);
469
- corner-shape: squircle;
470
- background: var(--atbl-surface);
471
- box-shadow: var(--atbl-shadow-surface);
472
- min-width: 0;
473
- }
474
-
475
- .altertable-data-widget-header {
476
- display: flex;
477
- justify-content: space-between;
478
- align-items: flex-start;
479
- gap: var(--atbl-space-md);
480
- padding: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg))) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg))) 0;
481
- min-height: 30px;
482
- }
483
-
484
- .altertable-data-widget-header > div:first-child {
485
- flex: 1;
486
- min-width: 0;
487
- }
488
-
489
- .altertable-data-widget-help {
490
- display: flex;
491
- flex: none;
492
- align-items: flex-start;
493
- }
494
-
495
- .altertable-data-widget-header h2 {
496
- color: var(--atbl-text);
497
- font-family: var(--atbl-font-heading, var(--atbl-input-font-heading, var(--atbl-font)));
498
- font-size: var(--atbl-type-widget-size);
499
- font-weight: var(--atbl-type-heading-weight);
500
- line-height: var(--atbl-type-heading-leading);
501
- letter-spacing: -.02em;
502
- margin: 0;
503
- }
504
-
505
- .altertable-data-widget-count {
506
- color: var(--atbl-muted);
507
- font-size: var(--atbl-type-meta-size);
508
- font-weight: var(--atbl-type-meta-weight);
509
- letter-spacing: 0;
510
- white-space: nowrap;
511
- margin-left: 8px;
512
- }
513
-
514
- .altertable-data-widget-header p {
515
- color: var(--atbl-muted);
516
- font-size: var(--atbl-type-meta-size);
517
- margin: 4px 0 0;
518
- line-height: 1.45;
519
- }
520
-
521
- .altertable-data-widget-body {
522
- padding: var(--atbl-space-md) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg))) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
523
- min-width: 0;
524
- }
525
-
526
- .altertable-data-widget-body[data-padding="flush"] {
527
- padding: 0;
528
- }
529
-
530
- .altertable-data-widget-footer {
531
- padding: var(--atbl-space-md) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
532
- }
533
-
534
- .altertable-data-widget-body > .altertable-status-panel {
535
- background: none;
536
- border: 0;
537
- border-radius: 0;
538
- margin: 0;
539
- padding: 0;
540
- }
541
- }
542
-
543
- /* src/react/ui/MetricWidget.css */
544
- @layer atbl.components {
545
- .altertable-metric-widget {
546
- display: flex;
547
- padding: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
548
- border: 1px solid var(--atbl-border);
549
- border-radius: calc(var(--atbl-radius-surface) * 1.5);
550
- corner-shape: squircle;
551
- background: var(--atbl-surface);
552
- box-shadow: var(--atbl-shadow-surface);
553
- flex-direction: column;
554
- min-width: 0;
555
- }
556
-
557
- .altertable-metric-widget.altertable-data-widget {
558
- padding: 0;
559
- }
560
-
561
- .altertable-metric-widget > .altertable-data-widget-header {
562
- min-height: 0;
563
- }
564
-
565
- .altertable-metric-widget > .altertable-data-widget-header h2 {
566
- color: var(--atbl-muted);
567
- font-family: inherit;
568
- font-size: var(--atbl-type-label-size);
569
- font-weight: var(--atbl-type-label-weight);
570
- letter-spacing: normal;
571
- }
572
-
573
- .altertable-metric-widget > .altertable-data-widget-body {
574
- padding-top: 0;
575
- }
576
-
577
- .altertable-metric-widget > .altertable-data-widget-body:has( + footer) {
578
- padding-bottom: 0;
579
- }
580
-
581
- .altertable-metric-widget > .altertable-data-widget-footer {
582
- padding-top: 0;
583
- padding-bottom: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
584
- }
585
-
586
- .altertable-metric-value {
587
- margin: var(--atbl-space-sm) 0 2px;
588
- color: var(--atbl-text);
589
- font-family: var(--atbl-font-heading, var(--atbl-input-font-heading, var(--atbl-font)));
590
- font-size: var(--atbl-type-metric-size);
591
- font-weight: var(--atbl-type-emphasis-weight);
592
- line-height: var(--atbl-type-metric-leading);
593
- letter-spacing: -.04em;
594
- overflow-wrap: anywhere;
595
- font-variant-numeric: tabular-nums;
596
- max-inline-size: 100%;
597
- }
598
-
599
- .altertable-metric-reading {
600
- display: flex;
601
- flex-direction: column;
602
- justify-content: flex-start;
603
- align-items: flex-start;
604
- gap: 4px;
605
- }
606
-
607
- .altertable-metric-trend {
608
- font-size: var(--atbl-type-meta-size);
609
- }
610
-
611
- .altertable-metric-change {
612
- display: inline-flex;
613
- color: var(--atbl-muted);
614
- font-variant-numeric: tabular-nums;
615
- align-items: center;
616
- gap: 3px;
617
- }
618
-
619
- .altertable-metric-change[data-tone="good"] {
620
- color: var(--atbl-positive, var(--atbl-accent));
621
- }
622
-
623
- .altertable-metric-change[data-tone="bad"] {
624
- color: var(--atbl-negative, var(--atbl-danger));
625
- }
626
-
627
- .altertable-metric-description {
628
- color: var(--atbl-muted);
629
- font-size: var(--atbl-type-meta-size);
630
- line-height: 1.45;
631
- }
632
-
633
- .altertable-metric-visual {
634
- margin-top: var(--atbl-space-sm);
635
- min-width: 0;
636
- }
637
-
638
- .altertable-metric-value[data-unavailable] {
639
- opacity: .6;
640
- }
641
-
642
- .altertable-metric-value > .altertable-skeleton {
643
- width: 6ch;
644
- height: 1em;
645
- }
646
- }
647
-
648
- /* src/react/ui/VisualizationWidget.css */
649
- @layer atbl.components {
650
- .altertable-visualization-widget-content {
651
- padding: var(--atbl-space-md) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg))) var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
652
- min-width: 0;
653
- }
654
-
655
- :where(.altertable-data-widget-body) > .altertable-visualization-widget-content {
656
- padding: 0;
657
- }
658
- }
659
-
660
- /* src/react/ui/ContentSkeleton.css */
661
- @layer atbl.components {
662
- .altertable-content-skeleton {
663
- display: grid;
664
- padding: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
665
- align-content: start;
666
- gap: 14px;
667
- min-width: 0;
668
- }
669
-
670
- .altertable-content-skeleton-label {
671
- width: 38%;
672
- height: 15px;
673
- }
674
-
675
- .altertable-content-skeleton-value {
676
- width: 56%;
677
- height: 38px;
678
- }
679
-
680
- .altertable-content-skeleton-chart {
681
- width: 100%;
682
- height: 180px;
683
- }
684
-
685
- .altertable-content-skeleton-foot {
686
- width: 70%;
687
- height: 12px;
688
- }
689
-
690
- .altertable-content-skeleton-subtitle {
691
- width: 52%;
692
- height: 12px;
693
- }
694
-
695
- .altertable-content-skeleton-rows {
696
- display: grid;
697
- gap: 18px;
698
- margin-top: 12px;
699
- }
700
-
701
- .altertable-content-skeleton-row {
702
- display: grid;
703
- gap: 8px;
704
- }
705
-
706
- .altertable-content-skeleton-row-label {
707
- width: 56%;
708
- height: 14px;
709
- }
710
-
711
- .altertable-content-skeleton-row-track {
712
- width: 100%;
713
- height: 8px;
714
- }
715
-
716
- .altertable-content-skeleton-row:nth-child(2) .altertable-content-skeleton-row-track {
717
- width: 72%;
718
- }
719
-
720
- .altertable-content-skeleton-row:nth-child(3) .altertable-content-skeleton-row-track {
721
- width: 48%;
722
- }
723
-
724
- .altertable-content-skeleton-row:nth-child(4) .altertable-content-skeleton-row-track {
725
- width: 30%;
726
- }
727
-
728
- .altertable-content-skeleton-body {
729
- display: grid;
730
- gap: 14px;
731
- min-width: 0;
732
- }
733
- }
734
-
735
- /* src/react/shared.css */
736
-
737
-
738
- /* src/react/ui/DataAppSkeleton.css */
739
- @layer atbl.components {
740
- .altertable-data-app-skeleton {
741
- display: flex;
742
- overflow: hidden;
743
- padding: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
744
- background: var(--atbl-background);
745
- flex: 1;
746
- min-width: 0;
747
- min-height: 0;
748
- }
749
-
750
- .altertable-data-app-skeleton-content {
751
- display: flex;
752
- gap: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
753
- max-width: var(--atbl-content-width);
754
- flex-direction: column;
755
- width: 100%;
756
- min-width: 0;
757
- margin-inline-start: auto;
758
- margin-inline-end: auto;
759
- }
760
-
761
- .altertable-data-app-skeleton-body {
762
- display: flex;
763
- gap: var(--atbl-layout-gap, clamp(var(--atbl-space-md), 2.5vw, var(--atbl-space-lg)));
764
- flex-direction: column;
765
- min-width: 0;
766
- }
767
-
768
- .altertable-data-app-skeleton-header, .altertable-data-app-skeleton-footer {
769
- min-width: 0;
770
- }
771
-
772
- .altertable-data-app-skeleton-widget-title {
773
- width: 144px;
774
- max-width: 100%;
775
- height: 16px;
776
- }
777
-
778
- .altertable-data-app-skeleton-chart {
779
- display: flex;
780
- align-items: flex-end;
781
- gap: var(--atbl-space-sm);
782
- height: 180px;
783
- }
784
-
785
- .altertable-data-app-skeleton-chart > * {
786
- flex: 1;
787
- min-width: 0;
788
- }
789
-
790
- .altertable-data-app-skeleton-rows {
791
- display: grid;
792
- gap: 20px;
793
- }
794
-
795
- .altertable-data-app-skeleton-row {
796
- display: grid;
797
- grid-template-columns: 2fr 1fr 1fr;
798
- gap: var(--atbl-space-md);
799
- }
800
-
801
- .altertable-data-app-skeleton-row > * {
802
- height: 16px;
803
- }
804
- }
805
-
806
- /* src/react/shellStyles.css */
807
- @layer atbl.tokens, atbl.base, atbl.components, atbl.interaction;
808
- `,
809
- options
810
- });
811
- }
85
+ } from "../../chunks/index-zcqxfwdq.js";
812
86
  // src/react/ui/StaticDataApp.tsx
813
87
  import { jsx } from "react/jsx-runtime";
814
88
  function DataApp(props) {
@@ -951,78 +225,8 @@ function GettingStarted({ dataContext }) {
951
225
  ]
952
226
  });
953
227
  }
954
- // src/react/ui/DataAppSkeleton.tsx
955
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
956
- var chartHeights = [40, 60, 50, 80, 60, 100, 80, 60];
957
- function DataAppSkeleton({
958
- header,
959
- footer,
960
- className,
961
- ...props
962
- }) {
963
- return /* @__PURE__ */ jsx3("output", {
964
- "aria-label": "Loading data app",
965
- ...props,
966
- "aria-busy": "true",
967
- className: classNames("altertable-data-app-skeleton", className),
968
- children: /* @__PURE__ */ jsxs2("div", {
969
- className: "altertable-data-app-skeleton-content",
970
- children: [
971
- header != null && header !== false && /* @__PURE__ */ jsx3("div", {
972
- className: "altertable-data-app-skeleton-header",
973
- children: header
974
- }),
975
- /* @__PURE__ */ jsxs2("div", {
976
- className: "altertable-data-app-skeleton-body",
977
- "aria-hidden": "true",
978
- children: [
979
- /* @__PURE__ */ jsx3(Grid2, {
980
- columns: 3,
981
- gap: "md",
982
- children: [0, 1, 2].map((item) => /* @__PURE__ */ jsx3(MetricWidget2, {
983
- label: "",
984
- loading: true
985
- }, item))
986
- }),
987
- /* @__PURE__ */ jsx3(VisualizationWidget2, {
988
- title: /* @__PURE__ */ jsx3(Skeleton2, {
989
- className: "altertable-data-app-skeleton-widget-title"
990
- }),
991
- visual: /* @__PURE__ */ jsx3("div", {
992
- className: "altertable-data-app-skeleton-chart",
993
- children: chartHeights.map((height, index) => /* @__PURE__ */ jsx3(Skeleton2, {
994
- style: { height: `${height}%` }
995
- }, index))
996
- })
997
- }),
998
- /* @__PURE__ */ jsx3(DataWidget2, {
999
- title: /* @__PURE__ */ jsx3(Skeleton2, {
1000
- className: "altertable-data-app-skeleton-widget-title"
1001
- }),
1002
- children: /* @__PURE__ */ jsx3("div", {
1003
- className: "altertable-data-app-skeleton-rows",
1004
- children: [0, 1, 2].map((row) => /* @__PURE__ */ jsxs2("div", {
1005
- className: "altertable-data-app-skeleton-row",
1006
- children: [
1007
- /* @__PURE__ */ jsx3(Skeleton2, {}),
1008
- /* @__PURE__ */ jsx3(Skeleton2, {}),
1009
- /* @__PURE__ */ jsx3(Skeleton2, {})
1010
- ]
1011
- }, row))
1012
- })
1013
- })
1014
- ]
1015
- }),
1016
- footer != null && footer !== false && /* @__PURE__ */ jsx3("div", {
1017
- className: "altertable-data-app-skeleton-footer",
1018
- children: footer
1019
- })
1020
- ]
1021
- })
1022
- });
1023
- }
1024
228
  // src/react/ui/GlossaryExplanation.tsx
1025
- import { jsx as jsx4 } from "react/jsx-runtime";
229
+ import { jsx as jsx3 } from "react/jsx-runtime";
1026
230
  function GlossaryExplanation({
1027
231
  entry,
1028
232
  empty,
@@ -1034,7 +238,7 @@ function GlossaryExplanation({
1034
238
  className,
1035
239
  ...props
1036
240
  }) {
1037
- return /* @__PURE__ */ jsx4(AboutData2, {
241
+ return /* @__PURE__ */ jsx3(AboutData2, {
1038
242
  ...props,
1039
243
  shortcut: false,
1040
244
  iconOnly: true,
@@ -1049,18 +253,18 @@ function GlossaryExplanation({
1049
253
  className: className ?? "altertable-inspect-trigger",
1050
254
  tooltip: "Explore this term",
1051
255
  "aria-label": props["aria-label"] ?? `Explore ${entry.term}`,
1052
- children: /* @__PURE__ */ jsx4(AppIcon2, {
256
+ children: /* @__PURE__ */ jsx3(AppIcon2, {
1053
257
  name: "openDetails"
1054
258
  })
1055
259
  });
1056
260
  }
1057
261
  // src/react/ui/GlossaryDefinition.tsx
1058
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
262
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
1059
263
  function GlossaryDefinition({
1060
264
  entry,
1061
265
  children
1062
266
  }) {
1063
- return /* @__PURE__ */ jsxs3(HelpPopover2, {
267
+ return /* @__PURE__ */ jsxs2(HelpPopover2, {
1064
268
  trigger: children ?? entry.term,
1065
269
  triggerLabel: `Explain ${entry.term}`,
1066
270
  label: entry.term,
@@ -1070,23 +274,683 @@ function GlossaryDefinition({
1070
274
  },
1071
275
  panelProps: { className: "altertable-glossary-definition-popover" },
1072
276
  children: [
1073
- /* @__PURE__ */ jsx5("strong", {
277
+ /* @__PURE__ */ jsx4("strong", {
1074
278
  children: entry.term
1075
279
  }),
1076
- /* @__PURE__ */ jsx5("div", {
280
+ /* @__PURE__ */ jsx4("div", {
1077
281
  children: entry.definition
1078
282
  })
1079
283
  ]
1080
284
  });
1081
285
  }
1082
286
  // src/react/ui/TrendChart.tsx
1083
- import { useLayoutEffect, useRef, useState } from "react";
287
+ import { useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState3 } from "react";
1084
288
  import {
1085
289
  AreaChart as RechartsAreaChart,
1086
290
  LineChart as RechartsLineChart,
1087
291
  ReferenceLine
1088
292
  } from "recharts";
1089
293
 
294
+ // src/react/ui/chart-date-axis.tsx
295
+ import {
296
+ createContext,
297
+ useCallback,
298
+ useContext,
299
+ useEffect,
300
+ useMemo,
301
+ useState
302
+ } from "react";
303
+ import { XAxis, usePlotArea } from "recharts";
304
+
305
+ // src/core/time-interval.ts
306
+ /*!
307
+ * TypeScript port of d3-time 3.1.0 (ISC), https://github.com/d3/d3-time/tree/v3.1.0
308
+ * Numeric tick-step helpers adapted from d3-array 3.2.4 (ISC).
309
+ *
310
+ * Copyright 2010-2022 Mike Bostock (d3-time)
311
+ * Copyright 2010-2023 Mike Bostock (d3-array tick-step helpers)
312
+ *
313
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
314
+ * with or without fee is hereby granted, provided that the above copyright notice
315
+ * and this permission notice appear in all copies.
316
+ *
317
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
318
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
319
+ * FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
320
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
321
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
322
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
323
+ * THIS SOFTWARE.
324
+ */
325
+ function timeInterval(floor, offset, count, field) {
326
+ function interval(value) {
327
+ const date = arguments.length === 0 ? new Date : new Date(+value);
328
+ floor(date);
329
+ return date;
330
+ }
331
+ interval.floor = (value) => {
332
+ const date = new Date(+value);
333
+ floor(date);
334
+ return date;
335
+ };
336
+ interval.ceil = (value) => {
337
+ const date = new Date(+value - 1);
338
+ floor(date);
339
+ offset(date, 1);
340
+ floor(date);
341
+ return date;
342
+ };
343
+ interval.round = (value) => {
344
+ const before = interval(value);
345
+ const after = interval.ceil(value);
346
+ return +value - +before < +after - +value ? before : after;
347
+ };
348
+ interval.offset = (value, step) => {
349
+ const date = new Date(+value);
350
+ offset(date, step == null ? 1 : Math.floor(step));
351
+ return date;
352
+ };
353
+ interval.range = (start, stop, step) => {
354
+ const range = [];
355
+ const date = interval.ceil(start);
356
+ const stride = step == null ? 1 : Math.floor(step);
357
+ if (!(+date < +stop) || !(stride > 0))
358
+ return range;
359
+ let previous;
360
+ do {
361
+ previous = new Date(+date);
362
+ range.push(previous);
363
+ offset(date, stride);
364
+ floor(date);
365
+ } while (+previous < +date && +date < +stop);
366
+ return range;
367
+ };
368
+ interval.filter = (test) => timeInterval((date) => {
369
+ if (!Number.isNaN(+date)) {
370
+ floor(date);
371
+ while (!test(date)) {
372
+ date.setTime(+date - 1);
373
+ floor(date);
374
+ }
375
+ }
376
+ }, (date, step) => {
377
+ if (!Number.isNaN(+date)) {
378
+ const direction = step < 0 ? -1 : 1;
379
+ for (let remaining = Math.abs(step);remaining > 0; --remaining) {
380
+ do {
381
+ offset(date, direction);
382
+ } while (!test(date));
383
+ }
384
+ }
385
+ });
386
+ if (count) {
387
+ interval.count = (start, end) => {
388
+ countStart.setTime(+start);
389
+ countEnd.setTime(+end);
390
+ floor(countStart);
391
+ floor(countEnd);
392
+ return Math.floor(count(countStart, countEnd));
393
+ };
394
+ interval.every = (step) => {
395
+ step = Math.floor(step);
396
+ if (!Number.isFinite(step) || !(step > 0))
397
+ return null;
398
+ if (step === 1)
399
+ return interval;
400
+ return interval.filter(field ? (date) => field(date) % step === 0 : (date) => interval.count(0, date) % step === 0);
401
+ };
402
+ }
403
+ return interval;
404
+ }
405
+ var countStart = new Date;
406
+ var countEnd = new Date;
407
+ var durationSecond = 1000;
408
+ var durationMinute = durationSecond * 60;
409
+ var durationHour = durationMinute * 60;
410
+ var durationDay = durationHour * 24;
411
+ var durationWeek = durationDay * 7;
412
+ var durationMonth = durationDay * 30;
413
+ var durationYear = durationDay * 365;
414
+ var millisecond = timeInterval(() => {}, (date, step) => {
415
+ date.setTime(+date + step);
416
+ }, (start, end) => {
417
+ return +end - +start;
418
+ });
419
+ millisecond.every = (k) => {
420
+ k = Math.floor(k);
421
+ if (!isFinite(k) || !(k > 0))
422
+ return null;
423
+ if (!(k > 1))
424
+ return millisecond;
425
+ return timeInterval((date) => {
426
+ date.setTime(Math.floor(+date / k) * k);
427
+ }, (date, step) => {
428
+ date.setTime(+date + step * k);
429
+ }, (start, end) => {
430
+ return (+end - +start) / k;
431
+ });
432
+ };
433
+ var milliseconds = millisecond.range;
434
+ var second = timeInterval((date) => {
435
+ date.setTime(+date - date.getMilliseconds());
436
+ }, (date, step) => {
437
+ date.setTime(+date + step * durationSecond);
438
+ }, (start, end) => {
439
+ return (+end - +start) / durationSecond;
440
+ }, (date) => {
441
+ return date.getUTCSeconds();
442
+ });
443
+ var seconds = second.range;
444
+ var timeMinute = timeInterval((date) => {
445
+ date.setTime(+date - date.getMilliseconds() - date.getSeconds() * durationSecond);
446
+ }, (date, step) => {
447
+ date.setTime(+date + step * durationMinute);
448
+ }, (start, end) => {
449
+ return (+end - +start) / durationMinute;
450
+ }, (date) => {
451
+ return date.getMinutes();
452
+ });
453
+ var timeMinutes = timeMinute.range;
454
+ var utcMinute = timeInterval((date) => {
455
+ date.setUTCSeconds(0, 0);
456
+ }, (date, step) => {
457
+ date.setTime(+date + step * durationMinute);
458
+ }, (start, end) => {
459
+ return (+end - +start) / durationMinute;
460
+ }, (date) => {
461
+ return date.getUTCMinutes();
462
+ });
463
+ var utcMinutes = utcMinute.range;
464
+ var timeHour = timeInterval((date) => {
465
+ date.setTime(+date - date.getMilliseconds() - date.getSeconds() * durationSecond - date.getMinutes() * durationMinute);
466
+ }, (date, step) => {
467
+ date.setTime(+date + step * durationHour);
468
+ }, (start, end) => {
469
+ return (+end - +start) / durationHour;
470
+ }, (date) => {
471
+ return date.getHours();
472
+ });
473
+ var timeHours = timeHour.range;
474
+ var utcHour = timeInterval((date) => {
475
+ date.setUTCMinutes(0, 0, 0);
476
+ }, (date, step) => {
477
+ date.setTime(+date + step * durationHour);
478
+ }, (start, end) => {
479
+ return (+end - +start) / durationHour;
480
+ }, (date) => {
481
+ return date.getUTCHours();
482
+ });
483
+ var utcHours = utcHour.range;
484
+ var timeDay = timeInterval((date) => date.setHours(0, 0, 0, 0), (date, step) => date.setDate(date.getDate() + step), (start, end) => (+end - +start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay, (date) => date.getDate() - 1);
485
+ var timeDays = timeDay.range;
486
+ var utcDay = timeInterval((date) => {
487
+ date.setUTCHours(0, 0, 0, 0);
488
+ }, (date, step) => {
489
+ date.setUTCDate(date.getUTCDate() + step);
490
+ }, (start, end) => {
491
+ return (+end - +start) / durationDay;
492
+ }, (date) => {
493
+ return date.getUTCDate() - 1;
494
+ });
495
+ var utcDays = utcDay.range;
496
+ var unixDay = timeInterval((date) => {
497
+ date.setUTCHours(0, 0, 0, 0);
498
+ }, (date, step) => {
499
+ date.setUTCDate(date.getUTCDate() + step);
500
+ }, (start, end) => {
501
+ return (+end - +start) / durationDay;
502
+ }, (date) => {
503
+ return Math.floor(+date / durationDay);
504
+ });
505
+ var unixDays = unixDay.range;
506
+ function timeWeekday(i) {
507
+ return timeInterval((date) => {
508
+ date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7);
509
+ date.setHours(0, 0, 0, 0);
510
+ }, (date, step) => {
511
+ date.setDate(date.getDate() + step * 7);
512
+ }, (start, end) => {
513
+ return (+end - +start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek;
514
+ });
515
+ }
516
+ var timeSunday = timeWeekday(0);
517
+ var timeMonday = timeWeekday(1);
518
+ var timeTuesday = timeWeekday(2);
519
+ var timeWednesday = timeWeekday(3);
520
+ var timeThursday = timeWeekday(4);
521
+ var timeFriday = timeWeekday(5);
522
+ var timeSaturday = timeWeekday(6);
523
+ var timeSundays = timeSunday.range;
524
+ var timeMondays = timeMonday.range;
525
+ var timeTuesdays = timeTuesday.range;
526
+ var timeWednesdays = timeWednesday.range;
527
+ var timeThursdays = timeThursday.range;
528
+ var timeFridays = timeFriday.range;
529
+ var timeSaturdays = timeSaturday.range;
530
+ function utcWeekday(i) {
531
+ return timeInterval((date) => {
532
+ date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7);
533
+ date.setUTCHours(0, 0, 0, 0);
534
+ }, (date, step) => {
535
+ date.setUTCDate(date.getUTCDate() + step * 7);
536
+ }, (start, end) => {
537
+ return (+end - +start) / durationWeek;
538
+ });
539
+ }
540
+ var utcSunday = utcWeekday(0);
541
+ var utcMonday = utcWeekday(1);
542
+ var utcTuesday = utcWeekday(2);
543
+ var utcWednesday = utcWeekday(3);
544
+ var utcThursday = utcWeekday(4);
545
+ var utcFriday = utcWeekday(5);
546
+ var utcSaturday = utcWeekday(6);
547
+ var utcSundays = utcSunday.range;
548
+ var utcMondays = utcMonday.range;
549
+ var utcTuesdays = utcTuesday.range;
550
+ var utcWednesdays = utcWednesday.range;
551
+ var utcThursdays = utcThursday.range;
552
+ var utcFridays = utcFriday.range;
553
+ var utcSaturdays = utcSaturday.range;
554
+ var timeMonth = timeInterval((date) => {
555
+ date.setDate(1);
556
+ date.setHours(0, 0, 0, 0);
557
+ }, (date, step) => {
558
+ date.setMonth(date.getMonth() + step);
559
+ }, (start, end) => {
560
+ return end.getMonth() - start.getMonth() + (end.getFullYear() - start.getFullYear()) * 12;
561
+ }, (date) => {
562
+ return date.getMonth();
563
+ });
564
+ var timeMonths = timeMonth.range;
565
+ var utcMonth = timeInterval((date) => {
566
+ date.setUTCDate(1);
567
+ date.setUTCHours(0, 0, 0, 0);
568
+ }, (date, step) => {
569
+ date.setUTCMonth(date.getUTCMonth() + step);
570
+ }, (start, end) => {
571
+ return end.getUTCMonth() - start.getUTCMonth() + (end.getUTCFullYear() - start.getUTCFullYear()) * 12;
572
+ }, (date) => {
573
+ return date.getUTCMonth();
574
+ });
575
+ var utcMonths = utcMonth.range;
576
+ var timeYear = timeInterval((date) => {
577
+ date.setMonth(0, 1);
578
+ date.setHours(0, 0, 0, 0);
579
+ }, (date, step) => {
580
+ date.setFullYear(date.getFullYear() + step);
581
+ }, (start, end) => {
582
+ return end.getFullYear() - start.getFullYear();
583
+ }, (date) => {
584
+ return date.getFullYear();
585
+ });
586
+ timeYear.every = (k) => {
587
+ return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => {
588
+ date.setFullYear(Math.floor(date.getFullYear() / k) * k);
589
+ date.setMonth(0, 1);
590
+ date.setHours(0, 0, 0, 0);
591
+ }, (date, step) => {
592
+ date.setFullYear(date.getFullYear() + step * k);
593
+ });
594
+ };
595
+ var timeYears = timeYear.range;
596
+ var utcYear = timeInterval((date) => {
597
+ date.setUTCMonth(0, 1);
598
+ date.setUTCHours(0, 0, 0, 0);
599
+ }, (date, step) => {
600
+ date.setUTCFullYear(date.getUTCFullYear() + step);
601
+ }, (start, end) => {
602
+ return end.getUTCFullYear() - start.getUTCFullYear();
603
+ }, (date) => {
604
+ return date.getUTCFullYear();
605
+ });
606
+ utcYear.every = (k) => {
607
+ return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => {
608
+ date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k);
609
+ date.setUTCMonth(0, 1);
610
+ date.setUTCHours(0, 0, 0, 0);
611
+ }, (date, step) => {
612
+ date.setUTCFullYear(date.getUTCFullYear() + step * k);
613
+ });
614
+ };
615
+ var utcYears = utcYear.range;
616
+ var e10 = Math.sqrt(50);
617
+ var e5 = Math.sqrt(10);
618
+ var e2 = Math.sqrt(2);
619
+ function tickSpec(start, stop, count) {
620
+ const step = (stop - start) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1;
621
+ let i1, i2, inc;
622
+ if (power < 0) {
623
+ inc = Math.pow(10, -power) / factor;
624
+ i1 = Math.round(start * inc);
625
+ i2 = Math.round(stop * inc);
626
+ if (i1 / inc < start)
627
+ ++i1;
628
+ if (i2 / inc > stop)
629
+ --i2;
630
+ inc = -inc;
631
+ } else {
632
+ inc = Math.pow(10, power) * factor;
633
+ i1 = Math.round(start / inc);
634
+ i2 = Math.round(stop / inc);
635
+ if (i1 * inc < start)
636
+ ++i1;
637
+ if (i2 * inc > stop)
638
+ --i2;
639
+ }
640
+ if (i2 < i1 && 0.5 <= count && count < 2)
641
+ return tickSpec(start, stop, count * 2);
642
+ return [i1, i2, inc];
643
+ }
644
+ function tickIncrement(start, stop, count) {
645
+ return tickSpec(start, stop, count)[2];
646
+ }
647
+ function tickStep(start, stop, count) {
648
+ const reverse = stop < start, inc = reverse ? tickIncrement(stop, start, count) : tickIncrement(start, stop, count);
649
+ return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
650
+ }
651
+ function ticker(year, month, week, day, hour, minute) {
652
+ const tickIntervals = [
653
+ [second, 1, durationSecond],
654
+ [second, 5, 5 * durationSecond],
655
+ [second, 15, 15 * durationSecond],
656
+ [second, 30, 30 * durationSecond],
657
+ [minute, 1, durationMinute],
658
+ [minute, 5, 5 * durationMinute],
659
+ [minute, 15, 15 * durationMinute],
660
+ [minute, 30, 30 * durationMinute],
661
+ [hour, 1, durationHour],
662
+ [hour, 3, 3 * durationHour],
663
+ [hour, 6, 6 * durationHour],
664
+ [hour, 12, 12 * durationHour],
665
+ [day, 1, durationDay],
666
+ [day, 2, 2 * durationDay],
667
+ [week, 1, durationWeek],
668
+ [month, 1, durationMonth],
669
+ [month, 3, 3 * durationMonth],
670
+ [year, 1, durationYear]
671
+ ];
672
+ function ticks(start, stop, count) {
673
+ const reverse = +stop < +start;
674
+ if (reverse)
675
+ [start, stop] = [stop, start];
676
+ const interval = typeof count !== "number" ? count : tickInterval(start, stop, count);
677
+ const ticks = interval ? interval.range(start, +stop + 1) : [];
678
+ return reverse ? ticks.reverse() : ticks;
679
+ }
680
+ function tickInterval(start, stop, count) {
681
+ const target = Math.abs(+stop - +start) / count;
682
+ let low = 0;
683
+ let high = tickIntervals.length;
684
+ if (Number.isNaN(target))
685
+ low = high;
686
+ while (low < high) {
687
+ const middle = low + high >>> 1;
688
+ if (tickIntervals[middle][2] <= target)
689
+ low = middle + 1;
690
+ else
691
+ high = middle;
692
+ }
693
+ const i = low;
694
+ if (i === tickIntervals.length)
695
+ return year.every(tickStep(+start / durationYear, +stop / durationYear, count));
696
+ if (i === 0)
697
+ return millisecond.every(Math.max(tickStep(+start, +stop, count), 1));
698
+ const [t, step] = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i];
699
+ return t.every(step);
700
+ }
701
+ return [ticks, tickInterval];
702
+ }
703
+ var [utcTicks, utcTickInterval] = ticker(utcYear, utcMonth, utcSunday, unixDay, utcHour, utcMinute);
704
+ var [timeTicks, timeTickInterval] = ticker(timeYear, timeMonth, timeSunday, timeDay, timeHour, timeMinute);
705
+
706
+ // src/react/ui/chart-time.ts
707
+ var day = 86400000;
708
+ function chartTimestamp(value, numeric = false) {
709
+ if (typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value)) {
710
+ return parseDateTime2(`${value}T00:00:00Z`)?.getTime() ?? null;
711
+ }
712
+ if (value instanceof Date || typeof value === "string" || numeric && typeof value === "number") {
713
+ return parseDateTime2(value)?.getTime() ?? null;
714
+ }
715
+ return null;
716
+ }
717
+ function timeModel(values, numeric = false) {
718
+ if (!values.length)
719
+ return null;
720
+ const parsed = values.map((value) => chartTimestamp(value, numeric));
721
+ if (parsed.some((value) => value == null))
722
+ return null;
723
+ const times = [...new Set(parsed)].sort((a, b) => a - b);
724
+ const start = times[0];
725
+ const end = times.at(-1);
726
+ const gaps = times.slice(1).map((value, index) => value - times[index]);
727
+ const precision = gaps.reduce((minimum, gap) => Math.min(minimum, gap), day);
728
+ const dateOnly = values.every((value) => typeof value === "string" && /^\d{4}-\d{2}-\d{2}$/.test(value));
729
+ const seconds = times.some((value) => value % 60000 !== 0) || precision < 60000;
730
+ const milliseconds = times.some((value) => value % 1000 !== 0) || precision < 1000;
731
+ function tooltip(value) {
732
+ const time = chartTimestamp(value, true);
733
+ if (time == null)
734
+ return typeof value === "string" || typeof value === "number" ? String(value) : "";
735
+ if (dateOnly)
736
+ return formatDate2(new Date(time).toISOString().slice(0, 10));
737
+ if (milliseconds) {
738
+ return new Intl.DateTimeFormat("en-US", {
739
+ timeZone: "UTC",
740
+ year: "numeric",
741
+ month: "short",
742
+ day: "numeric",
743
+ hour: "2-digit",
744
+ minute: "2-digit",
745
+ second: "2-digit",
746
+ fractionalSecondDigits: 3,
747
+ hourCycle: "h23"
748
+ }).format(time);
749
+ }
750
+ return formatDateTime2(time, {
751
+ precision: seconds ? "second" : "minute",
752
+ timeZone: "UTC"
753
+ });
754
+ }
755
+ return {
756
+ start,
757
+ end,
758
+ times,
759
+ precision: gaps.length ? gaps.reduce((minimum, gap) => Math.min(minimum, gap), Infinity) : day,
760
+ tooltip
761
+ };
762
+ }
763
+ function datePart(value, options) {
764
+ return new Intl.DateTimeFormat("en-US", {
765
+ ...options,
766
+ timeZone: "UTC"
767
+ }).format(value);
768
+ }
769
+ function timeTicks2(model, width) {
770
+ const { start, end } = model;
771
+ const firstDate = new Date(start);
772
+ const lastDate = new Date(end);
773
+ const spansYears = firstDate.getUTCFullYear() !== lastDate.getUTCFullYear();
774
+ const spansDates = firstDate.toISOString().slice(0, 10) !== lastDate.toISOString().slice(0, 10);
775
+ const count = Math.max(2, Math.min(12, Math.floor(width / 80), model.times.length));
776
+ let ticks = start === end ? [start] : utcTicks(new Date(start), new Date(end), Math.min(count, (end - start) / model.precision)).map(Number);
777
+ const step = ticks.length > 1 ? ticks[1] - ticks[0] : Math.max(end - start, model.precision);
778
+ const candidates = [...new Set([start, ...ticks, end])].sort((a, b) => a - b);
779
+ ticks = [start];
780
+ const gap = step < 1000 ? 110 : 80;
781
+ for (const value of candidates.slice(1)) {
782
+ if ((value - ticks.at(-1)) / (end - start) * width >= gap)
783
+ ticks.push(value);
784
+ }
785
+ if (end !== start && ticks.at(-1) !== end) {
786
+ if (ticks.length > 1 && (end - ticks.at(-1)) / (end - start) * width < gap)
787
+ ticks.pop();
788
+ ticks.push(end);
789
+ }
790
+ function label(value, index) {
791
+ const previous = index > 0 ? new Date(ticks[index - 1]) : undefined;
792
+ const date = new Date(value);
793
+ const yearChanged = !previous || previous.getUTCFullYear() !== date.getUTCFullYear();
794
+ const dateChanged = !previous || previous.toISOString().slice(0, 10) !== date.toISOString().slice(0, 10);
795
+ if (step >= 300 * day)
796
+ return { main: String(date.getUTCFullYear()), context: "" };
797
+ if (step >= 28 * day && (model.precision >= 28 * day || end - start >= 180 * day))
798
+ return {
799
+ main: datePart(value, { month: "short" }),
800
+ context: spansYears && yearChanged ? String(date.getUTCFullYear()) : ""
801
+ };
802
+ if (step >= day && !(model.precision < day && end - start <= 3 * day))
803
+ return {
804
+ main: datePart(value, { month: "short", day: "numeric" }),
805
+ context: spansYears && yearChanged ? String(date.getUTCFullYear()) : ""
806
+ };
807
+ return {
808
+ main: datePart(value, {
809
+ hour: "2-digit",
810
+ minute: "2-digit",
811
+ ...step < 60000 ? { second: "2-digit" } : {},
812
+ ...step < 1000 ? { fractionalSecondDigits: 3 } : {},
813
+ hourCycle: "h23"
814
+ }),
815
+ context: spansDates && dateChanged ? datePart(value, {
816
+ month: "short",
817
+ day: "numeric",
818
+ ...spansYears && yearChanged ? { year: "numeric" } : {}
819
+ }) : ""
820
+ };
821
+ }
822
+ return { ticks, label };
823
+ }
824
+
825
+ // src/react/ui/chart-date-axis.tsx
826
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
827
+ var DateAxes = createContext(null);
828
+ function ChartDateAxes({
829
+ data,
830
+ children
831
+ }) {
832
+ const [formatters, setFormatters] = useState(() => new Map);
833
+ const register = useCallback((id, formatter) => {
834
+ setFormatters((current) => new Map(current).set(id, formatter));
835
+ return () => setFormatters((current) => {
836
+ const next = new Map(current);
837
+ next.delete(id);
838
+ return next;
839
+ });
840
+ }, []);
841
+ return /* @__PURE__ */ jsx5(DateAxes.Provider, {
842
+ value: { data, formatters, register },
843
+ children
844
+ });
845
+ }
846
+ function useDateAxisLabel(id = 0) {
847
+ return useContext(DateAxes)?.formatters.get(id);
848
+ }
849
+ function field(row, key) {
850
+ if (row == null || typeof row !== "object")
851
+ return;
852
+ if (key in row)
853
+ return row[key];
854
+ return String(key).replace(/\[(\d+)\]/g, ".$1").split(".").reduce((value, part) => value != null && typeof value === "object" ? value[part] : undefined, row);
855
+ }
856
+ function ChartXAxis(props) {
857
+ const context = useContext(DateAxes);
858
+ const plot = usePlotArea();
859
+ const data = context?.data;
860
+ const dataKey = props.dataKey;
861
+ const numeric = props.scale === "utc";
862
+ const enabled = numeric || props.type == null && props.scale == null && props.tickFormatter == null && props.ticks == null;
863
+ const model = useMemo(() => {
864
+ if (!enabled || !data?.length || dataKey == null)
865
+ return null;
866
+ return timeModel(data.map((row) => typeof dataKey === "function" ? dataKey(row) : field(row, dataKey)), numeric);
867
+ }, [data, dataKey, enabled, numeric]);
868
+ const register = context?.register;
869
+ const id = props.xAxisId ?? 0;
870
+ useEffect(() => model ? register?.(id, model.tooltip) : undefined, [register, id, model]);
871
+ const axis = model ? timeTicks2(model, plot?.width ?? 400) : undefined;
872
+ return /* @__PURE__ */ jsx5(XAxis, {
873
+ stroke: "var(--atbl-muted)",
874
+ tickFormatter: (value) => typeof value === "number" ? formatNumber2(value) : String(value),
875
+ tickLine: false,
876
+ axisLine: { stroke: "var(--atbl-border)" },
877
+ tick: { fontSize: "var(--atbl-type-meta-size)" },
878
+ ...model && axis ? {
879
+ type: "number",
880
+ scale: "utc",
881
+ domain: model.start === model.end ? [
882
+ model.start - model.precision / 2,
883
+ model.end + model.precision / 2
884
+ ] : [model.start, model.end],
885
+ ticks: axis.ticks,
886
+ interval: 0,
887
+ height: 48,
888
+ tick: ({ x, y, payload, index }) => {
889
+ const label = axis.label(Number(payload.value), index);
890
+ return /* @__PURE__ */ jsxs3("text", {
891
+ x,
892
+ y: Number(y) + 5,
893
+ fill: "var(--atbl-muted)",
894
+ fontSize: "var(--atbl-type-meta-size)",
895
+ textAnchor: index === 0 ? "start" : index === axis.ticks.length - 1 ? "end" : "middle",
896
+ children: [
897
+ /* @__PURE__ */ jsx5("tspan", {
898
+ x,
899
+ dy: "0.8em",
900
+ children: label.main
901
+ }),
902
+ label.context && /* @__PURE__ */ jsx5("tspan", {
903
+ x,
904
+ dy: "1.4em",
905
+ children: label.context
906
+ })
907
+ ]
908
+ });
909
+ }
910
+ } : {},
911
+ ...props,
912
+ ...model ? {
913
+ type: "number",
914
+ dataKey: (row) => chartTimestamp(typeof dataKey === "function" ? dataKey(row) : field(row, dataKey), numeric)
915
+ } : {}
916
+ });
917
+ }
918
+
919
+ // src/react/ui/chart-primitives.tsx
920
+ import { useContext as useContext3, useLayoutEffect } from "react";
921
+
922
+ // src/react/ui/chart-interaction.tsx
923
+ import {
924
+ createContext as createContext2,
925
+ useContext as useContext2,
926
+ useId,
927
+ useEffect as useEffect2
928
+ } from "react";
929
+ import { jsx as jsx6 } from "react/jsx-runtime";
930
+ var ChartInteraction = createContext2(null);
931
+ function useChartSeries(id) {
932
+ const generatedId = useId();
933
+ const interaction = useContext2(ChartInteraction);
934
+ const seriesId = id ?? generatedId;
935
+ const registerSeries = interaction?.registerSeries;
936
+ useEffect2(() => registerSeries?.(seriesId), [registerSeries, seriesId]);
937
+ return {
938
+ id: seriesId,
939
+ active: !interaction?.pointer || interaction.seriesCount === 1 || interaction.hovered === seriesId
940
+ };
941
+ }
942
+ function ChartSeries({
943
+ id,
944
+ children
945
+ }) {
946
+ const interaction = useContext2(ChartInteraction);
947
+ return /* @__PURE__ */ jsx6("g", {
948
+ onPointerOver: () => interaction?.setHovered(id),
949
+ onPointerDown: () => interaction?.setHovered(id),
950
+ children
951
+ });
952
+ }
953
+
1090
954
  // src/react/ui/chart-primitives.tsx
1091
955
  import {
1092
956
  Area,
@@ -1094,23 +958,204 @@ import {
1094
958
  Bar,
1095
959
  Line,
1096
960
  Scatter,
1097
- XAxis,
1098
961
  YAxis,
1099
962
  CartesianGrid,
1100
963
  Tooltip,
1101
964
  DefaultTooltipContent
1102
965
  } from "recharts";
1103
- import { jsx as jsx6 } from "react/jsx-runtime";
1104
- var chartBarFill = "var(--atbl-chart-fill, color-mix(in srgb, var(--atbl-accent) 75%, var(--atbl-surface)))";
1105
- var accent = "var(--atbl-accent)";
966
+
967
+ // src/react/ui/ChartLegend.tsx
968
+ import {
969
+ Children,
970
+ useId as useId2,
971
+ useEffect as useEffect3,
972
+ useRef,
973
+ useState as useState2
974
+ } from "react";
975
+ import { jsx as jsx7, jsxs as jsxs4, Fragment } from "react/jsx-runtime";
976
+ function ChartLegendRoot({
977
+ children,
978
+ layout = "horizontal",
979
+ align = "start",
980
+ maxVisibleItems,
981
+ className,
982
+ "aria-label": ariaLabel = "Chart legend",
983
+ ...props
984
+ }) {
985
+ const [expanded, setExpanded] = useState2(false);
986
+ const listId = useId2();
987
+ const containerRef = useRef(null);
988
+ const [columns, setColumns] = useState2(2);
989
+ useEffect3(() => {
990
+ const container = containerRef.current;
991
+ if (!container)
992
+ return;
993
+ function measure() {
994
+ const list = containerRef.current?.firstElementChild;
995
+ if (list) {
996
+ setColumns(getComputedStyle(list).gridTemplateColumns.split(" ").length);
997
+ }
998
+ }
999
+ const observer = new ResizeObserver(measure);
1000
+ observer.observe(container);
1001
+ measure();
1002
+ return () => observer.disconnect();
1003
+ }, [layout]);
1004
+ const items = Children.toArray(children);
1005
+ const rowCapacity = layout === "vertical" ? 6 : columns * (layout === "single-row" ? 1 : 2);
1006
+ const configuredLimit = typeof maxVisibleItems === "number" && Number.isFinite(maxVisibleItems) ? Math.max(1, Math.floor(maxVisibleItems)) : rowCapacity;
1007
+ const cappedLimit = Math.min(configuredLimit, rowCapacity);
1008
+ const limit = layout === "vertical" ? configuredLimit : cappedLimit >= columns ? Math.floor(cappedLimit / columns) * columns : cappedLimit;
1009
+ const visibleCount = items.length > limit ? limit - 1 : limit;
1010
+ const hiddenCount = Math.max(0, items.length - visibleCount);
1011
+ return /* @__PURE__ */ jsx7("div", {
1012
+ ref: containerRef,
1013
+ className: "altertable-chart-legend-container",
1014
+ children: /* @__PURE__ */ jsxs4("ul", {
1015
+ id: listId,
1016
+ ...props,
1017
+ "aria-label": ariaLabel,
1018
+ "data-layout": layout,
1019
+ "data-align": align,
1020
+ className: classNames("altertable-chart-legend", className),
1021
+ children: [
1022
+ expanded ? items : items.slice(0, visibleCount),
1023
+ hiddenCount > 0 && /* @__PURE__ */ jsx7("li", {
1024
+ className: "altertable-chart-legend-overflow",
1025
+ children: /* @__PURE__ */ jsx7("button", {
1026
+ type: "button",
1027
+ "data-atbl-control": "action",
1028
+ "data-atbl-focus": "ring",
1029
+ className: "altertable-chart-legend-action",
1030
+ "aria-expanded": expanded,
1031
+ "aria-controls": props.id ?? listId,
1032
+ onClick: () => setExpanded((value) => !value),
1033
+ children: expanded ? "Show fewer" : `+${hiddenCount} more`
1034
+ })
1035
+ })
1036
+ ]
1037
+ })
1038
+ });
1039
+ }
1040
+ function ChartLegendItem({
1041
+ inactive,
1042
+ className,
1043
+ ...props
1044
+ }) {
1045
+ return /* @__PURE__ */ jsx7("li", {
1046
+ ...props,
1047
+ "data-inactive": inactive || undefined,
1048
+ className: classNames("altertable-chart-legend-item", className)
1049
+ });
1050
+ }
1051
+ function ChartLegendMarker({
1052
+ kind,
1053
+ color = kind === "bar" ? chartBarFill : "var(--atbl-chart-1)",
1054
+ className,
1055
+ style,
1056
+ ...props
1057
+ }) {
1058
+ return /* @__PURE__ */ jsxs4("svg", {
1059
+ ...props,
1060
+ "aria-hidden": "true",
1061
+ focusable: "false",
1062
+ viewBox: kind === "square" ? "0 0 8 8" : "0 0 20 12",
1063
+ "data-kind": kind,
1064
+ className: classNames("altertable-chart-legend-marker", className),
1065
+ style: { color, ...style },
1066
+ children: [
1067
+ kind === "square" && /* @__PURE__ */ jsx7("rect", {
1068
+ width: "8",
1069
+ height: "8",
1070
+ fill: "currentColor"
1071
+ }),
1072
+ kind === "bar" && /* @__PURE__ */ jsx7("path", {
1073
+ d: "M6 11V3Q6 1 8 1H12Q14 1 14 3V11Z",
1074
+ fill: "currentColor"
1075
+ }),
1076
+ kind === "slice" && /* @__PURE__ */ jsx7("rect", {
1077
+ x: "5",
1078
+ y: "1",
1079
+ width: "10",
1080
+ height: "10",
1081
+ rx: "2",
1082
+ fill: "currentColor"
1083
+ }),
1084
+ kind === "point" && /* @__PURE__ */ jsx7("circle", {
1085
+ cx: "10",
1086
+ cy: "6",
1087
+ r: "3",
1088
+ fill: "currentColor"
1089
+ }),
1090
+ kind === "line" && /* @__PURE__ */ jsxs4(Fragment, {
1091
+ children: [
1092
+ /* @__PURE__ */ jsx7("path", {
1093
+ d: "M1 6H19",
1094
+ fill: "none",
1095
+ stroke: "currentColor",
1096
+ strokeWidth: "2",
1097
+ strokeLinecap: "round"
1098
+ }),
1099
+ /* @__PURE__ */ jsx7("circle", {
1100
+ cx: "10",
1101
+ cy: "6",
1102
+ r: "2.5",
1103
+ fill: "var(--atbl-surface)",
1104
+ stroke: "currentColor",
1105
+ strokeWidth: "2"
1106
+ })
1107
+ ]
1108
+ }),
1109
+ kind === "area" && /* @__PURE__ */ jsxs4(Fragment, {
1110
+ children: [
1111
+ /* @__PURE__ */ jsx7("path", {
1112
+ d: "M1 10L7 5L13 7L19 2V11H1Z",
1113
+ fill: "currentColor",
1114
+ fillOpacity: "0.14"
1115
+ }),
1116
+ /* @__PURE__ */ jsx7("path", {
1117
+ d: "M1 10L7 5L13 7L19 2",
1118
+ fill: "none",
1119
+ stroke: "currentColor",
1120
+ strokeWidth: "2",
1121
+ strokeLinejoin: "round",
1122
+ strokeLinecap: "round"
1123
+ })
1124
+ ]
1125
+ })
1126
+ ]
1127
+ });
1128
+ }
1129
+ function ChartLegendLabel({
1130
+ className,
1131
+ children,
1132
+ title,
1133
+ ...props
1134
+ }) {
1135
+ return /* @__PURE__ */ jsx7("span", {
1136
+ ...props,
1137
+ title: title ?? (typeof children === "string" ? children : undefined),
1138
+ className: classNames("altertable-chart-legend-label", className),
1139
+ children
1140
+ });
1141
+ }
1142
+ var ChartLegend = Object.assign(ChartLegendRoot, {
1143
+ Item: ChartLegendItem,
1144
+ Marker: ChartLegendMarker,
1145
+ Label: ChartLegendLabel
1146
+ });
1147
+
1148
+ // src/react/ui/chart-primitives.tsx
1149
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1150
+ var seriesColor = "var(--atbl-chart-1)";
1106
1151
  function ChartDot({
1107
1152
  active = false,
1108
- stroke = accent,
1153
+ stroke = seriesColor,
1109
1154
  fill = active ? stroke : "var(--atbl-surface)",
1110
1155
  r = active ? 4.5 : 3,
1111
1156
  ...props
1112
1157
  }) {
1113
- return /* @__PURE__ */ jsx6(Dot, {
1158
+ return /* @__PURE__ */ jsx8(Dot, {
1114
1159
  stroke,
1115
1160
  fill,
1116
1161
  r,
@@ -1118,92 +1163,126 @@ function ChartDot({
1118
1163
  ...props
1119
1164
  });
1120
1165
  }
1166
+ function NearestChartDot({
1167
+ seriesId,
1168
+ cx,
1169
+ cy,
1170
+ stroke
1171
+ }) {
1172
+ const interaction = useContext3(ChartInteraction);
1173
+ const registerPoint = interaction?.registerPoint;
1174
+ useLayoutEffect(() => {
1175
+ if (cx == null || cy == null)
1176
+ return;
1177
+ return registerPoint?.(seriesId, cx, cy);
1178
+ }, [registerPoint, seriesId, cx, cy]);
1179
+ const active = !interaction?.pointer || interaction.seriesCount === 1 || interaction.hovered === seriesId;
1180
+ return active ? /* @__PURE__ */ jsx8(ChartDot, {
1181
+ cx,
1182
+ cy,
1183
+ stroke,
1184
+ active: true,
1185
+ style: { pointerEvents: "none" }
1186
+ }) : null;
1187
+ }
1121
1188
  function ChartBar(props) {
1122
- return /* @__PURE__ */ jsx6(Bar, {
1123
- fill: chartBarFill,
1124
- radius: [5, 5, 0, 0],
1125
- maxBarSize: 30,
1126
- activeBar: { fill: accent },
1127
- isAnimationActive: false,
1128
- ...props
1189
+ const series = useChartSeries(props.id);
1190
+ return /* @__PURE__ */ jsx8(ChartSeries, {
1191
+ id: series.id,
1192
+ children: /* @__PURE__ */ jsx8(Bar, {
1193
+ fill: chartBarFill,
1194
+ radius: props.stackId == null ? [5, 5, 0, 0] : 0,
1195
+ maxBarSize: 30,
1196
+ activeBar: series.active ? { opacity: 0.75 } : false,
1197
+ isAnimationActive: false,
1198
+ ...props,
1199
+ id: series.id
1200
+ })
1129
1201
  });
1130
1202
  }
1131
1203
  function ChartLine({
1132
- stroke = accent,
1133
- dot,
1204
+ stroke = seriesColor,
1205
+ dot = false,
1134
1206
  activeDot,
1135
1207
  ...props
1136
1208
  }) {
1137
- return /* @__PURE__ */ jsx6(Line, {
1138
- type: "linear",
1139
- stroke,
1140
- strokeWidth: 2,
1141
- strokeLinecap: "round",
1142
- strokeLinejoin: "round",
1143
- dot: dot === undefined || dot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx6(ChartDot, {
1144
- cx,
1145
- cy,
1146
- stroke
1147
- }) : dot,
1148
- activeDot: activeDot === undefined || activeDot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx6(ChartDot, {
1149
- cx,
1150
- cy,
1209
+ const series = useChartSeries(props.id);
1210
+ return /* @__PURE__ */ jsx8(ChartSeries, {
1211
+ id: series.id,
1212
+ children: /* @__PURE__ */ jsx8(Line, {
1213
+ type: "linear",
1151
1214
  stroke,
1152
- active: true
1153
- }) : activeDot,
1154
- isAnimationActive: false,
1155
- ...props
1215
+ strokeWidth: 2,
1216
+ strokeLinecap: "round",
1217
+ strokeLinejoin: "round",
1218
+ dot: dot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx8(ChartDot, {
1219
+ cx,
1220
+ cy,
1221
+ stroke
1222
+ }) : dot,
1223
+ activeDot: activeDot === undefined || activeDot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx8(NearestChartDot, {
1224
+ seriesId: series.id,
1225
+ cx,
1226
+ cy,
1227
+ stroke
1228
+ }) : activeDot,
1229
+ isAnimationActive: false,
1230
+ ...props,
1231
+ id: series.id
1232
+ })
1156
1233
  });
1157
1234
  }
1158
1235
  function ChartArea({
1159
- stroke = accent,
1160
- dot,
1236
+ stroke = seriesColor,
1237
+ dot = false,
1161
1238
  activeDot,
1162
1239
  ...props
1163
1240
  }) {
1164
- return /* @__PURE__ */ jsx6(Area, {
1165
- legendType: "square",
1166
- type: "linear",
1167
- stroke,
1168
- strokeWidth: 2,
1169
- strokeLinecap: "round",
1170
- strokeLinejoin: "round",
1171
- fill: stroke,
1172
- fillOpacity: 0.14,
1173
- dot: dot === undefined || dot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx6(ChartDot, {
1174
- cx,
1175
- cy,
1176
- stroke
1177
- }) : dot,
1178
- activeDot: activeDot === undefined || activeDot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx6(ChartDot, {
1179
- cx,
1180
- cy,
1241
+ const series = useChartSeries(props.id);
1242
+ return /* @__PURE__ */ jsx8(ChartSeries, {
1243
+ id: series.id,
1244
+ children: /* @__PURE__ */ jsx8(Area, {
1245
+ legendType: "square",
1246
+ type: "linear",
1181
1247
  stroke,
1182
- active: true
1183
- }) : activeDot,
1184
- isAnimationActive: false,
1185
- ...props
1248
+ strokeWidth: 2,
1249
+ strokeLinecap: "round",
1250
+ strokeLinejoin: "round",
1251
+ fill: stroke,
1252
+ fillOpacity: 0.14,
1253
+ dot: dot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx8(ChartDot, {
1254
+ cx,
1255
+ cy,
1256
+ stroke
1257
+ }) : dot,
1258
+ activeDot: activeDot === undefined || activeDot === true ? ({ cx, cy }) => /* @__PURE__ */ jsx8(NearestChartDot, {
1259
+ seriesId: series.id,
1260
+ cx,
1261
+ cy,
1262
+ stroke
1263
+ }) : activeDot,
1264
+ isAnimationActive: false,
1265
+ ...props,
1266
+ id: series.id
1267
+ })
1186
1268
  });
1187
1269
  }
1188
1270
  function ChartScatter(props) {
1189
- return /* @__PURE__ */ jsx6(Scatter, {
1190
- fill: accent,
1191
- isAnimationActive: false,
1192
- ...props
1193
- });
1194
- }
1195
- function ChartXAxis(props) {
1196
- return /* @__PURE__ */ jsx6(XAxis, {
1197
- stroke: "var(--atbl-muted)",
1198
- tickLine: false,
1199
- axisLine: { stroke: "var(--atbl-border)" },
1200
- tick: { fontSize: "var(--atbl-type-meta-size)" },
1201
- ...props
1271
+ const series = useChartSeries(props.id);
1272
+ return /* @__PURE__ */ jsx8(ChartSeries, {
1273
+ id: series.id,
1274
+ children: /* @__PURE__ */ jsx8(Scatter, {
1275
+ fill: seriesColor,
1276
+ isAnimationActive: false,
1277
+ ...props,
1278
+ id: series.id
1279
+ })
1202
1280
  });
1203
1281
  }
1204
1282
  function ChartYAxis(props) {
1205
- return /* @__PURE__ */ jsx6(YAxis, {
1283
+ return /* @__PURE__ */ jsx8(YAxis, {
1206
1284
  stroke: "var(--atbl-muted)",
1285
+ tickFormatter: (value) => typeof value === "number" ? formatNumber2(value) : String(value),
1207
1286
  tickLine: false,
1208
1287
  axisLine: false,
1209
1288
  tick: { fontSize: "var(--atbl-type-meta-size)" },
@@ -1211,20 +1290,54 @@ function ChartYAxis(props) {
1211
1290
  });
1212
1291
  }
1213
1292
  function ChartGrid(props) {
1214
- return /* @__PURE__ */ jsx6(CartesianGrid, {
1293
+ return /* @__PURE__ */ jsx8(CartesianGrid, {
1215
1294
  stroke: "var(--atbl-border)",
1216
1295
  vertical: false,
1217
1296
  ...props
1218
1297
  });
1219
1298
  }
1220
1299
  function ChartTooltipContent(props) {
1221
- if (!props.active)
1300
+ if (!props.active || !props.payload?.length)
1222
1301
  return null;
1223
- return /* @__PURE__ */ jsx6(TooltipSurface, {
1302
+ return /* @__PURE__ */ jsx8(TooltipSurface, {
1224
1303
  "data-variant": "chart",
1225
1304
  role: "tooltip",
1226
- children: /* @__PURE__ */ jsx6(DefaultTooltipContent, {
1305
+ children: /* @__PURE__ */ jsx8(DefaultTooltipContent, {
1227
1306
  ...props,
1307
+ separator: "",
1308
+ payload: props.payload?.map((entry) => ({
1309
+ ...entry,
1310
+ unit: undefined,
1311
+ formatter: (value, name, _item, index, payload) => {
1312
+ const formatter = entry.formatter ?? props.formatter;
1313
+ const formatted = formatter ? formatter(value, name, entry, index, props.payload ?? payload) : Array.isArray(value) ? value.map((item) => typeof item === "number" ? formatNumber2(item) : item).join(" ~ ") : typeof value === "number" ? formatNumber2(value) : value;
1314
+ if (formatted == null)
1315
+ return null;
1316
+ const [displayValue, displayName] = Array.isArray(formatted) ? formatted : [formatted, name];
1317
+ return [
1318
+ /* @__PURE__ */ jsxs5("span", {
1319
+ className: "altertable-chart-tooltip-row",
1320
+ children: [
1321
+ /* @__PURE__ */ jsx8(ChartLegend.Marker, {
1322
+ kind: "square",
1323
+ className: "altertable-chart-tooltip-marker",
1324
+ color: entry.color ?? entry.stroke ?? entry.fill ?? "var(--atbl-chart-1)"
1325
+ }),
1326
+ /* @__PURE__ */ jsxs5("span", {
1327
+ className: "altertable-chart-tooltip-reading",
1328
+ children: [
1329
+ displayName,
1330
+ displayName !== undefined && displayName !== "" ? props.separator ?? " : " : "",
1331
+ displayValue,
1332
+ entry.unit
1333
+ ]
1334
+ })
1335
+ ]
1336
+ }, entry.graphicalItemId),
1337
+ ""
1338
+ ];
1339
+ }
1340
+ })),
1228
1341
  contentStyle: {
1229
1342
  margin: 0,
1230
1343
  padding: 0,
@@ -1240,13 +1353,25 @@ function ChartTooltipContent(props) {
1240
1353
  lineHeight: 1.2,
1241
1354
  ...props.labelStyle
1242
1355
  },
1243
- itemStyle: { paddingTop: 2, paddingBottom: 0, ...props.itemStyle }
1356
+ itemStyle: {
1357
+ color: "var(--atbl-text)",
1358
+ paddingTop: 2,
1359
+ paddingBottom: 0,
1360
+ ...props.itemStyle
1361
+ }
1244
1362
  })
1245
1363
  });
1246
1364
  }
1247
1365
  function ChartTooltip(props) {
1248
- return /* @__PURE__ */ jsx6(Tooltip, {
1249
- content: /* @__PURE__ */ jsx6(ChartTooltipContent, {}),
1366
+ const dateLabel = useDateAxisLabel(props.axisId);
1367
+ const interaction = useContext3(ChartInteraction);
1368
+ return /* @__PURE__ */ jsx8(Tooltip, {
1369
+ labelFormatter: dateLabel,
1370
+ content: (content) => /* @__PURE__ */ jsx8(ChartTooltipContent, {
1371
+ ...content,
1372
+ payload: interaction?.pointer && interaction.seriesCount !== 1 && props.shared !== true ? content.payload.filter((entry) => entry.graphicalItemId === interaction.hovered) : content.payload
1373
+ }),
1374
+ position: interaction?.pointer && interaction.point ? { y: interaction.point.y } : undefined,
1250
1375
  cursor: false,
1251
1376
  isAnimationActive: false,
1252
1377
  ...props
@@ -1272,19 +1397,19 @@ function validateChartItems(kind, items) {
1272
1397
  }
1273
1398
 
1274
1399
  // src/react/ui/TrendChart.tsx
1275
- import { jsx as jsx7, jsxs as jsxs4, Fragment } from "react/jsx-runtime";
1400
+ import { jsx as jsx9, jsxs as jsxs6, Fragment as Fragment2 } from "react/jsx-runtime";
1276
1401
  function TrendChart({
1277
1402
  items,
1278
1403
  unit,
1279
1404
  ariaLabel,
1280
- formatValue = (value) => new Intl.NumberFormat().format(value),
1405
+ formatValue = formatNumber2,
1281
1406
  area = false
1282
1407
  }) {
1283
1408
  validateChartItems(area ? "area" : "line", items);
1284
1409
  const Plot = area ? RechartsAreaChart : RechartsLineChart;
1285
- const [activeIndex, setActiveIndex] = useState();
1286
- const scrollport = useRef(null);
1287
- useLayoutEffect(() => {
1410
+ const [activeIndex, setActiveIndex] = useState3();
1411
+ const scrollport = useRef2(null);
1412
+ useLayoutEffect2(() => {
1288
1413
  const element = scrollport.current;
1289
1414
  if (element)
1290
1415
  element.scrollLeft = element.scrollWidth - element.clientWidth;
@@ -1292,30 +1417,29 @@ function TrendChart({
1292
1417
  const magnitude = items.reduce((max, item) => Math.max(max, Math.abs(item.value)), 1);
1293
1418
  const low = items.reduce((min, item) => Math.min(min, item.value / magnitude), 0);
1294
1419
  const high = items.reduce((max, item) => Math.max(max, item.value / magnitude), 0);
1295
- return /* @__PURE__ */ jsxs4("section", {
1420
+ return /* @__PURE__ */ jsxs6("section", {
1296
1421
  className: "altertable-trend-chart",
1297
1422
  "aria-label": ariaLabel,
1298
1423
  children: [
1299
- items.length === 0 && /* @__PURE__ */ jsx7("span", {
1424
+ items.length === 0 && /* @__PURE__ */ jsx9("span", {
1300
1425
  children: "No data"
1301
1426
  }),
1302
- items.length > 0 && /* @__PURE__ */ jsx7(Fragment, {
1303
- children: /* @__PURE__ */ jsx7("div", {
1427
+ items.length > 0 && /* @__PURE__ */ jsx9(Fragment2, {
1428
+ children: /* @__PURE__ */ jsx9("div", {
1304
1429
  className: "altertable-trend-scroll",
1305
1430
  ref: scrollport,
1306
- children: /* @__PURE__ */ jsxs4("div", {
1431
+ children: /* @__PURE__ */ jsxs6("div", {
1307
1432
  className: "altertable-trend-plot",
1308
1433
  style: { minWidth: items.length * 40 },
1309
1434
  children: [
1310
- /* @__PURE__ */ jsx7("div", {
1435
+ /* @__PURE__ */ jsx9("div", {
1311
1436
  className: "altertable-chart-canvas",
1312
1437
  "aria-hidden": "true",
1313
- children: /* @__PURE__ */ jsxs4(Plot, {
1438
+ children: /* @__PURE__ */ jsxs6(Plot, {
1314
1439
  data: items.map((item) => ({
1315
1440
  ...item,
1316
1441
  plotValue: item.value / magnitude
1317
1442
  })),
1318
- title: ariaLabel,
1319
1443
  responsive: true,
1320
1444
  width: "100%",
1321
1445
  height: 220,
@@ -1323,256 +1447,103 @@ function TrendChart({
1323
1447
  accessibilityLayer: false,
1324
1448
  tabIndex: -1,
1325
1449
  children: [
1326
- /* @__PURE__ */ jsx7(ChartXAxis, {
1450
+ /* @__PURE__ */ jsx9(ChartXAxis, {
1327
1451
  hide: true,
1328
1452
  dataKey: "id",
1329
1453
  scale: "band"
1330
1454
  }),
1331
- /* @__PURE__ */ jsx7(ChartYAxis, {
1455
+ /* @__PURE__ */ jsx9(ChartYAxis, {
1332
1456
  hide: true,
1333
1457
  domain: [low, high === low ? low + 1 : high]
1334
1458
  }),
1335
- /* @__PURE__ */ jsx7(ReferenceLine, {
1459
+ /* @__PURE__ */ jsx9(ReferenceLine, {
1336
1460
  y: 0,
1337
1461
  stroke: "var(--atbl-border)"
1338
1462
  }),
1339
- area && /* @__PURE__ */ jsx7(ChartArea, {
1463
+ area && /* @__PURE__ */ jsx9(ChartArea, {
1340
1464
  dataKey: "plotValue",
1341
1465
  stroke: "none",
1342
- fill: "var(--atbl-accent)",
1466
+ fill: "var(--atbl-chart-1)",
1343
1467
  dot: false,
1344
1468
  activeDot: false
1345
1469
  }),
1346
- /* @__PURE__ */ jsx7(ChartLine, {
1470
+ /* @__PURE__ */ jsx9(ChartLine, {
1347
1471
  dataKey: "plotValue",
1348
- dot: ({ cx, cy, index }) => /* @__PURE__ */ jsx7(ChartDot, {
1472
+ dot: ({ cx, cy, index }) => index === activeIndex ? /* @__PURE__ */ jsx9(ChartDot, {
1349
1473
  cx,
1350
1474
  cy,
1351
- active: index === activeIndex
1352
- }),
1353
- activeDot: false
1354
- })
1355
- ]
1356
- })
1357
- }),
1358
- /* @__PURE__ */ jsx7("div", {
1359
- className: "altertable-trend-points",
1360
- children: items.map((item, index) => /* @__PURE__ */ jsx7(Tooltip2, {
1361
- variant: "chart",
1362
- onOpenChange: (open) => setActiveIndex((current) => open ? index : current === index ? undefined : current),
1363
- content: /* @__PURE__ */ jsxs4(Fragment, {
1364
- children: [
1365
- /* @__PURE__ */ jsx7("strong", {
1366
- children: item.label
1367
- }),
1368
- /* @__PURE__ */ jsxs4("span", {
1369
- children: [
1370
- formatValue(item.value),
1371
- " ",
1372
- unit
1373
- ]
1374
- })
1375
- ]
1376
- }),
1377
- className: "altertable-chart-column",
1378
- children: /* @__PURE__ */ jsxs4("button", {
1379
- "data-atbl-focus": "ring",
1380
- "data-atbl-control": "default",
1381
- type: "button",
1382
- tabIndex: -1,
1383
- className: "altertable-trend-point",
1384
- "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
1385
- children: [
1386
- /* @__PURE__ */ jsx7("span", {
1387
- className: "altertable-trend-hit"
1388
- }),
1389
- /* @__PURE__ */ jsx7("span", {
1390
- className: "altertable-trend-label",
1391
- children: item.label
1392
- })
1393
- ]
1394
- })
1395
- }, item.id))
1396
- })
1397
- ]
1398
- })
1399
- })
1400
- })
1401
- ]
1402
- });
1403
- }
1404
-
1405
- // src/react/ui/LineChart.tsx
1406
- import { jsx as jsx8 } from "react/jsx-runtime";
1407
- function LineChart(props) {
1408
- return /* @__PURE__ */ jsx8(TrendChart, {
1409
- ...props
1410
- });
1411
- }
1412
- // src/react/ui/AreaChart.tsx
1413
- import { jsx as jsx9 } from "react/jsx-runtime";
1414
- function AreaChart(props) {
1415
- return /* @__PURE__ */ jsx9(TrendChart, {
1416
- ...props,
1417
- area: true
1418
- });
1419
- }
1420
- // src/react/ui/ChartLegend.tsx
1421
- import {
1422
- Children,
1423
- useId,
1424
- useState as useState2
1425
- } from "react";
1426
- import { jsx as jsx10, jsxs as jsxs5, Fragment as Fragment2 } from "react/jsx-runtime";
1427
- function ChartLegendRoot({
1428
- children,
1429
- layout = "horizontal",
1430
- align = "start",
1431
- maxVisibleItems = 6,
1432
- className,
1433
- "aria-label": ariaLabel = "Chart legend",
1434
- ...props
1435
- }) {
1436
- const [expanded, setExpanded] = useState2(false);
1437
- const listId = useId();
1438
- const items = Children.toArray(children);
1439
- const limit = Number.isFinite(maxVisibleItems) ? Math.max(1, Math.floor(maxVisibleItems)) : 6;
1440
- const visibleCount = items.length > limit ? limit - 1 : limit;
1441
- const hiddenCount = Math.max(0, items.length - visibleCount);
1442
- return /* @__PURE__ */ jsx10("div", {
1443
- className: "altertable-chart-legend-container",
1444
- children: /* @__PURE__ */ jsxs5("ul", {
1445
- id: listId,
1446
- ...props,
1447
- "aria-label": ariaLabel,
1448
- "data-layout": layout,
1449
- "data-align": align,
1450
- className: classNames("altertable-chart-legend", className),
1451
- children: [
1452
- expanded ? items : items.slice(0, visibleCount),
1453
- hiddenCount > 0 && /* @__PURE__ */ jsx10("li", {
1454
- className: "altertable-chart-legend-overflow",
1455
- children: /* @__PURE__ */ jsx10("button", {
1456
- type: "button",
1457
- "data-atbl-control": "action",
1458
- "data-atbl-focus": "ring",
1459
- className: "altertable-chart-legend-action",
1460
- "aria-expanded": expanded,
1461
- "aria-controls": props.id ?? listId,
1462
- onClick: () => setExpanded((value) => !value),
1463
- children: expanded ? "Show fewer" : `+${hiddenCount} more`
1464
- })
1465
- })
1466
- ]
1467
- })
1468
- });
1469
- }
1470
- function ChartLegendItem({
1471
- inactive,
1472
- className,
1473
- ...props
1474
- }) {
1475
- return /* @__PURE__ */ jsx10("li", {
1476
- ...props,
1477
- "data-inactive": inactive || undefined,
1478
- className: classNames("altertable-chart-legend-item", className)
1479
- });
1480
- }
1481
- function ChartLegendMarker({
1482
- kind,
1483
- color = kind === "bar" ? chartBarFill : "var(--atbl-accent)",
1484
- className,
1485
- style,
1486
- ...props
1487
- }) {
1488
- return /* @__PURE__ */ jsxs5("svg", {
1489
- ...props,
1490
- "aria-hidden": "true",
1491
- focusable: "false",
1492
- viewBox: "0 0 20 12",
1493
- "data-kind": kind,
1494
- className: classNames("altertable-chart-legend-marker", className),
1495
- style: { color, ...style },
1496
- children: [
1497
- kind === "bar" && /* @__PURE__ */ jsx10("path", {
1498
- d: "M6 11V3Q6 1 8 1H12Q14 1 14 3V11Z",
1499
- fill: "currentColor"
1500
- }),
1501
- kind === "slice" && /* @__PURE__ */ jsx10("rect", {
1502
- x: "5",
1503
- y: "1",
1504
- width: "10",
1505
- height: "10",
1506
- rx: "2",
1507
- fill: "currentColor"
1508
- }),
1509
- kind === "point" && /* @__PURE__ */ jsx10("circle", {
1510
- cx: "10",
1511
- cy: "6",
1512
- r: "3",
1513
- fill: "currentColor"
1514
- }),
1515
- kind === "line" && /* @__PURE__ */ jsxs5(Fragment2, {
1516
- children: [
1517
- /* @__PURE__ */ jsx10("path", {
1518
- d: "M1 6H19",
1519
- fill: "none",
1520
- stroke: "currentColor",
1521
- strokeWidth: "2",
1522
- strokeLinecap: "round"
1523
- }),
1524
- /* @__PURE__ */ jsx10("circle", {
1525
- cx: "10",
1526
- cy: "6",
1527
- r: "2.5",
1528
- fill: "var(--atbl-surface)",
1529
- stroke: "currentColor",
1530
- strokeWidth: "2"
1531
- })
1532
- ]
1533
- }),
1534
- kind === "area" && /* @__PURE__ */ jsxs5(Fragment2, {
1535
- children: [
1536
- /* @__PURE__ */ jsx10("path", {
1537
- d: "M1 10L7 5L13 7L19 2V11H1Z",
1538
- fill: "currentColor",
1539
- fillOpacity: "0.14"
1540
- }),
1541
- /* @__PURE__ */ jsx10("path", {
1542
- d: "M1 10L7 5L13 7L19 2",
1543
- fill: "none",
1544
- stroke: "currentColor",
1545
- strokeWidth: "2",
1546
- strokeLinejoin: "round",
1547
- strokeLinecap: "round"
1475
+ active: index === activeIndex
1476
+ }) : /* @__PURE__ */ jsx9("g", {}),
1477
+ activeDot: false
1478
+ })
1479
+ ]
1480
+ })
1481
+ }),
1482
+ /* @__PURE__ */ jsx9("div", {
1483
+ className: "altertable-trend-points",
1484
+ children: items.map((item, index) => /* @__PURE__ */ jsx9(Tooltip2, {
1485
+ variant: "chart",
1486
+ onOpenChange: (open) => setActiveIndex((current) => open ? index : current === index ? undefined : current),
1487
+ content: /* @__PURE__ */ jsxs6(Fragment2, {
1488
+ children: [
1489
+ /* @__PURE__ */ jsx9("strong", {
1490
+ children: item.label
1491
+ }),
1492
+ /* @__PURE__ */ jsxs6("span", {
1493
+ children: [
1494
+ formatValue(item.value),
1495
+ " ",
1496
+ unit
1497
+ ]
1498
+ })
1499
+ ]
1500
+ }),
1501
+ className: "altertable-chart-column",
1502
+ children: /* @__PURE__ */ jsxs6("button", {
1503
+ "data-atbl-focus": "ring",
1504
+ "data-atbl-control": "default",
1505
+ type: "button",
1506
+ tabIndex: -1,
1507
+ className: "altertable-trend-point",
1508
+ "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
1509
+ children: [
1510
+ /* @__PURE__ */ jsx9("span", {
1511
+ className: "altertable-trend-hit"
1512
+ }),
1513
+ /* @__PURE__ */ jsx9("span", {
1514
+ className: "altertable-trend-label",
1515
+ children: item.label
1516
+ })
1517
+ ]
1518
+ })
1519
+ }, item.id))
1520
+ })
1521
+ ]
1548
1522
  })
1549
- ]
1523
+ })
1550
1524
  })
1551
1525
  ]
1552
1526
  });
1553
1527
  }
1554
- function ChartLegendLabel({
1555
- className,
1556
- children,
1557
- title,
1558
- ...props
1559
- }) {
1560
- return /* @__PURE__ */ jsx10("span", {
1528
+
1529
+ // src/react/ui/LineChart.tsx
1530
+ import { jsx as jsx10 } from "react/jsx-runtime";
1531
+ function LineChart(props) {
1532
+ return /* @__PURE__ */ jsx10(TrendChart, {
1533
+ ...props
1534
+ });
1535
+ }
1536
+ // src/react/ui/AreaChart.tsx
1537
+ import { jsx as jsx11 } from "react/jsx-runtime";
1538
+ function AreaChart(props) {
1539
+ return /* @__PURE__ */ jsx11(TrendChart, {
1561
1540
  ...props,
1562
- title: title ?? (typeof children === "string" ? children : undefined),
1563
- className: classNames("altertable-chart-legend-label", className),
1564
- children
1541
+ area: true
1565
1542
  });
1566
1543
  }
1567
- var ChartLegend = Object.assign(ChartLegendRoot, {
1568
- Item: ChartLegendItem,
1569
- Marker: ChartLegendMarker,
1570
- Label: ChartLegendLabel
1571
- });
1572
-
1573
1544
  // src/react/ui/PieChart.tsx
1574
- import { useState as useState3 } from "react";
1575
- import { jsx as jsx11, jsxs as jsxs6, Fragment as Fragment3 } from "react/jsx-runtime";
1545
+ import { useState as useState4 } from "react";
1546
+ import { jsx as jsx12, jsxs as jsxs7, Fragment as Fragment3 } from "react/jsx-runtime";
1576
1547
  function PieChart({
1577
1548
  items,
1578
1549
  unit,
@@ -1581,9 +1552,9 @@ function PieChart({
1581
1552
  formatValue = (value) => new Intl.NumberFormat().format(value)
1582
1553
  }) {
1583
1554
  validateChartItems("pie", items);
1584
- const [previewId, setPreviewId] = useState3(null);
1585
- const [plotOpen, setPlotOpen] = useState3(false);
1586
- const [legendId, setLegendId] = useState3(null);
1555
+ const [previewId, setPreviewId] = useState4(null);
1556
+ const [plotOpen, setPlotOpen] = useState4(false);
1557
+ const [legendId, setLegendId] = useState4(null);
1587
1558
  const maximum = items.reduce((max, item) => Math.max(max, item.value), 0);
1588
1559
  const total = maximum ? items.reduce((sum, item) => sum + item.value / maximum, 0) : 0;
1589
1560
  let cursor = -Math.PI / 2;
@@ -1610,12 +1581,12 @@ function PieChart({
1610
1581
  }).format(share);
1611
1582
  }
1612
1583
  function detail(item) {
1613
- return /* @__PURE__ */ jsxs6(Fragment3, {
1584
+ return /* @__PURE__ */ jsxs7(Fragment3, {
1614
1585
  children: [
1615
- /* @__PURE__ */ jsx11("strong", {
1586
+ /* @__PURE__ */ jsx12("strong", {
1616
1587
  children: item.label
1617
1588
  }),
1618
- /* @__PURE__ */ jsxs6("span", {
1589
+ /* @__PURE__ */ jsxs7("span", {
1619
1590
  children: [
1620
1591
  formatValue(item.value),
1621
1592
  " ",
@@ -1628,33 +1599,33 @@ function PieChart({
1628
1599
  });
1629
1600
  }
1630
1601
  const preview = slices.find((item) => item.id === previewId);
1631
- return /* @__PURE__ */ jsxs6("section", {
1602
+ return /* @__PURE__ */ jsxs7("section", {
1632
1603
  className: "altertable-pie-chart",
1633
1604
  "aria-label": ariaLabel,
1634
1605
  children: [
1635
- items.length === 0 && /* @__PURE__ */ jsx11("span", {
1606
+ items.length === 0 && /* @__PURE__ */ jsx12("span", {
1636
1607
  children: "No data"
1637
1608
  }),
1638
- items.length > 0 && /* @__PURE__ */ jsxs6(Fragment3, {
1609
+ items.length > 0 && /* @__PURE__ */ jsxs7(Fragment3, {
1639
1610
  children: [
1640
- /* @__PURE__ */ jsxs6("div", {
1611
+ /* @__PURE__ */ jsxs7("div", {
1641
1612
  className: "altertable-pie-plot",
1642
1613
  children: [
1643
- /* @__PURE__ */ jsx11(Tooltip2, {
1614
+ /* @__PURE__ */ jsx12(Tooltip2, {
1644
1615
  variant: "chart",
1645
1616
  className: "altertable-pie-tooltip",
1646
1617
  onOpenChange: setPlotOpen,
1647
1618
  content: preview ? detail(preview) : null,
1648
- children: /* @__PURE__ */ jsx11("svg", {
1619
+ children: /* @__PURE__ */ jsx12("svg", {
1649
1620
  viewBox: "0 0 220 220",
1650
1621
  "aria-hidden": "true",
1651
1622
  focusable: "false",
1652
- children: total === 0 ? /* @__PURE__ */ jsx11("circle", {
1623
+ children: total === 0 ? /* @__PURE__ */ jsx12("circle", {
1653
1624
  cx: "110",
1654
1625
  cy: "110",
1655
1626
  r: "100",
1656
1627
  className: "altertable-pie-empty"
1657
- }) : slices.filter((item) => item.share > 0).map((item) => /* @__PURE__ */ jsx11("path", {
1628
+ }) : slices.filter((item) => item.share > 0).map((item) => /* @__PURE__ */ jsx12("path", {
1658
1629
  d: item.path,
1659
1630
  fill: item.color,
1660
1631
  className: "altertable-pie-slice",
@@ -1675,40 +1646,40 @@ function PieChart({
1675
1646
  }, item.id))
1676
1647
  })
1677
1648
  }),
1678
- total === 0 && /* @__PURE__ */ jsx11("span", {
1649
+ total === 0 && /* @__PURE__ */ jsx12("span", {
1679
1650
  className: "altertable-pie-empty-label",
1680
1651
  children: "No nonzero values"
1681
1652
  })
1682
1653
  ]
1683
1654
  }),
1684
- showLegend && /* @__PURE__ */ jsx11(ChartLegend, {
1655
+ showLegend && /* @__PURE__ */ jsx12(ChartLegend, {
1685
1656
  layout: "vertical",
1686
1657
  "aria-label": `${ariaLabel} legend`,
1687
1658
  className: "altertable-pie-legend",
1688
- children: slices.map((item) => /* @__PURE__ */ jsx11(ChartLegend.Item, {
1689
- children: /* @__PURE__ */ jsx11(Tooltip2, {
1659
+ children: slices.map((item) => /* @__PURE__ */ jsx12(ChartLegend.Item, {
1660
+ children: /* @__PURE__ */ jsx12(Tooltip2, {
1690
1661
  variant: "chart",
1691
1662
  content: detail(item),
1692
1663
  onOpenChange: (open) => setLegendId((current) => open ? item.id : current === item.id ? null : current),
1693
- children: /* @__PURE__ */ jsxs6("button", {
1664
+ children: /* @__PURE__ */ jsxs7("button", {
1694
1665
  "data-atbl-focus": "ring",
1695
1666
  "data-atbl-control": "default",
1696
1667
  type: "button",
1697
1668
  tabIndex: -1,
1698
1669
  "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}, ${percent(item.share)}`,
1699
1670
  children: [
1700
- /* @__PURE__ */ jsx11(ChartLegend.Marker, {
1701
- kind: "slice",
1671
+ /* @__PURE__ */ jsx12(ChartLegend.Marker, {
1672
+ kind: "square",
1702
1673
  color: item.color
1703
1674
  }),
1704
- /* @__PURE__ */ jsx11(ChartLegend.Label, {
1675
+ /* @__PURE__ */ jsx12(ChartLegend.Label, {
1705
1676
  className: "altertable-pie-label",
1706
1677
  children: item.label
1707
1678
  }),
1708
- /* @__PURE__ */ jsx11("strong", {
1679
+ /* @__PURE__ */ jsx12("strong", {
1709
1680
  children: formatValue(item.value)
1710
1681
  }),
1711
- /* @__PURE__ */ jsx11("span", {
1682
+ /* @__PURE__ */ jsx12("span", {
1712
1683
  children: percent(item.share)
1713
1684
  })
1714
1685
  ]
@@ -1722,7 +1693,7 @@ function PieChart({
1722
1693
  });
1723
1694
  }
1724
1695
  // src/react/ui/ScatterChart.tsx
1725
- import { jsx as jsx12, jsxs as jsxs7, Fragment as Fragment4 } from "react/jsx-runtime";
1696
+ import { jsx as jsx13, jsxs as jsxs8, Fragment as Fragment4 } from "react/jsx-runtime";
1726
1697
  function formatNumber(value) {
1727
1698
  return new Intl.NumberFormat(undefined, { maximumFractionDigits: 1 }).format(value);
1728
1699
  }
@@ -1751,37 +1722,37 @@ function ScatterChart({
1751
1722
  validateChartItems("scatter", items);
1752
1723
  const xScale = scale(items.map((item) => item.x));
1753
1724
  const yScale = scale(items.map((item) => item.y));
1754
- return /* @__PURE__ */ jsxs7("section", {
1725
+ return /* @__PURE__ */ jsxs8("section", {
1755
1726
  className: "altertable-scatter-chart",
1756
1727
  "aria-label": ariaLabel,
1757
1728
  children: [
1758
- items.length === 0 && /* @__PURE__ */ jsx12("span", {
1729
+ items.length === 0 && /* @__PURE__ */ jsx13("span", {
1759
1730
  children: "No data"
1760
1731
  }),
1761
- items.length > 0 && /* @__PURE__ */ jsxs7(Fragment4, {
1732
+ items.length > 0 && /* @__PURE__ */ jsxs8(Fragment4, {
1762
1733
  children: [
1763
- /* @__PURE__ */ jsxs7("p", {
1734
+ /* @__PURE__ */ jsxs8("p", {
1764
1735
  className: "altertable-scatter-axis-title",
1765
1736
  children: [
1766
1737
  yLabel,
1767
1738
  yUnit && ` (${yUnit})`
1768
1739
  ]
1769
1740
  }),
1770
- /* @__PURE__ */ jsx12("div", {
1741
+ /* @__PURE__ */ jsx13("div", {
1771
1742
  className: "altertable-scatter-axes",
1772
- children: /* @__PURE__ */ jsxs7("div", {
1743
+ children: /* @__PURE__ */ jsxs8("div", {
1773
1744
  className: "altertable-scatter-plot",
1774
1745
  children: [
1775
- yScale.ticks.map((value, index) => /* @__PURE__ */ jsx12("div", {
1746
+ yScale.ticks.map((value, index) => /* @__PURE__ */ jsx13("div", {
1776
1747
  className: "altertable-scatter-gridline",
1777
1748
  style: { bottom: `${index * 50}%` },
1778
1749
  "aria-hidden": "true",
1779
- children: /* @__PURE__ */ jsx12("span", {
1750
+ children: /* @__PURE__ */ jsx13("span", {
1780
1751
  title: formatY(value),
1781
1752
  children: formatY(value)
1782
1753
  })
1783
1754
  }, index)),
1784
- xScale.ticks.map((value, index) => /* @__PURE__ */ jsx12("span", {
1755
+ xScale.ticks.map((value, index) => /* @__PURE__ */ jsx13("span", {
1785
1756
  className: "altertable-scatter-x-tick",
1786
1757
  "data-edge": index,
1787
1758
  style: { left: `${index * 50}%` },
@@ -1789,14 +1760,14 @@ function ScatterChart({
1789
1760
  title: formatX(value),
1790
1761
  children: formatX(value)
1791
1762
  }, index)),
1792
- items.map((item) => /* @__PURE__ */ jsx12(Tooltip2, {
1763
+ items.map((item) => /* @__PURE__ */ jsx13(Tooltip2, {
1793
1764
  variant: "chart",
1794
- content: /* @__PURE__ */ jsxs7(Fragment4, {
1765
+ content: /* @__PURE__ */ jsxs8(Fragment4, {
1795
1766
  children: [
1796
- /* @__PURE__ */ jsx12("strong", {
1767
+ /* @__PURE__ */ jsx13("strong", {
1797
1768
  children: item.label
1798
1769
  }),
1799
- /* @__PURE__ */ jsxs7("span", {
1770
+ /* @__PURE__ */ jsxs8("span", {
1800
1771
  children: [
1801
1772
  xLabel,
1802
1773
  ": ",
@@ -1805,7 +1776,7 @@ function ScatterChart({
1805
1776
  xUnit
1806
1777
  ]
1807
1778
  }),
1808
- /* @__PURE__ */ jsxs7("span", {
1779
+ /* @__PURE__ */ jsxs8("span", {
1809
1780
  children: [
1810
1781
  yLabel,
1811
1782
  ": ",
@@ -1821,20 +1792,20 @@ function ScatterChart({
1821
1792
  left: `${xScale.position(item.x)}%`,
1822
1793
  bottom: `${yScale.position(item.y)}%`
1823
1794
  },
1824
- children: /* @__PURE__ */ jsx12("button", {
1795
+ children: /* @__PURE__ */ jsx13("button", {
1825
1796
  "data-atbl-focus": "ring",
1826
1797
  "data-atbl-control": "default",
1827
1798
  type: "button",
1828
1799
  tabIndex: -1,
1829
1800
  className: "altertable-scatter-point",
1830
1801
  "aria-label": `${item.label}: ${xLabel} ${formatX(item.x)} ${xUnit}, ${yLabel} ${formatY(item.y)} ${yUnit}`,
1831
- children: /* @__PURE__ */ jsx12("span", {})
1802
+ children: /* @__PURE__ */ jsx13("span", {})
1832
1803
  })
1833
1804
  }, item.id))
1834
1805
  ]
1835
1806
  })
1836
1807
  }),
1837
- /* @__PURE__ */ jsxs7("p", {
1808
+ /* @__PURE__ */ jsxs8("p", {
1838
1809
  className: "altertable-scatter-axis-title altertable-scatter-x-title",
1839
1810
  children: [
1840
1811
  xLabel,
@@ -1847,47 +1818,46 @@ function ScatterChart({
1847
1818
  });
1848
1819
  }
1849
1820
  // src/react/ui/BarChart.tsx
1850
- import { useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState4 } from "react";
1821
+ import { useLayoutEffect as useLayoutEffect3, useRef as useRef3, useState as useState5 } from "react";
1851
1822
  import { BarChart as RechartsBarChart, Cell } from "recharts";
1852
- import { jsx as jsx13, jsxs as jsxs8, Fragment as Fragment5 } from "react/jsx-runtime";
1823
+ import { jsx as jsx14, jsxs as jsxs9, Fragment as Fragment5 } from "react/jsx-runtime";
1853
1824
  function BarChart({
1854
1825
  items,
1855
1826
  unit,
1856
1827
  ariaLabel,
1857
- formatValue = (value) => new Intl.NumberFormat().format(value)
1828
+ formatValue = formatNumber2
1858
1829
  }) {
1859
1830
  validateChartItems("bar", items);
1860
- const [activeId, setActiveId] = useState4();
1861
- const scrollport = useRef2(null);
1862
- useLayoutEffect2(() => {
1831
+ const [activeId, setActiveId] = useState5();
1832
+ const scrollport = useRef3(null);
1833
+ useLayoutEffect3(() => {
1863
1834
  const element = scrollport.current;
1864
1835
  if (element)
1865
1836
  element.scrollLeft = element.scrollWidth - element.clientWidth;
1866
1837
  }, [items]);
1867
1838
  const maximum = items.reduce((max, item) => Math.max(max, item.value), 1);
1868
- return /* @__PURE__ */ jsxs8("section", {
1839
+ return /* @__PURE__ */ jsxs9("section", {
1869
1840
  className: "altertable-selectable-bars",
1870
1841
  "aria-label": ariaLabel,
1871
1842
  children: [
1872
- items.length === 0 && /* @__PURE__ */ jsx13("span", {
1843
+ items.length === 0 && /* @__PURE__ */ jsx14("span", {
1873
1844
  children: "No data"
1874
1845
  }),
1875
- /* @__PURE__ */ jsx13("div", {
1846
+ /* @__PURE__ */ jsx14("div", {
1876
1847
  className: "altertable-selectable-bars-scroll",
1877
1848
  ref: scrollport,
1878
- children: /* @__PURE__ */ jsxs8("div", {
1849
+ children: /* @__PURE__ */ jsxs9("div", {
1879
1850
  className: "altertable-selectable-bars-plot",
1880
1851
  style: { minWidth: items.length * 45 },
1881
1852
  children: [
1882
- /* @__PURE__ */ jsx13("div", {
1853
+ /* @__PURE__ */ jsx14("div", {
1883
1854
  className: "altertable-chart-canvas",
1884
1855
  "aria-hidden": "true",
1885
- children: /* @__PURE__ */ jsxs8(RechartsBarChart, {
1856
+ children: /* @__PURE__ */ jsxs9(RechartsBarChart, {
1886
1857
  data: items.map((item) => ({
1887
1858
  ...item,
1888
1859
  plotValue: item.value / maximum
1889
1860
  })),
1890
- title: ariaLabel,
1891
1861
  responsive: true,
1892
1862
  width: "100%",
1893
1863
  height: 220,
@@ -1896,37 +1866,38 @@ function BarChart({
1896
1866
  tabIndex: -1,
1897
1867
  barCategoryGap: "24%",
1898
1868
  children: [
1899
- /* @__PURE__ */ jsx13(ChartXAxis, {
1869
+ /* @__PURE__ */ jsx14(ChartXAxis, {
1900
1870
  hide: true,
1901
1871
  dataKey: "id",
1902
1872
  scale: "band"
1903
1873
  }),
1904
- /* @__PURE__ */ jsx13(ChartYAxis, {
1874
+ /* @__PURE__ */ jsx14(ChartYAxis, {
1905
1875
  hide: true,
1906
1876
  domain: [0, 1],
1907
1877
  allowDataOverflow: true
1908
1878
  }),
1909
- /* @__PURE__ */ jsx13(ChartBar, {
1879
+ /* @__PURE__ */ jsx14(ChartBar, {
1910
1880
  dataKey: "plotValue",
1911
1881
  minPointSize: (value) => (value ?? 0) > 0 ? 7 : 0,
1912
- children: items.map((item) => /* @__PURE__ */ jsx13(Cell, {
1913
- fill: activeId === item.id ? "var(--atbl-accent)" : chartBarFill
1882
+ children: items.map((item) => /* @__PURE__ */ jsx14(Cell, {
1883
+ fill: chartBarFill,
1884
+ opacity: activeId === item.id ? 0.75 : 1
1914
1885
  }, item.id))
1915
1886
  })
1916
1887
  ]
1917
1888
  })
1918
1889
  }),
1919
- /* @__PURE__ */ jsx13("div", {
1890
+ /* @__PURE__ */ jsx14("div", {
1920
1891
  className: "altertable-selectable-bars-items",
1921
- children: items.map((item) => /* @__PURE__ */ jsx13(Tooltip2, {
1892
+ children: items.map((item) => /* @__PURE__ */ jsx14(Tooltip2, {
1922
1893
  variant: "chart",
1923
1894
  onOpenChange: (open) => setActiveId((current) => open ? item.id : current === item.id ? undefined : current),
1924
- content: /* @__PURE__ */ jsxs8(Fragment5, {
1895
+ content: /* @__PURE__ */ jsxs9(Fragment5, {
1925
1896
  children: [
1926
- /* @__PURE__ */ jsx13("strong", {
1897
+ /* @__PURE__ */ jsx14("strong", {
1927
1898
  children: item.label
1928
1899
  }),
1929
- /* @__PURE__ */ jsxs8("span", {
1900
+ /* @__PURE__ */ jsxs9("span", {
1930
1901
  children: [
1931
1902
  formatValue(item.value),
1932
1903
  " ",
@@ -1936,7 +1907,7 @@ function BarChart({
1936
1907
  ]
1937
1908
  }),
1938
1909
  className: "altertable-chart-column",
1939
- children: /* @__PURE__ */ jsxs8("button", {
1910
+ children: /* @__PURE__ */ jsxs9("button", {
1940
1911
  "data-atbl-focus": "ring",
1941
1912
  "data-atbl-control": "default",
1942
1913
  type: "button",
@@ -1944,10 +1915,10 @@ function BarChart({
1944
1915
  className: "altertable-selectable-bars-item",
1945
1916
  "aria-label": `${item.label}: ${formatValue(item.value)} ${unit}`,
1946
1917
  children: [
1947
- /* @__PURE__ */ jsx13("span", {
1918
+ /* @__PURE__ */ jsx14("span", {
1948
1919
  className: "altertable-selectable-bars-area"
1949
1920
  }),
1950
- /* @__PURE__ */ jsx13("span", {
1921
+ /* @__PURE__ */ jsx14("span", {
1951
1922
  className: "altertable-selectable-bars-label",
1952
1923
  children: item.label
1953
1924
  })
@@ -1967,18 +1938,18 @@ import {
1967
1938
  Radio as AriaRadio,
1968
1939
  Label
1969
1940
  } from "react-aria-components";
1970
- import { jsx as jsx14, jsxs as jsxs9, Fragment as Fragment6 } from "react/jsx-runtime";
1941
+ import { jsx as jsx15, jsxs as jsxs10, Fragment as Fragment6 } from "react/jsx-runtime";
1971
1942
  function RadioGroup({
1972
1943
  label,
1973
1944
  className,
1974
1945
  children,
1975
1946
  ...props
1976
1947
  }) {
1977
- return /* @__PURE__ */ jsxs9(AriaRadioGroup, {
1948
+ return /* @__PURE__ */ jsxs10(AriaRadioGroup, {
1978
1949
  ...props,
1979
1950
  className: classNames("altertable-radio-group", className),
1980
1951
  children: [
1981
- /* @__PURE__ */ jsx14(Label, {
1952
+ /* @__PURE__ */ jsx15(Label, {
1982
1953
  className: "altertable-control-label",
1983
1954
  children: label
1984
1955
  }),
@@ -1987,14 +1958,14 @@ function RadioGroup({
1987
1958
  });
1988
1959
  }
1989
1960
  function Radio({ className, children, ...props }) {
1990
- return /* @__PURE__ */ jsx14(AriaRadio, {
1961
+ return /* @__PURE__ */ jsx15(AriaRadio, {
1991
1962
  ...props,
1992
1963
  "data-atbl-control": "action",
1993
1964
  "data-atbl-focus": "ring",
1994
1965
  className: classNames("altertable-radio", className),
1995
- children: (state) => /* @__PURE__ */ jsxs9(Fragment6, {
1966
+ children: (state) => /* @__PURE__ */ jsxs10(Fragment6, {
1996
1967
  children: [
1997
- /* @__PURE__ */ jsx14("span", {
1968
+ /* @__PURE__ */ jsx15("span", {
1998
1969
  className: "altertable-radio-mark",
1999
1970
  "aria-hidden": "true"
2000
1971
  }),
@@ -2009,13 +1980,13 @@ function SegmentedControl({
2009
1980
  ...props
2010
1981
  }) {
2011
1982
  validateChoiceOptions(options);
2012
- return /* @__PURE__ */ jsx14(RadioGroup, {
1983
+ return /* @__PURE__ */ jsx15(RadioGroup, {
2013
1984
  ...props,
2014
1985
  orientation: "horizontal",
2015
1986
  className: classNames("altertable-segmented-control", className),
2016
- children: /* @__PURE__ */ jsx14("div", {
1987
+ children: /* @__PURE__ */ jsx15("div", {
2017
1988
  className: "altertable-segmented-options",
2018
- children: options.map((option) => /* @__PURE__ */ jsx14(Radio, {
1989
+ children: options.map((option) => /* @__PURE__ */ jsx15(Radio, {
2019
1990
  value: option.id,
2020
1991
  "data-atbl-internal-surface": "option",
2021
1992
  children: option.label
@@ -2024,7 +1995,7 @@ function SegmentedControl({
2024
1995
  });
2025
1996
  }
2026
1997
  // src/react/ui/CheckboxGroup.tsx
2027
- import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
1998
+ import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
2028
1999
  function CheckboxGroup({
2029
2000
  label,
2030
2001
  values,
@@ -2035,15 +2006,15 @@ function CheckboxGroup({
2035
2006
  ...props
2036
2007
  }) {
2037
2008
  invariant(new Set(values).size === values.length, "Checkbox group values must be unique.");
2038
- return /* @__PURE__ */ jsxs10("fieldset", {
2009
+ return /* @__PURE__ */ jsxs11("fieldset", {
2039
2010
  ...props,
2040
2011
  disabled,
2041
2012
  className: classNames("altertable-checkbox-group", className),
2042
2013
  children: [
2043
- /* @__PURE__ */ jsx15("legend", {
2014
+ /* @__PURE__ */ jsx16("legend", {
2044
2015
  children: label
2045
2016
  }),
2046
- /* @__PURE__ */ jsx15(CheckboxGroupContext, {
2017
+ /* @__PURE__ */ jsx16(CheckboxGroupContext, {
2047
2018
  value: {
2048
2019
  values,
2049
2020
  disabled,
@@ -2056,9 +2027,17 @@ function CheckboxGroup({
2056
2027
  ]
2057
2028
  });
2058
2029
  }
2030
+ // src/react/ui/ComposedChart.tsx
2031
+ import {
2032
+ useState as useState6,
2033
+ useCallback as useCallback2,
2034
+ useRef as useRef4,
2035
+ useLayoutEffect as useLayoutEffect4
2036
+ } from "react";
2037
+
2059
2038
  // src/react/ui/ComposedChartLegend.tsx
2060
2039
  import { Legend } from "recharts";
2061
- import { jsx as jsx16, jsxs as jsxs11, Fragment as Fragment7 } from "react/jsx-runtime";
2040
+ import { jsx as jsx17, jsxs as jsxs12, Fragment as Fragment7 } from "react/jsx-runtime";
2062
2041
  var legendMarkerKinds = {
2063
2042
  square: "area",
2064
2043
  rect: "bar",
@@ -2073,7 +2052,7 @@ function LegendContent({
2073
2052
  align,
2074
2053
  labelStyle,
2075
2054
  iconType,
2076
- iconSize = 20,
2055
+ iconSize = 8,
2077
2056
  inactiveColor = "var(--atbl-muted)",
2078
2057
  position,
2079
2058
  verticalAlign,
@@ -2085,7 +2064,7 @@ function LegendContent({
2085
2064
  if (!payload.some((entry) => entry.type !== "none"))
2086
2065
  return null;
2087
2066
  const vertical = layout === "vertical" || layout === "auto" && (position === "left" || position === "right");
2088
- return /* @__PURE__ */ jsx16(ChartLegend, {
2067
+ return /* @__PURE__ */ jsx17(ChartLegend, {
2089
2068
  "aria-label": ariaLabel,
2090
2069
  className: position === "top" || position == null && verticalAlign === "top" ? "altertable-composed-chart-legend-above" : position === "bottom" || position == null && verticalAlign !== "middle" && !vertical ? "altertable-composed-chart-legend-below" : undefined,
2091
2070
  maxVisibleItems,
@@ -2095,27 +2074,30 @@ function LegendContent({
2095
2074
  if (entry.type === "none")
2096
2075
  return null;
2097
2076
  const type = iconType ?? entry.type;
2098
- const kind = legendMarkerKinds[type ?? "none"] ?? "point";
2077
+ const kind = iconType ? legendMarkerKinds[type ?? "none"] ?? "point" : "square";
2099
2078
  const formatLabel = entry.formatter ?? formatter;
2100
2079
  const label = formatLabel ? formatLabel(entry.value, entry, index) : entry.value;
2101
- const content = /* @__PURE__ */ jsxs11(Fragment7, {
2080
+ const content = /* @__PURE__ */ jsxs12(Fragment7, {
2102
2081
  children: [
2103
- type !== "none" && (entry.legendIcon ?? /* @__PURE__ */ jsx16(ChartLegend.Marker, {
2082
+ type !== "none" && (entry.legendIcon ?? /* @__PURE__ */ jsx17(ChartLegend.Marker, {
2104
2083
  kind,
2105
2084
  color: entry.inactive ? inactiveColor : entry.color,
2106
- style: { width: iconSize, height: iconSize * 0.6 }
2085
+ style: {
2086
+ width: iconSize,
2087
+ height: kind === "square" ? iconSize : iconSize * 0.6
2088
+ }
2107
2089
  })),
2108
- /* @__PURE__ */ jsx16(ChartLegend.Label, {
2090
+ /* @__PURE__ */ jsx17(ChartLegend.Label, {
2109
2091
  style: labelStyle,
2110
2092
  children: label
2111
2093
  })
2112
2094
  ]
2113
2095
  });
2114
- return /* @__PURE__ */ jsx16(ChartLegend.Item, {
2096
+ return /* @__PURE__ */ jsx17(ChartLegend.Item, {
2115
2097
  inactive: entry.inactive,
2116
2098
  onMouseEnter: onMouseEnter ? (event) => onMouseEnter(entry, index, event) : undefined,
2117
2099
  onMouseLeave: onMouseLeave ? (event) => onMouseLeave(entry, index, event) : undefined,
2118
- children: onClick ? /* @__PURE__ */ jsx16("button", {
2100
+ children: onClick ? /* @__PURE__ */ jsx17("button", {
2119
2101
  type: "button",
2120
2102
  "data-atbl-control": "action",
2121
2103
  "data-atbl-focus": "ring",
@@ -2131,10 +2113,10 @@ function ComposedChartLegend({
2131
2113
  maxVisibleItems,
2132
2114
  ...props
2133
2115
  }) {
2134
- return /* @__PURE__ */ jsx16(Legend, {
2135
- iconSize: 20,
2116
+ return /* @__PURE__ */ jsx17(Legend, {
2117
+ iconSize: 8,
2136
2118
  inactiveColor: "var(--atbl-muted)",
2137
- content: /* @__PURE__ */ jsx16(LegendContent, {
2119
+ content: /* @__PURE__ */ jsx17(LegendContent, {
2138
2120
  maxVisibleItems
2139
2121
  }),
2140
2122
  ...props
@@ -2154,7 +2136,21 @@ import {
2154
2136
  LabelList,
2155
2137
  ErrorBar
2156
2138
  } from "recharts";
2157
- import { jsx as jsx17 } from "react/jsx-runtime";
2139
+ import { jsx as jsx18 } from "react/jsx-runtime";
2140
+ function closestSeries(hovered, points, position) {
2141
+ let selected = hovered;
2142
+ if (position && points.size > 0 && (hovered == null || points.has(hovered))) {
2143
+ let distance = Infinity;
2144
+ for (const [id, point] of points) {
2145
+ const candidate = Math.hypot(point.x - position.x, point.y - position.y);
2146
+ if (candidate < distance) {
2147
+ distance = candidate;
2148
+ selected = id;
2149
+ }
2150
+ }
2151
+ }
2152
+ return selected;
2153
+ }
2158
2154
  function ComposedChartRoot({
2159
2155
  data,
2160
2156
  ariaLabel,
@@ -2164,17 +2160,96 @@ function ComposedChartRoot({
2164
2160
  className,
2165
2161
  ...props
2166
2162
  }) {
2167
- return /* @__PURE__ */ jsx17("section", {
2168
- className: ["altertable-composed-chart", className].filter(Boolean).join(" "),
2169
- "aria-label": ariaLabel,
2170
- children: /* @__PURE__ */ jsx17(RechartsComposedChart, {
2171
- "data-atbl-focus": "inset",
2172
- ...props,
2173
- data,
2174
- width,
2175
- height,
2176
- responsive,
2177
- title: ariaLabel
2163
+ const [pointerFocus, setPointerFocus] = useState6(false);
2164
+ const [pointer, setPointer] = useState6(false);
2165
+ const [hovered, setHovered] = useState6(null);
2166
+ const pointerPosition = useRef4(null);
2167
+ const [nearest, setNearest] = useState6(null);
2168
+ const [points, setPoints] = useState6(() => new Map);
2169
+ const registerPoint = useCallback2((id, x, y) => {
2170
+ setPoints((current) => new Map(current).set(id, { x, y }));
2171
+ return () => setPoints((current) => {
2172
+ const next = new Map(current);
2173
+ next.delete(id);
2174
+ return next;
2175
+ });
2176
+ }, []);
2177
+ function trackPointer(event) {
2178
+ setPointer(true);
2179
+ const svg = event.currentTarget.querySelector('svg[role="application"]');
2180
+ if (!(svg instanceof SVGSVGElement))
2181
+ return;
2182
+ const matrix = svg.getScreenCTM();
2183
+ if (!matrix)
2184
+ return;
2185
+ const point = new DOMPoint(event.clientX, event.clientY).matrixTransform(matrix.inverse());
2186
+ pointerPosition.current = { x: point.x, y: point.y };
2187
+ setNearest(closestSeries(hovered, points, pointerPosition.current));
2188
+ }
2189
+ useLayoutEffect4(() => {
2190
+ setNearest(closestSeries(hovered, points, pointerPosition.current));
2191
+ }, [hovered, points]);
2192
+ const [seriesIds, setSeriesIds] = useState6(() => new Set);
2193
+ const registerSeries = useCallback2((id) => {
2194
+ setSeriesIds((current) => new Set(current).add(id));
2195
+ return () => {
2196
+ setSeriesIds((current) => {
2197
+ const next = new Set(current);
2198
+ next.delete(id);
2199
+ return next;
2200
+ });
2201
+ };
2202
+ }, []);
2203
+ return /* @__PURE__ */ jsx18(ChartInteraction.Provider, {
2204
+ value: {
2205
+ pointer,
2206
+ hovered: nearest,
2207
+ point: nearest == null ? undefined : points.get(nearest),
2208
+ registerPoint,
2209
+ setHovered,
2210
+ seriesCount: seriesIds.size,
2211
+ registerSeries
2212
+ },
2213
+ children: /* @__PURE__ */ jsx18("section", {
2214
+ className: ["altertable-composed-chart", className].filter(Boolean).join(" "),
2215
+ "aria-label": ariaLabel,
2216
+ "data-atbl-internal-pointer-focus": pointerFocus || undefined,
2217
+ onPointerDownCapture: (event) => {
2218
+ setPointerFocus(true);
2219
+ trackPointer(event);
2220
+ },
2221
+ onPointerOverCapture: trackPointer,
2222
+ onPointerMoveCapture: trackPointer,
2223
+ onPointerLeave: (event) => {
2224
+ if (event.pointerType !== "touch") {
2225
+ setHovered(null);
2226
+ pointerPosition.current = null;
2227
+ setNearest(null);
2228
+ }
2229
+ },
2230
+ onKeyDownCapture: () => {
2231
+ setPointerFocus(false);
2232
+ setPointer(false);
2233
+ pointerPosition.current = null;
2234
+ setNearest(null);
2235
+ setHovered(null);
2236
+ },
2237
+ onBlurCapture: (event) => {
2238
+ if (!event.currentTarget.contains(event.relatedTarget))
2239
+ setPointerFocus(false);
2240
+ },
2241
+ children: /* @__PURE__ */ jsx18(ChartDateAxes, {
2242
+ data,
2243
+ children: /* @__PURE__ */ jsx18(RechartsComposedChart, {
2244
+ "data-atbl-focus": "inset",
2245
+ ...props,
2246
+ data,
2247
+ width,
2248
+ height,
2249
+ responsive,
2250
+ "aria-label": ariaLabel
2251
+ })
2252
+ })
2178
2253
  })
2179
2254
  });
2180
2255
  }
@@ -2199,6 +2274,794 @@ var ComposedChart = Object.assign(ComposedChartRoot, {
2199
2274
  LabelList,
2200
2275
  ErrorBar
2201
2276
  });
2277
+ // src/react/ui/FunnelChart.tsx
2278
+ import { Fragment as Fragment8, useEffect as useEffect4, useRef as useRef5, useState as useState7 } from "react";
2279
+
2280
+ // src/react/ui/useSvgId.ts
2281
+ import { useId as useId3 } from "react";
2282
+ function useSvgId() {
2283
+ const id = useId3();
2284
+ return `svg-${Array.from(id, (character) => /[a-zA-Z0-9-]/.test(character) ? character : `_${character.codePointAt(0).toString(16)}_`).join("")}`;
2285
+ }
2286
+
2287
+ // src/react/ui/FunnelChart.tsx
2288
+ import { jsx as jsx19, jsxs as jsxs13, Fragment as Fragment9 } from "react/jsx-runtime";
2289
+ function FunnelChart({
2290
+ steps,
2291
+ series,
2292
+ unit,
2293
+ ariaLabel,
2294
+ className,
2295
+ formatValue = formatNumber2
2296
+ }) {
2297
+ const chartId = useSvgId();
2298
+ const [highlighted, setHighlighted] = useState7(null);
2299
+ const clearTimer = useRef5(null);
2300
+ function cancelClear() {
2301
+ if (clearTimer.current !== null)
2302
+ clearTimeout(clearTimer.current);
2303
+ clearTimer.current = null;
2304
+ }
2305
+ useEffect4(() => cancelClear, []);
2306
+ function highlight(id, conversion, step) {
2307
+ cancelClear();
2308
+ setHighlighted({ id, conversion, step });
2309
+ }
2310
+ function clearHighlight() {
2311
+ cancelClear();
2312
+ setHighlighted(null);
2313
+ }
2314
+ function scheduleClear() {
2315
+ cancelClear();
2316
+ clearTimer.current = setTimeout(() => setHighlighted(null), 100);
2317
+ }
2318
+ for (const [kind, items] of [
2319
+ ["funnel step", steps],
2320
+ ["funnel series", series]
2321
+ ]) {
2322
+ const ids = new Set;
2323
+ for (const item of items) {
2324
+ invariant(item.id.trim().length > 0 && !ids.has(item.id), `${kind} chart IDs must be nonblank and unique.`);
2325
+ ids.add(item.id);
2326
+ }
2327
+ }
2328
+ for (const item of series) {
2329
+ invariant(item.values.length === steps.length, "funnel chart counts must align with steps.");
2330
+ item.values.forEach((value, index) => {
2331
+ invariant(Number.isFinite(value) && value >= 0, "funnel chart counts must be finite and nonnegative.");
2332
+ invariant(index === 0 || value <= item.values[index - 1], "funnel chart counts must be nonincreasing.");
2333
+ });
2334
+ }
2335
+ function reading(item, index) {
2336
+ const first = item.values[0] ?? 0;
2337
+ const current = item.values[index];
2338
+ const previous = item.values[Math.max(0, index - 1)];
2339
+ return {
2340
+ current,
2341
+ previous,
2342
+ dropped: previous - current,
2343
+ conversion: first > 0 ? current / first : null,
2344
+ dropOff: first > 0 ? (previous - current) / first : null
2345
+ };
2346
+ }
2347
+ const data = steps.map((step, index) => ({
2348
+ label: step.label,
2349
+ index,
2350
+ ...Object.fromEntries(series.flatMap((item, seriesIndex) => {
2351
+ const value = reading(item, index);
2352
+ return [
2353
+ [`conversion${seriesIndex}`, (value.conversion ?? 0) * 100],
2354
+ [
2355
+ `drop${seriesIndex}`,
2356
+ (value.dropOff ?? (index === 0 ? 1 : 0)) * 100
2357
+ ]
2358
+ ];
2359
+ }))
2360
+ }));
2361
+ return /* @__PURE__ */ jsx19("section", {
2362
+ className: classNames("altertable-funnel-chart", className),
2363
+ "aria-label": ariaLabel,
2364
+ onKeyDownCapture: clearHighlight,
2365
+ children: steps.length === 0 || series.length === 0 ? /* @__PURE__ */ jsx19("span", {
2366
+ children: "No data"
2367
+ }) : /* @__PURE__ */ jsxs13(Fragment9, {
2368
+ children: [
2369
+ /* @__PURE__ */ jsxs13("div", {
2370
+ className: "altertable-funnel-header",
2371
+ children: [
2372
+ /* @__PURE__ */ jsx19(ChartLegend, {
2373
+ "aria-label": "Funnel series",
2374
+ layout: "single-row",
2375
+ children: series.map((item, index) => /* @__PURE__ */ jsxs13(ChartLegend.Item, {
2376
+ className: "altertable-funnel-summary-item",
2377
+ children: [
2378
+ /* @__PURE__ */ jsxs13("span", {
2379
+ className: "altertable-funnel-series-label",
2380
+ children: [
2381
+ /* @__PURE__ */ jsx19(ChartLegend.Marker, {
2382
+ kind: "square",
2383
+ color: `var(--atbl-chart-${index % 8 + 1})`
2384
+ }),
2385
+ /* @__PURE__ */ jsx19(ChartLegend.Label, {
2386
+ children: item.label
2387
+ })
2388
+ ]
2389
+ }),
2390
+ /* @__PURE__ */ jsx19("strong", {
2391
+ className: "altertable-funnel-series-value",
2392
+ children: formatPercent2(reading(item, steps.length - 1).conversion)
2393
+ })
2394
+ ]
2395
+ }, item.id))
2396
+ }),
2397
+ /* @__PURE__ */ jsxs13("p", {
2398
+ className: "altertable-funnel-path",
2399
+ children: [
2400
+ steps[0].label,
2401
+ " → ",
2402
+ steps.at(-1).label
2403
+ ]
2404
+ })
2405
+ ]
2406
+ }),
2407
+ /* @__PURE__ */ jsx19("div", {
2408
+ className: "altertable-funnel-scroll",
2409
+ children: /* @__PURE__ */ jsx19("div", {
2410
+ style: {
2411
+ minWidth: steps.length * Math.max(96, series.length * 40)
2412
+ },
2413
+ children: /* @__PURE__ */ jsxs13(ComposedChart, {
2414
+ data,
2415
+ ariaLabel: `${ariaLabel} plot`,
2416
+ height: 300,
2417
+ barCategoryGap: "4%",
2418
+ barGap: 1,
2419
+ onMouseLeave: clearHighlight,
2420
+ children: [
2421
+ /* @__PURE__ */ jsx19(ComposedChart.CartesianGrid, {}),
2422
+ /* @__PURE__ */ jsx19(ComposedChart.XAxis, {
2423
+ dataKey: "label",
2424
+ interval: 0,
2425
+ height: 48
2426
+ }),
2427
+ /* @__PURE__ */ jsx19(ComposedChart.YAxis, {
2428
+ domain: [0, 100],
2429
+ width: 42,
2430
+ tickFormatter: (value) => formatPercent2(value / 100)
2431
+ }),
2432
+ /* @__PURE__ */ jsx19("defs", {
2433
+ children: series.map((item, index) => /* @__PURE__ */ jsxs13("pattern", {
2434
+ id: `${chartId}-hatch-${index}`,
2435
+ patternUnits: "userSpaceOnUse",
2436
+ width: "6",
2437
+ height: "6",
2438
+ patternTransform: "rotate(45)",
2439
+ children: [
2440
+ /* @__PURE__ */ jsx19("rect", {
2441
+ width: "8",
2442
+ height: "8",
2443
+ fill: `var(--atbl-chart-${index % 8 + 1})`,
2444
+ fillOpacity: 0.16
2445
+ }),
2446
+ /* @__PURE__ */ jsx19("line", {
2447
+ x1: "0",
2448
+ y1: "0",
2449
+ x2: "0",
2450
+ y2: "8",
2451
+ stroke: `var(--atbl-chart-${index % 8 + 1})`,
2452
+ strokeOpacity: 0.4,
2453
+ strokeWidth: "2"
2454
+ })
2455
+ ]
2456
+ }, item.id))
2457
+ }),
2458
+ series.map((item, index) => /* @__PURE__ */ jsxs13(Fragment8, {
2459
+ children: [
2460
+ /* @__PURE__ */ jsx19(ComposedChart.Bar, {
2461
+ dataKey: `conversion${index}`,
2462
+ name: item.label,
2463
+ stackId: item.id,
2464
+ fill: `var(--atbl-chart-${index % 8 + 1})`,
2465
+ radius: 0,
2466
+ maxBarSize: undefined,
2467
+ activeBar: false,
2468
+ minPointSize: 0,
2469
+ opacity: !highlighted || highlighted.id === item.id ? 1 : 0.2,
2470
+ onMouseEnter: (bar) => highlight(item.id, true, bar.payload.index),
2471
+ onMouseLeave: scheduleClear,
2472
+ onClick: (bar) => highlight(item.id, true, bar.payload.index)
2473
+ }),
2474
+ /* @__PURE__ */ jsx19(ComposedChart.Bar, {
2475
+ dataKey: `drop${index}`,
2476
+ name: `${item.label} drop-off`,
2477
+ stackId: item.id,
2478
+ fill: `url(#${chartId}-hatch-${index})`,
2479
+ opacity: !highlighted || highlighted.id === item.id ? 1 : 0.2,
2480
+ onMouseEnter: (bar) => highlight(item.id, false, bar.payload.index),
2481
+ onMouseLeave: scheduleClear,
2482
+ onClick: (bar) => highlight(item.id, false, bar.payload.index),
2483
+ radius: 0,
2484
+ maxBarSize: undefined,
2485
+ activeBar: false
2486
+ })
2487
+ ]
2488
+ }, item.id)),
2489
+ /* @__PURE__ */ jsx19(ComposedChart.Tooltip, {
2490
+ content: ({ active, payload }) => {
2491
+ const index = payload?.[0]?.payload.index;
2492
+ if (!active || typeof index !== "number")
2493
+ return null;
2494
+ const tooltipItems = series.filter((item) => !highlighted || highlighted.step !== index || item.id === highlighted.id).flatMap((item) => {
2495
+ const value = reading(item, index);
2496
+ const selected = highlighted?.step === index;
2497
+ const readings = selected ? [highlighted.conversion] : [true, false];
2498
+ const seriesIndex = series.indexOf(item);
2499
+ return readings.map((conversion) => ({
2500
+ name: item.label,
2501
+ graphicalItemId: `${item.id}-${conversion ? "conversion" : "drop-off"}`,
2502
+ dataKey: `${item.id}-${conversion ? "conversion" : "drop-off"}`,
2503
+ color: `var(--atbl-chart-${seriesIndex % 8 + 1})`,
2504
+ value: (conversion ? value.conversion : value.dropOff) ?? 0,
2505
+ formatter: () => /* @__PURE__ */ jsxs13(Fragment9, {
2506
+ children: [
2507
+ formatPercent2(conversion ? value.conversion : value.dropOff),
2508
+ " ",
2509
+ conversion ? "conversion" : "drop-off",
2510
+ /* @__PURE__ */ jsxs13("span", {
2511
+ className: "altertable-funnel-tooltip-detail",
2512
+ children: [
2513
+ formatValue(conversion ? value.current : value.dropped),
2514
+ " ",
2515
+ "of ",
2516
+ formatValue(value.previous),
2517
+ " ",
2518
+ unit
2519
+ ]
2520
+ })
2521
+ ]
2522
+ })
2523
+ }));
2524
+ });
2525
+ return /* @__PURE__ */ jsx19(ChartTooltipContent, {
2526
+ active: true,
2527
+ label: steps[index].label,
2528
+ payload: tooltipItems
2529
+ });
2530
+ }
2531
+ })
2532
+ ]
2533
+ })
2534
+ })
2535
+ }),
2536
+ /* @__PURE__ */ jsx19("ul", {
2537
+ className: "altertable-sr-only",
2538
+ children: steps.map((step, index) => /* @__PURE__ */ jsxs13("li", {
2539
+ children: [
2540
+ step.label,
2541
+ series.map((item) => {
2542
+ const value = reading(item, index);
2543
+ return /* @__PURE__ */ jsxs13("span", {
2544
+ children: [
2545
+ " ",
2546
+ "· ",
2547
+ item.label,
2548
+ ": ",
2549
+ formatValue(value.current),
2550
+ " ",
2551
+ unit,
2552
+ ",",
2553
+ " ",
2554
+ formatPercent2(value.conversion),
2555
+ " conversion,",
2556
+ " ",
2557
+ formatValue(value.dropped),
2558
+ " dropped off"
2559
+ ]
2560
+ }, item.id);
2561
+ })
2562
+ ]
2563
+ }, step.id))
2564
+ })
2565
+ ]
2566
+ })
2567
+ });
2568
+ }
2569
+ // src/react/ui/RetentionChart.tsx
2570
+ import { Fragment as Fragment10 } from "react";
2571
+ import { jsx as jsx20, jsxs as jsxs14, Fragment as Fragment11 } from "react/jsx-runtime";
2572
+ function RetentionChart({
2573
+ series,
2574
+ unit,
2575
+ ariaLabel,
2576
+ className,
2577
+ formatValue = formatNumber2
2578
+ }) {
2579
+ const ids = new Set;
2580
+ const offsets = new Map;
2581
+ for (const item of series) {
2582
+ invariant(item.id.trim().length > 0 && !ids.has(item.id), "retention series chart IDs must be nonblank and unique.");
2583
+ ids.add(item.id);
2584
+ invariant(Number.isFinite(item.cohortSize) && item.cohortSize >= 0, "retention chart counts must be finite and nonnegative.");
2585
+ const seen = new Set;
2586
+ for (const point of item.points) {
2587
+ invariant(Number.isSafeInteger(point.offset) && point.offset >= 0 && !seen.has(point.offset), "retention chart offsets must be unique nonnegative integers within each series.");
2588
+ seen.add(point.offset);
2589
+ invariant(point.rate === null || Number.isFinite(point.rate) && point.rate >= 0 && point.rate <= 1, "retention chart rates must be finite fractions between 0 and 1, or null.");
2590
+ invariant(point.rate === null === (point.retainedCount === null), "retention chart unobserved rates and counts must both be null.");
2591
+ if (point.retainedCount !== null) {
2592
+ invariant(Number.isFinite(point.retainedCount) && point.retainedCount >= 0, "retention chart counts must be finite and nonnegative.");
2593
+ invariant(point.retainedCount <= item.cohortSize, "retention chart retained counts cannot exceed cohort size.");
2594
+ }
2595
+ invariant(!offsets.has(point.offset) || offsets.get(point.offset) === point.label, "retention chart labels must agree for the same offset.");
2596
+ offsets.set(point.offset, point.label);
2597
+ }
2598
+ }
2599
+ const data = [...offsets].sort(([a], [b]) => a - b).map(([offset, label]) => ({
2600
+ offset,
2601
+ label,
2602
+ ...Object.fromEntries(series.flatMap((_, index) => [
2603
+ [`rate${index}`, null],
2604
+ [`tail${index}`, null]
2605
+ ]))
2606
+ }));
2607
+ series.forEach((item, index) => {
2608
+ const points = [...item.points].sort((a, b) => a.offset - b.offset);
2609
+ points.forEach((point, pointIndex) => {
2610
+ const row = data.find((row) => row.offset === point.offset);
2611
+ row[point.incomplete ? `tail${index}` : `rate${index}`] = point.rate === null ? null : point.rate * 100;
2612
+ if (point.incomplete && pointIndex > 0) {
2613
+ const previous = points[pointIndex - 1];
2614
+ data.find((row) => row.offset === previous.offset)[`tail${index}`] = previous.rate === null ? null : previous.rate * 100;
2615
+ }
2616
+ });
2617
+ });
2618
+ return /* @__PURE__ */ jsx20("section", {
2619
+ className: classNames("altertable-retention-chart", className),
2620
+ "aria-label": ariaLabel,
2621
+ children: data.length === 0 ? /* @__PURE__ */ jsx20("span", {
2622
+ children: "No data"
2623
+ }) : /* @__PURE__ */ jsxs14(Fragment11, {
2624
+ children: [
2625
+ /* @__PURE__ */ jsxs14(ComposedChart, {
2626
+ data,
2627
+ ariaLabel: `${ariaLabel} plot`,
2628
+ children: [
2629
+ /* @__PURE__ */ jsx20(ComposedChart.CartesianGrid, {}),
2630
+ /* @__PURE__ */ jsx20(ComposedChart.XAxis, {
2631
+ dataKey: "offset",
2632
+ type: "number",
2633
+ domain: [0, Math.max(1, ...offsets.keys())],
2634
+ tickFormatter: (value) => offsets.get(Number(value)) ?? (data[0]?.label.replace(/\d+(?:\.\d+)?/, String(value)) || String(value))
2635
+ }),
2636
+ /* @__PURE__ */ jsx20(ComposedChart.YAxis, {
2637
+ domain: [0, 100],
2638
+ width: 42,
2639
+ tickFormatter: (value) => `${value}%`
2640
+ }),
2641
+ series.map((item, index) => /* @__PURE__ */ jsxs14(Fragment10, {
2642
+ children: [
2643
+ /* @__PURE__ */ jsx20(ComposedChart.Line, {
2644
+ dataKey: `rate${index}`,
2645
+ name: item.label,
2646
+ stroke: `var(--atbl-chart-${index % 8 + 1})`,
2647
+ connectNulls: false
2648
+ }),
2649
+ /* @__PURE__ */ jsx20(ComposedChart.Line, {
2650
+ dataKey: `tail${index}`,
2651
+ name: item.label,
2652
+ stroke: `var(--atbl-chart-${index % 8 + 1})`,
2653
+ strokeDasharray: "3 3",
2654
+ dot: false,
2655
+ activeDot: false,
2656
+ connectNulls: false
2657
+ })
2658
+ ]
2659
+ }, item.id)),
2660
+ /* @__PURE__ */ jsx20(ComposedChart.Tooltip, {
2661
+ filterNull: false,
2662
+ content: ({ active, payload }) => {
2663
+ const offset = payload?.[0]?.payload.offset;
2664
+ if (!active || typeof offset !== "number")
2665
+ return null;
2666
+ return /* @__PURE__ */ jsxs14(TooltipSurface, {
2667
+ "data-variant": "chart",
2668
+ role: "tooltip",
2669
+ children: [
2670
+ /* @__PURE__ */ jsx20("strong", {
2671
+ children: offsets.get(offset)
2672
+ }),
2673
+ series.map((item) => {
2674
+ const point = item.points.find((point) => point.offset === offset);
2675
+ if (!point)
2676
+ return null;
2677
+ return /* @__PURE__ */ jsxs14("span", {
2678
+ children: [
2679
+ item.label,
2680
+ ":",
2681
+ " ",
2682
+ point.rate === null ? "Not observed" : `${formatPercent2(point.rate)} · ${formatValue(point.retainedCount)} / ${formatValue(item.cohortSize)} ${unit}${point.incomplete ? " · Incomplete period" : ""}`
2683
+ ]
2684
+ }, item.id);
2685
+ })
2686
+ ]
2687
+ });
2688
+ }
2689
+ })
2690
+ ]
2691
+ }),
2692
+ /* @__PURE__ */ jsx20(ChartLegend, {
2693
+ "aria-label": `${ariaLabel} cohorts`,
2694
+ children: series.map((item, index) => /* @__PURE__ */ jsxs14(ChartLegend.Item, {
2695
+ children: [
2696
+ /* @__PURE__ */ jsx20(ChartLegend.Marker, {
2697
+ kind: "square",
2698
+ color: `var(--atbl-chart-${index % 8 + 1})`
2699
+ }),
2700
+ /* @__PURE__ */ jsx20(ChartLegend.Label, {
2701
+ children: item.label
2702
+ })
2703
+ ]
2704
+ }, item.id))
2705
+ }),
2706
+ /* @__PURE__ */ jsx20("ul", {
2707
+ className: "altertable-sr-only",
2708
+ children: series.map((item) => /* @__PURE__ */ jsxs14("li", {
2709
+ children: [
2710
+ item.label,
2711
+ item.points.map((point) => /* @__PURE__ */ jsxs14("span", {
2712
+ children: [
2713
+ " ",
2714
+ "· ",
2715
+ point.label,
2716
+ ":",
2717
+ " ",
2718
+ point.rate === null ? "Not observed" : `${formatPercent2(point.rate)} · ${formatValue(point.retainedCount)} / ${formatValue(item.cohortSize)} ${unit}${point.incomplete ? " · Incomplete period" : ""}`
2719
+ ]
2720
+ }, point.offset))
2721
+ ]
2722
+ }, item.id))
2723
+ })
2724
+ ]
2725
+ })
2726
+ });
2727
+ }
2728
+ // src/react/ui/JourneyChart.tsx
2729
+ import { useLayoutEffect as useLayoutEffect5, useRef as useRef6, useState as useState8 } from "react";
2730
+
2731
+ // src/react/ui/journey-flow.ts
2732
+ var journeyOutcomeLabels = {
2733
+ truncated: "More steps",
2734
+ "drop-off": "Drop-off",
2735
+ converted: "Converted",
2736
+ end: "End of path"
2737
+ };
2738
+ function journeyNodes(path) {
2739
+ const nodes = path.steps.map((step, depth) => ({
2740
+ key: JSON.stringify([depth, "event", step.event, step.property]),
2741
+ label: step.property === null ? step.event : `${step.event} · ${step.property}`,
2742
+ depth,
2743
+ outcome: "event"
2744
+ }));
2745
+ const outcome = path.truncated ? "truncated" : path.converted === false ? "drop-off" : path.converted === true ? "converted" : "end";
2746
+ nodes.push({
2747
+ key: JSON.stringify([nodes.length, outcome]),
2748
+ label: journeyOutcomeLabels[outcome],
2749
+ depth: nodes.length,
2750
+ outcome
2751
+ });
2752
+ return nodes;
2753
+ }
2754
+ function buildJourneyFlow(paths, expandedBranch) {
2755
+ const nodes = new Map;
2756
+ const links = new Map;
2757
+ for (const path of paths) {
2758
+ const fullSequence = journeyNodes(path);
2759
+ if (path.truncated)
2760
+ fullSequence.pop();
2761
+ const sequence = expandedBranch === undefined ? fullSequence : fullSequence.flatMap((node, index) => {
2762
+ const branchKeys = fullSequence.slice(0, index + 1).map((step) => step.key);
2763
+ const parentExpanded = index <= 1 || branchKeys.slice(0, index).every((key, depth) => expandedBranch[depth] === key);
2764
+ if (!parentExpanded)
2765
+ return [];
2766
+ return [
2767
+ {
2768
+ ...node,
2769
+ key: JSON.stringify(branchKeys),
2770
+ branchKeys,
2771
+ expandable: index >= 1 && index < fullSequence.length - 1,
2772
+ expanded: branchKeys.every((key, depth) => expandedBranch[depth] === key)
2773
+ }
2774
+ ];
2775
+ });
2776
+ sequence.forEach((node, index) => {
2777
+ const current = nodes.get(node.key) ?? {
2778
+ ...node,
2779
+ count: 0,
2780
+ pathKeys: []
2781
+ };
2782
+ current.count += path.count;
2783
+ if ("expandable" in node && node.expandable)
2784
+ current.expandable = true;
2785
+ current.pathKeys.push(path.id);
2786
+ nodes.set(node.key, current);
2787
+ const previous = sequence[index - 1];
2788
+ if (!previous)
2789
+ return;
2790
+ const key = JSON.stringify([previous.key, node.key]);
2791
+ const link = links.get(key) ?? {
2792
+ key,
2793
+ source: previous.key,
2794
+ target: node.key,
2795
+ count: 0,
2796
+ pathKeys: []
2797
+ };
2798
+ link.count += path.count;
2799
+ link.pathKeys.push(path.id);
2800
+ links.set(key, link);
2801
+ });
2802
+ }
2803
+ return { nodes: [...nodes.values()], links: [...links.values()] };
2804
+ }
2805
+ function limitJourneyFlow(graph, visibleEventsByDepth = {}) {
2806
+ const nodes = [];
2807
+ const replacements = new Map;
2808
+ for (const depth of new Set(graph.nodes.map((node) => node.depth))) {
2809
+ const column = graph.nodes.filter((node) => node.depth === depth).sort((a, b) => Number(Boolean(b.expanded)) - Number(Boolean(a.expanded)) || b.count - a.count || a.key.localeCompare(b.key));
2810
+ const events = column.filter((node) => node.outcome === "event");
2811
+ const outcomes = column.filter((node) => node.outcome !== "event");
2812
+ const limit = visibleEventsByDepth[depth] ?? 3;
2813
+ if (events.length <= limit) {
2814
+ nodes.push(...column);
2815
+ continue;
2816
+ }
2817
+ nodes.push(...events.slice(0, limit), ...outcomes);
2818
+ const hidden = events.slice(limit);
2819
+ const key = JSON.stringify(["other", depth]);
2820
+ hidden.forEach((node) => replacements.set(node.key, key));
2821
+ nodes.push({
2822
+ key,
2823
+ label: "More events",
2824
+ depth,
2825
+ outcome: "other",
2826
+ hiddenBranchCount: hidden.length,
2827
+ count: hidden.reduce((sum, node) => sum + node.count, 0),
2828
+ pathKeys: [...new Set(hidden.flatMap((node) => node.pathKeys))]
2829
+ });
2830
+ }
2831
+ const links = new Map;
2832
+ for (const link of graph.links) {
2833
+ const source = replacements.get(link.source) ?? link.source;
2834
+ const target = replacements.get(link.target) ?? link.target;
2835
+ const key = JSON.stringify([source, target]);
2836
+ const existing = links.get(key);
2837
+ if (existing) {
2838
+ existing.count += link.count;
2839
+ existing.pathKeys.push(...link.pathKeys);
2840
+ } else {
2841
+ links.set(key, {
2842
+ ...link,
2843
+ key,
2844
+ source,
2845
+ target,
2846
+ pathKeys: [...link.pathKeys]
2847
+ });
2848
+ }
2849
+ }
2850
+ return { nodes, links: [...links.values()] };
2851
+ }
2852
+
2853
+ // src/react/ui/JourneyChart.tsx
2854
+ import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
2855
+ function JourneyChart({
2856
+ paths,
2857
+ unit,
2858
+ ariaLabel,
2859
+ className,
2860
+ formatValue = formatNumber2
2861
+ }) {
2862
+ const ids = new Set;
2863
+ let total = 0;
2864
+ for (const path of paths) {
2865
+ invariant(path.id.trim().length > 0 && !ids.has(path.id), "journey path chart IDs must be nonblank and unique.");
2866
+ ids.add(path.id);
2867
+ invariant(Number.isFinite(path.count) && path.count >= 0, "journey chart counts must be finite and nonnegative.");
2868
+ total += path.count;
2869
+ invariant(path.steps.length > 0 && path.steps.every((step) => step.event.trim().length > 0), "journey chart paths require nonblank events.");
2870
+ }
2871
+ invariant(Number.isFinite(total), "journey chart total count must be finite.");
2872
+ return /* @__PURE__ */ jsx21("section", {
2873
+ className: classNames("altertable-journey-chart", className),
2874
+ "aria-label": ariaLabel,
2875
+ children: paths.length === 0 ? /* @__PURE__ */ jsx21("span", {
2876
+ children: "No data"
2877
+ }) : /* @__PURE__ */ jsx21(JourneyFlow, {
2878
+ paths,
2879
+ unit,
2880
+ formatValue
2881
+ }, JSON.stringify(paths))
2882
+ });
2883
+ }
2884
+ function JourneyFlow({
2885
+ paths,
2886
+ unit,
2887
+ formatValue
2888
+ }) {
2889
+ const [expandedBranch, setExpandedBranch] = useState8([]);
2890
+ const [visibleEventsByDepth, setVisibleEventsByDepth] = useState8({});
2891
+ const graph = limitJourneyFlow(buildJourneyFlow(paths, expandedBranch), visibleEventsByDepth);
2892
+ const scrollRef = useRef6(null);
2893
+ const pendingDepth = useRef6(null);
2894
+ const depthCount = Math.max(0, ...graph.nodes.map((node) => node.depth)) + 1;
2895
+ const startingCount = graph.nodes.filter((node) => node.depth === 0).reduce((sum, node) => sum + node.count, 0);
2896
+ function percent(count) {
2897
+ return formatPercent2(startingCount > 0 ? count / startingCount : null);
2898
+ }
2899
+ const nodeWidth = 176;
2900
+ const nodeHeight = 96;
2901
+ const barWidth = 16;
2902
+ const rowSpacing = nodeHeight + 80;
2903
+ const columnSpacing = nodeWidth + 112;
2904
+ const width = 34 + nodeWidth + (depthCount - 1) * columnSpacing;
2905
+ function columnX(depth) {
2906
+ return 10 + depth * columnSpacing;
2907
+ }
2908
+ useLayoutEffect5(() => {
2909
+ const depth = pendingDepth.current;
2910
+ const container = scrollRef.current;
2911
+ if (depth === null || !container || depth >= depthCount)
2912
+ return;
2913
+ pendingDepth.current = null;
2914
+ const left = columnX(depth);
2915
+ const right = left + nodeWidth + 24;
2916
+ const nextLeft = left < container.scrollLeft ? left - 24 : right > container.scrollLeft + container.clientWidth ? right - container.clientWidth : container.scrollLeft;
2917
+ if (nextLeft !== container.scrollLeft)
2918
+ container.scrollTo({
2919
+ left: Math.max(0, nextLeft),
2920
+ behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "instant" : "smooth"
2921
+ });
2922
+ });
2923
+ const columns = Array.from({ length: depthCount }, (_, depth) => graph.nodes.filter((node) => node.depth === depth).sort((a, b) => {
2924
+ function rank(node) {
2925
+ return node.outcome === "event" ? 0 : node.outcome === "other" ? 1 : 2;
2926
+ }
2927
+ return rank(a) - rank(b) || b.count - a.count || a.key.localeCompare(b.key);
2928
+ }));
2929
+ const positions = new Map;
2930
+ columns.forEach((column, depth) => {
2931
+ const parent = columns[depth - 1]?.find((node) => node.expanded);
2932
+ const parentY = parent ? positions.get(parent.key)?.y : undefined;
2933
+ const top = Math.max(104, (parentY ?? 104) - (column.length > 1 ? rowSpacing : 0));
2934
+ column.forEach((node, index) => positions.set(node.key, {
2935
+ node,
2936
+ x: columnX(depth),
2937
+ y: top + index * rowSpacing
2938
+ }));
2939
+ });
2940
+ const height = Math.max(280, ...[...positions.values()].map((position) => position.y + nodeHeight + 40));
2941
+ const outgoingOffsets = new Map;
2942
+ const incomingOffsets = new Map;
2943
+ const orderedLinks = [...graph.links].sort((a, b) => (positions.get(a.source)?.y ?? 0) - (positions.get(b.source)?.y ?? 0) || (positions.get(a.target)?.y ?? 0) - (positions.get(b.target)?.y ?? 0));
2944
+ const links = orderedLinks.flatMap((link) => {
2945
+ const source = positions.get(link.source);
2946
+ const target = positions.get(link.target);
2947
+ if (!source || !target || link.count <= 0 || startingCount <= 0)
2948
+ return [];
2949
+ const x0 = source.x + barWidth;
2950
+ const x1 = target.x;
2951
+ const mid = (x0 + x1) / 2;
2952
+ const sourceTop = source.y + (outgoingOffsets.get(link.source) ?? 0);
2953
+ const targetTop = target.y + (incomingOffsets.get(link.target) ?? 0);
2954
+ const thickness = link.count / startingCount * nodeHeight;
2955
+ outgoingOffsets.set(link.source, (outgoingOffsets.get(link.source) ?? 0) + thickness);
2956
+ incomingOffsets.set(link.target, (incomingOffsets.get(link.target) ?? 0) + thickness);
2957
+ return [
2958
+ {
2959
+ muted: target.node.outcome === "end" || target.node.outcome === "other",
2960
+ d: `M${x0},${sourceTop} C${mid},${sourceTop} ${mid},${targetTop} ${x1},${targetTop} L${x1},${targetTop + thickness} C${mid},${targetTop + thickness} ${mid},${sourceTop + thickness} ${x0},${sourceTop + thickness} Z`
2961
+ }
2962
+ ];
2963
+ });
2964
+ return /* @__PURE__ */ jsx21("div", {
2965
+ ref: scrollRef,
2966
+ className: "altertable-journey-scroll",
2967
+ children: /* @__PURE__ */ jsxs15("div", {
2968
+ className: "altertable-journey-plot",
2969
+ style: { minWidth: width, minHeight: height },
2970
+ children: [
2971
+ /* @__PURE__ */ jsxs15("svg", {
2972
+ width: "100%",
2973
+ height: "100%",
2974
+ "aria-hidden": "true",
2975
+ focusable: "false",
2976
+ children: [
2977
+ /* @__PURE__ */ jsx21("path", {
2978
+ d: links.filter((link) => !link.muted).map((link) => link.d).join(" "),
2979
+ fill: "color-mix(in srgb, var(--atbl-chart-5) 22%, var(--atbl-surface))"
2980
+ }),
2981
+ /* @__PURE__ */ jsx21("path", {
2982
+ d: links.filter((link) => link.muted).map((link) => link.d).join(" "),
2983
+ fill: "color-mix(in srgb, var(--atbl-muted) 22%, var(--atbl-surface))"
2984
+ })
2985
+ ]
2986
+ }),
2987
+ columns.map((column, depth) => /* @__PURE__ */ jsx21("span", {
2988
+ className: "altertable-journey-stage",
2989
+ style: { left: columnX(depth) },
2990
+ children: column.length > 0 && column.every((node) => node.outcome !== "event" && node.outcome !== "other") ? "Outcome" : `Step ${depth + 1}`
2991
+ }, depth)),
2992
+ [...positions.values()].map(({ node, x, y }) => /* @__PURE__ */ jsxs15("div", {
2993
+ className: "altertable-journey-node",
2994
+ style: {
2995
+ left: x,
2996
+ top: y,
2997
+ width: nodeWidth,
2998
+ height: startingCount > 0 ? node.count / startingCount * nodeHeight : 0
2999
+ },
3000
+ children: [
3001
+ /* @__PURE__ */ jsx21("div", {
3002
+ className: "altertable-journey-bar",
3003
+ "data-event": node.outcome === "event" || undefined,
3004
+ "aria-hidden": "true",
3005
+ style: { width: barWidth }
3006
+ }),
3007
+ /* @__PURE__ */ jsxs15("section", {
3008
+ "aria-label": `${node.label}, step ${node.depth + 1}, ${formatValue(node.count)} ${unit}`,
3009
+ className: "altertable-journey-label",
3010
+ children: [
3011
+ /* @__PURE__ */ jsx21("span", {
3012
+ className: "altertable-journey-name",
3013
+ title: node.label,
3014
+ children: node.label
3015
+ }),
3016
+ /* @__PURE__ */ jsxs15("span", {
3017
+ children: [
3018
+ formatValue(node.count),
3019
+ " ",
3020
+ unit,
3021
+ " · ",
3022
+ percent(node.count)
3023
+ ]
3024
+ }),
3025
+ node.hiddenBranchCount ? /* @__PURE__ */ jsxs15("span", {
3026
+ children: [
3027
+ node.hiddenBranchCount,
3028
+ " hidden",
3029
+ " ",
3030
+ node.hiddenBranchCount === 1 ? "event" : "events"
3031
+ ]
3032
+ }) : null
3033
+ ]
3034
+ }),
3035
+ node.expandable && /* @__PURE__ */ jsx21(Button2, {
3036
+ variant: "outline",
3037
+ size: "icon-compact",
3038
+ className: "altertable-journey-expand",
3039
+ "aria-label": `${node.expanded ? "Less" : "More"} after ${node.label}, step ${node.depth + 1}`,
3040
+ "aria-expanded": Boolean(node.expanded),
3041
+ onClick: () => {
3042
+ pendingDepth.current = node.expanded ? null : node.depth + 1;
3043
+ setVisibleEventsByDepth((limits) => Object.fromEntries(Object.entries(limits).filter(([depth]) => Number(depth) <= node.depth)));
3044
+ setExpandedBranch(node.expanded ? (node.branchKeys ?? []).slice(0, -1) : node.branchKeys ?? []);
3045
+ },
3046
+ children: node.expanded ? "−" : "›"
3047
+ }),
3048
+ node.outcome === "other" && /* @__PURE__ */ jsx21(Button2, {
3049
+ size: "compact",
3050
+ variant: "ghost",
3051
+ className: "altertable-journey-more",
3052
+ "aria-label": `Show more events at step ${node.depth + 1}`,
3053
+ onClick: () => setVisibleEventsByDepth((limits) => ({
3054
+ ...limits,
3055
+ [node.depth]: (limits[node.depth] ?? 3) + 3
3056
+ })),
3057
+ children: "Show more events"
3058
+ })
3059
+ ]
3060
+ }, node.key))
3061
+ ]
3062
+ })
3063
+ });
3064
+ }
2202
3065
  export {
2203
3066
  AboutData2 as AboutData,
2204
3067
  AppIcon2 as AppIcon,
@@ -2211,22 +3074,24 @@ export {
2211
3074
  ComposedChart,
2212
3075
  DataApp,
2213
3076
  DataAppProvider2 as DataAppProvider,
2214
- DataAppSkeleton,
2215
3077
  DataTable2 as DataTable,
2216
3078
  DataTableEmptyRow2 as DataTableEmptyRow,
2217
3079
  DataTableShare2 as DataTableShare,
2218
3080
  DataTableTimestamp2 as DataTableTimestamp,
2219
3081
  DataValue2 as DataValue,
2220
3082
  DataWidget2 as DataWidget,
3083
+ DateDisplay2 as DateDisplay,
2221
3084
  DateRangePicker2 as DateRangePicker,
2222
3085
  DimensionPicker2 as DimensionPicker,
2223
3086
  FilterActions2 as FilterActions,
2224
3087
  FilterBar2 as FilterBar,
3088
+ FunnelChart,
2225
3089
  GettingStarted,
2226
3090
  GlossaryDefinition,
2227
3091
  GlossaryExplanation,
2228
3092
  GradientScroll2 as GradientScroll,
2229
3093
  HelpPopover2 as HelpPopover,
3094
+ JourneyChart,
2230
3095
  LineChart,
2231
3096
  LiveControl2 as LiveControl,
2232
3097
  Menu2 as Menu,
@@ -2244,9 +3109,12 @@ export {
2244
3109
  PresentStory2 as PresentStory,
2245
3110
  Radio,
2246
3111
  RadioGroup,
3112
+ RetentionChart,
2247
3113
  ScatterChart,
2248
3114
  SearchField2 as SearchField,
2249
3115
  SearchMatch2 as SearchMatch,
3116
+ SearchTypeahead2 as SearchTypeahead,
3117
+ SectionHeading2 as SectionHeading,
2250
3118
  SegmentedControl,
2251
3119
  Select2 as Select,
2252
3120
  Sheet2 as Sheet,
@@ -2261,12 +3129,14 @@ export {
2261
3129
  TooltipProvider2 as TooltipProvider,
2262
3130
  VariableBar2 as VariableBar,
2263
3131
  VisualizationWidget2 as VisualizationWidget,
2264
- injectDataAppShellStyles,
2265
3132
  injectDataAppStyles2 as injectDataAppStyles,
2266
3133
  isPlainKeyEvent2 as isPlainKeyEvent,
3134
+ matchSearchText2 as matchSearchText,
2267
3135
  searchItems2 as searchItems,
2268
3136
  useAppVariables2 as useAppVariables,
3137
+ useDateFormatting2 as useDateFormatting,
3138
+ useSvgId,
2269
3139
  useViewTab2 as useViewTab
2270
3140
  };
2271
3141
 
2272
- //# debugId=FCD41F839B3A5B8964756E2164756E21
3142
+ //# debugId=3D3A9CC87FD5C9DB64756E2164756E21