bbl-mapbox-react 0.0.25 → 0.0.26

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.mjs CHANGED
@@ -5937,11 +5937,11 @@ function adjustPopupForBounds(e, t) {
5937
5937
  return r.x + t.width + 10 > n.width && (r.x = n.width - t.width - 10), r.x < 10 && (r.x = 10), r.y + t.height + 10 > n.height && (r.y = n.height - t.height - 10), r.y < 10 && (r.y = 10), r;
5938
5938
  }
5939
5939
  const Mapbox = forwardRef((e, c) => {
5940
- let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: C, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig: M, circleConfig: N, lengthConfig: P, showCoordinates: Se = !0, showScale: F = !0, showResetView: Ce = !0, showRoadHighlight: we = !1, showMeasure: I = !1, showRasterPaint: Ee = !1, showRoutePlanning: Ae, onRasterPaintChange: je, popupDefaults: L, renderPopup: Ne, onMapLoad: Pe, onEntityClick: Fe, onPopupOpen: Ie, onPopupClose: Le, className: Re = "", containerStyle: ze } = e, Be = useRef(null), Ve = useRef(null), He = useRef(null), R = useRef(null), z = useRef(/* @__PURE__ */ new Map()), B = useRef(/* @__PURE__ */ new Map()), Ue = useRef(/* @__PURE__ */ new Set()), [V, We] = useState(null), Ge = useRef(null), Ke = useRef(null), qe = useRef(null), [Je, Ye] = useState(null), Xe = useRef(null), Ze = useRef(null), [H, Qe] = useState(null), [$e, et] = useState(_), [tt, nt] = useState(null), rt = useRef(null), [it, U] = useState(null), [at, W] = useState(null), [ot, st] = useState(null), G = useRef(!1), ct = useRef(null), lt = useRef(null), K = useRef(null), ut = useRef(null), q = useRef(null), dt = useRef([]), ft = useRef(null), pt = useRef(null), mt = useRef(null), ht = useRef([]), gt = useRef(null), _t = useRef(!1), [vt, yt] = useState([]), bt = useRef([]);
5940
+ let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: p = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: C, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig: M, circleConfig: N, lengthConfig: P, showCoordinates: Se = !0, showScale: F = !0, showResetView: Ce = !0, showRoadHighlight: we = !1, showMeasure: I = !1, showRasterPaint: Ee = !1, showRoutePlanning: Ae, onRasterPaintChange: je, popupDefaults: L, renderPopup: Ne, onMapLoad: Pe, onEntityClick: Fe, onPopupOpen: Ie, onPopupClose: Le, className: Re = "", containerStyle: ze } = e, Be = useRef(null), Ve = useRef(null), He = useRef(null), R = useRef(null), z = useRef(/* @__PURE__ */ new Map()), B = useRef(/* @__PURE__ */ new Map()), Ue = useRef(/* @__PURE__ */ new Set()), [V, We] = useState(null), Ge = useRef(null), Ke = useRef(null), qe = useRef(null), [Je, Ye] = useState(null), Xe = useRef(null), Ze = useRef(null), [Qe, $e] = useState(null), [et, tt] = useState(_), [nt, rt] = useState(null), it = useRef(null), [at, H] = useState(null), [ot, U] = useState(null), [st, ct] = useState(null), W = useRef(!1), G = useRef(null), lt = useRef(null), K = useRef(null), ut = useRef(null), q = useRef(null), dt = useRef([]), ft = useRef(null), pt = useRef(null), mt = useRef(null), ht = useRef([]), gt = useRef(null), _t = useRef(!1), [vt, yt] = useState([]), bt = useRef([]);
5941
5941
  bt.current = vt;
5942
5942
  let J = useRef(null);
5943
5943
  useEffect(() => {
5944
- et(_);
5944
+ tt(_);
5945
5945
  }, [_]);
