bbl-mapbox-react 0.0.17 → 0.0.19

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
@@ -408,7 +408,34 @@ var BaseCanvasRenderer = class {
408
408
  destroy() {
409
409
  this.isDestroyed = !0, this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getSource(this.areaSourceId) && this.map.removeSource(this.areaSourceId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getSource(this.labelSourceId) && this.map.removeSource(this.labelSourceId), this.map.getLayer(this.layerId) && this.map.removeLayer(this.layerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId);
410
410
  }
411
- };
411
+ }, move_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775030039452'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='24839'%20data-spm-anchor-id='a313x.search_index.0.i1.78953a81FCkAe0'%20width='64'%20height='64'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cpath%20d='M512%20938.666667l-170.666667-170.666667h341.333334l-170.666667%20170.666667z%20m0-853.333334l170.666667%20170.666667H341.333333l170.666667-170.666667z%20m0%20512a85.333333%2085.333333%200%201%201%200-170.666666%2085.333333%2085.333333%200%200%201%200%20170.666666zM85.333333%20512l170.666667-170.666667v341.333334l-170.666667-170.666667z%20m853.333334%200l-170.666667%20170.666667V341.333333l170.666667%20170.666667z'%20fill='%23ffffff'%20p-id='24840'%3e%3c/path%3e%3c/svg%3e";
412
+ const MOVE_ICON_ID = "__edit-move-icon__";
413
+ var _moveIconLoading = !1;
414
+ function ensureMoveIcon(e) {
415
+ if (e.hasImage("__edit-move-icon__") || _moveIconLoading) return;
416
+ _moveIconLoading = !0;
417
+ let t = new Image();
418
+ t.onload = () => {
419
+ if (e.hasImage("__edit-move-icon__")) {
420
+ _moveIconLoading = !1;
421
+ return;
422
+ }
423
+ let n = document.createElement("canvas");
424
+ n.width = 28, n.height = 28;
425
+ let r = n.getContext("2d");
426
+ r.beginPath(), r.arc(28 / 2, 28 / 2, 28 / 2, 0, Math.PI * 2), r.fillStyle = "rgba(51,136,255,0.9)", r.fill();
427
+ let i = 28 * .6, a = (28 - i) / 2;
428
+ r.drawImage(t, a, a, i, i);
429
+ let o = r.getImageData(0, 0, 28, 28);
430
+ e.addImage(MOVE_ICON_ID, {
431
+ width: 28,
432
+ height: 28,
433
+ data: new Uint8Array(o.data.buffer)
434
+ }), _moveIconLoading = !1;
435
+ }, t.onerror = () => {
436
+ _moveIconLoading = !1;
437
+ }, t.src = move_default;
438
+ }
412
439
  function calculateRadarBounds(e, t) {
413
440
  let n = destinationPoint(e, t, 0), r = destinationPoint(e, t, 90), i = destinationPoint(e, t, 180), a = destinationPoint(e, t, 270)[0], o = r[0], s = i[1], c = n[1];
414
441
  return [
@@ -420,7 +447,7 @@ function calculateRadarBounds(e, t) {
420
447
  }
421
448
  var CanvasRadarRenderer = class extends BaseCanvasRenderer {
422
449
  constructor(e, t, n, r) {
423
- super(e, t, "radar", n, r), this.animationFrameId = null, this.currentRotation = t.initialRotation ?? RADAR_DEFAULTS.initialRotation;
450
+ super(e, t, "radar", n, r), this.animationFrameId = null, this.isEditing = !1, this.editSourceId = "", this.editMoveLayerId = "", this.editSourceId = `radar-edit-source-${t.id}`, this.editMoveLayerId = `radar-edit-move-${t.id}`, this.currentRotation = t.initialRotation ?? RADAR_DEFAULTS.initialRotation;
424
451
  let i = calculateRadarBounds(t.center, t.radius);
425
452
  this.init(i), t.isAnimating && this.startAnimation();
426
453
  }
@@ -480,7 +507,84 @@ var CanvasRadarRenderer = class extends BaseCanvasRenderer {
480
507
  return Math.sqrt((r * a) ** 2 + (i * 110540) ** 2) <= n;
481
508
  }
482
509
  destroy() {
483
- this.stopAnimation(), super.destroy();
510
+ this.removeEditLayers(), this.stopAnimation(), super.destroy();
511
+ }
512
+ getEditHandleGeoJSON(e) {
513
+ return {
514
+ type: "FeatureCollection",
515
+ features: [{
516
+ type: "Feature",
517
+ geometry: {
518
+ type: "Point",
519
+ coordinates: e ?? this.entity.center
520
+ },
521
+ properties: {
522
+ handleType: "move",
523
+ index: 0
524
+ }
525
+ }]
526
+ };
527
+ }
528
+ createEditLayers() {
529
+ this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
530
+ type: "geojson",
531
+ data: this.getEditHandleGeoJSON()
532
+ }), this.map.addLayer({
533
+ id: this.editMoveLayerId,
534
+ type: "symbol",
535
+ source: this.editSourceId,
536
+ filter: [
537
+ "==",
538
+ ["get", "handleType"],
539
+ "move"
540
+ ],
541
+ layout: {
542
+ "icon-image": MOVE_ICON_ID,
543
+ "icon-allow-overlap": !0,
544
+ "icon-ignore-placement": !0
545
+ }
546
+ }));
547
+ }
548
+ removeEditLayers() {
549
+ this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
550
+ }
551
+ refreshEditHandles(e) {
552
+ let t = this.map.getSource(this.editSourceId);
553
+ t && t.setData(this.getEditHandleGeoJSON(e));
554
+ }
555
+ setEditing(e) {
556
+ this.isEditing !== e && (this.isEditing = e, e ? this.createEditLayers() : this.removeEditLayers());
557
+ }
558
+ getEditHandleAt(e, t) {
559
+ if (!this.isEditing) return null;
560
+ let n = this.entity.center, r = this.map.project(e), i = this.map.project(n), a = r.x - i.x, o = r.y - i.y;
561
+ return a * a + o * o <= 144 ? {
562
+ type: "move",
563
+ index: 0,
564
+ position: n
565
+ } : null;
566
+ }
567
+ applyHandleMove(e, t) {
568
+ let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], a = {
569
+ ...this.entity,
570
+ center: i
571
+ };
572
+ this.entity = a;
573
+ let o = calculateRadarBounds(i, this.entity.radius);
574
+ return this.updateSourceCoordinates(o), this.updateLabel(), this.refreshEditHandles(), a;
575
+ }
576
+ updateEditPreview(e, t) {
577
+ let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], a = calculateRadarBounds(i, this.entity.radius);
578
+ this.updateSourceCoordinates(a);
579
+ let o = this.entity;
580
+ this.entity = {
581
+ ...this.entity,
582
+ center: i
583
+ }, this.updateLabel(), this.entity = o, this.refreshEditHandles(i);
584
+ }
585
+ cancelEditPreview() {
586
+ let e = calculateRadarBounds(this.entity.center, this.entity.radius);
587
+ this.updateSourceCoordinates(e), this.updateLabel(), this.refreshEditHandles();
484
588
  }
485
589
  };
486
590
  function calculateImageBounds(e, t, n) {
@@ -494,7 +598,7 @@ function calculateImageBounds(e, t, n) {
494
598
  }
495
599
  var CanvasImageRenderer = class extends BaseCanvasRenderer {
496
600
  constructor(e, t, n, r) {
497
- super(e, t, "image", n, r), this.loadedImage = null, this.imageLoaded = !1, this.currentSrc = "", this.imageAspectRatio = 1, this.loadImage(t.src, !0);
601
+ super(e, t, "image", n, r), this.loadedImage = null, this.imageLoaded = !1, this.currentSrc = "", this.imageAspectRatio = 1, this.isEditing = !1, this.editSourceId = "", this.editMoveLayerId = "", this.editSourceId = `image-edit-source-${t.id}`, this.editMoveLayerId = `image-edit-move-${t.id}`, this.loadImage(t.src, !0);
498
602
  }
499
603
  getSize() {
500
604
  let { width: e } = this.entity, t = e / this.imageAspectRatio;
@@ -600,9 +704,89 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
600
704
  let { center: t } = this.entity, [n, r] = this.getSize(), i = e[0] - t[0], a = e[1] - t[1], o = 111320 * Math.cos(t[1] * Math.PI / 180), s = Math.abs(i * o), c = Math.abs(a * 110540);
601
705
  return s <= n / 2 && c <= r / 2;
602
706
  }
707
+ getEditHandleGeoJSON(e) {
708
+ return {
709
+ type: "FeatureCollection",
710
+ features: [{
711
+ type: "Feature",
712
+ geometry: {
713
+ type: "Point",
714
+ coordinates: e ?? this.entity.center
715
+ },
716
+ properties: {
717
+ handleType: "move",
718
+ index: 0
719
+ }
720
+ }]
721
+ };
722
+ }
723
+ createEditLayers() {
724
+ this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
725
+ type: "geojson",
726
+ data: this.getEditHandleGeoJSON()
727
+ }), this.map.addLayer({
728
+ id: this.editMoveLayerId,
729
+ type: "symbol",
730
+ source: this.editSourceId,
731
+ filter: [
732
+ "==",
733
+ ["get", "handleType"],
734
+ "move"
735
+ ],
736
+ layout: {
737
+ "icon-image": MOVE_ICON_ID,
738
+ "icon-allow-overlap": !0,
739
+ "icon-ignore-placement": !0
740
+ }
741
+ }));
742
+ }
743
+ removeEditLayers() {
744
+ this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
745
+ }
746
+ refreshEditHandles(e) {
747
+ let t = this.map.getSource(this.editSourceId);
748
+ t && t.setData(this.getEditHandleGeoJSON(e));
749
+ }
750
+ setEditing(e) {
751
+ this.isEditing !== e && (this.isEditing = e, e ? this.createEditLayers() : this.removeEditLayers());
752
+ }
753
+ getEditHandleAt(e, t) {
754
+ if (!this.isEditing) return null;
755
+ let n = this.entity.center, r = this.map.project(e), i = this.map.project(n), a = r.x - i.x, o = r.y - i.y;
756
+ return a * a + o * o <= 144 ? {
757
+ type: "move",
758
+ index: 0,
759
+ position: n
760
+ } : null;
761
+ }
762
+ applyHandleMove(e, t) {
763
+ let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], a = {
764
+ ...this.entity,
765
+ center: i
766
+ };
767
+ this.entity = a;
768
+ let [o, s] = this.getSize(), c = calculateImageBounds(i, o, s);
769
+ return this.updateSourceCoordinates(c), this.updateLabel(), this.refreshEditHandles(), a;
770
+ }
771
+ updateEditPreview(e, t) {
772
+ let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], [a, o] = this.getSize(), s = calculateImageBounds(i, a, o);
773
+ this.updateSourceCoordinates(s);
774
+ let c = this.entity;
775
+ this.entity = {
776
+ ...this.entity,
777
+ center: i
778
+ }, this.updateLabel(), this.entity = c, this.refreshEditHandles(i);
779
+ }
780
+ cancelEditPreview() {
781
+ let [e, t] = this.getSize(), n = calculateImageBounds(this.entity.center, e, t);
782
+ this.updateSourceCoordinates(n), this.updateLabel(), this.refreshEditHandles();
783
+ }
784
+ destroy() {
785
+ this.removeEditLayers(), super.destroy();
786
+ }
603
787
  }, MarkerRenderer = class {
604
788
  constructor(e, t, n, r) {
605
- this.marker = null, this.markerElement = null, this.imageElement = null, this.labelElement = null, this.placeholderElement = null, this.isSelected = !1, this.imageAspectRatio = 1, this.imageLoaded = !1, this.destroyed = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.loadImageAndCreateMarker(t.src);
789
+ this.marker = null, this.markerElement = null, this.imageElement = null, this.labelElement = null, this.placeholderElement = null, this.isSelected = !1, this.imageAspectRatio = 1, this.imageLoaded = !1, this.destroyed = !1, this.isEditing = !1, this.moveIconElement = null, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.loadImageAndCreateMarker(t.src);
606
790
  }
607
791
  loadImageAndCreateMarker(e) {
608
792
  if (!e) {
@@ -674,7 +858,47 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
674
858
  (t.width !== e.width || t.rotation !== e.rotation || t.confidence !== e.confidence) && (this.imageElement.style.width = `${e.width}px`, this.imageElement.style.height = `${n}px`, this.imageElement.style.transform = `rotate(${r}deg)`, this.imageElement.style.opacity = `${i}`), t.name !== e.name && (e.name && !this.labelElement ? (this.labelElement = document.createElement("div"), this.labelElement.className = "mapbox-marker-label", this.labelElement.textContent = e.name, this.updateLabelStyle(), this.markerElement?.appendChild(this.labelElement), this.placeholderElement = document.createElement("div"), this.placeholderElement.className = "mapbox-marker-placeholder", this.placeholderElement.textContent = e.name, this.markerElement?.insertBefore(this.placeholderElement, this.markerElement.firstChild)) : !e.name && this.labelElement ? (this.labelElement.remove(), this.labelElement = null, this.placeholderElement?.remove(), this.placeholderElement = null) : this.labelElement && (this.labelElement.textContent = e.name || "", this.placeholderElement && (this.placeholderElement.textContent = e.name || ""))), t.confidence !== e.confidence && this.updateLabelStyle();
675
859
  }
676
860
  destroy() {
677
- this.destroyed = !0, this.marker &&= (this.marker.remove(), null), this.markerElement = null, this.imageElement = null, this.labelElement = null, this.placeholderElement = null;
861
+ this.removeMoveIcon(), this.destroyed = !0, this.marker &&= (this.marker.remove(), null), this.markerElement = null, this.imageElement = null, this.labelElement = null, this.placeholderElement = null;
862
+ }
863
+ createMoveIcon() {
864
+ if (this.moveIconElement || !this.markerElement) return;
865
+ let e = document.createElement("div");
866
+ e.className = "mapbox-marker-move-icon", e.style.cssText = "width:28px;height:28px;border-radius:50%;background:rgba(51,136,255,0.9);display:flex;align-items:center;justify-content:center;cursor:move;position:absolute;left:50%;bottom:0;transform:translate(-50%,100%);pointer-events:none;";
867
+ let t = document.createElement("img");
868
+ t.src = move_default, t.style.cssText = "width:60%;height:60%;", e.appendChild(t), this.markerElement.appendChild(e), this.moveIconElement = e;
869
+ }
870
+ removeMoveIcon() {
871
+ this.moveIconElement &&= (this.moveIconElement.remove(), null);
872
+ }
873
+ setEditing(e) {
874
+ this.isEditing !== e && (this.isEditing = e, e ? this.createMoveIcon() : this.removeMoveIcon());
875
+ }
876
+ getEditHandleAt(e, t) {
877
+ if (!this.isEditing) return null;
878
+ let n = this.map.project(e);
879
+ if (this.moveIconElement) {
880
+ let t = this.moveIconElement.getBoundingClientRect(), r = this.map.getContainer().getBoundingClientRect(), i = t.left + t.width / 2 - r.left, a = t.top + t.height / 2 - r.top, o = n.x - i, s = n.y - a;
881
+ if (o * o + s * s <= 256) return {
882
+ type: "move",
883
+ index: 0,
884
+ position: e
885
+ };
886
+ }
887
+ return null;
888
+ }
889
+ applyHandleMove(e, t) {
890
+ let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r], a = {
891
+ ...this.entity,
892
+ center: i
893
+ };
894
+ return this.entity = a, this.marker && this.marker.setLngLat(i), a;
895
+ }
896
+ updateEditPreview(e, t) {
897
+ let n = t[0] - e.position[0], r = t[1] - e.position[1], i = [this.entity.center[0] + n, this.entity.center[1] + r];
898
+ this.marker && this.marker.setLngLat(i);
899
+ }
900
+ cancelEditPreview() {
901
+ this.marker && this.marker.setLngLat(this.entity.center);
678
902
  }
679
903
  }, UnitRenderer = class extends MarkerRenderer {
680
904
  constructor(e, t, n, r) {
@@ -840,7 +1064,7 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
840
1064
  };
841
1065
  }
842
1066
  constructor(e, t, n, r, i, a) {
843
- this.isSelected = !1, this.initialized = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `polygon-source-${t.id}`, this.fillLayerId = `polygon-fill-${t.id}`, this.strokeLayerId = `polygon-stroke-${t.id}`, this.labelLayerId = `polygon-label-${t.id}`, this.areaLayerId = `polygon-area-${t.id}`, this.lengthLayerId = `polygon-length-${t.id}`, this.initLayers();
1067
+ this.isSelected = !1, this.initialized = !1, this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `polygon-source-${t.id}`, this.fillLayerId = `polygon-fill-${t.id}`, this.strokeLayerId = `polygon-stroke-${t.id}`, this.labelLayerId = `polygon-label-${t.id}`, this.areaLayerId = `polygon-area-${t.id}`, this.lengthLayerId = `polygon-length-${t.id}`, this.editSourceId = `polygon-edit-source-${t.id}`, this.editHandleLayerId = `polygon-edit-handles-${t.id}`, this.editMidpointLayerId = `polygon-edit-midpoints-${t.id}`, this.editMoveLayerId = `polygon-edit-move-${t.id}`, this.initLayers();
844
1068
  }
845
1069
  get nameStyle() {
846
1070
  return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
@@ -1162,8 +1386,201 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
1162
1386
  }
1163
1387
  (n.fillColor !== t.fillColor || n.fillOpacity !== t.fillOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.fillLayerId) && (this.map.setPaintProperty(this.fillLayerId, "fill-color", t.fillColor ?? e.DEFAULTS.fillColor), this.map.setPaintProperty(this.fillLayerId, "fill-opacity", (t.fillOpacity ?? e.DEFAULTS.fillOpacity) * i)), (n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.strokeLayerId) && (this.isSelected || this.map.setPaintProperty(this.strokeLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.strokeLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.strokeLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i)), n.confidence !== t.confidence && (this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i), this.map.getLayer(this.areaLayerId) && this.map.setPaintProperty(this.areaLayerId, "text-opacity", i), this.map.getLayer(this.lengthLayerId) && this.map.setPaintProperty(this.lengthLayerId, "text-opacity", i));
1164
1388
  }
