@m3ui-vue/m3ui-vue 1.2.0 → 1.2.2

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/dist/API.md +152 -11
  2. package/dist/{MMenuItem-DI351kIf.js → MMenuItem-D4Gx_l3F.js} +2 -2
  3. package/dist/{MMenuItem-DI351kIf.js.map → MMenuItem-D4Gx_l3F.js.map} +1 -1
  4. package/dist/{MSlider-BnEy5ieZ.js → MSlider-Dx_S3vJ9.js} +227 -221
  5. package/dist/{MSlider-BnEy5ieZ.js.map → MSlider-Dx_S3vJ9.js.map} +1 -1
  6. package/dist/{MTextField-BBmkaIbO.js → MTextField-Bz8JIsnl.js} +4 -4
  7. package/dist/{MTextField-BBmkaIbO.js.map → MTextField-Bz8JIsnl.js.map} +1 -1
  8. package/dist/api.json +1 -1
  9. package/dist/chart.js +1 -1
  10. package/dist/components/MMap.vue.d.ts +1 -1
  11. package/dist/components/MSlider.vue.d.ts +2 -2
  12. package/dist/composables/_effectCanvas.d.ts +23 -0
  13. package/dist/composables/_storageKeys.d.ts +9 -0
  14. package/dist/composables/themeInitScript.d.ts +2 -0
  15. package/dist/composables/useConfetti.d.ts +19 -8
  16. package/dist/composables/useFireworks.d.ts +37 -0
  17. package/dist/composables/useReactions.d.ts +32 -0
  18. package/dist/composables/viewportHints.d.ts +2 -0
  19. package/dist/directives/vSparkle.d.ts +27 -0
  20. package/dist/index.d.ts +7 -1
  21. package/dist/m3ui.js +5404 -5023
  22. package/dist/m3ui.js.map +1 -1
  23. package/dist/map.js +572 -572
  24. package/dist/map.js.map +1 -1
  25. package/dist/plugin.d.ts +10 -0
  26. package/dist/rich-text-editor.js +2 -2
  27. package/dist/{useThemeTokens-Bv-Uv8eX.js → useThemeTokens-y0HZpyhL.js} +23 -8
  28. package/dist/useThemeTokens-y0HZpyhL.js.map +1 -0
  29. package/package.json +1 -1
  30. package/src/__tests__/MSegmentedButton.test.ts +10 -0
  31. package/src/__tests__/MSlider.test.ts +36 -0
  32. package/src/__tests__/plugin.test.ts +56 -1
  33. package/src/__tests__/ssr.test.ts +1 -1
  34. package/src/__tests__/themeInitScript.test.ts +10 -0
  35. package/src/__tests__/useConfetti.test.ts +33 -2
  36. package/src/__tests__/useFireworks.test.ts +104 -0
  37. package/src/__tests__/useReactions.test.ts +51 -0
  38. package/src/__tests__/vSparkle.test.ts +83 -0
  39. package/src/components/MEmojiSelector.vue +3 -2
  40. package/src/components/MMap.vue +3 -2
  41. package/src/components/MSegmentedButton.vue +1 -1
  42. package/src/components/MSlider.vue +22 -4
  43. package/src/components/MTextField.vue +8 -4
  44. package/src/composables/_colorUtils.ts +4 -2
  45. package/src/composables/_effectCanvas.ts +109 -0
  46. package/src/composables/_ssrState.ts +2 -2
  47. package/src/composables/_storageKeys.ts +28 -0
  48. package/src/composables/themeInitScript.ts +5 -2
  49. package/src/composables/useColorPalette.ts +36 -8
  50. package/src/composables/useConfetti.ts +84 -107
  51. package/src/composables/useFireworks.ts +360 -0
  52. package/src/composables/useReactions.ts +131 -0
  53. package/src/composables/useTheme.ts +21 -4
  54. package/src/composables/viewportHints.ts +6 -5
  55. package/src/directives/vSparkle.ts +180 -0
  56. package/src/index.ts +7 -1
  57. package/src/plugin.ts +21 -5
  58. package/dist/useThemeTokens-Bv-Uv8eX.js.map +0 -1
package/dist/map.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"map.js","names":["$attrs","$slots","$attrs","$attrs","$slots","$slots","$attrs"],"sources":["../src/composables/useMap.ts","../src/components/MMapControl.vue","../src/components/MMapControl.vue","../src/components/_MMapAttribution.vue","../src/components/_MMapAttribution.vue","../src/composables/useMapLayers.ts","../src/composables/_mapStyle.ts","../src/components/MMap.vue","../src/components/MMap.vue","../src/composables/_mapPin.ts","../src/components/MMapMarker.vue","../src/components/MMapMarker.vue","../src/components/MMapPopup.vue","../src/components/MMapPopup.vue","../src/components/MMapGeoJson.vue","../src/components/MMapGeoJson.vue","../src/components/_MMapLayerItem.vue","../src/components/_MMapLayerItem.vue","../src/components/MMapLayers.vue","../src/components/MMapLayers.vue","../src/components/MMapBaseLayers.vue","../src/components/MMapBaseLayers.vue","../src/components/MMapFeatureInfo.vue","../src/components/MMapFeatureInfo.vue","../src/composables/mapAdapters.ts","../src/components/MMapIdentify.vue","../src/components/MMapIdentify.vue","../src/components/MMapHover.vue","../src/components/MMapHover.vue","../src/composables/_mapGeometry.ts","../src/components/MMapMeasure.vue","../src/components/MMapMeasure.vue","../src/composables/useMapFilter.ts","../src/components/MMapFilter.vue","../src/components/MMapFilter.vue","../src/composables/mapSearch.ts","../src/components/MMapSearch.vue","../src/components/MMapSearch.vue"],"sourcesContent":["import { computed, getCurrentInstance, inject, onBeforeUnmount, onMounted, provide, toValue, watch, type ComputedRef, type InjectionKey, type MaybeRefOrGetter, type Ref, type ShallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport type { MapLayerModel } from './mapAdapters'\nimport type { MapLayerState } from './useMapLayers'\n\n/** The `maplibre-gl` module (its classes: `Map`, `Marker`, `Popup`…) */\nexport type MaplibreModule = typeof import('maplibre-gl')\n\n/** What `MMap` provides to everything inside it. */\nexport interface MapContext {\n /** The MapLibre map, once created (never on the server) */\n map: ShallowRef<Maplibre.Map | undefined>\n /** The `maplibre-gl` module, loaded with the map (so nothing imports it on the server) */\n maplibre: ShallowRef<MaplibreModule | undefined>\n /** Bumped on every `style.load`: sources and layers added by components are re-added after a style change */\n styleVersion: Ref<number>\n /** The style as `MMap`'s `adapter` reads it (undefined without one) */\n model: ShallowRef<MapLayerModel | undefined>\n /** Visibility and opacity of the model's layers */\n layerState: MapLayerState\n /**\n * The tool that owns the map's clicks right now (`'measure'` while measuring), or null: `MMapIdentify` stays quiet\n * meanwhile. Set it from tools of your own the same way\n */\n activeTool: Ref<string | null>\n}\n\n// Internal: provided by MMap\nexport const MAP_KEY: InjectionKey<MapContext> = Symbol('m3-map')\n\n/**\n * A map to use from outside `<MMap>`: the `MMap` itself (a template ref: `<MMap ref=\"map\">` → `:map=\"map\"`) or its\n * `context`. Null or undefined until it mounts.\n */\nexport type MapSource = { context: MapContext } | MapContext | null | undefined\n\n/**\n * Internal: the enclosing MMap's context or, outside one, a context that follows `source` (empty until it's\n * there), provided to the caller's children too. Null when there's neither.\n */\nexport function resolveMapContext(source?: MaybeRefOrGetter<MapSource>): MapContext | null {\n const injected = inject(MAP_KEY, null)\n if (injected || source === undefined) return injected\n const ctx = computed(() => {\n const s = toValue(source)\n return !s ? undefined : 'context' in s ? s.context : s\n })\n const empty = { visible: {} as Record<string, boolean>, opacity: {} as Record<string, number> }\n const forwarded = {\n map: computed(() => ctx.value?.map.value),\n maplibre: computed(() => ctx.value?.maplibre.value),\n styleVersion: computed(() => ctx.value?.styleVersion.value ?? 0),\n model: computed(() => ctx.value?.model.value),\n // Reads and writes reach the map's own state once it's there\n layerState: new Proxy(empty, { get: (target, key) => Reflect.get(ctx.value?.layerState ?? target, key) }),\n activeTool: computed({\n get: () => ctx.value?.activeTool.value ?? null,\n set: (v) => { if (ctx.value) ctx.value.activeTool.value = v },\n }),\n } as unknown as MapContext\n provide(MAP_KEY, forwarded)\n return forwarded\n}\n\ntype MapEventType = keyof Maplibre.MapEventType\ntype LayerEventType = keyof Maplibre.MapLayerEventType\n\n/**\n * The map of the enclosing `MMap`, for your own controls, layers and handlers (call it in a component inside\n * `MMap`). Listeners added through it are removed when the component unmounts. Outside an `MMap` (a side panel),\n * pass it one: the `MMap`'s template ref, or a getter for it; until it mounts, `map` is undefined and `onReady` waits.\n *\n * ```ts\n * const { map, onLayer } = useMap()\n * onLayer('click', 'parcels-fill', (e) => console.log(e.features?.[0]?.properties))\n *\n * // In a panel next to the map: <MMap ref=\"mapRef\"> … <MyPanel :map=\"mapRef\" />\n * const { map } = useMap(() => props.map)\n * ```\n */\nexport function useMap(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMap() must be called in a component inside <MMap>, or be given one')\n const cleanups: (() => void)[] = []\n if (getCurrentInstance()) onBeforeUnmount(() => cleanups.splice(0).forEach((fn) => fn()))\n\n /**\n * Runs `fn` with the map as soon as it exists (right away if it already does), and in a component not before it's\n * mounted, so its template refs are there.\n */\n function onReady(fn: (map: Maplibre.Map, maplibre: MaplibreModule) => void) {\n const run = () => {\n if (ctx!.map.value && ctx!.maplibre.value) return fn(ctx!.map.value, ctx!.maplibre.value)\n const stop = watch(ctx!.map, (map) => {\n if (!map || !ctx!.maplibre.value) return\n stop()\n fn(map, ctx!.maplibre.value)\n })\n cleanups.push(stop)\n }\n const instance = getCurrentInstance()\n if (instance && !instance.isMounted) onMounted(run)\n else run()\n }\n\n /** A map event listener (`click`, `moveend`, `style.load`…), removed on unmount. */\n function on<T extends MapEventType>(type: T, listener: (e: Maplibre.MapEventType[T] & object) => void) {\n onReady((map) => {\n map.on(type, listener)\n cleanups.push(() => map.off(type, listener))\n })\n }\n\n /**\n * A listener for one layer's features (`click`, `mouseenter`, `mousemove`…: `e.features` holds the features under\n * the pointer), removed on unmount. It survives style changes, being keyed by the layer id.\n */\n function onLayer<T extends LayerEventType>(type: T, layerId: string, listener: (e: Maplibre.MapLayerEventType[T] & object) => void) {\n onReady((map) => {\n map.on(type, layerId, listener)\n cleanups.push(() => map.off(type, layerId, listener))\n })\n }\n\n // computed, not readonly(): readonly() is deep, and a proxied maplibre Map breaks\n return {\n map: computed(() => ctx.map.value) as ComputedRef<Maplibre.Map | undefined>,\n maplibre: computed(() => ctx.maplibre.value) as ComputedRef<MaplibreModule | undefined>,\n styleVersion: computed(() => ctx.styleVersion.value),\n /** The tool that owns the map's clicks (null: none): set it while yours does, and leave it alone otherwise */\n activeTool: ctx.activeTool,\n onReady,\n on,\n onLayer,\n }\n}\n","<script setup lang=\"ts\">\n/**\n * Your own control in a corner of an `MMap`, stacked with MapLibre's (zoom, geolocate…) in that corner. With `group`\n * (the default) it's a control group like the zoom buttons: put `<button>`s with a Material Symbols icon in it and\n * they get the same M3 look. Without it, anything goes (an `MFab`, an `MSearchBar`, a card). With a `#panel` slot it\n * expands in place: a button in it calls `toggle` and the control grows into a panel with your content (a layer\n * picker, filters, a legend), and back. Its size springs whenever its content changes size, so the other controls in\n * the corner move along instead of jumping. Available from the `/map` entry point.\n *\n * @slot default The control's content; `{ expanded, toggle }` when it has a `#panel`\n * @slot panel What the control expands into (`v-model:expanded`); `{ close }`. Escape or a press outside it closes it\n * @event update:expanded Emitted when the panel opens or closes — powers v-model:expanded\n */\nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { motionSprings } from '../composables/motion'\nimport { playSamples, prefersReducedMotion, sampleAt, sampleSpring } from '../composables/_springAnimation'\nimport type { MapControlPosition } from './MMap.vue'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The corner */\n position?: MapControlPosition\n /** Draw it as a control group (a surface with dividers between buttons), like MapLibre's zoom buttons */\n group?: boolean\n /** Expanded into its `#panel` (v-model:expanded) */\n expanded?: boolean\n /** Springs the control's size when its content changes size (expanding, or anything else) */\n animate?: boolean\n }>(),\n { position: 'top-right', group: true, expanded: false, animate: true },\n)\n\nconst emit = defineEmits<{ 'update:expanded': [boolean] }>()\nconst slots = useSlots()\n\nconst el = ref<HTMLElement>()\nconst { onReady } = useMap()\n\n// ── Expanding into the panel ────────────────────────────────────────────────────────────────────────────\nconst open = ref(props.expanded)\nwatch(() => props.expanded, (v) => { open.value = v })\nconst showPanel = computed(() => open.value && !!slots.panel)\nfunction setOpen(v: boolean) {\n if (v === open.value) return\n open.value = v\n emit('update:expanded', v)\n}\nconst toggle = () => setOpen(!open.value)\nconst close = () => setOpen(false)\n\nfunction onOutside(e: PointerEvent) {\n if (showPanel.value && !el.value?.contains(e.target as Node)) close()\n}\nfunction onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Escape' && showPanel.value) {\n close()\n e.stopPropagation()\n }\n}\n\n// ── Size: a spring between the old and the new size whenever the content resizes (Standard DefaultSpatial).\n// The new layout is already there when the ResizeObserver reports it, before it paints, so the animation starts\n// from the old size without a flash; the content is clipped while it runs. Width/height can't run on the\n// compositor, but a control is small. ──────────────────────────────────────────────────────────────────────\nlet size: { w: number; h: number } | null = null\nlet anim: Animation | null = null\nlet samples: number[] = []\nlet from = { w: 0, h: 0 }\nlet to = { w: 0, h: 0 }\nlet observer: ResizeObserver | null = null\n\nfunction measure(): { w: number; h: number } {\n return { w: el.value!.offsetWidth, h: el.value!.offsetHeight }\n}\n\nfunction onResize() {\n const node = el.value\n if (!node || anim) return\n const next = measure()\n if (size && (next.w !== size.w || next.h !== size.h) && props.animate && !prefersReducedMotion()) grow(node, size, next)\n size = next\n}\n\nfunction grow(node: HTMLElement, a: { w: number; h: number }, b: { w: number; h: number }) {\n from = a\n to = b\n samples = sampleSpring(0, 1, 0, motionSprings.standard.defaultSpatial, 0.002)\n node.style.overflow = 'hidden'\n const lerp = (p: number) => ({ width: `${a.w + (b.w - a.w) * p}px`, height: `${a.h + (b.h - a.h) * p}px` })\n anim = playSamples(node, samples, lerp)\n if (!anim) return finish(node)\n anim.onfinish = () => finish(node)\n}\n\nfunction finish(node: HTMLElement) {\n anim?.cancel()\n anim = null\n node.style.overflow = ''\n // The content may have changed size again while it ran\n const now = measure()\n if (now.w !== to.w || now.h !== to.h) {\n size = to\n onResize()\n } else size = now\n}\n\n// A size change while it runs (closed mid-opening) starts from where it is, not from the old size\nfunction retarget() {\n const node = el.value\n if (!node || !anim) return\n const p = sampleAt(samples, anim.currentTime)\n const at = { w: from.w + (to.w - from.w) * p, h: from.h + (to.h - from.h) * p }\n anim.onfinish = null\n anim.cancel()\n anim = null\n size = at\n onResize()\n}\nwatch(showPanel, retarget, { flush: 'post' })\n\nlet map: Maplibre.Map | undefined\n// MapLibre's IControl: the element it places in the corner\nconst control: Maplibre.IControl = {\n onAdd: () => el.value!,\n onRemove: () => el.value?.remove(),\n}\n\nonReady((m) => {\n map = m\n if (el.value) m.addControl(control, props.position)\n})\n\nwatch(() => props.position, (position) => {\n if (!map || !el.value) return\n map.removeControl(control)\n map.addControl(control, position)\n})\n\nonMounted(() => {\n document.addEventListener('pointerdown', onOutside, true)\n if (typeof ResizeObserver === 'undefined' || !el.value) return\n observer = new ResizeObserver(onResize)\n observer.observe(el.value)\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('pointerdown', onOutside, true)\n observer?.disconnect()\n anim?.cancel()\n if (map?.hasControl(control)) map.removeControl(control)\n})\n</script>\n\n<template>\n <!-- Moved into the map's corner by MapLibre -->\n <div class=\"hidden\">\n <div\n ref=\"el\"\n class=\"maplibregl-ctrl m3-map-control\"\n :class=\"showPanel ? 'm3-map-control-panel' : group ? 'maplibregl-ctrl-group' : ''\"\n v-bind=\"$attrs\"\n @keydown=\"onKeyDown\"\n >\n <div v-if=\"showPanel\" class=\"m3-map-control-panel-in\">\n <slot name=\"panel\" :close=\"close\" />\n </div>\n <slot v-else :expanded=\"open\" :toggle=\"toggle\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Your own control in a corner of an `MMap`, stacked with MapLibre's (zoom, geolocate…) in that corner. With `group`\n * (the default) it's a control group like the zoom buttons: put `<button>`s with a Material Symbols icon in it and\n * they get the same M3 look. Without it, anything goes (an `MFab`, an `MSearchBar`, a card). With a `#panel` slot it\n * expands in place: a button in it calls `toggle` and the control grows into a panel with your content (a layer\n * picker, filters, a legend), and back. Its size springs whenever its content changes size, so the other controls in\n * the corner move along instead of jumping. Available from the `/map` entry point.\n *\n * @slot default The control's content; `{ expanded, toggle }` when it has a `#panel`\n * @slot panel What the control expands into (`v-model:expanded`); `{ close }`. Escape or a press outside it closes it\n * @event update:expanded Emitted when the panel opens or closes — powers v-model:expanded\n */\nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { motionSprings } from '../composables/motion'\nimport { playSamples, prefersReducedMotion, sampleAt, sampleSpring } from '../composables/_springAnimation'\nimport type { MapControlPosition } from './MMap.vue'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The corner */\n position?: MapControlPosition\n /** Draw it as a control group (a surface with dividers between buttons), like MapLibre's zoom buttons */\n group?: boolean\n /** Expanded into its `#panel` (v-model:expanded) */\n expanded?: boolean\n /** Springs the control's size when its content changes size (expanding, or anything else) */\n animate?: boolean\n }>(),\n { position: 'top-right', group: true, expanded: false, animate: true },\n)\n\nconst emit = defineEmits<{ 'update:expanded': [boolean] }>()\nconst slots = useSlots()\n\nconst el = ref<HTMLElement>()\nconst { onReady } = useMap()\n\n// ── Expanding into the panel ────────────────────────────────────────────────────────────────────────────\nconst open = ref(props.expanded)\nwatch(() => props.expanded, (v) => { open.value = v })\nconst showPanel = computed(() => open.value && !!slots.panel)\nfunction setOpen(v: boolean) {\n if (v === open.value) return\n open.value = v\n emit('update:expanded', v)\n}\nconst toggle = () => setOpen(!open.value)\nconst close = () => setOpen(false)\n\nfunction onOutside(e: PointerEvent) {\n if (showPanel.value && !el.value?.contains(e.target as Node)) close()\n}\nfunction onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Escape' && showPanel.value) {\n close()\n e.stopPropagation()\n }\n}\n\n// ── Size: a spring between the old and the new size whenever the content resizes (Standard DefaultSpatial).\n// The new layout is already there when the ResizeObserver reports it, before it paints, so the animation starts\n// from the old size without a flash; the content is clipped while it runs. Width/height can't run on the\n// compositor, but a control is small. ──────────────────────────────────────────────────────────────────────\nlet size: { w: number; h: number } | null = null\nlet anim: Animation | null = null\nlet samples: number[] = []\nlet from = { w: 0, h: 0 }\nlet to = { w: 0, h: 0 }\nlet observer: ResizeObserver | null = null\n\nfunction measure(): { w: number; h: number } {\n return { w: el.value!.offsetWidth, h: el.value!.offsetHeight }\n}\n\nfunction onResize() {\n const node = el.value\n if (!node || anim) return\n const next = measure()\n if (size && (next.w !== size.w || next.h !== size.h) && props.animate && !prefersReducedMotion()) grow(node, size, next)\n size = next\n}\n\nfunction grow(node: HTMLElement, a: { w: number; h: number }, b: { w: number; h: number }) {\n from = a\n to = b\n samples = sampleSpring(0, 1, 0, motionSprings.standard.defaultSpatial, 0.002)\n node.style.overflow = 'hidden'\n const lerp = (p: number) => ({ width: `${a.w + (b.w - a.w) * p}px`, height: `${a.h + (b.h - a.h) * p}px` })\n anim = playSamples(node, samples, lerp)\n if (!anim) return finish(node)\n anim.onfinish = () => finish(node)\n}\n\nfunction finish(node: HTMLElement) {\n anim?.cancel()\n anim = null\n node.style.overflow = ''\n // The content may have changed size again while it ran\n const now = measure()\n if (now.w !== to.w || now.h !== to.h) {\n size = to\n onResize()\n } else size = now\n}\n\n// A size change while it runs (closed mid-opening) starts from where it is, not from the old size\nfunction retarget() {\n const node = el.value\n if (!node || !anim) return\n const p = sampleAt(samples, anim.currentTime)\n const at = { w: from.w + (to.w - from.w) * p, h: from.h + (to.h - from.h) * p }\n anim.onfinish = null\n anim.cancel()\n anim = null\n size = at\n onResize()\n}\nwatch(showPanel, retarget, { flush: 'post' })\n\nlet map: Maplibre.Map | undefined\n// MapLibre's IControl: the element it places in the corner\nconst control: Maplibre.IControl = {\n onAdd: () => el.value!,\n onRemove: () => el.value?.remove(),\n}\n\nonReady((m) => {\n map = m\n if (el.value) m.addControl(control, props.position)\n})\n\nwatch(() => props.position, (position) => {\n if (!map || !el.value) return\n map.removeControl(control)\n map.addControl(control, position)\n})\n\nonMounted(() => {\n document.addEventListener('pointerdown', onOutside, true)\n if (typeof ResizeObserver === 'undefined' || !el.value) return\n observer = new ResizeObserver(onResize)\n observer.observe(el.value)\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('pointerdown', onOutside, true)\n observer?.disconnect()\n anim?.cancel()\n if (map?.hasControl(control)) map.removeControl(control)\n})\n</script>\n\n<template>\n <!-- Moved into the map's corner by MapLibre -->\n <div class=\"hidden\">\n <div\n ref=\"el\"\n class=\"maplibregl-ctrl m3-map-control\"\n :class=\"showPanel ? 'm3-map-control-panel' : group ? 'maplibregl-ctrl-group' : ''\"\n v-bind=\"$attrs\"\n @keydown=\"onKeyDown\"\n >\n <div v-if=\"showPanel\" class=\"m3-map-control-panel-in\">\n <slot name=\"panel\" :close=\"close\" />\n </div>\n <slot v-else :expanded=\"open\" :toggle=\"toggle\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/*\n * Internal (not exported): MMap's attribution, instead of MapLibre's AttributionControl. A round M3 icon button in a\n * corner (surface, elevation 2) that opens into a pill with the credits of the style's sources, its size springing\n * open and closed through MMapControl. The credits are collected like MapLibre's control does: the attribution of\n * every source a layer uses (from its TileJSON once loaded, else the style), without repeats or ones contained in\n * another. They're HTML from the style (links), as MapLibre renders them.\n */\nimport { computed, ref } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport { useMap } from '../composables/useMap'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = defineProps<{ position: MapControlPosition }>()\n\nconst t = useLocale()\nconst { on, onReady } = useMap()\n\nconst credits = ref<string[]>([])\nconst open = ref(true)\n// The text wraps against the map's width, not the control's while its size springs (it would reflow every frame)\nconst maxWidth = ref(0)\nlet map: Maplibre.Map | undefined\n\nfunction collect() {\n if (!map) return\n const style = map.getStyle?.()\n if (!style?.sources) return\n const used = new Set(style.layers?.map((l) => (l as { source?: string }).source).filter(Boolean))\n const found: string[] = []\n for (const [id, spec] of Object.entries(style.sources)) {\n if (used.size && !used.has(id)) continue\n const text = (map.getSource(id) as { attribution?: string } | undefined)?.attribution ?? (spec as { attribution?: string }).attribution\n if (text && !found.includes(text)) found.push(text)\n }\n const next = found.filter((a) => !found.some((b) => b !== a && b.includes(a)))\n if (next.join('\\n') !== credits.value.join('\\n')) credits.value = next\n maxWidth.value = Math.max(0, map.getContainer().clientWidth - 20)\n}\n\nonReady((m) => {\n map = m\n collect()\n})\non('styledata', collect)\non('sourcedata', collect)\non('resize', collect)\n// Open when the map loads, folded away once it's dragged, as MapLibre's compact attribution\non('dragstart', () => { open.value = false })\n\nconst html = computed(() => credits.value.join(' '))\n// The button sits at the corner's outer edge, the text inward\nconst end = computed(() => props.position.endsWith('right'))\n</script>\n\n<template>\n <MMapControl\n v-if=\"html\"\n :position=\"position\"\n :group=\"false\"\n class=\"m3-map-attrib\"\n :class=\"open ? 'm3-map-attrib-open' : ''\"\n >\n <div class=\"m3-map-attrib-row\" :class=\"end ? 'flex-row-reverse' : ''\" :style=\"maxWidth ? { maxWidth: `${maxWidth}px` } : undefined\">\n <button\n type=\"button\"\n class=\"m3-map-attrib-button\"\n :title=\"t.mapToggleAttribution\"\n :aria-label=\"t.mapToggleAttribution\"\n :aria-expanded=\"open\"\n @click=\"open = !open\"\n >\n <MIcon name=\"info\" :size=\"20\" />\n </button>\n <div v-if=\"open\" class=\"m3-map-attrib-text\" :class=\"end ? 'pl-3.5' : 'pr-3.5'\" v-html=\"html\" />\n </div>\n </MMapControl>\n</template>\n","<script setup lang=\"ts\">\n/*\n * Internal (not exported): MMap's attribution, instead of MapLibre's AttributionControl. A round M3 icon button in a\n * corner (surface, elevation 2) that opens into a pill with the credits of the style's sources, its size springing\n * open and closed through MMapControl. The credits are collected like MapLibre's control does: the attribution of\n * every source a layer uses (from its TileJSON once loaded, else the style), without repeats or ones contained in\n * another. They're HTML from the style (links), as MapLibre renders them.\n */\nimport { computed, ref } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport { useMap } from '../composables/useMap'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = defineProps<{ position: MapControlPosition }>()\n\nconst t = useLocale()\nconst { on, onReady } = useMap()\n\nconst credits = ref<string[]>([])\nconst open = ref(true)\n// The text wraps against the map's width, not the control's while its size springs (it would reflow every frame)\nconst maxWidth = ref(0)\nlet map: Maplibre.Map | undefined\n\nfunction collect() {\n if (!map) return\n const style = map.getStyle?.()\n if (!style?.sources) return\n const used = new Set(style.layers?.map((l) => (l as { source?: string }).source).filter(Boolean))\n const found: string[] = []\n for (const [id, spec] of Object.entries(style.sources)) {\n if (used.size && !used.has(id)) continue\n const text = (map.getSource(id) as { attribution?: string } | undefined)?.attribution ?? (spec as { attribution?: string }).attribution\n if (text && !found.includes(text)) found.push(text)\n }\n const next = found.filter((a) => !found.some((b) => b !== a && b.includes(a)))\n if (next.join('\\n') !== credits.value.join('\\n')) credits.value = next\n maxWidth.value = Math.max(0, map.getContainer().clientWidth - 20)\n}\n\nonReady((m) => {\n map = m\n collect()\n})\non('styledata', collect)\non('sourcedata', collect)\non('resize', collect)\n// Open when the map loads, folded away once it's dragged, as MapLibre's compact attribution\non('dragstart', () => { open.value = false })\n\nconst html = computed(() => credits.value.join(' '))\n// The button sits at the corner's outer edge, the text inward\nconst end = computed(() => props.position.endsWith('right'))\n</script>\n\n<template>\n <MMapControl\n v-if=\"html\"\n :position=\"position\"\n :group=\"false\"\n class=\"m3-map-attrib\"\n :class=\"open ? 'm3-map-attrib-open' : ''\"\n >\n <div class=\"m3-map-attrib-row\" :class=\"end ? 'flex-row-reverse' : ''\" :style=\"maxWidth ? { maxWidth: `${maxWidth}px` } : undefined\">\n <button\n type=\"button\"\n class=\"m3-map-attrib-button\"\n :title=\"t.mapToggleAttribution\"\n :aria-label=\"t.mapToggleAttribution\"\n :aria-expanded=\"open\"\n @click=\"open = !open\"\n >\n <MIcon name=\"info\" :size=\"20\" />\n </button>\n <div v-if=\"open\" class=\"m3-map-attrib-text\" :class=\"end ? 'pl-3.5' : 'pr-3.5'\" v-html=\"html\" />\n </div>\n </MMapControl>\n</template>\n","import { computed, reactive, type MaybeRefOrGetter } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { resolveMapContext, type MapSource } from './useMap'\nimport type { MapLayerInfo, MapLayerModel } from './mapAdapters'\n\n/** The paint properties that make each layer type transparent. */\nconst OPACITY: Record<string, string[]> = {\n fill: ['fill-opacity'],\n line: ['line-opacity'],\n circle: ['circle-opacity', 'circle-stroke-opacity'],\n symbol: ['icon-opacity', 'text-opacity'],\n raster: ['raster-opacity'],\n heatmap: ['heatmap-opacity'],\n 'fill-extrusion': ['fill-extrusion-opacity'],\n}\n\n/** Visibility and opacity of the model's layers, shared by everything inside one `MMap`. */\nexport interface MapLayerState {\n visible: Record<string, boolean>\n opacity: Record<string, number>\n}\n\n// Internal: MMap's shared state, filled from the map on every style load\nexport function createLayerState(): MapLayerState {\n return reactive({ visible: {}, opacity: {} })\n}\n\nexport function readLayerState(state: MapLayerState, map: Maplibre.Map, model: MapLayerModel | undefined) {\n const visible: Record<string, boolean> = {}\n const opacity: Record<string, number> = {}\n for (const layer of model?.layers ?? []) {\n const style = map.getLayer(layer.id)\n if (!style) continue\n visible[layer.id] = map.getLayoutProperty(layer.id, 'visibility') !== 'none'\n const prop = OPACITY[style.type]?.[0]\n const value = prop ? map.getPaintProperty(layer.id, prop) : undefined\n opacity[layer.id] = typeof value === 'number' ? value : 1\n }\n state.visible = visible\n state.opacity = opacity\n}\n\n/**\n * The layers of the enclosing `MMap`'s style as its `adapter` describes them, with their visibility and opacity, for a\n * layer panel or a base layer switcher of your own (`MMapLayers` and `MMapBaseLayers` are built on it). Changes go to\n * the map and to every component using it; a layer's `children` follow it. Outside an `MMap`, pass it one (its\n * template ref), as with `useMap`.\n */\nexport function useMapLayers(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMapLayers() must be called in a component inside <MMap>, or be given one')\n const { map, model, layerState: state } = ctx\n\n const layers = computed(() => model.value?.layers ?? [])\n const byId = computed(() => new Map(layers.value.map((l) => [l.id, l])))\n\n function isVisible(id: string) {\n return state.visible[id] ?? true\n }\n\n function setVisible(id: string, visible: boolean) {\n const m = map.value\n if (m?.getLayer(id)) m.setLayoutProperty(id, 'visibility', visible ? 'visible' : 'none')\n state.visible[id] = visible\n for (const child of byId.value.get(id)?.children ?? []) setVisible(child, visible)\n }\n\n function toggle(id: string) {\n setVisible(id, !isVisible(id))\n }\n\n function opacityOf(id: string) {\n return state.opacity[id] ?? 1\n }\n\n function setOpacity(id: string, opacity: number) {\n const m = map.value\n const layer = m?.getLayer(id)\n if (layer) for (const prop of OPACITY[layer.type] ?? []) m!.setPaintProperty(id, prop, opacity)\n state.opacity[id] = opacity\n for (const child of byId.value.get(id)?.children ?? []) setOpacity(child, opacity)\n }\n\n /** The layers of a group (listed ones), or the ungrouped ones with `null`. */\n function layersOf(group: string | null): MapLayerInfo[] {\n return layers.value.filter((l) => l.listed && (group === null ? !l.group || !model.value?.groups.some((g) => g.name === l.group) : l.group === group))\n }\n\n function groupState(group: string): 'visible' | 'hidden' | 'partial' {\n const visible = layersOf(group).map((l) => isVisible(l.id))\n if (visible.length && visible.every(Boolean)) return 'visible'\n if (visible.some(Boolean)) return 'partial'\n return 'hidden'\n }\n\n function setGroupVisible(group: string, visible: boolean) {\n for (const layer of layersOf(group)) setVisible(layer.id, visible)\n }\n\n const baseLayers = computed(() => layers.value.filter((l) => l.base))\n /** The visible base layer's id, or null */\n const baseLayer = computed(() => baseLayers.value.find((l) => isVisible(l.id))?.id ?? null)\n\n /** Shows this base layer only (null: none). */\n function setBaseLayer(id: string | null) {\n for (const layer of baseLayers.value) setVisible(layer.id, layer.id === id)\n }\n\n return {\n /** The adapter's model (undefined without an `adapter`) */\n model: computed(() => model.value),\n layers,\n isVisible,\n setVisible,\n toggle,\n opacityOf,\n setOpacity,\n layersOf,\n groupState,\n setGroupVisible,\n baseLayers,\n baseLayer,\n setBaseLayer,\n }\n}\n","import type * as Maplibre from 'maplibre-gl'\n\n/*\n * Internal (not exported from index.ts): what MMap carries over when `mapStyle` changes.\n *\n * MapLibre's setStyle() replaces everything, so sources and layers added at runtime (with useMap(), or the\n * library's own MMapGeoJson / MMapMeasure) were gone after a switch, until whoever added them noticed. A\n * `transformStyle` hook moves them into the next style instead: whatever wasn't part of the previous style as\n * loaded (`own`) was added at runtime. The library's components re-add theirs only when missing, so they just find\n * them there.\n */\n\n/** The ids a style came with, before anything was added at runtime */\nexport interface StyleIds {\n sources: Set<string>\n layers: Set<string>\n}\n\nexport function styleIds(style: Pick<Maplibre.StyleSpecification, 'sources' | 'layers'> | undefined): StyleIds {\n return {\n sources: new Set(Object.keys(style?.sources ?? {})),\n layers: new Set((style?.layers ?? []).map((l) => l.id)),\n }\n}\n\n/**\n * `next` with the runtime sources and layers of `previous` added: layers on top, in their order, unless `keep`\n * says no or the next style has the same id; sources unless the next style has one by that id (it wins, and\n * carried layers use it).\n */\nexport function carryRuntimeLayers(\n previous: Maplibre.StyleSpecification | undefined,\n next: Maplibre.StyleSpecification,\n own: StyleIds,\n keep: (layer: Maplibre.LayerSpecification) => boolean = () => true,\n): Maplibre.StyleSpecification {\n if (!previous) return next\n const nextLayers = new Set(next.layers.map((l) => l.id))\n const layers = previous.layers.filter((l) => !own.layers.has(l.id) && !nextLayers.has(l.id) && keep(l))\n const sources = { ...next.sources }\n for (const [id, source] of Object.entries(previous.sources)) {\n if (!own.sources.has(id) && !(id in sources)) sources[id] = source\n }\n return { ...next, sources, layers: [...next.layers, ...layers] }\n}\n","<script setup lang=\"ts\">\n/**\n * A MapLibre GL map, for any style: a style URL (from an MVT server like mvt-rs, MapTiler, OpenFreeMap…) or a style\n * object. Its controls take the M3 look and the app's locale, the view can be a v-model and remembered between visits,\n * and markers, popups, GeoJSON layers and your own controls go inside it as components. For anything else, the\n * MapLibre map itself is the `ready` event's argument and the `map` of `useMap()` in components placed inside.\n * Available from the `/map` entry point; needs `maplibre-gl` installed and its CSS imported\n * (`maplibre-gl/dist/maplibre-gl.css`). Give it a height. Server-side rendering renders the empty container: MapLibre\n * loads in the browser.\n *\n * @slot default Map components (`MMapMarker`, `MMapPopup`, `MMapGeoJson`, `MMapControl`) and anything to show over\n * the map, rendered once the map exists\n * @event ready The map loaded (with its style), with the MapLibre `Map`\n * @event click A click on the map (MapLibre's `MapMouseEvent`: `lngLat`, `point`)\n * @event update:center The view moved (on `moveend`): `[lng, lat]`\n * @event update:zoom The zoom changed (on `moveend`)\n * @event update:bearing The rotation changed (on `moveend`)\n * @event update:pitch The tilt changed (on `moveend`)\n */\nimport { markRaw, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapAttribution from './_MMapAttribution.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { MAP_KEY, type MapContext, type MaplibreModule } from '../composables/useMap'\nimport { createLayerState, readLayerState } from '../composables/useMapLayers'\nimport type { MapAdapter, MapLayerModel } from '../composables/mapAdapters'\nimport { carryRuntimeLayers, styleIds, type StyleIds } from '../composables/_mapStyle'\n\nexport type MapControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The map's style: a style JSON URL or a style object (MapLibre's `StyleSpecification`). Changing it reloads the\n * style, keeping what was added at runtime (see `keepLayers`)\n */\n mapStyle: string | Maplibre.StyleSpecification\n /**\n * What happens to the sources and layers added at runtime (with `useMap()`, or by `MMapGeoJson`, `MMapMeasure`…)\n * when `mapStyle` changes: `true` carries them into the new style, on top of its layers; `false` drops them, as\n * MapLibre does; a function picks the layers to carry (their sources come along)\n */\n keepLayers?: boolean | ((layer: Maplibre.LayerSpecification) => boolean)\n /**\n * MapLibre's `transformStyle` for a `mapStyle` change, run after `keepLayers`: edit the next style before it\n * loads (copy a layer's paint over, add a sprite…)\n */\n transformStyle?: Maplibre.TransformStyleFunction\n /** `[lng, lat]` (v-model). When left out, the style's (or the remembered view's) */\n center?: [number, number]\n /** Zoom level (v-model) */\n zoom?: number\n /** Rotation in degrees (v-model) */\n bearing?: number\n /** Tilt in degrees (v-model) */\n pitch?: number\n /**\n * Remember the view (center, zoom, bearing, pitch) in localStorage and start from it on the next visit: `true`\n * under `m3-map-view`, or your own key (one per map)\n */\n persist?: boolean | string\n /** Zoom and compass buttons: `false`, or a corner (`true` is top-right) */\n navigation?: boolean | MapControlPosition\n /** A button that centers the map on the user's location and follows it: `false`, or a corner (`true` is top-right) */\n geolocate?: boolean | MapControlPosition\n /** A fullscreen button: `false`, or a corner (`true` is top-right) */\n fullscreen?: boolean | MapControlPosition\n /** A metric scale bar: `false`, or a corner (`true` is bottom-left) */\n scale?: boolean | MapControlPosition\n /** The credits of the style's sources, an info button that opens into a pill: `false`, or a corner (`true` is bottom-right). Most tile providers require it */\n attribution?: boolean | MapControlPosition\n /** Anything else for MapLibre's `Map` constructor (`maxZoom`, `maxBounds`, `cooperativeGestures`…) */\n options?: Partial<Omit<Maplibre.MapOptions, 'container' | 'style'>>\n /**\n * Reads the style's conventions (layer names, groups, base layers, what to identify or show on hover) for\n * `MMapLayers`, `MMapBaseLayers`, `MMapIdentify` and `MMapHover`: `genericAdapter`, `orvianAdapter()`, or your own\n */\n adapter?: MapAdapter\n }>(),\n {\n persist: false,\n keepLayers: true,\n navigation: true,\n geolocate: false,\n fullscreen: false,\n scale: true,\n attribution: true,\n },\n)\n\nconst emit = defineEmits<{\n ready: [map: Maplibre.Map]\n click: [event: Maplibre.MapMouseEvent]\n 'update:center': [center: [number, number]]\n 'update:zoom': [zoom: number]\n 'update:bearing': [bearing: number]\n 'update:pitch': [pitch: number]\n}>()\n\nconst root = ref<HTMLElement>()\nconst container = ref<HTMLElement>()\nconst map = shallowRef<Maplibre.Map>()\nconst maplibre = shallowRef<MaplibreModule>()\nconst styleVersion = ref(0)\n// The sources and layers the current style came with (the rest were added at runtime: keepLayers)\nlet ownIds: StyleIds | undefined\nconst model = shallowRef<MapLayerModel>()\nconst layerState = createLayerState()\nconst activeTool = ref<string | null>(null)\nconst context: MapContext = { map, maplibre, styleVersion, model, layerState, activeTool }\nprovide(MAP_KEY, context)\n\n/** The adapter's model of the current style, and the layers' visibility and opacity in it. */\nfunction readModel(m: Maplibre.Map) {\n model.value = props.adapter\n ? props.adapter(m.getStyle(), { styleUrl: typeof props.mapStyle === 'string' ? props.mapStyle : undefined })\n : undefined\n readLayerState(layerState, m, model.value)\n}\n\nconst t = useLocale()\n\n// ── Remembered view ────────────────────────────────────────────────────────────────────────────\n\ninterface View { center: [number, number]; zoom: number; bearing: number; pitch: number }\nconst persistKey = () => (typeof props.persist === 'string' ? props.persist : props.persist ? 'm3-map-view' : null)\n\nfunction readView(): Partial<View> {\n const key = persistKey()\n if (!key) return {}\n try {\n const view = JSON.parse(localStorage.getItem(key) ?? 'null') as Partial<View> | null\n return view && typeof view === 'object' ? view : {}\n } catch {\n return {}\n }\n}\n\nfunction currentView(m: Maplibre.Map): View {\n const c = m.getCenter()\n return { center: [c.lng, c.lat], zoom: m.getZoom(), bearing: m.getBearing(), pitch: m.getPitch() }\n}\n\n// ── Controls ───────────────────────────────────────────────────────────────────────────────────\n\n// The attribution is a component of ours (_MMapAttribution, in the template), not MapLibre's control\ntype ControlName = 'navigation' | 'geolocate' | 'fullscreen' | 'scale'\nconst CONTROLS: Record<ControlName, { corner: MapControlPosition; create: (ml: MaplibreModule) => Maplibre.IControl }> = {\n navigation: { corner: 'top-right', create: (ml) => new ml.NavigationControl() },\n geolocate: {\n corner: 'top-right',\n create: (ml) => new ml.GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true }),\n },\n fullscreen: { corner: 'top-right', create: (ml) => new ml.FullscreenControl({ container: root.value }) },\n scale: { corner: 'bottom-left', create: (ml) => new ml.ScaleControl({ maxWidth: 100, unit: 'metric' }) },\n}\nconst added = new Map<ControlName, Maplibre.IControl>()\n\nfunction syncControl(name: ControlName) {\n const m = map.value\n const ml = maplibre.value\n if (!m || !ml) return\n const old = added.get(name)\n if (old) {\n m.removeControl(old)\n added.delete(name)\n }\n const setting = props[name]\n if (!setting) return\n const control = CONTROLS[name].create(ml)\n m.addControl(control, setting === true ? CONTROLS[name].corner : setting)\n added.set(name, control)\n}\n\nfor (const name of Object.keys(CONTROLS) as ControlName[]) watch(() => props[name], () => syncControl(name))\n\n// ── Map ────────────────────────────────────────────────────────────────────────────────────────\n\n/** MapLibre's UI strings, from the app's M3 locale. */\nfunction mapLocale() {\n return {\n 'AttributionControl.ToggleAttribution': t.mapToggleAttribution,\n 'AttributionControl.MapFeedback': t.mapFeedback,\n 'FullscreenControl.Enter': t.mapEnterFullscreen,\n 'FullscreenControl.Exit': t.mapExitFullscreen,\n 'GeolocateControl.FindMyLocation': t.mapFindMyLocation,\n 'GeolocateControl.LocationNotAvailable': t.mapLocationNotAvailable,\n 'Map.Title': t.mapTitle,\n 'Marker.Title': t.mapMarker,\n 'NavigationControl.ResetBearing': t.mapResetBearing,\n 'NavigationControl.ZoomIn': t.mapZoomIn,\n 'NavigationControl.ZoomOut': t.mapZoomOut,\n 'Popup.Close': t.close,\n 'CooperativeGesturesHandler.WindowsHelpText': t.mapCtrlScroll,\n 'CooperativeGesturesHandler.MacHelpText': t.mapCmdScroll,\n 'CooperativeGesturesHandler.MobileHelpText': t.mapTwoFingers,\n }\n}\n\n// ── Control tooltips ───────────────────────────────────────────────────────────────────────────\n// MapLibre's buttons (and yours, in MMapControl) carry a `title`, which the browser shows as its own tooltip: it's\n// moved to data-m3-tip (and aria-label when there's none) and shown as an M3 plain tooltip, inside the map so it's\n// there in fullscreen too\n\nconst TIP_DELAY = 600 // MTooltip's\nconst tip = ref<{ text: string; x: number; y: number; left: boolean } | null>(null)\nlet tipTimer: ReturnType<typeof setTimeout> | undefined\nlet tipObserver: MutationObserver | undefined\n\nfunction adoptTitle(el: Element) {\n const title = el.getAttribute('title')\n if (!title || !el.closest('.maplibregl-ctrl')) return\n el.setAttribute('data-m3-tip', title)\n if (!el.hasAttribute('aria-label')) el.setAttribute('aria-label', title)\n el.removeAttribute('title')\n}\n\nfunction showTip(el: HTMLElement) {\n const text = el.getAttribute('data-m3-tip')\n const box = root.value?.getBoundingClientRect()\n if (!text || !box) return\n const r = el.getBoundingClientRect()\n // Toward the inside of the map: left of a control on the right half, right of one on the left\n const left = r.left + r.width / 2 > box.left + box.width / 2\n tip.value = { text, left, x: (left ? r.left - 8 : r.right + 8) - box.left, y: r.top + r.height / 2 - box.top }\n}\n\nfunction hideTip() {\n clearTimeout(tipTimer)\n tip.value = null\n}\n\nconst tipTarget = (e: Event) => (e.target as Element | null)?.closest?.<HTMLElement>('.maplibregl-ctrl [data-m3-tip]') ?? null\n\nfunction onTipOver(e: PointerEvent) {\n const el = tipTarget(e)\n if (!el || e.pointerType === 'touch') return\n clearTimeout(tipTimer)\n tipTimer = setTimeout(() => showTip(el), TIP_DELAY)\n}\nfunction onTipOut(e: PointerEvent) {\n const el = tipTarget(e)\n if (el && !el.contains(e.relatedTarget as Node | null)) hideTip()\n}\nfunction onTipFocus(e: FocusEvent) {\n const el = tipTarget(e)\n if (el?.matches(':focus-visible')) showTip(el)\n}\n\nonMounted(() => {\n const el = root.value\n if (!el) return\n el.querySelectorAll('[title]').forEach(adoptTitle)\n tipObserver = new MutationObserver((records) => {\n for (const r of records) {\n if (r.type === 'attributes') adoptTitle(r.target as Element)\n else r.addedNodes.forEach((n) => {\n if (!(n instanceof Element)) return\n adoptTitle(n)\n n.querySelectorAll('[title]').forEach(adoptTitle)\n })\n }\n })\n tipObserver.observe(el, { subtree: true, childList: true, attributes: true, attributeFilter: ['title'] })\n})\n\nonBeforeUnmount(() => {\n tipObserver?.disconnect()\n clearTimeout(tipTimer)\n})\n\nlet destroyed = false\n\nonMounted(async () => {\n // maplibre-gl ships a UMD build: depending on the bundler its classes are on the namespace or on `default`\n const mod = await import('maplibre-gl')\n const ml = ('Map' in mod ? mod : (mod as { default: MaplibreModule }).default) as MaplibreModule\n if (destroyed || !container.value) return\n const saved = readView()\n const view = {\n center: saved.center ?? props.center,\n zoom: saved.zoom ?? props.zoom,\n bearing: saved.bearing ?? props.bearing,\n pitch: saved.pitch ?? props.pitch,\n }\n const m = markRaw(new ml.Map({\n container: container.value,\n style: props.mapStyle,\n attributionControl: false,\n locale: mapLocale(),\n // Only what's set, so a style's own center and zoom apply otherwise\n ...Object.fromEntries(Object.entries(view).filter(([, v]) => v !== undefined)),\n ...props.options,\n }))\n maplibre.value = ml\n\n m.on('style.load', () => {\n // The first style's own ids; a later style's are taken in transformStyle, before runtime layers join it\n if (!ownIds) ownIds = styleIds(m.getStyle())\n readModel(m)\n styleVersion.value++\n })\n m.on('click', (e) => emit('click', e))\n m.on('moveend', () => {\n const v = currentView(m)\n emit('update:center', v.center)\n emit('update:zoom', v.zoom)\n emit('update:bearing', v.bearing)\n emit('update:pitch', v.pitch)\n const key = persistKey()\n if (key) {\n try { localStorage.setItem(key, JSON.stringify(v)) } catch { /* storage blocked */ }\n }\n })\n m.once('load', () => {\n // The map is shared once its style is loaded: components can add sources and layers right away\n map.value = m\n for (const name of Object.keys(CONTROLS) as ControlName[]) syncControl(name)\n emit('ready', m)\n })\n})\n\n// After the children's unmount hooks (a parent's beforeUnmount runs before theirs): they remove their layers, markers\n// and controls from a map that still exists\nonUnmounted(() => {\n destroyed = true\n map.value?.remove()\n map.value = undefined\n})\n\n// ── v-model ────────────────────────────────────────────────────────────────────────────────────\n// Compared by value: an inline `:center=\"[lng, lat]\"` is a new array on every parent render\n\nconst near = (a: number, b: number) => Math.abs(a - b) < 1e-9\nwatch(() => props.center?.join(','), () => {\n const m = map.value\n if (!m || !props.center) return\n const c = m.getCenter()\n if (!near(c.lng, props.center[0]) || !near(c.lat, props.center[1])) m.jumpTo({ center: props.center })\n})\nwatch(() => props.zoom, (zoom) => {\n if (map.value && zoom !== undefined && !near(map.value.getZoom(), zoom)) map.value.jumpTo({ zoom })\n})\nwatch(() => props.bearing, (bearing) => {\n if (map.value && bearing !== undefined && !near(map.value.getBearing(), bearing)) map.value.jumpTo({ bearing })\n})\nwatch(() => props.pitch, (pitch) => {\n if (map.value && pitch !== undefined && !near(map.value.getPitch(), pitch)) map.value.jumpTo({ pitch })\n})\nwatch(() => props.adapter, () => { if (map.value) readModel(map.value) })\n// A full reload (no diff): style.load fires, and components re-add whatever didn't come along\nwatch(() => props.mapStyle, (style) => map.value?.setStyle(style, {\n diff: false,\n transformStyle: (previous, next) => {\n const own = ownIds ?? styleIds(undefined)\n ownIds = styleIds(next)\n const keep = props.keepLayers\n let result = keep === false ? next : carryRuntimeLayers(previous, next, own, typeof keep === 'function' ? keep : undefined)\n if (props.transformStyle) result = props.transformStyle(previous, result)\n return result\n },\n}))\n\ndefineExpose({\n /** The MapLibre map, once loaded */\n map,\n /** What the components inside it share: pass the `MMap` (or this) as `map` to `MMapLayers`, `useMap()`… outside it */\n context,\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"m3-map relative overflow-hidden\"\n @pointerover=\"onTipOver\"\n @pointerout=\"onTipOut\"\n @pointerdown=\"hideTip\"\n @focusin=\"onTipFocus\"\n @focusout=\"hideTip\"\n >\n <!-- Sized, not positioned: MapLibre's CSS makes it position: relative (.maplibregl-map), which would undo absolute -->\n <div ref=\"container\" class=\"h-full w-full\" />\n <!-- Before the slot: added to its corner first, so it stays at the corner's edge -->\n <MMapAttribution v-if=\"map && attribution\" :position=\"attribution === true ? 'bottom-right' : attribution\" />\n <slot v-if=\"map\" />\n <Transition\n enter-active-class=\"transition-opacity duration-150\"\n enter-from-class=\"opacity-0\"\n leave-active-class=\"transition-opacity duration-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"tip\"\n role=\"tooltip\"\n class=\"pointer-events-none absolute z-10 min-h-6 max-w-[200px] -translate-y-1/2 rounded bg-inverse-surface px-2 py-1 text-body-small whitespace-nowrap text-inverse-on-surface\"\n :class=\"tip.left ? '-translate-x-full' : ''\"\n :style=\"{ left: `${tip.x}px`, top: `${tip.y}px` }\"\n >\n {{ tip.text }}\n </div>\n </Transition>\n </div>\n</template>\n\n<style>\n/* The app's typeface, not MapLibre's Helvetica (attribution, scale, popups) */\n.m3-map .maplibregl-map {\n font: inherit;\n}\n\n/* MapLibre's controls, popups and markers in M3: the theme's colors (they follow palette and dark mode), Material\n Symbols icons instead of MapLibre's fixed-color SVGs, M3 shapes and elevation. Scoped to .m3-map. */\n.m3-map .maplibregl-ctrl-group {\n background: var(--color-surface-container-high);\n border-radius: 12px;\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n}\n.m3-map .maplibregl-ctrl-group:not(:empty) {\n box-shadow: var(--shadow-elevation-2);\n}\n/* MMapControl: switching group on or off, or expanding into its panel, fades the surface instead of snapping */\n.m3-map .m3-map-control {\n transition: background-color 200ms, box-shadow 200ms, border-radius 200ms;\n}\n.m3-map .m3-map-control-panel {\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n border-radius: 16px;\n box-shadow: var(--shadow-elevation-2);\n}\n.m3-map .m3-map-control-panel-in {\n animation: m3-map-control-in 200ms 60ms both;\n}\n@keyframes m3-map-control-in {\n from { opacity: 0; }\n}\n@media (prefers-reduced-motion: reduce) {\n .m3-map .m3-map-control-panel-in { animation: none; }\n}\n.m3-map .maplibregl-ctrl-group button {\n width: 40px;\n height: 40px;\n color: var(--color-on-surface-variant);\n}\n.m3-map .maplibregl-ctrl-group button + button {\n border-top: 1px solid var(--color-outline-variant);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):active {\n background-color: color-mix(in srgb, var(--color-on-surface) 12%, transparent);\n}\n.m3-map .maplibregl-ctrl-group button[aria-pressed='true'] {\n background-color: var(--color-primary-container);\n color: var(--color-on-primary-container);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:disabled {\n color: color-mix(in srgb, var(--color-on-surface) 38%, transparent);\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n background-image: none !important;\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon::before {\n font-family: 'Material Symbols Outlined';\n font-size: 20px;\n line-height: 1;\n font-feature-settings: 'liga';\n -webkit-font-smoothing: antialiased;\n}\n.m3-map .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before { content: 'add'; }\n.m3-map .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before { content: 'remove'; }\n.m3-map .maplibregl-ctrl-compass .maplibregl-ctrl-icon::before { content: 'navigation'; }\n.m3-map .maplibregl-ctrl-geolocate .maplibregl-ctrl-icon::before { content: 'my_location'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting {\n color: var(--color-primary);\n}\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon::before { content: 'location_searching'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error {\n color: var(--color-error);\n}\n.m3-map .maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon::before { content: 'location_disabled'; }\n.m3-map .maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon::before { content: 'fullscreen'; }\n.m3-map .maplibregl-ctrl-shrink .maplibregl-ctrl-icon::before { content: 'fullscreen_exit'; }\n\n/* Attribution (_MMapAttribution): a round icon button that opens into a pill with the credits. The surface is the\n control itself, so MMapControl's size spring reveals the text; the row keeps its own width (max-content, capped at\n the map's) so the text doesn't reflow while the control's size animates. */\n.m3-map .m3-map-attrib {\n border-radius: 16px;\n background: var(--color-surface-container-high);\n box-shadow: var(--shadow-elevation-2);\n color: var(--color-on-surface-variant);\n}\n.m3-map .m3-map-attrib-row {\n display: flex;\n align-items: center;\n width: max-content;\n}\n.m3-map .m3-map-attrib-button {\n flex: none;\n display: grid;\n place-items: center;\n width: 32px;\n height: 32px;\n border-radius: 16px;\n color: var(--color-on-surface-variant);\n cursor: pointer;\n transition: background-color 150ms, color 150ms;\n}\n.m3-map .m3-map-attrib-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .m3-map-attrib-button:focus-visible {\n outline: none;\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .m3-map-attrib-open .m3-map-attrib-button {\n color: var(--color-primary);\n}\n.m3-map .m3-map-attrib-text {\n min-width: 0;\n padding-block: 8px;\n font-size: 12px;\n line-height: 16px;\n letter-spacing: 0.4px;\n animation: m3-map-control-in 200ms 60ms both;\n}\n.m3-map .m3-map-attrib-text a {\n color: var(--color-on-surface);\n text-decoration: none;\n}\n.m3-map .m3-map-attrib-text a:hover {\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.m3-map .maplibregl-ctrl-scale {\n background: color-mix(in srgb, var(--color-surface-container-high) 85%, transparent);\n border-color: var(--color-outline);\n color: var(--color-on-surface-variant);\n font-size: 11px;\n}\n\n/* Popups: an M3 surface (elevation 2, 16px corners) with a matching tip */\n.m3-map .maplibregl-popup-content {\n padding: 12px 16px;\n border-radius: 16px;\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n font: inherit;\n font-size: var(--text-body-medium);\n line-height: var(--text-body-medium--line-height);\n}\n.m3-map .maplibregl-popup-anchor-top .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {\n border-bottom-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-bottom .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {\n border-top-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-left .maplibregl-popup-tip {\n border-right-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-right .maplibregl-popup-tip {\n border-left-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-close-button {\n top: 6px;\n right: 6px;\n width: 28px;\n height: 28px;\n border-radius: 14px;\n color: var(--color-on-surface-variant);\n font-size: 18px;\n line-height: 1;\n}\n.m3-map .maplibregl-popup-close-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n\n/* The default marker takes the theme's primary (its SVG is drawn in currentColor) */\n.m3-map .m3-map-marker--default {\n color: var(--color-primary);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * A MapLibre GL map, for any style: a style URL (from an MVT server like mvt-rs, MapTiler, OpenFreeMap…) or a style\n * object. Its controls take the M3 look and the app's locale, the view can be a v-model and remembered between visits,\n * and markers, popups, GeoJSON layers and your own controls go inside it as components. For anything else, the\n * MapLibre map itself is the `ready` event's argument and the `map` of `useMap()` in components placed inside.\n * Available from the `/map` entry point; needs `maplibre-gl` installed and its CSS imported\n * (`maplibre-gl/dist/maplibre-gl.css`). Give it a height. Server-side rendering renders the empty container: MapLibre\n * loads in the browser.\n *\n * @slot default Map components (`MMapMarker`, `MMapPopup`, `MMapGeoJson`, `MMapControl`) and anything to show over\n * the map, rendered once the map exists\n * @event ready The map loaded (with its style), with the MapLibre `Map`\n * @event click A click on the map (MapLibre's `MapMouseEvent`: `lngLat`, `point`)\n * @event update:center The view moved (on `moveend`): `[lng, lat]`\n * @event update:zoom The zoom changed (on `moveend`)\n * @event update:bearing The rotation changed (on `moveend`)\n * @event update:pitch The tilt changed (on `moveend`)\n */\nimport { markRaw, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapAttribution from './_MMapAttribution.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { MAP_KEY, type MapContext, type MaplibreModule } from '../composables/useMap'\nimport { createLayerState, readLayerState } from '../composables/useMapLayers'\nimport type { MapAdapter, MapLayerModel } from '../composables/mapAdapters'\nimport { carryRuntimeLayers, styleIds, type StyleIds } from '../composables/_mapStyle'\n\nexport type MapControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The map's style: a style JSON URL or a style object (MapLibre's `StyleSpecification`). Changing it reloads the\n * style, keeping what was added at runtime (see `keepLayers`)\n */\n mapStyle: string | Maplibre.StyleSpecification\n /**\n * What happens to the sources and layers added at runtime (with `useMap()`, or by `MMapGeoJson`, `MMapMeasure`…)\n * when `mapStyle` changes: `true` carries them into the new style, on top of its layers; `false` drops them, as\n * MapLibre does; a function picks the layers to carry (their sources come along)\n */\n keepLayers?: boolean | ((layer: Maplibre.LayerSpecification) => boolean)\n /**\n * MapLibre's `transformStyle` for a `mapStyle` change, run after `keepLayers`: edit the next style before it\n * loads (copy a layer's paint over, add a sprite…)\n */\n transformStyle?: Maplibre.TransformStyleFunction\n /** `[lng, lat]` (v-model). When left out, the style's (or the remembered view's) */\n center?: [number, number]\n /** Zoom level (v-model) */\n zoom?: number\n /** Rotation in degrees (v-model) */\n bearing?: number\n /** Tilt in degrees (v-model) */\n pitch?: number\n /**\n * Remember the view (center, zoom, bearing, pitch) in localStorage and start from it on the next visit: `true`\n * under `m3-map-view`, or your own key (one per map)\n */\n persist?: boolean | string\n /** Zoom and compass buttons: `false`, or a corner (`true` is top-right) */\n navigation?: boolean | MapControlPosition\n /** A button that centers the map on the user's location and follows it: `false`, or a corner (`true` is top-right) */\n geolocate?: boolean | MapControlPosition\n /** A fullscreen button: `false`, or a corner (`true` is top-right) */\n fullscreen?: boolean | MapControlPosition\n /** A metric scale bar: `false`, or a corner (`true` is bottom-left) */\n scale?: boolean | MapControlPosition\n /** The credits of the style's sources, an info button that opens into a pill: `false`, or a corner (`true` is bottom-right). Most tile providers require it */\n attribution?: boolean | MapControlPosition\n /** Anything else for MapLibre's `Map` constructor (`maxZoom`, `maxBounds`, `cooperativeGestures`…) */\n options?: Partial<Omit<Maplibre.MapOptions, 'container' | 'style'>>\n /**\n * Reads the style's conventions (layer names, groups, base layers, what to identify or show on hover) for\n * `MMapLayers`, `MMapBaseLayers`, `MMapIdentify` and `MMapHover`: `genericAdapter`, `orvianAdapter()`, or your own\n */\n adapter?: MapAdapter\n }>(),\n {\n persist: false,\n keepLayers: true,\n navigation: true,\n geolocate: false,\n fullscreen: false,\n scale: true,\n attribution: true,\n },\n)\n\nconst emit = defineEmits<{\n ready: [map: Maplibre.Map]\n click: [event: Maplibre.MapMouseEvent]\n 'update:center': [center: [number, number]]\n 'update:zoom': [zoom: number]\n 'update:bearing': [bearing: number]\n 'update:pitch': [pitch: number]\n}>()\n\nconst root = ref<HTMLElement>()\nconst container = ref<HTMLElement>()\nconst map = shallowRef<Maplibre.Map>()\nconst maplibre = shallowRef<MaplibreModule>()\nconst styleVersion = ref(0)\n// The sources and layers the current style came with (the rest were added at runtime: keepLayers)\nlet ownIds: StyleIds | undefined\nconst model = shallowRef<MapLayerModel>()\nconst layerState = createLayerState()\nconst activeTool = ref<string | null>(null)\nconst context: MapContext = { map, maplibre, styleVersion, model, layerState, activeTool }\nprovide(MAP_KEY, context)\n\n/** The adapter's model of the current style, and the layers' visibility and opacity in it. */\nfunction readModel(m: Maplibre.Map) {\n model.value = props.adapter\n ? props.adapter(m.getStyle(), { styleUrl: typeof props.mapStyle === 'string' ? props.mapStyle : undefined })\n : undefined\n readLayerState(layerState, m, model.value)\n}\n\nconst t = useLocale()\n\n// ── Remembered view ────────────────────────────────────────────────────────────────────────────\n\ninterface View { center: [number, number]; zoom: number; bearing: number; pitch: number }\nconst persistKey = () => (typeof props.persist === 'string' ? props.persist : props.persist ? 'm3-map-view' : null)\n\nfunction readView(): Partial<View> {\n const key = persistKey()\n if (!key) return {}\n try {\n const view = JSON.parse(localStorage.getItem(key) ?? 'null') as Partial<View> | null\n return view && typeof view === 'object' ? view : {}\n } catch {\n return {}\n }\n}\n\nfunction currentView(m: Maplibre.Map): View {\n const c = m.getCenter()\n return { center: [c.lng, c.lat], zoom: m.getZoom(), bearing: m.getBearing(), pitch: m.getPitch() }\n}\n\n// ── Controls ───────────────────────────────────────────────────────────────────────────────────\n\n// The attribution is a component of ours (_MMapAttribution, in the template), not MapLibre's control\ntype ControlName = 'navigation' | 'geolocate' | 'fullscreen' | 'scale'\nconst CONTROLS: Record<ControlName, { corner: MapControlPosition; create: (ml: MaplibreModule) => Maplibre.IControl }> = {\n navigation: { corner: 'top-right', create: (ml) => new ml.NavigationControl() },\n geolocate: {\n corner: 'top-right',\n create: (ml) => new ml.GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true }),\n },\n fullscreen: { corner: 'top-right', create: (ml) => new ml.FullscreenControl({ container: root.value }) },\n scale: { corner: 'bottom-left', create: (ml) => new ml.ScaleControl({ maxWidth: 100, unit: 'metric' }) },\n}\nconst added = new Map<ControlName, Maplibre.IControl>()\n\nfunction syncControl(name: ControlName) {\n const m = map.value\n const ml = maplibre.value\n if (!m || !ml) return\n const old = added.get(name)\n if (old) {\n m.removeControl(old)\n added.delete(name)\n }\n const setting = props[name]\n if (!setting) return\n const control = CONTROLS[name].create(ml)\n m.addControl(control, setting === true ? CONTROLS[name].corner : setting)\n added.set(name, control)\n}\n\nfor (const name of Object.keys(CONTROLS) as ControlName[]) watch(() => props[name], () => syncControl(name))\n\n// ── Map ────────────────────────────────────────────────────────────────────────────────────────\n\n/** MapLibre's UI strings, from the app's M3 locale. */\nfunction mapLocale() {\n return {\n 'AttributionControl.ToggleAttribution': t.mapToggleAttribution,\n 'AttributionControl.MapFeedback': t.mapFeedback,\n 'FullscreenControl.Enter': t.mapEnterFullscreen,\n 'FullscreenControl.Exit': t.mapExitFullscreen,\n 'GeolocateControl.FindMyLocation': t.mapFindMyLocation,\n 'GeolocateControl.LocationNotAvailable': t.mapLocationNotAvailable,\n 'Map.Title': t.mapTitle,\n 'Marker.Title': t.mapMarker,\n 'NavigationControl.ResetBearing': t.mapResetBearing,\n 'NavigationControl.ZoomIn': t.mapZoomIn,\n 'NavigationControl.ZoomOut': t.mapZoomOut,\n 'Popup.Close': t.close,\n 'CooperativeGesturesHandler.WindowsHelpText': t.mapCtrlScroll,\n 'CooperativeGesturesHandler.MacHelpText': t.mapCmdScroll,\n 'CooperativeGesturesHandler.MobileHelpText': t.mapTwoFingers,\n }\n}\n\n// ── Control tooltips ───────────────────────────────────────────────────────────────────────────\n// MapLibre's buttons (and yours, in MMapControl) carry a `title`, which the browser shows as its own tooltip: it's\n// moved to data-m3-tip (and aria-label when there's none) and shown as an M3 plain tooltip, inside the map so it's\n// there in fullscreen too\n\nconst TIP_DELAY = 600 // MTooltip's\nconst tip = ref<{ text: string; x: number; y: number; left: boolean } | null>(null)\nlet tipTimer: ReturnType<typeof setTimeout> | undefined\nlet tipObserver: MutationObserver | undefined\n\nfunction adoptTitle(el: Element) {\n const title = el.getAttribute('title')\n if (!title || !el.closest('.maplibregl-ctrl')) return\n el.setAttribute('data-m3-tip', title)\n if (!el.hasAttribute('aria-label')) el.setAttribute('aria-label', title)\n el.removeAttribute('title')\n}\n\nfunction showTip(el: HTMLElement) {\n const text = el.getAttribute('data-m3-tip')\n const box = root.value?.getBoundingClientRect()\n if (!text || !box) return\n const r = el.getBoundingClientRect()\n // Toward the inside of the map: left of a control on the right half, right of one on the left\n const left = r.left + r.width / 2 > box.left + box.width / 2\n tip.value = { text, left, x: (left ? r.left - 8 : r.right + 8) - box.left, y: r.top + r.height / 2 - box.top }\n}\n\nfunction hideTip() {\n clearTimeout(tipTimer)\n tip.value = null\n}\n\nconst tipTarget = (e: Event) => (e.target as Element | null)?.closest?.<HTMLElement>('.maplibregl-ctrl [data-m3-tip]') ?? null\n\nfunction onTipOver(e: PointerEvent) {\n const el = tipTarget(e)\n if (!el || e.pointerType === 'touch') return\n clearTimeout(tipTimer)\n tipTimer = setTimeout(() => showTip(el), TIP_DELAY)\n}\nfunction onTipOut(e: PointerEvent) {\n const el = tipTarget(e)\n if (el && !el.contains(e.relatedTarget as Node | null)) hideTip()\n}\nfunction onTipFocus(e: FocusEvent) {\n const el = tipTarget(e)\n if (el?.matches(':focus-visible')) showTip(el)\n}\n\nonMounted(() => {\n const el = root.value\n if (!el) return\n el.querySelectorAll('[title]').forEach(adoptTitle)\n tipObserver = new MutationObserver((records) => {\n for (const r of records) {\n if (r.type === 'attributes') adoptTitle(r.target as Element)\n else r.addedNodes.forEach((n) => {\n if (!(n instanceof Element)) return\n adoptTitle(n)\n n.querySelectorAll('[title]').forEach(adoptTitle)\n })\n }\n })\n tipObserver.observe(el, { subtree: true, childList: true, attributes: true, attributeFilter: ['title'] })\n})\n\nonBeforeUnmount(() => {\n tipObserver?.disconnect()\n clearTimeout(tipTimer)\n})\n\nlet destroyed = false\n\nonMounted(async () => {\n // maplibre-gl ships a UMD build: depending on the bundler its classes are on the namespace or on `default`\n const mod = await import('maplibre-gl')\n const ml = ('Map' in mod ? mod : (mod as { default: MaplibreModule }).default) as MaplibreModule\n if (destroyed || !container.value) return\n const saved = readView()\n const view = {\n center: saved.center ?? props.center,\n zoom: saved.zoom ?? props.zoom,\n bearing: saved.bearing ?? props.bearing,\n pitch: saved.pitch ?? props.pitch,\n }\n const m = markRaw(new ml.Map({\n container: container.value,\n style: props.mapStyle,\n attributionControl: false,\n locale: mapLocale(),\n // Only what's set, so a style's own center and zoom apply otherwise\n ...Object.fromEntries(Object.entries(view).filter(([, v]) => v !== undefined)),\n ...props.options,\n }))\n maplibre.value = ml\n\n m.on('style.load', () => {\n // The first style's own ids; a later style's are taken in transformStyle, before runtime layers join it\n if (!ownIds) ownIds = styleIds(m.getStyle())\n readModel(m)\n styleVersion.value++\n })\n m.on('click', (e) => emit('click', e))\n m.on('moveend', () => {\n const v = currentView(m)\n emit('update:center', v.center)\n emit('update:zoom', v.zoom)\n emit('update:bearing', v.bearing)\n emit('update:pitch', v.pitch)\n const key = persistKey()\n if (key) {\n try { localStorage.setItem(key, JSON.stringify(v)) } catch { /* storage blocked */ }\n }\n })\n m.once('load', () => {\n // The map is shared once its style is loaded: components can add sources and layers right away\n map.value = m\n for (const name of Object.keys(CONTROLS) as ControlName[]) syncControl(name)\n emit('ready', m)\n })\n})\n\n// After the children's unmount hooks (a parent's beforeUnmount runs before theirs): they remove their layers, markers\n// and controls from a map that still exists\nonUnmounted(() => {\n destroyed = true\n map.value?.remove()\n map.value = undefined\n})\n\n// ── v-model ────────────────────────────────────────────────────────────────────────────────────\n// Compared by value: an inline `:center=\"[lng, lat]\"` is a new array on every parent render\n\nconst near = (a: number, b: number) => Math.abs(a - b) < 1e-9\nwatch(() => props.center?.join(','), () => {\n const m = map.value\n if (!m || !props.center) return\n const c = m.getCenter()\n if (!near(c.lng, props.center[0]) || !near(c.lat, props.center[1])) m.jumpTo({ center: props.center })\n})\nwatch(() => props.zoom, (zoom) => {\n if (map.value && zoom !== undefined && !near(map.value.getZoom(), zoom)) map.value.jumpTo({ zoom })\n})\nwatch(() => props.bearing, (bearing) => {\n if (map.value && bearing !== undefined && !near(map.value.getBearing(), bearing)) map.value.jumpTo({ bearing })\n})\nwatch(() => props.pitch, (pitch) => {\n if (map.value && pitch !== undefined && !near(map.value.getPitch(), pitch)) map.value.jumpTo({ pitch })\n})\nwatch(() => props.adapter, () => { if (map.value) readModel(map.value) })\n// A full reload (no diff): style.load fires, and components re-add whatever didn't come along\nwatch(() => props.mapStyle, (style) => map.value?.setStyle(style, {\n diff: false,\n transformStyle: (previous, next) => {\n const own = ownIds ?? styleIds(undefined)\n ownIds = styleIds(next)\n const keep = props.keepLayers\n let result = keep === false ? next : carryRuntimeLayers(previous, next, own, typeof keep === 'function' ? keep : undefined)\n if (props.transformStyle) result = props.transformStyle(previous, result)\n return result\n },\n}))\n\ndefineExpose({\n /** The MapLibre map, once loaded */\n map,\n /** What the components inside it share: pass the `MMap` (or this) as `map` to `MMapLayers`, `useMap()`… outside it */\n context,\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"m3-map relative overflow-hidden\"\n @pointerover=\"onTipOver\"\n @pointerout=\"onTipOut\"\n @pointerdown=\"hideTip\"\n @focusin=\"onTipFocus\"\n @focusout=\"hideTip\"\n >\n <!-- Sized, not positioned: MapLibre's CSS makes it position: relative (.maplibregl-map), which would undo absolute -->\n <div ref=\"container\" class=\"h-full w-full\" />\n <!-- Before the slot: added to its corner first, so it stays at the corner's edge -->\n <MMapAttribution v-if=\"map && attribution\" :position=\"attribution === true ? 'bottom-right' : attribution\" />\n <slot v-if=\"map\" />\n <Transition\n enter-active-class=\"transition-opacity duration-150\"\n enter-from-class=\"opacity-0\"\n leave-active-class=\"transition-opacity duration-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"tip\"\n role=\"tooltip\"\n class=\"pointer-events-none absolute z-10 min-h-6 max-w-[200px] -translate-y-1/2 rounded bg-inverse-surface px-2 py-1 text-body-small whitespace-nowrap text-inverse-on-surface\"\n :class=\"tip.left ? '-translate-x-full' : ''\"\n :style=\"{ left: `${tip.x}px`, top: `${tip.y}px` }\"\n >\n {{ tip.text }}\n </div>\n </Transition>\n </div>\n</template>\n\n<style>\n/* The app's typeface, not MapLibre's Helvetica (attribution, scale, popups) */\n.m3-map .maplibregl-map {\n font: inherit;\n}\n\n/* MapLibre's controls, popups and markers in M3: the theme's colors (they follow palette and dark mode), Material\n Symbols icons instead of MapLibre's fixed-color SVGs, M3 shapes and elevation. Scoped to .m3-map. */\n.m3-map .maplibregl-ctrl-group {\n background: var(--color-surface-container-high);\n border-radius: 12px;\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n}\n.m3-map .maplibregl-ctrl-group:not(:empty) {\n box-shadow: var(--shadow-elevation-2);\n}\n/* MMapControl: switching group on or off, or expanding into its panel, fades the surface instead of snapping */\n.m3-map .m3-map-control {\n transition: background-color 200ms, box-shadow 200ms, border-radius 200ms;\n}\n.m3-map .m3-map-control-panel {\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n border-radius: 16px;\n box-shadow: var(--shadow-elevation-2);\n}\n.m3-map .m3-map-control-panel-in {\n animation: m3-map-control-in 200ms 60ms both;\n}\n@keyframes m3-map-control-in {\n from { opacity: 0; }\n}\n@media (prefers-reduced-motion: reduce) {\n .m3-map .m3-map-control-panel-in { animation: none; }\n}\n.m3-map .maplibregl-ctrl-group button {\n width: 40px;\n height: 40px;\n color: var(--color-on-surface-variant);\n}\n.m3-map .maplibregl-ctrl-group button + button {\n border-top: 1px solid var(--color-outline-variant);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):active {\n background-color: color-mix(in srgb, var(--color-on-surface) 12%, transparent);\n}\n.m3-map .maplibregl-ctrl-group button[aria-pressed='true'] {\n background-color: var(--color-primary-container);\n color: var(--color-on-primary-container);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:disabled {\n color: color-mix(in srgb, var(--color-on-surface) 38%, transparent);\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n background-image: none !important;\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon::before {\n font-family: 'Material Symbols Outlined';\n font-size: 20px;\n line-height: 1;\n font-feature-settings: 'liga';\n -webkit-font-smoothing: antialiased;\n}\n.m3-map .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before { content: 'add'; }\n.m3-map .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before { content: 'remove'; }\n.m3-map .maplibregl-ctrl-compass .maplibregl-ctrl-icon::before { content: 'navigation'; }\n.m3-map .maplibregl-ctrl-geolocate .maplibregl-ctrl-icon::before { content: 'my_location'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting {\n color: var(--color-primary);\n}\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon::before { content: 'location_searching'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error {\n color: var(--color-error);\n}\n.m3-map .maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon::before { content: 'location_disabled'; }\n.m3-map .maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon::before { content: 'fullscreen'; }\n.m3-map .maplibregl-ctrl-shrink .maplibregl-ctrl-icon::before { content: 'fullscreen_exit'; }\n\n/* Attribution (_MMapAttribution): a round icon button that opens into a pill with the credits. The surface is the\n control itself, so MMapControl's size spring reveals the text; the row keeps its own width (max-content, capped at\n the map's) so the text doesn't reflow while the control's size animates. */\n.m3-map .m3-map-attrib {\n border-radius: 16px;\n background: var(--color-surface-container-high);\n box-shadow: var(--shadow-elevation-2);\n color: var(--color-on-surface-variant);\n}\n.m3-map .m3-map-attrib-row {\n display: flex;\n align-items: center;\n width: max-content;\n}\n.m3-map .m3-map-attrib-button {\n flex: none;\n display: grid;\n place-items: center;\n width: 32px;\n height: 32px;\n border-radius: 16px;\n color: var(--color-on-surface-variant);\n cursor: pointer;\n transition: background-color 150ms, color 150ms;\n}\n.m3-map .m3-map-attrib-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .m3-map-attrib-button:focus-visible {\n outline: none;\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .m3-map-attrib-open .m3-map-attrib-button {\n color: var(--color-primary);\n}\n.m3-map .m3-map-attrib-text {\n min-width: 0;\n padding-block: 8px;\n font-size: 12px;\n line-height: 16px;\n letter-spacing: 0.4px;\n animation: m3-map-control-in 200ms 60ms both;\n}\n.m3-map .m3-map-attrib-text a {\n color: var(--color-on-surface);\n text-decoration: none;\n}\n.m3-map .m3-map-attrib-text a:hover {\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.m3-map .maplibregl-ctrl-scale {\n background: color-mix(in srgb, var(--color-surface-container-high) 85%, transparent);\n border-color: var(--color-outline);\n color: var(--color-on-surface-variant);\n font-size: 11px;\n}\n\n/* Popups: an M3 surface (elevation 2, 16px corners) with a matching tip */\n.m3-map .maplibregl-popup-content {\n padding: 12px 16px;\n border-radius: 16px;\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n font: inherit;\n font-size: var(--text-body-medium);\n line-height: var(--text-body-medium--line-height);\n}\n.m3-map .maplibregl-popup-anchor-top .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {\n border-bottom-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-bottom .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {\n border-top-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-left .maplibregl-popup-tip {\n border-right-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-right .maplibregl-popup-tip {\n border-left-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-close-button {\n top: 6px;\n right: 6px;\n width: 28px;\n height: 28px;\n border-radius: 14px;\n color: var(--color-on-surface-variant);\n font-size: 18px;\n line-height: 1;\n}\n.m3-map .maplibregl-popup-close-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n\n/* The default marker takes the theme's primary (its SVG is drawn in currentColor) */\n.m3-map .m3-map-marker--default {\n color: var(--color-primary);\n}\n</style>\n","// Internal (not exported): MapLibre's default marker pin. Its SVG is 41px tall with the tip at the center of the\n// shadow ellipse below it (y ≈ 34.8), so MapLibre places it by its center, offset [0, -14], and gives a popup it\n// opens an offset per side (Marker.setPopup) so the popup meets the pin wherever it opens. Passing the pin an\n// anchor of 'bottom' (plus that default offset) put the tip about 20px above its point.\nimport type * as Maplibre from 'maplibre-gl'\n\nconst HEIGHT = 41 - 5.8 / 2\nconst RADIUS = 13.5\nconst LINEAR = RADIUS / Math.SQRT2\n\n/** The default pin's offset with its default (center) anchor */\nexport const PIN_OFFSET: [number, number] = [0, -14]\n\n/** Offsets for a popup at a pin's point, per side, as MapLibre's Marker.setPopup gives them */\nexport const PIN_POPUP_OFFSET: Record<Maplibre.PositionAnchor, [number, number]> = {\n center: [0, 0],\n top: [0, 0],\n 'top-left': [0, 0],\n 'top-right': [0, 0],\n bottom: [0, -HEIGHT],\n 'bottom-left': [LINEAR, (HEIGHT - RADIUS + LINEAR) * -1],\n 'bottom-right': [-LINEAR, (HEIGHT - RADIUS + LINEAR) * -1],\n left: [RADIUS, (HEIGHT - RADIUS) * -1],\n right: [-RADIUS, (HEIGHT - RADIUS) * -1],\n}\n","<script setup lang=\"ts\">\n/**\n * A marker on an `MMap`, at `lngLat`: MapLibre's pin in the theme's primary (or `color`), or your own content from the\n * default slot. With `draggable`, `lngLat` is a v-model. Content in `#popup` opens in a popup when the marker is\n * clicked. Available from the `/map` entry point.\n *\n * @slot default The marker itself, instead of the pin (any element, anchored by `anchor`)\n * @slot popup Content of a popup that opens when the marker is clicked\n * @event update:lngLat Dragged to a new position (`draggable`): `[lng, lat]`\n * @event click The marker was clicked\n */\nimport { onBeforeUnmount, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { PIN_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` (v-model with `draggable`) */\n lngLat: [number, number]\n /** The pin's color (any CSS color). Defaults to the theme's primary; ignored with custom content */\n color?: string\n /** Let the user drag it */\n draggable?: boolean\n /**\n * Which part of the marker sits on `lngLat`. By default the pin's tip (MapLibre's placement: its center, offset\n * `[0, -14]`), and the center of custom content\n */\n anchor?: Maplibre.PositionAnchor\n /** Offset in pixels, `[x, y]`. The pin's default is MapLibre's `[0, -14]`, which puts its tip on `lngLat` */\n offset?: [number, number]\n /** Rotation in degrees */\n rotation?: number\n }>(),\n { draggable: false, rotation: 0 },\n)\n\nconst emit = defineEmits<{\n 'update:lngLat': [lngLat: [number, number]]\n click: [event: MouseEvent]\n}>()\n\nconst slots = useSlots()\nconst content = ref<HTMLElement>()\nconst popupContent = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet marker: Maplibre.Marker | undefined\nlet custom = false\n\nonReady((map, ml) => {\n custom = !!slots.default && !!content.value\n marker = new ml.Marker({\n ...(custom ? { element: content.value } : { color: props.color ?? 'currentColor' }),\n draggable: props.draggable,\n // Left out for the pin unless given: MapLibre's own placement puts its tip on the point (see _mapPin.ts)\n ...(props.anchor ? { anchor: props.anchor } : custom ? { anchor: 'center' as const } : {}),\n ...(props.offset ? { offset: props.offset } : {}),\n rotation: props.rotation,\n })\n if (!custom && !props.color) marker.getElement().classList.add('m3-map-marker--default')\n marker.setLngLat(props.lngLat).addTo(map)\n marker.getElement().addEventListener('click', onClick)\n marker.on('dragend', () => {\n const { lng, lat } = marker!.getLngLat()\n emit('update:lngLat', [lng, lat])\n })\n if (slots.popup && popupContent.value) {\n // The pin's popup gets MapLibre's per-side offsets, which it only applies when `offset` isn't set at all\n marker.setPopup(new ml.Popup({ ...(custom ? { offset: 16 } : {}), maxWidth: '320px' }).setDOMContent(popupContent.value))\n }\n})\n\nfunction onClick(e: MouseEvent) {\n emit('click', e)\n}\n\n// Compared by value: an inline `:lng-lat=\"[lng, lat]\"` is a new array on every parent render\nwatch(() => props.lngLat.join(','), () => marker?.setLngLat(props.lngLat))\nwatch(() => props.draggable, (draggable) => marker?.setDraggable(draggable))\nwatch(() => props.rotation, (rotation) => marker?.setRotation(rotation))\nwatch(() => props.offset?.join(','), () => marker?.setOffset(props.offset ?? (custom ? [0, 0] : PIN_OFFSET)))\n\nonBeforeUnmount(() => {\n marker?.getElement().removeEventListener('click', onClick)\n marker?.getPopup()?.remove()\n marker?.remove()\n})\n\ndefineExpose({\n /** The MapLibre marker */\n marker: () => marker,\n})\n</script>\n\n<template>\n <!-- Rendered here, then moved into the map by MapLibre (the marker element and the popup's content) -->\n <div class=\"hidden\">\n <div v-if=\"$slots.default\" ref=\"content\" class=\"m3-map-marker\" v-bind=\"$attrs\">\n <slot />\n </div>\n <div v-if=\"$slots.popup\" ref=\"popupContent\">\n <slot name=\"popup\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A marker on an `MMap`, at `lngLat`: MapLibre's pin in the theme's primary (or `color`), or your own content from the\n * default slot. With `draggable`, `lngLat` is a v-model. Content in `#popup` opens in a popup when the marker is\n * clicked. Available from the `/map` entry point.\n *\n * @slot default The marker itself, instead of the pin (any element, anchored by `anchor`)\n * @slot popup Content of a popup that opens when the marker is clicked\n * @event update:lngLat Dragged to a new position (`draggable`): `[lng, lat]`\n * @event click The marker was clicked\n */\nimport { onBeforeUnmount, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { PIN_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` (v-model with `draggable`) */\n lngLat: [number, number]\n /** The pin's color (any CSS color). Defaults to the theme's primary; ignored with custom content */\n color?: string\n /** Let the user drag it */\n draggable?: boolean\n /**\n * Which part of the marker sits on `lngLat`. By default the pin's tip (MapLibre's placement: its center, offset\n * `[0, -14]`), and the center of custom content\n */\n anchor?: Maplibre.PositionAnchor\n /** Offset in pixels, `[x, y]`. The pin's default is MapLibre's `[0, -14]`, which puts its tip on `lngLat` */\n offset?: [number, number]\n /** Rotation in degrees */\n rotation?: number\n }>(),\n { draggable: false, rotation: 0 },\n)\n\nconst emit = defineEmits<{\n 'update:lngLat': [lngLat: [number, number]]\n click: [event: MouseEvent]\n}>()\n\nconst slots = useSlots()\nconst content = ref<HTMLElement>()\nconst popupContent = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet marker: Maplibre.Marker | undefined\nlet custom = false\n\nonReady((map, ml) => {\n custom = !!slots.default && !!content.value\n marker = new ml.Marker({\n ...(custom ? { element: content.value } : { color: props.color ?? 'currentColor' }),\n draggable: props.draggable,\n // Left out for the pin unless given: MapLibre's own placement puts its tip on the point (see _mapPin.ts)\n ...(props.anchor ? { anchor: props.anchor } : custom ? { anchor: 'center' as const } : {}),\n ...(props.offset ? { offset: props.offset } : {}),\n rotation: props.rotation,\n })\n if (!custom && !props.color) marker.getElement().classList.add('m3-map-marker--default')\n marker.setLngLat(props.lngLat).addTo(map)\n marker.getElement().addEventListener('click', onClick)\n marker.on('dragend', () => {\n const { lng, lat } = marker!.getLngLat()\n emit('update:lngLat', [lng, lat])\n })\n if (slots.popup && popupContent.value) {\n // The pin's popup gets MapLibre's per-side offsets, which it only applies when `offset` isn't set at all\n marker.setPopup(new ml.Popup({ ...(custom ? { offset: 16 } : {}), maxWidth: '320px' }).setDOMContent(popupContent.value))\n }\n})\n\nfunction onClick(e: MouseEvent) {\n emit('click', e)\n}\n\n// Compared by value: an inline `:lng-lat=\"[lng, lat]\"` is a new array on every parent render\nwatch(() => props.lngLat.join(','), () => marker?.setLngLat(props.lngLat))\nwatch(() => props.draggable, (draggable) => marker?.setDraggable(draggable))\nwatch(() => props.rotation, (rotation) => marker?.setRotation(rotation))\nwatch(() => props.offset?.join(','), () => marker?.setOffset(props.offset ?? (custom ? [0, 0] : PIN_OFFSET)))\n\nonBeforeUnmount(() => {\n marker?.getElement().removeEventListener('click', onClick)\n marker?.getPopup()?.remove()\n marker?.remove()\n})\n\ndefineExpose({\n /** The MapLibre marker */\n marker: () => marker,\n})\n</script>\n\n<template>\n <!-- Rendered here, then moved into the map by MapLibre (the marker element and the popup's content) -->\n <div class=\"hidden\">\n <div v-if=\"$slots.default\" ref=\"content\" class=\"m3-map-marker\" v-bind=\"$attrs\">\n <slot />\n </div>\n <div v-if=\"$slots.popup\" ref=\"popupContent\">\n <slot name=\"popup\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A popup on an `MMap` at `lngLat`, shown while `open` (v-model): e.g. what the user clicked on. Its content is the\n * default slot, styled as an M3 surface. For a popup that opens from a marker, use `MMapMarker`'s `#popup` slot.\n * Available from the `/map` entry point.\n *\n * @slot default The popup's content\n * @event update:open Closed by its close button or a click on the map (`closeOnClick`)\n */\nimport { onBeforeUnmount, ref, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` */\n lngLat: [number, number]\n /** Shown (v-model) */\n open?: boolean\n /** Show a close button */\n closeButton?: boolean\n /** Close it when the map is clicked */\n closeOnClick?: boolean\n /** Where the popup sits relative to `lngLat`. By default MapLibre picks the side with room */\n anchor?: Maplibre.PositionAnchor\n /**\n * Offset from `lngLat`: pixels, `[x, y]`, or one per side (`{ bottom: [0, -38], … }`, MapLibre's `Offset`).\n * By default none: its tip touches the point\n */\n offset?: Maplibre.Offset\n /** Maximum width (CSS) */\n maxWidth?: string\n }>(),\n { open: true, closeButton: true, closeOnClick: true, maxWidth: '320px' },\n)\n\nconst emit = defineEmits<{ 'update:open': [open: boolean] }>()\n\nconst content = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet popup: Maplibre.Popup | undefined\nlet map: Maplibre.Map | undefined\n// Closing it from `open` (rather than by the user) mustn't echo back as update:open\nlet closingFromProp = false\n\nfunction show() {\n if (!popup || !map || popup.isOpen()) return\n popup.setLngLat(props.lngLat).addTo(map)\n}\n\nonReady((m, ml) => {\n map = m\n popup = new ml.Popup({\n closeButton: props.closeButton,\n closeOnClick: props.closeOnClick,\n closeOnMove: false,\n anchor: props.anchor,\n ...(props.offset !== undefined ? { offset: props.offset } : {}),\n maxWidth: props.maxWidth,\n focusAfterOpen: false,\n })\n if (content.value) popup.setDOMContent(content.value)\n popup.on('close', () => {\n if (!closingFromProp) emit('update:open', false)\n })\n if (props.open) show()\n})\n\nwatch(() => props.open, (open) => {\n if (open) show()\n else if (popup?.isOpen()) {\n closingFromProp = true\n popup.remove()\n closingFromProp = false\n }\n})\nwatch(() => props.lngLat.join(','), () => popup?.setLngLat(props.lngLat))\nwatch(() => props.maxWidth, (w) => popup?.setMaxWidth(w))\nwatch(() => props.offset, (offset) => popup?.setOffset(offset ?? 0))\n\nonBeforeUnmount(() => {\n closingFromProp = true\n popup?.remove()\n})\n\ndefineExpose({\n /** The MapLibre popup */\n popup: () => popup,\n})\n</script>\n\n<template>\n <!-- Moved into the popup by MapLibre -->\n <div class=\"hidden\">\n <div ref=\"content\" v-bind=\"$attrs\">\n <slot />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A popup on an `MMap` at `lngLat`, shown while `open` (v-model): e.g. what the user clicked on. Its content is the\n * default slot, styled as an M3 surface. For a popup that opens from a marker, use `MMapMarker`'s `#popup` slot.\n * Available from the `/map` entry point.\n *\n * @slot default The popup's content\n * @event update:open Closed by its close button or a click on the map (`closeOnClick`)\n */\nimport { onBeforeUnmount, ref, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` */\n lngLat: [number, number]\n /** Shown (v-model) */\n open?: boolean\n /** Show a close button */\n closeButton?: boolean\n /** Close it when the map is clicked */\n closeOnClick?: boolean\n /** Where the popup sits relative to `lngLat`. By default MapLibre picks the side with room */\n anchor?: Maplibre.PositionAnchor\n /**\n * Offset from `lngLat`: pixels, `[x, y]`, or one per side (`{ bottom: [0, -38], … }`, MapLibre's `Offset`).\n * By default none: its tip touches the point\n */\n offset?: Maplibre.Offset\n /** Maximum width (CSS) */\n maxWidth?: string\n }>(),\n { open: true, closeButton: true, closeOnClick: true, maxWidth: '320px' },\n)\n\nconst emit = defineEmits<{ 'update:open': [open: boolean] }>()\n\nconst content = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet popup: Maplibre.Popup | undefined\nlet map: Maplibre.Map | undefined\n// Closing it from `open` (rather than by the user) mustn't echo back as update:open\nlet closingFromProp = false\n\nfunction show() {\n if (!popup || !map || popup.isOpen()) return\n popup.setLngLat(props.lngLat).addTo(map)\n}\n\nonReady((m, ml) => {\n map = m\n popup = new ml.Popup({\n closeButton: props.closeButton,\n closeOnClick: props.closeOnClick,\n closeOnMove: false,\n anchor: props.anchor,\n ...(props.offset !== undefined ? { offset: props.offset } : {}),\n maxWidth: props.maxWidth,\n focusAfterOpen: false,\n })\n if (content.value) popup.setDOMContent(content.value)\n popup.on('close', () => {\n if (!closingFromProp) emit('update:open', false)\n })\n if (props.open) show()\n})\n\nwatch(() => props.open, (open) => {\n if (open) show()\n else if (popup?.isOpen()) {\n closingFromProp = true\n popup.remove()\n closingFromProp = false\n }\n})\nwatch(() => props.lngLat.join(','), () => popup?.setLngLat(props.lngLat))\nwatch(() => props.maxWidth, (w) => popup?.setMaxWidth(w))\nwatch(() => props.offset, (offset) => popup?.setOffset(offset ?? 0))\n\nonBeforeUnmount(() => {\n closingFromProp = true\n popup?.remove()\n})\n\ndefineExpose({\n /** The MapLibre popup */\n popup: () => popup,\n})\n</script>\n\n<template>\n <!-- Moved into the popup by MapLibre -->\n <div class=\"hidden\">\n <div ref=\"content\" v-bind=\"$attrs\">\n <slot />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * GeoJSON on an `MMap`: a source from `data` (an object, or a URL MapLibre fetches) drawn with `layers`. Without\n * `layers` it draws every geometry in the theme's primary, following palette and dark mode: polygons filled with an\n * outline, lines, and points as circles. Replace `data` (a new object) to update it. It's added again after a style\n * change. Available from the `/map` entry point.\n *\n * @event click A click on one of its features (MapLibre's `MapLayerMouseEvent`: `e.features` holds them)\n */\nimport { computed, onBeforeUnmount, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\n\n// Omit over each member of the union (a plain Omit keeps only what all layer types share, losing paint and layout)\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** A layer of `MMapGeoJson`: any MapLibre layer without its `source` (and `id`, made up when left out). */\nexport type MapGeoJsonLayer = DistributiveOmit<Exclude<Maplibre.LayerSpecification, Maplibre.BackgroundLayerSpecification>, 'id' | 'source'> & { id?: string }\n\n// It renders nothing: no element for attributes to land on\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** A GeoJSON object, or the URL of one */\n data: Maplibre.GeoJSONSourceSpecification['data']\n /** The source's id (and the prefix of its layers' made-up ids). Unique on the map; generated when left out */\n id?: string\n /** How to draw it: MapLibre layers without `source`. Defaults to theme-colored fill, outline, line and circle layers */\n layers?: MapGeoJsonLayer[]\n /** Insert the layers below this layer id (e.g. under the style's labels) */\n before?: string\n /** Show a pointer over its features (set it when you handle `click`) */\n interactive?: boolean\n /** More options for the GeoJSON source (`cluster`, `promoteId`, `tolerance`…) */\n sourceOptions?: Partial<Omit<Maplibre.GeoJSONSourceSpecification, 'type' | 'data'>>\n }>(),\n { interactive: false },\n)\n\nconst emit = defineEmits<{ click: [event: Maplibre.MapLayerMouseEvent] }>()\n\nconst sourceId = props.id ?? `m3-geojson-${useId()}`\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst is = (...types: string[]): Maplibre.FilterSpecification => ['match', ['geometry-type'], types, true, false]\n\n/** The theme-colored default layers. */\nconst defaultLayers = computed<MapGeoJsonLayer[]>(() => {\n const { primary, surface } = theme.value\n return [\n { id: `${sourceId}-fill`, type: 'fill', filter: is('Polygon', 'MultiPolygon'), paint: { 'fill-color': primary, 'fill-opacity': 0.24 } },\n { id: `${sourceId}-line`, type: 'line', filter: is('Polygon', 'MultiPolygon', 'LineString', 'MultiLineString'), paint: { 'line-color': primary, 'line-width': 2 } },\n {\n id: `${sourceId}-circle`,\n type: 'circle',\n filter: is('Point', 'MultiPoint'),\n paint: { 'circle-color': primary, 'circle-radius': 6, 'circle-stroke-color': surface, 'circle-stroke-width': 2 },\n },\n ]\n})\n\nconst layers = computed(() =>\n (props.layers ?? defaultLayers.value).map((l, i) => ({ ...l, id: l.id ?? `${sourceId}-${i}`, source: sourceId }) as Maplibre.LayerSpecification),\n)\n\nlet map: Maplibre.Map | undefined\nlet added: string[] = []\n\nconst onClick = (e: Maplibre.MapLayerMouseEvent) => emit('click', e)\nconst onEnter = () => { if (props.interactive && map) map.getCanvas().style.cursor = 'pointer' }\nconst onLeave = () => { if (props.interactive && map) map.getCanvas().style.cursor = '' }\n\nfunction removeLayers() {\n if (!map) return\n for (const id of added) {\n map.off('click', id, onClick)\n map.off('mouseenter', id, onEnter)\n map.off('mouseleave', id, onLeave)\n if (map.getLayer(id)) map.removeLayer(id)\n }\n added = []\n}\n\nfunction addLayers() {\n if (!map) return\n removeLayers()\n for (const layer of layers.value) {\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n map.on('click', layer.id, onClick)\n map.on('mouseenter', layer.id, onEnter)\n map.on('mouseleave', layer.id, onLeave)\n added.push(layer.id)\n }\n}\n\n/** The source and its layers, unless they're there already (a style change drops them). */\nfunction add() {\n if (!map) return\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, { type: 'geojson', data: props.data, ...props.sourceOptions })\n added = []\n }\n if (!added.length || !map.getLayer(added[0]!)) addLayers()\n}\n\nonReady((m) => {\n map = m\n add()\n})\n\nwatch(styleVersion, () => add())\nwatch(() => props.data, (data) => (map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined)?.setData(data))\n// Layers by value: an inline `:layers=\"[...]\"` is a new array on every parent render\nwatch(() => JSON.stringify(layers.value), () => addLayers())\nwatch(() => props.before, () => addLayers())\n\nonBeforeUnmount(() => {\n if (!map) return\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n map = undefined\n})\n\ndefineExpose({\n /** The source's id */\n sourceId,\n /** The ids of its layers on the map */\n layerIds: () => [...added],\n})\n</script>\n\n<!-- Nothing of its own: it draws on the map -->\n<template></template>\n","<script setup lang=\"ts\">\n/**\n * GeoJSON on an `MMap`: a source from `data` (an object, or a URL MapLibre fetches) drawn with `layers`. Without\n * `layers` it draws every geometry in the theme's primary, following palette and dark mode: polygons filled with an\n * outline, lines, and points as circles. Replace `data` (a new object) to update it. It's added again after a style\n * change. Available from the `/map` entry point.\n *\n * @event click A click on one of its features (MapLibre's `MapLayerMouseEvent`: `e.features` holds them)\n */\nimport { computed, onBeforeUnmount, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\n\n// Omit over each member of the union (a plain Omit keeps only what all layer types share, losing paint and layout)\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** A layer of `MMapGeoJson`: any MapLibre layer without its `source` (and `id`, made up when left out). */\nexport type MapGeoJsonLayer = DistributiveOmit<Exclude<Maplibre.LayerSpecification, Maplibre.BackgroundLayerSpecification>, 'id' | 'source'> & { id?: string }\n\n// It renders nothing: no element for attributes to land on\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** A GeoJSON object, or the URL of one */\n data: Maplibre.GeoJSONSourceSpecification['data']\n /** The source's id (and the prefix of its layers' made-up ids). Unique on the map; generated when left out */\n id?: string\n /** How to draw it: MapLibre layers without `source`. Defaults to theme-colored fill, outline, line and circle layers */\n layers?: MapGeoJsonLayer[]\n /** Insert the layers below this layer id (e.g. under the style's labels) */\n before?: string\n /** Show a pointer over its features (set it when you handle `click`) */\n interactive?: boolean\n /** More options for the GeoJSON source (`cluster`, `promoteId`, `tolerance`…) */\n sourceOptions?: Partial<Omit<Maplibre.GeoJSONSourceSpecification, 'type' | 'data'>>\n }>(),\n { interactive: false },\n)\n\nconst emit = defineEmits<{ click: [event: Maplibre.MapLayerMouseEvent] }>()\n\nconst sourceId = props.id ?? `m3-geojson-${useId()}`\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst is = (...types: string[]): Maplibre.FilterSpecification => ['match', ['geometry-type'], types, true, false]\n\n/** The theme-colored default layers. */\nconst defaultLayers = computed<MapGeoJsonLayer[]>(() => {\n const { primary, surface } = theme.value\n return [\n { id: `${sourceId}-fill`, type: 'fill', filter: is('Polygon', 'MultiPolygon'), paint: { 'fill-color': primary, 'fill-opacity': 0.24 } },\n { id: `${sourceId}-line`, type: 'line', filter: is('Polygon', 'MultiPolygon', 'LineString', 'MultiLineString'), paint: { 'line-color': primary, 'line-width': 2 } },\n {\n id: `${sourceId}-circle`,\n type: 'circle',\n filter: is('Point', 'MultiPoint'),\n paint: { 'circle-color': primary, 'circle-radius': 6, 'circle-stroke-color': surface, 'circle-stroke-width': 2 },\n },\n ]\n})\n\nconst layers = computed(() =>\n (props.layers ?? defaultLayers.value).map((l, i) => ({ ...l, id: l.id ?? `${sourceId}-${i}`, source: sourceId }) as Maplibre.LayerSpecification),\n)\n\nlet map: Maplibre.Map | undefined\nlet added: string[] = []\n\nconst onClick = (e: Maplibre.MapLayerMouseEvent) => emit('click', e)\nconst onEnter = () => { if (props.interactive && map) map.getCanvas().style.cursor = 'pointer' }\nconst onLeave = () => { if (props.interactive && map) map.getCanvas().style.cursor = '' }\n\nfunction removeLayers() {\n if (!map) return\n for (const id of added) {\n map.off('click', id, onClick)\n map.off('mouseenter', id, onEnter)\n map.off('mouseleave', id, onLeave)\n if (map.getLayer(id)) map.removeLayer(id)\n }\n added = []\n}\n\nfunction addLayers() {\n if (!map) return\n removeLayers()\n for (const layer of layers.value) {\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n map.on('click', layer.id, onClick)\n map.on('mouseenter', layer.id, onEnter)\n map.on('mouseleave', layer.id, onLeave)\n added.push(layer.id)\n }\n}\n\n/** The source and its layers, unless they're there already (a style change drops them). */\nfunction add() {\n if (!map) return\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, { type: 'geojson', data: props.data, ...props.sourceOptions })\n added = []\n }\n if (!added.length || !map.getLayer(added[0]!)) addLayers()\n}\n\nonReady((m) => {\n map = m\n add()\n})\n\nwatch(styleVersion, () => add())\nwatch(() => props.data, (data) => (map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined)?.setData(data))\n// Layers by value: an inline `:layers=\"[...]\"` is a new array on every parent render\nwatch(() => JSON.stringify(layers.value), () => addLayers())\nwatch(() => props.before, () => addLayers())\n\nonBeforeUnmount(() => {\n if (!map) return\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n map = undefined\n})\n\ndefineExpose({\n /** The source's id */\n sourceId,\n /** The ids of its layers on the map */\n layerIds: () => [...added],\n})\n</script>\n\n<!-- Nothing of its own: it draws on the map -->\n<template></template>\n","<script setup lang=\"ts\">\n// Internal: one layer of MMapLayers (visibility, title, and expanded: description, opacity, legend, download)\nimport MIcon from './MIcon.vue'\nimport MSlider from './MSlider.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\ndefineProps<{ layer: MapLayerInfo; expanded: boolean }>()\nconst emit = defineEmits<{ 'toggle-expanded': [] }>()\n\nconst t = useLocale()\nconst { isVisible, toggle, opacityOf, setOpacity } = useMapLayers()\n</script>\n\n<template>\n <div class=\"flex overflow-hidden rounded-2xl bg-surface-container\" :class=\"isVisible(layer.id) ? '' : 'opacity-75'\">\n <div class=\"w-1 shrink-0 transition-colors duration-200\" :class=\"isVisible(layer.id) ? 'bg-primary' : 'bg-outline-variant'\" />\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <div class=\"flex cursor-pointer items-center gap-2 px-3 py-2\" @click=\"emit('toggle-expanded')\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"isVisible(layer.id) ? 'bg-primary/12 text-primary' : 'bg-on-surface/5 text-on-surface-variant'\"\n :aria-label=\"isVisible(layer.id) ? t.mapHideLayer : t.mapShowLayer\"\n :aria-pressed=\"isVisible(layer.id)\"\n @click.stop=\"toggle(layer.id)\"\n >\n <MIcon :name=\"isVisible(layer.id) ? 'visibility' : 'visibility_off'\" :size=\"18\" />\n </button>\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <span class=\"truncate text-body-medium\" :class=\"isVisible(layer.id) ? 'text-on-surface' : 'text-on-surface-variant'\">{{ layer.title }}</span>\n <span v-if=\"layer.description && !expanded\" class=\"truncate text-label-small text-on-surface-variant\">{{ layer.description }}</span>\n </div>\n <span v-if=\"isVisible(layer.id) && opacityOf(layer.id) < 1\" class=\"rounded-full bg-primary/8 px-2 py-0.5 text-label-small tabular-nums text-primary\">\n {{ Math.round(opacityOf(layer.id) * 100) }}%\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"shrink-0 text-on-surface-variant transition-transform duration-300\" :class=\"expanded ? 'rotate-180' : ''\" />\n </div>\n <!-- Expands with grid rows 0fr → 1fr, so the height animates without measuring it -->\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: expanded ? '1fr' : '0fr' }\">\n <div class=\"min-h-0 overflow-hidden\">\n <div class=\"flex flex-col gap-3 px-3 pb-3\">\n <p v-if=\"layer.description\" class=\"text-body-small text-on-surface-variant\">{{ layer.description }}</p>\n <div class=\"flex items-center gap-2 rounded-2xl bg-surface-container-highest/60 px-3 py-1\">\n <MIcon name=\"opacity\" :size=\"16\" class=\"shrink-0 text-on-surface-variant\" />\n <MSlider\n :model-value=\"opacityOf(layer.id)\"\n :min=\"0\"\n :max=\"1\"\n :step=\"0.01\"\n :label=\"t.mapOpacity\"\n class=\"flex-1\"\n @update:model-value=\"setOpacity(layer.id, Number($event))\"\n />\n </div>\n <img v-if=\"layer.legend\" :src=\"layer.legend\" alt=\"\" class=\"max-w-full self-start\" loading=\"lazy\">\n <div v-if=\"layer.download || $slots.actions\" class=\"flex flex-wrap items-center gap-2\">\n <a\n v-if=\"layer.download\"\n :href=\"layer.download\"\n target=\"_blank\"\n rel=\"noopener\"\n download\n class=\"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-label-large text-primary hover:bg-primary/8\"\n >\n <MIcon name=\"download\" :size=\"18\" />\n {{ t.mapDownload }}\n </a>\n <slot name=\"actions\" :layer=\"layer\" :visible=\"isVisible(layer.id)\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n// Internal: one layer of MMapLayers (visibility, title, and expanded: description, opacity, legend, download)\nimport MIcon from './MIcon.vue'\nimport MSlider from './MSlider.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\ndefineProps<{ layer: MapLayerInfo; expanded: boolean }>()\nconst emit = defineEmits<{ 'toggle-expanded': [] }>()\n\nconst t = useLocale()\nconst { isVisible, toggle, opacityOf, setOpacity } = useMapLayers()\n</script>\n\n<template>\n <div class=\"flex overflow-hidden rounded-2xl bg-surface-container\" :class=\"isVisible(layer.id) ? '' : 'opacity-75'\">\n <div class=\"w-1 shrink-0 transition-colors duration-200\" :class=\"isVisible(layer.id) ? 'bg-primary' : 'bg-outline-variant'\" />\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <div class=\"flex cursor-pointer items-center gap-2 px-3 py-2\" @click=\"emit('toggle-expanded')\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"isVisible(layer.id) ? 'bg-primary/12 text-primary' : 'bg-on-surface/5 text-on-surface-variant'\"\n :aria-label=\"isVisible(layer.id) ? t.mapHideLayer : t.mapShowLayer\"\n :aria-pressed=\"isVisible(layer.id)\"\n @click.stop=\"toggle(layer.id)\"\n >\n <MIcon :name=\"isVisible(layer.id) ? 'visibility' : 'visibility_off'\" :size=\"18\" />\n </button>\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <span class=\"truncate text-body-medium\" :class=\"isVisible(layer.id) ? 'text-on-surface' : 'text-on-surface-variant'\">{{ layer.title }}</span>\n <span v-if=\"layer.description && !expanded\" class=\"truncate text-label-small text-on-surface-variant\">{{ layer.description }}</span>\n </div>\n <span v-if=\"isVisible(layer.id) && opacityOf(layer.id) < 1\" class=\"rounded-full bg-primary/8 px-2 py-0.5 text-label-small tabular-nums text-primary\">\n {{ Math.round(opacityOf(layer.id) * 100) }}%\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"shrink-0 text-on-surface-variant transition-transform duration-300\" :class=\"expanded ? 'rotate-180' : ''\" />\n </div>\n <!-- Expands with grid rows 0fr → 1fr, so the height animates without measuring it -->\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: expanded ? '1fr' : '0fr' }\">\n <div class=\"min-h-0 overflow-hidden\">\n <div class=\"flex flex-col gap-3 px-3 pb-3\">\n <p v-if=\"layer.description\" class=\"text-body-small text-on-surface-variant\">{{ layer.description }}</p>\n <div class=\"flex items-center gap-2 rounded-2xl bg-surface-container-highest/60 px-3 py-1\">\n <MIcon name=\"opacity\" :size=\"16\" class=\"shrink-0 text-on-surface-variant\" />\n <MSlider\n :model-value=\"opacityOf(layer.id)\"\n :min=\"0\"\n :max=\"1\"\n :step=\"0.01\"\n :label=\"t.mapOpacity\"\n class=\"flex-1\"\n @update:model-value=\"setOpacity(layer.id, Number($event))\"\n />\n </div>\n <img v-if=\"layer.legend\" :src=\"layer.legend\" alt=\"\" class=\"max-w-full self-start\" loading=\"lazy\">\n <div v-if=\"layer.download || $slots.actions\" class=\"flex flex-wrap items-center gap-2\">\n <a\n v-if=\"layer.download\"\n :href=\"layer.download\"\n target=\"_blank\"\n rel=\"noopener\"\n download\n class=\"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-label-large text-primary hover:bg-primary/8\"\n >\n <MIcon name=\"download\" :size=\"18\" />\n {{ t.mapDownload }}\n </a>\n <slot name=\"actions\" :layer=\"layer\" :visible=\"isVisible(layer.id)\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * The layer list of an `MMap` with an `adapter`: a search field, the style's groups (collapsible, with a visibility\n * toggle for the whole group and a count) and its layers, each with a visibility toggle and, expanded, its\n * description, an opacity slider, its legend and a download link. Only the content: put it in an `MWindow`, an\n * `MSideSheet`, an `MBottomSheet` or an `MMapControl`, inside the `MMap` or anywhere else with `map`. Available from the\n * `/map` entry point.\n *\n * @slot actions Extra actions in an expanded layer (scope: `{ layer, visible }`)\n */\nimport { computed, ref } from 'vue'\nimport MIcon from './MIcon.vue'\nimport MTextField from './MTextField.vue'\nimport MMapLayerItem from './_MMapLayerItem.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\nconst props = withDefaults(\n defineProps<{\n /** Show the search field */\n search?: boolean\n /** Groups start collapsed */\n collapsed?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { search: true, collapsed: false },\n)\n\nconst t = useLocale()\nconst { model, layersOf, isVisible, groupState, setGroupVisible } = useMapLayers(() => props.map)\n\nconst query = ref('')\nconst matches = (layer: MapLayerInfo) => !query.value || layer.title.toLowerCase().includes(query.value.toLowerCase())\n\nconst groups = computed(() =>\n (model.value?.groups ?? [])\n .map((g) => ({ ...g, all: layersOf(g.name), layers: layersOf(g.name).filter(matches) }))\n .filter((g) => g.layers.length),\n)\nconst ungrouped = computed(() => layersOf(null).filter(matches))\n\n// Collapsed groups and expanded layers (by default the other way around, with `collapsed`)\nconst toggledGroups = ref(new Set<string>())\nconst isOpen = (group: string) => toggledGroups.value.has(group) === props.collapsed\nfunction toggleGroup(group: string) {\n const next = new Set(toggledGroups.value)\n if (!next.delete(group)) next.add(group)\n toggledGroups.value = next\n}\nconst expanded = ref(new Set<string>())\nfunction toggleExpanded(id: string) {\n const next = new Set(expanded.value)\n if (!next.delete(id)) next.add(id)\n expanded.value = next\n}\n\nconst visibleCount = (layers: MapLayerInfo[]) => layers.filter((l) => isVisible(l.id)).length\n</script>\n\n<template>\n <div class=\"flex flex-col gap-3\">\n <MTextField v-if=\"search\" v-model=\"query\" :label=\"t.mapSearchLayers\" leading-icon=\"search\" variant=\"outlined\" clearable />\n\n <section v-for=\"group in groups\" :key=\"group.name\" class=\"flex flex-col\">\n <div class=\"m3-map-layers-row flex cursor-pointer items-center gap-2 rounded-xl px-2 py-1.5\" @click=\"toggleGroup(group.name)\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"groupState(group.name) === 'visible' ? 'bg-primary-container text-on-primary-container'\n : groupState(group.name) === 'partial' ? 'bg-secondary-container text-on-secondary-container'\n : 'bg-on-surface/8 text-on-surface-variant'\"\n :aria-label=\"groupState(group.name) === 'hidden' ? t.mapShowLayer : t.mapHideLayer\"\n :aria-pressed=\"groupState(group.name) !== 'hidden'\"\n @click.stop=\"setGroupVisible(group.name, groupState(group.name) !== 'visible')\"\n >\n <MIcon :name=\"groupState(group.name) === 'hidden' ? 'visibility_off' : 'visibility'\" :size=\"18\" />\n </button>\n <span class=\"flex-1 select-none truncate text-label-large text-on-surface\">{{ group.title }}</span>\n <span class=\"rounded-full bg-surface-container-highest px-2 py-0.5 text-label-small tabular-nums text-on-surface-variant\">\n {{ visibleCount(group.all) }}/{{ group.all.length }}\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"text-on-surface-variant transition-transform duration-300\" :class=\"isOpen(group.name) ? 'rotate-180' : ''\" />\n </div>\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: isOpen(group.name) ? '1fr' : '0fr' }\">\n <div class=\"flex min-h-0 flex-col gap-1.5 overflow-hidden\" :class=\"isOpen(group.name) ? 'pt-1.5' : ''\">\n <MMapLayerItem v-for=\"layer in group.layers\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n </div>\n </section>\n\n <div v-if=\"ungrouped.length\" class=\"flex flex-col gap-1.5\">\n <MMapLayerItem v-for=\"layer in ungrouped\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n\n <div v-if=\"!groups.length && !ungrouped.length\" class=\"flex flex-col items-center gap-3 py-8\">\n <div class=\"grid size-14 place-items-center rounded-full bg-surface-container-highest\">\n <MIcon name=\"layers_clear\" :size=\"28\" class=\"text-on-surface-variant\" />\n </div>\n <p class=\"text-body-medium text-on-surface-variant\">{{ t.mapNoLayers }}</p>\n </div>\n </div>\n</template>\n\n<style>\n.m3-map-layers-row:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 6%, transparent);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * The layer list of an `MMap` with an `adapter`: a search field, the style's groups (collapsible, with a visibility\n * toggle for the whole group and a count) and its layers, each with a visibility toggle and, expanded, its\n * description, an opacity slider, its legend and a download link. Only the content: put it in an `MWindow`, an\n * `MSideSheet`, an `MBottomSheet` or an `MMapControl`, inside the `MMap` or anywhere else with `map`. Available from the\n * `/map` entry point.\n *\n * @slot actions Extra actions in an expanded layer (scope: `{ layer, visible }`)\n */\nimport { computed, ref } from 'vue'\nimport MIcon from './MIcon.vue'\nimport MTextField from './MTextField.vue'\nimport MMapLayerItem from './_MMapLayerItem.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\nconst props = withDefaults(\n defineProps<{\n /** Show the search field */\n search?: boolean\n /** Groups start collapsed */\n collapsed?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { search: true, collapsed: false },\n)\n\nconst t = useLocale()\nconst { model, layersOf, isVisible, groupState, setGroupVisible } = useMapLayers(() => props.map)\n\nconst query = ref('')\nconst matches = (layer: MapLayerInfo) => !query.value || layer.title.toLowerCase().includes(query.value.toLowerCase())\n\nconst groups = computed(() =>\n (model.value?.groups ?? [])\n .map((g) => ({ ...g, all: layersOf(g.name), layers: layersOf(g.name).filter(matches) }))\n .filter((g) => g.layers.length),\n)\nconst ungrouped = computed(() => layersOf(null).filter(matches))\n\n// Collapsed groups and expanded layers (by default the other way around, with `collapsed`)\nconst toggledGroups = ref(new Set<string>())\nconst isOpen = (group: string) => toggledGroups.value.has(group) === props.collapsed\nfunction toggleGroup(group: string) {\n const next = new Set(toggledGroups.value)\n if (!next.delete(group)) next.add(group)\n toggledGroups.value = next\n}\nconst expanded = ref(new Set<string>())\nfunction toggleExpanded(id: string) {\n const next = new Set(expanded.value)\n if (!next.delete(id)) next.add(id)\n expanded.value = next\n}\n\nconst visibleCount = (layers: MapLayerInfo[]) => layers.filter((l) => isVisible(l.id)).length\n</script>\n\n<template>\n <div class=\"flex flex-col gap-3\">\n <MTextField v-if=\"search\" v-model=\"query\" :label=\"t.mapSearchLayers\" leading-icon=\"search\" variant=\"outlined\" clearable />\n\n <section v-for=\"group in groups\" :key=\"group.name\" class=\"flex flex-col\">\n <div class=\"m3-map-layers-row flex cursor-pointer items-center gap-2 rounded-xl px-2 py-1.5\" @click=\"toggleGroup(group.name)\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"groupState(group.name) === 'visible' ? 'bg-primary-container text-on-primary-container'\n : groupState(group.name) === 'partial' ? 'bg-secondary-container text-on-secondary-container'\n : 'bg-on-surface/8 text-on-surface-variant'\"\n :aria-label=\"groupState(group.name) === 'hidden' ? t.mapShowLayer : t.mapHideLayer\"\n :aria-pressed=\"groupState(group.name) !== 'hidden'\"\n @click.stop=\"setGroupVisible(group.name, groupState(group.name) !== 'visible')\"\n >\n <MIcon :name=\"groupState(group.name) === 'hidden' ? 'visibility_off' : 'visibility'\" :size=\"18\" />\n </button>\n <span class=\"flex-1 select-none truncate text-label-large text-on-surface\">{{ group.title }}</span>\n <span class=\"rounded-full bg-surface-container-highest px-2 py-0.5 text-label-small tabular-nums text-on-surface-variant\">\n {{ visibleCount(group.all) }}/{{ group.all.length }}\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"text-on-surface-variant transition-transform duration-300\" :class=\"isOpen(group.name) ? 'rotate-180' : ''\" />\n </div>\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: isOpen(group.name) ? '1fr' : '0fr' }\">\n <div class=\"flex min-h-0 flex-col gap-1.5 overflow-hidden\" :class=\"isOpen(group.name) ? 'pt-1.5' : ''\">\n <MMapLayerItem v-for=\"layer in group.layers\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n </div>\n </section>\n\n <div v-if=\"ungrouped.length\" class=\"flex flex-col gap-1.5\">\n <MMapLayerItem v-for=\"layer in ungrouped\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n\n <div v-if=\"!groups.length && !ungrouped.length\" class=\"flex flex-col items-center gap-3 py-8\">\n <div class=\"grid size-14 place-items-center rounded-full bg-surface-container-highest\">\n <MIcon name=\"layers_clear\" :size=\"28\" class=\"text-on-surface-variant\" />\n </div>\n <p class=\"text-body-medium text-on-surface-variant\">{{ t.mapNoLayers }}</p>\n </div>\n </div>\n</template>\n\n<style>\n.m3-map-layers-row:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 6%, transparent);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * The base layer switcher of an `MMap` with an `adapter`: a round thumbnail per base layer (the adapter's `image`,\n * after `imageBase`), one shown at a time, plus \"no base layer\". Only the thumbnails: put them in an `MMapControl`\n * (`:group=\"false\"`), an `MFab`'s `#content` or a panel, inside the `MMap` or anywhere else with `map`. Available\n * from the `/map` entry point.\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\n\nconst props = withDefaults(\n defineProps<{\n /** Prefix for the thumbnails' paths (e.g. `/images/`); full URLs are used as they are */\n imageBase?: string\n /** Offer \"no base layer\" */\n none?: boolean\n /** Lay them out in a column */\n vertical?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { imageBase: '', none: true, vertical: false },\n)\n\nconst t = useLocale()\nconst { baseLayers, baseLayer, setBaseLayer } = useMapLayers(() => props.map)\n\nconst src = (image: string, base: string) => (/^(https?:|data:|\\/\\/)/.test(image) ? image : `${base}${image}`)\n</script>\n\n<template>\n <div class=\"flex gap-2\" :class=\"vertical ? 'flex-col' : 'flex-row flex-wrap'\" role=\"radiogroup\">\n <button\n v-for=\"layer in baseLayers\"\n :key=\"layer.id\"\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === layer.id ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :title=\"layer.title\"\n :aria-label=\"layer.title\"\n :aria-checked=\"baseLayer === layer.id\"\n @click=\"setBaseLayer(layer.id)\"\n >\n <img v-if=\"layer.base?.image\" :src=\"src(layer.base.image, imageBase)\" alt=\"\" class=\"size-full object-cover\">\n <MIcon v-else name=\"map\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n <button\n v-if=\"none\"\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === null ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :title=\"t.mapNoBaseLayer\"\n :aria-label=\"t.mapNoBaseLayer\"\n :aria-checked=\"baseLayer === null\"\n @click=\"setBaseLayer(null)\"\n >\n <MIcon name=\"layers_clear\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n </div>\n</template>\n\n<style>\n/* Inactive thumbnails in gray, the active one in color */\n.m3-map-base:not(.m3-map-base--active) img {\n filter: grayscale(1) opacity(0.6);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * The base layer switcher of an `MMap` with an `adapter`: a round thumbnail per base layer (the adapter's `image`,\n * after `imageBase`), one shown at a time, plus \"no base layer\". Only the thumbnails: put them in an `MMapControl`\n * (`:group=\"false\"`), an `MFab`'s `#content` or a panel, inside the `MMap` or anywhere else with `map`. Available\n * from the `/map` entry point.\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\n\nconst props = withDefaults(\n defineProps<{\n /** Prefix for the thumbnails' paths (e.g. `/images/`); full URLs are used as they are */\n imageBase?: string\n /** Offer \"no base layer\" */\n none?: boolean\n /** Lay them out in a column */\n vertical?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { imageBase: '', none: true, vertical: false },\n)\n\nconst t = useLocale()\nconst { baseLayers, baseLayer, setBaseLayer } = useMapLayers(() => props.map)\n\nconst src = (image: string, base: string) => (/^(https?:|data:|\\/\\/)/.test(image) ? image : `${base}${image}`)\n</script>\n\n<template>\n <div class=\"flex gap-2\" :class=\"vertical ? 'flex-col' : 'flex-row flex-wrap'\" role=\"radiogroup\">\n <button\n v-for=\"layer in baseLayers\"\n :key=\"layer.id\"\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === layer.id ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :title=\"layer.title\"\n :aria-label=\"layer.title\"\n :aria-checked=\"baseLayer === layer.id\"\n @click=\"setBaseLayer(layer.id)\"\n >\n <img v-if=\"layer.base?.image\" :src=\"src(layer.base.image, imageBase)\" alt=\"\" class=\"size-full object-cover\">\n <MIcon v-else name=\"map\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n <button\n v-if=\"none\"\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === null ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :title=\"t.mapNoBaseLayer\"\n :aria-label=\"t.mapNoBaseLayer\"\n :aria-checked=\"baseLayer === null\"\n @click=\"setBaseLayer(null)\"\n >\n <MIcon name=\"layers_clear\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n </div>\n</template>\n\n<style>\n/* Inactive thumbnails in gray, the active one in color */\n.m3-map-base:not(.m3-map-base--active) img {\n filter: grayscale(1) opacity(0.6);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * Identify results (from `MMapIdentify`'s `identify` event, or `identifyFeatures()`): a card per feature with its\n * layer's name and its formatted properties. `MMapIdentify` shows it in a popup; use it in a panel of your own (an\n * `MWindow`, an `MSideSheet`) the same way. Values are shown as text. Available from the `/map` entry point.\n *\n * @slot value A property's value (scope: `{ field, result }`), e.g. to turn URLs into links\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapIdentifyResult } from '../composables/mapAdapters'\n\ndefineProps<{\n /** What was found */\n results: MapIdentifyResult[]\n}>()\n\nconst t = useLocale()\n</script>\n\n<template>\n <div class=\"flex flex-col gap-2\">\n <div v-for=\"(result, i) in results\" :key=\"i\" class=\"overflow-hidden rounded-2xl bg-surface-container\">\n <div class=\"flex items-center gap-2 bg-primary-container/40 px-4 py-2\">\n <MIcon name=\"layers\" :size=\"16\" class=\"text-on-primary-container\" />\n <span class=\"text-label-large text-on-primary-container\">{{ result.layer.title }}</span>\n </div>\n <dl class=\"flex flex-col px-4 py-1\">\n <div v-for=\"field in result.fields\" :key=\"field.key\" class=\"flex flex-col gap-0.5 border-b border-outline-variant py-1.5 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-medium text-on-surface\">\n <slot name=\"value\" :field=\"field\" :result=\"result\">\n <span v-if=\"field.value\" class=\"break-words\">{{ field.value }}</span>\n <span v-else class=\"text-body-small italic text-on-surface-variant\">{{ t.mapNoValue }}</span>\n </slot>\n </dd>\n </div>\n </dl>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Identify results (from `MMapIdentify`'s `identify` event, or `identifyFeatures()`): a card per feature with its\n * layer's name and its formatted properties. `MMapIdentify` shows it in a popup; use it in a panel of your own (an\n * `MWindow`, an `MSideSheet`) the same way. Values are shown as text. Available from the `/map` entry point.\n *\n * @slot value A property's value (scope: `{ field, result }`), e.g. to turn URLs into links\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapIdentifyResult } from '../composables/mapAdapters'\n\ndefineProps<{\n /** What was found */\n results: MapIdentifyResult[]\n}>()\n\nconst t = useLocale()\n</script>\n\n<template>\n <div class=\"flex flex-col gap-2\">\n <div v-for=\"(result, i) in results\" :key=\"i\" class=\"overflow-hidden rounded-2xl bg-surface-container\">\n <div class=\"flex items-center gap-2 bg-primary-container/40 px-4 py-2\">\n <MIcon name=\"layers\" :size=\"16\" class=\"text-on-primary-container\" />\n <span class=\"text-label-large text-on-primary-container\">{{ result.layer.title }}</span>\n </div>\n <dl class=\"flex flex-col px-4 py-1\">\n <div v-for=\"field in result.fields\" :key=\"field.key\" class=\"flex flex-col gap-0.5 border-b border-outline-variant py-1.5 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-medium text-on-surface\">\n <slot name=\"value\" :field=\"field\" :result=\"result\">\n <span v-if=\"field.value\" class=\"break-words\">{{ field.value }}</span>\n <span v-else class=\"text-body-small italic text-on-surface-variant\">{{ t.mapNoValue }}</span>\n </slot>\n </dd>\n </div>\n </dl>\n </div>\n </div>\n</template>\n","import type * as Maplibre from 'maplibre-gl'\n\n/** How to show one property of a feature. */\nexport interface MapFieldFormat {\n /** The label (the key, capitalized, by default) */\n label?: string\n /** Text before the value */\n prefix?: string\n /** Text after the value */\n suffix?: string\n /** A number mask: its decimals set the fraction digits (`#.00` → 2) and a comma turns on grouping (`#,###`) */\n mask?: string\n /** Leave it out */\n hidden?: boolean\n}\n\n/** One layer of the style, as the map's UI components see it. */\nexport interface MapLayerInfo {\n /** The style layer's id */\n id: string\n /** Its name in the UI */\n title: string\n description?: string\n /** The `name` of its group in `MapLayerModel.groups` */\n group?: string\n /** Shown in `MMapLayers` */\n listed: boolean\n /** A base layer: `MMapBaseLayers` shows one of them at a time, with this thumbnail */\n base?: { image?: string }\n /** Layer ids shown, hidden and faded along with it */\n children: string[]\n /** Listed by `MMapIdentify` on click: every property, formatted by `format`, minus `exclude` */\n identify: false | { format: Record<string, MapFieldFormat>; exclude: string[] }\n /** Shown by `MMapHover` under the pointer: these properties, in order */\n hover: false | { fields: (MapFieldFormat & { key: string })[] }\n /** A legend image URL (an SVG, typically) */\n legend?: string\n /** A download URL for its data */\n download?: string\n}\n\n/** The style as the map's UI components see it: layers with names, groups, base layers, what to identify. */\nexport interface MapLayerModel {\n /** The style's name */\n title?: string\n /** Groups, in order */\n groups: { name: string; title: string }[]\n /** Layers, in the style's order (bottom to top) */\n layers: MapLayerInfo[]\n}\n\n/** What an adapter gets besides the style. */\nexport interface MapAdapterContext {\n /** The style's URL, when `MMap`'s `mapStyle` is one */\n styleUrl?: string\n}\n\n/** Reads a style's conventions (usually its `metadata`) into the model the map's UI components use. */\nexport type MapAdapter = (style: Maplibre.StyleSpecification, context: MapAdapterContext) => MapLayerModel\n\ntype Metadata = Record<string, unknown> | undefined\nconst meta = (layer: { metadata?: unknown }) => layer.metadata as Metadata\nconst VECTOR = new Set(['fill', 'line', 'circle', 'symbol', 'fill-extrusion', 'heatmap'])\n\n/**\n * Any style: every layer but the background is listed under its id (or `metadata.title`), vector layers identify all\n * their properties, and nothing is a base layer or shows on hover.\n */\nexport const genericAdapter: MapAdapter = (style) => ({\n title: style.name,\n groups: [],\n layers: style.layers\n .filter((l) => l.type !== 'background')\n .map((l) => ({\n id: l.id,\n title: (meta(l)?.title as string | undefined) ?? l.id,\n listed: true,\n children: [],\n identify: VECTOR.has(l.type) ? { format: {}, exclude: [] } : false,\n hover: false,\n })),\n})\n\nexport interface OrvianAdapterOptions {\n /**\n * A layer's legend image. By default, for a style served by mvt-rs (`…/services/styles/<style>`), its legend service\n * (`…/services/legends/<style>?layer_id=<id>`), unless the layer's `metadata.legend.show` is false;\n * `metadata.legend.wmslegend` overrides it\n */\n legend?: (layer: Maplibre.LayerSpecification, styleUrl?: string) => string | undefined\n}\n\n/**\n * The Orvian viewers' conventions in the style's `metadata`. On each layer: `alias`, `description`, `group`,\n * `show_in_layerlist` (false hides it from the list), `isbaselayer` with `image` (raster base layers), `childs` (layer\n * ids toggled with it), `identify` (true lists its properties on click), `fields` (per property: `alias`, `prefix`,\n * `suffix`, `mask`, `show: false`; plus `exclude`, a list of properties to leave out), `hover` (`enable` and `fields`,\n * a list of `{ <property>: { alias, prefix, suffix, mask } }`), `legend` (`show`, `wmslegend`) and `download`. On the\n * style: `groups` (`{ name, alias }`, in order).\n */\nexport function orvianAdapter(options: OrvianAdapterOptions = {}): MapAdapter {\n const legendOf = options.legend ?? ((layer, styleUrl) => {\n const legend = meta(layer)?.legend as { show?: boolean; wmslegend?: string } | undefined\n if (legend?.show === false) return undefined\n if (legend?.wmslegend) return legend.wmslegend\n if (!styleUrl?.includes('/services/styles/')) return undefined\n const url = styleUrl.replace('/services/styles/', '/services/legends/')\n return `${url}${url.includes('?') ? '&' : '?'}has_label=false&include_raster=true&layer_id=${encodeURIComponent(layer.id)}`\n })\n\n return (style, { styleUrl }) => {\n const groups = ((style.metadata as Metadata)?.groups as { name: string; alias?: string }[] | undefined) ?? []\n return {\n title: style.name,\n groups: groups.map((g) => ({ name: g.name, title: g.alias ?? g.name })),\n layers: style.layers\n .filter((l) => l.type !== 'background')\n .map((l) => {\n const m = meta(l) ?? {}\n const fields = { ...(m.fields as Record<string, unknown> | undefined) }\n const exclude = (fields.exclude as string[] | undefined) ?? []\n delete fields.exclude\n const format: Record<string, MapFieldFormat> = {}\n for (const [key, f] of Object.entries(fields as Record<string, { alias?: string; prefix?: string; suffix?: string; mask?: string; show?: boolean }>)) {\n format[key] = { label: f.alias, prefix: f.prefix, suffix: f.suffix, mask: f.mask, hidden: f.show === false }\n }\n const hover = m.hover as { enable?: boolean; fields?: Record<string, MapFieldFormat & { alias?: string }>[] } | undefined\n const base = l.type === 'raster' && m.isbaselayer === true\n return {\n id: l.id,\n title: (m.alias as string | undefined) ?? l.id,\n description: m.description as string | undefined,\n group: m.group as string | undefined,\n listed: !base && m.show_in_layerlist !== false,\n base: base && m.show_in_layerlist !== false ? { image: m.image as string | undefined } : undefined,\n children: Array.isArray(m.childs) ? (m.childs as string[]) : [],\n identify: m.identify === true ? { format, exclude } : false,\n hover: hover?.enable\n ? {\n fields: (hover.fields ?? []).flatMap((entry) =>\n Object.entries(entry).map(([key, f]) => ({ key, label: f.alias ?? f.label, prefix: f.prefix, suffix: f.suffix, mask: f.mask }))),\n }\n : false,\n legend: base ? undefined : legendOf(l, styleUrl),\n download: l.type !== 'raster' ? (m.download as string | undefined) : undefined,\n } satisfies MapLayerInfo\n }),\n }\n }\n}\n\n/** A property's label: its format's, or the key with a capital first letter. */\nexport function fieldLabel(key: string, format?: MapFieldFormat): string {\n return format?.label ?? key.charAt(0).toUpperCase() + key.slice(1)\n}\n\n/**\n * A property's value as text: numbers through `mask` (in the page's language, `<html lang>`), then `prefix` and\n * `suffix`. Empty values give ''.\n */\nexport function formatFieldValue(raw: unknown, format?: MapFieldFormat): string {\n if (raw === null || raw === undefined || String(raw).trim() === '') return ''\n let value = String(raw)\n const num = typeof raw === 'number' ? raw : Number(raw)\n if (format?.mask && !Number.isNaN(num)) {\n const decimals = format.mask.split('.')[1]?.length ?? 0\n const lang = typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined\n value = new Intl.NumberFormat(lang, {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n useGrouping: format.mask.includes(','),\n }).format(num)\n }\n if (format?.prefix) value = `${format.prefix} ${value}`\n if (format?.suffix) value = `${value} ${format.suffix}`\n return value\n}\n\n/** What `MMapIdentify` found on one layer at a point. */\nexport interface MapIdentifyResult {\n layer: MapLayerInfo\n feature: Maplibre.MapGeoJSONFeature\n /** Its properties as the layer's `identify` shows them, formatted */\n fields: { key: string; label: string; value: string }[]\n}\n\n// Keys MapLibre or a previous identify adds to a feature's properties\nconst INTERNAL_KEYS = new Set(['coordinates', 'mapCoordinates', 'layerId', '__layerMetadata'])\n\n/**\n * The features of the model's identify layers at a point (topmost first), with their properties formatted: what\n * `MMapIdentify` lists on click, for a UI of your own.\n */\nexport function identifyFeatures(map: Maplibre.Map, point: Maplibre.PointLike, model: MapLayerModel | undefined): MapIdentifyResult[] {\n const layers = new Map((model?.layers ?? []).filter((l) => l.identify && map.getLayer(l.id)).map((l) => [l.id, l]))\n if (!layers.size) return []\n const results: MapIdentifyResult[] = []\n for (const feature of map.queryRenderedFeatures(point, { layers: [...layers.keys()] })) {\n const layer = layers.get(feature.layer.id)\n if (!layer || !layer.identify) continue\n const { format, exclude } = layer.identify\n const fields = Object.entries(feature.properties ?? {})\n .filter(([key]) => !INTERNAL_KEYS.has(key) && !exclude.includes(key) && !format[key]?.hidden)\n .map(([key, raw]) => ({ key, label: fieldLabel(key, format[key]), value: formatFieldValue(raw, format[key]) }))\n if (fields.length) results.push({ layer, feature, fields })\n }\n return results\n}\n","<script setup lang=\"ts\">\n/**\n * Click-to-identify for an `MMap` with an `adapter`: a click on the map lists the features of the layers marked to\n * identify under it (with their formatted properties) in a popup, with a marker where the user clicked. The pointer\n * turns into a hand over those layers. The `identify` event carries the results, to show them in a panel of your own\n * instead (`:popup=\"false\"`, then `MMapFeatureInfo` in an `MWindow`). Available from the `/map` entry point.\n *\n * @slot default The popup's content instead of `MMapFeatureInfo` (scope: `{ results, lngLat, close }`)\n * @event identify The user clicked the map: what was found there (empty when nothing) and where (`[lng, lat]`)\n */\nimport { onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapPopup from './MMapPopup.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport MMapFeatureInfo from './MMapFeatureInfo.vue'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { identifyFeatures, type MapIdentifyResult } from '../composables/mapAdapters'\nimport { PIN_POPUP_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on the popup's content\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Listen to clicks. It also pauses by itself while another tool owns them (`MMapMeasure` measuring) */\n enabled?: boolean\n /** Show the results in a popup at the click */\n popup?: boolean\n /** Mark where the user clicked while there are results */\n marker?: boolean\n }>(),\n { enabled: true, popup: true, marker: true },\n)\n\nconst emit = defineEmits<{ identify: [results: MapIdentifyResult[], lngLat: [number, number]] }>()\n\nconst { on, onReady, activeTool } = useMap()\nconst { model } = useMapLayers()\n\nconst results = shallowRef<MapIdentifyResult[]>([])\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\non('click', (e) => {\n // Another tool (measuring…) owns the clicks\n if (!props.enabled || activeTool.value) return\n const map = e.target as Maplibre.Map\n results.value = identifyFeatures(map, e.point, model.value)\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = results.value.length > 0\n emit('identify', results.value, lngLat.value)\n})\n\nfunction close() {\n open.value = false\n}\nwatch(() => props.enabled, (enabled) => { if (!enabled) close() })\n\n// A hand over the layers that answer to a click\nlet map: Maplibre.Map | undefined\nlet hovered: string[] = []\nconst enter = () => { if (props.enabled && !activeTool.value && map) map.getCanvas().style.cursor = 'pointer' }\nconst leave = () => { if (map) map.getCanvas().style.cursor = '' }\nfunction bindCursor() {\n if (!map) return\n for (const id of hovered) {\n map.off('mouseenter', id, enter)\n map.off('mouseleave', id, leave)\n }\n hovered = (model.value?.layers ?? []).filter((l) => l.identify).map((l) => l.id)\n for (const id of hovered) {\n map.on('mouseenter', id, enter)\n map.on('mouseleave', id, leave)\n }\n}\nonReady((m) => {\n map = m\n bindCursor()\n})\nwatch(model, bindCursor)\nonBeforeUnmount(() => {\n hovered.forEach((id) => {\n map?.off('mouseenter', id, enter)\n map?.off('mouseleave', id, leave)\n })\n})\n\ndefineExpose({ close })\n</script>\n\n<template>\n <!-- One root (the marker and the popup move their content into the map) -->\n <div class=\"hidden\">\n <MMapMarker v-if=\"marker && open\" :lng-lat=\"lngLat\" />\n <MMapPopup v-if=\"popup && results.length\" v-model:open=\"open\" :lng-lat=\"lngLat\" max-width=\"360px\" :offset=\"marker ? PIN_POPUP_OFFSET : undefined\">\n <div class=\"max-h-80 overflow-y-auto\" v-bind=\"$attrs\">\n <slot :results=\"results\" :lng-lat=\"lngLat\" :close=\"close\">\n <MMapFeatureInfo :results=\"results\" />\n </slot>\n </div>\n </MMapPopup>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Click-to-identify for an `MMap` with an `adapter`: a click on the map lists the features of the layers marked to\n * identify under it (with their formatted properties) in a popup, with a marker where the user clicked. The pointer\n * turns into a hand over those layers. The `identify` event carries the results, to show them in a panel of your own\n * instead (`:popup=\"false\"`, then `MMapFeatureInfo` in an `MWindow`). Available from the `/map` entry point.\n *\n * @slot default The popup's content instead of `MMapFeatureInfo` (scope: `{ results, lngLat, close }`)\n * @event identify The user clicked the map: what was found there (empty when nothing) and where (`[lng, lat]`)\n */\nimport { onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapPopup from './MMapPopup.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport MMapFeatureInfo from './MMapFeatureInfo.vue'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { identifyFeatures, type MapIdentifyResult } from '../composables/mapAdapters'\nimport { PIN_POPUP_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on the popup's content\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Listen to clicks. It also pauses by itself while another tool owns them (`MMapMeasure` measuring) */\n enabled?: boolean\n /** Show the results in a popup at the click */\n popup?: boolean\n /** Mark where the user clicked while there are results */\n marker?: boolean\n }>(),\n { enabled: true, popup: true, marker: true },\n)\n\nconst emit = defineEmits<{ identify: [results: MapIdentifyResult[], lngLat: [number, number]] }>()\n\nconst { on, onReady, activeTool } = useMap()\nconst { model } = useMapLayers()\n\nconst results = shallowRef<MapIdentifyResult[]>([])\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\non('click', (e) => {\n // Another tool (measuring…) owns the clicks\n if (!props.enabled || activeTool.value) return\n const map = e.target as Maplibre.Map\n results.value = identifyFeatures(map, e.point, model.value)\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = results.value.length > 0\n emit('identify', results.value, lngLat.value)\n})\n\nfunction close() {\n open.value = false\n}\nwatch(() => props.enabled, (enabled) => { if (!enabled) close() })\n\n// A hand over the layers that answer to a click\nlet map: Maplibre.Map | undefined\nlet hovered: string[] = []\nconst enter = () => { if (props.enabled && !activeTool.value && map) map.getCanvas().style.cursor = 'pointer' }\nconst leave = () => { if (map) map.getCanvas().style.cursor = '' }\nfunction bindCursor() {\n if (!map) return\n for (const id of hovered) {\n map.off('mouseenter', id, enter)\n map.off('mouseleave', id, leave)\n }\n hovered = (model.value?.layers ?? []).filter((l) => l.identify).map((l) => l.id)\n for (const id of hovered) {\n map.on('mouseenter', id, enter)\n map.on('mouseleave', id, leave)\n }\n}\nonReady((m) => {\n map = m\n bindCursor()\n})\nwatch(model, bindCursor)\nonBeforeUnmount(() => {\n hovered.forEach((id) => {\n map?.off('mouseenter', id, enter)\n map?.off('mouseleave', id, leave)\n })\n})\n\ndefineExpose({ close })\n</script>\n\n<template>\n <!-- One root (the marker and the popup move their content into the map) -->\n <div class=\"hidden\">\n <MMapMarker v-if=\"marker && open\" :lng-lat=\"lngLat\" />\n <MMapPopup v-if=\"popup && results.length\" v-model:open=\"open\" :lng-lat=\"lngLat\" max-width=\"360px\" :offset=\"marker ? PIN_POPUP_OFFSET : undefined\">\n <div class=\"max-h-80 overflow-y-auto\" v-bind=\"$attrs\">\n <slot :results=\"results\" :lng-lat=\"lngLat\" :close=\"close\">\n <MMapFeatureInfo :results=\"results\" />\n </slot>\n </div>\n </MMapPopup>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Hover info for an `MMap` with an `adapter`: while on (v-model), the layers with `hover` fields show them for the\n * feature under the pointer, in a small popup that follows it. With `control` (on by default) it adds its own on/off\n * button to the map's controls. Pointer devices only: touch has no hover. Available from the `/map` entry point.\n *\n * @event update:modelValue Turned on or off with its button\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapPopup from './MMapPopup.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { formatFieldValue, fieldLabel, type MapLayerInfo } from '../composables/mapAdapters'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** On (v-model) */\n modelValue?: boolean\n /** Its on/off button: `false`, or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: false, control: true },\n)\n\nconst emit = defineEmits<{ 'update:modelValue': [on: boolean] }>()\n\nconst t = useLocale()\nconst { onReady } = useMap()\nconst { model } = useMapLayers()\n\nconst hoverLayers = computed(() => (model.value?.layers ?? []).filter((l) => l.hover && l.hover.fields.length))\nconst shown = shallowRef<{ layer: MapLayerInfo; fields: { key: string; label: string; value: string }[] } | null>(null)\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\nlet map: Maplibre.Map | undefined\nlet bound: string[] = []\n\nfunction move(e: Maplibre.MapLayerMouseEvent) {\n const feature = e.features?.[0]\n const layer = hoverLayers.value.find((l) => l.id === feature?.layer.id)\n if (!feature || !layer || !layer.hover) return\n const props = feature.properties ?? {}\n shown.value = {\n layer,\n fields: layer.hover.fields\n .map((f) => ({ key: f.key, label: fieldLabel(f.key, f), value: formatFieldValue(props[f.key], f) }))\n .filter((f) => f.value),\n }\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = true\n}\nfunction leave() {\n open.value = false\n}\n\nfunction bind() {\n if (!map) return\n for (const id of bound) {\n map.off('mousemove', id, move)\n map.off('mouseleave', id, leave)\n }\n bound = props.modelValue ? hoverLayers.value.map((l) => l.id) : []\n for (const id of bound) {\n map.on('mousemove', id, move)\n map.on('mouseleave', id, leave)\n }\n if (!props.modelValue) open.value = false\n}\n\nonReady((m) => {\n map = m\n bind()\n})\nwatch([() => props.modelValue, hoverLayers], bind)\nonBeforeUnmount(() => {\n for (const id of bound) {\n map?.off('mousemove', id, move)\n map?.off('mouseleave', id, leave)\n }\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control && hoverLayers.length\" :position=\"corner\">\n <button\n type=\"button\"\n class=\"grid place-items-center\"\n :title=\"t.mapHoverInfo\"\n :aria-label=\"t.mapHoverInfo\"\n :aria-pressed=\"modelValue\"\n @click=\"emit('update:modelValue', !modelValue)\"\n >\n <MIcon name=\"ads_click\" :size=\"20\" />\n </button>\n </MMapControl>\n <MMapPopup\n v-if=\"shown\"\n v-model:open=\"open\"\n :lng-lat=\"lngLat\"\n :close-button=\"false\"\n :close-on-click=\"false\"\n :offset=\"12\"\n max-width=\"280px\"\n class=\"m3-map-hover\"\n >\n <p class=\"-mx-4 -mt-3 mb-1 bg-primary-container px-3 py-1.5 text-label-medium text-on-primary-container\">{{ shown.layer.title }}</p>\n <dl class=\"flex flex-col\">\n <div v-for=\"field in shown.fields\" :key=\"field.key\" class=\"border-b border-outline-variant py-1 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-small text-on-surface\">{{ field.value }}</dd>\n </div>\n </dl>\n </MMapPopup>\n </div>\n</template>\n\n<style>\n/* The hover popup ignores the pointer, so it never steals the mousemove that keeps it open */\n.maplibregl-popup:has(.m3-map-hover) {\n pointer-events: none;\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * Hover info for an `MMap` with an `adapter`: while on (v-model), the layers with `hover` fields show them for the\n * feature under the pointer, in a small popup that follows it. With `control` (on by default) it adds its own on/off\n * button to the map's controls. Pointer devices only: touch has no hover. Available from the `/map` entry point.\n *\n * @event update:modelValue Turned on or off with its button\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapPopup from './MMapPopup.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { formatFieldValue, fieldLabel, type MapLayerInfo } from '../composables/mapAdapters'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** On (v-model) */\n modelValue?: boolean\n /** Its on/off button: `false`, or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: false, control: true },\n)\n\nconst emit = defineEmits<{ 'update:modelValue': [on: boolean] }>()\n\nconst t = useLocale()\nconst { onReady } = useMap()\nconst { model } = useMapLayers()\n\nconst hoverLayers = computed(() => (model.value?.layers ?? []).filter((l) => l.hover && l.hover.fields.length))\nconst shown = shallowRef<{ layer: MapLayerInfo; fields: { key: string; label: string; value: string }[] } | null>(null)\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\nlet map: Maplibre.Map | undefined\nlet bound: string[] = []\n\nfunction move(e: Maplibre.MapLayerMouseEvent) {\n const feature = e.features?.[0]\n const layer = hoverLayers.value.find((l) => l.id === feature?.layer.id)\n if (!feature || !layer || !layer.hover) return\n const props = feature.properties ?? {}\n shown.value = {\n layer,\n fields: layer.hover.fields\n .map((f) => ({ key: f.key, label: fieldLabel(f.key, f), value: formatFieldValue(props[f.key], f) }))\n .filter((f) => f.value),\n }\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = true\n}\nfunction leave() {\n open.value = false\n}\n\nfunction bind() {\n if (!map) return\n for (const id of bound) {\n map.off('mousemove', id, move)\n map.off('mouseleave', id, leave)\n }\n bound = props.modelValue ? hoverLayers.value.map((l) => l.id) : []\n for (const id of bound) {\n map.on('mousemove', id, move)\n map.on('mouseleave', id, leave)\n }\n if (!props.modelValue) open.value = false\n}\n\nonReady((m) => {\n map = m\n bind()\n})\nwatch([() => props.modelValue, hoverLayers], bind)\nonBeforeUnmount(() => {\n for (const id of bound) {\n map?.off('mousemove', id, move)\n map?.off('mouseleave', id, leave)\n }\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control && hoverLayers.length\" :position=\"corner\">\n <button\n type=\"button\"\n class=\"grid place-items-center\"\n :title=\"t.mapHoverInfo\"\n :aria-label=\"t.mapHoverInfo\"\n :aria-pressed=\"modelValue\"\n @click=\"emit('update:modelValue', !modelValue)\"\n >\n <MIcon name=\"ads_click\" :size=\"20\" />\n </button>\n </MMapControl>\n <MMapPopup\n v-if=\"shown\"\n v-model:open=\"open\"\n :lng-lat=\"lngLat\"\n :close-button=\"false\"\n :close-on-click=\"false\"\n :offset=\"12\"\n max-width=\"280px\"\n class=\"m3-map-hover\"\n >\n <p class=\"-mx-4 -mt-3 mb-1 bg-primary-container px-3 py-1.5 text-label-medium text-on-primary-container\">{{ shown.layer.title }}</p>\n <dl class=\"flex flex-col\">\n <div v-for=\"field in shown.fields\" :key=\"field.key\" class=\"border-b border-outline-variant py-1 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-small text-on-surface\">{{ field.value }}</dd>\n </div>\n </dl>\n </MMapPopup>\n </div>\n</template>\n\n<style>\n/* The hover popup ignores the pointer, so it never steals the mousemove that keeps it open */\n.maplibregl-popup:has(.m3-map-hover) {\n pointer-events: none;\n}\n</style>\n","// Internal: the geodesy MMapMeasure needs, on a sphere of the Earth's mean radius (as @turf/length and @turf/area do,\n// so the numbers match what the Orvian viewers measured with turf)\n\nexport type LngLat = [number, number]\n\nconst R = 6371008.8 // meters\nconst RAD = Math.PI / 180\n\n/** Great-circle distance between two points, in meters (haversine). */\nexport function distance(a: LngLat, b: LngLat): number {\n const dLat = (b[1] - a[1]) * RAD\n const dLng = (b[0] - a[0]) * RAD\n const h = Math.sin(dLat / 2) ** 2 + Math.cos(a[1] * RAD) * Math.cos(b[1] * RAD) * Math.sin(dLng / 2) ** 2\n return 2 * R * Math.asin(Math.min(1, Math.sqrt(h)))\n}\n\n/** The length of a path, in meters. */\nexport function pathLength(points: LngLat[]): number {\n let total = 0\n for (let i = 1; i < points.length; i++) total += distance(points[i - 1]!, points[i]!)\n return total\n}\n\n/** The point halfway along the great circle between two points. */\nexport function midpoint(a: LngLat, b: LngLat): LngLat {\n const [l1, p1, l2, p2] = [a[0] * RAD, a[1] * RAD, b[0] * RAD, b[1] * RAD]\n const bx = Math.cos(p2) * Math.cos(l2 - l1)\n const by = Math.cos(p2) * Math.sin(l2 - l1)\n const lat = Math.atan2(Math.sin(p1) + Math.sin(p2), Math.sqrt((Math.cos(p1) + bx) ** 2 + by ** 2))\n const lng = l1 + Math.atan2(by, Math.cos(p1) + bx)\n return [lng / RAD, lat / RAD]\n}\n\n/** The area of a ring (closed or not), in square meters, on the sphere (@turf/area's formula). */\nexport function ringArea(points: LngLat[]): number {\n const ring = closeRing(points)\n const n = ring.length - 1\n if (n <= 2) return 0\n let total = 0\n for (let i = 0; i < n; i++) {\n const lower = ring[i]!\n const middle = ring[i + 1 === n ? 0 : i + 1]!\n const upper = ring[i + 2 >= n ? (i + 2) % n : i + 2]!\n total += (upper[0] - lower[0]) * RAD * Math.sin(middle[1] * RAD)\n }\n return Math.abs((total * R * R) / 2)\n}\n\n/** The ring with its first point repeated at the end. */\nexport function closeRing(points: LngLat[]): LngLat[] {\n const first = points[0]\n const last = points[points.length - 1]\n return first && last && (first[0] !== last[0] || first[1] !== last[1]) ? [...points, first] : points\n}\n\n/** Where to label a polygon: its area centroid (in degrees, fine at a measuring scale), or the vertices' mean. */\nexport function centroid(points: LngLat[]): LngLat {\n const ring = closeRing(points)\n let a = 0\n let x = 0\n let y = 0\n for (let i = 0; i < ring.length - 1; i++) {\n const [x0, y0] = ring[i]!\n const [x1, y1] = ring[i + 1]!\n const f = x0 * y1 - x1 * y0\n a += f\n x += (x0 + x1) * f\n y += (y0 + y1) * f\n }\n if (Math.abs(a) < 1e-12) {\n const pts = ring.slice(0, -1)\n return [pts.reduce((s, p) => s + p[0], 0) / pts.length, pts.reduce((s, p) => s + p[1], 0) / pts.length]\n }\n return [x / (3 * a), y / (3 * a)]\n}\n","<script setup lang=\"ts\">\n/**\n * Distance and area measuring on an `MMap`, with its own control (distance, area, clear). Click to add points (a\n * preview follows the pointer), double-click, Enter or Escape to finish, click the first point to close the shape, or\n * press the active button again (in fullscreen, Escape finishes it too where the browser allows: Chromium). Finished\n * measurements stay editable: drag a vertex, or a midpoint to add one; the ✕ on a total or area deletes that one.\n * Labels show each segment, the total and the area; everything follows the theme. While measuring it owns the map's clicks\n * (`MMapIdentify` waits). Geodesic numbers, the same as turf's. Available from the `/map` entry point.\n *\n * @event update:modelValue The measuring mode changed (`'distance'`, `'area'`, or null when it finished)\n * @event change The measurements changed (added, edited, cleared): each one's points, length in meters and area in m²\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { centroid, closeRing, distance, midpoint, pathLength, ringArea, type LngLat } from '../composables/_mapGeometry'\nimport type { MapControlPosition } from './MMap.vue'\n\ntype Mode = 'distance' | 'area'\n\nconst props = withDefaults(\n defineProps<{\n /** The measuring mode (v-model): `'distance'`, `'area'`, or null. Set it to start measuring from outside */\n modelValue?: Mode | null\n /** Its buttons: `false` (drive it with v-model), or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: null, control: true },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [mode: Mode | null]\n change: [measurements: { mode: Mode; points: LngLat[]; closed: boolean; length: number; area?: number }[]]\n}>()\n\nconst t = useLocale()\nconst { onReady, styleVersion, activeTool } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst id = `m3-measure-${useId()}`\nconst SRC = { done: `${id}-done`, draft: `${id}-draft`, handles: `${id}-handles` }\nconst VERTEX = `${SRC.handles}-vertex`\nconst MIDPOINT = `${SRC.handles}-midpoint`\n\ninterface Measurement { mode: Mode; points: LngLat[]; closed: boolean }\n// Plain state, stepped on every pointer move: only the labels and the buttons are reactive\nconst measurements: Measurement[] = []\nlet draft: LngLat[] = []\nlet cursor: LngLat | null = null\nlet closingByFirst = false\nlet drag: { m: number; v: number } | null = null\nlet raf = 0\nlet map: Maplibre.Map | undefined\n\nconst mode = ref<Mode | null>(null)\nconst count = ref(0)\n// `m`: the finished measurement a total or area label belongs to (it carries that one's delete button)\nconst labels = shallowRef<{ key: string; at: LngLat; text: string; kind: 'segment' | 'total' | 'area'; m?: number }[]>([])\n\n// ── Text ───────────────────────────────────────────────────────────────────────────────────────\n\nconst lang = () => (typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined)\nconst num = (n: number, digits: number) => new Intl.NumberFormat(lang(), { minimumFractionDigits: digits, maximumFractionDigits: digits }).format(n)\nconst fmtDistance = (m: number) => (m === 0 ? '' : m < 1000 ? `${num(Math.round(m), 0)} m` : `${num(m / 1000, 2)} km`)\nconst fmtArea = (m2: number) => (m2 >= 1e6 ? `${num(m2 / 1e6, 2)} km²` : m2 >= 1e4 ? `${num(m2 / 1e4, 2)} ha` : `${num(Math.round(m2), 0)} m²`)\n\n// ── GeoJSON ────────────────────────────────────────────────────────────────────────────────────\n\n// Just the GeoJSON this draws (the global GeoJSON namespace isn't always typed)\ntype Geometry = { type: 'Point'; coordinates: LngLat } | { type: 'LineString'; coordinates: LngLat[] } | { type: 'Polygon'; coordinates: LngLat[][] }\ntype Feature = { type: 'Feature'; geometry: Geometry; properties: Record<string, unknown> }\ntype Label = (typeof labels.value)[number]\nconst point = (p: LngLat, properties: Record<string, unknown> = {}): Feature => ({ type: 'Feature', geometry: { type: 'Point', coordinates: p }, properties })\n\n/** A measurement's shapes, and its labels. */\nfunction build(points: LngLat[], m: Mode, key: string, index?: number): { features: Feature[]; labels: Label[] } {\n const features: Feature[] = points.map((p) => point(p))\n const out: Label[] = []\n if (points.length < 2) return { features, labels: out }\n features.push({ type: 'Feature', geometry: { type: 'LineString', coordinates: points }, properties: {} })\n const segments = (path: LngLat[]) => {\n for (let i = 0; i < path.length - 1; i++) {\n const text = fmtDistance(distance(path[i]!, path[i + 1]!))\n if (text) out.push({ key: `${key}-s${i}`, at: midpoint(path[i]!, path[i + 1]!), text, kind: 'segment' })\n }\n }\n if (m === 'distance') {\n segments(points)\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: `${t.mapTotal}: ${fmtDistance(pathLength(points))}`, kind: 'total', m: index })\n } else if (points.length >= 3) {\n const ring = closeRing(points)\n features.push({ type: 'Feature', geometry: { type: 'Polygon', coordinates: [ring] }, properties: {} })\n segments(ring)\n out.push({ key: `${key}-a`, at: centroid(ring), text: fmtArea(ringArea(ring)), kind: 'area', m: index })\n } else {\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: fmtDistance(pathLength(points)), kind: 'total', m: index })\n }\n return { features, labels: out }\n}\n\nconst collection = (features: Feature[]) => ({ type: 'FeatureCollection' as const, features })\nconst setData = (source: string, features: Feature[]) => (map?.getSource(source) as Maplibre.GeoJSONSource | undefined)?.setData(collection(features))\n\nfunction render() {\n if (!map) return\n const done = measurements.map((m, i) => build(m.points, m.mode, `m${i}`, i))\n const preview = mode.value && draft.length ? build(cursor ? [...draft, cursor] : draft, mode.value, 'draft') : { features: [], labels: [] }\n setData(SRC.done, done.flatMap((d) => d.features))\n setData(SRC.draft, preview.features)\n // Edit handles while not drawing: every vertex, and every segment's midpoint\n const handles: Feature[] = []\n if (!mode.value) {\n measurements.forEach((m, mi) => {\n const vertices = m.closed ? m.points.slice(0, -1) : m.points\n vertices.forEach((p, vi) => handles.push(point(p, { handle: 'vertex', m: mi, v: vi })))\n for (let i = 0; i < m.points.length - 1; i++) handles.push(point(midpoint(m.points[i]!, m.points[i + 1]!), { handle: 'midpoint', m: mi, after: i }))\n })\n }\n setData(SRC.handles, handles)\n labels.value = [...done.flatMap((d) => d.labels), ...preview.labels]\n}\n\nfunction report() {\n count.value = measurements.length\n emit('change', measurements.map((m) => ({\n mode: m.mode,\n points: m.points.map((p) => [...p] as LngLat),\n closed: m.closed,\n length: pathLength(m.points),\n ...(m.mode === 'area' || m.closed ? { area: ringArea(m.points) } : {}),\n })))\n}\n\n// ── Layers ─────────────────────────────────────────────────────────────────────────────────────\n\nconst is = (type: string): Maplibre.FilterSpecification => ['==', ['geometry-type'], type]\n\nfunction paints() {\n const { primary, surface } = theme.value\n return {\n fill: { 'fill-color': primary },\n line: { 'line-color': primary },\n vertices: { 'circle-color': surface, 'circle-stroke-color': primary },\n }\n}\n\nfunction ensureLayers() {\n if (!map) return\n for (const source of Object.values(SRC)) {\n if (!map.getSource(source)) map.addSource(source, { type: 'geojson', data: collection([]) })\n }\n const p = paints()\n const add = (layer: Maplibre.LayerSpecification) => { if (!map!.getLayer(layer.id)) map!.addLayer(layer) }\n for (const [source, draftStyle] of [[SRC.done, false], [SRC.draft, true]] as const) {\n add({ id: `${source}-fill`, type: 'fill', source, filter: is('Polygon'), paint: { ...p.fill, 'fill-opacity': draftStyle ? 0.15 : 0.2 } })\n add({ id: `${source}-line`, type: 'line', source, filter: ['!=', ['geometry-type'], 'Point'], paint: { ...p.line, 'line-width': 3, ...(draftStyle ? { 'line-dasharray': [2, 2] } : {}) } })\n add({ id: `${source}-points`, type: 'circle', source, filter: is('Point'), paint: { ...p.vertices, 'circle-radius': 5, 'circle-stroke-width': 2 } })\n }\n add({ id: MIDPOINT, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'midpoint'], paint: { ...p.vertices, 'circle-radius': 4, 'circle-stroke-width': 1.5, 'circle-opacity': 0.7 } })\n add({ id: VERTEX, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'vertex'], paint: { ...p.vertices, 'circle-radius': 7, 'circle-stroke-width': 2.5 } })\n}\n\nwatch(theme, () => {\n if (!map) return\n const p = paints()\n const set = (layer: string, paint: Record<string, unknown>) => {\n if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k, v)\n }\n for (const source of [SRC.done, SRC.draft]) {\n set(`${source}-fill`, p.fill)\n set(`${source}-line`, p.line)\n set(`${source}-points`, p.vertices)\n }\n set(MIDPOINT, p.vertices)\n set(VERTEX, p.vertices)\n})\n\n// ── Measuring ──────────────────────────────────────────────────────────────────────────────────\n\nconst lngLatOf = (e: { lngLat: { lng: number; lat: number } }): LngLat => [e.lngLat.lng, e.lngLat.lat]\n\nfunction onClick(e: Maplibre.MapMouseEvent) {\n if (draft.length >= 2) {\n const first = map!.project(draft[0]!)\n if (Math.hypot(first.x - e.point.x, first.y - e.point.y) < 20) {\n closingByFirst = true\n finish()\n return\n }\n }\n draft.push(lngLatOf(e))\n render()\n}\n\nfunction onMove(e: Maplibre.MapMouseEvent) {\n cursor = lngLatOf(e)\n if (raf) return\n raf = requestAnimationFrame(() => {\n raf = 0\n render()\n })\n}\n\nfunction onDblClick(e: Maplibre.MapMouseEvent) {\n e.preventDefault()\n if (draft.length < 2) return\n // The double click's first click added a point on top of the last one\n const a = map!.project(draft[draft.length - 1]!)\n const b = map!.project(draft[draft.length - 2]!)\n if (Math.hypot(a.x - b.x, a.y - b.y) < 10) draft.pop()\n finish()\n}\n\n// Enter finishes; Escape goes through the library's stack, so measuring on a map in a dialog doesn't close it too\nfunction onKey(e: KeyboardEvent) {\n if (e.key === 'Enter') finish()\n}\nuseEscapeStack(() => !!mode.value, () => finish(true))\n\n// In fullscreen the browser keeps Escape to leave it, and the page never sees it. Keyboard Lock (Chromium) lets the\n// page have it while measuring, so Escape finishes the measurement (holding Escape still leaves fullscreen)\ntype KeyboardLock = { lock?: (keys: string[]) => Promise<void>; unlock?: () => void }\nconst keyboard = () => (typeof navigator !== 'undefined' ? (navigator as Navigator & { keyboard?: KeyboardLock }).keyboard : undefined)\nlet locked = false\nfunction lockEscape() {\n if (!mode.value || !document.fullscreenElement || !keyboard()?.lock) return\n keyboard()!.lock!(['Escape']).then(() => { locked = true }, () => {})\n}\nfunction unlockEscape() {\n // Measuring again by then: that measurement holds the lock now\n if (mode.value) return\n if (locked) keyboard()?.unlock?.()\n locked = false\n}\n// Released once the Escape that finished the measurement is let go: unlocking during its keydown hands the rest of\n// that press back to the browser, which then leaves fullscreen anyway\nfunction unlockAfterEscape() {\n let fallback: ReturnType<typeof setTimeout> | undefined\n const done = () => {\n document.removeEventListener('keyup', onUp, true)\n clearTimeout(fallback)\n setTimeout(unlockEscape)\n }\n const onUp = (e: KeyboardEvent) => { if (e.key === 'Escape') done() }\n document.addEventListener('keyup', onUp, true)\n fallback = setTimeout(done, 1500)\n}\n\nfunction start(next: Mode) {\n if (!map) return\n if (mode.value === next) return finish()\n if (mode.value) finish()\n mode.value = next\n activeTool.value = 'measure'\n draft = []\n cursor = null\n map.getCanvas().style.cursor = 'crosshair'\n map.doubleClickZoom.disable()\n map.on('click', onClick)\n map.on('mousemove', onMove)\n map.on('dblclick', onDblClick)\n document.addEventListener('keydown', onKey)\n document.addEventListener('fullscreenchange', lockEscape)\n lockEscape()\n render()\n if (props.modelValue !== next) emit('update:modelValue', next)\n}\n\nfunction finish(byEscape = false) {\n if (!map || !mode.value) return\n cancelAnimationFrame(raf)\n raf = 0\n const closed = draft.length >= 3 && (closingByFirst || mode.value === 'area')\n if (draft.length >= 2) {\n measurements.push({ mode: mode.value, points: closed ? [...draft, [...draft[0]!] as LngLat] : draft, closed })\n }\n draft = []\n cursor = null\n closingByFirst = false\n mode.value = null\n if (activeTool.value === 'measure') activeTool.value = null\n map.getCanvas().style.cursor = ''\n map.doubleClickZoom.enable()\n map.off('click', onClick)\n map.off('mousemove', onMove)\n map.off('dblclick', onDblClick)\n document.removeEventListener('keydown', onKey)\n document.removeEventListener('fullscreenchange', lockEscape)\n if (byEscape && locked) unlockAfterEscape()\n else unlockEscape()\n render()\n report()\n if (props.modelValue !== null) emit('update:modelValue', null)\n}\n\n/** Deletes one finished measurement. */\nfunction remove(index: number) {\n if (!measurements[index]) return\n measurements.splice(index, 1)\n render()\n report()\n}\n\nfunction clear() {\n if (mode.value) finish()\n measurements.length = 0\n render()\n report()\n}\n\n// ── Editing ────────────────────────────────────────────────────────────────────────────────────\n\ntype HandleEvent = (Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) & { features?: Maplibre.MapGeoJSONFeature[] }\n\nfunction onHandleDown(e: HandleEvent) {\n const f = e.features?.[0]\n if (!f || mode.value || !map) return\n e.preventDefault()\n const mi = f.properties.m as number\n const m = measurements[mi]\n if (!m) return\n let vi = f.properties.v as number\n if (f.properties.handle === 'midpoint') {\n vi = (f.properties.after as number) + 1\n m.points.splice(vi, 0, lngLatOf(e))\n }\n drag = { m: mi, v: vi }\n activeTool.value = 'measure'\n map.getCanvas().style.cursor = 'grabbing'\n const touch = e.type === 'touchstart'\n if (touch) map.dragPan.disable()\n map.on(touch ? 'touchmove' : 'mousemove', onDragMove)\n map.once(touch ? 'touchend' : 'mouseup', onDragEnd)\n render()\n}\n\nfunction onDragMove(e: Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) {\n if (!drag) return\n const m = measurements[drag.m]\n if (!m) return\n const p = lngLatOf(e)\n m.points[drag.v] = p\n if (m.closed && drag.v === 0) m.points[m.points.length - 1] = p\n render()\n}\n\nfunction onDragEnd() {\n if (!map) return\n drag = null\n map.off('mousemove', onDragMove)\n map.off('touchmove', onDragMove)\n map.dragPan.enable()\n map.getCanvas().style.cursor = ''\n report()\n // The click that ends a press comes after mouseup: keep it from MMapIdentify\n setTimeout(() => { if (activeTool.value === 'measure' && !mode.value) activeTool.value = null })\n}\n\nconst onHandleEnter = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = 'grab' }\nconst onHandleLeave = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = '' }\n\nonReady((m) => {\n map = m\n ensureLayers()\n for (const layer of [VERTEX, MIDPOINT]) {\n m.on('mousedown', layer, onHandleDown)\n m.on('touchstart', layer, onHandleDown)\n m.on('mouseenter', layer, onHandleEnter)\n m.on('mouseleave', layer, onHandleLeave)\n }\n if (props.modelValue) start(props.modelValue)\n})\nwatch(styleVersion, () => {\n ensureLayers()\n render()\n})\nwatch(() => props.modelValue, (next) => {\n if (next && next !== mode.value) start(next)\n else if (!next && mode.value) finish()\n})\n\nonBeforeUnmount(() => {\n if (!map) return\n if (mode.value) finish()\n for (const layer of [VERTEX, MIDPOINT]) {\n map.off('mousedown', layer, onHandleDown)\n map.off('touchstart', layer, onHandleDown)\n map.off('mouseenter', layer, onHandleEnter)\n map.off('mouseleave', layer, onHandleLeave)\n }\n const layers = [VERTEX, MIDPOINT, ...[SRC.done, SRC.draft].flatMap((s) => [`${s}-points`, `${s}-line`, `${s}-fill`])]\n for (const layer of layers) if (map.getLayer(layer)) map.removeLayer(layer)\n for (const source of Object.values(SRC)) if (map.getSource(source)) map.removeSource(source)\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n\ndefineExpose({ start, finish, clear, remove })\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control\" :position=\"corner\">\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureDistance\" :aria-pressed=\"mode === 'distance'\" @click=\"start('distance')\">\n <MIcon name=\"straighten\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureArea\" :aria-pressed=\"mode === 'area'\" @click=\"start('area')\">\n <MIcon name=\"pentagon\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapClearMeasurements\" :disabled=\"!count && !mode\" @click=\"clear\">\n <MIcon name=\"delete\" :size=\"20\" />\n </button>\n </MMapControl>\n <!-- Labels: M3 chips that let the pointer through to the map -->\n <MMapMarker\n v-for=\"label in labels\"\n :key=\"label.key\"\n :lng-lat=\"label.at\"\n :anchor=\"label.kind === 'area' ? 'center' : 'top'\"\n :offset=\"label.kind === 'area' ? [0, 0] : [0, 8]\"\n class=\"pointer-events-none\"\n >\n <span\n class=\"flex items-center gap-1 whitespace-nowrap rounded-full py-0.5 shadow-elevation-1\"\n :class=\"[\n label.kind === 'segment' ? 'bg-surface-container-highest text-label-small text-on-surface' : 'bg-primary text-label-medium text-on-primary',\n label.m !== undefined ? 'pr-0.5 pl-2' : 'px-2',\n ]\"\n >\n {{ label.text }}\n <!-- Deletes this measurement; it catches its own pointer, so the map neither pans nor gets a click -->\n <button\n v-if=\"label.m !== undefined\"\n type=\"button\"\n class=\"pointer-events-auto grid size-5 cursor-pointer place-items-center rounded-full hover:bg-on-primary/12 focus-visible:outline-2 focus-visible:outline-on-primary\"\n :aria-label=\"t.mapDeleteMeasurement\"\n :title=\"t.mapDeleteMeasurement\"\n @click.stop=\"remove(label.m)\"\n @pointerdown.stop\n @mousedown.stop\n @touchstart.stop\n @dblclick.stop\n >\n <MIcon name=\"close\" :size=\"14\" />\n </button>\n </span>\n </MMapMarker>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Distance and area measuring on an `MMap`, with its own control (distance, area, clear). Click to add points (a\n * preview follows the pointer), double-click, Enter or Escape to finish, click the first point to close the shape, or\n * press the active button again (in fullscreen, Escape finishes it too where the browser allows: Chromium). Finished\n * measurements stay editable: drag a vertex, or a midpoint to add one; the ✕ on a total or area deletes that one.\n * Labels show each segment, the total and the area; everything follows the theme. While measuring it owns the map's clicks\n * (`MMapIdentify` waits). Geodesic numbers, the same as turf's. Available from the `/map` entry point.\n *\n * @event update:modelValue The measuring mode changed (`'distance'`, `'area'`, or null when it finished)\n * @event change The measurements changed (added, edited, cleared): each one's points, length in meters and area in m²\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { centroid, closeRing, distance, midpoint, pathLength, ringArea, type LngLat } from '../composables/_mapGeometry'\nimport type { MapControlPosition } from './MMap.vue'\n\ntype Mode = 'distance' | 'area'\n\nconst props = withDefaults(\n defineProps<{\n /** The measuring mode (v-model): `'distance'`, `'area'`, or null. Set it to start measuring from outside */\n modelValue?: Mode | null\n /** Its buttons: `false` (drive it with v-model), or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: null, control: true },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [mode: Mode | null]\n change: [measurements: { mode: Mode; points: LngLat[]; closed: boolean; length: number; area?: number }[]]\n}>()\n\nconst t = useLocale()\nconst { onReady, styleVersion, activeTool } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst id = `m3-measure-${useId()}`\nconst SRC = { done: `${id}-done`, draft: `${id}-draft`, handles: `${id}-handles` }\nconst VERTEX = `${SRC.handles}-vertex`\nconst MIDPOINT = `${SRC.handles}-midpoint`\n\ninterface Measurement { mode: Mode; points: LngLat[]; closed: boolean }\n// Plain state, stepped on every pointer move: only the labels and the buttons are reactive\nconst measurements: Measurement[] = []\nlet draft: LngLat[] = []\nlet cursor: LngLat | null = null\nlet closingByFirst = false\nlet drag: { m: number; v: number } | null = null\nlet raf = 0\nlet map: Maplibre.Map | undefined\n\nconst mode = ref<Mode | null>(null)\nconst count = ref(0)\n// `m`: the finished measurement a total or area label belongs to (it carries that one's delete button)\nconst labels = shallowRef<{ key: string; at: LngLat; text: string; kind: 'segment' | 'total' | 'area'; m?: number }[]>([])\n\n// ── Text ───────────────────────────────────────────────────────────────────────────────────────\n\nconst lang = () => (typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined)\nconst num = (n: number, digits: number) => new Intl.NumberFormat(lang(), { minimumFractionDigits: digits, maximumFractionDigits: digits }).format(n)\nconst fmtDistance = (m: number) => (m === 0 ? '' : m < 1000 ? `${num(Math.round(m), 0)} m` : `${num(m / 1000, 2)} km`)\nconst fmtArea = (m2: number) => (m2 >= 1e6 ? `${num(m2 / 1e6, 2)} km²` : m2 >= 1e4 ? `${num(m2 / 1e4, 2)} ha` : `${num(Math.round(m2), 0)} m²`)\n\n// ── GeoJSON ────────────────────────────────────────────────────────────────────────────────────\n\n// Just the GeoJSON this draws (the global GeoJSON namespace isn't always typed)\ntype Geometry = { type: 'Point'; coordinates: LngLat } | { type: 'LineString'; coordinates: LngLat[] } | { type: 'Polygon'; coordinates: LngLat[][] }\ntype Feature = { type: 'Feature'; geometry: Geometry; properties: Record<string, unknown> }\ntype Label = (typeof labels.value)[number]\nconst point = (p: LngLat, properties: Record<string, unknown> = {}): Feature => ({ type: 'Feature', geometry: { type: 'Point', coordinates: p }, properties })\n\n/** A measurement's shapes, and its labels. */\nfunction build(points: LngLat[], m: Mode, key: string, index?: number): { features: Feature[]; labels: Label[] } {\n const features: Feature[] = points.map((p) => point(p))\n const out: Label[] = []\n if (points.length < 2) return { features, labels: out }\n features.push({ type: 'Feature', geometry: { type: 'LineString', coordinates: points }, properties: {} })\n const segments = (path: LngLat[]) => {\n for (let i = 0; i < path.length - 1; i++) {\n const text = fmtDistance(distance(path[i]!, path[i + 1]!))\n if (text) out.push({ key: `${key}-s${i}`, at: midpoint(path[i]!, path[i + 1]!), text, kind: 'segment' })\n }\n }\n if (m === 'distance') {\n segments(points)\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: `${t.mapTotal}: ${fmtDistance(pathLength(points))}`, kind: 'total', m: index })\n } else if (points.length >= 3) {\n const ring = closeRing(points)\n features.push({ type: 'Feature', geometry: { type: 'Polygon', coordinates: [ring] }, properties: {} })\n segments(ring)\n out.push({ key: `${key}-a`, at: centroid(ring), text: fmtArea(ringArea(ring)), kind: 'area', m: index })\n } else {\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: fmtDistance(pathLength(points)), kind: 'total', m: index })\n }\n return { features, labels: out }\n}\n\nconst collection = (features: Feature[]) => ({ type: 'FeatureCollection' as const, features })\nconst setData = (source: string, features: Feature[]) => (map?.getSource(source) as Maplibre.GeoJSONSource | undefined)?.setData(collection(features))\n\nfunction render() {\n if (!map) return\n const done = measurements.map((m, i) => build(m.points, m.mode, `m${i}`, i))\n const preview = mode.value && draft.length ? build(cursor ? [...draft, cursor] : draft, mode.value, 'draft') : { features: [], labels: [] }\n setData(SRC.done, done.flatMap((d) => d.features))\n setData(SRC.draft, preview.features)\n // Edit handles while not drawing: every vertex, and every segment's midpoint\n const handles: Feature[] = []\n if (!mode.value) {\n measurements.forEach((m, mi) => {\n const vertices = m.closed ? m.points.slice(0, -1) : m.points\n vertices.forEach((p, vi) => handles.push(point(p, { handle: 'vertex', m: mi, v: vi })))\n for (let i = 0; i < m.points.length - 1; i++) handles.push(point(midpoint(m.points[i]!, m.points[i + 1]!), { handle: 'midpoint', m: mi, after: i }))\n })\n }\n setData(SRC.handles, handles)\n labels.value = [...done.flatMap((d) => d.labels), ...preview.labels]\n}\n\nfunction report() {\n count.value = measurements.length\n emit('change', measurements.map((m) => ({\n mode: m.mode,\n points: m.points.map((p) => [...p] as LngLat),\n closed: m.closed,\n length: pathLength(m.points),\n ...(m.mode === 'area' || m.closed ? { area: ringArea(m.points) } : {}),\n })))\n}\n\n// ── Layers ─────────────────────────────────────────────────────────────────────────────────────\n\nconst is = (type: string): Maplibre.FilterSpecification => ['==', ['geometry-type'], type]\n\nfunction paints() {\n const { primary, surface } = theme.value\n return {\n fill: { 'fill-color': primary },\n line: { 'line-color': primary },\n vertices: { 'circle-color': surface, 'circle-stroke-color': primary },\n }\n}\n\nfunction ensureLayers() {\n if (!map) return\n for (const source of Object.values(SRC)) {\n if (!map.getSource(source)) map.addSource(source, { type: 'geojson', data: collection([]) })\n }\n const p = paints()\n const add = (layer: Maplibre.LayerSpecification) => { if (!map!.getLayer(layer.id)) map!.addLayer(layer) }\n for (const [source, draftStyle] of [[SRC.done, false], [SRC.draft, true]] as const) {\n add({ id: `${source}-fill`, type: 'fill', source, filter: is('Polygon'), paint: { ...p.fill, 'fill-opacity': draftStyle ? 0.15 : 0.2 } })\n add({ id: `${source}-line`, type: 'line', source, filter: ['!=', ['geometry-type'], 'Point'], paint: { ...p.line, 'line-width': 3, ...(draftStyle ? { 'line-dasharray': [2, 2] } : {}) } })\n add({ id: `${source}-points`, type: 'circle', source, filter: is('Point'), paint: { ...p.vertices, 'circle-radius': 5, 'circle-stroke-width': 2 } })\n }\n add({ id: MIDPOINT, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'midpoint'], paint: { ...p.vertices, 'circle-radius': 4, 'circle-stroke-width': 1.5, 'circle-opacity': 0.7 } })\n add({ id: VERTEX, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'vertex'], paint: { ...p.vertices, 'circle-radius': 7, 'circle-stroke-width': 2.5 } })\n}\n\nwatch(theme, () => {\n if (!map) return\n const p = paints()\n const set = (layer: string, paint: Record<string, unknown>) => {\n if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k, v)\n }\n for (const source of [SRC.done, SRC.draft]) {\n set(`${source}-fill`, p.fill)\n set(`${source}-line`, p.line)\n set(`${source}-points`, p.vertices)\n }\n set(MIDPOINT, p.vertices)\n set(VERTEX, p.vertices)\n})\n\n// ── Measuring ──────────────────────────────────────────────────────────────────────────────────\n\nconst lngLatOf = (e: { lngLat: { lng: number; lat: number } }): LngLat => [e.lngLat.lng, e.lngLat.lat]\n\nfunction onClick(e: Maplibre.MapMouseEvent) {\n if (draft.length >= 2) {\n const first = map!.project(draft[0]!)\n if (Math.hypot(first.x - e.point.x, first.y - e.point.y) < 20) {\n closingByFirst = true\n finish()\n return\n }\n }\n draft.push(lngLatOf(e))\n render()\n}\n\nfunction onMove(e: Maplibre.MapMouseEvent) {\n cursor = lngLatOf(e)\n if (raf) return\n raf = requestAnimationFrame(() => {\n raf = 0\n render()\n })\n}\n\nfunction onDblClick(e: Maplibre.MapMouseEvent) {\n e.preventDefault()\n if (draft.length < 2) return\n // The double click's first click added a point on top of the last one\n const a = map!.project(draft[draft.length - 1]!)\n const b = map!.project(draft[draft.length - 2]!)\n if (Math.hypot(a.x - b.x, a.y - b.y) < 10) draft.pop()\n finish()\n}\n\n// Enter finishes; Escape goes through the library's stack, so measuring on a map in a dialog doesn't close it too\nfunction onKey(e: KeyboardEvent) {\n if (e.key === 'Enter') finish()\n}\nuseEscapeStack(() => !!mode.value, () => finish(true))\n\n// In fullscreen the browser keeps Escape to leave it, and the page never sees it. Keyboard Lock (Chromium) lets the\n// page have it while measuring, so Escape finishes the measurement (holding Escape still leaves fullscreen)\ntype KeyboardLock = { lock?: (keys: string[]) => Promise<void>; unlock?: () => void }\nconst keyboard = () => (typeof navigator !== 'undefined' ? (navigator as Navigator & { keyboard?: KeyboardLock }).keyboard : undefined)\nlet locked = false\nfunction lockEscape() {\n if (!mode.value || !document.fullscreenElement || !keyboard()?.lock) return\n keyboard()!.lock!(['Escape']).then(() => { locked = true }, () => {})\n}\nfunction unlockEscape() {\n // Measuring again by then: that measurement holds the lock now\n if (mode.value) return\n if (locked) keyboard()?.unlock?.()\n locked = false\n}\n// Released once the Escape that finished the measurement is let go: unlocking during its keydown hands the rest of\n// that press back to the browser, which then leaves fullscreen anyway\nfunction unlockAfterEscape() {\n let fallback: ReturnType<typeof setTimeout> | undefined\n const done = () => {\n document.removeEventListener('keyup', onUp, true)\n clearTimeout(fallback)\n setTimeout(unlockEscape)\n }\n const onUp = (e: KeyboardEvent) => { if (e.key === 'Escape') done() }\n document.addEventListener('keyup', onUp, true)\n fallback = setTimeout(done, 1500)\n}\n\nfunction start(next: Mode) {\n if (!map) return\n if (mode.value === next) return finish()\n if (mode.value) finish()\n mode.value = next\n activeTool.value = 'measure'\n draft = []\n cursor = null\n map.getCanvas().style.cursor = 'crosshair'\n map.doubleClickZoom.disable()\n map.on('click', onClick)\n map.on('mousemove', onMove)\n map.on('dblclick', onDblClick)\n document.addEventListener('keydown', onKey)\n document.addEventListener('fullscreenchange', lockEscape)\n lockEscape()\n render()\n if (props.modelValue !== next) emit('update:modelValue', next)\n}\n\nfunction finish(byEscape = false) {\n if (!map || !mode.value) return\n cancelAnimationFrame(raf)\n raf = 0\n const closed = draft.length >= 3 && (closingByFirst || mode.value === 'area')\n if (draft.length >= 2) {\n measurements.push({ mode: mode.value, points: closed ? [...draft, [...draft[0]!] as LngLat] : draft, closed })\n }\n draft = []\n cursor = null\n closingByFirst = false\n mode.value = null\n if (activeTool.value === 'measure') activeTool.value = null\n map.getCanvas().style.cursor = ''\n map.doubleClickZoom.enable()\n map.off('click', onClick)\n map.off('mousemove', onMove)\n map.off('dblclick', onDblClick)\n document.removeEventListener('keydown', onKey)\n document.removeEventListener('fullscreenchange', lockEscape)\n if (byEscape && locked) unlockAfterEscape()\n else unlockEscape()\n render()\n report()\n if (props.modelValue !== null) emit('update:modelValue', null)\n}\n\n/** Deletes one finished measurement. */\nfunction remove(index: number) {\n if (!measurements[index]) return\n measurements.splice(index, 1)\n render()\n report()\n}\n\nfunction clear() {\n if (mode.value) finish()\n measurements.length = 0\n render()\n report()\n}\n\n// ── Editing ────────────────────────────────────────────────────────────────────────────────────\n\ntype HandleEvent = (Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) & { features?: Maplibre.MapGeoJSONFeature[] }\n\nfunction onHandleDown(e: HandleEvent) {\n const f = e.features?.[0]\n if (!f || mode.value || !map) return\n e.preventDefault()\n const mi = f.properties.m as number\n const m = measurements[mi]\n if (!m) return\n let vi = f.properties.v as number\n if (f.properties.handle === 'midpoint') {\n vi = (f.properties.after as number) + 1\n m.points.splice(vi, 0, lngLatOf(e))\n }\n drag = { m: mi, v: vi }\n activeTool.value = 'measure'\n map.getCanvas().style.cursor = 'grabbing'\n const touch = e.type === 'touchstart'\n if (touch) map.dragPan.disable()\n map.on(touch ? 'touchmove' : 'mousemove', onDragMove)\n map.once(touch ? 'touchend' : 'mouseup', onDragEnd)\n render()\n}\n\nfunction onDragMove(e: Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) {\n if (!drag) return\n const m = measurements[drag.m]\n if (!m) return\n const p = lngLatOf(e)\n m.points[drag.v] = p\n if (m.closed && drag.v === 0) m.points[m.points.length - 1] = p\n render()\n}\n\nfunction onDragEnd() {\n if (!map) return\n drag = null\n map.off('mousemove', onDragMove)\n map.off('touchmove', onDragMove)\n map.dragPan.enable()\n map.getCanvas().style.cursor = ''\n report()\n // The click that ends a press comes after mouseup: keep it from MMapIdentify\n setTimeout(() => { if (activeTool.value === 'measure' && !mode.value) activeTool.value = null })\n}\n\nconst onHandleEnter = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = 'grab' }\nconst onHandleLeave = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = '' }\n\nonReady((m) => {\n map = m\n ensureLayers()\n for (const layer of [VERTEX, MIDPOINT]) {\n m.on('mousedown', layer, onHandleDown)\n m.on('touchstart', layer, onHandleDown)\n m.on('mouseenter', layer, onHandleEnter)\n m.on('mouseleave', layer, onHandleLeave)\n }\n if (props.modelValue) start(props.modelValue)\n})\nwatch(styleVersion, () => {\n ensureLayers()\n render()\n})\nwatch(() => props.modelValue, (next) => {\n if (next && next !== mode.value) start(next)\n else if (!next && mode.value) finish()\n})\n\nonBeforeUnmount(() => {\n if (!map) return\n if (mode.value) finish()\n for (const layer of [VERTEX, MIDPOINT]) {\n map.off('mousedown', layer, onHandleDown)\n map.off('touchstart', layer, onHandleDown)\n map.off('mouseenter', layer, onHandleEnter)\n map.off('mouseleave', layer, onHandleLeave)\n }\n const layers = [VERTEX, MIDPOINT, ...[SRC.done, SRC.draft].flatMap((s) => [`${s}-points`, `${s}-line`, `${s}-fill`])]\n for (const layer of layers) if (map.getLayer(layer)) map.removeLayer(layer)\n for (const source of Object.values(SRC)) if (map.getSource(source)) map.removeSource(source)\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n\ndefineExpose({ start, finish, clear, remove })\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control\" :position=\"corner\">\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureDistance\" :aria-pressed=\"mode === 'distance'\" @click=\"start('distance')\">\n <MIcon name=\"straighten\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureArea\" :aria-pressed=\"mode === 'area'\" @click=\"start('area')\">\n <MIcon name=\"pentagon\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapClearMeasurements\" :disabled=\"!count && !mode\" @click=\"clear\">\n <MIcon name=\"delete\" :size=\"20\" />\n </button>\n </MMapControl>\n <!-- Labels: M3 chips that let the pointer through to the map -->\n <MMapMarker\n v-for=\"label in labels\"\n :key=\"label.key\"\n :lng-lat=\"label.at\"\n :anchor=\"label.kind === 'area' ? 'center' : 'top'\"\n :offset=\"label.kind === 'area' ? [0, 0] : [0, 8]\"\n class=\"pointer-events-none\"\n >\n <span\n class=\"flex items-center gap-1 whitespace-nowrap rounded-full py-0.5 shadow-elevation-1\"\n :class=\"[\n label.kind === 'segment' ? 'bg-surface-container-highest text-label-small text-on-surface' : 'bg-primary text-label-medium text-on-primary',\n label.m !== undefined ? 'pr-0.5 pl-2' : 'px-2',\n ]\"\n >\n {{ label.text }}\n <!-- Deletes this measurement; it catches its own pointer, so the map neither pans nor gets a click -->\n <button\n v-if=\"label.m !== undefined\"\n type=\"button\"\n class=\"pointer-events-auto grid size-5 cursor-pointer place-items-center rounded-full hover:bg-on-primary/12 focus-visible:outline-2 focus-visible:outline-on-primary\"\n :aria-label=\"t.mapDeleteMeasurement\"\n :title=\"t.mapDeleteMeasurement\"\n @click.stop=\"remove(label.m)\"\n @pointerdown.stop\n @mousedown.stop\n @touchstart.stop\n @dblclick.stop\n >\n <MIcon name=\"close\" :size=\"14\" />\n </button>\n </span>\n </MMapMarker>\n </div>\n</template>\n","import type { MaybeRefOrGetter } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { resolveMapContext, type MapSource } from './useMap'\n\n// The style's own filter of each layer we filter (undefined: none), per map\nconst originals = new WeakMap<Maplibre.Map, Map<string, Maplibre.FilterSpecification | undefined>>()\n\n/**\n * Filters for the layers of the enclosing `MMap`, on top of the filters their style already has (a layer that only\n * draws parks keeps doing so): `setFilter(layer, expression)` combines both, `setFilter(layer, null)` brings the\n * style's back. `MMapFilter` is built on it; use it for filters of your own (a range slider, a date, a search…).\n * Outside an `MMap`, pass it one (its template ref), as with `useMap`.\n */\nexport function useMapFilter(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMapFilter() must be called in a component inside <MMap>, or be given one')\n\n function setFilter(layerId: string, filter: Maplibre.FilterSpecification | null) {\n const map = ctx!.map.value\n if (!map?.getLayer(layerId)) return\n let saved = originals.get(map)\n if (!saved) originals.set(map, (saved = new Map()))\n if (!saved.has(layerId)) saved.set(layerId, map.getFilter(layerId) ?? undefined)\n const original = saved.get(layerId)\n map.setFilter(layerId, filter ? (original ? ['all', original, filter] : filter) as Maplibre.FilterSpecification : original ?? null)\n }\n\n /**\n * The distinct values of a property among a layer's features loaded in the map (for vector tiles, the tiles in\n * view), sorted.\n */\n function valuesOf(layerId: string, property: string): (string | number)[] {\n const map = ctx!.map.value\n const layer = map?.getLayer(layerId) as (Maplibre.StyleLayer & { source?: string; sourceLayer?: string }) | undefined\n if (!map || !layer?.source) return []\n const features = map.querySourceFeatures(layer.source, layer.sourceLayer ? { sourceLayer: layer.sourceLayer } : undefined)\n const values = new Set<string | number>()\n for (const f of features) {\n const v = f.properties?.[property]\n if (typeof v === 'string' || typeof v === 'number') values.add(v)\n }\n return [...values].sort((a, b) => (typeof a === 'number' && typeof b === 'number' ? a - b : String(a).localeCompare(String(b))))\n }\n\n return { setFilter, valuesOf }\n}\n","<script setup lang=\"ts\">\n/**\n * A simple filter for one layer of an `MMap`: chips for the values of one of its properties; the layer shows only the\n * features with the selected ones (all of them with none selected). The values are `values`, or else the distinct\n * ones among the layer's features loaded in the map. The style's own filter on the layer stays. For anything more\n * involved, build your own on `useMapFilter()`. Inside the `MMap`, or anywhere else with `map`. Available from the `/map`\n * entry point.\n */\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport MChip from './MChip.vue'\nimport { useMap, type MapSource } from '../composables/useMap'\nimport { useMapFilter } from '../composables/useMapFilter'\n\nconst props = defineProps<{\n /** The layer's id */\n layer: string\n /** The property to filter by */\n property: string\n /** The values to offer (labels in `labels`); by default the ones found in the layer's loaded features */\n values?: (string | number)[]\n /** Labels for the values, by value */\n labels?: Record<string, string>\n /** The selected values (v-model) */\n modelValue?: (string | number)[]\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n}>()\n\nconst emit = defineEmits<{ 'update:modelValue': [values: (string | number)[]] }>()\n\nconst { onReady, styleVersion } = useMap(() => props.map)\nconst { setFilter, valuesOf } = useMapFilter(() => props.map)\n\nconst found = ref<(string | number)[]>([])\nconst options = computed(() => props.values ?? found.value)\nconst local = ref<(string | number)[]>([])\nconst selected = computed(() => props.modelValue ?? local.value)\n\nfunction apply() {\n const values = selected.value\n setFilter(props.layer, values.length ? ['in', ['get', props.property], ['literal', values]] : null)\n}\n\nfunction toggle(value: string | number) {\n const next = selected.value.includes(value) ? selected.value.filter((v) => v !== value) : [...selected.value, value]\n local.value = next\n emit('update:modelValue', next)\n}\n\nfunction refreshValues(map: { once: (type: 'idle', fn: () => void) => unknown }) {\n const read = () => { if (!props.values) found.value = valuesOf(props.layer, props.property) }\n read()\n // And once the layer's data is in, if it wasn't yet (tiles load after the style)\n map.once('idle', read)\n}\n\nonReady((map) => {\n refreshValues(map)\n apply()\n})\nwatch(selected, apply, { deep: true })\nwatch(styleVersion, () => apply())\nwatch(() => [props.layer, props.property], ([layer], [old]) => {\n if (layer !== old) setFilter(old as string, null)\n apply()\n})\nonBeforeUnmount(() => setFilter(props.layer, null))\n</script>\n\n<template>\n <div class=\"flex flex-wrap gap-2\">\n <MChip\n v-for=\"value in options\"\n :key=\"value\"\n type=\"filter\"\n clickable\n :selected=\"selected.includes(value)\"\n @click=\"toggle(value)\"\n >\n {{ labels?.[String(value)] ?? value }}\n </MChip>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A simple filter for one layer of an `MMap`: chips for the values of one of its properties; the layer shows only the\n * features with the selected ones (all of them with none selected). The values are `values`, or else the distinct\n * ones among the layer's features loaded in the map. The style's own filter on the layer stays. For anything more\n * involved, build your own on `useMapFilter()`. Inside the `MMap`, or anywhere else with `map`. Available from the `/map`\n * entry point.\n */\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport MChip from './MChip.vue'\nimport { useMap, type MapSource } from '../composables/useMap'\nimport { useMapFilter } from '../composables/useMapFilter'\n\nconst props = defineProps<{\n /** The layer's id */\n layer: string\n /** The property to filter by */\n property: string\n /** The values to offer (labels in `labels`); by default the ones found in the layer's loaded features */\n values?: (string | number)[]\n /** Labels for the values, by value */\n labels?: Record<string, string>\n /** The selected values (v-model) */\n modelValue?: (string | number)[]\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n}>()\n\nconst emit = defineEmits<{ 'update:modelValue': [values: (string | number)[]] }>()\n\nconst { onReady, styleVersion } = useMap(() => props.map)\nconst { setFilter, valuesOf } = useMapFilter(() => props.map)\n\nconst found = ref<(string | number)[]>([])\nconst options = computed(() => props.values ?? found.value)\nconst local = ref<(string | number)[]>([])\nconst selected = computed(() => props.modelValue ?? local.value)\n\nfunction apply() {\n const values = selected.value\n setFilter(props.layer, values.length ? ['in', ['get', props.property], ['literal', values]] : null)\n}\n\nfunction toggle(value: string | number) {\n const next = selected.value.includes(value) ? selected.value.filter((v) => v !== value) : [...selected.value, value]\n local.value = next\n emit('update:modelValue', next)\n}\n\nfunction refreshValues(map: { once: (type: 'idle', fn: () => void) => unknown }) {\n const read = () => { if (!props.values) found.value = valuesOf(props.layer, props.property) }\n read()\n // And once the layer's data is in, if it wasn't yet (tiles load after the style)\n map.once('idle', read)\n}\n\nonReady((map) => {\n refreshValues(map)\n apply()\n})\nwatch(selected, apply, { deep: true })\nwatch(styleVersion, () => apply())\nwatch(() => [props.layer, props.property], ([layer], [old]) => {\n if (layer !== old) setFilter(old as string, null)\n apply()\n})\nonBeforeUnmount(() => setFilter(props.layer, null))\n</script>\n\n<template>\n <div class=\"flex flex-wrap gap-2\">\n <MChip\n v-for=\"value in options\"\n :key=\"value\"\n type=\"filter\"\n clickable\n :selected=\"selected.includes(value)\"\n @click=\"toggle(value)\"\n >\n {{ labels?.[String(value)] ?? value }}\n </MChip>\n </div>\n</template>\n","/** A place found by a `MapSearchProvider`. */\nexport interface MapSearchResult {\n /** What to show */\n label: string\n /** Where it is */\n lngLat: [number, number]\n /** Its extent, `[west, south, east, north]`: the map fits it instead of zooming to the point */\n bbox?: [number, number, number, number]\n /** Its kind (`city`, `road`, `park`, `restaurant`…), for the icon */\n type?: string\n}\n\n/** Finds places for `MMapSearch`: the text in, results out. `signal` aborts a search the user replaced. */\nexport type MapSearchProvider = (query: string, signal: AbortSignal) => Promise<MapSearchResult[]>\n\nexport interface NominatimOptions {\n /** The Nominatim server (`https://nominatim.openstreetmap.org` by default; mind its usage policy, or run your own) */\n url?: string\n /** How many results (6) */\n limit?: number\n /** The results' language (`es`, `en`…); by default the page's (`<html lang>`) */\n language?: string\n /** Only these countries (ISO codes: `['ar']`) */\n countryCodes?: string[]\n /** Prefer (or with `bounded`, only) this area: `[west, south, east, north]` */\n viewbox?: [number, number, number, number]\n bounded?: boolean\n}\n\n/**\n * OpenStreetMap's Nominatim geocoder. Its public server allows one search per second and no search-as-you-type:\n * `MMapSearch` searches on Enter.\n */\nexport function nominatimProvider(options: NominatimOptions = {}): MapSearchProvider {\n return async (query, signal) => {\n const params = new URLSearchParams({ format: 'jsonv2', q: query, limit: String(options.limit ?? 6) })\n const language = options.language ?? (typeof document !== 'undefined' ? document.documentElement.lang : '')\n if (language) params.set('accept-language', language)\n if (options.countryCodes?.length) params.set('countrycodes', options.countryCodes.join(','))\n if (options.viewbox) params.set('viewbox', options.viewbox.join(','))\n if (options.bounded) params.set('bounded', '1')\n const res = await fetch(`${options.url ?? 'https://nominatim.openstreetmap.org'}/search?${params}`, { signal })\n if (!res.ok) throw new Error(`Nominatim: ${res.status}`)\n const data = await res.json() as { display_name: string; lat: string; lon: string; type?: string; boundingbox?: string[] }[]\n return data.map((r) => {\n // Nominatim's boundingbox is [south, north, west, east]\n const b = r.boundingbox?.map(Number)\n return {\n label: r.display_name,\n lngLat: [Number(r.lon), Number(r.lat)] as [number, number],\n bbox: b && b.length === 4 ? [b[2]!, b[0]!, b[3]!, b[1]!] as [number, number, number, number] : undefined,\n type: r.type,\n }\n })\n }\n}\n","<script setup lang=\"ts\">\n/**\n * A place search on an `MMap`: a search card in a corner. Enter searches through `provider` (OpenStreetMap's\n * Nominatim by default, or any function returning places); picking a result flies there (or fits its extent) and\n * marks it. Available from the `/map` entry point.\n *\n * @event select A result was picked\n */\nimport { computed, onBeforeUnmount, ref, shallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MCard from './MCard.vue'\nimport MIcon from './MIcon.vue'\nimport MIconButton from './MIconButton.vue'\nimport MList from './MList.vue'\nimport MListItem from './MListItem.vue'\nimport MSpinner from './MSpinner.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { nominatimProvider, type MapSearchProvider, type MapSearchResult } from '../composables/mapSearch'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** Where to search: `nominatimProvider(options)` by default, or your own function */\n provider?: MapSearchProvider\n /** The corner */\n position?: MapControlPosition\n /** The field's placeholder (the locale's \"Search places\" by default) */\n placeholder?: string\n /** The zoom to fly to for a result without an extent */\n zoom?: number\n /** Mark the picked result */\n marker?: boolean\n /** Search while typing (debounced), for providers that allow it; Nominatim's public server doesn't */\n instant?: boolean\n }>(),\n { position: 'top-left', zoom: 17, marker: true, instant: false },\n)\n\nconst emit = defineEmits<{ select: [result: MapSearchResult] }>()\n\nconst t = useLocale()\nconst { map } = useMap()\nconst provider = computed(() => props.provider ?? nominatimProvider())\n\nconst query = ref('')\nconst results = shallowRef<MapSearchResult[]>([])\nconst loading = ref(false)\nconst searched = ref(false)\nconst open = ref(false)\nconst picked = shallowRef<MapSearchResult | null>(null)\nlet controller: AbortController | undefined\nlet debounce: ReturnType<typeof setTimeout> | undefined\n\nasync function search() {\n const q = query.value.trim()\n if (!q) return\n controller?.abort()\n controller = new AbortController()\n const mine = controller\n loading.value = true\n open.value = true\n try {\n results.value = await provider.value(q, mine.signal)\n } catch {\n if (mine.signal.aborted) return\n results.value = []\n } finally {\n if (controller === mine) {\n loading.value = false\n searched.value = true\n }\n }\n}\n\nfunction onInput(value: string) {\n query.value = value\n if (!value) return clear()\n if (props.instant) {\n clearTimeout(debounce)\n debounce = setTimeout(search, 350)\n }\n}\n\nfunction select(result: MapSearchResult) {\n picked.value = result\n open.value = false\n const m = map.value as Maplibre.Map | undefined\n if (result.bbox && result.bbox[0] !== result.bbox[2]) m?.fitBounds([[result.bbox[0], result.bbox[1]], [result.bbox[2], result.bbox[3]]], { padding: 48, maxZoom: props.zoom })\n else m?.flyTo({ center: result.lngLat, zoom: props.zoom })\n emit('select', result)\n}\n\nfunction clear() {\n controller?.abort()\n clearTimeout(debounce)\n query.value = ''\n results.value = []\n searched.value = false\n loading.value = false\n open.value = false\n picked.value = null\n}\n\nonBeforeUnmount(() => {\n controller?.abort()\n clearTimeout(debounce)\n})\n\nconst ICONS: Record<string, string> = {\n city: 'location_city', town: 'location_city', village: 'holiday_village', hamlet: 'cottage', suburb: 'apartment',\n neighbourhood: 'maps_home_work', road: 'road', residential: 'home', house: 'home', building: 'domain',\n shop: 'storefront', park: 'park', water: 'water', river: 'water', lake: 'water', school: 'school',\n university: 'school', hospital: 'local_hospital', restaurant: 'restaurant', cafe: 'local_cafe', hotel: 'hotel',\n station: 'train', bus_stop: 'directions_bus', administrative: 'map', country: 'public', state: 'map',\n}\nconst iconOf = (type?: string) => (type && ICONS[type]) || 'location_on'\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl :position=\"position\" :group=\"false\">\n <MCard variant=\"elevated\" class=\"w-80 max-w-[calc(100vw-5rem)] overflow-hidden\">\n <form class=\"flex items-center gap-2 py-1 pr-1 pl-3\" role=\"search\" @submit.prevent=\"search\">\n <MIcon name=\"search\" :size=\"20\" class=\"shrink-0 text-on-surface-variant\" />\n <input\n :value=\"query\"\n type=\"search\"\n enterkeyhint=\"search\"\n :placeholder=\"placeholder ?? t.mapSearchPlaces\"\n :aria-label=\"placeholder ?? t.mapSearchPlaces\"\n class=\"min-w-0 flex-1 bg-transparent py-2 text-body-medium text-on-surface outline-none placeholder:text-on-surface-variant [&::-webkit-search-cancel-button]:hidden\"\n @input=\"onInput(($event.target as HTMLInputElement).value)\"\n @focus=\"open = searched && !picked\"\n >\n <MSpinner v-if=\"loading\" :size=\"20\" class=\"mr-2 shrink-0\" />\n <MIconButton v-else-if=\"query\" icon=\"close\" :label=\"t.clearSearch\" size=\"sm\" @click=\"clear\" />\n </form>\n <div v-if=\"open && searched && !loading\" class=\"border-t border-outline-variant\">\n <MList v-if=\"results.length\" class=\"max-h-72 overflow-y-auto\">\n <MListItem\n v-for=\"(r, i) in results\"\n :key=\"i\"\n :title=\"r.label\"\n :icon=\"iconOf(r.type)\"\n leading=\"icon\"\n clickable\n @click=\"select(r)\"\n />\n </MList>\n <div v-else class=\"flex flex-col items-center gap-2 py-6\">\n <MIcon name=\"search_off\" :size=\"28\" class=\"text-on-surface-variant\" />\n <span class=\"text-body-small text-on-surface-variant\">{{ t.noResults }}</span>\n </div>\n </div>\n </MCard>\n </MMapControl>\n <MMapMarker v-if=\"marker && picked\" :lng-lat=\"picked.lngLat\" />\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A place search on an `MMap`: a search card in a corner. Enter searches through `provider` (OpenStreetMap's\n * Nominatim by default, or any function returning places); picking a result flies there (or fits its extent) and\n * marks it. Available from the `/map` entry point.\n *\n * @event select A result was picked\n */\nimport { computed, onBeforeUnmount, ref, shallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MCard from './MCard.vue'\nimport MIcon from './MIcon.vue'\nimport MIconButton from './MIconButton.vue'\nimport MList from './MList.vue'\nimport MListItem from './MListItem.vue'\nimport MSpinner from './MSpinner.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { nominatimProvider, type MapSearchProvider, type MapSearchResult } from '../composables/mapSearch'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** Where to search: `nominatimProvider(options)` by default, or your own function */\n provider?: MapSearchProvider\n /** The corner */\n position?: MapControlPosition\n /** The field's placeholder (the locale's \"Search places\" by default) */\n placeholder?: string\n /** The zoom to fly to for a result without an extent */\n zoom?: number\n /** Mark the picked result */\n marker?: boolean\n /** Search while typing (debounced), for providers that allow it; Nominatim's public server doesn't */\n instant?: boolean\n }>(),\n { position: 'top-left', zoom: 17, marker: true, instant: false },\n)\n\nconst emit = defineEmits<{ select: [result: MapSearchResult] }>()\n\nconst t = useLocale()\nconst { map } = useMap()\nconst provider = computed(() => props.provider ?? nominatimProvider())\n\nconst query = ref('')\nconst results = shallowRef<MapSearchResult[]>([])\nconst loading = ref(false)\nconst searched = ref(false)\nconst open = ref(false)\nconst picked = shallowRef<MapSearchResult | null>(null)\nlet controller: AbortController | undefined\nlet debounce: ReturnType<typeof setTimeout> | undefined\n\nasync function search() {\n const q = query.value.trim()\n if (!q) return\n controller?.abort()\n controller = new AbortController()\n const mine = controller\n loading.value = true\n open.value = true\n try {\n results.value = await provider.value(q, mine.signal)\n } catch {\n if (mine.signal.aborted) return\n results.value = []\n } finally {\n if (controller === mine) {\n loading.value = false\n searched.value = true\n }\n }\n}\n\nfunction onInput(value: string) {\n query.value = value\n if (!value) return clear()\n if (props.instant) {\n clearTimeout(debounce)\n debounce = setTimeout(search, 350)\n }\n}\n\nfunction select(result: MapSearchResult) {\n picked.value = result\n open.value = false\n const m = map.value as Maplibre.Map | undefined\n if (result.bbox && result.bbox[0] !== result.bbox[2]) m?.fitBounds([[result.bbox[0], result.bbox[1]], [result.bbox[2], result.bbox[3]]], { padding: 48, maxZoom: props.zoom })\n else m?.flyTo({ center: result.lngLat, zoom: props.zoom })\n emit('select', result)\n}\n\nfunction clear() {\n controller?.abort()\n clearTimeout(debounce)\n query.value = ''\n results.value = []\n searched.value = false\n loading.value = false\n open.value = false\n picked.value = null\n}\n\nonBeforeUnmount(() => {\n controller?.abort()\n clearTimeout(debounce)\n})\n\nconst ICONS: Record<string, string> = {\n city: 'location_city', town: 'location_city', village: 'holiday_village', hamlet: 'cottage', suburb: 'apartment',\n neighbourhood: 'maps_home_work', road: 'road', residential: 'home', house: 'home', building: 'domain',\n shop: 'storefront', park: 'park', water: 'water', river: 'water', lake: 'water', school: 'school',\n university: 'school', hospital: 'local_hospital', restaurant: 'restaurant', cafe: 'local_cafe', hotel: 'hotel',\n station: 'train', bus_stop: 'directions_bus', administrative: 'map', country: 'public', state: 'map',\n}\nconst iconOf = (type?: string) => (type && ICONS[type]) || 'location_on'\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl :position=\"position\" :group=\"false\">\n <MCard variant=\"elevated\" class=\"w-80 max-w-[calc(100vw-5rem)] overflow-hidden\">\n <form class=\"flex items-center gap-2 py-1 pr-1 pl-3\" role=\"search\" @submit.prevent=\"search\">\n <MIcon name=\"search\" :size=\"20\" class=\"shrink-0 text-on-surface-variant\" />\n <input\n :value=\"query\"\n type=\"search\"\n enterkeyhint=\"search\"\n :placeholder=\"placeholder ?? t.mapSearchPlaces\"\n :aria-label=\"placeholder ?? t.mapSearchPlaces\"\n class=\"min-w-0 flex-1 bg-transparent py-2 text-body-medium text-on-surface outline-none placeholder:text-on-surface-variant [&::-webkit-search-cancel-button]:hidden\"\n @input=\"onInput(($event.target as HTMLInputElement).value)\"\n @focus=\"open = searched && !picked\"\n >\n <MSpinner v-if=\"loading\" :size=\"20\" class=\"mr-2 shrink-0\" />\n <MIconButton v-else-if=\"query\" icon=\"close\" :label=\"t.clearSearch\" size=\"sm\" @click=\"clear\" />\n </form>\n <div v-if=\"open && searched && !loading\" class=\"border-t border-outline-variant\">\n <MList v-if=\"results.length\" class=\"max-h-72 overflow-y-auto\">\n <MListItem\n v-for=\"(r, i) in results\"\n :key=\"i\"\n :title=\"r.label\"\n :icon=\"iconOf(r.type)\"\n leading=\"icon\"\n clickable\n @click=\"select(r)\"\n />\n </MList>\n <div v-else class=\"flex flex-col items-center gap-2 py-6\">\n <MIcon name=\"search_off\" :size=\"28\" class=\"text-on-surface-variant\" />\n <span class=\"text-body-small text-on-surface-variant\">{{ t.noResults }}</span>\n </div>\n </div>\n </MCard>\n </MMapControl>\n <MMapMarker v-if=\"marker && picked\" :lng-lat=\"picked.lngLat\" />\n </div>\n</template>\n"],"mappings":";;;;;;;;AA4BA,IAAa,KAAoC,OAAO,QAAQ;AAYhE,SAAgB,GAAkB,GAAyD;CACzF,IAAM,IAAW,EAAO,IAAS,IAAI;CACrC,IAAI,KAAY,MAAW,KAAA,GAAW,OAAO;CAC7C,IAAM,IAAM,QAAe;EACzB,IAAM,IAAI,EAAQ,CAAM;EACxB,OAAQ,IAAgB,aAAa,IAAI,EAAE,UAAU,IAAzC,KAAA;CACd,CAAC,GAEK,IAAY;EAChB,KAAK,QAAe,EAAI,OAAO,IAAI,KAAK;EACxC,UAAU,QAAe,EAAI,OAAO,SAAS,KAAK;EAClD,cAAc,QAAe,EAAI,OAAO,aAAa,SAAS,CAAC;EAC/D,OAAO,QAAe,EAAI,OAAO,MAAM,KAAK;EAE5C,YAAY,IAAI,MAAM;GAPR,SAAS,CAAC;GAA8B,SAAS,CAAC;EAO1C,GAAO,EAAE,MAAM,GAAQ,MAAQ,QAAQ,IAAI,EAAI,OAAO,cAAc,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AAA,SAA5B,EAAA,GAAA,EAA+D,IAAA;;GAA1B,WAAS,EAAA,MAAO"}
1
+ {"version":3,"file":"map.js","names":["$attrs","$slots","$attrs","$attrs","$slots","$slots","$attrs"],"sources":["../src/composables/useMap.ts","../src/components/MMapControl.vue","../src/components/MMapControl.vue","../src/components/_MMapAttribution.vue","../src/components/_MMapAttribution.vue","../src/composables/useMapLayers.ts","../src/composables/_mapStyle.ts","../src/components/MMap.vue","../src/components/MMap.vue","../src/composables/_mapPin.ts","../src/components/MMapMarker.vue","../src/components/MMapMarker.vue","../src/components/MMapPopup.vue","../src/components/MMapPopup.vue","../src/components/MMapGeoJson.vue","../src/components/MMapGeoJson.vue","../src/components/_MMapLayerItem.vue","../src/components/_MMapLayerItem.vue","../src/components/MMapLayers.vue","../src/components/MMapLayers.vue","../src/components/MMapBaseLayers.vue","../src/components/MMapBaseLayers.vue","../src/components/MMapFeatureInfo.vue","../src/components/MMapFeatureInfo.vue","../src/composables/mapAdapters.ts","../src/components/MMapIdentify.vue","../src/components/MMapIdentify.vue","../src/components/MMapHover.vue","../src/components/MMapHover.vue","../src/composables/_mapGeometry.ts","../src/components/MMapMeasure.vue","../src/components/MMapMeasure.vue","../src/composables/useMapFilter.ts","../src/components/MMapFilter.vue","../src/components/MMapFilter.vue","../src/composables/mapSearch.ts","../src/components/MMapSearch.vue","../src/components/MMapSearch.vue"],"sourcesContent":["import { computed, getCurrentInstance, inject, onBeforeUnmount, onMounted, provide, toValue, watch, type ComputedRef, type InjectionKey, type MaybeRefOrGetter, type Ref, type ShallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport type { MapLayerModel } from './mapAdapters'\nimport type { MapLayerState } from './useMapLayers'\n\n/** The `maplibre-gl` module (its classes: `Map`, `Marker`, `Popup`…) */\nexport type MaplibreModule = typeof import('maplibre-gl')\n\n/** What `MMap` provides to everything inside it. */\nexport interface MapContext {\n /** The MapLibre map, once created (never on the server) */\n map: ShallowRef<Maplibre.Map | undefined>\n /** The `maplibre-gl` module, loaded with the map (so nothing imports it on the server) */\n maplibre: ShallowRef<MaplibreModule | undefined>\n /** Bumped on every `style.load`: sources and layers added by components are re-added after a style change */\n styleVersion: Ref<number>\n /** The style as `MMap`'s `adapter` reads it (undefined without one) */\n model: ShallowRef<MapLayerModel | undefined>\n /** Visibility and opacity of the model's layers */\n layerState: MapLayerState\n /**\n * The tool that owns the map's clicks right now (`'measure'` while measuring), or null: `MMapIdentify` stays quiet\n * meanwhile. Set it from tools of your own the same way\n */\n activeTool: Ref<string | null>\n}\n\n// Internal: provided by MMap\nexport const MAP_KEY: InjectionKey<MapContext> = Symbol('m3-map')\n\n/**\n * A map to use from outside `<MMap>`: the `MMap` itself (a template ref: `<MMap ref=\"map\">` → `:map=\"map\"`) or its\n * `context`. Null or undefined until it mounts.\n */\nexport type MapSource = { context: MapContext } | MapContext | null | undefined\n\n/**\n * Internal: the enclosing MMap's context or, outside one, a context that follows `source` (empty until it's\n * there), provided to the caller's children too. Null when there's neither.\n */\nexport function resolveMapContext(source?: MaybeRefOrGetter<MapSource>): MapContext | null {\n const injected = inject(MAP_KEY, null)\n if (injected || source === undefined) return injected\n const ctx = computed(() => {\n const s = toValue(source)\n return !s ? undefined : 'context' in s ? s.context : s\n })\n const empty = { visible: {} as Record<string, boolean>, opacity: {} as Record<string, number> }\n const forwarded = {\n map: computed(() => ctx.value?.map.value),\n maplibre: computed(() => ctx.value?.maplibre.value),\n styleVersion: computed(() => ctx.value?.styleVersion.value ?? 0),\n model: computed(() => ctx.value?.model.value),\n // Reads and writes reach the map's own state once it's there\n layerState: new Proxy(empty, { get: (target, key) => Reflect.get(ctx.value?.layerState ?? target, key) }),\n activeTool: computed({\n get: () => ctx.value?.activeTool.value ?? null,\n set: (v) => { if (ctx.value) ctx.value.activeTool.value = v },\n }),\n } as unknown as MapContext\n provide(MAP_KEY, forwarded)\n return forwarded\n}\n\ntype MapEventType = keyof Maplibre.MapEventType\ntype LayerEventType = keyof Maplibre.MapLayerEventType\n\n/**\n * The map of the enclosing `MMap`, for your own controls, layers and handlers (call it in a component inside\n * `MMap`). Listeners added through it are removed when the component unmounts. Outside an `MMap` (a side panel),\n * pass it one: the `MMap`'s template ref, or a getter for it; until it mounts, `map` is undefined and `onReady` waits.\n *\n * ```ts\n * const { map, onLayer } = useMap()\n * onLayer('click', 'parcels-fill', (e) => console.log(e.features?.[0]?.properties))\n *\n * // In a panel next to the map: <MMap ref=\"mapRef\"> … <MyPanel :map=\"mapRef\" />\n * const { map } = useMap(() => props.map)\n * ```\n */\nexport function useMap(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMap() must be called in a component inside <MMap>, or be given one')\n const cleanups: (() => void)[] = []\n if (getCurrentInstance()) onBeforeUnmount(() => cleanups.splice(0).forEach((fn) => fn()))\n\n /**\n * Runs `fn` with the map as soon as it exists (right away if it already does), and in a component not before it's\n * mounted, so its template refs are there.\n */\n function onReady(fn: (map: Maplibre.Map, maplibre: MaplibreModule) => void) {\n const run = () => {\n if (ctx!.map.value && ctx!.maplibre.value) return fn(ctx!.map.value, ctx!.maplibre.value)\n const stop = watch(ctx!.map, (map) => {\n if (!map || !ctx!.maplibre.value) return\n stop()\n fn(map, ctx!.maplibre.value)\n })\n cleanups.push(stop)\n }\n const instance = getCurrentInstance()\n if (instance && !instance.isMounted) onMounted(run)\n else run()\n }\n\n /** A map event listener (`click`, `moveend`, `style.load`…), removed on unmount. */\n function on<T extends MapEventType>(type: T, listener: (e: Maplibre.MapEventType[T] & object) => void) {\n onReady((map) => {\n map.on(type, listener)\n cleanups.push(() => map.off(type, listener))\n })\n }\n\n /**\n * A listener for one layer's features (`click`, `mouseenter`, `mousemove`…: `e.features` holds the features under\n * the pointer), removed on unmount. It survives style changes, being keyed by the layer id.\n */\n function onLayer<T extends LayerEventType>(type: T, layerId: string, listener: (e: Maplibre.MapLayerEventType[T] & object) => void) {\n onReady((map) => {\n map.on(type, layerId, listener)\n cleanups.push(() => map.off(type, layerId, listener))\n })\n }\n\n // computed, not readonly(): readonly() is deep, and a proxied maplibre Map breaks\n return {\n map: computed(() => ctx.map.value) as ComputedRef<Maplibre.Map | undefined>,\n maplibre: computed(() => ctx.maplibre.value) as ComputedRef<MaplibreModule | undefined>,\n styleVersion: computed(() => ctx.styleVersion.value),\n /** The tool that owns the map's clicks (null: none): set it while yours does, and leave it alone otherwise */\n activeTool: ctx.activeTool,\n onReady,\n on,\n onLayer,\n }\n}\n","<script setup lang=\"ts\">\n/**\n * Your own control in a corner of an `MMap`, stacked with MapLibre's (zoom, geolocate…) in that corner. With `group`\n * (the default) it's a control group like the zoom buttons: put `<button>`s with a Material Symbols icon in it and\n * they get the same M3 look. Without it, anything goes (an `MFab`, an `MSearchBar`, a card). With a `#panel` slot it\n * expands in place: a button in it calls `toggle` and the control grows into a panel with your content (a layer\n * picker, filters, a legend), and back. Its size springs whenever its content changes size, so the other controls in\n * the corner move along instead of jumping. Available from the `/map` entry point.\n *\n * @slot default The control's content; `{ expanded, toggle }` when it has a `#panel`\n * @slot panel What the control expands into (`v-model:expanded`); `{ close }`. Escape or a press outside it closes it\n * @event update:expanded Emitted when the panel opens or closes — powers v-model:expanded\n */\nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { motionSprings } from '../composables/motion'\nimport { playSamples, prefersReducedMotion, sampleAt, sampleSpring } from '../composables/_springAnimation'\nimport type { MapControlPosition } from './MMap.vue'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The corner */\n position?: MapControlPosition\n /** Draw it as a control group (a surface with dividers between buttons), like MapLibre's zoom buttons */\n group?: boolean\n /** Expanded into its `#panel` (v-model:expanded) */\n expanded?: boolean\n /** Springs the control's size when its content changes size (expanding, or anything else) */\n animate?: boolean\n }>(),\n { position: 'top-right', group: true, expanded: false, animate: true },\n)\n\nconst emit = defineEmits<{ 'update:expanded': [boolean] }>()\nconst slots = useSlots()\n\nconst el = ref<HTMLElement>()\nconst { onReady } = useMap()\n\n// ── Expanding into the panel ────────────────────────────────────────────────────────────────────────────\nconst open = ref(props.expanded)\nwatch(() => props.expanded, (v) => { open.value = v })\nconst showPanel = computed(() => open.value && !!slots.panel)\nfunction setOpen(v: boolean) {\n if (v === open.value) return\n open.value = v\n emit('update:expanded', v)\n}\nconst toggle = () => setOpen(!open.value)\nconst close = () => setOpen(false)\n\nfunction onOutside(e: PointerEvent) {\n if (showPanel.value && !el.value?.contains(e.target as Node)) close()\n}\nfunction onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Escape' && showPanel.value) {\n close()\n e.stopPropagation()\n }\n}\n\n// ── Size: a spring between the old and the new size whenever the content resizes (Standard DefaultSpatial).\n// The new layout is already there when the ResizeObserver reports it, before it paints, so the animation starts\n// from the old size without a flash; the content is clipped while it runs. Width/height can't run on the\n// compositor, but a control is small. ──────────────────────────────────────────────────────────────────────\nlet size: { w: number; h: number } | null = null\nlet anim: Animation | null = null\nlet samples: number[] = []\nlet from = { w: 0, h: 0 }\nlet to = { w: 0, h: 0 }\nlet observer: ResizeObserver | null = null\n\nfunction measure(): { w: number; h: number } {\n return { w: el.value!.offsetWidth, h: el.value!.offsetHeight }\n}\n\nfunction onResize() {\n const node = el.value\n if (!node || anim) return\n const next = measure()\n if (size && (next.w !== size.w || next.h !== size.h) && props.animate && !prefersReducedMotion()) grow(node, size, next)\n size = next\n}\n\nfunction grow(node: HTMLElement, a: { w: number; h: number }, b: { w: number; h: number }) {\n from = a\n to = b\n samples = sampleSpring(0, 1, 0, motionSprings.standard.defaultSpatial, 0.002)\n node.style.overflow = 'hidden'\n const lerp = (p: number) => ({ width: `${a.w + (b.w - a.w) * p}px`, height: `${a.h + (b.h - a.h) * p}px` })\n anim = playSamples(node, samples, lerp)\n if (!anim) return finish(node)\n anim.onfinish = () => finish(node)\n}\n\nfunction finish(node: HTMLElement) {\n anim?.cancel()\n anim = null\n node.style.overflow = ''\n // The content may have changed size again while it ran\n const now = measure()\n if (now.w !== to.w || now.h !== to.h) {\n size = to\n onResize()\n } else size = now\n}\n\n// A size change while it runs (closed mid-opening) starts from where it is, not from the old size\nfunction retarget() {\n const node = el.value\n if (!node || !anim) return\n const p = sampleAt(samples, anim.currentTime)\n const at = { w: from.w + (to.w - from.w) * p, h: from.h + (to.h - from.h) * p }\n anim.onfinish = null\n anim.cancel()\n anim = null\n size = at\n onResize()\n}\nwatch(showPanel, retarget, { flush: 'post' })\n\nlet map: Maplibre.Map | undefined\n// MapLibre's IControl: the element it places in the corner\nconst control: Maplibre.IControl = {\n onAdd: () => el.value!,\n onRemove: () => el.value?.remove(),\n}\n\nonReady((m) => {\n map = m\n if (el.value) m.addControl(control, props.position)\n})\n\nwatch(() => props.position, (position) => {\n if (!map || !el.value) return\n map.removeControl(control)\n map.addControl(control, position)\n})\n\nonMounted(() => {\n document.addEventListener('pointerdown', onOutside, true)\n if (typeof ResizeObserver === 'undefined' || !el.value) return\n observer = new ResizeObserver(onResize)\n observer.observe(el.value)\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('pointerdown', onOutside, true)\n observer?.disconnect()\n anim?.cancel()\n if (map?.hasControl(control)) map.removeControl(control)\n})\n</script>\n\n<template>\n <!-- Moved into the map's corner by MapLibre -->\n <div class=\"hidden\">\n <div\n ref=\"el\"\n class=\"maplibregl-ctrl m3-map-control\"\n :class=\"showPanel ? 'm3-map-control-panel' : group ? 'maplibregl-ctrl-group' : ''\"\n v-bind=\"$attrs\"\n @keydown=\"onKeyDown\"\n >\n <div v-if=\"showPanel\" class=\"m3-map-control-panel-in\">\n <slot name=\"panel\" :close=\"close\" />\n </div>\n <slot v-else :expanded=\"open\" :toggle=\"toggle\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Your own control in a corner of an `MMap`, stacked with MapLibre's (zoom, geolocate…) in that corner. With `group`\n * (the default) it's a control group like the zoom buttons: put `<button>`s with a Material Symbols icon in it and\n * they get the same M3 look. Without it, anything goes (an `MFab`, an `MSearchBar`, a card). With a `#panel` slot it\n * expands in place: a button in it calls `toggle` and the control grows into a panel with your content (a layer\n * picker, filters, a legend), and back. Its size springs whenever its content changes size, so the other controls in\n * the corner move along instead of jumping. Available from the `/map` entry point.\n *\n * @slot default The control's content; `{ expanded, toggle }` when it has a `#panel`\n * @slot panel What the control expands into (`v-model:expanded`); `{ close }`. Escape or a press outside it closes it\n * @event update:expanded Emitted when the panel opens or closes — powers v-model:expanded\n */\nimport { computed, onBeforeUnmount, onMounted, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { motionSprings } from '../composables/motion'\nimport { playSamples, prefersReducedMotion, sampleAt, sampleSpring } from '../composables/_springAnimation'\nimport type { MapControlPosition } from './MMap.vue'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** The corner */\n position?: MapControlPosition\n /** Draw it as a control group (a surface with dividers between buttons), like MapLibre's zoom buttons */\n group?: boolean\n /** Expanded into its `#panel` (v-model:expanded) */\n expanded?: boolean\n /** Springs the control's size when its content changes size (expanding, or anything else) */\n animate?: boolean\n }>(),\n { position: 'top-right', group: true, expanded: false, animate: true },\n)\n\nconst emit = defineEmits<{ 'update:expanded': [boolean] }>()\nconst slots = useSlots()\n\nconst el = ref<HTMLElement>()\nconst { onReady } = useMap()\n\n// ── Expanding into the panel ────────────────────────────────────────────────────────────────────────────\nconst open = ref(props.expanded)\nwatch(() => props.expanded, (v) => { open.value = v })\nconst showPanel = computed(() => open.value && !!slots.panel)\nfunction setOpen(v: boolean) {\n if (v === open.value) return\n open.value = v\n emit('update:expanded', v)\n}\nconst toggle = () => setOpen(!open.value)\nconst close = () => setOpen(false)\n\nfunction onOutside(e: PointerEvent) {\n if (showPanel.value && !el.value?.contains(e.target as Node)) close()\n}\nfunction onKeyDown(e: KeyboardEvent) {\n if (e.key === 'Escape' && showPanel.value) {\n close()\n e.stopPropagation()\n }\n}\n\n// ── Size: a spring between the old and the new size whenever the content resizes (Standard DefaultSpatial).\n// The new layout is already there when the ResizeObserver reports it, before it paints, so the animation starts\n// from the old size without a flash; the content is clipped while it runs. Width/height can't run on the\n// compositor, but a control is small. ──────────────────────────────────────────────────────────────────────\nlet size: { w: number; h: number } | null = null\nlet anim: Animation | null = null\nlet samples: number[] = []\nlet from = { w: 0, h: 0 }\nlet to = { w: 0, h: 0 }\nlet observer: ResizeObserver | null = null\n\nfunction measure(): { w: number; h: number } {\n return { w: el.value!.offsetWidth, h: el.value!.offsetHeight }\n}\n\nfunction onResize() {\n const node = el.value\n if (!node || anim) return\n const next = measure()\n if (size && (next.w !== size.w || next.h !== size.h) && props.animate && !prefersReducedMotion()) grow(node, size, next)\n size = next\n}\n\nfunction grow(node: HTMLElement, a: { w: number; h: number }, b: { w: number; h: number }) {\n from = a\n to = b\n samples = sampleSpring(0, 1, 0, motionSprings.standard.defaultSpatial, 0.002)\n node.style.overflow = 'hidden'\n const lerp = (p: number) => ({ width: `${a.w + (b.w - a.w) * p}px`, height: `${a.h + (b.h - a.h) * p}px` })\n anim = playSamples(node, samples, lerp)\n if (!anim) return finish(node)\n anim.onfinish = () => finish(node)\n}\n\nfunction finish(node: HTMLElement) {\n anim?.cancel()\n anim = null\n node.style.overflow = ''\n // The content may have changed size again while it ran\n const now = measure()\n if (now.w !== to.w || now.h !== to.h) {\n size = to\n onResize()\n } else size = now\n}\n\n// A size change while it runs (closed mid-opening) starts from where it is, not from the old size\nfunction retarget() {\n const node = el.value\n if (!node || !anim) return\n const p = sampleAt(samples, anim.currentTime)\n const at = { w: from.w + (to.w - from.w) * p, h: from.h + (to.h - from.h) * p }\n anim.onfinish = null\n anim.cancel()\n anim = null\n size = at\n onResize()\n}\nwatch(showPanel, retarget, { flush: 'post' })\n\nlet map: Maplibre.Map | undefined\n// MapLibre's IControl: the element it places in the corner\nconst control: Maplibre.IControl = {\n onAdd: () => el.value!,\n onRemove: () => el.value?.remove(),\n}\n\nonReady((m) => {\n map = m\n if (el.value) m.addControl(control, props.position)\n})\n\nwatch(() => props.position, (position) => {\n if (!map || !el.value) return\n map.removeControl(control)\n map.addControl(control, position)\n})\n\nonMounted(() => {\n document.addEventListener('pointerdown', onOutside, true)\n if (typeof ResizeObserver === 'undefined' || !el.value) return\n observer = new ResizeObserver(onResize)\n observer.observe(el.value)\n})\n\nonBeforeUnmount(() => {\n document.removeEventListener('pointerdown', onOutside, true)\n observer?.disconnect()\n anim?.cancel()\n if (map?.hasControl(control)) map.removeControl(control)\n})\n</script>\n\n<template>\n <!-- Moved into the map's corner by MapLibre -->\n <div class=\"hidden\">\n <div\n ref=\"el\"\n class=\"maplibregl-ctrl m3-map-control\"\n :class=\"showPanel ? 'm3-map-control-panel' : group ? 'maplibregl-ctrl-group' : ''\"\n v-bind=\"$attrs\"\n @keydown=\"onKeyDown\"\n >\n <div v-if=\"showPanel\" class=\"m3-map-control-panel-in\">\n <slot name=\"panel\" :close=\"close\" />\n </div>\n <slot v-else :expanded=\"open\" :toggle=\"toggle\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/*\n * Internal (not exported): MMap's attribution, instead of MapLibre's AttributionControl. A round M3 icon button in a\n * corner (surface, elevation 2) that opens into a pill with the credits of the style's sources, its size springing\n * open and closed through MMapControl. The credits are collected like MapLibre's control does: the attribution of\n * every source a layer uses (from its TileJSON once loaded, else the style), without repeats or ones contained in\n * another. They're HTML from the style (links), as MapLibre renders them.\n */\nimport { computed, ref } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport { useMap } from '../composables/useMap'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = defineProps<{ position: MapControlPosition }>()\n\nconst t = useLocale()\nconst { on, onReady } = useMap()\n\nconst credits = ref<string[]>([])\nconst open = ref(true)\n// The text wraps against the map's width, not the control's while its size springs (it would reflow every frame)\nconst maxWidth = ref(0)\nlet map: Maplibre.Map | undefined\n\nfunction collect() {\n if (!map) return\n const style = map.getStyle?.()\n if (!style?.sources) return\n const used = new Set(style.layers?.map((l) => (l as { source?: string }).source).filter(Boolean))\n const found: string[] = []\n for (const [id, spec] of Object.entries(style.sources)) {\n if (used.size && !used.has(id)) continue\n const text = (map.getSource(id) as { attribution?: string } | undefined)?.attribution ?? (spec as { attribution?: string }).attribution\n if (text && !found.includes(text)) found.push(text)\n }\n const next = found.filter((a) => !found.some((b) => b !== a && b.includes(a)))\n if (next.join('\\n') !== credits.value.join('\\n')) credits.value = next\n maxWidth.value = Math.max(0, map.getContainer().clientWidth - 20)\n}\n\nonReady((m) => {\n map = m\n collect()\n})\non('styledata', collect)\non('sourcedata', collect)\non('resize', collect)\n// Open when the map loads, folded away once it's dragged, as MapLibre's compact attribution\non('dragstart', () => { open.value = false })\n\nconst html = computed(() => credits.value.join(' '))\n// The button sits at the corner's outer edge, the text inward\nconst end = computed(() => props.position.endsWith('right'))\n</script>\n\n<template>\n <MMapControl\n v-if=\"html\"\n :position=\"position\"\n :group=\"false\"\n class=\"m3-map-attrib\"\n :class=\"open ? 'm3-map-attrib-open' : ''\"\n >\n <div class=\"m3-map-attrib-row\" :class=\"end ? 'flex-row-reverse' : ''\" :style=\"maxWidth ? { maxWidth: `${maxWidth}px` } : undefined\">\n <button\n type=\"button\"\n class=\"m3-map-attrib-button\"\n :title=\"t.mapToggleAttribution\"\n :aria-label=\"t.mapToggleAttribution\"\n :aria-expanded=\"open\"\n @click=\"open = !open\"\n >\n <MIcon name=\"info\" :size=\"20\" />\n </button>\n <div v-if=\"open\" class=\"m3-map-attrib-text\" :class=\"end ? 'pl-3.5' : 'pr-3.5'\" v-html=\"html\" />\n </div>\n </MMapControl>\n</template>\n","<script setup lang=\"ts\">\n/*\n * Internal (not exported): MMap's attribution, instead of MapLibre's AttributionControl. A round M3 icon button in a\n * corner (surface, elevation 2) that opens into a pill with the credits of the style's sources, its size springing\n * open and closed through MMapControl. The credits are collected like MapLibre's control does: the attribution of\n * every source a layer uses (from its TileJSON once loaded, else the style), without repeats or ones contained in\n * another. They're HTML from the style (links), as MapLibre renders them.\n */\nimport { computed, ref } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport { useMap } from '../composables/useMap'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = defineProps<{ position: MapControlPosition }>()\n\nconst t = useLocale()\nconst { on, onReady } = useMap()\n\nconst credits = ref<string[]>([])\nconst open = ref(true)\n// The text wraps against the map's width, not the control's while its size springs (it would reflow every frame)\nconst maxWidth = ref(0)\nlet map: Maplibre.Map | undefined\n\nfunction collect() {\n if (!map) return\n const style = map.getStyle?.()\n if (!style?.sources) return\n const used = new Set(style.layers?.map((l) => (l as { source?: string }).source).filter(Boolean))\n const found: string[] = []\n for (const [id, spec] of Object.entries(style.sources)) {\n if (used.size && !used.has(id)) continue\n const text = (map.getSource(id) as { attribution?: string } | undefined)?.attribution ?? (spec as { attribution?: string }).attribution\n if (text && !found.includes(text)) found.push(text)\n }\n const next = found.filter((a) => !found.some((b) => b !== a && b.includes(a)))\n if (next.join('\\n') !== credits.value.join('\\n')) credits.value = next\n maxWidth.value = Math.max(0, map.getContainer().clientWidth - 20)\n}\n\nonReady((m) => {\n map = m\n collect()\n})\non('styledata', collect)\non('sourcedata', collect)\non('resize', collect)\n// Open when the map loads, folded away once it's dragged, as MapLibre's compact attribution\non('dragstart', () => { open.value = false })\n\nconst html = computed(() => credits.value.join(' '))\n// The button sits at the corner's outer edge, the text inward\nconst end = computed(() => props.position.endsWith('right'))\n</script>\n\n<template>\n <MMapControl\n v-if=\"html\"\n :position=\"position\"\n :group=\"false\"\n class=\"m3-map-attrib\"\n :class=\"open ? 'm3-map-attrib-open' : ''\"\n >\n <div class=\"m3-map-attrib-row\" :class=\"end ? 'flex-row-reverse' : ''\" :style=\"maxWidth ? { maxWidth: `${maxWidth}px` } : undefined\">\n <button\n type=\"button\"\n class=\"m3-map-attrib-button\"\n :title=\"t.mapToggleAttribution\"\n :aria-label=\"t.mapToggleAttribution\"\n :aria-expanded=\"open\"\n @click=\"open = !open\"\n >\n <MIcon name=\"info\" :size=\"20\" />\n </button>\n <div v-if=\"open\" class=\"m3-map-attrib-text\" :class=\"end ? 'pl-3.5' : 'pr-3.5'\" v-html=\"html\" />\n </div>\n </MMapControl>\n</template>\n","import { computed, reactive, type MaybeRefOrGetter } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { resolveMapContext, type MapSource } from './useMap'\nimport type { MapLayerInfo, MapLayerModel } from './mapAdapters'\n\n/** The paint properties that make each layer type transparent. */\nconst OPACITY: Record<string, string[]> = {\n fill: ['fill-opacity'],\n line: ['line-opacity'],\n circle: ['circle-opacity', 'circle-stroke-opacity'],\n symbol: ['icon-opacity', 'text-opacity'],\n raster: ['raster-opacity'],\n heatmap: ['heatmap-opacity'],\n 'fill-extrusion': ['fill-extrusion-opacity'],\n}\n\n/** Visibility and opacity of the model's layers, shared by everything inside one `MMap`. */\nexport interface MapLayerState {\n visible: Record<string, boolean>\n opacity: Record<string, number>\n}\n\n// Internal: MMap's shared state, filled from the map on every style load\nexport function createLayerState(): MapLayerState {\n return reactive({ visible: {}, opacity: {} })\n}\n\nexport function readLayerState(state: MapLayerState, map: Maplibre.Map, model: MapLayerModel | undefined) {\n const visible: Record<string, boolean> = {}\n const opacity: Record<string, number> = {}\n for (const layer of model?.layers ?? []) {\n const style = map.getLayer(layer.id)\n if (!style) continue\n visible[layer.id] = map.getLayoutProperty(layer.id, 'visibility') !== 'none'\n const prop = OPACITY[style.type]?.[0]\n const value = prop ? map.getPaintProperty(layer.id, prop) : undefined\n opacity[layer.id] = typeof value === 'number' ? value : 1\n }\n state.visible = visible\n state.opacity = opacity\n}\n\n/**\n * The layers of the enclosing `MMap`'s style as its `adapter` describes them, with their visibility and opacity, for a\n * layer panel or a base layer switcher of your own (`MMapLayers` and `MMapBaseLayers` are built on it). Changes go to\n * the map and to every component using it; a layer's `children` follow it. Outside an `MMap`, pass it one (its\n * template ref), as with `useMap`.\n */\nexport function useMapLayers(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMapLayers() must be called in a component inside <MMap>, or be given one')\n const { map, model, layerState: state } = ctx\n\n const layers = computed(() => model.value?.layers ?? [])\n const byId = computed(() => new Map(layers.value.map((l) => [l.id, l])))\n\n function isVisible(id: string) {\n return state.visible[id] ?? true\n }\n\n function setVisible(id: string, visible: boolean) {\n const m = map.value\n if (m?.getLayer(id)) m.setLayoutProperty(id, 'visibility', visible ? 'visible' : 'none')\n state.visible[id] = visible\n for (const child of byId.value.get(id)?.children ?? []) setVisible(child, visible)\n }\n\n function toggle(id: string) {\n setVisible(id, !isVisible(id))\n }\n\n function opacityOf(id: string) {\n return state.opacity[id] ?? 1\n }\n\n function setOpacity(id: string, opacity: number) {\n const m = map.value\n const layer = m?.getLayer(id)\n if (layer) for (const prop of OPACITY[layer.type] ?? []) m!.setPaintProperty(id, prop, opacity)\n state.opacity[id] = opacity\n for (const child of byId.value.get(id)?.children ?? []) setOpacity(child, opacity)\n }\n\n /** The layers of a group (listed ones), or the ungrouped ones with `null`. */\n function layersOf(group: string | null): MapLayerInfo[] {\n return layers.value.filter((l) => l.listed && (group === null ? !l.group || !model.value?.groups.some((g) => g.name === l.group) : l.group === group))\n }\n\n function groupState(group: string): 'visible' | 'hidden' | 'partial' {\n const visible = layersOf(group).map((l) => isVisible(l.id))\n if (visible.length && visible.every(Boolean)) return 'visible'\n if (visible.some(Boolean)) return 'partial'\n return 'hidden'\n }\n\n function setGroupVisible(group: string, visible: boolean) {\n for (const layer of layersOf(group)) setVisible(layer.id, visible)\n }\n\n const baseLayers = computed(() => layers.value.filter((l) => l.base))\n /** The visible base layer's id, or null */\n const baseLayer = computed(() => baseLayers.value.find((l) => isVisible(l.id))?.id ?? null)\n\n /** Shows this base layer only (null: none). */\n function setBaseLayer(id: string | null) {\n for (const layer of baseLayers.value) setVisible(layer.id, layer.id === id)\n }\n\n return {\n /** The adapter's model (undefined without an `adapter`) */\n model: computed(() => model.value),\n layers,\n isVisible,\n setVisible,\n toggle,\n opacityOf,\n setOpacity,\n layersOf,\n groupState,\n setGroupVisible,\n baseLayers,\n baseLayer,\n setBaseLayer,\n }\n}\n","import type * as Maplibre from 'maplibre-gl'\n\n/*\n * Internal (not exported from index.ts): what MMap carries over when `mapStyle` changes.\n *\n * MapLibre's setStyle() replaces everything, so sources and layers added at runtime (with useMap(), or the\n * library's own MMapGeoJson / MMapMeasure) were gone after a switch, until whoever added them noticed. A\n * `transformStyle` hook moves them into the next style instead: whatever wasn't part of the previous style as\n * loaded (`own`) was added at runtime. The library's components re-add theirs only when missing, so they just find\n * them there.\n */\n\n/** The ids a style came with, before anything was added at runtime */\nexport interface StyleIds {\n sources: Set<string>\n layers: Set<string>\n}\n\nexport function styleIds(style: Pick<Maplibre.StyleSpecification, 'sources' | 'layers'> | undefined): StyleIds {\n return {\n sources: new Set(Object.keys(style?.sources ?? {})),\n layers: new Set((style?.layers ?? []).map((l) => l.id)),\n }\n}\n\n/**\n * `next` with the runtime sources and layers of `previous` added: layers on top, in their order, unless `keep`\n * says no or the next style has the same id; sources unless the next style has one by that id (it wins, and\n * carried layers use it).\n */\nexport function carryRuntimeLayers(\n previous: Maplibre.StyleSpecification | undefined,\n next: Maplibre.StyleSpecification,\n own: StyleIds,\n keep: (layer: Maplibre.LayerSpecification) => boolean = () => true,\n): Maplibre.StyleSpecification {\n if (!previous) return next\n const nextLayers = new Set(next.layers.map((l) => l.id))\n const layers = previous.layers.filter((l) => !own.layers.has(l.id) && !nextLayers.has(l.id) && keep(l))\n const sources = { ...next.sources }\n for (const [id, source] of Object.entries(previous.sources)) {\n if (!own.sources.has(id) && !(id in sources)) sources[id] = source\n }\n return { ...next, sources, layers: [...next.layers, ...layers] }\n}\n","<script setup lang=\"ts\">\n/**\n * A MapLibre GL map, for any style: a style URL (from an MVT server like mvt-rs, MapTiler, OpenFreeMap…) or a style\n * object. Its controls take the M3 look and the app's locale, the view can be a v-model and remembered between visits,\n * and markers, popups, GeoJSON layers and your own controls go inside it as components. For anything else, the\n * MapLibre map itself is the `ready` event's argument and the `map` of `useMap()` in components placed inside.\n * Available from the `/map` entry point; needs `maplibre-gl` installed and its CSS imported\n * (`maplibre-gl/dist/maplibre-gl.css`). Give it a height. Server-side rendering renders the empty container: MapLibre\n * loads in the browser.\n *\n * @slot default Map components (`MMapMarker`, `MMapPopup`, `MMapGeoJson`, `MMapControl`) and anything to show over\n * the map, rendered once the map exists\n * @event ready The map loaded (with its style), with the MapLibre `Map`\n * @event click A click on the map (MapLibre's `MapMouseEvent`: `lngLat`, `point`)\n * @event update:center The view moved (on `moveend`): `[lng, lat]`\n * @event update:zoom The zoom changed (on `moveend`)\n * @event update:bearing The rotation changed (on `moveend`)\n * @event update:pitch The tilt changed (on `moveend`)\n */\nimport { markRaw, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapAttribution from './_MMapAttribution.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { MAP_KEY, type MapContext, type MaplibreModule } from '../composables/useMap'\nimport { createLayerState, readLayerState } from '../composables/useMapLayers'\nimport { storageKey } from '../composables/_storageKeys'\nimport type { MapAdapter, MapLayerModel } from '../composables/mapAdapters'\nimport { carryRuntimeLayers, styleIds, type StyleIds } from '../composables/_mapStyle'\n\nexport type MapControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The map's style: a style JSON URL or a style object (MapLibre's `StyleSpecification`). Changing it reloads the\n * style, keeping what was added at runtime (see `keepLayers`)\n */\n mapStyle: string | Maplibre.StyleSpecification\n /**\n * What happens to the sources and layers added at runtime (with `useMap()`, or by `MMapGeoJson`, `MMapMeasure`…)\n * when `mapStyle` changes: `true` carries them into the new style, on top of its layers; `false` drops them, as\n * MapLibre does; a function picks the layers to carry (their sources come along)\n */\n keepLayers?: boolean | ((layer: Maplibre.LayerSpecification) => boolean)\n /**\n * MapLibre's `transformStyle` for a `mapStyle` change, run after `keepLayers`: edit the next style before it\n * loads (copy a layer's paint over, add a sprite…)\n */\n transformStyle?: Maplibre.TransformStyleFunction\n /** `[lng, lat]` (v-model). When left out, the style's (or the remembered view's) */\n center?: [number, number]\n /** Zoom level (v-model) */\n zoom?: number\n /** Rotation in degrees (v-model) */\n bearing?: number\n /** Tilt in degrees (v-model) */\n pitch?: number\n /**\n * Remember the view (center, zoom, bearing, pitch) in localStorage and start from it on the next visit: `true`\n * under `m3-map-view` (after `createM3UI`'s `storagePrefix`, if any), or your own key (one per map)\n */\n persist?: boolean | string\n /** Zoom and compass buttons: `false`, or a corner (`true` is top-right) */\n navigation?: boolean | MapControlPosition\n /** A button that centers the map on the user's location and follows it: `false`, or a corner (`true` is top-right) */\n geolocate?: boolean | MapControlPosition\n /** A fullscreen button: `false`, or a corner (`true` is top-right) */\n fullscreen?: boolean | MapControlPosition\n /** A metric scale bar: `false`, or a corner (`true` is bottom-left) */\n scale?: boolean | MapControlPosition\n /** The credits of the style's sources, an info button that opens into a pill: `false`, or a corner (`true` is bottom-right). Most tile providers require it */\n attribution?: boolean | MapControlPosition\n /** Anything else for MapLibre's `Map` constructor (`maxZoom`, `maxBounds`, `cooperativeGestures`…) */\n options?: Partial<Omit<Maplibre.MapOptions, 'container' | 'style'>>\n /**\n * Reads the style's conventions (layer names, groups, base layers, what to identify or show on hover) for\n * `MMapLayers`, `MMapBaseLayers`, `MMapIdentify` and `MMapHover`: `genericAdapter`, `orvianAdapter()`, or your own\n */\n adapter?: MapAdapter\n }>(),\n {\n persist: false,\n keepLayers: true,\n navigation: true,\n geolocate: false,\n fullscreen: false,\n scale: true,\n attribution: true,\n },\n)\n\nconst emit = defineEmits<{\n ready: [map: Maplibre.Map]\n click: [event: Maplibre.MapMouseEvent]\n 'update:center': [center: [number, number]]\n 'update:zoom': [zoom: number]\n 'update:bearing': [bearing: number]\n 'update:pitch': [pitch: number]\n}>()\n\nconst root = ref<HTMLElement>()\nconst container = ref<HTMLElement>()\nconst map = shallowRef<Maplibre.Map>()\nconst maplibre = shallowRef<MaplibreModule>()\nconst styleVersion = ref(0)\n// The sources and layers the current style came with (the rest were added at runtime: keepLayers)\nlet ownIds: StyleIds | undefined\nconst model = shallowRef<MapLayerModel>()\nconst layerState = createLayerState()\nconst activeTool = ref<string | null>(null)\nconst context: MapContext = { map, maplibre, styleVersion, model, layerState, activeTool }\nprovide(MAP_KEY, context)\n\n/** The adapter's model of the current style, and the layers' visibility and opacity in it. */\nfunction readModel(m: Maplibre.Map) {\n model.value = props.adapter\n ? props.adapter(m.getStyle(), { styleUrl: typeof props.mapStyle === 'string' ? props.mapStyle : undefined })\n : undefined\n readLayerState(layerState, m, model.value)\n}\n\nconst t = useLocale()\n\n// ── Remembered view ────────────────────────────────────────────────────────────────────────────\n\ninterface View { center: [number, number]; zoom: number; bearing: number; pitch: number }\nconst persistKey = () => (typeof props.persist === 'string' ? props.persist : props.persist ? storageKey('m3-map-view') : null)\n\nfunction readView(): Partial<View> {\n const key = persistKey()\n if (!key) return {}\n try {\n const view = JSON.parse(localStorage.getItem(key) ?? 'null') as Partial<View> | null\n return view && typeof view === 'object' ? view : {}\n } catch {\n return {}\n }\n}\n\nfunction currentView(m: Maplibre.Map): View {\n const c = m.getCenter()\n return { center: [c.lng, c.lat], zoom: m.getZoom(), bearing: m.getBearing(), pitch: m.getPitch() }\n}\n\n// ── Controls ───────────────────────────────────────────────────────────────────────────────────\n\n// The attribution is a component of ours (_MMapAttribution, in the template), not MapLibre's control\ntype ControlName = 'navigation' | 'geolocate' | 'fullscreen' | 'scale'\nconst CONTROLS: Record<ControlName, { corner: MapControlPosition; create: (ml: MaplibreModule) => Maplibre.IControl }> = {\n navigation: { corner: 'top-right', create: (ml) => new ml.NavigationControl() },\n geolocate: {\n corner: 'top-right',\n create: (ml) => new ml.GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true }),\n },\n fullscreen: { corner: 'top-right', create: (ml) => new ml.FullscreenControl({ container: root.value }) },\n scale: { corner: 'bottom-left', create: (ml) => new ml.ScaleControl({ maxWidth: 100, unit: 'metric' }) },\n}\nconst added = new Map<ControlName, Maplibre.IControl>()\n\nfunction syncControl(name: ControlName) {\n const m = map.value\n const ml = maplibre.value\n if (!m || !ml) return\n const old = added.get(name)\n if (old) {\n m.removeControl(old)\n added.delete(name)\n }\n const setting = props[name]\n if (!setting) return\n const control = CONTROLS[name].create(ml)\n m.addControl(control, setting === true ? CONTROLS[name].corner : setting)\n added.set(name, control)\n}\n\nfor (const name of Object.keys(CONTROLS) as ControlName[]) watch(() => props[name], () => syncControl(name))\n\n// ── Map ────────────────────────────────────────────────────────────────────────────────────────\n\n/** MapLibre's UI strings, from the app's M3 locale. */\nfunction mapLocale() {\n return {\n 'AttributionControl.ToggleAttribution': t.mapToggleAttribution,\n 'AttributionControl.MapFeedback': t.mapFeedback,\n 'FullscreenControl.Enter': t.mapEnterFullscreen,\n 'FullscreenControl.Exit': t.mapExitFullscreen,\n 'GeolocateControl.FindMyLocation': t.mapFindMyLocation,\n 'GeolocateControl.LocationNotAvailable': t.mapLocationNotAvailable,\n 'Map.Title': t.mapTitle,\n 'Marker.Title': t.mapMarker,\n 'NavigationControl.ResetBearing': t.mapResetBearing,\n 'NavigationControl.ZoomIn': t.mapZoomIn,\n 'NavigationControl.ZoomOut': t.mapZoomOut,\n 'Popup.Close': t.close,\n 'CooperativeGesturesHandler.WindowsHelpText': t.mapCtrlScroll,\n 'CooperativeGesturesHandler.MacHelpText': t.mapCmdScroll,\n 'CooperativeGesturesHandler.MobileHelpText': t.mapTwoFingers,\n }\n}\n\n// ── Control tooltips ───────────────────────────────────────────────────────────────────────────\n// MapLibre's buttons (and yours, in MMapControl) carry a `title`, which the browser shows as its own tooltip: it's\n// moved to data-m3-tip (and aria-label when there's none) and shown as an M3 plain tooltip, inside the map so it's\n// there in fullscreen too\n\nconst TIP_DELAY = 600 // MTooltip's\nconst tip = ref<{ text: string; x: number; y: number; left: boolean } | null>(null)\nlet tipTimer: ReturnType<typeof setTimeout> | undefined\nlet tipObserver: MutationObserver | undefined\n\nfunction adoptTitle(el: Element) {\n const title = el.getAttribute('title')\n if (!title || !el.closest('.maplibregl-ctrl')) return\n el.setAttribute('data-m3-tip', title)\n if (!el.hasAttribute('aria-label')) el.setAttribute('aria-label', title)\n el.removeAttribute('title')\n}\n\nfunction showTip(el: HTMLElement) {\n const text = el.getAttribute('data-m3-tip')\n const box = root.value?.getBoundingClientRect()\n if (!text || !box) return\n const r = el.getBoundingClientRect()\n // Toward the inside of the map: left of a control on the right half, right of one on the left\n const left = r.left + r.width / 2 > box.left + box.width / 2\n tip.value = { text, left, x: (left ? r.left - 8 : r.right + 8) - box.left, y: r.top + r.height / 2 - box.top }\n}\n\nfunction hideTip() {\n clearTimeout(tipTimer)\n tip.value = null\n}\n\nconst tipTarget = (e: Event) => (e.target as Element | null)?.closest?.<HTMLElement>('.maplibregl-ctrl [data-m3-tip]') ?? null\n\nfunction onTipOver(e: PointerEvent) {\n const el = tipTarget(e)\n if (!el || e.pointerType === 'touch') return\n clearTimeout(tipTimer)\n tipTimer = setTimeout(() => showTip(el), TIP_DELAY)\n}\nfunction onTipOut(e: PointerEvent) {\n const el = tipTarget(e)\n if (el && !el.contains(e.relatedTarget as Node | null)) hideTip()\n}\nfunction onTipFocus(e: FocusEvent) {\n const el = tipTarget(e)\n if (el?.matches(':focus-visible')) showTip(el)\n}\n\nonMounted(() => {\n const el = root.value\n if (!el) return\n el.querySelectorAll('[title]').forEach(adoptTitle)\n tipObserver = new MutationObserver((records) => {\n for (const r of records) {\n if (r.type === 'attributes') adoptTitle(r.target as Element)\n else r.addedNodes.forEach((n) => {\n if (!(n instanceof Element)) return\n adoptTitle(n)\n n.querySelectorAll('[title]').forEach(adoptTitle)\n })\n }\n })\n tipObserver.observe(el, { subtree: true, childList: true, attributes: true, attributeFilter: ['title'] })\n})\n\nonBeforeUnmount(() => {\n tipObserver?.disconnect()\n clearTimeout(tipTimer)\n})\n\nlet destroyed = false\n\nonMounted(async () => {\n // maplibre-gl ships a UMD build: depending on the bundler its classes are on the namespace or on `default`\n const mod = await import('maplibre-gl')\n const ml = ('Map' in mod ? mod : (mod as { default: MaplibreModule }).default) as MaplibreModule\n if (destroyed || !container.value) return\n const saved = readView()\n const view = {\n center: saved.center ?? props.center,\n zoom: saved.zoom ?? props.zoom,\n bearing: saved.bearing ?? props.bearing,\n pitch: saved.pitch ?? props.pitch,\n }\n const m = markRaw(new ml.Map({\n container: container.value,\n style: props.mapStyle,\n attributionControl: false,\n locale: mapLocale(),\n // Only what's set, so a style's own center and zoom apply otherwise\n ...Object.fromEntries(Object.entries(view).filter(([, v]) => v !== undefined)),\n ...props.options,\n }))\n maplibre.value = ml\n\n m.on('style.load', () => {\n // The first style's own ids; a later style's are taken in transformStyle, before runtime layers join it\n if (!ownIds) ownIds = styleIds(m.getStyle())\n readModel(m)\n styleVersion.value++\n })\n m.on('click', (e) => emit('click', e))\n m.on('moveend', () => {\n const v = currentView(m)\n emit('update:center', v.center)\n emit('update:zoom', v.zoom)\n emit('update:bearing', v.bearing)\n emit('update:pitch', v.pitch)\n const key = persistKey()\n if (key) {\n try { localStorage.setItem(key, JSON.stringify(v)) } catch { /* storage blocked */ }\n }\n })\n m.once('load', () => {\n // The map is shared once its style is loaded: components can add sources and layers right away\n map.value = m\n for (const name of Object.keys(CONTROLS) as ControlName[]) syncControl(name)\n emit('ready', m)\n })\n})\n\n// After the children's unmount hooks (a parent's beforeUnmount runs before theirs): they remove their layers, markers\n// and controls from a map that still exists\nonUnmounted(() => {\n destroyed = true\n map.value?.remove()\n map.value = undefined\n})\n\n// ── v-model ────────────────────────────────────────────────────────────────────────────────────\n// Compared by value: an inline `:center=\"[lng, lat]\"` is a new array on every parent render\n\nconst near = (a: number, b: number) => Math.abs(a - b) < 1e-9\nwatch(() => props.center?.join(','), () => {\n const m = map.value\n if (!m || !props.center) return\n const c = m.getCenter()\n if (!near(c.lng, props.center[0]) || !near(c.lat, props.center[1])) m.jumpTo({ center: props.center })\n})\nwatch(() => props.zoom, (zoom) => {\n if (map.value && zoom !== undefined && !near(map.value.getZoom(), zoom)) map.value.jumpTo({ zoom })\n})\nwatch(() => props.bearing, (bearing) => {\n if (map.value && bearing !== undefined && !near(map.value.getBearing(), bearing)) map.value.jumpTo({ bearing })\n})\nwatch(() => props.pitch, (pitch) => {\n if (map.value && pitch !== undefined && !near(map.value.getPitch(), pitch)) map.value.jumpTo({ pitch })\n})\nwatch(() => props.adapter, () => { if (map.value) readModel(map.value) })\n// A full reload (no diff): style.load fires, and components re-add whatever didn't come along\nwatch(() => props.mapStyle, (style) => map.value?.setStyle(style, {\n diff: false,\n transformStyle: (previous, next) => {\n const own = ownIds ?? styleIds(undefined)\n ownIds = styleIds(next)\n const keep = props.keepLayers\n let result = keep === false ? next : carryRuntimeLayers(previous, next, own, typeof keep === 'function' ? keep : undefined)\n if (props.transformStyle) result = props.transformStyle(previous, result)\n return result\n },\n}))\n\ndefineExpose({\n /** The MapLibre map, once loaded */\n map,\n /** What the components inside it share: pass the `MMap` (or this) as `map` to `MMapLayers`, `useMap()`… outside it */\n context,\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"m3-map relative overflow-hidden\"\n @pointerover=\"onTipOver\"\n @pointerout=\"onTipOut\"\n @pointerdown=\"hideTip\"\n @focusin=\"onTipFocus\"\n @focusout=\"hideTip\"\n >\n <!-- Sized, not positioned: MapLibre's CSS makes it position: relative (.maplibregl-map), which would undo absolute -->\n <div ref=\"container\" class=\"h-full w-full\" />\n <!-- Before the slot: added to its corner first, so it stays at the corner's edge -->\n <MMapAttribution v-if=\"map && attribution\" :position=\"attribution === true ? 'bottom-right' : attribution\" />\n <slot v-if=\"map\" />\n <Transition\n enter-active-class=\"transition-opacity duration-150\"\n enter-from-class=\"opacity-0\"\n leave-active-class=\"transition-opacity duration-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"tip\"\n role=\"tooltip\"\n class=\"pointer-events-none absolute z-10 min-h-6 max-w-[200px] -translate-y-1/2 rounded bg-inverse-surface px-2 py-1 text-body-small whitespace-nowrap text-inverse-on-surface\"\n :class=\"tip.left ? '-translate-x-full' : ''\"\n :style=\"{ left: `${tip.x}px`, top: `${tip.y}px` }\"\n >\n {{ tip.text }}\n </div>\n </Transition>\n </div>\n</template>\n\n<style>\n/* The app's typeface, not MapLibre's Helvetica (attribution, scale, popups) */\n.m3-map .maplibregl-map {\n font: inherit;\n}\n\n/* MapLibre's controls, popups and markers in M3: the theme's colors (they follow palette and dark mode), Material\n Symbols icons instead of MapLibre's fixed-color SVGs, M3 shapes and elevation. Scoped to .m3-map. */\n.m3-map .maplibregl-ctrl-group {\n background: var(--color-surface-container-high);\n border-radius: 12px;\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n}\n.m3-map .maplibregl-ctrl-group:not(:empty) {\n box-shadow: var(--shadow-elevation-2);\n}\n/* MMapControl: switching group on or off, or expanding into its panel, fades the surface instead of snapping */\n.m3-map .m3-map-control {\n transition: background-color 200ms, box-shadow 200ms, border-radius 200ms;\n}\n.m3-map .m3-map-control-panel {\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n border-radius: 16px;\n box-shadow: var(--shadow-elevation-2);\n}\n.m3-map .m3-map-control-panel-in {\n animation: m3-map-control-in 200ms 60ms both;\n}\n@keyframes m3-map-control-in {\n from { opacity: 0; }\n}\n@media (prefers-reduced-motion: reduce) {\n .m3-map .m3-map-control-panel-in { animation: none; }\n}\n.m3-map .maplibregl-ctrl-group button {\n width: 40px;\n height: 40px;\n color: var(--color-on-surface-variant);\n}\n.m3-map .maplibregl-ctrl-group button + button {\n border-top: 1px solid var(--color-outline-variant);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):active {\n background-color: color-mix(in srgb, var(--color-on-surface) 12%, transparent);\n}\n.m3-map .maplibregl-ctrl-group button[aria-pressed='true'] {\n background-color: var(--color-primary-container);\n color: var(--color-on-primary-container);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:disabled {\n color: color-mix(in srgb, var(--color-on-surface) 38%, transparent);\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n background-image: none !important;\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon::before {\n font-family: 'Material Symbols Outlined';\n font-size: 20px;\n line-height: 1;\n font-feature-settings: 'liga';\n -webkit-font-smoothing: antialiased;\n}\n.m3-map .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before { content: 'add'; }\n.m3-map .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before { content: 'remove'; }\n.m3-map .maplibregl-ctrl-compass .maplibregl-ctrl-icon::before { content: 'navigation'; }\n.m3-map .maplibregl-ctrl-geolocate .maplibregl-ctrl-icon::before { content: 'my_location'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting {\n color: var(--color-primary);\n}\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon::before { content: 'location_searching'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error {\n color: var(--color-error);\n}\n.m3-map .maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon::before { content: 'location_disabled'; }\n.m3-map .maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon::before { content: 'fullscreen'; }\n.m3-map .maplibregl-ctrl-shrink .maplibregl-ctrl-icon::before { content: 'fullscreen_exit'; }\n\n/* Attribution (_MMapAttribution): a round icon button that opens into a pill with the credits. The surface is the\n control itself, so MMapControl's size spring reveals the text; the row keeps its own width (max-content, capped at\n the map's) so the text doesn't reflow while the control's size animates. */\n.m3-map .m3-map-attrib {\n border-radius: 16px;\n background: var(--color-surface-container-high);\n box-shadow: var(--shadow-elevation-2);\n color: var(--color-on-surface-variant);\n}\n.m3-map .m3-map-attrib-row {\n display: flex;\n align-items: center;\n width: max-content;\n}\n.m3-map .m3-map-attrib-button {\n flex: none;\n display: grid;\n place-items: center;\n width: 32px;\n height: 32px;\n border-radius: 16px;\n color: var(--color-on-surface-variant);\n cursor: pointer;\n transition: background-color 150ms, color 150ms;\n}\n.m3-map .m3-map-attrib-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .m3-map-attrib-button:focus-visible {\n outline: none;\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .m3-map-attrib-open .m3-map-attrib-button {\n color: var(--color-primary);\n}\n.m3-map .m3-map-attrib-text {\n min-width: 0;\n padding-block: 8px;\n font-size: 12px;\n line-height: 16px;\n letter-spacing: 0.4px;\n animation: m3-map-control-in 200ms 60ms both;\n}\n.m3-map .m3-map-attrib-text a {\n color: var(--color-on-surface);\n text-decoration: none;\n}\n.m3-map .m3-map-attrib-text a:hover {\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.m3-map .maplibregl-ctrl-scale {\n background: color-mix(in srgb, var(--color-surface-container-high) 85%, transparent);\n border-color: var(--color-outline);\n color: var(--color-on-surface-variant);\n font-size: 11px;\n}\n\n/* Popups: an M3 surface (elevation 2, 16px corners) with a matching tip */\n.m3-map .maplibregl-popup-content {\n padding: 12px 16px;\n border-radius: 16px;\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n font: inherit;\n font-size: var(--text-body-medium);\n line-height: var(--text-body-medium--line-height);\n}\n.m3-map .maplibregl-popup-anchor-top .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {\n border-bottom-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-bottom .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {\n border-top-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-left .maplibregl-popup-tip {\n border-right-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-right .maplibregl-popup-tip {\n border-left-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-close-button {\n top: 6px;\n right: 6px;\n width: 28px;\n height: 28px;\n border-radius: 14px;\n color: var(--color-on-surface-variant);\n font-size: 18px;\n line-height: 1;\n}\n.m3-map .maplibregl-popup-close-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n\n/* The default marker takes the theme's primary (its SVG is drawn in currentColor) */\n.m3-map .m3-map-marker--default {\n color: var(--color-primary);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * A MapLibre GL map, for any style: a style URL (from an MVT server like mvt-rs, MapTiler, OpenFreeMap…) or a style\n * object. Its controls take the M3 look and the app's locale, the view can be a v-model and remembered between visits,\n * and markers, popups, GeoJSON layers and your own controls go inside it as components. For anything else, the\n * MapLibre map itself is the `ready` event's argument and the `map` of `useMap()` in components placed inside.\n * Available from the `/map` entry point; needs `maplibre-gl` installed and its CSS imported\n * (`maplibre-gl/dist/maplibre-gl.css`). Give it a height. Server-side rendering renders the empty container: MapLibre\n * loads in the browser.\n *\n * @slot default Map components (`MMapMarker`, `MMapPopup`, `MMapGeoJson`, `MMapControl`) and anything to show over\n * the map, rendered once the map exists\n * @event ready The map loaded (with its style), with the MapLibre `Map`\n * @event click A click on the map (MapLibre's `MapMouseEvent`: `lngLat`, `point`)\n * @event update:center The view moved (on `moveend`): `[lng, lat]`\n * @event update:zoom The zoom changed (on `moveend`)\n * @event update:bearing The rotation changed (on `moveend`)\n * @event update:pitch The tilt changed (on `moveend`)\n */\nimport { markRaw, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapAttribution from './_MMapAttribution.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { MAP_KEY, type MapContext, type MaplibreModule } from '../composables/useMap'\nimport { createLayerState, readLayerState } from '../composables/useMapLayers'\nimport { storageKey } from '../composables/_storageKeys'\nimport type { MapAdapter, MapLayerModel } from '../composables/mapAdapters'\nimport { carryRuntimeLayers, styleIds, type StyleIds } from '../composables/_mapStyle'\n\nexport type MapControlPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n\nconst props = withDefaults(\n defineProps<{\n /**\n * The map's style: a style JSON URL or a style object (MapLibre's `StyleSpecification`). Changing it reloads the\n * style, keeping what was added at runtime (see `keepLayers`)\n */\n mapStyle: string | Maplibre.StyleSpecification\n /**\n * What happens to the sources and layers added at runtime (with `useMap()`, or by `MMapGeoJson`, `MMapMeasure`…)\n * when `mapStyle` changes: `true` carries them into the new style, on top of its layers; `false` drops them, as\n * MapLibre does; a function picks the layers to carry (their sources come along)\n */\n keepLayers?: boolean | ((layer: Maplibre.LayerSpecification) => boolean)\n /**\n * MapLibre's `transformStyle` for a `mapStyle` change, run after `keepLayers`: edit the next style before it\n * loads (copy a layer's paint over, add a sprite…)\n */\n transformStyle?: Maplibre.TransformStyleFunction\n /** `[lng, lat]` (v-model). When left out, the style's (or the remembered view's) */\n center?: [number, number]\n /** Zoom level (v-model) */\n zoom?: number\n /** Rotation in degrees (v-model) */\n bearing?: number\n /** Tilt in degrees (v-model) */\n pitch?: number\n /**\n * Remember the view (center, zoom, bearing, pitch) in localStorage and start from it on the next visit: `true`\n * under `m3-map-view` (after `createM3UI`'s `storagePrefix`, if any), or your own key (one per map)\n */\n persist?: boolean | string\n /** Zoom and compass buttons: `false`, or a corner (`true` is top-right) */\n navigation?: boolean | MapControlPosition\n /** A button that centers the map on the user's location and follows it: `false`, or a corner (`true` is top-right) */\n geolocate?: boolean | MapControlPosition\n /** A fullscreen button: `false`, or a corner (`true` is top-right) */\n fullscreen?: boolean | MapControlPosition\n /** A metric scale bar: `false`, or a corner (`true` is bottom-left) */\n scale?: boolean | MapControlPosition\n /** The credits of the style's sources, an info button that opens into a pill: `false`, or a corner (`true` is bottom-right). Most tile providers require it */\n attribution?: boolean | MapControlPosition\n /** Anything else for MapLibre's `Map` constructor (`maxZoom`, `maxBounds`, `cooperativeGestures`…) */\n options?: Partial<Omit<Maplibre.MapOptions, 'container' | 'style'>>\n /**\n * Reads the style's conventions (layer names, groups, base layers, what to identify or show on hover) for\n * `MMapLayers`, `MMapBaseLayers`, `MMapIdentify` and `MMapHover`: `genericAdapter`, `orvianAdapter()`, or your own\n */\n adapter?: MapAdapter\n }>(),\n {\n persist: false,\n keepLayers: true,\n navigation: true,\n geolocate: false,\n fullscreen: false,\n scale: true,\n attribution: true,\n },\n)\n\nconst emit = defineEmits<{\n ready: [map: Maplibre.Map]\n click: [event: Maplibre.MapMouseEvent]\n 'update:center': [center: [number, number]]\n 'update:zoom': [zoom: number]\n 'update:bearing': [bearing: number]\n 'update:pitch': [pitch: number]\n}>()\n\nconst root = ref<HTMLElement>()\nconst container = ref<HTMLElement>()\nconst map = shallowRef<Maplibre.Map>()\nconst maplibre = shallowRef<MaplibreModule>()\nconst styleVersion = ref(0)\n// The sources and layers the current style came with (the rest were added at runtime: keepLayers)\nlet ownIds: StyleIds | undefined\nconst model = shallowRef<MapLayerModel>()\nconst layerState = createLayerState()\nconst activeTool = ref<string | null>(null)\nconst context: MapContext = { map, maplibre, styleVersion, model, layerState, activeTool }\nprovide(MAP_KEY, context)\n\n/** The adapter's model of the current style, and the layers' visibility and opacity in it. */\nfunction readModel(m: Maplibre.Map) {\n model.value = props.adapter\n ? props.adapter(m.getStyle(), { styleUrl: typeof props.mapStyle === 'string' ? props.mapStyle : undefined })\n : undefined\n readLayerState(layerState, m, model.value)\n}\n\nconst t = useLocale()\n\n// ── Remembered view ────────────────────────────────────────────────────────────────────────────\n\ninterface View { center: [number, number]; zoom: number; bearing: number; pitch: number }\nconst persistKey = () => (typeof props.persist === 'string' ? props.persist : props.persist ? storageKey('m3-map-view') : null)\n\nfunction readView(): Partial<View> {\n const key = persistKey()\n if (!key) return {}\n try {\n const view = JSON.parse(localStorage.getItem(key) ?? 'null') as Partial<View> | null\n return view && typeof view === 'object' ? view : {}\n } catch {\n return {}\n }\n}\n\nfunction currentView(m: Maplibre.Map): View {\n const c = m.getCenter()\n return { center: [c.lng, c.lat], zoom: m.getZoom(), bearing: m.getBearing(), pitch: m.getPitch() }\n}\n\n// ── Controls ───────────────────────────────────────────────────────────────────────────────────\n\n// The attribution is a component of ours (_MMapAttribution, in the template), not MapLibre's control\ntype ControlName = 'navigation' | 'geolocate' | 'fullscreen' | 'scale'\nconst CONTROLS: Record<ControlName, { corner: MapControlPosition; create: (ml: MaplibreModule) => Maplibre.IControl }> = {\n navigation: { corner: 'top-right', create: (ml) => new ml.NavigationControl() },\n geolocate: {\n corner: 'top-right',\n create: (ml) => new ml.GeolocateControl({ positionOptions: { enableHighAccuracy: true }, trackUserLocation: true }),\n },\n fullscreen: { corner: 'top-right', create: (ml) => new ml.FullscreenControl({ container: root.value }) },\n scale: { corner: 'bottom-left', create: (ml) => new ml.ScaleControl({ maxWidth: 100, unit: 'metric' }) },\n}\nconst added = new Map<ControlName, Maplibre.IControl>()\n\nfunction syncControl(name: ControlName) {\n const m = map.value\n const ml = maplibre.value\n if (!m || !ml) return\n const old = added.get(name)\n if (old) {\n m.removeControl(old)\n added.delete(name)\n }\n const setting = props[name]\n if (!setting) return\n const control = CONTROLS[name].create(ml)\n m.addControl(control, setting === true ? CONTROLS[name].corner : setting)\n added.set(name, control)\n}\n\nfor (const name of Object.keys(CONTROLS) as ControlName[]) watch(() => props[name], () => syncControl(name))\n\n// ── Map ────────────────────────────────────────────────────────────────────────────────────────\n\n/** MapLibre's UI strings, from the app's M3 locale. */\nfunction mapLocale() {\n return {\n 'AttributionControl.ToggleAttribution': t.mapToggleAttribution,\n 'AttributionControl.MapFeedback': t.mapFeedback,\n 'FullscreenControl.Enter': t.mapEnterFullscreen,\n 'FullscreenControl.Exit': t.mapExitFullscreen,\n 'GeolocateControl.FindMyLocation': t.mapFindMyLocation,\n 'GeolocateControl.LocationNotAvailable': t.mapLocationNotAvailable,\n 'Map.Title': t.mapTitle,\n 'Marker.Title': t.mapMarker,\n 'NavigationControl.ResetBearing': t.mapResetBearing,\n 'NavigationControl.ZoomIn': t.mapZoomIn,\n 'NavigationControl.ZoomOut': t.mapZoomOut,\n 'Popup.Close': t.close,\n 'CooperativeGesturesHandler.WindowsHelpText': t.mapCtrlScroll,\n 'CooperativeGesturesHandler.MacHelpText': t.mapCmdScroll,\n 'CooperativeGesturesHandler.MobileHelpText': t.mapTwoFingers,\n }\n}\n\n// ── Control tooltips ───────────────────────────────────────────────────────────────────────────\n// MapLibre's buttons (and yours, in MMapControl) carry a `title`, which the browser shows as its own tooltip: it's\n// moved to data-m3-tip (and aria-label when there's none) and shown as an M3 plain tooltip, inside the map so it's\n// there in fullscreen too\n\nconst TIP_DELAY = 600 // MTooltip's\nconst tip = ref<{ text: string; x: number; y: number; left: boolean } | null>(null)\nlet tipTimer: ReturnType<typeof setTimeout> | undefined\nlet tipObserver: MutationObserver | undefined\n\nfunction adoptTitle(el: Element) {\n const title = el.getAttribute('title')\n if (!title || !el.closest('.maplibregl-ctrl')) return\n el.setAttribute('data-m3-tip', title)\n if (!el.hasAttribute('aria-label')) el.setAttribute('aria-label', title)\n el.removeAttribute('title')\n}\n\nfunction showTip(el: HTMLElement) {\n const text = el.getAttribute('data-m3-tip')\n const box = root.value?.getBoundingClientRect()\n if (!text || !box) return\n const r = el.getBoundingClientRect()\n // Toward the inside of the map: left of a control on the right half, right of one on the left\n const left = r.left + r.width / 2 > box.left + box.width / 2\n tip.value = { text, left, x: (left ? r.left - 8 : r.right + 8) - box.left, y: r.top + r.height / 2 - box.top }\n}\n\nfunction hideTip() {\n clearTimeout(tipTimer)\n tip.value = null\n}\n\nconst tipTarget = (e: Event) => (e.target as Element | null)?.closest?.<HTMLElement>('.maplibregl-ctrl [data-m3-tip]') ?? null\n\nfunction onTipOver(e: PointerEvent) {\n const el = tipTarget(e)\n if (!el || e.pointerType === 'touch') return\n clearTimeout(tipTimer)\n tipTimer = setTimeout(() => showTip(el), TIP_DELAY)\n}\nfunction onTipOut(e: PointerEvent) {\n const el = tipTarget(e)\n if (el && !el.contains(e.relatedTarget as Node | null)) hideTip()\n}\nfunction onTipFocus(e: FocusEvent) {\n const el = tipTarget(e)\n if (el?.matches(':focus-visible')) showTip(el)\n}\n\nonMounted(() => {\n const el = root.value\n if (!el) return\n el.querySelectorAll('[title]').forEach(adoptTitle)\n tipObserver = new MutationObserver((records) => {\n for (const r of records) {\n if (r.type === 'attributes') adoptTitle(r.target as Element)\n else r.addedNodes.forEach((n) => {\n if (!(n instanceof Element)) return\n adoptTitle(n)\n n.querySelectorAll('[title]').forEach(adoptTitle)\n })\n }\n })\n tipObserver.observe(el, { subtree: true, childList: true, attributes: true, attributeFilter: ['title'] })\n})\n\nonBeforeUnmount(() => {\n tipObserver?.disconnect()\n clearTimeout(tipTimer)\n})\n\nlet destroyed = false\n\nonMounted(async () => {\n // maplibre-gl ships a UMD build: depending on the bundler its classes are on the namespace or on `default`\n const mod = await import('maplibre-gl')\n const ml = ('Map' in mod ? mod : (mod as { default: MaplibreModule }).default) as MaplibreModule\n if (destroyed || !container.value) return\n const saved = readView()\n const view = {\n center: saved.center ?? props.center,\n zoom: saved.zoom ?? props.zoom,\n bearing: saved.bearing ?? props.bearing,\n pitch: saved.pitch ?? props.pitch,\n }\n const m = markRaw(new ml.Map({\n container: container.value,\n style: props.mapStyle,\n attributionControl: false,\n locale: mapLocale(),\n // Only what's set, so a style's own center and zoom apply otherwise\n ...Object.fromEntries(Object.entries(view).filter(([, v]) => v !== undefined)),\n ...props.options,\n }))\n maplibre.value = ml\n\n m.on('style.load', () => {\n // The first style's own ids; a later style's are taken in transformStyle, before runtime layers join it\n if (!ownIds) ownIds = styleIds(m.getStyle())\n readModel(m)\n styleVersion.value++\n })\n m.on('click', (e) => emit('click', e))\n m.on('moveend', () => {\n const v = currentView(m)\n emit('update:center', v.center)\n emit('update:zoom', v.zoom)\n emit('update:bearing', v.bearing)\n emit('update:pitch', v.pitch)\n const key = persistKey()\n if (key) {\n try { localStorage.setItem(key, JSON.stringify(v)) } catch { /* storage blocked */ }\n }\n })\n m.once('load', () => {\n // The map is shared once its style is loaded: components can add sources and layers right away\n map.value = m\n for (const name of Object.keys(CONTROLS) as ControlName[]) syncControl(name)\n emit('ready', m)\n })\n})\n\n// After the children's unmount hooks (a parent's beforeUnmount runs before theirs): they remove their layers, markers\n// and controls from a map that still exists\nonUnmounted(() => {\n destroyed = true\n map.value?.remove()\n map.value = undefined\n})\n\n// ── v-model ────────────────────────────────────────────────────────────────────────────────────\n// Compared by value: an inline `:center=\"[lng, lat]\"` is a new array on every parent render\n\nconst near = (a: number, b: number) => Math.abs(a - b) < 1e-9\nwatch(() => props.center?.join(','), () => {\n const m = map.value\n if (!m || !props.center) return\n const c = m.getCenter()\n if (!near(c.lng, props.center[0]) || !near(c.lat, props.center[1])) m.jumpTo({ center: props.center })\n})\nwatch(() => props.zoom, (zoom) => {\n if (map.value && zoom !== undefined && !near(map.value.getZoom(), zoom)) map.value.jumpTo({ zoom })\n})\nwatch(() => props.bearing, (bearing) => {\n if (map.value && bearing !== undefined && !near(map.value.getBearing(), bearing)) map.value.jumpTo({ bearing })\n})\nwatch(() => props.pitch, (pitch) => {\n if (map.value && pitch !== undefined && !near(map.value.getPitch(), pitch)) map.value.jumpTo({ pitch })\n})\nwatch(() => props.adapter, () => { if (map.value) readModel(map.value) })\n// A full reload (no diff): style.load fires, and components re-add whatever didn't come along\nwatch(() => props.mapStyle, (style) => map.value?.setStyle(style, {\n diff: false,\n transformStyle: (previous, next) => {\n const own = ownIds ?? styleIds(undefined)\n ownIds = styleIds(next)\n const keep = props.keepLayers\n let result = keep === false ? next : carryRuntimeLayers(previous, next, own, typeof keep === 'function' ? keep : undefined)\n if (props.transformStyle) result = props.transformStyle(previous, result)\n return result\n },\n}))\n\ndefineExpose({\n /** The MapLibre map, once loaded */\n map,\n /** What the components inside it share: pass the `MMap` (or this) as `map` to `MMapLayers`, `useMap()`… outside it */\n context,\n})\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"m3-map relative overflow-hidden\"\n @pointerover=\"onTipOver\"\n @pointerout=\"onTipOut\"\n @pointerdown=\"hideTip\"\n @focusin=\"onTipFocus\"\n @focusout=\"hideTip\"\n >\n <!-- Sized, not positioned: MapLibre's CSS makes it position: relative (.maplibregl-map), which would undo absolute -->\n <div ref=\"container\" class=\"h-full w-full\" />\n <!-- Before the slot: added to its corner first, so it stays at the corner's edge -->\n <MMapAttribution v-if=\"map && attribution\" :position=\"attribution === true ? 'bottom-right' : attribution\" />\n <slot v-if=\"map\" />\n <Transition\n enter-active-class=\"transition-opacity duration-150\"\n enter-from-class=\"opacity-0\"\n leave-active-class=\"transition-opacity duration-100\"\n leave-to-class=\"opacity-0\"\n >\n <div\n v-if=\"tip\"\n role=\"tooltip\"\n class=\"pointer-events-none absolute z-10 min-h-6 max-w-[200px] -translate-y-1/2 rounded bg-inverse-surface px-2 py-1 text-body-small whitespace-nowrap text-inverse-on-surface\"\n :class=\"tip.left ? '-translate-x-full' : ''\"\n :style=\"{ left: `${tip.x}px`, top: `${tip.y}px` }\"\n >\n {{ tip.text }}\n </div>\n </Transition>\n </div>\n</template>\n\n<style>\n/* The app's typeface, not MapLibre's Helvetica (attribution, scale, popups) */\n.m3-map .maplibregl-map {\n font: inherit;\n}\n\n/* MapLibre's controls, popups and markers in M3: the theme's colors (they follow palette and dark mode), Material\n Symbols icons instead of MapLibre's fixed-color SVGs, M3 shapes and elevation. Scoped to .m3-map. */\n.m3-map .maplibregl-ctrl-group {\n background: var(--color-surface-container-high);\n border-radius: 12px;\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n}\n.m3-map .maplibregl-ctrl-group:not(:empty) {\n box-shadow: var(--shadow-elevation-2);\n}\n/* MMapControl: switching group on or off, or expanding into its panel, fades the surface instead of snapping */\n.m3-map .m3-map-control {\n transition: background-color 200ms, box-shadow 200ms, border-radius 200ms;\n}\n.m3-map .m3-map-control-panel {\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n border-radius: 16px;\n box-shadow: var(--shadow-elevation-2);\n}\n.m3-map .m3-map-control-panel-in {\n animation: m3-map-control-in 200ms 60ms both;\n}\n@keyframes m3-map-control-in {\n from { opacity: 0; }\n}\n@media (prefers-reduced-motion: reduce) {\n .m3-map .m3-map-control-panel-in { animation: none; }\n}\n.m3-map .maplibregl-ctrl-group button {\n width: 40px;\n height: 40px;\n color: var(--color-on-surface-variant);\n}\n.m3-map .maplibregl-ctrl-group button + button {\n border-top: 1px solid var(--color-outline-variant);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:not(:disabled):active {\n background-color: color-mix(in srgb, var(--color-on-surface) 12%, transparent);\n}\n.m3-map .maplibregl-ctrl-group button[aria-pressed='true'] {\n background-color: var(--color-primary-container);\n color: var(--color-on-primary-container);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:focus-visible {\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .maplibregl-ctrl:not(.m3-map-control-panel) button:disabled {\n color: color-mix(in srgb, var(--color-on-surface) 38%, transparent);\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon {\n display: flex;\n align-items: center;\n justify-content: center;\n background-image: none !important;\n}\n.m3-map .maplibregl-ctrl button .maplibregl-ctrl-icon::before {\n font-family: 'Material Symbols Outlined';\n font-size: 20px;\n line-height: 1;\n font-feature-settings: 'liga';\n -webkit-font-smoothing: antialiased;\n}\n.m3-map .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before { content: 'add'; }\n.m3-map .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before { content: 'remove'; }\n.m3-map .maplibregl-ctrl-compass .maplibregl-ctrl-icon::before { content: 'navigation'; }\n.m3-map .maplibregl-ctrl-geolocate .maplibregl-ctrl-icon::before { content: 'my_location'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-waiting {\n color: var(--color-primary);\n}\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background .maplibregl-ctrl-icon::before { content: 'location_searching'; }\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-active-error,\n.m3-map .maplibregl-ctrl-geolocate.maplibregl-ctrl-geolocate-background-error {\n color: var(--color-error);\n}\n.m3-map .maplibregl-ctrl-geolocate:disabled .maplibregl-ctrl-icon::before { content: 'location_disabled'; }\n.m3-map .maplibregl-ctrl-fullscreen .maplibregl-ctrl-icon::before { content: 'fullscreen'; }\n.m3-map .maplibregl-ctrl-shrink .maplibregl-ctrl-icon::before { content: 'fullscreen_exit'; }\n\n/* Attribution (_MMapAttribution): a round icon button that opens into a pill with the credits. The surface is the\n control itself, so MMapControl's size spring reveals the text; the row keeps its own width (max-content, capped at\n the map's) so the text doesn't reflow while the control's size animates. */\n.m3-map .m3-map-attrib {\n border-radius: 16px;\n background: var(--color-surface-container-high);\n box-shadow: var(--shadow-elevation-2);\n color: var(--color-on-surface-variant);\n}\n.m3-map .m3-map-attrib-row {\n display: flex;\n align-items: center;\n width: max-content;\n}\n.m3-map .m3-map-attrib-button {\n flex: none;\n display: grid;\n place-items: center;\n width: 32px;\n height: 32px;\n border-radius: 16px;\n color: var(--color-on-surface-variant);\n cursor: pointer;\n transition: background-color 150ms, color 150ms;\n}\n.m3-map .m3-map-attrib-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n.m3-map .m3-map-attrib-button:focus-visible {\n outline: none;\n box-shadow: inset 0 0 0 2px var(--color-secondary);\n}\n.m3-map .m3-map-attrib-open .m3-map-attrib-button {\n color: var(--color-primary);\n}\n.m3-map .m3-map-attrib-text {\n min-width: 0;\n padding-block: 8px;\n font-size: 12px;\n line-height: 16px;\n letter-spacing: 0.4px;\n animation: m3-map-control-in 200ms 60ms both;\n}\n.m3-map .m3-map-attrib-text a {\n color: var(--color-on-surface);\n text-decoration: none;\n}\n.m3-map .m3-map-attrib-text a:hover {\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n.m3-map .maplibregl-ctrl-scale {\n background: color-mix(in srgb, var(--color-surface-container-high) 85%, transparent);\n border-color: var(--color-outline);\n color: var(--color-on-surface-variant);\n font-size: 11px;\n}\n\n/* Popups: an M3 surface (elevation 2, 16px corners) with a matching tip */\n.m3-map .maplibregl-popup-content {\n padding: 12px 16px;\n border-radius: 16px;\n background: var(--color-surface-container-high);\n color: var(--color-on-surface);\n box-shadow: var(--shadow-elevation-2);\n overflow: hidden;\n font: inherit;\n font-size: var(--text-body-medium);\n line-height: var(--text-body-medium--line-height);\n}\n.m3-map .maplibregl-popup-anchor-top .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-top-right .maplibregl-popup-tip {\n border-bottom-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-bottom .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,\n.m3-map .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {\n border-top-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-left .maplibregl-popup-tip {\n border-right-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-anchor-right .maplibregl-popup-tip {\n border-left-color: var(--color-surface-container-high);\n}\n.m3-map .maplibregl-popup-close-button {\n top: 6px;\n right: 6px;\n width: 28px;\n height: 28px;\n border-radius: 14px;\n color: var(--color-on-surface-variant);\n font-size: 18px;\n line-height: 1;\n}\n.m3-map .maplibregl-popup-close-button:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 8%, transparent);\n}\n\n/* The default marker takes the theme's primary (its SVG is drawn in currentColor) */\n.m3-map .m3-map-marker--default {\n color: var(--color-primary);\n}\n</style>\n","// Internal (not exported): MapLibre's default marker pin. Its SVG is 41px tall with the tip at the center of the\n// shadow ellipse below it (y ≈ 34.8), so MapLibre places it by its center, offset [0, -14], and gives a popup it\n// opens an offset per side (Marker.setPopup) so the popup meets the pin wherever it opens. Passing the pin an\n// anchor of 'bottom' (plus that default offset) put the tip about 20px above its point.\nimport type * as Maplibre from 'maplibre-gl'\n\nconst HEIGHT = 41 - 5.8 / 2\nconst RADIUS = 13.5\nconst LINEAR = RADIUS / Math.SQRT2\n\n/** The default pin's offset with its default (center) anchor */\nexport const PIN_OFFSET: [number, number] = [0, -14]\n\n/** Offsets for a popup at a pin's point, per side, as MapLibre's Marker.setPopup gives them */\nexport const PIN_POPUP_OFFSET: Record<Maplibre.PositionAnchor, [number, number]> = {\n center: [0, 0],\n top: [0, 0],\n 'top-left': [0, 0],\n 'top-right': [0, 0],\n bottom: [0, -HEIGHT],\n 'bottom-left': [LINEAR, (HEIGHT - RADIUS + LINEAR) * -1],\n 'bottom-right': [-LINEAR, (HEIGHT - RADIUS + LINEAR) * -1],\n left: [RADIUS, (HEIGHT - RADIUS) * -1],\n right: [-RADIUS, (HEIGHT - RADIUS) * -1],\n}\n","<script setup lang=\"ts\">\n/**\n * A marker on an `MMap`, at `lngLat`: MapLibre's pin in the theme's primary (or `color`), or your own content from the\n * default slot. With `draggable`, `lngLat` is a v-model. Content in `#popup` opens in a popup when the marker is\n * clicked. Available from the `/map` entry point.\n *\n * @slot default The marker itself, instead of the pin (any element, anchored by `anchor`)\n * @slot popup Content of a popup that opens when the marker is clicked\n * @event update:lngLat Dragged to a new position (`draggable`): `[lng, lat]`\n * @event click The marker was clicked\n */\nimport { onBeforeUnmount, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { PIN_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` (v-model with `draggable`) */\n lngLat: [number, number]\n /** The pin's color (any CSS color). Defaults to the theme's primary; ignored with custom content */\n color?: string\n /** Let the user drag it */\n draggable?: boolean\n /**\n * Which part of the marker sits on `lngLat`. By default the pin's tip (MapLibre's placement: its center, offset\n * `[0, -14]`), and the center of custom content\n */\n anchor?: Maplibre.PositionAnchor\n /** Offset in pixels, `[x, y]`. The pin's default is MapLibre's `[0, -14]`, which puts its tip on `lngLat` */\n offset?: [number, number]\n /** Rotation in degrees */\n rotation?: number\n }>(),\n { draggable: false, rotation: 0 },\n)\n\nconst emit = defineEmits<{\n 'update:lngLat': [lngLat: [number, number]]\n click: [event: MouseEvent]\n}>()\n\nconst slots = useSlots()\nconst content = ref<HTMLElement>()\nconst popupContent = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet marker: Maplibre.Marker | undefined\nlet custom = false\n\nonReady((map, ml) => {\n custom = !!slots.default && !!content.value\n marker = new ml.Marker({\n ...(custom ? { element: content.value } : { color: props.color ?? 'currentColor' }),\n draggable: props.draggable,\n // Left out for the pin unless given: MapLibre's own placement puts its tip on the point (see _mapPin.ts)\n ...(props.anchor ? { anchor: props.anchor } : custom ? { anchor: 'center' as const } : {}),\n ...(props.offset ? { offset: props.offset } : {}),\n rotation: props.rotation,\n })\n if (!custom && !props.color) marker.getElement().classList.add('m3-map-marker--default')\n marker.setLngLat(props.lngLat).addTo(map)\n marker.getElement().addEventListener('click', onClick)\n marker.on('dragend', () => {\n const { lng, lat } = marker!.getLngLat()\n emit('update:lngLat', [lng, lat])\n })\n if (slots.popup && popupContent.value) {\n // The pin's popup gets MapLibre's per-side offsets, which it only applies when `offset` isn't set at all\n marker.setPopup(new ml.Popup({ ...(custom ? { offset: 16 } : {}), maxWidth: '320px' }).setDOMContent(popupContent.value))\n }\n})\n\nfunction onClick(e: MouseEvent) {\n emit('click', e)\n}\n\n// Compared by value: an inline `:lng-lat=\"[lng, lat]\"` is a new array on every parent render\nwatch(() => props.lngLat.join(','), () => marker?.setLngLat(props.lngLat))\nwatch(() => props.draggable, (draggable) => marker?.setDraggable(draggable))\nwatch(() => props.rotation, (rotation) => marker?.setRotation(rotation))\nwatch(() => props.offset?.join(','), () => marker?.setOffset(props.offset ?? (custom ? [0, 0] : PIN_OFFSET)))\n\nonBeforeUnmount(() => {\n marker?.getElement().removeEventListener('click', onClick)\n marker?.getPopup()?.remove()\n marker?.remove()\n})\n\ndefineExpose({\n /** The MapLibre marker */\n marker: () => marker,\n})\n</script>\n\n<template>\n <!-- Rendered here, then moved into the map by MapLibre (the marker element and the popup's content) -->\n <div class=\"hidden\">\n <div v-if=\"$slots.default\" ref=\"content\" class=\"m3-map-marker\" v-bind=\"$attrs\">\n <slot />\n </div>\n <div v-if=\"$slots.popup\" ref=\"popupContent\">\n <slot name=\"popup\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A marker on an `MMap`, at `lngLat`: MapLibre's pin in the theme's primary (or `color`), or your own content from the\n * default slot. With `draggable`, `lngLat` is a v-model. Content in `#popup` opens in a popup when the marker is\n * clicked. Available from the `/map` entry point.\n *\n * @slot default The marker itself, instead of the pin (any element, anchored by `anchor`)\n * @slot popup Content of a popup that opens when the marker is clicked\n * @event update:lngLat Dragged to a new position (`draggable`): `[lng, lat]`\n * @event click The marker was clicked\n */\nimport { onBeforeUnmount, ref, useSlots, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { PIN_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` (v-model with `draggable`) */\n lngLat: [number, number]\n /** The pin's color (any CSS color). Defaults to the theme's primary; ignored with custom content */\n color?: string\n /** Let the user drag it */\n draggable?: boolean\n /**\n * Which part of the marker sits on `lngLat`. By default the pin's tip (MapLibre's placement: its center, offset\n * `[0, -14]`), and the center of custom content\n */\n anchor?: Maplibre.PositionAnchor\n /** Offset in pixels, `[x, y]`. The pin's default is MapLibre's `[0, -14]`, which puts its tip on `lngLat` */\n offset?: [number, number]\n /** Rotation in degrees */\n rotation?: number\n }>(),\n { draggable: false, rotation: 0 },\n)\n\nconst emit = defineEmits<{\n 'update:lngLat': [lngLat: [number, number]]\n click: [event: MouseEvent]\n}>()\n\nconst slots = useSlots()\nconst content = ref<HTMLElement>()\nconst popupContent = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet marker: Maplibre.Marker | undefined\nlet custom = false\n\nonReady((map, ml) => {\n custom = !!slots.default && !!content.value\n marker = new ml.Marker({\n ...(custom ? { element: content.value } : { color: props.color ?? 'currentColor' }),\n draggable: props.draggable,\n // Left out for the pin unless given: MapLibre's own placement puts its tip on the point (see _mapPin.ts)\n ...(props.anchor ? { anchor: props.anchor } : custom ? { anchor: 'center' as const } : {}),\n ...(props.offset ? { offset: props.offset } : {}),\n rotation: props.rotation,\n })\n if (!custom && !props.color) marker.getElement().classList.add('m3-map-marker--default')\n marker.setLngLat(props.lngLat).addTo(map)\n marker.getElement().addEventListener('click', onClick)\n marker.on('dragend', () => {\n const { lng, lat } = marker!.getLngLat()\n emit('update:lngLat', [lng, lat])\n })\n if (slots.popup && popupContent.value) {\n // The pin's popup gets MapLibre's per-side offsets, which it only applies when `offset` isn't set at all\n marker.setPopup(new ml.Popup({ ...(custom ? { offset: 16 } : {}), maxWidth: '320px' }).setDOMContent(popupContent.value))\n }\n})\n\nfunction onClick(e: MouseEvent) {\n emit('click', e)\n}\n\n// Compared by value: an inline `:lng-lat=\"[lng, lat]\"` is a new array on every parent render\nwatch(() => props.lngLat.join(','), () => marker?.setLngLat(props.lngLat))\nwatch(() => props.draggable, (draggable) => marker?.setDraggable(draggable))\nwatch(() => props.rotation, (rotation) => marker?.setRotation(rotation))\nwatch(() => props.offset?.join(','), () => marker?.setOffset(props.offset ?? (custom ? [0, 0] : PIN_OFFSET)))\n\nonBeforeUnmount(() => {\n marker?.getElement().removeEventListener('click', onClick)\n marker?.getPopup()?.remove()\n marker?.remove()\n})\n\ndefineExpose({\n /** The MapLibre marker */\n marker: () => marker,\n})\n</script>\n\n<template>\n <!-- Rendered here, then moved into the map by MapLibre (the marker element and the popup's content) -->\n <div class=\"hidden\">\n <div v-if=\"$slots.default\" ref=\"content\" class=\"m3-map-marker\" v-bind=\"$attrs\">\n <slot />\n </div>\n <div v-if=\"$slots.popup\" ref=\"popupContent\">\n <slot name=\"popup\" />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A popup on an `MMap` at `lngLat`, shown while `open` (v-model): e.g. what the user clicked on. Its content is the\n * default slot, styled as an M3 surface. For a popup that opens from a marker, use `MMapMarker`'s `#popup` slot.\n * Available from the `/map` entry point.\n *\n * @slot default The popup's content\n * @event update:open Closed by its close button or a click on the map (`closeOnClick`)\n */\nimport { onBeforeUnmount, ref, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` */\n lngLat: [number, number]\n /** Shown (v-model) */\n open?: boolean\n /** Show a close button */\n closeButton?: boolean\n /** Close it when the map is clicked */\n closeOnClick?: boolean\n /** Where the popup sits relative to `lngLat`. By default MapLibre picks the side with room */\n anchor?: Maplibre.PositionAnchor\n /**\n * Offset from `lngLat`: pixels, `[x, y]`, or one per side (`{ bottom: [0, -38], … }`, MapLibre's `Offset`).\n * By default none: its tip touches the point\n */\n offset?: Maplibre.Offset\n /** Maximum width (CSS) */\n maxWidth?: string\n }>(),\n { open: true, closeButton: true, closeOnClick: true, maxWidth: '320px' },\n)\n\nconst emit = defineEmits<{ 'update:open': [open: boolean] }>()\n\nconst content = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet popup: Maplibre.Popup | undefined\nlet map: Maplibre.Map | undefined\n// Closing it from `open` (rather than by the user) mustn't echo back as update:open\nlet closingFromProp = false\n\nfunction show() {\n if (!popup || !map || popup.isOpen()) return\n popup.setLngLat(props.lngLat).addTo(map)\n}\n\nonReady((m, ml) => {\n map = m\n popup = new ml.Popup({\n closeButton: props.closeButton,\n closeOnClick: props.closeOnClick,\n closeOnMove: false,\n anchor: props.anchor,\n ...(props.offset !== undefined ? { offset: props.offset } : {}),\n maxWidth: props.maxWidth,\n focusAfterOpen: false,\n })\n if (content.value) popup.setDOMContent(content.value)\n popup.on('close', () => {\n if (!closingFromProp) emit('update:open', false)\n })\n if (props.open) show()\n})\n\nwatch(() => props.open, (open) => {\n if (open) show()\n else if (popup?.isOpen()) {\n closingFromProp = true\n popup.remove()\n closingFromProp = false\n }\n})\nwatch(() => props.lngLat.join(','), () => popup?.setLngLat(props.lngLat))\nwatch(() => props.maxWidth, (w) => popup?.setMaxWidth(w))\nwatch(() => props.offset, (offset) => popup?.setOffset(offset ?? 0))\n\nonBeforeUnmount(() => {\n closingFromProp = true\n popup?.remove()\n})\n\ndefineExpose({\n /** The MapLibre popup */\n popup: () => popup,\n})\n</script>\n\n<template>\n <!-- Moved into the popup by MapLibre -->\n <div class=\"hidden\">\n <div ref=\"content\" v-bind=\"$attrs\">\n <slot />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A popup on an `MMap` at `lngLat`, shown while `open` (v-model): e.g. what the user clicked on. Its content is the\n * default slot, styled as an M3 surface. For a popup that opens from a marker, use `MMapMarker`'s `#popup` slot.\n * Available from the `/map` entry point.\n *\n * @slot default The popup's content\n * @event update:open Closed by its close button or a click on the map (`closeOnClick`)\n */\nimport { onBeforeUnmount, ref, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\n\n// Attributes (class, style…) go on what's shown on the map, not on the hidden wrapper it's rendered in\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Position, `[lng, lat]` */\n lngLat: [number, number]\n /** Shown (v-model) */\n open?: boolean\n /** Show a close button */\n closeButton?: boolean\n /** Close it when the map is clicked */\n closeOnClick?: boolean\n /** Where the popup sits relative to `lngLat`. By default MapLibre picks the side with room */\n anchor?: Maplibre.PositionAnchor\n /**\n * Offset from `lngLat`: pixels, `[x, y]`, or one per side (`{ bottom: [0, -38], … }`, MapLibre's `Offset`).\n * By default none: its tip touches the point\n */\n offset?: Maplibre.Offset\n /** Maximum width (CSS) */\n maxWidth?: string\n }>(),\n { open: true, closeButton: true, closeOnClick: true, maxWidth: '320px' },\n)\n\nconst emit = defineEmits<{ 'update:open': [open: boolean] }>()\n\nconst content = ref<HTMLElement>()\nconst { onReady } = useMap()\n\nlet popup: Maplibre.Popup | undefined\nlet map: Maplibre.Map | undefined\n// Closing it from `open` (rather than by the user) mustn't echo back as update:open\nlet closingFromProp = false\n\nfunction show() {\n if (!popup || !map || popup.isOpen()) return\n popup.setLngLat(props.lngLat).addTo(map)\n}\n\nonReady((m, ml) => {\n map = m\n popup = new ml.Popup({\n closeButton: props.closeButton,\n closeOnClick: props.closeOnClick,\n closeOnMove: false,\n anchor: props.anchor,\n ...(props.offset !== undefined ? { offset: props.offset } : {}),\n maxWidth: props.maxWidth,\n focusAfterOpen: false,\n })\n if (content.value) popup.setDOMContent(content.value)\n popup.on('close', () => {\n if (!closingFromProp) emit('update:open', false)\n })\n if (props.open) show()\n})\n\nwatch(() => props.open, (open) => {\n if (open) show()\n else if (popup?.isOpen()) {\n closingFromProp = true\n popup.remove()\n closingFromProp = false\n }\n})\nwatch(() => props.lngLat.join(','), () => popup?.setLngLat(props.lngLat))\nwatch(() => props.maxWidth, (w) => popup?.setMaxWidth(w))\nwatch(() => props.offset, (offset) => popup?.setOffset(offset ?? 0))\n\nonBeforeUnmount(() => {\n closingFromProp = true\n popup?.remove()\n})\n\ndefineExpose({\n /** The MapLibre popup */\n popup: () => popup,\n})\n</script>\n\n<template>\n <!-- Moved into the popup by MapLibre -->\n <div class=\"hidden\">\n <div ref=\"content\" v-bind=\"$attrs\">\n <slot />\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * GeoJSON on an `MMap`: a source from `data` (an object, or a URL MapLibre fetches) drawn with `layers`. Without\n * `layers` it draws every geometry in the theme's primary, following palette and dark mode: polygons filled with an\n * outline, lines, and points as circles. Replace `data` (a new object) to update it. It's added again after a style\n * change. Available from the `/map` entry point.\n *\n * @event click A click on one of its features (MapLibre's `MapLayerMouseEvent`: `e.features` holds them)\n */\nimport { computed, onBeforeUnmount, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\n\n// Omit over each member of the union (a plain Omit keeps only what all layer types share, losing paint and layout)\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** A layer of `MMapGeoJson`: any MapLibre layer without its `source` (and `id`, made up when left out). */\nexport type MapGeoJsonLayer = DistributiveOmit<Exclude<Maplibre.LayerSpecification, Maplibre.BackgroundLayerSpecification>, 'id' | 'source'> & { id?: string }\n\n// It renders nothing: no element for attributes to land on\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** A GeoJSON object, or the URL of one */\n data: Maplibre.GeoJSONSourceSpecification['data']\n /** The source's id (and the prefix of its layers' made-up ids). Unique on the map; generated when left out */\n id?: string\n /** How to draw it: MapLibre layers without `source`. Defaults to theme-colored fill, outline, line and circle layers */\n layers?: MapGeoJsonLayer[]\n /** Insert the layers below this layer id (e.g. under the style's labels) */\n before?: string\n /** Show a pointer over its features (set it when you handle `click`) */\n interactive?: boolean\n /** More options for the GeoJSON source (`cluster`, `promoteId`, `tolerance`…) */\n sourceOptions?: Partial<Omit<Maplibre.GeoJSONSourceSpecification, 'type' | 'data'>>\n }>(),\n { interactive: false },\n)\n\nconst emit = defineEmits<{ click: [event: Maplibre.MapLayerMouseEvent] }>()\n\nconst sourceId = props.id ?? `m3-geojson-${useId()}`\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst is = (...types: string[]): Maplibre.FilterSpecification => ['match', ['geometry-type'], types, true, false]\n\n/** The theme-colored default layers. */\nconst defaultLayers = computed<MapGeoJsonLayer[]>(() => {\n const { primary, surface } = theme.value\n return [\n { id: `${sourceId}-fill`, type: 'fill', filter: is('Polygon', 'MultiPolygon'), paint: { 'fill-color': primary, 'fill-opacity': 0.24 } },\n { id: `${sourceId}-line`, type: 'line', filter: is('Polygon', 'MultiPolygon', 'LineString', 'MultiLineString'), paint: { 'line-color': primary, 'line-width': 2 } },\n {\n id: `${sourceId}-circle`,\n type: 'circle',\n filter: is('Point', 'MultiPoint'),\n paint: { 'circle-color': primary, 'circle-radius': 6, 'circle-stroke-color': surface, 'circle-stroke-width': 2 },\n },\n ]\n})\n\nconst layers = computed(() =>\n (props.layers ?? defaultLayers.value).map((l, i) => ({ ...l, id: l.id ?? `${sourceId}-${i}`, source: sourceId }) as Maplibre.LayerSpecification),\n)\n\nlet map: Maplibre.Map | undefined\nlet added: string[] = []\n\nconst onClick = (e: Maplibre.MapLayerMouseEvent) => emit('click', e)\nconst onEnter = () => { if (props.interactive && map) map.getCanvas().style.cursor = 'pointer' }\nconst onLeave = () => { if (props.interactive && map) map.getCanvas().style.cursor = '' }\n\nfunction removeLayers() {\n if (!map) return\n for (const id of added) {\n map.off('click', id, onClick)\n map.off('mouseenter', id, onEnter)\n map.off('mouseleave', id, onLeave)\n if (map.getLayer(id)) map.removeLayer(id)\n }\n added = []\n}\n\nfunction addLayers() {\n if (!map) return\n removeLayers()\n for (const layer of layers.value) {\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n map.on('click', layer.id, onClick)\n map.on('mouseenter', layer.id, onEnter)\n map.on('mouseleave', layer.id, onLeave)\n added.push(layer.id)\n }\n}\n\n/** The source and its layers, unless they're there already (a style change drops them). */\nfunction add() {\n if (!map) return\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, { type: 'geojson', data: props.data, ...props.sourceOptions })\n added = []\n }\n if (!added.length || !map.getLayer(added[0]!)) addLayers()\n}\n\nonReady((m) => {\n map = m\n add()\n})\n\nwatch(styleVersion, () => add())\nwatch(() => props.data, (data) => (map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined)?.setData(data))\n// Layers by value: an inline `:layers=\"[...]\"` is a new array on every parent render\nwatch(() => JSON.stringify(layers.value), () => addLayers())\nwatch(() => props.before, () => addLayers())\n\nonBeforeUnmount(() => {\n if (!map) return\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n map = undefined\n})\n\ndefineExpose({\n /** The source's id */\n sourceId,\n /** The ids of its layers on the map */\n layerIds: () => [...added],\n})\n</script>\n\n<!-- Nothing of its own: it draws on the map -->\n<template></template>\n","<script setup lang=\"ts\">\n/**\n * GeoJSON on an `MMap`: a source from `data` (an object, or a URL MapLibre fetches) drawn with `layers`. Without\n * `layers` it draws every geometry in the theme's primary, following palette and dark mode: polygons filled with an\n * outline, lines, and points as circles. Replace `data` (a new object) to update it. It's added again after a style\n * change. Available from the `/map` entry point.\n *\n * @event click A click on one of its features (MapLibre's `MapLayerMouseEvent`: `e.features` holds them)\n */\nimport { computed, onBeforeUnmount, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\n\n// Omit over each member of the union (a plain Omit keeps only what all layer types share, losing paint and layout)\ntype DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never\n\n/** A layer of `MMapGeoJson`: any MapLibre layer without its `source` (and `id`, made up when left out). */\nexport type MapGeoJsonLayer = DistributiveOmit<Exclude<Maplibre.LayerSpecification, Maplibre.BackgroundLayerSpecification>, 'id' | 'source'> & { id?: string }\n\n// It renders nothing: no element for attributes to land on\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** A GeoJSON object, or the URL of one */\n data: Maplibre.GeoJSONSourceSpecification['data']\n /** The source's id (and the prefix of its layers' made-up ids). Unique on the map; generated when left out */\n id?: string\n /** How to draw it: MapLibre layers without `source`. Defaults to theme-colored fill, outline, line and circle layers */\n layers?: MapGeoJsonLayer[]\n /** Insert the layers below this layer id (e.g. under the style's labels) */\n before?: string\n /** Show a pointer over its features (set it when you handle `click`) */\n interactive?: boolean\n /** More options for the GeoJSON source (`cluster`, `promoteId`, `tolerance`…) */\n sourceOptions?: Partial<Omit<Maplibre.GeoJSONSourceSpecification, 'type' | 'data'>>\n }>(),\n { interactive: false },\n)\n\nconst emit = defineEmits<{ click: [event: Maplibre.MapLayerMouseEvent] }>()\n\nconst sourceId = props.id ?? `m3-geojson-${useId()}`\nconst { onReady, styleVersion } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst is = (...types: string[]): Maplibre.FilterSpecification => ['match', ['geometry-type'], types, true, false]\n\n/** The theme-colored default layers. */\nconst defaultLayers = computed<MapGeoJsonLayer[]>(() => {\n const { primary, surface } = theme.value\n return [\n { id: `${sourceId}-fill`, type: 'fill', filter: is('Polygon', 'MultiPolygon'), paint: { 'fill-color': primary, 'fill-opacity': 0.24 } },\n { id: `${sourceId}-line`, type: 'line', filter: is('Polygon', 'MultiPolygon', 'LineString', 'MultiLineString'), paint: { 'line-color': primary, 'line-width': 2 } },\n {\n id: `${sourceId}-circle`,\n type: 'circle',\n filter: is('Point', 'MultiPoint'),\n paint: { 'circle-color': primary, 'circle-radius': 6, 'circle-stroke-color': surface, 'circle-stroke-width': 2 },\n },\n ]\n})\n\nconst layers = computed(() =>\n (props.layers ?? defaultLayers.value).map((l, i) => ({ ...l, id: l.id ?? `${sourceId}-${i}`, source: sourceId }) as Maplibre.LayerSpecification),\n)\n\nlet map: Maplibre.Map | undefined\nlet added: string[] = []\n\nconst onClick = (e: Maplibre.MapLayerMouseEvent) => emit('click', e)\nconst onEnter = () => { if (props.interactive && map) map.getCanvas().style.cursor = 'pointer' }\nconst onLeave = () => { if (props.interactive && map) map.getCanvas().style.cursor = '' }\n\nfunction removeLayers() {\n if (!map) return\n for (const id of added) {\n map.off('click', id, onClick)\n map.off('mouseenter', id, onEnter)\n map.off('mouseleave', id, onLeave)\n if (map.getLayer(id)) map.removeLayer(id)\n }\n added = []\n}\n\nfunction addLayers() {\n if (!map) return\n removeLayers()\n for (const layer of layers.value) {\n map.addLayer(layer, props.before && map.getLayer(props.before) ? props.before : undefined)\n map.on('click', layer.id, onClick)\n map.on('mouseenter', layer.id, onEnter)\n map.on('mouseleave', layer.id, onLeave)\n added.push(layer.id)\n }\n}\n\n/** The source and its layers, unless they're there already (a style change drops them). */\nfunction add() {\n if (!map) return\n if (!map.getSource(sourceId)) {\n map.addSource(sourceId, { type: 'geojson', data: props.data, ...props.sourceOptions })\n added = []\n }\n if (!added.length || !map.getLayer(added[0]!)) addLayers()\n}\n\nonReady((m) => {\n map = m\n add()\n})\n\nwatch(styleVersion, () => add())\nwatch(() => props.data, (data) => (map?.getSource(sourceId) as Maplibre.GeoJSONSource | undefined)?.setData(data))\n// Layers by value: an inline `:layers=\"[...]\"` is a new array on every parent render\nwatch(() => JSON.stringify(layers.value), () => addLayers())\nwatch(() => props.before, () => addLayers())\n\nonBeforeUnmount(() => {\n if (!map) return\n removeLayers()\n if (map.getSource(sourceId)) map.removeSource(sourceId)\n map = undefined\n})\n\ndefineExpose({\n /** The source's id */\n sourceId,\n /** The ids of its layers on the map */\n layerIds: () => [...added],\n})\n</script>\n\n<!-- Nothing of its own: it draws on the map -->\n<template></template>\n","<script setup lang=\"ts\">\n// Internal: one layer of MMapLayers (visibility, title, and expanded: description, opacity, legend, download)\nimport MIcon from './MIcon.vue'\nimport MSlider from './MSlider.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\ndefineProps<{ layer: MapLayerInfo; expanded: boolean }>()\nconst emit = defineEmits<{ 'toggle-expanded': [] }>()\n\nconst t = useLocale()\nconst { isVisible, toggle, opacityOf, setOpacity } = useMapLayers()\n</script>\n\n<template>\n <div class=\"flex overflow-hidden rounded-2xl bg-surface-container\" :class=\"isVisible(layer.id) ? '' : 'opacity-75'\">\n <div class=\"w-1 shrink-0 transition-colors duration-200\" :class=\"isVisible(layer.id) ? 'bg-primary' : 'bg-outline-variant'\" />\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <div class=\"flex cursor-pointer items-center gap-2 px-3 py-2\" @click=\"emit('toggle-expanded')\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"isVisible(layer.id) ? 'bg-primary/12 text-primary' : 'bg-on-surface/5 text-on-surface-variant'\"\n :aria-label=\"isVisible(layer.id) ? t.mapHideLayer : t.mapShowLayer\"\n :aria-pressed=\"isVisible(layer.id)\"\n @click.stop=\"toggle(layer.id)\"\n >\n <MIcon :name=\"isVisible(layer.id) ? 'visibility' : 'visibility_off'\" :size=\"18\" />\n </button>\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <span class=\"truncate text-body-medium\" :class=\"isVisible(layer.id) ? 'text-on-surface' : 'text-on-surface-variant'\">{{ layer.title }}</span>\n <span v-if=\"layer.description && !expanded\" class=\"truncate text-label-small text-on-surface-variant\">{{ layer.description }}</span>\n </div>\n <span v-if=\"isVisible(layer.id) && opacityOf(layer.id) < 1\" class=\"rounded-full bg-primary/8 px-2 py-0.5 text-label-small tabular-nums text-primary\">\n {{ Math.round(opacityOf(layer.id) * 100) }}%\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"shrink-0 text-on-surface-variant transition-transform duration-300\" :class=\"expanded ? 'rotate-180' : ''\" />\n </div>\n <!-- Expands with grid rows 0fr → 1fr, so the height animates without measuring it -->\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: expanded ? '1fr' : '0fr' }\">\n <div class=\"min-h-0 overflow-hidden\">\n <div class=\"flex flex-col gap-3 px-3 pb-3\">\n <p v-if=\"layer.description\" class=\"text-body-small text-on-surface-variant\">{{ layer.description }}</p>\n <div class=\"flex items-center gap-2 rounded-2xl bg-surface-container-highest/60 px-3 py-1\">\n <MIcon name=\"opacity\" :size=\"16\" class=\"shrink-0 text-on-surface-variant\" />\n <MSlider\n :model-value=\"opacityOf(layer.id)\"\n :min=\"0\"\n :max=\"1\"\n :step=\"0.01\"\n :label=\"t.mapOpacity\"\n class=\"flex-1\"\n @update:model-value=\"setOpacity(layer.id, Number($event))\"\n />\n </div>\n <img v-if=\"layer.legend\" :src=\"layer.legend\" alt=\"\" class=\"max-w-full self-start\" loading=\"lazy\">\n <div v-if=\"layer.download || $slots.actions\" class=\"flex flex-wrap items-center gap-2\">\n <a\n v-if=\"layer.download\"\n :href=\"layer.download\"\n target=\"_blank\"\n rel=\"noopener\"\n download\n class=\"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-label-large text-primary hover:bg-primary/8\"\n >\n <MIcon name=\"download\" :size=\"18\" />\n {{ t.mapDownload }}\n </a>\n <slot name=\"actions\" :layer=\"layer\" :visible=\"isVisible(layer.id)\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n// Internal: one layer of MMapLayers (visibility, title, and expanded: description, opacity, legend, download)\nimport MIcon from './MIcon.vue'\nimport MSlider from './MSlider.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\ndefineProps<{ layer: MapLayerInfo; expanded: boolean }>()\nconst emit = defineEmits<{ 'toggle-expanded': [] }>()\n\nconst t = useLocale()\nconst { isVisible, toggle, opacityOf, setOpacity } = useMapLayers()\n</script>\n\n<template>\n <div class=\"flex overflow-hidden rounded-2xl bg-surface-container\" :class=\"isVisible(layer.id) ? '' : 'opacity-75'\">\n <div class=\"w-1 shrink-0 transition-colors duration-200\" :class=\"isVisible(layer.id) ? 'bg-primary' : 'bg-outline-variant'\" />\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <div class=\"flex cursor-pointer items-center gap-2 px-3 py-2\" @click=\"emit('toggle-expanded')\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"isVisible(layer.id) ? 'bg-primary/12 text-primary' : 'bg-on-surface/5 text-on-surface-variant'\"\n :aria-label=\"isVisible(layer.id) ? t.mapHideLayer : t.mapShowLayer\"\n :aria-pressed=\"isVisible(layer.id)\"\n @click.stop=\"toggle(layer.id)\"\n >\n <MIcon :name=\"isVisible(layer.id) ? 'visibility' : 'visibility_off'\" :size=\"18\" />\n </button>\n <div class=\"flex min-w-0 flex-1 flex-col\">\n <span class=\"truncate text-body-medium\" :class=\"isVisible(layer.id) ? 'text-on-surface' : 'text-on-surface-variant'\">{{ layer.title }}</span>\n <span v-if=\"layer.description && !expanded\" class=\"truncate text-label-small text-on-surface-variant\">{{ layer.description }}</span>\n </div>\n <span v-if=\"isVisible(layer.id) && opacityOf(layer.id) < 1\" class=\"rounded-full bg-primary/8 px-2 py-0.5 text-label-small tabular-nums text-primary\">\n {{ Math.round(opacityOf(layer.id) * 100) }}%\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"shrink-0 text-on-surface-variant transition-transform duration-300\" :class=\"expanded ? 'rotate-180' : ''\" />\n </div>\n <!-- Expands with grid rows 0fr → 1fr, so the height animates without measuring it -->\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: expanded ? '1fr' : '0fr' }\">\n <div class=\"min-h-0 overflow-hidden\">\n <div class=\"flex flex-col gap-3 px-3 pb-3\">\n <p v-if=\"layer.description\" class=\"text-body-small text-on-surface-variant\">{{ layer.description }}</p>\n <div class=\"flex items-center gap-2 rounded-2xl bg-surface-container-highest/60 px-3 py-1\">\n <MIcon name=\"opacity\" :size=\"16\" class=\"shrink-0 text-on-surface-variant\" />\n <MSlider\n :model-value=\"opacityOf(layer.id)\"\n :min=\"0\"\n :max=\"1\"\n :step=\"0.01\"\n :label=\"t.mapOpacity\"\n class=\"flex-1\"\n @update:model-value=\"setOpacity(layer.id, Number($event))\"\n />\n </div>\n <img v-if=\"layer.legend\" :src=\"layer.legend\" alt=\"\" class=\"max-w-full self-start\" loading=\"lazy\">\n <div v-if=\"layer.download || $slots.actions\" class=\"flex flex-wrap items-center gap-2\">\n <a\n v-if=\"layer.download\"\n :href=\"layer.download\"\n target=\"_blank\"\n rel=\"noopener\"\n download\n class=\"inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-label-large text-primary hover:bg-primary/8\"\n >\n <MIcon name=\"download\" :size=\"18\" />\n {{ t.mapDownload }}\n </a>\n <slot name=\"actions\" :layer=\"layer\" :visible=\"isVisible(layer.id)\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * The layer list of an `MMap` with an `adapter`: a search field, the style's groups (collapsible, with a visibility\n * toggle for the whole group and a count) and its layers, each with a visibility toggle and, expanded, its\n * description, an opacity slider, its legend and a download link. Only the content: put it in an `MWindow`, an\n * `MSideSheet`, an `MBottomSheet` or an `MMapControl`, inside the `MMap` or anywhere else with `map`. Available from the\n * `/map` entry point.\n *\n * @slot actions Extra actions in an expanded layer (scope: `{ layer, visible }`)\n */\nimport { computed, ref } from 'vue'\nimport MIcon from './MIcon.vue'\nimport MTextField from './MTextField.vue'\nimport MMapLayerItem from './_MMapLayerItem.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\nconst props = withDefaults(\n defineProps<{\n /** Show the search field */\n search?: boolean\n /** Groups start collapsed */\n collapsed?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { search: true, collapsed: false },\n)\n\nconst t = useLocale()\nconst { model, layersOf, isVisible, groupState, setGroupVisible } = useMapLayers(() => props.map)\n\nconst query = ref('')\nconst matches = (layer: MapLayerInfo) => !query.value || layer.title.toLowerCase().includes(query.value.toLowerCase())\n\nconst groups = computed(() =>\n (model.value?.groups ?? [])\n .map((g) => ({ ...g, all: layersOf(g.name), layers: layersOf(g.name).filter(matches) }))\n .filter((g) => g.layers.length),\n)\nconst ungrouped = computed(() => layersOf(null).filter(matches))\n\n// Collapsed groups and expanded layers (by default the other way around, with `collapsed`)\nconst toggledGroups = ref(new Set<string>())\nconst isOpen = (group: string) => toggledGroups.value.has(group) === props.collapsed\nfunction toggleGroup(group: string) {\n const next = new Set(toggledGroups.value)\n if (!next.delete(group)) next.add(group)\n toggledGroups.value = next\n}\nconst expanded = ref(new Set<string>())\nfunction toggleExpanded(id: string) {\n const next = new Set(expanded.value)\n if (!next.delete(id)) next.add(id)\n expanded.value = next\n}\n\nconst visibleCount = (layers: MapLayerInfo[]) => layers.filter((l) => isVisible(l.id)).length\n</script>\n\n<template>\n <div class=\"flex flex-col gap-3\">\n <MTextField v-if=\"search\" v-model=\"query\" :label=\"t.mapSearchLayers\" leading-icon=\"search\" variant=\"outlined\" clearable />\n\n <section v-for=\"group in groups\" :key=\"group.name\" class=\"flex flex-col\">\n <div class=\"m3-map-layers-row flex cursor-pointer items-center gap-2 rounded-xl px-2 py-1.5\" @click=\"toggleGroup(group.name)\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"groupState(group.name) === 'visible' ? 'bg-primary-container text-on-primary-container'\n : groupState(group.name) === 'partial' ? 'bg-secondary-container text-on-secondary-container'\n : 'bg-on-surface/8 text-on-surface-variant'\"\n :aria-label=\"groupState(group.name) === 'hidden' ? t.mapShowLayer : t.mapHideLayer\"\n :aria-pressed=\"groupState(group.name) !== 'hidden'\"\n @click.stop=\"setGroupVisible(group.name, groupState(group.name) !== 'visible')\"\n >\n <MIcon :name=\"groupState(group.name) === 'hidden' ? 'visibility_off' : 'visibility'\" :size=\"18\" />\n </button>\n <span class=\"flex-1 select-none truncate text-label-large text-on-surface\">{{ group.title }}</span>\n <span class=\"rounded-full bg-surface-container-highest px-2 py-0.5 text-label-small tabular-nums text-on-surface-variant\">\n {{ visibleCount(group.all) }}/{{ group.all.length }}\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"text-on-surface-variant transition-transform duration-300\" :class=\"isOpen(group.name) ? 'rotate-180' : ''\" />\n </div>\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: isOpen(group.name) ? '1fr' : '0fr' }\">\n <div class=\"flex min-h-0 flex-col gap-1.5 overflow-hidden\" :class=\"isOpen(group.name) ? 'pt-1.5' : ''\">\n <MMapLayerItem v-for=\"layer in group.layers\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n </div>\n </section>\n\n <div v-if=\"ungrouped.length\" class=\"flex flex-col gap-1.5\">\n <MMapLayerItem v-for=\"layer in ungrouped\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n\n <div v-if=\"!groups.length && !ungrouped.length\" class=\"flex flex-col items-center gap-3 py-8\">\n <div class=\"grid size-14 place-items-center rounded-full bg-surface-container-highest\">\n <MIcon name=\"layers_clear\" :size=\"28\" class=\"text-on-surface-variant\" />\n </div>\n <p class=\"text-body-medium text-on-surface-variant\">{{ t.mapNoLayers }}</p>\n </div>\n </div>\n</template>\n\n<style>\n.m3-map-layers-row:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 6%, transparent);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * The layer list of an `MMap` with an `adapter`: a search field, the style's groups (collapsible, with a visibility\n * toggle for the whole group and a count) and its layers, each with a visibility toggle and, expanded, its\n * description, an opacity slider, its legend and a download link. Only the content: put it in an `MWindow`, an\n * `MSideSheet`, an `MBottomSheet` or an `MMapControl`, inside the `MMap` or anywhere else with `map`. Available from the\n * `/map` entry point.\n *\n * @slot actions Extra actions in an expanded layer (scope: `{ layer, visible }`)\n */\nimport { computed, ref } from 'vue'\nimport MIcon from './MIcon.vue'\nimport MTextField from './MTextField.vue'\nimport MMapLayerItem from './_MMapLayerItem.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\nimport type { MapLayerInfo } from '../composables/mapAdapters'\n\nconst props = withDefaults(\n defineProps<{\n /** Show the search field */\n search?: boolean\n /** Groups start collapsed */\n collapsed?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { search: true, collapsed: false },\n)\n\nconst t = useLocale()\nconst { model, layersOf, isVisible, groupState, setGroupVisible } = useMapLayers(() => props.map)\n\nconst query = ref('')\nconst matches = (layer: MapLayerInfo) => !query.value || layer.title.toLowerCase().includes(query.value.toLowerCase())\n\nconst groups = computed(() =>\n (model.value?.groups ?? [])\n .map((g) => ({ ...g, all: layersOf(g.name), layers: layersOf(g.name).filter(matches) }))\n .filter((g) => g.layers.length),\n)\nconst ungrouped = computed(() => layersOf(null).filter(matches))\n\n// Collapsed groups and expanded layers (by default the other way around, with `collapsed`)\nconst toggledGroups = ref(new Set<string>())\nconst isOpen = (group: string) => toggledGroups.value.has(group) === props.collapsed\nfunction toggleGroup(group: string) {\n const next = new Set(toggledGroups.value)\n if (!next.delete(group)) next.add(group)\n toggledGroups.value = next\n}\nconst expanded = ref(new Set<string>())\nfunction toggleExpanded(id: string) {\n const next = new Set(expanded.value)\n if (!next.delete(id)) next.add(id)\n expanded.value = next\n}\n\nconst visibleCount = (layers: MapLayerInfo[]) => layers.filter((l) => isVisible(l.id)).length\n</script>\n\n<template>\n <div class=\"flex flex-col gap-3\">\n <MTextField v-if=\"search\" v-model=\"query\" :label=\"t.mapSearchLayers\" leading-icon=\"search\" variant=\"outlined\" clearable />\n\n <section v-for=\"group in groups\" :key=\"group.name\" class=\"flex flex-col\">\n <div class=\"m3-map-layers-row flex cursor-pointer items-center gap-2 rounded-xl px-2 py-1.5\" @click=\"toggleGroup(group.name)\">\n <button\n type=\"button\"\n class=\"grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200\"\n :class=\"groupState(group.name) === 'visible' ? 'bg-primary-container text-on-primary-container'\n : groupState(group.name) === 'partial' ? 'bg-secondary-container text-on-secondary-container'\n : 'bg-on-surface/8 text-on-surface-variant'\"\n :aria-label=\"groupState(group.name) === 'hidden' ? t.mapShowLayer : t.mapHideLayer\"\n :aria-pressed=\"groupState(group.name) !== 'hidden'\"\n @click.stop=\"setGroupVisible(group.name, groupState(group.name) !== 'visible')\"\n >\n <MIcon :name=\"groupState(group.name) === 'hidden' ? 'visibility_off' : 'visibility'\" :size=\"18\" />\n </button>\n <span class=\"flex-1 select-none truncate text-label-large text-on-surface\">{{ group.title }}</span>\n <span class=\"rounded-full bg-surface-container-highest px-2 py-0.5 text-label-small tabular-nums text-on-surface-variant\">\n {{ visibleCount(group.all) }}/{{ group.all.length }}\n </span>\n <MIcon name=\"expand_more\" :size=\"18\" class=\"text-on-surface-variant transition-transform duration-300\" :class=\"isOpen(group.name) ? 'rotate-180' : ''\" />\n </div>\n <div class=\"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]\" :style=\"{ gridTemplateRows: isOpen(group.name) ? '1fr' : '0fr' }\">\n <div class=\"flex min-h-0 flex-col gap-1.5 overflow-hidden\" :class=\"isOpen(group.name) ? 'pt-1.5' : ''\">\n <MMapLayerItem v-for=\"layer in group.layers\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n </div>\n </section>\n\n <div v-if=\"ungrouped.length\" class=\"flex flex-col gap-1.5\">\n <MMapLayerItem v-for=\"layer in ungrouped\" :key=\"layer.id\" :layer=\"layer\" :expanded=\"expanded.has(layer.id)\" @toggle-expanded=\"toggleExpanded(layer.id)\">\n <template v-if=\"$slots.actions\" #actions=\"scope\"><slot name=\"actions\" v-bind=\"scope\" /></template>\n </MMapLayerItem>\n </div>\n\n <div v-if=\"!groups.length && !ungrouped.length\" class=\"flex flex-col items-center gap-3 py-8\">\n <div class=\"grid size-14 place-items-center rounded-full bg-surface-container-highest\">\n <MIcon name=\"layers_clear\" :size=\"28\" class=\"text-on-surface-variant\" />\n </div>\n <p class=\"text-body-medium text-on-surface-variant\">{{ t.mapNoLayers }}</p>\n </div>\n </div>\n</template>\n\n<style>\n.m3-map-layers-row:hover {\n background-color: color-mix(in srgb, var(--color-on-surface) 6%, transparent);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * The base layer switcher of an `MMap` with an `adapter`: a round thumbnail per base layer (the adapter's `image`,\n * after `imageBase`), one shown at a time, plus \"no base layer\". Only the thumbnails: put them in an `MMapControl`\n * (`:group=\"false\"`), an `MFab`'s `#content` or a panel, inside the `MMap` or anywhere else with `map`. Available\n * from the `/map` entry point.\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\n\nconst props = withDefaults(\n defineProps<{\n /** Prefix for the thumbnails' paths (e.g. `/images/`); full URLs are used as they are */\n imageBase?: string\n /** Offer \"no base layer\" */\n none?: boolean\n /** Lay them out in a column */\n vertical?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { imageBase: '', none: true, vertical: false },\n)\n\nconst t = useLocale()\nconst { baseLayers, baseLayer, setBaseLayer } = useMapLayers(() => props.map)\n\nconst src = (image: string, base: string) => (/^(https?:|data:|\\/\\/)/.test(image) ? image : `${base}${image}`)\n</script>\n\n<template>\n <div class=\"flex gap-2\" :class=\"vertical ? 'flex-col' : 'flex-row flex-wrap'\" role=\"radiogroup\">\n <button\n v-for=\"layer in baseLayers\"\n :key=\"layer.id\"\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === layer.id ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :title=\"layer.title\"\n :aria-label=\"layer.title\"\n :aria-checked=\"baseLayer === layer.id\"\n @click=\"setBaseLayer(layer.id)\"\n >\n <img v-if=\"layer.base?.image\" :src=\"src(layer.base.image, imageBase)\" alt=\"\" class=\"size-full object-cover\">\n <MIcon v-else name=\"map\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n <button\n v-if=\"none\"\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === null ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :title=\"t.mapNoBaseLayer\"\n :aria-label=\"t.mapNoBaseLayer\"\n :aria-checked=\"baseLayer === null\"\n @click=\"setBaseLayer(null)\"\n >\n <MIcon name=\"layers_clear\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n </div>\n</template>\n\n<style>\n/* Inactive thumbnails in gray, the active one in color */\n.m3-map-base:not(.m3-map-base--active) img {\n filter: grayscale(1) opacity(0.6);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * The base layer switcher of an `MMap` with an `adapter`: a round thumbnail per base layer (the adapter's `image`,\n * after `imageBase`), one shown at a time, plus \"no base layer\". Only the thumbnails: put them in an `MMapControl`\n * (`:group=\"false\"`), an `MFab`'s `#content` or a panel, inside the `MMap` or anywhere else with `map`. Available\n * from the `/map` entry point.\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport type { MapSource } from '../composables/useMap'\n\nconst props = withDefaults(\n defineProps<{\n /** Prefix for the thumbnails' paths (e.g. `/images/`); full URLs are used as they are */\n imageBase?: string\n /** Offer \"no base layer\" */\n none?: boolean\n /** Lay them out in a column */\n vertical?: boolean\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n }>(),\n { imageBase: '', none: true, vertical: false },\n)\n\nconst t = useLocale()\nconst { baseLayers, baseLayer, setBaseLayer } = useMapLayers(() => props.map)\n\nconst src = (image: string, base: string) => (/^(https?:|data:|\\/\\/)/.test(image) ? image : `${base}${image}`)\n</script>\n\n<template>\n <div class=\"flex gap-2\" :class=\"vertical ? 'flex-col' : 'flex-row flex-wrap'\" role=\"radiogroup\">\n <button\n v-for=\"layer in baseLayers\"\n :key=\"layer.id\"\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === layer.id ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :title=\"layer.title\"\n :aria-label=\"layer.title\"\n :aria-checked=\"baseLayer === layer.id\"\n @click=\"setBaseLayer(layer.id)\"\n >\n <img v-if=\"layer.base?.image\" :src=\"src(layer.base.image, imageBase)\" alt=\"\" class=\"size-full object-cover\">\n <MIcon v-else name=\"map\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n <button\n v-if=\"none\"\n type=\"button\"\n role=\"radio\"\n class=\"m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110\"\n :class=\"baseLayer === null ? 'm3-map-base--active border-primary' : 'border-transparent'\"\n :title=\"t.mapNoBaseLayer\"\n :aria-label=\"t.mapNoBaseLayer\"\n :aria-checked=\"baseLayer === null\"\n @click=\"setBaseLayer(null)\"\n >\n <MIcon name=\"layers_clear\" :size=\"22\" class=\"text-on-surface-variant\" />\n </button>\n </div>\n</template>\n\n<style>\n/* Inactive thumbnails in gray, the active one in color */\n.m3-map-base:not(.m3-map-base--active) img {\n filter: grayscale(1) opacity(0.6);\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * Identify results (from `MMapIdentify`'s `identify` event, or `identifyFeatures()`): a card per feature with its\n * layer's name and its formatted properties. `MMapIdentify` shows it in a popup; use it in a panel of your own (an\n * `MWindow`, an `MSideSheet`) the same way. Values are shown as text. Available from the `/map` entry point.\n *\n * @slot value A property's value (scope: `{ field, result }`), e.g. to turn URLs into links\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapIdentifyResult } from '../composables/mapAdapters'\n\ndefineProps<{\n /** What was found */\n results: MapIdentifyResult[]\n}>()\n\nconst t = useLocale()\n</script>\n\n<template>\n <div class=\"flex flex-col gap-2\">\n <div v-for=\"(result, i) in results\" :key=\"i\" class=\"overflow-hidden rounded-2xl bg-surface-container\">\n <div class=\"flex items-center gap-2 bg-primary-container/40 px-4 py-2\">\n <MIcon name=\"layers\" :size=\"16\" class=\"text-on-primary-container\" />\n <span class=\"text-label-large text-on-primary-container\">{{ result.layer.title }}</span>\n </div>\n <dl class=\"flex flex-col px-4 py-1\">\n <div v-for=\"field in result.fields\" :key=\"field.key\" class=\"flex flex-col gap-0.5 border-b border-outline-variant py-1.5 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-medium text-on-surface\">\n <slot name=\"value\" :field=\"field\" :result=\"result\">\n <span v-if=\"field.value\" class=\"break-words\">{{ field.value }}</span>\n <span v-else class=\"text-body-small italic text-on-surface-variant\">{{ t.mapNoValue }}</span>\n </slot>\n </dd>\n </div>\n </dl>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Identify results (from `MMapIdentify`'s `identify` event, or `identifyFeatures()`): a card per feature with its\n * layer's name and its formatted properties. `MMapIdentify` shows it in a popup; use it in a panel of your own (an\n * `MWindow`, an `MSideSheet`) the same way. Values are shown as text. Available from the `/map` entry point.\n *\n * @slot value A property's value (scope: `{ field, result }`), e.g. to turn URLs into links\n */\nimport MIcon from './MIcon.vue'\nimport { useLocale } from '../composables/useLocale'\nimport type { MapIdentifyResult } from '../composables/mapAdapters'\n\ndefineProps<{\n /** What was found */\n results: MapIdentifyResult[]\n}>()\n\nconst t = useLocale()\n</script>\n\n<template>\n <div class=\"flex flex-col gap-2\">\n <div v-for=\"(result, i) in results\" :key=\"i\" class=\"overflow-hidden rounded-2xl bg-surface-container\">\n <div class=\"flex items-center gap-2 bg-primary-container/40 px-4 py-2\">\n <MIcon name=\"layers\" :size=\"16\" class=\"text-on-primary-container\" />\n <span class=\"text-label-large text-on-primary-container\">{{ result.layer.title }}</span>\n </div>\n <dl class=\"flex flex-col px-4 py-1\">\n <div v-for=\"field in result.fields\" :key=\"field.key\" class=\"flex flex-col gap-0.5 border-b border-outline-variant py-1.5 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-medium text-on-surface\">\n <slot name=\"value\" :field=\"field\" :result=\"result\">\n <span v-if=\"field.value\" class=\"break-words\">{{ field.value }}</span>\n <span v-else class=\"text-body-small italic text-on-surface-variant\">{{ t.mapNoValue }}</span>\n </slot>\n </dd>\n </div>\n </dl>\n </div>\n </div>\n</template>\n","import type * as Maplibre from 'maplibre-gl'\n\n/** How to show one property of a feature. */\nexport interface MapFieldFormat {\n /** The label (the key, capitalized, by default) */\n label?: string\n /** Text before the value */\n prefix?: string\n /** Text after the value */\n suffix?: string\n /** A number mask: its decimals set the fraction digits (`#.00` → 2) and a comma turns on grouping (`#,###`) */\n mask?: string\n /** Leave it out */\n hidden?: boolean\n}\n\n/** One layer of the style, as the map's UI components see it. */\nexport interface MapLayerInfo {\n /** The style layer's id */\n id: string\n /** Its name in the UI */\n title: string\n description?: string\n /** The `name` of its group in `MapLayerModel.groups` */\n group?: string\n /** Shown in `MMapLayers` */\n listed: boolean\n /** A base layer: `MMapBaseLayers` shows one of them at a time, with this thumbnail */\n base?: { image?: string }\n /** Layer ids shown, hidden and faded along with it */\n children: string[]\n /** Listed by `MMapIdentify` on click: every property, formatted by `format`, minus `exclude` */\n identify: false | { format: Record<string, MapFieldFormat>; exclude: string[] }\n /** Shown by `MMapHover` under the pointer: these properties, in order */\n hover: false | { fields: (MapFieldFormat & { key: string })[] }\n /** A legend image URL (an SVG, typically) */\n legend?: string\n /** A download URL for its data */\n download?: string\n}\n\n/** The style as the map's UI components see it: layers with names, groups, base layers, what to identify. */\nexport interface MapLayerModel {\n /** The style's name */\n title?: string\n /** Groups, in order */\n groups: { name: string; title: string }[]\n /** Layers, in the style's order (bottom to top) */\n layers: MapLayerInfo[]\n}\n\n/** What an adapter gets besides the style. */\nexport interface MapAdapterContext {\n /** The style's URL, when `MMap`'s `mapStyle` is one */\n styleUrl?: string\n}\n\n/** Reads a style's conventions (usually its `metadata`) into the model the map's UI components use. */\nexport type MapAdapter = (style: Maplibre.StyleSpecification, context: MapAdapterContext) => MapLayerModel\n\ntype Metadata = Record<string, unknown> | undefined\nconst meta = (layer: { metadata?: unknown }) => layer.metadata as Metadata\nconst VECTOR = new Set(['fill', 'line', 'circle', 'symbol', 'fill-extrusion', 'heatmap'])\n\n/**\n * Any style: every layer but the background is listed under its id (or `metadata.title`), vector layers identify all\n * their properties, and nothing is a base layer or shows on hover.\n */\nexport const genericAdapter: MapAdapter = (style) => ({\n title: style.name,\n groups: [],\n layers: style.layers\n .filter((l) => l.type !== 'background')\n .map((l) => ({\n id: l.id,\n title: (meta(l)?.title as string | undefined) ?? l.id,\n listed: true,\n children: [],\n identify: VECTOR.has(l.type) ? { format: {}, exclude: [] } : false,\n hover: false,\n })),\n})\n\nexport interface OrvianAdapterOptions {\n /**\n * A layer's legend image. By default, for a style served by mvt-rs (`…/services/styles/<style>`), its legend service\n * (`…/services/legends/<style>?layer_id=<id>`), unless the layer's `metadata.legend.show` is false;\n * `metadata.legend.wmslegend` overrides it\n */\n legend?: (layer: Maplibre.LayerSpecification, styleUrl?: string) => string | undefined\n}\n\n/**\n * The Orvian viewers' conventions in the style's `metadata`. On each layer: `alias`, `description`, `group`,\n * `show_in_layerlist` (false hides it from the list), `isbaselayer` with `image` (raster base layers), `childs` (layer\n * ids toggled with it), `identify` (true lists its properties on click), `fields` (per property: `alias`, `prefix`,\n * `suffix`, `mask`, `show: false`; plus `exclude`, a list of properties to leave out), `hover` (`enable` and `fields`,\n * a list of `{ <property>: { alias, prefix, suffix, mask } }`), `legend` (`show`, `wmslegend`) and `download`. On the\n * style: `groups` (`{ name, alias }`, in order).\n */\nexport function orvianAdapter(options: OrvianAdapterOptions = {}): MapAdapter {\n const legendOf = options.legend ?? ((layer, styleUrl) => {\n const legend = meta(layer)?.legend as { show?: boolean; wmslegend?: string } | undefined\n if (legend?.show === false) return undefined\n if (legend?.wmslegend) return legend.wmslegend\n if (!styleUrl?.includes('/services/styles/')) return undefined\n const url = styleUrl.replace('/services/styles/', '/services/legends/')\n return `${url}${url.includes('?') ? '&' : '?'}has_label=false&include_raster=true&layer_id=${encodeURIComponent(layer.id)}`\n })\n\n return (style, { styleUrl }) => {\n const groups = ((style.metadata as Metadata)?.groups as { name: string; alias?: string }[] | undefined) ?? []\n return {\n title: style.name,\n groups: groups.map((g) => ({ name: g.name, title: g.alias ?? g.name })),\n layers: style.layers\n .filter((l) => l.type !== 'background')\n .map((l) => {\n const m = meta(l) ?? {}\n const fields = { ...(m.fields as Record<string, unknown> | undefined) }\n const exclude = (fields.exclude as string[] | undefined) ?? []\n delete fields.exclude\n const format: Record<string, MapFieldFormat> = {}\n for (const [key, f] of Object.entries(fields as Record<string, { alias?: string; prefix?: string; suffix?: string; mask?: string; show?: boolean }>)) {\n format[key] = { label: f.alias, prefix: f.prefix, suffix: f.suffix, mask: f.mask, hidden: f.show === false }\n }\n const hover = m.hover as { enable?: boolean; fields?: Record<string, MapFieldFormat & { alias?: string }>[] } | undefined\n const base = l.type === 'raster' && m.isbaselayer === true\n return {\n id: l.id,\n title: (m.alias as string | undefined) ?? l.id,\n description: m.description as string | undefined,\n group: m.group as string | undefined,\n listed: !base && m.show_in_layerlist !== false,\n base: base && m.show_in_layerlist !== false ? { image: m.image as string | undefined } : undefined,\n children: Array.isArray(m.childs) ? (m.childs as string[]) : [],\n identify: m.identify === true ? { format, exclude } : false,\n hover: hover?.enable\n ? {\n fields: (hover.fields ?? []).flatMap((entry) =>\n Object.entries(entry).map(([key, f]) => ({ key, label: f.alias ?? f.label, prefix: f.prefix, suffix: f.suffix, mask: f.mask }))),\n }\n : false,\n legend: base ? undefined : legendOf(l, styleUrl),\n download: l.type !== 'raster' ? (m.download as string | undefined) : undefined,\n } satisfies MapLayerInfo\n }),\n }\n }\n}\n\n/** A property's label: its format's, or the key with a capital first letter. */\nexport function fieldLabel(key: string, format?: MapFieldFormat): string {\n return format?.label ?? key.charAt(0).toUpperCase() + key.slice(1)\n}\n\n/**\n * A property's value as text: numbers through `mask` (in the page's language, `<html lang>`), then `prefix` and\n * `suffix`. Empty values give ''.\n */\nexport function formatFieldValue(raw: unknown, format?: MapFieldFormat): string {\n if (raw === null || raw === undefined || String(raw).trim() === '') return ''\n let value = String(raw)\n const num = typeof raw === 'number' ? raw : Number(raw)\n if (format?.mask && !Number.isNaN(num)) {\n const decimals = format.mask.split('.')[1]?.length ?? 0\n const lang = typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined\n value = new Intl.NumberFormat(lang, {\n minimumFractionDigits: decimals,\n maximumFractionDigits: decimals,\n useGrouping: format.mask.includes(','),\n }).format(num)\n }\n if (format?.prefix) value = `${format.prefix} ${value}`\n if (format?.suffix) value = `${value} ${format.suffix}`\n return value\n}\n\n/** What `MMapIdentify` found on one layer at a point. */\nexport interface MapIdentifyResult {\n layer: MapLayerInfo\n feature: Maplibre.MapGeoJSONFeature\n /** Its properties as the layer's `identify` shows them, formatted */\n fields: { key: string; label: string; value: string }[]\n}\n\n// Keys MapLibre or a previous identify adds to a feature's properties\nconst INTERNAL_KEYS = new Set(['coordinates', 'mapCoordinates', 'layerId', '__layerMetadata'])\n\n/**\n * The features of the model's identify layers at a point (topmost first), with their properties formatted: what\n * `MMapIdentify` lists on click, for a UI of your own.\n */\nexport function identifyFeatures(map: Maplibre.Map, point: Maplibre.PointLike, model: MapLayerModel | undefined): MapIdentifyResult[] {\n const layers = new Map((model?.layers ?? []).filter((l) => l.identify && map.getLayer(l.id)).map((l) => [l.id, l]))\n if (!layers.size) return []\n const results: MapIdentifyResult[] = []\n for (const feature of map.queryRenderedFeatures(point, { layers: [...layers.keys()] })) {\n const layer = layers.get(feature.layer.id)\n if (!layer || !layer.identify) continue\n const { format, exclude } = layer.identify\n const fields = Object.entries(feature.properties ?? {})\n .filter(([key]) => !INTERNAL_KEYS.has(key) && !exclude.includes(key) && !format[key]?.hidden)\n .map(([key, raw]) => ({ key, label: fieldLabel(key, format[key]), value: formatFieldValue(raw, format[key]) }))\n if (fields.length) results.push({ layer, feature, fields })\n }\n return results\n}\n","<script setup lang=\"ts\">\n/**\n * Click-to-identify for an `MMap` with an `adapter`: a click on the map lists the features of the layers marked to\n * identify under it (with their formatted properties) in a popup, with a marker where the user clicked. The pointer\n * turns into a hand over those layers. The `identify` event carries the results, to show them in a panel of your own\n * instead (`:popup=\"false\"`, then `MMapFeatureInfo` in an `MWindow`). Available from the `/map` entry point.\n *\n * @slot default The popup's content instead of `MMapFeatureInfo` (scope: `{ results, lngLat, close }`)\n * @event identify The user clicked the map: what was found there (empty when nothing) and where (`[lng, lat]`)\n */\nimport { onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapPopup from './MMapPopup.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport MMapFeatureInfo from './MMapFeatureInfo.vue'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { identifyFeatures, type MapIdentifyResult } from '../composables/mapAdapters'\nimport { PIN_POPUP_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on the popup's content\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Listen to clicks. It also pauses by itself while another tool owns them (`MMapMeasure` measuring) */\n enabled?: boolean\n /** Show the results in a popup at the click */\n popup?: boolean\n /** Mark where the user clicked while there are results */\n marker?: boolean\n }>(),\n { enabled: true, popup: true, marker: true },\n)\n\nconst emit = defineEmits<{ identify: [results: MapIdentifyResult[], lngLat: [number, number]] }>()\n\nconst { on, onReady, activeTool } = useMap()\nconst { model } = useMapLayers()\n\nconst results = shallowRef<MapIdentifyResult[]>([])\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\non('click', (e) => {\n // Another tool (measuring…) owns the clicks\n if (!props.enabled || activeTool.value) return\n const map = e.target as Maplibre.Map\n results.value = identifyFeatures(map, e.point, model.value)\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = results.value.length > 0\n emit('identify', results.value, lngLat.value)\n})\n\nfunction close() {\n open.value = false\n}\nwatch(() => props.enabled, (enabled) => { if (!enabled) close() })\n\n// A hand over the layers that answer to a click\nlet map: Maplibre.Map | undefined\nlet hovered: string[] = []\nconst enter = () => { if (props.enabled && !activeTool.value && map) map.getCanvas().style.cursor = 'pointer' }\nconst leave = () => { if (map) map.getCanvas().style.cursor = '' }\nfunction bindCursor() {\n if (!map) return\n for (const id of hovered) {\n map.off('mouseenter', id, enter)\n map.off('mouseleave', id, leave)\n }\n hovered = (model.value?.layers ?? []).filter((l) => l.identify).map((l) => l.id)\n for (const id of hovered) {\n map.on('mouseenter', id, enter)\n map.on('mouseleave', id, leave)\n }\n}\nonReady((m) => {\n map = m\n bindCursor()\n})\nwatch(model, bindCursor)\nonBeforeUnmount(() => {\n hovered.forEach((id) => {\n map?.off('mouseenter', id, enter)\n map?.off('mouseleave', id, leave)\n })\n})\n\ndefineExpose({ close })\n</script>\n\n<template>\n <!-- One root (the marker and the popup move their content into the map) -->\n <div class=\"hidden\">\n <MMapMarker v-if=\"marker && open\" :lng-lat=\"lngLat\" />\n <MMapPopup v-if=\"popup && results.length\" v-model:open=\"open\" :lng-lat=\"lngLat\" max-width=\"360px\" :offset=\"marker ? PIN_POPUP_OFFSET : undefined\">\n <div class=\"max-h-80 overflow-y-auto\" v-bind=\"$attrs\">\n <slot :results=\"results\" :lng-lat=\"lngLat\" :close=\"close\">\n <MMapFeatureInfo :results=\"results\" />\n </slot>\n </div>\n </MMapPopup>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Click-to-identify for an `MMap` with an `adapter`: a click on the map lists the features of the layers marked to\n * identify under it (with their formatted properties) in a popup, with a marker where the user clicked. The pointer\n * turns into a hand over those layers. The `identify` event carries the results, to show them in a panel of your own\n * instead (`:popup=\"false\"`, then `MMapFeatureInfo` in an `MWindow`). Available from the `/map` entry point.\n *\n * @slot default The popup's content instead of `MMapFeatureInfo` (scope: `{ results, lngLat, close }`)\n * @event identify The user clicked the map: what was found there (empty when nothing) and where (`[lng, lat]`)\n */\nimport { onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MMapPopup from './MMapPopup.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport MMapFeatureInfo from './MMapFeatureInfo.vue'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { identifyFeatures, type MapIdentifyResult } from '../composables/mapAdapters'\nimport { PIN_POPUP_OFFSET } from '../composables/_mapPin'\n\n// Attributes (class, style…) go on the popup's content\ndefineOptions({ inheritAttrs: false })\n\nconst props = withDefaults(\n defineProps<{\n /** Listen to clicks. It also pauses by itself while another tool owns them (`MMapMeasure` measuring) */\n enabled?: boolean\n /** Show the results in a popup at the click */\n popup?: boolean\n /** Mark where the user clicked while there are results */\n marker?: boolean\n }>(),\n { enabled: true, popup: true, marker: true },\n)\n\nconst emit = defineEmits<{ identify: [results: MapIdentifyResult[], lngLat: [number, number]] }>()\n\nconst { on, onReady, activeTool } = useMap()\nconst { model } = useMapLayers()\n\nconst results = shallowRef<MapIdentifyResult[]>([])\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\non('click', (e) => {\n // Another tool (measuring…) owns the clicks\n if (!props.enabled || activeTool.value) return\n const map = e.target as Maplibre.Map\n results.value = identifyFeatures(map, e.point, model.value)\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = results.value.length > 0\n emit('identify', results.value, lngLat.value)\n})\n\nfunction close() {\n open.value = false\n}\nwatch(() => props.enabled, (enabled) => { if (!enabled) close() })\n\n// A hand over the layers that answer to a click\nlet map: Maplibre.Map | undefined\nlet hovered: string[] = []\nconst enter = () => { if (props.enabled && !activeTool.value && map) map.getCanvas().style.cursor = 'pointer' }\nconst leave = () => { if (map) map.getCanvas().style.cursor = '' }\nfunction bindCursor() {\n if (!map) return\n for (const id of hovered) {\n map.off('mouseenter', id, enter)\n map.off('mouseleave', id, leave)\n }\n hovered = (model.value?.layers ?? []).filter((l) => l.identify).map((l) => l.id)\n for (const id of hovered) {\n map.on('mouseenter', id, enter)\n map.on('mouseleave', id, leave)\n }\n}\nonReady((m) => {\n map = m\n bindCursor()\n})\nwatch(model, bindCursor)\nonBeforeUnmount(() => {\n hovered.forEach((id) => {\n map?.off('mouseenter', id, enter)\n map?.off('mouseleave', id, leave)\n })\n})\n\ndefineExpose({ close })\n</script>\n\n<template>\n <!-- One root (the marker and the popup move their content into the map) -->\n <div class=\"hidden\">\n <MMapMarker v-if=\"marker && open\" :lng-lat=\"lngLat\" />\n <MMapPopup v-if=\"popup && results.length\" v-model:open=\"open\" :lng-lat=\"lngLat\" max-width=\"360px\" :offset=\"marker ? PIN_POPUP_OFFSET : undefined\">\n <div class=\"max-h-80 overflow-y-auto\" v-bind=\"$attrs\">\n <slot :results=\"results\" :lng-lat=\"lngLat\" :close=\"close\">\n <MMapFeatureInfo :results=\"results\" />\n </slot>\n </div>\n </MMapPopup>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Hover info for an `MMap` with an `adapter`: while on (v-model), the layers with `hover` fields show them for the\n * feature under the pointer, in a small popup that follows it. With `control` (on by default) it adds its own on/off\n * button to the map's controls. Pointer devices only: touch has no hover. Available from the `/map` entry point.\n *\n * @event update:modelValue Turned on or off with its button\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapPopup from './MMapPopup.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { formatFieldValue, fieldLabel, type MapLayerInfo } from '../composables/mapAdapters'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** On (v-model) */\n modelValue?: boolean\n /** Its on/off button: `false`, or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: false, control: true },\n)\n\nconst emit = defineEmits<{ 'update:modelValue': [on: boolean] }>()\n\nconst t = useLocale()\nconst { onReady } = useMap()\nconst { model } = useMapLayers()\n\nconst hoverLayers = computed(() => (model.value?.layers ?? []).filter((l) => l.hover && l.hover.fields.length))\nconst shown = shallowRef<{ layer: MapLayerInfo; fields: { key: string; label: string; value: string }[] } | null>(null)\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\nlet map: Maplibre.Map | undefined\nlet bound: string[] = []\n\nfunction move(e: Maplibre.MapLayerMouseEvent) {\n const feature = e.features?.[0]\n const layer = hoverLayers.value.find((l) => l.id === feature?.layer.id)\n if (!feature || !layer || !layer.hover) return\n const props = feature.properties ?? {}\n shown.value = {\n layer,\n fields: layer.hover.fields\n .map((f) => ({ key: f.key, label: fieldLabel(f.key, f), value: formatFieldValue(props[f.key], f) }))\n .filter((f) => f.value),\n }\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = true\n}\nfunction leave() {\n open.value = false\n}\n\nfunction bind() {\n if (!map) return\n for (const id of bound) {\n map.off('mousemove', id, move)\n map.off('mouseleave', id, leave)\n }\n bound = props.modelValue ? hoverLayers.value.map((l) => l.id) : []\n for (const id of bound) {\n map.on('mousemove', id, move)\n map.on('mouseleave', id, leave)\n }\n if (!props.modelValue) open.value = false\n}\n\nonReady((m) => {\n map = m\n bind()\n})\nwatch([() => props.modelValue, hoverLayers], bind)\nonBeforeUnmount(() => {\n for (const id of bound) {\n map?.off('mousemove', id, move)\n map?.off('mouseleave', id, leave)\n }\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control && hoverLayers.length\" :position=\"corner\">\n <button\n type=\"button\"\n class=\"grid place-items-center\"\n :title=\"t.mapHoverInfo\"\n :aria-label=\"t.mapHoverInfo\"\n :aria-pressed=\"modelValue\"\n @click=\"emit('update:modelValue', !modelValue)\"\n >\n <MIcon name=\"ads_click\" :size=\"20\" />\n </button>\n </MMapControl>\n <MMapPopup\n v-if=\"shown\"\n v-model:open=\"open\"\n :lng-lat=\"lngLat\"\n :close-button=\"false\"\n :close-on-click=\"false\"\n :offset=\"12\"\n max-width=\"280px\"\n class=\"m3-map-hover\"\n >\n <p class=\"-mx-4 -mt-3 mb-1 bg-primary-container px-3 py-1.5 text-label-medium text-on-primary-container\">{{ shown.layer.title }}</p>\n <dl class=\"flex flex-col\">\n <div v-for=\"field in shown.fields\" :key=\"field.key\" class=\"border-b border-outline-variant py-1 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-small text-on-surface\">{{ field.value }}</dd>\n </div>\n </dl>\n </MMapPopup>\n </div>\n</template>\n\n<style>\n/* The hover popup ignores the pointer, so it never steals the mousemove that keeps it open */\n.maplibregl-popup:has(.m3-map-hover) {\n pointer-events: none;\n}\n</style>\n","<script setup lang=\"ts\">\n/**\n * Hover info for an `MMap` with an `adapter`: while on (v-model), the layers with `hover` fields show them for the\n * feature under the pointer, in a small popup that follows it. With `control` (on by default) it adds its own on/off\n * button to the map's controls. Pointer devices only: touch has no hover. Available from the `/map` entry point.\n *\n * @event update:modelValue Turned on or off with its button\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapPopup from './MMapPopup.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useMapLayers } from '../composables/useMapLayers'\nimport { formatFieldValue, fieldLabel, type MapLayerInfo } from '../composables/mapAdapters'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** On (v-model) */\n modelValue?: boolean\n /** Its on/off button: `false`, or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: false, control: true },\n)\n\nconst emit = defineEmits<{ 'update:modelValue': [on: boolean] }>()\n\nconst t = useLocale()\nconst { onReady } = useMap()\nconst { model } = useMapLayers()\n\nconst hoverLayers = computed(() => (model.value?.layers ?? []).filter((l) => l.hover && l.hover.fields.length))\nconst shown = shallowRef<{ layer: MapLayerInfo; fields: { key: string; label: string; value: string }[] } | null>(null)\nconst lngLat = ref<[number, number]>([0, 0])\nconst open = ref(false)\n\nlet map: Maplibre.Map | undefined\nlet bound: string[] = []\n\nfunction move(e: Maplibre.MapLayerMouseEvent) {\n const feature = e.features?.[0]\n const layer = hoverLayers.value.find((l) => l.id === feature?.layer.id)\n if (!feature || !layer || !layer.hover) return\n const props = feature.properties ?? {}\n shown.value = {\n layer,\n fields: layer.hover.fields\n .map((f) => ({ key: f.key, label: fieldLabel(f.key, f), value: formatFieldValue(props[f.key], f) }))\n .filter((f) => f.value),\n }\n lngLat.value = [e.lngLat.lng, e.lngLat.lat]\n open.value = true\n}\nfunction leave() {\n open.value = false\n}\n\nfunction bind() {\n if (!map) return\n for (const id of bound) {\n map.off('mousemove', id, move)\n map.off('mouseleave', id, leave)\n }\n bound = props.modelValue ? hoverLayers.value.map((l) => l.id) : []\n for (const id of bound) {\n map.on('mousemove', id, move)\n map.on('mouseleave', id, leave)\n }\n if (!props.modelValue) open.value = false\n}\n\nonReady((m) => {\n map = m\n bind()\n})\nwatch([() => props.modelValue, hoverLayers], bind)\nonBeforeUnmount(() => {\n for (const id of bound) {\n map?.off('mousemove', id, move)\n map?.off('mouseleave', id, leave)\n }\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control && hoverLayers.length\" :position=\"corner\">\n <button\n type=\"button\"\n class=\"grid place-items-center\"\n :title=\"t.mapHoverInfo\"\n :aria-label=\"t.mapHoverInfo\"\n :aria-pressed=\"modelValue\"\n @click=\"emit('update:modelValue', !modelValue)\"\n >\n <MIcon name=\"ads_click\" :size=\"20\" />\n </button>\n </MMapControl>\n <MMapPopup\n v-if=\"shown\"\n v-model:open=\"open\"\n :lng-lat=\"lngLat\"\n :close-button=\"false\"\n :close-on-click=\"false\"\n :offset=\"12\"\n max-width=\"280px\"\n class=\"m3-map-hover\"\n >\n <p class=\"-mx-4 -mt-3 mb-1 bg-primary-container px-3 py-1.5 text-label-medium text-on-primary-container\">{{ shown.layer.title }}</p>\n <dl class=\"flex flex-col\">\n <div v-for=\"field in shown.fields\" :key=\"field.key\" class=\"border-b border-outline-variant py-1 last:border-b-0\">\n <dt class=\"text-label-small text-on-surface-variant\">{{ field.label }}</dt>\n <dd class=\"text-body-small text-on-surface\">{{ field.value }}</dd>\n </div>\n </dl>\n </MMapPopup>\n </div>\n</template>\n\n<style>\n/* The hover popup ignores the pointer, so it never steals the mousemove that keeps it open */\n.maplibregl-popup:has(.m3-map-hover) {\n pointer-events: none;\n}\n</style>\n","// Internal: the geodesy MMapMeasure needs, on a sphere of the Earth's mean radius (as @turf/length and @turf/area do,\n// so the numbers match what the Orvian viewers measured with turf)\n\nexport type LngLat = [number, number]\n\nconst R = 6371008.8 // meters\nconst RAD = Math.PI / 180\n\n/** Great-circle distance between two points, in meters (haversine). */\nexport function distance(a: LngLat, b: LngLat): number {\n const dLat = (b[1] - a[1]) * RAD\n const dLng = (b[0] - a[0]) * RAD\n const h = Math.sin(dLat / 2) ** 2 + Math.cos(a[1] * RAD) * Math.cos(b[1] * RAD) * Math.sin(dLng / 2) ** 2\n return 2 * R * Math.asin(Math.min(1, Math.sqrt(h)))\n}\n\n/** The length of a path, in meters. */\nexport function pathLength(points: LngLat[]): number {\n let total = 0\n for (let i = 1; i < points.length; i++) total += distance(points[i - 1]!, points[i]!)\n return total\n}\n\n/** The point halfway along the great circle between two points. */\nexport function midpoint(a: LngLat, b: LngLat): LngLat {\n const [l1, p1, l2, p2] = [a[0] * RAD, a[1] * RAD, b[0] * RAD, b[1] * RAD]\n const bx = Math.cos(p2) * Math.cos(l2 - l1)\n const by = Math.cos(p2) * Math.sin(l2 - l1)\n const lat = Math.atan2(Math.sin(p1) + Math.sin(p2), Math.sqrt((Math.cos(p1) + bx) ** 2 + by ** 2))\n const lng = l1 + Math.atan2(by, Math.cos(p1) + bx)\n return [lng / RAD, lat / RAD]\n}\n\n/** The area of a ring (closed or not), in square meters, on the sphere (@turf/area's formula). */\nexport function ringArea(points: LngLat[]): number {\n const ring = closeRing(points)\n const n = ring.length - 1\n if (n <= 2) return 0\n let total = 0\n for (let i = 0; i < n; i++) {\n const lower = ring[i]!\n const middle = ring[i + 1 === n ? 0 : i + 1]!\n const upper = ring[i + 2 >= n ? (i + 2) % n : i + 2]!\n total += (upper[0] - lower[0]) * RAD * Math.sin(middle[1] * RAD)\n }\n return Math.abs((total * R * R) / 2)\n}\n\n/** The ring with its first point repeated at the end. */\nexport function closeRing(points: LngLat[]): LngLat[] {\n const first = points[0]\n const last = points[points.length - 1]\n return first && last && (first[0] !== last[0] || first[1] !== last[1]) ? [...points, first] : points\n}\n\n/** Where to label a polygon: its area centroid (in degrees, fine at a measuring scale), or the vertices' mean. */\nexport function centroid(points: LngLat[]): LngLat {\n const ring = closeRing(points)\n let a = 0\n let x = 0\n let y = 0\n for (let i = 0; i < ring.length - 1; i++) {\n const [x0, y0] = ring[i]!\n const [x1, y1] = ring[i + 1]!\n const f = x0 * y1 - x1 * y0\n a += f\n x += (x0 + x1) * f\n y += (y0 + y1) * f\n }\n if (Math.abs(a) < 1e-12) {\n const pts = ring.slice(0, -1)\n return [pts.reduce((s, p) => s + p[0], 0) / pts.length, pts.reduce((s, p) => s + p[1], 0) / pts.length]\n }\n return [x / (3 * a), y / (3 * a)]\n}\n","<script setup lang=\"ts\">\n/**\n * Distance and area measuring on an `MMap`, with its own control (distance, area, clear). Click to add points (a\n * preview follows the pointer), double-click, Enter or Escape to finish, click the first point to close the shape, or\n * press the active button again (in fullscreen, Escape finishes it too where the browser allows: Chromium). Finished\n * measurements stay editable: drag a vertex, or a midpoint to add one; the ✕ on a total or area deletes that one.\n * Labels show each segment, the total and the area; everything follows the theme. While measuring it owns the map's clicks\n * (`MMapIdentify` waits). Geodesic numbers, the same as turf's. Available from the `/map` entry point.\n *\n * @event update:modelValue The measuring mode changed (`'distance'`, `'area'`, or null when it finished)\n * @event change The measurements changed (added, edited, cleared): each one's points, length in meters and area in m²\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { centroid, closeRing, distance, midpoint, pathLength, ringArea, type LngLat } from '../composables/_mapGeometry'\nimport type { MapControlPosition } from './MMap.vue'\n\ntype Mode = 'distance' | 'area'\n\nconst props = withDefaults(\n defineProps<{\n /** The measuring mode (v-model): `'distance'`, `'area'`, or null. Set it to start measuring from outside */\n modelValue?: Mode | null\n /** Its buttons: `false` (drive it with v-model), or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: null, control: true },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [mode: Mode | null]\n change: [measurements: { mode: Mode; points: LngLat[]; closed: boolean; length: number; area?: number }[]]\n}>()\n\nconst t = useLocale()\nconst { onReady, styleVersion, activeTool } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst id = `m3-measure-${useId()}`\nconst SRC = { done: `${id}-done`, draft: `${id}-draft`, handles: `${id}-handles` }\nconst VERTEX = `${SRC.handles}-vertex`\nconst MIDPOINT = `${SRC.handles}-midpoint`\n\ninterface Measurement { mode: Mode; points: LngLat[]; closed: boolean }\n// Plain state, stepped on every pointer move: only the labels and the buttons are reactive\nconst measurements: Measurement[] = []\nlet draft: LngLat[] = []\nlet cursor: LngLat | null = null\nlet closingByFirst = false\nlet drag: { m: number; v: number } | null = null\nlet raf = 0\nlet map: Maplibre.Map | undefined\n\nconst mode = ref<Mode | null>(null)\nconst count = ref(0)\n// `m`: the finished measurement a total or area label belongs to (it carries that one's delete button)\nconst labels = shallowRef<{ key: string; at: LngLat; text: string; kind: 'segment' | 'total' | 'area'; m?: number }[]>([])\n\n// ── Text ───────────────────────────────────────────────────────────────────────────────────────\n\nconst lang = () => (typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined)\nconst num = (n: number, digits: number) => new Intl.NumberFormat(lang(), { minimumFractionDigits: digits, maximumFractionDigits: digits }).format(n)\nconst fmtDistance = (m: number) => (m === 0 ? '' : m < 1000 ? `${num(Math.round(m), 0)} m` : `${num(m / 1000, 2)} km`)\nconst fmtArea = (m2: number) => (m2 >= 1e6 ? `${num(m2 / 1e6, 2)} km²` : m2 >= 1e4 ? `${num(m2 / 1e4, 2)} ha` : `${num(Math.round(m2), 0)} m²`)\n\n// ── GeoJSON ────────────────────────────────────────────────────────────────────────────────────\n\n// Just the GeoJSON this draws (the global GeoJSON namespace isn't always typed)\ntype Geometry = { type: 'Point'; coordinates: LngLat } | { type: 'LineString'; coordinates: LngLat[] } | { type: 'Polygon'; coordinates: LngLat[][] }\ntype Feature = { type: 'Feature'; geometry: Geometry; properties: Record<string, unknown> }\ntype Label = (typeof labels.value)[number]\nconst point = (p: LngLat, properties: Record<string, unknown> = {}): Feature => ({ type: 'Feature', geometry: { type: 'Point', coordinates: p }, properties })\n\n/** A measurement's shapes, and its labels. */\nfunction build(points: LngLat[], m: Mode, key: string, index?: number): { features: Feature[]; labels: Label[] } {\n const features: Feature[] = points.map((p) => point(p))\n const out: Label[] = []\n if (points.length < 2) return { features, labels: out }\n features.push({ type: 'Feature', geometry: { type: 'LineString', coordinates: points }, properties: {} })\n const segments = (path: LngLat[]) => {\n for (let i = 0; i < path.length - 1; i++) {\n const text = fmtDistance(distance(path[i]!, path[i + 1]!))\n if (text) out.push({ key: `${key}-s${i}`, at: midpoint(path[i]!, path[i + 1]!), text, kind: 'segment' })\n }\n }\n if (m === 'distance') {\n segments(points)\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: `${t.mapTotal}: ${fmtDistance(pathLength(points))}`, kind: 'total', m: index })\n } else if (points.length >= 3) {\n const ring = closeRing(points)\n features.push({ type: 'Feature', geometry: { type: 'Polygon', coordinates: [ring] }, properties: {} })\n segments(ring)\n out.push({ key: `${key}-a`, at: centroid(ring), text: fmtArea(ringArea(ring)), kind: 'area', m: index })\n } else {\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: fmtDistance(pathLength(points)), kind: 'total', m: index })\n }\n return { features, labels: out }\n}\n\nconst collection = (features: Feature[]) => ({ type: 'FeatureCollection' as const, features })\nconst setData = (source: string, features: Feature[]) => (map?.getSource(source) as Maplibre.GeoJSONSource | undefined)?.setData(collection(features))\n\nfunction render() {\n if (!map) return\n const done = measurements.map((m, i) => build(m.points, m.mode, `m${i}`, i))\n const preview = mode.value && draft.length ? build(cursor ? [...draft, cursor] : draft, mode.value, 'draft') : { features: [], labels: [] }\n setData(SRC.done, done.flatMap((d) => d.features))\n setData(SRC.draft, preview.features)\n // Edit handles while not drawing: every vertex, and every segment's midpoint\n const handles: Feature[] = []\n if (!mode.value) {\n measurements.forEach((m, mi) => {\n const vertices = m.closed ? m.points.slice(0, -1) : m.points\n vertices.forEach((p, vi) => handles.push(point(p, { handle: 'vertex', m: mi, v: vi })))\n for (let i = 0; i < m.points.length - 1; i++) handles.push(point(midpoint(m.points[i]!, m.points[i + 1]!), { handle: 'midpoint', m: mi, after: i }))\n })\n }\n setData(SRC.handles, handles)\n labels.value = [...done.flatMap((d) => d.labels), ...preview.labels]\n}\n\nfunction report() {\n count.value = measurements.length\n emit('change', measurements.map((m) => ({\n mode: m.mode,\n points: m.points.map((p) => [...p] as LngLat),\n closed: m.closed,\n length: pathLength(m.points),\n ...(m.mode === 'area' || m.closed ? { area: ringArea(m.points) } : {}),\n })))\n}\n\n// ── Layers ─────────────────────────────────────────────────────────────────────────────────────\n\nconst is = (type: string): Maplibre.FilterSpecification => ['==', ['geometry-type'], type]\n\nfunction paints() {\n const { primary, surface } = theme.value\n return {\n fill: { 'fill-color': primary },\n line: { 'line-color': primary },\n vertices: { 'circle-color': surface, 'circle-stroke-color': primary },\n }\n}\n\nfunction ensureLayers() {\n if (!map) return\n for (const source of Object.values(SRC)) {\n if (!map.getSource(source)) map.addSource(source, { type: 'geojson', data: collection([]) })\n }\n const p = paints()\n const add = (layer: Maplibre.LayerSpecification) => { if (!map!.getLayer(layer.id)) map!.addLayer(layer) }\n for (const [source, draftStyle] of [[SRC.done, false], [SRC.draft, true]] as const) {\n add({ id: `${source}-fill`, type: 'fill', source, filter: is('Polygon'), paint: { ...p.fill, 'fill-opacity': draftStyle ? 0.15 : 0.2 } })\n add({ id: `${source}-line`, type: 'line', source, filter: ['!=', ['geometry-type'], 'Point'], paint: { ...p.line, 'line-width': 3, ...(draftStyle ? { 'line-dasharray': [2, 2] } : {}) } })\n add({ id: `${source}-points`, type: 'circle', source, filter: is('Point'), paint: { ...p.vertices, 'circle-radius': 5, 'circle-stroke-width': 2 } })\n }\n add({ id: MIDPOINT, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'midpoint'], paint: { ...p.vertices, 'circle-radius': 4, 'circle-stroke-width': 1.5, 'circle-opacity': 0.7 } })\n add({ id: VERTEX, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'vertex'], paint: { ...p.vertices, 'circle-radius': 7, 'circle-stroke-width': 2.5 } })\n}\n\nwatch(theme, () => {\n if (!map) return\n const p = paints()\n const set = (layer: string, paint: Record<string, unknown>) => {\n if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k, v)\n }\n for (const source of [SRC.done, SRC.draft]) {\n set(`${source}-fill`, p.fill)\n set(`${source}-line`, p.line)\n set(`${source}-points`, p.vertices)\n }\n set(MIDPOINT, p.vertices)\n set(VERTEX, p.vertices)\n})\n\n// ── Measuring ──────────────────────────────────────────────────────────────────────────────────\n\nconst lngLatOf = (e: { lngLat: { lng: number; lat: number } }): LngLat => [e.lngLat.lng, e.lngLat.lat]\n\nfunction onClick(e: Maplibre.MapMouseEvent) {\n if (draft.length >= 2) {\n const first = map!.project(draft[0]!)\n if (Math.hypot(first.x - e.point.x, first.y - e.point.y) < 20) {\n closingByFirst = true\n finish()\n return\n }\n }\n draft.push(lngLatOf(e))\n render()\n}\n\nfunction onMove(e: Maplibre.MapMouseEvent) {\n cursor = lngLatOf(e)\n if (raf) return\n raf = requestAnimationFrame(() => {\n raf = 0\n render()\n })\n}\n\nfunction onDblClick(e: Maplibre.MapMouseEvent) {\n e.preventDefault()\n if (draft.length < 2) return\n // The double click's first click added a point on top of the last one\n const a = map!.project(draft[draft.length - 1]!)\n const b = map!.project(draft[draft.length - 2]!)\n if (Math.hypot(a.x - b.x, a.y - b.y) < 10) draft.pop()\n finish()\n}\n\n// Enter finishes; Escape goes through the library's stack, so measuring on a map in a dialog doesn't close it too\nfunction onKey(e: KeyboardEvent) {\n if (e.key === 'Enter') finish()\n}\nuseEscapeStack(() => !!mode.value, () => finish(true))\n\n// In fullscreen the browser keeps Escape to leave it, and the page never sees it. Keyboard Lock (Chromium) lets the\n// page have it while measuring, so Escape finishes the measurement (holding Escape still leaves fullscreen)\ntype KeyboardLock = { lock?: (keys: string[]) => Promise<void>; unlock?: () => void }\nconst keyboard = () => (typeof navigator !== 'undefined' ? (navigator as Navigator & { keyboard?: KeyboardLock }).keyboard : undefined)\nlet locked = false\nfunction lockEscape() {\n if (!mode.value || !document.fullscreenElement || !keyboard()?.lock) return\n keyboard()!.lock!(['Escape']).then(() => { locked = true }, () => {})\n}\nfunction unlockEscape() {\n // Measuring again by then: that measurement holds the lock now\n if (mode.value) return\n if (locked) keyboard()?.unlock?.()\n locked = false\n}\n// Released once the Escape that finished the measurement is let go: unlocking during its keydown hands the rest of\n// that press back to the browser, which then leaves fullscreen anyway\nfunction unlockAfterEscape() {\n let fallback: ReturnType<typeof setTimeout> | undefined\n const done = () => {\n document.removeEventListener('keyup', onUp, true)\n clearTimeout(fallback)\n setTimeout(unlockEscape)\n }\n const onUp = (e: KeyboardEvent) => { if (e.key === 'Escape') done() }\n document.addEventListener('keyup', onUp, true)\n fallback = setTimeout(done, 1500)\n}\n\nfunction start(next: Mode) {\n if (!map) return\n if (mode.value === next) return finish()\n if (mode.value) finish()\n mode.value = next\n activeTool.value = 'measure'\n draft = []\n cursor = null\n map.getCanvas().style.cursor = 'crosshair'\n map.doubleClickZoom.disable()\n map.on('click', onClick)\n map.on('mousemove', onMove)\n map.on('dblclick', onDblClick)\n document.addEventListener('keydown', onKey)\n document.addEventListener('fullscreenchange', lockEscape)\n lockEscape()\n render()\n if (props.modelValue !== next) emit('update:modelValue', next)\n}\n\nfunction finish(byEscape = false) {\n if (!map || !mode.value) return\n cancelAnimationFrame(raf)\n raf = 0\n const closed = draft.length >= 3 && (closingByFirst || mode.value === 'area')\n if (draft.length >= 2) {\n measurements.push({ mode: mode.value, points: closed ? [...draft, [...draft[0]!] as LngLat] : draft, closed })\n }\n draft = []\n cursor = null\n closingByFirst = false\n mode.value = null\n if (activeTool.value === 'measure') activeTool.value = null\n map.getCanvas().style.cursor = ''\n map.doubleClickZoom.enable()\n map.off('click', onClick)\n map.off('mousemove', onMove)\n map.off('dblclick', onDblClick)\n document.removeEventListener('keydown', onKey)\n document.removeEventListener('fullscreenchange', lockEscape)\n if (byEscape && locked) unlockAfterEscape()\n else unlockEscape()\n render()\n report()\n if (props.modelValue !== null) emit('update:modelValue', null)\n}\n\n/** Deletes one finished measurement. */\nfunction remove(index: number) {\n if (!measurements[index]) return\n measurements.splice(index, 1)\n render()\n report()\n}\n\nfunction clear() {\n if (mode.value) finish()\n measurements.length = 0\n render()\n report()\n}\n\n// ── Editing ────────────────────────────────────────────────────────────────────────────────────\n\ntype HandleEvent = (Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) & { features?: Maplibre.MapGeoJSONFeature[] }\n\nfunction onHandleDown(e: HandleEvent) {\n const f = e.features?.[0]\n if (!f || mode.value || !map) return\n e.preventDefault()\n const mi = f.properties.m as number\n const m = measurements[mi]\n if (!m) return\n let vi = f.properties.v as number\n if (f.properties.handle === 'midpoint') {\n vi = (f.properties.after as number) + 1\n m.points.splice(vi, 0, lngLatOf(e))\n }\n drag = { m: mi, v: vi }\n activeTool.value = 'measure'\n map.getCanvas().style.cursor = 'grabbing'\n const touch = e.type === 'touchstart'\n if (touch) map.dragPan.disable()\n map.on(touch ? 'touchmove' : 'mousemove', onDragMove)\n map.once(touch ? 'touchend' : 'mouseup', onDragEnd)\n render()\n}\n\nfunction onDragMove(e: Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) {\n if (!drag) return\n const m = measurements[drag.m]\n if (!m) return\n const p = lngLatOf(e)\n m.points[drag.v] = p\n if (m.closed && drag.v === 0) m.points[m.points.length - 1] = p\n render()\n}\n\nfunction onDragEnd() {\n if (!map) return\n drag = null\n map.off('mousemove', onDragMove)\n map.off('touchmove', onDragMove)\n map.dragPan.enable()\n map.getCanvas().style.cursor = ''\n report()\n // The click that ends a press comes after mouseup: keep it from MMapIdentify\n setTimeout(() => { if (activeTool.value === 'measure' && !mode.value) activeTool.value = null })\n}\n\nconst onHandleEnter = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = 'grab' }\nconst onHandleLeave = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = '' }\n\nonReady((m) => {\n map = m\n ensureLayers()\n for (const layer of [VERTEX, MIDPOINT]) {\n m.on('mousedown', layer, onHandleDown)\n m.on('touchstart', layer, onHandleDown)\n m.on('mouseenter', layer, onHandleEnter)\n m.on('mouseleave', layer, onHandleLeave)\n }\n if (props.modelValue) start(props.modelValue)\n})\nwatch(styleVersion, () => {\n ensureLayers()\n render()\n})\nwatch(() => props.modelValue, (next) => {\n if (next && next !== mode.value) start(next)\n else if (!next && mode.value) finish()\n})\n\nonBeforeUnmount(() => {\n if (!map) return\n if (mode.value) finish()\n for (const layer of [VERTEX, MIDPOINT]) {\n map.off('mousedown', layer, onHandleDown)\n map.off('touchstart', layer, onHandleDown)\n map.off('mouseenter', layer, onHandleEnter)\n map.off('mouseleave', layer, onHandleLeave)\n }\n const layers = [VERTEX, MIDPOINT, ...[SRC.done, SRC.draft].flatMap((s) => [`${s}-points`, `${s}-line`, `${s}-fill`])]\n for (const layer of layers) if (map.getLayer(layer)) map.removeLayer(layer)\n for (const source of Object.values(SRC)) if (map.getSource(source)) map.removeSource(source)\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n\ndefineExpose({ start, finish, clear, remove })\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control\" :position=\"corner\">\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureDistance\" :aria-pressed=\"mode === 'distance'\" @click=\"start('distance')\">\n <MIcon name=\"straighten\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureArea\" :aria-pressed=\"mode === 'area'\" @click=\"start('area')\">\n <MIcon name=\"pentagon\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapClearMeasurements\" :disabled=\"!count && !mode\" @click=\"clear\">\n <MIcon name=\"delete\" :size=\"20\" />\n </button>\n </MMapControl>\n <!-- Labels: M3 chips that let the pointer through to the map -->\n <MMapMarker\n v-for=\"label in labels\"\n :key=\"label.key\"\n :lng-lat=\"label.at\"\n :anchor=\"label.kind === 'area' ? 'center' : 'top'\"\n :offset=\"label.kind === 'area' ? [0, 0] : [0, 8]\"\n class=\"pointer-events-none\"\n >\n <span\n class=\"flex items-center gap-1 whitespace-nowrap rounded-full py-0.5 shadow-elevation-1\"\n :class=\"[\n label.kind === 'segment' ? 'bg-surface-container-highest text-label-small text-on-surface' : 'bg-primary text-label-medium text-on-primary',\n label.m !== undefined ? 'pr-0.5 pl-2' : 'px-2',\n ]\"\n >\n {{ label.text }}\n <!-- Deletes this measurement; it catches its own pointer, so the map neither pans nor gets a click -->\n <button\n v-if=\"label.m !== undefined\"\n type=\"button\"\n class=\"pointer-events-auto grid size-5 cursor-pointer place-items-center rounded-full hover:bg-on-primary/12 focus-visible:outline-2 focus-visible:outline-on-primary\"\n :aria-label=\"t.mapDeleteMeasurement\"\n :title=\"t.mapDeleteMeasurement\"\n @click.stop=\"remove(label.m)\"\n @pointerdown.stop\n @mousedown.stop\n @touchstart.stop\n @dblclick.stop\n >\n <MIcon name=\"close\" :size=\"14\" />\n </button>\n </span>\n </MMapMarker>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * Distance and area measuring on an `MMap`, with its own control (distance, area, clear). Click to add points (a\n * preview follows the pointer), double-click, Enter or Escape to finish, click the first point to close the shape, or\n * press the active button again (in fullscreen, Escape finishes it too where the browser allows: Chromium). Finished\n * measurements stay editable: drag a vertex, or a midpoint to add one; the ✕ on a total or area deletes that one.\n * Labels show each segment, the total and the area; everything follows the theme. While measuring it owns the map's clicks\n * (`MMapIdentify` waits). Geodesic numbers, the same as turf's. Available from the `/map` entry point.\n *\n * @event update:modelValue The measuring mode changed (`'distance'`, `'area'`, or null when it finished)\n * @event change The measurements changed (added, edited, cleared): each one's points, length in meters and area in m²\n */\nimport { computed, onBeforeUnmount, ref, shallowRef, useId, watch } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MIcon from './MIcon.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { useThemeTokens } from '../composables/useThemeTokens'\nimport { useEscapeStack } from '../composables/_useEscapeStack'\nimport { centroid, closeRing, distance, midpoint, pathLength, ringArea, type LngLat } from '../composables/_mapGeometry'\nimport type { MapControlPosition } from './MMap.vue'\n\ntype Mode = 'distance' | 'area'\n\nconst props = withDefaults(\n defineProps<{\n /** The measuring mode (v-model): `'distance'`, `'area'`, or null. Set it to start measuring from outside */\n modelValue?: Mode | null\n /** Its buttons: `false` (drive it with v-model), or a corner (`true` is top-right) */\n control?: boolean | MapControlPosition\n }>(),\n { modelValue: null, control: true },\n)\n\nconst emit = defineEmits<{\n 'update:modelValue': [mode: Mode | null]\n change: [measurements: { mode: Mode; points: LngLat[]; closed: boolean; length: number; area?: number }[]]\n}>()\n\nconst t = useLocale()\nconst { onReady, styleVersion, activeTool } = useMap()\nconst theme = useThemeTokens(['primary', 'surface'] as const)\n\nconst id = `m3-measure-${useId()}`\nconst SRC = { done: `${id}-done`, draft: `${id}-draft`, handles: `${id}-handles` }\nconst VERTEX = `${SRC.handles}-vertex`\nconst MIDPOINT = `${SRC.handles}-midpoint`\n\ninterface Measurement { mode: Mode; points: LngLat[]; closed: boolean }\n// Plain state, stepped on every pointer move: only the labels and the buttons are reactive\nconst measurements: Measurement[] = []\nlet draft: LngLat[] = []\nlet cursor: LngLat | null = null\nlet closingByFirst = false\nlet drag: { m: number; v: number } | null = null\nlet raf = 0\nlet map: Maplibre.Map | undefined\n\nconst mode = ref<Mode | null>(null)\nconst count = ref(0)\n// `m`: the finished measurement a total or area label belongs to (it carries that one's delete button)\nconst labels = shallowRef<{ key: string; at: LngLat; text: string; kind: 'segment' | 'total' | 'area'; m?: number }[]>([])\n\n// ── Text ───────────────────────────────────────────────────────────────────────────────────────\n\nconst lang = () => (typeof document !== 'undefined' ? document.documentElement.lang || undefined : undefined)\nconst num = (n: number, digits: number) => new Intl.NumberFormat(lang(), { minimumFractionDigits: digits, maximumFractionDigits: digits }).format(n)\nconst fmtDistance = (m: number) => (m === 0 ? '' : m < 1000 ? `${num(Math.round(m), 0)} m` : `${num(m / 1000, 2)} km`)\nconst fmtArea = (m2: number) => (m2 >= 1e6 ? `${num(m2 / 1e6, 2)} km²` : m2 >= 1e4 ? `${num(m2 / 1e4, 2)} ha` : `${num(Math.round(m2), 0)} m²`)\n\n// ── GeoJSON ────────────────────────────────────────────────────────────────────────────────────\n\n// Just the GeoJSON this draws (the global GeoJSON namespace isn't always typed)\ntype Geometry = { type: 'Point'; coordinates: LngLat } | { type: 'LineString'; coordinates: LngLat[] } | { type: 'Polygon'; coordinates: LngLat[][] }\ntype Feature = { type: 'Feature'; geometry: Geometry; properties: Record<string, unknown> }\ntype Label = (typeof labels.value)[number]\nconst point = (p: LngLat, properties: Record<string, unknown> = {}): Feature => ({ type: 'Feature', geometry: { type: 'Point', coordinates: p }, properties })\n\n/** A measurement's shapes, and its labels. */\nfunction build(points: LngLat[], m: Mode, key: string, index?: number): { features: Feature[]; labels: Label[] } {\n const features: Feature[] = points.map((p) => point(p))\n const out: Label[] = []\n if (points.length < 2) return { features, labels: out }\n features.push({ type: 'Feature', geometry: { type: 'LineString', coordinates: points }, properties: {} })\n const segments = (path: LngLat[]) => {\n for (let i = 0; i < path.length - 1; i++) {\n const text = fmtDistance(distance(path[i]!, path[i + 1]!))\n if (text) out.push({ key: `${key}-s${i}`, at: midpoint(path[i]!, path[i + 1]!), text, kind: 'segment' })\n }\n }\n if (m === 'distance') {\n segments(points)\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: `${t.mapTotal}: ${fmtDistance(pathLength(points))}`, kind: 'total', m: index })\n } else if (points.length >= 3) {\n const ring = closeRing(points)\n features.push({ type: 'Feature', geometry: { type: 'Polygon', coordinates: [ring] }, properties: {} })\n segments(ring)\n out.push({ key: `${key}-a`, at: centroid(ring), text: fmtArea(ringArea(ring)), kind: 'area', m: index })\n } else {\n out.push({ key: `${key}-t`, at: points[points.length - 1]!, text: fmtDistance(pathLength(points)), kind: 'total', m: index })\n }\n return { features, labels: out }\n}\n\nconst collection = (features: Feature[]) => ({ type: 'FeatureCollection' as const, features })\nconst setData = (source: string, features: Feature[]) => (map?.getSource(source) as Maplibre.GeoJSONSource | undefined)?.setData(collection(features))\n\nfunction render() {\n if (!map) return\n const done = measurements.map((m, i) => build(m.points, m.mode, `m${i}`, i))\n const preview = mode.value && draft.length ? build(cursor ? [...draft, cursor] : draft, mode.value, 'draft') : { features: [], labels: [] }\n setData(SRC.done, done.flatMap((d) => d.features))\n setData(SRC.draft, preview.features)\n // Edit handles while not drawing: every vertex, and every segment's midpoint\n const handles: Feature[] = []\n if (!mode.value) {\n measurements.forEach((m, mi) => {\n const vertices = m.closed ? m.points.slice(0, -1) : m.points\n vertices.forEach((p, vi) => handles.push(point(p, { handle: 'vertex', m: mi, v: vi })))\n for (let i = 0; i < m.points.length - 1; i++) handles.push(point(midpoint(m.points[i]!, m.points[i + 1]!), { handle: 'midpoint', m: mi, after: i }))\n })\n }\n setData(SRC.handles, handles)\n labels.value = [...done.flatMap((d) => d.labels), ...preview.labels]\n}\n\nfunction report() {\n count.value = measurements.length\n emit('change', measurements.map((m) => ({\n mode: m.mode,\n points: m.points.map((p) => [...p] as LngLat),\n closed: m.closed,\n length: pathLength(m.points),\n ...(m.mode === 'area' || m.closed ? { area: ringArea(m.points) } : {}),\n })))\n}\n\n// ── Layers ─────────────────────────────────────────────────────────────────────────────────────\n\nconst is = (type: string): Maplibre.FilterSpecification => ['==', ['geometry-type'], type]\n\nfunction paints() {\n const { primary, surface } = theme.value\n return {\n fill: { 'fill-color': primary },\n line: { 'line-color': primary },\n vertices: { 'circle-color': surface, 'circle-stroke-color': primary },\n }\n}\n\nfunction ensureLayers() {\n if (!map) return\n for (const source of Object.values(SRC)) {\n if (!map.getSource(source)) map.addSource(source, { type: 'geojson', data: collection([]) })\n }\n const p = paints()\n const add = (layer: Maplibre.LayerSpecification) => { if (!map!.getLayer(layer.id)) map!.addLayer(layer) }\n for (const [source, draftStyle] of [[SRC.done, false], [SRC.draft, true]] as const) {\n add({ id: `${source}-fill`, type: 'fill', source, filter: is('Polygon'), paint: { ...p.fill, 'fill-opacity': draftStyle ? 0.15 : 0.2 } })\n add({ id: `${source}-line`, type: 'line', source, filter: ['!=', ['geometry-type'], 'Point'], paint: { ...p.line, 'line-width': 3, ...(draftStyle ? { 'line-dasharray': [2, 2] } : {}) } })\n add({ id: `${source}-points`, type: 'circle', source, filter: is('Point'), paint: { ...p.vertices, 'circle-radius': 5, 'circle-stroke-width': 2 } })\n }\n add({ id: MIDPOINT, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'midpoint'], paint: { ...p.vertices, 'circle-radius': 4, 'circle-stroke-width': 1.5, 'circle-opacity': 0.7 } })\n add({ id: VERTEX, type: 'circle', source: SRC.handles, filter: ['==', ['get', 'handle'], 'vertex'], paint: { ...p.vertices, 'circle-radius': 7, 'circle-stroke-width': 2.5 } })\n}\n\nwatch(theme, () => {\n if (!map) return\n const p = paints()\n const set = (layer: string, paint: Record<string, unknown>) => {\n if (map!.getLayer(layer)) for (const [k, v] of Object.entries(paint)) map!.setPaintProperty(layer, k, v)\n }\n for (const source of [SRC.done, SRC.draft]) {\n set(`${source}-fill`, p.fill)\n set(`${source}-line`, p.line)\n set(`${source}-points`, p.vertices)\n }\n set(MIDPOINT, p.vertices)\n set(VERTEX, p.vertices)\n})\n\n// ── Measuring ──────────────────────────────────────────────────────────────────────────────────\n\nconst lngLatOf = (e: { lngLat: { lng: number; lat: number } }): LngLat => [e.lngLat.lng, e.lngLat.lat]\n\nfunction onClick(e: Maplibre.MapMouseEvent) {\n if (draft.length >= 2) {\n const first = map!.project(draft[0]!)\n if (Math.hypot(first.x - e.point.x, first.y - e.point.y) < 20) {\n closingByFirst = true\n finish()\n return\n }\n }\n draft.push(lngLatOf(e))\n render()\n}\n\nfunction onMove(e: Maplibre.MapMouseEvent) {\n cursor = lngLatOf(e)\n if (raf) return\n raf = requestAnimationFrame(() => {\n raf = 0\n render()\n })\n}\n\nfunction onDblClick(e: Maplibre.MapMouseEvent) {\n e.preventDefault()\n if (draft.length < 2) return\n // The double click's first click added a point on top of the last one\n const a = map!.project(draft[draft.length - 1]!)\n const b = map!.project(draft[draft.length - 2]!)\n if (Math.hypot(a.x - b.x, a.y - b.y) < 10) draft.pop()\n finish()\n}\n\n// Enter finishes; Escape goes through the library's stack, so measuring on a map in a dialog doesn't close it too\nfunction onKey(e: KeyboardEvent) {\n if (e.key === 'Enter') finish()\n}\nuseEscapeStack(() => !!mode.value, () => finish(true))\n\n// In fullscreen the browser keeps Escape to leave it, and the page never sees it. Keyboard Lock (Chromium) lets the\n// page have it while measuring, so Escape finishes the measurement (holding Escape still leaves fullscreen)\ntype KeyboardLock = { lock?: (keys: string[]) => Promise<void>; unlock?: () => void }\nconst keyboard = () => (typeof navigator !== 'undefined' ? (navigator as Navigator & { keyboard?: KeyboardLock }).keyboard : undefined)\nlet locked = false\nfunction lockEscape() {\n if (!mode.value || !document.fullscreenElement || !keyboard()?.lock) return\n keyboard()!.lock!(['Escape']).then(() => { locked = true }, () => {})\n}\nfunction unlockEscape() {\n // Measuring again by then: that measurement holds the lock now\n if (mode.value) return\n if (locked) keyboard()?.unlock?.()\n locked = false\n}\n// Released once the Escape that finished the measurement is let go: unlocking during its keydown hands the rest of\n// that press back to the browser, which then leaves fullscreen anyway\nfunction unlockAfterEscape() {\n let fallback: ReturnType<typeof setTimeout> | undefined\n const done = () => {\n document.removeEventListener('keyup', onUp, true)\n clearTimeout(fallback)\n setTimeout(unlockEscape)\n }\n const onUp = (e: KeyboardEvent) => { if (e.key === 'Escape') done() }\n document.addEventListener('keyup', onUp, true)\n fallback = setTimeout(done, 1500)\n}\n\nfunction start(next: Mode) {\n if (!map) return\n if (mode.value === next) return finish()\n if (mode.value) finish()\n mode.value = next\n activeTool.value = 'measure'\n draft = []\n cursor = null\n map.getCanvas().style.cursor = 'crosshair'\n map.doubleClickZoom.disable()\n map.on('click', onClick)\n map.on('mousemove', onMove)\n map.on('dblclick', onDblClick)\n document.addEventListener('keydown', onKey)\n document.addEventListener('fullscreenchange', lockEscape)\n lockEscape()\n render()\n if (props.modelValue !== next) emit('update:modelValue', next)\n}\n\nfunction finish(byEscape = false) {\n if (!map || !mode.value) return\n cancelAnimationFrame(raf)\n raf = 0\n const closed = draft.length >= 3 && (closingByFirst || mode.value === 'area')\n if (draft.length >= 2) {\n measurements.push({ mode: mode.value, points: closed ? [...draft, [...draft[0]!] as LngLat] : draft, closed })\n }\n draft = []\n cursor = null\n closingByFirst = false\n mode.value = null\n if (activeTool.value === 'measure') activeTool.value = null\n map.getCanvas().style.cursor = ''\n map.doubleClickZoom.enable()\n map.off('click', onClick)\n map.off('mousemove', onMove)\n map.off('dblclick', onDblClick)\n document.removeEventListener('keydown', onKey)\n document.removeEventListener('fullscreenchange', lockEscape)\n if (byEscape && locked) unlockAfterEscape()\n else unlockEscape()\n render()\n report()\n if (props.modelValue !== null) emit('update:modelValue', null)\n}\n\n/** Deletes one finished measurement. */\nfunction remove(index: number) {\n if (!measurements[index]) return\n measurements.splice(index, 1)\n render()\n report()\n}\n\nfunction clear() {\n if (mode.value) finish()\n measurements.length = 0\n render()\n report()\n}\n\n// ── Editing ────────────────────────────────────────────────────────────────────────────────────\n\ntype HandleEvent = (Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) & { features?: Maplibre.MapGeoJSONFeature[] }\n\nfunction onHandleDown(e: HandleEvent) {\n const f = e.features?.[0]\n if (!f || mode.value || !map) return\n e.preventDefault()\n const mi = f.properties.m as number\n const m = measurements[mi]\n if (!m) return\n let vi = f.properties.v as number\n if (f.properties.handle === 'midpoint') {\n vi = (f.properties.after as number) + 1\n m.points.splice(vi, 0, lngLatOf(e))\n }\n drag = { m: mi, v: vi }\n activeTool.value = 'measure'\n map.getCanvas().style.cursor = 'grabbing'\n const touch = e.type === 'touchstart'\n if (touch) map.dragPan.disable()\n map.on(touch ? 'touchmove' : 'mousemove', onDragMove)\n map.once(touch ? 'touchend' : 'mouseup', onDragEnd)\n render()\n}\n\nfunction onDragMove(e: Maplibre.MapMouseEvent | Maplibre.MapTouchEvent) {\n if (!drag) return\n const m = measurements[drag.m]\n if (!m) return\n const p = lngLatOf(e)\n m.points[drag.v] = p\n if (m.closed && drag.v === 0) m.points[m.points.length - 1] = p\n render()\n}\n\nfunction onDragEnd() {\n if (!map) return\n drag = null\n map.off('mousemove', onDragMove)\n map.off('touchmove', onDragMove)\n map.dragPan.enable()\n map.getCanvas().style.cursor = ''\n report()\n // The click that ends a press comes after mouseup: keep it from MMapIdentify\n setTimeout(() => { if (activeTool.value === 'measure' && !mode.value) activeTool.value = null })\n}\n\nconst onHandleEnter = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = 'grab' }\nconst onHandleLeave = () => { if (map && !drag && !mode.value) map.getCanvas().style.cursor = '' }\n\nonReady((m) => {\n map = m\n ensureLayers()\n for (const layer of [VERTEX, MIDPOINT]) {\n m.on('mousedown', layer, onHandleDown)\n m.on('touchstart', layer, onHandleDown)\n m.on('mouseenter', layer, onHandleEnter)\n m.on('mouseleave', layer, onHandleLeave)\n }\n if (props.modelValue) start(props.modelValue)\n})\nwatch(styleVersion, () => {\n ensureLayers()\n render()\n})\nwatch(() => props.modelValue, (next) => {\n if (next && next !== mode.value) start(next)\n else if (!next && mode.value) finish()\n})\n\nonBeforeUnmount(() => {\n if (!map) return\n if (mode.value) finish()\n for (const layer of [VERTEX, MIDPOINT]) {\n map.off('mousedown', layer, onHandleDown)\n map.off('touchstart', layer, onHandleDown)\n map.off('mouseenter', layer, onHandleEnter)\n map.off('mouseleave', layer, onHandleLeave)\n }\n const layers = [VERTEX, MIDPOINT, ...[SRC.done, SRC.draft].flatMap((s) => [`${s}-points`, `${s}-line`, `${s}-fill`])]\n for (const layer of layers) if (map.getLayer(layer)) map.removeLayer(layer)\n for (const source of Object.values(SRC)) if (map.getSource(source)) map.removeSource(source)\n})\n\nconst corner = computed(() => (props.control === true ? 'top-right' : props.control || 'top-right'))\n\ndefineExpose({ start, finish, clear, remove })\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl v-if=\"control\" :position=\"corner\">\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureDistance\" :aria-pressed=\"mode === 'distance'\" @click=\"start('distance')\">\n <MIcon name=\"straighten\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapMeasureArea\" :aria-pressed=\"mode === 'area'\" @click=\"start('area')\">\n <MIcon name=\"pentagon\" :size=\"20\" />\n </button>\n <button type=\"button\" class=\"grid place-items-center\" :title=\"t.mapClearMeasurements\" :disabled=\"!count && !mode\" @click=\"clear\">\n <MIcon name=\"delete\" :size=\"20\" />\n </button>\n </MMapControl>\n <!-- Labels: M3 chips that let the pointer through to the map -->\n <MMapMarker\n v-for=\"label in labels\"\n :key=\"label.key\"\n :lng-lat=\"label.at\"\n :anchor=\"label.kind === 'area' ? 'center' : 'top'\"\n :offset=\"label.kind === 'area' ? [0, 0] : [0, 8]\"\n class=\"pointer-events-none\"\n >\n <span\n class=\"flex items-center gap-1 whitespace-nowrap rounded-full py-0.5 shadow-elevation-1\"\n :class=\"[\n label.kind === 'segment' ? 'bg-surface-container-highest text-label-small text-on-surface' : 'bg-primary text-label-medium text-on-primary',\n label.m !== undefined ? 'pr-0.5 pl-2' : 'px-2',\n ]\"\n >\n {{ label.text }}\n <!-- Deletes this measurement; it catches its own pointer, so the map neither pans nor gets a click -->\n <button\n v-if=\"label.m !== undefined\"\n type=\"button\"\n class=\"pointer-events-auto grid size-5 cursor-pointer place-items-center rounded-full hover:bg-on-primary/12 focus-visible:outline-2 focus-visible:outline-on-primary\"\n :aria-label=\"t.mapDeleteMeasurement\"\n :title=\"t.mapDeleteMeasurement\"\n @click.stop=\"remove(label.m)\"\n @pointerdown.stop\n @mousedown.stop\n @touchstart.stop\n @dblclick.stop\n >\n <MIcon name=\"close\" :size=\"14\" />\n </button>\n </span>\n </MMapMarker>\n </div>\n</template>\n","import type { MaybeRefOrGetter } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport { resolveMapContext, type MapSource } from './useMap'\n\n// The style's own filter of each layer we filter (undefined: none), per map\nconst originals = new WeakMap<Maplibre.Map, Map<string, Maplibre.FilterSpecification | undefined>>()\n\n/**\n * Filters for the layers of the enclosing `MMap`, on top of the filters their style already has (a layer that only\n * draws parks keeps doing so): `setFilter(layer, expression)` combines both, `setFilter(layer, null)` brings the\n * style's back. `MMapFilter` is built on it; use it for filters of your own (a range slider, a date, a search…).\n * Outside an `MMap`, pass it one (its template ref), as with `useMap`.\n */\nexport function useMapFilter(source?: MaybeRefOrGetter<MapSource>) {\n const ctx = resolveMapContext(source)\n if (!ctx) throw new Error('useMapFilter() must be called in a component inside <MMap>, or be given one')\n\n function setFilter(layerId: string, filter: Maplibre.FilterSpecification | null) {\n const map = ctx!.map.value\n if (!map?.getLayer(layerId)) return\n let saved = originals.get(map)\n if (!saved) originals.set(map, (saved = new Map()))\n if (!saved.has(layerId)) saved.set(layerId, map.getFilter(layerId) ?? undefined)\n const original = saved.get(layerId)\n map.setFilter(layerId, filter ? (original ? ['all', original, filter] : filter) as Maplibre.FilterSpecification : original ?? null)\n }\n\n /**\n * The distinct values of a property among a layer's features loaded in the map (for vector tiles, the tiles in\n * view), sorted.\n */\n function valuesOf(layerId: string, property: string): (string | number)[] {\n const map = ctx!.map.value\n const layer = map?.getLayer(layerId) as (Maplibre.StyleLayer & { source?: string; sourceLayer?: string }) | undefined\n if (!map || !layer?.source) return []\n const features = map.querySourceFeatures(layer.source, layer.sourceLayer ? { sourceLayer: layer.sourceLayer } : undefined)\n const values = new Set<string | number>()\n for (const f of features) {\n const v = f.properties?.[property]\n if (typeof v === 'string' || typeof v === 'number') values.add(v)\n }\n return [...values].sort((a, b) => (typeof a === 'number' && typeof b === 'number' ? a - b : String(a).localeCompare(String(b))))\n }\n\n return { setFilter, valuesOf }\n}\n","<script setup lang=\"ts\">\n/**\n * A simple filter for one layer of an `MMap`: chips for the values of one of its properties; the layer shows only the\n * features with the selected ones (all of them with none selected). The values are `values`, or else the distinct\n * ones among the layer's features loaded in the map. The style's own filter on the layer stays. For anything more\n * involved, build your own on `useMapFilter()`. Inside the `MMap`, or anywhere else with `map`. Available from the `/map`\n * entry point.\n */\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport MChip from './MChip.vue'\nimport { useMap, type MapSource } from '../composables/useMap'\nimport { useMapFilter } from '../composables/useMapFilter'\n\nconst props = defineProps<{\n /** The layer's id */\n layer: string\n /** The property to filter by */\n property: string\n /** The values to offer (labels in `labels`); by default the ones found in the layer's loaded features */\n values?: (string | number)[]\n /** Labels for the values, by value */\n labels?: Record<string, string>\n /** The selected values (v-model) */\n modelValue?: (string | number)[]\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n}>()\n\nconst emit = defineEmits<{ 'update:modelValue': [values: (string | number)[]] }>()\n\nconst { onReady, styleVersion } = useMap(() => props.map)\nconst { setFilter, valuesOf } = useMapFilter(() => props.map)\n\nconst found = ref<(string | number)[]>([])\nconst options = computed(() => props.values ?? found.value)\nconst local = ref<(string | number)[]>([])\nconst selected = computed(() => props.modelValue ?? local.value)\n\nfunction apply() {\n const values = selected.value\n setFilter(props.layer, values.length ? ['in', ['get', props.property], ['literal', values]] : null)\n}\n\nfunction toggle(value: string | number) {\n const next = selected.value.includes(value) ? selected.value.filter((v) => v !== value) : [...selected.value, value]\n local.value = next\n emit('update:modelValue', next)\n}\n\nfunction refreshValues(map: { once: (type: 'idle', fn: () => void) => unknown }) {\n const read = () => { if (!props.values) found.value = valuesOf(props.layer, props.property) }\n read()\n // And once the layer's data is in, if it wasn't yet (tiles load after the style)\n map.once('idle', read)\n}\n\nonReady((map) => {\n refreshValues(map)\n apply()\n})\nwatch(selected, apply, { deep: true })\nwatch(styleVersion, () => apply())\nwatch(() => [props.layer, props.property], ([layer], [old]) => {\n if (layer !== old) setFilter(old as string, null)\n apply()\n})\nonBeforeUnmount(() => setFilter(props.layer, null))\n</script>\n\n<template>\n <div class=\"flex flex-wrap gap-2\">\n <MChip\n v-for=\"value in options\"\n :key=\"value\"\n type=\"filter\"\n clickable\n :selected=\"selected.includes(value)\"\n @click=\"toggle(value)\"\n >\n {{ labels?.[String(value)] ?? value }}\n </MChip>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A simple filter for one layer of an `MMap`: chips for the values of one of its properties; the layer shows only the\n * features with the selected ones (all of them with none selected). The values are `values`, or else the distinct\n * ones among the layer's features loaded in the map. The style's own filter on the layer stays. For anything more\n * involved, build your own on `useMapFilter()`. Inside the `MMap`, or anywhere else with `map`. Available from the `/map`\n * entry point.\n */\nimport { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport MChip from './MChip.vue'\nimport { useMap, type MapSource } from '../composables/useMap'\nimport { useMapFilter } from '../composables/useMapFilter'\n\nconst props = defineProps<{\n /** The layer's id */\n layer: string\n /** The property to filter by */\n property: string\n /** The values to offer (labels in `labels`); by default the ones found in the layer's loaded features */\n values?: (string | number)[]\n /** Labels for the values, by value */\n labels?: Record<string, string>\n /** The selected values (v-model) */\n modelValue?: (string | number)[]\n /** The map, when this is outside it (a side panel): the `MMap`'s template ref */\n map?: MapSource\n}>()\n\nconst emit = defineEmits<{ 'update:modelValue': [values: (string | number)[]] }>()\n\nconst { onReady, styleVersion } = useMap(() => props.map)\nconst { setFilter, valuesOf } = useMapFilter(() => props.map)\n\nconst found = ref<(string | number)[]>([])\nconst options = computed(() => props.values ?? found.value)\nconst local = ref<(string | number)[]>([])\nconst selected = computed(() => props.modelValue ?? local.value)\n\nfunction apply() {\n const values = selected.value\n setFilter(props.layer, values.length ? ['in', ['get', props.property], ['literal', values]] : null)\n}\n\nfunction toggle(value: string | number) {\n const next = selected.value.includes(value) ? selected.value.filter((v) => v !== value) : [...selected.value, value]\n local.value = next\n emit('update:modelValue', next)\n}\n\nfunction refreshValues(map: { once: (type: 'idle', fn: () => void) => unknown }) {\n const read = () => { if (!props.values) found.value = valuesOf(props.layer, props.property) }\n read()\n // And once the layer's data is in, if it wasn't yet (tiles load after the style)\n map.once('idle', read)\n}\n\nonReady((map) => {\n refreshValues(map)\n apply()\n})\nwatch(selected, apply, { deep: true })\nwatch(styleVersion, () => apply())\nwatch(() => [props.layer, props.property], ([layer], [old]) => {\n if (layer !== old) setFilter(old as string, null)\n apply()\n})\nonBeforeUnmount(() => setFilter(props.layer, null))\n</script>\n\n<template>\n <div class=\"flex flex-wrap gap-2\">\n <MChip\n v-for=\"value in options\"\n :key=\"value\"\n type=\"filter\"\n clickable\n :selected=\"selected.includes(value)\"\n @click=\"toggle(value)\"\n >\n {{ labels?.[String(value)] ?? value }}\n </MChip>\n </div>\n</template>\n","/** A place found by a `MapSearchProvider`. */\nexport interface MapSearchResult {\n /** What to show */\n label: string\n /** Where it is */\n lngLat: [number, number]\n /** Its extent, `[west, south, east, north]`: the map fits it instead of zooming to the point */\n bbox?: [number, number, number, number]\n /** Its kind (`city`, `road`, `park`, `restaurant`…), for the icon */\n type?: string\n}\n\n/** Finds places for `MMapSearch`: the text in, results out. `signal` aborts a search the user replaced. */\nexport type MapSearchProvider = (query: string, signal: AbortSignal) => Promise<MapSearchResult[]>\n\nexport interface NominatimOptions {\n /** The Nominatim server (`https://nominatim.openstreetmap.org` by default; mind its usage policy, or run your own) */\n url?: string\n /** How many results (6) */\n limit?: number\n /** The results' language (`es`, `en`…); by default the page's (`<html lang>`) */\n language?: string\n /** Only these countries (ISO codes: `['ar']`) */\n countryCodes?: string[]\n /** Prefer (or with `bounded`, only) this area: `[west, south, east, north]` */\n viewbox?: [number, number, number, number]\n bounded?: boolean\n}\n\n/**\n * OpenStreetMap's Nominatim geocoder. Its public server allows one search per second and no search-as-you-type:\n * `MMapSearch` searches on Enter.\n */\nexport function nominatimProvider(options: NominatimOptions = {}): MapSearchProvider {\n return async (query, signal) => {\n const params = new URLSearchParams({ format: 'jsonv2', q: query, limit: String(options.limit ?? 6) })\n const language = options.language ?? (typeof document !== 'undefined' ? document.documentElement.lang : '')\n if (language) params.set('accept-language', language)\n if (options.countryCodes?.length) params.set('countrycodes', options.countryCodes.join(','))\n if (options.viewbox) params.set('viewbox', options.viewbox.join(','))\n if (options.bounded) params.set('bounded', '1')\n const res = await fetch(`${options.url ?? 'https://nominatim.openstreetmap.org'}/search?${params}`, { signal })\n if (!res.ok) throw new Error(`Nominatim: ${res.status}`)\n const data = await res.json() as { display_name: string; lat: string; lon: string; type?: string; boundingbox?: string[] }[]\n return data.map((r) => {\n // Nominatim's boundingbox is [south, north, west, east]\n const b = r.boundingbox?.map(Number)\n return {\n label: r.display_name,\n lngLat: [Number(r.lon), Number(r.lat)] as [number, number],\n bbox: b && b.length === 4 ? [b[2]!, b[0]!, b[3]!, b[1]!] as [number, number, number, number] : undefined,\n type: r.type,\n }\n })\n }\n}\n","<script setup lang=\"ts\">\n/**\n * A place search on an `MMap`: a search card in a corner. Enter searches through `provider` (OpenStreetMap's\n * Nominatim by default, or any function returning places); picking a result flies there (or fits its extent) and\n * marks it. Available from the `/map` entry point.\n *\n * @event select A result was picked\n */\nimport { computed, onBeforeUnmount, ref, shallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MCard from './MCard.vue'\nimport MIcon from './MIcon.vue'\nimport MIconButton from './MIconButton.vue'\nimport MList from './MList.vue'\nimport MListItem from './MListItem.vue'\nimport MSpinner from './MSpinner.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { nominatimProvider, type MapSearchProvider, type MapSearchResult } from '../composables/mapSearch'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** Where to search: `nominatimProvider(options)` by default, or your own function */\n provider?: MapSearchProvider\n /** The corner */\n position?: MapControlPosition\n /** The field's placeholder (the locale's \"Search places\" by default) */\n placeholder?: string\n /** The zoom to fly to for a result without an extent */\n zoom?: number\n /** Mark the picked result */\n marker?: boolean\n /** Search while typing (debounced), for providers that allow it; Nominatim's public server doesn't */\n instant?: boolean\n }>(),\n { position: 'top-left', zoom: 17, marker: true, instant: false },\n)\n\nconst emit = defineEmits<{ select: [result: MapSearchResult] }>()\n\nconst t = useLocale()\nconst { map } = useMap()\nconst provider = computed(() => props.provider ?? nominatimProvider())\n\nconst query = ref('')\nconst results = shallowRef<MapSearchResult[]>([])\nconst loading = ref(false)\nconst searched = ref(false)\nconst open = ref(false)\nconst picked = shallowRef<MapSearchResult | null>(null)\nlet controller: AbortController | undefined\nlet debounce: ReturnType<typeof setTimeout> | undefined\n\nasync function search() {\n const q = query.value.trim()\n if (!q) return\n controller?.abort()\n controller = new AbortController()\n const mine = controller\n loading.value = true\n open.value = true\n try {\n results.value = await provider.value(q, mine.signal)\n } catch {\n if (mine.signal.aborted) return\n results.value = []\n } finally {\n if (controller === mine) {\n loading.value = false\n searched.value = true\n }\n }\n}\n\nfunction onInput(value: string) {\n query.value = value\n if (!value) return clear()\n if (props.instant) {\n clearTimeout(debounce)\n debounce = setTimeout(search, 350)\n }\n}\n\nfunction select(result: MapSearchResult) {\n picked.value = result\n open.value = false\n const m = map.value as Maplibre.Map | undefined\n if (result.bbox && result.bbox[0] !== result.bbox[2]) m?.fitBounds([[result.bbox[0], result.bbox[1]], [result.bbox[2], result.bbox[3]]], { padding: 48, maxZoom: props.zoom })\n else m?.flyTo({ center: result.lngLat, zoom: props.zoom })\n emit('select', result)\n}\n\nfunction clear() {\n controller?.abort()\n clearTimeout(debounce)\n query.value = ''\n results.value = []\n searched.value = false\n loading.value = false\n open.value = false\n picked.value = null\n}\n\nonBeforeUnmount(() => {\n controller?.abort()\n clearTimeout(debounce)\n})\n\nconst ICONS: Record<string, string> = {\n city: 'location_city', town: 'location_city', village: 'holiday_village', hamlet: 'cottage', suburb: 'apartment',\n neighbourhood: 'maps_home_work', road: 'road', residential: 'home', house: 'home', building: 'domain',\n shop: 'storefront', park: 'park', water: 'water', river: 'water', lake: 'water', school: 'school',\n university: 'school', hospital: 'local_hospital', restaurant: 'restaurant', cafe: 'local_cafe', hotel: 'hotel',\n station: 'train', bus_stop: 'directions_bus', administrative: 'map', country: 'public', state: 'map',\n}\nconst iconOf = (type?: string) => (type && ICONS[type]) || 'location_on'\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl :position=\"position\" :group=\"false\">\n <MCard variant=\"elevated\" class=\"w-80 max-w-[calc(100vw-5rem)] overflow-hidden\">\n <form class=\"flex items-center gap-2 py-1 pr-1 pl-3\" role=\"search\" @submit.prevent=\"search\">\n <MIcon name=\"search\" :size=\"20\" class=\"shrink-0 text-on-surface-variant\" />\n <input\n :value=\"query\"\n type=\"search\"\n enterkeyhint=\"search\"\n :placeholder=\"placeholder ?? t.mapSearchPlaces\"\n :aria-label=\"placeholder ?? t.mapSearchPlaces\"\n class=\"min-w-0 flex-1 bg-transparent py-2 text-body-medium text-on-surface outline-none placeholder:text-on-surface-variant [&::-webkit-search-cancel-button]:hidden\"\n @input=\"onInput(($event.target as HTMLInputElement).value)\"\n @focus=\"open = searched && !picked\"\n >\n <MSpinner v-if=\"loading\" :size=\"20\" class=\"mr-2 shrink-0\" />\n <MIconButton v-else-if=\"query\" icon=\"close\" :label=\"t.clearSearch\" size=\"sm\" @click=\"clear\" />\n </form>\n <div v-if=\"open && searched && !loading\" class=\"border-t border-outline-variant\">\n <MList v-if=\"results.length\" class=\"max-h-72 overflow-y-auto\">\n <MListItem\n v-for=\"(r, i) in results\"\n :key=\"i\"\n :title=\"r.label\"\n :icon=\"iconOf(r.type)\"\n leading=\"icon\"\n clickable\n @click=\"select(r)\"\n />\n </MList>\n <div v-else class=\"flex flex-col items-center gap-2 py-6\">\n <MIcon name=\"search_off\" :size=\"28\" class=\"text-on-surface-variant\" />\n <span class=\"text-body-small text-on-surface-variant\">{{ t.noResults }}</span>\n </div>\n </div>\n </MCard>\n </MMapControl>\n <MMapMarker v-if=\"marker && picked\" :lng-lat=\"picked.lngLat\" />\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * A place search on an `MMap`: a search card in a corner. Enter searches through `provider` (OpenStreetMap's\n * Nominatim by default, or any function returning places); picking a result flies there (or fits its extent) and\n * marks it. Available from the `/map` entry point.\n *\n * @event select A result was picked\n */\nimport { computed, onBeforeUnmount, ref, shallowRef } from 'vue'\nimport type * as Maplibre from 'maplibre-gl'\nimport MCard from './MCard.vue'\nimport MIcon from './MIcon.vue'\nimport MIconButton from './MIconButton.vue'\nimport MList from './MList.vue'\nimport MListItem from './MListItem.vue'\nimport MSpinner from './MSpinner.vue'\nimport MMapControl from './MMapControl.vue'\nimport MMapMarker from './MMapMarker.vue'\nimport { useLocale } from '../composables/useLocale'\nimport { useMap } from '../composables/useMap'\nimport { nominatimProvider, type MapSearchProvider, type MapSearchResult } from '../composables/mapSearch'\nimport type { MapControlPosition } from './MMap.vue'\n\nconst props = withDefaults(\n defineProps<{\n /** Where to search: `nominatimProvider(options)` by default, or your own function */\n provider?: MapSearchProvider\n /** The corner */\n position?: MapControlPosition\n /** The field's placeholder (the locale's \"Search places\" by default) */\n placeholder?: string\n /** The zoom to fly to for a result without an extent */\n zoom?: number\n /** Mark the picked result */\n marker?: boolean\n /** Search while typing (debounced), for providers that allow it; Nominatim's public server doesn't */\n instant?: boolean\n }>(),\n { position: 'top-left', zoom: 17, marker: true, instant: false },\n)\n\nconst emit = defineEmits<{ select: [result: MapSearchResult] }>()\n\nconst t = useLocale()\nconst { map } = useMap()\nconst provider = computed(() => props.provider ?? nominatimProvider())\n\nconst query = ref('')\nconst results = shallowRef<MapSearchResult[]>([])\nconst loading = ref(false)\nconst searched = ref(false)\nconst open = ref(false)\nconst picked = shallowRef<MapSearchResult | null>(null)\nlet controller: AbortController | undefined\nlet debounce: ReturnType<typeof setTimeout> | undefined\n\nasync function search() {\n const q = query.value.trim()\n if (!q) return\n controller?.abort()\n controller = new AbortController()\n const mine = controller\n loading.value = true\n open.value = true\n try {\n results.value = await provider.value(q, mine.signal)\n } catch {\n if (mine.signal.aborted) return\n results.value = []\n } finally {\n if (controller === mine) {\n loading.value = false\n searched.value = true\n }\n }\n}\n\nfunction onInput(value: string) {\n query.value = value\n if (!value) return clear()\n if (props.instant) {\n clearTimeout(debounce)\n debounce = setTimeout(search, 350)\n }\n}\n\nfunction select(result: MapSearchResult) {\n picked.value = result\n open.value = false\n const m = map.value as Maplibre.Map | undefined\n if (result.bbox && result.bbox[0] !== result.bbox[2]) m?.fitBounds([[result.bbox[0], result.bbox[1]], [result.bbox[2], result.bbox[3]]], { padding: 48, maxZoom: props.zoom })\n else m?.flyTo({ center: result.lngLat, zoom: props.zoom })\n emit('select', result)\n}\n\nfunction clear() {\n controller?.abort()\n clearTimeout(debounce)\n query.value = ''\n results.value = []\n searched.value = false\n loading.value = false\n open.value = false\n picked.value = null\n}\n\nonBeforeUnmount(() => {\n controller?.abort()\n clearTimeout(debounce)\n})\n\nconst ICONS: Record<string, string> = {\n city: 'location_city', town: 'location_city', village: 'holiday_village', hamlet: 'cottage', suburb: 'apartment',\n neighbourhood: 'maps_home_work', road: 'road', residential: 'home', house: 'home', building: 'domain',\n shop: 'storefront', park: 'park', water: 'water', river: 'water', lake: 'water', school: 'school',\n university: 'school', hospital: 'local_hospital', restaurant: 'restaurant', cafe: 'local_cafe', hotel: 'hotel',\n station: 'train', bus_stop: 'directions_bus', administrative: 'map', country: 'public', state: 'map',\n}\nconst iconOf = (type?: string) => (type && ICONS[type]) || 'location_on'\n</script>\n\n<template>\n <div class=\"hidden\">\n <MMapControl :position=\"position\" :group=\"false\">\n <MCard variant=\"elevated\" class=\"w-80 max-w-[calc(100vw-5rem)] overflow-hidden\">\n <form class=\"flex items-center gap-2 py-1 pr-1 pl-3\" role=\"search\" @submit.prevent=\"search\">\n <MIcon name=\"search\" :size=\"20\" class=\"shrink-0 text-on-surface-variant\" />\n <input\n :value=\"query\"\n type=\"search\"\n enterkeyhint=\"search\"\n :placeholder=\"placeholder ?? t.mapSearchPlaces\"\n :aria-label=\"placeholder ?? t.mapSearchPlaces\"\n class=\"min-w-0 flex-1 bg-transparent py-2 text-body-medium text-on-surface outline-none placeholder:text-on-surface-variant [&::-webkit-search-cancel-button]:hidden\"\n @input=\"onInput(($event.target as HTMLInputElement).value)\"\n @focus=\"open = searched && !picked\"\n >\n <MSpinner v-if=\"loading\" :size=\"20\" class=\"mr-2 shrink-0\" />\n <MIconButton v-else-if=\"query\" icon=\"close\" :label=\"t.clearSearch\" size=\"sm\" @click=\"clear\" />\n </form>\n <div v-if=\"open && searched && !loading\" class=\"border-t border-outline-variant\">\n <MList v-if=\"results.length\" class=\"max-h-72 overflow-y-auto\">\n <MListItem\n v-for=\"(r, i) in results\"\n :key=\"i\"\n :title=\"r.label\"\n :icon=\"iconOf(r.type)\"\n leading=\"icon\"\n clickable\n @click=\"select(r)\"\n />\n </MList>\n <div v-else class=\"flex flex-col items-center gap-2 py-6\">\n <MIcon name=\"search_off\" :size=\"28\" class=\"text-on-surface-variant\" />\n <span class=\"text-body-small text-on-surface-variant\">{{ t.noResults }}</span>\n </div>\n </div>\n </MCard>\n </MMapControl>\n <MMapMarker v-if=\"marker && picked\" :lng-lat=\"picked.lngLat\" />\n </div>\n</template>\n"],"mappings":";;;;;;;;AA4BA,IAAa,KAAoC,OAAO,QAAQ;AAYhE,SAAgB,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