@watergis/maplibre-gl-terradraw 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/maplibre-gl-terradraw.es.js +1490 -1494
  2. package/dist/maplibre-gl-terradraw.es.js.map +1 -1
  3. package/dist/maplibre-gl-terradraw.umd.js +2 -2
  4. package/dist/maplibre-gl-terradraw.umd.js.map +1 -1
  5. package/dist/types/controls/MaplibreMeasureControl.d.ts +0 -6
  6. package/dist/types/controls/MaplibreMeasureControl.d.ts.map +1 -1
  7. package/dist/types/helpers/calcArea.d.ts +4 -0
  8. package/dist/types/helpers/calcArea.d.ts.map +1 -0
  9. package/dist/types/helpers/calcDistance.d.ts +5 -0
  10. package/dist/types/helpers/calcDistance.d.ts.map +1 -0
  11. package/dist/types/helpers/convertAreaUnit.d.ts +6 -0
  12. package/dist/types/helpers/convertAreaUnit.d.ts.map +1 -0
  13. package/dist/types/helpers/getDistanceUnitName.d.ts +3 -0
  14. package/dist/types/helpers/getDistanceUnitName.d.ts.map +1 -0
  15. package/dist/types/helpers/index.d.ts +6 -0
  16. package/dist/types/helpers/index.d.ts.map +1 -1
  17. package/dist/types/helpers/queryElevationByPoint.d.ts +5 -0
  18. package/dist/types/helpers/queryElevationByPoint.d.ts.map +1 -0
  19. package/dist/types/helpers/queryElevationFromRasterDEM.d.ts +4 -0
  20. package/dist/types/helpers/queryElevationFromRasterDEM.d.ts.map +1 -0
  21. package/dist/types/interfaces/MeasureControlOptions.d.ts +2 -8
  22. package/dist/types/interfaces/MeasureControlOptions.d.ts.map +1 -1
  23. package/dist/types/interfaces/TerrainSource.d.ts +9 -0
  24. package/dist/types/interfaces/TerrainSource.d.ts.map +1 -0
  25. package/dist/types/interfaces/index.d.ts +4 -3
  26. package/dist/types/interfaces/index.d.ts.map +1 -1
  27. package/package.json +10 -10