5946
5946
  let xt = useCallback((e) => {
5947
5947
  let t = z.current.get(e), n = B.current.get(e);
@@ -6057,12 +6057,12 @@ const Mapbox = forwardRef((e, c) => {
6057
6057
  if (!t || !t.getContainer()) return;
6058
6058
  let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = y;
6059
6059
  if (!n) {
6060
- rt.current &&= (rt.current.remove(), null);
6060
+ it.current &&= (it.current.remove(), null);
6061
6061
  return;
6062
6062
  }
6063
- if (rt.current) {
6064
- rt.current.setLngLat(e);
6065
- let t = rt.current.getElement(), n = t.querySelector(".marker-label");
6063
+ if (it.current) {
6064
+ it.current.setLngLat(e);
6065
+ let t = it.current.getElement(), n = t.querySelector(".marker-label");
6066
6066
  if (i) {
6067
6067
  let e = resolveNameConfig(a, O);
6068
6068
  if (n) n.textContent = i, n.style.color = e.fillColor, n.style.opacity = String(e.fillOpacity), n.style.webkitTextStrokeColor = e.strokeColor, n.style.webkitTextStrokeWidth = `${e.strokeWidth}px`;
@@ -6079,13 +6079,13 @@ const Mapbox = forwardRef((e, c) => {
6079
6079
  let e = resolveNameConfig(a, O), t = document.createElement("div");
6080
6080
  t.className = "marker-label", t.textContent = i, t.style.color = e.fillColor, t.style.opacity = String(e.fillOpacity), t.style.webkitTextStrokeColor = e.strokeColor, t.style.webkitTextStrokeWidth = `${e.strokeWidth}px`, n.appendChild(t);
6081
6081
  }
6082
- rt.current = new mapboxgl.Marker({
6082
+ it.current = new mapboxgl.Marker({
6083
6083
  element: n,
6084
6084
  anchor: "bottom"
6085
6085
  }).setLngLat(e).addTo(t);
6086
6086
  }
6087
6087
  }, [y, O]), Mt = useCallback(() => {
6088
- rt.current &&= (rt.current.remove(), null);
6088
+ it.current &&= (it.current.remove(), null);
6089
6089
  }, []), Nt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Pt = useCallback((e) => {
6090
6090
  let t = R.current;
6091
6091
  if (Be.current) if (gt.current &&= (gt.current.remove(), null), e && t) {
@@ -6192,11 +6192,11 @@ const Mapbox = forwardRef((e, c) => {
6192
6192
  },
6193
6193
  properties: {}
6194
6194
  });
6195
- let l = ct.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
6195
+ let l = G.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
6196
6196
  n.getLayer("rect-preview-line") && (n.setPaintProperty("rect-preview-line", "line-color", u), n.setPaintProperty("rect-preview-line", "line-width", d)), n.getLayer("rect-preview-fill") && (n.setPaintProperty("rect-preview-fill", "fill-color", f), n.setPaintProperty("rect-preview-fill", "fill-opacity", p));
6197
6197
  let m = n.getSource("rect-preview-measure-source");
6198
6198
  if (m) {
6199
- let e = Fn.current, t = [], n = c[0], r = c[1], i = c[2];
6199
+ let e = zn.current, t = [], n = c[0], r = c[1], i = c[2];
6200
6200
  if (e?.showArea) {
6201
6201
  let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
6202
6202
  t.push({
@@ -6247,7 +6247,7 @@ const Mapbox = forwardRef((e, c) => {
6247
6247
  features: []
6248
6248
  });
6249
6249
  }, []), X = useCallback(() => {
6250
- st(null), Rt();
6250
+ ct(null), Rt();
6251
6251
  }, [Rt]), zt = useCallback(() => {
6252
6252
  let e = R.current;
6253
6253
  e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
@@ -6316,7 +6316,7 @@ const Mapbox = forwardRef((e, c) => {
6316
6316
  });
6317
6317
  let o = K.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
6318
6318
  n.getLayer("circle-preview-line") && (n.setPaintProperty("circle-preview-line", "line-color", s), n.setPaintProperty("circle-preview-line", "line-width", c)), n.getLayer("circle-preview-fill") && (n.setPaintProperty("circle-preview-fill", "fill-color", l), n.setPaintProperty("circle-preview-fill", "fill-opacity", u));
6319
- let d = Fn.current, f = [], p = [];
6319
+ let d = zn.current, f = [], p = [];
6320
6320
  if (d?.showArea) {
6321
6321
  let t = Math.PI * i * i;
6322
6322
  f.push({
@@ -6460,7 +6460,7 @@ const Mapbox = forwardRef((e, c) => {
6460
6460
  n.getLayer("polygon-preview-line") && (n.setPaintProperty("polygon-preview-line", "line-color", s), n.setPaintProperty("polygon-preview-line", "line-width", c)), n.getLayer("polygon-preview-fill") && (n.setPaintProperty("polygon-preview-fill", "fill-color", l), n.setPaintProperty("polygon-preview-fill", "fill-opacity", u)), n.getLayer("polygon-vertices") && n.setPaintProperty("polygon-vertices", "circle-color", s);
6461
6461
  let d = n.getSource("polygon-preview-measure-source");
6462
6462
  if (d) {
6463
- let e = Fn.current, t = [];
6463
+ let e = zn.current, t = [];
6464
6464
  if (e?.showArea && a.length >= 3) {
6465
6465
  let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
6466
6466
  for (let e of a) r += e[0], i += e[1];
@@ -6575,7 +6575,7 @@ const Mapbox = forwardRef((e, c) => {
6575
6575
  n.getLayer("square-preview-line") && (n.setPaintProperty("square-preview-line", "line-color", s), n.setPaintProperty("square-preview-line", "line-width", c)), n.getLayer("square-preview-fill") && (n.setPaintProperty("square-preview-fill", "fill-color", l), n.setPaintProperty("square-preview-fill", "fill-opacity", u));
6576
6576
  let d = n.getSource("square-preview-measure-source");
6577
6577
  if (d) {
6578
- let t = Fn.current, n = [];
6578
+ let t = zn.current, n = [];
6579
6579
  if (t?.showArea && n.push({
6580
6580
  type: "Feature",
6581
6581
  geometry: {
@@ -6679,7 +6679,7 @@ const Mapbox = forwardRef((e, c) => {
6679
6679
  n.getLayer("polyline-preview-line") && (n.setPaintProperty("polyline-preview-line", "line-color", s), n.setPaintProperty("polyline-preview-line", "line-width", c)), n.getLayer("polyline-vertices") && n.setPaintProperty("polyline-vertices", "circle-color", s);
6680
6680
  let l = n.getSource("polyline-preview-measure-source");
6681
6681
  if (l) {
6682
- let e = Fn.current, t = [];
6682
+ let e = zn.current, t = [];
6683
6683
  if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
6684
6684
  let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
6685
6685
  t.push({
@@ -6717,7 +6717,7 @@ const Mapbox = forwardRef((e, c) => {
6717
6717
  }, []), Z = useCallback(() => {
6718
6718
  ht.current = [], nn();
6719
6719
  }, [nn]), rn = useCallback((e) => {
6720
- U(e), Pt(e), e ? (W("marker"), X(), Wt(), Jt(), $t(), Z()) : W(null);
6720
+ H(e), Pt(e), e ? (U("marker"), X(), Wt(), Jt(), $t(), Z()) : U(null);
6721
6721
  }, [
6722
6722
  Pt,
6723
6723
  X,
@@ -6726,27 +6726,27 @@ const Mapbox = forwardRef((e, c) => {
6726
6726
  $t,
6727
6727
  Z
6728
6728
  ]), an = useCallback((e) => {
6729
- if (W(e), e === "rectangle") {
6730
- U(null), Y(), Wt(), Jt(), $t(), Z();
6729
+ if (U(e), e === "rectangle") {
6730
+ H(null), Y(), Wt(), Jt(), $t(), Z();
6731
6731
  let e = R.current;
6732
6732
  e && (e.getCanvas().style.cursor = "crosshair");
6733
6733
  } else if (e === "circle") {
6734
- U(null), Y(), X(), Jt(), $t(), Z();
6734
+ H(null), Y(), X(), Jt(), $t(), Z();
6735
6735
  let e = R.current;
6736
6736
  e && (e.getCanvas().style.cursor = "crosshair");
6737
6737
  } else if (e === "polygon") {
6738
- U(null), Y(), X(), Wt(), $t(), Z();
6738
+ H(null), Y(), X(), Wt(), $t(), Z();
6739
6739
  let e = R.current;
6740
6740
  e && (e.getCanvas().style.cursor = "crosshair");
6741
6741
  } else if (e === "square") {
6742
- U(null), Y(), X(), Wt(), Jt(), Z();
6742
+ H(null), Y(), X(), Wt(), Jt(), Z();
6743
6743
  let e = R.current;
6744
6744
  e && (e.getCanvas().style.cursor = "crosshair");
6745
6745
  } else if (e === "polyline") {
6746
- U(null), Y(), X(), Wt(), Jt(), $t();
6746
+ H(null), Y(), X(), Wt(), Jt(), $t();
6747
6747
  let e = R.current;
6748
6748
  e && (e.getCanvas().style.cursor = "crosshair");
6749
- } else e === "marker" ? (X(), Wt(), Jt(), $t(), Z()) : (U(null), Y(), X(), Wt(), Jt(), $t(), Z());
6749
+ } else e === "marker" ? (X(), Wt(), Jt(), $t(), Z()) : (H(null), Y(), X(), Wt(), Jt(), $t(), Z());
6750
6750
  }, [
6751
6751
  Y,
6752
6752
  X,
@@ -6757,59 +6757,61 @@ const Mapbox = forwardRef((e, c) => {
6757
6757
  ]), on = useCallback((e) => {
6758
6758
  if (e !== "picker") {
6759
6759
  let e = y.value && isFinite(y.value.lng) && isFinite(y.value.lat), t = y.showMarker !== !1;
6760
- (!e || !t) && Mt(), nt(null);
6760
+ (!e || !t) && Mt(), rt(null);
6761
6761
  }
6762
- e !== "edit" && (U(null), W(null), X(), Z(), Y()), et(e);
6762
+ e !== "edit" && (H(null), U(null), X(), Z(), Y()), tt(e);
6763
6763
  }, [
6764
6764
  Mt,
6765
6765
  Y,
6766
6766
  X,
6767
6767
  Z
6768
- ]), sn = useCallback(() => $e, [$e]), cn = useCallback(() => tt, [tt]), ln = useCallback(() => {
6769
- Mt(), nt(null);
6770
- }, [Mt]);
6768
+ ]), sn = useCallback(() => et, [et]), cn = useCallback(() => nt, [nt]), ln = useCallback(() => {
6769
+ Mt(), rt(null);
6770
+ }, [Mt]), un = useRef(null), dn = useRef("display"), fn = useRef({}), pn = useCallback((e = {}) => (un.current &&= (un.current(null), null), new Promise((t) => {
6771
+ un.current = t, dn.current = Pn.current, fn.current = e, on("picker");
6772
+ })), [on]);
6771
6773
  useEffect(() => {
6772
- if (!H) return;
6774
+ if (!Qe) return;
6773
6775
  let e = y.value;
6774
6776
  if (e && isFinite(e.lng) && isFinite(e.lat)) {
6775
6777
  let t = [e.lng, e.lat];
6776
- nt(e), jt(t);
6778
+ rt(e), jt(t);
6777
6779
  }
6778
6780
  }, [
6779
6781
  y.value,
6780
6782
  jt,
6781
- H
6783
+ Qe
6782
6784
  ]);
6783
- let un = (e) => "mode" in e, dn = useCallback((e) => {
6784
- if (et("edit"), Mt(), nt(null), G.current = !0, un(e)) {
6785
- if (e.mode === "marker") e.markerStyle ? (lt.current = e.markerStyle, ct.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null, U(null), W("marker"), e.markerStyle.src && e.markerStyle.width ? Pt({
6785
+ let mn = (e) => "mode" in e, hn = useCallback((e) => {
6786
+ if (tt("edit"), Mt(), rt(null), W.current = !0, mn(e)) {
6787
+ if (e.mode === "marker") e.markerStyle ? (lt.current = e.markerStyle, G.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null, H(null), U("marker"), e.markerStyle.src && e.markerStyle.width ? Pt({
6786
6788
  id: "custom",
6787
6789
  name: e.markerStyle.name || "Marker",
6788
6790
  icon: e.markerStyle.src,
6789
6791
  width: e.markerStyle.width
6790
- }) : Y()) : e.template && (lt.current = null, ct.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null, U(e.template), W("marker"), Pt(e.template));
6792
+ }) : Y()) : e.template && (lt.current = null, G.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null, H(e.template), U("marker"), Pt(e.template));
6791
6793
  else if (e.mode === "rectangle") {
6792
- ct.current = e.rectangleStyle || null, lt.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null, U(null), W("rectangle"), Y();
6794
+ G.current = e.rectangleStyle || null, lt.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null, H(null), U("rectangle"), Y();
6793
6795
  let t = R.current;
6794
6796
  t && (t.getCanvas().style.cursor = "crosshair");
6795
6797
  } else if (e.mode === "circle") {
6796
- K.current = e.circleStyle || null, ct.current = null, lt.current = null, q.current = null, ft.current = null, mt.current = null, U(null), W("circle"), Y();
6798
+ K.current = e.circleStyle || null, G.current = null, lt.current = null, q.current = null, ft.current = null, mt.current = null, H(null), U("circle"), Y();
6797
6799
  let t = R.current;
6798
6800
  t && (t.getCanvas().style.cursor = "crosshair");
6799
6801
  } else if (e.mode === "polygon") {
6800
- q.current = e.polygonStyle || null, ct.current = null, lt.current = null, K.current = null, ft.current = null, mt.current = null, U(null), W("polygon"), Y();
6802
+ q.current = e.polygonStyle || null, G.current = null, lt.current = null, K.current = null, ft.current = null, mt.current = null, H(null), U("polygon"), Y();
6801
6803
  let t = R.current;
6802
6804
  t && (t.getCanvas().style.cursor = "crosshair");
6803
6805
  } else if (e.mode === "square") {
6804
- ft.current = e.squareStyle || null, ct.current = null, lt.current = null, K.current = null, q.current = null, mt.current = null, U(null), W("square"), Y();
6806
+ ft.current = e.squareStyle || null, G.current = null, lt.current = null, K.current = null, q.current = null, mt.current = null, H(null), U("square"), Y();
6805
6807
  let t = R.current;
6806
6808
  t && (t.getCanvas().style.cursor = "crosshair");
6807
6809
  } else if (e.mode === "polyline") {
6808
- mt.current = e.polylineStyle || null, ct.current = null, lt.current = null, K.current = null, q.current = null, ft.current = null, U(null), W("polyline"), Y();
6810
+ mt.current = e.polylineStyle || null, G.current = null, lt.current = null, K.current = null, q.current = null, ft.current = null, H(null), U("polyline"), Y();
6809
6811
  let t = R.current;
6810
6812
  t && (t.getCanvas().style.cursor = "crosshair");
6811
6813
  }
6812
- } else U(e), W("marker"), Pt(e), ct.current = null, lt.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null;
6814
+ } else H(e), U("marker"), Pt(e), G.current = null, lt.current = null, K.current = null, q.current = null, ft.current = null, mt.current = null;
6813
6815
  }, [
6814
6816
  Mt,
6815
6817
  Pt,
@@ -6831,7 +6833,7 @@ const Mapbox = forwardRef((e, c) => {
6831
6833
  setMode: on,
6832
6834
  getPickedLocation: cn,
6833
6835
  clearPickedLocation: ln,
6834
- startDrawing: dn,
6836
+ startDrawing: hn,
6835
6837
  getRenderer: (e) => z.current.get(e),
6836
6838
  setEditingEntities: (e) => {
6837
6839
  for (let t of bt.current) e.map(String).includes(String(t)) || z.current.get(t)?.setEditing?.(!1);
@@ -6839,6 +6841,7 @@ const Mapbox = forwardRef((e, c) => {
6839
6841
  J.current &&= (z.current.get(J.current.entityId)?.cancelEditPreview?.(), null), yt(e);
6840
6842
  },
6841
6843
  getEditingEntities: () => bt.current,
6844
+ startPicking: pn,
6842
6845
  startRoutePlanning: (e) => {
6843
6846
  Ve.current?.startPlanning(e);
6844
6847
  },
@@ -6858,9 +6861,10 @@ const Mapbox = forwardRef((e, c) => {
6858
6861
  on,
6859
6862
  cn,
6860
6863
  ln,
6861
- dn
6864
+ hn,
6865
+ pn
6862
6866
  ]);
6863
- let fn = useCallback(() => {
6867
+ let gn = useCallback(() => {
6864
6868
  let e = R.current;
6865
6869
  if (!e) return;
6866
6870
  let t = new Set(T.map((e) => e.id)), n = new Set(z.current.keys());
@@ -6904,10 +6908,10 @@ const Mapbox = forwardRef((e, c) => {
6904
6908
  M,
6905
6909
  N,
6906
6910
  P
6907
- ]), pn = useCallback(() => {
6911
+ ]), _n = useCallback(() => {
6908
6912
  for (let e of z.current.values()) e.destroy();
6909
6913
  z.current.clear();
6910
- }, []), mn = useCallback((e) => {
6914
+ }, []), vn = useCallback((e) => {
6911
6915
  let t = e.getStyle();
6912
6916
  if (!t?.layers) return;
6913
6917
  let n = [
@@ -6922,10 +6926,10 @@ const Mapbox = forwardRef((e, c) => {
6922
6926
  "marker-"
6923
6927
  ];
6924
6928
  for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
6925
- }, []), hn = useCallback((e) => {
6929
+ }, []), yn = useCallback((e) => {
6926
6930
  let t = C, n = { "raster-opacity": e.opacity ?? 1 }, r = e.brightness ?? t?.brightness, i = e.saturation ?? t?.saturation, a = e.contrast ?? t?.contrast, o = e.hueRotate ?? t?.hueRotate;
6927
6931
  return r !== void 0 && (n["raster-brightness-min"] = 0, n["raster-brightness-max"] = r), i !== void 0 && (n["raster-saturation"] = i), a !== void 0 && (n["raster-contrast"] = a), o !== void 0 && (n["raster-hue-rotate"] = o), n;
6928
- }, [C]), gn = useCallback((e, t) => {
6932
+ }, [C]), bn = useCallback((e, t) => {
6929
6933
  let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
6930
6934
  type: "raster",
6931
6935
  tiles: [t.url],
@@ -6935,19 +6939,19 @@ const Mapbox = forwardRef((e, c) => {
6935
6939
  scheme: t.scheme ?? "xyz"
6936
6940
  };
6937
6941
  t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
6938
- let a = mn(e);
6942
+ let a = vn(e);
6939
6943
  e.addLayer({
6940
6944
  id: r,
6941
6945
  type: "raster",
6942
6946
  source: n,
6943
- paint: hn(t),
6947
+ paint: yn(t),
6944
6948
  layout: { visibility: t.visible === !1 ? "none" : "visible" }
6945
6949
  }, a);
6946
- }, [mn, hn]), _n = useCallback(async (e, t) => {
6950
+ }, [vn, yn]), xn = useCallback(async (e, t) => {
6947
6951
  try {
6948
6952
  let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
6949
6953
  if (!Ue.current.has(t.id)) return;
6950
- let a = n.format === "pbf" || n.vector_layers, o = mn(e);
6954
+ let a = n.format === "pbf" || n.vector_layers, o = vn(e);
6951
6955
  if (a) {
6952
6956
  let t = {
6953
6957
  type: "vector",
@@ -6968,13 +6972,13 @@ const Mapbox = forwardRef((e, c) => {
6968
6972
  id: i,
6969
6973
  type: "raster",
6970
6974
  source: r,
6971
- paint: hn(t),
6975
+ paint: yn(t),
6972
6976
  layout: { visibility: t.visible === !1 ? "none" : "visible" }
6973
6977
  }, o);
6974
6978
  } catch (e) {
6975
6979
  console.error(`Failed to load TileJSON from ${t.url}:`, e);
6976
6980
  }
6977
- }, [mn, hn]), vn = useCallback(async (e, t) => {
6981
+ }, [vn, yn]), Sn = useCallback(async (e, t) => {
6978
6982
  try {
6979
6983
  let n = await (await fetch(t.url)).json();
6980
6984
  if (!Ue.current.has(t.id)) return;
@@ -6982,7 +6986,7 @@ const Mapbox = forwardRef((e, c) => {
6982
6986
  let n = `base-layer-source-${t.id}-${r}`;
6983
6987
  e.getSource(n) || e.addSource(n, i);
6984
6988
  }
6985
- let r = mn(e);
6989
+ let r = vn(e);
6986
6990
  if (n.layers) for (let i of n.layers) {
6987
6991
  let n = `base-layer-${t.id}-${i.id}`;
6988
6992
  if (e.getLayer(n)) continue;
@@ -6993,7 +6997,7 @@ const Mapbox = forwardRef((e, c) => {
6993
6997
  };
6994
6998
  i.type === "raster" && (a.paint = {
6995
6999
  ...a.paint,
6996
- ...hn(t)
7000
+ ...yn(t)
6997
7001
  }), t.visible === !1 && (a.layout = {
6998
7002
  ...a.layout,
6999
7003
  visibility: "none"
@@ -7006,50 +7010,50 @@ const Mapbox = forwardRef((e, c) => {
7006
7010
  } catch (e) {
7007
7011
  console.error(`Failed to load Style JSON from ${t.url}:`, e);
7008
7012
  }
7009
- }, [mn, hn]), yn = useCallback((e, t) => {
7013
+ }, [vn, yn]), Cn = useCallback((e, t) => {
7010
7014
  let n = e.getStyle();
7011
7015
  if (!n) return;
7012
7016
  let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
7013
7017
  for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
7014
7018
  let a = `base-layer-source-${t}`, o = n.sources ?? {};
7015
7019
  for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
7016
- }, []), bn = useCallback((e) => {
7020
+ }, []), wn = useCallback((e) => {
7017
7021
  let t = R.current;
7018
7022
  if (!t) return;
7019
7023
  let n = new Set(e.map((e) => e.id)), r = Ue.current;
7020
- for (let e of r) n.has(e) || (yn(t, e), r.delete(e));
7024
+ for (let e of r) n.has(e) || (Cn(t, e), r.delete(e));
7021
7025
  for (let n of e) if (r.has(n.id)) {
7022
7026
  let e = `base-layer-${n.id}`;
7023
7027
  if (t.getLayer(e)) {
7024
- let r = hn(n);
7028
+ let r = yn(n);
7025
7029
  for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
7026
7030
  t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
7027
7031
  }
7028
7032
  } else switch (r.add(n.id), n.type) {
7029
7033
  case "raster":
7030
- gn(t, n);
7034
+ bn(t, n);
7031
7035
  break;
7032
7036
  case "tilejson":
7033
- _n(t, n);
7037
+ xn(t, n);
7034
7038
  break;
7035
7039
  case "style":
7036
- vn(t, n);
7040
+ Sn(t, n);
7037
7041
  break;
7038
7042
  default: {
7039
7043
  let e = n;
7040
- e.url && gn(t, {
7044
+ e.url && bn(t, {
7041
7045
  ...e,
7042
7046
  type: "raster"
7043
7047
  });
7044
7048
  }
7045
7049
  }
7046
7050
  }, [
7047
- gn,
7048
- _n,
7049
- vn,
7050
- yn,
7051
- hn
7052
- ]), xn = useCallback((e) => {
7051
+ bn,
7052
+ xn,
7053
+ Sn,
7054
+ Cn,
7055
+ yn
7056
+ ]), Tn = useCallback((e) => {
7053
7057
  let t = e;
7054
7058
  for (; t;) {
7055
7059
  let e = t.getAttribute?.("data-entity-id");
@@ -7057,27 +7061,27 @@ const Mapbox = forwardRef((e, c) => {
7057
7061
  t = t.parentElement;
7058
7062
  }
7059
7063
  return null;
7060
- }, []), Sn = useCallback((e) => {
7064
+ }, []), En = useCallback((e) => {
7061
7065
  let t = [e.lngLat.lng, e.lngLat.lat], n = {
7062
7066
  x: e.point.x,
7063
7067
  y: e.point.y
7064
- }, r = An.current;
7068
+ }, r = Pn.current;
7065
7069
  if (r === "picker") {
7066
7070
  let e = {
7067
7071
  lng: t[0],
7068
7072
  lat: t[1]
7069
7073
  };
7070
- nt(e), jt(t), jn.current?.(e);
7074
+ rt(e), jt(t), Fn.current?.(e), un.current && (un.current(e), un.current = null, Mt(), rt(null), on(dn.current));
7071
7075
  return;
7072
7076
  }
7073
7077
  if (_t.current) return;
7074
7078
  if (r === "edit") {
7075
- let e = Nn.current;
7079
+ let e = Ln.current;
7076
7080
  if (e === "rectangle") {
7077
- let e = Pn.current;
7078
- if (!e) st(t);
7081
+ let e = Rn.current;
7082
+ if (!e) ct(t);
7079
7083
  else {
7080
- let n = ct.current, r = applyEntityConfig({
7084
+ let n = G.current, r = applyEntityConfig({
7081
7085
  ...n,
7082
7086
  id: n?.id ?? Nt(),
7083
7087
  type: "rectangle",
@@ -7089,7 +7093,7 @@ const Mapbox = forwardRef((e, c) => {
7089
7093
  let e = new RectangleRenderer(i, r, O, k, M, P);
7090
7094
  z.current.set(r.id, e);
7091
7095
  }
7092
- Q.current.onRectangleAdd?.(r), st(null), ct.current = null, G.current && (G.current = !1, W(null), i && (i.getCanvas().style.cursor = ""));
7096
+ Q.current.onRectangleAdd?.(r), ct(null), G.current = null, W.current && (W.current = !1, U(null), i && (i.getCanvas().style.cursor = ""));
7093
7097
  }
7094
7098
  return;
7095
7099
  }
@@ -7110,7 +7114,7 @@ const Mapbox = forwardRef((e, c) => {
7110
7114
  let e = new CircleRenderer(a, i, O, k, M, N);
7111
7115
  z.current.set(i.id, e);
7112
7116
  }
7113
- Q.current.onCircleAdd?.(i), ut.current = null, K.current = null, G.current && (G.current = !1, W(null), a && (a.getCanvas().style.cursor = ""));
7117
+ Q.current.onCircleAdd?.(i), ut.current = null, K.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
7114
7118
  }
7115
7119
  return;
7116
7120
  }
@@ -7131,7 +7135,7 @@ const Mapbox = forwardRef((e, c) => {
7131
7135
  let e = new PolygonRenderer(r, n, O, k, M, P);
7132
7136
  z.current.set(n.id, e);
7133
7137
  }
7134
- Q.current.onPolygonAdd?.(n), dt.current = [], q.current = null, G.current && (G.current = !1, W(null), r && (r.getCanvas().style.cursor = ""));
7138
+ Q.current.onPolygonAdd?.(n), dt.current = [], q.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
7135
7139
  return;
7136
7140
  }
7137
7141
  }
@@ -7155,7 +7159,7 @@ const Mapbox = forwardRef((e, c) => {
7155
7159
  let e = new SquareRenderer(a, i, O, k, M, P);
7156
7160
  z.current.set(i.id, e);
7157
7161
  }
7158
- Q.current.onSquareAdd?.(i), pt.current = null, ft.current = null, G.current && (G.current = !1, W(null), a && (a.getCanvas().style.cursor = ""));
7162
+ Q.current.onSquareAdd?.(i), pt.current = null, ft.current = null, W.current && (W.current = !1, U(null), a && (a.getCanvas().style.cursor = ""));
7159
7163
  }
7160
7164
  return;
7161
7165
  }
@@ -7173,10 +7177,10 @@ const Mapbox = forwardRef((e, c) => {
7173
7177
  src: n.src,
7174
7178
  width: n.width
7175
7179
  };
7176
- Q.current.onMarkerAdd?.(e), U(null), W(null), Y(), lt.current = null, G.current = !1;
7180
+ Q.current.onMarkerAdd?.(e), H(null), U(null), Y(), lt.current = null, W.current = !1;
7177
7181
  return;
7178
7182
  }
7179
- let r = Mn.current;
7183
+ let r = In.current;
7180
7184
  if (r) {
7181
7185
  let e = {
7182
7186
  id: Nt(),
@@ -7186,7 +7190,7 @@ const Mapbox = forwardRef((e, c) => {
7186
7190
  src: r.icon,
7187
7191
  width: r.size || r.width || 32
7188
7192
  };
7189
- r.customData !== void 0 && (e.customData = r.customData), Q.current.onMarkerAdd?.(e), U(null), W(null), Y(), G.current = !1;
7193
+ r.customData !== void 0 && (e.customData = r.customData), Q.current.onMarkerAdd?.(e), H(null), U(null), Y(), W.current = !1;
7190
7194
  return;
7191
7195
  }
7192
7196
  }
@@ -7224,7 +7228,7 @@ const Mapbox = forwardRef((e, c) => {
7224
7228
  }
7225
7229
  }
7226
7230
  }
7227
- let i = Dn.current, a = On.current, o = kn.current, s = xn(e.originalEvent.target);
7231
+ let i = jn.current, a = Mn.current, o = Nn.current, s = Tn(e.originalEvent.target);
7228
7232
  if (s) {
7229
7233
  let e = i.find((e) => String(e.id) === s);
7230
7234
  if (e) {
@@ -7261,15 +7265,15 @@ const Mapbox = forwardRef((e, c) => {
7261
7265
  }, [
7262
7266
  L,
7263
7267
  Ne,
7264
- xn
7265
- ]), Cn = useCallback((e) => {
7268
+ Tn
7269
+ ]), Dn = useCallback((e) => {
7266
7270
  let t = [e.lngLat.lng, e.lngLat.lat];
7267
7271
  if (J.current) {
7268
7272
  let { entityId: e, activeHandle: n } = J.current;
7269
7273
  z.current.get(e)?.updateEditPreview?.(n, t);
7270
7274
  return;
7271
7275
  }
7272
- let n = Nn.current, r = Pn.current;
7276
+ let n = Ln.current, r = Rn.current;
7273
7277
  n === "rectangle" && r && Lt(r, t);
7274
7278
  let i = ut.current;
7275
7279
  n === "circle" && i && Ht(i.center, t);
@@ -7279,7 +7283,7 @@ const Mapbox = forwardRef((e, c) => {
7279
7283
  n === "square" && o && Zt(o.center, t);
7280
7284
  let s = ht.current;
7281
7285
  n === "polyline" && s.length > 0 && tn(s, t);
7282
- let c = Dn.current, l = kn.current;
7286
+ let c = jn.current, l = Nn.current;
7283
7287
  for (let [e, n] of z.current) if (n.isPointInEntity(t)) {
7284
7288
  let t = c.find((t) => t.id === e);
7285
7289
  if (!t?.popup) continue;
@@ -7307,8 +7311,12 @@ const Mapbox = forwardRef((e, c) => {
7307
7311
  Kt,
7308
7312
  Zt,
7309
7313
  tn
7310
- ]), wn = useCallback((e) => {
7311
- if (e.preventDefault(), _t.current) return;
7314
+ ]), On = useCallback((e) => {
7315
+ if (e.preventDefault(), un.current) {
7316
+ un.current(null), un.current = null, Mt(), rt(null), on(dn.current);
7317
+ return;
7318
+ }
7319
+ if (_t.current) return;
7312
7320
  if (bt.current.length > 0) {
7313
7321
  let t = [e.lngLat.lng, e.lngLat.lat];
7314
7322
  if (J.current) {
@@ -7327,16 +7335,16 @@ const Mapbox = forwardRef((e, c) => {
7327
7335
  }
7328
7336
  }
7329
7337
  }
7330
- if (An.current !== "edit") return;
7331
- if (Mn.current) {
7332
- U(null), W(null), Y();
7338
+ if (Pn.current !== "edit") return;
7339
+ if (In.current) {
7340
+ H(null), U(null), Y();
7333
7341
  return;
7334
7342
  }
7335
- let t = Nn.current;
7343
+ let t = Ln.current;
7336
7344
  if (t === "rectangle") {
7337
- if (Pn.current) st(null), Rt();
7345
+ if (Rn.current) ct(null), Rt();
7338
7346
  else {
7339
- W(null);
7347
+ U(null);
7340
7348
  let e = R.current;
7341
7349
  e && (e.getCanvas().style.cursor = "");
7342
7350
  }
@@ -7345,7 +7353,7 @@ const Mapbox = forwardRef((e, c) => {
7345
7353
  if (t === "circle") {
7346
7354
  if (ut.current) ut.current = null, Ut();
7347
7355
  else {
7348
- W(null);
7356
+ U(null);
7349
7357
  let e = R.current;
7350
7358
  e && (e.getCanvas().style.cursor = "");
7351
7359
  }
@@ -7366,10 +7374,10 @@ const Mapbox = forwardRef((e, c) => {
7366
7374
  let e = new PolygonRenderer(r, n, O, k, M, P);
7367
7375
  z.current.set(n.id, e);
7368
7376
  }
7369
- Q.current.onPolygonAdd?.(n), dt.current = [], q.current = null, G.current && (G.current = !1, W(null), r && (r.getCanvas().style.cursor = ""));
7377
+ Q.current.onPolygonAdd?.(n), dt.current = [], q.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
7370
7378
  } else if (e.length > 0) dt.current = [], qt();
7371
7379
  else {
7372
- W(null);
7380
+ U(null);
7373
7381
  let e = R.current;
7374
7382
  e && (e.getCanvas().style.cursor = "");
7375
7383
  }
@@ -7378,7 +7386,7 @@ const Mapbox = forwardRef((e, c) => {
7378
7386
  if (t === "square") {
7379
7387
  if (pt.current) pt.current = null, Qt();
7380
7388
  else {
7381
- W(null);
7389
+ U(null);
7382
7390
  let e = R.current;
7383
7391
  e && (e.getCanvas().style.cursor = "");
7384
7392
  }
@@ -7399,10 +7407,10 @@ const Mapbox = forwardRef((e, c) => {
7399
7407
  let e = new PolylineRenderer(r, n, O, k, P);
7400
7408
  z.current.set(n.id, e);
7401
7409
  }
7402
- Q.current.onPolylineAdd?.(n), ht.current = [], mt.current = null, G.current && (G.current = !1, W(null), r && (r.getCanvas().style.cursor = ""));
7410
+ Q.current.onPolylineAdd?.(n), ht.current = [], mt.current = null, W.current && (W.current = !1, U(null), r && (r.getCanvas().style.cursor = ""));
7403
7411
  } else if (e.length > 0) ht.current = [], nn();
7404
7412
  else {
7405
- W(null);
7413
+ U(null);
7406
7414
  let e = R.current;
7407
7415
  e && (e.getCanvas().style.cursor = "");
7408
7416
  }
@@ -7411,11 +7419,11 @@ const Mapbox = forwardRef((e, c) => {
7411
7419
  let n = [e.lngLat.lng, e.lngLat.lat], r = {
7412
7420
  x: e.point.x,
7413
7421
  y: e.point.y
7414
- }, i = Dn.current, a = xn(e.originalEvent.target);
7422
+ }, i = jn.current, a = Tn(e.originalEvent.target);
7415
7423
  if (a) {
7416
7424
  let e = i.find((e) => String(e.id) === a);
7417
7425
  if (e) {
7418
- Tn(e, r, n);
7426
+ kn(e, r, n);
7419
7427
  return;
7420
7428
  }
7421
7429
  }
@@ -7424,7 +7432,7 @@ const Mapbox = forwardRef((e, c) => {
7424
7432
  if (o && R.current?.getLayer(o) && R.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
7425
7433
  let e = i.find((e) => e.id === t);
7426
7434
  if (e) {
7427
- Tn(e, r, n);
7435
+ kn(e, r, n);
7428
7436
  return;
7429
7437
  }
7430
7438
  }
@@ -7432,19 +7440,19 @@ const Mapbox = forwardRef((e, c) => {
7432
7440
  for (let [e, t] of z.current) if (t.isPointInEntity(n)) {
7433
7441
  let t = i.find((t) => t.id === e);
7434
7442
  if (t) {
7435
- Tn(t, r, n);
7443
+ kn(t, r, n);
7436
7444
  return;
7437
7445
  }
7438
7446
  }
7439
7447
  }, [
7440
- xn,
7448
+ Tn,
7441
7449
  Y,
7442
7450
  Rt,
7443
7451
  Ut,
7444
7452
  qt,
7445
7453
  Qt,
7446
7454
  nn
7447
- ]), Tn = useCallback((e, t, n) => {
7455
+ ]), kn = useCallback((e, t, n) => {
7448
7456
  let r = Be.current?.getBoundingClientRect(), i = r ? {
7449
7457
  x: t.x + r.left,
7450
7458
  y: t.y + r.top
@@ -7469,7 +7477,7 @@ const Mapbox = forwardRef((e, c) => {
7469
7477
  }
7470
7478
  }]
7471
7479
  });
7472
- }, []), En = useCallback(() => {
7480
+ }, []), An = useCallback(() => {
7473
7481
  Ye(null);
7474
7482
  }, []);
7475
7483
  useEffect(() => {
@@ -7499,59 +7507,59 @@ const Mapbox = forwardRef((e, c) => {
7499
7507
  document.body.contains(e) && document.body.removeChild(e);
7500
7508
  };
7501
7509
  }, [L?.zIndex]);
7502
- let Dn = useRef(T);
7503
- Dn.current = T;
7504
- let On = useRef(Fe);
7505
- On.current = Fe;
7506
- let kn = useRef(Tt);
7507
- kn.current = Tt;
7508
- let An = useRef($e);
7509
- An.current = $e;
7510
- let jn = useRef(b);
7511
- jn.current = b;
7512
- let Mn = useRef(it);
7513
- Mn.current = it;
7514
- let Nn = useRef(at);
7515
- Nn.current = at;
7516
- let Pn = useRef(ot);
7517
- Pn.current = ot;
7510
+ let jn = useRef(T);
7511
+ jn.current = T;
7512
+ let Mn = useRef(Fe);
7513
+ Mn.current = Fe;
7514
+ let Nn = useRef(Tt);
7515
+ Nn.current = Tt;
7516
+ let Pn = useRef(et);
7517
+ Pn.current = et;
7518
+ let Fn = useRef(b);
7519
+ Fn.current = b;
7520
+ let In = useRef(at);
7521
+ In.current = at;
7522
+ let Ln = useRef(ot);
7523
+ Ln.current = ot;
7524
+ let Rn = useRef(st);
7525
+ Rn.current = st;
7518
7526
  let Q = useRef(v);
7519
7527
  Q.current = v;
7520
- let Fn = useRef(D);
7521
- Fn.current = D, useEffect(() => {
7528
+ let zn = useRef(D);
7529
+ zn.current = D, useEffect(() => {
7522
7530
  let e = (e) => {
7523
7531
  if (e.key === "Escape" && J.current) {
7524
7532
  z.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
7525
7533
  return;
7526
7534
  }
7527
- if (e.key === "Escape" && $e === "edit") {
7528
- if (it && (U(null), W(null), Y()), at === "rectangle") if (ot) st(null), Rt();
7535
+ if (e.key === "Escape" && et === "edit") {
7536
+ if (at && (H(null), U(null), Y()), ot === "rectangle") if (st) ct(null), Rt();
7529
7537
  else {
7530
- W(null);
7538
+ U(null);
7531
7539
  let e = R.current;
7532
7540
  e && (e.getCanvas().style.cursor = "");
7533
7541
  }
7534
- if (at === "circle") if (ut.current) ut.current = null, Ut();
7542
+ if (ot === "circle") if (ut.current) ut.current = null, Ut();
7535
7543
  else {
7536
- W(null);
7544
+ U(null);
7537
7545
  let e = R.current;
7538
7546
  e && (e.getCanvas().style.cursor = "");
7539
7547
  }
7540
- if (at === "polygon") if (dt.current.length > 0) dt.current = [], qt();
7548
+ if (ot === "polygon") if (dt.current.length > 0) dt.current = [], qt();
7541
7549
  else {
7542
- W(null);
7550
+ U(null);
7543
7551
  let e = R.current;
7544
7552
  e && (e.getCanvas().style.cursor = "");
7545
7553
  }
7546
- if (at === "square") if (pt.current) pt.current = null, Qt();
7554
+ if (ot === "square") if (pt.current) pt.current = null, Qt();
7547
7555
  else {
7548
- W(null);
7556
+ U(null);
7549
7557
  let e = R.current;
7550
7558
  e && (e.getCanvas().style.cursor = "");
7551
7559
  }
7552
- if (at === "polyline") if (ht.current.length > 0) ht.current = [], nn();
7560
+ if (ot === "polyline") if (ht.current.length > 0) ht.current = [], nn();
7553
7561
  else {
7554
- W(null);
7562
+ U(null);
7555
7563
  let e = R.current;
7556
7564
  e && (e.getCanvas().style.cursor = "");
7557
7565
  }
@@ -7561,10 +7569,10 @@ const Mapbox = forwardRef((e, c) => {
7561
7569
  document.removeEventListener("keydown", e);
7562
7570
  };
7563
7571
  }, [
7564
- $e,
7565
- it,
7572
+ et,
7566
7573
  at,
7567
7574
  ot,
7575
+ st,
7568
7576
  Y,
7569
7577
  Rt,
7570
7578
  Ut,
@@ -7575,7 +7583,7 @@ const Mapbox = forwardRef((e, c) => {
7575
7583
  let e = R.current;
7576
7584
  if (!e || !V) return;
7577
7585
  let t = V.entityId, n = V.config, r = () => {
7578
- let r = Dn.current.find((e) => e.id === t);
7586
+ let r = jn.current.find((e) => e.id === t);
7579
7587
  if (!r) {
7580
7588
  Dt();
7581
7589
  return;
@@ -7594,7 +7602,7 @@ const Mapbox = forwardRef((e, c) => {
7594
7602
  let n = Je.lngLat, r = () => {
7595
7603
  let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
7596
7604
  if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
7597
- En();
7605
+ An();
7598
7606
  return;
7599
7607
  }
7600
7608
  let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
@@ -7603,7 +7611,7 @@ const Mapbox = forwardRef((e, c) => {
7603
7611
  return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
7604
7612
  e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
7605
7613
  };
7606
- }, [Je?.lngLat, En]), useEffect(() => {
7614
+ }, [Je?.lngLat, An]), useEffect(() => {
7607
7615
  if (!Be.current) return;
7608
7616
  let e = {
7609
7617
  version: 8,
@@ -7644,9 +7652,9 @@ const Mapbox = forwardRef((e, c) => {
7644
7652
  }
7645
7653
  B.current.clear(), T.forEach((e) => {
7646
7654
  B.current.set(e.id, e);
7647
- }), bn(S), fn(), It(), zt(), Gt(), Yt(), en(), Qe(_), Pe?.(_);
7648
- }), _.on("click", Sn), _.on("mousemove", Cn), _.on("contextmenu", wn), () => {
7649
- _.off("click", Sn), _.off("mousemove", Cn), _.off("contextmenu", wn), pn(), Mt(), Y(), X(), Z(), _.remove(), R.current = null;
7655
+ }), wn(S), gn(), It(), zt(), Gt(), Yt(), en(), $e(_), Pe?.(_);
7656
+ }), _.on("click", En), _.on("mousemove", Dn), _.on("contextmenu", On), () => {
7657
+ _.off("click", En), _.off("mousemove", Dn), _.off("contextmenu", On), _n(), Mt(), Y(), X(), Z(), _.remove(), R.current = null;
7650
7658
  };
7651
7659
  }, []), useEffect(() => {
7652
7660
  if (R.current) {
@@ -7654,53 +7662,53 @@ const Mapbox = forwardRef((e, c) => {
7654
7662
  R.current.once("load", () => {
7655
7663
  B.current.clear(), T.forEach((e) => {
7656
7664
  B.current.set(e.id, e);
7657
- }), fn();
7665
+ }), gn();
7658
7666
  });
7659
7667
  return;
7660
7668
  }
7661
7669
  B.current.clear(), T.forEach((e) => {
7662
7670
  B.current.set(e.id, e);
7663
- }), fn();
7671
+ }), gn();
7664
7672
  }
7665
- }, [T, fn]), useEffect(() => {
7666
- !R.current || !R.current.isStyleLoaded() || (pn(), fn());
7673
+ }, [T, gn]), useEffect(() => {
7674
+ !R.current || !R.current.isStyleLoaded() || (_n(), gn());
7667
7675
  }, [
7668
7676
  O,
7669
7677
  k,
7670
7678
  M,
7671
7679
  N,
7672
7680
  P,
7673
- pn,
7674
- fn
7681
+ _n,
7682
+ gn
7675
7683
  ]), useEffect(() => {
7676
7684
  if (R.current) {
7677
7685
  if (!R.current.isStyleLoaded()) {
7678
7686
  R.current.once("load", () => {
7679
- bn(S);
7687
+ wn(S);
7680
7688
  });
7681
7689
  return;
7682
7690
  }
7683
- bn(S);
7684
- }
7685
- }, [S, bn]);
7686
- let In = useRef(void 0), Ln = useRef(!0), Rn = useRef(S);
7687
- Rn.current = S;
7688
- let zn = useRef(bn);
7689
- zn.current = bn;
7690
- let Bn = useRef(pn);
7691
- Bn.current = pn;
7692
- let Vn = useRef(fn);
7693
- Vn.current = fn;
7694
- let Hn = useRef(It);
7695
- Hn.current = It;
7696
- let Un = useRef(zt);
7697
- Un.current = zt;
7698
- let Wn = useRef(Gt);
7699
- Wn.current = Gt;
7700
- let Gn = useRef(Yt);
7701
- Gn.current = Yt;
7702
- let Kn = useRef(en);
7703
- Kn.current = en, useEffect(() => {
7691
+ wn(S);
7692
+ }
7693
+ }, [S, wn]);
7694
+ let Bn = useRef(void 0), Vn = useRef(!0), Hn = useRef(S);
7695
+ Hn.current = S;
7696
+ let Un = useRef(wn);
7697
+ Un.current = wn;
7698
+ let Wn = useRef(_n);
7699
+ Wn.current = _n;
7700
+ let Gn = useRef(gn);
7701
+ Gn.current = gn;
7702
+ let Kn = useRef(It);
7703
+ Kn.current = It;
7704
+ let qn = useRef(zt);
7705
+ qn.current = zt;
7706
+ let Jn = useRef(Gt);
7707
+ Jn.current = Gt;
7708
+ let Yn = useRef(Yt);
7709
+ Yn.current = Yt;
7710
+ let Xn = useRef(en);
7711
+ Xn.current = en, useEffect(() => {
7704
7712
  let e = R.current;
7705
7713
  if (!e) return;
7706
7714
  let t = p || {
@@ -7708,27 +7716,27 @@ const Mapbox = forwardRef((e, c) => {
7708
7716
  sources: {},
7709
7717
  layers: []
7710
7718
  };
7711
- if (Ln.current) {
7712
- Ln.current = !1, In.current = p;
7719
+ if (Vn.current) {
7720
+ Vn.current = !1, Bn.current = p;
7713
7721
  return;
7714
7722
  }
7715
- In.current !== p && (In.current = p, e.setStyle(t), e.once("style.load", () => {
7723
+ Bn.current !== p && (Bn.current = p, e.setStyle(t), e.once("style.load", () => {
7716
7724
  if (!e.getStyle().glyphs) {
7717
7725
  let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
7718
7726
  t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
7719
7727
  }
7720
- Ue.current.clear(), zn.current(Rn.current), Bn.current(), Vn.current(), Hn.current(), Un.current(), Wn.current(), Gn.current(), Kn.current();
7728
+ Ue.current.clear(), Un.current(Hn.current), Wn.current(), Gn.current(), Kn.current(), qn.current(), Jn.current(), Yn.current(), Xn.current();
7721
7729
  }));
7722
7730
  }, [p]), useEffect(() => {
7723
7731
  let e = new Set(E.map(String));
7724
7732
  for (let [t, n] of z.current) n.setSelected(e.has(String(t)));
7725
7733
  }, [E]);
7726
- let qn = useRef({});
7734
+ let Zn = useRef({});
7727
7735
  useEffect(() => {
7728
7736
  let e = R.current;
7729
7737
  if (!e) return;
7730
- let t = qn.current, n = l && (t.center?.[0] !== l[0] || t.center?.[1] !== l[1]), r = t.zoom !== u, i = t.pitch !== d, a = t.bearing !== f;
7731
- !n && !r && !i && !a || (qn.current = {
7738
+ let t = Zn.current, n = l && (t.center?.[0] !== l[0] || t.center?.[1] !== l[1]), r = t.zoom !== u, i = t.pitch !== d, a = t.bearing !== f;
7739
+ !n && !r && !i && !a || (Zn.current = {
7732
7740
  center: l,
7733
7741
  zoom: u,
7734
7742
  pitch: d,
@@ -7745,7 +7753,7 @@ const Mapbox = forwardRef((e, c) => {
7745
7753
  d,
7746
7754
  f
7747
7755
  ]);
7748
- let Jn = (() => Se === !1 ? null : Se === !0 ? { enabled: !0 } : Se)(), Yn = (() => F === !1 ? null : F === !0 ? { enabled: !0 } : F)(), Xn = (() => Ce === !1 ? null : Ce === !0 ? { enabled: !0 } : Ce)(), $ = (() => {
7756
+ let Qn = (() => Se === !1 ? null : Se === !0 ? { enabled: !0 } : Se)(), $n = (() => F === !1 ? null : F === !0 ? { enabled: !0 } : F)(), er = (() => Ce === !1 ? null : Ce === !0 ? { enabled: !0 } : Ce)(), $ = (() => {
7749
7757
  if (we === !1) return null;
7750
7758
  let e, t, n;
7751
7759
  if (S && S.length > 0) {
@@ -7770,7 +7778,7 @@ const Mapbox = forwardRef((e, c) => {
7770
7778
  sourceLayer: we.sourceLayer || t,
7771
7779
  classField: we.classField || n
7772
7780
  };
7773
- })(), Zn = (() => I ? I === !0 ? { enabled: !0 } : I : null)(), Qn = (() => Ee ? Ee === !0 ? { enabled: !0 } : Ee : null)(), $n = (() => Ae || null)(), er = useMemo(() => {
7781
+ })(), tr = (() => I ? I === !0 ? { enabled: !0 } : I : null)(), nr = (() => Ee ? Ee === !0 ? { enabled: !0 } : Ee : null)(), rr = (() => Ae || null)(), ir = useMemo(() => {
7774
7782
  let e = [];
7775
7783
  for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
7776
7784
  let n = R.current;
@@ -7780,16 +7788,16 @@ const Mapbox = forwardRef((e, c) => {
7780
7788
  }
7781
7789
  } else e.push(`base-layer-${t.id}`);
7782
7790
  return e;
7783
- }, [S, H]);
7791
+ }, [S, Qe]);
7784
7792
  return /* @__PURE__ */ jsxs("div", {
7785
- className: `comp-mapbox ${$e === "picker" ? "comp-mapbox--picker-mode" : ""} ${Re}`,
7793
+ className: `comp-mapbox ${et === "picker" ? "comp-mapbox--picker-mode" : ""} ${Re}`,
7786
7794
  style: ze,
7787
7795
  children: [
7788
7796
  /* @__PURE__ */ jsx("div", {
7789
7797
  ref: Be,
7790
7798
  className: "comp-mapbox__map"
7791
7799
  }),
7792
- $e === "picker" && y.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
7800
+ et === "picker" && y.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
7793
7801
  className: "comp-mapbox__crosshair",
7794
7802
  children: [/* @__PURE__ */ jsx("div", {
7795
7803
  className: "comp-mapbox__crosshair-h",
@@ -7800,13 +7808,13 @@ const Mapbox = forwardRef((e, c) => {
7800
7808
  })]
7801
7809
  }),
7802
7810
  /* @__PURE__ */ jsxs("div", {
7803
- className: `comp-mapbox__edit-controls${$e === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 || $n && $n.enabled !== !1 ? "" : " comp-mapbox__edit-controls--hidden"}`,
7811
+ className: `comp-mapbox__edit-controls${et === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 || rr && rr.enabled !== !1 ? "" : " comp-mapbox__edit-controls--hidden"}`,
7804
7812
  children: [
7805
- $e === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
7813
+ et === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
7806
7814
  markerTemplates: v.markerTemplates || [],
7807
- selectedTemplate: it,
7815
+ selectedTemplate: at,
7808
7816
  onTemplateSelect: rn,
7809
- drawMode: at,
7817
+ drawMode: ot,
7810
7818
  onDrawModeChange: an,
7811
7819
  showRectangleTool: v.showRectangleTool,
7812
7820
  showCircleTool: v.showCircleTool,
@@ -7816,7 +7824,7 @@ const Mapbox = forwardRef((e, c) => {
7816
7824
  }),
7817
7825
  /* @__PURE__ */ jsx(RoadHighlightControl, {
7818
7826
  ref: He,
7819
- map: H,
7827
+ map: Qe,
7820
7828
  showButton: !!($ && $.enabled !== !1),
7821
7829
  highlightWidth: $?.highlightWidth,
7822
7830
  defaultRoadTypes: $?.defaultRoadTypes,
@@ -7827,64 +7835,64 @@ const Mapbox = forwardRef((e, c) => {
7827
7835
  className: $?.className,
7828
7836
  style: $?.style
7829
7837
  }),
7830
- $n && $n.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
7838
+ rr && rr.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
7831
7839
  ref: Ve,
7832
- map: H,
7833
- pointCount: $n.pointCount,
7834
- showPointCountInput: $n.showPointCountInput,
7835
- visualType: $n.visualType,
7836
- onSelectFinished: $n.onSelectFinished
7840
+ map: Qe,
7841
+ pointCount: rr.pointCount,
7842
+ showPointCountInput: rr.showPointCountInput,
7843
+ visualType: rr.visualType,
7844
+ onSelectFinished: rr.onSelectFinished
7837
7845
  })
7838
7846
  ]
7839
7847
  }),
7840
- (Jn?.enabled !== !1 || Yn?.enabled !== !1 || Xn?.enabled !== !1 || Zn && Zn.enabled !== !1 || Qn && Qn.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
7848
+ (Qn?.enabled !== !1 || $n?.enabled !== !1 || er?.enabled !== !1 || tr && tr.enabled !== !1 || nr && nr.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
7841
7849
  className: "comp-mapbox__controls",
7842
7850
  children: [
7843
- Jn && Jn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
7844
- map: H,
7845
- precision: Jn.precision,
7846
- className: Jn.className,
7847
- style: Jn.style
7851
+ Qn && Qn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
7852
+ map: Qe,
7853
+ precision: Qn.precision,
7854
+ className: Qn.className,
7855
+ style: Qn.style
7848
7856
  }),
7849
- Yn && Yn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
7850
- map: H,
7851
- maxWidth: Yn.maxWidth,
7852
- unit: Yn.unit,
7853
- className: Yn.className,
7854
- style: Yn.style
7857
+ $n && $n.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
7858
+ map: Qe,
7859
+ maxWidth: $n.maxWidth,
7860
+ unit: $n.unit,
7861
+ className: $n.className,
7862
+ style: $n.style
7855
7863
  }),
7856
- Zn && Zn.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
7857
- map: H,
7864
+ tr && tr.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
7865
+ map: Qe,
7858
7866
  entityConfig: D,
7859
7867
  onDrawModeChange: (e) => {
7860
7868
  _t.current = e;
7861
7869
  },
7862
- className: Zn.className,
7863
- style: Zn.style
7870
+ className: tr.className,
7871
+ style: tr.style
7864
7872
  }),
7865
- Qn && Qn.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
7866
- map: H,
7873
+ nr && nr.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
7874
+ map: Qe,
7867
7875
  value: C,
7868
7876
  onChange: je,
7869
- rasterPaintLayerIds: er,
7870
- className: Qn.className,
7871
- style: Qn.style
7877
+ rasterPaintLayerIds: ir,
7878
+ className: nr.className,
7879
+ style: nr.style
7872
7880
  }),
7873
- Xn && Xn.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
7874
- map: H,
7881
+ er && er.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
7882
+ map: Qe,
7875
7883
  initialCenter: l,
7876
7884
  initialZoom: u,
7877
7885
  initialPitch: d,
7878
7886
  initialBearing: f,
7879
- duration: Xn.duration,
7880
- className: Xn.className,
7881
- style: Xn.style
7887
+ duration: er.duration,
7888
+ className: er.className,
7889
+ style: er.style
7882
7890
  })
7883
7891
  ]
7884
7892
  }),
7885
- !($n && $n.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
7893
+ !(rr && rr.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
7886
7894
  ref: Ve,
7887
- map: H,
7895
+ map: Qe,
7888
7896
  showButton: !1
7889
7897
  }),
7890
7898
  V && Ge.current && /* @__PURE__ */ jsx(EntityPopup, {
@@ -7895,7 +7903,7 @@ const Mapbox = forwardRef((e, c) => {
7895
7903
  }),
7896
7904
  Je && Xe.current && /* @__PURE__ */ jsx(ContextMenu, {
7897
7905
  menuState: Je,
7898
- onClose: En,
7906
+ onClose: An,
7899
7907
  portalContainer: Xe.current,
7900
7908
  menuRef: Ze
7901
7909
  })