strata-react 1.0.33 → 1.0.35
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/README.md +12 -2
- package/UPGRADING.md +1 -0
- package/dist/components/conversation.d.ts +67 -0
- package/dist/components/dialog.d.ts +1 -1
- package/dist/components/folder-picker.d.ts +42 -0
- package/dist/components/lightbox.d.ts +34 -0
- package/dist/components/markable-text.d.ts +56 -0
- package/dist/components/media-group.d.ts +25 -0
- package/dist/components/media-player.d.ts +80 -2
- package/dist/components/region-editor.d.ts +55 -0
- package/dist/components/sequence-timeline.d.ts +50 -0
- package/dist/components/transcript-view.d.ts +36 -0
- package/dist/components/tree.d.ts +41 -0
- package/dist/components/waveform.d.ts +66 -0
- package/dist/{cursor-DplHNzj3.js → cursor-DDGBPiTJ.js} +2 -200
- package/dist/cursor-DDGBPiTJ.js.map +1 -0
- package/dist/field-7Z4N5r5g.js +178 -0
- package/dist/field-7Z4N5r5g.js.map +1 -0
- package/dist/format-B32-PVi2.js +201 -0
- package/dist/format-B32-PVi2.js.map +1 -0
- package/dist/hls/index.d.ts +19 -0
- package/dist/hls.js +84 -0
- package/dist/hls.js.map +1 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.js +3454 -568
- package/dist/index.js.map +1 -1
- package/dist/lib/marks.d.ts +6 -0
- package/dist/lib/region.d.ts +46 -0
- package/dist/lib/rich-text.d.ts +44 -0
- package/dist/lib/sequence.d.ts +34 -0
- package/dist/lib/transcript.d.ts +28 -0
- package/dist/lib/waveform.d.ts +36 -0
- package/dist/map.js +4 -2
- package/dist/map.js.map +1 -1
- package/dist/panorama/gl.d.ts +16 -0
- package/dist/panorama/index.d.ts +2 -0
- package/dist/panorama/panorama-viewer.d.ts +56 -0
- package/dist/panorama/projection.d.ts +45 -0
- package/dist/panorama.js +657 -0
- package/dist/panorama.js.map +1 -0
- package/dist/{query-DgJMyXTT.js → query-BJcxJLhh.js} +3 -2
- package/dist/{query-DgJMyXTT.js.map → query-BJcxJLhh.js.map} +1 -1
- package/dist/{run-BqZGKhW9.js → run-DzyLrZlA.js} +23 -5
- package/dist/run-DzyLrZlA.js.map +1 -0
- package/dist/testing.js +2 -2
- package/dist/{theme-BgTOESmN.js → theme-CFNi6WUO.js} +5 -175
- package/dist/theme-CFNi6WUO.js.map +1 -0
- package/dist/value-controls-D6O9TsM6.js +356 -0
- package/dist/value-controls-D6O9TsM6.js.map +1 -0
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +19 -4
- package/dist/cursor-DplHNzj3.js.map +0 -1
- package/dist/run-BqZGKhW9.js.map +0 -1
- package/dist/theme-BgTOESmN.js.map +0 -1
package/dist/map.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","names":["Tooltip","AriaButton","_Fragment"],"sources":["../src/map/map-styles.ts","../src/map/fan.ts","../src/map/markers.tsx","../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.strata-map .strata-map-marker, .strata-map .strata-map-crosshair { background: none; border: 0; display: grid; place-items: center; }\n.strata-map .strata-map-reset { display: grid; place-items: center; }\n.strata-map .strata-map-picking, .strata-map .strata-map-picking .leaflet-interactive { cursor: crosshair; }\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","// Markers that would sit on top of each other are moved apart in a small fan (strata-react issue #181).\n// Pure maths on pixel positions, no map and no DOM, so the rule can be tested and so a frame is the\n// same everywhere. The positions are in the map's *world* pixels at the current zoom (not the screen's),\n// so panning never changes the result, only zooming does, and zooming in is what settles the fan.\n//\n// Rules: markers within `gap` pixels of each other, directly or through a chain of neighbours\n// (single linkage), form one group. A group of two to six goes on one circle just wide enough that\n// neighbours are `gap` apart; a larger group fills rings of radius gap, 2 gap, 3 gap… each holding as\n// many as fit, so forty markers on one spot make a tidy rosette, not one huge circle. The first marker\n// of a group (input order) goes straight up and the rest follow clockwise: the same input always gives the\n// same output. A lone marker does not move.\n\n/** A marker's true place in world pixels. */\nexport type FanInput = { id: string; x: number; y: number };\n/** Where it is drawn; `fanned` is true when that is not its true place (draw a leader line back). */\nexport type FanOutput = { id: string; x: number; y: number; fanned: boolean };\n\n/** Move apart markers closer than `gap` pixels. Output is in input order. */\nexport function fanOut(items: readonly FanInput[], gap = 26): FanOutput[] {\n const parent = items.map((_, i) => i);\n const find = (i: number): number => (parent[i] === i ? i : (parent[i] = find(parent[i])));\n // A grid of `gap`-sized cells, so each marker is compared with its neighbours and not with all 500.\n const cells = new Map<string, number[]>();\n const key = (cx: number, cy: number) => `${cx},${cy}`;\n items.forEach((p, i) => {\n const [cx, cy] = [Math.floor(p.x / gap), Math.floor(p.y / gap)];\n for (let dx = -1; dx <= 1; dx++)\n for (let dy = -1; dy <= 1; dy++)\n for (const j of cells.get(key(cx + dx, cy + dy)) ?? []) {\n if (Math.hypot(items[j].x - p.x, items[j].y - p.y) < gap) parent[find(i)] = find(j);\n }\n const own = cells.get(key(cx, cy));\n if (own) own.push(i);\n else cells.set(key(cx, cy), [i]);\n });\n const groups = new Map<number, number[]>();\n items.forEach((_, i) => {\n const r = find(i);\n const g = groups.get(r);\n if (g) g.push(i);\n else groups.set(r, [i]);\n });\n const out: FanOutput[] = items.map((p) => ({ id: p.id, x: p.x, y: p.y, fanned: false }));\n for (const members of groups.values()) {\n const n = members.length;\n if (n < 2) continue;\n const cx = members.reduce((s, i) => s + items[i].x, 0) / n;\n const cy = members.reduce((s, i) => s + items[i].y, 0) / n;\n const place = (i: number, radius: number, angle: number) => {\n out[i] = { id: items[i].id, x: cx + radius * Math.sin(angle), y: cy - radius * Math.cos(angle), fanned: true };\n };\n if (n <= 6) {\n const radius = gap / (2 * Math.sin(Math.PI / n));\n members.forEach((i, k) => place(i, radius, (2 * Math.PI * k) / n));\n } else {\n let k = 0;\n for (let ring = 1; k < n; ring++) {\n const radius = ring * gap;\n const fit = Math.max(1, Math.floor((2 * Math.PI * radius) / gap));\n const here = Math.min(fit, n - k);\n for (let m = 0; m < here; m++) place(members[k + m], radius, (2 * Math.PI * m) / here);\n k += here;\n }\n }\n }\n return out;\n}\n","import * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport L from \"leaflet\";\nimport { Button as AriaButton } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { geo, type LatLng } from \"../lib/geo\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { fanOut } from \"./fan\";\n\n// Item markers on a map (strata-react issue #181, from strata-360's race map: a marker for every clip at\n// the middle of its stretch of track, the stretch drawn heavier, overlapping markers fanned apart, a card\n// on hover, a click that opens the clip). What is decided here and why:\n//\n// - **Each marker is a real control.** A React Aria `Button` portalled into the DOM node of a Leaflet\n// marker (a `divIcon` whose `html` is that node), so Leaflet keeps it where the map puts it while React\n// owns what it is: named by its label, pressed with a click, Enter or Space, a `Tooltip` on hover and\n// focus. Not Leaflet's popup, which is not a Strata surface and not reachable the same way.\n// - **One tab stop for all of them**, arrows (and Home and End) between them, in the order the app gave:\n// forty markers must not be forty tab stops. The map's own keyboard stays: the markers are a roving\n// group inside it, and the app's list of items beside the map is still the full keyboard path.\n// - **Only what is near the screen is drawn.** Each time the view settles the markers within the view\n// (plus a margin, so a fan is not cut at the edge) are laid out and the rest are not in the DOM, so 500\n// markers cost what the visible ones cost.\n// - **The fan is a pure function of the zoom** (`fanOut`, fan.ts): in world pixels, so panning never moves\n// it and zooming in settles it; a leader line joins each fanned marker to its true place.\n// - **States are shapes as well as colour**: a plain circle, a ringed larger one for selected, a diamond for\n// highlighted by the app (the newest draft's choice). The key names each one that is on the map.\n//\n// Checked: React Aria has no map part; `Button` and the Strata `Tooltip` are used as they are.\n\n/** The words the key uses for each marker state. */\nexport type MarkerKeyWords = { marker?: string; selected?: string; highlighted?: string };\n\n/** An item on the map: a place, or a stretch of a route (drawn heavier, the marker at its middle). */\nexport type MapMarker = {\n /** Stable between renders. */\n id: string;\n /** A place, or a stretch of a route between two distances along it (metres). */\n at: LatLng | { routeId: string; from: number; to: number };\n /** Its name: the button's accessible name and the card's default words. */\n label: string;\n selected?: boolean;\n /** Marked by the app (a diamond): the newest draft's choice, a flagged item. */\n highlighted?: boolean;\n /** Any CSS colour, normally a role; overrides the state's. */\n colour?: string;\n};\n\n/** A marker with where it really is and where it is drawn. */\nexport type Placed = { marker: MapMarker; at: LatLng; shown: LatLng; fanned: boolean };\n\nconst alongCache = new WeakMap<readonly LatLng[], number[]>();\n/** The running distance at each point of a route, kept per route array so a long route is walked once. */\nexport function alongOf(points: readonly LatLng[]): number[] {\n let a = alongCache.get(points);\n if (!a) {\n a = geo.cumulative(points);\n alongCache.set(points, a);\n }\n return a;\n}\n\n/** Where a marker really is: its place, or the middle of its stretch. Null when its route is not on the map. */\nexport function markerPlace(m: MapMarker, routes: readonly { id: string; points: readonly LatLng[] }[]): LatLng | null {\n if (Array.isArray(m.at)) return m.at as LatLng;\n const at = m.at as { routeId: string; from: number; to: number };\n const route = routes.find((r) => r.id === at.routeId);\n return route ? geo.pointAlong(route.points, (at.from + at.to) / 2, alongOf(route.points)) : null;\n}\n\n/** The markers near the view, with the overlapping ones fanned apart for this zoom. */\nexport function placeMarkers(map: L.Map, markers: readonly MapMarker[], routes: readonly { id: string; points: readonly LatLng[] }[]): Placed[] {\n const near = map.getBounds().pad(0.25);\n const zoom = map.getZoom();\n const here: { marker: MapMarker; at: LatLng }[] = [];\n for (const marker of markers) {\n const at = markerPlace(marker, routes);\n if (at && near.contains([at[0], at[1]])) here.push({ marker, at });\n }\n const fanned = fanOut(here.map((h) => ({ id: h.marker.id, ...map.project([h.at[0], h.at[1]], zoom) })));\n return here.map((h, i) => {\n const f = fanned[i];\n const shown = f.fanned ? map.unproject([f.x, f.y], zoom) : null;\n return { marker: h.marker, at: h.at, shown: shown ? ([shown.lat, shown.lng] as LatLng) : h.at, fanned: f.fanned };\n });\n}\n\nconst state = (m: MapMarker) => (m.highlighted ? \"highlighted\" : m.selected ? \"selected\" : \"marker\");\n\ntype PinProps = {\n map: L.Map;\n placed: Placed;\n active: boolean;\n onActivate: (id: string) => void;\n onMove: (id: string, to: \"next\" | \"previous\" | \"first\" | \"last\") => void;\n register: (id: string, el: HTMLElement | null) => void;\n onSelect?: (id: string) => void;\n card?: (m: MapMarker) => React.ReactNode;\n};\n\n/** One marker: a Leaflet marker holding a node that React fills with a labelled button. */\nfunction Pin({ map, placed, active, onActivate, onMove, register, onSelect, card }: PinProps) {\n const { marker, shown } = placed;\n const host = React.useMemo(() => {\n const el = document.createElement(\"div\");\n el.className = \"strata-map-pin\";\n return el;\n }, []);\n const layer = React.useRef<L.Marker | null>(null);\n React.useEffect(() => {\n const m = L.marker([shown[0], shown[1]], { icon: L.divIcon({ className: \"strata-map-marker\", html: host, iconSize: [28, 28], iconAnchor: [14, 14] }), interactive: false, keyboard: false }).addTo(map);\n layer.current = m;\n return () => {\n layer.current = null;\n m.remove();\n };\n // Made once per pin; where it is and how high it sits are updated below.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, host]);\n React.useEffect(() => {\n layer.current?.setLatLng([shown[0], shown[1]]);\n }, [shown]);\n React.useEffect(() => {\n layer.current?.setZIndexOffset(marker.selected ? 1000 : marker.highlighted ? 500 : 0);\n }, [marker.selected, marker.highlighted]);\n const kind = state(marker);\n const swatch = marker.colour ?? (kind === \"highlighted\" ? \"var(--success)\" : kind === \"selected\" ? \"var(--foreground)\" : \"var(--primary)\");\n return createPortal(\n <Tooltip label={card ? card(marker) : marker.label} side=\"top\">\n <AriaButton\n ref={(el) => register(marker.id, el)}\n aria-label={marker.label}\n aria-pressed={marker.selected ?? false}\n excludeFromTabOrder={!active}\n onFocus={() => onActivate(marker.id)}\n onPress={() => onSelect?.(marker.id)}\n onKeyDown={(e) => {\n const to = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? \"next\" : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? \"previous\" : e.key === \"Home\" ? \"first\" : e.key === \"End\" ? \"last\" : null;\n if (!to) return;\n e.preventDefault();\n e.stopPropagation();\n onMove(marker.id, to);\n }}\n className=\"pointer-events-auto grid size-7 cursor-pointer place-items-center rounded-pill outline-offset-1 focus-visible:outline-2 focus-visible:outline-ring\"\n >\n <Shape kind={kind} colour={swatch} />\n </AriaButton>\n </Tooltip>,\n host,\n );\n}\n\n/** The drawn shape of a marker state: a circle, a ringed larger circle, a diamond. Shapes carry the meaning as colour does. */\nfunction Shape({ kind, colour }: { kind: \"marker\" | \"selected\" | \"highlighted\"; colour: string }) {\n return (\n <span\n aria-hidden\n className={cn(\"block border-2 border-background\", kind === \"highlighted\" ? \"size-3.5 rotate-45 rounded-sm\" : \"rounded-pill\", kind === \"selected\" ? \"size-4 ring-2 ring-foreground\" : kind === \"marker\" ? \"size-3.5\" : \"\")}\n style={{ background: colour }}\n />\n );\n}\n\ntype LayerProps = {\n map: L.Map;\n placed: readonly Placed[];\n onSelect?: (id: string) => void;\n card?: (m: MapMarker) => React.ReactNode;\n};\n\n/** The pins for the markers near the view, as one roving group: one tab stop, arrows between them. */\nexport function MarkerLayer({ map, placed, onSelect, card }: LayerProps) {\n const [activeId, setActiveId] = React.useState<string | null>(null);\n const els = React.useRef(new Map<string, HTMLElement>());\n const ids = placed.map((p) => p.marker.id);\n const active = activeId !== null && ids.includes(activeId) ? activeId : (ids[0] ?? null);\n const register = React.useCallback((id: string, el: HTMLElement | null) => {\n if (el) els.current.set(id, el);\n else els.current.delete(id);\n }, []);\n const move = (id: string, to: \"next\" | \"previous\" | \"first\" | \"last\") => {\n const i = ids.indexOf(id);\n const next = to === \"first\" ? 0 : to === \"last\" ? ids.length - 1 : Math.min(ids.length - 1, Math.max(0, i + (to === \"next\" ? 1 : -1)));\n setActiveId(ids[next]);\n els.current.get(ids[next])?.focus();\n };\n return (\n <>\n {placed.map((p) => (\n <Pin key={p.marker.id} map={map} placed={p} active={p.marker.id === active} onActivate={setActiveId} onMove={move} register={register} onSelect={onSelect} card={card} />\n ))}\n </>\n );\n}\n\n/** The key to the marker states that are on the map, each with its shape and its words. */\nexport function MarkerKey({ markers, words }: { markers: readonly MapMarker[]; words?: MarkerKeyWords }) {\n const kinds = ([\"marker\", \"selected\", \"highlighted\"] as const).filter((k) => markers.some((m) => state(m) === k));\n const text = { marker: words?.marker ?? \"Item\", selected: words?.selected ?? \"Selected\", highlighted: words?.highlighted ?? \"Highlighted\" };\n if (!kinds.length) return null;\n return (\n <div className=\"rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground\">\n <ul className=\"grid gap-0.5\">\n {kinds.map((k) => (\n <li key={k} className=\"flex items-center gap-2\">\n <span className=\"grid size-4 place-items-center\">\n <Shape kind={k} colour={k === \"highlighted\" ? \"var(--success)\" : k === \"selected\" ? \"var(--foreground)\" : \"var(--primary)\"} />\n </span>\n {text[k]}\n </li>\n ))}\n </ul>\n </div>\n );\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\";\nimport { useSharedCursor } from \"../components/cursor\";\nimport { MarkerKey, MarkerLayer, alongOf, placeMarkers, type MapMarker, type MarkerKeyWords } from \"./markers\";\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// Map as picture content (issue #161, from strata-vid, where a route inset is composed over footage and\n// must look the same on every frame as in an export drawn on a canvas). Three additions, none of which\n// changes a page map: `zoom` sets the zoom from outside (any number, so an animation is a prop that\n// changes every frame; unset keeps fit-to-routes), `follow=\"centre\"` holds the view on a position at that\n// zoom, and `positions` draws several moving positions, each tied to a route and drawn in its colour.\n// Centred follow pans to a whole-pixel view worked out from the position and zoom alone (`centre`), with\n// no animation: Leaflet's own centred pan truncates each step, so where the view ended up would depend\n// on the path it took; this depends only on the position and zoom, which is what makes frame N the same\n// picture however it was reached. A `reset` would give the same view but empties the tile layer on every\n// call, which flickers at one update per frame.\n// Fractional zoom needs `zoomSnap: 0`, which is set only while `zoom` is controlled, so a page map still\n// snaps to half steps. Each marker is one `L.CircleMarker` kept by id and moved with `setLatLng`.\n//\n// The map as an instrument, not only a picture (strata-react issues #181, #182, #184):\n// - `markers`: items on the route as controls with cards, fanned apart (markers.tsx).\n// - `onViewChange`: the visible bounds and zoom, once when movement settles (debounced `settle` ms), and\n// not for a move the app made through its own props (`zoom`, `view`, `follow`, the first fit), which it\n// already knows about: every move the component makes itself runs inside `silently`, and Leaflet's events\n// are synchronous with animation off, so the flag cannot leak. `reportAppMoves` turns that off.\n// - `view` restores a saved view; the person's own moves go out through `onViewChange`. A reset control\n// in Leaflet's own control group fits the routes again (or sets the zoom, when one is controlled).\n// - `picking` + `onPick`: choose a place. Pointer: a click. Keyboard: arrows move a crosshair (Shift for\n// bigger steps), Enter chooses, Escape asks to cancel; Leaflet's own arrow handling is switched off for\n// the time, since both would move. The result is announced with the nearest route, how far along it and\n// how far off (`geo.snap`). Route lines stop taking clicks while picking, or a pick near the route would\n// select the route instead. A click when not picking does nothing new.\n// - `cursor`: joins a `CursorScope` (cursor.tsx). The scope's unit here is metres along one route; a\n// pointer near the route (within 24 px of it) writes the distance of the nearest point on it, and\n// another member's distance is drawn as a ring on the route. Never drawn back at its own writer.\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\n/** One moving position, for a map with more than one (two runners on the same loop). */\nexport type MapPosition = {\n /** Stable between renders: the marker is kept by it and moved, never recreated. */\n id: string;\n /** Where it is now; null hides it. */\n at: LatLng | null;\n /** What it is called in the text alternative (\"Runner A\"). */\n label: string;\n /** The route it travels. Its marker takes that route's colour and the text alternative says how far along it is. */\n routeId?: string;\n /** Any CSS colour, normally a role. Overrides the route's. Default: the route's colour, else the theme's primary. */\n colour?: string;\n};\n\n/** The view the map settled on. */\nexport type MapView = { bounds: [LatLng, LatLng]; zoom: number; center: LatLng };\n\n/** The route nearest a picked place. */\nexport type PickNearest = {\n routeId: string;\n /** The leg of the route (its first point's index) the place is nearest. */\n index: number;\n /** How far the place is from the route, in metres. */\n distanceM: number;\n /** How far along the route the nearest point is, in metres. */\n alongM: number;\n /** The nearest point on the route. */\n position: LatLng;\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 /** More moving positions, each in its route's colour and named in the text alternative. Moved without redrawing any route; `position` may be used beside them. */\n positions?: readonly MapPosition[];\n /** Which position `follow` tracks: a `positions` id. Default `position`, else the first of `positions` that is shown. */\n followId?: string;\n /** `true` pans only when the position leaves the inner 80% of the view; `\"centre\"` keeps it exactly in the centre on every update, with no animation (a frame is deterministic), at `zoom` when that is set, else the zoom the map has. */\n follow?: boolean | \"centre\";\n /** The zoom level, any number (12, 14.5): it may change every frame without redrawing routes. Unset, the map fits its routes and the person zooms. */\n zoom?: number;\n /** Items on the map: places, or stretches of a route. Keep the array stable between renders. */\n markers?: readonly MapMarker[];\n /** A marker was pressed (click, Enter or Space). */\n onMarkerSelect?: (id: string) => void;\n /** The words shown beside a marker on hover and focus (as `Tooltip`; not interactive). Default its label. */\n renderMarkerCard?: (marker: MapMarker) => React.ReactNode;\n /** The words of the marker key; `false` leaves the key out. */\n markerKey?: MarkerKeyWords | false;\n /** Join the nearest `CursorScope`: a pointer near a route puts its distance along it in every member, and another member's distance shows as a ring on the route. `{ routeId }` picks the route (default the first). */\n cursor?: boolean | { routeId?: string };\n /** The view settled after the person moved or zoomed it: bounds, zoom and centre. Not called for moves the app caused through props. */\n onViewChange?: (view: MapView) => void;\n /** Milliseconds the view must be still before `onViewChange`. Default 250. */\n settle?: number;\n /** Also call `onViewChange` for moves the app caused through props (the first fit, `zoom`, `view`, `follow`). */\n reportAppMoves?: boolean;\n /** A view to show: centre and zoom, as a saved view or the app's own. The person can still move away from it; set it again to go back. Wins over fitting the routes. */\n view?: { center: LatLng; zoom: number };\n /** Choose a place on the map. While set, a click or Enter picks and route lines do not take clicks. */\n picking?: boolean;\n /** A place was chosen, with the nearest route to it when there is one. */\n onPick?: (at: LatLng, info: { nearest: PickNearest | null }) => void;\n /** Escape was pressed while picking: the app turns `picking` off. */\n onPickCancel?: () => void;\n /** The banner for pick mode (\"Click the map to set the point; Escape cancels\"), shown top centre. */\n pickBanner?: React.ReactNode;\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\n/** How many moves of the map the component itself is making right now (see `onViewChange`). */\nconst quiet = new WeakMap<L.Map, number>();\n/** Run a move the component makes itself, so `onViewChange` does not report it. Leaflet's events are synchronous with animation off. */\nfunction silently<T>(map: L.Map, fn: () => T): T {\n quiet.set(map, (quiet.get(map) ?? 0) + 1);\n try {\n return fn();\n } finally {\n quiet.set(map, (quiet.get(map) ?? 1) - 1);\n }\n}\n\n/** The route nearest a place, by distance from it to the route (not to a vertex). */\nfunction nearestRoute(routes: readonly MapRoute[], at: LatLng): PickNearest | null {\n let best: PickNearest | null = null;\n for (const r of routes) {\n const s = geo.snap(r.points, at, alongOf(r.points));\n if (s && (!best || s.offset < best.distanceM)) best = { routeId: r.id, index: s.index, distanceM: s.offset, alongM: s.metres, position: s.position };\n }\n return best;\n}\n\nconst RESET_ICON = '<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4\"/></svg>';\nconst CROSS_ICON = '<svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" aria-hidden=\"true\" fill=\"none\" stroke-linecap=\"round\"><path d=\"M16 4v24M4 16h24\" stroke=\"var(--background)\" stroke-width=\"5\"/><path d=\"M16 4v24M4 16h24\" stroke=\"var(--foreground)\" stroke-width=\"2\"/></svg>';\n\n/** Leaflet's control group gets a reset: fit the routes again. A link with a button role, as Leaflet's own zoom buttons are. */\nfunction resetControl(onReset: () => void): L.Control {\n const control = new L.Control({ position: \"topleft\" });\n control.onAdd = () => {\n const bar = L.DomUtil.create(\"div\", \"leaflet-bar leaflet-control\");\n const a = L.DomUtil.create(\"a\", \"strata-map-reset\", bar);\n a.href = \"#\";\n a.setAttribute(\"role\", \"button\");\n a.setAttribute(\"aria-label\", \"Reset view\");\n a.title = \"Reset view\";\n a.innerHTML = RESET_ICON;\n L.DomEvent.disableClickPropagation(bar);\n L.DomEvent.on(a, \"click\", (e) => {\n L.DomEvent.preventDefault(e);\n onReset();\n });\n L.DomEvent.on(a, \"keydown\", (e) => {\n if ((e as KeyboardEvent).key === \" \") {\n L.DomEvent.preventDefault(e);\n onReset();\n }\n });\n return bar;\n };\n return control;\n}\n\n/** Put the routes in view (or, with a zoom set, centre the routes at it). */\nfunction showRoutes(map: L.Map, routes: readonly MapRoute[], zoom: number | undefined) {\n const box = geo.bounds(routes.flatMap((r) => r.points));\n if (!box) return false;\n if (zoom !== undefined) map.setView([(box[0][0] + box[1][0]) / 2, (box[0][1] + box[1][1]) / 2], zoom, { animate: false });\n else map.fitBounds([tuple(box[0]), tuple(box[1])], { padding: [24, 24], animate: false, maxZoom: 17 });\n return true;\n}\n\nconst SINGLE = \"\\u0000position\";\nconst PALETTE = [1, 2, 3, 4, 5].map((n) => `var(--chart-${n})`);\n\n/**\n * Put `target` in the exact middle of the view at zoom `z`, with no animation and without throwing the\n * loaded tiles away. A zoom change goes through `setView` (Leaflet redraws its tiles then anyway). The\n * position is then set by panning to a whole-pixel top-left worked out from the target and the zoom\n * alone, so where the view ends up does not depend on the path taken (Leaflet's own centred pan\n * truncates each step and drifts); a `reset` would be exact too but empties the tile layer on every\n * call, which flickers when the position changes every frame.\n */\nfunction centre(map: L.Map, target: LatLng, z: number) {\n silently(map, () => {\n if (map.getZoom() !== z) map.setView(tuple(target), z, { animate: false });\n const want = map.project(tuple(target), z).subtract(map.getSize().divideBy(2)).round();\n const have = map.getPixelBounds().min!.round();\n const move = want.subtract(have);\n if (move.x || move.y) map.panBy(move, { animate: false, noMoveStart: true });\n });\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 positions,\n followId,\n follow = false,\n zoom,\n markers,\n onMarkerSelect,\n renderMarkerCard,\n markerKey,\n cursor: cursorProp,\n onViewChange,\n settle = 250,\n reportAppMoves = false,\n view,\n picking = false,\n onPick,\n onPickCancel,\n pickBanner,\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, onViewChange, reportAppMoves, settle, picking, onPick, onPickCancel, routes, units, view, zoom });\n latest.current = { onSelect, onViewChange, reportAppMoves, settle, picking, onPick, onPickCancel, routes, units, view, zoom };\n const [announced, setAnnounced] = React.useState(\"\");\n // True once the map has a view (the first fit has happened): before that Leaflet cannot say what is near.\n const [ready, setReady] = React.useState(false);\n const selectable = Boolean(onSelect);\n // One marker per position, by id, with the style last applied so a moving marker is not restyled every frame.\n const posMarkers = React.useRef(new Map<string, { marker: L.CircleMarker; style: string }>());\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 posMarkers.current.clear();\n m.remove();\n setMap(null);\n setReady(false);\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 // A zoom set from outside is any number; Leaflet snaps to `zoomSnap`, so it is 0 while zoom is controlled.\n const zoomed = zoom !== undefined;\n React.useEffect(() => {\n if (map) map.options.zoomSnap = zoomed ? 0 : 0.5;\n }, [map, zoomed]);\n\n // Every position on the map, the single `position` first: what is spoken, drawn and followed.\n const all = React.useMemo<MapPosition[]>(() => [...(position ? [{ id: SINGLE, at: position, label: positionLabel }] : []), ...(positions ?? [])], [position, positionLabel, positions]);\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(all);\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 // A position tied to another route is not on this one; one tied to no route is described along each.\n for (const p of spoken) {\n if (!p.at || !r.points.length || (p.routeId !== undefined && p.routeId !== r.id && routes.some((o) => o.id === p.routeId))) continue;\n here += ` ${p.label}: ${format.distance(along[geo.nearest(r.points, p.at)] ?? 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 const items = markers?.length ? ` ${markers.length === 1 ? \"One marker\" : `${markers.length} markers`}${markers.some((m) => m.selected) ? `, selected: ${markers.filter((m) => m.selected).map((m) => m.label).join(\", \")}` : \"\"}.` : \"\";\n return `Map with ${routes.length === 1 ? \"one route\" : `${routes.length} routes`}. ${parts.join(\" \")}${items}`;\n }, [summary, routes, spoken, units, stops.length, colourScaleLabel, formatValue, markers]);\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 && !picking, 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 // Redrawn routes are new layers: keep the positions above them.\n for (const { marker } of posMarkers.current.values()) marker.bringToFront();\n return () => void group.remove();\n }, [map, routes, scheme, selectedId, stops, selectable, picking]);\n\n // The position a followed view is held on: read by the fit (a map shown for the first time starts\n // centred on it) and by the position effect.\n const target = React.useMemo(() => {\n if (!follow) return null;\n const shown = all.filter((p) => p.at);\n return (followId ? shown.find((p) => p.id === followId) : shown[0])?.at ?? null;\n }, [all, follow, followId]);\n const latestView = React.useRef({ target, zoom, centred: follow === \"centre\" });\n latestView.current = { target, zoom, centred: follow === \"centre\" };\n\n // Fit to the routes when the map first has a size and whenever the set of routes changes. With a\n // zoom set there is nothing to fit: the view is placed at that zoom, on the followed position when\n // the map is centred on one, else on the middle of the routes.\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 if (!geo.bounds(routes.flatMap((r) => r.points)) && !latest.current.view) return;\n fitted.current = routeKey;\n const v = latestView.current;\n setReady(true);\n // A given view wins, then a set zoom (on the followed position, or the routes' middle), then the routes.\n silently(map, () => {\n if (latest.current.view) map.setView(tuple(latest.current.view.center), latest.current.view.zoom, { animate: false });\n else if (v.zoom !== undefined && v.centred && v.target) map.setView(tuple(v.target), v.zoom, { animate: false });\n else showRoutes(map, latest.current.routes, v.zoom);\n });\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 // A zoom that changes after the first view (an animation) moves the zoom about the view's centre.\n React.useEffect(() => {\n if (map && zoom !== undefined && fitted.current !== null && map.getZoom() !== zoom) silently(map, () => map.setZoom(zoom, { animate: false }));\n }, [map, zoom]);\n\n // The positions: one marker each, kept by id and moved with `setLatLng`. No route is touched.\n React.useEffect(() => {\n if (!map) return;\n const el = map.getContainer();\n const live = posMarkers.current;\n const seen = new Set<string>();\n for (const p of all) {\n if (!p.at) continue;\n seen.add(p.id);\n let entry = live.get(p.id);\n if (!entry) {\n entry = { marker: L.circleMarker(tuple(p.at), { radius: 8, weight: 3, fillOpacity: 1, interactive: false }).addTo(map), style: \"\" };\n live.set(p.id, entry);\n } else entry.marker.setLatLng(tuple(p.at));\n const index = routes.findIndex((r) => r.id === p.routeId);\n const spec = p.colour ?? (index >= 0 ? (routes[index].colour ?? PALETTE[index % PALETTE.length]) : \"var(--primary)\");\n const style = `${scheme}|${spec}`;\n if (entry.style !== style) {\n entry.style = style;\n entry.marker.setStyle({ color: resolveColour(el, \"var(--background)\"), fillColor: resolveColour(el, spec) });\n }\n }\n for (const [id, entry] of live) {\n if (seen.has(id)) continue;\n entry.marker.remove();\n live.delete(id);\n }\n if (!target) return;\n if (follow === \"centre\") {\n // Before the first fit with no zoom set there is no zoom to hold; the fit places the view.\n const z = zoom ?? (fitted.current === null ? undefined : map.getZoom());\n if (z !== undefined) centre(map, target, z);\n } else if (!map.getBounds().pad(-0.2).contains(tuple(target))) silently(map, () => map.panTo(tuple(target), { animate: false }));\n }, [map, all, routes, scheme, follow, target, zoom]);\n\n // The reset control: fit the routes again, as the person's own move (so it is reported).\n React.useEffect(() => {\n if (!map) return;\n const control = resetControl(() => {\n const view = latest.current.view;\n if (view) map.setView(tuple(view.center), view.zoom, { animate: false });\n else showRoutes(map, latest.current.routes, latest.current.zoom);\n });\n control.addTo(map);\n return () => void control.remove();\n }, [map]);\n\n // The view, reported once it settles: the person's moves, not the app's own (unless asked).\n React.useEffect(() => {\n if (!map) return;\n let timer: number | undefined;\n const send = () => {\n timer = undefined;\n const b = map.getBounds();\n const c = map.getCenter();\n latest.current.onViewChange?.({ bounds: [[b.getSouth(), b.getWest()], [b.getNorth(), b.getEast()]], zoom: map.getZoom(), center: [c.lat, c.lng] });\n };\n const moved = () => {\n if (!latest.current.onViewChange) return;\n if (!latest.current.reportAppMoves && (quiet.get(map) ?? 0) > 0) return;\n window.clearTimeout(timer);\n timer = window.setTimeout(send, latest.current.settle);\n };\n map.on(\"moveend zoomend\", moved);\n // The first fit ran before this listener was there: with `reportAppMoves`, it is reported too.\n if (fitted.current !== null && latest.current.reportAppMoves) moved();\n return () => {\n map.off(\"moveend zoomend\", moved);\n window.clearTimeout(timer);\n };\n }, [map]);\n\n // A view the app sets (a saved one): the map goes there when it changes, silently.\n const [viewLat, viewLng, viewZoom] = view ? [view.center[0], view.center[1], view.zoom] : [null, null, null];\n React.useEffect(() => {\n if (!map || viewLat === null || viewLng === null || viewZoom === null || fitted.current === null) return;\n const c = map.getCenter();\n if (map.getZoom() === viewZoom && Math.abs(c.lat - viewLat) < 1e-7 && Math.abs(c.lng - viewLng) < 1e-7) return;\n silently(map, () => map.setView([viewLat, viewLng], viewZoom, { animate: false }));\n }, [map, viewLat, viewLng, viewZoom]);\n\n // The shared cursor: metres along one route.\n const shared = useSharedCursor();\n const cursorOn = Boolean(cursorProp) && shared !== null;\n const cursorRouteId = typeof cursorProp === \"object\" && cursorProp.routeId ? cursorProp.routeId : routes[0]?.id;\n const cursorRoute = routes.find((r) => r.id === cursorRouteId) ?? null;\n const setPointer = shared?.setPointer;\n React.useEffect(() => {\n if (!map || !cursorOn || !cursorRoute || !setPointer) return;\n const along = alongOf(cursorRoute.points);\n const onMove = (e: L.LeafletMouseEvent) => {\n if (latest.current.picking) return;\n const snap = geo.snap(cursorRoute.points, [e.latlng.lat, e.latlng.lng], along);\n if (!snap) return;\n const apart = map.latLngToContainerPoint(e.latlng).distanceTo(map.latLngToContainerPoint(tuple(snap.position)));\n setPointer(apart <= 24 ? snap.metres : null);\n };\n const onOut = () => setPointer(null);\n map.on(\"mousemove\", onMove);\n map.on(\"mouseout\", onOut);\n return () => {\n map.off(\"mousemove\", onMove);\n map.off(\"mouseout\", onOut);\n setPointer(null);\n };\n }, [map, cursorOn, cursorRoute, setPointer]);\n const otherAlong = cursorOn ? (shared?.other ?? null) : null;\n const ring = React.useRef<L.CircleMarker | null>(null);\n React.useEffect(() => {\n if (!map) return;\n const at = otherAlong !== null && cursorRoute ? geo.pointAlong(cursorRoute.points, otherAlong, alongOf(cursorRoute.points)) : null;\n if (!at) {\n ring.current?.remove();\n ring.current = null;\n return;\n }\n if (!ring.current) {\n const el = map.getContainer();\n ring.current = L.circleMarker(tuple(at), { radius: 9, weight: 3, fillOpacity: 0, interactive: false, color: resolveColour(el, \"var(--foreground)\") }).addTo(map);\n } else ring.current.setLatLng(tuple(at));\n }, [map, otherAlong, cursorRoute]);\n React.useEffect(() => () => void (ring.current = null), [map]);\n\n // Item markers: those near the view, laid out again each time it settles.\n const [tick, setTick] = React.useState(0);\n React.useEffect(() => {\n if (!map || !markers?.length) return;\n const again = () => setTick((t) => t + 1);\n map.on(\"moveend zoomend resize\", again);\n return () => void map.off(\"moveend zoomend resize\", again);\n }, [map, markers?.length]);\n const placed = React.useMemo(() => (map && ready && markers?.length ? placeMarkers(map, markers, routes) : []), [map, ready, markers, routes, tick]);\n // A stretch is its route's part drawn heavier, and a fanned marker has a leader line back to its true place.\n React.useEffect(() => {\n if (!map || !markers?.length) return;\n const group = L.featureGroup().addTo(map);\n const el = map.getContainer();\n for (const m of markers) {\n if (Array.isArray(m.at)) continue;\n const at = m.at as { routeId: string; from: number; to: number };\n const index = routes.findIndex((r) => r.id === at.routeId);\n if (index < 0) continue;\n const route = routes[index];\n const part = geo.slice(route.points, at.from, at.to, alongOf(route.points));\n if (part.length < 2) continue;\n const colour = m.colour ?? (m.highlighted ? \"var(--success)\" : m.selected ? \"var(--foreground)\" : (route.colour ?? PALETTE[index % PALETTE.length]));\n L.polyline(part.map(tuple), { color: resolveColour(el, colour), weight: (route.weight ?? 4) + (m.selected ? 5 : 3), opacity: m.selected ? 1 : 0.8, lineCap: \"round\", interactive: false }).addTo(group);\n }\n for (const p of placed) if (p.fanned) L.polyline([tuple(p.at), tuple(p.shown)], { color: resolveColour(el, \"var(--muted-foreground)\"), weight: 1, dashArray: \"2 3\", interactive: false }).addTo(group);\n for (const { marker } of posMarkers.current.values()) marker.bringToFront();\n return () => void group.remove();\n }, [map, markers, routes, placed, scheme]);\n\n // Choosing a place.\n React.useEffect(() => {\n if (!map || !picking) return;\n const el = map.getContainer();\n el.classList.add(\"strata-map-picking\");\n map.keyboard.disable();\n setAnnounced(\"Choose a place on the map. Arrow keys move the crosshair, Shift for bigger steps, Enter chooses, Escape cancels.\");\n let cross: L.Marker | null = null;\n const showCross = (at: L.LatLng) => {\n if (!cross) cross = L.marker(at, { interactive: false, keyboard: false, icon: L.divIcon({ className: \"strata-map-crosshair\", html: CROSS_ICON, iconSize: [32, 32], iconAnchor: [16, 16] }) }).addTo(map);\n else cross.setLatLng(at);\n };\n const choose = (ll: L.LatLng) => {\n const at: LatLng = [ll.lat, ll.lng];\n const nearest = nearestRoute(latest.current.routes, at);\n const route = nearest ? latest.current.routes.find((r) => r.id === nearest.routeId) : undefined;\n setAnnounced(`Picked ${at[0].toFixed(5)}, ${at[1].toFixed(5)}.${nearest && route ? ` Nearest: ${route.label}, ${format.distance(nearest.alongM, latest.current.units)} along, ${format.distance(nearest.distanceM, latest.current.units)} from the route.` : \"\"}`);\n latest.current.onPick?.(at, { nearest });\n };\n const onClick = (e: L.LeafletMouseEvent) => {\n cross?.remove();\n cross = null;\n choose(e.latlng);\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n latest.current.onPickCancel?.();\n return;\n }\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.stopPropagation();\n choose(cross ? cross.getLatLng() : map.getCenter());\n return;\n }\n const step = e.shiftKey ? 50 : 10;\n const d = ({ ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] } as Record<string, [number, number]>)[e.key];\n if (!d) return;\n e.preventDefault();\n e.stopPropagation();\n const from = map.latLngToContainerPoint(cross ? cross.getLatLng() : map.getCenter());\n let to = from.add(d);\n const size = map.getSize();\n // Past the edge, the map moves and the crosshair stays at the edge.\n const inside = L.point(Math.min(Math.max(to.x, 16), size.x - 16), Math.min(Math.max(to.y, 16), size.y - 16));\n if (!inside.equals(to)) {\n map.panBy(to.subtract(inside), { animate: false });\n to = inside;\n }\n showCross(map.containerPointToLatLng(to));\n };\n map.on(\"click\", onClick);\n el.addEventListener(\"keydown\", onKey);\n return () => {\n map.off(\"click\", onClick);\n el.removeEventListener(\"keydown\", onKey);\n cross?.remove();\n el.classList.remove(\"strata-map-picking\");\n map.keyboard.enable();\n };\n }, [map, picking]);\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 <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {announced}\n </p>\n {map && placed.length > 0 && <MarkerLayer map={map} placed={placed} onSelect={onMarkerSelect} card={renderMarkerCard} />}\n {topEnd && <div className=\"absolute top-2 right-2 z-1000\">{topEnd}</div>}\n {picking && pickBanner && <div className=\"absolute top-2 left-1/2 z-1000 max-w-[60%] -translate-x-1/2\">{pickBanner}</div>}\n {(stops.length > 0 || bottomStart || (markers?.length && markerKey !== false)) && (\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 {markers && markers.length > 0 && markerKey !== false && <MarkerKey markers={markers} words={markerKey} />}\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;;;;;;;;;;;;;;;;;;;AAoBf,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;;;ACrBA,SAAgB,OAAO,OAA4B,MAAM,IAAiB;CACxE,MAAM,SAAS,MAAM,KAAK,GAAG,MAAM,CAAC;CACpC,MAAM,QAAQ,MAAuB,OAAO,OAAO,IAAI,IAAK,OAAO,KAAK,KAAK,OAAO,EAAE;CAEtF,MAAM,wBAAQ,IAAI,IAAsB;CACxC,MAAM,OAAO,IAAY,OAAe,GAAG,GAAG,GAAG;CACjD,MAAM,SAAS,GAAG,MAAM;EACtB,MAAM,CAAC,IAAI,MAAM,CAAC,KAAK,MAAM,EAAE,IAAI,GAAG,GAAG,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC;EAC9D,KAAK,IAAI,KAAK,IAAI,MAAM,GAAG,MACzB,KAAK,IAAI,KAAK,IAAI,MAAM,GAAG,MACzB,KAAK,MAAM,KAAK,MAAM,IAAI,IAAI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EAAE,EAAE,IAAU,CAAA,CACvC;GALK,GAAA,EAAE,EAKP,CACL;EACC,CAAA,CACD;;AAET"}
|
|
1
|
+
{"version":3,"file":"map.js","names":["Tooltip","AriaButton","_Fragment"],"sources":["../src/map/map-styles.ts","../src/map/fan.ts","../src/map/markers.tsx","../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.strata-map .strata-map-marker, .strata-map .strata-map-crosshair { background: none; border: 0; display: grid; place-items: center; }\n.strata-map .strata-map-reset { display: grid; place-items: center; }\n.strata-map .strata-map-picking, .strata-map .strata-map-picking .leaflet-interactive { cursor: crosshair; }\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","// Markers that would sit on top of each other are moved apart in a small fan (strata-react issue #181).\n// Pure maths on pixel positions, no map and no DOM, so the rule can be tested and so a frame is the\n// same everywhere. The positions are in the map's *world* pixels at the current zoom (not the screen's),\n// so panning never changes the result, only zooming does, and zooming in is what settles the fan.\n//\n// Rules: markers within `gap` pixels of each other, directly or through a chain of neighbours\n// (single linkage), form one group. A group of two to six goes on one circle just wide enough that\n// neighbours are `gap` apart; a larger group fills rings of radius gap, 2 gap, 3 gap… each holding as\n// many as fit, so forty markers on one spot make a tidy rosette, not one huge circle. The first marker\n// of a group (input order) goes straight up and the rest follow clockwise: the same input always gives the\n// same output. A lone marker does not move.\n\n/** A marker's true place in world pixels. */\nexport type FanInput = { id: string; x: number; y: number };\n/** Where it is drawn; `fanned` is true when that is not its true place (draw a leader line back). */\nexport type FanOutput = { id: string; x: number; y: number; fanned: boolean };\n\n/** Move apart markers closer than `gap` pixels. Output is in input order. */\nexport function fanOut(items: readonly FanInput[], gap = 26): FanOutput[] {\n const parent = items.map((_, i) => i);\n const find = (i: number): number => (parent[i] === i ? i : (parent[i] = find(parent[i])));\n // A grid of `gap`-sized cells, so each marker is compared with its neighbours and not with all 500.\n const cells = new Map<string, number[]>();\n const key = (cx: number, cy: number) => `${cx},${cy}`;\n items.forEach((p, i) => {\n const [cx, cy] = [Math.floor(p.x / gap), Math.floor(p.y / gap)];\n for (let dx = -1; dx <= 1; dx++)\n for (let dy = -1; dy <= 1; dy++)\n for (const j of cells.get(key(cx + dx, cy + dy)) ?? []) {\n if (Math.hypot(items[j].x - p.x, items[j].y - p.y) < gap) parent[find(i)] = find(j);\n }\n const own = cells.get(key(cx, cy));\n if (own) own.push(i);\n else cells.set(key(cx, cy), [i]);\n });\n const groups = new Map<number, number[]>();\n items.forEach((_, i) => {\n const r = find(i);\n const g = groups.get(r);\n if (g) g.push(i);\n else groups.set(r, [i]);\n });\n const out: FanOutput[] = items.map((p) => ({ id: p.id, x: p.x, y: p.y, fanned: false }));\n for (const members of groups.values()) {\n const n = members.length;\n if (n < 2) continue;\n const cx = members.reduce((s, i) => s + items[i].x, 0) / n;\n const cy = members.reduce((s, i) => s + items[i].y, 0) / n;\n const place = (i: number, radius: number, angle: number) => {\n out[i] = { id: items[i].id, x: cx + radius * Math.sin(angle), y: cy - radius * Math.cos(angle), fanned: true };\n };\n if (n <= 6) {\n const radius = gap / (2 * Math.sin(Math.PI / n));\n members.forEach((i, k) => place(i, radius, (2 * Math.PI * k) / n));\n } else {\n let k = 0;\n for (let ring = 1; k < n; ring++) {\n const radius = ring * gap;\n const fit = Math.max(1, Math.floor((2 * Math.PI * radius) / gap));\n const here = Math.min(fit, n - k);\n for (let m = 0; m < here; m++) place(members[k + m], radius, (2 * Math.PI * m) / here);\n k += here;\n }\n }\n }\n return out;\n}\n","import * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport L from \"leaflet\";\nimport { Button as AriaButton } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { geo, type LatLng } from \"../lib/geo\";\nimport { Tooltip } from \"../components/tooltip\";\nimport { fanOut } from \"./fan\";\n\n// Item markers on a map (strata-react issue #181, from strata-360's race map: a marker for every clip at\n// the middle of its stretch of track, the stretch drawn heavier, overlapping markers fanned apart, a card\n// on hover, a click that opens the clip). What is decided here and why:\n//\n// - **Each marker is a real control.** A React Aria `Button` portalled into the DOM node of a Leaflet\n// marker (a `divIcon` whose `html` is that node), so Leaflet keeps it where the map puts it while React\n// owns what it is: named by its label, pressed with a click, Enter or Space, a `Tooltip` on hover and\n// focus. Not Leaflet's popup, which is not a Strata surface and not reachable the same way.\n// - **One tab stop for all of them**, arrows (and Home and End) between them, in the order the app gave:\n// forty markers must not be forty tab stops. The map's own keyboard stays: the markers are a roving\n// group inside it, and the app's list of items beside the map is still the full keyboard path.\n// - **Only what is near the screen is drawn.** Each time the view settles the markers within the view\n// (plus a margin, so a fan is not cut at the edge) are laid out and the rest are not in the DOM, so 500\n// markers cost what the visible ones cost.\n// - **The fan is a pure function of the zoom** (`fanOut`, fan.ts): in world pixels, so panning never moves\n// it and zooming in settles it; a leader line joins each fanned marker to its true place.\n// - **States are shapes as well as colour**: a plain circle, a ringed larger one for selected, a diamond for\n// highlighted by the app (the newest draft's choice). The key names each one that is on the map.\n//\n// Checked: React Aria has no map part; `Button` and the Strata `Tooltip` are used as they are.\n\n/** The words the key uses for each marker state. */\nexport type MarkerKeyWords = { marker?: string; selected?: string; highlighted?: string };\n\n/** An item on the map: a place, or a stretch of a route (drawn heavier, the marker at its middle). */\nexport type MapMarker = {\n /** Stable between renders. */\n id: string;\n /** A place, or a stretch of a route between two distances along it (metres). */\n at: LatLng | { routeId: string; from: number; to: number };\n /** Its name: the button's accessible name and the card's default words. */\n label: string;\n selected?: boolean;\n /** Marked by the app (a diamond): the newest draft's choice, a flagged item. */\n highlighted?: boolean;\n /** Any CSS colour, normally a role; overrides the state's. */\n colour?: string;\n};\n\n/** A marker with where it really is and where it is drawn. */\nexport type Placed = { marker: MapMarker; at: LatLng; shown: LatLng; fanned: boolean };\n\nconst alongCache = new WeakMap<readonly LatLng[], number[]>();\n/** The running distance at each point of a route, kept per route array so a long route is walked once. */\nexport function alongOf(points: readonly LatLng[]): number[] {\n let a = alongCache.get(points);\n if (!a) {\n a = geo.cumulative(points);\n alongCache.set(points, a);\n }\n return a;\n}\n\n/** Where a marker really is: its place, or the middle of its stretch. Null when its route is not on the map. */\nexport function markerPlace(m: MapMarker, routes: readonly { id: string; points: readonly LatLng[] }[]): LatLng | null {\n if (Array.isArray(m.at)) return m.at as LatLng;\n const at = m.at as { routeId: string; from: number; to: number };\n const route = routes.find((r) => r.id === at.routeId);\n return route ? geo.pointAlong(route.points, (at.from + at.to) / 2, alongOf(route.points)) : null;\n}\n\n/** The markers near the view, with the overlapping ones fanned apart for this zoom. */\nexport function placeMarkers(map: L.Map, markers: readonly MapMarker[], routes: readonly { id: string; points: readonly LatLng[] }[]): Placed[] {\n const near = map.getBounds().pad(0.25);\n const zoom = map.getZoom();\n const here: { marker: MapMarker; at: LatLng }[] = [];\n for (const marker of markers) {\n const at = markerPlace(marker, routes);\n if (at && near.contains([at[0], at[1]])) here.push({ marker, at });\n }\n const fanned = fanOut(here.map((h) => ({ id: h.marker.id, ...map.project([h.at[0], h.at[1]], zoom) })));\n return here.map((h, i) => {\n const f = fanned[i];\n const shown = f.fanned ? map.unproject([f.x, f.y], zoom) : null;\n return { marker: h.marker, at: h.at, shown: shown ? ([shown.lat, shown.lng] as LatLng) : h.at, fanned: f.fanned };\n });\n}\n\nconst state = (m: MapMarker) => (m.highlighted ? \"highlighted\" : m.selected ? \"selected\" : \"marker\");\n\ntype PinProps = {\n map: L.Map;\n placed: Placed;\n active: boolean;\n onActivate: (id: string) => void;\n onMove: (id: string, to: \"next\" | \"previous\" | \"first\" | \"last\") => void;\n register: (id: string, el: HTMLElement | null) => void;\n onSelect?: (id: string) => void;\n card?: (m: MapMarker) => React.ReactNode;\n};\n\n/** One marker: a Leaflet marker holding a node that React fills with a labelled button. */\nfunction Pin({ map, placed, active, onActivate, onMove, register, onSelect, card }: PinProps) {\n const { marker, shown } = placed;\n const host = React.useMemo(() => {\n const el = document.createElement(\"div\");\n el.className = \"strata-map-pin\";\n return el;\n }, []);\n const layer = React.useRef<L.Marker | null>(null);\n React.useEffect(() => {\n const m = L.marker([shown[0], shown[1]], { icon: L.divIcon({ className: \"strata-map-marker\", html: host, iconSize: [28, 28], iconAnchor: [14, 14] }), interactive: false, keyboard: false }).addTo(map);\n layer.current = m;\n return () => {\n layer.current = null;\n m.remove();\n };\n // Made once per pin; where it is and how high it sits are updated below.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [map, host]);\n React.useEffect(() => {\n layer.current?.setLatLng([shown[0], shown[1]]);\n }, [shown]);\n React.useEffect(() => {\n layer.current?.setZIndexOffset(marker.selected ? 1000 : marker.highlighted ? 500 : 0);\n }, [marker.selected, marker.highlighted]);\n const kind = state(marker);\n const swatch = marker.colour ?? (kind === \"highlighted\" ? \"var(--success)\" : kind === \"selected\" ? \"var(--foreground)\" : \"var(--primary)\");\n return createPortal(\n <Tooltip label={card ? card(marker) : marker.label} side=\"top\">\n <AriaButton\n ref={(el) => register(marker.id, el)}\n aria-label={marker.label}\n aria-pressed={marker.selected ?? false}\n excludeFromTabOrder={!active}\n onFocus={() => onActivate(marker.id)}\n onPress={() => onSelect?.(marker.id)}\n onKeyDown={(e) => {\n const to = e.key === \"ArrowRight\" || e.key === \"ArrowDown\" ? \"next\" : e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? \"previous\" : e.key === \"Home\" ? \"first\" : e.key === \"End\" ? \"last\" : null;\n if (!to) return;\n e.preventDefault();\n e.stopPropagation();\n onMove(marker.id, to);\n }}\n className=\"pointer-events-auto grid size-7 cursor-pointer place-items-center rounded-pill outline-offset-1 focus-visible:outline-2 focus-visible:outline-ring\"\n >\n <Shape kind={kind} colour={swatch} />\n </AriaButton>\n </Tooltip>,\n host,\n );\n}\n\n/** The drawn shape of a marker state: a circle, a ringed larger circle, a diamond. Shapes carry the meaning as colour does. */\nfunction Shape({ kind, colour }: { kind: \"marker\" | \"selected\" | \"highlighted\"; colour: string }) {\n return (\n <span\n aria-hidden\n className={cn(\"block border-2 border-background\", kind === \"highlighted\" ? \"size-3.5 rotate-45 rounded-sm\" : \"rounded-pill\", kind === \"selected\" ? \"size-4 ring-2 ring-foreground\" : kind === \"marker\" ? \"size-3.5\" : \"\")}\n style={{ background: colour }}\n />\n );\n}\n\ntype LayerProps = {\n map: L.Map;\n placed: readonly Placed[];\n onSelect?: (id: string) => void;\n card?: (m: MapMarker) => React.ReactNode;\n};\n\n/** The pins for the markers near the view, as one roving group: one tab stop, arrows between them. */\nexport function MarkerLayer({ map, placed, onSelect, card }: LayerProps) {\n const [activeId, setActiveId] = React.useState<string | null>(null);\n const els = React.useRef(new Map<string, HTMLElement>());\n const ids = placed.map((p) => p.marker.id);\n const active = activeId !== null && ids.includes(activeId) ? activeId : (ids[0] ?? null);\n const register = React.useCallback((id: string, el: HTMLElement | null) => {\n if (el) els.current.set(id, el);\n else els.current.delete(id);\n }, []);\n const move = (id: string, to: \"next\" | \"previous\" | \"first\" | \"last\") => {\n const i = ids.indexOf(id);\n const next = to === \"first\" ? 0 : to === \"last\" ? ids.length - 1 : Math.min(ids.length - 1, Math.max(0, i + (to === \"next\" ? 1 : -1)));\n setActiveId(ids[next]);\n els.current.get(ids[next])?.focus();\n };\n return (\n <>\n {placed.map((p) => (\n <Pin key={p.marker.id} map={map} placed={p} active={p.marker.id === active} onActivate={setActiveId} onMove={move} register={register} onSelect={onSelect} card={card} />\n ))}\n </>\n );\n}\n\n/** The key to the marker states that are on the map, each with its shape and its words. */\nexport function MarkerKey({ markers, words }: { markers: readonly MapMarker[]; words?: MarkerKeyWords }) {\n const kinds = ([\"marker\", \"selected\", \"highlighted\"] as const).filter((k) => markers.some((m) => state(m) === k));\n const text = { marker: words?.marker ?? \"Item\", selected: words?.selected ?? \"Selected\", highlighted: words?.highlighted ?? \"Highlighted\" };\n if (!kinds.length) return null;\n return (\n <div className=\"rounded-control border border-border bg-background px-2 py-1.5 type-caption text-foreground\">\n <ul className=\"grid gap-0.5\">\n {kinds.map((k) => (\n <li key={k} className=\"flex items-center gap-2\">\n <span className=\"grid size-4 place-items-center\">\n <Shape kind={k} colour={k === \"highlighted\" ? \"var(--success)\" : k === \"selected\" ? \"var(--foreground)\" : \"var(--primary)\"} />\n </span>\n {text[k]}\n </li>\n ))}\n </ul>\n </div>\n );\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\";\nimport { useSharedCursor } from \"../components/cursor\";\nimport { MarkerKey, MarkerLayer, alongOf, placeMarkers, type MapMarker, type MarkerKeyWords } from \"./markers\";\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// Map as picture content (issue #161, from strata-vid, where a route inset is composed over footage and\n// must look the same on every frame as in an export drawn on a canvas). Three additions, none of which\n// changes a page map: `zoom` sets the zoom from outside (any number, so an animation is a prop that\n// changes every frame; unset keeps fit-to-routes), `follow=\"centre\"` holds the view on a position at that\n// zoom, and `positions` draws several moving positions, each tied to a route and drawn in its colour.\n// Centred follow pans to a whole-pixel view worked out from the position and zoom alone (`centre`), with\n// no animation: Leaflet's own centred pan truncates each step, so where the view ended up would depend\n// on the path it took; this depends only on the position and zoom, which is what makes frame N the same\n// picture however it was reached. A `reset` would give the same view but empties the tile layer on every\n// call, which flickers at one update per frame.\n// Fractional zoom needs `zoomSnap: 0`, which is set only while `zoom` is controlled, so a page map still\n// snaps to half steps. Each marker is one `L.CircleMarker` kept by id and moved with `setLatLng`.\n//\n// The map as an instrument, not only a picture (strata-react issues #181, #182, #184):\n// - `markers`: items on the route as controls with cards, fanned apart (markers.tsx).\n// - `onViewChange`: the visible bounds and zoom, once when movement settles (debounced `settle` ms), and\n// not for a move the app made through its own props (`zoom`, `view`, `follow`, the first fit), which it\n// already knows about: every move the component makes itself runs inside `silently`, and Leaflet's events\n// are synchronous with animation off, so the flag cannot leak. `reportAppMoves` turns that off.\n// - `view` restores a saved view; the person's own moves go out through `onViewChange`. A reset control\n// in Leaflet's own control group fits the routes again (or sets the zoom, when one is controlled).\n// - `picking` + `onPick`: choose a place. Pointer: a click. Keyboard: arrows move a crosshair (Shift for\n// bigger steps), Enter chooses, Escape asks to cancel; Leaflet's own arrow handling is switched off for\n// the time, since both would move. The result is announced with the nearest route, how far along it and\n// how far off (`geo.snap`). Route lines stop taking clicks while picking, or a pick near the route would\n// select the route instead. A click when not picking does nothing new.\n// - `cursor`: joins a `CursorScope` (cursor.tsx). The scope's unit here is metres along one route; a\n// pointer near the route (within 24 px of it) writes the distance of the nearest point on it, and\n// another member's distance is drawn as a ring on the route. Never drawn back at its own writer.\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\n/** One moving position, for a map with more than one (two runners on the same loop). */\nexport type MapPosition = {\n /** Stable between renders: the marker is kept by it and moved, never recreated. */\n id: string;\n /** Where it is now; null hides it. */\n at: LatLng | null;\n /** What it is called in the text alternative (\"Runner A\"). */\n label: string;\n /** The route it travels. Its marker takes that route's colour and the text alternative says how far along it is. */\n routeId?: string;\n /** Any CSS colour, normally a role. Overrides the route's. Default: the route's colour, else the theme's primary. */\n colour?: string;\n};\n\n/** The view the map settled on. */\nexport type MapView = { bounds: [LatLng, LatLng]; zoom: number; center: LatLng };\n\n/** The route nearest a picked place. */\nexport type PickNearest = {\n routeId: string;\n /** The leg of the route (its first point's index) the place is nearest. */\n index: number;\n /** How far the place is from the route, in metres. */\n distanceM: number;\n /** How far along the route the nearest point is, in metres. */\n alongM: number;\n /** The nearest point on the route. */\n position: LatLng;\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 /** More moving positions, each in its route's colour and named in the text alternative. Moved without redrawing any route; `position` may be used beside them. */\n positions?: readonly MapPosition[];\n /** Which position `follow` tracks: a `positions` id. Default `position`, else the first of `positions` that is shown. */\n followId?: string;\n /** `true` pans only when the position leaves the inner 80% of the view; `\"centre\"` keeps it exactly in the centre on every update, with no animation (a frame is deterministic), at `zoom` when that is set, else the zoom the map has. */\n follow?: boolean | \"centre\";\n /** The zoom level, any number (12, 14.5): it may change every frame without redrawing routes. Unset, the map fits its routes and the person zooms. */\n zoom?: number;\n /** Items on the map: places, or stretches of a route. Keep the array stable between renders. */\n markers?: readonly MapMarker[];\n /** A marker was pressed (click, Enter or Space). */\n onMarkerSelect?: (id: string) => void;\n /** The words shown beside a marker on hover and focus (as `Tooltip`; not interactive). Default its label. */\n renderMarkerCard?: (marker: MapMarker) => React.ReactNode;\n /** The words of the marker key; `false` leaves the key out. */\n markerKey?: MarkerKeyWords | false;\n /** Join the nearest `CursorScope`: a pointer near a route puts its distance along it in every member, and another member's distance shows as a ring on the route. `{ routeId }` picks the route (default the first). */\n cursor?: boolean | { routeId?: string };\n /** The view settled after the person moved or zoomed it: bounds, zoom and centre. Not called for moves the app caused through props. */\n onViewChange?: (view: MapView) => void;\n /** Milliseconds the view must be still before `onViewChange`. Default 250. */\n settle?: number;\n /** Also call `onViewChange` for moves the app caused through props (the first fit, `zoom`, `view`, `follow`). */\n reportAppMoves?: boolean;\n /** A view to show: centre and zoom, as a saved view or the app's own. The person can still move away from it; set it again to go back. Wins over fitting the routes. */\n view?: { center: LatLng; zoom: number };\n /** Choose a place on the map. While set, a click or Enter picks and route lines do not take clicks. */\n picking?: boolean;\n /** A place was chosen, with the nearest route to it when there is one. */\n onPick?: (at: LatLng, info: { nearest: PickNearest | null }) => void;\n /** Escape was pressed while picking: the app turns `picking` off. */\n onPickCancel?: () => void;\n /** The banner for pick mode (\"Click the map to set the point; Escape cancels\"), shown top centre. */\n pickBanner?: React.ReactNode;\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\n/** How many moves of the map the component itself is making right now (see `onViewChange`). */\nconst quiet = new WeakMap<L.Map, number>();\n/** Run a move the component makes itself, so `onViewChange` does not report it. Leaflet's events are synchronous with animation off. */\nfunction silently<T>(map: L.Map, fn: () => T): T {\n quiet.set(map, (quiet.get(map) ?? 0) + 1);\n try {\n return fn();\n } finally {\n quiet.set(map, (quiet.get(map) ?? 1) - 1);\n }\n}\n\n/** The route nearest a place, by distance from it to the route (not to a vertex). */\nfunction nearestRoute(routes: readonly MapRoute[], at: LatLng): PickNearest | null {\n let best: PickNearest | null = null;\n for (const r of routes) {\n const s = geo.snap(r.points, at, alongOf(r.points));\n if (s && (!best || s.offset < best.distanceM)) best = { routeId: r.id, index: s.index, distanceM: s.offset, alongM: s.metres, position: s.position };\n }\n return best;\n}\n\nconst RESET_ICON = '<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2 6V2h4M10 2h4v4M14 10v4h-4M6 14H2v-4\"/></svg>';\nconst CROSS_ICON = '<svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" aria-hidden=\"true\" fill=\"none\" stroke-linecap=\"round\"><path d=\"M16 4v24M4 16h24\" stroke=\"var(--background)\" stroke-width=\"5\"/><path d=\"M16 4v24M4 16h24\" stroke=\"var(--foreground)\" stroke-width=\"2\"/></svg>';\n\n/** Leaflet's control group gets a reset: fit the routes again. A link with a button role, as Leaflet's own zoom buttons are. */\nfunction resetControl(onReset: () => void): L.Control {\n const control = new L.Control({ position: \"topleft\" });\n control.onAdd = () => {\n const bar = L.DomUtil.create(\"div\", \"leaflet-bar leaflet-control\");\n const a = L.DomUtil.create(\"a\", \"strata-map-reset\", bar);\n a.href = \"#\";\n a.setAttribute(\"role\", \"button\");\n a.setAttribute(\"aria-label\", \"Reset view\");\n a.title = \"Reset view\";\n a.innerHTML = RESET_ICON;\n L.DomEvent.disableClickPropagation(bar);\n L.DomEvent.on(a, \"click\", (e) => {\n L.DomEvent.preventDefault(e);\n onReset();\n });\n L.DomEvent.on(a, \"keydown\", (e) => {\n if ((e as KeyboardEvent).key === \" \") {\n L.DomEvent.preventDefault(e);\n onReset();\n }\n });\n return bar;\n };\n return control;\n}\n\n/** Put the routes in view (or, with a zoom set, centre the routes at it). */\nfunction showRoutes(map: L.Map, routes: readonly MapRoute[], zoom: number | undefined) {\n const box = geo.bounds(routes.flatMap((r) => r.points));\n if (!box) return false;\n if (zoom !== undefined) map.setView([(box[0][0] + box[1][0]) / 2, (box[0][1] + box[1][1]) / 2], zoom, { animate: false });\n else map.fitBounds([tuple(box[0]), tuple(box[1])], { padding: [24, 24], animate: false, maxZoom: 17 });\n return true;\n}\n\nconst SINGLE = \"\\u0000position\";\nconst PALETTE = [1, 2, 3, 4, 5].map((n) => `var(--chart-${n})`);\n\n/**\n * Put `target` in the exact middle of the view at zoom `z`, with no animation and without throwing the\n * loaded tiles away. A zoom change goes through `setView` (Leaflet redraws its tiles then anyway). The\n * position is then set by panning to a whole-pixel top-left worked out from the target and the zoom\n * alone, so where the view ends up does not depend on the path taken (Leaflet's own centred pan\n * truncates each step and drifts); a `reset` would be exact too but empties the tile layer on every\n * call, which flickers when the position changes every frame.\n */\nfunction centre(map: L.Map, target: LatLng, z: number) {\n silently(map, () => {\n if (map.getZoom() !== z) map.setView(tuple(target), z, { animate: false });\n const want = map.project(tuple(target), z).subtract(map.getSize().divideBy(2)).round();\n const have = map.getPixelBounds().min!.round();\n const move = want.subtract(have);\n if (move.x || move.y) map.panBy(move, { animate: false, noMoveStart: true });\n });\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 positions,\n followId,\n follow = false,\n zoom,\n markers,\n onMarkerSelect,\n renderMarkerCard,\n markerKey,\n cursor: cursorProp,\n onViewChange,\n settle = 250,\n reportAppMoves = false,\n view,\n picking = false,\n onPick,\n onPickCancel,\n pickBanner,\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, onViewChange, reportAppMoves, settle, picking, onPick, onPickCancel, routes, units, view, zoom });\n latest.current = { onSelect, onViewChange, reportAppMoves, settle, picking, onPick, onPickCancel, routes, units, view, zoom };\n const [announced, setAnnounced] = React.useState(\"\");\n // True once the map has a view (the first fit has happened): before that Leaflet cannot say what is near.\n const [ready, setReady] = React.useState(false);\n const selectable = Boolean(onSelect);\n // One marker per position, by id, with the style last applied so a moving marker is not restyled every frame.\n const posMarkers = React.useRef(new Map<string, { marker: L.CircleMarker; style: string }>());\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 posMarkers.current.clear();\n m.remove();\n setMap(null);\n setReady(false);\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 // A zoom set from outside is any number; Leaflet snaps to `zoomSnap`, so it is 0 while zoom is controlled.\n const zoomed = zoom !== undefined;\n React.useEffect(() => {\n if (map) map.options.zoomSnap = zoomed ? 0 : 0.5;\n }, [map, zoomed]);\n\n // Every position on the map, the single `position` first: what is spoken, drawn and followed.\n const all = React.useMemo<MapPosition[]>(() => [...(position ? [{ id: SINGLE, at: position, label: positionLabel }] : []), ...(positions ?? [])], [position, positionLabel, positions]);\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(all);\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 // A position tied to another route is not on this one; one tied to no route is described along each.\n for (const p of spoken) {\n if (!p.at || !r.points.length || (p.routeId !== undefined && p.routeId !== r.id && routes.some((o) => o.id === p.routeId))) continue;\n here += ` ${p.label}: ${format.distance(along[geo.nearest(r.points, p.at)] ?? 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 const items = markers?.length ? ` ${markers.length === 1 ? \"One marker\" : `${markers.length} markers`}${markers.some((m) => m.selected) ? `, selected: ${markers.filter((m) => m.selected).map((m) => m.label).join(\", \")}` : \"\"}.` : \"\";\n return `Map with ${routes.length === 1 ? \"one route\" : `${routes.length} routes`}. ${parts.join(\" \")}${items}`;\n }, [summary, routes, spoken, units, stops.length, colourScaleLabel, formatValue, markers]);\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 && !picking, 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 // Redrawn routes are new layers: keep the positions above them.\n for (const { marker } of posMarkers.current.values()) marker.bringToFront();\n return () => void group.remove();\n }, [map, routes, scheme, selectedId, stops, selectable, picking]);\n\n // The position a followed view is held on: read by the fit (a map shown for the first time starts\n // centred on it) and by the position effect.\n const target = React.useMemo(() => {\n if (!follow) return null;\n const shown = all.filter((p) => p.at);\n return (followId ? shown.find((p) => p.id === followId) : shown[0])?.at ?? null;\n }, [all, follow, followId]);\n const latestView = React.useRef({ target, zoom, centred: follow === \"centre\" });\n latestView.current = { target, zoom, centred: follow === \"centre\" };\n\n // Fit to the routes when the map first has a size and whenever the set of routes changes. With a\n // zoom set there is nothing to fit: the view is placed at that zoom, on the followed position when\n // the map is centred on one, else on the middle of the routes.\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 if (!geo.bounds(routes.flatMap((r) => r.points)) && !latest.current.view) return;\n fitted.current = routeKey;\n const v = latestView.current;\n setReady(true);\n // A given view wins, then a set zoom (on the followed position, or the routes' middle), then the routes.\n silently(map, () => {\n if (latest.current.view) map.setView(tuple(latest.current.view.center), latest.current.view.zoom, { animate: false });\n else if (v.zoom !== undefined && v.centred && v.target) map.setView(tuple(v.target), v.zoom, { animate: false });\n else showRoutes(map, latest.current.routes, v.zoom);\n });\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 // A zoom that changes after the first view (an animation) moves the zoom about the view's centre.\n React.useEffect(() => {\n if (map && zoom !== undefined && fitted.current !== null && map.getZoom() !== zoom) silently(map, () => map.setZoom(zoom, { animate: false }));\n }, [map, zoom]);\n\n // The positions: one marker each, kept by id and moved with `setLatLng`. No route is touched.\n React.useEffect(() => {\n if (!map) return;\n const el = map.getContainer();\n const live = posMarkers.current;\n const seen = new Set<string>();\n for (const p of all) {\n if (!p.at) continue;\n seen.add(p.id);\n let entry = live.get(p.id);\n if (!entry) {\n entry = { marker: L.circleMarker(tuple(p.at), { radius: 8, weight: 3, fillOpacity: 1, interactive: false }).addTo(map), style: \"\" };\n live.set(p.id, entry);\n } else entry.marker.setLatLng(tuple(p.at));\n const index = routes.findIndex((r) => r.id === p.routeId);\n const spec = p.colour ?? (index >= 0 ? (routes[index].colour ?? PALETTE[index % PALETTE.length]) : \"var(--primary)\");\n const style = `${scheme}|${spec}`;\n if (entry.style !== style) {\n entry.style = style;\n entry.marker.setStyle({ color: resolveColour(el, \"var(--background)\"), fillColor: resolveColour(el, spec) });\n }\n }\n for (const [id, entry] of live) {\n if (seen.has(id)) continue;\n entry.marker.remove();\n live.delete(id);\n }\n if (!target) return;\n if (follow === \"centre\") {\n // Before the first fit with no zoom set there is no zoom to hold; the fit places the view.\n const z = zoom ?? (fitted.current === null ? undefined : map.getZoom());\n if (z !== undefined) centre(map, target, z);\n } else if (!map.getBounds().pad(-0.2).contains(tuple(target))) silently(map, () => map.panTo(tuple(target), { animate: false }));\n }, [map, all, routes, scheme, follow, target, zoom]);\n\n // The reset control: fit the routes again, as the person's own move (so it is reported).\n React.useEffect(() => {\n if (!map) return;\n const control = resetControl(() => {\n const view = latest.current.view;\n if (view) map.setView(tuple(view.center), view.zoom, { animate: false });\n else showRoutes(map, latest.current.routes, latest.current.zoom);\n });\n control.addTo(map);\n return () => void control.remove();\n }, [map]);\n\n // The view, reported once it settles: the person's moves, not the app's own (unless asked).\n React.useEffect(() => {\n if (!map) return;\n let timer: number | undefined;\n const send = () => {\n timer = undefined;\n const b = map.getBounds();\n const c = map.getCenter();\n latest.current.onViewChange?.({ bounds: [[b.getSouth(), b.getWest()], [b.getNorth(), b.getEast()]], zoom: map.getZoom(), center: [c.lat, c.lng] });\n };\n const moved = () => {\n if (!latest.current.onViewChange) return;\n if (!latest.current.reportAppMoves && (quiet.get(map) ?? 0) > 0) return;\n window.clearTimeout(timer);\n timer = window.setTimeout(send, latest.current.settle);\n };\n map.on(\"moveend zoomend\", moved);\n // The first fit ran before this listener was there: with `reportAppMoves`, it is reported too.\n if (fitted.current !== null && latest.current.reportAppMoves) moved();\n return () => {\n map.off(\"moveend zoomend\", moved);\n window.clearTimeout(timer);\n };\n }, [map]);\n\n // A view the app sets (a saved one): the map goes there when it changes, silently.\n const [viewLat, viewLng, viewZoom] = view ? [view.center[0], view.center[1], view.zoom] : [null, null, null];\n React.useEffect(() => {\n if (!map || viewLat === null || viewLng === null || viewZoom === null || fitted.current === null) return;\n const c = map.getCenter();\n if (map.getZoom() === viewZoom && Math.abs(c.lat - viewLat) < 1e-7 && Math.abs(c.lng - viewLng) < 1e-7) return;\n silently(map, () => map.setView([viewLat, viewLng], viewZoom, { animate: false }));\n }, [map, viewLat, viewLng, viewZoom]);\n\n // The shared cursor: metres along one route.\n const shared = useSharedCursor();\n const cursorOn = Boolean(cursorProp) && shared !== null;\n const cursorRouteId = typeof cursorProp === \"object\" && cursorProp.routeId ? cursorProp.routeId : routes[0]?.id;\n const cursorRoute = routes.find((r) => r.id === cursorRouteId) ?? null;\n const setPointer = shared?.setPointer;\n React.useEffect(() => {\n if (!map || !cursorOn || !cursorRoute || !setPointer) return;\n const along = alongOf(cursorRoute.points);\n const onMove = (e: L.LeafletMouseEvent) => {\n if (latest.current.picking) return;\n const snap = geo.snap(cursorRoute.points, [e.latlng.lat, e.latlng.lng], along);\n if (!snap) return;\n const apart = map.latLngToContainerPoint(e.latlng).distanceTo(map.latLngToContainerPoint(tuple(snap.position)));\n setPointer(apart <= 24 ? snap.metres : null);\n };\n const onOut = () => setPointer(null);\n map.on(\"mousemove\", onMove);\n map.on(\"mouseout\", onOut);\n return () => {\n map.off(\"mousemove\", onMove);\n map.off(\"mouseout\", onOut);\n setPointer(null);\n };\n }, [map, cursorOn, cursorRoute, setPointer]);\n const otherAlong = cursorOn ? (shared?.other ?? null) : null;\n const ring = React.useRef<L.CircleMarker | null>(null);\n React.useEffect(() => {\n if (!map) return;\n const at = otherAlong !== null && cursorRoute ? geo.pointAlong(cursorRoute.points, otherAlong, alongOf(cursorRoute.points)) : null;\n if (!at) {\n ring.current?.remove();\n ring.current = null;\n return;\n }\n if (!ring.current) {\n const el = map.getContainer();\n ring.current = L.circleMarker(tuple(at), { radius: 9, weight: 3, fillOpacity: 0, interactive: false, color: resolveColour(el, \"var(--foreground)\") }).addTo(map);\n } else ring.current.setLatLng(tuple(at));\n }, [map, otherAlong, cursorRoute]);\n React.useEffect(() => () => void (ring.current = null), [map]);\n\n // Item markers: those near the view, laid out again each time it settles.\n const [tick, setTick] = React.useState(0);\n React.useEffect(() => {\n if (!map || !markers?.length) return;\n const again = () => setTick((t) => t + 1);\n map.on(\"moveend zoomend resize\", again);\n return () => void map.off(\"moveend zoomend resize\", again);\n }, [map, markers?.length]);\n const placed = React.useMemo(() => (map && ready && markers?.length ? placeMarkers(map, markers, routes) : []), [map, ready, markers, routes, tick]);\n // A stretch is its route's part drawn heavier, and a fanned marker has a leader line back to its true place.\n React.useEffect(() => {\n if (!map || !markers?.length) return;\n const group = L.featureGroup().addTo(map);\n const el = map.getContainer();\n for (const m of markers) {\n if (Array.isArray(m.at)) continue;\n const at = m.at as { routeId: string; from: number; to: number };\n const index = routes.findIndex((r) => r.id === at.routeId);\n if (index < 0) continue;\n const route = routes[index];\n const part = geo.slice(route.points, at.from, at.to, alongOf(route.points));\n if (part.length < 2) continue;\n const colour = m.colour ?? (m.highlighted ? \"var(--success)\" : m.selected ? \"var(--foreground)\" : (route.colour ?? PALETTE[index % PALETTE.length]));\n L.polyline(part.map(tuple), { color: resolveColour(el, colour), weight: (route.weight ?? 4) + (m.selected ? 5 : 3), opacity: m.selected ? 1 : 0.8, lineCap: \"round\", interactive: false }).addTo(group);\n }\n for (const p of placed) if (p.fanned) L.polyline([tuple(p.at), tuple(p.shown)], { color: resolveColour(el, \"var(--muted-foreground)\"), weight: 1, dashArray: \"2 3\", interactive: false }).addTo(group);\n for (const { marker } of posMarkers.current.values()) marker.bringToFront();\n return () => void group.remove();\n }, [map, markers, routes, placed, scheme]);\n\n // Choosing a place.\n React.useEffect(() => {\n if (!map || !picking) return;\n const el = map.getContainer();\n el.classList.add(\"strata-map-picking\");\n map.keyboard.disable();\n setAnnounced(\"Choose a place on the map. Arrow keys move the crosshair, Shift for bigger steps, Enter chooses, Escape cancels.\");\n let cross: L.Marker | null = null;\n const showCross = (at: L.LatLng) => {\n if (!cross) cross = L.marker(at, { interactive: false, keyboard: false, icon: L.divIcon({ className: \"strata-map-crosshair\", html: CROSS_ICON, iconSize: [32, 32], iconAnchor: [16, 16] }) }).addTo(map);\n else cross.setLatLng(at);\n };\n const choose = (ll: L.LatLng) => {\n const at: LatLng = [ll.lat, ll.lng];\n const nearest = nearestRoute(latest.current.routes, at);\n const route = nearest ? latest.current.routes.find((r) => r.id === nearest.routeId) : undefined;\n setAnnounced(`Picked ${at[0].toFixed(5)}, ${at[1].toFixed(5)}.${nearest && route ? ` Nearest: ${route.label}, ${format.distance(nearest.alongM, latest.current.units)} along, ${format.distance(nearest.distanceM, latest.current.units)} from the route.` : \"\"}`);\n latest.current.onPick?.(at, { nearest });\n };\n const onClick = (e: L.LeafletMouseEvent) => {\n cross?.remove();\n cross = null;\n choose(e.latlng);\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n latest.current.onPickCancel?.();\n return;\n }\n if (e.key === \"Enter\") {\n e.preventDefault();\n e.stopPropagation();\n choose(cross ? cross.getLatLng() : map.getCenter());\n return;\n }\n const step = e.shiftKey ? 50 : 10;\n const d = ({ ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] } as Record<string, [number, number]>)[e.key];\n if (!d) return;\n e.preventDefault();\n e.stopPropagation();\n const from = map.latLngToContainerPoint(cross ? cross.getLatLng() : map.getCenter());\n let to = from.add(d);\n const size = map.getSize();\n // Past the edge, the map moves and the crosshair stays at the edge.\n const inside = L.point(Math.min(Math.max(to.x, 16), size.x - 16), Math.min(Math.max(to.y, 16), size.y - 16));\n if (!inside.equals(to)) {\n map.panBy(to.subtract(inside), { animate: false });\n to = inside;\n }\n showCross(map.containerPointToLatLng(to));\n };\n map.on(\"click\", onClick);\n el.addEventListener(\"keydown\", onKey);\n return () => {\n map.off(\"click\", onClick);\n el.removeEventListener(\"keydown\", onKey);\n cross?.remove();\n el.classList.remove(\"strata-map-picking\");\n map.keyboard.enable();\n };\n }, [map, picking]);\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 <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n {announced}\n </p>\n {map && placed.length > 0 && <MarkerLayer map={map} placed={placed} onSelect={onMarkerSelect} card={renderMarkerCard} />}\n {topEnd && <div className=\"absolute top-2 right-2 z-1000\">{topEnd}</div>}\n {picking && pickBanner && <div className=\"absolute top-2 left-1/2 z-1000 max-w-[60%] -translate-x-1/2\">{pickBanner}</div>}\n {(stops.length > 0 || bottomStart || (markers?.length && markerKey !== false)) && (\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 {markers && markers.length > 0 && markerKey !== false && <MarkerKey markers={markers} words={markerKey} />}\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.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AAA;GACtE,WAAW,cAAc,oBAAC,OAAD;IAAK,WAAU;IAA+D,UAAA;GAAgB,CAAA;IACtH,MAAM,SAAS,KAAK,eAAgB,SAAS,UAAU,cAAc,UACrE,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA;KACG,MAAM,SAAS,KAAK,oBAAC,WAAD;MAAkB;MAAO,OAAO;MAA+B;KAAc,CAAA;KACjG,WAAW,QAAQ,SAAS,KAAK,cAAc,SAAS,oBAAC,WAAD;MAAoB;MAAS,OAAO;KAAY,CAAA;KACxG;IACE;;EAEJ;;AAET;;AAGA,SAAS,UAAU,EAAE,OAAO,OAAO,eAAyH;CAC1J,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACG,SAAS,oBAAC,KAAD;GAAG,WAAU;GAAe,UAAA;EAAS,CAAA,GAC/C,oBAAC,MAAD;GAAI,WAAU;GACX,UAAA,MAAM,KAAK,MACV,qBAAC,MAAD;IAAe,WAAU;IAAzB,UAAA,CACE,oBAAC,OAAD;KAAK,OAAM;KAAK,QAAO;KAAI,eAAA;KACzB,UAAA,oBAAC,QAAD;MAAM,IAAG;MAAI,IAAG;MAAK,IAAG;MAAI,IAAG;MAAI,QAAQ,EAAE;MAAQ,aAAa;MAAG,eAAc;KAAS,CAAA;IACzF,CAAA,GACL,oBAAC,QAAD,EAAA,UAAO,QAAQ,YAAY,EAAE,EAAE,IAAU,CAAA,CACvC;GALK,GAAA,EAAE,EAKP,CACL;EACC,CAAA,CACD;;AAET"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PanoramaView } from './projection';
|
|
2
|
+
/** Anything WebGL can take as a texture: a decoded image or a playing video. */
|
|
3
|
+
export type PanoramaPicture = HTMLImageElement | HTMLVideoElement | ImageBitmap | HTMLCanvasElement;
|
|
4
|
+
/** What draws the window. */
|
|
5
|
+
export type PanoramaRenderer = {
|
|
6
|
+
/** Sends the picture to the GPU. Call when the picture is a new one (an image) or a new frame (a video). */
|
|
7
|
+
upload: (picture: PanoramaPicture) => void;
|
|
8
|
+
/** Draws the view into a canvas of `width` by `height` device pixels. */
|
|
9
|
+
draw: (view: PanoramaView, width: number, height: number) => void;
|
|
10
|
+
/** How many times `upload` has sent a picture (a video frame, an image), for the documented cost and for tests. */
|
|
11
|
+
uploads: () => number;
|
|
12
|
+
/** Frees the GPU objects. */
|
|
13
|
+
dispose: () => void;
|
|
14
|
+
};
|
|
15
|
+
/** Makes a renderer on `canvas`, or null where WebGL2 is not available (the viewer then shows the flat picture). */
|
|
16
|
+
export declare function createRenderer(canvas: HTMLCanvasElement): PanoramaRenderer | null;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { PanoramaViewer, type PanoramaViewerProps, type PanoramaOverlayApi } from './panorama-viewer';
|
|
2
|
+
export { clampView, describeView, degreesPerPixel, project, projectFlat, unproject, unprojectFlat, wrapYaw, yawDelta, type PanoramaView, type PanoramaSize, type PanoramaPoint } from './projection';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PanoramaPoint, PanoramaSize, PanoramaView } from './projection';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type PanoramaPictureSource = {
|
|
4
|
+
image: string;
|
|
5
|
+
video?: never;
|
|
6
|
+
} | {
|
|
7
|
+
video: React.RefObject<HTMLVideoElement | null>;
|
|
8
|
+
image?: never;
|
|
9
|
+
};
|
|
10
|
+
/** What an overlay is given. */
|
|
11
|
+
export type PanoramaOverlayApi = {
|
|
12
|
+
view: PanoramaView;
|
|
13
|
+
size: PanoramaSize;
|
|
14
|
+
/** Where the direction is in the box, or null behind the camera. */
|
|
15
|
+
project: (yaw: number, pitch: number) => PanoramaPoint | null;
|
|
16
|
+
/** The direction under a place in the box. */
|
|
17
|
+
unproject: (x: number, y: number) => {
|
|
18
|
+
yaw: number;
|
|
19
|
+
pitch: number;
|
|
20
|
+
};
|
|
21
|
+
/** The flat picture is being drawn (no WebGL2). */
|
|
22
|
+
flat: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type PanoramaViewerProps = PanoramaPictureSource & {
|
|
25
|
+
/** Names the viewer: "360 view of the kitchen". Required; the current direction is added to it. */
|
|
26
|
+
label: string;
|
|
27
|
+
/** The view, when the app holds it. */
|
|
28
|
+
view?: PanoramaView;
|
|
29
|
+
/** The view the viewer starts with, when it holds its own. Default straight ahead at 90°. */
|
|
30
|
+
defaultView?: PanoramaView;
|
|
31
|
+
/** The view changed (a drag, a key, a wheel, the slider). Not called for a view the app set. */
|
|
32
|
+
onViewChange?: (view: PanoramaView) => void;
|
|
33
|
+
/** A click that did not drag: the direction under it. */
|
|
34
|
+
onPick?: (direction: {
|
|
35
|
+
yaw: number;
|
|
36
|
+
pitch: number;
|
|
37
|
+
}) => void;
|
|
38
|
+
/** Highest and lowest look, degrees from the horizon. Default 85. */
|
|
39
|
+
maxPitch?: number;
|
|
40
|
+
/** Narrowest and widest field of view, degrees. Default 20 and 120. */
|
|
41
|
+
minFov?: number;
|
|
42
|
+
maxFov?: number;
|
|
43
|
+
/** Zoom with the wheel. Default true. */
|
|
44
|
+
wheelZoom?: boolean;
|
|
45
|
+
/** Show a field-of-view slider under the picture. */
|
|
46
|
+
fovSlider?: boolean;
|
|
47
|
+
/** Markers and outlines drawn over the picture in its own coordinates. */
|
|
48
|
+
overlay?: (api: PanoramaOverlayApi) => React.ReactNode;
|
|
49
|
+
/** `"flat"` draws the flat picture even where WebGL2 is available (a low-power mode, or to see what a browser without it shows). Default `"auto"`. */
|
|
50
|
+
mode?: "auto" | "flat";
|
|
51
|
+
/** The shape of the box. Default 16/9. */
|
|
52
|
+
aspect?: number | `${number}/${number}`;
|
|
53
|
+
className?: string;
|
|
54
|
+
};
|
|
55
|
+
/** A 360 picture or video as a window you pan and zoom, controlled from outside, with an overlay in the picture's coordinates. */
|
|
56
|
+
export declare function PanoramaViewer({ label, image, video, view: controlled, defaultView, onViewChange, onPick, maxPitch, minFov, maxFov, wheelZoom, fovSlider, overlay, mode, aspect, className }: PanoramaViewerProps): React.JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Where the window looks and how wide it sees, degrees. */
|
|
2
|
+
export type PanoramaView = {
|
|
3
|
+
yaw: number;
|
|
4
|
+
pitch: number;
|
|
5
|
+
fov: number;
|
|
6
|
+
};
|
|
7
|
+
/** The size of the picture box in CSS pixels. */
|
|
8
|
+
export type PanoramaSize = {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
/** A place in the box. `inside` says it is within the box; a point behind the camera has none (`project` returns null). */
|
|
13
|
+
export type PanoramaPoint = {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
inside: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** Wraps a heading to (-180, 180]. */
|
|
19
|
+
export declare function wrapYaw(yaw: number): number;
|
|
20
|
+
/** The smallest signed turn from heading `from` to heading `to`, in (-180, 180]. Use it for a difference of headings, never `to - from`. */
|
|
21
|
+
export declare const yawDelta: (from: number, to: number) => number;
|
|
22
|
+
/** Keeps a view inside its limits: heading wrapped, pitch within +-`maxPitch`, field of view within `minFov` to `maxFov`. */
|
|
23
|
+
export declare function clampView(view: PanoramaView, { maxPitch, minFov, maxFov }?: {
|
|
24
|
+
maxPitch?: number;
|
|
25
|
+
minFov?: number;
|
|
26
|
+
maxFov?: number;
|
|
27
|
+
}): PanoramaView;
|
|
28
|
+
/** Where the direction (`yaw`, `pitch`) is drawn in the box for `view`, or null when it is behind the camera. */
|
|
29
|
+
export declare function project(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint | null;
|
|
30
|
+
/** The direction under a point of the box for `view`: the inverse of `project`. */
|
|
31
|
+
export declare function unproject(view: PanoramaView, size: PanoramaSize, x: number, y: number): {
|
|
32
|
+
yaw: number;
|
|
33
|
+
pitch: number;
|
|
34
|
+
};
|
|
35
|
+
/** Pixels to degrees at the middle of the box: how far a drag of `px` turns the view. */
|
|
36
|
+
export declare const degreesPerPixel: (view: PanoramaView, size: PanoramaSize) => number;
|
|
37
|
+
/** The flat picture's own mapping, for the fallback with no WebGL: longitude and latitude are straight across and down, the visible rectangle is `fov` wide and as tall as the box's shape makes it. */
|
|
38
|
+
export declare function projectFlat(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint;
|
|
39
|
+
/** The inverse of `projectFlat`. */
|
|
40
|
+
export declare function unprojectFlat(view: PanoramaView, size: PanoramaSize, x: number, y: number): {
|
|
41
|
+
yaw: number;
|
|
42
|
+
pitch: number;
|
|
43
|
+
};
|
|
44
|
+
/** The direction in words: "Looking 40° right, 5° up", "Looking straight ahead". Whole degrees; nothing is said for less than half a degree. */
|
|
45
|
+
export declare function describeView(view: Pick<PanoramaView, "yaw" | "pitch">): string;
|