@ogc-maps/storybook-components 0.10.0 → 0.11.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 (44) hide show
  1. package/dist/FeatureTooltip-DxzN-jnp.js +49 -0
  2. package/dist/components/FeatureTooltip/FeatureTooltip.d.ts +12 -2
  3. package/dist/components/FeatureTooltip/FeatureTooltip.d.ts.map +1 -1
  4. package/dist/components/FeatureTooltip/index.js +1 -1
  5. package/dist/components/LayerEditor/LayerEditor.d.ts.map +1 -1
  6. package/dist/components/ResultsDrawer/ResultsDrawer.d.ts +15 -0
  7. package/dist/components/ResultsDrawer/ResultsDrawer.d.ts.map +1 -0
  8. package/dist/components/ResultsDrawer/index.d.ts +3 -0
  9. package/dist/components/ResultsDrawer/index.d.ts.map +1 -0
  10. package/dist/components/SelectionPanel/SelectionPanel.d.ts +15 -0
  11. package/dist/components/SelectionPanel/SelectionPanel.d.ts.map +1 -0
  12. package/dist/components/SelectionPanel/index.d.ts +3 -0
  13. package/dist/components/SelectionPanel/index.d.ts.map +1 -0
  14. package/dist/components/UIConfigEditor/UIConfigEditor.d.ts.map +1 -1
  15. package/dist/components/admin/CollapsibleSection.d.ts +1 -1
  16. package/dist/components/admin/CollapsibleSection.d.ts.map +1 -1
  17. package/dist/components/index.d.ts +6 -2
  18. package/dist/components/index.d.ts.map +1 -1
  19. package/dist/geo-CyDCsiW-.js +1116 -0
  20. package/dist/hooks/index.d.ts +4 -2
  21. package/dist/hooks/index.d.ts.map +1 -1
  22. package/dist/hooks/index.js +30 -25
  23. package/dist/hooks/useSelection.d.ts +14 -0
  24. package/dist/hooks/useSelection.d.ts.map +1 -0
  25. package/dist/{index-DA_GGs_P.js → index-BrphSJJ2.js} +113 -112
  26. package/dist/main.js +1289 -1047
  27. package/dist/schemas/config.d.ts +11 -0
  28. package/dist/schemas/config.d.ts.map +1 -1
  29. package/dist/schemas/index.js +1 -1
  30. package/dist/style.css +1 -1
  31. package/dist/types/index.js +1 -1
  32. package/dist/utils/boxDraw.d.ts +5 -0
  33. package/dist/utils/boxDraw.d.ts.map +1 -0
  34. package/dist/utils/cql2.d.ts +11 -0
  35. package/dist/utils/cql2.d.ts.map +1 -1
  36. package/dist/utils/index.d.ts +2 -0
  37. package/dist/utils/index.d.ts.map +1 -1
  38. package/dist/utils/ogcApi.d.ts +7 -0
  39. package/dist/utils/ogcApi.d.ts.map +1 -1
  40. package/dist/utils/selection.d.ts +12 -0
  41. package/dist/utils/selection.d.ts.map +1 -0
  42. package/package.json +1 -1
  43. package/dist/FeatureTooltip-Db1LgLQV.js +0 -47
  44. package/dist/geo-CIJBPCVe.js +0 -1038
