@watergis/maplibre-gl-terradraw 1.3.10 → 1.3.11

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.
@@ -15,7 +15,7 @@ var M;
15
15
  (function(s) {
16
16
  s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
17
17
  })(M || (M = {}));
18
- const T = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, V = "edited", st = "closingPoint", _t = "snappingPoint", kt = "coordinatePoint", rt = "coordinatePointIds";
18
+ const T = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, V = "edited", rt = "closingPoint", _t = "snappingPoint", kt = "coordinatePoint", nt = "coordinatePointIds";
19
19
  function wt(s) {
20
20
  return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
21
21
  }
@@ -181,7 +181,7 @@ function Bt(s) {
181
181
  }
182
182
  function o(r, n, a, l) {
183
183
  const d = t[r][n], h = t[r][n + 1], c = t[a][l], u = t[a][l + 1], p = function(m, v, f, C) {
184
- if (ct(m, f) || ct(m, C) || ct(v, f) || ct(C, f)) return null;
184
+ if (ut(m, f) || ut(m, C) || ut(v, f) || ut(C, f)) return null;
185
185
  const P = m[0], S = m[1], b = v[0], w = v[1], D = f[0], G = f[1], L = C[0], j = C[1], z = (P - b) * (G - j) - (S - w) * (D - L);
186
186
  return z === 0 ? null : [((P * w - S * b) * (D - L) - (P - b) * (D * j - G * L)) / z, ((P * w - S * b) * (G - j) - (S - w) * (D * j - G * L)) / z];
187
187
  }(d, h, c, u);
@@ -190,7 +190,7 @@ function Bt(s) {
190
190
  g = h[0] !== d[0] ? (p[0] - d[0]) / (h[0] - d[0]) : (p[1] - d[1]) / (h[1] - d[1]), y = u[0] !== c[0] ? (p[0] - c[0]) / (u[0] - c[0]) : (p[1] - c[1]) / (u[1] - c[1]), i(g) || i(y) || (p.toString(), e.push(p));
191
191
  }
192
192
  }
