basalt-ui 2.22.0 → 2.23.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.
- package/CHANGELOG.md +27 -0
- package/MIGRATING.md +187 -12
- package/agent/agents/basalt-design-reviewer.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/dist/charts/BandStrip.d.ts.map +1 -1
- package/dist/charts/BandStrip.js +51 -5
- package/dist/charts/Bars.d.ts.map +1 -1
- package/dist/charts/Bars.js +2 -1
- package/dist/charts/CartesianChart.d.ts +2 -0
- package/dist/charts/CartesianChart.d.ts.map +1 -1
- package/dist/charts/ChartCard.d.ts +1 -1
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +25 -15
- package/dist/charts/Sparkline.d.ts +8 -2
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +67 -13
- package/dist/charts/band-fold.d.ts +22 -4
- package/dist/charts/band-fold.d.ts.map +1 -1
- package/dist/charts/band-fold.js +10 -2
- package/dist/charts/chart-dates.d.ts +12 -0
- package/dist/charts/chart-dates.d.ts.map +1 -0
- package/dist/charts/chart-dates.js +16 -0
- package/dist/charts/compile.d.ts +8 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +30 -21
- package/dist/charts/date-tick-format.d.ts +5 -5
- package/dist/charts/date-tick-format.d.ts.map +1 -1
- package/dist/charts/date-tick-format.js +3 -7
- package/dist/charts/labels.d.ts +7 -3
- package/dist/charts/labels.d.ts.map +1 -1
- package/dist/charts/labels.js +28 -17
- package/dist/charts/ref-label.d.ts +17 -0
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +13 -1
- package/dist/charts/sparkline.module.css +8 -11
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +3 -1
- package/dist/charts/types.d.ts +4 -3
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +9 -5
- package/dist/cli/shot/detect.js +8 -5
- package/dist/cli/shot/playwright.d.ts +8 -0
- package/dist/cli/shot/playwright.d.ts.map +1 -1
- package/dist/cli/shot/playwright.js +5 -1
- package/dist/cli/shot/types.d.ts +2 -0
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/tokens-css.d.ts +5 -7
- package/dist/cli/tokens-css.d.ts.map +1 -1
- package/dist/cli/tokens-css.js +11 -12
- package/dist/dashboard/bar-list.d.ts +6 -1
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +8 -0
- package/dist/dashboard/bar-list.module.css +30 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +2 -2
- package/dist/dashboard/meter-model.d.ts +25 -20
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +24 -12
- package/dist/dashboard/meter-parts.d.ts +1 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +39 -4
- package/dist/dashboard/meter.d.ts +14 -8
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +1 -1
- package/dist/dashboard/meter.module.css +15 -0
- package/dist/dashboard/meter.module.css.d.ts +1 -0
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +1 -1
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.module.css +25 -6
- package/dist/dashboard/stat-group.module.css +7 -0
- package/dist/dashboard/stat-strip.d.ts +15 -5
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +50 -34
- package/dist/dashboard/stat-strip.module.css +83 -61
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +0 -5
- package/dist/styles.css +18 -11
- package/dist/theme/controls.module.css +14 -0
- package/dist/theme/controls.module.css.d.ts +1 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +10 -7
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +9 -1
- package/dist/tokens/palette.d.ts +7 -10
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +7 -10
- package/llms.txt +6 -4
- package/package.json +1 -1
- package/src/charts/BandStrip.tsx +55 -5
- package/src/charts/Bars.tsx +2 -1
- package/src/charts/CartesianChart.tsx +2 -0
- package/src/charts/ChartCard.tsx +32 -19
- package/src/charts/Sparkline.tsx +92 -19
- package/src/charts/band-fold.ts +25 -6
- package/src/charts/chart-dates.ts +30 -0
- package/src/charts/compile.ts +64 -23
- package/src/charts/date-tick-format.ts +10 -13
- package/src/charts/labels.ts +43 -22
- package/src/charts/ref-label.ts +27 -0
- package/src/charts/sparkline.module.css +8 -11
- package/src/charts/state.tsx +6 -3
- package/src/charts/types.ts +4 -3
- package/src/cli/shot/capture.ts +15 -3
- package/src/cli/shot/detect.ts +9 -9
- package/src/cli/shot/playwright.ts +18 -2
- package/src/cli/shot/types.ts +2 -0
- package/src/cli/tokens-css.ts +18 -20
- package/src/dashboard/bar-list.module.css +30 -0
- package/src/dashboard/bar-list.tsx +29 -0
- package/src/dashboard/delta-badge.tsx +6 -2
- package/src/dashboard/meter-model.ts +58 -41
- package/src/dashboard/meter-parts.tsx +66 -5
- package/src/dashboard/meter.module.css +15 -0
- package/src/dashboard/meter.module.css.d.ts +1 -0
- package/src/dashboard/meter.tsx +15 -11
- package/src/dashboard/query-state.tsx +1 -1
- package/src/dashboard/stat-card-parts.tsx +1 -1
- package/src/dashboard/stat-card.module.css +25 -6
- package/src/dashboard/stat-group.module.css +7 -0
- package/src/dashboard/stat-strip.module.css +83 -61
- package/src/dashboard/stat-strip.tsx +93 -54
- package/src/guard/index.ts +0 -5
- package/src/styles.css +18 -11
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +14 -8
- package/src/theme/controls.module.css +14 -0
- package/src/theme/controls.module.css.d.ts +1 -0
- package/src/theme/index.ts +10 -7
- package/src/theme/status-verdict.tsx +5 -1
- package/src/tokens/palette.ts +7 -10
package/dist/charts/Sparkline.js
CHANGED
|
@@ -11,7 +11,10 @@ import { cx } from "../common/props.js";
|
|
|
11
11
|
import { VX, alpha } from "../tokens/index.js";
|
|
12
12
|
import { chartCurve } from "./curves.js";
|
|
13
13
|
import { barMark } from "./marks.js";
|
|
14
|
-
import { defaultNumberFormat } from "./compile.js";
|
|
14
|
+
import { bucketDay, dayGranular, defaultNumberFormat } from "./compile.js";
|
|
15
|
+
import { referenceLabelPlacement } from "./ref-label.js";
|
|
16
|
+
import { readoutClock, readoutDay } from "./chart-dates.js";
|
|
17
|
+
import { toDate } from "../format/shared.js";
|
|
15
18
|
import { ChartEngine, idPrefixOf } from "./host.js";
|
|
16
19
|
import classes from "./sparkline.module.css";
|
|
17
20
|
import { ChartPlaceholder, resolveChartState } from "./state.js";
|
|
@@ -19,13 +22,38 @@ import { CHART_THEME, DASH } from "./theme.js";
|
|
|
19
22
|
const LINE_WIDTH = 1.5;
|
|
20
23
|
const DOT_R = 2.5;
|
|
21
24
|
const BAR_GAP = 0.15;
|
|
25
|
+
const READOUT_GAP = 8;
|
|
22
26
|
const LINE_INSET = 3;
|
|
23
27
|
const MUTED_LINE = alpha(VX.muted, 0.35);
|
|
24
|
-
const
|
|
28
|
+
const REFERENCE_LABEL_DX = 3;
|
|
25
29
|
const LINE_PX_PER_POINT = 1;
|
|
26
30
|
const BAR_PX_PER_BAR = 2;
|
|
27
31
|
const LINE_POOL_MIN = 4;
|
|
32
|
+
const DAY_MS = 864e5;
|
|
28
33
|
const finite = (v) => Number.isFinite(v) ? v : null;
|
|
34
|
+
function momentsOf(data) {
|
|
35
|
+
const dates = [];
|
|
36
|
+
for (const d of data) {
|
|
37
|
+
if (typeof d !== "object" || d === null) return void 0;
|
|
38
|
+
dates.push(toDate(d.at));
|
|
39
|
+
}
|
|
40
|
+
const known = dates.filter((d) => d !== null);
|
|
41
|
+
if (known.length === 0) return void 0;
|
|
42
|
+
let lo = Number.POSITIVE_INFINITY;
|
|
43
|
+
let hi = Number.NEGATIVE_INFINITY;
|
|
44
|
+
for (const d of known) {
|
|
45
|
+
const day = Math.floor(d.getTime() / DAY_MS);
|
|
46
|
+
if (day < lo) lo = day;
|
|
47
|
+
if (day > hi) hi = day;
|
|
48
|
+
}
|
|
49
|
+
const oneDay = lo === hi;
|
|
50
|
+
const byDay = dayGranular(known);
|
|
51
|
+
return dates.map((d) => {
|
|
52
|
+
if (d === null) return void 0;
|
|
53
|
+
if (byDay) return readoutDay(bucketDay(d));
|
|
54
|
+
return oneDay ? readoutClock(d) : `${readoutDay(d)} ${readoutClock(d)}`;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
29
57
|
function extent(rows) {
|
|
30
58
|
let lo = Number.POSITIVE_INFINITY;
|
|
31
59
|
let hi = Number.NEGATIVE_INFINITY;
|
|
@@ -102,7 +130,7 @@ function frameOf([lo, hi], mark, count, hasEnd) {
|
|
|
102
130
|
}
|
|
103
131
|
function compileSparkline(source, extentOf, mark, color, emphasisColor, reference, referenceLabel) {
|
|
104
132
|
const frame = frameOf(extentOf, mark, source.length, emphasisColor !== null);
|
|
105
|
-
const referenceMark = () => reference === null ? [] : [
|
|
133
|
+
const referenceMark = (height) => reference === null ? [] : [
|
|
106
134
|
ruleY([reference], {
|
|
107
135
|
id: "reference",
|
|
108
136
|
stroke: VX.line,
|
|
@@ -120,19 +148,29 @@ function compileSparkline(source, extentOf, mark, color, emphasisColor, referenc
|
|
|
120
148
|
fill: VX.ink2,
|
|
121
149
|
fontSize: VX.text.micro,
|
|
122
150
|
anchor: "start",
|
|
123
|
-
|
|
151
|
+
dx: REFERENCE_LABEL_DX,
|
|
152
|
+
dy: referenceLabelPlacement({
|
|
153
|
+
value: reference,
|
|
154
|
+
domain: frame.y,
|
|
155
|
+
height,
|
|
156
|
+
inset: mark === "bar" ? 0 : LINE_INSET,
|
|
157
|
+
fontSize: VX.text.micro
|
|
158
|
+
}).dy
|
|
124
159
|
})
|
|
125
160
|
)
|
|
126
161
|
]
|
|
127
162
|
];
|
|
128
163
|
return {
|
|
129
|
-
|
|
164
|
+
// A bar's hover is the bar and the readout chip: no engine point marker (bar chrome only, as
|
|
165
|
+
// `Bars`).
|
|
166
|
+
...mark === "bar" && { focusRing: false },
|
|
167
|
+
chart: ({ width, height }) => {
|
|
130
168
|
const rows = poolSparkline(source, width, mark);
|
|
131
169
|
const last = rows.at(-1);
|
|
132
170
|
if (mark === "bar") {
|
|
133
171
|
return {
|
|
134
172
|
marks: [
|
|
135
|
-
...referenceMark(),
|
|
173
|
+
...referenceMark(height),
|
|
136
174
|
barMark(rows, {
|
|
137
175
|
id: "bars",
|
|
138
176
|
x: "i",
|
|
@@ -157,7 +195,7 @@ function compileSparkline(source, extentOf, mark, color, emphasisColor, referenc
|
|
|
157
195
|
}
|
|
158
196
|
return {
|
|
159
197
|
marks: [
|
|
160
|
-
...referenceMark(),
|
|
198
|
+
...referenceMark(height),
|
|
161
199
|
lineY(rows, {
|
|
162
200
|
id: "line",
|
|
163
201
|
x: "i",
|
|
@@ -229,7 +267,10 @@ function Sparkline(props) {
|
|
|
229
267
|
const [keyed, setKeyed] = useState(null);
|
|
230
268
|
const active = hover ?? keyed;
|
|
231
269
|
const model = useMemo(() => {
|
|
232
|
-
const rows2 = data.map((
|
|
270
|
+
const rows2 = data.map((d, i) => ({
|
|
271
|
+
i,
|
|
272
|
+
v: finite(typeof d === "object" && d !== null ? d.value : d)
|
|
273
|
+
}));
|
|
233
274
|
const range = extent(rows2);
|
|
234
275
|
if (range === null) return null;
|
|
235
276
|
const at2 = reference === "mean" ? meanOf(rows2) : reference ?? null;
|
|
@@ -238,6 +279,7 @@ function Sparkline(props) {
|
|
|
238
279
|
const end = emphasizeLast ? emphasisColor : null;
|
|
239
280
|
return {
|
|
240
281
|
rows: rows2,
|
|
282
|
+
moments: momentsOf(data),
|
|
241
283
|
frame: frameOf(full, mark, rows2.length, end !== null),
|
|
242
284
|
definition: compileSparkline(rows2, full, mark, color, end, ref, referenceLabel)
|
|
243
285
|
};
|
|
@@ -269,14 +311,25 @@ function Sparkline(props) {
|
|
|
269
311
|
setKeyed(lastFinite(rows));
|
|
270
312
|
};
|
|
271
313
|
const inset = mark === "line" ? LINE_INSET : 0;
|
|
272
|
-
const layerStyle = { inset
|
|
314
|
+
const layerStyle = { inset };
|
|
273
315
|
const value = active === null ? null : rows?.[active]?.v ?? null;
|
|
274
316
|
const at = interactive && active !== null && value !== null ? {
|
|
275
317
|
value,
|
|
276
318
|
fx: mark === "bar" ? (active + 0.5) / model.rows.length : (active - model.frame.x[0]) / (model.frame.x[1] - model.frame.x[0]),
|
|
277
319
|
fy: (model.frame.y[1] - value) / (model.frame.y[1] - model.frame.y[0]),
|
|
278
|
-
label: labels?.[active]
|
|
320
|
+
label: labels?.[active] ?? model.moments?.[active]
|
|
279
321
|
} : null;
|
|
322
|
+
const beside = at === null ? null : at.fx > 0.5 ? "left" : "right";
|
|
323
|
+
const readoutStyle = at === null ? void 0 : {
|
|
324
|
+
...beside === "right" ? {
|
|
325
|
+
left: `calc(${at.fx * 100}% + ${READOUT_GAP}px)`,
|
|
326
|
+
maxWidth: `calc(${(1 - at.fx) * 100}% - ${READOUT_GAP}px)`
|
|
327
|
+
} : {
|
|
328
|
+
right: `calc(${(1 - at.fx) * 100}% + ${READOUT_GAP}px)`,
|
|
329
|
+
maxWidth: `calc(${at.fx * 100}% - ${READOUT_GAP}px)`
|
|
330
|
+
},
|
|
331
|
+
...at.fy > 0.5 ? { top: 0 } : { bottom: 0 }
|
|
332
|
+
};
|
|
280
333
|
return /* @__PURE__ */ jsxs(
|
|
281
334
|
"div",
|
|
282
335
|
{
|
|
@@ -305,9 +358,10 @@ function Sparkline(props) {
|
|
|
305
358
|
}
|
|
306
359
|
),
|
|
307
360
|
at !== null && // One layer on the plot rect (inside a line's margin): the dot and the readout take their
|
|
308
|
-
// fractions of the same box, so both land where the mark did.
|
|
361
|
+
// fractions of the same box, so both land where the mark did. A bar has no dot: the bar
|
|
362
|
+
// is the marker.
|
|
309
363
|
/* @__PURE__ */ jsxs("span", { "aria-hidden": "true", className: classes.layer, style: layerStyle, children: [
|
|
310
|
-
/* @__PURE__ */ jsx(
|
|
364
|
+
mark === "line" && /* @__PURE__ */ jsx(
|
|
311
365
|
"span",
|
|
312
366
|
{
|
|
313
367
|
"data-basalt-sparkline-dot": "",
|
|
@@ -321,7 +375,7 @@ function Sparkline(props) {
|
|
|
321
375
|
"data-basalt-sparkline-readout": "",
|
|
322
376
|
"aria-live": hover === null ? "polite" : "off",
|
|
323
377
|
className: classes.readout,
|
|
324
|
-
style:
|
|
378
|
+
style: readoutStyle,
|
|
325
379
|
children: [
|
|
326
380
|
format(at.value),
|
|
327
381
|
at.label !== void 0 && /* @__PURE__ */ jsxs("span", { className: classes.label, children: [
|
|
@@ -18,12 +18,29 @@ export type NamedChartState = Pick<ChartSeries<never>, 'key' | 'label' | 'color'
|
|
|
18
18
|
};
|
|
19
19
|
/** The status inks a state can name: `VX.status.*`. */
|
|
20
20
|
export type StatusTone = 'good' | 'warn' | 'bad' | 'neutral';
|
|
21
|
-
|
|
22
|
-
export declare function glyphOf(s: Pick<NamedChartState, 'glyph' | 'tone'> & {
|
|
21
|
+
type ToneSource = Pick<NamedChartState, 'glyph' | 'tone'> & {
|
|
23
22
|
color?: string | undefined;
|
|
24
|
-
}
|
|
25
|
-
/** A
|
|
23
|
+
};
|
|
24
|
+
/** A state's status tone: its own, else the one its status colour names. */
|
|
25
|
+
export declare function toneOf(s: ToneSource): StatusTone | undefined;
|
|
26
|
+
/** The glyph a state draws: its own, else its status tone's default, else none. */
|
|
27
|
+
export declare function glyphOf(s: ToneSource): string | undefined;
|
|
28
|
+
/** A heat cell narrower than this (px) draws no glyph: it would not fit inside the fill. */
|
|
26
29
|
export declare const GLYPH_MIN_PX = 12;
|
|
30
|
+
/**
|
|
31
|
+
* A `BandStrip` cell narrower than this (px) draws no glyph: its fill is full-height, so the glyph
|
|
32
|
+
* is set at the xs size (a 16 px line), and a `!` or `×` is unreadable in less. Such a cell draws a
|
|
33
|
+
* notch instead, see {@link NOTCH_PX}. A `Heatmap` keeps {@link GLYPH_MIN_PX}.
|
|
34
|
+
*/
|
|
35
|
+
export declare const BAND_GLYPH_MIN_PX = 16;
|
|
36
|
+
/**
|
|
37
|
+
* The height (px) of the bottom notch a glyph state draws where the glyph does not fit: a warn
|
|
38
|
+
* notch is shorter than a bad one, so the state is never told by hue alone.
|
|
39
|
+
*/
|
|
40
|
+
export declare const NOTCH_PX: {
|
|
41
|
+
readonly warn: 3;
|
|
42
|
+
readonly bad: 6;
|
|
43
|
+
};
|
|
27
44
|
/** A run of adjacent slots drawn as one band; `items` are the source data it stands for. */
|
|
28
45
|
export type Group<T> = {
|
|
29
46
|
start: number;
|
|
@@ -44,4 +61,5 @@ export declare function foldBands<T>(data: readonly T[], cap: number, merge: (gr
|
|
|
44
61
|
* in production the chart degrades to the unset behaviour.
|
|
45
62
|
*/
|
|
46
63
|
export declare function resolveNamedState<K extends string>(component: string, prop: string, requested: K | undefined, known: readonly string[]): K | undefined;
|
|
64
|
+
export {};
|
|
47
65
|
//# sourceMappingURL=band-fold.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"band-fold.d.ts","sourceRoot":"","sources":["../../src/charts/band-fold.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,WAAW,CAAC,KAAK,CAAC,EAClB,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,aAAa,CAC1E,GAAG;IACF;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B;gDAC4C;IAC5C,IAAI,CAAC,EAA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AAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,EAAE,CAAA;CAAE,CAAA;AAEpD,8FAA8F;AAC9F,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CASvE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAI3F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAChD,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,GAAG,SAAS,EACxB,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,CAAC,GAAG,SAAS,CAOf"}
|
package/dist/charts/band-fold.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { oneOf } from "../common/errors.js";
|
|
2
2
|
import { VX } from "../tokens/index.js";
|
|
3
3
|
const TONE_GLYPH = { warn: "!", bad: "\xD7" };
|
|
4
|
+
function toneOf(s) {
|
|
5
|
+
return s.tone ?? (s.color === VX.status.warn ? "warn" : s.color === VX.status.bad ? "bad" : void 0);
|
|
6
|
+
}
|
|
4
7
|
function glyphOf(s) {
|
|
5
|
-
const tone =
|
|
8
|
+
const tone = toneOf(s);
|
|
6
9
|
return s.glyph ?? (tone === void 0 ? void 0 : TONE_GLYPH[tone]);
|
|
7
10
|
}
|
|
8
11
|
const GLYPH_MIN_PX = 12;
|
|
12
|
+
const BAND_GLYPH_MIN_PX = 16;
|
|
13
|
+
const NOTCH_PX = { warn: 3, bad: 6 };
|
|
9
14
|
function groupsOf(data, cap) {
|
|
10
15
|
const size = Math.max(1, Math.ceil(data.length / Math.max(cap, 1)));
|
|
11
16
|
const out = [];
|
|
@@ -30,9 +35,12 @@ function resolveNamedState(component, prop, requested, known) {
|
|
|
30
35
|
return void 0;
|
|
31
36
|
}
|
|
32
37
|
export {
|
|
38
|
+
BAND_GLYPH_MIN_PX,
|
|
33
39
|
GLYPH_MIN_PX,
|
|
40
|
+
NOTCH_PX,
|
|
34
41
|
foldBands,
|
|
35
42
|
glyphOf,
|
|
36
43
|
groupsOf,
|
|
37
|
-
resolveNamedState
|
|
44
|
+
resolveNamedState,
|
|
45
|
+
toneOf
|
|
38
46
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** An axis tick's day: `4 Oct` (the page locale's own order). */
|
|
2
|
+
export declare const axisDay: (d: Date) => string;
|
|
3
|
+
/** {@link axisDay} with a two-digit year. */
|
|
4
|
+
export declare const axisDayYear: (d: Date) => string;
|
|
5
|
+
export declare const monthName: (d: Date) => string;
|
|
6
|
+
/** The tooltip header's date: weekday, day, month and year. */
|
|
7
|
+
export declare const headerDay: (d: Date) => string;
|
|
8
|
+
/** A day written out for a readout (`12 Oct`): the same format as an axis tick. */
|
|
9
|
+
export declare const readoutDay: (d: Date) => string;
|
|
10
|
+
/** A clock time for a readout, `HH:MM` in the page locale's digits. */
|
|
11
|
+
export declare const readoutClock: (d: Date) => string;
|
|
12
|
+
//# sourceMappingURL=chart-dates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-dates.d.ts","sourceRoot":"","sources":["../../src/charts/chart-dates.ts"],"names":[],"mappings":"AAWA,iEAAiE;AACjE,eAAO,MAAM,OAAO,GAAI,GAAG,IAAI,KAAG,MAA0D,CAAA;AAE5F,6CAA6C;AAC7C,eAAO,MAAM,WAAW,GAAI,GAAG,IAAI,KAAG,MAC6B,CAAA;AAEnE,eAAO,MAAM,SAAS,GAAI,GAAG,IAAI,KAAG,MAA0C,CAAA;AAE9E,+DAA+D;AAC/D,eAAO,MAAM,SAAS,GAAI,GAAG,IAAI,KAAG,MACiD,CAAA;AAErF,mFAAmF;AACnF,eAAO,MAAM,UAAU,MAbI,IAAI,KAAG,MAaD,CAAA;AAEjC,uEAAuE;AACvE,eAAO,MAAM,YAAY,GAAI,GAAG,IAAI,KAAG,MACiC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { dateFormat } from "../format/shared.js";
|
|
2
|
+
const utcFormat = (options, d) => dateFormat(void 0, { ...options, timeZone: "UTC" }).format(d);
|
|
3
|
+
const axisDay = (d) => utcFormat({ day: "numeric", month: "short" }, d);
|
|
4
|
+
const axisDayYear = (d) => utcFormat({ day: "numeric", month: "short", year: "2-digit" }, d);
|
|
5
|
+
const monthName = (d) => utcFormat({ month: "short" }, d);
|
|
6
|
+
const headerDay = (d) => utcFormat({ weekday: "short", day: "numeric", month: "short", year: "numeric" }, d);
|
|
7
|
+
const readoutDay = axisDay;
|
|
8
|
+
const readoutClock = (d) => utcFormat({ hour: "2-digit", minute: "2-digit", hourCycle: "h23" }, d);
|
|
9
|
+
export {
|
|
10
|
+
axisDay,
|
|
11
|
+
axisDayYear,
|
|
12
|
+
headerDay,
|
|
13
|
+
monthName,
|
|
14
|
+
readoutClock,
|
|
15
|
+
readoutDay
|
|
16
|
+
};
|
package/dist/charts/compile.d.ts
CHANGED
|
@@ -30,8 +30,16 @@ export type CartesianInput<T, X extends ChartX> = Pick<CartesianChartProps<T, X>
|
|
|
30
30
|
tooltipBelow?: boolean;
|
|
31
31
|
/** The vertical rule under the cursor. Default `true`; a bar kind has none (its hover is the bar). */
|
|
32
32
|
crosshair?: boolean;
|
|
33
|
+
/** The engine's point marker on the focused datum. Default `true`; a bar kind has none (its hover is the bar). */
|
|
34
|
+
focusRing?: boolean;
|
|
33
35
|
};
|
|
34
36
|
export declare function defaultNumberFormat(v: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* The UTC midnight of the day a day-keyed instant stands for. A key at LOCAL midnight is that local
|
|
39
|
+
* calendar date (east of UTC it is `22:00` UTC of the day before); any other key is its UTC date, so
|
|
40
|
+
* a key at 12:00 UTC or later never rolls to the next day.
|
|
41
|
+
*/
|
|
42
|
+
export declare function bucketDay(d: Date): Date;
|
|
35
43
|
/**
|
|
36
44
|
* The tooltip's date: weekday, day, month and year in the page's locale (`defineFormat` /
|
|
37
45
|
* `BasaltProvider`), read in UTC like the time scale; a non-midnight instant adds `HH:MM`. With
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/charts/compile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/charts/compile.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAGV,aAAa,EAEb,yBAAyB,EACzB,eAAe,IAAI,gBAAgB,EACnC,UAAU,EACV,yBAAyB,EAE1B,MAAM,6BAA6B,CAAA;AAIpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAO5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EAEnB,WAAW,EACX,eAAe,EACf,MAAM,EAEN,OAAO,EAEP,QAAQ,EACT,MAAM,SAAS,CAAA;AAEhB;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;AAE/F,gGAAgG;AAChG,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,IAAI,CACpD,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,EACvB,MAAM,GACN,GAAG,GACH,QAAQ,GACR,OAAO,GACP,GAAG,GACH,IAAI,GACJ,QAAQ,GACR,SAAS,GACT,SAAS,GACT,OAAO,GACP,QAAQ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/charts/compile.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { headerDay, readoutClock } from "./chart-dates.js";
|
|
1
2
|
import { dateTickFormat, utcAxisDate } from "./date-tick-format.js";
|
|
2
3
|
import { crosshair } from "@tanstack/charts/crosshair";
|
|
3
4
|
import { decorative } from "@tanstack/charts/mark/decorative";
|
|
@@ -8,7 +9,7 @@ import { scaleLinear } from "@tanstack/charts/scales/linear";
|
|
|
8
9
|
import { scaleUtc } from "d3-scale";
|
|
9
10
|
import { portal } from "@tanstack/charts/tooltip/portal";
|
|
10
11
|
import { compact } from "../format/number.js";
|
|
11
|
-
import { NON_FINITE,
|
|
12
|
+
import { NON_FINITE, numberFormat } from "../format/shared.js";
|
|
12
13
|
import { VX } from "../tokens/index.js";
|
|
13
14
|
import { cursorBinding, followerOptions, quietWhileFollowing } from "./cursor.js";
|
|
14
15
|
import { cursorDots } from "./marks.js";
|
|
@@ -37,22 +38,9 @@ function bucketDay(d) {
|
|
|
37
38
|
}
|
|
38
39
|
function utcHeaderDate(d, dayOnly = false) {
|
|
39
40
|
if (!Number.isFinite(d.getTime())) return NON_FINITE;
|
|
40
|
-
const
|
|
41
|
-
const date = dateFormat(void 0, {
|
|
42
|
-
weekday: "short",
|
|
43
|
-
day: "numeric",
|
|
44
|
-
month: "short",
|
|
45
|
-
year: "numeric",
|
|
46
|
-
timeZone: "UTC"
|
|
47
|
-
}).format(at);
|
|
41
|
+
const date = headerDay(dayOnly ? bucketDay(d) : d);
|
|
48
42
|
if (dayOnly || d.getTime() % DAY_MS === 0) return date;
|
|
49
|
-
|
|
50
|
-
hour: "2-digit",
|
|
51
|
-
minute: "2-digit",
|
|
52
|
-
hourCycle: "h23",
|
|
53
|
-
timeZone: "UTC"
|
|
54
|
-
}).format(d);
|
|
55
|
-
return `${date} ${clock}`;
|
|
43
|
+
return `${date} ${readoutClock(d)}`;
|
|
56
44
|
}
|
|
57
45
|
const DAY_MS = 864e5;
|
|
58
46
|
function dateTicks(domain, count, stepMs) {
|
|
@@ -119,18 +107,28 @@ function visibleSeries(series, hidden) {
|
|
|
119
107
|
(s) => !hidden.has(s.key) && !(s.parent !== void 0 && hidden.has(s.parent))
|
|
120
108
|
);
|
|
121
109
|
}
|
|
110
|
+
const decimalSeparator = () => numberFormat(void 0, {}).formatToParts(1.1).find((p) => p.type === "decimal")?.value ?? ".";
|
|
111
|
+
const zeroFraction = (separator) => new RegExp(`(\\d)${separator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}0+(?!\\d)`, "g");
|
|
112
|
+
function wholeStepFormat(axis, cfg, ticks) {
|
|
113
|
+
const [lo, hi] = [Math.min(...axis.domain), Math.max(...axis.domain)];
|
|
114
|
+
const values = "values" in ticks ? ticks.values : cfg?.scale === "log" ? [] : scaleLinear().domain([lo, hi]).ticks(ticks.count);
|
|
115
|
+
if (values.length === 0 || !values.every(Number.isInteger)) return axis.format;
|
|
116
|
+
const padded = zeroFraction(decimalSeparator());
|
|
117
|
+
return (v) => axis.format(v).replace(padded, "$1");
|
|
118
|
+
}
|
|
122
119
|
function yGuide(opts) {
|
|
123
120
|
const { cfg, axis, cls, side, grid } = opts;
|
|
124
121
|
const ladder = LADDER[cls];
|
|
125
122
|
const ticks = typeof cfg?.ticks === "object" ? { values: cfg.ticks } : { count: typeof cfg?.ticks === "number" ? cfg.ticks : ladder.yTicks };
|
|
126
123
|
const gridLine = grid ? { grid: GRID_LINE } : {};
|
|
127
124
|
if (cls === "micro") return { ...gridLine, axis: false };
|
|
125
|
+
const tickFormat = wholeStepFormat(axis, cfg, ticks);
|
|
128
126
|
return {
|
|
129
127
|
...gridLine,
|
|
130
128
|
...side === "right" && { side: "right" },
|
|
131
129
|
axis: {
|
|
132
130
|
line: false,
|
|
133
|
-
ticks: { ...ticks, format:
|
|
131
|
+
ticks: { ...ticks, format: tickFormat, line: false },
|
|
134
132
|
tickLabels: { fontSize: TICK_FONT, opacity: 1 }
|
|
135
133
|
}
|
|
136
134
|
};
|
|
@@ -159,8 +157,8 @@ function xTickFormat(consumer, tickValues) {
|
|
|
159
157
|
if (consumer) return consumer;
|
|
160
158
|
if (tickValues.length === 0 || !tickValues.every((v) => v instanceof Date))
|
|
161
159
|
return defaultFormatX;
|
|
162
|
-
const
|
|
163
|
-
return (v) => v instanceof Date ?
|
|
160
|
+
const dateFormat = dateTickFormat(tickValues);
|
|
161
|
+
return (v) => v instanceof Date ? dateFormat(v) : defaultFormatX(v);
|
|
164
162
|
}
|
|
165
163
|
function xGuide(opts) {
|
|
166
164
|
const { model, xTicks, cls } = opts;
|
|
@@ -413,6 +411,7 @@ function underlayMarks(input, model, axes) {
|
|
|
413
411
|
});
|
|
414
412
|
return [...zones, ...xZones];
|
|
415
413
|
}
|
|
414
|
+
const BAR_BODY = 0.8;
|
|
416
415
|
const REF_LABEL_DX = 6;
|
|
417
416
|
const REF_LABEL_DY_ABOVE = -5;
|
|
418
417
|
const REF_LABEL_DY_BELOW = 11;
|
|
@@ -506,7 +505,7 @@ function buildScales(opts) {
|
|
|
506
505
|
}
|
|
507
506
|
function tooltipHeader(input, formatX, dayOnly, v, d) {
|
|
508
507
|
if (input.tooltip && input.tooltip.formatHeader) return input.tooltip.formatHeader(v, d);
|
|
509
|
-
if (v instanceof Date && !input.formatX) return utcHeaderDate(v, dayOnly);
|
|
508
|
+
if (v instanceof Date && (!input.formatX || dayOnly)) return utcHeaderDate(v, dayOnly);
|
|
510
509
|
return formatX(v);
|
|
511
510
|
}
|
|
512
511
|
function dayGranular(values) {
|
|
@@ -624,10 +623,18 @@ function compileCartesian(input) {
|
|
|
624
623
|
);
|
|
625
624
|
const dayOnly = dayGranular(model.values);
|
|
626
625
|
const names = (input.refLines ?? []).some((r) => r.label !== void 0 && r.label !== "");
|
|
626
|
+
const barHalf = model.halfStep * BAR_BODY;
|
|
627
627
|
const linesOn = (side) => visible.filter((s) => shared.onRight(s) === (side === "right" && shared.right !== null)).map(
|
|
628
628
|
(s) => rows(s.key).flatMap((r) => {
|
|
629
629
|
const fx = model.fraction(r.x);
|
|
630
|
-
|
|
630
|
+
if (fx === null || r.y === null) return [];
|
|
631
|
+
if (!(model.band && s.mark === "bar")) return [{ fx, y: r.y }];
|
|
632
|
+
return [
|
|
633
|
+
{ fx: fx - barHalf, y: 0 },
|
|
634
|
+
{ fx: fx - barHalf, y: r.y },
|
|
635
|
+
{ fx: fx + barHalf, y: r.y },
|
|
636
|
+
{ fx: fx + barHalf, y: 0 }
|
|
637
|
+
];
|
|
631
638
|
})
|
|
632
639
|
);
|
|
633
640
|
const definition = {
|
|
@@ -689,6 +696,7 @@ function compileCartesian(input) {
|
|
|
689
696
|
// Followers resolve the leader's group, so they draw its dots; `quietWhileFollowing` mutes the
|
|
690
697
|
// tooltip unless the chart opts into following tooltips.
|
|
691
698
|
focus: "group-x",
|
|
699
|
+
...input.focusRing === false && { focusRing: false },
|
|
692
700
|
maxFocusDistance: Number.POSITIVE_INFINITY,
|
|
693
701
|
cursor: cursorBinding({
|
|
694
702
|
group: input.cursorGroup,
|
|
@@ -705,6 +713,7 @@ function compileCartesian(input) {
|
|
|
705
713
|
export {
|
|
706
714
|
areaGradient,
|
|
707
715
|
areaGradientId,
|
|
716
|
+
bucketDay,
|
|
708
717
|
compileCartesian,
|
|
709
718
|
dashedSwatch,
|
|
710
719
|
dateTicks,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The default Date x tick labels: chosen from the TICK step (not the data step), read in UTC like
|
|
3
3
|
* the scale that placed them. A label may recur on one axis only behind a MARKER label (a day or a
|
|
4
|
-
* year) — `12:00, 18:00, 18
|
|
4
|
+
* year) — `12:00, 18:00, 18 Oct, 06:00, 12:00` is fine, `17 Oct, 17 Oct, 18 Oct` is not. Each span has
|
|
5
5
|
* a ladder of levels, plainest first; the first level that holds the invariant wins. The last rung
|
|
6
6
|
* of every ladder names the whole date (or instant) of its tick, so the invariant always holds.
|
|
7
7
|
*/
|
|
8
8
|
export declare const pad2: (n: number) => string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare
|
|
9
|
+
/** The day (`4 Oct`, in the page locale), read in UTC like the time scale (a local read shifts a
|
|
10
|
+
* day west of UTC). */
|
|
11
|
+
export declare const utcAxisDate: (d: Date) => string;
|
|
12
12
|
/**
|
|
13
13
|
* A formatter for one tick set. A Date that is not among the ticks (a hover, a consumer reading
|
|
14
|
-
* the axis format) reads as plain
|
|
14
|
+
* the axis format) reads as the plain day: its position in the set is undefined.
|
|
15
15
|
*/
|
|
16
16
|
export declare function dateTickFormat(ticks: readonly Date[]): (d: Date) => string;
|
|
17
17
|
//# sourceMappingURL=date-tick-format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-tick-format.d.ts","sourceRoot":"","sources":["../../src/charts/date-tick-format.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"date-tick-format.d.ts","sourceRoot":"","sources":["../../src/charts/date-tick-format.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,eAAO,MAAM,IAAI,GAAI,GAAG,MAAM,KAAG,MAAoC,CAAA;AAUrE;uBACuB;AACvB,eAAO,MAAM,WAAW,qBAAU,CAAA;AAgGlC;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM,CAM1E"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { axisDay, axisDayYear, monthName } from "./chart-dates.js";
|
|
2
2
|
const pad2 = (n) => String(n).padStart(2, "0");
|
|
3
|
-
const monthName = (d) => MONTHS[d.getUTCMonth()];
|
|
4
3
|
const DAY_MS = 864e5;
|
|
5
4
|
const HOUR_MS = 36e5;
|
|
6
5
|
const MONTH_STEP_MS = 27 * DAY_MS;
|
|
7
|
-
|
|
8
|
-
return `${pad2(d.getUTCDate())}.${pad2(d.getUTCMonth() + 1)}`;
|
|
9
|
-
}
|
|
6
|
+
const utcAxisDate = axisDay;
|
|
10
7
|
const utcClock = (d) => `${pad2(d.getUTCHours())}:${pad2(d.getUTCMinutes())}`;
|
|
11
8
|
const utcClockSeconds = (d) => `${utcClock(d)}:${pad2(d.getUTCSeconds())}`;
|
|
12
9
|
const utcClockMillis = (d) => `${utcClockSeconds(d)}.${String(d.getUTCMilliseconds()).padStart(3, "0")}`;
|
|
13
|
-
const utcAxisDateYear =
|
|
10
|
+
const utcAxisDateYear = axisDayYear;
|
|
14
11
|
const isMidnight = (t) => t % DAY_MS === 0;
|
|
15
12
|
const isJanuary = (d) => d.getUTCMonth() === 0;
|
|
16
13
|
const dayOf = (t) => Math.floor(t / DAY_MS);
|
|
@@ -75,7 +72,6 @@ function dateTickFormat(ticks) {
|
|
|
75
72
|
}
|
|
76
73
|
export {
|
|
77
74
|
dateTickFormat,
|
|
78
|
-
monthName,
|
|
79
75
|
pad2,
|
|
80
76
|
utcAxisDate
|
|
81
77
|
};
|
package/dist/charts/labels.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ChartMarks, ChartSeries, ChartX, PlotContext, PlotRow } from './types.js';
|
|
2
2
|
export type EndLabelAnchor = 'start' | 'end';
|
|
3
|
+
/** Which side of its line a flipped label sits: away from the line's last segment. */
|
|
4
|
+
export type EndLabelSide = 'above' | 'below';
|
|
3
5
|
/**
|
|
4
6
|
* The side of its point an end label takes: `start` (right of the point) unless the point leaves
|
|
5
7
|
* less room than the label needs. `fraction` is the point's x as a share of the plot width,
|
|
@@ -19,13 +21,15 @@ export type EndLabel<T, X extends ChartX> = {
|
|
|
19
21
|
series: ChartSeries<T>;
|
|
20
22
|
row: PlotRow<T, X>;
|
|
21
23
|
anchor: EndLabelAnchor;
|
|
24
|
+
/** Only a flipped label (left of its point) can meet its own line; it takes the clear side. */
|
|
25
|
+
side: EndLabelSide;
|
|
22
26
|
/** A vertical shift in px (negative is up) that keeps this label clear of its neighbours. */
|
|
23
27
|
nudge: number;
|
|
24
28
|
};
|
|
25
29
|
/**
|
|
26
30
|
* Pushes labels apart: `ys` are the labels' heights in px from the plot's bottom, returned as the
|
|
27
31
|
* shift each needs (positive is up) so no two sit closer than {@link END_LABEL_MIN_GAP} and the
|
|
28
|
-
* topmost
|
|
32
|
+
* lowest and the topmost stay {@link END_LABEL_EDGE} inside the plot. Order is kept.
|
|
29
33
|
*/
|
|
30
34
|
export declare function spreadLabels(ys: readonly number[], plotHeight: number): number[];
|
|
31
35
|
/**
|
|
@@ -36,8 +40,8 @@ export declare function spreadLabels(ys: readonly number[], plotHeight: number):
|
|
|
36
40
|
* (`plot.xFraction` outside [0, 1]: clipped by a narrower `xDomain`), has no label.
|
|
37
41
|
*/
|
|
38
42
|
export declare function endLabelPlan<T, X extends ChartX>(plot: PlotContext<T, X>, lines: readonly ChartSeries<T>[], naming?: LinesNaming): EndLabel<T, X>[];
|
|
39
|
-
/** The offset of a label from its point: right of it, level; or left of it
|
|
40
|
-
export declare function endLabelOffset(anchor: EndLabelAnchor): {
|
|
43
|
+
/** The offset of a label from its point: right of it, level; or left of it, above or below. */
|
|
44
|
+
export declare function endLabelOffset(anchor: EndLabelAnchor, side?: EndLabelSide): {
|
|
41
45
|
dx: number;
|
|
42
46
|
dy: number;
|
|
43
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/charts/labels.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/charts/labels.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAmBpF,MAAM,MAAM,cAAc,GAAG,OAAO,GAA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