@maptiler/geocoding-control 2.1.0-with-autocomplete-timeout → 2.1.1

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 (61) hide show
  1. package/leaflet-controller.js +1942 -1523
  2. package/leaflet-controller.js.map +1 -1
  3. package/leaflet-controller.umd.js +1 -22
  4. package/leaflet-controller.umd.js.map +1 -1
  5. package/leaflet.js +2798 -2385
  6. package/leaflet.js.map +1 -1
  7. package/leaflet.umd.js +1 -22
  8. package/leaflet.umd.js.map +1 -1
  9. package/maplibregl-controller.js +1918 -1498
  10. package/maplibregl-controller.js.map +1 -1
  11. package/maplibregl-controller.umd.js +1 -22
  12. package/maplibregl-controller.umd.js.map +1 -1
  13. package/maplibregl.js +2892 -2478
  14. package/maplibregl.js.map +1 -1
  15. package/maplibregl.umd.js +1 -22
  16. package/maplibregl.umd.js.map +1 -1
  17. package/maptilersdk.js +2898 -2482
  18. package/maptilersdk.js.map +1 -1
  19. package/maptilersdk.umd.js +1 -22
  20. package/maptilersdk.umd.js.map +1 -1
  21. package/openlayers-controller.js +1686 -1264
  22. package/openlayers-controller.js.map +1 -1
  23. package/openlayers-controller.umd.js +1 -22
  24. package/openlayers-controller.umd.js.map +1 -1
  25. package/openlayers.js +2778 -2365
  26. package/openlayers.js.map +1 -1
  27. package/openlayers.umd.js +1 -22
  28. package/openlayers.umd.js.map +1 -1
  29. package/package.json +19 -19
  30. package/react.js +753 -756
  31. package/react.js.map +1 -1
  32. package/react.umd.js +1 -1
  33. package/react.umd.js.map +1 -1
  34. package/{MapLibreBasedGeocodingControl.d.ts → src/MapLibreBasedGeocodingControl.d.ts} +35 -69
  35. package/{maplibregl.d.ts → src/maplibregl.d.ts} +34 -68
  36. package/{maptilersdk.d.ts → src/maptilersdk.d.ts} +34 -68
  37. package/src/types.d.ts +391 -0
  38. package/svelte/GeocodingControl.svelte +71 -58
  39. package/svelte/GeocodingControl.svelte.d.ts +5 -3
  40. package/svelte/MapLibreBasedGeocodingControl.d.ts +35 -69
  41. package/svelte/maplibregl.d.ts +34 -68
  42. package/svelte/maptilersdk.d.ts +34 -68
  43. package/svelte/maptilersdk.js +2 -0
  44. package/svelte/react.js +3 -0
  45. package/svelte/types.d.ts +175 -128
  46. package/vanilla.js +847 -853
  47. package/vanilla.js.map +1 -1
  48. package/vanilla.umd.js +1 -1
  49. package/vanilla.umd.js.map +1 -1
  50. package/types.d.ts +0 -344
  51. /package/{geo-coordinates-parser.t.d.ts → src/geo-coordinates-parser.t.d.ts} +0 -0
  52. /package/{geoUtils.d.ts → src/geoUtils.d.ts} +0 -0
  53. /package/{leaflet-controller.d.ts → src/leaflet-controller.d.ts} +0 -0
  54. /package/{leaflet.d.ts → src/leaflet.d.ts} +0 -0
  55. /package/{maplibregl-controller.d.ts → src/maplibregl-controller.d.ts} +0 -0
  56. /package/{mask.d.ts → src/mask.d.ts} +0 -0
  57. /package/{openlayers-controller.d.ts → src/openlayers-controller.d.ts} +0 -0
  58. /package/{openlayers.d.ts → src/openlayers.d.ts} +0 -0
  59. /package/{proximity.d.ts → src/proximity.d.ts} +0 -0
  60. /package/{react.d.ts → src/react.d.ts} +0 -0
  61. /package/{vanilla.d.ts → src/vanilla.d.ts} +0 -0
