@edugis-org/webmapx 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +149 -0
  2. package/dist-lib/WMTS-DCN4zX0-.js +1169 -0
  3. package/dist-lib/alert-GeHlqlN8.js +310 -0
  4. package/dist-lib/assets/epsg-lookup.worker-J7TVnHDq.js +1 -0
  5. package/dist-lib/assets/shapefile.worker-kQfZj6G2.js +4 -0
  6. package/dist-lib/attribution-format-B4f05_u0.js +62 -0
  7. package/dist-lib/button-DFdGkRPQ.js +741 -0
  8. package/dist-lib/cesium-adapter-BHXNytkU.js +1488 -0
  9. package/dist-lib/checkbox-QoR4S8tV.js +284 -0
  10. package/dist-lib/chunk-HEgqtunE.js +20 -0
  11. package/dist-lib/chunk.36O46B5H-B6ZL7Sm1.js +77 -0
  12. package/dist-lib/chunk.3RPBFEDE-BFO1fHVm.js +138 -0
  13. package/dist-lib/chunk.5JY5FUCG-DTXsslmx.js +1090 -0
  14. package/dist-lib/chunk.6CTB5ZDJ-DjZrBd6Y.js +99 -0
  15. package/dist-lib/chunk.AJ3ENQ5C-Ci7Gm2b6.js +175 -0
  16. package/dist-lib/chunk.LD4M4QGE-CiCfhE8r.js +8 -0
  17. package/dist-lib/chunk.NYIIDP5N-BikXIStD.js +99 -0
  18. package/dist-lib/chunk.RWUUFNUL-DFztA4uV.js +43 -0
  19. package/dist-lib/chunk.SI4ACBFK-CLb9VfMG.js +61 -0
  20. package/dist-lib/chunk.YHLNUJ7P-D-kanrCf.js +503 -0
  21. package/dist-lib/core-CMAlSR68.js +22 -0
  22. package/dist-lib/decorate-CWgUV1hU.js +1139 -0
  23. package/dist-lib/decorators-B35AgiCU.js +351 -0
  24. package/dist-lib/deferred-query-service-BJDcngw6.js +386 -0
  25. package/dist-lib/dist-Dm6b7XCs.js +12318 -0
  26. package/dist-lib/dist-Ha9LQCut.js +244 -0
  27. package/dist-lib/dist-c1PlDAd1.js +2359 -0
  28. package/dist-lib/dist-kKlmcBXq.js +50 -0
  29. package/dist-lib/divider-CPm675yY.js +41 -0
  30. package/dist-lib/dropped-config-C_GyVa8o.js +17 -0
  31. package/dist-lib/dropped-layer-builder-DAaYgUPk.js +396 -0
  32. package/dist-lib/epsg-definitions-BZLZWa8Q.js +668 -0
  33. package/dist-lib/esm-CTuscnN5.js +46 -0
  34. package/dist-lib/file-sniff-Dhxj3KTF.js +251 -0
  35. package/dist-lib/geo-calculations-DbFJAUoI.js +30 -0
  36. package/dist-lib/icon-CEOgWlro.js +9 -0
  37. package/dist-lib/icon-button-Da_nBTy3.js +408 -0
  38. package/dist-lib/input-CeGntPlT.js +590 -0
  39. package/dist-lib/layer-discovery-afWzu5hY.js +2825 -0
  40. package/dist-lib/leaflet-adapter-D9djjrKv.js +1227 -0
  41. package/dist-lib/lib-CdHVicAE.js +4074 -0
  42. package/dist-lib/map-layer-registry-2cmkiRDK.js +62 -0
  43. package/dist-lib/maplibre-adapter-TFc3e0G9.js +1190 -0
  44. package/dist-lib/maplibre-expression-evaluator-DCWUcpwf.js +7233 -0
  45. package/dist-lib/marker-utils-DztWXeop.js +12 -0
  46. package/dist-lib/ol-tilegrid-9VtyxaLG.js +64 -0
  47. package/dist-lib/openlayers-adapter-DVW1KCRv.js +13307 -0
  48. package/dist-lib/option-CBxl1mZP.js +1106 -0
  49. package/dist-lib/papaparse.min-B7v3c0D7.js +501 -0
  50. package/dist-lib/rbush-C8k41T4z.js +254 -0
  51. package/dist-lib/shapefile-SawVY6xg.js +207 -0
  52. package/dist-lib/spinner-DysxdNG9.js +6 -0
  53. package/dist-lib/src-CL94RDe3.js +111 -0
  54. package/dist-lib/throttle-BeneRNYK.js +16 -0
  55. package/dist-lib/toast-Cm28o9U6.js +15 -0
  56. package/dist-lib/togeojson.es-DAgiTBvg.js +579 -0
  57. package/dist-lib/tooltip-Cucn1SiD.js +197 -0
  58. package/dist-lib/webmapx-3d-tool-D4CTD2gB.js +176 -0
  59. package/dist-lib/webmapx-base-tool-Dm9NAWLD.js +75 -0
  60. package/dist-lib/webmapx-config-edit-tool-DCTyxqTk.js +389 -0
  61. package/dist-lib/webmapx-coordinates-tool-jeWohup9.js +648 -0
  62. package/dist-lib/webmapx-core-bundle-BDImi1RE.js +8203 -0
  63. package/dist-lib/webmapx-draw-tool-DooAV8cF.js +4336 -0
  64. package/dist-lib/webmapx-geolocation-tool-Rw3-Iad1.js +788 -0
  65. package/dist-lib/webmapx-import-layer-tool-DRYviHd5.js +250 -0
  66. package/dist-lib/webmapx-info-tool-BJA157cy.js +412 -0
  67. package/dist-lib/webmapx-language-osmvector-M5y_lwOg.js +489 -0
  68. package/dist-lib/webmapx-measure-tool-BXhMJFC6.js +590 -0
  69. package/dist-lib/webmapx-modal-tool-eF6Naluv.js +84 -0
  70. package/dist-lib/webmapx-plugin-tool-D2Hghf9n.js +45 -0
  71. package/dist-lib/webmapx-print-tool-ob1bOsR5.js +348 -0
  72. package/dist-lib/webmapx-search-tool-Cv8BrYvY.js +437 -0
  73. package/dist-lib/webmapx-settings-DDEJ8aoV.js +479 -0
  74. package/dist-lib/webmapx-truearea-tool-CMB4Orm-.js +615 -0
  75. package/dist-lib/webmapx-view-mode-tool-CUpLNjOj.js +106 -0
  76. package/dist-lib/webmapx.css +2 -0
  77. package/dist-lib/webmapx.js +1321 -0
  78. package/dist-lib/wms-feature-info-C0RVMEQC.js +145 -0
  79. package/dist-lib/wms-url-builder-DIJLQ1v2.js +54 -0
  80. package/dist-lib/zip.js-DVhmtjxZ.js +3615 -0
  81. package/package.json +107 -0
  82. package/public/data/country-epsg-codes.json +297 -0
  83. package/public/data/world-countries-simplified.topojson +1 -0
  84. package/src/locales/en/core.json +20 -0