@@ -0,0 +1,1116 @@
1
+ import { useState as d, useEffect as G, useCallback as P, useMemo as j } from "react";
2
+ var b = 63710088e-1, ee = {
3
+ centimeters: b * 100,
4
+ centimetres: b * 100,
5
+ degrees: 360 / (2 * Math.PI),
6
+ feet: b * 3.28084,
7
+ inches: b * 39.37,
8
+ kilometers: b / 1e3,
9
+ kilometres: b / 1e3,
10
+ meters: b,
11
+ metres: b,
12
+ miles: b / 1609.344,
13
+ millimeters: b * 1e3,
14
+ millimetres: b * 1e3,
15
+ nauticalmiles: b / 1852,
16
+ radians: 1,
17
+ yards: b * 1.0936
18
+ };
19
+ function T(e, t, n = {}) {
20
+ const r = { type: "Feature" };
21
+ return (n.id === 0 || n.id) && (r.id = n.id), n.bbox && (r.bbox = n.bbox), r.properties = t || {}, r.geometry = e, r;
22
+ }
23
+ function te(e, t, n = {}) {
24
+ for (const s of e) {
25
+ if (s.length < 4)
26
+ throw new Error(
27
+ "Each LinearRing of a Polygon must have 4 or more Positions."
28
+ );
29
+ if (s[s.length - 1].length !== s[0].length)
30
+ throw new Error("First and last Position are not equivalent.");
31
+ for (let i = 0; i < s[s.length - 1].length; i++)
32
+ if (s[s.length - 1][i] !== s[0][i])
33
+ throw new Error("First and last Position are not equivalent.");
34
+ }
35
+ return T({
36
+ type: "Polygon",
37
+ coordinates: e
38
+ }, t, n);
39
+ }
40
+ function z(e, t, n = {}) {
41
+ if (e.length < 2)
42
+ throw new Error("coordinates must be an array of two or more positions");
43
+ return T({
44
+ type: "LineString",
45
+ coordinates: e
46
+ }, t, n);
47
+ }
48
+ function ne(e, t = "kilometers") {
49
+ const n = ee[t];
50
+ if (!n)
51
+ throw new Error(t + " units is invalid");
52
+ return e * n;
53
+ }
54
+ function O(e) {
55
+ return e % 360 * Math.PI / 180;
56
+ }
57
+ function x(e) {
58
+ if (!e)
59
+ throw new Error("coord is required");
60
+ if (!Array.isArray(e)) {
61
+ if (e.type === "Feature" && e.geometry !== null && e.geometry.type === "Point")
62
+ return [...e.geometry.coordinates];
63
+ if (e.type === "Point")
64
+ return [...e.coordinates];
65
+ }
66
+ if (Array.isArray(e) && e.length >= 2 && !Array.isArray(e[0]) && !Array.isArray(e[1]))
67
+ return [...e];
68
+ throw new Error("coord must be GeoJSON Point or an Array of numbers");
69
+ }
70
+ function re(e, t, n = {}) {
71
+ var r = x(e), s = x(t), i = O(s[1] - r[1]), l = O(s[0] - r[0]), o = O(r[1]), a = O(s[1]), c = Math.pow(Math.sin(i / 2), 2) + Math.pow(Math.sin(l / 2), 2) * Math.cos(o) * Math.cos(a);
72
+ return ne(
73
+ 2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)),
74
+ n.units
75
+ );
76
+ }
77
+ function Q(e, t, n) {
78
+ if (e !== null)
79
+ for (var r, s, i, l, o, a, c, g = 0, f = 0, u, m = e.type, h = m === "FeatureCollection", y = m === "Feature", w = h ? e.features.length : 1, p = 0; p < w; p++) {
80
+ c = h ? (
81
+ // @ts-expect-error: Known type conflict
82
+ e.features[p].geometry
83
+ ) : y ? (
84
+ // @ts-expect-error: Known type conflict
85
+ e.geometry
86
+ ) : e, u = c ? c.type === "GeometryCollection" : !1, o = u ? c.geometries.length : 1;
87
+ for (var $ = 0; $ < o; $++) {
88
+ var M = 0, v = 0;
89
+ if (l = u ? c.geometries[$] : c, l !== null) {
90
+ a = l.coordinates;
91
+ var S = l.type;
92
+ switch (g = 0, S) {
93
+ case null:
94
+ break;
95
+ case "Point":
96
+ if (
97
+ // @ts-expect-error: Known type conflict
98
+ t(
99
+ a,
100
+ f,
101
+ p,
102
+ M,
103
+ v
104
+ ) === !1
105
+ )
106
+ return !1;
107
+ f++, M++;
108
+ break;
109
+ case "LineString":
110
+ case "MultiPoint":
111
+ for (r = 0; r < a.length; r++) {
112
+ if (
113
+ // @ts-expect-error: Known type conflict
114
+ t(
115
+ a[r],
116
+ f,
117
+ p,
118
+ M,
119
+ v
120
+ ) === !1
121
+ )
122
+ return !1;
123
+ f++, S === "MultiPoint" && M++;
124
+ }
125
+ S === "LineString" && M++;
126
+ break;
127
+ case "Polygon":
128
+ case "MultiLineString":
129
+ for (r = 0; r < a.length; r++) {
130
+ for (s = 0; s < a[r].length - g; s++) {
131
+ if (
132
+ // @ts-expect-error: Known type conflict
133
+ t(
134
+ a[r][s],
135
+ f,
136
+ p,
137
+ M,
138
+ v
139
+ ) === !1
140
+ )
141
+ return !1;
142
+ f++;
143
+ }
144
+ S === "MultiLineString" && M++, S === "Polygon" && v++;
145
+ }
146
+ S === "Polygon" && M++;
147
+ break;
148
+ case "MultiPolygon":
149
+ for (r = 0; r < a.length; r++) {
150
+ for (v = 0, s = 0; s < a[r].length; s++) {
151
+ for (i = 0; i < a[r][s].length - g; i++) {
152
+ if (
153
+ // @ts-expect-error: Known type conflict
154
+ t(
155
+ a[r][s][i],
156
+ f,
157
+ p,
158
+ M,
159
+ v
160
+ ) === !1
161
+ )
162
+ return !1;
163
+ f++;
164
+ }
165
+ v++;
166
+ }
167
+ M++;
168
+ }
169
+ break;
170
+ case "GeometryCollection":
171
+ for (r = 0; r < l.geometries.length; r++)
172
+ if (
173
+ // @ts-expect-error: Known type conflict
174
+ Q(l.geometries[r], t) === !1
175
+ )
176
+ return !1;
177
+ break;
178
+ default:
179
+ throw new Error("Unknown Geometry Type");
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+ function V(e, t) {
186
+ var n, r, s, i, l, o, a, c, g, f, u = 0, m = e.type === "FeatureCollection", h = e.type === "Feature", y = m ? e.features.length : 1;
187
+ for (n = 0; n < y; n++) {
188
+ for (o = m ? (
189
+ // @ts-expect-error: Known type conflict
190
+ e.features[n].geometry
191
+ ) : h ? (
192
+ // @ts-expect-error: Known type conflict
193
+ e.geometry
194
+ ) : e, c = m ? (
195
+ // @ts-expect-error: Known type conflict
196
+ e.features[n].properties
197
+ ) : h ? (
198
+ // @ts-expect-error: Known type conflict
199
+ e.properties
200
+ ) : {}, g = m ? (
201
+ // @ts-expect-error: Known type conflict
202
+ e.features[n].bbox
203
+ ) : h ? (
204
+ // @ts-expect-error: Known type conflict
205
+ e.bbox
206
+ ) : void 0, f = m ? (
207
+ // @ts-expect-error: Known type conflict
208
+ e.features[n].id
209
+ ) : h ? (
210
+ // @ts-expect-error: Known type conflict
211
+ e.id
212
+ ) : void 0, a = o ? o.type === "GeometryCollection" : !1, l = a ? o.geometries.length : 1, s = 0; s < l; s++) {
213
+ if (i = a ? o.geometries[s] : o, i === null) {
214
+ if (
215
+ // @ts-expect-error: Known type conflict
216
+ t(
217
+ // @ts-expect-error: Known type conflict
218
+ null,
219
+ u,
220
+ c,
221
+ g,
222
+ f
223
+ ) === !1
224
+ )
225
+ return !1;
226
+ continue;
227
+ }
228
+ switch (i.type) {
229
+ case "Point":
230
+ case "LineString":
231
+ case "MultiPoint":
232
+ case "Polygon":
233
+ case "MultiLineString":
234
+ case "MultiPolygon": {
235
+ if (
236
+ // @ts-expect-error: Known type conflict
237
+ t(
238
+ i,
239
+ u,
240
+ c,
241
+ g,
242
+ f
243
+ ) === !1
244
+ )
245
+ return !1;
246
+ break;
247
+ }
248
+ case "GeometryCollection": {
249
+ for (r = 0; r < i.geometries.length; r++)
250
+ if (
251
+ // @ts-expect-error: Known type conflict
252
+ t(
253
+ i.geometries[r],
254
+ u,
255
+ c,
256
+ g,
257
+ f
258
+ ) === !1
259
+ )
260
+ return !1;
261
+ break;
262
+ }
263
+ default:
264
+ throw new Error("Unknown Geometry Type");
265
+ }
266
+ }
267
+ u++;
268
+ }
269
+ }
270
+ function se(e, t, n) {
271
+ var r = n;
272
+ return V(
273
+ e,
274
+ function(s, i, l, o, a) {
275
+ r = t(
276
+ // @ts-expect-error: Known type conflict
277
+ r,
278
+ s,
279
+ i,
280
+ l,
281
+ o,
282
+ a
283
+ );
284
+ }
285
+ ), r;
286
+ }
287
+ function ie(e, t) {
288
+ V(e, function(n, r, s, i, l) {
289
+ var o = n === null ? null : n.type;
290
+ switch (o) {
291
+ case null:
292
+ case "Point":
293
+ case "LineString":
294
+ case "Polygon":
295
+ return (
296
+ // @ts-expect-error: Known type conflict
297
+ t(
298
+ T(n, s, { bbox: i, id: l }),
299
+ r,
300
+ 0
301
+ ) === !1 ? !1 : void 0
302
+ );
303
+ }
304
+ var a;
305
+ switch (o) {
306
+ case "MultiPoint":
307
+ a = "Point";
308
+ break;
309
+ case "MultiLineString":
310
+ a = "LineString";
311
+ break;
312
+ case "MultiPolygon":
313
+ a = "Polygon";
314
+ break;
315
+ }
316
+ for (
317
+ var c = 0;
318
+ // @ts-expect-error: Known type conflict
319
+ c < n.coordinates.length;
320
+ c++
321
+ ) {
322
+ var g = n.coordinates[c], f = {
323
+ type: a,
324
+ coordinates: g
325
+ };
326
+ if (
327
+ // @ts-expect-error: Known type conflict
328
+ t(T(f, s), r, c) === !1
329
+ )
330
+ return !1;
331
+ }
332
+ });
333
+ }
334
+ function oe(e, t) {
335
+ ie(e, function(n, r, s) {
336
+ var i = 0;
337
+ if (n.geometry) {
338
+ var l = n.geometry.type;
339
+ if (!(l === "Point" || l === "MultiPoint")) {
340
+ var o, a = 0, c = 0, g = 0;
341
+ if (
342
+ // @ts-expect-error: Known type conflict
343
+ Q(
344
+ n,
345
+ function(f, u, m, h, y) {
346
+ if (
347
+ // @ts-expect-error: Known type conflict
348
+ o === void 0 || r > a || h > c || y > g
349
+ ) {
350
+ o = f, a = r, c = h, g = y, i = 0;
351
+ return;
352
+ }
353
+ var w = z(
354
+ // @ts-expect-error: Known type conflict
355
+ [o, f],
356
+ n.properties
357
+ );
358
+ if (
359
+ // @ts-expect-error: Known type conflict
360
+ t(
361
+ // @ts-expect-error: Known type conflict
362
+ w,
363
+ r,
364
+ s,
365
+ y,
366
+ i
367
+ ) === !1
368
+ )
369
+ return !1;
370
+ i++, o = f;
371
+ }
372
+ ) === !1
373
+ )
374
+ return !1;
375
+ }
376
+ }
377
+ });
378
+ }
379
+ function ae(e, t, n) {
380
+ var r = n, s = !1;
381
+ return oe(
382
+ e,
383
+ function(i, l, o, a, c) {
384
+ s === !1 && n === void 0 ? r = i : r = t(
385
+ r,
386
+ // @ts-expect-error: Known type conflict
387
+ i,
388
+ l,
389
+ o,
390
+ a,
391
+ c
392
+ ), s = !0;
393
+ }
394
+ ), r;
395
+ }
396
+ function le(e, t = {}) {
397
+ return ae(
398
+ e,
399
+ (n, r) => {
400
+ const s = r.geometry.coordinates;
401
+ return n + re(s[0], s[1], t);
402
+ },
403
+ 0
404
+ );
405
+ }
406
+ var ce = le;
407
+ function ue(e) {
408
+ return se(
409
+ e,
410
+ (t, n) => t + fe(n),
411
+ 0
412
+ );
413
+ }
414
+ function fe(e) {
415
+ let t = 0, n;
416
+ switch (e.type) {
417
+ case "Polygon":
418
+ return _(e.coordinates);
419
+ case "MultiPolygon":
420
+ for (n = 0; n < e.coordinates.length; n++)
421
+ t += _(e.coordinates[n]);
422
+ return t;
423
+ case "Point":
424
+ case "MultiPoint":
425
+ case "LineString":
426
+ case "MultiLineString":
427
+ return 0;
428
+ }
429
+ return 0;
430
+ }
431
+ function _(e) {
432
+ let t = 0;
433
+ if (e && e.length > 0) {
434
+ t += Math.abs(I(e[0]));
435
+ for (let n = 1; n < e.length; n++)
436
+ t -= Math.abs(I(e[n]));
437
+ }
438
+ return t;
439
+ }
440
+ var ge = b * b / 2, N = Math.PI / 180;
441
+ function I(e) {
442
+ const t = e.length - 1;
443
+ if (t <= 2) return 0;
444
+ let n = 0, r = 0;
445
+ for (; r < t; ) {
446
+ const s = e[r], i = e[r + 1 === t ? 0 : r + 1], l = e[r + 2 >= t ? (r + 2) % t : r + 2], o = s[0] * N, a = i[1] * N, c = l[0] * N;
447
+ n += (c - o) * Math.sin(a), r++;
448
+ }
449
+ return n * ge;
450
+ }
451
+ var he = ue;
452
+ const xe = {
453
+ distance: ["km", "mi", "m", "ft"],
454
+ area: ["km2", "mi2", "ha", "acres"]
455
+ }, me = {
456
+ km: "km",
457
+ mi: "mi",
458
+ m: "m",
459
+ ft: "ft",
460
+ km2: "km²",
461
+ mi2: "mi²",
462
+ ha: "ha",
463
+ acres: "ac"
464
+ }, de = {
465
+ km: 1,
466
+ mi: 0.621371,
467
+ m: 1e3,
468
+ ft: 3280.84
469
+ }, ye = {
470
+ km2: 1e-6,
471
+ mi2: 3861e-10,
472
+ ha: 1e-4,
473
+ acres: 247105e-9
474
+ };
475
+ function pe(e, t = "km") {
476
+ if (e.length < 2) return 0;
477
+ const n = z(e);
478
+ return ce(n, { units: "kilometers" }) * de[t];
479
+ }
480
+ function be(e, t = "km2") {
481
+ if (e.length < 3) return 0;
482
+ const n = [...e, e[0]], r = te([n]);
483
+ return he(r) * ye[t];
484
+ }
485
+ function we(e, t, n) {
486
+ return e === "distance" && t.length >= 2 ? { value: pe(t, n), unit: n } : e === "area" && t.length >= 3 ? { value: be(t, n), unit: n } : null;
487
+ }
488
+ function Me(e) {
489
+ return e === "distance" ? "km" : "km2";
490
+ }
491
+ function Se(e, t) {
492
+ return t.length < 2 ? null : {
493
+ type: "Feature",
494
+ geometry: e === "area" && t.length >= 3 ? { type: "Polygon", coordinates: [[...t, t[0]]] } : { type: "LineString", coordinates: t },
495
+ properties: {}
496
+ };
497
+ }
498
+ function $e(e) {
499
+ return e.length === 0 ? null : {
500
+ type: "FeatureCollection",
501
+ features: e.map((t) => ({
502
+ type: "Feature",
503
+ geometry: { type: "Point", coordinates: t },
504
+ properties: {}
505
+ }))
506
+ };
507
+ }
508
+ function _e(e) {
509
+ const { value: t, unit: n } = e, r = me[n];
510
+ return t < 0.01 ? `< 0.01 ${r}` : t < 100 ? `${t.toFixed(2)} ${r}` : t < 1e4 ? `${t.toFixed(1)} ${r}` : `${t.toLocaleString(void 0, { maximumFractionDigits: 0 })} ${r}`;
511
+ }
512
+ function C(e) {
513
+ return e.endsWith("/") ? e.slice(0, -1) : e;
514
+ }
515
+ async function L(e) {
516
+ const t = await fetch(e);
517
+ if (!t.ok)
518
+ throw new Error(`OGC API request failed: ${t.status} ${t.statusText} (${e})`);
519
+ return t.json();
520
+ }
521
+ async function ve(e) {
522
+ const t = `${C(e)}/collections?f=json`;
523
+ return (await L(t)).collections;
524
+ }
525
+ async function k(e, t, n = {}) {
526
+ var l;
527
+ const r = C(e), s = new URLSearchParams({ f: "geojson" });
528
+ if (n.limit != null && s.set("limit", String(n.limit)), n.offset != null && s.set("offset", String(n.offset)), n.bbox && s.set("bbox", n.bbox.join(",")), (l = n.properties) != null && l.length && s.set("properties", n.properties.join(",")), n.datetime && s.set("datetime", n.datetime), n.cql2Filter)
529
+ s.set("filter-lang", "cql2-json"), s.set("filter", JSON.stringify(n.cql2Filter));
530
+ else if (n.filter)
531
+ for (const [o, a] of Object.entries(n.filter))
532
+ s.set(o, String(a));
533
+ const i = `${r}/collections/${encodeURIComponent(t)}/items?${s}`;
534
+ return L(i);
535
+ }
536
+ async function Ie(e, t, n) {
537
+ const s = `${C(e)}/collections/${encodeURIComponent(t)}/items/${encodeURIComponent(String(n))}?f=geojson`;
538
+ try {
539
+ return await L(s);
540
+ } catch {
541
+ return null;
542
+ }
543
+ }
544
+ async function Pe(e, t) {
545
+ const r = `${C(e)}/collections/${encodeURIComponent(t)}/queryables?f=schemajson`;
546
+ return L(r);
547
+ }
548
+ async function Ce(e, t) {
549
+ const r = `${C(e)}/collections/${encodeURIComponent(t)}?f=json`;
550
+ return L(r);
551
+ }
552
+ async function We(e) {
553
+ const t = `${C(e)}/conformance?f=json`;
554
+ return L(t);
555
+ }
556
+ async function Je(e, t, n = "WebMercatorQuad") {
557
+ const r = Le(e, t, n);
558
+ return L(r);
559
+ }
560
+ async function ze(e, t, n = {}) {
561
+ return (await k(e, t, {
562
+ ...n,
563
+ limit: 0
564
+ })).numberMatched ?? null;
565
+ }
566
+ function Le(e, t, n = "WebMercatorQuad") {
567
+ return `${C(e)}/collections/${encodeURIComponent(t)}/tiles/${encodeURIComponent(n)}/tilejson.json`;
568
+ }
569
+ function Qe(e, t, n = "WebMercatorQuad") {
570
+ return `${C(e)}/collections/${encodeURIComponent(t)}/tiles/${encodeURIComponent(n)}/{z}/{x}/{y}`;
571
+ }
572
+ function Ve(e, t, n, r = "WebMercatorQuad") {
573
+ const i = `${C(e)}/collections/${encodeURIComponent(t)}/tiles/${encodeURIComponent(r)}/{z}/{x}/{y}`;
574
+ if (!n || Object.keys(n).length === 0) return i;
575
+ const l = new URLSearchParams();
576
+ for (const [o, a] of Object.entries(n))
577
+ l.set(o, String(a));
578
+ return `${i}?${l}`;
579
+ }
580
+ async function Be(e, t, n, r) {
581
+ const s = r != null && r.query ? { op: "like", args: [{ property: n }, `%${r.query}%`] } : void 0, i = /* @__PURE__ */ new Set(), l = (o) => {
582
+ var a;
583
+ for (const c of o) {
584
+ const g = (a = c.properties) == null ? void 0 : a[n];
585
+ g != null && typeof g == "string" && i.add(g);
586
+ }
587
+ };
588
+ if (r != null && r.fetchAll) {
589
+ const o = r.maxFeatures ?? 1e4, a = r.limit ?? 500;
590
+ let c = 0, g = 0;
591
+ for (; g < o; ) {
592
+ const f = Math.min(a, o - g), u = await k(e, t, {
593
+ properties: [n],
594
+ limit: f,
595
+ offset: c,
596
+ cql2Filter: s
597
+ });
598
+ if (l(u.features), g += u.features.length, c += u.features.length, u.features.length < f || u.numberMatched != null && c >= u.numberMatched) break;
599
+ }
600
+ } else {
601
+ const o = await k(e, t, {
602
+ properties: [n],
603
+ limit: (r == null ? void 0 : r.limit) ?? 50,
604
+ cql2Filter: s
605
+ });
606
+ l(o.features);
607
+ }
608
+ return Array.from(i).sort();
609
+ }
610
+ function Ke(e, t, n, r = "WebMercatorQuad") {
611
+ const i = `${C(e)}/collections/${encodeURIComponent(t)}/tiles/${encodeURIComponent(r)}/{z}/{x}/{y}`;
612
+ if (!n) return i;
613
+ const l = new URLSearchParams({
614
+ "filter-lang": "cql2-json",
615
+ filter: JSON.stringify(n)
616
+ });
617
+ return `${i}?${l}`;
618
+ }
619
+ function Ye(e) {
620
+ const [t, n] = d([]), [r, s] = d(!1), [i, l] = d(null);
621
+ return G(() => {
622
+ if (!e) return;
623
+ let o = !1;
624
+ return s(!0), l(null), ve(e).then((a) => {
625
+ o || n(a);
626
+ }).catch((a) => {
627
+ o || l(a instanceof Error ? a : new Error(String(a)));
628
+ }).finally(() => {
629
+ o || s(!1);
630
+ }), () => {
631
+ o = !0;
632
+ };
633
+ }, [e]), { collections: t, loading: r, error: i };
634
+ }
635
+ function Xe(e, t) {
636
+ const [n, r] = d(null), [s, i] = d(!1), [l, o] = d(null);
637
+ return G(() => {
638
+ if (!e || !t) return;
639
+ let a = !1;
640
+ return i(!0), o(null), Pe(e, t).then((c) => {
641
+ a || r(c);
642
+ }).catch((c) => {
643
+ a || o(c instanceof Error ? c : new Error(String(c)));
644
+ }).finally(() => {
645
+ a || i(!1);
646
+ }), () => {
647
+ a = !0;
648
+ };
649
+ }, [e, t]), { queryables: n, loading: s, error: l };
650
+ }
651
+ function He(e, t, n = {}) {
652
+ const [r, s] = d([]), [i, l] = d(!1), [o, a] = d(null), [c, g] = d(!1), f = JSON.stringify(n);
653
+ return G(() => {
654
+ if (!e || !t) return;
655
+ let u = !1;
656
+ l(!0), a(null);
657
+ const m = JSON.parse(f);
658
+ return k(e, t, m).then((h) => {
659
+ if (!u) {
660
+ s(h.features);
661
+ const y = m.limit ?? 10, w = m.offset ?? 0;
662
+ h.numberMatched != null ? g(w + h.features.length < h.numberMatched) : g(h.features.length >= y);
663
+ }
664
+ }).catch((h) => {
665
+ u || (a(h instanceof Error ? h : new Error(String(h))), s([]), g(!1));
666
+ }).finally(() => {
667
+ u || l(!1);
668
+ }), () => {
669
+ u = !0;
670
+ };
671
+ }, [e, t, f]), { features: r, loading: i, error: o, hasMore: c };
672
+ }
673
+ function D(e) {
674
+ return `${e[0]} ${e[1]}`;
675
+ }
676
+ function R(e) {
677
+ return e.map(D).join(", ");
678
+ }
679
+ function B(e) {
680
+ if (!e || !e.type) return "";
681
+ switch (e.type) {
682
+ case "Point":
683
+ return `POINT (${D(e.coordinates)})`;
684
+ case "MultiPoint":
685
+ return `MULTIPOINT (${e.coordinates.map((t) => `(${D(t)})`).join(", ")})`;
686
+ case "LineString":
687
+ return `LINESTRING (${R(e.coordinates)})`;
688
+ case "MultiLineString":
689
+ return `MULTILINESTRING (${e.coordinates.map((t) => `(${R(t)})`).join(", ")})`;
690
+ case "Polygon":
691
+ return `POLYGON (${e.coordinates.map((t) => `(${R(t)})`).join(", ")})`;
692
+ case "MultiPolygon":
693
+ return `MULTIPOLYGON (${e.coordinates.map((t) => `(${t.map((n) => `(${R(n)})`).join(", ")})`).join(", ")})`;
694
+ case "GeometryCollection":
695
+ return `GEOMETRYCOLLECTION (${e.geometries.map(B).join(", ")})`;
696
+ default:
697
+ return "";
698
+ }
699
+ }
700
+ function K(e, t) {
701
+ const n = URL.createObjectURL(e), r = document.createElement("a");
702
+ r.href = n, r.download = t, r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
703
+ }
704
+ function U(e, t) {
705
+ return e.includes('"') || e.includes(t) || e.includes(`
706
+ `) ? `"${e.replace(/"/g, '""')}"` : e;
707
+ }
708
+ function ke(e, t) {
709
+ const n = (e.properties ?? {})[t];
710
+ return n == null ? "" : typeof n == "object" ? JSON.stringify(n) : String(n);
711
+ }
712
+ function Ee(e, t = {}) {
713
+ const { fields: n, includeGeometry: r = !0, delimiter: s = "," } = t;
714
+ if (e.length === 0) return "";
715
+ const i = n ?? [...new Set(e.flatMap((a) => Object.keys(a.properties ?? {})))], l = r ? [...i, "geometry"] : i, o = e.map((a) => {
716
+ const c = i.map(
717
+ (g) => U(ke(a, g), s)
718
+ );
719
+ return r && c.push(U(B(a.geometry), s)), c.join(s);
720
+ });
721
+ return [l.map((a) => U(a, s)).join(s), ...o].join(`
722
+ `);
723
+ }
724
+ function Fe(e, t) {
725
+ const n = new Blob([e], { type: "text/csv;charset=utf-8;" });
726
+ K(n, t);
727
+ }
728
+ function Ze({
729
+ baseUrl: e,
730
+ limit: t = 1e3,
731
+ csvOptions: n
732
+ }) {
733
+ const [r, s] = d(!1), [i, l] = d(null);
734
+ return { exportCsv: P(
735
+ async (a, c = `${a}.csv`, g) => {
736
+ s(!0), l(null);
737
+ const f = [], u = Math.min(t, 1e3);
738
+ let m = 0;
739
+ try {
740
+ for (; f.length < t; ) {
741
+ const y = t - f.length, w = Math.min(u, y), p = await k(e, a, {
742
+ limit: w,
743
+ offset: m,
744
+ cql2Filter: g
745
+ });
746
+ if (f.push(...p.features), m += p.features.length, p.features.length < w || p.numberMatched != null && m >= p.numberMatched) break;
747
+ }
748
+ const h = Ee(f, n);
749
+ Fe(h, c);
750
+ } catch (h) {
751
+ l(h instanceof Error ? h : new Error(String(h)));
752
+ } finally {
753
+ s(!1);
754
+ }
755
+ },
756
+ [e, t, n]
757
+ ), loading: r, error: i };
758
+ }
759
+ function et({
760
+ baseUrl: e,
761
+ limit: t = 1e5,
762
+ converters: n
763
+ }) {
764
+ const [r, s] = d(!1), [i, l] = d(null), [o, a] = d(null);
765
+ return { runExport: P(
766
+ async (g, f, u, m) => {
767
+ const h = n[f];
768
+ if (!h) {
769
+ a(new Error(`Unknown export format: ${f}`));
770
+ return;
771
+ }
772
+ s(!0), l("Fetching features..."), a(null);
773
+ const y = [], w = Math.min(t, 1e3);
774
+ let p = 0;
775
+ try {
776
+ for (; y.length < t; ) {
777
+ const M = t - y.length, v = Math.min(w, M), S = await k(e, g, {
778
+ limit: v,
779
+ offset: p,
780
+ cql2Filter: m
781
+ });
782
+ y.push(...S.features), p += S.features.length;
783
+ const F = S.numberMatched;
784
+ if (F != null ? l(`Fetching features... (${y.length} of ${F})`) : l(`Fetching features... (${y.length})`), S.features.length < v || F != null && p >= F) break;
785
+ }
786
+ l("Converting...");
787
+ const $ = await h(y, g);
788
+ K($.blob, u);
789
+ } catch ($) {
790
+ a($ instanceof Error ? $ : new Error(String($)));
791
+ } finally {
792
+ s(!1), l(null);
793
+ }
794
+ },
795
+ [e, t, n]
796
+ ), loading: r, progress: i, error: o };
797
+ }
798
+ function tt(e, t) {
799
+ const [n, r] = d(null), [s, i] = d(!1), [l, o] = d(null);
800
+ return G(() => {
801
+ if (!e || !t) return;
802
+ let a = !1;
803
+ return i(!0), o(null), Ce(e, t).then((c) => {
804
+ a || r(c);
805
+ }).catch((c) => {
806
+ a || o(c instanceof Error ? c : new Error(String(c)));
807
+ }).finally(() => {
808
+ a || i(!1);
809
+ }), () => {
810
+ a = !0;
811
+ };
812
+ }, [e, t]), { collection: n, loading: s, error: l };
813
+ }
814
+ function nt() {
815
+ const [e, t] = d(null), [n, r] = d([]), [s, i] = d("km"), l = j(
816
+ () => e ? we(e, n, s) : null,
817
+ [e, n, s]
818
+ ), o = j(
819
+ () => e ? Se(e, n) : null,
820
+ [e, n]
821
+ ), a = j(
822
+ () => e ? $e(n) : null,
823
+ [e, n]
824
+ ), c = P((u) => {
825
+ t(u), r([]), u && i(Me(u));
826
+ }, []), g = P((u) => {
827
+ r((m) => [...m, u]);
828
+ }, []), f = P(() => {
829
+ r([]);
830
+ }, []);
831
+ return { mode: e, points: n, unit: s, measurement: l, geometryData: o, pointsData: a, setMode: c, setUnit: i, addPoint: g, clear: f };
832
+ }
833
+ function q(e) {
834
+ return e.id != null ? `${e.layerId}:${e.id}` : `${e.layerId}:${JSON.stringify(e.properties)}`;
835
+ }
836
+ const W = 1e3;
837
+ function rt() {
838
+ const [e, t] = d(null), [n, r] = d(null), [s, i] = d([]), l = j(() => s.length === 0 ? null : {
839
+ type: "FeatureCollection",
840
+ features: s.map((u) => ({
841
+ type: "Feature",
842
+ properties: u.properties,
843
+ geometry: u.geometry
844
+ }))
845
+ }, [s]), o = P((u) => {
846
+ t(u);
847
+ }, []), a = P((u) => {
848
+ r(u), i([]);
849
+ }, []), c = P((u) => {
850
+ i((m) => {
851
+ const h = new Set(m.map(q)), y = u.filter((p) => !h.has(q(p))), w = [...m, ...y];
852
+ return w.length > W ? w.slice(0, W) : w;
853
+ });
854
+ }, []), g = P((u) => {
855
+ i((m) => m.filter((h) => q(h) !== u));
856
+ }, []), f = P(() => {
857
+ i([]);
858
+ }, []);
859
+ return {
860
+ mode: e,
861
+ activeLayerId: n,
862
+ features: s,
863
+ highlightData: l,
864
+ setMode: o,
865
+ setActiveLayerId: a,
866
+ addFeatures: c,
867
+ removeFeature: g,
868
+ clearFeatures: f
869
+ };
870
+ }
871
+ function st(e) {
872
+ if (!e) return;
873
+ const t = [], n = {};
874
+ for (const [r, s] of Object.entries(e))
875
+ s.visible !== !1 && (t.push(r), s.label && (n[r] = s.label));
876
+ return { fields: t, labels: n };
877
+ }
878
+ async function it(e) {
879
+ try {
880
+ const t = await fetch(e);
881
+ if (!t.ok) return null;
882
+ const n = await t.json();
883
+ return n.sprite ? typeof n.sprite == "string" ? n.sprite : Array.isArray(n.sprite) && n.sprite.length > 0 ? n.sprite[0].url : null : null;
884
+ } catch {
885
+ return null;
886
+ }
887
+ }
888
+ async function Oe(e) {
889
+ try {
890
+ const t = await fetch(`${e}.json`);
891
+ if (!t.ok) return [];
892
+ const n = await t.json();
893
+ return Object.keys(n).sort();
894
+ } catch {
895
+ return [];
896
+ }
897
+ }
898
+ async function ot(e, t) {
899
+ const n = await fetch(e);
900
+ if (!n.ok) throw new Error(`Failed to fetch style: ${n.status}`);
901
+ const r = await n.json();
902
+ if (!t.length) return r;
903
+ const s = Array.isArray(r.sprite) ? r.sprite : r.sprite ? [{ id: "default", url: r.sprite }] : [], i = new Set(t.map((o) => o.id)), l = [
904
+ ...s.filter((o) => !i.has(o.id)),
905
+ ...t.map((o) => ({ id: o.id, url: o.url }))
906
+ ];
907
+ return { ...r, sprite: l };
908
+ }
909
+ async function Re(e) {
910
+ try {
911
+ const t = await fetch(e);
912
+ if (!t.ok) return [];
913
+ const n = await t.json();
914
+ return n.sprite ? typeof n.sprite == "string" ? [{ id: "default", url: n.sprite }] : Array.isArray(n.sprite) ? n.sprite : [] : [];
915
+ } catch {
916
+ return [];
917
+ }
918
+ }
919
+ async function J(e) {
920
+ const t = await Oe(e.url);
921
+ return e.id === "default" ? t : t.map((n) => `${e.id}:${n}`);
922
+ }
923
+ async function at(e, t = []) {
924
+ const n = [];
925
+ e && n.push(
926
+ Re(e).then(
927
+ (s) => Promise.all(s.map(J)).then((i) => i.flat())
928
+ )
929
+ );
930
+ for (const s of t)
931
+ n.push(J(s));
932
+ const r = await Promise.all(n);
933
+ return [...new Set(r.flat())].sort();
934
+ }
935
+ function E(e, t) {
936
+ return { op: "=", args: [{ property: e }, t] };
937
+ }
938
+ function lt(e, t) {
939
+ return { op: "<>", args: [{ property: e }, t] };
940
+ }
941
+ function Ae(e, t) {
942
+ return { op: ">", args: [{ property: e }, t] };
943
+ }
944
+ function Y(e, t) {
945
+ return { op: ">=", args: [{ property: e }, t] };
946
+ }
947
+ function je(e, t) {
948
+ return { op: "<", args: [{ property: e }, t] };
949
+ }
950
+ function X(e, t) {
951
+ return { op: "<=", args: [{ property: e }, t] };
952
+ }
953
+ function Te(e, t, n) {
954
+ return { op: "and", args: [Y(e, t), X(e, n)] };
955
+ }
956
+ function ct(e, t) {
957
+ return { op: "like", args: [{ property: e }, t] };
958
+ }
959
+ function ut(e, t) {
960
+ return { op: "in", args: [{ property: e }, t] };
961
+ }
962
+ function ft(e) {
963
+ return { op: "isNull", args: [{ property: e }] };
964
+ }
965
+ function H(...e) {
966
+ const t = e.filter((n) => n != null);
967
+ return t.length === 0 ? null : t.length === 1 ? t[0] : { op: "and", args: t };
968
+ }
969
+ function gt(...e) {
970
+ const t = e.filter((n) => n != null);
971
+ return t.length === 0 ? null : t.length === 1 ? t[0] : { op: "or", args: t };
972
+ }
973
+ function ht(e) {
974
+ return { op: "not", args: [e] };
975
+ }
976
+ function Ge(e, t) {
977
+ return { op: "t_after", args: [{ property: e }, t] };
978
+ }
979
+ function Ne(e, t) {
980
+ return { op: "t_before", args: [{ property: e }, t] };
981
+ }
982
+ function Ue(e, t, n) {
983
+ const r = "date" in t ? t.date : t.timestamp, s = "date" in n ? n.date : n.timestamp;
984
+ return { op: "t_during", args: [{ property: e }, { interval: [r, s] }] };
985
+ }
986
+ function mt(e, t) {
987
+ return { op: "s_intersects", args: [{ property: e }, t] };
988
+ }
989
+ function dt(e, t) {
990
+ return { op: "s_within", args: [{ property: e }, t] };
991
+ }
992
+ function yt(e, t, n, r = "meters") {
993
+ return { op: "s_dwithin", args: [{ property: e }, t, n, r] };
994
+ }
995
+ function pt(e) {
996
+ const t = Object.entries(e).filter(([, n]) => n !== void 0 && n !== "").map(([n, r]) => E(n, r));
997
+ return H(...t);
998
+ }
999
+ function bt(e, t) {
1000
+ const n = new Map(t.map((s) => [s.property, s])), r = Object.entries(e).map(([s, i]) => {
1001
+ if (i === void 0) return null;
1002
+ const l = n.get(s);
1003
+ if (typeof i == "string")
1004
+ return i === "" ? null : (l == null ? void 0 : l.type) === "datetime" ? E(s, { timestamp: i }) : E(s, i);
1005
+ if (typeof i == "number")
1006
+ return E(s, i);
1007
+ if (typeof i == "object") {
1008
+ if ("start" in i || "end" in i) {
1009
+ const { start: o, end: a } = i;
1010
+ return o && a ? Ue(s, { timestamp: o }, { timestamp: a }) : o ? Ge(s, { timestamp: o }) : a ? Ne(s, { timestamp: a }) : null;
1011
+ }
1012
+ if ("value" in i && "operator" in i) {
1013
+ const { value: o, operator: a } = i;
1014
+ if (o == null || String(o) === "") return null;
1015
+ switch (a) {
1016
+ case "gt":
1017
+ return Ae(s, o);
1018
+ case "lt":
1019
+ return je(s, o);
1020
+ case "gte":
1021
+ return Y(s, o);
1022
+ case "lte":
1023
+ return X(s, o);
1024
+ default:
1025
+ return E(s, o);
1026
+ }
1027
+ }
1028
+ if ("min" in i && "max" in i) {
1029
+ const { min: o, max: a } = i;
1030
+ return o === void 0 || a === void 0 ? null : Te(s, o, a);
1031
+ }
1032
+ }
1033
+ return null;
1034
+ });
1035
+ return H(...r);
1036
+ }
1037
+ function wt(e) {
1038
+ return JSON.stringify(e);
1039
+ }
1040
+ function Z(e) {
1041
+ const t = e.type, n = e.coordinates;
1042
+ return t === "Point" ? [n] : t === "MultiPoint" || t === "LineString" ? n : t === "MultiLineString" || t === "Polygon" ? n.flat() : t === "MultiPolygon" ? n.flat(2) : t === "GeometryCollection" ? (e.geometries ?? []).flatMap(Z) : [];
1043
+ }
1044
+ const A = 0.01;
1045
+ function Mt(e) {
1046
+ const t = Z(e);
1047
+ if (t.length === 0) return null;
1048
+ let n = 1 / 0, r = 1 / 0, s = -1 / 0, i = -1 / 0;
1049
+ for (const [l, o] of t)
1050
+ l < n && (n = l), l > s && (s = l), o < r && (r = o), o > i && (i = o);
1051
+ return n === s && r === i && (n -= A, r -= A, s += A, i += A), [n, r, s, i];
1052
+ }
1053
+ export {
1054
+ be as $,
1055
+ je as A,
1056
+ X as B,
1057
+ lt as C,
1058
+ ht as D,
1059
+ gt as E,
1060
+ st as F,
1061
+ ot as G,
1062
+ yt as H,
1063
+ mt as I,
1064
+ dt as J,
1065
+ wt as K,
1066
+ Ge as L,
1067
+ Ne as M,
1068
+ Ue as N,
1069
+ Ze as O,
1070
+ et as P,
1071
+ nt as Q,
1072
+ tt as R,
1073
+ Ye as S,
1074
+ He as T,
1075
+ Xe as U,
1076
+ rt as V,
1077
+ xe as W,
1078
+ _e as X,
1079
+ me as Y,
1080
+ Se as Z,
1081
+ $e as _,
1082
+ H as a,
1083
+ pe as a0,
1084
+ we as a1,
1085
+ Me as a2,
1086
+ Fe as a3,
1087
+ Oe as a4,
1088
+ it as a5,
1089
+ at as a6,
1090
+ q as a7,
1091
+ Mt as b,
1092
+ Te as c,
1093
+ K as d,
1094
+ E as e,
1095
+ Ee as f,
1096
+ Ce as g,
1097
+ ve as h,
1098
+ We as i,
1099
+ Be as j,
1100
+ Ie as k,
1101
+ ze as l,
1102
+ k as m,
1103
+ Pe as n,
1104
+ Je as o,
1105
+ pt as p,
1106
+ bt as q,
1107
+ Ke as r,
1108
+ Ve as s,
1109
+ Le as t,
1110
+ Qe as u,
1111
+ Ae as v,
1112
+ Y as w,
1113
+ ut as x,
1114
+ ft as y,
1115
+ ct as z
1116
+ };