193
- function ct(s, t) {
193
+ function ut(s, t) {
194
194
  return s[0] === t[0] && s[1] === t[1];
195
195
  }
196
196
  function It(s, t) {
@@ -217,7 +217,7 @@ function bt(s, t) {
217
217
  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: Qe } : { valid: !0 };
218
218
  var e, i;
219
219
  }
220
- function dt(s, t) {
220
+ function ht(s, t) {
221
221
  const e = bt(s, t);
222
222
  return e.valid ? Bt(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
223
223
  }
@@ -278,7 +278,7 @@ class Ce extends N {
278
278
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (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;
279
279
  }
280
280
  validateFeature(t) {
281
- return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
281
+ return this.validateModeFeature(t, (e) => ht(e, this.coordinatePrecision));
282
282
  }
283
283
  updateCircle(t) {
284
284
  if (this.clickCount === 1 && this.center && this.currentCircleId) {
@@ -312,7 +312,7 @@ const E = (s, t) => {
312
312
  const { x: e, y: i } = s, { x: o, y: r } = t, n = o - e, a = r - i;
313
313
  return Math.sqrt(a * a + n * n);
314
314
  };
315
- function ht(s) {
315
+ function ct(s) {
316
316
  if (!function(e) {
317
317
  const i = e.coordinates[0];
318
318
  let o = 0;
@@ -334,7 +334,7 @@ class Pe extends N {
334
334
  close() {
335
335
  if (this.currentId === void 0) return;
336
336
  if (this.currentId) {
337
- const e = ht(this.store.getGeometryCopy(this.currentId));
337
+ const e = ct(this.store.getGeometryCopy(this.currentId));
338
338
  e && this.store.updateGeometry([{ id: this.currentId, geometry: e }]);
339
339
  }
340
340
  const t = this.currentId;
@@ -366,7 +366,7 @@ class Pe extends N {
366
366
  onClick(t) {
367
367
  if (!this.preventNewFeature) {
368
368
  if (this.startingClick === !1) {
369
- const [e, i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode } }, { geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: { mode: this.mode, [st]: !0 } }]);
369
+ const [e, i] = this.store.create([{ geometry: { type: "Polygon", coordinates: [[[t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat], [t.lng, t.lat]]] }, properties: { mode: this.mode } }, { geometry: { type: "Point", coordinates: [t.lng, t.lat] }, properties: { mode: this.mode, [rt]: !0 } }]);
370
370
  return this.currentId = e, this.closingPointId = i, this.startingClick = !0, void this.setDrawing();
371
371
  }
372
372
  this.close();
@@ -408,7 +408,7 @@ function Se({ unproject: s, point: t, pointerDistance: e }) {
408
408
  const i = e / 2, { x: o, y: r } = t;
409
409
  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])] } };
410
410
  }
411
- class nt extends k {
411
+ class at extends k {
412
412
  constructor(t) {
413
413
  super(t);
414
414
  }
@@ -417,7 +417,7 @@ class nt extends k {
417
417
  return Se({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
418
418
  }
419
419
  }
420
- class at extends k {
420
+ class lt extends k {
421
421
  constructor(t) {
422
422
  super(t);
423
423
  }
@@ -450,7 +450,7 @@ function Jt(s, t, e) {
450
450
  const i = O(s[0]), o = O(s[1]), r = O(e), n = ve(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
451
451
  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)];
452
452
  }
453
- function lt({ x: s, y: t }, e, i) {
453
+ function dt({ x: s, y: t }, e, i) {
454
454
  const o = O(i);
455
455
  return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
456
456
  }
@@ -481,7 +481,7 @@ function si(s, t, e) {
481
481
  const d = s[s.length - 1];
482
482
  return [d, d];
483
483
  }
484
- function ut(s) {
484
+ function pt(s) {
485
485
  return s * (Math.PI / 180);
486
486
  }
487
487
  function Zt(s) {
@@ -509,7 +509,7 @@ class ri extends k {
509
509
  }
510
510
  generateInsertionGeodesicCoordinates(t, e, i) {
511
511
  const o = U(t, e), r = function(n, a, l) {
512
- const d = [], h = ut(n[1]), c = ut(n[0]), u = ut(a[1]), p = ut(a[0]);
512
+ const d = [], h = pt(n[1]), c = pt(n[0]), u = pt(a[1]), p = pt(a[0]);
513
513
  l += 1;
514
514
  const g = 2 * Math.asin(Math.sqrt(Math.sin((u - h) / 2) ** 2 + Math.cos(h) * Math.cos(u) * Math.sin((p - c) / 2) ** 2));
515
515
  if (g === 0 || isNaN(g)) return d;
@@ -664,7 +664,7 @@ class be extends N {
664
664
  this.updateGeometries(l, i[i.length - 1], M.Commit), this.currentCoordinate++;
665
665
  }
666
666
  registerBehaviors(t) {
667
- this.coordinateSnapping = new vt(t, new at(t), new nt(t)), this.insertPoint = new ri(t), this.clickBoundingBox = new nt(t), this.pixelDistance = new at(t), this.lineSnapping = new Ie(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new vt(t, this.pixelDistance, this.clickBoundingBox);
667
+ this.coordinateSnapping = new vt(t, new lt(t), new at(t)), this.insertPoint = new ri(t), this.clickBoundingBox = new at(t), this.pixelDistance = new lt(t), this.lineSnapping = new Ie(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new vt(t, this.pixelDistance, this.clickBoundingBox);
668
668
  }
669
669
  start() {
670
670
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -763,7 +763,7 @@ class be extends N {
763
763
  const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
764
764
  if (t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode) return e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex = 10, e;
765
765
  if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
766
- const i = t.properties[st];
766
+ const i = t.properties[rt];
767
767
  return e.pointColor = this.getHexColorStylingValue(i ? this.styles.closingPointColor : this.styles.snappingPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(i ? this.styles.closingPointWidth : this.styles.snappingPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.closingPointOutlineColor : this.styles.snappingPointOutlineColor, "#ffffff", t), e.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.closingPointOutlineWidth : this.styles.snappingPointOutlineWidth, 2, t), e.zIndex = 40, e;
768
768
  }
769
769
  return e;
@@ -825,7 +825,7 @@ class we extends N {
825
825
  this.editedFeatureId !== void 0 && (this.onFinish(this.editedFeatureId, { mode: this.mode, action: "edit" }), this.setCursor(this.cursors.dragEnd), this.store.updateProperty([{ id: this.editedFeatureId, property: V, value: !1 }]), this.editedFeatureId = void 0, e(!0));
826
826
  }
827
827
  registerBehaviors(t) {
828
- this.pixelDistance = new at(t), this.clickBoundingBox = new nt(t);
828
+ this.pixelDistance = new lt(t), this.clickBoundingBox = new at(t);
829
829
  }
830
830
  styleFeature(t) {
831
831
  const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
@@ -873,7 +873,7 @@ class gi extends k {
873
873
  create(t, e) {
874
874
  if (this.ids.length) throw new Error("Opening and closing points already created");
875
875
  if (t.length <= 3) throw new Error("Requires at least 4 coordinates");
876
- this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [st]: !0 } }, { geometry: { type: "Point", coordinates: t[t.length - 2] }, properties: { mode: e, [st]: !0 } }]);
876
+ this._startEndPoints = this.store.create([{ geometry: { type: "Point", coordinates: t[0] }, properties: { mode: e, [rt]: !0 } }, { geometry: { type: "Point", coordinates: t[t.length - 2] }, properties: { mode: e, [rt]: !0 } }]);
877
877
  }
878
878
  delete() {
879
879
  this.ids.length && (this.store.delete(this.ids), this._startEndPoints = []);
@@ -931,7 +931,7 @@ class Fe extends k {
931
931
  return this.store.create(t.map((i) => ({ geometry: { type: "Point", coordinates: i }, properties: { mode: e, [kt]: !0 } })));
932
932
  }
933
933
  setFeatureCoordinatePoints(t, e) {
934
- this.store.updateProperty([{ id: t, property: rt, value: e }]);
934
+ this.store.updateProperty([{ id: t, property: nt, value: e }]);
935
935
  }
936
936
  deleteCoordinatePoints(t) {
937
937
  const e = t.filter((i) => this.store.has(i));
@@ -953,7 +953,7 @@ class Ee extends N {
953
953
  this.coordinatePoints.createOrUpdate(e);
954
954
  });
955
955
  else if (this.coordinatePoints && this.showCoordinatePoints === !1) {
956
- const e = this.store.copyAllWhere((i) => i.mode === this.mode && !!i[rt]);
956
+ const e = this.store.copyAllWhere((i) => i.mode === this.mode && !!i[nt]);
957
957
  this.coordinatePoints.deletePointsByFeatureIds(e.map((i) => i.id));
958
958
  }
959
959
  }
@@ -964,13 +964,13 @@ class Ee extends N {
964
964
  if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], M.Finish)) return;
965
965
  const e = this.currentId;
966
966
  if (this.currentId) {
967
- const i = ht(this.store.getGeometryCopy(this.currentId));
967
+ const i = ct(this.store.getGeometryCopy(this.currentId));
968
968
  i && this.store.updateGeometry([{ id: this.currentId, geometry: i }]);
969
969
  }
970
970
  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" });
971
971
  }
972
972
  registerBehaviors(t) {
973
- this.clickBoundingBox = new nt(t), this.pixelDistance = new at(t), this.lineSnapping = new Ie(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new vt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new gi(t, this.pixelDistance), this.coordinatePoints = new Fe(t);
973
+ this.clickBoundingBox = new at(t), this.pixelDistance = new lt(t), this.lineSnapping = new Ie(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new vt(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new gi(t, this.pixelDistance), this.coordinatePoints = new Fe(t);
974
974
  }
975
975
  start() {
976
976
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -1111,7 +1111,7 @@ class Ee extends N {
1111
1111
  if (t.properties.mode === this.mode) {
1112
1112
  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;
1113
1113
  if (t.geometry.type === "Point") {
1114
- const i = t.properties[V], o = t.properties[kt], r = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[_t] ? "snappingPoint" : o ? "coordinatePoint" : void 0;
1114
+ const i = t.properties[V], o = t.properties[kt], r = i ? "editedPoint" : t.properties[rt] ? "closingPoint" : t.properties[_t] ? "snappingPoint" : o ? "coordinatePoint" : void 0;
1115
1115
  if (!r) return e;
1116
1116
  const n = { 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 }, coordinatePoint: { width: this.styles.coordinatePointWidth, color: this.styles.coordinatePointColor, outlineColor: this.styles.coordinatePointOutlineColor, outlineWidth: this.styles.coordinatePointOutlineWidth } };
1117
1117
  return e.pointWidth = this.getNumericStylingValue(n[r].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(n[r].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(n[r].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(n[r].outlineWidth, 2, t), e.zIndex = i ? 35 : o ? 25 : 30, e;
@@ -1144,7 +1144,7 @@ class Oe extends N {
1144
1144
  close() {
1145
1145
  const t = this.currentRectangleId;
1146
1146
  if (t) {
1147
- const e = ht(this.store.getGeometryCopy(t));
1147
+ const e = ct(this.store.getGeometryCopy(t));
1148
1148
  e && this.store.updateGeometry([{ id: t, geometry: e }]);
1149
1149
  }
1150
1150
  this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.onFinish(t, { mode: this.mode, action: "draw" });
@@ -1185,7 +1185,7 @@ class Oe extends N {
1185
1185
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (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;
1186
1186
  }
1187
1187
  validateFeature(t) {
1188
- return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
1188
+ return this.validateModeFeature(t, (e) => ht(e, this.coordinatePrecision));
1189
1189
  }
1190
1190
  }
1191
1191
  class et extends N {
@@ -1281,7 +1281,7 @@ class Pi extends k {
1281
1281
  }
1282
1282
  insert(t, e, i) {
1283
1283
  const o = this.store.getGeometryCopy(e), { midPointFeatureId: r, midPointSegment: n } = this.store.getPropertiesCopy(e), a = this.store.getGeometryCopy(r), l = a.type === "Polygon" ? a.coordinates[0] : a.coordinates;
1284
- l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id: r, geometry: a }]), this.store.getPropertiesCopy(t)[rt] && this.coordinatePointBehavior.createOrUpdate(t), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(l, r, i), this.selectionPointBehavior.create(l, a.type, r);
1284
+ l.splice(n + 1, 0, o.coordinates), a.coordinates = a.type === "Polygon" ? [l] : l, this.store.updateGeometry([{ id: r, geometry: a }]), this.store.getPropertiesCopy(t)[nt] && this.coordinatePointBehavior.createOrUpdate(t), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(l, r, i), this.selectionPointBehavior.create(l, a.type, r);
1285
1285
  }
1286
1286
  create(t, e, i) {
1287
1287
  if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
@@ -1775,7 +1775,7 @@ class Be extends Ye {
1775
1775
  this._state = "selecting";
1776
1776
  }
1777
1777
  registerBehaviors(t) {
1778
- this.pixelDistance = new at(t), this.clickBoundingBox = new nt(t), this.featuresAtMouseEvent = new xi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Si(t), this.coordinatePoints = new Fe(t), this.midPoints = new Pi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new vt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Mi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new wi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Ii(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new bi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap), this.dragCoordinateResizeFeature = new Fi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints);
1778
+ this.pixelDistance = new lt(t), this.clickBoundingBox = new at(t), this.featuresAtMouseEvent = new xi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new Si(t), this.coordinatePoints = new Fe(t), this.midPoints = new Pi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new vt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Mi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new wi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Ii(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new bi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap), this.dragCoordinateResizeFeature = new Fi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints);
1779
1779
  }
1780
1780
  deselectFeature() {
1781
1781
  this.deselect();
@@ -1995,7 +1995,7 @@ function Li(s, t) {
1995
1995
  function Et(s) {
1996
1996
  return (s.maxX - s.minX) * (s.maxY - s.minY);
1997
1997
  }
1998
- function pt(s) {
1998
+ function gt(s) {
1999
1999
  return s.maxX - s.minX + (s.maxY - s.minY);
2000
2000
  }
2001
2001
  function _i(s, t) {
@@ -2005,7 +2005,7 @@ function _i(s, t) {
2005
2005
  function Ot(s, t) {
2006
2006
  return s.minX <= t.minX && s.minY <= t.minY && t.maxX <= s.maxX && t.maxY <= s.maxY;
2007
2007
  }
2008
- function gt(s, t) {
2008
+ function yt(s, t) {
2009
2009
  return t.minX <= s.maxX && t.minY <= s.maxY && t.maxX >= s.minX && t.maxY >= s.minY;
2010
2010
  }
2011
2011
  function q(s) {
@@ -2026,12 +2026,12 @@ class ki {
2026
2026
  search(t) {
2027
2027
  let e = this.data;
2028
2028
  const i = [];
2029
- if (!gt(t, e)) return i;
2029
+ if (!yt(t, e)) return i;
2030
2030
  const o = this.toBBox, r = [];
2031
2031
  for (; e; ) {
2032
2032
  for (let n = 0; n < e.children.length; n++) {
2033
2033
  const a = e.children[n], l = e.leaf ? o(a) : a;
2034
- gt(t, l) && (e.leaf ? i.push(a) : Ot(t, l) ? this._all(a, i) : r.push(a));
2034
+ yt(t, l) && (e.leaf ? i.push(a) : Ot(t, l) ? this._all(a, i) : r.push(a));
2035
2035
  }
2036
2036
  e = r.pop();
2037
2037
  }
@@ -2039,12 +2039,12 @@ class ki {
2039
2039
  }
2040
2040
  collides(t) {
2041
2041
  let e = this.data;
2042
- if (gt(t, e)) {
2042
+ if (yt(t, e)) {
2043
2043
  const i = [];
2044
2044
  for (; e; ) {
2045
2045
  for (let o = 0; o < e.children.length; o++) {
2046
2046
  const r = e.children[o], n = e.leaf ? this.toBBox(r) : r;
2047
- if (gt(t, n)) {
2047
+ if (yt(t, n)) {
2048
2048
  if (e.leaf || Ot(t, n)) return !0;
2049
2049
  i.push(r);
2050
2050
  }
@@ -2160,14 +2160,14 @@ class ki {
2160
2160
  _allDistMargin(t, e, i, o) {
2161
2161
  t.children.sort(o);
2162
2162
  const r = this.toBBox, n = it(t, 0, e, r), a = it(t, i - e, i, r);
2163
- let l = pt(n) + pt(a);
2163
+ let l = gt(n) + gt(a);
2164
2164
  for (let d = e; d < i - e; d++) {
2165
2165
  const h = t.children[d];
2166
- ot(n, t.leaf ? r(h) : h), l += pt(n);
2166
+ ot(n, t.leaf ? r(h) : h), l += gt(n);
2167
2167
  }
2168
2168
  for (let d = i - e - 1; d >= e; d--) {
2169
2169
  const h = t.children[d];
2170
- ot(a, t.leaf ? r(h) : h), l += pt(a);
2170
+ ot(a, t.leaf ? r(h) : h), l += gt(a);
2171
2171
  }
2172
2172
  return l;
2173
2173
  }
@@ -2374,7 +2374,7 @@ class je extends N {
2374
2374
  const o = e[0], r = e[1], n = De(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 = oe(a, l, h), p = c ? 90 - u : oe(a, l, h) - 90, g = E(l, h), y = Math.cos(O(p)) * g, m = A(a, d) + (function(S, b, w) {
2375
2375
  const D = (w.x - b.x) * (S.y - b.y) - (w.y - b.y) * (S.x - b.x);
2376
2376
  return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
2377
- }(a, d, h) === "right" ? -90 : 90), v = lt(a, y, m), f = lt(d, y, m), C = W(v.x, v.y), P = W(f.x, f.y);
2377
+ }(a, d, h) === "right" ? -90 : 90), v = dt(a, y, m), f = dt(d, y, m), C = W(v.x, v.y), P = W(f.x, f.y);
2378
2378
  i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
2379
2379
  }
2380
2380
  i && this.updatePolygonGeometry(this.currentId, i, M.Provisional);
@@ -2420,7 +2420,7 @@ class je extends N {
2420
2420
  return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (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;
2421
2421
  }
2422
2422
  validateFeature(t) {
2423
- return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
2423
+ return this.validateModeFeature(t, (e) => ht(e, this.coordinatePrecision));
2424
2424
  }
2425
2425
  }
2426
2426
  function Ne(s, t, e) {
@@ -2436,7 +2436,7 @@ class Ge extends N {
2436
2436
  }
2437
2437
  close() {
2438
2438
  if (this.currentId === void 0) return;
2439
- const t = ht(this.store.getGeometryCopy(this.currentId));
2439
+ const t = ct(this.store.getGeometryCopy(this.currentId));
2440
2440
  t && this.store.updateGeometry([{ id: this.currentId, geometry: t }]);
2441
2441
  const e = this.currentId;
2442
2442
  this.currentCoordinate = 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
@@ -2466,7 +2466,7 @@ class Ge extends N {
2466
2466
  const f = (this.direction === "anticlockwise" ? 1 : -1) * v / p;
2467
2467
  g.push(r);
2468
2468
  for (let C = 0; C <= p; C++) {
2469
- const P = lt(a, h, y + C * f), { lng: S, lat: b } = W(P.x, P.y), w = [F(S, this.coordinatePrecision), F(b, this.coordinatePrecision)];
2469
+ const P = dt(a, h, y + C * f), { lng: S, lat: b } = W(P.x, P.y), w = [F(S, this.coordinatePrecision), F(b, this.coordinatePrecision)];
2470
2470
  w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
2471
2471
  }
2472
2472
  g.push(o), i = [...g];
@@ -2510,7 +2510,7 @@ class Ge extends N {
2510
2510
  return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (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;
2511
2511
  }
2512
2512
  validateFeature(t) {
2513
- return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
2513
+ return this.validateModeFeature(t, (e) => ht(e, this.coordinatePrecision));
2514
2514
  }
2515
2515
  }
2516
2516
  const zi = { cancel: "Escape", finish: "Enter" }, Xi = { start: "crosshair", close: "pointer" };
@@ -2525,7 +2525,7 @@ class Ae extends N {
2525
2525
  if (this.currentStartingPointId === void 0) return;
2526
2526
  const t = this.currentStartingPointId, e = this.currentInitialArcId, i = this.currentId;
2527
2527
  if (t && this.store.delete([t]), e && this.store.delete([e]), this.currentId) {
2528
- const o = ht(this.store.getGeometryCopy(this.currentId));
2528
+ const o = ct(this.store.getGeometryCopy(this.currentId));
2529
2529
  o && this.store.updateGeometry([{ id: this.currentId, geometry: o }]);
2530
2530
  }
2531
2531
  this.currentCoordinate = 0, this.currentStartingPointId = void 0, this.currentInitialArcId = void 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), i && this.onFinish(i, { mode: this.mode, action: "draw" });
@@ -2549,7 +2549,7 @@ class Ae extends N {
2549
2549
  this.direction === "anticlockwise" ? (m = y - g, m < 0 && (m += 360)) : (m = g - y, m < 0 && (m += 360));
2550
2550
  const v = (this.direction === "anticlockwise" ? 1 : -1) * m / u;
2551
2551
  for (let f = 0; f <= u; f++) {
2552
- const C = lt(l, d, g + f * v), { lng: P, lat: S } = W(C.x, C.y), b = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
2552
+ const C = dt(l, d, g + f * v), { lng: P, lat: S } = W(C.x, C.y), b = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
2553
2553
  b[0] !== p[p.length - 1][0] && b[1] !== p[p.length - 1][1] && p.push(b);
2554
2554
  }
2555
2555
  this.updateLineStringGeometry(this.currentInitialArcId, p, M.Provisional);
@@ -2560,7 +2560,7 @@ class Ae extends N {
2560
2560
  if (this.notInSector({ normalizedCursor: v, normalizedStart: y, normalizedEnd: m, direction: this.direction })) return;
2561
2561
  const f = this.getDeltaBearing(this.direction, y, m), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * f / C, S = E(d, c), b = [];
2562
2562
  for (let w = 0; w <= C; w++) {
2563
- const D = lt(d, S, y + w * P), { lng: G, lat: L } = W(D.x, D.y), j = [F(G, this.coordinatePrecision), F(L, this.coordinatePrecision)];
2563
+ const D = dt(d, S, y + w * P), { lng: G, lat: L } = W(D.x, D.y), j = [F(G, this.coordinatePrecision), F(L, this.coordinatePrecision)];
2564
2564
  j[0] !== e[e.length - 1][0] && j[1] !== e[e.length - 1][1] && b.unshift(j);
2565
2565
  }
2566
2566
  e.push(...b), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, M.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
@@ -2607,7 +2607,7 @@ class Ae extends N {
2607
2607
  return t.properties.mode === this.mode && (t.geometry.type === "Polygon" ? (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) : t.geometry.type === "LineString" ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.zIndex = 10) : t.geometry.type === "Point" && (e.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 20)), e;
2608
2608
  }
2609
2609
  validateFeature(t) {
2610
- return this.validateModeFeature(t, (e) => dt(e, this.coordinatePrecision));
2610
+ return this.validateModeFeature(t, (e) => ht(e, this.coordinatePrecision));
2611
2611
  }
2612
2612
  getDeltaBearing(t, e, i) {
2613
2613
  let o;
@@ -2831,7 +2831,7 @@ class $i {
2831
2831
  t.forEach((i) => {
2832
2832
  if (!this._store.has(i)) throw new Error(`No feature with id ${i}, can not delete`);
2833
2833
  const o = this._store.copy(i);
2834
- o.properties[T.SELECTED] && this.deselectFeature(i), o.properties[rt] && e.push(...o.properties[rt]);
2834
+ o.properties[T.SELECTED] && this.deselectFeature(i), o.properties[nt] && e.push(...o.properties[nt]);
2835
2835
  }), this._store.delete([...t, ...e]);
2836
2836
  }
2837
2837
  selectFeature(t) {
@@ -3035,7 +3035,7 @@ const ko = [
3035
3035
  "download"
3036
3036
  ],
3037
3037
  open: !1
3038
- }, ft = {
3038
+ }, st = {
3039
3039
  modes: [
3040
3040
  "render",
3041
3041
  "point",
@@ -3579,7 +3579,7 @@ function to(s, t = "kilometers") {
3579
3579
  throw new Error(t + " units is invalid");
3580
3580
  return s * e;
3581
3581
  }
3582
- function yt(s) {
3582
+ function ft(s) {
3583
3583
  return s % 360 * Math.PI / 180;
3584
3584
  }
3585
3585
  function se(s) {
@@ -3806,7 +3806,7 @@ function le(s) {
3806
3806
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
3807
3807
  }
3808
3808
  function lo(s, t, e = {}) {
3809
- var i = le(s), o = le(t), r = yt(o[1] - i[1]), n = yt(o[0] - i[0]), a = yt(i[1]), l = yt(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3809
+ var i = le(s), o = le(t), r = ft(o[1] - i[1]), n = ft(o[0] - i[0]), a = ft(i[1]), l = ft(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3810
3810
  return to(
3811
3811
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3812
3812
  e.units
@@ -3870,9 +3870,9 @@ const de = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians
3870
3870
  var ge, ye, fe;
3871
3871
  const Bo = [
3872
3872
  ...Mt,
3873
- (ge = ft.polygonLayerSpec) == null ? void 0 : ge.source,
3874
- (ye = ft.lineLayerLabelSpec) == null ? void 0 : ye.source,
3875
- (fe = ft.pointLayerLabelSpec) == null ? void 0 : fe.source
3873
+ (ge = st.polygonLayerSpec) == null ? void 0 : ge.source,
3874
+ (ye = st.lineLayerLabelSpec) == null ? void 0 : ye.source,
3875
+ (fe = st.pointLayerLabelSpec) == null ? void 0 : fe.source
3876
3876
  ], Ue = (s, t, e = Mt) => {
3877
3877
  const i = JSON.parse(JSON.stringify(s));
3878
3878
  return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
@@ -4502,8 +4502,8 @@ class jo extends Fo {
4502
4502
  * @param options Plugin control options
4503
4503
  */
4504
4504
  constructor(e) {
4505
- let i = structuredClone(ft);
4506
- e && (i = Object.assign(i, e));
4505
+ let i = structuredClone(st);
4506
+ i.modeOptions = st.modeOptions, e && (i = Object.assign(i, e));
4507
4507
  super({
4508
4508
  modes: i.modes,
4509
4509
  open: i.open,
@@ -5082,7 +5082,7 @@ export {
5082
5082
  Lt as convertMetricDistance,
5083
5083
  co as debounce,
5084
5084
  Hi as defaultControlOptions,
5085
- ft as defaultMeasureControlOptions,
5085
+ st as defaultMeasureControlOptions,
5086
5086
  Ji as getDefaultModeOptions,
5087
5087
  de as getDistanceUnitName,
5088
5088
  ue as queryElevationByPoint,