1389
+ getEditHandleGeoJSON(e) {
1390
+ let t = e ?? this.entity.coordinates;
1391
+ if (!t || t.length < 3) return {
1392
+ type: "FeatureCollection",
1393
+ features: []
1394
+ };
1395
+ let n = [];
1396
+ for (let e = 0; e < t.length; e++) n.push({
1397
+ type: "Feature",
1398
+ geometry: {
1399
+ type: "Point",
1400
+ coordinates: t[e]
1401
+ },
1402
+ properties: {
1403
+ handleType: "vertex",
1404
+ index: e
1405
+ }
1406
+ });
1407
+ for (let e = 0; e < t.length; e++) {
1408
+ let r = t[e], i = t[(e + 1) % t.length];
1409
+ n.push({
1410
+ type: "Feature",
1411
+ geometry: {
1412
+ type: "Point",
1413
+ coordinates: [(r[0] + i[0]) / 2, (r[1] + i[1]) / 2]
1414
+ },
1415
+ properties: {
1416
+ handleType: "midpoint",
1417
+ index: e
1418
+ }
1419
+ });
1420
+ }
1421
+ let r = 0, i = 0;
1422
+ for (let e of t) r += e[0], i += e[1];
1423
+ return r /= t.length, i /= t.length, n.push({
1424
+ type: "Feature",
1425
+ geometry: {
1426
+ type: "Point",
1427
+ coordinates: [r, i]
1428
+ },
1429
+ properties: {
1430
+ handleType: "move",
1431
+ index: 0
1432
+ }
1433
+ }), {
1434
+ type: "FeatureCollection",
1435
+ features: n
1436
+ };
1437
+ }
1438
+ createEditLayers() {
1439
+ this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
1440
+ type: "geojson",
1441
+ data: this.getEditHandleGeoJSON()
1442
+ }), this.map.addLayer({
1443
+ id: this.editMidpointLayerId,
1444
+ type: "circle",
1445
+ source: this.editSourceId,
1446
+ filter: [
1447
+ "==",
1448
+ ["get", "handleType"],
1449
+ "midpoint"
1450
+ ],
1451
+ paint: {
1452
+ "circle-radius": 4,
1453
+ "circle-color": "#3388ff",
1454
+ "circle-opacity": .5,
1455
+ "circle-stroke-color": "#3388ff",
1456
+ "circle-stroke-width": 1
1457
+ }
1458
+ }), this.map.addLayer({
1459
+ id: this.editHandleLayerId,
1460
+ type: "circle",
1461
+ source: this.editSourceId,
1462
+ filter: [
1463
+ "==",
1464
+ ["get", "handleType"],
1465
+ "vertex"
1466
+ ],
1467
+ paint: {
1468
+ "circle-radius": 6,
1469
+ "circle-color": "#ffffff",
1470
+ "circle-stroke-color": "#3388ff",
1471
+ "circle-stroke-width": 2
1472
+ }
1473
+ }), this.map.addLayer({
1474
+ id: this.editMoveLayerId,
1475
+ type: "symbol",
1476
+ source: this.editSourceId,
1477
+ filter: [
1478
+ "==",
1479
+ ["get", "handleType"],
1480
+ "move"
1481
+ ],
1482
+ layout: {
1483
+ "icon-image": MOVE_ICON_ID,
1484
+ "icon-allow-overlap": !0,
1485
+ "icon-ignore-placement": !0
1486
+ }
1487
+ }));
1488
+ }
1489
+ removeEditLayers() {
1490
+ this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getLayer(this.editMidpointLayerId) && this.map.removeLayer(this.editMidpointLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
1491
+ }
1492
+ refreshEditHandles(e) {
1493
+ let t = this.map.getSource(this.editSourceId);
1494
+ t && t.setData(this.getEditHandleGeoJSON(e));
1495
+ }
1496
+ setEditing(e) {
1497
+ this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
1498
+ }
1499
+ getEditHandleAt(e, t) {
1500
+ if (!this.isEditing) return null;
1501
+ let n = this.entity.coordinates;
1502
+ if (!n || n.length < 3) return null;
1503
+ let r = this.map.project(e), i = 0, a = 0;
1504
+ for (let e of n) i += e[0], a += e[1];
1505
+ i /= n.length, a /= n.length;
1506
+ let o = this.map.project([i, a]), s = r.x - o.x, c = r.y - o.y;
1507
+ if (s * s + c * c <= 144) return {
1508
+ type: "move",
1509
+ index: 0,
1510
+ position: [i, a]
1511
+ };
1512
+ for (let e = 0; e < n.length; e++) {
1513
+ let t = this.map.project(n[e]), i = r.x - t.x, a = r.y - t.y;
1514
+ if (i * i + a * a <= 100) return {
1515
+ type: "vertex",
1516
+ index: e,
1517
+ position: n[e]
1518
+ };
1519
+ }
1520
+ for (let e = 0; e < n.length; e++) {
1521
+ let t = n[e], i = n[(e + 1) % n.length], a = [(t[0] + i[0]) / 2, (t[1] + i[1]) / 2], o = this.map.project(a), s = r.x - o.x, c = r.y - o.y;
1522
+ if (s * s + c * c <= 100) return {
1523
+ type: "midpoint",
1524
+ index: e,
1525
+ position: a
1526
+ };
1527
+ }
1528
+ return null;
1529
+ }
1530
+ offsetCoordinates(e, t, n) {
1531
+ let r = n[0] - t[0], i = n[1] - t[1];
1532
+ return e.map((e) => [e[0] + r, e[1] + i]);
1533
+ }
1534
+ applyHandleMove(e, t) {
1535
+ let n;
1536
+ e.type === "move" ? n = this.offsetCoordinates(this.entity.coordinates, e.position, t) : (n = [...this.entity.coordinates], n[e.index] = t);
1537
+ let r = {
1538
+ ...this.entity,
1539
+ coordinates: n
1540
+ };
1541
+ this.entity = r;
1542
+ let i = this.map.getSource(this.sourceId);
1543
+ return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
1544
+ }
1545
+ updateEditPreview(e, t) {
1546
+ let n;
1547
+ e.type === "move" ? n = this.offsetCoordinates(this.entity.coordinates, e.position, t) : (n = [...this.entity.coordinates], n[e.index] = t);
1548
+ let r = this.entity;
1549
+ this.entity = {
1550
+ ...this.entity,
1551
+ coordinates: n
1552
+ };
1553
+ let i = this.map.getSource(this.sourceId);
1554
+ i && i.setData(this.getGeoJSON()), this.entity = r, this.refreshEditHandles(n);
1555
+ }
1556
+ cancelEditPreview() {
1557
+ let e = this.map.getSource(this.sourceId);
1558
+ e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
1559
+ }
1560
+ deleteVertex(e) {
1561
+ let t = this.entity.coordinates;
1562
+ if (!t || t.length <= 3) return null;
1563
+ let n = t.filter((t, n) => n !== e), r = {
1564
+ ...this.entity,
1565
+ coordinates: n
1566
+ };
1567
+ this.entity = r;
1568
+ let i = this.map.getSource(this.sourceId);
1569
+ return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
1570
+ }
1571
+ addVertex(e, t) {
1572
+ let n = [...this.entity.coordinates];
1573
+ n.splice(e + 1, 0, t);
1574
+ let r = {
1575
+ ...this.entity,
1576
+ coordinates: n
1577
+ };
1578
+ this.entity = r;
1579
+ let i = this.map.getSource(this.sourceId);
1580
+ return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
1581
+ }
1165
1582
  destroy() {
1166
- this.initialized &&= (this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
1583
+ this.initialized &&= (this.removeEditLayers(), this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
1167
1584
  }
1168
1585
  }, PolylineRenderer = class e {
1169
1586
  static {
@@ -1176,7 +1593,7 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
1176
1593
  };
1177
1594
  }
1178
1595
  constructor(e, t, n, r, i) {
1179
- this.isSelected = !1, this.initialized = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalLengthConfig = i, this.sourceId = `polyline-source-${t.id}`, this.lineLayerId = `polyline-stroke-${t.id}`, this.labelLayerId = `polyline-label-${t.id}`, this.lengthLayerId = `polyline-length-${t.id}`, this.initLayers();
1596
+ this.isSelected = !1, this.initialized = !1, this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalLengthConfig = i, this.sourceId = `polyline-source-${t.id}`, this.lineLayerId = `polyline-stroke-${t.id}`, this.labelLayerId = `polyline-label-${t.id}`, this.lengthLayerId = `polyline-length-${t.id}`, this.editSourceId = `polyline-edit-source-${t.id}`, this.editHandleLayerId = `polyline-edit-handles-${t.id}`, this.editMidpointLayerId = `polyline-edit-midpoints-${t.id}`, this.editMoveLayerId = `polyline-edit-move-${t.id}`, this.initLayers();
1180
1597
  }
1181
1598
  get nameStyle() {
1182
1599
  return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
@@ -1423,8 +1840,201 @@ var CanvasImageRenderer = class extends BaseCanvasRenderer {
1423
1840
  }
1424
1841
  (n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence || n.dashArray !== t.dashArray) && this.map.getLayer(this.lineLayerId) && (this.isSelected || this.map.setPaintProperty(this.lineLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.lineLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.lineLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i), t.dashArray && this.map.setPaintProperty(this.lineLayerId, "line-dasharray", t.dashArray)), (n.lineCap !== t.lineCap || n.lineJoin !== t.lineJoin) && this.map.getLayer(this.lineLayerId) && (this.map.setLayoutProperty(this.lineLayerId, "line-cap", t.lineCap ?? e.DEFAULTS.lineCap), this.map.setLayoutProperty(this.lineLayerId, "line-join", t.lineJoin ?? e.DEFAULTS.lineJoin)), n.confidence !== t.confidence && this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i), n.confidence !== t.confidence && this.map.getLayer(this.lengthLayerId) && this.map.setPaintProperty(this.lengthLayerId, "text-opacity", i);
1425
1842
  }
1843
+ getEditHandleGeoJSON(e) {
1844
+ let t = e ?? this.entity.coordinates;
1845
+ if (!t || t.length < 2) return {
1846
+ type: "FeatureCollection",
1847
+ features: []
1848
+ };
1849
+ let n = [];
1850
+ for (let e = 0; e < t.length; e++) n.push({
1851
+ type: "Feature",
1852
+ geometry: {
1853
+ type: "Point",
1854
+ coordinates: t[e]
1855
+ },
1856
+ properties: {
1857
+ handleType: "vertex",
1858
+ index: e
1859
+ }
1860
+ });
1861
+ for (let e = 0; e < t.length - 1; e++) {
1862
+ let r = t[e], i = t[e + 1];
1863
+ n.push({
1864
+ type: "Feature",
1865
+ geometry: {
1866
+ type: "Point",
1867
+ coordinates: [(r[0] + i[0]) / 2, (r[1] + i[1]) / 2]
1868
+ },
1869
+ properties: {
1870
+ handleType: "midpoint",
1871
+ index: e
1872
+ }
1873
+ });
1874
+ }
1875
+ let r = 0, i = 0;
1876
+ for (let e of t) r += e[0], i += e[1];
1877
+ return r /= t.length, i /= t.length, n.push({
1878
+ type: "Feature",
1879
+ geometry: {
1880
+ type: "Point",
1881
+ coordinates: [r, i]
1882
+ },
1883
+ properties: {
1884
+ handleType: "move",
1885
+ index: 0
1886
+ }
1887
+ }), {
1888
+ type: "FeatureCollection",
1889
+ features: n
1890
+ };
1891
+ }
1892
+ createEditLayers() {
1893
+ this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
1894
+ type: "geojson",
1895
+ data: this.getEditHandleGeoJSON()
1896
+ }), this.map.addLayer({
1897
+ id: this.editMidpointLayerId,
1898
+ type: "circle",
1899
+ source: this.editSourceId,
1900
+ filter: [
1901
+ "==",
1902
+ ["get", "handleType"],
1903
+ "midpoint"
1904
+ ],
1905
+ paint: {
1906
+ "circle-radius": 4,
1907
+ "circle-color": "#3388ff",
1908
+ "circle-opacity": .5,
1909
+ "circle-stroke-color": "#3388ff",
1910
+ "circle-stroke-width": 1
1911
+ }
1912
+ }), this.map.addLayer({
1913
+ id: this.editHandleLayerId,
1914
+ type: "circle",
1915
+ source: this.editSourceId,
1916
+ filter: [
1917
+ "==",
1918
+ ["get", "handleType"],
1919
+ "vertex"
1920
+ ],
1921
+ paint: {
1922
+ "circle-radius": 6,
1923
+ "circle-color": "#ffffff",
1924
+ "circle-stroke-color": "#3388ff",
1925
+ "circle-stroke-width": 2
1926
+ }
1927
+ }), this.map.addLayer({
1928
+ id: this.editMoveLayerId,
1929
+ type: "symbol",
1930
+ source: this.editSourceId,
1931
+ filter: [
1932
+ "==",
1933
+ ["get", "handleType"],
1934
+ "move"
1935
+ ],
1936
+ layout: {
1937
+ "icon-image": MOVE_ICON_ID,
1938
+ "icon-allow-overlap": !0,
1939
+ "icon-ignore-placement": !0
1940
+ }
1941
+ }));
1942
+ }
1943
+ removeEditLayers() {
1944
+ this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getLayer(this.editMidpointLayerId) && this.map.removeLayer(this.editMidpointLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
1945
+ }
1946
+ refreshEditHandles(e) {
1947
+ let t = this.map.getSource(this.editSourceId);
1948
+ t && t.setData(this.getEditHandleGeoJSON(e));
1949
+ }
1950
+ setEditing(e) {
1951
+ this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
1952
+ }
1953
+ getEditHandleAt(e, t) {
1954
+ if (!this.isEditing) return null;
1955
+ let n = this.entity.coordinates;
1956
+ if (!n || n.length < 2) return null;
1957
+ let r = this.map.project(e), i = 0, a = 0;
1958
+ for (let e of n) i += e[0], a += e[1];
1959
+ i /= n.length, a /= n.length;
1960
+ let o = this.map.project([i, a]), s = r.x - o.x, c = r.y - o.y;
1961
+ if (s * s + c * c <= 144) return {
1962
+ type: "move",
1963
+ index: 0,
1964
+ position: [i, a]
1965
+ };
1966
+ for (let e = 0; e < n.length; e++) {
1967
+ let t = this.map.project(n[e]), i = r.x - t.x, a = r.y - t.y;
1968
+ if (i * i + a * a <= 100) return {
1969
+ type: "vertex",
1970
+ index: e,
1971
+ position: n[e]
1972
+ };
1973
+ }
1974
+ for (let e = 0; e < n.length - 1; e++) {
1975
+ let t = n[e], i = n[e + 1], a = [(t[0] + i[0]) / 2, (t[1] + i[1]) / 2], o = this.map.project(a), s = r.x - o.x, c = r.y - o.y;
1976
+ if (s * s + c * c <= 100) return {
1977
+ type: "midpoint",
1978
+ index: e,
1979
+ position: a
1980
+ };
1981
+ }
1982
+ return null;
1983
+ }
1984
+ offsetCoordinates(e, t, n) {
1985
+ let r = n[0] - t[0], i = n[1] - t[1];
1986
+ return e.map((e) => [e[0] + r, e[1] + i]);
1987
+ }
1988
+ applyHandleMove(e, t) {
1989
+ let n;
1990
+ e.type === "move" ? n = this.offsetCoordinates(this.entity.coordinates, e.position, t) : (n = [...this.entity.coordinates], n[e.index] = t);
1991
+ let r = {
1992
+ ...this.entity,
1993
+ coordinates: n
1994
+ };
1995
+ this.entity = r;
1996
+ let i = this.map.getSource(this.sourceId);
1997
+ return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
1998
+ }
1999
+ updateEditPreview(e, t) {
2000
+ let n;
2001
+ e.type === "move" ? n = this.offsetCoordinates(this.entity.coordinates, e.position, t) : (n = [...this.entity.coordinates], n[e.index] = t);
2002
+ let r = this.entity;
2003
+ this.entity = {
2004
+ ...this.entity,
2005
+ coordinates: n
2006
+ };
2007
+ let i = this.map.getSource(this.sourceId);
2008
+ i && i.setData(this.getGeoJSON()), this.entity = r, this.refreshEditHandles(n);
2009
+ }
2010
+ cancelEditPreview() {
2011
+ let e = this.map.getSource(this.sourceId);
2012
+ e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
2013
+ }
2014
+ deleteVertex(e) {
2015
+ let t = this.entity.coordinates;
2016
+ if (!t || t.length <= 2) return null;
2017
+ let n = t.filter((t, n) => n !== e), r = {
2018
+ ...this.entity,
2019
+ coordinates: n
2020
+ };
2021
+ this.entity = r;
2022
+ let i = this.map.getSource(this.sourceId);
2023
+ return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
2024
+ }
2025
+ addVertex(e, t) {
2026
+ let n = [...this.entity.coordinates];
2027
+ n.splice(e + 1, 0, t);
2028
+ let r = {
2029
+ ...this.entity,
2030
+ coordinates: n
2031
+ };
2032
+ this.entity = r;
2033
+ let i = this.map.getSource(this.sourceId);
2034
+ return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
2035
+ }
1426
2036
  destroy() {
1427
- this.initialized &&= (this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.lineLayerId) && this.map.removeLayer(this.lineLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
2037
+ this.initialized &&= (this.removeEditLayers(), this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.lineLayerId) && this.map.removeLayer(this.lineLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
1428
2038
  }
1429
2039
  };
1430
2040
  function createCirclePolygon$1(e, t, n = 64) {
@@ -1452,7 +2062,7 @@ var CircleRenderer = class e {
1452
2062
  };
1453
2063
  }
1454
2064
  constructor(e, t, n, r, i, a) {
1455
- this.isSelected = !1, this.initialized = !1, this.gradientLayerIds = [], this.gradientSourceIds = [], this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalCircleConfig = a, this.sourceId = `circle-source-${t.id}`, this.fillLayerId = `circle-fill-${t.id}`, this.strokeLayerId = `circle-stroke-${t.id}`, this.centerPointLayerId = `circle-center-${t.id}`, this.labelLayerId = `circle-label-${t.id}`, this.areaLayerId = `circle-area-${t.id}`, this.radiusLineLayerId = `circle-radius-line-${t.id}`, this.radiusLabelLayerId = `circle-radius-label-${t.id}`, this.initLayers();
2065
+ this.isSelected = !1, this.initialized = !1, this.gradientLayerIds = [], this.gradientSourceIds = [], this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalCircleConfig = a, this.sourceId = `circle-source-${t.id}`, this.fillLayerId = `circle-fill-${t.id}`, this.strokeLayerId = `circle-stroke-${t.id}`, this.centerPointLayerId = `circle-center-${t.id}`, this.labelLayerId = `circle-label-${t.id}`, this.areaLayerId = `circle-area-${t.id}`, this.radiusLineLayerId = `circle-radius-line-${t.id}`, this.radiusLabelLayerId = `circle-radius-label-${t.id}`, this.editSourceId = `circle-edit-source-${t.id}`, this.editHandleLayerId = `circle-edit-handles-${t.id}`, this.editMoveLayerId = `circle-edit-move-${t.id}`, this.initLayers();
1456
2066
  }
1457
2067
  get nameStyle() {
1458
2068
  return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
@@ -1872,9 +2482,146 @@ var CircleRenderer = class e {
1872
2482
  this.map.getLayer(this.gradientLayerIds[n]) && (this.map.setPaintProperty(this.gradientLayerIds[n], "fill-color", `rgb(${i.r}, ${i.g}, ${i.b})`), this.map.setPaintProperty(this.gradientLayerIds[n], "fill-opacity", a));
1873
2483
  }
1874
2484
  }
2485
+ static {
2486
+ this.EDGE_BEARINGS = [
2487
+ 0,
2488
+ 90,
2489
+ 180,
2490
+ 270
2491
+ ];
2492
+ }
2493
+ getEditHandlePositions(t, n) {
2494
+ let r = t ?? this.entity.center, i = n ?? this.entity.radius, a = [];
2495
+ for (let t = 0; t < e.EDGE_BEARINGS.length; t++) a.push({
2496
+ type: "edge",
2497
+ index: t,
2498
+ position: destinationPoint(r, i, e.EDGE_BEARINGS[t])
2499
+ });
2500
+ return a.push({
2501
+ type: "move",
2502
+ index: 0,
2503
+ position: r
2504
+ }), a;
2505
+ }
2506
+ getEditHandleGeoJSON(e, t) {
2507
+ return {
2508
+ type: "FeatureCollection",
2509
+ features: this.getEditHandlePositions(e, t).map((e) => ({
2510
+ type: "Feature",
2511
+ geometry: {
2512
+ type: "Point",
2513
+ coordinates: e.position
2514
+ },
2515
+ properties: {
2516
+ handleType: e.type,
2517
+ index: e.index
2518
+ }
2519
+ }))
2520
+ };
2521
+ }
2522
+ createEditLayers() {
2523
+ this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
2524
+ type: "geojson",
2525
+ data: this.getEditHandleGeoJSON()
2526
+ }), this.map.addLayer({
2527
+ id: this.editHandleLayerId,
2528
+ type: "circle",
2529
+ source: this.editSourceId,
2530
+ filter: [
2531
+ "==",
2532
+ ["get", "handleType"],
2533
+ "edge"
2534
+ ],
2535
+ paint: {
2536
+ "circle-radius": 6,
2537
+ "circle-color": "#ffffff",
2538
+ "circle-stroke-color": "#3388ff",
2539
+ "circle-stroke-width": 2
2540
+ }
2541
+ }), this.map.addLayer({
2542
+ id: this.editMoveLayerId,
2543
+ type: "symbol",
2544
+ source: this.editSourceId,
2545
+ filter: [
2546
+ "==",
2547
+ ["get", "handleType"],
2548
+ "move"
2549
+ ],
2550
+ layout: {
2551
+ "icon-image": MOVE_ICON_ID,
2552
+ "icon-allow-overlap": !0,
2553
+ "icon-ignore-placement": !0
2554
+ }
2555
+ }));
2556
+ }
2557
+ removeEditLayers() {
2558
+ this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
2559
+ }
2560
+ refreshEditHandles(e, t) {
2561
+ let n = this.map.getSource(this.editSourceId);
2562
+ n && n.setData(this.getEditHandleGeoJSON(e, t));
2563
+ }
2564
+ setEditing(e) {
2565
+ this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
2566
+ }
2567
+ getEditHandleAt(e, t) {
2568
+ if (!this.isEditing) return null;
2569
+ let n = this.map.project(e), r = this.getEditHandlePositions(), i = r.find((e) => e.type === "move");
2570
+ if (i) {
2571
+ let e = this.map.project(i.position), t = n.x - e.x, r = n.y - e.y;
2572
+ if (t * t + r * r <= 144) return {
2573
+ type: "move",
2574
+ index: i.index,
2575
+ position: i.position
2576
+ };
2577
+ }
2578
+ for (let e of r) {
2579
+ if (e.type === "move") continue;
2580
+ let t = this.map.project(e.position), r = n.x - t.x, i = n.y - t.y;
2581
+ if (r * r + i * i <= 100) return {
2582
+ type: e.type,
2583
+ index: e.index,
2584
+ position: e.position
2585
+ };
2586
+ }
2587
+ return null;
2588
+ }
2589
+ applyHandleMove(e, t) {
2590
+ let n;
2591
+ if (e.type === "move") n = {
2592
+ ...this.entity,
2593
+ center: t
2594
+ };
2595
+ else {
2596
+ let e = this.calculateDistance(this.entity.center, t);
2597
+ n = {
2598
+ ...this.entity,
2599
+ radius: e
2600
+ };
2601
+ }
2602
+ this.entity = n;
2603
+ let r = this.map.getSource(this.sourceId);
2604
+ return r && r.setData(this.getGeoJSON()), this.refreshEditHandles(), n;
2605
+ }
2606
+ updateEditPreview(e, t) {
2607
+ let n, r;
2608
+ e.type === "move" ? (n = t, r = this.entity.radius) : (n = this.entity.center, r = this.calculateDistance(this.entity.center, t));
2609
+ let i = this.entity;
2610
+ this.entity = {
2611
+ ...this.entity,
2612
+ center: n,
2613
+ radius: r
2614
+ };
2615
+ let a = this.map.getSource(this.sourceId);
2616
+ a && a.setData(this.getGeoJSON()), this.entity = i, this.refreshEditHandles(n, r);
2617
+ }
2618
+ cancelEditPreview() {
2619
+ let e = this.map.getSource(this.sourceId);
2620
+ e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
2621
+ }
1875
2622
  destroy() {
1876
2623
  if (this.initialized) {
1877
- this.map.getLayer(this.radiusLabelLayerId) && this.map.removeLayer(this.radiusLabelLayerId), this.map.getLayer(this.radiusLineLayerId) && this.map.removeLayer(this.radiusLineLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.centerPointLayerId) && this.map.removeLayer(this.centerPointLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId);
2624
+ this.removeEditLayers(), this.map.getLayer(this.radiusLabelLayerId) && this.map.removeLayer(this.radiusLabelLayerId), this.map.getLayer(this.radiusLineLayerId) && this.map.removeLayer(this.radiusLineLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.centerPointLayerId) && this.map.removeLayer(this.centerPointLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId);
1878
2625
  for (let e of this.gradientLayerIds) this.map.getLayer(e) && this.map.removeLayer(e);
1879
2626
  for (let e of this.gradientSourceIds) this.map.getSource(e) && this.map.removeSource(e);
1880
2627
  this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), this.initialized = !1;
@@ -1901,9 +2648,17 @@ function calculateCircleBounds(e, t) {
1901
2648
  [a, s]
1902
2649
  ];
1903
2650
  }
1904
- var CanvasCircleRenderer = class extends BaseCanvasRenderer {
2651
+ var CanvasCircleRenderer = class e extends BaseCanvasRenderer {
2652
+ static {
2653
+ this.EDGE_BEARINGS = [
2654
+ 0,
2655
+ 90,
2656
+ 180,
2657
+ 270
2658
+ ];
2659
+ }
1905
2660
  constructor(e, t, n, r, i, a) {
1906
- super(e, t, "canvas-circle", n, r, i), this.animationFrameId = null, this.animationTime = 0, this.pulsePhase = 0, this.globalCircleConfig = a, this.radiusSourceId = `canvas-circle-radius-source-${String(t.id)}`, this.radiusLineLayerId = `canvas-circle-radius-line-${String(t.id)}`, this.radiusLabelLayerId = `canvas-circle-radius-label-${String(t.id)}`;
2661
+ super(e, t, "canvas-circle", n, r, i), this.animationFrameId = null, this.animationTime = 0, this.pulsePhase = 0, this.isEditing = !1, this.editSourceId = "", this.editHandleLayerId = "", this.editMoveLayerId = "", this.globalCircleConfig = a, this.radiusSourceId = `canvas-circle-radius-source-${String(t.id)}`, this.radiusLineLayerId = `canvas-circle-radius-line-${String(t.id)}`, this.radiusLabelLayerId = `canvas-circle-radius-label-${String(t.id)}`, this.editSourceId = `canvas-circle-edit-source-${String(t.id)}`, this.editHandleLayerId = `canvas-circle-edit-handles-${String(t.id)}`, this.editMoveLayerId = `canvas-circle-edit-move-${String(t.id)}`;
1907
2662
  let o = calculateCircleBounds(t.center, t.radius);
1908
2663
  this.init(o), this.initRadiusLayer(), t.isAnimating && this.startAnimation();
1909
2664
  }
@@ -2117,7 +2872,141 @@ var CanvasCircleRenderer = class extends BaseCanvasRenderer {
2117
2872
  return Math.sqrt((r * a) ** 2 + (i * 110540) ** 2) <= n;
2118
2873
  }
2119
2874
  destroy() {
2120
- this.stopAnimation(), this.map.getLayer(this.radiusLabelLayerId) && this.map.removeLayer(this.radiusLabelLayerId), this.map.getLayer(this.radiusLineLayerId) && this.map.removeLayer(this.radiusLineLayerId), this.map.getSource(this.radiusSourceId) && this.map.removeSource(this.radiusSourceId), super.destroy();
2875
+ this.removeEditLayers(), this.stopAnimation(), this.map.getLayer(this.radiusLabelLayerId) && this.map.removeLayer(this.radiusLabelLayerId), this.map.getLayer(this.radiusLineLayerId) && this.map.removeLayer(this.radiusLineLayerId), this.map.getSource(this.radiusSourceId) && this.map.removeSource(this.radiusSourceId), super.destroy();
2876
+ }
2877
+ getEditHandlePositions(t, n) {
2878
+ let r = t ?? this.entity.center, i = n ?? this.entity.radius, a = [];
2879
+ for (let t = 0; t < e.EDGE_BEARINGS.length; t++) a.push({
2880
+ type: "edge",
2881
+ index: t,
2882
+ position: destinationPoint(r, i, e.EDGE_BEARINGS[t])
2883
+ });
2884
+ return a.push({
2885
+ type: "move",
2886
+ index: 0,
2887
+ position: r
2888
+ }), a;
2889
+ }
2890
+ getEditHandleGeoJSON(e, t) {
2891
+ return {
2892
+ type: "FeatureCollection",
2893
+ features: this.getEditHandlePositions(e, t).map((e) => ({
2894
+ type: "Feature",
2895
+ geometry: {
2896
+ type: "Point",
2897
+ coordinates: e.position
2898
+ },
2899
+ properties: {
2900
+ handleType: e.type,
2901
+ index: e.index
2902
+ }
2903
+ }))
2904
+ };
2905
+ }
2906
+ createEditLayers() {
2907
+ this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
2908
+ type: "geojson",
2909
+ data: this.getEditHandleGeoJSON()
2910
+ }), this.map.addLayer({
2911
+ id: this.editHandleLayerId,
2912
+ type: "circle",
2913
+ source: this.editSourceId,
2914
+ filter: [
2915
+ "==",
2916
+ ["get", "handleType"],
2917
+ "edge"
2918
+ ],
2919
+ paint: {
2920
+ "circle-radius": 6,
2921
+ "circle-color": "#ffffff",
2922
+ "circle-stroke-color": "#3388ff",
2923
+ "circle-stroke-width": 2
2924
+ }
2925
+ }), this.map.addLayer({
2926
+ id: this.editMoveLayerId,
2927
+ type: "symbol",
2928
+ source: this.editSourceId,
2929
+ filter: [
2930
+ "==",
2931
+ ["get", "handleType"],
2932
+ "move"
2933
+ ],
2934
+ layout: {
2935
+ "icon-image": MOVE_ICON_ID,
2936
+ "icon-allow-overlap": !0,
2937
+ "icon-ignore-placement": !0
2938
+ }
2939
+ }));
2940
+ }
2941
+ removeEditLayers() {
2942
+ this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
2943
+ }
2944
+ refreshEditHandles(e, t) {
2945
+ let n = this.map.getSource(this.editSourceId);
2946
+ n && n.setData(this.getEditHandleGeoJSON(e, t));
2947
+ }
2948
+ setEditing(e) {
2949
+ this.isEditing !== e && (this.isEditing = e, e ? this.createEditLayers() : this.removeEditLayers());
2950
+ }
2951
+ getEditHandleAt(e, t) {
2952
+ if (!this.isEditing) return null;
2953
+ let n = this.map.project(e), r = this.getEditHandlePositions(), i = r.find((e) => e.type === "move");
2954
+ if (i) {
2955
+ let e = this.map.project(i.position), t = n.x - e.x, r = n.y - e.y;
2956
+ if (t * t + r * r <= 144) return {
2957
+ type: "move",
2958
+ index: i.index,
2959
+ position: i.position
2960
+ };
2961
+ }
2962
+ for (let e of r) {
2963
+ if (e.type === "move") continue;
2964
+ let t = this.map.project(e.position), r = n.x - t.x, i = n.y - t.y;
2965
+ if (r * r + i * i <= 100) return {
2966
+ type: e.type,
2967
+ index: e.index,
2968
+ position: e.position
2969
+ };
2970
+ }
2971
+ return null;
2972
+ }
2973
+ applyHandleMove(e, t) {
2974
+ let n;
2975
+ if (e.type === "move") {
2976
+ let r = t[0] - e.position[0], i = t[1] - e.position[1], a = [this.entity.center[0] + r, this.entity.center[1] + i];
2977
+ n = {
2978
+ ...this.entity,
2979
+ center: a
2980
+ };
2981
+ } else {
2982
+ let e = distance(this.entity.center, t);
2983
+ n = {
2984
+ ...this.entity,
2985
+ radius: e
2986
+ };
2987
+ }
2988
+ this.entity = n;
2989
+ let r = calculateCircleBounds(n.center, n.radius);
2990
+ return this.updateSourceCoordinates(r), this.updateLabel(), this.updateAreaLabel(), this.updateRadiusLayer(), this.refreshEditHandles(), n;
2991
+ }
2992
+ updateEditPreview(e, t) {
2993
+ let n, r;
2994
+ if (e.type === "move") {
2995
+ let i = t[0] - e.position[0], a = t[1] - e.position[1];
2996
+ n = [this.entity.center[0] + i, this.entity.center[1] + a], r = this.entity.radius;
2997
+ } else n = this.entity.center, r = distance(this.entity.center, t);
2998
+ let i = calculateCircleBounds(n, r);
2999
+ this.updateSourceCoordinates(i);
3000
+ let a = this.entity;
3001
+ this.entity = {
3002
+ ...this.entity,
3003
+ center: n,
3004
+ radius: r
3005
+ }, this.updateLabel(), this.entity = a, this.refreshEditHandles(n, r);
3006
+ }
3007
+ cancelEditPreview() {
3008
+ let e = calculateCircleBounds(this.entity.center, this.entity.radius);
3009
+ this.updateSourceCoordinates(e), this.updateLabel(), this.refreshEditHandles();
2121
3010
  }
2122
3011
  };
2123
3012
  function createSquareCoordinates(e, t) {
@@ -2141,7 +3030,7 @@ var SquareRenderer = class e {
2141
3030
  };
2142
3031
  }
2143
3032
  constructor(e, t, n, r, i, a) {
2144
- this.isSelected = !1, this.initialized = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `square-source-${t.id}`, this.fillLayerId = `square-fill-${t.id}`, this.strokeLayerId = `square-stroke-${t.id}`, this.labelLayerId = `square-label-${t.id}`, this.areaLayerId = `square-area-${t.id}`, this.lengthLayerId = `square-length-${t.id}`, this.initLayers();
3033
+ this.isSelected = !1, this.initialized = !1, this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `square-source-${t.id}`, this.fillLayerId = `square-fill-${t.id}`, this.strokeLayerId = `square-stroke-${t.id}`, this.labelLayerId = `square-label-${t.id}`, this.areaLayerId = `square-area-${t.id}`, this.lengthLayerId = `square-length-${t.id}`, this.editSourceId = `square-edit-source-${t.id}`, this.editHandleLayerId = `square-edit-handles-${t.id}`, this.editMoveLayerId = `square-edit-move-${t.id}`, this.initLayers();
2145
3034
  }
2146
3035
  get nameStyle() {
2147
3036
  return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
@@ -2440,8 +3329,142 @@ var SquareRenderer = class e {
2440
3329
  }
2441
3330
  (n.fillColor !== t.fillColor || n.fillOpacity !== t.fillOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.fillLayerId) && (this.map.setPaintProperty(this.fillLayerId, "fill-color", t.fillColor ?? e.DEFAULTS.fillColor), this.map.setPaintProperty(this.fillLayerId, "fill-opacity", (t.fillOpacity ?? e.DEFAULTS.fillOpacity) * i)), (n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.strokeLayerId) && (this.isSelected || this.map.setPaintProperty(this.strokeLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.strokeLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.strokeLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i)), n.confidence !== t.confidence && (this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i), this.map.getLayer(this.areaLayerId) && this.map.setPaintProperty(this.areaLayerId, "text-opacity", i), this.map.getLayer(this.lengthLayerId) && this.map.setPaintProperty(this.lengthLayerId, "text-opacity", i));
2442
3331
  }
