@watergis/maplibre-gl-terradraw 1.8.0 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { LngLat as Je } from "maplibre-gl";
1
+ import { LngLat as He } from "maplibre-gl";
2
2
  function x() {
3
3
  return x = Object.assign ? Object.assign.bind() : function(r) {
4
4
  for (var t = 1; t < arguments.length; t++) {
@@ -13,23 +13,23 @@ var E;
13
13
  r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
14
14
  })(E || (E = {}));
15
15
  const k = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT_FEATURE_ID: "selectionPointFeatureId", SELECTION_POINT: "selectionPoint" }, S = { MODE: "mode", CURRENTLY_DRAWING: "currentlyDrawing", EDITED: "edited", CLOSING_POINT: "closingPoint", SNAPPING_POINT: "snappingPoint", COORDINATE_POINT: "coordinatePoint", COORDINATE_POINT_FEATURE_ID: "coordinatePointFeatureId", COORDINATE_POINT_IDS: "coordinatePointIds", PROVISIONAL_COORDINATE_COUNT: "provisionalCoordinateCount", COMMITTED_COORDINATE_COUNT: "committedCoordinateCount" }, j = 10;
16
- function wt(r) {
16
+ function Lt(r) {
17
17
  return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
18
18
  }
19
- function Qt(r) {
19
+ function te(r) {
20
20
  return !!(r && typeof r == "object" && "properties" in r && typeof r.properties == "object" && r.properties !== null && "mode" in r.properties);
21
21
  }
22
- function te(r) {
22
+ function ee(r) {
23
23
  return !!(function(t) {
24
24
  return typeof t == "number" && !isNaN(new Date(t).valueOf());
25
25
  })(r);
26
26
  }
27
- const He = "Feature mode property does not match the mode being added to";
27
+ const Ze = "Feature mode property does not match the mode being added to";
28
28
  var q;
29
29
  (function(r) {
30
30
  r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
31
31
  })(q || (q = {}));
32
- const Ze = { rightClick: !0, contextMenu: !1, leftClick: !0, onDragStart: !0, onDrag: !0, onDragEnd: !0 };
32
+ const Qe = { rightClick: !0, contextMenu: !1, leftClick: !0, onDragStart: !0, onDrag: !0, onDragEnd: !0 };
33
33
  class A {
34
34
  get state() {
35
35
  return this._state;
@@ -47,7 +47,7 @@ class A {
47
47
  registerBehaviors(t) {
48
48
  }
49
49
  constructor(t, e = !1) {
50
- this._state = "unregistered", this._styles = {}, this.pointerEvents = Ze, this.behaviors = [], this.validate = void 0, this.pointerDistance = 40, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.projection = "web-mercator", this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.type = q.Drawing, this.mode = "base", e || this.updateOptions(t);
50
+ this._state = "unregistered", this._styles = {}, this.pointerEvents = Qe, this.behaviors = [], this.validate = void 0, this.pointerDistance = 40, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.projection = "web-mercator", this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.type = q.Drawing, this.mode = "base", e || this.updateOptions(t);
51
51
  }
52
52
  updateOptions(t) {
53
53
  t != null && t.styles && (this.styles = x({}, this._styles, t.styles)), t != null && t.pointerDistance && (this.pointerDistance = t.pointerDistance), t != null && t.validation && (this.validate = t && t.validation), t != null && t.projection && (this.projection = t.projection), t?.pointerEvents !== void 0 && (this.pointerEvents = t.pointerEvents);
@@ -82,9 +82,9 @@ class A {
82
82
  if (this._state === "unregistered") throw new Error("Mode must be registered");
83
83
  const e = (function(i, o) {
84
84
  let s;
85
- if (wt(i)) if (i.id == null) s = "Feature has no id";
85
+ if (Lt(i)) if (i.id == null) s = "Feature has no id";
86
86
  else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
87
- else if (o(i.id)) if (wt(i.geometry)) if (wt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
87
+ else if (o(i.id)) if (Lt(i.geometry)) if (Lt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
88
88
  if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
89
89
  } else s = "Feature coordinates is not an array";
90
90
  else s = "Feature is not Point, LineString or Polygon";
@@ -102,7 +102,7 @@ class A {
102
102
  }
103
103
  validateModeFeature(t, e) {
104
104
  const i = this.performFeatureValidation(t);
105
- return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: He } : e(t) : { valid: !1, reason: i.reason };
105
+ return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Ze } : e(t) : { valid: !1, reason: i.reason };
106
106
  }
107
107
  onFinish(t, e) {
108
108
  }
@@ -134,7 +134,7 @@ class A {
134
134
  return t === void 0 ? e : typeof t == "function" ? t(i) : t;
135
135
  }
136
136
  }
137
- let Qe = class extends A {
137
+ let ti = class extends A {
138
138
  constructor(...t) {
139
139
  super(...t), this.type = q.Select;
140
140
  }
@@ -143,34 +143,34 @@ function U(r, t) {
143
143
  const e = (d) => d * Math.PI / 180, i = e(r[1]), o = e(r[0]), s = e(t[1]), n = s - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(s) * Math.sin(a / 2) * Math.sin(a / 2);
144
144
  return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
145
145
  }
146
- const xe = 63710088e-1;
146
+ const Oe = 63710088e-1;
147
147
  function D(r) {
148
148
  return r % 360 * Math.PI / 180;
149
149
  }
150
- function Oe(r) {
150
+ function Ee(r) {
151
151
  return r / 6371.0088;
152
152
  }
153
153
  function V(r) {
154
154
  return r % (2 * Math.PI) * 180 / Math.PI;
155
155
  }
156
- function w(r, t = 9) {
156
+ function b(r, t = 9) {
157
157
  const e = Math.pow(10, t);
158
158
  return Math.round(r * e) / e;
159
159
  }
160
- const ee = 57.29577951308232, ie = 0.017453292519943295, St = 6378137, O = (r, t) => ({ x: r === 0 ? 0 : r * ie * St, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * ie / 2)) * St }), R = (r, t) => ({ lng: r === 0 ? 0 : ee * (r / St), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / St)) - Math.PI / 2) * ee });
161
- function ti(r, t, e) {
162
- const i = D(r[0]), o = D(r[1]), s = D(e), n = Oe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
160
+ const ie = 57.29577951308232, oe = 0.017453292519943295, xt = 6378137, O = (r, t) => ({ x: r === 0 ? 0 : r * oe * xt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * oe / 2)) * xt }), R = (r, t) => ({ lng: r === 0 ? 0 : ie * (r / xt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / xt)) - Math.PI / 2) * ie });
161
+ function ei(r, t, e) {
162
+ const i = D(r[0]), o = D(r[1]), s = D(e), n = Ee(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
163
163
  return [V(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), V(a)];
164
164
  }
165
- function oe(r) {
165
+ function se(r) {
166
166
  const { center: t, radiusKilometers: e, coordinatePrecision: i } = r, o = r.steps ? r.steps : 64, s = [];
167
167
  for (let n = 0; n < o; n++) {
168
- const a = ti(t, e, -360 * n / o);
169
- s.push([w(a[0], i), w(a[1], i)]);
168
+ const a = ei(t, e, -360 * n / o);
169
+ s.push([b(a[0], i), b(a[1], i)]);
170
170
  }
171
171
  return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
172
172
  }
173
- function jt(r) {
173
+ function At(r) {
174
174
  let t;
175
175
  if (r.geometry.type === "Polygon") t = r.geometry.coordinates;
176
176
  else {
@@ -184,51 +184,51 @@ function jt(r) {
184
184
  return s < 0 || s > 1;
185
185
  }
186
186
  function o(s, n, a, l) {
187
- const d = t[s][n], c = t[s][n + 1], h = t[a][l], u = t[a][l + 1], p = (function(m, v, C, f) {
188
- if (gt(m, C) || gt(m, f) || gt(v, C) || gt(f, C)) return null;
189
- const P = m[0], I = m[1], b = v[0], L = v[1], M = C[0], N = C[1], _ = f[0], T = f[1], $ = (P - b) * (N - T) - (I - L) * (M - _);
190
- return $ === 0 ? null : [((P * L - I * b) * (M - _) - (P - b) * (M * T - N * _)) / $, ((P * L - I * b) * (N - T) - (I - L) * (M * T - N * _)) / $];
187
+ const d = t[s][n], c = t[s][n + 1], h = t[a][l], u = t[a][l + 1], p = (function(f, v, C, m) {
188
+ if (ft(f, C) || ft(f, m) || ft(v, C) || ft(m, C)) return null;
189
+ const P = f[0], I = f[1], w = v[0], L = v[1], M = C[0], N = C[1], _ = m[0], T = m[1], $ = (P - w) * (N - T) - (I - L) * (M - _);
190
+ return $ === 0 ? null : [((P * L - I * w) * (M - _) - (P - w) * (M * T - N * _)) / $, ((P * L - I * w) * (N - T) - (I - L) * (M * T - N * _)) / $];
191
191
  })(d, c, h, u);
192
192
  if (p === null) return;
193
193
  let g, y;
194
194
  g = c[0] !== d[0] ? (p[0] - d[0]) / (c[0] - d[0]) : (p[1] - d[1]) / (c[1] - d[1]), y = u[0] !== h[0] ? (p[0] - h[0]) / (u[0] - h[0]) : (p[1] - h[1]) / (u[1] - h[1]), i(g) || i(y) || (p.toString(), e.push(p));
195
195
  }
196
196
  }
197
- function gt(r, t) {
197
+ function ft(r, t) {
198
198
  return r[0] === t[0] && r[1] === t[1];
199
199
  }
200
- function Ot(r, t) {
201
- return se(r[0]) <= t && se(r[1]) <= t;
200
+ function bt(r, t) {
201
+ return re(r[0]) <= t && re(r[1]) <= t;
202
202
  }
203
- function At(r) {
203
+ function Rt(r) {
204
204
  return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (e = r[0]) >= -180 && e <= 180 && (t = r[1]) >= -90 && t <= 90;
205
205
  var t, e;
206
206
  }
207
- function se(r) {
207
+ function re(r) {
208
208
  let t = 1, e = 0;
209
209
  for (; Math.round(r * t) / t !== r; ) t *= 10, e++;
210
210
  return e;
211
211
  }
212
- const ei = "Feature has holes", ii = "Feature has less than 4 coordinates", oi = "Feature has invalid coordinates", si = "Feature coordinates are not closed";
213
- function Et(r, t) {
212
+ const ii = "Feature has holes", oi = "Feature has less than 4 coordinates", si = "Feature has invalid coordinates", ri = "Feature coordinates are not closed";
213
+ function wt(r, t) {
214
214
  if (r.geometry.type !== "Polygon") return { valid: !1, reason: "Feature is not a Polygon" };
215
- if (r.geometry.coordinates.length !== 1) return { valid: !1, reason: ei };
216
- if (r.geometry.coordinates[0].length < 4) return { valid: !1, reason: ii };
215
+ if (r.geometry.coordinates.length !== 1) return { valid: !1, reason: ii };
216
+ if (r.geometry.coordinates[0].length < 4) return { valid: !1, reason: oi };
217
217
  for (let o = 0; o < r.geometry.coordinates[0].length; o++) {
218
- if (!At(r.geometry.coordinates[0][o])) return { valid: !1, reason: oi };
219
- if (!Ot(r.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
218
+ if (!Rt(r.geometry.coordinates[0][o])) return { valid: !1, reason: si };
219
+ if (!bt(r.geometry.coordinates[0][o], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
220
220
  }
221
- return (e = r.geometry.coordinates[0][0])[0] !== (i = r.geometry.coordinates[0][r.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: si } : { valid: !0 };
221
+ return (e = r.geometry.coordinates[0][0])[0] !== (i = r.geometry.coordinates[0][r.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: ri } : { valid: !0 };
222
222
  var e, i;
223
223
  }
224
- function ut(r, t) {
225
- const e = Et(r, t);
226
- return e.valid ? jt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
224
+ function gt(r, t) {
225
+ const e = wt(r, t);
226
+ return e.valid ? At(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
227
227
  }
228
- const ri = { cancel: "Escape", finish: "Enter" }, ni = { start: "crosshair" };
229
- let Ee = class extends A {
228
+ const ni = { cancel: "Escape", finish: "Enter" }, ai = { start: "crosshair" };
229
+ let be = class extends A {
230
230
  constructor(t) {
231
- super(t, !0), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = ri, this.cursors = ni, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1, this.updateOptions(t);
231
+ super(t, !0), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = ni, this.cursors = ai, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1, this.updateOptions(t);
232
232
  }
233
233
  updateOptions(t) {
234
234
  super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.startingRadiusKilometers && (this.startingRadiusKilometers = t.startingRadiusKilometers);
@@ -252,7 +252,7 @@ let Ee = class extends A {
252
252
  onClick(t) {
253
253
  if (t.button === "right" && this.allowPointerEvent(this.pointerEvents.rightClick, t) || t.button === "left" && this.allowPointerEvent(this.pointerEvents.leftClick, t) || t.isContextMenu && this.allowPointerEvent(this.pointerEvents.contextMenu, t)) if (this.clickCount === 0) {
254
254
  this.center = [t.lng, t.lat];
255
- const e = oe({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers, [S.CURRENTLY_DRAWING]: !0 } }]);
255
+ const e = se({ center: this.center, radiusKilometers: this.startingRadiusKilometers, coordinatePrecision: this.coordinatePrecision }), [i] = this.store.create([{ geometry: e.geometry, properties: { mode: this.mode, radiusKilometers: this.startingRadiusKilometers, [S.CURRENTLY_DRAWING]: !0 } }]);
256
256
  this.currentCircleId = i, this.clickCount++, this.cursorMovedAfterInitialCursorDown = !1, this.setDrawing();
257
257
  } else this.clickCount === 1 && this.center && this.currentCircleId !== void 0 && this.cursorMovedAfterInitialCursorDown && this.updateCircle(t), this.close();
258
258
  }
@@ -283,7 +283,7 @@ let Ee = class extends A {
283
283
  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 = j), e;
284
284
  }
285
285
  validateFeature(t) {
286
- return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
286
+ return this.validateModeFeature(t, (e) => gt(e, this.coordinatePrecision));
287
287
  }
288
288
  updateCircle(t) {
289
289
  if (this.clickCount === 1 && this.center && this.currentCircleId) {
@@ -298,15 +298,15 @@ let Ee = class extends A {
298
298
  })(this.center, [t.lng, t.lat]);
299
299
  i = (function(s) {
300
300
  const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = O(h, u), y = [];
301
- for (let m = 0; m < d; m++) {
302
- const v = 360 * m / d * Math.PI / 180, C = c * Math.cos(v), f = c * Math.sin(v), [P, I] = [p + C, g + f], { lng: b, lat: L } = R(P, I);
303
- y.push([w(b, l), w(L, l)]);
301
+ for (let f = 0; f < d; f++) {
302
+ const v = 360 * f / d * Math.PI / 180, C = c * Math.cos(v), m = c * Math.sin(v), [P, I] = [p + C, g + m], { lng: w, lat: L } = R(P, I);
303
+ y.push([b(w, l), b(L, l)]);
304
304
  }
305
305
  return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
306
306
  })({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
307
307
  } else {
308
308
  if (this.projection !== "globe") throw new Error("Invalid projection");
309
- i = oe({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
309
+ i = se({ center: this.center, radiusKilometers: e, coordinatePrecision: this.coordinatePrecision });
310
310
  }
311
311
  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: E.Provisional }).valid) return;
312
312
  this.store.updateGeometry([{ id: this.currentCircleId, geometry: i.geometry }]), this.store.updateProperty([{ id: this.currentCircleId, property: "radiusKilometers", value: e }]);
@@ -320,7 +320,7 @@ const F = (r, t) => {
320
320
  const { x: e, y: i } = r, { x: o, y: s } = t, n = o - e, a = s - i;
321
321
  return Math.sqrt(a * a + n * n);
322
322
  };
323
- function pt(r) {
323
+ function yt(r) {
324
324
  if (!(function(e) {
325
325
  const i = e.coordinates[0];
326
326
  let o = 0;
@@ -331,10 +331,10 @@ function pt(r) {
331
331
  return o < 0;
332
332
  })(r)) return { type: "Polygon", coordinates: [r.coordinates[0].reverse()] };
333
333
  }
334
- const ai = { cancel: "Escape", finish: "Enter" }, li = { start: "crosshair", close: "pointer" };
335
- class be extends A {
334
+ const li = { cancel: "Escape", finish: "Enter" }, di = { start: "crosshair", close: "pointer" };
335
+ class we extends A {
336
336
  constructor(t) {
337
- super(t, !0), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = ai, this.cursors = li, this.preventPointsNearClose = !0, this.autoClose = !1, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1, this.updateOptions(t);
337
+ super(t, !0), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = li, this.cursors = di, this.preventPointsNearClose = !0, this.autoClose = !1, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1, this.updateOptions(t);
338
338
  }
339
339
  updateOptions(t) {
340
340
  super.updateOptions(t), t != null && t.minDistance && (this.minDistance = t.minDistance), t?.preventPointsNearClose !== void 0 && (this.preventPointsNearClose = t.preventPointsNearClose), t?.autoClose !== void 0 && (this.autoClose = t.autoClose), t != null && t.autoCloseTimeout && (this.autoCloseTimeout = t.autoCloseTimeout), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors));
@@ -342,7 +342,7 @@ class be extends A {
342
342
  close() {
343
343
  if (this.currentId === void 0) return;
344
344
  if (this.currentId) {
345
- const e = pt(this.store.getGeometryCopy(this.currentId));
345
+ const e = yt(this.store.getGeometryCopy(this.currentId));
346
346
  e && this.store.updateGeometry([{ id: this.currentId, geometry: e }]), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
347
347
  }
348
348
  const t = this.currentId;
@@ -405,7 +405,7 @@ class be extends A {
405
405
  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 = j, e) : (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 50), e);
406
406
  }
407
407
  validateFeature(t) {
408
- return this.validateModeFeature(t, (e) => Et(e, this.coordinatePrecision));
408
+ return this.validateModeFeature(t, (e) => wt(e, this.coordinatePrecision));
409
409
  }
410
410
  afterFeatureUpdated(t) {
411
411
  this.currentId === t.id && (this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.hasLeftStartingPoint = !1);
@@ -416,20 +416,20 @@ let B = class {
416
416
  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 = s, this.coordinatePrecision = n, this.projection = a;
417
417
  }
418
418
  };
419
- function we({ unproject: r, point: t, pointerDistance: e }) {
419
+ function Le({ unproject: r, point: t, pointerDistance: e }) {
420
420
  const i = e / 2, { x: o, y: s } = t;
421
421
  return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[r(o - i, s - i), r(o + i, s - i), r(o + i, s + i), r(o - i, s + i), r(o - i, s - i)].map((n) => [n.lng, n.lat])] } };
422
422
  }
423
- class dt extends B {
423
+ class ct extends B {
424
424
  constructor(t) {
425
425
  super(t);
426
426
  }
427
427
  create(t) {
428
428
  const { containerX: e, containerY: i } = t;
429
- return we({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
429
+ return Le({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
430
430
  }
431
431
  }
432
- class ct extends B {
432
+ class ht extends B {
433
433
  constructor(t) {
434
434
  super(t);
435
435
  }
@@ -438,7 +438,7 @@ class ct extends B {
438
438
  return F({ x: i, y: o }, { x: t.containerX, y: t.containerY });
439
439
  }
440
440
  }
441
- let It = class extends B {
441
+ let Ot = class extends B {
442
442
  constructor(t, e, i) {
443
443
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (s) => !!(s.properties && s.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, s) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== s)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
444
444
  }
@@ -458,15 +458,15 @@ let It = class extends B {
458
458
  }), s;
459
459
  }
460
460
  };
461
- function re(r, t, e) {
462
- const i = D(r[0]), o = D(r[1]), s = D(e), n = Oe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
461
+ function ne(r, t, e) {
462
+ const i = D(r[0]), o = D(r[1]), s = D(e), n = Ee(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
463
463
  return [V(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), V(a)];
464
464
  }
465
- function ht({ x: r, y: t }, e, i) {
465
+ function ut({ x: r, y: t }, e, i) {
466
466
  const o = D(i);
467
467
  return { x: r + e * Math.cos(o), y: t + e * Math.sin(o) };
468
468
  }
469
- function ne(r, t) {
469
+ function ae(r, t) {
470
470
  const e = D(r[0]), i = D(t[0]), o = D(r[1]), s = D(t[1]), n = Math.sin(i - e) * Math.cos(s), a = Math.cos(o) * Math.sin(s) - Math.sin(o) * Math.cos(s) * Math.cos(i - e);
471
471
  return V(Math.atan2(n, a));
472
472
  }
@@ -479,15 +479,15 @@ function G({ x: r, y: t }, { x: e, y: i }) {
479
479
  function X(r) {
480
480
  return (r + 360) % 360;
481
481
  }
482
- function di(r, t, e) {
482
+ function ci(r, t, e) {
483
483
  const i = [], o = r.length;
484
484
  let s, n, a, l = 0;
485
485
  for (let c = 0; c < r.length && !(t >= l && c === r.length - 1); c++) {
486
486
  if (l > t && i.length === 0) {
487
487
  if (s = t - l, !s) return i.push(r[c]), i;
488
- n = ne(r[c], r[c - 1]) - 180, a = re(r[c], s, n), i.push(a);
488
+ n = ae(r[c], r[c - 1]) - 180, a = ne(r[c], s, n), i.push(a);
489
489
  }
490
- if (l >= e) return s = e - l, s ? (n = ne(r[c], r[c - 1]) - 180, a = re(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
490
+ if (l >= e) return s = e - l, s ? (n = ae(r[c], r[c - 1]) - 180, a = ne(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
491
491
  if (l >= t && i.push(r[c]), c === r.length - 1) return i;
492
492
  l += U(r[c], r[c + 1]);
493
493
  }
@@ -495,13 +495,13 @@ function di(r, t, e) {
495
495
  const d = r[r.length - 1];
496
496
  return [d, d];
497
497
  }
498
- function yt(r) {
498
+ function mt(r) {
499
499
  return r * (Math.PI / 180);
500
500
  }
501
- function ae(r) {
501
+ function le(r) {
502
502
  return r * (180 / Math.PI);
503
503
  }
504
- class ci extends B {
504
+ class hi extends B {
505
505
  constructor(t) {
506
506
  super(t), this.config = void 0, this.config = t;
507
507
  }
@@ -514,7 +514,7 @@ class ci extends B {
514
514
  Number.isInteger(n) || (n = Math.floor(n) + 1);
515
515
  const a = [];
516
516
  for (let d = 0; d < n; d++) {
517
- const c = di(o, i * d, i * (d + 1));
517
+ const c = ci(o, i * d, i * (d + 1));
518
518
  a.push(c);
519
519
  }
520
520
  const l = [];
@@ -523,47 +523,47 @@ class ci extends B {
523
523
  }
524
524
  generateInsertionGeodesicCoordinates(t, e, i) {
525
525
  const o = U(t, e), s = (function(n, a, l) {
526
- const d = [], c = yt(n[1]), h = yt(n[0]), u = yt(a[1]), p = yt(a[0]);
526
+ const d = [], c = mt(n[1]), h = mt(n[0]), u = mt(a[1]), p = mt(a[0]);
527
527
  l += 1;
528
528
  const g = 2 * Math.asin(Math.sqrt(Math.sin((u - c) / 2) ** 2 + Math.cos(c) * Math.cos(u) * Math.sin((p - h) / 2) ** 2));
529
529
  if (g === 0 || isNaN(g)) return d;
530
530
  for (let y = 0; y <= l; y++) {
531
- const m = y / l, v = Math.sin((1 - m) * g) / Math.sin(g), C = Math.sin(m * g) / Math.sin(g), f = v * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(p), P = v * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(p), I = v * Math.sin(c) + C * Math.sin(u);
532
- if (isNaN(f) || isNaN(P) || isNaN(I)) continue;
533
- const b = Math.atan2(I, Math.sqrt(f ** 2 + P ** 2)), L = Math.atan2(P, f);
534
- isNaN(b) || isNaN(L) || d.push([ae(L), ae(b)]);
531
+ const f = y / l, v = Math.sin((1 - f) * g) / Math.sin(g), C = Math.sin(f * g) / Math.sin(g), m = v * Math.cos(c) * Math.cos(h) + C * Math.cos(u) * Math.cos(p), P = v * Math.cos(c) * Math.sin(h) + C * Math.cos(u) * Math.sin(p), I = v * Math.sin(c) + C * Math.sin(u);
532
+ if (isNaN(m) || isNaN(P) || isNaN(I)) continue;
533
+ const w = Math.atan2(I, Math.sqrt(m ** 2 + P ** 2)), L = Math.atan2(P, m);
534
+ isNaN(w) || isNaN(L) || d.push([le(L), le(w)]);
535
535
  }
536
536
  return d.slice(1, -1);
537
537
  })(t, e, Math.floor(o / i));
538
538
  return this.limitCoordinates(s);
539
539
  }
540
540
  limitCoordinates(t) {
541
- return t.map((e) => [w(e[0], this.config.coordinatePrecision), w(e[1], this.config.coordinatePrecision)]);
541
+ return t.map((e) => [b(e[0], this.config.coordinatePrecision), b(e[1], this.config.coordinatePrecision)]);
542
542
  }
543
543
  }
544
- function tt(r, t) {
544
+ function et(r, t) {
545
545
  return r[0] === t[0] && r[1] === t[1];
546
546
  }
547
- function Rt(r, t) {
547
+ function Gt(r, t) {
548
548
  if (r.geometry.type !== "LineString") return { valid: !1, reason: "Feature is not a LineString" };
549
549
  if (r.geometry.coordinates.length < 2) return { valid: !1, reason: "Feature has less than 2 coordinates" };
550
550
  for (let e = 0; e < r.geometry.coordinates.length; e++) {
551
- if (!At(r.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
552
- if (!Ot(r.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
551
+ if (!Rt(r.geometry.coordinates[e])) return { valid: !1, reason: "Feature has invalid coordinates" };
552
+ if (!bt(r.geometry.coordinates[e], t)) return { valid: !1, reason: "Feature has coordinates with excessive precision" };
553
553
  }
554
554
  return { valid: !0 };
555
555
  }
556
- function le(r) {
556
+ function de(r) {
557
557
  return Math.sqrt(Math.pow(r[0], 2) + Math.pow(r[1], 2) + Math.pow(r[2], 2));
558
558
  }
559
559
  function Y(r, t) {
560
560
  const e = (function(i, o) {
561
561
  const [s, n, a] = i, [l, d, c] = o;
562
562
  return s * l + n * d + a * c;
563
- })(r, t) / (le(r) * le(t));
563
+ })(r, t) / (de(r) * de(t));
564
564
  return Math.acos(Math.min(Math.max(e, -1), 1));
565
565
  }
566
- function Lt(r) {
566
+ function Ft(r) {
567
567
  const t = D(r[1]), e = D(r[0]);
568
568
  return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
569
569
  }
@@ -571,26 +571,26 @@ function K(r) {
571
571
  const [t, e, i] = r, o = V(Math.asin(i));
572
572
  return [V(Math.atan2(e, t)), o];
573
573
  }
574
- function hi(r, t, e) {
575
- const i = Lt(r), o = Lt(t), s = Lt(e), [n, a, l] = s, [d, c, h] = (function(T, $) {
576
- const [Kt, Xt, qt] = T, [Jt, Ht, Zt] = $;
577
- return [Xt * Zt - qt * Ht, qt * Jt - Kt * Zt, Kt * Ht - Xt * Jt];
578
- })(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, m = u * h - g * d, v = p * d - u * c, C = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(m, 2) + Math.pow(v, 2)), f = [y * C, m * C, v * C], P = [-1 * y * C, -1 * m * C, -1 * v * C], I = Y(i, o), b = Y(i, f), L = Y(o, f), M = Y(i, P), N = Y(o, P);
574
+ function ui(r, t, e) {
575
+ const i = Ft(r), o = Ft(t), s = Ft(e), [n, a, l] = s, [d, c, h] = (function(T, $) {
576
+ const [Xt, qt, Jt] = T, [Ht, Zt, Qt] = $;
577
+ return [qt * Qt - Jt * Zt, Jt * Ht - Xt * Qt, Xt * Zt - qt * Ht];
578
+ })(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, f = u * h - g * d, v = p * d - u * c, C = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(f, 2) + Math.pow(v, 2)), m = [y * C, f * C, v * C], P = [-1 * y * C, -1 * f * C, -1 * v * C], I = Y(i, o), w = Y(i, m), L = Y(o, m), M = Y(i, P), N = Y(o, P);
579
579
  let _;
580
- return _ = b < M && b < N || L < M && L < N ? f : P, Y(i, _) > I || Y(o, _) > I ? U(K(_), K(i)) <= U(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
580
+ return _ = w < M && w < N || L < M && L < N ? m : P, Y(i, _) > I || Y(o, _) > I ? U(K(_), K(i)) <= U(K(_), K(o)) ? [K(i), !0, !1] : [K(o), !1, !0] : [K(_), !1, !1];
581
581
  }
582
- function ui(r, t, e) {
582
+ function pi(r, t, e) {
583
583
  const i = t.x - r.x, o = t.y - r.y, s = Math.max(0, Math.min(1, ((e.x - r.x) * i + (e.y - r.y) * o) / (i * i + o * o)));
584
584
  return { x: r.x + s * i, y: r.y + s * o };
585
585
  }
586
- class Gt extends B {
586
+ class Ut extends B {
587
587
  constructor(t, e, i) {
588
588
  super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => {
589
589
  const s = this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode));
590
- return s.coordinate ? [w(s.coordinate[0], this.config.coordinatePrecision), w(s.coordinate[1], this.config.coordinatePrecision)] : void 0;
590
+ return s.coordinate ? [b(s.coordinate[0], this.config.coordinatePrecision), b(s.coordinate[1], this.config.coordinatePrecision)] : void 0;
591
591
  }, this.getSnappableCoordinate = (o, s) => {
592
592
  const n = this.getSnappable(o, (a) => !!(a.properties && a.properties.mode === this.mode && a.id !== s));
593
- return n.coordinate ? [w(n.coordinate[0], this.config.coordinatePrecision), w(n.coordinate[1], this.config.coordinatePrecision)] : void 0;
593
+ return n.coordinate ? [b(n.coordinate[0], this.config.coordinatePrecision), b(n.coordinate[1], this.config.coordinatePrecision)] : void 0;
594
594
  }, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
595
595
  }
596
596
  getSnappable(t, e) {
@@ -607,38 +607,38 @@ class Gt extends B {
607
607
  let d;
608
608
  const c = [t.lng, t.lat];
609
609
  if (this.config.projection === "web-mercator" ? d = (function(u, p) {
610
- let g = [1 / 0, 1 / 0], y = 1 / 0, m = 0;
610
+ let g = [1 / 0, 1 / 0], y = 1 / 0, f = 0;
611
611
  for (let v of p) {
612
- const C = v[0], f = v[1];
612
+ const C = v[0], m = v[1];
613
613
  let P, I = 1 / 0;
614
- const b = O(C[0], C[1]), L = O(f[0], f[1]), M = O(u[0], u[1]);
614
+ const w = O(C[0], C[1]), L = O(m[0], m[1]), M = O(u[0], u[1]);
615
615
  if (C[0] === u[0] && C[1] === u[1]) P = C;
616
- else if (f[0] === u[0] && f[1] === u[1]) P = f;
616
+ else if (m[0] === u[0] && m[1] === u[1]) P = m;
617
617
  else {
618
- const { x: N, y: _ } = ui(b, L, M), { lng: T, lat: $ } = R(N, _);
618
+ const { x: N, y: _ } = pi(w, L, M), { lng: T, lat: $ } = R(N, _);
619
619
  P = [T, $];
620
620
  }
621
- P && (I = F(M, O(P[0], P[1])), I < y && (g = P, y = I, m = p.indexOf(v)));
621
+ P && (I = F(M, O(P[0], P[1])), I < y && (g = P, y = I, f = p.indexOf(v)));
622
622
  }
623
- return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: m, distance: y };
623
+ return y === 1 / 0 ? void 0 : { coordinate: g, lineIndex: f, distance: y };
624
624
  })(c, l) : this.config.projection === "globe" && (d = (function(u, p) {
625
- let g = [1 / 0, 1 / 0], y = 1 / 0, m = 0;
625
+ let g = [1 / 0, 1 / 0], y = 1 / 0, f = 0;
626
626
  for (let v of p) {
627
- const C = v[0], f = v[1];
627
+ const C = v[0], m = v[1];
628
628
  let P, I = 1 / 0;
629
- C[0] === u[0] && C[1] === u[1] ? P = C : f[0] === u[0] && f[1] === u[1] ? P = f : [P] = hi(C, f, u), P && (I = U(u, P), I < y && (g = P, y = I, m = p.indexOf(v)));
629
+ C[0] === u[0] && C[1] === u[1] ? P = C : m[0] === u[0] && m[1] === u[1] ? P = m : [P] = ui(C, m, u), P && (I = U(u, P), I < y && (g = P, y = I, f = p.indexOf(v)));
630
630
  }
631
- return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: m };
631
+ return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: f };
632
632
  })(c, l)), !d) return;
633
633
  const h = this.pixelDistance.measure(t, d.coordinate);
634
- h < s.minDistance && h < this.pointerDistance && (s.featureId = n.id, s.coordinate = [w(d.coordinate[0], this.config.coordinatePrecision), w(d.coordinate[1], this.config.coordinatePrecision)], s.featureCoordinateIndex = d.lineIndex, s.minDistance = h);
634
+ h < s.minDistance && h < this.pointerDistance && (s.featureId = n.id, s.coordinate = [b(d.coordinate[0], this.config.coordinatePrecision), b(d.coordinate[1], this.config.coordinatePrecision)], s.featureCoordinateIndex = d.lineIndex, s.minDistance = h);
635
635
  }), s;
636
636
  }
637
637
  }
638
- const pi = { cancel: "Escape", finish: "Enter" }, gi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
639
- class Ut extends A {
638
+ const gi = { cancel: "Escape", finish: "Enter" }, yi = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
639
+ class zt extends A {
640
640
  constructor(t) {
641
- super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = pi, this.snapping = void 0, this.cursors = gi, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommittedCoordinates = void 0, this.snappedPointId = void 0, this.lastMouseMoveEvent = 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);
641
+ super(t, !0), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = gi, this.snapping = void 0, this.cursors = yi, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommittedCoordinates = void 0, this.snappedPointId = void 0, this.lastMouseMoveEvent = 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);
642
642
  }
643
643
  updateOptions(t) {
644
644
  super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t != null && t.snapping && (this.snapping = t.snapping), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.insertCoordinates && (this.insertCoordinates = t.insertCoordinates), t && t.editable && (this.editable = t.editable);
@@ -696,7 +696,7 @@ class Ut extends A {
696
696
  this.updateGeometries(l, i[i.length - 1], E.Commit), this.currentCoordinate++;
697
697
  }
698
698
  registerBehaviors(t) {
699
- this.coordinateSnapping = new It(t, new ct(t), new dt(t)), this.insertPoint = new ci(t), this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new Gt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new It(t, this.pixelDistance, this.clickBoundingBox);
699
+ this.coordinateSnapping = new Ot(t, new ht(t), new ct(t)), this.insertPoint = new hi(t), this.clickBoundingBox = new ct(t), this.pixelDistance = new ht(t), this.lineSnapping = new Ut(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Ot(t, this.pixelDistance, this.clickBoundingBox);
700
700
  }
701
701
  start() {
702
702
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -716,7 +716,7 @@ class Ut extends A {
716
716
  let o = [...i, e];
717
717
  if (this.insertCoordinates && this.currentId && this.lastCommittedCoordinates) {
718
718
  const s = this.lastCommittedCoordinates[this.lastCommittedCoordinates.length - 1], n = e;
719
- if (!tt(s, n)) {
719
+ if (!et(s, n)) {
720
720
  const a = this.generateInsertCoordinates(s, n);
721
721
  o = [...this.lastCommittedCoordinates.slice(0, -1), ...a, e];
722
722
  }
@@ -792,7 +792,7 @@ class Ut extends A {
792
792
  return e;
793
793
  }
794
794
  validateFeature(t) {
795
- return this.validateModeFeature(t, (e) => Rt(e, this.coordinatePrecision));
795
+ return this.validateModeFeature(t, (e) => Gt(e, this.coordinatePrecision));
796
796
  }
797
797
  lineStringFilter(t) {
798
798
  return !!(t.geometry.type === "LineString" && t.properties && t.properties.mode === this.mode);
@@ -810,14 +810,14 @@ class Ut extends A {
810
810
  this.editedFeatureId === t.id && this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0), this.snappedPointId && this.lastMouseMoveEvent && this.updateSnappedCoordinate(this.lastMouseMoveEvent), this.currentId === t.id && (this.closingPointId && (this.store.delete([this.closingPointId]), this.closingPointId = void 0), this.currentCoordinate = 0, this.currentId = void 0, this.state === "drawing" && this.setStarted());
811
811
  }
812
812
  }
813
- const yi = "Feature is not a Point", fi = "Feature has invalid coordinates", mi = "Feature has coordinates with excessive precision";
814
- function Le(r, t) {
815
- return r.geometry.type !== "Point" ? { valid: !1, reason: yi } : At(r.geometry.coordinates) ? Ot(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: mi } : { valid: !1, reason: fi };
813
+ const fi = "Feature is not a Point", mi = "Feature has invalid coordinates", vi = "Feature has coordinates with excessive precision";
814
+ function Fe(r, t) {
815
+ return r.geometry.type !== "Point" ? { valid: !1, reason: fi } : Rt(r.geometry.coordinates) ? bt(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: vi } : { valid: !1, reason: mi };
816
816
  }
817
- const vi = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
818
- class zt extends A {
817
+ const Ci = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
818
+ class Vt extends A {
819
819
  constructor(t) {
820
- super(t, !0), this.mode = "point", this.cursors = vi, this.editable = !1, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
820
+ super(t, !0), this.mode = "point", this.cursors = Ci, this.editable = !1, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.updateOptions(t);
821
821
  }
822
822
  updateOptions(t) {
823
823
  super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t != null && t.editable && (this.editable = t.editable);
@@ -856,7 +856,7 @@ class zt extends A {
856
856
  this.allowPointerEvent(this.pointerEvents.onDragEnd, t) && 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: S.EDITED, value: !1 }]), this.editedFeatureId = void 0, e(!0));
857
857
  }
858
858
  registerBehaviors(t) {
859
- this.pixelDistance = new ct(t), this.clickBoundingBox = new dt(t);
859
+ this.pixelDistance = new ht(t), this.clickBoundingBox = new ct(t);
860
860
  }
861
861
  styleFeature(t) {
862
862
  const e = x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
@@ -867,7 +867,7 @@ class zt extends A {
867
867
  return e;
868
868
  }
869
869
  validateFeature(t) {
870
- return this.validateModeFeature(t, (e) => Le(e, this.coordinatePrecision));
870
+ return this.validateModeFeature(t, (e) => Fe(e, this.coordinatePrecision));
871
871
  }
872
872
  onLeftClick(t) {
873
873
  const e = { type: "Point", coordinates: [t.lng, t.lat] }, i = { mode: this.mode };
@@ -895,7 +895,7 @@ class zt extends A {
895
895
  this.editedFeatureId === t.id && (this.editedFeatureId = void 0, this.setCursor(this.cursors.create));
896
896
  }
897
897
  }
898
- class Ci extends B {
898
+ class Pi extends B {
899
899
  constructor(t, e) {
900
900
  super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
901
901
  }
@@ -921,7 +921,7 @@ class Ci extends B {
921
921
  return { isClosing: o < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
922
922
  }
923
923
  }
924
- class Fe extends B {
924
+ class Me extends B {
925
925
  constructor(t) {
926
926
  super(t);
927
927
  }
@@ -976,10 +976,10 @@ class Fe extends B {
976
976
  e && (this.deleteCoordinatePoints(e), this.setFeatureCoordinatePoints(t, null));
977
977
  }
978
978
  }
979
- const Pi = { cancel: "Escape", finish: "Enter" }, Si = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
980
- class Me extends A {
979
+ const Si = { cancel: "Escape", finish: "Enter" }, Ii = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
980
+ class De extends A {
981
981
  constructor(t) {
982
- super(t, !0), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Pi, this.cursors = Si, this.mouseMove = !1, this.showCoordinatePoints = !1, this.lastMouseMoveEvent = void 0, 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.coordinatePoints = 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);
982
+ super(t, !0), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Si, this.cursors = Ii, this.mouseMove = !1, this.showCoordinatePoints = !1, this.lastMouseMoveEvent = void 0, 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.coordinatePoints = 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);
983
983
  }
984
984
  updateOptions(t) {
985
985
  if (super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.snapping && (this.snapping = t.snapping), t?.editable !== void 0 && (this.editable = t.editable), t?.pointerEvents !== void 0 && (this.pointerEvents = t.pointerEvents), t?.showCoordinatePoints !== void 0) {
@@ -998,13 +998,13 @@ class Me extends A {
998
998
  if (t.length < 5 || !this.updatePolygonGeometry([...t.slice(0, -2), t[0]], E.Finish)) return;
999
999
  const e = this.currentId;
1000
1000
  if (this.currentId) {
1001
- const i = pt(this.store.getGeometryCopy(this.currentId));
1001
+ const i = yt(this.store.getGeometryCopy(this.currentId));
1002
1002
  i && (this.store.updateGeometry([{ id: this.currentId, geometry: i }]), this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(this.currentId)), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }, { id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: void 0 }, { id: this.currentId, property: S.PROVISIONAL_COORDINATE_COUNT, value: void 0 }]);
1003
1003
  }
1004
1004
  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" });
1005
1005
  }
1006
1006
  registerBehaviors(t) {
1007
- this.clickBoundingBox = new dt(t), this.pixelDistance = new ct(t), this.lineSnapping = new Gt(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new It(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new Ci(t, this.pixelDistance), this.coordinatePoints = new Fe(t);
1007
+ this.clickBoundingBox = new ct(t), this.pixelDistance = new ht(t), this.lineSnapping = new Ut(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new Ot(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new Pi(t, this.pixelDistance), this.coordinatePoints = new Me(t);
1008
1008
  }
1009
1009
  start() {
1010
1010
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -1076,20 +1076,20 @@ class Me extends A {
1076
1076
  const e = this.snapCoordinate(t);
1077
1077
  e && (t.lng = e[0], t.lat = e[1]);
1078
1078
  const i = this.store.getGeometryCopy(this.currentId);
1079
- if (tt([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]], E.Commit)) return;
1079
+ if (et([t.lng, t.lat], i.coordinates[0][0]) || !this.updatePolygonGeometry([i.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], i.coordinates[0][0]], E.Commit)) return;
1080
1080
  this.store.updateProperty([{ id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++;
1081
1081
  } else if (this.currentCoordinate === 2 && this.currentId) {
1082
1082
  const e = this.snapCoordinate(t);
1083
1083
  e && (t.lng = e[0], t.lat = e[1]);
1084
1084
  const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
1085
- if (tt([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]], E.Commit)) return;
1085
+ if (et([t.lng, t.lat], i[1]) || !this.updatePolygonGeometry([i[0], i[1], [t.lng, t.lat], [t.lng, t.lat], i[0]], E.Commit)) return;
1086
1086
  this.currentCoordinate === 2 && this.closingPoints.create(i, "polygon"), this.store.updateProperty([{ id: this.currentId, property: S.COMMITTED_COORDINATE_COUNT, value: this.currentCoordinate + 1 }]), this.currentCoordinate++;
1087
1087
  } else if (this.currentId) {
1088
1088
  const e = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: o } = this.closingPoints.isClosingPoint(t);
1089
1089
  if (o || i) this.close();
1090
1090
  else {
1091
1091
  const s = this.snapCoordinate(t);
1092
- if (s && (t.lng = s[0], t.lat = s[1]), tt([t.lng, t.lat], e[this.currentCoordinate - 1])) return;
1092
+ if (s && (t.lng = s[0], t.lat = s[1]), et([t.lng, t.lat], e[this.currentCoordinate - 1])) return;
1093
1093
  const n = /* @__PURE__ */ (function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
1094
1094
  return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
1095
1095
  })([[...e.slice(0, -1), [t.lng, t.lat], e[0]]]);
@@ -1161,13 +1161,13 @@ class Me extends A {
1161
1161
  this.showCoordinatePoints && this.coordinatePoints.createOrUpdate(t.id), this.editedFeatureId === t.id && this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0), this.snappedPointId && this.lastMouseMoveEvent && this.updateSnappedCoordinate(this.lastMouseMoveEvent), this.currentId === t.id && (this.currentCoordinate = 0, this.currentId = void 0, this.closingPoints.delete(), this.state === "drawing" && this.setStarted());
1162
1162
  }
1163
1163
  validateFeature(t) {
1164
- return this.validateModeFeature(t, (e) => Et(e, this.coordinatePrecision));
1164
+ return this.validateModeFeature(t, (e) => wt(e, this.coordinatePrecision));
1165
1165
  }
1166
1166
  }
1167
- const Ii = { cancel: "Escape", finish: "Enter" }, xi = { start: "crosshair" };
1168
- class De extends A {
1167
+ const xi = { cancel: "Escape", finish: "Enter" }, Oi = { start: "crosshair" };
1168
+ class _e extends A {
1169
1169
  constructor(t) {
1170
- super(t, !0), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = Ii, this.cursors = xi, this.updateOptions(t);
1170
+ super(t, !0), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = xi, this.cursors = Oi, this.updateOptions(t);
1171
1171
  }
1172
1172
  updateOptions(t) {
1173
1173
  super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents));
@@ -1182,7 +1182,7 @@ class De extends A {
1182
1182
  close() {
1183
1183
  const t = this.currentRectangleId;
1184
1184
  if (t) {
1185
- const e = pt(this.store.getGeometryCopy(t));
1185
+ const e = yt(this.store.getGeometryCopy(t));
1186
1186
  e && this.store.updateGeometry([{ id: t, geometry: e }]), this.store.updateProperty([{ id: t, property: S.CURRENTLY_DRAWING, value: void 0 }]);
1187
1187
  }
1188
1188
  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" });
@@ -1223,13 +1223,13 @@ class De extends A {
1223
1223
  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 = j), e;
1224
1224
  }
1225
1225
  validateFeature(t) {
1226
- return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
1226
+ return this.validateModeFeature(t, (e) => gt(e, this.coordinatePrecision));
1227
1227
  }
1228
1228
  afterFeatureUpdated(t) {
1229
1229
  this.currentRectangleId === t.id && (this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted());
1230
1230
  }
1231
1231
  }
1232
- class Q extends A {
1232
+ class tt extends A {
1233
1233
  constructor(t) {
1234
1234
  if (!t.modeName) throw new Error("Mode name is required for TerraDrawRenderMode");
1235
1235
  super(t, !0), this.type = q.Render, this.mode = "render", this.updateOptions(t);
@@ -1268,50 +1268,50 @@ class Q extends A {
1268
1268
  validateFeature(t) {
1269
1269
  const e = super.validateFeature(t);
1270
1270
  if (e.valid) {
1271
- const i = t, o = Le(i, this.coordinatePrecision).valid || Et(i, this.coordinatePrecision).valid || Rt(i, this.coordinatePrecision).valid;
1271
+ const i = t, o = Fe(i, this.coordinatePrecision).valid || wt(i, this.coordinatePrecision).valid || Gt(i, this.coordinatePrecision).valid;
1272
1272
  return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
1273
1273
  }
1274
1274
  return e;
1275
1275
  }
1276
1276
  }
1277
- function kt(r, t) {
1277
+ function Nt(r, t) {
1278
1278
  const e = r, i = t, o = D(e[1]), s = D(i[1]);
1279
1279
  let n = D(i[0] - e[0]);
1280
1280
  n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
1281
1281
  const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (V(Math.atan2(n, a)) + 360) % 360;
1282
1282
  return l > 180 ? -(360 - l) : l;
1283
1283
  }
1284
- function _e(r, t, e) {
1284
+ function ke(r, t, e) {
1285
1285
  let i = t;
1286
1286
  t < 0 && (i = -Math.abs(i));
1287
- const o = i / xe, s = r[0] * Math.PI / 180, n = D(r[1]), a = D(e), l = o * Math.cos(a);
1287
+ const o = i / Oe, s = r[0] * Math.PI / 180, n = D(r[1]), a = D(e), l = o * Math.cos(a);
1288
1288
  let d = n + l;
1289
1289
  Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
1290
1290
  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 * (s + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1291
1291
  return u[0] += u[0] - r[0] > 180 ? -360 : r[0] - u[0] > 180 ? 360 : 0, u;
1292
1292
  }
1293
- function ke(r, t, e, i, o) {
1293
+ function Ne(r, t, e, i, o) {
1294
1294
  const s = i(r[0], r[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((s.x + n.x) / 2, (s.y + n.y) / 2);
1295
- return [w(a, e), w(l, e)];
1295
+ return [b(a, e), b(l, e)];
1296
1296
  }
1297
- function Oi(r, t, e) {
1298
- const i = _e(r, 1e3 * U(r, t) / 2, kt(r, t));
1299
- return [w(i[0], e), w(i[1], e)];
1297
+ function Ei(r, t, e) {
1298
+ const i = ke(r, 1e3 * U(r, t) / 2, Nt(r, t));
1299
+ return [b(i[0], e), b(i[1], e)];
1300
1300
  }
1301
- function de({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
1301
+ function ce({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
1302
1302
  const s = [];
1303
1303
  for (let n = 0; n < r.length - 1; n++) {
1304
1304
  let a;
1305
- if (o === "web-mercator") a = ke(r[n], r[n + 1], t, i, e);
1305
+ if (o === "web-mercator") a = Ne(r[n], r[n + 1], t, i, e);
1306
1306
  else {
1307
1307
  if (o !== "globe") throw new Error("Invalid projection");
1308
- a = Oi(r[n], r[n + 1], t);
1308
+ a = Ei(r[n], r[n + 1], t);
1309
1309
  }
1310
1310
  s.push(a);
1311
1311
  }
1312
1312
  return s;
1313
1313
  }
1314
- class Ei extends B {
1314
+ class bi extends B {
1315
1315
  constructor(t, e, i) {
1316
1316
  super(t), this.config = void 0, this.selectionPointBehavior = void 0, this.coordinatePointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e, this.coordinatePointBehavior = i;
1317
1317
  }
@@ -1327,17 +1327,17 @@ class Ei extends B {
1327
1327
  create(t, e, i) {
1328
1328
  if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
1329
1329
  this._midPoints = this.store.create((function(o, s, n, a, l, d) {
1330
- return de({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1330
+ return ce({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1331
1331
  })(t, (o) => ({ mode: this.mode, [k.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
1332
1332
  }
1333
1333
  delete() {
1334
1334
  this._midPoints.length && (this.store.delete(this._midPoints), this._midPoints = []);
1335
1335
  }
1336
1336
  getUpdated(t) {
1337
- if (this._midPoints.length !== 0) return de({ 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 } }));
1337
+ if (this._midPoints.length !== 0) return ce({ 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 } }));
1338
1338
  }
1339
1339
  }
1340
- class bi extends B {
1340
+ class wi extends B {
1341
1341
  constructor(t) {
1342
1342
  super(t), this._selectionPoints = [];
1343
1343
  }
@@ -1363,7 +1363,7 @@ class bi extends B {
1363
1363
  if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
1364
1364
  }
1365
1365
  }
1366
- function Ne(r, t) {
1366
+ function Te(r, t) {
1367
1367
  let e = !1;
1368
1368
  for (let n = 0, a = t.length; n < a; n++) {
1369
1369
  const l = t[n];
@@ -1372,7 +1372,7 @@ function Ne(r, t) {
1372
1372
  var i, o, s;
1373
1373
  return e;
1374
1374
  }
1375
- const Nt = (r, t, e) => {
1375
+ const Tt = (r, t, e) => {
1376
1376
  const i = (s) => s * s, o = (s, n) => i(s.x - n.x) + i(s.y - n.y);
1377
1377
  return Math.sqrt(((s, n, a) => {
1378
1378
  const l = o(n, a);
@@ -1381,7 +1381,7 @@ const Nt = (r, t, e) => {
1381
1381
  return d = Math.max(0, Math.min(1, d)), o(s, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
1382
1382
  })(r, t, e));
1383
1383
  };
1384
- class wi extends B {
1384
+ class Li extends B {
1385
1385
  constructor(t, e, i) {
1386
1386
  super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
1387
1387
  }
@@ -1397,18 +1397,18 @@ class wi extends B {
1397
1397
  } else if (g.type === "LineString") {
1398
1398
  if (i) continue;
1399
1399
  for (let y = 0; y < g.coordinates.length - 1; y++) {
1400
- const m = g.coordinates[y], v = g.coordinates[y + 1], C = Nt({ x: t.containerX, y: t.containerY }, this.project(m[0], m[1]), this.project(v[0], v[1]));
1400
+ const f = g.coordinates[y], v = g.coordinates[y + 1], C = Tt({ x: t.containerX, y: t.containerY }, this.project(f[0], f[1]), this.project(v[0], v[1]));
1401
1401
  C < this.pointerDistance && C < l && (l = C, o = p);
1402
1402
  }
1403
1403
  } else if (g.type === "Polygon") {
1404
1404
  if (i || o) continue;
1405
- Ne([t.lng, t.lat], g.coordinates) && (n = p);
1405
+ Te([t.lng, t.lat], g.coordinates) && (n = p);
1406
1406
  }
1407
1407
  }
1408
1408
  return { clickedFeature: i || o || n, clickedMidPoint: s };
1409
1409
  }
1410
1410
  }
1411
- class Li extends B {
1411
+ class Fi extends B {
1412
1412
  constructor(t, e, i, o, s) {
1413
1413
  super(t), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o, this.coordinatePoints = s;
1414
1414
  }
@@ -1435,13 +1435,13 @@ class Li extends B {
1435
1435
  const h = s[c];
1436
1436
  let u, p;
1437
1437
  if (this.config.projection === "web-mercator") {
1438
- const g = O(this.dragPosition[0], this.dragPosition[1]), y = O(o[0], o[1]), m = O(h[0], h[1]), v = { x: g.x - y.x, y: g.y - y.y }, C = m.x - v.x, f = m.y - v.y, { lng: P, lat: I } = R(C, f);
1438
+ const g = O(this.dragPosition[0], this.dragPosition[1]), y = O(o[0], o[1]), f = O(h[0], h[1]), v = { x: g.x - y.x, y: g.y - y.y }, C = f.x - v.x, m = f.y - v.y, { lng: P, lat: I } = R(C, m);
1439
1439
  u = P, p = I;
1440
1440
  } else {
1441
1441
  const g = [this.dragPosition[0] - o[0], this.dragPosition[1] - o[1]];
1442
1442
  u = h[0] - g[0], p = h[1] - g[1];
1443
1443
  }
1444
- if (u = w(u, this.config.coordinatePrecision), p = w(p, this.config.coordinatePrecision), u > 180 || u < -180 || p > 90 || p < -90) return !1;
1444
+ if (u = b(u, this.config.coordinatePrecision), p = b(p, this.config.coordinatePrecision), u > 180 || u < -180 || p > 90 || p < -90) return !1;
1445
1445
  s[c] = [u, p];
1446
1446
  }
1447
1447
  i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
@@ -1451,7 +1451,7 @@ class Li extends B {
1451
1451
  } else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
1452
1452
  }
1453
1453
  }
1454
- class Fi extends B {
1454
+ class Mi extends B {
1455
1455
  constructor(t, e, i, o, s, n, a) {
1456
1456
  super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = void 0, this.coordinateSnapping = void 0, this.lineSnapping = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o, this.coordinatePoints = s, this.coordinateSnapping = n, this.lineSnapping = a;
1457
1457
  }
@@ -1502,8 +1502,8 @@ class Fi extends B {
1502
1502
  const v = d.length - 1;
1503
1503
  d[0] = u, d[v] = u;
1504
1504
  } else d[n] = u;
1505
- const p = this.selectionPoints.getOneUpdated(n, u), g = p ? [p] : [], y = this.midPoints.getUpdated(d) || [], m = this.coordinatePoints.getUpdated(s, d) || [];
1506
- return !(a.type !== "Point" && !e && jt({ geometry: a }) || i && !i(h, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional }).valid || (this.store.updateGeometry([{ id: s, geometry: a }, ...g, ...y, ...m]), 0));
1505
+ const p = this.selectionPoints.getOneUpdated(n, u), g = p ? [p] : [], y = this.midPoints.getUpdated(d) || [], f = this.coordinatePoints.getUpdated(s, d) || [];
1506
+ return !(a.type !== "Point" && !e && At({ geometry: a }) || i && !i(h, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional }).valid || (this.store.updateGeometry([{ id: s, geometry: a }, ...g, ...y, ...f]), 0));
1507
1507
  }
1508
1508
  isDragging() {
1509
1509
  return this.draggedCoordinate.id !== null;
@@ -1515,20 +1515,20 @@ class Fi extends B {
1515
1515
  this.draggedCoordinate = { id: null, index: -1 };
1516
1516
  }
1517
1517
  }
1518
- function ce(r) {
1518
+ function he(r) {
1519
1519
  let t = 0, e = 0, i = 0;
1520
1520
  return (r.geometry.type === "Polygon" ? r.geometry.coordinates[0].slice(0, -1) : r.geometry.coordinates).forEach((o) => {
1521
1521
  t += o[0], e += o[1], i++;
1522
1522
  }, !0), [t / i, e / i];
1523
1523
  }
1524
- const Te = (r, t) => {
1524
+ const We = (r, t) => {
1525
1525
  if (t === 0 || t === 360 || t === -360) return r;
1526
1526
  const e = 0.017453292519943295 * t, i = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map(([n, a]) => O(n, a)), o = i.reduce((n, a) => ({ x: n.x + a.x, y: n.y + a.y }), { x: 0, y: 0 });
1527
1527
  o.x /= i.length, o.y /= i.length;
1528
1528
  const s = i.map((n) => ({ x: o.x + (n.x - o.x) * Math.cos(e) - (n.y - o.y) * Math.sin(e), y: o.y + (n.x - o.x) * Math.sin(e) + (n.y - o.y) * Math.cos(e) })).map(({ x: n, y: a }) => [R(n, a).lng, R(n, a).lat]);
1529
1529
  return r.geometry.type === "Polygon" ? r.geometry.coordinates[0] = s : r.geometry.coordinates = s, r;
1530
1530
  };
1531
- function Tt(r) {
1531
+ function Wt(r) {
1532
1532
  const t = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map((e) => {
1533
1533
  const { x: i, y: o } = O(e[0], e[1]);
1534
1534
  return [i, o];
@@ -1551,7 +1551,7 @@ function Tt(r) {
1551
1551
  return { x: o / i, y: s / i };
1552
1552
  })(t);
1553
1553
  }
1554
- class Mi extends B {
1554
+ class Di extends B {
1555
1555
  constructor(t, e, i, o) {
1556
1556
  super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = void 0, this.lastBearing = void 0, this.selectedGeometry = void 0, this.selectedGeometryCentroid = void 0, this.selectedGeometryWebMercatorCentroid = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i, this.coordinatePoints = o;
1557
1557
  }
@@ -1566,40 +1566,40 @@ class Mi extends B {
1566
1566
  let n;
1567
1567
  const a = { type: "Feature", geometry: o, properties: {} };
1568
1568
  if (this.config.projection === "web-mercator") {
1569
- this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid = Tt(a));
1569
+ this.selectedGeometryWebMercatorCentroid || (this.selectedGeometryWebMercatorCentroid = Wt(a));
1570
1570
  const u = O(t.lng, t.lat);
1571
1571
  if (n = G(this.selectedGeometryWebMercatorCentroid, u), n === 0) return;
1572
1572
  if (!this.lastBearing) return void (this.lastBearing = n);
1573
- Te(a, -(this.lastBearing - n));
1573
+ We(a, -(this.lastBearing - n));
1574
1574
  } else {
1575
1575
  if (this.config.projection !== "globe") throw new Error("Unsupported projection");
1576
- if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid = ce({ geometry: o })), n = kt(this.selectedGeometryCentroid, s), !this.lastBearing) return void (this.lastBearing = n + 180);
1576
+ if (this.selectedGeometryCentroid || (this.selectedGeometryCentroid = he({ geometry: o })), n = Nt(this.selectedGeometryCentroid, s), !this.lastBearing) return void (this.lastBearing = n + 180);
1577
1577
  (function(u, p) {
1578
1578
  if (p === 0 || p === 360 || p === -360) return u;
1579
- const g = ce(u);
1579
+ const g = he(u);
1580
1580
  (u.geometry.type === "Polygon" ? u.geometry.coordinates[0] : u.geometry.coordinates).forEach((y) => {
1581
- const m = kt(g, y) + p, v = (function(f, P) {
1582
- f[0] += f[0] - P[0] > 180 ? -360 : P[0] - f[0] > 180 ? 360 : 0;
1583
- const I = xe, b = P[1] * Math.PI / 180, L = f[1] * Math.PI / 180, M = L - b;
1584
- let N = Math.abs(f[0] - P[0]) * Math.PI / 180;
1581
+ const f = Nt(g, y) + p, v = (function(m, P) {
1582
+ m[0] += m[0] - P[0] > 180 ? -360 : P[0] - m[0] > 180 ? 360 : 0;
1583
+ const I = Oe, w = P[1] * Math.PI / 180, L = m[1] * Math.PI / 180, M = L - w;
1584
+ let N = Math.abs(m[0] - P[0]) * Math.PI / 180;
1585
1585
  N > Math.PI && (N -= 2 * Math.PI);
1586
- const _ = Math.log(Math.tan(L / 2 + Math.PI / 4) / Math.tan(b / 2 + Math.PI / 4)), T = Math.abs(_) > 1e-11 ? M / _ : Math.cos(b);
1586
+ const _ = Math.log(Math.tan(L / 2 + Math.PI / 4) / Math.tan(w / 2 + Math.PI / 4)), T = Math.abs(_) > 1e-11 ? M / _ : Math.cos(w);
1587
1587
  return Math.sqrt(M * M + T * T * N * N) * I;
1588
- })(g, y), C = _e(g, v, m);
1588
+ })(g, y), C = ke(g, v, f);
1589
1589
  y[0] = C[0], y[1] = C[1];
1590
1590
  });
1591
1591
  })(a, -(this.lastBearing - (n + 180)));
1592
1592
  }
1593
1593
  const l = o.type === "Polygon" ? o.coordinates[0] : o.coordinates;
1594
1594
  l.forEach((u) => {
1595
- u[0] = w(u[0], this.coordinatePrecision), u[1] = w(u[1], this.coordinatePrecision);
1595
+ u[0] = b(u[0], this.coordinatePrecision), u[1] = b(u[1], this.coordinatePrecision);
1596
1596
  });
1597
1597
  const d = this.midPoints.getUpdated(l) || [], c = this.selectionPoints.getUpdated(l) || [], h = this.coordinatePoints.getUpdated(e, l) || [];
1598
1598
  if (i && !i({ id: e, type: "Feature", geometry: o, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional })) return !1;
1599
1599
  this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d, ...h]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
1600
1600
  }
1601
1601
  }
1602
- class Di extends B {
1602
+ class _i extends B {
1603
1603
  constructor(t, e) {
1604
1604
  super(t), this.config = void 0, this.dragCoordinateResizeBehavior = void 0, this.config = t, this.dragCoordinateResizeBehavior = e;
1605
1605
  }
@@ -1614,13 +1614,13 @@ class Di extends B {
1614
1614
  this.dragCoordinateResizeBehavior.stopDragging();
1615
1615
  }
1616
1616
  }
1617
- function We({ coordinates: r, originX: t, originY: e, xScale: i, yScale: o }) {
1617
+ function Be({ coordinates: r, originX: t, originY: e, xScale: i, yScale: o }) {
1618
1618
  i === 1 && o === 1 || r.forEach((s) => {
1619
1619
  const { x: n, y: a } = O(s[0], s[1]), l = t + (n - t) * i, d = e + (a - e) * o, { lng: c, lat: h } = R(l, d);
1620
1620
  s[0] = c, s[1] = h;
1621
1621
  });
1622
1622
  }
1623
- class _i extends B {
1623
+ class ki extends B {
1624
1624
  constructor(t, e, i, o, s) {
1625
1625
  super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinatePoints = 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, this.coordinatePoints = s;
1626
1626
  }
@@ -1679,7 +1679,7 @@ class _i extends B {
1679
1679
  centerWebMercatorDrag(t) {
1680
1680
  const e = this.getSelectedFeatureDataWebMercator();
1681
1681
  if (!e) return null;
1682
- const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = Tt(i);
1682
+ const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = Wt(i);
1683
1683
  if (!a) return null;
1684
1684
  const l = O(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = O(t.lng, t.lat);
1685
1685
  return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
@@ -1687,7 +1687,7 @@ class _i extends B {
1687
1687
  centerFixedWebMercatorDrag(t) {
1688
1688
  const e = this.getSelectedFeatureDataWebMercator();
1689
1689
  if (!e) return null;
1690
- const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = Tt(i);
1690
+ const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = Wt(i);
1691
1691
  if (!a) return null;
1692
1692
  const l = O(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = O(t.lng, t.lat);
1693
1693
  return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
@@ -1695,7 +1695,7 @@ class _i extends B {
1695
1695
  scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
1696
1696
  if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
1697
1697
  let n = F(e, o) / F(e, i);
1698
- return n < 0 && (n = this.minimumScale), We({ coordinates: s, originX: e.x, originY: e.y, xScale: n, yScale: n }), s;
1698
+ return n < 0 && (n = this.minimumScale), Be({ coordinates: s, originX: e.x, originY: e.y, xScale: n, yScale: n }), s;
1699
1699
  }
1700
1700
  oppositeFixedWebMercatorDrag(t) {
1701
1701
  const e = this.getSelectedFeatureDataWebMercator();
@@ -1776,19 +1776,19 @@ class _i extends B {
1776
1776
  if (e === "center" ? s = this.centerWebMercatorDrag(t) : e === "opposite" ? s = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? s = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (s = this.oppositeFixedWebMercatorDrag(t)), !s) return !1;
1777
1777
  for (let c = 0; c < s.length; c++) {
1778
1778
  const h = s[c];
1779
- if (h[0] = w(h[0], this.coordinatePrecision), h[1] = w(h[1], this.coordinatePrecision), !Ot(h, this.coordinatePrecision)) return !1;
1779
+ if (h[0] = b(h[0], this.coordinatePrecision), h[1] = b(h[1], this.coordinatePrecision), !bt(h, this.coordinatePrecision)) return !1;
1780
1780
  }
1781
1781
  const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = this.coordinatePoints.getUpdated(o.id, s) || [], d = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
1782
1782
  return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: d, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: E.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: d }, ...a, ...n, ...l]), 0));
1783
1783
  }
1784
1784
  }
1785
- const ki = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, he = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
1786
- class Vt extends Qe {
1785
+ const Ni = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] }, ue = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
1786
+ class $t extends ti {
1787
1787
  constructor(t) {
1788
- super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = ki, this.cursors = he, this.validations = {}, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinateSnap = 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.coordinatePoints = void 0, this.lineSnap = void 0, this.updateOptions(t);
1788
+ super(t, !0), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = {}, this.keyEvents = Ni, this.cursors = ue, this.validations = {}, this.selectionPoints = void 0, this.midPoints = void 0, this.coordinateSnap = 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.coordinatePoints = void 0, this.lineSnap = void 0, this.updateOptions(t);
1789
1789
  }
1790
1790
  updateOptions(t) {
1791
- if (super.updateOptions(t), this.cursors = t && t.cursors ? x({}, this.cursors, t.cursors) : he, t?.keyEvents === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t?.dragEventThrottle !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), t?.allowManualDeselection !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
1791
+ if (super.updateOptions(t), this.cursors = t && t.cursors ? x({}, this.cursors, t.cursors) : ue, t?.keyEvents === null ? this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t?.dragEventThrottle !== void 0 && (this.dragEventThrottle = t.dragEventThrottle), t?.allowManualDeselection !== void 0 && (this.allowManualDeselection = t.allowManualDeselection), t != null && t.flags) {
1792
1792
  this.flags = x({}, this.flags, t.flags), this.validations = {};
1793
1793
  for (const e in this.flags) {
1794
1794
  const i = this.flags[e].feature;
@@ -1804,7 +1804,7 @@ class Vt extends Qe {
1804
1804
  this._state = "selecting";
1805
1805
  }
1806
1806
  registerBehaviors(t) {
1807
- this.pixelDistance = new ct(t), this.clickBoundingBox = new dt(t), this.featuresAtMouseEvent = new wi(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new bi(t), this.coordinatePoints = new Fe(t), this.midPoints = new Ei(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new It(t, this.pixelDistance, this.clickBoundingBox), this.lineSnap = new Gt(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Mi(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Li(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new Fi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap, this.lineSnap), this.dragCoordinateResizeFeature = new _i(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new Di(t, this.dragCoordinateResizeFeature);
1807
+ this.pixelDistance = new ht(t), this.clickBoundingBox = new ct(t), this.featuresAtMouseEvent = new Li(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new wi(t), this.coordinatePoints = new Me(t), this.midPoints = new bi(t, this.selectionPoints, this.coordinatePoints), this.coordinateSnap = new Ot(t, this.pixelDistance, this.clickBoundingBox), this.lineSnap = new Ut(t, this.pixelDistance, this.clickBoundingBox), this.rotateFeature = new Di(t, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragFeature = new Fi(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints, this.coordinatePoints), this.dragCoordinate = new Mi(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints, this.coordinateSnap, this.lineSnap), this.dragCoordinateResizeFeature = new ki(t, this.pixelDistance, this.selectionPoints, this.midPoints, this.coordinatePoints), this.scaleFeature = new _i(t, this.dragCoordinateResizeFeature);
1808
1808
  }
1809
1809
  deselectFeature() {
1810
1810
  this.deselect();
@@ -1973,7 +1973,7 @@ class Vt extends Qe {
1973
1973
  }
1974
1974
  }
1975
1975
  }
1976
- class Ni extends A {
1976
+ class Ti extends A {
1977
1977
  constructor(...t) {
1978
1978
  super(...t), this.type = q.Static, this.mode = "static";
1979
1979
  }
@@ -2001,85 +2001,85 @@ class Ni extends A {
2001
2001
  return x({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2002
2002
  }
2003
2003
  }
2004
- function Be(r, t, e, i, o) {
2004
+ function je(r, t, e, i, o) {
2005
2005
  for (; i > e; ) {
2006
2006
  if (i - e > 600) {
2007
2007
  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);
2008
- Be(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
2008
+ je(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
2009
2009
  }
2010
2010
  const s = r[t];
2011
2011
  let n = e, a = i;
2012
- for (it(r, e, t), o(r[i], s) > 0 && it(r, e, i); n < a; ) {
2013
- for (it(r, n, a), n++, a--; o(r[n], s) < 0; ) n++;
2012
+ for (ot(r, e, t), o(r[i], s) > 0 && ot(r, e, i); n < a; ) {
2013
+ for (ot(r, n, a), n++, a--; o(r[n], s) < 0; ) n++;
2014
2014
  for (; o(r[a], s) > 0; ) a--;
2015
2015
  }
2016
- o(r[e], s) === 0 ? it(r, e, a) : (a++, it(r, a, i)), a <= t && (e = a + 1), t <= a && (i = a - 1);
2016
+ o(r[e], s) === 0 ? ot(r, e, a) : (a++, ot(r, a, i)), a <= t && (e = a + 1), t <= a && (i = a - 1);
2017
2017
  }
2018
2018
  }
2019
- function it(r, t, e) {
2019
+ function ot(r, t, e) {
2020
2020
  const i = r[t];
2021
2021
  r[t] = r[e], r[e] = i;
2022
2022
  }
2023
- function J(r, t) {
2024
- nt(r, 0, r.children.length, t, r);
2023
+ function H(r, t) {
2024
+ at(r, 0, r.children.length, t, r);
2025
2025
  }
2026
- function nt(r, t, e, i, o) {
2027
- o || (o = Z([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
2026
+ function at(r, t, e, i, o) {
2027
+ o || (o = Q([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
2028
2028
  for (let s = t; s < e; s++) {
2029
2029
  const n = r.children[s];
2030
- at(o, r.leaf ? i(n) : n);
2030
+ lt(o, r.leaf ? i(n) : n);
2031
2031
  }
2032
2032
  return o;
2033
2033
  }
2034
- function at(r, t) {
2034
+ function lt(r, t) {
2035
2035
  return r.minX = Math.min(r.minX, t.minX), r.minY = Math.min(r.minY, t.minY), r.maxX = Math.max(r.maxX, t.maxX), r.maxY = Math.max(r.maxY, t.maxY), r;
2036
2036
  }
2037
- function Ti(r, t) {
2037
+ function Wi(r, t) {
2038
2038
  return r.minX - t.minX;
2039
2039
  }
2040
- function Wi(r, t) {
2040
+ function Bi(r, t) {
2041
2041
  return r.minY - t.minY;
2042
2042
  }
2043
- function Ft(r) {
2043
+ function Mt(r) {
2044
2044
  return (r.maxX - r.minX) * (r.maxY - r.minY);
2045
2045
  }
2046
- function ft(r) {
2046
+ function vt(r) {
2047
2047
  return r.maxX - r.minX + (r.maxY - r.minY);
2048
2048
  }
2049
- function Bi(r, t) {
2049
+ function ji(r, t) {
2050
2050
  const e = Math.max(r.minX, t.minX), i = Math.max(r.minY, t.minY), o = Math.min(r.maxX, t.maxX), s = Math.min(r.maxY, t.maxY);
2051
2051
  return Math.max(0, o - e) * Math.max(0, s - i);
2052
2052
  }
2053
- function Mt(r, t) {
2053
+ function Dt(r, t) {
2054
2054
  return r.minX <= t.minX && r.minY <= t.minY && t.maxX <= r.maxX && t.maxY <= r.maxY;
2055
2055
  }
2056
- function mt(r, t) {
2056
+ function Ct(r, t) {
2057
2057
  return t.minX <= r.maxX && t.minY <= r.maxY && t.maxX >= r.minX && t.maxY >= r.minY;
2058
2058
  }
2059
- function Z(r) {
2059
+ function Q(r) {
2060
2060
  return { children: r, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
2061
2061
  }
2062
- function ue(r, t, e, i, o) {
2062
+ function pe(r, t, e, i, o) {
2063
2063
  const s = [t, e];
2064
2064
  for (; s.length; ) {
2065
2065
  if ((e = s.pop()) - (t = s.pop()) <= i) continue;
2066
2066
  const n = t + Math.ceil((e - t) / i / 2) * i;
2067
- Be(r, n, t, e, o), s.push(t, n, n, e);
2067
+ je(r, n, t, e, o), s.push(t, n, n, e);
2068
2068
  }
2069
2069
  }
2070
- class ji {
2070
+ class Ai {
2071
2071
  constructor(t) {
2072
2072
  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();
2073
2073
  }
2074
2074
  search(t) {
2075
2075
  let e = this.data;
2076
2076
  const i = [];
2077
- if (!mt(t, e)) return i;
2077
+ if (!Ct(t, e)) return i;
2078
2078
  const o = this.toBBox, s = [];
2079
2079
  for (; e; ) {
2080
2080
  for (let n = 0; n < e.children.length; n++) {
2081
2081
  const a = e.children[n], l = e.leaf ? o(a) : a;
2082
- mt(t, l) && (e.leaf ? i.push(a) : Mt(t, l) ? this._all(a, i) : s.push(a));
2082
+ Ct(t, l) && (e.leaf ? i.push(a) : Dt(t, l) ? this._all(a, i) : s.push(a));
2083
2083
  }
2084
2084
  e = s.pop();
2085
2085
  }
@@ -2087,13 +2087,13 @@ class ji {
2087
2087
  }
2088
2088
  collides(t) {
2089
2089
  let e = this.data;
2090
- if (mt(t, e)) {
2090
+ if (Ct(t, e)) {
2091
2091
  const i = [];
2092
2092
  for (; e; ) {
2093
2093
  for (let o = 0; o < e.children.length; o++) {
2094
2094
  const s = e.children[o], n = e.leaf ? this.toBBox(s) : s;
2095
- if (mt(t, n)) {
2096
- if (e.leaf || Mt(t, n)) return !0;
2095
+ if (Ct(t, n)) {
2096
+ if (e.leaf || Dt(t, n)) return !0;
2097
2097
  i.push(s);
2098
2098
  }
2099
2099
  }
@@ -2122,7 +2122,7 @@ class ji {
2122
2122
  this._insert(t, this.data.height - 1);
2123
2123
  }
2124
2124
  clear() {
2125
- this.data = Z([]);
2125
+ this.data = Q([]);
2126
2126
  }
2127
2127
  remove(t) {
2128
2128
  let e = this.data;
@@ -2133,7 +2133,7 @@ class ji {
2133
2133
  const d = e.children.indexOf(t);
2134
2134
  d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
2135
2135
  }
2136
- l || e.leaf || !Mt(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), s.push(n), n = 0, a = e, e = e.children[0]);
2136
+ l || e.leaf || !Dt(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), s.push(n), n = 0, a = e, e = e.children[0]);
2137
2137
  }
2138
2138
  }
2139
2139
  toBBox(t) {
@@ -2153,25 +2153,25 @@ class ji {
2153
2153
  _build(t, e, i, o) {
2154
2154
  const s = i - e + 1;
2155
2155
  let n, a = this._maxEntries;
2156
- if (s <= a) return n = Z(t.slice(e, i + 1)), J(n, this.toBBox), n;
2157
- o || (o = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, o - 1))), n = Z([]), n.leaf = !1, n.height = o;
2156
+ if (s <= a) return n = Q(t.slice(e, i + 1)), H(n, this.toBBox), n;
2157
+ o || (o = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, o - 1))), n = Q([]), n.leaf = !1, n.height = o;
2158
2158
  const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
2159
- ue(t, e, i, d, this.compareMinX);
2159
+ pe(t, e, i, d, this.compareMinX);
2160
2160
  for (let c = e; c <= i; c += d) {
2161
2161
  const h = Math.min(c + d - 1, i);
2162
- ue(t, c, h, l, this.compareMinY);
2162
+ pe(t, c, h, l, this.compareMinY);
2163
2163
  for (let u = c; u <= h; u += l) {
2164
2164
  const p = Math.min(u + l - 1, h);
2165
2165
  n.children.push(this._build(t, u, p, o - 1));
2166
2166
  }
2167
2167
  }
2168
- return J(n, this.toBBox), n;
2168
+ return H(n, this.toBBox), n;
2169
2169
  }
2170
2170
  _chooseSubtree(t, e, i, o) {
2171
2171
  for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
2172
2172
  let a, l = 1 / 0, d = 1 / 0;
2173
2173
  for (let c = 0; c < e.children.length; c++) {
2174
- const h = e.children[c], u = Ft(h), p = (s = t, n = h, (Math.max(n.maxX, s.maxX) - Math.min(n.minX, s.minX)) * (Math.max(n.maxY, s.maxY) - Math.min(n.minY, s.minY)) - u);
2174
+ const h = e.children[c], u = Mt(h), p = (s = t, n = h, (Math.max(n.maxX, s.maxX) - Math.min(n.minX, s.minX)) * (Math.max(n.maxY, s.maxY) - Math.min(n.minY, s.minY)) - u);
2175
2175
  p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
2176
2176
  }
2177
2177
  e = a || e.children[0];
@@ -2181,54 +2181,54 @@ class ji {
2181
2181
  }
2182
2182
  _insert(t, e, i) {
2183
2183
  const o = i ? t : this.toBBox(t), s = [], n = this._chooseSubtree(o, this.data, e, s);
2184
- for (n.children.push(t), at(n, o); e >= 0 && s[e].children.length > this._maxEntries; ) this._split(s, e), e--;
2184
+ for (n.children.push(t), lt(n, o); e >= 0 && s[e].children.length > this._maxEntries; ) this._split(s, e), e--;
2185
2185
  this._adjustParentBBoxes(o, s, e);
2186
2186
  }
2187
2187
  _split(t, e) {
2188
2188
  const i = t[e], o = i.children.length, s = this._minEntries;
2189
2189
  this._chooseSplitAxis(i, s, o);
2190
- const n = this._chooseSplitIndex(i, s, o), a = Z(i.children.splice(n, i.children.length - n));
2191
- a.height = i.height, a.leaf = i.leaf, J(i, this.toBBox), J(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
2190
+ const n = this._chooseSplitIndex(i, s, o), a = Q(i.children.splice(n, i.children.length - n));
2191
+ a.height = i.height, a.leaf = i.leaf, H(i, this.toBBox), H(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
2192
2192
  }
2193
2193
  _splitRoot(t, e) {
2194
- this.data = Z([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, J(this.data, this.toBBox);
2194
+ this.data = Q([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, H(this.data, this.toBBox);
2195
2195
  }
2196
2196
  _chooseSplitIndex(t, e, i) {
2197
2197
  let o, s = 1 / 0, n = 1 / 0;
2198
2198
  for (let a = e; a <= i - e; a++) {
2199
- const l = nt(t, 0, a, this.toBBox), d = nt(t, a, i, this.toBBox), c = Bi(l, d), h = Ft(l) + Ft(d);
2199
+ const l = at(t, 0, a, this.toBBox), d = at(t, a, i, this.toBBox), c = ji(l, d), h = Mt(l) + Mt(d);
2200
2200
  c < s ? (s = c, o = a, n = h < n ? h : n) : c === s && h < n && (n = h, o = a);
2201
2201
  }
2202
2202
  return o || i - e;
2203
2203
  }
2204
2204
  _chooseSplitAxis(t, e, i) {
2205
- const o = t.leaf ? this.compareMinX : Ti, s = t.leaf ? this.compareMinY : Wi;
2205
+ const o = t.leaf ? this.compareMinX : Wi, s = t.leaf ? this.compareMinY : Bi;
2206
2206
  this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, s) && t.children.sort(o);
2207
2207
  }
2208
2208
  _allDistMargin(t, e, i, o) {
2209
2209
  t.children.sort(o);
2210
- const s = this.toBBox, n = nt(t, 0, e, s), a = nt(t, i - e, i, s);
2211
- let l = ft(n) + ft(a);
2210
+ const s = this.toBBox, n = at(t, 0, e, s), a = at(t, i - e, i, s);
2211
+ let l = vt(n) + vt(a);
2212
2212
  for (let d = e; d < i - e; d++) {
2213
2213
  const c = t.children[d];
2214
- at(n, t.leaf ? s(c) : c), l += ft(n);
2214
+ lt(n, t.leaf ? s(c) : c), l += vt(n);
2215
2215
  }
2216
2216
  for (let d = i - e - 1; d >= e; d--) {
2217
2217
  const c = t.children[d];
2218
- at(a, t.leaf ? s(c) : c), l += ft(a);
2218
+ lt(a, t.leaf ? s(c) : c), l += vt(a);
2219
2219
  }
2220
2220
  return l;
2221
2221
  }
2222
2222
  _adjustParentBBoxes(t, e, i) {
2223
- for (let o = i; o >= 0; o--) at(e[o], t);
2223
+ for (let o = i; o >= 0; o--) lt(e[o], t);
2224
2224
  }
2225
2225
  _condense(t) {
2226
- 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() : J(t[i], this.toBBox);
2226
+ 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);
2227
2227
  }
2228
2228
  }
2229
- class Ai {
2229
+ class Ri {
2230
2230
  constructor(t) {
2231
- this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new ji(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
2231
+ this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new Ai(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
2232
2232
  }
2233
2233
  setMaps(t, e) {
2234
2234
  this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
@@ -2279,14 +2279,14 @@ class Ai {
2279
2279
  return this.tree.collides(this.toBBox(t));
2280
2280
  }
2281
2281
  }
2282
- const Ri = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
2282
+ const Gi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
2283
2283
  const t = 16 * Math.random() | 0;
2284
2284
  return (r == "x" ? t : 3 & t | 8).toString(16);
2285
2285
  }), isValidId: (r) => typeof r == "string" && r.length === 36 };
2286
- class Gi {
2286
+ class Ui {
2287
2287
  constructor(t) {
2288
2288
  this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
2289
- }, this.store = {}, this.spatialIndex = new Ai(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : Ri;
2289
+ }, this.store = {}, this.spatialIndex = new Ri(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : Gi;
2290
2290
  }
2291
2291
  clone(t) {
2292
2292
  return JSON.parse(JSON.stringify(t));
@@ -2310,10 +2310,10 @@ class Gi {
2310
2310
  }
2311
2311
  if (this.tracked) {
2312
2312
  if (d.properties.createdAt) {
2313
- if (!te(d.properties.createdAt)) return n.push({ id: d.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2313
+ if (!ee(d.properties.createdAt)) return n.push({ id: d.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2314
2314
  } else d.properties.createdAt = +/* @__PURE__ */ new Date();
2315
2315
  if (d.properties.updatedAt) {
2316
- if (!te(d.properties.updatedAt)) return n.push({ id: d.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2316
+ if (!ee(d.properties.updatedAt)) return n.push({ id: d.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2317
2317
  } else d.properties.updatedAt = +/* @__PURE__ */ new Date();
2318
2318
  }
2319
2319
  return this.has(c) ? (n.push({ id: c, valid: !1, reason: `Feature already exists with this id: ${c}` }), !1) : (this.store[c] = d, a.push(d), n.push({ id: c, valid: !0 }), !0);
@@ -2390,16 +2390,16 @@ class Gi {
2390
2390
  return Object.keys(this.store).length;
2391
2391
  }
2392
2392
  }
2393
- const Ui = "Feature is not a Polygon or LineString", zi = "Feature intersects itself", Vi = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: Ui } : jt(r) ? { valid: !1, reason: zi } : { valid: !0 };
2394
- function pe(r, t, e) {
2393
+ const zi = "Feature is not a Polygon or LineString", Vi = "Feature intersects itself", $i = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: zi } : At(r) ? { valid: !1, reason: Vi } : { valid: !0 };
2394
+ function ge(r, t, e) {
2395
2395
  const i = G(r, t);
2396
2396
  let o = G(t, e) - i;
2397
2397
  return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
2398
2398
  }
2399
- const $i = { cancel: "Escape", finish: "Enter" }, Yi = { start: "crosshair", close: "pointer" };
2400
- class je extends A {
2399
+ const Yi = { cancel: "Escape", finish: "Enter" }, Ki = { start: "crosshair", close: "pointer" };
2400
+ class Ae extends A {
2401
2401
  constructor(t) {
2402
- super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = $i, this.cursors = Yi, this.mouseMove = !1, this.updateOptions(t);
2402
+ super(t, !0), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Yi, this.cursors = Ki, this.mouseMove = !1, this.updateOptions(t);
2403
2403
  }
2404
2404
  updateOptions(t) {
2405
2405
  super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents));
@@ -2424,11 +2424,11 @@ class je extends A {
2424
2424
  const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
2425
2425
  i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
2426
2426
  } else if (this.currentCoordinate === 2) {
2427
- const o = e[0], s = e[1], n = ke(o, s, this.coordinatePrecision, this.project, this.unproject), a = O(o[0], o[1]), l = O(n[0], n[1]), d = O(s[0], s[1]), c = O(t.lng, t.lat), h = F(c, a) < F(c, d), u = pe(a, l, c), p = h ? 90 - u : pe(a, l, c) - 90, g = F(l, c), y = Math.cos(D(p)) * g, m = G(a, d) + ((function(I, b, L) {
2428
- const M = (L.x - b.x) * (I.y - b.y) - (L.y - b.y) * (I.x - b.x);
2427
+ const o = e[0], s = e[1], n = Ne(o, s, this.coordinatePrecision, this.project, this.unproject), a = O(o[0], o[1]), l = O(n[0], n[1]), d = O(s[0], s[1]), c = O(t.lng, t.lat), h = F(c, a) < F(c, d), u = ge(a, l, c), p = h ? 90 - u : ge(a, l, c) - 90, g = F(l, c), y = Math.cos(D(p)) * g, f = G(a, d) + ((function(I, w, L) {
2428
+ const M = (L.x - w.x) * (I.y - w.y) - (L.y - w.y) * (I.x - w.x);
2429
2429
  return M > 1e-10 ? "left" : M < -1e-10 ? "right" : "left";
2430
- })(a, d, c) === "right" ? -90 : 90), v = ht(a, y, m), C = ht(d, y, m), f = R(v.x, v.y), P = R(C.x, C.y);
2431
- i = [e[0], e[1], [P.lng, P.lat], [f.lng, f.lat], e[0]];
2430
+ })(a, d, c) === "right" ? -90 : 90), v = ut(a, y, f), C = ut(d, y, f), m = R(v.x, v.y), P = R(C.x, C.y);
2431
+ i = [e[0], e[1], [b(P.lng, this.coordinatePrecision), b(P.lat, this.coordinatePrecision)], [b(m.lng, this.coordinatePrecision), b(m.lat, this.coordinatePrecision)], e[0]];
2432
2432
  }
2433
2433
  i && this.updatePolygonGeometry(this.currentId, i, E.Provisional);
2434
2434
  }
@@ -2442,7 +2442,7 @@ class je extends A {
2442
2442
  this.currentId = e, this.currentCoordinate++, this.setDrawing();
2443
2443
  } else if (this.currentCoordinate === 1 && this.currentId) {
2444
2444
  const e = this.store.getGeometryCopy(this.currentId);
2445
- if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], E.Commit)) return;
2445
+ if (et([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], E.Commit)) return;
2446
2446
  this.currentCoordinate++;
2447
2447
  } else this.currentCoordinate === 2 && this.currentId && this.close();
2448
2448
  }
@@ -2473,26 +2473,26 @@ class je extends A {
2473
2473
  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 = j), e;
2474
2474
  }
2475
2475
  validateFeature(t) {
2476
- return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
2476
+ return this.validateModeFeature(t, (e) => gt(e, this.coordinatePrecision));
2477
2477
  }
2478
2478
  afterFeatureUpdated(t) {
2479
2479
  this.currentId === t.id && (this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
2480
2480
  }
2481
2481
  }
2482
- function Ae(r, t, e) {
2482
+ function Re(r, t, e) {
2483
2483
  return (t.x - r.x) * (e.y - r.y) - (t.y - r.y) * (e.x - r.x) <= 0;
2484
2484
  }
2485
- const Ki = { cancel: "Escape", finish: "Enter" }, Xi = { start: "crosshair", close: "pointer" };
2486
- class Re extends A {
2485
+ const Xi = { cancel: "Escape", finish: "Enter" }, qi = { start: "crosshair", close: "pointer" };
2486
+ class Ge extends A {
2487
2487
  constructor(t) {
2488
- super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Ki, this.direction = void 0, this.arcPoints = 64, this.cursors = Xi, this.mouseMove = !1, this.updateOptions(t);
2488
+ super(t, !0), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = Xi, this.direction = void 0, this.arcPoints = 64, this.cursors = qi, this.mouseMove = !1, this.updateOptions(t);
2489
2489
  }
2490
2490
  updateOptions(t) {
2491
2491
  super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.arcPoints && (this.arcPoints = t.arcPoints);
2492
2492
  }
2493
2493
  close() {
2494
2494
  if (this.currentId === void 0) return;
2495
- const t = pt(this.store.getGeometryCopy(this.currentId));
2495
+ const t = yt(this.store.getGeometryCopy(this.currentId));
2496
2496
  t && this.store.updateGeometry([{ id: this.currentId, geometry: t }]), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
2497
2497
  const e = this.currentId;
2498
2498
  this.currentCoordinate = 0, this.currentId = void 0, this.direction = void 0, this.state === "drawing" && this.setStarted(), this.onFinish(e, { mode: this.mode, action: "draw" });
@@ -2513,16 +2513,16 @@ class Re extends A {
2513
2513
  } else if (this.currentCoordinate === 2) {
2514
2514
  const o = e[0], s = e[1], n = [t.lng, t.lat], a = O(o[0], o[1]), l = O(s[0], s[1]), d = O(n[0], n[1]);
2515
2515
  if (this.direction === void 0) {
2516
- const f = Ae(a, l, d);
2517
- this.direction = f ? "clockwise" : "anticlockwise";
2516
+ const m = Re(a, l, d);
2517
+ this.direction = m ? "clockwise" : "anticlockwise";
2518
2518
  }
2519
- const c = F(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [o], y = X(h), m = X(u);
2519
+ const c = F(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [o], y = X(h), f = X(u);
2520
2520
  let v;
2521
- this.direction === "anticlockwise" ? (v = m - y, v < 0 && (v += 360)) : (v = y - m, v < 0 && (v += 360));
2521
+ this.direction === "anticlockwise" ? (v = f - y, v < 0 && (v += 360)) : (v = y - f, v < 0 && (v += 360));
2522
2522
  const C = (this.direction === "anticlockwise" ? 1 : -1) * v / p;
2523
2523
  g.push(s);
2524
- for (let f = 0; f <= p; f++) {
2525
- const P = ht(a, c, y + f * C), { lng: I, lat: b } = R(P.x, P.y), L = [w(I, this.coordinatePrecision), w(b, this.coordinatePrecision)];
2524
+ for (let m = 0; m <= p; m++) {
2525
+ const P = ut(a, c, y + m * C), { lng: I, lat: w } = R(P.x, P.y), L = [b(I, this.coordinatePrecision), b(w, this.coordinatePrecision)];
2526
2526
  L[0] !== g[g.length - 1][0] && L[1] !== g[g.length - 1][1] && g.push(L);
2527
2527
  }
2528
2528
  g.push(o), i = [...g];
@@ -2539,7 +2539,7 @@ class Re extends A {
2539
2539
  this.currentId = e, this.currentCoordinate++, this.setDrawing();
2540
2540
  } else if (this.currentCoordinate === 1 && this.currentId) {
2541
2541
  const e = this.store.getGeometryCopy(this.currentId);
2542
- if (tt([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], E.Commit)) return;
2542
+ if (et([t.lng, t.lat], e.coordinates[0][0]) || !this.updatePolygonGeometry(this.currentId, [e.coordinates[0][0], [t.lng, t.lat], [t.lng, t.lat], e.coordinates[0][0]], E.Commit)) return;
2543
2543
  this.currentCoordinate++;
2544
2544
  } else this.currentCoordinate === 2 && this.currentId && this.close();
2545
2545
  }
@@ -2566,16 +2566,16 @@ class Re extends A {
2566
2566
  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 = j), e;
2567
2567
  }
2568
2568
  validateFeature(t) {
2569
- return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
2569
+ return this.validateModeFeature(t, (e) => gt(e, this.coordinatePrecision));
2570
2570
  }
2571
2571
  afterFeatureUpdated(t) {
2572
2572
  this.currentId === t.id && (this.currentId = void 0, this.direction = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
2573
2573
  }
2574
2574
  }
2575
- const qi = { cancel: "Escape", finish: "Enter" }, Ji = { start: "crosshair", close: "pointer" };
2576
- class Ge extends A {
2575
+ const Ji = { cancel: "Escape", finish: "Enter" }, Hi = { start: "crosshair", close: "pointer" };
2576
+ class Ue extends A {
2577
2577
  constructor(t) {
2578
- super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = qi, this.direction = void 0, this.arcPoints = 64, this.cursors = Ji, this.mouseMove = !1, this.updateOptions(t);
2578
+ super(t, !0), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = Ji, this.direction = void 0, this.arcPoints = 64, this.cursors = Hi, this.mouseMove = !1, this.updateOptions(t);
2579
2579
  }
2580
2580
  updateOptions(t) {
2581
2581
  super.updateOptions(t), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors)), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.arcPoints && (this.arcPoints = t.arcPoints);
@@ -2584,7 +2584,7 @@ class Ge extends A {
2584
2584
  if (this.currentStartingPointId === void 0) return;
2585
2585
  const t = this.currentStartingPointId, e = this.currentInitialArcId, i = this.currentId;
2586
2586
  if (t && this.store.delete([t]), e && this.store.delete([e]), this.currentId) {
2587
- const o = pt(this.store.getGeometryCopy(this.currentId));
2587
+ const o = yt(this.store.getGeometryCopy(this.currentId));
2588
2588
  o && this.store.updateGeometry([{ id: this.currentId, geometry: o }]), this.store.updateProperty([{ id: this.currentId, property: S.CURRENTLY_DRAWING, value: void 0 }]);
2589
2589
  }
2590
2590
  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" });
@@ -2600,29 +2600,29 @@ class Ge extends A {
2600
2600
  if (this.currentCoordinate === 2) {
2601
2601
  const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n = O(o[0], o[1]), a = O(s[0], s[1]), l = O(i[0], i[1]), d = F(l, n);
2602
2602
  if (this.direction === void 0) {
2603
- const C = Ae(l, n, a);
2603
+ const C = Re(l, n, a);
2604
2604
  this.direction = C ? "clockwise" : "anticlockwise";
2605
2605
  }
2606
2606
  const c = G(l, n), h = G(l, a), u = this.arcPoints, p = [o], g = X(c), y = X(h);
2607
- let m;
2608
- this.direction === "anticlockwise" ? (m = y - g, m < 0 && (m += 360)) : (m = g - y, m < 0 && (m += 360));
2609
- const v = (this.direction === "anticlockwise" ? 1 : -1) * m / u;
2607
+ let f;
2608
+ this.direction === "anticlockwise" ? (f = y - g, f < 0 && (f += 360)) : (f = g - y, f < 0 && (f += 360));
2609
+ const v = (this.direction === "anticlockwise" ? 1 : -1) * f / u;
2610
2610
  for (let C = 0; C <= u; C++) {
2611
- const f = ht(l, d, g + C * v), { lng: P, lat: I } = R(f.x, f.y), b = [w(P, this.coordinatePrecision), w(I, this.coordinatePrecision)];
2612
- b[0] !== p[p.length - 1][0] && b[1] !== p[p.length - 1][1] && p.push(b);
2611
+ const m = ut(l, d, g + C * v), { lng: P, lat: I } = R(m.x, m.y), w = [b(P, this.coordinatePrecision), b(I, this.coordinatePrecision)];
2612
+ w[0] !== p[p.length - 1][0] && w[1] !== p[p.length - 1][1] && p.push(w);
2613
2613
  }
2614
2614
  this.updateLineStringGeometry(this.currentInitialArcId, p, E.Provisional);
2615
2615
  } else if (this.currentCoordinate === 3) {
2616
2616
  const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2617
2617
  if (e.length < 2 || !this.direction) return;
2618
- const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = O(t.lng, t.lat), a = O(o[0], o[1]), l = O(s[0], s[1]), d = O(i[0], i[1]), c = F(d, a), h = F(d, n) < c ? a : n, u = G(d, n), p = G(d, a), g = G(d, l), y = X(p), m = X(g), v = X(u);
2619
- if (this.notInSector({ normalizedCursor: v, normalizedStart: y, normalizedEnd: m, direction: this.direction })) return;
2620
- const C = this.getDeltaBearing(this.direction, y, m), f = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * C / f, I = F(d, h), b = [];
2621
- for (let L = 0; L <= f; L++) {
2622
- const M = ht(d, I, y + L * P), { lng: N, lat: _ } = R(M.x, M.y), T = [w(N, this.coordinatePrecision), w(_, this.coordinatePrecision)];
2623
- T[0] !== e[e.length - 1][0] && T[1] !== e[e.length - 1][1] && b.unshift(T);
2618
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = O(t.lng, t.lat), a = O(o[0], o[1]), l = O(s[0], s[1]), d = O(i[0], i[1]), c = F(d, a), h = F(d, n) < c ? a : n, u = G(d, n), p = G(d, a), g = G(d, l), y = X(p), f = X(g), v = X(u);
2619
+ if (this.notInSector({ normalizedCursor: v, normalizedStart: y, normalizedEnd: f, direction: this.direction })) return;
2620
+ const C = this.getDeltaBearing(this.direction, y, f), m = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * C / m, I = F(d, h), w = [];
2621
+ for (let L = 0; L <= m; L++) {
2622
+ const M = ut(d, I, y + L * P), { lng: N, lat: _ } = R(M.x, M.y), T = [b(N, this.coordinatePrecision), b(_, this.coordinatePrecision)];
2623
+ T[0] !== e[e.length - 1][0] && T[1] !== e[e.length - 1][1] && w.unshift(T);
2624
2624
  }
2625
- e.push(...b), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, E.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode, [S.CURRENTLY_DRAWING]: !0 } }]);
2625
+ e.push(...w), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, E.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode, [S.CURRENTLY_DRAWING]: !0 } }]);
2626
2626
  }
2627
2627
  }
2628
2628
  }
@@ -2666,7 +2666,7 @@ class Ge extends A {
2666
2666
  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 = j) : 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 = j) : 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;
2667
2667
  }
2668
2668
  validateFeature(t) {
2669
- return this.validateModeFeature(t, (e) => ut(e, this.coordinatePrecision));
2669
+ return this.validateModeFeature(t, (e) => gt(e, this.coordinatePrecision));
2670
2670
  }
2671
2671
  afterFeatureUpdated(t) {
2672
2672
  this.currentId === t.id && (this.currentStartingPointId && this.store.delete([this.currentStartingPointId]), this.currentInitialArcId && this.store.delete([this.currentInitialArcId]), this.currentStartingPointId = void 0, this.direction = void 0, this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted());
@@ -2679,7 +2679,7 @@ class Ge extends A {
2679
2679
  return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
2680
2680
  }
2681
2681
  }
2682
- class H {
2682
+ class Z {
2683
2683
  constructor({ name: t, callback: e, unregister: i, register: o }) {
2684
2684
  this.name = void 0, this.callback = void 0, this.registered = !1, this.register = void 0, this.unregister = void 0, this.name = t, this.register = () => {
2685
2685
  this.registered || (this.registered = !0, o(e));
@@ -2688,7 +2688,7 @@ class H {
2688
2688
  }, this.callback = e;
2689
2689
  }
2690
2690
  }
2691
- var Hi = { __proto__: null, TerraDrawBaseAdapter: class {
2691
+ var Zi = { __proto__: null, TerraDrawBaseAdapter: class {
2692
2692
  constructor(r) {
2693
2693
  this._nextKeyUpIsContextMenu = !1, 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 r.minPixelDragDistance == "number" ? r.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof r.minPixelDragDistanceSelecting == "number" ? r.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof r.minPixelDragDistanceDrawing == "number" ? r.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof r.coordinatePrecision == "number" ? r.coordinatePrecision : 9;
2694
2694
  }
@@ -2703,7 +2703,7 @@ var Hi = { __proto__: null, TerraDrawBaseAdapter: class {
2703
2703
  const e = this.getLngLatFromEvent(r);
2704
2704
  if (!e) return null;
2705
2705
  const { lng: i, lat: o } = e, { containerX: s, containerY: n } = this.getMapElementXYPosition(r), a = this.getButton(r), l = Array.from(this._heldKeys);
2706
- return { lng: w(i, this._coordinatePrecision), lat: w(o, this._coordinatePrecision), containerX: s, containerY: n, button: a, heldKeys: l, isContextMenu: t };
2706
+ return { lng: b(i, this._coordinatePrecision), lat: b(o, this._coordinatePrecision), containerX: s, containerY: n, button: a, heldKeys: l, isContextMenu: t };
2707
2707
  }
2708
2708
  register(r) {
2709
2709
  this._currentModeCallbacks = r, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
@@ -2714,7 +2714,7 @@ var Hi = { __proto__: null, TerraDrawBaseAdapter: class {
2714
2714
  return this._coordinatePrecision;
2715
2715
  }
2716
2716
  getAdapterListeners() {
2717
- return [new H({ name: "pointerdown", callback: (r) => {
2717
+ return [new Z({ name: "pointerdown", callback: (r) => {
2718
2718
  if (!this._currentModeCallbacks || !r.isPrimary) return;
2719
2719
  const t = this.getDrawEventFromEvent(r);
2720
2720
  t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
@@ -2722,7 +2722,7 @@ var Hi = { __proto__: null, TerraDrawBaseAdapter: class {
2722
2722
  this.getMapEventElement().addEventListener("pointerdown", r);
2723
2723
  }, unregister: (r) => {
2724
2724
  this.getMapEventElement().removeEventListener("pointerdown", r);
2725
- } }), new H({ name: "pointermove", callback: (r) => {
2725
+ } }), new Z({ name: "pointermove", callback: (r) => {
2726
2726
  if (!this._currentModeCallbacks || !r.isPrimary) return;
2727
2727
  r.preventDefault();
2728
2728
  const t = this.getDrawEventFromEvent(r);
@@ -2742,13 +2742,13 @@ var Hi = { __proto__: null, TerraDrawBaseAdapter: class {
2742
2742
  this.getMapEventElement().addEventListener("pointermove", r);
2743
2743
  }, unregister: (r) => {
2744
2744
  this.getMapEventElement().removeEventListener("pointermove", r);
2745
- } }), new H({ name: "contextmenu", callback: (r) => {
2745
+ } }), new Z({ name: "contextmenu", callback: (r) => {
2746
2746
  this._currentModeCallbacks && (r.preventDefault(), this._nextKeyUpIsContextMenu = !0);
2747
2747
  }, register: (r) => {
2748
2748
  this.getMapEventElement().addEventListener("contextmenu", r);
2749
2749
  }, unregister: (r) => {
2750
2750
  this.getMapEventElement().removeEventListener("contextmenu", r);
2751
- } }), new H({ name: "pointerup", callback: (r) => {
2751
+ } }), new Z({ name: "pointerup", callback: (r) => {
2752
2752
  if (!this._currentModeCallbacks || r.target !== this.getMapEventElement() || !r.isPrimary) return;
2753
2753
  const t = this.getDrawEventFromEvent(r);
2754
2754
  t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (e) => {
@@ -2758,13 +2758,13 @@ var Hi = { __proto__: null, TerraDrawBaseAdapter: class {
2758
2758
  this.getMapEventElement().addEventListener("pointerup", r);
2759
2759
  }, unregister: (r) => {
2760
2760
  this.getMapEventElement().removeEventListener("pointerup", r);
2761
- } }), new H({ name: "keyup", callback: (r) => {
2761
+ } }), new Z({ name: "keyup", callback: (r) => {
2762
2762
  this._currentModeCallbacks && (this._heldKeys.delete(r.key), this._currentModeCallbacks.onKeyUp({ key: r.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => r.preventDefault() }));
2763
2763
  }, register: (r) => {
2764
2764
  this.getMapEventElement().addEventListener("keyup", r);
2765
2765
  }, unregister: (r) => {
2766
2766
  this.getMapEventElement().removeEventListener("keyup", r);
2767
- } }), new H({ name: "keydown", callback: (r) => {
2767
+ } }), new Z({ name: "keydown", callback: (r) => {
2768
2768
  this._currentModeCallbacks && (this._heldKeys.add(r.key), this._currentModeCallbacks.onKeyDown({ key: r.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => r.preventDefault() }));
2769
2769
  }, register: (r) => {
2770
2770
  this.getMapEventElement().addEventListener("keydown", r);
@@ -2778,10 +2778,10 @@ var Hi = { __proto__: null, TerraDrawBaseAdapter: class {
2778
2778
  }), this.clear(), this._currentModeCallbacks = void 0;
2779
2779
  }
2780
2780
  } };
2781
- const Zi = { cancel: "Escape", finish: "Enter" }, Qi = { start: "crosshair", close: "pointer" };
2782
- class Ue extends A {
2781
+ const Qi = { cancel: "Escape", finish: "Enter" }, to = { start: "crosshair", close: "pointer" };
2782
+ class ze extends A {
2783
2783
  constructor(t) {
2784
- super(t, !0), this.mode = "freehand-linestring", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = Zi, this.cursors = Qi, this.preventNewFeature = !1, this.updateOptions(t);
2784
+ super(t, !0), this.mode = "freehand-linestring", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = 20, this.keyEvents = Qi, this.cursors = to, this.preventNewFeature = !1, this.updateOptions(t);
2785
2785
  }
2786
2786
  updateOptions(t) {
2787
2787
  super.updateOptions(t), t != null && t.minDistance && (this.minDistance = t.minDistance), t?.keyEvents === null ? this.keyEvents = { cancel: null, finish: null } : t != null && t.keyEvents && (this.keyEvents = x({}, this.keyEvents, t.keyEvents)), t != null && t.cursors && (this.cursors = x({}, this.cursors, t.cursors));
@@ -2843,13 +2843,13 @@ class Ue extends A {
2843
2843
  return t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex = j, e) : (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode && (e.pointWidth = this.getNumericStylingValue(this.styles.closingPointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(this.styles.closingPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.closingPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.closingPointOutlineWidth, 2, t), e.zIndex = 50), e);
2844
2844
  }
2845
2845
  validateFeature(t) {
2846
- return this.validateModeFeature(t, (e) => Rt(e, this.coordinatePrecision));
2846
+ return this.validateModeFeature(t, (e) => Gt(e, this.coordinatePrecision));
2847
2847
  }
2848
2848
  afterFeatureUpdated(t) {
2849
2849
  this.currentId === t.id && (this.closingPointId && this.store.delete([this.closingPointId]), this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0);
2850
2850
  }
2851
2851
  }
2852
- function Wt(r) {
2852
+ function Bt(r) {
2853
2853
  if (r === null || typeof r == "boolean" || typeof r == "string") return !0;
2854
2854
  if (r === void 0) return !1;
2855
2855
  if (typeof r == "number") return Number.isFinite(r);
@@ -2860,13 +2860,13 @@ function Wt(r) {
2860
2860
  }
2861
2861
  if (ArrayBuffer.isView(r) && !(r instanceof DataView)) return !1;
2862
2862
  if (Array.isArray(r)) {
2863
- for (const t of r) if (!Wt(t)) return !1;
2863
+ for (const t of r) if (!Bt(t)) return !1;
2864
2864
  }
2865
- return typeof r == "object" && Object.keys(r).every((t) => typeof t == "string" && Wt(r[t]));
2865
+ return typeof r == "object" && Object.keys(r).every((t) => typeof t == "string" && Bt(r[t]));
2866
2866
  }
2867
- class to {
2867
+ class eo {
2868
2868
  constructor(t) {
2869
- 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 Ni();
2869
+ 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 Ti();
2870
2870
  const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
2871
2871
  if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
2872
2872
  return e.add(h.mode), c[h.mode] = h, c;
@@ -2877,7 +2877,7 @@ class to {
2877
2877
  if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
2878
2878
  this._instanceSelectMode = c;
2879
2879
  }
2880
- }), this._modes = x({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Gi({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2880
+ }), this._modes = x({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new Ui({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2881
2881
  const s = (c) => {
2882
2882
  const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
2883
2883
  return { changed: h, unchanged: u };
@@ -2921,44 +2921,44 @@ class to {
2921
2921
  }), t;
2922
2922
  }
2923
2923
  featuresAtLocation({ lng: t, lat: e }, i) {
2924
- const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = !(!i || i.ignoreCoordinatePoints === void 0) && i.ignoreCoordinatePoints, a = !(!i || i.ignoreCurrentlyDrawing === void 0) && i.ignoreCurrentlyDrawing, l = !(!i || i.ignoreClosingPoints === void 0) && i.ignoreClosingPoints, d = this._adapter.unproject.bind(this._adapter), c = this._adapter.project.bind(this._adapter), h = c(t, e), u = we({ unproject: d, point: h, pointerDistance: o });
2925
- return this._store.search(u).filter((p) => {
2926
- if (s && (p.properties[k.MID_POINT] || p.properties[k.SELECTION_POINT]) || n && p.properties[S.COORDINATE_POINT] || l && p.properties[S.CLOSING_POINT] || a && p.properties[S.CURRENTLY_DRAWING]) return !1;
2927
- if (p.geometry.type === "Point") {
2928
- const g = p.geometry.coordinates, y = c(g[0], g[1]);
2929
- return F(h, y) < o;
2924
+ const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = !(!i || i.ignoreCoordinatePoints === void 0) && i.ignoreCoordinatePoints, a = !(!i || i.ignoreCurrentlyDrawing === void 0) && i.ignoreCurrentlyDrawing, l = !(!i || i.ignoreClosingPoints === void 0) && i.ignoreClosingPoints, d = !(!i || i.ignoreSnappingPoints === void 0) && i.ignoreSnappingPoints, c = this._adapter.unproject.bind(this._adapter), h = this._adapter.project.bind(this._adapter), u = h(t, e), p = Le({ unproject: c, point: u, pointerDistance: o });
2925
+ return this._store.search(p).filter((g) => {
2926
+ if (s && (g.properties[k.MID_POINT] || g.properties[k.SELECTION_POINT]) || n && g.properties[S.COORDINATE_POINT] || l && g.properties[S.CLOSING_POINT] || a && g.properties[S.CURRENTLY_DRAWING] || d && g.properties[S.SNAPPING_POINT]) return !1;
2927
+ if (g.geometry.type === "Point") {
2928
+ const y = g.geometry.coordinates, f = h(y[0], y[1]);
2929
+ return F(u, f) < o;
2930
2930
  }
2931
- if (p.geometry.type === "LineString") {
2932
- const g = p.geometry.coordinates;
2933
- for (let y = 0; y < g.length - 1; y++) {
2934
- const m = g[y], v = g[y + 1];
2935
- if (Nt(h, c(m[0], m[1]), c(v[0], v[1])) < o) return !0;
2931
+ if (g.geometry.type === "LineString") {
2932
+ const y = g.geometry.coordinates;
2933
+ for (let f = 0; f < y.length - 1; f++) {
2934
+ const v = y[f], C = y[f + 1];
2935
+ if (Tt(u, h(v[0], v[1]), h(C[0], C[1])) < o) return !0;
2936
2936
  }
2937
2937
  return !1;
2938
2938
  }
2939
- if (Ne([t, e], p.geometry.coordinates)) return !0;
2939
+ if (Te([t, e], g.geometry.coordinates)) return !0;
2940
2940
  if (i != null && i.includePolygonsWithinPointerDistance) {
2941
- const g = p.geometry.coordinates;
2942
- for (const y of g) for (let m = 0; m < y.length - 1; m++) {
2943
- const v = y[m], C = y[m + 1], f = c(v[0], v[1]), P = c(C[0], C[1]);
2944
- if (Nt(h, f, P) < o) return !0;
2941
+ const y = g.geometry.coordinates;
2942
+ for (const f of y) for (let v = 0; v < f.length - 1; v++) {
2943
+ const C = f[v], m = f[v + 1], P = h(C[0], C[1]), I = h(m[0], m[1]);
2944
+ if (Tt(u, P, I) < o) return !0;
2945
2945
  }
2946
2946
  }
2947
2947
  return !1;
2948
- }).map((p) => {
2949
- if (i == null || !i.addClosestCoordinateInfoToProperties) return p;
2950
- let g;
2951
- if (p.geometry.type === "Polygon") g = p.geometry.coordinates[0], g.pop();
2948
+ }).map((g) => {
2949
+ if (i == null || !i.addClosestCoordinateInfoToProperties) return g;
2950
+ let y;
2951
+ if (g.geometry.type === "Polygon") y = g.geometry.coordinates[0].slice(0, -1);
2952
2952
  else {
2953
- if (p.geometry.type !== "LineString") return p;
2954
- g = p.geometry.coordinates;
2953
+ if (g.geometry.type !== "LineString") return g;
2954
+ y = g.geometry.coordinates;
2955
2955
  }
2956
- let y, m = -1, v = 1 / 0;
2957
- for (let C = 0; C < g.length; C++) {
2958
- const f = g[C], P = F(c(f[0], f[1]), h);
2959
- P < v && (m = C, v = P, y = f);
2956
+ let f, v = -1, C = 1 / 0;
2957
+ for (let m = 0; m < y.length; m++) {
2958
+ const P = y[m], I = F(h(P[0], P[1]), u);
2959
+ I < C && (v = m, C = I, f = P);
2960
2960
  }
2961
- return p.properties.closestCoordinateIndexToEvent = m, p.properties.closestCoordinatePixelDistanceToEvent = v, p.properties.closestCoordinateDistanceKmToEvent = U(y, [t, e]), p;
2961
+ return g.properties.closestCoordinateIndexToEvent = v, g.properties.closestCoordinatePixelDistanceToEvent = C, g.properties.closestCoordinateDistanceKmToEvent = U(f, [t, e]), g;
2962
2962
  });
2963
2963
  }
2964
2964
  getSelectModeOrThrow() {
@@ -3040,7 +3040,7 @@ class to {
3040
3040
  const s = Object.entries(e);
3041
3041
  s.forEach(([n, a]) => {
3042
3042
  if (!this.checkIsReservedProperty(n)) throw new Error(`You are trying to update a reserved property name: ${n}. Please choose another name.`);
3043
- if (a !== void 0 && !Wt(a)) throw new Error(`Invalid JSON value provided for property ${n}`);
3043
+ if (a !== void 0 && !Bt(a)) throw new Error(`Invalid JSON value provided for property ${n}`);
3044
3044
  }), this._store.updateProperty(s.map(([n, a]) => ({ id: i.id, property: n, value: a })), { origin: "api" });
3045
3045
  }
3046
3046
  updateFeatureGeometry(t, e) {
@@ -3074,9 +3074,9 @@ class to {
3074
3074
  if (e.projection != "web-mercator") throw new Error(`Projection ${e.projection} is not currently supported for transformation`);
3075
3075
  if (e.type === "scale") {
3076
3076
  const { x: a, y: l } = O(e.origin[0], e.origin[1]);
3077
- We({ coordinates: n, originX: a, originY: l, xScale: e.options.xScale || 1, yScale: e.options.yScale || 1 });
3078
- } else e.type === "rotate" && (i = Te(i, e.options.angle || 0), n = i.geometry.type === "Polygon" ? i.geometry.coordinates[0] : i.geometry.coordinates);
3079
- if (n = n.map((a) => [w(a[0], this._adapter.getCoordinatePrecision()), w(a[1], this._adapter.getCoordinatePrecision())]), i.geometry.coordinates = i.geometry.type === "Polygon" ? [n] : n, this._store.updateGeometry([{ id: i.id, geometry: i.geometry }], { origin: "api" }), s.afterFeatureUpdated) {
3077
+ Be({ coordinates: n, originX: a, originY: l, xScale: e.options.xScale || 1, yScale: e.options.yScale || 1 });
3078
+ } else e.type === "rotate" && (i = We(i, e.options.angle || 0), n = i.geometry.type === "Polygon" ? i.geometry.coordinates[0] : i.geometry.coordinates);
3079
+ if (n = n.map((a) => [b(a[0], this._adapter.getCoordinatePrecision()), b(a[1], this._adapter.getCoordinatePrecision())]), i.geometry.coordinates = i.geometry.type === "Polygon" ? [n] : n, this._store.updateGeometry([{ id: i.id, geometry: i.geometry }], { origin: "api" }), s.afterFeatureUpdated) {
3080
3080
  s.afterFeatureUpdated(i);
3081
3081
  const a = i.properties[k.SELECTED], l = this.getSelectMode({ switchToSelectMode: !1 });
3082
3082
  l && a && l.afterFeatureUpdated(i);
@@ -3084,7 +3084,7 @@ class to {
3084
3084
  }
3085
3085
  addFeatures(t) {
3086
3086
  return this.checkEnabled(), t.length === 0 ? [] : this._store.load(t, (e) => {
3087
- if (Qt(e)) {
3087
+ if (te(e)) {
3088
3088
  const i = e.properties.mode, o = this._modes[i];
3089
3089
  if (!o) return { id: e.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
3090
3090
  const s = o.validateFeature.bind(o)(e);
@@ -3092,7 +3092,7 @@ class to {
3092
3092
  }
3093
3093
  return { id: e.id, valid: !1, reason: "Mode property does not exist" };
3094
3094
  }, (e) => {
3095
- if (Qt(e)) {
3095
+ if (te(e)) {
3096
3096
  const i = this._modes[e.properties.mode];
3097
3097
  i && i.afterFeatureAdded && i.afterFeatureAdded(e);
3098
3098
  }
@@ -3141,7 +3141,7 @@ class to {
3141
3141
  i.includes(e) && i.splice(i.indexOf(e), 1);
3142
3142
  }
3143
3143
  }
3144
- class eo extends Hi.TerraDrawBaseAdapter {
3144
+ class io extends Zi.TerraDrawBaseAdapter {
3145
3145
  constructor(t) {
3146
3146
  super(t), this._renderBeforeLayerId = void 0, this._prefixId = void 0, this._initialDragPan = void 0, this._initialDragRotate = void 0, this._nextRender = void 0, this._map = void 0, this._container = void 0, 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(), this._renderBeforeLayerId = t.renderBelowLayerId, this._prefixId = t.prefixId || "td";
3147
3147
  }
@@ -3229,7 +3229,7 @@ class eo extends Hi.TerraDrawBaseAdapter {
3229
3229
  this._renderBeforeLayerId && (this._map.moveLayer(s, this._renderBeforeLayerId), this._map.moveLayer(o, s), this._map.moveLayer(i + "-outline", o), this._map.moveLayer(i, o)), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
3230
3230
  }
3231
3231
  }
3232
- const $o = [
3232
+ const Yo = [
3233
3233
  "render",
3234
3234
  "point",
3235
3235
  "linestring",
@@ -3245,7 +3245,7 @@ const $o = [
3245
3245
  "delete-selection",
3246
3246
  "delete",
3247
3247
  "download"
3248
- ], Yo = [
3248
+ ], Ko = [
3249
3249
  "render",
3250
3250
  "linestring",
3251
3251
  "point",
@@ -3254,7 +3254,7 @@ const $o = [
3254
3254
  "delete",
3255
3255
  "download",
3256
3256
  "settings"
3257
- ], io = {
3257
+ ], oo = {
3258
3258
  modes: [
3259
3259
  "render",
3260
3260
  "point",
@@ -3273,7 +3273,7 @@ const $o = [
3273
3273
  "download"
3274
3274
  ],
3275
3275
  open: !1
3276
- }, bt = {
3276
+ }, J = {
3277
3277
  kilometer: "km",
3278
3278
  meter: "m",
3279
3279
  centimeter: "cm",
@@ -3288,7 +3288,7 @@ const $o = [
3288
3288
  "square yards": "yd²",
3289
3289
  acres: "acres",
3290
3290
  "square miles": "mi²"
3291
- }, lt = {
3291
+ }, dt = {
3292
3292
  modes: [
3293
3293
  "render",
3294
3294
  "point",
@@ -3309,7 +3309,7 @@ const $o = [
3309
3309
  open: !1,
3310
3310
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
3311
3311
  modeOptions: {
3312
- point: new zt({
3312
+ point: new Vt({
3313
3313
  editable: !0,
3314
3314
  styles: {
3315
3315
  pointColor: "#FFFFFF",
@@ -3318,7 +3318,7 @@ const $o = [
3318
3318
  pointOutlineWidth: 1
3319
3319
  }
3320
3320
  }),
3321
- linestring: new Ut({
3321
+ linestring: new zt({
3322
3322
  editable: !0,
3323
3323
  styles: {
3324
3324
  lineStringColor: "#666666",
@@ -3329,7 +3329,7 @@ const $o = [
3329
3329
  closingPointOutlineWidth: 1
3330
3330
  }
3331
3331
  }),
3332
- polygon: new Me({
3332
+ polygon: new De({
3333
3333
  editable: !0,
3334
3334
  styles: {
3335
3335
  fillColor: "#EDEFF0",
@@ -3342,7 +3342,7 @@ const $o = [
3342
3342
  closingPointOutlineWidth: 1
3343
3343
  }
3344
3344
  }),
3345
- rectangle: new De({
3345
+ rectangle: new _e({
3346
3346
  styles: {
3347
3347
  fillColor: "#EDEFF0",
3348
3348
  fillOpacity: 0.7,
@@ -3350,7 +3350,7 @@ const $o = [
3350
3350
  outlineWidth: 2
3351
3351
  }
3352
3352
  }),
3353
- "angled-rectangle": new je({
3353
+ "angled-rectangle": new Ae({
3354
3354
  styles: {
3355
3355
  fillColor: "#EDEFF0",
3356
3356
  fillOpacity: 0.7,
@@ -3358,7 +3358,7 @@ const $o = [
3358
3358
  outlineWidth: 2
3359
3359
  }
3360
3360
  }),
3361
- circle: new Ee({
3361
+ circle: new be({
3362
3362
  styles: {
3363
3363
  fillColor: "#EDEFF0",
3364
3364
  fillOpacity: 0.7,
@@ -3366,7 +3366,7 @@ const $o = [
3366
3366
  outlineWidth: 2
3367
3367
  }
3368
3368
  }),
3369
- freehand: new be({
3369
+ freehand: new we({
3370
3370
  styles: {
3371
3371
  fillColor: "#EDEFF0",
3372
3372
  fillOpacity: 0.7,
@@ -3378,7 +3378,7 @@ const $o = [
3378
3378
  closingPointOutlineWidth: 1
3379
3379
  }
3380
3380
  }),
3381
- "freehand-linestring": new Ue({
3381
+ "freehand-linestring": new ze({
3382
3382
  styles: {
3383
3383
  lineStringColor: "#666666",
3384
3384
  lineStringWidth: 2,
@@ -3388,7 +3388,7 @@ const $o = [
3388
3388
  closingPointOutlineWidth: 1
3389
3389
  }
3390
3390
  }),
3391
- sensor: new Ge({
3391
+ sensor: new Ue({
3392
3392
  styles: {
3393
3393
  fillColor: "#EDEFF0",
3394
3394
  fillOpacity: 0.7,
@@ -3400,7 +3400,7 @@ const $o = [
3400
3400
  centerPointOutlineWidth: 1
3401
3401
  }
3402
3402
  }),
3403
- sector: new Re({
3403
+ sector: new Ge({
3404
3404
  styles: {
3405
3405
  fillColor: "#EDEFF0",
3406
3406
  fillOpacity: 0.7,
@@ -3408,7 +3408,7 @@ const $o = [
3408
3408
  outlineWidth: 2
3409
3409
  }
3410
3410
  }),
3411
- select: new Vt({
3411
+ select: new $t({
3412
3412
  flags: {
3413
3413
  point: {
3414
3414
  feature: {
@@ -3531,7 +3531,13 @@ const $o = [
3531
3531
  "text-field": [
3532
3532
  "case",
3533
3533
  ["all", ["has", "elevation"], [">", ["get", "elevation"], 0]],
3534
- ["concat", "Alt. ", ["to-string", ["floor", ["get", "elevation"]]], " m"],
3534
+ [
3535
+ "concat",
3536
+ "Alt. ",
3537
+ ["to-string", ["floor", ["get", "elevation"]]],
3538
+ " ",
3539
+ ["get", "elevationUnit"]
3540
+ ],
3535
3541
  ""
3536
3542
  ],
3537
3543
  "symbol-placement": "point",
@@ -3583,8 +3589,14 @@ const $o = [
3583
3589
  [
3584
3590
  "case",
3585
3591
  ["all", ["has", "elevation"], [">", ["get", "elevation"], 0]],
3586
- ["concat", `
3587
- Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3592
+ [
3593
+ "concat",
3594
+ `
3595
+ Alt. `,
3596
+ ["to-string", ["floor", ["get", "elevation"]]],
3597
+ " ",
3598
+ ["get", "elevationUnit"]
3599
+ ],
3588
3600
  ""
3589
3601
  ]
3590
3602
  ],
@@ -3675,7 +3687,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3675
3687
  forceDistanceUnit: "auto",
3676
3688
  areaPrecision: 2,
3677
3689
  forceAreaUnit: "auto",
3678
- measureUnitSymbols: JSON.parse(JSON.stringify(bt)),
3690
+ measureUnitSymbols: JSON.parse(JSON.stringify(J)),
3679
3691
  elevationCacheConfig: {
3680
3692
  enabled: !0,
3681
3693
  maxSize: 1e3,
@@ -3701,7 +3713,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3701
3713
  open: !1,
3702
3714
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
3703
3715
  modeOptions: {
3704
- point: new zt({
3716
+ point: new Vt({
3705
3717
  editable: !1,
3706
3718
  styles: {
3707
3719
  pointColor: "#FFFFFF",
@@ -3710,7 +3722,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3710
3722
  pointOutlineWidth: 1
3711
3723
  }
3712
3724
  }),
3713
- linestring: new Ut({
3725
+ linestring: new zt({
3714
3726
  editable: !1,
3715
3727
  styles: {
3716
3728
  lineStringColor: "#FF0000",
@@ -3721,7 +3733,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3721
3733
  closingPointOutlineWidth: 1
3722
3734
  }
3723
3735
  }),
3724
- select: new Vt({
3736
+ select: new $t({
3725
3737
  flags: {
3726
3738
  point: {
3727
3739
  feature: {
@@ -3742,7 +3754,7 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3742
3754
  }
3743
3755
  }
3744
3756
  }),
3745
- settings: new Q({
3757
+ settings: new tt({
3746
3758
  modeName: "settings",
3747
3759
  styles: {}
3748
3760
  })
@@ -3916,34 +3928,34 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3916
3928
  "text-halo-color": "rgb(255, 255, 255)"
3917
3929
  }
3918
3930
  }
3919
- }, oo = () => ({
3920
- render: new Q({
3931
+ }, so = () => ({
3932
+ render: new tt({
3921
3933
  modeName: "render",
3922
3934
  styles: {}
3923
3935
  }),
3924
- point: new zt({
3936
+ point: new Vt({
3925
3937
  editable: !0
3926
3938
  }),
3927
- linestring: new Ut({
3939
+ linestring: new zt({
3928
3940
  editable: !0
3929
3941
  }),
3930
- polygon: new Me({
3942
+ polygon: new De({
3931
3943
  editable: !0,
3932
3944
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3933
3945
  // @ts-ignore
3934
3946
  validation: (t, e) => {
3935
3947
  const i = e.updateType;
3936
- return i === "finish" || i === "commit" ? Vi(t) : { valid: !0 };
3948
+ return i === "finish" || i === "commit" ? $i(t) : { valid: !0 };
3937
3949
  }
3938
3950
  }),
3939
- rectangle: new De(),
3940
- "angled-rectangle": new je(),
3941
- circle: new Ee(),
3942
- freehand: new be(),
3943
- "freehand-linestring": new Ue(),
3944
- sensor: new Ge(),
3945
- sector: new Re(),
3946
- select: new Vt({
3951
+ rectangle: new _e(),
3952
+ "angled-rectangle": new Ae(),
3953
+ circle: new be(),
3954
+ freehand: new we(),
3955
+ "freehand-linestring": new ze(),
3956
+ sensor: new Ue(),
3957
+ sector: new Ge(),
3958
+ select: new $t({
3947
3959
  flags: {
3948
3960
  point: {
3949
3961
  feature: {
@@ -4056,20 +4068,20 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
4056
4068
  }
4057
4069
  }
4058
4070
  }),
4059
- delete: new Q({
4071
+ delete: new tt({
4060
4072
  modeName: "delete",
4061
4073
  styles: {}
4062
4074
  }),
4063
- "delete-selection": new Q({
4075
+ "delete-selection": new tt({
4064
4076
  modeName: "delete-selection",
4065
4077
  styles: {}
4066
4078
  }),
4067
- download: new Q({
4079
+ download: new tt({
4068
4080
  modeName: "download",
4069
4081
  styles: {}
4070
4082
  })
4071
4083
  });
4072
- var W = 63710088e-1, so = {
4084
+ var W = 63710088e-1, ro = {
4073
4085
  centimeters: W * 100,
4074
4086
  centimetres: W * 100,
4075
4087
  degrees: 360 / (2 * Math.PI),
@@ -4086,42 +4098,42 @@ var W = 63710088e-1, so = {
4086
4098
  radians: 1,
4087
4099
  yards: W * 1.0936
4088
4100
  };
4089
- function ro(r, t, e = {}) {
4101
+ function no(r, t, e = {}) {
4090
4102
  const i = { type: "Feature" };
4091
4103
  return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
4092
4104
  }
4093
- function no(r, t, e = {}) {
4105
+ function ao(r, t, e = {}) {
4094
4106
  if (!r)
4095
4107
  throw new Error("coordinates is required");
4096
4108
  if (!Array.isArray(r))
4097
4109
  throw new Error("coordinates must be an Array");
4098
4110
  if (r.length < 2)
4099
4111
  throw new Error("coordinates must be at least 2 numbers long");
4100
- if (!ge(r[0]) || !ge(r[1]))
4112
+ if (!ye(r[0]) || !ye(r[1]))
4101
4113
  throw new Error("coordinates must contain numbers");
4102
- return ro({
4114
+ return no({
4103
4115
  type: "Point",
4104
4116
  coordinates: r
4105
4117
  }, t, e);
4106
4118
  }
4107
- function ao(r, t = "kilometers") {
4108
- const e = so[t];
4119
+ function lo(r, t = "kilometers") {
4120
+ const e = ro[t];
4109
4121
  if (!e)
4110
4122
  throw new Error(t + " units is invalid");
4111
4123
  return r * e;
4112
4124
  }
4113
- function vt(r) {
4125
+ function Pt(r) {
4114
4126
  return r % 360 * Math.PI / 180;
4115
4127
  }
4116
- function ge(r) {
4128
+ function ye(r) {
4117
4129
  return !isNaN(r) && r !== null && !Array.isArray(r);
4118
4130
  }
4119
- function ze(r, t, e) {
4131
+ function Ve(r, t, e) {
4120
4132
  if (r !== null)
4121
- for (var i, o, s, n, a, l, d, c = 0, h = 0, u, p = r.type, g = p === "FeatureCollection", y = p === "Feature", m = g ? r.features.length : 1, v = 0; v < m; v++) {
4133
+ for (var i, o, s, n, a, l, d, c = 0, h = 0, u, p = r.type, g = p === "FeatureCollection", y = p === "Feature", f = g ? r.features.length : 1, v = 0; v < f; v++) {
4122
4134
  d = g ? r.features[v].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
4123
4135
  for (var C = 0; C < a; C++) {
4124
- var f = 0, P = 0;
4136
+ var m = 0, P = 0;
4125
4137
  if (n = u ? d.geometries[C] : d, n !== null) {
4126
4138
  l = n.coordinates;
4127
4139
  var I = n.type;
@@ -4133,11 +4145,11 @@ function ze(r, t, e) {
4133
4145
  l,
4134
4146
  h,
4135
4147
  v,
4136
- f,
4148
+ m,
4137
4149
  P
4138
4150
  ) === !1)
4139
4151
  return !1;
4140
- h++, f++;
4152
+ h++, m++;
4141
4153
  break;
4142
4154
  case "LineString":
4143
4155
  case "MultiPoint":
@@ -4146,13 +4158,13 @@ function ze(r, t, e) {
4146
4158
  l[i],
4147
4159
  h,
4148
4160
  v,
4149
- f,
4161
+ m,
4150
4162
  P
4151
4163
  ) === !1)
4152
4164
  return !1;
4153
- h++, I === "MultiPoint" && f++;
4165
+ h++, I === "MultiPoint" && m++;
4154
4166
  }
4155
- I === "LineString" && f++;
4167
+ I === "LineString" && m++;
4156
4168
  break;
4157
4169
  case "Polygon":
4158
4170
  case "MultiLineString":
@@ -4162,15 +4174,15 @@ function ze(r, t, e) {
4162
4174
  l[i][o],
4163
4175
  h,
4164
4176
  v,
4165
- f,
4177
+ m,
4166
4178
  P
4167
4179
  ) === !1)
4168
4180
  return !1;
4169
4181
  h++;
4170
4182
  }
4171
- I === "MultiLineString" && f++, I === "Polygon" && P++;
4183
+ I === "MultiLineString" && m++, I === "Polygon" && P++;
4172
4184
  }
4173
- I === "Polygon" && f++;
4185
+ I === "Polygon" && m++;
4174
4186
  break;
4175
4187
  case "MultiPolygon":
4176
4188
  for (i = 0; i < l.length; i++) {
@@ -4180,7 +4192,7 @@ function ze(r, t, e) {
4180
4192
  l[i][o][s],
4181
4193
  h,
4182
4194
  v,
4183
- f,
4195
+ m,
4184
4196
  P
4185
4197
  ) === !1)
4186
4198
  return !1;
@@ -4188,12 +4200,12 @@ function ze(r, t, e) {
4188
4200
  }
4189
4201
  P++;
4190
4202
  }
4191
- f++;
4203
+ m++;
4192
4204
  }
4193
4205
  break;
4194
4206
  case "GeometryCollection":
4195
4207
  for (i = 0; i < n.geometries.length; i++)
4196
- if (ze(n.geometries[i], t) === !1)
4208
+ if (Ve(n.geometries[i], t) === !1)
4197
4209
  return !1;
4198
4210
  break;
4199
4211
  default:
@@ -4203,7 +4215,7 @@ function ze(r, t, e) {
4203
4215
  }
4204
4216
  }
4205
4217
  }
4206
- function lo(r, t) {
4218
+ function co(r, t) {
4207
4219
  var e, i, o, s, n, a, l, d, c, h, u = 0, p = r.type === "FeatureCollection", g = r.type === "Feature", y = p ? r.features.length : 1;
4208
4220
  for (e = 0; e < y; e++) {
4209
4221
  for (a = p ? r.features[e].geometry : g ? r.geometry : r, d = p ? r.features[e].properties : g ? r.properties : {}, c = p ? r.features[e].bbox : g ? r.bbox : void 0, h = p ? r.features[e].id : g ? r.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
@@ -4254,9 +4266,9 @@ function lo(r, t) {
4254
4266
  u++;
4255
4267
  }
4256
4268
  }
4257
- function co(r, t, e) {
4269
+ function ho(r, t, e) {
4258
4270
  var i = e;
4259
- return lo(
4271
+ return co(
4260
4272
  r,
4261
4273
  function(o, s, n, a, l) {
4262
4274
  s === 0 && e === void 0 ? i = o : i = t(
@@ -4270,21 +4282,21 @@ function co(r, t, e) {
4270
4282
  }
4271
4283
  ), i;
4272
4284
  }
4273
- function ho(r) {
4274
- return co(
4285
+ function uo(r) {
4286
+ return ho(
4275
4287
  r,
4276
- (t, e) => t + uo(e),
4288
+ (t, e) => t + po(e),
4277
4289
  0
4278
4290
  );
4279
4291
  }
4280
- function uo(r) {
4292
+ function po(r) {
4281
4293
  let t = 0, e;
4282
4294
  switch (r.type) {
4283
4295
  case "Polygon":
4284
- return ye(r.coordinates);
4296
+ return fe(r.coordinates);
4285
4297
  case "MultiPolygon":
4286
4298
  for (e = 0; e < r.coordinates.length; e++)
4287
- t += ye(r.coordinates[e]);
4299
+ t += fe(r.coordinates[e]);
4288
4300
  return t;
4289
4301
  case "Point":
4290
4302
  case "MultiPoint":
@@ -4294,36 +4306,36 @@ function uo(r) {
4294
4306
  }
4295
4307
  return 0;
4296
4308
  }
4297
- function ye(r) {
4309
+ function fe(r) {
4298
4310
  let t = 0;
4299
4311
  if (r && r.length > 0) {
4300
- t += Math.abs(fe(r[0]));
4312
+ t += Math.abs(me(r[0]));
4301
4313
  for (let e = 1; e < r.length; e++)
4302
- t -= Math.abs(fe(r[e]));
4314
+ t -= Math.abs(me(r[e]));
4303
4315
  }
4304
4316
  return t;
4305
4317
  }
4306
- var po = W * W / 2, Dt = Math.PI / 180;
4307
- function fe(r) {
4318
+ var go = W * W / 2, _t = Math.PI / 180;
4319
+ function me(r) {
4308
4320
  const t = r.length - 1;
4309
4321
  if (t <= 2) return 0;
4310
4322
  let e = 0, i = 0;
4311
4323
  for (; i < t; ) {
4312
- const o = r[i], s = r[i + 1 === t ? 0 : i + 1], n = r[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Dt, l = s[1] * Dt, d = n[0] * Dt;
4324
+ const o = r[i], s = r[i + 1 === t ? 0 : i + 1], n = r[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * _t, l = s[1] * _t, d = n[0] * _t;
4313
4325
  e += (d - a) * Math.sin(l), i++;
4314
4326
  }
4315
- return e * po;
4327
+ return e * go;
4316
4328
  }
4317
- var go = ho;
4318
- const yo = (r, t, e = "auto", i = bt) => {
4329
+ var yo = uo;
4330
+ const fo = (r, t, e = "auto", i = J) => {
4319
4331
  const o = ["square meters", "square kilometers", "ares", "hectares"], s = ["square feet", "square yards", "acres", "square miles"];
4320
4332
  let n = e;
4321
4333
  if (e !== "auto") {
4322
4334
  const a = o.includes(e), l = s.includes(e);
4323
4335
  (t === "metric" && !a || t === "imperial" && !l) && (n = "auto");
4324
4336
  }
4325
- return t === "metric" ? n !== "auto" ? ot(r, n, i) : r >= 1e6 ? ot(r, "square kilometers", i) : r >= 1e4 ? ot(r, "hectares", i) : r >= 100 ? ot(r, "ares", i) : ot(r, "square meters", i) : n !== "auto" ? st(r, n, i) : r >= 258998811e-2 ? st(r, "square miles", i) : r >= 4046.856 ? st(r, "acres", i) : r >= 0.83612736 ? st(r, "square yards", i) : st(r, "square feet", i);
4326
- }, ot = (r, t, e) => {
4337
+ return t === "metric" ? n !== "auto" ? st(r, n, i) : r >= 1e6 ? st(r, "square kilometers", i) : r >= 1e4 ? st(r, "hectares", i) : r >= 100 ? st(r, "ares", i) : st(r, "square meters", i) : n !== "auto" ? rt(r, n, i) : r >= 258998811e-2 ? rt(r, "square miles", i) : r >= 4046.856 ? rt(r, "acres", i) : r >= 0.83612736 ? rt(r, "square yards", i) : rt(r, "square feet", i);
4338
+ }, st = (r, t, e) => {
4327
4339
  let i = r, o = e["square meters"];
4328
4340
  switch (t) {
4329
4341
  case "square meters":
@@ -4343,7 +4355,7 @@ const yo = (r, t, e = "auto", i = bt) => {
4343
4355
  area: i,
4344
4356
  unit: o
4345
4357
  };
4346
- }, st = (r, t, e) => {
4358
+ }, rt = (r, t, e) => {
4347
4359
  let i = r / 258998811e-2, o = e["square meters"];
4348
4360
  switch (t) {
4349
4361
  case "square feet":
@@ -4363,12 +4375,12 @@ const yo = (r, t, e = "auto", i = bt) => {
4363
4375
  area: i,
4364
4376
  unit: o
4365
4377
  };
4366
- }, me = (r, t, e, i, o) => {
4378
+ }, ve = (r, t, e, i, o) => {
4367
4379
  if (r.geometry.type !== "Polygon") return r;
4368
- const s = go(r.geometry), n = yo(s, t, i, o);
4380
+ const s = yo(r.geometry), n = fo(s, t, i, o);
4369
4381
  return n.area = parseFloat(n.area.toFixed(e)), r.properties.area = n.area, r.properties.unit = n.unit, r;
4370
4382
  };
4371
- function ve(r) {
4383
+ function Ce(r) {
4372
4384
  if (!r)
4373
4385
  throw new Error("coord is required");
4374
4386
  if (!Array.isArray(r)) {
@@ -4381,15 +4393,15 @@ function ve(r) {
4381
4393
  return [...r];
4382
4394
  throw new Error("coord must be GeoJSON Point or an Array of numbers");
4383
4395
  }
4384
- function fo(r, t, e = {}) {
4385
- var i = ve(r), o = ve(t), s = vt(o[1] - i[1]), n = vt(o[0] - i[0]), a = vt(i[1]), l = vt(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
4386
- return ao(
4396
+ function mo(r, t, e = {}) {
4397
+ var i = Ce(r), o = Ce(t), s = Pt(o[1] - i[1]), n = Pt(o[0] - i[0]), a = Pt(i[1]), l = Pt(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
4398
+ return lo(
4387
4399
  2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
4388
4400
  e.units
4389
4401
  );
4390
4402
  }
4391
- var mo = fo;
4392
- const _t = (r, t = "metric", e = "auto", i = bt) => {
4403
+ var vo = mo;
4404
+ const kt = (r, t = "metric", e = "auto", i = J) => {
4393
4405
  const o = ["centimeter", "meter", "kilometer"], s = ["inch", "foot", "mile"];
4394
4406
  let n = e;
4395
4407
  if (e !== "auto") {
@@ -4400,8 +4412,8 @@ const _t = (r, t = "metric", e = "auto", i = bt) => {
4400
4412
  distance: r,
4401
4413
  unit: i.kilometer
4402
4414
  };
4403
- return t === "metric" ? a = Ct(r, n, i) : t === "imperial" && (a = Pt(r, n, i)), a;
4404
- }, Ct = (r, t, e) => {
4415
+ return t === "metric" ? a = St(r, n, i) : t === "imperial" && (a = It(r, n, i)), a;
4416
+ }, St = (r, t, e) => {
4405
4417
  let i = {
4406
4418
  distance: r,
4407
4419
  unit: e.kilometer
@@ -4417,14 +4429,14 @@ const _t = (r, t = "metric", e = "auto", i = bt) => {
4417
4429
  i.distance = r * 1e5, i.unit = e[t];
4418
4430
  break;
4419
4431
  case "auto":
4420
- r >= 1 ? i = Ct(r, "kilometer", e) : r * 1e3 >= 1 ? i = Ct(r, "meter", e) : i = Ct(r, "centimeter", e);
4432
+ r >= 1 ? i = St(r, "kilometer", e) : r * 1e3 >= 1 ? i = St(r, "meter", e) : i = St(r, "centimeter", e);
4421
4433
  break;
4422
4434
  default:
4423
4435
  i.distance = r, i.unit = e.kilometer;
4424
4436
  break;
4425
4437
  }
4426
4438
  return i;
4427
- }, Pt = (r, t, e) => {
4439
+ }, It = (r, t, e) => {
4428
4440
  let i = {
4429
4441
  distance: r,
4430
4442
  unit: e.mile
@@ -4440,32 +4452,32 @@ const _t = (r, t = "metric", e = "auto", i = bt) => {
4440
4452
  i.distance = r * 63360, i.unit = e[t];
4441
4453
  break;
4442
4454
  case "auto":
4443
- r >= 1 ? i = Pt(r, "mile", e) : r * 5280 >= 1 ? i = Pt(r, "foot", e) : i = Pt(r, "inch", e);
4455
+ r >= 1 ? i = It(r, "mile", e) : r * 5280 >= 1 ? i = It(r, "foot", e) : i = It(r, "inch", e);
4444
4456
  break;
4445
4457
  default:
4446
4458
  i.distance = r, i.unit = e.mile;
4447
4459
  break;
4448
4460
  }
4449
4461
  return i;
4450
- }, Ce = (r, t, e, i, o, s, n, a) => {
4462
+ }, Pe = (r, t, e, i, o, s, n, a) => {
4451
4463
  if (r.geometry.type !== "LineString") return r;
4452
4464
  const l = r.geometry.coordinates;
4453
4465
  let d = 0;
4454
4466
  const c = [];
4455
4467
  for (let u = 0; u < l.length - 1; u++) {
4456
- const p = l[u], g = l[u + 1], y = mo(p, g, { units: t === "metric" ? "kilometers" : "miles" });
4468
+ const p = l[u], g = l[u + 1], y = vo(p, g, { units: t === "metric" ? "kilometers" : "miles" });
4457
4469
  d += y;
4458
- const m = JSON.parse(JSON.stringify(r));
4459
- if (m.id = `${m.id}-${u}`, m.geometry.coordinates = [p, g], m.properties.originalId = r.id, m.properties.distance = y, m.properties.total = d, n === !0 && a === void 0) {
4470
+ const f = JSON.parse(JSON.stringify(r));
4471
+ if (f.id = `${f.id}-${u}`, f.geometry.coordinates = [p, g], f.properties.originalId = r.id, f.properties.distance = y, f.properties.total = d, n === !0 && a === void 0) {
4460
4472
  const v = s?.queryTerrainElevation(p);
4461
- v && (m.properties.elevation_start = v);
4473
+ v && (f.properties.elevation_start = v);
4462
4474
  const C = s?.queryTerrainElevation(g);
4463
- C && (m.properties.elevation_end = C);
4475
+ C && (f.properties.elevation_end = C);
4464
4476
  }
4465
- c.push(m);
4477
+ c.push(f);
4466
4478
  }
4467
4479
  r.properties.distance = c[c.length - 1].properties.total, r.properties.segments = JSON.parse(JSON.stringify(c));
4468
- const h = _t(
4480
+ const h = kt(
4469
4481
  r.properties.distance,
4470
4482
  t,
4471
4483
  i,
@@ -4473,14 +4485,14 @@ const _t = (r, t = "metric", e = "auto", i = bt) => {
4473
4485
  );
4474
4486
  return r.properties.distance = h.distance, r.properties.unit = h.unit, r.properties.segments.forEach(
4475
4487
  (u) => {
4476
- const p = _t(
4488
+ const p = kt(
4477
4489
  u.properties.distance,
4478
4490
  t,
4479
4491
  i,
4480
4492
  o
4481
4493
  );
4482
4494
  u.properties.distance = p.distance, u.properties.unit = p.unit;
4483
- const g = _t(
4495
+ const g = kt(
4484
4496
  u.properties.total,
4485
4497
  t,
4486
4498
  i,
@@ -4499,25 +4511,31 @@ const _t = (r, t = "metric", e = "auto", i = bt) => {
4499
4511
  );
4500
4512
  }
4501
4513
  ), r;
4502
- }, Pe = (r) => r.charAt(0).toUpperCase() + r.slice(1), et = [
4514
+ }, pt = (r, t = "metric", e = J) => t === "imperial" ? {
4515
+ elevation: r * 3.28084,
4516
+ unit: e.foot
4517
+ } : {
4518
+ elevation: r,
4519
+ unit: e.meter
4520
+ }, Se = (r) => r.charAt(0).toUpperCase() + r.slice(1), it = [
4503
4521
  "{prefix}-point",
4504
4522
  "{prefix}-point-lower",
4505
4523
  "{prefix}-linestring",
4506
4524
  "{prefix}-polygon",
4507
4525
  "{prefix}-polygon-outline"
4508
- ], Ko = [
4509
- ...et,
4510
- lt.polygonLayerSpec?.source,
4511
- lt.lineLayerLabelSpec?.source,
4512
- lt.pointLayerLabelSpec?.source
4513
4526
  ], Xo = [
4514
- ...et,
4527
+ ...it,
4528
+ dt.polygonLayerSpec?.source,
4529
+ dt.lineLayerLabelSpec?.source,
4530
+ dt.pointLayerLabelSpec?.source
4531
+ ], qo = [
4532
+ ...it,
4515
4533
  z.routingLineLayerNodeLabelSpec?.source,
4516
4534
  z.routingLineLayerNodeSpec?.source,
4517
4535
  z.isochronePolygonLayerSpec?.source,
4518
4536
  z.isochroneLineLayerSpec?.source,
4519
4537
  z.isochroneLabelLayerSpec?.source
4520
- ], $t = (r, t, e = et, i = "td") => {
4538
+ ], Yt = (r, t, e = it, i = "td") => {
4521
4539
  e = e.map((s) => s.replace("{prefix}", i));
4522
4540
  const o = JSON.parse(JSON.stringify(r));
4523
4541
  return t && (t.onlyTerraDrawLayers === !0 ? (o.layers = o.layers.filter((s) => "source" in s && e.includes(s.source)), Object.keys(o.sources).forEach((s) => {
@@ -4525,13 +4543,13 @@ const _t = (r, t = "metric", e = "auto", i = bt) => {
4525
4543
  })) : t.excludeTerraDrawLayers === !0 && (o.layers = o.layers.filter((s) => "source" in s && !e.includes(s.source) || s.type === "background"), Object.keys(o.sources).forEach((s) => {
4526
4544
  e.includes(s) && delete o.sources[s];
4527
4545
  }))), o;
4528
- }, Ve = (r, t = 250) => {
4546
+ }, $e = (r, t = 250) => {
4529
4547
  let e;
4530
4548
  return (...i) => {
4531
4549
  clearTimeout(e), e = setTimeout(() => r(...i), t);
4532
4550
  };
4533
4551
  };
4534
- class $e {
4552
+ class Ye {
4535
4553
  cache = /* @__PURE__ */ new Map();
4536
4554
  maxSize;
4537
4555
  ttl;
@@ -4609,7 +4627,7 @@ class $e {
4609
4627
  };
4610
4628
  }
4611
4629
  }
4612
- class vo {
4630
+ class Co {
4613
4631
  className;
4614
4632
  dialog;
4615
4633
  title;
@@ -4698,67 +4716,86 @@ class vo {
4698
4716
  }), o;
4699
4717
  }
4700
4718
  }
4701
- const Se = (r, t, e, i) => {
4719
+ const Ie = (r, t, e, i, o = "metric", s = J) => {
4702
4720
  if (r.geometry.type !== "Point") return r;
4703
- const o = r.geometry.coordinates;
4704
- if (e === !0 && i === void 0) {
4705
- const s = t?.queryTerrainElevation(o);
4706
- s && (r.properties.elevation = s);
4721
+ const n = r.geometry.coordinates;
4722
+ if (e === !0) {
4723
+ if (i === void 0) {
4724
+ const a = t?.queryTerrainElevation(n);
4725
+ if (a) {
4726
+ const { elevation: l, unit: d } = pt(
4727
+ a,
4728
+ o,
4729
+ s
4730
+ );
4731
+ r.properties.elevation = l, r.properties.elevationUnit = d;
4732
+ }
4733
+ } else if (r.properties.elevation !== void 0 && typeof r.properties.elevation == "number") {
4734
+ let a = r.properties.elevation;
4735
+ const l = r.properties.elevationUnit;
4736
+ (l === "ft" || l === "foot") && (a = a / 3.28084);
4737
+ const { elevation: d, unit: c } = pt(
4738
+ a,
4739
+ o,
4740
+ s
4741
+ );
4742
+ r.properties.elevation = d, r.properties.elevationUnit = c;
4743
+ }
4707
4744
  }
4708
4745
  return r;
4709
4746
  };
4710
- var Co = Object.defineProperty, Po = (r, t, e) => t in r ? Co(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, rt = (r, t, e) => Po(r, typeof t != "symbol" ? t + "" : t, e), xt = 2 * Math.PI * 6378137 / 2;
4711
- function So(r) {
4747
+ var Po = Object.defineProperty, So = (r, t, e) => t in r ? Po(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, nt = (r, t, e) => So(r, typeof t != "symbol" ? t + "" : t, e), Et = 2 * Math.PI * 6378137 / 2;
4748
+ function Io(r) {
4712
4749
  return r = r || 256, 2 * Math.PI * 6378137 / r;
4713
4750
  }
4714
- function Io(r, t, e = { enable: !0, decimal: 1 }) {
4715
- r = Yt(r);
4716
- var i = r[0], o = r[1], s = i * xt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
4717
- return n = n * xt / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
4751
+ function xo(r, t, e = { enable: !0, decimal: 1 }) {
4752
+ r = Kt(r);
4753
+ var i = r[0], o = r[1], s = i * Et / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
4754
+ return n = n * Et / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
4718
4755
  }
4719
- function xo(r, t, e) {
4720
- var i = r[0], o = r[1], s = Fo(t, e), n = (i + xt) / s, a = (o + xt) / s;
4756
+ function Oo(r, t, e) {
4757
+ var i = r[0], o = r[1], s = Mo(t, e), n = (i + Et) / s, a = (o + Et) / s;
4721
4758
  return [n, a, t];
4722
4759
  }
4723
- function Ye(r, t, e) {
4724
- r = Yt(r);
4725
- var i = Io(r), o = xo(i, t);
4726
- return Eo(o);
4760
+ function Ke(r, t, e) {
4761
+ r = Kt(r);
4762
+ var i = xo(r), o = Oo(i, t);
4763
+ return bo(o);
4727
4764
  }
4728
- function Oo(r, t, e) {
4729
- if (r = Yt(r), t === 0)
4765
+ function Eo(r, t, e) {
4766
+ if (r = Kt(r), t === 0)
4730
4767
  return [0, 0, 0];
4731
- var i = Ye(r, t);
4732
- return bo(i);
4768
+ var i = Ke(r, t);
4769
+ return wo(i);
4733
4770
  }
4734
- function Eo(r, t, e) {
4771
+ function bo(r, t, e) {
4735
4772
  t = t || 256;
4736
4773
  var i = r[0], o = r[1], s = r[2];
4737
4774
  if (s === 0) return [0, 0, 0];
4738
- Ke(s);
4775
+ Xe(s);
4739
4776
  var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
4740
4777
  return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, s];
4741
4778
  }
4742
- function bo(r, t) {
4743
- wo(r);
4779
+ function wo(r, t) {
4780
+ Lo(r);
4744
4781
  var e = r[0], i = r[1], o = r[2];
4745
4782
  if (o === 0)
4746
4783
  return [0, 0, 0];
4747
4784
  var s = e, n = Math.pow(2, o) - 1 - i;
4748
4785
  return [s, n, o];
4749
4786
  }
4750
- function wo(r, t) {
4787
+ function Lo(r, t) {
4751
4788
  var e = r[0], i = r[1], o = r[2];
4752
4789
  if (o == null) throw new Error("<zoom> is required");
4753
4790
  if (e == null) throw new Error("<x> is required");
4754
4791
  if (i == null) throw new Error("<y> is required");
4755
- return o = Ke(o), r = Lo(r), r;
4792
+ return o = Xe(o), r = Fo(r), r;
4756
4793
  }
4757
- function Lo(r) {
4794
+ function Fo(r) {
4758
4795
  var t = r[0], e = r[1], i = r[2], o = Math.pow(2, i);
4759
4796
  return t = t % o, t < 0 && (t = t + o), [t, e, i];
4760
4797
  }
4761
- function Ke(r) {
4798
+ function Xe(r) {
4762
4799
  if (r === !1) return r;
4763
4800
  if (r == null)
4764
4801
  throw new Error("<zoom> is required");
@@ -4768,22 +4805,22 @@ function Ke(r) {
4768
4805
  throw new Error("<zoom> cannot be greater than 32");
4769
4806
  return r;
4770
4807
  }
4771
- function Yt(r, t) {
4772
- var e = Do(r[0]), i = Mo(r[1]);
4808
+ function Kt(r, t) {
4809
+ var e = _o(r[0]), i = Do(r[1]);
4773
4810
  return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
4774
4811
  }
4775
- function Fo(r, t) {
4776
- return So(t) / Math.pow(2, r);
4812
+ function Mo(r, t) {
4813
+ return Io(t) / Math.pow(2, r);
4777
4814
  }
4778
- function Mo(r) {
4815
+ function Do(r) {
4779
4816
  if (r == null) throw new Error("lat is required");
4780
4817
  return (r > 90 || r < -90) && (r = r % 180, r > 90 && (r = -180 + r), r < -90 && (r = 180 + r), r === 0 && (r = 0)), r;
4781
4818
  }
4782
- function Do(r) {
4819
+ function _o(r) {
4783
4820
  if (r == null) throw new Error("lng is required");
4784
4821
  return (r > 180 || r < -180) && (r = r % 360, r > 180 && (r = -360 + r), r < -180 && (r = 360 + r), r === 0 && (r = 0)), r;
4785
4822
  }
4786
- class Xe {
4823
+ class qe {
4787
4824
  /**
4788
4825
  * Constructor
4789
4826
  * @param url URL for terrain RGB raster tilesets
@@ -4794,7 +4831,7 @@ class Xe {
4794
4831
  * @param tms whether it is Tile Map Service
4795
4832
  */
4796
4833
  constructor(t, e, i, o, s) {
4797
- rt(this, "url"), rt(this, "tileSize"), rt(this, "tms"), rt(this, "minzoom"), rt(this, "maxzoom"), this.url = t, this.tileSize = e, this.tms = s, this.minzoom = i, this.maxzoom = o, this.tms = s;
4834
+ nt(this, "url"), nt(this, "tileSize"), nt(this, "tms"), nt(this, "minzoom"), nt(this, "maxzoom"), this.url = t, this.tileSize = e, this.tms = s, this.minzoom = i, this.maxzoom = o, this.tms = s;
4798
4835
  }
4799
4836
  /**
4800
4837
  * Get the value from target coordinates and zoom level by using certain formula.
@@ -4808,7 +4845,7 @@ class Xe {
4808
4845
  const s = t[0], n = t[1];
4809
4846
  let a = e;
4810
4847
  e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
4811
- const l = this.tms ? Ye([s, n], a) : Oo([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
4848
+ const l = this.tms ? Ke([s, n], a) : Eo([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
4812
4849
  let c = this.getUrlExtension(d);
4813
4850
  switch (c || (c = "png"), c) {
4814
4851
  case "png":
@@ -4910,7 +4947,7 @@ class Xe {
4910
4947
  return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
4911
4948
  }
4912
4949
  }
4913
- class _o extends Xe {
4950
+ class ko extends qe {
4914
4951
  /**
4915
4952
  * Constructor
4916
4953
  * @param url URL for terrain RGB raster tilesets
@@ -4942,7 +4979,7 @@ class _o extends Xe {
4942
4979
  return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
4943
4980
  }
4944
4981
  }
4945
- class ko extends Xe {
4982
+ class No extends qe {
4946
4983
  /**
4947
4984
  * Constructor
4948
4985
  * @param url URL for terrarium raster tilesets
@@ -4976,11 +5013,11 @@ class ko extends Xe {
4976
5013
  return parseInt(o.toFixed(0));
4977
5014
  }
4978
5015
  }
4979
- const No = (r, t = 8) => {
5016
+ const To = (r, t = 8) => {
4980
5017
  const [e, i] = r, o = Math.pow(10, t), s = Math.round(e * o) / o, n = Math.round(i * o) / o;
4981
5018
  return `${s},${n}`;
4982
- }, Ie = async (r, t, e, i) => {
4983
- const o = [], s = {
5019
+ }, xe = async (r, t, e, i, o = "metric", s = J) => {
5020
+ const n = [], a = {
4984
5021
  enabled: !0,
4985
5022
  maxSize: 1e3,
4986
5023
  ttl: 36e5,
@@ -4988,36 +5025,53 @@ const No = (r, t = 8) => {
4988
5025
  precision: 6,
4989
5026
  ...e
4990
5027
  };
4991
- let n;
4992
- s.enabled && (n = i || new $e(s.maxSize, s.ttl));
4993
- let a, l = 15;
5028
+ let l;
5029
+ a.enabled && (l = i || new Ye(a.maxSize, a.ttl));
5030
+ let d, c = 15;
4994
5031
  if (t) {
4995
- const d = t.url, c = t.encoding ?? "mapbox", h = t.tileSize ?? 512, u = t.minzoom ?? 5;
4996
- l = t.maxzoom ?? 15;
4997
- const p = t.tms ?? !1;
4998
- a = c === "mapbox" ? new _o(d, h, u, l, p) : new ko(d, h, u, l, p);
4999
- }
5000
- for (const d of r)
5001
- o.push(
5002
- new Promise((c) => {
5003
- d.geometry.type !== "Point" && c(d);
5004
- const h = d.geometry.coordinates, u = No(h, s.precision);
5005
- if (n) {
5006
- const p = n.get(u);
5007
- if (p !== void 0) {
5008
- isNaN(p) || (d.properties.elevation = p), c(d);
5032
+ const h = t.url, u = t.encoding ?? "mapbox", p = t.tileSize ?? 512, g = t.minzoom ?? 5;
5033
+ c = t.maxzoom ?? 15;
5034
+ const y = t.tms ?? !1;
5035
+ d = u === "mapbox" ? new ko(h, p, g, c, y) : new No(h, p, g, c, y);
5036
+ }
5037
+ for (const h of r)
5038
+ n.push(
5039
+ new Promise((u) => {
5040
+ h.geometry.type !== "Point" && u(h);
5041
+ const p = h.geometry.coordinates, g = To(p, a.precision);
5042
+ if (l) {
5043
+ const y = l.get(g);
5044
+ if (y !== void 0) {
5045
+ if (!isNaN(y)) {
5046
+ const { elevation: f, unit: v } = pt(
5047
+ y,
5048
+ o,
5049
+ s
5050
+ );
5051
+ h.properties.elevation = f, h.properties.elevationUnit = v;
5052
+ }
5053
+ u(h);
5009
5054
  return;
5010
5055
  }
5011
5056
  }
5012
- a ? a.getElevation(d.geometry.coordinates, l).then((p) => {
5013
- p != null && typeof p == "number" && (n && n.set(u, p), d.properties.elevation = p), c(d);
5057
+ d ? d.getElevation(h.geometry.coordinates, c).then((y) => {
5058
+ if (y != null && typeof y == "number") {
5059
+ l && l.set(g, y);
5060
+ const { elevation: f, unit: v } = pt(
5061
+ y,
5062
+ o,
5063
+ s
5064
+ );
5065
+ h.properties.elevation = f, h.properties.elevationUnit = v;
5066
+ }
5067
+ u(h);
5014
5068
  }).catch(() => {
5015
- n && n.has(u) && n.delete(u), c(d);
5016
- }) : c(d);
5069
+ l && l.has(g) && l.delete(g), u(h);
5070
+ }) : u(h);
5017
5071
  })
5018
5072
  );
5019
- return await Promise.all(o);
5020
- }, qo = (r, t = 9) => {
5073
+ return await Promise.all(n);
5074
+ }, Jo = (r, t = 9) => {
5021
5075
  function e(o) {
5022
5076
  return [Number(o[0].toFixed(t)), Number(o[1].toFixed(t))];
5023
5077
  }
@@ -5051,11 +5105,11 @@ const No = (r, t = 8) => {
5051
5105
  ...o,
5052
5106
  geometry: i(o.geometry)
5053
5107
  }));
5054
- }, To = [
5108
+ }, Wo = [
5055
5109
  { value: "time", label: "Time" },
5056
5110
  { value: "distance", label: "Distance" }
5057
5111
  ];
5058
- class Wo {
5112
+ class Bo {
5059
5113
  url;
5060
5114
  /**
5061
5115
  * Constructor
@@ -5087,15 +5141,15 @@ class Wo {
5087
5141
  return await (await fetch(l)).json();
5088
5142
  }
5089
5143
  }
5090
- const Bt = [
5144
+ const jt = [
5091
5145
  { value: "pedestrian", label: "Pedestrian" },
5092
5146
  { value: "bicycle", label: "Bicycle" },
5093
5147
  { value: "auto", label: "Car" }
5094
- ], Bo = [
5148
+ ], jo = [
5095
5149
  { value: "kilometers", label: "km" },
5096
5150
  { value: "miles", label: "mile" }
5097
5151
  ];
5098
- class jo {
5152
+ class Ao {
5099
5153
  tripData = [];
5100
5154
  /**
5101
5155
  * get the raw trip data from the valhalla routing API.
@@ -5146,7 +5200,7 @@ class jo {
5146
5200
  return;
5147
5201
  }
5148
5202
  const o = `${this.url}/route`, s = {
5149
- locations: this.tripData.map((f) => ({ lon: f.lng, lat: f.lat })),
5203
+ locations: this.tripData.map((m) => ({ lon: m.lng, lat: m.lat })),
5150
5204
  costing: e,
5151
5205
  costing_options: { auto: { country_crossing_penalty: 2e3 } },
5152
5206
  units: i,
@@ -5154,28 +5208,28 @@ class jo {
5154
5208
  }, n = `${o}?json=${JSON.stringify(s)}`, l = await (await fetch(n)).json();
5155
5209
  if ("error" in l)
5156
5210
  throw this.tripData.pop(), new Error(`${l.status} (${l.status_code}): ${l.error} (${l.error_code})`);
5157
- const d = l.trip.legs.map((f) => this.decodeShape(f.shape));
5211
+ const d = l.trip.legs.map((m) => this.decodeShape(m.shape));
5158
5212
  let c = [];
5159
- d.forEach((f) => {
5160
- c = [...c, ...f];
5213
+ d.forEach((m) => {
5214
+ c = [...c, ...m];
5161
5215
  }), this.tripSummary = l.trip.summary, this.tripSummary.length = Number(this.tripSummary.length.toFixed(2)), this.tripSummary.time = Number((this.tripSummary.time / 60).toFixed());
5162
5216
  const h = [];
5163
5217
  let u = 0, p = 0;
5164
- const g = [], y = this.geoPoint(this.tripData.map((f) => [f.lng, f.lat]));
5165
- l.trip.legs.forEach((f, P) => {
5166
- const I = this.decodeShape(f.shape);
5167
- h.push(...I), u += Number(f.summary.length.toFixed(2)), p += Number((f.summary.time / 60).toFixed()), g.push(...f.maneuvers);
5168
- const b = y.features[P + 1];
5169
- b.properties = {
5170
- ...b.properties,
5218
+ const g = [], y = this.geoPoint(this.tripData.map((m) => [m.lng, m.lat]));
5219
+ l.trip.legs.forEach((m, P) => {
5220
+ const I = this.decodeShape(m.shape);
5221
+ h.push(...I), u += Number(m.summary.length.toFixed(2)), p += Number((m.summary.time / 60).toFixed()), g.push(...m.maneuvers);
5222
+ const w = y.features[P + 1];
5223
+ w.properties = {
5224
+ ...w.properties,
5171
5225
  distance: u,
5172
5226
  distance_unit: i === "kilometers" ? "km" : "mi",
5173
5227
  time: p,
5174
- maneuvers: f.maneuvers
5228
+ maneuvers: m.maneuvers
5175
5229
  };
5176
5230
  });
5177
- const m = Bt.find((f) => f.value === e)?.label, v = this.geoLineString(h, {
5178
- costingModel: m,
5231
+ const f = jt.find((m) => m.value === e)?.label, v = this.geoLineString(h, {
5232
+ costingModel: f,
5179
5233
  distance: u,
5180
5234
  distance_unit: i === "kilometers" ? "km" : "mi",
5181
5235
  time: p,
@@ -5183,7 +5237,7 @@ class jo {
5183
5237
  }), C = y.features[0];
5184
5238
  return C.properties = {
5185
5239
  ...C.properties,
5186
- costingModel: m
5240
+ costingModel: f
5187
5241
  }, { feature: v, pointFeatures: y };
5188
5242
  }
5189
5243
  /**
@@ -5249,7 +5303,7 @@ class jo {
5249
5303
  return n;
5250
5304
  }
5251
5305
  }
5252
- class qe {
5306
+ class Je {
5253
5307
  controlContainer;
5254
5308
  map;
5255
5309
  modeButtons = {};
@@ -5288,7 +5342,7 @@ class qe {
5288
5342
  i && i.length > 0 && (this.isExpanded ? i.item(0)?.classList.add("enabled") : (i.item(0)?.classList.remove("enabled"), this.resetActiveMode())), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.isExpanded ? this.dispatchEvent("expanded") : this.dispatchEvent("collapsed");
5289
5343
  }
5290
5344
  terradraw;
5291
- options = io;
5345
+ options = oo;
5292
5346
  events = {};
5293
5347
  defaultMode = "render";
5294
5348
  /**
@@ -5316,7 +5370,7 @@ class qe {
5316
5370
  if (this.options && this.options.modes && this.options.modes.length === 0)
5317
5371
  throw new Error("At least a mode must be enabled.");
5318
5372
  this.map = t;
5319
- const e = oo(), i = [];
5373
+ const e = so(), i = [];
5320
5374
  return this.options?.modes?.forEach((o) => {
5321
5375
  if (this.options.modeOptions && this.options.modeOptions[o]) {
5322
5376
  const s = this.options.modeOptions[o];
@@ -5334,12 +5388,12 @@ class qe {
5334
5388
  }), i.forEach((o) => {
5335
5389
  o.state !== "unregistered" && (o._state = "unregistered");
5336
5390
  }), this.options?.modes?.includes("render") || (i.push(
5337
- new Q({
5391
+ new tt({
5338
5392
  modeName: "default",
5339
5393
  styles: {}
5340
5394
  })
5341
- ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new to({
5342
- adapter: new eo({ map: t, ...this.options.adapterOptions }),
5395
+ ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new eo({
5396
+ adapter: new io({ map: t, ...this.options.adapterOptions }),
5343
5397
  modes: i
5344
5398
  }), this.map?.loaded() ? this.terradraw.start() : this.map?.once("load", () => {
5345
5399
  this.terradraw?.start();
@@ -5437,7 +5491,7 @@ class qe {
5437
5491
  */
5438
5492
  addTerradrawButton(t) {
5439
5493
  const e = document.createElement("button");
5440
- e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = Pe("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}add-control`), this.isExpanded || e.classList.add("hidden"), e.title = Pe(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.addEventListener("click", () => {
5494
+ e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = Se("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}add-control`), this.isExpanded || e.classList.add("hidden"), e.title = Se(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.addEventListener("click", () => {
5441
5495
  this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
5442
5496
  })) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${this.cssPrefix}${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
5443
5497
  if (!this.terradraw || !this.terradraw.enabled) return;
@@ -5485,10 +5539,10 @@ class qe {
5485
5539
  * @returns
5486
5540
  */
5487
5541
  cleanStyle(t, e) {
5488
- return $t(
5542
+ return Yt(
5489
5543
  t,
5490
5544
  e,
5491
- et,
5545
+ it,
5492
5546
  this.options.adapterOptions?.prefixId
5493
5547
  );
5494
5548
  }
@@ -5552,16 +5606,16 @@ class qe {
5552
5606
  }
5553
5607
  }
5554
5608
  }
5555
- function Ao(r, t = {}) {
5609
+ function Ro(r, t = {}) {
5556
5610
  let e = 0, i = 0, o = 0;
5557
- return ze(
5611
+ return Ve(
5558
5612
  r,
5559
5613
  function(s) {
5560
5614
  e += s[0], i += s[1], o++;
5561
5615
  }
5562
- ), no([e / o, i / o], t.properties);
5616
+ ), ao([e / o, i / o], t.properties);
5563
5617
  }
5564
- class Jo extends qe {
5618
+ class Ho extends Je {
5565
5619
  measureOptions;
5566
5620
  elevationCache;
5567
5621
  /**
@@ -5573,7 +5627,7 @@ class Jo extends qe {
5573
5627
  }
5574
5628
  set measureUnitType(t) {
5575
5629
  const e = this.measureOptions.measureUnitType === t;
5576
- this.measureOptions.measureUnitType = t, e || this.recalc();
5630
+ this.measureOptions.measureUnitType = t, e || (this.computeElevation && this.recalculateElevationUnits(), this.recalc());
5577
5631
  }
5578
5632
  /**
5579
5633
  * The precision of distance value. It will be set different value when distance unit is changed. Using setter to override the value if you want.
@@ -5623,7 +5677,7 @@ class Jo extends qe {
5623
5677
  * Measure unit symbols. If you want to change the default symbol, please overwrite the symbol by this option.
5624
5678
  */
5625
5679
  get measureUnitSymbols() {
5626
- return this.measureOptions.measureUnitSymbols ?? JSON.parse(JSON.stringify(bt));
5680
+ return this.measureOptions.measureUnitSymbols ?? JSON.parse(JSON.stringify(J));
5627
5681
  }
5628
5682
  set measureUnitSymbols(t) {
5629
5683
  const e = JSON.stringify(this.measureOptions.measureUnitSymbols) === JSON.stringify(t);
@@ -5681,8 +5735,8 @@ class Jo extends qe {
5681
5735
  */
5682
5736
  constructor(t) {
5683
5737
  let e = {
5684
- ...JSON.parse(JSON.stringify(lt)),
5685
- modeOptions: { ...lt.modeOptions }
5738
+ ...JSON.parse(JSON.stringify(dt)),
5739
+ modeOptions: { ...dt.modeOptions }
5686
5740
  };
5687
5741
  t && (e = Object.assign(e, t));
5688
5742
  const i = e.adapterOptions?.prefixId ?? "td-measure";
@@ -5691,7 +5745,7 @@ class Jo extends qe {
5691
5745
  open: e.open,
5692
5746
  modeOptions: e.modeOptions,
5693
5747
  adapterOptions: e.adapterOptions
5694
- }), this._cssPrefix = "measure-", this.measureOptions = e, this.measureOptions.elevationCacheConfig && this.measureOptions.elevationCacheConfig?.enabled && (this.elevationCache = new $e(
5748
+ }), this._cssPrefix = "measure-", this.measureOptions = e, this.measureOptions.elevationCacheConfig && this.measureOptions.elevationCacheConfig?.enabled && (this.elevationCache = new Ye(
5695
5749
  this.measureOptions.elevationCacheConfig.maxSize,
5696
5750
  this.measureOptions.elevationCacheConfig.ttl
5697
5751
  ));
@@ -5757,12 +5811,12 @@ class Jo extends qe {
5757
5811
  * @returns
5758
5812
  */
5759
5813
  cleanStyle(t, e) {
5760
- const i = et, o = this.measureOptions.polygonLayerSpec?.source;
5814
+ const i = it, o = this.measureOptions.polygonLayerSpec?.source;
5761
5815
  o && i.push(o);
5762
5816
  const s = this.measureOptions.lineLayerLabelSpec?.source;
5763
5817
  s && i.push(s);
5764
5818
  const n = this.measureOptions.pointLayerLabelSpec?.source;
5765
- return n && i.push(n), $t(
5819
+ return n && i.push(n), Yt(
5766
5820
  t,
5767
5821
  e,
5768
5822
  i,
@@ -5845,7 +5899,7 @@ class Jo extends qe {
5845
5899
  * Handle finish event of terradraw. It will be called after finishing adding a feature
5846
5900
  * @param id Feature ID
5847
5901
  */
5848
- handleTerradrawFeatureReady = Ve((t) => {
5902
+ handleTerradrawFeatureReady = $e((t) => {
5849
5903
  this.map && (this.computeElevationByLineFeatureID(t), this.computeElevationByPointFeatureID(t));
5850
5904
  }, 300);
5851
5905
  /**
@@ -5944,11 +5998,13 @@ class Jo extends qe {
5944
5998
  (o) => o.properties?.originalId === t && o.geometry.type === "Point"
5945
5999
  );
5946
6000
  if (i && i.length > 0) {
5947
- const o = await Ie(
6001
+ const o = await xe(
5948
6002
  i,
5949
6003
  this.measureOptions.terrainSource,
5950
6004
  this.measureOptions.elevationCacheConfig,
5951
- this.elevationCache
6005
+ this.elevationCache,
6006
+ this.measureUnitType,
6007
+ this.measureUnitSymbols
5952
6008
  );
5953
6009
  this.replaceGeoJSONSource(
5954
6010
  o,
@@ -5971,11 +6027,13 @@ class Jo extends qe {
5971
6027
  (o) => o.id === t && o.geometry.type === "Point" && o.properties?.mode === "point"
5972
6028
  );
5973
6029
  if (i && i.length > 0) {
5974
- const o = await Ie(
6030
+ const o = await xe(
5975
6031
  i,
5976
6032
  this.measureOptions.terrainSource,
5977
6033
  this.measureOptions.elevationCacheConfig,
5978
- this.elevationCache
6034
+ this.elevationCache,
6035
+ this.measureUnitType,
6036
+ this.measureUnitSymbols
5979
6037
  );
5980
6038
  this.replaceGeoJSONSource(
5981
6039
  o,
@@ -5986,6 +6044,40 @@ class Jo extends qe {
5986
6044
  }
5987
6045
  }
5988
6046
  };
6047
+ /**
6048
+ * Recalculate elevation units for existing features without re-querying elevation data
6049
+ * This is called when measureUnitType changes to convert elevation values between metric and imperial
6050
+ */
6051
+ recalculateElevationUnits() {
6052
+ if (!this.map) return;
6053
+ const t = this.measureOptions.pointLayerLabelSpec.source;
6054
+ this.updateElevationUnitsInSource(t);
6055
+ const e = this.measureOptions.lineLayerLabelSpec.source;
6056
+ this.updateElevationUnitsInSource(e);
6057
+ }
6058
+ /**
6059
+ * Update elevation units in a specific GeoJSON source
6060
+ */
6061
+ updateElevationUnitsInSource(t) {
6062
+ if (!this.map) return;
6063
+ const e = this.map.getStyle().sources[t];
6064
+ if (e && typeof e.data != "string" && e.data.type === "FeatureCollection") {
6065
+ let i = !1;
6066
+ for (const o of e.data.features)
6067
+ if (o.properties?.elevation !== void 0) {
6068
+ const s = o.properties.elevationUnit;
6069
+ let n = o.properties.elevation;
6070
+ (s === "ft" || s === "foot") && (n = n / 3.28084);
6071
+ const { elevation: a, unit: l } = pt(
6072
+ n,
6073
+ this.measureUnitType,
6074
+ this.measureUnitSymbols
6075
+ );
6076
+ o.properties.elevation = a, o.properties.elevationUnit = l, i = !0;
6077
+ }
6078
+ i && this.map.getSource(t).setData(e.data);
6079
+ }
6080
+ }
5989
6081
  /**
5990
6082
  * measure polygon area for given feature ID
5991
6083
  * @param id terradraw feature id
@@ -6002,7 +6094,7 @@ class Jo extends qe {
6002
6094
  (a) => a.properties?.originalId !== t
6003
6095
  ));
6004
6096
  const n = JSON.parse(JSON.stringify(o));
6005
- n.id = n.id + "-area-label", n.geometry = Ao(o.geometry).geometry, n.properties.originalId = o.id, o = me(
6097
+ n.id = n.id + "-area-label", n.geometry = Ro(o.geometry).geometry, n.properties.originalId = o.id, o = ve(
6006
6098
  o,
6007
6099
  this.measureUnitType,
6008
6100
  this.areaPrecision,
@@ -6038,7 +6130,7 @@ class Jo extends qe {
6038
6130
  if (s) {
6039
6131
  typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter(
6040
6132
  (a) => a.properties?.originalId !== t
6041
- )), o = Ce(
6133
+ )), o = Pe(
6042
6134
  o,
6043
6135
  this.measureUnitType,
6044
6136
  this.distancePrecision,
@@ -6087,11 +6179,13 @@ class Jo extends qe {
6087
6179
  let o = e.getSnapshot()?.find((s) => s.id === t && s.geometry.type === "Point");
6088
6180
  if (o) {
6089
6181
  const s = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
6090
- s && (typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter((n) => n.id !== t)), o = Se(
6182
+ s && (typeof s.data != "string" && s.data.type === "FeatureCollection" && (s.data.features = s.data.features.filter((n) => n.id !== t)), o = Ie(
6091
6183
  o,
6092
6184
  this.map,
6093
6185
  this.computeElevation,
6094
- this.measureOptions.terrainSource
6186
+ this.measureOptions.terrainSource,
6187
+ this.measureUnitType,
6188
+ this.measureUnitSymbols
6095
6189
  ), this.computeElevation === !0 && typeof s.data != "string" && s.data.type === "FeatureCollection" && s.data.features.push(o), this.map.getSource(
6096
6190
  this.measureOptions.pointLayerLabelSpec.source
6097
6191
  )?.setData(s.data), this.map.getLayer(this.measureOptions.polygonLayerSpec.id) && this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && (this.map.moveLayer(
@@ -6132,7 +6226,7 @@ class Jo extends qe {
6132
6226
  const o = e.features[i];
6133
6227
  if (!this.map || !this.map.loaded()) continue;
6134
6228
  const s = o.geometry.type;
6135
- s === "LineString" ? e.features[i] = Ce(
6229
+ s === "LineString" ? e.features[i] = Pe(
6136
6230
  o,
6137
6231
  this.measureUnitType,
6138
6232
  this.distancePrecision,
@@ -6141,23 +6235,25 @@ class Jo extends qe {
6141
6235
  this.map,
6142
6236
  this.computeElevation,
6143
6237
  this.measureOptions.terrainSource
6144
- ) : s === "Polygon" ? e.features[i] = me(
6238
+ ) : s === "Polygon" ? e.features[i] = ve(
6145
6239
  o,
6146
6240
  this.measureUnitType,
6147
6241
  this.areaPrecision,
6148
6242
  this.forceAreaUnit,
6149
6243
  this.measureUnitSymbols
6150
- ) : s === "Point" && (e.features[i] = Se(
6244
+ ) : s === "Point" && (e.features[i] = Ie(
6151
6245
  o,
6152
6246
  this.map,
6153
6247
  this.computeElevation,
6154
- this.measureOptions.terrainSource
6248
+ this.measureOptions.terrainSource,
6249
+ this.measureUnitType,
6250
+ this.measureUnitSymbols
6155
6251
  ));
6156
6252
  }
6157
6253
  return e;
6158
6254
  }
6159
6255
  }
6160
- class Ho extends qe {
6256
+ class Zo extends Je {
6161
6257
  controlOptions;
6162
6258
  valhallaOptions;
6163
6259
  _modalDialog;
@@ -6353,16 +6449,16 @@ class Ho extends qe {
6353
6449
  * @returns
6354
6450
  */
6355
6451
  cleanStyle(t, e) {
6356
- const i = et, o = this.controlOptions.routingLineLayerNodeSpec?.source;
6452
+ const i = it, o = this.controlOptions.routingLineLayerNodeSpec?.source;
6357
6453
  o && i.push(o);
6358
6454
  const s = this.controlOptions.isochronePolygonLayerSpec?.source;
6359
- return s && i.push(s), $t(t, e, i, this.options.adapterOptions?.prefixId);
6455
+ return s && i.push(s), Yt(t, e, i, this.options.adapterOptions?.prefixId);
6360
6456
  }
6361
6457
  /**
6362
6458
  * Create the settings dialog for Valhalla control
6363
6459
  */
6364
6460
  createSettingsDialog() {
6365
- this.settingDialog = new vo(
6461
+ this.settingDialog = new Co(
6366
6462
  `maplibregl-terradraw-${this.cssPrefix}settings-dialog`,
6367
6463
  "Settings"
6368
6464
  ), this.settingDialog.create(
@@ -6404,7 +6500,7 @@ class Ho extends qe {
6404
6500
  const i = document.createElement("label");
6405
6501
  i.textContent = "Means of Transport", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
6406
6502
  this.settingDialog.createSegmentButtons(
6407
- Bt,
6503
+ jt,
6408
6504
  this.routingCostingModel,
6409
6505
  (n) => {
6410
6506
  this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.costingModel = n, this.dispatchEvent("setting-changed");
@@ -6416,7 +6512,7 @@ class Ho extends qe {
6416
6512
  const s = document.createElement("label");
6417
6513
  return s.textContent = "Distance Unit", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
6418
6514
  this.settingDialog.createSegmentButtons(
6419
- Bo,
6515
+ jo,
6420
6516
  this.routingDistanceUnit,
6421
6517
  (n) => {
6422
6518
  this.valhallaOptions.routingOptions || (this.valhallaOptions.routingOptions = {}), this.valhallaOptions.routingOptions.distanceUnit = n, this.dispatchEvent("setting-changed");
@@ -6433,7 +6529,7 @@ class Ho extends qe {
6433
6529
  const i = document.createElement("label");
6434
6530
  i.textContent = "Contour Type", i.classList.add("setting-label"), e.appendChild(i), e.appendChild(
6435
6531
  this.settingDialog.createSegmentButtons(
6436
- To,
6532
+ Wo,
6437
6533
  this.controlOptions.valhallaOptions?.isochroneOptions?.contourType || "time",
6438
6534
  (d) => {
6439
6535
  this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.contourType = d, this.dispatchEvent("setting-changed");
@@ -6445,7 +6541,7 @@ class Ho extends qe {
6445
6541
  const s = document.createElement("label");
6446
6542
  s.textContent = "Means of Transport", s.classList.add("setting-label"), o.appendChild(s), o.appendChild(
6447
6543
  this.settingDialog.createSegmentButtons(
6448
- Bt,
6544
+ jt,
6449
6545
  this.controlOptions.valhallaOptions?.isochroneOptions?.costingModel || "auto",
6450
6546
  (d) => {
6451
6547
  this.valhallaOptions.isochroneOptions || (this.valhallaOptions.isochroneOptions = {}), this.valhallaOptions.isochroneOptions.costingModel = d, this.dispatchEvent("setting-changed");
@@ -6483,8 +6579,8 @@ class Ho extends qe {
6483
6579
  const h = document.createElement("button");
6484
6580
  return h.type = "button", h.classList.add("add-row-button"), h.textContent = "Add Contour", h.hidden = c.length >= 4, h.addEventListener("click", (u) => {
6485
6581
  u.stopPropagation();
6486
- const p = this.valhallaOptions.isochroneOptions?.contours, g = JSON.parse(JSON.stringify(p[p.length - 1])), y = d.children.length, m = this.createContourRow(g, y);
6487
- d.appendChild(m), p.push(g), this.updateAddRowButtonState(), this.dispatchEvent("setting-changed");
6582
+ const p = this.valhallaOptions.isochroneOptions?.contours, g = JSON.parse(JSON.stringify(p[p.length - 1])), y = d.children.length, f = this.createContourRow(g, y);
6583
+ d.appendChild(f), p.push(g), this.updateAddRowButtonState(), this.dispatchEvent("setting-changed");
6488
6584
  }), t.appendChild(h), t;
6489
6585
  }
6490
6586
  /**
@@ -6517,8 +6613,8 @@ class Ho extends qe {
6517
6613
  const p = parseInt(i.getAttribute("data-index") || "0");
6518
6614
  i.remove(), this.valhallaOptions.isochroneOptions?.contours && this.valhallaOptions.isochroneOptions.contours.splice(p, 1);
6519
6615
  const g = i.parentElement;
6520
- g && Array.from(g.children).forEach((y, m) => {
6521
- y.setAttribute("data-index", m.toString());
6616
+ g && Array.from(g.children).forEach((y, f) => {
6617
+ y.setAttribute("data-index", f.toString());
6522
6618
  }), this.updateAddRowButtonState(), this.dispatchEvent("setting-changed");
6523
6619
  }), c.appendChild(h);
6524
6620
  }
@@ -6628,14 +6724,14 @@ class Ho extends qe {
6628
6724
  * Handle finish event of terradraw. It will be called after finishing adding a feature
6629
6725
  * @param id Feature ID
6630
6726
  */
6631
- handleTerradrawFeatureReady = Ve((t) => {
6727
+ handleTerradrawFeatureReady = $e((t) => {
6632
6728
  this.map && (this.computeRouteByLineFeatureID(t), this.computeIsochroneByPointFeatureID(t));
6633
6729
  }, 300);
6634
6730
  computeIsochroneByPointFeatureID = async (t) => {
6635
6731
  if (!this.map || !this.valhallaOptions.url) return;
6636
6732
  const e = this.terradraw?.getSnapshotFeature(t);
6637
6733
  if (!e || e && e.geometry.type !== "Point") return;
6638
- const i = e.geometry.coordinates, n = (await new Wo(this.valhallaUrl).calcIsochrone(
6734
+ const i = e.geometry.coordinates, n = (await new Bo(this.valhallaUrl).calcIsochrone(
6639
6735
  i[0],
6640
6736
  i[1],
6641
6737
  this.isochroneContourType,
@@ -6669,9 +6765,9 @@ class Ho extends qe {
6669
6765
  if (!this.map || !this.valhallaOptions.url) return;
6670
6766
  const e = this.terradraw?.getSnapshotFeature(t);
6671
6767
  if (!e || e && e.geometry.type !== "LineString") return;
6672
- const i = new jo(this.valhallaUrl), o = e.geometry.coordinates.map((c) => {
6768
+ const i = new Ao(this.valhallaUrl), o = e.geometry.coordinates.map((c) => {
6673
6769
  const h = c;
6674
- return new Je(h[0], h[1]);
6770
+ return new He(h[0], h[1]);
6675
6771
  });
6676
6772
  if (!o || o && o.length < 2) return;
6677
6773
  const s = await i.calcRoute(
@@ -6740,35 +6836,36 @@ class Ho extends qe {
6740
6836
  }
6741
6837
  }
6742
6838
  export {
6743
- $o as AvailableModes,
6744
- Yo as AvailableValhallaModes,
6745
- Jo as MaplibreMeasureControl,
6746
- qe as MaplibreTerradrawControl,
6747
- Ho as MaplibreValhallaControl,
6748
- $e as MemoryCache,
6749
- vo as ModalDialog,
6750
- Ko as TERRADRAW_MEASURE_SOURCE_IDS,
6751
- et as TERRADRAW_SOURCE_IDS,
6752
- Xo as TERRADRAW_VALHALLA_SOURCE_IDS,
6753
- Wo as ValhallaIsochrone,
6754
- jo as ValhallaRouting,
6755
- me as calcArea,
6756
- Ce as calcDistance,
6757
- Pe as capitalize,
6758
- $t as cleanMaplibreStyle,
6759
- To as contourTypeOptions,
6760
- yo as convertAreaUnit,
6761
- _t as convertDistance,
6762
- Bt as costingModelOptions,
6763
- Ve as debounce,
6764
- io as defaultControlOptions,
6765
- lt as defaultMeasureControlOptions,
6766
- bt as defaultMeasureUnitSymbols,
6839
+ Yo as AvailableModes,
6840
+ Ko as AvailableValhallaModes,
6841
+ Ho as MaplibreMeasureControl,
6842
+ Je as MaplibreTerradrawControl,
6843
+ Zo as MaplibreValhallaControl,
6844
+ Ye as MemoryCache,
6845
+ Co as ModalDialog,
6846
+ Xo as TERRADRAW_MEASURE_SOURCE_IDS,
6847
+ it as TERRADRAW_SOURCE_IDS,
6848
+ qo as TERRADRAW_VALHALLA_SOURCE_IDS,
6849
+ Bo as ValhallaIsochrone,
6850
+ Ao as ValhallaRouting,
6851
+ ve as calcArea,
6852
+ Pe as calcDistance,
6853
+ Se as capitalize,
6854
+ Yt as cleanMaplibreStyle,
6855
+ Wo as contourTypeOptions,
6856
+ fo as convertArea,
6857
+ kt as convertDistance,
6858
+ pt as convertElevation,
6859
+ jt as costingModelOptions,
6860
+ $e as debounce,
6861
+ oo as defaultControlOptions,
6862
+ dt as defaultMeasureControlOptions,
6863
+ J as defaultMeasureUnitSymbols,
6767
6864
  z as defaultValhallaControlOptions,
6768
- oo as getDefaultModeOptions,
6769
- Se as queryElevationByPoint,
6770
- Ie as queryElevationFromRasterDEM,
6771
- qo as roundFeatureCoordinates,
6772
- Bo as routingDistanceUnitOptions
6865
+ so as getDefaultModeOptions,
6866
+ Ie as queryElevationByPoint,
6867
+ xe as queryElevationFromRasterDEM,
6868
+ Jo as roundFeatureCoordinates,
6869
+ jo as routingDistanceUnitOptions
6773
6870
  };
6774
6871
  //# sourceMappingURL=maplibre-gl-terradraw.es.js.map