@element-editor/adapter-maplibre 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -3,11 +3,11 @@ import { jsx as X, jsxs as fe, Fragment as lt } from "react/jsx-runtime";
3
3
  import { useContext as pt, createContext as Nt, useEffect as K, useState as le, useRef as $, useCallback as ve, useMemo as Bt, memo as ao, useLayoutEffect as uo, forwardRef as In, useImperativeHandle as fo } from "react";
4
4
  import { canProcessShape as _t, warnOnce as Rn, DEFAULT_FEATURE_COLOR_ON_DARK as go, createClickRepeatGuard as yo, routingError as po, CLICK_TOOL_MODES as ho, CLICK_SLOP_PX as mo, makeCircleCoords as vo, makeRectCoords as xo, isMultiGeometry as ht, getPartCount as wo, getPartGeometry as At, placeBox as Fn, commitTopoMove as on, vertexEditPatch as So, commitTopoInsert as wt, commitTopoDelete as rn, rdp as bo, withXY as Ve, setPartGeometry as Lo, insertedPosition as sn, transformUpdates as Eo, getMercatorLatCorrectionRatio as Te, unproject as Ot, project as me, offsetGeometry as $t, applyVisualTransform as Po, toRadians as Ke, mapPositions as _n, vertexEditNotice as Co, fitPadding as jt, addPickedFeature as Mo, OSM_PICK_OVERLAY_COLORS as at, unionPieces as ko, tileCandidateResult as Io, OSM_PICK_MIN_ZOOM as Ro, overpassRadiusForZoom as Fo, tileCandidates as _o, normalizeFitBoundsTarget as Ao, visibleCenterOffset as cn, loadErrorCode as ln } from "@element-editor/core/internal";
5
5
  import { useAccentPalette as To, useDataStore as he, useUIStore as W, useElementEditorConfig as ke, useGeoStore as Le, useEmit as Ue, useIsEventForEditor as zt, featureLabel as Do, ContextMenu as Ko, VertexSelectionBar as No, FeatureMapContextMenu as Bo, useAccentStyle as Oo, useTheme as An, runGeometryWorkerOperation as $o, MapControllerProvider as jo, EventProvider as zo, useAdapterControls as Ho, useKeyboardShortcuts as Vo, useApplyAccentToRoot as Xo, useReportThemeFromRoot as Yo, preloadEditorPanelsWhenIdle as Go, useSetMapController as Wo, BasemapPicker as Uo } from "@element-editor/ui";
6
- import { ActiveDrawingToolbar as gi, EditingToolbar as yi, ElementEditorUIProvider as pi, FloatingToolbar as hi, GeoStoreProvider as mi, MapControllerProvider as vi, StoreContext as xi, useDataStore as wi, useGeoStore as Si, useKeyboardShortcuts as bi, useMapController as Li, useSetMapController as Ei, useUIStore as Pi } from "@element-editor/ui";
6
+ import { ActiveDrawingToolbar as fi, EditingToolbar as gi, ElementEditorUIProvider as yi, FloatingToolbar as pi, GeoStoreProvider as hi, MapControllerProvider as mi, StoreContext as vi, useDataStore as xi, useGeoStore as wi, useKeyboardShortcuts as Si, useMapController as bi, useSetMapController as Li, useUIStore as Ei } from "@element-editor/ui";
7
7
  import { useOptionalEmit as Tn, useRouting as Zo, applyRootTokens as qo, useContextMenu as Jo } from "@element-editor/ui/internal";
8
8
  import { readAccentPalette as Dn, DEFAULT_FEATURE_COLOR as Kn, fetchRoute as an, getGeometryBBox as Nn, formatLength as mt, formatArea as Ht, fetchOverpassFeatures as Qo, overpassErrorMessage as er, OverpassError as tr, readStorage as nr, writeStorage as or, ElementEditorError as Tt } from "@element-editor/core";
9
- import { ElementEditorError as Mi } from "@element-editor/core";
10
- import De from "maplibre-gl";
9
+ import { ElementEditorError as Ci } from "@element-editor/core";
10
+ import * as De from "maplibre-gl";
11
11
  import { Crosshair as rr, Trash as sr } from "@phosphor-icons/react";
12
12
  import { createPortal as Ze } from "react-dom";
13
13
  import { transformRotate as ir } from "@turf/transform-rotate";
@@ -227,60 +227,60 @@ function Lr(e) {
227
227
  }
228
228
  const Be = ["elm-features-fill", "elm-features-line", Xt, "elm-features-point"];
