@npm9912/v-map 0.1.1 → 0.2.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 (127) hide show
  1. package/README.md +17 -5
  2. package/dist/cjs/{cesium-provider-BiFFyAl9.js → cesium-provider-CTtu9eTD.js} +6 -5
  3. package/dist/cjs/{deck-provider-Ctq3Q8a1.js → deck-provider-fNa818HH.js} +9 -9
  4. package/dist/cjs/events-BMG7RKne.js +11 -0
  5. package/dist/cjs/{geotiff-source-RaNzzWkC.js → geotiff-source-B9ARUE9z.js} +1 -1
  6. package/dist/cjs/{index-ISOEpMC3.js → index-9APmzoa2.js} +6 -6
  7. package/dist/cjs/{index-CbVT-Con.js → index-BJg0ncfC.js} +4 -4
  8. package/dist/cjs/{index-CJvvX4yx.js → index-C1ubapwF.js} +4 -4
  9. package/dist/cjs/{index-B8LHqjyg.js → index-ChrKyU6i.js} +4 -4
  10. package/dist/cjs/{index-JSwBbvGA.js → index-DmGHwivM.js} +1 -0
  11. package/dist/cjs/{layer-extension-B_olS0rc.js → layer-extension-D3a-1DFI.js} +1 -1
  12. package/dist/cjs/{leaflet-provider-DOqfs7g5.js → leaflet-provider-7Nw-AdV_.js} +6 -5
  13. package/dist/cjs/loader.cjs.js +2 -2
  14. package/dist/cjs/{messages-D7h4m8Tx.js → messages-CFCxeG8p.js} +0 -9
  15. package/dist/cjs/{openlayers-provider-Dfeg6L4n.js → openlayers-provider-DMxYtFkS.js} +5 -4
  16. package/dist/cjs/{polygon-layer-B9PrN7vr.js → polygon-layer-Dx1ZWZP0.js} +1 -1
  17. package/dist/cjs/{scenegraph-layer-DwNoxQdi.js → scenegraph-layer-ctLehP0q.js} +1 -1
  18. package/dist/cjs/v-map-builder.cjs.entry.js +4 -3
  19. package/dist/cjs/v-map-error.cjs.entry.js +121 -0
  20. package/dist/cjs/v-map-layer-geojson_12.cjs.entry.js +11 -10
  21. package/dist/cjs/{v-map-layer-helper-iAzxAg9I.js → v-map-layer-helper-DnWpjZ_Q.js} +7 -6
  22. package/dist/cjs/v-map-layer-terrain-geotiff.cjs.entry.js +5 -4
  23. package/dist/cjs/v-map-layercontrol.cjs.entry.js +1 -1
  24. package/dist/cjs/v-map.cjs.js +2 -2
  25. package/dist/cjs/{v-map.v-map-layer-osm.v-map-layergroup-BsXp3BoL.js → v-map.v-map-layer-osm.v-map-layergroup-BJ3_NqAj.js} +16 -15
  26. package/dist/cjs/v-map_3.cjs.entry.js +5 -4
  27. package/dist/collection/collection-manifest.json +1 -0
  28. package/dist/collection/components/v-map/v-map.css +3 -0
  29. package/dist/collection/components/v-map-error/v-map-error.css +136 -0
  30. package/dist/collection/components/v-map-error/v-map-error.js +277 -0
  31. package/dist/collection/components/v-map-layer-geojson/v-map-layer-geojson.js +1 -1
  32. package/dist/collection/components/v-map-layer-terrain/v-map-layer-terrain.js +1 -1
  33. package/dist/collection/components/v-map-layer-terrain-geotiff/v-map-layer-terrain-geotiff.js +1 -1
  34. package/dist/collection/components/v-map-layer-tile3d/v-map-layer-tile3d.js +1 -1
  35. package/dist/collection/components/v-map-layer-wcs/v-map-layer-wcs.js +1 -1
  36. package/dist/collection/components/v-map-layer-wfs/v-map-layer-wfs.js +1 -1
  37. package/dist/collection/components/v-map-layergroup/v-map-layergroup.js +1 -1
  38. package/dist/collection/components/v-map-style/v-map-style.js +1 -1
  39. package/dist/components/cesium-provider.js +1 -1
  40. package/dist/components/deck-provider.js +1 -1
  41. package/dist/components/events.js +1 -1
  42. package/dist/components/geotiff-source.js +1 -1
  43. package/dist/components/leaflet-provider.js +1 -1
  44. package/dist/components/logger.js +1 -0
  45. package/dist/components/openlayers-provider.js +1 -1
  46. package/dist/components/v-map-builder.js +2 -2
  47. package/dist/components/v-map-error.d.ts +11 -0
  48. package/dist/components/v-map-error.js +1 -0
  49. package/dist/components/v-map-layer-geojson2.js +1 -1
  50. package/dist/components/v-map-layer-geotiff2.js +1 -1
  51. package/dist/components/v-map-layer-google2.js +1 -1
  52. package/dist/components/v-map-layer-helper.js +1 -1
  53. package/dist/components/v-map-layer-osm2.js +1 -1
  54. package/dist/components/v-map-layer-scatterplot2.js +1 -1
  55. package/dist/components/v-map-layer-terrain-geotiff.js +1 -1
  56. package/dist/components/v-map-layer-terrain2.js +1 -1
  57. package/dist/components/v-map-layer-tile3d2.js +1 -1
  58. package/dist/components/v-map-layer-wcs2.js +1 -1
  59. package/dist/components/v-map-layer-wfs2.js +1 -1
  60. package/dist/components/v-map-layer-wkt2.js +1 -1
  61. package/dist/components/v-map-layer-wms2.js +1 -1
  62. package/dist/components/v-map-layer-xyz2.js +1 -1
  63. package/dist/components/v-map-layergroup2.js +1 -1
  64. package/dist/components/v-map-style2.js +2 -2
  65. package/dist/components/v-map2.js +1 -1
  66. package/dist/esm/{cesium-provider-BJfAup3w.js → cesium-provider-Bh__cBGf.js} +6 -5
  67. package/dist/esm/{deck-provider-C7U9VDEq.js → deck-provider-DxIpS4lY.js} +9 -9
  68. package/dist/esm/events-CrV_misM.js +9 -0
  69. package/dist/esm/{geotiff-source-esnDnC-u.js → geotiff-source-BRjO-Dvr.js} +1 -1
  70. package/dist/esm/{index-BIEmlzCf.js → index-Bh2gBu9u.js} +5 -5
  71. package/dist/esm/{index-jzneDarq.js → index-BoNyIrdq.js} +1 -1
  72. package/dist/esm/{index-jN06TXUp.js → index-C3mnOs0I.js} +4 -4
  73. package/dist/esm/{index-B1zwA4IC.js → index-C63kfbil.js} +6 -6
  74. package/dist/esm/{index-DbSdn93t.js → index-DxbztwCv.js} +7 -7
  75. package/dist/esm/{layer-extension-CZXK5goK.js → layer-extension-C5Y2UES3.js} +1 -1
  76. package/dist/esm/{leaflet-provider-Q41TB6ku.js → leaflet-provider-k6JSYiYX.js} +6 -5
  77. package/dist/esm/loader.js +3 -3
  78. package/dist/esm/{messages-CMKJzsgL.js → messages-QJHuuz0g.js} +1 -9
  79. package/dist/esm/{openlayers-provider-CMsDsQTQ.js → openlayers-provider-DIquf3Tx.js} +5 -4
  80. package/dist/esm/{polygon-layer-ByhxGhWC.js → polygon-layer-ZIT5mJy5.js} +1 -1
  81. package/dist/esm/{scenegraph-layer-09K_B6DT.js → scenegraph-layer-CNIRd2uu.js} +1 -1
  82. package/dist/esm/v-map-builder.entry.js +3 -2
  83. package/dist/esm/v-map-error.entry.js +119 -0
  84. package/dist/esm/v-map-layer-geojson_12.entry.js +10 -9
  85. package/dist/esm/{v-map-layer-helper-Dys44Cgo.js → v-map-layer-helper-CuHYsU9f.js} +2 -1
  86. package/dist/esm/v-map-layer-terrain-geotiff.entry.js +5 -4
  87. package/dist/esm/v-map-layercontrol.entry.js +1 -1
  88. package/dist/esm/v-map.js +3 -3
  89. package/dist/esm/{v-map.v-map-layer-osm.v-map-layergroup-B4pFHuSf.js → v-map.v-map-layer-osm.v-map-layergroup-Zwdvm9PG.js} +10 -9
  90. package/dist/esm/v-map_3.entry.js +5 -4
  91. package/dist/types/components/v-map-error/v-map-error.d.ts +79 -0
  92. package/dist/types/components.d.ts +128 -0
  93. package/dist/v-map/p-05ee633f.entry.js +1 -0
  94. package/dist/v-map/p-08ad1392.entry.js +1 -0
  95. package/dist/v-map/p-2-mR3oVa.js +1 -0
  96. package/dist/v-map/{p-c21c93fe.entry.js → p-3a57b64a.entry.js} +1 -1
  97. package/dist/v-map/p-58dda864.entry.js +1 -0
  98. package/dist/v-map/p-915314c0.entry.js +10 -0
  99. package/dist/v-map/{p-MyTSFnEk.js → p-9Rt23jlQ.js} +1 -1
  100. package/dist/v-map/p-BSsFEMZP.js +1 -0
  101. package/dist/v-map/{p-jzneDarq.js → p-BoNyIrdq.js} +2 -2
  102. package/dist/v-map/p-BpE6L1g0.js +1 -0
  103. package/dist/v-map/{p-DvHXtWUg.js → p-C0M0-Kvt.js} +1 -1
  104. package/dist/v-map/p-CbiLpFhO.js +1 -0
  105. package/dist/v-map/p-Ci70E1EM.js +1 -0
  106. package/dist/v-map/p-CrV_misM.js +1 -0
  107. package/dist/v-map/{p-DrOQ9V4h.js → p-DAf4itFZ.js} +1 -1
  108. package/dist/v-map/p-DVBtCUtQ.js +1 -0
  109. package/dist/v-map/{p-CZqY0yW4.js → p-DuJ_mTaq.js} +1 -1
  110. package/dist/v-map/p-G6iftXUC.js +1 -0
  111. package/dist/v-map/{p-CMKJzsgL.js → p-QJHuuz0g.js} +1 -1
  112. package/dist/v-map/{p-aa410e64.entry.js → p-e21ea0ce.entry.js} +2 -2
  113. package/dist/v-map/{p-DmICdG34.js → p-rCyRSFJb.js} +2 -2
  114. package/dist/v-map/{p-CafTHT9i.js → p-vhbi5XXi.js} +1 -1
  115. package/dist/v-map/{p-Dckgonw8.js → p-yXLNXXx-.js} +1 -1
  116. package/dist/v-map/v-map.esm.js +1 -1
  117. package/package.json +1 -1
  118. package/dist/v-map/p--vVleK-M.js +0 -1
  119. package/dist/v-map/p-09d10db0.entry.js +0 -1
  120. package/dist/v-map/p-5eba6058.entry.js +0 -10
  121. package/dist/v-map/p-6b102336.entry.js +0 -1
  122. package/dist/v-map/p-BdijL4Av.js +0 -1
  123. package/dist/v-map/p-BeFu0ap4.js +0 -1
  124. package/dist/v-map/p-BxFJezdK.js +0 -1
  125. package/dist/v-map/p-DCTHyf58.js +0 -1
  126. package/dist/v-map/p-WaMDUuAz.js +0 -1
  127. package/dist/v-map/p-uiIP-taz.js +0 -1
