maplibre-preview 1.4.0 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1195 @@
1
+ !function (t, e) {
2
+ "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).mlcontour = e()
3
+ }(this, (function () {
4
+ "use strict";
5
+ var t, e, i;
6
+
7
+ function r(r, s) {
8
+ if (t) if (e) {
9
+ var n = "var sharedChunk = {}; (" + t + ")(sharedChunk); (" + e + ")(sharedChunk);", o = {};
10
+ t(o), i = s(o), "undefined" != typeof window && (i.workerUrl = window.URL.createObjectURL(new Blob([n], {type: "text/javascript"})))
11
+ } else e = s; else t = s
12
+ }
13
+
14
+ return r(0, (function (t) {
15
+ class e {
16
+ constructor(t, e) {
17
+ this.start = t, this.end = e, this.points = [], this.append = this.append.bind(this), this.prepend = this.prepend.bind(this)
18
+ }
19
+
20
+ append(t, e) {
21
+ this.points.push(Math.round(t), Math.round(e))
22
+ }
23
+
24
+ prepend(t, e) {
25
+ this.points.splice(0, 0, Math.round(t), Math.round(e))
26
+ }
27
+
28
+ lineString() {
29
+ return this.toArray()
30
+ }
31
+
32
+ isEmpty() {
33
+ return this.points.length < 2
34
+ }
35
+
36
+ appendFragment(t) {
37
+ this.points.push(...t.points), this.end = t.end
38
+ }
39
+
40
+ toArray() {
41
+ return this.points
42
+ }
43
+ }
44
+
45
+ const i = [[], [[[1, 2], [0, 1]]], [[[2, 1], [1, 2]]], [[[2, 1], [0, 1]]], [[[1, 0], [2, 1]]], [[[1, 2], [0, 1]], [[1, 0], [2, 1]]], [[[1, 0], [1, 2]]], [[[1, 0], [0, 1]]], [[[0, 1], [1, 0]]], [[[1, 2], [1, 0]]], [[[0, 1], [1, 0]], [[2, 1], [1, 2]]], [[[2, 1], [1, 0]]], [[[0, 1], [2, 1]]], [[[1, 2], [2, 1]]], [[[0, 1], [1, 2]]], []];
46
+
47
+ function r(t, e, i, r) {
48
+ return (e = 2 * e + r[0]) + (i = 2 * i + r[1]) * (t + 1) * 2
49
+ }
50
+
51
+ function s(t, e, i) {
52
+ return (e - t) / (i - t)
53
+ }
54
+
55
+ function n(t, n, o = 4096, a = 1) {
56
+ if (!t) return {};
57
+ const h = o / (n.width - 1);
58
+ let l, c, d, u, f, p;
59
+ const w = {}, g = new Map, m = new Map;
60
+
61
+ function b(t, e, i) {
62
+ 0 === t[0] ? i(h * (p - 1), h * (f - s(d, e, l))) : 2 === t[0] ? i(h * p, h * (f - s(u, e, c))) : 0 === t[1] ? i(h * (p - s(c, e, l)), h * (f - 1)) : i(h * (p - s(u, e, d)), h * f)
63
+ }
64
+
65
+ for (f = 1 - a; f < n.height + a; f++) {
66
+ c = n.get(0, f - 1), u = n.get(0, f);
67
+ let s = Math.min(c, u), o = Math.max(c, u);
68
+ for (p = 1 - a; p < n.width + a; p++) {
69
+ l = c, d = u, c = n.get(p, f - 1), u = n.get(p, f);
70
+ const a = s, h = o;
71
+ if (s = Math.min(c, u), o = Math.max(c, u), isNaN(l) || isNaN(c) || isNaN(u) || isNaN(d)) continue;
72
+ const y = Math.min(a, s), v = Math.max(h, o), P = Math.ceil(y / t) * t, x = Math.floor(v / t) * t;
73
+ for (let s = P; s <= x; s += t) {
74
+ const t = l > s, o = c > s, a = d > s, h = u > s;
75
+ for (const l of i[(t ? 8 : 0) | (o ? 4 : 0) | (h ? 2 : 0) | (a ? 1 : 0)]) {
76
+ let t = g.get(s);
77
+ t || g.set(s, t = new Map);
78
+ let i = m.get(s);
79
+ i || m.set(s, i = new Map);
80
+ const o = l[0], a = l[1], h = r(n.width, p, f, o), c = r(n.width, p, f, a);
81
+ let d, u;
82
+ if (d = i.get(h)) if (i.delete(h), u = t.get(c)) if (t.delete(c), d === u) {
83
+ if (b(a, s, d.append), !d.isEmpty()) {
84
+ let t = w[s];
85
+ t || (w[s] = t = []), t.push(d.lineString())
86
+ }
87
+ } else d.appendFragment(u), i.set(d.end = u.end, d); else b(a, s, d.append), i.set(d.end = c, d); else if (d = t.get(c)) t.delete(c), b(o, s, d.prepend), t.set(d.start = h, d); else {
88
+ const r = new e(h, c);
89
+ b(o, s, r.append), b(a, s, r.append), t.set(h, r), i.set(c, r)
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ for (const [t, e] of g.entries()) {
96
+ let i = null;
97
+ for (const r of e.values()) r.isEmpty() || (null == i && (i = w[t] || (w[t] = [])), i.push(r.lineString()))
98
+ }
99
+ return w
100
+ }
101
+
102
+ /*! *****************************************************************************
103
+ Copyright (c) Microsoft Corporation.
104
+
105
+ Permission to use, copy, modify, and/or distribute this software for any
106
+ purpose with or without fee is hereby granted.
107
+
108
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
109
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
110
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
111
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
112
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
113
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
114
+ PERFORMANCE OF THIS SOFTWARE.
115
+ ***************************************************************************** */
116
+ function o(t, e) {
117
+ var i = {};
118
+ for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (i[r] = t[r]);
119
+ if (null != t && "function" == typeof Object.getOwnPropertySymbols) {
120
+ var s = 0;
121
+ for (r = Object.getOwnPropertySymbols(t); s < r.length; s++) e.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[s]) && (i[r[s]] = t[r[s]])
122
+ }
123
+ return i
124
+ }
125
+
126
+ function a(t, e, i, r) {
127
+ return new (i || (i = Promise))((function (s, n) {
128
+ function o(t) {
129
+ try {
130
+ h(r.next(t))
131
+ } catch (t) {
132
+ n(t)
133
+ }
134
+ }
135
+
136
+ function a(t) {
137
+ try {
138
+ h(r.throw(t))
139
+ } catch (t) {
140
+ n(t)
141
+ }
142
+ }
143
+
144
+ function h(t) {
145
+ var e;
146
+ t.done ? s(t.value) : (e = t.value, e instanceof i ? e : new i((function (t) {
147
+ t(e)
148
+ }))).then(o, a)
149
+ }
150
+
151
+ h((r = r.apply(t, e || [])).next())
152
+ }))
153
+ }
154
+
155
+ function h(t) {
156
+ const e = Object.entries(t);
157
+ return e.sort((([t], [e]) => t < e ? -1 : t > e ? 1 : 0)), e
158
+ }
159
+
160
+ function l(t) {
161
+ return h(t).map((([t, e]) => [t, ..."number" == typeof e ? [e] : e].join("*"))).join("~")
162
+ }
163
+
164
+ function c(t) {
165
+ return h(t).map((([t, e]) => `${encodeURIComponent(t)}=${encodeURIComponent(e)}`)).join(",")
166
+ }
167
+
168
+ let d = null;
169
+
170
+ function u() {
171
+ return null == d && (d = "undefined" != typeof OffscreenCanvas && new OffscreenCanvas(1, 1).getContext("2d") && "function" == typeof createImageBitmap), d || !1
172
+ }
173
+
174
+ let f = null;
175
+
176
+ function p(t, e, i) {
177
+ let r = () => {
178
+ };
179
+ const s = setTimeout((() => {
180
+ r(new Error("timed out")), null == i || i.abort()
181
+ }), t);
182
+ w(i, (() => {
183
+ r(new Error("aborted")), clearTimeout(s)
184
+ }));
185
+ const n = new Promise(((t, e) => {
186
+ r = e
187
+ }));
188
+ return Promise.race([n, e.finally((() => clearTimeout(s)))])
189
+ }
190
+
191
+ function w(t, e) {
192
+ e && (null == t || t.signal.addEventListener("abort", e))
193
+ }
194
+
195
+ function g(t) {
196
+ var e;
197
+ return Boolean(null === (e = null == t ? void 0 : t.signal) || void 0 === e ? void 0 : e.aborted)
198
+ }
199
+
200
+ let m, b, y, v, P = 0;
201
+
202
+ class x {
203
+ constructor(t = 100) {
204
+ this.size = () => this.items.size, this.get = (t, e, i) => {
205
+ let r = this.items.get(t);
206
+ if (r) r.lastUsed = ++P, r.waiting++; else {
207
+ const i = new AbortController, s = e(t, i);
208
+ r = {abortController: i, item: s, lastUsed: ++P, waiting: 1}, this.items.set(t, r), this.prune()
209
+ }
210
+ const s = this.items, n = r.item.then((t => t), (e => (s.delete(t), Promise.reject(e))));
211
+ let o = !1;
212
+ return w(i, (() => {
213
+ var e;
214
+ r && r.abortController && !o && (o = !0, --r.waiting <= 0 && (null === (e = r.abortController) || void 0 === e || e.abort(), s.delete(t)))
215
+ })), n
216
+ }, this.clear = () => this.items.clear(), this.maxSize = t, this.items = new Map
217
+ }
218
+
219
+ prune() {
220
+ if (this.items.size > this.maxSize) {
221
+ let t, e = 1 / 0;
222
+ this.items.forEach(((i, r) => {
223
+ i.lastUsed < e && (e = i.lastUsed, t = r)
224
+ })), void 0 !== t && this.items.delete(t)
225
+ }
226
+ }
227
+ }
228
+
229
+ function F(t, e) {
230
+ return m || (m = new OffscreenCanvas(t.width, t.height), b = m.getContext("2d", {willReadFrequently: !0})), V(t, e, m, b)
231
+ }
232
+
233
+ const k = function () {
234
+ if (null == f && (f = !1, u() && "undefined" != typeof VideoFrame)) {
235
+ const t = 5, e = new OffscreenCanvas(5, 5).getContext("2d", {willReadFrequently: !0});
236
+ if (e) {
237
+ for (let i = 0; i < t * t; i++) {
238
+ const r = 4 * i;
239
+ e.fillStyle = `rgb(${r},${r + 1},${r + 2})`, e.fillRect(i % t, Math.floor(i / t), 1, 1)
240
+ }
241
+ const i = e.getImageData(0, 0, t, t).data;
242
+ for (let e = 0; e < t * t * 4; e++) if (e % 4 != 3 && i[e] !== e) {
243
+ f = !0;
244
+ break
245
+ }
246
+ }
247
+ }
248
+ return f || !1
249
+ }() ? function (t, e, i) {
250
+ return a(this, void 0, void 0, (function* () {
251
+ var r, s, n;
252
+ const o = yield createImageBitmap(t);
253
+ if (g(i)) return null;
254
+ const a = new VideoFrame(o, {timestamp: 0});
255
+ try {
256
+ if (!((null === (r = null == a ? void 0 : a.format) || void 0 === r ? void 0 : r.startsWith("BGR")) || (null === (s = null == a ? void 0 : a.format) || void 0 === s ? void 0 : s.startsWith("RGB")))) throw new Error(`Unrecognized format: ${null == a ? void 0 : a.format}`);
257
+ const t = null === (n = null == a ? void 0 : a.format) || void 0 === n ? void 0 : n.startsWith("BGR"),
258
+ i = a.allocationSize(), h = new Uint8ClampedArray(i);
259
+ if (yield a.copyTo(h), t) for (let t = 0; t < h.length; t += 4) {
260
+ const e = h[t];
261
+ h[t] = h[t + 2], h[t + 2] = e
262
+ }
263
+ return M(o.width, o.height, e, h)
264
+ } catch (t) {
265
+ return g(i) ? null : F(o, e)
266
+ } finally {
267
+ a.close()
268
+ }
269
+ }))
270
+ } : u() ? function (t, e, i) {
271
+ return a(this, void 0, void 0, (function* () {
272
+ const r = yield createImageBitmap(t);
273
+ return g(i) ? null : F(r, e)
274
+ }))
275
+ } : "undefined" != typeof WorkerGlobalScope && "undefined" != typeof self && self instanceof WorkerGlobalScope ? function (t, e, i) {
276
+ return self.actor.send("decodeImage", [], i, void 0, t, e)
277
+ } : function (t, e, i) {
278
+ return a(this, void 0, void 0, (function* () {
279
+ y || (y = document.createElement("canvas"), v = y.getContext("2d", {willReadFrequently: !0}));
280
+ const r = new Image;
281
+ w(i, (() => r.src = ""));
282
+ return V(yield new Promise(((e, s) => {
283
+ r.onload = () => {
284
+ g(i) || e(r), URL.revokeObjectURL(r.src), r.onload = null
285
+ }, r.onerror = () => s(new Error("Could not load image.")), r.src = t.size ? URL.createObjectURL(t) : ""
286
+ })), e, y, v)
287
+ }))
288
+ };
289
+
290
+ function V(t, e, i, r) {
291
+ if (i.width = t.width, i.height = t.height, !r) throw new Error("failed to get context");
292
+ r.drawImage(t, 0, 0, t.width, t.height);
293
+ const s = r.getImageData(0, 0, t.width, t.height).data;
294
+ return M(t.width, t.height, e, s)
295
+ }
296
+
297
+ function M(t, e, i, r) {
298
+ const s = "mapbox" === i ? (t, e, i) => .1 * (256 * t * 256 + 256 * e + i) - 1e4 : (t, e, i) => 256 * t + e + i / 256 - 32768,
299
+ n = new Float32Array(t * e);
300
+ for (let t = 0; t < r.length; t += 4) n[t / 4] = s(r[t], r[t + 1], r[t + 2]);
301
+ return {width: t, height: e, data: n}
302
+ }
303
+
304
+ class S {
305
+ constructor(t, e, i) {
306
+ this.split = (t, e, i) => {
307
+ if (0 === t) return this;
308
+ const r = 1 << t, s = e * this.width / r, n = i * this.height / r;
309
+ return new S(this.width / r, this.height / r, ((t, e) => this.get(t + s, e + n)))
310
+ }, this.subsamplePixelCenters = t => {
311
+ const e = (t, e, i) => isNaN(t) ? e : isNaN(e) ? t : t + (e - t) * i;
312
+ if (t <= 1) return this;
313
+ const i = .5 - 1 / (2 * t);
314
+ return new S(this.width * t, this.height * t, ((r, s) => {
315
+ const n = r / t - i, o = s / t - i, a = Math.floor(n), h = Math.floor(o), l = this.get(a, h),
316
+ c = this.get(a + 1, h), d = this.get(a, h + 1), u = this.get(a + 1, h + 1), f = n - a,
317
+ p = o - h, w = e(l, c, f), g = e(d, u, f);
318
+ return e(w, g, p)
319
+ }))
320
+ }, this.averagePixelCentersToGrid = (t = 1) => new S(this.width + 1, this.height + 1, ((e, i) => {
321
+ let r = 0, s = 0, n = 0;
322
+ for (let o = e - t; o < e + t; o++) for (let e = i - t; e < i + t; e++) isNaN(n = this.get(o, e)) || (s++, r += n);
323
+ return 0 === s ? NaN : r / s
324
+ })), this.scaleElevation = t => 1 === t ? this : new S(this.width, this.height, ((e, i) => this.get(e, i) * t)), this.materialize = (t = 2) => {
325
+ const e = this.width + 2 * t, i = new Float32Array(e * (this.height + 2 * t));
326
+ let r = 0;
327
+ for (let e = -t; e < this.height + t; e++) for (let s = -t; s < this.width + t; s++) i[r++] = this.get(s, e);
328
+ return new S(this.width, this.height, ((r, s) => i[(s + t) * e + r + t]))
329
+ }, this.get = i, this.width = t, this.height = e
330
+ }
331
+
332
+ static fromRawDem(t) {
333
+ return new S(t.width, t.height, ((e, i) => {
334
+ const r = t.data[i * t.width + e];
335
+ return s = r, !isNaN(s) && s >= -12e3 && s <= 9e3 ? r : NaN;
336
+ var s
337
+ }))
338
+ }
339
+
340
+ static combineNeighbors(t) {
341
+ if (9 !== t.length) throw new Error("Must include a tile plus 8 neighbors");
342
+ const e = t[4];
343
+ if (!e) return;
344
+ const i = e.width, r = e.height;
345
+ return new S(i, r, ((e, s) => {
346
+ let n = 0;
347
+ s < 0 ? s += r : s < r ? n += 3 : (s -= r, n += 6), e < 0 ? e += i : e < i ? n += 1 : (e -= i, n += 2);
348
+ const o = t[n];
349
+ return o ? o.get(e, s) : NaN
350
+ }))
351
+ }
352
+ }
353
+
354
+ const T = 4294967296, N = 1 / T, C = "undefined" == typeof TextDecoder ? null : new TextDecoder("utf-8");
355
+
356
+ class O {
357
+ constructor(t = new Uint8Array(16)) {
358
+ this.buf = ArrayBuffer.isView(t) ? t : new Uint8Array(t), this.dataView = new DataView(this.buf.buffer), this.pos = 0, this.type = 0, this.length = this.buf.length
359
+ }
360
+
361
+ readFields(t, e, i = this.length) {
362
+ for (; this.pos < i;) {
363
+ const i = this.readVarint(), r = i >> 3, s = this.pos;
364
+ this.type = 7 & i, t(r, e, this), this.pos === s && this.skip(i)
365
+ }
366
+ return e
367
+ }
368
+
369
+ readMessage(t, e) {
370
+ return this.readFields(t, e, this.readVarint() + this.pos)
371
+ }
372
+
373
+ readFixed32() {
374
+ const t = this.dataView.getUint32(this.pos, !0);
375
+ return this.pos += 4, t
376
+ }
377
+
378
+ readSFixed32() {
379
+ const t = this.dataView.getInt32(this.pos, !0);
380
+ return this.pos += 4, t
381
+ }
382
+
383
+ readFixed64() {
384
+ const t = this.dataView.getUint32(this.pos, !0) + this.dataView.getUint32(this.pos + 4, !0) * T;
385
+ return this.pos += 8, t
386
+ }
387
+
388
+ readSFixed64() {
389
+ const t = this.dataView.getUint32(this.pos, !0) + this.dataView.getInt32(this.pos + 4, !0) * T;
390
+ return this.pos += 8, t
391
+ }
392
+
393
+ readFloat() {
394
+ const t = this.dataView.getFloat32(this.pos, !0);
395
+ return this.pos += 4, t
396
+ }
397
+
398
+ readDouble() {
399
+ const t = this.dataView.getFloat64(this.pos, !0);
400
+ return this.pos += 8, t
401
+ }
402
+
403
+ readVarint(t) {
404
+ const e = this.buf;
405
+ let i, r;
406
+ return r = e[this.pos++], i = 127 & r, r < 128 ? i : (r = e[this.pos++], i |= (127 & r) << 7, r < 128 ? i : (r = e[this.pos++], i |= (127 & r) << 14, r < 128 ? i : (r = e[this.pos++], i |= (127 & r) << 21, r < 128 ? i : (r = e[this.pos], i |= (15 & r) << 28, function (t, e, i) {
407
+ const r = i.buf;
408
+ let s, n;
409
+ if (n = r[i.pos++], s = (112 & n) >> 4, n < 128) return U(t, s, e);
410
+ if (n = r[i.pos++], s |= (127 & n) << 3, n < 128) return U(t, s, e);
411
+ if (n = r[i.pos++], s |= (127 & n) << 10, n < 128) return U(t, s, e);
412
+ if (n = r[i.pos++], s |= (127 & n) << 17, n < 128) return U(t, s, e);
413
+ if (n = r[i.pos++], s |= (127 & n) << 24, n < 128) return U(t, s, e);
414
+ if (n = r[i.pos++], s |= (1 & n) << 31, n < 128) return U(t, s, e);
415
+ throw new Error("Expected varint not more than 10 bytes")
416
+ }(i, t, this)))))
417
+ }
418
+
419
+ readVarint64() {
420
+ return this.readVarint(!0)
421
+ }
422
+
423
+ readSVarint() {
424
+ const t = this.readVarint();
425
+ return t % 2 == 1 ? (t + 1) / -2 : t / 2
426
+ }
427
+
428
+ readBoolean() {
429
+ return Boolean(this.readVarint())
430
+ }
431
+
432
+ readString() {
433
+ const t = this.readVarint() + this.pos, e = this.pos;
434
+ return this.pos = t, t - e >= 12 && C ? C.decode(this.buf.subarray(e, t)) : function (t, e, i) {
435
+ let r = "", s = e;
436
+ for (; s < i;) {
437
+ const e = t[s];
438
+ let n, o, a, h = null, l = e > 239 ? 4 : e > 223 ? 3 : e > 191 ? 2 : 1;
439
+ if (s + l > i) break;
440
+ 1 === l ? e < 128 && (h = e) : 2 === l ? (n = t[s + 1], 128 == (192 & n) && (h = (31 & e) << 6 | 63 & n, h <= 127 && (h = null))) : 3 === l ? (n = t[s + 1], o = t[s + 2], 128 == (192 & n) && 128 == (192 & o) && (h = (15 & e) << 12 | (63 & n) << 6 | 63 & o, (h <= 2047 || h >= 55296 && h <= 57343) && (h = null))) : 4 === l && (n = t[s + 1], o = t[s + 2], a = t[s + 3], 128 == (192 & n) && 128 == (192 & o) && 128 == (192 & a) && (h = (15 & e) << 18 | (63 & n) << 12 | (63 & o) << 6 | 63 & a, (h <= 65535 || h >= 1114112) && (h = null))), null === h ? (h = 65533, l = 1) : h > 65535 && (h -= 65536, r += String.fromCharCode(h >>> 10 & 1023 | 55296), h = 56320 | 1023 & h), r += String.fromCharCode(h), s += l
441
+ }
442
+ return r
443
+ }(this.buf, e, t)
444
+ }
445
+
446
+ readBytes() {
447
+ const t = this.readVarint() + this.pos, e = this.buf.subarray(this.pos, t);
448
+ return this.pos = t, e
449
+ }
450
+
451
+ readPackedVarint(t = [], e) {
452
+ const i = this.readPackedEnd();
453
+ for (; this.pos < i;) t.push(this.readVarint(e));
454
+ return t
455
+ }
456
+
457
+ readPackedSVarint(t = []) {
458
+ const e = this.readPackedEnd();
459
+ for (; this.pos < e;) t.push(this.readSVarint());
460
+ return t
461
+ }
462
+
463
+ readPackedBoolean(t = []) {
464
+ const e = this.readPackedEnd();
465
+ for (; this.pos < e;) t.push(this.readBoolean());
466
+ return t
467
+ }
468
+
469
+ readPackedFloat(t = []) {
470
+ const e = this.readPackedEnd();
471
+ for (; this.pos < e;) t.push(this.readFloat());
472
+ return t
473
+ }
474
+
475
+ readPackedDouble(t = []) {
476
+ const e = this.readPackedEnd();
477
+ for (; this.pos < e;) t.push(this.readDouble());
478
+ return t
479
+ }
480
+
481
+ readPackedFixed32(t = []) {
482
+ const e = this.readPackedEnd();
483
+ for (; this.pos < e;) t.push(this.readFixed32());
484
+ return t
485
+ }
486
+
487
+ readPackedSFixed32(t = []) {
488
+ const e = this.readPackedEnd();
489
+ for (; this.pos < e;) t.push(this.readSFixed32());
490
+ return t
491
+ }
492
+
493
+ readPackedFixed64(t = []) {
494
+ const e = this.readPackedEnd();
495
+ for (; this.pos < e;) t.push(this.readFixed64());
496
+ return t
497
+ }
498
+
499
+ readPackedSFixed64(t = []) {
500
+ const e = this.readPackedEnd();
501
+ for (; this.pos < e;) t.push(this.readSFixed64());
502
+ return t
503
+ }
504
+
505
+ readPackedEnd() {
506
+ return 2 === this.type ? this.readVarint() + this.pos : this.pos + 1
507
+ }
508
+
509
+ skip(t) {
510
+ const e = 7 & t;
511
+ if (0 === e) for (; this.buf[this.pos++] > 127;) ; else if (2 === e) this.pos = this.readVarint() + this.pos; else if (5 === e) this.pos += 4; else {
512
+ if (1 !== e) throw new Error(`Unimplemented type: ${e}`);
513
+ this.pos += 8
514
+ }
515
+ }
516
+
517
+ writeTag(t, e) {
518
+ this.writeVarint(t << 3 | e)
519
+ }
520
+
521
+ realloc(t) {
522
+ let e = this.length || 16;
523
+ for (; e < this.pos + t;) e *= 2;
524
+ if (e !== this.length) {
525
+ const t = new Uint8Array(e);
526
+ t.set(this.buf), this.buf = t, this.dataView = new DataView(t.buffer), this.length = e
527
+ }
528
+ }
529
+
530
+ finish() {
531
+ return this.length = this.pos, this.pos = 0, this.buf.subarray(0, this.length)
532
+ }
533
+
534
+ writeFixed32(t) {
535
+ this.realloc(4), this.dataView.setInt32(this.pos, t, !0), this.pos += 4
536
+ }
537
+
538
+ writeSFixed32(t) {
539
+ this.realloc(4), this.dataView.setInt32(this.pos, t, !0), this.pos += 4
540
+ }
541
+
542
+ writeFixed64(t) {
543
+ this.realloc(8), this.dataView.setInt32(this.pos, -1 & t, !0), this.dataView.setInt32(this.pos + 4, Math.floor(t * N), !0), this.pos += 8
544
+ }
545
+
546
+ writeSFixed64(t) {
547
+ this.realloc(8), this.dataView.setInt32(this.pos, -1 & t, !0), this.dataView.setInt32(this.pos + 4, Math.floor(t * N), !0), this.pos += 8
548
+ }
549
+
550
+ writeVarint(t) {
551
+ (t = +t || 0) > 268435455 || t < 0 ? function (t, e) {
552
+ let i, r;
553
+ t >= 0 ? (i = t % 4294967296 | 0, r = t / 4294967296 | 0) : (i = ~(-t % 4294967296), r = ~(-t / 4294967296), 4294967295 ^ i ? i = i + 1 | 0 : (i = 0, r = r + 1 | 0));
554
+ if (t >= 0x10000000000000000 || t < -0x10000000000000000) throw new Error("Given varint doesn't fit into 10 bytes");
555
+ e.realloc(10), function (t, e, i) {
556
+ i.buf[i.pos++] = 127 & t | 128, t >>>= 7, i.buf[i.pos++] = 127 & t | 128, t >>>= 7, i.buf[i.pos++] = 127 & t | 128, t >>>= 7, i.buf[i.pos++] = 127 & t | 128, t >>>= 7, i.buf[i.pos] = 127 & t
557
+ }(i, 0, e), function (t, e) {
558
+ const i = (7 & t) << 4;
559
+ if (e.buf[e.pos++] |= i | ((t >>>= 3) ? 128 : 0), !t) return;
560
+ if (e.buf[e.pos++] = 127 & t | ((t >>>= 7) ? 128 : 0), !t) return;
561
+ if (e.buf[e.pos++] = 127 & t | ((t >>>= 7) ? 128 : 0), !t) return;
562
+ if (e.buf[e.pos++] = 127 & t | ((t >>>= 7) ? 128 : 0), !t) return;
563
+ if (e.buf[e.pos++] = 127 & t | ((t >>>= 7) ? 128 : 0), !t) return;
564
+ e.buf[e.pos++] = 127 & t
565
+ }(r, e)
566
+ }(t, this) : (this.realloc(4), this.buf[this.pos++] = 127 & t | (t > 127 ? 128 : 0), t <= 127 || (this.buf[this.pos++] = 127 & (t >>>= 7) | (t > 127 ? 128 : 0), t <= 127 || (this.buf[this.pos++] = 127 & (t >>>= 7) | (t > 127 ? 128 : 0), t <= 127 || (this.buf[this.pos++] = t >>> 7 & 127))))
567
+ }
568
+
569
+ writeSVarint(t) {
570
+ this.writeVarint(t < 0 ? 2 * -t - 1 : 2 * t)
571
+ }
572
+
573
+ writeBoolean(t) {
574
+ this.writeVarint(+t)
575
+ }
576
+
577
+ writeString(t) {
578
+ t = String(t), this.realloc(4 * t.length), this.pos++;
579
+ const e = this.pos;
580
+ this.pos = function (t, e, i) {
581
+ for (let r, s, n = 0; n < e.length; n++) {
582
+ if (r = e.charCodeAt(n), r > 55295 && r < 57344) {
583
+ if (!s) {
584
+ r > 56319 || n + 1 === e.length ? (t[i++] = 239, t[i++] = 191, t[i++] = 189) : s = r;
585
+ continue
586
+ }
587
+ if (r < 56320) {
588
+ t[i++] = 239, t[i++] = 191, t[i++] = 189, s = r;
589
+ continue
590
+ }
591
+ r = s - 55296 << 10 | r - 56320 | 65536, s = null
592
+ } else s && (t[i++] = 239, t[i++] = 191, t[i++] = 189, s = null);
593
+ r < 128 ? t[i++] = r : (r < 2048 ? t[i++] = r >> 6 | 192 : (r < 65536 ? t[i++] = r >> 12 | 224 : (t[i++] = r >> 18 | 240, t[i++] = r >> 12 & 63 | 128), t[i++] = r >> 6 & 63 | 128), t[i++] = 63 & r | 128)
594
+ }
595
+ return i
596
+ }(this.buf, t, this.pos);
597
+ const i = this.pos - e;
598
+ i >= 128 && I(e, i, this), this.pos = e - 1, this.writeVarint(i), this.pos += i
599
+ }
600
+
601
+ writeFloat(t) {
602
+ this.realloc(4), this.dataView.setFloat32(this.pos, t, !0), this.pos += 4
603
+ }
604
+
605
+ writeDouble(t) {
606
+ this.realloc(8), this.dataView.setFloat64(this.pos, t, !0), this.pos += 8
607
+ }
608
+
609
+ writeBytes(t) {
610
+ const e = t.length;
611
+ this.writeVarint(e), this.realloc(e);
612
+ for (let i = 0; i < e; i++) this.buf[this.pos++] = t[i]
613
+ }
614
+
615
+ writeRawMessage(t, e) {
616
+ this.pos++;
617
+ const i = this.pos;
618
+ t(e, this);
619
+ const r = this.pos - i;
620
+ r >= 128 && I(i, r, this), this.pos = i - 1, this.writeVarint(r), this.pos += r
621
+ }
622
+
623
+ writeMessage(t, e, i) {
624
+ this.writeTag(t, 2), this.writeRawMessage(e, i)
625
+ }
626
+
627
+ writePackedVarint(t, e) {
628
+ e.length && this.writeMessage(t, E, e)
629
+ }
630
+
631
+ writePackedSVarint(t, e) {
632
+ e.length && this.writeMessage(t, B, e)
633
+ }
634
+
635
+ writePackedBoolean(t, e) {
636
+ e.length && this.writeMessage(t, j, e)
637
+ }
638
+
639
+ writePackedFloat(t, e) {
640
+ e.length && this.writeMessage(t, A, e)
641
+ }
642
+
643
+ writePackedDouble(t, e) {
644
+ e.length && this.writeMessage(t, D, e)
645
+ }
646
+
647
+ writePackedFixed32(t, e) {
648
+ e.length && this.writeMessage(t, z, e)
649
+ }
650
+
651
+ writePackedSFixed32(t, e) {
652
+ e.length && this.writeMessage(t, R, e)
653
+ }
654
+
655
+ writePackedFixed64(t, e) {
656
+ e.length && this.writeMessage(t, $, e)
657
+ }
658
+
659
+ writePackedSFixed64(t, e) {
660
+ e.length && this.writeMessage(t, L, e)
661
+ }
662
+
663
+ writeBytesField(t, e) {
664
+ this.writeTag(t, 2), this.writeBytes(e)
665
+ }
666
+
667
+ writeFixed32Field(t, e) {
668
+ this.writeTag(t, 5), this.writeFixed32(e)
669
+ }
670
+
671
+ writeSFixed32Field(t, e) {
672
+ this.writeTag(t, 5), this.writeSFixed32(e)
673
+ }
674
+
675
+ writeFixed64Field(t, e) {
676
+ this.writeTag(t, 1), this.writeFixed64(e)
677
+ }
678
+
679
+ writeSFixed64Field(t, e) {
680
+ this.writeTag(t, 1), this.writeSFixed64(e)
681
+ }
682
+
683
+ writeVarintField(t, e) {
684
+ this.writeTag(t, 0), this.writeVarint(e)
685
+ }
686
+
687
+ writeSVarintField(t, e) {
688
+ this.writeTag(t, 0), this.writeSVarint(e)
689
+ }
690
+
691
+ writeStringField(t, e) {
692
+ this.writeTag(t, 2), this.writeString(e)
693
+ }
694
+
695
+ writeFloatField(t, e) {
696
+ this.writeTag(t, 5), this.writeFloat(e)
697
+ }
698
+
699
+ writeDoubleField(t, e) {
700
+ this.writeTag(t, 1), this.writeDouble(e)
701
+ }
702
+
703
+ writeBooleanField(t, e) {
704
+ this.writeVarintField(t, +e)
705
+ }
706
+ }
707
+
708
+ function U(t, e, i) {
709
+ return i ? 4294967296 * e + (t >>> 0) : 4294967296 * (e >>> 0) + (t >>> 0)
710
+ }
711
+
712
+ function I(t, e, i) {
713
+ const r = e <= 16383 ? 1 : e <= 2097151 ? 2 : e <= 268435455 ? 3 : Math.floor(Math.log(e) / (7 * Math.LN2));
714
+ i.realloc(r);
715
+ for (let e = i.pos - 1; e >= t; e--) i.buf[e + r] = i.buf[e]
716
+ }
717
+
718
+ function E(t, e) {
719
+ for (let i = 0; i < t.length; i++) e.writeVarint(t[i])
720
+ }
721
+
722
+ function B(t, e) {
723
+ for (let i = 0; i < t.length; i++) e.writeSVarint(t[i])
724
+ }
725
+
726
+ function A(t, e) {
727
+ for (let i = 0; i < t.length; i++) e.writeFloat(t[i])
728
+ }
729
+
730
+ function D(t, e) {
731
+ for (let i = 0; i < t.length; i++) e.writeDouble(t[i])
732
+ }
733
+
734
+ function j(t, e) {
735
+ for (let i = 0; i < t.length; i++) e.writeBoolean(t[i])
736
+ }
737
+
738
+ function z(t, e) {
739
+ for (let i = 0; i < t.length; i++) e.writeFixed32(t[i])
740
+ }
741
+
742
+ function R(t, e) {
743
+ for (let i = 0; i < t.length; i++) e.writeSFixed32(t[i])
744
+ }
745
+
746
+ function $(t, e) {
747
+ for (let i = 0; i < t.length; i++) e.writeFixed64(t[i])
748
+ }
749
+
750
+ function L(t, e) {
751
+ for (let i = 0; i < t.length; i++) e.writeSFixed64(t[i])
752
+ }
753
+
754
+ var G;
755
+
756
+ function W(t, e) {
757
+ if (!e) throw new Error("pbf undefined");
758
+ e.writeVarintField(15, 2), e.writeStringField(1, t.id || ""), e.writeVarintField(5, t.extent || 4096);
759
+ const i = {keys: [], values: [], keycache: {}, valuecache: {}};
760
+ for (const r of t.features) i.feature = r, e.writeMessage(2, q, i);
761
+ for (const t of i.keys) e.writeStringField(3, t);
762
+ for (const t of i.values) e.writeMessage(4, J, t)
763
+ }
764
+
765
+ function q(t, e) {
766
+ const i = t.feature;
767
+ if (!i || !e) throw new Error;
768
+ e.writeMessage(2, K, t), e.writeVarintField(3, i.type), e.writeMessage(4, H, i)
769
+ }
770
+
771
+ function K(t, e) {
772
+ const i = t.feature;
773
+ if (!i || !e) throw new Error;
774
+ const r = t.keys, s = t.values, n = t.keycache, o = t.valuecache;
775
+ for (const t in i.properties) {
776
+ let a = i.properties[t], h = n[t];
777
+ if (null === a) continue;
778
+ void 0 === h && (r.push(t), h = r.length - 1, n[t] = h), e.writeVarint(h);
779
+ const l = typeof a;
780
+ "string" !== l && "boolean" !== l && "number" !== l && (a = JSON.stringify(a));
781
+ const c = `${l}:${a}`;
782
+ let d = o[c];
783
+ void 0 === d && (s.push(a), d = s.length - 1, o[c] = d), e.writeVarint(d)
784
+ }
785
+ }
786
+
787
+ function Y(t, e) {
788
+ return (e << 3) + (7 & t)
789
+ }
790
+
791
+ function _(t) {
792
+ return t << 1 ^ t >> 31
793
+ }
794
+
795
+ function H(t, e) {
796
+ if (!e) throw new Error;
797
+ const i = t.geometry, r = t.type;
798
+ let s = 0, n = 0;
799
+ for (const t of i) {
800
+ let i = 1;
801
+ r === G.POINT && (i = t.length / 2), e.writeVarint(Y(1, i));
802
+ const o = t.length / 2, a = r === G.POLYGON ? o - 1 : o;
803
+ for (let i = 0; i < a; i++) {
804
+ 1 === i && 1 !== r && e.writeVarint(Y(2, a - 1));
805
+ const o = t[2 * i] - s, h = t[2 * i + 1] - n;
806
+ e.writeVarint(_(o)), e.writeVarint(_(h)), s += o, n += h
807
+ }
808
+ r === G.POLYGON && e.writeVarint(Y(7, 1))
809
+ }
810
+ }
811
+
812
+ function J(t, e) {
813
+ if (!e) throw new Error;
814
+ "string" == typeof t ? e.writeStringField(1, t) : "boolean" == typeof t ? e.writeBooleanField(7, t) : "number" == typeof t && (t % 1 != 0 ? e.writeDoubleField(3, t) : t < 0 ? e.writeSVarintField(6, t) : e.writeVarintField(5, t))
815
+ }
816
+
817
+ !function (t) {
818
+ t[t.UNKNOWN = 0] = "UNKNOWN", t[t.POINT = 1] = "POINT", t[t.LINESTRING = 2] = "LINESTRING", t[t.POLYGON = 3] = "POLYGON"
819
+ }(G || (G = {}));
820
+ const Q = "undefined" != typeof performance ? performance : void 0,
821
+ X = Q ? Q.timeOrigin || (new Date).getTime() - Q.now() : (new Date).getTime();
822
+
823
+ function Z(t) {
824
+ var e;
825
+ return JSON.parse(JSON.stringify((null === (e = null == Q ? void 0 : Q.getEntriesByName) || void 0 === e ? void 0 : e.call(Q, t)) || []))
826
+ }
827
+
828
+ function tt() {
829
+ return Q ? Q.now() : (new Date).getTime()
830
+ }
831
+
832
+ function et(t) {
833
+ const e = [];
834
+ for (const i of t) e.push(...i);
835
+ return e
836
+ }
837
+
838
+ class it {
839
+ constructor(t) {
840
+ this.marks = {}, this.urls = [], this.fetched = [], this.resources = [], this.tilesFetched = 0, this.timeOrigin = X, this.finish = t => {
841
+ this.markFinish();
842
+ const e = t => {
843
+ const e = this.marks[t] || [], i = Math.max(...e.map((t => Math.max(...t)))),
844
+ r = Math.min(...e.map((t => Math.min(...t))));
845
+ return Number.isFinite(i) ? i - r : void 0
846
+ }, i = e("main") || 0, r = e("fetch"), s = e("decode"), n = e("isoline");
847
+ return {
848
+ url: t,
849
+ tilesUsed: this.tilesFetched,
850
+ origin: this.timeOrigin,
851
+ marks: this.marks,
852
+ resources: [...this.resources, ...et(this.fetched.map(Z))],
853
+ duration: i,
854
+ fetch: r,
855
+ decode: s,
856
+ process: n,
857
+ wait: i - (r || 0) - (s || 0) - (n || 0)
858
+ }
859
+ }, this.error = t => Object.assign(Object.assign({}, this.finish(t)), {error: !0}), this.marker = t => {
860
+ var e;
861
+ this.marks[t] || (this.marks[t] = []);
862
+ const i = [tt()];
863
+ return null === (e = this.marks[t]) || void 0 === e || e.push(i), () => i.push(tt())
864
+ }, this.useTile = t => {
865
+ this.urls.indexOf(t) < 0 && (this.urls.push(t), this.tilesFetched++)
866
+ }, this.fetchTile = t => {
867
+ this.fetched.indexOf(t) < 0 && this.fetched.push(t)
868
+ }, this.addAll = t => {
869
+ var e;
870
+ this.tilesFetched += t.tilesUsed;
871
+ const i = t.origin - this.timeOrigin;
872
+ for (const r in t.marks) {
873
+ const s = r;
874
+ (this.marks[s] || (this.marks[s] = [])).push(...(null === (e = t.marks[s]) || void 0 === e ? void 0 : e.map((t => t.map((t => t + i))))) || [])
875
+ }
876
+ this.resources.push(...t.resources.map((t => function (t, e) {
877
+ const i = {};
878
+ for (const r in t) 0 !== t[r] && rt.test(r) ? i[r] = Number(t[r]) + e : i[r] = t[r];
879
+ return i
880
+ }(t, i))))
881
+ }, this.markFinish = this.marker(t)
882
+ }
883
+ }
884
+
885
+ const rt = /(Start$|End$|^start|^end)/;
886
+ const st = (t, e) => a(void 0, void 0, void 0, (function* () {
887
+ const i = {signal: e.signal}, r = yield fetch(t, i);
888
+ if (!r.ok) throw new Error(`Bad response: ${r.status} for ${t}`);
889
+ return {
890
+ data: yield r.blob(),
891
+ expires: r.headers.get("expires") || void 0,
892
+ cacheControl: r.headers.get("cache-control") || void 0
893
+ }
894
+ }));
895
+ let nt = 0;
896
+ t.A = class {
897
+ constructor(t, e, i = 2e4) {
898
+ this.callbacks = {}, this.cancels = {}, this.dest = t, this.timeoutMs = i, this.dest.onmessage = t => a(this, [t], void 0, (function* ({data: t}) {
899
+ const i = t;
900
+ if ("cancel" === i.type) {
901
+ const t = this.cancels[i.id];
902
+ delete this.cancels[i.id], null == t || t.abort()
903
+ } else if ("response" === i.type) {
904
+ const t = this.callbacks[i.id];
905
+ delete this.callbacks[i.id], t && t(i.error ? new Error(i.error) : void 0, i.response, i.timings)
906
+ } else if ("request" === i.type) {
907
+ const t = new it("worker"), r = e[i.name], s = new AbortController,
908
+ n = r.apply(r, [...i.args, s, t]), o = `${i.name}_${i.id}`;
909
+ if (i.id && n) {
910
+ this.cancels[i.id] = s;
911
+ try {
912
+ const e = yield n, r = null == e ? void 0 : e.transferrables;
913
+ this.postMessage({id: i.id, type: "response", response: e, timings: t.finish(o)}, r)
914
+ } catch (e) {
915
+ this.postMessage({
916
+ id: i.id,
917
+ type: "response",
918
+ error: (null == e ? void 0 : e.toString()) || "error",
919
+ timings: t.finish(o)
920
+ })
921
+ }
922
+ delete this.cancels[i.id]
923
+ }
924
+ }
925
+ }))
926
+ }
927
+
928
+ postMessage(t, e) {
929
+ this.dest.postMessage(t, e || [])
930
+ }
931
+
932
+ send(t, e, i, r, ...s) {
933
+ const n = ++nt, o = new Promise(((i, o) => {
934
+ this.postMessage({id: n, type: "request", name: t, args: s}, e), this.callbacks[n] = (t, e, s) => {
935
+ null == r || r.addAll(s), t ? o(t) : i(e)
936
+ }
937
+ }));
938
+ return w(i, (() => {
939
+ delete this.callbacks[n], this.postMessage({id: n, type: "cancel"})
940
+ })), p(this.timeoutMs, o, i)
941
+ }
942
+ }, t.H = S, t.L = class {
943
+ constructor(t) {
944
+ this.loaded = Promise.resolve(), this.fetchAndParseTile = (t, e, i, r, s) => {
945
+ const n = this,
946
+ o = this.demUrlPattern.replace("{z}", t.toString()).replace("{x}", e.toString()).replace("{y}", i.toString());
947
+ return null == s || s.useTile(o), this.parsedCache.get(o, ((r, o) => a(this, void 0, void 0, (function* () {
948
+ const r = yield n.fetchTile(t, e, i, o, s);
949
+ if (g(o)) throw new Error("canceled");
950
+ const a = n.decodeImage(r.data, n.encoding, o), h = null == s ? void 0 : s.marker("decode"),
951
+ l = yield a;
952
+ return null == h || h(), l
953
+ }))), r)
954
+ }, this.tileCache = new x(t.cacheSize), this.parsedCache = new x(t.cacheSize), this.contourCache = new x(t.cacheSize), this.timeoutMs = t.timeoutMs, this.demUrlPattern = t.demUrlPattern, this.encoding = t.encoding, this.maxzoom = t.maxzoom, this.decodeImage = t.decodeImage || k, this.getTile = t.getTile || st
955
+ }
956
+
957
+ fetchTile(t, e, i, r, s) {
958
+ const n = this.demUrlPattern.replace("{z}", t.toString()).replace("{x}", e.toString()).replace("{y}", i.toString());
959
+ return null == s || s.useTile(n), this.tileCache.get(n, ((t, e) => {
960
+ null == s || s.fetchTile(n);
961
+ const i = null == s ? void 0 : s.marker("fetch");
962
+ return p(this.timeoutMs, this.getTile(n, e).finally((() => null == i ? void 0 : i())), e)
963
+ }), r)
964
+ }
965
+
966
+ fetchDem(t, e, i, r, s, n) {
967
+ return a(this, void 0, void 0, (function* () {
968
+ const o = Math.min(t - (r.overzoom || 0), this.maxzoom), a = t - o, h = 1 << a,
969
+ l = Math.floor(e / h), c = Math.floor(i / h), d = yield this.fetchAndParseTile(o, l, c, s, n);
970
+ return S.fromRawDem(d).split(a, e % h, i % h)
971
+ }))
972
+ }
973
+
974
+ fetchContourTile(t, e, i, r, s, o) {
975
+ const {
976
+ levels: h,
977
+ multiplier: l = 1,
978
+ buffer: d = 1,
979
+ extent: u = 4096,
980
+ contourLayer: f = "contours",
981
+ elevationKey: p = "ele",
982
+ levelKey: w = "level",
983
+ subsampleBelow: m = 100
984
+ } = r;
985
+ if (!h || 0 === h.length) return Promise.resolve({arrayBuffer: new ArrayBuffer(0)});
986
+ const b = [t, e, i, c(r)].join("/");
987
+ return this.contourCache.get(b, ((s, c) => a(this, void 0, void 0, (function* () {
988
+ const s = 1 << t, a = [];
989
+ for (let n = i - 1; n <= i + 1; n++) for (let i = e - 1; i <= e + 1; i++) a.push(n < 0 || n >= s ? void 0 : this.fetchDem(t, (i + s) % s, n, r, c, o));
990
+ const b = yield Promise.all(a);
991
+ let y = S.combineNeighbors(b);
992
+ if (!y || g(c)) return {arrayBuffer: (new Uint8Array).buffer};
993
+ const v = null == o ? void 0 : o.marker("isoline");
994
+ if (y.width >= m) y = y.materialize(2); else for (; y.width < m;) y = y.subsamplePixelCenters(2).materialize(2);
995
+ y = y.averagePixelCentersToGrid().scaleElevation(l).materialize(1);
996
+ const P = n(h[0], y, u, d);
997
+ null == v || v();
998
+ const x = function (t) {
999
+ const e = new O;
1000
+ for (const i in t.layers) {
1001
+ const r = t.layers[i];
1002
+ r.extent || (r.extent = t.extent), e.writeMessage(3, W, Object.assign(Object.assign({}, r), {id: i}))
1003
+ }
1004
+ return e.finish()
1005
+ }({
1006
+ extent: u, layers: {
1007
+ [f]: {
1008
+ features: Object.entries(P).map((([t, e]) => {
1009
+ const i = Number(t);
1010
+ return {
1011
+ type: G.LINESTRING,
1012
+ geometry: e,
1013
+ properties: {[p]: i, [w]: Math.max(...h.map(((t, e) => i % t == 0 ? e : 0)))}
1014
+ }
1015
+ }))
1016
+ }
1017
+ }
1018
+ });
1019
+ return null == v || v(), {arrayBuffer: x.buffer}
1020
+ }))), s)
1021
+ }
1022
+ }, t.T = it, t._ = a, t.a = function (t) {
1023
+ return Object.fromEntries(t.replace(/^.*\?/, "").split("&").map((t => {
1024
+ const e = t.split("=").map(decodeURIComponent), i = e[0];
1025
+ let r = e[1];
1026
+ switch (i) {
1027
+ case"thresholds":
1028
+ s = r, r = Object.fromEntries(s.split("~").map((t => t.split("*").map(Number))).map((([t, ...e]) => [t, e])));
1029
+ break;
1030
+ case"extent":
1031
+ case"multiplier":
1032
+ case"overzoom":
1033
+ case"buffer":
1034
+ r = Number(r)
1035
+ }
1036
+ var s;
1037
+ return [i, r]
1038
+ })))
1039
+ }, t.b = n, t.c = M, t.d = k, t.e = function (t) {
1040
+ var {thresholds: e} = t, i = o(t, ["thresholds"]);
1041
+ return h(Object.assign({thresholds: l(e)}, i)).map((([t, e]) => `${encodeURIComponent(t)}=${encodeURIComponent(e)}`)).join("&")
1042
+ }, t.f = function (t) {
1043
+ return t.then((({arrayBuffer: t}) => {
1044
+ const e = function (t) {
1045
+ const e = new ArrayBuffer(t.byteLength);
1046
+ return new Uint8Array(e).set(new Uint8Array(t)), e
1047
+ }(t);
1048
+ return {arrayBuffer: e, transferrables: [e]}
1049
+ }))
1050
+ }, t.g = function (t, e) {
1051
+ const {thresholds: i} = t, r = o(t, ["thresholds"]);
1052
+ let s = [], n = -1 / 0;
1053
+ return Object.entries(i).forEach((([t, i]) => {
1054
+ const r = Number(t);
1055
+ r <= e && r > n && (n = r, s = "number" == typeof i ? [i] : i)
1056
+ })), Object.assign({levels: s}, r)
1057
+ }, t.p = function (t, e) {
1058
+ return t.then((t => {
1059
+ var {data: i} = t, r = o(t, ["data"]);
1060
+ let s = i;
1061
+ return e && (s = new Float32Array(i.length), s.set(i)), Object.assign(Object.assign({}, r), {
1062
+ data: s,
1063
+ transferrables: [s.buffer]
1064
+ })
1065
+ }))
1066
+ }
1067
+ })), r(0, (function (t) {
1068
+ const e = t => Promise.reject(new Error(`No manager registered for ${t}`));
1069
+ const i = "undefined" != typeof self ? self : "undefined" != typeof window ? window : global;
1070
+ i.actor = new t.A(i, new class {
1071
+ constructor() {
1072
+ this.managers = {}, this.init = (e, i) => (this.managers[e.managerId] = new t.L(e), Promise.resolve()), this.fetchTile = (t, i, r, s, n, o) => {
1073
+ var a;
1074
+ return (null === (a = this.managers[t]) || void 0 === a ? void 0 : a.fetchTile(i, r, s, n, o)) || e(t)
1075
+ }, this.fetchAndParseTile = (i, r, s, n, o, a) => {
1076
+ var h;
1077
+ return t.p((null === (h = this.managers[i]) || void 0 === h ? void 0 : h.fetchAndParseTile(r, s, n, o, a)) || e(i), !0)
1078
+ }, this.fetchContourTile = (i, r, s, n, o, a, h) => {
1079
+ var l;
1080
+ return t.f((null === (l = this.managers[i]) || void 0 === l ? void 0 : l.fetchContourTile(r, s, n, o, a, h)) || e(i))
1081
+ }
1082
+ }
1083
+ })
1084
+ })), r(0, (function (t) {
1085
+ const e = {workerUrl: ""};
1086
+ let i, r = 0;
1087
+
1088
+ class s {
1089
+ constructor() {
1090
+ this.decodeImage = (e, i, r) => t.p(t.d(e, i, r), !1)
1091
+ }
1092
+ }
1093
+
1094
+ class n {
1095
+ constructor(n) {
1096
+ this.fetchTile = (t, e, i, r, s) => this.actor.send("fetchTile", [], r, s, this.managerId, t, e, i), this.fetchAndParseTile = (t, e, i, r, s) => this.actor.send("fetchAndParseTile", [], r, s, this.managerId, t, e, i), this.fetchContourTile = (t, e, i, r, s, n) => this.actor.send("fetchContourTile", [], s, n, this.managerId, t, e, i, r);
1097
+ const o = this.managerId = ++r;
1098
+ this.actor = n.actor || function () {
1099
+ if (!i) {
1100
+ const r = new Worker(e.workerUrl), n = new s;
1101
+ i = new t.A(r, n)
1102
+ }
1103
+ return i
1104
+ }(), this.loaded = this.actor.send("init", [], new AbortController, void 0, Object.assign(Object.assign({}, n), {managerId: o}))
1105
+ }
1106
+ }
1107
+
1108
+ Blob.prototype.arrayBuffer || (Blob.prototype.arrayBuffer = function () {
1109
+ return new Promise(((t, e) => {
1110
+ const i = new FileReader;
1111
+ i.onload = e => {
1112
+ var i;
1113
+ return t(null === (i = e.target) || void 0 === i ? void 0 : i.result)
1114
+ }, i.onerror = e, i.readAsArrayBuffer(this)
1115
+ }))
1116
+ });
1117
+ const o = t => (e, i) => {
1118
+ if (i instanceof AbortController) return t(e, i);
1119
+ {
1120
+ const r = new AbortController;
1121
+ return t(e, r).then((t => i(void 0, t.data, t.cacheControl, t.expires)), (t => i(t))).catch((t => i(t))), {cancel: () => r.abort()}
1122
+ }
1123
+ }, a = new Set;
1124
+ const h = {
1125
+ generateIsolines: t.b, DemSource: class {
1126
+ constructor({
1127
+ url: e,
1128
+ cacheSize: i = 100,
1129
+ id: r = "dem",
1130
+ encoding: s = "terrarium",
1131
+ maxzoom: h = 12,
1132
+ worker: l = !0,
1133
+ timeoutMs: c = 1e4,
1134
+ actor: d
1135
+ }) {
1136
+ this.timingCallbacks = [], this.onTiming = t => {
1137
+ this.timingCallbacks.push(t)
1138
+ }, this.setupMaplibre = t => {
1139
+ t.addProtocol(this.sharedDemProtocolId, this.sharedDemProtocol), t.addProtocol(this.contourProtocolId, this.contourProtocol)
1140
+ }, this.sharedDemProtocolV4 = (e, i) => t._(this, void 0, void 0, (function* () {
1141
+ const [r, s, n] = this.parseUrl(e.url), o = new t.T("main");
1142
+ let a;
1143
+ try {
1144
+ const t = yield this.manager.fetchTile(r, s, n, i, o);
1145
+ a = o.finish(e.url);
1146
+ return {data: yield t.data.arrayBuffer(), cacheControl: t.cacheControl, expires: t.expires}
1147
+ } catch (t) {
1148
+ throw a = o.error(e.url), t
1149
+ } finally {
1150
+ this.timingCallbacks.forEach((t => t(a)))
1151
+ }
1152
+ })), this.contourProtocolV4 = (e, i) => t._(this, void 0, void 0, (function* () {
1153
+ const r = new t.T("main");
1154
+ let s;
1155
+ try {
1156
+ const [n, o, a] = this.parseUrl(e.url), h = t.a(e.url),
1157
+ l = yield this.manager.fetchContourTile(n, o, a, t.g(h, n), i, r);
1158
+ return s = r.finish(e.url), {data: l.arrayBuffer}
1159
+ } catch (t) {
1160
+ throw s = r.error(e.url), t
1161
+ } finally {
1162
+ this.timingCallbacks.forEach((t => t(s)))
1163
+ }
1164
+ })), this.contourProtocol = o(this.contourProtocolV4), this.sharedDemProtocol = o(this.sharedDemProtocolV4), this.contourProtocolUrl = e => `${this.contourProtocolUrlBase}?${t.e(e)}`;
1165
+ let u = r, f = 1;
1166
+ for (; a.has(u);) u = r + f++;
1167
+ a.add(u), this.sharedDemProtocolId = `${u}-shared`, this.contourProtocolId = `${u}-contour`, this.sharedDemProtocolUrl = `${this.sharedDemProtocolId}://{z}/{x}/{y}`, this.contourProtocolUrlBase = `${this.contourProtocolId}://{z}/{x}/{y}`;
1168
+ const p = l ? n : t.L;
1169
+ this.manager = new p({
1170
+ demUrlPattern: e,
1171
+ cacheSize: i,
1172
+ encoding: s,
1173
+ maxzoom: h,
1174
+ timeoutMs: c,
1175
+ actor: d
1176
+ })
1177
+ }
1178
+
1179
+ getDemTile(t, e, i, r) {
1180
+ return this.manager.fetchAndParseTile(t, e, i, r || new AbortController)
1181
+ }
1182
+
1183
+ parseUrl(t) {
1184
+ const [, e, i, r] = /\/\/(\d+)\/(\d+)\/(\d+)/.exec(t) || [];
1185
+ return [Number(e), Number(i), Number(r)]
1186
+ }
1187
+ }, HeightTile: t.H, LocalDemManager: t.L, decodeParsedImage: t.c, set workerUrl(t) {
1188
+ e.workerUrl = t
1189
+ }, get workerUrl() {
1190
+ return e.workerUrl
1191
+ }
1192
+ };
1193
+ return h
1194
+ })), i
1195
+ }));