229
229
  function Er({ map: e }) {
230
- const t = he((A) => A.features), n = he((A) => A.groups), o = he((A) => A.selectedIds), r = W((A) => A.editingMode), s = W((A) => A.geometryPreview !== null), i = W((A) => A.bufferCreateNew), l = yr(), u = ke().featureColor, c = vt(), [v, d] = le(() => un(e));
230
+ const t = he((_) => _.features), n = he((_) => _.groups), o = he((_) => _.selectedIds), r = W((_) => _.editingMode), s = W((_) => _.geometryPreview !== null), i = W((_) => _.bufferCreateNew), l = yr(), u = ke().featureColor, c = vt(), [v, d] = le(() => un(e));
231
231
  K(() => {
232
- const A = () => d(un(e));
233
- return A(), e.on("styledata", A), () => {
234
- e.off("styledata", A);
232
+ const _ = () => d(un(e));
233
+ return _(), e.on("styledata", _), () => {
234
+ e.off("styledata", _);
235
235
  };
236
236
  }, [e, c]);
237
237
  const g = v ? wr : Hn, w = qe(e, g);
238
238
  K(() => {
239
239
  Ne(e, g, w);
240
240
  }, [c]);
241
- const P = Tn(), T = $(!1);
241
+ const C = Tn(), T = $(!1);
242
242
  K(() => {
243
- T.current || e.getGlyphs() || (T.current = !0, P == null || P({
243
+ T.current || e.getGlyphs() || (T.current = !0, C == null || C({
244
244
  type: "error",
245
245
  code: "unsupported",
246
246
  source: "basemap",
247
247
  quiet: !0,
248
248
  message: 'The map style has no glyphs, so text features are not shown. Use a style whose glyphs serve "Noto Sans Regular".'
249
249
  }));
250
- }, [e, c, P]);
251
- const M = s && (r === "simplify-shape" || r === "smooth-shape" || r === "buffer-shape" && !i) ? o : null;
250
+ }, [e, c, C]);
251
+ const k = s && (r === "simplify-shape" || r === "smooth-shape" || r === "buffer-shape" && !i) ? o : null;
252
252
  K(() => {
253
- const A = e.getSource(ge);
254
- if (!A) return;
255
- const D = new Set(n.filter((C) => C.hidden).map((C) => C.id)), q = M ? new Set(M) : null, y = t.filter((C) => !(C.hidden || C.groupId && D.has(C.groupId) || q != null && q.has(C.id) && _t(C.geometry.type))), f = [];
253
+ const _ = e.getSource(ge);
254
+ if (!_) return;
255
+ const D = new Set(n.filter((M) => M.hidden).map((M) => M.id)), q = k ? new Set(k) : null, p = t.filter((M) => !(M.hidden || M.groupId && D.has(M.groupId) || q != null && q.has(M.id) && _t(M.geometry.type))), f = [];
256
256
  let b = !0;
257
- for (const C of y) {
258
- const { _validation: R, ...I } = C, a = l == null ? void 0 : l(C), x = {}, p = (a == null ? void 0 : a.color) ?? u;
259
- if (p !== void 0 && (x._color = p), a && (a.fillColor !== void 0 && (x._fillColor = a.fillColor), a.opacity !== void 0 && (x._opacity = a.opacity), a.fillOpacity !== void 0 && (x._fillOpacity = a.fillOpacity), a.weight !== void 0 && (x._weight = a.weight)), C.geometry.type === "GeometryCollection") {
260
- C.geometry.geometries.length > 1 && (b = !1);
261
- for (const m of C.geometry.geometries)
257
+ for (const M of p) {
258
+ const { _validation: A, ...E } = M, a = l == null ? void 0 : l(M), x = {}, y = (a == null ? void 0 : a.color) ?? u;
259
+ if (y !== void 0 && (x._color = y), a && (a.fillColor !== void 0 && (x._fillColor = a.fillColor), a.opacity !== void 0 && (x._opacity = a.opacity), a.fillOpacity !== void 0 && (x._fillOpacity = a.fillOpacity), a.weight !== void 0 && (x._weight = a.weight)), M.geometry.type === "GeometryCollection") {
260
+ M.geometry.geometries.length > 1 && (b = !1);
261
+ for (const m of M.geometry.geometries)
262
262
  f.push({
263
- ...I,
263
+ ...E,
264
264
  geometry: m,
265
- properties: { ...I.properties, ...x, id: C.id }
265
+ properties: { ...E.properties, ...x, id: M.id }
266
266
  });
267
267
  } else
268
268
  f.push({
269
- ...I,
270
- properties: { ...I.properties, ...x, id: C.id }
269
+ ...E,
270
+ properties: { ...E.properties, ...x, id: M.id }
271
271
  });
272
272
  }
273
- A.setData({ type: "FeatureCollection", features: f }), fr(e, f, b);
274
- }, [t, n, e, M, l, u, c]);
275
- const N = $(/* @__PURE__ */ new Set()), E = $(c);
273
+ _.setData({ type: "FeatureCollection", features: f }), fr(e, f, b);
274
+ }, [t, n, e, k, l, u, c]);
275
+ const N = $(/* @__PURE__ */ new Set()), P = $(c);
276
276
  return K(() => {
277
277
  if (!e.getSource(ge)) return;
278
- E.current !== c && (E.current = c, N.current = /* @__PURE__ */ new Set());
279
- const A = N.current, D = new Set(o);
280
- for (const q of A)
278
+ P.current !== c && (P.current = c, N.current = /* @__PURE__ */ new Set());
279
+ const _ = N.current, D = new Set(o);
280
+ for (const q of _)
281
281
  D.has(q) || e.setFeatureState({ source: ge, id: q }, { selected: !1 });
282
282
  for (const q of D)
283
- A.has(q) || e.setFeatureState({ source: ge, id: q }, { selected: !0 });
283
+ _.has(q) || e.setFeatureState({ source: ge, id: q }, { selected: !0 });
284
284
  N.current = D;
285
285
  }, [o, e, c]), null;
286
286
  }
@@ -289,76 +289,76 @@ function bt(e, t, n) {
289
289
  }
290
290
  function Vn(e, t, n, o, r = 15, s = /* @__PURE__ */ new Set()) {
291
291
  const i = n.project([e, t]), l = i.x, u = i.y;
292
- let c = 1 / 0, v = null, d = null, g = 1 / 0, w = 0, P = 0, T = !1, _ = null;
293
- const M = r + 1;
294
- let N = 1 / 0, E = -1 / 0, A = 1 / 0, D = -1 / 0;
295
- for (const [b, C] of [[l - M, u - M], [l + M, u - M], [l - M, u + M], [l + M, u + M]]) {
296
- const R = n.unproject([b, C]);
297
- R.lng < N && (N = R.lng), R.lng > E && (E = R.lng), R.lat < A && (A = R.lat), R.lat > D && (D = R.lat);
292
+ let c = 1 / 0, v = null, d = null, g = 1 / 0, w = 0, C = 0, T = !1, F = null;
293
+ const k = r + 1;
294
+ let N = 1 / 0, P = -1 / 0, _ = 1 / 0, D = -1 / 0;
295
+ for (const [b, M] of [[l - k, u - k], [l + k, u - k], [l - k, u + k], [l + k, u + k]]) {
296
+ const A = n.unproject([b, M]);
297
+ A.lng < N && (N = A.lng), A.lng > P && (P = A.lng), A.lat < _ && (_ = A.lat), A.lat > D && (D = A.lat);
298
298
  }
299
299
  let q = "";
300
- function y(b, C = !0) {
300
+ function p(b, M = !0) {
301
301
  if (!b || b.length === 0) return;
302
- let R = -1, I = 0, a = 0;
302
+ let A = -1, E = 0, a = 0;
303
303
  for (let x = 0; x < b.length; x++) {
304
- const p = b[x];
305
- if (!(p[0] < N || p[0] > E || p[1] < A || p[1] > D)) {
306
- if (R !== x) {
307
- const F = n.project(p);
308
- I = F.x, a = F.y, R = x;
304
+ const y = b[x];
305
+ if (!(y[0] < N || y[0] > P || y[1] < _ || y[1] > D)) {
306
+ if (A !== x) {
307
+ const R = n.project(y);
308
+ E = R.x, a = R.y, A = x;
309
309
  }
310
- const m = Math.hypot(l - I, u - a);
311
- m < c && (c = m, v = p, d = q);
310
+ const m = Math.hypot(l - E, u - a);
311
+ m < c && (c = m, v = y, d = q);
312
312
  }
313
- if (C && x < b.length - 1) {
313
+ if (M && x < b.length - 1) {
314
314
  const m = b[x + 1];
315
- if (p[0] < N && m[0] < N || p[0] > E && m[0] > E || p[1] < A && m[1] < A || p[1] > D && m[1] > D) continue;
316
- if (R !== x) {
317
- const k = n.project(p);
318
- I = k.x, a = k.y;
315
+ if (y[0] < N && m[0] < N || y[0] > P && m[0] > P || y[1] < _ && m[1] < _ || y[1] > D && m[1] > D) continue;
316
+ if (A !== x) {
317
+ const I = n.project(y);
318
+ E = I.x, a = I.y;
319
319
  }
320
- const F = I, S = a, L = n.project(m);
321
- R = x + 1, I = L.x, a = L.y;
322
- const B = (F - L.x) ** 2 + (S - L.y) ** 2;
323
- let V = F, j = S;
320
+ const R = E, S = a, L = n.project(m);
321
+ A = x + 1, E = L.x, a = L.y;
322
+ const B = (R - L.x) ** 2 + (S - L.y) ** 2;
323
+ let V = R, j = S;
324
324
  if (B !== 0) {
325
- let k = ((l - F) * (L.x - F) + (u - S) * (L.y - S)) / B;
326
- k = Math.max(0, Math.min(1, k)), V = F + k * (L.x - F), j = S + k * (L.y - S);
325
+ let I = ((l - R) * (L.x - R) + (u - S) * (L.y - S)) / B;
326
+ I = Math.max(0, Math.min(1, I)), V = R + I * (L.x - R), j = S + I * (L.y - S);
327
327
  }
328
328
  const h = Math.hypot(l - V, u - j);
329
- h < g && (g = h, w = V, P = j, T = !0, _ = q);
329
+ h < g && (g = h, w = V, C = j, T = !0, F = q);
330
330
  }
331
331
  }
332
332
  }
333
333
  function f(b) {
334
334
  switch (b.type) {
335
335
  case "Point":
336
- y([b.coordinates]);
336
+ p([b.coordinates]);
337
337
  break;
338
338
  case "MultiPoint":
339
- y(b.coordinates, !1);
339
+ p(b.coordinates, !1);
340
340
  break;
341
341
  case "LineString":
342
- y(b.coordinates);
342
+ p(b.coordinates);
343
343
  break;
344
344
  case "Polygon":
345
345
  case "MultiLineString":
346
- for (const C of b.coordinates) y(C);
346
+ for (const M of b.coordinates) p(M);
347
347
  break;
348
348
  case "MultiPolygon":
349
- for (const C of b.coordinates)
350
- for (const R of C) y(R);
349
+ for (const M of b.coordinates)
350
+ for (const A of M) p(A);
351
351
  break;
352
352
  case "GeometryCollection":
353
- for (const C of b.geometries) f(C);
353
+ for (const M of b.geometries) f(M);
354
354
  break;
355
355
  }
356
356
  }
357
357
  for (const b of o)
358
358
  if (!s.has(b.id)) {
359
359
  if (b.bbox) {
360
- const [C, R, I, a] = b.bbox;
361
- if (I < N || C > E || a < A || R > D) continue;
360
+ const [M, A, E, a] = b.bbox;
361
+ if (E < N || M > P || a < _ || A > D) continue;
362
362
  }
363
363
  q = b.id, f(b.geometry);
364
364
  }
@@ -369,11 +369,11 @@ function Vn(e, t, n, o, r = 15, s = /* @__PURE__ */ new Set()) {
369
369
  featureId: d ?? void 0
370
370
  };
371
371
  if (g <= r && T) {
372
- const b = n.unproject([w, P]);
372
+ const b = n.unproject([w, C]);
373
373
  return {
374
374
  lnglat: [b.lng, b.lat],
375
375
  isVertex: !1,
376
- featureId: _ ?? void 0
376
+ featureId: F ?? void 0
377
377
  };
378
378
  }
379
379
  return null;
@@ -381,8 +381,8 @@ function Vn(e, t, n, o, r = 15, s = /* @__PURE__ */ new Set()) {
381
381
  function Dt(e, t, n, o = 15) {
382
382
  const r = e.project(t), s = e.project(n), i = s.x - r.x, l = s.y - r.y, u = Math.hypot(i, l);
383
383
  if (u < 1) return n;
384
- const c = Math.atan2(l, i), v = o * Math.PI / 180, d = Math.round(c / v) * v, g = r.x + u * Math.cos(d), w = r.y + u * Math.sin(d), P = e.unproject([g, w]);
385
- return [P.lng, P.lat];
384
+ const c = Math.atan2(l, i), v = o * Math.PI / 180, d = Math.round(c / v) * v, g = r.x + u * Math.cos(d), w = r.y + u * Math.sin(d), C = e.unproject([g, w]);
385
+ return [C.lng, C.lat];
386
386
  }
387
387
  let Kt = !1;
388
388
  function Pr() {
@@ -411,242 +411,242 @@ const Ge = (e) => e !== "none" ? "crosshair" : "", Ir = 3, yn = 5;
411
411
  function Rr({ map: e, routingApiKey: t }) {
412
412
  const { uiStore: n, dataStore: o } = Le(), r = Zo(t), s = ke().network.fetch, i = $(null);
413
413
  i.current = r === !1 ? null : { ...r, fetch: s };
414
- const l = Ue(), u = zt(), c = W((y) => y.editingMode), v = W((y) => y.cancelDrawing), d = W((y) => y.routeWaypoints), g = $(d);
414
+ const l = Ue(), u = zt(), c = W((p) => p.editingMode), v = W((p) => p.cancelDrawing), d = W((p) => p.routeWaypoints), g = $(d);
415
415
  K(() => {
416
416
  g.current = d;
417
417
  }, [d]);
418
- const w = $(null), P = $(null), T = $(null), _ = $(!1), M = $(!1), N = $(!1), E = $(null), A = $(yo()).current, D = $(!1), q = ve(
419
- async (y) => {
420
- if (!(y.length < 2)) {
418
+ const w = $(null), C = $(null), T = $(null), F = $(!1), k = $(!1), N = $(!1), P = $(null), _ = $(yo()).current, D = $(!1), q = ve(
419
+ async (p) => {
420
+ if (!(p.length < 2)) {
421
421
  n.getState().setRoutePreview(null, !0);
422
422
  try {
423
423
  if (!i.current) throw new Error("routing is off");
424
- const f = await an(y, i.current);
424
+ const f = await an(p, i.current);
425
425
  g.current.length >= 2 && n.getState().setRoutePreview(f, !1);
426
426
  } catch (f) {
427
427
  const b = po(f);
428
- l({ type: "error", code: b.code, source: "routing", message: b.message, error: b }), n.getState().setRoutePreview(y, !1);
428
+ l({ type: "error", code: b.code, source: "routing", message: b.message, error: b }), n.getState().setRoutePreview(p, !1);
429
429
  }
430
430
  }
431
431
  },
432
432
  [n, l]
433
433
  );
434
434
  return K(() => {
435
- const y = e.getCanvas();
435
+ const p = e.getCanvas();
436
436
  function f() {
437
- D.current || (D.current = !0, e.dragPan.enable(), y.style.cursor = "grab");
437
+ D.current || (D.current = !0, e.dragPan.enable(), p.style.cursor = "grab");
438
438
  }
439
439
  function b() {
440
440
  if (!D.current) return;
441
441
  D.current = !1;
442
- const p = n.getState().editingMode;
443
- y.style.cursor = Ge(p), (p === "draw-rect" || p === "draw-circle" || p === "draw-freehand") && e.dragPan.disable();
442
+ const y = n.getState().editingMode;
443
+ p.style.cursor = Ge(y), (y === "draw-rect" || y === "draw-circle" || y === "draw-freehand") && e.dragPan.disable();
444
444
  }
445
- const C = (p) => {
446
- if (p.key === "Shift" && (M.current = !0), !!u(p)) {
447
- if (p.code === "Space") {
448
- const m = p.target;
445
+ const M = (y) => {
446
+ if (y.key === "Shift" && (k.current = !0), !!u(y)) {
447
+ if (y.code === "Space") {
448
+ const m = y.target;
449
449
  if (m && (m.tagName === "INPUT" || m.tagName === "TEXTAREA" || m.isContentEditable)) return;
450
- p.preventDefault(), n.getState().editingMode !== "none" && f();
450
+ y.preventDefault(), n.getState().editingMode !== "none" && f();
451
451
  return;
452
452
  }
453
- if (p.key === "Escape") {
454
- const { selectedMeasurementId: m, setSelectedMeasurementId: F } = n.getState();
453
+ if (y.key === "Escape") {
454
+ const { selectedMeasurementId: m, setSelectedMeasurementId: R } = n.getState();
455
455
  if (m) {
456
- F(null);
456
+ R(null);
457
457
  return;
458
458
  }
459
459
  v();
460
460
  return;
461
461
  }
462
- if (p.key === "Enter") {
462
+ if (y.key === "Enter") {
463
463
  const m = n.getState();
464
464
  if (m.editingMode === "measure") {
465
465
  m.completeMeasure();
466
466
  return;
467
467
  }
468
468
  }
469
- if (p.key === "Backspace" || p.key === "Delete") {
469
+ if (y.key === "Backspace" || y.key === "Delete") {
470
470
  const m = n.getState();
471
471
  if (m.selectedMeasurementId) {
472
472
  m.removeMeasurement(m.selectedMeasurementId);
473
473
  return;
474
474
  }
475
- const F = m.editingMode;
476
- if (F === "measure") {
475
+ const R = m.editingMode;
476
+ if (R === "measure") {
477
477
  m.removeLastMeasurePoint();
478
478
  return;
479
479
  }
480
- if (F === "draw-line" || F === "slice-shape") {
480
+ if (R === "draw-line" || R === "slice-shape") {
481
481
  m.removeLastLineVertex();
482
482
  return;
483
483
  }
484
- if (F === "draw-polygon" || F === "cut-hole") {
484
+ if (R === "draw-polygon" || R === "cut-hole") {
485
485
  m.removeLastPolygonVertex();
486
486
  return;
487
487
  }
488
- if (F === "draw-route") {
488
+ if (R === "draw-route") {
489
489
  m.removeLastRouteWaypoint();
490
490
  return;
491
491
  }
492
492
  }
493
493
  }
494
- }, R = (p) => {
495
- if (p.code === "Space") {
494
+ }, A = (y) => {
495
+ if (y.code === "Space") {
496
496
  b();
497
497
  return;
498
498
  }
499
- p.key === "Shift" && (M.current = !1);
500
- }, I = () => b(), a = () => {
501
- y.style.cursor = "grabbing";
499
+ y.key === "Shift" && (k.current = !1);
500
+ }, E = () => b(), a = () => {
501
+ p.style.cursor = "grabbing";
502
502
  }, x = () => {
503
- y.style.cursor = D.current ? "grab" : Ge(n.getState().editingMode);
503
+ p.style.cursor = D.current ? "grab" : Ge(n.getState().editingMode);
504
504
  };
505
- return window.addEventListener("keydown", C), window.addEventListener("keyup", R), window.addEventListener("blur", I), e.on("dragstart", a), e.on("dragend", x), () => {
506
- window.removeEventListener("keydown", C), window.removeEventListener("keyup", R), window.removeEventListener("blur", I), e.off("dragstart", a), e.off("dragend", x);
505
+ return window.addEventListener("keydown", M), window.addEventListener("keyup", A), window.addEventListener("blur", E), e.on("dragstart", a), e.on("dragend", x), () => {
506
+ window.removeEventListener("keydown", M), window.removeEventListener("keyup", A), window.removeEventListener("blur", E), e.off("dragstart", a), e.off("dragend", x);
507
507
  };
508
508
  }, [v, n, e, u]), K(() => {
509
509
  e.getCanvas().style.cursor = Ge(c);
510
510
  }, [c, e]), K(() => {
511
- c === "draw-freehand" ? e.dragPan.disable() : (e.dragPan.enable(), _.current = !1);
511
+ c === "draw-freehand" ? e.dragPan.disable() : (e.dragPan.enable(), F.current = !1);
512
512
  }, [c, e]), K(() => (c !== "none" ? e.doubleClickZoom.disable() : e.doubleClickZoom.enable(), () => {
513
513
  e.doubleClickZoom.enable();
514
514
  }), [c, e]), K(() => {
515
- var C;
515
+ var A;
516
516
  if (!ho.includes(c)) return;
517
- const y = (C = e.handlers) == null ? void 0 : C._handlersById, f = [y == null ? void 0 : y.mapEvent, y == null ? void 0 : y.mousePan].filter((R) => typeof (R == null ? void 0 : R._clickTolerance) == "number"), b = f.map((R) => R._clickTolerance);
518
- for (const R of f) R._clickTolerance = mo;
519
- return () => f.forEach((R, I) => {
520
- R._clickTolerance = b[I];
517
+ const p = e, f = (A = p.handlers ?? p._handlerManager) == null ? void 0 : A._handlersById, b = [f == null ? void 0 : f.mapEvent, f == null ? void 0 : f.mousePan].filter((E) => typeof (E == null ? void 0 : E._clickTolerance) == "number"), M = b.map((E) => E._clickTolerance);
518
+ for (const E of b) E._clickTolerance = mo;
519
+ return () => b.forEach((E, a) => {
520
+ E._clickTolerance = M[a];
521
521
  });
522
522
  }, [c, e]), K(() => (c !== "none" ? e.boxZoom.disable() : e.boxZoom.enable(), () => {
523
523
  e.boxZoom.enable();
524
524
  }), [c, e]), K(() => () => {
525
- P.current && clearTimeout(P.current), T.current && T.current.abort();
525
+ C.current && clearTimeout(C.current), T.current && T.current.abort();
526
526
  }, []), K(() => {
527
- const y = (a) => a.metaKey || a.ctrlKey || a.altKey, f = (a) => {
528
- if (!y(a.originalEvent) && !D.current) {
527
+ const p = (a) => a.metaKey || a.ctrlKey || a.altKey, f = (a) => {
528
+ if (!p(a.originalEvent) && !D.current) {
529
529
  if (c === "draw-freehand") {
530
- _.current = !0, n.getState().clearFreehandPoints(), n.getState().addFreehandPoint([a.lngLat.lng, a.lngLat.lat]);
530
+ F.current = !0, n.getState().clearFreehandPoints(), n.getState().addFreehandPoint([a.lngLat.lng, a.lngLat.lat]);
531
531
  return;
532
532
  }
533
533
  if (c === "draw-rect") {
534
534
  e.dragPan.disable(), o.getState().selectedIds.length > 0 && o.setState({ selectedIds: [] });
535
535
  const x = n.getState().snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
536
- n.getState().setRectCorner(x), N.current = !0, E.current = { x: a.point.x, y: a.point.y };
536
+ n.getState().setRectCorner(x), N.current = !0, P.current = { x: a.point.x, y: a.point.y };
537
537
  return;
538
538
  }
539
539
  if (c === "draw-circle") {
540
540
  e.dragPan.disable(), o.getState().selectedIds.length > 0 && o.setState({ selectedIds: [] });
541
541
  const x = n.getState().snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
542
- n.getState().setCircleCenter(x), N.current = !0, E.current = { x: a.point.x, y: a.point.y };
542
+ n.getState().setCircleCenter(x), N.current = !0, P.current = { x: a.point.x, y: a.point.y };
543
543
  return;
544
544
  }
545
545
  }
546
546
  }, b = (a) => {
547
- if (c === "draw-freehand" && _.current) {
548
- _.current = !1;
549
- const F = e.getZoom(), S = 156543.03392 * Math.cos(a.lngLat.lat * Math.PI / 180) / Math.pow(2, F), L = Ir * S / 111320;
547
+ if (c === "draw-freehand" && F.current) {
548
+ F.current = !1;
549
+ const R = e.getZoom(), S = 156543.03392 * Math.cos(a.lngLat.lat * Math.PI / 180) / Math.pow(2, R), L = Ir * S / 111320;
550
550
  n.getState().commitFreehand(L), Lt();
551
551
  return;
552
552
  }
553
553
  if (!N.current) return;
554
554
  N.current = !1, e.dragPan.enable();
555
- const x = E.current, p = x ? Math.hypot(a.point.x - x.x, a.point.y - x.y) : 0;
556
- E.current = null;
555
+ const x = P.current, y = x ? Math.hypot(a.point.x - x.x, a.point.y - x.y) : 0;
556
+ P.current = null;
557
557
  const m = n.getState();
558
558
  if (c === "draw-rect") {
559
- const F = m.rectCorner;
560
- if (!F) return;
561
- if (p < yn) {
559
+ const R = m.rectCorner;
560
+ if (!R) return;
561
+ if (y < yn) {
562
562
  n.setState({ rectCorner: null });
563
563
  return;
564
564
  }
565
- const S = m.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat], L = M.current || a.originalEvent.shiftKey;
566
- m.commitRect(F, S, {}, L), Lt();
565
+ const S = m.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat], L = k.current || a.originalEvent.shiftKey;
566
+ m.commitRect(R, S, {}, L), Lt();
567
567
  return;
568
568
  }
569
569
  if (c === "draw-circle") {
570
- const F = m.circleCenter;
571
- if (!F) return;
570
+ const R = m.circleCenter;
571
+ if (!R) return;
572
572
  let S;
573
- if (p < yn) {
573
+ if (y < yn) {
574
574
  const V = e.unproject([a.point.x + 25, a.point.y]);
575
575
  S = [V.lng, V.lat];
576
576
  } else
577
577
  S = m.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
578
- const L = S[0] - F[0], B = S[1] - F[1];
579
- Math.hypot(L, B) >= 1e-6 && (m.commitCircle(F, S, {}), Lt());
578
+ const L = S[0] - R[0], B = S[1] - R[1];
579
+ Math.hypot(L, B) >= 1e-6 && (m.commitCircle(R, S, {}), Lt());
580
580
  return;
581
581
  }
582
- }, C = (a) => {
582
+ }, M = (a) => {
583
583
  const x = n.getState();
584
- if (c === "draw-freehand" && _.current) {
584
+ if (c === "draw-freehand" && F.current) {
585
585
  x.addFreehandPoint([a.lngLat.lng, a.lngLat.lat]);
586
586
  return;
587
587
  }
588
588
  if (c === "draw-route" && g.current.length > 0) {
589
- const p = [a.lngLat.lng, a.lngLat.lat];
590
- x.setRouteCursorPos(p), x.setRouteCursorPreview(null), P.current && clearTimeout(P.current), T.current && T.current.abort();
589
+ const y = [a.lngLat.lng, a.lngLat.lat];
590
+ x.setRouteCursorPos(y), x.setRouteCursorPreview(null), C.current && clearTimeout(C.current), T.current && T.current.abort();
591
591
  const m = g.current[g.current.length - 1];
592
- P.current = setTimeout(async () => {
593
- const F = new AbortController();
594
- T.current = F;
592
+ C.current = setTimeout(async () => {
593
+ const R = new AbortController();
594
+ T.current = R;
595
595
  try {
596
596
  if (!i.current) return;
597
- const S = await an([m, p], { ...i.current, signal: F.signal });
598
- F.signal.aborted || n.getState().setRouteCursorPreview(S);
597
+ const S = await an([m, y], { ...i.current, signal: R.signal });
598
+ R.signal.aborted || n.getState().setRouteCursorPreview(S);
599
599
  } catch {
600
600
  }
601
601
  }, 400);
602
602
  }
603
603
  if ((c === "draw-polygon" || c === "cut-hole") && x.polygonInProgress.length >= 3) {
604
- const p = x.polygonInProgress[0], m = e.project(p), F = Math.hypot(a.point.x - m.x, a.point.y - m.y);
605
- e.getCanvas().style.cursor = F <= 48 ? "pointer" : "crosshair";
604
+ const y = x.polygonInProgress[0], m = e.project(y), R = Math.hypot(a.point.x - m.x, a.point.y - m.y);
605
+ e.getCanvas().style.cursor = R <= 48 ? "pointer" : "crosshair";
606
606
  }
607
- }, R = (a) => {
608
- const x = A.click(a.originalEvent);
609
- if (y(a.originalEvent) || kr() || D.current || Gn()) return;
610
- const p = n.getState();
607
+ }, A = (a) => {
608
+ const x = _.click(a.originalEvent);
609
+ if (p(a.originalEvent) || kr() || D.current || Gn()) return;
610
+ const y = n.getState();
611
611
  if (c === "measure") {
612
612
  if (x || Cr()) return;
613
- p.selectedMeasurementId && p.setSelectedMeasurementId(null);
614
- const S = p.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
615
- p.addMeasurePoint(S);
613
+ y.selectedMeasurementId && y.setSelectedMeasurementId(null);
614
+ const S = y.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
615
+ y.addMeasurePoint(S);
616
616
  return;
617
617
  }
618
618
  ["place-point", "draw-line", "draw-polygon", "draw-route", "draw-circle", "draw-rect"].includes(c) && o.getState().selectedIds.length > 0 && o.setState({ selectedIds: [] });
619
- const F = p.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
619
+ const R = y.snappedCoord ?? [a.lngLat.lng, a.lngLat.lat];
620
620
  if (c === "place-point") {
621
621
  if (x) return;
622
- p.commitPoint(F);
622
+ y.commitPoint(R);
623
623
  return;
624
624
  }
625
625
  if (c === "draw-line" || c === "draw-polygon" || c === "draw-route" || c === "cut-hole" || c === "slice-shape") {
626
- let S = F;
627
- if (M.current || a.originalEvent.shiftKey) {
628
- const L = c === "draw-line" || c === "slice-shape" ? p.lineInProgress : p.polygonInProgress;
626
+ let S = R;
627
+ if (k.current || a.originalEvent.shiftKey) {
628
+ const L = c === "draw-line" || c === "slice-shape" ? y.lineInProgress : y.polygonInProgress;
629
629
  L.length >= 1 && (S = Dt(e, L[L.length - 1], S));
630
630
  }
631
- if ((c === "draw-polygon" || c === "cut-hole") && p.polygonInProgress.length >= 2) {
632
- const L = p.polygonInProgress[0], B = e.project(L);
631
+ if ((c === "draw-polygon" || c === "cut-hole") && y.polygonInProgress.length >= 2) {
632
+ const L = y.polygonInProgress[0], B = e.project(L);
633
633
  if (Math.hypot(a.point.x - B.x, a.point.y - B.y) <= 48) {
634
- c === "draw-polygon" ? p.commitPolygon({}) : p.commitCutHole();
634
+ c === "draw-polygon" ? y.commitPolygon({}) : y.commitCutHole();
635
635
  return;
636
636
  }
637
637
  }
638
638
  if (x) return;
639
- if (c === "draw-line" || c === "slice-shape") p.addLineVertex(S);
640
- else if (c === "draw-polygon" || c === "cut-hole") p.addPolygonVertex(S);
639
+ if (c === "draw-line" || c === "slice-shape") y.addLineVertex(S);
640
+ else if (c === "draw-polygon" || c === "cut-hole") y.addPolygonVertex(S);
641
641
  else if (c === "draw-route") {
642
- w.current = { waypoints: [...g.current], preview: p.routePreview }, P.current && (clearTimeout(P.current), P.current = null), T.current && (T.current.abort(), T.current = null), p.setRouteCursorPos(null), p.setRouteCursorPreview(null), p.addRouteWaypoint(S);
642
+ w.current = { waypoints: [...g.current], preview: y.routePreview }, C.current && (clearTimeout(C.current), C.current = null), T.current && (T.current.abort(), T.current = null), y.setRouteCursorPos(null), y.setRouteCursorPreview(null), y.addRouteWaypoint(S);
643
643
  const L = [...g.current, S];
644
644
  q(L);
645
645
  }
646
646
  return;
647
647
  }
648
- }, I = () => {
649
- if (!A.isDouble()) return;
648
+ }, E = () => {
649
+ if (!_.isDouble()) return;
650
650
  const a = n.getState();
651
651
  if (c === "measure") {
652
652
  a.completeMeasure();
@@ -658,8 +658,8 @@ function Rr({ map: e, routingApiKey: t }) {
658
658
  routeLoading: !1
659
659
  }), w.current = null), a.commitRoute());
660
660
  };
661
- return e.on("mousedown", f), e.on("mouseup", b), e.on("mousemove", C), e.on("click", R), e.on("dblclick", I), () => {
662
- e.off("mousedown", f), e.off("mouseup", b), e.off("mousemove", C), e.off("click", R), e.off("dblclick", I);
661
+ return e.on("mousedown", f), e.on("mouseup", b), e.on("mousemove", M), e.on("click", A), e.on("dblclick", E), () => {
662
+ e.off("mousedown", f), e.off("mouseup", b), e.off("mousemove", M), e.off("click", A), e.off("dblclick", E);
663
663
  };
664
664
  }, [c, e, q, n, o]), null;
665
665
  }
@@ -751,9 +751,9 @@ function Ar({ map: e }) {
751
751
  if (g.length === 0) return Fe(e, []);
752
752
  let w = v ?? g[g.length - 1];
753
753
  l.current && g.length >= 1 && (w = Dt(e, g[g.length - 1], w));
754
- const P = [...g, w];
755
- d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: P } }), g.forEach((T, _) => {
756
- d.push({ type: "Feature", properties: { _isFirst: _ === 0 }, geometry: { type: "Point", coordinates: T } });
754
+ const C = [...g, w];
755
+ d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: C } }), g.forEach((T, F) => {
756
+ d.push({ type: "Feature", properties: { _isFirst: F === 0 }, geometry: { type: "Point", coordinates: T } });
757
757
  });
758
758
  }
759
759
  if (c.editingMode === "draw-polygon" || c.editingMode === "cut-hole") {
@@ -761,31 +761,31 @@ function Ar({ map: e }) {
761
761
  if (g.length === 0) return Fe(e, []);
762
762
  let w = v ?? g[g.length - 1];
763
763
  l.current && g.length >= 1 && (w = Dt(e, g[g.length - 1], w));
764
- const P = [...g, w, g[0]];
765
- g.length >= 2 ? d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [P] } }) : d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: P } }), g.forEach((T, _) => {
766
- d.push({ type: "Feature", properties: { _isFirst: _ === 0 }, geometry: { type: "Point", coordinates: T } });
764
+ const C = [...g, w, g[0]];
765
+ g.length >= 2 ? d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [C] } }) : d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: C } }), g.forEach((T, F) => {
766
+ d.push({ type: "Feature", properties: { _isFirst: F === 0 }, geometry: { type: "Point", coordinates: T } });
767
767
  });
768
768
  }
769
769
  if (c.editingMode === "draw-circle") {
770
770
  const g = c.circleCenter;
771
771
  if (!g) return Fe(e, []);
772
- const w = v ?? g, P = vo(g, w, s.current, 64);
773
- d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [P] } }), d.push({ type: "Feature", properties: { _isFirst: !0 }, geometry: { type: "Point", coordinates: g } }), d.push({ type: "Feature", properties: {}, geometry: { type: "Point", coordinates: w } });
772
+ const w = v ?? g, C = vo(g, w, s.current, 64);
773
+ d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [C] } }), d.push({ type: "Feature", properties: { _isFirst: !0 }, geometry: { type: "Point", coordinates: g } }), d.push({ type: "Feature", properties: {}, geometry: { type: "Point", coordinates: w } });
774
774
  }
775
775
  if (c.editingMode === "draw-rect") {
776
776
  const g = c.rectCorner;
777
777
  if (!g) return Fe(e, []);
778
- const P = xo(g, v ?? g, s.current, l.current);
779
- d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [P] } });
778
+ const C = xo(g, v ?? g, s.current, l.current);
779
+ d.push({ type: "Feature", properties: {}, geometry: { type: "Polygon", coordinates: [C] } });
780
780
  }
781
781
  if (c.editingMode === "draw-route") {
782
782
  const g = c.routeWaypoints;
783
783
  if (g.length === 0) return Fe(e, []);
784
784
  const w = c.routePreview ?? g;
785
785
  w.length >= 2 && d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: w } });
786
- const P = c.routeCursorPreview ?? (v ? [g[g.length - 1], v] : null);
787
- P && P.length >= 2 && d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: P } }), g.forEach((T, _) => {
788
- d.push({ type: "Feature", properties: { _isFirst: _ === 0 }, geometry: { type: "Point", coordinates: T } });
786
+ const C = c.routeCursorPreview ?? (v ? [g[g.length - 1], v] : null);
787
+ C && C.length >= 2 && d.push({ type: "Feature", properties: {}, geometry: { type: "LineString", coordinates: C } }), g.forEach((T, F) => {
788
+ d.push({ type: "Feature", properties: { _isFirst: F === 0 }, geometry: { type: "Point", coordinates: T } });
789
789
  });
790
790
  }
791
791
  if (c.editingMode === "draw-freehand") {
@@ -888,23 +888,23 @@ function Un({ map: e, coords: t, onSave: n, onClose: o }) {
888
888
  }), d = $(null);
889
889
  K(() => {
890
890
  const w = () => {
891
- const P = e.project(t);
892
- v({ x: P.x, y: P.y });
891
+ const C = e.project(t);
892
+ v({ x: C.x, y: C.y });
893
893
  };
894
894
  return e.on("move", w), e.on("zoom", w), e.on("resize", w), () => {
895
895
  e.off("move", w), e.off("zoom", w), e.off("resize", w);
896
896
  };
897
897
  }, [e, t]), K(() => {
898
- var w, P;
899
- (w = d.current) == null || w.focus(), (P = d.current) == null || P.select();
898
+ var w, C;
899
+ (w = d.current) == null || w.focus(), (C = d.current) == null || C.select();
900
900
  }, []);
901
901
  function g() {
902
- const w = parseFloat(s), P = parseFloat(l);
903
- if (isNaN(w) || isNaN(P)) {
902
+ const w = parseFloat(s), C = parseFloat(l);
903
+ if (isNaN(w) || isNaN(C)) {
904
904
  r({ type: "warning", message: "Invalid coordinates" });
905
905
  return;
906
906
  }
907
- n([w, P]), r({ type: "success", message: "Coordinate updated" }), o();
907
+ n([w, C]), r({ type: "success", message: "Coordinate updated" }), o();
908
908
  }
909
909
  return Ze(
910
910
  /* @__PURE__ */ X(
@@ -1140,46 +1140,46 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1140
1140
  K(() => {
1141
1141
  g.current = v;
1142
1142
  }, [v]);
1143
- const w = $(/* @__PURE__ */ new Map()), [P, T] = le(null), _ = ve(() => T(null), []), [M, N] = le(null);
1143
+ const w = $(/* @__PURE__ */ new Map()), [C, T] = le(null), F = ve(() => T(null), []), [k, N] = le(null);
1144
1144
  K(() => {
1145
1145
  d(/* @__PURE__ */ new Set()), T(null), N(null);
1146
1146
  }, [t.id, u]);
1147
- const E = $(n);
1147
+ const P = $(n);
1148
1148
  K(() => {
1149
- n !== E.current && (E.current = n, !(!n || n.length === 0) && d((h) => {
1150
- const k = new Set(h);
1151
- for (const O of n) k.add(`0:${O}`);
1149
+ n !== P.current && (P.current = n, !(!n || n.length === 0) && d((h) => {
1150
+ const I = new Set(h);
1151
+ for (const O of n) I.add(`0:${O}`);
1152
1152
  for (const O of n) {
1153
1153
  const z = w.current.get(`0:${O}`);
1154
1154
  z && Ct(z, !0);
1155
1155
  }
1156
- return k;
1156
+ return I;
1157
1157
  }));
1158
1158
  }, [n]);
1159
- function A(h) {
1159
+ function _(h) {
1160
1160
  Vt(e, /* @__PURE__ */ new Map([[t.id, h]]));
1161
1161
  }
1162
1162
  function D(h) {
1163
- const k = nt(t.geometry, u, h);
1164
- o.getState().updateFeature(t.id, So(t, k));
1163
+ const I = nt(t.geometry, u, h);
1164
+ o.getState().updateFeature(t.id, So(t, I));
1165
1165
  }
1166
1166
  const q = $(!1);
1167
1167
  K(() => {
1168
- const h = (k) => {
1169
- q.current = k.metaKey || k.ctrlKey;
1168
+ const h = (I) => {
1169
+ q.current = I.metaKey || I.ctrlKey;
1170
1170
  };
1171
1171
  return window.addEventListener("keydown", h), window.addEventListener("keyup", h), () => {
1172
1172
  window.removeEventListener("keydown", h), window.removeEventListener("keyup", h);
1173
1173
  };
1174
1174
  }, []);
1175
- function y() {
1176
- Br(), c.current.forEach((z) => z.remove()), c.current = [], w.current = /* @__PURE__ */ new Map(), f.current = [], b.current = null, C.current = !1;
1175
+ function p() {
1176
+ Br(), c.current.forEach((z) => z.remove()), c.current = [], w.current = /* @__PURE__ */ new Map(), f.current = [], b.current = null, M.current = !1;
1177
1177
  const h = Oe(t.geometry, u);
1178
1178
  if (!h) return;
1179
- const k = ot(h), O = g.current;
1180
- I.current = !1, k.forEach((z, G) => {
1179
+ const I = ot(h), O = g.current;
1180
+ E.current = !1, I.forEach((z, G) => {
1181
1181
  const H = h.type === "Polygon" ? z.slice(0, -1) : z, te = Sn(e, H, (Z) => O.has(`${G}:${Z}`));
1182
- te.capped && (I.current = !0);
1182
+ te.capped && (E.current = !0);
1183
1183
  for (const Z of te.indices) {
1184
1184
  const ne = H[Z], se = `${G}:${Z}`, ie = xn(O.has(se));
1185
1185
  w.current.set(se, ie);
@@ -1197,13 +1197,13 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1197
1197
  return Q && Ct(Q, oe.has(se)), oe;
1198
1198
  }) : (d(/* @__PURE__ */ new Set([se])), w.current.forEach((ee, oe) => Ct(ee, oe === se)));
1199
1199
  }), re.on("dragstart", () => {
1200
- J = !0, C.current = !0, o.getState().takeSnapshot(), document.querySelectorAll(".elm-midpoint-marker").forEach((Y) => {
1200
+ J = !0, M.current = !0, o.getState().takeSnapshot(), document.querySelectorAll(".elm-midpoint-marker").forEach((Y) => {
1201
1201
  Y.style.display = "none";
1202
1202
  }), Ce(!0);
1203
1203
  });
1204
1204
  const ce = [ne[0], ne[1]], U = ze(() => {
1205
1205
  const Y = re.getLngLat(), ee = [Y.lng, Y.lat], oe = Mt(h, G, Z, ee);
1206
- A(nt(t.geometry, u, oe));
1206
+ _(nt(t.geometry, u, oe));
1207
1207
  });
1208
1208
  re.on("drag", () => U.schedule()), re.on("dragend", () => {
1209
1209
  U.cancel();
@@ -1217,7 +1217,7 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1217
1217
  ee
1218
1218
  ));
1219
1219
  }
1220
- Ce(!1), C.current = !1, setTimeout(() => {
1220
+ Ce(!1), M.current = !1, setTimeout(() => {
1221
1221
  J = !1;
1222
1222
  }, 50);
1223
1223
  }), ie.addEventListener("contextmenu", (Y) => {
@@ -1228,18 +1228,18 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1228
1228
  const Z = h.type === "Polygon" ? H.length : H.length - 1, ne = [];
1229
1229
  for (let ie = 0; ie < Z; ie++) ne.push(Or(H[ie], H[(ie + 1) % H.length]));
1230
1230
  const se = Sn(e, ne, () => !1);
1231
- se.capped && (I.current = !0);
1231
+ se.capped && (E.current = !0);
1232
1232
  for (const ie of se.indices) {
1233
1233
  const re = H[ie], J = H[(ie + 1) % H.length], ce = ne[ie], U = xn(!1, !0);
1234
1234
  U.style.display = "none", f.current.push({ el: U, a: re, b: J });
1235
1235
  const Y = new De.Marker({ element: U, draggable: !0 }).setLngLat(ce).addTo(e);
1236
1236
  let ee = !1;
1237
1237
  Y.on("dragstart", () => {
1238
- ee = !0, C.current = !0, o.getState().takeSnapshot(), Ce(!0);
1238
+ ee = !0, M.current = !0, o.getState().takeSnapshot(), Ce(!0);
1239
1239
  });
1240
1240
  const oe = ze(() => {
1241
1241
  const Q = Y.getLngLat(), de = [Q.lng, Q.lat], ue = He(h, G, ie + 1, de);
1242
- A(nt(t.geometry, u, ue));
1242
+ _(nt(t.geometry, u, ue));
1243
1243
  });
1244
1244
  Y.on("drag", () => oe.schedule()), Y.on("dragend", () => {
1245
1245
  oe.cancel();
@@ -1256,7 +1256,7 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1256
1256
  }
1257
1257
  setTimeout(() => {
1258
1258
  ee = !1;
1259
- }, 50), Ce(!1), C.current = !1;
1259
+ }, 50), Ce(!1), M.current = !1;
1260
1260
  }), U.addEventListener("click", (Q) => {
1261
1261
  if (Q.stopPropagation(), ee) {
1262
1262
  ee = !1;
@@ -1279,14 +1279,14 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1279
1279
  }
1280
1280
  });
1281
1281
  }
1282
- const f = $([]), b = $(null), C = $(!1);
1282
+ const f = $([]), b = $(null), M = $(!1);
1283
1283
  K(() => {
1284
1284
  const h = (z) => {
1285
1285
  if (z === b.current) return;
1286
1286
  const G = f.current;
1287
1287
  b.current !== null && G[b.current] && (G[b.current].el.style.display = "none"), z !== null && (G[z].el.style.display = "flex"), b.current = z;
1288
- }, k = (z) => {
1289
- if (C.current) return;
1288
+ }, I = (z) => {
1289
+ if (M.current) return;
1290
1290
  const { x: G, y: H } = z.point;
1291
1291
  let te = -1, Z = 1 / 0;
1292
1292
  f.current.forEach(({ a: se, b: ie }, re) => {
@@ -1297,18 +1297,18 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1297
1297
  h(te >= 0 && Z <= ne * ne ? te : null);
1298
1298
  }, O = (z) => {
1299
1299
  const G = z.originalEvent.relatedTarget;
1300
- !C.current && !(G instanceof Node && e.getContainer().contains(G)) && h(null);
1300
+ !M.current && !(G instanceof Node && e.getContainer().contains(G)) && h(null);
1301
1301
  };
1302
- return e.on("mousemove", k), e.on("mouseout", O), () => {
1303
- e.off("mousemove", k), e.off("mouseout", O);
1302
+ return e.on("mousemove", I), e.on("mouseout", O), () => {
1303
+ e.off("mousemove", I), e.off("mouseout", O);
1304
1304
  };
1305
1305
  }, [e]);
1306
- const R = $(() => {
1306
+ const A = $(() => {
1307
1307
  });
1308
- R.current = (h) => {
1308
+ A.current = (h) => {
1309
1309
  var ee, oe;
1310
- const k = h.originalEvent;
1311
- if (C.current || k.button !== 0 || k.shiftKey || (oe = (ee = k.target) == null ? void 0 : ee.closest) != null && oe.call(ee, ".maplibregl-marker")) return;
1310
+ const I = h.originalEvent;
1311
+ if (M.current || I.button !== 0 || I.shiftKey || (oe = (ee = I.target) == null ? void 0 : ee.closest) != null && oe.call(ee, ".maplibregl-marker")) return;
1312
1312
  const O = Oe(t.geometry, u);
1313
1313
  if (!O || O.type !== "Polygon" && O.type !== "LineString") return;
1314
1314
  const z = O.type === "Polygon";
@@ -1327,11 +1327,11 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1327
1327
  const ie = h.point;
1328
1328
  let re = [h.lngLat.lng, h.lngLat.lat], J = !1;
1329
1329
  const ce = ze(() => {
1330
- A(nt(t.geometry, u, He(O, te, Z + 1, re)));
1330
+ _(nt(t.geometry, u, He(O, te, Z + 1, re)));
1331
1331
  }), U = (Q) => {
1332
1332
  if (!J) {
1333
1333
  if (Math.hypot(Q.point.x - ie.x, Q.point.y - ie.y) < 3) return;
1334
- J = !0, C.current = !0, o.getState().takeSnapshot(), document.querySelectorAll(".elm-midpoint-marker").forEach((ue) => {
1334
+ J = !0, M.current = !0, o.getState().takeSnapshot(), document.querySelectorAll(".elm-midpoint-marker").forEach((ue) => {
1335
1335
  ue.style.display = "none";
1336
1336
  }), b.current = null, Ce(!0);
1337
1337
  }
@@ -1348,53 +1348,53 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1348
1348
  const Q = o.getState();
1349
1349
  Q.updateFeatures(wt(Q.features, t.id, ne, se, re));
1350
1350
  }
1351
- Ce(!1), C.current = !1;
1351
+ Ce(!1), M.current = !1;
1352
1352
  }
1353
1353
  };
1354
1354
  e.on("mousemove", U), window.addEventListener("mouseup", Y);
1355
1355
  }, K(() => {
1356
- const h = (k) => R.current(k);
1356
+ const h = (I) => A.current(I);
1357
1357
  return e.on("mousedown", h), () => {
1358
1358
  e.off("mousedown", h);
1359
1359
  };
1360
1360
  }, [e]);
1361
- const I = $(!1), a = $(y);
1362
- a.current = y, K(() => {
1361
+ const E = $(!1), a = $(p);
1362
+ a.current = p, K(() => {
1363
1363
  const h = () => {
1364
- I.current && a.current();
1364
+ E.current && a.current();
1365
1365
  };
1366
1366
  return e.on("moveend", h), () => {
1367
1367
  e.off("moveend", h);
1368
1368
  };
1369
- }, [e]), K(() => (y(), () => {
1369
+ }, [e]), K(() => (p(), () => {
1370
1370
  c.current.forEach((h) => h.remove()), c.current = [], w.current = /* @__PURE__ */ new Map();
1371
1371
  }), [t, e, l, u]);
1372
- function x(h, k) {
1372
+ function x(h, I) {
1373
1373
  const O = Oe(t.geometry, u);
1374
1374
  if (!O) return;
1375
- const z = jr(O, h, k);
1375
+ const z = jr(O, h, I);
1376
1376
  if (!z) {
1377
1377
  s({ type: "warning", message: `Cannot delete: ${O.type === "Polygon" ? "an area needs at least 3" : O.type === "LineString" ? "a line needs at least 2" : "at least 1"} points` });
1378
1378
  return;
1379
1379
  }
1380
- const G = ot(O)[h][k];
1380
+ const G = ot(O)[h][I];
1381
1381
  if (o.getState().takeSnapshot(), D(z), d(/* @__PURE__ */ new Set()), O.type === "Polygon" && r.getState().topoEditEnabled) {
1382
1382
  const H = o.getState();
1383
1383
  H.updateFeatures(rn(H.features, t.id, [G]));
1384
1384
  }
1385
1385
  }
1386
- function p() {
1386
+ function y() {
1387
1387
  const h = g.current;
1388
1388
  if (h.size === 0) return;
1389
- const k = Oe(t.geometry, u);
1390
- if (!k) return;
1389
+ const I = Oe(t.geometry, u);
1390
+ if (!I) return;
1391
1391
  const O = /* @__PURE__ */ new Map();
1392
1392
  for (const z of h) {
1393
1393
  const [G, H] = z.split(":"), te = Number(G), Z = Number(H), ne = O.get(te) ?? [];
1394
1394
  ne.push(Z), O.set(te, ne);
1395
1395
  }
1396
- if (k.type === "LineString") {
1397
- const z = k.coordinates, G = new Set(O.get(0) ?? []), H = z.filter((te, Z) => !G.has(Z));
1396
+ if (I.type === "LineString") {
1397
+ const z = I.coordinates, G = new Set(O.get(0) ?? []), H = z.filter((te, Z) => !G.has(Z));
1398
1398
  if (H.length < 2) {
1399
1399
  s({ type: "warning", message: "Cannot delete: a line needs at least 2 points" });
1400
1400
  return;
@@ -1402,8 +1402,8 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1402
1402
  o.getState().takeSnapshot(), D({ type: "LineString", coordinates: H }), d(/* @__PURE__ */ new Set());
1403
1403
  return;
1404
1404
  }
1405
- if (k.type === "MultiPoint") {
1406
- const z = k.coordinates, G = new Set(O.get(0) ?? []), H = z.filter((te, Z) => !G.has(Z));
1405
+ if (I.type === "MultiPoint") {
1406
+ const z = I.coordinates, G = new Set(O.get(0) ?? []), H = z.filter((te, Z) => !G.has(Z));
1407
1407
  if (H.length < 1) {
1408
1408
  s({ type: "warning", message: "Cannot delete: at least 1 point required" });
1409
1409
  return;
@@ -1411,8 +1411,8 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1411
1411
  o.getState().takeSnapshot(), D({ type: "MultiPoint", coordinates: H }), d(/* @__PURE__ */ new Set());
1412
1412
  return;
1413
1413
  }
1414
- if (k.type === "Polygon") {
1415
- const z = k.coordinates, G = [];
1414
+ if (I.type === "Polygon") {
1415
+ const z = I.coordinates, G = [];
1416
1416
  for (let H = 0; H < z.length; H++) {
1417
1417
  const te = z[H], Z = te.slice(0, -1), ne = new Set(O.get(H) ?? []);
1418
1418
  if (ne.size === 0) {
@@ -1440,16 +1440,16 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1440
1440
  }
1441
1441
  const h = Oe(t.geometry, u);
1442
1442
  if (!h || h.type !== "LineString" && h.type !== "Polygon") return;
1443
- const k = /* @__PURE__ */ new Map();
1443
+ const I = /* @__PURE__ */ new Map();
1444
1444
  for (const U of g.current) {
1445
- const [Y, ee] = U.split(":"), oe = Number(Y), Q = Number(ee), de = k.get(oe) ?? [];
1446
- de.push(Q), k.set(oe, de);
1445
+ const [Y, ee] = U.split(":"), oe = Number(Y), Q = Number(ee), de = I.get(oe) ?? [];
1446
+ de.push(Q), I.set(oe, de);
1447
1447
  }
1448
- if (k.size !== 1) {
1448
+ if (I.size !== 1) {
1449
1449
  s({ type: "warning", message: "Selection must stay within one ring/line to simplify" });
1450
1450
  return;
1451
1451
  }
1452
- const [O, z] = Array.from(k.entries())[0], G = z.sort((U, Y) => U - Y), H = G[0], te = G[G.length - 1], Z = h.type === "Polygon", ne = Z ? h.coordinates[O].slice(0, -1) : h.coordinates, se = ne.slice(H, te + 1), ie = bo(se, 1e-5), re = se.length - ie.length;
1452
+ const [O, z] = Array.from(I.entries())[0], G = z.sort((U, Y) => U - Y), H = G[0], te = G[G.length - 1], Z = h.type === "Polygon", ne = Z ? h.coordinates[O].slice(0, -1) : h.coordinates, se = ne.slice(H, te + 1), ie = bo(se, 1e-5), re = se.length - ie.length;
1453
1453
  if (re === 0) {
1454
1454
  s({ type: "warning", message: "Nothing to remove: no selected point sits on a straight line" });
1455
1455
  return;
@@ -1470,57 +1470,57 @@ function $r({ map: e, feature: t, initialSelectedIndices: n }) {
1470
1470
  }
1471
1471
  K(() => {
1472
1472
  if (v.size === 0) return;
1473
- function h(k) {
1474
- if (k.key !== "Delete" && k.key !== "Backspace") return;
1475
- const O = k.target;
1476
- O && (O.tagName === "INPUT" || O.tagName === "TEXTAREA" || O.isContentEditable) || i(k) && (k.preventDefault(), k.stopPropagation(), p());
1473
+ function h(I) {
1474
+ if (I.key !== "Delete" && I.key !== "Backspace") return;
1475
+ const O = I.target;
1476
+ O && (O.tagName === "INPUT" || O.tagName === "TEXTAREA" || O.isContentEditable) || i(I) && (I.preventDefault(), I.stopPropagation(), y());
1477
1477
  }
1478
1478
  return window.addEventListener("keydown", h, { capture: !0 }), () => window.removeEventListener("keydown", h, { capture: !0 });
1479
1479
  }, [v]);
1480
- const F = v.size > 0, S = P && (() => {
1481
- const h = `${P.ringIdx}:${P.vertIdx}`, k = v.has(h) && v.size > 1;
1480
+ const R = v.size > 0, S = C && (() => {
1481
+ const h = `${C.ringIdx}:${C.vertIdx}`, I = v.has(h) && v.size > 1;
1482
1482
  return /* @__PURE__ */ X(
1483
1483
  Ko,
1484
1484
  {
1485
- x: P.x,
1486
- y: P.y,
1487
- onClose: _,
1485
+ x: C.x,
1486
+ y: C.y,
1487
+ onClose: F,
1488
1488
  items: [
1489
- { label: "Edit coordinates…", icon: /* @__PURE__ */ X(rr, { size: 16 }), onClick: () => N({ ringIdx: P.ringIdx, vertIdx: P.vertIdx }) },
1489
+ { label: "Edit coordinates…", icon: /* @__PURE__ */ X(rr, { size: 16 }), onClick: () => N({ ringIdx: C.ringIdx, vertIdx: C.vertIdx }) },
1490
1490
  { separator: !0 },
1491
1491
  {
1492
- label: k ? `Delete ${v.size} points` : "Delete point",
1492
+ label: I ? `Delete ${v.size} points` : "Delete point",
1493
1493
  icon: /* @__PURE__ */ X(sr, { size: 16 }),
1494
- onClick: () => k ? p() : x(P.ringIdx, P.vertIdx)
1494
+ onClick: () => I ? y() : x(C.ringIdx, C.vertIdx)
1495
1495
  }
1496
1496
  ]
1497
1497
  }
1498
1498
  );
1499
- })(), L = M && Oe(t.geometry, u), B = L && M ? (j = ot(L)[M.ringIdx]) == null ? void 0 : j[M.vertIdx] : void 0, V = M && L && B && /* @__PURE__ */ X(
1499
+ })(), L = k && Oe(t.geometry, u), B = L && k ? (j = ot(L)[k.ringIdx]) == null ? void 0 : j[k.vertIdx] : void 0, V = k && L && B && /* @__PURE__ */ X(
1500
1500
  Un,
1501
1501
  {
1502
1502
  map: e,
1503
1503
  coords: B,
1504
1504
  onSave: (h) => {
1505
- if (o.getState().takeSnapshot(), D(Mt(L, M.ringIdx, M.vertIdx, h)), L.type === "Polygon" && r.getState().topoEditEnabled) {
1506
- const k = o.getState();
1507
- k.updateFeatures(on(k.features, t.id, B, h));
1505
+ if (o.getState().takeSnapshot(), D(Mt(L, k.ringIdx, k.vertIdx, h)), L.type === "Polygon" && r.getState().topoEditEnabled) {
1506
+ const I = o.getState();
1507
+ I.updateFeatures(on(I.features, t.id, B, h));
1508
1508
  }
1509
1509
  },
1510
1510
  onClose: () => N(null)
1511
1511
  },
1512
- `${M.ringIdx}:${M.vertIdx}`
1512
+ `${k.ringIdx}:${k.vertIdx}`
1513
1513
  );
1514
1514
  return /* @__PURE__ */ fe(lt, { children: [
1515
1515
  S,
1516
1516
  V,
1517
- F && /* @__PURE__ */ X(
1517
+ R && /* @__PURE__ */ X(
1518
1518
  No,
1519
1519
  {
1520
1520
  mapContainer: e.getContainer(),
1521
1521
  count: v.size,
1522
1522
  onSimplify: m,
1523
- onDelete: p
1523
+ onDelete: y
1524
1524
  }
1525
1525
  )
1526
1526
  ] });
@@ -1625,30 +1625,30 @@ function kt(e, t, n) {
1625
1625
  function Yr(e, t, n, o, r) {
1626
1626
  const [s, i] = t, l = Ke(r), u = Math.cos(l), c = Math.sin(l), v = Te(i);
1627
1627
  return e.map(([d, g]) => {
1628
- const w = (d - s) * v, P = g - i, T = w * u + P * c, _ = -w * c + P * u, M = T * n, N = _ * o, E = M * u - N * c, A = M * c + N * u;
1629
- return [s + E / v, i + A];
1628
+ const w = (d - s) * v, C = g - i, T = w * u + C * c, F = -w * c + C * u, k = T * n, N = F * o, P = k * u - N * c, _ = k * c + N * u;
1629
+ return [s + P / v, i + _];
1630
1630
  });
1631
1631
  }
1632
1632
  function Gr(e, t, n, o) {
1633
1633
  const r = me(t), s = Ke(o), i = Math.cos(s), l = Math.sin(s);
1634
1634
  function u(c) {
1635
- const v = me(c), d = v[0] - r[0], g = v[1] - r[1], w = d * i + g * l, P = -d * l + g * i, T = w * n, _ = P * n, M = T * i - _ * l, N = T * l + _ * i;
1636
- return Ot([r[0] + M, r[1] + N]);
1635
+ const v = me(c), d = v[0] - r[0], g = v[1] - r[1], w = d * i + g * l, C = -d * l + g * i, T = w * n, F = C * n, k = T * i - F * l, N = T * l + F * i;
1636
+ return Ot([r[0] + k, r[1] + N]);
1637
1637
  }
1638
1638
  return { ...e, geometry: _n(e.geometry, u) };
1639
1639
  }
1640
1640
  function Wr(e, t, n, o) {
1641
1641
  const r = me(t), s = Ke(o), i = Math.cos(s), l = Math.sin(s);
1642
1642
  return e.map((u) => {
1643
- const c = me(u), v = c[0] - r[0], d = c[1] - r[1], g = v * i + d * l, w = -v * l + d * i, P = g * n, T = w * n, _ = P * i - T * l, M = P * l + T * i;
1644
- return Ot([r[0] + _, r[1] + M]);
1643
+ const c = me(u), v = c[0] - r[0], d = c[1] - r[1], g = v * i + d * l, w = -v * l + d * i, C = g * n, T = w * n, F = C * i - T * l, k = C * l + T * i;
1644
+ return Ot([r[0] + F, r[1] + k]);
1645
1645
  });
1646
1646
  }
1647
1647
  function Ur(e, t, n, o, r) {
1648
1648
  const [s, i] = t, l = Ke(r), u = Math.cos(l), c = Math.sin(l), v = Te(i);
1649
1649
  function d(g) {
1650
- const w = (g[0] - s) * v, P = g[1] - i, T = w * u + P * c, _ = -w * c + P * u, M = T * n, N = _ * o, E = M * u - N * c, A = M * c + N * u;
1651
- return [s + E / v, i + A];
1650
+ const w = (g[0] - s) * v, C = g[1] - i, T = w * u + C * c, F = -w * c + C * u, k = T * n, N = F * o, P = k * u - N * c, _ = k * c + N * u;
1651
+ return [s + P / v, i + _];
1652
1652
  }
1653
1653
  return { ...e, geometry: _n(e.geometry, d) };
1654
1654
  }
@@ -1659,34 +1659,34 @@ function qr(e, t, n, o) {
1659
1659
  const r = o ? e.initialBbox.center : e.origin, s = Math.cos(Ke(e.rotationAngle)), i = Math.sin(Ke(e.rotationAngle));
1660
1660
  let l;
1661
1661
  if (n) {
1662
- const _ = me(r);
1663
- l = (M) => {
1664
- const N = me(M), E = N[0] - _[0], A = N[1] - _[1];
1665
- return [E * s + A * i, -E * i + A * s];
1662
+ const F = me(r);
1663
+ l = (k) => {
1664
+ const N = me(k), P = N[0] - F[0], _ = N[1] - F[1];
1665
+ return [P * s + _ * i, -P * i + _ * s];
1666
1666
  };
1667
1667
  } else {
1668
- const _ = Te(r[1]);
1669
- l = (M) => {
1670
- const N = (M[0] - r[0]) * _, E = M[1] - r[1];
1671
- return [N * s + E * i, -N * i + E * s];
1668
+ const F = Te(r[1]);
1669
+ l = (k) => {
1670
+ const N = (k[0] - r[0]) * F, P = k[1] - r[1];
1671
+ return [N * s + P * i, -N * i + P * s];
1672
1672
  };
1673
1673
  }
1674
- const [u, c] = l(e.startLngLat), [v, d] = l(t), g = e.edgeIndex === 0 || e.edgeIndex === 2, w = e.edgeIndex === 1 || e.edgeIndex === 3, P = (_) => Math.abs(_) < 0.01 ? _ < 0 ? -0.01 : 0.01 : _, T = (_, M) => Math.abs(M) > 1e-9 ? _ / M : 1;
1674
+ const [u, c] = l(e.startLngLat), [v, d] = l(t), g = e.edgeIndex === 0 || e.edgeIndex === 2, w = e.edgeIndex === 1 || e.edgeIndex === 3, C = (F) => Math.abs(F) < 0.01 ? F < 0 ? -0.01 : 0.01 : F, T = (F, k) => Math.abs(k) > 1e-9 ? F / k : 1;
1675
1675
  if (n) {
1676
- let _;
1677
- if (g) _ = T(d, c);
1678
- else if (w) _ = T(v, u);
1676
+ let F;
1677
+ if (g) F = T(d, c);
1678
+ else if (w) F = T(v, u);
1679
1679
  else {
1680
- const M = u * u + c * c;
1681
- _ = M > 1e-18 ? (v * u + d * c) / M : 1;
1680
+ const k = u * u + c * c;
1681
+ F = k > 1e-18 ? (v * u + d * c) / k : 1;
1682
1682
  }
1683
- return { origin: r, uniform: !0, factor: P(_) };
1683
+ return { origin: r, uniform: !0, factor: C(F) };
1684
1684
  }
1685
1685
  return {
1686
1686
  origin: r,
1687
1687
  uniform: !1,
1688
- scaleX: w || !g ? P(T(v, u)) : 1,
1689
- scaleY: g || !w ? P(T(d, c)) : 1
1688
+ scaleX: w || !g ? C(T(v, u)) : 1,
1689
+ scaleY: g || !w ? C(T(d, c)) : 1
1690
1690
  };
1691
1691
  }
1692
1692
  function Jr(e, t, n, o) {
@@ -1748,7 +1748,7 @@ function It(e) {
1748
1748
  ].join(";"), t;
1749
1749
  }
1750
1750
  function es({ map: e, features: t }) {
1751
- const { dataStore: n, uiStore: o } = Le(), r = he((y) => y.selectedIds), s = W((y) => y.transformActive), i = W((y) => y.setTransformDragging), l = $(t);
1751
+ const { dataStore: n, uiStore: o } = Le(), r = he((p) => p.selectedIds), s = W((p) => p.transformActive), i = W((p) => p.setTransformDragging), l = $(t);
1752
1752
  l.current = t;
1753
1753
  const [u, c] = le(null), v = $(null);
1754
1754
  v.current = u;
@@ -1756,75 +1756,75 @@ function es({ map: e, features: t }) {
1756
1756
  K(() => {
1757
1757
  c(null), d.current = 0;
1758
1758
  }, [g]);
1759
- const w = $(null), P = $(null), T = $([]);
1760
- function _() {
1761
- T.current.forEach((y) => y.remove()), T.current = [];
1759
+ const w = $(null), C = $(null), T = $([]);
1760
+ function F() {
1761
+ T.current.forEach((p) => p.remove()), T.current = [];
1762
1762
  }
1763
- function M(y) {
1763
+ function k(p) {
1764
1764
  const f = /* @__PURE__ */ new Map();
1765
- for (const b of y) f.set(String(b.id ?? ""), b.geometry);
1765
+ for (const b of p) f.set(String(b.id ?? ""), b.geometry);
1766
1766
  Vt(e, f);
1767
1767
  }
1768
- function N(y) {
1768
+ function N(p) {
1769
1769
  const f = T.current;
1770
1770
  if (f.length === 9) {
1771
- for (let b = 0; b < 4; b++) f[b].setLngLat(y.corners[b]);
1772
- for (let b = 0; b < 4; b++) f[4 + b].setLngLat(y.edges[b]);
1773
- f[8].setLngLat(y.rotateHandle);
1771
+ for (let b = 0; b < 4; b++) f[b].setLngLat(p.corners[b]);
1772
+ for (let b = 0; b < 4; b++) f[4 + b].setLngLat(p.edges[b]);
1773
+ f[8].setLngLat(p.rotateHandle);
1774
1774
  }
1775
1775
  }
1776
- const E = $(null);
1776
+ const P = $(null);
1777
1777
  K(() => {
1778
1778
  if (!s || t.length === 0) return;
1779
- _();
1780
- const y = v.current ?? it(t), f = ["nw", "ne", "se", "sw"], b = ["n", "e", "s", "w"], C = [];
1781
- y.corners.forEach((R, I) => {
1782
- const a = It(f[I]), x = new De.Marker({ element: a, draggable: !1 }).setLngLat(R).addTo(e);
1783
- a.addEventListener("mousedown", (p) => D(p, I, !1)), C.push(x);
1784
- }), y.edges.forEach((R, I) => {
1785
- const a = It(b[I]), x = new De.Marker({ element: a, draggable: !1 }).setLngLat(R).addTo(e);
1786
- a.addEventListener("mousedown", (p) => D(p, I, !0)), C.push(x);
1779
+ F();
1780
+ const p = v.current ?? it(t), f = ["nw", "ne", "se", "sw"], b = ["n", "e", "s", "w"], M = [];
1781
+ p.corners.forEach((A, E) => {
1782
+ const a = It(f[E]), x = new De.Marker({ element: a, draggable: !1 }).setLngLat(A).addTo(e);
1783
+ a.addEventListener("mousedown", (y) => D(y, E, !1)), M.push(x);
1784
+ }), p.edges.forEach((A, E) => {
1785
+ const a = It(b[E]), x = new De.Marker({ element: a, draggable: !1 }).setLngLat(A).addTo(e);
1786
+ a.addEventListener("mousedown", (y) => D(y, E, !0)), M.push(x);
1787
1787
  });
1788
1788
  {
1789
- const R = It("rotate"), I = new De.Marker({ element: R, anchor: "bottom", draggable: !1 }).setLngLat(y.rotateHandle).addTo(e);
1790
- R.addEventListener("mousedown", (a) => q(a)), C.push(I);
1789
+ const A = It("rotate"), E = new De.Marker({ element: A, anchor: "bottom", draggable: !1 }).setLngLat(p.rotateHandle).addTo(e);
1790
+ A.addEventListener("mousedown", (a) => q(a)), M.push(E);
1791
1791
  }
1792
- return T.current = C, () => {
1793
- _();
1792
+ return T.current = M, () => {
1793
+ F();
1794
1794
  };
1795
1795
  }, [s, g, u, e]), K(() => {
1796
- function y(S) {
1796
+ function p(S) {
1797
1797
  const L = e.getCanvasContainer().getBoundingClientRect(), B = e.unproject([S.clientX - L.left, S.clientY - L.top]);
1798
1798
  return [B.lng, B.lat];
1799
1799
  }
1800
- const f = ze(I);
1800
+ const f = ze(E);
1801
1801
  let b = null;
1802
- function C(S) {
1803
- E.current && (S.preventDefault(), b = { clientX: S.clientX, clientY: S.clientY }, f.schedule(S));
1802
+ function M(S) {
1803
+ P.current && (S.preventDefault(), b = { clientX: S.clientX, clientY: S.clientY }, f.schedule(S));
1804
1804
  }
1805
- function R(S) {
1805
+ function A(S) {
1806
1806
  var L;
1807
- S.key !== "Shift" && S.key !== "Alt" || ((L = E.current) == null ? void 0 : L.type) !== "scale" || !b || (S.preventDefault(), f.schedule({ ...b, shiftKey: S.shiftKey, altKey: S.altKey }));
1807
+ S.key !== "Shift" && S.key !== "Alt" || ((L = P.current) == null ? void 0 : L.type) !== "scale" || !b || (S.preventDefault(), f.schedule({ ...b, shiftKey: S.shiftKey, altKey: S.altKey }));
1808
1808
  }
1809
- function I(S) {
1810
- const L = E.current;
1809
+ function E(S) {
1810
+ const L = P.current;
1811
1811
  if (!L) return;
1812
- const [B, V] = y(S), j = n.getState().geometryMode;
1812
+ const [B, V] = p(S), j = n.getState().geometryMode;
1813
1813
  if (L.type === "move") {
1814
1814
  if (!L.moving) {
1815
1815
  const H = e.getCanvasContainer().getBoundingClientRect();
1816
1816
  if (Math.hypot(S.clientX - H.left - L.startPoint.x, S.clientY - H.top - L.startPoint.y) < Vr) return;
1817
1817
  L.moving = !0, i(!0);
1818
1818
  }
1819
- const h = j === "visual", k = zr(L.startLngLat, [B, V], h), O = L.initialFeatures.map((H) => ({ ...H, geometry: $t(H.geometry, k, h) })), z = L.initialBbox, G = {
1820
- corners: st(z.corners, k, h),
1821
- edges: st(z.edges, k, h),
1822
- center: st([z.center], k, h)[0],
1823
- rotateHandle: st([z.rotateHandle], k, h)[0]
1819
+ const h = j === "visual", I = zr(L.startLngLat, [B, V], h), O = L.initialFeatures.map((H) => ({ ...H, geometry: $t(H.geometry, I, h) })), z = L.initialBbox, G = {
1820
+ corners: st(z.corners, I, h),
1821
+ edges: st(z.edges, I, h),
1822
+ center: st([z.center], I, h)[0],
1823
+ rotateHandle: st([z.rotateHandle], I, h)[0]
1824
1824
  };
1825
- w.current = O, P.current = G, M(O), N(G);
1825
+ w.current = O, C.current = G, k(O), N(G);
1826
1826
  } else if (L.type === "rotate") {
1827
- const h = L.center, k = Te(h[1]), O = V - h[1], z = j === "visual" ? (B - h[0]) * k : B - h[0], H = (Math.atan2(O, z) - L.initialAngle) * (180 / Math.PI), te = L.initialFeatures.map(
1827
+ const h = L.center, I = Te(h[1]), O = V - h[1], z = j === "visual" ? (B - h[0]) * I : B - h[0], H = (Math.atan2(O, z) - L.initialAngle) * (180 / Math.PI), te = L.initialFeatures.map(
1828
1828
  (ne) => j === "visual" ? Po(ne, h, 1, 1, H) : ir(ne, H, { pivot: h })
1829
1829
  ), Z = {
1830
1830
  corners: kt(L.initialBbox.corners, h, H),
@@ -1832,25 +1832,25 @@ function es({ map: e, features: t }) {
1832
1832
  center: h,
1833
1833
  rotateHandle: kt([L.initialBbox.rotateHandle], h, H)[0]
1834
1834
  };
1835
- w.current = te, P.current = Z, M(te), N(Z);
1835
+ w.current = te, C.current = Z, k(te), N(Z);
1836
1836
  } else if (L.type === "scale") {
1837
- const h = L.rotationAngle, k = qr({
1837
+ const h = L.rotationAngle, I = qr({
1838
1838
  initialBbox: L.initialBbox,
1839
1839
  origin: L.origin,
1840
1840
  startLngLat: L.startLngLat,
1841
1841
  edgeIndex: L.edgeIndex,
1842
1842
  rotationAngle: h
1843
- }, [B, V], S.shiftKey, S.altKey), O = Jr(L.initialFeatures, L.initialBbox, k, h);
1844
- w.current = O.features, P.current = O.box, M(O.features), N(O.box);
1843
+ }, [B, V], S.shiftKey, S.altKey), O = Jr(L.initialFeatures, L.initialBbox, I, h);
1844
+ w.current = O.features, C.current = O.box, k(O.features), N(O.box);
1845
1845
  }
1846
1846
  }
1847
1847
  function a() {
1848
1848
  f.flush();
1849
- const S = E.current;
1849
+ const S = P.current;
1850
1850
  if (!S) return;
1851
- const L = w.current, B = P.current, V = S.type === "rotate";
1852
- if (E.current = null, b = null, w.current = null, P.current = null, e.dragPan.enable(), i(!1), S.type === "move" && L) {
1853
- const j = e.getContainer(), h = (k) => k.stopPropagation();
1851
+ const L = w.current, B = C.current, V = S.type === "rotate";
1852
+ if (P.current = null, b = null, w.current = null, C.current = null, e.dragPan.enable(), i(!1), S.type === "move" && L) {
1853
+ const j = e.getContainer(), h = (I) => I.stopPropagation();
1854
1854
  j.addEventListener("click", h, !0), setTimeout(() => j.removeEventListener("click", h, !0), 0);
1855
1855
  }
1856
1856
  if (L && (n.getState().takeSnapshot(), n.getState().updateFeatures(Eo(
@@ -1859,7 +1859,7 @@ function es({ map: e, features: t }) {
1859
1859
  o.getState().topoEditEnabled
1860
1860
  ))), B) {
1861
1861
  if (V) {
1862
- const j = B.center, h = B.edges[1], k = Te(j[1]), O = (h[0] - j[0]) * k, z = h[1] - j[1];
1862
+ const j = B.center, h = B.edges[1], I = Te(j[1]), O = (h[0] - j[0]) * I, z = h[1] - j[1];
1863
1863
  d.current = Math.atan2(z, O) * (180 / Math.PI);
1864
1864
  }
1865
1865
  c(B);
@@ -1867,21 +1867,21 @@ function es({ map: e, features: t }) {
1867
1867
  }
1868
1868
  function x(S, L, B) {
1869
1869
  S.preventDefault(), S.stopPropagation(), e.dragPan.disable();
1870
- const V = v.current ?? it(l.current), [j, h] = y(S), k = B ? V.edges[(L + 2) % 4] : V.corners[(L + 2) % 4];
1871
- E.current = {
1870
+ const V = v.current ?? it(l.current), [j, h] = p(S), I = B ? V.edges[(L + 2) % 4] : V.corners[(L + 2) % 4];
1871
+ P.current = {
1872
1872
  type: "scale",
1873
1873
  initialFeatures: structuredClone(l.current),
1874
1874
  initialBbox: V,
1875
1875
  rotationAngle: d.current,
1876
- origin: k,
1876
+ origin: I,
1877
1877
  startLngLat: [j, h],
1878
1878
  edgeIndex: B ? L : void 0
1879
1879
  }, i(!0);
1880
1880
  }
1881
- function p(S) {
1881
+ function y(S) {
1882
1882
  S.preventDefault(), S.stopPropagation(), e.dragPan.disable();
1883
- const L = v.current ?? it(l.current), B = L.center, [V, j] = y(S), h = n.getState().geometryMode, k = Te(B[1]), O = j - B[1], z = h === "visual" ? (V - B[0]) * k : V - B[0];
1884
- E.current = {
1883
+ const L = v.current ?? it(l.current), B = L.center, [V, j] = p(S), h = n.getState().geometryMode, I = Te(B[1]), O = j - B[1], z = h === "visual" ? (V - B[0]) * I : V - B[0];
1884
+ P.current = {
1885
1885
  type: "rotate",
1886
1886
  initialFeatures: structuredClone(l.current),
1887
1887
  initialBbox: L,
@@ -1891,38 +1891,38 @@ function es({ map: e, features: t }) {
1891
1891
  }, i(!0);
1892
1892
  }
1893
1893
  function m(S) {
1894
- if (E.current || S.button !== 0 || S.shiftKey || S.altKey || S.ctrlKey || S.metaKey || S.target !== e.getCanvas()) return;
1894
+ if (P.current || S.button !== 0 || S.shiftKey || S.altKey || S.ctrlKey || S.metaKey || S.target !== e.getCanvas()) return;
1895
1895
  const L = o.getState();
1896
1896
  if (!L.transformActive || L.readonly || L.editingMode !== "none" || L.vertexEditActive) return;
1897
1897
  const B = l.current;
1898
1898
  if (B.length === 0) return;
1899
1899
  const V = v.current ?? it(B), j = e.getCanvasContainer().getBoundingClientRect(), h = { x: S.clientX - j.left, y: S.clientY - j.top };
1900
- Hr(h, V.corners.map((k) => e.project(k)), Xr) && (S.preventDefault(), S.stopPropagation(), e.dragPan.disable(), E.current = {
1900
+ Hr(h, V.corners.map((I) => e.project(I)), Xr) && (S.preventDefault(), S.stopPropagation(), e.dragPan.disable(), P.current = {
1901
1901
  type: "move",
1902
1902
  initialFeatures: structuredClone(B),
1903
1903
  initialBbox: V,
1904
1904
  rotationAngle: d.current,
1905
- startLngLat: y(S),
1905
+ startLngLat: p(S),
1906
1906
  startPoint: h,
1907
1907
  moving: !1
1908
1908
  });
1909
1909
  }
1910
- const F = e.getContainer();
1911
- return F.addEventListener("mousedown", m, !0), A.current.handleScaleStart = x, A.current.handleRotateStart = p, document.addEventListener("mousemove", C), document.addEventListener("mouseup", a), document.addEventListener("keydown", R), document.addEventListener("keyup", R), () => {
1912
- f.cancel(), F.removeEventListener("mousedown", m, !0), document.removeEventListener("mousemove", C), document.removeEventListener("mouseup", a), document.removeEventListener("keydown", R), document.removeEventListener("keyup", R);
1910
+ const R = e.getContainer();
1911
+ return R.addEventListener("mousedown", m, !0), _.current.handleScaleStart = x, _.current.handleRotateStart = y, document.addEventListener("mousemove", M), document.addEventListener("mouseup", a), document.addEventListener("keydown", A), document.addEventListener("keyup", A), () => {
1912
+ f.cancel(), R.removeEventListener("mousedown", m, !0), document.removeEventListener("mousemove", M), document.removeEventListener("mouseup", a), document.removeEventListener("keydown", A), document.removeEventListener("keyup", A);
1913
1913
  };
1914
1914
  }, [e, n, o, i]);
1915
- const A = $({
1915
+ const _ = $({
1916
1916
  handleScaleStart: () => {
1917
1917
  },
1918
1918
  handleRotateStart: () => {
1919
1919
  }
1920
1920
  });
1921
- function D(y, f, b) {
1922
- A.current.handleScaleStart(y, f, b);
1921
+ function D(p, f, b) {
1922
+ _.current.handleScaleStart(p, f, b);
1923
1923
  }
1924
- function q(y) {
1925
- A.current.handleRotateStart(y);
1924
+ function q(p) {
1925
+ _.current.handleRotateStart(p);
1926
1926
  }
1927
1927
  return null;
1928
1928
  }
@@ -2012,36 +2012,36 @@ function os(e, t) {
2012
2012
  function rs({ map: e, onVertexBoxSelect: t }) {
2013
2013
  const { dataStore: n } = Le(), o = W((d) => d.editingMode), r = W((d) => d.vertexEditActive), s = W((d) => d.transformActive), i = W((d) => d.readonly), l = $(o), u = $(r), c = $(s), v = $(i);
2014
2014
  return l.current = o, u.current = r, c.current = s, v.current = i, K(() => {
2015
- const d = e.getCanvas(), g = e.getContainer(), w = (P) => {
2016
- if (!P.shiftKey || v.current || c.current) return;
2015
+ const d = e.getCanvas(), g = e.getContainer(), w = (C) => {
2016
+ if (!C.shiftKey || v.current || c.current) return;
2017
2017
  const T = u.current;
2018
2018
  if (!T && l.current !== "none") return;
2019
- P.preventDefault(), e.dragPan.disable(), e.boxZoom.disable();
2020
- const _ = P.clientX, M = P.clientY, N = g.getBoundingClientRect(), E = [...n.getState().selectedIds], A = document.createElement("div");
2021
- A.style.cssText = [
2019
+ C.preventDefault(), e.dragPan.disable(), e.boxZoom.disable();
2020
+ const F = C.clientX, k = C.clientY, N = g.getBoundingClientRect(), P = [...n.getState().selectedIds], _ = document.createElement("div");
2021
+ _.style.cssText = [
2022
2022
  "position:absolute",
2023
2023
  "pointer-events:none",
2024
2024
  "border:2px solid var(--color-primary-500)",
2025
2025
  "background:color-mix(in srgb, var(--color-primary-500) 8%, transparent)",
2026
2026
  "z-index:9999",
2027
2027
  "border-radius:2px"
2028
- ].join(";"), g.appendChild(A);
2028
+ ].join(";"), g.appendChild(_);
2029
2029
  let D = !1, q = 0;
2030
- function y(a) {
2031
- const x = Math.min(_, a.clientX) - N.left, p = Math.min(M, a.clientY) - N.top, m = Math.max(_, a.clientX) - N.left, F = Math.max(M, a.clientY) - N.top, S = e.unproject([x, p]), L = e.unproject([m, F]);
2030
+ function p(a) {
2031
+ const x = Math.min(F, a.clientX) - N.left, y = Math.min(k, a.clientY) - N.top, m = Math.max(F, a.clientX) - N.left, R = Math.max(k, a.clientY) - N.top, S = e.unproject([x, y]), L = e.unproject([m, R]);
2032
2032
  return {
2033
2033
  boxW: S.lng,
2034
2034
  boxE: L.lng,
2035
2035
  boxN: S.lat,
2036
2036
  boxS: L.lat,
2037
2037
  overlayX: x,
2038
- overlayY: p,
2038
+ overlayY: y,
2039
2039
  overlayW: m - x,
2040
- overlayH: F - p
2040
+ overlayH: R - y
2041
2041
  };
2042
2042
  }
2043
2043
  function f(a) {
2044
- const { boxW: x, boxE: p, boxN: m, boxS: F } = y(a), S = n.getState(), L = new Set(S.groups.filter((h) => h.hidden).map((h) => h.id)), B = S.features.filter(
2044
+ const { boxW: x, boxE: y, boxN: m, boxS: R } = p(a), S = n.getState(), L = new Set(S.groups.filter((h) => h.hidden).map((h) => h.id)), B = S.features.filter(
2045
2045
  (h) => !h.hidden && (!h.groupId || !L.has(h.groupId))
2046
2046
  ), V = {
2047
2047
  type: "Feature",
@@ -2049,23 +2049,23 @@ function rs({ map: e, onVertexBoxSelect: t }) {
2049
2049
  geometry: {
2050
2050
  type: "Polygon",
2051
2051
  coordinates: [[
2052
- [x, F],
2053
- [p, F],
2054
- [p, m],
2052
+ [x, R],
2053
+ [y, R],
2054
+ [y, m],
2055
2055
  [x, m],
2056
- [x, F]
2056
+ [x, R]
2057
2057
  ]]
2058
2058
  }
2059
2059
  }, j = [];
2060
2060
  for (const h of B) {
2061
2061
  if (h.geometry.type === "Point") {
2062
2062
  const [te, Z] = h.geometry.coordinates;
2063
- te >= x && te <= p && Z >= F && Z <= m && j.push(h.id);
2063
+ te >= x && te <= y && Z >= R && Z <= m && j.push(h.id);
2064
2064
  continue;
2065
2065
  }
2066
- const k = h.bbox ?? Nn(h.geometry), [O, z, G, H] = k;
2067
- if (G >= x && O <= p && H >= F && z <= m) {
2068
- if (ns(k, x, F, p, m)) {
2066
+ const I = h.bbox ?? Nn(h.geometry), [O, z, G, H] = I;
2067
+ if (G >= x && O <= y && H >= R && z <= m) {
2068
+ if (ns(I, x, R, y, m)) {
2069
2069
  j.push(h.id);
2070
2070
  continue;
2071
2071
  }
@@ -2079,53 +2079,53 @@ function rs({ map: e, onVertexBoxSelect: t }) {
2079
2079
  return j;
2080
2080
  }
2081
2081
  function b(a) {
2082
- const x = new Set(E);
2083
- a.forEach((F) => x.add(F));
2084
- const p = Array.from(x), m = n.getState();
2085
- os(m.selectedIds, p) && m.selectedGroupId === null || m.setSelection(p);
2082
+ const x = new Set(P);
2083
+ a.forEach((R) => x.add(R));
2084
+ const y = Array.from(x), m = n.getState();
2085
+ os(m.selectedIds, y) && m.selectedGroupId === null || m.setSelection(y);
2086
2086
  }
2087
- function C(a) {
2087
+ function M(a) {
2088
2088
  const x = n.getState().selectedIds[0];
2089
2089
  if (!x) return null;
2090
- const p = n.getState().features.find((j) => j.id === x);
2091
- if (!p) return null;
2090
+ const y = n.getState().features.find((j) => j.id === x);
2091
+ if (!y) return null;
2092
2092
  let m;
2093
- if (p.geometry.type === "LineString")
2094
- m = p.geometry.coordinates;
2095
- else if (p.geometry.type === "Polygon")
2096
- m = p.geometry.coordinates[0].slice(0, -1);
2093
+ if (y.geometry.type === "LineString")
2094
+ m = y.geometry.coordinates;
2095
+ else if (y.geometry.type === "Polygon")
2096
+ m = y.geometry.coordinates[0].slice(0, -1);
2097
2097
  else
2098
2098
  return null;
2099
- const { boxW: F, boxE: S, boxN: L, boxS: B } = y(a), V = [];
2099
+ const { boxW: R, boxE: S, boxN: L, boxS: B } = p(a), V = [];
2100
2100
  for (let j = 0; j < m.length; j++) {
2101
- const [h, k] = m[j];
2102
- h >= F && h <= S && k >= B && k <= L && V.push(j);
2101
+ const [h, I] = m[j];
2102
+ h >= R && h <= S && I >= B && I <= L && V.push(j);
2103
2103
  }
2104
2104
  return { id: x, indices: V };
2105
2105
  }
2106
- const R = (a) => {
2107
- const x = Math.abs(a.clientX - _), p = Math.abs(a.clientY - M);
2108
- if (!D && x < 5 && p < 5) return;
2106
+ const A = (a) => {
2107
+ const x = Math.abs(a.clientX - F), y = Math.abs(a.clientY - k);
2108
+ if (!D && x < 5 && y < 5) return;
2109
2109
  D = !0;
2110
- const { overlayX: m, overlayY: F, overlayW: S, overlayH: L } = y(a);
2111
- A.style.left = `${m}px`, A.style.top = `${F}px`, A.style.width = `${S}px`, A.style.height = `${L}px`, !T && Date.now() - q > 30 && (b(f(a)), q = Date.now());
2112
- }, I = (a) => {
2113
- if (A.remove(), e.dragPan.enable(), e.boxZoom.enable(), window.removeEventListener("mousemove", R), window.removeEventListener("mouseup", I), !D) return;
2110
+ const { overlayX: m, overlayY: R, overlayW: S, overlayH: L } = p(a);
2111
+ _.style.left = `${m}px`, _.style.top = `${R}px`, _.style.width = `${S}px`, _.style.height = `${L}px`, !T && Date.now() - q > 30 && (b(f(a)), q = Date.now());
2112
+ }, E = (a) => {
2113
+ if (_.remove(), e.dragPan.enable(), e.boxZoom.enable(), window.removeEventListener("mousemove", A), window.removeEventListener("mouseup", E), !D) return;
2114
2114
  if (T) {
2115
- const p = C(a);
2116
- p && p.indices.length > 0 && t && t(p.id, p.indices);
2115
+ const y = M(a);
2116
+ y && y.indices.length > 0 && t && t(y.id, y.indices);
2117
2117
  return;
2118
2118
  }
2119
2119
  const x = f(a);
2120
- if (b(x), x.length === 0 && E.length === 1 && t) {
2121
- const p = n.getState().features.find((m) => m.id === E[0]);
2122
- if (p && (p.geometry.type === "LineString" || p.geometry.type === "Polygon")) {
2123
- const m = C(a);
2120
+ if (b(x), x.length === 0 && P.length === 1 && t) {
2121
+ const y = n.getState().features.find((m) => m.id === P[0]);
2122
+ if (y && (y.geometry.type === "LineString" || y.geometry.type === "Polygon")) {
2123
+ const m = M(a);
2124
2124
  m && m.indices.length > 0 && t(m.id, m.indices);
2125
2125
  }
2126
2126
  }
2127
2127
  };
2128
- window.addEventListener("mousemove", R), window.addEventListener("mouseup", I);
2128
+ window.addEventListener("mousemove", A), window.addEventListener("mouseup", E);
2129
2129
  };
2130
2130
  return d.addEventListener("mousedown", w), () => d.removeEventListener("mousedown", w);
2131
2131
  }, [e, n, t]), null;
@@ -2237,49 +2237,49 @@ function us({ map: e }) {
2237
2237
  ct();
2238
2238
  }, [r.length, i]), K(() => {
2239
2239
  if (!i) return;
2240
- const a = t.getState(), x = a.selectedIds.length === 1 ? a.features.find((m) => m.id === a.selectedIds[0]) : void 0, p = Co(x);
2241
- p && o({ type: "warning", message: p });
2240
+ const a = t.getState(), x = a.selectedIds.length === 1 ? a.features.find((m) => m.id === a.selectedIds[0]) : void 0, y = Co(x);
2241
+ y && o({ type: "warning", message: y });
2242
2242
  }, [i, t, o]);
2243
2243
  const v = $(!1);
2244
2244
  K(() => {
2245
2245
  if (!l || v.current) return;
2246
- const a = t.getState(), x = a.selectedIds.length === 1 ? a.features.find((p) => p.id === a.selectedIds[0]) : void 0;
2246
+ const a = t.getState(), x = a.selectedIds.length === 1 ? a.features.find((y) => y.id === a.selectedIds[0]) : void 0;
2247
2247
  (x == null ? void 0 : x._drawType) === "route" && (o({ type: "warning", message: "Transforming may break road alignment." }), v.current = !0);
2248
2248
  }, [l, s, t, o]);
2249
- const d = $(null), g = $(null), [w, P] = le(null), [T, _] = le(null), [M, N] = le(null);
2249
+ const d = $(null), g = $(null), [w, C] = le(null), [T, F] = le(null), [k, N] = le(null);
2250
2250
  K(() => {
2251
- !i && M && N(null);
2252
- }, [i, M]);
2253
- const E = is(c), A = Jo();
2251
+ !i && k && N(null);
2252
+ }, [i, k]);
2253
+ const P = is(c), _ = Jo();
2254
2254
  K(() => {
2255
2255
  if (c) return;
2256
- const a = e.getCanvasContainer(), x = (p) => {
2257
- var k, O;
2258
- p.preventDefault();
2259
- const m = a.getBoundingClientRect(), F = [p.clientX - m.left, p.clientY - m.top], S = $e(e, F, Be);
2256
+ const a = e.getCanvasContainer(), x = (y) => {
2257
+ var I, O;
2258
+ y.preventDefault();
2259
+ const m = a.getBoundingClientRect(), R = [y.clientX - m.left, y.clientY - m.top], S = $e(e, R, Be);
2260
2260
  if (S.length === 0) return;
2261
- const L = String(S[0].id ?? ((k = S[0].properties) == null ? void 0 : k.id) ?? "");
2261
+ const L = String(S[0].id ?? ((I = S[0].properties) == null ? void 0 : I.id) ?? "");
2262
2262
  if (!L) return;
2263
2263
  const B = t.getState(), V = B.features.find((z) => z.id === L);
2264
2264
  if (!V) return;
2265
2265
  const j = B.selectedIds;
2266
2266
  j.length >= 2 && j.includes(L) || B.selectFeature(L);
2267
2267
  const h = V.geometry.type === "Point" && ((O = V.properties) == null ? void 0 : O._isText) !== "true";
2268
- A.open(p.clientX, p.clientY, {
2268
+ _.open(y.clientX, y.clientY, {
2269
2269
  feature: V,
2270
- requestPreciseCoords: h ? () => _(L) : void 0
2270
+ requestPreciseCoords: h ? () => F(L) : void 0
2271
2271
  });
2272
2272
  };
2273
2273
  return a.addEventListener("contextmenu", x), () => {
2274
2274
  a.removeEventListener("contextmenu", x);
2275
2275
  };
2276
- }, [c, t, e, A]), K(() => {
2277
- const a = u !== "none", x = (F = !0) => {
2278
- bt(e, null, d.current), d.current = null, F && Pt(e, null), ct(), E.leave(a ? void 0 : "");
2279
- }, p = (F) => {
2276
+ }, [c, t, e, _]), K(() => {
2277
+ const a = u !== "none", x = (R = !0) => {
2278
+ bt(e, null, d.current), d.current = null, R && Pt(e, null), ct(), P.leave(a ? void 0 : "");
2279
+ }, y = (R) => {
2280
2280
  var V, j;
2281
2281
  if (e.dragPan.isActive() || (V = g.current) != null && V.dragging) return;
2282
- const S = $e(e, F.point, Be), L = S.length > 0 ? String(S[0].id ?? ((j = S[0].properties) == null ? void 0 : j.id)) : null;
2282
+ const S = $e(e, R.point, Be), L = S.length > 0 ? String(S[0].id ?? ((j = S[0].properties) == null ? void 0 : j.id)) : null;
2283
2283
  if (L === d.current) return;
2284
2284
  if (!L) {
2285
2285
  x();
@@ -2287,28 +2287,28 @@ function us({ map: e }) {
2287
2287
  }
2288
2288
  Gt() !== L && Pt(e, null), a || bt(e, L, d.current), d.current = L;
2289
2289
  const B = t.getState().features.find((h) => h.id === L);
2290
- B ? Nr(B, n, F.originalEvent) : ct(), E.enter(e.getCanvas(), F.originalEvent, a ? void 0 : "pointer");
2290
+ B ? Nr(B, n, R.originalEvent) : ct(), P.enter(e.getCanvas(), R.originalEvent, a ? void 0 : "pointer");
2291
2291
  };
2292
- e.on("mousemove", p);
2292
+ e.on("mousemove", y);
2293
2293
  const m = () => x();
2294
2294
  return e.on("mouseout", m), () => {
2295
- e.off("mousemove", p), e.off("mouseout", m);
2295
+ e.off("mousemove", y), e.off("mouseout", m);
2296
2296
  try {
2297
2297
  x(!1);
2298
2298
  } catch {
2299
2299
  }
2300
2300
  };
2301
- }, [u, e, t, n, E]);
2301
+ }, [u, e, t, n, P]);
2302
2302
  const D = $(r);
2303
2303
  K(() => {
2304
2304
  const a = D.current;
2305
2305
  if (D.current = r, r.length <= a.length) return;
2306
- const p = e.getCanvas().getBoundingClientRect(), m = cs();
2307
- if (m.x < p.left || m.x > p.right || m.y < p.top || m.y > p.bottom) return;
2308
- const F = new Set(a.map((h) => h.id)), S = new Set(r.filter((h) => !F.has(h.id)).map((h) => h.id)), L = [m.x - p.left, m.y - p.top], B = () => {
2306
+ const y = e.getCanvas().getBoundingClientRect(), m = cs();
2307
+ if (m.x < y.left || m.x > y.right || m.y < y.top || m.y > y.bottom) return;
2308
+ const R = new Set(a.map((h) => h.id)), S = new Set(r.filter((h) => !R.has(h.id)).map((h) => h.id)), L = [m.x - y.left, m.y - y.top], B = () => {
2309
2309
  var h;
2310
2310
  try {
2311
- const k = e.unproject(L), O = $e(e, e.project(k), Be)[0], z = O ? String(O.id ?? ((h = O.properties) == null ? void 0 : h.id)) : null;
2311
+ const I = e.unproject(L), O = $e(e, e.project(I), Be)[0], z = O ? String(O.id ?? ((h = O.properties) == null ? void 0 : h.id)) : null;
2312
2312
  z && S.has(z) && Pt(e, z), e.fire("mousemove", {
2313
2313
  // A real Point: a plain { x, y } makes every listener's
2314
2314
  // queryRenderedFeatures(e.point) hit the whole viewport, so the
@@ -2316,8 +2316,8 @@ function us({ map: e }) {
2316
2316
  // `map.project` returns the map's own Point class (a `new Point` from the
2317
2317
  // peer copy fails maplibre's instanceof check when the host bundles its own
2318
2318
  // maplibre, e.g. MapTiler SDK) and avoids a named import from CJS maplibre-gl.
2319
- point: e.project(k),
2320
- lngLat: k,
2319
+ point: e.project(I),
2320
+ lngLat: I,
2321
2321
  originalEvent: new MouseEvent("mousemove", {
2322
2322
  clientX: m.x,
2323
2323
  clientY: m.y,
@@ -2341,12 +2341,12 @@ function us({ map: e }) {
2341
2341
  const a = (x) => {
2342
2342
  var L;
2343
2343
  if (Gn()) return;
2344
- const p = $e(e, x.point, Be), m = t.getState();
2345
- if (p.length === 0) {
2344
+ const y = $e(e, x.point, Be), m = t.getState();
2345
+ if (y.length === 0) {
2346
2346
  i ? n.getState().setVertexEditActive(!1) : m.clearSelection();
2347
2347
  return;
2348
2348
  }
2349
- const F = p[0], S = String(F.id ?? ((L = F.properties) == null ? void 0 : L.id) ?? "");
2349
+ const R = y[0], S = String(R.id ?? ((L = R.properties) == null ? void 0 : L.id) ?? "");
2350
2350
  if (S)
2351
2351
  if (x.originalEvent.shiftKey) {
2352
2352
  const B = m.selectedIds;
@@ -2361,19 +2361,19 @@ function us({ map: e }) {
2361
2361
  if (c || u !== "none") return;
2362
2362
  const a = (x) => {
2363
2363
  var S, L;
2364
- const p = $e(e, x.point, Be);
2365
- if (p.length === 0) return;
2364
+ const y = $e(e, x.point, Be);
2365
+ if (y.length === 0) return;
2366
2366
  x.preventDefault();
2367
- const m = String(p[0].id ?? ((S = p[0].properties) == null ? void 0 : S.id) ?? "");
2367
+ const m = String(y[0].id ?? ((S = y[0].properties) == null ? void 0 : S.id) ?? "");
2368
2368
  if (!m) return;
2369
- const F = t.getState().features.find((B) => B.id === m);
2370
- if (F) {
2371
- if (((L = F.properties) == null ? void 0 : L._isText) === "true") {
2372
- t.getState().selectFeature(m), P(m);
2369
+ const R = t.getState().features.find((B) => B.id === m);
2370
+ if (R) {
2371
+ if (((L = R.properties) == null ? void 0 : L._isText) === "true") {
2372
+ t.getState().selectFeature(m), C(m);
2373
2373
  return;
2374
2374
  }
2375
- if (t.getState().selectFeature(m), ht(F.geometry)) {
2376
- const B = Dr(F.geometry, [x.lngLat.lng, x.lngLat.lat]);
2375
+ if (t.getState().selectFeature(m), ht(R.geometry)) {
2376
+ const B = Dr(R.geometry, [x.lngLat.lng, x.lngLat.lat]);
2377
2377
  n.getState().setSelectedPartIndex(B);
2378
2378
  } else
2379
2379
  n.getState().setSelectedPartIndex(null);
@@ -2385,26 +2385,26 @@ function us({ map: e }) {
2385
2385
  };
2386
2386
  }, [c, u, t, n, e]), K(() => {
2387
2387
  if (c || i) return;
2388
- const x = u !== "none", p = (m) => {
2388
+ const x = u !== "none", y = (m) => {
2389
2389
  var re;
2390
2390
  if (m.originalEvent.shiftKey) return;
2391
- const F = m.originalEvent.altKey, S = m.originalEvent.ctrlKey || m.originalEvent.metaKey;
2392
- if (x && !F && !S) return;
2391
+ const R = m.originalEvent.altKey, S = m.originalEvent.ctrlKey || m.originalEvent.metaKey;
2392
+ if (x && !R && !S) return;
2393
2393
  const L = $e(e, m.point, Be);
2394
2394
  if (L.length === 0) return;
2395
2395
  const B = String(L[0].id ?? ((re = L[0].properties) == null ? void 0 : re.id) ?? "");
2396
2396
  if (!B) return;
2397
2397
  const V = t.getState();
2398
- if (V.selectedIds.includes(B) && V.selectedIds.length >= 2 && !F && !S) return;
2398
+ if (V.selectedIds.includes(B) && V.selectedIds.length >= 2 && !R && !S) return;
2399
2399
  V.selectedIds.includes(B) || V.selectFeature(B);
2400
- const h = t.getState().selectedIds, k = h.includes(B) ? h : [B], O = new Map(
2401
- k.flatMap((J) => {
2400
+ const h = t.getState().selectedIds, I = h.includes(B) ? h : [B], O = new Map(
2401
+ I.flatMap((J) => {
2402
2402
  const ce = V.features.find((U) => U.id === J);
2403
2403
  return ce ? [[J, ce.geometry]] : [];
2404
2404
  })
2405
- ), z = F, G = V.geometryMode, H = [m.lngLat.lng, m.lngLat.lat], te = G === "visual" ? me(H) : H;
2405
+ ), z = R, G = V.geometryMode, H = [m.lngLat.lng, m.lngLat.lat], te = G === "visual" ? me(H) : H;
2406
2406
  e.dragPan.disable(), g.current = {
2407
- featureIds: k,
2407
+ featureIds: I,
2408
2408
  startLngLat: H,
2409
2409
  startProjected: te,
2410
2410
  geometryMode: G,
@@ -2455,7 +2455,7 @@ function us({ map: e }) {
2455
2455
  const J = g.current;
2456
2456
  if (g.current = null, e.dragPan.enable(), J != null && J.dragging) {
2457
2457
  const ce = Ge(n.getState().editingMode);
2458
- if (E.leave(ce), e.getCanvas().style.cursor = ce, bt(e, null, d.current), d.current = null, Ce(!1), Mr(), t.getState().takeSnapshot(), J.duplicate) {
2458
+ if (P.leave(ce), e.getCanvas().style.cursor = ce, bt(e, null, d.current), d.current = null, Ce(!1), Mr(), t.getState().takeSnapshot(), J.duplicate) {
2459
2459
  const U = [];
2460
2460
  for (const ee of J.featureIds) {
2461
2461
  const oe = Z.get(ee);
@@ -2474,47 +2474,47 @@ function us({ map: e }) {
2474
2474
  };
2475
2475
  e.on("mousemove", se), e.on("mouseup", ie);
2476
2476
  };
2477
- return e.on("mousedown", p), () => {
2478
- e.off("mousedown", p);
2477
+ return e.on("mousedown", y), () => {
2478
+ e.off("mousedown", y);
2479
2479
  };
2480
- }, [c, u, i, t, n, e, E]);
2481
- const q = s.length === 1 ? r.find((a) => a.id === s[0]) ?? null : null, y = r.filter((a) => s.includes(a.id)), f = A.state && /* @__PURE__ */ X(
2480
+ }, [c, u, i, t, n, e, P]);
2481
+ const q = s.length === 1 ? r.find((a) => a.id === s[0]) ?? null : null, p = r.filter((a) => s.includes(a.id)), f = _.state && /* @__PURE__ */ X(
2482
2482
  Bo,
2483
2483
  {
2484
- x: A.state.x,
2485
- y: A.state.y,
2486
- data: A.state.data,
2487
- onClose: A.close
2484
+ x: _.state.x,
2485
+ y: _.state.y,
2486
+ data: _.state.data,
2487
+ onClose: _.close
2488
2488
  }
2489
- ), b = w ? r.find((a) => a.id === w) ?? null : null, C = b && /* @__PURE__ */ X(
2489
+ ), b = w ? r.find((a) => a.id === w) ?? null : null, M = b && /* @__PURE__ */ X(
2490
2490
  ts,
2491
2491
  {
2492
2492
  map: e,
2493
2493
  feature: b,
2494
- onDone: () => P(null)
2494
+ onDone: () => C(null)
2495
2495
  }
2496
- ), R = T ? r.find((a) => a.id === T) ?? null : null, I = R && R.geometry.type === "Point" && /* @__PURE__ */ X(
2496
+ ), A = T ? r.find((a) => a.id === T) ?? null : null, E = A && A.geometry.type === "Point" && /* @__PURE__ */ X(
2497
2497
  Un,
2498
2498
  {
2499
2499
  map: e,
2500
- coords: R.geometry.coordinates,
2500
+ coords: A.geometry.coordinates,
2501
2501
  onSave: (a) => {
2502
- t.getState().takeSnapshot(), t.getState().updateFeature(R.id, { geometry: { type: "Point", coordinates: Ve(R.geometry.coordinates, a) } });
2502
+ t.getState().takeSnapshot(), t.getState().updateFeature(A.id, { geometry: { type: "Point", coordinates: Ve(A.geometry.coordinates, a) } });
2503
2503
  },
2504
- onClose: () => _(null)
2504
+ onClose: () => F(null)
2505
2505
  }
2506
2506
  );
2507
2507
  return c || u !== "none" ? /* @__PURE__ */ fe(lt, { children: [
2508
2508
  f,
2509
- C,
2510
- I
2509
+ M,
2510
+ E
2511
2511
  ] }) : /* @__PURE__ */ fe(lt, { children: [
2512
2512
  i && q && /* @__PURE__ */ X(
2513
2513
  $r,
2514
2514
  {
2515
2515
  map: e,
2516
2516
  feature: q,
2517
- initialSelectedIndices: M ?? void 0
2517
+ initialSelectedIndices: k ?? void 0
2518
2518
  }
2519
2519
  ),
2520
2520
  /* @__PURE__ */ X(
@@ -2530,10 +2530,10 @@ function us({ map: e }) {
2530
2530
  }
2531
2531
  }
2532
2532
  ),
2533
- l && !i && y.length >= 1 && /* @__PURE__ */ X(es, { map: e, features: y }),
2533
+ l && !i && p.length >= 1 && /* @__PURE__ */ X(es, { map: e, features: p }),
2534
2534
  f,
2535
- C,
2536
- I
2535
+ M,
2536
+ E
2537
2537
  ] });
2538
2538
  }
2539
2539
  const Me = "elm-snap", eo = [
@@ -2601,47 +2601,47 @@ function gs({ map: e }) {
2601
2601
  c();
2602
2602
  return;
2603
2603
  }
2604
- const _ = T.originalEvent;
2605
- if (_.metaKey || _.ctrlKey) {
2604
+ const F = T.originalEvent;
2605
+ if (F.metaKey || F.ctrlKey) {
2606
2606
  c();
2607
2607
  return;
2608
2608
  }
2609
- const M = _.target;
2610
- if ((D = M == null ? void 0 : M.closest) != null && D.call(M, ".elm-midpoint-marker")) {
2609
+ const k = F.target;
2610
+ if ((D = k == null ? void 0 : k.closest) != null && D.call(k, ".elm-midpoint-marker")) {
2611
2611
  c();
2612
2612
  return;
2613
2613
  }
2614
- const N = Gt(), E = Vn(T.lngLat.lng, T.lngLat.lat, e, s, 15, new Set(N ? [N] : []));
2615
- if (!E) {
2614
+ const N = Gt(), P = Vn(T.lngLat.lng, T.lngLat.lat, e, s, 15, new Set(N ? [N] : []));
2615
+ if (!P) {
2616
2616
  c();
2617
2617
  return;
2618
2618
  }
2619
- if (i && E.isVertex) {
2619
+ if (i && P.isVertex) {
2620
2620
  const q = new Set(n.getState().selectedIds);
2621
- if (E.featureId && q.has(E.featureId)) {
2621
+ if (P.featureId && q.has(P.featureId)) {
2622
2622
  c();
2623
2623
  return;
2624
2624
  }
2625
2625
  }
2626
- t.getState().setSnappedCoord(E.lnglat);
2627
- const A = e.getSource(Me);
2628
- A == null || A.setData({
2626
+ t.getState().setSnappedCoord(P.lnglat);
2627
+ const _ = e.getSource(Me);
2628
+ _ == null || _.setData({
2629
2629
  type: "FeatureCollection",
2630
2630
  features: [{
2631
2631
  type: "Feature",
2632
- properties: { _kind: E.isVertex ? "vertex" : "edge" },
2633
- geometry: { type: "Point", coordinates: E.lnglat }
2632
+ properties: { _kind: P.isVertex ? "vertex" : "edge" },
2633
+ geometry: { type: "Point", coordinates: P.lnglat }
2634
2634
  }]
2635
2635
  });
2636
- }), g = (T) => d.schedule(T), w = () => d.flush(), P = () => {
2636
+ }), g = (T) => d.schedule(T), w = () => d.flush(), C = () => {
2637
2637
  d.cancel(), c();
2638
2638
  };
2639
- return e.on("mousemove", g), e.on("mouseout", P), window.addEventListener("pointerdown", w, !0), window.addEventListener("pointerup", w, !0), () => {
2640
- d.cancel(), e.off("mousemove", g), e.off("mouseout", P), window.removeEventListener("pointerdown", w, !0), window.removeEventListener("pointerup", w, !0);
2639
+ return e.on("mousemove", g), e.on("mouseout", C), window.addEventListener("pointerdown", w, !0), window.addEventListener("pointerup", w, !0), () => {
2640
+ d.cancel(), e.off("mousemove", g), e.off("mouseout", C), window.removeEventListener("pointerdown", w, !0), window.removeEventListener("pointerup", w, !0);
2641
2641
  };
2642
2642
  }, [o, r, s, i, e, t, n, l]), null;
2643
2643
  }
2644
- function ci({ map: e }) {
2644
+ function ii({ map: e }) {
2645
2645
  const t = he((n) => n.features);
2646
2646
  return K(() => {
2647
2647
  if (t.length === 0) return;
@@ -3034,125 +3034,125 @@ const Ls = ao(function({
3034
3034
  );
3035
3035
  });
3036
3036
  function Es({ map: e }) {
3037
- const t = vt(), n = W((y) => y.editingMode), o = W((y) => y.measurePoints), r = W((y) => y.measureMode), s = W((y) => y.completedMeasurements), i = W((y) => y.selectedMeasurementId), l = W((y) => y.snappedCoord), u = W((y) => y.toggleMeasurementSelection), c = W((y) => y.setSelectedMeasurementId), v = oo(e, n, n === "measure"), { units: d } = ke(), g = { unit: d.length, display: d.display, precision: d.precision }, w = { unit: d.area, display: d.display, precision: d.precision }, [P, T] = le(null), _ = n === "measure", M = _ ? l ?? v : null, N = o.length > 0 ? o[o.length - 1] : null;
3037
+ const t = vt(), n = W((p) => p.editingMode), o = W((p) => p.measurePoints), r = W((p) => p.measureMode), s = W((p) => p.completedMeasurements), i = W((p) => p.selectedMeasurementId), l = W((p) => p.snappedCoord), u = W((p) => p.toggleMeasurementSelection), c = W((p) => p.setSelectedMeasurementId), v = oo(e, n, n === "measure"), { units: d } = ke(), g = { unit: d.length, display: d.display, precision: d.precision }, w = { unit: d.area, display: d.display, precision: d.precision }, [C, T] = le(null), F = n === "measure", k = F ? l ?? v : null, N = o.length > 0 ? o[o.length - 1] : null;
3038
3038
  K(() => {
3039
- const y = [];
3039
+ const p = [];
3040
3040
  for (const f of s) {
3041
- const b = P === f.id, C = i === f.id;
3041
+ const b = C === f.id, M = i === f.id;
3042
3042
  if (f.mode === "distance") {
3043
- for (let I = 0; I < f.points.length - 1; I++)
3044
- y.push({
3043
+ for (let E = 0; E < f.points.length - 1; E++)
3044
+ p.push({
3045
3045
  type: "Feature",
3046
- properties: { _kind: "segment", _id: f.id, _segIdx: I, _hovered: b, _selected: C },
3047
- geometry: { type: "LineString", coordinates: [f.points[I], f.points[I + 1]] }
3046
+ properties: { _kind: "segment", _id: f.id, _segIdx: E, _hovered: b, _selected: M },
3047
+ geometry: { type: "LineString", coordinates: [f.points[E], f.points[E + 1]] }
3048
3048
  });
3049
- f.points.forEach((I, a) => {
3050
- y.push({
3049
+ f.points.forEach((E, a) => {
3050
+ p.push({
3051
3051
  type: "Feature",
3052
3052
  properties: { _kind: "dot", _id: f.id, _isFirst: a === 0 },
3053
- geometry: { type: "Point", coordinates: I }
3053
+ geometry: { type: "Point", coordinates: E }
3054
3054
  });
3055
3055
  });
3056
3056
  } else
3057
- y.push({
3057
+ p.push({
3058
3058
  type: "Feature",
3059
- properties: { _kind: "area", _id: f.id, _hovered: b, _selected: C },
3059
+ properties: { _kind: "area", _id: f.id, _hovered: b, _selected: M },
3060
3060
  geometry: { type: "Polygon", coordinates: [f.points] }
3061
- }), y.push({
3061
+ }), p.push({
3062
3062
  type: "Feature",
3063
- properties: { _kind: "segment", _id: f.id, _hovered: b, _selected: C },
3063
+ properties: { _kind: "segment", _id: f.id, _hovered: b, _selected: M },
3064
3064
  geometry: { type: "LineString", coordinates: f.points }
3065
- }), f.points.slice(0, -1).forEach((I, a) => {
3066
- y.push({
3065
+ }), f.points.slice(0, -1).forEach((E, a) => {
3066
+ p.push({
3067
3067
  type: "Feature",
3068
3068
  properties: { _kind: "dot", _id: f.id, _isFirst: a === 0 },
3069
- geometry: { type: "Point", coordinates: I }
3069
+ geometry: { type: "Point", coordinates: E }
3070
3070
  });
3071
3071
  });
3072
3072
  }
3073
- _ && o.length >= 2 && y.push({
3073
+ F && o.length >= 2 && p.push({
3074
3074
  type: "Feature",
3075
3075
  properties: { _kind: "live-line" },
3076
3076
  geometry: { type: "LineString", coordinates: o }
3077
- }), _ && r === "area" && o.length >= 3 && y.push({
3077
+ }), F && r === "area" && o.length >= 3 && p.push({
3078
3078
  type: "Feature",
3079
3079
  properties: { _kind: "live-area" },
3080
3080
  geometry: { type: "Polygon", coordinates: [[...o, o[0]]] }
3081
- }), _ && M && N && y.push({
3081
+ }), F && k && N && p.push({
3082
3082
  type: "Feature",
3083
3083
  properties: { _kind: "ghost" },
3084
- geometry: { type: "LineString", coordinates: [N, M] }
3085
- }), _ && r === "area" && M && o.length >= 2 && y.push({
3084
+ geometry: { type: "LineString", coordinates: [N, k] }
3085
+ }), F && r === "area" && k && o.length >= 2 && p.push({
3086
3086
  type: "Feature",
3087
3087
  properties: { _kind: "close-hint" },
3088
- geometry: { type: "LineString", coordinates: [M, o[0]] }
3089
- }), _ && o.forEach((f, b) => {
3090
- y.push({
3088
+ geometry: { type: "LineString", coordinates: [k, o[0]] }
3089
+ }), F && o.forEach((f, b) => {
3090
+ p.push({
3091
3091
  type: "Feature",
3092
3092
  properties: { _kind: "live-dot", _isFirst: b === 0 },
3093
3093
  geometry: { type: "Point", coordinates: f }
3094
3094
  });
3095
- }), ws(e, y);
3095
+ }), ws(e, p);
3096
3096
  }, [
3097
3097
  e,
3098
- _,
3098
+ F,
3099
3099
  o,
3100
3100
  r,
3101
3101
  s,
3102
- P,
3102
+ C,
3103
3103
  i,
3104
- M,
3104
+ k,
3105
3105
  N,
3106
3106
  t
3107
3107
  ]), K(() => {
3108
- const y = (I) => {
3109
- var p, m;
3110
- const a = (p = I.features) == null ? void 0 : p[0];
3108
+ const p = (E) => {
3109
+ var y, m;
3110
+ const a = (y = E.features) == null ? void 0 : y[0];
3111
3111
  if (!a) return;
3112
3112
  const x = (m = a.properties) == null ? void 0 : m._id;
3113
- x && (Pr(), I.originalEvent.stopPropagation(), u(x));
3114
- }, f = (I) => {
3115
- var F, S, L, B;
3116
- const a = (F = I.features) == null ? void 0 : F[0];
3113
+ x && (Pr(), E.originalEvent.stopPropagation(), u(x));
3114
+ }, f = (E) => {
3115
+ var R, S, L, B;
3116
+ const a = (R = E.features) == null ? void 0 : R[0];
3117
3117
  if (!a) return;
3118
3118
  const x = (S = a.properties) == null ? void 0 : S._id;
3119
3119
  if (!x) return;
3120
3120
  T(x);
3121
- const p = (L = a.properties) == null ? void 0 : L._kind, m = (B = a.properties) == null ? void 0 : B._segIdx;
3122
- if (p === "segment" && typeof m == "number") {
3121
+ const y = (L = a.properties) == null ? void 0 : L._kind, m = (B = a.properties) == null ? void 0 : B._segIdx;
3122
+ if (y === "segment" && typeof m == "number") {
3123
3123
  const V = s.find((j) => j.id === x);
3124
3124
  if (V && V.mode === "distance") {
3125
3125
  const j = V.points[m], h = V.points[m + 1];
3126
3126
  if (j && h) {
3127
- const k = mt(_e(We([j, h])) * 1e3, g);
3128
- Ss(`${k.value} ${k.unit}`, I.originalEvent.clientX, I.originalEvent.clientY);
3127
+ const I = mt(_e(We([j, h])) * 1e3, g);
3128
+ Ss(`${I.value} ${I.unit}`, E.originalEvent.clientX, E.originalEvent.clientY);
3129
3129
  }
3130
3130
  }
3131
3131
  }
3132
- }, b = (I) => {
3133
- var p, m;
3134
- const a = (p = I.features) == null ? void 0 : p[0];
3132
+ }, b = (E) => {
3133
+ var y, m;
3134
+ const a = (y = E.features) == null ? void 0 : y[0];
3135
3135
  if (!a) return;
3136
- ((m = a.properties) == null ? void 0 : m._kind) === "segment" && ro(I.originalEvent.clientX, I.originalEvent.clientY);
3137
- }, C = () => {
3136
+ ((m = a.properties) == null ? void 0 : m._kind) === "segment" && ro(E.originalEvent.clientX, E.originalEvent.clientY);
3137
+ }, M = () => {
3138
3138
  T(null), Cn();
3139
- }, R = (I) => {
3139
+ }, A = (E) => {
3140
3140
  try {
3141
- e.queryRenderedFeatures(I.point, { layers: Rt }).length === 0 && c(null);
3141
+ e.queryRenderedFeatures(E.point, { layers: Rt }).length === 0 && c(null);
3142
3142
  } catch {
3143
3143
  }
3144
3144
  };
3145
- for (const I of Rt)
3146
- e.on("click", I, y), e.on("mouseenter", I, f), e.on("mousemove", I, b), e.on("mouseleave", I, C);
3147
- return e.on("click", R), () => {
3148
- for (const I of Rt)
3149
- e.off("click", I, y), e.off("mouseenter", I, f), e.off("mousemove", I, b), e.off("mouseleave", I, C);
3150
- e.off("click", R), Cn();
3145
+ for (const E of Rt)
3146
+ e.on("click", E, p), e.on("mouseenter", E, f), e.on("mousemove", E, b), e.on("mouseleave", E, M);
3147
+ return e.on("click", A), () => {
3148
+ for (const E of Rt)
3149
+ e.off("click", E, p), e.off("mouseenter", E, f), e.off("mousemove", E, b), e.off("mouseleave", E, M);
3150
+ e.off("click", A), Cn();
3151
3151
  };
3152
3152
  }, [e, u, c, s, g.unit, g.display, g.precision]);
3153
- const E = r === "distance" ? 1 : 2, A = M && o.length >= E ? [...o, M] : o, D = bs(A, r, g, w), q = M ?? N;
3153
+ const P = r === "distance" ? 1 : 2, _ = k && o.length >= P ? [...o, k] : o, D = bs(_, r, g, w), q = k ?? N;
3154
3154
  return /* @__PURE__ */ fe(lt, { children: [
3155
- s.map((y) => /* @__PURE__ */ X(Ls, { map: e, m: y }, y.id)),
3155
+ s.map((p) => /* @__PURE__ */ X(Ls, { map: e, m: p }, p.id)),
3156
3156
  D && q && /* @__PURE__ */ X(so, { map: e, position: q, parts: D })
3157
3157
  ] });
3158
3158
  }
@@ -3271,42 +3271,42 @@ async function Fs(e, t) {
3271
3271
  function _s({ map: e }) {
3272
3272
  const { dataStore: t, uiStore: n } = Le(), o = ke().network, r = $(o);
3273
3273
  r.current = o;
3274
- const s = Ue(), i = zt(), l = W((y) => y.editingMode), [u, c] = le(null), [v, d] = le(null), g = Oo(), w = An(), P = $(null), T = $(null), _ = $(null), M = $(null);
3274
+ const s = Ue(), i = zt(), l = W((p) => p.editingMode), [u, c] = le(null), [v, d] = le(null), g = Oo(), w = An(), C = $(null), T = $(null), F = $(null), k = $(null);
3275
3275
  K(() => () => {
3276
- _.current && (_.current.remove(), _.current = null);
3276
+ F.current && (F.current.remove(), F.current = null);
3277
3277
  }, [e]);
3278
3278
  const N = vt();
3279
3279
  K(() => {
3280
3280
  ks(e, u, v);
3281
3281
  }, [e, u, v, N]);
3282
- const E = ve(
3283
- (y) => Mo(t.getState(), n.getState(), y),
3282
+ const P = ve(
3283
+ (p) => Mo(t.getState(), n.getState(), p),
3284
3284
  [t, n]
3285
- ), A = ve(() => {
3286
- _.current && (_.current.remove(), _.current = null);
3285
+ ), _ = ve(() => {
3286
+ F.current && (F.current.remove(), F.current = null);
3287
3287
  }, []), D = ve(() => {
3288
- c(null), d(null), P.current = null, A(), T.current && (T.current.abort(), T.current = null);
3289
- }, [A]), q = ve((y) => {
3290
- const f = P.current;
3291
- if (D(), !("pieces" in y)) {
3292
- E(y);
3288
+ c(null), d(null), C.current = null, _(), T.current && (T.current.abort(), T.current = null);
3289
+ }, [_]), q = ve((p) => {
3290
+ const f = C.current;
3291
+ if (D(), !("pieces" in p)) {
3292
+ P(p);
3293
3293
  return;
3294
3294
  }
3295
3295
  if (!f) return;
3296
3296
  const b = new AbortController();
3297
- T.current = b, Fs(y, f).then((C) => {
3298
- b.signal.aborted || (T.current = null, C && E(C));
3297
+ T.current = b, Fs(p, f).then((M) => {
3298
+ b.signal.aborted || (T.current = null, M && P(M));
3299
3299
  });
3300
- }, [E, D]);
3300
+ }, [P, D]);
3301
3301
  return K(() => {
3302
3302
  if (!u && l !== "pick-shape") return;
3303
- function y(f) {
3303
+ function p(f) {
3304
3304
  f.key === "Escape" && i(f) && D();
3305
3305
  }
3306
- return window.addEventListener("keydown", y), () => window.removeEventListener("keydown", y);
3306
+ return window.addEventListener("keydown", p), () => window.removeEventListener("keydown", p);
3307
3307
  }, [u, l, D, i]), K(() => {
3308
3308
  if (l !== "pick-shape") return;
3309
- const y = (f) => {
3309
+ const p = (f) => {
3310
3310
  if (e.getZoom() < Ro) {
3311
3311
  s({ type: "warning", message: "Zoom in further to use the picker" });
3312
3312
  return;
@@ -3314,72 +3314,72 @@ function _s({ map: e }) {
3314
3314
  f.originalEvent.preventDefault(), D();
3315
3315
  const b = new AbortController();
3316
3316
  T.current = b;
3317
- const C = f.lngLat.lng, R = f.lngLat.lat;
3318
- P.current = [C, R], Ps();
3319
- const I = document.createElement("div");
3320
- I.style.cssText = "width:64px;height:64px;pointer-events:none;display:flex;align-items:center;justify-content:center;", I.innerHTML = `
3317
+ const M = f.lngLat.lng, A = f.lngLat.lat;
3318
+ C.current = [M, A], Ps();
3319
+ const E = document.createElement("div");
3320
+ E.style.cssText = "width:64px;height:64px;pointer-events:none;display:flex;align-items:center;justify-content:center;", E.innerHTML = `
3321
3321
  <div class="elm-osm-pulse-ring" style="position:absolute"></div>
3322
3322
  <div class="elm-osm-spinner"></div>
3323
- `, _.current = new De.Marker({ element: I, anchor: "center" }).setLngLat([C, R]).addTo(e);
3324
- const a = Rs(e, f.point), { overpass: x, fetch: p } = r.current, m = x === !1;
3325
- (a.length > 0 || m ? Promise.resolve(a) : Qo(R, C, Fo(e.getZoom()), [C, R], { ...x, fetch: p, signal: b.signal })).then((S) => {
3326
- A(), S.length === 0 ? (s({ type: "warning", message: m ? "No shape here in the basemap" : "No features found here" }), D()) : S.length === 1 ? q(S[0]) : c(S);
3323
+ `, F.current = new De.Marker({ element: E, anchor: "center" }).setLngLat([M, A]).addTo(e);
3324
+ const a = Rs(e, f.point), { overpass: x, fetch: y } = r.current, m = x === !1;
3325
+ (a.length > 0 || m ? Promise.resolve(a) : Qo(A, M, Fo(e.getZoom()), [M, A], { ...x, fetch: y, signal: b.signal })).then((S) => {
3326
+ _(), S.length === 0 ? (s({ type: "warning", message: m ? "No shape here in the basemap" : "No features found here" }), D()) : S.length === 1 ? q(S[0]) : c(S);
3327
3327
  }).catch((S) => {
3328
- (S == null ? void 0 : S.name) !== "AbortError" && (A(), s({ type: "error", code: S instanceof tr ? S.code : "unknown", source: "picker", message: er(S), cause: S }), D());
3328
+ (S == null ? void 0 : S.name) !== "AbortError" && (_(), s({ type: "error", code: S instanceof tr ? S.code : "unknown", source: "picker", message: er(S), cause: S }), D());
3329
3329
  });
3330
3330
  };
3331
- return e.on("click", y), () => {
3332
- e.off("click", y);
3331
+ return e.on("click", p), () => {
3332
+ e.off("click", p);
3333
3333
  };
3334
- }, [l, e, D, A, q, s]), K(() => {
3335
- if (!u || !P.current) return;
3336
- const y = P.current;
3334
+ }, [l, e, D, _, q, s]), K(() => {
3335
+ if (!u || !C.current) return;
3336
+ const p = C.current;
3337
3337
  let f;
3338
3338
  function b() {
3339
- if (!M.current) {
3339
+ if (!k.current) {
3340
3340
  f = requestAnimationFrame(b);
3341
3341
  return;
3342
3342
  }
3343
- const C = e.project(y), R = e.getContainer().getBoundingClientRect();
3344
- M.current.style.left = `${R.left + C.x + 16}px`, M.current.style.top = `${R.top + C.y - 8}px`, f = requestAnimationFrame(b);
3343
+ const M = e.project(p), A = e.getContainer().getBoundingClientRect();
3344
+ k.current.style.left = `${A.left + M.x + 16}px`, k.current.style.top = `${A.top + M.y - 8}px`, f = requestAnimationFrame(b);
3345
3345
  }
3346
3346
  return f = requestAnimationFrame(b), () => cancelAnimationFrame(f);
3347
3347
  }, [u, e]), K(() => {
3348
3348
  if (!u) return;
3349
- const y = (I) => {
3350
- var m, F;
3351
- const a = (m = I.features) == null ? void 0 : m[0];
3349
+ const p = (E) => {
3350
+ var m, R;
3351
+ const a = (m = E.features) == null ? void 0 : m[0];
3352
3352
  if (!a) return;
3353
- const x = (F = a.properties) == null ? void 0 : F._idx;
3353
+ const x = (R = a.properties) == null ? void 0 : R._idx;
3354
3354
  if (typeof x != "number") return;
3355
- I.originalEvent.stopPropagation();
3356
- const p = u[x];
3357
- p && q(p);
3358
- }, f = (I) => {
3359
- var p, m;
3360
- const a = (p = I.features) == null ? void 0 : p[0];
3355
+ E.originalEvent.stopPropagation();
3356
+ const y = u[x];
3357
+ y && q(y);
3358
+ }, f = (E) => {
3359
+ var y, m;
3360
+ const a = (y = E.features) == null ? void 0 : y[0];
3361
3361
  if (!a) return;
3362
3362
  const x = (m = a.properties) == null ? void 0 : m._idx;
3363
3363
  typeof x == "number" && d(x), e.getCanvas().style.cursor = "pointer";
3364
3364
  }, b = () => {
3365
3365
  e.getCanvas().style.cursor = Ge(n.getState().editingMode);
3366
- }, C = () => {
3366
+ }, M = () => {
3367
3367
  d(null), b();
3368
- }, R = ["elm-osm-trace-fill", "elm-osm-trace-line"];
3369
- for (const I of R)
3370
- e.on("click", I, y), e.on("mouseenter", I, f), e.on("mouseleave", I, C);
3368
+ }, A = ["elm-osm-trace-fill", "elm-osm-trace-line"];
3369
+ for (const E of A)
3370
+ e.on("click", E, p), e.on("mouseenter", E, f), e.on("mouseleave", E, M);
3371
3371
  return () => {
3372
- for (const I of R)
3373
- e.off("click", I, y), e.off("mouseenter", I, f), e.off("mouseleave", I, C);
3372
+ for (const E of A)
3373
+ e.off("click", E, p), e.off("mouseenter", E, f), e.off("mouseleave", E, M);
3374
3374
  b();
3375
3375
  };
3376
3376
  }, [u, e, q, n]), K(() => {
3377
3377
  l !== "pick-shape" && D();
3378
3378
  }, [l, D]), u ? Ze(
3379
- /* @__PURE__ */ X("div", { ref: M, "data-elm-portal": !0, "data-elm-theme": w, style: { ...g, position: "fixed", zIndex: 1e4 }, children: /* @__PURE__ */ X("div", { className: "bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 text-elm-text-secondary shadow-elm rounded-elm overflow-hidden min-w-[180px] max-w-[280px] text-sm py-1", children: u.map((y, f) => /* @__PURE__ */ fe(
3379
+ /* @__PURE__ */ X("div", { ref: k, "data-elm-portal": !0, "data-elm-theme": w, style: { ...g, position: "fixed", zIndex: 1e4 }, children: /* @__PURE__ */ X("div", { className: "bg-elm-surface/95 backdrop-blur-md border border-elm-border/80 text-elm-text-secondary shadow-elm rounded-elm overflow-hidden min-w-[180px] max-w-[280px] text-sm py-1", children: u.map((p, f) => /* @__PURE__ */ fe(
3380
3380
  "button",
3381
3381
  {
3382
- onClick: () => q(y),
3382
+ onClick: () => q(p),
3383
3383
  onMouseEnter: () => d(f),
3384
3384
  onMouseLeave: () => d(null),
3385
3385
  className: `w-full text-left px-3 py-2 flex items-center gap-2 transition-colors ${v === f ? "bg-primary-50 dark:bg-white/5" : "hover:bg-(--elm-surface-hover,var(--color-gray-50)) dark:hover:bg-elm-surface-hover"}`,
@@ -3392,12 +3392,12 @@ function _s({ map: e }) {
3392
3392
  }
3393
3393
  ),
3394
3394
  /* @__PURE__ */ fe("span", { className: "flex flex-col min-w-0", children: [
3395
- /* @__PURE__ */ X("span", { className: "font-medium text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-100)) truncate", children: y.name || `Unnamed ${y.type.toLowerCase()}` }),
3396
- /* @__PURE__ */ X("span", { className: "text-xs text-(--elm-text-subtle,var(--color-gray-400))", children: y.type })
3395
+ /* @__PURE__ */ X("span", { className: "font-medium text-(--elm-text,var(--color-gray-800)) dark:text-(--elm-text,var(--color-gray-100)) truncate", children: p.name || `Unnamed ${p.type.toLowerCase()}` }),
3396
+ /* @__PURE__ */ X("span", { className: "text-xs text-(--elm-text-subtle,var(--color-gray-400))", children: p.type })
3397
3397
  ] })
3398
3398
  ]
3399
3399
  },
3400
- "key" in y ? y.key : `${y.osmId}/${f}`
3400
+ "key" in p ? p.key : `${p.osmId}/${f}`
3401
3401
  )) }) }),
3402
3402
  document.body
3403
3403
  ) : null;
@@ -3435,84 +3435,84 @@ function Ds(e, t) {
3435
3435
  }
3436
3436
  function Ks({ map: e }) {
3437
3437
  const { units: t } = ke(), n = { unit: t.length, display: t.display, precision: t.precision }, o = { unit: t.area, display: t.display, precision: t.precision }, r = (f) => {
3438
- const { value: b, unit: C } = mt(f * 1e3, n);
3439
- return `${b} ${C}`;
3438
+ const { value: b, unit: M } = mt(f * 1e3, n);
3439
+ return `${b} ${M}`;
3440
3440
  }, s = (f) => {
3441
- const { value: b, unit: C } = Ht(f, o);
3442
- return `${b} ${C}`;
3443
- }, i = W((f) => f.showMeasurements), l = W((f) => f.editingMode), u = W((f) => f.snappedCoord), c = W((f) => f.lineInProgress), v = W((f) => f.polygonInProgress), d = W((f) => f.circleCenter), g = W((f) => f.rectCorner), w = W((f) => f.freehandPoints), P = W((f) => f.freehandClosed), T = W((f) => f.routeWaypoints), _ = oo(e, l, l !== "none"), [M, N] = le(null), E = u ?? _;
3441
+ const { value: b, unit: M } = Ht(f, o);
3442
+ return `${b} ${M}`;
3443
+ }, i = W((f) => f.showMeasurements), l = W((f) => f.editingMode), u = W((f) => f.snappedCoord), c = W((f) => f.lineInProgress), v = W((f) => f.polygonInProgress), d = W((f) => f.circleCenter), g = W((f) => f.rectCorner), w = W((f) => f.freehandPoints), C = W((f) => f.freehandClosed), T = W((f) => f.routeWaypoints), F = oo(e, l, l !== "none"), [k, N] = le(null), P = u ?? F;
3444
3444
  K(() => {
3445
- if (!E) {
3445
+ if (!P) {
3446
3446
  N(null);
3447
3447
  return;
3448
3448
  }
3449
- N(e.project(E));
3450
- const f = () => N(E ? e.project(E) : null);
3449
+ N(e.project(P));
3450
+ const f = () => N(P ? e.project(P) : null);
3451
3451
  return e.on("move", f), e.on("zoom", f), () => {
3452
3452
  e.off("move", f), e.off("zoom", f);
3453
3453
  };
3454
- }, [e, E == null ? void 0 : E[0], E == null ? void 0 : E[1]]);
3455
- const A = $(null), [D, q] = le({ w: 0, h: 0 });
3454
+ }, [e, P == null ? void 0 : P[0], P == null ? void 0 : P[1]]);
3455
+ const _ = $(null), [D, q] = le({ w: 0, h: 0 });
3456
3456
  if (uo(() => {
3457
- const f = A.current;
3457
+ const f = _.current;
3458
3458
  f && (f.offsetWidth !== D.w || f.offsetHeight !== D.h) && q({ w: f.offsetWidth, h: f.offsetHeight });
3459
- }), !i || l === "none" || !E || !M) return null;
3460
- const y = [];
3459
+ }), !i || l === "none" || !P || !k) return null;
3460
+ const p = [];
3461
3461
  try {
3462
3462
  if (l === "place-point")
3463
- y.push({ label: "", value: `${E[1].toFixed(6)}, ${E[0].toFixed(6)}` });
3463
+ p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
3464
3464
  else if (l === "draw-line" || l === "slice-shape") {
3465
- const f = [...c, E];
3465
+ const f = [...c, P];
3466
3466
  if (f.length >= 2) {
3467
3467
  const b = We(f);
3468
- y.push({ label: "Length", value: r(_e(b)) }), y.push({ label: "Segment length", value: r(Pe(f[f.length - 2], f[f.length - 1])) });
3468
+ p.push({ label: "Length", value: r(_e(b)) }), p.push({ label: "Segment length", value: r(Pe(f[f.length - 2], f[f.length - 1])) });
3469
3469
  }
3470
- y.push({ label: "", value: `${E[1].toFixed(6)}, ${E[0].toFixed(6)}` });
3470
+ p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
3471
3471
  } else if (l === "draw-polygon" || l === "cut-hole") {
3472
- const f = [...v, E];
3472
+ const f = [...v, P];
3473
3473
  if (f.length >= 3) {
3474
- const b = [...f, f[0]], C = ut([b]);
3475
- y.push({ label: "Area", value: s(dt(C)) }), y.push({ label: "Perimeter", value: r(_e(C)) });
3476
- const R = Bn(C);
3477
- y.push({ label: "Height", value: r(Pe([R[0], R[1]], [R[0], R[3]])) }), y.push({ label: "Width", value: r(Pe([R[0], R[1]], [R[2], R[1]])) });
3478
- } else f.length === 2 && y.push({ label: "Segment length", value: r(Pe(f[0], f[1])) });
3479
- y.push({ label: "", value: `${E[1].toFixed(6)}, ${E[0].toFixed(6)}` });
3474
+ const b = [...f, f[0]], M = ut([b]);
3475
+ p.push({ label: "Area", value: s(dt(M)) }), p.push({ label: "Perimeter", value: r(_e(M)) });
3476
+ const A = Bn(M);
3477
+ p.push({ label: "Height", value: r(Pe([A[0], A[1]], [A[0], A[3]])) }), p.push({ label: "Width", value: r(Pe([A[0], A[1]], [A[2], A[1]])) });
3478
+ } else f.length === 2 && p.push({ label: "Segment length", value: r(Pe(f[0], f[1])) });
3479
+ p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
3480
3480
  } else if (l === "draw-circle") {
3481
3481
  if (d) {
3482
- const f = Pe(d, E);
3483
- y.push({ label: "Radius", value: r(f) }), y.push({ label: "Area", value: s(Math.PI * (f * 1e3) * (f * 1e3)) });
3482
+ const f = Pe(d, P);
3483
+ p.push({ label: "Radius", value: r(f) }), p.push({ label: "Area", value: s(Math.PI * (f * 1e3) * (f * 1e3)) });
3484
3484
  }
3485
- y.push({ label: "", value: `${E[1].toFixed(6)}, ${E[0].toFixed(6)}` });
3485
+ p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
3486
3486
  } else if (l === "draw-rect") {
3487
3487
  if (g) {
3488
- const f = Pe([g[0], g[1]], [E[0], g[1]]), b = Pe([g[0], g[1]], [g[0], E[1]]), C = f * b * 1e6;
3489
- y.push({ label: "Area", value: s(C) }), y.push({ label: "Width", value: r(f) }), y.push({ label: "Height", value: r(b) });
3488
+ const f = Pe([g[0], g[1]], [P[0], g[1]]), b = Pe([g[0], g[1]], [g[0], P[1]]), M = f * b * 1e6;
3489
+ p.push({ label: "Area", value: s(M) }), p.push({ label: "Width", value: r(f) }), p.push({ label: "Height", value: r(b) });
3490
3490
  }
3491
- y.push({ label: "", value: `${E[1].toFixed(6)}, ${E[0].toFixed(6)}` });
3491
+ p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
3492
3492
  } else if (l === "draw-route") {
3493
- const f = [...T, E];
3494
- f.length >= 2 && y.push({ label: "Straight distance", value: r(Pe(f[f.length - 2], f[f.length - 1])) }), y.push({ label: "", value: `${E[1].toFixed(6)}, ${E[0].toFixed(6)}` });
3493
+ const f = [...T, P];
3494
+ f.length >= 2 && p.push({ label: "Straight distance", value: r(Pe(f[f.length - 2], f[f.length - 1])) }), p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
3495
3495
  } else if (l === "draw-freehand") {
3496
- if (w.length >= 3 && P) {
3496
+ if (w.length >= 3 && C) {
3497
3497
  const f = [...w, w[0]], b = ut([f]);
3498
- y.push({ label: "Area", value: s(dt(b)) }), y.push({ label: "Perimeter", value: r(_e(b)) });
3498
+ p.push({ label: "Area", value: s(dt(b)) }), p.push({ label: "Perimeter", value: r(_e(b)) });
3499
3499
  } else if (w.length >= 2) {
3500
3500
  const f = We(w);
3501
- y.push({ label: "Length", value: r(_e(f)) });
3501
+ p.push({ label: "Length", value: r(_e(f)) });
3502
3502
  }
3503
- y.push({ label: "", value: `${E[1].toFixed(6)}, ${E[0].toFixed(6)}` });
3503
+ p.push({ label: "", value: `${P[1].toFixed(6)}, ${P[0].toFixed(6)}` });
3504
3504
  }
3505
3505
  } catch {
3506
3506
  }
3507
- return y.length === 0 ? null : Ze(
3507
+ return p.length === 0 ? null : Ze(
3508
3508
  /* @__PURE__ */ X(
3509
3509
  "div",
3510
3510
  {
3511
- ref: A,
3511
+ ref: _,
3512
3512
  className: "elm-measurement-tooltip",
3513
3513
  style: {
3514
3514
  position: "absolute",
3515
- ...Fn(M.x, M.y, D.w, D.h, {
3515
+ ...Fn(k.x, k.y, D.w, D.h, {
3516
3516
  x: "after",
3517
3517
  y: "center",
3518
3518
  gapX: 20,
@@ -3531,7 +3531,7 @@ function Ks({ map: e }) {
3531
3531
  color: "var(--elm-text-secondary, rgb(75, 85, 99))",
3532
3532
  fontFamily: "var(--elm-font, ui-sans-serif, system-ui, sans-serif)"
3533
3533
  },
3534
- children: /* @__PURE__ */ X("div", { style: { display: "flex", flexDirection: "column", gap: 4, textAlign: "left" }, children: y.map((f, b) => /* @__PURE__ */ fe("div", { style: { display: "flex", gap: 8, alignItems: "center", lineHeight: 1.3 }, children: [
3534
+ children: /* @__PURE__ */ X("div", { style: { display: "flex", flexDirection: "column", gap: 4, textAlign: "left" }, children: p.map((f, b) => /* @__PURE__ */ fe("div", { style: { display: "flex", gap: 8, alignItems: "center", lineHeight: 1.3 }, children: [
3535
3535
  f.label && /* @__PURE__ */ fe("span", { style: { fontWeight: 600, color: "var(--elm-text, rgb(17, 24, 39))" }, children: [
3536
3536
  f.label,
3537
3537
  ":"
@@ -3544,7 +3544,7 @@ function Ks({ map: e }) {
3544
3544
  );
3545
3545
  }
3546
3546
  const Qt = Nt(null);
3547
- function li() {
3547
+ function ci() {
3548
3548
  const e = pt(Qt);
3549
3549
  if (!e) throw new Error("useMapLibre must be used inside ElementEditorControls");
3550
3550
  return e;
@@ -3631,7 +3631,7 @@ const Os = In(
3631
3631
  t.children
3632
3632
  ] });
3633
3633
  }
3634
- ), ai = In(
3634
+ ), li = In(
3635
3635
  function(t, n) {
3636
3636
  const [o, r] = le(() => t.map.isStyleLoaded()), [s, i] = le(0);
3637
3637
  K(() => Ds(t.map, () => {
@@ -3659,7 +3659,7 @@ function je(e, t) {
3659
3659
  const n = e.id ?? e.label ?? ("url" in e ? e.url : typeof e.style == "string" ? e.style : void 0);
3660
3660
  return n || (t >= 0 ? `custom-${t}` : (Ft.has(e) || Ft.set(e, `custom-anon-${++js}`), Ft.get(e)));
3661
3661
  }
3662
- const io = () => import("./style-mSgM9UsZ.js"), zs = () => Promise.all([io(), import("./catalog-gI-xABuu.js")]).then(([e, t]) => ({ ...e, ...t }));
3662
+ const io = () => import("./style-DVShZtJT.js"), zs = () => Promise.all([io(), import("./catalog-gI-xABuu.js")]).then(([e, t]) => ({ ...e, ...t }));
3663
3663
  let yt = !1;
3664
3664
  const co = (e) => new Tt(
3665
3665
  "network",
@@ -3694,99 +3694,99 @@ function Hs(e, t, n) {
3694
3694
  const g = c(t);
3695
3695
  if (v.current === "" && (v.current = je(i.resolveBasemap(d.current.basemap, d.current.theme), -1)), v.current === g) return;
3696
3696
  let w = !1;
3697
- const P = (D) => D instanceof Error ? D.message : String(D), T = i.resolveBasemap(t, o), _ = typeof T == "object" && "style" in T && typeof T.style == "string", M = (D) => {
3698
- N(), v.current = null, u(new Tt(ln(D.error), "basemap", `The basemap could not be loaded (${P(D.error)}).`, { cause: D.error }));
3697
+ const C = (D) => D instanceof Error ? D.message : String(D), T = i.resolveBasemap(t, o), F = typeof T == "object" && "style" in T && typeof T.style == "string", k = (D) => {
3698
+ N(), v.current = null, u(new Tt(ln(D.error), "basemap", `The basemap could not be loaded (${C(D.error)}).`, { cause: D.error }));
3699
3699
  }, N = () => {
3700
- e.off("error", M), e.off("styledata", N);
3701
- }, E = () => {
3702
- w || !(e.isStyleLoaded() || e.getSource("elm-features")) || (w = !0, e.off("styledata", E), v.current = g, i.setBasemap(e, t, { theme: o, network: s.current }).then(() => {
3703
- _ && !A && (e.on("error", M), e.once("styledata", N));
3700
+ e.off("error", k), e.off("styledata", N);
3701
+ }, P = () => {
3702
+ w || !(e.isStyleLoaded() || e.getSource("elm-features")) || (w = !0, e.off("styledata", P), v.current = g, i.setBasemap(e, t, { theme: o, network: s.current }).then(() => {
3703
+ F && !_ && (e.on("error", k), e.once("styledata", N));
3704
3704
  }, (D) => {
3705
- v.current = null, u(new Tt(ln(D), "basemap", `The basemap could not be switched (${P(D)}). The map keeps the previous one.`, { cause: D }));
3705
+ v.current = null, u(new Tt(ln(D), "basemap", `The basemap could not be switched (${C(D)}). The map keeps the previous one.`, { cause: D }));
3706
3706
  }));
3707
3707
  };
3708
- let A = !1;
3709
- return e.on("styledata", E), E(), () => {
3710
- w = !0, A = !0, e.off("styledata", E), N();
3708
+ let _ = !1;
3709
+ return e.on("styledata", P), P(), () => {
3710
+ w = !0, _ = !0, e.off("styledata", P), N();
3711
3711
  };
3712
3712
  }, [e, i, t, o]);
3713
3713
  }
3714
- function ui(e) {
3715
- const { basemaps: t, value: n, defaultValue: o = "auto", onChange: r, storageKey: s, initialApplied: i, size: l, tooltipSide: u } = e, c = Ns(), v = e.map ?? c, d = An(), [g, w] = le(null), P = lo();
3714
+ function ai(e) {
3715
+ const { basemaps: t, value: n, defaultValue: o = "auto", onChange: r, storageKey: s, initialApplied: i, size: l, tooltipSide: u } = e, c = Ns(), v = e.map ?? c, d = An(), [g, w] = le(null), C = lo();
3716
3716
  K(() => {
3717
3717
  let a = !0;
3718
3718
  return zs().then((x) => a && w(x), (x) => {
3719
- a && !yt && (yt = !0, P(co(x)));
3719
+ a && !yt && (yt = !0, C(co(x)));
3720
3720
  }), () => {
3721
3721
  a = !1;
3722
3722
  };
3723
3723
  }, []);
3724
- const T = ke(), _ = Bt(() => t ?? ["auto", ...$s], [t]), M = _.map(je);
3725
- (_.filter((a) => typeof a == "object" && !a.id && !a.label && !("url" in a) && typeof a.style != "string").length > 1 || new Set(M).size < M.length) && Rn("basemap-ids", "BasemapControl: give each custom basemap a unique `id` (two entries without one, or with the same id/label, cannot be told apart).");
3724
+ const T = ke(), F = Bt(() => t ?? ["auto", ...$s], [t]), k = F.map(je);
3725
+ (F.filter((a) => typeof a == "object" && !a.id && !a.label && !("url" in a) && typeof a.style != "string").length > 1 || new Set(k).size < k.length) && Rn("basemap-ids", "BasemapControl: give each custom basemap a unique `id` (two entries without one, or with the same id/label, cannot be told apart).");
3726
3726
  const [N] = le(() => {
3727
3727
  const a = s ? nr(s, T) : null;
3728
- return a ? _.find((x, p) => je(x, p) === a) : void 0;
3729
- }), [E, A] = le(N ?? o), [D, q] = le(n !== void 0 || e.defaultValue !== void 0 || N !== void 0), y = n ?? E, f = _.indexOf(y), b = f >= 0 ? M[f] : je(y, -1);
3730
- Hs(D || n !== void 0 ? v : null, y, {
3728
+ return a ? F.find((x, y) => je(x, y) === a) : void 0;
3729
+ }), [P, _] = le(N ?? o), [D, q] = le(n !== void 0 || e.defaultValue !== void 0 || N !== void 0), p = n ?? P, f = F.indexOf(p), b = f >= 0 ? k[f] : je(p, -1);
3730
+ Hs(D || n !== void 0 ? v : null, p, {
3731
3731
  theme: d,
3732
- initialApplied: D && i && b === je(o, _.indexOf(o))
3732
+ initialApplied: D && i && b === je(o, F.indexOf(o))
3733
3733
  });
3734
- const C = ve((a) => {
3735
- const x = M.indexOf(a);
3734
+ const M = ve((a) => {
3735
+ const x = k.indexOf(a);
3736
3736
  if (x < 0) return;
3737
- const p = _[x];
3738
- q(!0), n === void 0 && A(p), s && (typeof p == "string" || p.id) && or(s, a, T), r == null || r(p);
3739
- }, [M, _, n, s, r, T]);
3737
+ const y = F[x];
3738
+ q(!0), n === void 0 && _(y), s && (typeof y == "string" || y.id) && or(s, a, T), r == null || r(y);
3739
+ }, [k, F, n, s, r, T]);
3740
3740
  if (!g) return null;
3741
- const R = (a) => {
3741
+ const A = (a) => {
3742
3742
  var x;
3743
- return (x = g.BASEMAPS.find((p) => p.id === a)) == null ? void 0 : x.thumbnail;
3744
- }, I = _.map((a, x) => {
3745
- const p = M[x], m = typeof a == "string" ? g.BASEMAPS.find((F) => F.id === a) : void 0;
3743
+ return (x = g.BASEMAPS.find((y) => y.id === a)) == null ? void 0 : x.thumbnail;
3744
+ }, E = F.map((a, x) => {
3745
+ const y = k[x], m = typeof a == "string" ? g.BASEMAPS.find((R) => R.id === a) : void 0;
3746
3746
  return {
3747
- id: p,
3748
- label: a === "auto" ? "Auto" : (m == null ? void 0 : m.label) ?? (typeof a == "object" && a.label || p),
3747
+ id: y,
3748
+ label: a === "auto" ? "Auto" : (m == null ? void 0 : m.label) ?? (typeof a == "object" && a.label || y),
3749
3749
  // Auto shows both looks it switches between (light → streets, dark → dark).
3750
- thumbnail: a === "auto" ? [R("streets"), R("dark")].every(Boolean) ? [R("streets"), R("dark")] : void 0 : typeof a == "string" ? R(a) : a.thumbnail
3750
+ thumbnail: a === "auto" ? [A("streets"), A("dark")].every(Boolean) ? [A("streets"), A("dark")] : void 0 : typeof a == "string" ? A(a) : a.thumbnail
3751
3751
  };
3752
3752
  });
3753
- return /* @__PURE__ */ X(Uo, { options: I, value: b, onChange: C, size: l, tooltipSide: u });
3753
+ return /* @__PURE__ */ X(Uo, { options: E, value: b, onChange: M, size: l, tooltipSide: u });
3754
3754
  }
3755
3755
  export {
3756
- gi as ActiveDrawingToolbar,
3757
- ui as BasemapControl,
3756
+ fi as ActiveDrawingToolbar,
3757
+ ai as BasemapControl,
3758
3758
  ys as BoundaryLayer,
3759
3759
  rs as BoxSelectHandler,
3760
3760
  Rr as DrawingLayer,
3761
3761
  Ar as DrawingPreviewLayer,
3762
- yi as EditingToolbar,
3763
- ai as ElementEditorControls,
3764
- Mi as ElementEditorError,
3765
- pi as ElementEditorUIProvider,
3762
+ gi as EditingToolbar,
3763
+ li as ElementEditorControls,
3764
+ Ci as ElementEditorError,
3765
+ yi as ElementEditorUIProvider,
3766
3766
  us as FeatureInteractionLayer,
3767
3767
  Er as FeatureLayer,
3768
3768
  gr as FeatureStyleProvider,
3769
- ci as FitBounds,
3770
- hi as FloatingToolbar,
3771
- mi as GeoStoreProvider,
3769
+ ii as FitBounds,
3770
+ pi as FloatingToolbar,
3771
+ hi as GeoStoreProvider,
3772
3772
  ms as GeometryProcessingPreview,
3773
- vi as MapControllerProvider,
3773
+ mi as MapControllerProvider,
3774
3774
  Es as MeasurePreviewLayer,
3775
3775
  Ks as MeasurementTooltip,
3776
3776
  _s as OsmTraceHandler,
3777
3777
  gs as SnapController,
3778
- xi as StoreContext,
3778
+ vi as StoreContext,
3779
3779
  es as TransformControls,
3780
3780
  $r as VertexEditor,
3781
3781
  Vn as findSnapPoint,
3782
3782
  Dt as snapToAngle,
3783
3783
  Hs as useBasemap,
3784
- wi as useDataStore,
3784
+ xi as useDataStore,
3785
3785
  yr as useFeatureStyle,
3786
- Si as useGeoStore,
3787
- bi as useKeyboardShortcuts,
3788
- Li as useMapController,
3789
- li as useMapLibre,
3790
- Ei as useSetMapController,
3791
- Pi as useUIStore
3786
+ wi as useGeoStore,
3787
+ Si as useKeyboardShortcuts,
3788
+ bi as useMapController,
3789
+ ci as useMapLibre,
3790
+ Li as useSetMapController,
3791
+ Ei as useUIStore
3792
3792
  };