@@ -0,0 +1,277 @@
1
+ import { Host, h, } from "@stencil/core";
2
+ import { VMapEvents } from "../../utils/events";
3
+ const MSG_COMPONENT = 'v-map-error';
4
+ /**
5
+ * `<v-map-error>` lauscht auf das `vmap-error` Event seiner Eltern-`<v-map>`
6
+ * (oder einer per `for`-Attribut adressierten Karte) und rendert die Fehler
7
+ * als kleine, opinionated gestylte Toast-Stapel innerhalb des Karten-Containers.
8
+ *
9
+ * Damit können einfache HTML-Beispiele Fehler sichtbar machen, ohne eine
10
+ * Zeile JavaScript zu schreiben.
11
+ *
12
+ * @example
13
+ * ```html
14
+ * <v-map flavour="ol">
15
+ * <v-map-error position="top-right" auto-dismiss="5000"></v-map-error>
16
+ * <v-map-layergroup group-title="Basiskarten" basemapid="OSM-BASE">
17
+ * <v-map-layer-osm id="OSM-BASE" label="OSM"></v-map-layer-osm>
18
+ * </v-map-layergroup>
19
+ * </v-map>
20
+ * ```
21
+ *
22
+ * @part container - Wrapper um den gesamten Toast-Stapel
23
+ * @part toast - Einzelner Fehler-Toast (anpassbar via `::part(toast)`)
24
+ * @part badge - Typ-Badge innerhalb des Toasts (z. B. "network", "validation")
25
+ * @part message - Fehler-Nachricht innerhalb des Toasts
26
+ * @part close - Schliessen-Button innerhalb des Toasts
27
+ */
28
+ export class VMapError {
29
+ host;
30
+ /**
31
+ * ID der `<v-map>`-Karte, deren Fehler angezeigt werden sollen.
32
+ * Wenn nicht angegeben, hängt sich die Komponente an das nächste
33
+ * `<v-map>`-Vorfahrenelement im DOM-Baum.
34
+ */
35
+ for;
36
+ /**
37
+ * Position des Toast-Stapels innerhalb des `<v-map>`-Containers.
38
+ * @default 'top-right'
39
+ */
40
+ position = 'top-right';
41
+ /**
42
+ * Auto-Dismiss-Zeit in Millisekunden. `0` deaktiviert das automatische
43
+ * Ausblenden — Toasts bleiben dann sichtbar, bis sie manuell geschlossen
44
+ * oder durch einen neueren Fehler aus dem Stapel gedrängt werden.
45
+ * @default 5000
46
+ */
47
+ autoDismiss = 5000;
48
+ /**
49
+ * Maximale Anzahl gleichzeitig sichtbarer Toasts. Ältere werden bei
50
+ * Überschreitung am oberen Ende des Stapels entfernt.
51
+ * @default 3
52
+ */
53
+ max = 3;
54
+ /**
55
+ * Zusätzliches Logging in die Browser-Console.
56
+ * - `'none'` (Default): nur Toast-Anzeige, kein Console-Output
57
+ * - `'console'`: jeder Fehler wird zusätzlich mit `console.error` geloggt
58
+ * @default 'none'
59
+ */
60
+ log = 'none';
61
+ toasts = [];
62
+ mapElement = null;
63
+ boundHandler = (e) => this.onError(e);
64
+ retryTimer;
65
+ nextId = 0;
66
+ // ---- Lifecycle ----------------------------------------------------------
67
+ connectedCallback() {
68
+ this.attach();
69
+ }
70
+ disconnectedCallback() {
71
+ this.detach();
72
+ for (const t of this.toasts) {
73
+ if (t.timeoutId !== undefined)
74
+ clearTimeout(t.timeoutId);
75
+ }
76
+ this.toasts = [];
77
+ if (this.retryTimer !== undefined) {
78
+ clearTimeout(this.retryTimer);
79
+ this.retryTimer = undefined;
80
+ }
81
+ }
82
+ // ---- DOM-Discovery ------------------------------------------------------
83
+ attach(retry = 0) {
84
+ const target = this.for
85
+ ? document.getElementById(this.for)
86
+ : this.host.closest('v-map');
87
+ if (target instanceof HTMLElement) {
88
+ this.mapElement = target;
89
+ this.mapElement.addEventListener(VMapEvents.Error, this.boundHandler);
90
+ return;
91
+ }
92
+ // Karte noch nicht im DOM - kurz warten und erneut versuchen
93
+ if (retry < 50) {
94
+ this.retryTimer = window.setTimeout(() => this.attach(retry + 1), 100);
95
+ }
96
+ }
97
+ detach() {
98
+ if (this.mapElement) {
99
+ this.mapElement.removeEventListener(VMapEvents.Error, this.boundHandler);
100
+ this.mapElement = null;
101
+ }
102
+ }
103
+ // ---- Error Handling -----------------------------------------------------
104
+ onError(e) {
105
+ const detail = e.detail;
106
+ if (!detail)
107
+ return;
108
+ if (this.log === 'console') {
109
+ console.error(`[${MSG_COMPONENT}]`, detail.type, detail.message, detail);
110
+ }
111
+ const id = this.nextId++;
112
+ const toast = { id, detail };
113
+ if (this.autoDismiss > 0) {
114
+ toast.timeoutId = window.setTimeout(() => this.dismiss(id), this.autoDismiss);
115
+ }
116
+ const next = [...this.toasts, toast];
117
+ while (next.length > this.max) {
118
+ const removed = next.shift();
119
+ if (removed?.timeoutId !== undefined)
120
+ clearTimeout(removed.timeoutId);
121
+ }
122
+ this.toasts = next;
123
+ }
124
+ dismiss(id) {
125
+ const target = this.toasts.find(t => t.id === id);
126
+ if (target?.timeoutId !== undefined)
127
+ clearTimeout(target.timeoutId);
128
+ this.toasts = this.toasts.filter(t => t.id !== id);
129
+ }
130
+ // ---- Render -------------------------------------------------------------
131
+ render() {
132
+ return (h(Host, { key: 'edec9031306084f0b55ac6ef5b21e69995ca912c' }, h("div", { key: '665451bfd7a0957b947715654707705904e11d6b', class: "stack", part: "container" }, this.toasts.map(t => (h("div", { key: t.id, class: "toast", part: "toast", role: "alert", "aria-live": "assertive" }, h("span", { class: "badge", part: "badge" }, t.detail.type), h("span", { class: "message", part: "message" }, t.detail.message), h("button", { type: "button", class: "close", part: "close", "aria-label": "Schliessen", onClick: () => this.dismiss(t.id) }, '\u00d7')))))));
133
+ }
134
+ static get is() { return "v-map-error"; }
135
+ static get encapsulation() { return "shadow"; }
136
+ static get originalStyleUrls() {
137
+ return {
138
+ "$": ["v-map-error.css"]
139
+ };
140
+ }
141
+ static get styleUrls() {
142
+ return {
143
+ "$": ["v-map-error.css"]
144
+ };
145
+ }
146
+ static get properties() {
147
+ return {
148
+ "for": {
149
+ "type": "string",
150
+ "mutable": false,
151
+ "complexType": {
152
+ "original": "string",
153
+ "resolved": "string",
154
+ "references": {}
155
+ },
156
+ "required": false,
157
+ "optional": true,
158
+ "docs": {
159
+ "tags": [],
160
+ "text": "ID der `<v-map>`-Karte, deren Fehler angezeigt werden sollen.\nWenn nicht angegeben, h\u00E4ngt sich die Komponente an das n\u00E4chste\n`<v-map>`-Vorfahrenelement im DOM-Baum."
161
+ },
162
+ "getter": false,
163
+ "setter": false,
164
+ "reflect": false,
165
+ "attribute": "for"
166
+ },
167
+ "position": {
168
+ "type": "string",
169
+ "mutable": false,
170
+ "complexType": {
171
+ "original": "ToastPosition",
172
+ "resolved": "\"bottom\" | \"bottom-left\" | \"bottom-right\" | \"top\" | \"top-left\" | \"top-right\"",
173
+ "references": {
174
+ "ToastPosition": {
175
+ "location": "global",
176
+ "id": "global::ToastPosition"
177
+ }
178
+ }
179
+ },
180
+ "required": false,
181
+ "optional": false,
182
+ "docs": {
183
+ "tags": [{
184
+ "name": "default",
185
+ "text": "'top-right'"
186
+ }],
187
+ "text": "Position des Toast-Stapels innerhalb des `<v-map>`-Containers."
188
+ },
189
+ "getter": false,
190
+ "setter": false,
191
+ "reflect": true,
192
+ "attribute": "position",
193
+ "defaultValue": "'top-right'"
194
+ },
195
+ "autoDismiss": {
196
+ "type": "number",
197
+ "mutable": false,
198
+ "complexType": {
199
+ "original": "number",
200
+ "resolved": "number",
201
+ "references": {}
202
+ },
203
+ "required": false,
204
+ "optional": false,
205
+ "docs": {
206
+ "tags": [{
207
+ "name": "default",
208
+ "text": "5000"
209
+ }],
210
+ "text": "Auto-Dismiss-Zeit in Millisekunden. `0` deaktiviert das automatische\nAusblenden \u2014 Toasts bleiben dann sichtbar, bis sie manuell geschlossen\noder durch einen neueren Fehler aus dem Stapel gedr\u00E4ngt werden."
211
+ },
212
+ "getter": false,
213
+ "setter": false,
214
+ "reflect": false,
215
+ "attribute": "auto-dismiss",
216
+ "defaultValue": "5000"
217
+ },
218
+ "max": {
219
+ "type": "number",
220
+ "mutable": false,
221
+ "complexType": {
222
+ "original": "number",
223
+ "resolved": "number",
224
+ "references": {}
225
+ },
226
+ "required": false,
227
+ "optional": false,
228
+ "docs": {
229
+ "tags": [{
230
+ "name": "default",
231
+ "text": "3"
232
+ }],
233
+ "text": "Maximale Anzahl gleichzeitig sichtbarer Toasts. \u00C4ltere werden bei\n\u00DCberschreitung am oberen Ende des Stapels entfernt."
234
+ },
235
+ "getter": false,
236
+ "setter": false,
237
+ "reflect": false,
238
+ "attribute": "max",
239
+ "defaultValue": "3"
240
+ },
241
+ "log": {
242
+ "type": "string",
243
+ "mutable": false,
244
+ "complexType": {
245
+ "original": "LogMode",
246
+ "resolved": "\"console\" | \"none\"",
247
+ "references": {
248
+ "LogMode": {
249
+ "location": "global",
250
+ "id": "global::LogMode"
251
+ }
252
+ }
253
+ },
254
+ "required": false,
255
+ "optional": false,
256
+ "docs": {
257
+ "tags": [{
258
+ "name": "default",
259
+ "text": "'none'"
260
+ }],
261
+ "text": "Zus\u00E4tzliches Logging in die Browser-Console.\n- `'none'` (Default): nur Toast-Anzeige, kein Console-Output\n- `'console'`: jeder Fehler wird zus\u00E4tzlich mit `console.error` geloggt"
262
+ },
263
+ "getter": false,
264
+ "setter": false,
265
+ "reflect": false,
266
+ "attribute": "log",
267
+ "defaultValue": "'none'"
268
+ }
269
+ };
270
+ }
271
+ static get states() {
272
+ return {
273
+ "toasts": {}
274
+ };
275
+ }
276
+ static get elementRef() { return "host"; }
277
+ }
@@ -363,7 +363,7 @@ export class VMapLayerGeoJSON {
363
363
  return config;
364
364
  }
365
365
  render() {
366
- return h("slot", { key: '093a5de19ea7090df1883b15e379b604dfabc1a1', name: "geojson", onSlotchange: this.onSlotChange });
366
+ return h("slot", { key: '92aa382d5258a981896ef7316cc269b095304d13', name: "geojson", onSlotchange: this.onSlotChange });
367
367
  }
368
368
  static get is() { return "v-map-layer-geojson"; }
369
369
  static get encapsulation() { return "shadow"; }
@@ -209,7 +209,7 @@ export class VMapLayerTerrain {
209
209
  return config;
210
210
  }
211
211
  render() {
212
- return h("slot", { key: 'c199c1789ddbfdf0c9327a154d82d2ffac090b33' });
212
+ return h("slot", { key: 'fa57254fc8c1a200ca5e2788bcc9f2beaa388a49' });
213
213
  }
214
214
  static get is() { return "v-map-layer-terrain"; }
215
215
  static get encapsulation() { return "shadow"; }
@@ -187,7 +187,7 @@ export class VMapLayerTerrainGeotiff {
187
187
  log(MSG_COMPONENT + MSG.COMPONENT_WILL_RENDER);
188
188
  }
189
189
  render() {
190
- return h("slot", { key: 'ec36579674879e6def334a8fc18a471aea8f286a' });
190
+ return h("slot", { key: '9d6029408f7126a557ae123b418b7aed610b798c' });
191
191
  }
192
192
  static get is() { return "v-map-layer-terrain-geotiff"; }
193
193
  static get encapsulation() { return "shadow"; }
@@ -201,7 +201,7 @@ export class VMapLayerTile3d {
201
201
  return config;
202
202
  }
203
203
  render() {
204
- return h("slot", { key: '39223347c38080929d4865fa5ee2de4f3b1f87b1' });
204
+ return h("slot", { key: '808774d80fbe0948330b8e7f94c08d331bc49a99' });
205
205
  }
206
206
  static get is() { return "v-map-layer-tile3d"; }
207
207
  static get encapsulation() { return "shadow"; }
@@ -129,7 +129,7 @@ export class VMapLayerWcs {
129
129
  };
130
130
  }
131
131
  render() {
132
- return h("slot", { key: 'b42cc02537db832f69250cb4545f7c15ce1e5a93' });
132
+ return h("slot", { key: '02f2834e39c6e4d041f401d982a97af14d1c3e4d' });
133
133
  }
134
134
  static get is() { return "v-map-layer-wcs"; }
135
135
  static get encapsulation() { return "shadow"; }
@@ -182,7 +182,7 @@ export class VMapLayerWfs {
182
182
  return config;
183
183
  }
184
184
  render() {
185
- return h("slot", { key: '347b5c4d982518a9f9c0ed25b1701d06d3f45134' });
185
+ return h("slot", { key: 'fb3fcca9a332f5b0bacce83b61152869b9afd820' });
186
186
  }
187
187
  static get is() { return "v-map-layer-wfs"; }
188
188
  static get encapsulation() { return "shadow"; }
@@ -94,7 +94,7 @@ export class VMapLayerGroup {
94
94
  return this.groupId;
95
95
  }
96
96
  render() {
97
- return h("slot", { key: '584a5816d8f73071bf257e3f70a4c2baea2d2f56' });
97
+ return h("slot", { key: 'cffd8e9ece1377275f6d23503004eeffafa4cfcd' });
98
98
  }
99
99
  static get is() { return "v-map-layergroup"; }
100
100
  static get encapsulation() { return "shadow"; }
@@ -248,7 +248,7 @@ export class VMapStyle {
248
248
  return this.error;
249
249
  }
250
250
  render() {
251
- return (h("div", { key: 'a913bf37c39b0dc70522bb813809c38e5e099ebe', class: "style-container" }, this.isLoading && h("div", { key: 'b8a28051b8ff2ae1d80b1a0af110f9e8342e2260', class: "loading" }, "Loading style..."), this.error && (h("div", { key: 'b7db13abadd3f11f5916296d3e0278ce9044fafc', class: "error" }, "Style Error: ", this.error.message)), this.parsedStyle && (h("div", { key: '56e9327b9794d3eb09c520a17cc1103538f42453', class: "success" }, "Style loaded (", this.format.toUpperCase(), ")", this.getLayerTargets().length > 0 && (h("div", { key: 'b08e604f7fbec96aede1112538b0d785e9b3d226', class: "targets" }, "Targets: ", this.getLayerTargets().join(', '))))), h("slot", { key: '609e6131f414425f639cc81104cbb20da61bc1de' })));
251
+ return (h("div", { key: '8e1c5cdf6914778d39e8dd74a35d92cd65f7f32c', class: "style-container" }, this.isLoading && h("div", { key: '3c82160e21fa5f8a4ece8399b0e5cc42204104f2', class: "loading" }, "Loading style..."), this.error && (h("div", { key: '2017dd34fb9c95595c72611204ad8b7fcb411098', class: "error" }, "Style Error: ", this.error.message)), this.parsedStyle && (h("div", { key: 'a1d2893f784deca67748dd1a757dd0b2aae39974', class: "success" }, "Style loaded (", this.format.toUpperCase(), ")", this.getLayerTargets().length > 0 && (h("div", { key: '4e798d938ed53bbac980b9e98b05960c907b0447', class: "targets" }, "Targets: ", this.getLayerTargets().join(', '))))), h("slot", { key: 'e32cf2619d0347bcf0ded90cc13ddd5a168cc483' })));
252
252
  }
253
253
  static get is() { return "v-map-style"; }
