efficient-shell 4.137.1 → 4.145.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +77 -11
  2. package/dist/{Browser-ZX5OTOKK.js → Browser-24YNRTKT.js} +14 -14
  3. package/dist/Calculator-LER6KUQC.js +29 -0
  4. package/dist/{ConfirmDialog-NPKW2XHM.js → ConfirmDialog-GAYETRMG.js} +1 -1
  5. package/dist/{CurrencyConverter-2KOM7L6V.js → CurrencyConverter-Y35GFDFF.js} +6 -6
  6. package/dist/{Documents-IZTIQYPG.js → Documents-7FYX2CGT.js} +14 -14
  7. package/dist/{Files-B63KKXGZ.js → Files-RZOML2N6.js} +39 -39
  8. package/dist/{Notepad-WA77V45J.js → Notepad-VVDCBDUA.js} +13 -13
  9. package/dist/PdfViewer-CvLb2j_l.d.ts +40 -0
  10. package/dist/PdfViewer-ZCT3PYXU.js +1 -0
  11. package/dist/{PomodoroTimer-SDUBKXUS.js → PomodoroTimer-VAM3AJOX.js} +37 -37
  12. package/dist/{Preview-D4KOA4OI.js → Preview-HZ37D7QJ.js} +23 -23
  13. package/dist/{Sidebar-Y57LYXXI.js → Sidebar-CVF7C6BO.js} +3 -3
  14. package/dist/{Spreadsheet-JX5E6WH6.js → Spreadsheet-6WX3P6AB.js} +15 -15
  15. package/dist/{Stock-XAQ5WMUZ.js → Stock-AUWI3TUX.js} +3 -3
  16. package/dist/{Weather-HLAGJ5LV.js → Weather-HU75TH7T.js} +13 -13
  17. package/dist/{WorldClock-IRI4VCTA.js → WorldClock-T64MDRMJ.js} +5 -5
  18. package/dist/apps/index.d.ts +3 -23
  19. package/dist/apps/index.js +1 -1
  20. package/dist/brand.css +1 -1
  21. package/dist/{chunk-UZAJ5BF6.js → chunk-2RHMSFZV.js} +7 -7
  22. package/dist/{chunk-466CM2TJ.js → chunk-4FS742BM.js} +1 -1
  23. package/dist/{chunk-JN4WXTWJ.js → chunk-7DAQ3WVP.js} +42 -42
  24. package/dist/chunk-CVTOZCM3.js +24 -0
  25. package/dist/{chunk-H562R4GX.js → chunk-GDSGXDET.js} +1 -1
  26. package/dist/{chunk-A2OQLLYK.js → chunk-I55UMU3R.js} +1 -1
  27. package/dist/chunk-KKOHUQPF.js +1 -0
  28. package/dist/{chunk-Y7BOLDRM.js → chunk-L7TEFXIS.js} +14 -14
  29. package/dist/chunk-LVFMK5OQ.js +29 -0
  30. package/dist/{chunk-5CRAF2AD.js → chunk-MU5H2CDL.js} +2 -2
  31. package/dist/{chunk-FQLMX3IE.js → chunk-NBBOFQPL.js} +441 -442
  32. package/dist/{chunk-TAWKWSPN.js → chunk-RJ4LACFH.js} +3 -3
  33. package/dist/{chunk-B43AGQET.js → chunk-SLCR26NK.js} +4 -4
  34. package/dist/{chunk-XO43FJRM.js → chunk-TFKB2WEB.js} +5 -5
  35. package/dist/chunk-TR6PLN7W.js +1 -0
  36. package/dist/chunk-TWV42Q3K.js +1 -0
  37. package/dist/{chunk-VVAGSKW7.js → chunk-UB22J6EF.js} +1 -1
  38. package/dist/{chunk-44UO7FYU.js → chunk-V453E4KU.js} +4 -4
  39. package/dist/file-intake/index.js +1 -1
  40. package/dist/{index-DVI9DMSu.d.ts → index-NhR7frRu.d.ts} +189 -17
  41. package/dist/index.d.ts +2 -2
  42. package/dist/index.js +235 -235
  43. package/dist/map/index.d.ts +266 -13
  44. package/dist/map/index.js +22 -20
  45. package/dist/page-tabs/index.js +13 -13
  46. package/dist/pdf/index.d.ts +9 -0
  47. package/dist/pdf/index.js +2 -0
  48. package/dist/ui/index.d.ts +1 -1
  49. package/dist/ui/index.js +1 -1
  50. package/dist/ui.css +7 -0
  51. package/package.json +6 -1
  52. package/dist/Calculator-4SQGOQFQ.js +0 -29
  53. package/dist/PdfViewer-RBRGEKWF.js +0 -1
  54. package/dist/chunk-3A46NCXK.js +0 -29
  55. package/dist/chunk-OQDWLHZI.js +0 -1
  56. package/dist/chunk-OWSAMA3I.js +0 -23
  57. package/dist/chunk-U4GTZPXP.js +0 -1
  58. package/dist/chunk-VEGMDXT4.js +0 -1
@@ -9,7 +9,8 @@ import * as maplibre_gl from 'maplibre-gl';
9
9
  * Records on a map. One pin per placed record: a button carrying a glyph (or
10
10
  * an icon) and, for a screen reader, the record's name in words, never the
11
11
  * colour alone. The one map every EFFICIENT portal draws — the admin portal's
12
- * Customer / Supplier maps and Trip Planner, the dealer portal's Address Book.
12
+ * Customer / Supplier maps and Trip Planner, the dealer portal's Address Book,
13
+ * Foyerboard's leads and day plans.
13
14
  *
14
15
  * Ported from Foyerboard's leads map, which draws its map the way
15
16
  * whoson.today does: MapLibre over OpenFreeMap's vector tiles — free,
@@ -20,32 +21,85 @@ import * as maplibre_gl from 'maplibre-gl';
20
21
  * MapLibre is fetched only once the map mounts (`loadMapLibre`, which also
21
22
  * says how the host serves its worker), and the map is made once per mount;
22
23
  * pins, the selection, the theme and the fitted view are separate effects so
23
- * a re-render never rebuilds the map.
24
+ * a re-render never rebuilds the map. Pins are made again only when `pins`
25
+ * itself changes — choosing or pointing at one restyles it in place, so the
26
+ * keyboard's focus stays on it — so pass a memoised array.
24
27
  *
25
- * It also draws ROUTES — the Trip Planner's days, each a line under the pins
26
- * (solid along the streets, dashed where it is only a straight-line estimate),
27
- * again after a theme change, which replaces the style and every layer on it.
28
+ * It also draws ROUTES — the Trip Planner's days, a day plan's drive — each a
29
+ * line under the pins (solid along the streets, dashed where it is only a
30
+ * straight-line estimate), again after a theme change, which replaces the
31
+ * style and every layer on it; and MARKS — points that are not records (where
32
+ * a day starts and ends, a place on the route), named but never pressed.
33
+ *
34
+ * What else it can do, each opt-in:
35
+ *
36
+ * - `groupCrowded` keeps every pin a target of 24 px or more with no two
37
+ * targets touching (WCAG 2.5.8): crowded pins are drawn as one group, which
38
+ * zooms in to set them apart (`pinLayout.ts`).
39
+ * - `card` stands the chosen pin's card beside it, pointing at it, moving with
40
+ * the map (`cardPlacement.ts`) — along the bottom edge of a narrow map.
41
+ * - `highlightKey` rings what the list beside the map points at
42
+ * (`useMapHighlight`): a picture, never a target, and the map never moves for it.
43
+ * - `picking` + `onPick` take the next click on the map as a point.
44
+ * - `fullScreen` draws a full-screen control and drives the browser's own.
28
45
  */
29
46
  interface MapPin {
30
47
  key: string;
48
+ /** The pin's accessible name: the record's name in words, and whatever its
49
+ * colour or icon says (a stage, a stop's number) — never the colour alone. */
31
50
  label: string;
51
+ /** Its tooltip; `label` when unset. */
52
+ title?: string;
32
53
  lat: number;
33
54
  lng: number;
34
- /** One or two characters drawn on the pin (when it has no `icon`). */
55
+ /** One or two characters drawn on the pin (when it has no icon). A stop shows its number instead. */
35
56
  glyph: string;
36
57
  /** An icon drawn instead of the glyph: SVG path data, 24 × 24, stroked —
37
58
  * the admin Trip Planner's stage icons. */
38
59
  icon?: readonly string[];
60
+ /** An icon drawn instead of the glyph as a React element — a lucide-react or
61
+ * heroicons component. Wins over `icon`. */
62
+ iconNode?: ReactNode;
39
63
  /** A small tag on the pin's corner — a visit's place in the day's order. */
40
64
  badge?: string;
41
65
  /** Tone classes for the badge; white by default. */
42
66
  badgeTone?: string;
43
- /** Tone classes (background + text) — see `pinTone`. */
67
+ /** Tone classes for the pin's disc (background + text) — see `pinTone`. A
68
+ * border colour among them replaces the white edge. */
44
69
  tone: string;
70
+ /** `data-*` attributes on the pin's disc, for a host stylesheet that colours
71
+ * by key — `{ stageColour: 'red' }` is `data-stage-colour="red"`. */
72
+ data?: Readonly<Record<string, string>>;
45
73
  /** The pin marks an area, not the address: drawn dashed and faded. */
46
74
  approximate?: boolean;
47
75
  /** Shown for context only (another day's visits on the Trip Planner): drawn faint. */
48
76
  faded?: boolean;
77
+ /** Its number on a route (1 is the first stop): drawn as that number, a
78
+ * little bigger and ringed. With `groupCrowded`, stops group only with
79
+ * stops ("3–4"), and a pin that would sit under one is left off. */
80
+ stop?: number;
81
+ /** Drawn as a small dot on a full-size target, without its glyph — a record
82
+ * shown beside a route's stops, which could join it. */
83
+ dot?: boolean;
84
+ }
85
+ /** A point that is not a record: drawn and named, never pressed. */
86
+ interface MapMark {
87
+ key: string;
88
+ /** Its accessible name — what it is and where: "Start: Office". */
89
+ label: string;
90
+ /** Its tooltip; `label` when unset. */
91
+ title?: string;
92
+ lat: number;
93
+ lng: number;
94
+ /** What is written on it: "S", "E", a stop's number. */
95
+ text: string;
96
+ /** Tone classes for the square; a dark one edged in white when unset. A
97
+ * border colour among them replaces the white edge. */
98
+ tone?: string;
99
+ /** Drawn at a stop's size — a place on the route among numbered stops. */
100
+ stop?: boolean;
101
+ /** `data-*` attributes on the mark, as on a pin. */
102
+ data?: Readonly<Record<string, string>>;
49
103
  }
50
104
  /** A line on the map: a day's road, or its straight-line estimate. */