@@ -0,0 +1,1227 @@
1
+ import { t as e } from "./wms-feature-info-C0RVMEQC.js";
2
+ import { a as t, i as n, n as r, o as i, r as a, t as o } from "./deferred-query-service-BJDcngw6.js";
3
+ import { i as s, n as c, r as l, t as u } from "./maplibre-expression-evaluator-DCWUcpwf.js";
4
+ import { n as d } from "./marker-utils-DztWXeop.js";
5
+ import * as f from "leaflet";
6
+ import { version as p } from "leaflet";
7
+ //#region src/map/leaflet-services/LeafletLayerFactory.ts
8
+ if (typeof document < "u" && typeof document.getElementById == "function" && !document.getElementById("webmapx-symbol-label-style")) {
9
+ let e = document.createElement("style");
10
+ e.id = "webmapx-symbol-label-style", e.textContent = ".webmapx-symbol-label { background: none; border: none; }", document.head.appendChild(e);
11
+ }
12
+ function m(e) {
13
+ return e.replace(/[&<>"']/g, (e) => ({
14
+ "&": "&amp;",
15
+ "<": "&lt;",
16
+ ">": "&gt;",
17
+ "\"": "&quot;",
18
+ "'": "&#39;"
19
+ })[e]);
20
+ }
21
+ function h(e) {
22
+ let t = f.CRS.EPSG3857.project(e.getSouthWest()), n = f.CRS.EPSG3857.project(e.getNorthEast());
23
+ return [
24
+ t.x,
25
+ t.y,
26
+ n.x,
27
+ n.y
28
+ ].join(",");
29
+ }
30
+ var g = f.TileLayer.extend({ getTileUrl(e) {
31
+ let t = this._tileCoordsToBounds(e);
32
+ return this._url.replace("{bbox-epsg-3857}", h(t));
33
+ } }), _ = class e {
34
+ static createXYZLayer(e, t) {
35
+ if (t.type !== "raster" || t.service !== "xyz") return null;
36
+ let n = Array.isArray(t.url) ? t.url[0] : t.url, r = t.tileSize || 256, i = {
37
+ attribution: t.attribution,
38
+ tileSize: r,
39
+ zoomOffset: r === 512 ? -1 : 0,
40
+ minZoom: t.minzoom,
41
+ maxNativeZoom: t.maxzoom
42
+ }, a = n.includes("{bbox-epsg-3857}") ? new g(n, i) : f.tileLayer(n, i);
43
+ return {
44
+ id: `${e}-raster-xyz`,
45
+ type: "raster",
46
+ layer: a
47
+ };
48
+ }
49
+ static createWMSLayer(e, t) {
50
+ if (t.type !== "raster" || t.service !== "wms") return null;
51
+ let n = t, r = Array.isArray(n.url) ? n.url[0] : n.url, i = f.tileLayer.wms(r, {
52
+ layers: n.layers || "",
53
+ styles: n.styles || "",
54
+ format: n.format || "image/png",
55
+ transparent: n.transparent ?? !0,
56
+ version: n.version || "1.1.1",
57
+ crs: n.crs === "EPSG:4326" ? f.CRS.EPSG4326 : f.CRS.EPSG3857,
58
+ attribution: n.attribution,
59
+ minZoom: n.minzoom,
60
+ maxNativeZoom: n.maxzoom
61
+ });
62
+ return {
63
+ id: `${e}-raster-wms`,
64
+ type: "raster",
65
+ layer: i
66
+ };
67
+ }
68
+ static createGeoJSONLayer(t, n, r, i) {
69
+ let a = [];
70
+ for (let n of i) {
71
+ if (![
72
+ "fill",
73
+ "line",
74
+ "circle",
75
+ "symbol"
76
+ ].includes(n.type)) continue;
77
+ let i = e.createFilterFunction(n.filter), o = f.geoJSON(r, {
78
+ style: (t) => e.convertPaintToLeafletStyle(n, t),
79
+ pointToLayer: (t, r) => {
80
+ if (n.type === "circle") {
81
+ let i = e.resolveNumberExpression(n.paint?.["circle-radius"], t, 6);
82
+ return f.circleMarker(r, {
83
+ radius: i,
84
+ ...e.convertPaintToLeafletStyle(n, t),
85
+ interactive: !0
86
+ });
87
+ }
88
+ return n.type === "symbol" ? f.marker(r, {
89
+ icon: e.createTextLabelIcon(n, t),
90
+ interactive: !1
91
+ }) : f.marker(r, {
92
+ opacity: 0,
93
+ interactive: !1
94
+ });
95
+ },
96
+ filter: i,
97
+ interactive: !0
98
+ }), s = n.id ? `${t}-${n.id}` : `${t}-${n.type}-${a.length}`;
99
+ a.push({
100
+ id: s,
101
+ type: "geojson",
102
+ layer: o
103
+ });
104
+ }
105
+ return a;
106
+ }
107
+ static createTextLabelIcon(e, t) {
108
+ let n = t ?? { properties: {} }, r = e.layout || {}, i = e.paint || {}, a = l(r["text-field"], n, 0, ""), o = u(i["text-color"], n, 0, "#000"), s = u(i["text-halo-color"], n, 0, "transparent"), d = c(i["text-halo-width"], n, 0, 0), p = `<span style="color:${o};font-size:${c(r["text-size"], n, 0, 12)}px;text-shadow:${d > 0 ? [
109
+ [-1, -1],
110
+ [1, -1],
111
+ [-1, 1],
112
+ [1, 1]
113
+ ].map(([e, t]) => `${e * d}px ${t * d}px 0 ${s}`).join(", ") : "none"};white-space:nowrap;">${m(a)}</span>`;
114
+ return f.divIcon({
115
+ className: "webmapx-symbol-label",
116
+ html: p,
117
+ iconSize: [0, 0]
118
+ });
119
+ }
120
+ static createFilterFunction(e) {
121
+ if (!(!e || !Array.isArray(e))) return (t) => s(e, t);
122
+ }
123
+ static resolveNumberExpression(e, t, n) {
124
+ return c(e, t ?? { properties: {} }, 0, n);
125
+ }
126
+ static resolveColorExpression(e, t, n) {
127
+ return u(e, t ?? { properties: {} }, 0, n);
128
+ }
129
+ static convertPaintToLeafletStyle(e, t) {
130
+ let n = e.paint || {}, r = t ?? { properties: {} }, i = {};
131
+ switch (e.type) {
132
+ case "fill":
133
+ i.fillColor = u(n["fill-color"], r, 0, "#3388ff"), i.fillOpacity = c(n["fill-opacity"], r, 0, .5), i.color = u(n["fill-outline-color"], r, 0, i.fillColor), i.weight = 1, i.opacity = 1;
134
+ break;
135
+ case "line":
136
+ i.color = u(n["line-color"], r, 0, "#3388ff"), i.weight = c(n["line-width"], r, 0, 3), i.opacity = c(n["line-opacity"], r, 0, 1), i.fill = !1, n["line-dasharray"] && (i.dashArray = Array.isArray(n["line-dasharray"]) ? n["line-dasharray"].join(" ") : n["line-dasharray"]);
137
+ break;
138
+ case "circle":
139
+ i.fillColor = u(n["circle-color"], r, 0, "#3388ff"), i.fillOpacity = c(n["circle-opacity"], r, 0, 1), i.color = u(n["circle-stroke-color"], r, 0, i.fillColor), i.weight = c(n["circle-stroke-width"], r, 0, 1), i.opacity = c(n["circle-stroke-opacity"], r, 0, 1);
140
+ break;
141
+ }
142
+ return i;
143
+ }
144
+ }, v = 1, y = class {
145
+ constructor(e, t) {
146
+ this.store = e, this.eventBus = t, this.layerOrderRegistry = null, this.mapInstance = null, this.mapReadyCallbacks = [], this.silentSourceIds = /* @__PURE__ */ new Set(), this.sources = /* @__PURE__ */ new Map(), this.geoJSONData = /* @__PURE__ */ new Map(), this.logicalToNative = /* @__PURE__ */ new Map(), this.sourceToLayers = /* @__PURE__ */ new Map(), this.runtimeLayerOrder = [], this.runtimeLayerZoomRange = /* @__PURE__ */ new Map(), this.initialConfig = {
147
+ center: [51.17, 10.45],
148
+ zoom: 4
149
+ };
150
+ }
151
+ setLayerOrderRegistry(e) {
152
+ this.layerOrderRegistry = e;
153
+ }
154
+ applyZIndexIsolation(e) {
155
+ e.style.isolation = "isolate", e.style.zIndex = "0", e.style.position = "relative";
156
+ }
157
+ injectLeafletCSSFixes() {
158
+ let e = "webmapx-leaflet-fixes";
159
+ if (document.getElementById(e)) return;
160
+ let t = document.createElement("style");
161
+ t.id = e, t.textContent = "\n .leaflet-container { background: #f2efe9 !important; }\n .leaflet-tile-pane { background: #f2efe9 !important; }\n .leaflet-container img.leaflet-tile { mix-blend-mode: normal; }\n ", document.head.appendChild(t);
162
+ }
163
+ getViewportState() {
164
+ if (this.mapInstance) {
165
+ let e = this.mapInstance.getCenter(), t = this.mapInstance.getZoom() - v;
166
+ return {
167
+ center: [e.lng, e.lat],
168
+ zoom: t,
169
+ bearing: 0,
170
+ pitch: 0
171
+ };
172
+ }
173
+ return {
174
+ center: [0, 0],
175
+ zoom: 1,
176
+ bearing: 0,
177
+ pitch: 0
178
+ };
179
+ }
180
+ setViewport(e, t) {
181
+ if (this.mapInstance) {
182
+ let n = this.clampZoom(t), r = Math.round(n) + v;
183
+ this.mapInstance.flyTo([e[1], e[0]], r), n !== t && this.scheduleViewportSync();
184
+ }
185
+ }
186
+ initialize(e, t) {
187
+ let n = t?.center ? [t.center[1], t.center[0]] : this.initialConfig.center, r = t?.zoom ?? this.initialConfig.zoom, i = Math.round(r) + v;
188
+ this.minZoom = t?.minZoom, this.maxZoom = t?.maxZoom;
189
+ let a = t?.minZoom === void 0 ? void 0 : Math.round(t.minZoom) + v, o = t?.maxZoom === void 0 ? void 0 : Math.round(t.maxZoom) + v, s = this.resolveContainer(e);
190
+ s instanceof HTMLElement && this.applyZIndexIsolation(s), this.injectLeafletCSSFixes(), this.mapInstance = f.map(s, {
191
+ center: n,
192
+ zoom: i,
193
+ minZoom: a,
194
+ maxZoom: o,
195
+ attributionControl: !1,
196
+ zoomControl: !1
197
+ }), this.flushMapReadyCallbacks(), this.setupBaseLayers(t), this.setupMapEvents(this.mapInstance, r, n);
198
+ }
199
+ setupBaseLayers(e) {
200
+ if (e?.style?.sources) for (let t of Object.values(e.style.sources)) t.type === "raster" && t.tiles?.length && f.tileLayer(t.tiles[0], {
201
+ attribution: t.attribution || "",
202
+ tileSize: t.tileSize || 256,
203
+ minZoom: t.minzoom,
204
+ maxNativeZoom: t.maxzoom
205
+ }).addTo(this.mapInstance);
206
+ else e?.styleUrl && (async () => {
207
+ await this.loadStyleFromUrl(e.styleUrl);
208
+ })();
209
+ }
210
+ setupMapEvents(e, t, n) {
211
+ e.whenReady(() => {
212
+ this.store.dispatch({
213
+ mapLoaded: !0,
214
+ zoomLevel: t,
215
+ mapCenter: [n[1], n[0]],
216
+ mapViewportBounds: this.buildViewportFeature()
217
+ }, "MAP");
218
+ }), e.on("loading", () => this.store.dispatch({ mapBusy: !0 }, "MAP")), e.on("load", () => this.store.dispatch({ mapBusy: !1 }, "MAP")), e.on("zoomend", () => {
219
+ let t = e.getZoom() - v;
220
+ this.applyRuntimeLayerVisibility(), this.store.dispatch({
221
+ zoomLevel: t,
222
+ mapViewportBounds: this.buildViewportFeature()
223
+ }, "MAP"), this.eventBus?.emit({
224
+ type: "zoom-end",
225
+ zoom: t
226
+ });
227
+ }), e.on("moveend", () => {
228
+ let t = e.getCenter(), n = e.getZoom() - v;
229
+ this.store.dispatch({
230
+ mapCenter: [t.lng, t.lat],
231
+ zoomLevel: n,
232
+ mapViewportBounds: this.buildViewportFeature()
233
+ }, "MAP"), this.emitViewChangeEnd();
234
+ }), e.on("move", () => {
235
+ this.dispatchViewportBoundsSnapshot(), this.emitViewChange();
236
+ }), this.attachPointerEvents(e);
237
+ }
238
+ attachPointerEvents(e) {
239
+ e.on("mousemove", (e) => this.emitPointerEvent("pointer-move", e)), e.on("mousedown", (e) => {
240
+ let t = [e.latlng.lng, e.latlng.lat], n = [e.layerPoint.x, e.layerPoint.y];
241
+ this.eventBus?.emit({
242
+ type: "pointer-down",
243
+ coords: t,
244
+ pixel: n,
245
+ button: e.originalEvent.button,
246
+ originalEvent: e.originalEvent
247
+ });
248
+ }), e.on("mouseup", (e) => {
249
+ let t = [e.latlng.lng, e.latlng.lat], n = [e.layerPoint.x, e.layerPoint.y];
250
+ this.eventBus?.emit({
251
+ type: "pointer-up",
252
+ coords: t,
253
+ pixel: n,
254
+ button: e.originalEvent.button,
255
+ originalEvent: e.originalEvent
256
+ });
257
+ });
258
+ let t = e.getContainer(), n = (n) => {
259
+ let r = t.getBoundingClientRect(), i = f.point(n.clientX - r.left, n.clientY - r.top), a = e.containerPointToLatLng(i), o = [i.x, i.y];
260
+ return {
261
+ coords: [a.lng, a.lat],
262
+ pixel: o
263
+ };
264
+ };
265
+ t.addEventListener("pointermove", (e) => {
266
+ if (e.pointerType === "mouse") return;
267
+ let t = n(e);
268
+ t && this.eventBus?.emit({
269
+ type: "pointer-move",
270
+ coords: t.coords,
271
+ pixel: t.pixel,
272
+ resolution: null,
273
+ originalEvent: e
274
+ });
275
+ }), t.addEventListener("pointerdown", (e) => {
276
+ if (e.pointerType === "mouse") return;
277
+ let t = n(e);
278
+ t && this.eventBus?.emit({
279
+ type: "pointer-down",
280
+ coords: t.coords,
281
+ pixel: t.pixel,
282
+ button: 0,
283
+ originalEvent: e
284
+ });
285
+ }), t.addEventListener("pointerup", (e) => {
286
+ if (e.pointerType === "mouse") return;
287
+ let t = n(e);
288
+ t && this.eventBus?.emit({
289
+ type: "pointer-up",
290
+ coords: t.coords,
291
+ pixel: t.pixel,
292
+ button: 0,
293
+ originalEvent: e
294
+ });
295
+ }), t.addEventListener("pointercancel", () => {
296
+ this.eventBus?.emit({ type: "pointer-cancel" });
297
+ }), e.on("mouseout", (e) => {
298
+ this.eventBus?.emit({
299
+ type: "pointer-leave",
300
+ originalEvent: e.originalEvent
301
+ }), this.store.dispatch({
302
+ pointerCoordinates: null,
303
+ pointerResolution: null
304
+ }, "MAP");
305
+ }), e.on("click", (e) => this.emitPointerEvent("click", e, !0)), e.on("dblclick", (e) => this.emitPointerEvent("dblclick", e)), e.on("contextmenu", (e) => this.emitPointerEvent("contextmenu", e));
306
+ }
307
+ emitPointerEvent(e, t, n = !1) {
308
+ let r = [t.latlng.lng, t.latlng.lat], i = [t.layerPoint.x, t.layerPoint.y], a = this.computePointerResolution(t), o = {
309
+ type: e,
310
+ coords: r,
311
+ pixel: i,
312
+ resolution: a,
313
+ originalEvent: t.originalEvent
314
+ };
315
+ this.eventBus?.emit(o), n && this.store.dispatch({
316
+ lastClickedCoordinates: r,
317
+ lastClickedResolution: a
318
+ }, "MAP"), e === "pointer-move" && this.store.dispatch({
319
+ pointerCoordinates: r,
320
+ pointerResolution: a
321
+ }, "MAP");
322
+ }
323
+ project(e) {
324
+ if (!this.mapInstance) return console.warn("[CORE SERVICE - Leaflet] project called before map instance is ready."), [0, 0];
325
+ let t = f.latLng(e[1], e[0]), n = this.mapInstance.latLngToContainerPoint(t);
326
+ return [n.x, n.y];
327
+ }
328
+ unproject(e) {
329
+ if (!this.mapInstance) return null;
330
+ let t = this.mapInstance.containerPointToLatLng({
331
+ x: e[0],
332
+ y: e[1]
333
+ });
334
+ return t ? [t.lng, t.lat] : null;
335
+ }
336
+ fitBounds(e) {
337
+ if (!this.mapInstance) return;
338
+ let t = f.latLng(e[1], e[0]), n = f.latLng(e[3], e[2]), r = f.latLngBounds(t, n);
339
+ this.mapInstance.fitBounds(r, {
340
+ padding: [40, 40],
341
+ animate: !0
342
+ });
343
+ }
344
+ setCursor(e) {
345
+ this.mapInstance && (this.mapInstance.getContainer().style.cursor = e);
346
+ }
347
+ setPanEnabled(e) {
348
+ this.mapInstance && (e ? this.mapInstance.dragging.enable() : this.mapInstance.dragging.disable());
349
+ }
350
+ setTouchCaptureEnabled(e) {
351
+ if (!this.mapInstance) return;
352
+ let t = this.mapInstance.getContainer();
353
+ t.style.touchAction = e ? "" : "none";
354
+ }
355
+ setDoubleClickZoomEnabled(e) {
356
+ this.mapInstance && (e ? this.mapInstance.doubleClickZoom.enable() : this.mapInstance.doubleClickZoom.disable());
357
+ }
358
+ setLayerVisibility(e, t) {
359
+ this.mapInstance && (this.logicalToNative.get(e) ?? []).forEach((e) => {
360
+ t ? this.mapInstance.hasLayer(e) || this.mapInstance.addLayer(e) : this.mapInstance.hasLayer(e) && this.mapInstance.removeLayer(e);
361
+ });
362
+ }
363
+ getSourceData(e) {
364
+ let t = this.geoJSONData.get(e);
365
+ if (t) return t;
366
+ let n = this.sources.get(e);
367
+ return !n || n.type !== "geojson" ? null : typeof n.data == "string" ? n.data : n.data && typeof n.data == "object" ? (this.geoJSONData.set(e, n.data), n.data) : null;
368
+ }
369
+ computePointerResolution(e) {
370
+ if (!this.mapInstance || !e.layerPoint) return null;
371
+ let { x: t, y: n } = e.layerPoint, r = this.mapInstance.layerPointToLatLng([t + 1, n]), i = this.mapInstance.layerPointToLatLng([t, n + 1]), a = Math.abs(r.lng - e.latlng.lng), o = Math.abs(i.lat - e.latlng.lat);
372
+ return !isFinite(a) || !isFinite(o) ? null : {
373
+ lng: Math.max(a, 1e-12),
374
+ lat: Math.max(o, 1e-12)
375
+ };
376
+ }
377
+ emitViewChange() {
378
+ if (!this.eventBus || !this.mapInstance) return;
379
+ let e = this.mapInstance.getCenter(), t = this.mapInstance.getBounds(), n = this.mapInstance.getZoom() - v;
380
+ this.eventBus.emit({
381
+ type: "view-change",
382
+ center: [e.lng, e.lat],
383
+ zoom: n,
384
+ bearing: 0,
385
+ pitch: 0,
386
+ bounds: {
387
+ sw: [t.getSouthWest().lng, t.getSouthWest().lat],
388
+ ne: [t.getNorthEast().lng, t.getNorthEast().lat]
389
+ }
390
+ });
391
+ }
392
+ emitViewChangeEnd() {
393
+ if (!this.eventBus || !this.mapInstance) return;
394
+ let e = this.mapInstance.getCenter(), t = this.mapInstance.getBounds(), n = this.mapInstance.getZoom() - v;
395
+ this.eventBus.emit({
396
+ type: "view-change-end",
397
+ center: [e.lng, e.lat],
398
+ zoom: n,
399
+ bearing: 0,
400
+ pitch: 0,
401
+ bounds: {
402
+ sw: [t.getSouthWest().lng, t.getSouthWest().lat],
403
+ ne: [t.getNorthEast().lng, t.getNorthEast().lat]
404
+ }
405
+ });
406
+ }
407
+ onMapReady(e) {
408
+ this.mapInstance ? e(this.mapInstance) : this.mapReadyCallbacks.push(e);
409
+ }
410
+ setZoom(e) {
411
+ if (!this.mapInstance) return;
412
+ let t = this.clampZoom(e);
413
+ if (this.mapInstance.getZoom() - v === t && t !== e) {
414
+ this.scheduleViewportSync();
415
+ return;
416
+ }
417
+ this.mapInstance.setZoom(Math.round(t) + v);
418
+ }
419
+ getZoom() {
420
+ return this.mapInstance ? this.mapInstance.getZoom() - v : this.initialConfig.zoom;
421
+ }
422
+ getNavigationCapabilities() {
423
+ return {
424
+ bearing: !1,
425
+ pitch: !1
426
+ };
427
+ }
428
+ getBearing() {
429
+ return 0;
430
+ }
431
+ setBearing(e) {}
432
+ getPitch() {
433
+ return 0;
434
+ }
435
+ setPitch(e) {}
436
+ setTerrainEnabled(e) {
437
+ return !1;
438
+ }
439
+ isTerrainEnabled() {
440
+ return null;
441
+ }
442
+ resetNorth() {}
443
+ resetNorthPitch() {
444
+ this.resetNorth();
445
+ }
446
+ setProjection(e) {
447
+ return !1;
448
+ }
449
+ getProjection() {
450
+ return null;
451
+ }
452
+ scheduleViewportSync() {
453
+ this.mapInstance && requestAnimationFrame(() => {
454
+ if (!this.mapInstance) return;
455
+ let e = this.mapInstance.getCenter(), t = this.mapInstance.getZoom() - v, n = this.buildViewportFeature();
456
+ this.store.dispatch({
457
+ mapCenter: [e.lng, e.lat],
458
+ zoomLevel: t,
459
+ mapViewportBounds: n
460
+ }, "MAP"), this.emitViewChangeEnd();
461
+ });
462
+ }
463
+ clampZoom(e) {
464
+ let t = e;
465
+ return this.minZoom !== void 0 && (t = Math.max(t, this.minZoom)), this.maxZoom !== void 0 && (t = Math.min(t, this.maxZoom)), t;
466
+ }
467
+ addLayer(e, t) {
468
+ if (!this.mapInstance) return !1;
469
+ let n = e.source;
470
+ if (!n) return e?.addTo === "function" && e.addTo(this.mapInstance), !1;
471
+ let r = this.sources.get(n);
472
+ if (!r) return console.warn(`[CORE SERVICE] Source "${n}" not found for layer "${e.id}".`), !1;
473
+ let i = this.geoJSONData.get(n) || r.data || {
474
+ type: "FeatureCollection",
475
+ features: []
476
+ }, a = Array.isArray(e.layers) ? e.layers : [e], o = _.createGeoJSONLayer(e.id ?? e.source, r, i, a);
477
+ this.runtimeLayerZoomRange.set(e.id, this.readLayerZoomRange(e));
478
+ let s = [];
479
+ for (let e of o) e.layer.addTo(this.mapInstance), s.push(e.layer);
480
+ return this.removeRuntimeLayer(e.id), this.insertByOptions(this.runtimeLayerOrder, e.id, t) || this.runtimeLayerOrder.push(e.id), this.logicalToNative.set(e.id, s), this.layerOrderRegistry?.registerInlineLayer(e.id, s, t), this.applyRuntimeLayerVisibility(), this.sourceToLayers.has(n) || this.sourceToLayers.set(n, []), this.sourceToLayers.get(n).push(e.id), !0;
481
+ }
482
+ removeLayer(e) {
483
+ let t = this.logicalToNative.get(e);
484
+ if (t && this.mapInstance) {
485
+ t.forEach((e) => this.mapInstance.removeLayer(e)), this.logicalToNative.delete(e), this.removeRuntimeLayer(e), this.runtimeLayerZoomRange.delete(e);
486
+ for (let [t, n] of this.sourceToLayers.entries()) {
487
+ let r = n.indexOf(e);
488
+ if (r > -1) {
489
+ n.splice(r, 1), n.length === 0 && this.sourceToLayers.delete(t);
490
+ break;
491
+ }
492
+ }
493
+ this.layerOrderRegistry?.unregisterInlineLayer(e), this.applyRuntimeLayerOrder();
494
+ }
495
+ }
496
+ addSource(e, t) {
497
+ this.sources.set(e, t), t?.type === "geojson" && t.data && typeof t.data == "object" && this.geoJSONData.set(e, t.data);
498
+ }
499
+ removeSource(e) {
500
+ let t = this.sourceToLayers.get(e);
501
+ t && t.forEach((e) => this.removeLayer(e)), this.sources.delete(e), this.geoJSONData.delete(e);
502
+ }
503
+ removeRuntimeLayer(e) {
504
+ this.runtimeLayerOrder = this.runtimeLayerOrder.filter((t) => t !== e), this.runtimeLayerZoomRange.delete(e);
505
+ }
506
+ readLayerZoomRange(e) {
507
+ return {
508
+ minzoom: this.toNumericZoom(e?.minzoom ?? e?.minZoom),
509
+ maxzoom: this.toNumericZoom(e?.maxzoom ?? e?.maxZoom)
510
+ };
511
+ }
512
+ toNumericZoom(e) {
513
+ return typeof e == "number" && isFinite(e) ? e : void 0;
514
+ }
515
+ isLayerVisibleAtZoom(e, t) {
516
+ let n = this.runtimeLayerZoomRange.get(e);
517
+ return n ? !(n.minzoom !== void 0 && t < n.minzoom || n.maxzoom !== void 0 && t >= n.maxzoom) : !0;
518
+ }
519
+ applyRuntimeLayerVisibility() {
520
+ if (!this.mapInstance) return;
521
+ let e = this.mapInstance.getZoom() - v;
522
+ for (let t of this.runtimeLayerOrder) {
523
+ let n = this.isLayerVisibleAtZoom(t, e), r = this.logicalToNative.get(t) ?? [];
524
+ for (let e of r) n ? this.mapInstance.hasLayer(e) || e.addTo(this.mapInstance) : this.mapInstance.hasLayer(e) && this.mapInstance.removeLayer(e);
525
+ }
526
+ this.applyRuntimeLayerOrder();
527
+ }
528
+ insertByOptions(e, t, n) {
529
+ let r = n?.beforeLayerId;
530
+ if (typeof r == "string") {
531
+ let n = e.indexOf(r);
532
+ if (n >= 0) return e.splice(n, 0, t), !0;
533
+ }
534
+ let i = n?.afterLayerId;
535
+ if (typeof i == "string") {
536
+ let n = e.indexOf(i);
537
+ if (n >= 0) return e.splice(n + 1, 0, t), !0;
538
+ }
539
+ return !1;
540
+ }
541
+ applyRuntimeLayerOrder() {
542
+ if (this.mapInstance) for (let e of this.runtimeLayerOrder) {
543
+ let t = this.logicalToNative.get(e) ?? [];
544
+ for (let e of t) e.bringToFront?.();
545
+ }
546
+ }
547
+ getSource(e) {
548
+ if (!this.sources.has(e)) return;
549
+ let t = this;
550
+ return {
551
+ id: e,
552
+ setData: (n) => {
553
+ t.geoJSONData.set(e, n);
554
+ let r = t.sourceToLayers.get(e);
555
+ if (r) for (let e of r) {
556
+ let r = t.logicalToNative.get(e);
557
+ r && r.forEach((e) => {
558
+ "clearLayers" in e && "addData" in e && (e.clearLayers(), e.addData(n));
559
+ });
560
+ }
561
+ }
562
+ };
563
+ }
564
+ suppressBusySignalForSource(e) {
565
+ this.silentSourceIds.add(e);
566
+ }
567
+ unsuppressBusySignalForSource(e) {
568
+ this.silentSourceIds.delete(e);
569
+ }
570
+ dispatchViewportBoundsSnapshot() {
571
+ let e = this.buildViewportFeature();
572
+ this.store.dispatch({ mapViewportBounds: e }, "MAP");
573
+ }
574
+ buildViewportFeature() {
575
+ if (!this.mapInstance) return null;
576
+ let e = this.mapInstance.getBounds();
577
+ if (!e) return null;
578
+ let t = e.getSouthWest(), n = e.getNorthEast();
579
+ return {
580
+ type: "Feature",
581
+ properties: { role: "mapViewport" },
582
+ geometry: {
583
+ type: "Polygon",
584
+ coordinates: [[
585
+ [t.lng, t.lat],
586
+ [t.lng, n.lat],
587
+ [n.lng, n.lat],
588
+ [n.lng, t.lat],
589
+ [t.lng, t.lat]
590
+ ]]
591
+ }
592
+ };
593
+ }
594
+ resolveContainer(e) {
595
+ let t = document.getElementById(e);
596
+ if (!t) return e;
597
+ if (t.tagName.toLowerCase() === "webmapx-map") {
598
+ let e = t.querySelector("[slot=\"map-view\"]");
599
+ if (e) return e;
600
+ }
601
+ return t;
602
+ }
603
+ flushMapReadyCallbacks() {
604
+ this.mapInstance && this.mapReadyCallbacks.splice(0).forEach((e) => {
605
+ try {
606
+ e(this.mapInstance);
607
+ } catch (e) {
608
+ console.error("[CORE SERVICE] mapReady callback failed.", e);
609
+ }
610
+ });
611
+ }
612
+ async loadStyleFromUrl(e) {
613
+ if (!this.mapInstance) return !1;
614
+ try {
615
+ let t = await fetch(e);
616
+ if (!t.ok) return !1;
617
+ let n = await t.json(), r = 0;
618
+ if (n.sources) for (let [e, t] of Object.entries(n.sources)) t.type === "raster" && t.tiles?.length && (f.tileLayer(t.tiles[0], {
619
+ attribution: t.attribution || "",
620
+ tileSize: t.tileSize || 256,
621
+ minZoom: t.minzoom,
622
+ maxNativeZoom: t.maxzoom
623
+ }).addTo(this.mapInstance), r++);
624
+ return r > 0;
625
+ } catch (e) {
626
+ return console.error("[CORE SERVICE] Error loading style:", e), !1;
627
+ }
628
+ }
629
+ }, b = class {
630
+ constructor(e) {
631
+ this.leafletInstance = {}, this.leafletInstance = e;
632
+ }
633
+ setBufferRadius(e) {
634
+ console.log(`[SERVICE TEMPLATE] Set buffer radius to ${e}km on Leaflet.`);
635
+ }
636
+ toggleTool() {
637
+ console.log("[SERVICE TEMPLATE] Toggled buffer tool activation.");
638
+ }
639
+ }, x = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", S = "&copy; <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors", C = 1;
640
+ function w(e) {
641
+ return e.endsWith(".json") || e.includes("/style");
642
+ }
643
+ var T = class {
644
+ constructor(e, t) {
645
+ this.id = e, this.layer = t;
646
+ }
647
+ setData(e) {
648
+ this.layer.clearLayers(), this.layer.addData(e);
649
+ }
650
+ }, E = class {
651
+ constructor(e, t, n, r) {
652
+ this.id = e, this.layer = t, this.source = n, this.map = r;
653
+ }
654
+ getSource() {
655
+ return this.source;
656
+ }
657
+ remove() {
658
+ this.map.removeLayer(this.layer);
659
+ }
660
+ }, D = class {
661
+ constructor(e) {
662
+ this.map = e, this.sources = /* @__PURE__ */ new Map(), this.layers = /* @__PURE__ */ new Map(), this.geoJsonLayers = /* @__PURE__ */ new Map(), this.resizeObserver = null;
663
+ let t = e.getContainer();
664
+ this.resizeObserver = new ResizeObserver(() => {
665
+ e.invalidateSize({ animate: !1 });
666
+ }), this.resizeObserver.observe(t);
667
+ }
668
+ setViewport(e, t, n, r) {
669
+ let i = Math.max(0, Math.round(t) + C);
670
+ this.map.setView([e[1], e[0]], i, { animate: !1 });
671
+ }
672
+ createSource(e, t) {
673
+ if (!this.sources.has(e)) {
674
+ let n = f.geoJSON(t);
675
+ this.geoJsonLayers.set(e, n);
676
+ let r = new T(e, n);
677
+ this.sources.set(e, r);
678
+ }
679
+ return this.sources.get(e);
680
+ }
681
+ getSource(e) {
682
+ return this.sources.get(e) || null;
683
+ }
684
+ createLayer(e) {
685
+ if (!this.layers.has(e.id)) {
686
+ let t = this.geoJsonLayers.get(e.sourceId);
687
+ if (!t) throw Error(`Source ${e.sourceId} not found for layer ${e.id}`);
688
+ let n = this.toLeafletStyle(e);
689
+ t.setStyle(n), t.addTo(this.map);
690
+ let r = this.sources.get(e.sourceId), i = new E(e.id, t, r, this.map);
691
+ this.layers.set(e.id, i);
692
+ }
693
+ return this.layers.get(e.id);
694
+ }
695
+ getLayer(e) {
696
+ return this.layers.get(e) || null;
697
+ }
698
+ onReady(e) {
699
+ this.map.whenReady(() => {
700
+ let t = () => {
701
+ this.map.invalidateSize({ animate: !1 });
702
+ };
703
+ t(), setTimeout(t, 0), setTimeout(t, 50), setTimeout(() => {
704
+ t(), e();
705
+ }, 100);
706
+ });
707
+ }
708
+ destroy() {
709
+ this.resizeObserver &&= (this.resizeObserver.disconnect(), null), this.map.remove();
710
+ }
711
+ toLeafletStyle(e) {
712
+ let t = {};
713
+ if (e.paint) switch (e.type) {
714
+ case "fill":
715
+ "fill-color" in e.paint && (t.fillColor = e.paint["fill-color"]), "fill-opacity" in e.paint && (t.fillOpacity = e.paint["fill-opacity"]), t.stroke = !1;
716
+ break;
717
+ case "line":
718
+ "line-color" in e.paint && (t.color = e.paint["line-color"]), "line-width" in e.paint && (t.weight = e.paint["line-width"]), "line-opacity" in e.paint && (t.opacity = e.paint["line-opacity"]), t.fill = !1;
719
+ break;
720
+ case "circle":
721
+ "circle-color" in e.paint && (t.fillColor = e.paint["circle-color"]), "circle-opacity" in e.paint && (t.fillOpacity = e.paint["circle-opacity"]);
722
+ break;
723
+ case "symbol": break;
724
+ }
725
+ return t;
726
+ }
727
+ }, O = class {
728
+ constructor() {
729
+ this.shadowStyleId = "webmapx-leaflet-shadow-styles";
730
+ }
731
+ createMap(e, t) {
732
+ this.ensureLeafletShadowStyles(e);
733
+ let n = {
734
+ center: t?.center ? [t.center[1], t.center[0]] : [0, 0],
735
+ zoom: Math.max(0, Math.round(t?.zoom ?? 1) + C),
736
+ attributionControl: !1,
737
+ zoomControl: !1,
738
+ className: "leaflet-edge-buffered"
739
+ }, r = f.map(e, n), i = Array.isArray(t?.tileUrls) && t.tileUrls.length > 0 ? t.tileUrls[0] : t?.tileUrl;
740
+ return i ? f.tileLayer(i, {
741
+ attribution: t?.tileAttribution ?? S,
742
+ tileSize: t?.tileSize
743
+ }).addTo(r) : t?.styleUrl && !w(t.styleUrl) ? f.tileLayer(t.styleUrl, { attribution: t.tileAttribution ?? S }).addTo(r) : f.tileLayer(x, { attribution: t?.tileAttribution ?? S }).addTo(r), t?.interactive === !1 && (r.dragging.disable(), r.touchZoom.disable(), r.doubleClickZoom.disable(), r.scrollWheelZoom.disable(), r.boxZoom.disable(), r.keyboard.disable(), r.tap && r.tap.disable()), new D(r);
744
+ }
745
+ ensureLeafletShadowStyles(e) {
746
+ let t = e.getRootNode();
747
+ if (!(t instanceof ShadowRoot) || t.querySelector(`#${this.shadowStyleId}`)) return;
748
+ let n = document.createElement("style");
749
+ n.id = this.shadowStyleId, n.textContent = "\n .leaflet-pane,\n .leaflet-tile,\n .leaflet-marker-icon,\n .leaflet-marker-shadow,\n .leaflet-tile-container,\n .leaflet-pane > svg,\n .leaflet-pane > canvas,\n .leaflet-zoom-box,\n .leaflet-image-layer,\n .leaflet-layer {\n position: absolute;\n left: 0;\n top: 0;\n }\n .leaflet-container {\n overflow: hidden;\n }\n .leaflet-container .leaflet-marker-pane img,\n .leaflet-container .leaflet-shadow-pane img,\n .leaflet-container .leaflet-tile-pane img,\n .leaflet-container img.leaflet-image-layer,\n .leaflet-container .leaflet-tile {\n max-width: none !important;\n max-height: none !important;\n width: auto;\n padding: 0;\n }\n .leaflet-container img.leaflet-tile {\n mix-blend-mode: normal;\n }\n .leaflet-tile {\n visibility: hidden;\n }\n .leaflet-tile-loaded {\n visibility: inherit;\n }\n .leaflet-pane { z-index: 400; }\n .leaflet-tile-pane { z-index: 200; }\n .leaflet-overlay-pane { z-index: 400; }\n .leaflet-shadow-pane { z-index: 500; }\n .leaflet-marker-pane { z-index: 600; }\n .leaflet-tooltip-pane { z-index: 650; }\n .leaflet-popup-pane { z-index: 700; }\n .leaflet-map-pane canvas { z-index: 100; }\n .leaflet-map-pane svg { z-index: 200; }\n .leaflet-zoom-animated {\n transform-origin: 0 0;\n }\n ", t.appendChild(n);
750
+ }
751
+ }, k = "warpedmap://", A = class {
752
+ constructor(e, t) {
753
+ this.logicalToNative = /* @__PURE__ */ new Map(), this.logicalToWMSSource = /* @__PURE__ */ new Map(), this.nativeLayerInstances = /* @__PURE__ */ new Map(), this.nativeLayerToSource = /* @__PURE__ */ new Map(), this.warpedMapLayers = /* @__PURE__ */ new Map(), this.compositeSubLayerCache = /* @__PURE__ */ new Map(), this.sourceIdCounter = 0, this.busyOps = 0, this.logicalOrder = [], this.map = e, this.store = t;
754
+ }
755
+ beginBusyOperation() {
756
+ this.busyOps += 1, this.busyOps === 1 && this.store.dispatch({ mapBusy: !0 }, "MAP");
757
+ }
758
+ endBusyOperation() {
759
+ if (this.busyOps <= 0) {
760
+ this.busyOps = 0, this.store.dispatch({ mapBusy: !1 }, "MAP");
761
+ return;
762
+ }
763
+ --this.busyOps, this.busyOps === 0 && this.store.dispatch({ mapBusy: !1 }, "MAP");
764
+ }
765
+ attachTileBusyEvents(e) {
766
+ let t = e;
767
+ typeof t.on == "function" && (t.__webmapxBusyBound || (t.__webmapxBusyBound = !0, t.on("loading", () => this.beginBusyOperation()), t.on("load", () => this.endBusyOperation()), t.on("tileerror", () => this.endBusyOperation())));
768
+ }
769
+ resolveInsertIndex(e) {
770
+ if (e?.beforeLayerId) {
771
+ let t = this.logicalOrder.indexOf(e.beforeLayerId);
772
+ if (t >= 0) return t;
773
+ }
774
+ if (e?.afterLayerId) {
775
+ let t = this.logicalOrder.indexOf(e.afterLayerId);
776
+ if (t >= 0) return t + 1;
777
+ }
778
+ }
779
+ upsertLogicalOrder(e, t) {
780
+ if (this.logicalOrder = this.logicalOrder.filter((t) => t !== e), typeof t != "number" || !Number.isFinite(t)) {
781
+ this.logicalOrder.push(e);
782
+ return;
783
+ }
784
+ let n = Math.max(0, Math.min(t, this.logicalOrder.length));
785
+ this.logicalOrder.splice(n, 0, e);
786
+ }
787
+ reapplyLogicalOrder() {
788
+ for (let e of this.logicalOrder) {
789
+ let t = this.warpedMapLayers.get(e);
790
+ if (t) {
791
+ let e = t.container;
792
+ e?.parentElement && e.parentElement.appendChild(e);
793
+ continue;
794
+ }
795
+ let n = this.logicalToNative.get(e) ?? [];
796
+ for (let e of n) {
797
+ let t = this.nativeLayerInstances.get(e);
798
+ !t || !this.map.hasLayer(t) || (this.map.removeLayer(t), this.map.addLayer(t));
799
+ }
800
+ }
801
+ }
802
+ isWarpedMapSource(e) {
803
+ return e.type === "raster" && "url" in e ? (Array.isArray(e.url) ? e.url[0] : e.url).startsWith(k) : !1;
804
+ }
805
+ parseWarpedMapUrl(e) {
806
+ return e.startsWith(k) ? "https://" + e.slice(12) : e;
807
+ }
808
+ async addWarpedMapLayer(e, t) {
809
+ try {
810
+ this.beginBusyOperation();
811
+ let { WarpedMapLayer: n } = await import("./dist-Ha9LQCut.js"), r = `warpedmap-${e}`, i = new n(t, { pane: "overlayPane" });
812
+ return i.addTo(this.map), this.warpedMapLayers.set(e, i), this.nativeLayerInstances.set(r, i), this.logicalToNative.set(e, [r]), !0;
813
+ } catch (e) {
814
+ return console.warn("[LEAFLET LAYER SERVICE] @allmaps/leaflet not available or error loading warped map:", e), !1;
815
+ } finally {
816
+ this.endBusyOperation();
817
+ }
818
+ }
819
+ async addLayer(e, r) {
820
+ let i = e.id, a = this.resolveInsertIndex(r);
821
+ if (e.type === "allmaps") {
822
+ let t = await this.addWarpedMapLayer(i, e.annotation);
823
+ return t && (this.upsertLogicalOrder(i, a), this.reapplyLogicalOrder()), t;
824
+ }
825
+ if (e.type === "style") {
826
+ let t = n(e);
827
+ return t ? this.addCompositeLayer(t, r) : !1;
828
+ }
829
+ let o = e;
830
+ if (!o.source) return !1;
831
+ let s = e.sources?.[o.source], c = s ? t(o.source, s) : null;
832
+ if (!c) return !1;
833
+ if (this.isWarpedMapSource(c)) {
834
+ let e = Array.isArray(c.url) ? c.url[0] : c.url, t = this.parseWarpedMapUrl(e), n = await this.addWarpedMapLayer(i, t);
835
+ return n && (this.upsertLogicalOrder(i, a), this.reapplyLogicalOrder()), n;
836
+ }
837
+ let l = [], u = [o];
838
+ if (c.type === "raster") {
839
+ let t = c.service === "xyz" ? _.createXYZLayer(i, c) : _.createWMSLayer(i, c);
840
+ t && !this.nativeLayerInstances.has(t.id) && (this.attachTileBusyEvents(t.layer), t.layer.addTo(this.map), this.nativeLayerInstances.set(t.id, t.layer), l.push(t.id)), c.service === "wms" && this.logicalToWMSSource.set(i, {
841
+ layerTitle: e.title,
842
+ sourceConfig: c
843
+ });
844
+ } else if (c.type === "geojson") {
845
+ let e = await this.fetchGeoJSON(c);
846
+ if (!e) return !1;
847
+ let t = _.createGeoJSONLayer(i, c, e, u);
848
+ for (let e of t) this.nativeLayerInstances.has(e.id) || (e.layer.addTo(this.map), this.nativeLayerInstances.set(e.id, e.layer), this.nativeLayerToSource.set(e.id, c.id), l.push(e.id));
849
+ } else if (c.type === "vector") return console.warn("[LEAFLET LAYER SERVICE] Vector tile sources require leaflet.vectorgrid plugin"), !1;
850
+ return this.logicalToNative.set(i, l), this.upsertLogicalOrder(i, a), this.reapplyLogicalOrder(), l.length > 0;
851
+ }
852
+ async fetchGeoJSON(e) {
853
+ if (typeof e.data != "string") return e.data;
854
+ try {
855
+ return this.beginBusyOperation(), await (await fetch(e.data)).json();
856
+ } catch (e) {
857
+ return console.error("[LEAFLET LAYER SERVICE] Failed to fetch GeoJSON:", e), null;
858
+ } finally {
859
+ this.endBusyOperation();
860
+ }
861
+ }
862
+ async addCompositeLayer(e, t) {
863
+ let n = e.styleId, r = this.resolveInsertIndex(t), i = [], o = /* @__PURE__ */ new Map();
864
+ for (let t of e.subLayers) {
865
+ let e = t.source ?? "";
866
+ o.has(e) || o.set(e, []), o.get(e).push(t);
867
+ }
868
+ for (let [t, r] of o.entries()) {
869
+ let o = a(e, t)?.config ?? null;
870
+ if (o) {
871
+ if (o.type === "raster") {
872
+ let e = o.service === "xyz" ? _.createXYZLayer(n, o) : _.createWMSLayer(n, o);
873
+ e && !this.nativeLayerInstances.has(e.id) && (this.attachTileBusyEvents(e.layer), e.layer.addTo(this.map), this.nativeLayerInstances.set(e.id, e.layer), i.push(e.id));
874
+ } else if (o.type === "geojson") {
875
+ let e = await this.fetchGeoJSON(o);
876
+ if (!e) continue;
877
+ let t = _.createGeoJSONLayer(n, o, e, r);
878
+ for (let a of t) if (!this.nativeLayerInstances.has(a.id)) {
879
+ a.layer.addTo(this.map), this.nativeLayerInstances.set(a.id, a.layer), this.nativeLayerToSource.set(a.id, o.id), i.push(a.id);
880
+ let t = r.find((e) => a.id === `${n}-${e.id}`);
881
+ t && this.compositeSubLayerCache.set(a.id, {
882
+ spec: t,
883
+ sourceConfig: o,
884
+ data: e
885
+ });
886
+ }
887
+ }
888
+ }
889
+ }
890
+ return this.logicalToNative.set(n, i), this.upsertLogicalOrder(n, r), this.reapplyLogicalOrder(), i.length > 0;
891
+ }
892
+ updateLayerStyle(e, t, n) {
893
+ let r = `${e}-${t}`, i = this.compositeSubLayerCache.get(r), a = this.nativeLayerInstances.get(r);
894
+ if (!i || !a || typeof a.setStyle != "function") return !1;
895
+ let o = {
896
+ ...i.spec,
897
+ paint: {
898
+ ...i.spec.paint ?? {},
899
+ ...n
900
+ }
901
+ };
902
+ return a.setStyle((e) => _.convertPaintToLeafletStyle(o, e)), this.compositeSubLayerCache.set(r, {
903
+ ...i,
904
+ spec: o
905
+ }), !0;
906
+ }
907
+ moveLayer(e, t) {
908
+ let n = t ?? null;
909
+ if (n && !this.logicalOrder.includes(n)) {
910
+ let e = Object.keys(this.store.getState().mapLayers ?? {}), t = e.indexOf(n);
911
+ n = t === -1 ? null : e.slice(t + 1).find((e) => this.logicalOrder.includes(e)) ?? null;
912
+ }
913
+ let r = n ? this.resolveInsertIndex({ beforeLayerId: n }) : void 0;
914
+ this.upsertLogicalOrder(e, r), this.reapplyLogicalOrder();
915
+ }
916
+ removeLayer(e) {
917
+ if (this.warpedMapLayers.has(e)) {
918
+ let t = this.warpedMapLayers.get(e);
919
+ t && this.map.removeLayer(t), this.warpedMapLayers.delete(e);
920
+ }
921
+ let t = this.logicalToNative.get(e) || [];
922
+ for (let e of t) {
923
+ let t = this.nativeLayerInstances.get(e);
924
+ t && (this.map.removeLayer(t), this.nativeLayerInstances.delete(e), this.nativeLayerToSource.delete(e), this.compositeSubLayerCache.delete(e));
925
+ }
926
+ this.logicalToNative.delete(e), this.logicalToWMSSource.delete(e), this.logicalOrder = this.logicalOrder.filter((t) => t !== e);
927
+ }
928
+ getVisibleLayers() {
929
+ return Array.from(this.logicalToNative.keys());
930
+ }
931
+ isLayerVisible(e) {
932
+ return this.logicalToNative.has(e);
933
+ }
934
+ setLayerOpacity(e, t) {
935
+ let n = this.logicalToNative.get(e) ?? [];
936
+ for (let e of n) {
937
+ let n = this.nativeLayerInstances.get(e);
938
+ n && (typeof n.setOpacity == "function" ? n.setOpacity(t) : typeof n.setStyle == "function" && n.setStyle({
939
+ opacity: t,
940
+ fillOpacity: t
941
+ }));
942
+ }
943
+ }
944
+ setLayerVisibility(e, t) {
945
+ let n = this.logicalToNative.get(e) ?? [];
946
+ for (let e of n) {
947
+ let n = this.nativeLayerInstances.get(e);
948
+ n && (t ? this.map.hasLayer(n) || this.map.addLayer(n) : this.map.hasLayer(n) && this.map.removeLayer(n));
949
+ }
950
+ }
951
+ getSourceData(e) {
952
+ for (let [t, n] of this.nativeLayerToSource.entries()) {
953
+ if (n !== e) continue;
954
+ let r = this.nativeLayerInstances.get(t), i = r && typeof r.toGeoJSON == "function" ? r.toGeoJSON() : null;
955
+ if (i) {
956
+ if (i.type === "FeatureCollection") return i;
957
+ if (i.type === "Feature") return {
958
+ type: "FeatureCollection",
959
+ features: [i]
960
+ };
961
+ }
962
+ }
963
+ return null;
964
+ }
965
+ setSourceData(e, t) {
966
+ let n = !1;
967
+ for (let [r, i] of this.nativeLayerToSource.entries()) {
968
+ if (i !== e) continue;
969
+ let a = this.nativeLayerInstances.get(r);
970
+ !a || typeof a.clearLayers != "function" || typeof a.addData != "function" || (a.clearLayers(), a.addData(t), n = !0);
971
+ }
972
+ return n;
973
+ }
974
+ queryVectorFeaturesAtPixel(e, t, n, r) {
975
+ let i = [], a = f.point(t[0], t[1]);
976
+ for (let [t, o] of this.logicalToNative.entries()) if (!(r && !r.has(t))) for (let r of o) {
977
+ let o = this.nativeLayerInstances.get(r);
978
+ if (!o || typeof o.getLayers != "function") continue;
979
+ let s = o;
980
+ for (let r of s.getLayers()) if (this.isHitAtPixel(e, r, a, n)) {
981
+ let e = r.feature;
982
+ e?.properties && i.push({
983
+ layerId: t,
984
+ properties: e.properties
985
+ });
986
+ }
987
+ }
988
+ return i;
989
+ }
990
+ isHitAtPixel(e, t, n, r) {
991
+ if (t instanceof f.CircleMarker) {
992
+ let i = e.latLngToContainerPoint(t.getLatLng()), a = t.getRadius() + r;
993
+ return i.distanceTo(n) <= a;
994
+ }
995
+ if (t instanceof f.Polygon) {
996
+ let i = t.getLatLngs(), a = (t) => t.map((t) => e.latLngToContainerPoint(t)), o = i[0][0], s = o != null && typeof o.lat == "number", c = [];
997
+ if (s) c.push(i.map(a));
998
+ else for (let e of i) c.push(e.map(a));
999
+ if (t.options?.fill === !1) {
1000
+ for (let e of c) for (let t of e) for (let e = 0; e < t.length; e++) {
1001
+ let i = t[e], a = t[(e + 1) % t.length];
1002
+ if (this.pointToSegmentDistancePx(n, i, a) <= r) return !0;
1003
+ }
1004
+ return !1;
1005
+ }
1006
+ if (!t.getBounds().contains(e.containerPointToLatLng(n))) return !1;
1007
+ for (let e of c) {
1008
+ let [t, ...r] = e;
1009
+ if (!(!t || !this.pointInRing(n, t)) && !r.some((e) => this.pointInRing(n, e))) return !0;
1010
+ }
1011
+ return !1;
1012
+ }
1013
+ if (t instanceof f.Polyline) {
1014
+ let i = t.getLatLngs().flat(2);
1015
+ for (let t = 0; t < i.length - 1; t++) {
1016
+ let a = e.latLngToContainerPoint(i[t]), o = e.latLngToContainerPoint(i[t + 1]);
1017
+ if (this.pointToSegmentDistancePx(n, a, o) <= r) return !0;
1018
+ }
1019
+ }
1020
+ return !1;
1021
+ }
1022
+ pointInRing(e, t) {
1023
+ let n = !1;
1024
+ for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
1025
+ let a = t[r].x, o = t[r].y, s = t[i].x, c = t[i].y;
1026
+ o > e.y != c > e.y && e.x < (s - a) * (e.y - o) / (c - o) + a && (n = !n);
1027
+ }
1028
+ return n;
1029
+ }
1030
+ pointToSegmentDistancePx(e, t, n) {
1031
+ let r = n.x - t.x, i = n.y - t.y, a = r * r + i * i;
1032
+ if (a === 0) return e.distanceTo(t);
1033
+ let o = Math.max(0, Math.min(1, ((e.x - t.x) * r + (e.y - t.y) * i) / a));
1034
+ return e.distanceTo(f.point(t.x + o * r, t.y + o * i));
1035
+ }
1036
+ registerInlineLayer(e, t, n) {
1037
+ let r = this.resolveInsertIndex(n), i = [];
1038
+ for (let n = 0; n < t.length; n++) {
1039
+ let r = `${e}-inline-${n}`;
1040
+ this.nativeLayerInstances.set(r, t[n]), i.push(r);
1041
+ }
1042
+ this.logicalToNative.set(e, i), this.upsertLogicalOrder(e, r);
1043
+ }
1044
+ unregisterInlineLayer(e) {
1045
+ let t = this.logicalToNative.get(e) ?? [];
1046
+ for (let e of t) this.nativeLayerInstances.delete(e);
1047
+ this.logicalToNative.delete(e), this.logicalOrder = this.logicalOrder.filter((t) => t !== e);
1048
+ }
1049
+ getVisibleWMSLayers() {
1050
+ let e = [];
1051
+ for (let [t, n] of this.logicalToWMSSource.entries()) this.logicalToNative.has(t) && e.push({
1052
+ layerId: t,
1053
+ ...n
1054
+ });
1055
+ return e;
1056
+ }
1057
+ }, j = class {
1058
+ constructor(e, t) {
1059
+ this.map = e, this.layerService = t;
1060
+ }
1061
+ async queryFeatures(t, n = {}) {
1062
+ let { pixel: r } = t, i = n.tolerancePx ?? 5, a = [], o = n.layerIds?.length ? new Set(n.layerIds) : null, s = this.layerService.queryVectorFeaturesAtPixel(this.map, r, i, o ?? void 0);
1063
+ for (let e of s) a.push({
1064
+ layerId: e.layerId,
1065
+ properties: e.properties,
1066
+ source: "vector"
1067
+ });
1068
+ if (n.includeWMS) {
1069
+ let t = this.map.getBounds(), n = this.map.getSize(), i = {
1070
+ west: t.getWest(),
1071
+ south: t.getSouth(),
1072
+ east: t.getEast(),
1073
+ north: t.getNorth()
1074
+ }, s = this.layerService.getVisibleWMSLayers(), c = await Promise.all(s.filter((e) => !o || o.has(e.layerId)).map((t) => e({
1075
+ sourceConfig: t.sourceConfig,
1076
+ layerId: t.layerId,
1077
+ layerTitle: t.layerTitle,
1078
+ bounds: i,
1079
+ containerWidth: n.x,
1080
+ containerHeight: n.y,
1081
+ pixelX: r[0],
1082
+ pixelY: r[1]
1083
+ })));
1084
+ for (let e of c) a.push(...e);
1085
+ }
1086
+ return a;
1087
+ }
1088
+ };
1089
+ //#endregion
1090
+ //#region src/map/leaflet-services/MapMarkerService.ts
1091
+ function M(e) {
1092
+ return f.divIcon({
1093
+ html: d(e),
1094
+ className: "",
1095
+ iconSize: [24, 36],
1096
+ iconAnchor: [12, 36]
1097
+ });
1098
+ }
1099
+ var N = class {
1100
+ constructor(e) {
1101
+ this.map = e, this.markers = /* @__PURE__ */ new Map();
1102
+ }
1103
+ add(e, t, n = {}) {
1104
+ this.remove(e);
1105
+ let r = n.color ?? "#e63946", i = f.marker([t[1], t[0]], {
1106
+ icon: M(r),
1107
+ draggable: n.draggable ?? !1
1108
+ }).addTo(this.map);
1109
+ this.markers.set(e, i);
1110
+ }
1111
+ move(e, t) {
1112
+ this.markers.get(e)?.setLatLng([t[1], t[0]]);
1113
+ }
1114
+ remove(e) {
1115
+ let t = this.markers.get(e);
1116
+ t && (t.remove(), this.markers.delete(e));
1117
+ }
1118
+ }, P = class extends i {
1119
+ constructor() {
1120
+ super(), this.engineId = "leaflet", this.engineVersion = p, this.markerService = null, this.core = new y(this.store, this.events), this.toolService = new b({}), this.logicalLayerExecutor = new r(), this.queryExecutor = new o(), this.queryService = this.queryExecutor, this.mapFactory = new O(), this.core.onMapReady?.((e) => {
1121
+ let t = new A(e, this.store);
1122
+ this.core.setLayerOrderRegistry(t), this.logicalLayerExecutor.bind(t), this.queryExecutor.bind(new j(e, t)), this.markerService = new N(e);
1123
+ });
1124
+ }
1125
+ initialize(e, t) {
1126
+ this.core.initialize(e, t);
1127
+ }
1128
+ getViewportState() {
1129
+ return this.core.getViewportState();
1130
+ }
1131
+ setViewport(e, t) {
1132
+ this.core.setViewport(e, t);
1133
+ }
1134
+ getZoom() {
1135
+ return this.core.getZoom();
1136
+ }
1137
+ setZoom(e) {
1138
+ this.core.setZoom(e);
1139
+ }
1140
+ getBearing() {
1141
+ return this.core.getBearing();
1142
+ }
1143
+ setBearing(e) {
1144
+ this.core.setBearing(e);
1145
+ }
1146
+ getPitch() {
1147
+ return this.core.getPitch();
1148
+ }
1149
+ setPitch(e) {
1150
+ this.core.setPitch(e);
1151
+ }
1152
+ setTerrainEnabled(e) {
1153
+ return !1;
1154
+ }
1155
+ isTerrainEnabled() {
1156
+ return null;
1157
+ }
1158
+ resetNorth() {
1159
+ this.core.resetNorth();
1160
+ }
1161
+ resetNorthPitch() {
1162
+ this.core.resetNorthPitch();
1163
+ }
1164
+ fitBounds(e) {
1165
+ this.core.fitBounds(e);
1166
+ }
1167
+ setProjection(e) {
1168
+ return !1;
1169
+ }
1170
+ getProjection() {
1171
+ return null;
1172
+ }
1173
+ setCursor(e) {
1174
+ this.core.setCursor(e);
1175
+ }
1176
+ setPanEnabled(e) {
1177
+ this.core.setPanEnabled(e);
1178
+ }
1179
+ setTouchCaptureEnabled(e) {}
1180
+ setDoubleClickZoomEnabled(e) {
1181
+ this.core.setDoubleClickZoomEnabled(e);
1182
+ }
1183
+ setLayerVisibility(e, t) {
1184
+ this.logicalLayerExecutor.setLayerVisibility(e, t);
1185
+ }
1186
+ setLayerOpacity(e, t) {
1187
+ this.logicalLayerExecutor.setLayerOpacity(e, t);
1188
+ }
1189
+ getSourceData(e) {
1190
+ return this.core.getSourceData(e) ?? this.logicalLayerExecutor.getSourceData(e);
1191
+ }
1192
+ project(e) {
1193
+ return this.core.project(e);
1194
+ }
1195
+ unproject(e) {
1196
+ return this.core.unproject(e);
1197
+ }
1198
+ getNavigationCapabilities() {
1199
+ return this.core.getNavigationCapabilities();
1200
+ }
1201
+ async engineAddLayer(e, t) {
1202
+ return await this.logicalLayerExecutor.addLayer(e, t) ? !0 : this.core.addLayer(e, t);
1203
+ }
1204
+ removeLogicalLayer(e) {
1205
+ this.removeLayer(e);
1206
+ }
1207
+ engineAddSource(e, t) {
1208
+ this.core.addSource(e, t);
1209
+ }
1210
+ engineRemoveLayer(e) {
1211
+ this.logicalLayerExecutor.removeLayer(e), this.core.removeLayer(e);
1212
+ }
1213
+ engineRemoveSource(e) {
1214
+ this.core.removeSource(e);
1215
+ }
1216
+ getCore() {
1217
+ return this.core;
1218
+ }
1219
+ getLogicalLayerExecutor() {
1220
+ return this.logicalLayerExecutor;
1221
+ }
1222
+ getMarkerService() {
1223
+ return this.markerService;
1224
+ }
1225
+ };
1226
+ //#endregion
1227
+ export { P as LeafletAdapter };