@kalisio/common-geospatial 0.9.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.
@@ -0,0 +1,1334 @@
1
+ import v from "proj4";
2
+ const z = typeof process > "u" || process.env?.NODE_ENV !== "production";
3
+ class K extends Error {
4
+ constructor(t) {
5
+ super(t), this.name = "AssertionError";
6
+ }
7
+ }
8
+ function Q(e, t, n) {
9
+ if (!t(e)) throw new K(n);
10
+ }
11
+ const o = {
12
+ that(e, t, n) {
13
+ z && Q(e, t, n);
14
+ },
15
+ all(e) {
16
+ if (z)
17
+ for (const { value: t, validator: n, message: r } of e)
18
+ Q(t, n, r);
19
+ },
20
+ any(e) {
21
+ if (!(!z || e.length === 0) && !e.some(({ value: t, validator: n }) => n(t)))
22
+ throw new K(e.map(({ message: t }) => t).join(" or "));
23
+ }
24
+ }, a = {
25
+ defined(e) {
26
+ return e != null;
27
+ },
28
+ nil(e) {
29
+ return !a.defined(e);
30
+ },
31
+ plainObject(e) {
32
+ return a.defined(e) && typeof e == "object" && !Array.isArray(e) && e.constructor === Object;
33
+ },
34
+ emptyObject(e) {
35
+ return a.plainObject(e) && Object.keys(e).length === 0;
36
+ },
37
+ nonEmptyObject(e) {
38
+ return a.plainObject(e) && Object.keys(e).length > 0;
39
+ },
40
+ boolean(e) {
41
+ return typeof e == "boolean";
42
+ },
43
+ booleanTrue(e) {
44
+ return e === !0;
45
+ },
46
+ booleanFalse(e) {
47
+ return e === !1;
48
+ },
49
+ string(e) {
50
+ return typeof e == "string";
51
+ },
52
+ emptyString(e) {
53
+ return a.string(e) && e.trim().length === 0;
54
+ },
55
+ nonEmptyString(e) {
56
+ return a.string(e) && e.trim().length > 0;
57
+ },
58
+ char(e) {
59
+ return a.string(e) && /^.$/u.test(e);
60
+ },
61
+ hex(e) {
62
+ return a.nonEmptyString(e) && e.length % 2 === 0 && /^[0-9a-fA-F]*$/.test(e);
63
+ },
64
+ dataUri(e) {
65
+ return a.string(e) ? e.startsWith("data:") && e.includes(";base64,") : !1;
66
+ },
67
+ url(e) {
68
+ if (typeof e != "string") return !1;
69
+ const t = /^([a-z][a-z0-9+.-]*:\/\/)([^/?#]+)(\/[^?#]*)?(\?[^#]*)?(#.*)?$/i.exec(e);
70
+ if (!t?.[2].includes(",")) return URL.canParse(e);
71
+ const [, n, r, i = "", s = "", u = ""] = t;
72
+ return r.split(",").every((l, c) => (l = l.trim(), !l || c > 0 && l.includes("@") ? !1 : URL.canParse(`${n}${l}${i}${s}${u}`)));
73
+ },
74
+ email(e) {
75
+ if (!a.string(e)) return !1;
76
+ const t = /^[-!#$%&'*+/0-9=?A-Z^_a-z`{|}~](\.?[-!#$%&'*+/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-?\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/, [n, r] = e.split("@");
77
+ return !n || !r || n.length > 64 || r.length > 255 || r.split(".").some((i) => i.length > 63) ? !1 : t.test(e);
78
+ },
79
+ regularExpression(e) {
80
+ return a.defined(e) && e instanceof RegExp;
81
+ },
82
+ number(e) {
83
+ return typeof e == "number" && !isNaN(e) && isFinite(e);
84
+ },
85
+ positive(e) {
86
+ return a.number(e) && e > 0;
87
+ },
88
+ nonPositive(e) {
89
+ return a.number(e) && e <= 0;
90
+ },
91
+ negative(e) {
92
+ return a.number(e) && e < 0;
93
+ },
94
+ nonNegative(e) {
95
+ return a.number(e) && e >= 0;
96
+ },
97
+ inRange(e, t, n) {
98
+ return o.that(n, (r) => r >= t, "max must be greater than or equal to min"), a.number(e) && e >= t && e <= n;
99
+ },
100
+ inRangeExclusive(e, t, n) {
101
+ return o.that(n, (r) => r > t, "max must be greater than min"), a.number(e) && e > t && e < n;
102
+ },
103
+ inRangeExclusiveMin(e, t, n) {
104
+ return o.that(n, (r) => r > t, "max must be greater than min"), a.number(e) && e > t && e <= n;
105
+ },
106
+ inRangeExclusiveMax(e, t, n) {
107
+ return o.that(n, (r) => r >= t, "max must be greater than or equal to min"), a.number(e) && e >= t && e < n;
108
+ },
109
+ integer(e) {
110
+ return a.number(e) && Number.isInteger(e);
111
+ },
112
+ positiveInteger(e) {
113
+ return a.integer(e) && a.positive(e);
114
+ },
115
+ nonPositiveInteger(e) {
116
+ return a.integer(e) && a.nonPositive(e);
117
+ },
118
+ negativeInteger(e) {
119
+ return a.integer(e) && a.negative(e);
120
+ },
121
+ nonNegativeInteger(e) {
122
+ return a.integer(e) && a.nonNegative(e);
123
+ },
124
+ array(e) {
125
+ return Array.isArray(e);
126
+ },
127
+ emptyArray(e) {
128
+ return a.array(e) && e.length === 0;
129
+ },
130
+ nonEmptyArray(e) {
131
+ return a.array(e) && e.length > 0;
132
+ },
133
+ arrayOfLength(e, t) {
134
+ return o.that(t, a.nonNegativeInteger, "length must be a non negative integer"), a.array(e) && e.length === t;
135
+ },
136
+ arrayOfLengthAtLeast(e, t) {
137
+ return o.that(t, a.nonNegativeInteger, "minLength must be a non negative integer"), a.array(e) && e.length >= t;
138
+ },
139
+ arrayOfLengthAtMost(e, t) {
140
+ return o.that(t, a.nonNegativeInteger, "maxLength must be a non negative integer"), a.array(e) && e.length <= t;
141
+ },
142
+ arrayOfLengthBetween(e, t, n) {
143
+ return o.all([
144
+ { value: t, validator: a.nonNegativeInteger, message: "minLength must be a non negative integer" },
145
+ { value: n, validator: a.nonNegativeInteger, message: "maxLength must be a non negative integer" },
146
+ { value: t, validator: (r) => r <= n, message: "minLength must be less than or equal to maxLength" }
147
+ ]), a.array(e) && e.length >= t && e.length <= n;
148
+ },
149
+ map(e) {
150
+ return a.defined(e) && e instanceof Map;
151
+ },
152
+ emptyMap(e) {
153
+ return a.map(e) && e.size === 0;
154
+ },
155
+ nonEmptyMap(e) {
156
+ return a.map(e) && e.size > 0;
157
+ },
158
+ set(e) {
159
+ return a.defined(e) && e instanceof Set;
160
+ },
161
+ emptySet(e) {
162
+ return a.set(e) && e.size === 0;
163
+ },
164
+ nonEmptySet(e) {
165
+ return a.set(e) && e.size > 0;
166
+ },
167
+ function(e) {
168
+ return typeof e == "function";
169
+ },
170
+ oneOf(e, t) {
171
+ return o.that(t, a.nonEmptyArray, "allowed values must be a non empty array"), t.includes(e);
172
+ },
173
+ empty(e) {
174
+ return a.nil(e) ? !0 : a.string(e) ? a.emptyString(e) : a.array(e) ? a.emptyArray(e) : a.plainObject(e) ? a.emptyObject(e) : a.map(e) ? a.emptyMap(e) : a.set(e) ? a.emptySet(e) : !1;
175
+ }
176
+ }, I = {
177
+ key(e, t) {
178
+ return o.all([
179
+ { value: e, validator: a.plainObject, message: "obj must be an object" },
180
+ { value: t, validator: a.nonEmptyString, message: "key must be a non empty string" }
181
+ ]), Object.hasOwn(e, t);
182
+ },
183
+ keys(e, t) {
184
+ return o.all([
185
+ { value: e, validator: a.plainObject, message: "obj must be an object" },
186
+ { value: t, validator: (n) => a.array(n) && n.length > 0 && n.every(a.nonEmptyString), message: "keys must be an array of non empty strings" }
187
+ ]), t.every((n) => I.key(e, n));
188
+ },
189
+ keyWithValue(e, t) {
190
+ return I.key(e, t) && a.defined(e[t]);
191
+ },
192
+ path(e, t) {
193
+ o.all([
194
+ { value: e, validator: a.plainObject, message: "obj must be an object" },
195
+ { value: t, validator: a.nonEmptyString, message: "path must be a non empty string" }
196
+ ]);
197
+ let n = e;
198
+ for (const r of t.split(".")) {
199
+ if (!n || !a.plainObject(n) || !(r in n)) return !1;
200
+ n = n[r];
201
+ }
202
+ return !0;
203
+ }
204
+ };
205
+ function se(e, t, n = "") {
206
+ return Object.entries(t).every(([r, i]) => {
207
+ const s = n ? `${n}.${r}` : r;
208
+ if (!I.key(e, r))
209
+ return i._optional === !0;
210
+ const u = e[r];
211
+ if (a.plainObject(i))
212
+ return a.plainObject(u) && se(u, i, s);
213
+ if (typeof i == "function")
214
+ return i(u);
215
+ throw new K(`Invalid validator for key "${s}"`);
216
+ });
217
+ }
218
+ const d = {
219
+ schema(e, t) {
220
+ return o.all([
221
+ { value: e, validator: a.plainObject, message: "obj must be an object" },
222
+ { value: t, validator: a.plainObject, message: "schema must be an object" }
223
+ ]), se(e, t);
224
+ }
225
+ };
226
+ function g(e) {
227
+ o.that(e, a.function, "validator must be a function");
228
+ function t(n) {
229
+ return a.nil(n) ? !0 : e(n);
230
+ }
231
+ return t._optional = !0, t;
232
+ }
233
+ const m = {
234
+ LATITUDE: "LAT",
235
+ LONGITUDE: "LON",
236
+ ALTITUDE: "ALT"
237
+ };
238
+ function oe(e) {
239
+ return o.that(e, a.string, "axis must be a string"), Object.values(m).includes(e);
240
+ }
241
+ function G(e) {
242
+ return o.that(e, a.string, "axis must be a string"), e === m.LATITUDE;
243
+ }
244
+ function q(e) {
245
+ return o.that(e, a.string, "axis must be a string"), e === m.LONGITUDE;
246
+ }
247
+ function Et(e) {
248
+ return o.that(e, a.string, "axis must be a string"), e === m.ALTITUDE;
249
+ }
250
+ const Ne = { NORTH: { label: "Nord", symbol: "N" }, SOUTH: { label: "Sud", symbol: "S" }, EAST: { label: "Est", symbol: "E" }, WEST: { label: "Ouest", symbol: "O" } }, Se = { INVALID_CONTENT: "Le contenu est invalide", EMPTY_OBJECT: "L'objet est vide", UNKNOWN_TYPE: "Le type de l'objet est inconnu", MISSING_GEOMETRY: "La géométrie est manquante", INVALID_FEATURES_ARRAY: "Le tableau de features est invalide", INVALID_GEOMETRY: "La géométrie est invalide", INVALID_GEOMETRY_TYPE: "Le type de géométrie est invalide", INVALID_COORDINATES_LENGTH: "Le nombre de coordonnées est invalide", INVALID_MULTI_LINESTRING_COORDINATES: "Les coordonnées du MultiLineString sont invalides", INVALID_POLYGON_COORDINATES: "Les coordonnées du Polygon sont invalides", INVALID_MULTIPOLYGON_COORDINATES: "Les coordonnées du MultiPolygon sont invalides", INVALID_GEOMETRYCOLLECTION_GEOMETRIES: "Les géométries de la GeometryCollection sont invalides", RING_NOT_CLOSED: "L'anneau n'est pas fermé", INVALID_WINDING_ORDER: "L'ordre d'orientation de l'anneau est invalide", SELF_INTERSECTION: "Une auto-intersection a été détectée", HOLE_INTERSECTS_SHELL: "Un trou intersecte le contour extérieur", ANTIMERIDIAN_CROSSING: "La géométrie traverse l'antiméridien", DUPLICATE_POSITION: "Une position consécutive est dupliquée", INVALID_POSITION_LENGTH: "Le nombre de coordonnées de la position est invalide", INVALID_POSITION_COORDINATES: "Les coordonnées de la position sont invalides", INVALID_LONGITUDE_RANGE: "La longitude est hors limites", INVALID_LATITUDE_RANGE: "La latitude est hors limites", INVALID_ALTITUDE: "L'altitude est invalide", EXCESSIVE_LONGITUDE_PRECISION: "La précision de la longitude est excessive", EXCESSIVE_LATITUDE_PRECISION: "La précision de la latitude est excessive", INVALID_BBOX_LENGTH: "Le nombre de coordonnées de la boîte englobante est invalide", INVALID_BBOX_LATITUDE_ORDER: "L'ordre des latitudes de la boîte englobante est invalide", INVALID_BBOX_LONGITUDE_ORDER: "L'ordre des longitudes de la boîte englobante est invalide", INVALID_BBOX_ALTITUDE_ORDER: "L'ordre des altitudes de la boîte englobante est invalide", BBOX_ANTIMERIDIAN_CROSSING: "La boîte englobante traverse l'antiméridien", INVALID_CRS_OBJECT: "L'objet CRS est invalide", INVALID_CRS_NAME: "Le nom du CRS est invalide", INVALID_CRS_LINK: "Le lien du CRS est invalide", INVALID_CRS_TYPE: "Le type de CRS est invalide", UNSUPPORTED_CRS: "Le CRS n'est pas pris en charge", UNSUPPORTED_LINK_CRS: "Le lien CRS n'est pas pris en charge", UNSUPPORTED_NESTED_CRS: "Le CRS imbriqué n'est pas pris en charge" }, De = {
251
+ DIRECTIONS: Ne,
252
+ VALIDATION: Se
253
+ }, Le = { NORTH: { label: "North", symbol: "N" }, SOUTH: { label: "South", symbol: "S" }, EAST: { label: "East", symbol: "E" }, WEST: { label: "West", symbol: "W" } }, Te = { INVALID_CONTENT: "Contant is invalid", EMPTY_OBJECT: "Object is empty", UNKNOWN_TYPE: "Unknown object type", MISSING_GEOMETRY: "Geometry is missing", INVALID_FEATURES_ARRAY: "Features array is invalid", INVALID_GEOMETRY: "Geometry is invalid", INVALID_GEOMETRY_TYPE: "Geometry type is invalid", INVALID_COORDINATES_LENGTH: "Coordinates length is invalid", INVALID_MULTI_LINESTRING_COORDINATES: "MultiLineString coordinates are invalid", INVALID_POLYGON_COORDINATES: "Polygon coordinates are invalid", INVALID_MULTIPOLYGON_COORDINATES: "MultiPolygon coordinates are invalid", INVALID_GEOMETRYCOLLECTION_GEOMETRIES: "GeometryCollection geometries are invalid", RING_NOT_CLOSED: "Ring is not closed", INVALID_WINDING_ORDER: "Ring winding order is invalid", SELF_INTERSECTION: "Self-intersection detected", HOLE_INTERSECTS_SHELL: "A hole intersects the exterior ring", ANTIMERIDIAN_CROSSING: "Geometry crosses the antimeridian", DUPLICATE_POSITION: "Consecutive position is duplicated", INVALID_POSITION_LENGTH: "Position length is invalid", INVALID_POSITION_COORDINATES: "Position coordinates are invalid", INVALID_LONGITUDE_RANGE: "Longitude is out of range", INVALID_LATITUDE_RANGE: "Latitude is out of range", INVALID_ALTITUDE: "Altitude is invalid", EXCESSIVE_LONGITUDE_PRECISION: "Longitude precision is excessive", EXCESSIVE_LATITUDE_PRECISION: "Latitude precision is excessive", INVALID_BBOX_LENGTH: "Bounding box length is invalid", INVALID_BBOX_LATITUDE_ORDER: "Bounding box latitude order is invalid", INVALID_BBOX_LONGITUDE_ORDER: "Bounding box longitude order is invalid", INVALID_BBOX_ALTITUDE_ORDER: "Bounding box altitude order is invalid", BBOX_ANTIMERIDIAN_CROSSING: "Bounding box crosses the antimeridian", INVALID_CRS_OBJECT: "CRS object is invalid", INVALID_CRS_NAME: "CRS name is invalid", INVALID_CRS_LINK: "CRS link is invalid", INVALID_CRS_TYPE: "CRS type is invalid", UNSUPPORTED_CRS: "CRS is not supported", UNSUPPORTED_LINK_CRS: "CRS link is not supported", UNSUPPORTED_NESTED_CRS: "Nested CRS is not supported" }, ye = {
254
+ DIRECTIONS: Le,
255
+ VALIDATION: Te
256
+ }, _e = {
257
+ DIRECTIONS: {
258
+ NORTH: { label: a.string, symbol: a.char },
259
+ SOUTH: { label: a.string, symbol: a.char },
260
+ EAST: { label: a.string, symbol: a.char },
261
+ WEST: { label: a.string, symbol: a.char }
262
+ }
263
+ }, S = {
264
+ en: ye,
265
+ fr: De
266
+ };
267
+ let R = "en";
268
+ const ee = "en";
269
+ function vt() {
270
+ return Object.keys(S);
271
+ }
272
+ function It(e) {
273
+ o.all([
274
+ { value: e, validator: a.string, message: "code must be a string" },
275
+ { value: e, validator: (t) => I.key(S, t), message: "code is unknown" }
276
+ ]), R = e;
277
+ }
278
+ function Ae() {
279
+ return R;
280
+ }
281
+ function ue() {
282
+ return R === ee ? [R] : [R, ee];
283
+ }
284
+ function bt(e, t) {
285
+ o.all([
286
+ { value: e, validator: a.string, message: "code must be a string" },
287
+ { value: e, validator: (n) => !I.key(S, n), message: "messages already registered" },
288
+ { value: t, validator: a.plainObject, message: "messages must be an object" },
289
+ { value: t, validator: (n) => d.schema(n, _e), message: "messages do not conform to schema" }
290
+ ]), S[e] = t;
291
+ }
292
+ function J(e) {
293
+ return o.all([
294
+ { value: e, validator: a.string, message: "code must be a string" },
295
+ { value: e, validator: (t) => I.key(S, t), message: "code is unknown" }
296
+ ]), S[e];
297
+ }
298
+ function M() {
299
+ return J(Ae()).DIRECTIONS;
300
+ }
301
+ function W(e) {
302
+ const t = /* @__PURE__ */ new Set();
303
+ for (const n of ue()) {
304
+ const { DIRECTIONS: r } = J(n);
305
+ for (const i of e) t.add(r[i].symbol);
306
+ }
307
+ return [...t];
308
+ }
309
+ function w(e, t) {
310
+ const n = t.toUpperCase();
311
+ return ue().some((r) => {
312
+ const { label: i, symbol: s } = J(r).DIRECTIONS[e];
313
+ return n === i.toUpperCase() || n === s.toUpperCase();
314
+ });
315
+ }
316
+ function ht(e = null) {
317
+ const t = M();
318
+ return a.defined(e) ? (o.that(e, oe, "axis must be a valid axis"), G(e) ? [t.SOUTH, t.NORTH] : q(e) ? [t.EAST, t.WEST] : []) : [t.SOUTH, t.NORTH, t.EAST, t.WEST];
319
+ }
320
+ function j(e = null) {
321
+ return a.defined(e) ? (o.that(e, oe, "axis must be a valid axis"), G(e) ? W(["NORTH", "SOUTH"]) : q(e) ? W(["EAST", "WEST"]) : []) : W(["NORTH", "SOUTH", "EAST", "WEST"]);
322
+ }
323
+ function Ot() {
324
+ return M().NORTH;
325
+ }
326
+ function Nt() {
327
+ return M().SOUTH;
328
+ }
329
+ function St() {
330
+ return M().EAST;
331
+ }
332
+ function Dt() {
333
+ return M().WEST;
334
+ }
335
+ function h(e) {
336
+ return o.that(e, a.string, "dir must be a string"), Re(e) || le(e) || Z(e) || k(e);
337
+ }
338
+ function Re(e) {
339
+ return o.that(e, a.string, "dir must be a string"), w("NORTH", e);
340
+ }
341
+ function le(e) {
342
+ return o.that(e, a.string, "dir must be a string"), w("SOUTH", e);
343
+ }
344
+ function Z(e) {
345
+ return o.that(e, a.string, "dir must be a string"), w("EAST", e);
346
+ }
347
+ function k(e) {
348
+ return o.that(e, a.string, "dir must be a string"), w("WEST", e);
349
+ }
350
+ function Ce(e) {
351
+ return o.that(e, h, "dir must be a direction"), k(e) || Z(e) ? m.LONGITUDE : m.LATITUDE;
352
+ }
353
+ const Me = {
354
+ degrees: a.number,
355
+ direction: g(h)
356
+ }, je = /^(-?\d{1,3}(?:\.\d+)?)°?$/;
357
+ function Ve() {
358
+ return new RegExp(`^(\\d{1,3}(?:\\.\\d+)?)°?([${j()}])$`, "i");
359
+ }
360
+ function V(e) {
361
+ let t = null, n = null;
362
+ if (a.plainObject(e) && d.schema(e, Me))
363
+ a.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, n = e.direction) : t = e.degrees;
364
+ else if (a.string(e)) {
365
+ const r = e.replace(/\s+/g, ""), i = r.match(je) ?? r.match(Ve());
366
+ i && (t = parseFloat(i[1]), n = i[2] ?? null);
367
+ }
368
+ return {
369
+ get degrees() {
370
+ return t;
371
+ },
372
+ get direction() {
373
+ return n;
374
+ },
375
+ get format() {
376
+ return "DD";
377
+ },
378
+ isValid() {
379
+ return a.number(t);
380
+ },
381
+ toString(r) {
382
+ if (o.that(r, a.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
383
+ let i = `${t.toFixed(r)}°`;
384
+ return n && (i += ` ${n}`), i;
385
+ },
386
+ toDecimal() {
387
+ return this.isValid() ? V({ degrees: t, direction: n }) : null;
388
+ }
389
+ };
390
+ }
391
+ const Ge = {
392
+ degrees: a.integer,
393
+ minutes: (e) => a.inRangeExclusiveMax(e, 0, 60),
394
+ direction: g(h)
395
+ }, Ue = /^(-?\d{1,3})°(\d{1,2}(?:\.\d+)?)'?$/;
396
+ function Pe() {
397
+ return new RegExp(`^(\\d{1,3})°(\\d{1,2}(?:\\.\\d+)?)'?([${j().join("")}])$`, "i");
398
+ }
399
+ function ce(e) {
400
+ let t = null, n = null, r = null;
401
+ if (a.plainObject(e) && d.schema(e, Ge))
402
+ a.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, n = e.minutes, r = e.direction) : (t = e.degrees, n = e.minutes);
403
+ else if (a.string(e)) {
404
+ const i = e.replace(/\s+/g, ""), s = i.match(Ue) ?? i.match(Pe());
405
+ s && (t = parseFloat(s[1]), n = parseFloat(s[2]), r = s[3] ?? null);
406
+ }
407
+ return {
408
+ get degrees() {
409
+ return t;
410
+ },
411
+ get minutes() {
412
+ return n;
413
+ },
414
+ get direction() {
415
+ return r;
416
+ },
417
+ get format() {
418
+ return "DDM";
419
+ },
420
+ isValid() {
421
+ return a.integer(t) && a.inRangeExclusiveMax(n, 0, 60);
422
+ },
423
+ toString(i) {
424
+ if (o.that(i, a.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
425
+ let s = `${t}° ${n.toFixed(i)}'`;
426
+ return r && (s += ` ${r}`), s;
427
+ },
428
+ toDecimal() {
429
+ return this.isValid() ? V({ degrees: t + n / 60, direction: r }) : null;
430
+ }
431
+ };
432
+ }
433
+ const xe = {
434
+ degrees: a.nonNegativeInteger,
435
+ minutes: (e) => a.inRangeExclusiveMax(e, 0, 60),
436
+ direction: h
437
+ };
438
+ function Be() {
439
+ return new RegExp(`^(\\d{2})(\\d{3})([${j(m.LATITUDE).join("")}])$`, "i");
440
+ }
441
+ function $e() {
442
+ return new RegExp(`^(\\d{3})(\\d{3})([${j(m.LONGITUDE).join("")}])$`, "i");
443
+ }
444
+ function me(e) {
445
+ let t = null, n = null, r = null;
446
+ if (a.plainObject(e) && d.schema(e, xe))
447
+ t = e.degrees, n = e.minutes, r = e.direction;
448
+ else if (a.string(e)) {
449
+ const i = e.trim(), s = i.match(Be()) ?? i.match($e());
450
+ s && (t = parseFloat(s[1]), n = parseFloat(s[2]) / 10, r = s[3]);
451
+ }
452
+ return {
453
+ get degrees() {
454
+ return t;
455
+ },
456
+ get minutes() {
457
+ return n;
458
+ },
459
+ get direction() {
460
+ return r;
461
+ },
462
+ get format() {
463
+ return "DDM_AERO";
464
+ },
465
+ isValid() {
466
+ return a.nonNegativeInteger(t) && a.inRangeExclusiveMax(n, 0, 60) && h(r);
467
+ },
468
+ toString() {
469
+ if (!this.isValid()) return "";
470
+ const i = Z(r) || k(r), s = String(t).padStart(i ? 3 : 2, "0"), u = Math.floor(n * 10).toString().padStart(3, "0");
471
+ return `${s}${u}${r}`;
472
+ },
473
+ toDecimal() {
474
+ return this.isValid() ? V({ degrees: t + n / 60, direction: r }) : null;
475
+ }
476
+ };
477
+ }
478
+ const we = {
479
+ degrees: a.integer,
480
+ minutes: (e) => a.integer(e) && a.inRange(e, 0, 59),
481
+ seconds: (e) => a.inRangeExclusiveMax(e, 0, 60),
482
+ direction: g(h)
483
+ }, ke = /^(-?\d{1,3})°(\d{1,2})'(\d{1,2}(?:\.\d+)?)"?$/;
484
+ function He() {
485
+ return new RegExp(`^(\\d{1,3})°(\\d{1,2})'(\\d{1,2}(?:\\.\\d+)?)"?([${j().join("")}])$`, "i");
486
+ }
487
+ function ge(e) {
488
+ let t = null, n = null, r = null, i = null;
489
+ if (a.plainObject(e) && d.schema(e, we))
490
+ a.defined(e.direction) ? e.degrees >= 0 && (t = e.degrees, n = e.minutes, r = e.seconds, i = e.direction) : (t = e.degrees, n = e.minutes, r = e.seconds);
491
+ else if (a.string(e)) {
492
+ const s = e.replace(/\s+/g, ""), u = s.match(ke) ?? s.match(He());
493
+ u && (t = parseFloat(u[1]), n = parseFloat(u[2]), r = parseFloat(u[3]), i = u[4] ?? null);
494
+ }
495
+ return {
496
+ get degrees() {
497
+ return t;
498
+ },
499
+ get minutes() {
500
+ return n;
501
+ },
502
+ get seconds() {
503
+ return r;
504
+ },
505
+ get direction() {
506
+ return i;
507
+ },
508
+ get format() {
509
+ return "DMS";
510
+ },
511
+ isValid() {
512
+ return a.integer(t) && a.integer(n) && a.inRange(n, 0, 59) && a.inRangeExclusiveMax(r, 0, 60);
513
+ },
514
+ toString(s) {
515
+ if (o.that(s, a.positiveInteger, "decimalPlaces must be a positive integer"), !this.isValid()) return "";
516
+ let u = `${t}° ${n}' ${r.toFixed(s)}"`;
517
+ return i && (u += ` ${i}`), u;
518
+ },
519
+ toDecimal() {
520
+ return this.isValid() ? V({ degrees: t + n / 60 + r / 3600, direction: i }) : null;
521
+ }
522
+ };
523
+ }
524
+ function te(e) {
525
+ const t = Math.floor(e.degrees), n = (e.degrees - t) * 60;
526
+ return { degrees: t, minutes: n, direction: e.direction };
527
+ }
528
+ function ze(e) {
529
+ const t = Math.floor(e.degrees), n = (e.degrees - t) * 60, r = Math.floor(n), i = (n - r) * 60;
530
+ return { degrees: t, minutes: r, seconds: i, direction: e.direction };
531
+ }
532
+ const ne = {
533
+ DD: (e) => (o.that(e, (t) => t.isValid(), "dd must be a valid coordinate"), e),
534
+ DDM: (e) => {
535
+ o.that(e, (i) => i.isValid(), "dd must be a valid coordinate");
536
+ const { degrees: t, minutes: n, direction: r } = te(e);
537
+ return ce(r ? { degrees: t, minutes: n, direction: r } : { degrees: t, minutes: n });
538
+ },
539
+ DMS: (e) => {
540
+ o.that(e, (s) => s.isValid(), "dd must be a valid coordinate");
541
+ const { degrees: t, minutes: n, seconds: r, direction: i } = ze(e);
542
+ return ge(i ? { degrees: t, minutes: n, seconds: r, direction: i } : { degrees: t, minutes: n, seconds: r });
543
+ },
544
+ DDM_AERO: (e) => {
545
+ o.that(e, (i) => i.isValid(), "dd must be a valid coordinate");
546
+ const { degrees: t, minutes: n, direction: r } = te(e);
547
+ return me({ degrees: t, minutes: n, direction: r });
548
+ }
549
+ }, F = {
550
+ DD: "DD",
551
+ DDM: "DDM",
552
+ DDM_AERO: "DDM_AERO",
553
+ DMS: "DMS"
554
+ }, We = {
555
+ DD: V,
556
+ DDM: ce,
557
+ DDM_AERO: me,
558
+ DMS: ge
559
+ }, L = 7, b = 8, Fe = Array.from({ length: b + 1 }, (e, t) => 10 ** t);
560
+ function ae(e, t) {
561
+ if (o.that(e, a.number, "coord must be a number"), a.defined(t))
562
+ return o.that(t, h, "dir must be a direction"), Ce(t);
563
+ if (Math.abs(e) > 90) return m.LONGITUDE;
564
+ }
565
+ function Lt(e) {
566
+ o.that(e, a.number, "coord must be a number");
567
+ const t = e.toExponential(), [n, r] = t.split("e").map(Number), i = (n.toString().split(".")[1] || "").length;
568
+ return Math.max(0, i - r);
569
+ }
570
+ function de(e, t = L) {
571
+ o.all([
572
+ {
573
+ value: e,
574
+ validator: a.number,
575
+ message: "coord must be a number"
576
+ },
577
+ {
578
+ value: t,
579
+ validator: (r) => a.inRange(r, 0, b),
580
+ message: `precision must be in range [0, ${b}]`
581
+ }
582
+ ]);
583
+ const n = Fe[t];
584
+ return Math.round(e * n) / n;
585
+ }
586
+ function Tt(e, t) {
587
+ if (o.all([
588
+ { value: e, validator: a.number, message: "coord must be a number" },
589
+ { value: t, validator: (r) => q(r) || G(r), message: "axis must be either a longitude or latitude" }
590
+ ]), G(t))
591
+ return Math.max(-90, Math.min(90, e));
592
+ let n = ((e + 180) % 360 + 360) % 360 - 180;
593
+ return n === -180 && (n = 180), Object.is(n, -0) && (n = 0), n;
594
+ }
595
+ function yt(e, t) {
596
+ o.all([
597
+ { value: e, validator: (r) => a.defined(r) && r.isValid(), message: "from must be a valid coordinate" },
598
+ { value: t, validator: (r) => I.key(ne, r), message: `unknown format: ${t}` }
599
+ ]);
600
+ const n = e.format === F.DD ? e : e.toDecimal();
601
+ return n.isValid() ? t === F.DD ? n : ne[t](n) : null;
602
+ }
603
+ function Ye(e) {
604
+ o.that(e, a.nonEmptyString, "pattern must be a non empty string");
605
+ for (const t of Object.keys(F)) {
606
+ const n = We[t](e);
607
+ if (n.isValid()) return n;
608
+ }
609
+ return null;
610
+ }
611
+ const _t = {
612
+ node: typeof process < "u" && process.versions?.node != null,
613
+ worker: typeof WorkerGlobalScope < "u" && self instanceof WorkerGlobalScope,
614
+ serviceWorker: typeof ServiceWorkerGlobalScope < "u" && self instanceof ServiceWorkerGlobalScope,
615
+ test: typeof process < "u" && process.env.NODE_ENV === "test",
616
+ dev: typeof process < "u" && process.env.NODE_ENV === "development",
617
+ prod: typeof process < "u" && process.env.NODE_ENV === "production"
618
+ }, fe = {
619
+ ignoreSpaces: g(a.boolean),
620
+ ignoreDiacritics: g(a.boolean),
621
+ ignoreCase: g(a.boolean),
622
+ locale: g(a.string)
623
+ }, Xe = {
624
+ ...fe
625
+ };
626
+ function O(e, t, n) {
627
+ return f.words(e).map((r, i) => t(f.normalize(r, { ignoreDiacritics: !0 }), i)).join(n);
628
+ }
629
+ const f = {
630
+ DIACRITICS: {
631
+ a: "aáàäâã",
632
+ e: "eéëèê",
633
+ i: "iíïìî",
634
+ o: "oóöòõô",
635
+ u: "uüúùû",
636
+ c: "cç"
637
+ },
638
+ normalize(e, t = {}) {
639
+ o.all([
640
+ { value: e, validator: a.string, message: "str must be a string" },
641
+ { value: t, validator: (l) => d.schema(l, fe) }
642
+ ]);
643
+ const {
644
+ ignoreSpaces: n = !1,
645
+ ignoreDiacritics: r = !1,
646
+ ignoreCase: i = !1,
647
+ locale: s = void 0
648
+ // 'fr-FR'
649
+ } = t;
650
+ let u = e;
651
+ return n && (u = u.replace(/\s+/g, " ").trim()), r && (u = u.normalize("NFKD").replace(new RegExp("\\p{M}", "gu"), "")), i && (u = u.toLocaleLowerCase(s)), u;
652
+ },
653
+ compare(e, t, n = {}) {
654
+ o.all([
655
+ { value: e, validator: a.string, message: "str1 must be a string" },
656
+ { value: t, validator: a.string, message: "str2 must be a string" },
657
+ { value: n, validator: (u) => d.schema(u, Xe) }
658
+ ]);
659
+ const r = { ignoreDiacritics: !0, ignoreCase: !0, ...n }, i = f.normalize(e, r), s = f.normalize(t, r);
660
+ return i.localeCompare(s, n.locale);
661
+ },
662
+ makeDiacriticPattern(e, t = {}) {
663
+ o.that(e, a.string, "pattern must be a string");
664
+ const { reverse: n = !1 } = t ?? {};
665
+ let r = "";
666
+ for (const i of e) {
667
+ const s = i.toLowerCase();
668
+ let u = null;
669
+ for (const l of Object.values(this.DIACRITICS))
670
+ if (n && l.includes(s) || !n && l.startsWith(s)) {
671
+ u = l;
672
+ break;
673
+ }
674
+ u ? r += `[${u}]` : r += i;
675
+ }
676
+ return r;
677
+ },
678
+ initials(e, t = {}) {
679
+ o.that(e, a.string, "str must be a string");
680
+ const { max: n = void 0 } = t, r = e.trim().split(/[\s-]+/).filter(Boolean).map((i) => i[0].toUpperCase());
681
+ return (n ? r.slice(0, n) : r).join("");
682
+ },
683
+ words(e) {
684
+ return o.that(e, a.string, "str must be a string"), e.match(new RegExp("\\p{Lu}+(?=\\p{Lu}\\p{Ll})|\\p{Lu}?\\p{Ll}+|\\p{Lu}+|\\p{Nd}+", "gu")) ?? [];
685
+ },
686
+ slugify(e, t = "-") {
687
+ return o.all([
688
+ { value: e, validator: a.string, message: "str must be a string" },
689
+ { value: t, validator: a.char, message: "separator must be a char" }
690
+ ]), f.normalize(e.trim(), { ignoreDiacritics: !0 }).toLowerCase().replace(/[^a-z0-9]+/gi, t).replace(new RegExp(`^${t}|${t}$`, "g"), "");
691
+ },
692
+ capitalize(e) {
693
+ return o.that(e, a.string, "str must be a string"), e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
694
+ },
695
+ camelCase(e) {
696
+ return o.that(e, a.string, "str must be a string"), O(e, (t, n) => n === 0 ? t.toLowerCase() : f.capitalize(t), "");
697
+ },
698
+ pascalCase(e) {
699
+ return o.that(e, a.string, "str must be a string"), O(e, (t) => f.capitalize(t), "");
700
+ },
701
+ kebabCase(e) {
702
+ return o.that(e, a.string, "str must be a string"), O(e, (t) => t.toLowerCase(), "-");
703
+ },
704
+ snakeCase(e) {
705
+ return o.that(e, a.string, "str must be a string"), O(e, (t) => t.toLowerCase(), "_");
706
+ },
707
+ constantCase(e) {
708
+ return o.that(e, a.string, "str must be a string"), O(e, (t) => t.toUpperCase(), "_");
709
+ },
710
+ dotCase(e) {
711
+ return o.that(e, a.string, "str must be a string"), O(e, (t) => t.toLowerCase(), ".");
712
+ },
713
+ titleCase(e) {
714
+ return o.that(e, a.string, "str must be a string"), f.words(e).map((t) => f.capitalize(t)).join(" ");
715
+ }
716
+ }, Y = {
717
+ ignoreSpaces: g(a.boolean),
718
+ ignoreDiacritics: g(a.boolean),
719
+ ignoreCase: g(a.boolean),
720
+ locale: g(a.string)
721
+ }, Ke = {
722
+ ...Y,
723
+ ignoredKeys: g(a.array)
724
+ };
725
+ function X(e, t = {}) {
726
+ if (!a.defined(e)) return e;
727
+ const n = t?.ignoredKeys ?? [], r = { ignoreDiacritics: !1, ignoreCase: !1, locale: t.locale };
728
+ return a.array(e) ? e.map((i) => X(i, t)).sort(
729
+ (i, s) => f.compare(JSON.stringify(i), JSON.stringify(s), r)
730
+ ) : a.plainObject(e) ? Object.fromEntries(
731
+ Object.entries(e).filter(([i]) => !n.includes(i)).sort(([i], [s]) => f.compare(i, s, r)).map(([i, s]) => [
732
+ i,
733
+ X(s, t)
734
+ ])
735
+ ) : a.string(e) ? f.normalize(e, t) : e;
736
+ }
737
+ const At = {
738
+ clone(e) {
739
+ return o.that(e, a.defined, "obj must be defined"), structuredClone(e);
740
+ },
741
+ normalize(e, t = {}) {
742
+ return o.all([
743
+ { value: e, validator: (n) => a.array(n) || a.plainObject(n), message: "obj must be an array or a plain object" },
744
+ { value: t, validator: (n) => d.schema(n, Ke) }
745
+ ]), X(e, t);
746
+ },
747
+ reorder(e, t, n = {}) {
748
+ o.all([
749
+ { value: e, validator: a.plainObject, message: "obj must be a plain object" },
750
+ { value: t, validator: a.string, message: "property must be a string" },
751
+ { value: n, validator: (i) => d.schema(i, Y) }
752
+ ]);
753
+ const r = (i, s) => f.compare(i[t], s[t], n);
754
+ return Object.fromEntries(
755
+ Object.entries(e).sort(([, i], [, s]) => r(i, s))
756
+ );
757
+ },
758
+ lookup(e, t) {
759
+ return o.all([
760
+ { value: e, validator: a.defined, message: "obj must be defined" },
761
+ { value: t, validator: a.nonEmptyString, message: "path must be a non empty string" }
762
+ ]), t.split(".").reduce((n, r) => n?.[r], e);
763
+ },
764
+ dotify(e) {
765
+ o.that(e, a.plainObject, "obj must be a plain object");
766
+ const t = {};
767
+ function n(r, i) {
768
+ for (const [s, u] of Object.entries(r)) {
769
+ const l = i ? `${i}.${s}` : s;
770
+ a.nonEmptyObject(u) ? n(u, l) : t[l] = u;
771
+ }
772
+ }
773
+ return n(e), t;
774
+ },
775
+ sort(e, t, n = {}) {
776
+ return o.all([
777
+ { value: e, validator: a.array, message: "arr must be an array" },
778
+ { value: t, validator: a.string, message: "property must be a string" },
779
+ { value: n, validator: (r) => d.schema(r, Y) }
780
+ ]), [...e].sort((r, i) => f.compare(r[t], i[t], n));
781
+ }
782
+ }, p = {
783
+ clamp(e, t, n) {
784
+ return o.all([
785
+ { value: e, validator: a.number, message: "value must be a number" },
786
+ { value: t, validator: a.number, message: "min must be a number" },
787
+ { value: n, validator: a.number, message: "max must be a number" }
788
+ ]), Math.min(Math.max(e, t), n);
789
+ },
790
+ round(e, t = 2) {
791
+ o.all([
792
+ { value: e, validator: a.number, message: "value must be a number" },
793
+ { value: t, validator: a.nonNegativeInteger, message: "precision must be a non-negative integer" }
794
+ ]);
795
+ const n = 10 ** t;
796
+ return Math.round(e * n) / n;
797
+ },
798
+ sign(e, t = 0) {
799
+ return o.all([
800
+ { value: e, validator: a.number, message: "value must be a number" },
801
+ { value: t, validator: a.nonNegative, message: "epsilon must be a non-negative number" }
802
+ ]), e > t ? 1 : e < -t ? -1 : 0;
803
+ },
804
+ percentage(e, t) {
805
+ return o.all([
806
+ { value: e, validator: a.number, message: "value must be a number" },
807
+ { value: t, validator: a.number, message: "total must be a number" }
808
+ ]), p.round(e / t * 100, 2);
809
+ },
810
+ exponential(e, t = 2) {
811
+ if (o.all([
812
+ { value: e, validator: a.number, message: "value must be a number" },
813
+ { value: t, validator: a.nonNegativeInteger, message: "decimals must be a non-negative integer" }
814
+ ]), e === 0) return `0.${"0".repeat(t)}e+0`;
815
+ const n = Math.floor(Math.log10(Math.abs(e)));
816
+ return `${(e / Math.pow(10, n)).toFixed(t)}e${n >= 0 ? "+" : ""}${n}`;
817
+ },
818
+ linear(e, t = 0, n = 1) {
819
+ return o.all([
820
+ { value: e, validator: (r) => a.inRange(r, 0, 1), message: "t must be in range [0, 1]" },
821
+ { value: t, validator: a.number, message: "initial must be a number" },
822
+ { value: n, validator: a.number, message: "final must be a number" }
823
+ ]), t + e * (n - t);
824
+ },
825
+ to: {
826
+ radians(e) {
827
+ return o.that(e, a.number, "degrees must be a number"), e * Math.PI / 180;
828
+ },
829
+ degrees(e) {
830
+ return o.that(e, a.number, "radians must be a number"), e * 180 / Math.PI;
831
+ }
832
+ },
833
+ pow: {
834
+ square(e) {
835
+ return o.that(e, a.number, "value must be a number"), e * e;
836
+ },
837
+ cube(e) {
838
+ return o.that(e, a.number, "value must be a number"), p.pow.square(e) * e;
839
+ }
840
+ },
841
+ ease: {
842
+ in(e, t = 0.5) {
843
+ return o.all([
844
+ { value: e, validator: (n) => a.inRange(n, 0, 1), message: "t must be in range [0, 1]" },
845
+ { value: t, validator: a.number, message: "linearity must be a number" }
846
+ ]), Math.pow(e, 1 / t);
847
+ },
848
+ out(e, t = 0.5) {
849
+ return o.all([
850
+ { value: e, validator: (n) => a.inRange(n, 0, 1), message: "t must be in range [0, 1]" },
851
+ { value: t, validator: a.number, message: "linearity must be a number" }
852
+ ]), 1 - Math.pow(1 - e, 1 / t);
853
+ },
854
+ cubicBezier(e, t = 0.42, n = 0, r = 0.58, i = 1) {
855
+ o.that(e, (c) => a.inRange(c, 0, 1), "t must be in range [0, 1]");
856
+ const s = 1 - e, u = e * e, l = s * s;
857
+ return l * s * n + 3 * l * e * t + 3 * s * u * r + u * e * i;
858
+ }
859
+ },
860
+ stats: {
861
+ sum(e) {
862
+ return o.that(e, a.array, "values must be an array"), e.reduce((t, n) => t + n, 0);
863
+ },
864
+ average(e) {
865
+ return o.that(e, a.nonEmptyArray, "values must be a non-empty array"), p.stats.sum(e) / e.length;
866
+ },
867
+ median(e) {
868
+ o.that(e, a.nonEmptyArray, "values must be a non-empty array");
869
+ const t = [...e].sort((r, i) => r - i), n = Math.floor(t.length / 2);
870
+ return t.length % 2 === 0 ? p.linear(0.5, t[n - 1], t[n]) : t[n];
871
+ }
872
+ }
873
+ }, U = p.to.radians(1), qe = 1e-12;
874
+ function D(e) {
875
+ const t = e[0] * U, n = e[1] * U, r = Math.cos(n);
876
+ return [r * Math.cos(t), r * Math.sin(t), Math.sin(n)];
877
+ }
878
+ function Je(e) {
879
+ const t = Math.atan2(e[1], e[0]), n = Math.asin(e[2]);
880
+ return [t / U, n / U];
881
+ }
882
+ function A(e, t) {
883
+ return e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
884
+ }
885
+ function C(e, t) {
886
+ return [
887
+ e[1] * t[2] - e[2] * t[1],
888
+ e[2] * t[0] - e[0] * t[2],
889
+ e[0] * t[1] - e[1] * t[0]
890
+ ];
891
+ }
892
+ function pe(e, t) {
893
+ return [e[0] + t[0], e[1] + t[1], e[2] + t[2]];
894
+ }
895
+ function P(e, t) {
896
+ return [e[0] * t, e[1] * t, e[2] * t];
897
+ }
898
+ function x(e) {
899
+ return Math.sqrt(e[0] * e[0] + e[1] * e[1] + e[2] * e[2]);
900
+ }
901
+ function Ze(e) {
902
+ const t = x(e);
903
+ return [e[0] / t, e[1] / t, e[2] / t];
904
+ }
905
+ function Qe(e, t) {
906
+ return Math.atan2(x(C(e, t)), A(e, t));
907
+ }
908
+ function et(e) {
909
+ return C(e, Ee(e));
910
+ }
911
+ function Ee(e) {
912
+ return Ze(C([0, 0, 1], e));
913
+ }
914
+ function tt(e, t) {
915
+ const n = et(e), r = Ee(e);
916
+ return pe(
917
+ P(n, Math.cos(t)),
918
+ P(r, Math.sin(t))
919
+ );
920
+ }
921
+ function nt(e, t, n) {
922
+ const r = tt(e, t);
923
+ return pe(
924
+ P(e, Math.cos(n)),
925
+ P(r, Math.sin(n))
926
+ );
927
+ }
928
+ function ve(e, t, n, r, i = qe) {
929
+ const s = C(e, t), u = C(n, r), l = x(s), c = x(u);
930
+ if (l <= i || c <= i) return !1;
931
+ const T = p.sign(A(s, n) / l, i), y = p.sign(A(s, r) / l, i);
932
+ if (T * y !== -1) return !1;
933
+ const _ = p.sign(A(u, e) / c, i), Oe = p.sign(A(u, t) / c, i);
934
+ return _ * Oe === -1;
935
+ }
936
+ const Rt = "WGS84", N = "+proj=longlat +datum=WGS84 +no_defs", at = {
937
+ WGS84: N,
938
+ "CRS:84": N,
939
+ CRS84: N,
940
+ "urn:ogc:def:crs:OGC:1.3:CRS84": N,
941
+ "urn:ogc:def:crs:OGC:2:84": N,
942
+ "urn:ogc:def:crs:EPSG::4326": N,
943
+ "EPSG:2154": "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +units=m +no_defs"
944
+ };
945
+ for (const [e, t] of Object.entries(at))
946
+ v.defs(e) || v.defs(e, t);
947
+ const rt = /^urn:ogc:def:crs:EPSG::(\d+)$/i;
948
+ function Ct(e) {
949
+ o.that(e, a.nonEmptyString, "name must be a non empty string");
950
+ const t = e.match(rt);
951
+ return t ? `EPSG:${t[1]}` : e;
952
+ }
953
+ function Mt(e) {
954
+ o.that(e, a.nonEmptyString, "name must be a non empty string");
955
+ const t = e.match(/^EPSG:(\d+)$/i);
956
+ return t ? `urn:ogc:def:crs:EPSG::${t[1]}` : e;
957
+ }
958
+ function jt() {
959
+ return Object.keys(v.defs);
960
+ }
961
+ function Vt(e, t) {
962
+ o.all([
963
+ {
964
+ value: e,
965
+ validator: a.nonEmptyString,
966
+ message: "name must be a non empty string"
967
+ },
968
+ {
969
+ value: t,
970
+ validator: (n) => a.nonEmptyString(n) || a.nonEmptyObject(n),
971
+ message: "definition must be a non empty string or a non empty object"
972
+ }
973
+ ]), v.defs(e, t);
974
+ }
975
+ function re(e) {
976
+ return o.that(e, a.nonEmptyString, "name must be a non empty string"), a.defined(v.defs(e));
977
+ }
978
+ function Gt(e) {
979
+ return o.that(e, a.nonEmptyString, "name must be a non empty string"), v.defs(e);
980
+ }
981
+ function Ut(e) {
982
+ o.that(e, a.nonEmptyString, "name must be a non empty string");
983
+ const t = v.defs(e);
984
+ if (!t) return !1;
985
+ const n = v.defs("EPSG:4326");
986
+ return t.projName === n.projName && t.datumCode === n.datumCode;
987
+ }
988
+ const H = {
989
+ precision: g(a.number),
990
+ consider3D: g(a.boolean)
991
+ }, Ie = 63710088e-1;
992
+ function Pt(e) {
993
+ o.that(e, (T) => a.nonEmptyString(T), "pattern must be a non-empty string");
994
+ const t = e.split(/[,;|]/);
995
+ if (t.length !== 2) return null;
996
+ const [n, r] = t.map(Ye);
997
+ if (!n || !r) return null;
998
+ const i = n.toDecimal(), s = r.toDecimal(), u = ae(i.degrees, i.direction), l = ae(s.degrees, s.direction), c = (T) => {
999
+ const { degrees: y, direction: _ } = T;
1000
+ return _ && (k(_) || le(_)) ? -y : y;
1001
+ };
1002
+ return u === m.LONGITUDE && l === m.LATITUDE ? [c(i), c(s)] : l === m.LONGITUDE && u === m.LATITUDE ? [c(s), c(i)] : u === m.LONGITUDE && !l ? [c(i), c(s)] : u === m.LATITUDE && !l ? [c(s), c(i)] : l === m.LONGITUDE && !u ? [c(s), c(i)] : l === m.LATITUDE && !u ? [c(i), c(s)] : !u && !l ? [
1003
+ [c(i), c(s)],
1004
+ [c(s), c(i)]
1005
+ ] : null;
1006
+ }
1007
+ function E(e) {
1008
+ return a.arrayOfLengthBetween(e, 2, 3) ? e.every(a.number) : !1;
1009
+ }
1010
+ function it(e) {
1011
+ return o.that(e, E, "position must be a valid position"), a.arrayOfLength(e, 3);
1012
+ }
1013
+ function be(e, t, n = {}) {
1014
+ o.all([
1015
+ {
1016
+ value: e,
1017
+ validator: E,
1018
+ message: "position1 must be a valid position"
1019
+ },
1020
+ {
1021
+ value: t,
1022
+ validator: E,
1023
+ message: "position2 must be a valid position"
1024
+ },
1025
+ {
1026
+ value: n,
1027
+ validator: (u) => d.schema(u, H),
1028
+ message: "options must be a valid options object"
1029
+ }
1030
+ ]);
1031
+ const { precision: r = L, consider3D: i = !1 } = n, s = i ? Math.max(e.length, t.length) : 2;
1032
+ return Array.from(
1033
+ { length: s },
1034
+ (u, l) => (e[l] ?? 0).toFixed(r) === (t[l] ?? 0).toFixed(r)
1035
+ ).every(Boolean);
1036
+ }
1037
+ function st(e, t = L) {
1038
+ o.all([
1039
+ {
1040
+ value: e,
1041
+ validator: E,
1042
+ message: "position must be a position"
1043
+ },
1044
+ {
1045
+ value: t,
1046
+ validator: (n) => a.inRange(n, 0, b),
1047
+ message: `precision must be in range [0, ${b}]`
1048
+ }
1049
+ ]);
1050
+ for (let n = 0; n < e.length; n++)
1051
+ e[n] = de(e[n], t);
1052
+ return e;
1053
+ }
1054
+ function ot(e, t, n) {
1055
+ return o.all([
1056
+ {
1057
+ value: e,
1058
+ validator: E,
1059
+ message: "position must be a valid position"
1060
+ },
1061
+ {
1062
+ value: t,
1063
+ validator: re,
1064
+ message: `unknown source projection: ${t}`
1065
+ },
1066
+ {
1067
+ value: n,
1068
+ validator: re,
1069
+ message: `unknown target projection: ${n}`
1070
+ }
1071
+ ]), v(t, n, e);
1072
+ }
1073
+ function xt(e, t, n) {
1074
+ o.all([
1075
+ { value: e, validator: E, message: "position must be a valid position" },
1076
+ { value: t, validator: a.number, message: "bearing must be a number" },
1077
+ { value: n, validator: a.number, message: "distance must be a number" }
1078
+ ]);
1079
+ const r = nt(
1080
+ D(e),
1081
+ p.to.radians(t),
1082
+ n / Ie
1083
+ );
1084
+ return Je(r);
1085
+ }
1086
+ function Bt(e, t) {
1087
+ return o.all([
1088
+ { value: e, validator: E, message: "position1 must be a valid position" },
1089
+ { value: t, validator: E, message: "position2 must be a valid position" }
1090
+ ]), Qe(D(e), D(t)) * Ie;
1091
+ }
1092
+ function B(e) {
1093
+ if (!a.arrayOfLength(e, 4) && !a.arrayOfLength(e, 6)) return !1;
1094
+ const t = e.length === 4, n = t ? [e[0], e[1]] : [e[0], e[1], e[2]], r = t ? [e[2], e[3]] : [e[3], e[4], e[5]];
1095
+ if (!E(n) || !E(r)) return !1;
1096
+ const [, i] = n, [, s] = r;
1097
+ return !(i > s || !t && e[2] > e[5]);
1098
+ }
1099
+ function ie(e) {
1100
+ return o.that(e, B, "bbox must be a valid bounding-box"), a.arrayOfLength(e, 6);
1101
+ }
1102
+ function $t(e, t) {
1103
+ return o.all([
1104
+ { value: e, validator: B, message: "bbox1 must be a valid bounding-box" },
1105
+ { value: t, validator: B, message: "bbox2 must be a valid bounding-box" }
1106
+ ]), ie(e) && ie(t) ? [
1107
+ Math.min(e[0], t[0]),
1108
+ Math.min(e[1], t[1]),
1109
+ Math.min(e[2], t[2]),
1110
+ Math.max(e[3], t[3]),
1111
+ Math.max(e[4], t[4]),
1112
+ Math.max(e[5], t[5])
1113
+ ] : [
1114
+ Math.min(e[0], t[0]),
1115
+ Math.min(e[1], t[1]),
1116
+ Math.max(e[2], t[2]),
1117
+ Math.max(e[3], t[3])
1118
+ ];
1119
+ }
1120
+ const ut = {
1121
+ ignore3D: g(a.boolean)
1122
+ };
1123
+ function wt(e, t = {}) {
1124
+ o.all([
1125
+ {
1126
+ value: e,
1127
+ validator: a.nonEmptyArray,
1128
+ message: "positions must be a non-empty array"
1129
+ },
1130
+ {
1131
+ value: e,
1132
+ validator: (i) => i.every(E),
1133
+ message: "positions must be an array of valid positions"
1134
+ },
1135
+ {
1136
+ value: t,
1137
+ validator: (i) => d.schema(i, ut),
1138
+ message: "options must be a valid options object"
1139
+ }
1140
+ ]);
1141
+ const { ignore3D: n = !1 } = t;
1142
+ return !n && e.some(it) ? e.reduce((i, s) => [
1143
+ Math.min(i[0], s[0]),
1144
+ Math.min(i[1], s[1]),
1145
+ Math.min(i[2], s[2] ?? 0),
1146
+ Math.max(i[3], s[0]),
1147
+ Math.max(i[4], s[1]),
1148
+ Math.max(i[5], s[2] ?? 0)
1149
+ ], [1 / 0, 1 / 0, 1 / 0, -1 / 0, -1 / 0, -1 / 0]) : e.reduce((i, s) => [
1150
+ Math.min(i[0], s[0]),
1151
+ Math.min(i[1], s[1]),
1152
+ Math.max(i[2], s[0]),
1153
+ Math.max(i[3], s[1])
1154
+ ], [1 / 0, 1 / 0, -1 / 0, -1 / 0]);
1155
+ }
1156
+ function kt(e, t = L) {
1157
+ o.all([
1158
+ {
1159
+ value: e,
1160
+ validator: B,
1161
+ message: "bbox must be a valid bounding box"
1162
+ },
1163
+ {
1164
+ value: t,
1165
+ validator: (n) => a.inRange(n, 0, b),
1166
+ message: `precision must be in range [0, ${b}]`
1167
+ }
1168
+ ]);
1169
+ for (let n = 0; n < e.length; n++)
1170
+ e[n] = de(e[n], t);
1171
+ return e;
1172
+ }
1173
+ const lt = {
1174
+ ...H,
1175
+ deduplicate: g(a.boolean)
1176
+ };
1177
+ function ct(e) {
1178
+ return a.array(e) && e.every(E);
1179
+ }
1180
+ function mt(e, t = {}) {
1181
+ o.that(t, (s) => d.schema(s, H), "options must be a valid options object");
1182
+ const { precision: n = L, consider3D: r = !1 } = t, i = [];
1183
+ for (const s of e) {
1184
+ const u = i[i.length - 1];
1185
+ (!u || !be(s, u, { precision: n, consider3D: r })) && i.push(s);
1186
+ }
1187
+ return i;
1188
+ }
1189
+ function gt(e, t = {}) {
1190
+ o.all([
1191
+ {
1192
+ value: e,
1193
+ validator: a.array,
1194
+ message: "positions must be an array"
1195
+ },
1196
+ {
1197
+ value: t,
1198
+ validator: (u) => d.schema(u, lt),
1199
+ message: "options must be a valid options object"
1200
+ }
1201
+ ]);
1202
+ const { precision: n = L, deduplicate: r = !1, consider3D: i = !1 } = t, s = e.map((u) => st(u, n));
1203
+ return r ? mt(s, { precision: n, consider3D: i }) : s;
1204
+ }
1205
+ function Ht(e, t, n) {
1206
+ return o.that(e, a.array, "positions must be an array"), e.map((r) => ot(r, t, n));
1207
+ }
1208
+ function $(e, t = {}) {
1209
+ return !a.arrayOfLengthAtLeast(e, 4) || !ct(e) ? !1 : he(e, t);
1210
+ }
1211
+ function he(e, t = {}) {
1212
+ if (o.that(t, (i) => d.schema(i, H), "options must be a valid options object"), !a.arrayOfLengthAtLeast(e, 1)) return !1;
1213
+ const n = e[0], r = e[e.length - 1];
1214
+ return be(n, r, t);
1215
+ }
1216
+ function dt(e, t = {}) {
1217
+ return !a.nonEmptyArray(e) || he(e, t) ? e : [...e, [...e[0]]];
1218
+ }
1219
+ function zt(e, t = {}) {
1220
+ const n = gt(e, { deduplicate: !0, ...t });
1221
+ return dt(n, t);
1222
+ }
1223
+ function ft(e) {
1224
+ o.that(e, $, "ring must be a valid closed ring of at least 4 positions");
1225
+ let t = 0;
1226
+ for (let n = 0; n < e.length - 1; n++) {
1227
+ const [r, i] = e[n], [s, u] = e[n + 1];
1228
+ t += p.to.radians(s - r) * (2 + Math.sin(p.to.radians(i)) + Math.sin(p.to.radians(u)));
1229
+ }
1230
+ return -t / 2;
1231
+ }
1232
+ function Wt(e) {
1233
+ return ft(e) < 0;
1234
+ }
1235
+ function Ft(e, t) {
1236
+ o.all([
1237
+ { value: e, validator: $, message: "ring1 must be a valid closed ring" },
1238
+ { value: t, validator: $, message: "ring2 must be a valid closed ring" }
1239
+ ]);
1240
+ const n = e.map(D), r = t.map(D);
1241
+ for (let i = 0; i < n.length - 1; i++)
1242
+ for (let s = 0; s < r.length - 1; s++)
1243
+ if (ve(n[i], n[i + 1], r[s], r[s + 1]))
1244
+ return !0;
1245
+ return !1;
1246
+ }
1247
+ function Yt(e) {
1248
+ o.that(e, $, "ring must be a valid closed ring");
1249
+ const t = e.map(D), n = [], r = t.length - 1;
1250
+ for (let i = 0; i < r; i++)
1251
+ for (let s = i + 1; s < r; s++)
1252
+ s !== i + 1 && (i === 0 && s === r - 1 || ve(t[i], t[i + 1], t[s], t[s + 1]) && n.push([i, s]));
1253
+ return n;
1254
+ }
1255
+ export {
1256
+ $t as $,
1257
+ m as A,
1258
+ Et as B,
1259
+ F as C,
1260
+ L as D,
1261
+ Ie as E,
1262
+ Wt as F,
1263
+ he as G,
1264
+ Z as H,
1265
+ H as I,
1266
+ G as J,
1267
+ q as K,
1268
+ Re as L,
1269
+ b as M,
1270
+ be as N,
1271
+ le as O,
1272
+ oe as P,
1273
+ B as Q,
1274
+ h as R,
1275
+ E as S,
1276
+ lt as T,
1277
+ ct as U,
1278
+ $ as V,
1279
+ Rt as W,
1280
+ Ut as X,
1281
+ k as Y,
1282
+ vt as Z,
1283
+ jt as _,
1284
+ We as a,
1285
+ Tt as a0,
1286
+ Ct as a1,
1287
+ Ye as a2,
1288
+ Pt as a3,
1289
+ bt as a4,
1290
+ ot as a5,
1291
+ Ht as a6,
1292
+ Yt as a7,
1293
+ Ft as a8,
1294
+ It as a9,
1295
+ ft as aa,
1296
+ kt as ab,
1297
+ de as ac,
1298
+ st as ad,
1299
+ gt as ae,
1300
+ zt as af,
1301
+ a as ag,
1302
+ o as ah,
1303
+ At as ai,
1304
+ g as aj,
1305
+ d as ak,
1306
+ _t as al,
1307
+ ye as am,
1308
+ Fe as b,
1309
+ dt as c,
1310
+ wt as d,
1311
+ yt as e,
1312
+ mt as f,
1313
+ Vt as g,
1314
+ Mt as h,
1315
+ xt as i,
1316
+ Bt as j,
1317
+ ue as k,
1318
+ Lt as l,
1319
+ Ce as m,
1320
+ j as n,
1321
+ ht as o,
1322
+ St as p,
1323
+ Ae as q,
1324
+ J as r,
1325
+ Ot as s,
1326
+ Gt as t,
1327
+ Nt as u,
1328
+ Dt as v,
1329
+ ae as w,
1330
+ re as x,
1331
+ ie as y,
1332
+ it as z
1333
+ };
1334
+ //# sourceMappingURL=ring-Cks2pGr8.js.map