51
105
  interface MapRoute {
@@ -56,8 +110,14 @@ interface MapRoute {
56
110
  estimate: boolean;
57
111
  /** Context only (another day): drawn faint. */
58
112
  faded?: boolean;
113
+ /** The line's colour: any CSS colour, custom properties included
114
+ * (`var(--tone-info-line)`). The theme's accent when unset. */
115
+ color?: string;
116
+ /** A credit (HTML) for the map's attribution while this route is drawn —
117
+ * the road router's, whose terms ask for it beside the map. */
118
+ attribution?: string;
59
119
  }
60
- declare function EntityMap({ pins, selectedKey, focus, onSelect, ariaLabel, className, children, routes, fitTo, attribution, }: {
120
+ declare function EntityMap({ pins, selectedKey, focus, onSelect, ariaLabel, className, children, routes, fitTo, attribution, marks, groupCrowded, noun, highlightKey, picking, onPick, card, cardMinMapWidth, fullScreen, initialView, cooperativeGestures, }: {
61
121
  pins: MapPin[];
62
122
  selectedKey: string | null;
63
123
  /** Bump `n` to fly to a pin (the list's "show on map"). */
@@ -68,16 +128,209 @@ declare function EntityMap({ pins, selectedKey, focus, onSelect, ariaLabel, clas
68
128
  onSelect: (key: string) => void;
69
129
  ariaLabel: string;
70
130
  className?: string;
71
- /** Drawn over the map: the selected record's card, the legend. */
131
+ /** Drawn over the map: the selected record's card, the legend, a bar. */
72
132
  children?: ReactNode;
73
- /** Lines under the pins — the Trip Planner's day routes. */
133
+ /** Lines under the pins — the Trip Planner's day routes, a day plan's drive. */
74
134
  routes?: MapRoute[];
75
- /** Fit the view to these pins only (the day being planned); all pins when unset. */
135
+ /** Fit the view to these pins and marks only (the day being planned); all pins when unset. */
76
136
  fitTo?: string[] | null;
77
- /** Extra credit line for the attribution (HTML), e.g. the router's. Read once, at mount. */
137
+ /** Extra credit line for the attribution (HTML), e.g. the router's. Read once, at mount;
138
+ * a credit that comes and goes with a route is the route's `attribution`. */
78
139
  attribution?: string;
140
+ /** Points that are not records — a route's start and end, a place on it. */
141
+ marks?: MapMark[];
142
+ /** Keep every pin a target of 24 px or more with no two touching (WCAG 2.5.8):
143
+ * crowded pins become one group that zooms in to set them apart, and a pin
144
+ * that would sit under a stop or crowd a control over the map is left off
145
+ * until the map moves. */
146
+ groupCrowded?: boolean;
147
+ /** What the pins are, for a group's name: `n => n === 1 ? 'lead' : 'leads'`. "place(s)" by default. */
148
+ noun?: (count: number) => string;
149
+ /** What the list beside the map points at (`useMapHighlight`): ringed where
150
+ * the map shows it — its pin, the group holding it, or its own spot. */
151
+ highlightKey?: string | null;
152
+ /** The next click on the map is a point (`onPick`); the pointer is a crosshair meanwhile. */
153
+ picking?: boolean;
154
+ onPick?: (point: {
155
+ lat: number;
156
+ lng: number;
157
+ }) => void;
158
+ /** The chosen pin's card: beside its pin, pointing at it, moving with the
159
+ * map — along the bottom edge of a map narrower than `cardMinMapWidth`. */
160
+ card?: ReactNode;
161
+ cardMinMapWidth?: number;
162
+ /** A full-screen control over the map's top-left corner. The host lays the
163
+ * page out for `active`; the map asks the browser for full screen to match,
164
+ * and says when the browser leaves it (Escape, its own control). */
165
+ fullScreen?: {
166
+ active: boolean;
167
+ onChange: (active: boolean) => void;
168
+ };
169
+ /** Where the view opens before it has fitted the pins: the whole world by default. */
170
+ initialView?: {
171
+ center: [number, number];
172
+ zoom: number;
173
+ };
174
+ /** Two fingers to move the map (one scrolls the page) — `'coarse'` on touch screens only. */
175
+ cooperativeGestures?: boolean | 'coarse';
79
176
  }): react_jsx_runtime.JSX.Element;
80
177
 
178
+ /**
179
+ * What a list beside an `EntityMap` points at, for its `highlightKey` — and
180
+ * what a row spreads on itself (`pointAt(key)`) to point at its record: the
181
+ * pointer over it, or the keyboard's focus in it. A row letting go clears only
182
+ * its own, so moving from one row to the next never flickers through nothing.
183
+ *
184
+ * const { highlightKey, pointAt } = useMapHighlight();
185
+ * <li {...pointAt(lead.id)}>…</li>
186
+ * <EntityMap highlightKey={highlightKey} … />
187
+ *
188
+ * Ported from Foyerboard's leads map, where pointing at a venue in the list
189
+ * rings its pin.
190
+ */
191
+ declare function useMapHighlight(): {
192
+ highlightKey: string | null;
193
+ pointAt: (key: string) => {
194
+ onMouseEnter: () => void;
195
+ onMouseLeave: () => void;
196
+ onFocus: () => void;
197
+ onBlur: () => void;
198
+ };
199
+ };
200
+
201
+ /**
202
+ * Where `EntityMap` draws its pins when it keeps their targets apart
203
+ * (`groupCrowded`), worked out from where each pin falls on the screen. Pure,
204
+ * so it is tested without a map.
205
+ *
206
+ * A pin is a target of at least 24 × 24 px (WCAG 2.5.8), and no two targets
207
+ * may overlap: the one beneath could then be pressed only where the other
208
+ * leaves room, which fails the criterion however big each one is (axe's
209
+ * `target-size`; 4.13 even THROWS on a target several others cover, and
210
+ * reports the rule as `incomplete`, not as a violation). So pins whose targets
211
+ * would touch become ONE target — a group, which zooms in to set them apart —
212
+ * and a route's stops group only with stops ("3–4"). A pin whose target would
213
+ * sit under a stop, or crowd something pressable drawn over the map (its zoom
214
+ * buttons, its attribution toggle, the chosen pin's card), is left off until
215
+ * the map moves: the stop is what matters there, and the list beside the map
216
+ * has every record.
217
+ *
218
+ * Ported from Foyerboard's leads map (`map-pins.ts`), where a day plan's
219
+ * stops sit among every other lead.
220
+ */
221
+ /** The smallest target WCAG 2.5.8 allows, in CSS px: every pin and group is at least this. */
222
+ declare const MAP_TARGET_PX = 24;
223
+ /** A stop's target: its numbered disc, a little bigger than any other pin. */
224
+ declare const MAP_STOP_PX = 28;
225
+ /** Two pins this far apart, across or down, never share a group — whatever their kind. */
226
+ declare const MAP_APART_PX: number;
227
+ interface PinBox {
228
+ left: number;
229
+ top: number;
230
+ right: number;
231
+ bottom: number;
232
+ }
233
+ interface PinAt {
234
+ key: string;
235
+ /** Where the pin falls, in px from the map's top left corner. */
236
+ x: number;
237
+ y: number;
238
+ /** Its number on the route (1 is the first stop), or null. */
239
+ stop: number | null;
240
+ }
241
+ interface PinGroup {
242
+ /** The pins it stands for; it is drawn where the first one is. */
243
+ keys: string[];
244
+ /** The stops' numbers, in order — empty for a group of pins that are not stops. */
245
+ stops: number[];
246
+ x: number;
247
+ y: number;
248
+ /** Its target. */
249
+ width: number;
250
+ height: number;
251
+ /** Pins left off because they would sit under this stop. */
252
+ under: number;
253
+ }
254
+ interface PinLayout {
255
+ groups: PinGroup[];
256
+ /** The pins not drawn: under a stop, or crowding something pressable over the map. */
257
+ hidden: string[];
258
+ }
259
+ /** "3", "3–4", "2, 5", "1–3, 7": a group of stops, by number. */
260
+ declare function stopsLabel(stops: readonly number[]): string;
261
+ /**
262
+ * Places `pins` — stops first, by number, then every other pin in the order
263
+ * given — and says which are drawn as themselves, which as a group and which
264
+ * not at all. `over` are the boxes of what can be pressed over the map, which a
265
+ * pin must not crowd. Where a pin goes depends only on the zoom and on `over`,
266
+ * never on which pin is chosen, so choosing one never moves the others.
267
+ */
268
+ declare function layoutPins(pins: readonly PinAt[], over?: readonly PinBox[]): PinLayout;
269
+ /**
270
+ * The zoom at which a pin stands on its own: every other pin at least
271
+ * `MAP_APART_PX` away from it, across or down. `at` and `others` are where they
272
+ * fall at `zoom`; each step of zoom doubles every distance. A pin on the very
273
+ * spot of another never stands apart (Infinity) — the caller caps it at the
274
+ * map's closest.
275
+ */
276
+ declare function zoomApart(at: {
277
+ x: number;
278
+ y: number;
279
+ }, others: readonly {
280
+ x: number;
281
+ y: number;
282
+ }[], zoom: number): number;
283
+
284
+ /**
285
+ * Where the chosen pin's card goes on an `EntityMap` (its `card`): beside its
286
+ * pin, pointing at it — above the pin where there is room, else below it, and
287
+ * turned to a corner by the map's sides so it never runs off them. Where it
288
+ * fits neither above nor below, it goes on the roomier side and the map moves
289
+ * by what is missing (`move`). Pure, so it is tested without a map: the map
290
+ * measures, this decides.
291
+ *
292
+ * The anchor is MapLibre's popup anchor: the side of the CARD that points at
293
+ * the pin — "bottom" is a card above it.
294
+ *
295
+ * Ported from Foyerboard's leads map (`map-card.ts`).
296
+ */
297
+ type CardAnchor = 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
298
+ /**
299
+ * A map narrower than this shows the card along its bottom edge instead, as a
300
+ * phone would: a card beside a pin needs the card's width (26rem) and a margin
301
+ * either side.
302
+ */
303
+ declare const CARD_MIN_MAP_WIDTH = 480;
304
+ interface Size {
305
+ width: number;
306
+ height: number;
307
+ }
308
+ interface CardPlace {
309
+ anchor: CardAnchor;
310
+ /** How far the map's content must move (px, right and down) for the whole card to be on the map. */
311
+ move: {
312
+ x: number;
313
+ y: number;
314
+ };
315
+ }
316
+ /**
317
+ * How tall the card itself (its pointer not included) may be on a map this
318
+ * tall: however far the map must move, the pin is still on it. A card taller
319
+ * than this scrolls.
320
+ */
321
+ declare const cardMaxHeight: (mapHeight: number, top?: number) => number;
322
+ /**
323
+ * `at` is where the pin is on the map, `card` the card's size (its pointer
324
+ * included), `map` the map's — all in px from the map's top left corner.
325
+ * `top` is how far down the card must stay: below the controls drawn along
326
+ * the map's top edge (its zoom buttons, a full-screen control), which would
327
+ * otherwise sit on the card's heading.
328
+ */
329
+ declare function placeCard(at: {
330
+ x: number;
331
+ y: number;
332
+ }, card: Size, map: Size, top?: number): CardPlace;
333
+
81
334
  /**
82
335
  * Map points — the wire shape every EFFICIENT map endpoint answers with, and
83
336
  * the pure logic over it: what a point says about itself, how its pin looks,
@@ -326,4 +579,4 @@ declare const mapLibreWorkerUrl: (version: string) => string;
326
579
  /** MapLibre, loaded once per page; a failed load is retried by the next map. */
327
580
  declare function loadMapLibre(): Promise<MapLibre>;
328
581
 
329
- export { COMPACT_SHOW, EntityMap, LocationsMap, MAPLIBRE_WORKER_FILE, MAP_CATEGORIES, type MapCategory, MapLegend, type MapPin, type MapPlacement, type MapPoint, type MapPoints, type MapRoute, type MapSummary, PENDING_POLL_MS, SECONDARY_KINDS, SelectedCard, categoryLabel, categoryTone, foldAttributionOnce, isOnMap, legendCategories, loadMapLibre, locationNumbers, mapLibreWorkerUrl, mapPointsRefetchInterval, offMapNotes, pinCategory, pinGlyph, pinTone, placementNote, pointKey, summarize, summaryText, useMapPoints };
582
+ export { CARD_MIN_MAP_WIDTH, COMPACT_SHOW, type CardAnchor, type CardPlace, EntityMap, LocationsMap, MAPLIBRE_WORKER_FILE, MAP_APART_PX, MAP_CATEGORIES, MAP_STOP_PX, MAP_TARGET_PX, type MapCategory, MapLegend, type MapMark, type MapPin, type MapPlacement, type MapPoint, type MapPoints, type MapRoute, type MapSummary, PENDING_POLL_MS, type PinAt, type PinBox, type PinGroup, type PinLayout, SECONDARY_KINDS, SelectedCard, cardMaxHeight, categoryLabel, categoryTone, foldAttributionOnce, isOnMap, layoutPins, legendCategories, loadMapLibre, locationNumbers, mapLibreWorkerUrl, mapPointsRefetchInterval, offMapNotes, pinCategory, pinGlyph, pinTone, placeCard, placementNote, pointKey, stopsLabel, summarize, summaryText, useMapHighlight, useMapPoints, zoomApart };
package/dist/map/index.js CHANGED
@@ -1,21 +1,23 @@
1
1
  "use client";
2
- import{Button_default as e}from"../chunk-PH3PRIFP.js";import{rootIsDark as t,ROOT_THEME_ATTRIBUTES as r}from"../chunk-MAIHBBWT.js";import{useRef as n,useState as a,useEffect as o,useCallback as l,useMemo as i,useSyncExternalStore as s}from"react";import{jsxs as c,jsx as d}from"react/jsx-runtime";import{useQuery as u}from"@tanstack/react-query";var p="maplibregl-compact-show";function m(e){if(!e)return()=>{};const t=()=>!!e.classList.contains(p)&&(e.classList.remove(p),!0);if(t())return()=>{};const r=new MutationObserver(()=>{t()&&r.disconnect()});return r.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()}var h="maplibre-gl-worker.mjs",g=e=>`/maplibre-gl/${e}/${h}`,f=null;function b(){return f??=Promise.all([import("maplibre-gl"),import("maplibre-gl/dist/maplibre-gl.css")]).then(([e])=>(e.setWorkerUrl(g(e.getVersion())),e)).catch(e=>{throw f=null,e}),f}function y(e){const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:r}),()=>t.disconnect()}var x=t;var w="routes";function v(){const e=document.createElement("span");e.className="text-blue-600",e.style.display="none",document.body.appendChild(e);const t=getComputedStyle(e).color||"#2563eb";return e.remove(),function(e){const t=document.createElement("canvas").getContext("2d");if(!t)return"#2563eb";t.fillStyle="#2563eb",t.fillStyle=e,t.fillRect(0,0,1,1);const[r,n,a]=t.getImageData(0,0,1,1).data;return`rgb(${r}, ${n}, ${a})`}(t)}var N={light:"https://tiles.openfreemap.org/styles/positron",dark:"https://tiles.openfreemap.org/styles/dark"},k={center:[30,20],zoom:1},C="http://www.w3.org/2000/svg";function $(e,t){const r=document.createElement("button");if(r.type="button",r.title=e.approximate?`${e.label} (approximate)`:e.label,r.setAttribute("aria-label",e.approximate?`${e.label}, approximate location`:e.label),r.dataset.pin=e.key,r.className=["relative grid place-items-center rounded-full border-2 border-white font-semibold leading-none shadow-md cursor-pointer",e.tone,t?"h-8 w-8 text-xs ring-2 ring-gray-900 ring-offset-1":"h-6 w-6 text-[10px]",e.approximate?"border-dashed opacity-80":"",e.faded&&!t?"opacity-40":""].join(" "),e.icon?.length?r.appendChild(function(e,t){const r=document.createElementNS(C,"svg");r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("fill","none"),r.setAttribute("stroke","currentColor"),r.setAttribute("stroke-width","2"),r.setAttribute("aria-hidden","true"),r.setAttribute("class",t?"h-4 w-4":"h-3.5 w-3.5");for(const t of e){const e=document.createElementNS(C,"path");e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("d",t),r.appendChild(e)}return r}(e.icon,t)):r.textContent=e.glyph,e.badge){const t=document.createElement("span");t.setAttribute("aria-hidden","true"),t.className=["absolute -right-2 -top-2 grid h-4 min-w-4 place-items-center rounded-full px-0.5 text-[9px] font-semibold leading-none shadow",e.badgeTone??"bg-white text-gray-900"].join(" "),t.textContent=e.badge,r.appendChild(t)}return r}function L({pins:e,selectedKey:t,focus:r,onSelect:i,ariaLabel:u,className:p="",children:h,routes:g,fitTo:f,attribution:C}){const L=n(null),S=n(null),j=n(null),A=n([]),M=n(""),[T,z]=a(!1),[P,E]=a(!1),F=s(y,x,()=>!1)?"dark":"light",R=n({onSelect:i,pins:e,selectedKey:t});o(()=>{R.current={onSelect:i,pins:e,selectedKey:t}});const B=l(()=>{const e=S.current,{pins:t,selectedKey:r}=R.current,n=r?t.find(e=>e.key===r):void 0;if(!e||!n||e.getBounds().contains([n.lng,n.lat]))return;const a=window.matchMedia("(prefers-reduced-motion: reduce)").matches;e.easeTo({center:[n.lng,n.lat],duration:a?0:400})},[]);o(()=>{let e=!1,t=null,r=null,n=()=>{};return(async()=>{try{const a=await b();if(e||!L.current)return;j.current=a,t=new a.Map({container:L.current,style:N[F],center:k.center,zoom:k.zoom,attributionControl:C?{compact:!0,customAttribution:C}:{compact:!0},dragRotate:!1,pitchWithRotate:!1,touchPitch:!1,maxPitch:0}),t.touchZoomRotate.disableRotation(),t.keyboard.disableRotation(),t.addControl(new a.NavigationControl({showCompass:!1}),"top-right"),t.on("error",e=>console.warn("[map]",e.error?.message)),n=m(L.current.querySelector(".maplibregl-ctrl-attrib"));const o=t;r=new ResizeObserver(()=>{o.resize(),B()}),r.observe(L.current),S.current=t,z(!0)}catch(t){console.error("[map] could not start",t),e||E(!0)}})(),()=>{e=!0,r?.disconnect(),n(),A.current.forEach(e=>e.remove()),A.current=[],t?.remove(),S.current=null}},[]);const q=n(F);return o(()=>{T&&S.current&&q.current!==F&&(q.current=F,S.current.setStyle(N[F]))},[T,F]),o(()=>{const r=S.current,n=j.current;if(!T||!r||!n)return;A.current.forEach(e=>e.remove()),A.current=[];const a=[...e].sort((e,r)=>Number(e.key===t)-Number(r.key===t));for(const e of a){const a=$(e,e.key===t);a.addEventListener("click",t=>{t.stopPropagation(),R.current.onSelect(e.key)}),A.current.push(new n.Marker({element:a,anchor:"center"}).setLngLat([e.lng,e.lat]).addTo(r))}},[T,e,t]),o(()=>{if(!T||!t)return;const e=requestAnimationFrame(B);return()=>cancelAnimationFrame(e)},[T,t,B]),o(()=>{const t=S.current,r=j.current,n=f?e.filter(e=>f.includes(e.key)):e;if(!T||!t||!r||0===n.length)return;const a=n.map(e=>`${e.key}@${e.lat},${e.lng}`).sort().join("|");if(M.current===a)return;const o=""===M.current;if(M.current=a,1===n.length)return void t.jumpTo({center:[n[0].lng,n[0].lat],zoom:13});const l=new r.LngLatBounds([n[0].lng,n[0].lat],[n[0].lng,n[0].lat]);for(const e of n)l.extend([e.lng,e.lat]);t.fitBounds(l,{padding:48,maxZoom:14,animate:!o})},[T,e,f]),o(()=>{const e=S.current;if(!T||!e)return;const t={type:"FeatureCollection",features:(g??[]).filter(e=>e.coordinates.length>=2).map(e=>({type:"Feature",properties:{key:e.key,estimate:e.estimate,faded:!!e.faded},geometry:{type:"LineString",coordinates:e.coordinates}}))},r=()=>{try{(()=>{const r=v(),n=["case",["get","faded"],.25,.85],a=e.getSource(w);a?a.setData(t):e.addSource(w,{type:"geojson",data:t}),e.getLayer("routes-road")?e.setPaintProperty("routes-road","line-color",r):e.addLayer({id:"routes-road",type:"line",source:w,filter:["!",["get","estimate"]],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":r,"line-width":4,"line-opacity":n}}),e.getLayer("routes-estimate")?e.setPaintProperty("routes-estimate","line-color",r):e.addLayer({id:"routes-estimate",type:"line",source:w,filter:["get","estimate"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":r,"line-width":3,"line-dasharray":[1.5,1.5],"line-opacity":n}})})()}catch(e){console.debug("[map] routes wait for the style",e)}};return r(),e.on("style.load",r),e.once("idle",r),()=>{e.off("style.load",r),e.off("idle",r)}},[T,g,F]),o(()=>{const t=S.current;if(!T||!t||!r)return;const n=e.find(e=>e.key===r.key);if(!n)return;const a={center:[n.lng,n.lat],zoom:Math.max(t.getZoom(),13)};window.matchMedia("(prefers-reduced-motion: reduce)").matches?t.jumpTo(a):t.flyTo({...a,duration:600})},[T,r?.n]),/* @__PURE__ */c("div",{className:`relative min-h-72 overflow-hidden rounded-lg border border-gray-200 bg-gray-100 ${p}`,children:[
3
- /* @__PURE__ */d("div",{className:"absolute inset-0",children:/* @__PURE__ */d("div",{ref:L,className:"h-full w-full",role:"region","aria-label":u})}),P&&/* @__PURE__ */d("p",{className:"absolute inset-0 grid place-items-center p-6 text-center text-sm text-gray-500",children:"The map could not be drawn here. The list has everything it shows."}),h]})}var S=3e3,j=e=>!!e?.pending&&3e3,A=e=>`${e.kind}:${e.id}`,M=e=>("located"===e.placement||"approximate"===e.placement)&&null!=e.lat&&null!=e.lng;function T(e){switch(e){case"located":return null;case"approximate":return"Approximate: only the suburb or postcode matched";case"pending":return"Locating…";case"not_found":return"Not on the map: address not found";case"failed":return"Not on the map: the map service could not be reached";case"no_address":return"Not on the map: no city or postcode"}}var z={importer:{label:"Importer",tone:"bg-sky-600 text-white"},dealer:{label:"Dealer",tone:"bg-purple-600 text-white"},retail:{label:"Retail",tone:"bg-green-600 text-white"},supplier:{label:"Supplier",tone:"bg-sky-600 text-white"},delivery_location:{label:"Delivery location",tone:"bg-amber-600 text-white"},warehouse:{label:"Warehouse",tone:"bg-amber-600 text-white"}},P=["importer","dealer","retail","supplier","delivery_location","warehouse"];function E(e){return"supplier"===e.kind?"supplier":"customer"===e.kind?e.category||"importer":e.kind}var F=(e,t=z)=>t[e]?.tone??"bg-gray-700 text-white",R=(e,t=z)=>t[e]?.label??e,B=(e,t)=>F(E(e),t);function q(e,t,r=z){return null!=t?String(t):(r[E(e)]?.label??"").charAt(0).toUpperCase()}var K=["delivery_location","warehouse"];function O(e,t=K){const r=/* @__PURE__ */new Map;let n=0;for(const a of e)t.includes(a.kind)&&r.set(A(a),++n);return r}function W(e){const t={onMap:0,approximate:0,pending:0,off:0};for(const r of e)M(r)?(t.onMap+=1,"approximate"===r.placement&&(t.approximate+=1)):"pending"===r.placement?t.pending+=1:t.off+=1;return t}function I(e){const t=[`${e.onMap} on the map`];return e.approximate&&t.push(`${e.approximate} approximate`),e.pending&&t.push(`${e.pending} locating`),e.off&&t.push(`${e.off} not on the map`),t.join(" · ")}function _(e){const t=[...new Set(e.filter(M).map(E))];return[...P.filter(e=>t.includes(e)),...t.filter(e=>!P.includes(e))]}function D(e,t){return e.filter(e=>!M(e)&&"pending"!==e.placement).map(e=>{const r=t?.get(A(e)),n=T(e.placement)?.replace(/^Not on the map: /,"")??"";return{key:A(e),text:`${null!=r?`${r}. `:""}${e.label}: ${n}`}})}function H({categories:e,palette:t=z,floating:r=!0}){return e.length<2?null:/* @__PURE__ */d("div",{className:(r?"absolute left-3 top-3 z-10 ":"")+"flex flex-wrap gap-x-3 gap-y-1 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs text-gray-600 shadow-sm",children:e.map(e=>/* @__PURE__ */c("span",{className:"inline-flex items-center gap-1.5",children:[
4
- /* @__PURE__ */d("span",{"aria-hidden":!0,className:`h-2.5 w-2.5 rounded-full ${F(e,t)}`}),R(e,t)]},e))})}function Z({point:t,number:r,onOpen:n,onClose:a,palette:o=z}){const l=T(t.placement),i=E(t);/* @__PURE__ */
5
- return c("section",{"aria-label":`${t.label}, chosen on the map`,className:"absolute bottom-3 left-3 right-3 z-10 max-w-md space-y-1.5 rounded-lg border border-gray-200 bg-white p-3 shadow-md",children:[
6
- /* @__PURE__ */c("div",{className:"flex items-start justify-between gap-2",children:[
7
- /* @__PURE__ */c("div",{className:"min-w-0",children:[
8
- /* @__PURE__ */c("h3",{className:"text-sm font-semibold text-gray-900 [overflow-wrap:anywhere]",children:[null!=r&&/* @__PURE__ */c("span",{className:"mr-1 text-gray-400",children:[r,"."]}),t.label,t.code&&/* @__PURE__ */d("span",{className:"ml-1.5 text-xs font-normal text-gray-400",children:t.code})]}),
9
- /* @__PURE__ */d("p",{className:"text-xs text-gray-500",children:o[i]?R(i,o):t.category})]}),
10
- /* @__PURE__ */d("button",{type:"button",onClick:a,"aria-label":"Close",className:"rounded p-0.5 text-gray-400 hover:text-gray-600",children:/* @__PURE__ */d("svg",{"aria-hidden":!0,className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */d("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),
11
- /* @__PURE__ */d("p",{className:"text-sm text-gray-700 [overflow-wrap:anywhere]",children:t.address||"—"}),l&&/* @__PURE__ */d("p",{className:"text-xs text-gray-500",children:l}),t.matched&&"approximate"===t.placement&&/* @__PURE__ */c("p",{className:"text-xs text-gray-400 [overflow-wrap:anywhere]",children:["Placed at: ",t.matched]}),n&&/* @__PURE__ */d("div",{className:"flex justify-end",children:/* @__PURE__ */d(e,{variant:"secondary",size:"sm",onClick:n,children:"Open"})})]})}function U(e,t,{staleTime:r}={}){return u({queryKey:e,queryFn:t,staleTime:r,refetchInterval:e=>j(e.state.data)})}function V({queryKey:e,queryFn:t,refreshSignal:r,onOpen:l,ariaLabel:s,title:u="Locations",palette:p=z,numbers:m,className:h="",mapClassName:g="min-h-[240px] flex-1"}){const{data:f,isError:b,refetch:y}=U(e,t,{staleTime:0}),x=n(!1);o(()=>{x.current?y():x.current=!0},[r]);const[w,v]=a(null),N=i(()=>f?.points??[],[f]),k=i(()=>m??O(N),[m,N]),C=i(()=>N.filter(M).map(e=>({key:A(e),label:e.label,lat:e.lat,lng:e.lng,glyph:q(e,k.get(A(e))??null,p),tone:B(e,p),approximate:"approximate"===e.placement})),[N,k,p]),$=i(()=>D(N,k),[N,k]),S=i(()=>_(N),[N]),j=f?.pending??0,T=N.find(e=>A(e)===w)??null,P=T&&l?l(T):null;/* @__PURE__ */
12
- return c("section",{"aria-label":u,className:`flex min-w-0 flex-col ${h}`,children:[
13
- /* @__PURE__ */c("div",{className:"flex min-h-[30px] items-center justify-between mb-2",children:[
14
- /* @__PURE__ */d("h3",{className:"text-sm font-semibold text-gray-900",children:u}),f&&/* @__PURE__ */d("span",{className:"text-xs text-gray-500",children:I(W(N))})]}),
15
- /* @__PURE__ */c(L,{pins:C,selectedKey:w,focus:null,onSelect:v,ariaLabel:s,className:g,children:[
16
- /* @__PURE__ */c("div",{className:"absolute left-3 top-3 z-10 flex max-w-[70%] flex-col items-start gap-1.5",children:[
17
- /* @__PURE__ */d(H,{categories:S,palette:p,floating:!1}),b&&/* @__PURE__ */c("div",{className:"flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs text-gray-600 shadow-sm",children:["Couldn’t load the locations.",
18
- /* @__PURE__ */d("button",{type:"button",onClick:()=>{y()},className:"font-medium text-blue-600 hover:text-blue-800 hover:underline",children:"Try again"})]}),!b&&(j>0||$.length>0)&&/* @__PURE__ */c("div",{className:"max-w-full space-y-0.5 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs shadow-sm","aria-live":"polite",children:[j>0&&/* @__PURE__ */c("p",{className:"flex items-center gap-1.5 text-gray-500",children:[
19
- /* @__PURE__ */c("svg",{className:"h-3 w-3 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[
20
- /* @__PURE__ */d("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),
21
- /* @__PURE__ */d("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),"Locating ",j," address",1===j?"":"es","…"]}),$.slice(0,3).map(e=>/* @__PURE__ */d("p",{className:"truncate text-amber-700",title:e.text,children:e.text},e.key)),$.length>3&&/* @__PURE__ */c("p",{className:"text-gray-500",children:["+",$.length-3," more not on the map"]})]})]}),T&&/* @__PURE__ */d(Z,{point:T,number:k.get(A(T))??null,onOpen:P,onClose:()=>v(null),palette:p})]})]})}export{p as COMPACT_SHOW,L as EntityMap,V as LocationsMap,h as MAPLIBRE_WORKER_FILE,z as MAP_CATEGORIES,H as MapLegend,S as PENDING_POLL_MS,K as SECONDARY_KINDS,Z as SelectedCard,R as categoryLabel,F as categoryTone,m as foldAttributionOnce,M as isOnMap,_ as legendCategories,b as loadMapLibre,O as locationNumbers,g as mapLibreWorkerUrl,j as mapPointsRefetchInterval,D as offMapNotes,E as pinCategory,q as pinGlyph,B as pinTone,T as placementNote,A as pointKey,W as summarize,I as summaryText,U as useMapPoints};
2
+ import{Button_default as e}from"../chunk-PH3PRIFP.js";import{rootIsDark as t,ROOT_THEME_ATTRIBUTES as n}from"../chunk-MAIHBBWT.js";import{useShellStrings as r}from"../chunk-TR6PLN7W.js";import{useRef as o,useState as a,useEffect as l,useCallback as i,useMemo as s,useSyncExternalStore as c}from"react";import{createPortal as u}from"react-dom";import{jsxs as d,jsx as p,Fragment as m}from"react/jsx-runtime";import{useQuery as h}from"@tanstack/react-query";var g="maplibregl-compact-show";function f(e){if(!e)return()=>{};const t=()=>!!e.classList.contains(g)&&(e.classList.remove(g),!0);if(t())return()=>{};const n=new MutationObserver(()=>{t()&&n.disconnect()});return n.observe(e,{attributes:!0,attributeFilter:["class"]}),()=>n.disconnect()}var y=20,b=12,x=480,v={center:[0,0],left:[y,0],right:[-20,0],top:[0,y],"top-left":[0,y],"top-right":[0,y],bottom:[0,-20],"bottom-left":[0,-20],"bottom-right":[0,-20]},w=(e,t=12)=>Math.max(0,Math.floor(e-t-b-y-10-16));function k(e,t,n,r=12){const o=e.y-y-r,a=n.height-e.y-y-b,l=t.height<=o||t.height>a&&o>=a,i=l?Math.max(0,t.height-o):-Math.max(0,t.height-a);let s="",c=0;return e.x-t.width/2<b?(s="-left",c=Math.max(0,b-e.x)):e.x+t.width/2>n.width-b&&(s="-right",c=-Math.max(0,e.x-(n.width-b))),{anchor:`${l?"bottom":"top"}${s}`,move:{x:c,y:i}}}var M="maplibre-gl-worker.mjs",N=e=>`/maplibre-gl/${e}/${M}`,C=null;function L(){return C??=Promise.all([import("maplibre-gl"),import("maplibre-gl/dist/maplibre-gl.css")]).then(([e])=>(e.setWorkerUrl(N(e.getVersion())),e)).catch(e=>{throw C=null,e}),C}var $=24,E=28,S=29;function j(e){const t=[...e].sort((e,t)=>e-t),n=[];for(let e=0;e<t.length;){let r=e;for(;r+1<t.length&&t[r+1]===t[r]+1;)r++;n.push(r===e?String(t[e]):`${t[e]}–${t[r]}`),e=r+1}return n.join(", ")}function A(e){const t=Math.max(E,12+8*e.length);return t+t%2}var z=(e,t,n,r)=>({left:e-n/2,top:t-r/2,right:e+n/2,bottom:t+r/2});function B(e,t){return e.left<t.right+1&&t.left<e.right+1&&e.top<t.bottom+1&&t.top<e.bottom+1}var R=e=>z(e.x,e.y,e.width,e.height);function T(e){for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++)if(B(R(e[t]),R(e[n])))return[e[t],e[n]];return null}function O(e,t=[]){const n=[],r=e=>t.some(t=>B(t,e));let o=e.filter(e=>null!==e.stop).sort((e,t)=>e.stop-t.stop).map(e=>({keys:[e.key],stops:[e.stop],x:e.x,y:e.y,width:E,height:E,under:0}));for(let e=T(o);e;e=T(o)){const[t,n]=e;t.keys.push(...n.keys),t.stops.push(...n.stops),t.stops.sort((e,t)=>e-t),t.width=A(j(t.stops)),o=o.filter(e=>e!==n)}o=o.filter(e=>!r(R(e))||(n.push(...e.keys),!1));const a=[];for(const t of e){if(null!==t.stop)continue;const e=z(t.x,t.y,$,$),l=o.find(t=>B(R(t),e));if(l||r(e)){n.push(t.key),l&&l.under++;continue}const i=a.find(t=>B(R(t),e));i?i.keys.push(t.key):a.push({keys:[t.key],stops:[],x:t.x,y:t.y,width:$,height:$,under:0})}return{groups:[...o,...a],hidden:n}}function W(e,t,n){let r=-1/0;for(const o of t){const t=Math.max(Math.abs(o.x-e.x),Math.abs(o.y-e.y));r=Math.max(r,0===t?1/0:n+Math.log2(29/t))}return r}function F(e){const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:n}),()=>t.disconnect()}var P=t;var q="routes",K=["routes-road","routes-estimate"];function _(e){const t=document.createElement("span");t.style.display="none",t.style.color=e,document.body.appendChild(t);const n=getComputedStyle(t).color||"#2563eb";return t.remove(),H(n)}function H(e){const t=document.createElement("canvas").getContext("2d");if(!t)return"#2563eb";t.fillStyle="#2563eb",t.fillStyle=e,t.fillRect(0,0,1,1);const[n,r,o]=t.getImageData(0,0,1,1).data;return`rgb(${n}, ${r}, ${o})`}var I={light:"https://tiles.openfreemap.org/styles/positron",dark:"https://tiles.openfreemap.org/styles/dark"},D={center:[30,20],zoom:1},Z="ring-2 ring-gray-900 ring-offset-2";var V="var(--color-gray-600, #4b5563)",G="http://www.w3.org/2000/svg",U=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,J=/^(?:\d+|[xytrblse](?:-\d+)?|solid|dashed|dotted|double|hidden|none)$/;function Q(e){return e.split(/\s+/).some(e=>{const t=e.search(/[[(]/),n=t<0?e:e.slice(0,t),r=e.slice(n.lastIndexOf(":")+1);return r.startsWith("border-")&&!J.test(r.slice(7))})}var X=(...e)=>e.filter(Boolean).join(" ");function Y(e){const t=document.createElementNS(G,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none"),t.setAttribute("stroke","currentColor"),t.setAttribute("stroke-width","2"),t.setAttribute("aria-hidden","true");for(const n of e){const e=document.createElementNS(G,"path");e.setAttribute("stroke-linecap","round"),e.setAttribute("stroke-linejoin","round"),e.setAttribute("d",n),t.appendChild(e)}return t}function ee(e,t){for(const[n,r]of Object.entries(t??{}))e.dataset[n]=r}var te=(e,t)=>X("relative grid place-items-center rounded-full cursor-pointer",t&&(null!=e.stop?"h-7 w-7":"h-6 w-6"));function ne(e,t,n,r){const o=t&&!r&&null==e.stop&&!e.dot;return X("grid place-items-center rounded-full border-2 font-semibold leading-none shadow-md transition-transform motion-reduce:transition-none",!Q(e.tone)&&"border-white",e.tone,e.dot?"h-4 w-4 opacity-80":null!=e.stop?"h-7 w-7 text-xs ring-2 ring-gray-900":o?"h-8 w-8 text-xs [&_svg]:h-4 [&_svg]:w-4":"h-6 w-6 text-[10px] [&_svg]:h-3.5 [&_svg]:w-3.5",t&&(o?"ring-2 ring-gray-900 ring-offset-1":Z),e.approximate&&"border-dashed opacity-80",e.faded&&!t&&"opacity-40",n&&"scale-125 opacity-100")}var re=e=>X("grid place-items-center border-2 px-0.5 text-xs font-semibold leading-none shadow-sm",e.stop?"h-7 min-w-7":"h-6 min-w-6",!Q(e.tone??"")&&"border-white",e.tone??"bg-gray-900 text-white");function oe({pins:t,selectedKey:n,focus:s,onSelect:m,ariaLabel:h,className:g="",children:y,routes:b,fitTo:x,attribution:M,marks:N,groupCrowded:C=!1,noun:S,highlightKey:A=null,picking:z=!1,onPick:B,card:R,cardMinMapWidth:T=480,fullScreen:G,initialView:J=D,cooperativeGestures:Q=!1}){const oe=r().map,ie=o(null),se=o(null),ce=o(null),ue=o(null),de=o([]),pe=o(/* @__PURE__ */new Map),me=o(/* @__PURE__ */new Map),he=o(/* @__PURE__ */new Map),ge=o(null),fe=o(/* @__PURE__ */new Map),ye=o(""),[be,xe]=a(!1),[ve,we]=a(!1),ke=c(F,P,()=>!1)?"dark":"light",Me=o({onSelect:m,onPick:B,picking:z,pins:t,selectedKey:n,highlightKey:A,groupCrowded:C,strings:oe,noun:S});l(()=>{Me.current={onSelect:m,onPick:B,picking:z,pins:t,selectedKey:n,highlightKey:A,groupCrowded:C,strings:oe,noun:S}});const Ne=i(()=>{const e=ce.current,{pins:t,selectedKey:n}=Me.current,r=n?t.find(e=>e.key===n):void 0;e&&r&&!e.getBounds().contains([r.lng,r.lat])&&e.easeTo({center:[r.lng,r.lat],duration:U()?0:400})},[]),Ce=o(!1),Le=i((e,t)=>{const n=ce.current,r=ue.current;if(!n||!r)return;const o=n.getZoom();if(o>=17.5){const t=e.indexOf(Me.current.selectedKey??"");return void Me.current.onSelect(e[(t+1)%e.length])}const a=e.map(e=>pe.current.get(e).pin),l=new r.LngLatBounds([a[0].lng,a[0].lat],[a[0].lng,a[0].lat]);for(const e of a)l.extend([e.lng,e.lat]);const i=a.map(e=>n.project([e.lng,e.lat])),s=Math.max(...i.map((e,t)=>W(e,i.filter((e,n)=>n!==t),o))),{clientWidth:c,clientHeight:u}=n.getContainer(),d=n.cameraForBounds(l,{padding:Math.min(64,c/4,u/4)})?.zoom??18,p=document.activeElement===t;Ce.current=!0,n.once("moveend",()=>{if(Ce.current=!1,!p)return;const e=a[0].key,t=pe.current.get(e)?.button,n=t&&"none"!==t.style.display?t:[...me.current.values()].find(t=>t.keys.includes(e))?.button;n?.focus({preventScroll:!0})}),n.easeTo({center:l.getCenter(),zoom:Math.min(18,Math.max(o+1,Math.min(d,s))),duration:U()?0:600})},[]),$e=i(()=>{const e=ce.current,t=ue.current;if(!e||!t||!ie.current||Ce.current&&e.isMoving())return;const{selectedKey:n,highlightKey:r,groupCrowded:o,strings:a,noun:l}=Me.current;for(const[e,t]of pe.current){const a=ne(t.pin,e===n,e===r,o);t.mark.className!==a&&(t.mark.className=a);const l=e===n?"1":"";t.button.style.zIndex!==l&&(t.button.style.zIndex=l)}let i=null;if(o){const r=e.getContainer().getBoundingClientRect(),o=[...ie.current.querySelectorAll("a[href], button, input, select, textarea, summary, [role='button'], [tabindex]:not([tabindex='-1'])")].filter(e=>!e.closest("[data-pin], [data-pin-group], .maplibregl-canvas")).map(e=>{const t=e.getBoundingClientRect(),n=e.closest("[data-map-card]")?.getBoundingClientRect()??t;return{left:Math.max(t.left,n.left)-r.left,top:Math.max(t.top,n.top)-r.top,right:Math.min(t.right,n.right)-r.left,bottom:Math.min(t.bottom,n.bottom)-r.top}}).filter(e=>e.right>e.left&&e.bottom>e.top);i=O([...pe.current.values()].map(({pin:t})=>{const n=e.project([t.lng,t.lat]);return{key:t.key,x:n.x,y:n.y,stop:t.stop??null}}),o);const s=e=>(l??a.places)(e),c=e.getZoom()<17.5?a.spread:a.cycle,u=(e,t)=>{const n=t?"":"none";e.style.display!==n&&(e.style.display=n)},d=/* @__PURE__ */new Map;for(const r of i.groups){const o=r.under>0?a.closeBy(r.under,s(r.under)):null,l=1===r.keys.length?pe.current.get(r.keys[0]):null;if(l){u(l.button,!0),l.button.setAttribute("aria-label",o?`${l.name}; ${o}`:l.name),l.button.title=o?`${l.title}\n${o}`:l.title;continue}for(const e of r.keys)u(pe.current.get(e).button,!1);const i=r.keys.join(" ");let p=me.current.get(i);if(!p){const n=document.createElement("button");n.type="button",n.dataset.pinGroup="",n.className="grid place-items-center rounded-full cursor-pointer",n.append(document.createElement("span"));const o=pe.current.get(r.keys[0]).pin,a={button:n,keys:r.keys,marker:new t.Marker({element:n,anchor:"center"}).setLngLat([o.lng,o.lat]).addTo(e)};n.addEventListener("click",e=>{e.stopPropagation(),Le(a.keys,n)}),p=a}p.keys=r.keys;const m=r.keys.map(e=>pe.current.get(e)),h=r.stops.length>0?j(r.stops):String(m.length),g=r.stops.length>0?a.stops(h):a.group(m.length,s(m.length));p.button.style.width=`${r.width}px`,p.button.style.height=`${r.height}px`,p.button.setAttribute("aria-label",`${g}: ${m.map(e=>e.pin.label).join("; ")}. ${c}${o?`; ${o}`:""}.`),p.button.title=[`${g}:`,...m.map(e=>e.title),...o?[o]:[],c].join("\n");const f=p.button.firstElementChild;f.textContent=h;const y=X("grid place-items-center rounded-full border-2 border-gray-700 bg-white font-semibold leading-none text-gray-900 shadow-sm",r.stops.length>0?"h-7 w-full px-1 text-xs ring-2 ring-gray-900":m.every(e=>e.pin.dot)?"h-5 w-5 text-[0.6rem]":"h-6 w-6 text-[0.7rem]",null!=n&&r.keys.includes(n)&&Z);f.className!==y&&(f.className=y),d.set(i,p)}for(const e of i.hidden)u(pe.current.get(e).button,!1);for(const[e,t]of me.current)d.has(e)||t.marker.remove();me.current=d}if(ge.current){const e=r&&i?i.groups.find(e=>e.keys.includes(r)&&e.keys.length>1):void 0,t=r?pe.current.get(r):void 0,n=r?he.current.get(r):void 0,o=e?{at:pe.current.get(e.keys[0]).pin,width:e.width,height:e.height}:t?{at:t.pin,width:t.button.offsetWidth||(null!=t.pin.stop?E:$),height:t.button.offsetHeight||(null!=t.pin.stop?E:$)}:n?{at:n.mark,width:n.element.offsetWidth||E,height:n.element.offsetHeight||E}:null,a=ge.current.getElement();a.style.display=o?"":"none",o&&(ge.current.setLngLat([o.at.lng,o.at.lat]),a.style.width=`${o.width+22}px`,a.style.height=`${o.height+22}px`)}},[Le]);l(()=>{if($e(),!ie.current)return;const e=new ResizeObserver(()=>$e());e.observe(ie.current);for(const t of ie.current.children)t.contains(se.current)||e.observe(t);return()=>e.disconnect()}),l(()=>{let e=!1,t=null,n=null,r=()=>{};return(async()=>{try{const o=await L();if(e||!se.current)return;ue.current=o,t=new o.Map({container:se.current,style:I[ke],center:J.center,zoom:J.zoom,attributionControl:M?{compact:!0,customAttribution:M}:{compact:!0},dragRotate:!1,pitchWithRotate:!1,touchPitch:!1,maxPitch:0,cooperativeGestures:"coarse"===Q?window.matchMedia("(pointer: coarse)").matches:Q}),t.touchZoomRotate.disableRotation(),t.keyboard.disableRotation(),t.addControl(new o.NavigationControl({showCompass:!1}),"top-right");const a=document.createElement("div");a.dataset.pinRing="",a.setAttribute("aria-hidden","true"),a.className="pointer-events-none rounded-full border-2 border-gray-900 bg-gray-900/15 shadow-[0_0_0_2px_var(--color-white,#fff)]",a.style.display="none",ge.current=new o.Marker({element:a,anchor:"center"}).setLngLat(J.center).addTo(t),t.on("click",e=>{Me.current.picking&&Me.current.onPick?.({lat:e.lngLat.lat,lng:e.lngLat.lng})}),t.on("move",$e),t.on("moveend",$e),t.on("resize",$e),t.on("error",e=>console.warn("[map]",e.error?.message)),r=f(se.current.querySelector(".maplibregl-ctrl-attrib"));const l=t;n=new ResizeObserver(()=>{l.resize(),Ne()}),n.observe(se.current),ce.current=t,xe(!0)}catch(t){console.error("[map] could not start",t),e||we(!0)}})(),()=>{e=!0,n?.disconnect(),r(),de.current.forEach(e=>e.remove()),de.current=[],me.current.forEach(e=>e.marker.remove()),me.current.clear(),ge.current?.remove(),ge.current=null,t?.remove(),ce.current=null}},[]);const Ee=o(ke);l(()=>{be&&ce.current&&Ee.current!==ke&&(Ee.current=ke,ce.current.setStyle(I[ke]))},[be,ke]),l(()=>{const e=ce.current,n=ue.current;if(!be||!e||!n)return;de.current.forEach(e=>e.remove()),de.current=[],me.current.forEach(e=>e.marker.remove()),me.current.clear(),pe.current.clear(),he.current.clear();for(const e of fe.current.keys())t.some(t=>t.key===e)||fe.current.delete(e);const r=Me.current.strings;for(const o of t){const t=document.createElement("button");t.type="button",t.dataset.pin=o.key,t.className=te(o,C);const a=o.approximate?r.approximate(o.label):o.label,l=o.title??(o.approximate?r.approximateTitle(o.label):o.label);t.setAttribute("aria-label",a),t.title=l;const i=document.createElement("span");if(ee(i,o.data),o.dot);else if(null!=o.iconNode){const e=fe.current.get(o.key);e&&i.append(e)}else o.icon?.length?i.append(Y(o.icon)):i.textContent=null!=o.stop?String(o.stop):o.glyph;if(t.append(i),o.badge){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className=X("absolute -right-2 -top-2 grid h-4 min-w-4 place-items-center rounded-full px-0.5 text-[9px] font-semibold leading-none shadow",o.badgeTone??"bg-white text-gray-900"),e.textContent=o.badge,t.appendChild(e)}t.addEventListener("click",e=>{e.stopPropagation(),Me.current.onSelect(o.key)}),de.current.push(new n.Marker({element:t,anchor:"center"}).setLngLat([o.lng,o.lat]).addTo(e)),pe.current.set(o.key,{pin:o,button:t,mark:i,name:a,title:l})}for(const t of N??[]){const r=document.createElement("div");r.dataset.mapMark=t.key,ee(r,t.data),r.className=re(t),r.textContent=t.text,r.title=t.title??t.label,r.setAttribute("role","img"),r.setAttribute("aria-label",t.label),de.current.push(new n.Marker({element:r,anchor:"center"}).setLngLat([t.lng,t.lat]).addTo(e)),he.current.set(t.key,{mark:t,element:r})}$e()},[be,t,N,C,$e]),l(()=>{be&&$e()},[be,n,A,$e]),l(()=>{if(!be||!n)return;const e=requestAnimationFrame(Ne);return()=>cancelAnimationFrame(e)},[be,n,Ne]),l(()=>{const e=ce.current,n=ue.current,r=x?[...t,...N??[]].filter(e=>x.includes(e.key)):t;if(!be||!e||!n||0===r.length)return;const o=r.map(e=>`${e.key}@${e.lat},${e.lng}`).sort().join("|");if(ye.current===o)return;const a=""===ye.current;if(ye.current=o,1===r.length)return void e.jumpTo({center:[r[0].lng,r[0].lat],zoom:13});const l=new n.LngLatBounds([r[0].lng,r[0].lat],[r[0].lng,r[0].lat]);for(const e of r)l.extend([e.lng,e.lat]);e.fitBounds(l,{padding:48,maxZoom:14,animate:!a})},[be,t,N,x]),l(()=>{const e=ce.current;if(!be||!e)return;const t=(b??[]).filter(e=>e.coordinates.length>=2),n=[...new Set(t.flatMap(e=>e.attribution?[e.attribution]:[]))].join(" · "),r=()=>{const r=function(){const e=document.createElement("span");e.className="text-blue-600",e.style.display="none",document.body.appendChild(e);const t=getComputedStyle(e).color||"#2563eb";return e.remove(),H(t)}(),o={type:"FeatureCollection",features:t.map(e=>({type:"Feature",properties:{key:e.key,estimate:e.estimate,faded:!!e.faded,color:e.color?_(e.color):r},geometry:{type:"LineString",coordinates:e.coordinates}}))},a=["case",["get","faded"],.25,.85],l=["get","color"],i=e.getSource(q);if(i&&(i.attribution||"")!==n){for(const t of K)e.getLayer(t)&&e.removeLayer(t);e.removeSource(q)}const s=e.getSource(q);s?s.setData(o):e.addSource(q,{type:"geojson",data:o,...n?{attribution:n}:{}}),e.getLayer("routes-road")||e.addLayer({id:"routes-road",type:"line",source:q,filter:["!",["get","estimate"]],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":l,"line-width":4,"line-opacity":a}}),e.getLayer("routes-estimate")||e.addLayer({id:"routes-estimate",type:"line",source:q,filter:["get","estimate"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":l,"line-width":3,"line-dasharray":[1.5,1.5],"line-opacity":a}})},o=()=>{try{r()}catch(e){console.debug("[map] routes wait for the style",e)}};return o(),e.on("style.load",o),e.once("idle",o),()=>{e.off("style.load",o),e.off("idle",o)}},[be,b,ke]),l(()=>{const e=ce.current;if(!be||!e||!s)return;const n=t.find(e=>e.key===s.key);if(!n)return;const r=e.getZoom(),o=C?W(e.project([n.lng,n.lat]),t.filter(e=>e.key!==n.key).map(t=>e.project([t.lng,t.lat])),r):-1/0,a={center:[n.lng,n.lat],zoom:Math.min(18,Math.max(r,13,o))};U()?e.jumpTo(a):e.flyTo({...a,duration:600})},[be,s?.n]);const[Se,je]=a(!1);l(()=>{const e=ie.current;if(!e)return;const t=()=>je(e.clientWidth<T);t();const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[T]);const Ae=n?t.find(e=>e.key===n)??null:null,ze=Ae?.key??null,Be=Ae?.lng??0,Re=Ae?.lat??0,Te=be&&!Se&&null!=R&&!!Ae,[Oe,We]=a(null);l(()=>{const e=ce.current,t=ue.current;if(!(Te&&e&&t&&ze))return;const n=document.createElement("div");n.dataset.mapCard="",n.className="w-[26rem] overflow-y-auto overscroll-contain";const r=new t.Popup({anchor:"bottom",offset:v,className:"rosh-map-card",maxWidth:"none",closeButton:!1,closeOnClick:!1,closeOnMove:!1,focusAfterOpen:!1}).setLngLat([Be,Re]).setDOMContent(n).addTo(e),o=r.getElement(),a=o.querySelector(".maplibregl-popup-content");a&&Object.assign(a.style,{padding:"0",background:"transparent",borderRadius:"0",boxShadow:"none"});const l=o.querySelector(".maplibregl-popup-tip");l&&Object.assign(l.style,{borderTopColor:V,borderBottomColor:V}),We(n);let i=!1,s=!1;const c=(t=!0)=>{if(s)return;if(e.isMoving())return void(i||(i=!0,e.once("moveend",()=>{i=!1,c()})));const{clientWidth:o,clientHeight:a}=e.getContainer(),l=function(e,t){const n=e.getBoundingClientRect().top,r=[...e.querySelectorAll(".maplibregl-ctrl-top-left > *, .maplibregl-ctrl-top-right > *"),...t?.querySelectorAll(":scope > [data-map-control]")??[]];let o=0;for(const e of r){const t=e.getBoundingClientRect();t.height>0&&(o=Math.max(o,t.bottom-n))}return o}(e.getContainer(),ie.current)+8,u=`${w(a,l)}px`;n.style.maxHeight!==u&&(n.style.maxHeight=u);const d=r.getElement(),p=r.getLngLat(),{anchor:m,move:h}=k(e.project(p),{width:d.offsetWidth,height:d.offsetHeight},{width:o,height:a},l);r.options.anchor!==m&&(r.options.anchor=m,r.setLngLat(p)),!t||0===h.x&&0===h.y||e.panBy([-h.x,-h.y],{duration:U()?0:250}),$e()},u=new ResizeObserver(()=>c());u.observe(n);const d=()=>c(),p=()=>{i||c(!1)};e.on("resize",d),e.on("moveend",p);let m=!1;const h=pe.current,g=e=>{m=n.contains(e.target)};return document.addEventListener("focusin",g),()=>{if(s=!0,u.disconnect(),e.off("resize",d),e.off("moveend",p),document.removeEventListener("focusin",g),r.remove(),We(null),m&&(!document.activeElement||document.activeElement===document.body)){const e=h.get(ze)?.button;e&&"none"!==e.style.display&&e.focus({preventScroll:!0})}}},[Te,ze,Be,Re,$e]);const Fe=G?.active??!1,Pe=o(G?.onChange);l(()=>{Pe.current=G?.onChange}),l(()=>{if(!G)return;const e=document.documentElement;Fe&&!document.fullscreenElement&&e.requestFullscreen&&e.requestFullscreen().catch(()=>{}),!Fe&&document.fullscreenElement&&document.exitFullscreen().catch(()=>{})},[Fe]);const qe=!!G;return l(()=>{if(!qe)return;const e=()=>{document.fullscreenElement||Pe.current?.(!1)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[qe]),/* @__PURE__ */d("div",{ref:ie,className:X("relative min-h-72 overflow-hidden rounded-lg border border-gray-200 bg-gray-100",z&&"[&_canvas]:cursor-crosshair",g),children:[
3
+ /* @__PURE__ */p("div",{className:"absolute inset-0",children:/* @__PURE__ */p("div",{ref:se,className:"h-full w-full",role:"region","aria-label":h})}),ve&&/* @__PURE__ */p("p",{className:"absolute inset-0 grid place-items-center p-6 text-center text-sm text-gray-500",children:oe.failed}),G&&/* @__PURE__ */p(e,{"data-map-control":"",variant:"secondary",size:"sm",className:"absolute left-3 top-3 z-10",onClick:()=>G.onChange(!G.active),leftIcon:/* @__PURE__ */p(le,{leave:G.active}),children:G.active?oe.leaveFullScreen:oe.fullScreen}),y,null!=R&&!Te&&/* @__PURE__ */p("div",{"data-map-card":"",className:"absolute bottom-3 left-3 right-3 z-10 max-h-[calc(100%-1.5rem)] max-w-md overflow-y-auto overscroll-contain",children:R}),Te&&Oe?u(R,Oe):null,be&&/* @__PURE__ */p(ae,{pins:t,hosts:fe.current})]})}function ae({pins:e,hosts:t}){/* @__PURE__ */
4
+ return p(m,{children:e.map(e=>{if(null==e.iconNode||e.dot)return null;let n=t.get(e.key);return n||(n=document.createElement("span"),n.className="contents",t.set(e.key,n)),u(e.iconNode,n,e.key)})})}function le({leave:e}){/* @__PURE__ */
5
+ return p("svg",{"aria-hidden":"true",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */p("path",{strokeLinecap:"round",strokeLinejoin:"round",d:e?"M9 9V4.5M9 9H4.5M9 9 3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5 5.25 5.25":"M3.75 3.75v4.5m0-4.5h4.5m-4.5 0L9 9M3.75 20.25v-4.5m0 4.5h4.5m-4.5 0L9 15M20.25 3.75h-4.5m4.5 0v4.5m0-4.5L15 9m5.25 11.25h-4.5m4.5 0v-4.5m0 4.5L15 15"})})}function ie(){const[e,t]=a(null);return{highlightKey:e,pointAt:i(e=>{const n=()=>t(e),r=()=>t(t=>t===e?null:t);return{onMouseEnter:n,onMouseLeave:r,onFocus:n,onBlur:r}},[])}}var se=3e3,ce=e=>!!e?.pending&&3e3,ue=e=>`${e.kind}:${e.id}`,de=e=>("located"===e.placement||"approximate"===e.placement)&&null!=e.lat&&null!=e.lng;function pe(e){switch(e){case"located":return null;case"approximate":return"Approximate: only the suburb or postcode matched";case"pending":return"Locating…";case"not_found":return"Not on the map: address not found";case"failed":return"Not on the map: the map service could not be reached";case"no_address":return"Not on the map: no city or postcode"}}var me={importer:{label:"Importer",tone:"bg-sky-600 text-white"},dealer:{label:"Dealer",tone:"bg-purple-600 text-white"},retail:{label:"Retail",tone:"bg-green-600 text-white"},supplier:{label:"Supplier",tone:"bg-sky-600 text-white"},delivery_location:{label:"Delivery location",tone:"bg-amber-600 text-white"},warehouse:{label:"Warehouse",tone:"bg-amber-600 text-white"}},he=["importer","dealer","retail","supplier","delivery_location","warehouse"];function ge(e){return"supplier"===e.kind?"supplier":"customer"===e.kind?e.category||"importer":e.kind}var fe=(e,t=me)=>t[e]?.tone??"bg-gray-700 text-white",ye=(e,t=me)=>t[e]?.label??e,be=(e,t)=>fe(ge(e),t);function xe(e,t,n=me){return null!=t?String(t):(n[ge(e)]?.label??"").charAt(0).toUpperCase()}var ve=["delivery_location","warehouse"];function we(e,t=ve){const n=/* @__PURE__ */new Map;let r=0;for(const o of e)t.includes(o.kind)&&n.set(ue(o),++r);return n}function ke(e){const t={onMap:0,approximate:0,pending:0,off:0};for(const n of e)de(n)?(t.onMap+=1,"approximate"===n.placement&&(t.approximate+=1)):"pending"===n.placement?t.pending+=1:t.off+=1;return t}function Me(e){const t=[`${e.onMap} on the map`];return e.approximate&&t.push(`${e.approximate} approximate`),e.pending&&t.push(`${e.pending} locating`),e.off&&t.push(`${e.off} not on the map`),t.join(" · ")}function Ne(e){const t=[...new Set(e.filter(de).map(ge))];return[...he.filter(e=>t.includes(e)),...t.filter(e=>!he.includes(e))]}function Ce(e,t){return e.filter(e=>!de(e)&&"pending"!==e.placement).map(e=>{const n=t?.get(ue(e)),r=pe(e.placement)?.replace(/^Not on the map: /,"")??"";return{key:ue(e),text:`${null!=n?`${n}. `:""}${e.label}: ${r}`}})}function Le({categories:e,palette:t=me,floating:n=!0}){return e.length<2?null:/* @__PURE__ */p("div",{className:(n?"absolute left-3 top-3 z-10 ":"")+"flex flex-wrap gap-x-3 gap-y-1 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs text-gray-600 shadow-sm",children:e.map(e=>/* @__PURE__ */d("span",{className:"inline-flex items-center gap-1.5",children:[
6
+ /* @__PURE__ */p("span",{"aria-hidden":!0,className:`h-2.5 w-2.5 rounded-full ${fe(e,t)}`}),ye(e,t)]},e))})}function $e({point:t,number:n,onOpen:o,onClose:a,palette:l=me}){const i=pe(t.placement),s=ge(t),c=r().map;/* @__PURE__ */
7
+ return d("section",{"aria-label":c.chosen(t.label),className:"absolute bottom-3 left-3 right-3 z-10 max-w-md space-y-1.5 rounded-lg border border-gray-200 bg-white p-3 shadow-md",children:[
8
+ /* @__PURE__ */d("div",{className:"flex items-start justify-between gap-2",children:[
9
+ /* @__PURE__ */d("div",{className:"min-w-0",children:[
10
+ /* @__PURE__ */d("h3",{className:"text-sm font-semibold text-gray-900 [overflow-wrap:anywhere]",children:[null!=n&&/* @__PURE__ */d("span",{className:"mr-1 text-gray-400",children:[n,"."]}),t.label,t.code&&/* @__PURE__ */p("span",{className:"ml-1.5 text-xs font-normal text-gray-400",children:t.code})]}),
11
+ /* @__PURE__ */p("p",{className:"text-xs text-gray-500",children:l[s]?ye(s,l):t.category})]}),
12
+ /* @__PURE__ */p("button",{type:"button",onClick:a,"aria-label":c.closeCard,className:"rounded p-0.5 text-gray-400 hover:text-gray-600",children:/* @__PURE__ */p("svg",{"aria-hidden":!0,className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:/* @__PURE__ */p("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),
13
+ /* @__PURE__ */p("p",{className:"text-sm text-gray-700 [overflow-wrap:anywhere]",children:t.address||"—"}),i&&/* @__PURE__ */p("p",{className:"text-xs text-gray-500",children:i}),t.matched&&"approximate"===t.placement&&/* @__PURE__ */d("p",{className:"text-xs text-gray-400 [overflow-wrap:anywhere]",children:["Placed at: ",t.matched]}),o&&/* @__PURE__ */p("div",{className:"flex justify-end",children:/* @__PURE__ */p(e,{variant:"secondary",size:"sm",onClick:o,children:c.openRecord})})]})}function Ee(e,t,{staleTime:n}={}){return h({queryKey:e,queryFn:t,staleTime:n,refetchInterval:e=>ce(e.state.data)})}function Se({queryKey:e,queryFn:t,refreshSignal:n,onOpen:r,ariaLabel:i,title:c="Locations",palette:u=me,numbers:m,className:h="",mapClassName:g="min-h-[240px] flex-1"}){const{data:f,isError:y,refetch:b}=Ee(e,t,{staleTime:0}),x=o(!1);l(()=>{x.current?b():x.current=!0},[n]);const[v,w]=a(null),k=s(()=>f?.points??[],[f]),M=s(()=>m??we(k),[m,k]),N=s(()=>k.filter(de).map(e=>({key:ue(e),label:e.label,lat:e.lat,lng:e.lng,glyph:xe(e,M.get(ue(e))??null,u),tone:be(e,u),approximate:"approximate"===e.placement})),[k,M,u]),C=s(()=>Ce(k,M),[k,M]),L=s(()=>Ne(k),[k]),$=f?.pending??0,E=k.find(e=>ue(e)===v)??null,S=E&&r?r(E):null;/* @__PURE__ */
14
+ return d("section",{"aria-label":c,className:`flex min-w-0 flex-col ${h}`,children:[
15
+ /* @__PURE__ */d("div",{className:"flex min-h-[30px] items-center justify-between mb-2",children:[
16
+ /* @__PURE__ */p("h3",{className:"text-sm font-semibold text-gray-900",children:c}),f&&/* @__PURE__ */p("span",{className:"text-xs text-gray-500",children:Me(ke(k))})]}),
17
+ /* @__PURE__ */d(oe,{pins:N,selectedKey:v,focus:null,onSelect:w,ariaLabel:i,className:g,children:[
18
+ /* @__PURE__ */d("div",{className:"absolute left-3 top-3 z-10 flex max-w-[70%] flex-col items-start gap-1.5",children:[
19
+ /* @__PURE__ */p(Le,{categories:L,palette:u,floating:!1}),y&&/* @__PURE__ */d("div",{className:"flex items-center gap-2 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs text-gray-600 shadow-sm",children:["Couldn’t load the locations.",
20
+ /* @__PURE__ */p("button",{type:"button",onClick:()=>{b()},className:"font-medium text-blue-600 hover:text-blue-800 hover:underline",children:"Try again"})]}),!y&&($>0||C.length>0)&&/* @__PURE__ */d("div",{className:"max-w-full space-y-0.5 rounded-lg border border-gray-200 bg-white px-2.5 py-1.5 text-xs shadow-sm","aria-live":"polite",children:[$>0&&/* @__PURE__ */d("p",{className:"flex items-center gap-1.5 text-gray-500",children:[
21
+ /* @__PURE__ */d("svg",{className:"h-3 w-3 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[
22
+ /* @__PURE__ */p("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),
23
+ /* @__PURE__ */p("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),"Locating ",$," address",1===$?"":"es","…"]}),C.slice(0,3).map(e=>/* @__PURE__ */p("p",{className:"truncate text-amber-700",title:e.text,children:e.text},e.key)),C.length>3&&/* @__PURE__ */d("p",{className:"text-gray-500",children:["+",C.length-3," more not on the map"]})]})]}),E&&/* @__PURE__ */p($e,{point:E,number:M.get(ue(E))??null,onOpen:S,onClose:()=>w(null),palette:u})]})]})}export{x as CARD_MIN_MAP_WIDTH,g as COMPACT_SHOW,oe as EntityMap,Se as LocationsMap,M as MAPLIBRE_WORKER_FILE,S as MAP_APART_PX,me as MAP_CATEGORIES,E as MAP_STOP_PX,$ as MAP_TARGET_PX,Le as MapLegend,se as PENDING_POLL_MS,ve as SECONDARY_KINDS,$e as SelectedCard,w as cardMaxHeight,ye as categoryLabel,fe as categoryTone,f as foldAttributionOnce,de as isOnMap,O as layoutPins,Ne as legendCategories,L as loadMapLibre,we as locationNumbers,N as mapLibreWorkerUrl,ce as mapPointsRefetchInterval,Ce as offMapNotes,ge as pinCategory,xe as pinGlyph,be as pinTone,k as placeCard,pe as placementNote,ue as pointKey,j as stopsLabel,ke as summarize,Me as summaryText,ie as useMapHighlight,Ee as useMapPoints,W as zoomApart};
@@ -1,22 +1,22 @@
1
1
  "use client";
2
- import{PopupMenu as e,PopupMenuItem as t,PopupMenuDivider as n}from"../chunk-UZAJ5BF6.js";import{confirm as r}from"../chunk-3A46NCXK.js";import"../chunk-57MIENLJ.js";import{useShellStrings as i}from"../chunk-OQDWLHZI.js";import"../chunk-MAIHBBWT.js";import{useBrowserLayoutEffect as l}from"../chunk-D65T4H6J.js";import*as a from"react";import{createContext as s,memo as o,useRef as c,useEffect as d,useMemo as u,useId as y,useCallback as f,useReducer as m,useContext as p,useState as h,Fragment as b}from"react";import{useLocation as k,useNavigate as v}from"react-router-dom";import{jsx as g,Fragment as x,jsxs as w}from"react/jsx-runtime";var N=s(null),I=s(null),K=12;var A=(e,t)=>e.filter(e=>e!==t);function F(e,t){return[...t.map(t=>e.find(e=>e.key===t)).filter(e=>Boolean(e)),...e.filter(e=>!t.includes(e.key))]}function T(e,t,n=12){const r=e.clock+1;let i;i=e.tabs.find(e=>e.key===t.key)?e.tabs.map(e=>e.key===t.key?{...e,path:t.path,title:"page"===e.titleFrom?e.title:t.title||e.title,lastActive:r}:e):[...e.tabs,{key:t.key,path:t.path,title:t.title,titleFrom:"route",pinned:!1,lastActive:r}];let l={...e,tabs:i,activeKey:t.key,mounted:(a=e.mounted,s=t.key,a.includes(s)?a:[...a,s]),clock:r};var a,s;return l.closing&&l.closing!==t.key?l=C(l,l.closing):l.closing===t.key&&(l={...l,closing:null}),function(e,t){let n=e;for(;n.tabs.length>t;){const e=n.tabs.filter(e=>!e.pinned&&e.key!==n.activeKey&&!n.dirty.includes(e.key)&&e.key!==n.closing).sort((e,t)=>e.lastActive-t.lastActive);if(0===e.length)break;n=C(n,e[0].key)}return n}(l,n)}function $(e){let t={...e,activeKey:null};return t.closing&&(t=C(t,t.closing)),t}function C(e,t){return{...e,tabs:e.tabs.filter(e=>e.key!==t),mounted:A(e.mounted,t),dirty:A(e.dirty,t),activeKey:e.activeKey===t?null:e.activeKey,closing:e.closing===t?null:e.closing}}function L(e,t){switch(t.type){case"visit":return T(e,t.entry,t.maxTabs);case"transient":return $(e);case"close":{let n=e;for(const e of t.keys)n=C(n,e);return t.closing?function(e,t){return{...e,closing:t}}(n,t.closing):n}case"title":return function(e,t,n){const r=e.tabs.find(e=>e.key===t);return!r||!n||r.title===n&&"page"===r.titleFrom?e:{...e,tabs:e.tabs.map(e=>e.key===t?{...e,title:n,titleFrom:"page"}:e)}}(e,t.key,t.title);case"dirty":return function(e,t,n){return n===e.dirty.includes(t)?e:{...e,dirty:n?[...e.dirty,t]:A(e.dirty,t)}}(e,t.key,t.dirty)}}var M=e=>`${e.pathname}${e.search}`;function j(e){const t=e.indexOf("#"),n=t>=0?e.slice(t):"",r=t>=0?e.slice(0,t):e,i=r.indexOf("?");return{pathname:i>=0?r.slice(0,i):r,search:i>=0?r.slice(i):"",hash:n}}function D({children:e,resolve:t,pinned:n=[],storageKey:a,maxTabs:s=12,enabled:o=!0,confirmDiscard:p}){const h=k(),b=v(),x=i().pageTabs,w=y(),I=c(t);I.current=t;const K=f(e=>{const t=I.current(e);return t?{key:t.key??e.pathname,path:M(e),title:t.title}:null},[]),[A,C]=m(L,void 0,()=>{const e=function(e,t){if(!e)return[];let n;try{n=JSON.parse(e)}catch{return[]}const r=n;if(!r||1!==r.v||!Array.isArray(r.tabs))return[];const i=[];for(const e of r.tabs){if(!e||"string"!=typeof e.path||!e.path.startsWith("/")||e.path.startsWith("//"))continue;const n=e.path.indexOf("#"),r=n>=0?e.path.slice(0,n):e.path,l=t(r);if(!l||i.some(e=>e.key===l.key))continue;const a="page"===e.titleFrom&&"string"==typeof e.title&&e.title;i.push({key:l.key,path:r,title:a||l.title,titleFrom:a?"page":"route",pinned:!1,lastActive:0})}return i}(function(e){if(!e)return null;try{return localStorage.getItem(e)}catch{return null}}(a),e=>K(j(e)));let t=function(e,t){const n=t.map(e=>e.key);let r=e.tabs.map(e=>({...e,pinned:n.includes(e.key)}));for(const e of t)r.some(t=>t.key===e.key)||(r=[...r,{key:e.key,path:e.path,title:e.title,titleFrom:"route",pinned:!0,lastActive:0}]);return{...e,tabs:F(r,n)}}({tabs:[],activeKey:null,mounted:[],dirty:[],closing:null,clock:0,tabs:e},n.map(e=>K(j(e))).filter(e=>Boolean(e)));const r=o?K(h):null;return t=r?T(t,r,s):$(t),t}),D=c(A);D.current=A;const O=c(/* @__PURE__ */new Map),z=o?K(h):null,B=z?.key??null;l(()=>{if(!o)return;const e=K(h);e?(O.current.set(e.key,h),C({type:"visit",entry:e,maxTabs:s})):C({type:"transient"})},[h,o,s,K]),d(()=>{const e=new Set(A.tabs.map(e=>e.key));for(const t of O.current.keys())e.has(t)||O.current.delete(t)},[A.tabs]);const E=u(()=>function(e){const t={v:1,tabs:e.tabs.filter(t=>t.key!==e.closing).map(({key:e,path:t,title:n,titleFrom:r})=>({key:e,path:t,title:n,titleFrom:r}))};return JSON.stringify(t)}(A),[A]);d(()=>{if(a)try{localStorage.setItem(a,E)}catch{}},[E,a]);const R=A.dirty.length>0;d(()=>{if(!R)return;const e=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[R]);const S=c(/* @__PURE__ */new Map),J=f((e,t)=>{let n=S.current.get(e);return void 0===n&&(n=S.current.size,S.current.set(e,n)),`${w}-page-${t}-${n}`},[w]),H=f(e=>p?p(e):r({title:x.discardTitle,message:1===e.length?x.discardOne:x.discardCount?.(e.length)??`${e.length} ${x.discardMany}`,confirmLabel:x.discardConfirm,cancelLabel:x.keepEditing,variant:"warning"}),[p,x]),W=f(()=>{const e=D.current;return e.tabs.find(e=>e.pinned)?.path??"/"},[]),_=f((e,t,n)=>{const r=D.current,i=r.activeKey;if(!i||!e.includes(i))return void C({type:"close",keys:e,closing:null});let l=t;if(!l){const t={...r,tabs:r.tabs.filter(t=>t.key===i||!e.includes(t.key))},a=n?r.tabs.find(t=>t.key===n&&!e.includes(t.key)):void 0;l=(a??function(e,t){const n=e.tabs.filter(n=>n.key!==e.closing||n.key===t),r=n.findIndex(e=>e.key===t);return r<0?null:n[r+1]??n[r-1]??null}(t,i))?.path??W()}C({type:"close",keys:e.filter(e=>e!==i),closing:i}),b(l)},[b,W]),P=f(async(e,t={})=>{const n=D.current.tabs.find(t=>t.key===e);return!n||n.pinned?(t.to&&b(t.to),!1):!(!t.force&&D.current.dirty.includes(e)&&!await H([n]))&&(!!D.current.tabs.some(t=>t.key===e)&&(_([e],t.to),!0))},[H,_,b]),V=f(async(e,t)=>{let n=function(e,t,n){const r=e.tabs.filter(e=>!e.pinned);if("all"===t)return r.map(e=>e.key);if("others"===t)return r.filter(e=>e.key!==n).map(e=>e.key);const i=e.tabs.findIndex(e=>e.key===n);return i<0?[]:e.tabs.slice(i+1).filter(e=>!e.pinned).map(e=>e.key)}(D.current,e,t);const r=D.current.tabs.filter(e=>n.includes(e.key)&&D.current.dirty.includes(e.key));r.length&&!await H(r)&&(n=n.filter(e=>!r.some(t=>t.key===e)));const i=new Set(D.current.tabs.map(e=>e.key));n=n.filter(e=>i.has(e)),n.length&&_(n,void 0,"all"===e?null:t)},[H,_]),X=f(e=>{const t=D.current.tabs.find(t=>t.key===e);t&&e!==D.current.activeKey&&b(t.path)},[b]),Z=f((e,t)=>C({type:"title",key:e,title:t}),[]),Q=f((e,t)=>C({type:"dirty",key:e,dirty:t}),[]),U=f(e=>K(e)?.key??null,[K]),Y=f(e=>O.current.get(e),[]),q=u(()=>o?A.tabs.filter(e=>e.key!==A.closing):[],[o,A.tabs,A.closing]),G=u(()=>({enabled:o,state:A,currentKey:B,resolve:t,keyFor:U,locationFor:Y,idFor:J,activate:X,close:P,closeMany:V,setTitle:Z,setDirty:Q,visibleTabs:q}),[o,A,B,t,U,Y,J,X,P,V,Z,Q,q]);/* @__PURE__ */
3
- return g(N.Provider,{value:G,children:e})}var O=a.Activity,z=Boolean(O);function B({active:e,children:t}){return O?/* @__PURE__ */g(O,{mode:e?"visible":"hidden",children:t}):/* @__PURE__ */g(x,{children:t})}var E=o(function({tabKey:e,active:t,location:n,render:r,className:i,panelId:a,tabId:s}){const o=c(null),y=c(t),f=c(/* @__PURE__ */new Map);l(()=>{const e=y.current;if(y.current=t,t&&!e)for(const[e,[t,n]]of f.current)e.isConnected?(e.scrollTop=t,e.scrollLeft=n):f.current.delete(e)},[t]),d(()=>{const e=o.current;if(!e)return;const t=e=>{if(!y.current)return;const t=e.target;t&&"number"==typeof t.scrollTop&&f.current.set(t,[t.scrollTop,t.scrollLeft])};return e.addEventListener("scroll",t,!0),()=>e.removeEventListener("scroll",t,!0)},[]);const m=u(()=>({key:e,activeRef:y}),[e]);/* @__PURE__ */
4
- return g("div",{ref:o,role:a?"tabpanel":void 0,id:a,"aria-labelledby":s,hidden:!t,style:t?void 0:{display:"none"},className:i,"data-page-tab":e,children:/* @__PURE__ */g(I.Provider,{value:m,children:/* @__PURE__ */g(B,{active:t,children:r(n)})})})},(e,t)=>e.active===t.active&&e.location===t.location&&e.className===t.className&&e.panelId===t.panelId&&e.tabId===t.tabId&&(!t.active||e.render===t.render)),R="\0transient";function S({children:e,frameClassName:t}){const n=p(N),r=k();if(!n||!n.enabled)/* @__PURE__ */
5
- return g("div",{className:t,children:e(r)},R);const{state:i,currentKey:l,locationFor:a,idFor:s}=n,o=i.tabs.filter(e=>i.mounted.includes(e.key)).map(e=>e.key);return l&&!o.includes(l)&&o.push(l),/* @__PURE__ */w(x,{children:[o.map(n=>{const i=n===l,o=i?r:a(n);return o?/* @__PURE__ */g(E,{tabKey:n,active:i,location:o,render:e,className:t,panelId:s(n,"panel"),tabId:s(n,"tab")},n):null}),!l&&/* @__PURE__ */g(E,{tabKey:R,active:!0,location:r,render:e,className:t},R)]})}var J="outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-500";function H(){/* @__PURE__ */
6
- return g("svg",{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",className:"size-3.5",children:/* @__PURE__ */g("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})})}function W({className:r,activeClassName:l,end:a}){const s=p(N),o=i().pageTabs,u=c(null),[y,f]=h(null),m=s?.currentKey??null;if(d(()=>{if(!s||!m)return;const e=document.getElementById(s.idFor(m,"tab"));e?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[s,m]),!s||!s.enabled)return null;const{visibleTabs:k,state:v,idFor:x,activate:I,close:K,closeMany:A,resolve:F}=s,T=k.some(e=>e.key===m)?m:k[0]?.key,$=e=>{const t=k[(e+k.length)%k.length];t&&document.getElementById(x(t.key,"tab"))?.focus()},C=y?k.find(e=>e.key===y.key):void 0,L=C?k.indexOf(C):-1,M=e=>e.some(e=>!e.pinned),D=e=>()=>{f(null),e()};/* @__PURE__ */
2
+ import{PopupMenu as e,PopupMenuItem as t,PopupMenuDivider as n}from"../chunk-2RHMSFZV.js";import{confirm as r}from"../chunk-LVFMK5OQ.js";import"../chunk-57MIENLJ.js";import"../chunk-MAIHBBWT.js";import{useShellStrings as i}from"../chunk-TR6PLN7W.js";import{useBrowserLayoutEffect as l}from"../chunk-D65T4H6J.js";import*as a from"react";import{createContext as s,memo as o,useRef as c,useEffect as d,useMemo as u,useId as y,useCallback as f,useReducer as m,useContext as p,useState as h,Fragment as b}from"react";import{useLocation as k,useNavigate as v}from"react-router-dom";import{jsx as g,Fragment as x,jsxs as w}from"react/jsx-runtime";var N=s(null),I=s(null),K=12;var F=(e,t)=>e.filter(e=>e!==t);function T(e,t){return[...t.map(t=>e.find(e=>e.key===t)).filter(e=>Boolean(e)),...e.filter(e=>!t.includes(e.key))]}function $(e,t,n=12){const r=e.clock+1;let i;i=e.tabs.find(e=>e.key===t.key)?e.tabs.map(e=>e.key===t.key?{...e,path:t.path,title:"page"===e.titleFrom?e.title:t.title||e.title,lastActive:r}:e):[...e.tabs,{key:t.key,path:t.path,title:t.title,titleFrom:"route",pinned:!1,lastActive:r}];let l={...e,tabs:i,activeKey:t.key,mounted:(a=e.mounted,s=t.key,a.includes(s)?a:[...a,s]),clock:r};var a,s;return l.closing&&l.closing!==t.key?l=L(l,l.closing):l.closing===t.key&&(l={...l,closing:null}),function(e,t){let n=e;for(;n.tabs.length>t;){const e=n.tabs.filter(e=>!e.pinned&&e.key!==n.activeKey&&!n.dirty.includes(e.key)&&e.key!==n.closing).sort((e,t)=>e.lastActive-t.lastActive);if(0===e.length)break;n=L(n,e[0].key)}return n}(l,n)}function A(e){let t={...e,activeKey:null};return t.closing&&(t=L(t,t.closing)),t}function L(e,t){return{...e,tabs:e.tabs.filter(e=>e.key!==t),mounted:F(e.mounted,t),dirty:F(e.dirty,t),activeKey:e.activeKey===t?null:e.activeKey,closing:e.closing===t?null:e.closing}}function M(e,t){switch(t.type){case"visit":return $(e,t.entry,t.maxTabs);case"transient":return A(e);case"close":{let n=e;for(const e of t.keys)n=L(n,e);return t.closing?function(e,t){return{...e,closing:t}}(n,t.closing):n}case"title":return function(e,t,n){const r=e.tabs.find(e=>e.key===t);return!r||!n||r.title===n&&"page"===r.titleFrom?e:{...e,tabs:e.tabs.map(e=>e.key===t?{...e,title:n,titleFrom:"page"}:e)}}(e,t.key,t.title);case"dirty":return function(e,t,n){return n===e.dirty.includes(t)?e:{...e,dirty:n?[...e.dirty,t]:F(e.dirty,t)}}(e,t.key,t.dirty)}}var C=e=>`${e.pathname}${e.search}`;function j(e){const t=e.indexOf("#"),n=t>=0?e.slice(t):"",r=t>=0?e.slice(0,t):e,i=r.indexOf("?");return{pathname:i>=0?r.slice(0,i):r,search:i>=0?r.slice(i):"",hash:n}}function D({children:e,resolve:t,pinned:n=[],storageKey:a,maxTabs:s=12,enabled:o=!0,confirmDiscard:p}){const h=k(),b=v(),x=i().pageTabs,w=y(),I=c(t);I.current=t;const K=f(e=>{const t=I.current(e);return t?{key:t.key??e.pathname,path:C(e),title:t.title}:null},[]),[F,L]=m(M,void 0,()=>{const e=function(e,t){if(!e)return[];let n;try{n=JSON.parse(e)}catch{return[]}const r=n;if(!r||1!==r.v||!Array.isArray(r.tabs))return[];const i=[];for(const e of r.tabs){if(!e||"string"!=typeof e.path||!e.path.startsWith("/")||e.path.startsWith("//"))continue;const n=e.path.indexOf("#"),r=n>=0?e.path.slice(0,n):e.path,l=t(r);if(!l||i.some(e=>e.key===l.key))continue;const a="page"===e.titleFrom&&"string"==typeof e.title&&e.title;i.push({key:l.key,path:r,title:a||l.title,titleFrom:a?"page":"route",pinned:!1,lastActive:0})}return i}(function(e){if(!e)return null;try{return localStorage.getItem(e)}catch{return null}}(a),e=>K(j(e)));let t=function(e,t){const n=t.map(e=>e.key);let r=e.tabs.map(e=>({...e,pinned:n.includes(e.key)}));for(const e of t)r.some(t=>t.key===e.key)||(r=[...r,{key:e.key,path:e.path,title:e.title,titleFrom:"route",pinned:!0,lastActive:0}]);return{...e,tabs:T(r,n)}}({tabs:[],activeKey:null,mounted:[],dirty:[],closing:null,clock:0,tabs:e},n.map(e=>K(j(e))).filter(e=>Boolean(e)));const r=o?K(h):null;return t=r?$(t,r,s):A(t),t}),D=c(F);D.current=F;const O=c(/* @__PURE__ */new Map),z=o?K(h):null,E=z?.key??null;l(()=>{if(!o)return;const e=K(h);e?(O.current.set(e.key,h),L({type:"visit",entry:e,maxTabs:s})):L({type:"transient"})},[h,o,s,K]),d(()=>{const e=new Set(F.tabs.map(e=>e.key));for(const t of O.current.keys())e.has(t)||O.current.delete(t)},[F.tabs]);const B=u(()=>function(e){const t={v:1,tabs:e.tabs.filter(t=>t.key!==e.closing).map(({key:e,path:t,title:n,titleFrom:r})=>({key:e,path:t,title:n,titleFrom:r}))};return JSON.stringify(t)}(F),[F]);d(()=>{if(a)try{localStorage.setItem(a,B)}catch{}},[B,a]);const R=F.dirty.length>0;d(()=>{if(!R)return;const e=e=>{e.preventDefault(),e.returnValue=""};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[R]);const S=c(/* @__PURE__ */new Map),H=f((e,t)=>{let n=S.current.get(e);return void 0===n&&(n=S.current.size,S.current.set(e,n)),`${w}-page-${t}-${n}`},[w]),J=f(e=>p?p(e):r({title:x.discardTitle,message:1===e.length?x.discardOne:x.discardCount?.(e.length)??`${e.length} ${x.discardMany}`,confirmLabel:x.discardConfirm,cancelLabel:x.keepEditing,variant:"warning"}),[p,x]),V=f(()=>{const e=D.current;return e.tabs.find(e=>e.pinned)?.path??"/"},[]),W=f((e,t,n)=>{const r=D.current,i=r.activeKey;if(!i||!e.includes(i))return void L({type:"close",keys:e,closing:null});let l=t;if(!l){const t={...r,tabs:r.tabs.filter(t=>t.key===i||!e.includes(t.key))},a=n?r.tabs.find(t=>t.key===n&&!e.includes(t.key)):void 0;l=(a??function(e,t){const n=e.tabs.filter(n=>n.key!==e.closing||n.key===t),r=n.findIndex(e=>e.key===t);return r<0?null:n[r+1]??n[r-1]??null}(t,i))?.path??V()}L({type:"close",keys:e.filter(e=>e!==i),closing:i}),b(l)},[b,V]),_=f(async(e,t={})=>{const n=D.current.tabs.find(t=>t.key===e);return!n||n.pinned?(t.to&&b(t.to),!1):!(!t.force&&D.current.dirty.includes(e)&&!await J([n]))&&(!!D.current.tabs.some(t=>t.key===e)&&(W([e],t.to),!0))},[J,W,b]),P=f(async(e,t)=>{let n=function(e,t,n){const r=e.tabs.filter(e=>!e.pinned);if("all"===t)return r.map(e=>e.key);if("others"===t)return r.filter(e=>e.key!==n).map(e=>e.key);const i=e.tabs.findIndex(e=>e.key===n);return i<0?[]:e.tabs.slice(i+1).filter(e=>!e.pinned).map(e=>e.key)}(D.current,e,t);const r=D.current.tabs.filter(e=>n.includes(e.key)&&D.current.dirty.includes(e.key));r.length&&!await J(r)&&(n=n.filter(e=>!r.some(t=>t.key===e)));const i=new Set(D.current.tabs.map(e=>e.key));n=n.filter(e=>i.has(e)),n.length&&W(n,void 0,"all"===e?null:t)},[J,W]),Q=f(e=>{const t=D.current.tabs.find(t=>t.key===e);t&&e!==D.current.activeKey&&b(t.path)},[b]),X=f((e,t)=>L({type:"title",key:e,title:t}),[]),Y=f((e,t)=>L({type:"dirty",key:e,dirty:t}),[]),Z=f(e=>K(e)?.key??null,[K]),q=f(e=>O.current.get(e),[]),G=u(()=>o?F.tabs.filter(e=>e.key!==F.closing):[],[o,F.tabs,F.closing]),U=u(()=>({enabled:o,state:F,currentKey:E,resolve:t,keyFor:Z,locationFor:q,idFor:H,activate:Q,close:_,closeMany:P,setTitle:X,setDirty:Y,visibleTabs:G}),[o,F,E,t,Z,q,H,Q,_,P,X,Y,G]);/* @__PURE__ */
3
+ return g(N.Provider,{value:U,children:e})}var O=a.Activity,z=Boolean(O);function E({active:e,children:t}){return O?/* @__PURE__ */g(O,{mode:e?"visible":"hidden",children:t}):/* @__PURE__ */g(x,{children:t})}var B=o(function({tabKey:e,active:t,location:n,render:r,className:i,panelId:a,tabId:s}){const o=c(null),y=c(t),f=c(/* @__PURE__ */new Map);l(()=>{const e=y.current;if(y.current=t,t&&!e)for(const[e,[t,n]]of f.current)e.isConnected?(e.scrollTop=t,e.scrollLeft=n):f.current.delete(e)},[t]),d(()=>{const e=o.current;if(!e)return;const t=e=>{if(!y.current)return;const t=e.target;t&&"number"==typeof t.scrollTop&&f.current.set(t,[t.scrollTop,t.scrollLeft])};return e.addEventListener("scroll",t,!0),()=>e.removeEventListener("scroll",t,!0)},[]);const m=u(()=>({key:e,activeRef:y}),[e]);/* @__PURE__ */
4
+ return g("div",{ref:o,role:a?"tabpanel":void 0,id:a,"aria-labelledby":s,hidden:!t,style:t?void 0:{display:"none"},className:i,"data-page-tab":e,children:/* @__PURE__ */g(I.Provider,{value:m,children:/* @__PURE__ */g(E,{active:t,children:r(n)})})})},(e,t)=>e.active===t.active&&e.location===t.location&&e.className===t.className&&e.panelId===t.panelId&&e.tabId===t.tabId&&(!t.active||e.render===t.render)),R="\0transient";function S({children:e,frameClassName:t}){const n=p(N),r=k();if(!n||!n.enabled)/* @__PURE__ */
5
+ return g("div",{className:t,children:e(r)},R);const{state:i,currentKey:l,locationFor:a,idFor:s}=n,o=i.tabs.filter(e=>i.mounted.includes(e.key)).map(e=>e.key);return l&&!o.includes(l)&&o.push(l),/* @__PURE__ */w(x,{children:[o.map(n=>{const i=n===l,o=i?r:a(n);return o?/* @__PURE__ */g(B,{tabKey:n,active:i,location:o,render:e,className:t,panelId:s(n,"panel"),tabId:s(n,"tab")},n):null}),!l&&/* @__PURE__ */g(B,{tabKey:R,active:!0,location:r,render:e,className:t},R)]})}var H="outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-500";function J(){/* @__PURE__ */
6
+ return g("svg",{viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",className:"size-3.5",children:/* @__PURE__ */g("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z"})})}function V({className:r,activeClassName:l,end:a}){const s=p(N),o=i().pageTabs,u=c(null),[y,f]=h(null),m=s?.currentKey??null;if(d(()=>{if(!s||!m)return;const e=document.getElementById(s.idFor(m,"tab"));e?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[s,m]),!s||!s.enabled)return null;const{visibleTabs:k,state:v,idFor:x,activate:I,close:K,closeMany:F,resolve:T}=s,$=k.some(e=>e.key===m)?m:k[0]?.key,A=e=>{const t=k[(e+k.length)%k.length];t&&document.getElementById(x(t.key,"tab"))?.focus()},L=y?k.find(e=>e.key===y.key):void 0,M=L?k.indexOf(L):-1,C=e=>e.some(e=>!e.pinned),D=e=>()=>{f(null),e()};/* @__PURE__ */
7
7
  return w("div",{className:r??"relative flex h-10 shrink-0 items-end gap-3 bg-gray-100 px-3",children:[
8
8
  /* @__PURE__ */g("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-x-0 bottom-0 h-px bg-gray-200"}),
9
- /* @__PURE__ */g("div",{ref:u,role:"tablist","aria-label":o.label,onKeyDown:e=>{const t=k.findIndex(t=>document.getElementById(x(t.key,"tab"))===e.target);if(!(t<0)){if("ArrowRight"===e.key)$(t+1);else if("ArrowLeft"===e.key)$(t-1);else if("Home"===e.key)$(0);else if("End"===e.key)$(k.length-1);else{if("Delete"!==e.key||k[t].pinned)return;K(k[t].key)}e.preventDefault()}},className:"flex min-w-0 flex-1 items-end overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:k.map((e,t)=>{const n=e.key===m,r=v.dirty.includes(e.key),i=F(j(e.path))?.icon,a=n?l??"z-[1] border-gray-200 bg-gray-50 text-gray-900":"border-transparent text-gray-600 hover:bg-gray-200/70 hover:text-gray-900",s=t>0&&!n&&k[t-1].key!==m,c={type:"button",role:"tab",id:x(e.key,"tab"),"aria-selected":n,"aria-controls":v.mounted.includes(e.key)?x(e.key,"panel"):void 0,tabIndex:e.key===T?0:-1,title:e.title,onClick:()=>I(e.key)},d={onContextMenu:t=>((e,t)=>{e.preventDefault(),f({x:e.clientX,y:e.clientY,key:t.key})})(t,e),onAuxClick:t=>((e,t)=>{1!==e.button||t.pinned||(e.preventDefault(),K(t.key))})(t,e),onMouseDown:e=>{1===e.button&&e.preventDefault()}},u=i&&
9
+ /* @__PURE__ */g("div",{ref:u,role:"tablist","aria-label":o.label,onKeyDown:e=>{const t=k.findIndex(t=>document.getElementById(x(t.key,"tab"))===e.target);if(!(t<0)){if("ArrowRight"===e.key)A(t+1);else if("ArrowLeft"===e.key)A(t-1);else if("Home"===e.key)A(0);else if("End"===e.key)A(k.length-1);else{if("Delete"!==e.key||k[t].pinned)return;K(k[t].key)}e.preventDefault()}},className:"flex min-w-0 flex-1 items-end overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:k.map((e,t)=>{const n=e.key===m,r=v.dirty.includes(e.key),i=T(j(e.path))?.icon,a=n?l??"z-[1] border-gray-200 bg-gray-50 text-gray-900":"border-transparent text-gray-600 hover:bg-gray-200/70 hover:text-gray-900",s=t>0&&!n&&k[t-1].key!==m,c={type:"button",role:"tab",id:x(e.key,"tab"),"aria-selected":n,"aria-controls":v.mounted.includes(e.key)?x(e.key,"panel"):void 0,tabIndex:e.key===$?0:-1,title:e.title,onClick:()=>I(e.key)},d={onContextMenu:t=>((e,t)=>{e.preventDefault(),f({x:e.clientX,y:e.clientY,key:t.key})})(t,e),onAuxClick:t=>((e,t)=>{1!==e.button||t.pinned||(e.preventDefault(),K(t.key))})(t,e),onMouseDown:e=>{1===e.button&&e.preventDefault()}},u=i&&
10
10
  /* @__PURE__ */w("span",{className:"relative flex size-4 shrink-0 items-center justify-center text-gray-500 [&>svg]:size-4","aria-hidden":"true",children:[i,r&&!n&&!e.pinned&&
11
- /* @__PURE__ */g("span",{className:"absolute -right-1 -top-1 hidden size-2 rounded-full bg-gray-500 ring-2 ring-gray-100 @max-[6.5rem]:block @max-[6.5rem]:group-hover:hidden"})]});return e.pinned?/* @__PURE__ */g("div",{role:"presentation",className:`group relative flex h-9 flex-none items-center justify-center rounded-t-md border border-b-0 transition-colors ${i?"w-10":""} ${a}`,...d,children:/* @__PURE__ */w("button",{...c,className:`flex h-full items-center justify-center rounded-t-md ${i?"w-full":"px-3"} ${J}`,children:[u,
11
+ /* @__PURE__ */g("span",{className:"absolute -right-1 -top-1 hidden size-2 rounded-full bg-gray-500 ring-2 ring-gray-100 @max-[6.5rem]:block @max-[6.5rem]:group-hover:hidden"})]});return e.pinned?/* @__PURE__ */g("div",{role:"presentation",className:`group relative flex h-9 flex-none items-center justify-center rounded-t-md border border-b-0 transition-colors ${i?"w-10":""} ${a}`,...d,children:/* @__PURE__ */w("button",{...c,className:`flex h-full items-center justify-center rounded-t-md ${i?"w-full":"px-3"} ${H}`,children:[u,
12
12
  /* @__PURE__ */g("span",{className:i?"sr-only":"whitespace-nowrap text-[13px]",children:e.title})]})},e.key):/* @__PURE__ */w(b,{children:[s&&/* @__PURE__ */g("span",{"aria-hidden":"true",className:"mb-2.5 h-4 w-px shrink-0 self-end border-l border-gray-300"}),
13
13
  /* @__PURE__ */w("div",{role:"presentation",className:`group @container relative flex h-9 flex-[0_1_15rem] items-center rounded-t-md border border-b-0 text-[13px] transition-colors ${n?"min-w-[4.25rem]":"min-w-[2.75rem]"} ${a}`,...d,children:[
14
- /* @__PURE__ */w("button",{...c,className:`flex h-full min-w-0 flex-1 items-center gap-2 rounded-t-md pl-3 pr-1 text-left ${J} ${n?"@max-[5rem]:pl-2.5":"@max-[6.5rem]:pr-3 @max-[6.5rem]:group-hover:pr-1 @max-[4.5rem]:justify-center @max-[4.5rem]:px-0 @max-[4.5rem]:group-hover:pl-1.5"}`,children:[u,
14
+ /* @__PURE__ */w("button",{...c,className:`flex h-full min-w-0 flex-1 items-center gap-2 rounded-t-md pl-3 pr-1 text-left ${H} ${n?"@max-[5rem]:pl-2.5":"@max-[6.5rem]:pr-3 @max-[6.5rem]:group-hover:pr-1 @max-[4.5rem]:justify-center @max-[4.5rem]:px-0 @max-[4.5rem]:group-hover:pl-1.5"}`,children:[u,
15
15
  /* @__PURE__ */g("span",{className:"min-w-0 flex-1 overflow-hidden whitespace-nowrap [mask-image:linear-gradient(to_right,#000_calc(100%-1rem),transparent)] "+(i?n?"@max-[5rem]:sr-only":"@max-[4.5rem]:sr-only":""),children:e.title})]}),
16
16
  /* @__PURE__ */w("span",{className:"mr-1.5 flex size-5 shrink-0 items-center justify-center "+(n?"":"@max-[6.5rem]:hidden @max-[6.5rem]:group-hover:flex"),children:[r&&/* @__PURE__ */g("span",{role:"img","aria-label":o.unsaved,className:"size-2 rounded-full bg-gray-500 group-hover:hidden"}),
17
- /* @__PURE__ */g("button",{type:"button",tabIndex:-1,"aria-label":o.closeTab?.(e.title)??`${o.close} ${e.title}`,onClick:()=>{K(e.key)},className:"size-5 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 "+(r?"hidden group-hover:flex":n?"flex":"flex opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),children:/* @__PURE__ */g(H,{})})]})]})]},e.key)})}),a&&/* @__PURE__ */g("div",{className:"flex shrink-0 items-center gap-2 self-center",children:a}),y&&C&&/* @__PURE__ */w(e,{portal:!0,style:{left:y.x,top:y.y},onClose:()=>f(null),children:[
18
- /* @__PURE__ */g(t,{disabled:C.pinned,onClick:D(()=>K(C.key)),children:o.close}),
17
+ /* @__PURE__ */g("button",{type:"button",tabIndex:-1,"aria-label":o.closeTab?.(e.title)??`${o.close} ${e.title}`,onClick:()=>{K(e.key)},className:"size-5 items-center justify-center rounded text-gray-400 hover:bg-gray-200 hover:text-gray-700 "+(r?"hidden group-hover:flex":n?"flex":"flex opacity-0 group-hover:opacity-100 focus-visible:opacity-100"),children:/* @__PURE__ */g(J,{})})]})]})]},e.key)})}),a&&/* @__PURE__ */g("div",{className:"flex shrink-0 items-center gap-2 self-center",children:a}),y&&L&&/* @__PURE__ */w(e,{portal:!0,style:{left:y.x,top:y.y},onClose:()=>f(null),children:[
18
+ /* @__PURE__ */g(t,{disabled:L.pinned,onClick:D(()=>K(L.key)),children:o.close}),
19
19
  /* @__PURE__ */g(n,{}),
20
- /* @__PURE__ */g(t,{disabled:!M(k.filter(e=>e.key!==C.key)),onClick:D(()=>A("others",C.key)),children:o.closeOthers}),
21
- /* @__PURE__ */g(t,{disabled:!M(k.slice(L+1)),onClick:D(()=>A("right",C.key)),children:o.closeRight}),
22
- /* @__PURE__ */g(t,{disabled:!M(k),onClick:D(()=>A("all",null)),children:o.closeAll})]})]})}var _={enabled:!1,tabs:[],activeKey:null,activate:()=>{},close:async()=>!1,closeOthers:async()=>{},closeRight:async()=>{},closeAll:async()=>{}};function P(){const e=p(N);return e&&e.enabled?{enabled:!0,tabs:e.visibleTabs,activeKey:e.currentKey,activate:e.activate,close:e.close,closeOthers:t=>e.closeMany("others",t),closeRight:t=>e.closeMany("right",t),closeAll:()=>e.closeMany("all",null)}:_}function V(){const e=p(N),t=p(I),n=v();return{key:e?.enabled&&t?t.key:null,close:f(async(r={})=>e?.enabled&&t&&e.state.tabs.some(e=>e.key===t.key)?e.close(t.key,r):(r.to&&n(r.to),!1),[e,t,n])}}function X(e){const t=p(N),n=p(I),r=t?.enabled?t.setTitle:void 0,i=n?.key;d(()=>{r&&i&&e&&r(i,e)},[r,i,e])}function Z(e){const t=p(N),n=p(I),r=t?.enabled?t.setDirty:void 0;d(()=>{if(r&&n)return r(n.key,e),()=>{n.activeRef.current&&r(n.key,!1)}},[r,n,e])}export{K as DEFAULT_MAX_TABS,z as PAGE_TABS_PAUSE_HIDDEN,W as PageTabBar,S as PageTabsOutlet,D as PageTabsProvider,j as parseTabPath,V as usePageTab,Z as usePageTabDirty,X as usePageTabTitle,P as usePageTabs};
20
+ /* @__PURE__ */g(t,{disabled:!C(k.filter(e=>e.key!==L.key)),onClick:D(()=>F("others",L.key)),children:o.closeOthers}),
21
+ /* @__PURE__ */g(t,{disabled:!C(k.slice(M+1)),onClick:D(()=>F("right",L.key)),children:o.closeRight}),
22
+ /* @__PURE__ */g(t,{disabled:!C(k),onClick:D(()=>F("all",null)),children:o.closeAll})]})]})}var W={enabled:!1,tabs:[],activeKey:null,activate:()=>{},close:async()=>!1,closeOthers:async()=>{},closeRight:async()=>{},closeAll:async()=>{}};function _(){const e=p(N);return e&&e.enabled?{enabled:!0,tabs:e.visibleTabs,activeKey:e.currentKey,activate:e.activate,close:e.close,closeOthers:t=>e.closeMany("others",t),closeRight:t=>e.closeMany("right",t),closeAll:()=>e.closeMany("all",null)}:W}function P(){const e=p(N),t=p(I),n=v();return{key:e?.enabled&&t?t.key:null,close:f(async(r={})=>e?.enabled&&t&&e.state.tabs.some(e=>e.key===t.key)?e.close(t.key,r):(r.to&&n(r.to),!1),[e,t,n])}}function Q(e){const t=p(N),n=p(I),r=t?.enabled?t.setTitle:void 0,i=n?.key;d(()=>{r&&i&&e&&r(i,e)},[r,i,e])}function X(e){const t=p(N),n=p(I),r=t?.enabled?t.setDirty:void 0;d(()=>{if(r&&n)return r(n.key,e),()=>{n.activeRef.current&&r(n.key,!1)}},[r,n,e])}export{K as DEFAULT_MAX_TABS,z as PAGE_TABS_PAUSE_HIDDEN,V as PageTabBar,S as PageTabsOutlet,D as PageTabsProvider,j as parseTabPath,P as usePageTab,X as usePageTabDirty,Q as usePageTabTitle,_ as usePageTabs};