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