@m3ui-vue/m3ui-vue 1.0.2 → 1.0.3

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 (106) hide show
  1. package/dist/API.md +599 -9
  2. package/dist/MMenuItem-DFyXflk9.js +707 -0
  3. package/dist/MMenuItem-DFyXflk9.js.map +1 -0
  4. package/dist/MSlider-CdNIH7jc.js +1376 -0
  5. package/dist/MSlider-CdNIH7jc.js.map +1 -0
  6. package/dist/MTextField-B4X92vH_.js +671 -0
  7. package/dist/MTextField-B4X92vH_.js.map +1 -0
  8. package/dist/api.json +1 -1
  9. package/dist/code-editor.js +1 -1
  10. package/dist/components/MIconButton.vue.d.ts +1 -1
  11. package/dist/components/MMap.vue.d.ts +74 -0
  12. package/dist/components/MMapBaseLayers.vue.d.ts +15 -0
  13. package/dist/components/MMapControl.vue.d.ts +23 -0
  14. package/dist/components/MMapFeatureInfo.vue.d.ts +25 -0
  15. package/dist/components/MMapFilter.vue.d.ts +19 -0
  16. package/dist/components/MMapGeoJson.vue.d.ts +34 -0
  17. package/dist/components/MMapHover.vue.d.ts +17 -0
  18. package/dist/components/MMapIdentify.vue.d.ts +37 -0
  19. package/dist/components/MMapLayers.vue.d.ts +31 -0
  20. package/dist/components/MMapMarker.vue.d.ts +42 -0
  21. package/dist/components/MMapMeasure.vue.d.ts +43 -0
  22. package/dist/components/MMapPopup.vue.d.ts +43 -0
  23. package/dist/components/MMapSearch.vue.d.ts +28 -0
  24. package/dist/components/_MMapLayerItem.vue.d.ts +25 -0
  25. package/dist/composables/_mapGeometry.d.ts +13 -0
  26. package/dist/composables/_ssrState.d.ts +30 -0
  27. package/dist/composables/_storageKeys.d.ts +3 -0
  28. package/dist/composables/_useThemeTokens.d.ts +7 -0
  29. package/dist/composables/mapAdapters.d.ts +111 -0
  30. package/dist/composables/mapSearch.d.ts +31 -0
  31. package/dist/composables/themeInitScript.d.ts +4 -3
  32. package/dist/composables/useColorPalette.d.ts +173 -7
  33. package/dist/composables/useLocale.d.ts +30 -0
  34. package/dist/composables/useMap.d.ts +47 -0
  35. package/dist/composables/useMapFilter.d.ts +10 -0
  36. package/dist/composables/useMapLayers.d.ts +30 -0
  37. package/dist/composables/useTheme.d.ts +2 -1
  38. package/dist/index.d.ts +2 -1
  39. package/dist/locales/index.js +217 -7
  40. package/dist/locales/index.js.map +1 -1
  41. package/dist/m3ui-vue.css +1 -1
  42. package/dist/m3ui.js +6709 -7976
  43. package/dist/m3ui.js.map +1 -1
  44. package/dist/map.d.ts +24 -0
  45. package/dist/map.js +1931 -0
  46. package/dist/map.js.map +1 -0
  47. package/dist/plugin.d.ts +18 -2
  48. package/dist/rich-text-editor.js +27 -26
  49. package/dist/rich-text-editor.js.map +1 -1
  50. package/dist/styles.css +1 -1
  51. package/dist/{useLocale-CuvWRZ1h.js → useLocale-b5-hzsL3.js} +32 -2
  52. package/dist/useLocale-b5-hzsL3.js.map +1 -0
  53. package/package.json +11 -2
  54. package/src/__tests__/MFab.test.ts +52 -6
  55. package/src/__tests__/MMap.test.ts +292 -0
  56. package/src/__tests__/MMapLayers.test.ts +257 -0
  57. package/src/__tests__/MMapTools.test.ts +233 -0
  58. package/src/__tests__/_fakeMaplibre.ts +158 -0
  59. package/src/__tests__/hydration.test.ts +33 -0
  60. package/src/__tests__/ssr.test.ts +63 -1
  61. package/src/__tests__/ssrState.test.ts +155 -0
  62. package/src/__tests__/themeInitScript.test.ts +18 -0
  63. package/src/components/MFab.vue +29 -7
  64. package/src/components/MIconButton.vue +1 -1
  65. package/src/components/MLightbox.vue +6 -2
  66. package/src/components/MMap.vue +522 -0
  67. package/src/components/MMapBaseLayers.vue +67 -0
  68. package/src/components/MMapControl.vue +61 -0
  69. package/src/components/MMapFeatureInfo.vue +41 -0
  70. package/src/components/MMapFilter.vue +80 -0
  71. package/src/components/MMapGeoJson.vue +136 -0
  72. package/src/components/MMapHover.vue +131 -0
  73. package/src/components/MMapIdentify.vue +103 -0
  74. package/src/components/MMapLayers.vue +111 -0
  75. package/src/components/MMapMarker.vue +102 -0
  76. package/src/components/MMapMeasure.vue +452 -0
  77. package/src/components/MMapPopup.vue +99 -0
  78. package/src/components/MMapSearch.vue +162 -0
  79. package/src/components/_MMapLayerItem.vue +77 -0
  80. package/src/composables/_mapGeometry.ts +75 -0
  81. package/src/composables/_ssrState.ts +80 -0
  82. package/src/composables/_storageKeys.ts +6 -0
  83. package/src/composables/_useThemeTokens.ts +42 -0
  84. package/src/composables/mapAdapters.ts +208 -0
  85. package/src/composables/mapSearch.ts +56 -0
  86. package/src/composables/themeInitScript.ts +6 -4
  87. package/src/composables/useColorPalette.ts +23 -9
  88. package/src/composables/useLocale.ts +62 -0
  89. package/src/composables/useMap.ts +98 -0
  90. package/src/composables/useMapFilter.ts +45 -0
  91. package/src/composables/useMapLayers.ts +124 -0
  92. package/src/composables/useTheme.ts +8 -3
  93. package/src/composables/useWindowSizeClass.ts +14 -5
  94. package/src/index.ts +2 -1
  95. package/src/locales/de.ts +31 -1
  96. package/src/locales/es.ts +31 -1
  97. package/src/locales/fr.ts +31 -1
  98. package/src/locales/ja.ts +31 -1
  99. package/src/locales/ko.ts +31 -1
  100. package/src/locales/pt.ts +31 -1
  101. package/src/locales/zh.ts +31 -1
  102. package/src/map.ts +32 -0
  103. package/src/plugin.ts +54 -3
  104. package/dist/MTextField-BPbFeI9M.js +0 -1368
  105. package/dist/MTextField-BPbFeI9M.js.map +0 -1
  106. package/dist/useLocale-CuvWRZ1h.js.map +0 -1
