gs-maplibre-draw 0.0.3 → 0.0.5

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.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- const { abs: R, cos: N, sin: U, acos: et, atan2: J, sqrt: F, pow: L } = Math;
2
- function $(o) {
3
- return o < 0 ? -L(-o, 1 / 3) : L(o, 1 / 3);
1
+ const { abs: pt, cos: ot, sin: ut, acos: ye, atan2: gt, sqrt: lt, pow: W } = Math;
2
+ function mt(n) {
3
+ return n < 0 ? -W(-n, 1 / 3) : W(n, 1 / 3);
4
4
  }
5
- const tt = Math.PI, X = 2 * tt, P = tt / 2, nt = 1e-6, Q = Number.MAX_SAFE_INTEGER || 9007199254740991, H = Number.MIN_SAFE_INTEGER || -9007199254740991, it = { x: 0, y: 0, z: 0 }, y = {
5
+ const Wt = Math.PI, Mt = 2 * Wt, ct = Wt / 2, de = 1e-6, Xt = Number.MAX_SAFE_INTEGER || 9007199254740991, Yt = Number.MIN_SAFE_INTEGER || -9007199254740991, pe = { x: 0, y: 0, z: 0 }, _ = {
6
6
  // Legendre-Gauss abscissae with n=24 (x_i values, defined at i=n as the roots of the nth order Legendre polynomial Pn(x))
7
7
  Tvalues: [
8
8
  -0.06405689286260563,
@@ -57,374 +57,374 @@ const tt = Math.PI, X = 2 * tt, P = tt / 2, nt = 1e-6, Q = Number.MAX_SAFE_INTEG
57
57
  0.0123412297999872,
58
58
  0.0123412297999872
59
59
  ],
60
- arcfn: function(o, e) {
61
- const n = e(o);
62
- let i = n.x * n.x + n.y * n.y;
63
- return typeof n.z < "u" && (i += n.z * n.z), F(i);
60
+ arcfn: function(n, e) {
61
+ const r = e(n);
62
+ let i = r.x * r.x + r.y * r.y;
63
+ return typeof r.z < "u" && (i += r.z * r.z), lt(i);
64
64
  },
65
- compute: function(o, e, n) {
66
- if (o === 0)
65
+ compute: function(n, e, r) {
66
+ if (n === 0)
67
67
  return e[0].t = 0, e[0];
68
68
  const i = e.length - 1;
69
- if (o === 1)
69
+ if (n === 1)
70
70
  return e[i].t = 1, e[i];
71
- const s = 1 - o;
72
- let c = e;
71
+ const o = 1 - n;
72
+ let s = e;
73
73
  if (i === 0)
74
- return e[0].t = o, e[0];
74
+ return e[0].t = n, e[0];
75
75
  if (i === 1) {
76
76
  const l = {
77
- x: s * c[0].x + o * c[1].x,
78
- y: s * c[0].y + o * c[1].y,
79
- t: o
77
+ x: o * s[0].x + n * s[1].x,
78
+ y: o * s[0].y + n * s[1].y,
79
+ t: n
80
80
  };
81
- return n && (l.z = s * c[0].z + o * c[1].z), l;
81
+ return r && (l.z = o * s[0].z + n * s[1].z), l;
82
82
  }
83
83
  if (i < 4) {
84
- let l = s * s, u = o * o, f, h, a, p = 0;
85
- i === 2 ? (c = [c[0], c[1], c[2], it], f = l, h = s * o * 2, a = u) : i === 3 && (f = l * s, h = l * o * 3, a = s * u * 3, p = o * u);
86
- const g = {
87
- x: f * c[0].x + h * c[1].x + a * c[2].x + p * c[3].x,
88
- y: f * c[0].y + h * c[1].y + a * c[2].y + p * c[3].y,
89
- t: o
84
+ let l = o * o, c = n * n, f, g, y, d = 0;
85
+ i === 2 ? (s = [s[0], s[1], s[2], pe], f = l, g = o * n * 2, y = c) : i === 3 && (f = l * o, g = l * n * 3, y = o * c * 3, d = n * c);
86
+ const M = {
87
+ x: f * s[0].x + g * s[1].x + y * s[2].x + d * s[3].x,
88
+ y: f * s[0].y + g * s[1].y + y * s[2].y + d * s[3].y,
89
+ t: n
90
90
  };
91
- return n && (g.z = f * c[0].z + h * c[1].z + a * c[2].z + p * c[3].z), g;
91
+ return r && (M.z = f * s[0].z + g * s[1].z + y * s[2].z + d * s[3].z), M;
92
92
  }
93
- const r = JSON.parse(JSON.stringify(e));
94
- for (; r.length > 1; ) {
95
- for (let l = 0; l < r.length - 1; l++)
96
- r[l] = {
97
- x: r[l].x + (r[l + 1].x - r[l].x) * o,
98
- y: r[l].y + (r[l + 1].y - r[l].y) * o
99
- }, typeof r[l].z < "u" && (r[l].z = r[l].z + (r[l + 1].z - r[l].z) * o);
100
- r.splice(r.length - 1, 1);
93
+ const a = JSON.parse(JSON.stringify(e));
94
+ for (; a.length > 1; ) {
95
+ for (let l = 0; l < a.length - 1; l++)
96
+ a[l] = {
97
+ x: a[l].x + (a[l + 1].x - a[l].x) * n,
98
+ y: a[l].y + (a[l + 1].y - a[l].y) * n
99
+ }, typeof a[l].z < "u" && (a[l].z = a[l].z + (a[l + 1].z - a[l].z) * n);
100
+ a.splice(a.length - 1, 1);
101
101
  }
102
- return r[0].t = o, r[0];
102
+ return a[0].t = n, a[0];
103
103
  },
104
- computeWithRatios: function(o, e, n, i) {
105
- const s = 1 - o, c = n, r = e;
106
- let l = c[0], u = c[1], f = c[2], h = c[3], a;
107
- if (l *= s, u *= o, r.length === 2)
108
- return a = l + u, {
109
- x: (l * r[0].x + u * r[1].x) / a,
110
- y: (l * r[0].y + u * r[1].y) / a,
111
- z: i ? (l * r[0].z + u * r[1].z) / a : !1,
112
- t: o
104
+ computeWithRatios: function(n, e, r, i) {
105
+ const o = 1 - n, s = r, a = e;
106
+ let l = s[0], c = s[1], f = s[2], g = s[3], y;
107
+ if (l *= o, c *= n, a.length === 2)
108
+ return y = l + c, {
109
+ x: (l * a[0].x + c * a[1].x) / y,
110
+ y: (l * a[0].y + c * a[1].y) / y,
111
+ z: i ? (l * a[0].z + c * a[1].z) / y : !1,
112
+ t: n
113
113
  };
114
- if (l *= s, u *= 2 * s, f *= o * o, r.length === 3)
115
- return a = l + u + f, {
116
- x: (l * r[0].x + u * r[1].x + f * r[2].x) / a,
117
- y: (l * r[0].y + u * r[1].y + f * r[2].y) / a,
118
- z: i ? (l * r[0].z + u * r[1].z + f * r[2].z) / a : !1,
119
- t: o
114
+ if (l *= o, c *= 2 * o, f *= n * n, a.length === 3)
115
+ return y = l + c + f, {
116
+ x: (l * a[0].x + c * a[1].x + f * a[2].x) / y,
117
+ y: (l * a[0].y + c * a[1].y + f * a[2].y) / y,
118
+ z: i ? (l * a[0].z + c * a[1].z + f * a[2].z) / y : !1,
119
+ t: n
120
120
  };
121
- if (l *= s, u *= 1.5 * s, f *= 3 * s, h *= o * o * o, r.length === 4)
122
- return a = l + u + f + h, {
123
- x: (l * r[0].x + u * r[1].x + f * r[2].x + h * r[3].x) / a,
124
- y: (l * r[0].y + u * r[1].y + f * r[2].y + h * r[3].y) / a,
125
- z: i ? (l * r[0].z + u * r[1].z + f * r[2].z + h * r[3].z) / a : !1,
126
- t: o
121
+ if (l *= o, c *= 1.5 * o, f *= 3 * o, g *= n * n * n, a.length === 4)
122
+ return y = l + c + f + g, {
123
+ x: (l * a[0].x + c * a[1].x + f * a[2].x + g * a[3].x) / y,
124
+ y: (l * a[0].y + c * a[1].y + f * a[2].y + g * a[3].y) / y,
125
+ z: i ? (l * a[0].z + c * a[1].z + f * a[2].z + g * a[3].z) / y : !1,
126
+ t: n
127
127
  };
128
128
  },
129
- derive: function(o, e) {
130
- const n = [];
131
- for (let i = o, s = i.length, c = s - 1; s > 1; s--, c--) {
132
- const r = [];
133
- for (let l = 0, u; l < c; l++)
134
- u = {
135
- x: c * (i[l + 1].x - i[l].x),
136
- y: c * (i[l + 1].y - i[l].y)
137
- }, e && (u.z = c * (i[l + 1].z - i[l].z)), r.push(u);
138
- n.push(r), i = r;
129
+ derive: function(n, e) {
130
+ const r = [];
131
+ for (let i = n, o = i.length, s = o - 1; o > 1; o--, s--) {
132
+ const a = [];
133
+ for (let l = 0, c; l < s; l++)
134
+ c = {
135
+ x: s * (i[l + 1].x - i[l].x),
136
+ y: s * (i[l + 1].y - i[l].y)
137
+ }, e && (c.z = s * (i[l + 1].z - i[l].z)), a.push(c);
138
+ r.push(a), i = a;
139
139
  }
140
- return n;
140
+ return r;
141
141
  },
142
- between: function(o, e, n) {
143
- return e <= o && o <= n || y.approximately(o, e) || y.approximately(o, n);
142
+ between: function(n, e, r) {
143
+ return e <= n && n <= r || _.approximately(n, e) || _.approximately(n, r);
144
144
  },
145
- approximately: function(o, e, n) {
146
- return R(o - e) <= (n || nt);
145
+ approximately: function(n, e, r) {
146
+ return pt(n - e) <= (r || de);
147
147
  },
148
- length: function(o) {
149
- const n = y.Tvalues.length;
148
+ length: function(n) {
149
+ const r = _.Tvalues.length;
150
150
  let i = 0;
151
- for (let s = 0, c; s < n; s++)
152
- c = 0.5 * y.Tvalues[s] + 0.5, i += y.Cvalues[s] * y.arcfn(c, o);
151
+ for (let o = 0, s; o < r; o++)
152
+ s = 0.5 * _.Tvalues[o] + 0.5, i += _.Cvalues[o] * _.arcfn(s, n);
153
153
  return 0.5 * i;
154
154
  },
155
- map: function(o, e, n, i, s) {
156
- const c = n - e, r = s - i, l = o - e, u = l / c;
157
- return i + r * u;
155
+ map: function(n, e, r, i, o) {
156
+ const s = r - e, a = o - i, l = n - e, c = l / s;
157
+ return i + a * c;
158
158
  },
159
- lerp: function(o, e, n) {
159
+ lerp: function(n, e, r) {
160
160
  const i = {
161
- x: e.x + o * (n.x - e.x),
162
- y: e.y + o * (n.y - e.y)
161
+ x: e.x + n * (r.x - e.x),
162
+ y: e.y + n * (r.y - e.y)
163
163
  };
164
- return e.z !== void 0 && n.z !== void 0 && (i.z = e.z + o * (n.z - e.z)), i;
164
+ return e.z !== void 0 && r.z !== void 0 && (i.z = e.z + n * (r.z - e.z)), i;
165
165
  },
166
- pointToString: function(o) {
167
- let e = o.x + "/" + o.y;
168
- return typeof o.z < "u" && (e += "/" + o.z), e;
166
+ pointToString: function(n) {
167
+ let e = n.x + "/" + n.y;
168
+ return typeof n.z < "u" && (e += "/" + n.z), e;
169
169
  },
170
- pointsToString: function(o) {
171
- return "[" + o.map(y.pointToString).join(", ") + "]";
170
+ pointsToString: function(n) {
171
+ return "[" + n.map(_.pointToString).join(", ") + "]";
172
172
  },
173
- copy: function(o) {
174
- return JSON.parse(JSON.stringify(o));
173
+ copy: function(n) {
174
+ return JSON.parse(JSON.stringify(n));
175
175
  },
176
- angle: function(o, e, n) {
177
- const i = e.x - o.x, s = e.y - o.y, c = n.x - o.x, r = n.y - o.y, l = i * r - s * c, u = i * c + s * r;
178
- return J(l, u);
176
+ angle: function(n, e, r) {
177
+ const i = e.x - n.x, o = e.y - n.y, s = r.x - n.x, a = r.y - n.y, l = i * a - o * s, c = i * s + o * a;
178
+ return gt(l, c);
179
179
  },
180
180
  // round as string, to avoid rounding errors
181
- round: function(o, e) {
182
- const n = "" + o, i = n.indexOf(".");
183
- return parseFloat(n.substring(0, i + 1 + e));
181
+ round: function(n, e) {
182
+ const r = "" + n, i = r.indexOf(".");
183
+ return parseFloat(r.substring(0, i + 1 + e));
184
184
  },
185
- dist: function(o, e) {
186
- const n = o.x - e.x, i = o.y - e.y;
187
- return F(n * n + i * i);
185
+ dist: function(n, e) {
186
+ const r = n.x - e.x, i = n.y - e.y;
187
+ return lt(r * r + i * i);
188
188
  },
189
- closest: function(o, e) {
190
- let n = L(2, 63), i, s;
191
- return o.forEach(function(c, r) {
192
- s = y.dist(e, c), s < n && (n = s, i = r);
193
- }), { mdist: n, mpos: i };
189
+ closest: function(n, e) {
190
+ let r = W(2, 63), i, o;
191
+ return n.forEach(function(s, a) {
192
+ o = _.dist(e, s), o < r && (r = o, i = a);
193
+ }), { mdist: r, mpos: i };
194
194
  },
195
- abcratio: function(o, e) {
195
+ abcratio: function(n, e) {
196
196
  if (e !== 2 && e !== 3)
197
197
  return !1;
198
- if (typeof o > "u")
199
- o = 0.5;
200
- else if (o === 0 || o === 1)
201
- return o;
202
- const n = L(o, e) + L(1 - o, e), i = n - 1;
203
- return R(i / n);
198
+ if (typeof n > "u")
199
+ n = 0.5;
200
+ else if (n === 0 || n === 1)
201
+ return n;
202
+ const r = W(n, e) + W(1 - n, e), i = r - 1;
203
+ return pt(i / r);
204
204
  },
205
- projectionratio: function(o, e) {
205
+ projectionratio: function(n, e) {
206
206
  if (e !== 2 && e !== 3)
207
207
  return !1;
208
- if (typeof o > "u")
209
- o = 0.5;
210
- else if (o === 0 || o === 1)
211
- return o;
212
- const n = L(1 - o, e), i = L(o, e) + n;
213
- return n / i;
208
+ if (typeof n > "u")
209
+ n = 0.5;
210
+ else if (n === 0 || n === 1)
211
+ return n;
212
+ const r = W(1 - n, e), i = W(n, e) + r;
213
+ return r / i;
214
214
  },
215
- lli8: function(o, e, n, i, s, c, r, l) {
216
- const u = (o * i - e * n) * (s - r) - (o - n) * (s * l - c * r), f = (o * i - e * n) * (c - l) - (e - i) * (s * l - c * r), h = (o - n) * (c - l) - (e - i) * (s - r);
217
- return h == 0 ? !1 : { x: u / h, y: f / h };
215
+ lli8: function(n, e, r, i, o, s, a, l) {
216
+ const c = (n * i - e * r) * (o - a) - (n - r) * (o * l - s * a), f = (n * i - e * r) * (s - l) - (e - i) * (o * l - s * a), g = (n - r) * (s - l) - (e - i) * (o - a);
217
+ return g == 0 ? !1 : { x: c / g, y: f / g };
218
218
  },
219
- lli4: function(o, e, n, i) {
220
- const s = o.x, c = o.y, r = e.x, l = e.y, u = n.x, f = n.y, h = i.x, a = i.y;
221
- return y.lli8(s, c, r, l, u, f, h, a);
219
+ lli4: function(n, e, r, i) {
220
+ const o = n.x, s = n.y, a = e.x, l = e.y, c = r.x, f = r.y, g = i.x, y = i.y;
221
+ return _.lli8(o, s, a, l, c, f, g, y);
222
222
  },
223
- lli: function(o, e) {
224
- return y.lli4(o, o.c, e, e.c);
223
+ lli: function(n, e) {
224
+ return _.lli4(n, n.c, e, e.c);
225
225
  },
226
- makeline: function(o, e) {
227
- return new E(
228
- o.x,
229
- o.y,
230
- (o.x + e.x) / 2,
231
- (o.y + e.y) / 2,
226
+ makeline: function(n, e) {
227
+ return new U(
228
+ n.x,
229
+ n.y,
230
+ (n.x + e.x) / 2,
231
+ (n.y + e.y) / 2,
232
232
  e.x,
233
233
  e.y
234
234
  );
235
235
  },
236
- findbbox: function(o) {
237
- let e = Q, n = Q, i = H, s = H;
238
- return o.forEach(function(c) {
239
- const r = c.bbox();
240
- e > r.x.min && (e = r.x.min), n > r.y.min && (n = r.y.min), i < r.x.max && (i = r.x.max), s < r.y.max && (s = r.y.max);
236
+ findbbox: function(n) {
237
+ let e = Xt, r = Xt, i = Yt, o = Yt;
238
+ return n.forEach(function(s) {
239
+ const a = s.bbox();
240
+ e > a.x.min && (e = a.x.min), r > a.y.min && (r = a.y.min), i < a.x.max && (i = a.x.max), o < a.y.max && (o = a.y.max);
241
241
  }), {
242
242
  x: { min: e, mid: (e + i) / 2, max: i, size: i - e },
243
- y: { min: n, mid: (n + s) / 2, max: s, size: s - n }
243
+ y: { min: r, mid: (r + o) / 2, max: o, size: o - r }
244
244
  };
245
245
  },
246
- shapeintersections: function(o, e, n, i, s) {
247
- if (!y.bboxoverlap(e, i))
246
+ shapeintersections: function(n, e, r, i, o) {
247
+ if (!_.bboxoverlap(e, i))
248
248
  return [];
249
- const c = [], r = [o.startcap, o.forward, o.back, o.endcap], l = [n.startcap, n.forward, n.back, n.endcap];
250
- return r.forEach(function(u) {
251
- u.virtual || l.forEach(function(f) {
249
+ const s = [], a = [n.startcap, n.forward, n.back, n.endcap], l = [r.startcap, r.forward, r.back, r.endcap];
250
+ return a.forEach(function(c) {
251
+ c.virtual || l.forEach(function(f) {
252
252
  if (f.virtual)
253
253
  return;
254
- const h = u.intersects(f, s);
255
- h.length > 0 && (h.c1 = u, h.c2 = f, h.s1 = o, h.s2 = n, c.push(h));
254
+ const g = c.intersects(f, o);
255
+ g.length > 0 && (g.c1 = c, g.c2 = f, g.s1 = n, g.s2 = r, s.push(g));
256
256
  });
257
- }), c;
257
+ }), s;
258
258
  },
259
- makeshape: function(o, e, n) {
260
- const i = e.points.length, s = o.points.length, c = y.makeline(e.points[i - 1], o.points[0]), r = y.makeline(o.points[s - 1], e.points[0]), l = {
261
- startcap: c,
262
- forward: o,
259
+ makeshape: function(n, e, r) {
260
+ const i = e.points.length, o = n.points.length, s = _.makeline(e.points[i - 1], n.points[0]), a = _.makeline(n.points[o - 1], e.points[0]), l = {
261
+ startcap: s,
262
+ forward: n,
263
263
  back: e,
264
- endcap: r,
265
- bbox: y.findbbox([c, o, e, r])
264
+ endcap: a,
265
+ bbox: _.findbbox([s, n, e, a])
266
266
  };
267
- return l.intersections = function(u) {
268
- return y.shapeintersections(
267
+ return l.intersections = function(c) {
268
+ return _.shapeintersections(
269
269
  l,
270
270
  l.bbox,
271
- u,
272
- u.bbox,
273
- n
271
+ c,
272
+ c.bbox,
273
+ r
274
274
  );
275
275
  }, l;
276
276
  },
277
- getminmax: function(o, e, n) {
278
- if (!n)
277
+ getminmax: function(n, e, r) {
278
+ if (!r)
279
279
  return { min: 0, max: 0 };
280
- let i = Q, s = H, c, r;
281
- n.indexOf(0) === -1 && (n = [0].concat(n)), n.indexOf(1) === -1 && n.push(1);
282
- for (let l = 0, u = n.length; l < u; l++)
283
- c = n[l], r = o.get(c), r[e] < i && (i = r[e]), r[e] > s && (s = r[e]);
284
- return { min: i, mid: (i + s) / 2, max: s, size: s - i };
280
+ let i = Xt, o = Yt, s, a;
281
+ r.indexOf(0) === -1 && (r = [0].concat(r)), r.indexOf(1) === -1 && r.push(1);
282
+ for (let l = 0, c = r.length; l < c; l++)
283
+ s = r[l], a = n.get(s), a[e] < i && (i = a[e]), a[e] > o && (o = a[e]);
284
+ return { min: i, mid: (i + o) / 2, max: o, size: o - i };
285
285
  },
286
- align: function(o, e) {
287
- const n = e.p1.x, i = e.p1.y, s = -J(e.p2.y - i, e.p2.x - n), c = function(r) {
286
+ align: function(n, e) {
287
+ const r = e.p1.x, i = e.p1.y, o = -gt(e.p2.y - i, e.p2.x - r), s = function(a) {
288
288
  return {
289
- x: (r.x - n) * N(s) - (r.y - i) * U(s),
290
- y: (r.x - n) * U(s) + (r.y - i) * N(s)
289
+ x: (a.x - r) * ot(o) - (a.y - i) * ut(o),
290
+ y: (a.x - r) * ut(o) + (a.y - i) * ot(o)
291
291
  };
292
292
  };
293
- return o.map(c);
293
+ return n.map(s);
294
294
  },
295
- roots: function(o, e) {
295
+ roots: function(n, e) {
296
296
  e = e || { p1: { x: 0, y: 0 }, p2: { x: 1, y: 0 } };
297
- const n = o.length - 1, i = y.align(o, e), s = function(x) {
297
+ const r = n.length - 1, i = _.align(n, e), o = function(x) {
298
298
  return 0 <= x && x <= 1;
299
299
  };
300
- if (n === 2) {
301
- const x = i[0].y, m = i[1].y, v = i[2].y, w = x - 2 * m + v;
302
- if (w !== 0) {
303
- const b = -F(m * m - x * v), k = -x + m, q = -(b + k) / w, M = -(-b + k) / w;
304
- return [q, M].filter(s);
305
- } else if (m !== v && w === 0)
306
- return [(2 * m - v) / (2 * m - 2 * v)].filter(s);
300
+ if (r === 2) {
301
+ const x = i[0].y, v = i[1].y, S = i[2].y, X = x - 2 * v + S;
302
+ if (X !== 0) {
303
+ const Y = -lt(v * v - x * S), b = -x + v, N = -(Y + b) / X, R = -(-Y + b) / X;
304
+ return [N, R].filter(o);
305
+ } else if (v !== S && X === 0)
306
+ return [(2 * v - S) / (2 * v - 2 * S)].filter(o);
307
307
  return [];
308
308
  }
309
- const c = i[0].y, r = i[1].y, l = i[2].y, u = i[3].y;
310
- let f = -c + 3 * r - 3 * l + u, h = 3 * c - 6 * r + 3 * l, a = -3 * c + 3 * r, p = c;
311
- if (y.approximately(f, 0)) {
312
- if (y.approximately(h, 0))
313
- return y.approximately(a, 0) ? [] : [-p / a].filter(s);
314
- const x = F(a * a - 4 * h * p), m = 2 * h;
315
- return [(x - a) / m, (-a - x) / m].filter(s);
309
+ const s = i[0].y, a = i[1].y, l = i[2].y, c = i[3].y;
310
+ let f = -s + 3 * a - 3 * l + c, g = 3 * s - 6 * a + 3 * l, y = -3 * s + 3 * a, d = s;
311
+ if (_.approximately(f, 0)) {
312
+ if (_.approximately(g, 0))
313
+ return _.approximately(y, 0) ? [] : [-d / y].filter(o);
314
+ const x = lt(y * y - 4 * g * d), v = 2 * g;
315
+ return [(x - y) / v, (-y - x) / v].filter(o);
316
316
  }
317
- h /= f, a /= f, p /= f;
318
- const g = (3 * a - h * h) / 3, _ = g / 3, C = (2 * h * h * h - 9 * h * a + 27 * p) / 27, A = C / 2, S = A * A + _ * _ * _;
319
- let j, O, T, z, d;
320
- if (S < 0) {
321
- const x = -g / 3, m = x * x * x, v = F(m), w = -C / (2 * v), b = w < -1 ? -1 : w > 1 ? 1 : w, k = et(b), q = $(v), M = 2 * q;
322
- return T = M * N(k / 3) - h / 3, z = M * N((k + X) / 3) - h / 3, d = M * N((k + 2 * X) / 3) - h / 3, [T, z, d].filter(s);
317
+ g /= f, y /= f, d /= f;
318
+ const M = (3 * y - g * g) / 3, k = M / 3, L = (2 * g * g * g - 9 * g * y + 27 * d) / 27, D = L / 2, O = D * D + k * k * k;
319
+ let u, h, m, p, w;
320
+ if (O < 0) {
321
+ const x = -M / 3, v = x * x * x, S = lt(v), X = -L / (2 * S), Y = X < -1 ? -1 : X > 1 ? 1 : X, b = ye(Y), N = mt(S), R = 2 * N;
322
+ return m = R * ot(b / 3) - g / 3, p = R * ot((b + Mt) / 3) - g / 3, w = R * ot((b + 2 * Mt) / 3) - g / 3, [m, p, w].filter(o);
323
323
  } else {
324
- if (S === 0)
325
- return j = A < 0 ? $(-A) : -$(A), T = 2 * j - h / 3, z = -j - h / 3, [T, z].filter(s);
324
+ if (O === 0)
325
+ return u = D < 0 ? mt(-D) : -mt(D), m = 2 * u - g / 3, p = -u - g / 3, [m, p].filter(o);
326
326
  {
327
- const x = F(S);
328
- return j = $(-A + x), O = $(A + x), [j - O - h / 3].filter(s);
327
+ const x = lt(O);
328
+ return u = mt(-D + x), h = mt(D + x), [u - h - g / 3].filter(o);
329
329
  }
330
330
  }
331
331
  },
332
- droots: function(o) {
333
- if (o.length === 3) {
334
- const e = o[0], n = o[1], i = o[2], s = e - 2 * n + i;
335
- if (s !== 0) {
336
- const c = -F(n * n - e * i), r = -e + n, l = -(c + r) / s, u = -(-c + r) / s;
337
- return [l, u];
338
- } else if (n !== i && s === 0)
339
- return [(2 * n - i) / (2 * (n - i))];
332
+ droots: function(n) {
333
+ if (n.length === 3) {
334
+ const e = n[0], r = n[1], i = n[2], o = e - 2 * r + i;
335
+ if (o !== 0) {
336
+ const s = -lt(r * r - e * i), a = -e + r, l = -(s + a) / o, c = -(-s + a) / o;
337
+ return [l, c];
338
+ } else if (r !== i && o === 0)
339
+ return [(2 * r - i) / (2 * (r - i))];
340
340
  return [];
341
341
  }
342
- if (o.length === 2) {
343
- const e = o[0], n = o[1];
344
- return e !== n ? [e / (e - n)] : [];
342
+ if (n.length === 2) {
343
+ const e = n[0], r = n[1];
344
+ return e !== r ? [e / (e - r)] : [];
345
345
  }
346
346
  return [];
347
347
  },
348
- curvature: function(o, e, n, i, s) {
349
- let c, r, l, u, f = 0, h = 0;
350
- const a = y.compute(o, e), p = y.compute(o, n), g = a.x * a.x + a.y * a.y;
351
- if (i ? (c = F(
352
- L(a.y * p.z - p.y * a.z, 2) + L(a.z * p.x - p.z * a.x, 2) + L(a.x * p.y - p.x * a.y, 2)
353
- ), r = L(g + a.z * a.z, 3 / 2)) : (c = a.x * p.y - a.y * p.x, r = L(g, 3 / 2)), c === 0 || r === 0)
348
+ curvature: function(n, e, r, i, o) {
349
+ let s, a, l, c, f = 0, g = 0;
350
+ const y = _.compute(n, e), d = _.compute(n, r), M = y.x * y.x + y.y * y.y;
351
+ if (i ? (s = lt(
352
+ W(y.y * d.z - d.y * y.z, 2) + W(y.z * d.x - d.z * y.x, 2) + W(y.x * d.y - d.x * y.y, 2)
353
+ ), a = W(M + y.z * y.z, 3 / 2)) : (s = y.x * d.y - y.y * d.x, a = W(M, 3 / 2)), s === 0 || a === 0)
354
354
  return { k: 0, r: 0 };
355
- if (f = c / r, h = r / c, !s) {
356
- const _ = y.curvature(o - 1e-3, e, n, i, !0).k, C = y.curvature(o + 1e-3, e, n, i, !0).k;
357
- u = (C - f + (f - _)) / 2, l = (R(C - f) + R(f - _)) / 2;
355
+ if (f = s / a, g = a / s, !o) {
356
+ const k = _.curvature(n - 1e-3, e, r, i, !0).k, L = _.curvature(n + 1e-3, e, r, i, !0).k;
357
+ c = (L - f + (f - k)) / 2, l = (pt(L - f) + pt(f - k)) / 2;
358
358
  }
359
- return { k: f, r: h, dk: u, adk: l };
359
+ return { k: f, r: g, dk: c, adk: l };
360
360
  },
361
- inflections: function(o) {
362
- if (o.length < 4)
361
+ inflections: function(n) {
362
+ if (n.length < 4)
363
363
  return [];
364
- const e = y.align(o, { p1: o[0], p2: o.slice(-1)[0] }), n = e[2].x * e[1].y, i = e[3].x * e[1].y, s = e[1].x * e[2].y, c = e[3].x * e[2].y, r = 18 * (-3 * n + 2 * i + 3 * s - c), l = 18 * (3 * n - i - 3 * s), u = 18 * (s - n);
365
- if (y.approximately(r, 0)) {
366
- if (!y.approximately(l, 0)) {
367
- let p = -u / l;
368
- if (0 <= p && p <= 1)
369
- return [p];
364
+ const e = _.align(n, { p1: n[0], p2: n.slice(-1)[0] }), r = e[2].x * e[1].y, i = e[3].x * e[1].y, o = e[1].x * e[2].y, s = e[3].x * e[2].y, a = 18 * (-3 * r + 2 * i + 3 * o - s), l = 18 * (3 * r - i - 3 * o), c = 18 * (o - r);
365
+ if (_.approximately(a, 0)) {
366
+ if (!_.approximately(l, 0)) {
367
+ let d = -c / l;
368
+ if (0 <= d && d <= 1)
369
+ return [d];
370
370
  }
371
371
  return [];
372
372
  }
373
- const f = 2 * r;
374
- if (y.approximately(f, 0))
373
+ const f = 2 * a;
374
+ if (_.approximately(f, 0))
375
375
  return [];
376
- const h = l * l - 4 * r * u;
377
- if (h < 0)
376
+ const g = l * l - 4 * a * c;
377
+ if (g < 0)
378
378
  return [];
379
- const a = Math.sqrt(h);
380
- return [(a - l) / f, -(l + a) / f].filter(function(p) {
381
- return 0 <= p && p <= 1;
379
+ const y = Math.sqrt(g);
380
+ return [(y - l) / f, -(l + y) / f].filter(function(d) {
381
+ return 0 <= d && d <= 1;
382
382
  });
383
383
  },
384
- bboxoverlap: function(o, e) {
385
- const n = ["x", "y"], i = n.length;
386
- for (let s = 0, c, r, l, u; s < i; s++)
387
- if (c = n[s], r = o[c].mid, l = e[c].mid, u = (o[c].size + e[c].size) / 2, R(r - l) >= u)
384
+ bboxoverlap: function(n, e) {
385
+ const r = ["x", "y"], i = r.length;
386
+ for (let o = 0, s, a, l, c; o < i; o++)
387
+ if (s = r[o], a = n[s].mid, l = e[s].mid, c = (n[s].size + e[s].size) / 2, pt(a - l) >= c)
388
388
  return !1;
389
389
  return !0;
390
390
  },
391
- expandbox: function(o, e) {
392
- e.x.min < o.x.min && (o.x.min = e.x.min), e.y.min < o.y.min && (o.y.min = e.y.min), e.z && e.z.min < o.z.min && (o.z.min = e.z.min), e.x.max > o.x.max && (o.x.max = e.x.max), e.y.max > o.y.max && (o.y.max = e.y.max), e.z && e.z.max > o.z.max && (o.z.max = e.z.max), o.x.mid = (o.x.min + o.x.max) / 2, o.y.mid = (o.y.min + o.y.max) / 2, o.z && (o.z.mid = (o.z.min + o.z.max) / 2), o.x.size = o.x.max - o.x.min, o.y.size = o.y.max - o.y.min, o.z && (o.z.size = o.z.max - o.z.min);
391
+ expandbox: function(n, e) {
392
+ e.x.min < n.x.min && (n.x.min = e.x.min), e.y.min < n.y.min && (n.y.min = e.y.min), e.z && e.z.min < n.z.min && (n.z.min = e.z.min), e.x.max > n.x.max && (n.x.max = e.x.max), e.y.max > n.y.max && (n.y.max = e.y.max), e.z && e.z.max > n.z.max && (n.z.max = e.z.max), n.x.mid = (n.x.min + n.x.max) / 2, n.y.mid = (n.y.min + n.y.max) / 2, n.z && (n.z.mid = (n.z.min + n.z.max) / 2), n.x.size = n.x.max - n.x.min, n.y.size = n.y.max - n.y.min, n.z && (n.z.size = n.z.max - n.z.min);
393
393
  },
394
- pairiteration: function(o, e, n) {
395
- const i = o.bbox(), s = e.bbox(), c = 1e5, r = n || 0.5;
396
- if (i.x.size + i.y.size < r && s.x.size + s.y.size < r)
394
+ pairiteration: function(n, e, r) {
395
+ const i = n.bbox(), o = e.bbox(), s = 1e5, a = r || 0.5;
396
+ if (i.x.size + i.y.size < a && o.x.size + o.y.size < a)
397
397
  return [
398
- (c * (o._t1 + o._t2) / 2 | 0) / c + "/" + (c * (e._t1 + e._t2) / 2 | 0) / c
398
+ (s * (n._t1 + n._t2) / 2 | 0) / s + "/" + (s * (e._t1 + e._t2) / 2 | 0) / s
399
399
  ];
400
- let l = o.split(0.5), u = e.split(0.5), f = [
401
- { left: l.left, right: u.left },
402
- { left: l.left, right: u.right },
403
- { left: l.right, right: u.right },
404
- { left: l.right, right: u.left }
400
+ let l = n.split(0.5), c = e.split(0.5), f = [
401
+ { left: l.left, right: c.left },
402
+ { left: l.left, right: c.right },
403
+ { left: l.right, right: c.right },
404
+ { left: l.right, right: c.left }
405
405
  ];
406
- f = f.filter(function(a) {
407
- return y.bboxoverlap(a.left.bbox(), a.right.bbox());
406
+ f = f.filter(function(y) {
407
+ return _.bboxoverlap(y.left.bbox(), y.right.bbox());
408
408
  });
409
- let h = [];
410
- return f.length === 0 || (f.forEach(function(a) {
411
- h = h.concat(
412
- y.pairiteration(a.left, a.right, r)
409
+ let g = [];
410
+ return f.length === 0 || (f.forEach(function(y) {
411
+ g = g.concat(
412
+ _.pairiteration(y.left, y.right, a)
413
413
  );
414
- }), h = h.filter(function(a, p) {
415
- return h.indexOf(a) === p;
416
- })), h;
414
+ }), g = g.filter(function(y, d) {
415
+ return g.indexOf(y) === d;
416
+ })), g;
417
417
  },
418
- getccenter: function(o, e, n) {
419
- const i = e.x - o.x, s = e.y - o.y, c = n.x - e.x, r = n.y - e.y, l = i * N(P) - s * U(P), u = i * U(P) + s * N(P), f = c * N(P) - r * U(P), h = c * U(P) + r * N(P), a = (o.x + e.x) / 2, p = (o.y + e.y) / 2, g = (e.x + n.x) / 2, _ = (e.y + n.y) / 2, C = a + l, A = p + u, S = g + f, j = _ + h, O = y.lli8(a, p, C, A, g, _, S, j), T = y.dist(O, o);
420
- let z = J(o.y - O.y, o.x - O.x), d = J(e.y - O.y, e.x - O.x), x = J(n.y - O.y, n.x - O.x), m;
421
- return z < x ? ((z > d || d > x) && (z += X), z > x && (m = x, x = z, z = m)) : x < d && d < z ? (m = x, x = z, z = m) : x += X, O.s = z, O.e = x, O.r = T, O;
418
+ getccenter: function(n, e, r) {
419
+ const i = e.x - n.x, o = e.y - n.y, s = r.x - e.x, a = r.y - e.y, l = i * ot(ct) - o * ut(ct), c = i * ut(ct) + o * ot(ct), f = s * ot(ct) - a * ut(ct), g = s * ut(ct) + a * ot(ct), y = (n.x + e.x) / 2, d = (n.y + e.y) / 2, M = (e.x + r.x) / 2, k = (e.y + r.y) / 2, L = y + l, D = d + c, O = M + f, u = k + g, h = _.lli8(y, d, L, D, M, k, O, u), m = _.dist(h, n);
420
+ let p = gt(n.y - h.y, n.x - h.x), w = gt(e.y - h.y, e.x - h.x), x = gt(r.y - h.y, r.x - h.x), v;
421
+ return p < x ? ((p > w || w > x) && (p += Mt), p > x && (v = x, x = p, p = v)) : x < w && w < p ? (v = x, x = p, p = v) : x += Mt, h.s = p, h.e = x, h.r = m, h;
422
422
  },
423
- numberSort: function(o, e) {
424
- return o - e;
423
+ numberSort: function(n, e) {
424
+ return n - e;
425
425
  }
426
426
  };
427
- class V {
427
+ class wt {
428
428
  constructor(e) {
429
429
  this.curves = [], this._3d = !1, e && (this.curves = e, this._3d = this.curves[0]._3d);
430
430
  }
@@ -433,7 +433,7 @@ class V {
433
433
  }
434
434
  toString() {
435
435
  return "[" + this.curves.map(function(e) {
436
- return y.pointsToString(e.points);
436
+ return _.pointsToString(e.points);
437
437
  }).join(", ") + "]";
438
438
  }
439
439
  addCurve(e) {
@@ -442,8 +442,8 @@ class V {
442
442
  length() {
443
443
  return this.curves.map(function(e) {
444
444
  return e.length();
445
- }).reduce(function(e, n) {
446
- return e + n;
445
+ }).reduce(function(e, r) {
446
+ return e + r;
447
447
  });
448
448
  }
449
449
  curve(e) {
@@ -451,97 +451,97 @@ class V {
451
451
  }
452
452
  bbox() {
453
453
  const e = this.curves;
454
- for (var n = e[0].bbox(), i = 1; i < e.length; i++)
455
- y.expandbox(n, e[i].bbox());
456
- return n;
454
+ for (var r = e[0].bbox(), i = 1; i < e.length; i++)
455
+ _.expandbox(r, e[i].bbox());
456
+ return r;
457
457
  }
458
458
  offset(e) {
459
- const n = [];
459
+ const r = [];
460
460
  return this.curves.forEach(function(i) {
461
- n.push(...i.offset(e));
462
- }), new V(n);
461
+ r.push(...i.offset(e));
462
+ }), new wt(r);
463
463
  }
464
464
  }
465
- const { abs: G, min: K, max: B, cos: rt, sin: st, acos: ot, sqrt: Z } = Math, ct = Math.PI;
466
- class E {
465
+ const { abs: xt, min: $t, max: Gt, cos: ge, sin: me, acos: xe, sqrt: vt } = Math, ve = Math.PI;
466
+ class U {
467
467
  constructor(e) {
468
- let n = e && e.forEach ? e : Array.from(arguments).slice(), i = !1;
469
- if (typeof n[0] == "object") {
470
- i = n.length;
471
- const g = [];
472
- n.forEach(function(_) {
473
- ["x", "y", "z"].forEach(function(C) {
474
- typeof _[C] < "u" && g.push(_[C]);
468
+ let r = e && e.forEach ? e : Array.from(arguments).slice(), i = !1;
469
+ if (typeof r[0] == "object") {
470
+ i = r.length;
471
+ const M = [];
472
+ r.forEach(function(k) {
473
+ ["x", "y", "z"].forEach(function(L) {
474
+ typeof k[L] < "u" && M.push(k[L]);
475
475
  });
476
- }), n = g;
476
+ }), r = M;
477
477
  }
478
- let s = !1;
479
- const c = n.length;
478
+ let o = !1;
479
+ const s = r.length;
480
480
  if (i) {
481
481
  if (i > 4) {
482
482
  if (arguments.length !== 1)
483
483
  throw new Error(
484
484
  "Only new Bezier(point[]) is accepted for 4th and higher order curves"
485
485
  );
486
- s = !0;
486
+ o = !0;
487
487
  }
488
- } else if (c !== 6 && c !== 8 && c !== 9 && c !== 12 && arguments.length !== 1)
488
+ } else if (s !== 6 && s !== 8 && s !== 9 && s !== 12 && arguments.length !== 1)
489
489
  throw new Error(
490
490
  "Only new Bezier(point[]) is accepted for 4th and higher order curves"
491
491
  );
492
- const r = this._3d = !s && (c === 9 || c === 12) || e && e[0] && typeof e[0].z < "u", l = this.points = [];
493
- for (let g = 0, _ = r ? 3 : 2; g < c; g += _) {
494
- var u = {
495
- x: n[g],
496
- y: n[g + 1]
492
+ const a = this._3d = !o && (s === 9 || s === 12) || e && e[0] && typeof e[0].z < "u", l = this.points = [];
493
+ for (let M = 0, k = a ? 3 : 2; M < s; M += k) {
494
+ var c = {
495
+ x: r[M],
496
+ y: r[M + 1]
497
497
  };
498
- r && (u.z = n[g + 2]), l.push(u);
498
+ a && (c.z = r[M + 2]), l.push(c);
499
499
  }
500
- const f = this.order = l.length - 1, h = this.dims = ["x", "y"];
501
- r && h.push("z"), this.dimlen = h.length;
502
- const a = y.align(l, { p1: l[0], p2: l[f] }), p = y.dist(l[0], l[f]);
503
- this._linear = a.reduce((g, _) => g + G(_.y), 0) < p / 50, this._lut = [], this._t1 = 0, this._t2 = 1, this.update();
504
- }
505
- static quadraticFromPoints(e, n, i, s) {
506
- if (typeof s > "u" && (s = 0.5), s === 0)
507
- return new E(n, n, i);
508
- if (s === 1)
509
- return new E(e, n, n);
510
- const c = E.getABC(2, e, n, i, s);
511
- return new E(e, c.A, i);
512
- }
513
- static cubicFromPoints(e, n, i, s, c) {
514
- typeof s > "u" && (s = 0.5);
515
- const r = E.getABC(3, e, n, i, s);
516
- typeof c > "u" && (c = y.dist(n, r.C));
517
- const l = c * (1 - s) / s, u = y.dist(e, i), f = (i.x - e.x) / u, h = (i.y - e.y) / u, a = c * f, p = c * h, g = l * f, _ = l * h, C = { x: n.x - a, y: n.y - p }, A = { x: n.x + g, y: n.y + _ }, S = r.A, j = { x: S.x + (C.x - S.x) / (1 - s), y: S.y + (C.y - S.y) / (1 - s) }, O = { x: S.x + (A.x - S.x) / s, y: S.y + (A.y - S.y) / s }, T = { x: e.x + (j.x - e.x) / s, y: e.y + (j.y - e.y) / s }, z = {
518
- x: i.x + (O.x - i.x) / (1 - s),
519
- y: i.y + (O.y - i.y) / (1 - s)
500
+ const f = this.order = l.length - 1, g = this.dims = ["x", "y"];
501
+ a && g.push("z"), this.dimlen = g.length;
502
+ const y = _.align(l, { p1: l[0], p2: l[f] }), d = _.dist(l[0], l[f]);
503
+ this._linear = y.reduce((M, k) => M + xt(k.y), 0) < d / 50, this._lut = [], this._t1 = 0, this._t2 = 1, this.update();
504
+ }
505
+ static quadraticFromPoints(e, r, i, o) {
506
+ if (typeof o > "u" && (o = 0.5), o === 0)
507
+ return new U(r, r, i);
508
+ if (o === 1)
509
+ return new U(e, r, r);
510
+ const s = U.getABC(2, e, r, i, o);
511
+ return new U(e, s.A, i);
512
+ }
513
+ static cubicFromPoints(e, r, i, o, s) {
514
+ typeof o > "u" && (o = 0.5);
515
+ const a = U.getABC(3, e, r, i, o);
516
+ typeof s > "u" && (s = _.dist(r, a.C));
517
+ const l = s * (1 - o) / o, c = _.dist(e, i), f = (i.x - e.x) / c, g = (i.y - e.y) / c, y = s * f, d = s * g, M = l * f, k = l * g, L = { x: r.x - y, y: r.y - d }, D = { x: r.x + M, y: r.y + k }, O = a.A, u = { x: O.x + (L.x - O.x) / (1 - o), y: O.y + (L.y - O.y) / (1 - o) }, h = { x: O.x + (D.x - O.x) / o, y: O.y + (D.y - O.y) / o }, m = { x: e.x + (u.x - e.x) / o, y: e.y + (u.y - e.y) / o }, p = {
518
+ x: i.x + (h.x - i.x) / (1 - o),
519
+ y: i.y + (h.y - i.y) / (1 - o)
520
520
  };
521
- return new E(e, T, z, i);
521
+ return new U(e, m, p, i);
522
522
  }
523
523
  static getUtils() {
524
- return y;
524
+ return _;
525
525
  }
526
526
  getUtils() {
527
- return E.getUtils();
527
+ return U.getUtils();
528
528
  }
529
529
  static get PolyBezier() {
530
- return V;
530
+ return wt;
531
531
  }
532
532
  valueOf() {
533
533
  return this.toString();
534
534
  }
535
535
  toString() {
536
- return y.pointsToString(this.points);
536
+ return _.pointsToString(this.points);
537
537
  }
538
538
  toSVG() {
539
539
  if (this._3d)
540
540
  return !1;
541
- const e = this.points, n = e[0].x, i = e[0].y, s = ["M", n, i, this.order === 2 ? "Q" : "C"];
542
- for (let c = 1, r = e.length; c < r; c++)
543
- s.push(e[c].x), s.push(e[c].y);
544
- return s.join(" ");
541
+ const e = this.points, r = e[0].x, i = e[0].y, o = ["M", r, i, this.order === 2 ? "Q" : "C"];
542
+ for (let s = 1, a = e.length; s < a; s++)
543
+ o.push(e[s].x), o.push(e[s].y);
544
+ return o.join(" ");
545
545
  }
546
546
  setRatios(e) {
547
547
  if (e.length !== this.points.length)
@@ -553,57 +553,57 @@ class E {
553
553
  e !== this._print && (this._print = e, this.update());
554
554
  }
555
555
  coordDigest() {
556
- return this.points.map(function(e, n) {
557
- return "" + n + e.x + e.y + (e.z ? e.z : 0);
556
+ return this.points.map(function(e, r) {
557
+ return "" + r + e.x + e.y + (e.z ? e.z : 0);
558
558
  }).join("");
559
559
  }
560
560
  update() {
561
- this._lut = [], this.dpoints = y.derive(this.points, this._3d), this.computedirection();
561
+ this._lut = [], this.dpoints = _.derive(this.points, this._3d), this.computedirection();
562
562
  }
563
563
  computedirection() {
564
- const e = this.points, n = y.angle(e[0], e[this.order], e[1]);
565
- this.clockwise = n > 0;
564
+ const e = this.points, r = _.angle(e[0], e[this.order], e[1]);
565
+ this.clockwise = r > 0;
566
566
  }
567
567
  length() {
568
- return y.length(this.derivative.bind(this));
568
+ return _.length(this.derivative.bind(this));
569
569
  }
570
- static getABC(e = 2, n, i, s, c = 0.5) {
571
- const r = y.projectionratio(c, e), l = 1 - r, u = {
572
- x: r * n.x + l * s.x,
573
- y: r * n.y + l * s.y
574
- }, f = y.abcratio(c, e);
570
+ static getABC(e = 2, r, i, o, s = 0.5) {
571
+ const a = _.projectionratio(s, e), l = 1 - a, c = {
572
+ x: a * r.x + l * o.x,
573
+ y: a * r.y + l * o.y
574
+ }, f = _.abcratio(s, e);
575
575
  return { A: {
576
- x: i.x + (i.x - u.x) / f,
577
- y: i.y + (i.y - u.y) / f
578
- }, B: i, C: u, S: n, E: s };
576
+ x: i.x + (i.x - c.x) / f,
577
+ y: i.y + (i.y - c.y) / f
578
+ }, B: i, C: c, S: r, E: o };
579
579
  }
580
- getABC(e, n) {
581
- n = n || this.get(e);
582
- let i = this.points[0], s = this.points[this.order];
583
- return E.getABC(this.order, i, n, s, e);
580
+ getABC(e, r) {
581
+ r = r || this.get(e);
582
+ let i = this.points[0], o = this.points[this.order];
583
+ return U.getABC(this.order, i, r, o, e);
584
584
  }
585
585
  getLUT(e) {
586
586
  if (this.verify(), e = e || 100, this._lut.length === e + 1)
587
587
  return this._lut;
588
588
  this._lut = [], e++, this._lut = [];
589
- for (let n = 0, i, s; n < e; n++)
590
- s = n / (e - 1), i = this.compute(s), i.t = s, this._lut.push(i);
589
+ for (let r = 0, i, o; r < e; r++)
590
+ o = r / (e - 1), i = this.compute(o), i.t = o, this._lut.push(i);
591
591
  return this._lut;
592
592
  }
593
- on(e, n) {
594
- n = n || 5;
595
- const i = this.getLUT(), s = [];
596
- for (let c = 0, r, l = 0; c < i.length; c++)
597
- r = i[c], y.dist(r, e) < n && (s.push(r), l += c / i.length);
598
- return s.length ? t /= s.length : !1;
593
+ on(e, r) {
594
+ r = r || 5;
595
+ const i = this.getLUT(), o = [];
596
+ for (let s = 0, a, l = 0; s < i.length; s++)
597
+ a = i[s], _.dist(a, e) < r && (o.push(a), l += s / i.length);
598
+ return o.length ? t /= o.length : !1;
599
599
  }
600
600
  project(e) {
601
- const n = this.getLUT(), i = n.length - 1, s = y.closest(n, e), c = s.mpos, r = (c - 1) / i, l = (c + 1) / i, u = 0.1 / i;
602
- let f = s.mdist, h = r, a = h, p;
601
+ const r = this.getLUT(), i = r.length - 1, o = _.closest(r, e), s = o.mpos, a = (s - 1) / i, l = (s + 1) / i, c = 0.1 / i;
602
+ let f = o.mdist, g = a, y = g, d;
603
603
  f += 1;
604
- for (let g; h < l + u; h += u)
605
- p = this.compute(h), g = y.dist(e, p), g < f && (f = g, a = h);
606
- return a = a < 0 ? 0 : a > 1 ? 1 : a, p = this.compute(a), p.t = a, p.d = f, p;
604
+ for (let M; g < l + c; g += c)
605
+ d = this.compute(g), M = _.dist(e, d), M < f && (f = M, y = g);
606
+ return y = y < 0 ? 0 : y > 1 ? 1 : y, d = this.compute(y), d.t = y, d.d = f, d;
607
607
  }
608
608
  get(e) {
609
609
  return this.compute(e);
@@ -612,136 +612,136 @@ class E {
612
612
  return this.points[e];
613
613
  }
614
614
  compute(e) {
615
- return this.ratios ? y.computeWithRatios(e, this.points, this.ratios, this._3d) : y.compute(e, this.points, this._3d, this.ratios);
615
+ return this.ratios ? _.computeWithRatios(e, this.points, this.ratios, this._3d) : _.compute(e, this.points, this._3d, this.ratios);
616
616
  }
617
617
  raise() {
618
- const e = this.points, n = [e[0]], i = e.length;
619
- for (let s = 1, c, r; s < i; s++)
620
- c = e[s], r = e[s - 1], n[s] = {
621
- x: (i - s) / i * c.x + s / i * r.x,
622
- y: (i - s) / i * c.y + s / i * r.y
618
+ const e = this.points, r = [e[0]], i = e.length;
619
+ for (let o = 1, s, a; o < i; o++)
620
+ s = e[o], a = e[o - 1], r[o] = {
621
+ x: (i - o) / i * s.x + o / i * a.x,
622
+ y: (i - o) / i * s.y + o / i * a.y
623
623
  };
624
- return n[i] = e[i - 1], new E(n);
624
+ return r[i] = e[i - 1], new U(r);
625
625
  }
626
626
  derivative(e) {
627
- return y.compute(e, this.dpoints[0], this._3d);
627
+ return _.compute(e, this.dpoints[0], this._3d);
628
628
  }
629
629
  dderivative(e) {
630
- return y.compute(e, this.dpoints[1], this._3d);
630
+ return _.compute(e, this.dpoints[1], this._3d);
631
631
  }
632
632
  align() {
633
633
  let e = this.points;
634
- return new E(y.align(e, { p1: e[0], p2: e[e.length - 1] }));
634
+ return new U(_.align(e, { p1: e[0], p2: e[e.length - 1] }));
635
635
  }
636
636
  curvature(e) {
637
- return y.curvature(e, this.dpoints[0], this.dpoints[1], this._3d);
637
+ return _.curvature(e, this.dpoints[0], this.dpoints[1], this._3d);
638
638
  }
639
639
  inflections() {
640
- return y.inflections(this.points);
640
+ return _.inflections(this.points);
641
641
  }
642
642
  normal(e) {
643
643
  return this._3d ? this.__normal3(e) : this.__normal2(e);
644
644
  }
645
645
  __normal2(e) {
646
- const n = this.derivative(e), i = Z(n.x * n.x + n.y * n.y);
647
- return { t: e, x: -n.y / i, y: n.x / i };
646
+ const r = this.derivative(e), i = vt(r.x * r.x + r.y * r.y);
647
+ return { t: e, x: -r.y / i, y: r.x / i };
648
648
  }
649
649
  __normal3(e) {
650
- const n = this.derivative(e), i = this.derivative(e + 0.01), s = Z(n.x * n.x + n.y * n.y + n.z * n.z), c = Z(i.x * i.x + i.y * i.y + i.z * i.z);
651
- n.x /= s, n.y /= s, n.z /= s, i.x /= c, i.y /= c, i.z /= c;
652
- const r = {
653
- x: i.y * n.z - i.z * n.y,
654
- y: i.z * n.x - i.x * n.z,
655
- z: i.x * n.y - i.y * n.x
656
- }, l = Z(r.x * r.x + r.y * r.y + r.z * r.z);
657
- r.x /= l, r.y /= l, r.z /= l;
658
- const u = [
659
- r.x * r.x,
660
- r.x * r.y - r.z,
661
- r.x * r.z + r.y,
662
- r.x * r.y + r.z,
663
- r.y * r.y,
664
- r.y * r.z - r.x,
665
- r.x * r.z - r.y,
666
- r.y * r.z + r.x,
667
- r.z * r.z
650
+ const r = this.derivative(e), i = this.derivative(e + 0.01), o = vt(r.x * r.x + r.y * r.y + r.z * r.z), s = vt(i.x * i.x + i.y * i.y + i.z * i.z);
651
+ r.x /= o, r.y /= o, r.z /= o, i.x /= s, i.y /= s, i.z /= s;
652
+ const a = {
653
+ x: i.y * r.z - i.z * r.y,
654
+ y: i.z * r.x - i.x * r.z,
655
+ z: i.x * r.y - i.y * r.x
656
+ }, l = vt(a.x * a.x + a.y * a.y + a.z * a.z);
657
+ a.x /= l, a.y /= l, a.z /= l;
658
+ const c = [
659
+ a.x * a.x,
660
+ a.x * a.y - a.z,
661
+ a.x * a.z + a.y,
662
+ a.x * a.y + a.z,
663
+ a.y * a.y,
664
+ a.y * a.z - a.x,
665
+ a.x * a.z - a.y,
666
+ a.y * a.z + a.x,
667
+ a.z * a.z
668
668
  ];
669
669
  return {
670
670
  t: e,
671
- x: u[0] * n.x + u[1] * n.y + u[2] * n.z,
672
- y: u[3] * n.x + u[4] * n.y + u[5] * n.z,
673
- z: u[6] * n.x + u[7] * n.y + u[8] * n.z
671
+ x: c[0] * r.x + c[1] * r.y + c[2] * r.z,
672
+ y: c[3] * r.x + c[4] * r.y + c[5] * r.z,
673
+ z: c[6] * r.x + c[7] * r.y + c[8] * r.z
674
674
  };
675
675
  }
676
676
  hull(e) {
677
- let n = this.points, i = [], s = [], c = 0;
678
- for (s[c++] = n[0], s[c++] = n[1], s[c++] = n[2], this.order === 3 && (s[c++] = n[3]); n.length > 1; ) {
677
+ let r = this.points, i = [], o = [], s = 0;
678
+ for (o[s++] = r[0], o[s++] = r[1], o[s++] = r[2], this.order === 3 && (o[s++] = r[3]); r.length > 1; ) {
679
679
  i = [];
680
- for (let r = 0, l, u = n.length - 1; r < u; r++)
681
- l = y.lerp(e, n[r], n[r + 1]), s[c++] = l, i.push(l);
682
- n = i;
680
+ for (let a = 0, l, c = r.length - 1; a < c; a++)
681
+ l = _.lerp(e, r[a], r[a + 1]), o[s++] = l, i.push(l);
682
+ r = i;
683
683
  }
684
- return s;
684
+ return o;
685
685
  }
686
- split(e, n) {
687
- if (e === 0 && n)
688
- return this.split(n).left;
689
- if (n === 1)
686
+ split(e, r) {
687
+ if (e === 0 && r)
688
+ return this.split(r).left;
689
+ if (r === 1)
690
690
  return this.split(e).right;
691
- const i = this.hull(e), s = {
692
- left: this.order === 2 ? new E([i[0], i[3], i[5]]) : new E([i[0], i[4], i[7], i[9]]),
693
- right: this.order === 2 ? new E([i[5], i[4], i[2]]) : new E([i[9], i[8], i[6], i[3]]),
691
+ const i = this.hull(e), o = {
692
+ left: this.order === 2 ? new U([i[0], i[3], i[5]]) : new U([i[0], i[4], i[7], i[9]]),
693
+ right: this.order === 2 ? new U([i[5], i[4], i[2]]) : new U([i[9], i[8], i[6], i[3]]),
694
694
  span: i
695
695
  };
696
- return s.left._t1 = y.map(0, 0, 1, this._t1, this._t2), s.left._t2 = y.map(e, 0, 1, this._t1, this._t2), s.right._t1 = y.map(e, 0, 1, this._t1, this._t2), s.right._t2 = y.map(1, 0, 1, this._t1, this._t2), n ? (n = y.map(n, e, 1, 0, 1), s.right.split(n).left) : s;
696
+ return o.left._t1 = _.map(0, 0, 1, this._t1, this._t2), o.left._t2 = _.map(e, 0, 1, this._t1, this._t2), o.right._t1 = _.map(e, 0, 1, this._t1, this._t2), o.right._t2 = _.map(1, 0, 1, this._t1, this._t2), r ? (r = _.map(r, e, 1, 0, 1), o.right.split(r).left) : o;
697
697
  }
698
698
  extrema() {
699
699
  const e = {};
700
- let n = [];
700
+ let r = [];
701
701
  return this.dims.forEach(
702
702
  (function(i) {
703
- let s = function(r) {
704
- return r[i];
705
- }, c = this.dpoints[0].map(s);
706
- e[i] = y.droots(c), this.order === 3 && (c = this.dpoints[1].map(s), e[i] = e[i].concat(y.droots(c))), e[i] = e[i].filter(function(r) {
707
- return r >= 0 && r <= 1;
708
- }), n = n.concat(e[i].sort(y.numberSort));
703
+ let o = function(a) {
704
+ return a[i];
705
+ }, s = this.dpoints[0].map(o);
706
+ e[i] = _.droots(s), this.order === 3 && (s = this.dpoints[1].map(o), e[i] = e[i].concat(_.droots(s))), e[i] = e[i].filter(function(a) {
707
+ return a >= 0 && a <= 1;
708
+ }), r = r.concat(e[i].sort(_.numberSort));
709
709
  }).bind(this)
710
- ), e.values = n.sort(y.numberSort).filter(function(i, s) {
711
- return n.indexOf(i) === s;
710
+ ), e.values = r.sort(_.numberSort).filter(function(i, o) {
711
+ return r.indexOf(i) === o;
712
712
  }), e;
713
713
  }
714
714
  bbox() {
715
- const e = this.extrema(), n = {};
715
+ const e = this.extrema(), r = {};
716
716
  return this.dims.forEach(
717
717
  (function(i) {
718
- n[i] = y.getminmax(this, i, e[i]);
718
+ r[i] = _.getminmax(this, i, e[i]);
719
719
  }).bind(this)
720
- ), n;
720
+ ), r;
721
721
  }
722
722
  overlaps(e) {
723
- const n = this.bbox(), i = e.bbox();
724
- return y.bboxoverlap(n, i);
723
+ const r = this.bbox(), i = e.bbox();
724
+ return _.bboxoverlap(r, i);
725
725
  }
726
- offset(e, n) {
727
- if (typeof n < "u") {
728
- const i = this.get(e), s = this.normal(e), c = {
726
+ offset(e, r) {
727
+ if (typeof r < "u") {
728
+ const i = this.get(e), o = this.normal(e), s = {
729
729
  c: i,
730
- n: s,
731
- x: i.x + s.x * n,
732
- y: i.y + s.y * n
730
+ n: o,
731
+ x: i.x + o.x * r,
732
+ y: i.y + o.y * r
733
733
  };
734
- return this._3d && (c.z = i.z + s.z * n), c;
734
+ return this._3d && (s.z = i.z + o.z * r), s;
735
735
  }
736
736
  if (this._linear) {
737
- const i = this.normal(0), s = this.points.map(function(c) {
738
- const r = {
739
- x: c.x + e * i.x,
740
- y: c.y + e * i.y
737
+ const i = this.normal(0), o = this.points.map(function(s) {
738
+ const a = {
739
+ x: s.x + e * i.x,
740
+ y: s.y + e * i.y
741
741
  };
742
- return c.z && i.z && (r.z = c.z + e * i.z), r;
742
+ return s.z && i.z && (a.z = s.z + e * i.z), a;
743
743
  });
744
- return [new E(s)];
744
+ return [new U(o)];
745
745
  }
746
746
  return this.reduce().map(function(i) {
747
747
  return i._linear ? i.offset(e)[0] : i.scale(e);
@@ -749,328 +749,1438 @@ class E {
749
749
  }
750
750
  simple() {
751
751
  if (this.order === 3) {
752
- const s = y.angle(this.points[0], this.points[3], this.points[1]), c = y.angle(this.points[0], this.points[3], this.points[2]);
753
- if (s > 0 && c < 0 || s < 0 && c > 0)
752
+ const o = _.angle(this.points[0], this.points[3], this.points[1]), s = _.angle(this.points[0], this.points[3], this.points[2]);
753
+ if (o > 0 && s < 0 || o < 0 && s > 0)
754
754
  return !1;
755
755
  }
756
- const e = this.normal(0), n = this.normal(1);
757
- let i = e.x * n.x + e.y * n.y;
758
- return this._3d && (i += e.z * n.z), G(ot(i)) < ct / 3;
756
+ const e = this.normal(0), r = this.normal(1);
757
+ let i = e.x * r.x + e.y * r.y;
758
+ return this._3d && (i += e.z * r.z), xt(xe(i)) < ve / 3;
759
759
  }
760
760
  reduce() {
761
- let e, n = 0, i = 0, s = 0.01, c, r = [], l = [], u = this.extrema().values;
762
- for (u.indexOf(0) === -1 && (u = [0].concat(u)), u.indexOf(1) === -1 && u.push(1), n = u[0], e = 1; e < u.length; e++)
763
- i = u[e], c = this.split(n, i), c._t1 = n, c._t2 = i, r.push(c), n = i;
764
- return r.forEach(function(f) {
765
- for (n = 0, i = 0; i <= 1; )
766
- for (i = n + s; i <= 1 + s; i += s)
767
- if (c = f.split(n, i), !c.simple()) {
768
- if (i -= s, G(n - i) < s)
761
+ let e, r = 0, i = 0, o = 0.01, s, a = [], l = [], c = this.extrema().values;
762
+ for (c.indexOf(0) === -1 && (c = [0].concat(c)), c.indexOf(1) === -1 && c.push(1), r = c[0], e = 1; e < c.length; e++)
763
+ i = c[e], s = this.split(r, i), s._t1 = r, s._t2 = i, a.push(s), r = i;
764
+ return a.forEach(function(f) {
765
+ for (r = 0, i = 0; i <= 1; )
766
+ for (i = r + o; i <= 1 + o; i += o)
767
+ if (s = f.split(r, i), !s.simple()) {
768
+ if (i -= o, xt(r - i) < o)
769
769
  return [];
770
- c = f.split(n, i), c._t1 = y.map(n, 0, 1, f._t1, f._t2), c._t2 = y.map(i, 0, 1, f._t1, f._t2), l.push(c), n = i;
770
+ s = f.split(r, i), s._t1 = _.map(r, 0, 1, f._t1, f._t2), s._t2 = _.map(i, 0, 1, f._t1, f._t2), l.push(s), r = i;
771
771
  break;
772
772
  }
773
- n < 1 && (c = f.split(n, 1), c._t1 = y.map(n, 0, 1, f._t1, f._t2), c._t2 = f._t2, l.push(c));
773
+ r < 1 && (s = f.split(r, 1), s._t1 = _.map(r, 0, 1, f._t1, f._t2), s._t2 = f._t2, l.push(s));
774
774
  }), l;
775
775
  }
776
- translate(e, n, i) {
777
- i = typeof i == "number" ? i : n;
778
- const s = this.order;
779
- let c = this.points.map((r, l) => (1 - l / s) * n + l / s * i);
780
- return new E(
781
- this.points.map((r, l) => ({
782
- x: r.x + e.x * c[l],
783
- y: r.y + e.y * c[l]
776
+ translate(e, r, i) {
777
+ i = typeof i == "number" ? i : r;
778
+ const o = this.order;
779
+ let s = this.points.map((a, l) => (1 - l / o) * r + l / o * i);
780
+ return new U(
781
+ this.points.map((a, l) => ({
782
+ x: a.x + e.x * s[l],
783
+ y: a.y + e.y * s[l]
784
784
  }))
785
785
  );
786
786
  }
787
787
  scale(e) {
788
- const n = this.order;
788
+ const r = this.order;
789
789
  let i = !1;
790
- if (typeof e == "function" && (i = e), i && n === 2)
790
+ if (typeof e == "function" && (i = e), i && r === 2)
791
791
  return this.raise().scale(i);
792
- const s = this.clockwise, c = this.points;
792
+ const o = this.clockwise, s = this.points;
793
793
  if (this._linear)
794
794
  return this.translate(
795
795
  this.normal(0),
796
796
  i ? i(0) : e,
797
797
  i ? i(1) : e
798
798
  );
799
- const r = i ? i(0) : e, l = i ? i(1) : e, u = [this.offset(0, 10), this.offset(1, 10)], f = [], h = y.lli4(u[0], u[0].c, u[1], u[1].c);
800
- if (!h)
799
+ const a = i ? i(0) : e, l = i ? i(1) : e, c = [this.offset(0, 10), this.offset(1, 10)], f = [], g = _.lli4(c[0], c[0].c, c[1], c[1].c);
800
+ if (!g)
801
801
  throw new Error("cannot scale this curve. Try reducing it first.");
802
- return [0, 1].forEach(function(a) {
803
- const p = f[a * n] = y.copy(c[a * n]);
804
- p.x += (a ? l : r) * u[a].n.x, p.y += (a ? l : r) * u[a].n.y;
805
- }), i ? ([0, 1].forEach(function(a) {
806
- if (!(n === 2 && a)) {
807
- var p = c[a + 1], g = {
808
- x: p.x - h.x,
809
- y: p.y - h.y
810
- }, _ = i ? i((a + 1) / n) : e;
811
- i && !s && (_ = -_);
812
- var C = Z(g.x * g.x + g.y * g.y);
813
- g.x /= C, g.y /= C, f[a + 1] = {
814
- x: p.x + _ * g.x,
815
- y: p.y + _ * g.y
802
+ return [0, 1].forEach(function(y) {
803
+ const d = f[y * r] = _.copy(s[y * r]);
804
+ d.x += (y ? l : a) * c[y].n.x, d.y += (y ? l : a) * c[y].n.y;
805
+ }), i ? ([0, 1].forEach(function(y) {
806
+ if (!(r === 2 && y)) {
807
+ var d = s[y + 1], M = {
808
+ x: d.x - g.x,
809
+ y: d.y - g.y
810
+ }, k = i ? i((y + 1) / r) : e;
811
+ i && !o && (k = -k);
812
+ var L = vt(M.x * M.x + M.y * M.y);
813
+ M.x /= L, M.y /= L, f[y + 1] = {
814
+ x: d.x + k * M.x,
815
+ y: d.y + k * M.y
816
816
  };
817
817
  }
818
- }), new E(f)) : ([0, 1].forEach((a) => {
819
- if (n === 2 && a)
818
+ }), new U(f)) : ([0, 1].forEach((y) => {
819
+ if (r === 2 && y)
820
820
  return;
821
- const p = f[a * n], g = this.derivative(a), _ = { x: p.x + g.x, y: p.y + g.y };
822
- f[a + 1] = y.lli4(p, _, h, c[a + 1]);
823
- }), new E(f));
824
- }
825
- outline(e, n, i, s) {
826
- if (n = n === void 0 ? e : n, this._linear) {
827
- const z = this.normal(0), d = this.points[0], x = this.points[this.points.length - 1];
828
- let m, v, w;
829
- i === void 0 && (i = e, s = n), m = { x: d.x + z.x * e, y: d.y + z.y * e }, w = { x: x.x + z.x * i, y: x.y + z.y * i }, v = { x: (m.x + w.x) / 2, y: (m.y + w.y) / 2 };
830
- const b = [m, v, w];
831
- m = { x: d.x - z.x * n, y: d.y - z.y * n }, w = { x: x.x - z.x * s, y: x.y - z.y * s }, v = { x: (m.x + w.x) / 2, y: (m.y + w.y) / 2 };
832
- const k = [w, v, m], q = y.makeline(k[2], b[0]), M = y.makeline(b[2], k[0]), I = [q, new E(b), M, new E(k)];
833
- return new V(I);
821
+ const d = f[y * r], M = this.derivative(y), k = { x: d.x + M.x, y: d.y + M.y };
822
+ f[y + 1] = _.lli4(d, k, g, s[y + 1]);
823
+ }), new U(f));
824
+ }
825
+ outline(e, r, i, o) {
826
+ if (r = r === void 0 ? e : r, this._linear) {
827
+ const p = this.normal(0), w = this.points[0], x = this.points[this.points.length - 1];
828
+ let v, S, X;
829
+ i === void 0 && (i = e, o = r), v = { x: w.x + p.x * e, y: w.y + p.y * e }, X = { x: x.x + p.x * i, y: x.y + p.y * i }, S = { x: (v.x + X.x) / 2, y: (v.y + X.y) / 2 };
830
+ const Y = [v, S, X];
831
+ v = { x: w.x - p.x * r, y: w.y - p.y * r }, X = { x: x.x - p.x * o, y: x.y - p.y * o }, S = { x: (v.x + X.x) / 2, y: (v.y + X.y) / 2 };
832
+ const b = [X, S, v], N = _.makeline(b[2], Y[0]), R = _.makeline(Y[2], b[0]), H = [N, new U(Y), R, new U(b)];
833
+ return new wt(H);
834
834
  }
835
- const c = this.reduce(), r = c.length, l = [];
836
- let u = [], f, h = 0, a = this.length();
837
- const p = typeof i < "u" && typeof s < "u";
838
- function g(z, d, x, m, v) {
839
- return function(w) {
840
- const b = m / x, k = (m + v) / x, q = d - z;
841
- return y.map(w, 0, 1, z + b * q, z + k * q);
835
+ const s = this.reduce(), a = s.length, l = [];
836
+ let c = [], f, g = 0, y = this.length();
837
+ const d = typeof i < "u" && typeof o < "u";
838
+ function M(p, w, x, v, S) {
839
+ return function(X) {
840
+ const Y = v / x, b = (v + S) / x, N = w - p;
841
+ return _.map(X, 0, 1, p + Y * N, p + b * N);
842
842
  };
843
843
  }
844
- c.forEach(function(z) {
845
- const d = z.length();
846
- p ? (l.push(
847
- z.scale(g(e, i, a, h, d))
848
- ), u.push(
849
- z.scale(g(-n, -s, a, h, d))
850
- )) : (l.push(z.scale(e)), u.push(z.scale(-n))), h += d;
851
- }), u = u.map(function(z) {
852
- return f = z.points, f[3] ? z.points = [f[3], f[2], f[1], f[0]] : z.points = [f[2], f[1], f[0]], z;
844
+ s.forEach(function(p) {
845
+ const w = p.length();
846
+ d ? (l.push(
847
+ p.scale(M(e, i, y, g, w))
848
+ ), c.push(
849
+ p.scale(M(-r, -o, y, g, w))
850
+ )) : (l.push(p.scale(e)), c.push(p.scale(-r))), g += w;
851
+ }), c = c.map(function(p) {
852
+ return f = p.points, f[3] ? p.points = [f[3], f[2], f[1], f[0]] : p.points = [f[2], f[1], f[0]], p;
853
853
  }).reverse();
854
- const _ = l[0].points[0], C = l[r - 1].points[l[r - 1].points.length - 1], A = u[r - 1].points[u[r - 1].points.length - 1], S = u[0].points[0], j = y.makeline(A, _), O = y.makeline(C, S), T = [j].concat(l).concat([O]).concat(u);
855
- return new V(T);
856
- }
857
- outlineshapes(e, n, i) {
858
- n = n || e;
859
- const s = this.outline(e, n).curves, c = [];
860
- for (let r = 1, l = s.length; r < l / 2; r++) {
861
- const u = y.makeshape(
862
- s[r],
863
- s[l - r],
854
+ const k = l[0].points[0], L = l[a - 1].points[l[a - 1].points.length - 1], D = c[a - 1].points[c[a - 1].points.length - 1], O = c[0].points[0], u = _.makeline(D, k), h = _.makeline(L, O), m = [u].concat(l).concat([h]).concat(c);
855
+ return new wt(m);
856
+ }
857
+ outlineshapes(e, r, i) {
858
+ r = r || e;
859
+ const o = this.outline(e, r).curves, s = [];
860
+ for (let a = 1, l = o.length; a < l / 2; a++) {
861
+ const c = _.makeshape(
862
+ o[a],
863
+ o[l - a],
864
864
  i
865
865
  );
866
- u.startcap.virtual = r > 1, u.endcap.virtual = r < l / 2 - 1, c.push(u);
866
+ c.startcap.virtual = a > 1, c.endcap.virtual = a < l / 2 - 1, s.push(c);
867
867
  }
868
- return c;
868
+ return s;
869
869
  }
870
- intersects(e, n) {
871
- return e ? e.p1 && e.p2 ? this.lineIntersects(e) : (e instanceof E && (e = e.reduce()), this.curveintersects(
870
+ intersects(e, r) {
871
+ return e ? e.p1 && e.p2 ? this.lineIntersects(e) : (e instanceof U && (e = e.reduce()), this.curveintersects(
872
872
  this.reduce(),
873
873
  e,
874
- n
875
- )) : this.selfintersects(n);
874
+ r
875
+ )) : this.selfintersects(r);
876
876
  }
877
877
  lineIntersects(e) {
878
- const n = K(e.p1.x, e.p2.x), i = K(e.p1.y, e.p2.y), s = B(e.p1.x, e.p2.x), c = B(e.p1.y, e.p2.y);
879
- return y.roots(this.points, e).filter((r) => {
880
- var l = this.get(r);
881
- return y.between(l.x, n, s) && y.between(l.y, i, c);
878
+ const r = $t(e.p1.x, e.p2.x), i = $t(e.p1.y, e.p2.y), o = Gt(e.p1.x, e.p2.x), s = Gt(e.p1.y, e.p2.y);
879
+ return _.roots(this.points, e).filter((a) => {
880
+ var l = this.get(a);
881
+ return _.between(l.x, r, o) && _.between(l.y, i, s);
882
882
  });
883
883
  }
884
884
  selfintersects(e) {
885
- const n = this.reduce(), i = n.length - 2, s = [];
886
- for (let c = 0, r, l, u; c < i; c++)
887
- l = n.slice(c, c + 1), u = n.slice(c + 2), r = this.curveintersects(l, u, e), s.push(...r);
888
- return s;
885
+ const r = this.reduce(), i = r.length - 2, o = [];
886
+ for (let s = 0, a, l, c; s < i; s++)
887
+ l = r.slice(s, s + 1), c = r.slice(s + 2), a = this.curveintersects(l, c, e), o.push(...a);
888
+ return o;
889
889
  }
890
- curveintersects(e, n, i) {
891
- const s = [];
892
- e.forEach(function(r) {
893
- n.forEach(function(l) {
894
- r.overlaps(l) && s.push({ left: r, right: l });
890
+ curveintersects(e, r, i) {
891
+ const o = [];
892
+ e.forEach(function(a) {
893
+ r.forEach(function(l) {
894
+ a.overlaps(l) && o.push({ left: a, right: l });
895
895
  });
896
896
  });
897
- let c = [];
898
- return s.forEach(function(r) {
899
- const l = y.pairiteration(
900
- r.left,
901
- r.right,
897
+ let s = [];
898
+ return o.forEach(function(a) {
899
+ const l = _.pairiteration(
900
+ a.left,
901
+ a.right,
902
902
  i
903
903
  );
904
- l.length > 0 && (c = c.concat(l));
905
- }), c;
904
+ l.length > 0 && (s = s.concat(l));
905
+ }), s;
906
906
  }
907
907
  arcs(e) {
908
908
  return e = e || 0.5, this._iterate(e, []);
909
909
  }
910
- _error(e, n, i, s) {
911
- const c = (s - i) / 4, r = this.get(i + c), l = this.get(s - c), u = y.dist(e, n), f = y.dist(e, r), h = y.dist(e, l);
912
- return G(f - u) + G(h - u);
910
+ _error(e, r, i, o) {
911
+ const s = (o - i) / 4, a = this.get(i + s), l = this.get(o - s), c = _.dist(e, r), f = _.dist(e, a), g = _.dist(e, l);
912
+ return xt(f - c) + xt(g - c);
913
913
  }
914
- _iterate(e, n) {
915
- let i = 0, s = 1, c;
914
+ _iterate(e, r) {
915
+ let i = 0, o = 1, s;
916
916
  do {
917
- c = 0, s = 1;
918
- let r = this.get(i), l, u, f, h, a = !1, p = !1, g, _ = s, C = 1;
917
+ s = 0, o = 1;
918
+ let a = this.get(i), l, c, f, g, y = !1, d = !1, M, k = o, L = 1;
919
919
  do
920
- if (p = a, h = f, _ = (i + s) / 2, l = this.get(_), u = this.get(s), f = y.getccenter(r, l, u), f.interval = {
920
+ if (d = y, g = f, k = (i + o) / 2, l = this.get(k), c = this.get(o), f = _.getccenter(a, l, c), f.interval = {
921
921
  start: i,
922
- end: s
923
- }, a = this._error(f, r, i, s) <= e, g = p && !a, g || (C = s), a) {
924
- if (s >= 1) {
925
- if (f.interval.end = C = 1, h = f, s > 1) {
926
- let S = {
927
- x: f.x + f.r * rt(f.e),
928
- y: f.y + f.r * st(f.e)
922
+ end: o
923
+ }, y = this._error(f, a, i, o) <= e, M = d && !y, M || (L = o), y) {
924
+ if (o >= 1) {
925
+ if (f.interval.end = L = 1, g = f, o > 1) {
926
+ let O = {
927
+ x: f.x + f.r * ge(f.e),
928
+ y: f.y + f.r * me(f.e)
929
929
  };
930
- f.e += y.angle({ x: f.x, y: f.y }, S, this.get(1));
930
+ f.e += _.angle({ x: f.x, y: f.y }, O, this.get(1));
931
931
  }
932
932
  break;
933
933
  }
934
- s = s + (s - i) / 2;
934
+ o = o + (o - i) / 2;
935
935
  } else
936
- s = _;
937
- while (!g && c++ < 100);
938
- if (c >= 100)
936
+ o = k;
937
+ while (!M && s++ < 100);
938
+ if (s >= 100)
939
939
  break;
940
- h = h || f, n.push(h), i = C;
941
- } while (s < 1);
940
+ g = g || f, r.push(g), i = L;
941
+ } while (o < 1);
942
+ return r;
943
+ }
944
+ }
945
+ var Q = 63710088e-1, te = {
946
+ centimeters: Q * 100,
947
+ centimetres: Q * 100,
948
+ degrees: Q / 111325,
949
+ feet: Q * 3.28084,
950
+ inches: Q * 39.37,
951
+ kilometers: Q / 1e3,
952
+ kilometres: Q / 1e3,
953
+ meters: Q,
954
+ metres: Q,
955
+ miles: Q / 1609.344,
956
+ millimeters: Q * 1e3,
957
+ millimetres: Q * 1e3,
958
+ nauticalmiles: Q / 1852,
959
+ radians: 1,
960
+ yards: Q * 1.0936
961
+ };
962
+ function ee(n, e, r) {
963
+ r === void 0 && (r = {});
964
+ var i = { type: "Feature" };
965
+ return (r.id === 0 || r.id) && (i.id = r.id), r.bbox && (i.bbox = r.bbox), i.properties = e || {}, i.geometry = n, i;
966
+ }
967
+ function ht(n, e, r) {
968
+ if (r === void 0 && (r = {}), !n)
969
+ throw new Error("coordinates is required");
970
+ if (!Array.isArray(n))
971
+ throw new Error("coordinates must be an Array");
972
+ if (n.length < 2)
973
+ throw new Error("coordinates must be at least 2 numbers long");
974
+ if (!Tt(n[0]) || !Tt(n[1]))
975
+ throw new Error("coordinates must contain numbers");
976
+ var i = {
977
+ type: "Point",
978
+ coordinates: n
979
+ };
980
+ return ee(i, e, r);
981
+ }
982
+ function Dt(n, e, r) {
983
+ r === void 0 && (r = {});
984
+ for (var i = 0, o = n; i < o.length; i++) {
985
+ var s = o[i];
986
+ if (s.length < 4)
987
+ throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
988
+ for (var a = 0; a < s[s.length - 1].length; a++)
989
+ if (s[s.length - 1][a] !== s[0][a])
990
+ throw new Error("First and last Position are not equivalent.");
991
+ }
992
+ var l = {
993
+ type: "Polygon",
994
+ coordinates: n
995
+ };
996
+ return ee(l, e, r);
997
+ }
998
+ function _t(n, e) {
999
+ if (e === void 0 && (e = 0), e && !(e >= 0))
1000
+ throw new Error("precision must be a positive number");
1001
+ var r = Math.pow(10, e || 0);
1002
+ return Math.round(n * r) / r;
1003
+ }
1004
+ function we(n, e) {
1005
+ e === void 0 && (e = "kilometers");
1006
+ var r = te[e];
1007
+ if (!r)
1008
+ throw new Error(e + " units is invalid");
1009
+ return n * r;
1010
+ }
1011
+ function Me(n, e) {
1012
+ e === void 0 && (e = "kilometers");
1013
+ var r = te[e];
1014
+ if (!r)
1015
+ throw new Error(e + " units is invalid");
1016
+ return n / r;
1017
+ }
1018
+ function Nt(n) {
1019
+ var e = n % (2 * Math.PI);
1020
+ return e * 180 / Math.PI;
1021
+ }
1022
+ function it(n) {
1023
+ var e = n % 360;
1024
+ return e * Math.PI / 180;
1025
+ }
1026
+ function Tt(n) {
1027
+ return !isNaN(n) && n !== null && !Array.isArray(n);
1028
+ }
1029
+ function kt(n, e, r) {
1030
+ if (n !== null)
1031
+ for (var i, o, s, a, l, c, f, g = 0, y = 0, d, M = n.type, k = M === "FeatureCollection", L = M === "Feature", D = k ? n.features.length : 1, O = 0; O < D; O++) {
1032
+ f = k ? n.features[O].geometry : L ? n.geometry : n, d = f ? f.type === "GeometryCollection" : !1, l = d ? f.geometries.length : 1;
1033
+ for (var u = 0; u < l; u++) {
1034
+ var h = 0, m = 0;
1035
+ if (a = d ? f.geometries[u] : f, a !== null) {
1036
+ c = a.coordinates;
1037
+ var p = a.type;
1038
+ switch (g = r && (p === "Polygon" || p === "MultiPolygon") ? 1 : 0, p) {
1039
+ case null:
1040
+ break;
1041
+ case "Point":
1042
+ if (e(
1043
+ c,
1044
+ y,
1045
+ O,
1046
+ h,
1047
+ m
1048
+ ) === !1)
1049
+ return !1;
1050
+ y++, h++;
1051
+ break;
1052
+ case "LineString":
1053
+ case "MultiPoint":
1054
+ for (i = 0; i < c.length; i++) {
1055
+ if (e(
1056
+ c[i],
1057
+ y,
1058
+ O,
1059
+ h,
1060
+ m
1061
+ ) === !1)
1062
+ return !1;
1063
+ y++, p === "MultiPoint" && h++;
1064
+ }
1065
+ p === "LineString" && h++;
1066
+ break;
1067
+ case "Polygon":
1068
+ case "MultiLineString":
1069
+ for (i = 0; i < c.length; i++) {
1070
+ for (o = 0; o < c[i].length - g; o++) {
1071
+ if (e(
1072
+ c[i][o],
1073
+ y,
1074
+ O,
1075
+ h,
1076
+ m
1077
+ ) === !1)
1078
+ return !1;
1079
+ y++;
1080
+ }
1081
+ p === "MultiLineString" && h++, p === "Polygon" && m++;
1082
+ }
1083
+ p === "Polygon" && h++;
1084
+ break;
1085
+ case "MultiPolygon":
1086
+ for (i = 0; i < c.length; i++) {
1087
+ for (m = 0, o = 0; o < c[i].length; o++) {
1088
+ for (s = 0; s < c[i][o].length - g; s++) {
1089
+ if (e(
1090
+ c[i][o][s],
1091
+ y,
1092
+ O,
1093
+ h,
1094
+ m
1095
+ ) === !1)
1096
+ return !1;
1097
+ y++;
1098
+ }
1099
+ m++;
1100
+ }
1101
+ h++;
1102
+ }
1103
+ break;
1104
+ case "GeometryCollection":
1105
+ for (i = 0; i < a.geometries.length; i++)
1106
+ if (kt(a.geometries[i], e, r) === !1)
1107
+ return !1;
1108
+ break;
1109
+ default:
1110
+ throw new Error("Unknown Geometry Type");
1111
+ }
1112
+ }
1113
+ }
1114
+ }
1115
+ }
1116
+ function _e(n, e) {
1117
+ var r, i, o, s, a, l, c, f, g, y, d = 0, M = n.type === "FeatureCollection", k = n.type === "Feature", L = M ? n.features.length : 1;
1118
+ for (r = 0; r < L; r++) {
1119
+ for (l = M ? n.features[r].geometry : k ? n.geometry : n, f = M ? n.features[r].properties : k ? n.properties : {}, g = M ? n.features[r].bbox : k ? n.bbox : void 0, y = M ? n.features[r].id : k ? n.id : void 0, c = l ? l.type === "GeometryCollection" : !1, a = c ? l.geometries.length : 1, o = 0; o < a; o++) {
1120
+ if (s = c ? l.geometries[o] : l, s === null) {
1121
+ if (e(
1122
+ null,
1123
+ d,
1124
+ f,
1125
+ g,
1126
+ y
1127
+ ) === !1)
1128
+ return !1;
1129
+ continue;
1130
+ }
1131
+ switch (s.type) {
1132
+ case "Point":
1133
+ case "LineString":
1134
+ case "MultiPoint":
1135
+ case "Polygon":
1136
+ case "MultiLineString":
1137
+ case "MultiPolygon": {
1138
+ if (e(
1139
+ s,
1140
+ d,
1141
+ f,
1142
+ g,
1143
+ y
1144
+ ) === !1)
1145
+ return !1;
1146
+ break;
1147
+ }
1148
+ case "GeometryCollection": {
1149
+ for (i = 0; i < s.geometries.length; i++)
1150
+ if (e(
1151
+ s.geometries[i],
1152
+ d,
1153
+ f,
1154
+ g,
1155
+ y
1156
+ ) === !1)
1157
+ return !1;
1158
+ break;
1159
+ }
1160
+ default:
1161
+ throw new Error("Unknown Geometry Type");
1162
+ }
1163
+ }
1164
+ d++;
1165
+ }
1166
+ }
1167
+ function ze(n, e, r) {
1168
+ var i = r;
1169
+ return _e(
1170
+ n,
1171
+ function(o, s, a, l, c) {
1172
+ s === 0 && r === void 0 ? i = o : i = e(
1173
+ i,
1174
+ o,
1175
+ s,
1176
+ a,
1177
+ l,
1178
+ c
1179
+ );
1180
+ }
1181
+ ), i;
1182
+ }
1183
+ function yt(n) {
1184
+ if (!n)
1185
+ throw new Error("coord is required");
1186
+ if (!Array.isArray(n)) {
1187
+ if (n.type === "Feature" && n.geometry !== null && n.geometry.type === "Point")
1188
+ return n.geometry.coordinates;
1189
+ if (n.type === "Point")
1190
+ return n.coordinates;
1191
+ }
1192
+ if (Array.isArray(n) && n.length >= 2 && !Array.isArray(n[0]) && !Array.isArray(n[1]))
1193
+ return n;
1194
+ throw new Error("coord must be GeoJSON Point or an Array of numbers");
1195
+ }
1196
+ function Se(n, e) {
1197
+ return n.type === "FeatureCollection" ? "FeatureCollection" : n.type === "GeometryCollection" ? "GeometryCollection" : n.type === "Feature" && n.geometry !== null ? n.geometry.type : n.type;
1198
+ }
1199
+ var re = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
1200
+ function ke(n) {
1201
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
1202
+ }
1203
+ function Pe(n) {
1204
+ if (n.__esModule)
942
1205
  return n;
1206
+ var e = n.default;
1207
+ if (typeof e == "function") {
1208
+ var r = function i() {
1209
+ return this instanceof i ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments);
1210
+ };
1211
+ r.prototype = e.prototype;
1212
+ } else
1213
+ r = {};
1214
+ return Object.defineProperty(r, "__esModule", { value: !0 }), Object.keys(n).forEach(function(i) {
1215
+ var o = Object.getOwnPropertyDescriptor(n, i);
1216
+ Object.defineProperty(r, i, o.get ? o : {
1217
+ enumerable: !0,
1218
+ get: function() {
1219
+ return n[i];
1220
+ }
1221
+ });
1222
+ }), r;
1223
+ }
1224
+ var Jt = { exports: {} }, ne = { exports: {} };
1225
+ (function(n, e) {
1226
+ (function(r, i) {
1227
+ n.exports = i();
1228
+ })(re, function() {
1229
+ function r(u, h, m, p, w) {
1230
+ (function x(v, S, X, Y, b) {
1231
+ for (; Y > X; ) {
1232
+ if (Y - X > 600) {
1233
+ var N = Y - X + 1, R = S - X + 1, H = Math.log(N), z = 0.5 * Math.exp(2 * H / 3), E = 0.5 * Math.sqrt(H * z * (N - z) / N) * (R - N / 2 < 0 ? -1 : 1), q = Math.max(X, Math.floor(S - R * z / N + E)), F = Math.min(Y, Math.floor(S + (N - R) * z / N + E));
1234
+ x(v, S, q, F, b);
1235
+ }
1236
+ var P = v[S], C = X, A = Y;
1237
+ for (i(v, X, S), b(v[Y], P) > 0 && i(v, X, Y); C < A; ) {
1238
+ for (i(v, C, A), C++, A--; b(v[C], P) < 0; )
1239
+ C++;
1240
+ for (; b(v[A], P) > 0; )
1241
+ A--;
1242
+ }
1243
+ b(v[X], P) === 0 ? i(v, X, A) : i(v, ++A, Y), A <= S && (X = A + 1), S <= A && (Y = A - 1);
1244
+ }
1245
+ })(u, h, m || 0, p || u.length - 1, w || o);
1246
+ }
1247
+ function i(u, h, m) {
1248
+ var p = u[h];
1249
+ u[h] = u[m], u[m] = p;
1250
+ }
1251
+ function o(u, h) {
1252
+ return u < h ? -1 : u > h ? 1 : 0;
1253
+ }
1254
+ var s = function(u) {
1255
+ u === void 0 && (u = 9), this._maxEntries = Math.max(4, u), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
1256
+ };
1257
+ function a(u, h, m) {
1258
+ if (!m)
1259
+ return h.indexOf(u);
1260
+ for (var p = 0; p < h.length; p++)
1261
+ if (m(u, h[p]))
1262
+ return p;
1263
+ return -1;
1264
+ }
1265
+ function l(u, h) {
1266
+ c(u, 0, u.children.length, h, u);
1267
+ }
1268
+ function c(u, h, m, p, w) {
1269
+ w || (w = D(null)), w.minX = 1 / 0, w.minY = 1 / 0, w.maxX = -1 / 0, w.maxY = -1 / 0;
1270
+ for (var x = h; x < m; x++) {
1271
+ var v = u.children[x];
1272
+ f(w, u.leaf ? p(v) : v);
1273
+ }
1274
+ return w;
1275
+ }
1276
+ function f(u, h) {
1277
+ return u.minX = Math.min(u.minX, h.minX), u.minY = Math.min(u.minY, h.minY), u.maxX = Math.max(u.maxX, h.maxX), u.maxY = Math.max(u.maxY, h.maxY), u;
1278
+ }
1279
+ function g(u, h) {
1280
+ return u.minX - h.minX;
1281
+ }
1282
+ function y(u, h) {
1283
+ return u.minY - h.minY;
1284
+ }
1285
+ function d(u) {
1286
+ return (u.maxX - u.minX) * (u.maxY - u.minY);
1287
+ }
1288
+ function M(u) {
1289
+ return u.maxX - u.minX + (u.maxY - u.minY);
1290
+ }
1291
+ function k(u, h) {
1292
+ return u.minX <= h.minX && u.minY <= h.minY && h.maxX <= u.maxX && h.maxY <= u.maxY;
1293
+ }
1294
+ function L(u, h) {
1295
+ return h.minX <= u.maxX && h.minY <= u.maxY && h.maxX >= u.minX && h.maxY >= u.minY;
1296
+ }
1297
+ function D(u) {
1298
+ return { children: u, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
1299
+ }
1300
+ function O(u, h, m, p, w) {
1301
+ for (var x = [h, m]; x.length; )
1302
+ if (!((m = x.pop()) - (h = x.pop()) <= p)) {
1303
+ var v = h + Math.ceil((m - h) / p / 2) * p;
1304
+ r(u, v, h, m, w), x.push(h, v, v, m);
1305
+ }
1306
+ }
1307
+ return s.prototype.all = function() {
1308
+ return this._all(this.data, []);
1309
+ }, s.prototype.search = function(u) {
1310
+ var h = this.data, m = [];
1311
+ if (!L(u, h))
1312
+ return m;
1313
+ for (var p = this.toBBox, w = []; h; ) {
1314
+ for (var x = 0; x < h.children.length; x++) {
1315
+ var v = h.children[x], S = h.leaf ? p(v) : v;
1316
+ L(u, S) && (h.leaf ? m.push(v) : k(u, S) ? this._all(v, m) : w.push(v));
1317
+ }
1318
+ h = w.pop();
1319
+ }
1320
+ return m;
1321
+ }, s.prototype.collides = function(u) {
1322
+ var h = this.data;
1323
+ if (!L(u, h))
1324
+ return !1;
1325
+ for (var m = []; h; ) {
1326
+ for (var p = 0; p < h.children.length; p++) {
1327
+ var w = h.children[p], x = h.leaf ? this.toBBox(w) : w;
1328
+ if (L(u, x)) {
1329
+ if (h.leaf || k(u, x))
1330
+ return !0;
1331
+ m.push(w);
1332
+ }
1333
+ }
1334
+ h = m.pop();
1335
+ }
1336
+ return !1;
1337
+ }, s.prototype.load = function(u) {
1338
+ if (!u || !u.length)
1339
+ return this;
1340
+ if (u.length < this._minEntries) {
1341
+ for (var h = 0; h < u.length; h++)
1342
+ this.insert(u[h]);
1343
+ return this;
1344
+ }
1345
+ var m = this._build(u.slice(), 0, u.length - 1, 0);
1346
+ if (this.data.children.length)
1347
+ if (this.data.height === m.height)
1348
+ this._splitRoot(this.data, m);
1349
+ else {
1350
+ if (this.data.height < m.height) {
1351
+ var p = this.data;
1352
+ this.data = m, m = p;
1353
+ }
1354
+ this._insert(m, this.data.height - m.height - 1, !0);
1355
+ }
1356
+ else
1357
+ this.data = m;
1358
+ return this;
1359
+ }, s.prototype.insert = function(u) {
1360
+ return u && this._insert(u, this.data.height - 1), this;
1361
+ }, s.prototype.clear = function() {
1362
+ return this.data = D([]), this;
1363
+ }, s.prototype.remove = function(u, h) {
1364
+ if (!u)
1365
+ return this;
1366
+ for (var m, p, w, x = this.data, v = this.toBBox(u), S = [], X = []; x || S.length; ) {
1367
+ if (x || (x = S.pop(), p = S[S.length - 1], m = X.pop(), w = !0), x.leaf) {
1368
+ var Y = a(u, x.children, h);
1369
+ if (Y !== -1)
1370
+ return x.children.splice(Y, 1), S.push(x), this._condense(S), this;
1371
+ }
1372
+ w || x.leaf || !k(x, v) ? p ? (m++, x = p.children[m], w = !1) : x = null : (S.push(x), X.push(m), m = 0, p = x, x = x.children[0]);
1373
+ }
1374
+ return this;
1375
+ }, s.prototype.toBBox = function(u) {
1376
+ return u;
1377
+ }, s.prototype.compareMinX = function(u, h) {
1378
+ return u.minX - h.minX;
1379
+ }, s.prototype.compareMinY = function(u, h) {
1380
+ return u.minY - h.minY;
1381
+ }, s.prototype.toJSON = function() {
1382
+ return this.data;
1383
+ }, s.prototype.fromJSON = function(u) {
1384
+ return this.data = u, this;
1385
+ }, s.prototype._all = function(u, h) {
1386
+ for (var m = []; u; )
1387
+ u.leaf ? h.push.apply(h, u.children) : m.push.apply(m, u.children), u = m.pop();
1388
+ return h;
1389
+ }, s.prototype._build = function(u, h, m, p) {
1390
+ var w, x = m - h + 1, v = this._maxEntries;
1391
+ if (x <= v)
1392
+ return l(w = D(u.slice(h, m + 1)), this.toBBox), w;
1393
+ p || (p = Math.ceil(Math.log(x) / Math.log(v)), v = Math.ceil(x / Math.pow(v, p - 1))), (w = D([])).leaf = !1, w.height = p;
1394
+ var S = Math.ceil(x / v), X = S * Math.ceil(Math.sqrt(v));
1395
+ O(u, h, m, X, this.compareMinX);
1396
+ for (var Y = h; Y <= m; Y += X) {
1397
+ var b = Math.min(Y + X - 1, m);
1398
+ O(u, Y, b, S, this.compareMinY);
1399
+ for (var N = Y; N <= b; N += S) {
1400
+ var R = Math.min(N + S - 1, b);
1401
+ w.children.push(this._build(u, N, R, p - 1));
1402
+ }
1403
+ }
1404
+ return l(w, this.toBBox), w;
1405
+ }, s.prototype._chooseSubtree = function(u, h, m, p) {
1406
+ for (; p.push(h), !h.leaf && p.length - 1 !== m; ) {
1407
+ for (var w = 1 / 0, x = 1 / 0, v = void 0, S = 0; S < h.children.length; S++) {
1408
+ var X = h.children[S], Y = d(X), b = (N = u, R = X, (Math.max(R.maxX, N.maxX) - Math.min(R.minX, N.minX)) * (Math.max(R.maxY, N.maxY) - Math.min(R.minY, N.minY)) - Y);
1409
+ b < x ? (x = b, w = Y < w ? Y : w, v = X) : b === x && Y < w && (w = Y, v = X);
1410
+ }
1411
+ h = v || h.children[0];
1412
+ }
1413
+ var N, R;
1414
+ return h;
1415
+ }, s.prototype._insert = function(u, h, m) {
1416
+ var p = m ? u : this.toBBox(u), w = [], x = this._chooseSubtree(p, this.data, h, w);
1417
+ for (x.children.push(u), f(x, p); h >= 0 && w[h].children.length > this._maxEntries; )
1418
+ this._split(w, h), h--;
1419
+ this._adjustParentBBoxes(p, w, h);
1420
+ }, s.prototype._split = function(u, h) {
1421
+ var m = u[h], p = m.children.length, w = this._minEntries;
1422
+ this._chooseSplitAxis(m, w, p);
1423
+ var x = this._chooseSplitIndex(m, w, p), v = D(m.children.splice(x, m.children.length - x));
1424
+ v.height = m.height, v.leaf = m.leaf, l(m, this.toBBox), l(v, this.toBBox), h ? u[h - 1].children.push(v) : this._splitRoot(m, v);
1425
+ }, s.prototype._splitRoot = function(u, h) {
1426
+ this.data = D([u, h]), this.data.height = u.height + 1, this.data.leaf = !1, l(this.data, this.toBBox);
1427
+ }, s.prototype._chooseSplitIndex = function(u, h, m) {
1428
+ for (var p, w, x, v, S, X, Y, b = 1 / 0, N = 1 / 0, R = h; R <= m - h; R++) {
1429
+ var H = c(u, 0, R, this.toBBox), z = c(u, R, m, this.toBBox), E = (w = H, x = z, v = void 0, S = void 0, X = void 0, Y = void 0, v = Math.max(w.minX, x.minX), S = Math.max(w.minY, x.minY), X = Math.min(w.maxX, x.maxX), Y = Math.min(w.maxY, x.maxY), Math.max(0, X - v) * Math.max(0, Y - S)), q = d(H) + d(z);
1430
+ E < b ? (b = E, p = R, N = q < N ? q : N) : E === b && q < N && (N = q, p = R);
1431
+ }
1432
+ return p || m - h;
1433
+ }, s.prototype._chooseSplitAxis = function(u, h, m) {
1434
+ var p = u.leaf ? this.compareMinX : g, w = u.leaf ? this.compareMinY : y;
1435
+ this._allDistMargin(u, h, m, p) < this._allDistMargin(u, h, m, w) && u.children.sort(p);
1436
+ }, s.prototype._allDistMargin = function(u, h, m, p) {
1437
+ u.children.sort(p);
1438
+ for (var w = this.toBBox, x = c(u, 0, h, w), v = c(u, m - h, m, w), S = M(x) + M(v), X = h; X < m - h; X++) {
1439
+ var Y = u.children[X];
1440
+ f(x, u.leaf ? w(Y) : Y), S += M(x);
1441
+ }
1442
+ for (var b = m - h - 1; b >= h; b--) {
1443
+ var N = u.children[b];
1444
+ f(v, u.leaf ? w(N) : N), S += M(v);
1445
+ }
1446
+ return S;
1447
+ }, s.prototype._adjustParentBBoxes = function(u, h, m) {
1448
+ for (var p = m; p >= 0; p--)
1449
+ f(h[p], u);
1450
+ }, s.prototype._condense = function(u) {
1451
+ for (var h = u.length - 1, m = void 0; h >= 0; h--)
1452
+ u[h].children.length === 0 ? h > 0 ? (m = u[h - 1].children).splice(m.indexOf(u[h]), 1) : this.clear() : l(u[h], this.toBBox);
1453
+ }, s;
1454
+ });
1455
+ })(ne);
1456
+ var Le = ne.exports;
1457
+ class Xe {
1458
+ constructor(e = [], r = Ye) {
1459
+ if (this.data = e, this.length = this.data.length, this.compare = r, this.length > 0)
1460
+ for (let i = (this.length >> 1) - 1; i >= 0; i--)
1461
+ this._down(i);
1462
+ }
1463
+ push(e) {
1464
+ this.data.push(e), this.length++, this._up(this.length - 1);
1465
+ }
1466
+ pop() {
1467
+ if (this.length === 0)
1468
+ return;
1469
+ const e = this.data[0], r = this.data.pop();
1470
+ return this.length--, this.length > 0 && (this.data[0] = r, this._down(0)), e;
1471
+ }
1472
+ peek() {
1473
+ return this.data[0];
1474
+ }
1475
+ _up(e) {
1476
+ const { data: r, compare: i } = this, o = r[e];
1477
+ for (; e > 0; ) {
1478
+ const s = e - 1 >> 1, a = r[s];
1479
+ if (i(o, a) >= 0)
1480
+ break;
1481
+ r[e] = a, e = s;
1482
+ }
1483
+ r[e] = o;
1484
+ }
1485
+ _down(e) {
1486
+ const { data: r, compare: i } = this, o = this.length >> 1, s = r[e];
1487
+ for (; e < o; ) {
1488
+ let a = (e << 1) + 1, l = r[a];
1489
+ const c = a + 1;
1490
+ if (c < this.length && i(r[c], l) < 0 && (a = c, l = r[c]), i(l, s) >= 0)
1491
+ break;
1492
+ r[e] = l, e = a;
1493
+ }
1494
+ r[e] = s;
1495
+ }
1496
+ }
1497
+ function Ye(n, e) {
1498
+ return n < e ? -1 : n > e ? 1 : 0;
1499
+ }
1500
+ const Ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1501
+ __proto__: null,
1502
+ default: Xe
1503
+ }, Symbol.toStringTag, { value: "Module" })), Ae = /* @__PURE__ */ Pe(Ee);
1504
+ var Pt = { exports: {} }, Oe = function(e, r, i, o) {
1505
+ var s = e[0], a = e[1], l = !1;
1506
+ i === void 0 && (i = 0), o === void 0 && (o = r.length);
1507
+ for (var c = (o - i) / 2, f = 0, g = c - 1; f < c; g = f++) {
1508
+ var y = r[i + f * 2 + 0], d = r[i + f * 2 + 1], M = r[i + g * 2 + 0], k = r[i + g * 2 + 1], L = d > a != k > a && s < (M - y) * (a - d) / (k - d) + y;
1509
+ L && (l = !l);
1510
+ }
1511
+ return l;
1512
+ }, Ce = function(e, r, i, o) {
1513
+ var s = e[0], a = e[1], l = !1;
1514
+ i === void 0 && (i = 0), o === void 0 && (o = r.length);
1515
+ for (var c = o - i, f = 0, g = c - 1; f < c; g = f++) {
1516
+ var y = r[f + i][0], d = r[f + i][1], M = r[g + i][0], k = r[g + i][1], L = d > a != k > a && s < (M - y) * (a - d) / (k - d) + y;
1517
+ L && (l = !l);
1518
+ }
1519
+ return l;
1520
+ }, ie = Oe, oe = Ce;
1521
+ Pt.exports = function(e, r, i, o) {
1522
+ return r.length > 0 && Array.isArray(r[0]) ? oe(e, r, i, o) : ie(e, r, i, o);
1523
+ };
1524
+ Pt.exports.nested = oe;
1525
+ Pt.exports.flat = ie;
1526
+ var be = Pt.exports, qt = { exports: {} };
1527
+ (function(n, e) {
1528
+ (function(r, i) {
1529
+ i(e);
1530
+ })(re, function(r) {
1531
+ const o = 33306690738754706e-32;
1532
+ function s(L, D, O, u, h) {
1533
+ let m, p, w, x, v = D[0], S = u[0], X = 0, Y = 0;
1534
+ S > v == S > -v ? (m = v, v = D[++X]) : (m = S, S = u[++Y]);
1535
+ let b = 0;
1536
+ if (X < L && Y < O)
1537
+ for (S > v == S > -v ? (w = m - ((p = v + m) - v), v = D[++X]) : (w = m - ((p = S + m) - S), S = u[++Y]), m = p, w !== 0 && (h[b++] = w); X < L && Y < O; )
1538
+ S > v == S > -v ? (w = m - ((p = m + v) - (x = p - m)) + (v - x), v = D[++X]) : (w = m - ((p = m + S) - (x = p - m)) + (S - x), S = u[++Y]), m = p, w !== 0 && (h[b++] = w);
1539
+ for (; X < L; )
1540
+ w = m - ((p = m + v) - (x = p - m)) + (v - x), v = D[++X], m = p, w !== 0 && (h[b++] = w);
1541
+ for (; Y < O; )
1542
+ w = m - ((p = m + S) - (x = p - m)) + (S - x), S = u[++Y], m = p, w !== 0 && (h[b++] = w);
1543
+ return m === 0 && b !== 0 || (h[b++] = m), b;
1544
+ }
1545
+ function a(L) {
1546
+ return new Float64Array(L);
1547
+ }
1548
+ const l = 33306690738754716e-32, c = 22204460492503146e-32, f = 11093356479670487e-47, g = a(4), y = a(8), d = a(12), M = a(16), k = a(4);
1549
+ r.orient2d = function(L, D, O, u, h, m) {
1550
+ const p = (D - m) * (O - h), w = (L - h) * (u - m), x = p - w;
1551
+ if (p === 0 || w === 0 || p > 0 != w > 0)
1552
+ return x;
1553
+ const v = Math.abs(p + w);
1554
+ return Math.abs(x) >= l * v ? x : -function(S, X, Y, b, N, R, H) {
1555
+ let z, E, q, F, P, C, A, $, J, T, B, G, I, Z, j, K, st, V;
1556
+ const tt = S - N, et = Y - N, rt = X - R, nt = b - R;
1557
+ P = (j = ($ = tt - (A = (C = 134217729 * tt) - (C - tt))) * (T = nt - (J = (C = 134217729 * nt) - (C - nt))) - ((Z = tt * nt) - A * J - $ * J - A * T)) - (B = j - (st = ($ = rt - (A = (C = 134217729 * rt) - (C - rt))) * (T = et - (J = (C = 134217729 * et) - (C - et))) - ((K = rt * et) - A * J - $ * J - A * T))), g[0] = j - (B + P) + (P - st), P = (I = Z - ((G = Z + B) - (P = G - Z)) + (B - P)) - (B = I - K), g[1] = I - (B + P) + (P - K), P = (V = G + B) - G, g[2] = G - (V - P) + (B - P), g[3] = V;
1558
+ let at = function(he, Bt) {
1559
+ let Rt = Bt[0];
1560
+ for (let Lt = 1; Lt < he; Lt++)
1561
+ Rt += Bt[Lt];
1562
+ return Rt;
1563
+ }(4, g), dt = c * H;
1564
+ if (at >= dt || -at >= dt || (z = S - (tt + (P = S - tt)) + (P - N), q = Y - (et + (P = Y - et)) + (P - N), E = X - (rt + (P = X - rt)) + (P - R), F = b - (nt + (P = b - nt)) + (P - R), z === 0 && E === 0 && q === 0 && F === 0) || (dt = f * H + o * Math.abs(at), (at += tt * F + nt * z - (rt * q + et * E)) >= dt || -at >= dt))
1565
+ return at;
1566
+ P = (j = ($ = z - (A = (C = 134217729 * z) - (C - z))) * (T = nt - (J = (C = 134217729 * nt) - (C - nt))) - ((Z = z * nt) - A * J - $ * J - A * T)) - (B = j - (st = ($ = E - (A = (C = 134217729 * E) - (C - E))) * (T = et - (J = (C = 134217729 * et) - (C - et))) - ((K = E * et) - A * J - $ * J - A * T))), k[0] = j - (B + P) + (P - st), P = (I = Z - ((G = Z + B) - (P = G - Z)) + (B - P)) - (B = I - K), k[1] = I - (B + P) + (P - K), P = (V = G + B) - G, k[2] = G - (V - P) + (B - P), k[3] = V;
1567
+ const ce = s(4, g, 4, k, y);
1568
+ P = (j = ($ = tt - (A = (C = 134217729 * tt) - (C - tt))) * (T = F - (J = (C = 134217729 * F) - (C - F))) - ((Z = tt * F) - A * J - $ * J - A * T)) - (B = j - (st = ($ = rt - (A = (C = 134217729 * rt) - (C - rt))) * (T = q - (J = (C = 134217729 * q) - (C - q))) - ((K = rt * q) - A * J - $ * J - A * T))), k[0] = j - (B + P) + (P - st), P = (I = Z - ((G = Z + B) - (P = G - Z)) + (B - P)) - (B = I - K), k[1] = I - (B + P) + (P - K), P = (V = G + B) - G, k[2] = G - (V - P) + (B - P), k[3] = V;
1569
+ const ue = s(ce, y, 4, k, d);
1570
+ P = (j = ($ = z - (A = (C = 134217729 * z) - (C - z))) * (T = F - (J = (C = 134217729 * F) - (C - F))) - ((Z = z * F) - A * J - $ * J - A * T)) - (B = j - (st = ($ = E - (A = (C = 134217729 * E) - (C - E))) * (T = q - (J = (C = 134217729 * q) - (C - q))) - ((K = E * q) - A * J - $ * J - A * T))), k[0] = j - (B + P) + (P - st), P = (I = Z - ((G = Z + B) - (P = G - Z)) + (B - P)) - (B = I - K), k[1] = I - (B + P) + (P - K), P = (V = G + B) - G, k[2] = G - (V - P) + (B - P), k[3] = V;
1571
+ const fe = s(ue, d, 4, k, M);
1572
+ return M[fe - 1];
1573
+ }(L, D, O, u, h, m, v);
1574
+ }, r.orient2dfast = function(L, D, O, u, h, m) {
1575
+ return (D - m) * (O - h) - (L - h) * (u - m);
1576
+ }, Object.defineProperty(r, "__esModule", { value: !0 });
1577
+ });
1578
+ })(qt, qt.exports);
1579
+ var De = qt.exports, Ut = Le, St = Ae, Ne = be, qe = De.orient2d;
1580
+ St.default && (St = St.default);
1581
+ Jt.exports = se;
1582
+ Jt.exports.default = se;
1583
+ function se(n, e, r) {
1584
+ e = Math.max(0, e === void 0 ? 2 : e), r = r || 0;
1585
+ var i = $e(n), o = new Ut(16);
1586
+ o.toBBox = function(u) {
1587
+ return {
1588
+ minX: u[0],
1589
+ minY: u[1],
1590
+ maxX: u[0],
1591
+ maxY: u[1]
1592
+ };
1593
+ }, o.compareMinX = function(u, h) {
1594
+ return u[0] - h[0];
1595
+ }, o.compareMinY = function(u, h) {
1596
+ return u[1] - h[1];
1597
+ }, o.load(n);
1598
+ for (var s = [], a = 0, l; a < i.length; a++) {
1599
+ var c = i[a];
1600
+ o.remove(c), l = Ht(c, l), s.push(l);
1601
+ }
1602
+ var f = new Ut(16);
1603
+ for (a = 0; a < s.length; a++)
1604
+ f.insert(Et(s[a]));
1605
+ for (var g = e * e, y = r * r; s.length; ) {
1606
+ var d = s.shift(), M = d.p, k = d.next.p, L = At(M, k);
1607
+ if (!(L < y)) {
1608
+ var D = L / g;
1609
+ c = Fe(o, d.prev.p, M, k, d.next.next.p, D, f), c && Math.min(At(c, M), At(c, k)) <= D && (s.push(d), s.push(Ht(c, d)), o.remove(c), f.remove(d), f.insert(Et(d)), f.insert(Et(d.next)));
1610
+ }
1611
+ }
1612
+ d = l;
1613
+ var O = [];
1614
+ do
1615
+ O.push(d.p), d = d.next;
1616
+ while (d !== l);
1617
+ return O.push(d.p), O;
1618
+ }
1619
+ function Fe(n, e, r, i, o, s, a) {
1620
+ for (var l = new St([], Je), c = n.data; c; ) {
1621
+ for (var f = 0; f < c.children.length; f++) {
1622
+ var g = c.children[f], y = c.leaf ? Ot(g, r, i) : Be(r, i, g);
1623
+ y > s || l.push({
1624
+ node: g,
1625
+ dist: y
1626
+ });
1627
+ }
1628
+ for (; l.length && !l.peek().node.children; ) {
1629
+ var d = l.pop(), M = d.node, k = Ot(M, e, r), L = Ot(M, i, o);
1630
+ if (d.dist < k && d.dist < L && Zt(r, M, a) && Zt(i, M, a))
1631
+ return M;
1632
+ }
1633
+ c = l.pop(), c && (c = c.node);
1634
+ }
1635
+ return null;
1636
+ }
1637
+ function Je(n, e) {
1638
+ return n.dist - e.dist;
1639
+ }
1640
+ function Be(n, e, r) {
1641
+ if (It(n, r) || It(e, r))
1642
+ return 0;
1643
+ var i = zt(n[0], n[1], e[0], e[1], r.minX, r.minY, r.maxX, r.minY);
1644
+ if (i === 0)
1645
+ return 0;
1646
+ var o = zt(n[0], n[1], e[0], e[1], r.minX, r.minY, r.minX, r.maxY);
1647
+ if (o === 0)
1648
+ return 0;
1649
+ var s = zt(n[0], n[1], e[0], e[1], r.maxX, r.minY, r.maxX, r.maxY);
1650
+ if (s === 0)
1651
+ return 0;
1652
+ var a = zt(n[0], n[1], e[0], e[1], r.minX, r.maxY, r.maxX, r.maxY);
1653
+ return a === 0 ? 0 : Math.min(i, o, s, a);
1654
+ }
1655
+ function It(n, e) {
1656
+ return n[0] >= e.minX && n[0] <= e.maxX && n[1] >= e.minY && n[1] <= e.maxY;
1657
+ }
1658
+ function Zt(n, e, r) {
1659
+ for (var i = Math.min(n[0], e[0]), o = Math.min(n[1], e[1]), s = Math.max(n[0], e[0]), a = Math.max(n[1], e[1]), l = r.search({ minX: i, minY: o, maxX: s, maxY: a }), c = 0; c < l.length; c++)
1660
+ if (Re(l[c].p, l[c].next.p, n, e))
1661
+ return !1;
1662
+ return !0;
1663
+ }
1664
+ function ft(n, e, r) {
1665
+ return qe(n[0], n[1], e[0], e[1], r[0], r[1]);
1666
+ }
1667
+ function Re(n, e, r, i) {
1668
+ return n !== i && e !== r && ft(n, e, r) > 0 != ft(n, e, i) > 0 && ft(r, i, n) > 0 != ft(r, i, e) > 0;
1669
+ }
1670
+ function Et(n) {
1671
+ var e = n.p, r = n.next.p;
1672
+ return n.minX = Math.min(e[0], r[0]), n.minY = Math.min(e[1], r[1]), n.maxX = Math.max(e[0], r[0]), n.maxY = Math.max(e[1], r[1]), n;
1673
+ }
1674
+ function $e(n) {
1675
+ for (var e = n[0], r = n[0], i = n[0], o = n[0], s = 0; s < n.length; s++) {
1676
+ var a = n[s];
1677
+ a[0] < e[0] && (e = a), a[0] > i[0] && (i = a), a[1] < r[1] && (r = a), a[1] > o[1] && (o = a);
1678
+ }
1679
+ var l = [e, r, i, o], c = l.slice();
1680
+ for (s = 0; s < n.length; s++)
1681
+ Ne(n[s], l) || c.push(n[s]);
1682
+ return Te(c);
1683
+ }
1684
+ function Ht(n, e) {
1685
+ var r = {
1686
+ p: n,
1687
+ prev: null,
1688
+ next: null,
1689
+ minX: 0,
1690
+ minY: 0,
1691
+ maxX: 0,
1692
+ maxY: 0
1693
+ };
1694
+ return e ? (r.next = e.next, r.prev = e, e.next.prev = r, e.next = r) : (r.prev = r, r.next = r), r;
1695
+ }
1696
+ function At(n, e) {
1697
+ var r = n[0] - e[0], i = n[1] - e[1];
1698
+ return r * r + i * i;
1699
+ }
1700
+ function Ot(n, e, r) {
1701
+ var i = e[0], o = e[1], s = r[0] - i, a = r[1] - o;
1702
+ if (s !== 0 || a !== 0) {
1703
+ var l = ((n[0] - i) * s + (n[1] - o) * a) / (s * s + a * a);
1704
+ l > 1 ? (i = r[0], o = r[1]) : l > 0 && (i += s * l, o += a * l);
1705
+ }
1706
+ return s = n[0] - i, a = n[1] - o, s * s + a * a;
1707
+ }
1708
+ function zt(n, e, r, i, o, s, a, l) {
1709
+ var c = r - n, f = i - e, g = a - o, y = l - s, d = n - o, M = e - s, k = c * c + f * f, L = c * g + f * y, D = g * g + y * y, O = c * d + f * M, u = g * d + y * M, h = k * D - L * L, m, p, w, x, v = h, S = h;
1710
+ h === 0 ? (p = 0, v = 1, x = u, S = D) : (p = L * u - D * O, x = k * u - L * O, p < 0 ? (p = 0, x = u, S = D) : p > v && (p = v, x = u + L, S = D)), x < 0 ? (x = 0, -O < 0 ? p = 0 : -O > k ? p = v : (p = -O, v = k)) : x > S && (x = S, -O + L < 0 ? p = 0 : -O + L > k ? p = v : (p = -O + L, v = k)), m = p === 0 ? 0 : p / v, w = x === 0 ? 0 : x / S;
1711
+ var X = (1 - m) * n + m * r, Y = (1 - m) * e + m * i, b = (1 - w) * o + w * a, N = (1 - w) * s + w * l, R = b - X, H = N - Y;
1712
+ return R * R + H * H;
1713
+ }
1714
+ function Ge(n, e) {
1715
+ return n[0] === e[0] ? n[1] - e[1] : n[0] - e[0];
1716
+ }
1717
+ function Te(n) {
1718
+ n.sort(Ge);
1719
+ for (var e = [], r = 0; r < n.length; r++) {
1720
+ for (; e.length >= 2 && ft(e[e.length - 2], e[e.length - 1], n[r]) <= 0; )
1721
+ e.pop();
1722
+ e.push(n[r]);
1723
+ }
1724
+ for (var i = [], o = n.length - 1; o >= 0; o--) {
1725
+ for (; i.length >= 2 && ft(i[i.length - 2], i[i.length - 1], n[o]) <= 0; )
1726
+ i.pop();
1727
+ i.push(n[o]);
1728
+ }
1729
+ return i.pop(), e.pop(), e.concat(i);
1730
+ }
1731
+ var Ue = Jt.exports;
1732
+ const Ie = /* @__PURE__ */ ke(Ue);
1733
+ function Ze(n, e) {
1734
+ e === void 0 && (e = {}), e.concavity = e.concavity || 1 / 0;
1735
+ var r = [];
1736
+ if (kt(n, function(o) {
1737
+ r.push([o[0], o[1]]);
1738
+ }), !r.length)
1739
+ return null;
1740
+ var i = Ie(r, e.concavity);
1741
+ return i.length > 3 ? Dt([i]) : null;
1742
+ }
1743
+ function ae(n, e, r) {
1744
+ r === void 0 && (r = {});
1745
+ var i = yt(n), o = yt(e), s = it(o[1] - i[1]), a = it(o[0] - i[0]), l = it(i[1]), c = it(o[1]), f = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(a / 2), 2) * Math.cos(l) * Math.cos(c);
1746
+ return we(2 * Math.atan2(Math.sqrt(f), Math.sqrt(1 - f)), r.units);
1747
+ }
1748
+ function He(n, e, r, i) {
1749
+ i === void 0 && (i = {});
1750
+ var o = yt(n), s = it(o[0]), a = it(o[1]), l = it(r), c = Me(e, i.units), f = Math.asin(Math.sin(a) * Math.cos(c) + Math.cos(a) * Math.sin(c) * Math.cos(l)), g = s + Math.atan2(Math.sin(l) * Math.sin(c) * Math.cos(a), Math.cos(c) - Math.sin(a) * Math.sin(f)), y = Nt(g), d = Nt(f);
1751
+ return ht([y, d], i.properties);
1752
+ }
1753
+ function le(n, e, r) {
1754
+ if (r === void 0 && (r = {}), r.final === !0)
1755
+ return Qe(n, e);
1756
+ var i = yt(n), o = yt(e), s = it(i[0]), a = it(o[0]), l = it(i[1]), c = it(o[1]), f = Math.sin(a - s) * Math.cos(c), g = Math.cos(l) * Math.sin(c) - Math.sin(l) * Math.cos(c) * Math.cos(a - s);
1757
+ return Nt(Math.atan2(f, g));
1758
+ }
1759
+ function Qe(n, e) {
1760
+ var r = le(e, n);
1761
+ return r = (r + 180) % 360, r;
1762
+ }
1763
+ function je(n, e) {
1764
+ var r = ae(n, e), i = le(n, e), o = He(n, r / 2, i);
1765
+ return o;
1766
+ }
1767
+ function Qt(n, e) {
1768
+ e === void 0 && (e = {});
1769
+ var r = 0, i = 0, o = 0;
1770
+ return kt(n, function(s) {
1771
+ r += s[0], i += s[1], o++;
1772
+ }, !0), ht([r / o, i / o], e.properties);
1773
+ }
1774
+ function Ft(n, e) {
1775
+ switch (e === void 0 && (e = {}), Se(n)) {
1776
+ case "Point":
1777
+ return ht(yt(n), e.properties);
1778
+ case "Polygon":
1779
+ var r = [];
1780
+ kt(n, function(m) {
1781
+ r.push(m);
1782
+ });
1783
+ var i = Qt(n, { properties: e.properties }), o = i.geometry.coordinates, s = 0, a = 0, l = 0, c, f, g, y, d, M, k, L, D = r.map(function(m) {
1784
+ return [m[0] - o[0], m[1] - o[1]];
1785
+ });
1786
+ for (c = 0; c < r.length - 1; c++)
1787
+ f = D[c], y = f[0], M = f[1], g = D[c + 1], d = g[0], k = g[1], L = y * k - d * M, l += L, s += (y + d) * L, a += (M + k) * L;
1788
+ if (l === 0)
1789
+ return i;
1790
+ var O = l * 0.5, u = 1 / (6 * O);
1791
+ return ht([o[0] + u * s, o[1] + u * a], e.properties);
1792
+ default:
1793
+ var h = Ze(n);
1794
+ return h ? Ft(h, { properties: e.properties }) : Qt(n, { properties: e.properties });
1795
+ }
1796
+ }
1797
+ var jt = 6378137;
1798
+ function Ct(n) {
1799
+ return ze(n, function(e, r) {
1800
+ return e + Ke(r);
1801
+ }, 0);
1802
+ }
1803
+ function Ke(n) {
1804
+ var e = 0, r;
1805
+ switch (n.type) {
1806
+ case "Polygon":
1807
+ return Kt(n.coordinates);
1808
+ case "MultiPolygon":
1809
+ for (r = 0; r < n.coordinates.length; r++)
1810
+ e += Kt(n.coordinates[r]);
1811
+ return e;
1812
+ case "Point":
1813
+ case "MultiPoint":
1814
+ case "LineString":
1815
+ case "MultiLineString":
1816
+ return 0;
943
1817
  }
1818
+ return 0;
944
1819
  }
945
- function lt(o) {
946
- let e = [], n = [], i = !1, s = !1, c = [], r = "", l = "", u = {
1820
+ function Kt(n) {
1821
+ var e = 0;
1822
+ if (n && n.length > 0) {
1823
+ e += Math.abs(Vt(n[0]));
1824
+ for (var r = 1; r < n.length; r++)
1825
+ e -= Math.abs(Vt(n[r]));
1826
+ }
1827
+ return e;
1828
+ }
1829
+ function Vt(n) {
1830
+ var e, r, i, o, s, a, l, c = 0, f = n.length;
1831
+ if (f > 2) {
1832
+ for (l = 0; l < f; l++)
1833
+ l === f - 2 ? (o = f - 2, s = f - 1, a = 0) : l === f - 1 ? (o = f - 1, s = 0, a = 1) : (o = l, s = l + 1, a = l + 2), e = n[o], r = n[s], i = n[a], c += (bt(i[0]) - bt(e[0])) * Math.sin(bt(r[1]));
1834
+ c = c * jt * jt / 2;
1835
+ }
1836
+ return c;
1837
+ }
1838
+ function bt(n) {
1839
+ return n * Math.PI / 180;
1840
+ }
1841
+ function Ve(n) {
1842
+ let e = "free", r = "", i = [], o = [], s = {}, a = !1, l = !0, c = !1, f = [], g = { type: "FeatureCollection", features: [] }, y = {
947
1843
  type: "Feature",
948
- properties: {
949
- fillColor: "",
950
- MGValue: 1
951
- },
1844
+ properties: {},
1845
+ geometry: {
1846
+ type: "LineString",
1847
+ coordinates: []
1848
+ }
1849
+ }, d = {
1850
+ type: "Feature",
1851
+ properties: {},
952
1852
  geometry: {
953
1853
  type: "Polygon",
954
- coordinates: [[]]
1854
+ coordinates: []
1855
+ }
1856
+ }, M = {
1857
+ type: "Feature",
1858
+ properties: { area: "" },
1859
+ geometry: {
1860
+ type: "Point",
1861
+ coordinates: []
955
1862
  }
956
1863
  };
957
- const f = (d, x) => {
958
- u.properties.fillColor = d || "#ff0", u.properties.MGValue = x || 1, l = d || "#ff0";
959
- }, h = (d, x) => {
960
- i || (i = !0, f(d || "#ff0", x || 1), o.on("click", a), o.getCanvas().style.cursor = "crosshair");
961
- }, a = () => {
962
- if (s = !s, s)
963
- r = C(), e.push(r), n.push(r), u.geometry.coordinates[0].length = 0, c.length = 0, o.addSource(r, { type: "geojson", data: u }), o.scrollZoom.disable(), o.dragPan.disable(), o.doubleClickZoom.disable(), o.addLayer({
964
- id: r,
965
- type: "fill",
966
- source: r,
967
- paint: {
968
- "fill-antialias": !0,
969
- "fill-color": l,
970
- "fill-opacity": 0.8,
971
- "fill-outline-color": "black"
972
- }
973
- }), o.addLayer({
974
- id: "draw" + r,
975
- type: "line",
976
- source: r,
977
- paint: {
978
- "line-width": 2,
979
- "line-color": "black"
980
- }
981
- }), o.on("mousemove", S);
982
- else {
983
- if (o.scrollZoom.enable(), o.dragPan.enable(), o.doubleClickZoom.enable(), o.removeLayer("draw" + r), o.off("mousemove", S), T(c)) {
984
- alert("落区自相交,请重画"), e.pop(), n.pop(), o.removeLayer(r), o.removeSource(r);
985
- return;
1864
+ const k = (z) => {
1865
+ switch (n.off("click", h), n.off("mousemove", Y), n.off("contextmenu", p), v(), a && (l = !0, n.scrollZoom.enable(), n.dragPan.enable(), n.doubleClickZoom.enable()), a = !0, e = z.type || "point", c = z.compute || !1, s = z, s.compute = c, y.properties = s, d.properties = s, M.properties = s, e) {
1866
+ case "point":
1867
+ r = S(), i.push(r), o.push(r), g.features.length = 0, n.addSource(r, { type: "geojson", data: g }), n.addLayer({
1868
+ id: r,
1869
+ type: "circle",
1870
+ source: r,
1871
+ paint: {
1872
+ "circle-color": s["circle-color"] || "#ff0",
1873
+ "circle-radius": s["circle-radius"] || 5,
1874
+ "circle-stroke-color": s["circle-stroke-color"] || "#000",
1875
+ "circle-stroke-width": s["circle-stroke-width"] || 2
1876
+ }
1877
+ });
1878
+ break;
1879
+ }
1880
+ n.on("click", h), n.getCanvas().style.cursor = "crosshair";
1881
+ }, L = (z) => {
1882
+ g.features.push({
1883
+ type: "Feature",
1884
+ properties: s,
1885
+ geometry: { type: "Point", coordinates: z.lngLat.toArray() }
1886
+ }), n.getSource(r).setData(JSON.parse(JSON.stringify(g)));
1887
+ }, D = (z) => {
1888
+ l && (r = S(), i.push(r), o.push(r), y.geometry.coordinates.length = 0, g.features.length = 0, n.addSource(r, { type: "geojson", data: y }), n.addSource(r + "text", { type: "geojson", data: g }), n.addLayer({
1889
+ id: r,
1890
+ type: "line",
1891
+ source: r,
1892
+ layout: {
1893
+ "line-join": "round",
1894
+ "line-cap": "round"
1895
+ },
1896
+ paint: {
1897
+ "line-color": "#ff0",
1898
+ "line-width": 4
1899
+ }
1900
+ }), n.addLayer({
1901
+ id: r + "point",
1902
+ type: "circle",
1903
+ source: r,
1904
+ paint: {
1905
+ "circle-color": s["circle-color"] || "#ff0",
1906
+ "circle-radius": s["circle-radius"] || 5,
1907
+ "circle-stroke-color": s["circle-stroke-color"] || "#000",
1908
+ "circle-stroke-width": s["circle-stroke-width"] || 2
1909
+ }
1910
+ }), n.addLayer({
1911
+ id: r + "text",
1912
+ type: "symbol",
1913
+ source: r + "text",
1914
+ layout: {
1915
+ // 'symbol-placement' :'line-center',
1916
+ "text-field": ["get", "distance"],
1917
+ "text-allow-overlap": !0,
1918
+ "text-anchor": "bottom",
1919
+ "text-overlap": "always",
1920
+ visibility: c ? "visible" : "none"
1921
+ }
1922
+ }), l = !1, n.on("mousemove", Y), n.on("contextmenu", p)), y.geometry.coordinates.push(z.lngLat.toArray()), n.getSource(r).setData(y), g.features.push({
1923
+ type: "Feature",
1924
+ properties: { name: 0 },
1925
+ geometry: { type: "Point", coordinates: z.lngLat.toArray() }
1926
+ }), n.getSource(r + "text").setData(g);
1927
+ }, O = (z) => {
1928
+ l && (r = S(), i.push(r), o.push(r), d.geometry.coordinates.length = 0, d.geometry.coordinates[0] = [], n.addSource(r, { type: "geojson", data: d }), n.addSource(r + "area", { type: "geojson", data: M }), n.addLayer({
1929
+ id: r,
1930
+ type: "fill",
1931
+ source: r,
1932
+ paint: {
1933
+ "fill-antialias": !1,
1934
+ "fill-color": s.fillColor || "#ff0",
1935
+ "fill-opacity": 0.8
1936
+ // 'fill-outline-color': 'black',
1937
+ }
1938
+ }), n.addLayer({
1939
+ id: r + "outline",
1940
+ type: "line",
1941
+ source: r,
1942
+ paint: {
1943
+ "line-width": 2,
1944
+ "line-color": "black"
1945
+ // 'line-translate-anchor':'viewport'
1946
+ },
1947
+ layout: {
1948
+ "line-cap": "round",
1949
+ "line-join": "round"
1950
+ }
1951
+ }), n.addLayer({
1952
+ id: r + "point",
1953
+ type: "circle",
1954
+ source: r,
1955
+ paint: {
1956
+ "circle-color": s["circle-color"] || "#ff0",
1957
+ "circle-radius": s["circle-radius"] || 5,
1958
+ "circle-stroke-color": s["circle-stroke-color"] || "#000",
1959
+ "circle-stroke-width": s["circle-stroke-width"] || 2
1960
+ }
1961
+ }), n.addLayer({
1962
+ id: r + "area",
1963
+ type: "symbol",
1964
+ source: r + "area",
1965
+ layout: {
1966
+ "text-field": ["get", "area"],
1967
+ // 'text-field': '456',
1968
+ "text-allow-overlap": !0,
1969
+ // 'text-anchor': 'bottom',
1970
+ "text-overlap": "always",
1971
+ visibility: c ? "visible" : "none"
1972
+ }
1973
+ }), l = !1, n.on("mousemove", Y), n.on("contextmenu", p)), d.geometry.coordinates[0].length >= 3 && d.geometry.coordinates[0].pop(), d.geometry.coordinates[0].push(z.lngLat.toArray()), d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]), n.getSource(r).setData(d);
1974
+ }, u = (z) => {
1975
+ l && (r = S(), i.push(r), o.push(r), d.geometry.coordinates.length = 0, d.geometry.coordinates[0] = [], f.length = 0, n.addSource(r, { type: "geojson", data: d }), n.addSource(r + "area", { type: "geojson", data: M }), n.addLayer({
1976
+ id: r,
1977
+ type: "fill",
1978
+ source: r,
1979
+ paint: {
1980
+ "fill-antialias": !1,
1981
+ "fill-color": s.fillColor || "#ff0",
1982
+ "fill-opacity": 0.8
986
1983
  }
987
- const d = [...c.slice(c.length / 5), ...c.slice(0, c.length / 5)], m = new E(d).getLUT(100);
988
- u.geometry.coordinates[0].length = 0;
989
- for (let w = 0; w < m.length; w++) {
990
- const b = o.unproject(m[w]);
991
- u.geometry.coordinates[0].push(b.toArray());
1984
+ }), n.addLayer({
1985
+ id: r + "outline",
1986
+ type: "line",
1987
+ source: r,
1988
+ paint: {
1989
+ "line-width": 2,
1990
+ "line-color": "black"
1991
+ // 'line-translate-anchor':'viewport'
1992
+ },
1993
+ layout: {
1994
+ "line-cap": "round",
1995
+ "line-join": "round"
992
1996
  }
993
- const v = o.getSource(r);
994
- v !== void 0 && v.setData(JSON.parse(JSON.stringify(u)));
1997
+ }), n.addLayer({
1998
+ id: r + "area",
1999
+ type: "symbol",
2000
+ source: r + "area",
2001
+ layout: {
2002
+ "text-field": ["get", "area"],
2003
+ // 'text-field': '456',
2004
+ "text-allow-overlap": !0,
2005
+ // 'text-anchor': 'bottom',
2006
+ "text-overlap": "always",
2007
+ visibility: c ? "visible" : "none"
2008
+ }
2009
+ }), l = !1, d.geometry.coordinates[0].push(z.lngLat.toArray()), n.getSource(r).setData(d), n.on("mousemove", Y), n.on("contextmenu", p), n.scrollZoom.disable(), n.dragPan.disable(), n.doubleClickZoom.disable());
2010
+ }, h = (z) => {
2011
+ switch (e) {
2012
+ case "point":
2013
+ L(z);
2014
+ break;
2015
+ case "line":
2016
+ D(z);
2017
+ break;
2018
+ case "polygon":
2019
+ O(z);
2020
+ break;
2021
+ case "free":
2022
+ u(z);
2023
+ break;
2024
+ }
2025
+ }, m = (z) => {
2026
+ switch (e) {
2027
+ case "line":
2028
+ if (y.geometry.coordinates.length) {
2029
+ y.geometry.coordinates.length == 1 && y.geometry.coordinates.push(z.lngLat.toArray()), y.geometry.coordinates[y.geometry.coordinates.length - 1] = z.lngLat.toArray(), n.getSource(r).setData(y);
2030
+ const A = y.geometry.coordinates[y.geometry.coordinates.length - 2], $ = y.geometry.coordinates[y.geometry.coordinates.length - 1], J = ae(A, $, { units: "kilometers" }), T = je(ht(A), ht($)), B = g.features[g.features.length - 1];
2031
+ B.properties.distance = _t(J, 4) + "km", B.geometry.coordinates = T.geometry.coordinates, n.getSource(r + "text").setData(JSON.parse(JSON.stringify(g)));
2032
+ }
2033
+ break;
2034
+ case "polygon":
2035
+ const F = d.geometry.coordinates[0].length;
2036
+ if (F) {
2037
+ F == 2 ? d.geometry.coordinates[0][F - 1] = z.lngLat.toArray() : d.geometry.coordinates[0][F - 2] = z.lngLat.toArray();
2038
+ const C = Ct(d) / 1e6;
2039
+ if (F >= 4) {
2040
+ var E = Dt(d.geometry.coordinates), q = Ft(E);
2041
+ M.geometry.coordinates = q.geometry.coordinates, M.properties.area = _t(C, 2) + "km²";
2042
+ }
2043
+ n.getSource(r).setData(d), n.getSource(r + "area").setData(M);
2044
+ }
2045
+ break;
2046
+ case "free":
2047
+ const P = d.geometry.coordinates[0].length;
2048
+ if (P) {
2049
+ f.push(z.point), d.geometry.coordinates[0].length != 1 && d.geometry.coordinates[0].pop(), d.geometry.coordinates[0].push(z.lngLat.toArray()), d.geometry.coordinates[0].push(d.geometry.coordinates[0][0]);
2050
+ const C = Ct(d) / 1e6;
2051
+ if (P >= 4) {
2052
+ var E = Dt(d.geometry.coordinates), q = Ft(E);
2053
+ M.geometry.coordinates = q.geometry.coordinates, M.properties.area = _t(C, 2) + "km²";
2054
+ }
2055
+ n.getSource(r).setData(d), n.getSource(r + "area").setData(M);
2056
+ }
2057
+ break;
995
2058
  }
996
- }, p = (d) => {
997
- c.push(d.point), u.geometry.coordinates[0].push(d.lngLat.toArray());
998
- const x = o.getSource(r);
999
- x !== void 0 && x.setData(u);
1000
- }, g = () => {
1001
- const d = n.slice(0, e.length), x = [];
1002
- return d.forEach((m) => {
1003
- const v = o.getSource(m);
1004
- x.push(v.serialize().data);
1005
- }), x;
1006
- }, _ = () => {
1007
- e.forEach((d) => o.removeLayer(d)), n.forEach((d) => o.removeSource(d)), e.length = 0, n.length = 0, o.off("click", a), o.getCanvas().style.cursor = "pointer", i = !1;
1008
- }, C = () => {
1009
- let d = (/* @__PURE__ */ new Date()).getTime();
1010
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(m) {
1011
- const v = (d + Math.random() * 16) % 16 | 0;
1012
- return d = Math.floor(d / 16), (m === "x" ? v : v & 3 | 8).toString(16);
2059
+ }, p = (z) => {
2060
+ z.preventDefault(), n.off("mousemove", Y), n.off("contextmenu", p), l = !0, n.scrollZoom.enable(), n.dragPan.enable(), n.doubleClickZoom.enable();
2061
+ const E = n.getSource(r);
2062
+ switch (e) {
2063
+ case "line":
2064
+ y.geometry.coordinates.length && E.setData(JSON.parse(JSON.stringify(y)));
2065
+ break;
2066
+ case "polygon":
2067
+ d.geometry.coordinates[0].length && E.setData(JSON.parse(JSON.stringify(d)));
2068
+ break;
2069
+ case "free":
2070
+ if (d.geometry.coordinates[0].length) {
2071
+ if (E.setData(JSON.parse(JSON.stringify(d))), R(f)) {
2072
+ alert("落区自相交,请重画"), i.pop(), o.pop(), n.removeLayer(r), n.removeLayer(r + "outline"), n.removeLayer(r + "area"), n.removeSource(r), n.removeSource(r + "area");
2073
+ return;
2074
+ }
2075
+ const q = [...f.slice(f.length / 5), ...f.slice(0, f.length / 5)], P = new U(q).getLUT();
2076
+ P.push(P[0]), d.geometry.coordinates[0].length = 0;
2077
+ for (let $ = 0; $ < P.length; $++) {
2078
+ const J = n.unproject(P[$]);
2079
+ d.geometry.coordinates[0].push(J.toArray());
2080
+ }
2081
+ E.setData(JSON.parse(JSON.stringify(d)));
2082
+ const C = Ct(d) / 1e6;
2083
+ M.properties.area = _t(C, 2) + "km²", n.getSource(r + "area").setData(JSON.parse(JSON.stringify(M)));
2084
+ }
2085
+ break;
2086
+ }
2087
+ }, w = () => {
2088
+ const z = o.slice(0, i.length), E = [];
2089
+ return z.forEach((q) => {
2090
+ const F = n.getSource(q);
2091
+ E.push(F.serialize().data);
2092
+ }), E;
2093
+ }, x = () => {
2094
+ i.forEach((z) => {
2095
+ n.removeLayer(z), n.getLayer(z + "outline") && n.removeLayer(z + "outline"), n.getLayer(z + "point") && n.removeLayer(z + "point"), n.getLayer(z + "area") && n.removeLayer(z + "area"), n.getLayer(z + "text") && n.removeLayer(z + "text");
2096
+ }), o.forEach((z) => {
2097
+ n.removeSource(z), n.getSource(z + "text") && n.removeSource(z + "text"), n.getSource(z + "area") && n.removeSource(z + "area");
2098
+ }), i.length = 0, o.length = 0, n.off("click", h), n.off("mousemove", Y), n.off("contextmenu", p), n.getCanvas().style.cursor = "pointer", a = !1, v();
2099
+ }, v = () => {
2100
+ g.features.length = 0, y.geometry.coordinates.length = 0, d.geometry.coordinates.length = 0, d.geometry.coordinates[0] = [], M.geometry.coordinates.length = 0;
2101
+ }, S = () => {
2102
+ let z = (/* @__PURE__ */ new Date()).getTime();
2103
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(q) {
2104
+ const F = (z + Math.random() * 16) % 16 | 0;
2105
+ return z = Math.floor(z / 16), (q === "x" ? F : F & 3 | 8).toString(16);
1013
2106
  });
1014
- }, S = ((d, x) => {
1015
- let m = 0;
1016
- return function(...v) {
1017
- const w = (/* @__PURE__ */ new Date()).getTime();
1018
- w - m < x || (m = w, d(...v));
2107
+ }, Y = ((z, E) => {
2108
+ let q = 0;
2109
+ return function(...F) {
2110
+ const P = (/* @__PURE__ */ new Date()).getTime();
2111
+ P - q < E || (q = P, z(...F));
1019
2112
  };
1020
- })(p, 20), j = () => {
1021
- e.length && (o.removeLayer(e[e.length - 1]), e.pop());
1022
- }, O = () => {
1023
- if (n.length) {
1024
- const d = e.length - n.length, x = n.slice(d);
1025
- if (console.log(x), d !== 0 && x.length) {
1026
- const m = o.getSource(x[0]);
1027
- console.log(m, "source");
1028
- let v = "";
1029
- m && (v = m.serialize().data.valueOf().properties.fillColor), o.getLayer(x[0]) || (e.push(x[0]), o.addLayer({
1030
- id: x[0],
2113
+ })(m, 20), b = () => {
2114
+ e == "free" && i.length && (n.removeLayer(i[i.length - 1]), n.removeLayer(i[i.length - 1] + "outline"), n.getLayer(i[i.length - 1] + "area") && n.removeLayer(i[i.length - 1] + "area"), i.pop());
2115
+ }, N = () => {
2116
+ if (e == "free" && o.length) {
2117
+ const z = i.length - o.length, E = o.slice(z);
2118
+ if (z !== 0 && E.length) {
2119
+ const P = n.getSource(E[0]).serialize().data.valueOf();
2120
+ n.getLayer(E[0]) || (i.push(E[0]), n.addLayer({
2121
+ id: E[0],
1031
2122
  type: "fill",
1032
- source: x[0],
2123
+ source: E[0],
1033
2124
  paint: {
1034
- "fill-color": v,
2125
+ "fill-color": P.properties.fillColor || "#ff0",
1035
2126
  "fill-opacity": 0.8,
1036
2127
  "fill-outline-color": "black"
1037
2128
  }
2129
+ }), n.addLayer({
2130
+ id: E[0] + "outline",
2131
+ type: "line",
2132
+ source: E[0],
2133
+ paint: {
2134
+ "line-width": 2,
2135
+ "line-color": "black"
2136
+ }
2137
+ }), n.addLayer({
2138
+ id: E[0] + "area",
2139
+ type: "symbol",
2140
+ source: E[0] + "area",
2141
+ layout: {
2142
+ "text-field": ["get", "area"],
2143
+ // 'text-field': '456',
2144
+ "text-allow-overlap": !0,
2145
+ // 'text-anchor': 'bottom',
2146
+ "text-overlap": "always",
2147
+ visibility: P.properties.compute ? "visible" : "none"
2148
+ }
1038
2149
  }));
1039
2150
  }
1040
2151
  }
1041
- }, T = (d) => {
1042
- let x = !1, m = d, v = [], w = m.length - 1;
1043
- for (let k = 0; k < w; k++) {
1044
- let q = m[k], M = m[k + 1];
1045
- (q.x != M.x || q.y != M.y) && v.push(q);
2152
+ }, R = (z) => {
2153
+ let E = !1, q = z, F = [], P = q.length - 1;
2154
+ for (let A = 0; A < P; A++) {
2155
+ let $ = q[A], J = q[A + 1];
2156
+ ($.x != J.x || $.y != J.y) && F.push($);
1046
2157
  }
1047
- let b = v.length - 1;
1048
- for (let k = 0; k < b; k++) {
1049
- let q = v[k], M = v[k + 1];
1050
- for (let I = k + 2; I < b; I++) {
1051
- let W = v[I], D = v[I + 1], Y = z(q, M, W, D);
1052
- if (Y == null && M.x == D.x && M.y == D.y && (Y = { x: M.x, y: M.y }), Y != null) {
1053
- x = !0;
2158
+ let C = F.length - 1;
2159
+ for (let A = 0; A < C; A++) {
2160
+ let $ = F[A], J = F[A + 1];
2161
+ for (let T = A + 2; T < C; T++) {
2162
+ let B = F[T], G = F[T + 1], I = H($, J, B, G);
2163
+ if (I == null && J.x == G.x && J.y == G.y && (I = { x: J.x, y: J.y }), I != null) {
2164
+ E = !0;
1054
2165
  break;
1055
2166
  }
1056
2167
  }
1057
- if (x)
2168
+ if (E)
1058
2169
  break;
1059
2170
  }
1060
- return x;
1061
- }, z = (d, x, m, v) => {
1062
- var w = null, b = (d.x - m.x) * (x.y - m.y) - (d.y - m.y) * (x.x - m.x), k = (d.x - v.x) * (x.y - v.y) - (d.y - v.y) * (x.x - v.x);
1063
- if (b * k >= 0)
1064
- return w;
1065
- var q = (m.x - d.x) * (v.y - d.y) - (m.y - d.y) * (v.x - d.x), M = q + b - k;
1066
- if (q * M >= 0)
1067
- return w;
1068
- var I = q / (k - b), W = I * (x.x - d.x), D = I * (x.y - d.y);
1069
- return w = { x: d.x + W, y: d.y + D }, w;
2171
+ return E;
2172
+ }, H = (z, E, q, F) => {
2173
+ var P = null, C = (z.x - q.x) * (E.y - q.y) - (z.y - q.y) * (E.x - q.x), A = (z.x - F.x) * (E.y - F.y) - (z.y - F.y) * (E.x - F.x);
2174
+ if (C * A >= 0)
2175
+ return P;
2176
+ var $ = (q.x - z.x) * (F.y - z.y) - (q.y - z.y) * (F.x - z.x), J = $ + C - A;
2177
+ if ($ * J >= 0)
2178
+ return P;
2179
+ var T = $ / (A - C), B = T * (E.x - z.x), G = T * (E.y - z.y);
2180
+ return P = { x: z.x + B, y: z.y + G }, P;
1070
2181
  };
1071
- return { isStart: i, start: h, getFeatures: g, clear: _, revoke: j, redo: O, setColor: f };
2182
+ return { isDraw: a, start: k, getFeatures: w, clear: x, revoke: b, redo: N };
1072
2183
  }
1073
- const ut = { drawFreehand: lt };
1074
2184
  export {
1075
- ut as default
2185
+ Ve as draw
1076
2186
  };