@watergis/maplibre-gl-terradraw 1.3.5 → 1.3.6

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.
@@ -1,6 +1,6 @@
1
- var Te = Object.defineProperty;
2
- var Ae = (s, t, e) => t in s ? Te(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var k = (s, t, e) => Ae(s, typeof t != "symbol" ? t + "" : t, e);
1
+ var Ve = Object.defineProperty;
2
+ var Ue = (s, t, e) => t in s ? Ve(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var k = (s, t, e) => Ue(s, typeof t != "symbol" ? t + "" : t, e);
4
4
  import "maplibre-gl";
5
5
  function b() {
6
6
  return b = Object.assign ? Object.assign.bind() : function(s) {
@@ -15,16 +15,16 @@ var I;
15
15
  (function(s) {
16
16
  s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
17
17
  })(I || (I = {}));
18
- const U = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, V = "edited", st = "closingPoint", Ot = "snappingPoint";
18
+ const U = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, V = "edited", st = "closingPoint", Dt = "snappingPoint";
19
19
  function bt(s) {
20
20
  return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
21
21
  }
22
- function Vt(s) {
22
+ function Ut(s) {
23
23
  return !!function(t) {
24
24
  return typeof t == "number" && !isNaN(new Date(t).valueOf());
25
25
  }(s);
26
26
  }
27
- const Ve = "Feature mode property does not match the mode being added to";
27
+ const Re = "Feature mode property does not match the mode being added to";
28
28
  var $;
29
29
  (function(s) {
30
30
  s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
@@ -94,7 +94,7 @@ class N {
94
94
  }
95
95
  validateModeFeature(t, e) {
96
96
  const i = this.performFeatureValidation(t);
97
- return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Ve } : e(t) : { valid: !1, reason: i.reason };
97
+ return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Re } : e(t) : { valid: !1, reason: i.reason };
98
98
  }
99
99
  onFinish(t, e) {
100
100
  }
@@ -126,7 +126,7 @@ class N {
126
126
  return t === void 0 ? e : typeof t == "function" ? t(i) : t;
127
127
  }
128
128
  }
129
- class Ue extends N {
129
+ class ze extends N {
130
130
  constructor(...t) {
131
131
  super(...t), this.type = $.Select;
132
132
  }
@@ -135,11 +135,11 @@ function A(s, t) {
135
135
  const e = (d) => d * Math.PI / 180, i = e(s[1]), o = e(s[0]), r = e(t[1]), n = r - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(r) * Math.sin(a / 2) * Math.sin(a / 2);
136
136
  return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
137
137
  }
138
- const ue = 63710088e-1;
138
+ const ge = 63710088e-1;
139
139
  function O(s) {
140
140
  return s % 360 * Math.PI / 180;
141
141
  }
142
- function pe(s) {
142
+ function ye(s) {
143
143
  return s / 6371.0088;
144
144
  }
145
145
  function R(s) {
@@ -149,20 +149,20 @@ function w(s, t = 9) {
149
149
  const e = Math.pow(10, t);
150
150
  return Math.round(s * e) / e;
151
151
  }
152
- const Ut = 57.29577951308232, Rt = 0.017453292519943295, ft = 6378137, x = (s, t) => ({ x: s === 0 ? 0 : s * Rt * ft, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Rt / 2)) * ft }), j = (s, t) => ({ lng: s === 0 ? 0 : Ut * (s / ft), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ft)) - Math.PI / 2) * Ut });
153
- function Re(s, t, e) {
154
- const i = O(s[0]), o = O(s[1]), r = O(e), n = pe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
152
+ const Rt = 57.29577951308232, zt = 0.017453292519943295, ft = 6378137, x = (s, t) => ({ x: s === 0 ? 0 : s * zt * ft, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * zt / 2)) * ft }), j = (s, t) => ({ lng: s === 0 ? 0 : Rt * (s / ft), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / ft)) - Math.PI / 2) * Rt });
153
+ function Xe(s, t, e) {
154
+ const i = O(s[0]), o = O(s[1]), r = O(e), n = ye(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
155
155
  return [R(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), R(a)];
156
156
  }
157
- function zt(s) {
157
+ function Xt(s) {
158
158
  const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, r = [];
159
159
  for (let n = 0; n < o; n++) {
160
- const a = Re(t, e, -360 * n / o);
160
+ const a = Xe(t, e, -360 * n / o);
161
161
  r.push([w(a[0], i), w(a[1], i)]);
162
162
  }
163
163
  return r.push(r[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [r] }, properties: {} };
164
164
  }
165
- function _t(s) {
165
+ function Lt(s) {
166
166
  let t;
167
167
  if (s.geometry.type === "Polygon") t = s.geometry.coordinates;
168
168
  else {
@@ -176,51 +176,51 @@ function _t(s) {
176
176
  return r < 0 || r > 1;
177
177
  }
178
178
  function o(r, n, a, l) {
179
- const d = t[r][n], h = t[r][n + 1], c = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
180
- if (ht(v, m) || ht(v, C) || ht(f, m) || ht(C, m)) return null;
179
+ const d = t[r][n], c = t[r][n + 1], h = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
180
+ if (ct(v, m) || ct(v, C) || ct(f, m) || ct(C, m)) return null;
181
181
  const P = v[0], S = v[1], M = f[0], F = f[1], D = m[0], G = m[1], _ = C[0], B = C[1], z = (P - M) * (G - B) - (S - F) * (D - _);
182
182
  return z === 0 ? null : [((P * F - S * M) * (D - _) - (P - M) * (D * B - G * _)) / z, ((P * F - S * M) * (G - B) - (S - F) * (D * B - G * _)) / z];
183
- }(d, h, c, u);
183
+ }(d, c, h, u);
184
184
  if (p === null) return;
185
185
  let y, g;
186
- y = h[0] !== d[0] ? (p[0] - d[0]) / (h[0] - d[0]) : (p[1] - d[1]) / (h[1] - d[1]), g = u[0] !== c[0] ? (p[0] - c[0]) / (u[0] - c[0]) : (p[1] - c[1]) / (u[1] - c[1]), i(y) || i(g) || (p.toString(), e.push(p));
186
+ y = c[0] !== d[0] ? (p[0] - d[0]) / (c[0] - d[0]) : (p[1] - d[1]) / (c[1] - d[1]), g = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(y) || i(g) || (p.toString(), e.push(p));
187
187
  }
188
188
  }
189
- function ht(s, t) {
189
+ function ct(s, t) {
190
190
  return s[0] === t[0] && s[1] === t[1];
191
191
  }
192
192
  function St(s, t) {
193
- return Xt(s[0]) <= t && Xt(s[1]) <= t;
193
+ return Kt(s[0]) <= t && Kt(s[1]) <= t;
194
194
  }
195
- function Lt(s) {
195
+ function kt(s) {
196
196
  return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (e = s[0]) >= -180 && e <= 180 && (t = s[1]) >= -90 && t <= 90;
197
197
  var t, e;
198
198
  }
199
- function Xt(s) {
199
+ function Kt(s) {
200
200
  let t = 1, e = 0;
201
201
  for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
202
202
  return e;
203
203
  }
204
- const ze = "Feature has holes", Xe = "Feature has less than 4 coordinates", Ke = "Feature has invalid coordinates", Ye = "Feature coordinates are not closed";
204
+ const Ke = "Feature has holes", Ye = "Feature has less than 4 coordinates", $e = "Feature has invalid coordinates", He = "Feature coordinates are not closed";
205
205
  function xt(s, t) {
206
206
  if (s.geometry.type !== "Polygon") return { valid: !1, reason: "Feature is not a Polygon" };
207
- if (s.geometry.coordinates.length !== 1) return { valid: !1, reason: ze };
208
- if (s.geometry.coordinates[0].length < 4) return { valid: !1, reason: Xe };
207
+ if (s.geometry.coordinates.length !== 1) return { valid: !1, reason: Ke };
208
+ if (s.geometry.coordinates[0].length < 4) return { valid: !1, reason: Ye };
209
209
  for (let o = 0; o < s.geometry.coordinates[0].length; o++) {
210
- if (!Lt(s.geometry.coordinates[0][o])) return { valid: !1, reason: Ke };
210
+ if (!kt(s.geometry.coordinates[0][o])) return { valid: !1, reason: $e };
211
211
  if (!St(s.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
212
212
  }
213
- return (e = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: Ye } : { valid: !0 };
213
+ return (e = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: He } : { valid: !0 };
214
214
  var e, i;
215
215
  }
216
216
  function lt(s, t) {
217
217
  const e = xt(s, t);
218
- return e.valid ? _t(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
218
+ return e.valid ? Lt(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
219
219
  }
220
- const $e = { cancel: "Escape", finish: "Enter" }, He = { start: "crosshair" };
221
- let ge = class extends N {
220
+ const qe = { cancel: "Escape", finish: "Enter" }, Je = { start: "crosshair" };
221
+ let fe = class extends N {
222
222
  constructor(t) {
223
- super(t, !0), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = $e, this.cursors = He, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1, this.updateOptions(t);
223
+ super(t, !0), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = qe, this.cursors = Je, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1, this.updateOptions(t);
224
224
  }
225
225
  updateOptions(t) {
226
226
  super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.startingRadiusKilometers && (this.startingRadiusKilometers = t.startingRadiusKilometers);
@@ -243,7 +243,7 @@ let ge = class extends N {
243
243
  onClick(t) {
244
244
  if (this.clickCount === 0) {
245
245
  this.center = [t.lng, t.lat];
246
- const e = zt({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
246
+ const e = Xt({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers } }]);
247
247
  this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
248
248
  } else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
249
249
  }
@@ -284,20 +284,20 @@ let ge = class extends N {
284
284
  const o = function(r, n) {
285
285
  const a = 1e3 * A(r, n);
286
286
  if (a === 0) return 1;
287
- const { x: l, y: d } = x(r[0], r[1]), { x: h, y: c } = x(n[0], n[1]);
288
- return Math.sqrt(Math.pow(h - l, 2) + Math.pow(c - d, 2)) / a;
287
+ const { x: l, y: d } = x(r[0], r[1]), { x: c, y: h } = x(n[0], n[1]);
288
+ return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
289
289
  }(this.center, [t.lng, t.lat]);
290
290
  i = function(r) {
291
- const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64, h = 1e3 * a, [c, u] = n, { x: p, y } = x(c, u), g = [];
291
+ const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y } = x(h, u), g = [];
292
292
  for (let v = 0; v < d; v++) {
293
- const f = 360 * v / d * Math.PI / 180, m = h * Math.cos(f), C = h * Math.sin(f), [P, S] = [p + m, y + C], { lng: M, lat: F } = j(P, S);
293
+ const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, S] = [p + m, y + C], { lng: M, lat: F } = j(P, S);
294
294
  g.push([w(M, l), w(F, l)]);
295
295
  }
296
296
  return g.push(g[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [g] }, properties: {} };
297
297
  }({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
298
298
  } else {
299
299
  if (this.projection !== "globe") throw new Error("Invalid projection");
300
- i = zt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
300
+ i = Xt({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
301
301
  }
302
302
  if (this.validate && !this.validate({ type: "Feature", id: this.currentCircleId, geometry: i.geometry, properties: { radiusKilometers: e } }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Provisional }).valid) return;
303
303
  this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
@@ -319,10 +319,10 @@ function dt(s) {
319
319
  return o < 0;
320
320
  }(s)) return { type: "Polygon", coordinates: [s.coordinates[0].reverse()] };
321
321
  }
322
- const qe = { cancel: "Escape", finish: "Enter" }, Je = { start: "crosshair", close: "pointer" };
323
- class ye extends N {
322
+ const Ze = { cancel: "Escape", finish: "Enter" }, Qe = { start: "crosshair", close: "pointer" };
323
+ class me extends N {
324
324
  constructor(t) {
325
- super(t, !0), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = qe, this.cursors = Je, this.preventPointsNearClose = !0, this.autoClose = !1, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1, this.updateOptions(t);
325
+ super(t, !0), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = Ze, this.cursors = Qe, this.preventPointsNearClose = !0, this.autoClose = !1, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1, this.updateOptions(t);
326
326
  }
327
327
  updateOptions(t) {
328
328
  super.updateOptions(t), t != null && t.minDistance && (this.minDistance = t.minDistance), (t == null ? void 0 : t.preventPointsNearClose) !== void 0 && (this.preventPointsNearClose = t.preventPointsNearClose), (t == null ? void 0 : t.autoClose) !== void 0 && (this.autoClose = t.autoClose), t != null && t.autoCloseTimeout && (this.autoCloseTimeout = t.autoCloseTimeout), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors));
@@ -348,8 +348,8 @@ class ye extends N {
348
348
  }
349
349
  onMouseMove(t) {
350
350
  if (this.currentId === void 0 || this.startingClick === !1) return;
351
- const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, r] = e.coordinates[0][i], { x: n, y: a } = this.project(o, r), l = E({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, h] = e.coordinates[0][0], { x: c, y: u } = this.project(d, h);
352
- if (E({ x: c, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
351
+ const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, r] = e.coordinates[0][i], { x: n, y: a } = this.project(o, r), l = E({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
352
+ if (E({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
353
353
  if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
354
354
  this.preventNewFeature = !1;
355
355
  }, this.autoCloseTimeout), this.close()), this.setCursor(this.cursors.close), this.preventPointsNearClose) return;
@@ -400,7 +400,7 @@ class W {
400
400
  this.store = void 0, this.mode = void 0, this.project = void 0, this.unproject = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.projection = void 0, this.store = t, this.mode = e, this.project = i, this.unproject = o, this.pointerDistance = r, this.coordinatePrecision = n, this.projection = a;
401
401
  }
402
402
  }
403
- function fe({ unproject: s, point: t, pointerDistance: e }) {
403
+ function ve({ unproject: s, point: t, pointerDistance: e }) {
404
404
  const i = e / 2, { x: o, y: r } = t;
405
405
  return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[s(o - i, r - i), s(o + i, r - i), s(o + i, r + i), s(o - i, r + i), s(o - i, r - i)].map((n) => [n.lng, n.lat])] } };
406
406
  }
@@ -410,7 +410,7 @@ class rt extends W {
410
410
  }
411
411
  create(t) {
412
412
  const { containerX: e, containerY: i } = t;
413
- return fe({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
413
+ return ve({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
414
414
  }
415
415
  }
416
416
  class nt extends W {
@@ -422,7 +422,7 @@ class nt extends W {
422
422
  return E({ x: i, y: o }, { x: t.containerX, y: t.containerY });
423
423
  }
424
424
  }
425
- let Dt = class extends W {
425
+ let _t = class extends W {
426
426
  constructor(t, e, i) {
427
427
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
428
428
  }
@@ -436,21 +436,21 @@ let Dt = class extends W {
436
436
  a = n.geometry.coordinates;
437
437
  }
438
438
  a.forEach((l, d) => {
439
- const h = this.pixelDistance.measure(t, l);
440
- h < r.minDist && h < this.pointerDistance && (r.coordinate = l, r.minDist = h, r.featureId = n.id, r.featureCoordinateIndex = d);
439
+ const c = this.pixelDistance.measure(t, l);
440
+ c < r.minDist && c < this.pointerDistance && (r.coordinate = l, r.minDist = c, r.featureId = n.id, r.featureCoordinateIndex = d);
441
441
  });
442
442
  }), r;
443
443
  }
444
444
  };
445
- function Kt(s, t, e) {
446
- const i = O(s[0]), o = O(s[1]), r = O(e), n = pe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
445
+ function Yt(s, t, e) {
446
+ const i = O(s[0]), o = O(s[1]), r = O(e), n = ye(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
447
447
  return [R(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), R(a)];
448
448
  }
449
449
  function at({ x: s, y: t }, e, i) {
450
450
  const o = O(i);
451
451
  return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
452
452
  }
453
- function Yt(s, t) {
453
+ function $t(s, t) {
454
454
  const e = O(s[0]), i = O(t[0]), o = O(s[1]), r = O(t[1]), n = Math.sin(i - e) * Math.cos(r), a = Math.cos(o) * Math.sin(r) - Math.sin(o) * Math.cos(r) * Math.cos(i - e);
455
455
  return R(Math.atan2(n, a));
456
456
  }
@@ -461,29 +461,29 @@ function T({ x: s, y: t }, { x: e, y: i }) {
461
461
  function Y(s) {
462
462
  return (s + 360) % 360;
463
463
  }
464
- function Ze(s, t, e) {
464
+ function ti(s, t, e) {
465
465
  const i = [], o = s.length;
466
466
  let r, n, a, l = 0;
467
- for (let h = 0; h < s.length && !(t >= l && h === s.length - 1); h++) {
467
+ for (let c = 0; c < s.length && !(t >= l && c === s.length - 1); c++) {
468
468
  if (l > t && i.length === 0) {
469
- if (r = t - l, !r) return i.push(s[h]), i;
470
- n = Yt(s[h], s[h - 1]) - 180, a = Kt(s[h], r, n), i.push(a);
469
+ if (r = t - l, !r) return i.push(s[c]), i;
470
+ n = $t(s[c], s[c - 1]) - 180, a = Yt(s[c], r, n), i.push(a);
471
471
  }
472
- if (l >= e) return r = e - l, r ? (n = Yt(s[h], s[h - 1]) - 180, a = Kt(s[h], r, n), i.push(a), i) : (i.push(s[h]), i);
473
- if (l >= t && i.push(s[h]), h === s.length - 1) return i;
474
- l += A(s[h], s[h + 1]);
472
+ if (l >= e) return r = e - l, r ? (n = $t(s[c], s[c - 1]) - 180, a = Yt(s[c], r, n), i.push(a), i) : (i.push(s[c]), i);
473
+ if (l >= t && i.push(s[c]), c === s.length - 1) return i;
474
+ l += A(s[c], s[c + 1]);
475
475
  }
476
476
  if (l < t && s.length === o) throw new Error("Start position is beyond line");
477
477
  const d = s[s.length - 1];
478
478
  return [d, d];
479
479
  }
480
- function ct(s) {
480
+ function ht(s) {
481
481
  return s * (Math.PI / 180);
482
482
  }
483
- function $t(s) {
483
+ function Ht(s) {
484
484
  return s * (180 / Math.PI);
485
485
  }
486
- class Qe extends W {
486
+ class ei extends W {
487
487
  constructor(t) {
488
488
  super(t), this.config = void 0, this.config = t;
489
489
  }
@@ -496,8 +496,8 @@ class Qe extends W {
496
496
  Number.isInteger(n) || (n = Math.floor(n) + 1);
497
497
  const a = [];
498
498
  for (let d = 0; d < n; d++) {
499
- const h = Ze(o, i * d, i * (d + 1));
500
- a.push(h);
499
+ const c = ti(o, i * d, i * (d + 1));
500
+ a.push(c);
501
501
  }
502
502
  const l = [];
503
503
  for (let d = 0; d < a.length; d++) l.push(a[d][1]);
@@ -505,15 +505,15 @@ class Qe extends W {
505
505
  }
506
506
  generateInsertionGeodesicCoordinates(t, e, i) {
507
507
  const o = A(t, e), r = function(n, a, l) {
508
- const d = [], h = ct(n[1]), c = ct(n[0]), u = ct(a[1]), p = ct(a[0]);
508
+ const d = [], c = ht(n[1]), h = ht(n[0]), u = ht(a[1]), p = ht(a[0]);
509
509
  l += 1;
510
- const y = 2 * Math.asin(Math.sqrt(Math.sin((u - h) / 2) ** 2 + Math.cos(h) * Math.cos(u) * Math.sin((p - c) / 2) ** 2));
510
+ const y = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
511
511
  if (y === 0 || isNaN(y)) return d;
512
512
  for (let g = 0; g <= l; g++) {
513
- const v = g / l, f = Math.sin((1 - v) * y) / Math.sin(y), m = Math.sin(v * y) / Math.sin(y), C = f * Math.cos(h) * Math.cos(c) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(h) * Math.sin(c) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(h) + m * Math.sin(u);
513
+ const v = g / l, f = Math.sin((1 - v) * y) / Math.sin(y), m = Math.sin(v * y) / Math.sin(y), C = f * Math.cos(c) * Math.cos(h) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(c) * Math.sin(h) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(c) + m * Math.sin(u);
514
514
  if (isNaN(C) || isNaN(P) || isNaN(S)) continue;
515
515
  const M = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), F = Math.atan2(P, C);
516
- isNaN(M) || isNaN(F) || d.push([$t(F), $t(M)]);
516
+ isNaN(M) || isNaN(F) || d.push([Ht(F), Ht(M)]);
517
517
  }
518
518
  return d.slice(1, -1);
519
519
  }(t, e, Math.floor(o / i));
@@ -526,23 +526,23 @@ class Qe extends W {
526
526
  function Z(s, t) {
527
527
  return s[0] === t[0] && s[1] === t[1];
528
528
  }
529
- function me(s, t) {
529
+ function Ce(s, t) {
530
530
  if (s.geometry.type !== "LineString") return { valid: !1, reason: "Feature is not a LineString" };
531
531
  if (s.geometry.coordinates.length < 2) return { valid: !1, reason: "Feature has less than 2 coordinates" };
532
532
  for (let e = 0; e < s.geometry.coordinates.length; e++) {
533
- if (!Lt(s.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
533
+ if (!kt(s.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
534
534
  if (!St(s.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
535
535
  }
536
536
  return { valid: !0 };
537
537
  }
538
- function Ht(s) {
538
+ function qt(s) {
539
539
  return Math.sqrt(Math.pow(s[0], 2) + Math.pow(s[1], 2) + Math.pow(s[2], 2));
540
540
  }
541
541
  function X(s, t) {
542
542
  const e = function(i, o) {
543
- const [r, n, a] = i, [l, d, h] = o;
544
- return r * l + n * d + a * h;
545
- }(s, t) / (Ht(s) * Ht(t));
543
+ const [r, n, a] = i, [l, d, c] = o;
544
+ return r * l + n * d + a * c;
545
+ }(s, t) / (qt(s) * qt(t));
546
546
  return Math.acos(Math.min(Math.max(e, -1), 1));
547
547
  }
548
548
  function Mt(s) {
@@ -553,19 +553,19 @@ function K(s) {
553
553
  const [t, e, i] = s, o = R(Math.asin(i));
554
554
  return [R(Math.atan2(e, t)), o];
555
555
  }
556
- function ti(s, t, e) {
557
- const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d, h, c] = function(B, z) {
558
- const [Wt, Bt, Nt] = B, [Gt, Tt, At] = z;
559
- return [Bt * At - Nt * Tt, Nt * Gt - Wt * At, Wt * Tt - Bt * Gt];
560
- }(i, o), u = h * l - c * a, p = c * n - d * l, y = d * a - h * n, g = y * h - p * c, v = u * c - y * d, f = p * d - u * h, m = 1 / Math.sqrt(Math.pow(g, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [g * m, v * m, f * m], P = [-1 * g * m, -1 * v * m, -1 * f * m], S = X(i, o), M = X(i, C), F = X(o, C), D = X(i, P), G = X(o, P);
556
+ function ii(s, t, e) {
557
+ const i = Mt(s), o = Mt(t), r = Mt(e), [n, a, l] = r, [d, c, h] = function(B, z) {
558
+ const [Bt, Nt, Gt] = B, [Tt, At, Vt] = z;
559
+ return [Nt * Vt - Gt * At, Gt * Tt - Bt * Vt, Bt * At - Nt * Tt];
560
+ }(i, o), u = c * l - h * a, p = h * n - d * l, y = d * a - c * n, g = y * c - p * h, v = u * h - y * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(g, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [g * m, v * m, f * m], P = [-1 * g * m, -1 * v * m, -1 * f * m], S = X(i, o), M = X(i, C), F = X(o, C), D = X(i, P), G = X(o, P);
561
561
  let _;
562
562
  return _ = M < D && M < G || F < D && F < G ? C : P, X(i, _) > S || X(o, _) > S ? A(K(_), K(i)) <= A(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
563
563
  }
564
- function ei(s, t, e) {
564
+ function oi(s, t, e) {
565
565
  const i = t.x - s.x, o = t.y - s.y, r = Math.max(0, Math.min(1, ((e.x - s.x) * i + (e.y - s.y) * o) / (i * i + o * o)));
566
566
  return { x: s.x + r * i, y: s.y + r * o };
567
567
  }
568
- class ve extends W {
568
+ class Pe extends W {
569
569
  constructor(t, e, i) {
570
570
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
571
571
  }
@@ -581,7 +581,7 @@ class ve extends W {
581
581
  const l = [];
582
582
  for (let u = 0; u < a.length - 1; u++) l.push([a[u], a[u + 1]]);
583
583
  let d;
584
- const h = [t.lng, t.lat];
584
+ const c = [t.lng, t.lat];
585
585
  if (this.config.projection === "web-mercator" ? d = function(u, p) {
586
586
  let y = [1 / 0, 1 / 0], g = 1 / 0, v = 0;
587
587
  for (let f of p) {
@@ -591,30 +591,30 @@ class ve extends W {
591
591
  if (m[0] === u[0] && m[1] === u[1]) P = m;
592
592
  else if (C[0] === u[0] && C[1] === u[1]) P = C;
593
593
  else {
594
- const { x: G, y: _ } = ei(M, F, D), { lng: B, lat: z } = j(G, _);
594
+ const { x: G, y: _ } = oi(M, F, D), { lng: B, lat: z } = j(G, _);
595
595
  P = [B, z];
596
596
  }
597
597
  P && (S = E(D, x(P[0], P[1])), S < g && (y = P, g = S, v = p.indexOf(f)));
598
598
  }
599
599
  return g === 1 / 0 ? void 0 : { coordinate: y, lineIndex: v, distance: g };
600
- }(h, l) : this.config.projection === "globe" && (d = function(u, p) {
600
+ }(c, l) : this.config.projection === "globe" && (d = function(u, p) {
601
601
  let y = [1 / 0, 1 / 0], g = 1 / 0, v = 0;
602
602
  for (let f of p) {
603
603
  const m = f[0], C = f[1];
604
604
  let P, S = 1 / 0;
605
- m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = ti(m, C, u), P && (S = A(u, P), S < g && (y = P, g = S, v = p.indexOf(f)));
605
+ m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = ii(m, C, u), P && (S = A(u, P), S < g && (y = P, g = S, v = p.indexOf(f)));
606
606
  }
607
607
  return g === 1 / 0 ? void 0 : { coordinate: y, distance: g, lineIndex: v };
608
- }(h, l)), !d) return;
609
- const c = this.pixelDistance.measure(t, d.coordinate);
610
- c < r.minDistance && c < this.pointerDistance && (r.featureId = n.id, r.coordinate = d.coordinate, r.featureCoordinateIndex = d.lineIndex, r.minDistance = c);
608
+ }(c, l)), !d) return;
609
+ const h = this.pixelDistance.measure(t, d.coordinate);
610
+ h < r.minDistance && h < this.pointerDistance && (r.featureId = n.id, r.coordinate = d.coordinate, r.featureCoordinateIndex = d.lineIndex, r.minDistance = h);
611
611
  }), r;
612
612
  }
613
613
  }
614
- const ii = { cancel: "Escape", finish: "Enter" }, oi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
615
- class Ce extends N {
614
+ const si = { cancel: "Escape", finish: "Enter" }, ri = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
615
+ class Se extends N {
616
616
  constructor(t) {
617
- super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = ii, this.snapping = void 0, this.cursors = oi, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0, this.lineSnapping = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
617
+ super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = si, this.snapping = void 0, this.cursors = ri, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0, this.lineSnapping = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
618
618
  }
619
619
  updateOptions(t) {
620
620
  super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), t != null && t.snapping && (this.snapping = t.snapping), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.insertCoordinates && (this.insertCoordinates = t.insertCoordinates), t && t.editable && (this.editable = t.editable);
@@ -660,7 +660,7 @@ class Ce extends N {
660
660
  this.updateGeometries(l, i[i.length - 1], I.Commit), this.currentCoordinate++;
661
661
  }
662
662
  registerBehaviors(t) {
663
- this.coordinateSnapping = new Dt(t, new nt(t), new rt(t)), this.insertPoint = new Qe(t), this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new ve(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Dt(t, this.pixelDistance, this.clickBoundingBox);
663
+ this.coordinateSnapping = new _t(t, new nt(t), new rt(t)), this.insertPoint = new ei(t), this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new Pe(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new _t(t, this.pixelDistance, this.clickBoundingBox);
664
664
  }
665
665
  start() {
666
666
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -674,7 +674,7 @@ class Ce extends N {
674
674
  if (e) {
675
675
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
676
676
  else {
677
- const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
677
+ const [n] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Dt]: !0 } }]);
678
678
  this.snappedPointId = n;
679
679
  }
680
680
  t.lng = e[0], t.lat = e[1];
@@ -765,7 +765,7 @@ class Ce extends N {
765
765
  return e;
766
766
  }
767
767
  validateFeature(t) {
768
- return this.validateModeFeature(t, (e) => me(e, this.coordinatePrecision));
768
+ return this.validateModeFeature(t, (e) => Ce(e, this.coordinatePrecision));
769
769
  }
770
770
  lineStringFilter(t) {
771
771
  return !!(t.geometry.type === "LineString" && t.properties && t.properties.mode === this.mode);
@@ -776,14 +776,14 @@ class Ce extends N {
776
776
  return (e = this.snapping) != null && e.toCoordinate && (o = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t)), (i = this.snapping) != null && i.toCustom && (o = this.snapping.toCustom(t)), o;
777
777
  }
778
778
  }
779
- const si = "Feature is not a Point", ri = "Feature has invalid coordinates", ni = "Feature has coordinates with excessive precision";
780
- function Pe(s, t) {
781
- return s.geometry.type !== "Point" ? { valid: !1, reason: si } : Lt(s.geometry.coordinates) ? St(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: ni } : { valid: !1, reason: ri };
779
+ const ni = "Feature is not a Point", ai = "Feature has invalid coordinates", li = "Feature has coordinates with excessive precision";
780
+ function xe(s, t) {
781
+ return s.geometry.type !== "Point" ? { valid: !1, reason: ni } : kt(s.geometry.coordinates) ? St(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: li } : { valid: !1, reason: ai };
782
782
  }
783
- const ai = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
784
- class Se extends N {
783
+ const di = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
784
+ class Ie extends N {
785
785
  constructor(t) {
786
- super(t, !0), this.mode = "point", this.cursors = ai, this.editable = !1, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
786
+ super(t, !0), this.mode = "point", this.cursors = di, this.editable = !1, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
787
787
  }
788
788
  updateOptions(t) {
789
789
  super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), t != null && t.editable && (this.editable = t.editable);
@@ -832,7 +832,7 @@ class Se extends N {
832
832
  return e;
833
833
  }
834
834
  validateFeature(t) {
835
- return this.validateModeFeature(t, (e) => Pe(e, this.coordinatePrecision));
835
+ return this.validateModeFeature(t, (e) => xe(e, this.coordinatePrecision));
836
836
  }
837
837
  onLeftClick(t) {
838
838
  const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
@@ -857,7 +857,7 @@ class Se extends N {
857
857
  return o;
858
858
  }
859
859
  }
860
- class li extends W {
860
+ class ci extends W {
861
861
  constructor(t, e) {
862
862
  super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
863
863
  }
@@ -883,10 +883,10 @@ class li extends W {
883
883
  return { isClosing: o < this.pointerDistance, isPreviousClosing: r < this.pointerDistance };
884
884
  }
885
885
  }
886
- const di = { cancel: "Escape", finish: "Enter" }, hi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
887
- class xe extends N {
886
+ const hi = { cancel: "Escape", finish: "Enter" }, ui = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
887
+ class be extends N {
888
888
  constructor(t) {
889
- super(t, !0), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = di, this.cursors = hi, this.mouseMove = !1, this.snapping = void 0, this.snappedPointId = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
889
+ super(t, !0), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = hi, this.cursors = ui, this.mouseMove = !1, this.snapping = void 0, this.snappedPointId = void 0, this.editable = !1, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
890
890
  }
891
891
  updateOptions(t) {
892
892
  super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.snapping && (this.snapping = t.snapping), t != null && t.editable && (this.editable = t.editable);
@@ -903,7 +903,7 @@ class xe extends N {
903
903
  this.snappedPointId && this.store.delete([this.snappedPointId]), this.currentCoordinate = 0, this.currentId = void 0, this.snappedPointId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
904
904
  }
905
905
  registerBehaviors(t) {
906
- this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new ve(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Dt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new li(t, this.pixelDistance);
906
+ this.clickBoundingBox = new rt(t), this.pixelDistance = new nt(t), this.lineSnapping = new Pe(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new _t(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new ci(t, this.pixelDistance);
907
907
  }
908
908
  start() {
909
909
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -917,7 +917,7 @@ class xe extends N {
917
917
  if (e) {
918
918
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
919
919
  else {
920
- const [r] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
920
+ const [r] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Dt]: !0 } }]);
921
921
  this.snappedPointId = r;
922
922
  }
923
923
  t.lng = e[0], t.lat = e[1];
@@ -1044,7 +1044,7 @@ class xe extends N {
1044
1044
  if (t.properties.mode === this.mode) {
1045
1045
  if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
1046
1046
  if (t.geometry.type === "Point") {
1047
- const i = t.properties[V], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[Ot] ? "snappingPoint" : void 0;
1047
+ const i = t.properties[V], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[Dt] ? "snappingPoint" : void 0;
1048
1048
  if (!o) return e;
1049
1049
  const r = { editedPoint: { width: this.styles.editedPointOutlineWidth, color: this.styles.editedPointColor, outlineColor: this.styles.editedPointOutlineColor, outlineWidth: this.styles.editedPointOutlineWidth }, closingPoint: { width: this.styles.closingPointWidth, color: this.styles.closingPointColor, outlineColor: this.styles.closingPointOutlineColor, outlineWidth: this.styles.closingPointOutlineWidth }, snappingPoint: { width: this.styles.snappingPointWidth, color: this.styles.snappingPointColor, outlineColor: this.styles.snappingPointOutlineColor, outlineWidth: this.styles.snappingPointOutlineWidth } };
1050
1050
  return e.pointWidth = this.getNumericStylingValue(r[o].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(r[o].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(r[o].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(r[o].outlineWidth, 2, t), e.zIndex = i ? 35 : 30, e;
@@ -1056,10 +1056,10 @@ class xe extends N {
1056
1056
  return this.validateModeFeature(t, (e) => xt(e, this.coordinatePrecision));
1057
1057
  }
1058
1058
  }
1059
- const ci = { cancel: "Escape", finish: "Enter" }, ui = { start: "crosshair" };
1060
- class Ie extends N {
1059
+ const pi = { cancel: "Escape", finish: "Enter" }, gi = { start: "crosshair" };
1060
+ class Me extends N {
1061
1061
  constructor(t) {
1062
- super(t, !0), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = ci, this.cursors = ui, this.updateOptions(t);
1062
+ super(t, !0), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = pi, this.cursors = gi, this.updateOptions(t);
1063
1063
  }
1064
1064
  updateOptions(t) {
1065
1065
  super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents));
@@ -1157,7 +1157,7 @@ class et extends N {
1157
1157
  validateFeature(t) {
1158
1158
  const e = super.validateFeature(t);
1159
1159
  if (e.valid) {
1160
- const i = t, o = Pe(i, this.coordinatePrecision).valid || xt(i, this.coordinatePrecision).valid || me(i, this.coordinatePrecision).valid;
1160
+ const i = t, o = xe(i, this.coordinatePrecision).valid || xt(i, this.coordinatePrecision).valid || Ce(i, this.coordinatePrecision).valid;
1161
1161
  return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
1162
1162
  }
1163
1163
  return e;
@@ -1170,37 +1170,37 @@ function mt(s, t) {
1170
1170
  const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (R(Math.atan2(n, a)) + 360) % 360;
1171
1171
  return l > 180 ? -(360 - l) : l;
1172
1172
  }
1173
- function kt(s, t, e) {
1173
+ function jt(s, t, e) {
1174
1174
  let i = t;
1175
1175
  t < 0 && (i = -Math.abs(i));
1176
- const o = i / ue, r = s[0] * Math.PI / 180, n = O(s[1]), a = O(e), l = o * Math.cos(a);
1176
+ const o = i / ge, r = s[0] * Math.PI / 180, n = O(s[1]), a = O(e), l = o * Math.cos(a);
1177
1177
  let d = n + l;
1178
1178
  Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
1179
- const h = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), c = Math.abs(h) > 1e-11 ? l / h : Math.cos(n), u = [(180 * (r + o * Math.sin(a) / c) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1179
+ const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (r + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1180
1180
  return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
1181
1181
  }
1182
- function be(s, t, e, i, o) {
1182
+ function we(s, t, e, i, o) {
1183
1183
  const r = i(s[0], s[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((r.x + n.x) / 2, (r.y + n.y) / 2);
1184
1184
  return [w(a, e), w(l, e)];
1185
1185
  }
1186
- function pi(s, t, e) {
1187
- const i = kt(s, 1e3 * A(s, t) / 2, mt(s, t));
1186
+ function yi(s, t, e) {
1187
+ const i = jt(s, 1e3 * A(s, t) / 2, mt(s, t));
1188
1188
  return [w(i[0], e), w(i[1], e)];
1189
1189
  }
1190
- function qt({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
1190
+ function Jt({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
1191
1191
  const r = [];
1192
1192
  for (let n = 0; n < s.length - 1; n++) {
1193
1193
  let a;
1194
- if (o === "web-mercator") a = be(s[n], s[n + 1], t, i, e);
1194
+ if (o === "web-mercator") a = we(s[n], s[n + 1], t, i, e);
1195
1195
  else {
1196
1196
  if (o !== "globe") throw new Error("Invalid projection");
1197
- a = pi(s[n], s[n + 1], t);
1197
+ a = yi(s[n], s[n + 1], t);
1198
1198
  }
1199
1199
  r.push(a);
1200
1200
  }
1201
1201
  return r;
1202
1202
  }
1203
- class gi extends W {
1203
+ class fi extends W {
1204
1204
  constructor(t, e) {
1205
1205
  super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
1206
1206
  }
@@ -1216,17 +1216,17 @@ class gi extends W {
1216
1216
  create(t, e, i) {
1217
1217
  if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
1218
1218
  this._midPoints = this.store.create(function(o, r, n, a, l, d) {
1219
- return qt({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((h, c) => ({ geometry: { type: "Point", coordinates: h }, properties: r(c) }));
1219
+ return Jt({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: r(h) }));
1220
1220
  }(t, (o) => ({ mode: this.mode, [U.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
1221
1221
  }
1222
1222
  delete() {
1223
1223
  this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
1224
1224
  }
1225
1225
  getUpdated(t) {
1226
- if (this._midPoints.length !== 0) return qt({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
1226
+ if (this._midPoints.length !== 0) return Jt({ featureCoords: t, precision: this.coordinatePrecision, project: this.config.project, unproject: this.config.unproject, projection: this.config.projection }).map((e, i) => ({ id: this._midPoints[i], geometry: { type: "Point", coordinates: e } }));
1227
1227
  }
1228
1228
  }
1229
- class yi extends W {
1229
+ class mi extends W {
1230
1230
  constructor(t) {
1231
1231
  super(t), this._selectionPoints = [];
1232
1232
  }
@@ -1252,16 +1252,16 @@ class yi extends W {
1252
1252
  if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
1253
1253
  }
1254
1254
  }
1255
- function Me(s, t) {
1255
+ function Fe(s, t) {
1256
1256
  let e = !1;
1257
1257
  for (let n = 0, a = t.length; n < a; n++) {
1258
1258
  const l = t[n];
1259
- for (let d = 0, h = l.length, c = h - 1; d < h; c = d++) (o = l[d])[1] > (i = s)[1] != (r = l[c])[1] > i[1] && i[0] < (r[0] - o[0]) * (i[1] - o[1]) / (r[1] - o[1]) + o[0] && (e = !e);
1259
+ for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i = s)[1] != (r = l[h])[1] > i[1] && i[0] < (r[0] - o[0]) * (i[1] - o[1]) / (r[1] - o[1]) + o[0] && (e = !e);
1260
1260
  }
1261
1261
  var i, o, r;
1262
1262
  return e;
1263
1263
  }
1264
- const we = (s, t, e) => {
1264
+ const Ee = (s, t, e) => {
1265
1265
  const i = (r) => r * r, o = (r, n) => i(r.x - n.x) + i(r.y - n.y);
1266
1266
  return Math.sqrt(((r, n, a) => {
1267
1267
  const l = o(n, a);
@@ -1270,15 +1270,15 @@ const we = (s, t, e) => {
1270
1270
  return d = Math.max(0, Math.min(1, d)), o(r, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
1271
1271
  })(s, t, e));
1272
1272
  };
1273
- class fi extends W {
1273
+ class vi extends W {
1274
1274
  constructor(t, e, i) {
1275
1275
  super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
1276
1276
  }
1277
1277
  find(t, e) {
1278
1278
  let i, o, r, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
1279
- const h = this.createClickBoundingBox.create(t), c = this.store.search(h);
1280
- for (let u = 0; u < c.length; u++) {
1281
- const p = c[u], y = p.geometry;
1279
+ const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
1280
+ for (let u = 0; u < h.length; u++) {
1281
+ const p = h[u], y = p.geometry;
1282
1282
  if (y.type === "Point") {
1283
1283
  if (p.properties.selectionPoint || !e && p.properties[U.MID_POINT]) continue;
1284
1284
  const g = this.pixelDistance.measure(t, y.coordinates);
@@ -1286,18 +1286,18 @@ class fi extends W {
1286
1286
  } else if (y.type === "LineString") {
1287
1287
  if (i) continue;
1288
1288
  for (let g = 0; g < y.coordinates.length - 1; g++) {
1289
- const v = y.coordinates[g], f = y.coordinates[g + 1], m = we({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
1289
+ const v = y.coordinates[g], f = y.coordinates[g + 1], m = Ee({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
1290
1290
  m < this.pointerDistance && m < l && (l = m, o = p);
1291
1291
  }
1292
1292
  } else if (y.type === "Polygon") {
1293
1293
  if (i || o) continue;
1294
- Me([t.lng, t.lat], y.coordinates) && (n = p);
1294
+ Fe([t.lng, t.lat], y.coordinates) && (n = p);
1295
1295
  }
1296
1296
  }
1297
1297
  return { clickedFeature: i || o || n, clickedMidPoint: r };
1298
1298
  }
1299
1299
  }
1300
- class mi extends W {
1300
+ class Ci extends W {
1301
1301
  constructor(t, e, i, o) {
1302
1302
  super(t), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o;
1303
1303
  }
@@ -1321,17 +1321,17 @@ class mi extends W {
1321
1321
  let r, n;
1322
1322
  if (i.type === "Polygon" ? (r = i.coordinates[0], n = r.length - 1) : (r = i.coordinates, n = r.length), !this.dragPosition) return !1;
1323
1323
  for (let d = 0; d < n; d++) {
1324
- const h = r[d];
1325
- let c, u;
1324
+ const c = r[d];
1325
+ let h, u;
1326
1326
  if (this.config.projection === "web-mercator") {
1327
- const p = x(this.dragPosition[0], this.dragPosition[1]), y = x(o[0], o[1]), g = x(h[0], h[1]), v = { x: p.x - y.x, y: p.y - y.y }, f = g.x - v.x, m = g.y - v.y, { lng: C, lat: P } = j(f, m);
1328
- c = C, u = P;
1327
+ const p = x(this.dragPosition[0], this.dragPosition[1]), y = x(o[0], o[1]), g = x(c[0], c[1]), v = { x: p.x - y.x, y: p.y - y.y }, f = g.x - v.x, m = g.y - v.y, { lng: C, lat: P } = j(f, m);
1328
+ h = C, u = P;
1329
1329
  } else {
1330
1330
  const p = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
1331
- c = h[0] - p[0], u = h[1] - p[1];
1331
+ h = c[0] - p[0], u = c[1] - p[1];
1332
1332
  }
1333
- if (c = w(c, this.config.coordinatePrecision), u = w(u, this.config.coordinatePrecision), c > 180 || c < -180 || u > 90 || u < -90) return !1;
1334
- r[d] = [c, u];
1333
+ if (h = w(h, this.config.coordinatePrecision), u = w(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
1334
+ r[d] = [h, u];
1335
1335
  }
1336
1336
  i.type === "Polygon" && (r[r.length - 1] = [r[0][0], r[0][1]]);
1337
1337
  const a = this.selectionPoints.getUpdated(r) || [], l = this.midPoints.getUpdated(r) || [];
@@ -1340,7 +1340,7 @@ class mi extends W {
1340
1340
  } else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
1341
1341
  }
1342
1342
  }
1343
- class vi extends W {
1343
+ class Pi extends W {
1344
1344
  constructor(t, e, i, o) {
1345
1345
  super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
1346
1346
  }
@@ -1371,11 +1371,11 @@ class vi extends W {
1371
1371
  if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
1372
1372
  if (r.type !== "Polygon" || o !== n.length - 1 && o !== 0) n[o] = a;
1373
1373
  else {
1374
- const c = n.length - 1;
1375
- n[0] = a, n[c] = a;
1374
+ const h = n.length - 1;
1375
+ n[0] = a, n[h] = a;
1376
1376
  }
1377
- const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], h = this.midPoints.getUpdated(n) || [];
1378
- return !(r.type !== "Point" && !e && _t({ geometry: r }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: r, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: r }, ...d, ...h]), 0));
1377
+ const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(n) || [];
1378
+ return !(r.type !== "Point" && !e && Lt({ geometry: r }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: r, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: r }, ...d, ...c]), 0));
1379
1379
  }
1380
1380
  isDragging() {
1381
1381
  return this.draggedCoordinate.id !== null;
@@ -1393,9 +1393,9 @@ function vt(s) {
1393
1393
  t += o[0], e += o[1], i++;
1394
1394
  }, !0), [t / i, e / i];
1395
1395
  }
1396
- function Fe(s, t) {
1396
+ function Oe(s, t) {
1397
1397
  s[0] += s[0] - t[0] > 180 ? -360 : t[0] - s[0] > 180 ? 360 : 0;
1398
- const e = ue, i = t[1] * Math.PI / 180, o = s[1] * Math.PI / 180, r = o - i;
1398
+ const e = ge, i = t[1] * Math.PI / 180, o = s[1] * Math.PI / 180, r = o - i;
1399
1399
  let n = Math.abs(s[0] - t[0]) * Math.PI / 180;
1400
1400
  n > Math.PI && (n -= 2 * Math.PI);
1401
1401
  const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? r / a : Math.cos(i);
@@ -1410,8 +1410,8 @@ function Ct(s) {
1410
1410
  let i = 0, o = 0, r = 0;
1411
1411
  const n = e.length;
1412
1412
  for (let a = 0; a < n - 1; a++) {
1413
- const [l, d] = e[a], [h, c] = e[a + 1], u = l * c - h * d;
1414
- i += u, o += (l + h) * u, r += (d + c) * u;
1413
+ const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
1414
+ i += u, o += (l + c) * u, r += (d + h) * u;
1415
1415
  }
1416
1416
  return i /= 2, o /= 6 * i, r /= 6 * i, { x: o, y: r };
1417
1417
  }(t) : function(e) {
@@ -1424,7 +1424,7 @@ function Ct(s) {
1424
1424
  return { x: o / i, y: r / i };
1425
1425
  }(t);
1426
1426
  }
1427
- class Ci extends W {
1427
+ class Si extends W {
1428
1428
  constructor(t, e, i) {
1429
1429
  super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
1430
1430
  }
@@ -1439,35 +1439,35 @@ class Ci extends W {
1439
1439
  const a = { type: "Feature", geometry: o, properties: {} };
1440
1440
  if (this.config.projection === "web-mercator") {
1441
1441
  if (n = T(Ct(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
1442
- ((c, u) => {
1443
- if (u === 0 || u === 360 || u === -360) return c;
1444
- const p = 0.017453292519943295 * u, y = (c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).map(([f, m]) => x(f, m)), g = y.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
1442
+ ((h, u) => {
1443
+ if (u === 0 || u === 360 || u === -360) return h;
1444
+ const p = 0.017453292519943295 * u, y = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, m]) => x(f, m)), g = y.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
1445
1445
  g.x /= y.length, g.y /= y.length;
1446
1446
  const v = y.map((f) => ({ x: g.x + (f.x - g.x) * Math.cos(p) - (f.y - g.y) * Math.sin(p), y: g.y + (f.x - g.x) * Math.sin(p) + (f.y - g.y) * Math.cos(p) })).map(({ x: f, y: m }) => [j(f, m).lng, j(f, m).lat]);
1447
- c.geometry.type === "Polygon" ? c.geometry.coordinates[0] = v : c.geometry.coordinates = v;
1447
+ h.geometry.type === "Polygon" ? h.geometry.coordinates[0] = v : h.geometry.coordinates = v;
1448
1448
  })(a, -(this.lastBearing - n));
1449
1449
  } else {
1450
1450
  if (this.config.projection !== "globe") throw new Error("Unsupported projection");
1451
1451
  if (n = mt(vt({ geometry: o }), r), !this.lastBearing) return void (this.lastBearing = n + 180);
1452
- (function(c, u) {
1453
- if (u === 0 || u === 360 || u === -360) return c;
1454
- const p = vt(c);
1455
- (c.geometry.type === "Polygon" ? c.geometry.coordinates[0] : c.geometry.coordinates).forEach((y) => {
1456
- const g = mt(p, y) + u, v = Fe(p, y), f = kt(p, v, g);
1452
+ (function(h, u) {
1453
+ if (u === 0 || u === 360 || u === -360) return h;
1454
+ const p = vt(h);
1455
+ (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((y) => {
1456
+ const g = mt(p, y) + u, v = Oe(p, y), f = jt(p, v, g);
1457
1457
  y[0] = f[0], y[1] = f[1];
1458
1458
  });
1459
1459
  })(a, -(this.lastBearing - (n + 180)));
1460
1460
  }
1461
1461
  const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1462
- l.forEach((c) => {
1463
- c[0] = w(c[0], this.coordinatePrecision), c[1] = w(c[1], this.coordinatePrecision);
1462
+ l.forEach((h) => {
1463
+ h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision);
1464
1464
  });
1465
- const d = this.midPoints.getUpdated(l) || [], h = this.selectionPoints.getUpdated(l) || [];
1465
+ const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [];
1466
1466
  if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional })) return !1;
1467
- this.store.updateGeometry([{ id: e, geometry: o }, ...h, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
1467
+ this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
1468
1468
  }
1469
1469
  }
1470
- class Pi extends W {
1470
+ class xi extends W {
1471
1471
  constructor(t, e, i) {
1472
1472
  super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
1473
1473
  }
@@ -1498,20 +1498,20 @@ class Pi extends W {
1498
1498
  })(n, d, [p, y]);
1499
1499
  } else this.config.projection === "globe" && function(p, y, g, v = "xy") {
1500
1500
  y === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
1501
- const m = Fe(g, f), C = mt(g, f), P = kt(g, m * y, C);
1501
+ const m = Oe(g, f), C = mt(g, f), P = jt(g, m * y, C);
1502
1502
  v !== "x" && v !== "xy" || (f[0] = P[0]), v !== "y" && v !== "xy" || (f[1] = P[1]);
1503
1503
  });
1504
1504
  }(n, d, vt(n));
1505
- const h = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1506
- h.forEach((p) => {
1505
+ const c = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1506
+ c.forEach((p) => {
1507
1507
  p[0] = w(p[0], this.coordinatePrecision), p[1] = w(p[1], this.coordinatePrecision);
1508
1508
  });
1509
- const c = this.midPoints.getUpdated(h) || [], u = this.selectionPoints.getUpdated(h) || [];
1509
+ const h = this.midPoints.getUpdated(c) || [], u = this.selectionPoints.getUpdated(c) || [];
1510
1510
  if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional })) return !1;
1511
- this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...c]), this.lastDistance = a;
1511
+ this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...h]), this.lastDistance = a;
1512
1512
  }
1513
1513
  }
1514
- class Si extends W {
1514
+ class Ii extends W {
1515
1515
  constructor(t, e, i, o) {
1516
1516
  super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.minimumScale = 1e-4, this.draggedCoordinate = { id: null, index: -1 }, this.boundingBoxMaps = { opposite: { 0: 4, 1: 5, 2: 6, 3: 7, 4: 0, 5: 1, 6: 2, 7: 3 } }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
1517
1517
  }
@@ -1572,16 +1572,16 @@ class Si extends W {
1572
1572
  if (!e) return null;
1573
1573
  const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Ct(i);
1574
1574
  if (!a) return null;
1575
- const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = x(t.lng, t.lat);
1576
- return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), r;
1575
+ const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
1576
+ return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
1577
1577
  }
1578
1578
  centerFixedWebMercatorDrag(t) {
1579
1579
  const e = this.getSelectedFeatureDataWebMercator();
1580
1580
  if (!e) return null;
1581
1581
  const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = Ct(i);
1582
1582
  if (!a) return null;
1583
- const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), h = x(t.lng, t.lat);
1584
- return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: h, webMercatorSelected: l, webMercatorOrigin: a }), r;
1583
+ const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
1584
+ return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
1585
1585
  }
1586
1586
  scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
1587
1587
  if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
@@ -1591,14 +1591,14 @@ class Si extends W {
1591
1591
  oppositeFixedWebMercatorDrag(t) {
1592
1592
  const e = this.getSelectedFeatureDataWebMercator();
1593
1593
  if (!e) return null;
1594
- const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, h = x(t.lng, t.lat);
1595
- return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: h, webMercatorSelected: n, webMercatorOrigin: d }), o;
1594
+ const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
1595
+ return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
1596
1596
  }
1597
1597
  oppositeWebMercatorDrag(t) {
1598
1598
  const e = this.getSelectedFeatureDataWebMercator();
1599
1599
  if (!e) return null;
1600
- const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, h = x(t.lng, t.lat);
1601
- return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: h, webMercatorSelected: n, webMercatorOrigin: d }), o;
1600
+ const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
1601
+ return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
1602
1602
  }
1603
1603
  scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
1604
1604
  const n = e.x - o.x, a = e.y - o.y;
@@ -1622,8 +1622,8 @@ class Si extends W {
1622
1622
  }
1623
1623
  performWebMercatorScale(t, e, i, o, r) {
1624
1624
  t.forEach((n) => {
1625
- const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, h = i + (l - i) * r, { lng: c, lat: u } = j(d, h);
1626
- n[0] = c, n[1] = u;
1625
+ const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * r, { lng: h, lat: u } = j(d, c);
1626
+ n[0] = h, n[1] = u;
1627
1627
  });
1628
1628
  }
1629
1629
  getBBoxWebMercator(t) {
@@ -1666,20 +1666,20 @@ class Si extends W {
1666
1666
  let r = null;
1667
1667
  if (e === "center" ? r = this.centerWebMercatorDrag(t) : e === "opposite" ? r = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? r = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (r = this.oppositeFixedWebMercatorDrag(t)), !r) return !1;
1668
1668
  for (let d = 0; d < r.length; d++) {
1669
- const h = r[d];
1670
- if (h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision), !St(h, this.coordinatePrecision)) return !1;
1669
+ const c = r[d];
1670
+ if (c[0] = w(c[0], this.coordinatePrecision), c[1] = w(c[1], this.coordinatePrecision), !St(c, this.coordinatePrecision)) return !1;
1671
1671
  }
1672
1672
  const n = this.midPoints.getUpdated(r) || [], a = this.selectionPoints.getUpdated(r) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [r] : r };
1673
1673
  return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: l, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: I.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
1674
1674
  }
1675
1675
  }
1676
- const xi = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, Jt = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
1677
- class Ee extends Ue {
1676
+ const bi = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, Zt = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
1677
+ class De extends ze {
1678
1678
  constructor(t) {
1679
- super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = xi, this.cursors = Jt, this.validations = {}, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.updateOptions(t);
1679
+ super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = bi, this.cursors = Zt, this.validations = {}, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.updateOptions(t);
1680
1680
  }
1681
1681
  updateOptions(t) {
1682
- if (super.updateOptions(t), this.cursors = t && t.cursors ? b({}, this.cursors, t.cursors) : Jt, (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), (t == null ? void 0 : t.dragEventThrottle) !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), (t == null ? void 0 : t.allowManualDeselection) !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
1682
+ if (super.updateOptions(t), this.cursors = t && t.cursors ? b({}, this.cursors, t.cursors) : Zt, (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), (t == null ? void 0 : t.dragEventThrottle) !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), (t == null ? void 0 : t.allowManualDeselection) !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
1683
1683
  this.flags = b({}, this.flags, t.flags), this.validations = {};
1684
1684
  for (const e in this.flags) {
1685
1685
  const i = this.flags[e].feature;
@@ -1695,7 +1695,7 @@ class Ee extends Ue {
1695
1695
  this._state = "selecting";
1696
1696
  }
1697
1697
  registerBehaviors(t) {
1698
- this.pixelDistance = new nt(t), this.clickBoundingBox = new rt(t), this.featuresAtMouseEvent = new fi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new yi(t), this.midPoints = new gi(t, this.selectionPoints), this.rotateFeature = new Ci(t, this.selectionPoints, this.midPoints), this.scaleFeature = new Pi(t, this.selectionPoints, this.midPoints), this.dragFeature = new mi(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new vi(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Si(t, this.pixelDistance, this.selectionPoints, this.midPoints);
1698
+ this.pixelDistance = new nt(t), this.clickBoundingBox = new rt(t), this.featuresAtMouseEvent = new vi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new mi(t), this.midPoints = new fi(t, this.selectionPoints), this.rotateFeature = new Si(t, this.selectionPoints, this.midPoints), this.scaleFeature = new xi(t, this.selectionPoints, this.midPoints), this.dragFeature = new Ci(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new Pi(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new Ii(t, this.pixelDistance, this.selectionPoints, this.midPoints);
1699
1699
  }
1700
1700
  deselectFeature() {
1701
1701
  this.deselect();
@@ -1710,18 +1710,18 @@ class Ee extends Ue {
1710
1710
  onRightClick(t) {
1711
1711
  if (!this.selectionPoints.ids.length) return;
1712
1712
  let e, i = 1 / 0;
1713
- if (this.selectionPoints.ids.forEach((c) => {
1714
- const u = this.store.getGeometryCopy(c), p = this.pixelDistance.measure(t, u.coordinates);
1715
- p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(c));
1713
+ if (this.selectionPoints.ids.forEach((h) => {
1714
+ const u = this.store.getGeometryCopy(h), p = this.pixelDistance.measure(t, u.coordinates);
1715
+ p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(h));
1716
1716
  }), !e) return;
1717
1717
  const o = e.selectionPointFeatureId, r = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
1718
1718
  if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
1719
1719
  const d = this.store.getGeometryCopy(o);
1720
- let h;
1720
+ let c;
1721
1721
  if (d.type === "Polygon") {
1722
- if (h = d.coordinates[0], h.length <= 4) return;
1723
- } else if (d.type === "LineString" && (h = d.coordinates, h.length <= 2)) return;
1724
- h && (d.type !== "Polygon" || r !== 0 && r !== h.length - 1 ? h.splice(r, 1) : (h.shift(), h.pop(), h.push([h[0][0], h[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(h, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(h, o, this.coordinatePrecision)));
1722
+ if (c = d.coordinates[0], c.length <= 4) return;
1723
+ } else if (d.type === "LineString" && (c = d.coordinates, c.length <= 2)) return;
1724
+ c && (d.type !== "Polygon" || r !== 0 && r !== c.length - 1 ? c.splice(r, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: I.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision)));
1725
1725
  }
1726
1726
  select(t, e = !0) {
1727
1727
  if (this.selected[0] === t) return;
@@ -1839,7 +1839,7 @@ class Ee extends Ue {
1839
1839
  return e;
1840
1840
  }
1841
1841
  }
1842
- class Ii extends N {
1842
+ class Mi extends N {
1843
1843
  constructor(...t) {
1844
1844
  super(...t), this.type = $.Static, this.mode = "static";
1845
1845
  }
@@ -1867,11 +1867,11 @@ class Ii extends N {
1867
1867
  return b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1868
1868
  }
1869
1869
  }
1870
- function Oe(s, t, e, i, o) {
1870
+ function _e(s, t, e, i, o) {
1871
1871
  for (; i > e; ) {
1872
1872
  if (i - e > 600) {
1873
- const l = i - e + 1, d = t - e + 1, h = Math.log(l), c = 0.5 * Math.exp(2 * h / 3), u = 0.5 * Math.sqrt(h * c * (l - c) / l) * (d - l / 2 < 0 ? -1 : 1);
1874
- Oe(s, t, Math.max(e, Math.floor(t - d * c / l + u)), Math.min(i, Math.floor(t + (l - d) * c / l + u)), o);
1873
+ const l = i - e + 1, d = t - e + 1, c = Math.log(l), h = 0.5 * Math.exp(2 * c / 3), u = 0.5 * Math.sqrt(c * h * (l - h) / l) * (d - l / 2 < 0 ? -1 : 1);
1874
+ _e(s, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
1875
1875
  }
1876
1876
  const r = s[t];
1877
1877
  let n = e, a = i;
@@ -1900,10 +1900,10 @@ function it(s, t, e, i, o) {
1900
1900
  function ot(s, t) {
1901
1901
  return s.minX = Math.min(s.minX, t.minX), s.minY = Math.min(s.minY, t.minY), s.maxX = Math.max(s.maxX, t.maxX), s.maxY = Math.max(s.maxY, t.maxY), s;
1902
1902
  }
1903
- function bi(s, t) {
1903
+ function wi(s, t) {
1904
1904
  return s.minX - t.minX;
1905
1905
  }
1906
- function Mi(s, t) {
1906
+ function Fi(s, t) {
1907
1907
  return s.minY - t.minY;
1908
1908
  }
1909
1909
  function wt(s) {
@@ -1912,7 +1912,7 @@ function wt(s) {
1912
1912
  function ut(s) {
1913
1913
  return s.maxX - s.minX + (s.maxY - s.minY);
1914
1914
  }
1915
- function wi(s, t) {
1915
+ function Ei(s, t) {
1916
1916
  const e = Math.max(s.minX, t.minX), i = Math.max(s.minY, t.minY), o = Math.min(s.maxX, t.maxX), r = Math.min(s.maxY, t.maxY);
1917
1917
  return Math.max(0, o - e) * Math.max(0, r - i);
1918
1918
  }
@@ -1925,15 +1925,15 @@ function pt(s, t) {
1925
1925
  function J(s) {
1926
1926
  return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
1927
1927
  }
1928
- function Zt(s, t, e, i, o) {
1928
+ function Qt(s, t, e, i, o) {
1929
1929
  const r = [t, e];
1930
1930
  for (; r.length; ) {
1931
1931
  if ((e = r.pop()) - (t = r.pop()) <= i) continue;
1932
1932
  const n = t + Math.ceil((e - t) / i / 2) * i;
1933
- Oe(s, n, t, e, o), r.push(t, n, n, e);
1933
+ _e(s, n, t, e, o), r.push(t, n, n, e);
1934
1934
  }
1935
1935
  }
1936
- class Fi {
1936
+ class Oi {
1937
1937
  constructor(t) {
1938
1938
  this._maxEntries = void 0, this._minEntries = void 0, this.data = void 0, this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
1939
1939
  }
@@ -2022,12 +2022,12 @@ class Fi {
2022
2022
  if (r <= a) return n = J(t.slice(e, i + 1)), H(n, this.toBBox), n;
2023
2023
  o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n = J([]), n.leaf = !1, n.height = o;
2024
2024
  const l = Math.ceil(r / a), d = l * Math.ceil(Math.sqrt(a));
2025
- Zt(t, e, i, d, this.compareMinX);
2026
- for (let h = e; h <= i; h += d) {
2027
- const c = Math.min(h + d - 1, i);
2028
- Zt(t, h, c, l, this.compareMinY);
2029
- for (let u = h; u <= c; u += l) {
2030
- const p = Math.min(u + l - 1, c);
2025
+ Qt(t, e, i, d, this.compareMinX);
2026
+ for (let c = e; c <= i; c += d) {
2027
+ const h = Math.min(c + d - 1, i);
2028
+ Qt(t, c, h, l, this.compareMinY);
2029
+ for (let u = c; u <= h; u += l) {
2030
+ const p = Math.min(u + l - 1, h);
2031
2031
  n.children.push(this._build(t, u, p, o - 1));
2032
2032
  }
2033
2033
  }
@@ -2036,9 +2036,9 @@ class Fi {
2036
2036
  _chooseSubtree(t, e, i, o) {
2037
2037
  for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
2038
2038
  let a, l = 1 / 0, d = 1 / 0;
2039
- for (let h = 0; h < e.children.length; h++) {
2040
- const c = e.children[h], u = wt(c), p = (r = t, n = c, (Math.max(n.maxX, r.maxX) - Math.min(n.minX, r.minX)) * (Math.max(n.maxY, r.maxY) - Math.min(n.minY, r.minY)) - u);
2041
- p < d ? (d = p, l = u < l ? u : l, a = c) : p === d && u < l && (l = u, a = c);
2039
+ for (let c = 0; c < e.children.length; c++) {
2040
+ const h = e.children[c], u = wt(h), p = (r = t, n = h, (Math.max(n.maxX, r.maxX) - Math.min(n.minX, r.minX)) * (Math.max(n.maxY, r.maxY) - Math.min(n.minY, r.minY)) - u);
2041
+ p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
2042
2042
  }
2043
2043
  e = a || e.children[0];
2044
2044
  }
@@ -2062,13 +2062,13 @@ class Fi {
2062
2062
  _chooseSplitIndex(t, e, i) {
2063
2063
  let o, r = 1 / 0, n = 1 / 0;
2064
2064
  for (let a = e; a <= i - e; a++) {
2065
- const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), h = wi(l, d), c = wt(l) + wt(d);
2066
- h < r ? (r = h, o = a, n = c < n ? c : n) : h === r && c < n && (n = c, o = a);
2065
+ const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), c = Ei(l, d), h = wt(l) + wt(d);
2066
+ c < r ? (r = c, o = a, n = h < n ? h : n) : c === r && h < n && (n = h, o = a);
2067
2067
  }
2068
2068
  return o || i - e;
2069
2069
  }
2070
2070
  _chooseSplitAxis(t, e, i) {
2071
- const o = t.leaf ? this.compareMinX : bi, r = t.leaf ? this.compareMinY : Mi;
2071
+ const o = t.leaf ? this.compareMinX : wi, r = t.leaf ? this.compareMinY : Fi;
2072
2072
  this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, r) && t.children.sort(o);
2073
2073
  }
2074
2074
  _allDistMargin(t, e, i, o) {
@@ -2076,12 +2076,12 @@ class Fi {
2076
2076
  const r = this.toBBox, n = it(t, 0, e, r), a = it(t, i - e, i, r);
2077
2077
  let l = ut(n) + ut(a);
2078
2078
  for (let d = e; d < i - e; d++) {
2079
- const h = t.children[d];
2080
- ot(n, t.leaf ? r(h) : h), l += ut(n);
2079
+ const c = t.children[d];
2080
+ ot(n, t.leaf ? r(c) : c), l += ut(n);
2081
2081
  }
2082
2082
  for (let d = i - e - 1; d >= e; d--) {
2083
- const h = t.children[d];
2084
- ot(a, t.leaf ? r(h) : h), l += ut(a);
2083
+ const c = t.children[d];
2084
+ ot(a, t.leaf ? r(c) : c), l += ut(a);
2085
2085
  }
2086
2086
  return l;
2087
2087
  }
@@ -2092,9 +2092,9 @@ class Fi {
2092
2092
  for (let e, i = t.length - 1; i >= 0; i--) t[i].children.length === 0 ? i > 0 ? (e = t[i - 1].children, e.splice(e.indexOf(t[i]), 1)) : this.clear() : H(t[i], this.toBBox);
2093
2093
  }
2094
2094
  }
2095
- class Ei {
2095
+ class Di {
2096
2096
  constructor(t) {
2097
- this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new Fi(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
2097
+ this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new Oi(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
2098
2098
  }
2099
2099
  setMaps(t, e) {
2100
2100
  this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
@@ -2145,14 +2145,14 @@ class Ei {
2145
2145
  return this.tree.collides(this.toBBox(t));
2146
2146
  }
2147
2147
  }
2148
- const Oi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
2148
+ const _i = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
2149
2149
  const t = 16 * Math.random() | 0;
2150
2150
  return (s == "x" ? t : 3 & t | 8).toString(16);
2151
2151
  }), isValidId: (s) => typeof s == "string" && s.length === 36 };
2152
- class Di {
2152
+ class Li {
2153
2153
  constructor(t) {
2154
2154
  this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
2155
- }, this.store = {}, this.spatialIndex = new Ei(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : Oi;
2155
+ }, this.store = {}, this.spatialIndex = new Di(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : _i;
2156
2156
  }
2157
2157
  clone(t) {
2158
2158
  return JSON.parse(JSON.stringify(t));
@@ -2176,10 +2176,10 @@ class Di {
2176
2176
  }
2177
2177
  if (this.tracked) {
2178
2178
  if (n.properties.createdAt) {
2179
- if (!Vt(n.properties.createdAt)) return r.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2179
+ if (!Ut(n.properties.createdAt)) return r.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2180
2180
  } else n.properties.createdAt = +/* @__PURE__ */ new Date();
2181
2181
  if (n.properties.updatedAt) {
2182
- if (!Vt(n.properties.updatedAt)) return r.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2182
+ if (!Ut(n.properties.updatedAt)) return r.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2183
2183
  } else n.properties.updatedAt = +/* @__PURE__ */ new Date();
2184
2184
  }
2185
2185
  return this.has(a) ? (r.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = n, o.push(a), r.push({ id: a, valid: !0 }), !0);
@@ -2249,16 +2249,16 @@ class Di {
2249
2249
  return Object.keys(this.store).length;
2250
2250
  }
2251
2251
  }
2252
- const _i = "Feature is not a Polygon or LineString", Li = "Feature intersects itself", ki = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: _i } : _t(s) ? { valid: !1, reason: Li } : { valid: !0 };
2253
- function Qt(s, t, e) {
2252
+ const ki = "Feature is not a Polygon or LineString", ji = "Feature intersects itself", Wi = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: ki } : Lt(s) ? { valid: !1, reason: ji } : { valid: !0 };
2253
+ function te(s, t, e) {
2254
2254
  const i = T(s, t);
2255
2255
  let o = T(t, e) - i;
2256
2256
  return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
2257
2257
  }
2258
- const ji = { cancel: "Escape", finish: "Enter" }, Wi = { start: "crosshair", close: "pointer" };
2259
- class De extends N {
2258
+ const Bi = { cancel: "Escape", finish: "Enter" }, Ni = { start: "crosshair", close: "pointer" };
2259
+ class Le extends N {
2260
2260
  constructor(t) {
2261
- super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = ji, this.cursors = Wi, this.mouseMove = !1, this.updateOptions(t);
2261
+ super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Bi, this.cursors = Ni, this.mouseMove = !1, this.updateOptions(t);
2262
2262
  }
2263
2263
  updateOptions(t) {
2264
2264
  super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents));
@@ -2282,10 +2282,10 @@ class De extends N {
2282
2282
  const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
2283
2283
  i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
2284
2284
  } else if (this.currentCoordinate === 2) {
2285
- const o = e[0], r = e[1], n = be(o, r, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(r[0], r[1]), h = x(t.lng, t.lat), c = E(h, a) < E(h, d), u = Qt(a, l, h), p = c ? 90 - u : Qt(a, l, h) - 90, y = E(l, h), g = Math.cos(O(p)) * y, v = T(a, d) + (function(S, M, F) {
2285
+ const o = e[0], r = e[1], n = we(o, r, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(r[0], r[1]), c = x(t.lng, t.lat), h = E(c, a) < E(c, d), u = te(a, l, c), p = h ? 90 - u : te(a, l, c) - 90, y = E(l, c), g = Math.cos(O(p)) * y, v = T(a, d) + (function(S, M, F) {
2286
2286
  const D = (F.x - M.x) * (S.y - M.y) - (F.y - M.y) * (S.x - M.x);
2287
2287
  return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
2288
- }(a, d, h) === "right" ? -90 : 90), f = at(a, g, v), m = at(d, g, v), C = j(f.x, f.y), P = j(m.x, m.y);
2288
+ }(a, d, c) === "right" ? -90 : 90), f = at(a, g, v), m = at(d, g, v), C = j(f.x, f.y), P = j(m.x, m.y);
2289
2289
  i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
2290
2290
  }
2291
2291
  i && this.updatePolygonGeometry(this.currentId, i, I.Provisional);
@@ -2334,13 +2334,13 @@ class De extends N {
2334
2334
  return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
2335
2335
  }
2336
2336
  }
2337
- function _e(s, t, e) {
2337
+ function ke(s, t, e) {
2338
2338
  return (t.x - s.x) * (e.y - s.y) - (t.y - s.y) * (e.x - s.x) <= 0;
2339
2339
  }
2340
- const Bi = { cancel: "Escape", finish: "Enter" }, Ni = { start: "crosshair", close: "pointer" };
2341
- class Le extends N {
2340
+ const Gi = { cancel: "Escape", finish: "Enter" }, Ti = { start: "crosshair", close: "pointer" };
2341
+ class je extends N {
2342
2342
  constructor(t) {
2343
- super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Bi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ni, this.mouseMove = !1, this.updateOptions(t);
2343
+ super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Gi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ti, this.mouseMove = !1, this.updateOptions(t);
2344
2344
  }
2345
2345
  updateOptions(t) {
2346
2346
  super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.arcPoints && (this.arcPoints = t.arcPoints);
@@ -2368,16 +2368,16 @@ class Le extends N {
2368
2368
  } else if (this.currentCoordinate === 2) {
2369
2369
  const o = e[0], r = e[1], n = [t.lng, t.lat], a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(n[0], n[1]);
2370
2370
  if (this.direction === void 0) {
2371
- const C = _e(a, l, d);
2371
+ const C = ke(a, l, d);
2372
2372
  this.direction = C ? "clockwise" : "anticlockwise";
2373
2373
  }
2374
- const h = E(a, l), c = T(a, l), u = T(a, d), p = this.arcPoints, y = [o], g = Y(c), v = Y(u);
2374
+ const c = E(a, l), h = T(a, l), u = T(a, d), p = this.arcPoints, y = [o], g = Y(h), v = Y(u);
2375
2375
  let f;
2376
2376
  this.direction === "anticlockwise" ? (f = v - g, f < 0 && (f += 360)) : (f = g - v, f < 0 && (f += 360));
2377
2377
  const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
2378
2378
  y.push(r);
2379
2379
  for (let C = 0; C <= p; C++) {
2380
- const P = at(a, h, g + C * m), { lng: S, lat: M } = j(P.x, P.y), F = [w(S, this.coordinatePrecision), w(M, this.coordinatePrecision)];
2380
+ const P = at(a, c, g + C * m), { lng: S, lat: M } = j(P.x, P.y), F = [w(S, this.coordinatePrecision), w(M, this.coordinatePrecision)];
2381
2381
  F[0] !== y[y.length - 1][0] && F[1] !== y[y.length - 1][1] && y.push(F);
2382
2382
  }
2383
2383
  y.push(o), i = [...y];
@@ -2424,10 +2424,10 @@ class Le extends N {
2424
2424
  return this.validateModeFeature(t, (e) => lt(e, this.coordinatePrecision));
2425
2425
  }
2426
2426
  }
2427
- const Gi = { cancel: "Escape", finish: "Enter" }, Ti = { start: "crosshair", close: "pointer" };
2428
- class ke extends N {
2427
+ const Ai = { cancel: "Escape", finish: "Enter" }, Vi = { start: "crosshair", close: "pointer" };
2428
+ class We extends N {
2429
2429
  constructor(t) {
2430
- super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = Gi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ti, this.mouseMove = !1, this.updateOptions(t);
2430
+ super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = Ai, this.direction = void 0, this.arcPoints = 64, this.cursors = Vi, this.mouseMove = !1, this.updateOptions(t);
2431
2431
  }
2432
2432
  updateOptions(t) {
2433
2433
  super.updateOptions(t), t != null && t.cursors && (this.cursors = b({}, this.cursors, t.cursors)), (t == null ? void 0 : t.keyEvents) === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = b({}, this.keyEvents, t.keyEvents)), t != null && t.arcPoints && (this.arcPoints = t.arcPoints);
@@ -2452,10 +2452,10 @@ class ke extends N {
2452
2452
  if (this.currentCoordinate === 2) {
2453
2453
  const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = [t.lng, t.lat], n = x(o[0], o[1]), a = x(r[0], r[1]), l = x(i[0], i[1]), d = E(l, n);
2454
2454
  if (this.direction === void 0) {
2455
- const m = _e(l, n, a);
2455
+ const m = ke(l, n, a);
2456
2456
  this.direction = m ? "clockwise" : "anticlockwise";
2457
2457
  }
2458
- const h = T(l, n), c = T(l, a), u = this.arcPoints, p = [o], y = Y(h), g = Y(c);
2458
+ const c = T(l, n), h = T(l, a), u = this.arcPoints, p = [o], y = Y(c), g = Y(h);
2459
2459
  let v;
2460
2460
  this.direction === "anticlockwise" ? (v = g - y, v < 0 && (v += 360)) : (v = y - g, v < 0 && (v += 360));
2461
2461
  const f = (this.direction === "anticlockwise" ? 1 : -1) * v / u;
@@ -2467,9 +2467,9 @@ class ke extends N {
2467
2467
  } else if (this.currentCoordinate === 3) {
2468
2468
  const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2469
2469
  if (e.length < 2 || !this.direction) return;
2470
- const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]), h = E(d, a), c = E(d, n) < h ? a : n, u = T(d, n), p = T(d, a), y = T(d, l), g = Y(p), v = Y(y), f = Y(u);
2470
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]), c = E(d, a), h = E(d, n) < c ? a : n, u = T(d, n), p = T(d, a), y = T(d, l), g = Y(p), v = Y(y), f = Y(u);
2471
2471
  if (this.notInSector({ normalizedCursor: f, normalizedStart: g, normalizedEnd: v, direction: this.direction })) return;
2472
- const m = this.getDeltaBearing(this.direction, g, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = E(d, c), M = [];
2472
+ const m = this.getDeltaBearing(this.direction, g, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = E(d, h), M = [];
2473
2473
  for (let F = 0; F <= C; F++) {
2474
2474
  const D = at(d, S, g + F * P), { lng: G, lat: _ } = j(D.x, D.y), B = [w(G, this.coordinatePrecision), w(_, this.coordinatePrecision)];
2475
2475
  B[0] !== e[e.length - 1][0] && B[1] !== e[e.length - 1][1] && M.unshift(B);
@@ -2537,7 +2537,7 @@ class q {
2537
2537
  }, this.callback = e;
2538
2538
  }
2539
2539
  }
2540
- var Ai = { __proto__: null, TerraDrawBaseAdapter: class {
2540
+ var Ui = { __proto__: null, TerraDrawBaseAdapter: class {
2541
2541
  constructor(s) {
2542
2542
  this._minPixelDragDistance = void 0, this._minPixelDragDistanceDrawing = void 0, this._minPixelDragDistanceSelecting = void 0, this._lastDrawEvent = void 0, this._coordinatePrecision = void 0, this._heldKeys = /* @__PURE__ */ new Set(), this._listeners = [], this._dragState = "not-dragging", this._currentModeCallbacks = void 0, this._minPixelDragDistance = typeof s.minPixelDragDistance == "number" ? s.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof s.minPixelDragDistanceSelecting == "number" ? s.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof s.minPixelDragDistanceDrawing == "number" ? s.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof s.coordinatePrecision == "number" ? s.coordinatePrecision : 9;
2543
2543
  }
@@ -2627,51 +2627,51 @@ var Ai = { __proto__: null, TerraDrawBaseAdapter: class {
2627
2627
  }), this.clear();
2628
2628
  }
2629
2629
  } };
2630
- class Vi {
2630
+ class Ri {
2631
2631
  constructor(t) {
2632
- this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new Ii();
2633
- const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((h, c) => {
2634
- if (e.has(c.mode)) throw new Error(`There is already a ${c.mode} mode provided`);
2635
- return e.add(c.mode), h[c.mode] = c, h;
2632
+ this._modes = void 0, this._mode = void 0, this._adapter = void 0, this._enabled = !1, this._store = void 0, this._eventListeners = void 0, this._instanceSelectMode = void 0, this._adapter = t.adapter, this._mode = new Mi();
2633
+ const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
2634
+ if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
2635
+ return e.add(h.mode), c[h.mode] = h, c;
2636
2636
  }, {}), o = Object.keys(i);
2637
2637
  if (o.length === 0) throw new Error("No modes provided");
2638
- o.forEach((h) => {
2639
- if (i[h].type === $.Select) {
2638
+ o.forEach((c) => {
2639
+ if (i[c].type === $.Select) {
2640
2640
  if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
2641
- this._instanceSelectMode = h;
2641
+ this._instanceSelectMode = c;
2642
2642
  }
2643
- }), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Di({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2644
- const r = (h) => {
2645
- const c = [], u = this._store.copyAll().filter((p) => !h.includes(p.id) || (c.push(p), !1));
2646
- return { changed: c, unchanged: u };
2647
- }, n = (h, c) => {
2643
+ }), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Li({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2644
+ const r = (c) => {
2645
+ const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
2646
+ return { changed: h, unchanged: u };
2647
+ }, n = (c, h) => {
2648
2648
  this._enabled && this._eventListeners.finish.forEach((u) => {
2649
- u(h, c);
2649
+ u(c, h);
2650
2650
  });
2651
- }, a = (h, c) => {
2651
+ }, a = (c, h) => {
2652
2652
  if (!this._enabled) return;
2653
2653
  this._eventListeners.change.forEach((y) => {
2654
- y(h, c);
2654
+ y(c, h);
2655
2655
  });
2656
- const { changed: u, unchanged: p } = r(h);
2657
- c === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : c === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : c === "delete" ? this._adapter.render({ created: [], deletedIds: h, unchanged: p, updated: [] }, this.getModeStyles()) : c === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
2658
- }, l = (h) => {
2656
+ const { changed: u, unchanged: p } = r(c);
2657
+ h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: p, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
2658
+ }, l = (c) => {
2659
2659
  if (!this._enabled) return;
2660
2660
  this._eventListeners.select.forEach((p) => {
2661
- p(h);
2661
+ p(c);
2662
2662
  });
2663
- const { changed: c, unchanged: u } = r([h]);
2664
- this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: c }, this.getModeStyles());
2665
- }, d = (h) => {
2663
+ const { changed: h, unchanged: u } = r([c]);
2664
+ this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2665
+ }, d = (c) => {
2666
2666
  if (!this._enabled) return;
2667
2667
  this._eventListeners.deselect.forEach((p) => {
2668
2668
  p();
2669
2669
  });
2670
- const { changed: c, unchanged: u } = r([h]);
2671
- c && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: c }, this.getModeStyles());
2670
+ const { changed: h, unchanged: u } = r([c]);
2671
+ h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2672
2672
  };
2673
- Object.keys(this._modes).forEach((h) => {
2674
- this._modes[h].register({ mode: h, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
2673
+ Object.keys(this._modes).forEach((c) => {
2674
+ this._modes[c].register({ mode: c, store: this._store, setCursor: this._adapter.setCursor.bind(this._adapter), project: this._adapter.project.bind(this._adapter), unproject: this._adapter.unproject.bind(this._adapter), setDoubleClickToZoom: this._adapter.setDoubleClickToZoom.bind(this._adapter), onChange: a, onSelect: l, onDeselect: d, onFinish: n, coordinatePrecision: this._adapter.getCoordinatePrecision() });
2675
2675
  });
2676
2676
  }
2677
2677
  checkEnabled() {
@@ -2684,22 +2684,22 @@ class Vi {
2684
2684
  }), t;
2685
2685
  }
2686
2686
  featuresAtLocation({ lng: t, lat: e }, i) {
2687
- const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = fe({ unproject: n, point: l, pointerDistance: o });
2688
- return this._store.search(d).filter((h) => {
2689
- if (r && (h.properties[U.MID_POINT] || h.properties[U.SELECTION_POINT])) return !1;
2690
- if (h.geometry.type === "Point") {
2691
- const c = h.geometry.coordinates, u = a(c[0], c[1]);
2687
+ const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = ve({ unproject: n, point: l, pointerDistance: o });
2688
+ return this._store.search(d).filter((c) => {
2689
+ if (r && (c.properties[U.MID_POINT] || c.properties[U.SELECTION_POINT])) return !1;
2690
+ if (c.geometry.type === "Point") {
2691
+ const h = c.geometry.coordinates, u = a(h[0], h[1]);
2692
2692
  return E(l, u) < o;
2693
2693
  }
2694
- if (h.geometry.type === "LineString") {
2695
- const c = h.geometry.coordinates;
2696
- for (let u = 0; u < c.length - 1; u++) {
2697
- const p = c[u], y = c[u + 1];
2698
- if (we(l, a(p[0], p[1]), a(y[0], y[1])) < o) return !0;
2694
+ if (c.geometry.type === "LineString") {
2695
+ const h = c.geometry.coordinates;
2696
+ for (let u = 0; u < h.length - 1; u++) {
2697
+ const p = h[u], y = h[u + 1];
2698
+ if (Ee(l, a(p[0], p[1]), a(y[0], y[1])) < o) return !0;
2699
2699
  }
2700
2700
  return !1;
2701
2701
  }
2702
- return !!Me([t, e], h.geometry.coordinates) || void 0;
2702
+ return !!Fe([t, e], c.geometry.coordinates) || void 0;
2703
2703
  });
2704
2704
  }
2705
2705
  getSelectMode() {
@@ -2807,7 +2807,7 @@ class Vi {
2807
2807
  i.includes(e) && i.splice(i.indexOf(e), 1);
2808
2808
  }
2809
2809
  }
2810
- class Ui extends Ai.TerraDrawBaseAdapter {
2810
+ class zi extends Ui.TerraDrawBaseAdapter {
2811
2811
  constructor(t) {
2812
2812
  super(t), this._initialDragPan = void 0, this._initialDragRotate = void 0, this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer(), this._initialDragRotate = this._map.dragRotate.isEnabled(), this._initialDragPan = this._map.dragPan.isEnabled();
2813
2813
  }
@@ -2877,13 +2877,13 @@ class Ui extends Ai.TerraDrawBaseAdapter {
2877
2877
  this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
2878
2878
  const i = [...t.created, ...t.updated, ...t.unchanged], o = [], r = [], n = [];
2879
2879
  for (let a = 0; a < i.length; a++) {
2880
- const l = i[a], { properties: d } = l, h = e[d.mode](l);
2881
- l.geometry.type === "Point" ? (d.pointColor = h.pointColor, d.pointOutlineColor = h.pointOutlineColor, d.pointOutlineWidth = h.pointOutlineWidth, d.pointWidth = h.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = h.lineStringColor, d.lineStringWidth = h.lineStringWidth, r.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = h.polygonFillColor, d.polygonFillOpacity = h.polygonFillOpacity, d.polygonOutlineColor = h.polygonOutlineColor, d.polygonOutlineWidth = h.polygonOutlineWidth, n.push(l));
2880
+ const l = i[a], { properties: d } = l, c = e[d.mode](l);
2881
+ l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, r.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, n.push(l));
2882
2882
  }
2883
2883
  if (this._rendered) {
2884
2884
  const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
2885
- let h;
2886
- (a || this.changedIds.points) && (h = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", r), d && this._setGeoJSONLayerData("Polygon", n), h && this._map.moveLayer(h);
2885
+ let c;
2886
+ (a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", r), d && this._setGeoJSONLayerData("Polygon", n), c && this._map.moveLayer(c);
2887
2887
  } else {
2888
2888
  const a = this._addGeoJSONLayer("Point", o);
2889
2889
  this._addGeoJSONLayer("LineString", r), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
@@ -2905,7 +2905,7 @@ class Ui extends Ai.TerraDrawBaseAdapter {
2905
2905
  super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
2906
2906
  }
2907
2907
  }
2908
- const Eo = [
2908
+ const Oo = [
2909
2909
  "render",
2910
2910
  "point",
2911
2911
  "linestring",
@@ -2920,7 +2920,7 @@ const Eo = [
2920
2920
  "delete-selection",
2921
2921
  "delete",
2922
2922
  "download"
2923
- ], Ri = {
2923
+ ], Xi = {
2924
2924
  modes: [
2925
2925
  "render",
2926
2926
  "point",
@@ -2958,7 +2958,7 @@ const Eo = [
2958
2958
  open: !1,
2959
2959
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
2960
2960
  modeOptions: {
2961
- point: new Se({
2961
+ point: new Ie({
2962
2962
  editable: !0,
2963
2963
  styles: {
2964
2964
  pointColor: "#FFFFFF",
@@ -2967,7 +2967,7 @@ const Eo = [
2967
2967
  pointOutlineWidth: 1
2968
2968
  }
2969
2969
  }),
2970
- linestring: new Ce({
2970
+ linestring: new Se({
2971
2971
  editable: !0,
2972
2972
  styles: {
2973
2973
  lineStringColor: "#666666",
@@ -2978,7 +2978,7 @@ const Eo = [
2978
2978
  closingPointOutlineWidth: 1
2979
2979
  }
2980
2980
  }),
2981
- polygon: new xe({
2981
+ polygon: new be({
2982
2982
  editable: !0,
2983
2983
  styles: {
2984
2984
  fillColor: "#EDEFF0",
@@ -2991,7 +2991,7 @@ const Eo = [
2991
2991
  closingPointOutlineWidth: 1
2992
2992
  }
2993
2993
  }),
2994
- rectangle: new Ie({
2994
+ rectangle: new Me({
2995
2995
  styles: {
2996
2996
  fillColor: "#EDEFF0",
2997
2997
  fillOpacity: 0.7,
@@ -2999,7 +2999,7 @@ const Eo = [
2999
2999
  outlineWidth: 2
3000
3000
  }
3001
3001
  }),
3002
- "angled-rectangle": new De({
3002
+ "angled-rectangle": new Le({
3003
3003
  styles: {
3004
3004
  fillColor: "#EDEFF0",
3005
3005
  fillOpacity: 0.7,
@@ -3007,7 +3007,7 @@ const Eo = [
3007
3007
  outlineWidth: 2
3008
3008
  }
3009
3009
  }),
3010
- circle: new ge({
3010
+ circle: new fe({
3011
3011
  styles: {
3012
3012
  fillColor: "#EDEFF0",
3013
3013
  fillOpacity: 0.7,
@@ -3015,7 +3015,7 @@ const Eo = [
3015
3015
  outlineWidth: 2
3016
3016
  }
3017
3017
  }),
3018
- freehand: new ye({
3018
+ freehand: new me({
3019
3019
  styles: {
3020
3020
  fillColor: "#EDEFF0",
3021
3021
  fillOpacity: 0.7,
@@ -3027,7 +3027,7 @@ const Eo = [
3027
3027
  closingPointOutlineWidth: 1
3028
3028
  }
3029
3029
  }),
3030
- sensor: new ke({
3030
+ sensor: new We({
3031
3031
  styles: {
3032
3032
  fillColor: "#EDEFF0",
3033
3033
  fillOpacity: 0.7,
@@ -3039,7 +3039,7 @@ const Eo = [
3039
3039
  centerPointOutlineWidth: 1
3040
3040
  }
3041
3041
  }),
3042
- sector: new Le({
3042
+ sector: new je({
3043
3043
  styles: {
3044
3044
  fillColor: "#EDEFF0",
3045
3045
  fillOpacity: 0.7,
@@ -3047,7 +3047,7 @@ const Eo = [
3047
3047
  outlineWidth: 2
3048
3048
  }
3049
3049
  }),
3050
- select: new Ee({
3050
+ select: new De({
3051
3051
  flags: {
3052
3052
  point: {
3053
3053
  feature: {
@@ -3205,7 +3205,7 @@ const Eo = [
3205
3205
  ["==", ["get", "total"], 0],
3206
3206
  "",
3207
3207
  ["concat", `
3208
- (`, ["to-string", ["get", "total"]], " ", ["get", "unit"], ")"]
3208
+ (`, ["to-string", ["get", "total"]], " ", ["get", "totalUnit"], ")"]
3209
3209
  ],
3210
3210
  [
3211
3211
  "case",
@@ -3301,33 +3301,33 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3301
3301
  distancePrecision: 2,
3302
3302
  areaUnit: "metric",
3303
3303
  areaPrecision: 2
3304
- }, zi = () => ({
3304
+ }, Ki = () => ({
3305
3305
  render: new et({
3306
3306
  modeName: "render",
3307
3307
  styles: {}
3308
3308
  }),
3309
- point: new Se({
3309
+ point: new Ie({
3310
3310
  editable: !0
3311
3311
  }),
3312
- linestring: new Ce({
3312
+ linestring: new Se({
3313
3313
  editable: !0
3314
3314
  }),
3315
- polygon: new xe({
3315
+ polygon: new be({
3316
3316
  editable: !0,
3317
3317
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3318
3318
  // @ts-ignore
3319
3319
  validation: (t, e) => {
3320
3320
  const i = e.updateType;
3321
- return i === "finish" || i === "commit" ? ki(t) : { valid: !0 };
3321
+ return i === "finish" || i === "commit" ? Wi(t) : { valid: !0 };
3322
3322
  }
3323
3323
  }),
3324
- rectangle: new Ie(),
3325
- "angled-rectangle": new De(),
3326
- circle: new ge(),
3327
- freehand: new ye(),
3328
- sensor: new ke(),
3329
- sector: new Le(),
3330
- select: new Ee({
3324
+ rectangle: new Me(),
3325
+ "angled-rectangle": new Le(),
3326
+ circle: new fe(),
3327
+ freehand: new me(),
3328
+ sensor: new We(),
3329
+ sector: new je(),
3330
+ select: new De({
3331
3331
  flags: {
3332
3332
  point: {
3333
3333
  feature: {
@@ -3441,7 +3441,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3441
3441
  styles: {}
3442
3442
  })
3443
3443
  });
3444
- var L = 63710088e-1, Xi = {
3444
+ var L = 63710088e-1, Yi = {
3445
3445
  centimeters: L * 100,
3446
3446
  centimetres: L * 100,
3447
3447
  degrees: 360 / (2 * Math.PI),
@@ -3458,26 +3458,26 @@ var L = 63710088e-1, Xi = {
3458
3458
  radians: 1,
3459
3459
  yards: L * 1.0936
3460
3460
  };
3461
- function Ki(s, t, e = {}) {
3461
+ function $i(s, t, e = {}) {
3462
3462
  const i = { type: "Feature" };
3463
3463
  return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = s, i;
3464
3464
  }
3465
- function Yi(s, t, e = {}) {
3465
+ function Hi(s, t, e = {}) {
3466
3466
  if (!s)
3467
3467
  throw new Error("coordinates is required");
3468
3468
  if (!Array.isArray(s))
3469
3469
  throw new Error("coordinates must be an Array");
3470
3470
  if (s.length < 2)
3471
3471
  throw new Error("coordinates must be at least 2 numbers long");
3472
- if (!te(s[0]) || !te(s[1]))
3472
+ if (!ee(s[0]) || !ee(s[1]))
3473
3473
  throw new Error("coordinates must contain numbers");
3474
- return Ki({
3474
+ return $i({
3475
3475
  type: "Point",
3476
3476
  coordinates: s
3477
3477
  }, t, e);
3478
3478
  }
3479
- function $i(s, t = "kilometers") {
3480
- const e = Xi[t];
3479
+ function qi(s, t = "kilometers") {
3480
+ const e = Yi[t];
3481
3481
  if (!e)
3482
3482
  throw new Error(t + " units is invalid");
3483
3483
  return s * e;
@@ -3485,60 +3485,60 @@ function $i(s, t = "kilometers") {
3485
3485
  function gt(s) {
3486
3486
  return s % 360 * Math.PI / 180;
3487
3487
  }
3488
- function te(s) {
3488
+ function ee(s) {
3489
3489
  return !isNaN(s) && s !== null && !Array.isArray(s);
3490
3490
  }
3491
- function je(s, t, e) {
3491
+ function Be(s, t, e) {
3492
3492
  if (s !== null)
3493
- for (var i, o, r, n, a, l, d, h = 0, c = 0, u, p = s.type, y = p === "FeatureCollection", g = p === "Feature", v = y ? s.features.length : 1, f = 0; f < v; f++) {
3493
+ for (var i, o, r, n, a, l, d, c = 0, h = 0, u, p = s.type, y = p === "FeatureCollection", g = p === "Feature", v = y ? s.features.length : 1, f = 0; f < v; f++) {
3494
3494
  d = y ? s.features[f].geometry : g ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
3495
3495
  for (var m = 0; m < a; m++) {
3496
3496
  var C = 0, P = 0;
3497
3497
  if (n = u ? d.geometries[m] : d, n !== null) {
3498
3498
  l = n.coordinates;
3499
3499
  var S = n.type;
3500
- switch (h = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
3500
+ switch (c = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
3501
3501
  case null:
3502
3502
  break;
3503
3503
  case "Point":
3504
3504
  if (t(
3505
3505
  l,
3506
- c,
3506
+ h,
3507
3507
  f,
3508
3508
  C,
3509
3509
  P
3510
3510
  ) === !1)
3511
3511
  return !1;
3512
- c++, C++;
3512
+ h++, C++;
3513
3513
  break;
3514
3514
  case "LineString":
3515
3515
  case "MultiPoint":
3516
3516
  for (i = 0; i < l.length; i++) {
3517
3517
  if (t(
3518
3518
  l[i],
3519
- c,
3519
+ h,
3520
3520
  f,
3521
3521
  C,
3522
3522
  P
3523
3523
  ) === !1)
3524
3524
  return !1;
3525
- c++, S === "MultiPoint" && C++;
3525
+ h++, S === "MultiPoint" && C++;
3526
3526
  }
3527
3527
  S === "LineString" && C++;
3528
3528
  break;
3529
3529
  case "Polygon":
3530
3530
  case "MultiLineString":
3531
3531
  for (i = 0; i < l.length; i++) {
3532
- for (o = 0; o < l[i].length - h; o++) {
3532
+ for (o = 0; o < l[i].length - c; o++) {
3533
3533
  if (t(
3534
3534
  l[i][o],
3535
- c,
3535
+ h,
3536
3536
  f,
3537
3537
  C,
3538
3538
  P
3539
3539
  ) === !1)
3540
3540
  return !1;
3541
- c++;
3541
+ h++;
3542
3542
  }
3543
3543
  S === "MultiLineString" && C++, S === "Polygon" && P++;
3544
3544
  }
@@ -3547,16 +3547,16 @@ function je(s, t, e) {
3547
3547
  case "MultiPolygon":
3548
3548
  for (i = 0; i < l.length; i++) {
3549
3549
  for (P = 0, o = 0; o < l[i].length; o++) {
3550
- for (r = 0; r < l[i][o].length - h; r++) {
3550
+ for (r = 0; r < l[i][o].length - c; r++) {
3551
3551
  if (t(
3552
3552
  l[i][o][r],
3553
- c,
3553
+ h,
3554
3554
  f,
3555
3555
  C,
3556
3556
  P
3557
3557
  ) === !1)
3558
3558
  return !1;
3559
- c++;
3559
+ h++;
3560
3560
  }
3561
3561
  P++;
3562
3562
  }
@@ -3565,7 +3565,7 @@ function je(s, t, e) {
3565
3565
  break;
3566
3566
  case "GeometryCollection":
3567
3567
  for (i = 0; i < n.geometries.length; i++)
3568
- if (je(n.geometries[i], t) === !1)
3568
+ if (Be(n.geometries[i], t) === !1)
3569
3569
  return !1;
3570
3570
  break;
3571
3571
  default:
@@ -3575,17 +3575,17 @@ function je(s, t, e) {
3575
3575
  }
3576
3576
  }
3577
3577
  }
3578
- function Hi(s, t) {
3579
- var e, i, o, r, n, a, l, d, h, c, u = 0, p = s.type === "FeatureCollection", y = s.type === "Feature", g = p ? s.features.length : 1;
3578
+ function Ji(s, t) {
3579
+ var e, i, o, r, n, a, l, d, c, h, u = 0, p = s.type === "FeatureCollection", y = s.type === "Feature", g = p ? s.features.length : 1;
3580
3580
  for (e = 0; e < g; e++) {
3581
- for (a = p ? s.features[e].geometry : y ? s.geometry : s, d = p ? s.features[e].properties : y ? s.properties : {}, h = p ? s.features[e].bbox : y ? s.bbox : void 0, c = p ? s.features[e].id : y ? s.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
3581
+ for (a = p ? s.features[e].geometry : y ? s.geometry : s, d = p ? s.features[e].properties : y ? s.properties : {}, c = p ? s.features[e].bbox : y ? s.bbox : void 0, h = p ? s.features[e].id : y ? s.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
3582
3582
  if (r = l ? a.geometries[o] : a, r === null) {
3583
3583
  if (t(
3584
3584
  null,
3585
3585
  u,
3586
3586
  d,
3587
- h,
3588
- c
3587
+ c,
3588
+ h
3589
3589
  ) === !1)
3590
3590
  return !1;
3591
3591
  continue;
@@ -3601,8 +3601,8 @@ function Hi(s, t) {
3601
3601
  r,
3602
3602
  u,
3603
3603
  d,
3604
- h,
3605
- c
3604
+ c,
3605
+ h
3606
3606
  ) === !1)
3607
3607
  return !1;
3608
3608
  break;
@@ -3613,8 +3613,8 @@ function Hi(s, t) {
3613
3613
  r.geometries[i],
3614
3614
  u,
3615
3615
  d,
3616
- h,
3617
- c
3616
+ c,
3617
+ h
3618
3618
  ) === !1)
3619
3619
  return !1;
3620
3620
  break;
@@ -3626,9 +3626,9 @@ function Hi(s, t) {
3626
3626
  u++;
3627
3627
  }
3628
3628
  }
3629
- function qi(s, t, e) {
3629
+ function Zi(s, t, e) {
3630
3630
  var i = e;
3631
- return Hi(
3631
+ return Ji(
3632
3632
  s,
3633
3633
  function(o, r, n, a, l) {
3634
3634
  r === 0 && e === void 0 ? i = o : i = t(
@@ -3642,21 +3642,21 @@ function qi(s, t, e) {
3642
3642
  }
3643
3643
  ), i;
3644
3644
  }
3645
- function Ji(s) {
3646
- return qi(
3645
+ function Qi(s) {
3646
+ return Zi(
3647
3647
  s,
3648
- (t, e) => t + Zi(e),
3648
+ (t, e) => t + to(e),
3649
3649
  0
3650
3650
  );
3651
3651
  }
3652
- function Zi(s) {
3652
+ function to(s) {
3653
3653
  let t = 0, e;
3654
3654
  switch (s.type) {
3655
3655
  case "Polygon":
3656
- return ee(s.coordinates);
3656
+ return ie(s.coordinates);
3657
3657
  case "MultiPolygon":
3658
3658
  for (e = 0; e < s.coordinates.length; e++)
3659
- t += ee(s.coordinates[e]);
3659
+ t += ie(s.coordinates[e]);
3660
3660
  return t;
3661
3661
  case "Point":
3662
3662
  case "MultiPoint":
@@ -3666,17 +3666,17 @@ function Zi(s) {
3666
3666
  }
3667
3667
  return 0;
3668
3668
  }
3669
- function ee(s) {
3669
+ function ie(s) {
3670
3670
  let t = 0;
3671
3671
  if (s && s.length > 0) {
3672
- t += Math.abs(ie(s[0]));
3672
+ t += Math.abs(oe(s[0]));
3673
3673
  for (let e = 1; e < s.length; e++)
3674
- t -= Math.abs(ie(s[e]));
3674
+ t -= Math.abs(oe(s[e]));
3675
3675
  }
3676
3676
  return t;
3677
3677
  }
3678
- var Qi = L * L / 2, Et = Math.PI / 180;
3679
- function ie(s) {
3678
+ var eo = L * L / 2, Et = Math.PI / 180;
3679
+ function oe(s) {
3680
3680
  const t = s.length - 1;
3681
3681
  if (t <= 2) return 0;
3682
3682
  let e = 0, i = 0;
@@ -3684,18 +3684,18 @@ function ie(s) {
3684
3684
  const o = s[i], r = s[i + 1 === t ? 0 : i + 1], n = s[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Et, l = r[1] * Et, d = n[0] * Et;
3685
3685
  e += (d - a) * Math.sin(l), i++;
3686
3686
  }
3687
- return e * Qi;
3687
+ return e * eo;
3688
3688
  }
3689
- var to = Ji;
3690
- const eo = (s, t) => {
3689
+ var io = Qi;
3690
+ const oo = (s, t) => {
3691
3691
  let e = s, i = "m²";
3692
3692
  return t === "metric" ? s >= 1e6 ? (e = s / 1e6, i = "km²") : s >= 1e4 && (e = s / 1e4, i = "ha") : s >= 258998811e-2 ? (e = s / 258998811e-2, i = "mi²") : s >= 4046.856 ? (e = s / 4046.856, i = "acre") : s >= 0.83612736 && (e = s / 0.83612736, i = "yd²"), { area: e, unit: i };
3693
- }, oe = (s, t, e) => {
3693
+ }, se = (s, t, e) => {
3694
3694
  if (s.geometry.type !== "Polygon") return s;
3695
- const i = to(s.geometry), o = eo(i, t);
3695
+ const i = io(s.geometry), o = oo(i, t);
3696
3696
  return o.area = parseFloat(o.area.toFixed(e)), s.properties.area = o.area, s.properties.unit = o.unit, s;
3697
3697
  };
3698
- function se(s) {
3698
+ function re(s) {
3699
3699
  if (!s)
3700
3700
  throw new Error("coord is required");
3701
3701
  if (!Array.isArray(s)) {
@@ -3708,52 +3708,87 @@ function se(s) {
3708
3708
  return [...s];
3709
3709
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
3710
3710
  }
3711
- function io(s, t, e = {}) {
3712
- var i = se(s), o = se(t), r = gt(o[1] - i[1]), n = gt(o[0] - i[0]), a = gt(i[1]), l = gt(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3713
- return $i(
3711
+ function so(s, t, e = {}) {
3712
+ var i = re(s), o = re(t), r = gt(o[1] - i[1]), n = gt(o[0] - i[0]), a = gt(i[1]), l = gt(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3713
+ return qi(
3714
3714
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3715
3715
  e.units
3716
3716
  );
3717
3717
  }
3718
- var oo = io;
3719
- const so = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians" ? "rad" : "km", re = (s, t, e, i, o, r) => {
3718
+ var ro = so;
3719
+ const ne = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians" ? "rad" : "km", Ot = (s) => {
3720
+ if (s >= 1)
3721
+ return {
3722
+ distance: s,
3723
+ unit: "km"
3724
+ };
3725
+ const t = s * 1e3;
3726
+ return t >= 1 ? {
3727
+ distance: t,
3728
+ unit: "m"
3729
+ } : {
3730
+ distance: t * 100,
3731
+ unit: "cm"
3732
+ };
3733
+ }, ae = (s, t, e, i, o, r) => {
3720
3734
  if (s.geometry.type !== "LineString") return s;
3721
3735
  const n = s.geometry.coordinates;
3722
3736
  let a = 0;
3723
3737
  const l = [];
3724
3738
  for (let d = 0; d < n.length - 1; d++) {
3725
- const h = n[d], c = n[d + 1], u = oo(h, c, { units: t });
3739
+ const c = n[d], h = n[d + 1], u = ro(c, h, { units: t });
3726
3740
  a += u;
3727
3741
  const p = JSON.parse(JSON.stringify(s));
3728
- if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [h, c], p.properties.originalId = s.id, p.properties.distance = parseFloat(u.toFixed(e)), p.properties.total = parseFloat(a.toFixed(e)), p.properties.unit = so(t), o === !0 && r === void 0) {
3729
- const y = i == null ? void 0 : i.queryTerrainElevation(h);
3742
+ if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [c, h], p.properties.originalId = s.id, p.properties.distance = u, p.properties.total = a, p.properties.unit = ne(t), p.properties.totalUnit = ne(t), o === !0 && r === void 0) {
3743
+ const y = i == null ? void 0 : i.queryTerrainElevation(c);
3730
3744
  y && (p.properties.elevation_start = y);
3731
- const g = i == null ? void 0 : i.queryTerrainElevation(c);
3745
+ const g = i == null ? void 0 : i.queryTerrainElevation(h);
3732
3746
  g && (p.properties.elevation_end = g);
3733
3747
  }
3734
3748
  l.push(p);
3735
3749
  }
3736
- return s.properties.distance = l[l.length - 1].properties.total, s.properties.unit = l[l.length - 1].properties.unit, s.properties.segments = JSON.parse(JSON.stringify(l)), s;
3737
- }, ne = (s) => s.charAt(0).toUpperCase() + s.slice(1), It = ["td-point", "td-linestring", "td-polygon"];
3738
- var de, he, ce;
3739
- const Oo = [
3750
+ if (s.properties.distance = l[l.length - 1].properties.total, s.properties.unit = l[l.length - 1].properties.unit, s.properties.segments = JSON.parse(JSON.stringify(l)), t === "kilometers") {
3751
+ const d = Ot(s.properties.distance);
3752
+ s.properties.distance = d.distance, s.properties.unit = d.unit, s.properties.segments.forEach(
3753
+ (c) => {
3754
+ const h = Ot(c.properties.distance);
3755
+ c.properties.distance = h.distance, c.properties.unit = h.unit;
3756
+ const u = Ot(c.properties.total);
3757
+ c.properties.total = u.distance, c.properties.totalUnit = u.unit;
3758
+ }
3759
+ );
3760
+ }
3761
+ return s.properties.distance = parseFloat(
3762
+ s.properties.distance.toFixed(e)
3763
+ ), s.properties.segments.forEach(
3764
+ (d) => {
3765
+ d.properties.distance = parseFloat(
3766
+ d.properties.distance.toFixed(e)
3767
+ ), d.properties.total = parseFloat(
3768
+ d.properties.total.toFixed(e)
3769
+ );
3770
+ }
3771
+ ), s;
3772
+ }, le = (s) => s.charAt(0).toUpperCase() + s.slice(1), It = ["td-point", "td-linestring", "td-polygon"];
3773
+ var he, ue, pe;
3774
+ const Do = [
3740
3775
  ...It,
3741
- (de = yt.polygonLayerSpec) == null ? void 0 : de.source,
3742
- (he = yt.lineLayerLabelSpec) == null ? void 0 : he.source,
3743
- (ce = yt.pointLayerLabelSpec) == null ? void 0 : ce.source
3744
- ], We = (s, t, e = It) => {
3776
+ (he = yt.polygonLayerSpec) == null ? void 0 : he.source,
3777
+ (ue = yt.lineLayerLabelSpec) == null ? void 0 : ue.source,
3778
+ (pe = yt.pointLayerLabelSpec) == null ? void 0 : pe.source
3779
+ ], Ne = (s, t, e = It) => {
3745
3780
  const i = JSON.parse(JSON.stringify(s));
3746
3781
  return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
3747
3782
  e.includes(o) || delete i.sources[o];
3748
3783
  })) : t.excludeTerraDrawLayers === !0 && (i.layers = i.layers.filter((o) => "source" in o && !e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
3749
3784
  e.includes(o) && delete i.sources[o];
3750
3785
  }))), i;
3751
- }, ro = (s, t = 250) => {
3786
+ }, no = (s, t = 250) => {
3752
3787
  let e;
3753
3788
  return (...i) => {
3754
3789
  clearTimeout(e), e = setTimeout(() => s(...i), t);
3755
3790
  };
3756
- }, ae = (s, t, e, i) => {
3791
+ }, de = (s, t, e, i) => {
3757
3792
  if (s.geometry.type !== "Point") return s;
3758
3793
  const o = s.geometry.coordinates;
3759
3794
  if (e === !0 && i === void 0) {
@@ -3762,58 +3797,58 @@ const Oo = [
3762
3797
  }
3763
3798
  return s;
3764
3799
  };
3765
- var no = Object.defineProperty, ao = (s, t, e) => t in s ? no(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, tt = (s, t, e) => ao(s, typeof t != "symbol" ? t + "" : t, e), Pt = 2 * Math.PI * 6378137 / 2;
3766
- function lo(s) {
3800
+ var ao = Object.defineProperty, lo = (s, t, e) => t in s ? ao(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, tt = (s, t, e) => lo(s, typeof t != "symbol" ? t + "" : t, e), Pt = 2 * Math.PI * 6378137 / 2;
3801
+ function co(s) {
3767
3802
  return s = s || 256, 2 * Math.PI * 6378137 / s;
3768
3803
  }
3769
3804
  function ho(s, t, e = { enable: !0, decimal: 1 }) {
3770
- s = jt(s);
3805
+ s = Wt(s);
3771
3806
  var i = s[0], o = s[1], r = i * Pt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
3772
3807
  return n = n * Pt / 180, e.enable && (r = Number(r.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [r, n];
3773
3808
  }
3774
- function co(s, t, e) {
3775
- var i = s[0], o = s[1], r = mo(t, e), n = (i + Pt) / r, a = (o + Pt) / r;
3809
+ function uo(s, t, e) {
3810
+ var i = s[0], o = s[1], r = vo(t, e), n = (i + Pt) / r, a = (o + Pt) / r;
3776
3811
  return [n, a, t];
3777
3812
  }
3778
- function Be(s, t, e) {
3779
- s = jt(s);
3780
- var i = ho(s), o = co(i, t);
3781
- return po(o);
3813
+ function Ge(s, t, e) {
3814
+ s = Wt(s);
3815
+ var i = ho(s), o = uo(i, t);
3816
+ return go(o);
3782
3817
  }
3783
- function uo(s, t, e) {
3784
- if (s = jt(s), t === 0)
3818
+ function po(s, t, e) {
3819
+ if (s = Wt(s), t === 0)
3785
3820
  return [0, 0, 0];
3786
- var i = Be(s, t);
3787
- return go(i);
3821
+ var i = Ge(s, t);
3822
+ return yo(i);
3788
3823
  }
3789
- function po(s, t, e) {
3824
+ function go(s, t, e) {
3790
3825
  t = t || 256;
3791
3826
  var i = s[0], o = s[1], r = s[2];
3792
3827
  if (r === 0) return [0, 0, 0];
3793
- Ne(r);
3828
+ Te(r);
3794
3829
  var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
3795
3830
  return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, r];
3796
3831
  }
3797
- function go(s, t) {
3798
- yo(s);
3832
+ function yo(s, t) {
3833
+ fo(s);
3799
3834
  var e = s[0], i = s[1], o = s[2];
3800
3835
  if (o === 0)
3801
3836
  return [0, 0, 0];
3802
3837
  var r = e, n = Math.pow(2, o) - 1 - i;
3803
3838
  return [r, n, o];
3804
3839
  }
3805
- function yo(s, t) {
3840
+ function fo(s, t) {
3806
3841
  var e = s[0], i = s[1], o = s[2];
3807
3842
  if (o == null) throw new Error("<zoom> is required");
3808
3843
  if (e == null) throw new Error("<x> is required");
3809
3844
  if (i == null) throw new Error("<y> is required");
3810
- return o = Ne(o), s = fo(s), s;
3845
+ return o = Te(o), s = mo(s), s;
3811
3846
  }
3812
- function fo(s) {
3847
+ function mo(s) {
3813
3848
  var t = s[0], e = s[1], i = s[2], o = Math.pow(2, i);
3814
3849
  return t = t % o, t < 0 && (t = t + o), [t, e, i];
3815
3850
  }
3816
- function Ne(s) {
3851
+ function Te(s) {
3817
3852
  if (s === !1) return s;
3818
3853
  if (s == null)
3819
3854
  throw new Error("<zoom> is required");
@@ -3823,22 +3858,22 @@ function Ne(s) {
3823
3858
  throw new Error("<zoom> cannot be greater than 32");
3824
3859
  return s;
3825
3860
  }
3826
- function jt(s, t) {
3827
- var e = Co(s[0]), i = vo(s[1]);
3861
+ function Wt(s, t) {
3862
+ var e = Po(s[0]), i = Co(s[1]);
3828
3863
  return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
3829
3864
  }
3830
- function mo(s, t) {
3831
- return lo(t) / Math.pow(2, s);
3865
+ function vo(s, t) {
3866
+ return co(t) / Math.pow(2, s);
3832
3867
  }
3833
- function vo(s) {
3868
+ function Co(s) {
3834
3869
  if (s == null) throw new Error("lat is required");
3835
3870
  return (s > 90 || s < -90) && (s = s % 180, s > 90 && (s = -180 + s), s < -90 && (s = 180 + s), s === 0 && (s = 0)), s;
3836
3871
  }
3837
- function Co(s) {
3872
+ function Po(s) {
3838
3873
  if (s == null) throw new Error("lng is required");
3839
3874
  return (s > 180 || s < -180) && (s = s % 360, s > 180 && (s = -360 + s), s < -180 && (s = 360 + s), s === 0 && (s = 0)), s;
3840
3875
  }
3841
- class Ge {
3876
+ class Ae {
3842
3877
  /**
3843
3878
  * Constructor
3844
3879
  * @param url URL for terrain RGB raster tilesets
@@ -3863,17 +3898,17 @@ class Ge {
3863
3898
  const r = t[0], n = t[1];
3864
3899
  let a = e;
3865
3900
  e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
3866
- const l = this.tms ? Be([r, n], a) : uo([r, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
3867
- let h = this.getUrlExtension(d);
3868
- switch (h || (h = "png"), h) {
3901
+ const l = this.tms ? Ge([r, n], a) : po([r, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
3902
+ let c = this.getUrlExtension(d);
3903
+ switch (c || (c = "png"), c) {
3869
3904
  case "png":
3870
3905
  case "webp":
3871
- this.getValueFromRaster(d, l, r, n).then((c) => {
3872
- i(c);
3906
+ this.getValueFromRaster(d, l, r, n).then((h) => {
3907
+ i(h);
3873
3908
  });
3874
3909
  break;
3875
3910
  default:
3876
- o(new Error(`Invalid file extension: ${h}`));
3911
+ o(new Error(`Invalid file extension: ${c}`));
3877
3912
  break;
3878
3913
  }
3879
3914
  }
@@ -3898,12 +3933,12 @@ class Ge {
3898
3933
  return new Promise((a, l) => {
3899
3934
  const d = new Image();
3900
3935
  d.onload = () => {
3901
- const h = document.createElement("canvas");
3902
- h.width = d.width, h.height = d.height;
3903
- const c = h.getContext("2d");
3904
- if (!c) return l(new Error("Failed to create canvas context"));
3905
- c.drawImage(d, 0, 0);
3906
- const u = c.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), y = this.calc(p[0], p[1], p[2], p[3]);
3936
+ const c = document.createElement("canvas");
3937
+ c.width = d.width, c.height = d.height;
3938
+ const h = c.getContext("2d");
3939
+ if (!h) return l(new Error("Failed to create canvas context"));
3940
+ h.drawImage(d, 0, 0);
3941
+ const u = h.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), y = this.calc(p[0], p[1], p[2], p[3]);
3907
3942
  a(y);
3908
3943
  }, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
3909
3944
  });
@@ -3919,7 +3954,7 @@ class Ge {
3919
3954
  pixels2rgba(t, e, i, o) {
3920
3955
  const r = [];
3921
3956
  for (let d = 0; d < t.length; d += 4) {
3922
- const h = t[d], c = t[d + 1], u = t[d + 2], p = t[d + 3], y = [h, c, u, p];
3957
+ const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], y = [c, h, u, p];
3923
3958
  r.push(y);
3924
3959
  }
3925
3960
  const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
@@ -3933,8 +3968,8 @@ class Ge {
3933
3968
  * @returns The position in pixel
3934
3969
  */
3935
3970
  getPixelPosition(t, e, i) {
3936
- const o = this.tileSize, r = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a, h = Math.floor(o * l), c = Math.floor(r * (1 - d));
3937
- return [h, c];
3971
+ const o = this.tileSize, r = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a, c = Math.floor(o * l), h = Math.floor(r * (1 - d));
3972
+ return [c, h];
3938
3973
  }
3939
3974
  /**
3940
3975
  * Get file extenstion name from the URL
@@ -3965,7 +4000,7 @@ class Ge {
3965
4000
  return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
3966
4001
  }
3967
4002
  }
3968
- class Po extends Ge {
4003
+ class So extends Ae {
3969
4004
  /**
3970
4005
  * Constructor
3971
4006
  * @param url URL for terrain RGB raster tilesets
@@ -3997,7 +4032,7 @@ class Po extends Ge {
3997
4032
  return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
3998
4033
  }
3999
4034
  }
4000
- class So extends Ge {
4035
+ class xo extends Ae {
4001
4036
  /**
4002
4037
  * Constructor
4003
4038
  * @param url URL for terrarium raster tilesets
@@ -4031,22 +4066,22 @@ class So extends Ge {
4031
4066
  return parseInt(o.toFixed(0));
4032
4067
  }
4033
4068
  }
4034
- const le = async (s, t) => {
4069
+ const ce = async (s, t) => {
4035
4070
  const e = [];
4036
4071
  for (const i of s)
4037
4072
  e.push(
4038
4073
  new Promise((o) => {
4039
4074
  if (i.geometry.type !== "Point" && o(i), t) {
4040
- const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15, h = t.tms ?? !1;
4041
- (n === "mapbox" ? new Po(r, a, l, d, h) : new So(r, a, l, d, h)).getElevation(i.geometry.coordinates, d).then((c) => {
4042
- c && (i.properties.elevation = c), o(i);
4075
+ const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15, c = t.tms ?? !1;
4076
+ (n === "mapbox" ? new So(r, a, l, d, c) : new xo(r, a, l, d, c)).getElevation(i.geometry.coordinates, d).then((h) => {
4077
+ h && (i.properties.elevation = h), o(i);
4043
4078
  }).catch(() => o(i));
4044
4079
  } else
4045
4080
  o(i);
4046
4081
  })
4047
4082
  );
4048
4083
  return await Promise.all(e);
4049
- }, Do = (s, t = 9) => {
4084
+ }, _o = (s, t = 9) => {
4050
4085
  function e(o) {
4051
4086
  return [Number(o[0].toFixed(t)), Number(o[1].toFixed(t))];
4052
4087
  }
@@ -4081,7 +4116,7 @@ const le = async (s, t) => {
4081
4116
  geometry: i(o.geometry)
4082
4117
  }));
4083
4118
  };
4084
- class xo {
4119
+ class Io {
4085
4120
  /**
4086
4121
  * Constructor
4087
4122
  * @param options Plugin control options
@@ -4092,7 +4127,7 @@ class xo {
4092
4127
  k(this, "modeButtons", {});
4093
4128
  k(this, "_isExpanded", !1);
4094
4129
  k(this, "terradraw");
4095
- k(this, "options", Ri);
4130
+ k(this, "options", Xi);
4096
4131
  k(this, "events", {});
4097
4132
  k(this, "defaultMode", "render");
4098
4133
  this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
@@ -4136,20 +4171,20 @@ class xo {
4136
4171
  if (this.options && this.options.modes && this.options.modes.length === 0)
4137
4172
  throw new Error("At least a mode must be enabled.");
4138
4173
  this.map = t;
4139
- const e = zi(), i = [];
4174
+ const e = Ki(), i = [];
4140
4175
  return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((d) => {
4141
4176
  if (this.options.modeOptions && this.options.modeOptions[d]) {
4142
- const h = this.options.modeOptions[d];
4177
+ const c = this.options.modeOptions[d];
4143
4178
  if (d === "select") {
4144
- const c = e[d];
4145
- if (c) {
4146
- const u = c.flags;
4179
+ const h = e[d];
4180
+ if (h) {
4181
+ const u = h.flags;
4147
4182
  Object.keys(u).forEach((p) => {
4148
- h.flags[p] || (h.flags[p] = u[p]);
4183
+ c.flags[p] || (c.flags[p] = u[p]);
4149
4184
  });
4150
4185
  }
4151
4186
  }
4152
- i.push(h);
4187
+ i.push(c);
4153
4188
  } else e[d] && i.push(e[d]);
4154
4189
  }), i.forEach((d) => {
4155
4190
  d.state !== "unregistered" && (d._state = "unregistered");
@@ -4158,14 +4193,14 @@ class xo {
4158
4193
  modeName: "default",
4159
4194
  styles: {}
4160
4195
  })
4161
- ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Vi({
4162
- adapter: new Ui({ map: t, ...this.options.adapterOptions }),
4196
+ ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new Ri({
4197
+ adapter: new zi({ map: t, ...this.options.adapterOptions }),
4163
4198
  modes: i
4164
4199
  }), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
4165
4200
  d.mode !== "default" && this.addTerradrawButton(d.mode);
4166
4201
  }), Object.values(this.modeButtons).forEach((d) => {
4167
- var h;
4168
- (h = this.controlContainer) == null || h.appendChild(d);
4202
+ var c;
4203
+ (c = this.controlContainer) == null || c.appendChild(d);
4169
4204
  }), (l = this.terradraw) == null || l.on("change", this.toggleButtonsWhenNoFeature.bind(this)), this.toggleButtonsWhenNoFeature(), this.controlContainer;
4170
4205
  }
4171
4206
  /**
@@ -4256,7 +4291,7 @@ class xo {
4256
4291
  */
4257
4292
  addTerradrawButton(t) {
4258
4293
  const e = document.createElement("button");
4259
- e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = ne("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = ne(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
4294
+ e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = le("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = le(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
4260
4295
  this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
4261
4296
  })) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
4262
4297
  var r;
@@ -4306,7 +4341,7 @@ class xo {
4306
4341
  * @returns
4307
4342
  */
4308
4343
  cleanStyle(t, e) {
4309
- return We(t, e, It);
4344
+ return Ne(t, e, It);
4310
4345
  }
4311
4346
  /**
4312
4347
  * Download button click event handler
@@ -4340,28 +4375,28 @@ class xo {
4340
4375
  var a, l;
4341
4376
  const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, r = o && t && e === "select", n = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
4342
4377
  for (let d = 0; d < n.length; d++) {
4343
- const h = n.item(d);
4344
- h && (r ? h.classList.remove("hidden-delete-selection") : h.classList.add("hidden-delete-selection"));
4378
+ const c = n.item(d);
4379
+ c && (r ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
4345
4380
  }
4346
4381
  if (!o) {
4347
4382
  const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
4348
- for (let h = 0; h < d.length; h++) {
4349
- const c = d.item(h);
4350
- c && c.classList.remove("active");
4383
+ for (let c = 0; c < d.length; c++) {
4384
+ const h = d.item(c);
4385
+ h && h.classList.remove("active");
4351
4386
  }
4352
4387
  }
4353
4388
  }
4354
4389
  }
4355
- function Io(s, t = {}) {
4390
+ function bo(s, t = {}) {
4356
4391
  let e = 0, i = 0, o = 0;
4357
- return je(
4392
+ return Be(
4358
4393
  s,
4359
4394
  function(r) {
4360
4395
  e += r[0], i += r[1], o++;
4361
4396
  }
4362
- ), Yi([e / o, i / o], t.properties);
4397
+ ), Hi([e / o, i / o], t.properties);
4363
4398
  }
4364
- class _o extends xo {
4399
+ class Lo extends Io {
4365
4400
  /**
4366
4401
  * Constructor
4367
4402
  * @param options Plugin control options
@@ -4400,7 +4435,7 @@ class _o extends xo {
4400
4435
  * Handle finish event of terradraw. It will be called after finishing adding a feature
4401
4436
  * @param id Feature ID
4402
4437
  */
4403
- k(this, "handleTerradrawFeatureReady", ro((e) => {
4438
+ k(this, "handleTerradrawFeatureReady", no((e) => {
4404
4439
  this.map && (this.computeElevationByLineFeatureID(e), this.computeElevationByPointFeatureID(e));
4405
4440
  }, 300));
4406
4441
  /**
@@ -4418,7 +4453,7 @@ class _o extends xo {
4418
4453
  }
4419
4454
  );
4420
4455
  if (o && o.length > 0) {
4421
- const r = await le(
4456
+ const r = await ce(
4422
4457
  o,
4423
4458
  this.measureOptions.terrainSource
4424
4459
  );
@@ -4446,7 +4481,7 @@ class _o extends xo {
4446
4481
  }
4447
4482
  );
4448
4483
  if (o && o.length > 0) {
4449
- const r = await le(
4484
+ const r = await ce(
4450
4485
  o,
4451
4486
  this.measureOptions.terrainSource
4452
4487
  );
@@ -4575,13 +4610,13 @@ class _o extends xo {
4575
4610
  * @returns
4576
4611
  */
4577
4612
  cleanStyle(e, i) {
4578
- var l, d, h;
4613
+ var l, d, c;
4579
4614
  const o = It, r = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
4580
4615
  r && o.push(r);
4581
4616
  const n = (d = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : d.source;
4582
4617
  n && o.push(n);
4583
- const a = (h = this.measureOptions.pointLayerLabelSpec) == null ? void 0 : h.source;
4584
- return a && o.push(a), We(e, i, o);
4618
+ const a = (c = this.measureOptions.pointLayerLabelSpec) == null ? void 0 : c.source;
4619
+ return a && o.push(a), Ne(e, i, o);
4585
4620
  }
4586
4621
  /**
4587
4622
  * Register measure control related maplibre sources and layers
@@ -4651,10 +4686,10 @@ class _o extends xo {
4651
4686
  if (!n) return;
4652
4687
  const a = n.getSnapshot();
4653
4688
  for (const l of e) {
4654
- const d = a.find((h) => h.id === l);
4689
+ const d = a.find((c) => c.id === l);
4655
4690
  if (d) {
4656
- const h = d.geometry.type, c = d.properties.mode;
4657
- c === "linestring" && h === "LineString" ? this.measureLine(l) : c === "point" && h === "Point" ? this.measurePoint(l) : !["point", "linestring", "select", "render"].includes(c) && h === "Polygon" && this.measurePolygon(l);
4691
+ const c = d.geometry.type, h = d.properties.mode;
4692
+ h === "linestring" && c === "LineString" ? this.measureLine(l) : h === "point" && c === "Point" ? this.measurePoint(l) : !["point", "linestring", "select", "render"].includes(h) && c === "Polygon" && this.measurePolygon(l);
4658
4693
  } else
4659
4694
  this.clearMeasureFeatures(r, [l]);
4660
4695
  }
@@ -4706,30 +4741,30 @@ class _o extends xo {
4706
4741
  const r = this.map.getStyle().sources[i];
4707
4742
  if (r && typeof r.data != "string" && r.data.type === "FeatureCollection") {
4708
4743
  const l = [];
4709
- for (const h of e)
4710
- (n = this.terradraw) != null && n.getSnapshotFeature(h.id) && l.push(h);
4711
- const d = l.map((h) => h.id);
4744
+ for (const c of e)
4745
+ (n = this.terradraw) != null && n.getSnapshotFeature(c.id) && l.push(c);
4746
+ const d = l.map((c) => c.id);
4712
4747
  if (typeof r.data != "string" && r.data.type === "FeatureCollection") {
4713
4748
  o === "linestring" ? r.data.features = [
4714
4749
  ...r.data.features = r.data.features.filter(
4715
- (c) => {
4750
+ (h) => {
4716
4751
  var u;
4717
- return !(d.includes((u = c.properties) == null ? void 0 : u.originalId) && c.geometry.type === "Point");
4752
+ return !(d.includes((u = h.properties) == null ? void 0 : u.originalId) && h.geometry.type === "Point");
4718
4753
  }
4719
4754
  ),
4720
4755
  ...l
4721
4756
  ] : o === "point" && (r.data.features = [
4722
4757
  ...r.data.features = r.data.features.filter(
4723
- (c) => !(d.includes(c.id) && c.geometry.type === "Point")
4758
+ (h) => !(d.includes(h.id) && h.geometry.type === "Point")
4724
4759
  ),
4725
4760
  ...l
4726
4761
  ]);
4727
- const h = {};
4728
- r.data.features.forEach((c) => {
4762
+ const c = {};
4763
+ r.data.features.forEach((h) => {
4729
4764
  var p;
4730
- const u = c.id;
4731
- h[u] ? !h[u].properties.elevation && ((p = c.properties) != null && p.elevation) && (h[u] = c) : h[u] = c;
4732
- }), r.data.features = Array.from(Object.values(h)), (a = this.map.getSource(i)) == null || a.setData(r.data);
4765
+ const u = h.id;
4766
+ c[u] ? !c[u].properties.elevation && ((p = h.properties) != null && p.elevation) && (c[u] = h) : c[u] = h;
4767
+ }), r.data.features = Array.from(Object.values(c)), (a = this.map.getSource(i)) == null || a.setData(r.data);
4733
4768
  }
4734
4769
  }
4735
4770
  }
@@ -4749,12 +4784,12 @@ class _o extends xo {
4749
4784
  if (a) {
4750
4785
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
4751
4786
  (d) => {
4752
- var h;
4753
- return ((h = d.properties) == null ? void 0 : h.originalId) !== e;
4787
+ var c;
4788
+ return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
4754
4789
  }
4755
4790
  ));
4756
4791
  const l = JSON.parse(JSON.stringify(r));
4757
- l.id = l.id + "-area-label", l.geometry = Io(r.geometry).geometry, l.properties.originalId = r.id, r = oe(r, this.areaUnit, this.areaPrecision), l.properties.area = r.properties.area, l.properties.unit = r.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (n = this.map.getSource(
4792
+ l.id = l.id + "-area-label", l.geometry = bo(r.geometry).geometry, l.properties.originalId = r.id, r = se(r, this.areaUnit, this.areaPrecision), l.properties.area = r.properties.area, l.properties.unit = r.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (n = this.map.getSource(
4758
4793
  this.measureOptions.polygonLayerSpec.source
4759
4794
  )) == null || n.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
4760
4795
  this.measureOptions.lineLayerLabelSpec.id
@@ -4784,10 +4819,10 @@ class _o extends xo {
4784
4819
  if (a) {
4785
4820
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
4786
4821
  (d) => {
4787
- var h;
4788
- return ((h = d.properties) == null ? void 0 : h.originalId) !== e;
4822
+ var c;
4823
+ return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
4789
4824
  }
4790
- )), r = re(
4825
+ )), r = ae(
4791
4826
  r,
4792
4827
  this.distanceUnit,
4793
4828
  this.distancePrecision,
@@ -4797,21 +4832,21 @@ class _o extends xo {
4797
4832
  );
4798
4833
  const l = r.properties.segments;
4799
4834
  for (let d = 0; d < l.length; d++) {
4800
- const h = l[d];
4801
- typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(h);
4802
- const c = h.geometry.coordinates, u = c[0], p = c[1];
4835
+ const c = l[d];
4836
+ typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
4837
+ const h = c.geometry.coordinates, u = h[0], p = h[1];
4803
4838
  if (d === 0) {
4804
- const g = JSON.parse(JSON.stringify(h));
4805
- g.id = `${h.id}-node-${d}`, g.geometry = {
4839
+ const g = JSON.parse(JSON.stringify(c));
4840
+ g.id = `${c.id}-node-${d}`, g.geometry = {
4806
4841
  type: "Point",
4807
4842
  coordinates: u
4808
- }, g.properties.distance = 0, g.properties.total = 0, h.properties.elevation_start && (g.properties.elevation = h.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
4843
+ }, g.properties.distance = 0, g.properties.total = 0, c.properties.elevation_start && (g.properties.elevation = c.properties.elevation_start), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(g);
4809
4844
  }
4810
- const y = JSON.parse(JSON.stringify(h));
4811
- y.id = `${h.id}-node-${d + 1}`, y.geometry = {
4845
+ const y = JSON.parse(JSON.stringify(c));
4846
+ y.id = `${c.id}-node-${d + 1}`, y.geometry = {
4812
4847
  type: "Point",
4813
4848
  coordinates: p
4814
- }, h.properties.elevation_end && (y.properties.elevation = h.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
4849
+ }, c.properties.elevation_end && (y.properties.elevation = c.properties.elevation_end), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(y);
4815
4850
  }
4816
4851
  (n = this.map.getSource(
4817
4852
  this.measureOptions.lineLayerLabelSpec.source
@@ -4836,7 +4871,7 @@ class _o extends xo {
4836
4871
  let r = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Point");
4837
4872
  if (r) {
4838
4873
  const a = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
4839
- a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter((l) => l.id !== e)), r = ae(
4874
+ a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter((l) => l.id !== e)), r = de(
4840
4875
  r,
4841
4876
  this.map,
4842
4877
  this.computeElevation,
@@ -4881,14 +4916,14 @@ class _o extends xo {
4881
4916
  const r = i.features[o];
4882
4917
  if (!this.map || !this.map.loaded()) continue;
4883
4918
  const n = r.geometry.type;
4884
- n === "LineString" ? i.features[o] = re(
4919
+ n === "LineString" ? i.features[o] = ae(
4885
4920
  r,
4886
4921
  this.distanceUnit,
4887
4922
  this.distancePrecision,
4888
4923
  this.map,
4889
4924
  this.computeElevation,
4890
4925
  this.measureOptions.terrainSource
4891
- ) : n === "Polygon" ? i.features[o] = oe(r, this.areaUnit, this.areaPrecision) : n === "Point" && (i.features[o] = ae(
4926
+ ) : n === "Polygon" ? i.features[o] = se(r, this.areaUnit, this.areaPrecision) : n === "Point" && (i.features[o] = de(
4892
4927
  r,
4893
4928
  this.map,
4894
4929
  this.computeElevation,
@@ -4899,23 +4934,24 @@ class _o extends xo {
4899
4934
  }
4900
4935
  }
4901
4936
  export {
4902
- Eo as AvailableModes,
4903
- _o as MaplibreMeasureControl,
4904
- xo as MaplibreTerradrawControl,
4905
- Oo as TERRADRAW_MEASURE_SOURCE_IDS,
4937
+ Oo as AvailableModes,
4938
+ Lo as MaplibreMeasureControl,
4939
+ Io as MaplibreTerradrawControl,
4940
+ Do as TERRADRAW_MEASURE_SOURCE_IDS,
4906
4941
  It as TERRADRAW_SOURCE_IDS,
4907
- oe as calcArea,
4908
- re as calcDistance,
4909
- ne as capitalize,
4910
- We as cleanMaplibreStyle,
4911
- eo as convertAreaUnit,
4912
- ro as debounce,
4913
- Ri as defaultControlOptions,
4942
+ se as calcArea,
4943
+ ae as calcDistance,
4944
+ le as capitalize,
4945
+ Ne as cleanMaplibreStyle,
4946
+ oo as convertAreaUnit,
4947
+ Ot as convertMetricDistance,
4948
+ no as debounce,
4949
+ Xi as defaultControlOptions,
4914
4950
  yt as defaultMeasureControlOptions,
4915
- zi as getDefaultModeOptions,
4916
- so as getDistanceUnitName,
4917
- ae as queryElevationByPoint,
4918
- le as queryElevationFromRasterDEM,
4919
- Do as roundFeatureCoordinates
4951
+ Ki as getDefaultModeOptions,
4952
+ ne as getDistanceUnitName,
4953
+ de as queryElevationByPoint,
4954
+ ce as queryElevationFromRasterDEM,
4955
+ _o as roundFeatureCoordinates
4920
4956
  };
4921
4957
  //# sourceMappingURL=maplibre-gl-terradraw.es.js.map