@mechane-ai/elements 0.0.0-stage → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +32 -0
  3. package/README.md +119 -2
  4. package/dist/accessibility-C-aIZ1Yx.js +15 -0
  5. package/dist/ai.js +323 -0
  6. package/dist/assets/stylex.css +2664 -0
  7. package/dist/categorical-values-cMX7Mykq.js +58 -0
  8. package/dist/chart-frame-bX0VLC_W.js +152 -0
  9. package/dist/chart-input-qnM44oen.js +21 -0
  10. package/dist/charts/cartesian.js +1040 -0
  11. package/dist/charts/distribution.js +610 -0
  12. package/dist/charts/graph.js +231 -0
  13. package/dist/charts/hierarchy.js +109 -0
  14. package/dist/charts/matrix.js +439 -0
  15. package/dist/charts/timeline.js +198 -0
  16. package/dist/charts.js +1 -0
  17. package/dist/code-block-BiMcfdlB.js +175 -0
  18. package/dist/collections.js +466 -0
  19. package/dist/content/code.js +1 -0
  20. package/dist/content/diff.js +96 -0
  21. package/dist/content/link.js +1 -0
  22. package/dist/content/markdown.js +155 -0
  23. package/dist/content/tree.js +77 -0
  24. package/dist/content-link-Bm-Td5wm.js +26 -0
  25. package/dist/content.js +318 -0
  26. package/dist/feedback.js +1 -0
  27. package/dist/forms/dates.js +168 -0
  28. package/dist/forms.js +1 -0
  29. package/dist/index.js +1 -0
  30. package/dist/layout.js +379 -0
  31. package/dist/navigation/commands.js +80 -0
  32. package/dist/navigation-yxK3iQXo.js +39 -0
  33. package/dist/navigation.js +58 -0
  34. package/dist/overlays.js +1 -0
  35. package/dist/packages/ai/src/approval.d.ts +29 -0
  36. package/dist/packages/ai/src/conversation.d.ts +34 -0
  37. package/dist/packages/ai/src/index.d.ts +10 -0
  38. package/dist/packages/ai/src/message.d.ts +19 -0
  39. package/dist/packages/ai/src/prompt-input.d.ts +25 -0
  40. package/dist/packages/ai/src/sources.d.ts +17 -0
  41. package/dist/packages/charts/src/cartesian/bar-chart.d.ts +24 -0
  42. package/dist/packages/charts/src/cartesian/breakdown-bar.d.ts +12 -0
  43. package/dist/packages/charts/src/cartesian/index.d.ts +12 -0
  44. package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +37 -0
  45. package/dist/packages/charts/src/cartesian/sparkline.d.ts +11 -0
  46. package/dist/packages/charts/src/cartesian/time-series-data.d.ts +54 -0
  47. package/dist/packages/charts/src/cartesian/time-series-line.d.ts +9 -0
  48. package/dist/packages/charts/src/cartesian/time-series.d.ts +29 -0
  49. package/dist/packages/charts/src/categorical-values.d.ts +24 -0
  50. package/dist/packages/charts/src/chart-frame.d.ts +34 -0
  51. package/dist/packages/charts/src/chart-input.d.ts +10 -0
  52. package/dist/packages/charts/src/chart-theme.d.ts +48 -0
  53. package/dist/packages/charts/src/distribution/distribution-input.d.ts +14 -0
  54. package/dist/packages/charts/src/distribution/distribution-plot.d.ts +135 -0
  55. package/dist/packages/charts/src/distribution/ecdf.d.ts +23 -0
  56. package/dist/packages/charts/src/distribution/histogram.d.ts +26 -0
  57. package/dist/packages/charts/src/distribution/index.d.ts +8 -0
  58. package/dist/packages/charts/src/distribution/interval-plot.d.ts +24 -0
  59. package/dist/packages/charts/src/distribution/ranked-bars.d.ts +22 -0
  60. package/dist/packages/charts/src/graph/index.d.ts +2 -0
  61. package/dist/packages/charts/src/graph/relation-graph.d.ts +45 -0
  62. package/dist/packages/charts/src/hierarchy/index.d.ts +2 -0
  63. package/dist/packages/charts/src/hierarchy/treemap.d.ts +12 -0
  64. package/dist/packages/charts/src/index.d.ts +4 -0
  65. package/dist/packages/charts/src/matrix/color-legend.d.ts +7 -0
  66. package/dist/packages/charts/src/matrix/heatmap-scale.d.ts +8 -0
  67. package/dist/packages/charts/src/matrix/index.d.ts +7 -0
  68. package/dist/packages/charts/src/matrix/matrix.d.ts +34 -0
  69. package/dist/packages/charts/src/matrix/token-heatmap.d.ts +20 -0
  70. package/dist/packages/charts/src/plot-width.d.ts +5 -0
  71. package/dist/packages/charts/src/timeline/index.d.ts +2 -0
  72. package/dist/packages/charts/src/timeline/waterfall.d.ts +34 -0
  73. package/dist/packages/collections/src/collection-controls.d.ts +41 -0
  74. package/dist/packages/collections/src/data-table.d.ts +49 -0
  75. package/dist/packages/collections/src/index.d.ts +10 -0
  76. package/dist/packages/collections/src/inspector.d.ts +16 -0
  77. package/dist/packages/collections/src/list-footer.d.ts +6 -0
  78. package/dist/packages/collections/src/metrics.d.ts +9 -0
  79. package/dist/packages/collections/src/table.d.ts +17 -0
  80. package/dist/packages/collections/src/timestamp.d.ts +7 -0
  81. package/dist/packages/content/src/code/code-block.d.ts +22 -0
  82. package/dist/packages/content/src/code/index.d.ts +2 -0
  83. package/dist/packages/content/src/code/use-highlighted-code.d.ts +9 -0
  84. package/dist/packages/content/src/content-link.d.ts +8 -0
  85. package/dist/packages/content/src/diff/diff-source.d.ts +32 -0
  86. package/dist/packages/content/src/diff/diff-viewer.d.ts +3 -0
  87. package/dist/packages/content/src/diff/index.d.ts +2 -0
  88. package/dist/packages/content/src/diff/pierre-diff.d.ts +14 -0
  89. package/dist/packages/content/src/index.d.ts +8 -0
  90. package/dist/packages/content/src/json-viewer.d.ts +11 -0
  91. package/dist/packages/content/src/link.d.ts +2 -0
  92. package/dist/packages/content/src/log-viewer.d.ts +9 -0
  93. package/dist/packages/content/src/markdown/index.d.ts +2 -0
  94. package/dist/packages/content/src/markdown/markdown.d.ts +7 -0
  95. package/dist/packages/content/src/pierre-theme.d.ts +36 -0
  96. package/dist/packages/content/src/stack-trace.d.ts +16 -0
  97. package/dist/packages/content/src/trace.d.ts +35 -0
  98. package/dist/packages/content/src/tree/file-tree-types.d.ts +12 -0
  99. package/dist/packages/content/src/tree/file-tree.d.ts +3 -0
  100. package/dist/packages/content/src/tree/index.d.ts +2 -0
  101. package/dist/packages/content/src/tree/pierre-tree.d.ts +3 -0
  102. package/dist/packages/core/src/actions.d.ts +31 -0
  103. package/dist/packages/core/src/avatar.d.ts +10 -0
  104. package/dist/packages/core/src/copy-value.d.ts +9 -0
  105. package/dist/packages/core/src/disclosure.d.ts +33 -0
  106. package/dist/packages/core/src/index.d.ts +7 -0
  107. package/dist/packages/core/src/surfaces.d.ts +18 -0
  108. package/dist/packages/core/src/text.d.ts +30 -0
  109. package/dist/packages/feedback/src/feedback.d.ts +11 -0
  110. package/dist/packages/feedback/src/index.d.ts +7 -0
  111. package/dist/packages/feedback/src/loading.d.ts +7 -0
  112. package/dist/packages/feedback/src/progress.d.ts +10 -0
  113. package/dist/packages/feedback/src/skeleton.d.ts +18 -0
  114. package/dist/packages/feedback/src/toast.d.ts +28 -0
  115. package/dist/packages/forms/src/combobox.d.ts +81 -0
  116. package/dist/packages/forms/src/dates/calendar.d.ts +32 -0
  117. package/dist/packages/forms/src/dates/date-range-picker.d.ts +16 -0
  118. package/dist/packages/forms/src/dates/index.d.ts +4 -0
  119. package/dist/packages/forms/src/field-styles.d.ts +66 -0
  120. package/dist/packages/forms/src/form-controls.d.ts +81 -0
  121. package/dist/packages/forms/src/forms.d.ts +32 -0
  122. package/dist/packages/forms/src/index.d.ts +7 -0
  123. package/dist/packages/forms/src/select.d.ts +44 -0
  124. package/dist/packages/forms/src/selection-styles.d.ts +110 -0
  125. package/dist/packages/forms/src/selection.d.ts +57 -0
  126. package/dist/packages/forms/src/settings-row.d.ts +8 -0
  127. package/dist/packages/foundations/src/accessibility.d.ts +14 -0
  128. package/dist/packages/foundations/src/control-state.d.ts +67 -0
  129. package/dist/packages/foundations/src/overlay-styles.d.ts +46 -0
  130. package/dist/packages/foundations/src/popup-styles.d.ts +84 -0
  131. package/dist/packages/foundations/src/style-composition.d.ts +22 -0
  132. package/dist/packages/foundations/src/theme.d.ts +16 -0
  133. package/dist/packages/foundations/src/tokens.stylex.d.ts +143 -0
  134. package/dist/packages/layout/src/app-shell.d.ts +9 -0
  135. package/dist/packages/layout/src/detail-page.d.ts +6 -0
  136. package/dist/packages/layout/src/frame.stylex.d.ts +23 -0
  137. package/dist/packages/layout/src/index.d.ts +6 -0
  138. package/dist/packages/layout/src/page-toolbar.d.ts +14 -0
  139. package/dist/packages/layout/src/resizable.d.ts +27 -0
  140. package/dist/packages/layout/src/sidebar.d.ts +46 -0
  141. package/dist/packages/navigation/src/commands/command.d.ts +37 -0
  142. package/dist/packages/navigation/src/commands/index.d.ts +2 -0
  143. package/dist/packages/navigation/src/index.d.ts +3 -0
  144. package/dist/packages/navigation/src/navigation.d.ts +24 -0
  145. package/dist/packages/navigation/src/skip-link.d.ts +6 -0
  146. package/dist/packages/navigation/src/tabs.d.ts +19 -0
  147. package/dist/packages/overlays/src/alert-dialog.d.ts +18 -0
  148. package/dist/packages/overlays/src/dialog.d.ts +27 -0
  149. package/dist/packages/overlays/src/drawer.d.ts +33 -0
  150. package/dist/packages/overlays/src/index.d.ts +7 -0
  151. package/dist/packages/overlays/src/menu.d.ts +51 -0
  152. package/dist/packages/overlays/src/popover.d.ts +24 -0
  153. package/dist/packages/overlays/src/preview.d.ts +17 -0
  154. package/dist/packages/overlays/src/tooltip.d.ts +18 -0
  155. package/dist/pierre-diff-CZdzgiYm.js +66 -0
  156. package/dist/pierre-theme-BpESNIsV.js +96 -0
  157. package/dist/pierre-tree-qZVvI5c1.js +106 -0
  158. package/dist/plot-width--OgdohB5.js +18 -0
  159. package/dist/popup-styles-CvtZDE2t.js +135 -0
  160. package/dist/src-BfvOOeA3.js +272 -0
  161. package/dist/src-CbYaLvhD.js +671 -0
  162. package/dist/src-CfDf8TY8.js +466 -0
  163. package/dist/src-CvpS9XIR.js +1077 -0
  164. package/dist/style-composition-uYlczSsB.js +9 -0
  165. package/dist/theme.js +7 -0
  166. package/dist/tokens.js +138 -0
  167. package/package.json +148 -3
  168. package/packages/foundations/src/tokens.stylex.ts +145 -0
  169. package/styles.css +2 -0