@@ -1,33 +1,33 @@
1
- var Be = Object.defineProperty;
2
- var je = (r, t, e) => t in r ? Be(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var _ = (r, t, e) => je(r, typeof t != "symbol" ? t + "" : t, e);
1
+ var Ge = Object.defineProperty;
2
+ var Te = (s, t, e) => t in s ? Ge(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var k = (s, t, e) => Te(s, typeof t != "symbol" ? t + "" : t, e);
4
4
  import "maplibre-gl";
5
- function I() {
6
- return I = Object.assign ? Object.assign.bind() : function(r) {
5
+ function b() {
6
+ return b = Object.assign ? Object.assign.bind() : function(s) {
7
7
  for (var t = 1; t < arguments.length; t++) {
8
8
  var e = arguments[t];
9
- for (var i in e) ({}).hasOwnProperty.call(e, i) && (r[i] = e[i]);
9
+ for (var i in e) ({}).hasOwnProperty.call(e, i) && (s[i] = e[i]);
10
10
  }
11
- return r;
12
- }, I.apply(null, arguments);
11
+ return s;
12
+ }, b.apply(null, arguments);
13
13
  }
14
14
  var M;
15
- (function(r) {
16
- r.Commit = "commit", r.Provisional = "provisional", r.Finish = "finish";
15
+ (function(s) {
16
+ s.Commit = "commit", s.Provisional = "provisional", s.Finish = "finish";
17
17
  })(M || (M = {}));
18
18
  const V = { SELECTED: "selected", MID_POINT: "midPoint", SELECTION_POINT: "selectionPoint" }, J = "edited", st = "closingPoint", Ot = "snappingPoint";
19
- function It(r) {
20
- return !!(r && typeof r == "object" && r !== null && !Array.isArray(r));
19
+ function bt(s) {
20
+ return !!(s && typeof s == "object" && s !== null && !Array.isArray(s));
21
21
  }
22
- function Tt(r) {
22
+ function Gt(s) {
23
23
  return !!function(t) {
24
24
  return typeof t == "number" && !isNaN(new Date(t).valueOf());
25
- }(r);
25
+ }(s);
26
26
  }
27
- const Ne = "Feature mode property does not match the mode being added to";
27
+ const Ve = "Feature mode property does not match the mode being added to";
28
28
  var Y;
29
- (function(r) {
30
- r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
29
+ (function(s) {
30
+ s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
31
31
  })(Y || (Y = {}));
32
32
  class N {
33
33
  get state() {
@@ -46,7 +46,7 @@ class N {
46
46
  registerBehaviors(t) {
47
47
  }
48
48
  constructor(t) {
49
- this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = Y.Drawing, this.mode = "base", this._state = "unregistered", this._styles = t && t.styles ? I({}, t.styles) : {}, this.pointerDistance = t && t.pointerDistance || 40, this.validate = t && t.validation, this.projection = t && t.projection || "web-mercator";
49
+ this._state = void 0, this._styles = void 0, this.behaviors = [], this.validate = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.onStyleChange = void 0, this.store = void 0, this.setDoubleClickToZoom = void 0, this.unproject = void 0, this.project = void 0, this.setCursor = void 0, this.projection = void 0, this.type = Y.Drawing, this.mode = "base", this._state = "unregistered", this._styles = t && t.styles ? b({}, t.styles) : {}, this.pointerDistance = t && t.pointerDistance || 40, this.validate = t && t.validation, this.projection = t && t.projection || "web-mercator";
50
50
  }
51
51
  setDrawing() {
52
52
  if (this._state !== "started") throw new Error("Mode must be unregistered or stopped to start");
@@ -70,18 +70,18 @@ class N {
70
70
  performFeatureValidation(t) {
71
71
  if (this._state === "unregistered") throw new Error("Mode must be registered");
72
72
  const e = function(i, o) {
73
- let s;
74
- if (It(i)) if (i.id == null) s = "Feature has no id";
75
- else if (typeof i.id != "string" && typeof i.id != "number") s = "Feature must be string or number as per GeoJSON spec";
76
- else if (o(i.id)) if (It(i.geometry)) if (It(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
73
+ let r;
74
+ if (bt(i)) if (i.id == null) r = "Feature has no id";
75
+ else if (typeof i.id != "string" && typeof i.id != "number") r = "Feature must be string or number as per GeoJSON spec";
76
+ else if (o(i.id)) if (bt(i.geometry)) if (bt(i.properties)) if (typeof i.geometry.type == "string" && ["Polygon", "LineString", "Point"].includes(i.geometry.type)) if (Array.isArray(i.geometry.coordinates)) {
77
77
  if (!i.properties.mode || typeof i.properties.mode != "string") return { valid: !1, reason: "Feature does not have a valid mode property" };
78
- } else s = "Feature coordinates is not an array";
79
- else s = "Feature is not Point, LineString or Polygon";
80
- else s = "Feature has no properties";
81
- else s = "Feature has no geometry";
82
- else s = "Feature must match the id strategy (default is UUID4)";
83
- else s = "Feature is not object";
84
- return s ? { valid: !1, reason: s } : { valid: !0 };
78
+ } else r = "Feature coordinates is not an array";
79
+ else r = "Feature is not Point, LineString or Polygon";
80
+ else r = "Feature has no properties";
81
+ else r = "Feature has no geometry";
82
+ else r = "Feature must match the id strategy (default is UUID4)";
83
+ else r = "Feature is not object";
84
+ return r ? { valid: !1, reason: r } : { valid: !0 };
85
85
  }(t, this.store.idStrategy.isValidId);
86
86
  if (this.validate) {
87
87
  const i = this.validate(t, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional });
@@ -91,7 +91,7 @@ class N {
91
91
  }
92
92
  validateModeFeature(t, e) {
93
93
  const i = this.performFeatureValidation(t);
94
- return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Ne } : e(t) : { valid: !1, reason: i.reason };
94
+ return i.valid ? t.properties.mode !== this.mode ? { valid: !1, reason: Ve } : e(t) : { valid: !1, reason: i.reason };
95
95
  }
96
96
  onFinish(t, e) {
97
97
  }
@@ -123,96 +123,96 @@ class N {
123
123
  return t === void 0 ? e : typeof t == "function" ? t(i) : t;
124
124
  }
125
125
  }
126
- class Ae extends N {
126
+ class Ue extends N {
127
127
  constructor(...t) {
128
128
  super(...t), this.type = Y.Select;
129
129
  }
130
130
  }
131
- function G(r, t) {
132
- 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);
131
+ function T(s, t) {
132
+ const e = (d) => d * Math.PI / 180, i = e(s[1]), o = e(s[0]), r = e(t[1]), n = r - i, a = e(t[0]) - o, l = Math.sin(n / 2) * Math.sin(n / 2) + Math.cos(i) * Math.cos(r) * Math.sin(a / 2) * Math.sin(a / 2);
133
133
  return 2 * Math.atan2(Math.sqrt(l), Math.sqrt(1 - l)) * 6371e3 / 1e3;
134
134
  }
135
- const le = 63710088e-1;
136
- function E(r) {
137
- return r % 360 * Math.PI / 180;
135
+ const ue = 63710088e-1;
136
+ function E(s) {
137
+ return s % 360 * Math.PI / 180;
138
138
  }
139
- function de(r) {
140
- return r / 6371.0088;
139
+ function pe(s) {
140
+ return s / 6371.0088;
141
141
  }
142
- function U(r) {
143
- return r % (2 * Math.PI) * 180 / Math.PI;
142
+ function U(s) {
143
+ return s % (2 * Math.PI) * 180 / Math.PI;
144
144
  }
145
- function F(r, t = 9) {
145
+ function F(s, t = 9) {
146
146
  const e = Math.pow(10, t);
147
- return Math.round(r * e) / e;
147
+ return Math.round(s * e) / e;
148
148
  }
149
- const Gt = 57.29577951308232, Vt = 0.017453292519943295, pt = 6378137, x = (r, t) => ({ x: r === 0 ? 0 : r * Vt * pt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Vt / 2)) * pt }), W = (r, t) => ({ lng: r === 0 ? 0 : Gt * (r / pt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / pt)) - Math.PI / 2) * Gt });
150
- function Te(r, t, e) {
151
- const i = E(r[0]), o = E(r[1]), s = E(e), n = de(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
152
- return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
149
+ const Tt = 57.29577951308232, Vt = 0.017453292519943295, pt = 6378137, x = (s, t) => ({ x: s === 0 ? 0 : s * Vt * pt, y: t === 0 ? 0 : Math.log(Math.tan(Math.PI / 4 + t * Vt / 2)) * pt }), W = (s, t) => ({ lng: s === 0 ? 0 : Tt * (s / pt), lat: t === 0 ? 0 : (2 * Math.atan(Math.exp(t / pt)) - Math.PI / 2) * Tt });
150
+ function ze(s, t, e) {
151
+ const i = E(s[0]), o = E(s[1]), r = E(e), n = pe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
152
+ return [U(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
153
153
  }
154
- function Ut(r) {
155
- const { center: t, radiusKilometers: e, coordinatePrecision: i } = r, o = r.steps ? r.steps : 64, s = [];
154
+ function Ut(s) {
155
+ const { center: t, radiusKilometers: e, coordinatePrecision: i } = s, o = s.steps ? s.steps : 64, r = [];
156
156
  for (let n = 0; n < o; n++) {
157
- const a = Te(t, e, -360 * n / o);
158
- s.push([F(a[0], i), F(a[1], i)]);
157
+ const a = ze(t, e, -360 * n / o);
158
+ r.push([F(a[0], i), F(a[1], i)]);
159
159
  }
160
- return s.push(s[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [s] }, properties: {} };
160
+ return r.push(r[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [r] }, properties: {} };
161
161
  }
162
- function Dt(r) {
162
+ function Dt(s) {
163
163
  let t;
164
- if (r.geometry.type === "Polygon") t = r.geometry.coordinates;
164
+ if (s.geometry.type === "Polygon") t = s.geometry.coordinates;
165
165
  else {
166
- if (r.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
167
- t = [r.geometry.coordinates];
166
+ if (s.geometry.type !== "LineString") throw new Error("Self intersects only accepts Polygons and LineStrings");
167
+ t = [s.geometry.coordinates];
168
168
  }
169
169
  const e = [];
170
- for (let s = 0; s < t.length; s++) for (let n = 0; n < t[s].length - 1; n++) for (let a = 0; a < t.length; a++) for (let l = 0; l < t[a].length - 1; l++) o(s, n, a, l);
170
+ for (let r = 0; r < t.length; r++) for (let n = 0; n < t[r].length - 1; n++) for (let a = 0; a < t.length; a++) for (let l = 0; l < t[a].length - 1; l++) o(r, n, a, l);
171
171
  return e.length > 0;
172
- function i(s) {
173
- return s < 0 || s > 1;
172
+ function i(r) {
173
+ return r < 0 || r > 1;
174
174
  }
175
- function o(s, n, a, l) {
176
- const d = t[s][n], c = t[s][n + 1], h = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
175
+ function o(r, n, a, l) {
176
+ const d = t[r][n], c = t[r][n + 1], h = t[a][l], u = t[a][l + 1], p = function(v, f, m, C) {
177
177
  if (at(v, m) || at(v, C) || at(f, m) || at(C, m)) return null;
178
- const P = v[0], S = v[1], b = f[0], w = f[1], D = m[0], A = m[1], L = C[0], j = C[1], z = (P - b) * (A - j) - (S - w) * (D - L);
179
- return z === 0 ? null : [((P * w - S * b) * (D - L) - (P - b) * (D * j - A * L)) / z, ((P * w - S * b) * (A - j) - (S - w) * (D * j - A * L)) / z];
178
+ const P = v[0], S = v[1], I = f[0], w = f[1], D = m[0], A = m[1], L = C[0], B = C[1], z = (P - I) * (A - B) - (S - w) * (D - L);
179
+ return z === 0 ? null : [((P * w - S * I) * (D - L) - (P - I) * (D * B - A * L)) / z, ((P * w - S * I) * (A - B) - (S - w) * (D * B - A * L)) / z];
180
180
  }(d, c, h, u);
181
181
  if (p === null) return;
182
182
  let g, y;
183
183
  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));
184
184
  }
185
185
  }
186
- function at(r, t) {
187
- return r[0] === t[0] && r[1] === t[1];
186
+ function at(s, t) {
187
+ return s[0] === t[0] && s[1] === t[1];
188
188
  }
189
- function vt(r, t) {
190
- return r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number" && r[0] !== 1 / 0 && r[1] !== 1 / 0 && (i = r[0]) >= -180 && i <= 180 && (e = r[1]) >= -90 && e <= 90 && zt(r[0]) <= t && zt(r[1]) <= t;
189
+ function vt(s, t) {
190
+ return s.length === 2 && typeof s[0] == "number" && typeof s[1] == "number" && s[0] !== 1 / 0 && s[1] !== 1 / 0 && (i = s[0]) >= -180 && i <= 180 && (e = s[1]) >= -90 && e <= 90 && zt(s[0]) <= t && zt(s[1]) <= t;
191
191
  var e, i;
192
192
  }
193
- function zt(r) {
193
+ function zt(s) {
194
194
  let t = 1, e = 0;
195
- for (; Math.round(r * t) / t !== r; ) t *= 10, e++;
195
+ for (; Math.round(s * t) / t !== s; ) t *= 10, e++;
196
196
  return e;
197
197
  }
198
- const Ge = "Feature has holes", Ve = "Feature has less than 4 coordinates", Ue = "Feature has invalid coordinates", ze = "Feature coordinates are not closed";
199
- function Ct(r, t) {
200
- return r.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : r.geometry.coordinates.length !== 1 ? { valid: !1, reason: Ge } : r.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Ve } : r.geometry.coordinates[0].every((o) => vt(o, t)) ? (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: ze } : { valid: !0 } : { valid: !1, reason: Ue };
198
+ const Re = "Feature has holes", Xe = "Feature has less than 4 coordinates", Ke = "Feature has invalid coordinates", Ye = "Feature coordinates are not closed";
199
+ function Ct(s, t) {
200
+ return s.geometry.type !== "Polygon" ? { valid: !1, reason: "Feature is not a Polygon" } : s.geometry.coordinates.length !== 1 ? { valid: !1, reason: Re } : s.geometry.coordinates[0].length < 4 ? { valid: !1, reason: Xe } : s.geometry.coordinates[0].every((o) => vt(o, t)) ? (e = s.geometry.coordinates[0][0])[0] !== (i = s.geometry.coordinates[0][s.geometry.coordinates[0].length - 1])[0] || e[1] !== i[1] ? { valid: !1, reason: Ye } : { valid: !0 } : { valid: !1, reason: Ke };
201
201
  var e, i;
202
202
  }
203
- function nt(r, t) {
204
- const e = Ct(r, t);
205
- return e.valid ? Dt(r) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
203
+ function nt(s, t) {
204
+ const e = Ct(s, t);
205
+ return e.valid ? Dt(s) ? { valid: !1, reason: "Feature intersects itself" } : { valid: !0 } : e;
206
206
  }
207
- class ce extends N {
207
+ class ge extends N {
208
208
  constructor(t) {
209
209
  var e;
210
210
  super(t), this.mode = "circle", this.center = void 0, this.clickCount = 0, this.currentCircleId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.startingRadiusKilometers = 1e-5, this.cursorMovedAfterInitialCursorDown = !1;
211
211
  const i = { start: "crosshair" };
212
- if (this.cursors = t && t.cursors ? I({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
212
+ if (this.cursors = t && t.cursors ? b({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
213
213
  else {
214
214
  const o = { cancel: "Escape", finish: "Enter" };
215
- this.keyEvents = t && t.keyEvents ? I({}, o, t.keyEvents) : o;
215
+ this.keyEvents = t && t.keyEvents ? b({}, o, t.keyEvents) : o;
216
216
  }
217
217
  this.startingRadiusKilometers = (e = t == null ? void 0 : t.startingRadiusKilometers) != null ? e : 1e-5, this.validate = t == null ? void 0 : t.validation;
218
218
  }
@@ -261,7 +261,7 @@ class ce extends N {
261
261
  }
262
262
  }
263
263
  styleFeature(t) {
264
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
264
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
265
265
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
266
266
  }
267
267
  validateFeature(t) {
@@ -269,20 +269,20 @@ class ce extends N {
269
269
  }
270
270
  updateCircle(t) {
271
271
  if (this.clickCount === 1 && this.center && this.currentCircleId) {
272
- const e = G(this.center, [t.lng, t.lat]);
272
+ const e = T(this.center, [t.lng, t.lat]);
273
273
  let i;
274
274
  if (this.projection === "web-mercator") {
275
- const o = function(s, n) {
276
- const a = 1e3 * G(s, n);
275
+ const o = function(r, n) {
276
+ const a = 1e3 * T(r, n);
277
277
  if (a === 0) return 1;
278
- const { x: l, y: d } = x(s[0], s[1]), { x: c, y: h } = x(n[0], n[1]);
278
+ const { x: l, y: d } = x(r[0], r[1]), { x: c, y: h } = x(n[0], n[1]);
279
279
  return Math.sqrt(Math.pow(c - l, 2) + Math.pow(h - d, 2)) / a;
280
280
  }(this.center, [t.lng, t.lat]);
281
- i = function(s) {
282
- const { center: n, radiusKilometers: a, coordinatePrecision: l } = s, d = s.steps ? s.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = x(h, u), y = [];
281
+ i = function(r) {
282
+ const { center: n, radiusKilometers: a, coordinatePrecision: l } = r, d = r.steps ? r.steps : 64, c = 1e3 * a, [h, u] = n, { x: p, y: g } = x(h, u), y = [];
283
283
  for (let v = 0; v < d; v++) {
284
- const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, S] = [p + m, g + C], { lng: b, lat: w } = W(P, S);
285
- y.push([F(b, l), F(w, l)]);
284
+ const f = 360 * v / d * Math.PI / 180, m = c * Math.cos(f), C = c * Math.sin(f), [P, S] = [p + m, g + C], { lng: I, lat: w } = W(P, S);
285
+ y.push([F(I, l), F(w, l)]);
286
286
  }
287
287
  return y.push(y[0]), { type: "Feature", geometry: { type: "Polygon", coordinates: [y] }, properties: {} };
288
288
  }({ center: this.center, radiusKilometers: e * o, coordinatePrecision: this.coordinatePrecision });
@@ -295,19 +295,19 @@ class ce extends N {
295
295
  }
296
296
  }
297
297
  }
298
- const O = (r, t) => {
299
- const { x: e, y: i } = r, { x: o, y: s } = t, n = o - e, a = s - i;
298
+ const O = (s, t) => {
299
+ const { x: e, y: i } = s, { x: o, y: r } = t, n = o - e, a = r - i;
300
300
  return Math.sqrt(a * a + n * n);
301
301
  };
302
- let he = class extends N {
302
+ let ye = class extends N {
303
303
  constructor(t) {
304
304
  super(t), this.mode = "freehand", this.startingClick = !1, this.currentId = void 0, this.closingPointId = void 0, this.minDistance = void 0, this.keyEvents = void 0, this.cursors = void 0, this.preventPointsNearClose = void 0, this.autoClose = void 0, this.autoCloseTimeout = 500, this.hasLeftStartingPoint = !1, this.preventNewFeature = !1;
305
305
  const e = { start: "crosshair", close: "pointer" };
306
- if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.preventPointsNearClose = t && t.preventPointsNearClose || !0, t && t.autoCloseTimeout && !t.autoClose) throw new Error("autoCloseTimeout is set, but autoClose is not enabled");
306
+ if (this.cursors = t && t.cursors ? b({}, e, t.cursors) : e, this.preventPointsNearClose = t && t.preventPointsNearClose || !0, t && t.autoCloseTimeout && !t.autoClose) throw new Error("autoCloseTimeout is set, but autoClose is not enabled");
307
307
  if (this.autoClose = t && t.autoClose || !1, this.autoCloseTimeout = t && t.autoCloseTimeout || 500, this.minDistance = t && t.minDistance || 20, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
308
308
  else {
309
309
  const i = { cancel: "Escape", finish: "Enter" };
310
- this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
310
+ this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
311
311
  }
312
312
  this.validate = t == null ? void 0 : t.validation;
313
313
  }
@@ -328,7 +328,7 @@ let he = class extends N {
328
328
  }
329
329
  onMouseMove(t) {
330
330
  if (this.currentId === void 0 || this.startingClick === !1) return;
331
- const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, s] = e.coordinates[0][i], { x: n, y: a } = this.project(o, s), l = O({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
331
+ const e = this.store.getGeometryCopy(this.currentId), i = e.coordinates[0].length - 2, [o, r] = e.coordinates[0][i], { x: n, y: a } = this.project(o, r), l = O({ x: n, y: a }, { x: t.containerX, y: t.containerY }), [d, c] = e.coordinates[0][0], { x: h, y: u } = this.project(d, c);
332
332
  if (O({ x: h, y: u }, { x: t.containerX, y: t.containerY }) < this.pointerDistance) {
333
333
  if (this.autoClose && this.hasLeftStartingPoint && (this.preventNewFeature = !0, setTimeout(() => {
334
334
  this.preventNewFeature = !1;
@@ -368,31 +368,31 @@ let he = class extends N {
368
368
  }
369
369
  }
370
370
  styleFeature(t) {
371
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
371
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
372
372
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e) : (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 = 40), e);
373
373
  }
374
374
  validateFeature(t) {
375
375
  return this.validateModeFeature(t, (e) => Ct(e, this.coordinatePrecision));
376
376
  }
377
- }, B = class {
378
- constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: s, coordinatePrecision: n, projection: a }) {
379
- 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;
377
+ }, j = class {
378
+ constructor({ store: t, mode: e, project: i, unproject: o, pointerDistance: r, coordinatePrecision: n, projection: a }) {
379
+ this.store = void 0, this.mode = void 0, this.project = void 0, this.unproject = void 0, this.pointerDistance = void 0, this.coordinatePrecision = void 0, this.projection = void 0, this.store = t, this.mode = e, this.project = i, this.unproject = o, this.pointerDistance = r, this.coordinatePrecision = n, this.projection = a;
380
380
  }
381
381
  };
382
- function ue({ unproject: r, point: t, pointerDistance: e }) {
383
- const i = e / 2, { x: o, y: s } = t;
384
- 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])] } };
382
+ function fe({ unproject: s, point: t, pointerDistance: e }) {
383
+ const i = e / 2, { x: o, y: r } = t;
384
+ return { type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [[s(o - i, r - i), s(o + i, r - i), s(o + i, r + i), s(o - i, r + i), s(o - i, r - i)].map((n) => [n.lng, n.lat])] } };
385
385
  }
386
- let Pt = class extends B {
386
+ let Pt = class extends j {
387
387
  constructor(t) {
388
388
  super(t);
389
389
  }
390
390
  create(t) {
391
391
  const { containerX: e, containerY: i } = t;
392
- return ue({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
392
+ return fe({ unproject: this.unproject, point: { x: e, y: i }, pointerDistance: this.pointerDistance });
393
393
  }
394
394
  };
395
- class St extends B {
395
+ class St extends j {
396
396
  constructor(t) {
397
397
  super(t);
398
398
  }
@@ -401,12 +401,12 @@ class St extends B {
401
401
  return O({ x: i, y: o }, { x: t.containerX, y: t.containerY });
402
402
  }
403
403
  }
404
- class pe extends B {
404
+ class me extends j {
405
405
  constructor(t, e, i) {
406
- 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;
406
+ super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
407
407
  }
408
408
  getSnappable(t, e) {
409
- const i = this.clickBoundingBox.create(t), o = this.store.search(i, e), s = { featureId: void 0, featureCoordinateIndex: void 0, coordinate: void 0, minDist: 1 / 0 };
409
+ const i = this.clickBoundingBox.create(t), o = this.store.search(i, e), r = { featureId: void 0, featureCoordinateIndex: void 0, coordinate: void 0, minDist: 1 / 0 };
410
410
  return o.forEach((n) => {
411
411
  let a;
412
412
  if (n.geometry.type === "Polygon") a = n.geometry.coordinates[0];
@@ -416,66 +416,66 @@ class pe extends B {
416
416
  }
417
417
  a.forEach((l, d) => {
418
418
  const c = this.pixelDistance.measure(t, l);
419
- c < s.minDist && c < this.pointerDistance && (s.coordinate = l, s.minDist = c, s.featureId = n.id, s.featureCoordinateIndex = d);
419
+ c < r.minDist && c < this.pointerDistance && (r.coordinate = l, r.minDist = c, r.featureId = n.id, r.featureCoordinateIndex = d);
420
420
  });
421
- }), s;
421
+ }), r;
422
422
  }
423
423
  }
424
- function Rt(r, t, e) {
425
- const i = E(r[0]), o = E(r[1]), s = E(e), n = de(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(s));
426
- return [U(i + Math.atan2(Math.sin(s) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
424
+ function Rt(s, t, e) {
425
+ const i = E(s[0]), o = E(s[1]), r = E(e), n = pe(t), a = Math.asin(Math.sin(o) * Math.cos(n) + Math.cos(o) * Math.sin(n) * Math.cos(r));
426
+ return [U(i + Math.atan2(Math.sin(r) * Math.sin(n) * Math.cos(o), Math.cos(n) - Math.sin(o) * Math.sin(a))), U(a)];
427
427
  }
428
- function rt({ x: r, y: t }, e, i) {
428
+ function rt({ x: s, y: t }, e, i) {
429
429
  const o = E(i);
430
- return { x: r + e * Math.cos(o), y: t + e * Math.sin(o) };
430
+ return { x: s + e * Math.cos(o), y: t + e * Math.sin(o) };
431
431
  }
432
- function Xt(r, t) {
433
- const e = E(r[0]), i = E(t[0]), o = E(r[1]), s = E(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);
432
+ function Xt(s, t) {
433
+ const e = E(s[0]), i = E(t[0]), o = E(s[1]), r = E(t[1]), n = Math.sin(i - e) * Math.cos(r), a = Math.cos(o) * Math.sin(r) - Math.sin(o) * Math.cos(r) * Math.cos(i - e);
434
434
  return U(Math.atan2(n, a));
435
435
  }
436
- function T({ x: r, y: t }, { x: e, y: i }) {
437
- let o = Math.atan2(i - t, e - r);
436
+ function G({ x: s, y: t }, { x: e, y: i }) {
437
+ let o = Math.atan2(i - t, e - s);
438
438
  return o *= 180 / Math.PI, o > 180 ? o -= 360 : o < -180 && (o += 360), o;
439
439
  }
440
- function K(r) {
441
- return (r + 360) % 360;
440
+ function K(s) {
441
+ return (s + 360) % 360;
442
442
  }
443
- function Re(r, t, e) {
444
- const i = [], o = r.length;
445
- let s, n, a, l = 0;
446
- for (let c = 0; c < r.length && !(t >= l && c === r.length - 1); c++) {
443
+ function $e(s, t, e) {
444
+ const i = [], o = s.length;
445
+ let r, n, a, l = 0;
446
+ for (let c = 0; c < s.length && !(t >= l && c === s.length - 1); c++) {
447
447
  if (l > t && i.length === 0) {
448
- if (s = t - l, !s) return i.push(r[c]), i;
449
- n = Xt(r[c], r[c - 1]) - 180, a = Rt(r[c], s, n), i.push(a);
448
+ if (r = t - l, !r) return i.push(s[c]), i;
449
+ n = Xt(s[c], s[c - 1]) - 180, a = Rt(s[c], r, n), i.push(a);
450
450
  }
451
- if (l >= e) return s = e - l, s ? (n = Xt(r[c], r[c - 1]) - 180, a = Rt(r[c], s, n), i.push(a), i) : (i.push(r[c]), i);
452
- if (l >= t && i.push(r[c]), c === r.length - 1) return i;
453
- l += G(r[c], r[c + 1]);
451
+ if (l >= e) return r = e - l, r ? (n = Xt(s[c], s[c - 1]) - 180, a = Rt(s[c], r, n), i.push(a), i) : (i.push(s[c]), i);
452
+ if (l >= t && i.push(s[c]), c === s.length - 1) return i;
453
+ l += T(s[c], s[c + 1]);
454
454
  }
455
- if (l < t && r.length === o) throw new Error("Start position is beyond line");
456
- const d = r[r.length - 1];
455
+ if (l < t && s.length === o) throw new Error("Start position is beyond line");
456
+ const d = s[s.length - 1];
457
457
  return [d, d];
458
458
  }
459
- function lt(r) {
460
- return r * (Math.PI / 180);
459
+ function lt(s) {
460
+ return s * (Math.PI / 180);
461
461
  }
462
- function Kt(r) {
463
- return r * (180 / Math.PI);
462
+ function Kt(s) {
463
+ return s * (180 / Math.PI);
464
464
  }
465
- class Xe extends B {
465
+ class He extends j {
466
466
  constructor(t) {
467
467
  super(t), this.config = void 0, this.config = t;
468
468
  }
469
469
  generateInsertionCoordinates(t, e, i) {
470
470
  const o = [t, e];
471
- let s = 0;
472
- for (let d = 0; d < o.length - 1; d++) s += G(o[0], o[1]);
473
- if (s <= i) return o;
474
- let n = s / i - 1;
471
+ let r = 0;
472
+ for (let d = 0; d < o.length - 1; d++) r += T(o[0], o[1]);
473
+ if (r <= i) return o;
474
+ let n = r / i - 1;
475
475
  Number.isInteger(n) || (n = Math.floor(n) + 1);
476
476
  const a = [];
477
477
  for (let d = 0; d < n; d++) {
478
- const c = Re(o, i * d, i * (d + 1));
478
+ const c = $e(o, i * d, i * (d + 1));
479
479
  a.push(c);
480
480
  }
481
481
  const l = [];
@@ -483,7 +483,7 @@ class Xe extends B {
483
483
  return this.limitCoordinates(l);
484
484
  }
485
485
  generateInsertionGeodesicCoordinates(t, e, i) {
486
- const o = G(t, e), s = function(n, a, l) {
486
+ const o = T(t, e), r = function(n, a, l) {
487
487
  const d = [], c = lt(n[1]), h = lt(n[0]), u = lt(a[1]), p = lt(a[0]);
488
488
  l += 1;
489
489
  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));
@@ -491,31 +491,31 @@ class Xe extends B {
491
491
  for (let y = 0; y <= l; y++) {
492
492
  const v = y / l, f = Math.sin((1 - v) * g) / Math.sin(g), m = Math.sin(v * g) / Math.sin(g), C = f * Math.cos(c) * Math.cos(h) + m * Math.cos(u) * Math.cos(p), P = f * Math.cos(c) * Math.sin(h) + m * Math.cos(u) * Math.sin(p), S = f * Math.sin(c) + m * Math.sin(u);
493
493
  if (isNaN(C) || isNaN(P) || isNaN(S)) continue;
494
- const b = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), w = Math.atan2(P, C);
495
- isNaN(b) || isNaN(w) || d.push([Kt(w), Kt(b)]);
494
+ const I = Math.atan2(S, Math.sqrt(C ** 2 + P ** 2)), w = Math.atan2(P, C);
495
+ isNaN(I) || isNaN(w) || d.push([Kt(w), Kt(I)]);
496
496
  }
497
497
  return d.slice(1, -1);
498
498
  }(t, e, Math.floor(o / i));
499
- return this.limitCoordinates(s);
499
+ return this.limitCoordinates(r);
500
500
  }
501
501
  limitCoordinates(t) {
502
502
  return t.map((e) => [F(e[0], this.config.coordinatePrecision), F(e[1], this.config.coordinatePrecision)]);
503
503
  }
504
504
  }
505
- function Z(r, t) {
506
- return r[0] === t[0] && r[1] === t[1];
505
+ function Z(s, t) {
506
+ return s[0] === t[0] && s[1] === t[1];
507
507
  }
508
- function ge(r, t) {
509
- return r.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : r.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : r.geometry.coordinates.every((e) => vt(e, t)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
508
+ function ve(s, t) {
509
+ return s.geometry.type !== "LineString" ? { valid: !1, reason: "Feature is not a LineString" } : s.geometry.coordinates.length < 2 ? { valid: !1, reason: "Feature has less than 2 coordinates" } : s.geometry.coordinates.every((e) => vt(e, t)) ? { valid: !0 } : { valid: !1, reason: "Feature has invalid coordinates" };
510
510
  }
511
- class ye extends N {
511
+ class Ce extends N {
512
512
  constructor(t) {
513
513
  super(t), this.mode = "linestring", this.currentCoordinate = 0, this.currentId = void 0, this.closingPointId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.cursors = void 0, this.mouseMove = !1, this.insertCoordinates = void 0, this.lastCommitedCoordinates = void 0, this.snappedPointId = void 0, this.coordinateSnapping = void 0, this.insertPoint = void 0;
514
514
  const e = { start: "crosshair", close: "pointer" };
515
- if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
515
+ if (this.cursors = t && t.cursors ? b({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
516
516
  else {
517
517
  const i = { cancel: "Escape", finish: "Enter" };
518
- this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
518
+ this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
519
519
  }
520
520
  this.validate = t == null ? void 0 : t.validation, this.insertCoordinates = t == null ? void 0 : t.insertCoordinates;
521
521
  }
@@ -530,13 +530,13 @@ class ye extends N {
530
530
  if (!this.currentId) return;
531
531
  const o = { type: "LineString", coordinates: t };
532
532
  if (this.validate && !this.validate({ type: "Feature", geometry: o }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: i }).valid) return;
533
- const s = [{ id: this.currentId, geometry: o }];
534
- this.closingPointId && e && s.push({ id: this.closingPointId, geometry: { type: "Point", coordinates: e } }), i === "commit" && (this.lastCommitedCoordinates = o.coordinates), this.store.updateGeometry(s);
533
+ const r = [{ id: this.currentId, geometry: o }];
534
+ this.closingPointId && e && r.push({ id: this.closingPointId, geometry: { type: "Point", coordinates: e } }), i === "commit" && (this.lastCommitedCoordinates = o.coordinates), this.store.updateGeometry(r);
535
535
  }
536
536
  generateInsertCoordinates(t, e) {
537
537
  if (!this.insertCoordinates || !this.lastCommitedCoordinates) throw new Error("Not able to insert coordinates");
538
538
  if (this.insertCoordinates.strategy !== "amount") throw new Error("Strategy does not exist");
539
- const i = G(t, e) / (this.insertCoordinates.value + 1);
539
+ const i = T(t, e) / (this.insertCoordinates.value + 1);
540
540
  let o = [];
541
541
  return this.projection === "globe" ? o = this.insertPoint.generateInsertionGeodesicCoordinates(t, e, i) : this.projection === "web-mercator" && (o = this.insertPoint.generateInsertionCoordinates(t, e, i)), o;
542
542
  }
@@ -553,14 +553,14 @@ class ye extends N {
553
553
  }
554
554
  updateToLine(t, e) {
555
555
  if (!this.currentId) return;
556
- const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, s] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, s);
556
+ const i = this.store.getGeometryCopy(this.currentId).coordinates, [o, r] = this.lastCommitedCoordinates ? this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1] : i[i.length - 2], { x: n, y: a } = this.project(o, r);
557
557
  if (O({ x: n, y: a }, { x: e.x, y: e.y }) < this.pointerDistance) return void this.close();
558
558
  this.setCursor(this.cursors.close);
559
559
  const l = [...i, t];
560
560
  this.updateGeometries(l, i[i.length - 1], M.Commit), this.currentCoordinate++;
561
561
  }
562
562
  registerBehaviors(t) {
563
- this.coordinateSnapping = new pe(t, new St(t), new Pt(t)), this.insertPoint = new Xe(t);
563
+ this.coordinateSnapping = new me(t, new St(t), new Pt(t)), this.insertPoint = new He(t);
564
564
  }
565
565
  start() {
566
566
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -586,15 +586,15 @@ class ye extends N {
586
586
  const [n, a] = o[o.length - 1], { x: l, y: d } = this.project(n, a);
587
587
  O({ x: l, y: d }, { x: t.containerX, y: t.containerY }) < this.pointerDistance && this.setCursor(this.cursors.close);
588
588
  }
589
- let s = [...o, i];
589
+ let r = [...o, i];
590
590
  if (this.insertCoordinates && this.currentId && this.lastCommitedCoordinates) {
591
591
  const n = this.lastCommitedCoordinates[this.lastCommitedCoordinates.length - 1], a = i;
592
592
  if (!Z(n, a)) {
593
593
  const l = this.generateInsertCoordinates(n, a);
594
- s = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
594
+ r = [...this.lastCommitedCoordinates.slice(0, -1), ...l, i];
595
595
  }
596
596
  }
597
- this.updateGeometries(s, void 0, M.Provisional);
597
+ this.updateGeometries(r, void 0, M.Provisional);
598
598
  }
599
599
  onClick(t) {
600
600
  this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
@@ -621,7 +621,7 @@ class ye extends N {
621
621
  }
622
622
  }
623
623
  styleFeature(t) {
624
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
624
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
625
625
  if (t.type === "Feature" && t.geometry.type === "LineString" && t.properties.mode === this.mode) return e.lineStringColor = this.getHexColorStylingValue(this.styles.lineStringColor, e.lineStringColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.lineStringWidth, e.lineStringWidth, t), e.zIndex = 10, e;
626
626
  if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
627
627
  const i = t.properties[st];
@@ -630,7 +630,7 @@ class ye extends N {
630
630
  return e;
631
631
  }
632
632
  validateFeature(t) {
633
- return this.validateModeFeature(t, (e) => ge(e, this.coordinatePrecision));
633
+ return this.validateModeFeature(t, (e) => ve(e, this.coordinatePrecision));
634
634
  }
635
635
  snapCoordinate(t) {
636
636
  var e, i;
@@ -638,15 +638,15 @@ class ye extends N {
638
638
  return (e = this.snapping) != null && e.toCoordinate && (o = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t)), (i = this.snapping) != null && i.toCustom && (o = this.snapping.toCustom(t)), o;
639
639
  }
640
640
  }
641
- const Ke = "Feature is not a Point", Ye = "Feature has invalid coordinates";
642
- function fe(r, t) {
643
- return r.geometry.type !== "Point" ? { valid: !1, reason: Ke } : vt(r.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: Ye };
641
+ const qe = "Feature is not a Point", Je = "Feature has invalid coordinates";
642
+ function Pe(s, t) {
643
+ return s.geometry.type !== "Point" ? { valid: !1, reason: qe } : vt(s.geometry.coordinates, t) ? { valid: !0 } : { valid: !1, reason: Je };
644
644
  }
645
- class me extends N {
645
+ class Se extends N {
646
646
  constructor(t) {
647
647
  super(t), this.mode = "point", this.cursors = void 0, this.editable = void 0, this.editedFeatureId = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0;
648
648
  const e = { create: "crosshair", dragStart: "grabbing", dragEnd: "crosshair" };
649
- this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.editable = !(!t || !t.editable) && t.editable;
649
+ this.cursors = t && t.cursors ? b({}, e, t.cursors) : e, this.editable = !(!t || !t.editable) && t.editable;
650
650
  }
651
651
  start() {
652
652
  this.setStarted(), this.setCursor(this.cursors.create);
@@ -673,14 +673,14 @@ class me extends N {
673
673
  onDragStart(t, e) {
674
674
  if (this.editable) {
675
675
  const i = this.clickBoundingBox.create(t), o = this.store.search(i);
676
- let s, n = 1 / 0;
676
+ let r, n = 1 / 0;
677
677
  for (let a = 0; a < o.length; a++) {
678
678
  const l = o[a];
679
679
  if (l.geometry.type !== "Point" || l.properties.mode !== this.mode) continue;
680
680
  const d = this.pixelDistance.measure(t, l.geometry.coordinates);
681
- d > n || d > this.pointerDistance || (n = d, s = l);
681
+ d > n || d > this.pointerDistance || (n = d, r = l);
682
682
  }
683
- s && (this.editedFeatureId = s.id);
683
+ r && (this.editedFeatureId = r.id);
684
684
  }
685
685
  this.editedFeatureId && (this.setCursor(this.cursors.dragStart), e(!1));
686
686
  }
@@ -694,7 +694,7 @@ class me extends N {
694
694
  this.pixelDistance = new St(t), this.clickBoundingBox = new Pt(t);
695
695
  }
696
696
  styleFeature(t) {
697
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
697
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
698
698
  if (t.type === "Feature" && t.geometry.type === "Point" && t.properties.mode === this.mode) {
699
699
  const i = !!(t.id && this.editedFeatureId === t.id);
700
700
  e.pointWidth = this.getNumericStylingValue(i ? this.styles.editedPointWidth : this.styles.pointWidth, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(i ? this.styles.editedPointColor : this.styles.pointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(i ? this.styles.editedPointOutlineColor : this.styles.pointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(i ? this.styles.editedPointOutlineWidth : this.styles.pointOutlineWidth, 2, t), e.zIndex = 30;
@@ -702,10 +702,10 @@ class me extends N {
702
702
  return e;
703
703
  }
704
704
  validateFeature(t) {
705
- return this.validateModeFeature(t, (e) => fe(e, this.coordinatePrecision));
705
+ return this.validateModeFeature(t, (e) => Pe(e, this.coordinatePrecision));
706
706
  }
707
707
  }
708
- class $e extends B {
708
+ class Ze extends j {
709
709
  constructor(t, e) {
710
710
  super(t), this.config = void 0, this.pixelDistance = void 0, this._startEndPoints = [], this.config = t, this.pixelDistance = e;
711
711
  }
@@ -727,46 +727,46 @@ class $e extends B {
727
727
  this.store.updateGeometry([{ id: this.ids[0], geometry: { type: "Point", coordinates: t[0] } }, { id: this.ids[1], geometry: { type: "Point", coordinates: t[t.length - 3] } }]);
728
728
  }
729
729
  isClosingPoint(t) {
730
- const e = this.store.getGeometryCopy(this.ids[0]), i = this.store.getGeometryCopy(this.ids[1]), o = this.pixelDistance.measure(t, e.coordinates), s = this.pixelDistance.measure(t, i.coordinates);
731
- return { isClosing: o < this.pointerDistance, isPreviousClosing: s < this.pointerDistance };
730
+ const e = this.store.getGeometryCopy(this.ids[0]), i = this.store.getGeometryCopy(this.ids[1]), o = this.pixelDistance.measure(t, e.coordinates), r = this.pixelDistance.measure(t, i.coordinates);
731
+ return { isClosing: o < this.pointerDistance, isPreviousClosing: r < this.pointerDistance };
732
732
  }
733
733
  }
734
- function Yt(r) {
735
- return Math.sqrt(Math.pow(r[0], 2) + Math.pow(r[1], 2) + Math.pow(r[2], 2));
734
+ function Yt(s) {
735
+ return Math.sqrt(Math.pow(s[0], 2) + Math.pow(s[1], 2) + Math.pow(s[2], 2));
736
736
  }
737
- function R(r, t) {
737
+ function R(s, t) {
738
738
  const e = function(i, o) {
739
- const [s, n, a] = i, [l, d, c] = o;
740
- return s * l + n * d + a * c;
741
- }(r, t) / (Yt(r) * Yt(t));
739
+ const [r, n, a] = i, [l, d, c] = o;
740
+ return r * l + n * d + a * c;
741
+ }(s, t) / (Yt(s) * Yt(t));
742
742
  return Math.acos(Math.min(Math.max(e, -1), 1));
743
743
  }
744
- function bt(r) {
745
- const t = E(r[1]), e = E(r[0]);
744
+ function It(s) {
745
+ const t = E(s[1]), e = E(s[0]);
746
746
  return [Math.cos(t) * Math.cos(e), Math.cos(t) * Math.sin(e), Math.sin(t)];
747
747
  }
748
- function X(r) {
749
- const [t, e, i] = r, o = U(Math.asin(i));
748
+ function X(s) {
749
+ const [t, e, i] = s, o = U(Math.asin(i));
750
750
  return [U(Math.atan2(e, t)), o];
751
751
  }
752
- function He(r, t, e) {
753
- const i = bt(r), o = bt(t), s = bt(e), [n, a, l] = s, [d, c, h] = function(j, z) {
754
- const [kt, Wt, Bt] = j, [jt, Nt, At] = z;
755
- return [Wt * At - Bt * Nt, Bt * jt - kt * At, kt * Nt - Wt * jt];
756
- }(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, v = u * h - g * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], S = R(i, o), b = R(i, C), w = R(o, C), D = R(i, P), A = R(o, P);
752
+ function Qe(s, t, e) {
753
+ const i = It(s), o = It(t), r = It(e), [n, a, l] = r, [d, c, h] = function(B, z) {
754
+ const [kt, Wt, jt] = B, [Bt, Nt, At] = z;
755
+ return [Wt * At - jt * Nt, jt * Bt - kt * At, kt * Nt - Wt * Bt];
756
+ }(i, o), u = c * l - h * a, p = h * n - d * l, g = d * a - c * n, y = g * c - p * h, v = u * h - g * d, f = p * d - u * c, m = 1 / Math.sqrt(Math.pow(y, 2) + Math.pow(v, 2) + Math.pow(f, 2)), C = [y * m, v * m, f * m], P = [-1 * y * m, -1 * v * m, -1 * f * m], S = R(i, o), I = R(i, C), w = R(o, C), D = R(i, P), A = R(o, P);
757
757
  let L;
758
- return L = b < D && b < A || w < D && w < A ? C : P, R(i, L) > S || R(o, L) > S ? G(X(L), X(i)) <= G(X(L), X(o)) ? [X(i), !0, !1] : [X(o), !1, !0] : [X(L), !1, !1];
758
+ return L = I < D && I < A || w < D && w < A ? C : P, R(i, L) > S || R(o, L) > S ? T(X(L), X(i)) <= T(X(L), X(o)) ? [X(i), !0, !1] : [X(o), !1, !0] : [X(L), !1, !1];
759
759
  }
760
- function qe(r, t, e) {
761
- 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)));
762
- return { x: r.x + s * i, y: r.y + s * o };
760
+ function ti(s, t, e) {
761
+ const i = t.x - s.x, o = t.y - s.y, r = Math.max(0, Math.min(1, ((e.x - s.x) * i + (e.y - s.y) * o) / (i * i + o * o)));
762
+ return { x: s.x + r * i, y: s.y + r * o };
763
763
  }
764
- class Je extends B {
764
+ class ei extends j {
765
765
  constructor(t, e, i) {
766
- 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;
766
+ super(t), this.config = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.getSnappableCoordinateFirstClick = (o) => this.getSnappable(o, (r) => !!(r.properties && r.properties.mode === this.mode)).coordinate, this.getSnappableCoordinate = (o, r) => this.getSnappable(o, (n) => !!(n.properties && n.properties.mode === this.mode && n.id !== r)).coordinate, this.config = t, this.pixelDistance = e, this.clickBoundingBox = i;
767
767
  }
768
768
  getSnappable(t, e) {
769
- const i = this.clickBoundingBox.create(t), o = this.store.search(i, e), s = { featureId: void 0, featureCoordinateIndex: void 0, coordinate: void 0, minDistance: 1 / 0 };
769
+ const i = this.clickBoundingBox.create(t), o = this.store.search(i, e), r = { featureId: void 0, featureCoordinateIndex: void 0, coordinate: void 0, minDistance: 1 / 0 };
770
770
  return o.forEach((n) => {
771
771
  let a;
772
772
  if (n.geometry.type === "Polygon") a = n.geometry.coordinates[0];
@@ -783,12 +783,12 @@ class Je extends B {
783
783
  for (let f of p) {
784
784
  const m = f[0], C = f[1];
785
785
  let P, S = 1 / 0;
786
- const b = x(m[0], m[1]), w = x(C[0], C[1]), D = x(u[0], u[1]);
786
+ const I = x(m[0], m[1]), w = x(C[0], C[1]), D = x(u[0], u[1]);
787
787
  if (m[0] === u[0] && m[1] === u[1]) P = m;
788
788
  else if (C[0] === u[0] && C[1] === u[1]) P = C;
789
789
  else {
790
- const { x: A, y: L } = qe(b, w, D), { lng: j, lat: z } = W(A, L);
791
- P = [j, z];
790
+ const { x: A, y: L } = ti(I, w, D), { lng: B, lat: z } = W(A, L);
791
+ P = [B, z];
792
792
  }
793
793
  P && (S = O(D, x(P[0], P[1])), S < y && (g = P, y = S, v = p.indexOf(f)));
794
794
  }
@@ -798,23 +798,23 @@ class Je extends B {
798
798
  for (let f of p) {
799
799
  const m = f[0], C = f[1];
800
800
  let P, S = 1 / 0;
801
- m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = He(m, C, u), P && (S = G(u, P), S < y && (g = P, y = S, v = p.indexOf(f)));
801
+ m[0] === u[0] && m[1] === u[1] ? P = m : C[0] === u[0] && C[1] === u[1] ? P = C : [P] = Qe(m, C, u), P && (S = T(u, P), S < y && (g = P, y = S, v = p.indexOf(f)));
802
802
  }
803
803
  return y === 1 / 0 ? void 0 : { coordinate: g, distance: y, lineIndex: v };
804
804
  }(c, l)), !d) return;
805
805
  const h = this.pixelDistance.measure(t, d.coordinate);
806
- h < s.minDistance && h < this.pointerDistance && (s.featureId = n.id, s.coordinate = d.coordinate, s.featureCoordinateIndex = d.lineIndex, s.minDistance = h);
807
- }), s;
806
+ h < r.minDistance && h < this.pointerDistance && (r.featureId = n.id, r.coordinate = d.coordinate, r.featureCoordinateIndex = d.lineIndex, r.minDistance = h);
807
+ }), r;
808
808
  }
809
809
  }
810
- class ve extends N {
810
+ class xe extends N {
811
811
  constructor(t) {
812
812
  super(t), this.mode = "polygon", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.snapping = void 0, this.editable = void 0, this.snappedPointId = void 0, this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedSnapType = void 0, this.editedInsertIndex = void 0, this.editedPointId = void 0, this.lineSnapping = void 0, this.coordinateSnapping = void 0, this.pixelDistance = void 0, this.closingPoints = void 0, this.clickBoundingBox = void 0, this.cursors = void 0, this.mouseMove = !1;
813
813
  const e = { start: "crosshair", close: "pointer", dragStart: "grabbing", dragEnd: "crosshair" };
814
- if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
814
+ if (this.cursors = t && t.cursors ? b({}, e, t.cursors) : e, this.snapping = t && t.snapping ? t.snapping : void 0, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
815
815
  else {
816
816
  const i = { cancel: "Escape", finish: "Enter" };
817
- this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
817
+ this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
818
818
  }
819
819
  this.editable = !(!t || !t.editable) && t.editable;
820
820
  }
@@ -826,7 +826,7 @@ class ve extends N {
826
826
  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" });
827
827
  }
828
828
  registerBehaviors(t) {
829
- this.clickBoundingBox = new Pt(t), this.pixelDistance = new St(t), this.lineSnapping = new Je(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new pe(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new $e(t, this.pixelDistance);
829
+ this.clickBoundingBox = new Pt(t), this.pixelDistance = new St(t), this.lineSnapping = new ei(t, this.pixelDistance, this.clickBoundingBox), this.coordinateSnapping = new me(t, this.pixelDistance, this.clickBoundingBox), this.closingPoints = new Ze(t, this.pixelDistance);
830
830
  }
831
831
  start() {
832
832
  this.setStarted(), this.setCursor(this.cursors.start);
@@ -840,8 +840,8 @@ class ve extends N {
840
840
  if (e) {
841
841
  if (this.snappedPointId) this.store.updateGeometry([{ id: this.snappedPointId, geometry: { type: "Point", coordinates: e } }]);
842
842
  else {
843
- const [s] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
844
- this.snappedPointId = s;
843
+ const [r] = this.store.create([{ geometry: { type: "Point", coordinates: e }, properties: { mode: this.mode, [Ot]: !0 } }]);
844
+ this.snappedPointId = r;
845
845
  }
846
846
  t.lng = e[0], t.lat = e[1];
847
847
  } else this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0);
@@ -849,12 +849,12 @@ class ve extends N {
849
849
  const i = this.store.getGeometryCopy(this.currentId).coordinates[0];
850
850
  let o;
851
851
  if (this.currentCoordinate === 1) {
852
- const s = 1 / Math.pow(10, this.coordinatePrecision - 1), n = Math.max(1e-6, s);
852
+ const r = 1 / Math.pow(10, this.coordinatePrecision - 1), n = Math.max(1e-6, r);
853
853
  o = [i[0], [t.lng, t.lat], [t.lng, t.lat - n], i[0]];
854
854
  } else if (this.currentCoordinate === 2) o = [i[0], i[1], [t.lng, t.lat], i[0]];
855
855
  else {
856
- const { isClosing: s, isPreviousClosing: n } = this.closingPoints.isClosingPoint(t);
857
- n || s ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), o = [...i.slice(0, -2), i[0], i[0]]) : o = [...i.slice(0, -2), [t.lng, t.lat], i[0]];
856
+ const { isClosing: r, isPreviousClosing: n } = this.closingPoints.isClosingPoint(t);
857
+ n || r ? (this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.setCursor(this.cursors.close), o = [...i.slice(0, -2), i[0], i[0]]) : o = [...i.slice(0, -2), [t.lng, t.lat], i[0]];
858
858
  }
859
859
  this.updatePolygonGeometry(o, M.Provisional);
860
860
  }
@@ -865,16 +865,16 @@ class ve extends N {
865
865
  }
866
866
  snapCoordinate(t) {
867
867
  var e, i, o;
868
- let s;
868
+ let r;
869
869
  if ((e = this.snapping) != null && e.toLine) {
870
870
  let n;
871
- n = this.currentId ? this.lineSnapping.getSnappableCoordinate(t, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(t), n && (s = n);
871
+ n = this.currentId ? this.lineSnapping.getSnappableCoordinate(t, this.currentId) : this.lineSnapping.getSnappableCoordinateFirstClick(t), n && (r = n);
872
872
  }
873
873
  if ((i = this.snapping) != null && i.toCoordinate) {
874
874
  let n;
875
- n = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t), n && (s = n);
875
+ n = this.currentId ? this.coordinateSnapping.getSnappableCoordinate(t, this.currentId) : this.coordinateSnapping.getSnappableCoordinateFirstClick(t), n && (r = n);
876
876
  }
877
- return (o = this.snapping) != null && o.toCustom && (s = this.snapping.toCustom(t)), s;
877
+ return (o = this.snapping) != null && o.toCustom && (r = this.snapping.toCustom(t)), r;
878
878
  }
879
879
  onClick(t) {
880
880
  if (this.currentCoordinate > 0 && !this.mouseMove && this.onMouseMove(t), this.mouseMove = !1, this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.currentCoordinate === 0) {
@@ -898,8 +898,8 @@ class ve extends N {
898
898
  const e = this.store.getGeometryCopy(this.currentId).coordinates[0], { isClosing: i, isPreviousClosing: o } = this.closingPoints.isClosingPoint(t);
899
899
  if (o || i) this.close();
900
900
  else {
901
- const s = this.snapCoordinate(t);
902
- if (s && (t.lng = s[0], t.lat = s[1]), Z([t.lng, t.lat], e[this.currentCoordinate - 1])) return;
901
+ const r = this.snapCoordinate(t);
902
+ if (r && (t.lng = r[0], t.lat = r[1]), Z([t.lng, t.lat], e[this.currentCoordinate - 1])) return;
903
903
  const n = /* @__PURE__ */ function(a = [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]) {
904
904
  return { type: "Feature", geometry: { type: "Polygon", coordinates: a }, properties: {} };
905
905
  }([[...e.slice(0, -1), [t.lng, t.lat], e[0]]]);
@@ -919,8 +919,8 @@ class ve extends N {
919
919
  if (this.state === "started") {
920
920
  const o = this.lineSnapping.getSnappable(t);
921
921
  o.coordinate && (this.editedSnapType = "line", this.editedFeatureCoordinateIndex = o.featureCoordinateIndex, this.editedFeatureId = o.featureId, i = o.coordinate);
922
- const s = this.coordinateSnapping.getSnappable(t);
923
- s.coordinate && (this.editedSnapType = "coordinate", this.editedFeatureCoordinateIndex = s.featureCoordinateIndex, this.editedFeatureId = s.featureId, i = s.coordinate);
922
+ const r = this.coordinateSnapping.getSnappable(t);
923
+ r.coordinate && (this.editedSnapType = "coordinate", this.editedFeatureCoordinateIndex = r.featureCoordinateIndex, this.editedFeatureId = r.featureId, i = r.coordinate);
924
924
  }
925
925
  if (this.editedFeatureId && i) {
926
926
  if (!this.editedPointId) {
@@ -934,8 +934,8 @@ class ve extends N {
934
934
  if (this.editedFeatureId === void 0 || this.editedFeatureCoordinateIndex === void 0) return;
935
935
  const i = this.store.getGeometryCopy(this.editedFeatureId), o = i.coordinates[0];
936
936
  this.editedSnapType === "coordinate" || this.editedSnapType === "line" && this.editedInsertIndex !== void 0 ? this.editedFeatureCoordinateIndex === 0 || this.editedFeatureCoordinateIndex === i.coordinates[0].length - 1 ? (o[0] = [t.lng, t.lat], o[o.length - 1] = [t.lng, t.lat]) : o[this.editedFeatureCoordinateIndex] = [t.lng, t.lat] : this.editedSnapType === "line" && this.editedInsertIndex === void 0 && (this.editedInsertIndex = this.editedFeatureCoordinateIndex + 1, i.coordinates[0].splice(this.editedInsertIndex, 0, [t.lng, t.lat]), this.editedFeatureCoordinateIndex++);
937
- const s = { type: "Polygon", coordinates: i.coordinates };
938
- this.validate && !this.validate({ type: "Feature", geometry: s, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: s }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !0 }]), e(!0));
937
+ const r = { type: "Polygon", coordinates: i.coordinates };
938
+ this.validate && !this.validate({ type: "Feature", geometry: r, properties: this.store.getPropertiesCopy(this.editedFeatureId) }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Provisional }).valid || (this.snapping && this.snappedPointId && (this.store.delete([this.snappedPointId]), this.snappedPointId = void 0), this.store.updateGeometry([{ id: this.editedFeatureId, geometry: r }]), this.editedPointId && this.store.updateGeometry([{ id: this.editedPointId, geometry: { type: "Point", coordinates: [t.lng, t.lat] } }]), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !0 }]), e(!0));
939
939
  }
940
940
  onDragEnd(t, e) {
941
941
  this.editedFeatureId !== void 0 && (this.setCursor(this.cursors.dragEnd), this.editedPointId && (this.store.delete([this.editedPointId]), this.editedPointId = void 0), this.store.updateProperty([{ id: this.editedFeatureId, property: J, value: !1 }]), this.editedFeatureId = void 0, this.editedFeatureCoordinateIndex = void 0, this.editedInsertIndex = void 0, this.editedSnapType = void 0, e(!0));
@@ -949,14 +949,14 @@ class ve extends N {
949
949
  }
950
950
  }
951
951
  styleFeature(t) {
952
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
952
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
953
953
  if (t.properties.mode === this.mode) {
954
954
  if (t.geometry.type === "Polygon") return e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10, e;
955
955
  if (t.geometry.type === "Point") {
956
956
  const i = t.properties[J], o = i ? "editedPoint" : t.properties[st] ? "closingPoint" : t.properties[Ot] ? "snappingPoint" : void 0;
957
957
  if (!o) return e;
958
- const s = { editedPoint: { width: this.styles.editedPointOutlineWidth, color: this.styles.editedPointColor, outlineColor: this.styles.editedPointOutlineColor, outlineWidth: this.styles.editedPointOutlineWidth }, closingPoint: { width: this.styles.closingPointWidth, color: this.styles.closingPointColor, outlineColor: this.styles.closingPointOutlineColor, outlineWidth: this.styles.closingPointOutlineWidth }, snappingPoint: { width: this.styles.snappingPointWidth, color: this.styles.snappingPointColor, outlineColor: this.styles.snappingPointOutlineColor, outlineWidth: this.styles.snappingPointOutlineWidth } };
959
- return e.pointWidth = this.getNumericStylingValue(s[o].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(s[o].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(s[o].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(s[o].outlineWidth, 2, t), e.zIndex = i ? 35 : 30, e;
958
+ const r = { editedPoint: { width: this.styles.editedPointOutlineWidth, color: this.styles.editedPointColor, outlineColor: this.styles.editedPointOutlineColor, outlineWidth: this.styles.editedPointOutlineWidth }, closingPoint: { width: this.styles.closingPointWidth, color: this.styles.closingPointColor, outlineColor: this.styles.closingPointOutlineColor, outlineWidth: this.styles.closingPointOutlineWidth }, snappingPoint: { width: this.styles.snappingPointWidth, color: this.styles.snappingPointColor, outlineColor: this.styles.snappingPointOutlineColor, outlineWidth: this.styles.snappingPointOutlineWidth } };
959
+ return e.pointWidth = this.getNumericStylingValue(r[o].width, e.pointWidth, t), e.pointColor = this.getHexColorStylingValue(r[o].color, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(r[o].outlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(r[o].outlineWidth, 2, t), e.zIndex = i ? 35 : 30, e;
960
960
  }
961
961
  }
962
962
  return e;
@@ -965,14 +965,14 @@ class ve extends N {
965
965
  return this.validateModeFeature(t, (e) => Ct(e, this.coordinatePrecision));
966
966
  }
967
967
  }
968
- class Ce extends N {
968
+ class be extends N {
969
969
  constructor(t) {
970
970
  super(t), this.mode = "rectangle", this.center = void 0, this.clickCount = 0, this.currentRectangleId = void 0, this.keyEvents = void 0, this.cursors = void 0;
971
971
  const e = { start: "crosshair" };
972
- if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
972
+ if (this.cursors = t && t.cursors ? b({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
973
973
  else {
974
974
  const i = { cancel: "Escape", finish: "Enter" };
975
- this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
975
+ this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
976
976
  }
977
977
  }
978
978
  updateRectangle(t, e) {
@@ -1018,7 +1018,7 @@ class Ce extends N {
1018
1018
  this.center = void 0, this.currentRectangleId = void 0, this.clickCount = 0, this.state === "drawing" && this.setStarted(), t !== void 0 && this.store.delete([t]);
1019
1019
  }
1020
1020
  styleFeature(t) {
1021
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1021
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1022
1022
  return t.type === "Feature" && t.geometry.type === "Polygon" && t.properties.mode === this.mode && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
1023
1023
  }
1024
1024
  validateFeature(t) {
@@ -1060,50 +1060,50 @@ class et extends N {
1060
1060
  validateFeature(t) {
1061
1061
  const e = super.validateFeature(t);
1062
1062
  if (e.valid) {
1063
- const i = t, o = fe(i, this.coordinatePrecision).valid || Ct(i, this.coordinatePrecision).valid || ge(i, this.coordinatePrecision).valid;
1063
+ const i = t, o = Pe(i, this.coordinatePrecision).valid || Ct(i, this.coordinatePrecision).valid || ve(i, this.coordinatePrecision).valid;
1064
1064
  return o ? { valid: !0 } : { valid: o, reason: "Feature is not a valid Point, Polygon or LineString feature" };
1065
1065
  }
1066
1066
  return e;
1067
1067
  }
1068
1068
  }
1069
- function gt(r, t) {
1070
- const e = r, i = t, o = E(e[1]), s = E(i[1]);
1069
+ function gt(s, t) {
1070
+ const e = s, i = t, o = E(e[1]), r = E(i[1]);
1071
1071
  let n = E(i[0] - e[0]);
1072
1072
  n > Math.PI && (n -= 2 * Math.PI), n < -Math.PI && (n += 2 * Math.PI);
1073
- const a = Math.log(Math.tan(s / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (U(Math.atan2(n, a)) + 360) % 360;
1073
+ const a = Math.log(Math.tan(r / 2 + Math.PI / 4) / Math.tan(o / 2 + Math.PI / 4)), l = (U(Math.atan2(n, a)) + 360) % 360;
1074
1074
  return l > 180 ? -(360 - l) : l;
1075
1075
  }
1076
- function Lt(r, t, e) {
1076
+ function Lt(s, t, e) {
1077
1077
  let i = t;
1078
1078
  t < 0 && (i = -Math.abs(i));
1079
- const o = i / le, s = r[0] * Math.PI / 180, n = E(r[1]), a = E(e), l = o * Math.cos(a);
1079
+ const o = i / ue, r = s[0] * Math.PI / 180, n = E(s[1]), a = E(e), l = o * Math.cos(a);
1080
1080
  let d = n + l;
1081
1081
  Math.abs(d) > Math.PI / 2 && (d = d > 0 ? Math.PI - d : -Math.PI - d);
1082
- 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];
1083
- return u[0] += u[0] - r[0] > 180 ? -360 : r[0] - u[0] > 180 ? 360 : 0, u;
1082
+ const c = Math.log(Math.tan(d / 2 + Math.PI / 4) / Math.tan(n / 2 + Math.PI / 4)), h = Math.abs(c) > 1e-11 ? l / c : Math.cos(n), u = [(180 * (r + o * Math.sin(a) / h) / Math.PI + 540) % 360 - 180, 180 * d / Math.PI];
1083
+ return u[0] += u[0] - s[0] > 180 ? -360 : s[0] - u[0] > 180 ? 360 : 0, u;
1084
1084
  }
1085
- function Pe(r, t, e, i, o) {
1086
- 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);
1085
+ function Ie(s, t, e, i, o) {
1086
+ const r = i(s[0], s[1]), n = i(t[0], t[1]), { lng: a, lat: l } = o((r.x + n.x) / 2, (r.y + n.y) / 2);
1087
1087
  return [F(a, e), F(l, e)];
1088
1088
  }
1089
- function Ze(r, t, e) {
1090
- const i = Lt(r, 1e3 * G(r, t) / 2, gt(r, t));
1089
+ function ii(s, t, e) {
1090
+ const i = Lt(s, 1e3 * T(s, t) / 2, gt(s, t));
1091
1091
  return [F(i[0], e), F(i[1], e)];
1092
1092
  }
1093
- function $t({ featureCoords: r, precision: t, unproject: e, project: i, projection: o }) {
1094
- const s = [];
1095
- for (let n = 0; n < r.length - 1; n++) {
1093
+ function $t({ featureCoords: s, precision: t, unproject: e, project: i, projection: o }) {
1094
+ const r = [];
1095
+ for (let n = 0; n < s.length - 1; n++) {
1096
1096
  let a;
1097
- if (o === "web-mercator") a = Pe(r[n], r[n + 1], t, i, e);
1097
+ if (o === "web-mercator") a = Ie(s[n], s[n + 1], t, i, e);
1098
1098
  else {
1099
1099
  if (o !== "globe") throw new Error("Invalid projection");
1100
- a = Ze(r[n], r[n + 1], t);
1100
+ a = ii(s[n], s[n + 1], t);
1101
1101
  }
1102
- s.push(a);
1102
+ r.push(a);
1103
1103
  }
1104
- return s;
1104
+ return r;
1105
1105
  }
1106
- class Qe extends B {
1106
+ class oi extends j {
1107
1107
  constructor(t, e) {
1108
1108
  super(t), this.config = void 0, this.selectionPointBehavior = void 0, this._midPoints = [], this.config = t, this.selectionPointBehavior = e;
1109
1109
  }
@@ -1113,13 +1113,13 @@ class Qe extends B {
1113
1113
  set ids(t) {
1114
1114
  }
1115
1115
  insert(t, e) {
1116
- const i = this.store.getGeometryCopy(t), { midPointFeatureId: o, midPointSegment: s } = this.store.getPropertiesCopy(t), n = this.store.getGeometryCopy(o), a = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
1117
- a.splice(s + 1, 0, i.coordinates), n.coordinates = n.type === "Polygon" ? [a] : a, this.store.updateGeometry([{ id: o, geometry: n }]), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(a, o, e), this.selectionPointBehavior.create(a, n.type, o);
1116
+ const i = this.store.getGeometryCopy(t), { midPointFeatureId: o, midPointSegment: r } = this.store.getPropertiesCopy(t), n = this.store.getGeometryCopy(o), a = n.type === "Polygon" ? n.coordinates[0] : n.coordinates;
1117
+ a.splice(r + 1, 0, i.coordinates), n.coordinates = n.type === "Polygon" ? [a] : a, this.store.updateGeometry([{ id: o, geometry: n }]), this.store.delete([...this._midPoints, ...this.selectionPointBehavior.ids]), this.create(a, o, e), this.selectionPointBehavior.create(a, n.type, o);
1118
1118
  }
1119
1119
  create(t, e, i) {
1120
1120
  if (!this.store.has(e)) throw new Error("Store does not have feature with this id");
1121
- this._midPoints = this.store.create(function(o, s, n, a, l, d) {
1122
- return $t({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: s(h) }));
1121
+ this._midPoints = this.store.create(function(o, r, n, a, l, d) {
1122
+ return $t({ featureCoords: o, precision: n, project: a, unproject: l, projection: d }).map((c, h) => ({ geometry: { type: "Point", coordinates: c }, properties: r(h) }));
1123
1123
  }(t, (o) => ({ mode: this.mode, [V.MID_POINT]: !0, midPointSegment: o, midPointFeatureId: e }), i, this.config.project, this.config.unproject, this.projection));
1124
1124
  }
1125
1125
  delete() {
@@ -1129,7 +1129,7 @@ class Qe extends B {
1129
1129
  if (this._midPoints.length !== 0) return $t({ 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 } }));
1130
1130
  }
1131
1131
  }
1132
- class ti extends B {
1132
+ class si extends j {
1133
1133
  constructor(t) {
1134
1134
  super(t), this._selectionPoints = [];
1135
1135
  }
@@ -1139,8 +1139,8 @@ class ti extends B {
1139
1139
  set ids(t) {
1140
1140
  }
1141
1141
  create(t, e, i) {
1142
- this._selectionPoints = this.store.create(function(o, s, n) {
1143
- const a = [], l = s === "Polygon" ? o.length - 1 : o.length;
1142
+ this._selectionPoints = this.store.create(function(o, r, n) {
1143
+ const a = [], l = r === "Polygon" ? o.length - 1 : o.length;
1144
1144
  for (let d = 0; d < l; d++) a.push({ geometry: { type: "Point", coordinates: o[d] }, properties: n(d) });
1145
1145
  return a;
1146
1146
  }(t, e, (o) => ({ mode: this.mode, selectionPoint: !0, selectionPointFeatureId: i, index: o })));
@@ -1155,52 +1155,52 @@ class ti extends B {
1155
1155
  if (this._selectionPoints[t] !== void 0) return { id: this._selectionPoints[t], geometry: { type: "Point", coordinates: e } };
1156
1156
  }
1157
1157
  }
1158
- function Se(r, t) {
1158
+ function Me(s, t) {
1159
1159
  let e = !1;
1160
1160
  for (let n = 0, a = t.length; n < a; n++) {
1161
1161
  const l = t[n];
1162
- for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i = r)[1] != (s = l[h])[1] > i[1] && i[0] < (s[0] - o[0]) * (i[1] - o[1]) / (s[1] - o[1]) + o[0] && (e = !e);
1162
+ for (let d = 0, c = l.length, h = c - 1; d < c; h = d++) (o = l[d])[1] > (i = s)[1] != (r = l[h])[1] > i[1] && i[0] < (r[0] - o[0]) * (i[1] - o[1]) / (r[1] - o[1]) + o[0] && (e = !e);
1163
1163
  }
1164
- var i, o, s;
1164
+ var i, o, r;
1165
1165
  return e;
1166
1166
  }
1167
- const xe = (r, t, e) => {
1168
- const i = (s) => s * s, o = (s, n) => i(s.x - n.x) + i(s.y - n.y);
1169
- return Math.sqrt(((s, n, a) => {
1167
+ const we = (s, t, e) => {
1168
+ const i = (r) => r * r, o = (r, n) => i(r.x - n.x) + i(r.y - n.y);
1169
+ return Math.sqrt(((r, n, a) => {
1170
1170
  const l = o(n, a);
1171
- if (l === 0) return o(s, n);
1172
- let d = ((s.x - n.x) * (a.x - n.x) + (s.y - n.y) * (a.y - n.y)) / l;
1173
- 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) });
1174
- })(r, t, e));
1171
+ if (l === 0) return o(r, n);
1172
+ let d = ((r.x - n.x) * (a.x - n.x) + (r.y - n.y) * (a.y - n.y)) / l;
1173
+ return d = Math.max(0, Math.min(1, d)), o(r, { x: n.x + d * (a.x - n.x), y: n.y + d * (a.y - n.y) });
1174
+ })(s, t, e));
1175
1175
  };
1176
- class ei extends B {
1176
+ class ri extends j {
1177
1177
  constructor(t, e, i) {
1178
1178
  super(t), this.config = void 0, this.createClickBoundingBox = void 0, this.pixelDistance = void 0, this.config = t, this.createClickBoundingBox = e, this.pixelDistance = i;
1179
1179
  }
1180
1180
  find(t, e) {
1181
- let i, o, s, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
1181
+ let i, o, r, n, a = 1 / 0, l = 1 / 0, d = 1 / 0;
1182
1182
  const c = this.createClickBoundingBox.create(t), h = this.store.search(c);
1183
1183
  for (let u = 0; u < h.length; u++) {
1184
1184
  const p = h[u], g = p.geometry;
1185
1185
  if (g.type === "Point") {
1186
1186
  if (p.properties.selectionPoint || !e && p.properties[V.MID_POINT]) continue;
1187
1187
  const y = this.pixelDistance.measure(t, g.coordinates);
1188
- p.properties[V.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, s = p) : !p.properties[V.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
1188
+ p.properties[V.MID_POINT] && y < this.pointerDistance && y < d ? (d = y, r = p) : !p.properties[V.MID_POINT] && y < this.pointerDistance && y < a && (a = y, i = p);
1189
1189
  } else if (g.type === "LineString") {
1190
1190
  if (i) continue;
1191
1191
  for (let y = 0; y < g.coordinates.length - 1; y++) {
1192
- const v = g.coordinates[y], f = g.coordinates[y + 1], m = xe({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
1192
+ const v = g.coordinates[y], f = g.coordinates[y + 1], m = we({ x: t.containerX, y: t.containerY }, this.project(v[0], v[1]), this.project(f[0], f[1]));
1193
1193
  m < this.pointerDistance && m < l && (l = m, o = p);
1194
1194
  }
1195
1195
  } else if (g.type === "Polygon") {
1196
1196
  if (i || o) continue;
1197
- Se([t.lng, t.lat], g.coordinates) && (n = p);
1197
+ Me([t.lng, t.lat], g.coordinates) && (n = p);
1198
1198
  }
1199
1199
  }
1200
- return { clickedFeature: i || o || n, clickedMidPoint: s };
1200
+ return { clickedFeature: i || o || n, clickedMidPoint: r };
1201
1201
  }
1202
1202
  }
1203
- class ii extends B {
1203
+ class ni extends j {
1204
1204
  constructor(t, e, i, o) {
1205
1205
  super(t), this.config = void 0, this.featuresAtCursorEvent = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedFeatureId = null, this.dragPosition = void 0, this.config = t, this.featuresAtCursorEvent = e, this.selectionPoints = i, this.midPoints = o;
1206
1206
  }
@@ -1221,10 +1221,10 @@ class ii extends B {
1221
1221
  if (!this.draggedFeatureId) return;
1222
1222
  const i = this.store.getGeometryCopy(this.draggedFeatureId), o = [t.lng, t.lat];
1223
1223
  if (i.type === "Polygon" || i.type === "LineString") {
1224
- let s, n;
1225
- if (i.type === "Polygon" ? (s = i.coordinates[0], n = s.length - 1) : (s = i.coordinates, n = s.length), !this.dragPosition) return !1;
1224
+ let r, n;
1225
+ if (i.type === "Polygon" ? (r = i.coordinates[0], n = r.length - 1) : (r = i.coordinates, n = r.length), !this.dragPosition) return !1;
1226
1226
  for (let d = 0; d < n; d++) {
1227
- const c = s[d];
1227
+ const c = r[d];
1228
1228
  let h, u;
1229
1229
  if (this.config.projection === "web-mercator") {
1230
1230
  const p = x(this.dragPosition[0], this.dragPosition[1]), g = x(o[0], o[1]), y = x(c[0], c[1]), v = { x: p.x - g.x, y: p.y - g.y }, f = y.x - v.x, m = y.y - v.y, { lng: C, lat: P } = W(f, m);
@@ -1234,16 +1234,16 @@ class ii extends B {
1234
1234
  h = c[0] - p[0], u = c[1] - p[1];
1235
1235
  }
1236
1236
  if (h = F(h, this.config.coordinatePrecision), u = F(u, this.config.coordinatePrecision), h > 180 || h < -180 || u > 90 || u < -90) return !1;
1237
- s[d] = [h, u];
1237
+ r[d] = [h, u];
1238
1238
  }
1239
- i.type === "Polygon" && (s[s.length - 1] = [s[0][0], s[0][1]]);
1240
- const a = this.selectionPoints.getUpdated(s) || [], l = this.midPoints.getUpdated(s) || [];
1239
+ i.type === "Polygon" && (r[r.length - 1] = [r[0][0], r[0][1]]);
1240
+ const a = this.selectionPoints.getUpdated(r) || [], l = this.midPoints.getUpdated(r) || [];
1241
1241
  if (e && !e({ type: "Feature", id: this.draggedFeatureId, geometry: i, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional }).valid) return !1;
1242
1242
  this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: i }, ...a, ...l]), this.dragPosition = [t.lng, t.lat];
1243
1243
  } else i.type === "Point" && (this.store.updateGeometry([{ id: this.draggedFeatureId, geometry: { type: "Point", coordinates: o } }]), this.dragPosition = [t.lng, t.lat]);
1244
1244
  }
1245
1245
  }
1246
- class oi extends B {
1246
+ class ai extends j {
1247
1247
  constructor(t, e, i, o) {
1248
1248
  super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.draggedCoordinate = { id: null, index: -1 }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
1249
1249
  }
@@ -1255,11 +1255,11 @@ class oi extends B {
1255
1255
  if (e.type !== "Polygon") return i;
1256
1256
  o = e.coordinates[0];
1257
1257
  }
1258
- for (let s = 0; s < o.length; s++) {
1259
- const n = this.pixelDistance.measure(t, o[s]);
1258
+ for (let r = 0; r < o.length; r++) {
1259
+ const n = this.pixelDistance.measure(t, o[r]);
1260
1260
  if (n < this.pointerDistance && n < i.dist) {
1261
- const a = e.type === "Polygon" && (s === o.length - 1 || s === 0);
1262
- i.dist = n, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
1261
+ const a = e.type === "Polygon" && (r === o.length - 1 || r === 0);
1262
+ i.dist = n, i.index = a ? 0 : r, i.isFirstOrLastPolygonCoord = a;
1263
1263
  }
1264
1264
  }
1265
1265
  return i;
@@ -1270,15 +1270,15 @@ class oi extends B {
1270
1270
  }
1271
1271
  drag(t, e, i) {
1272
1272
  if (this.draggedCoordinate.id === null) return !1;
1273
- const o = this.draggedCoordinate.index, s = this.store.getGeometryCopy(this.draggedCoordinate.id), n = s.type === "LineString" ? s.coordinates : s.coordinates[0], a = [t.lng, t.lat];
1273
+ const o = this.draggedCoordinate.index, r = this.store.getGeometryCopy(this.draggedCoordinate.id), n = r.type === "LineString" ? r.coordinates : r.coordinates[0], a = [t.lng, t.lat];
1274
1274
  if (t.lng > 180 || t.lng < -180 || t.lat > 90 || t.lat < -90) return !1;
1275
- if (s.type !== "Polygon" || o !== n.length - 1 && o !== 0) n[o] = a;
1275
+ if (r.type !== "Polygon" || o !== n.length - 1 && o !== 0) n[o] = a;
1276
1276
  else {
1277
1277
  const h = n.length - 1;
1278
1278
  n[0] = a, n[h] = a;
1279
1279
  }
1280
1280
  const l = this.selectionPoints.getOneUpdated(o, a), d = l ? [l] : [], c = this.midPoints.getUpdated(n) || [];
1281
- return !(s.type !== "Point" && !e && Dt({ geometry: s }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: s, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: s }, ...d, ...c]), 0));
1281
+ return !(r.type !== "Point" && !e && Dt({ geometry: r }) || i && !i({ type: "Feature", id: this.draggedCoordinate.id, geometry: r, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: r }, ...d, ...c]), 0));
1282
1282
  }
1283
1283
  isDragging() {
1284
1284
  return this.draggedCoordinate.id !== null;
@@ -1290,44 +1290,44 @@ class oi extends B {
1290
1290
  this.draggedCoordinate = { id: null, index: -1 };
1291
1291
  }
1292
1292
  }
1293
- function yt(r) {
1293
+ function yt(s) {
1294
1294
  let t = 0, e = 0, i = 0;
1295
- return (r.geometry.type === "Polygon" ? r.geometry.coordinates[0].slice(0, -1) : r.geometry.coordinates).forEach((o) => {
1295
+ return (s.geometry.type === "Polygon" ? s.geometry.coordinates[0].slice(0, -1) : s.geometry.coordinates).forEach((o) => {
1296
1296
  t += o[0], e += o[1], i++;
1297
1297
  }, !0), [t / i, e / i];
1298
1298
  }
1299
- function Ie(r, t) {
1300
- r[0] += r[0] - t[0] > 180 ? -360 : t[0] - r[0] > 180 ? 360 : 0;
1301
- const e = le, i = t[1] * Math.PI / 180, o = r[1] * Math.PI / 180, s = o - i;
1302
- let n = Math.abs(r[0] - t[0]) * Math.PI / 180;
1299
+ function Fe(s, t) {
1300
+ s[0] += s[0] - t[0] > 180 ? -360 : t[0] - s[0] > 180 ? 360 : 0;
1301
+ const e = ue, i = t[1] * Math.PI / 180, o = s[1] * Math.PI / 180, r = o - i;
1302
+ let n = Math.abs(s[0] - t[0]) * Math.PI / 180;
1303
1303
  n > Math.PI && (n -= 2 * Math.PI);
1304
- const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? s / a : Math.cos(i);
1305
- return Math.sqrt(s * s + l * l * n * n) * e;
1304
+ const a = Math.log(Math.tan(o / 2 + Math.PI / 4) / Math.tan(i / 2 + Math.PI / 4)), l = Math.abs(a) > 1e-11 ? r / a : Math.cos(i);
1305
+ return Math.sqrt(r * r + l * l * n * n) * e;
1306
1306
  }
1307
- function ft(r) {
1308
- const t = (r.geometry.type === "Polygon" ? r.geometry.coordinates[0] : r.geometry.coordinates).map((e) => {
1307
+ function ft(s) {
1308
+ const t = (s.geometry.type === "Polygon" ? s.geometry.coordinates[0] : s.geometry.coordinates).map((e) => {
1309
1309
  const { x: i, y: o } = x(e[0], e[1]);
1310
1310
  return [i, o];
1311
1311
  });
1312
- return r.geometry.type === "Polygon" ? function(e) {
1313
- let i = 0, o = 0, s = 0;
1312
+ return s.geometry.type === "Polygon" ? function(e) {
1313
+ let i = 0, o = 0, r = 0;
1314
1314
  const n = e.length;
1315
1315
  for (let a = 0; a < n - 1; a++) {
1316
1316
  const [l, d] = e[a], [c, h] = e[a + 1], u = l * h - c * d;
1317
- i += u, o += (l + c) * u, s += (d + h) * u;
1317
+ i += u, o += (l + c) * u, r += (d + h) * u;
1318
1318
  }
1319
- return i /= 2, o /= 6 * i, s /= 6 * i, { x: o, y: s };
1319
+ return i /= 2, o /= 6 * i, r /= 6 * i, { x: o, y: r };
1320
1320
  }(t) : function(e) {
1321
1321
  const i = e.length;
1322
- let o = 0, s = 0;
1322
+ let o = 0, r = 0;
1323
1323
  for (let n = 0; n < i; n++) {
1324
1324
  const [a, l] = e[n];
1325
- o += a, s += l;
1325
+ o += a, r += l;
1326
1326
  }
1327
- return { x: o / i, y: s / i };
1327
+ return { x: o / i, y: r / i };
1328
1328
  }(t);
1329
1329
  }
1330
- class si extends B {
1330
+ class li extends j {
1331
1331
  constructor(t, e, i) {
1332
1332
  super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastBearing = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
1333
1333
  }
@@ -1337,11 +1337,11 @@ class si extends B {
1337
1337
  rotate(t, e, i) {
1338
1338
  const o = this.store.getGeometryCopy(e);
1339
1339
  if (o.type !== "Polygon" && o.type !== "LineString") return;
1340
- const s = [t.lng, t.lat];
1340
+ const r = [t.lng, t.lat];
1341
1341
  let n;
1342
1342
  const a = { type: "Feature", geometry: o, properties: {} };
1343
1343
  if (this.config.projection === "web-mercator") {
1344
- if (n = T(ft(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
1344
+ if (n = G(ft(a), x(t.lng, t.lat)), !this.lastBearing) return void (this.lastBearing = n);
1345
1345
  ((h, u) => {
1346
1346
  if (u === 0 || u === 360 || u === -360) return h;
1347
1347
  const p = 0.017453292519943295 * u, g = (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).map(([f, m]) => x(f, m)), y = g.reduce((f, m) => ({ x: f.x + m.x, y: f.y + m.y }), { x: 0, y: 0 });
@@ -1351,12 +1351,12 @@ class si extends B {
1351
1351
  })(a, -(this.lastBearing - n));
1352
1352
  } else {
1353
1353
  if (this.config.projection !== "globe") throw new Error("Unsupported projection");
1354
- if (n = gt(yt({ geometry: o }), s), !this.lastBearing) return void (this.lastBearing = n + 180);
1354
+ if (n = gt(yt({ geometry: o }), r), !this.lastBearing) return void (this.lastBearing = n + 180);
1355
1355
  (function(h, u) {
1356
1356
  if (u === 0 || u === 360 || u === -360) return h;
1357
1357
  const p = yt(h);
1358
1358
  (h.geometry.type === "Polygon" ? h.geometry.coordinates[0] : h.geometry.coordinates).forEach((g) => {
1359
- const y = gt(p, g) + u, v = Ie(p, g), f = Lt(p, v, y);
1359
+ const y = gt(p, g) + u, v = Fe(p, g), f = Lt(p, v, y);
1360
1360
  g[0] = f[0], g[1] = f[1];
1361
1361
  });
1362
1362
  })(a, -(this.lastBearing - (n + 180)));
@@ -1370,7 +1370,7 @@ class si extends B {
1370
1370
  this.store.updateGeometry([{ id: e, geometry: o }, ...c, ...d]), this.projection === "web-mercator" ? this.lastBearing = n : this.projection === "globe" && (this.lastBearing = n + 180);
1371
1371
  }
1372
1372
  }
1373
- class ri extends B {
1373
+ class di extends j {
1374
1374
  constructor(t, e, i) {
1375
1375
  super(t), this.config = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.lastDistance = void 0, this.config = t, this.selectionPoints = e, this.midPoints = i;
1376
1376
  }
@@ -1380,7 +1380,7 @@ class ri extends B {
1380
1380
  scale(t, e, i) {
1381
1381
  const o = this.store.getGeometryCopy(e);
1382
1382
  if (o.type !== "Polygon" && o.type !== "LineString") return;
1383
- const s = [t.lng, t.lat], n = { type: "Feature", geometry: o, properties: {} };
1383
+ const r = [t.lng, t.lat], n = { type: "Feature", geometry: o, properties: {} };
1384
1384
  let a;
1385
1385
  const l = ft(n);
1386
1386
  if (this.config.projection === "web-mercator") {
@@ -1388,7 +1388,7 @@ class ri extends B {
1388
1388
  a = O(l, p);
1389
1389
  } else {
1390
1390
  if (this.config.projection !== "globe") throw new Error("Invalid projection");
1391
- a = G(yt({ geometry: o }), s);
1391
+ a = T(yt({ geometry: o }), r);
1392
1392
  }
1393
1393
  if (!this.lastDistance) return void (this.lastDistance = a);
1394
1394
  const d = 1 - (this.lastDistance - a) / a;
@@ -1396,12 +1396,12 @@ class ri extends B {
1396
1396
  const { lng: p, lat: g } = W(l.x, l.y);
1397
1397
  (function(y, v, f) {
1398
1398
  if (v === 1) return y;
1399
- const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, b]) => x(S, b)), C = x(f[0], f[1]), P = m.map((S) => ({ x: C.x + (S.x - C.x) * v, y: C.y + (S.y - C.y) * v })).map(({ x: S, y: b }) => [W(S, b).lng, W(S, b).lat]);
1399
+ const m = (y.geometry.type === "Polygon" ? y.geometry.coordinates[0] : y.geometry.coordinates).map(([S, I]) => x(S, I)), C = x(f[0], f[1]), P = m.map((S) => ({ x: C.x + (S.x - C.x) * v, y: C.y + (S.y - C.y) * v })).map(({ x: S, y: I }) => [W(S, I).lng, W(S, I).lat]);
1400
1400
  y.geometry.type === "Polygon" ? y.geometry.coordinates[0] = P : y.geometry.coordinates = P;
1401
1401
  })(n, d, [p, g]);
1402
1402
  } else this.config.projection === "globe" && function(p, g, y, v = "xy") {
1403
1403
  g === 1 || (p.geometry.type === "Polygon" ? p.geometry.coordinates[0] : p.geometry.coordinates).forEach((f) => {
1404
- const m = Ie(y, f), C = gt(y, f), P = Lt(y, m * g, C);
1404
+ const m = Fe(y, f), C = gt(y, f), P = Lt(y, m * g, C);
1405
1405
  v !== "x" && v !== "xy" || (f[0] = P[0]), v !== "y" && v !== "xy" || (f[1] = P[1]);
1406
1406
  });
1407
1407
  }(n, d, yt(n));
@@ -1414,7 +1414,7 @@ class ri extends B {
1414
1414
  this.store.updateGeometry([{ id: e, geometry: o }, ...u, ...h]), this.lastDistance = a;
1415
1415
  }
1416
1416
  }
1417
- class ni extends B {
1417
+ class ci extends j {
1418
1418
  constructor(t, e, i, o) {
1419
1419
  super(t), this.config = void 0, this.pixelDistance = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.minimumScale = 1e-4, this.draggedCoordinate = { id: null, index: -1 }, this.boundingBoxMaps = { opposite: { 0: 4, 1: 5, 2: 6, 3: 7, 4: 0, 5: 1, 6: 2, 7: 3 } }, this.config = t, this.pixelDistance = e, this.selectionPoints = i, this.midPoints = o;
1420
1420
  }
@@ -1426,11 +1426,11 @@ class ni extends B {
1426
1426
  if (e.type !== "Polygon") return i;
1427
1427
  o = e.coordinates[0];
1428
1428
  }
1429
- for (let s = 0; s < o.length; s++) {
1430
- const n = this.pixelDistance.measure(t, o[s]);
1429
+ for (let r = 0; r < o.length; r++) {
1430
+ const n = this.pixelDistance.measure(t, o[r]);
1431
1431
  if (n < this.pointerDistance && n < i.dist) {
1432
- const a = e.type === "Polygon" && (s === o.length - 1 || s === 0);
1433
- i.dist = n, i.index = a ? 0 : s, i.isFirstOrLastPolygonCoord = a;
1432
+ const a = e.type === "Polygon" && (r === o.length - 1 || r === 0);
1433
+ i.dist = n, i.index = a ? 0 : r, i.isFirstOrLastPolygonCoord = a;
1434
1434
  }
1435
1435
  }
1436
1436
  return i;
@@ -1473,43 +1473,43 @@ class ni extends B {
1473
1473
  centerWebMercatorDrag(t) {
1474
1474
  const e = this.getSelectedFeatureDataWebMercator();
1475
1475
  if (!e) return null;
1476
- const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = ft(i);
1476
+ const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = ft(i);
1477
1477
  if (!a) return null;
1478
1478
  const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
1479
- return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1479
+ return this.scaleWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
1480
1480
  }
1481
1481
  centerFixedWebMercatorDrag(t) {
1482
1482
  const e = this.getSelectedFeatureDataWebMercator();
1483
1483
  if (!e) return null;
1484
- const { feature: i, boundingBox: o, updatedCoords: s, selectedCoordinate: n } = e, a = ft(i);
1484
+ const { feature: i, boundingBox: o, updatedCoords: r, selectedCoordinate: n } = e, a = ft(i);
1485
1485
  if (!a) return null;
1486
1486
  const l = x(n[0], n[1]), { closestBBoxIndex: d } = this.getIndexesWebMercator(o, l), c = x(t.lng, t.lat);
1487
- return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: s, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), s;
1487
+ return this.scaleFixedWebMercator({ closestBBoxIndex: d, updatedCoords: r, webMercatorCursor: c, webMercatorSelected: l, webMercatorOrigin: a }), r;
1488
1488
  }
1489
- scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
1489
+ scaleFixedWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
1490
1490
  if (!this.isValidDragWebMercator(t, e.x - o.x, e.y - o.y)) return null;
1491
1491
  let n = O(e, o) / O(e, i);
1492
- return n < 0 && (n = this.minimumScale), this.performWebMercatorScale(s, e.x, e.y, n, n), s;
1492
+ return n < 0 && (n = this.minimumScale), this.performWebMercatorScale(r, e.x, e.y, n, n), r;
1493
1493
  }
1494
1494
  oppositeFixedWebMercatorDrag(t) {
1495
1495
  const e = this.getSelectedFeatureDataWebMercator();
1496
1496
  if (!e) return null;
1497
- const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
1497
+ const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
1498
1498
  return this.scaleFixedWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
1499
1499
  }
1500
1500
  oppositeWebMercatorDrag(t) {
1501
1501
  const e = this.getSelectedFeatureDataWebMercator();
1502
1502
  if (!e) return null;
1503
- const { boundingBox: i, updatedCoords: o, selectedCoordinate: s } = e, n = x(s[0], s[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
1503
+ const { boundingBox: i, updatedCoords: o, selectedCoordinate: r } = e, n = x(r[0], r[1]), { oppositeBboxIndex: a, closestBBoxIndex: l } = this.getIndexesWebMercator(i, n), d = { x: i[a][0], y: i[a][1] }, c = x(t.lng, t.lat);
1504
1504
  return this.scaleWebMercator({ closestBBoxIndex: l, updatedCoords: o, webMercatorCursor: c, webMercatorSelected: n, webMercatorOrigin: d }), o;
1505
1505
  }
1506
- scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: s }) {
1506
+ scaleWebMercator({ closestBBoxIndex: t, webMercatorOrigin: e, webMercatorSelected: i, webMercatorCursor: o, updatedCoords: r }) {
1507
1507
  const n = e.x - o.x, a = e.y - o.y;
1508
1508
  if (!this.isValidDragWebMercator(t, n, a)) return null;
1509
1509
  let l = 1;
1510
1510
  n !== 0 && t !== 1 && t !== 5 && (l = 1 - (e.x - i.x - n) / n);
1511
1511
  let d = 1;
1512
- return a !== 0 && t !== 3 && t !== 7 && (d = 1 - (e.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(s, e.x, e.y, l, d), s) : null;
1512
+ return a !== 0 && t !== 3 && t !== 7 && (d = 1 - (e.y - i.y - a) / a), this.validateScale(l, d) ? (l < 0 && (l = this.minimumScale), d < 0 && (d = this.minimumScale), this.performWebMercatorScale(r, e.x, e.y, l, d), r) : null;
1513
1513
  }
1514
1514
  getFeature(t) {
1515
1515
  if (this.draggedCoordinate.id === null) return null;
@@ -1523,9 +1523,9 @@ class ni extends B {
1523
1523
  const i = !isNaN(t) && e < Number.MAX_SAFE_INTEGER, o = !isNaN(e) && e < Number.MAX_SAFE_INTEGER;
1524
1524
  return i && o;
1525
1525
  }
1526
- performWebMercatorScale(t, e, i, o, s) {
1526
+ performWebMercatorScale(t, e, i, o, r) {
1527
1527
  t.forEach((n) => {
1528
- const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * s, { lng: h, lat: u } = W(d, c);
1528
+ const { x: a, y: l } = x(n[0], n[1]), d = e + (a - e) * o, c = i + (l - i) * r, { lng: h, lat: u } = W(d, c);
1529
1529
  n[0] = h, n[1] = u;
1530
1530
  });
1531
1531
  }
@@ -1537,14 +1537,14 @@ class ni extends B {
1537
1537
  })).forEach(([a, l]) => {
1538
1538
  a < e[0] && (e[0] = a), l < e[1] && (e[1] = l), a > e[2] && (e[2] = a), l > e[3] && (e[3] = l);
1539
1539
  });
1540
- const [i, o, s, n] = e;
1541
- return [[i, n], [(i + s) / 2, n], [s, n], [s, n + (o - n) / 2], [s, o], [(i + s) / 2, o], [i, o], [i, n + (o - n) / 2]];
1540
+ const [i, o, r, n] = e;
1541
+ return [[i, n], [(i + r) / 2, n], [r, n], [r, n + (o - n) / 2], [r, o], [(i + r) / 2, o], [i, o], [i, n + (o - n) / 2]];
1542
1542
  }
1543
1543
  getIndexesWebMercator(t, e) {
1544
1544
  let i, o = 1 / 0;
1545
- for (let s = 0; s < t.length; s++) {
1546
- const n = O({ x: e.x, y: e.y }, { x: t[s][0], y: t[s][1] });
1547
- n < o && (i = s, o = n);
1545
+ for (let r = 0; r < t.length; r++) {
1546
+ const n = O({ x: e.x, y: e.y }, { x: t[r][0], y: t[r][1] });
1547
+ n < o && (i = r, o = n);
1548
1548
  }
1549
1549
  if (i === void 0) throw new Error("No closest coordinate found");
1550
1550
  return { oppositeBboxIndex: this.boundingBoxMaps.opposite[i], closestBBoxIndex: i };
@@ -1566,29 +1566,29 @@ class ni extends B {
1566
1566
  if (!this.draggedCoordinate.id) return !1;
1567
1567
  const o = this.getFeature(this.draggedCoordinate.id);
1568
1568
  if (!o) return !1;
1569
- let s = null;
1570
- 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;
1571
- for (let d = 0; d < s.length; d++) {
1572
- const c = s[d];
1569
+ let r = null;
1570
+ if (e === "center" ? r = this.centerWebMercatorDrag(t) : e === "opposite" ? r = this.oppositeWebMercatorDrag(t) : e === "center-fixed" ? r = this.centerFixedWebMercatorDrag(t) : e === "opposite-fixed" && (r = this.oppositeFixedWebMercatorDrag(t)), !r) return !1;
1571
+ for (let d = 0; d < r.length; d++) {
1572
+ const c = r[d];
1573
1573
  if (c[0] = F(c[0], this.coordinatePrecision), c[1] = F(c[1], this.coordinatePrecision), !vt(c, this.coordinatePrecision)) return !1;
1574
1574
  }
1575
- const n = this.midPoints.getUpdated(s) || [], a = this.selectionPoints.getUpdated(s) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [s] : s };
1575
+ const n = this.midPoints.getUpdated(r) || [], a = this.selectionPoints.getUpdated(r) || [], l = { type: o.geometry.type, coordinates: o.geometry.type === "Polygon" ? [r] : r };
1576
1576
  return !(i && !i({ id: this.draggedCoordinate.id, type: "Feature", geometry: l, properties: {} }, { project: this.config.project, unproject: this.config.unproject, coordinatePrecision: this.config.coordinatePrecision, updateType: M.Provisional }).valid || (this.store.updateGeometry([{ id: this.draggedCoordinate.id, geometry: l }, ...a, ...n]), 0));
1577
1577
  }
1578
1578
  }
1579
- class be extends Ae {
1579
+ class Ee extends Ue {
1580
1580
  constructor(t) {
1581
1581
  var e;
1582
1582
  super(t), this.mode = "select", this.allowManualDeselection = !0, this.dragEventThrottle = 5, this.dragEventCount = 0, this.selected = [], this.flags = void 0, this.keyEvents = void 0, this.selectionPoints = void 0, this.midPoints = void 0, this.featuresAtMouseEvent = void 0, this.pixelDistance = void 0, this.clickBoundingBox = void 0, this.dragFeature = void 0, this.dragCoordinate = void 0, this.rotateFeature = void 0, this.scaleFeature = void 0, this.dragCoordinateResizeFeature = void 0, this.cursors = void 0, this.validations = {}, this.flags = t && t.flags ? t.flags : {};
1583
1583
  const i = { pointerOver: "move", dragStart: "move", dragEnd: "move", insertMidpoint: "crosshair" };
1584
- if (this.cursors = t && t.cursors ? I({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null };
1584
+ if (this.cursors = t && t.cursors ? b({}, i, t.cursors) : i, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { deselect: null, delete: null, rotate: null, scale: null };
1585
1585
  else {
1586
1586
  const o = { deselect: "Escape", delete: "Delete", rotate: ["Control", "r"], scale: ["Control", "s"] };
1587
- this.keyEvents = t && t.keyEvents ? I({}, o, t.keyEvents) : o;
1587
+ this.keyEvents = t && t.keyEvents ? b({}, o, t.keyEvents) : o;
1588
1588
  }
1589
1589
  if (this.dragEventThrottle = t && t.dragEventThrottle !== void 0 && t.dragEventThrottle || 5, this.allowManualDeselection = (e = t == null ? void 0 : t.allowManualDeselection) == null || e, t && t.flags && t.flags) for (const o in t.flags) {
1590
- const s = t.flags[o].feature;
1591
- s && s.validation && (this.validations[o] = s.validation);
1590
+ const r = t.flags[o].feature;
1591
+ r && r.validation && (this.validations[o] = r.validation);
1592
1592
  }
1593
1593
  }
1594
1594
  selectFeature(t) {
@@ -1599,7 +1599,7 @@ class be extends Ae {
1599
1599
  this._state = "selecting";
1600
1600
  }
1601
1601
  registerBehaviors(t) {
1602
- this.pixelDistance = new St(t), this.clickBoundingBox = new Pt(t), this.featuresAtMouseEvent = new ei(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new ti(t), this.midPoints = new Qe(t, this.selectionPoints), this.rotateFeature = new si(t, this.selectionPoints, this.midPoints), this.scaleFeature = new ri(t, this.selectionPoints, this.midPoints), this.dragFeature = new ii(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new oi(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new ni(t, this.pixelDistance, this.selectionPoints, this.midPoints);
1602
+ this.pixelDistance = new St(t), this.clickBoundingBox = new Pt(t), this.featuresAtMouseEvent = new ri(t, this.clickBoundingBox, this.pixelDistance), this.selectionPoints = new si(t), this.midPoints = new oi(t, this.selectionPoints), this.rotateFeature = new li(t, this.selectionPoints, this.midPoints), this.scaleFeature = new di(t, this.selectionPoints, this.midPoints), this.dragFeature = new ni(t, this.featuresAtMouseEvent, this.selectionPoints, this.midPoints), this.dragCoordinate = new ai(t, this.pixelDistance, this.selectionPoints, this.midPoints), this.dragCoordinateResizeFeature = new ci(t, this.pixelDistance, this.selectionPoints, this.midPoints);
1603
1603
  }
1604
1604
  deselectFeature() {
1605
1605
  this.deselect();
@@ -1618,22 +1618,22 @@ class be extends Ae {
1618
1618
  const u = this.store.getGeometryCopy(h), p = this.pixelDistance.measure(t, u.coordinates);
1619
1619
  p < this.pointerDistance && p < i && (i = p, e = this.store.getPropertiesCopy(h));
1620
1620
  }), !e) return;
1621
- const o = e.selectionPointFeatureId, s = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
1621
+ const o = e.selectionPointFeatureId, r = e.index, n = this.store.getPropertiesCopy(o), a = this.flags[n.mode], l = this.validations[n.mode];
1622
1622
  if (!(a && a.feature && a.feature.coordinates && a.feature.coordinates.deletable)) return;
1623
1623
  const d = this.store.getGeometryCopy(o);
1624
1624
  let c;
1625
1625
  if (d.type === "Polygon") {
1626
1626
  if (c = d.coordinates[0], c.length <= 4) return;
1627
1627
  } else if (d.type === "LineString" && (c = d.coordinates, c.length <= 2)) return;
1628
- c && (d.type !== "Polygon" || s !== 0 && s !== c.length - 1 ? c.splice(s, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision)));
1628
+ c && (d.type !== "Polygon" || r !== 0 && r !== c.length - 1 ? c.splice(r, 1) : (c.shift(), c.pop(), c.push([c[0][0], c[0][1]])), (!l || l({ id: o, type: "Feature", geometry: d, properties: n }, { project: this.project, unproject: this.unproject, coordinatePrecision: this.coordinatePrecision, updateType: M.Commit }).valid) && (this.store.delete([...this.midPoints.ids, ...this.selectionPoints.ids]), this.store.updateGeometry([{ id: o, geometry: d }]), this.selectionPoints.create(c, d.type, o), a && a.feature && a.feature.coordinates && a.feature.coordinates.midpoints && this.midPoints.create(c, o, this.coordinatePrecision)));
1629
1629
  }
1630
1630
  select(t, e = !0) {
1631
1631
  if (this.selected[0] === t) return;
1632
1632
  const { mode: i } = this.store.getPropertiesCopy(t), o = this.flags[i];
1633
1633
  if (!o || !o.feature) return;
1634
- const s = this.selected[0];
1635
- if (s) {
1636
- if (s === t) return;
1634
+ const r = this.selected[0];
1635
+ if (r) {
1636
+ if (r === t) return;
1637
1637
  this.deselect();
1638
1638
  }
1639
1639
  e && this.setCursor(this.cursors.pointerOver), this.selected = [t], this.store.updateProperty([{ id: t, property: "selected", value: !0 }]), this.onSelect(t);
@@ -1684,20 +1684,20 @@ class be extends Ae {
1684
1684
  const i = this.store.getPropertiesCopy(this.selected[0]), o = this.flags[i.mode];
1685
1685
  if (!(o && o.feature && (o.feature.draggable || o.feature.coordinates && o.feature.coordinates.draggable || o.feature.coordinates && o.feature.coordinates.resizable))) return;
1686
1686
  this.dragEventCount = 0;
1687
- const s = this.selected[0], n = this.dragCoordinate.getDraggableIndex(t, s);
1688
- return o && o.feature && o.feature.coordinates && (o.feature.coordinates.draggable || o.feature.coordinates.resizable) && n !== -1 ? (this.setCursor(this.cursors.dragStart), o.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(s, n) : this.dragCoordinate.startDragging(s, n), void e(!1)) : o && o.feature && o.feature.draggable && this.dragFeature.canDrag(t, s) ? (this.setCursor(this.cursors.dragStart), this.dragFeature.startDragging(t, s), void e(!1)) : void 0;
1687
+ const r = this.selected[0], n = this.dragCoordinate.getDraggableIndex(t, r);
1688
+ return o && o.feature && o.feature.coordinates && (o.feature.coordinates.draggable || o.feature.coordinates.resizable) && n !== -1 ? (this.setCursor(this.cursors.dragStart), o.feature.coordinates.resizable ? this.dragCoordinateResizeFeature.startDragging(r, n) : this.dragCoordinate.startDragging(r, n), void e(!1)) : o && o.feature && o.feature.draggable && this.dragFeature.canDrag(t, r) ? (this.setCursor(this.cursors.dragStart), this.dragFeature.startDragging(t, r), void e(!1)) : void 0;
1689
1689
  }
1690
1690
  onDrag(t, e) {
1691
1691
  const i = this.selected[0];
1692
1692
  if (!i) return;
1693
- const o = this.store.getPropertiesCopy(i), s = this.flags[o.mode], n = (s && s.feature && s.feature.selfIntersectable) === !0;
1693
+ const o = this.store.getPropertiesCopy(i), r = this.flags[o.mode], n = (r && r.feature && r.feature.selfIntersectable) === !0;
1694
1694
  if (this.dragEventCount++, this.dragEventCount % this.dragEventThrottle == 0) return;
1695
1695
  const a = this.validations[o.mode];
1696
- if (s && s.feature && s.feature.rotateable && this.canRotate(t)) return e(!1), void this.rotateFeature.rotate(t, i, a);
1697
- if (s && s.feature && s.feature.scaleable && this.canScale(t)) return e(!1), void this.scaleFeature.scale(t, i, a);
1698
- if (this.dragCoordinateResizeFeature.isDragging() && s.feature && s.feature.coordinates && s.feature.coordinates.resizable) {
1696
+ if (r && r.feature && r.feature.rotateable && this.canRotate(t)) return e(!1), void this.rotateFeature.rotate(t, i, a);
1697
+ if (r && r.feature && r.feature.scaleable && this.canScale(t)) return e(!1), void this.scaleFeature.scale(t, i, a);
1698
+ if (this.dragCoordinateResizeFeature.isDragging() && r.feature && r.feature.coordinates && r.feature.coordinates.resizable) {
1699
1699
  if (this.projection === "globe") throw new Error("Globe is currently unsupported projection for resizable");
1700
- return e(!1), void this.dragCoordinateResizeFeature.drag(t, s.feature.coordinates.resizable, a);
1700
+ return e(!1), void this.dragCoordinateResizeFeature.drag(t, r.feature.coordinates.resizable, a);
1701
1701
  }
1702
1702
  this.dragCoordinate.isDragging() ? this.dragCoordinate.drag(t, n, a) : this.dragFeature.isDragging() ? this.dragFeature.drag(t, a) : e(!0);
1703
1703
  }
@@ -1708,21 +1708,21 @@ class be extends Ae {
1708
1708
  if (!this.selected.length) return void this.setCursor("unset");
1709
1709
  if (this.dragFeature.isDragging()) return;
1710
1710
  let e = !1;
1711
- this.midPoints.ids.forEach((s) => {
1711
+ this.midPoints.ids.forEach((r) => {
1712
1712
  if (e) return;
1713
- const n = this.store.getGeometryCopy(s);
1713
+ const n = this.store.getGeometryCopy(r);
1714
1714
  this.pixelDistance.measure(t, n.coordinates) < this.pointerDistance && (e = !0);
1715
1715
  });
1716
1716
  let i = !1;
1717
- if (this.selectionPoints.ids.forEach((s) => {
1718
- const n = this.store.getGeometryCopy(s);
1717
+ if (this.selectionPoints.ids.forEach((r) => {
1718
+ const n = this.store.getGeometryCopy(r);
1719
1719
  this.pixelDistance.measure(t, n.coordinates) < this.pointerDistance && (e = !1, i = !0);
1720
1720
  }), e) return void this.setCursor(this.cursors.insertMidpoint);
1721
1721
  const { clickedFeature: o } = this.featuresAtMouseEvent.find(t, !0);
1722
1722
  this.setCursor(this.selected.length > 0 && (o && o.id === this.selected[0] || i) ? this.cursors.pointerOver : "unset");
1723
1723
  }
1724
1724
  styleFeature(t) {
1725
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1725
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1726
1726
  if (t.properties.mode === this.mode && t.geometry.type === "Point") {
1727
1727
  if (t.properties.selectionPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.selectionPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.selectionPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.selectionPointWidth, e.pointWidth, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.selectionPointOutlineWidth, 2, t), e.zIndex = 30, e;
1728
1728
  if (t.properties.midPoint) return e.pointColor = this.getHexColorStylingValue(this.styles.midPointColor, e.pointColor, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.midPointOutlineColor, e.pointOutlineColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.midPointWidth, 4, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.midPointOutlineWidth, 2, t), e.zIndex = 40, e;
@@ -1734,7 +1734,7 @@ class be extends Ae {
1734
1734
  return e;
1735
1735
  }
1736
1736
  }
1737
- class ai extends N {
1737
+ class hi extends N {
1738
1738
  constructor(...t) {
1739
1739
  super(...t), this.type = Y.Static, this.mode = "static";
1740
1740
  }
@@ -1759,76 +1759,76 @@ class ai extends N {
1759
1759
  cleanUp() {
1760
1760
  }
1761
1761
  styleFeature() {
1762
- return I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1762
+ return b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
1763
1763
  }
1764
1764
  }
1765
- function Me(r, t, e, i, o) {
1765
+ function Oe(s, t, e, i, o) {
1766
1766
  for (; i > e; ) {
1767
1767
  if (i - e > 600) {
1768
1768
  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);
1769
- Me(r, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
1769
+ Oe(s, t, Math.max(e, Math.floor(t - d * h / l + u)), Math.min(i, Math.floor(t + (l - d) * h / l + u)), o);
1770
1770
  }
1771
- const s = r[t];
1771
+ const r = s[t];
1772
1772
  let n = e, a = i;
1773
- for (Q(r, e, t), o(r[i], s) > 0 && Q(r, e, i); n < a; ) {
1774
- for (Q(r, n, a), n++, a--; o(r[n], s) < 0; ) n++;
1775
- for (; o(r[a], s) > 0; ) a--;
1773
+ for (Q(s, e, t), o(s[i], r) > 0 && Q(s, e, i); n < a; ) {
1774
+ for (Q(s, n, a), n++, a--; o(s[n], r) < 0; ) n++;
1775
+ for (; o(s[a], r) > 0; ) a--;
1776
1776
  }
1777
- o(r[e], s) === 0 ? Q(r, e, a) : (a++, Q(r, a, i)), a <= t && (e = a + 1), t <= a && (i = a - 1);
1777
+ o(s[e], r) === 0 ? Q(s, e, a) : (a++, Q(s, a, i)), a <= t && (e = a + 1), t <= a && (i = a - 1);
1778
1778
  }
1779
1779
  }
1780
- function Q(r, t, e) {
1781
- const i = r[t];
1782
- r[t] = r[e], r[e] = i;
1780
+ function Q(s, t, e) {
1781
+ const i = s[t];
1782
+ s[t] = s[e], s[e] = i;
1783
1783
  }
1784
- function $(r, t) {
1785
- it(r, 0, r.children.length, t, r);
1784
+ function $(s, t) {
1785
+ it(s, 0, s.children.length, t, s);
1786
1786
  }
1787
- function it(r, t, e, i, o) {
1787
+ function it(s, t, e, i, o) {
1788
1788
  o || (o = q([])), o.minX = 1 / 0, o.minY = 1 / 0, o.maxX = -1 / 0, o.maxY = -1 / 0;
1789
- for (let s = t; s < e; s++) {
1790
- const n = r.children[s];
1791
- ot(o, r.leaf ? i(n) : n);
1789
+ for (let r = t; r < e; r++) {
1790
+ const n = s.children[r];
1791
+ ot(o, s.leaf ? i(n) : n);
1792
1792
  }
1793
1793
  return o;
1794
1794
  }
1795
- function ot(r, t) {
1796
- 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;
1795
+ function ot(s, t) {
1796
+ return s.minX = Math.min(s.minX, t.minX), s.minY = Math.min(s.minY, t.minY), s.maxX = Math.max(s.maxX, t.maxX), s.maxY = Math.max(s.maxY, t.maxY), s;
1797
1797
  }
1798
- function li(r, t) {
1799
- return r.minX - t.minX;
1798
+ function ui(s, t) {
1799
+ return s.minX - t.minX;
1800
1800
  }
1801
- function di(r, t) {
1802
- return r.minY - t.minY;
1801
+ function pi(s, t) {
1802
+ return s.minY - t.minY;
1803
1803
  }
1804
- function Mt(r) {
1805
- return (r.maxX - r.minX) * (r.maxY - r.minY);
1804
+ function Mt(s) {
1805
+ return (s.maxX - s.minX) * (s.maxY - s.minY);
1806
1806
  }
1807
- function dt(r) {
1808
- return r.maxX - r.minX + (r.maxY - r.minY);
1807
+ function dt(s) {
1808
+ return s.maxX - s.minX + (s.maxY - s.minY);
1809
1809
  }
1810
- function ci(r, t) {
1811
- 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);
1812
- return Math.max(0, o - e) * Math.max(0, s - i);
1810
+ function gi(s, t) {
1811
+ const e = Math.max(s.minX, t.minX), i = Math.max(s.minY, t.minY), o = Math.min(s.maxX, t.maxX), r = Math.min(s.maxY, t.maxY);
1812
+ return Math.max(0, o - e) * Math.max(0, r - i);
1813
1813
  }
1814
- function wt(r, t) {
1815
- return r.minX <= t.minX && r.minY <= t.minY && t.maxX <= r.maxX && t.maxY <= r.maxY;
1814
+ function wt(s, t) {
1815
+ return s.minX <= t.minX && s.minY <= t.minY && t.maxX <= s.maxX && t.maxY <= s.maxY;
1816
1816
  }
1817
- function ct(r, t) {
1818
- return t.minX <= r.maxX && t.minY <= r.maxY && t.maxX >= r.minX && t.maxY >= r.minY;
1817
+ function ct(s, t) {
1818
+ return t.minX <= s.maxX && t.minY <= s.maxY && t.maxX >= s.minX && t.maxY >= s.minY;
1819
1819
  }
1820
- function q(r) {
1821
- return { children: r, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
1820
+ function q(s) {
1821
+ return { children: s, height: 1, leaf: !0, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
1822
1822
  }
1823
- function Ht(r, t, e, i, o) {
1824
- const s = [t, e];
1825
- for (; s.length; ) {
1826
- if ((e = s.pop()) - (t = s.pop()) <= i) continue;
1823
+ function Ht(s, t, e, i, o) {
1824
+ const r = [t, e];
1825
+ for (; r.length; ) {
1826
+ if ((e = r.pop()) - (t = r.pop()) <= i) continue;
1827
1827
  const n = t + Math.ceil((e - t) / i / 2) * i;
1828
- Me(r, n, t, e, o), s.push(t, n, n, e);
1828
+ Oe(s, n, t, e, o), r.push(t, n, n, e);
1829
1829
  }
1830
1830
  }
1831
- class hi {
1831
+ class yi {
1832
1832
  constructor(t) {
1833
1833
  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();
1834
1834
  }
@@ -1836,13 +1836,13 @@ class hi {
1836
1836
  let e = this.data;
1837
1837
  const i = [];
1838
1838
  if (!ct(t, e)) return i;
1839
- const o = this.toBBox, s = [];
1839
+ const o = this.toBBox, r = [];
1840
1840
  for (; e; ) {
1841
1841
  for (let n = 0; n < e.children.length; n++) {
1842
1842
  const a = e.children[n], l = e.leaf ? o(a) : a;
1843
- ct(t, l) && (e.leaf ? i.push(a) : wt(t, l) ? this._all(a, i) : s.push(a));
1843
+ ct(t, l) && (e.leaf ? i.push(a) : wt(t, l) ? this._all(a, i) : r.push(a));
1844
1844
  }
1845
- e = s.pop();
1845
+ e = r.pop();
1846
1846
  }
1847
1847
  return i;
1848
1848
  }
@@ -1852,10 +1852,10 @@ class hi {
1852
1852
  const i = [];
1853
1853
  for (; e; ) {
1854
1854
  for (let o = 0; o < e.children.length; o++) {
1855
- const s = e.children[o], n = e.leaf ? this.toBBox(s) : s;
1855
+ const r = e.children[o], n = e.leaf ? this.toBBox(r) : r;
1856
1856
  if (ct(t, n)) {
1857
1857
  if (e.leaf || wt(t, n)) return !0;
1858
- i.push(s);
1858
+ i.push(r);
1859
1859
  }
1860
1860
  }
1861
1861
  e = i.pop();
@@ -1887,14 +1887,14 @@ class hi {
1887
1887
  }
1888
1888
  remove(t) {
1889
1889
  let e = this.data;
1890
- const i = this.toBBox(t), o = [], s = [];
1890
+ const i = this.toBBox(t), o = [], r = [];
1891
1891
  let n, a, l = !1;
1892
1892
  for (; e || o.length; ) {
1893
- if (e || (e = o.pop(), a = o[o.length - 1], n = s.pop(), l = !0), e.leaf) {
1893
+ if (e || (e = o.pop(), a = o[o.length - 1], n = r.pop(), l = !0), e.leaf) {
1894
1894
  const d = e.children.indexOf(t);
1895
1895
  d !== -1 && (e.children.splice(d, 1), o.push(e), this._condense(o));
1896
1896
  }
1897
- l || e.leaf || !wt(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]);
1897
+ l || e.leaf || !wt(e, i) ? a ? (n++, e = a.children[n], l = !1) : e = null : (o.push(e), r.push(n), n = 0, a = e, e = e.children[0]);
1898
1898
  }
1899
1899
  }
1900
1900
  toBBox(t) {
@@ -1912,11 +1912,11 @@ class hi {
1912
1912
  return e;
1913
1913
  }
1914
1914
  _build(t, e, i, o) {
1915
- const s = i - e + 1;
1915
+ const r = i - e + 1;
1916
1916
  let n, a = this._maxEntries;
1917
- if (s <= a) return n = q(t.slice(e, i + 1)), $(n, this.toBBox), n;
1918
- 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;
1919
- const l = Math.ceil(s / a), d = l * Math.ceil(Math.sqrt(a));
1917
+ if (r <= a) return n = q(t.slice(e, i + 1)), $(n, this.toBBox), n;
1918
+ o || (o = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, o - 1))), n = q([]), n.leaf = !1, n.height = o;
1919
+ const l = Math.ceil(r / a), d = l * Math.ceil(Math.sqrt(a));
1920
1920
  Ht(t, e, i, d, this.compareMinX);
1921
1921
  for (let c = e; c <= i; c += d) {
1922
1922
  const h = Math.min(c + d - 1, i);
@@ -1932,51 +1932,51 @@ class hi {
1932
1932
  for (; o.push(e), !e.leaf && o.length - 1 !== i; ) {
1933
1933
  let a, l = 1 / 0, d = 1 / 0;
1934
1934
  for (let c = 0; c < e.children.length; c++) {
1935
- 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);
1935
+ const h = e.children[c], u = Mt(h), p = (r = t, n = h, (Math.max(n.maxX, r.maxX) - Math.min(n.minX, r.minX)) * (Math.max(n.maxY, r.maxY) - Math.min(n.minY, r.minY)) - u);
1936
1936
  p < d ? (d = p, l = u < l ? u : l, a = h) : p === d && u < l && (l = u, a = h);
1937
1937
  }
1938
1938
  e = a || e.children[0];
1939
1939
  }
1940
- var s, n;
1940
+ var r, n;
1941
1941
  return e;
1942
1942
  }
1943
1943
  _insert(t, e, i) {
1944
- const o = i ? t : this.toBBox(t), s = [], n = this._chooseSubtree(o, this.data, e, s);
1945
- for (n.children.push(t), ot(n, o); e >= 0 && s[e].children.length > this._maxEntries; ) this._split(s, e), e--;
1946
- this._adjustParentBBoxes(o, s, e);
1944
+ const o = i ? t : this.toBBox(t), r = [], n = this._chooseSubtree(o, this.data, e, r);
1945
+ for (n.children.push(t), ot(n, o); e >= 0 && r[e].children.length > this._maxEntries; ) this._split(r, e), e--;
1946
+ this._adjustParentBBoxes(o, r, e);
1947
1947
  }
1948
1948
  _split(t, e) {
1949
- const i = t[e], o = i.children.length, s = this._minEntries;
1950
- this._chooseSplitAxis(i, s, o);
1951
- const n = this._chooseSplitIndex(i, s, o), a = q(i.children.splice(n, i.children.length - n));
1949
+ const i = t[e], o = i.children.length, r = this._minEntries;
1950
+ this._chooseSplitAxis(i, r, o);
1951
+ const n = this._chooseSplitIndex(i, r, o), a = q(i.children.splice(n, i.children.length - n));
1952
1952
  a.height = i.height, a.leaf = i.leaf, $(i, this.toBBox), $(a, this.toBBox), e ? t[e - 1].children.push(a) : this._splitRoot(i, a);
1953
1953
  }
1954
1954
  _splitRoot(t, e) {
1955
1955
  this.data = q([t, e]), this.data.height = t.height + 1, this.data.leaf = !1, $(this.data, this.toBBox);
1956
1956
  }
1957
1957
  _chooseSplitIndex(t, e, i) {
1958
- let o, s = 1 / 0, n = 1 / 0;
1958
+ let o, r = 1 / 0, n = 1 / 0;
1959
1959
  for (let a = e; a <= i - e; a++) {
1960
- const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), c = ci(l, d), h = Mt(l) + Mt(d);
1961
- c < s ? (s = c, o = a, n = h < n ? h : n) : c === s && h < n && (n = h, o = a);
1960
+ const l = it(t, 0, a, this.toBBox), d = it(t, a, i, this.toBBox), c = gi(l, d), h = Mt(l) + Mt(d);
1961
+ c < r ? (r = c, o = a, n = h < n ? h : n) : c === r && h < n && (n = h, o = a);
1962
1962
  }
1963
1963
  return o || i - e;
1964
1964
  }
1965
1965
  _chooseSplitAxis(t, e, i) {
1966
- const o = t.leaf ? this.compareMinX : li, s = t.leaf ? this.compareMinY : di;
1967
- this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, s) && t.children.sort(o);
1966
+ const o = t.leaf ? this.compareMinX : ui, r = t.leaf ? this.compareMinY : pi;
1967
+ this._allDistMargin(t, e, i, o) < this._allDistMargin(t, e, i, r) && t.children.sort(o);
1968
1968
  }
1969
1969
  _allDistMargin(t, e, i, o) {
1970
1970
  t.children.sort(o);
1971
- const s = this.toBBox, n = it(t, 0, e, s), a = it(t, i - e, i, s);
1971
+ const r = this.toBBox, n = it(t, 0, e, r), a = it(t, i - e, i, r);
1972
1972
  let l = dt(n) + dt(a);
1973
1973
  for (let d = e; d < i - e; d++) {
1974
1974
  const c = t.children[d];
1975
- ot(n, t.leaf ? s(c) : c), l += dt(n);
1975
+ ot(n, t.leaf ? r(c) : c), l += dt(n);
1976
1976
  }
1977
1977
  for (let d = i - e - 1; d >= e; d--) {
1978
1978
  const c = t.children[d];
1979
- ot(a, t.leaf ? s(c) : c), l += dt(a);
1979
+ ot(a, t.leaf ? r(c) : c), l += dt(a);
1980
1980
  }
1981
1981
  return l;
1982
1982
  }
@@ -1987,9 +1987,9 @@ class hi {
1987
1987
  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() : $(t[i], this.toBBox);
1988
1988
  }
1989
1989
  }
1990
- class ui {
1990
+ class fi {
1991
1991
  constructor(t) {
1992
- this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new hi(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
1992
+ this.tree = void 0, this.idToNode = void 0, this.nodeToId = void 0, this.tree = new yi(t && t.maxEntries ? t.maxEntries : 9), this.idToNode = /* @__PURE__ */ new Map(), this.nodeToId = /* @__PURE__ */ new Map();
1993
1993
  }
1994
1994
  setMaps(t, e) {
1995
1995
  this.idToNode.set(t.id, e), this.nodeToId.set(e, t.id);
@@ -2004,8 +2004,8 @@ class ui {
2004
2004
  o = [t.geometry.coordinates];
2005
2005
  }
2006
2006
  for (let a = 0; a < o.length; a++) i.push(o[a][1]), e.push(o[a][0]);
2007
- const s = Math.min(...i), n = Math.max(...i);
2008
- return { minX: Math.min(...e), minY: s, maxX: Math.max(...e), maxY: n };
2007
+ const r = Math.min(...i), n = Math.max(...i);
2008
+ return { minX: Math.min(...e), minY: r, maxX: Math.max(...e), maxY: n };
2009
2009
  }
2010
2010
  insert(t) {
2011
2011
  if (this.idToNode.get(String(t.id))) throw new Error("Feature already exists");
@@ -2015,9 +2015,9 @@ class ui {
2015
2015
  load(t) {
2016
2016
  const e = [], i = /* @__PURE__ */ new Set();
2017
2017
  t.forEach((o) => {
2018
- const s = this.toBBox(o);
2019
- if (this.setMaps(o, s), i.has(String(o.id))) throw new Error(`Duplicate feature ID found ${o.id}`);
2020
- i.add(String(o.id)), e.push(s);
2018
+ const r = this.toBBox(o);
2019
+ if (this.setMaps(o, r), i.has(String(o.id))) throw new Error(`Duplicate feature ID found ${o.id}`);
2020
+ i.add(String(o.id)), e.push(r);
2021
2021
  }), this.tree.load(e);
2022
2022
  }
2023
2023
  update(t) {
@@ -2040,14 +2040,14 @@ class ui {
2040
2040
  return this.tree.collides(this.toBBox(t));
2041
2041
  }
2042
2042
  }
2043
- const pi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(r) {
2043
+ const mi = { getId: () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(s) {
2044
2044
  const t = 16 * Math.random() | 0;
2045
- return (r == "x" ? t : 3 & t | 8).toString(16);
2046
- }), isValidId: (r) => typeof r == "string" && r.length === 36 };
2047
- class gi {
2045
+ return (s == "x" ? t : 3 & t | 8).toString(16);
2046
+ }), isValidId: (s) => typeof s == "string" && s.length === 36 };
2047
+ class vi {
2048
2048
  constructor(t) {
2049
2049
  this.idStrategy = void 0, this.tracked = void 0, this.spatialIndex = void 0, this.store = void 0, this._onChange = () => {
2050
- }, this.store = {}, this.spatialIndex = new ui(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : pi;
2050
+ }, this.store = {}, this.spatialIndex = new fi(), this.tracked = !t || t.tracked !== !1, this.idStrategy = t && t.idStrategy ? t.idStrategy : mi;
2051
2051
  }
2052
2052
  clone(t) {
2053
2053
  return JSON.parse(JSON.stringify(t));
@@ -2061,24 +2061,24 @@ class gi {
2061
2061
  load(t, e) {
2062
2062
  if (t.length === 0) return [];
2063
2063
  let i = this.clone(t);
2064
- const o = [], s = [];
2064
+ const o = [], r = [];
2065
2065
  return i = i.filter((n) => {
2066
2066
  n.id == null && (n.id = this.idStrategy.getId());
2067
2067
  const a = n.id;
2068
2068
  if (e) {
2069
2069
  const l = e(n);
2070
- if (!l.valid) return s.push({ id: a, valid: !1, reason: l.reason }), !1;
2070
+ if (!l.valid) return r.push({ id: a, valid: !1, reason: l.reason }), !1;
2071
2071
  }
2072
2072
  if (this.tracked) {
2073
2073
  if (n.properties.createdAt) {
2074
- if (!Tt(n.properties.createdAt)) return s.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2074
+ if (!Gt(n.properties.createdAt)) return r.push({ id: n.id, valid: !1, reason: "createdAt is not a valid numeric timestamp" }), !1;
2075
2075
  } else n.properties.createdAt = +/* @__PURE__ */ new Date();
2076
2076
  if (n.properties.updatedAt) {
2077
- if (!Tt(n.properties.updatedAt)) return s.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2077
+ if (!Gt(n.properties.updatedAt)) return r.push({ id: n.id, valid: !1, reason: "updatedAt is not a valid numeric timestamp" }), !1;
2078
2078
  } else n.properties.updatedAt = +/* @__PURE__ */ new Date();
2079
2079
  }
2080
- return this.has(a) ? (s.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = n, o.push(a), s.push({ id: a, valid: !0 }), !0);
2081
- }), this.spatialIndex.load(i), this._onChange(o, "create"), s;
2080
+ return this.has(a) ? (r.push({ id: a, valid: !1, reason: `Feature already exists with this id: ${a}` }), !1) : (this.store[a] = n, o.push(a), r.push({ id: a, valid: !0 }), !0);
2081
+ }), this.spatialIndex.load(i), this._onChange(o, "create"), r;
2082
2082
  }
2083
2083
  search(t, e) {
2084
2084
  const i = this.spatialIndex.search(t).map((o) => this.store[o]);
@@ -2101,26 +2101,26 @@ class gi {
2101
2101
  }
2102
2102
  updateProperty(t) {
2103
2103
  const e = [];
2104
- t.forEach(({ id: i, property: o, value: s }) => {
2104
+ t.forEach(({ id: i, property: o, value: r }) => {
2105
2105
  const n = this.store[i];
2106
2106
  if (!n) throw new Error(`No feature with this (${i}), can not update geometry`);
2107
- e.push(i), n.properties[o] = s, this.tracked && (n.properties.updatedAt = +/* @__PURE__ */ new Date());
2107
+ e.push(i), n.properties[o] = r, this.tracked && (n.properties.updatedAt = +/* @__PURE__ */ new Date());
2108
2108
  }), this._onChange && this._onChange(e, "update");
2109
2109
  }
2110
2110
  updateGeometry(t) {
2111
2111
  const e = [];
2112
2112
  t.forEach(({ id: i, geometry: o }) => {
2113
2113
  e.push(i);
2114
- const s = this.store[i];
2115
- if (!s) throw new Error(`No feature with this (${i}), can not update geometry`);
2116
- s.geometry = this.clone(o), this.spatialIndex.update(s), this.tracked && (s.properties.updatedAt = +/* @__PURE__ */ new Date());
2114
+ const r = this.store[i];
2115
+ if (!r) throw new Error(`No feature with this (${i}), can not update geometry`);
2116
+ r.geometry = this.clone(o), this.spatialIndex.update(r), this.tracked && (r.properties.updatedAt = +/* @__PURE__ */ new Date());
2117
2117
  }), this._onChange && this._onChange(e, "update");
2118
2118
  }
2119
2119
  create(t) {
2120
2120
  const e = [];
2121
2121
  return t.forEach(({ geometry: i, properties: o }) => {
2122
- let s, n = I({}, o);
2123
- this.tracked && (s = +/* @__PURE__ */ new Date(), o ? (n.createdAt = typeof o.createdAt == "number" ? o.createdAt : s, n.updatedAt = typeof o.updatedAt == "number" ? o.updatedAt : s) : n = { createdAt: s, updatedAt: s });
2122
+ let r, n = b({}, o);
2123
+ this.tracked && (r = +/* @__PURE__ */ new Date(), o ? (n.createdAt = typeof o.createdAt == "number" ? o.createdAt : r, n.updatedAt = typeof o.updatedAt == "number" ? o.updatedAt : r) : n = { createdAt: r, updatedAt: r });
2124
2124
  const a = this.getId(), l = { id: a, type: "Feature", geometry: i, properties: n };
2125
2125
  this.store[a] = l, this.spatialIndex.insert(l), e.push(a);
2126
2126
  }), this._onChange && this._onChange([...e], "create"), e;
@@ -2141,20 +2141,20 @@ class gi {
2141
2141
  return Object.keys(this.store).length;
2142
2142
  }
2143
2143
  }
2144
- const yi = "Feature is not a Polygon or LineString", fi = "Feature intersects itself", mi = (r) => r.geometry.type !== "Polygon" && r.geometry.type !== "LineString" ? { valid: !1, reason: yi } : Dt(r) ? { valid: !1, reason: fi } : { valid: !0 };
2145
- function qt(r, t, e) {
2146
- const i = T(r, t);
2147
- let o = T(t, e) - i;
2144
+ const Ci = "Feature is not a Polygon or LineString", Pi = "Feature intersects itself", Si = (s) => s.geometry.type !== "Polygon" && s.geometry.type !== "LineString" ? { valid: !1, reason: Ci } : Dt(s) ? { valid: !1, reason: Pi } : { valid: !0 };
2145
+ function qt(s, t, e) {
2146
+ const i = G(s, t);
2147
+ let o = G(t, e) - i;
2148
2148
  return o < 0 && (o += 360), 180 - Math.abs(o - 90 - 90);
2149
2149
  }
2150
- class we extends N {
2150
+ class De extends N {
2151
2151
  constructor(t) {
2152
2152
  super(t), this.mode = "angled-rectangle", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.cursors = void 0, this.mouseMove = !1;
2153
2153
  const e = { start: "crosshair", close: "pointer" };
2154
- if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2154
+ if (this.cursors = t && t.cursors ? b({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2155
2155
  else {
2156
2156
  const i = { cancel: "Escape", finish: "Enter" };
2157
- this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
2157
+ this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
2158
2158
  }
2159
2159
  }
2160
2160
  close() {
@@ -2173,11 +2173,11 @@ class we extends N {
2173
2173
  const e = this.store.getGeometryCopy(this.currentId).coordinates[0];
2174
2174
  let i;
2175
2175
  if (this.currentCoordinate === 1) {
2176
- const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
2177
- i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
2176
+ const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
2177
+ i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
2178
2178
  } else if (this.currentCoordinate === 2) {
2179
- const o = e[0], s = e[1], n = Pe(o, s, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(s[0], s[1]), c = x(t.lng, t.lat), h = O(c, a) < O(c, d), u = qt(a, l, c), p = h ? 90 - u : qt(a, l, c) - 90, g = O(l, c), y = Math.cos(E(p)) * g, v = T(a, d) + (function(S, b, w) {
2180
- const D = (w.x - b.x) * (S.y - b.y) - (w.y - b.y) * (S.x - b.x);
2179
+ const o = e[0], r = e[1], n = Ie(o, r, this.coordinatePrecision, this.project, this.unproject), a = x(o[0], o[1]), l = x(n[0], n[1]), d = x(r[0], r[1]), c = x(t.lng, t.lat), h = O(c, a) < O(c, d), u = qt(a, l, c), p = h ? 90 - u : qt(a, l, c) - 90, g = O(l, c), y = Math.cos(E(p)) * g, v = G(a, d) + (function(S, I, w) {
2180
+ const D = (w.x - I.x) * (S.y - I.y) - (w.y - I.y) * (S.x - I.x);
2181
2181
  return D > 1e-10 ? "left" : D < -1e-10 ? "right" : "left";
2182
2182
  }(a, d, c) === "right" ? -90 : 90), f = rt(a, y, v), m = rt(d, y, v), C = W(f.x, f.y), P = W(m.x, m.y);
2183
2183
  i = [e[0], e[1], [P.lng, P.lat], [C.lng, C.lat], e[0]];
@@ -2217,24 +2217,24 @@ class we extends N {
2217
2217
  this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
2218
2218
  }
2219
2219
  styleFeature(t) {
2220
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2220
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2221
2221
  return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
2222
2222
  }
2223
2223
  validateFeature(t) {
2224
2224
  return this.validateModeFeature(t, (e) => nt(e, this.coordinatePrecision));
2225
2225
  }
2226
2226
  }
2227
- function Fe(r, t, e) {
2228
- return (t.x - r.x) * (e.y - r.y) - (t.y - r.y) * (e.x - r.x) <= 0;
2227
+ function Le(s, t, e) {
2228
+ return (t.x - s.x) * (e.y - s.y) - (t.y - s.y) * (e.x - s.x) <= 0;
2229
2229
  }
2230
- class Ee extends N {
2230
+ class _e extends N {
2231
2231
  constructor(t) {
2232
2232
  super(t), this.mode = "sector", this.currentCoordinate = 0, this.currentId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
2233
2233
  const e = { start: "crosshair", close: "pointer" };
2234
- if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2234
+ if (this.cursors = t && t.cursors ? b({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2235
2235
  else {
2236
2236
  const i = { cancel: "Escape", finish: "Enter" };
2237
- this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
2237
+ this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
2238
2238
  }
2239
2239
  this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
2240
2240
  }
@@ -2254,21 +2254,21 @@ class Ee extends N {
2254
2254
  const e = this.store.getGeometryCopy(this.currentId).coordinates[0];
2255
2255
  let i;
2256
2256
  if (this.currentCoordinate === 1) {
2257
- const o = 1 / Math.pow(10, this.coordinatePrecision - 1), s = Math.max(1e-6, o);
2258
- i = [e[0], [t.lng, t.lat], [t.lng, t.lat - s], e[0]];
2257
+ const o = 1 / Math.pow(10, this.coordinatePrecision - 1), r = Math.max(1e-6, o);
2258
+ i = [e[0], [t.lng, t.lat], [t.lng, t.lat - r], e[0]];
2259
2259
  } else if (this.currentCoordinate === 2) {
2260
- const o = e[0], s = e[1], n = [t.lng, t.lat], a = x(o[0], o[1]), l = x(s[0], s[1]), d = x(n[0], n[1]);
2260
+ const o = e[0], r = e[1], n = [t.lng, t.lat], a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(n[0], n[1]);
2261
2261
  if (this.direction === void 0) {
2262
- const C = Fe(a, l, d);
2262
+ const C = Le(a, l, d);
2263
2263
  this.direction = C ? "clockwise" : "anticlockwise";
2264
2264
  }
2265
- const c = O(a, l), h = T(a, l), u = T(a, d), p = this.arcPoints, g = [o], y = K(h), v = K(u);
2265
+ const c = O(a, l), h = G(a, l), u = G(a, d), p = this.arcPoints, g = [o], y = K(h), v = K(u);
2266
2266
  let f;
2267
2267
  this.direction === "anticlockwise" ? (f = v - y, f < 0 && (f += 360)) : (f = y - v, f < 0 && (f += 360));
2268
2268
  const m = (this.direction === "anticlockwise" ? 1 : -1) * f / p;
2269
- g.push(s);
2269
+ g.push(r);
2270
2270
  for (let C = 0; C <= p; C++) {
2271
- const P = rt(a, c, y + C * m), { lng: S, lat: b } = W(P.x, P.y), w = [F(S, this.coordinatePrecision), F(b, this.coordinatePrecision)];
2271
+ const P = rt(a, c, y + C * m), { lng: S, lat: I } = W(P.x, P.y), w = [F(S, this.coordinatePrecision), F(I, this.coordinatePrecision)];
2272
2272
  w[0] !== g[g.length - 1][0] && w[1] !== g[g.length - 1][1] && g.push(w);
2273
2273
  }
2274
2274
  g.push(o), i = [...g];
@@ -2308,21 +2308,21 @@ class Ee extends N {
2308
2308
  this.currentId = void 0, this.direction = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
2309
2309
  }
2310
2310
  styleFeature(t) {
2311
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2311
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2312
2312
  return t.properties.mode === this.mode && t.geometry.type === "Polygon" && (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10), e;
2313
2313
  }
2314
2314
  validateFeature(t) {
2315
2315
  return this.validateModeFeature(t, (e) => nt(e, this.coordinatePrecision));
2316
2316
  }
2317
2317
  }
2318
- class Oe extends N {
2318
+ class ke extends N {
2319
2319
  constructor(t) {
2320
2320
  super(t), this.mode = "sensor", this.currentCoordinate = 0, this.currentId = void 0, this.currentInitialArcId = void 0, this.currentStartingPointId = void 0, this.keyEvents = void 0, this.direction = void 0, this.arcPoints = void 0, this.cursors = void 0, this.mouseMove = !1;
2321
2321
  const e = { start: "crosshair", close: "pointer" };
2322
- if (this.cursors = t && t.cursors ? I({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2322
+ if (this.cursors = t && t.cursors ? b({}, e, t.cursors) : e, (t == null ? void 0 : t.keyEvents) === null) this.keyEvents = { cancel: null, finish: null };
2323
2323
  else {
2324
2324
  const i = { cancel: "Escape", finish: "Enter" };
2325
- this.keyEvents = t && t.keyEvents ? I({}, i, t.keyEvents) : i;
2325
+ this.keyEvents = t && t.keyEvents ? b({}, i, t.keyEvents) : i;
2326
2326
  }
2327
2327
  this.arcPoints = (t == null ? void 0 : t.arcPoints) || 64;
2328
2328
  }
@@ -2340,31 +2340,31 @@ class Oe extends N {
2340
2340
  onMouseMove(t) {
2341
2341
  if (this.mouseMove = !0, this.setCursor(this.cursors.start), this.currentInitialArcId !== void 0 && this.currentStartingPointId !== void 0 && this.currentCoordinate !== 0) {
2342
2342
  if (this.currentCoordinate === 2) {
2343
- const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = [t.lng, t.lat], n = x(o[0], o[1]), a = x(s[0], s[1]), l = x(i[0], i[1]), d = O(l, n);
2343
+ const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates, i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = [t.lng, t.lat], n = x(o[0], o[1]), a = x(r[0], r[1]), l = x(i[0], i[1]), d = O(l, n);
2344
2344
  if (this.direction === void 0) {
2345
- const m = Fe(l, n, a);
2345
+ const m = Le(l, n, a);
2346
2346
  this.direction = m ? "clockwise" : "anticlockwise";
2347
2347
  }
2348
- const c = T(l, n), h = T(l, a), u = this.arcPoints, p = [o], g = K(c), y = K(h);
2348
+ const c = G(l, n), h = G(l, a), u = this.arcPoints, p = [o], g = K(c), y = K(h);
2349
2349
  let v;
2350
2350
  this.direction === "anticlockwise" ? (v = y - g, v < 0 && (v += 360)) : (v = g - y, v < 0 && (v += 360));
2351
2351
  const f = (this.direction === "anticlockwise" ? 1 : -1) * v / u;
2352
2352
  for (let m = 0; m <= u; m++) {
2353
- const C = rt(l, d, g + m * f), { lng: P, lat: S } = W(C.x, C.y), b = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
2354
- b[0] !== p[p.length - 1][0] && b[1] !== p[p.length - 1][1] && p.push(b);
2353
+ const C = rt(l, d, g + m * f), { lng: P, lat: S } = W(C.x, C.y), I = [F(P, this.coordinatePrecision), F(S, this.coordinatePrecision)];
2354
+ I[0] !== p[p.length - 1][0] && I[1] !== p[p.length - 1][1] && p.push(I);
2355
2355
  }
2356
2356
  this.updateLineStringGeometry(this.currentInitialArcId, p, M.Provisional);
2357
2357
  } else if (this.currentCoordinate === 3) {
2358
2358
  const e = this.store.getGeometryCopy(this.currentInitialArcId).coordinates;
2359
2359
  if (e.length < 2 || !this.direction) return;
2360
- const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], s = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(s[0], s[1]), d = x(i[0], i[1]), c = O(d, a), h = O(d, n) < c ? a : n, u = T(d, n), p = T(d, a), g = T(d, l), y = K(p), v = K(g), f = K(u);
2360
+ const i = this.store.getGeometryCopy(this.currentStartingPointId).coordinates, o = e[0], r = e[e.length - 1], n = x(t.lng, t.lat), a = x(o[0], o[1]), l = x(r[0], r[1]), d = x(i[0], i[1]), c = O(d, a), h = O(d, n) < c ? a : n, u = G(d, n), p = G(d, a), g = G(d, l), y = K(p), v = K(g), f = K(u);
2361
2361
  if (this.notInSector({ normalizedCursor: f, normalizedStart: y, normalizedEnd: v, direction: this.direction })) return;
2362
- const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = O(d, h), b = [];
2362
+ const m = this.getDeltaBearing(this.direction, y, v), C = this.arcPoints, P = (this.direction === "anticlockwise" ? 1 : -1) * m / C, S = O(d, h), I = [];
2363
2363
  for (let w = 0; w <= C; w++) {
2364
- const D = rt(d, S, y + w * P), { lng: A, lat: L } = W(D.x, D.y), j = [F(A, this.coordinatePrecision), F(L, this.coordinatePrecision)];
2365
- j[0] !== e[e.length - 1][0] && j[1] !== e[e.length - 1][1] && b.unshift(j);
2364
+ const D = rt(d, S, y + w * P), { lng: A, lat: L } = W(D.x, D.y), B = [F(A, this.coordinatePrecision), F(L, this.coordinatePrecision)];
2365
+ B[0] !== e[e.length - 1][0] && B[1] !== e[e.length - 1][1] && I.unshift(B);
2366
2366
  }
2367
- e.push(...b), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, M.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
2367
+ e.push(...I), e.push(e[0]), this.currentId ? this.updatePolygonGeometry(this.currentId, e, M.Provisional) : [this.currentId] = this.store.create([{ geometry: { type: "Polygon", coordinates: [e] }, properties: { mode: this.mode } }]);
2368
2368
  }
2369
2369
  }
2370
2370
  }
@@ -2404,7 +2404,7 @@ class Oe extends N {
2404
2404
  this.currentStartingPointId = void 0, this.direction = void 0, this.currentId = void 0, this.currentCoordinate = 0, this.state === "drawing" && this.setStarted();
2405
2405
  }
2406
2406
  styleFeature(t) {
2407
- const e = I({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2407
+ const e = b({}, { polygonFillColor: "#3f97e0", polygonOutlineColor: "#3f97e0", polygonOutlineWidth: 4, polygonFillOpacity: 0.3, pointColor: "#3f97e0", pointOutlineColor: "#ffffff", pointOutlineWidth: 0, pointWidth: 6, lineStringColor: "#3f97e0", lineStringWidth: 4, zIndex: 0 });
2408
2408
  return t.properties.mode === this.mode && (t.geometry.type === "Polygon" ? (e.polygonFillColor = this.getHexColorStylingValue(this.styles.fillColor, e.polygonFillColor, t), e.polygonOutlineColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.polygonOutlineWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.polygonFillOpacity = this.getNumericStylingValue(this.styles.fillOpacity, e.polygonFillOpacity, t), e.zIndex = 10) : t.geometry.type === "LineString" ? (e.lineStringColor = this.getHexColorStylingValue(this.styles.outlineColor, e.polygonOutlineColor, t), e.lineStringWidth = this.getNumericStylingValue(this.styles.outlineWidth, e.polygonOutlineWidth, t), e.zIndex = 10) : t.geometry.type === "Point" && (e.pointColor = this.getHexColorStylingValue(this.styles.centerPointColor, e.pointColor, t), e.pointWidth = this.getNumericStylingValue(this.styles.centerPointWidth, e.pointWidth, t), e.pointOutlineColor = this.getHexColorStylingValue(this.styles.centerPointOutlineColor, e.pointOutlineColor, t), e.pointOutlineWidth = this.getNumericStylingValue(this.styles.centerPointOutlineWidth, e.pointOutlineWidth, t), e.zIndex = 20)), e;
2409
2409
  }
2410
2410
  validateFeature(t) {
@@ -2418,9 +2418,9 @@ class Oe extends N {
2418
2418
  return o === "clockwise" ? e <= i ? t >= e && t <= i : t >= e || t <= i : e >= i ? t <= e && t >= i : t <= e || t >= i;
2419
2419
  }
2420
2420
  }
2421
- class vi {
2421
+ class xi {
2422
2422
  constructor(t) {
2423
- 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 ai();
2423
+ 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 hi();
2424
2424
  const e = /* @__PURE__ */ new Set(), i = t.modes.reduce((c, h) => {
2425
2425
  if (e.has(h.mode)) throw new Error(`There is already a ${h.mode} mode provided`);
2426
2426
  return e.add(h.mode), c[h.mode] = h, c;
@@ -2431,8 +2431,8 @@ class vi {
2431
2431
  if (this._instanceSelectMode) throw new Error("only one type of select mode can be provided");
2432
2432
  this._instanceSelectMode = c;
2433
2433
  }
2434
- }), this._modes = I({}, 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 });
2435
- const s = (c) => {
2434
+ }), this._modes = b({}, i, { static: this._mode }), this._eventListeners = { change: [], select: [], deselect: [], finish: [], ready: [] }, this._store = new vi({ tracked: !!t.tracked, idStrategy: t.idStrategy ? t.idStrategy : void 0 });
2435
+ const r = (c) => {
2436
2436
  const h = [], u = this._store.copyAll().filter((p) => !c.includes(p.id) || (h.push(p), !1));
2437
2437
  return { changed: h, unchanged: u };
2438
2438
  }, n = (c, h) => {
@@ -2444,21 +2444,21 @@ class vi {
2444
2444
  this._eventListeners.change.forEach((g) => {
2445
2445
  g(c, h);
2446
2446
  });
2447
- const { changed: u, unchanged: p } = s(c);
2447
+ const { changed: u, unchanged: p } = r(c);
2448
2448
  h === "create" ? this._adapter.render({ created: u, deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles()) : h === "update" ? this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: u }, this.getModeStyles()) : h === "delete" ? this._adapter.render({ created: [], deletedIds: c, unchanged: p, updated: [] }, this.getModeStyles()) : h === "styling" && this._adapter.render({ created: [], deletedIds: [], unchanged: p, updated: [] }, this.getModeStyles());
2449
2449
  }, l = (c) => {
2450
2450
  if (!this._enabled) return;
2451
2451
  this._eventListeners.select.forEach((p) => {
2452
2452
  p(c);
2453
2453
  });
2454
- const { changed: h, unchanged: u } = s([c]);
2454
+ const { changed: h, unchanged: u } = r([c]);
2455
2455
  this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2456
2456
  }, d = (c) => {
2457
2457
  if (!this._enabled) return;
2458
2458
  this._eventListeners.deselect.forEach((p) => {
2459
2459
  p();
2460
2460
  });
2461
- const { changed: h, unchanged: u } = s([c]);
2461
+ const { changed: h, unchanged: u } = r([c]);
2462
2462
  h && this._adapter.render({ created: [], deletedIds: [], unchanged: u, updated: h }, this.getModeStyles());
2463
2463
  };
2464
2464
  Object.keys(this._modes).forEach((c) => {
@@ -2475,9 +2475,9 @@ class vi {
2475
2475
  }), t;
2476
2476
  }
2477
2477
  featuresAtLocation({ lng: t, lat: e }, i) {
2478
- const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, s = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = ue({ unproject: n, point: l, pointerDistance: o });
2478
+ const o = i && i.pointerDistance !== void 0 ? i.pointerDistance : 30, r = !i || i.ignoreSelectFeatures === void 0 || i.ignoreSelectFeatures, n = this._adapter.unproject.bind(this._adapter), a = this._adapter.project.bind(this._adapter), l = a(t, e), d = fe({ unproject: n, point: l, pointerDistance: o });
2479
2479
  return this._store.search(d).filter((c) => {
2480
- if (s && (c.properties[V.MID_POINT] || c.properties[V.SELECTION_POINT])) return !1;
2480
+ if (r && (c.properties[V.MID_POINT] || c.properties[V.SELECTION_POINT])) return !1;
2481
2481
  if (c.geometry.type === "Point") {
2482
2482
  const h = c.geometry.coordinates, u = a(h[0], h[1]);
2483
2483
  return O(l, u) < o;
@@ -2486,11 +2486,11 @@ class vi {
2486
2486
  const h = c.geometry.coordinates;
2487
2487
  for (let u = 0; u < h.length - 1; u++) {
2488
2488
  const p = h[u], g = h[u + 1];
2489
- if (xe(l, a(p[0], p[1]), a(g[0], g[1])) < o) return !0;
2489
+ if (we(l, a(p[0], p[1]), a(g[0], g[1])) < o) return !0;
2490
2490
  }
2491
2491
  return !1;
2492
2492
  }
2493
- return !!Se([t, e], c.geometry.coordinates) || void 0;
2493
+ return !!Me([t, e], c.geometry.coordinates) || void 0;
2494
2494
  });
2495
2495
  }
2496
2496
  getSelectMode() {
@@ -2542,8 +2542,8 @@ class vi {
2542
2542
  }(e)) {
2543
2543
  const i = e.properties.mode, o = this._modes[i];
2544
2544
  if (!o) return { id: e.id, valid: !1, reason: `${i} mode is not in the list of instantiated modes` };
2545
- const s = o.validateFeature.bind(o)(e);
2546
- return { id: e.id, valid: s.valid, reason: s.reason ? s.reason : s.valid ? void 0 : "Feature is invalid" };
2545
+ const r = o.validateFeature.bind(o)(e);
2546
+ return { id: e.id, valid: r.valid, reason: r.reason ? r.reason : r.valid ? void 0 : "Feature is invalid" };
2547
2547
  }
2548
2548
  return { id: e.id, valid: !1, reason: "Mode property does not exist" };
2549
2549
  });
@@ -2592,12 +2592,12 @@ class vi {
2592
2592
  }
2593
2593
  }
2594
2594
  var Jt, Ft, Zt;
2595
- function Qt(r, t = 9) {
2595
+ function Qt(s, t = 9) {
2596
2596
  const e = Math.pow(10, t);
2597
- return Math.round(r * e) / e;
2597
+ return Math.round(s * e) / e;
2598
2598
  }
2599
- (Ft = Jt || (Jt = {})).Commit = "commit", Ft.Provisional = "provisional", Ft.Finish = "finish", function(r) {
2600
- r.Drawing = "drawing", r.Select = "select", r.Static = "static", r.Render = "render";
2599
+ (Ft = Jt || (Jt = {})).Commit = "commit", Ft.Provisional = "provisional", Ft.Finish = "finish", function(s) {
2600
+ s.Drawing = "drawing", s.Select = "select", s.Static = "static", s.Render = "render";
2601
2601
  }(Zt || (Zt = {}));
2602
2602
  class H {
2603
2603
  constructor({ name: t, callback: e, unregister: i, register: o }) {
@@ -2608,25 +2608,25 @@ class H {
2608
2608
  }, this.callback = e;
2609
2609
  }
2610
2610
  }
2611
- var Ci = class {
2612
- constructor(r) {
2613
- 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;
2611
+ var bi = class {
2612
+ constructor(s) {
2613
+ this._minPixelDragDistance = void 0, this._minPixelDragDistanceDrawing = void 0, this._minPixelDragDistanceSelecting = void 0, this._lastDrawEvent = void 0, this._coordinatePrecision = void 0, this._heldKeys = /* @__PURE__ */ new Set(), this._listeners = [], this._dragState = "not-dragging", this._currentModeCallbacks = void 0, this._minPixelDragDistance = typeof s.minPixelDragDistance == "number" ? s.minPixelDragDistance : 1, this._minPixelDragDistanceSelecting = typeof s.minPixelDragDistanceSelecting == "number" ? s.minPixelDragDistanceSelecting : 1, this._minPixelDragDistanceDrawing = typeof s.minPixelDragDistanceDrawing == "number" ? s.minPixelDragDistanceDrawing : 8, this._coordinatePrecision = typeof s.coordinatePrecision == "number" ? s.coordinatePrecision : 9;
2614
2614
  }
2615
- getButton(r) {
2616
- return r.button === -1 ? "neither" : r.button === 0 ? "left" : r.button === 1 ? "middle" : r.button === 2 ? "right" : "neither";
2615
+ getButton(s) {
2616
+ return s.button === -1 ? "neither" : s.button === 0 ? "left" : s.button === 1 ? "middle" : s.button === 2 ? "right" : "neither";
2617
2617
  }
2618
- getMapElementXYPosition(r) {
2618
+ getMapElementXYPosition(s) {
2619
2619
  const t = this.getMapEventElement(), { left: e, top: i } = t.getBoundingClientRect();
2620
- return { containerX: r.clientX - e, containerY: r.clientY - i };
2620
+ return { containerX: s.clientX - e, containerY: s.clientY - i };
2621
2621
  }
2622
- getDrawEventFromEvent(r) {
2623
- const t = this.getLngLatFromEvent(r);
2622
+ getDrawEventFromEvent(s) {
2623
+ const t = this.getLngLatFromEvent(s);
2624
2624
  if (!t) return null;
2625
- const { lng: e, lat: i } = t, { containerX: o, containerY: s } = this.getMapElementXYPosition(r), n = this.getButton(r), a = Array.from(this._heldKeys);
2626
- return { lng: Qt(e, this._coordinatePrecision), lat: Qt(i, this._coordinatePrecision), containerX: o, containerY: s, button: n, heldKeys: a };
2625
+ const { lng: e, lat: i } = t, { containerX: o, containerY: r } = this.getMapElementXYPosition(s), n = this.getButton(s), a = Array.from(this._heldKeys);
2626
+ return { lng: Qt(e, this._coordinatePrecision), lat: Qt(i, this._coordinatePrecision), containerX: o, containerY: r, button: n, heldKeys: a };
2627
2627
  }
2628
- register(r) {
2629
- this._currentModeCallbacks = r, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
2628
+ register(s) {
2629
+ this._currentModeCallbacks = s, this._listeners = this.getAdapterListeners(), this._listeners.forEach((t) => {
2630
2630
  t.register();
2631
2631
  });
2632
2632
  }
@@ -2634,74 +2634,74 @@ var Ci = class {
2634
2634
  return this._coordinatePrecision;
2635
2635
  }
2636
2636
  getAdapterListeners() {
2637
- return [new H({ name: "pointerdown", callback: (r) => {
2638
- if (!this._currentModeCallbacks || !r.isPrimary) return;
2639
- const t = this.getDrawEventFromEvent(r);
2637
+ return [new H({ name: "pointerdown", callback: (s) => {
2638
+ if (!this._currentModeCallbacks || !s.isPrimary) return;
2639
+ const t = this.getDrawEventFromEvent(s);
2640
2640
  t && (this._dragState = "pre-dragging", this._lastDrawEvent = t);
2641
- }, register: (r) => {
2642
- this.getMapEventElement().addEventListener("pointerdown", r);
2643
- }, unregister: (r) => {
2644
- this.getMapEventElement().removeEventListener("pointerdown", r);
2645
- } }), new H({ name: "pointermove", callback: (r) => {
2646
- if (!this._currentModeCallbacks || !r.isPrimary) return;
2647
- r.preventDefault();
2648
- const t = this.getDrawEventFromEvent(r);
2641
+ }, register: (s) => {
2642
+ this.getMapEventElement().addEventListener("pointerdown", s);
2643
+ }, unregister: (s) => {
2644
+ this.getMapEventElement().removeEventListener("pointerdown", s);
2645
+ } }), new H({ name: "pointermove", callback: (s) => {
2646
+ if (!this._currentModeCallbacks || !s.isPrimary) return;
2647
+ s.preventDefault();
2648
+ const t = this.getDrawEventFromEvent(s);
2649
2649
  if (t) if (this._dragState === "not-dragging") this._currentModeCallbacks.onMouseMove(t), this._lastDrawEvent = t;
2650
2650
  else if (this._dragState === "pre-dragging") {
2651
2651
  if (!this._lastDrawEvent) return;
2652
- const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), s = ((a, l) => {
2652
+ const e = { x: this._lastDrawEvent.containerX, y: this._lastDrawEvent.containerY }, i = { x: t.containerX, y: t.containerY }, o = this._currentModeCallbacks.getState(), r = ((a, l) => {
2653
2653
  const { x: d, y: c } = a, { x: h, y: u } = l, p = h - d, g = u - c;
2654
2654
  return Math.sqrt(g * g + p * p);
2655
2655
  })(e, i);
2656
2656
  let n = !1;
2657
- if (n = o === "drawing" ? s < this._minPixelDragDistanceDrawing : o === "selecting" ? s < this._minPixelDragDistanceSelecting : s < this._minPixelDragDistance, n) return;
2657
+ if (n = o === "drawing" ? r < this._minPixelDragDistanceDrawing : o === "selecting" ? r < this._minPixelDragDistanceSelecting : r < this._minPixelDragDistance, n) return;
2658
2658
  this._dragState = "dragging", this._currentModeCallbacks.onDragStart(t, (a) => {
2659
2659
  this.setDraggability.bind(this)(a);
2660
2660
  });
2661
2661
  } else this._dragState === "dragging" && this._currentModeCallbacks.onDrag(t, (e) => {
2662
2662
  this.setDraggability.bind(this)(e);
2663
2663
  });
2664
- }, register: (r) => {
2665
- this.getMapEventElement().addEventListener("pointermove", r);
2666
- }, unregister: (r) => {
2667
- this.getMapEventElement().removeEventListener("pointermove", r);
2668
- } }), new H({ name: "contextmenu", callback: (r) => {
2669
- this._currentModeCallbacks && r.preventDefault();
2670
- }, register: (r) => {
2671
- this.getMapEventElement().addEventListener("contextmenu", r);
2672
- }, unregister: (r) => {
2673
- this.getMapEventElement().removeEventListener("contextmenu", r);
2674
- } }), new H({ name: "pointerup", callback: (r) => {
2675
- if (!this._currentModeCallbacks || r.target !== this.getMapEventElement() || !r.isPrimary) return;
2676
- const t = this.getDrawEventFromEvent(r);
2664
+ }, register: (s) => {
2665
+ this.getMapEventElement().addEventListener("pointermove", s);
2666
+ }, unregister: (s) => {
2667
+ this.getMapEventElement().removeEventListener("pointermove", s);
2668
+ } }), new H({ name: "contextmenu", callback: (s) => {
2669
+ this._currentModeCallbacks && s.preventDefault();
2670
+ }, register: (s) => {
2671
+ this.getMapEventElement().addEventListener("contextmenu", s);
2672
+ }, unregister: (s) => {
2673
+ this.getMapEventElement().removeEventListener("contextmenu", s);
2674
+ } }), new H({ name: "pointerup", callback: (s) => {
2675
+ if (!this._currentModeCallbacks || s.target !== this.getMapEventElement() || !s.isPrimary) return;
2676
+ const t = this.getDrawEventFromEvent(s);
2677
2677
  t && (this._dragState === "dragging" ? this._currentModeCallbacks.onDragEnd(t, (e) => {
2678
2678
  this.setDraggability.bind(this)(e);
2679
2679
  }) : this._dragState !== "not-dragging" && this._dragState !== "pre-dragging" || this._currentModeCallbacks.onClick(t), this._dragState = "not-dragging", this.setDraggability(!0));
2680
- }, register: (r) => {
2681
- this.getMapEventElement().addEventListener("pointerup", r);
2682
- }, unregister: (r) => {
2683
- this.getMapEventElement().removeEventListener("pointerup", r);
2684
- } }), new H({ name: "keyup", callback: (r) => {
2685
- this._currentModeCallbacks && (this._heldKeys.delete(r.key), this._currentModeCallbacks.onKeyUp({ key: r.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => r.preventDefault() }));
2686
- }, register: (r) => {
2687
- this.getMapEventElement().addEventListener("keyup", r);
2688
- }, unregister: (r) => {
2689
- this.getMapEventElement().removeEventListener("keyup", r);
2690
- } }), new H({ name: "keydown", callback: (r) => {
2691
- this._currentModeCallbacks && (this._heldKeys.add(r.key), this._currentModeCallbacks.onKeyDown({ key: r.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => r.preventDefault() }));
2692
- }, register: (r) => {
2693
- this.getMapEventElement().addEventListener("keydown", r);
2694
- }, unregister: (r) => {
2695
- this.getMapEventElement().removeEventListener("keydown", r);
2680
+ }, register: (s) => {
2681
+ this.getMapEventElement().addEventListener("pointerup", s);
2682
+ }, unregister: (s) => {
2683
+ this.getMapEventElement().removeEventListener("pointerup", s);
2684
+ } }), new H({ name: "keyup", callback: (s) => {
2685
+ this._currentModeCallbacks && (this._heldKeys.delete(s.key), this._currentModeCallbacks.onKeyUp({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
2686
+ }, register: (s) => {
2687
+ this.getMapEventElement().addEventListener("keyup", s);
2688
+ }, unregister: (s) => {
2689
+ this.getMapEventElement().removeEventListener("keyup", s);
2690
+ } }), new H({ name: "keydown", callback: (s) => {
2691
+ this._currentModeCallbacks && (this._heldKeys.add(s.key), this._currentModeCallbacks.onKeyDown({ key: s.key, heldKeys: Array.from(this._heldKeys), preventDefault: () => s.preventDefault() }));
2692
+ }, register: (s) => {
2693
+ this.getMapEventElement().addEventListener("keydown", s);
2694
+ }, unregister: (s) => {
2695
+ this.getMapEventElement().removeEventListener("keydown", s);
2696
2696
  } })];
2697
2697
  }
2698
2698
  unregister() {
2699
- this._listeners.forEach((r) => {
2700
- r.unregister();
2699
+ this._listeners.forEach((s) => {
2700
+ s.unregister();
2701
2701
  }), this.clear();
2702
2702
  }
2703
2703
  };
2704
- class Pi extends Ci {
2704
+ class Ii extends bi {
2705
2705
  constructor(t) {
2706
2706
  super(t), this._nextRender = void 0, this._map = void 0, this._container = void 0, this._rendered = !1, this.changedIds = { deletion: !1, points: !1, linestrings: !1, polygons: !1, styling: !1 }, this._map = t.map, this._container = this._map.getContainer();
2707
2707
  }
@@ -2769,18 +2769,18 @@ class Pi extends Ci {
2769
2769
  }
2770
2770
  render(t, e) {
2771
2771
  this.updateChangedIds(t), this._nextRender && cancelAnimationFrame(this._nextRender), this._nextRender = requestAnimationFrame(() => {
2772
- const i = [...t.created, ...t.updated, ...t.unchanged], o = [], s = [], n = [];
2772
+ const i = [...t.created, ...t.updated, ...t.unchanged], o = [], r = [], n = [];
2773
2773
  for (let a = 0; a < i.length; a++) {
2774
2774
  const l = i[a], { properties: d } = l, c = e[d.mode](l);
2775
- l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, s.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, n.push(l));
2775
+ l.geometry.type === "Point" ? (d.pointColor = c.pointColor, d.pointOutlineColor = c.pointOutlineColor, d.pointOutlineWidth = c.pointOutlineWidth, d.pointWidth = c.pointWidth, o.push(l)) : l.geometry.type === "LineString" ? (d.lineStringColor = c.lineStringColor, d.lineStringWidth = c.lineStringWidth, r.push(l)) : l.geometry.type === "Polygon" && (d.polygonFillColor = c.polygonFillColor, d.polygonFillOpacity = c.polygonFillOpacity, d.polygonOutlineColor = c.polygonOutlineColor, d.polygonOutlineWidth = c.polygonOutlineWidth, n.push(l));
2776
2776
  }
2777
2777
  if (this._rendered) {
2778
2778
  const a = this.changedIds.deletion || this.changedIds.styling, l = a || this.changedIds.linestrings, d = a || this.changedIds.polygons;
2779
2779
  let c;
2780
- (a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", s), d && this._setGeoJSONLayerData("Polygon", n), c && this._map.moveLayer(c);
2780
+ (a || this.changedIds.points) && (c = this._setGeoJSONLayerData("Point", o)), l && this._setGeoJSONLayerData("LineString", r), d && this._setGeoJSONLayerData("Polygon", n), c && this._map.moveLayer(c);
2781
2781
  } else {
2782
2782
  const a = this._addGeoJSONLayer("Point", o);
2783
- this._addGeoJSONLayer("LineString", s), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
2783
+ this._addGeoJSONLayer("LineString", r), this._addGeoJSONLayer("Polygon", n), this._rendered = !0, a && this._map.moveLayer(a);
2784
2784
  }
2785
2785
  this.changedIds = { points: !1, linestrings: !1, polygons: !1, deletion: !1, styling: !1 };
2786
2786
  });
@@ -2799,7 +2799,7 @@ class Pi extends Ci {
2799
2799
  super.register(t), (e = this._currentModeCallbacks) != null && e.onReady && this._currentModeCallbacks.onReady();
2800
2800
  }
2801
2801
  }
2802
- const io = [
2802
+ const ho = [
2803
2803
  "render",
2804
2804
  "point",
2805
2805
  "linestring",
@@ -2814,7 +2814,7 @@ const io = [
2814
2814
  "delete-selection",
2815
2815
  "delete",
2816
2816
  "download"
2817
- ], Si = {
2817
+ ], Mi = {
2818
2818
  modes: [
2819
2819
  "render",
2820
2820
  "point",
@@ -2852,7 +2852,7 @@ const io = [
2852
2852
  open: !1,
2853
2853
  // see styling parameters of Terra Draw at https://github.com/JamesLMilner/terra-draw/blob/main/guides/5.STYLING.md
2854
2854
  modeOptions: {
2855
- point: new me({
2855
+ point: new Se({
2856
2856
  styles: {
2857
2857
  pointColor: "#FFFFFF",
2858
2858
  pointWidth: 5,
@@ -2860,7 +2860,7 @@ const io = [
2860
2860
  pointOutlineWidth: 1
2861
2861
  }
2862
2862
  }),
2863
- linestring: new ye({
2863
+ linestring: new Ce({
2864
2864
  styles: {
2865
2865
  lineStringColor: "#232E3D",
2866
2866
  lineStringWidth: 2,
@@ -2870,7 +2870,7 @@ const io = [
2870
2870
  closingPointOutlineWidth: 1
2871
2871
  }
2872
2872
  }),
2873
- polygon: new ve({
2873
+ polygon: new xe({
2874
2874
  styles: {
2875
2875
  fillColor: "#EDEFF0",
2876
2876
  fillOpacity: 0.7,
@@ -2882,7 +2882,7 @@ const io = [
2882
2882
  closingPointOutlineWidth: 1
2883
2883
  }
2884
2884
  }),
2885
- rectangle: new Ce({
2885
+ rectangle: new be({
2886
2886
  styles: {
2887
2887
  fillColor: "#EDEFF0",
2888
2888
  fillOpacity: 0.7,
@@ -2890,7 +2890,7 @@ const io = [
2890
2890
  outlineWidth: 2
2891
2891
  }
2892
2892
  }),
2893
- "angled-rectangle": new we({
2893
+ "angled-rectangle": new De({
2894
2894
  styles: {
2895
2895
  fillColor: "#EDEFF0",
2896
2896
  fillOpacity: 0.7,
@@ -2898,7 +2898,7 @@ const io = [
2898
2898
  outlineWidth: 2
2899
2899
  }
2900
2900
  }),
2901
- circle: new ce({
2901
+ circle: new ge({
2902
2902
  styles: {
2903
2903
  fillColor: "#EDEFF0",
2904
2904
  fillOpacity: 0.7,
@@ -2906,7 +2906,7 @@ const io = [
2906
2906
  outlineWidth: 2
2907
2907
  }
2908
2908
  }),
2909
- freehand: new he({
2909
+ freehand: new ye({
2910
2910
  styles: {
2911
2911
  fillColor: "#EDEFF0",
2912
2912
  fillOpacity: 0.7,
@@ -2918,7 +2918,7 @@ const io = [
2918
2918
  closingPointOutlineWidth: 1
2919
2919
  }
2920
2920
  }),
2921
- sensor: new Oe({
2921
+ sensor: new ke({
2922
2922
  styles: {
2923
2923
  fillColor: "#EDEFF0",
2924
2924
  fillOpacity: 0.7,
@@ -2930,7 +2930,7 @@ const io = [
2930
2930
  centerPointOutlineWidth: 1
2931
2931
  }
2932
2932
  }),
2933
- sector: new Ee({
2933
+ sector: new _e({
2934
2934
  styles: {
2935
2935
  fillColor: "#EDEFF0",
2936
2936
  fillOpacity: 0.7,
@@ -2938,7 +2938,7 @@ const io = [
2938
2938
  outlineWidth: 2
2939
2939
  }
2940
2940
  }),
2941
- select: new be({
2941
+ select: new Ee({
2942
2942
  flags: {
2943
2943
  point: {
2944
2944
  feature: {
@@ -3192,28 +3192,28 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3192
3192
  distancePrecision: 2,
3193
3193
  areaUnit: "metric",
3194
3194
  areaPrecision: 2
3195
- }, xi = () => ({
3195
+ }, wi = () => ({
3196
3196
  render: new et({
3197
3197
  modeName: "render",
3198
3198
  styles: {}
3199
3199
  }),
3200
- point: new me(),
3201
- linestring: new ye(),
3202
- polygon: new ve({
3200
+ point: new Se(),
3201
+ linestring: new Ce(),
3202
+ polygon: new xe({
3203
3203
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3204
3204
  // @ts-ignore
3205
3205
  validation: (t, e) => {
3206
3206
  const i = e.updateType;
3207
- return i === "finish" || i === "commit" ? mi(t) : { valid: !0 };
3207
+ return i === "finish" || i === "commit" ? Si(t) : { valid: !0 };
3208
3208
  }
3209
3209
  }),
3210
- rectangle: new Ce(),
3211
- "angled-rectangle": new we(),
3212
- circle: new ce(),
3213
- freehand: new he(),
3214
- sensor: new Oe(),
3215
- sector: new Ee(),
3216
- select: new be({
3210
+ rectangle: new be(),
3211
+ "angled-rectangle": new De(),
3212
+ circle: new ge(),
3213
+ freehand: new ye(),
3214
+ sensor: new ke(),
3215
+ sector: new _e(),
3216
+ select: new Ee({
3217
3217
  flags: {
3218
3218
  point: {
3219
3219
  feature: {
@@ -3326,65 +3326,652 @@ Alt. `, ["to-string", ["floor", ["get", "elevation"]]], " m"],
3326
3326
  modeName: "download",
3327
3327
  styles: {}
3328
3328
  })
3329
- }), te = (r) => r.charAt(0).toUpperCase() + r.slice(1), xt = ["td-point", "td-linestring", "td-polygon"];
3330
- var re, ne, ae;
3331
- const oo = [
3329
+ });
3330
+ var _ = 63710088e-1, Fi = {
3331
+ centimeters: _ * 100,
3332
+ centimetres: _ * 100,
3333
+ degrees: 360 / (2 * Math.PI),
3334
+ feet: _ * 3.28084,
3335
+ inches: _ * 39.37,
3336
+ kilometers: _ / 1e3,
3337
+ kilometres: _ / 1e3,
3338
+ meters: _,
3339
+ metres: _,
3340
+ miles: _ / 1609.344,
3341
+ millimeters: _ * 1e3,
3342
+ millimetres: _ * 1e3,
3343
+ nauticalmiles: _ / 1852,
3344
+ radians: 1,
3345
+ yards: _ * 1.0936
3346
+ };
3347
+ function Ei(s, t, e = {}) {
3348
+ const i = { type: "Feature" };
3349
+ return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = s, i;
3350
+ }
3351
+ function Oi(s, t, e = {}) {
3352
+ if (!s)
3353
+ throw new Error("coordinates is required");
3354
+ if (!Array.isArray(s))
3355
+ throw new Error("coordinates must be an Array");
3356
+ if (s.length < 2)
3357
+ throw new Error("coordinates must be at least 2 numbers long");
3358
+ if (!te(s[0]) || !te(s[1]))
3359
+ throw new Error("coordinates must contain numbers");
3360
+ return Ei({
3361
+ type: "Point",
3362
+ coordinates: s
3363
+ }, t, e);
3364
+ }
3365
+ function Di(s, t = "kilometers") {
3366
+ const e = Fi[t];
3367
+ if (!e)
3368
+ throw new Error(t + " units is invalid");
3369
+ return s * e;
3370
+ }
3371
+ function ht(s) {
3372
+ return s % 360 * Math.PI / 180;
3373
+ }
3374
+ function te(s) {
3375
+ return !isNaN(s) && s !== null && !Array.isArray(s);
3376
+ }
3377
+ function We(s, t, e) {
3378
+ if (s !== null)
3379
+ for (var i, o, r, n, a, l, d, c = 0, h = 0, u, p = s.type, g = p === "FeatureCollection", y = p === "Feature", v = g ? s.features.length : 1, f = 0; f < v; f++) {
3380
+ d = g ? s.features[f].geometry : y ? s.geometry : s, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
3381
+ for (var m = 0; m < a; m++) {
3382
+ var C = 0, P = 0;
3383
+ if (n = u ? d.geometries[m] : d, n !== null) {
3384
+ l = n.coordinates;
3385
+ var S = n.type;
3386
+ switch (c = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
3387
+ case null:
3388
+ break;
3389
+ case "Point":
3390
+ if (t(
3391
+ l,
3392
+ h,
3393
+ f,
3394
+ C,
3395
+ P
3396
+ ) === !1)
3397
+ return !1;
3398
+ h++, C++;
3399
+ break;
3400
+ case "LineString":
3401
+ case "MultiPoint":
3402
+ for (i = 0; i < l.length; i++) {
3403
+ if (t(
3404
+ l[i],
3405
+ h,
3406
+ f,
3407
+ C,
3408
+ P
3409
+ ) === !1)
3410
+ return !1;
3411
+ h++, S === "MultiPoint" && C++;
3412
+ }
3413
+ S === "LineString" && C++;
3414
+ break;
3415
+ case "Polygon":
3416
+ case "MultiLineString":
3417
+ for (i = 0; i < l.length; i++) {
3418
+ for (o = 0; o < l[i].length - c; o++) {
3419
+ if (t(
3420
+ l[i][o],
3421
+ h,
3422
+ f,
3423
+ C,
3424
+ P
3425
+ ) === !1)
3426
+ return !1;
3427
+ h++;
3428
+ }
3429
+ S === "MultiLineString" && C++, S === "Polygon" && P++;
3430
+ }
3431
+ S === "Polygon" && C++;
3432
+ break;
3433
+ case "MultiPolygon":
3434
+ for (i = 0; i < l.length; i++) {
3435
+ for (P = 0, o = 0; o < l[i].length; o++) {
3436
+ for (r = 0; r < l[i][o].length - c; r++) {
3437
+ if (t(
3438
+ l[i][o][r],
3439
+ h,
3440
+ f,
3441
+ C,
3442
+ P
3443
+ ) === !1)
3444
+ return !1;
3445
+ h++;
3446
+ }
3447
+ P++;
3448
+ }
3449
+ C++;
3450
+ }
3451
+ break;
3452
+ case "GeometryCollection":
3453
+ for (i = 0; i < n.geometries.length; i++)
3454
+ if (We(n.geometries[i], t) === !1)
3455
+ return !1;
3456
+ break;
3457
+ default:
3458
+ throw new Error("Unknown Geometry Type");
3459
+ }
3460
+ }
3461
+ }
3462
+ }
3463
+ }
3464
+ function Li(s, t) {
3465
+ var e, i, o, r, n, a, l, d, c, h, u = 0, p = s.type === "FeatureCollection", g = s.type === "Feature", y = p ? s.features.length : 1;
3466
+ for (e = 0; e < y; e++) {
3467
+ for (a = p ? s.features[e].geometry : g ? s.geometry : s, d = p ? s.features[e].properties : g ? s.properties : {}, c = p ? s.features[e].bbox : g ? s.bbox : void 0, h = p ? s.features[e].id : g ? s.id : void 0, l = a ? a.type === "GeometryCollection" : !1, n = l ? a.geometries.length : 1, o = 0; o < n; o++) {
3468
+ if (r = l ? a.geometries[o] : a, r === null) {
3469
+ if (t(
3470
+ null,
3471
+ u,
3472
+ d,
3473
+ c,
3474
+ h
3475
+ ) === !1)
3476
+ return !1;
3477
+ continue;
3478
+ }
3479
+ switch (r.type) {
3480
+ case "Point":
3481
+ case "LineString":
3482
+ case "MultiPoint":
3483
+ case "Polygon":
3484
+ case "MultiLineString":
3485
+ case "MultiPolygon": {
3486
+ if (t(
3487
+ r,
3488
+ u,
3489
+ d,
3490
+ c,
3491
+ h
3492
+ ) === !1)
3493
+ return !1;
3494
+ break;
3495
+ }
3496
+ case "GeometryCollection": {
3497
+ for (i = 0; i < r.geometries.length; i++)
3498
+ if (t(
3499
+ r.geometries[i],
3500
+ u,
3501
+ d,
3502
+ c,
3503
+ h
3504
+ ) === !1)
3505
+ return !1;
3506
+ break;
3507
+ }
3508
+ default:
3509
+ throw new Error("Unknown Geometry Type");
3510
+ }
3511
+ }
3512
+ u++;
3513
+ }
3514
+ }
3515
+ function _i(s, t, e) {
3516
+ var i = e;
3517
+ return Li(
3518
+ s,
3519
+ function(o, r, n, a, l) {
3520
+ r === 0 && e === void 0 ? i = o : i = t(
3521
+ i,
3522
+ o,
3523
+ r,
3524
+ n,
3525
+ a,
3526
+ l
3527
+ );
3528
+ }
3529
+ ), i;
3530
+ }
3531
+ function ki(s) {
3532
+ return _i(
3533
+ s,
3534
+ (t, e) => t + Wi(e),
3535
+ 0
3536
+ );
3537
+ }
3538
+ function Wi(s) {
3539
+ let t = 0, e;
3540
+ switch (s.type) {
3541
+ case "Polygon":
3542
+ return ee(s.coordinates);
3543
+ case "MultiPolygon":
3544
+ for (e = 0; e < s.coordinates.length; e++)
3545
+ t += ee(s.coordinates[e]);
3546
+ return t;
3547
+ case "Point":
3548
+ case "MultiPoint":
3549
+ case "LineString":
3550
+ case "MultiLineString":
3551
+ return 0;
3552
+ }
3553
+ return 0;
3554
+ }
3555
+ function ee(s) {
3556
+ let t = 0;
3557
+ if (s && s.length > 0) {
3558
+ t += Math.abs(ie(s[0]));
3559
+ for (let e = 1; e < s.length; e++)
3560
+ t -= Math.abs(ie(s[e]));
3561
+ }
3562
+ return t;
3563
+ }
3564
+ var ji = _ * _ / 2, Et = Math.PI / 180;
3565
+ function ie(s) {
3566
+ const t = s.length - 1;
3567
+ if (t <= 2) return 0;
3568
+ let e = 0, i = 0;
3569
+ for (; i < t; ) {
3570
+ const o = s[i], r = s[i + 1 === t ? 0 : i + 1], n = s[i + 2 >= t ? (i + 2) % t : i + 2], a = o[0] * Et, l = r[1] * Et, d = n[0] * Et;
3571
+ e += (d - a) * Math.sin(l), i++;
3572
+ }
3573
+ return e * ji;
3574
+ }
3575
+ var Bi = ki;
3576
+ const Ni = (s, t) => {
3577
+ let e = s, i = "m²";
3578
+ return t === "metric" ? s >= 1e6 ? (e = s / 1e6, i = "km²") : s >= 1e4 && (e = s / 1e4, i = "ha") : s >= 258998811e-2 ? (e = s / 258998811e-2, i = "mi²") : s >= 4046.856 ? (e = s / 4046.856, i = "acre") : s >= 0.83612736 && (e = s / 0.83612736, i = "yd²"), { area: e, unit: i };
3579
+ }, oe = (s, t, e) => {
3580
+ if (s.geometry.type !== "Polygon") return s;
3581
+ const i = Bi(s.geometry), o = Ni(i, t);
3582
+ return o.area = parseFloat(o.area.toFixed(e)), s.properties.area = o.area, s.properties.unit = o.unit, s;
3583
+ };
3584
+ function se(s) {
3585
+ if (!s)
3586
+ throw new Error("coord is required");
3587
+ if (!Array.isArray(s)) {
3588
+ if (s.type === "Feature" && s.geometry !== null && s.geometry.type === "Point")
3589
+ return [...s.geometry.coordinates];
3590
+ if (s.type === "Point")
3591
+ return [...s.coordinates];
3592
+ }
3593
+ if (Array.isArray(s) && s.length >= 2 && !Array.isArray(s[0]) && !Array.isArray(s[1]))
3594
+ return [...s];
3595
+ throw new Error("coord must be GeoJSON Point or an Array of numbers");
3596
+ }
3597
+ function Ai(s, t, e = {}) {
3598
+ var i = se(s), o = se(t), r = ht(o[1] - i[1]), n = ht(o[0] - i[0]), a = ht(i[1]), l = ht(o[1]), d = Math.pow(Math.sin(r / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3599
+ return Di(
3600
+ 2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3601
+ e.units
3602
+ );
3603
+ }
3604
+ var Gi = Ai;
3605
+ const Ti = (s) => s === "degrees" ? "°" : s === "miles" ? "mi" : s === "radians" ? "rad" : "km", re = (s, t, e, i, o, r) => {
3606
+ if (s.geometry.type !== "LineString") return s;
3607
+ const n = s.geometry.coordinates;
3608
+ let a = 0;
3609
+ const l = [];
3610
+ for (let d = 0; d < n.length - 1; d++) {
3611
+ const c = n[d], h = n[d + 1], u = Gi(c, h, { units: t });
3612
+ a += u;
3613
+ const p = JSON.parse(JSON.stringify(s));
3614
+ if (p.id = `${p.id}-${d}`, p.geometry.coordinates = [c, h], p.properties.originalId = s.id, p.properties.distance = parseFloat(u.toFixed(e)), p.properties.total = parseFloat(a.toFixed(e)), p.properties.unit = Ti(t), o === !0 && r === void 0) {
3615
+ const g = i == null ? void 0 : i.queryTerrainElevation(c);
3616
+ g && (p.properties.elevation_start = g);
3617
+ const y = i == null ? void 0 : i.queryTerrainElevation(h);
3618
+ y && (p.properties.elevation_end = y);
3619
+ }
3620
+ l.push(p);
3621
+ }
3622
+ return s.properties.distance = l[l.length - 1].properties.total, s.properties.unit = l[l.length - 1].properties.unit, s.properties.segments = JSON.parse(JSON.stringify(l)), s;
3623
+ }, ne = (s) => s.charAt(0).toUpperCase() + s.slice(1), xt = ["td-point", "td-linestring", "td-polygon"];
3624
+ var de, ce, he;
3625
+ const uo = [
3332
3626
  ...xt,
3333
- (re = ut.polygonLayerSpec) == null ? void 0 : re.source,
3334
- (ne = ut.lineLayerLabelSpec) == null ? void 0 : ne.source,
3335
- (ae = ut.pointLayerLabelSpec) == null ? void 0 : ae.source
3336
- ], De = (r, t, e = xt) => {
3337
- const i = JSON.parse(JSON.stringify(r));
3627
+ (de = ut.polygonLayerSpec) == null ? void 0 : de.source,
3628
+ (ce = ut.lineLayerLabelSpec) == null ? void 0 : ce.source,
3629
+ (he = ut.pointLayerLabelSpec) == null ? void 0 : he.source
3630
+ ], je = (s, t, e = xt) => {
3631
+ const i = JSON.parse(JSON.stringify(s));
3338
3632
  return t && (t.onlyTerraDrawLayers === !0 ? (i.layers = i.layers.filter((o) => "source" in o && e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
3339
3633
  e.includes(o) || delete i.sources[o];
3340
3634
  })) : t.excludeTerraDrawLayers === !0 && (i.layers = i.layers.filter((o) => "source" in o && !e.includes(o.source)), Object.keys(i.sources).forEach((o) => {
3341
3635
  e.includes(o) && delete i.sources[o];
3342
3636
  }))), i;
3343
- }, Ii = (r, t = 250) => {
3637
+ }, Vi = (s, t = 250) => {
3344
3638
  let e;
3345
3639
  return (...i) => {
3346
- clearTimeout(e), e = setTimeout(() => r(...i), t);
3640
+ clearTimeout(e), e = setTimeout(() => s(...i), t);
3347
3641
  };
3642
+ }, ae = (s, t, e, i) => {
3643
+ if (s.geometry.type !== "Point") return s;
3644
+ const o = s.geometry.coordinates;
3645
+ if (e === !0 && i === void 0) {
3646
+ const r = t == null ? void 0 : t.queryTerrainElevation(o);
3647
+ r && (s.properties.elevation = r);
3648
+ }
3649
+ return s;
3348
3650
  };
3349
- class bi {
3651
+ var Ui = Object.defineProperty, zi = (s, t, e) => t in s ? Ui(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, tt = (s, t, e) => zi(s, typeof t != "symbol" ? t + "" : t, e), mt = 2 * Math.PI * 6378137 / 2;
3652
+ function Ri(s) {
3653
+ return s = s || 256, 2 * Math.PI * 6378137 / s;
3654
+ }
3655
+ function Xi(s, t, e = { enable: !0, decimal: 1 }) {
3656
+ s = _t(s);
3657
+ var i = s[0], o = s[1], r = i * mt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
3658
+ return n = n * mt / 180, e.enable && (r = Number(r.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [r, n];
3659
+ }
3660
+ function Ki(s, t, e) {
3661
+ var i = s[0], o = s[1], r = Zi(t, e), n = (i + mt) / r, a = (o + mt) / r;
3662
+ return [n, a, t];
3663
+ }
3664
+ function Be(s, t, e) {
3665
+ s = _t(s);
3666
+ var i = Xi(s), o = Ki(i, t);
3667
+ return $i(o);
3668
+ }
3669
+ function Yi(s, t, e) {
3670
+ if (s = _t(s), t === 0)
3671
+ return [0, 0, 0];
3672
+ var i = Be(s, t);
3673
+ return Hi(i);
3674
+ }
3675
+ function $i(s, t, e) {
3676
+ t = t || 256;
3677
+ var i = s[0], o = s[1], r = s[2];
3678
+ if (r === 0) return [0, 0, 0];
3679
+ Ne(r);
3680
+ var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
3681
+ return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, r];
3682
+ }
3683
+ function Hi(s, t) {
3684
+ qi(s);
3685
+ var e = s[0], i = s[1], o = s[2];
3686
+ if (o === 0)
3687
+ return [0, 0, 0];
3688
+ var r = e, n = Math.pow(2, o) - 1 - i;
3689
+ return [r, n, o];
3690
+ }
3691
+ function qi(s, t) {
3692
+ var e = s[0], i = s[1], o = s[2];
3693
+ if (o == null) throw new Error("<zoom> is required");
3694
+ if (e == null) throw new Error("<x> is required");
3695
+ if (i == null) throw new Error("<y> is required");
3696
+ return o = Ne(o), s = Ji(s), s;
3697
+ }
3698
+ function Ji(s) {
3699
+ var t = s[0], e = s[1], i = s[2], o = Math.pow(2, i);
3700
+ return t = t % o, t < 0 && (t = t + o), [t, e, i];
3701
+ }
3702
+ function Ne(s) {
3703
+ if (s === !1) return s;
3704
+ if (s == null)
3705
+ throw new Error("<zoom> is required");
3706
+ if (s < 0)
3707
+ throw new Error("<zoom> cannot be less than 0");
3708
+ if (s > 32)
3709
+ throw new Error("<zoom> cannot be greater than 32");
3710
+ return s;
3711
+ }
3712
+ function _t(s, t) {
3713
+ var e = to(s[0]), i = Qi(s[1]);
3714
+ return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
3715
+ }
3716
+ function Zi(s, t) {
3717
+ return Ri(t) / Math.pow(2, s);
3718
+ }
3719
+ function Qi(s) {
3720
+ if (s == null) throw new Error("lat is required");
3721
+ return (s > 90 || s < -90) && (s = s % 180, s > 90 && (s = -180 + s), s < -90 && (s = 180 + s), s === 0 && (s = 0)), s;
3722
+ }
3723
+ function to(s) {
3724
+ if (s == null) throw new Error("lng is required");
3725
+ return (s > 180 || s < -180) && (s = s % 360, s > 180 && (s = -360 + s), s < -180 && (s = 360 + s), s === 0 && (s = 0)), s;
3726
+ }
3727
+ class Ae {
3350
3728
  /**
3351
3729
  * Constructor
3352
- * @param options Plugin control options
3353
- */
3354
- constructor(t) {
3355
- _(this, "controlContainer");
3356
- _(this, "map");
3357
- _(this, "modeButtons", {});
3358
- _(this, "_isExpanded", !1);
3359
- _(this, "terradraw");
3360
- _(this, "options", Si);
3361
- _(this, "events", {});
3362
- _(this, "defaultMode", "render");
3363
- this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
3364
- }
3365
- /**
3366
- * get the state of whether the control is expanded or collapsed
3730
+ * @param url URL for terrain RGB raster tilesets
3731
+ * @param tileSize size of tile. 256 or 512
3732
+ * @param tms whether it is Tile Map Service
3733
+ * @param minzoom minzoom for terrain RGB raster tilesets
3734
+ * @param maxzoom maxzoom for terrain RGB raster tilesets
3735
+ * @param tms whether it is Tile Map Service
3367
3736
  */
3368
- get isExpanded() {
3369
- return this._isExpanded;
3737
+ constructor(t, e, i, o, r) {
3738
+ tt(this, "url"), tt(this, "tileSize"), tt(this, "tms"), tt(this, "minzoom"), tt(this, "maxzoom"), this.url = t, this.tileSize = e, this.tms = r, this.minzoom = i, this.maxzoom = o, this.tms = r;
3370
3739
  }
3371
3740
  /**
3372
- * set the state of the control either expanded or collapsed.
3373
- * terradraw mode will be reset if the state is changed.
3374
- * either `expanded` or `collapsed` event is dispatched when changed
3741
+ * Get the value from target coordinates and zoom level by using certain formula.
3742
+ * @param lnglat coordinates
3743
+ * @param z zoom level
3744
+ * @returns the value calculated by certain formula
3375
3745
  */
3376
- set isExpanded(t) {
3377
- var o, s;
3378
- this._isExpanded = t;
3379
- const e = document.getElementsByClassName("maplibregl-terradraw-add-control");
3380
- for (let n = 0; n < e.length; n++) {
3381
- const a = e.item(n);
3382
- a && (this.isExpanded ? a.classList.remove("hidden") : a.classList.add("hidden"));
3383
- }
3384
- const i = document.getElementsByClassName("maplibregl-terradraw-render-button");
3385
- i && i.length > 0 && (this.isExpanded ? (o = i.item(0)) == null || o.classList.add("enabled") : ((s = i.item(0)) == null || s.classList.remove("enabled"), this.resetActiveMode())), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.isExpanded ? this.dispatchEvent("expanded") : this.dispatchEvent("collapsed");
3386
- }
3387
- /**
3746
+ getValue(t, e) {
3747
+ return new Promise(
3748
+ (i, o) => {
3749
+ const r = t[0], n = t[1];
3750
+ let a = e;
3751
+ e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
3752
+ const l = this.tms ? Be([r, n], a) : Yi([r, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
3753
+ let c = this.getUrlExtension(d);
3754
+ switch (c || (c = "png"), c) {
3755
+ case "png":
3756
+ case "webp":
3757
+ this.getValueFromRaster(d, l, r, n).then((h) => {
3758
+ i(h);
3759
+ });
3760
+ break;
3761
+ default:
3762
+ o(new Error(`Invalid file extension: ${c}`));
3763
+ break;
3764
+ }
3765
+ }
3766
+ );
3767
+ }
3768
+ /**
3769
+ * Get the value calculated from coordinates on WEBP raster tileset
3770
+ * @param url tile URL
3771
+ * @param tile tile index info
3772
+ * @param lng longitude
3773
+ * @param lat latitude
3774
+ * @returns the value calculated from coordinates. If tile does not exist returns undefined
3775
+ */
3776
+ async getValueFromRaster(t, e, i, o) {
3777
+ const r = await fetch(t);
3778
+ if (!r.ok) {
3779
+ if (r.status === 404)
3780
+ return;
3781
+ throw new Error(`Failed to fetch tile: ${r.statusText}`);
3782
+ }
3783
+ const n = await r.blob();
3784
+ return new Promise((a, l) => {
3785
+ const d = new Image();
3786
+ d.onload = () => {
3787
+ const c = document.createElement("canvas");
3788
+ c.width = d.width, c.height = d.height;
3789
+ const h = c.getContext("2d");
3790
+ if (!h) return l(new Error("Failed to create canvas context"));
3791
+ h.drawImage(d, 0, 0);
3792
+ const u = h.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), g = this.calc(p[0], p[1], p[2], p[3]);
3793
+ a(g);
3794
+ }, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
3795
+ });
3796
+ }
3797
+ /**
3798
+ * Get RGBA values from coordinates information
3799
+ * @param pixels pixels info
3800
+ * @param tile tile index info
3801
+ * @param lng longitude
3802
+ * @param lat latitude
3803
+ * @returns RGBA values
3804
+ */
3805
+ pixels2rgba(t, e, i, o) {
3806
+ const r = [];
3807
+ for (let d = 0; d < t.length; d += 4) {
3808
+ const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], g = [c, h, u, p];
3809
+ r.push(g);
3810
+ }
3811
+ const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
3812
+ return r[l];
3813
+ }
3814
+ /**
3815
+ * Get the position in pixel from the coordinates
3816
+ * @param lng longitude
3817
+ * @param lat latitude
3818
+ * @param bbox bbox (minx, miny, maxx, maxy)
3819
+ * @returns The position in pixel
3820
+ */
3821
+ getPixelPosition(t, e, i) {
3822
+ const o = this.tileSize, r = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a, c = Math.floor(o * l), h = Math.floor(r * (1 - d));
3823
+ return [c, h];
3824
+ }
3825
+ /**
3826
+ * Get file extenstion name from the URL
3827
+ * @param url URL for tilesets
3828
+ * @returns file extenstion either png or webp
3829
+ */
3830
+ getUrlExtension(t) {
3831
+ let e = t.split(/[#?]/)[0].split(".").pop();
3832
+ return e && (e = e.trim()), e;
3833
+ }
3834
+ /**
3835
+ * Get the bbox of a tile
3836
+ * @param {Array<number>} tile
3837
+ * @returns {Array<number>} bbox
3838
+ * @example
3839
+ * var bbox = tileToBBOX([5, 10, 10])
3840
+ * //=bbox
3841
+ */
3842
+ tileToBBOX(t) {
3843
+ const e = this.tile2lon(t[0] + 1, t[2]), i = this.tile2lon(t[0], t[2]), o = this.tile2lat(t[1] + 1, t[2]), r = this.tile2lat(t[1], t[2]);
3844
+ return [i, o, e, r];
3845
+ }
3846
+ tile2lon(t, e) {
3847
+ return t / Math.pow(2, e) * 360 - 180;
3848
+ }
3849
+ tile2lat(t, e) {
3850
+ const i = 180 / Math.PI, o = Math.PI - 2 * Math.PI * t / Math.pow(2, e);
3851
+ return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
3852
+ }
3853
+ }
3854
+ class eo extends Ae {
3855
+ /**
3856
+ * Constructor
3857
+ * @param url URL for terrain RGB raster tilesets
3858
+ * @param tileSize size of tile. 256 or 512
3859
+ * @param tms whether it is Tile Map Service
3860
+ * @param minzoom minzoom for terrain RGB raster tilesets. default is 5
3861
+ * @param maxzoom maxzoom for terrain RGB raster tilesets. default is 15
3862
+ */
3863
+ constructor(t, e, i = 5, o = 15, r = !1) {
3864
+ super(t, e, i, o, r);
3865
+ }
3866
+ /**
3867
+ * Get an altitude calculated from terrain RGB information
3868
+ * @param lnglat coordinates
3869
+ * @param z zoom level
3870
+ * @returns an altitude calculated from terrain RGB information
3871
+ */
3872
+ async getElevation(t, e) {
3873
+ return await this.getValue(t, e);
3874
+ }
3875
+ /**
3876
+ * Formula for calculating an elevation from RGB
3877
+ * @param r red
3878
+ * @param g green
3879
+ * @param b blue
3880
+ * @returns an elevation calculated
3881
+ */
3882
+ calc(t, e, i) {
3883
+ return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
3884
+ }
3885
+ }
3886
+ class io extends Ae {
3887
+ /**
3888
+ * Constructor
3889
+ * @param url URL for terrarium raster tilesets
3890
+ * @param tileSize size of tile. 256 or 512
3891
+ * @param tms whether it is Tile Map Service
3892
+ * @param minzoom minzoom for terrain RGB raster tilesets. default is 5
3893
+ * @param maxzoom maxzoom for terrain RGB raster tilesets. default is 15
3894
+ */
3895
+ constructor(t, e, i = 5, o = 15, r = !1) {
3896
+ super(t, e, i, o, r);
3897
+ }
3898
+ /**
3899
+ * Get an altitude calculated from terrain RGB information
3900
+ * @param lnglat coordinates
3901
+ * @param z zoom level
3902
+ * @returns an altitude calculated from terrain RGB information
3903
+ */
3904
+ async getElevation(t, e) {
3905
+ return await this.getValue(t, e);
3906
+ }
3907
+ /**
3908
+ * Formula for calculating an elevation from RGB
3909
+ * https://github.com/tilezen/joerd/blob/master/docs/formats.md#terrarium
3910
+ * @param r red
3911
+ * @param g green
3912
+ * @param b blue
3913
+ * @returns an elevation calculated
3914
+ */
3915
+ calc(t, e, i) {
3916
+ const o = t * 256 + e + i / 256 - 32768;
3917
+ return parseInt(o.toFixed(0));
3918
+ }
3919
+ }
3920
+ const le = async (s, t) => {
3921
+ const e = [];
3922
+ for (const i of s)
3923
+ e.push(
3924
+ new Promise((o) => {
3925
+ if (i.geometry.type !== "Point" && o(i), t) {
3926
+ const r = t.url, n = t.encoding ?? "mapbox", a = t.tileSize ?? 512, l = t.minzoom ?? 5, d = t.maxzoom ?? 15, c = t.tms ?? !1;
3927
+ (n === "mapbox" ? new eo(r, a, l, d, c) : new io(r, a, l, d, c)).getElevation(i.geometry.coordinates, d).then((h) => {
3928
+ h && (i.properties.elevation = h), o(i);
3929
+ }).catch(() => o(i));
3930
+ } else
3931
+ o(i);
3932
+ })
3933
+ );
3934
+ return await Promise.all(e);
3935
+ };
3936
+ class oo {
3937
+ /**
3938
+ * Constructor
3939
+ * @param options Plugin control options
3940
+ */
3941
+ constructor(t) {
3942
+ k(this, "controlContainer");
3943
+ k(this, "map");
3944
+ k(this, "modeButtons", {});
3945
+ k(this, "_isExpanded", !1);
3946
+ k(this, "terradraw");
3947
+ k(this, "options", Mi);
3948
+ k(this, "events", {});
3949
+ k(this, "defaultMode", "render");
3950
+ this.modeButtons = {}, t && (this.options = Object.assign(this.options, t));
3951
+ }
3952
+ /**
3953
+ * get the state of whether the control is expanded or collapsed
3954
+ */
3955
+ get isExpanded() {
3956
+ return this._isExpanded;
3957
+ }
3958
+ /**
3959
+ * set the state of the control either expanded or collapsed.
3960
+ * terradraw mode will be reset if the state is changed.
3961
+ * either `expanded` or `collapsed` event is dispatched when changed
3962
+ */
3963
+ set isExpanded(t) {
3964
+ var o, r;
3965
+ this._isExpanded = t;
3966
+ const e = document.getElementsByClassName("maplibregl-terradraw-add-control");
3967
+ for (let n = 0; n < e.length; n++) {
3968
+ const a = e.item(n);
3969
+ a && (this.isExpanded ? a.classList.remove("hidden") : a.classList.add("hidden"));
3970
+ }
3971
+ const i = document.getElementsByClassName("maplibregl-terradraw-render-button");
3972
+ i && i.length > 0 && (this.isExpanded ? (o = i.item(0)) == null || o.classList.add("enabled") : ((r = i.item(0)) == null || r.classList.remove("enabled"), this.resetActiveMode())), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.isExpanded ? this.dispatchEvent("expanded") : this.dispatchEvent("collapsed");
3973
+ }
3974
+ /**
3388
3975
  * Get the default control position
3389
3976
  * @returns default control position. Default is 'top-right'
3390
3977
  */
@@ -3397,12 +3984,12 @@ class bi {
3397
3984
  * @returns HTML Element
3398
3985
  */
3399
3986
  onAdd(t) {
3400
- var o, s, n, a, l;
3987
+ var o, r, n, a, l;
3401
3988
  if (this.options && this.options.modes && this.options.modes.length === 0)
3402
3989
  throw new Error("At least a mode must be enabled.");
3403
3990
  this.map = t;
3404
- const e = xi(), i = [];
3405
- return (s = (o = this.options) == null ? void 0 : o.modes) == null || s.forEach((d) => {
3991
+ const e = wi(), i = [];
3992
+ return (r = (o = this.options) == null ? void 0 : o.modes) == null || r.forEach((d) => {
3406
3993
  if (this.options.modeOptions && this.options.modeOptions[d]) {
3407
3994
  const c = this.options.modeOptions[d];
3408
3995
  if (d === "select") {
@@ -3423,8 +4010,8 @@ class bi {
3423
4010
  modeName: "default",
3424
4011
  styles: {}
3425
4012
  })
3426
- ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new vi({
3427
- adapter: new Pi({ map: t, ...this.options.adapterOptions }),
4013
+ ), this.defaultMode = "default"), this.isExpanded = this.options.open === !0, this.terradraw = new xi({
4014
+ adapter: new Ii({ map: t, ...this.options.adapterOptions }),
3428
4015
  modes: i
3429
4016
  }), this.terradraw.start(), this.controlContainer = document.createElement("div"), this.controlContainer.classList.add("maplibregl-ctrl"), this.controlContainer.classList.add("maplibregl-ctrl-group"), i.forEach((d) => {
3430
4017
  d.mode !== "default" && this.addTerradrawButton(d.mode);
@@ -3438,729 +4025,195 @@ class bi {
3438
4025
  * @returns void
3439
4026
  */
3440
4027
  onRemove() {
3441
- !this.controlContainer || !this.controlContainer.parentNode || !this.map || (this.deactivate(), this.modeButtons = {}, this.terradraw = void 0, this.map = void 0, this.controlContainer.parentNode.removeChild(this.controlContainer));
3442
- }
3443
- /**
3444
- * Register an event for the plugin
3445
- * @param event event type
3446
- * @param callback
3447
- */
3448
- on(t, e) {
3449
- this.events[t] ? this.events[t].push(e) : this.events[t] = [e];
3450
- }
3451
- /**
3452
- * Unregister an event for the plugin
3453
- * @param event event type
3454
- * @param callback
3455
- * @returns
3456
- */
3457
- off(t, e) {
3458
- if (!this.events[t]) return;
3459
- const i = this.events[t].findIndex((o) => o === e);
3460
- i !== -1 && this.events[t].splice(i, 1);
3461
- }
3462
- /**
3463
- * Dispatch an event. Pass the current snapshot of features and mode
3464
- * @param event event type
3465
- * @param args additional arguments
3466
- */
3467
- dispatchEvent(t, e) {
3468
- this.events[t] && this.events[t].forEach((i) => {
3469
- var n, a;
3470
- const o = (n = this.terradraw) == null ? void 0 : n.getSnapshot(), s = o == null ? void 0 : o.filter((l) => l.properties.selected === !0);
3471
- i({
3472
- feature: s,
3473
- mode: (a = this.terradraw) == null ? void 0 : a.getMode(),
3474
- ...e
3475
- });
3476
- });
3477
- }
3478
- /**
3479
- * Activate Terra Draw to start drawing
3480
- */
3481
- activate() {
3482
- this.terradraw && (this.terradraw.enabled || (this.terradraw.start(), this.dispatchEvent("mode-changed")));
3483
- }
3484
- /**
3485
- * Deactivate Terra Draw to stop drawing
3486
- */
3487
- deactivate() {
3488
- this.terradraw && this.terradraw.enabled && (this.resetActiveMode(), this.dispatchEvent("mode-changed"), this.terradraw.stop());
3489
- }
3490
- /**
3491
- * Get the Terra Draw instance.
3492
- * For the Terra Draw API, please refer to https://terradraw.io/#/api
3493
- * @returns Terra Draw instance
3494
- */
3495
- getTerraDrawInstance() {
3496
- return this.terradraw;
3497
- }
3498
- /**
3499
- * Toggle editor control
3500
- */
3501
- toggleEditor() {
3502
- this.terradraw && (this.isExpanded = !this.isExpanded);
3503
- }
3504
- /**
3505
- * Reset active mode to back to render mode
3506
- */
3507
- resetActiveMode() {
3508
- var e;
3509
- if (!this.terradraw) return;
3510
- this.terradraw.enabled || this.terradraw.start();
3511
- const t = document.getElementsByClassName("maplibregl-terradraw-add-control");
3512
- for (let i = 0; i < t.length; i++) {
3513
- const o = t.item(i);
3514
- o && o.classList.remove("active");
3515
- }
3516
- (e = this.terradraw) == null || e.setMode(this.defaultMode);
3517
- }
3518
- /**
3519
- * Add Terra Draw drawing mode button
3520
- * @param mode Terra Draw mode name
3521
- */
3522
- addTerradrawButton(t) {
3523
- const e = document.createElement("button");
3524
- e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = te("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = te(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
3525
- this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
3526
- })) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
3527
- var s;
3528
- if (!this.terradraw || !this.terradraw.enabled) return;
3529
- const o = ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((n) => n.properties.selected === !0);
3530
- if (o.length > 0) {
3531
- const n = o.map((a) => a.id);
3532
- this.terradraw.removeFeatures(n);
3533
- for (const a of n)
3534
- this.terradraw.deselectFeature(a);
3535
- this.dispatchEvent("feature-deleted", { deletedIds: n });
3536
- }
3537
- this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
3538
- })) : t === "download" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", this.handleDownload.bind(this))) : (e.classList.add(`maplibregl-terradraw-add-${t}-button`), e.addEventListener("click", () => {
3539
- if (!this.terradraw) return;
3540
- const i = e.classList.contains("active");
3541
- this.activate(), this.resetActiveMode(), i || (this.terradraw.setMode(t), e.classList.add("active")), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
3542
- })));
3543
- }
3544
- /**
3545
- * get GeoJSON features
3546
- * @param onlySelected If true, returns only selected features. Default is false.
3547
- * @returns FeatureCollection in GeoJSON format
3548
- */
3549
- getFeatures(t = !1) {
3550
- var s;
3551
- if (!this.terradraw) return;
3552
- const o = {
3553
- type: "FeatureCollection",
3554
- features: ((s = this.terradraw) == null ? void 0 : s.getSnapshot()).filter((n) => n.properties.mode !== "select")
3555
- };
3556
- return t !== !0 || (o.features = o.features.filter((n) => n.properties.selected === !0)), o;
3557
- }
3558
- /**
3559
- * clean maplibre style to filter only for terradraw related layers or without them.
3560
- * If options are not set, returns original style given to the function.
3561
- *
3562
- * This can be useful incase users only want to get terradraw related layers or without it.
3563
- *
3564
- * Usage:
3565
- * `cleanStyle(map.getStyle, { excludeTerraDrawLayers: true})`
3566
- * `cleanStyle(map.getStyle, { onlyTerraDrawLayers: true})`
3567
- *
3568
- * @param style maplibre style spec
3569
- * @param options.excludeTerraDrawLayers return maplibre style without terradraw layers and sources
3570
- * @param options.onlyTerraDrawLayers return maplibre style with only terradraw layers and sources
3571
- * @returns
3572
- */
3573
- cleanStyle(t, e) {
3574
- return De(t, e, xt);
3575
- }
3576
- /**
3577
- * Download button click event handler
3578
- */
3579
- handleDownload() {
3580
- const t = this.getFeatures(!1), e = "data:application/json;charset=utf-8," + encodeURIComponent(JSON.stringify(t)), i = document.createElement("a");
3581
- i.setAttribute("href", e), i.setAttribute("download", "data.geojson"), document.body.appendChild(i), i.click(), i.remove();
3582
- }
3583
- /**
3584
- * Toggle the state of buttons when there is no features
3585
- */
3586
- toggleButtonsWhenNoFeature() {
3587
- if (!this.controlContainer) return;
3588
- const t = this.getFeatures(!1), e = !!(t && t.features.length > 0), i = [
3589
- "maplibregl-terradraw-add-select-button",
3590
- "maplibregl-terradraw-download-button",
3591
- "maplibregl-terradraw-delete-button"
3592
- ];
3593
- for (const o of i) {
3594
- const s = this.controlContainer.getElementsByClassName(o);
3595
- for (let n = 0; n < s.length; n++) {
3596
- const a = s.item(n);
3597
- a && (a.disabled = !e);
3598
- }
3599
- }
3600
- }
3601
- /**
3602
- * Toggle the state of delete-select button
3603
- */
3604
- toggleDeleteSelectionButton() {
3605
- var a, l;
3606
- const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, s = o && t && e === "select", n = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
3607
- for (let d = 0; d < n.length; d++) {
3608
- const c = n.item(d);
3609
- c && (s ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
3610
- }
3611
- if (!o) {
3612
- const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
3613
- for (let c = 0; c < d.length; c++) {
3614
- const h = d.item(c);
3615
- h && h.classList.remove("active");
3616
- }
3617
- }
3618
- }
3619
- }
3620
- var k = 63710088e-1, Mi = {
3621
- centimeters: k * 100,
3622
- centimetres: k * 100,
3623
- degrees: 360 / (2 * Math.PI),
3624
- feet: k * 3.28084,
3625
- inches: k * 39.37,
3626
- kilometers: k / 1e3,
3627
- kilometres: k / 1e3,
3628
- meters: k,
3629
- metres: k,
3630
- miles: k / 1609.344,
3631
- millimeters: k * 1e3,
3632
- millimetres: k * 1e3,
3633
- nauticalmiles: k / 1852,
3634
- radians: 1,
3635
- yards: k * 1.0936
3636
- };
3637
- function wi(r, t, e = {}) {
3638
- const i = { type: "Feature" };
3639
- return (e.id === 0 || e.id) && (i.id = e.id), e.bbox && (i.bbox = e.bbox), i.properties = t || {}, i.geometry = r, i;
3640
- }
3641
- function Fi(r, t, e = {}) {
3642
- if (!r)
3643
- throw new Error("coordinates is required");
3644
- if (!Array.isArray(r))
3645
- throw new Error("coordinates must be an Array");
3646
- if (r.length < 2)
3647
- throw new Error("coordinates must be at least 2 numbers long");
3648
- if (!ee(r[0]) || !ee(r[1]))
3649
- throw new Error("coordinates must contain numbers");
3650
- return wi({
3651
- type: "Point",
3652
- coordinates: r
3653
- }, t, e);
3654
- }
3655
- function Ei(r, t = "kilometers") {
3656
- const e = Mi[t];
3657
- if (!e)
3658
- throw new Error(t + " units is invalid");
3659
- return r * e;
3660
- }
3661
- function ht(r) {
3662
- return r % 360 * Math.PI / 180;
3663
- }
3664
- function ee(r) {
3665
- return !isNaN(r) && r !== null && !Array.isArray(r);
3666
- }
3667
- function ie(r) {
3668
- if (!r)
3669
- throw new Error("coord is required");
3670
- if (!Array.isArray(r)) {
3671
- if (r.type === "Feature" && r.geometry !== null && r.geometry.type === "Point")
3672
- return [...r.geometry.coordinates];
3673
- if (r.type === "Point")
3674
- return [...r.coordinates];
3675
- }
3676
- if (Array.isArray(r) && r.length >= 2 && !Array.isArray(r[0]) && !Array.isArray(r[1]))
3677
- return [...r];
3678
- throw new Error("coord must be GeoJSON Point or an Array of numbers");
3679
- }
3680
- function Oi(r, t, e = {}) {
3681
- var i = ie(r), o = ie(t), s = ht(o[1] - i[1]), n = ht(o[0] - i[0]), a = ht(i[1]), l = ht(o[1]), d = Math.pow(Math.sin(s / 2), 2) + Math.pow(Math.sin(n / 2), 2) * Math.cos(a) * Math.cos(l);
3682
- return Ei(
3683
- 2 * Math.atan2(Math.sqrt(d), Math.sqrt(1 - d)),
3684
- e.units
3685
- );
3686
- }
3687
- function Le(r, t, e) {
3688
- if (r !== null)
3689
- for (var i, o, s, n, a, l, d, c = 0, h = 0, u, p = r.type, g = p === "FeatureCollection", y = p === "Feature", v = g ? r.features.length : 1, f = 0; f < v; f++) {
3690
- d = g ? r.features[f].geometry : y ? r.geometry : r, u = d ? d.type === "GeometryCollection" : !1, a = u ? d.geometries.length : 1;
3691
- for (var m = 0; m < a; m++) {
3692
- var C = 0, P = 0;
3693
- if (n = u ? d.geometries[m] : d, n !== null) {
3694
- l = n.coordinates;
3695
- var S = n.type;
3696
- switch (c = S === "Polygon" || S === "MultiPolygon" ? 1 : 0, S) {
3697
- case null:
3698
- break;
3699
- case "Point":
3700
- if (t(
3701
- l,
3702
- h,
3703
- f,
3704
- C,
3705
- P
3706
- ) === !1)
3707
- return !1;
3708
- h++, C++;
3709
- break;
3710
- case "LineString":
3711
- case "MultiPoint":
3712
- for (i = 0; i < l.length; i++) {
3713
- if (t(
3714
- l[i],
3715
- h,
3716
- f,
3717
- C,
3718
- P
3719
- ) === !1)
3720
- return !1;
3721
- h++, S === "MultiPoint" && C++;
3722
- }
3723
- S === "LineString" && C++;
3724
- break;
3725
- case "Polygon":
3726
- case "MultiLineString":
3727
- for (i = 0; i < l.length; i++) {
3728
- for (o = 0; o < l[i].length - c; o++) {
3729
- if (t(
3730
- l[i][o],
3731
- h,
3732
- f,
3733
- C,
3734
- P
3735
- ) === !1)
3736
- return !1;
3737
- h++;
3738
- }
3739
- S === "MultiLineString" && C++, S === "Polygon" && P++;
3740
- }
3741
- S === "Polygon" && C++;
3742
- break;
3743
- case "MultiPolygon":
3744
- for (i = 0; i < l.length; i++) {
3745
- for (P = 0, o = 0; o < l[i].length; o++) {
3746
- for (s = 0; s < l[i][o].length - c; s++) {
3747
- if (t(
3748
- l[i][o][s],
3749
- h,
3750
- f,
3751
- C,
3752
- P
3753
- ) === !1)
3754
- return !1;
3755
- h++;
3756
- }
3757
- P++;
3758
- }
3759
- C++;
3760
- }
3761
- break;
3762
- case "GeometryCollection":
3763
- for (i = 0; i < n.geometries.length; i++)
3764
- if (Le(n.geometries[i], t) === !1)
3765
- return !1;
3766
- break;
3767
- default:
3768
- throw new Error("Unknown Geometry Type");
3769
- }
3770
- }
3771
- }
3772
- }
3773
- }
3774
- function Di(r, t) {
3775
- 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;
3776
- for (e = 0; e < y; e++) {
3777
- 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++) {
3778
- if (s = l ? a.geometries[o] : a, s === null) {
3779
- if (t(
3780
- null,
3781
- u,
3782
- d,
3783
- c,
3784
- h
3785
- ) === !1)
3786
- return !1;
3787
- continue;
3788
- }
3789
- switch (s.type) {
3790
- case "Point":
3791
- case "LineString":
3792
- case "MultiPoint":
3793
- case "Polygon":
3794
- case "MultiLineString":
3795
- case "MultiPolygon": {
3796
- if (t(
3797
- s,
3798
- u,
3799
- d,
3800
- c,
3801
- h
3802
- ) === !1)
3803
- return !1;
3804
- break;
3805
- }
3806
- case "GeometryCollection": {
3807
- for (i = 0; i < s.geometries.length; i++)
3808
- if (t(
3809
- s.geometries[i],
3810
- u,
3811
- d,
3812
- c,
3813
- h
3814
- ) === !1)
3815
- return !1;
3816
- break;
3817
- }
3818
- default:
3819
- throw new Error("Unknown Geometry Type");
3820
- }
3821
- }
3822
- u++;
3823
- }
3824
- }
3825
- function Li(r, t, e) {
3826
- var i = e;
3827
- return Di(
3828
- r,
3829
- function(o, s, n, a, l) {
3830
- s === 0 && e === void 0 ? i = o : i = t(
3831
- i,
3832
- o,
3833
- s,
3834
- n,
3835
- a,
3836
- l
3837
- );
3838
- }
3839
- ), i;
3840
- }
3841
- function _i(r) {
3842
- return Li(
3843
- r,
3844
- (t, e) => t + ki(e),
3845
- 0
3846
- );
3847
- }
3848
- function ki(r) {
3849
- let t = 0, e;
3850
- switch (r.type) {
3851
- case "Polygon":
3852
- return oe(r.coordinates);
3853
- case "MultiPolygon":
3854
- for (e = 0; e < r.coordinates.length; e++)
3855
- t += oe(r.coordinates[e]);
3856
- return t;
3857
- case "Point":
3858
- case "MultiPoint":
3859
- case "LineString":
3860
- case "MultiLineString":
3861
- return 0;
3862
- }
3863
- return 0;
3864
- }
3865
- function oe(r) {
3866
- let t = 0;
3867
- if (r && r.length > 0) {
3868
- t += Math.abs(se(r[0]));
3869
- for (let e = 1; e < r.length; e++)
3870
- t -= Math.abs(se(r[e]));
3871
- }
3872
- return t;
3873
- }
3874
- var Wi = k * k / 2, Et = Math.PI / 180;
3875
- function se(r) {
3876
- const t = r.length - 1;
3877
- if (t <= 2) return 0;
3878
- let e = 0, i = 0;
3879
- for (; i < t; ) {
3880
- 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] * Et, l = s[1] * Et, d = n[0] * Et;
3881
- e += (d - a) * Math.sin(l), i++;
3882
- }
3883
- return e * Wi;
3884
- }
3885
- function Bi(r, t = {}) {
3886
- let e = 0, i = 0, o = 0;
3887
- return Le(
3888
- r,
3889
- function(s) {
3890
- e += s[0], i += s[1], o++;
3891
- }
3892
- ), Fi([e / o, i / o], t.properties);
3893
- }
3894
- var ji = Object.defineProperty, Ni = (r, t, e) => t in r ? ji(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, tt = (r, t, e) => Ni(r, typeof t != "symbol" ? t + "" : t, e), mt = 2 * Math.PI * 6378137 / 2;
3895
- function Ai(r) {
3896
- return r = r || 256, 2 * Math.PI * 6378137 / r;
3897
- }
3898
- function Ti(r, t, e = { enable: !0, decimal: 1 }) {
3899
- r = _t(r);
3900
- var i = r[0], o = r[1], s = i * mt / 180, n = Math.log(Math.tan((90 + o) * Math.PI / 360)) / (Math.PI / 180);
3901
- return n = n * mt / 180, e.enable && (s = Number(s.toFixed(e.decimal)), n = Number(n.toFixed(e.decimal))), [s, n];
3902
- }
3903
- function Gi(r, t, e) {
3904
- var i = r[0], o = r[1], s = Ki(t, e), n = (i + mt) / s, a = (o + mt) / s;
3905
- return [n, a, t];
3906
- }
3907
- function _e(r, t, e) {
3908
- r = _t(r);
3909
- var i = Ti(r), o = Gi(i, t);
3910
- return Ui(o);
3911
- }
3912
- function Vi(r, t, e) {
3913
- if (r = _t(r), t === 0)
3914
- return [0, 0, 0];
3915
- var i = _e(r, t);
3916
- return zi(i);
3917
- }
3918
- function Ui(r, t, e) {
3919
- t = t || 256;
3920
- var i = r[0], o = r[1], s = r[2];
3921
- if (s === 0) return [0, 0, 0];
3922
- ke(s);
3923
- var n = Math.ceil(i / t) - 1, a = Math.ceil(o / t) - 1;
3924
- return n < 0 && (n = 0), a < 0 && (a = 0), [n, a, s];
3925
- }
3926
- function zi(r, t) {
3927
- Ri(r);
3928
- var e = r[0], i = r[1], o = r[2];
3929
- if (o === 0)
3930
- return [0, 0, 0];
3931
- var s = e, n = Math.pow(2, o) - 1 - i;
3932
- return [s, n, o];
3933
- }
3934
- function Ri(r, t) {
3935
- var e = r[0], i = r[1], o = r[2];
3936
- if (o == null) throw new Error("<zoom> is required");
3937
- if (e == null) throw new Error("<x> is required");
3938
- if (i == null) throw new Error("<y> is required");
3939
- return o = ke(o), r = Xi(r), r;
3940
- }
3941
- function Xi(r) {
3942
- var t = r[0], e = r[1], i = r[2], o = Math.pow(2, i);
3943
- return t = t % o, t < 0 && (t = t + o), [t, e, i];
3944
- }
3945
- function ke(r) {
3946
- if (r === !1) return r;
3947
- if (r == null)
3948
- throw new Error("<zoom> is required");
3949
- if (r < 0)
3950
- throw new Error("<zoom> cannot be less than 0");
3951
- if (r > 32)
3952
- throw new Error("<zoom> cannot be greater than 32");
3953
- return r;
3954
- }
3955
- function _t(r, t) {
3956
- var e = $i(r[0]), i = Yi(r[1]);
3957
- return i > 85 && (i = 85), i < -85 && (i = -85), [e, i];
3958
- }
3959
- function Ki(r, t) {
3960
- return Ai(t) / Math.pow(2, r);
3961
- }
3962
- function Yi(r) {
3963
- if (r == null) throw new Error("lat is required");
3964
- return (r > 90 || r < -90) && (r = r % 180, r > 90 && (r = -180 + r), r < -90 && (r = 180 + r), r === 0 && (r = 0)), r;
3965
- }
3966
- function $i(r) {
3967
- if (r == null) throw new Error("lng is required");
3968
- return (r > 180 || r < -180) && (r = r % 360, r > 180 && (r = -360 + r), r < -180 && (r = 360 + r), r === 0 && (r = 0)), r;
3969
- }
3970
- class We {
3971
- /**
3972
- * Constructor
3973
- * @param url URL for terrain RGB raster tilesets
3974
- * @param tileSize size of tile. 256 or 512
3975
- * @param tms whether it is Tile Map Service
3976
- * @param minzoom minzoom for terrain RGB raster tilesets
3977
- * @param maxzoom maxzoom for terrain RGB raster tilesets
3978
- * @param tms whether it is Tile Map Service
3979
- */
3980
- constructor(t, e, i, o, s) {
3981
- tt(this, "url"), tt(this, "tileSize"), tt(this, "tms"), tt(this, "minzoom"), tt(this, "maxzoom"), this.url = t, this.tileSize = e, this.tms = s, this.minzoom = i, this.maxzoom = o, this.tms = s;
3982
- }
3983
- /**
3984
- * Get the value from target coordinates and zoom level by using certain formula.
3985
- * @param lnglat coordinates
3986
- * @param z zoom level
3987
- * @returns the value calculated by certain formula
3988
- */
3989
- getValue(t, e) {
3990
- return new Promise(
3991
- (i, o) => {
3992
- const s = t[0], n = t[1];
3993
- let a = e;
3994
- e > this.maxzoom ? a = this.maxzoom : e < this.minzoom && (a = this.minzoom);
3995
- const l = this.tms ? _e([s, n], a) : Vi([s, n], a), d = this.url.replace(/{x}/g, l[0].toString()).replace(/{y}/g, l[1].toString()).replace(/{z}/g, l[2].toString());
3996
- let c = this.getUrlExtension(d);
3997
- switch (c || (c = "png"), c) {
3998
- case "png":
3999
- case "webp":
4000
- this.getValueFromRaster(d, l, s, n).then((h) => {
4001
- i(h);
4002
- });
4003
- break;
4004
- default:
4005
- o(new Error(`Invalid file extension: ${c}`));
4006
- break;
4007
- }
4008
- }
4009
- );
4028
+ !this.controlContainer || !this.controlContainer.parentNode || !this.map || (this.deactivate(), this.modeButtons = {}, this.terradraw = void 0, this.map = void 0, this.controlContainer.parentNode.removeChild(this.controlContainer));
4010
4029
  }
4011
4030
  /**
4012
- * Get the value calculated from coordinates on WEBP raster tileset
4013
- * @param url tile URL
4014
- * @param tile tile index info
4015
- * @param lng longitude
4016
- * @param lat latitude
4017
- * @returns the value calculated from coordinates. If tile does not exist returns undefined
4031
+ * Register an event for the plugin
4032
+ * @param event event type
4033
+ * @param callback
4018
4034
  */
4019
- async getValueFromRaster(t, e, i, o) {
4020
- const s = await fetch(t);
4021
- if (!s.ok) {
4022
- if (s.status === 404)
4023
- return;
4024
- throw new Error(`Failed to fetch tile: ${s.statusText}`);
4025
- }
4026
- const n = await s.blob();
4027
- return new Promise((a, l) => {
4028
- const d = new Image();
4029
- d.onload = () => {
4030
- const c = document.createElement("canvas");
4031
- c.width = d.width, c.height = d.height;
4032
- const h = c.getContext("2d");
4033
- if (!h) return l(new Error("Failed to create canvas context"));
4034
- h.drawImage(d, 0, 0);
4035
- const u = h.getImageData(0, 0, d.width, d.height).data, p = this.pixels2rgba(new Uint8Array(u), e, i, o), g = this.calc(p[0], p[1], p[2], p[3]);
4036
- a(g);
4037
- }, d.onerror = () => a(void 0), d.src = URL.createObjectURL(n);
4038
- });
4035
+ on(t, e) {
4036
+ this.events[t] ? this.events[t].push(e) : this.events[t] = [e];
4039
4037
  }
4040
4038
  /**
4041
- * Get RGBA values from coordinates information
4042
- * @param pixels pixels info
4043
- * @param tile tile index info
4044
- * @param lng longitude
4045
- * @param lat latitude
4046
- * @returns RGBA values
4039
+ * Unregister an event for the plugin
4040
+ * @param event event type
4041
+ * @param callback
4042
+ * @returns
4047
4043
  */
4048
- pixels2rgba(t, e, i, o) {
4049
- const s = [];
4050
- for (let d = 0; d < t.length; d += 4) {
4051
- const c = t[d], h = t[d + 1], u = t[d + 2], p = t[d + 3], g = [c, h, u, p];
4052
- s.push(g);
4053
- }
4054
- const n = this.tileToBBOX(e), a = this.getPixelPosition(i, o, n), l = a[0] + a[1] * this.tileSize;
4055
- return s[l];
4044
+ off(t, e) {
4045
+ if (!this.events[t]) return;
4046
+ const i = this.events[t].findIndex((o) => o === e);
4047
+ i !== -1 && this.events[t].splice(i, 1);
4056
4048
  }
4057
4049
  /**
4058
- * Get the position in pixel from the coordinates
4059
- * @param lng longitude
4060
- * @param lat latitude
4061
- * @param bbox bbox (minx, miny, maxx, maxy)
4062
- * @returns The position in pixel
4050
+ * Dispatch an event. Pass the current snapshot of features and mode
4051
+ * @param event event type
4052
+ * @param args additional arguments
4063
4053
  */
4064
- getPixelPosition(t, e, i) {
4065
- const o = this.tileSize, s = this.tileSize, n = i[2] - i[0], a = i[3] - i[1], l = (t - i[0]) / n, d = (e - i[1]) / a, c = Math.floor(o * l), h = Math.floor(s * (1 - d));
4066
- return [c, h];
4054
+ dispatchEvent(t, e) {
4055
+ this.events[t] && this.events[t].forEach((i) => {
4056
+ var n, a;
4057
+ const o = (n = this.terradraw) == null ? void 0 : n.getSnapshot(), r = o == null ? void 0 : o.filter((l) => l.properties.selected === !0);
4058
+ i({
4059
+ feature: r,
4060
+ mode: (a = this.terradraw) == null ? void 0 : a.getMode(),
4061
+ ...e
4062
+ });
4063
+ });
4067
4064
  }
4068
4065
  /**
4069
- * Get file extenstion name from the URL
4070
- * @param url URL for tilesets
4071
- * @returns file extenstion either png or webp
4066
+ * Activate Terra Draw to start drawing
4072
4067
  */
4073
- getUrlExtension(t) {
4074
- let e = t.split(/[#?]/)[0].split(".").pop();
4075
- return e && (e = e.trim()), e;
4068
+ activate() {
4069
+ this.terradraw && (this.terradraw.enabled || (this.terradraw.start(), this.dispatchEvent("mode-changed")));
4076
4070
  }
4077
4071
  /**
4078
- * Get the bbox of a tile
4079
- * @param {Array<number>} tile
4080
- * @returns {Array<number>} bbox
4081
- * @example
4082
- * var bbox = tileToBBOX([5, 10, 10])
4083
- * //=bbox
4072
+ * Deactivate Terra Draw to stop drawing
4084
4073
  */
4085
- tileToBBOX(t) {
4086
- const e = this.tile2lon(t[0] + 1, t[2]), i = this.tile2lon(t[0], t[2]), o = this.tile2lat(t[1] + 1, t[2]), s = this.tile2lat(t[1], t[2]);
4087
- return [i, o, e, s];
4074
+ deactivate() {
4075
+ this.terradraw && this.terradraw.enabled && (this.resetActiveMode(), this.dispatchEvent("mode-changed"), this.terradraw.stop());
4088
4076
  }
4089
- tile2lon(t, e) {
4090
- return t / Math.pow(2, e) * 360 - 180;
4077
+ /**
4078
+ * Get the Terra Draw instance.
4079
+ * For the Terra Draw API, please refer to https://terradraw.io/#/api
4080
+ * @returns Terra Draw instance
4081
+ */
4082
+ getTerraDrawInstance() {
4083
+ return this.terradraw;
4091
4084
  }
4092
- tile2lat(t, e) {
4093
- const i = 180 / Math.PI, o = Math.PI - 2 * Math.PI * t / Math.pow(2, e);
4094
- return i * Math.atan(0.5 * (Math.exp(o) - Math.exp(-o)));
4085
+ /**
4086
+ * Toggle editor control
4087
+ */
4088
+ toggleEditor() {
4089
+ this.terradraw && (this.isExpanded = !this.isExpanded);
4095
4090
  }
4096
- }
4097
- class Hi extends We {
4098
4091
  /**
4099
- * Constructor
4100
- * @param url URL for terrain RGB raster tilesets
4101
- * @param tileSize size of tile. 256 or 512
4102
- * @param tms whether it is Tile Map Service
4103
- * @param minzoom minzoom for terrain RGB raster tilesets. default is 5
4104
- * @param maxzoom maxzoom for terrain RGB raster tilesets. default is 15
4092
+ * Reset active mode to back to render mode
4105
4093
  */
4106
- constructor(t, e, i = 5, o = 15, s = !1) {
4107
- super(t, e, i, o, s);
4094
+ resetActiveMode() {
4095
+ var e;
4096
+ if (!this.terradraw) return;
4097
+ this.terradraw.enabled || this.terradraw.start();
4098
+ const t = document.getElementsByClassName("maplibregl-terradraw-add-control");
4099
+ for (let i = 0; i < t.length; i++) {
4100
+ const o = t.item(i);
4101
+ o && o.classList.remove("active");
4102
+ }
4103
+ (e = this.terradraw) == null || e.setMode(this.defaultMode);
4108
4104
  }
4109
4105
  /**
4110
- * Get an altitude calculated from terrain RGB information
4111
- * @param lnglat coordinates
4112
- * @param z zoom level
4113
- * @returns an altitude calculated from terrain RGB information
4106
+ * Add Terra Draw drawing mode button
4107
+ * @param mode Terra Draw mode name
4114
4108
  */
4115
- async getElevation(t, e) {
4116
- return await this.getValue(t, e);
4109
+ addTerradrawButton(t) {
4110
+ const e = document.createElement("button");
4111
+ e.type = "button", this.modeButtons[t] = e, t === "render" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), this.isExpanded && e.classList.add("enabled"), e.type = "button", e.title = ne("expand or collapse drawing tool"), e.addEventListener("click", this.toggleEditor.bind(this))) : (e.classList.add("maplibregl-terradraw-add-control"), this.isExpanded || e.classList.add("hidden"), e.title = ne(t.replace(/-/g, " ")), t === "delete" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", () => {
4112
+ this.terradraw && this.terradraw.enabled && (this.terradraw.clear(), this.deactivate(), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature(), this.dispatchEvent("feature-deleted"));
4113
+ })) : t === "delete-selection" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.classList.add("hidden-delete-selection"), e.addEventListener("click", () => {
4114
+ var r;
4115
+ if (!this.terradraw || !this.terradraw.enabled) return;
4116
+ const o = ((r = this.terradraw) == null ? void 0 : r.getSnapshot()).filter((n) => n.properties.selected === !0);
4117
+ if (o.length > 0) {
4118
+ const n = o.map((a) => a.id);
4119
+ this.terradraw.removeFeatures(n);
4120
+ for (const a of n)
4121
+ this.terradraw.deselectFeature(a);
4122
+ this.dispatchEvent("feature-deleted", { deletedIds: n });
4123
+ }
4124
+ this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
4125
+ })) : t === "download" ? (e.classList.add(`maplibregl-terradraw-${t}-button`), e.addEventListener("click", this.handleDownload.bind(this))) : (e.classList.add(`maplibregl-terradraw-add-${t}-button`), e.addEventListener("click", () => {
4126
+ if (!this.terradraw) return;
4127
+ const i = e.classList.contains("active");
4128
+ this.activate(), this.resetActiveMode(), i || (this.terradraw.setMode(t), e.classList.add("active")), this.toggleDeleteSelectionButton(), this.toggleButtonsWhenNoFeature();
4129
+ })));
4117
4130
  }
4118
4131
  /**
4119
- * Formula for calculating an elevation from RGB
4120
- * @param r red
4121
- * @param g green
4122
- * @param b blue
4123
- * @returns an elevation calculated
4132
+ * get GeoJSON features
4133
+ * @param onlySelected If true, returns only selected features. Default is false.
4134
+ * @returns FeatureCollection in GeoJSON format
4124
4135
  */
4125
- calc(t, e, i) {
4126
- return -1e4 + (t * 256 * 256 + e * 256 + i) * 0.1;
4136
+ getFeatures(t = !1) {
4137
+ var r;
4138
+ if (!this.terradraw) return;
4139
+ const o = {
4140
+ type: "FeatureCollection",
4141
+ features: ((r = this.terradraw) == null ? void 0 : r.getSnapshot()).filter((n) => n.properties.mode !== "select")
4142
+ };
4143
+ return t !== !0 || (o.features = o.features.filter((n) => n.properties.selected === !0)), o;
4127
4144
  }
4128
- }
4129
- class qi extends We {
4130
4145
  /**
4131
- * Constructor
4132
- * @param url URL for terrarium raster tilesets
4133
- * @param tileSize size of tile. 256 or 512
4134
- * @param tms whether it is Tile Map Service
4135
- * @param minzoom minzoom for terrain RGB raster tilesets. default is 5
4136
- * @param maxzoom maxzoom for terrain RGB raster tilesets. default is 15
4146
+ * clean maplibre style to filter only for terradraw related layers or without them.
4147
+ * If options are not set, returns original style given to the function.
4148
+ *
4149
+ * This can be useful incase users only want to get terradraw related layers or without it.
4150
+ *
4151
+ * Usage:
4152
+ * `cleanStyle(map.getStyle, { excludeTerraDrawLayers: true})`
4153
+ * `cleanStyle(map.getStyle, { onlyTerraDrawLayers: true})`
4154
+ *
4155
+ * @param style maplibre style spec
4156
+ * @param options.excludeTerraDrawLayers return maplibre style without terradraw layers and sources
4157
+ * @param options.onlyTerraDrawLayers return maplibre style with only terradraw layers and sources
4158
+ * @returns
4137
4159
  */
4138
- constructor(t, e, i = 5, o = 15, s = !1) {
4139
- super(t, e, i, o, s);
4160
+ cleanStyle(t, e) {
4161
+ return je(t, e, xt);
4140
4162
  }
4141
4163
  /**
4142
- * Get an altitude calculated from terrain RGB information
4143
- * @param lnglat coordinates
4144
- * @param z zoom level
4145
- * @returns an altitude calculated from terrain RGB information
4164
+ * Download button click event handler
4146
4165
  */
4147
- async getElevation(t, e) {
4148
- return await this.getValue(t, e);
4166
+ handleDownload() {
4167
+ const t = this.getFeatures(!1), e = "data:application/json;charset=utf-8," + encodeURIComponent(JSON.stringify(t)), i = document.createElement("a");
4168
+ i.setAttribute("href", e), i.setAttribute("download", "data.geojson"), document.body.appendChild(i), i.click(), i.remove();
4149
4169
  }
4150
4170
  /**
4151
- * Formula for calculating an elevation from RGB
4152
- * https://github.com/tilezen/joerd/blob/master/docs/formats.md#terrarium
4153
- * @param r red
4154
- * @param g green
4155
- * @param b blue
4156
- * @returns an elevation calculated
4171
+ * Toggle the state of buttons when there is no features
4157
4172
  */
4158
- calc(t, e, i) {
4159
- const o = t * 256 + e + i / 256 - 32768;
4160
- return parseInt(o.toFixed(0));
4173
+ toggleButtonsWhenNoFeature() {
4174
+ if (!this.controlContainer) return;
4175
+ const t = this.getFeatures(!1), e = !!(t && t.features.length > 0), i = [
4176
+ "maplibregl-terradraw-add-select-button",
4177
+ "maplibregl-terradraw-download-button",
4178
+ "maplibregl-terradraw-delete-button"
4179
+ ];
4180
+ for (const o of i) {
4181
+ const r = this.controlContainer.getElementsByClassName(o);
4182
+ for (let n = 0; n < r.length; n++) {
4183
+ const a = r.item(n);
4184
+ a && (a.disabled = !e);
4185
+ }
4186
+ }
4187
+ }
4188
+ /**
4189
+ * Toggle the state of delete-select button
4190
+ */
4191
+ toggleDeleteSelectionButton() {
4192
+ var a, l;
4193
+ const t = ((a = this.terradraw) == null ? void 0 : a.enabled) || !1, e = (l = this.terradraw) == null ? void 0 : l.getMode(), i = this.getFeatures(!1), o = i && i.features.length > 0, r = o && t && e === "select", n = document.getElementsByClassName("maplibregl-terradraw-delete-selection-button");
4194
+ for (let d = 0; d < n.length; d++) {
4195
+ const c = n.item(d);
4196
+ c && (r ? c.classList.remove("hidden-delete-selection") : c.classList.add("hidden-delete-selection"));
4197
+ }
4198
+ if (!o) {
4199
+ const d = document.getElementsByClassName("maplibregl-terradraw-add-select-button");
4200
+ for (let c = 0; c < d.length; c++) {
4201
+ const h = d.item(c);
4202
+ h && h.classList.remove("active");
4203
+ }
4204
+ }
4161
4205
  }
4162
4206
  }
4163
- class so extends bi {
4207
+ function so(s, t = {}) {
4208
+ let e = 0, i = 0, o = 0;
4209
+ return We(
4210
+ s,
4211
+ function(r) {
4212
+ e += r[0], i += r[1], o++;
4213
+ }
4214
+ ), Oi([e / o, i / o], t.properties);
4215
+ }
4216
+ class po extends oo {
4164
4217
  /**
4165
4218
  * Constructor
4166
4219
  * @param options Plugin control options
@@ -4173,11 +4226,11 @@ class so extends bi {
4173
4226
  open: i.open,
4174
4227
  modeOptions: i.modeOptions
4175
4228
  });
4176
- _(this, "measureOptions");
4229
+ k(this, "measureOptions");
4177
4230
  /**
4178
4231
  * Handle deselect event of terradraw
4179
4232
  */
4180
- _(this, "handleTerradrawDeselect", () => {
4233
+ k(this, "handleTerradrawDeselect", () => {
4181
4234
  if (this.map && this.computeElevation === !0 && this.measureOptions.terrainSource !== void 0) {
4182
4235
  const e = this.getTerraDrawInstance();
4183
4236
  if (!e) return;
@@ -4187,11 +4240,11 @@ class so extends bi {
4187
4240
  if (o.length > 0)
4188
4241
  for (const n of o)
4189
4242
  this.computeElevationByLineFeatureID(n.id);
4190
- const s = i.filter(
4243
+ const r = i.filter(
4191
4244
  (n) => n.properties.mode === "point" && n.geometry.type === "Point"
4192
4245
  );
4193
- if (s.length > 0)
4194
- for (const n of s)
4246
+ if (r.length > 0)
4247
+ for (const n of r)
4195
4248
  this.computeElevationByPointFeatureID(n.id);
4196
4249
  }
4197
4250
  });
@@ -4199,29 +4252,30 @@ class so extends bi {
4199
4252
  * Handle finish event of terradraw. It will be called after finishing adding a feature
4200
4253
  * @param id Feature ID
4201
4254
  */
4202
- _(this, "handleTerradrawFeatureReady", Ii((e) => {
4255
+ k(this, "handleTerradrawFeatureReady", Vi((e) => {
4203
4256
  this.map && (this.computeElevationByLineFeatureID(e), this.computeElevationByPointFeatureID(e));
4204
4257
  }, 300));
4205
4258
  /**
4206
4259
  * Compute elevation by a LineString feature ID
4207
4260
  * @param id FeatureID
4208
4261
  */
4209
- _(this, "computeElevationByLineFeatureID", async (e) => {
4262
+ k(this, "computeElevationByLineFeatureID", async (e) => {
4210
4263
  if (this.map && this.computeElevation === !0) {
4211
4264
  const i = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
4212
4265
  if (i && typeof i.data != "string" && i.data.type === "FeatureCollection") {
4213
4266
  const o = i.data.features.filter(
4214
- (s) => {
4267
+ (r) => {
4215
4268
  var n;
4216
- return ((n = s.properties) == null ? void 0 : n.originalId) === e && s.geometry.type === "Point";
4269
+ return ((n = r.properties) == null ? void 0 : n.originalId) === e && r.geometry.type === "Point";
4217
4270
  }
4218
4271
  );
4219
4272
  if (o && o.length > 0) {
4220
- const s = await this.queryTerrainElevation(
4221
- o
4273
+ const r = await le(
4274
+ o,
4275
+ this.measureOptions.terrainSource
4222
4276
  );
4223
4277
  this.replaceGeoJSONSource(
4224
- s,
4278
+ r,
4225
4279
  this.measureOptions.lineLayerLabelSpec.source,
4226
4280
  "linestring"
4227
4281
  );
@@ -4233,22 +4287,23 @@ class so extends bi {
4233
4287
  * Compute elevation by a Point feature ID
4234
4288
  * @param id FeatureID
4235
4289
  */
4236
- _(this, "computeElevationByPointFeatureID", async (e) => {
4290
+ k(this, "computeElevationByPointFeatureID", async (e) => {
4237
4291
  if (this.map && this.computeElevation === !0) {
4238
4292
  const i = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
4239
4293
  if (i && typeof i.data != "string" && i.data.type === "FeatureCollection") {
4240
4294
  const o = i.data.features.filter(
4241
- (s) => {
4295
+ (r) => {
4242
4296
  var n;
4243
- return s.id === e && s.geometry.type === "Point" && ((n = s.properties) == null ? void 0 : n.mode) === "point";
4297
+ return r.id === e && r.geometry.type === "Point" && ((n = r.properties) == null ? void 0 : n.mode) === "point";
4244
4298
  }
4245
4299
  );
4246
4300
  if (o && o.length > 0) {
4247
- const s = await this.queryTerrainElevation(
4248
- o
4301
+ const r = await le(
4302
+ o,
4303
+ this.measureOptions.terrainSource
4249
4304
  );
4250
4305
  this.replaceGeoJSONSource(
4251
- s,
4306
+ r,
4252
4307
  this.measureOptions.pointLayerLabelSpec.source,
4253
4308
  "point"
4254
4309
  );
@@ -4256,16 +4311,6 @@ class so extends bi {
4256
4311
  }
4257
4312
  }
4258
4313
  });
4259
- /**
4260
- * Calculate area / distance and update a feature properties
4261
- * @param feature GeoJSON feature
4262
- * @returns updated GeoJSON feature
4263
- */
4264
- _(this, "updateFeatureProperties", (e) => {
4265
- if (!this.map || !this.map.loaded()) return e;
4266
- const i = e.geometry.type;
4267
- return i === "LineString" ? e = this.calcDistance(e) : i === "Polygon" ? e = this.calcArea(e) : i === "Point" && (e = this.queryElevationByPoint(e)), e;
4268
- });
4269
4314
  this.measureOptions = i;
4270
4315
  }
4271
4316
  /**
@@ -4361,8 +4406,8 @@ class so extends bi {
4361
4406
  this.registerMesureControl();
4362
4407
  const i = e.getSnapshot();
4363
4408
  for (const o of i) {
4364
- const s = o.id, n = o.geometry.type, a = o.properties.mode;
4365
- a === "linestring" && n === "LineString" ? (this.measureLine(s), this.computeElevationByLineFeatureID(s)) : a === "point" && n === "Point" ? (this.measurePoint(s), this.computeElevationByPointFeatureID(s)) : !["point", "linestring", "select", "render"].includes(a) && n === "Polygon" && this.measurePolygon(s);
4409
+ const r = o.id, n = o.geometry.type, a = o.properties.mode;
4410
+ a === "linestring" && n === "LineString" ? (this.measureLine(r), this.computeElevationByLineFeatureID(r)) : a === "point" && n === "Point" ? (this.measurePoint(r), this.computeElevationByPointFeatureID(r)) : !["point", "linestring", "select", "render"].includes(a) && n === "Polygon" && this.measurePolygon(r);
4366
4411
  }
4367
4412
  }
4368
4413
  }
@@ -4383,20 +4428,20 @@ class so extends bi {
4383
4428
  */
4384
4429
  cleanStyle(e, i) {
4385
4430
  var l, d, c;
4386
- const o = xt, s = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
4387
- s && o.push(s);
4431
+ const o = xt, r = (l = this.measureOptions.polygonLayerSpec) == null ? void 0 : l.source;
4432
+ r && o.push(r);
4388
4433
  const n = (d = this.measureOptions.lineLayerLabelSpec) == null ? void 0 : d.source;
4389
4434
  n && o.push(n);
4390
4435
  const a = (c = this.measureOptions.pointLayerLabelSpec) == null ? void 0 : c.source;
4391
- return a && o.push(a), De(e, i, o);
4436
+ return a && o.push(a), je(e, i, o);
4392
4437
  }
4393
4438
  /**
4394
4439
  * Register measure control related maplibre sources and layers
4395
4440
  */
4396
4441
  registerMesureControl() {
4397
- var s, n, a;
4442
+ var r, n, a;
4398
4443
  if (!this.map) return;
4399
- const e = (s = this.options.modes) == null ? void 0 : s.filter((l) => ["linestring"].includes(l));
4444
+ const e = (r = this.options.modes) == null ? void 0 : r.filter((l) => ["linestring"].includes(l));
4400
4445
  ((n = this.options.modes) == null ? void 0 : n.find((l) => l === "point")) && (this.map.getSource(
4401
4446
  this.measureOptions.pointLayerLabelSpec.source
4402
4447
  ) || this.map.addSource(
@@ -4447,23 +4492,23 @@ class so extends bi {
4447
4492
  const i = this.getTerraDrawInstance();
4448
4493
  if (!i) return;
4449
4494
  const o = i.getSnapshot();
4450
- for (const s of e) {
4451
- const n = o.find((a) => a.id === s);
4495
+ for (const r of e) {
4496
+ const n = o.find((a) => a.id === r);
4452
4497
  if (n) {
4453
4498
  const a = n.geometry.type, l = n.properties.mode;
4454
- l === "linestring" && a === "LineString" ? this.measureLine(s) : l === "point" && a === "Point" ? this.measurePoint(s) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(s);
4499
+ l === "linestring" && a === "LineString" ? this.measureLine(r) : l === "point" && a === "Point" ? this.measurePoint(r) : !["point", "linestring", "select", "render"].includes(l) && a === "Polygon" && this.measurePolygon(r);
4455
4500
  } else
4456
4501
  this.clearMeasureFeatures(
4457
- s,
4502
+ r,
4458
4503
  this.measureOptions.lineLayerNodeSpec.source
4459
4504
  ), this.clearMeasureFeatures(
4460
- s,
4505
+ r,
4461
4506
  this.measureOptions.lineLayerLabelSpec.source
4462
4507
  ), this.clearMeasureFeatures(
4463
- s,
4508
+ r,
4464
4509
  this.measureOptions.polygonLayerSpec.source
4465
4510
  ), this.clearMeasureFeatures(
4466
- s,
4511
+ r,
4467
4512
  this.measureOptions.pointLayerLabelSpec.source
4468
4513
  );
4469
4514
  }
@@ -4493,7 +4538,7 @@ class so extends bi {
4493
4538
  * @returns void
4494
4539
  */
4495
4540
  clearMeasureFeatures(e, i) {
4496
- var s;
4541
+ var r;
4497
4542
  if (!this.map) return;
4498
4543
  const o = this.map.getStyle().sources[i];
4499
4544
  o && typeof o.data != "string" && o.data.type === "FeatureCollection" && (o.data.features = o.data.features.filter(
@@ -4501,26 +4546,7 @@ class so extends bi {
4501
4546
  var a;
4502
4547
  return ((a = n.properties) == null ? void 0 : a.originalId) !== e;
4503
4548
  }
4504
- ), (s = this.map.getSource(i)) == null || s.setData(o.data));
4505
- }
4506
- /**
4507
- * Calculate area from polygon feature
4508
- * @param feature Polygon GeoJSON feature
4509
- * @returns The returning feature will contain `area`,`unit` properties.
4510
- */
4511
- calcArea(e) {
4512
- if (e.geometry.type !== "Polygon") return e;
4513
- const i = _i(e.geometry);
4514
- let o = i, s = "m²";
4515
- return this.areaUnit === "metric" ? i >= 1e6 ? (o = i / 1e6, s = "km²") : i >= 1e4 && (o = i / 1e4, s = "ha") : i >= 258998811e-2 ? (o = i / 258998811e-2, s = "mi²") : i >= 4046.856 ? (o = i / 4046.856, s = "acre") : i >= 0.83612736 && (o = i / 0.83612736, s = "yd²"), o = parseFloat(o.toFixed(this.areaPrecision)), e.properties.area = o, e.properties.unit = s, e;
4516
- }
4517
- /**
4518
- * Get the equivalent unit name for displaying
4519
- * @param distanceUnit distance unit
4520
- * @returns Unit name for displaying
4521
- */
4522
- getDistanceUnitName(e) {
4523
- return e === "degrees" ? "°" : e === "miles" ? "mi" : e === "radians" ? "rad" : "km";
4549
+ ), (r = this.map.getSource(i)) == null || r.setData(o.data));
4524
4550
  }
4525
4551
  /**
4526
4552
  * Replace GeoJSON source with updated features for a given source ID
@@ -4531,92 +4557,33 @@ class so extends bi {
4531
4557
  replaceGeoJSONSource(e, i, o) {
4532
4558
  var n;
4533
4559
  if (!this.map) return;
4534
- const s = this.map.getStyle().sources[i];
4535
- if (s && typeof s.data != "string" && s.data.type === "FeatureCollection") {
4560
+ const r = this.map.getStyle().sources[i];
4561
+ if (r && typeof r.data != "string" && r.data.type === "FeatureCollection") {
4536
4562
  const a = e.map((l) => l.id);
4537
- if (typeof s.data != "string" && s.data.type === "FeatureCollection") {
4538
- o === "linestring" ? s.data.features = [
4539
- ...s.data.features = s.data.features.filter(
4563
+ if (typeof r.data != "string" && r.data.type === "FeatureCollection") {
4564
+ o === "linestring" ? r.data.features = [
4565
+ ...r.data.features = r.data.features.filter(
4540
4566
  (d) => {
4541
4567
  var c;
4542
4568
  return !(a.includes((c = d.properties) == null ? void 0 : c.originalId) && d.geometry.type === "Point");
4543
4569
  }
4544
4570
  ),
4545
4571
  ...e
4546
- ] : o === "point" && (s.data.features = [
4547
- ...s.data.features = s.data.features.filter(
4572
+ ] : o === "point" && (r.data.features = [
4573
+ ...r.data.features = r.data.features.filter(
4548
4574
  (d) => !(a.includes(d.id) && d.geometry.type === "Point")
4549
4575
  ),
4550
4576
  ...e
4551
4577
  ]);
4552
4578
  const l = {};
4553
- s.data.features.forEach((d) => {
4579
+ r.data.features.forEach((d) => {
4554
4580
  var h;
4555
4581
  const c = d.id;
4556
4582
  l[c] ? !l[c].properties.elevation && ((h = d.properties) != null && h.elevation) && (l[c] = d) : l[c] = d;
4557
- }), s.data.features = Array.from(Object.values(l)), (n = this.map.getSource(i)) == null || n.setData(s.data);
4583
+ }), r.data.features = Array.from(Object.values(l)), (n = this.map.getSource(i)) == null || n.setData(r.data);
4558
4584
  }
4559
4585
  }
4560
4586
  }
4561
- /**
4562
- * Query terrain elvation for point features
4563
- * @param point Point GeoJSON features
4564
- * @returns point features after adding elevation property
4565
- */
4566
- async queryTerrainElevation(e) {
4567
- if (!this.map) return e;
4568
- const i = [];
4569
- for (const o of e)
4570
- i.push(
4571
- new Promise((s) => {
4572
- o.geometry.type !== "Point" && s(o);
4573
- const n = this.measureOptions.terrainSource;
4574
- if (n) {
4575
- const a = n.url, l = n.encoding ?? "mapbox", d = n.tileSize ?? 512, c = n.minzoom ?? 5, h = n.maxzoom ?? 15, u = n.tms ?? !1;
4576
- (l === "mapbox" ? new Hi(a, d, c, h, u) : new qi(a, d, c, h, u)).getElevation(o.geometry.coordinates, h).then((p) => {
4577
- p && (o.properties.elevation = p), s(o);
4578
- }).catch(() => s(o));
4579
- } else
4580
- s(o);
4581
- })
4582
- );
4583
- return await Promise.all(i);
4584
- }
4585
- queryElevationByPoint(e) {
4586
- var o;
4587
- if (e.geometry.type !== "Point") return e;
4588
- const i = e.geometry.coordinates;
4589
- if (this.computeElevation === !0 && this.measureOptions.terrainSource === void 0) {
4590
- const s = (o = this.map) == null ? void 0 : o.queryTerrainElevation(i);
4591
- s && (e.properties.elevation = s);
4592
- }
4593
- return e;
4594
- }
4595
- /**
4596
- * Caclulate distance for each segment on a given feature
4597
- * @param feature LineString GeoJSON feature
4598
- * @returns The returning feature will contain `segments`, `distance`, `unit` properties. `segments` will have multiple point features.
4599
- */
4600
- calcDistance(e) {
4601
- var n, a;
4602
- if (e.geometry.type !== "LineString") return e;
4603
- const i = e.geometry.coordinates;
4604
- let o = 0;
4605
- const s = [];
4606
- for (let l = 0; l < i.length - 1; l++) {
4607
- const d = i[l], c = i[l + 1], h = Oi(d, c, { units: this.distanceUnit });
4608
- o += h;
4609
- const u = JSON.parse(JSON.stringify(e));
4610
- if (u.id = `${u.id}-${l}`, u.geometry.coordinates = [d, c], u.properties.originalId = e.id, u.properties.distance = parseFloat(h.toFixed(this.distancePrecision)), u.properties.total = parseFloat(o.toFixed(this.distancePrecision)), u.properties.unit = this.getDistanceUnitName(this.distanceUnit), this.computeElevation === !0 && this.measureOptions.terrainSource === void 0) {
4611
- const p = (n = this.map) == null ? void 0 : n.queryTerrainElevation(d);
4612
- p && (u.properties.elevation_start = p);
4613
- const g = (a = this.map) == null ? void 0 : a.queryTerrainElevation(c);
4614
- g && (u.properties.elevation_end = g);
4615
- }
4616
- s.push(u);
4617
- }
4618
- return e.properties.distance = s[s.length - 1].properties.total, e.properties.unit = s[s.length - 1].properties.unit, e.properties.segments = JSON.parse(JSON.stringify(s)), e;
4619
- }
4620
4587
  /**
4621
4588
  * measure polygon area for given feature ID
4622
4589
  * @param id terradraw feature id
@@ -4627,8 +4594,8 @@ class so extends bi {
4627
4594
  const i = this.getTerraDrawInstance();
4628
4595
  if (!i) return;
4629
4596
  const o = i.getSnapshot();
4630
- let s = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Polygon");
4631
- if (s) {
4597
+ let r = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Polygon");
4598
+ if (r) {
4632
4599
  const a = this.map.getStyle().sources[this.measureOptions.polygonLayerSpec.source];
4633
4600
  if (a) {
4634
4601
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
@@ -4637,8 +4604,8 @@ class so extends bi {
4637
4604
  return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
4638
4605
  }
4639
4606
  ));
4640
- const l = JSON.parse(JSON.stringify(s));
4641
- l.id = l.id + "-area-label", l.geometry = Bi(s.geometry).geometry, l.properties.originalId = s.id, s = this.calcArea(s), l.properties.area = s.properties.area, l.properties.unit = s.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (n = this.map.getSource(
4607
+ const l = JSON.parse(JSON.stringify(r));
4608
+ l.id = l.id + "-area-label", l.geometry = so(r.geometry).geometry, l.properties.originalId = r.id, r = oe(r, this.areaUnit, this.areaPrecision), l.properties.area = r.properties.area, l.properties.unit = r.properties.unit, typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(l), (n = this.map.getSource(
4642
4609
  this.measureOptions.polygonLayerSpec.source
4643
4610
  )) == null || n.setData(a.data), this.map.moveLayer(this.measureOptions.polygonLayerSpec.id), this.map.getLayer(this.measureOptions.lineLayerLabelSpec.id) && this.map.moveLayer(
4644
4611
  this.measureOptions.lineLayerLabelSpec.id
@@ -4662,8 +4629,8 @@ class so extends bi {
4662
4629
  const i = this.getTerraDrawInstance();
4663
4630
  if (!i) return;
4664
4631
  const o = i.getSnapshot();
4665
- let s = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "LineString");
4666
- if (s) {
4632
+ let r = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "LineString");
4633
+ if (r) {
4667
4634
  const a = this.map.getStyle().sources[this.measureOptions.lineLayerLabelSpec.source];
4668
4635
  if (a) {
4669
4636
  typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
@@ -4671,8 +4638,15 @@ class so extends bi {
4671
4638
  var c;
4672
4639
  return ((c = d.properties) == null ? void 0 : c.originalId) !== e;
4673
4640
  }
4674
- )), s = this.calcDistance(s);
4675
- const l = s.properties.segments;
4641
+ )), r = re(
4642
+ r,
4643
+ this.distanceUnit,
4644
+ this.distancePrecision,
4645
+ this.map,
4646
+ this.computeElevation,
4647
+ this.measureOptions.terrainSource
4648
+ );
4649
+ const l = r.properties.segments;
4676
4650
  for (let d = 0; d < l.length; d++) {
4677
4651
  const c = l[d];
4678
4652
  typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(c);
@@ -4710,15 +4684,15 @@ class so extends bi {
4710
4684
  const i = this.getTerraDrawInstance();
4711
4685
  if (!i) return;
4712
4686
  const o = i.getSnapshot();
4713
- let s = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Point");
4714
- if (s) {
4687
+ let r = o == null ? void 0 : o.find((a) => a.id === e && a.geometry.type === "Point");
4688
+ if (r) {
4715
4689
  const a = this.map.getStyle().sources[this.measureOptions.pointLayerLabelSpec.source];
4716
- a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter(
4717
- (l) => {
4718
- var d;
4719
- return ((d = l.properties) == null ? void 0 : d.originalId) !== e;
4720
- }
4721
- )), s = this.queryElevationByPoint(s), typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(s), (n = this.map.getSource(
4690
+ a && (typeof a.data != "string" && a.data.type === "FeatureCollection" && (a.data.features = a.data.features.filter((l) => l.id !== e)), r = ae(
4691
+ r,
4692
+ this.map,
4693
+ this.computeElevation,
4694
+ this.measureOptions.terrainSource
4695
+ ), this.computeElevation === !0 && typeof a.data != "string" && a.data.type === "FeatureCollection" && a.data.features.push(r), (n = this.map.getSource(
4722
4696
  this.measureOptions.pointLayerLabelSpec.source
4723
4697
  )) == null || n.setData(a.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(
4724
4698
  this.measureOptions.lineLayerLabelSpec.id
@@ -4733,7 +4707,7 @@ class so extends bi {
4733
4707
  * Event definition when feature is deleted by terradraw
4734
4708
  */
4735
4709
  onFeatureDeleted(e) {
4736
- var o, s;
4710
+ var o, r;
4737
4711
  if (!this.map) return;
4738
4712
  if (this.getTerraDrawInstance()) {
4739
4713
  let n = [];
@@ -4754,7 +4728,7 @@ class so extends bi {
4754
4728
  else
4755
4729
  for (const l of a) {
4756
4730
  const d = this.map.getStyle().sources[l.source];
4757
- d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = []), (s = this.map.getSource(l.source)) == null || s.setData(d.data));
4731
+ d && (typeof d.data != "string" && d.data.type === "FeatureCollection" && (d.data.features = []), (r = this.map.getSource(l.source)) == null || r.setData(d.data));
4758
4732
  }
4759
4733
  }
4760
4734
  }
@@ -4766,22 +4740,44 @@ class so extends bi {
4766
4740
  getFeatures(e = !1) {
4767
4741
  const i = super.getFeatures(e);
4768
4742
  if (!i || !this.terradraw) return i;
4769
- for (let o = 0; o < i.features.length; o++)
4770
- i.features[o] = this.updateFeatureProperties(i.features[o]);
4743
+ for (let o = 0; o < i.features.length; o++) {
4744
+ const r = i.features[o];
4745
+ if (!this.map || !this.map.loaded()) continue;
4746
+ const n = r.geometry.type;
4747
+ n === "LineString" ? i.features[o] = re(
4748
+ r,
4749
+ this.distanceUnit,
4750
+ this.distancePrecision,
4751
+ this.map,
4752
+ this.computeElevation,
4753
+ this.measureOptions.terrainSource
4754
+ ) : n === "Polygon" ? i.features[o] = oe(r, this.areaUnit, this.areaPrecision) : n === "Point" && (i.features[o] = ae(
4755
+ r,
4756
+ this.map,
4757
+ this.computeElevation,
4758
+ this.measureOptions.terrainSource
4759
+ ));
4760
+ }
4771
4761
  return i;
4772
4762
  }
4773
4763
  }
4774
4764
  export {
4775
- io as AvailableModes,
4776
- so as MaplibreMeasureControl,
4777
- bi as MaplibreTerradrawControl,
4778
- oo as TERRADRAW_MEASURE_SOURCE_IDS,
4765
+ ho as AvailableModes,
4766
+ po as MaplibreMeasureControl,
4767
+ oo as MaplibreTerradrawControl,
4768
+ uo as TERRADRAW_MEASURE_SOURCE_IDS,
4779
4769
  xt as TERRADRAW_SOURCE_IDS,
4780
- te as capitalize,
4781
- De as cleanMaplibreStyle,
4782
- Ii as debounce,
4783
- Si as defaultControlOptions,
4770
+ oe as calcArea,
4771
+ re as calcDistance,
4772
+ ne as capitalize,
4773
+ je as cleanMaplibreStyle,
4774
+ Ni as convertAreaUnit,
4775
+ Vi as debounce,
4776
+ Mi as defaultControlOptions,
4784
4777
  ut as defaultMeasureControlOptions,
4785
- xi as getDefaultModeOptions
4778
+ wi as getDefaultModeOptions,
4779
+ Ti as getDistanceUnitName,
4780
+ ae as queryElevationByPoint,
4781
+ le as queryElevationFromRasterDEM
4786
4782
  };
4787
4783
  //# sourceMappingURL=maplibre-gl-terradraw.es.js.map