strata-react 1.0.18 → 1.0.21

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.
@@ -93,6 +93,12 @@ export declare function createFormat(locale: string, options?: FormatOptions): {
93
93
  * to fix the unit, so figures compared side by side ("431 of 466 GB") share one.
94
94
  */
95
95
  bytes: (value: number, unit?: ByteUnit) => string;
96
+ /**
97
+ * A distance in metres as a person says it: metres under a kilometre ("850 m"), then
98
+ * kilometres, one decimal below 100 ("12.4 km"), whole above; `"imperial"` is feet under a
99
+ * tenth of a mile ("320 ft"), then miles ("7.7 mi").
100
+ */
101
+ distance: (metres: number, system?: "metric" | "imperial") => string;
96
102
  /** The unit `bytes` would choose for a value, to share it across a set of figures. */
97
103
  byteUnit: (value: number) => ByteUnit;
98
104
  /**
@@ -167,6 +173,12 @@ export declare const format: {
167
173
  * to fix the unit, so figures compared side by side ("431 of 466 GB") share one.
168
174
  */
169
175
  bytes: (value: number, unit?: ByteUnit) => string;
176
+ /**
177
+ * A distance in metres as a person says it: metres under a kilometre ("850 m"), then
178
+ * kilometres, one decimal below 100 ("12.4 km"), whole above; `"imperial"` is feet under a
179
+ * tenth of a mile ("320 ft"), then miles ("7.7 mi").
180
+ */
181
+ distance: (metres: number, system?: "metric" | "imperial") => string;
170
182
  /** The unit `bytes` would choose for a value, to share it across a set of figures. */
171
183
  byteUnit: (value: number) => ByteUnit;
172
184
  /**
@@ -0,0 +1,44 @@
1
+ /** A position: `[latitude, longitude]` in degrees. */
2
+ export type LatLng = readonly [lat: number, lng: number];
3
+ /** Great-circle distance between two positions, in metres. */
4
+ export declare function distance([lat1, lng1]: LatLng, [lat2, lng2]: LatLng): number;
5
+ /** The direction from `a` to `b` in degrees clockwise from north (0 to 360), for neighbouring points. */
6
+ export declare function bearing([lat1, lng1]: LatLng, [lat2, lng2]: LatLng): number;
7
+ /** The running distance along a route at each point, in metres, starting at 0. */
8
+ export declare function cumulative(points: readonly LatLng[]): number[];
9
+ /** The length of a route in metres. */
10
+ export declare function length(points: readonly LatLng[]): number;
11
+ /** The south-west and north-east corners that hold every point, or null for none. */
12
+ export declare function bounds(points: readonly LatLng[]): [LatLng, LatLng] | null;
13
+ /** The position `metres` along a route (clamped to its ends), by linear interpolation, or null for no points. */
14
+ export declare function pointAlong(points: readonly LatLng[], metres: number, along?: readonly number[]): LatLng | null;
15
+ /**
16
+ * `count` positions evenly spaced by distance along a route (the ends skipped), each with the
17
+ * direction of travel there. The direction is smoothed: the bearing from a point a fraction
18
+ * (`window`) of the spacing before to one the same distance after, so GPS jitter and a tight bend
19
+ * do not turn a chevron sideways.
20
+ */
21
+ export declare function arrows(points: readonly LatLng[], count?: number, window?: number): {
22
+ position: LatLng;
23
+ bearing: number;
24
+ }[];
25
+ /** The first and last positions, and whether they are within `loopWithin` metres of each other (a loop), or null for no route. */
26
+ export declare function ends(points: readonly LatLng[], loopWithin?: number): {
27
+ start: LatLng;
28
+ finish: LatLng;
29
+ loop: boolean;
30
+ } | null;
31
+ /** The index of the point nearest `position`, for "where on the route is this?". */
32
+ export declare function nearest(points: readonly LatLng[], position: LatLng): number;
33
+ /** Route geometry helpers: `geo.distance`, `bearing`, `length`, `cumulative`, `bounds`, `pointAlong`, `arrows`, `ends`, `nearest`. */
34
+ export declare const geo: {
35
+ distance: typeof distance;
36
+ bearing: typeof bearing;
37
+ cumulative: typeof cumulative;
38
+ length: typeof length;
39
+ bounds: typeof bounds;
40
+ pointAlong: typeof pointAlong;
41
+ arrows: typeof arrows;
42
+ ends: typeof ends;
43
+ nearest: typeof nearest;
44
+ };
@@ -0,0 +1 @@
1
+ export { RouteMap, type MapRoute, type RouteMapProps, type TileSource } from './route-map';
@@ -0,0 +1,2 @@
1
+ /** Puts Leaflet's stylesheet and the token overrides in the document head, once. */
2
+ export declare function installMapStyles(): void;
@@ -0,0 +1,72 @@
1
+ import { LatLng } from '../lib/geo';
2
+ import * as React from "react";
3
+ /** A source of map tiles: a URL template the app's provider documents, and the attribution it requires. */
4
+ export type TileSource = {
5
+ /** `https://tiles.example.com/{z}/{x}/{y}.png`; `{s}` and `{r}` work as in Leaflet. */
6
+ url: string;
7
+ /** What the provider requires shown (HTML allowed: "© OpenStreetMap contributors"). */
8
+ attribution: string;
9
+ subdomains?: string;
10
+ minZoom?: number;
11
+ maxZoom?: number;
12
+ };
13
+ /** One route on the map. */
14
+ export type MapRoute = {
15
+ id: string;
16
+ /** Its name, in the text alternative and on hover ("Wednesday run"). */
17
+ label: string;
18
+ points: readonly LatLng[];
19
+ /** Any CSS colour, normally a role (`var(--chart-2)`). Default: the chart palette in order. */
20
+ colour?: string;
21
+ /** Line width in pixels. Default 4. */
22
+ weight?: number;
23
+ /** One value per point, coloured by `colourScale` (speed, elevation, heart rate). */
24
+ values?: readonly number[];
25
+ /** Direction chevrons along the line: true for five, or a count. Default on for a single route. */
26
+ arrows?: boolean | number;
27
+ /** Start and finish marks. Default on for a single route. */
28
+ ends?: boolean;
29
+ };
30
+ export type RouteMapProps = {
31
+ /** Names the map ("Route of Wednesday's run"). */
32
+ label: string;
33
+ /** Keep this array stable between renders (state or `useMemo`): the routes are redrawn when it changes, which a moving position must not cause. */
34
+ routes: readonly MapRoute[];
35
+ tiles: {
36
+ light: TileSource;
37
+ dark?: TileSource;
38
+ };
39
+ /** Where the moving thing is now. Moved without redrawing any route; null for none. */
40
+ position?: LatLng | null;
41
+ /** What the position is called in the text alternative. Default "Current position". */
42
+ positionLabel?: string;
43
+ /** Keep the position in view as it moves. */
44
+ follow?: boolean;
45
+ /** The route drawn heavier, with the others lighter. */
46
+ selectedId?: string | null;
47
+ /** A route line was pressed. Give the app's own list of routes the same action for the keyboard. */
48
+ onSelect?: (id: string) => void;
49
+ /** Step colours for routes that have `values`: a step starts at `at` and runs to the next. */
50
+ colourScale?: readonly {
51
+ at: number;
52
+ colour: string;
53
+ }[];
54
+ /** What the colours mean, written in the key ("Speed"). */
55
+ colourScaleLabel?: string;
56
+ /** Writes a value in the key and the text alternative ("12 km/h"). Default the plain number. */
57
+ formatValue?: (value: number) => string;
58
+ /** Replaces the generated text alternative. */
59
+ summary?: string;
60
+ /** Units for lengths in the generated text. Default metric. */
61
+ units?: "metric" | "imperial";
62
+ /** Wheel zoom. Off by default so the page still scrolls past the map. */
63
+ scrollZoom?: boolean;
64
+ /** An app control or figure in the top end corner (Leaflet leaves it free). */
65
+ topEnd?: React.ReactNode;
66
+ /** An app legend or figure in the bottom start corner, below the colour key when there is one. */
67
+ bottomStart?: React.ReactNode;
68
+ /** Layout only. The map is 16:9 and at least 16rem tall unless a height is given. */
69
+ className?: string;
70
+ };
71
+ /** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */
72
+ export declare function RouteMap({ label, routes, tiles, position, positionLabel, follow, selectedId, onSelect, colourScale, colourScaleLabel, formatValue, summary, units, scrollZoom, topEnd, bottomStart, className, }: RouteMapProps): React.JSX.Element;
package/dist/map.js ADDED
@@ -0,0 +1,400 @@
1
+ import { _ as cn, a as useColorScheme } from "./theme-BgTOESmN.js";
2
+ import { a as format, t as geo } from "./geo-C0jcFp4q.js";
3
+ import * as React from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import L from "leaflet";
6
+ import leafletCss from "leaflet/dist/leaflet.css?inline";
7
+ // src/map/map-styles.ts
8
+ var strata = `
9
+ .strata-map .leaflet-container { background: var(--surface-sunken); color: var(--foreground); font: inherit; }
10
+ .strata-map .leaflet-container:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
11
+ .strata-map .leaflet-bar { border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; overflow: hidden; }
12
+ .strata-map .leaflet-bar a { background: var(--background); color: var(--foreground); border-bottom: 1px solid var(--border); width: var(--control-h, 2.5rem); height: var(--control-h, 2.5rem); line-height: var(--control-h, 2.5rem); }
13
+ .strata-map .leaflet-control-zoom-in, .strata-map .leaflet-control-zoom-out { font: inherit; font-size: 1.25rem; font-weight: 600; }
14
+ .strata-map .leaflet-bar a:last-child { border-bottom: 0; }
15
+ .strata-map .leaflet-bar a:hover, .strata-map .leaflet-bar a:focus-visible { background: var(--muted); }
16
+ .strata-map .leaflet-bar a.leaflet-disabled { color: var(--muted-foreground); background: var(--background); cursor: not-allowed; }
17
+ .strata-map .leaflet-control-attribution { background: color-mix(in oklab, var(--background) 85%, transparent); color: var(--muted-foreground); font-size: 0.75rem; }
18
+ .strata-map .leaflet-control-attribution a { color: inherit; text-decoration: underline; }
19
+ .strata-map .leaflet-tooltip { background: var(--background); color: var(--foreground); border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; font: inherit; font-size: 0.8125rem; padding: 0.125rem 0.375rem; }
20
+ .strata-map .leaflet-tooltip::before { display: none; }
21
+ .strata-map[data-dark-treatment] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }
22
+ .strata-map .strata-map-arrow { background: none; border: 0; }
23
+ `;
24
+ var installed = false;
25
+ /** Puts Leaflet's stylesheet and the token overrides in the document head, once. */
26
+ function installMapStyles() {
27
+ if (installed || typeof document === "undefined") return;
28
+ installed = true;
29
+ const el = document.createElement("style");
30
+ el.setAttribute("data-strata-map", "");
31
+ el.textContent = leafletCss + strata;
32
+ document.head.appendChild(el);
33
+ }
34
+ // src/map/route-map.tsx
35
+ /** The smallest and largest value, without spreading the array (a long recording passes the engine's argument limit). */
36
+ function extent(values) {
37
+ let lo = Infinity;
38
+ let hi = -Infinity;
39
+ for (const v of values) {
40
+ if (v < lo) lo = v;
41
+ if (v > hi) hi = v;
42
+ }
43
+ return [lo, hi];
44
+ }
45
+ var tuple = (p) => [p[0], p[1]];
46
+ var plain = (v) => String(v);
47
+ /** `value`, sampled once a second (a throttle, not a debounce: a value that changes every frame still comes through): for text a screen reader may read, which must not change sixty times a second. */
48
+ function useSlow(value, ms = 1e3) {
49
+ const [slow, setSlow] = React.useState(value);
50
+ const latest = React.useRef(value);
51
+ latest.current = value;
52
+ React.useEffect(() => {
53
+ const id = window.setInterval(() => setSlow(latest.current), ms);
54
+ return () => window.clearInterval(id);
55
+ }, [ms]);
56
+ return slow;
57
+ }
58
+ var PALETTE = [
59
+ 1,
60
+ 2,
61
+ 3,
62
+ 4,
63
+ 5
64
+ ].map((n) => `var(--chart-${n})`);
65
+ /** The colour a CSS value (a `var()`, a role) resolves to on `el`, so an SVG attribute gets a real one. Falls back to the value itself. */
66
+ function resolveColour(el, value) {
67
+ const probe = document.createElement("span");
68
+ probe.style.color = value;
69
+ el.appendChild(probe);
70
+ const resolved = getComputedStyle(probe).color;
71
+ probe.remove();
72
+ return resolved || value;
73
+ }
74
+ /** Indices where a run of one step ends, so a coloured route is a few polylines. */
75
+ function stepRuns(points, values, stepOf) {
76
+ const runs = [];
77
+ for (let i = 1; i < points.length; i++) {
78
+ const step = stepOf(((values[i - 1] ?? 0) + (values[i] ?? 0)) / 2);
79
+ const last = runs[runs.length - 1];
80
+ if (last && last.step === step) last.to = i;
81
+ else runs.push({
82
+ from: i - 1,
83
+ to: i,
84
+ step
85
+ });
86
+ }
87
+ return runs;
88
+ }
89
+ var arrowHtml = (bearing, colour, halo) => `<svg width="26" height="26" viewBox="0 0 26 26" aria-hidden="true" style="transform: rotate(${bearing.toFixed(0)}deg)"><path d="M6 17 L13 9 L20 17" fill="none" stroke="${halo}" stroke-width="7" stroke-linecap="round" stroke-linejoin="round"/><path d="M6 17 L13 9 L20 17" fill="none" stroke="${colour}" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
90
+ /** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */
91
+ function RouteMap({ label, routes, tiles, position = null, positionLabel = "Current position", follow = false, selectedId = null, onSelect, colourScale, colourScaleLabel, formatValue = plain, summary, units = "metric", scrollZoom = false, topEnd, bottomStart, className }) {
92
+ const { scheme } = useColorScheme();
93
+ const host = React.useRef(null);
94
+ const root = React.useRef(null);
95
+ const [map, setMap] = React.useState(null);
96
+ const summaryId = React.useId();
97
+ const latest = React.useRef({ onSelect });
98
+ latest.current = { onSelect };
99
+ const selectable = Boolean(onSelect);
100
+ const marker = React.useRef(null);
101
+ const markerScheme = React.useRef(null);
102
+ const source = (scheme === "dark" ? tiles.dark : void 0) ?? tiles.light;
103
+ const treated = scheme === "dark" && !tiles.dark;
104
+ const stops = React.useMemo(() => colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : [], [colourScale]);
105
+ React.useEffect(() => {
106
+ installMapStyles();
107
+ const el = host.current;
108
+ if (!el) return;
109
+ const m = L.map(el, {
110
+ scrollWheelZoom: scrollZoom,
111
+ fadeAnimation: false,
112
+ zoomAnimation: false,
113
+ markerZoomAnimation: false,
114
+ inertia: false,
115
+ attributionControl: false,
116
+ zoomSnap: .5
117
+ });
118
+ L.control.attribution({ prefix: "<a href=\"https://leafletjs.com\">Leaflet</a>" }).addTo(m);
119
+ el.setAttribute("aria-roledescription", "map");
120
+ const ro = new ResizeObserver(() => m.invalidateSize({ animate: false }));
121
+ ro.observe(el);
122
+ setMap(m);
123
+ return () => {
124
+ ro.disconnect();
125
+ marker.current = null;
126
+ markerScheme.current = null;
127
+ m.remove();
128
+ setMap(null);
129
+ };
130
+ }, []);
131
+ React.useEffect(() => {
132
+ if (!map) return;
133
+ if (scrollZoom) map.scrollWheelZoom.enable();
134
+ else map.scrollWheelZoom.disable();
135
+ }, [map, scrollZoom]);
136
+ const spoken = useSlow(position);
137
+ const text = React.useMemo(() => {
138
+ if (summary) return summary;
139
+ if (!routes.length) return "No routes to show.";
140
+ const parts = routes.map((r) => {
141
+ const along = geo.cumulative(r.points);
142
+ const total = along[along.length - 1] ?? 0;
143
+ const shape = geo.ends(r.points)?.loop ? ", a loop" : "";
144
+ let here = "";
145
+ if (spoken && r.points.length) {
146
+ const i = geo.nearest(r.points, spoken);
147
+ here = ` ${positionLabel}: ${format.distance(along[i] ?? 0, units)} along.`;
148
+ }
149
+ let range = "";
150
+ if (stops.length && r.values?.length) range = ` ${colourScaleLabel ?? "Value"} from ${formatValue(extent(r.values)[0])} to ${formatValue(extent(r.values)[1])}.`;
151
+ return `${r.label}: ${format.distance(total, units)}${shape}.${range}${here}`;
152
+ });
153
+ return `Map with ${routes.length === 1 ? "one route" : `${routes.length} routes`}. ${parts.join(" ")}`;
154
+ }, [
155
+ summary,
156
+ routes,
157
+ spoken,
158
+ positionLabel,
159
+ units,
160
+ stops.length,
161
+ colourScaleLabel,
162
+ formatValue
163
+ ]);
164
+ React.useEffect(() => {
165
+ if (!map) return;
166
+ const c = map.getContainer();
167
+ c.setAttribute("aria-label", label);
168
+ c.setAttribute("aria-describedby", summaryId);
169
+ }, [
170
+ map,
171
+ label,
172
+ summaryId
173
+ ]);
174
+ React.useEffect(() => {
175
+ if (!map) return;
176
+ const layer = L.tileLayer(source.url, {
177
+ attribution: source.attribution,
178
+ subdomains: source.subdomains ?? "abc",
179
+ minZoom: source.minZoom,
180
+ maxZoom: source.maxZoom ?? 19,
181
+ keepBuffer: 1
182
+ });
183
+ layer.addTo(map);
184
+ return () => void layer.remove();
185
+ }, [
186
+ map,
187
+ source.url,
188
+ source.attribution,
189
+ source.subdomains,
190
+ source.minZoom,
191
+ source.maxZoom
192
+ ]);
193
+ React.useEffect(() => {
194
+ if (!map) return;
195
+ const group = L.featureGroup().addTo(map);
196
+ const el = map.getContainer();
197
+ const halo = resolveColour(el, "var(--background)");
198
+ const single = routes.length === 1;
199
+ const stepOf = (v) => {
200
+ let at = 0;
201
+ stops.forEach((s, i) => {
202
+ if (s.at <= v) at = i;
203
+ });
204
+ return at;
205
+ };
206
+ routes.forEach((route, index) => {
207
+ if (route.points.length < 2) return;
208
+ const base = resolveColour(el, route.colour ?? PALETTE[index % PALETTE.length]);
209
+ const selected = route.id === selectedId;
210
+ const dim = selectedId !== null && !selected;
211
+ const style = {
212
+ weight: (route.weight ?? 4) + (selected ? 2 : 0),
213
+ opacity: dim ? .55 : 1,
214
+ lineCap: "round",
215
+ lineJoin: "round",
216
+ interactive: selectable,
217
+ bubblingMouseEvents: false
218
+ };
219
+ const lines = [];
220
+ if (stops.length && route.values?.length) for (const run of stepRuns(route.points, route.values, stepOf)) lines.push(L.polyline(route.points.slice(run.from, run.to + 1).map(tuple), {
221
+ ...style,
222
+ color: resolveColour(el, stops[run.step].colour)
223
+ }));
224
+ else lines.push(L.polyline(route.points.map(tuple), {
225
+ ...style,
226
+ color: base
227
+ }));
228
+ for (const line of lines) {
229
+ line.bindTooltip(route.label, { sticky: true });
230
+ line.on("click", () => latest.current.onSelect?.(route.id));
231
+ line.addTo(group);
232
+ }
233
+ const chevrons = route.arrows === void 0 ? single ? 5 : 0 : route.arrows === true ? 5 : route.arrows === false ? 0 : route.arrows;
234
+ if (chevrons > 0) for (const a of geo.arrows(route.points, chevrons)) L.marker(tuple(a.position), {
235
+ interactive: false,
236
+ keyboard: false,
237
+ icon: L.divIcon({
238
+ className: "strata-map-arrow",
239
+ iconSize: [26, 26],
240
+ iconAnchor: [13, 13],
241
+ html: arrowHtml(a.bearing, base, halo)
242
+ })
243
+ }).addTo(group);
244
+ if (route.ends ?? single) {
245
+ const ends = geo.ends(route.points);
246
+ if (ends) {
247
+ const success = resolveColour(el, "var(--success)");
248
+ const danger = resolveColour(el, "var(--danger)");
249
+ const mark = (at, text, options) => L.circleMarker(tuple(at), {
250
+ radius: 7,
251
+ interactive: true,
252
+ bubblingMouseEvents: false,
253
+ ...options
254
+ }).bindTooltip(text).addTo(group);
255
+ if (ends.loop) mark(ends.start, `${route.label}: start and finish`, {
256
+ color: danger,
257
+ weight: 3,
258
+ fillColor: success,
259
+ fillOpacity: 1
260
+ });
261
+ else {
262
+ mark(ends.finish, `${route.label}: finish`, {
263
+ color: danger,
264
+ weight: 3,
265
+ fillColor: halo,
266
+ fillOpacity: 1
267
+ });
268
+ mark(ends.start, `${route.label}: start`, {
269
+ color: halo,
270
+ weight: 2,
271
+ fillColor: success,
272
+ fillOpacity: 1
273
+ });
274
+ }
275
+ }
276
+ }
277
+ });
278
+ return () => void group.remove();
279
+ }, [
280
+ map,
281
+ routes,
282
+ scheme,
283
+ selectedId,
284
+ stops,
285
+ selectable
286
+ ]);
287
+ const routeKey = routes.map((r) => r.id).join("\n");
288
+ const fitted = React.useRef(null);
289
+ React.useEffect(() => {
290
+ if (!map) return;
291
+ const fit = () => {
292
+ const size = map.getSize();
293
+ if (fitted.current === routeKey || size.x === 0 || size.y === 0) return;
294
+ const box = geo.bounds(routes.flatMap((r) => r.points));
295
+ if (!box) return;
296
+ fitted.current = routeKey;
297
+ map.fitBounds([tuple(box[0]), tuple(box[1])], {
298
+ padding: [24, 24],
299
+ animate: false,
300
+ maxZoom: 17
301
+ });
302
+ };
303
+ fit();
304
+ map.on("resize", fit);
305
+ return () => void map.off("resize", fit);
306
+ }, [map, routeKey]);
307
+ const [lat, lng] = position ?? [null, null];
308
+ React.useEffect(() => {
309
+ if (!map) return;
310
+ if (lat === null || lng === null) {
311
+ marker.current?.remove();
312
+ marker.current = null;
313
+ return;
314
+ }
315
+ const el = map.getContainer();
316
+ if (!marker.current) {
317
+ marker.current = L.circleMarker([lat, lng], {
318
+ radius: 8,
319
+ weight: 3,
320
+ fillOpacity: 1,
321
+ interactive: false
322
+ }).addTo(map);
323
+ markerScheme.current = null;
324
+ } else marker.current.setLatLng([lat, lng]);
325
+ if (markerScheme.current !== scheme) {
326
+ markerScheme.current = scheme;
327
+ marker.current.setStyle({
328
+ color: resolveColour(el, "var(--background)"),
329
+ fillColor: resolveColour(el, "var(--primary)")
330
+ });
331
+ }
332
+ if (follow && !map.getBounds().pad(-.2).contains([lat, lng])) map.panTo([lat, lng], { animate: false });
333
+ }, [
334
+ map,
335
+ lat,
336
+ lng,
337
+ follow,
338
+ scheme
339
+ ]);
340
+ return /* @__PURE__ */ jsxs("div", {
341
+ ref: root,
342
+ "data-dark-treatment": treated ? "" : void 0,
343
+ className: cn("strata-map relative isolate aspect-video min-h-64 overflow-hidden rounded-surface border border-border", className),
344
+ children: [
345
+ /* @__PURE__ */ jsx("div", {
346
+ ref: host,
347
+ className: "size-full"
348
+ }),
349
+ /* @__PURE__ */ jsx("p", {
350
+ id: summaryId,
351
+ className: "sr-only",
352
+ children: text
353
+ }),
354
+ topEnd && /* @__PURE__ */ jsx("div", {
355
+ className: "absolute top-2 right-2 z-1000",
356
+ children: topEnd
357
+ }),
358
+ (stops.length > 0 || bottomStart) && /* @__PURE__ */ jsxs("div", {
359
+ className: "absolute bottom-6 left-2 z-1000 grid max-w-[60%] gap-2",
360
+ children: [stops.length > 0 && /* @__PURE__ */ jsx(ColourKey, {
361
+ stops,
362
+ label: colourScaleLabel,
363
+ formatValue
364
+ }), bottomStart]
365
+ })
366
+ ]
367
+ });
368
+ }
369
+ /** The key to a colour scale: its name, then each step with where it starts, so colour is never the only cue. */
370
+ function ColourKey({ stops, label, formatValue }) {
371
+ return /* @__PURE__ */ jsxs("div", {
372
+ className: "rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground",
373
+ children: [label && /* @__PURE__ */ jsx("p", {
374
+ className: "font-medium",
375
+ children: label
376
+ }), /* @__PURE__ */ jsx("ul", {
377
+ className: "grid gap-0.5",
378
+ children: stops.map((s) => /* @__PURE__ */ jsxs("li", {
379
+ className: "flex items-center gap-2 tabular-nums",
380
+ children: [/* @__PURE__ */ jsx("svg", {
381
+ width: "20",
382
+ height: "4",
383
+ "aria-hidden": true,
384
+ children: /* @__PURE__ */ jsx("line", {
385
+ x1: "0",
386
+ x2: "20",
387
+ y1: "2",
388
+ y2: "2",
389
+ stroke: s.colour,
390
+ strokeWidth: 4,
391
+ strokeLinecap: "round"
392
+ })
393
+ }), /* @__PURE__ */ jsx("span", { children: `From ${formatValue(s.at)}` })]
394
+ }, s.at))
395
+ })]
396
+ });
397
+ }
398
+ export { RouteMap };
399
+
400
+ //# sourceMappingURL=map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.js","names":[],"sources":["../src/map/map-styles.ts","../src/map/route-map.tsx"],"sourcesContent":["import leafletCss from \"leaflet/dist/leaflet.css?inline\";\n\n// Leaflet draws with its own stylesheet (panes, tiles, controls positioned by class), which an app\n// would otherwise have to import beside strata-react's. That is an install step a component must\n// not need (CLAUDE.md, \"Imports decide the peers\"), so the map puts it in the page itself, once,\n// followed by the few rules that make Leaflet's own parts (zoom buttons, attribution, tooltips)\n// read as the app: its roles, its control height, its radius. The dark treatment is here too, in\n// one place: a map without dark tiles is turned to the dark scheme with a filter, which is a\n// fallback, not a design (an app with a dark tile set passes it as `tiles.dark`).\nconst strata = `\n.strata-map .leaflet-container { background: var(--surface-sunken); color: var(--foreground); font: inherit; }\n.strata-map .leaflet-container:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }\n.strata-map .leaflet-bar { border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; overflow: hidden; }\n.strata-map .leaflet-bar a { background: var(--background); color: var(--foreground); border-bottom: 1px solid var(--border); width: var(--control-h, 2.5rem); height: var(--control-h, 2.5rem); line-height: var(--control-h, 2.5rem); }\n.strata-map .leaflet-control-zoom-in, .strata-map .leaflet-control-zoom-out { font: inherit; font-size: 1.25rem; font-weight: 600; }\n.strata-map .leaflet-bar a:last-child { border-bottom: 0; }\n.strata-map .leaflet-bar a:hover, .strata-map .leaflet-bar a:focus-visible { background: var(--muted); }\n.strata-map .leaflet-bar a.leaflet-disabled { color: var(--muted-foreground); background: var(--background); cursor: not-allowed; }\n.strata-map .leaflet-control-attribution { background: color-mix(in oklab, var(--background) 85%, transparent); color: var(--muted-foreground); font-size: 0.75rem; }\n.strata-map .leaflet-control-attribution a { color: inherit; text-decoration: underline; }\n.strata-map .leaflet-tooltip { background: var(--background); color: var(--foreground); border: 1px solid var(--border); border-radius: var(--radius-control, 4px); box-shadow: none; font: inherit; font-size: 0.8125rem; padding: 0.125rem 0.375rem; }\n.strata-map .leaflet-tooltip::before { display: none; }\n.strata-map[data-dark-treatment] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9); }\n.strata-map .strata-map-arrow { background: none; border: 0; }\n`;\n\nlet installed = false;\n\n/** Puts Leaflet's stylesheet and the token overrides in the document head, once. */\nexport function installMapStyles() {\n if (installed || typeof document === \"undefined\") return;\n installed = true;\n const el = document.createElement(\"style\");\n el.setAttribute(\"data-strata-map\", \"\");\n el.textContent = leafletCss + strata;\n document.head.appendChild(el);\n}\n","import * as React from \"react\";\nimport L from \"leaflet\";\nimport { useColorScheme } from \"../components/theme\";\nimport { cn } from \"../lib/utils\";\nimport { format } from \"../lib/format\";\nimport { geo, type LatLng } from \"../lib/geo\";\nimport { installMapStyles } from \"./map-styles\";\n\n// A themed map of routes with a position that moves along them (strata-react issue #80, from\n// strata-vid's MapPanel and jonathanburnhams.com's activity maps). It is behind its own entry,\n// `strata-react/map`, because Leaflet is heavy and an app that draws no maps should not install it:\n// Leaflet is an optional peer and nothing in the main entry imports it.\n//\n// Leaflet, without react-leaflet (Jonathan's choice, 2026-11-12). react-leaflet binds every layer to\n// a React element, so a position that moves sixty times a second re-renders the route elements\n// beside it; here the map is made once, the routes are one effect that runs only when the routes\n// change, and the position is another that calls `setLatLng` on one marker. A position update\n// touches nothing else: no route is redrawn, none is recreated.\n//\n// What the app supplies, and what the component decides:\n// - Tiles are the app's (`tiles.light`, `tiles.dark`, each with the attribution its provider\n// requires, shown on the map). A dark scheme uses `tiles.dark` when there is one, else the light\n// tiles under a filter (see map-styles.ts); the choice follows the colour scheme.\n// - Colours are roles. A route's colour is any CSS colour (`var(--chart-2)`, `var(--info)`), resolved\n// against the map's own element so SVG strokes, which Leaflet writes as attributes, get a real\n// colour that follows the scheme. Routes default to the chart palette in order.\n// - Colour by value (`values` on a route plus `colourScale`) follows LineChart's rules (§3.8): the\n// colour is a fact of the subject, steps are the app's, and a key names them (`colourScaleLabel`\n// and the step thresholds through `formatValue`) so colour is never the only cue. Runs of one\n// step are drawn as one line, so a long route is a few polylines, not thousands.\n// - One route is the common case: it gets direction chevrons and start and finish marks (a loop is\n// one mark) by default; with several routes those are off unless a route asks.\n// - Fit-to-content happens on first show and when the set of routes changes, not when a route's\n// points are replaced by the same ids, so a person who has zoomed is not thrown back.\n// - Overlay slots, `topEnd` and `bottomStart`, sit where Leaflet puts nothing (it uses the top\n// start for zoom and the bottom end for attribution), so an app's own control or figure never\n// covers a required notice.\n//\n// Keyboard and screen readers. Leaflet's container is a focus stop: arrows pan, + and − zoom. It is\n// named by `label` and described by a text alternative that says what is drawn (each route, its\n// length, whether it is a loop, and how far along the position is), written from the data or given\n// as `summary`. Hovering a route or a mark is a bonus; its facts are in that text. Choosing a route\n// is `onSelect`, and a screen that lets a person choose one lists its routes beside the map (a\n// pointer click on a line has no keyboard equivalent inside Leaflet's SVG, so the list is the path).\n//\n// No animation: zoom, fade and inertia are off, because a map is panned all the time and a tile\n// fade makes a screenshot depend on timing (character by frequency, and strata-visual).\n//\n// Checked: React Aria has no map or geographic part. Leaflet's own keyboard handler and focus are\n// kept as they are.\n\n/** A source of map tiles: a URL template the app's provider documents, and the attribution it requires. */\nexport type TileSource = {\n /** `https://tiles.example.com/{z}/{x}/{y}.png`; `{s}` and `{r}` work as in Leaflet. */\n url: string;\n /** What the provider requires shown (HTML allowed: \"© OpenStreetMap contributors\"). */\n attribution: string;\n subdomains?: string;\n minZoom?: number;\n maxZoom?: number;\n};\n\n/** One route on the map. */\nexport type MapRoute = {\n id: string;\n /** Its name, in the text alternative and on hover (\"Wednesday run\"). */\n label: string;\n points: readonly LatLng[];\n /** Any CSS colour, normally a role (`var(--chart-2)`). Default: the chart palette in order. */\n colour?: string;\n /** Line width in pixels. Default 4. */\n weight?: number;\n /** One value per point, coloured by `colourScale` (speed, elevation, heart rate). */\n values?: readonly number[];\n /** Direction chevrons along the line: true for five, or a count. Default on for a single route. */\n arrows?: boolean | number;\n /** Start and finish marks. Default on for a single route. */\n ends?: boolean;\n};\n\nexport type RouteMapProps = {\n /** Names the map (\"Route of Wednesday's run\"). */\n label: string;\n /** Keep this array stable between renders (state or `useMemo`): the routes are redrawn when it changes, which a moving position must not cause. */\n routes: readonly MapRoute[];\n tiles: { light: TileSource; dark?: TileSource };\n /** Where the moving thing is now. Moved without redrawing any route; null for none. */\n position?: LatLng | null;\n /** What the position is called in the text alternative. Default \"Current position\". */\n positionLabel?: string;\n /** Keep the position in view as it moves. */\n follow?: boolean;\n /** The route drawn heavier, with the others lighter. */\n selectedId?: string | null;\n /** A route line was pressed. Give the app's own list of routes the same action for the keyboard. */\n onSelect?: (id: string) => void;\n /** Step colours for routes that have `values`: a step starts at `at` and runs to the next. */\n colourScale?: readonly { at: number; colour: string }[];\n /** What the colours mean, written in the key (\"Speed\"). */\n colourScaleLabel?: string;\n /** Writes a value in the key and the text alternative (\"12 km/h\"). Default the plain number. */\n formatValue?: (value: number) => string;\n /** Replaces the generated text alternative. */\n summary?: string;\n /** Units for lengths in the generated text. Default metric. */\n units?: \"metric\" | \"imperial\";\n /** Wheel zoom. Off by default so the page still scrolls past the map. */\n scrollZoom?: boolean;\n /** An app control or figure in the top end corner (Leaflet leaves it free). */\n topEnd?: React.ReactNode;\n /** An app legend or figure in the bottom start corner, below the colour key when there is one. */\n bottomStart?: React.ReactNode;\n /** Layout only. The map is 16:9 and at least 16rem tall unless a height is given. */\n className?: string;\n};\n\n/** The smallest and largest value, without spreading the array (a long recording passes the engine's argument limit). */\nfunction extent(values: readonly number[]): [number, number] {\n let lo = Infinity;\n let hi = -Infinity;\n for (const v of values) {\n if (v < lo) lo = v;\n if (v > hi) hi = v;\n }\n return [lo, hi];\n}\n\nconst tuple = (p: LatLng): L.LatLngTuple => [p[0], p[1]];\nconst plain = (v: number) => String(v);\n\n/** `value`, sampled once a second (a throttle, not a debounce: a value that changes every frame still comes through): for text a screen reader may read, which must not change sixty times a second. */\nfunction useSlow<T>(value: T, ms = 1000): T {\n const [slow, setSlow] = React.useState(value);\n const latest = React.useRef(value);\n latest.current = value;\n React.useEffect(() => {\n const id = window.setInterval(() => setSlow(latest.current), ms);\n return () => window.clearInterval(id);\n }, [ms]);\n return slow;\n}\n\nconst PALETTE = [1, 2, 3, 4, 5].map((n) => `var(--chart-${n})`);\n\n/** The colour a CSS value (a `var()`, a role) resolves to on `el`, so an SVG attribute gets a real one. Falls back to the value itself. */\nfunction resolveColour(el: HTMLElement, value: string): string {\n const probe = document.createElement(\"span\");\n probe.style.color = value;\n el.appendChild(probe);\n const resolved = getComputedStyle(probe).color;\n probe.remove();\n return resolved || value;\n}\n\n/** Indices where a run of one step ends, so a coloured route is a few polylines. */\nfunction stepRuns(points: readonly LatLng[], values: readonly number[], stepOf: (v: number) => number) {\n const runs: { from: number; to: number; step: number }[] = [];\n for (let i = 1; i < points.length; i++) {\n const step = stepOf(((values[i - 1] ?? 0) + (values[i] ?? 0)) / 2);\n const last = runs[runs.length - 1];\n if (last && last.step === step) last.to = i;\n else runs.push({ from: i - 1, to: i, step });\n }\n return runs;\n}\n\nconst arrowHtml = (bearing: number, colour: string, halo: string) =>\n `<svg width=\"26\" height=\"26\" viewBox=\"0 0 26 26\" aria-hidden=\"true\" style=\"transform: rotate(${bearing.toFixed(0)}deg)\">` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${halo}\" stroke-width=\"7\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>` +\n `<path d=\"M6 17 L13 9 L20 17\" fill=\"none\" stroke=\"${colour}\" stroke-width=\"3.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/></svg>`;\n\n/** A map of one or more routes with a position that moves along them, on tiles the app supplies, themed from its roles. Leaflet, behind `strata-react/map`. */\nexport function RouteMap({\n label,\n routes,\n tiles,\n position = null,\n positionLabel = \"Current position\",\n follow = false,\n selectedId = null,\n onSelect,\n colourScale,\n colourScaleLabel,\n formatValue = plain,\n summary,\n units = \"metric\",\n scrollZoom = false,\n topEnd,\n bottomStart,\n className,\n}: RouteMapProps) {\n const { scheme } = useColorScheme();\n const host = React.useRef<HTMLDivElement>(null);\n const root = React.useRef<HTMLDivElement>(null);\n const [map, setMap] = React.useState<L.Map | null>(null);\n const summaryId = React.useId();\n const latest = React.useRef({ onSelect });\n latest.current = { onSelect };\n const selectable = Boolean(onSelect);\n const marker = React.useRef<L.CircleMarker | null>(null);\n const markerScheme = React.useRef<string | null>(null);\n\n const darkTiles = scheme === \"dark\" ? tiles.dark : undefined;\n const source = darkTiles ?? tiles.light;\n const treated = scheme === \"dark\" && !tiles.dark;\n const stops = React.useMemo(() => (colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : []), [colourScale]);\n\n // The map, made once. Its container is Leaflet's; React owns only the wrapper around it.\n React.useEffect(() => {\n installMapStyles();\n const el = host.current;\n if (!el) return;\n const m = L.map(el, { scrollWheelZoom: scrollZoom, fadeAnimation: false, zoomAnimation: false, markerZoomAnimation: false, inertia: false, attributionControl: false, zoomSnap: 0.5 });\n L.control.attribution({ prefix: '<a href=\"https://leafletjs.com\">Leaflet</a>' }).addTo(m);\n el.setAttribute(\"aria-roledescription\", \"map\");\n // Leaflet follows the window, not its container; a pane that resizes (a Workspace split) needs the same.\n const ro = new ResizeObserver(() => m.invalidateSize({ animate: false }));\n ro.observe(el);\n setMap(m);\n return () => {\n ro.disconnect();\n marker.current = null;\n markerScheme.current = null;\n m.remove();\n setMap(null);\n };\n // The wheel setting is applied below, so the map is not rebuilt for it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n React.useEffect(() => {\n if (!map) return;\n if (scrollZoom) map.scrollWheelZoom.enable();\n else map.scrollWheelZoom.disable();\n }, [map, scrollZoom]);\n\n // The text alternative: written from the data unless the app gives one. The position is in it, but\n // it is not a live region: a position that moves many times a second must not be announced.\n const spoken = useSlow(position);\n const text = React.useMemo(() => {\n if (summary) return summary;\n if (!routes.length) return \"No routes to show.\";\n const parts = routes.map((r) => {\n const along = geo.cumulative(r.points);\n const total = along[along.length - 1] ?? 0;\n const ends = geo.ends(r.points);\n const shape = ends?.loop ? \", a loop\" : \"\";\n let here = \"\";\n if (spoken && r.points.length) {\n const i = geo.nearest(r.points, spoken);\n here = ` ${positionLabel}: ${format.distance(along[i] ?? 0, units)} along.`;\n }\n let range = \"\";\n if (stops.length && r.values?.length) range = ` ${colourScaleLabel ?? \"Value\"} from ${formatValue(extent(r.values)[0])} to ${formatValue(extent(r.values)[1])}.`;\n return `${r.label}: ${format.distance(total, units)}${shape}.${range}${here}`;\n });\n return `Map with ${routes.length === 1 ? \"one route\" : `${routes.length} routes`}. ${parts.join(\" \")}`;\n }, [summary, routes, spoken, positionLabel, units, stops.length, colourScaleLabel, formatValue]);\n\n React.useEffect(() => {\n if (!map) return;\n const c = map.getContainer();\n c.setAttribute(\"aria-label\", label);\n c.setAttribute(\"aria-describedby\", summaryId);\n }, [map, label, summaryId]);\n\n // Tiles: the light set, or the dark one in the dark scheme.\n React.useEffect(() => {\n if (!map) return;\n const layer = L.tileLayer(source.url, { attribution: source.attribution, subdomains: source.subdomains ?? \"abc\", minZoom: source.minZoom, maxZoom: source.maxZoom ?? 19, keepBuffer: 1 });\n layer.addTo(map);\n return () => void layer.remove();\n }, [map, source.url, source.attribution, source.subdomains, source.minZoom, source.maxZoom]);\n\n // The routes: redrawn when the routes, the scheme (colours resolve differently), the selection or\n // the scale change, and never for a position update.\n React.useEffect(() => {\n if (!map) return;\n const group = L.featureGroup().addTo(map);\n const el = map.getContainer();\n const halo = resolveColour(el, \"var(--background)\");\n const single = routes.length === 1;\n const stepOf = (v: number) => {\n let at = 0;\n stops.forEach((s, i) => {\n if (s.at <= v) at = i;\n });\n return at;\n };\n routes.forEach((route, index) => {\n if (route.points.length < 2) return;\n const base = resolveColour(el, route.colour ?? PALETTE[index % PALETTE.length]);\n const selected = route.id === selectedId;\n const dim = selectedId !== null && !selected;\n const weight = (route.weight ?? 4) + (selected ? 2 : 0);\n const style = { weight, opacity: dim ? 0.55 : 1, lineCap: \"round\" as const, lineJoin: \"round\" as const, interactive: selectable, bubblingMouseEvents: false };\n const lines: L.Polyline[] = [];\n if (stops.length && route.values?.length) {\n for (const run of stepRuns(route.points, route.values, stepOf)) {\n lines.push(L.polyline(route.points.slice(run.from, run.to + 1).map(tuple), { ...style, color: resolveColour(el, stops[run.step].colour) }));\n }\n } else {\n lines.push(L.polyline(route.points.map(tuple), { ...style, color: base }));\n }\n for (const line of lines) {\n line.bindTooltip(route.label, { sticky: true });\n line.on(\"click\", () => latest.current.onSelect?.(route.id));\n line.addTo(group);\n }\n const chevrons = route.arrows === undefined ? (single ? 5 : 0) : route.arrows === true ? 5 : route.arrows === false ? 0 : route.arrows;\n if (chevrons > 0) {\n for (const a of geo.arrows(route.points, chevrons)) {\n L.marker(tuple(a.position), {\n interactive: false,\n keyboard: false,\n icon: L.divIcon({ className: \"strata-map-arrow\", iconSize: [26, 26], iconAnchor: [13, 13], html: arrowHtml(a.bearing, base, halo) }),\n }).addTo(group);\n }\n }\n if (route.ends ?? single) {\n const ends = geo.ends(route.points);\n if (ends) {\n const success = resolveColour(el, \"var(--success)\");\n const danger = resolveColour(el, \"var(--danger)\");\n const mark = (at: LatLng, text: string, options: L.CircleMarkerOptions) => L.circleMarker(tuple(at), { radius: 7, interactive: true, bubblingMouseEvents: false, ...options }).bindTooltip(text).addTo(group);\n // Shapes carry the meaning as well as colour: a filled start, a ringed finish, one of each for a loop.\n if (ends.loop) mark(ends.start, `${route.label}: start and finish`, { color: danger, weight: 3, fillColor: success, fillOpacity: 1 });\n else {\n mark(ends.finish, `${route.label}: finish`, { color: danger, weight: 3, fillColor: halo, fillOpacity: 1 });\n mark(ends.start, `${route.label}: start`, { color: halo, weight: 2, fillColor: success, fillOpacity: 1 });\n }\n }\n }\n });\n return () => void group.remove();\n }, [map, routes, scheme, selectedId, stops, selectable]);\n\n // Fit to the routes when the map first has a size and whenever the set of routes changes.\n const routeKey = routes.map((r) => r.id).join(\"\\n\");\n const fitted = React.useRef<string | null>(null);\n React.useEffect(() => {\n if (!map) return;\n const fit = () => {\n const size = map.getSize();\n if (fitted.current === routeKey || size.x === 0 || size.y === 0) return;\n const box = geo.bounds(routes.flatMap((r) => r.points));\n if (!box) return;\n fitted.current = routeKey;\n map.fitBounds([tuple(box[0]), tuple(box[1])], { padding: [24, 24], animate: false, maxZoom: 17 });\n };\n fit();\n map.on(\"resize\", fit);\n return () => void map.off(\"resize\", fit);\n // `routes` is read when the key says the set changed; a new array of the same ids does not refit.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, routeKey]);\n\n // The position: one marker, moved with `setLatLng`. Nothing else is touched.\n const [lat, lng] = position ?? [null, null];\n React.useEffect(() => {\n if (!map) return;\n if (lat === null || lng === null) {\n marker.current?.remove();\n marker.current = null;\n return;\n }\n const el = map.getContainer();\n if (!marker.current) {\n marker.current = L.circleMarker([lat, lng], { radius: 8, weight: 3, fillOpacity: 1, interactive: false }).addTo(map);\n markerScheme.current = null;\n } else marker.current.setLatLng([lat, lng]);\n if (markerScheme.current !== scheme) {\n markerScheme.current = scheme;\n marker.current.setStyle({ color: resolveColour(el, \"var(--background)\"), fillColor: resolveColour(el, \"var(--primary)\") });\n }\n if (follow && !map.getBounds().pad(-0.2).contains([lat, lng])) map.panTo([lat, lng], { animate: false });\n }, [map, lat, lng, follow, scheme]);\n\n return (\n <div ref={root} data-dark-treatment={treated ? \"\" : undefined} className={cn(\"strata-map relative isolate aspect-video min-h-64 overflow-hidden rounded-surface border border-border\", className)}>\n <div ref={host} className=\"size-full\" />\n <p id={summaryId} className=\"sr-only\">\n {text}\n </p>\n {topEnd && <div className=\"absolute top-2 right-2 z-1000\">{topEnd}</div>}\n {(stops.length > 0 || bottomStart) && (\n <div className=\"absolute bottom-6 left-2 z-1000 grid max-w-[60%] gap-2\">\n {stops.length > 0 && <ColourKey stops={stops} label={colourScaleLabel} formatValue={formatValue} />}\n {bottomStart}\n </div>\n )}\n </div>\n );\n}\n\n/** The key to a colour scale: its name, then each step with where it starts, so colour is never the only cue. */\nfunction ColourKey({ stops, label, formatValue }: { stops: readonly { at: number; colour: string }[]; label?: string; formatValue: (v: number) => string }) {\n return (\n <div className=\"rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground\">\n {label && <p className=\"font-medium\">{label}</p>}\n <ul className=\"grid gap-0.5\">\n {stops.map((s) => (\n <li key={s.at} className=\"flex items-center gap-2 tabular-nums\">\n <svg width=\"20\" height=\"4\" aria-hidden>\n <line x1=\"0\" x2=\"20\" y1=\"2\" y2=\"2\" stroke={s.colour} strokeWidth={4} strokeLinecap=\"round\" />\n </svg>\n <span>{`From ${formatValue(s.at)}`}</span>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":";;;;;;;AASA,IAAM,SAAS;;;;;;;;;;;;;;;;AAiBf,IAAI,YAAY;;AAGhB,SAAgB,mBAAmB;CACjC,IAAI,aAAa,OAAO,aAAa,aAAa;CAClD,YAAY;CACZ,MAAM,KAAK,SAAS,cAAc,OAAO;CACzC,GAAG,aAAa,mBAAmB,EAAE;CACrC,GAAG,cAAc,aAAa;CAC9B,SAAS,KAAK,YAAY,EAAE;AAC9B;;;ACiFA,SAAS,OAAO,QAA6C;CAC3D,IAAI,KAAK;CACT,IAAI,KAAK;CACT,KAAK,MAAM,KAAK,QAAQ;EACtB,IAAI,IAAI,IAAI,KAAK;EACjB,IAAI,IAAI,IAAI,KAAK;CACnB;CACA,OAAO,CAAC,IAAI,EAAE;AAChB;AAEA,IAAM,SAAS,MAA6B,CAAC,EAAE,IAAI,EAAE,EAAE;AACvD,IAAM,SAAS,MAAc,OAAO,CAAC;;AAGrC,SAAS,QAAW,OAAU,KAAK,KAAS;CAC1C,MAAM,CAAC,MAAM,WAAW,MAAM,SAAS,KAAK;CAC5C,MAAM,SAAS,MAAM,OAAO,KAAK;CACjC,OAAO,UAAU;CACjB,MAAM,gBAAgB;EACpB,MAAM,KAAK,OAAO,kBAAkB,QAAQ,OAAO,OAAO,GAAG,EAAE;EAC/D,aAAa,OAAO,cAAc,EAAE;CACtC,GAAG,CAAC,EAAE,CAAC;CACP,OAAO;AACT;AAEA,IAA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