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

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