@@ -0,0 +1,1040 @@
1
+ import { i as e, n as t, r as n, t as r } from "../categorical-values-cMX7Mykq.js";
2
+ import { a as i, i as a, n as o, o as s, r as c, t as l } from "../chart-frame-bX0VLC_W.js";
3
+ import { n as u, r as d, t as f } from "../chart-input-qnM44oen.js";
4
+ import { t as p } from "../plot-width--OgdohB5.js";
5
+ import { b as m } from "../src-CbYaLvhD.js";
6
+ import { m as h } from "../src-CvpS9XIR.js";
7
+ import { colors as g } from "../tokens.js";
8
+ import * as _ from "@stylexjs/stylex";
9
+ import { useEffect as v, useId as y, useMemo as b, useRef as x, useState as S } from "react";
10
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
11
+ import { scaleBand as E, scaleLinear as D } from "@visx/scale";
12
+ import { AreaClosed as O, Bar as k, LinePath as A } from "@visx/shape";
13
+ // packages/charts/src/cartesian/bar-chart.tsx
14
+ var ee = { plot: {
15
+ kqGvvJ: "x1we84gm",
16
+ $$css: !0
17
+ } };
18
+ function j({ categories: e, series: n, domain: r, mode: i }) {
19
+ if (e.length > t.items || n.length > t.series) return `Choose a window with at most ${t.items} categories and ${t.series} series.`;
20
+ if (!d(r) || r[0] > 0 || r[1] < 0) return "The bar domain must be finite, increasing, and include zero.";
21
+ if (!u(e) || !u(n)) return "Bar categories and series require unique identifiers.";
22
+ for (let t of n) {
23
+ if (t.values.length !== e.length) return "Every series requires one explicit value per category.";
24
+ for (let e of t.values) {
25
+ if (e !== null && (!Number.isFinite(e) || e < r[0] || e > r[1])) return "Bar values must be finite and within the supplied domain.";
26
+ if (i === "stacked" && (e === null || e < 0)) return "Stacked bars require present nonnegative values.";
27
+ }
28
+ }
29
+ if (i === "stacked" && e.some((e, t) => n.reduce((e, n) => e + (n.values[t] ?? 0), 0) > r[1])) return "Stacked bar totals must fit the supplied domain.";
30
+ }
31
+ function M({ title: e, description: t, categories: o, series: l, domain: u, mode: d = "grouped", formatValue: m, selection: h, height: g = 200 }) {
32
+ let v = j({
33
+ categories: o,
34
+ series: l,
35
+ domain: u,
36
+ mode: d
37
+ }), { ref: y, width: b } = p();
38
+ if (v !== void 0 || !Number.isFinite(g) || g < 48) return /* @__PURE__ */ w(f, {
39
+ title: e,
40
+ description: t,
41
+ message: v ?? "Chart height must be at least 48 pixels."
42
+ });
43
+ let x = g - 28, S = D({
44
+ domain: [...u],
45
+ range: [x, 12]
46
+ }), C = Math.max(52, ...S.ticks(3).map((e) => m(e).length * 7 + 12)), O = Math.max(C + 1, b - 16), A = E({
47
+ domain: o.map((e) => e.id),
48
+ range: [C, O],
49
+ padding: .3
50
+ }), M = E({
51
+ domain: l.map((e) => e.id),
52
+ range: [0, A.bandwidth()],
53
+ padding: .08
54
+ }), N = Math.max(1, Math.ceil(56 / A.step())), P = Math.max(1, Math.floor(A.step() * N / 12) - 1), F = l.map((e, t) => ({
55
+ id: e.id,
56
+ label: e.label,
57
+ tone: n(e.tone, t)
58
+ }));
59
+ return /* @__PURE__ */ T(c, {
60
+ title: e,
61
+ description: t,
62
+ children: [
63
+ /* @__PURE__ */ w(a, { items: F }),
64
+ /* @__PURE__ */ w("div", {
65
+ ref: y,
66
+ ..._.props(i.plot, ee.plot),
67
+ children: o.length === 0 || l.length === 0 ? /* @__PURE__ */ w("p", {
68
+ className: "x153jb6y x1ghz6dp xy8obcc",
69
+ children: "No categories"
70
+ }) : /* @__PURE__ */ T("svg", {
71
+ role: "img",
72
+ "aria-label": e,
73
+ viewBox: `0 0 ${b} ${g}`,
74
+ height: g,
75
+ ..._.props(i.svg),
76
+ children: [S.ticks(3).map((e) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
77
+ x1: C,
78
+ x2: O,
79
+ y1: S(e),
80
+ y2: S(e),
81
+ ..._.props(i.grid)
82
+ }), /* @__PURE__ */ w("text", {
83
+ x: C - 8,
84
+ y: S(e),
85
+ textAnchor: "end",
86
+ dominantBaseline: "middle",
87
+ ..._.props(i.label),
88
+ children: m(e)
89
+ })] }, e)), o.map((e, t) => /* @__PURE__ */ T("g", { children: [l.map((r, a) => {
90
+ let o = r.values[t];
91
+ if (o == null) return null;
92
+ let c = d === "stacked" ? l.slice(0, a).reduce((e, n) => e + (n.values[t] ?? 0), 0) : 0, u = S(c), f = S(c + o);
93
+ return /* @__PURE__ */ w(k, {
94
+ x: (A(e.id) ?? C) + (d === "stacked" ? 0 : M(r.id) ?? 0),
95
+ y: Math.min(u, f),
96
+ width: d === "stacked" ? A.bandwidth() : M.bandwidth(),
97
+ height: Math.max(+(o === 0), Math.abs(f - u)),
98
+ fill: s[n(r.tone, a)],
99
+ ..._.props(h?.selectedId === e.id && i.selected),
100
+ children: /* @__PURE__ */ T("title", { children: [
101
+ e.label,
102
+ " · ",
103
+ r.label,
104
+ ": ",
105
+ m(o)
106
+ ] })
107
+ }, r.id);
108
+ }), t % N === 0 && /* @__PURE__ */ w("text", {
109
+ x: (A(e.id) ?? C) + A.bandwidth() / 2,
110
+ y: g - 4,
111
+ textAnchor: "middle",
112
+ ..._.props(i.label),
113
+ children: e.label.length > P ? `${e.label.slice(0, P)}…` : e.label
114
+ })] }, e.id))]
115
+ })
116
+ }),
117
+ /* @__PURE__ */ w(r, {
118
+ items: o.map((e, t) => ({
119
+ id: e.id,
120
+ label: e.label,
121
+ valueLabel: l.map((e) => `${e.label}: ${e.values[t] === null || e.values[t] === void 0 ? "Unavailable" : m(e.values[t])}`).join(" · "),
122
+ tone: "neutral"
123
+ })),
124
+ selection: h
125
+ })
126
+ ]
127
+ });
128
+ }
129
+ // packages/charts/src/cartesian/breakdown-bar.tsx
130
+ var N = {
131
+ kzqmXN: "x5lhr3w",
132
+ kZKoxP: "x5yr21d",
133
+ $$css: !0
134
+ }, P = { segment: (e, t) => [
135
+ N,
136
+ {
137
+ kWkggS: t == null ? t : "xl8spv7",
138
+ $$css: !0
139
+ },
140
+ {
141
+ "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(`${e}%`),
142
+ "--x-backgroundColor": t ?? void 0
143
+ }
144
+ ] };
145
+ function F({ title: t, description: i, items: a, total: o, formatValue: l, selection: u }) {
146
+ let d = e(a), p = a.reduce((e, t) => e + (t.value ?? 0), 0), m = 2 ** -52 * Math.max(p, o, 1) * a.length;
147
+ return d === void 0 ? !Number.isFinite(o) || o < 0 || p - o > m ? /* @__PURE__ */ w(f, {
148
+ title: t,
149
+ description: i,
150
+ message: "The total must be finite and at least the sum of recorded values."
151
+ }) : /* @__PURE__ */ w(c, {
152
+ title: t,
153
+ description: i,
154
+ children: a.length === 0 ? /* @__PURE__ */ w("p", {
155
+ className: "x153jb6y x1ghz6dp xy8obcc",
156
+ children: "No values"
157
+ }) : /* @__PURE__ */ T(C, { children: [
158
+ /* @__PURE__ */ w("div", {
159
+ "aria-hidden": !0,
160
+ className: "x78zum5 x170jfvy xb3r6kr x1r7kqkb xmkeg23 x1y0btm7 x1ey3b81 x1jfksii",
161
+ children: a.map((e, t) => e.value === null ? null : /* @__PURE__ */ w("span", { ..._.props(P.segment(o === 0 ? 0 : e.value / o * 100, s[n(e.tone, t)])) }, e.id))
162
+ }),
163
+ /* @__PURE__ */ w(r, {
164
+ items: a.map((e, t) => ({
165
+ id: e.id,
166
+ label: e.label,
167
+ valueLabel: e.value === null ? "Unavailable" : l(e.value),
168
+ tone: n(e.tone, t)
169
+ })),
170
+ selection: u
171
+ }),
172
+ o - p > m && /* @__PURE__ */ T("p", {
173
+ className: "x153jb6y x1ghz6dp xy8obcc",
174
+ children: [
175
+ "Unassigned portion: ",
176
+ l(o - p),
177
+ " of ",
178
+ l(o)
179
+ ]
180
+ })
181
+ ] })
182
+ }) : /* @__PURE__ */ w(f, {
183
+ title: t,
184
+ description: i,
185
+ message: d
186
+ });
187
+ }
188
+ // packages/charts/src/cartesian/scatter-plot.tsx
189
+ var I = 260, L = 56, R = 20, z = 12, B = 1e3, V = {
190
+ kzqmXN: "x1xc55vz",
191
+ kZKoxP: "xdk7pt",
192
+ kaIpWk: "x16rqkct",
193
+ $$css: !0
194
+ }, H = {
195
+ brush: {
196
+ kFalU9: "xx69xxh",
197
+ kkrTdU: "xsid9ct",
198
+ $$css: !0
199
+ },
200
+ target: {
201
+ kVAEAm: "x10l6tqk",
202
+ k1xSpc: "xrvj5dj",
203
+ kgQiWS: "x1ku5rj1",
204
+ kzqmXN: "x187nhsf",
205
+ kZKoxP: "xn3w4p2",
206
+ k3aq6I: "x11lhmoz",
207
+ kMzoRj: "xc342km",
208
+ kmVPX3: "x1717udv",
209
+ kWkggS: "xjbqb8w",
210
+ kkrTdU: "x1ypdohk",
211
+ kfzvcC: "x67bb7w",
212
+ kPJHz1: "x13qnu6",
213
+ kZs9gx: "x19rmrnh",
214
+ k7shQP: "x9v5kkp",
215
+ kiEn40: "x175ew0f",
216
+ kguI0P: "xisywhd",
217
+ kUjPgX: "xakijqq",
218
+ kFU1ZQ: "xzbfamy",
219
+ kRG58y: "x1cdmj33",
220
+ $$css: !0
221
+ },
222
+ location: (e, t) => [{
223
+ kbCHJM: e == null ? e : "xgq9j65",
224
+ k87sOh: t == null ? t : "xjbys53",
225
+ $$css: !0
226
+ }, {
227
+ "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
228
+ "--x-top": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
229
+ }],
230
+ dot: (e) => [
231
+ V,
232
+ {
233
+ kWkggS: e == null ? e : "xl8spv7",
234
+ $$css: !0
235
+ },
236
+ { "--x-backgroundColor": e ?? void 0 }
237
+ ],
238
+ selected: {
239
+ kMeerF: "x12ei19c",
240
+ kjBf7l: "xj5pgkc",
241
+ k3XXqK: "xaatb59",
242
+ kInvED: "x1ewu8gn",
243
+ $$css: !0
244
+ }
245
+ };
246
+ function U(e) {
247
+ let { title: t, description: n, points: r, xDomain: i, yDomain: a, xLabel: u, yLabel: d, formatX: m, formatY: h, selection: g, rangeSelection: v, emptyLabel: y } = e, { ref: b, width: x } = p(), S = K(e);
248
+ if (S !== null) return /* @__PURE__ */ w(f, {
249
+ title: t,
250
+ description: n,
251
+ message: S
252
+ });
253
+ let C = D({
254
+ domain: [...i],
255
+ range: [L, Math.max(L, x - R)]
256
+ }), E = D({
257
+ domain: [...a],
258
+ range: [216, z]
259
+ });
260
+ return /* @__PURE__ */ T(c, {
261
+ title: t,
262
+ description: n,
263
+ children: [
264
+ r.length === 0 ? /* @__PURE__ */ w("p", {
265
+ className: "x1ghz6dp x153jb6y",
266
+ children: y
267
+ }) : /* @__PURE__ */ T("div", {
268
+ ref: b,
269
+ className: "x1n2onr6 xeuugli",
270
+ children: [/* @__PURE__ */ w(W, {
271
+ width: x,
272
+ scaleX: C,
273
+ scaleY: E,
274
+ ...e
275
+ }, `${i[0]}:${i[1]}:${a[0]}:${a[1]}:${x}`), g !== void 0 && /* @__PURE__ */ w("div", {
276
+ className: "x10l6tqk x10a8y8t x1n71m9f x47corl",
277
+ children: r.map((e) => /* @__PURE__ */ w("button", {
278
+ type: "button",
279
+ title: e.label,
280
+ "aria-label": `${e.label}, ${u}: ${m(e.x)}, ${d}: ${h(e.y)}`,
281
+ "aria-pressed": g.selectedId === e.id,
282
+ onClick: () => g.onSelect(e.id),
283
+ ..._.props(H.target, H.location(C(e.x), E(e.y))),
284
+ children: /* @__PURE__ */ w("span", {
285
+ "aria-hidden": !0,
286
+ ..._.props(H.dot(s[e.tone]), g.selectedId === e.id && H.selected)
287
+ })
288
+ }, e.id))
289
+ })]
290
+ }),
291
+ v !== void 0 && /* @__PURE__ */ w(G, {
292
+ ...e,
293
+ rangeSelection: v
294
+ }),
295
+ r.length > 0 && /* @__PURE__ */ w(l, { children: r.map((e) => /* @__PURE__ */ T(o, {
296
+ label: `${e.label}, ${u}: ${m(e.x)}, ${d}: ${h(e.y)}`,
297
+ selected: g?.selectedId === e.id,
298
+ onSelect: g === void 0 ? void 0 : () => g.onSelect(e.id),
299
+ children: [/* @__PURE__ */ w("span", { children: e.label }), /* @__PURE__ */ T("span", {
300
+ className: "xss6m8b xuxw1ft x153jb6y",
301
+ children: [
302
+ m(e.x),
303
+ " · ",
304
+ h(e.y)
305
+ ]
306
+ })]
307
+ }, e.id)) })
308
+ ]
309
+ });
310
+ }
311
+ function W({ width: e, scaleX: t, scaleY: n, points: r, xLabel: a, yLabel: o, formatX: c, formatY: l, selection: u, rangeSelection: d }) {
312
+ let f = y(), [p, m] = S(null), h = p === null ? d?.value : {
313
+ x: [Math.min(p.start.x, p.end.x), Math.max(p.start.x, p.end.x)],
314
+ y: [Math.min(p.start.y, p.end.y), Math.max(p.start.y, p.end.y)]
315
+ };
316
+ function g(r) {
317
+ let i = r.currentTarget.getBoundingClientRect();
318
+ return {
319
+ x: t.copy().clamp(!0).invert((r.clientX - i.left) / i.width * e),
320
+ y: n.copy().clamp(!0).invert((r.clientY - i.top) / i.height * I)
321
+ };
322
+ }
323
+ function v(t) {
324
+ if (d === void 0 || t.button !== 0 || t.pointerType === "touch") return;
325
+ let n = t.currentTarget.getBoundingClientRect(), r = (t.clientX - n.left) / n.width * e, i = (t.clientY - n.top) / n.height * I;
326
+ if (r < L || r > e - R || i < z || i > 216) return;
327
+ let a = g(t);
328
+ t.currentTarget.setPointerCapture(t.pointerId), m({
329
+ start: a,
330
+ end: a,
331
+ pointerId: t.pointerId
332
+ });
333
+ }
334
+ function b(e) {
335
+ p !== null && p.pointerId === e.pointerId && m({
336
+ ...p,
337
+ end: g(e)
338
+ });
339
+ }
340
+ function x(e) {
341
+ if (p === null || p.pointerId !== e.pointerId) return;
342
+ let t = g(e), n = {
343
+ x: [Math.min(p.start.x, t.x), Math.max(p.start.x, t.x)],
344
+ y: [Math.min(p.start.y, t.y), Math.max(p.start.y, t.y)]
345
+ };
346
+ m(null), e.currentTarget.releasePointerCapture(e.pointerId), d?.onChange(n);
347
+ }
348
+ return /* @__PURE__ */ T("svg", {
349
+ width: e,
350
+ height: I,
351
+ viewBox: `0 0 ${e} ${I}`,
352
+ "aria-hidden": !0,
353
+ onPointerDown: v,
354
+ onPointerMove: b,
355
+ onPointerUp: x,
356
+ onPointerCancel: () => m(null),
357
+ onLostPointerCapture: () => m(null),
358
+ ..._.props(i.svg, d !== void 0 && H.brush),
359
+ children: [
360
+ /* @__PURE__ */ w("defs", { children: /* @__PURE__ */ w("clipPath", {
361
+ id: f,
362
+ children: /* @__PURE__ */ w("rect", {
363
+ x: L,
364
+ y: z,
365
+ width: Math.max(0, e - L - R),
366
+ height: 204
367
+ })
368
+ }) }),
369
+ t.ticks(5).map((e) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
370
+ x1: t(e),
371
+ x2: t(e),
372
+ y1: z,
373
+ y2: 216,
374
+ ..._.props(i.grid)
375
+ }), /* @__PURE__ */ w("text", {
376
+ x: t(e),
377
+ y: 234,
378
+ textAnchor: "middle",
379
+ ..._.props(i.label),
380
+ children: c(e)
381
+ })] }, e)),
382
+ n.ticks(4).map((t) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
383
+ x1: L,
384
+ x2: e - R,
385
+ y1: n(t),
386
+ y2: n(t),
387
+ ..._.props(i.grid)
388
+ }), /* @__PURE__ */ w("text", {
389
+ x: 48,
390
+ y: n(t) + 4,
391
+ textAnchor: "end",
392
+ ..._.props(i.label),
393
+ children: l(t)
394
+ })] }, t)),
395
+ /* @__PURE__ */ w("text", {
396
+ x: (L + e - R) / 2,
397
+ y: 256,
398
+ textAnchor: "middle",
399
+ ..._.props(i.label),
400
+ children: a
401
+ }),
402
+ /* @__PURE__ */ w("text", {
403
+ x: 12,
404
+ y: 108,
405
+ textAnchor: "middle",
406
+ transform: "rotate(-90 12 108)",
407
+ ..._.props(i.label),
408
+ children: o
409
+ }),
410
+ /* @__PURE__ */ T("g", {
411
+ clipPath: `url(#${f})`,
412
+ children: [h != null && /* @__PURE__ */ w("rect", {
413
+ x: t(h.x[0]),
414
+ y: n(h.y[1]),
415
+ width: t(h.x[1]) - t(h.x[0]),
416
+ height: n(h.y[0]) - n(h.y[1]),
417
+ className: "x1e0kj8g xv7c1pl x1tg5nk6 xnpr05h x15lqr97 x47corl"
418
+ }), u === void 0 && r.map((e) => /* @__PURE__ */ w("circle", {
419
+ cx: t(e.x),
420
+ cy: n(e.y),
421
+ r: 4,
422
+ fill: s[e.tone]
423
+ }, e.id))]
424
+ })
425
+ ]
426
+ });
427
+ }
428
+ function G({ rangeSelection: e, xDomain: t, yDomain: n, xLabel: r, yLabel: i, formatX: a, formatY: o }) {
429
+ let s = e.value ?? {
430
+ x: t,
431
+ y: n
432
+ };
433
+ return /* @__PURE__ */ T("fieldset", {
434
+ className: "xrvj5dj x1n8ia3y x1xxf3xd xc342km x1717udv xeuugli",
435
+ children: [
436
+ /* @__PURE__ */ w("legend", {
437
+ className: "x153jb6y xy8obcc x1jfksii",
438
+ children: "Drag with a mouse, or adjust these bounds to select a coordinate range."
439
+ }),
440
+ /* @__PURE__ */ T(h.Root, {
441
+ value: s.x,
442
+ min: t[0],
443
+ max: t[1],
444
+ step: e.xStep,
445
+ locale: e.locale,
446
+ thumbCollisionBehavior: "none",
447
+ onValueChange: (t) => e.onChange({
448
+ x: t,
449
+ y: s.y
450
+ }),
451
+ children: [/* @__PURE__ */ T("div", {
452
+ className: "x78zum5 x1qughib x1hnptsi x153jb6y xy8obcc",
453
+ children: [/* @__PURE__ */ w(h.Label, { children: r }), /* @__PURE__ */ T("span", { children: [
454
+ a(s.x[0]),
455
+ " – ",
456
+ a(s.x[1])
457
+ ] })]
458
+ }), /* @__PURE__ */ w(h.Control, { children: /* @__PURE__ */ T(h.Track, { children: [
459
+ /* @__PURE__ */ w(h.Indicator, {}),
460
+ /* @__PURE__ */ w(h.Thumb, {
461
+ index: 0,
462
+ "aria-label": `${r} minimum`,
463
+ getAriaValueText: (e, t) => a(t)
464
+ }),
465
+ /* @__PURE__ */ w(h.Thumb, {
466
+ index: 1,
467
+ "aria-label": `${r} maximum`,
468
+ getAriaValueText: (e, t) => a(t)
469
+ })
470
+ ] }) })]
471
+ }),
472
+ /* @__PURE__ */ T(h.Root, {
473
+ value: s.y,
474
+ min: n[0],
475
+ max: n[1],
476
+ step: e.yStep,
477
+ locale: e.locale,
478
+ thumbCollisionBehavior: "none",
479
+ onValueChange: (t) => e.onChange({
480
+ x: s.x,
481
+ y: t
482
+ }),
483
+ children: [/* @__PURE__ */ T("div", {
484
+ className: "x78zum5 x1qughib x1hnptsi x153jb6y xy8obcc",
485
+ children: [/* @__PURE__ */ w(h.Label, { children: i }), /* @__PURE__ */ T("span", { children: [
486
+ o(s.y[0]),
487
+ " – ",
488
+ o(s.y[1])
489
+ ] })]
490
+ }), /* @__PURE__ */ w(h.Control, { children: /* @__PURE__ */ T(h.Track, { children: [
491
+ /* @__PURE__ */ w(h.Indicator, {}),
492
+ /* @__PURE__ */ w(h.Thumb, {
493
+ index: 0,
494
+ "aria-label": `${i} minimum`,
495
+ getAriaValueText: (e, t) => o(t)
496
+ }),
497
+ /* @__PURE__ */ w(h.Thumb, {
498
+ index: 1,
499
+ "aria-label": `${i} maximum`,
500
+ getAriaValueText: (e, t) => o(t)
501
+ })
502
+ ] }) })]
503
+ }),
504
+ /* @__PURE__ */ w(m, {
505
+ type: "button",
506
+ disabled: e.value === null,
507
+ onClick: () => e.onChange(null),
508
+ children: "Clear range"
509
+ })
510
+ ]
511
+ });
512
+ }
513
+ function K({ points: e, xDomain: t, yDomain: n, rangeSelection: r }) {
514
+ if (!d(t) || !d(n)) return "Scatter domains must contain finite, increasing endpoints.";
515
+ if (e.length > 1e3) return `This plot exceeds the ${B}-point render limit. Supply a smaller, labelled sample.`;
516
+ if (!u(e)) return "Scatter points must have unique identifiers.";
517
+ if (e.some((e) => !Number.isFinite(e.x) || !Number.isFinite(e.y))) return "Scatter coordinates must be finite.";
518
+ if (e.some((e) => {
519
+ let r = e.x < t[0] || e.x > t[1], i = e.y < n[0] || e.y > n[1];
520
+ return r || i;
521
+ })) return "Scatter coordinates fall outside the declared domain. Widen the domain or supply a labelled window of points.";
522
+ if (r === void 0) return null;
523
+ let i = Number.isFinite(r.xStep) && r.xStep > 0 && r.xStep <= t[1] - t[0], a = Number.isFinite(r.yStep) && r.yStep > 0 && r.yStep <= n[1] - n[0];
524
+ if (!i || !a) return "Range selection steps must be finite, positive, and no larger than their domain span.";
525
+ let o = r.value;
526
+ return o === null ? null : !q(o.x, t) || !q(o.y, n) ? "The selected range must have finite, ordered bounds inside the declared domain." : null;
527
+ }
528
+ function q(e, t) {
529
+ return !e.every(Number.isFinite) || e[0] > e[1] ? !1 : e[0] >= t[0] && e[1] <= t[1];
530
+ }
531
+ // packages/charts/src/cartesian/time-series-data.ts
532
+ var J = {
533
+ series: 12,
534
+ pointsPerSeries: 2e3,
535
+ markers: 200,
536
+ panels: 12
537
+ }, te = .01, ne = [
538
+ "series1",
539
+ "series2",
540
+ "series3",
541
+ "series4",
542
+ "series5",
543
+ "series6"
544
+ ];
545
+ function re({ series: e, isStacked: t, markers: n }) {
546
+ let r = e[0]?.points.map((e) => e.timestamp) ?? [];
547
+ if (e.length > J.series || r.length > J.pointsPerSeries || n.length > J.markers) return `Choose a window with at most ${J.series} series, ${J.pointsPerSeries} observations per series, and ${J.markers} markers.`;
548
+ if (!u(e) || !u(n)) return "Series and markers require unique identifiers.";
549
+ for (let n of e) {
550
+ if (n.points.length !== r.length) return "Every series must supply the same observation timestamps.";
551
+ let e = se({
552
+ points: n.points,
553
+ timestamps: r,
554
+ isStacked: t
555
+ });
556
+ if (e !== void 0) return e;
557
+ }
558
+ for (let t of n) {
559
+ if (!r.includes(t.timestamp)) return "Every marker must align with an observation timestamp.";
560
+ if (t.kind === "point") {
561
+ let n = e.find((e) => e.id === t.seriesId)?.points.find((e) => e.timestamp === t.timestamp);
562
+ if (n === void 0 || n.value !== t.value) return "Point markers must reference the recorded series value.";
563
+ }
564
+ }
565
+ let i = e.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value])), a = Math.max(0, ...i) - Math.min(0, ...i), o = (r.at(-1) ?? 0) - (r[0] ?? 0);
566
+ if (!Number.isFinite(a) || !Number.isFinite(o)) return "The elapsed-time and value ranges must be finite.";
567
+ if (t && r.some((t, n) => !Number.isFinite(e.reduce((e, t) => e + (t.points[n]?.value ?? 0), 0)))) return "Stacked observation totals must be finite.";
568
+ }
569
+ function ie({ series: e, markers: t, timestampUnit: n, isStacked: r }) {
570
+ return JSON.stringify([
571
+ n,
572
+ r,
573
+ e.map((e) => [
574
+ e.id,
575
+ e.label,
576
+ e.tone,
577
+ e.points.map((e) => [e.timestamp, e.value])
578
+ ]),
579
+ t.map((e) => [
580
+ e.id,
581
+ e.kind,
582
+ e.timestamp,
583
+ e.label,
584
+ e.seriesId,
585
+ e.value
586
+ ])
587
+ ]);
588
+ }
589
+ function ae(e, t, n = !1) {
590
+ if (e !== t) return [e, t];
591
+ let r = Math.max(1, Math.abs(e) * te), i = n ? 0 : e - r, a = t + r;
592
+ return [Number.isFinite(i) ? i : e, Number.isFinite(a) ? a : t];
593
+ }
594
+ function oe(e, t) {
595
+ let n = e.filter((e) => e.tone === void 0);
596
+ return e.map((r, i) => {
597
+ let a = n.findIndex((e) => e.id === r.id), o = r.tone ?? ne[a % ne.length] ?? "series1", s = r.points.map((n, r) => {
598
+ let a = t ? e.slice(0, i).reduce((e, t) => e + (t.points[r]?.value ?? 0), 0) : 0;
599
+ return {
600
+ ...n,
601
+ base: a
602
+ };
603
+ });
604
+ return {
605
+ id: r.id,
606
+ label: r.label,
607
+ tone: o,
608
+ points: s
609
+ };
610
+ });
611
+ }
612
+ function se({ points: e, timestamps: t, isStacked: n }) {
613
+ for (let [r, i] of e.entries()) {
614
+ let a = e[r - 1], o = a !== void 0 && i.timestamp <= a.timestamp;
615
+ if (!Number.isFinite(i.timestamp) || i.timestamp !== t[r] || o) return "Observation timestamps must be finite, aligned, and strictly increasing.";
616
+ if (i.value !== null && !Number.isFinite(i.value)) return "Observations must be finite numbers or explicit missing values.";
617
+ if (n && (i.value === null || i.value < 0)) return "Stacked observations must be present and nonnegative.";
618
+ }
619
+ }
620
+ // packages/charts/src/cartesian/time-series-line.tsx
621
+ function ce({ series: e, x: t, y: n, inspectedTimestamp: r, pointRadius: a = 3 }) {
622
+ return /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(A, {
623
+ data: [...e.points],
624
+ defined: (e) => e.value !== null,
625
+ x: (e) => t(e.timestamp),
626
+ y: (e) => n((e.value ?? 0) + e.base),
627
+ stroke: s[e.tone],
628
+ ..._.props(i.mark)
629
+ }), e.points.filter((t, n) => {
630
+ if (t.value === null) return !1;
631
+ let i = e.points[n - 1]?.value === null || e.points[n + 1]?.value === null;
632
+ return e.points.length === 1 || i || t.timestamp === r;
633
+ }).map((r) => /* @__PURE__ */ w("circle", {
634
+ cx: t(r.timestamp),
635
+ cy: n((r.value ?? 0) + r.base),
636
+ r: a,
637
+ fill: s[e.tone]
638
+ }, r.timestamp))] });
639
+ }
640
+ // packages/charts/src/cartesian/sparkline.tsx
641
+ function Y({ title: e, summary: t, unit: n, timestampUnit: r, series: i, valueDomain: a }) {
642
+ let o = y(), s = y(), c = le({
643
+ title: e,
644
+ summary: t,
645
+ unit: n,
646
+ series: i,
647
+ valueDomain: a
648
+ }), l = i.points.some((e) => e.value !== null);
649
+ if (c !== void 0 || !l) return /* @__PURE__ */ w("span", {
650
+ role: "img",
651
+ "aria-label": `${e}. ${c ?? "No recorded values. Missing observations remain unavailable."}`,
652
+ title: c ?? "No recorded values",
653
+ className: "x2pejg6 x10w6t97 x2lah0s xxymvpz x3nfvp2 x6s0dn4 xl56j7k x153jb6y x1hz01jw xy8obcc",
654
+ children: c === void 0 ? "No data" : "Invalid trend"
655
+ });
656
+ let u = i.points[0]?.timestamp ?? 0, d = i.points.at(-1)?.timestamp ?? u, f = D({
657
+ domain: [...ae(u, d)],
658
+ range: [3, 125]
659
+ }), p = D({
660
+ domain: [...a],
661
+ range: [29, 3]
662
+ }), m = oe([i], !1)[0];
663
+ return /* @__PURE__ */ T("svg", {
664
+ role: "img",
665
+ "aria-labelledby": o,
666
+ "aria-describedby": s,
667
+ focusable: "false",
668
+ viewBox: "0 0 128 32",
669
+ width: 128,
670
+ height: 32,
671
+ className: "x1rg5ohu x2pejg6 x10w6t97 x2lah0s xxymvpz",
672
+ children: [
673
+ /* @__PURE__ */ w("title", {
674
+ id: o,
675
+ children: e
676
+ }),
677
+ /* @__PURE__ */ T("desc", {
678
+ id: s,
679
+ children: [
680
+ t,
681
+ " Values in ",
682
+ n,
683
+ "; timestamps in ",
684
+ r,
685
+ ". Displayed value domain: ",
686
+ a[0],
687
+ " to",
688
+ " ",
689
+ a[1],
690
+ " ",
691
+ n,
692
+ "."
693
+ ]
694
+ }),
695
+ m !== void 0 && /* @__PURE__ */ w(ce, {
696
+ series: m,
697
+ x: f,
698
+ y: p,
699
+ pointRadius: 2
700
+ })
701
+ ]
702
+ });
703
+ }
704
+ function le({ title: e, summary: t, unit: n, series: r, valueDomain: i }) {
705
+ if (e.trim() === "" || t.trim() === "" || n.trim() === "") return "A trend requires a title, a readable summary, and a value unit.";
706
+ if (!d(i)) return "The displayed value domain must have finite, increasing bounds.";
707
+ let a = re({
708
+ series: [r],
709
+ isStacked: !1,
710
+ markers: []
711
+ });
712
+ if (a !== void 0) return a;
713
+ if (r.points.some((e) => e.value !== null && (e.value < i[0] || e.value > i[1]))) return "Every recorded value must be inside the declared value domain.";
714
+ }
715
+ // packages/charts/src/cartesian/time-series.tsx
716
+ var ue = { plot: {
717
+ k7Eaqz: "xeuugli",
718
+ kInvED: "x1hl8ikr",
719
+ kZs9gx: "x19rmrnh",
720
+ k7shQP: "x9v5kkp",
721
+ kPJHz1: "x13qnu6",
722
+ $$css: !0
723
+ } };
724
+ function X(e) {
725
+ return /* @__PURE__ */ w($, {
726
+ ...e,
727
+ kind: "line",
728
+ stacked: !1
729
+ });
730
+ }
731
+ function Z({ stacked: e = !1, ...t }) {
732
+ return /* @__PURE__ */ w($, {
733
+ ...t,
734
+ kind: "area",
735
+ stacked: e
736
+ });
737
+ }
738
+ function Q({ charts: e, ...t }) {
739
+ let n = x(null), [r, i] = S(), a = JSON.stringify(e.map((e) => [
740
+ e.id,
741
+ e.title,
742
+ ie({
743
+ series: e.series,
744
+ markers: e.markers ?? [],
745
+ timestampUnit: t.timestampUnit,
746
+ isStacked: !1
747
+ })
748
+ ])), o = JSON.stringify(e[0]?.series[0]?.points.map((e) => e.timestamp) ?? []), s = e.every((e) => JSON.stringify(e.series[0]?.points.map((e) => e.timestamp) ?? []) === o);
749
+ if (r !== void 0 && r.signature !== a && i(void 0), v(() => {
750
+ function e(e) {
751
+ e.target instanceof Node && n.current?.contains(e.target) !== !0 && i(void 0);
752
+ }
753
+ return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
754
+ }, []), !s || !u(e)) return /* @__PURE__ */ w(f, {
755
+ title: "Small multiples",
756
+ message: "Charts need unique identifiers and aligned observation timestamps."
757
+ });
758
+ if (e.length > J.panels) return /* @__PURE__ */ w(f, {
759
+ title: "Small multiples",
760
+ message: `Choose at most ${J.panels} panels.`
761
+ });
762
+ if (e.length === 0) return /* @__PURE__ */ w(c, {
763
+ title: "Small multiples",
764
+ children: /* @__PURE__ */ w("p", {
765
+ className: "x153jb6y",
766
+ children: "No charts"
767
+ })
768
+ });
769
+ let l = {
770
+ value: r?.signature === a ? r : void 0,
771
+ onChange: (e) => i(e === void 0 ? void 0 : {
772
+ ...e,
773
+ signature: a
774
+ })
775
+ }, d = Math.max(52, ...e.flatMap((e) => e.series.flatMap((t) => t.points.flatMap((t) => t.value === null || !Number.isFinite(t.value) ? [] : [e.formatValue(t.value).length * 7 + 12]))));
776
+ return /* @__PURE__ */ w("div", {
777
+ ref: n,
778
+ className: "xrvj5dj x1j825kq",
779
+ children: e.map((e) => /* @__PURE__ */ w($, {
780
+ ...t,
781
+ title: e.title,
782
+ description: e.description,
783
+ series: e.series,
784
+ formatValue: e.formatValue,
785
+ markers: e.markers,
786
+ kind: "line",
787
+ stacked: !1,
788
+ sharedInspection: l,
789
+ axisWidth: d
790
+ }, e.id))
791
+ });
792
+ }
793
+ function $({ title: e, description: t, series: n, timestampUnit: r, formatTimestamp: o, formatValue: u, markers: d = [], height: m = 180, actions: h, kind: E, stacked: k, sharedInspection: A, axisWidth: ee }) {
794
+ let j = !Number.isFinite(m) || m < 48 ? "Chart height must be at least 48 pixels." : re({
795
+ series: n,
796
+ isStacked: k,
797
+ markers: d
798
+ }), M = b(() => j === void 0 ? oe(n, k) : [], [
799
+ n,
800
+ k,
801
+ j
802
+ ]), N = M[0]?.points ?? [], { ref: P, width: F, element: I } = p(), L = x(null), [R, z] = S(), B = ie({
803
+ series: n,
804
+ markers: d,
805
+ timestampUnit: r,
806
+ isStacked: k
807
+ }), V = A === void 0 ? R?.signature === B ? R : void 0 : A.value, H = y();
808
+ R !== void 0 && (R.signature !== B || j !== void 0) && z(void 0);
809
+ let U = A !== void 0;
810
+ if (v(() => {
811
+ if (U) return;
812
+ function e(e) {
813
+ e.target instanceof Node && L.current?.contains(e.target) !== !0 && z(void 0);
814
+ }
815
+ return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
816
+ }, [U]), j !== void 0) return /* @__PURE__ */ w(f, {
817
+ title: e,
818
+ description: t,
819
+ message: j
820
+ });
821
+ if (N.length === 0) return /* @__PURE__ */ w(c, {
822
+ title: e,
823
+ description: t,
824
+ actions: h,
825
+ children: /* @__PURE__ */ w("p", {
826
+ className: "x153jb6y",
827
+ children: "No observations"
828
+ })
829
+ });
830
+ let W = m - 28, G = N[0]?.timestamp ?? 0, K = N.at(-1)?.timestamp ?? G, q = M.flatMap((e) => e.points.flatMap((e) => e.value === null ? [] : [e.value + e.base])), J = E === "area" ? Math.min(0, ...q) : Math.min(...q), te = E === "area" ? Math.max(0, ...q) : Math.max(...q), ne = q.length === 0 ? 0 : J, se = q.length === 0 ? 1 : te, Y = D({
831
+ domain: [...ae(ne, se, E === "area")],
832
+ range: [W, 12]
833
+ }), le = Y.ticks(3), X = ee ?? Math.max(52, ...le.map((e) => u(e).length * 7 + 12)), Z = Math.max(X + 1, F - 16), Q = D({
834
+ domain: [...ae(G, K)],
835
+ range: [X, Z]
836
+ });
837
+ function $(e) {
838
+ let t = I?.getBoundingClientRect();
839
+ if (t === void 0) return;
840
+ let n = Q.invert(e - t.left), r = N.find((e, t) => {
841
+ let r = N[t + 1];
842
+ return r === void 0 || n <= e.timestamp + (r.timestamp - e.timestamp) / 2;
843
+ });
844
+ r !== void 0 && de({
845
+ signature: B,
846
+ timestamp: r.timestamp,
847
+ source: "pointer"
848
+ });
849
+ }
850
+ function de(e) {
851
+ A === void 0 ? z(e) : A.onChange(e);
852
+ }
853
+ function fe(e) {
854
+ let t = N.findIndex((e) => e.timestamp === V?.timestamp), n = {
855
+ ArrowRight: Math.min(N.length - 1, t + 1),
856
+ ArrowLeft: Math.max(0, t - 1),
857
+ Home: 0,
858
+ End: N.length - 1
859
+ };
860
+ switch (e.key) {
861
+ case "Escape":
862
+ e.preventDefault(), de(void 0);
863
+ break;
864
+ case "ArrowRight":
865
+ case "ArrowLeft":
866
+ case "Home":
867
+ case "End": {
868
+ e.preventDefault();
869
+ let t = N[n[e.key]];
870
+ t !== void 0 && de({
871
+ signature: B,
872
+ timestamp: t.timestamp,
873
+ source: "keyboard"
874
+ });
875
+ break;
876
+ }
877
+ }
878
+ }
879
+ return /* @__PURE__ */ w("div", {
880
+ ref: L,
881
+ className: "xeuugli",
882
+ children: /* @__PURE__ */ T(c, {
883
+ title: e,
884
+ description: t,
885
+ actions: h,
886
+ children: [/* @__PURE__ */ T("div", {
887
+ className: "xrvj5dj x1n8ia3y",
888
+ children: [
889
+ /* @__PURE__ */ w(a, { items: M.map(({ id: e, label: t, tone: n }) => ({
890
+ id: e,
891
+ label: t,
892
+ tone: n
893
+ })) }),
894
+ /* @__PURE__ */ w("div", {
895
+ ref: P,
896
+ ..._.props(i.plot),
897
+ children: /* @__PURE__ */ T("svg", {
898
+ role: "img",
899
+ "aria-label": `${e}. Use arrow keys to inspect observations.`,
900
+ "aria-describedby": H,
901
+ tabIndex: 0,
902
+ viewBox: `0 0 ${F} ${m}`,
903
+ height: m,
904
+ onKeyDown: fe,
905
+ onPointerMove: (e) => {
906
+ e.pointerType === "mouse" && $(e.clientX);
907
+ },
908
+ onPointerDown: (e) => $(e.clientX),
909
+ ..._.props(i.svg, ue.plot),
910
+ children: [
911
+ le.map((e) => /* @__PURE__ */ T("g", { children: [/* @__PURE__ */ w("line", {
912
+ x1: X,
913
+ x2: Z,
914
+ y1: Y(e),
915
+ y2: Y(e),
916
+ ..._.props(i.grid)
917
+ }), /* @__PURE__ */ w("text", {
918
+ x: X - 8,
919
+ y: Y(e),
920
+ textAnchor: "end",
921
+ dominantBaseline: "middle",
922
+ ..._.props(i.label),
923
+ children: u(e)
924
+ })] }, e)),
925
+ M.map((e) => /* @__PURE__ */ T("g", { children: [E === "area" && /* @__PURE__ */ w(O, {
926
+ data: [...e.points],
927
+ defined: (e) => e.value !== null,
928
+ x: (e) => Q(e.timestamp),
929
+ y0: (e) => Y(e.base),
930
+ y1: (e) => Y((e.value ?? 0) + e.base),
931
+ yScale: Y,
932
+ fill: s[e.tone],
933
+ fillOpacity: k ? .65 : .15
934
+ }), /* @__PURE__ */ w(ce, {
935
+ series: e,
936
+ x: Q,
937
+ y: Y,
938
+ inspectedTimestamp: V?.timestamp
939
+ })] }, e.id)),
940
+ d.map((e) => /* @__PURE__ */ T("g", { children: [e.kind === "time" ? /* @__PURE__ */ w("line", {
941
+ x1: Q(e.timestamp),
942
+ x2: Q(e.timestamp),
943
+ y1: 12,
944
+ y2: W,
945
+ className: "xhq4mlf x1ntoi03 x13efnbd"
946
+ }) : /* @__PURE__ */ w("circle", {
947
+ cx: Q(e.timestamp),
948
+ cy: Y(e.value + (M.find((t) => t.id === e.seriesId)?.points.find((t) => t.timestamp === e.timestamp)?.base ?? 0)),
949
+ r: 4,
950
+ fill: g.surface,
951
+ ..._.props(i.selected)
952
+ }), /* @__PURE__ */ w("title", { children: e.kind === "point" ? `${e.label}: ${u(e.value)}` : e.label })] }, e.id)),
953
+ V !== void 0 && /* @__PURE__ */ w("line", {
954
+ x1: Q(V.timestamp),
955
+ x2: Q(V.timestamp),
956
+ y1: 12,
957
+ y2: W,
958
+ className: "xhq4mlf x1ntoi03 x13efnbd"
959
+ }),
960
+ /* @__PURE__ */ w("text", {
961
+ x: X,
962
+ y: m - 4,
963
+ ..._.props(i.label),
964
+ children: o(G)
965
+ }),
966
+ K !== G && /* @__PURE__ */ w("text", {
967
+ x: Z,
968
+ y: m - 4,
969
+ textAnchor: "end",
970
+ ..._.props(i.label),
971
+ children: o(K)
972
+ })
973
+ ]
974
+ })
975
+ }),
976
+ /* @__PURE__ */ w("div", {
977
+ id: H,
978
+ "aria-live": V?.source === "keyboard" ? "polite" : "off",
979
+ className: "x78zum5 x1a02dak x1pha0wt x8zbtdt x1gkm1c7 xy8obcc xas2l8k x1mqbd49",
980
+ children: V === void 0 ? /* @__PURE__ */ w("span", {
981
+ className: "x153jb6y",
982
+ children: "Point, tap, or use the arrow keys to inspect values."
983
+ }) : /* @__PURE__ */ T(C, { children: [
984
+ /* @__PURE__ */ w("span", { children: o(V.timestamp) }),
985
+ /* @__PURE__ */ w("dl", {
986
+ className: "x78zum5 x1a02dak x1n8ia3y x1ghz6dp",
987
+ children: M.map((e) => {
988
+ let t = e.points.find((e) => e.timestamp === V.timestamp);
989
+ return /* @__PURE__ */ T("div", {
990
+ className: "x78zum5 xunmzkg x1ghz6dp xss6m8b",
991
+ children: [/* @__PURE__ */ w("dt", { children: e.label }), /* @__PURE__ */ w("dd", {
992
+ className: "x1ghz6dp xbixft",
993
+ children: t?.value === null || t === void 0 ? "Unavailable" : u(t.value)
994
+ })]
995
+ }, e.id);
996
+ })
997
+ }),
998
+ d.filter((e) => e.timestamp === V.timestamp).map((e) => /* @__PURE__ */ w("span", { children: e.label }, e.id))
999
+ ] })
1000
+ }),
1001
+ d.length > 0 && /* @__PURE__ */ w("ul", {
1002
+ className: "x78zum5 x1a02dak x1n8ia3y x1ghz6dp x1717udv xe8uvvx xy8obcc x153jb6y",
1003
+ children: d.map((e) => /* @__PURE__ */ T("li", { children: [
1004
+ o(e.timestamp),
1005
+ " · ",
1006
+ e.label,
1007
+ e.kind === "point" && ` · ${u(e.value)}`
1008
+ ] }, e.id))
1009
+ })
1010
+ ]
1011
+ }), /* @__PURE__ */ w(l, { children: /* @__PURE__ */ T("table", {
1012
+ className: "xh8yej3 x1mwwwfo xy8obcc x1yc453h xss6m8b",
1013
+ children: [
1014
+ /* @__PURE__ */ T("caption", { children: [e, " observations"] }),
1015
+ /* @__PURE__ */ w("thead", { children: /* @__PURE__ */ T("tr", { children: [/* @__PURE__ */ T("th", {
1016
+ className: "x69ldcm x1yc453h xso031l x1q0q8m5 x1qndepd xo1l8bm",
1017
+ children: [
1018
+ "Time (",
1019
+ r,
1020
+ ")"
1021
+ ]
1022
+ }), M.map((e) => /* @__PURE__ */ w("th", {
1023
+ scope: "col",
1024
+ className: "x69ldcm x1yc453h xso031l x1q0q8m5 x1qndepd xo1l8bm",
1025
+ children: e.label
1026
+ }, e.id))] }) }),
1027
+ /* @__PURE__ */ w("tbody", { children: N.map((e, t) => /* @__PURE__ */ T("tr", { children: [/* @__PURE__ */ w("th", {
1028
+ scope: "row",
1029
+ className: "x69ldcm x1yc453h xso031l x1q0q8m5 x1qndepd xo1l8bm",
1030
+ children: o(e.timestamp)
1031
+ }), M.map((e) => /* @__PURE__ */ w("td", {
1032
+ className: "x69ldcm x1yc453h xso031l x1q0q8m5 x1qndepd xo1l8bm",
1033
+ children: e.points[t]?.value === null || e.points[t]?.value === void 0 ? "Unavailable" : u(e.points[t].value)
1034
+ }, e.id))] }, e.timestamp)) })
1035
+ ]
1036
+ }) })]
1037
+ })
1038
+ });
1039
+ }
1040
+ export { Z as AreaChart, M as BarChart, F as BreakdownBar, X as LineChart, B as MAX_SCATTER_POINTS, U as ScatterPlot, Q as SmallMultiples, Y as Sparkline, J as timeSeriesLimits };