@@ -1,116 +1,116 @@
1
- var ie = Object.defineProperty;
2
- var oe = (r, t, e) => t in r ? ie(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var it = (r, t, e) => oe(r, typeof t != "symbol" ? t + "" : t, e);
4
- import * as T from "leaflet";
5
- function V(r, t, e = {}) {
6
- const n = { type: "Feature" };
7
- return (e.id === 0 || e.id) && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.properties = t || {}, n.geometry = r, n;
8
- }
9
- function xt(r, t, e = {}) {
10
- for (const i of r) {
11
- if (i.length < 4)
1
+ var Pt = Object.defineProperty;
2
+ var Ot = (t, e, n) => e in t ? Pt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var C = (t, e, n) => Ot(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import * as ce from "leaflet";
5
+ function Ee(t, e, n = {}) {
6
+ const i = { type: "Feature" };
7
+ return (n.id === 0 || n.id) && (i.id = n.id), n.bbox && (i.bbox = n.bbox), i.properties = e || {}, i.geometry = t, i;
8
+ }
9
+ function Ze(t, e, n = {}) {
10
+ for (const r of t) {
11
+ if (r.length < 4)
12
12
  throw new Error(
13
13
  "Each LinearRing of a Polygon must have 4 or more Positions."
14
14
  );
15
- if (i[i.length - 1].length !== i[0].length)
15
+ if (r[r.length - 1].length !== r[0].length)
16
16
  throw new Error("First and last Position are not equivalent.");
17
- for (let o = 0; o < i[i.length - 1].length; o++)
18
- if (i[i.length - 1][o] !== i[0][o])
17
+ for (let u = 0; u < r[r.length - 1].length; u++)
18
+ if (r[r.length - 1][u] !== r[0][u])
19
19
  throw new Error("First and last Position are not equivalent.");
20
20
  }
21
- return V({
21
+ return Ee({
22
22
  type: "Polygon",
23
- coordinates: r
24
- }, t, e);
23
+ coordinates: t
24
+ }, e, n);
25
25
  }
26
- function Z(r, t = {}) {
27
- const e = { type: "FeatureCollection" };
28
- return t.id && (e.id = t.id), t.bbox && (e.bbox = t.bbox), e.features = r, e;
26
+ function ve(t, e = {}) {
27
+ const n = { type: "FeatureCollection" };
28
+ return e.id && (n.id = e.id), e.bbox && (n.bbox = e.bbox), n.features = t, n;
29
29
  }
30
- function Ut(r, t, e = {}) {
31
- return V({
30
+ function gt(t, e, n = {}) {
31
+ return Ee({
32
32
  type: "MultiPolygon",
33
- coordinates: r
34
- }, t, e);
35
- }
36
- function Yt(r, t, e) {
37
- if (r !== null)
38
- for (var n, i, o, u, l, c, f, p = 0, s = 0, a, h = r.type, g = h === "FeatureCollection", d = h === "Feature", w = g ? r.features.length : 1, y = 0; y < w; y++) {
39
- f = g ? r.features[y].geometry : d ? r.geometry : r, a = f ? f.type === "GeometryCollection" : !1, l = a ? f.geometries.length : 1;
40
- for (var v = 0; v < l; v++) {
41
- var x = 0, m = 0;
42
- if (u = a ? f.geometries[v] : f, u !== null) {
43
- c = u.coordinates;
44
- var b = u.type;
45
- switch (p = 0, b) {
33
+ coordinates: t
34
+ }, e, n);
35
+ }
36
+ function yt(t, e, n) {
37
+ if (t !== null)
38
+ for (var i, r, u, a, h, E, p, _ = 0, b = 0, M, T = t.type, L = T === "FeatureCollection", B = T === "Feature", q = L ? t.features.length : 1, I = 0; I < q; I++) {
39
+ p = L ? t.features[I].geometry : B ? t.geometry : t, M = p ? p.type === "GeometryCollection" : !1, h = M ? p.geometries.length : 1;
40
+ for (var v = 0; v < h; v++) {
41
+ var N = 0, $ = 0;
42
+ if (a = M ? p.geometries[v] : p, a !== null) {
43
+ E = a.coordinates;
44
+ var K = a.type;
45
+ switch (_ = 0, K) {
46
46
  case null:
47
47
  break;
48
48
  case "Point":
49
- if (t(
50
- c,
51
- s,
52
- y,
53
- x,
54
- m
49
+ if (e(
50
+ E,
51
+ b,
52
+ I,
53
+ N,
54
+ $
55
55
  ) === !1)
56
56
  return !1;
57
- s++, x++;
57
+ b++, N++;
58
58
  break;
59
59
  case "LineString":
60
60
  case "MultiPoint":
61
- for (n = 0; n < c.length; n++) {
62
- if (t(
63
- c[n],
64
- s,
65
- y,
66
- x,
67
- m
61
+ for (i = 0; i < E.length; i++) {
62
+ if (e(
63
+ E[i],
64
+ b,
65
+ I,
66
+ N,
67
+ $
68
68
  ) === !1)
69
69
  return !1;
70
- s++, b === "MultiPoint" && x++;
70
+ b++, K === "MultiPoint" && N++;
71
71
  }
72
- b === "LineString" && x++;
72
+ K === "LineString" && N++;
73
73
  break;
74
74
  case "Polygon":
75
75
  case "MultiLineString":
76
- for (n = 0; n < c.length; n++) {
77
- for (i = 0; i < c[n].length - p; i++) {
78
- if (t(
79
- c[n][i],
80
- s,
81
- y,
82
- x,
83
- m
76
+ for (i = 0; i < E.length; i++) {
77
+ for (r = 0; r < E[i].length - _; r++) {
78
+ if (e(
79
+ E[i][r],
80
+ b,
81
+ I,
82
+ N,
83
+ $
84
84
  ) === !1)
85
85
  return !1;
86
- s++;
86
+ b++;
87
87
  }
88
- b === "MultiLineString" && x++, b === "Polygon" && m++;
88
+ K === "MultiLineString" && N++, K === "Polygon" && $++;
89
89
  }
90
- b === "Polygon" && x++;
90
+ K === "Polygon" && N++;
91
91
  break;
92
92
  case "MultiPolygon":
93
- for (n = 0; n < c.length; n++) {
94
- for (m = 0, i = 0; i < c[n].length; i++) {
95
- for (o = 0; o < c[n][i].length - p; o++) {
96
- if (t(
97
- c[n][i][o],
98
- s,
99
- y,
100
- x,
101
- m
93
+ for (i = 0; i < E.length; i++) {
94
+ for ($ = 0, r = 0; r < E[i].length; r++) {
95
+ for (u = 0; u < E[i][r].length - _; u++) {
96
+ if (e(
97
+ E[i][r][u],
98
+ b,
99
+ I,
100
+ N,
101
+ $
102
102
  ) === !1)
103
103
  return !1;
104
- s++;
104
+ b++;
105
105
  }
106
- m++;
106
+ $++;
107
107
  }
108
- x++;
108
+ N++;
109
109
  }
110
110
  break;
111
111
  case "GeometryCollection":
112
- for (n = 0; n < u.geometries.length; n++)
113
- if (Yt(u.geometries[n], t) === !1)
112
+ for (i = 0; i < a.geometries.length; i++)
113
+ if (yt(a.geometries[i], e) === !1)
114
114
  return !1;
115
115
  break;
116
116
  default:
@@ -120,46 +120,46 @@ function Yt(r, t, e) {
120
120
  }
121
121
  }
122
122
  }
123
- function vt(r, t) {
124
- var e, n, i, o, u, l, c, f, p, s, a = 0, h = r.type === "FeatureCollection", g = r.type === "Feature", d = h ? r.features.length : 1;
125
- for (e = 0; e < d; e++) {
126
- for (l = h ? r.features[e].geometry : g ? r.geometry : r, f = h ? r.features[e].properties : g ? r.properties : {}, p = h ? r.features[e].bbox : g ? r.bbox : void 0, s = h ? r.features[e].id : g ? r.id : void 0, c = l ? l.type === "GeometryCollection" : !1, u = c ? l.geometries.length : 1, i = 0; i < u; i++) {
127
- if (o = c ? l.geometries[i] : l, o === null) {
128
- if (t(
123
+ function Ye(t, e) {
124
+ var n, i, r, u, a, h, E, p, _, b, M = 0, T = t.type === "FeatureCollection", L = t.type === "Feature", B = T ? t.features.length : 1;
125
+ for (n = 0; n < B; n++) {
126
+ for (h = T ? t.features[n].geometry : L ? t.geometry : t, p = T ? t.features[n].properties : L ? t.properties : {}, _ = T ? t.features[n].bbox : L ? t.bbox : void 0, b = T ? t.features[n].id : L ? t.id : void 0, E = h ? h.type === "GeometryCollection" : !1, a = E ? h.geometries.length : 1, r = 0; r < a; r++) {
127
+ if (u = E ? h.geometries[r] : h, u === null) {
128
+ if (e(
129
129
  null,
130
- a,
131
- f,
130
+ M,
132
131
  p,
133
- s
132
+ _,
133
+ b
134
134
  ) === !1)
135
135
  return !1;
136
136
  continue;
137
137
  }
138
- switch (o.type) {
138
+ switch (u.type) {
139
139
  case "Point":
140
140
  case "LineString":
141
141
  case "MultiPoint":
142
142
  case "Polygon":
143
143
  case "MultiLineString":
144
144
  case "MultiPolygon": {
145
- if (t(
146
- o,
147
- a,
148
- f,
145
+ if (e(
146
+ u,
147
+ M,
149
148
  p,
150
- s
149
+ _,
150
+ b
151
151
  ) === !1)
152
152
  return !1;
153
153
  break;
154
154
  }
155
155
  case "GeometryCollection": {
156
- for (n = 0; n < o.geometries.length; n++)
157
- if (t(
158
- o.geometries[n],
159
- a,
160
- f,
156
+ for (i = 0; i < u.geometries.length; i++)
157
+ if (e(
158
+ u.geometries[i],
159
+ M,
161
160
  p,
162
- s
161
+ _,
162
+ b
163
163
  ) === !1)
164
164
  return !1;
165
165
  break;
@@ -168,62 +168,62 @@ function vt(r, t) {
168
168
  throw new Error("Unknown Geometry Type");
169
169
  }
170
170
  }
171
- a++;
171
+ M++;
172
172
  }
173
173
  }
174
- function se(r, t) {
175
- vt(r, function(e, n, i, o, u) {
176
- var l = e === null ? null : e.type;
177
- switch (l) {
174
+ function Rt(t, e) {
175
+ Ye(t, function(n, i, r, u, a) {
176
+ var h = n === null ? null : n.type;
177
+ switch (h) {
178
178
  case null:
179
179
  case "Point":
180
180
  case "LineString":
181
181
  case "Polygon":
182
- return t(
183
- V(e, i, { bbox: o, id: u }),
184
- n,
182
+ return e(
183
+ Ee(n, r, { bbox: u, id: a }),
184
+ i,
185
185
  0
186
186
  ) === !1 ? !1 : void 0;
187
187
  }
188
- var c;
189
- switch (l) {
188
+ var E;
189
+ switch (h) {
190
190
  case "MultiPoint":
191
- c = "Point";
191
+ E = "Point";
192
192
  break;
193
193
  case "MultiLineString":
194
- c = "LineString";
194
+ E = "LineString";
195
195
  break;
196
196
  case "MultiPolygon":
197
- c = "Polygon";
197
+ E = "Polygon";
198
198
  break;
199
199
  }
200
- for (var f = 0; f < e.coordinates.length; f++) {
201
- var p = e.coordinates[f], s = {
202
- type: c,
203
- coordinates: p
200
+ for (var p = 0; p < n.coordinates.length; p++) {
201
+ var _ = n.coordinates[p], b = {
202
+ type: E,
203
+ coordinates: _
204
204
  };
205
- if (t(V(s, i), n, f) === !1)
205
+ if (e(Ee(b, r), i, p) === !1)
206
206
  return !1;
207
207
  }
208
208
  });
209
209
  }
210
- function le(r, t = {}) {
211
- if (r.bbox != null && t.recompute !== !0)
212
- return r.bbox;
213
- const e = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
214
- return Yt(r, (n) => {
215
- e[0] > n[0] && (e[0] = n[0]), e[1] > n[1] && (e[1] = n[1]), e[2] < n[0] && (e[2] = n[0]), e[3] < n[1] && (e[3] = n[1]);
216
- }), e;
217
- }
218
- var ut = le;
219
- function ue(r) {
220
- if (!r)
210
+ function Nt(t, e = {}) {
211
+ if (t.bbox != null && e.recompute !== !0)
212
+ return t.bbox;
213
+ const n = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
214
+ return yt(t, (i) => {
215
+ n[0] > i[0] && (n[0] = i[0]), n[1] > i[1] && (n[1] = i[1]), n[2] < i[0] && (n[2] = i[0]), n[3] < i[1] && (n[3] = i[1]);
216
+ }), n;
217
+ }
218
+ var qe = Nt;
219
+ function At(t) {
220
+ if (!t)
221
221
  throw new Error("geojson is required");
222
- switch (r.type) {
222
+ switch (t.type) {
223
223
  case "Feature":
224
- return Dt(r);
224
+ return dt(t);
225
225
  case "FeatureCollection":
226
- return fe(r);
226
+ return It(t);
227
227
  case "Point":
228
228
  case "LineString":
229
229
  case "Polygon":
@@ -231,627 +231,1073 @@ function ue(r) {
231
231
  case "MultiLineString":
232
232
  case "MultiPolygon":
233
233
  case "GeometryCollection":
234
- return mt(r);
234
+ return We(t);
235
235
  default:
236
236
  throw new Error("unknown GeoJSON type");
237
237
  }
238
238
  }
239
- function Dt(r) {
240
- const t = { type: "Feature" };
241
- return Object.keys(r).forEach((e) => {
242
- switch (e) {
239
+ function dt(t) {
240
+ const e = { type: "Feature" };
241
+ return Object.keys(t).forEach((n) => {
242
+ switch (n) {
243
243
  case "type":
244
244
  case "properties":
245
245
  case "geometry":
246
246
  return;
247
247
  default:
248
- t[e] = r[e];
248
+ e[n] = t[n];
249
249
  }
250
- }), t.properties = jt(r.properties), r.geometry == null ? t.geometry = null : t.geometry = mt(r.geometry), t;
250
+ }), e.properties = mt(t.properties), t.geometry == null ? e.geometry = null : e.geometry = We(t.geometry), e;
251
251
  }
252
- function jt(r) {
253
- const t = {};
254
- return r && Object.keys(r).forEach((e) => {
255
- const n = r[e];
256
- typeof n == "object" ? n === null ? t[e] = null : Array.isArray(n) ? t[e] = n.map((i) => i) : t[e] = jt(n) : t[e] = n;
257
- }), t;
252
+ function mt(t) {
253
+ const e = {};
254
+ return t && Object.keys(t).forEach((n) => {
255
+ const i = t[n];
256
+ typeof i == "object" ? i === null ? e[n] = null : Array.isArray(i) ? e[n] = i.map((r) => r) : e[n] = mt(i) : e[n] = i;
257
+ }), e;
258
258
  }
259
- function fe(r) {
260
- const t = { type: "FeatureCollection" };
261
- return Object.keys(r).forEach((e) => {
262
- switch (e) {
259
+ function It(t) {
260
+ const e = { type: "FeatureCollection" };
261
+ return Object.keys(t).forEach((n) => {
262
+ switch (n) {
263
263
  case "type":
264
264
  case "features":
265
265
  return;
266
266
  default:
267
- t[e] = r[e];
267
+ e[n] = t[n];
268
268
  }
269
- }), t.features = r.features.map((e) => Dt(e)), t;
270
- }
271
- function mt(r) {
272
- const t = { type: r.type };
273
- return r.bbox && (t.bbox = r.bbox), r.type === "GeometryCollection" ? (t.geometries = r.geometries.map((e) => mt(e)), t) : (t.coordinates = Xt(r.coordinates), t);
274
- }
275
- function Xt(r) {
276
- const t = r;
277
- return typeof t[0] != "object" ? t.slice() : t.map((e) => Xt(e));
278
- }
279
- var ce = ue;
280
- /**
281
- * splaytree v3.1.2
282
- * Fast Splay tree for Node and browser
283
- *
284
- * @author Alexander Milevski <info@w8r.name>
285
- * @license MIT
286
- * @preserve
287
- */
288
- /*! *****************************************************************************
289
- Copyright (c) Microsoft Corporation. All rights reserved.
290
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
291
- this file except in compliance with the License. You may obtain a copy of the
292
- License at http://www.apache.org/licenses/LICENSE-2.0
293
-
294
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
295
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
296
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
297
- MERCHANTABLITY OR NON-INFRINGEMENT.
298
-
299
- See the Apache Version 2.0 License for specific language governing permissions
300
- and limitations under the License.
301
- ***************************************************************************** */
302
- function he(r, t) {
303
- var e = { label: 0, sent: function() {
304
- if (o[0] & 1) throw o[1];
305
- return o[1];
306
- }, trys: [], ops: [] }, n, i, o, u;
307
- return u = { next: l(0), throw: l(1), return: l(2) }, typeof Symbol == "function" && (u[Symbol.iterator] = function() {
308
- return this;
309
- }), u;
310
- function l(f) {
311
- return function(p) {
312
- return c([f, p]);
313
- };
314
- }
315
- function c(f) {
316
- if (n) throw new TypeError("Generator is already executing.");
317
- for (; e; ) try {
318
- if (n = 1, i && (o = f[0] & 2 ? i.return : f[0] ? i.throw || ((o = i.return) && o.call(i), 0) : i.next) && !(o = o.call(i, f[1])).done) return o;
319
- switch (i = 0, o && (f = [f[0] & 2, o.value]), f[0]) {
320
- case 0:
321
- case 1:
322
- o = f;
323
- break;
324
- case 4:
325
- return e.label++, { value: f[1], done: !1 };
326
- case 5:
327
- e.label++, i = f[1], f = [0];
328
- continue;
329
- case 7:
330
- f = e.ops.pop(), e.trys.pop();
331
- continue;
332
- default:
333
- if (o = e.trys, !(o = o.length > 0 && o[o.length - 1]) && (f[0] === 6 || f[0] === 2)) {
334
- e = 0;
269
+ }), e.features = t.features.map((n) => dt(n)), e;
270
+ }
271
+ function We(t) {
272
+ const e = { type: t.type };
273
+ return t.bbox && (e.bbox = t.bbox), t.type === "GeometryCollection" ? (e.geometries = t.geometries.map((n) => We(n)), e) : (e.coordinates = xt(t.coordinates), e);
274
+ }
275
+ function xt(t) {
276
+ const e = t;
277
+ return typeof e[0] != "object" ? e.slice() : e.map((n) => xt(n));
278
+ }
279
+ var kt = At, Bt = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, Be = Math.ceil, j = Math.floor, Z = "[BigNumber Error] ", He = Z + "Number primitive has more than 15 significant digits: ", ee = 1e14, R = 14, je = 9007199254740991, Ge = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], le = 1e7, Y = 1e9;
280
+ function wt(t) {
281
+ var e, n, i, r = v.prototype = { constructor: v, toString: null, valueOf: null }, u = new v(1), a = 20, h = 4, E = -7, p = 21, _ = -1e7, b = 1e7, M = !1, T = 1, L = 0, B = {
282
+ prefix: "",
283
+ groupSize: 3,
284
+ secondaryGroupSize: 0,
285
+ groupSeparator: ",",
286
+ decimalSeparator: ".",
287
+ fractionGroupSize: 0,
288
+ fractionGroupSeparator: " ",
289
+ // non-breaking space
290
+ suffix: ""
291
+ }, q = "0123456789abcdefghijklmnopqrstuvwxyz", I = !0;
292
+ function v(s, o) {
293
+ var l, m, c, y, w, f, g, x, d = this;
294
+ if (!(d instanceof v)) return new v(s, o);
295
+ if (o == null) {
296
+ if (s && s._isBigNumber === !0) {
297
+ d.s = s.s, !s.c || s.e > b ? d.c = d.e = null : s.e < _ ? d.c = [d.e = 0] : (d.e = s.e, d.c = s.c.slice());
298
+ return;
299
+ }
300
+ if ((f = typeof s == "number") && s * 0 == 0) {
301
+ if (d.s = 1 / s < 0 ? (s = -s, -1) : 1, s === ~~s) {
302
+ for (y = 0, w = s; w >= 10; w /= 10, y++) ;
303
+ y > b ? d.c = d.e = null : (d.e = y, d.c = [s]);
304
+ return;
305
+ }
306
+ x = String(s);
307
+ } else {
308
+ if (!Bt.test(x = String(s))) return i(d, x, f);
309
+ d.s = x.charCodeAt(0) == 45 ? (x = x.slice(1), -1) : 1;
310
+ }
311
+ (y = x.indexOf(".")) > -1 && (x = x.replace(".", "")), (w = x.search(/e/i)) > 0 ? (y < 0 && (y = w), y += +x.slice(w + 1), x = x.substring(0, w)) : y < 0 && (y = x.length);
312
+ } else {
313
+ if (F(o, 2, q.length, "Base"), o == 10 && I)
314
+ return d = new v(s), W(d, a + d.e + 1, h);
315
+ if (x = String(s), f = typeof s == "number") {
316
+ if (s * 0 != 0) return i(d, x, f, o);
317
+ if (d.s = 1 / s < 0 ? (x = x.slice(1), -1) : 1, v.DEBUG && x.replace(/^0\.0*|\./, "").length > 15)
318
+ throw Error(He + s);
319
+ } else
320
+ d.s = x.charCodeAt(0) === 45 ? (x = x.slice(1), -1) : 1;
321
+ for (l = q.slice(0, o), y = w = 0, g = x.length; w < g; w++)
322
+ if (l.indexOf(m = x.charAt(w)) < 0) {
323
+ if (m == ".") {
324
+ if (w > y) {
325
+ y = g;
326
+ continue;
327
+ }
328
+ } else if (!c && (x == x.toUpperCase() && (x = x.toLowerCase()) || x == x.toLowerCase() && (x = x.toUpperCase()))) {
329
+ c = !0, w = -1, y = 0;
335
330
  continue;
336
331
  }
337
- if (f[0] === 3 && (!o || f[1] > o[0] && f[1] < o[3])) {
338
- e.label = f[1];
339
- break;
340
- }
341
- if (f[0] === 6 && e.label < o[1]) {
342
- e.label = o[1], o = f;
343
- break;
344
- }
345
- if (o && e.label < o[2]) {
346
- e.label = o[2], e.ops.push(f);
347
- break;
348
- }
349
- o[2] && e.ops.pop(), e.trys.pop();
350
- continue;
351
- }
352
- f = t.call(r, e);
353
- } catch (p) {
354
- f = [6, p], i = 0;
355
- } finally {
356
- n = o = 0;
332
+ return i(d, String(s), f, o);
333
+ }
334
+ f = !1, x = n(x, o, 10, d.s), (y = x.indexOf(".")) > -1 ? x = x.replace(".", "") : y = x.length;
357
335
  }
358
- if (f[0] & 5) throw f[1];
359
- return { value: f[0] ? f[1] : void 0, done: !0 };
360
- }
361
- }
362
- var F = (
363
- /** @class */
364
- /* @__PURE__ */ function() {
365
- function r(t, e) {
366
- this.next = null, this.key = t, this.data = e, this.left = null, this.right = null;
367
- }
368
- return r;
369
- }()
370
- );
371
- function ae(r, t) {
372
- return r > t ? 1 : r < t ? -1 : 0;
373
- }
374
- function B(r, t, e) {
375
- for (var n = new F(null, null), i = n, o = n; ; ) {
376
- var u = e(r, t.key);
377
- if (u < 0) {
378
- if (t.left === null)
379
- break;
380
- if (e(r, t.left.key) < 0) {
381
- var l = t.left;
382
- if (t.left = l.right, l.right = t, t = l, t.left === null)
383
- break;
384
- }
385
- o.left = t, o = t, t = t.left;
386
- } else if (u > 0) {
387
- if (t.right === null)
388
- break;
389
- if (e(r, t.right.key) > 0) {
390
- var l = t.right;
391
- if (t.right = l.left, l.left = t, t = l, t.right === null)
392
- break;
336
+ for (w = 0; x.charCodeAt(w) === 48; w++) ;
337
+ for (g = x.length; x.charCodeAt(--g) === 48; ) ;
338
+ if (x = x.slice(w, ++g)) {
339
+ if (g -= w, f && v.DEBUG && g > 15 && (s > je || s !== j(s)))
340
+ throw Error(He + d.s * s);
341
+ if ((y = y - w - 1) > b)
342
+ d.c = d.e = null;
343
+ else if (y < _)
344
+ d.c = [d.e = 0];
345
+ else {
346
+ if (d.e = y, d.c = [], w = (y + 1) % R, y < 0 && (w += R), w < g) {
347
+ for (w && d.c.push(+x.slice(0, w)), g -= R; w < g; )
348
+ d.c.push(+x.slice(w, w += R));
349
+ w = R - (x = x.slice(w)).length;
350
+ } else
351
+ w -= g;
352
+ for (; w--; x += "0") ;
353
+ d.c.push(+x);
393
354
  }
394
- i.right = t, i = t, t = t.right;
395
355
  } else
396
- break;
397
- }
398
- return i.right = t.left, o.left = t.right, t.left = n.right, t.right = n.left, t;
399
- }
400
- function ot(r, t, e, n) {
401
- var i = new F(r, t);
402
- if (e === null)
403
- return i.left = i.right = null, i;
404
- e = B(r, e, n);
405
- var o = n(r, e.key);
406
- return o < 0 ? (i.left = e.left, i.right = e, e.left = null) : o >= 0 && (i.right = e.right, i.left = e, e.right = null), i;
407
- }
408
- function Et(r, t, e) {
409
- var n = null, i = null;
410
- if (t) {
411
- t = B(r, t, e);
412
- var o = e(t.key, r);
413
- o === 0 ? (n = t.left, i = t.right) : o < 0 ? (i = t.right, t.right = null, n = t) : (n = t.left, t.left = null, i = t);
414
- }
415
- return { left: n, right: i };
416
- }
417
- function pe(r, t, e) {
418
- return t === null ? r : (r === null || (t = B(r.key, t, e), t.left = r), t);
419
- }
420
- function ft(r, t, e, n, i) {
421
- if (r) {
422
- n("" + t + (e ? "└── " : "├── ") + i(r) + `
423
- `);
424
- var o = t + (e ? " " : "│ ");
425
- r.left && ft(r.left, o, !1, n, i), r.right && ft(r.right, o, !0, n, i);
426
- }
427
- }
428
- var wt = (
429
- /** @class */
430
- function() {
431
- function r(t) {
432
- t === void 0 && (t = ae), this._root = null, this._size = 0, this._comparator = t;
433
- }
434
- return r.prototype.insert = function(t, e) {
435
- return this._size++, this._root = ot(t, e, this._root, this._comparator);
436
- }, r.prototype.add = function(t, e) {
437
- var n = new F(t, e);
438
- this._root === null && (n.left = n.right = null, this._size++, this._root = n);
439
- var i = this._comparator, o = B(t, this._root, i), u = i(t, o.key);
440
- return u === 0 ? this._root = o : (u < 0 ? (n.left = o.left, n.right = o, o.left = null) : u > 0 && (n.right = o.right, n.left = o, o.right = null), this._size++, this._root = n), this._root;
441
- }, r.prototype.remove = function(t) {
442
- this._root = this._remove(t, this._root, this._comparator);
443
- }, r.prototype._remove = function(t, e, n) {
444
- var i;
445
- if (e === null)
446
- return null;
447
- e = B(t, e, n);
448
- var o = n(t, e.key);
449
- return o === 0 ? (e.left === null ? i = e.right : (i = B(t, e.left, n), i.right = e.right), this._size--, i) : e;
450
- }, r.prototype.pop = function() {
451
- var t = this._root;
452
- if (t) {
453
- for (; t.left; )
454
- t = t.left;
455
- return this._root = B(t.key, this._root, this._comparator), this._root = this._remove(t.key, this._root, this._comparator), { key: t.key, data: t.data };
356
+ d.c = [d.e = 0];
357
+ }
358
+ v.clone = wt, v.ROUND_UP = 0, v.ROUND_DOWN = 1, v.ROUND_CEIL = 2, v.ROUND_FLOOR = 3, v.ROUND_HALF_UP = 4, v.ROUND_HALF_DOWN = 5, v.ROUND_HALF_EVEN = 6, v.ROUND_HALF_CEIL = 7, v.ROUND_HALF_FLOOR = 8, v.EUCLID = 9, v.config = v.set = function(s) {
359
+ var o, l;
360
+ if (s != null)
361
+ if (typeof s == "object") {
362
+ if (s.hasOwnProperty(o = "DECIMAL_PLACES") && (l = s[o], F(l, 0, Y, o), a = l), s.hasOwnProperty(o = "ROUNDING_MODE") && (l = s[o], F(l, 0, 8, o), h = l), s.hasOwnProperty(o = "EXPONENTIAL_AT") && (l = s[o], l && l.pop ? (F(l[0], -1e9, 0, o), F(l[1], 0, Y, o), E = l[0], p = l[1]) : (F(l, -1e9, Y, o), E = -(p = l < 0 ? -l : l))), s.hasOwnProperty(o = "RANGE"))
363
+ if (l = s[o], l && l.pop)
364
+ F(l[0], -1e9, -1, o), F(l[1], 1, Y, o), _ = l[0], b = l[1];
365
+ else if (F(l, -1e9, Y, o), l)
366
+ _ = -(b = l < 0 ? -l : l);
367
+ else
368
+ throw Error(Z + o + " cannot be zero: " + l);
369
+ if (s.hasOwnProperty(o = "CRYPTO"))
370
+ if (l = s[o], l === !!l)
371
+ if (l)
372
+ if (typeof crypto < "u" && crypto && (crypto.getRandomValues || crypto.randomBytes))
373
+ M = l;
374
+ else
375
+ throw M = !l, Error(Z + "crypto unavailable");
376
+ else
377
+ M = l;
378
+ else
379
+ throw Error(Z + o + " not true or false: " + l);
380
+ if (s.hasOwnProperty(o = "MODULO_MODE") && (l = s[o], F(l, 0, 9, o), T = l), s.hasOwnProperty(o = "POW_PRECISION") && (l = s[o], F(l, 0, Y, o), L = l), s.hasOwnProperty(o = "FORMAT"))
381
+ if (l = s[o], typeof l == "object") B = l;
382
+ else throw Error(Z + o + " not an object: " + l);
383
+ if (s.hasOwnProperty(o = "ALPHABET"))
384
+ if (l = s[o], typeof l == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(l))
385
+ I = l.slice(0, 10) == "0123456789", q = l;
386
+ else
387
+ throw Error(Z + o + " invalid: " + l);
388
+ } else
389
+ throw Error(Z + "Object expected: " + s);
390
+ return {
391
+ DECIMAL_PLACES: a,
392
+ ROUNDING_MODE: h,
393
+ EXPONENTIAL_AT: [E, p],
394
+ RANGE: [_, b],
395
+ CRYPTO: M,
396
+ MODULO_MODE: T,
397
+ POW_PRECISION: L,
398
+ FORMAT: B,
399
+ ALPHABET: q
400
+ };
401
+ }, v.isBigNumber = function(s) {
402
+ if (!s || s._isBigNumber !== !0) return !1;
403
+ if (!v.DEBUG) return !0;
404
+ var o, l, m = s.c, c = s.e, y = s.s;
405
+ e: if ({}.toString.call(m) == "[object Array]") {
406
+ if ((y === 1 || y === -1) && c >= -1e9 && c <= Y && c === j(c)) {
407
+ if (m[0] === 0) {
408
+ if (c === 0 && m.length === 1) return !0;
409
+ break e;
410
+ }
411
+ if (o = (c + 1) % R, o < 1 && (o += R), String(m[0]).length == o) {
412
+ for (o = 0; o < m.length; o++)
413
+ if (l = m[o], l < 0 || l >= ee || l !== j(l)) break e;
414
+ if (l !== 0) return !0;
415
+ }
456
416
  }
457
- return null;
458
- }, r.prototype.findStatic = function(t) {
459
- for (var e = this._root, n = this._comparator; e; ) {
460
- var i = n(t, e.key);
461
- if (i === 0)
462
- return e;
463
- i < 0 ? e = e.left : e = e.right;
417
+ } else if (m === null && c === null && (y === null || y === 1 || y === -1))
418
+ return !0;
419
+ throw Error(Z + "Invalid BigNumber: " + s);
420
+ }, v.maximum = v.max = function() {
421
+ return $(arguments, -1);
422
+ }, v.minimum = v.min = function() {
423
+ return $(arguments, 1);
424
+ }, v.random = function() {
425
+ var s = 9007199254740992, o = Math.random() * s & 2097151 ? function() {
426
+ return j(Math.random() * s);
427
+ } : function() {
428
+ return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
429
+ };
430
+ return function(l) {
431
+ var m, c, y, w, f, g = 0, x = [], d = new v(u);
432
+ if (l == null ? l = a : F(l, 0, Y), w = Be(l / R), M)
433
+ if (crypto.getRandomValues) {
434
+ for (m = crypto.getRandomValues(new Uint32Array(w *= 2)); g < w; )
435
+ f = m[g] * 131072 + (m[g + 1] >>> 11), f >= 9e15 ? (c = crypto.getRandomValues(new Uint32Array(2)), m[g] = c[0], m[g + 1] = c[1]) : (x.push(f % 1e14), g += 2);
436
+ g = w / 2;
437
+ } else if (crypto.randomBytes) {
438
+ for (m = crypto.randomBytes(w *= 7); g < w; )
439
+ f = (m[g] & 31) * 281474976710656 + m[g + 1] * 1099511627776 + m[g + 2] * 4294967296 + m[g + 3] * 16777216 + (m[g + 4] << 16) + (m[g + 5] << 8) + m[g + 6], f >= 9e15 ? crypto.randomBytes(7).copy(m, g) : (x.push(f % 1e14), g += 7);
440
+ g = w / 7;
441
+ } else
442
+ throw M = !1, Error(Z + "crypto unavailable");
443
+ if (!M)
444
+ for (; g < w; )
445
+ f = o(), f < 9e15 && (x[g++] = f % 1e14);
446
+ for (w = x[--g], l %= R, w && l && (f = Ge[R - l], x[g] = j(w / f) * f); x[g] === 0; x.pop(), g--) ;
447
+ if (g < 0)
448
+ x = [y = 0];
449
+ else {
450
+ for (y = -1; x[0] === 0; x.splice(0, 1), y -= R) ;
451
+ for (g = 1, f = x[0]; f >= 10; f /= 10, g++) ;
452
+ g < R && (y -= R - g);
464
453
  }
465
- return null;
466
- }, r.prototype.find = function(t) {
467
- return this._root && (this._root = B(t, this._root, this._comparator), this._comparator(t, this._root.key) !== 0) ? null : this._root;
468
- }, r.prototype.contains = function(t) {
469
- for (var e = this._root, n = this._comparator; e; ) {
470
- var i = n(t, e.key);
471
- if (i === 0)
472
- return !0;
473
- i < 0 ? e = e.left : e = e.right;
454
+ return d.e = y, d.c = x, d;
455
+ };
456
+ }(), v.sum = function() {
457
+ for (var s = 1, o = arguments, l = new v(o[0]); s < o.length; ) l = l.plus(o[s++]);
458
+ return l;
459
+ }, n = /* @__PURE__ */ function() {
460
+ var s = "0123456789";
461
+ function o(l, m, c, y) {
462
+ for (var w, f = [0], g, x = 0, d = l.length; x < d; ) {
463
+ for (g = f.length; g--; f[g] *= m) ;
464
+ for (f[0] += y.indexOf(l.charAt(x++)), w = 0; w < f.length; w++)
465
+ f[w] > c - 1 && (f[w + 1] == null && (f[w + 1] = 0), f[w + 1] += f[w] / c | 0, f[w] %= c);
474
466
  }
475
- return !1;
476
- }, r.prototype.forEach = function(t, e) {
477
- for (var n = this._root, i = [], o = !1; !o; )
478
- n !== null ? (i.push(n), n = n.left) : i.length !== 0 ? (n = i.pop(), t.call(e, n), n = n.right) : o = !0;
479
- return this;
480
- }, r.prototype.range = function(t, e, n, i) {
481
- for (var o = [], u = this._comparator, l = this._root, c; o.length !== 0 || l; )
482
- if (l)
483
- o.push(l), l = l.left;
484
- else {
485
- if (l = o.pop(), c = u(l.key, e), c > 0)
467
+ return f.reverse();
468
+ }
469
+ return function(l, m, c, y, w) {
470
+ var f, g, x, d, S, P, O, k, D = l.indexOf("."), U = a, A = h;
471
+ for (D >= 0 && (d = L, L = 0, l = l.replace(".", ""), k = new v(m), P = k.pow(l.length - D), L = d, k.c = o(
472
+ se(H(P.c), P.e, "0"),
473
+ 10,
474
+ c,
475
+ s
476
+ ), k.e = k.c.length), O = o(l, m, c, w ? (f = q, s) : (f = s, q)), x = d = O.length; O[--d] == 0; O.pop()) ;
477
+ if (!O[0]) return f.charAt(0);
478
+ if (D < 0 ? --x : (P.c = O, P.e = x, P.s = y, P = e(P, k, U, A, c), O = P.c, S = P.r, x = P.e), g = x + U + 1, D = O[g], d = c / 2, S = S || g < 0 || O[g + 1] != null, S = A < 4 ? (D != null || S) && (A == 0 || A == (P.s < 0 ? 3 : 2)) : D > d || D == d && (A == 4 || S || A == 6 && O[g - 1] & 1 || A == (P.s < 0 ? 8 : 7)), g < 1 || !O[0])
479
+ l = S ? se(f.charAt(1), -U, f.charAt(0)) : f.charAt(0);
480
+ else {
481
+ if (O.length = g, S)
482
+ for (--c; ++O[--g] > c; )
483
+ O[g] = 0, g || (++x, O = [1].concat(O));
484
+ for (d = O.length; !O[--d]; ) ;
485
+ for (D = 0, l = ""; D <= d; l += f.charAt(O[D++])) ;
486
+ l = se(l, x, f.charAt(0));
487
+ }
488
+ return l;
489
+ };
490
+ }(), e = /* @__PURE__ */ function() {
491
+ function s(m, c, y) {
492
+ var w, f, g, x, d = 0, S = m.length, P = c % le, O = c / le | 0;
493
+ for (m = m.slice(); S--; )
494
+ g = m[S] % le, x = m[S] / le | 0, w = O * g + x * P, f = P * g + w % le * le + d, d = (f / y | 0) + (w / le | 0) + O * x, m[S] = f % y;
495
+ return d && (m = [d].concat(m)), m;
496
+ }
497
+ function o(m, c, y, w) {
498
+ var f, g;
499
+ if (y != w)
500
+ g = y > w ? 1 : -1;
501
+ else
502
+ for (f = g = 0; f < y; f++)
503
+ if (m[f] != c[f]) {
504
+ g = m[f] > c[f] ? 1 : -1;
486
505
  break;
487
- if (u(l.key, t) >= 0 && n.call(i, l))
488
- return this;
489
- l = l.right;
490
- }
491
- return this;
492
- }, r.prototype.keys = function() {
493
- var t = [];
494
- return this.forEach(function(e) {
495
- var n = e.key;
496
- return t.push(n);
497
- }), t;
498
- }, r.prototype.values = function() {
499
- var t = [];
500
- return this.forEach(function(e) {
501
- var n = e.data;
502
- return t.push(n);
503
- }), t;
504
- }, r.prototype.min = function() {
505
- return this._root ? this.minNode(this._root).key : null;
506
- }, r.prototype.max = function() {
507
- return this._root ? this.maxNode(this._root).key : null;
508
- }, r.prototype.minNode = function(t) {
509
- if (t === void 0 && (t = this._root), t)
510
- for (; t.left; )
511
- t = t.left;
512
- return t;
513
- }, r.prototype.maxNode = function(t) {
514
- if (t === void 0 && (t = this._root), t)
515
- for (; t.right; )
516
- t = t.right;
517
- return t;
518
- }, r.prototype.at = function(t) {
519
- for (var e = this._root, n = !1, i = 0, o = []; !n; )
520
- if (e)
521
- o.push(e), e = e.left;
522
- else if (o.length > 0) {
523
- if (e = o.pop(), i === t)
524
- return e;
525
- i++, e = e.right;
526
- } else
527
- n = !0;
528
- return null;
529
- }, r.prototype.next = function(t) {
530
- var e = this._root, n = null;
531
- if (t.right) {
532
- for (n = t.right; n.left; )
533
- n = n.left;
534
- return n;
506
+ }
507
+ return g;
508
+ }
509
+ function l(m, c, y, w) {
510
+ for (var f = 0; y--; )
511
+ m[y] -= f, f = m[y] < c[y] ? 1 : 0, m[y] = f * w + m[y] - c[y];
512
+ for (; !m[0] && m.length > 1; m.splice(0, 1)) ;
513
+ }
514
+ return function(m, c, y, w, f) {
515
+ var g, x, d, S, P, O, k, D, U, A, G, V, be, Ie, ke, te, ge, J = m.s == c.s ? 1 : -1, X = m.c, z = c.c;
516
+ if (!X || !X[0] || !z || !z[0])
517
+ return new v(
518
+ // Return NaN if either NaN, or both Infinity or 0.
519
+ !m.s || !c.s || (X ? z && X[0] == z[0] : !z) ? NaN : (
520
+ // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
521
+ X && X[0] == 0 || !z ? J * 0 : J / 0
522
+ )
523
+ );
524
+ for (D = new v(J), U = D.c = [], x = m.e - c.e, J = y + x + 1, f || (f = ee, x = Q(m.e / R) - Q(c.e / R), J = J / R | 0), d = 0; z[d] == (X[d] || 0); d++) ;
525
+ if (z[d] > (X[d] || 0) && x--, J < 0)
526
+ U.push(1), S = !0;
527
+ else {
528
+ for (Ie = X.length, te = z.length, d = 0, J += 2, P = j(f / (z[0] + 1)), P > 1 && (z = s(z, P, f), X = s(X, P, f), te = z.length, Ie = X.length), be = te, A = X.slice(0, te), G = A.length; G < te; A[G++] = 0) ;
529
+ ge = z.slice(), ge = [0].concat(ge), ke = z[0], z[1] >= f / 2 && ke++;
530
+ do {
531
+ if (P = 0, g = o(z, A, te, G), g < 0) {
532
+ if (V = A[0], te != G && (V = V * f + (A[1] || 0)), P = j(V / ke), P > 1)
533
+ for (P >= f && (P = f - 1), O = s(z, P, f), k = O.length, G = A.length; o(O, A, k, G) == 1; )
534
+ P--, l(O, te < k ? ge : z, k, f), k = O.length, g = 1;
535
+ else
536
+ P == 0 && (g = P = 1), O = z.slice(), k = O.length;
537
+ if (k < G && (O = [0].concat(O)), l(A, O, G, f), G = A.length, g == -1)
538
+ for (; o(z, A, te, G) < 1; )
539
+ P++, l(A, te < G ? ge : z, G, f), G = A.length;
540
+ } else g === 0 && (P++, A = [0]);
541
+ U[d++] = P, A[0] ? A[G++] = X[be] || 0 : (A = [X[be]], G = 1);
542
+ } while ((be++ < Ie || A[0] != null) && J--);
543
+ S = A[0] != null, U[0] || U.splice(0, 1);
535
544
  }
536
- for (var i = this._comparator; e; ) {
537
- var o = i(t.key, e.key);
538
- if (o === 0)
539
- break;
540
- o < 0 ? (n = e, e = e.left) : e = e.right;
545
+ if (f == ee) {
546
+ for (d = 1, J = U[0]; J >= 10; J /= 10, d++) ;
547
+ W(D, y + (D.e = d + x * R - 1) + 1, w, S);
548
+ } else
549
+ D.e = x, D.r = +S;
550
+ return D;
551
+ };
552
+ }();
553
+ function N(s, o, l, m) {
554
+ var c, y, w, f, g;
555
+ if (l == null ? l = h : F(l, 0, 8), !s.c) return s.toString();
556
+ if (c = s.c[0], w = s.e, o == null)
557
+ g = H(s.c), g = m == 1 || m == 2 && (w <= E || w >= p) ? Te(g, w) : se(g, w, "0");
558
+ else if (s = W(new v(s), o, l), y = s.e, g = H(s.c), f = g.length, m == 1 || m == 2 && (o <= y || y <= E)) {
559
+ for (; f < o; g += "0", f++) ;
560
+ g = Te(g, y);
561
+ } else if (o -= w, g = se(g, y, "0"), y + 1 > f) {
562
+ if (--o > 0) for (g += "."; o--; g += "0") ;
563
+ } else if (o += y - f, o > 0)
564
+ for (y + 1 == f && (g += "."); o--; g += "0") ;
565
+ return s.s < 0 && c ? "-" + g : g;
566
+ }
567
+ function $(s, o) {
568
+ for (var l, m, c = 1, y = new v(s[0]); c < s.length; c++)
569
+ m = new v(s[c]), (!m.s || (l = fe(y, m)) === o || l === 0 && y.s === o) && (y = m);
570
+ return y;
571
+ }
572
+ function K(s, o, l) {
573
+ for (var m = 1, c = o.length; !o[--c]; o.pop()) ;
574
+ for (c = o[0]; c >= 10; c /= 10, m++) ;
575
+ return (l = m + l * R - 1) > b ? s.c = s.e = null : l < _ ? s.c = [s.e = 0] : (s.e = l, s.c = o), s;
576
+ }
577
+ i = /* @__PURE__ */ function() {
578
+ var s = /^(-?)0([xbo])(?=\w[\w.]*$)/i, o = /^([^.]+)\.$/, l = /^\.([^.]+)$/, m = /^-?(Infinity|NaN)$/, c = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
579
+ return function(y, w, f, g) {
580
+ var x, d = f ? w : w.replace(c, "");
581
+ if (m.test(d))
582
+ y.s = isNaN(d) ? null : d < 0 ? -1 : 1;
583
+ else {
584
+ if (!f && (d = d.replace(s, function(S, P, O) {
585
+ return x = (O = O.toLowerCase()) == "x" ? 16 : O == "b" ? 2 : 8, !g || g == x ? P : S;
586
+ }), g && (x = g, d = d.replace(o, "$1").replace(l, "0.$1")), w != d))
587
+ return new v(d, x);
588
+ if (v.DEBUG)
589
+ throw Error(Z + "Not a" + (g ? " base " + g : "") + " number: " + w);
590
+ y.s = null;
541
591
  }
542
- return n;
543
- }, r.prototype.prev = function(t) {
544
- var e = this._root, n = null;
545
- if (t.left !== null) {
546
- for (n = t.left; n.right; )
547
- n = n.right;
548
- return n;
592
+ y.c = y.e = null;
593
+ };
594
+ }();
595
+ function W(s, o, l, m) {
596
+ var c, y, w, f, g, x, d, S = s.c, P = Ge;
597
+ if (S) {
598
+ e: {
599
+ for (c = 1, f = S[0]; f >= 10; f /= 10, c++) ;
600
+ if (y = o - c, y < 0)
601
+ y += R, w = o, g = S[x = 0], d = j(g / P[c - w - 1] % 10);
602
+ else if (x = Be((y + 1) / R), x >= S.length)
603
+ if (m) {
604
+ for (; S.length <= x; S.push(0)) ;
605
+ g = d = 0, c = 1, y %= R, w = y - R + 1;
606
+ } else
607
+ break e;
608
+ else {
609
+ for (g = f = S[x], c = 1; f >= 10; f /= 10, c++) ;
610
+ y %= R, w = y - R + c, d = w < 0 ? 0 : j(g / P[c - w - 1] % 10);
611
+ }
612
+ if (m = m || o < 0 || // Are there any non-zero digits after the rounding digit?
613
+ // The expression n % pows10[d - j - 1] returns all digits of n to the right
614
+ // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
615
+ S[x + 1] != null || (w < 0 ? g : g % P[c - w - 1]), m = l < 4 ? (d || m) && (l == 0 || l == (s.s < 0 ? 3 : 2)) : d > 5 || d == 5 && (l == 4 || m || l == 6 && // Check whether the digit to the left of the rounding digit is odd.
616
+ (y > 0 ? w > 0 ? g / P[c - w] : 0 : S[x - 1]) % 10 & 1 || l == (s.s < 0 ? 8 : 7)), o < 1 || !S[0])
617
+ return S.length = 0, m ? (o -= s.e + 1, S[0] = P[(R - o % R) % R], s.e = -o || 0) : S[0] = s.e = 0, s;
618
+ if (y == 0 ? (S.length = x, f = 1, x--) : (S.length = x + 1, f = P[R - y], S[x] = w > 0 ? j(g / P[c - w] % P[w]) * f : 0), m)
619
+ for (; ; )
620
+ if (x == 0) {
621
+ for (y = 1, w = S[0]; w >= 10; w /= 10, y++) ;
622
+ for (w = S[0] += f, f = 1; w >= 10; w /= 10, f++) ;
623
+ y != f && (s.e++, S[0] == ee && (S[0] = 1));
624
+ break;
625
+ } else {
626
+ if (S[x] += f, S[x] != ee) break;
627
+ S[x--] = 0, f = 1;
628
+ }
629
+ for (y = S.length; S[--y] === 0; S.pop()) ;
549
630
  }
550
- for (var i = this._comparator; e; ) {
551
- var o = i(t.key, e.key);
552
- if (o === 0)
553
- break;
554
- o < 0 ? e = e.left : (n = e, e = e.right);
631
+ s.e > b ? s.c = s.e = null : s.e < _ && (s.c = [s.e = 0]);
632
+ }
633
+ return s;
634
+ }
635
+ function re(s) {
636
+ var o, l = s.e;
637
+ return l === null ? s.toString() : (o = H(s.c), o = l <= E || l >= p ? Te(o, l) : se(o, l, "0"), s.s < 0 ? "-" + o : o);
638
+ }
639
+ return r.absoluteValue = r.abs = function() {
640
+ var s = new v(this);
641
+ return s.s < 0 && (s.s = 1), s;
642
+ }, r.comparedTo = function(s, o) {
643
+ return fe(this, new v(s, o));
644
+ }, r.decimalPlaces = r.dp = function(s, o) {
645
+ var l, m, c, y = this;
646
+ if (s != null)
647
+ return F(s, 0, Y), o == null ? o = h : F(o, 0, 8), W(new v(y), s + y.e + 1, o);
648
+ if (!(l = y.c)) return null;
649
+ if (m = ((c = l.length - 1) - Q(this.e / R)) * R, c = l[c]) for (; c % 10 == 0; c /= 10, m--) ;
650
+ return m < 0 && (m = 0), m;
651
+ }, r.dividedBy = r.div = function(s, o) {
652
+ return e(this, new v(s, o), a, h);
653
+ }, r.dividedToIntegerBy = r.idiv = function(s, o) {
654
+ return e(this, new v(s, o), 0, 1);
655
+ }, r.exponentiatedBy = r.pow = function(s, o) {
656
+ var l, m, c, y, w, f, g, x, d, S = this;
657
+ if (s = new v(s), s.c && !s.isInteger())
658
+ throw Error(Z + "Exponent not an integer: " + re(s));
659
+ if (o != null && (o = new v(o)), f = s.e > 14, !S.c || !S.c[0] || S.c[0] == 1 && !S.e && S.c.length == 1 || !s.c || !s.c[0])
660
+ return d = new v(Math.pow(+re(S), f ? s.s * (2 - _e(s)) : +re(s))), o ? d.mod(o) : d;
661
+ if (g = s.s < 0, o) {
662
+ if (o.c ? !o.c[0] : !o.s) return new v(NaN);
663
+ m = !g && S.isInteger() && o.isInteger(), m && (S = S.mod(o));
664
+ } else {
665
+ if (s.e > 9 && (S.e > 0 || S.e < -1 || (S.e == 0 ? S.c[0] > 1 || f && S.c[1] >= 24e7 : S.c[0] < 8e13 || f && S.c[0] <= 9999975e7)))
666
+ return y = S.s < 0 && _e(s) ? -0 : 0, S.e > -1 && (y = 1 / y), new v(g ? 1 / y : y);
667
+ L && (y = Be(L / R + 2));
668
+ }
669
+ for (f ? (l = new v(0.5), g && (s.s = 1), x = _e(s)) : (c = Math.abs(+re(s)), x = c % 2), d = new v(u); ; ) {
670
+ if (x) {
671
+ if (d = d.times(S), !d.c) break;
672
+ y ? d.c.length > y && (d.c.length = y) : m && (d = d.mod(o));
555
673
  }
556
- return n;
557
- }, r.prototype.clear = function() {
558
- return this._root = null, this._size = 0, this;
559
- }, r.prototype.toList = function() {
560
- return ye(this._root);
561
- }, r.prototype.load = function(t, e, n) {
562
- e === void 0 && (e = []), n === void 0 && (n = !1);
563
- var i = t.length, o = this._comparator;
564
- if (n && at(t, e, 0, i - 1, o), this._root === null)
565
- this._root = ct(t, e, 0, i), this._size = i;
674
+ if (c) {
675
+ if (c = j(c / 2), c === 0) break;
676
+ x = c % 2;
677
+ } else if (s = s.times(l), W(s, s.e + 1, 1), s.e > 14)
678
+ x = _e(s);
566
679
  else {
567
- var u = de(this.toList(), ge(t, e), o);
568
- i = this._size + i, this._root = ht({ head: u }, 0, i);
680
+ if (c = +re(s), c === 0) break;
681
+ x = c % 2;
569
682
  }
570
- return this;
571
- }, r.prototype.isEmpty = function() {
572
- return this._root === null;
573
- }, Object.defineProperty(r.prototype, "size", {
574
- get: function() {
575
- return this._size;
576
- },
577
- enumerable: !0,
578
- configurable: !0
579
- }), Object.defineProperty(r.prototype, "root", {
580
- get: function() {
581
- return this._root;
582
- },
583
- enumerable: !0,
584
- configurable: !0
585
- }), r.prototype.toString = function(t) {
586
- t === void 0 && (t = function(n) {
587
- return String(n.key);
588
- });
589
- var e = [];
590
- return ft(this._root, "", !0, function(n) {
591
- return e.push(n);
592
- }, t), e.join("");
593
- }, r.prototype.update = function(t, e, n) {
594
- var i = this._comparator, o = Et(t, this._root, i), u = o.left, l = o.right;
595
- i(t, e) < 0 ? l = ot(e, n, l, i) : u = ot(e, n, u, i), this._root = pe(u, l, i);
596
- }, r.prototype.split = function(t) {
597
- return Et(t, this._root, this._comparator);
598
- }, r.prototype[Symbol.iterator] = function() {
599
- var t, e, n;
600
- return he(this, function(i) {
601
- switch (i.label) {
602
- case 0:
603
- t = this._root, e = [], n = !1, i.label = 1;
604
- case 1:
605
- return n ? [3, 6] : t === null ? [3, 2] : (e.push(t), t = t.left, [3, 5]);
606
- case 2:
607
- return e.length === 0 ? [3, 4] : (t = e.pop(), [4, t]);
608
- case 3:
609
- return i.sent(), t = t.right, [3, 5];
610
- case 4:
611
- n = !0, i.label = 5;
612
- case 5:
613
- return [3, 1];
614
- case 6:
615
- return [
616
- 2
617
- /*return*/
618
- ];
683
+ S = S.times(S), y ? S.c && S.c.length > y && (S.c.length = y) : m && (S = S.mod(o));
684
+ }
685
+ return m ? d : (g && (d = u.div(d)), o ? d.mod(o) : y ? W(d, L, h, w) : d);
686
+ }, r.integerValue = function(s) {
687
+ var o = new v(this);
688
+ return s == null ? s = h : F(s, 0, 8), W(o, o.e + 1, s);
689
+ }, r.isEqualTo = r.eq = function(s, o) {
690
+ return fe(this, new v(s, o)) === 0;
691
+ }, r.isFinite = function() {
692
+ return !!this.c;
693
+ }, r.isGreaterThan = r.gt = function(s, o) {
694
+ return fe(this, new v(s, o)) > 0;
695
+ }, r.isGreaterThanOrEqualTo = r.gte = function(s, o) {
696
+ return (o = fe(this, new v(s, o))) === 1 || o === 0;
697
+ }, r.isInteger = function() {
698
+ return !!this.c && Q(this.e / R) > this.c.length - 2;
699
+ }, r.isLessThan = r.lt = function(s, o) {
700
+ return fe(this, new v(s, o)) < 0;
701
+ }, r.isLessThanOrEqualTo = r.lte = function(s, o) {
702
+ return (o = fe(this, new v(s, o))) === -1 || o === 0;
703
+ }, r.isNaN = function() {
704
+ return !this.s;
705
+ }, r.isNegative = function() {
706
+ return this.s < 0;
707
+ }, r.isPositive = function() {
708
+ return this.s > 0;
709
+ }, r.isZero = function() {
710
+ return !!this.c && this.c[0] == 0;
711
+ }, r.minus = function(s, o) {
712
+ var l, m, c, y, w = this, f = w.s;
713
+ if (s = new v(s, o), o = s.s, !f || !o) return new v(NaN);
714
+ if (f != o)
715
+ return s.s = -o, w.plus(s);
716
+ var g = w.e / R, x = s.e / R, d = w.c, S = s.c;
717
+ if (!g || !x) {
718
+ if (!d || !S) return d ? (s.s = -o, s) : new v(S ? w : NaN);
719
+ if (!d[0] || !S[0])
720
+ return S[0] ? (s.s = -o, s) : new v(d[0] ? w : (
721
+ // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
722
+ h == 3 ? -0 : 0
723
+ ));
724
+ }
725
+ if (g = Q(g), x = Q(x), d = d.slice(), f = g - x) {
726
+ for ((y = f < 0) ? (f = -f, c = d) : (x = g, c = S), c.reverse(), o = f; o--; c.push(0)) ;
727
+ c.reverse();
728
+ } else
729
+ for (m = (y = (f = d.length) < (o = S.length)) ? f : o, f = o = 0; o < m; o++)
730
+ if (d[o] != S[o]) {
731
+ y = d[o] < S[o];
732
+ break;
619
733
  }
620
- });
621
- }, r;
622
- }()
623
- );
624
- function ct(r, t, e, n) {
625
- var i = n - e;
626
- if (i > 0) {
627
- var o = e + Math.floor(i / 2), u = r[o], l = t[o], c = new F(u, l);
628
- return c.left = ct(r, t, e, o), c.right = ct(r, t, o + 1, n), c;
629
- }
630
- return null;
631
- }
632
- function ge(r, t) {
633
- for (var e = new F(null, null), n = e, i = 0; i < r.length; i++)
634
- n = n.next = new F(r[i], t[i]);
635
- return n.next = null, e.next;
636
- }
637
- function ye(r) {
638
- for (var t = r, e = [], n = !1, i = new F(null, null), o = i; !n; )
639
- t ? (e.push(t), t = t.left) : e.length > 0 ? (t = o = o.next = e.pop(), t = t.right) : n = !0;
640
- return o.next = null, i.next;
641
- }
642
- function ht(r, t, e) {
643
- var n = e - t;
644
- if (n > 0) {
645
- var i = t + Math.floor(n / 2), o = ht(r, t, i), u = r.head;
646
- return u.left = o, r.head = r.head.next, u.right = ht(r, i + 1, e), u;
734
+ if (y && (c = d, d = S, S = c, s.s = -s.s), o = (m = S.length) - (l = d.length), o > 0) for (; o--; d[l++] = 0) ;
735
+ for (o = ee - 1; m > f; ) {
736
+ if (d[--m] < S[m]) {
737
+ for (l = m; l && !d[--l]; d[l] = o) ;
738
+ --d[l], d[m] += ee;
739
+ }
740
+ d[m] -= S[m];
741
+ }
742
+ for (; d[0] == 0; d.splice(0, 1), --x) ;
743
+ return d[0] ? K(s, d, x) : (s.s = h == 3 ? -1 : 1, s.c = [s.e = 0], s);
744
+ }, r.modulo = r.mod = function(s, o) {
745
+ var l, m, c = this;
746
+ return s = new v(s, o), !c.c || !s.s || s.c && !s.c[0] ? new v(NaN) : !s.c || c.c && !c.c[0] ? new v(c) : (T == 9 ? (m = s.s, s.s = 1, l = e(c, s, 0, 3), s.s = m, l.s *= m) : l = e(c, s, 0, T), s = c.minus(l.times(s)), !s.c[0] && T == 1 && (s.s = c.s), s);
747
+ }, r.multipliedBy = r.times = function(s, o) {
748
+ var l, m, c, y, w, f, g, x, d, S, P, O, k, D, U, A = this, G = A.c, V = (s = new v(s, o)).c;
749
+ if (!G || !V || !G[0] || !V[0])
750
+ return !A.s || !s.s || G && !G[0] && !V || V && !V[0] && !G ? s.c = s.e = s.s = null : (s.s *= A.s, !G || !V ? s.c = s.e = null : (s.c = [0], s.e = 0)), s;
751
+ for (m = Q(A.e / R) + Q(s.e / R), s.s *= A.s, g = G.length, S = V.length, g < S && (k = G, G = V, V = k, c = g, g = S, S = c), c = g + S, k = []; c--; k.push(0)) ;
752
+ for (D = ee, U = le, c = S; --c >= 0; ) {
753
+ for (l = 0, P = V[c] % U, O = V[c] / U | 0, w = g, y = c + w; y > c; )
754
+ x = G[--w] % U, d = G[w] / U | 0, f = O * x + d * P, x = P * x + f % U * U + k[y] + l, l = (x / D | 0) + (f / U | 0) + O * d, k[y--] = x % D;
755
+ k[y] = l;
756
+ }
757
+ return l ? ++m : k.splice(0, 1), K(s, k, m);
758
+ }, r.negated = function() {
759
+ var s = new v(this);
760
+ return s.s = -s.s || null, s;
761
+ }, r.plus = function(s, o) {
762
+ var l, m = this, c = m.s;
763
+ if (s = new v(s, o), o = s.s, !c || !o) return new v(NaN);
764
+ if (c != o)
765
+ return s.s = -o, m.minus(s);
766
+ var y = m.e / R, w = s.e / R, f = m.c, g = s.c;
767
+ if (!y || !w) {
768
+ if (!f || !g) return new v(c / 0);
769
+ if (!f[0] || !g[0]) return g[0] ? s : new v(f[0] ? m : c * 0);
770
+ }
771
+ if (y = Q(y), w = Q(w), f = f.slice(), c = y - w) {
772
+ for (c > 0 ? (w = y, l = g) : (c = -c, l = f), l.reverse(); c--; l.push(0)) ;
773
+ l.reverse();
774
+ }
775
+ for (c = f.length, o = g.length, c - o < 0 && (l = g, g = f, f = l, o = c), c = 0; o; )
776
+ c = (f[--o] = f[o] + g[o] + c) / ee | 0, f[o] = ee === f[o] ? 0 : f[o] % ee;
777
+ return c && (f = [c].concat(f), ++w), K(s, f, w);
778
+ }, r.precision = r.sd = function(s, o) {
779
+ var l, m, c, y = this;
780
+ if (s != null && s !== !!s)
781
+ return F(s, 1, Y), o == null ? o = h : F(o, 0, 8), W(new v(y), s, o);
782
+ if (!(l = y.c)) return null;
783
+ if (c = l.length - 1, m = c * R + 1, c = l[c]) {
784
+ for (; c % 10 == 0; c /= 10, m--) ;
785
+ for (c = l[0]; c >= 10; c /= 10, m++) ;
786
+ }
787
+ return s && y.e + 1 > m && (m = y.e + 1), m;
788
+ }, r.shiftedBy = function(s) {
789
+ return F(s, -9007199254740991, je), this.times("1e" + s);
790
+ }, r.squareRoot = r.sqrt = function() {
791
+ var s, o, l, m, c, y = this, w = y.c, f = y.s, g = y.e, x = a + 4, d = new v("0.5");
792
+ if (f !== 1 || !w || !w[0])
793
+ return new v(!f || f < 0 && (!w || w[0]) ? NaN : w ? y : 1 / 0);
794
+ if (f = Math.sqrt(+re(y)), f == 0 || f == 1 / 0 ? (o = H(w), (o.length + g) % 2 == 0 && (o += "0"), f = Math.sqrt(+o), g = Q((g + 1) / 2) - (g < 0 || g % 2), f == 1 / 0 ? o = "5e" + g : (o = f.toExponential(), o = o.slice(0, o.indexOf("e") + 1) + g), l = new v(o)) : l = new v(f + ""), l.c[0]) {
795
+ for (g = l.e, f = g + x, f < 3 && (f = 0); ; )
796
+ if (c = l, l = d.times(c.plus(e(y, c, x, 1))), H(c.c).slice(0, f) === (o = H(l.c)).slice(0, f))
797
+ if (l.e < g && --f, o = o.slice(f - 3, f + 1), o == "9999" || !m && o == "4999") {
798
+ if (!m && (W(c, c.e + a + 2, 0), c.times(c).eq(y))) {
799
+ l = c;
800
+ break;
801
+ }
802
+ x += 4, f += 4, m = 1;
803
+ } else {
804
+ (!+o || !+o.slice(1) && o.charAt(0) == "5") && (W(l, l.e + a + 2, 1), s = !l.times(l).eq(y));
805
+ break;
806
+ }
807
+ }
808
+ return W(l, l.e + a + 1, h, s);
809
+ }, r.toExponential = function(s, o) {
810
+ return s != null && (F(s, 0, Y), s++), N(this, s, o, 1);
811
+ }, r.toFixed = function(s, o) {
812
+ return s != null && (F(s, 0, Y), s = s + this.e + 1), N(this, s, o);
813
+ }, r.toFormat = function(s, o, l) {
814
+ var m, c = this;
815
+ if (l == null)
816
+ s != null && o && typeof o == "object" ? (l = o, o = null) : s && typeof s == "object" ? (l = s, s = o = null) : l = B;
817
+ else if (typeof l != "object")
818
+ throw Error(Z + "Argument not an object: " + l);
819
+ if (m = c.toFixed(s, o), c.c) {
820
+ var y, w = m.split("."), f = +l.groupSize, g = +l.secondaryGroupSize, x = l.groupSeparator || "", d = w[0], S = w[1], P = c.s < 0, O = P ? d.slice(1) : d, k = O.length;
821
+ if (g && (y = f, f = g, g = y, k -= y), f > 0 && k > 0) {
822
+ for (y = k % f || f, d = O.substr(0, y); y < k; y += f) d += x + O.substr(y, f);
823
+ g > 0 && (d += x + O.slice(y)), P && (d = "-" + d);
824
+ }
825
+ m = S ? d + (l.decimalSeparator || "") + ((g = +l.fractionGroupSize) ? S.replace(
826
+ new RegExp("\\d{" + g + "}\\B", "g"),
827
+ "$&" + (l.fractionGroupSeparator || "")
828
+ ) : S) : d;
829
+ }
830
+ return (l.prefix || "") + m + (l.suffix || "");
831
+ }, r.toFraction = function(s) {
832
+ var o, l, m, c, y, w, f, g, x, d, S, P, O = this, k = O.c;
833
+ if (s != null && (f = new v(s), !f.isInteger() && (f.c || f.s !== 1) || f.lt(u)))
834
+ throw Error(Z + "Argument " + (f.isInteger() ? "out of range: " : "not an integer: ") + re(f));
835
+ if (!k) return new v(O);
836
+ for (o = new v(u), x = l = new v(u), m = g = new v(u), P = H(k), y = o.e = P.length - O.e - 1, o.c[0] = Ge[(w = y % R) < 0 ? R + w : w], s = !s || f.comparedTo(o) > 0 ? y > 0 ? o : x : f, w = b, b = 1 / 0, f = new v(P), g.c[0] = 0; d = e(f, o, 0, 1), c = l.plus(d.times(m)), c.comparedTo(s) != 1; )
837
+ l = m, m = c, x = g.plus(d.times(c = x)), g = c, o = f.minus(d.times(c = o)), f = c;
838
+ return c = e(s.minus(l), m, 0, 1), g = g.plus(c.times(x)), l = l.plus(c.times(m)), g.s = x.s = O.s, y = y * 2, S = e(x, m, y, h).minus(O).abs().comparedTo(
839
+ e(g, l, y, h).minus(O).abs()
840
+ ) < 1 ? [x, m] : [g, l], b = w, S;
841
+ }, r.toNumber = function() {
842
+ return +re(this);
843
+ }, r.toPrecision = function(s, o) {
844
+ return s != null && F(s, 1, Y), N(this, s, o, 2);
845
+ }, r.toString = function(s) {
846
+ var o, l = this, m = l.s, c = l.e;
847
+ return c === null ? m ? (o = "Infinity", m < 0 && (o = "-" + o)) : o = "NaN" : (s == null ? o = c <= E || c >= p ? Te(H(l.c), c) : se(H(l.c), c, "0") : s === 10 && I ? (l = W(new v(l), a + c + 1, h), o = se(H(l.c), l.e, "0")) : (F(s, 2, q.length, "Base"), o = n(se(H(l.c), c, "0"), 10, s, m, !0)), m < 0 && l.c[0] && (o = "-" + o)), o;
848
+ }, r.valueOf = r.toJSON = function() {
849
+ return re(this);
850
+ }, r._isBigNumber = !0, r[Symbol.toStringTag] = "BigNumber", r[Symbol.for("nodejs.util.inspect.custom")] = r.valueOf, t != null && v.set(t), v;
851
+ }
852
+ function Q(t) {
853
+ var e = t | 0;
854
+ return t > 0 || t === e ? e : e - 1;
855
+ }
856
+ function H(t) {
857
+ for (var e, n, i = 1, r = t.length, u = t[0] + ""; i < r; ) {
858
+ for (e = t[i++] + "", n = R - e.length; n--; e = "0" + e) ;
859
+ u += e;
860
+ }
861
+ for (r = u.length; u.charCodeAt(--r) === 48; ) ;
862
+ return u.slice(0, r + 1 || 1);
863
+ }
864
+ function fe(t, e) {
865
+ var n, i, r = t.c, u = e.c, a = t.s, h = e.s, E = t.e, p = e.e;
866
+ if (!a || !h) return null;
867
+ if (n = r && !r[0], i = u && !u[0], n || i) return n ? i ? 0 : -h : a;
868
+ if (a != h) return a;
869
+ if (n = a < 0, i = E == p, !r || !u) return i ? 0 : !r ^ n ? 1 : -1;
870
+ if (!i) return E > p ^ n ? 1 : -1;
871
+ for (h = (E = r.length) < (p = u.length) ? E : p, a = 0; a < h; a++) if (r[a] != u[a]) return r[a] > u[a] ^ n ? 1 : -1;
872
+ return E == p ? 0 : E > p ^ n ? 1 : -1;
873
+ }
874
+ function F(t, e, n, i) {
875
+ if (t < e || t > n || t !== j(t))
876
+ throw Error(Z + (i || "Argument") + (typeof t == "number" ? t < e || t > n ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(t));
877
+ }
878
+ function _e(t) {
879
+ var e = t.c.length - 1;
880
+ return Q(t.e / R) == e && t.c[e] % 2 != 0;
881
+ }
882
+ function Te(t, e) {
883
+ return (t.length > 1 ? t.charAt(0) + "." + t.slice(1) : t) + (e < 0 ? "e" : "e+") + e;
884
+ }
885
+ function se(t, e, n) {
886
+ var i, r;
887
+ if (e < 0) {
888
+ for (r = n + "."; ++e; r += n) ;
889
+ t = r + t;
890
+ } else if (i = t.length, ++e > i) {
891
+ for (r = n, e -= i; --e; r += n) ;
892
+ t += r;
893
+ } else e < i && (t = t.slice(0, e) + "." + t.slice(e));
894
+ return t;
895
+ }
896
+ var ie = wt(), Gt = class {
897
+ constructor(t) {
898
+ C(this, "key");
899
+ C(this, "left", null);
900
+ C(this, "right", null);
901
+ this.key = t;
647
902
  }
648
- return null;
649
- }
650
- function de(r, t, e) {
651
- for (var n = new F(null, null), i = n, o = r, u = t; o !== null && u !== null; )
652
- e(o.key, u.key) < 0 ? (i.next = o, o = o.next) : (i.next = u, u = u.next), i = i.next;
653
- return o !== null ? i.next = o : u !== null && (i.next = u), n.next;
654
- }
655
- function at(r, t, e, n, i) {
656
- if (!(e >= n)) {
657
- for (var o = r[e + n >> 1], u = e - 1, l = n + 1; ; ) {
658
- do
659
- u++;
660
- while (i(r[u], o) < 0);
661
- do
662
- l--;
663
- while (i(r[l], o) > 0);
664
- if (u >= l)
903
+ }, ye = class extends Gt {
904
+ constructor(t) {
905
+ super(t);
906
+ }
907
+ }, $t = class {
908
+ constructor() {
909
+ C(this, "size", 0);
910
+ C(this, "modificationCount", 0);
911
+ C(this, "splayCount", 0);
912
+ }
913
+ splay(t) {
914
+ const e = this.root;
915
+ if (e == null)
916
+ return this.compare(t, t), -1;
917
+ let n = null, i = null, r = null, u = null, a = e;
918
+ const h = this.compare;
919
+ let E;
920
+ for (; ; )
921
+ if (E = h(a.key, t), E > 0) {
922
+ let p = a.left;
923
+ if (p == null || (E = h(p.key, t), E > 0 && (a.left = p.right, p.right = a, a = p, p = a.left, p == null)))
924
+ break;
925
+ n == null ? i = a : n.left = a, n = a, a = p;
926
+ } else if (E < 0) {
927
+ let p = a.right;
928
+ if (p == null || (E = h(p.key, t), E < 0 && (a.right = p.left, p.left = a, a = p, p = a.right, p == null)))
929
+ break;
930
+ r == null ? u = a : r.right = a, r = a, a = p;
931
+ } else
665
932
  break;
666
- var c = r[u];
667
- r[u] = r[l], r[l] = c, c = t[u], t[u] = t[l], t[l] = c;
933
+ return r != null && (r.right = a.left, a.left = u), n != null && (n.left = a.right, a.right = i), this.root !== a && (this.root = a, this.splayCount++), E;
934
+ }
935
+ splayMin(t) {
936
+ let e = t, n = e.left;
937
+ for (; n != null; ) {
938
+ const i = n;
939
+ e.left = i.right, i.right = e, e = i, n = e.left;
668
940
  }
669
- at(r, t, e, l, i), at(r, t, l + 1, n, i);
941
+ return e;
670
942
  }
671
- }
672
- const O = 11102230246251565e-32, S = 134217729, xe = (3 + 8 * O) * O;
673
- function st(r, t, e, n, i) {
674
- let o, u, l, c, f = t[0], p = n[0], s = 0, a = 0;
675
- p > f == p > -f ? (o = f, f = t[++s]) : (o = p, p = n[++a]);
676
- let h = 0;
677
- if (s < r && a < e)
678
- for (p > f == p > -f ? (u = f + o, l = o - (u - f), f = t[++s]) : (u = p + o, l = o - (u - p), p = n[++a]), o = u, l !== 0 && (i[h++] = l); s < r && a < e; )
679
- p > f == p > -f ? (u = o + f, c = u - o, l = o - (u - c) + (f - c), f = t[++s]) : (u = o + p, c = u - o, l = o - (u - c) + (p - c), p = n[++a]), o = u, l !== 0 && (i[h++] = l);
680
- for (; s < r; )
681
- u = o + f, c = u - o, l = o - (u - c) + (f - c), f = t[++s], o = u, l !== 0 && (i[h++] = l);
682
- for (; a < e; )
683
- u = o + p, c = u - o, l = o - (u - c) + (p - c), p = n[++a], o = u, l !== 0 && (i[h++] = l);
684
- return (o !== 0 || h === 0) && (i[h++] = o), h;
685
- }
686
- function ve(r, t) {
687
- let e = t[0];
688
- for (let n = 1; n < r; n++) e += t[n];
689
- return e;
690
- }
691
- function K(r) {
692
- return new Float64Array(r);
693
- }
694
- const me = (3 + 16 * O) * O, we = (2 + 12 * O) * O, be = (9 + 64 * O) * O * O, q = K(4), _t = K(8), St = K(12), Pt = K(16), P = K(4);
695
- function Ee(r, t, e, n, i, o, u) {
696
- let l, c, f, p, s, a, h, g, d, w, y, v, x, m, b, E, M, _;
697
- const C = r - i, R = e - i, I = t - o, $ = n - o;
698
- m = C * $, a = S * C, h = a - (a - C), g = C - h, a = S * $, d = a - (a - $), w = $ - d, b = g * w - (m - h * d - g * d - h * w), E = I * R, a = S * I, h = a - (a - I), g = I - h, a = S * R, d = a - (a - R), w = R - d, M = g * w - (E - h * d - g * d - h * w), y = b - M, s = b - y, q[0] = b - (y + s) + (s - M), v = m + y, s = v - m, x = m - (v - s) + (y - s), y = x - E, s = x - y, q[1] = x - (y + s) + (s - E), _ = v + y, s = _ - v, q[2] = v - (_ - s) + (y - s), q[3] = _;
699
- let A = ve(4, q), D = we * u;
700
- if (A >= D || -A >= D || (s = r - C, l = r - (C + s) + (s - i), s = e - R, f = e - (R + s) + (s - i), s = t - I, c = t - (I + s) + (s - o), s = n - $, p = n - ($ + s) + (s - o), l === 0 && c === 0 && f === 0 && p === 0) || (D = be * u + xe * Math.abs(A), A += C * p + $ * l - (I * f + R * c), A >= D || -A >= D)) return A;
701
- m = l * $, a = S * l, h = a - (a - l), g = l - h, a = S * $, d = a - (a - $), w = $ - d, b = g * w - (m - h * d - g * d - h * w), E = c * R, a = S * c, h = a - (a - c), g = c - h, a = S * R, d = a - (a - R), w = R - d, M = g * w - (E - h * d - g * d - h * w), y = b - M, s = b - y, P[0] = b - (y + s) + (s - M), v = m + y, s = v - m, x = m - (v - s) + (y - s), y = x - E, s = x - y, P[1] = x - (y + s) + (s - E), _ = v + y, s = _ - v, P[2] = v - (_ - s) + (y - s), P[3] = _;
702
- const ee = st(4, q, 4, P, _t);
703
- m = C * p, a = S * C, h = a - (a - C), g = C - h, a = S * p, d = a - (a - p), w = p - d, b = g * w - (m - h * d - g * d - h * w), E = I * f, a = S * I, h = a - (a - I), g = I - h, a = S * f, d = a - (a - f), w = f - d, M = g * w - (E - h * d - g * d - h * w), y = b - M, s = b - y, P[0] = b - (y + s) + (s - M), v = m + y, s = v - m, x = m - (v - s) + (y - s), y = x - E, s = x - y, P[1] = x - (y + s) + (s - E), _ = v + y, s = _ - v, P[2] = v - (_ - s) + (y - s), P[3] = _;
704
- const ne = st(ee, _t, 4, P, St);
705
- m = l * p, a = S * l, h = a - (a - l), g = l - h, a = S * p, d = a - (a - p), w = p - d, b = g * w - (m - h * d - g * d - h * w), E = c * f, a = S * c, h = a - (a - c), g = c - h, a = S * f, d = a - (a - f), w = f - d, M = g * w - (E - h * d - g * d - h * w), y = b - M, s = b - y, P[0] = b - (y + s) + (s - M), v = m + y, s = v - m, x = m - (v - s) + (y - s), y = x - E, s = x - y, P[1] = x - (y + s) + (s - E), _ = v + y, s = _ - v, P[2] = v - (_ - s) + (y - s), P[3] = _;
706
- const re = st(ne, St, 4, P, Pt);
707
- return Pt[re - 1];
708
- }
709
- function _e(r, t, e, n, i, o) {
710
- const u = (t - o) * (e - i), l = (r - i) * (n - o), c = u - l, f = Math.abs(u + l);
711
- return Math.abs(c) >= me * f ? c : -Ee(r, t, e, n, i, o, f);
712
- }
713
- const j = (r, t) => r.ll.x <= t.x && t.x <= r.ur.x && r.ll.y <= t.y && t.y <= r.ur.y, pt = (r, t) => {
714
- if (t.ur.x < r.ll.x || r.ur.x < t.ll.x || t.ur.y < r.ll.y || r.ur.y < t.ll.y) return null;
715
- const e = r.ll.x < t.ll.x ? t.ll.x : r.ll.x, n = r.ur.x < t.ur.x ? r.ur.x : t.ur.x, i = r.ll.y < t.ll.y ? t.ll.y : r.ll.y, o = r.ur.y < t.ur.y ? r.ur.y : t.ur.y;
716
- return {
717
- ll: {
718
- x: e,
719
- y: i
720
- },
721
- ur: {
722
- x: n,
723
- y: o
943
+ splayMax(t) {
944
+ let e = t, n = e.right;
945
+ for (; n != null; ) {
946
+ const i = n;
947
+ e.right = i.left, i.left = e, e = i, n = e.right;
724
948
  }
725
- };
726
- };
727
- let G = Number.EPSILON;
728
- G === void 0 && (G = Math.pow(2, -52));
729
- const Se = G * G, Mt = (r, t) => {
730
- if (-G < r && r < G && -G < t && t < G)
731
- return 0;
732
- const e = r - t;
733
- return e * e < Se * r * t ? 0 : r < t ? -1 : 1;
734
- };
735
- class Pe {
736
- constructor() {
737
- this.reset();
949
+ return e;
950
+ }
951
+ _delete(t) {
952
+ if (this.root == null || this.splay(t) != 0) return null;
953
+ let n = this.root;
954
+ const i = n, r = n.left;
955
+ if (this.size--, r == null)
956
+ this.root = n.right;
957
+ else {
958
+ const u = n.right;
959
+ n = this.splayMax(r), n.right = u, this.root = n;
960
+ }
961
+ return this.modificationCount++, i;
962
+ }
963
+ addNewRoot(t, e) {
964
+ this.size++, this.modificationCount++;
965
+ const n = this.root;
966
+ if (n == null) {
967
+ this.root = t;
968
+ return;
969
+ }
970
+ e < 0 ? (t.left = n, t.right = n.right, n.right = null) : (t.right = n, t.left = n.left, n.left = null), this.root = t;
971
+ }
972
+ _first() {
973
+ const t = this.root;
974
+ return t == null ? null : (this.root = this.splayMin(t), this.root);
975
+ }
976
+ _last() {
977
+ const t = this.root;
978
+ return t == null ? null : (this.root = this.splayMax(t), this.root);
979
+ }
980
+ clear() {
981
+ this.root = null, this.size = 0, this.modificationCount++;
982
+ }
983
+ has(t) {
984
+ return this.validKey(t) && this.splay(t) == 0;
738
985
  }
739
- reset() {
740
- this.xRounder = new Lt(), this.yRounder = new Lt();
986
+ defaultCompare() {
987
+ return (t, e) => t < e ? -1 : t > e ? 1 : 0;
741
988
  }
742
- round(t, e) {
989
+ wrap() {
743
990
  return {
744
- x: this.xRounder.round(t),
745
- y: this.yRounder.round(e)
991
+ getRoot: () => this.root,
992
+ setRoot: (t) => {
993
+ this.root = t;
994
+ },
995
+ getSize: () => this.size,
996
+ getModificationCount: () => this.modificationCount,
997
+ getSplayCount: () => this.splayCount,
998
+ setSplayCount: (t) => {
999
+ this.splayCount = t;
1000
+ },
1001
+ splay: (t) => this.splay(t),
1002
+ has: (t) => this.has(t)
746
1003
  };
747
1004
  }
748
- }
749
- class Lt {
750
- constructor() {
751
- this.tree = new wt(), this.round(0);
752
- }
753
- // Note: this can rounds input values backwards or forwards.
754
- // You might ask, why not restrict this to just rounding
755
- // forwards? Wouldn't that allow left endpoints to always
756
- // remain left endpoints during splitting (never change to
757
- // right). No - it wouldn't, because we snap intersections
758
- // to endpoints (to establish independence from the segment
759
- // angle for t-intersections).
760
- round(t) {
761
- const e = this.tree.add(t), n = this.tree.prev(e);
762
- if (n !== null && Mt(e.key, n.key) === 0)
763
- return this.tree.remove(t), n.key;
764
- const i = this.tree.next(e);
765
- return i !== null && Mt(e.key, i.key) === 0 ? (this.tree.remove(t), i.key) : t;
1005
+ }, ht, pt, Pe = class me extends $t {
1006
+ constructor(n, i) {
1007
+ super();
1008
+ C(this, "root", null);
1009
+ C(this, "compare");
1010
+ C(this, "validKey");
1011
+ C(this, ht, "[object Set]");
1012
+ this.compare = n ?? this.defaultCompare(), this.validKey = i ?? ((r) => r != null && r != null);
1013
+ }
1014
+ delete(n) {
1015
+ return this.validKey(n) ? this._delete(n) != null : !1;
1016
+ }
1017
+ deleteAll(n) {
1018
+ for (const i of n)
1019
+ this.delete(i);
1020
+ }
1021
+ forEach(n) {
1022
+ const i = this[Symbol.iterator]();
1023
+ let r;
1024
+ for (; r = i.next(), !r.done; )
1025
+ n(r.value, r.value, this);
1026
+ }
1027
+ add(n) {
1028
+ const i = this.splay(n);
1029
+ return i != 0 && this.addNewRoot(new ye(n), i), this;
1030
+ }
1031
+ addAndReturn(n) {
1032
+ const i = this.splay(n);
1033
+ return i != 0 && this.addNewRoot(new ye(n), i), this.root.key;
1034
+ }
1035
+ addAll(n) {
1036
+ for (const i of n)
1037
+ this.add(i);
1038
+ }
1039
+ isEmpty() {
1040
+ return this.root == null;
1041
+ }
1042
+ isNotEmpty() {
1043
+ return this.root != null;
1044
+ }
1045
+ single() {
1046
+ if (this.size == 0) throw "Bad state: No element";
1047
+ if (this.size > 1) throw "Bad state: Too many element";
1048
+ return this.root.key;
1049
+ }
1050
+ first() {
1051
+ if (this.size == 0) throw "Bad state: No element";
1052
+ return this._first().key;
1053
+ }
1054
+ last() {
1055
+ if (this.size == 0) throw "Bad state: No element";
1056
+ return this._last().key;
1057
+ }
1058
+ lastBefore(n) {
1059
+ if (n == null) throw "Invalid arguments(s)";
1060
+ if (this.root == null) return null;
1061
+ if (this.splay(n) < 0) return this.root.key;
1062
+ let r = this.root.left;
1063
+ if (r == null) return null;
1064
+ let u = r.right;
1065
+ for (; u != null; )
1066
+ r = u, u = r.right;
1067
+ return r.key;
1068
+ }
1069
+ firstAfter(n) {
1070
+ if (n == null) throw "Invalid arguments(s)";
1071
+ if (this.root == null) return null;
1072
+ if (this.splay(n) > 0) return this.root.key;
1073
+ let r = this.root.right;
1074
+ if (r == null) return null;
1075
+ let u = r.left;
1076
+ for (; u != null; )
1077
+ r = u, u = r.left;
1078
+ return r.key;
1079
+ }
1080
+ retainAll(n) {
1081
+ const i = new me(this.compare, this.validKey), r = this.modificationCount;
1082
+ for (const u of n) {
1083
+ if (r != this.modificationCount)
1084
+ throw "Concurrent modification during iteration.";
1085
+ this.validKey(u) && this.splay(u) == 0 && i.add(this.root.key);
1086
+ }
1087
+ i.size != this.size && (this.root = i.root, this.size = i.size, this.modificationCount++);
1088
+ }
1089
+ lookup(n) {
1090
+ return !this.validKey(n) || this.splay(n) != 0 ? null : this.root.key;
1091
+ }
1092
+ intersection(n) {
1093
+ const i = new me(this.compare, this.validKey);
1094
+ for (const r of this)
1095
+ n.has(r) && i.add(r);
1096
+ return i;
1097
+ }
1098
+ difference(n) {
1099
+ const i = new me(this.compare, this.validKey);
1100
+ for (const r of this)
1101
+ n.has(r) || i.add(r);
1102
+ return i;
1103
+ }
1104
+ union(n) {
1105
+ const i = this.clone();
1106
+ return i.addAll(n), i;
1107
+ }
1108
+ clone() {
1109
+ const n = new me(this.compare, this.validKey);
1110
+ return n.size = this.size, n.root = this.copyNode(this.root), n;
1111
+ }
1112
+ copyNode(n) {
1113
+ if (n == null) return null;
1114
+ function i(u, a) {
1115
+ let h, E;
1116
+ do {
1117
+ if (h = u.left, E = u.right, h != null) {
1118
+ const p = new ye(h.key);
1119
+ a.left = p, i(h, p);
1120
+ }
1121
+ if (E != null) {
1122
+ const p = new ye(E.key);
1123
+ a.right = p, u = E, a = p;
1124
+ }
1125
+ } while (E != null);
1126
+ }
1127
+ const r = new ye(n.key);
1128
+ return i(n, r), r;
766
1129
  }
767
- }
768
- const J = new Pe(), tt = (r, t) => r.x * t.y - r.y * t.x, Vt = (r, t) => r.x * t.x + r.y * t.y, Ct = (r, t, e) => {
769
- const n = _e(r.x, r.y, t.x, t.y, e.x, e.y);
770
- return n > 0 ? -1 : n < 0 ? 1 : 0;
771
- }, et = (r) => Math.sqrt(Vt(r, r)), Me = (r, t, e) => {
772
- const n = {
773
- x: t.x - r.x,
774
- y: t.y - r.y
775
- }, i = {
776
- x: e.x - r.x,
777
- y: e.y - r.y
778
- };
779
- return tt(i, n) / et(i) / et(n);
780
- }, Le = (r, t, e) => {
781
- const n = {
782
- x: t.x - r.x,
783
- y: t.y - r.y
784
- }, i = {
785
- x: e.x - r.x,
786
- y: e.y - r.y
787
- };
788
- return Vt(i, n) / et(i) / et(n);
789
- }, Rt = (r, t, e) => t.y === 0 ? null : {
790
- x: r.x + t.x / t.y * (e - r.y),
791
- y: e
792
- }, It = (r, t, e) => t.x === 0 ? null : {
793
- x: e,
794
- y: r.y + t.y / t.x * (e - r.x)
795
- }, Ce = (r, t, e, n) => {
796
- if (t.x === 0) return It(e, n, r.x);
797
- if (n.x === 0) return It(r, t, e.x);
798
- if (t.y === 0) return Rt(e, n, r.y);
799
- if (n.y === 0) return Rt(r, t, e.y);
800
- const i = tt(t, n);
801
- if (i == 0) return null;
802
- const o = {
803
- x: e.x - r.x,
804
- y: e.y - r.y
805
- }, u = tt(o, t) / i, l = tt(o, n) / i, c = r.x + l * t.x, f = e.x + u * n.x, p = r.y + l * t.y, s = e.y + u * n.y, a = (c + f) / 2, h = (p + s) / 2;
806
- return {
807
- x: a,
808
- y: h
809
- };
1130
+ toSet() {
1131
+ return this.clone();
1132
+ }
1133
+ entries() {
1134
+ return new Ft(this.wrap());
1135
+ }
1136
+ keys() {
1137
+ return this[Symbol.iterator]();
1138
+ }
1139
+ values() {
1140
+ return this[Symbol.iterator]();
1141
+ }
1142
+ [(pt = Symbol.iterator, ht = Symbol.toStringTag, pt)]() {
1143
+ return new qt(this.wrap());
1144
+ }
1145
+ }, Et = class {
1146
+ constructor(t) {
1147
+ C(this, "tree");
1148
+ C(this, "path", new Array());
1149
+ C(this, "modificationCount", null);
1150
+ C(this, "splayCount");
1151
+ this.tree = t, this.splayCount = t.getSplayCount();
1152
+ }
1153
+ [Symbol.iterator]() {
1154
+ return this;
1155
+ }
1156
+ next() {
1157
+ return this.moveNext() ? { done: !1, value: this.current() } : { done: !0, value: null };
1158
+ }
1159
+ current() {
1160
+ if (!this.path.length) return null;
1161
+ const t = this.path[this.path.length - 1];
1162
+ return this.getValue(t);
1163
+ }
1164
+ rebuildPath(t) {
1165
+ this.path.splice(0, this.path.length), this.tree.splay(t), this.path.push(this.tree.getRoot()), this.splayCount = this.tree.getSplayCount();
1166
+ }
1167
+ findLeftMostDescendent(t) {
1168
+ for (; t != null; )
1169
+ this.path.push(t), t = t.left;
1170
+ }
1171
+ moveNext() {
1172
+ if (this.modificationCount != this.tree.getModificationCount()) {
1173
+ if (this.modificationCount == null) {
1174
+ this.modificationCount = this.tree.getModificationCount();
1175
+ let n = this.tree.getRoot();
1176
+ for (; n != null; )
1177
+ this.path.push(n), n = n.left;
1178
+ return this.path.length > 0;
1179
+ }
1180
+ throw "Concurrent modification during iteration.";
1181
+ }
1182
+ if (!this.path.length) return !1;
1183
+ this.splayCount != this.tree.getSplayCount() && this.rebuildPath(this.path[this.path.length - 1].key);
1184
+ let t = this.path[this.path.length - 1], e = t.right;
1185
+ if (e != null) {
1186
+ for (; e != null; )
1187
+ this.path.push(e), e = e.left;
1188
+ return !0;
1189
+ }
1190
+ for (this.path.pop(); this.path.length && this.path[this.path.length - 1].right === t; )
1191
+ t = this.path.pop();
1192
+ return this.path.length > 0;
1193
+ }
1194
+ }, qt = class extends Et {
1195
+ getValue(t) {
1196
+ return t.key;
1197
+ }
1198
+ }, Ft = class extends Et {
1199
+ getValue(t) {
1200
+ return [t.key, t.key];
1201
+ }
1202
+ }, vt = (t) => () => t, Fe = (t) => {
1203
+ const e = t ? (n, i) => i.minus(n).abs().isLessThanOrEqualTo(t) : vt(!1);
1204
+ return (n, i) => e(n, i) ? 0 : n.comparedTo(i);
810
1205
  };
811
- class L {
1206
+ function Dt(t) {
1207
+ const e = t ? (n, i, r, u, a) => n.exponentiatedBy(2).isLessThanOrEqualTo(
1208
+ u.minus(i).exponentiatedBy(2).plus(a.minus(r).exponentiatedBy(2)).times(t)
1209
+ ) : vt(!1);
1210
+ return (n, i, r) => {
1211
+ const u = n.x, a = n.y, h = r.x, E = r.y, p = a.minus(E).times(i.x.minus(h)).minus(u.minus(h).times(i.y.minus(E)));
1212
+ return e(p, u, a, h, E) ? 0 : p.comparedTo(0);
1213
+ };
1214
+ }
1215
+ var zt = (t) => t, Ut = (t) => {
1216
+ if (t) {
1217
+ const e = new Pe(Fe(t)), n = new Pe(Fe(t)), i = (u, a) => a.addAndReturn(u), r = (u) => ({
1218
+ x: i(u.x, e),
1219
+ y: i(u.y, n)
1220
+ });
1221
+ return r({ x: new ie(0), y: new ie(0) }), r;
1222
+ }
1223
+ return zt;
1224
+ }, De = (t) => ({
1225
+ set: (e) => {
1226
+ oe = De(e);
1227
+ },
1228
+ reset: () => De(t),
1229
+ compare: Fe(t),
1230
+ snap: Ut(t),
1231
+ orient: Dt(t)
1232
+ }), oe = De(), de = (t, e) => t.ll.x.isLessThanOrEqualTo(e.x) && e.x.isLessThanOrEqualTo(t.ur.x) && t.ll.y.isLessThanOrEqualTo(e.y) && e.y.isLessThanOrEqualTo(t.ur.y), ze = (t, e) => {
1233
+ if (e.ur.x.isLessThan(t.ll.x) || t.ur.x.isLessThan(e.ll.x) || e.ur.y.isLessThan(t.ll.y) || t.ur.y.isLessThan(e.ll.y))
1234
+ return null;
1235
+ const n = t.ll.x.isLessThan(e.ll.x) ? e.ll.x : t.ll.x, i = t.ur.x.isLessThan(e.ur.x) ? t.ur.x : e.ur.x, r = t.ll.y.isLessThan(e.ll.y) ? e.ll.y : t.ll.y, u = t.ur.y.isLessThan(e.ur.y) ? t.ur.y : e.ur.y;
1236
+ return { ll: { x: n, y: r }, ur: { x: i, y: u } };
1237
+ }, Me = (t, e) => t.x.times(e.y).minus(t.y.times(e.x)), St = (t, e) => t.x.times(e.x).plus(t.y.times(e.y)), Oe = (t) => St(t, t).sqrt(), Vt = (t, e, n) => {
1238
+ const i = { x: e.x.minus(t.x), y: e.y.minus(t.y) }, r = { x: n.x.minus(t.x), y: n.y.minus(t.y) };
1239
+ return Me(r, i).div(Oe(r)).div(Oe(i));
1240
+ }, Kt = (t, e, n) => {
1241
+ const i = { x: e.x.minus(t.x), y: e.y.minus(t.y) }, r = { x: n.x.minus(t.x), y: n.y.minus(t.y) };
1242
+ return St(r, i).div(Oe(r)).div(Oe(i));
1243
+ }, Qe = (t, e, n) => e.y.isZero() ? null : { x: t.x.plus(e.x.div(e.y).times(n.minus(t.y))), y: n }, et = (t, e, n) => e.x.isZero() ? null : { x: n, y: t.y.plus(e.y.div(e.x).times(n.minus(t.x))) }, Xt = (t, e, n, i) => {
1244
+ if (e.x.isZero()) return et(n, i, t.x);
1245
+ if (i.x.isZero()) return et(t, e, n.x);
1246
+ if (e.y.isZero()) return Qe(n, i, t.y);
1247
+ if (i.y.isZero()) return Qe(t, e, n.y);
1248
+ const r = Me(e, i);
1249
+ if (r.isZero()) return null;
1250
+ const u = { x: n.x.minus(t.x), y: n.y.minus(t.y) }, a = Me(u, e).div(r), h = Me(u, i).div(r), E = t.x.plus(h.times(e.x)), p = n.x.plus(a.times(i.x)), _ = t.y.plus(h.times(e.y)), b = n.y.plus(a.times(i.y)), M = E.plus(p).div(2), T = _.plus(b).div(2);
1251
+ return { x: M, y: T };
1252
+ }, ne = class bt {
1253
+ // Warning: 'point' input will be modified and re-used (for performance)
1254
+ constructor(e, n) {
1255
+ C(this, "point");
1256
+ C(this, "isLeft");
1257
+ C(this, "segment");
1258
+ C(this, "otherSE");
1259
+ C(this, "consumedBy");
1260
+ e.events === void 0 ? e.events = [this] : e.events.push(this), this.point = e, this.isLeft = n;
1261
+ }
812
1262
  // for ordering sweep events in the sweep event queue
813
- static compare(t, e) {
814
- const n = L.comparePoints(t.point, e.point);
815
- return n !== 0 ? n : (t.point !== e.point && t.link(e), t.isLeft !== e.isLeft ? t.isLeft ? 1 : -1 : z.compare(t.segment, e.segment));
1263
+ static compare(e, n) {
1264
+ const i = bt.comparePoints(e.point, n.point);
1265
+ return i !== 0 ? i : (e.point !== n.point && e.link(n), e.isLeft !== n.isLeft ? e.isLeft ? 1 : -1 : Ne.compare(e.segment, n.segment));
816
1266
  }
817
1267
  // for ordering points in sweep line order
818
- static comparePoints(t, e) {
819
- return t.x < e.x ? -1 : t.x > e.x ? 1 : t.y < e.y ? -1 : t.y > e.y ? 1 : 0;
820
- }
821
- // Warning: 'point' input will be modified and re-used (for performance)
822
- constructor(t, e) {
823
- t.events === void 0 ? t.events = [this] : t.events.push(this), this.point = t, this.isLeft = e;
1268
+ static comparePoints(e, n) {
1269
+ return e.x.isLessThan(n.x) ? -1 : e.x.isGreaterThan(n.x) ? 1 : e.y.isLessThan(n.y) ? -1 : e.y.isGreaterThan(n.y) ? 1 : 0;
824
1270
  }
825
- link(t) {
826
- if (t.point === this.point)
1271
+ link(e) {
1272
+ if (e.point === this.point)
827
1273
  throw new Error("Tried to link already linked events");
828
- const e = t.point.events;
829
- for (let n = 0, i = e.length; n < i; n++) {
830
- const o = e[n];
831
- this.point.events.push(o), o.point = this.point;
1274
+ const n = e.point.events;
1275
+ for (let i = 0, r = n.length; i < r; i++) {
1276
+ const u = n[i];
1277
+ this.point.events.push(u), u.point = this.point;
832
1278
  }
833
1279
  this.checkForConsuming();
834
1280
  }
835
1281
  /* Do a pass over our linked events and check to see if any pair
836
1282
  * of segments match, and should be consumed. */
837
1283
  checkForConsuming() {
838
- const t = this.point.events.length;
839
- for (let e = 0; e < t; e++) {
840
- const n = this.point.events[e];
841
- if (n.segment.consumedBy === void 0)
842
- for (let i = e + 1; i < t; i++) {
843
- const o = this.point.events[i];
844
- o.consumedBy === void 0 && n.otherSE.point.events === o.otherSE.point.events && n.segment.consume(o.segment);
1284
+ const e = this.point.events.length;
1285
+ for (let n = 0; n < e; n++) {
1286
+ const i = this.point.events[n];
1287
+ if (i.segment.consumedBy === void 0)
1288
+ for (let r = n + 1; r < e; r++) {
1289
+ const u = this.point.events[r];
1290
+ u.consumedBy === void 0 && i.otherSE.point.events === u.otherSE.point.events && i.segment.consume(u.segment);
845
1291
  }
846
1292
  }
847
1293
  }
848
1294
  getAvailableLinkedEvents() {
849
- const t = [];
850
- for (let e = 0, n = this.point.events.length; e < n; e++) {
851
- const i = this.point.events[e];
852
- i !== this && !i.segment.ringOut && i.segment.isInResult() && t.push(i);
1295
+ const e = [];
1296
+ for (let n = 0, i = this.point.events.length; n < i; n++) {
1297
+ const r = this.point.events[n];
1298
+ r !== this && !r.segment.ringOut && r.segment.isInResult() && e.push(r);
853
1299
  }
854
- return t;
1300
+ return e;
855
1301
  }
856
1302
  /**
857
1303
  * Returns a comparator function for sorting linked events that will
@@ -863,29 +1309,303 @@ class L {
863
1309
  * The comparator function has a compute cache such that it avoids
864
1310
  * re-computing already-computed values.
865
1311
  */
866
- getLeftmostComparator(t) {
867
- const e = /* @__PURE__ */ new Map(), n = (i) => {
868
- const o = i.otherSE;
869
- e.set(i, {
870
- sine: Me(this.point, t.point, o.point),
871
- cosine: Le(this.point, t.point, o.point)
1312
+ getLeftmostComparator(e) {
1313
+ const n = /* @__PURE__ */ new Map(), i = (r) => {
1314
+ const u = r.otherSE;
1315
+ n.set(r, {
1316
+ sine: Vt(this.point, e.point, u.point),
1317
+ cosine: Kt(this.point, e.point, u.point)
872
1318
  });
873
1319
  };
874
- return (i, o) => {
875
- e.has(i) || n(i), e.has(o) || n(o);
876
- const {
877
- sine: u,
878
- cosine: l
879
- } = e.get(i), {
880
- sine: c,
881
- cosine: f
882
- } = e.get(o);
883
- return u >= 0 && c >= 0 ? l < f ? 1 : l > f ? -1 : 0 : u < 0 && c < 0 ? l < f ? -1 : l > f ? 1 : 0 : c < u ? -1 : c > u ? 1 : 0;
1320
+ return (r, u) => {
1321
+ n.has(r) || i(r), n.has(u) || i(u);
1322
+ const { sine: a, cosine: h } = n.get(r), { sine: E, cosine: p } = n.get(u);
1323
+ return a.isGreaterThanOrEqualTo(0) && E.isGreaterThanOrEqualTo(0) ? h.isLessThan(p) ? 1 : h.isGreaterThan(p) ? -1 : 0 : a.isLessThan(0) && E.isLessThan(0) ? h.isLessThan(p) ? -1 : h.isGreaterThan(p) ? 1 : 0 : E.isLessThan(a) ? -1 : E.isGreaterThan(a) ? 1 : 0;
884
1324
  };
885
1325
  }
886
- }
887
- let Re = 0;
888
- class z {
1326
+ }, Zt = class Ue {
1327
+ constructor(e) {
1328
+ C(this, "events");
1329
+ C(this, "poly");
1330
+ C(this, "_isExteriorRing");
1331
+ C(this, "_enclosingRing");
1332
+ this.events = e;
1333
+ for (let n = 0, i = e.length; n < i; n++)
1334
+ e[n].segment.ringOut = this;
1335
+ this.poly = null;
1336
+ }
1337
+ /* Given the segments from the sweep line pass, compute & return a series
1338
+ * of closed rings from all the segments marked to be part of the result */
1339
+ static factory(e) {
1340
+ const n = [];
1341
+ for (let i = 0, r = e.length; i < r; i++) {
1342
+ const u = e[i];
1343
+ if (!u.isInResult() || u.ringOut) continue;
1344
+ let a = null, h = u.leftSE, E = u.rightSE;
1345
+ const p = [h], _ = h.point, b = [];
1346
+ for (; a = h, h = E, p.push(h), h.point !== _; )
1347
+ for (; ; ) {
1348
+ const M = h.getAvailableLinkedEvents();
1349
+ if (M.length === 0) {
1350
+ const B = p[0].point, q = p[p.length - 1].point;
1351
+ throw new Error(
1352
+ `Unable to complete output ring starting at [${B.x}, ${B.y}]. Last matching segment found ends at [${q.x}, ${q.y}].`
1353
+ );
1354
+ }
1355
+ if (M.length === 1) {
1356
+ E = M[0].otherSE;
1357
+ break;
1358
+ }
1359
+ let T = null;
1360
+ for (let B = 0, q = b.length; B < q; B++)
1361
+ if (b[B].point === h.point) {
1362
+ T = B;
1363
+ break;
1364
+ }
1365
+ if (T !== null) {
1366
+ const B = b.splice(T)[0], q = p.splice(B.index);
1367
+ q.unshift(q[0].otherSE), n.push(new Ue(q.reverse()));
1368
+ continue;
1369
+ }
1370
+ b.push({
1371
+ index: p.length,
1372
+ point: h.point
1373
+ });
1374
+ const L = h.getLeftmostComparator(a);
1375
+ E = M.sort(L)[0].otherSE;
1376
+ break;
1377
+ }
1378
+ n.push(new Ue(p));
1379
+ }
1380
+ return n;
1381
+ }
1382
+ getGeom() {
1383
+ let e = this.events[0].point;
1384
+ const n = [e];
1385
+ for (let p = 1, _ = this.events.length - 1; p < _; p++) {
1386
+ const b = this.events[p].point, M = this.events[p + 1].point;
1387
+ oe.orient(b, e, M) !== 0 && (n.push(b), e = b);
1388
+ }
1389
+ if (n.length === 1) return null;
1390
+ const i = n[0], r = n[1];
1391
+ oe.orient(i, e, r) === 0 && n.shift(), n.push(n[0]);
1392
+ const u = this.isExteriorRing() ? 1 : -1, a = this.isExteriorRing() ? 0 : n.length - 1, h = this.isExteriorRing() ? n.length : -1, E = [];
1393
+ for (let p = a; p != h; p += u)
1394
+ E.push([n[p].x.toNumber(), n[p].y.toNumber()]);
1395
+ return E;
1396
+ }
1397
+ isExteriorRing() {
1398
+ if (this._isExteriorRing === void 0) {
1399
+ const e = this.enclosingRing();
1400
+ this._isExteriorRing = e ? !e.isExteriorRing() : !0;
1401
+ }
1402
+ return this._isExteriorRing;
1403
+ }
1404
+ enclosingRing() {
1405
+ return this._enclosingRing === void 0 && (this._enclosingRing = this._calcEnclosingRing()), this._enclosingRing;
1406
+ }
1407
+ /* Returns the ring that encloses this one, if any */
1408
+ _calcEnclosingRing() {
1409
+ var r, u;
1410
+ let e = this.events[0];
1411
+ for (let a = 1, h = this.events.length; a < h; a++) {
1412
+ const E = this.events[a];
1413
+ ne.compare(e, E) > 0 && (e = E);
1414
+ }
1415
+ let n = e.segment.prevInResult(), i = n ? n.prevInResult() : null;
1416
+ for (; ; ) {
1417
+ if (!n) return null;
1418
+ if (!i) return n.ringOut;
1419
+ if (i.ringOut !== n.ringOut)
1420
+ return ((r = i.ringOut) == null ? void 0 : r.enclosingRing()) !== n.ringOut ? n.ringOut : (u = n.ringOut) == null ? void 0 : u.enclosingRing();
1421
+ n = i.prevInResult(), i = n ? n.prevInResult() : null;
1422
+ }
1423
+ }
1424
+ }, tt = class {
1425
+ constructor(t) {
1426
+ C(this, "exteriorRing");
1427
+ C(this, "interiorRings");
1428
+ this.exteriorRing = t, t.poly = this, this.interiorRings = [];
1429
+ }
1430
+ addInterior(t) {
1431
+ this.interiorRings.push(t), t.poly = this;
1432
+ }
1433
+ getGeom() {
1434
+ const t = this.exteriorRing.getGeom();
1435
+ if (t === null) return null;
1436
+ const e = [t];
1437
+ for (let n = 0, i = this.interiorRings.length; n < i; n++) {
1438
+ const r = this.interiorRings[n].getGeom();
1439
+ r !== null && e.push(r);
1440
+ }
1441
+ return e;
1442
+ }
1443
+ }, Yt = class {
1444
+ constructor(t) {
1445
+ C(this, "rings");
1446
+ C(this, "polys");
1447
+ this.rings = t, this.polys = this._composePolys(t);
1448
+ }
1449
+ getGeom() {
1450
+ const t = [];
1451
+ for (let e = 0, n = this.polys.length; e < n; e++) {
1452
+ const i = this.polys[e].getGeom();
1453
+ i !== null && t.push(i);
1454
+ }
1455
+ return t;
1456
+ }
1457
+ _composePolys(t) {
1458
+ var n;
1459
+ const e = [];
1460
+ for (let i = 0, r = t.length; i < r; i++) {
1461
+ const u = t[i];
1462
+ if (!u.poly)
1463
+ if (u.isExteriorRing()) e.push(new tt(u));
1464
+ else {
1465
+ const a = u.enclosingRing();
1466
+ a != null && a.poly || e.push(new tt(a)), (n = a == null ? void 0 : a.poly) == null || n.addInterior(u);
1467
+ }
1468
+ }
1469
+ return e;
1470
+ }
1471
+ }, Wt = class {
1472
+ constructor(t, e = Ne.compare) {
1473
+ C(this, "queue");
1474
+ C(this, "tree");
1475
+ C(this, "segments");
1476
+ this.queue = t, this.tree = new Pe(e), this.segments = [];
1477
+ }
1478
+ process(t) {
1479
+ const e = t.segment, n = [];
1480
+ if (t.consumedBy)
1481
+ return t.isLeft ? this.queue.delete(t.otherSE) : this.tree.delete(e), n;
1482
+ t.isLeft && this.tree.add(e);
1483
+ let i = e, r = e;
1484
+ do
1485
+ i = this.tree.lastBefore(i);
1486
+ while (i != null && i.consumedBy != null);
1487
+ do
1488
+ r = this.tree.firstAfter(r);
1489
+ while (r != null && r.consumedBy != null);
1490
+ if (t.isLeft) {
1491
+ let u = null;
1492
+ if (i) {
1493
+ const h = i.getIntersection(e);
1494
+ if (h !== null && (e.isAnEndpoint(h) || (u = h), !i.isAnEndpoint(h))) {
1495
+ const E = this._splitSafely(i, h);
1496
+ for (let p = 0, _ = E.length; p < _; p++)
1497
+ n.push(E[p]);
1498
+ }
1499
+ }
1500
+ let a = null;
1501
+ if (r) {
1502
+ const h = r.getIntersection(e);
1503
+ if (h !== null && (e.isAnEndpoint(h) || (a = h), !r.isAnEndpoint(h))) {
1504
+ const E = this._splitSafely(r, h);
1505
+ for (let p = 0, _ = E.length; p < _; p++)
1506
+ n.push(E[p]);
1507
+ }
1508
+ }
1509
+ if (u !== null || a !== null) {
1510
+ let h = null;
1511
+ u === null ? h = a : a === null ? h = u : h = ne.comparePoints(
1512
+ u,
1513
+ a
1514
+ ) <= 0 ? u : a, this.queue.delete(e.rightSE), n.push(e.rightSE);
1515
+ const E = e.split(h);
1516
+ for (let p = 0, _ = E.length; p < _; p++)
1517
+ n.push(E[p]);
1518
+ }
1519
+ n.length > 0 ? (this.tree.delete(e), n.push(t)) : (this.segments.push(e), e.prev = i);
1520
+ } else {
1521
+ if (i && r) {
1522
+ const u = i.getIntersection(r);
1523
+ if (u !== null) {
1524
+ if (!i.isAnEndpoint(u)) {
1525
+ const a = this._splitSafely(i, u);
1526
+ for (let h = 0, E = a.length; h < E; h++)
1527
+ n.push(a[h]);
1528
+ }
1529
+ if (!r.isAnEndpoint(u)) {
1530
+ const a = this._splitSafely(r, u);
1531
+ for (let h = 0, E = a.length; h < E; h++)
1532
+ n.push(a[h]);
1533
+ }
1534
+ }
1535
+ }
1536
+ this.tree.delete(e);
1537
+ }
1538
+ return n;
1539
+ }
1540
+ /* Safely split a segment that is currently in the datastructures
1541
+ * IE - a segment other than the one that is currently being processed. */
1542
+ _splitSafely(t, e) {
1543
+ this.tree.delete(t);
1544
+ const n = t.rightSE;
1545
+ this.queue.delete(n);
1546
+ const i = t.split(e);
1547
+ return i.push(n), t.consumedBy === void 0 && this.tree.add(t), i;
1548
+ }
1549
+ }, Jt = class {
1550
+ constructor() {
1551
+ C(this, "type");
1552
+ C(this, "numMultiPolys");
1553
+ }
1554
+ run(t, e, n) {
1555
+ xe.type = t;
1556
+ const i = [new it(e, !0)];
1557
+ for (let p = 0, _ = n.length; p < _; p++)
1558
+ i.push(new it(n[p], !1));
1559
+ if (xe.numMultiPolys = i.length, xe.type === "difference") {
1560
+ const p = i[0];
1561
+ let _ = 1;
1562
+ for (; _ < i.length; )
1563
+ ze(i[_].bbox, p.bbox) !== null ? _++ : i.splice(_, 1);
1564
+ }
1565
+ if (xe.type === "intersection")
1566
+ for (let p = 0, _ = i.length; p < _; p++) {
1567
+ const b = i[p];
1568
+ for (let M = p + 1, T = i.length; M < T; M++)
1569
+ if (ze(b.bbox, i[M].bbox) === null) return [];
1570
+ }
1571
+ const r = new Pe(ne.compare);
1572
+ for (let p = 0, _ = i.length; p < _; p++) {
1573
+ const b = i[p].getSweepEvents();
1574
+ for (let M = 0, T = b.length; M < T; M++)
1575
+ r.add(b[M]);
1576
+ }
1577
+ const u = new Wt(r);
1578
+ let a = null;
1579
+ for (r.size != 0 && (a = r.first(), r.delete(a)); a; ) {
1580
+ const p = u.process(a);
1581
+ for (let _ = 0, b = p.length; _ < b; _++) {
1582
+ const M = p[_];
1583
+ M.consumedBy === void 0 && r.add(M);
1584
+ }
1585
+ r.size != 0 ? (a = r.first(), r.delete(a)) : a = null;
1586
+ }
1587
+ oe.reset();
1588
+ const h = Zt.factory(u.segments);
1589
+ return new Yt(h).getGeom();
1590
+ }
1591
+ }, xe = new Jt(), Re = xe, Ht = 0, Ne = class Ce {
1592
+ /* Warning: a reference to ringWindings input will be stored,
1593
+ * and possibly will be later modified */
1594
+ constructor(e, n, i, r) {
1595
+ C(this, "id");
1596
+ C(this, "leftSE");
1597
+ C(this, "rightSE");
1598
+ C(this, "rings");
1599
+ C(this, "windings");
1600
+ C(this, "ringOut");
1601
+ C(this, "consumedBy");
1602
+ C(this, "prev");
1603
+ C(this, "_prevInResult");
1604
+ C(this, "_beforeState");
1605
+ C(this, "_afterState");
1606
+ C(this, "_isInResult");
1607
+ this.id = ++Ht, this.leftSE = e, e.segment = this, e.otherSE = n, this.rightSE = n, n.segment = this, n.otherSE = e, this.rings = i, this.windings = r;
1608
+ }
889
1609
  /* This compare() function is for ordering segments in the sweep
890
1610
  * line tree, and does so according to the following criteria:
891
1611
  *
@@ -899,88 +1619,80 @@ class z {
899
1619
  * or more of the segments are vertical) then the line to be considered
900
1620
  * is directly on the right-more of the two left inputs.
901
1621
  */
902
- static compare(t, e) {
903
- const n = t.leftSE.point.x, i = e.leftSE.point.x, o = t.rightSE.point.x, u = e.rightSE.point.x;
904
- if (u < n) return 1;
905
- if (o < i) return -1;
906
- const l = t.leftSE.point.y, c = e.leftSE.point.y, f = t.rightSE.point.y, p = e.rightSE.point.y;
907
- if (n < i) {
908
- if (c < l && c < f) return 1;
909
- if (c > l && c > f) return -1;
910
- const s = t.comparePoint(e.leftSE.point);
911
- if (s < 0) return 1;
912
- if (s > 0) return -1;
913
- const a = e.comparePoint(t.rightSE.point);
914
- return a !== 0 ? a : -1;
915
- }
916
- if (n > i) {
917
- if (l < c && l < p) return -1;
918
- if (l > c && l > p) return 1;
919
- const s = e.comparePoint(t.leftSE.point);
920
- if (s !== 0) return s;
921
- const a = t.comparePoint(e.rightSE.point);
922
- return a < 0 ? 1 : a > 0 ? -1 : 1;
923
- }
924
- if (l < c) return -1;
925
- if (l > c) return 1;
926
- if (o < u) {
927
- const s = e.comparePoint(t.rightSE.point);
928
- if (s !== 0) return s;
929
- }
930
- if (o > u) {
931
- const s = t.comparePoint(e.rightSE.point);
932
- if (s < 0) return 1;
933
- if (s > 0) return -1;
934
- }
935
- if (o !== u) {
936
- const s = f - l, a = o - n, h = p - c, g = u - i;
937
- if (s > a && h < g) return 1;
938
- if (s < a && h > g) return -1;
939
- }
940
- return o > u ? 1 : o < u || f < p ? -1 : f > p ? 1 : t.id < e.id ? -1 : t.id > e.id ? 1 : 0;
941
- }
942
- /* Warning: a reference to ringWindings input will be stored,
943
- * and possibly will be later modified */
944
- constructor(t, e, n, i) {
945
- this.id = ++Re, this.leftSE = t, t.segment = this, t.otherSE = e, this.rightSE = e, e.segment = this, e.otherSE = t, this.rings = n, this.windings = i;
946
- }
947
- static fromRing(t, e, n) {
948
- let i, o, u;
949
- const l = L.comparePoints(t, e);
950
- if (l < 0)
951
- i = t, o = e, u = 1;
952
- else if (l > 0)
953
- i = e, o = t, u = -1;
954
- else throw new Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);
955
- const c = new L(i, !0), f = new L(o, !1);
956
- return new z(c, f, [n], [u]);
1622
+ static compare(e, n) {
1623
+ const i = e.leftSE.point.x, r = n.leftSE.point.x, u = e.rightSE.point.x, a = n.rightSE.point.x;
1624
+ if (a.isLessThan(i)) return 1;
1625
+ if (u.isLessThan(r)) return -1;
1626
+ const h = e.leftSE.point.y, E = n.leftSE.point.y, p = e.rightSE.point.y, _ = n.rightSE.point.y;
1627
+ if (i.isLessThan(r)) {
1628
+ if (E.isLessThan(h) && E.isLessThan(p)) return 1;
1629
+ if (E.isGreaterThan(h) && E.isGreaterThan(p)) return -1;
1630
+ const b = e.comparePoint(n.leftSE.point);
1631
+ if (b < 0) return 1;
1632
+ if (b > 0) return -1;
1633
+ const M = n.comparePoint(e.rightSE.point);
1634
+ return M !== 0 ? M : -1;
1635
+ }
1636
+ if (i.isGreaterThan(r)) {
1637
+ if (h.isLessThan(E) && h.isLessThan(_)) return -1;
1638
+ if (h.isGreaterThan(E) && h.isGreaterThan(_)) return 1;
1639
+ const b = n.comparePoint(e.leftSE.point);
1640
+ if (b !== 0) return b;
1641
+ const M = e.comparePoint(n.rightSE.point);
1642
+ return M < 0 ? 1 : M > 0 ? -1 : 1;
1643
+ }
1644
+ if (h.isLessThan(E)) return -1;
1645
+ if (h.isGreaterThan(E)) return 1;
1646
+ if (u.isLessThan(a)) {
1647
+ const b = n.comparePoint(e.rightSE.point);
1648
+ if (b !== 0) return b;
1649
+ }
1650
+ if (u.isGreaterThan(a)) {
1651
+ const b = e.comparePoint(n.rightSE.point);
1652
+ if (b < 0) return 1;
1653
+ if (b > 0) return -1;
1654
+ }
1655
+ if (!u.eq(a)) {
1656
+ const b = p.minus(h), M = u.minus(i), T = _.minus(E), L = a.minus(r);
1657
+ if (b.isGreaterThan(M) && T.isLessThan(L)) return 1;
1658
+ if (b.isLessThan(M) && T.isGreaterThan(L)) return -1;
1659
+ }
1660
+ return u.isGreaterThan(a) ? 1 : u.isLessThan(a) || p.isLessThan(_) ? -1 : p.isGreaterThan(_) ? 1 : e.id < n.id ? -1 : e.id > n.id ? 1 : 0;
1661
+ }
1662
+ static fromRing(e, n, i) {
1663
+ let r, u, a;
1664
+ const h = ne.comparePoints(e, n);
1665
+ if (h < 0)
1666
+ r = e, u = n, a = 1;
1667
+ else if (h > 0)
1668
+ r = n, u = e, a = -1;
1669
+ else
1670
+ throw new Error(
1671
+ `Tried to create degenerate segment at [${e.x}, ${e.y}]`
1672
+ );
1673
+ const E = new ne(r, !0), p = new ne(u, !1);
1674
+ return new Ce(E, p, [i], [a]);
957
1675
  }
958
1676
  /* When a segment is split, the rightSE is replaced with a new sweep event */
959
- replaceRightSE(t) {
960
- this.rightSE = t, this.rightSE.segment = this, this.rightSE.otherSE = this.leftSE, this.leftSE.otherSE = this.rightSE;
1677
+ replaceRightSE(e) {
1678
+ this.rightSE = e, this.rightSE.segment = this, this.rightSE.otherSE = this.leftSE, this.leftSE.otherSE = this.rightSE;
961
1679
  }
962
1680
  bbox() {
963
- const t = this.leftSE.point.y, e = this.rightSE.point.y;
1681
+ const e = this.leftSE.point.y, n = this.rightSE.point.y;
964
1682
  return {
965
- ll: {
966
- x: this.leftSE.point.x,
967
- y: t < e ? t : e
968
- },
969
- ur: {
970
- x: this.rightSE.point.x,
971
- y: t > e ? t : e
972
- }
1683
+ ll: { x: this.leftSE.point.x, y: e.isLessThan(n) ? e : n },
1684
+ ur: { x: this.rightSE.point.x, y: e.isGreaterThan(n) ? e : n }
973
1685
  };
974
1686
  }
975
1687
  /* A vector from the left point to the right */
976
1688
  vector() {
977
1689
  return {
978
- x: this.rightSE.point.x - this.leftSE.point.x,
979
- y: this.rightSE.point.y - this.leftSE.point.y
1690
+ x: this.rightSE.point.x.minus(this.leftSE.point.x),
1691
+ y: this.rightSE.point.y.minus(this.leftSE.point.y)
980
1692
  };
981
1693
  }
982
- isAnEndpoint(t) {
983
- return t.x === this.leftSE.point.x && t.y === this.leftSE.point.y || t.x === this.rightSE.point.x && t.y === this.rightSE.point.y;
1694
+ isAnEndpoint(e) {
1695
+ return e.x.eq(this.leftSE.point.x) && e.y.eq(this.leftSE.point.y) || e.x.eq(this.rightSE.point.x) && e.y.eq(this.rightSE.point.y);
984
1696
  }
985
1697
  /* Compare this segment with a point.
986
1698
  *
@@ -995,15 +1707,8 @@ class z {
995
1707
  * 0: point is colinear to segment
996
1708
  * -1: point lies below the segment (to the right of vertical)
997
1709
  */
998
- comparePoint(t) {
999
- if (this.isAnEndpoint(t)) return 0;
1000
- const e = this.leftSE.point, n = this.rightSE.point, i = this.vector();
1001
- if (e.x === n.x)
1002
- return t.x === e.x ? 0 : t.x < e.x ? 1 : -1;
1003
- const o = (t.y - e.y) / i.y, u = e.x + o * i.x;
1004
- if (t.x === u) return 0;
1005
- const l = (t.x - e.x) / i.x, c = e.y + l * i.y;
1006
- return t.y === c ? 0 : t.y < c ? -1 : 1;
1710
+ comparePoint(e) {
1711
+ return oe.orient(this.leftSE.point, e, this.rightSE.point);
1007
1712
  }
1008
1713
  /**
1009
1714
  * Given another segment, returns the first non-trivial intersection
@@ -1020,21 +1725,21 @@ class z {
1020
1725
  * If no non-trivial intersection exists, return null
1021
1726
  * Else, return null.
1022
1727
  */
1023
- getIntersection(t) {
1024
- const e = this.bbox(), n = t.bbox(), i = pt(e, n);
1025
- if (i === null) return null;
1026
- const o = this.leftSE.point, u = this.rightSE.point, l = t.leftSE.point, c = t.rightSE.point, f = j(e, l) && this.comparePoint(l) === 0, p = j(n, o) && t.comparePoint(o) === 0, s = j(e, c) && this.comparePoint(c) === 0, a = j(n, u) && t.comparePoint(u) === 0;
1027
- if (p && f)
1028
- return a && !s ? u : !a && s ? c : null;
1728
+ getIntersection(e) {
1729
+ const n = this.bbox(), i = e.bbox(), r = ze(n, i);
1730
+ if (r === null) return null;
1731
+ const u = this.leftSE.point, a = this.rightSE.point, h = e.leftSE.point, E = e.rightSE.point, p = de(n, h) && this.comparePoint(h) === 0, _ = de(i, u) && e.comparePoint(u) === 0, b = de(n, E) && this.comparePoint(E) === 0, M = de(i, a) && e.comparePoint(a) === 0;
1732
+ if (_ && p)
1733
+ return M && !b ? a : !M && b ? E : null;
1734
+ if (_)
1735
+ return b && u.x.eq(E.x) && u.y.eq(E.y) ? null : u;
1029
1736
  if (p)
1030
- return s && o.x === c.x && o.y === c.y ? null : o;
1031
- if (f)
1032
- return a && u.x === l.x && u.y === l.y ? null : l;
1033
- if (a && s) return null;
1034
- if (a) return u;
1035
- if (s) return c;
1036
- const h = Ce(o, this.vector(), l, t.vector());
1037
- return h === null || !j(i, h) ? null : J.round(h.x, h.y);
1737
+ return M && a.x.eq(h.x) && a.y.eq(h.y) ? null : h;
1738
+ if (M && b) return null;
1739
+ if (M) return a;
1740
+ if (b) return E;
1741
+ const T = Xt(u, this.vector(), h, e.vector());
1742
+ return T === null || !de(r, T) ? null : oe.snap(T);
1038
1743
  }
1039
1744
  /**
1040
1745
  * Split the given segment into multiple segments on the given points.
@@ -1048,40 +1753,45 @@ class z {
1048
1753
  *
1049
1754
  * Warning: input array of points is modified
1050
1755
  */
1051
- split(t) {
1052
- const e = [], n = t.events !== void 0, i = new L(t, !0), o = new L(t, !1), u = this.rightSE;
1053
- this.replaceRightSE(o), e.push(o), e.push(i);
1054
- const l = new z(i, u, this.rings.slice(), this.windings.slice());
1055
- return L.comparePoints(l.leftSE.point, l.rightSE.point) > 0 && l.swapEvents(), L.comparePoints(this.leftSE.point, this.rightSE.point) > 0 && this.swapEvents(), n && (i.checkForConsuming(), o.checkForConsuming()), e;
1756
+ split(e) {
1757
+ const n = [], i = e.events !== void 0, r = new ne(e, !0), u = new ne(e, !1), a = this.rightSE;
1758
+ this.replaceRightSE(u), n.push(u), n.push(r);
1759
+ const h = new Ce(
1760
+ r,
1761
+ a,
1762
+ this.rings.slice(),
1763
+ this.windings.slice()
1764
+ );
1765
+ return ne.comparePoints(h.leftSE.point, h.rightSE.point) > 0 && h.swapEvents(), ne.comparePoints(this.leftSE.point, this.rightSE.point) > 0 && this.swapEvents(), i && (r.checkForConsuming(), u.checkForConsuming()), n;
1056
1766
  }
1057
1767
  /* Swap which event is left and right */
1058
1768
  swapEvents() {
1059
- const t = this.rightSE;
1060
- this.rightSE = this.leftSE, this.leftSE = t, this.leftSE.isLeft = !0, this.rightSE.isLeft = !1;
1061
- for (let e = 0, n = this.windings.length; e < n; e++)
1062
- this.windings[e] *= -1;
1769
+ const e = this.rightSE;
1770
+ this.rightSE = this.leftSE, this.leftSE = e, this.leftSE.isLeft = !0, this.rightSE.isLeft = !1;
1771
+ for (let n = 0, i = this.windings.length; n < i; n++)
1772
+ this.windings[n] *= -1;
1063
1773
  }
1064
1774
  /* Consume another segment. We take their rings under our wing
1065
1775
  * and mark them as consumed. Use for perfectly overlapping segments */
1066
- consume(t) {
1067
- let e = this, n = t;
1068
- for (; e.consumedBy; ) e = e.consumedBy;
1776
+ consume(e) {
1777
+ let n = this, i = e;
1069
1778
  for (; n.consumedBy; ) n = n.consumedBy;
1070
- const i = z.compare(e, n);
1071
- if (i !== 0) {
1072
- if (i > 0) {
1073
- const o = e;
1074
- e = n, n = o;
1779
+ for (; i.consumedBy; ) i = i.consumedBy;
1780
+ const r = Ce.compare(n, i);
1781
+ if (r !== 0) {
1782
+ if (r > 0) {
1783
+ const u = n;
1784
+ n = i, i = u;
1075
1785
  }
1076
- if (e.prev === n) {
1077
- const o = e;
1078
- e = n, n = o;
1786
+ if (n.prev === i) {
1787
+ const u = n;
1788
+ n = i, i = u;
1079
1789
  }
1080
- for (let o = 0, u = n.rings.length; o < u; o++) {
1081
- const l = n.rings[o], c = n.windings[o], f = e.rings.indexOf(l);
1082
- f === -1 ? (e.rings.push(l), e.windings.push(c)) : e.windings[f] += c;
1790
+ for (let u = 0, a = i.rings.length; u < a; u++) {
1791
+ const h = i.rings[u], E = i.windings[u], p = n.rings.indexOf(h);
1792
+ p === -1 ? (n.rings.push(h), n.windings.push(E)) : n.windings[p] += E;
1083
1793
  }
1084
- n.rings = null, n.windings = null, n.consumedBy = e, n.leftSE.consumedBy = e.leftSE, n.rightSE.consumedBy = e.rightSE;
1794
+ i.rings = null, i.windings = null, i.consumedBy = n, i.leftSE.consumedBy = n.leftSE, i.rightSE.consumedBy = n.rightSE;
1085
1795
  }
1086
1796
  }
1087
1797
  /* The first segment previous segment chain that is in the result */
@@ -1090,45 +1800,46 @@ class z {
1090
1800
  }
1091
1801
  beforeState() {
1092
1802
  if (this._beforeState !== void 0) return this._beforeState;
1093
- if (!this.prev) this._beforeState = {
1094
- rings: [],
1095
- windings: [],
1096
- multiPolys: []
1097
- };
1803
+ if (!this.prev)
1804
+ this._beforeState = {
1805
+ rings: [],
1806
+ windings: [],
1807
+ multiPolys: []
1808
+ };
1098
1809
  else {
1099
- const t = this.prev.consumedBy || this.prev;
1100
- this._beforeState = t.afterState();
1810
+ const e = this.prev.consumedBy || this.prev;
1811
+ this._beforeState = e.afterState();
1101
1812
  }
1102
1813
  return this._beforeState;
1103
1814
  }
1104
1815
  afterState() {
1105
1816
  if (this._afterState !== void 0) return this._afterState;
1106
- const t = this.beforeState();
1817
+ const e = this.beforeState();
1107
1818
  this._afterState = {
1108
- rings: t.rings.slice(0),
1109
- windings: t.windings.slice(0),
1819
+ rings: e.rings.slice(0),
1820
+ windings: e.windings.slice(0),
1110
1821
  multiPolys: []
1111
1822
  };
1112
- const e = this._afterState.rings, n = this._afterState.windings, i = this._afterState.multiPolys;
1113
- for (let l = 0, c = this.rings.length; l < c; l++) {
1114
- const f = this.rings[l], p = this.windings[l], s = e.indexOf(f);
1115
- s === -1 ? (e.push(f), n.push(p)) : n[s] += p;
1116
- }
1117
- const o = [], u = [];
1118
- for (let l = 0, c = e.length; l < c; l++) {
1119
- if (n[l] === 0) continue;
1120
- const f = e[l], p = f.poly;
1121
- if (u.indexOf(p) === -1)
1122
- if (f.isExterior) o.push(p);
1823
+ const n = this._afterState.rings, i = this._afterState.windings, r = this._afterState.multiPolys;
1824
+ for (let h = 0, E = this.rings.length; h < E; h++) {
1825
+ const p = this.rings[h], _ = this.windings[h], b = n.indexOf(p);
1826
+ b === -1 ? (n.push(p), i.push(_)) : i[b] += _;
1827
+ }
1828
+ const u = [], a = [];
1829
+ for (let h = 0, E = n.length; h < E; h++) {
1830
+ if (i[h] === 0) continue;
1831
+ const p = n[h], _ = p.poly;
1832
+ if (a.indexOf(_) === -1)
1833
+ if (p.isExterior) u.push(_);
1123
1834
  else {
1124
- u.indexOf(p) === -1 && u.push(p);
1125
- const s = o.indexOf(f.poly);
1126
- s !== -1 && o.splice(s, 1);
1835
+ a.indexOf(_) === -1 && a.push(_);
1836
+ const b = u.indexOf(p.poly);
1837
+ b !== -1 && u.splice(b, 1);
1127
1838
  }
1128
1839
  }
1129
- for (let l = 0, c = o.length; l < c; l++) {
1130
- const f = o[l].multiPoly;
1131
- i.indexOf(f) === -1 && i.push(f);
1840
+ for (let h = 0, E = u.length; h < E; h++) {
1841
+ const p = u[h].multiPoly;
1842
+ r.indexOf(p) === -1 && r.push(p);
1132
1843
  }
1133
1844
  return this._afterState;
1134
1845
  }
@@ -1136,59 +1847,54 @@ class z {
1136
1847
  isInResult() {
1137
1848
  if (this.consumedBy) return !1;
1138
1849
  if (this._isInResult !== void 0) return this._isInResult;
1139
- const t = this.beforeState().multiPolys, e = this.afterState().multiPolys;
1140
- switch (k.type) {
1850
+ const e = this.beforeState().multiPolys, n = this.afterState().multiPolys;
1851
+ switch (Re.type) {
1141
1852
  case "union": {
1142
- const n = t.length === 0, i = e.length === 0;
1143
- this._isInResult = n !== i;
1853
+ const i = e.length === 0, r = n.length === 0;
1854
+ this._isInResult = i !== r;
1144
1855
  break;
1145
1856
  }
1146
1857
  case "intersection": {
1147
- let n, i;
1148
- t.length < e.length ? (n = t.length, i = e.length) : (n = e.length, i = t.length), this._isInResult = i === k.numMultiPolys && n < i;
1858
+ let i, r;
1859
+ e.length < n.length ? (i = e.length, r = n.length) : (i = n.length, r = e.length), this._isInResult = r === Re.numMultiPolys && i < r;
1149
1860
  break;
1150
1861
  }
1151
1862
  case "xor": {
1152
- const n = Math.abs(t.length - e.length);
1153
- this._isInResult = n % 2 === 1;
1863
+ const i = Math.abs(e.length - n.length);
1864
+ this._isInResult = i % 2 === 1;
1154
1865
  break;
1155
1866
  }
1156
1867
  case "difference": {
1157
- const n = (i) => i.length === 1 && i[0].isSubject;
1158
- this._isInResult = n(t) !== n(e);
1868
+ const i = (r) => r.length === 1 && r[0].isSubject;
1869
+ this._isInResult = i(e) !== i(n);
1159
1870
  break;
1160
1871
  }
1161
- default:
1162
- throw new Error(`Unrecognized operation type found ${k.type}`);
1163
1872
  }
1164
1873
  return this._isInResult;
1165
1874
  }
1166
- }
1167
- class $t {
1875
+ }, nt = class {
1168
1876
  constructor(t, e, n) {
1877
+ C(this, "poly");
1878
+ C(this, "isExterior");
1879
+ C(this, "segments");
1880
+ C(this, "bbox");
1169
1881
  if (!Array.isArray(t) || t.length === 0)
1170
1882
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1171
1883
  if (this.poly = e, this.isExterior = n, this.segments = [], typeof t[0][0] != "number" || typeof t[0][1] != "number")
1172
1884
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1173
- const i = J.round(t[0][0], t[0][1]);
1885
+ const i = oe.snap({ x: new ie(t[0][0]), y: new ie(t[0][1]) });
1174
1886
  this.bbox = {
1175
- ll: {
1176
- x: i.x,
1177
- y: i.y
1178
- },
1179
- ur: {
1180
- x: i.x,
1181
- y: i.y
1182
- }
1887
+ ll: { x: i.x, y: i.y },
1888
+ ur: { x: i.x, y: i.y }
1183
1889
  };
1184
- let o = i;
1185
- for (let u = 1, l = t.length; u < l; u++) {
1890
+ let r = i;
1891
+ for (let u = 1, a = t.length; u < a; u++) {
1186
1892
  if (typeof t[u][0] != "number" || typeof t[u][1] != "number")
1187
1893
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1188
- let c = J.round(t[u][0], t[u][1]);
1189
- c.x === o.x && c.y === o.y || (this.segments.push(z.fromRing(o, c, this)), c.x < this.bbox.ll.x && (this.bbox.ll.x = c.x), c.y < this.bbox.ll.y && (this.bbox.ll.y = c.y), c.x > this.bbox.ur.x && (this.bbox.ur.x = c.x), c.y > this.bbox.ur.y && (this.bbox.ur.y = c.y), o = c);
1894
+ const h = oe.snap({ x: new ie(t[u][0]), y: new ie(t[u][1]) });
1895
+ h.x.eq(r.x) && h.y.eq(r.y) || (this.segments.push(Ne.fromRing(r, h, this)), h.x.isLessThan(this.bbox.ll.x) && (this.bbox.ll.x = h.x), h.y.isLessThan(this.bbox.ll.y) && (this.bbox.ll.y = h.y), h.x.isGreaterThan(this.bbox.ur.x) && (this.bbox.ur.x = h.x), h.y.isGreaterThan(this.bbox.ur.y) && (this.bbox.ur.y = h.y), r = h);
1190
1896
  }
1191
- (i.x !== o.x || i.y !== o.y) && this.segments.push(z.fromRing(o, i, this));
1897
+ (!i.x.eq(r.x) || !i.y.eq(r.y)) && this.segments.push(Ne.fromRing(r, i, this));
1192
1898
  }
1193
1899
  getSweepEvents() {
1194
1900
  const t = [];
@@ -1198,24 +1904,21 @@ class $t {
1198
1904
  }
1199
1905
  return t;
1200
1906
  }
1201
- }
1202
- class Ie {
1907
+ }, jt = class {
1203
1908
  constructor(t, e) {
1909
+ C(this, "multiPoly");
1910
+ C(this, "exteriorRing");
1911
+ C(this, "interiorRings");
1912
+ C(this, "bbox");
1204
1913
  if (!Array.isArray(t))
1205
1914
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1206
- this.exteriorRing = new $t(t[0], this, !0), this.bbox = {
1207
- ll: {
1208
- x: this.exteriorRing.bbox.ll.x,
1209
- y: this.exteriorRing.bbox.ll.y
1210
- },
1211
- ur: {
1212
- x: this.exteriorRing.bbox.ur.x,
1213
- y: this.exteriorRing.bbox.ur.y
1214
- }
1915
+ this.exteriorRing = new nt(t[0], this, !0), this.bbox = {
1916
+ ll: { x: this.exteriorRing.bbox.ll.x, y: this.exteriorRing.bbox.ll.y },
1917
+ ur: { x: this.exteriorRing.bbox.ur.x, y: this.exteriorRing.bbox.ur.y }
1215
1918
  }, this.interiorRings = [];
1216
1919
  for (let n = 1, i = t.length; n < i; n++) {
1217
- const o = new $t(t[n], this, !1);
1218
- o.bbox.ll.x < this.bbox.ll.x && (this.bbox.ll.x = o.bbox.ll.x), o.bbox.ll.y < this.bbox.ll.y && (this.bbox.ll.y = o.bbox.ll.y), o.bbox.ur.x > this.bbox.ur.x && (this.bbox.ur.x = o.bbox.ur.x), o.bbox.ur.y > this.bbox.ur.y && (this.bbox.ur.y = o.bbox.ur.y), this.interiorRings.push(o);
1920
+ const r = new nt(t[n], this, !1);
1921
+ r.bbox.ll.x.isLessThan(this.bbox.ll.x) && (this.bbox.ll.x = r.bbox.ll.x), r.bbox.ll.y.isLessThan(this.bbox.ll.y) && (this.bbox.ll.y = r.bbox.ll.y), r.bbox.ur.x.isGreaterThan(this.bbox.ur.x) && (this.bbox.ur.x = r.bbox.ur.x), r.bbox.ur.y.isGreaterThan(this.bbox.ur.y) && (this.bbox.ur.y = r.bbox.ur.y), this.interiorRings.push(r);
1219
1922
  }
1220
1923
  this.multiPoly = e;
1221
1924
  }
@@ -1223,14 +1926,16 @@ class Ie {
1223
1926
  const t = this.exteriorRing.getSweepEvents();
1224
1927
  for (let e = 0, n = this.interiorRings.length; e < n; e++) {
1225
1928
  const i = this.interiorRings[e].getSweepEvents();
1226
- for (let o = 0, u = i.length; o < u; o++)
1227
- t.push(i[o]);
1929
+ for (let r = 0, u = i.length; r < u; r++)
1930
+ t.push(i[r]);
1228
1931
  }
1229
1932
  return t;
1230
1933
  }
1231
- }
1232
- class kt {
1934
+ }, it = class {
1233
1935
  constructor(t, e) {
1936
+ C(this, "isSubject");
1937
+ C(this, "polys");
1938
+ C(this, "bbox");
1234
1939
  if (!Array.isArray(t))
1235
1940
  throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
1236
1941
  try {
@@ -1238,18 +1943,12 @@ class kt {
1238
1943
  } catch {
1239
1944
  }
1240
1945
  this.polys = [], this.bbox = {
1241
- ll: {
1242
- x: Number.POSITIVE_INFINITY,
1243
- y: Number.POSITIVE_INFINITY
1244
- },
1245
- ur: {
1246
- x: Number.NEGATIVE_INFINITY,
1247
- y: Number.NEGATIVE_INFINITY
1248
- }
1946
+ ll: { x: new ie(Number.POSITIVE_INFINITY), y: new ie(Number.POSITIVE_INFINITY) },
1947
+ ur: { x: new ie(Number.NEGATIVE_INFINITY), y: new ie(Number.NEGATIVE_INFINITY) }
1249
1948
  };
1250
1949
  for (let n = 0, i = t.length; n < i; n++) {
1251
- const o = new Ie(t[n], this);
1252
- o.bbox.ll.x < this.bbox.ll.x && (this.bbox.ll.x = o.bbox.ll.x), o.bbox.ll.y < this.bbox.ll.y && (this.bbox.ll.y = o.bbox.ll.y), o.bbox.ur.x > this.bbox.ur.x && (this.bbox.ur.x = o.bbox.ur.x), o.bbox.ur.y > this.bbox.ur.y && (this.bbox.ur.y = o.bbox.ur.y), this.polys.push(o);
1950
+ const r = new jt(t[n], this);
1951
+ r.bbox.ll.x.isLessThan(this.bbox.ll.x) && (this.bbox.ll.x = r.bbox.ll.x), r.bbox.ll.y.isLessThan(this.bbox.ll.y) && (this.bbox.ll.y = r.bbox.ll.y), r.bbox.ur.x.isGreaterThan(this.bbox.ur.x) && (this.bbox.ur.x = r.bbox.ur.x), r.bbox.ur.y.isGreaterThan(this.bbox.ur.y) && (this.bbox.ur.y = r.bbox.ur.y), this.polys.push(r);
1253
1952
  }
1254
1953
  this.isSubject = e;
1255
1954
  }
@@ -1257,456 +1956,177 @@ class kt {
1257
1956
  const t = [];
1258
1957
  for (let e = 0, n = this.polys.length; e < n; e++) {
1259
1958
  const i = this.polys[e].getSweepEvents();
1260
- for (let o = 0, u = i.length; o < u; o++)
1261
- t.push(i[o]);
1262
- }
1263
- return t;
1264
- }
1265
- }
1266
- class nt {
1267
- /* Given the segments from the sweep line pass, compute & return a series
1268
- * of closed rings from all the segments marked to be part of the result */
1269
- static factory(t) {
1270
- const e = [];
1271
- for (let n = 0, i = t.length; n < i; n++) {
1272
- const o = t[n];
1273
- if (!o.isInResult() || o.ringOut) continue;
1274
- let u = null, l = o.leftSE, c = o.rightSE;
1275
- const f = [l], p = l.point, s = [];
1276
- for (; u = l, l = c, f.push(l), l.point !== p; )
1277
- for (; ; ) {
1278
- const a = l.getAvailableLinkedEvents();
1279
- if (a.length === 0) {
1280
- const d = f[0].point, w = f[f.length - 1].point;
1281
- throw new Error(`Unable to complete output ring starting at [${d.x}, ${d.y}]. Last matching segment found ends at [${w.x}, ${w.y}].`);
1282
- }
1283
- if (a.length === 1) {
1284
- c = a[0].otherSE;
1285
- break;
1286
- }
1287
- let h = null;
1288
- for (let d = 0, w = s.length; d < w; d++)
1289
- if (s[d].point === l.point) {
1290
- h = d;
1291
- break;
1292
- }
1293
- if (h !== null) {
1294
- const d = s.splice(h)[0], w = f.splice(d.index);
1295
- w.unshift(w[0].otherSE), e.push(new nt(w.reverse()));
1296
- continue;
1297
- }
1298
- s.push({
1299
- index: f.length,
1300
- point: l.point
1301
- });
1302
- const g = l.getLeftmostComparator(u);
1303
- c = a.sort(g)[0].otherSE;
1304
- break;
1305
- }
1306
- e.push(new nt(f));
1307
- }
1308
- return e;
1309
- }
1310
- constructor(t) {
1311
- this.events = t;
1312
- for (let e = 0, n = t.length; e < n; e++)
1313
- t[e].segment.ringOut = this;
1314
- this.poly = null;
1315
- }
1316
- getGeom() {
1317
- let t = this.events[0].point;
1318
- const e = [t];
1319
- for (let f = 1, p = this.events.length - 1; f < p; f++) {
1320
- const s = this.events[f].point, a = this.events[f + 1].point;
1321
- Ct(s, t, a) !== 0 && (e.push(s), t = s);
1322
- }
1323
- if (e.length === 1) return null;
1324
- const n = e[0], i = e[1];
1325
- Ct(n, t, i) === 0 && e.shift(), e.push(e[0]);
1326
- const o = this.isExteriorRing() ? 1 : -1, u = this.isExteriorRing() ? 0 : e.length - 1, l = this.isExteriorRing() ? e.length : -1, c = [];
1327
- for (let f = u; f != l; f += o) c.push([e[f].x, e[f].y]);
1328
- return c;
1329
- }
1330
- isExteriorRing() {
1331
- if (this._isExteriorRing === void 0) {
1332
- const t = this.enclosingRing();
1333
- this._isExteriorRing = t ? !t.isExteriorRing() : !0;
1334
- }
1335
- return this._isExteriorRing;
1336
- }
1337
- enclosingRing() {
1338
- return this._enclosingRing === void 0 && (this._enclosingRing = this._calcEnclosingRing()), this._enclosingRing;
1339
- }
1340
- /* Returns the ring that encloses this one, if any */
1341
- _calcEnclosingRing() {
1342
- let t = this.events[0];
1343
- for (let i = 1, o = this.events.length; i < o; i++) {
1344
- const u = this.events[i];
1345
- L.compare(t, u) > 0 && (t = u);
1346
- }
1347
- let e = t.segment.prevInResult(), n = e ? e.prevInResult() : null;
1348
- for (; ; ) {
1349
- if (!e) return null;
1350
- if (!n) return e.ringOut;
1351
- if (n.ringOut !== e.ringOut)
1352
- return n.ringOut.enclosingRing() !== e.ringOut ? e.ringOut : e.ringOut.enclosingRing();
1353
- e = n.prevInResult(), n = e ? e.prevInResult() : null;
1354
- }
1355
- }
1356
- }
1357
- class At {
1358
- constructor(t) {
1359
- this.exteriorRing = t, t.poly = this, this.interiorRings = [];
1360
- }
1361
- addInterior(t) {
1362
- this.interiorRings.push(t), t.poly = this;
1363
- }
1364
- getGeom() {
1365
- const t = [this.exteriorRing.getGeom()];
1366
- if (t[0] === null) return null;
1367
- for (let e = 0, n = this.interiorRings.length; e < n; e++) {
1368
- const i = this.interiorRings[e].getGeom();
1369
- i !== null && t.push(i);
1370
- }
1371
- return t;
1372
- }
1373
- }
1374
- class $e {
1375
- constructor(t) {
1376
- this.rings = t, this.polys = this._composePolys(t);
1377
- }
1378
- getGeom() {
1379
- const t = [];
1380
- for (let e = 0, n = this.polys.length; e < n; e++) {
1381
- const i = this.polys[e].getGeom();
1382
- i !== null && t.push(i);
1959
+ for (let r = 0, u = i.length; r < u; r++)
1960
+ t.push(i[r]);
1383
1961
  }
1384
1962
  return t;
1385
1963
  }
1386
- _composePolys(t) {
1387
- const e = [];
1388
- for (let n = 0, i = t.length; n < i; n++) {
1389
- const o = t[n];
1390
- if (!o.poly)
1391
- if (o.isExteriorRing()) e.push(new At(o));
1392
- else {
1393
- const u = o.enclosingRing();
1394
- u.poly || e.push(new At(u)), u.poly.addInterior(o);
1395
- }
1396
- }
1397
- return e;
1398
- }
1399
- }
1400
- class ke {
1401
- constructor(t) {
1402
- let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : z.compare;
1403
- this.queue = t, this.tree = new wt(e), this.segments = [];
1404
- }
1405
- process(t) {
1406
- const e = t.segment, n = [];
1407
- if (t.consumedBy)
1408
- return t.isLeft ? this.queue.remove(t.otherSE) : this.tree.remove(e), n;
1409
- const i = t.isLeft ? this.tree.add(e) : this.tree.find(e);
1410
- if (!i) throw new Error(`Unable to find segment #${e.id} [${e.leftSE.point.x}, ${e.leftSE.point.y}] -> [${e.rightSE.point.x}, ${e.rightSE.point.y}] in SweepLine tree.`);
1411
- let o = i, u = i, l, c;
1412
- for (; l === void 0; )
1413
- o = this.tree.prev(o), o === null ? l = null : o.key.consumedBy === void 0 && (l = o.key);
1414
- for (; c === void 0; )
1415
- u = this.tree.next(u), u === null ? c = null : u.key.consumedBy === void 0 && (c = u.key);
1416
- if (t.isLeft) {
1417
- let f = null;
1418
- if (l) {
1419
- const s = l.getIntersection(e);
1420
- if (s !== null && (e.isAnEndpoint(s) || (f = s), !l.isAnEndpoint(s))) {
1421
- const a = this._splitSafely(l, s);
1422
- for (let h = 0, g = a.length; h < g; h++)
1423
- n.push(a[h]);
1424
- }
1425
- }
1426
- let p = null;
1427
- if (c) {
1428
- const s = c.getIntersection(e);
1429
- if (s !== null && (e.isAnEndpoint(s) || (p = s), !c.isAnEndpoint(s))) {
1430
- const a = this._splitSafely(c, s);
1431
- for (let h = 0, g = a.length; h < g; h++)
1432
- n.push(a[h]);
1433
- }
1434
- }
1435
- if (f !== null || p !== null) {
1436
- let s = null;
1437
- f === null ? s = p : p === null ? s = f : s = L.comparePoints(f, p) <= 0 ? f : p, this.queue.remove(e.rightSE), n.push(e.rightSE);
1438
- const a = e.split(s);
1439
- for (let h = 0, g = a.length; h < g; h++)
1440
- n.push(a[h]);
1441
- }
1442
- n.length > 0 ? (this.tree.remove(e), n.push(t)) : (this.segments.push(e), e.prev = l);
1443
- } else {
1444
- if (l && c) {
1445
- const f = l.getIntersection(c);
1446
- if (f !== null) {
1447
- if (!l.isAnEndpoint(f)) {
1448
- const p = this._splitSafely(l, f);
1449
- for (let s = 0, a = p.length; s < a; s++)
1450
- n.push(p[s]);
1451
- }
1452
- if (!c.isAnEndpoint(f)) {
1453
- const p = this._splitSafely(c, f);
1454
- for (let s = 0, a = p.length; s < a; s++)
1455
- n.push(p[s]);
1456
- }
1457
- }
1458
- }
1459
- this.tree.remove(e);
1460
- }
1461
- return n;
1462
- }
1463
- /* Safely split a segment that is currently in the datastructures
1464
- * IE - a segment other than the one that is currently being processed. */
1465
- _splitSafely(t, e) {
1466
- this.tree.remove(t);
1467
- const n = t.rightSE;
1468
- this.queue.remove(n);
1469
- const i = t.split(e);
1470
- return i.push(n), t.consumedBy === void 0 && this.tree.add(t), i;
1471
- }
1472
- }
1473
- const Ot = typeof process < "u" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6, Ae = typeof process < "u" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6;
1474
- class Oe {
1475
- run(t, e, n) {
1476
- k.type = t, J.reset();
1477
- const i = [new kt(e, !0)];
1478
- for (let s = 0, a = n.length; s < a; s++)
1479
- i.push(new kt(n[s], !1));
1480
- if (k.numMultiPolys = i.length, k.type === "difference") {
1481
- const s = i[0];
1482
- let a = 1;
1483
- for (; a < i.length; )
1484
- pt(i[a].bbox, s.bbox) !== null ? a++ : i.splice(a, 1);
1485
- }
1486
- if (k.type === "intersection")
1487
- for (let s = 0, a = i.length; s < a; s++) {
1488
- const h = i[s];
1489
- for (let g = s + 1, d = i.length; g < d; g++)
1490
- if (pt(h.bbox, i[g].bbox) === null) return [];
1491
- }
1492
- const o = new wt(L.compare);
1493
- for (let s = 0, a = i.length; s < a; s++) {
1494
- const h = i[s].getSweepEvents();
1495
- for (let g = 0, d = h.length; g < d; g++)
1496
- if (o.insert(h[g]), o.size > Ot)
1497
- throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).");
1498
- }
1499
- const u = new ke(o);
1500
- let l = o.size, c = o.pop();
1501
- for (; c; ) {
1502
- const s = c.key;
1503
- if (o.size === l) {
1504
- const h = s.segment;
1505
- throw new Error(`Unable to pop() ${s.isLeft ? "left" : "right"} SweepEvent [${s.point.x}, ${s.point.y}] from segment #${h.id} [${h.leftSE.point.x}, ${h.leftSE.point.y}] -> [${h.rightSE.point.x}, ${h.rightSE.point.y}] from queue.`);
1506
- }
1507
- if (o.size > Ot)
1508
- throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");
1509
- if (u.segments.length > Ae)
1510
- throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");
1511
- const a = u.process(s);
1512
- for (let h = 0, g = a.length; h < g; h++) {
1513
- const d = a[h];
1514
- d.consumedBy === void 0 && o.insert(d);
1515
- }
1516
- l = o.size, c = o.pop();
1517
- }
1518
- J.reset();
1519
- const f = nt.factory(u.segments);
1520
- return new $e(f).getGeom();
1521
- }
1522
- }
1523
- const k = new Oe(), Ne = function(r) {
1524
- for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++)
1525
- e[n - 1] = arguments[n];
1526
- return k.run("union", r, e);
1527
- }, Be = function(r) {
1528
- for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++)
1529
- e[n - 1] = arguments[n];
1530
- return k.run("intersection", r, e);
1531
- }, Ge = function(r) {
1532
- for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++)
1533
- e[n - 1] = arguments[n];
1534
- return k.run("xor", r, e);
1535
- }, ze = function(r) {
1536
- for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++)
1537
- e[n - 1] = arguments[n];
1538
- return k.run("difference", r, e);
1539
- };
1540
- var Zt = {
1541
- union: Ne,
1542
- intersection: Be,
1543
- xor: Ge,
1544
- difference: ze
1545
- };
1546
- function Fe(r, t = {}) {
1547
- const e = [];
1548
- if (vt(r, (i) => {
1549
- e.push(i.coordinates);
1550
- }), e.length < 2)
1964
+ }, Qt = (t, ...e) => Re.run("union", t, e), en = (t, ...e) => Re.run("difference", t, e);
1965
+ oe.set;
1966
+ function tn(t, e = {}) {
1967
+ const n = [];
1968
+ if (Ye(t, (r) => {
1969
+ n.push(r.coordinates);
1970
+ }), n.length < 2)
1551
1971
  throw new Error("Must have at least 2 geometries");
1552
- const n = Zt.union(e[0], ...e.slice(1));
1553
- return n.length === 0 ? null : n.length === 1 ? xt(n[0], t.properties) : Ut(n, t.properties);
1972
+ const i = Qt(n[0], ...n.slice(1));
1973
+ return i.length === 0 ? null : i.length === 1 ? Ze(i[0], e.properties) : gt(i, e.properties);
1554
1974
  }
1555
- var Jt = Fe;
1556
- function gt(r) {
1557
- const t = [...r];
1558
- return t[2] < t[0] && (Math.abs((t[0] + t[2] + 360) / 2) > Math.abs((t[0] - 360 + t[2]) / 2) ? t[0] -= 360 : t[2] += 360), t;
1975
+ var _t = tn;
1976
+ function Ve(t) {
1977
+ const e = [...t];
1978
+ return e[2] < e[0] && (Math.abs((e[0] + e[2] + 360) / 2) > Math.abs((e[0] - 360 + e[2]) / 2) ? e[0] -= 360 : e[2] += 360), e;
1559
1979
  }
1560
- function W() {
1980
+ function Se() {
1561
1981
  }
1562
- function Wt(r) {
1563
- return r();
1982
+ function Tt(t) {
1983
+ return t();
1564
1984
  }
1565
- function Nt() {
1985
+ function rt() {
1566
1986
  return /* @__PURE__ */ Object.create(null);
1567
1987
  }
1568
- function rt(r) {
1569
- r.forEach(Wt);
1988
+ function Ae(t) {
1989
+ t.forEach(Tt);
1570
1990
  }
1571
- function Kt(r) {
1572
- return typeof r == "function";
1991
+ function Lt(t) {
1992
+ return typeof t == "function";
1573
1993
  }
1574
- function Te(r, t) {
1575
- return r != r ? t == t : r !== t || r && typeof r == "object" || typeof r == "function";
1994
+ function nn(t, e) {
1995
+ return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
1576
1996
  }
1577
- function qe(r) {
1578
- return Object.keys(r).length === 0;
1997
+ function rn(t) {
1998
+ return Object.keys(t).length === 0;
1579
1999
  }
1580
- function Qe(r, t) {
1581
- r.appendChild(t);
2000
+ function sn(t, e) {
2001
+ t.appendChild(e);
1582
2002
  }
1583
- function Ue(r, t, e) {
1584
- r.insertBefore(t, e || null);
2003
+ function on(t, e, n) {
2004
+ t.insertBefore(e, n || null);
1585
2005
  }
1586
- function Ht(r) {
1587
- r.parentNode && r.parentNode.removeChild(r);
2006
+ function Mt(t) {
2007
+ t.parentNode && t.parentNode.removeChild(t);
1588
2008
  }
1589
- function Bt(r) {
1590
- return document.createElementNS("http://www.w3.org/2000/svg", r);
2009
+ function st(t) {
2010
+ return document.createElementNS("http://www.w3.org/2000/svg", t);
1591
2011
  }
1592
- function N(r, t, e) {
1593
- e == null ? r.removeAttribute(t) : r.getAttribute(t) !== e && r.setAttribute(t, e);
2012
+ function ue(t, e, n) {
2013
+ n == null ? t.removeAttribute(e) : t.getAttribute(e) !== n && t.setAttribute(e, n);
1594
2014
  }
1595
- function Ye(r) {
1596
- return Array.from(r.childNodes);
2015
+ function ln(t) {
2016
+ return Array.from(t.childNodes);
1597
2017
  }
1598
- function H(r, t, e) {
1599
- r.classList.toggle(t, !!e);
2018
+ function Le(t, e, n) {
2019
+ t.classList.toggle(e, !!n);
1600
2020
  }
1601
- let bt;
1602
- function X(r) {
1603
- bt = r;
2021
+ let Je;
2022
+ function we(t) {
2023
+ Je = t;
1604
2024
  }
1605
- const U = [], Gt = [];
1606
- let Y = [];
1607
- const zt = [], De = /* @__PURE__ */ Promise.resolve();
1608
- let yt = !1;
1609
- function je() {
1610
- yt || (yt = !0, De.then(te));
2025
+ const he = [], ot = [];
2026
+ let pe = [];
2027
+ const lt = [], un = /* @__PURE__ */ Promise.resolve();
2028
+ let Ke = !1;
2029
+ function fn() {
2030
+ Ke || (Ke = !0, un.then(Ct));
1611
2031
  }
1612
- function dt(r) {
1613
- Y.push(r);
2032
+ function Xe(t) {
2033
+ pe.push(t);
1614
2034
  }
1615
- const lt = /* @__PURE__ */ new Set();
1616
- let Q = 0;
1617
- function te() {
1618
- if (Q !== 0)
2035
+ const $e = /* @__PURE__ */ new Set();
2036
+ let ae = 0;
2037
+ function Ct() {
2038
+ if (ae !== 0)
1619
2039
  return;
1620
- const r = bt;
2040
+ const t = Je;
1621
2041
  do {
1622
2042
  try {
1623
- for (; Q < U.length; ) {
1624
- const t = U[Q];
1625
- Q++, X(t), Xe(t.$$);
2043
+ for (; ae < he.length; ) {
2044
+ const e = he[ae];
2045
+ ae++, we(e), cn(e.$$);
1626
2046
  }
1627
- } catch (t) {
1628
- throw U.length = 0, Q = 0, t;
1629
- }
1630
- for (X(null), U.length = 0, Q = 0; Gt.length; ) Gt.pop()();
1631
- for (let t = 0; t < Y.length; t += 1) {
1632
- const e = Y[t];
1633
- lt.has(e) || (lt.add(e), e());
1634
- }
1635
- Y.length = 0;
1636
- } while (U.length);
1637
- for (; zt.length; )
1638
- zt.pop()();
1639
- yt = !1, lt.clear(), X(r);
1640
- }
1641
- function Xe(r) {
1642
- if (r.fragment !== null) {
1643
- r.update(), rt(r.before_update);
1644
- const t = r.dirty;
1645
- r.dirty = [-1], r.fragment && r.fragment.p(r.ctx, t), r.after_update.forEach(dt);
1646
- }
1647
- }
1648
- function Ve(r) {
1649
- const t = [], e = [];
1650
- Y.forEach((n) => r.indexOf(n) === -1 ? t.push(n) : e.push(n)), e.forEach((n) => n()), Y = t;
1651
- }
1652
- const Ze = /* @__PURE__ */ new Set();
1653
- function Je(r, t) {
1654
- r && r.i && (Ze.delete(r), r.i(t));
1655
- }
1656
- function We(r, t, e) {
1657
- const { fragment: n, after_update: i } = r.$$;
1658
- n && n.m(t, e), dt(() => {
1659
- const o = r.$$.on_mount.map(Wt).filter(Kt);
1660
- r.$$.on_destroy ? r.$$.on_destroy.push(...o) : rt(o), r.$$.on_mount = [];
1661
- }), i.forEach(dt);
1662
- }
1663
- function Ke(r, t) {
1664
- const e = r.$$;
1665
- e.fragment !== null && (Ve(e.after_update), rt(e.on_destroy), e.fragment && e.fragment.d(t), e.on_destroy = e.fragment = null, e.ctx = []);
1666
- }
1667
- function He(r, t) {
1668
- r.$$.dirty[0] === -1 && (U.push(r), je(), r.$$.dirty.fill(0)), r.$$.dirty[t / 31 | 0] |= 1 << t % 31;
1669
- }
1670
- function tn(r, t, e, n, i, o, u = null, l = [-1]) {
1671
- const c = bt;
1672
- X(r);
1673
- const f = r.$$ = {
2047
+ } catch (e) {
2048
+ throw he.length = 0, ae = 0, e;
2049
+ }
2050
+ for (we(null), he.length = 0, ae = 0; ot.length; ) ot.pop()();
2051
+ for (let e = 0; e < pe.length; e += 1) {
2052
+ const n = pe[e];
2053
+ $e.has(n) || ($e.add(n), n());
2054
+ }
2055
+ pe.length = 0;
2056
+ } while (he.length);
2057
+ for (; lt.length; )
2058
+ lt.pop()();
2059
+ Ke = !1, $e.clear(), we(t);
2060
+ }
2061
+ function cn(t) {
2062
+ if (t.fragment !== null) {
2063
+ t.update(), Ae(t.before_update);
2064
+ const e = t.dirty;
2065
+ t.dirty = [-1], t.fragment && t.fragment.p(t.ctx, e), t.after_update.forEach(Xe);
2066
+ }
2067
+ }
2068
+ function an(t) {
2069
+ const e = [], n = [];
2070
+ pe.forEach((i) => t.indexOf(i) === -1 ? e.push(i) : n.push(i)), n.forEach((i) => i()), pe = e;
2071
+ }
2072
+ const hn = /* @__PURE__ */ new Set();
2073
+ function pn(t, e) {
2074
+ t && t.i && (hn.delete(t), t.i(e));
2075
+ }
2076
+ function gn(t, e, n) {
2077
+ const { fragment: i, after_update: r } = t.$$;
2078
+ i && i.m(e, n), Xe(() => {
2079
+ const u = t.$$.on_mount.map(Tt).filter(Lt);
2080
+ t.$$.on_destroy ? t.$$.on_destroy.push(...u) : Ae(u), t.$$.on_mount = [];
2081
+ }), r.forEach(Xe);
2082
+ }
2083
+ function yn(t, e) {
2084
+ const n = t.$$;
2085
+ n.fragment !== null && (an(n.after_update), Ae(n.on_destroy), n.fragment && n.fragment.d(e), n.on_destroy = n.fragment = null, n.ctx = []);
2086
+ }
2087
+ function dn(t, e) {
2088
+ t.$$.dirty[0] === -1 && (he.push(t), fn(), t.$$.dirty.fill(0)), t.$$.dirty[e / 31 | 0] |= 1 << e % 31;
2089
+ }
2090
+ function mn(t, e, n, i, r, u, a = null, h = [-1]) {
2091
+ const E = Je;
2092
+ we(t);
2093
+ const p = t.$$ = {
1674
2094
  fragment: null,
1675
2095
  ctx: [],
1676
2096
  // state
1677
- props: o,
1678
- update: W,
1679
- not_equal: i,
1680
- bound: Nt(),
2097
+ props: u,
2098
+ update: Se,
2099
+ not_equal: r,
2100
+ bound: rt(),
1681
2101
  // lifecycle
1682
2102
  on_mount: [],
1683
2103
  on_destroy: [],
1684
2104
  on_disconnect: [],
1685
2105
  before_update: [],
1686
2106
  after_update: [],
1687
- context: new Map(t.context || (c ? c.$$.context : [])),
2107
+ context: new Map(e.context || (E ? E.$$.context : [])),
1688
2108
  // everything else
1689
- callbacks: Nt(),
1690
- dirty: l,
2109
+ callbacks: rt(),
2110
+ dirty: h,
1691
2111
  skip_bound: !1,
1692
- root: t.target || c.$$.root
2112
+ root: e.target || E.$$.root
1693
2113
  };
1694
- u && u(f.root);
1695
- let p = !1;
1696
- if (f.ctx = e ? e(r, t.props || {}, (s, a, ...h) => {
1697
- const g = h.length ? h[0] : a;
1698
- return f.ctx && i(f.ctx[s], f.ctx[s] = g) && (!f.skip_bound && f.bound[s] && f.bound[s](g), p && He(r, s)), a;
1699
- }) : [], f.update(), p = !0, rt(f.before_update), f.fragment = n ? n(f.ctx) : !1, t.target) {
1700
- if (t.hydrate) {
1701
- const s = Ye(t.target);
1702
- f.fragment && f.fragment.l(s), s.forEach(Ht);
2114
+ a && a(p.root);
2115
+ let _ = !1;
2116
+ if (p.ctx = n(t, e.props || {}, (b, M, ...T) => {
2117
+ const L = T.length ? T[0] : M;
2118
+ return p.ctx && r(p.ctx[b], p.ctx[b] = L) && (!p.skip_bound && p.bound[b] && p.bound[b](L), _ && dn(t, b)), M;
2119
+ }), p.update(), _ = !0, Ae(p.before_update), p.fragment = i(p.ctx), e.target) {
2120
+ if (e.hydrate) {
2121
+ const b = ln(e.target);
2122
+ p.fragment && p.fragment.l(b), b.forEach(Mt);
1703
2123
  } else
1704
- f.fragment && f.fragment.c();
1705
- t.intro && Je(r.$$.fragment), We(r, t.target, t.anchor), te();
2124
+ p.fragment && p.fragment.c();
2125
+ e.intro && pn(t.$$.fragment), gn(t, e.target, e.anchor), Ct();
1706
2126
  }
1707
- X(c);
2127
+ we(E);
1708
2128
  }
1709
- class en {
2129
+ class xn {
1710
2130
  constructor() {
1711
2131
  /**
1712
2132
  * ### PRIVATE API
@@ -1715,7 +2135,7 @@ class en {
1715
2135
  *
1716
2136
  * @type {any}
1717
2137
  */
1718
- it(this, "$$");
2138
+ C(this, "$$");
1719
2139
  /**
1720
2140
  * ### PRIVATE API
1721
2141
  *
@@ -1723,11 +2143,11 @@ class en {
1723
2143
  *
1724
2144
  * @type {any}
1725
2145
  */
1726
- it(this, "$$set");
2146
+ C(this, "$$set");
1727
2147
  }
1728
2148
  /** @returns {void} */
1729
2149
  $destroy() {
1730
- Ke(this, 1), this.$destroy = W;
2150
+ yn(this, 1), this.$destroy = Se;
1731
2151
  }
1732
2152
  /**
1733
2153
  * @template {Extract<keyof Events, string>} K
@@ -1735,103 +2155,102 @@ class en {
1735
2155
  * @param {((e: Events[K]) => void) | null | undefined} callback
1736
2156
  * @returns {() => void}
1737
2157
  */
1738
- $on(t, e) {
1739
- if (!Kt(e))
1740
- return W;
1741
- const n = this.$$.callbacks[t] || (this.$$.callbacks[t] = []);
1742
- return n.push(e), () => {
1743
- const i = n.indexOf(e);
1744
- i !== -1 && n.splice(i, 1);
2158
+ $on(e, n) {
2159
+ if (!Lt(n))
2160
+ return Se;
2161
+ const i = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
2162
+ return i.push(n), () => {
2163
+ const r = i.indexOf(n);
2164
+ r !== -1 && i.splice(r, 1);
1745
2165
  };
1746
2166
  }
1747
2167
  /**
1748
2168
  * @param {Partial<Props>} props
1749
2169
  * @returns {void}
1750
2170
  */
1751
- $set(t) {
1752
- this.$$set && !qe(t) && (this.$$.skip_bound = !0, this.$$set(t), this.$$.skip_bound = !1);
2171
+ $set(e) {
2172
+ this.$$set && !rn(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
1753
2173
  }
1754
2174
  }
1755
- const nn = "4";
1756
- typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(nn);
1757
- function rn(r) {
1758
- let t, e, n;
2175
+ const wn = "4";
2176
+ typeof window < "u" && (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(wn);
2177
+ function En(t) {
2178
+ let e, n, i;
1759
2179
  return {
1760
2180
  c() {
1761
- t = Bt("svg"), e = Bt("path"), N(e, "stroke-width", "4"), N(e, "d", "M 5,33.103579 C 5,17.607779 18.457,5 35,5 C 51.543,5 65,17.607779 65,33.103579 C 65,56.388679 40.4668,76.048179 36.6112,79.137779 C 36.3714,79.329879 36.2116,79.457979 36.1427,79.518879 C 35.8203,79.800879 35.4102,79.942779 35,79.942779 C 34.5899,79.942779 34.1797,79.800879 33.8575,79.518879 C 33.7886,79.457979 33.6289,79.330079 33.3893,79.138079 C 29.5346,76.049279 5,56.389379 5,33.103579 Z M 35.0001,49.386379 C 43.1917,49.386379 49.8323,42.646079 49.8323,34.331379 C 49.8323,26.016779 43.1917,19.276479 35.0001,19.276479 C 26.8085,19.276479 20.1679,26.016779 20.1679,34.331379 C 20.1679,42.646079 26.8085,49.386379 35.0001,49.386379 Z"), N(e, "class", "svelte-gzo3ar"), N(t, "width", n = /*displayIn*/
1762
- r[0] === "list" ? 20 : void 0), N(t, "viewBox", "0 0 70 85"), N(t, "fill", "none"), N(t, "class", "svelte-gzo3ar"), H(
1763
- t,
2181
+ e = st("svg"), n = st("path"), ue(n, "stroke-width", "4"), ue(n, "d", "M 5,33.103579 C 5,17.607779 18.457,5 35,5 C 51.543,5 65,17.607779 65,33.103579 C 65,56.388679 40.4668,76.048179 36.6112,79.137779 C 36.3714,79.329879 36.2116,79.457979 36.1427,79.518879 C 35.8203,79.800879 35.4102,79.942779 35,79.942779 C 34.5899,79.942779 34.1797,79.800879 33.8575,79.518879 C 33.7886,79.457979 33.6289,79.330079 33.3893,79.138079 C 29.5346,76.049279 5,56.389379 5,33.103579 Z M 35.0001,49.386379 C 43.1917,49.386379 49.8323,42.646079 49.8323,34.331379 C 49.8323,26.016779 43.1917,19.276479 35.0001,19.276479 C 26.8085,19.276479 20.1679,26.016779 20.1679,34.331379 C 20.1679,42.646079 26.8085,49.386379 35.0001,49.386379 Z"), ue(n, "class", "svelte-gzo3ar"), ue(e, "width", i = /*displayIn*/
2182
+ t[0] === "list" ? 20 : void 0), ue(e, "viewBox", "0 0 70 85"), ue(e, "fill", "none"), ue(e, "class", "svelte-gzo3ar"), Le(
2183
+ e,
1764
2184
  "in-map",
1765
2185
  /*displayIn*/
1766
- r[0] !== "list"
1767
- ), H(
1768
- t,
2186
+ t[0] !== "list"
2187
+ ), Le(
2188
+ e,
1769
2189
  "list-icon",
1770
2190
  /*displayIn*/
1771
- r[0] === "list"
2191
+ t[0] === "list"
1772
2192
  );
1773
2193
  },
1774
- m(i, o) {
1775
- Ue(i, t, o), Qe(t, e);
2194
+ m(r, u) {
2195
+ on(r, e, u), sn(e, n);
1776
2196
  },
1777
- p(i, [o]) {
1778
- o & /*displayIn*/
1779
- 1 && n !== (n = /*displayIn*/
1780
- i[0] === "list" ? 20 : void 0) && N(t, "width", n), o & /*displayIn*/
1781
- 1 && H(
1782
- t,
2197
+ p(r, [u]) {
2198
+ u & /*displayIn*/
2199
+ 1 && i !== (i = /*displayIn*/
2200
+ r[0] === "list" ? 20 : void 0) && ue(e, "width", i), u & /*displayIn*/
2201
+ 1 && Le(
2202
+ e,
1783
2203
  "in-map",
1784
2204
  /*displayIn*/
1785
- i[0] !== "list"
1786
- ), o & /*displayIn*/
1787
- 1 && H(
1788
- t,
2205
+ r[0] !== "list"
2206
+ ), u & /*displayIn*/
2207
+ 1 && Le(
2208
+ e,
1789
2209
  "list-icon",
1790
2210
  /*displayIn*/
1791
- i[0] === "list"
2211
+ r[0] === "list"
1792
2212
  );
1793
2213
  },
1794
- i: W,
1795
- o: W,
1796
- d(i) {
1797
- i && Ht(t);
2214
+ i: Se,
2215
+ o: Se,
2216
+ d(r) {
2217
+ r && Mt(e);
1798
2218
  }
1799
2219
  };
1800
2220
  }
1801
- function on(r, t, e) {
1802
- let { displayIn: n } = t;
1803
- return r.$$set = (i) => {
1804
- "displayIn" in i && e(0, n = i.displayIn);
1805
- }, [n];
2221
+ function vn(t, e, n) {
2222
+ let { displayIn: i } = e;
2223
+ return t.$$set = (r) => {
2224
+ "displayIn" in r && n(0, i = r.displayIn);
2225
+ }, [i];
1806
2226
  }
1807
- class sn extends en {
1808
- constructor(t) {
1809
- super(), tn(this, t, on, rn, Te, { displayIn: 0 });
2227
+ class Sn extends xn {
2228
+ constructor(e) {
2229
+ super(), mn(this, e, vn, En, nn, { displayIn: 0 });
1810
2230
  }
1811
2231
  }
1812
- function ln(r) {
1813
- const t = [];
1814
- if (vt(r, (i) => {
1815
- t.push(i.coordinates);
1816
- }), t.length < 2)
2232
+ function bn(t) {
2233
+ const e = [];
2234
+ if (Ye(t, (r) => {
2235
+ e.push(r.coordinates);
2236
+ }), e.length < 2)
1817
2237
  throw new Error("Must have at least two features");
1818
- const e = r.features[0].properties || {}, n = Zt.difference(t[0], ...t.slice(1));
1819
- return n.length === 0 ? null : n.length === 1 ? xt(n[0], e) : Ut(n, e);
1820
- }
1821
- var un = ln;
1822
- function fn(r) {
1823
- if (!r)
1824
- throw new Error("geojson is required");
1825
- var t = [];
1826
- return se(r, function(e) {
1827
- t.push(e);
1828
- }), Z(t);
1829
- }
1830
- var cn = fn;
1831
- function Ft(r, t) {
1832
- const e = un(
1833
- Z([
1834
- xt([
2238
+ const n = t.features[0].properties || {}, i = en(e[0], ...e.slice(1));
2239
+ return i.length === 0 ? null : i.length === 1 ? Ze(i[0], n) : gt(i, n);
2240
+ }
2241
+ var _n = bn;
2242
+ function Tn(t) {
2243
+ if (!t) throw new Error("geojson is required");
2244
+ var e = [];
2245
+ return Rt(t, function(n) {
2246
+ e.push(n);
2247
+ }), ve(e);
2248
+ }
2249
+ var Ln = Tn;
2250
+ function ut(t, e) {
2251
+ const n = _n(
2252
+ ve([
2253
+ Ze([
1835
2254
  [
1836
2255
  [180, 90],
1837
2256
  [-180, 90],
@@ -1840,63 +2259,63 @@ function Ft(r, t) {
1840
2259
  [180, 90]
1841
2260
  ]
1842
2261
  ]),
1843
- r
2262
+ t
1844
2263
  ])
1845
2264
  );
1846
- if (!e)
2265
+ if (!n)
1847
2266
  return;
1848
- e.properties = { isMask: !0 };
1849
- const n = gt(ut(r)), i = (n[2] - n[0]) / 360 / 1e3, o = n[0] < -180, u = n[2] > 180, l = cn(r);
1850
- if (l.features.length > 1 && (o || u))
1851
- for (const c of l.features) {
1852
- const f = gt(ut(c));
1853
- if (u && f[0] < -180 + i)
1854
- for (const p of c.geometry.coordinates)
1855
- for (const s of p)
1856
- s[0] += 360 - i;
1857
- if (o && f[2] > 180 - i)
1858
- for (const p of c.geometry.coordinates)
1859
- for (const s of p)
1860
- s[0] -= 360 - i;
1861
- }
1862
- t(
1863
- Z([
1864
- l.features.length < 2 ? r : Jt(l) ?? r,
1865
- e
2267
+ n.properties = { isMask: !0 };
2268
+ const i = Ve(qe(t)), r = (i[2] - i[0]) / 360 / 1e3, u = i[0] < -180, a = i[2] > 180, h = Ln(t);
2269
+ if (h.features.length > 1 && (u || a))
2270
+ for (const E of h.features) {
2271
+ const p = Ve(qe(E));
2272
+ if (a && p[0] < -180 + r)
2273
+ for (const _ of E.geometry.coordinates)
2274
+ for (const b of _)
2275
+ b[0] += 360 - r;
2276
+ if (u && p[2] > 180 - r)
2277
+ for (const _ of E.geometry.coordinates)
2278
+ for (const b of _)
2279
+ b[0] -= 360 - r;
2280
+ }
2281
+ e(
2282
+ ve([
2283
+ h.features.length < 2 ? t : _t(h) ?? t,
2284
+ n
1866
2285
  ])
1867
2286
  );
1868
2287
  }
1869
- const Tt = (r) => {
1870
- var n, i, o;
1871
- const t = (n = r == null ? void 0 : r.geometry) == null ? void 0 : n.type, e = (i = r == null ? void 0 : r.properties) != null && i.isMask ? 0 : t === "LineString" || t === "MultiLineString" ? 3 : 2;
2288
+ const ft = (t) => {
2289
+ var i, r, u;
2290
+ const e = (i = t == null ? void 0 : t.geometry) == null ? void 0 : i.type, n = (r = t == null ? void 0 : t.properties) != null && r.isMask ? 0 : e === "LineString" || e === "MultiLineString" ? 3 : 2;
1872
2291
  return {
1873
2292
  color: "#3170fe",
1874
2293
  fillColor: "#000",
1875
- fillOpacity: (o = r == null ? void 0 : r.properties) != null && o.isMask ? 0.1 : 0,
1876
- weight: e,
1877
- dashArray: [e, e],
2294
+ fillOpacity: (u = t == null ? void 0 : t.properties) != null && u.isMask ? 0.1 : 0,
2295
+ weight: n,
2296
+ dashArray: [n, n],
1878
2297
  lineCap: "butt"
1879
2298
  };
1880
2299
  };
1881
- function an(r, t = !0, e = !0, n = {}, i = {}, o = Tt) {
1882
- let u;
1883
- const l = [];
1884
- let c, f;
1885
- const p = T.geoJSON(void 0, {
1886
- style: o === !0 ? Tt : o === !1 ? void 0 : o ?? void 0,
2300
+ function Cn(t, e = !0, n = !0, i = {}, r = {}, u = ft) {
2301
+ let a;
2302
+ const h = [];
2303
+ let E, p;
2304
+ const _ = ce.geoJSON(void 0, {
2305
+ style: u === !0 ? ft : u === !1 ? void 0 : u ?? void 0,
1887
2306
  interactive: !1
1888
- }).addTo(r), s = (h) => {
1889
- u == null || u({
2307
+ }).addTo(t), b = (T) => {
2308
+ a == null || a({
1890
2309
  type: "mapClick",
1891
- coordinates: [h.latlng.lng, h.latlng.lat]
2310
+ coordinates: [T.latlng.lng, T.latlng.lat]
1892
2311
  });
1893
2312
  };
1894
- function a(h, g = !1) {
1895
- const d = document.createElement("div");
1896
- return new sn({ props: { displayIn: "leaflet" }, target: d }), new T.Marker(h, {
1897
- interactive: g,
1898
- icon: new T.DivIcon({
1899
- html: d,
2313
+ function M(T, L = !1) {
2314
+ const B = document.createElement("div");
2315
+ return new Sn({ props: { displayIn: "leaflet" }, target: B }), new ce.Marker(T, {
2316
+ interactive: L,
2317
+ icon: new ce.DivIcon({
2318
+ html: B,
1900
2319
  className: "",
1901
2320
  iconAnchor: [12, 26],
1902
2321
  iconSize: [25, 30],
@@ -1905,152 +2324,152 @@ function an(r, t = !0, e = !0, n = {}, i = {}, o = Tt) {
1905
2324
  });
1906
2325
  }
1907
2326
  return {
1908
- setEventHandler(h) {
1909
- h ? (u = h, r.on("click", s)) : (u = void 0, r.off("click", s));
2327
+ setEventHandler(T) {
2328
+ T ? (a = T, t.on("click", b)) : (a = void 0, t.off("click", b));
1910
2329
  },
1911
- flyTo(h, g) {
1912
- r.flyTo([h[1], h[0]], g, { duration: 2, ...n });
2330
+ flyTo(T, L) {
2331
+ t.flyTo([T[1], T[0]], L, { duration: 2, ...i });
1913
2332
  },
1914
- fitBounds(h, g, d) {
1915
- r.flyToBounds(
2333
+ fitBounds(T, L, B) {
2334
+ t.flyToBounds(
1916
2335
  [
1917
- [h[1], h[0]],
1918
- [h[3], h[2]]
2336
+ [T[1], T[0]],
2337
+ [T[3], T[2]]
1919
2338
  ],
1920
2339
  {
1921
- padding: [g, g],
2340
+ padding: [L, L],
1922
2341
  duration: 2,
1923
- ...d ? { maxZoom: d } : {},
1924
- ...i
2342
+ ...B ? { maxZoom: B } : {},
2343
+ ...r
1925
2344
  }
1926
2345
  );
1927
2346
  },
1928
- indicateReverse(h) {
1929
- r.getContainer().style.cursor = h ? "crosshair" : "";
2347
+ indicateReverse(T) {
2348
+ t.getContainer().style.cursor = T ? "crosshair" : "";
1930
2349
  },
1931
- setReverseMarker(h) {
1932
- var d;
1933
- if (!t)
2350
+ setReverseMarker(T) {
2351
+ var B;
2352
+ if (!e)
1934
2353
  return;
1935
- const g = h && [h[1], h[0]];
1936
- f ? g ? f.setLatLng(g) : (f.remove(), f = void 0) : g && (t instanceof Function ? f = t(r) ?? void 0 : (f = (typeof t == "object" ? new T.Marker(g, t) : a(g)).addTo(r), (d = f.getElement()) == null || d.classList.add("marker-reverse")));
2354
+ const L = T && [T[1], T[0]];
2355
+ p ? L ? p.setLatLng(L) : (p.remove(), p = void 0) : L && (e instanceof Function ? p = e(t) ?? void 0 : (p = (typeof e == "object" ? new ce.Marker(L, e) : M(L)).addTo(t), (B = p.getElement()) == null || B.classList.add("marker-reverse")));
1937
2356
  },
1938
- setFeatures(h, g, d) {
1939
- function w(y) {
1940
- p.clearLayers(), y && p.addData(y);
2357
+ setFeatures(T, L, B) {
2358
+ function q(I) {
2359
+ _.clearLayers(), I && _.addData(I);
1941
2360
  }
1942
- for (const y of l)
1943
- y.remove();
1944
- l.length = 0, w();
1945
- t: if (g) {
1946
- let y = !1;
1947
- if (g.geometry.type === "GeometryCollection") {
1948
- const v = g.geometry.geometries.filter(
1949
- (x) => x.type === "Polygon" || x.type === "MultiPolygon"
2361
+ for (const I of h)
2362
+ I.remove();
2363
+ h.length = 0, q();
2364
+ e: if (L) {
2365
+ let I = !1;
2366
+ if (L.geometry.type === "GeometryCollection") {
2367
+ const v = L.geometry.geometries.filter(
2368
+ (N) => N.type === "Polygon" || N.type === "MultiPolygon"
1950
2369
  );
1951
- e: if (v.length > 0) {
1952
- const x = Jt(
1953
- Z(v.map((m) => V(m)))
2370
+ t: if (v.length > 0) {
2371
+ const N = _t(
2372
+ ve(v.map(($) => Ee($)))
1954
2373
  );
1955
- if (!x)
1956
- break e;
1957
- Ft(
2374
+ if (!N)
2375
+ break t;
2376
+ ut(
1958
2377
  {
1959
- ...g,
1960
- geometry: x.geometry
2378
+ ...L,
2379
+ geometry: N.geometry
1961
2380
  },
1962
- w
1963
- ), y = !0;
2381
+ q
2382
+ ), I = !0;
1964
2383
  } else {
1965
- const x = g.geometry.geometries.filter(
1966
- (m) => m.type === "LineString" || m.type === "MultiLineString"
2384
+ const N = L.geometry.geometries.filter(
2385
+ ($) => $.type === "LineString" || $.type === "MultiLineString"
1967
2386
  );
1968
- x.length > 0 && (w({
1969
- ...g,
1970
- geometry: { type: "GeometryCollection", geometries: x }
1971
- }), y = !0);
2387
+ N.length > 0 && (q({
2388
+ ...L,
2389
+ geometry: { type: "GeometryCollection", geometries: N }
2390
+ }), I = !0);
1972
2391
  }
1973
2392
  }
1974
- if (!y) {
1975
- if (g.geometry.type === "Polygon" || g.geometry.type === "MultiPolygon")
1976
- Ft(g, (v) => {
2393
+ if (!I) {
2394
+ if (L.geometry.type === "Polygon" || L.geometry.type === "MultiPolygon")
2395
+ ut(L, (v) => {
1977
2396
  if (!v)
1978
2397
  return;
1979
- const x = [...v.features], m = gt(ut(g)), b = m[2] - m[0];
1980
- m[0] - b / 4 < -180 && x.push(...qt(v, -360).features), m[2] + b / 4 > 180 && x.push(...qt(v, 360).features), w(Z(x));
2398
+ const N = [...v.features], $ = Ve(qe(L)), K = $[2] - $[0];
2399
+ $[0] - K / 4 < -180 && N.push(...ct(v, -360).features), $[2] + K / 4 > 180 && N.push(...ct(v, 360).features), q(ve(N));
1981
2400
  });
1982
- else if (g.geometry.type === "LineString" || g.geometry.type === "MultiLineString") {
1983
- w(g);
1984
- break t;
2401
+ else if (L.geometry.type === "LineString" || L.geometry.type === "MultiLineString") {
2402
+ q(L);
2403
+ break e;
1985
2404
  }
1986
2405
  }
1987
- if (!d && g.geometry.type !== "Point")
1988
- break t;
1989
- if (t instanceof Function) {
1990
- const v = t(r, g);
1991
- v && l.push(v.addTo(r));
1992
- } else if (t) {
1993
- const v = [g.center[1], g.center[0]];
1994
- l.push(
1995
- typeof t == "object" ? new T.Marker(v, t) : a(v).addTo(r)
2406
+ if (!B && L.geometry.type !== "Point")
2407
+ break e;
2408
+ if (e instanceof Function) {
2409
+ const v = e(t, L);
2410
+ v && h.push(v.addTo(t));
2411
+ } else if (e) {
2412
+ const v = [L.center[1], L.center[0]];
2413
+ h.push(
2414
+ typeof e == "object" ? new ce.Marker(v, e) : M(v).addTo(t)
1996
2415
  );
1997
2416
  }
1998
2417
  }
1999
- if (e)
2000
- for (const y of h ?? []) {
2001
- if (y === g)
2418
+ if (n)
2419
+ for (const I of T ?? []) {
2420
+ if (I === L)
2002
2421
  continue;
2003
2422
  const v = [
2004
- y.center[1],
2005
- y.center[0]
2423
+ I.center[1],
2424
+ I.center[0]
2006
2425
  ];
2007
- let x;
2008
- if (e instanceof Function) {
2009
- if (x = e(r, y), !x)
2426
+ let N;
2427
+ if (n instanceof Function) {
2428
+ if (N = n(t, I), !N)
2010
2429
  continue;
2011
2430
  } else
2012
- x = (typeof e == "object" ? new T.Marker(v, e) : a(v, !0)).addTo(r).bindTooltip(
2013
- y.place_type[0] === "reverse" ? y.place_name : y.place_name.replace(/,.*/, ""),
2431
+ N = (typeof n == "object" ? new ce.Marker(v, n) : M(v, !0)).addTo(t).bindTooltip(
2432
+ I.place_type[0] === "reverse" ? I.place_name : I.place_name.replace(/,.*/, ""),
2014
2433
  {
2015
2434
  direction: "top"
2016
2435
  }
2017
2436
  );
2018
- const m = x.getElement();
2019
- m && (m.addEventListener("click", (b) => {
2020
- b.stopPropagation(), u == null || u({ type: "markerClick", id: y.id });
2021
- }), m.addEventListener("mouseenter", () => {
2022
- u == null || u({ type: "markerMouseEnter", id: y.id });
2023
- }), m.addEventListener("mouseleave", () => {
2024
- u == null || u({ type: "markerMouseLeave", id: y.id });
2025
- }), m.classList.toggle("marker-fuzzy", !!y.matching_text)), l.push(x);
2437
+ const $ = N.getElement();
2438
+ $ && ($.addEventListener("click", (K) => {
2439
+ K.stopPropagation(), a == null || a({ type: "markerClick", id: I.id });
2440
+ }), $.addEventListener("mouseenter", () => {
2441
+ a == null || a({ type: "markerMouseEnter", id: I.id });
2442
+ }), $.addEventListener("mouseleave", () => {
2443
+ a == null || a({ type: "markerMouseLeave", id: I.id });
2444
+ }), $.classList.toggle("marker-fuzzy", !!I.matching_text)), h.push(N);
2026
2445
  }
2027
2446
  },
2028
- setSelectedMarker(h) {
2029
- var g, d;
2030
- c && ((g = c.getElement()) == null || g.classList.toggle("marker-selected", !1)), c = h > -1 ? l[h] : void 0, (d = c == null ? void 0 : c.getElement()) == null || d.classList.toggle("marker-selected", !0);
2447
+ setSelectedMarker(T) {
2448
+ var L, B;
2449
+ E && ((L = E.getElement()) == null || L.classList.toggle("marker-selected", !1)), E = T > -1 ? h[T] : void 0, (B = E == null ? void 0 : E.getElement()) == null || B.classList.toggle("marker-selected", !0);
2031
2450
  },
2032
2451
  getCenterAndZoom() {
2033
- const h = r.getCenter();
2034
- return [r.getZoom(), h.lng, h.lat];
2452
+ const T = t.getCenter();
2453
+ return [t.getZoom(), T.lng, T.lat];
2035
2454
  }
2036
2455
  };
2037
2456
  }
2038
- function qt(r, t) {
2039
- const e = ce(r);
2040
- for (const n of e.features)
2041
- if (n.geometry.type == "MultiPolygon")
2042
- for (const i of n.geometry.coordinates)
2043
- Qt(i, t);
2457
+ function ct(t, e) {
2458
+ const n = kt(t);
2459
+ for (const i of n.features)
2460
+ if (i.geometry.type == "MultiPolygon")
2461
+ for (const r of i.geometry.coordinates)
2462
+ at(r, e);
2044
2463
  else
2045
- Qt(n.geometry.coordinates, t);
2046
- return e;
2464
+ at(i.geometry.coordinates, e);
2465
+ return n;
2047
2466
  }
2048
- function Qt(r, t) {
2049
- for (const e of r)
2050
- for (const n of e)
2051
- n[0] += t;
2467
+ function at(t, e) {
2468
+ for (const n of t)
2469
+ for (const i of n)
2470
+ i[0] += e;
2052
2471
  }
2053
2472
  export {
2054
- an as createLeafletMapController
2473
+ Cn as createLeafletMapController
2055
2474
  };
2056
2475
  //# sourceMappingURL=leaflet-controller.js.map