3332
+ getCorners(e, t) {
3333
+ return createSquareCoordinates(e ?? this.entity.center, t ?? this.entity.length).slice(0, 4);
3334
+ }
3335
+ getEditHandleGeoJSON(e, t) {
3336
+ let n = this.getCorners(e, t).map((e, t) => ({
3337
+ type: "Feature",
3338
+ geometry: {
3339
+ type: "Point",
3340
+ coordinates: e
3341
+ },
3342
+ properties: {
3343
+ handleType: "vertex",
3344
+ index: t
3345
+ }
3346
+ })), r = e ?? this.entity.center;
3347
+ return n.push({
3348
+ type: "Feature",
3349
+ geometry: {
3350
+ type: "Point",
3351
+ coordinates: r
3352
+ },
3353
+ properties: {
3354
+ handleType: "move",
3355
+ index: 0
3356
+ }
3357
+ }), {
3358
+ type: "FeatureCollection",
3359
+ features: n
3360
+ };
3361
+ }
3362
+ createEditLayers() {
3363
+ this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
3364
+ type: "geojson",
3365
+ data: this.getEditHandleGeoJSON()
3366
+ }), this.map.addLayer({
3367
+ id: this.editHandleLayerId,
3368
+ type: "circle",
3369
+ source: this.editSourceId,
3370
+ filter: [
3371
+ "==",
3372
+ ["get", "handleType"],
3373
+ "vertex"
3374
+ ],
3375
+ paint: {
3376
+ "circle-radius": 6,
3377
+ "circle-color": "#ffffff",
3378
+ "circle-stroke-color": "#3388ff",
3379
+ "circle-stroke-width": 2
3380
+ }
3381
+ }), this.map.addLayer({
3382
+ id: this.editMoveLayerId,
3383
+ type: "symbol",
3384
+ source: this.editSourceId,
3385
+ filter: [
3386
+ "==",
3387
+ ["get", "handleType"],
3388
+ "move"
3389
+ ],
3390
+ layout: {
3391
+ "icon-image": MOVE_ICON_ID,
3392
+ "icon-allow-overlap": !0,
3393
+ "icon-ignore-placement": !0
3394
+ }
3395
+ }));
3396
+ }
3397
+ removeEditLayers() {
3398
+ this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
3399
+ }
3400
+ refreshEditHandles(e, t) {
3401
+ let n = this.map.getSource(this.editSourceId);
3402
+ n && n.setData(this.getEditHandleGeoJSON(e, t));
3403
+ }
3404
+ setEditing(e) {
3405
+ this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
3406
+ }
3407
+ getEditHandleAt(e, t) {
3408
+ if (!this.isEditing) return null;
3409
+ let n = this.getCorners(), r = this.map.project(e), i = this.entity.center, a = this.map.project(i), o = r.x - a.x, s = r.y - a.y;
3410
+ if (o * o + s * s <= 144) return {
3411
+ type: "move",
3412
+ index: 0,
3413
+ position: i
3414
+ };
3415
+ for (let e = 0; e < n.length; e++) {
3416
+ let t = this.map.project(n[e]), i = r.x - t.x, a = r.y - t.y;
3417
+ if (i * i + a * a <= 100) return {
3418
+ type: "vertex",
3419
+ index: e,
3420
+ position: n[e]
3421
+ };
3422
+ }
3423
+ return null;
3424
+ }
3425
+ computeNewLength(e) {
3426
+ return distance(this.entity.center, e) * Math.SQRT2;
3427
+ }
3428
+ applyHandleMove(e, t) {
3429
+ let n;
3430
+ if (e.type === "move") {
3431
+ let r = t[0] - e.position[0], i = t[1] - e.position[1], a = [this.entity.center[0] + r, this.entity.center[1] + i];
3432
+ n = {
3433
+ ...this.entity,
3434
+ center: a
3435
+ };
3436
+ } else {
3437
+ let e = this.computeNewLength(t);
3438
+ n = {
3439
+ ...this.entity,
3440
+ length: e
3441
+ };
3442
+ }
3443
+ this.entity = n;
3444
+ let r = this.map.getSource(this.sourceId);
3445
+ return r && r.setData(this.getGeoJSON()), this.refreshEditHandles(), n;
3446
+ }
3447
+ updateEditPreview(e, t) {
3448
+ let n, r;
3449
+ if (e.type === "move") {
3450
+ let i = t[0] - e.position[0], a = t[1] - e.position[1];
3451
+ n = [this.entity.center[0] + i, this.entity.center[1] + a], r = this.entity.length;
3452
+ } else n = this.entity.center, r = this.computeNewLength(t);
3453
+ let i = this.entity;
3454
+ this.entity = {
3455
+ ...this.entity,
3456
+ center: n,
3457
+ length: r
3458
+ };
3459
+ let a = this.map.getSource(this.sourceId);
3460
+ a && a.setData(this.getGeoJSON()), this.entity = i, this.refreshEditHandles(n, r);
3461
+ }
3462
+ cancelEditPreview() {
3463
+ let e = this.map.getSource(this.sourceId);
3464
+ e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
3465
+ }
2443
3466
  destroy() {
2444
- this.initialized &&= (this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
3467
+ this.initialized &&= (this.removeEditLayers(), this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
2445
3468
  }
2446
3469
  };
2447
3470
  function createRectangleCoordinates(e) {
@@ -2465,7 +3488,7 @@ var RectangleRenderer = class e {
2465
3488
  };
2466
3489
  }
2467
3490
  constructor(e, t, n, r, i, a) {
2468
- this.isSelected = !1, this.initialized = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `rectangle-source-${t.id}`, this.fillLayerId = `rectangle-fill-${t.id}`, this.strokeLayerId = `rectangle-stroke-${t.id}`, this.labelLayerId = `rectangle-label-${t.id}`, this.areaLayerId = `rectangle-area-${t.id}`, this.lengthLayerId = `rectangle-length-${t.id}`, this.initLayers();
3491
+ this.isSelected = !1, this.initialized = !1, this.isEditing = !1, this.map = e, this.entity = t, this.globalNameConfig = n, this.globalSelectNameConfig = r, this.globalAreaConfig = i, this.globalLengthConfig = a, this.sourceId = `rectangle-source-${t.id}`, this.fillLayerId = `rectangle-fill-${t.id}`, this.strokeLayerId = `rectangle-stroke-${t.id}`, this.labelLayerId = `rectangle-label-${t.id}`, this.areaLayerId = `rectangle-area-${t.id}`, this.lengthLayerId = `rectangle-length-${t.id}`, this.editSourceId = `rectangle-edit-source-${t.id}`, this.editHandleLayerId = `rectangle-edit-handles-${t.id}`, this.editMoveLayerId = `rectangle-edit-move-${t.id}`, this.initLayers();
2469
3492
  }
2470
3493
  get nameStyle() {
2471
3494
  return resolveNameConfig(this.entity.nameConfig, this.globalNameConfig, DEFAULT_NAME_CONFIG);
@@ -2777,8 +3800,135 @@ var RectangleRenderer = class e {
2777
3800
  }
2778
3801
  (n.fillColor !== t.fillColor || n.fillOpacity !== t.fillOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.fillLayerId) && (this.map.setPaintProperty(this.fillLayerId, "fill-color", t.fillColor ?? e.DEFAULTS.fillColor), this.map.setPaintProperty(this.fillLayerId, "fill-opacity", (t.fillOpacity ?? e.DEFAULTS.fillOpacity) * i)), (n.strokeColor !== t.strokeColor || n.strokeWidth !== t.strokeWidth || n.strokeOpacity !== t.strokeOpacity || n.confidence !== t.confidence) && this.map.getLayer(this.strokeLayerId) && (this.isSelected || this.map.setPaintProperty(this.strokeLayerId, "line-color", t.strokeColor ?? e.DEFAULTS.strokeColor), this.map.setPaintProperty(this.strokeLayerId, "line-width", t.strokeWidth ?? e.DEFAULTS.strokeWidth), this.map.setPaintProperty(this.strokeLayerId, "line-opacity", (t.strokeOpacity ?? e.DEFAULTS.strokeOpacity) * i)), n.confidence !== t.confidence && (this.map.getLayer(this.labelLayerId) && this.map.setPaintProperty(this.labelLayerId, "text-opacity", i), this.map.getLayer(this.areaLayerId) && this.map.setPaintProperty(this.areaLayerId, "text-opacity", i), this.map.getLayer(this.lengthLayerId) && this.map.setPaintProperty(this.lengthLayerId, "text-opacity", i));
2779
3802
  }
3803
+ getCorners(e) {
3804
+ return createRectangleCoordinates(e ?? this.entity.bounds).slice(0, 4);
3805
+ }
3806
+ getEditHandleGeoJSON(e) {
3807
+ let t = this.getCorners(e).map((e, t) => ({
3808
+ type: "Feature",
3809
+ geometry: {
3810
+ type: "Point",
3811
+ coordinates: e
3812
+ },
3813
+ properties: {
3814
+ handleType: "vertex",
3815
+ index: t
3816
+ }
3817
+ })), n = e ?? this.entity.bounds, r = (n[0][0] + n[1][0]) / 2, i = (n[0][1] + n[1][1]) / 2;
3818
+ return t.push({
3819
+ type: "Feature",
3820
+ geometry: {
3821
+ type: "Point",
3822
+ coordinates: [r, i]
3823
+ },
3824
+ properties: {
3825
+ handleType: "move",
3826
+ index: 0
3827
+ }
3828
+ }), {
3829
+ type: "FeatureCollection",
3830
+ features: t
3831
+ };
3832
+ }
3833
+ createEditLayers() {
3834
+ this.map.getSource(this.editSourceId) || (ensureMoveIcon(this.map), this.map.addSource(this.editSourceId, {
3835
+ type: "geojson",
3836
+ data: this.getEditHandleGeoJSON()
3837
+ }), this.map.addLayer({
3838
+ id: this.editHandleLayerId,
3839
+ type: "circle",
3840
+ source: this.editSourceId,
3841
+ filter: [
3842
+ "==",
3843
+ ["get", "handleType"],
3844
+ "vertex"
3845
+ ],
3846
+ paint: {
3847
+ "circle-radius": 6,
3848
+ "circle-color": "#ffffff",
3849
+ "circle-stroke-color": "#3388ff",
3850
+ "circle-stroke-width": 2
3851
+ }
3852
+ }), this.map.addLayer({
3853
+ id: this.editMoveLayerId,
3854
+ type: "symbol",
3855
+ source: this.editSourceId,
3856
+ filter: [
3857
+ "==",
3858
+ ["get", "handleType"],
3859
+ "move"
3860
+ ],
3861
+ layout: {
3862
+ "icon-image": MOVE_ICON_ID,
3863
+ "icon-allow-overlap": !0,
3864
+ "icon-ignore-placement": !0
3865
+ }
3866
+ }));
3867
+ }
3868
+ removeEditLayers() {
3869
+ this.map.getLayer(this.editMoveLayerId) && this.map.removeLayer(this.editMoveLayerId), this.map.getLayer(this.editHandleLayerId) && this.map.removeLayer(this.editHandleLayerId), this.map.getSource(this.editSourceId) && this.map.removeSource(this.editSourceId);
3870
+ }
3871
+ refreshEditHandles(e) {
3872
+ let t = this.map.getSource(this.editSourceId);
3873
+ t && t.setData(this.getEditHandleGeoJSON(e));
3874
+ }
3875
+ setEditing(e) {
3876
+ this.isEditing !== e && (this.isEditing = e, this.initialized && (e ? this.createEditLayers() : this.removeEditLayers()));
3877
+ }
3878
+ getEditHandleAt(e, t) {
3879
+ if (!this.isEditing) return null;
3880
+ let n = this.getCorners(), r = this.map.project(e), i = this.calculateRectangleCenter(), a = this.map.project(i), o = r.x - a.x, s = r.y - a.y;
3881
+ if (o * o + s * s <= 144) return {
3882
+ type: "move",
3883
+ index: 0,
3884
+ position: i
3885
+ };
3886
+ for (let e = 0; e < n.length; e++) {
3887
+ let t = this.map.project(n[e]), i = r.x - t.x, a = r.y - t.y;
3888
+ if (i * i + a * a <= 100) return {
3889
+ type: "vertex",
3890
+ index: e,
3891
+ position: n[e]
3892
+ };
3893
+ }
3894
+ return null;
3895
+ }
3896
+ computeNewBounds(e, t) {
3897
+ let n = this.getCorners(), r = (e + 2) % 4, i = n[r];
3898
+ return [[Math.min(t[0], i[0]), Math.min(t[1], i[1])], [Math.max(t[0], i[0]), Math.max(t[1], i[1])]];
3899
+ }
3900
+ offsetBounds(e, t, n) {
3901
+ let r = n[0] - t[0], i = n[1] - t[1];
3902
+ return [[e[0][0] + r, e[0][1] + i], [e[1][0] + r, e[1][1] + i]];
3903
+ }
3904
+ applyHandleMove(e, t) {
3905
+ let n;
3906
+ n = e.type === "move" ? this.offsetBounds(this.entity.bounds, e.position, t) : this.computeNewBounds(e.index, t);
3907
+ let r = {
3908
+ ...this.entity,
3909
+ bounds: n
3910
+ };
3911
+ this.entity = r;
3912
+ let i = this.map.getSource(this.sourceId);
3913
+ return i && i.setData(this.getGeoJSON()), this.refreshEditHandles(), r;
3914
+ }
3915
+ updateEditPreview(e, t) {
3916
+ let n;
3917
+ n = e.type === "move" ? this.offsetBounds(this.entity.bounds, e.position, t) : this.computeNewBounds(e.index, t);
3918
+ let r = this.entity;
3919
+ this.entity = {
3920
+ ...this.entity,
3921
+ bounds: n
3922
+ };
3923
+ let i = this.map.getSource(this.sourceId);
3924
+ i && i.setData(this.getGeoJSON()), this.entity = r, this.refreshEditHandles(n);
3925
+ }
3926
+ cancelEditPreview() {
3927
+ let e = this.map.getSource(this.sourceId);
3928
+ e && e.setData(this.getGeoJSON()), this.refreshEditHandles();
3929
+ }
2780
3930
  destroy() {
2781
- this.initialized &&= (this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
3931
+ this.initialized &&= (this.removeEditLayers(), this.map.getLayer(this.lengthLayerId) && this.map.removeLayer(this.lengthLayerId), this.map.getLayer(this.areaLayerId) && this.map.removeLayer(this.areaLayerId), this.map.getLayer(this.labelLayerId) && this.map.removeLayer(this.labelLayerId), this.map.getLayer(this.strokeLayerId) && this.map.removeLayer(this.strokeLayerId), this.map.getLayer(this.fillLayerId) && this.map.removeLayer(this.fillLayerId), this.map.getSource(this.sourceId) && this.map.removeSource(this.sourceId), !1);
2782
3932
  }
2783
3933
  };
2784
3934
  const EntityPopup = ({ popupState: e, onClose: r, portalContainer: i, popupRef: s }) => {
@@ -3017,9 +4167,9 @@ function detectVectorSource(e) {
3017
4167
  };
3018
4168
  return null;
3019
4169
  }
3020
- function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes: i = [], defaultMinWidth: c = 0, source: l, sourceLayer: u, className: d = "", style: f }) {
3021
- let [g, _] = useState(!1), [v, y] = useState(i), [b, x] = useState(!1), S = useRef(null), C = useRef(null), w = useRef(null), T = useCallback((e, t, n) => {
3022
- if (!e.isStyleLoaded()) return !1;
4170
+ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes: i = [], defaultMinWidth: c = 0, source: l, sourceLayer: u, classField: d = "class", className: f = "", style: g }) {
4171
+ let [_, v] = useState(!1), [y, b] = useState(i), [x, S] = useState(!1), C = useRef(!1), ve = useRef(null), w = useRef(null), T = useRef(null), E = useCallback((e, t, n) => {
4172
+ if (!e.isStyleLoaded() || !e.getSource(t)) return !1;
3023
4173
  let i = !0;
3024
4174
  return ROAD_TYPE_OPTIONS.forEach((a) => {
3025
4175
  let o = `${LAYER_ID_PREFIX}${a.class}`;
@@ -3031,7 +4181,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
3031
4181
  "source-layer": n,
3032
4182
  filter: [
3033
4183
  "==",
3034
- ["get", "class"],
4184
+ ["get", d],
3035
4185
  a.class
3036
4186
  ],
3037
4187
  paint: {
@@ -3045,7 +4195,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
3045
4195
  console.error(`Failed to add road highlight layer for ${a.class}:`, e), i = !1;
3046
4196
  }
3047
4197
  }), i;
3048
- }, [r]);
4198
+ }, [r, d]);
3049
4199
  useEffect(() => {
3050
4200
  if (!e) return;
3051
4201
  let t = () => {
@@ -3054,25 +4204,27 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
3054
4204
  let r = detectVectorSource(e);
3055
4205
  r && (console.log("Auto-detected vector source:", r), t ||= r.source, n ||= r.sourceLayer);
3056
4206
  }
3057
- t && n ? T(e, t, n) && x(!0) : console.warn("No vector source found for road highlighting");
4207
+ t && n ? E(e, t, n) && (C.current = !0, S(!0)) : console.warn("No vector source found for road highlighting");
3058
4208
  };
3059
4209
  e.isStyleLoaded() ? t() : e.once("load", t);
3060
4210
  let n = () => {
3061
4211
  e.isStyleLoaded() && t();
4212
+ }, r = () => {
4213
+ C.current || t();
3062
4214
  };
3063
- return e.on("styledata", n), () => {
3064
- e.off("styledata", n);
4215
+ return e.on("styledata", n), e.on("sourcedata", r), () => {
4216
+ e.off("styledata", n), e.off("sourcedata", r);
3065
4217
  };
3066
4218
  }, [
3067
4219
  e,
3068
4220
  l,
3069
4221
  u,
3070
- T
4222
+ E
3071
4223
  ]), useEffect(() => {
3072
- !e || !b || ROAD_TYPE_OPTIONS.forEach((t) => {
4224
+ !e || !x || ROAD_TYPE_OPTIONS.forEach((t) => {
3073
4225
  let n = `${LAYER_ID_PREFIX}${t.class}`;
3074
4226
  if (e.getLayer(n)) try {
3075
- let r = v.includes(t.class);
4227
+ let r = y.includes(t.class);
3076
4228
  e.setLayoutProperty(n, "visibility", r ? "visible" : "none");
3077
4229
  } catch (e) {
3078
4230
  console.error(`Failed to update layer ${n}:`, e);
@@ -3080,38 +4232,38 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
3080
4232
  });
3081
4233
  }, [
3082
4234
  e,
3083
- b,
3084
- v
4235
+ x,
4236
+ y
3085
4237
  ]), useEffect(() => {
3086
- if (!g) return;
4238
+ if (!_) return;
3087
4239
  let e = (e) => {
3088
- S.current && !S.current.contains(e.target) && C.current && !C.current.contains(e.target) && _(!1);
4240
+ ve.current && !ve.current.contains(e.target) && w.current && !w.current.contains(e.target) && v(!1);
3089
4241
  }, t = setTimeout(() => {
3090
4242
  document.addEventListener("mousedown", e);
3091
4243
  }, 0);
3092
4244
  return () => {
3093
4245
  clearTimeout(t), document.removeEventListener("mousedown", e);
3094
4246
  };
3095
- }, [g]), useEffect(() => () => {
4247
+ }, [_]), useEffect(() => () => {
3096
4248
  e && e.getStyle() && ROAD_TYPE_OPTIONS.forEach((t) => {
3097
4249
  let n = `${LAYER_ID_PREFIX}${t.class}`;
3098
4250
  if (e.getLayer(n)) try {
3099
4251
  e.removeLayer(n);
3100
4252
  } catch {}
3101
- }), w.current &&= (w.current.remove(), null);
4253
+ }), T.current &&= (T.current.remove(), null);
3102
4254
  }, [e]);
3103
- let E = useCallback((e) => ROAD_TYPE_OPTIONS.find((t) => t.class === e)?.label || e, []), D = useCallback((t) => {
3104
- if (!e || v.length === 0) {
3105
- w.current && w.current.remove(), e?.getCanvas().style.cursor && (e.getCanvas().style.cursor = "");
4255
+ let ye = useCallback((e) => ROAD_TYPE_OPTIONS.find((t) => t.class === e)?.label || e, []), be = useCallback((t) => {
4256
+ if (!e || y.length === 0) {
4257
+ T.current && T.current.remove(), e?.getCanvas().style.cursor && (e.getCanvas().style.cursor = "");
3106
4258
  return;
3107
4259
  }
3108
- let n = v.map((e) => `${LAYER_ID_PREFIX}${e}`), r = [[t.point.x - 10, t.point.y - 10], [t.point.x + 10, t.point.y + 10]], i = e.queryRenderedFeatures(r, { layers: n.filter((t) => e.getLayer(t)) });
4260
+ let n = y.map((e) => `${LAYER_ID_PREFIX}${e}`), r = [[t.point.x - 10, t.point.y - 10], [t.point.x + 10, t.point.y + 10]], i = e.queryRenderedFeatures(r, { layers: n.filter((t) => e.getLayer(t)) });
3109
4261
  if (i.length > 0) {
3110
4262
  let n = i[0].properties || {}, r = t.lngLat, a = n.name || n.name_en || n.name_local || "", o = n.class || "", c = n.type || "", l = n.structure || "", u = n.oneway, d = n.layer, f = n.iso_3166_1 || "", p = n.iso_3166_2 || "", m = (e) => !(e == null || e === "" || typeof e == "string" && e.toLowerCase() === "none"), h = [];
3111
4263
  m(o) && h.push(`
3112
4264
  <div class="road-highlight-popup__row">
3113
4265
  <span>道路类型:</span>
3114
- <span class="road-highlight-popup__value">${E(o)}</span>
4266
+ <span class="road-highlight-popup__value">${ye(o)}</span>
3115
4267
  </div>
3116
4268
  `), h.push(`
3117
4269
  <div class="road-highlight-popup__row">
@@ -3160,47 +4312,47 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
3160
4312
  <div class="road-highlight-popup__info">${h.join("")}</div>
3161
4313
  </div>
3162
4314
  `;
3163
- w.current ||= new mapboxgl.Popup({
4315
+ T.current ||= new mapboxgl.Popup({
3164
4316
  closeButton: !1,
3165
4317
  closeOnClick: !1,
3166
4318
  offset: 15,
3167
4319
  className: "road-highlight-popup"
3168
- }), w.current.setLngLat(r).setHTML(g).addTo(e), e.getCanvas().style.cursor = "pointer";
3169
- } else w.current && w.current.remove(), e.getCanvas().style.cursor = "";
4320
+ }), T.current.setLngLat(r).setHTML(g).addTo(e), e.getCanvas().style.cursor = "pointer";
4321
+ } else T.current && T.current.remove(), e.getCanvas().style.cursor = "";
3170
4322
  }, [
3171
4323
  e,
3172
- v,
3173
- E
4324
+ y,
4325
+ ye
3174
4326
  ]);
3175
4327
  useEffect(() => {
3176
- if (!(!e || !b)) return e.on("mousemove", D), () => {
3177
- e.off("mousemove", D), w.current && w.current.remove(), e.getCanvas().style.cursor = "";
4328
+ if (!(!e || !x)) return e.on("mousemove", be), () => {
4329
+ e.off("mousemove", be), T.current && T.current.remove(), e.getCanvas().style.cursor = "";
3178
4330
  };
3179
4331
  }, [
3180
4332
  e,
3181
- b,
3182
- D
4333
+ x,
4334
+ be
3183
4335
  ]);
3184
- let ve = (e, t) => {
3185
- y((n) => t ? [...n, e] : n.filter((t) => t !== e));
3186
- }, ye = (e) => {
3187
- y(e ? ROAD_TYPE_OPTIONS.map((e) => e.class) : []);
3188
- }, k = v.length > 0;
4336
+ let O = (e, t) => {
4337
+ b((n) => t ? [...n, e] : n.filter((t) => t !== e));
4338
+ }, xe = (e) => {
4339
+ b(e ? ROAD_TYPE_OPTIONS.map((e) => e.class) : []);
4340
+ }, Se = y.length > 0;
3189
4341
  return /* @__PURE__ */ jsxs("div", {
3190
- className: `mapbox-road-highlight-control ${d}`,
3191
- style: f,
4342
+ className: `mapbox-road-highlight-control ${f}`,
4343
+ style: g,
3192
4344
  children: [/* @__PURE__ */ jsxs("button", {
3193
- ref: C,
3194
- className: `mapbox-control-btn mapbox-road-highlight-control__btn ${k ? "mapbox-road-highlight-control__btn--active" : ""}`,
3195
- onClick: () => _(!g),
3196
- title: `路网高亮${v.length > 0 ? ` (已选 ${v.length})` : ""}`,
4345
+ ref: w,
4346
+ className: `mapbox-control-btn mapbox-road-highlight-control__btn ${Se ? "mapbox-road-highlight-control__btn--active" : ""}`,
4347
+ onClick: () => v(!_),
4348
+ title: `路网高亮${y.length > 0 ? ` (已选 ${y.length})` : ""}`,
3197
4349
  children: [/* @__PURE__ */ jsx("img", {
3198
4350
  src: road_default,
3199
4351
  alt: "road",
3200
4352
  className: "mapbox-road-highlight-control__btn-icon"
3201
- }), /* @__PURE__ */ jsxs("span", { children: ["路网", v.length > 0 ? ` (${v.length})` : ""] })]
3202
- }), g && /* @__PURE__ */ jsxs("div", {
3203
- ref: S,
4353
+ }), /* @__PURE__ */ jsxs("span", { children: ["路网", y.length > 0 ? ` (${y.length})` : ""] })]
4354
+ }), _ && /* @__PURE__ */ jsxs("div", {
4355
+ ref: ve,
3204
4356
  className: "mapbox-road-highlight-control__panel",
3205
4357
  children: [
3206
4358
  /* @__PURE__ */ jsxs("div", {
@@ -3209,9 +4361,9 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
3209
4361
  className: "mapbox-road-highlight-control__panel-title",
3210
4362
  children: "道路类型"
3211
4363
  }), /* @__PURE__ */ jsx(Checkbox, {
3212
- checked: v.length === ROAD_TYPE_OPTIONS.length,
3213
- indeterminate: v.length > 0 && v.length < ROAD_TYPE_OPTIONS.length,
3214
- onChange: ye,
4364
+ checked: y.length === ROAD_TYPE_OPTIONS.length,
4365
+ indeterminate: y.length > 0 && y.length < ROAD_TYPE_OPTIONS.length,
4366
+ onChange: xe,
3215
4367
  style: {
3216
4368
  "--color-text-1": "#fff",
3217
4369
  "--color-border-2": "rgba(255, 255, 255, 0.3)"
@@ -3228,11 +4380,11 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
3228
4380
  className: "mapbox-road-highlight-control__type-list",
3229
4381
  children: ROAD_TYPE_OPTIONS.map((e) => /* @__PURE__ */ jsxs("div", {
3230
4382
  className: "mapbox-road-highlight-control__type-item",
3231
- onClick: () => ve(e.class, !v.includes(e.class)),
4383
+ onClick: () => O(e.class, !y.includes(e.class)),
3232
4384
  children: [
3233
4385
  /* @__PURE__ */ jsx(Checkbox, {
3234
- checked: v.includes(e.class),
3235
- onChange: (t) => ve(e.class, t),
4386
+ checked: y.includes(e.class),
4387
+ onChange: (t) => O(e.class, t),
3236
4388
  onClick: (e) => e.stopPropagation(),
3237
4389
  style: {
3238
4390
  "--color-text-1": "#fff",
@@ -3257,7 +4409,7 @@ function RoadHighlightControl({ map: e, highlightWidth: r = 3, defaultRoadTypes:
3257
4409
  className: "mapbox-road-highlight-control__tip",
3258
4410
  children: "💡 选中道路类型后立即显示高亮"
3259
4411
  }),
3260
- !b && /* @__PURE__ */ jsx("div", {
4412
+ !x && /* @__PURE__ */ jsx("div", {
3261
4413
  className: "mapbox-road-highlight-control__warning",
3262
4414
  children: "⚠️ 正在初始化图层..."
3263
4415
  })
@@ -3505,61 +4657,65 @@ function clearAllPreviewSources(e) {
3505
4657
  "polyline-vertices-source"
3506
4658
  ]) clearPreviewSource(e, `${PREVIEW_PREFIX}${t}`);
3507
4659
  }
3508
- function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, className: s = "", style: c }) {
3509
- let [l, u] = useState(!1), [d, f] = useState(null), [g, _] = useState({
4660
+ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, onDrawModeChange: s, className: c = "", style: l }) {
4661
+ let [u, d] = useState(!1), [f, g] = useState(null), [_, v] = useState({
3510
4662
  showArea: !0,
3511
4663
  showLength: !0,
3512
4664
  showRadius: !0
3513
- }), v = r !== void 0, y = v ? {
4665
+ }), y = r !== void 0, b = y ? {
3514
4666
  showArea: r.showArea ?? !0,
3515
4667
  showLength: r.showLength ?? !0,
3516
4668
  showRadius: r.showRadius ?? !0
3517
- } : g, [b, x] = useState([]), S = useRef(/* @__PURE__ */ new Map()), C = useRef(0), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef(null), A = useRef([]), j = useRef([]), M = useRef(y);
3518
- M.current = y;
3519
- let N = useRef(d);
3520
- N.current = d;
3521
- let be = useCallback(() => `measure-${++C.current}`, []), xe = useRef(!1), Se = useCallback(() => {
3522
- !e || !e.isStyleLoaded() || (initAllPreviewLayers(e), xe.current = !0);
4669
+ } : _, [x, S] = useState([]), C = useRef(/* @__PURE__ */ new Map()), w = useRef(0), T = useRef(null), E = useRef(null), D = useRef(null), O = useRef(null), k = useRef(null), A = useRef([]), j = useRef([]), M = useRef(b);
4670
+ M.current = b;
4671
+ let we = useRef(f);
4672
+ we.current = f;
4673
+ let N = useCallback(() => `measure-${++w.current}`, []);
4674
+ useEffect(() => {
4675
+ s?.(f !== null);
4676
+ }, [f, s]);
4677
+ let Te = useRef(!1), Ee = useCallback(() => {
4678
+ !e || !e.isStyleLoaded() || (initAllPreviewLayers(e), Te.current = !0);
3523
4679
  }, [e]);
3524
4680
  useEffect(() => {
3525
4681
  if (!e) return;
3526
4682
  let t = () => {
3527
- initAllPreviewLayers(e), xe.current = !0;
4683
+ initAllPreviewLayers(e), Te.current = !0;
3528
4684
  };
3529
4685
  e.isStyleLoaded() ? t() : e.once("load", t);
3530
4686
  let n = () => {
3531
- xe.current = !1;
4687
+ Te.current = !1;
3532
4688
  };
3533
4689
  return e.on("style.load", n), () => {
3534
4690
  e.off("style.load", n);
3535
4691
  };
3536
4692
  }, [e]), useEffect(() => {
3537
4693
  let e = (e) => {
3538
- T.current && !T.current.contains(e.target) && E.current && !E.current.contains(e.target) && u(!1);
4694
+ T.current && !T.current.contains(e.target) && E.current && !E.current.contains(e.target) && d(!1);
3539
4695
  };
3540
4696
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
3541
4697
  }, []);
3542
- let Ce = useCallback((t) => {
4698
+ let P = useCallback((t) => {
3543
4699
  if (!e) return;
3544
4700
  let n = applyEntityConfig(t, M.current), r = null;
3545
4701
  if (n.type === "circle" ? r = new CircleRenderer(e, n) : n.type === "square" ? r = new SquareRenderer(e, n) : n.type === "rectangle" ? r = new RectangleRenderer(e, n) : n.type === "polygon" ? r = new PolygonRenderer(e, n) : n.type === "polyline" && (r = new PolylineRenderer(e, n)), r) {
3546
- S.current.set(n.id, r);
4702
+ C.current.set(n.id, r);
3547
4703
  let e = {
3548
4704
  entity: n,
3549
4705
  shapeLabel: SHAPE_LABELS[n.type] || n.type,
3550
4706
  area: computeEntityArea(n),
3551
4707
  lengthOrRadius: computeEntityLengthOrRadius(n)
3552
4708
  };
3553
- x((t) => [...t, e]);
3554
- }
3555
- }, [e]), we = useCallback((e) => {
3556
- let t = S.current.get(e);
3557
- t && (t.destroy(), S.current.delete(e)), x((t) => t.filter((t) => t.entity.id !== e));
3558
- }, []), Te = useCallback(() => {
3559
- S.current.forEach((e) => e.destroy()), S.current.clear(), x([]);
3560
- }, []), Ee = useCallback((t) => {
4709
+ S((t) => [...t, e]);
4710
+ }
4711
+ }, [e]), De = useCallback((e) => {
4712
+ let t = C.current.get(e);
4713
+ t && (t.destroy(), C.current.delete(e)), S((t) => t.filter((t) => t.entity.id !== e));
4714
+ }, []), Oe = useCallback(() => {
4715
+ C.current.forEach((e) => e.destroy()), C.current.clear(), S([]);
4716
+ }, []), ke = useCallback((t) => {
3561
4717
  if (!e) return;
3562
- let n = S.current.get(t);
4718
+ let n = C.current.get(t);
3563
4719
  if (!n) return;
3564
4720
  let r = n.getBounds();
3565
4721
  e.fitBounds(r, {
@@ -3567,21 +4723,21 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
3567
4723
  maxZoom: 18,
3568
4724
  duration: 1e3
3569
4725
  });
3570
- }, [e]), De = useCallback((e, t) => {
4726
+ }, [e]), Ae = useCallback((e, t) => {
3571
4727
  let n = {
3572
4728
  ...M.current,
3573
4729
  [e]: t
3574
4730
  };
3575
- v ? i?.({ ...n }) : _(n), x((t) => t.map((t) => {
4731
+ y ? i?.({ ...n }) : v(n), S((t) => t.map((t) => {
3576
4732
  let r = { ...t.entity };
3577
4733
  r[e] = void 0;
3578
- let i = applyEntityConfig(r, n), a = S.current.get(t.entity.id);
4734
+ let i = applyEntityConfig(r, n), a = C.current.get(t.entity.id);
3579
4735
  return a && a.update(i), {
3580
4736
  ...t,
3581
4737
  entity: i
3582
4738
  };
3583
4739
  }));
3584
- }, [v, i]), Oe = useCallback((t, n) => {
4740
+ }, [y, i]), je = useCallback((t, n) => {
3585
4741
  if (!e) return;
3586
4742
  let [r, i] = t, [a, o] = n, s = [
3587
4743
  [Math.min(r, a), Math.max(i, o)],
@@ -3631,7 +4787,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
3631
4787
  features: t
3632
4788
  });
3633
4789
  }
3634
- }, [e]), ke = useCallback((t, n) => {
4790
+ }, [e]), Me = useCallback((t, n) => {
3635
4791
  if (!e) return;
3636
4792
  let r = calculateDistance(t, n), i = createCirclePolygon(t, r), a = e.getSource(`${PREVIEW_PREFIX}circle-preview-source`);
3637
4793
  a && a.setData({
@@ -3678,7 +4834,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
3678
4834
  type: "FeatureCollection",
3679
4835
  features: c
3680
4836
  });
3681
- }, [e]), Ae = useCallback((t, n) => {
4837
+ }, [e]), Ne = useCallback((t, n) => {
3682
4838
  if (!e) return;
3683
4839
  let r = calculateDistance(t, n) * 2, i = createSquareCoords(t, r), a = e.getSource(`${PREVIEW_PREFIX}square-preview-source`);
3684
4840
  a && a.setData({
@@ -3715,7 +4871,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
3715
4871
  features: n
3716
4872
  });
3717
4873
  }
3718
- }, [e]), je = useCallback((t, n) => {
4874
+ }, [e]), Pe = useCallback((t, n) => {
3719
4875
  if (!e) return;
3720
4876
  let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polygon-preview-source`);
3721
4877
  i && (r.length >= 3 ? i.setData({
@@ -3792,7 +4948,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
3792
4948
  features: t
3793
4949
  });
3794
4950
  }
3795
- }, [e]), Me = useCallback((t, n) => {
4951
+ }, [e]), F = useCallback((t, n) => {
3796
4952
  if (!e) return;
3797
4953
  let r = [...t, n], i = e.getSource(`${PREVIEW_PREFIX}polyline-preview-source`);
3798
4954
  i && (r.length >= 2 ? i.setData({
@@ -3839,118 +4995,118 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
3839
4995
  }
3840
4996
  }, [e]);
3841
4997
  useEffect(() => {
3842
- if (!e || !d) return;
3843
- Se(), e.getCanvas().style.cursor = "crosshair";
4998
+ if (!e || !f) return;
4999
+ Ee(), e.getCanvas().style.cursor = "crosshair";
3844
5000
  let t = (t) => {
3845
- let n = [t.lngLat.lng, t.lngLat.lat], r = N.current;
5001
+ let n = [t.lngLat.lng, t.lngLat.lat], r = we.current;
3846
5002
  if (r === "rectangle") {
3847
5003
  let t = D.current;
3848
5004
  if (!t) D.current = n;
3849
5005
  else {
3850
5006
  let r = {
3851
- id: be(),
5007
+ id: N(),
3852
5008
  type: "rectangle",
3853
5009
  bounds: [t, n]
3854
5010
  };
3855
- Ce(r), D.current = null, clearAllPreviewSources(e), f(null);
5011
+ P(r), D.current = null, clearAllPreviewSources(e), g(null);
3856
5012
  }
3857
5013
  } else if (r === "circle") {
3858
5014
  let t = O.current;
3859
5015
  if (!t) O.current = { center: n };
3860
5016
  else {
3861
5017
  let r = calculateDistance(t.center, n), i = {
3862
- id: be(),
5018
+ id: N(),
3863
5019
  type: "circle",
3864
5020
  center: t.center,
3865
5021
  radius: r
3866
5022
  };
3867
- Ce(i), O.current = null, clearAllPreviewSources(e), f(null);
5023
+ P(i), O.current = null, clearAllPreviewSources(e), g(null);
3868
5024
  }
3869
5025
  } else if (r === "square") {
3870
5026
  let t = k.current;
3871
5027
  if (!t) k.current = { center: n };
3872
5028
  else {
3873
5029
  let r = calculateDistance(t.center, n) * 2, i = {
3874
- id: be(),
5030
+ id: N(),
3875
5031
  type: "square",
3876
5032
  center: t.center,
3877
5033
  length: r
3878
5034
  };
3879
- Ce(i), k.current = null, clearAllPreviewSources(e), f(null);
5035
+ P(i), k.current = null, clearAllPreviewSources(e), g(null);
3880
5036
  }
3881
5037
  } else if (r === "polygon") {
3882
5038
  let t = A.current;
3883
5039
  if (t.length >= 3 && calculateDistance(t[0], n) < 20) {
3884
5040
  let n = {
3885
- id: be(),
5041
+ id: N(),
3886
5042
  type: "polygon",
3887
5043
  coordinates: [...t]
3888
5044
  };
3889
- Ce(n), A.current = [], clearAllPreviewSources(e), f(null);
5045
+ P(n), A.current = [], clearAllPreviewSources(e), g(null);
3890
5046
  return;
3891
5047
  }
3892
5048
  A.current = [...t, n];
3893
5049
  } else r === "polyline" && (j.current = [...j.current, n]);
3894
5050
  }, n = (e) => {
3895
- let t = [e.lngLat.lng, e.lngLat.lat], n = N.current;
3896
- if (n === "rectangle" && D.current) Oe(D.current, t);
3897
- else if (n === "circle" && O.current) ke(O.current.center, t);
3898
- else if (n === "square" && k.current) Ae(k.current.center, t);
5051
+ let t = [e.lngLat.lng, e.lngLat.lat], n = we.current;
5052
+ if (n === "rectangle" && D.current) je(D.current, t);
5053
+ else if (n === "circle" && O.current) Me(O.current.center, t);
5054
+ else if (n === "square" && k.current) Ne(k.current.center, t);
3899
5055
  else if (n === "polygon") {
3900
5056
  let e = A.current;
3901
- e.length > 0 && je(e, t);
5057
+ e.length > 0 && Pe(e, t);
3902
5058
  } else if (n === "polyline") {
3903
5059
  let e = j.current;
3904
- e.length > 0 && Me(e, t);
5060
+ e.length > 0 && F(e, t);
3905
5061
  }
3906
5062
  }, r = (t) => {
3907
5063
  t.preventDefault();
3908
- let n = N.current;
5064
+ let n = we.current;
3909
5065
  if (n === "polygon") {
3910
5066
  let t = A.current;
3911
5067
  if (t.length >= 3) {
3912
5068
  let n = {
3913
- id: be(),
5069
+ id: N(),
3914
5070
  type: "polygon",
3915
5071
  coordinates: [...t]
3916
5072
  };
3917
- Ce(n), A.current = [], clearAllPreviewSources(e), f(null);
5073
+ P(n), A.current = [], clearAllPreviewSources(e), g(null);
3918
5074
  } else A.current = [], clearAllPreviewSources(e);
3919
5075
  } else if (n === "polyline") {
3920
5076
  let t = j.current;
3921
5077
  if (t.length >= 2) {
3922
5078
  let n = {
3923
- id: be(),
5079
+ id: N(),
3924
5080
  type: "polyline",
3925
5081
  coordinates: [...t]
3926
5082
  };
3927
- Ce(n), j.current = [], clearAllPreviewSources(e), f(null);
5083
+ P(n), j.current = [], clearAllPreviewSources(e), g(null);
3928
5084
  } else j.current = [], clearAllPreviewSources(e);
3929
5085
  }
3930
5086
  }, i = (t) => {
3931
- t.key === "Escape" && (D.current = null, O.current = null, k.current = null, A.current = [], j.current = [], clearAllPreviewSources(e), f(null));
5087
+ t.key === "Escape" && (D.current = null, O.current = null, k.current = null, A.current = [], j.current = [], clearAllPreviewSources(e), g(null));
3932
5088
  }, a = (t) => {
3933
5089
  t.preventDefault();
3934
- let n = N.current;
5090
+ let n = we.current;
3935
5091
  if (n === "polygon") {
3936
5092
  let t = A.current;
3937
5093
  if (t.length >= 3) {
3938
5094
  let n = {
3939
- id: be(),
5095
+ id: N(),
3940
5096
  type: "polygon",
3941
5097
  coordinates: [...t]
3942
5098
  };
3943
- Ce(n), A.current = [], clearAllPreviewSources(e), f(null);
5099
+ P(n), A.current = [], clearAllPreviewSources(e), g(null);
3944
5100
  }
3945
5101
  } else if (n === "polyline") {
3946
5102
  let t = j.current;
3947
5103
  if (t.length >= 2) {
3948
5104
  let n = {
3949
- id: be(),
5105
+ id: N(),
3950
5106
  type: "polyline",
3951
5107
  coordinates: [...t]
3952
5108
  };
3953
- Ce(n), j.current = [], clearAllPreviewSources(e), f(null);
5109
+ P(n), j.current = [], clearAllPreviewSources(e), g(null);
3954
5110
  }
3955
5111
  }
3956
5112
  };
@@ -3959,28 +5115,28 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
3959
5115
  };
3960
5116
  }, [
3961
5117
  e,
3962
- d,
3963
- be,
3964
- Ce,
3965
- Se,
3966
- Oe,
3967
- ke,
3968
- Ae,
5118
+ f,
5119
+ N,
5120
+ P,
5121
+ Ee,
3969
5122
  je,
3970
- Me
5123
+ Me,
5124
+ Ne,
5125
+ Pe,
5126
+ F
3971
5127
  ]), useEffect(() => () => {
3972
- S.current.forEach((e) => e.destroy()), S.current.clear();
5128
+ C.current.forEach((e) => e.destroy()), C.current.clear();
3973
5129
  }, []);
3974
- let Ne = useCallback((t) => {
3975
- f((e) => e === t ? null : t), D.current = null, O.current = null, k.current = null, A.current = [], j.current = [], e && clearAllPreviewSources(e);
5130
+ let Fe = useCallback((t) => {
5131
+ g((e) => e === t ? null : t), D.current = null, O.current = null, k.current = null, A.current = [], j.current = [], e && clearAllPreviewSources(e);
3976
5132
  }, [e]);
3977
5133
  return e ? /* @__PURE__ */ jsxs("div", {
3978
- className: `mapbox-measure-control ${s}`,
3979
- style: c,
5134
+ className: `mapbox-measure-control ${c}`,
5135
+ style: l,
3980
5136
  children: [/* @__PURE__ */ jsxs("button", {
3981
5137
  ref: E,
3982
- className: `mapbox-control-btn mapbox-measure-control__btn ${l ? "mapbox-measure-control__btn--active" : ""}`,
3983
- onClick: () => u(!l),
5138
+ className: `mapbox-control-btn mapbox-measure-control__btn ${u ? "mapbox-measure-control__btn--active" : ""}`,
5139
+ onClick: () => d(!u),
3984
5140
  title: "测量",
3985
5141
  children: [
3986
5142
  /* @__PURE__ */ jsx("img", {
@@ -3989,13 +5145,13 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
3989
5145
  className: "mapbox-measure-control__btn-icon"
3990
5146
  }),
3991
5147
  /* @__PURE__ */ jsx("span", { children: "测量" }),
3992
- b.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
5148
+ x.length > 0 && /* @__PURE__ */ jsxs("span", { children: [
3993
5149
  "(",
3994
- b.length,
5150
+ x.length,
3995
5151
  ")"
3996
5152
  ] })
3997
5153
  ]
3998
- }), l && /* @__PURE__ */ jsxs("div", {
5154
+ }), u && /* @__PURE__ */ jsxs("div", {
3999
5155
  ref: T,
4000
5156
  className: "mapbox-measure-control__panel",
4001
5157
  children: [
@@ -4007,18 +5163,18 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
4007
5163
  className: "mapbox-measure-control__settings",
4008
5164
  children: [
4009
5165
  /* @__PURE__ */ jsx(Checkbox, {
4010
- checked: y.showArea,
4011
- onChange: (e) => De("showArea", e),
5166
+ checked: b.showArea,
5167
+ onChange: (e) => Ae("showArea", e),
4012
5168
  children: "面积"
4013
5169
  }),
4014
5170
  /* @__PURE__ */ jsx(Checkbox, {
4015
- checked: y.showLength,
4016
- onChange: (e) => De("showLength", e),
5171
+ checked: b.showLength,
5172
+ onChange: (e) => Ae("showLength", e),
4017
5173
  children: "长度"
4018
5174
  }),
4019
5175
  /* @__PURE__ */ jsx(Checkbox, {
4020
- checked: y.showRadius,
4021
- onChange: (e) => De("showRadius", e),
5176
+ checked: b.showRadius,
5177
+ onChange: (e) => Ae("showRadius", e),
4022
5178
  children: "半径"
4023
5179
  })
4024
5180
  ]
@@ -4030,16 +5186,16 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
4030
5186
  /* @__PURE__ */ jsxs("div", {
4031
5187
  className: "mapbox-measure-control__tools",
4032
5188
  children: [DRAW_TOOLS.map((e) => /* @__PURE__ */ jsx("button", {
4033
- className: `mapbox-measure-control__tool-btn ${d === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
4034
- onClick: () => Ne(e.mode),
5189
+ className: `mapbox-measure-control__tool-btn ${f === e.mode ? "mapbox-measure-control__tool-btn--active" : ""}`,
5190
+ onClick: () => Fe(e.mode),
4035
5191
  title: e.label,
4036
5192
  children: /* @__PURE__ */ jsx("img", {
4037
5193
  src: e.icon,
4038
5194
  alt: e.label
4039
5195
  })
4040
- }, e.mode)), b.length > 0 && /* @__PURE__ */ jsx("button", {
5196
+ }, e.mode)), x.length > 0 && /* @__PURE__ */ jsx("button", {
4041
5197
  className: "mapbox-measure-control__tool-btn mapbox-measure-control__tool-btn--danger",
4042
- onClick: Te,
5198
+ onClick: Oe,
4043
5199
  title: "清除全部",
4044
5200
  children: /* @__PURE__ */ jsx("img", {
4045
5201
  src: "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1769394652565'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='6483'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='128'%20height='128'%3e%3cpath%20d='M841.385637%20288.639098a36.479886%2036.479886%200%200%201%2072.74644%207.679976l6.613312%20629.544699A109.866323%20109.866323%200%200%201%20810.665733%201023.9968H222.507571a109.652991%20109.652991%200%200%201-109.012992-98.133027l-3.626656-629.544699a36.479886%2036.479886%200%200%201%2072.74644-7.679976L186.241018%20917.330467a36.479886%2036.479886%200%200%200%2036.266553%2032.639898H810.665733A36.479886%2036.479886%200%200%200%20847.99895%20917.330467z%20m-219.732646%20113.706311a36.479886%2036.479886%200%200%201%2036.693218%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.479886-36.479886z%20m-219.305982%200a36.479886%2036.479886%200%200%201%2036.479886%2036.479886v255.9992a36.693219%2036.693219%200%201%201-73.173104%200v-255.9992a36.479886%2036.479886%200%200%201%2036.693218-36.479886z%20m-36.693218-255.9992h292.692418V91.519714a18.346609%2018.346609%200%200%200-18.346609-18.346609H384.0004a18.346609%2018.346609%200%200%200-18.346609%2018.346609z%20m-73.173105%200V73.173105A73.173105%2073.173105%200%200%201%20365.653791%200h292.692418a73.386437%2073.386437%200%200%201%2073.173105%2073.173105v73.173104h255.9992a36.693219%2036.693219%200%200%201%200%2073.173105H36.481486a36.693219%2036.693219%200%200%201%200-73.173105z'%20fill='%23EB6865'%20p-id='6484'%3e%3c/path%3e%3c/svg%3e",
@@ -4047,7 +5203,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
4047
5203
  })
4048
5204
  })]
4049
5205
  }),
4050
- b.length > 0 ? /* @__PURE__ */ jsx("div", {
5206
+ x.length > 0 ? /* @__PURE__ */ jsx("div", {
4051
5207
  className: "mapbox-measure-control__list",
4052
5208
  children: /* @__PURE__ */ jsxs("table", {
4053
5209
  className: "mapbox-measure-control__table",
@@ -4057,9 +5213,9 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
4057
5213
  /* @__PURE__ */ jsx("th", { children: "面积" }),
4058
5214
  /* @__PURE__ */ jsx("th", { children: "长度/半径" }),
4059
5215
  /* @__PURE__ */ jsx("th", {})
4060
- ] }) }), /* @__PURE__ */ jsx("tbody", { children: b.map((e) => /* @__PURE__ */ jsxs("tr", {
5216
+ ] }) }), /* @__PURE__ */ jsx("tbody", { children: x.map((e) => /* @__PURE__ */ jsxs("tr", {
4061
5217
  className: "mapbox-measure-control__table-row",
4062
- onClick: () => Ee(e.entity.id),
5218
+ onClick: () => ke(e.entity.id),
4063
5219
  children: [
4064
5220
  /* @__PURE__ */ jsx("td", { children: e.shapeLabel }),
4065
5221
  /* @__PURE__ */ jsx("td", { children: String(e.entity.id) }),
@@ -4068,7 +5224,7 @@ function MeasureControl({ map: e, entityConfig: r, onEntityConfigChange: i, clas
4068
5224
  /* @__PURE__ */ jsx("td", { children: /* @__PURE__ */ jsx("button", {
4069
5225
  className: "mapbox-measure-control__delete-btn",
4070
5226
  onClick: (t) => {
4071
- t.stopPropagation(), we(e.entity.id);
5227
+ t.stopPropagation(), De(e.entity.id);
4072
5228
  },
4073
5229
  title: "删除",
4074
5230
  children: /* @__PURE__ */ jsx("img", {
@@ -4145,7 +5301,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
4145
5301
  }, [b, x]);
4146
5302
  let C = useCallback((t) => {
4147
5303
  if (!(!e || c.length === 0)) for (let n of c) e.getLayer(n) && (e.setPaintProperty(n, "raster-brightness-min", 0), e.setPaintProperty(n, "raster-brightness-max", t.brightness), e.setPaintProperty(n, "raster-saturation", t.saturation), e.setPaintProperty(n, "raster-contrast", t.contrast), e.setPaintProperty(n, "raster-hue-rotate", t.hueRotate));
4148
- }, [e, c]), w = useCallback((e, t) => {
5304
+ }, [e, c]), ve = useCallback((e, t) => {
4149
5305
  if (b) s?.({
4150
5306
  ...x,
4151
5307
  [e]: t
@@ -4163,7 +5319,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
4163
5319
  x,
4164
5320
  h,
4165
5321
  C
4166
- ]), T = useCallback(() => {
5322
+ ]), w = useCallback(() => {
4167
5323
  b ? s?.({ ...DEFAULT_CONFIG }) : (_({ ...DEFAULT_CONFIG }), C({ ...DEFAULT_CONFIG }));
4168
5324
  }, [
4169
5325
  b,
@@ -4178,7 +5334,7 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
4178
5334
  C,
4179
5335
  h
4180
5336
  ]);
4181
- let E = (e, t) => e === "hueRotate" ? `${Math.round(t)}°` : t.toFixed(2);
5337
+ let T = (e, t) => e === "hueRotate" ? `${Math.round(t)}°` : t.toFixed(2);
4182
5338
  return /* @__PURE__ */ jsxs("div", {
4183
5339
  className: `mapbox-raster-paint-control${l ? ` ${l}` : ""}`,
4184
5340
  style: u,
@@ -4208,17 +5364,17 @@ function RasterPaintControl({ map: e, value: r, onChange: s, rasterPaintLayerIds
4208
5364
  max: r,
4209
5365
  step: i,
4210
5366
  value: x[e],
4211
- onChange: (t) => w(e, t),
5367
+ onChange: (t) => ve(e, t),
4212
5368
  tooltipVisible: !1
4213
5369
  }),
4214
5370
  /* @__PURE__ */ jsx("span", {
4215
5371
  className: "mapbox-raster-paint-control__value",
4216
- children: E(e, x[e])
5372
+ children: T(e, x[e])
4217
5373
  })
4218
5374
  ]
4219
5375
  }, e)), /* @__PURE__ */ jsx("button", {
4220
5376
  className: "mapbox-raster-paint-control__reset",
4221
- onClick: T,
5377
+ onClick: w,
4222
5378
  children: "重置"
4223
5379
  })]
4224
5380
  })]
@@ -4245,15 +5401,15 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
4245
5401
  i === "square" ? s(null) : (r(null), s("square"));
4246
5402
  }, C = () => {
4247
5403
  i === "polyline" ? s(null) : (r(null), s("polyline"));
4248
- }, w = () => {
5404
+ }, ve = () => {
4249
5405
  (i === "rectangle" || i === "circle" || i === "polygon" || i === "square" || i === "polyline") && s(null), g(!h);
4250
- }, T = (e) => e.size ? {
5406
+ }, w = (e) => e.size ? {
4251
5407
  width: e.size,
4252
5408
  height: e.size
4253
5409
  } : {
4254
5410
  width: e.width || 32,
4255
5411
  height: e.height || 32
4256
- }, E = h || t, D = i === "rectangle", O = i === "circle", ve = i === "polygon", ye = i === "square", k = i === "polyline";
5412
+ }, T = h || t, E = i === "rectangle", D = i === "circle", ye = i === "polygon", be = i === "square", O = i === "polyline";
4257
5413
  return /* @__PURE__ */ jsxs("div", {
4258
5414
  ref: _,
4259
5415
  className: "mapbox-edit-control",
@@ -4261,8 +5417,8 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
4261
5417
  className: "mapbox-edit-control__btn-group",
4262
5418
  children: [
4263
5419
  /* @__PURE__ */ jsxs("button", {
4264
- className: `mapbox-control-btn ${E ? "mapbox-control-btn--active" : ""}`,
4265
- onClick: w,
5420
+ className: `mapbox-control-btn ${T ? "mapbox-control-btn--active" : ""}`,
5421
+ onClick: ve,
4266
5422
  title: "Marker",
4267
5423
  children: [t ? /* @__PURE__ */ jsx("img", {
4268
5424
  src: t.icon,
@@ -4275,7 +5431,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
4275
5431
  }), /* @__PURE__ */ jsx("span", { children: t ? t.name : "Marker" })]
4276
5432
  }),
4277
5433
  d && /* @__PURE__ */ jsxs("button", {
4278
- className: `mapbox-control-btn ${ye ? "mapbox-control-btn--active" : ""}`,
5434
+ className: `mapbox-control-btn ${be ? "mapbox-control-btn--active" : ""}`,
4279
5435
  onClick: S,
4280
5436
  title: "绘制正方形",
4281
5437
  children: [/* @__PURE__ */ jsx("img", {
@@ -4285,7 +5441,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
4285
5441
  }), /* @__PURE__ */ jsx("span", { children: "正方形" })]
4286
5442
  }),
4287
5443
  c && /* @__PURE__ */ jsxs("button", {
4288
- className: `mapbox-control-btn ${D ? "mapbox-control-btn--active" : ""}`,
5444
+ className: `mapbox-control-btn ${E ? "mapbox-control-btn--active" : ""}`,
4289
5445
  onClick: y,
4290
5446
  title: "绘制矩形",
4291
5447
  children: [/* @__PURE__ */ jsx("img", {
@@ -4295,7 +5451,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
4295
5451
  }), /* @__PURE__ */ jsx("span", { children: "矩形" })]
4296
5452
  }),
4297
5453
  l && /* @__PURE__ */ jsxs("button", {
4298
- className: `mapbox-control-btn ${O ? "mapbox-control-btn--active" : ""}`,
5454
+ className: `mapbox-control-btn ${D ? "mapbox-control-btn--active" : ""}`,
4299
5455
  onClick: b,
4300
5456
  title: "绘制圆形",
4301
5457
  children: [/* @__PURE__ */ jsx("img", {
@@ -4305,7 +5461,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
4305
5461
  }), /* @__PURE__ */ jsx("span", { children: "圆形" })]
4306
5462
  }),
4307
5463
  u && /* @__PURE__ */ jsxs("button", {
4308
- className: `mapbox-control-btn ${ve ? "mapbox-control-btn--active" : ""}`,
5464
+ className: `mapbox-control-btn ${ye ? "mapbox-control-btn--active" : ""}`,
4309
5465
  onClick: x,
4310
5466
  title: "绘制多边形",
4311
5467
  children: [/* @__PURE__ */ jsx("img", {
@@ -4315,7 +5471,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
4315
5471
  }), /* @__PURE__ */ jsx("span", { children: "多边形" })]
4316
5472
  }),
4317
5473
  f && /* @__PURE__ */ jsxs("button", {
4318
- className: `mapbox-control-btn ${k ? "mapbox-control-btn--active" : ""}`,
5474
+ className: `mapbox-control-btn ${O ? "mapbox-control-btn--active" : ""}`,
4319
5475
  onClick: C,
4320
5476
  title: "绘制折线",
4321
5477
  children: [/* @__PURE__ */ jsx("img", {
@@ -4333,7 +5489,7 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
4333
5489
  }), /* @__PURE__ */ jsx("div", {
4334
5490
  className: "mapbox-edit-control__template-list",
4335
5491
  children: e.map((e) => {
4336
- let n = T(e), r = t?.id === e.id;
5492
+ let n = w(e), r = t?.id === e.id;
4337
5493
  return /* @__PURE__ */ jsxs("div", {
4338
5494
  className: `mapbox-edit-control__template-item ${r ? "mapbox-edit-control__template-item--selected" : ""}`,
4339
5495
  onClick: () => v(e),
@@ -4403,6 +5559,220 @@ const EditControl = ({ markerTemplates: e, selectedTemplate: t, onTemplateSelect
4403
5559
  });
4404
5560
  return createPortal(d, i);
4405
5561
  };
5562
+ var route_planning_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20t='1775031767174'%20class='icon'%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='30653'%20data-spm-anchor-id='a313x.search_index.0.i6.78953a81FCkAe0'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='64'%20height='64'%3e%3cpath%20d='M322.24%20479.210667l-42.453333-42.432%20198.826666-198.826667c53.397333-53.376%20139.306667-53.568%20191.914667-0.981333%2052.608%2052.608%2052.416%20138.517333-0.981333%20191.914666L455.722667%20642.709333l-42.432-42.453333%20213.824-213.802667a74.773333%2074.773333%200%200%200-0.341334-105.728%2074.773333%2074.773333%200%200%200-105.728-0.341333l-198.826666%20198.826667z'%20fill='%23ffffff'%20p-id='30654'%3e%3c/path%3e%3cpath%20d='M699.093333%20613.333333l42.453334%2042.432-169.429334%20169.408c-48.341333%2048.341333-129.28%2042.282667-181.248-9.664-51.968-51.968-58.026667-132.906667-9.664-181.248l234.346667-234.346666%2042.432%2042.410666L423.616%20676.693333c-22.250667%2022.250667-19.050667%2065.024%2011.008%2095.061334%2030.037333%2030.058667%2072.810667%2033.258667%2095.061333%2010.986666l169.429334-169.408zM187.989333%20571.029333c-38.933333-38.933333-38.805333-102.613333%200.853334-142.293333%2039.68-39.68%20103.381333-39.808%20142.293333-0.853333%2038.954667%2038.912%2038.826667%20102.613333-0.853333%20142.293333-39.68%2039.658667-103.381333%2039.786667-142.293334%200.853333z%20m43.733334-43.733333c15.744%2015.744%2040.874667%2015.68%2056.128%200.426667%2015.253333-15.232%2015.296-40.362667-0.426667-56.106667-15.765333-15.744-40.896-15.701333-56.149333-0.448-15.232%2015.232-15.296%2040.384%200.448%2056.106667z'%20fill='%23ffffff'%20p-id='30655'%3e%3c/path%3e%3cpath%20d='M846.144%20489.728l-31.466667%20198.784-56.96-101.461333-104.042666-38.506667z'%20fill='%23ffffff'%20p-id='30656'%3e%3c/path%3e%3c/svg%3e", SOURCE_ID = "route-planning-temp-line", LINE_LAYER_ID = "route-planning-temp-line-layer", POINT_LAYER_ID = "route-planning-temp-point-layer";
5563
+ const RoutePlanningControl = forwardRef(({ map: e, pointCount: i = 2, showPointCountInput: c = !1, visualType: l = "marker", onSelectFinished: u, showButton: d = !0 }, f) => {
5564
+ let [h, g] = useState("idle"), [_, v] = useState(0), [y, b] = useState(i), [x, S] = useState(!1), C = useRef(null), ve = useRef(null), w = useRef([]), T = useRef([]), E = useRef("idle"), D = useRef(null), ye = useRef("");
5565
+ useEffect(() => {
5566
+ E.current = h;
5567
+ }, [h]), useEffect(() => {
5568
+ b(i);
5569
+ }, [i]), useEffect(() => {
5570
+ if (!x) return;
5571
+ let e = (e) => {
5572
+ ve.current && !ve.current.contains(e.target) && C.current && !C.current.contains(e.target) && S(!1);
5573
+ }, t = setTimeout(() => {
5574
+ document.addEventListener("mousedown", e);
5575
+ }, 0);
5576
+ return () => {
5577
+ clearTimeout(t), document.removeEventListener("mousedown", e);
5578
+ };
5579
+ }, [x]);
5580
+ let be = useCallback(() => {
5581
+ for (let e of T.current) e.remove();
5582
+ T.current = [], e && (e.getLayer(LINE_LAYER_ID) && e.removeLayer(LINE_LAYER_ID), e.getLayer(POINT_LAYER_ID) && e.removeLayer(POINT_LAYER_ID), e.getSource(SOURCE_ID) && e.removeSource(SOURCE_ID));
5583
+ }, [e]), O = useCallback(() => {
5584
+ if (!e) return;
5585
+ let t = w.current, n = {
5586
+ type: "FeatureCollection",
5587
+ features: [{
5588
+ type: "Feature",
5589
+ properties: {},
5590
+ geometry: {
5591
+ type: "LineString",
5592
+ coordinates: t.length >= 2 ? t : []
5593
+ }
5594
+ }, ...t.map((e, t) => ({
5595
+ type: "Feature",
5596
+ properties: { index: t },
5597
+ geometry: {
5598
+ type: "Point",
5599
+ coordinates: e
5600
+ }
5601
+ }))]
5602
+ }, r = e.getSource(SOURCE_ID);
5603
+ r ? r.setData(n) : (e.addSource(SOURCE_ID, {
5604
+ type: "geojson",
5605
+ data: n
5606
+ }), e.addLayer({
5607
+ id: LINE_LAYER_ID,
5608
+ type: "line",
5609
+ source: SOURCE_ID,
5610
+ filter: [
5611
+ "==",
5612
+ "$type",
5613
+ "LineString"
5614
+ ],
5615
+ paint: {
5616
+ "line-color": "#4A90D9",
5617
+ "line-width": 3,
5618
+ "line-dasharray": [2, 2]
5619
+ }
5620
+ }), e.addLayer({
5621
+ id: POINT_LAYER_ID,
5622
+ type: "circle",
5623
+ source: SOURCE_ID,
5624
+ filter: [
5625
+ "==",
5626
+ "$type",
5627
+ "Point"
5628
+ ],
5629
+ paint: {
5630
+ "circle-radius": 6,
5631
+ "circle-color": "#4A90D9",
5632
+ "circle-stroke-width": 2,
5633
+ "circle-stroke-color": "#fff"
5634
+ }
5635
+ }));
5636
+ }, [e]), xe = useCallback((t) => {
5637
+ if (!e || !D.current) return;
5638
+ let { visualType: n } = D.current;
5639
+ if (n === "marker") {
5640
+ let n = document.createElement("div");
5641
+ n.className = "route-planning-temp-marker", n.textContent = String(w.current.length);
5642
+ let r = new mapboxgl.Marker({ element: n }).setLngLat(t).addTo(e);
5643
+ T.current.push(r);
5644
+ } else O();
5645
+ }, [e, O]), Se = useCallback(() => {
5646
+ be(), w.current = [], D.current = null, v(0), g("idle"), e && (e.getCanvas().style.cursor = ye.current);
5647
+ }, [be, e]), Ce = useCallback(async () => {
5648
+ let e = D.current, t = [...w.current];
5649
+ if (!e || t.length < 2) {
5650
+ Se();
5651
+ return;
5652
+ }
5653
+ g("planning");
5654
+ try {
5655
+ await e.onSelectFinished(t);
5656
+ } catch (e) {
5657
+ console.error("Route planning onSelectFinished failed:", e);
5658
+ } finally {
5659
+ Se();
5660
+ }
5661
+ }, [Se]), k = useCallback((e) => {
5662
+ if (E.current !== "selecting" || !D.current) return;
5663
+ let t = [e.lngLat.lng, e.lngLat.lat];
5664
+ w.current.push(t);
5665
+ let n = w.current.length;
5666
+ v(n), xe(t), n >= D.current.pointCount && Ce();
5667
+ }, [xe, Ce]), A = useCallback((e) => {
5668
+ E.current === "selecting" && (e.preventDefault(), Se());
5669
+ }, [Se]);
5670
+ useEffect(() => {
5671
+ if (e && h === "selecting") return e.on("click", k), e.on("contextmenu", A), () => {
5672
+ e.off("click", k), e.off("contextmenu", A);
5673
+ };
5674
+ }, [
5675
+ e,
5676
+ h,
5677
+ k,
5678
+ A
5679
+ ]);
5680
+ let j = useCallback((t) => {
5681
+ if (!e) return;
5682
+ E.current !== "idle" && Se();
5683
+ let n = Math.max(2, t.pointCount ?? i), r = t.visualType ?? l;
5684
+ D.current = {
5685
+ pointCount: n,
5686
+ visualType: r,
5687
+ onSelectFinished: t.onSelectFinished
5688
+ }, w.current = [], v(0), b(n), S(!1), ye.current = e.getCanvas().style.cursor, e.getCanvas().style.cursor = "crosshair", g("selecting");
5689
+ }, [
5690
+ e,
5691
+ i,
5692
+ l,
5693
+ Se
5694
+ ]);
5695
+ useImperativeHandle(f, () => ({ startPlanning: j }), [j]);
5696
+ let M = () => {
5697
+ h === "idle" ? S((e) => !e) : h === "selecting" && Se();
5698
+ }, we = () => {
5699
+ u && j({
5700
+ pointCount: Math.max(2, y),
5701
+ visualType: l,
5702
+ onSelectFinished: u
5703
+ });
5704
+ }, N = (e) => {
5705
+ let t = parseInt(e.target.value, 10);
5706
+ !isNaN(t) && t >= 2 ? b(t) : e.target.value === "" && b(2);
5707
+ }, Te = () => {
5708
+ if (h === "planning") return /* @__PURE__ */ jsx("span", { children: "规划中..." });
5709
+ if (h === "selecting") {
5710
+ let e = D.current?.pointCount ?? y;
5711
+ return /* @__PURE__ */ jsxs("span", { children: [
5712
+ _,
5713
+ "/",
5714
+ e
5715
+ ] });
5716
+ }
5717
+ return "路径规划";
5718
+ }, Ee = h === "selecting", P = h === "planning";
5719
+ return !d && h === "idle" ? null : /* @__PURE__ */ jsxs("div", {
5720
+ className: `mapbox-route-planning-control${d ? "" : " mapbox-route-planning-control--floating"}`,
5721
+ children: [/* @__PURE__ */ jsxs("button", {
5722
+ ref: C,
5723
+ className: `mapbox-control-btn mapbox-route-planning-control__btn${Ee ? " mapbox-route-planning-control__btn--active" : ""}${P ? " mapbox-route-planning-control__btn--planning" : ""}${x ? " mapbox-route-planning-control__btn--active" : ""}`,
5724
+ onClick: M,
5725
+ disabled: P,
5726
+ title: h === "idle" ? "路径规划" : h === "selecting" ? "取消选点" : "规划中...",
5727
+ children: [/* @__PURE__ */ jsx("img", {
5728
+ src: route_planning_default,
5729
+ alt: "route",
5730
+ className: "mapbox-route-planning-control__btn-icon"
5731
+ }), Te()]
5732
+ }), x && h === "idle" && /* @__PURE__ */ jsxs("div", {
5733
+ ref: ve,
5734
+ className: "mapbox-route-planning-control__panel",
5735
+ children: [/* @__PURE__ */ jsx("div", {
5736
+ className: "mapbox-route-planning-control__panel-header",
5737
+ children: /* @__PURE__ */ jsx("span", {
5738
+ className: "mapbox-route-planning-control__panel-title",
5739
+ children: "路径规划"
5740
+ })
5741
+ }), /* @__PURE__ */ jsxs("div", {
5742
+ className: "mapbox-route-planning-control__panel-body",
5743
+ children: [
5744
+ /* @__PURE__ */ jsxs("div", {
5745
+ className: "mapbox-route-planning-control__panel-row",
5746
+ children: [/* @__PURE__ */ jsx("span", {
5747
+ className: "mapbox-route-planning-control__panel-label",
5748
+ children: "选点数量"
5749
+ }), c ? /* @__PURE__ */ jsx("input", {
5750
+ type: "number",
5751
+ className: "mapbox-route-planning-control__panel-input",
5752
+ value: y,
5753
+ min: 2,
5754
+ onChange: N
5755
+ }) : /* @__PURE__ */ jsx("span", {
5756
+ className: "mapbox-route-planning-control__panel-value",
5757
+ children: y
5758
+ })]
5759
+ }),
5760
+ /* @__PURE__ */ jsx("div", {
5761
+ className: "mapbox-route-planning-control__panel-tip",
5762
+ children: "左键点击地图选点,右键取消"
5763
+ }),
5764
+ /* @__PURE__ */ jsx("button", {
5765
+ className: "mapbox-route-planning-control__panel-start",
5766
+ onClick: we,
5767
+ disabled: !u,
5768
+ children: "开始规划"
5769
+ })
5770
+ ]
5771
+ })]
5772
+ })]
5773
+ });
5774
+ });
5775
+ RoutePlanningControl.displayName = "RoutePlanningControl";
4406
5776
  function mergePopupConfig(e, t, n) {
4407
5777
  return {
4408
5778
  content: e.content ?? n ?? null,
@@ -4550,51 +5920,53 @@ function adjustPopupForBounds(e, t) {
4550
5920
  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;
4551
5921
  }
4552
5922
  const Mapbox = forwardRef((e, c) => {
4553
- let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: h = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: T, entities: E = [], selectedIds: D = [], entityConfig: O, nameConfig: k, selectNameConfig: A, areaConfig: j, circleConfig: M, lengthConfig: N, showCoordinates: xe = !0, showScale: Te = !0, showResetView: Ee = !0, showRoadHighlight: De = !1, showMeasure: ke = !1, showRasterPaint: Ae = !1, onRasterPaintChange: Me, popupDefaults: P, renderPopup: Pe, onMapLoad: Fe, onEntityClick: Ie, onPopupOpen: Le, onPopupClose: Re, className: ze = "", containerStyle: Be } = e, Ve = useRef(null), F = useRef(null), I = useRef(/* @__PURE__ */ new Map()), L = useRef(/* @__PURE__ */ new Map()), He = useRef(/* @__PURE__ */ new Set()), [R, Ue] = useState(null), We = useRef(null), Ge = useRef(null), Ke = useRef(null), [qe, Je] = useState(null), Ye = useRef(null), Xe = useRef(null), [Ze, Qe] = useState(null), [z, $e] = useState(_), [et, tt] = useState(null), nt = useRef(null), [rt, B] = useState(null), [it, V] = useState(null), [at, ot] = useState(null), H = useRef(!1), U = useRef(null), W = useRef(null), G = useRef(null), st = useRef(null), K = useRef(null), ct = useRef([]), q = useRef(null), lt = useRef(null), J = useRef(null), ut = useRef([]), dt = useRef(null);
5923
+ let { center: l = [116.4074, 39.9042], zoom: u = 12, pitch: d = 0, bearing: f = 0, style: h = "mapbox://styles/mapbox/dark-v11", maxBounds: g, mode: _ = "display", editConfig: v = {}, pickerConfig: y = {}, onPick: b, interactive: x = {}, layers: S = [], rasterPaint: w, entities: T = [], selectedIds: E = [], entityConfig: D, nameConfig: O, selectNameConfig: k, areaConfig: A, circleConfig: j, lengthConfig: M, showCoordinates: we = !0, showScale: N = !0, showResetView: Te = !0, showRoadHighlight: Ee = !1, showMeasure: De = !1, showRasterPaint: je = !1, showRoutePlanning: Me, onRasterPaintChange: Ne, popupDefaults: F, renderPopup: Fe, onMapLoad: Ie, onEntityClick: Le, onPopupOpen: Re, onPopupClose: ze, className: Be = "", containerStyle: Ve } = e, He = useRef(null), Ue = useRef(null), I = useRef(null), L = useRef(/* @__PURE__ */ new Map()), R = useRef(/* @__PURE__ */ new Map()), We = useRef(/* @__PURE__ */ new Set()), [z, Ge] = useState(null), Ke = useRef(null), qe = useRef(null), Je = useRef(null), [Ye, Xe] = useState(null), Ze = useRef(null), Qe = useRef(null), [B, $e] = useState(null), [et, tt] = useState(_), [nt, rt] = useState(null), it = useRef(null), [at, V] = useState(null), [ot, H] = useState(null), [st, ct] = useState(null), U = useRef(!1), W = useRef(null), lt = useRef(null), G = useRef(null), ut = useRef(null), K = useRef(null), dt = useRef([]), q = useRef(null), ft = useRef(null), pt = useRef(null), mt = useRef([]), ht = useRef(null), gt = useRef(!1), [_t, vt] = useState([]), yt = useRef([]);
5924
+ yt.current = _t;
5925
+ let J = useRef(null);
4554
5926
  useEffect(() => {
4555
- $e(_);
5927
+ tt(_);
4556
5928
  }, [_]);
4557
- let ft = useCallback((e) => {
4558
- let t = I.current.get(e), n = L.current.get(e);
5929
+ let bt = useCallback((e) => {
5930
+ let t = L.current.get(e), n = R.current.get(e);
4559
5931
  if (t && n) {
4560
5932
  if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
4561
5933
  let r = {
4562
5934
  ...n,
4563
5935
  isAnimating: !0
4564
5936
  };
4565
- L.current.set(e, r), t.startAnimation();
5937
+ R.current.set(e, r), t.startAnimation();
4566
5938
  } else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
4567
5939
  let r = {
4568
5940
  ...n,
4569
5941
  isAnimating: !0
4570
5942
  };
4571
- L.current.set(e, r), t.startAnimation();
5943
+ R.current.set(e, r), t.startAnimation();
4572
5944
  }
4573
5945
  }
4574
- }, []), pt = useCallback((e) => {
4575
- let t = I.current.get(e), n = L.current.get(e);
5946
+ }, []), xt = useCallback((e) => {
5947
+ let t = L.current.get(e), n = R.current.get(e);
4576
5948
  if (t && n) {
4577
5949
  if (n.type === "radar" && t instanceof CanvasRadarRenderer) {
4578
5950
  let r = {
4579
5951
  ...n,
4580
5952
  isAnimating: !1
4581
5953
  };
4582
- L.current.set(e, r), t.stopAnimation();
5954
+ R.current.set(e, r), t.stopAnimation();
4583
5955
  } else if (n.type === "circle" && t instanceof CanvasCircleRenderer) {
4584
5956
  let r = {
4585
5957
  ...n,
4586
5958
  isAnimating: !1
4587
5959
  };
4588
- L.current.set(e, r), t.stopAnimation();
5960
+ R.current.set(e, r), t.stopAnimation();
4589
5961
  }
4590
5962
  }
4591
- }, []), mt = useCallback((e) => {
4592
- let t = L.current.get(e);
4593
- t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? pt(e) : ft(e));
4594
- }, [ft, pt]), ht = useCallback((e) => {
5963
+ }, []), St = useCallback((e) => {
5964
+ let t = R.current.get(e);
5965
+ t && (t.type === "radar" || t.type === "circle") && (t.type, t.isAnimating ? xt(e) : bt(e));
5966
+ }, [bt, xt]), Ct = useCallback((e) => {
4595
5967
  if (e === void 0) {
4596
5968
  let e = !1;
4597
- for (let [, t] of I.current) if (t instanceof UnitRenderer) {
5969
+ for (let [, t] of L.current) if (t instanceof UnitRenderer) {
4598
5970
  let n = t.getShowTrajectory();
4599
5971
  if (n === "all" || typeof n == "number" && n > 0) {
4600
5972
  e = !0;
@@ -4602,46 +5974,46 @@ const Mapbox = forwardRef((e, c) => {
4602
5974
  }
4603
5975
  }
4604
5976
  let t = e ? 0 : "all";
4605
- for (let [, e] of I.current) e instanceof UnitRenderer && e.setShowTrajectory(t);
5977
+ for (let [, e] of L.current) e instanceof UnitRenderer && e.setShowTrajectory(t);
4606
5978
  } else {
4607
5979
  let t = new Set(e.map(String));
4608
- for (let [e, n] of I.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
5980
+ for (let [e, n] of L.current) n instanceof UnitRenderer && n.setShowTrajectory(t.has(String(e)) ? "all" : 0);
4609
5981
  }
4610
- }, []), gt = useCallback((e, t, n) => {
4611
- let r = E.find((t) => String(t.id) === String(e));
4612
- if (!r?.popup || !F.current) return;
4613
- let i = r.popup.content ?? Pe?.(r);
5982
+ }, []), wt = useCallback((e, t, n) => {
5983
+ let r = T.find((t) => String(t.id) === String(e));
5984
+ if (!r?.popup || !I.current) return;
5985
+ let i = r.popup.content ?? Fe?.(r);
4614
5986
  if (!i) return;
4615
- let a = mergePopupConfig(r.popup, P, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, F.current, n);
4616
- Ue({
5987
+ let a = mergePopupConfig(r.popup, F, i), { position: o, actualPosition: s } = calculatePopupPosition(r, a, I.current, n);
5988
+ Ge({
4617
5989
  entityId: e,
4618
5990
  position: o,
4619
5991
  config: a,
4620
5992
  openedBy: t,
4621
5993
  actualPosition: s
4622
- }), Le?.(e);
5994
+ }), Re?.(e);
4623
5995
  }, [
4624
- E,
4625
- P,
4626
- Pe,
4627
- Le
4628
- ]), _t = useCallback((e) => {
4629
- R?.entityId === e && (Ue(null), Re?.(e));
4630
- }, [R, Re]), vt = useCallback(() => {
4631
- Ue((e) => (e && Re?.(e.entityId), null));
4632
- }, [Re]), yt = useCallback((e) => R?.entityId === e, [R]), bt = useCallback((e, t, n) => {
4633
- let r = F.current;
5996
+ T,
5997
+ F,
5998
+ Fe,
5999
+ Re
6000
+ ]), Tt = useCallback((e) => {
6001
+ z?.entityId === e && (Ge(null), ze?.(e));
6002
+ }, [z, ze]), Et = useCallback(() => {
6003
+ Ge((e) => (e && ze?.(e.entityId), null));
6004
+ }, [ze]), Dt = useCallback((e) => z?.entityId === e, [z]), Ot = useCallback((e, t, n) => {
6005
+ let r = I.current;
4634
6006
  r && r.flyTo({
4635
6007
  center: e,
4636
6008
  zoom: t ?? r.getZoom(),
4637
6009
  ...n
4638
6010
  });
4639
- }, []), xt = useCallback((e, t, n) => {
4640
- let r = F.current;
6011
+ }, []), kt = useCallback((e, t, n) => {
6012
+ let r = I.current;
4641
6013
  if (!r || e.length === 0) return;
4642
6014
  let i = [];
4643
6015
  for (let t of e) {
4644
- let e = I.current.get(t);
6016
+ let e = L.current.get(t);
4645
6017
  e && i.push(e.getBounds());
4646
6018
  }
4647
6019
  if (i.length === 0) return;
@@ -4663,19 +6035,19 @@ const Mapbox = forwardRef((e, c) => {
4663
6035
  pitch: n?.pitch ?? r.getPitch()
4664
6036
  };
4665
6037
  t !== void 0 && (p.maxZoom = t), n?.essential !== void 0 && (p.essential = n.essential), r.fitBounds(f, p);
4666
- }, []), St = useCallback((e) => {
4667
- let t = F.current;
6038
+ }, []), At = useCallback((e) => {
6039
+ let t = I.current;
4668
6040
  if (!t || !t.getContainer()) return;
4669
6041
  let { showMarker: n = !0, markerColor: r = "#3388ff", name: i, nameConfig: a } = y;
4670
6042
  if (!n) {
4671
- nt.current &&= (nt.current.remove(), null);
6043
+ it.current &&= (it.current.remove(), null);
4672
6044
  return;
4673
6045
  }
4674
- if (nt.current) {
4675
- nt.current.setLngLat(e);
4676
- let t = nt.current.getElement(), n = t.querySelector(".marker-label");
6046
+ if (it.current) {
6047
+ it.current.setLngLat(e);
6048
+ let t = it.current.getElement(), n = t.querySelector(".marker-label");
4677
6049
  if (i) {
4678
- let e = resolveNameConfig(a, k);
6050
+ let e = resolveNameConfig(a, O);
4679
6051
  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`;
4680
6052
  else {
4681
6053
  let n = document.createElement("div");
@@ -4687,41 +6059,41 @@ const Mapbox = forwardRef((e, c) => {
4687
6059
  n.className = "mapbox-picker-marker";
4688
6060
  let o = document.createElement("div");
4689
6061
  if (o.className = "marker-inner", o.style.background = r, n.appendChild(o), i) {
4690
- let e = resolveNameConfig(a, k), t = document.createElement("div");
6062
+ let e = resolveNameConfig(a, O), t = document.createElement("div");
4691
6063
  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);
4692
6064
  }
4693
- nt.current = new mapboxgl.Marker({
6065
+ it.current = new mapboxgl.Marker({
4694
6066
  element: n,
4695
6067
  anchor: "bottom"
4696
6068
  }).setLngLat(e).addTo(t);
4697
6069
  }
4698
- }, [y, k]), Ct = useCallback(() => {
4699
- nt.current &&= (nt.current.remove(), null);
4700
- }, []), wt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Tt = useCallback((e) => {
4701
- let t = F.current;
4702
- if (Ve.current) if (dt.current &&= (dt.current.remove(), null), e && t) {
6070
+ }, [y, O]), jt = useCallback(() => {
6071
+ it.current &&= (it.current.remove(), null);
6072
+ }, []), Mt = useCallback(() => `marker-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, []), Nt = useCallback((e) => {
6073
+ let t = I.current;
6074
+ if (He.current) if (ht.current &&= (ht.current.remove(), null), e && t) {
4703
6075
  t.getCanvas().style.cursor = "none";
4704
6076
  let n = document.createElement("div");
4705
6077
  n.className = "mapbox-custom-cursor";
4706
6078
  let r = e.size || e.width || 32;
4707
6079
  n.style.cssText = "\n position: fixed;\n pointer-events: none;\n z-index: 9999;\n transform: translate(-50%, -50%);\n opacity: 0.8;\n ";
4708
6080
  let i = document.createElement("img");
4709
- i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n), dt.current = n;
6081
+ i.src = e.icon, i.style.width = `${r}px`, i.style.height = `${e.size || e.height || r}px`, i.style.objectFit = "contain", n.appendChild(i), document.body.appendChild(n), ht.current = n;
4710
6082
  let a = (e) => {
4711
- dt.current && (dt.current.style.left = `${e.clientX}px`, dt.current.style.top = `${e.clientY}px`);
6083
+ ht.current && (ht.current.style.left = `${e.clientX}px`, ht.current.style.top = `${e.clientY}px`);
4712
6084
  };
4713
6085
  document.addEventListener("mousemove", a), n.dataset.cleanup = "true", n._cleanup = () => {
4714
6086
  document.removeEventListener("mousemove", a);
4715
6087
  };
4716
6088
  } else t && (t.getCanvas().style.cursor = "");
4717
6089
  }, []), Y = useCallback(() => {
4718
- if (dt.current) {
4719
- let e = dt.current._cleanup;
4720
- e && e(), dt.current.remove(), dt.current = null;
6090
+ if (ht.current) {
6091
+ let e = ht.current._cleanup;
6092
+ e && e(), ht.current.remove(), ht.current = null;
4721
6093
  }
4722
- let e = F.current;
6094
+ let e = I.current;
4723
6095
  e && (e.getCanvas().style.cursor = "");
4724
- }, []), Et = useCallback((e, t, n) => {
6096
+ }, []), Pt = useCallback((e, t, n) => {
4725
6097
  if (!e.getSource(t)) {
4726
6098
  if (!e.getStyle().glyphs) {
4727
6099
  let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
@@ -4757,8 +6129,8 @@ const Mapbox = forwardRef((e, c) => {
4757
6129
  }
4758
6130
  });
4759
6131
  }
4760
- }, []), Dt = useCallback(() => {
4761
- let e = F.current;
6132
+ }, []), Ft = useCallback(() => {
6133
+ let e = I.current;
4762
6134
  e && (e.getSource("rect-preview-source") || (e.addSource("rect-preview-source", {
4763
6135
  type: "geojson",
4764
6136
  data: {
@@ -4782,9 +6154,9 @@ const Mapbox = forwardRef((e, c) => {
4782
6154
  "line-width": 2,
4783
6155
  "line-dasharray": [4, 4]
4784
6156
  }
4785
- }), Et(e, "rect-preview-measure-source", "rect-preview-measure-label")));
4786
- }, [Et]), Ot = useCallback((e, t) => {
4787
- let n = F.current;
6157
+ }), Pt(e, "rect-preview-measure-source", "rect-preview-measure-label")));
6158
+ }, [Pt]), It = useCallback((e, t) => {
6159
+ let n = I.current;
4788
6160
  if (!n) return;
4789
6161
  let r = n.getSource("rect-preview-source");
4790
6162
  if (!r) return;
@@ -4803,11 +6175,11 @@ const Mapbox = forwardRef((e, c) => {
4803
6175
  },
4804
6176
  properties: {}
4805
6177
  });
4806
- let l = U.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
6178
+ let l = W.current, u = l?.strokeColor ?? "#3388ff", d = l?.strokeWidth ?? 2, f = l?.fillColor ?? "#3388ff", p = l?.fillOpacity ?? .1;
4807
6179
  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));
4808
6180
  let m = n.getSource("rect-preview-measure-source");
4809
6181
  if (m) {
4810
- let e = En.current, t = [], n = c[0], r = c[1], i = c[2];
6182
+ let e = Pn.current, t = [], n = c[0], r = c[1], i = c[2];
4811
6183
  if (e?.showArea) {
4812
6184
  let e = [(n[0] + i[0]) / 2, (n[1] + i[1]) / 2], a = distance(n, r), o = distance(r, i);
4813
6185
  t.push({
@@ -4844,8 +6216,8 @@ const Mapbox = forwardRef((e, c) => {
4844
6216
  features: t
4845
6217
  });
4846
6218
  }
4847
- }, []), kt = useCallback(() => {
4848
- let e = F.current;
6219
+ }, []), Lt = useCallback(() => {
6220
+ let e = I.current;
4849
6221
  if (!e) return;
4850
6222
  let t = e.getSource("rect-preview-source");
4851
6223
  t && t.setData({
@@ -4858,9 +6230,9 @@ const Mapbox = forwardRef((e, c) => {
4858
6230
  features: []
4859
6231
  });
4860
6232
  }, []), X = useCallback(() => {
4861
- ot(null), kt();
4862
- }, [kt]), At = useCallback(() => {
4863
- let e = F.current;
6233
+ ct(null), Lt();
6234
+ }, [Lt]), Rt = useCallback(() => {
6235
+ let e = I.current;
4864
6236
  e && (e.getSource("circle-preview-source") || (e.addSource("circle-preview-source", {
4865
6237
  type: "geojson",
4866
6238
  data: {
@@ -4884,7 +6256,7 @@ const Mapbox = forwardRef((e, c) => {
4884
6256
  "line-width": 2,
4885
6257
  "line-dasharray": [4, 4]
4886
6258
  }
4887
- }), Et(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
6259
+ }), Pt(e, "circle-preview-measure-source", "circle-preview-measure-label"), e.getSource("circle-preview-radius-source") || (e.addSource("circle-preview-radius-source", {
4888
6260
  type: "geojson",
4889
6261
  data: {
4890
6262
  type: "FeatureCollection",
@@ -4901,22 +6273,22 @@ const Mapbox = forwardRef((e, c) => {
4901
6273
  "line-dasharray": [4, 4]
4902
6274
  }
4903
6275
  }))));
4904
- }, [Et]), jt = useCallback((e, t, n = 64) => {
6276
+ }, [Pt]), zt = useCallback((e, t, n = 64) => {
4905
6277
  let [r, i] = e, a = [], o = t / 6371e3, s = i * Math.PI / 180;
4906
6278
  for (let e = 0; e <= n; e++) {
4907
6279
  let t = e / n * 2 * Math.PI, c = o * Math.cos(t), l = o * Math.sin(t) / Math.cos(s), u = i + c * 180 / Math.PI, d = r + l * 180 / Math.PI;
4908
6280
  a.push([d, u]);
4909
6281
  }
4910
6282
  return a;
4911
- }, []), Mt = useCallback((e, t) => {
6283
+ }, []), Bt = useCallback((e, t) => {
4912
6284
  let [n, r] = e, [i, a] = t, o = (a - r) * Math.PI / 180, s = (i - n) * Math.PI / 180, c = Math.sin(o / 2) * Math.sin(o / 2) + Math.cos(r * Math.PI / 180) * Math.cos(a * Math.PI / 180) * Math.sin(s / 2) * Math.sin(s / 2);
4913
6285
  return 6371e3 * (2 * Math.atan2(Math.sqrt(c), Math.sqrt(1 - c)));
4914
- }, []), Nt = useCallback((e, t) => {
4915
- let n = F.current;
6286
+ }, []), Vt = useCallback((e, t) => {
6287
+ let n = I.current;
4916
6288
  if (!n) return;
4917
6289
  let r = n.getSource("circle-preview-source");
4918
6290
  if (!r) return;
4919
- let i = Mt(e, t), a = jt(e, i);
6291
+ let i = Bt(e, t), a = zt(e, i);
4920
6292
  r.setData({
4921
6293
  type: "Feature",
4922
6294
  geometry: {
@@ -4927,7 +6299,7 @@ const Mapbox = forwardRef((e, c) => {
4927
6299
  });
4928
6300
  let o = G.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2, l = o?.fillColor ?? "#3388ff", u = o?.fillOpacity ?? .1;
4929
6301
  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));
4930
- let d = En.current, f = [], p = [];
6302
+ let d = Pn.current, f = [], p = [];
4931
6303
  if (d?.showArea) {
4932
6304
  let t = Math.PI * i * i;
4933
6305
  f.push({
@@ -4967,8 +6339,8 @@ const Mapbox = forwardRef((e, c) => {
4967
6339
  type: "FeatureCollection",
4968
6340
  features: p
4969
6341
  });
4970
- }, [Mt, jt]), Pt = useCallback(() => {
4971
- let e = F.current;
6342
+ }, [Bt, zt]), Ht = useCallback(() => {
6343
+ let e = I.current;
4972
6344
  if (!e) return;
4973
6345
  let t = e.getSource("circle-preview-source");
4974
6346
  t && t.setData({
@@ -4985,10 +6357,10 @@ const Mapbox = forwardRef((e, c) => {
4985
6357
  type: "FeatureCollection",
4986
6358
  features: []
4987
6359
  });
4988
- }, []), Ft = useCallback(() => {
4989
- st.current = null, Pt();
4990
- }, [Pt]), It = useCallback(() => {
4991
- let e = F.current;
6360
+ }, []), Ut = useCallback(() => {
6361
+ ut.current = null, Ht();
6362
+ }, [Ht]), Wt = useCallback(() => {
6363
+ let e = I.current;
4992
6364
  e && (e.getSource("polygon-preview-source") || (e.addSource("polygon-preview-source", {
4993
6365
  type: "geojson",
4994
6366
  data: {
@@ -5028,9 +6400,9 @@ const Mapbox = forwardRef((e, c) => {
5028
6400
  "circle-stroke-color": "#ffffff",
5029
6401
  "circle-stroke-width": 2
5030
6402
  }
5031
- }), Et(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
5032
- }, [Et]), Lt = useCallback((e, t) => {
5033
- let n = F.current;
6403
+ }), Pt(e, "polygon-preview-measure-source", "polygon-preview-measure-label")));
6404
+ }, [Pt]), Gt = useCallback((e, t) => {
6405
+ let n = I.current;
5034
6406
  if (!n) return;
5035
6407
  let r = n.getSource("polygon-preview-source"), i = n.getSource("polygon-vertices-source");
5036
6408
  if (!r || !i) return;
@@ -5071,7 +6443,7 @@ const Mapbox = forwardRef((e, c) => {
5071
6443
  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);
5072
6444
  let d = n.getSource("polygon-preview-measure-source");
5073
6445
  if (d) {
5074
- let e = En.current, t = [];
6446
+ let e = Pn.current, t = [];
5075
6447
  if (e?.showArea && a.length >= 3) {
5076
6448
  let e = [...a, a[0]], n = polygonArea(e), r = 0, i = 0;
5077
6449
  for (let e of a) r += e[0], i += e[1];
@@ -5113,8 +6485,8 @@ const Mapbox = forwardRef((e, c) => {
5113
6485
  features: t
5114
6486
  });
5115
6487
  }
5116
- }, []), Rt = useCallback(() => {
5117
- let e = F.current;
6488
+ }, []), Kt = useCallback(() => {
6489
+ let e = I.current;
5118
6490
  if (!e) return;
5119
6491
  let t = e.getSource("polygon-preview-source");
5120
6492
  t && t.setData({
@@ -5131,10 +6503,10 @@ const Mapbox = forwardRef((e, c) => {
5131
6503
  type: "FeatureCollection",
5132
6504
  features: []
5133
6505
  });
5134
- }, []), zt = useCallback(() => {
5135
- ct.current = [], Rt();
5136
- }, [Rt]), Bt = useCallback(() => {
5137
- let e = F.current;
6506
+ }, []), qt = useCallback(() => {
6507
+ dt.current = [], Kt();
6508
+ }, [Kt]), Jt = useCallback(() => {
6509
+ let e = I.current;
5138
6510
  e && (e.getSource("square-preview-source") || (e.addSource("square-preview-source", {
5139
6511
  type: "geojson",
5140
6512
  data: {
@@ -5158,8 +6530,8 @@ const Mapbox = forwardRef((e, c) => {
5158
6530
  "line-width": 2,
5159
6531
  "line-dasharray": [4, 4]
5160
6532
  }
5161
- }), Et(e, "square-preview-measure-source", "square-preview-measure-label")));
5162
- }, [Et]), Vt = useCallback((e, t) => {
6533
+ }), Pt(e, "square-preview-measure-source", "square-preview-measure-label")));
6534
+ }, [Pt]), Yt = useCallback((e, t) => {
5163
6535
  let [n, r] = e, i = t / 2 / 6371e3, a = r * Math.PI / 180, o = i * 180 / Math.PI, s = i * 180 / Math.PI / Math.cos(a);
5164
6536
  return [
5165
6537
  [n - s, r + o],
@@ -5168,12 +6540,12 @@ const Mapbox = forwardRef((e, c) => {
5168
6540
  [n - s, r - o],
5169
6541
  [n - s, r + o]
5170
6542
  ];
5171
- }, []), Ht = useCallback((e, t) => {
5172
- let n = F.current;
6543
+ }, []), Xt = useCallback((e, t) => {
6544
+ let n = I.current;
5173
6545
  if (!n) return;
5174
6546
  let r = n.getSource("square-preview-source");
5175
6547
  if (!r) return;
5176
- let i = Mt(e, t) * 2, a = Vt(e, i);
6548
+ let i = Bt(e, t) * 2, a = Yt(e, i);
5177
6549
  r.setData({
5178
6550
  type: "Feature",
5179
6551
  geometry: {
@@ -5186,7 +6558,7 @@ const Mapbox = forwardRef((e, c) => {
5186
6558
  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));
5187
6559
  let d = n.getSource("square-preview-measure-source");
5188
6560
  if (d) {
5189
- let t = En.current, n = [];
6561
+ let t = Pn.current, n = [];
5190
6562
  if (t?.showArea && n.push({
5191
6563
  type: "Feature",
5192
6564
  geometry: {
@@ -5210,8 +6582,8 @@ const Mapbox = forwardRef((e, c) => {
5210
6582
  features: n
5211
6583
  });
5212
6584
  }
5213
- }, [Mt, Vt]), Ut = useCallback(() => {
5214
- let e = F.current;
6585
+ }, [Bt, Yt]), Zt = useCallback(() => {
6586
+ let e = I.current;
5215
6587
  if (!e) return;
5216
6588
  let t = e.getSource("square-preview-source");
5217
6589
  t && t.setData({
@@ -5223,10 +6595,10 @@ const Mapbox = forwardRef((e, c) => {
5223
6595
  type: "FeatureCollection",
5224
6596
  features: []
5225
6597
  });
5226
- }, []), Wt = useCallback(() => {
5227
- lt.current = null, Ut();
5228
- }, [Ut]), Gt = useCallback(() => {
5229
- let e = F.current;
6598
+ }, []), Qt = useCallback(() => {
6599
+ ft.current = null, Zt();
6600
+ }, [Zt]), $t = useCallback(() => {
6601
+ let e = I.current;
5230
6602
  e && (e.getSource("polyline-preview-source") || (e.addSource("polyline-preview-source", {
5231
6603
  type: "geojson",
5232
6604
  data: {
@@ -5258,9 +6630,9 @@ const Mapbox = forwardRef((e, c) => {
5258
6630
  "circle-stroke-color": "#ffffff",
5259
6631
  "circle-stroke-width": 2
5260
6632
  }
5261
- }), Et(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
5262
- }, [Et]), Kt = useCallback((e, t) => {
5263
- let n = F.current;
6633
+ }), Pt(e, "polyline-preview-measure-source", "polyline-preview-measure-label")));
6634
+ }, [Pt]), en = useCallback((e, t) => {
6635
+ let n = I.current;
5264
6636
  if (!n) return;
5265
6637
  let r = n.getSource("polyline-preview-source"), i = n.getSource("polyline-vertices-source");
5266
6638
  if (!r || !i) return;
@@ -5286,11 +6658,11 @@ const Mapbox = forwardRef((e, c) => {
5286
6658
  properties: {}
5287
6659
  }))
5288
6660
  });
5289
- let o = J.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
6661
+ let o = pt.current, s = o?.strokeColor ?? "#3388ff", c = o?.strokeWidth ?? 2;
5290
6662
  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);
5291
6663
  let l = n.getSource("polyline-preview-measure-source");
5292
6664
  if (l) {
5293
- let e = En.current, t = [];
6665
+ let e = Pn.current, t = [];
5294
6666
  if (e?.showLength && a.length >= 2) for (let e = 0; e < a.length - 1; e++) {
5295
6667
  let n = a[e], r = a[e + 1], i = [(n[0] + r[0]) / 2, (n[1] + r[1]) / 2];
5296
6668
  t.push({
@@ -5307,8 +6679,8 @@ const Mapbox = forwardRef((e, c) => {
5307
6679
  features: t
5308
6680
  });
5309
6681
  }
5310
- }, []), qt = useCallback(() => {
5311
- let e = F.current;
6682
+ }, []), tn = useCallback(() => {
6683
+ let e = I.current;
5312
6684
  if (!e) return;
5313
6685
  let t = e.getSource("polyline-preview-source");
5314
6686
  t && t.setData({
@@ -5326,149 +6698,158 @@ const Mapbox = forwardRef((e, c) => {
5326
6698
  features: []
5327
6699
  });
5328
6700
  }, []), Z = useCallback(() => {
5329
- ut.current = [], qt();
5330
- }, [qt]), Jt = useCallback((e) => {
5331
- B(e), Tt(e), e ? (V("marker"), X(), Ft(), zt(), Wt(), Z()) : V(null);
6701
+ mt.current = [], tn();
6702
+ }, [tn]), nn = useCallback((e) => {
6703
+ V(e), Nt(e), e ? (H("marker"), X(), Ut(), qt(), Qt(), Z()) : H(null);
5332
6704
  }, [
5333
- Tt,
6705
+ Nt,
5334
6706
  X,
5335
- Ft,
5336
- zt,
5337
- Wt,
6707
+ Ut,
6708
+ qt,
6709
+ Qt,
5338
6710
  Z
5339
- ]), Yt = useCallback((e) => {
5340
- if (V(e), e === "rectangle") {
5341
- B(null), Y(), Ft(), zt(), Wt(), Z();
5342
- let e = F.current;
6711
+ ]), rn = useCallback((e) => {
6712
+ if (H(e), e === "rectangle") {
6713
+ V(null), Y(), Ut(), qt(), Qt(), Z();
6714
+ let e = I.current;
5343
6715
  e && (e.getCanvas().style.cursor = "crosshair");
5344
6716
  } else if (e === "circle") {
5345
- B(null), Y(), X(), zt(), Wt(), Z();
5346
- let e = F.current;
6717
+ V(null), Y(), X(), qt(), Qt(), Z();
6718
+ let e = I.current;
5347
6719
  e && (e.getCanvas().style.cursor = "crosshair");
5348
6720
  } else if (e === "polygon") {
5349
- B(null), Y(), X(), Ft(), Wt(), Z();
5350
- let e = F.current;
6721
+ V(null), Y(), X(), Ut(), Qt(), Z();
6722
+ let e = I.current;
5351
6723
  e && (e.getCanvas().style.cursor = "crosshair");
5352
6724
  } else if (e === "square") {
5353
- B(null), Y(), X(), Ft(), zt(), Z();
5354
- let e = F.current;
6725
+ V(null), Y(), X(), Ut(), qt(), Z();
6726
+ let e = I.current;
5355
6727
  e && (e.getCanvas().style.cursor = "crosshair");
5356
6728
  } else if (e === "polyline") {
5357
- B(null), Y(), X(), Ft(), zt(), Wt();
5358
- let e = F.current;
6729
+ V(null), Y(), X(), Ut(), qt(), Qt();
6730
+ let e = I.current;
5359
6731
  e && (e.getCanvas().style.cursor = "crosshair");
5360
- } else e === "marker" ? (X(), Ft(), zt(), Wt(), Z()) : (B(null), Y(), X(), Ft(), zt(), Wt(), Z());
6732
+ } else e === "marker" ? (X(), Ut(), qt(), Qt(), Z()) : (V(null), Y(), X(), Ut(), qt(), Qt(), Z());
5361
6733
  }, [
5362
6734
  Y,
5363
6735
  X,
5364
- Ft,
5365
- zt,
5366
- Wt,
6736
+ Ut,
6737
+ qt,
6738
+ Qt,
5367
6739
  Z
5368
- ]), Xt = useCallback((e) => {
6740
+ ]), an = useCallback((e) => {
5369
6741
  if (e !== "picker") {
5370
6742
  let e = y.value && isFinite(y.value.lng) && isFinite(y.value.lat), t = y.showMarker !== !1;
5371
- (!e || !t) && Ct(), tt(null);
6743
+ (!e || !t) && jt(), rt(null);
5372
6744
  }
5373
- e !== "edit" && (B(null), V(null), X(), Z(), Y()), $e(e);
6745
+ e !== "edit" && (V(null), H(null), X(), Z(), Y()), tt(e);
5374
6746
  }, [
5375
- Ct,
6747
+ jt,
5376
6748
  Y,
5377
6749
  X,
5378
6750
  Z
5379
- ]), Zt = useCallback(() => z, [z]), Qt = useCallback(() => et, [et]), $t = useCallback(() => {
5380
- Ct(), tt(null);
5381
- }, [Ct]);
6751
+ ]), on = useCallback(() => et, [et]), sn = useCallback(() => nt, [nt]), cn = useCallback(() => {
6752
+ jt(), rt(null);
6753
+ }, [jt]);
5382
6754
  useEffect(() => {
5383
- if (!Ze) return;
6755
+ if (!B) return;
5384
6756
  let e = y.value;
5385
6757
  if (e && isFinite(e.lng) && isFinite(e.lat)) {
5386
6758
  let t = [e.lng, e.lat];
5387
- tt(e), St(t);
6759
+ rt(e), At(t);
5388
6760
  }
5389
6761
  }, [
5390
6762
  y.value,
5391
- St,
5392
- Ze
6763
+ At,
6764
+ B
5393
6765
  ]);
5394
- let en = (e) => "mode" in e, tn = useCallback((e) => {
5395
- if ($e("edit"), Ct(), tt(null), H.current = !0, en(e)) {
5396
- if (e.mode === "marker") e.markerStyle ? (W.current = e.markerStyle, U.current = null, G.current = null, K.current = null, q.current = null, J.current = null, B(null), V("marker"), e.markerStyle.src && e.markerStyle.width ? Tt({
6766
+ let ln = (e) => "mode" in e, un = useCallback((e) => {
6767
+ if (tt("edit"), jt(), rt(null), U.current = !0, ln(e)) {
6768
+ if (e.mode === "marker") e.markerStyle ? (lt.current = e.markerStyle, W.current = null, G.current = null, K.current = null, q.current = null, pt.current = null, V(null), H("marker"), e.markerStyle.src && e.markerStyle.width ? Nt({
5397
6769
  id: "custom",
5398
6770
  name: e.markerStyle.name || "Marker",
5399
6771
  icon: e.markerStyle.src,
5400
6772
  width: e.markerStyle.width
5401
- }) : Y()) : e.template && (W.current = null, U.current = null, G.current = null, K.current = null, q.current = null, J.current = null, B(e.template), V("marker"), Tt(e.template));
6773
+ }) : Y()) : e.template && (lt.current = null, W.current = null, G.current = null, K.current = null, q.current = null, pt.current = null, V(e.template), H("marker"), Nt(e.template));
5402
6774
  else if (e.mode === "rectangle") {
5403
- U.current = e.rectangleStyle || null, W.current = null, G.current = null, K.current = null, q.current = null, J.current = null, B(null), V("rectangle"), Y();
5404
- let t = F.current;
6775
+ W.current = e.rectangleStyle || null, lt.current = null, G.current = null, K.current = null, q.current = null, pt.current = null, V(null), H("rectangle"), Y();
6776
+ let t = I.current;
5405
6777
  t && (t.getCanvas().style.cursor = "crosshair");
5406
6778
  } else if (e.mode === "circle") {
5407
- G.current = e.circleStyle || null, U.current = null, W.current = null, K.current = null, q.current = null, J.current = null, B(null), V("circle"), Y();
5408
- let t = F.current;
6779
+ G.current = e.circleStyle || null, W.current = null, lt.current = null, K.current = null, q.current = null, pt.current = null, V(null), H("circle"), Y();
6780
+ let t = I.current;
5409
6781
  t && (t.getCanvas().style.cursor = "crosshair");
5410
6782
  } else if (e.mode === "polygon") {
5411
- K.current = e.polygonStyle || null, U.current = null, W.current = null, G.current = null, q.current = null, J.current = null, B(null), V("polygon"), Y();
5412
- let t = F.current;
6783
+ K.current = e.polygonStyle || null, W.current = null, lt.current = null, G.current = null, q.current = null, pt.current = null, V(null), H("polygon"), Y();
6784
+ let t = I.current;
5413
6785
  t && (t.getCanvas().style.cursor = "crosshair");
5414
6786
  } else if (e.mode === "square") {
5415
- q.current = e.squareStyle || null, U.current = null, W.current = null, G.current = null, K.current = null, J.current = null, B(null), V("square"), Y();
5416
- let t = F.current;
6787
+ q.current = e.squareStyle || null, W.current = null, lt.current = null, G.current = null, K.current = null, pt.current = null, V(null), H("square"), Y();
6788
+ let t = I.current;
5417
6789
  t && (t.getCanvas().style.cursor = "crosshair");
5418
6790
  } else if (e.mode === "polyline") {
5419
- J.current = e.polylineStyle || null, U.current = null, W.current = null, G.current = null, K.current = null, q.current = null, B(null), V("polyline"), Y();
5420
- let t = F.current;
6791
+ pt.current = e.polylineStyle || null, W.current = null, lt.current = null, G.current = null, K.current = null, q.current = null, V(null), H("polyline"), Y();
6792
+ let t = I.current;
5421
6793
  t && (t.getCanvas().style.cursor = "crosshair");
5422
6794
  }
5423
- } else B(e), V("marker"), Tt(e), U.current = null, W.current = null, G.current = null, K.current = null, q.current = null, J.current = null;
6795
+ } else V(e), H("marker"), Nt(e), W.current = null, lt.current = null, G.current = null, K.current = null, q.current = null, pt.current = null;
5424
6796
  }, [
5425
- Ct,
5426
- Tt,
6797
+ jt,
6798
+ Nt,
5427
6799
  Y
5428
6800
  ]);
5429
6801
  useImperativeHandle(c, () => ({
5430
- startAnimation: ft,
5431
- stopAnimation: pt,
5432
- toggleAnimation: mt,
5433
- getMap: () => F.current,
5434
- openPopup: (e) => gt(e, "programmatic"),
5435
- closePopup: _t,
5436
- closeAllPopups: vt,
5437
- isPopupOpen: yt,
5438
- toggleUnitTrajectory: ht,
5439
- flyTo: bt,
5440
- flyToEntities: xt,
5441
- getMode: Zt,
5442
- setMode: Xt,
5443
- getPickedLocation: Qt,
5444
- clearPickedLocation: $t,
5445
- startDrawing: tn,
5446
- getRenderer: (e) => I.current.get(e)
6802
+ startAnimation: bt,
6803
+ stopAnimation: xt,
6804
+ toggleAnimation: St,
6805
+ getMap: () => I.current,
6806
+ openPopup: (e) => wt(e, "programmatic"),
6807
+ closePopup: Tt,
6808
+ closeAllPopups: Et,
6809
+ isPopupOpen: Dt,
6810
+ toggleUnitTrajectory: Ct,
6811
+ flyTo: Ot,
6812
+ flyToEntities: kt,
6813
+ getMode: on,
6814
+ setMode: an,
6815
+ getPickedLocation: sn,
6816
+ clearPickedLocation: cn,
6817
+ startDrawing: un,
6818
+ getRenderer: (e) => L.current.get(e),
6819
+ setEditingEntities: (e) => {
6820
+ for (let t of yt.current) e.map(String).includes(String(t)) || L.current.get(t)?.setEditing?.(!1);
6821
+ for (let t of e) L.current.get(t)?.setEditing?.(!0);
6822
+ J.current &&= (L.current.get(J.current.entityId)?.cancelEditPreview?.(), null), vt(e);
6823
+ },
6824
+ getEditingEntities: () => yt.current,
6825
+ startRoutePlanning: (e) => {
6826
+ Ue.current?.startPlanning(e);
6827
+ }
5447
6828
  }), [
5448
- ft,
5449
- pt,
5450
- mt,
5451
- gt,
5452
- _t,
5453
- vt,
5454
- yt,
5455
- ht,
5456
6829
  bt,
5457
6830
  xt,
5458
- Zt,
5459
- Xt,
5460
- Qt,
5461
- $t,
5462
- tn
6831
+ St,
6832
+ wt,
6833
+ Tt,
6834
+ Et,
6835
+ Dt,
6836
+ Ct,
6837
+ Ot,
6838
+ kt,
6839
+ on,
6840
+ an,
6841
+ sn,
6842
+ cn,
6843
+ un
5463
6844
  ]);
5464
- let nn = useCallback(() => {
5465
- let e = F.current;
6845
+ let dn = useCallback(() => {
6846
+ let e = I.current;
5466
6847
  if (!e) return;
5467
- let t = new Set(E.map((e) => e.id)), n = new Set(I.current.keys());
5468
- for (let e of n) t.has(e) || (I.current.get(e)?.destroy(), I.current.delete(e));
5469
- let r = new Set(D.map(String));
5470
- for (let t of E) {
5471
- let n = applyEntityConfig(t, O), i = I.current.get(n.id);
6848
+ let t = new Set(T.map((e) => e.id)), n = new Set(L.current.keys());
6849
+ for (let e of n) t.has(e) || (L.current.get(e)?.destroy(), L.current.delete(e));
6850
+ let r = new Set(E.map(String));
6851
+ for (let t of T) {
6852
+ let n = applyEntityConfig(t, D), i = L.current.get(n.id);
5472
6853
  if (i) if (n.type === "radar" && i instanceof CanvasRadarRenderer) i.update(n);
5473
6854
  else if (n.type === "image" && i instanceof CanvasImageRenderer) i.update(n);
5474
6855
  else if (n.type === "marker" && i instanceof MarkerRenderer) i.update(n);
@@ -5477,34 +6858,38 @@ const Mapbox = forwardRef((e, c) => {
5477
6858
  else if (n.type === "circle") if (n.fillType === "radial-gradient") if (i instanceof CanvasCircleRenderer) i.update(n);
5478
6859
  else {
5479
6860
  i.destroy();
5480
- let t = new CanvasCircleRenderer(e, n, k, A, j, M);
5481
- I.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
6861
+ let t = new CanvasCircleRenderer(e, n, O, k, A, j);
6862
+ L.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
5482
6863
  }
5483
6864
  else if (i instanceof CircleRenderer) i.update(n);
5484
6865
  else {
5485
6866
  i.destroy();
5486
- let t = new CircleRenderer(e, n, k, A, j, M);
5487
- I.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
6867
+ let t = new CircleRenderer(e, n, O, k, A, j);
6868
+ L.current.set(n.id, t), t.setSelected(r.has(String(n.id)));
5488
6869
  }
5489
6870
  else (n.type === "square" && i instanceof SquareRenderer || n.type === "rectangle" && i instanceof RectangleRenderer || n.type === "polyline" && i instanceof PolylineRenderer) && i.update(n);
5490
6871
  else {
5491
6872
  let t = null;
5492
- n.type === "radar" ? t = new CanvasRadarRenderer(e, n, k, A) : n.type === "image" ? t = new CanvasImageRenderer(e, n, k, A) : n.type === "marker" ? t = new MarkerRenderer(e, n, k, A) : n.type === "unit" ? t = new UnitRenderer(e, n, k, A) : n.type === "polygon" ? t = new PolygonRenderer(e, n, k, A, j, N) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, k, A, j, M) : new CircleRenderer(e, n, k, A, j, M) : n.type === "square" ? t = new SquareRenderer(e, n, k, A, j, N) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, k, A, j, N) : n.type === "polyline" && (t = new PolylineRenderer(e, n, k, A, N)), t && (I.current.set(n.id, t), t.setSelected(r.has(String(n.id))));
6873
+ n.type === "radar" ? t = new CanvasRadarRenderer(e, n, O, k) : n.type === "image" ? t = new CanvasImageRenderer(e, n, O, k) : n.type === "marker" ? t = new MarkerRenderer(e, n, O, k) : n.type === "unit" ? t = new UnitRenderer(e, n, O, k) : n.type === "polygon" ? t = new PolygonRenderer(e, n, O, k, A, M) : n.type === "circle" ? t = n.fillType === "radial-gradient" ? new CanvasCircleRenderer(e, n, O, k, A, j) : new CircleRenderer(e, n, O, k, A, j) : n.type === "square" ? t = new SquareRenderer(e, n, O, k, A, M) : n.type === "rectangle" ? t = new RectangleRenderer(e, n, O, k, A, M) : n.type === "polyline" && (t = new PolylineRenderer(e, n, O, k, M)), t && (L.current.set(n.id, t), t.setSelected(r.has(String(n.id))), yt.current.map(String).includes(String(n.id)) && t.setEditing?.(!0));
5493
6874
  }
5494
6875
  }
6876
+ for (let e of yt.current) {
6877
+ let t = L.current.get(e);
6878
+ t && t.setEditing?.(!0);
6879
+ }
5495
6880
  }, [
6881
+ T,
5496
6882
  E,
5497
6883
  D,
5498
6884
  O,
5499
6885
  k,
5500
6886
  A,
5501
6887
  j,
5502
- M,
5503
- N
5504
- ]), rn = useCallback(() => {
5505
- for (let e of I.current.values()) e.destroy();
5506
- I.current.clear();
5507
- }, []), an = useCallback((e) => {
6888
+ M
6889
+ ]), fn = useCallback(() => {
6890
+ for (let e of L.current.values()) e.destroy();
6891
+ L.current.clear();
6892
+ }, []), pn = useCallback((e) => {
5508
6893
  let t = e.getStyle();
5509
6894
  if (!t?.layers) return;
5510
6895
  let n = [
@@ -5519,10 +6904,10 @@ const Mapbox = forwardRef((e, c) => {
5519
6904
  "marker-"
5520
6905
  ];
5521
6906
  for (let e of t.layers) if (n.some((t) => e.id.startsWith(t))) return e.id;
5522
- }, []), on = useCallback((e) => {
5523
- let t = T, 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;
6907
+ }, []), mn = useCallback((e) => {
6908
+ let t = w, 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;
5524
6909
  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;
5525
- }, [T]), sn = useCallback((e, t) => {
6910
+ }, [w]), hn = useCallback((e, t) => {
5526
6911
  let n = `base-layer-source-${t.id}`, r = `base-layer-${t.id}`, i = {
5527
6912
  type: "raster",
5528
6913
  tiles: [t.url],
@@ -5532,27 +6917,28 @@ const Mapbox = forwardRef((e, c) => {
5532
6917
  scheme: t.scheme ?? "xyz"
5533
6918
  };
5534
6919
  t.bounds && (i.bounds = t.bounds), t.attribution && (i.attribution = t.attribution), e.addSource(n, i);
5535
- let a = an(e);
6920
+ let a = pn(e);
5536
6921
  e.addLayer({
5537
6922
  id: r,
5538
6923
  type: "raster",
5539
6924
  source: n,
5540
- paint: on(t),
6925
+ paint: mn(t),
5541
6926
  layout: { visibility: t.visible === !1 ? "none" : "visible" }
5542
6927
  }, a);
5543
- }, [an, on]), cn = useCallback(async (e, t) => {
6928
+ }, [pn, mn]), gn = useCallback(async (e, t) => {
5544
6929
  try {
5545
6930
  let n = await (await fetch(t.url)).json(), r = `base-layer-source-${t.id}`, i = `base-layer-${t.id}`;
5546
- if (!He.current.has(t.id)) return;
5547
- let a = n.format === "pbf" || n.vector_layers, o = an(e);
5548
- a ? (e.addSource(r, {
5549
- type: "vector",
5550
- tiles: n.tiles,
5551
- minzoom: n.minzoom ?? 0,
5552
- maxzoom: n.maxzoom ?? 22,
5553
- bounds: n.bounds,
5554
- attribution: n.attribution
5555
- }), console.warn(`TileJSON "${t.id}" 是矢量瓦片,建议使用 type: 'style' 加载完整样式`)) : (e.addSource(r, {
6931
+ if (!We.current.has(t.id)) return;
6932
+ let a = n.format === "pbf" || n.vector_layers, o = pn(e);
6933
+ if (a) {
6934
+ let t = {
6935
+ type: "vector",
6936
+ tiles: n.tiles,
6937
+ minzoom: n.minzoom ?? 0,
6938
+ maxzoom: n.maxzoom ?? 22
6939
+ };
6940
+ n.bounds && (t.bounds = n.bounds), n.attribution && (t.attribution = n.attribution), e.addSource(r, t);
6941
+ } else e.addSource(r, {
5556
6942
  type: "raster",
5557
6943
  tiles: n.tiles,
5558
6944
  tileSize: t.tileSize ?? n.tileSize ?? 256,
@@ -5564,21 +6950,21 @@ const Mapbox = forwardRef((e, c) => {
5564
6950
  id: i,
5565
6951
  type: "raster",
5566
6952
  source: r,
5567
- paint: on(t),
6953
+ paint: mn(t),
5568
6954
  layout: { visibility: t.visible === !1 ? "none" : "visible" }
5569
- }, o));
6955
+ }, o);
5570
6956
  } catch (e) {
5571
6957
  console.error(`Failed to load TileJSON from ${t.url}:`, e);
5572
6958
  }
5573
- }, [an, on]), ln = useCallback(async (e, t) => {
6959
+ }, [pn, mn]), _n = useCallback(async (e, t) => {
5574
6960
  try {
5575
6961
  let n = await (await fetch(t.url)).json();
5576
- if (!He.current.has(t.id)) return;
6962
+ if (!We.current.has(t.id)) return;
5577
6963
  if (n.sources) for (let [r, i] of Object.entries(n.sources)) {
5578
6964
  let n = `base-layer-source-${t.id}-${r}`;
5579
6965
  e.getSource(n) || e.addSource(n, i);
5580
6966
  }
5581
- let r = an(e);
6967
+ let r = pn(e);
5582
6968
  if (n.layers) for (let i of n.layers) {
5583
6969
  let n = `base-layer-${t.id}-${i.id}`;
5584
6970
  if (e.getLayer(n)) continue;
@@ -5589,7 +6975,7 @@ const Mapbox = forwardRef((e, c) => {
5589
6975
  };
5590
6976
  i.type === "raster" && (a.paint = {
5591
6977
  ...a.paint,
5592
- ...on(t)
6978
+ ...mn(t)
5593
6979
  }), t.visible === !1 && (a.layout = {
5594
6980
  ...a.layout,
5595
6981
  visibility: "none"
@@ -5602,50 +6988,50 @@ const Mapbox = forwardRef((e, c) => {
5602
6988
  } catch (e) {
5603
6989
  console.error(`Failed to load Style JSON from ${t.url}:`, e);
5604
6990
  }
5605
- }, [an, on]), un = useCallback((e, t) => {
6991
+ }, [pn, mn]), vn = useCallback((e, t) => {
5606
6992
  let n = e.getStyle();
5607
6993
  if (!n) return;
5608
6994
  let r = `base-layer-${t}`, i = n.layers?.filter((e) => e.id.startsWith(r)) ?? [];
5609
6995
  for (let t of i) e.getLayer(t.id) && e.removeLayer(t.id);
5610
6996
  let a = `base-layer-source-${t}`, o = n.sources ?? {};
5611
6997
  for (let t of Object.keys(o)) t.startsWith(a) && e.getSource(t) && e.removeSource(t);
5612
- }, []), dn = useCallback((e) => {
5613
- let t = F.current;
6998
+ }, []), yn = useCallback((e) => {
6999
+ let t = I.current;
5614
7000
  if (!t) return;
5615
- let n = new Set(e.map((e) => e.id)), r = He.current;
5616
- for (let e of r) n.has(e) || (un(t, e), r.delete(e));
7001
+ let n = new Set(e.map((e) => e.id)), r = We.current;
7002
+ for (let e of r) n.has(e) || (vn(t, e), r.delete(e));
5617
7003
  for (let n of e) if (r.has(n.id)) {
5618
7004
  let e = `base-layer-${n.id}`;
5619
7005
  if (t.getLayer(e)) {
5620
- let r = on(n);
7006
+ let r = mn(n);
5621
7007
  for (let [n, i] of Object.entries(r)) t.setPaintProperty(e, n, i);
5622
7008
  t.setLayoutProperty(e, "visibility", n.visible === !1 ? "none" : "visible");
5623
7009
  }
5624
7010
  } else switch (r.add(n.id), n.type) {
5625
7011
  case "raster":
5626
- sn(t, n);
7012
+ hn(t, n);
5627
7013
  break;
5628
7014
  case "tilejson":
5629
- cn(t, n);
7015
+ gn(t, n);
5630
7016
  break;
5631
7017
  case "style":
5632
- ln(t, n);
7018
+ _n(t, n);
5633
7019
  break;
5634
7020
  default: {
5635
7021
  let e = n;
5636
- e.url && sn(t, {
7022
+ e.url && hn(t, {
5637
7023
  ...e,
5638
7024
  type: "raster"
5639
7025
  });
5640
7026
  }
5641
7027
  }
5642
7028
  }, [
5643
- sn,
5644
- cn,
5645
- ln,
5646
- un,
5647
- on
5648
- ]), fn = useCallback((e) => {
7029
+ hn,
7030
+ gn,
7031
+ _n,
7032
+ vn,
7033
+ mn
7034
+ ]), bn = useCallback((e) => {
5649
7035
  let t = e;
5650
7036
  for (; t;) {
5651
7037
  let e = t.getAttribute?.("data-entity-id");
@@ -5653,293 +7039,353 @@ const Mapbox = forwardRef((e, c) => {
5653
7039
  t = t.parentElement;
5654
7040
  }
5655
7041
  return null;
5656
- }, []), pn = useCallback((e) => {
7042
+ }, []), xn = useCallback((e) => {
5657
7043
  let t = [e.lngLat.lng, e.lngLat.lat], n = {
5658
7044
  x: e.point.x,
5659
7045
  y: e.point.y
5660
- }, r = xn.current;
7046
+ }, r = kn.current;
5661
7047
  if (r === "picker") {
5662
7048
  let e = {
5663
7049
  lng: t[0],
5664
7050
  lat: t[1]
5665
7051
  };
5666
- tt(e), St(t), Sn.current?.(e);
7052
+ rt(e), At(t), An.current?.(e);
5667
7053
  return;
5668
7054
  }
7055
+ if (gt.current) return;
5669
7056
  if (r === "edit") {
5670
- let e = wn.current;
7057
+ let e = Mn.current;
5671
7058
  if (e === "rectangle") {
5672
- let e = Tn.current;
5673
- if (!e) ot(t);
7059
+ let e = Nn.current;
7060
+ if (!e) ct(t);
5674
7061
  else {
5675
- let n = U.current, r = applyEntityConfig({
7062
+ let n = W.current, r = applyEntityConfig({
5676
7063
  ...n,
5677
- id: n?.id ?? wt(),
7064
+ id: n?.id ?? Mt(),
5678
7065
  type: "rectangle",
5679
7066
  bounds: [e, t]
5680
- }, O);
5681
- kt();
5682
- let i = F.current;
5683
- if (i && !I.current.has(r.id)) {
5684
- let e = new RectangleRenderer(i, r, k, A, j, N);
5685
- I.current.set(r.id, e);
7067
+ }, D);
7068
+ Lt();
7069
+ let i = I.current;
7070
+ if (i && !L.current.has(r.id)) {
7071
+ let e = new RectangleRenderer(i, r, O, k, A, M);
7072
+ L.current.set(r.id, e);
5686
7073
  }
5687
- Q.current.onRectangleAdd?.(r), ot(null), U.current = null, H.current && (H.current = !1, V(null), i && (i.getCanvas().style.cursor = ""));
7074
+ Q.current.onRectangleAdd?.(r), ct(null), W.current = null, U.current && (U.current = !1, H(null), i && (i.getCanvas().style.cursor = ""));
5688
7075
  }
5689
7076
  return;
5690
7077
  }
5691
7078
  if (e === "circle") {
5692
- let e = st.current;
5693
- if (!e) st.current = { center: t };
7079
+ let e = ut.current;
7080
+ if (!e) ut.current = { center: t };
5694
7081
  else {
5695
- let n = Mt(e.center, t), r = G.current, i = applyEntityConfig({
7082
+ let n = Bt(e.center, t), r = G.current, i = applyEntityConfig({
5696
7083
  ...r,
5697
- id: r?.id ?? wt(),
7084
+ id: r?.id ?? Mt(),
5698
7085
  type: "circle",
5699
7086
  center: e.center,
5700
7087
  radius: n
5701
- }, O);
5702
- Pt();
5703
- let a = F.current;
5704
- if (a && !I.current.has(i.id)) {
5705
- let e = new CircleRenderer(a, i, k, A, j, M);
5706
- I.current.set(i.id, e);
7088
+ }, D);
7089
+ Ht();
7090
+ let a = I.current;
7091
+ if (a && !L.current.has(i.id)) {
7092
+ let e = new CircleRenderer(a, i, O, k, A, j);
7093
+ L.current.set(i.id, e);
5707
7094
  }
5708
- Q.current.onCircleAdd?.(i), st.current = null, G.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
7095
+ Q.current.onCircleAdd?.(i), ut.current = null, G.current = null, U.current && (U.current = !1, H(null), a && (a.getCanvas().style.cursor = ""));
5709
7096
  }
5710
7097
  return;
5711
7098
  }
5712
7099
  if (e === "polygon") {
5713
- let e = ct.current;
7100
+ let e = dt.current;
5714
7101
  if (e.length >= 3) {
5715
7102
  let n = e[0];
5716
- if (Mt(n, t) < 20) {
7103
+ if (Bt(n, t) < 20) {
5717
7104
  let t = K.current, n = applyEntityConfig({
5718
7105
  ...t,
5719
- id: t?.id ?? wt(),
7106
+ id: t?.id ?? Mt(),
5720
7107
  type: "polygon",
5721
7108
  coordinates: [...e]
5722
- }, O);
5723
- Rt();
5724
- let r = F.current;
5725
- if (r && !I.current.has(n.id)) {
5726
- let e = new PolygonRenderer(r, n, k, A, j, N);
5727
- I.current.set(n.id, e);
7109
+ }, D);
7110
+ Kt();
7111
+ let r = I.current;
7112
+ if (r && !L.current.has(n.id)) {
7113
+ let e = new PolygonRenderer(r, n, O, k, A, M);
7114
+ L.current.set(n.id, e);
5728
7115
  }
5729
- Q.current.onPolygonAdd?.(n), ct.current = [], K.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
7116
+ Q.current.onPolygonAdd?.(n), dt.current = [], K.current = null, U.current && (U.current = !1, H(null), r && (r.getCanvas().style.cursor = ""));
5730
7117
  return;
5731
7118
  }
5732
7119
  }
5733
- ct.current = [...e, t];
7120
+ dt.current = [...e, t];
5734
7121
  return;
5735
7122
  }
5736
7123
  if (e === "square") {
5737
- let e = lt.current;
5738
- if (!e) lt.current = { center: t };
7124
+ let e = ft.current;
7125
+ if (!e) ft.current = { center: t };
5739
7126
  else {
5740
- let n = Mt(e.center, t) * 2, r = q.current, i = applyEntityConfig({
7127
+ let n = Bt(e.center, t) * 2, r = q.current, i = applyEntityConfig({
5741
7128
  ...r,
5742
- id: r?.id ?? wt(),
7129
+ id: r?.id ?? Mt(),
5743
7130
  type: "square",
5744
7131
  center: e.center,
5745
7132
  length: n
5746
- }, O);
5747
- Ut();
5748
- let a = F.current;
5749
- if (a && !I.current.has(i.id)) {
5750
- let e = new SquareRenderer(a, i, k, A, j, N);
5751
- I.current.set(i.id, e);
7133
+ }, D);
7134
+ Zt();
7135
+ let a = I.current;
7136
+ if (a && !L.current.has(i.id)) {
7137
+ let e = new SquareRenderer(a, i, O, k, A, M);
7138
+ L.current.set(i.id, e);
5752
7139
  }
5753
- Q.current.onSquareAdd?.(i), lt.current = null, q.current = null, H.current && (H.current = !1, V(null), a && (a.getCanvas().style.cursor = ""));
7140
+ Q.current.onSquareAdd?.(i), ft.current = null, q.current = null, U.current && (U.current = !1, H(null), a && (a.getCanvas().style.cursor = ""));
5754
7141
  }
5755
7142
  return;
5756
7143
  }
5757
7144
  if (e === "polyline") {
5758
- ut.current = [...ut.current, t];
7145
+ mt.current = [...mt.current, t];
5759
7146
  return;
5760
7147
  }
5761
- let n = W.current;
7148
+ let n = lt.current;
5762
7149
  if (n && n.src && n.width) {
5763
7150
  let e = {
5764
7151
  ...n,
5765
- id: n.id ?? wt(),
7152
+ id: n.id ?? Mt(),
5766
7153
  type: "marker",
5767
7154
  center: t,
5768
7155
  src: n.src,
5769
7156
  width: n.width
5770
7157
  };
5771
- Q.current.onMarkerAdd?.(e), B(null), V(null), Y(), W.current = null, H.current = !1;
7158
+ Q.current.onMarkerAdd?.(e), V(null), H(null), Y(), lt.current = null, U.current = !1;
5772
7159
  return;
5773
7160
  }
5774
- let r = Cn.current;
7161
+ let r = jn.current;
5775
7162
  if (r) {
5776
7163
  let e = {
5777
- id: wt(),
7164
+ id: Mt(),
5778
7165
  type: "marker",
5779
7166
  name: r.name,
5780
7167
  center: t,
5781
7168
  src: r.icon,
5782
7169
  width: r.size || r.width || 32
5783
7170
  };
5784
- r.customData !== void 0 && (e.customData = r.customData), Q.current.onMarkerAdd?.(e), B(null), V(null), Y(), H.current = !1;
7171
+ r.customData !== void 0 && (e.customData = r.customData), Q.current.onMarkerAdd?.(e), V(null), H(null), Y(), U.current = !1;
5785
7172
  return;
5786
7173
  }
5787
7174
  }
5788
- let i = vn.current, a = yn.current, o = bn.current, s = fn(e.originalEvent.target);
7175
+ if (yt.current.length > 0) {
7176
+ let e = I.current?.getZoom() ?? 12;
7177
+ if (J.current) {
7178
+ let { entityId: e, activeHandle: n } = J.current, r = L.current.get(e);
7179
+ if (r?.applyHandleMove) {
7180
+ let e = r.applyHandleMove(n, t);
7181
+ Q.current.onEntityEdit?.(e);
7182
+ }
7183
+ J.current = null;
7184
+ return;
7185
+ }
7186
+ for (let n of yt.current) {
7187
+ let r = L.current.get(n);
7188
+ if (!r?.getEditHandleAt) continue;
7189
+ let i = r.getEditHandleAt(t, e);
7190
+ if (i) {
7191
+ if (i.type === "midpoint" && r.addVertex) {
7192
+ let e = r.addVertex(i.index, i.position);
7193
+ Q.current.onEntityEdit?.(e), J.current = {
7194
+ entityId: n,
7195
+ activeHandle: {
7196
+ type: "vertex",
7197
+ index: i.index + 1,
7198
+ position: i.position
7199
+ }
7200
+ };
7201
+ } else J.current = {
7202
+ entityId: n,
7203
+ activeHandle: i
7204
+ };
7205
+ return;
7206
+ }
7207
+ }
7208
+ }
7209
+ let i = En.current, a = Dn.current, o = On.current, s = bn(e.originalEvent.target);
5789
7210
  if (s) {
5790
7211
  let e = i.find((e) => String(e.id) === s);
5791
7212
  if (e) {
5792
7213
  if (a?.(e), e.popup) {
5793
- let t = e.popup.content ?? Pe?.(e);
5794
- t && mergePopupConfig(e.popup, P, t).trigger === "click" && o(s, "click", n);
7214
+ let t = e.popup.content ?? Fe?.(e);
7215
+ t && mergePopupConfig(e.popup, F, t).trigger === "click" && o(s, "click", n);
5795
7216
  }
5796
7217
  return;
5797
7218
  }
5798
7219
  }
5799
- for (let [t, r] of I.current) {
7220
+ for (let [t, r] of L.current) {
5800
7221
  let s = r.getLabelLayerId();
5801
- if (s && F.current?.getLayer(s) && F.current.queryRenderedFeatures(e.point, { layers: [s] }).length > 0) {
7222
+ if (s && I.current?.getLayer(s) && I.current.queryRenderedFeatures(e.point, { layers: [s] }).length > 0) {
5802
7223
  let e = i.find((e) => e.id === t);
5803
7224
  if (e) {
5804
7225
  if (a?.(e), e.popup) {
5805
- let r = e.popup.content ?? Pe?.(e);
5806
- r && mergePopupConfig(e.popup, P, r).trigger === "click" && o(t, "click", n);
7226
+ let r = e.popup.content ?? Fe?.(e);
7227
+ r && mergePopupConfig(e.popup, F, r).trigger === "click" && o(t, "click", n);
5807
7228
  }
5808
7229
  return;
5809
7230
  }
5810
7231
  }
5811
7232
  }
5812
- for (let [e, r] of I.current) if (r.isPointInEntity(t)) {
7233
+ for (let [e, r] of L.current) if (r.isPointInEntity(t)) {
5813
7234
  let t = i.find((t) => t.id === e);
5814
7235
  if (t) {
5815
7236
  if (a?.(t), t.popup) {
5816
- let r = t.popup.content ?? Pe?.(t);
5817
- r && mergePopupConfig(t.popup, P, r).trigger === "click" && o(e, "click", n);
7237
+ let r = t.popup.content ?? Fe?.(t);
7238
+ r && mergePopupConfig(t.popup, F, r).trigger === "click" && o(e, "click", n);
5818
7239
  }
5819
7240
  return;
5820
7241
  }
5821
7242
  }
5822
7243
  }, [
5823
- P,
5824
- Pe,
5825
- fn
5826
- ]), mn = useCallback((e) => {
5827
- let t = [e.lngLat.lng, e.lngLat.lat], n = wn.current, r = Tn.current;
5828
- n === "rectangle" && r && Ot(r, t);
5829
- let i = st.current;
5830
- n === "circle" && i && Nt(i.center, t);
5831
- let a = ct.current;
5832
- n === "polygon" && a.length > 0 && Lt(a, t);
5833
- let o = lt.current;
5834
- n === "square" && o && Ht(o.center, t);
5835
- let s = ut.current;
5836
- n === "polyline" && s.length > 0 && Kt(s, t);
5837
- let c = vn.current, l = bn.current;
5838
- for (let [e, n] of I.current) if (n.isPointInEntity(t)) {
7244
+ F,
7245
+ Fe,
7246
+ bn
7247
+ ]), Sn = useCallback((e) => {
7248
+ let t = [e.lngLat.lng, e.lngLat.lat];
7249
+ if (J.current) {
7250
+ let { entityId: e, activeHandle: n } = J.current;
7251
+ L.current.get(e)?.updateEditPreview?.(n, t);
7252
+ return;
7253
+ }
7254
+ let n = Mn.current, r = Nn.current;
7255
+ n === "rectangle" && r && It(r, t);
7256
+ let i = ut.current;
7257
+ n === "circle" && i && Vt(i.center, t);
7258
+ let a = dt.current;
7259
+ n === "polygon" && a.length > 0 && Gt(a, t);
7260
+ let o = ft.current;
7261
+ n === "square" && o && Xt(o.center, t);
7262
+ let s = mt.current;
7263
+ n === "polyline" && s.length > 0 && en(s, t);
7264
+ let c = En.current, l = On.current;
7265
+ for (let [e, n] of L.current) if (n.isPointInEntity(t)) {
5839
7266
  let t = c.find((t) => t.id === e);
5840
7267
  if (!t?.popup) continue;
5841
- let n = t.popup.content ?? Pe?.(t);
7268
+ let n = t.popup.content ?? Fe?.(t);
5842
7269
  if (!n) continue;
5843
- let r = mergePopupConfig(t.popup, P, n);
7270
+ let r = mergePopupConfig(t.popup, F, n);
5844
7271
  if (r.trigger === "hover") {
5845
- Ke.current && clearTimeout(Ke.current), Ke.current = window.setTimeout(() => {
7272
+ Je.current && clearTimeout(Je.current), Je.current = window.setTimeout(() => {
5846
7273
  l(e, "hover");
5847
7274
  }, r.hoverDelay);
5848
7275
  return;
5849
7276
  }
5850
7277
  }
5851
- if (Ke.current &&= (clearTimeout(Ke.current), null), R?.openedBy === "hover") {
5852
- let e = I.current.get(R.entityId);
5853
- e && !e.isPointInEntity(t) && _t(R.entityId);
7278
+ if (Je.current &&= (clearTimeout(Je.current), null), z?.openedBy === "hover") {
7279
+ let e = L.current.get(z.entityId);
7280
+ e && !e.isPointInEntity(t) && Tt(z.entityId);
5854
7281
  }
5855
7282
  }, [
5856
- P,
5857
- Pe,
5858
- R,
5859
- _t,
5860
- Ot,
5861
- Nt,
5862
- Lt,
5863
- Ht,
5864
- Kt
5865
- ]), hn = useCallback((e) => {
5866
- if (e.preventDefault(), xn.current !== "edit") return;
5867
- if (Cn.current) {
5868
- B(null), V(null), Y();
7283
+ F,
7284
+ Fe,
7285
+ z,
7286
+ Tt,
7287
+ It,
7288
+ Vt,
7289
+ Gt,
7290
+ Xt,
7291
+ en
7292
+ ]), Cn = useCallback((e) => {
7293
+ if (e.preventDefault(), gt.current) return;
7294
+ if (yt.current.length > 0) {
7295
+ let t = [e.lngLat.lng, e.lngLat.lat];
7296
+ if (J.current) {
7297
+ L.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
7298
+ return;
7299
+ }
7300
+ let n = I.current?.getZoom() ?? 12;
7301
+ for (let e of yt.current) {
7302
+ let r = L.current.get(e);
7303
+ if (!r?.getEditHandleAt || !r.deleteVertex) continue;
7304
+ let i = r.getEditHandleAt(t, n);
7305
+ if (i && i.type === "vertex") {
7306
+ let e = r.deleteVertex(i.index);
7307
+ e && Q.current.onEntityEdit?.(e);
7308
+ return;
7309
+ }
7310
+ }
7311
+ }
7312
+ if (kn.current !== "edit") return;
7313
+ if (jn.current) {
7314
+ V(null), H(null), Y();
5869
7315
  return;
5870
7316
  }
5871
- let t = wn.current;
7317
+ let t = Mn.current;
5872
7318
  if (t === "rectangle") {
5873
- if (Tn.current) ot(null), kt();
7319
+ if (Nn.current) ct(null), Lt();
5874
7320
  else {
5875
- V(null);
5876
- let e = F.current;
7321
+ H(null);
7322
+ let e = I.current;
5877
7323
  e && (e.getCanvas().style.cursor = "");
5878
7324
  }
5879
7325
  return;
5880
7326
  }
5881
7327
  if (t === "circle") {
5882
- if (st.current) st.current = null, Pt();
7328
+ if (ut.current) ut.current = null, Ht();
5883
7329
  else {
5884
- V(null);
5885
- let e = F.current;
7330
+ H(null);
7331
+ let e = I.current;
5886
7332
  e && (e.getCanvas().style.cursor = "");
5887
7333
  }
5888
7334
  return;
5889
7335
  }
5890
7336
  if (t === "polygon") {
5891
- let e = ct.current;
7337
+ let e = dt.current;
5892
7338
  if (e.length >= 3) {
5893
7339
  let t = K.current, n = applyEntityConfig({
5894
7340
  ...t,
5895
- id: t?.id ?? wt(),
7341
+ id: t?.id ?? Mt(),
5896
7342
  type: "polygon",
5897
7343
  coordinates: [...e]
5898
- }, O);
5899
- Rt();
5900
- let r = F.current;
5901
- if (r && !I.current.has(n.id)) {
5902
- let e = new PolygonRenderer(r, n, k, A, j, N);
5903
- I.current.set(n.id, e);
7344
+ }, D);
7345
+ Kt();
7346
+ let r = I.current;
7347
+ if (r && !L.current.has(n.id)) {
7348
+ let e = new PolygonRenderer(r, n, O, k, A, M);
7349
+ L.current.set(n.id, e);
5904
7350
  }
5905
- Q.current.onPolygonAdd?.(n), ct.current = [], K.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
5906
- } else if (e.length > 0) ct.current = [], Rt();
7351
+ Q.current.onPolygonAdd?.(n), dt.current = [], K.current = null, U.current && (U.current = !1, H(null), r && (r.getCanvas().style.cursor = ""));
7352
+ } else if (e.length > 0) dt.current = [], Kt();
5907
7353
  else {
5908
- V(null);
5909
- let e = F.current;
7354
+ H(null);
7355
+ let e = I.current;
5910
7356
  e && (e.getCanvas().style.cursor = "");
5911
7357
  }
5912
7358
  return;
5913
7359
  }
5914
7360
  if (t === "square") {
5915
- if (lt.current) lt.current = null, Ut();
7361
+ if (ft.current) ft.current = null, Zt();
5916
7362
  else {
5917
- V(null);
5918
- let e = F.current;
7363
+ H(null);
7364
+ let e = I.current;
5919
7365
  e && (e.getCanvas().style.cursor = "");
5920
7366
  }
5921
7367
  return;
5922
7368
  }
5923
7369
  if (t === "polyline") {
5924
- let e = ut.current;
7370
+ let e = mt.current;
5925
7371
  if (e.length >= 2) {
5926
- let t = J.current, n = applyEntityConfig({
7372
+ let t = pt.current, n = applyEntityConfig({
5927
7373
  ...t,
5928
- id: t?.id ?? wt(),
7374
+ id: t?.id ?? Mt(),
5929
7375
  type: "polyline",
5930
7376
  coordinates: [...e]
5931
- }, O);
5932
- qt();
5933
- let r = F.current;
5934
- if (r && !I.current.has(n.id)) {
5935
- let e = new PolylineRenderer(r, n, k, A, N);
5936
- I.current.set(n.id, e);
7377
+ }, D);
7378
+ tn();
7379
+ let r = I.current;
7380
+ if (r && !L.current.has(n.id)) {
7381
+ let e = new PolylineRenderer(r, n, O, k, M);
7382
+ L.current.set(n.id, e);
5937
7383
  }
5938
- Q.current.onPolylineAdd?.(n), ut.current = [], J.current = null, H.current && (H.current = !1, V(null), r && (r.getCanvas().style.cursor = ""));
5939
- } else if (e.length > 0) ut.current = [], qt();
7384
+ Q.current.onPolylineAdd?.(n), mt.current = [], pt.current = null, U.current && (U.current = !1, H(null), r && (r.getCanvas().style.cursor = ""));
7385
+ } else if (e.length > 0) mt.current = [], tn();
5940
7386
  else {
5941
- V(null);
5942
- let e = F.current;
7387
+ H(null);
7388
+ let e = I.current;
5943
7389
  e && (e.getCanvas().style.cursor = "");
5944
7390
  }
5945
7391
  return;
@@ -5947,45 +7393,45 @@ const Mapbox = forwardRef((e, c) => {
5947
7393
  let n = [e.lngLat.lng, e.lngLat.lat], r = {
5948
7394
  x: e.point.x,
5949
7395
  y: e.point.y
5950
- }, i = vn.current, a = fn(e.originalEvent.target);
7396
+ }, i = En.current, a = bn(e.originalEvent.target);
5951
7397
  if (a) {
5952
7398
  let e = i.find((e) => String(e.id) === a);
5953
7399
  if (e) {
5954
- gn(e, r, n);
7400
+ wn(e, r, n);
5955
7401
  return;
5956
7402
  }
5957
7403
  }
5958
- for (let [t, a] of I.current) {
7404
+ for (let [t, a] of L.current) {
5959
7405
  let o = a.getLabelLayerId();
5960
- if (o && F.current?.getLayer(o) && F.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
7406
+ if (o && I.current?.getLayer(o) && I.current.queryRenderedFeatures(e.point, { layers: [o] }).length > 0) {
5961
7407
  let e = i.find((e) => e.id === t);
5962
7408
  if (e) {
5963
- gn(e, r, n);
7409
+ wn(e, r, n);
5964
7410
  return;
5965
7411
  }
5966
7412
  }
5967
7413
  }
5968
- for (let [e, t] of I.current) if (t.isPointInEntity(n)) {
7414
+ for (let [e, t] of L.current) if (t.isPointInEntity(n)) {
5969
7415
  let t = i.find((t) => t.id === e);
5970
7416
  if (t) {
5971
- gn(t, r, n);
7417
+ wn(t, r, n);
5972
7418
  return;
5973
7419
  }
5974
7420
  }
5975
7421
  }, [
5976
- fn,
7422
+ bn,
5977
7423
  Y,
5978
- kt,
5979
- Pt,
5980
- Rt,
5981
- Ut,
5982
- qt
5983
- ]), gn = useCallback((e, t, n) => {
5984
- let r = Ve.current?.getBoundingClientRect(), i = r ? {
7424
+ Lt,
7425
+ Ht,
7426
+ Kt,
7427
+ Zt,
7428
+ tn
7429
+ ]), wn = useCallback((e, t, n) => {
7430
+ let r = He.current?.getBoundingClientRect(), i = r ? {
5985
7431
  x: t.x + r.left,
5986
7432
  y: t.y + r.top
5987
7433
  } : t;
5988
- Je({
7434
+ Xe({
5989
7435
  position: i,
5990
7436
  lngLat: n,
5991
7437
  items: [{
@@ -6005,8 +7451,8 @@ const Mapbox = forwardRef((e, c) => {
6005
7451
  }
6006
7452
  }]
6007
7453
  });
6008
- }, []), _n = useCallback(() => {
6009
- Je(null);
7454
+ }, []), Tn = useCallback(() => {
7455
+ Xe(null);
6010
7456
  }, []);
6011
7457
  useEffect(() => {
6012
7458
  let e = document.createElement("div");
@@ -6017,11 +7463,11 @@ const Mapbox = forwardRef((e, c) => {
6017
7463
  width: 100%;
6018
7464
  pointer-events: none;
6019
7465
  height: 100%;
6020
- z-index: ${P?.zIndex ?? 1e3};
6021
- `, document.body.appendChild(e), We.current = e, () => {
7466
+ z-index: ${F?.zIndex ?? 1e3};
7467
+ `, document.body.appendChild(e), Ke.current = e, () => {
6022
7468
  document.body.contains(e) && document.body.removeChild(e);
6023
7469
  };
6024
- }, [P?.zIndex]), useEffect(() => {
7470
+ }, [F?.zIndex]), useEffect(() => {
6025
7471
  let e = document.createElement("div");
6026
7472
  return e.id = `mapbox-context-menu-container-${Date.now()}`, e.style.cssText = `
6027
7473
  position: fixed;
@@ -6030,61 +7476,65 @@ const Mapbox = forwardRef((e, c) => {
6030
7476
  width: 100%;
6031
7477
  pointer-events: none;
6032
7478
  height: 100%;
6033
- z-index: ${(P?.zIndex ?? 1e3) + 100};
6034
- `, document.body.appendChild(e), Ye.current = e, () => {
7479
+ z-index: ${(F?.zIndex ?? 1e3) + 100};
7480
+ `, document.body.appendChild(e), Ze.current = e, () => {
6035
7481
  document.body.contains(e) && document.body.removeChild(e);
6036
7482
  };
6037
- }, [P?.zIndex]);
6038
- let vn = useRef(E);
6039
- vn.current = E;
6040
- let yn = useRef(Ie);
6041
- yn.current = Ie;
6042
- let bn = useRef(gt);
6043
- bn.current = gt;
6044
- let xn = useRef(z);
6045
- xn.current = z;
6046
- let Sn = useRef(b);
6047
- Sn.current = b;
6048
- let Cn = useRef(rt);
6049
- Cn.current = rt;
6050
- let wn = useRef(it);
6051
- wn.current = it;
6052
- let Tn = useRef(at);
6053
- Tn.current = at;
7483
+ }, [F?.zIndex]);
7484
+ let En = useRef(T);
7485
+ En.current = T;
7486
+ let Dn = useRef(Le);
7487
+ Dn.current = Le;
7488
+ let On = useRef(wt);
7489
+ On.current = wt;
7490
+ let kn = useRef(et);
7491
+ kn.current = et;
7492
+ let An = useRef(b);
7493
+ An.current = b;
7494
+ let jn = useRef(at);
7495
+ jn.current = at;
7496
+ let Mn = useRef(ot);
7497
+ Mn.current = ot;
7498
+ let Nn = useRef(st);
7499
+ Nn.current = st;
6054
7500
  let Q = useRef(v);
6055
7501
  Q.current = v;
6056
- let En = useRef(O);
6057
- En.current = O, useEffect(() => {
7502
+ let Pn = useRef(D);
7503
+ Pn.current = D, useEffect(() => {
6058
7504
  let e = (e) => {
6059
- if (e.key === "Escape" && z === "edit") {
6060
- if (rt && (B(null), V(null), Y()), it === "rectangle") if (at) ot(null), kt();
7505
+ if (e.key === "Escape" && J.current) {
7506
+ L.current.get(J.current.entityId)?.cancelEditPreview?.(), J.current = null;
7507
+ return;
7508
+ }
7509
+ if (e.key === "Escape" && et === "edit") {
7510
+ if (at && (V(null), H(null), Y()), ot === "rectangle") if (st) ct(null), Lt();
6061
7511
  else {
6062
- V(null);
6063
- let e = F.current;
7512
+ H(null);
7513
+ let e = I.current;
6064
7514
  e && (e.getCanvas().style.cursor = "");
6065
7515
  }
6066
- if (it === "circle") if (st.current) st.current = null, Pt();
7516
+ if (ot === "circle") if (ut.current) ut.current = null, Ht();
6067
7517
  else {
6068
- V(null);
6069
- let e = F.current;
7518
+ H(null);
7519
+ let e = I.current;
6070
7520
  e && (e.getCanvas().style.cursor = "");
6071
7521
  }
6072
- if (it === "polygon") if (ct.current.length > 0) ct.current = [], Rt();
7522
+ if (ot === "polygon") if (dt.current.length > 0) dt.current = [], Kt();
6073
7523
  else {
6074
- V(null);
6075
- let e = F.current;
7524
+ H(null);
7525
+ let e = I.current;
6076
7526
  e && (e.getCanvas().style.cursor = "");
6077
7527
  }
6078
- if (it === "square") if (lt.current) lt.current = null, Ut();
7528
+ if (ot === "square") if (ft.current) ft.current = null, Zt();
6079
7529
  else {
6080
- V(null);
6081
- let e = F.current;
7530
+ H(null);
7531
+ let e = I.current;
6082
7532
  e && (e.getCanvas().style.cursor = "");
6083
7533
  }
6084
- if (it === "polyline") if (ut.current.length > 0) ut.current = [], qt();
7534
+ if (ot === "polyline") if (mt.current.length > 0) mt.current = [], tn();
6085
7535
  else {
6086
- V(null);
6087
- let e = F.current;
7536
+ H(null);
7537
+ let e = I.current;
6088
7538
  e && (e.getCanvas().style.cursor = "");
6089
7539
  }
6090
7540
  }
@@ -6093,56 +7543,56 @@ const Mapbox = forwardRef((e, c) => {
6093
7543
  document.removeEventListener("keydown", e);
6094
7544
  };
6095
7545
  }, [
6096
- z,
6097
- rt,
6098
- it,
7546
+ et,
6099
7547
  at,
7548
+ ot,
7549
+ st,
6100
7550
  Y,
6101
- kt,
6102
- Pt,
6103
- Rt,
6104
- Ut,
6105
- qt
7551
+ Lt,
7552
+ Ht,
7553
+ Kt,
7554
+ Zt,
7555
+ tn
6106
7556
  ]), useEffect(() => {
6107
- let e = F.current;
6108
- if (!e || !R) return;
6109
- let t = R.entityId, n = R.config, r = () => {
6110
- let r = vn.current.find((e) => e.id === t);
7557
+ let e = I.current;
7558
+ if (!e || !z) return;
7559
+ let t = z.entityId, n = z.config, r = () => {
7560
+ let r = En.current.find((e) => e.id === t);
6111
7561
  if (!r) {
6112
- vt();
7562
+ Et();
6113
7563
  return;
6114
7564
  }
6115
- let { position: i } = calculatePopupPosition(r, n, e, void 0, Ge.current);
6116
- Ge.current && (Ge.current.style.left = `${i.x}px`, Ge.current.style.top = `${i.y}px`);
7565
+ let { position: i } = calculatePopupPosition(r, n, e, void 0, qe.current);
7566
+ qe.current && (qe.current.style.left = `${i.x}px`, qe.current.style.top = `${i.y}px`);
6117
7567
  }, i = setTimeout(() => {
6118
7568
  r();
6119
7569
  }, 50);
6120
7570
  return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
6121
7571
  clearTimeout(i), e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
6122
7572
  };
6123
- }, [R?.entityId, vt]), useEffect(() => {
6124
- let e = F.current, t = Ve.current;
6125
- if (!e || !qe || !t) return;
6126
- let n = qe.lngLat, r = () => {
7573
+ }, [z?.entityId, Et]), useEffect(() => {
7574
+ let e = I.current, t = He.current;
7575
+ if (!e || !Ye || !t) return;
7576
+ let n = Ye.lngLat, r = () => {
6127
7577
  let r = e.project(n), i = t.clientWidth, a = t.clientHeight;
6128
7578
  if (r.x < 0 || r.x > i || r.y < 0 || r.y > a) {
6129
- _n();
7579
+ Tn();
6130
7580
  return;
6131
7581
  }
6132
7582
  let o = t.getBoundingClientRect(), s = r.x + o.left, c = r.y + o.top;
6133
- Xe.current && (Xe.current.style.left = `${s}px`, Xe.current.style.top = `${c}px`);
7583
+ Qe.current && (Qe.current.style.left = `${s}px`, Qe.current.style.top = `${c}px`);
6134
7584
  };
6135
7585
  return e.on("move", r), e.on("zoom", r), e.on("rotate", r), e.on("pitch", r), () => {
6136
7586
  e.off("move", r), e.off("zoom", r), e.off("rotate", r), e.off("pitch", r);
6137
7587
  };
6138
- }, [qe?.lngLat, _n]), useEffect(() => {
6139
- if (!Ve.current) return;
7588
+ }, [Ye?.lngLat, Tn]), useEffect(() => {
7589
+ if (!He.current) return;
6140
7590
  let e = {
6141
7591
  version: 8,
6142
7592
  sources: {},
6143
7593
  layers: []
6144
7594
  }, { dragPan: t = !0, scrollZoom: n = !0, doubleClickZoom: r = !0, touchZoomRotate: i = !0, keyboard: a = !0, dragRotate: o = !0, pitchWithRotate: c = !0, touchPitch: p = !0, boxZoom: m = !0 } = x, _ = new mapboxgl.Map({
6145
- container: Ve.current,
7595
+ container: He.current,
6146
7596
  style: h || e,
6147
7597
  center: l,
6148
7598
  zoom: u,
@@ -6169,98 +7619,98 @@ const Mapbox = forwardRef((e, c) => {
6169
7619
  return { url: e };
6170
7620
  }
6171
7621
  });
6172
- return F.current = _, _.on("load", () => {
7622
+ return I.current = _, _.on("load", () => {
6173
7623
  if (!_.getStyle().glyphs) {
6174
7624
  let e = _.style, t = "/gis-fonts/{fontstack}/{range}.pbf";
6175
7625
  e.glyphs = t, e.stylesheet && (e.stylesheet.glyphs = t);
6176
7626
  }
6177
- L.current.clear(), E.forEach((e) => {
6178
- L.current.set(e.id, e);
6179
- }), dn(S), nn(), Dt(), At(), It(), Bt(), Gt(), Qe(_), Fe?.(_);
6180
- }), _.on("click", pn), _.on("mousemove", mn), _.on("contextmenu", hn), () => {
6181
- _.off("click", pn), _.off("mousemove", mn), _.off("contextmenu", hn), rn(), Ct(), Y(), X(), Z(), _.remove(), F.current = null;
7627
+ R.current.clear(), T.forEach((e) => {
7628
+ R.current.set(e.id, e);
7629
+ }), yn(S), dn(), Ft(), Rt(), Wt(), Jt(), $t(), $e(_), Ie?.(_);
7630
+ }), _.on("click", xn), _.on("mousemove", Sn), _.on("contextmenu", Cn), () => {
7631
+ _.off("click", xn), _.off("mousemove", Sn), _.off("contextmenu", Cn), fn(), jt(), Y(), X(), Z(), _.remove(), I.current = null;
6182
7632
  };
6183
7633
  }, []), useEffect(() => {
6184
- if (F.current) {
6185
- if (!F.current.isStyleLoaded()) {
6186
- F.current.once("load", () => {
6187
- L.current.clear(), E.forEach((e) => {
6188
- L.current.set(e.id, e);
6189
- }), nn();
7634
+ if (I.current) {
7635
+ if (!I.current.isStyleLoaded()) {
7636
+ I.current.once("load", () => {
7637
+ R.current.clear(), T.forEach((e) => {
7638
+ R.current.set(e.id, e);
7639
+ }), dn();
6190
7640
  });
6191
7641
  return;
6192
7642
  }
6193
- L.current.clear(), E.forEach((e) => {
6194
- L.current.set(e.id, e);
6195
- }), nn();
7643
+ R.current.clear(), T.forEach((e) => {
7644
+ R.current.set(e.id, e);
7645
+ }), dn();
6196
7646
  }
6197
- }, [E, nn]), useEffect(() => {
6198
- !F.current || !F.current.isStyleLoaded() || (rn(), nn());
7647
+ }, [T, dn]), useEffect(() => {
7648
+ !I.current || !I.current.isStyleLoaded() || (fn(), dn());
6199
7649
  }, [
7650
+ O,
6200
7651
  k,
6201
7652
  A,
6202
7653
  j,
6203
7654
  M,
6204
- N,
6205
- rn,
6206
- nn
7655
+ fn,
7656
+ dn
6207
7657
  ]), useEffect(() => {
6208
- if (F.current) {
6209
- if (!F.current.isStyleLoaded()) {
6210
- F.current.once("load", () => {
6211
- dn(S);
7658
+ if (I.current) {
7659
+ if (!I.current.isStyleLoaded()) {
7660
+ I.current.once("load", () => {
7661
+ yn(S);
6212
7662
  });
6213
7663
  return;
6214
7664
  }
6215
- dn(S);
6216
- }
6217
- }, [S, dn]);
6218
- let Dn = useRef(void 0), On = useRef(!0), kn = useRef(S);
6219
- kn.current = S;
6220
- let An = useRef(dn);
6221
- An.current = dn;
6222
- let jn = useRef(rn);
6223
- jn.current = rn;
6224
- let Mn = useRef(nn);
6225
- Mn.current = nn;
6226
- let Nn = useRef(Dt);
6227
- Nn.current = Dt;
6228
- let Pn = useRef(At);
6229
- Pn.current = At;
6230
- let Fn = useRef(It);
6231
- Fn.current = It;
6232
- let In = useRef(Bt);
6233
- In.current = Bt;
6234
- let Ln = useRef(Gt);
6235
- Ln.current = Gt, useEffect(() => {
6236
- let e = F.current;
7665
+ yn(S);
7666
+ }
7667
+ }, [S, yn]);
7668
+ let Fn = useRef(void 0), In = useRef(!0), Ln = useRef(S);
7669
+ Ln.current = S;
7670
+ let Rn = useRef(yn);
7671
+ Rn.current = yn;
7672
+ let zn = useRef(fn);
7673
+ zn.current = fn;
7674
+ let Bn = useRef(dn);
7675
+ Bn.current = dn;
7676
+ let Vn = useRef(Ft);
7677
+ Vn.current = Ft;
7678
+ let Hn = useRef(Rt);
7679
+ Hn.current = Rt;
7680
+ let Un = useRef(Wt);
7681
+ Un.current = Wt;
7682
+ let Wn = useRef(Jt);
7683
+ Wn.current = Jt;
7684
+ let Gn = useRef($t);
7685
+ Gn.current = $t, useEffect(() => {
7686
+ let e = I.current;
6237
7687
  if (!e) return;
6238
7688
  let t = h || {
6239
7689
  version: 8,
6240
7690
  sources: {},
6241
7691
  layers: []
6242
7692
  };
6243
- if (On.current) {
6244
- On.current = !1, Dn.current = h;
7693
+ if (In.current) {
7694
+ In.current = !1, Fn.current = h;
6245
7695
  return;
6246
7696
  }
6247
- Dn.current !== h && (Dn.current = h, e.setStyle(t), e.once("style.load", () => {
7697
+ Fn.current !== h && (Fn.current = h, e.setStyle(t), e.once("style.load", () => {
6248
7698
  if (!e.getStyle().glyphs) {
6249
7699
  let t = e.style, n = "/gis-fonts/{fontstack}/{range}.pbf";
6250
7700
  t.glyphs = n, t.stylesheet && (t.stylesheet.glyphs = n);
6251
7701
  }
6252
- He.current.clear(), An.current(kn.current), jn.current(), Mn.current(), Nn.current(), Pn.current(), Fn.current(), In.current(), Ln.current();
7702
+ We.current.clear(), Rn.current(Ln.current), zn.current(), Bn.current(), Vn.current(), Hn.current(), Un.current(), Wn.current(), Gn.current();
6253
7703
  }));
6254
7704
  }, [h]), useEffect(() => {
6255
- let e = new Set(D.map(String));
6256
- for (let [t, n] of I.current) n.setSelected(e.has(String(t)));
6257
- }, [D]);
6258
- let Rn = useRef({});
7705
+ let e = new Set(E.map(String));
7706
+ for (let [t, n] of L.current) n.setSelected(e.has(String(t)));
7707
+ }, [E]);
7708
+ let Kn = useRef({});
6259
7709
  useEffect(() => {
6260
- let e = F.current;
7710
+ let e = I.current;
6261
7711
  if (!e) return;
6262
- let t = Rn.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;
6263
- !n && !r && !i && !a || (Rn.current = {
7712
+ let t = Kn.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;
7713
+ !n && !r && !i && !a || (Kn.current = {
6264
7714
  center: l,
6265
7715
  zoom: u,
6266
7716
  pitch: d,
@@ -6277,49 +7727,51 @@ const Mapbox = forwardRef((e, c) => {
6277
7727
  d,
6278
7728
  f
6279
7729
  ]);
6280
- let zn = (() => xe === !1 ? null : xe === !0 ? { enabled: !0 } : xe)(), Bn = (() => Te === !1 ? null : Te === !0 ? { enabled: !0 } : Te)(), Vn = (() => Ee === !1 ? null : Ee === !0 ? { enabled: !0 } : Ee)(), $ = (() => {
6281
- if (De === !1) return null;
6282
- let e, t;
7730
+ let qn = (() => we === !1 ? null : we === !0 ? { enabled: !0 } : we)(), Jn = (() => N === !1 ? null : N === !0 ? { enabled: !0 } : N)(), Yn = (() => Te === !1 ? null : Te === !0 ? { enabled: !0 } : Te)(), $ = (() => {
7731
+ if (Ee === !1) return null;
7732
+ let e, t, n;
6283
7733
  if (S && S.length > 0) {
6284
- let n = S.find((e) => e.hasRoadNetwork === !0) || S[0];
6285
- if (n.type === "style") {
6286
- let t = F.current?.getStyle();
7734
+ let r = S.find((e) => e.hasRoadNetwork === !0) || S[0];
7735
+ if (r.type === "style") {
7736
+ let t = I.current?.getStyle();
6287
7737
  if (t?.sources) {
6288
- let r = `base-layer-source-${n.id}-`, i = Object.keys(t.sources).find((e) => e.startsWith(r));
7738
+ let n = `base-layer-source-${r.id}-`, i = Object.keys(t.sources).find((e) => e.startsWith(n));
6289
7739
  i && (e = i);
6290
7740
  }
6291
- } else e = `base-layer-source-${n.id}`;
6292
- t = n.roadNetworkSourceLayer || "road";
7741
+ } else e = `base-layer-source-${r.id}`;
7742
+ t = r.roadNetworkSourceLayer || "road", n = r.roadNetworkClassField;
6293
7743
  }
6294
- return De === !0 ? {
7744
+ return Ee === !0 ? {
6295
7745
  enabled: !0,
6296
7746
  source: e,
6297
- sourceLayer: t
7747
+ sourceLayer: t,
7748
+ classField: n
6298
7749
  } : {
6299
- ...De,
6300
- source: De.source || e,
6301
- sourceLayer: De.sourceLayer || t
7750
+ ...Ee,
7751
+ source: Ee.source || e,
7752
+ sourceLayer: Ee.sourceLayer || t,
7753
+ classField: Ee.classField || n
6302
7754
  };
6303
- })(), Hn = (() => ke ? ke === !0 ? { enabled: !0 } : ke : null)(), Un = (() => Ae ? Ae === !0 ? { enabled: !0 } : Ae : null)(), Wn = useMemo(() => {
7755
+ })(), Xn = (() => De ? De === !0 ? { enabled: !0 } : De : null)(), Zn = (() => je ? je === !0 ? { enabled: !0 } : je : null)(), Qn = (() => Me || null)(), $n = useMemo(() => {
6304
7756
  let e = [];
6305
7757
  for (let t of S) if (t.applyRasterPaint) if (t.type === "style") {
6306
- let n = F.current;
7758
+ let n = I.current;
6307
7759
  if (n) {
6308
7760
  let r = `base-layer-${t.id}-`, i = n.getStyle();
6309
7761
  if (i?.layers) for (let t of i.layers) t.id.startsWith(r) && t.type === "raster" && e.push(t.id);
6310
7762
  }
6311
7763
  } else e.push(`base-layer-${t.id}`);
6312
7764
  return e;
6313
- }, [S, Ze]);
7765
+ }, [S, B]);
6314
7766
  return /* @__PURE__ */ jsxs("div", {
6315
- className: `comp-mapbox ${z === "picker" ? "comp-mapbox--picker-mode" : ""} ${ze}`,
6316
- style: Be,
7767
+ className: `comp-mapbox ${et === "picker" ? "comp-mapbox--picker-mode" : ""} ${Be}`,
7768
+ style: Ve,
6317
7769
  children: [
6318
7770
  /* @__PURE__ */ jsx("div", {
6319
- ref: Ve,
7771
+ ref: He,
6320
7772
  className: "comp-mapbox__map"
6321
7773
  }),
6322
- z === "picker" && y.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
7774
+ et === "picker" && y.showCrosshair === !0 && /* @__PURE__ */ jsxs("div", {
6323
7775
  className: "comp-mapbox__crosshair",
6324
7776
  children: [/* @__PURE__ */ jsx("div", {
6325
7777
  className: "comp-mapbox__crosshair-h",
@@ -6329,83 +7781,103 @@ const Mapbox = forwardRef((e, c) => {
6329
7781
  style: y.crosshairColor ? { backgroundColor: y.crosshairColor } : void 0
6330
7782
  })]
6331
7783
  }),
6332
- z === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 ? /* @__PURE__ */ jsxs("div", {
7784
+ et === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) || $ && $.enabled !== !1 || Qn && Qn.enabled !== !1 ? /* @__PURE__ */ jsxs("div", {
6333
7785
  className: "comp-mapbox__edit-controls",
6334
- children: [z === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
6335
- markerTemplates: v.markerTemplates || [],
6336
- selectedTemplate: rt,
6337
- onTemplateSelect: Jt,
6338
- drawMode: it,
6339
- onDrawModeChange: Yt,
6340
- showRectangleTool: v.showRectangleTool,
6341
- showCircleTool: v.showCircleTool,
6342
- showPolygonTool: v.showPolygonTool,
6343
- showSquareTool: v.showSquareTool,
6344
- showPolylineTool: v.showPolylineTool
6345
- }), $ && $.enabled !== !1 && /* @__PURE__ */ jsx(RoadHighlightControl, {
6346
- map: Ze,
6347
- highlightWidth: $.highlightWidth,
6348
- defaultRoadTypes: $.defaultRoadTypes,
6349
- defaultMinWidth: $.defaultMinWidth,
6350
- source: $.source,
6351
- sourceLayer: $.sourceLayer,
6352
- className: $.className,
6353
- style: $.style
6354
- })]
7786
+ children: [
7787
+ et === "edit" && v.showEditTools !== !1 && (v.markerTemplates && v.markerTemplates.length > 0 || v.showRectangleTool || v.showCircleTool || v.showPolygonTool || v.showSquareTool || v.showPolylineTool) && /* @__PURE__ */ jsx(EditControl, {
7788
+ markerTemplates: v.markerTemplates || [],
7789
+ selectedTemplate: at,
7790
+ onTemplateSelect: nn,
7791
+ drawMode: ot,
7792
+ onDrawModeChange: rn,
7793
+ showRectangleTool: v.showRectangleTool,
7794
+ showCircleTool: v.showCircleTool,
7795
+ showPolygonTool: v.showPolygonTool,
7796
+ showSquareTool: v.showSquareTool,
7797
+ showPolylineTool: v.showPolylineTool
7798
+ }),
7799
+ $ && $.enabled !== !1 && /* @__PURE__ */ jsx(RoadHighlightControl, {
7800
+ map: B,
7801
+ highlightWidth: $.highlightWidth,
7802
+ defaultRoadTypes: $.defaultRoadTypes,
7803
+ defaultMinWidth: $.defaultMinWidth,
7804
+ source: $.source,
7805
+ sourceLayer: $.sourceLayer,
7806
+ classField: $.classField,
7807
+ className: $.className,
7808
+ style: $.style
7809
+ }),
7810
+ Qn && Qn.enabled !== !1 && /* @__PURE__ */ jsx(RoutePlanningControl, {
7811
+ ref: Ue,
7812
+ map: B,
7813
+ pointCount: Qn.pointCount,
7814
+ showPointCountInput: Qn.showPointCountInput,
7815
+ visualType: Qn.visualType,
7816
+ onSelectFinished: Qn.onSelectFinished
7817
+ })
7818
+ ]
6355
7819
  }) : null,
6356
- (zn?.enabled !== !1 || Bn?.enabled !== !1 || Vn?.enabled !== !1 || Hn && Hn.enabled !== !1 || Un && Un.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
7820
+ (qn?.enabled !== !1 || Jn?.enabled !== !1 || Yn?.enabled !== !1 || Xn && Xn.enabled !== !1 || Zn && Zn.enabled !== !1) && /* @__PURE__ */ jsxs("div", {
6357
7821
  className: "comp-mapbox__controls",
6358
7822
  children: [
6359
- zn && zn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
6360
- map: Ze,
6361
- precision: zn.precision,
6362
- className: zn.className,
6363
- style: zn.style
7823
+ qn && qn.enabled !== !1 && /* @__PURE__ */ jsx(CoordinateDisplay, {
7824
+ map: B,
7825
+ precision: qn.precision,
7826
+ className: qn.className,
7827
+ style: qn.style
6364
7828
  }),
6365
- Bn && Bn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
6366
- map: Ze,
6367
- maxWidth: Bn.maxWidth,
6368
- unit: Bn.unit,
6369
- className: Bn.className,
6370
- style: Bn.style
7829
+ Jn && Jn.enabled !== !1 && /* @__PURE__ */ jsx(ScaleControl, {
7830
+ map: B,
7831
+ maxWidth: Jn.maxWidth,
7832
+ unit: Jn.unit,
7833
+ className: Jn.className,
7834
+ style: Jn.style
6371
7835
  }),
6372
- Hn && Hn.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
6373
- map: Ze,
6374
- entityConfig: O,
6375
- className: Hn.className,
6376
- style: Hn.style
7836
+ Xn && Xn.enabled !== !1 && /* @__PURE__ */ jsx(MeasureControl, {
7837
+ map: B,
7838
+ entityConfig: D,
7839
+ onDrawModeChange: (e) => {
7840
+ gt.current = e;
7841
+ },
7842
+ className: Xn.className,
7843
+ style: Xn.style
6377
7844
  }),
6378
- Un && Un.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
6379
- map: Ze,
6380
- value: T,
6381
- onChange: Me,
6382
- rasterPaintLayerIds: Wn,
6383
- className: Un.className,
6384
- style: Un.style
7845
+ Zn && Zn.enabled !== !1 && /* @__PURE__ */ jsx(RasterPaintControl, {
7846
+ map: B,
7847
+ value: w,
7848
+ onChange: Ne,
7849
+ rasterPaintLayerIds: $n,
7850
+ className: Zn.className,
7851
+ style: Zn.style
6385
7852
  }),
6386
- Vn && Vn.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
6387
- map: Ze,
7853
+ Yn && Yn.enabled !== !1 && /* @__PURE__ */ jsx(ResetViewControl, {
7854
+ map: B,
6388
7855
  initialCenter: l,
6389
7856
  initialZoom: u,
6390
7857
  initialPitch: d,
6391
7858
  initialBearing: f,
6392
- duration: Vn.duration,
6393
- className: Vn.className,
6394
- style: Vn.style
7859
+ duration: Yn.duration,
7860
+ className: Yn.className,
7861
+ style: Yn.style
6395
7862
  })
6396
7863
  ]
6397
7864
  }),
6398
- R && We.current && /* @__PURE__ */ jsx(EntityPopup, {
6399
- popupState: R,
6400
- onClose: () => _t(R.entityId),
6401
- portalContainer: We.current,
6402
- popupRef: Ge
7865
+ !(Qn && Qn.enabled !== !1) && /* @__PURE__ */ jsx(RoutePlanningControl, {
7866
+ ref: Ue,
7867
+ map: B,
7868
+ showButton: !1
7869
+ }),
7870
+ z && Ke.current && /* @__PURE__ */ jsx(EntityPopup, {
7871
+ popupState: z,
7872
+ onClose: () => Tt(z.entityId),
7873
+ portalContainer: Ke.current,
7874
+ popupRef: qe
6403
7875
  }),
6404
- qe && Ye.current && /* @__PURE__ */ jsx(ContextMenu, {
6405
- menuState: qe,
6406
- onClose: _n,
6407
- portalContainer: Ye.current,
6408
- menuRef: Xe
7876
+ Ye && Ze.current && /* @__PURE__ */ jsx(ContextMenu, {
7877
+ menuState: Ye,
7878
+ onClose: Tn,
7879
+ portalContainer: Ze.current,
7880
+ menuRef: Qe
6409
7881
  })
6410
7882
  ]
6411
7883
  });