package/dist/map.js ADDED
@@ -0,0 +1,1931 @@
1
+ import { a as e, i as t, l as n, n as r, s as i, t as a } from "./MSlider-CdNIH7jc.js";
2
+ import { i as o } from "./useLocale-b5-hzsL3.js";
3
+ import { h as s, n as c, t as l } from "./MTextField-B4X92vH_.js";
4
+ import { t as u } from "./MIcon-DLOkQduI.js";
5
+ import { Fragment as d, Transition as f, computed as p, createBlock as m, createCommentVNode as h, createElementBlock as g, createElementVNode as _, createSlots as v, createTextVNode as y, createVNode as b, defineComponent as x, getCurrentInstance as S, inject as C, markRaw as w, mergeProps as T, normalizeClass as E, normalizeStyle as D, onBeforeUnmount as O, onMounted as k, onUnmounted as A, openBlock as j, provide as M, reactive as N, ref as P, renderList as F, renderSlot as I, shallowRef as L, toDisplayString as R, unref as z, useId as B, useSlots as V, watch as H, withCtx as U, withModifiers as W } from "vue";
6
+ //#region src/composables/useMap.ts
7
+ var ee = Symbol("m3-map");
8
+ function G() {
9
+ let e = C(ee, null);
10
+ if (!e) throw Error("useMap() must be called in a component inside <MMap>");
11
+ let t = [];
12
+ S() && O(() => t.splice(0).forEach((e) => e()));
13
+ function n(n) {
14
+ let r = () => {
15
+ if (e.map.value && e.maplibre.value) return n(e.map.value, e.maplibre.value);
16
+ let r = H(e.map, (t) => {
17
+ t && e.maplibre.value && (r(), n(t, e.maplibre.value));
18
+ });
19
+ t.push(r);
20
+ }, i = S();
21
+ i && !i.isMounted ? k(r) : r();
22
+ }
23
+ function r(e, r) {
24
+ n((n) => {
25
+ n.on(e, r), t.push(() => n.off(e, r));
26
+ });
27
+ }
28
+ function i(e, r, i) {
29
+ n((n) => {
30
+ n.on(e, r, i), t.push(() => n.off(e, r, i));
31
+ });
32
+ }
33
+ return {
34
+ map: p(() => e.map.value),
35
+ maplibre: p(() => e.maplibre.value),
36
+ styleVersion: p(() => e.styleVersion.value),
37
+ activeTool: e.activeTool,
38
+ onReady: n,
39
+ on: r,
40
+ onLayer: i
41
+ };
42
+ }
43
+ //#endregion
44
+ //#region src/composables/useMapLayers.ts
45
+ var te = {
46
+ fill: ["fill-opacity"],
47
+ line: ["line-opacity"],
48
+ circle: ["circle-opacity", "circle-stroke-opacity"],
49
+ symbol: ["icon-opacity", "text-opacity"],
50
+ raster: ["raster-opacity"],
51
+ heatmap: ["heatmap-opacity"],
52
+ "fill-extrusion": ["fill-extrusion-opacity"]
53
+ };
54
+ function K() {
55
+ return N({
56
+ visible: {},
57
+ opacity: {}
58
+ });
59
+ }
60
+ function ne(e, t, n) {
61
+ let r = {}, i = {};
62
+ for (let e of n?.layers ?? []) {
63
+ let n = t.getLayer(e.id);
64
+ if (!n) continue;
65
+ r[e.id] = t.getLayoutProperty(e.id, "visibility") !== "none";
66
+ let a = te[n.type]?.[0], o = a ? t.getPaintProperty(e.id, a) : void 0;
67
+ i[e.id] = typeof o == "number" ? o : 1;
68
+ }
69
+ e.visible = r, e.opacity = i;
70
+ }
71
+ function q() {
72
+ let e = C(ee, null);
73
+ if (!e) throw Error("useMapLayers() must be called in a component inside <MMap>");
74
+ let { map: t, model: n, layerState: r } = e, i = p(() => n.value?.layers ?? []), a = p(() => new Map(i.value.map((e) => [e.id, e])));
75
+ function o(e) {
76
+ return r.visible[e] ?? !0;
77
+ }
78
+ function s(e, n) {
79
+ let i = t.value;
80
+ i?.getLayer(e) && i.setLayoutProperty(e, "visibility", n ? "visible" : "none"), r.visible[e] = n;
81
+ for (let t of a.value.get(e)?.children ?? []) s(t, n);
82
+ }
83
+ function c(e) {
84
+ s(e, !o(e));
85
+ }
86
+ function l(e) {
87
+ return r.opacity[e] ?? 1;
88
+ }
89
+ function u(e, n) {
90
+ let i = t.value, o = i?.getLayer(e);
91
+ if (o) for (let t of te[o.type] ?? []) i.setPaintProperty(e, t, n);
92
+ r.opacity[e] = n;
93
+ for (let t of a.value.get(e)?.children ?? []) u(t, n);
94
+ }
95
+ function d(e) {
96
+ return i.value.filter((t) => t.listed && (e === null ? !t.group || !n.value?.groups.some((e) => e.name === t.group) : t.group === e));
97
+ }
98
+ function f(e) {
99
+ let t = d(e).map((e) => o(e.id));
100
+ return t.length && t.every(Boolean) ? "visible" : t.some(Boolean) ? "partial" : "hidden";
101
+ }
102
+ function m(e, t) {
103
+ for (let n of d(e)) s(n.id, t);
104
+ }
105
+ let h = p(() => i.value.filter((e) => e.base)), g = p(() => h.value.find((e) => o(e.id))?.id ?? null);
106
+ function _(e) {
107
+ for (let t of h.value) s(t.id, t.id === e);
108
+ }
109
+ return {
110
+ model: p(() => n.value),
111
+ layers: i,
112
+ isVisible: o,
113
+ setVisible: s,
114
+ toggle: c,
115
+ opacityOf: l,
116
+ setOpacity: u,
117
+ layersOf: d,
118
+ groupState: f,
119
+ setGroupVisible: m,
120
+ baseLayers: h,
121
+ baseLayer: g,
122
+ setBaseLayer: _
123
+ };
124
+ }
125
+ //#endregion
126
+ //#region src/components/MMap.vue?vue&type=script&setup=true&lang.ts
127
+ var re = 600, J = /* @__PURE__ */ x({
128
+ __name: "MMap",
129
+ props: {
130
+ mapStyle: {},
131
+ center: {},
132
+ zoom: {},
133
+ bearing: {},
134
+ pitch: {},
135
+ persist: {
136
+ type: [Boolean, String],
137
+ default: !1
138
+ },
139
+ navigation: {
140
+ type: [Boolean, String],
141
+ default: !0
142
+ },
143
+ geolocate: {
144
+ type: [Boolean, String],
145
+ default: !1
146
+ },
147
+ fullscreen: {
148
+ type: [Boolean, String],
149
+ default: !1
150
+ },
151
+ scale: {
152
+ type: [Boolean, String],
153
+ default: !0
154
+ },
155
+ attribution: {
156
+ type: [Boolean, String],
157
+ default: !0
158
+ },
159
+ options: {},
160
+ adapter: {}
161
+ },
162
+ emits: [
163
+ "ready",
164
+ "click",
165
+ "update:center",
166
+ "update:zoom",
167
+ "update:bearing",
168
+ "update:pitch"
169
+ ],
170
+ setup(e, { expose: t, emit: n }) {
171
+ let r = e, i = n, a = P(), s = P(), c = L(), l = L(), u = P(0), d = L(), p = K(), m = P(null);
172
+ M(ee, {
173
+ map: c,
174
+ maplibre: l,
175
+ styleVersion: u,
176
+ model: d,
177
+ layerState: p,
178
+ activeTool: m
179
+ });
180
+ function v(e) {
181
+ d.value = r.adapter ? r.adapter(e.getStyle(), { styleUrl: typeof r.mapStyle == "string" ? r.mapStyle : void 0 }) : void 0, ne(p, e, d.value);
182
+ }
183
+ let y = o(), x = () => typeof r.persist == "string" ? r.persist : r.persist ? "m3-map-view" : null;
184
+ function S() {
185
+ let e = x();
186
+ if (!e) return {};
187
+ try {
188
+ let t = JSON.parse(localStorage.getItem(e) ?? "null");
189
+ return t && typeof t == "object" ? t : {};
190
+ } catch {
191
+ return {};
192
+ }
193
+ }
194
+ function C(e) {
195
+ let t = e.getCenter();
196
+ return {
197
+ center: [t.lng, t.lat],
198
+ zoom: e.getZoom(),
199
+ bearing: e.getBearing(),
200
+ pitch: e.getPitch()
201
+ };
202
+ }
203
+ let T = {
204
+ navigation: {
205
+ corner: "top-right",
206
+ create: (e) => new e.NavigationControl()
207
+ },
208
+ geolocate: {
209
+ corner: "top-right",
210
+ create: (e) => new e.GeolocateControl({
211
+ positionOptions: { enableHighAccuracy: !0 },
212
+ trackUserLocation: !0
213
+ })
214
+ },
215
+ fullscreen: {
216
+ corner: "top-right",
217
+ create: (e) => new e.FullscreenControl({ container: a.value })
218
+ },
219
+ scale: {
220
+ corner: "bottom-left",
221
+ create: (e) => new e.ScaleControl({
222
+ maxWidth: 100,
223
+ unit: "metric"
224
+ })
225
+ },
226
+ attribution: {
227
+ corner: "bottom-right",
228
+ create: (e) => new e.AttributionControl({ compact: !0 })
229
+ }
230
+ }, N = /* @__PURE__ */ new Map();
231
+ function F(e) {
232
+ let t = c.value, n = l.value;
233
+ if (!t || !n) return;
234
+ let i = N.get(e);
235
+ i && (t.removeControl(i), N.delete(e));
236
+ let a = r[e];
237
+ if (!a) return;
238
+ let o = T[e].create(n);
239
+ t.addControl(o, a === !0 ? T[e].corner : a), N.set(e, o);
240
+ }
241
+ for (let e of Object.keys(T)) H(() => r[e], () => F(e));
242
+ function z() {
243
+ return {
244
+ "AttributionControl.ToggleAttribution": y.mapToggleAttribution,
245
+ "AttributionControl.MapFeedback": y.mapFeedback,
246
+ "FullscreenControl.Enter": y.mapEnterFullscreen,
247
+ "FullscreenControl.Exit": y.mapExitFullscreen,
248
+ "GeolocateControl.FindMyLocation": y.mapFindMyLocation,
249
+ "GeolocateControl.LocationNotAvailable": y.mapLocationNotAvailable,
250
+ "Map.Title": y.mapTitle,
251
+ "Marker.Title": y.mapMarker,
252
+ "NavigationControl.ResetBearing": y.mapResetBearing,
253
+ "NavigationControl.ZoomIn": y.mapZoomIn,
254
+ "NavigationControl.ZoomOut": y.mapZoomOut,
255
+ "Popup.Close": y.close,
256
+ "CooperativeGesturesHandler.WindowsHelpText": y.mapCtrlScroll,
257
+ "CooperativeGesturesHandler.MacHelpText": y.mapCmdScroll,
258
+ "CooperativeGesturesHandler.MobileHelpText": y.mapTwoFingers
259
+ };
260
+ }
261
+ let B = P(null), V, W;
262
+ function G(e) {
263
+ let t = e.getAttribute("title");
264
+ t && e.closest(".maplibregl-ctrl") && (e.setAttribute("data-m3-tip", t), e.hasAttribute("aria-label") || e.setAttribute("aria-label", t), e.removeAttribute("title"));
265
+ }
266
+ function te(e) {
267
+ let t = e.getAttribute("data-m3-tip"), n = a.value?.getBoundingClientRect();
268
+ if (!t || !n) return;
269
+ let r = e.getBoundingClientRect(), i = r.left + r.width / 2 > n.left + n.width / 2;
270
+ B.value = {
271
+ text: t,
272
+ left: i,
273
+ x: (i ? r.left - 8 : r.right + 8) - n.left,
274
+ y: r.top + r.height / 2 - n.top
275
+ };
276
+ }
277
+ function q() {
278
+ clearTimeout(V), B.value = null;
279
+ }
280
+ let J = (e) => e.target?.closest?.(".maplibregl-ctrl [data-m3-tip]") ?? null;
281
+ function ie(e) {
282
+ let t = J(e);
283
+ t && e.pointerType !== "touch" && (clearTimeout(V), V = setTimeout(() => te(t), re));
284
+ }
285
+ function ae(e) {
286
+ let t = J(e);
287
+ t && !t.contains(e.relatedTarget) && q();
288
+ }
289
+ function oe(e) {
290
+ let t = J(e);
291
+ t?.matches(":focus-visible") && te(t);
292
+ }
293
+ k(() => {
294
+ let e = a.value;
295
+ e && (e.querySelectorAll("[title]").forEach(G), W = new MutationObserver((e) => {
296
+ for (let t of e) t.type === "attributes" ? G(t.target) : t.addedNodes.forEach((e) => {
297
+ e instanceof Element && (G(e), e.querySelectorAll("[title]").forEach(G));
298
+ });
299
+ }), W.observe(e, {
300
+ subtree: !0,
301
+ childList: !0,
302
+ attributes: !0,
303
+ attributeFilter: ["title"]
304
+ }));
305
+ }), O(() => {
306
+ W?.disconnect(), clearTimeout(V);
307
+ });
308
+ let Y = !1;
309
+ k(async () => {
310
+ let e = await import("maplibre-gl"), t = "Map" in e ? e : e.default;
311
+ if (Y || !s.value) return;
312
+ let n = S(), a = {
313
+ center: n.center ?? r.center,
314
+ zoom: n.zoom ?? r.zoom,
315
+ bearing: n.bearing ?? r.bearing,
316
+ pitch: n.pitch ?? r.pitch
317
+ }, o = w(new t.Map({
318
+ container: s.value,
319
+ style: r.mapStyle,
320
+ attributionControl: !1,
321
+ locale: z(),
322
+ ...Object.fromEntries(Object.entries(a).filter(([, e]) => e !== void 0)),
323
+ ...r.options
324
+ }));
325
+ l.value = t, o.on("style.load", () => {
326
+ v(o), u.value++;
327
+ }), o.on("click", (e) => i("click", e)), o.on("moveend", () => {
328
+ let e = C(o);
329
+ i("update:center", e.center), i("update:zoom", e.zoom), i("update:bearing", e.bearing), i("update:pitch", e.pitch);
330
+ let t = x();
331
+ if (t) try {
332
+ localStorage.setItem(t, JSON.stringify(e));
333
+ } catch {}
334
+ }), o.once("load", () => {
335
+ c.value = o;
336
+ for (let e of Object.keys(T)) F(e);
337
+ i("ready", o);
338
+ });
339
+ }), A(() => {
340
+ Y = !0, c.value?.remove(), c.value = void 0;
341
+ });
342
+ let X = (e, t) => Math.abs(e - t) < 1e-9;
343
+ return H(() => r.center?.join(","), () => {
344
+ let e = c.value;
345
+ if (!e || !r.center) return;
346
+ let t = e.getCenter();
347
+ (!X(t.lng, r.center[0]) || !X(t.lat, r.center[1])) && e.jumpTo({ center: r.center });
348
+ }), H(() => r.zoom, (e) => {
349
+ c.value && e !== void 0 && !X(c.value.getZoom(), e) && c.value.jumpTo({ zoom: e });
350
+ }), H(() => r.bearing, (e) => {
351
+ c.value && e !== void 0 && !X(c.value.getBearing(), e) && c.value.jumpTo({ bearing: e });
352
+ }), H(() => r.pitch, (e) => {
353
+ c.value && e !== void 0 && !X(c.value.getPitch(), e) && c.value.jumpTo({ pitch: e });
354
+ }), H(() => r.adapter, () => {
355
+ c.value && v(c.value);
356
+ }), H(() => r.mapStyle, (e) => c.value?.setStyle(e, { diff: !1 })), t({ map: c }), (e, t) => (j(), g("div", {
357
+ ref_key: "root",
358
+ ref: a,
359
+ class: "m3-map relative overflow-hidden",
360
+ onPointerover: ie,
361
+ onPointerout: ae,
362
+ onPointerdown: q,
363
+ onFocusin: oe,
364
+ onFocusout: q
365
+ }, [
366
+ _("div", {
367
+ ref_key: "container",
368
+ ref: s,
369
+ class: "h-full w-full"
370
+ }, null, 512),
371
+ c.value ? I(e.$slots, "default", {}, void 0, void 0, 0) : h("", !0),
372
+ b(f, {
373
+ "enter-active-class": "transition-opacity duration-150",
374
+ "enter-from-class": "opacity-0",
375
+ "leave-active-class": "transition-opacity duration-100",
376
+ "leave-to-class": "opacity-0"
377
+ }, {
378
+ default: U(() => [B.value ? (j(), g("div", {
379
+ key: 0,
380
+ role: "tooltip",
381
+ class: E(["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", B.value.left ? "-translate-x-full" : ""]),
382
+ style: D({
383
+ left: `${B.value.x}px`,
384
+ top: `${B.value.y}px`
385
+ })
386
+ }, R(B.value.text), 7)) : h("", !0)]),
387
+ _: 1
388
+ })
389
+ ], 544));
390
+ }
391
+ }), ie = { class: "hidden" }, ae = /* @__PURE__ */ x({
392
+ inheritAttrs: !1,
393
+ __name: "MMapMarker",
394
+ props: {
395
+ lngLat: {},
396
+ color: {},
397
+ draggable: {
398
+ type: Boolean,
399
+ default: !1
400
+ },
401
+ anchor: {},
402
+ offset: {},
403
+ rotation: { default: 0 }
404
+ },
405
+ emits: ["update:lngLat", "click"],
406
+ setup(e, { expose: t, emit: n }) {
407
+ let r = e, i = n, a = V(), o = P(), s = P(), { onReady: c } = G(), l;
408
+ c((e, t) => {
409
+ let n = !!a.default && o.value;
410
+ l = new t.Marker({
411
+ ...n ? { element: o.value } : { color: r.color ?? "currentColor" },
412
+ draggable: r.draggable,
413
+ anchor: r.anchor ?? (n ? "center" : "bottom"),
414
+ offset: r.offset,
415
+ rotation: r.rotation
416
+ }), !n && !r.color && l.getElement().classList.add("m3-map-marker--default"), l.setLngLat(r.lngLat).addTo(e), l.getElement().addEventListener("click", u), l.on("dragend", () => {
417
+ let { lng: e, lat: t } = l.getLngLat();
418
+ i("update:lngLat", [e, t]);
419
+ }), a.popup && s.value && l.setPopup(new t.Popup({
420
+ offset: n ? 16 : 32,
421
+ maxWidth: "320px"
422
+ }).setDOMContent(s.value));
423
+ });
424
+ function u(e) {
425
+ i("click", e);
426
+ }
427
+ return H(() => r.lngLat.join(","), () => l?.setLngLat(r.lngLat)), H(() => r.draggable, (e) => l?.setDraggable(e)), H(() => r.rotation, (e) => l?.setRotation(e)), H(() => r.offset?.join(","), () => l?.setOffset(r.offset ?? [0, 0])), O(() => {
428
+ l?.getElement().removeEventListener("click", u), l?.getPopup()?.remove(), l?.remove();
429
+ }), t({ marker: () => l }), (e, t) => (j(), g("div", ie, [e.$slots.default ? (j(), g("div", T({
430
+ key: 0,
431
+ ref_key: "content",
432
+ ref: o,
433
+ class: "m3-map-marker"
434
+ }, e.$attrs), [I(e.$slots, "default")], 16)) : h("", !0), e.$slots.popup ? (j(), g("div", {
435
+ key: 1,
436
+ ref_key: "popupContent",
437
+ ref: s
438
+ }, [I(e.$slots, "popup")], 512)) : h("", !0)]));
439
+ }
440
+ }), oe = { class: "hidden" }, Y = /* @__PURE__ */ x({
441
+ inheritAttrs: !1,
442
+ __name: "MMapPopup",
443
+ props: {
444
+ lngLat: {},
445
+ open: {
446
+ type: Boolean,
447
+ default: !0
448
+ },
449
+ closeButton: {
450
+ type: Boolean,
451
+ default: !0
452
+ },
453
+ closeOnClick: {
454
+ type: Boolean,
455
+ default: !0
456
+ },
457
+ anchor: {},
458
+ offset: { default: 8 },
459
+ maxWidth: { default: "320px" }
460
+ },
461
+ emits: ["update:open"],
462
+ setup(e, { expose: t, emit: n }) {
463
+ let r = e, i = n, a = P(), { onReady: o } = G(), s, c, l = !1;
464
+ function u() {
465
+ s && c && !s.isOpen() && s.setLngLat(r.lngLat).addTo(c);
466
+ }
467
+ return o((e, t) => {
468
+ c = e, s = new t.Popup({
469
+ closeButton: r.closeButton,
470
+ closeOnClick: r.closeOnClick,
471
+ closeOnMove: !1,
472
+ anchor: r.anchor,
473
+ offset: r.offset,
474
+ maxWidth: r.maxWidth,
475
+ focusAfterOpen: !1
476
+ }), a.value && s.setDOMContent(a.value), s.on("close", () => {
477
+ l || i("update:open", !1);
478
+ }), r.open && u();
479
+ }), H(() => r.open, (e) => {
480
+ e ? u() : s?.isOpen() && (l = !0, s.remove(), l = !1);
481
+ }), H(() => r.lngLat.join(","), () => s?.setLngLat(r.lngLat)), H(() => r.maxWidth, (e) => s?.setMaxWidth(e)), O(() => {
482
+ l = !0, s?.remove();
483
+ }), t({ popup: () => s }), (e, t) => (j(), g("div", oe, [_("div", T({
484
+ ref_key: "content",
485
+ ref: a
486
+ }, e.$attrs), [I(e.$slots, "default")], 16)]));
487
+ }
488
+ });
489
+ //#endregion
490
+ //#region src/composables/_useThemeTokens.ts
491
+ function X(e) {
492
+ let t = () => {
493
+ let t = getComputedStyle(document.documentElement);
494
+ return Object.fromEntries(e.map((e) => [e, t.getPropertyValue(`--color-${e}`).trim()]));
495
+ }, r = P(typeof document > "u" ? Object.fromEntries(e.map((e) => [e, ""])) : t()), i, a;
496
+ return k(() => {
497
+ let o = () => {
498
+ let n = t();
499
+ e.some((e) => n[e] !== r.value[e]) && (r.value = n);
500
+ }, s = (e) => (e instanceof Element ? e : e?.parentElement)?.id === n;
501
+ i = new MutationObserver((e) => {
502
+ e.some((e) => e.target === document.documentElement || s(e.target) || Array.from(e.addedNodes).some(s)) && (o(), clearTimeout(a), a = setTimeout(o, 300));
503
+ }), i.observe(document.documentElement, {
504
+ attributes: !0,
505
+ attributeFilter: [
506
+ "class",
507
+ "style",
508
+ "data-palette",
509
+ "data-contrast"
510
+ ]
511
+ }), i.observe(document.head, {
512
+ childList: !0,
513
+ characterData: !0,
514
+ subtree: !0
515
+ });
516
+ }), O(() => {
517
+ i?.disconnect(), clearTimeout(a);
518
+ }), r;
519
+ }
520
+ //#endregion
521
+ //#region src/components/MMapGeoJson.vue
522
+ var se = /* @__PURE__ */ x({
523
+ inheritAttrs: !1,
524
+ __name: "MMapGeoJson",
525
+ props: {
526
+ data: {},
527
+ id: {},
528
+ layers: {},
529
+ before: {},
530
+ interactive: {
531
+ type: Boolean,
532
+ default: !1
533
+ },
534
+ sourceOptions: {}
535
+ },
536
+ emits: ["click"],
537
+ setup(e, { expose: t, emit: n }) {
538
+ let r = e, i = n, a = r.id ?? `m3-geojson-${B()}`, { onReady: o, styleVersion: s } = G(), c = X(["primary", "surface"]), l = (...e) => [
539
+ "match",
540
+ ["geometry-type"],
541
+ e,
542
+ !0,
543
+ !1
544
+ ], u = p(() => {
545
+ let { primary: e, surface: t } = c.value;
546
+ return [
547
+ {
548
+ id: `${a}-fill`,
549
+ type: "fill",
550
+ filter: l("Polygon", "MultiPolygon"),
551
+ paint: {
552
+ "fill-color": e,
553
+ "fill-opacity": .24
554
+ }
555
+ },
556
+ {
557
+ id: `${a}-line`,
558
+ type: "line",
559
+ filter: l("Polygon", "MultiPolygon", "LineString", "MultiLineString"),
560
+ paint: {
561
+ "line-color": e,
562
+ "line-width": 2
563
+ }
564
+ },
565
+ {
566
+ id: `${a}-circle`,
567
+ type: "circle",
568
+ filter: l("Point", "MultiPoint"),
569
+ paint: {
570
+ "circle-color": e,
571
+ "circle-radius": 6,
572
+ "circle-stroke-color": t,
573
+ "circle-stroke-width": 2
574
+ }
575
+ }
576
+ ];
577
+ }), d = p(() => (r.layers ?? u.value).map((e, t) => ({
578
+ ...e,
579
+ id: e.id ?? `${a}-${t}`,
580
+ source: a
581
+ }))), f, m = [], h = (e) => i("click", e), g = () => {
582
+ r.interactive && f && (f.getCanvas().style.cursor = "pointer");
583
+ }, _ = () => {
584
+ r.interactive && f && (f.getCanvas().style.cursor = "");
585
+ };
586
+ function v() {
587
+ if (f) {
588
+ for (let e of m) f.off("click", e, h), f.off("mouseenter", e, g), f.off("mouseleave", e, _), f.getLayer(e) && f.removeLayer(e);
589
+ m = [];
590
+ }
591
+ }
592
+ function y() {
593
+ if (f) {
594
+ v();
595
+ for (let e of d.value) f.addLayer(e, r.before && f.getLayer(r.before) ? r.before : void 0), f.on("click", e.id, h), f.on("mouseenter", e.id, g), f.on("mouseleave", e.id, _), m.push(e.id);
596
+ }
597
+ }
598
+ function b() {
599
+ f && (f.getSource(a) || (f.addSource(a, {
600
+ type: "geojson",
601
+ data: r.data,
602
+ ...r.sourceOptions
603
+ }), m = []), (!m.length || !f.getLayer(m[0])) && y());
604
+ }
605
+ return o((e) => {
606
+ f = e, b();
607
+ }), H(s, () => b()), H(() => r.data, (e) => (f?.getSource(a))?.setData(e)), H(() => JSON.stringify(d.value), () => y()), H(() => r.before, () => y()), O(() => {
608
+ f &&= (v(), f.getSource(a) && f.removeSource(a), void 0);
609
+ }), t({
610
+ sourceId: a,
611
+ layerIds: () => [...m]
612
+ }), (e, t) => null;
613
+ }
614
+ }), ce = { class: "hidden" }, le = /* @__PURE__ */ x({
615
+ inheritAttrs: !1,
616
+ __name: "MMapControl",
617
+ props: {
618
+ position: { default: "top-right" },
619
+ group: {
620
+ type: Boolean,
621
+ default: !0
622
+ }
623
+ },
624
+ setup(e) {
625
+ let t = e, n = P(), { onReady: r } = G(), i, a = {
626
+ onAdd: () => n.value,
627
+ onRemove: () => n.value?.remove()
628
+ };
629
+ return r((e) => {
630
+ i = e, n.value && e.addControl(a, t.position);
631
+ }), H(() => t.position, (e) => {
632
+ i && n.value && (i.removeControl(a), i.addControl(a, e));
633
+ }), O(() => {
634
+ i?.hasControl(a) && i.removeControl(a);
635
+ }), (t, r) => (j(), g("div", ce, [_("div", T({
636
+ ref_key: "el",
637
+ ref: n,
638
+ class: ["maplibregl-ctrl", e.group ? "maplibregl-ctrl-group" : ""]
639
+ }, t.$attrs), [I(t.$slots, "default")], 16)]));
640
+ }
641
+ }), ue = { class: "flex min-w-0 flex-1 flex-col" }, de = ["aria-label", "aria-pressed"], fe = { class: "flex min-w-0 flex-1 flex-col" }, pe = {
642
+ key: 0,
643
+ class: "truncate text-label-small text-on-surface-variant"
644
+ }, me = {
645
+ key: 0,
646
+ class: "rounded-full bg-primary/8 px-2 py-0.5 text-label-small tabular-nums text-primary"
647
+ }, he = { class: "min-h-0 overflow-hidden" }, ge = { class: "flex flex-col gap-3 px-3 pb-3" }, _e = {
648
+ key: 0,
649
+ class: "text-body-small text-on-surface-variant"
650
+ }, ve = { class: "flex items-center gap-2 rounded-2xl bg-surface-container-highest/60 px-3 py-1" }, ye = ["src"], be = {
651
+ key: 2,
652
+ class: "flex flex-wrap items-center gap-2"
653
+ }, xe = ["href"], Z = /* @__PURE__ */ x({
654
+ __name: "_MMapLayerItem",
655
+ props: {
656
+ layer: {},
657
+ expanded: { type: Boolean }
658
+ },
659
+ emits: ["toggle-expanded"],
660
+ setup(e, { emit: t }) {
661
+ let n = t, r = o(), { isVisible: i, toggle: s, opacityOf: c, setOpacity: l } = q();
662
+ return (t, o) => (j(), g("div", { class: E(["flex overflow-hidden rounded-2xl bg-surface-container", z(i)(e.layer.id) ? "" : "opacity-75"]) }, [_("div", { class: E(["w-1 shrink-0 transition-colors duration-200", z(i)(e.layer.id) ? "bg-primary" : "bg-outline-variant"]) }, null, 2), _("div", ue, [_("div", {
663
+ class: "flex cursor-pointer items-center gap-2 px-3 py-2",
664
+ onClick: o[1] ||= (e) => n("toggle-expanded")
665
+ }, [
666
+ _("button", {
667
+ type: "button",
668
+ class: E(["grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200", z(i)(e.layer.id) ? "bg-primary/12 text-primary" : "bg-on-surface/5 text-on-surface-variant"]),
669
+ "aria-label": z(i)(e.layer.id) ? z(r).mapHideLayer : z(r).mapShowLayer,
670
+ "aria-pressed": z(i)(e.layer.id),
671
+ onClick: o[0] ||= W((t) => z(s)(e.layer.id), ["stop"])
672
+ }, [b(u, {
673
+ name: z(i)(e.layer.id) ? "visibility" : "visibility_off",
674
+ size: 18
675
+ }, null, 8, ["name"])], 10, de),
676
+ _("div", fe, [_("span", { class: E(["truncate text-body-medium", z(i)(e.layer.id) ? "text-on-surface" : "text-on-surface-variant"]) }, R(e.layer.title), 3), e.layer.description && !e.expanded ? (j(), g("span", pe, R(e.layer.description), 1)) : h("", !0)]),
677
+ z(i)(e.layer.id) && z(c)(e.layer.id) < 1 ? (j(), g("span", me, R(Math.round(z(c)(e.layer.id) * 100)) + "% ", 1)) : h("", !0),
678
+ b(u, {
679
+ name: "expand_more",
680
+ size: 18,
681
+ class: E(["shrink-0 text-on-surface-variant transition-transform duration-300", e.expanded ? "rotate-180" : ""])
682
+ }, null, 8, ["class"])
683
+ ]), _("div", {
684
+ class: "grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]",
685
+ style: D({ gridTemplateRows: e.expanded ? "1fr" : "0fr" })
686
+ }, [_("div", he, [_("div", ge, [
687
+ e.layer.description ? (j(), g("p", _e, R(e.layer.description), 1)) : h("", !0),
688
+ _("div", ve, [b(u, {
689
+ name: "opacity",
690
+ size: 16,
691
+ class: "shrink-0 text-on-surface-variant"
692
+ }), b(a, {
693
+ "model-value": z(c)(e.layer.id),
694
+ min: 0,
695
+ max: 1,
696
+ step: .01,
697
+ label: z(r).mapOpacity,
698
+ class: "flex-1",
699
+ "onUpdate:modelValue": o[2] ||= (t) => z(l)(e.layer.id, Number(t))
700
+ }, null, 8, ["model-value", "label"])]),
701
+ e.layer.legend ? (j(), g("img", {
702
+ key: 1,
703
+ src: e.layer.legend,
704
+ alt: "",
705
+ class: "max-w-full self-start",
706
+ loading: "lazy"
707
+ }, null, 8, ye)) : h("", !0),
708
+ e.layer.download || t.$slots.actions ? (j(), g("div", be, [e.layer.download ? (j(), g("a", {
709
+ key: 0,
710
+ href: e.layer.download,
711
+ target: "_blank",
712
+ rel: "noopener",
713
+ download: "",
714
+ class: "inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-label-large text-primary hover:bg-primary/8"
715
+ }, [b(u, {
716
+ name: "download",
717
+ size: 18
718
+ }), y(" " + R(z(r).mapDownload), 1)], 8, xe)) : h("", !0), I(t.$slots, "actions", {
719
+ layer: e.layer,
720
+ visible: z(i)(e.layer.id)
721
+ })])) : h("", !0)
722
+ ])])], 4)])], 2));
723
+ }
724
+ }), Q = { class: "flex flex-col gap-3" }, Se = ["onClick"], Ce = [
725
+ "aria-label",
726
+ "aria-pressed",
727
+ "onClick"
728
+ ], we = { class: "flex-1 select-none truncate text-label-large text-on-surface" }, Te = { class: "rounded-full bg-surface-container-highest px-2 py-0.5 text-label-small tabular-nums text-on-surface-variant" }, Ee = {
729
+ key: 1,
730
+ class: "flex flex-col gap-1.5"
731
+ }, De = {
732
+ key: 2,
733
+ class: "flex flex-col items-center gap-3 py-8"
734
+ }, Oe = { class: "grid size-14 place-items-center rounded-full bg-surface-container-highest" }, ke = { class: "text-body-medium text-on-surface-variant" }, Ae = /* @__PURE__ */ x({
735
+ __name: "MMapLayers",
736
+ props: {
737
+ search: {
738
+ type: Boolean,
739
+ default: !0
740
+ },
741
+ collapsed: {
742
+ type: Boolean,
743
+ default: !1
744
+ }
745
+ },
746
+ setup(e) {
747
+ let t = e, n = o(), { model: r, layersOf: i, isVisible: a, groupState: s, setGroupVisible: c } = q(), f = P(""), y = (e) => !f.value || e.title.toLowerCase().includes(f.value.toLowerCase()), x = p(() => (r.value?.groups ?? []).map((e) => ({
748
+ ...e,
749
+ all: i(e.name),
750
+ layers: i(e.name).filter(y)
751
+ })).filter((e) => e.layers.length)), S = p(() => i(null).filter(y)), C = P(/* @__PURE__ */ new Set()), w = (e) => C.value.has(e) === t.collapsed;
752
+ function O(e) {
753
+ let t = new Set(C.value);
754
+ t.delete(e) || t.add(e), C.value = t;
755
+ }
756
+ let k = P(/* @__PURE__ */ new Set());
757
+ function A(e) {
758
+ let t = new Set(k.value);
759
+ t.delete(e) || t.add(e), k.value = t;
760
+ }
761
+ let M = (e) => e.filter((e) => a(e.id)).length;
762
+ return (t, r) => (j(), g("div", Q, [
763
+ e.search ? (j(), m(l, {
764
+ key: 0,
765
+ modelValue: f.value,
766
+ "onUpdate:modelValue": r[0] ||= (e) => f.value = e,
767
+ label: z(n).mapSearchLayers,
768
+ "leading-icon": "search",
769
+ variant: "outlined",
770
+ clearable: ""
771
+ }, null, 8, ["modelValue", "label"])) : h("", !0),
772
+ (j(!0), g(d, null, F(x.value, (e) => (j(), g("section", {
773
+ key: e.name,
774
+ class: "flex flex-col"
775
+ }, [_("div", {
776
+ class: "m3-map-layers-row flex cursor-pointer items-center gap-2 rounded-xl px-2 py-1.5",
777
+ onClick: (t) => O(e.name)
778
+ }, [
779
+ _("button", {
780
+ type: "button",
781
+ class: E(["grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200", z(s)(e.name) === "visible" ? "bg-primary-container text-on-primary-container" : z(s)(e.name) === "partial" ? "bg-secondary-container text-on-secondary-container" : "bg-on-surface/8 text-on-surface-variant"]),
782
+ "aria-label": z(s)(e.name) === "hidden" ? z(n).mapShowLayer : z(n).mapHideLayer,
783
+ "aria-pressed": z(s)(e.name) !== "hidden",
784
+ onClick: W((t) => z(c)(e.name, z(s)(e.name) !== "visible"), ["stop"])
785
+ }, [b(u, {
786
+ name: z(s)(e.name) === "hidden" ? "visibility_off" : "visibility",
787
+ size: 18
788
+ }, null, 8, ["name"])], 10, Ce),
789
+ _("span", we, R(e.title), 1),
790
+ _("span", Te, R(M(e.all)) + "/" + R(e.all.length), 1),
791
+ b(u, {
792
+ name: "expand_more",
793
+ size: 18,
794
+ class: E(["text-on-surface-variant transition-transform duration-300", w(e.name) ? "rotate-180" : ""])
795
+ }, null, 8, ["class"])
796
+ ], 8, Se), _("div", {
797
+ class: "grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]",
798
+ style: D({ gridTemplateRows: w(e.name) ? "1fr" : "0fr" })
799
+ }, [_("div", { class: E(["flex min-h-0 flex-col gap-1.5 overflow-hidden", w(e.name) ? "pt-1.5" : ""]) }, [(j(!0), g(d, null, F(e.layers, (e) => (j(), m(Z, {
800
+ key: e.id,
801
+ layer: e,
802
+ expanded: k.value.has(e.id),
803
+ onToggleExpanded: (t) => A(e.id)
804
+ }, v({ _: 2 }, [t.$slots.actions ? {
805
+ name: "actions",
806
+ fn: U((e) => [I(t.$slots, "actions", T({ ref_for: !0 }, e))]),
807
+ key: "0"
808
+ } : void 0]), 1032, [
809
+ "layer",
810
+ "expanded",
811
+ "onToggleExpanded"
812
+ ]))), 128))], 2)], 4)]))), 128)),
813
+ S.value.length ? (j(), g("div", Ee, [(j(!0), g(d, null, F(S.value, (e) => (j(), m(Z, {
814
+ key: e.id,
815
+ layer: e,
816
+ expanded: k.value.has(e.id),
817
+ onToggleExpanded: (t) => A(e.id)
818
+ }, v({ _: 2 }, [t.$slots.actions ? {
819
+ name: "actions",
820
+ fn: U((e) => [I(t.$slots, "actions", T({ ref_for: !0 }, e))]),
821
+ key: "0"
822
+ } : void 0]), 1032, [
823
+ "layer",
824
+ "expanded",
825
+ "onToggleExpanded"
826
+ ]))), 128))])) : h("", !0),
827
+ !x.value.length && !S.value.length ? (j(), g("div", De, [_("div", Oe, [b(u, {
828
+ name: "layers_clear",
829
+ size: 28,
830
+ class: "text-on-surface-variant"
831
+ })]), _("p", ke, R(z(n).mapNoLayers), 1)])) : h("", !0)
832
+ ]));
833
+ }
834
+ }), je = [
835
+ "title",
836
+ "aria-label",
837
+ "aria-checked",
838
+ "onClick"
839
+ ], Me = ["src"], Ne = [
840
+ "title",
841
+ "aria-label",
842
+ "aria-checked"
843
+ ], Pe = /* @__PURE__ */ x({
844
+ __name: "MMapBaseLayers",
845
+ props: {
846
+ imageBase: { default: "" },
847
+ none: {
848
+ type: Boolean,
849
+ default: !0
850
+ },
851
+ vertical: {
852
+ type: Boolean,
853
+ default: !1
854
+ }
855
+ },
856
+ setup(e) {
857
+ let t = o(), { baseLayers: n, baseLayer: r, setBaseLayer: i } = q(), a = (e, t) => /^(https?:|data:|\/\/)/.test(e) ? e : `${t}${e}`;
858
+ return (o, s) => (j(), g("div", {
859
+ class: E(["flex gap-2", e.vertical ? "flex-col" : "flex-row flex-wrap"]),
860
+ role: "radiogroup"
861
+ }, [(j(!0), g(d, null, F(z(n), (t) => (j(), g("button", {
862
+ key: t.id,
863
+ type: "button",
864
+ role: "radio",
865
+ class: E(["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", z(r) === t.id ? "m3-map-base--active border-primary" : "border-transparent"]),
866
+ title: t.title,
867
+ "aria-label": t.title,
868
+ "aria-checked": z(r) === t.id,
869
+ onClick: (e) => z(i)(t.id)
870
+ }, [t.base?.image ? (j(), g("img", {
871
+ key: 0,
872
+ src: a(t.base.image, e.imageBase),
873
+ alt: "",
874
+ class: "size-full object-cover"
875
+ }, null, 8, Me)) : (j(), m(u, {
876
+ key: 1,
877
+ name: "map",
878
+ size: 22,
879
+ class: "text-on-surface-variant"
880
+ }))], 10, je))), 128)), e.none ? (j(), g("button", {
881
+ key: 0,
882
+ type: "button",
883
+ role: "radio",
884
+ class: E(["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", z(r) === null ? "m3-map-base--active border-primary" : "border-transparent"]),
885
+ title: z(t).mapNoBaseLayer,
886
+ "aria-label": z(t).mapNoBaseLayer,
887
+ "aria-checked": z(r) === null,
888
+ onClick: s[0] ||= (e) => z(i)(null)
889
+ }, [b(u, {
890
+ name: "layers_clear",
891
+ size: 22,
892
+ class: "text-on-surface-variant"
893
+ })], 10, Ne)) : h("", !0)], 2));
894
+ }
895
+ }), Fe = { class: "flex flex-col gap-2" }, Ie = { class: "flex items-center gap-2 bg-primary-container/40 px-4 py-2" }, Le = { class: "text-label-large text-on-primary-container" }, Re = { class: "flex flex-col px-4 py-1" }, ze = { class: "text-label-small text-on-surface-variant" }, Be = { class: "text-body-medium text-on-surface" }, Ve = {
896
+ key: 0,
897
+ class: "break-words"
898
+ }, He = {
899
+ key: 1,
900
+ class: "text-body-small italic text-on-surface-variant"
901
+ }, Ue = /* @__PURE__ */ x({
902
+ __name: "MMapFeatureInfo",
903
+ props: { results: {} },
904
+ setup(e) {
905
+ let t = o();
906
+ return (n, r) => (j(), g("div", Fe, [(j(!0), g(d, null, F(e.results, (e, r) => (j(), g("div", {
907
+ key: r,
908
+ class: "overflow-hidden rounded-2xl bg-surface-container"
909
+ }, [_("div", Ie, [b(u, {
910
+ name: "layers",
911
+ size: 16,
912
+ class: "text-on-primary-container"
913
+ }), _("span", Le, R(e.layer.title), 1)]), _("dl", Re, [(j(!0), g(d, null, F(e.fields, (r) => (j(), g("div", {
914
+ key: r.key,
915
+ class: "flex flex-col gap-0.5 border-b border-outline-variant py-1.5 last:border-b-0"
916
+ }, [_("dt", ze, R(r.label), 1), _("dd", Be, [I(n.$slots, "value", {
917
+ field: r,
918
+ result: e
919
+ }, () => [r.value ? (j(), g("span", Ve, R(r.value), 1)) : (j(), g("span", He, R(z(t).mapNoValue), 1))])])]))), 128))])]))), 128))]));
920
+ }
921
+ }), We = (e) => e.metadata, Ge = /* @__PURE__ */ new Set([
922
+ "fill",
923
+ "line",
924
+ "circle",
925
+ "symbol",
926
+ "fill-extrusion",
927
+ "heatmap"
928
+ ]), Ke = (e) => ({
929
+ title: e.name,
930
+ groups: [],
931
+ layers: e.layers.filter((e) => e.type !== "background").map((e) => ({
932
+ id: e.id,
933
+ title: We(e)?.title ?? e.id,
934
+ listed: !0,
935
+ children: [],
936
+ identify: Ge.has(e.type) ? {
937
+ format: {},
938
+ exclude: []
939
+ } : !1,
940
+ hover: !1
941
+ }))
942
+ });
943
+ function qe(e = {}) {
944
+ let t = e.legend ?? ((e, t) => {
945
+ let n = We(e)?.legend;
946
+ if (n?.show === !1) return;
947
+ if (n?.wmslegend) return n.wmslegend;
948
+ if (!t?.includes("/services/styles/")) return;
949
+ let r = t.replace("/services/styles/", "/services/legends/");
950
+ return `${r}${r.includes("?") ? "&" : "?"}has_label=false&include_raster=true&layer_id=${encodeURIComponent(e.id)}`;
951
+ });
952
+ return (e, { styleUrl: n }) => {
953
+ let r = e.metadata?.groups ?? [];
954
+ return {
955
+ title: e.name,
956
+ groups: r.map((e) => ({
957
+ name: e.name,
958
+ title: e.alias ?? e.name
959
+ })),
960
+ layers: e.layers.filter((e) => e.type !== "background").map((e) => {
961
+ let r = We(e) ?? {}, i = { ...r.fields }, a = i.exclude ?? [];
962
+ delete i.exclude;
963
+ let o = {};
964
+ for (let [e, t] of Object.entries(i)) o[e] = {
965
+ label: t.alias,
966
+ prefix: t.prefix,
967
+ suffix: t.suffix,
968
+ mask: t.mask,
969
+ hidden: t.show === !1
970
+ };
971
+ let s = r.hover, c = e.type === "raster" && r.isbaselayer === !0;
972
+ return {
973
+ id: e.id,
974
+ title: r.alias ?? e.id,
975
+ description: r.description,
976
+ group: r.group,
977
+ listed: !c && r.show_in_layerlist !== !1,
978
+ base: c && r.show_in_layerlist !== !1 ? { image: r.image } : void 0,
979
+ children: Array.isArray(r.childs) ? r.childs : [],
980
+ identify: r.identify === !0 && {
981
+ format: o,
982
+ exclude: a
983
+ },
984
+ hover: s?.enable ? { fields: (s.fields ?? []).flatMap((e) => Object.entries(e).map(([e, t]) => ({
985
+ key: e,
986
+ label: t.alias ?? t.label,
987
+ prefix: t.prefix,
988
+ suffix: t.suffix,
989
+ mask: t.mask
990
+ }))) } : !1,
991
+ legend: c ? void 0 : t(e, n),
992
+ download: e.type === "raster" ? void 0 : r.download
993
+ };
994
+ })
995
+ };
996
+ };
997
+ }
998
+ function Je(e, t) {
999
+ return t?.label ?? e.charAt(0).toUpperCase() + e.slice(1);
1000
+ }
1001
+ function Ye(e, t) {
1002
+ if (e == null || String(e).trim() === "") return "";
1003
+ let n = String(e), r = typeof e == "number" ? e : Number(e);
1004
+ if (t?.mask && !Number.isNaN(r)) {
1005
+ let e = t.mask.split(".")[1]?.length ?? 0, i = typeof document < "u" && document.documentElement.lang || void 0;
1006
+ n = new Intl.NumberFormat(i, {
1007
+ minimumFractionDigits: e,
1008
+ maximumFractionDigits: e,
1009
+ useGrouping: t.mask.includes(",")
1010
+ }).format(r);
1011
+ }
1012
+ return t?.prefix && (n = `${t.prefix} ${n}`), t?.suffix && (n = `${n} ${t.suffix}`), n;
1013
+ }
1014
+ var Xe = /* @__PURE__ */ new Set([
1015
+ "coordinates",
1016
+ "mapCoordinates",
1017
+ "layerId",
1018
+ "__layerMetadata"
1019
+ ]);
1020
+ function Ze(e, t, n) {
1021
+ let r = new Map((n?.layers ?? []).filter((t) => t.identify && e.getLayer(t.id)).map((e) => [e.id, e]));
1022
+ if (!r.size) return [];
1023
+ let i = [];
1024
+ for (let n of e.queryRenderedFeatures(t, { layers: [...r.keys()] })) {
1025
+ let e = r.get(n.layer.id);
1026
+ if (!e || !e.identify) continue;
1027
+ let { format: t, exclude: a } = e.identify, o = Object.entries(n.properties ?? {}).filter(([e]) => !Xe.has(e) && !a.includes(e) && !t[e]?.hidden).map(([e, n]) => ({
1028
+ key: e,
1029
+ label: Je(e, t[e]),
1030
+ value: Ye(n, t[e])
1031
+ }));
1032
+ o.length && i.push({
1033
+ layer: e,
1034
+ feature: n,
1035
+ fields: o
1036
+ });
1037
+ }
1038
+ return i;
1039
+ }
1040
+ //#endregion
1041
+ //#region src/components/MMapIdentify.vue?vue&type=script&setup=true&lang.ts
1042
+ var Qe = { class: "hidden" }, $e = /* @__PURE__ */ x({
1043
+ inheritAttrs: !1,
1044
+ __name: "MMapIdentify",
1045
+ props: {
1046
+ enabled: {
1047
+ type: Boolean,
1048
+ default: !0
1049
+ },
1050
+ popup: {
1051
+ type: Boolean,
1052
+ default: !0
1053
+ },
1054
+ marker: {
1055
+ type: Boolean,
1056
+ default: !0
1057
+ }
1058
+ },
1059
+ emits: ["identify"],
1060
+ setup(e, { expose: t, emit: n }) {
1061
+ let r = e, i = n, { on: a, onReady: o, activeTool: s } = G(), { model: c } = q(), l = L([]), u = P([0, 0]), d = P(!1);
1062
+ a("click", (e) => {
1063
+ if (!r.enabled || s.value) return;
1064
+ let t = e.target;
1065
+ l.value = Ze(t, e.point, c.value), u.value = [e.lngLat.lng, e.lngLat.lat], d.value = l.value.length > 0, i("identify", l.value, u.value);
1066
+ });
1067
+ function f() {
1068
+ d.value = !1;
1069
+ }
1070
+ H(() => r.enabled, (e) => {
1071
+ e || f();
1072
+ });
1073
+ let p, v = [], y = () => {
1074
+ r.enabled && !s.value && p && (p.getCanvas().style.cursor = "pointer");
1075
+ }, x = () => {
1076
+ p && (p.getCanvas().style.cursor = "");
1077
+ };
1078
+ function S() {
1079
+ if (p) {
1080
+ for (let e of v) p.off("mouseenter", e, y), p.off("mouseleave", e, x);
1081
+ v = (c.value?.layers ?? []).filter((e) => e.identify).map((e) => e.id);
1082
+ for (let e of v) p.on("mouseenter", e, y), p.on("mouseleave", e, x);
1083
+ }
1084
+ }
1085
+ return o((e) => {
1086
+ p = e, S();
1087
+ }), H(c, S), O(() => {
1088
+ v.forEach((e) => {
1089
+ p?.off("mouseenter", e, y), p?.off("mouseleave", e, x);
1090
+ });
1091
+ }), t({ close: f }), (t, n) => (j(), g("div", Qe, [e.marker && d.value ? (j(), m(ae, {
1092
+ key: 0,
1093
+ "lng-lat": u.value
1094
+ }, null, 8, ["lng-lat"])) : h("", !0), e.popup && l.value.length ? (j(), m(Y, {
1095
+ key: 1,
1096
+ open: d.value,
1097
+ "onUpdate:open": n[0] ||= (e) => d.value = e,
1098
+ "lng-lat": u.value,
1099
+ "max-width": "360px",
1100
+ offset: e.marker ? 40 : 8
1101
+ }, {
1102
+ default: U(() => [_("div", T({ class: "max-h-80 overflow-y-auto" }, t.$attrs), [I(t.$slots, "default", {
1103
+ results: l.value,
1104
+ lngLat: u.value,
1105
+ close: f
1106
+ }, () => [b(Ue, { results: l.value }, null, 8, ["results"])])], 16)]),
1107
+ _: 3
1108
+ }, 8, [
1109
+ "open",
1110
+ "lng-lat",
1111
+ "offset"
1112
+ ])) : h("", !0)]));
1113
+ }
1114
+ }), et = { class: "hidden" }, tt = [
1115
+ "title",
1116
+ "aria-label",
1117
+ "aria-pressed"
1118
+ ], nt = { class: "-mx-4 -mt-3 mb-1 bg-primary-container px-3 py-1.5 text-label-medium text-on-primary-container" }, rt = { class: "flex flex-col" }, it = { class: "text-label-small text-on-surface-variant" }, at = { class: "text-body-small text-on-surface" }, ot = /* @__PURE__ */ x({
1119
+ __name: "MMapHover",
1120
+ props: {
1121
+ modelValue: {
1122
+ type: Boolean,
1123
+ default: !1
1124
+ },
1125
+ control: {
1126
+ type: [Boolean, String],
1127
+ default: !0
1128
+ }
1129
+ },
1130
+ emits: ["update:modelValue"],
1131
+ setup(e, { emit: t }) {
1132
+ let n = e, r = t, i = o(), { onReady: a } = G(), { model: s } = q(), c = p(() => (s.value?.layers ?? []).filter((e) => e.hover && e.hover.fields.length)), l = L(null), f = P([0, 0]), v = P(!1), y, x = [];
1133
+ function S(e) {
1134
+ let t = e.features?.[0], n = c.value.find((e) => e.id === t?.layer.id);
1135
+ if (!t || !n || !n.hover) return;
1136
+ let r = t.properties ?? {};
1137
+ l.value = {
1138
+ layer: n,
1139
+ fields: n.hover.fields.map((e) => ({
1140
+ key: e.key,
1141
+ label: Je(e.key, e),
1142
+ value: Ye(r[e.key], e)
1143
+ })).filter((e) => e.value)
1144
+ }, f.value = [e.lngLat.lng, e.lngLat.lat], v.value = !0;
1145
+ }
1146
+ function C() {
1147
+ v.value = !1;
1148
+ }
1149
+ function w() {
1150
+ if (y) {
1151
+ for (let e of x) y.off("mousemove", e, S), y.off("mouseleave", e, C);
1152
+ x = n.modelValue ? c.value.map((e) => e.id) : [];
1153
+ for (let e of x) y.on("mousemove", e, S), y.on("mouseleave", e, C);
1154
+ n.modelValue || (v.value = !1);
1155
+ }
1156
+ }
1157
+ a((e) => {
1158
+ y = e, w();
1159
+ }), H([() => n.modelValue, c], w), O(() => {
1160
+ for (let e of x) y?.off("mousemove", e, S), y?.off("mouseleave", e, C);
1161
+ });
1162
+ let T = p(() => n.control === !0 ? "top-right" : n.control || "top-right");
1163
+ return (t, n) => (j(), g("div", et, [e.control && c.value.length ? (j(), m(le, {
1164
+ key: 0,
1165
+ position: T.value
1166
+ }, {
1167
+ default: U(() => [_("button", {
1168
+ type: "button",
1169
+ class: "grid place-items-center",
1170
+ title: z(i).mapHoverInfo,
1171
+ "aria-label": z(i).mapHoverInfo,
1172
+ "aria-pressed": e.modelValue,
1173
+ onClick: n[0] ||= (t) => r("update:modelValue", !e.modelValue)
1174
+ }, [b(u, {
1175
+ name: "ads_click",
1176
+ size: 20
1177
+ })], 8, tt)]),
1178
+ _: 1
1179
+ }, 8, ["position"])) : h("", !0), l.value ? (j(), m(Y, {
1180
+ key: 1,
1181
+ open: v.value,
1182
+ "onUpdate:open": n[1] ||= (e) => v.value = e,
1183
+ "lng-lat": f.value,
1184
+ "close-button": !1,
1185
+ "close-on-click": !1,
1186
+ offset: 12,
1187
+ "max-width": "280px",
1188
+ class: "m3-map-hover"
1189
+ }, {
1190
+ default: U(() => [_("p", nt, R(l.value.layer.title), 1), _("dl", rt, [(j(!0), g(d, null, F(l.value.fields, (e) => (j(), g("div", {
1191
+ key: e.key,
1192
+ class: "border-b border-outline-variant py-1 last:border-b-0"
1193
+ }, [_("dt", it, R(e.label), 1), _("dd", at, R(e.value), 1)]))), 128))])]),
1194
+ _: 1
1195
+ }, 8, ["open", "lng-lat"])) : h("", !0)]));
1196
+ }
1197
+ }), st = 6371008.8, $ = Math.PI / 180;
1198
+ function ct(e, t) {
1199
+ let n = (t[1] - e[1]) * $, r = (t[0] - e[0]) * $, i = Math.sin(n / 2) ** 2 + Math.cos(e[1] * $) * Math.cos(t[1] * $) * Math.sin(r / 2) ** 2;
1200
+ return 2 * st * Math.asin(Math.min(1, Math.sqrt(i)));
1201
+ }
1202
+ function lt(e) {
1203
+ let t = 0;
1204
+ for (let n = 1; n < e.length; n++) t += ct(e[n - 1], e[n]);
1205
+ return t;
1206
+ }
1207
+ function ut(e, t) {
1208
+ let [n, r, i, a] = [
1209
+ e[0] * $,
1210
+ e[1] * $,
1211
+ t[0] * $,
1212
+ t[1] * $
1213
+ ], o = Math.cos(a) * Math.cos(i - n), s = Math.cos(a) * Math.sin(i - n), c = Math.atan2(Math.sin(r) + Math.sin(a), Math.sqrt((Math.cos(r) + o) ** 2 + s ** 2));
1214
+ return [(n + Math.atan2(s, Math.cos(r) + o)) / $, c / $];
1215
+ }
1216
+ function dt(e) {
1217
+ let t = ft(e), n = t.length - 1;
1218
+ if (n <= 2) return 0;
1219
+ let r = 0;
1220
+ for (let e = 0; e < n; e++) {
1221
+ let i = t[e], a = t[e + 1 === n ? 0 : e + 1], o = t[e + 2 >= n ? (e + 2) % n : e + 2];
1222
+ r += (o[0] - i[0]) * $ * Math.sin(a[1] * $);
1223
+ }
1224
+ return Math.abs(r * st * st / 2);
1225
+ }
1226
+ function ft(e) {
1227
+ let t = e[0], n = e[e.length - 1];
1228
+ return t && n && (t[0] !== n[0] || t[1] !== n[1]) ? [...e, t] : e;
1229
+ }
1230
+ function pt(e) {
1231
+ let t = ft(e), n = 0, r = 0, i = 0;
1232
+ for (let e = 0; e < t.length - 1; e++) {
1233
+ let [a, o] = t[e], [s, c] = t[e + 1], l = a * c - s * o;
1234
+ n += l, r += (a + s) * l, i += (o + c) * l;
1235
+ }
1236
+ if (Math.abs(n) < 1e-12) {
1237
+ let e = t.slice(0, -1);
1238
+ return [e.reduce((e, t) => e + t[0], 0) / e.length, e.reduce((e, t) => e + t[1], 0) / e.length];
1239
+ }
1240
+ return [r / (3 * n), i / (3 * n)];
1241
+ }
1242
+ //#endregion
1243
+ //#region src/components/MMapMeasure.vue?vue&type=script&setup=true&lang.ts
1244
+ var mt = { class: "hidden" }, ht = ["title", "aria-pressed"], gt = ["title", "aria-pressed"], _t = ["title", "disabled"], vt = [
1245
+ "aria-label",
1246
+ "title",
1247
+ "onClick"
1248
+ ], yt = /* @__PURE__ */ x({
1249
+ __name: "MMapMeasure",
1250
+ props: {
1251
+ modelValue: { default: null },
1252
+ control: {
1253
+ type: [Boolean, String],
1254
+ default: !0
1255
+ }
1256
+ },
1257
+ emits: ["update:modelValue", "change"],
1258
+ setup(e, { expose: t, emit: n }) {
1259
+ let r = e, i = n, a = o(), { onReady: s, styleVersion: c, activeTool: l } = G(), f = X(["primary", "surface"]), v = `m3-measure-${B()}`, x = {
1260
+ done: `${v}-done`,
1261
+ draft: `${v}-draft`,
1262
+ handles: `${v}-handles`
1263
+ }, S = `${x.handles}-vertex`, C = `${x.handles}-midpoint`, w = [], T = [], D = null, k = !1, A = null, M = 0, N, I = P(null), V = P(0), ee = L([]), te = () => typeof document < "u" && document.documentElement.lang || void 0, K = (e, t) => new Intl.NumberFormat(te(), {
1264
+ minimumFractionDigits: t,
1265
+ maximumFractionDigits: t
1266
+ }).format(e), ne = (e) => e === 0 ? "" : e < 1e3 ? `${K(Math.round(e), 0)} m` : `${K(e / 1e3, 2)} km`, q = (e) => e >= 1e6 ? `${K(e / 1e6, 2)} km²` : e >= 1e4 ? `${K(e / 1e4, 2)} ha` : `${K(Math.round(e), 0)} m²`, re = (e, t = {}) => ({
1267
+ type: "Feature",
1268
+ geometry: {
1269
+ type: "Point",
1270
+ coordinates: e
1271
+ },
1272
+ properties: t
1273
+ });
1274
+ function J(e, t, n, r) {
1275
+ let i = e.map((e) => re(e)), o = [];
1276
+ if (e.length < 2) return {
1277
+ features: i,
1278
+ labels: o
1279
+ };
1280
+ i.push({
1281
+ type: "Feature",
1282
+ geometry: {
1283
+ type: "LineString",
1284
+ coordinates: e
1285
+ },
1286
+ properties: {}
1287
+ });
1288
+ let s = (e) => {
1289
+ for (let t = 0; t < e.length - 1; t++) {
1290
+ let r = ne(ct(e[t], e[t + 1]));
1291
+ r && o.push({
1292
+ key: `${n}-s${t}`,
1293
+ at: ut(e[t], e[t + 1]),
1294
+ text: r,
1295
+ kind: "segment"
1296
+ });
1297
+ }
1298
+ };
1299
+ if (t === "distance") s(e), o.push({
1300
+ key: `${n}-t`,
1301
+ at: e[e.length - 1],
1302
+ text: `${a.mapTotal}: ${ne(lt(e))}`,
1303
+ kind: "total",
1304
+ m: r
1305
+ });
1306
+ else if (e.length >= 3) {
1307
+ let t = ft(e);
1308
+ i.push({
1309
+ type: "Feature",
1310
+ geometry: {
1311
+ type: "Polygon",
1312
+ coordinates: [t]
1313
+ },
1314
+ properties: {}
1315
+ }), s(t), o.push({
1316
+ key: `${n}-a`,
1317
+ at: pt(t),
1318
+ text: q(dt(t)),
1319
+ kind: "area",
1320
+ m: r
1321
+ });
1322
+ } else o.push({
1323
+ key: `${n}-t`,
1324
+ at: e[e.length - 1],
1325
+ text: ne(lt(e)),
1326
+ kind: "total",
1327
+ m: r
1328
+ });
1329
+ return {
1330
+ features: i,
1331
+ labels: o
1332
+ };
1333
+ }
1334
+ let ie = (e) => ({
1335
+ type: "FeatureCollection",
1336
+ features: e
1337
+ }), oe = (e, t) => (N?.getSource(e))?.setData(ie(t));
1338
+ function Y() {
1339
+ if (!N) return;
1340
+ let e = w.map((e, t) => J(e.points, e.mode, `m${t}`, t)), t = I.value && T.length ? J(D ? [...T, D] : T, I.value, "draft") : {
1341
+ features: [],
1342
+ labels: []
1343
+ };
1344
+ oe(x.done, e.flatMap((e) => e.features)), oe(x.draft, t.features);
1345
+ let n = [];
1346
+ I.value || w.forEach((e, t) => {
1347
+ (e.closed ? e.points.slice(0, -1) : e.points).forEach((e, r) => n.push(re(e, {
1348
+ handle: "vertex",
1349
+ m: t,
1350
+ v: r
1351
+ })));
1352
+ for (let r = 0; r < e.points.length - 1; r++) n.push(re(ut(e.points[r], e.points[r + 1]), {
1353
+ handle: "midpoint",
1354
+ m: t,
1355
+ after: r
1356
+ }));
1357
+ }), oe(x.handles, n), ee.value = [...e.flatMap((e) => e.labels), ...t.labels];
1358
+ }
1359
+ function se() {
1360
+ V.value = w.length, i("change", w.map((e) => ({
1361
+ mode: e.mode,
1362
+ points: e.points.map((e) => [...e]),
1363
+ closed: e.closed,
1364
+ length: lt(e.points),
1365
+ ...e.mode === "area" || e.closed ? { area: dt(e.points) } : {}
1366
+ })));
1367
+ }
1368
+ let ce = (e) => [
1369
+ "==",
1370
+ ["geometry-type"],
1371
+ e
1372
+ ];
1373
+ function ue() {
1374
+ let { primary: e, surface: t } = f.value;
1375
+ return {
1376
+ fill: { "fill-color": e },
1377
+ line: { "line-color": e },
1378
+ vertices: {
1379
+ "circle-color": t,
1380
+ "circle-stroke-color": e
1381
+ }
1382
+ };
1383
+ }
1384
+ function de() {
1385
+ if (!N) return;
1386
+ for (let e of Object.values(x)) N.getSource(e) || N.addSource(e, {
1387
+ type: "geojson",
1388
+ data: ie([])
1389
+ });
1390
+ let e = ue(), t = (e) => {
1391
+ N.getLayer(e.id) || N.addLayer(e);
1392
+ };
1393
+ for (let [n, r] of [[x.done, !1], [x.draft, !0]]) t({
1394
+ id: `${n}-fill`,
1395
+ type: "fill",
1396
+ source: n,
1397
+ filter: ce("Polygon"),
1398
+ paint: {
1399
+ ...e.fill,
1400
+ "fill-opacity": r ? .15 : .2
1401
+ }
1402
+ }), t({
1403
+ id: `${n}-line`,
1404
+ type: "line",
1405
+ source: n,
1406
+ filter: [
1407
+ "!=",
1408
+ ["geometry-type"],
1409
+ "Point"
1410
+ ],
1411
+ paint: {
1412
+ ...e.line,
1413
+ "line-width": 3,
1414
+ ...r ? { "line-dasharray": [2, 2] } : {}
1415
+ }
1416
+ }), t({
1417
+ id: `${n}-points`,
1418
+ type: "circle",
1419
+ source: n,
1420
+ filter: ce("Point"),
1421
+ paint: {
1422
+ ...e.vertices,
1423
+ "circle-radius": 5,
1424
+ "circle-stroke-width": 2
1425
+ }
1426
+ });
1427
+ t({
1428
+ id: C,
1429
+ type: "circle",
1430
+ source: x.handles,
1431
+ filter: [
1432
+ "==",
1433
+ ["get", "handle"],
1434
+ "midpoint"
1435
+ ],
1436
+ paint: {
1437
+ ...e.vertices,
1438
+ "circle-radius": 4,
1439
+ "circle-stroke-width": 1.5,
1440
+ "circle-opacity": .7
1441
+ }
1442
+ }), t({
1443
+ id: S,
1444
+ type: "circle",
1445
+ source: x.handles,
1446
+ filter: [
1447
+ "==",
1448
+ ["get", "handle"],
1449
+ "vertex"
1450
+ ],
1451
+ paint: {
1452
+ ...e.vertices,
1453
+ "circle-radius": 7,
1454
+ "circle-stroke-width": 2.5
1455
+ }
1456
+ });
1457
+ }
1458
+ H(f, () => {
1459
+ if (!N) return;
1460
+ let e = ue(), t = (e, t) => {
1461
+ if (N.getLayer(e)) for (let [n, r] of Object.entries(t)) N.setPaintProperty(e, n, r);
1462
+ };
1463
+ for (let n of [x.done, x.draft]) t(`${n}-fill`, e.fill), t(`${n}-line`, e.line), t(`${n}-points`, e.vertices);
1464
+ t(C, e.vertices), t(S, e.vertices);
1465
+ });
1466
+ let fe = (e) => [e.lngLat.lng, e.lngLat.lat];
1467
+ function pe(e) {
1468
+ if (T.length >= 2) {
1469
+ let t = N.project(T[0]);
1470
+ if (Math.hypot(t.x - e.point.x, t.y - e.point.y) < 20) {
1471
+ k = !0, Q();
1472
+ return;
1473
+ }
1474
+ }
1475
+ T.push(fe(e)), Y();
1476
+ }
1477
+ function me(e) {
1478
+ D = fe(e), !M && (M = requestAnimationFrame(() => {
1479
+ M = 0, Y();
1480
+ }));
1481
+ }
1482
+ function he(e) {
1483
+ if (e.preventDefault(), T.length < 2) return;
1484
+ let t = N.project(T[T.length - 1]), n = N.project(T[T.length - 2]);
1485
+ Math.hypot(t.x - n.x, t.y - n.y) < 10 && T.pop(), Q();
1486
+ }
1487
+ function ge(e) {
1488
+ (e.key === "Escape" || e.key === "Enter") && Q(e.key === "Escape");
1489
+ }
1490
+ let _e = () => typeof navigator < "u" ? navigator.keyboard : void 0, ve = !1;
1491
+ function ye() {
1492
+ I.value && document.fullscreenElement && _e()?.lock && _e().lock(["Escape"]).then(() => {
1493
+ ve = !0;
1494
+ }, () => {});
1495
+ }
1496
+ function be() {
1497
+ I.value || (ve && _e()?.unlock?.(), ve = !1);
1498
+ }
1499
+ function xe() {
1500
+ let e, t = () => {
1501
+ document.removeEventListener("keyup", n, !0), clearTimeout(e), setTimeout(be);
1502
+ }, n = (e) => {
1503
+ e.key === "Escape" && t();
1504
+ };
1505
+ document.addEventListener("keyup", n, !0), e = setTimeout(t, 1500);
1506
+ }
1507
+ function Z(e) {
1508
+ if (N) {
1509
+ if (I.value === e) return Q();
1510
+ I.value && Q(), I.value = e, l.value = "measure", T = [], D = null, N.getCanvas().style.cursor = "crosshair", N.doubleClickZoom.disable(), N.on("click", pe), N.on("mousemove", me), N.on("dblclick", he), document.addEventListener("keydown", ge), document.addEventListener("fullscreenchange", ye), ye(), Y(), r.modelValue !== e && i("update:modelValue", e);
1511
+ }
1512
+ }
1513
+ function Q(e = !1) {
1514
+ if (!N || !I.value) return;
1515
+ cancelAnimationFrame(M), M = 0;
1516
+ let t = T.length >= 3 && (k || I.value === "area");
1517
+ T.length >= 2 && w.push({
1518
+ mode: I.value,
1519
+ points: t ? [...T, [...T[0]]] : T,
1520
+ closed: t
1521
+ }), T = [], D = null, k = !1, I.value = null, l.value === "measure" && (l.value = null), N.getCanvas().style.cursor = "", N.doubleClickZoom.enable(), N.off("click", pe), N.off("mousemove", me), N.off("dblclick", he), document.removeEventListener("keydown", ge), document.removeEventListener("fullscreenchange", ye), e && ve ? xe() : be(), Y(), se(), r.modelValue !== null && i("update:modelValue", null);
1522
+ }
1523
+ function Se(e) {
1524
+ w[e] && (w.splice(e, 1), Y(), se());
1525
+ }
1526
+ function Ce() {
1527
+ I.value && Q(), w.length = 0, Y(), se();
1528
+ }
1529
+ function we(e) {
1530
+ let t = e.features?.[0];
1531
+ if (!t || I.value || !N) return;
1532
+ e.preventDefault();
1533
+ let n = t.properties.m, r = w[n];
1534
+ if (!r) return;
1535
+ let i = t.properties.v;
1536
+ t.properties.handle === "midpoint" && (i = t.properties.after + 1, r.points.splice(i, 0, fe(e))), A = {
1537
+ m: n,
1538
+ v: i
1539
+ }, l.value = "measure", N.getCanvas().style.cursor = "grabbing";
1540
+ let a = e.type === "touchstart";
1541
+ a && N.dragPan.disable(), N.on(a ? "touchmove" : "mousemove", Te), N.once(a ? "touchend" : "mouseup", Ee), Y();
1542
+ }
1543
+ function Te(e) {
1544
+ if (!A) return;
1545
+ let t = w[A.m];
1546
+ if (!t) return;
1547
+ let n = fe(e);
1548
+ t.points[A.v] = n, t.closed && A.v === 0 && (t.points[t.points.length - 1] = n), Y();
1549
+ }
1550
+ function Ee() {
1551
+ N && (A = null, N.off("mousemove", Te), N.off("touchmove", Te), N.dragPan.enable(), N.getCanvas().style.cursor = "", se(), setTimeout(() => {
1552
+ l.value === "measure" && !I.value && (l.value = null);
1553
+ }));
1554
+ }
1555
+ let De = () => {
1556
+ N && !A && !I.value && (N.getCanvas().style.cursor = "grab");
1557
+ }, Oe = () => {
1558
+ N && !A && !I.value && (N.getCanvas().style.cursor = "");
1559
+ };
1560
+ s((e) => {
1561
+ N = e, de();
1562
+ for (let t of [S, C]) e.on("mousedown", t, we), e.on("touchstart", t, we), e.on("mouseenter", t, De), e.on("mouseleave", t, Oe);
1563
+ r.modelValue && Z(r.modelValue);
1564
+ }), H(c, () => {
1565
+ de(), Y();
1566
+ }), H(() => r.modelValue, (e) => {
1567
+ e && e !== I.value ? Z(e) : !e && I.value && Q();
1568
+ }), O(() => {
1569
+ if (!N) return;
1570
+ I.value && Q();
1571
+ for (let e of [S, C]) N.off("mousedown", e, we), N.off("touchstart", e, we), N.off("mouseenter", e, De), N.off("mouseleave", e, Oe);
1572
+ let e = [
1573
+ S,
1574
+ C,
1575
+ ...[x.done, x.draft].flatMap((e) => [
1576
+ `${e}-points`,
1577
+ `${e}-line`,
1578
+ `${e}-fill`
1579
+ ])
1580
+ ];
1581
+ for (let t of e) N.getLayer(t) && N.removeLayer(t);
1582
+ for (let e of Object.values(x)) N.getSource(e) && N.removeSource(e);
1583
+ });
1584
+ let ke = p(() => r.control === !0 ? "top-right" : r.control || "top-right");
1585
+ return t({
1586
+ start: Z,
1587
+ finish: Q,
1588
+ clear: Ce,
1589
+ remove: Se
1590
+ }), (t, n) => (j(), g("div", mt, [e.control ? (j(), m(le, {
1591
+ key: 0,
1592
+ position: ke.value
1593
+ }, {
1594
+ default: U(() => [
1595
+ _("button", {
1596
+ type: "button",
1597
+ class: "grid place-items-center",
1598
+ title: z(a).mapMeasureDistance,
1599
+ "aria-pressed": I.value === "distance",
1600
+ onClick: n[0] ||= (e) => Z("distance")
1601
+ }, [b(u, {
1602
+ name: "straighten",
1603
+ size: 20
1604
+ })], 8, ht),
1605
+ _("button", {
1606
+ type: "button",
1607
+ class: "grid place-items-center",
1608
+ title: z(a).mapMeasureArea,
1609
+ "aria-pressed": I.value === "area",
1610
+ onClick: n[1] ||= (e) => Z("area")
1611
+ }, [b(u, {
1612
+ name: "pentagon",
1613
+ size: 20
1614
+ })], 8, gt),
1615
+ _("button", {
1616
+ type: "button",
1617
+ class: "grid place-items-center",
1618
+ title: z(a).mapClearMeasurements,
1619
+ disabled: !V.value && !I.value,
1620
+ onClick: Ce
1621
+ }, [b(u, {
1622
+ name: "delete",
1623
+ size: 20
1624
+ })], 8, _t)
1625
+ ]),
1626
+ _: 1
1627
+ }, 8, ["position"])) : h("", !0), (j(!0), g(d, null, F(ee.value, (e) => (j(), m(ae, {
1628
+ key: e.key,
1629
+ "lng-lat": e.at,
1630
+ anchor: e.kind === "area" ? "center" : "top",
1631
+ offset: e.kind === "area" ? [0, 0] : [0, 8],
1632
+ class: "pointer-events-none"
1633
+ }, {
1634
+ default: U(() => [_("span", { class: E(["flex items-center gap-1 whitespace-nowrap rounded-full py-0.5 shadow-elevation-1", [e.kind === "segment" ? "bg-surface-container-highest text-label-small text-on-surface" : "bg-primary text-label-medium text-on-primary", e.m === void 0 ? "px-2" : "pr-0.5 pl-2"]]) }, [y(R(e.text) + " ", 1), e.m === void 0 ? h("", !0) : (j(), g("button", {
1635
+ key: 0,
1636
+ type: "button",
1637
+ 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",
1638
+ "aria-label": z(a).mapDeleteMeasurement,
1639
+ title: z(a).mapDeleteMeasurement,
1640
+ onClick: W((t) => Se(e.m), ["stop"]),
1641
+ onPointerdown: n[2] ||= W(() => {}, ["stop"]),
1642
+ onMousedown: n[3] ||= W(() => {}, ["stop"]),
1643
+ onTouchstart: n[4] ||= W(() => {}, ["stop"]),
1644
+ onDblclick: n[5] ||= W(() => {}, ["stop"])
1645
+ }, [b(u, {
1646
+ name: "close",
1647
+ size: 14
1648
+ })], 40, vt))], 2)]),
1649
+ _: 2
1650
+ }, 1032, [
1651
+ "lng-lat",
1652
+ "anchor",
1653
+ "offset"
1654
+ ]))), 128))]));
1655
+ }
1656
+ }), bt = /* @__PURE__ */ new WeakMap();
1657
+ function xt() {
1658
+ let e = C(ee, null);
1659
+ if (!e) throw Error("useMapFilter() must be called in a component inside <MMap>");
1660
+ function t(t, n) {
1661
+ let r = e.map.value;
1662
+ if (!r?.getLayer(t)) return;
1663
+ let i = bt.get(r);
1664
+ i || bt.set(r, i = /* @__PURE__ */ new Map()), i.has(t) || i.set(t, r.getFilter(t) ?? void 0);
1665
+ let a = i.get(t);
1666
+ r.setFilter(t, n ? a ? [
1667
+ "all",
1668
+ a,
1669
+ n
1670
+ ] : n : a ?? null);
1671
+ }
1672
+ function n(t, n) {
1673
+ let r = e.map.value, i = r?.getLayer(t);
1674
+ if (!r || !i?.source) return [];
1675
+ let a = r.querySourceFeatures(i.source, i.sourceLayer ? { sourceLayer: i.sourceLayer } : void 0), o = /* @__PURE__ */ new Set();
1676
+ for (let e of a) {
1677
+ let t = e.properties?.[n];
1678
+ (typeof t == "string" || typeof t == "number") && o.add(t);
1679
+ }
1680
+ return [...o].sort((e, t) => typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t)));
1681
+ }
1682
+ return {
1683
+ setFilter: t,
1684
+ valuesOf: n
1685
+ };
1686
+ }
1687
+ //#endregion
1688
+ //#region src/components/MMapFilter.vue?vue&type=script&setup=true&lang.ts
1689
+ var St = { class: "flex flex-wrap gap-2" }, Ct = /* @__PURE__ */ x({
1690
+ __name: "MMapFilter",
1691
+ props: {
1692
+ layer: {},
1693
+ property: {},
1694
+ values: {},
1695
+ labels: {},
1696
+ modelValue: {}
1697
+ },
1698
+ emits: ["update:modelValue"],
1699
+ setup(t, { emit: n }) {
1700
+ let r = t, i = n, { onReady: a, styleVersion: o } = G(), { setFilter: s, valuesOf: c } = xt(), l = P([]), u = p(() => r.values ?? l.value), f = P([]), h = p(() => r.modelValue ?? f.value);
1701
+ function _() {
1702
+ let e = h.value;
1703
+ s(r.layer, e.length ? [
1704
+ "in",
1705
+ ["get", r.property],
1706
+ ["literal", e]
1707
+ ] : null);
1708
+ }
1709
+ function v(e) {
1710
+ let t = h.value.includes(e) ? h.value.filter((t) => t !== e) : [...h.value, e];
1711
+ f.value = t, i("update:modelValue", t);
1712
+ }
1713
+ function b(e) {
1714
+ let t = () => {
1715
+ r.values || (l.value = c(r.layer, r.property));
1716
+ };
1717
+ t(), e.once("idle", t);
1718
+ }
1719
+ return a((e) => {
1720
+ b(e), _();
1721
+ }), H(h, _, { deep: !0 }), H(o, () => _()), H(() => [r.layer, r.property], ([e], [t]) => {
1722
+ e !== t && s(t, null), _();
1723
+ }), O(() => s(r.layer, null)), (n, r) => (j(), g("div", St, [(j(!0), g(d, null, F(u.value, (n) => (j(), m(e, {
1724
+ key: n,
1725
+ type: "filter",
1726
+ clickable: "",
1727
+ selected: h.value.includes(n),
1728
+ onClick: (e) => v(n)
1729
+ }, {
1730
+ default: U(() => [y(R(t.labels?.[String(n)] ?? n), 1)]),
1731
+ _: 2
1732
+ }, 1032, ["selected", "onClick"]))), 128))]));
1733
+ }
1734
+ });
1735
+ //#endregion
1736
+ //#region src/composables/mapSearch.ts
1737
+ function wt(e = {}) {
1738
+ return async (t, n) => {
1739
+ let r = new URLSearchParams({
1740
+ format: "jsonv2",
1741
+ q: t,
1742
+ limit: String(e.limit ?? 6)
1743
+ }), i = e.language ?? (typeof document < "u" ? document.documentElement.lang : "");
1744
+ i && r.set("accept-language", i), e.countryCodes?.length && r.set("countrycodes", e.countryCodes.join(",")), e.viewbox && r.set("viewbox", e.viewbox.join(",")), e.bounded && r.set("bounded", "1");
1745
+ let a = await fetch(`${e.url ?? "https://nominatim.openstreetmap.org"}/search?${r}`, { signal: n });
1746
+ if (!a.ok) throw Error(`Nominatim: ${a.status}`);
1747
+ return (await a.json()).map((e) => {
1748
+ let t = e.boundingbox?.map(Number);
1749
+ return {
1750
+ label: e.display_name,
1751
+ lngLat: [Number(e.lon), Number(e.lat)],
1752
+ bbox: t && t.length === 4 ? [
1753
+ t[2],
1754
+ t[0],
1755
+ t[3],
1756
+ t[1]
1757
+ ] : void 0,
1758
+ type: e.type
1759
+ };
1760
+ });
1761
+ };
1762
+ }
1763
+ //#endregion
1764
+ //#region src/components/MMapSearch.vue?vue&type=script&setup=true&lang.ts
1765
+ var Tt = { class: "hidden" }, Et = [
1766
+ "value",
1767
+ "placeholder",
1768
+ "aria-label"
1769
+ ], Dt = {
1770
+ key: 0,
1771
+ class: "border-t border-outline-variant"
1772
+ }, Ot = {
1773
+ key: 1,
1774
+ class: "flex flex-col items-center gap-2 py-6"
1775
+ }, kt = { class: "text-body-small text-on-surface-variant" }, At = /* @__PURE__ */ x({
1776
+ __name: "MMapSearch",
1777
+ props: {
1778
+ provider: {},
1779
+ position: { default: "top-left" },
1780
+ placeholder: {},
1781
+ zoom: { default: 17 },
1782
+ marker: {
1783
+ type: Boolean,
1784
+ default: !0
1785
+ },
1786
+ instant: {
1787
+ type: Boolean,
1788
+ default: !1
1789
+ }
1790
+ },
1791
+ emits: ["select"],
1792
+ setup(e, { emit: n }) {
1793
+ let a = e, l = n, f = o(), { map: v } = G(), y = p(() => a.provider ?? wt()), x = P(""), S = L([]), C = P(!1), w = P(!1), T = P(!1), E = L(null), D, k;
1794
+ async function A() {
1795
+ let e = x.value.trim();
1796
+ if (!e) return;
1797
+ D?.abort(), D = new AbortController();
1798
+ let t = D;
1799
+ C.value = !0, T.value = !0;
1800
+ try {
1801
+ S.value = await y.value(e, t.signal);
1802
+ } catch {
1803
+ if (t.signal.aborted) return;
1804
+ S.value = [];
1805
+ } finally {
1806
+ D === t && (C.value = !1, w.value = !0);
1807
+ }
1808
+ }
1809
+ function M(e) {
1810
+ if (x.value = e, !e) return I();
1811
+ a.instant && (clearTimeout(k), k = setTimeout(A, 350));
1812
+ }
1813
+ function N(e) {
1814
+ E.value = e, T.value = !1;
1815
+ let t = v.value;
1816
+ e.bbox && e.bbox[0] !== e.bbox[2] ? t?.fitBounds([[e.bbox[0], e.bbox[1]], [e.bbox[2], e.bbox[3]]], {
1817
+ padding: 48,
1818
+ maxZoom: a.zoom
1819
+ }) : t?.flyTo({
1820
+ center: e.lngLat,
1821
+ zoom: a.zoom
1822
+ }), l("select", e);
1823
+ }
1824
+ function I() {
1825
+ D?.abort(), clearTimeout(k), x.value = "", S.value = [], w.value = !1, C.value = !1, T.value = !1, E.value = null;
1826
+ }
1827
+ O(() => {
1828
+ D?.abort(), clearTimeout(k);
1829
+ });
1830
+ let B = {
1831
+ city: "location_city",
1832
+ town: "location_city",
1833
+ village: "holiday_village",
1834
+ hamlet: "cottage",
1835
+ suburb: "apartment",
1836
+ neighbourhood: "maps_home_work",
1837
+ road: "road",
1838
+ residential: "home",
1839
+ house: "home",
1840
+ building: "domain",
1841
+ shop: "storefront",
1842
+ park: "park",
1843
+ water: "water",
1844
+ river: "water",
1845
+ lake: "water",
1846
+ school: "school",
1847
+ university: "school",
1848
+ hospital: "local_hospital",
1849
+ restaurant: "restaurant",
1850
+ cafe: "local_cafe",
1851
+ hotel: "hotel",
1852
+ station: "train",
1853
+ bus_stop: "directions_bus",
1854
+ administrative: "map",
1855
+ country: "public",
1856
+ state: "map"
1857
+ }, V = (e) => e && B[e] || "location_on";
1858
+ return (n, a) => (j(), g("div", Tt, [b(le, {
1859
+ position: e.position,
1860
+ group: !1
1861
+ }, {
1862
+ default: U(() => [b(i, {
1863
+ variant: "elevated",
1864
+ class: "w-80 max-w-[calc(100vw-5rem)] overflow-hidden"
1865
+ }, {
1866
+ default: U(() => [_("form", {
1867
+ class: "flex items-center gap-2 py-1 pr-1 pl-3",
1868
+ role: "search",
1869
+ onSubmit: W(A, ["prevent"])
1870
+ }, [
1871
+ b(u, {
1872
+ name: "search",
1873
+ size: 20,
1874
+ class: "shrink-0 text-on-surface-variant"
1875
+ }),
1876
+ _("input", {
1877
+ value: x.value,
1878
+ type: "search",
1879
+ enterkeyhint: "search",
1880
+ placeholder: e.placeholder ?? z(f).mapSearchPlaces,
1881
+ "aria-label": e.placeholder ?? z(f).mapSearchPlaces,
1882
+ 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",
1883
+ onInput: a[0] ||= (e) => M(e.target.value),
1884
+ onFocus: a[1] ||= (e) => T.value = w.value && !E.value
1885
+ }, null, 40, Et),
1886
+ C.value ? (j(), m(s, {
1887
+ key: 0,
1888
+ size: 20,
1889
+ class: "mr-2 shrink-0"
1890
+ })) : x.value ? (j(), m(c, {
1891
+ key: 1,
1892
+ icon: "close",
1893
+ label: z(f).clearSearch,
1894
+ size: "sm",
1895
+ onClick: I
1896
+ }, null, 8, ["label"])) : h("", !0)
1897
+ ], 32), T.value && w.value && !C.value ? (j(), g("div", Dt, [S.value.length ? (j(), m(t, {
1898
+ key: 0,
1899
+ class: "max-h-72 overflow-y-auto"
1900
+ }, {
1901
+ default: U(() => [(j(!0), g(d, null, F(S.value, (e, t) => (j(), m(r, {
1902
+ key: t,
1903
+ title: e.label,
1904
+ icon: V(e.type),
1905
+ leading: "icon",
1906
+ clickable: "",
1907
+ onClick: (t) => N(e)
1908
+ }, null, 8, [
1909
+ "title",
1910
+ "icon",
1911
+ "onClick"
1912
+ ]))), 128))]),
1913
+ _: 1
1914
+ })) : (j(), g("div", Ot, [b(u, {
1915
+ name: "search_off",
1916
+ size: 28,
1917
+ class: "text-on-surface-variant"
1918
+ }), _("span", kt, R(z(f).noResults), 1)]))])) : h("", !0)]),
1919
+ _: 1
1920
+ })]),
1921
+ _: 1
1922
+ }, 8, ["position"]), e.marker && E.value ? (j(), m(ae, {
1923
+ key: 0,
1924
+ "lng-lat": E.value.lngLat
1925
+ }, null, 8, ["lng-lat"])) : h("", !0)]));
1926
+ }
1927
+ });
1928
+ //#endregion
1929
+ export { J as MMap, Pe as MMapBaseLayers, le as MMapControl, Ue as MMapFeatureInfo, Ct as MMapFilter, se as MMapGeoJson, ot as MMapHover, $e as MMapIdentify, Ae as MMapLayers, ae as MMapMarker, yt as MMapMeasure, Y as MMapPopup, At as MMapSearch, Je as fieldLabel, Ye as formatFieldValue, Ke as genericAdapter, Ze as identifyFeatures, wt as nominatimProvider, qe as orvianAdapter, G as useMap, xt as useMapFilter, q as useMapLayers };
1930
+
1931
+ //# sourceMappingURL=map.js.map