254
254
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- import{w as t,l as e,e as i}from"./events.js";import{C as s}from"./v-map2.js";import{l as r,a,b as n,G as o,g as h}from"./geotiff-source.js";class c{id;_visible=!0;_basemap=null;_layers=new Map;_originalVisible=new Map;_dirty=!0;constructor(t,e=!0){this.id=t,this._visible=e}get visible(){return this._visible}set visible(t){this._visible!==t&&(this._visible=t,this._dirty=!0)}get basemap(){return this._basemap}set basemap(t){this._basemap!==t&&(this._basemap=t,this._dirty=!0)}isDirty(){return this._dirty}addLayer(t){this._layers.has(t.id)||(this._layers.set(t.id,t),this._originalVisible.set(t.id,t.layer.getVisible()),this._dirty=!0)}setLayerElementId(t,e){const i=this._layers.get(t);i&&i.elementId!==e&&(i.elementId=e??null,this._dirty=!0)}removeLayer(t){const e=this._layers.delete(t);return this._originalVisible.delete(t),e&&(this._dirty=!0),e}clear(){this._layers.clear(),this._originalVisible.clear(),this._dirty=!0}apply(){if(this._dirty){for(const[t,e]of this._layers){const i=this._originalVisible.get(t)??!0;let s=this._visible&&i;s&&this._basemap&&(s=e.elementId===this._basemap),e.layer.getVisible()!==s&&e.layer.setVisible(s)}this._dirty=!1}}}class l{_groups=[];_dirty=!0;get groups(){return[...this._groups]}getGroup(t){return this._groups.find((e=>e.id===t))}hasGroup(t){return this._groups.some((e=>e.id===t))}ensureGroup(t,e=!0){let i=this.getGroup(t);return i||(i=new c(t,e),this._groups.push(i),this._dirty=!0,i)}addLayerToGroup(t,e,i){this.ensureGroup(t,e).addLayer(i),this._dirty=!0}removeLayer(t,e=!0){let i=!1;for(const s of this._groups)if(s.removeLayer(t)&&(i=!0,!e))break;return i&&(this._dirty=!0),i}setGroupVisible(t,e){const i=this.getGroup(t);if(!i)throw new Error(`CesiumLayerGroup "${t}" nicht gefunden`);i.visible=e,this._dirty=!0}setBasemap(t,e){const i=this.getGroup(t);if(!i)throw new Error(`CesiumLayerGroup "${t}" nicht gefunden`);i.basemap=e,this._dirty=!0}apply(){if(this._dirty||this._groups.some((t=>t.isDirty()))){for(const t of this._groups)t.apply();this._dirty=!1}}clear(){this._groups=[],this._dirty=!0}}class u{Cesium;layers=new Map;viewer;constructor(t,e){this.viewer=e,this.Cesium=t}replaceLayer(t,e,i){if(!this.Cesium)throw new Error("Cesium must be initialized first. Call init() method.");const s=e.getZIndex(),r=e.getVisible(),a=e.getOpacity();this.removeLayer(t);const n=this.addLayer(t,i);return n.setZIndex(s),n.setVisible(r),n.setOpacity(a),n}addLayer(t,e){if(!this.Cesium)throw new Error("Cesium must be initialized first. Call init() method.");e instanceof this.Cesium.GeoJsonDataSource||e instanceof this.Cesium.DataSource?this.viewer.dataSources.add(e):e instanceof this.Cesium.Cesium3DTileset?(this.viewer.scene.primitives.add(e),e.style||(e.style=new this.Cesium.Cesium3DTileStyle)):e instanceof this.Cesium.ImageryLayer&&this.viewer.imageryLayers.add(e),e.id=t;const i=this.wrapLayer(e);return this.layers.set(t,i),i}addCustomLayer(t,e){return this.layers.set(t,e),e}getLayer(t){const e=this.layers.get(t);if(!e)throw new Error(`Layer mit ID "${t}" nicht gefunden.`);return e}getLayerById(t){return this.getLayer(t)}removeLayer(t){this.getLayer(t).remove(),this.layers.delete(t)}setVisible(t,e){this.getLayer(t).setVisible(e)}setOpacity(t,e){this.getLayer(t).setOpacity(e)}async setZIndex(t,e){const i=this.getLayer(t);await i.setZIndex(e)}wrapLayer(t){return t instanceof this.Cesium.ImageryLayer?this.wrapImageryLayer(t):t instanceof this.Cesium.Cesium3DTileset?this.wrapTilesetLayer(t):this.wrapDataSourceLayer(t)}async sortImageryLayers(t,e,i){const s=this.sort(t,e,i);t.removeAll(!1),s.forEach((e=>t.add(e)))}async sort3DTileSets(t,e,i){const s=this.sort(t,e,i);t.removeAll(),s.forEach((e=>t.add(e)))}async sortDataSources(t,e,i){const s=this.sort(t,e,i);t.removeAll(!1),s.forEach((async e=>await t.add(e)))}sort(t,e,i){t.remove(e,!1);const s=[];for(let e=0;e<t.length;e++)s.push(t.get(e));return s.sort(((t,e)=>(t.zIndex||0)-(e.zIndex||0))),e.zIndex=i,s.push(e),s.sort(((t,e)=>(t.zIndex||0)-(e.zIndex||0))),s}wrapImageryLayer(t){const e=this.viewer.imageryLayers;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>t.alpha,setOpacity:e=>{t.alpha=e},getZIndex:()=>{for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&await this.sortImageryLayers(e,t,i)},remove:()=>e.remove(t)}}wrapTilesetLayer(t){const e=this.viewer.scene.primitives;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>{const e=t.style;if(e.color&&"string"==typeof e.color){const t=e.color.match(/color\(.*?,([\d.]+)\)/);return t?parseFloat(t[1]):1}return 1},setOpacity:e=>{const i=t.style.color;let s;if("string"==typeof i){const t=i.replace(/color\((.*?),[\d.]+\)/,`color($1, ${e})`);s=t.includes("color")?t:`color('white', ${e})`}else s=`color('white', ${e})`;t.style=new this.Cesium.Cesium3DTileStyle({color:s,colorBlendMode:this.Cesium.ColorBlendMode.MIX})},getZIndex:()=>{const e=this.viewer.scene.primitives;for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&this.sort3DTileSets(e,t,i)},setColor:(e,i=1)=>{const s=e instanceof this.Cesium.Color?e.toCssHexString():e.replace(/[#\s]/g,"");t.style=new this.Cesium.Cesium3DTileStyle({color:`color('${s}', ${i})`,colorBlendMode:this.Cesium.ColorBlendMode.MIX})},setStyle:e=>{t.style=e instanceof this.Cesium.Cesium3DTileStyle?e:new this.Cesium.Cesium3DTileStyle(e)},remove:()=>this.viewer.scene.primitives.remove(t)}}wrapDataSourceLayer(t){const e=this.viewer.dataSources;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>1,setOpacity:e=>{t.__vmapLockOpacity||t.entities.values.forEach((t=>{const i=(t,i)=>{const{Color:s,JulianDate:r}=this.Cesium,a=t=>s.fromAlpha(t??i,e,new s);if(!t)return new this.Cesium.ConstantProperty(a(i));const n=t;if(n&&"function"==typeof n.getValue){const t=a(n.getValue(this.viewer?.clock?.currentTime??new r,new s));return"function"==typeof n.setValue?(n.setValue(t),n):new this.Cesium.ConstantProperty(t)}return new this.Cesium.ConstantProperty(a(t instanceof this.Cesium.Color?t:i))};if(t.polygon){const e=t.polygon.material;(e instanceof Cesium.ColorMaterialProperty||e instanceof Cesium.ImageMaterialProperty)&&(e.color=i(e.color,Cesium.Color.WHITE))}if(t.polyline){const e=t.polyline.material;(e instanceof Cesium.ColorMaterialProperty||e instanceof Cesium.PolylineOutlineMaterialProperty)&&(e.color=i(e.color,Cesium.Color.WHITE))}t.point&&(t.point.color=i(t.point.color,Cesium.Color.WHITE)),t.billboard&&(t.billboard.color=i(t.billboard.color,Cesium.Color.WHITE)),t.label&&(t.label.fillColor=i(t.label.fillColor,Cesium.Color.BLACK),t.label.outlineColor&&(t.label.outlineColor=i(t.label.outlineColor,Cesium.Color.BLACK))),t.model&&(t.model.color=i(t.model.color,Cesium.Color.WHITE))}))},getZIndex:()=>{for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&await this.sortDataSources(e,t,i)},remove:()=>e.remove(t)}}}class w{locked=!1;queue=[];async runExclusive(t){await this.acquire();try{return await t()}finally{this.release()}}acquire(){return this.locked?new Promise((t=>this.queue.push(t))):(this.locked=!0,Promise.resolve())}release(){const t=this.queue.shift();t?t():this.locked=!1}}function p(t,e){if(!t)throw new Error(e)}const m=new w;class d{tileWidth;tileHeight;tilingScheme;rectangle;errorEvent;credit=void 0;tileDiscardPolicy=void 0;proxy=void 0;hasAlphaChannel=!0;minimumLevel;maximumLevel;Cesium;tileProcessor;resolution;resampleMethod;colorStops;readyPromiseInternal;ready=!1;constructor(t){const{Cesium:e,rectangleDegrees:i,tileProcessor:s,tileSize:r,resolution:a,resampleMethod:n,colorStops:o,minimumLevel:h,maximumLevel:c}=t;this.Cesium=e,this.tileProcessor=s,this.tileWidth=r,this.tileHeight=r,this.resolution=a,this.resampleMethod=n,this.colorStops=o,this.minimumLevel=h??0,this.maximumLevel=c,this.rectangle=e.Rectangle.fromDegrees(i[0],i[1],i[2],i[3]),this.tilingScheme=new e.WebMercatorTilingScheme,this.errorEvent=new e.Event,this.ready=!0,this.readyPromiseInternal=Promise.resolve(!0)}get tilingSchemeName(){return this.tilingScheme instanceof this.Cesium.WebMercatorTilingScheme?"WebMercator":void 0}get readyPromise(){return this.readyPromiseInternal}get tileCredits(){}getTileCredits(t,e,i){}get url(){}flipCanvasVertically(e,i,s){const r=document.createElement("canvas");r.width=i,r.height=s;const a=r.getContext("2d");return a?(a.translate(0,s),a.scale(1,-1),a.drawImage(e,0,0),r):(t("v-map - cesium - failed to get 2d context for flip"),e)}async createFlippedImageBitmap(e,i){if("function"==typeof createImageBitmap)try{const t=document.createElement("canvas");t.width=i,t.height=i;const s=t.getContext("2d");if(!s)throw new Error("Failed to get 2d context");const r=s.createImageData(i,i);r.data.set(e),s.putImageData(r,0,0);const a=this.flipCanvasVertically(t,i,i);return await createImageBitmap(a)}catch(e){return void t("v-map - cesium - createImageBitmap failed, falling back",e)}}async createFlippedImageFromRGBA(e){const i=Math.ceil(this.tileWidth*this.resolution),s=await this.createFlippedImageBitmap(e,i);if(s)return s;const r=document.createElement("canvas");r.width=i,r.height=i;const a=r.getContext("2d");if(!a)return void t("v-map - cesium - unable to acquire canvas 2d context");const n=a.createImageData(i,i);return n.data.set(e),a.putImageData(n,0,0),this.flipCanvasVertically(r,i,i)}async requestImage(i,s,r){if(!this.ready)return;if(r<this.minimumLevel||void 0!==this.maximumLevel&&r>this.maximumLevel)return;const a={x:i,y:s,z:r,tileSize:this.tileWidth,resolution:this.resolution,resampleMethod:this.resampleMethod,colorStops:this.colorStops};let n=null;try{if(n=await this.tileProcessor.getTileData(a),!n)return void e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): no data returned`);e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): rgba ${n.length} bytes, sampleSize=${Math.ceil(this.tileWidth*this.resolution)}`)}catch(e){return this.errorEvent.raiseEvent(e),void t("v-map - cesium - getTileData - GeoTIFF tile request failed",e)}try{const t=await this.createFlippedImageFromRGBA(n);return e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): result=${t?.constructor?.name??"undefined"}, size=${t instanceof HTMLCanvasElement||t instanceof ImageBitmap?`${t.width}x${t.height}`:"n/a"}`),t}catch(e){return this.errorEvent.raiseEvent(e),void t("v-map - cesium - createFlippedImageFromRGBA - GeoTIFF tile request failed",e)}}pickFeatures(){}}const y="v-map - cesium - terrain-geotiff - ";class f{Cesium;image;fromProjection="EPSG:4326";sourceBounds=[0,0,0,0];wgs84Bounds=[0,0,0,0];width=0;height=0;noDataValue=0;ready=!1;_readyPromise;heightmapWidth=65;heightmapHeight=65;proj4;tilingScheme;constructor(t){this.Cesium=t.Cesium,this.tilingScheme=new this.Cesium.GeographicTilingScheme,this._readyPromise=this.initialize(t)}async initialize(t){try{e(`${y}loadGeoTIFF: url=${t.url}`);const[i,{default:s},a]=await Promise.all([import("./geotiff.js").then((function(t){return t.g})),import("./index4.js"),import("./main-dist.js").then((function(t){return t.m}))]),n=await r(t.url,{projection:t.projection,forceProjection:t.forceProjection??!1,nodata:t.nodata},{geotiff:i,proj4:s,geokeysToProj4:a});return this.image=n.baseImage,this.fromProjection=n.fromProjection,this.sourceBounds=n.sourceBounds,this.wgs84Bounds=n.wgs84Bounds,this.width=n.width,this.height=n.height,this.noDataValue=n.noDataValue??0,this.proj4=n.proj4,e(`${y}loaded: projection=${this.fromProjection}, bounds=[${this.sourceBounds.map((t=>t.toFixed(0))).join(",")}], wgs84=[${this.wgs84Bounds.map((t=>t.toFixed(4))).join(",")}], size=${this.width}x${this.height}`),this.ready=!0,!0}catch(t){return i(`${y}failed to load GeoTIFF:`,t),this.ready=!1,!1}}get rectangle(){if(!this.ready||!this.wgs84Bounds)return this.Cesium.Rectangle.MAX_VALUE;const[t,e,i,s]=this.wgs84Bounds;return this.Cesium.Rectangle.fromDegrees(t,e,i,s)}async requestTileGeometry(e,i,s){if(this.ready&&this.image)try{const r=this.tilingScheme.tileXYToRectangle(e,i,s);let a=this.Cesium.Math.toDegrees(r.west),n=this.Cesium.Math.toDegrees(r.south),o=this.Cesium.Math.toDegrees(r.east),h=this.Cesium.Math.toDegrees(r.north);const[c,l,u,w]=this.wgs84Bounds;if(o<c||a>u||h<l||n>w)return this.createFlatHeightmap();a=Math.max(c,Math.min(u,a)),o=Math.max(c,Math.min(u,o)),n=Math.max(l,Math.min(w,n)),h=Math.max(l,Math.min(w,h));const p=e=>{try{return this.proj4("EPSG:4326",this.fromProjection,e)}catch(i){return t(`${y}transform failed:`,i),e}},m=p([a,n]),d=p([o,h]),[f,g,v,b]=this.sourceBounds,S=this.width,C=this.height,$=v-f,L=b-g,G=Math.floor((m[0]-f)/$*S),k=Math.floor((b-d[1])/L*C),M=Math.ceil((d[0]-f)/$*S),x=Math.ceil((b-m[1])/L*C),F=Math.max(0,Math.min(G,S)),E=Math.max(0,Math.min(k,C)),I=Math.max(1,Math.min(M-G,S-F)),T=Math.max(1,Math.min(x-k,C-E)),O=(await this.image.readRasters({window:[F,E,F+I,E+T],width:this.heightmapWidth,height:this.heightmapHeight,resampleMethod:"bilinear"}))[0],A=new Float32Array(this.heightmapWidth*this.heightmapHeight);for(let t=0;t<A.length;t++){let e=O[t];e!==this.noDataValue&&isFinite(e)||(e=0),A[t]=e}return new this.Cesium.HeightmapTerrainData({buffer:A,width:this.heightmapWidth,height:this.heightmapHeight,childTileMask:0,structure:{heightScale:1,heightOffset:0,elementsPerHeight:1,stride:1,elementMultiplier:1}})}catch(e){return t(`${y}failed to load tile geometry:`,e),this.createFlatHeightmap()}}createFlatHeightmap(){const t=new Float32Array(this.heightmapWidth*this.heightmapHeight);return t.fill(0),new this.Cesium.HeightmapTerrainData({buffer:t,width:this.heightmapWidth,height:this.heightmapHeight,childTileMask:0})}get availability(){}getTilingScheme(){return this.tilingScheme}getLevelMaximumGeometricError(t){return this.tilingScheme.ellipsoid.maximumRadius/(65*Math.pow(2,t))}loadTileDataAvailability(t,e,i){}getTileDataAvailable(t,e,i){if(!this.ready)return!1;const s=this.tilingScheme.tileXYToRectangle(t,e,i),r=this.Cesium.Math.toDegrees(s.west),a=this.Cesium.Math.toDegrees(s.south),n=this.Cesium.Math.toDegrees(s.east),o=this.Cesium.Math.toDegrees(s.north),[h,c,l,u]=this.wgs84Bounds;return!(n<h||r>l||o<c||a>u)}get readyPromise(){return this._readyPromise}get credit(){return new this.Cesium.Credit("GeoTIFF Terrain")}get hasWaterMask(){return!1}get hasVertexNormals(){return!1}get errorEvent(){return new this.Cesium.Event}}const g="v-map - cesium - terrain-geotiff - ";class v{Cesium;viewer;provider;options;opacity=1;previousProvider;constructor(t,e,i,s){this.Cesium=t,this.viewer=e,this.provider=i,this.options=s??{},this.previousProvider=e.terrainProvider,this.viewer.terrainProvider=this.provider}getOptions(){return this.options}setOptions(t){this.options=t}getVisible(){return this.viewer.scene.globe.show}setVisible(t){this.viewer.scene.globe.show=t}getOpacity(){return this.opacity}setOpacity(e){this.opacity=e;const i=this.viewer.scene.globe;if(!i.translucency)try{i.translucency=new this.Cesium.GlobeTranslucency,i.translucency.enabled=!0}catch(e){return void t("Cesium terrain opacity not supported",e)}i.translucency.enabled=e<1,i.translucency.frontFaceAlpha=e}getZIndex(){return 0}async setZIndex(t){}remove(){try{this.viewer.terrainProvider=this.previousProvider?this.previousProvider:new this.Cesium.EllipsoidTerrainProvider,this.viewer.scene.globe.show=!0}catch(e){t("Cesium terrain reset failed",e)}}}class b{viewer;Cesium;layerManager;shadowRoot;layerGroups=new l;layerManagerMutex=new w;layerErrorCallbacks=new Map;layerErrorCleanups=new Map;async init(t){this.shadowRoot=t.shadowRoot;const e=t.target.getRootNode()instanceof ShadowRoot?t.target.getRootNode():void 0;await async function(t){const e=`https://cdn.jsdelivr.net/npm/cesium@${s.replace(/^[^\d]*/,"")}/Build/Cesium`,i=`${e}/Widgets/widgets.css`,r=(await(await fetch(i)).text()).replace(/url\((?!['"]?data:)(['"]?)([^'")]+)\1\)/g,((t,i,s)=>`url(${e}/Widgets/${s.replace(/^\.?\//,"")})`));if(t)if("adoptedStyleSheets"in Document.prototype){const e=new CSSStyleSheet;await e.replace(r),t.adoptedStyleSheets=[...t.adoptedStyleSheets??[],e]}else{const e=document.createElement("style");e.textContent=r,t.appendChild(e)}}(e),this.Cesium=await async function(t=s){const e=`https://cdn.jsdelivr.net/npm/cesium@${t.replace(/^[^\d]*/,"")}/Build/Cesium`,i=`${e}/Cesium.js`;await m.runExclusive((async()=>{globalThis.Cesium||await new Promise(((t,e)=>{const s="cesium-cdn-script";if(document.getElementById(s))return t();const r=document.createElement("script");r.id=s,r.async=!0,r.src=i,r.addEventListener("load",(()=>t()),{once:!0}),r.addEventListener("error",(()=>e(new Error(`Laden fehlgeschlagen: ${i}`))),{once:!0}),document.head.appendChild(r)}))}));const r=globalThis.Cesium;p(r,"globalThis.Cesium nicht verfügbar.");const a=r.VERSION;var n,o;return p((n=String(t),o=a,n.match(/^\d+\.\d+/)?.[0]===o.match(/^\d+\.\d+/)?.[0]),`Cesium-Version abweichend: erwartet ~${t}, geladen ${a}`),globalThis.CESIUM_BASE_URL=e,r}(),Cesium.Ion.defaultAccessToken=null,this.viewer=new this.Cesium.Viewer(t.target,{baseLayer:!1,baseLayerPicker:!1,terrainProvider:new Cesium.EllipsoidTerrainProvider}),this.viewer.scene.primitives.removeAll(),this.viewer.scene.backgroundColor=this.Cesium.Color.WHITE,this.viewer.scene.globe.baseColor=this.Cesium.Color.WHITE,this.viewer.scene.globe.depthTestAgainstTerrain=!1,this.layerManager=new u(this.Cesium,this.viewer)}async destroy(){!function(t){if(!t)return;const i=Array.from(t.querySelectorAll("style"));for(const t of i)if(t.textContent?.includes(".cesium-credit-lightbox-overlay")){t.remove(),e("v-map - provider - cesium - Cesium‑Widget‑CSS entfernt");break}}(this.shadowRoot),this.viewer?.destroy(),this.viewer=void 0}async createLayer(t,e){let i=null;switch(t.type){case"geojson":{const s={},r=t,a=await this.createGeoJSONLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"osm":{const s=await this.createOSMLayer(t);i=this.layerManager.addLayer(e,s);break}case"google":{const s=await this.createGoogleLayer(t);i=this.layerManager.addLayer(e,s);break}case"terrain":{const s=await this.createTerrainLayer(t);i=this.layerManager.addCustomLayer(e,s);break}case"xyz":{const s=await this.createXYZLayer(t);i=this.layerManager.addLayer(e,s);break}case"wms":{const s=await this.addWMSLayer(t);i=this.layerManager.addLayer(e,s);break}case"wcs":{const s=await this.createWCSLayer(t);i=this.layerManager.addLayer(e,s);break}case"arcgis":await this.addArcGISLayer(t);break;case"wfs":{const s={clampToGround:!0},r=t,a=await this.createWFSLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"wkt":{const s={clampToGround:!0},r=t,a=await this.createWKTLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"geotiff":{const s=await this.createGeoTIFFLayer(t);i=this.layerManager.addLayer(e,s);break}case"tile3d":{const s=await this.createTile3DLayer(t);i=this.layerManager.addLayer(e,s);const r=t;i.setOptions(r.tilesetOptions??{}),r.cesiumStyle&&"setStyle"in i&&i.setStyle(r.cesiumStyle);break}case"terrain-geotiff":{const s=await this.createGeoTIFFTerrainLayer(t);i=this.layerManager.addCustomLayer(e,s);break}default:throw new Error(`Unsupported layer type: ${t.type}`)}if(!i)return null;const s=t;return void 0!==s.zIndex&&await i.setZIndex(s.zIndex),void 0!==s.opacity&&i.setOpacity(s.opacity),void 0!==s.visible&&i.setVisible(s.visible),i}async addLayerToGroup(t){return await this.layerManagerMutex.runExclusive((async()=>{const e=crypto.randomUUID(),i=await this.createLayer(t,e);return this.layerGroups.addLayerToGroup(t.groupId,void 0===typeof t.groupVisible||t.groupVisible,{id:e,elementId:t.layerElementId??t.elementId??null,layer:i}),this.layerGroups.apply(),e}))}async setBaseLayer(t,e){await this.layerManagerMutex.runExclusive((async()=>{this.layerGroups.setBasemap(t,e??null),this.layerGroups.apply()}))}async addBaseLayer(t,e,i){return i&&e?await this.layerManagerMutex.runExclusive((async()=>{const s=crypto.randomUUID(),r=await this.createLayer(t,s);return this.layerGroups.addLayerToGroup(t.groupId,void 0===typeof t.groupVisible||t.groupVisible,{id:s,elementId:i,layer:r}),this.layerGroups.setBasemap(t.groupId??"basemap",e),this.layerGroups.apply(),s})):null}async ensureGroup(t,e,i){this.layerGroups.ensureGroup(t,e)}async setGroupVisible(t,e){this.layerGroups.setGroupVisible(t,e),this.layerGroups.apply()}onLayerError(t,e){this.layerErrorCallbacks.set(t,e),this.attachCesiumErrorListeners(t)}offLayerError(t){this.layerErrorCleanups.get(t)?.(),this.layerErrorCleanups.delete(t),this.layerErrorCallbacks.delete(t)}attachCesiumErrorListeners(t){this.layerErrorCleanups.get(t)?.();const e=this.layerErrorCallbacks.get(t);if(!e)return;const i=this.layerManager.getLayer(t);if(!i)return;const s=[],r=()=>{e({type:"network",message:"Tile load error"})},a=i._imageryLayer;if(a?.imageryProvider?.errorEvent){const t=a.imageryProvider.errorEvent.addEventListener(r);s.push(t)}const n=i._tileset;if(n?.tileFailed){const t=n.tileFailed.addEventListener(r);s.push(t)}s.length>0&&this.layerErrorCleanups.set(t,(()=>s.forEach((t=>t()))))}async removeLayer(t){t&&(this.offLayerError(t),await this.layerManagerMutex.runExclusive((async()=>{this.layerManager.removeLayer(t),this.layerGroups.removeLayer(t,!0),this.layerGroups.apply()})))}async setOpacity(t,e){this.layerManager.setOpacity(t,e),this.layerGroups.apply()}async setVisible(t,e){this.layerManager.setVisible(t,e),this.layerGroups.apply()}async setZIndex(t,e){await this.layerManager.setZIndex(t,e),this.layerGroups.apply()}applyGeostylerStyling(t,i){t.__vmapLockOpacity=!0;const s=(t,e)=>null==t||"object"==typeof t&&null!==t&&"name"in t?e:t,r=(t,e)=>{if(null==t)return e;if("number"==typeof t)return t;const i=Number(t);return Number.isFinite(i)?i:e},a=t.entities.values;if(i.rules)for(const t of i.rules)if(t.symbolizers)for(const i of t.symbolizers)for(let t=0;t<a.length;t++){const n=a[t];switch(i.kind){case"Fill":if(n.polygon){const t=s(i.color,"rgba(0,100,255,0.3)"),a=r(s(i.opacity,.3),.3),o=s(i.outlineColor,"rgba(0,100,255,1)"),h=s(i.outlineWidth,1);let c=this.parseCesiumColor(t,this.Cesium.Color.BLUE.withAlpha(.3));null!=a&&(c=this.applyCesiumOpacity(c,a));const l=this.parseCesiumColor(o,this.Cesium.Color.BLUE);e("v-map - provider - cesium - applyGeostylerStyling: Fill",{fillColor:t,fillOpacity:a,computedFill:c?.toString?.(),outlineColor:o,outlineWidth:h}),n.polygon.fill=new this.Cesium.ConstantProperty(!0),n.polygon.material=new this.Cesium.ColorMaterialProperty(c),n.polygon.outline=new this.Cesium.ConstantProperty(!0),n.polygon.outlineColor=new this.Cesium.ConstantProperty(l),n.polygon.outlineWidth=new this.Cesium.ConstantProperty(h),n.polygon.extrudedHeight=void 0,n.polygon.heightReference=new this.Cesium.ConstantProperty(this.Cesium.HeightReference.CLAMP_TO_GROUND),n.polygon.perPositionHeight=new this.Cesium.ConstantProperty(!1),n.polygon.classificationType=new this.Cesium.ConstantProperty(this.Cesium.ClassificationType.BOTH)}break;case"Line":if(n.polyline){const t=s(i.color,"rgba(0,100,255,1)"),a=r(s(i.width,2),2),o=r(s(i.opacity,1),1);let h=this.parseCesiumColor(t,this.Cesium.Color.BLUE);null!=o&&(h=this.applyCesiumOpacity(h,o)),e("v-map - provider - cesium - applyGeostylerStyling: Line",{lineColor:t,lineOpacity:o,computedColor:h?.toString?.(),lineWidth:a}),n.polyline.material=new this.Cesium.ColorMaterialProperty(h),n.polyline.width=new this.Cesium.ConstantProperty(a)}break;case"Mark":if(n.point){const t=s(i.color,"rgba(0,100,255,1)"),a=r(s(i.radius,6),6),o=r(s(i.opacity,1),1);let h=this.parseCesiumColor(t,this.Cesium.Color.BLUE);null!=o&&(h=this.applyCesiumOpacity(h,o)),e("v-map - provider - cesium - applyGeostylerStyling: Mark",{pointColor:t,pointOpacity:o,computedColor:h?.toString?.(),pointRadius:a}),n.point.color=new this.Cesium.ConstantProperty(h),n.point.pixelSize=new this.Cesium.ConstantProperty(a)}break;case"Icon":if(n.point){const t=s(i.image),a=r(s(i.size,32),32),o=r(s(i.opacity,1),1);t&&"string"==typeof t&&(n.billboard=new this.Cesium.BillboardGraphics({image:new this.Cesium.ConstantProperty(t),width:new this.Cesium.ConstantProperty(a),height:new this.Cesium.ConstantProperty(a),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM),color:null!=o?new this.Cesium.ConstantProperty(this.Cesium.Color.WHITE.withAlpha(o)):void 0}),n.point.show=new this.Cesium.ConstantProperty(!1),e("v-map - provider - cesium - applyGeostylerStyling: Icon",{iconSrc:t,iconSize:a,iconOpacity:o}))}break;case"Text":const t=i.label,a="string"==typeof t?t:void 0;if(a&&n.properties&&n.properties[a]){const t=s(i.color,"#000000"),o=r(s(i.size,12),12),h=r(s(i.opacity,1),1);let c=this.parseCesiumColor(t,this.Cesium.Color.WHITE);null!=h&&(c=this.applyCesiumOpacity(c,h)),e("v-map - provider - cesium - applyGeostylerStyling: Text",{labelProp:a,textColor:t,textOpacity:h,computedColor:c?.toString?.(),textSize:o});const l=n.properties[a]?.getValue?.(this.viewer.clock.currentTime)??n.properties[a]?._value??"";n.label=new this.Cesium.LabelGraphics({text:new this.Cesium.ConstantProperty(String(l)),font:new this.Cesium.ConstantProperty(`${o}px Arial`),fillColor:new this.Cesium.ConstantProperty(c),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM)})}}}}parseCesiumColor(t,e){if(!t)return e;if(t.startsWith("#"))return this.Cesium.Color.fromCssColorString(t);if(t.includes("rgb"))return this.Cesium.Color.fromCssColorString(t);try{return this.Cesium.Color.fromCssColorString(t)}catch{return e}}applyCesiumOpacity(t,e){return t?t.withAlpha(e):t}createCesiumStyle(t={}){const e=this.Cesium.Color.BLUE.withAlpha(.3),i=this.Cesium.Color.BLUE,s=this.Cesium.Color.BLUE,r=this.parseCesiumColor(t.fillColor,e),a=this.parseCesiumColor(t.strokeColor,i),n=this.parseCesiumColor(t.pointColor,s),o=void 0!==t.fillOpacity?this.applyCesiumOpacity(r,t.fillOpacity):r,h=void 0!==t.strokeOpacity?this.applyCesiumOpacity(a,t.strokeOpacity):a,c=void 0!==t.pointOpacity?this.applyCesiumOpacity(n,t.pointOpacity):n;return{fill:!0,fillColor:o,outline:!0,outlineColor:h,outlineWidth:t.strokeWidth??2,extrudedHeight:t.extrudeHeight,heightReference:t.zOffset?this.Cesium.HeightReference.RELATIVE_TO_GROUND:this.Cesium.HeightReference.CLAMP_TO_GROUND,pixelSize:t.pointRadius??8,color:c,scaleByDistance:t.pointRadius?new this.Cesium.NearFarScalar(150,2,15e6,.5):void 0,width:t.strokeWidth??2,clampToGround:!t.zOffset,labelText:t.textProperty,labelFont:t.textSize?`${t.textSize}pt monospace`:"12pt monospace",labelFillColor:t.textColor?this.parseCesiumColor(t.textColor,this.Cesium.Color.WHITE):this.Cesium.Color.WHITE,labelOutlineColor:t.textHaloColor?this.parseCesiumColor(t.textHaloColor,this.Cesium.Color.BLACK):this.Cesium.Color.BLACK,labelOutlineWidth:t.textHaloWidth??1,labelPixelOffset:t.textOffset?new this.Cesium.Cartesian2(t.textOffset[0],t.textOffset[1]):this.Cesium.Cartesian2.ZERO,height:t.zOffset??0}}applyEnhancedStyling(t,e={}){const i=this.createCesiumStyle(e),s=t.entities.values;for(let t=0;t<s.length;t++){const r=s[t];let a=i;if(e.styleFunction&&r.properties){const t={properties:r.properties._propertyNames.reduce(((t,e)=>(t[e]=r.properties[e]?._value,t)),{}),geometry:r},s=e.styleFunction(t);s&&(a={...i,...this.createCesiumStyle(s)})}if(r.polygon&&(r.polygon.fill=new this.Cesium.ConstantProperty(a.fill),r.polygon.material=new this.Cesium.ColorMaterialProperty(a.fillColor),r.polygon.outline=new this.Cesium.ConstantProperty(a.outline),r.polygon.outlineColor=new this.Cesium.ConstantProperty(a.outlineColor),r.polygon.outlineWidth=new this.Cesium.ConstantProperty(a.outlineWidth),r.polygon.height=void 0!==a.height?new this.Cesium.ConstantProperty(a.height):void 0,r.polygon.extrudedHeight=void 0!==a.extrudedHeight?new this.Cesium.ConstantProperty(a.extrudedHeight):void 0,r.polygon.heightReference=void 0!==a.heightReference?new this.Cesium.ConstantProperty(a.heightReference):void 0),r.polyline&&(r.polyline.material=new this.Cesium.ColorMaterialProperty(a.outlineColor),r.polyline.width=new this.Cesium.ConstantProperty(a.width),r.polyline.clampToGround=new this.Cesium.ConstantProperty(a.clampToGround)),r.point){r.point.pixelSize=new this.Cesium.ConstantProperty(a.pixelSize),r.point.color=new this.Cesium.ConstantProperty(a.color);const t=a.scaleByDistance;r.point.scaleByDistance=t?new this.Cesium.ConstantProperty(t):void 0,e.iconUrl&&(r.billboard=new this.Cesium.BillboardGraphics({image:new this.Cesium.ConstantProperty(e.iconUrl),width:new this.Cesium.ConstantProperty(e.iconSize?e.iconSize[0]:32),height:new this.Cesium.ConstantProperty(e.iconSize?e.iconSize[1]:32),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM),scaleByDistance:t?new this.Cesium.ConstantProperty(t):void 0}),r.point.show=new this.Cesium.ConstantProperty(!1))}if(e.textProperty&&r.properties&&r.properties[e.textProperty]){const t=r.properties[e.textProperty]?.getValue?.(this.viewer.clock.currentTime)??r.properties[e.textProperty]?._value??"";r.label=new this.Cesium.LabelGraphics({text:new this.Cesium.ConstantProperty(String(t)),font:new this.Cesium.ConstantProperty(a.labelFont),fillColor:new this.Cesium.ConstantProperty(a.labelFillColor),outlineColor:new this.Cesium.ConstantProperty(a.labelOutlineColor),outlineWidth:new this.Cesium.ConstantProperty(a.labelOutlineWidth),pixelOffset:new this.Cesium.ConstantProperty(a.labelPixelOffset),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM)})}}}async createWKTLayer(t,e){const i=await this.wktToGeoJSON(t),s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async wktToGeoJSON(t){const e=await this.resolveWktText(t),i=await import("./index5.js").then((function(t){return t.i})),s="function"==typeof i.default?i.default:i.parse;if("function"!=typeof s)throw new Error("wellknown parser not available");const r=s(e);if(!r)throw new Error("Failed to parse WKT");return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:r}]}}async resolveWktText(t){if(t.wkt)return t.wkt;if(t.url){const e=await fetch(t.url);if(!e.ok)throw new Error(`Failed to fetch WKT: ${e.status}`);return await e.text()}throw new Error("Either wkt or url must be provided")}async createGeoJSONLayer(t,e){let i=null;i=t.geojson?JSON.parse(t.geojson):t.url;const s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async createWFSLayer(t,e){const i=await this.fetchWFSFromUrl(t),s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async createOSMLayer(t){return new this.Cesium.ImageryLayer(new this.Cesium.OpenStreetMapImageryProvider({url:t.url||"https://a.tile.openstreetmap.org"}))}async createGoogleLayer(t){if(!t.apiKey)throw new Error("Google-Layer benötigt 'apiKey' (Google Maps Platform).");await this.loadGoogleMapsApi(t.apiKey,{language:t.language,region:t.region,libraries:t.libraries});const e=this.getGoogleMapTypeId(t.mapType||"roadmap"),i=this.Cesium,s=new i.UrlTemplateImageryProvider({url:"https://maps.googleapis.com/maps/api/staticmap?template",maximumLevel:t.maxZoom||19,minimumLevel:0,tilingScheme:new i.WebMercatorTilingScheme,credit:"Google Maps",urlSchemeZeroPadding:{"{x}":"","{y}":"","{z}":""}});return s.buildImageResource=function(s,r,a){const n=(new i.WebMercatorTilingScheme).tileXYToRectangle(s,r,a),o=i.Math.toDegrees(n.west),h=i.Math.toDegrees(n.south),c=i.Math.toDegrees(n.east),l=i.Math.toDegrees(n.north),u=new URLSearchParams({center:`${(h+l)/2},${(o+c)/2}`,zoom:a.toString(),size:"256x256",scale:"scaleFactor1x"===t.scale?"1":"2",maptype:e,key:t.apiKey,format:"png"});t.language&&u.set("language",t.language),t.region&&u.set("region",t.region);const w=`https://maps.googleapis.com/maps/api/staticmap?${u.toString()}`;return new i.Resource({url:w})},this.ensureGoogleLogo(),new this.Cesium.ImageryLayer(s,{alpha:t.opacity??1,show:t.visible??!0})}getGoogleMapTypeId(t){switch(t){case"roadmap":default:return"roadmap";case"satellite":return"satellite";case"terrain":return"terrain";case"hybrid":return"hybrid"}}async loadGoogleMapsApi(t,e){const i=window,s=i.__mockGoogleMapsApi;"function"!=typeof s?i.google?.maps||await new Promise(((s,r)=>{const a="___cesiumGoogleInit___"+Math.random().toString(36).slice(2);i[a]=()=>s();const n=document.createElement("script"),o=new URLSearchParams({key:t,callback:a,v:"weekly"});e?.language&&o.set("language",e.language),e?.region&&o.set("region",e.region),e?.libraries?.length&&o.set("libraries",e.libraries.join(",")),n.src=`https://maps.googleapis.com/maps/api/js?${o.toString()}`,n.async=!0,n.onerror=()=>r(new Error("Google Maps JS API failed to load")),document.head.appendChild(n)})):await s(t,e)}ensureGoogleLogo(){if(!this.viewer?.container||this.viewer.container._googleLogoAdded)return;const t=document.createElement("img");t.src="https://developers.google.com/static/maps/documentation/images/google_on_white.png",t.alt="Google",t.style.position="absolute",t.style.bottom="6px",t.style.left="6px",t.style.height="18px",t.style.pointerEvents="none",t.style.zIndex="1000",this.viewer.container.appendChild(t),this.viewer.container._googleLogoAdded=!0}async createXYZLayer(t){if(!t.url)throw new Error("XYZ layer requires a url");const e=Array.isArray(t.attributions)?t.attributions.join(", "):t.attributions,i={url:t.url,credit:e,maximumLevel:t.maxZoom,...t.options||{}},s=new this.Cesium.UrlTemplateImageryProvider(i);return new this.Cesium.ImageryLayer(s,{alpha:t.opacity??1,show:t.visible??!0})}async createTerrainLayer(t){let e;e=t.elevationData?await this.Cesium.CesiumTerrainProvider.fromUrl(t.elevationData):await this.Cesium.createWorldTerrainAsync();const i=new v(this.Cesium,this.viewer,e,t);return void 0!==t.visible&&i.setVisible(t.visible),void 0!==t.opacity&&i.setOpacity(t.opacity),i}async createGeoTIFFTerrainLayer(t){if(!t.url){e(`${g}layer created without URL, waiting for URL to load`);const i=new this.Cesium.EllipsoidTerrainProvider,s=new v(this.Cesium,this.viewer,i,t);return s.setVisible(!1),s}try{e(`${g}create layer: url=${t.url}`);const i=await async function(t){const e=new f(t);return await e.readyPromise,e}({url:t.url,projection:t.projection,forceProjection:t.forceProjection,nodata:t.nodata,Cesium:this.Cesium}),s=new v(this.Cesium,this.viewer,i,t);return void 0!==t.visible&&s.setVisible(t.visible),void 0!==t.opacity&&s.setOpacity(t.opacity),e(`${g}layer created successfully`),s}catch(e){i(`${g}failed to create terrain layer:`,e);const s=new this.Cesium.EllipsoidTerrainProvider;return new v(this.Cesium,this.viewer,s,t)}}async addWMSLayer(t){return new this.Cesium.ImageryLayer(new this.Cesium.WebMapServiceImageryProvider({url:t.url,layers:t.layers,parameters:t.extraParams}))}async createWCSLayer(t){if(!t.url||!t.coverageName)throw new Error("WCS layer requires url and coverageName");const e=t.version??"2.0.1",i=t.format??"image/tiff",s=t.projection??"EPSG:4326",r=t.tileSize??256,a=this.Cesium,n=new a.UrlTemplateImageryProvider({url:`${t.url}?wcs_placeholder`,maximumLevel:t.maxZoom??18,minimumLevel:t.minZoom??0,tileWidth:r,tileHeight:r,tilingScheme:new a.GeographicTilingScheme,credit:"WCS"});return n.buildImageResource=function(n,o,h){const c=(new a.GeographicTilingScheme).tileXYToRectangle(n,o,h),l=a.Math.toDegrees(c.west),u=a.Math.toDegrees(c.south),w=a.Math.toDegrees(c.east),p=a.Math.toDegrees(c.north),m={SERVICE:"WCS",REQUEST:"GetCoverage",VERSION:e,FORMAT:i};let d;if(e.startsWith("2.0")){const e={...m,coverageId:t.coverageName,...t.params||{}};(i.includes("tiff")||i.includes("geotiff"))&&(e["geotiff:compression"]="LZW");const s=new URLSearchParams;Object.entries(e).forEach((([t,e])=>{null!=e&&s.set(t,String(e))}));const r=s.toString(),a=`subset=X(${l},${w})`,n=`subset=Y(${u},${p})`;d=`${t.url}${t.url.includes("?")?"&":"?"}${r}&${a}&${n}`}else{const e={...m,COVERAGE:t.coverageName,BBOX:`${l},${u},${w},${p}`,CRS:s,WIDTH:String(r),HEIGHT:String(r),...t.params||{}},i=new URLSearchParams;Object.entries(e).forEach((([t,e])=>{null!=e&&i.set(t,String(e))})),d=`${t.url}${t.url.includes("?")?"&":"?"}${i.toString()}`}return new a.Resource({url:d})},new this.Cesium.ImageryLayer(n,{alpha:t.opacity??1,show:t.visible??!0})}async addArcGISLayer(t){const e=await this.Cesium.ArcGisMapServerImageryProvider.fromUrl(t.url);this.viewer.imageryLayers.addImageryProvider(e)}async createGeoTIFFLayer(t){if(!t.url)throw new Error("GeoTIFF layer requires a URL");try{const e=t,i=await a(t.url,e.projection,e.forceProjection,t.nodata),s=await n(i,"EPSG:3857"),r=new o(s);let c;if(r.createGlobalTriangulation(),t.colorMap){const{stops:e}=h(t.colorMap,t.valueRange);c=e}const l=new d({Cesium:this.Cesium,rectangleDegrees:i.wgs84Bounds,tileProcessor:r,tileSize:t.tileSize??256,resolution:t.resolution??1,resampleMethod:t.resampleMethod??"bilinear",colorStops:c}),u=new this.Cesium.ImageryLayer(l,{alpha:t.opacity??1,show:t.visible??!0});return u.__vmapGeoTIFFMeta={url:t.url,width:i.width,height:i.height,samplesPerPixel:i.samplesPerPixel,noData:i.noDataValue},u}catch(t){i("v-map - provider - cesium - Failed to create GeoTIFF layer",t);const e=new this.Cesium.SingleTileImageryProvider({url:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",rectangle:this.Cesium.Rectangle.fromDegrees(-180,-90,180,90)});return new this.Cesium.ImageryLayer(e,{alpha:0,show:!1})}}async createTile3DLayer(t){if(!t.url)throw new Error("Tile3D layer requires a URL");const e=await this.Cesium.Cesium3DTileset.fromUrl(t.url,t.tilesetOptions??{});return t.cesiumStyle&&(e.style=new this.Cesium.Cesium3DTileStyle(t.cesiumStyle)),e}async updateLayer(t,e){return await this.layerManagerMutex.runExclusive((async()=>{const i=this.layerErrorCallbacks.has(t);i&&this.offLayerError(t);const s=this.layerManager.getLayer(t);switch(e.type){case"geojson":{const i=e.data,r=s.getOptions(),a=await this.createGeoJSONLayer({geojson:i.geojson,url:i.url,style:i.style,geostylerStyle:i.geostylerStyle},r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"wfs":{const i=e.data,r=s.getOptions(),a=await this.createWFSLayer(i,r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"osm":{const i=s.getOptions(),r=new this.Cesium.ImageryLayer(new this.Cesium.OpenStreetMapImageryProvider({url:e.data.url||"https://a.tile.openstreetmap.org"}));this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"google":{const i=s.getOptions(),r=await this.createGoogleLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"xyz":{const i=s.getOptions(),r=await this.createXYZLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"wcs":{const i=s.getOptions(),r=await this.createWCSLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"wkt":{const i=e.data,r=s.getOptions(),a=await this.createWKTLayer({wkt:i.wkt,url:i.url,style:i.style,geostylerStyle:i.geostylerStyle},r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"geotiff":{const i=e.data,r=await this.createGeoTIFFLayer({url:i.url});this.layerManager.replaceLayer(t,s,r)}break;case"tile3d":{const i=e.data??{};if(!i.url)throw new Error("tile3d update requires a url");const r=await this.createTile3DLayer({type:"tile3d",url:i.url,tilesetOptions:i.tilesetOptions,cesiumStyle:i.cesiumStyle}),a=this.layerManager.replaceLayer(t,s,r);a.setOptions(i.tilesetOptions??{}),i.cesiumStyle&&"setStyle"in a&&a.setStyle(i.cesiumStyle)}break;case"tile3d-style":"setStyle"in s&&s.setStyle((e.data??{}).style??{});break;case"terrain":{const i=s.getOptions(),r=s.getVisible(),a=s.getOpacity();s.remove();const n=await this.createTerrainLayer({type:"terrain",...i,...e.data??{}}),o=this.layerManager.addCustomLayer(t,n);o.setVisible(r),o.setOpacity(a)}break;case"terrain-geotiff":{s.remove();const i=await this.createGeoTIFFTerrainLayer({type:"terrain-geotiff",...e.data??{}});this.layerManager.addCustomLayer(t,i)}}i&&this.attachCesiumErrorListeners(t)}))}async setView(i,s){if(!this.viewer)return;const[r,a]=i;this.viewer.camera.flyTo({destination:this.Cesium.Cartesian3.fromDegrees(r,a,1e6/s),duration:2,orientation:{heading:this.Cesium.Math.toRadians(0),pitch:this.Cesium.Math.toRadians(-30),roll:0},complete:()=>e("v-map - provider - cesium - Fly‑to finished"),cancel:()=>t("v-map - provider - cesium - Fly‑to cancelled")})}async fetchWFSFromUrl(t){const e={service:"WFS",request:"GetFeature",version:t.version??"1.1.0",typeName:t.typeName,outputFormat:t.outputFormat??"application/json",srsName:t.srsName??"EPSG:4326",...t.params??{}},i=this.appendParams(t.url,e),s=await fetch(i);if(!s.ok)throw new Error(`WFS request failed (${s.status} ${s.statusText})`);const r=(t.outputFormat??"application/json").toLowerCase();if(r.includes("json")||r.includes("geojson")||"application/json"===r){const t=s.headers.get("content-type");if(t?.includes("application/json"))return await s.json();const e=await s.text();return JSON.parse(e)}if(r.includes("gml")||r.includes("xml")){const t=await s.text(),{GmlParser:e}=await import("./index.browser.js"),i=new e;return await i.parse(t)}return await s.json()}appendParams(t,e){const i=new URLSearchParams;return Object.entries(e).forEach((([t,e])=>{null!=e&&i.set(t,String(e))})),i.toString()?`${t}${t.includes("?")?"&":"?"}${i.toString()}`:t}}export{b as CesiumProvider}
1
+ import{w as t,l as e,e as i}from"./logger.js";import{C as s}from"./v-map2.js";import{l as r,a,b as n,G as o,g as h}from"./geotiff-source.js";class c{id;_visible=!0;_basemap=null;_layers=new Map;_originalVisible=new Map;_dirty=!0;constructor(t,e=!0){this.id=t,this._visible=e}get visible(){return this._visible}set visible(t){this._visible!==t&&(this._visible=t,this._dirty=!0)}get basemap(){return this._basemap}set basemap(t){this._basemap!==t&&(this._basemap=t,this._dirty=!0)}isDirty(){return this._dirty}addLayer(t){this._layers.has(t.id)||(this._layers.set(t.id,t),this._originalVisible.set(t.id,t.layer.getVisible()),this._dirty=!0)}setLayerElementId(t,e){const i=this._layers.get(t);i&&i.elementId!==e&&(i.elementId=e??null,this._dirty=!0)}removeLayer(t){const e=this._layers.delete(t);return this._originalVisible.delete(t),e&&(this._dirty=!0),e}clear(){this._layers.clear(),this._originalVisible.clear(),this._dirty=!0}apply(){if(this._dirty){for(const[t,e]of this._layers){const i=this._originalVisible.get(t)??!0;let s=this._visible&&i;s&&this._basemap&&(s=e.elementId===this._basemap),e.layer.getVisible()!==s&&e.layer.setVisible(s)}this._dirty=!1}}}class l{_groups=[];_dirty=!0;get groups(){return[...this._groups]}getGroup(t){return this._groups.find((e=>e.id===t))}hasGroup(t){return this._groups.some((e=>e.id===t))}ensureGroup(t,e=!0){let i=this.getGroup(t);return i||(i=new c(t,e),this._groups.push(i),this._dirty=!0,i)}addLayerToGroup(t,e,i){this.ensureGroup(t,e).addLayer(i),this._dirty=!0}removeLayer(t,e=!0){let i=!1;for(const s of this._groups)if(s.removeLayer(t)&&(i=!0,!e))break;return i&&(this._dirty=!0),i}setGroupVisible(t,e){const i=this.getGroup(t);if(!i)throw new Error(`CesiumLayerGroup "${t}" nicht gefunden`);i.visible=e,this._dirty=!0}setBasemap(t,e){const i=this.getGroup(t);if(!i)throw new Error(`CesiumLayerGroup "${t}" nicht gefunden`);i.basemap=e,this._dirty=!0}apply(){if(this._dirty||this._groups.some((t=>t.isDirty()))){for(const t of this._groups)t.apply();this._dirty=!1}}clear(){this._groups=[],this._dirty=!0}}class u{Cesium;layers=new Map;viewer;constructor(t,e){this.viewer=e,this.Cesium=t}replaceLayer(t,e,i){if(!this.Cesium)throw new Error("Cesium must be initialized first. Call init() method.");const s=e.getZIndex(),r=e.getVisible(),a=e.getOpacity();this.removeLayer(t);const n=this.addLayer(t,i);return n.setZIndex(s),n.setVisible(r),n.setOpacity(a),n}addLayer(t,e){if(!this.Cesium)throw new Error("Cesium must be initialized first. Call init() method.");e instanceof this.Cesium.GeoJsonDataSource||e instanceof this.Cesium.DataSource?this.viewer.dataSources.add(e):e instanceof this.Cesium.Cesium3DTileset?(this.viewer.scene.primitives.add(e),e.style||(e.style=new this.Cesium.Cesium3DTileStyle)):e instanceof this.Cesium.ImageryLayer&&this.viewer.imageryLayers.add(e),e.id=t;const i=this.wrapLayer(e);return this.layers.set(t,i),i}addCustomLayer(t,e){return this.layers.set(t,e),e}getLayer(t){const e=this.layers.get(t);if(!e)throw new Error(`Layer mit ID "${t}" nicht gefunden.`);return e}getLayerById(t){return this.getLayer(t)}removeLayer(t){this.getLayer(t).remove(),this.layers.delete(t)}setVisible(t,e){this.getLayer(t).setVisible(e)}setOpacity(t,e){this.getLayer(t).setOpacity(e)}async setZIndex(t,e){const i=this.getLayer(t);await i.setZIndex(e)}wrapLayer(t){return t instanceof this.Cesium.ImageryLayer?this.wrapImageryLayer(t):t instanceof this.Cesium.Cesium3DTileset?this.wrapTilesetLayer(t):this.wrapDataSourceLayer(t)}async sortImageryLayers(t,e,i){const s=this.sort(t,e,i);t.removeAll(!1),s.forEach((e=>t.add(e)))}async sort3DTileSets(t,e,i){const s=this.sort(t,e,i);t.removeAll(),s.forEach((e=>t.add(e)))}async sortDataSources(t,e,i){const s=this.sort(t,e,i);t.removeAll(!1),s.forEach((async e=>await t.add(e)))}sort(t,e,i){t.remove(e,!1);const s=[];for(let e=0;e<t.length;e++)s.push(t.get(e));return s.sort(((t,e)=>(t.zIndex||0)-(e.zIndex||0))),e.zIndex=i,s.push(e),s.sort(((t,e)=>(t.zIndex||0)-(e.zIndex||0))),s}wrapImageryLayer(t){const e=this.viewer.imageryLayers;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>t.alpha,setOpacity:e=>{t.alpha=e},getZIndex:()=>{for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&await this.sortImageryLayers(e,t,i)},remove:()=>e.remove(t)}}wrapTilesetLayer(t){const e=this.viewer.scene.primitives;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>{const e=t.style;if(e.color&&"string"==typeof e.color){const t=e.color.match(/color\(.*?,([\d.]+)\)/);return t?parseFloat(t[1]):1}return 1},setOpacity:e=>{const i=t.style.color;let s;if("string"==typeof i){const t=i.replace(/color\((.*?),[\d.]+\)/,`color($1, ${e})`);s=t.includes("color")?t:`color('white', ${e})`}else s=`color('white', ${e})`;t.style=new this.Cesium.Cesium3DTileStyle({color:s,colorBlendMode:this.Cesium.ColorBlendMode.MIX})},getZIndex:()=>{const e=this.viewer.scene.primitives;for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&this.sort3DTileSets(e,t,i)},setColor:(e,i=1)=>{const s=e instanceof this.Cesium.Color?e.toCssHexString():e.replace(/[#\s]/g,"");t.style=new this.Cesium.Cesium3DTileStyle({color:`color('${s}', ${i})`,colorBlendMode:this.Cesium.ColorBlendMode.MIX})},setStyle:e=>{t.style=e instanceof this.Cesium.Cesium3DTileStyle?e:new this.Cesium.Cesium3DTileStyle(e)},remove:()=>this.viewer.scene.primitives.remove(t)}}wrapDataSourceLayer(t){const e=this.viewer.dataSources;let i={};return{getOptions:()=>i,setOptions(t){i=t},getVisible:()=>t.show,setVisible:e=>{t.show=e},getOpacity:()=>1,setOpacity:e=>{t.__vmapLockOpacity||t.entities.values.forEach((t=>{const i=(t,i)=>{const{Color:s,JulianDate:r}=this.Cesium,a=t=>s.fromAlpha(t??i,e,new s);if(!t)return new this.Cesium.ConstantProperty(a(i));const n=t;if(n&&"function"==typeof n.getValue){const t=a(n.getValue(this.viewer?.clock?.currentTime??new r,new s));return"function"==typeof n.setValue?(n.setValue(t),n):new this.Cesium.ConstantProperty(t)}return new this.Cesium.ConstantProperty(a(t instanceof this.Cesium.Color?t:i))};if(t.polygon){const e=t.polygon.material;(e instanceof Cesium.ColorMaterialProperty||e instanceof Cesium.ImageMaterialProperty)&&(e.color=i(e.color,Cesium.Color.WHITE))}if(t.polyline){const e=t.polyline.material;(e instanceof Cesium.ColorMaterialProperty||e instanceof Cesium.PolylineOutlineMaterialProperty)&&(e.color=i(e.color,Cesium.Color.WHITE))}t.point&&(t.point.color=i(t.point.color,Cesium.Color.WHITE)),t.billboard&&(t.billboard.color=i(t.billboard.color,Cesium.Color.WHITE)),t.label&&(t.label.fillColor=i(t.label.fillColor,Cesium.Color.BLACK),t.label.outlineColor&&(t.label.outlineColor=i(t.label.outlineColor,Cesium.Color.BLACK))),t.model&&(t.model.color=i(t.model.color,Cesium.Color.WHITE))}))},getZIndex:()=>{for(let i=0;i<e.length;i++)if(e.get(i)===t)return i;return-1},setZIndex:async i=>{void 0!==i&&await this.sortDataSources(e,t,i)},remove:()=>e.remove(t)}}}class w{locked=!1;queue=[];async runExclusive(t){await this.acquire();try{return await t()}finally{this.release()}}acquire(){return this.locked?new Promise((t=>this.queue.push(t))):(this.locked=!0,Promise.resolve())}release(){const t=this.queue.shift();t?t():this.locked=!1}}function p(t,e){if(!t)throw new Error(e)}const m=new w;class d{tileWidth;tileHeight;tilingScheme;rectangle;errorEvent;credit=void 0;tileDiscardPolicy=void 0;proxy=void 0;hasAlphaChannel=!0;minimumLevel;maximumLevel;Cesium;tileProcessor;resolution;resampleMethod;colorStops;readyPromiseInternal;ready=!1;constructor(t){const{Cesium:e,rectangleDegrees:i,tileProcessor:s,tileSize:r,resolution:a,resampleMethod:n,colorStops:o,minimumLevel:h,maximumLevel:c}=t;this.Cesium=e,this.tileProcessor=s,this.tileWidth=r,this.tileHeight=r,this.resolution=a,this.resampleMethod=n,this.colorStops=o,this.minimumLevel=h??0,this.maximumLevel=c,this.rectangle=e.Rectangle.fromDegrees(i[0],i[1],i[2],i[3]),this.tilingScheme=new e.WebMercatorTilingScheme,this.errorEvent=new e.Event,this.ready=!0,this.readyPromiseInternal=Promise.resolve(!0)}get tilingSchemeName(){return this.tilingScheme instanceof this.Cesium.WebMercatorTilingScheme?"WebMercator":void 0}get readyPromise(){return this.readyPromiseInternal}get tileCredits(){}getTileCredits(t,e,i){}get url(){}flipCanvasVertically(e,i,s){const r=document.createElement("canvas");r.width=i,r.height=s;const a=r.getContext("2d");return a?(a.translate(0,s),a.scale(1,-1),a.drawImage(e,0,0),r):(t("v-map - cesium - failed to get 2d context for flip"),e)}async createFlippedImageBitmap(e,i){if("function"==typeof createImageBitmap)try{const t=document.createElement("canvas");t.width=i,t.height=i;const s=t.getContext("2d");if(!s)throw new Error("Failed to get 2d context");const r=s.createImageData(i,i);r.data.set(e),s.putImageData(r,0,0);const a=this.flipCanvasVertically(t,i,i);return await createImageBitmap(a)}catch(e){return void t("v-map - cesium - createImageBitmap failed, falling back",e)}}async createFlippedImageFromRGBA(e){const i=Math.ceil(this.tileWidth*this.resolution),s=await this.createFlippedImageBitmap(e,i);if(s)return s;const r=document.createElement("canvas");r.width=i,r.height=i;const a=r.getContext("2d");if(!a)return void t("v-map - cesium - unable to acquire canvas 2d context");const n=a.createImageData(i,i);return n.data.set(e),a.putImageData(n,0,0),this.flipCanvasVertically(r,i,i)}async requestImage(i,s,r){if(!this.ready)return;if(r<this.minimumLevel||void 0!==this.maximumLevel&&r>this.maximumLevel)return;const a={x:i,y:s,z:r,tileSize:this.tileWidth,resolution:this.resolution,resampleMethod:this.resampleMethod,colorStops:this.colorStops};let n=null;try{if(n=await this.tileProcessor.getTileData(a),!n)return void e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): no data returned`);e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): rgba ${n.length} bytes, sampleSize=${Math.ceil(this.tileWidth*this.resolution)}`)}catch(e){return this.errorEvent.raiseEvent(e),void t("v-map - cesium - getTileData - GeoTIFF tile request failed",e)}try{const t=await this.createFlippedImageFromRGBA(n);return e(`v-map - cesium - geotiff - requestImage(${i},${s},${r}): result=${t?.constructor?.name??"undefined"}, size=${t instanceof HTMLCanvasElement||t instanceof ImageBitmap?`${t.width}x${t.height}`:"n/a"}`),t}catch(e){return this.errorEvent.raiseEvent(e),void t("v-map - cesium - createFlippedImageFromRGBA - GeoTIFF tile request failed",e)}}pickFeatures(){}}const y="v-map - cesium - terrain-geotiff - ";class f{Cesium;image;fromProjection="EPSG:4326";sourceBounds=[0,0,0,0];wgs84Bounds=[0,0,0,0];width=0;height=0;noDataValue=0;ready=!1;_readyPromise;heightmapWidth=65;heightmapHeight=65;proj4;tilingScheme;constructor(t){this.Cesium=t.Cesium,this.tilingScheme=new this.Cesium.GeographicTilingScheme,this._readyPromise=this.initialize(t)}async initialize(t){try{e(`${y}loadGeoTIFF: url=${t.url}`);const[i,{default:s},a]=await Promise.all([import("./geotiff.js").then((function(t){return t.g})),import("./index4.js"),import("./main-dist.js").then((function(t){return t.m}))]),n=await r(t.url,{projection:t.projection,forceProjection:t.forceProjection??!1,nodata:t.nodata},{geotiff:i,proj4:s,geokeysToProj4:a});return this.image=n.baseImage,this.fromProjection=n.fromProjection,this.sourceBounds=n.sourceBounds,this.wgs84Bounds=n.wgs84Bounds,this.width=n.width,this.height=n.height,this.noDataValue=n.noDataValue??0,this.proj4=n.proj4,e(`${y}loaded: projection=${this.fromProjection}, bounds=[${this.sourceBounds.map((t=>t.toFixed(0))).join(",")}], wgs84=[${this.wgs84Bounds.map((t=>t.toFixed(4))).join(",")}], size=${this.width}x${this.height}`),this.ready=!0,!0}catch(t){return i(`${y}failed to load GeoTIFF:`,t),this.ready=!1,!1}}get rectangle(){if(!this.ready||!this.wgs84Bounds)return this.Cesium.Rectangle.MAX_VALUE;const[t,e,i,s]=this.wgs84Bounds;return this.Cesium.Rectangle.fromDegrees(t,e,i,s)}async requestTileGeometry(e,i,s){if(this.ready&&this.image)try{const r=this.tilingScheme.tileXYToRectangle(e,i,s);let a=this.Cesium.Math.toDegrees(r.west),n=this.Cesium.Math.toDegrees(r.south),o=this.Cesium.Math.toDegrees(r.east),h=this.Cesium.Math.toDegrees(r.north);const[c,l,u,w]=this.wgs84Bounds;if(o<c||a>u||h<l||n>w)return this.createFlatHeightmap();a=Math.max(c,Math.min(u,a)),o=Math.max(c,Math.min(u,o)),n=Math.max(l,Math.min(w,n)),h=Math.max(l,Math.min(w,h));const p=e=>{try{return this.proj4("EPSG:4326",this.fromProjection,e)}catch(i){return t(`${y}transform failed:`,i),e}},m=p([a,n]),d=p([o,h]),[f,g,v,b]=this.sourceBounds,S=this.width,C=this.height,$=v-f,L=b-g,G=Math.floor((m[0]-f)/$*S),k=Math.floor((b-d[1])/L*C),M=Math.ceil((d[0]-f)/$*S),x=Math.ceil((b-m[1])/L*C),F=Math.max(0,Math.min(G,S)),E=Math.max(0,Math.min(k,C)),I=Math.max(1,Math.min(M-G,S-F)),T=Math.max(1,Math.min(x-k,C-E)),O=(await this.image.readRasters({window:[F,E,F+I,E+T],width:this.heightmapWidth,height:this.heightmapHeight,resampleMethod:"bilinear"}))[0],A=new Float32Array(this.heightmapWidth*this.heightmapHeight);for(let t=0;t<A.length;t++){let e=O[t];e!==this.noDataValue&&isFinite(e)||(e=0),A[t]=e}return new this.Cesium.HeightmapTerrainData({buffer:A,width:this.heightmapWidth,height:this.heightmapHeight,childTileMask:0,structure:{heightScale:1,heightOffset:0,elementsPerHeight:1,stride:1,elementMultiplier:1}})}catch(e){return t(`${y}failed to load tile geometry:`,e),this.createFlatHeightmap()}}createFlatHeightmap(){const t=new Float32Array(this.heightmapWidth*this.heightmapHeight);return t.fill(0),new this.Cesium.HeightmapTerrainData({buffer:t,width:this.heightmapWidth,height:this.heightmapHeight,childTileMask:0})}get availability(){}getTilingScheme(){return this.tilingScheme}getLevelMaximumGeometricError(t){return this.tilingScheme.ellipsoid.maximumRadius/(65*Math.pow(2,t))}loadTileDataAvailability(t,e,i){}getTileDataAvailable(t,e,i){if(!this.ready)return!1;const s=this.tilingScheme.tileXYToRectangle(t,e,i),r=this.Cesium.Math.toDegrees(s.west),a=this.Cesium.Math.toDegrees(s.south),n=this.Cesium.Math.toDegrees(s.east),o=this.Cesium.Math.toDegrees(s.north),[h,c,l,u]=this.wgs84Bounds;return!(n<h||r>l||o<c||a>u)}get readyPromise(){return this._readyPromise}get credit(){return new this.Cesium.Credit("GeoTIFF Terrain")}get hasWaterMask(){return!1}get hasVertexNormals(){return!1}get errorEvent(){return new this.Cesium.Event}}const g="v-map - cesium - terrain-geotiff - ";class v{Cesium;viewer;provider;options;opacity=1;previousProvider;constructor(t,e,i,s){this.Cesium=t,this.viewer=e,this.provider=i,this.options=s??{},this.previousProvider=e.terrainProvider,this.viewer.terrainProvider=this.provider}getOptions(){return this.options}setOptions(t){this.options=t}getVisible(){return this.viewer.scene.globe.show}setVisible(t){this.viewer.scene.globe.show=t}getOpacity(){return this.opacity}setOpacity(e){this.opacity=e;const i=this.viewer.scene.globe;if(!i.translucency)try{i.translucency=new this.Cesium.GlobeTranslucency,i.translucency.enabled=!0}catch(e){return void t("Cesium terrain opacity not supported",e)}i.translucency.enabled=e<1,i.translucency.frontFaceAlpha=e}getZIndex(){return 0}async setZIndex(t){}remove(){try{this.viewer.terrainProvider=this.previousProvider?this.previousProvider:new this.Cesium.EllipsoidTerrainProvider,this.viewer.scene.globe.show=!0}catch(e){t("Cesium terrain reset failed",e)}}}class b{viewer;Cesium;layerManager;shadowRoot;layerGroups=new l;layerManagerMutex=new w;layerErrorCallbacks=new Map;layerErrorCleanups=new Map;async init(t){this.shadowRoot=t.shadowRoot;const e=t.target.getRootNode()instanceof ShadowRoot?t.target.getRootNode():void 0;await async function(t){const e=`https://cdn.jsdelivr.net/npm/cesium@${s.replace(/^[^\d]*/,"")}/Build/Cesium`,i=`${e}/Widgets/widgets.css`,r=(await(await fetch(i)).text()).replace(/url\((?!['"]?data:)(['"]?)([^'")]+)\1\)/g,((t,i,s)=>`url(${e}/Widgets/${s.replace(/^\.?\//,"")})`));if(t)if("adoptedStyleSheets"in Document.prototype){const e=new CSSStyleSheet;await e.replace(r),t.adoptedStyleSheets=[...t.adoptedStyleSheets??[],e]}else{const e=document.createElement("style");e.textContent=r,t.appendChild(e)}}(e),this.Cesium=await async function(t=s){const e=`https://cdn.jsdelivr.net/npm/cesium@${t.replace(/^[^\d]*/,"")}/Build/Cesium`,i=`${e}/Cesium.js`;await m.runExclusive((async()=>{globalThis.Cesium||await new Promise(((t,e)=>{const s="cesium-cdn-script";if(document.getElementById(s))return t();const r=document.createElement("script");r.id=s,r.async=!0,r.src=i,r.addEventListener("load",(()=>t()),{once:!0}),r.addEventListener("error",(()=>e(new Error(`Laden fehlgeschlagen: ${i}`))),{once:!0}),document.head.appendChild(r)}))}));const r=globalThis.Cesium;p(r,"globalThis.Cesium nicht verfügbar.");const a=r.VERSION;var n,o;return p((n=String(t),o=a,n.match(/^\d+\.\d+/)?.[0]===o.match(/^\d+\.\d+/)?.[0]),`Cesium-Version abweichend: erwartet ~${t}, geladen ${a}`),globalThis.CESIUM_BASE_URL=e,r}(),Cesium.Ion.defaultAccessToken=null,this.viewer=new this.Cesium.Viewer(t.target,{baseLayer:!1,baseLayerPicker:!1,terrainProvider:new Cesium.EllipsoidTerrainProvider}),this.viewer.scene.primitives.removeAll(),this.viewer.scene.backgroundColor=this.Cesium.Color.WHITE,this.viewer.scene.globe.baseColor=this.Cesium.Color.WHITE,this.viewer.scene.globe.depthTestAgainstTerrain=!1,this.layerManager=new u(this.Cesium,this.viewer)}async destroy(){!function(t){if(!t)return;const i=Array.from(t.querySelectorAll("style"));for(const t of i)if(t.textContent?.includes(".cesium-credit-lightbox-overlay")){t.remove(),e("v-map - provider - cesium - Cesium‑Widget‑CSS entfernt");break}}(this.shadowRoot),this.viewer?.destroy(),this.viewer=void 0}async createLayer(t,e){let i=null;switch(t.type){case"geojson":{const s={},r=t,a=await this.createGeoJSONLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"osm":{const s=await this.createOSMLayer(t);i=this.layerManager.addLayer(e,s);break}case"google":{const s=await this.createGoogleLayer(t);i=this.layerManager.addLayer(e,s);break}case"terrain":{const s=await this.createTerrainLayer(t);i=this.layerManager.addCustomLayer(e,s);break}case"xyz":{const s=await this.createXYZLayer(t);i=this.layerManager.addLayer(e,s);break}case"wms":{const s=await this.addWMSLayer(t);i=this.layerManager.addLayer(e,s);break}case"wcs":{const s=await this.createWCSLayer(t);i=this.layerManager.addLayer(e,s);break}case"arcgis":await this.addArcGISLayer(t);break;case"wfs":{const s={clampToGround:!0},r=t,a=await this.createWFSLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"wkt":{const s={clampToGround:!0},r=t,a=await this.createWKTLayer(r,s);i=this.layerManager.addLayer(e,a),i.setOptions(s);break}case"geotiff":{const s=await this.createGeoTIFFLayer(t);i=this.layerManager.addLayer(e,s);break}case"tile3d":{const s=await this.createTile3DLayer(t);i=this.layerManager.addLayer(e,s);const r=t;i.setOptions(r.tilesetOptions??{}),r.cesiumStyle&&"setStyle"in i&&i.setStyle(r.cesiumStyle);break}case"terrain-geotiff":{const s=await this.createGeoTIFFTerrainLayer(t);i=this.layerManager.addCustomLayer(e,s);break}default:throw new Error(`Unsupported layer type: ${t.type}`)}if(!i)return null;const s=t;return void 0!==s.zIndex&&await i.setZIndex(s.zIndex),void 0!==s.opacity&&i.setOpacity(s.opacity),void 0!==s.visible&&i.setVisible(s.visible),i}async addLayerToGroup(t){return await this.layerManagerMutex.runExclusive((async()=>{const e=crypto.randomUUID(),i=await this.createLayer(t,e);return this.layerGroups.addLayerToGroup(t.groupId,void 0===typeof t.groupVisible||t.groupVisible,{id:e,elementId:t.layerElementId??t.elementId??null,layer:i}),this.layerGroups.apply(),e}))}async setBaseLayer(t,e){await this.layerManagerMutex.runExclusive((async()=>{this.layerGroups.setBasemap(t,e??null),this.layerGroups.apply()}))}async addBaseLayer(t,e,i){return i&&e?await this.layerManagerMutex.runExclusive((async()=>{const s=crypto.randomUUID(),r=await this.createLayer(t,s);return this.layerGroups.addLayerToGroup(t.groupId,void 0===typeof t.groupVisible||t.groupVisible,{id:s,elementId:i,layer:r}),this.layerGroups.setBasemap(t.groupId??"basemap",e),this.layerGroups.apply(),s})):null}async ensureGroup(t,e,i){this.layerGroups.ensureGroup(t,e)}async setGroupVisible(t,e){this.layerGroups.setGroupVisible(t,e),this.layerGroups.apply()}onLayerError(t,e){this.layerErrorCallbacks.set(t,e),this.attachCesiumErrorListeners(t)}offLayerError(t){this.layerErrorCleanups.get(t)?.(),this.layerErrorCleanups.delete(t),this.layerErrorCallbacks.delete(t)}attachCesiumErrorListeners(t){this.layerErrorCleanups.get(t)?.();const e=this.layerErrorCallbacks.get(t);if(!e)return;const i=this.layerManager.getLayer(t);if(!i)return;const s=[],r=()=>{e({type:"network",message:"Tile load error"})},a=i._imageryLayer;if(a?.imageryProvider?.errorEvent){const t=a.imageryProvider.errorEvent.addEventListener(r);s.push(t)}const n=i._tileset;if(n?.tileFailed){const t=n.tileFailed.addEventListener(r);s.push(t)}s.length>0&&this.layerErrorCleanups.set(t,(()=>s.forEach((t=>t()))))}async removeLayer(t){t&&(this.offLayerError(t),await this.layerManagerMutex.runExclusive((async()=>{this.layerManager.removeLayer(t),this.layerGroups.removeLayer(t,!0),this.layerGroups.apply()})))}async setOpacity(t,e){this.layerManager.setOpacity(t,e),this.layerGroups.apply()}async setVisible(t,e){this.layerManager.setVisible(t,e),this.layerGroups.apply()}async setZIndex(t,e){await this.layerManager.setZIndex(t,e),this.layerGroups.apply()}applyGeostylerStyling(t,i){t.__vmapLockOpacity=!0;const s=(t,e)=>null==t||"object"==typeof t&&null!==t&&"name"in t?e:t,r=(t,e)=>{if(null==t)return e;if("number"==typeof t)return t;const i=Number(t);return Number.isFinite(i)?i:e},a=t.entities.values;if(i.rules)for(const t of i.rules)if(t.symbolizers)for(const i of t.symbolizers)for(let t=0;t<a.length;t++){const n=a[t];switch(i.kind){case"Fill":if(n.polygon){const t=s(i.color,"rgba(0,100,255,0.3)"),a=r(s(i.opacity,.3),.3),o=s(i.outlineColor,"rgba(0,100,255,1)"),h=s(i.outlineWidth,1);let c=this.parseCesiumColor(t,this.Cesium.Color.BLUE.withAlpha(.3));null!=a&&(c=this.applyCesiumOpacity(c,a));const l=this.parseCesiumColor(o,this.Cesium.Color.BLUE);e("v-map - provider - cesium - applyGeostylerStyling: Fill",{fillColor:t,fillOpacity:a,computedFill:c?.toString?.(),outlineColor:o,outlineWidth:h}),n.polygon.fill=new this.Cesium.ConstantProperty(!0),n.polygon.material=new this.Cesium.ColorMaterialProperty(c),n.polygon.outline=new this.Cesium.ConstantProperty(!0),n.polygon.outlineColor=new this.Cesium.ConstantProperty(l),n.polygon.outlineWidth=new this.Cesium.ConstantProperty(h),n.polygon.extrudedHeight=void 0,n.polygon.heightReference=new this.Cesium.ConstantProperty(this.Cesium.HeightReference.CLAMP_TO_GROUND),n.polygon.perPositionHeight=new this.Cesium.ConstantProperty(!1),n.polygon.classificationType=new this.Cesium.ConstantProperty(this.Cesium.ClassificationType.BOTH)}break;case"Line":if(n.polyline){const t=s(i.color,"rgba(0,100,255,1)"),a=r(s(i.width,2),2),o=r(s(i.opacity,1),1);let h=this.parseCesiumColor(t,this.Cesium.Color.BLUE);null!=o&&(h=this.applyCesiumOpacity(h,o)),e("v-map - provider - cesium - applyGeostylerStyling: Line",{lineColor:t,lineOpacity:o,computedColor:h?.toString?.(),lineWidth:a}),n.polyline.material=new this.Cesium.ColorMaterialProperty(h),n.polyline.width=new this.Cesium.ConstantProperty(a)}break;case"Mark":if(n.point){const t=s(i.color,"rgba(0,100,255,1)"),a=r(s(i.radius,6),6),o=r(s(i.opacity,1),1);let h=this.parseCesiumColor(t,this.Cesium.Color.BLUE);null!=o&&(h=this.applyCesiumOpacity(h,o)),e("v-map - provider - cesium - applyGeostylerStyling: Mark",{pointColor:t,pointOpacity:o,computedColor:h?.toString?.(),pointRadius:a}),n.point.color=new this.Cesium.ConstantProperty(h),n.point.pixelSize=new this.Cesium.ConstantProperty(a)}break;case"Icon":if(n.point){const t=s(i.image),a=r(s(i.size,32),32),o=r(s(i.opacity,1),1);t&&"string"==typeof t&&(n.billboard=new this.Cesium.BillboardGraphics({image:new this.Cesium.ConstantProperty(t),width:new this.Cesium.ConstantProperty(a),height:new this.Cesium.ConstantProperty(a),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM),color:null!=o?new this.Cesium.ConstantProperty(this.Cesium.Color.WHITE.withAlpha(o)):void 0}),n.point.show=new this.Cesium.ConstantProperty(!1),e("v-map - provider - cesium - applyGeostylerStyling: Icon",{iconSrc:t,iconSize:a,iconOpacity:o}))}break;case"Text":const t=i.label,a="string"==typeof t?t:void 0;if(a&&n.properties&&n.properties[a]){const t=s(i.color,"#000000"),o=r(s(i.size,12),12),h=r(s(i.opacity,1),1);let c=this.parseCesiumColor(t,this.Cesium.Color.WHITE);null!=h&&(c=this.applyCesiumOpacity(c,h)),e("v-map - provider - cesium - applyGeostylerStyling: Text",{labelProp:a,textColor:t,textOpacity:h,computedColor:c?.toString?.(),textSize:o});const l=n.properties[a]?.getValue?.(this.viewer.clock.currentTime)??n.properties[a]?._value??"";n.label=new this.Cesium.LabelGraphics({text:new this.Cesium.ConstantProperty(String(l)),font:new this.Cesium.ConstantProperty(`${o}px Arial`),fillColor:new this.Cesium.ConstantProperty(c),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM)})}}}}parseCesiumColor(t,e){if(!t)return e;if(t.startsWith("#"))return this.Cesium.Color.fromCssColorString(t);if(t.includes("rgb"))return this.Cesium.Color.fromCssColorString(t);try{return this.Cesium.Color.fromCssColorString(t)}catch{return e}}applyCesiumOpacity(t,e){return t?t.withAlpha(e):t}createCesiumStyle(t={}){const e=this.Cesium.Color.BLUE.withAlpha(.3),i=this.Cesium.Color.BLUE,s=this.Cesium.Color.BLUE,r=this.parseCesiumColor(t.fillColor,e),a=this.parseCesiumColor(t.strokeColor,i),n=this.parseCesiumColor(t.pointColor,s),o=void 0!==t.fillOpacity?this.applyCesiumOpacity(r,t.fillOpacity):r,h=void 0!==t.strokeOpacity?this.applyCesiumOpacity(a,t.strokeOpacity):a,c=void 0!==t.pointOpacity?this.applyCesiumOpacity(n,t.pointOpacity):n;return{fill:!0,fillColor:o,outline:!0,outlineColor:h,outlineWidth:t.strokeWidth??2,extrudedHeight:t.extrudeHeight,heightReference:t.zOffset?this.Cesium.HeightReference.RELATIVE_TO_GROUND:this.Cesium.HeightReference.CLAMP_TO_GROUND,pixelSize:t.pointRadius??8,color:c,scaleByDistance:t.pointRadius?new this.Cesium.NearFarScalar(150,2,15e6,.5):void 0,width:t.strokeWidth??2,clampToGround:!t.zOffset,labelText:t.textProperty,labelFont:t.textSize?`${t.textSize}pt monospace`:"12pt monospace",labelFillColor:t.textColor?this.parseCesiumColor(t.textColor,this.Cesium.Color.WHITE):this.Cesium.Color.WHITE,labelOutlineColor:t.textHaloColor?this.parseCesiumColor(t.textHaloColor,this.Cesium.Color.BLACK):this.Cesium.Color.BLACK,labelOutlineWidth:t.textHaloWidth??1,labelPixelOffset:t.textOffset?new this.Cesium.Cartesian2(t.textOffset[0],t.textOffset[1]):this.Cesium.Cartesian2.ZERO,height:t.zOffset??0}}applyEnhancedStyling(t,e={}){const i=this.createCesiumStyle(e),s=t.entities.values;for(let t=0;t<s.length;t++){const r=s[t];let a=i;if(e.styleFunction&&r.properties){const t={properties:r.properties._propertyNames.reduce(((t,e)=>(t[e]=r.properties[e]?._value,t)),{}),geometry:r},s=e.styleFunction(t);s&&(a={...i,...this.createCesiumStyle(s)})}if(r.polygon&&(r.polygon.fill=new this.Cesium.ConstantProperty(a.fill),r.polygon.material=new this.Cesium.ColorMaterialProperty(a.fillColor),r.polygon.outline=new this.Cesium.ConstantProperty(a.outline),r.polygon.outlineColor=new this.Cesium.ConstantProperty(a.outlineColor),r.polygon.outlineWidth=new this.Cesium.ConstantProperty(a.outlineWidth),r.polygon.height=void 0!==a.height?new this.Cesium.ConstantProperty(a.height):void 0,r.polygon.extrudedHeight=void 0!==a.extrudedHeight?new this.Cesium.ConstantProperty(a.extrudedHeight):void 0,r.polygon.heightReference=void 0!==a.heightReference?new this.Cesium.ConstantProperty(a.heightReference):void 0),r.polyline&&(r.polyline.material=new this.Cesium.ColorMaterialProperty(a.outlineColor),r.polyline.width=new this.Cesium.ConstantProperty(a.width),r.polyline.clampToGround=new this.Cesium.ConstantProperty(a.clampToGround)),r.point){r.point.pixelSize=new this.Cesium.ConstantProperty(a.pixelSize),r.point.color=new this.Cesium.ConstantProperty(a.color);const t=a.scaleByDistance;r.point.scaleByDistance=t?new this.Cesium.ConstantProperty(t):void 0,e.iconUrl&&(r.billboard=new this.Cesium.BillboardGraphics({image:new this.Cesium.ConstantProperty(e.iconUrl),width:new this.Cesium.ConstantProperty(e.iconSize?e.iconSize[0]:32),height:new this.Cesium.ConstantProperty(e.iconSize?e.iconSize[1]:32),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM),scaleByDistance:t?new this.Cesium.ConstantProperty(t):void 0}),r.point.show=new this.Cesium.ConstantProperty(!1))}if(e.textProperty&&r.properties&&r.properties[e.textProperty]){const t=r.properties[e.textProperty]?.getValue?.(this.viewer.clock.currentTime)??r.properties[e.textProperty]?._value??"";r.label=new this.Cesium.LabelGraphics({text:new this.Cesium.ConstantProperty(String(t)),font:new this.Cesium.ConstantProperty(a.labelFont),fillColor:new this.Cesium.ConstantProperty(a.labelFillColor),outlineColor:new this.Cesium.ConstantProperty(a.labelOutlineColor),outlineWidth:new this.Cesium.ConstantProperty(a.labelOutlineWidth),pixelOffset:new this.Cesium.ConstantProperty(a.labelPixelOffset),verticalOrigin:new this.Cesium.ConstantProperty(this.Cesium.VerticalOrigin.BOTTOM)})}}}async createWKTLayer(t,e){const i=await this.wktToGeoJSON(t),s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async wktToGeoJSON(t){const e=await this.resolveWktText(t),i=await import("./index5.js").then((function(t){return t.i})),s="function"==typeof i.default?i.default:i.parse;if("function"!=typeof s)throw new Error("wellknown parser not available");const r=s(e);if(!r)throw new Error("Failed to parse WKT");return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:r}]}}async resolveWktText(t){if(t.wkt)return t.wkt;if(t.url){const e=await fetch(t.url);if(!e.ok)throw new Error(`Failed to fetch WKT: ${e.status}`);return await e.text()}throw new Error("Either wkt or url must be provided")}async createGeoJSONLayer(t,e){let i=null;i=t.geojson?JSON.parse(t.geojson):t.url;const s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async createWFSLayer(t,e){const i=await this.fetchWFSFromUrl(t),s=await this.Cesium.GeoJsonDataSource.load(i,e);return t.geostylerStyle?this.applyGeostylerStyling(s,t.geostylerStyle):t.style&&this.applyEnhancedStyling(s,t.style),s}async createOSMLayer(t){return new this.Cesium.ImageryLayer(new this.Cesium.OpenStreetMapImageryProvider({url:t.url||"https://a.tile.openstreetmap.org"}))}async createGoogleLayer(t){if(!t.apiKey)throw new Error("Google-Layer benötigt 'apiKey' (Google Maps Platform).");await this.loadGoogleMapsApi(t.apiKey,{language:t.language,region:t.region,libraries:t.libraries});const e=this.getGoogleMapTypeId(t.mapType||"roadmap"),i=this.Cesium,s=new i.UrlTemplateImageryProvider({url:"https://maps.googleapis.com/maps/api/staticmap?template",maximumLevel:t.maxZoom||19,minimumLevel:0,tilingScheme:new i.WebMercatorTilingScheme,credit:"Google Maps",urlSchemeZeroPadding:{"{x}":"","{y}":"","{z}":""}});return s.buildImageResource=function(s,r,a){const n=(new i.WebMercatorTilingScheme).tileXYToRectangle(s,r,a),o=i.Math.toDegrees(n.west),h=i.Math.toDegrees(n.south),c=i.Math.toDegrees(n.east),l=i.Math.toDegrees(n.north),u=new URLSearchParams({center:`${(h+l)/2},${(o+c)/2}`,zoom:a.toString(),size:"256x256",scale:"scaleFactor1x"===t.scale?"1":"2",maptype:e,key:t.apiKey,format:"png"});t.language&&u.set("language",t.language),t.region&&u.set("region",t.region);const w=`https://maps.googleapis.com/maps/api/staticmap?${u.toString()}`;return new i.Resource({url:w})},this.ensureGoogleLogo(),new this.Cesium.ImageryLayer(s,{alpha:t.opacity??1,show:t.visible??!0})}getGoogleMapTypeId(t){switch(t){case"roadmap":default:return"roadmap";case"satellite":return"satellite";case"terrain":return"terrain";case"hybrid":return"hybrid"}}async loadGoogleMapsApi(t,e){const i=window,s=i.__mockGoogleMapsApi;"function"!=typeof s?i.google?.maps||await new Promise(((s,r)=>{const a="___cesiumGoogleInit___"+Math.random().toString(36).slice(2);i[a]=()=>s();const n=document.createElement("script"),o=new URLSearchParams({key:t,callback:a,v:"weekly"});e?.language&&o.set("language",e.language),e?.region&&o.set("region",e.region),e?.libraries?.length&&o.set("libraries",e.libraries.join(",")),n.src=`https://maps.googleapis.com/maps/api/js?${o.toString()}`,n.async=!0,n.onerror=()=>r(new Error("Google Maps JS API failed to load")),document.head.appendChild(n)})):await s(t,e)}ensureGoogleLogo(){if(!this.viewer?.container||this.viewer.container._googleLogoAdded)return;const t=document.createElement("img");t.src="https://developers.google.com/static/maps/documentation/images/google_on_white.png",t.alt="Google",t.style.position="absolute",t.style.bottom="6px",t.style.left="6px",t.style.height="18px",t.style.pointerEvents="none",t.style.zIndex="1000",this.viewer.container.appendChild(t),this.viewer.container._googleLogoAdded=!0}async createXYZLayer(t){if(!t.url)throw new Error("XYZ layer requires a url");const e=Array.isArray(t.attributions)?t.attributions.join(", "):t.attributions,i={url:t.url,credit:e,maximumLevel:t.maxZoom,...t.options||{}},s=new this.Cesium.UrlTemplateImageryProvider(i);return new this.Cesium.ImageryLayer(s,{alpha:t.opacity??1,show:t.visible??!0})}async createTerrainLayer(t){let e;e=t.elevationData?await this.Cesium.CesiumTerrainProvider.fromUrl(t.elevationData):await this.Cesium.createWorldTerrainAsync();const i=new v(this.Cesium,this.viewer,e,t);return void 0!==t.visible&&i.setVisible(t.visible),void 0!==t.opacity&&i.setOpacity(t.opacity),i}async createGeoTIFFTerrainLayer(t){if(!t.url){e(`${g}layer created without URL, waiting for URL to load`);const i=new this.Cesium.EllipsoidTerrainProvider,s=new v(this.Cesium,this.viewer,i,t);return s.setVisible(!1),s}try{e(`${g}create layer: url=${t.url}`);const i=await async function(t){const e=new f(t);return await e.readyPromise,e}({url:t.url,projection:t.projection,forceProjection:t.forceProjection,nodata:t.nodata,Cesium:this.Cesium}),s=new v(this.Cesium,this.viewer,i,t);return void 0!==t.visible&&s.setVisible(t.visible),void 0!==t.opacity&&s.setOpacity(t.opacity),e(`${g}layer created successfully`),s}catch(e){i(`${g}failed to create terrain layer:`,e);const s=new this.Cesium.EllipsoidTerrainProvider;return new v(this.Cesium,this.viewer,s,t)}}async addWMSLayer(t){return new this.Cesium.ImageryLayer(new this.Cesium.WebMapServiceImageryProvider({url:t.url,layers:t.layers,parameters:t.extraParams}))}async createWCSLayer(t){if(!t.url||!t.coverageName)throw new Error("WCS layer requires url and coverageName");const e=t.version??"2.0.1",i=t.format??"image/tiff",s=t.projection??"EPSG:4326",r=t.tileSize??256,a=this.Cesium,n=new a.UrlTemplateImageryProvider({url:`${t.url}?wcs_placeholder`,maximumLevel:t.maxZoom??18,minimumLevel:t.minZoom??0,tileWidth:r,tileHeight:r,tilingScheme:new a.GeographicTilingScheme,credit:"WCS"});return n.buildImageResource=function(n,o,h){const c=(new a.GeographicTilingScheme).tileXYToRectangle(n,o,h),l=a.Math.toDegrees(c.west),u=a.Math.toDegrees(c.south),w=a.Math.toDegrees(c.east),p=a.Math.toDegrees(c.north),m={SERVICE:"WCS",REQUEST:"GetCoverage",VERSION:e,FORMAT:i};let d;if(e.startsWith("2.0")){const e={...m,coverageId:t.coverageName,...t.params||{}};(i.includes("tiff")||i.includes("geotiff"))&&(e["geotiff:compression"]="LZW");const s=new URLSearchParams;Object.entries(e).forEach((([t,e])=>{null!=e&&s.set(t,String(e))}));const r=s.toString(),a=`subset=X(${l},${w})`,n=`subset=Y(${u},${p})`;d=`${t.url}${t.url.includes("?")?"&":"?"}${r}&${a}&${n}`}else{const e={...m,COVERAGE:t.coverageName,BBOX:`${l},${u},${w},${p}`,CRS:s,WIDTH:String(r),HEIGHT:String(r),...t.params||{}},i=new URLSearchParams;Object.entries(e).forEach((([t,e])=>{null!=e&&i.set(t,String(e))})),d=`${t.url}${t.url.includes("?")?"&":"?"}${i.toString()}`}return new a.Resource({url:d})},new this.Cesium.ImageryLayer(n,{alpha:t.opacity??1,show:t.visible??!0})}async addArcGISLayer(t){const e=await this.Cesium.ArcGisMapServerImageryProvider.fromUrl(t.url);this.viewer.imageryLayers.addImageryProvider(e)}async createGeoTIFFLayer(t){if(!t.url)throw new Error("GeoTIFF layer requires a URL");try{const e=t,i=await a(t.url,e.projection,e.forceProjection,t.nodata),s=await n(i,"EPSG:3857"),r=new o(s);let c;if(r.createGlobalTriangulation(),t.colorMap){const{stops:e}=h(t.colorMap,t.valueRange);c=e}const l=new d({Cesium:this.Cesium,rectangleDegrees:i.wgs84Bounds,tileProcessor:r,tileSize:t.tileSize??256,resolution:t.resolution??1,resampleMethod:t.resampleMethod??"bilinear",colorStops:c}),u=new this.Cesium.ImageryLayer(l,{alpha:t.opacity??1,show:t.visible??!0});return u.__vmapGeoTIFFMeta={url:t.url,width:i.width,height:i.height,samplesPerPixel:i.samplesPerPixel,noData:i.noDataValue},u}catch(t){i("v-map - provider - cesium - Failed to create GeoTIFF layer",t);const e=new this.Cesium.SingleTileImageryProvider({url:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==",rectangle:this.Cesium.Rectangle.fromDegrees(-180,-90,180,90)});return new this.Cesium.ImageryLayer(e,{alpha:0,show:!1})}}async createTile3DLayer(t){if(!t.url)throw new Error("Tile3D layer requires a URL");const e=await this.Cesium.Cesium3DTileset.fromUrl(t.url,t.tilesetOptions??{});return t.cesiumStyle&&(e.style=new this.Cesium.Cesium3DTileStyle(t.cesiumStyle)),e}async updateLayer(t,e){return await this.layerManagerMutex.runExclusive((async()=>{const i=this.layerErrorCallbacks.has(t);i&&this.offLayerError(t);const s=this.layerManager.getLayer(t);switch(e.type){case"geojson":{const i=e.data,r=s.getOptions(),a=await this.createGeoJSONLayer({geojson:i.geojson,url:i.url,style:i.style,geostylerStyle:i.geostylerStyle},r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"wfs":{const i=e.data,r=s.getOptions(),a=await this.createWFSLayer(i,r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"osm":{const i=s.getOptions(),r=new this.Cesium.ImageryLayer(new this.Cesium.OpenStreetMapImageryProvider({url:e.data.url||"https://a.tile.openstreetmap.org"}));this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"google":{const i=s.getOptions(),r=await this.createGoogleLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"xyz":{const i=s.getOptions(),r=await this.createXYZLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"wcs":{const i=s.getOptions(),r=await this.createWCSLayer(e.data);this.layerManager.replaceLayer(t,s,r).setOptions(i)}break;case"wkt":{const i=e.data,r=s.getOptions(),a=await this.createWKTLayer({wkt:i.wkt,url:i.url,style:i.style,geostylerStyle:i.geostylerStyle},r);this.layerManager.replaceLayer(t,s,a).setOptions(r)}break;case"geotiff":{const i=e.data,r=await this.createGeoTIFFLayer({url:i.url});this.layerManager.replaceLayer(t,s,r)}break;case"tile3d":{const i=e.data??{};if(!i.url)throw new Error("tile3d update requires a url");const r=await this.createTile3DLayer({type:"tile3d",url:i.url,tilesetOptions:i.tilesetOptions,cesiumStyle:i.cesiumStyle}),a=this.layerManager.replaceLayer(t,s,r);a.setOptions(i.tilesetOptions??{}),i.cesiumStyle&&"setStyle"in a&&a.setStyle(i.cesiumStyle)}break;case"tile3d-style":"setStyle"in s&&s.setStyle((e.data??{}).style??{});break;case"terrain":{const i=s.getOptions(),r=s.getVisible(),a=s.getOpacity();s.remove();const n=await this.createTerrainLayer({type:"terrain",...i,...e.data??{}}),o=this.layerManager.addCustomLayer(t,n);o.setVisible(r),o.setOpacity(a)}break;case"terrain-geotiff":{s.remove();const i=await this.createGeoTIFFTerrainLayer({type:"terrain-geotiff",...e.data??{}});this.layerManager.addCustomLayer(t,i)}}i&&this.attachCesiumErrorListeners(t)}))}async setView(i,s){if(!this.viewer)return;const[r,a]=i;this.viewer.camera.flyTo({destination:this.Cesium.Cartesian3.fromDegrees(r,a,1e6/s),duration:2,orientation:{heading:this.Cesium.Math.toRadians(0),pitch:this.Cesium.Math.toRadians(-30),roll:0},complete:()=>e("v-map - provider - cesium - Fly‑to finished"),cancel:()=>t("v-map - provider - cesium - Fly‑to cancelled")})}async fetchWFSFromUrl(t){const e={service:"WFS",request:"GetFeature",version:t.version??"1.1.0",typeName:t.typeName,outputFormat:t.outputFormat??"application/json",srsName:t.srsName??"EPSG:4326",...t.params??{}},i=this.appendParams(t.url,e),s=await fetch(i);if(!s.ok)throw new Error(`WFS request failed (${s.status} ${s.statusText})`);const r=(t.outputFormat??"application/json").toLowerCase();if(r.includes("json")||r.includes("geojson")||"application/json"===r){const t=s.headers.get("content-type");if(t?.includes("application/json"))return await s.json();const e=await s.text();return JSON.parse(e)}if(r.includes("gml")||r.includes("xml")){const t=await s.text(),{GmlParser:e}=await import("./index.browser.js"),i=new e;return await i.parse(t)}return await s.json()}appendParams(t,e){const i=new URLSearchParams;return Object.entries(e).forEach((([t,e])=>{null!=e&&i.set(t,String(e))})),i.toString()?`${t}${t.includes("?")?"&":"?"}${i.toString()}`:t}}export{b as CesiumProvider}