leaflet-polydraw 0.8.10 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11644,6 +11644,52 @@ function convex(geojson, options = {}) {
11644
11644
  }
11645
11645
  return null;
11646
11646
  }
11647
+ function centerOfMass(geojson, options = {}) {
11648
+ switch (getType(geojson)) {
11649
+ case "Point":
11650
+ return point(getCoord(geojson), options.properties);
11651
+ case "Polygon":
11652
+ var coords = [];
11653
+ coordEach(geojson, function(coord) {
11654
+ coords.push(coord);
11655
+ });
11656
+ var centre = centroid(geojson, { properties: options.properties });
11657
+ var translation = centre.geometry.coordinates;
11658
+ var sx = 0;
11659
+ var sy = 0;
11660
+ var sArea = 0;
11661
+ var i, pi2, pj, xi, xj, yi, yj, a;
11662
+ var neutralizedPoints = coords.map(function(point2) {
11663
+ return [point2[0] - translation[0], point2[1] - translation[1]];
11664
+ });
11665
+ for (i = 0; i < coords.length - 1; i++) {
11666
+ pi2 = neutralizedPoints[i];
11667
+ xi = pi2[0];
11668
+ yi = pi2[1];
11669
+ pj = neutralizedPoints[i + 1];
11670
+ xj = pj[0];
11671
+ yj = pj[1];
11672
+ a = xi * yj - xj * yi;
11673
+ sArea += a;
11674
+ sx += (xi + xj) * a;
11675
+ sy += (yi + yj) * a;
11676
+ }
11677
+ if (sArea === 0) {
11678
+ return centre;
11679
+ } else {
11680
+ var area2 = sArea * 0.5;
11681
+ var areaFactor = 1 / (6 * area2);
11682
+ return point(
11683
+ [translation[0] + areaFactor * sx, translation[1] + areaFactor * sy],
11684
+ options.properties
11685
+ );
11686
+ }
11687
+ default:
11688
+ var hull = convex(geojson);
11689
+ if (hull) return centerOfMass(hull, { properties: options.properties });
11690
+ else return centroid(geojson, { properties: options.properties });
11691
+ }
11692
+ }
11647
11693
  function clone$1(geojson) {
11648
11694
  if (!geojson) {
11649
11695
  throw new Error("geojson is required");
@@ -16060,6 +16106,9 @@ class TurfHelper {
16060
16106
  const length$12 = length(poly, { units: "kilometers" });
16061
16107
  return length$12;
16062
16108
  }
16109
+ getCenterOfMass(feature2) {
16110
+ return centerOfMass(feature2);
16111
+ }
16063
16112
  getDoubleElbowLatLngs(points) {
16064
16113
  const doubleized = [];
16065
16114
  const len = points.length;
@@ -16997,6 +17046,18 @@ class PolygonUtil {
16997
17046
  const bounds = polyLine.getBounds();
16998
17047
  return bounds;
16999
17048
  }
17049
+ /**
17050
+ * Calculates the center of mass of the polygon.
17051
+ * @param polygon A GeoJSON polygon.
17052
+ * @returns The center LatLng.
17053
+ */
17054
+ static getCenterOfMass(polygon2) {
17055
+ const centerOfMass2 = this.turfHelper.getCenterOfMass(polygon2);
17056
+ return {
17057
+ lat: centerOfMass2.geometry.coordinates[1],
17058
+ lng: centerOfMass2.geometry.coordinates[0]
17059
+ };
17060
+ }
17000
17061
  }
17001
17062
  __publicField(PolygonUtil, "turfHelper", new TurfHelper(defaultConfig));
17002
17063
  class PolygonInfo {
@@ -17214,11 +17275,57 @@ class MapStateService {
17214
17275
  updatePolygons(polygons) {
17215
17276
  }
17216
17277
  }
17278
+ class EventManager {
17279
+ constructor() {
17280
+ __publicField(this, "eventListeners", /* @__PURE__ */ new Map());
17281
+ }
17282
+ /**
17283
+ * Register an event listener.
17284
+ * @param event - The event to listen for.
17285
+ * @param callback - The callback to execute when the event is emitted.
17286
+ */
17287
+ on(event, callback) {
17288
+ var _a2;
17289
+ if (!this.eventListeners.has(event)) {
17290
+ this.eventListeners.set(event, []);
17291
+ }
17292
+ (_a2 = this.eventListeners.get(event)) == null ? void 0 : _a2.push(callback);
17293
+ }
17294
+ /**
17295
+ * Unregister an event listener.
17296
+ * @param event - The event to stop listening for.
17297
+ * @param callback - The specific callback to remove.
17298
+ */
17299
+ off(event, callback) {
17300
+ if (this.eventListeners.has(event)) {
17301
+ const listeners = this.eventListeners.get(event);
17302
+ if (listeners) {
17303
+ const index = listeners.indexOf(callback);
17304
+ if (index > -1) {
17305
+ listeners.splice(index, 1);
17306
+ }
17307
+ }
17308
+ }
17309
+ }
17310
+ /**
17311
+ * Emit an event.
17312
+ * @param event - The event to emit.
17313
+ * @param data - The data to pass to the event listeners.
17314
+ */
17315
+ emit(event, data) {
17316
+ var _a2;
17317
+ if (this.eventListeners.has(event)) {
17318
+ (_a2 = this.eventListeners.get(event)) == null ? void 0 : _a2.forEach((callback) => callback(data));
17319
+ }
17320
+ }
17321
+ }
17217
17322
  class ModeManager {
17218
- constructor(config) {
17323
+ constructor(config, eventManager) {
17219
17324
  __publicField(this, "state");
17220
17325
  __publicField(this, "config");
17326
+ __publicField(this, "eventManager");
17221
17327
  this.config = config;
17328
+ this.eventManager = eventManager;
17222
17329
  this.state = this.createInitialState();
17223
17330
  }
17224
17331
  /**
@@ -17268,6 +17375,7 @@ class ModeManager {
17268
17375
  break;
17269
17376
  }
17270
17377
  this.state.isDrawingActive = mode !== DrawMode.Off;
17378
+ this.eventManager.emit("polydraw:mode:change", { mode });
17271
17379
  }
17272
17380
  /**
17273
17381
  * Set interaction state for Off mode (normal editing)
@@ -17401,43 +17509,22 @@ class PolygonDrawManager {
17401
17509
  __publicField(this, "map");
17402
17510
  __publicField(this, "config");
17403
17511
  __publicField(this, "modeManager");
17512
+ __publicField(this, "eventManager");
17404
17513
  __publicField(this, "tracer");
17405
- __publicField(this, "eventListeners", /* @__PURE__ */ new Map());
17406
17514
  // Point-to-Point drawing state
17407
17515
  __publicField(this, "p2pMarkers", []);
17408
17516
  __publicField(this, "isModifierKeyHeld", false);
17409
- console.log("PolygonDrawManager constructor");
17410
17517
  this.turfHelper = dependencies.turfHelper;
17411
17518
  this.map = dependencies.map;
17412
17519
  this.config = dependencies.config;
17413
17520
  this.modeManager = dependencies.modeManager;
17521
+ this.eventManager = dependencies.eventManager;
17414
17522
  this.tracer = dependencies.tracer;
17415
17523
  }
17416
- /**
17417
- * Add event listener
17418
- */
17419
- on(event, callback) {
17420
- console.log("PolygonDrawManager on");
17421
- if (!this.eventListeners.has(event)) {
17422
- this.eventListeners.set(event, []);
17423
- }
17424
- this.eventListeners.get(event).push(callback);
17425
- }
17426
- /**
17427
- * Emit event to all listeners
17428
- */
17429
- emit(event, data) {
17430
- console.log("PolygonDrawManager emit");
17431
- const listeners = this.eventListeners.get(event);
17432
- if (listeners) {
17433
- listeners.forEach((callback) => callback(data));
17434
- }
17435
- }
17436
17524
  /**
17437
17525
  * Handle mouse move during freehand drawing
17438
17526
  */
17439
17527
  mouseMove(event) {
17440
- console.log("mouseMove");
17441
17528
  if ("latlng" in event && event.latlng) {
17442
17529
  this.tracer.addLatLng(event.latlng);
17443
17530
  } else if ("touches" in event && event.touches && event.touches.length > 0) {
@@ -17452,7 +17539,6 @@ class PolygonDrawManager {
17452
17539
  * Handle mouse up/leave to complete freehand drawing
17453
17540
  */
17454
17541
  async mouseUpLeave(event) {
17455
- console.log("mouseUpLeave");
17456
17542
  const tracerGeoJSON = this.tracer.toGeoJSON();
17457
17543
  if (!tracerGeoJSON || !tracerGeoJSON.geometry || !tracerGeoJSON.geometry.coordinates || tracerGeoJSON.geometry.coordinates.length < 3) {
17458
17544
  return {
@@ -17475,7 +17561,7 @@ class PolygonDrawManager {
17475
17561
  error: "Invalid polygon created from trace"
17476
17562
  };
17477
17563
  }
17478
- this.emit("drawCompleted", {
17564
+ this.eventManager.emit("polydraw:polygon:created", {
17479
17565
  polygon: geoPos,
17480
17566
  mode: this.modeManager.getCurrentMode()
17481
17567
  });
@@ -17498,7 +17584,6 @@ class PolygonDrawManager {
17498
17584
  * Handle point-to-point click
17499
17585
  */
17500
17586
  handlePointToPointClick(clickLatLng) {
17501
- console.log("handlePointToPointClick");
17502
17587
  if (!clickLatLng) {
17503
17588
  return;
17504
17589
  }
@@ -17527,7 +17612,6 @@ class PolygonDrawManager {
17527
17612
  this.updateP2PTracer();
17528
17613
  });
17529
17614
  pointMarker.on("click", (e) => {
17530
- console.log("p2p marker click");
17531
17615
  if (this.isModifierKeyHeld && this.config.modes.edgeDeletion) {
17532
17616
  this.deleteP2PMarker(pointMarker);
17533
17617
  L.DomEvent.stopPropagation(e);
@@ -17557,7 +17641,6 @@ class PolygonDrawManager {
17557
17641
  }
17558
17642
  });
17559
17643
  pointMarker.on("click", (e) => {
17560
- console.log("p2p first marker click");
17561
17644
  if (this.isModifierKeyHeld && this.config.modes.edgeDeletion) {
17562
17645
  this.deleteP2PMarker(pointMarker);
17563
17646
  L.DomEvent.stopPropagation(e);
@@ -17578,7 +17661,6 @@ class PolygonDrawManager {
17578
17661
  * Handle double-click to complete point-to-point polygon
17579
17662
  */
17580
17663
  handleDoubleClick(e) {
17581
- console.log("handleDoubleClick");
17582
17664
  if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint) {
17583
17665
  return;
17584
17666
  }
@@ -17590,7 +17672,6 @@ class PolygonDrawManager {
17590
17672
  * Complete point-to-point polygon drawing
17591
17673
  */
17592
17674
  completePointToPointPolygon() {
17593
- console.log("PolygonDrawManager completePointToPointPolygon");
17594
17675
  const points = this.p2pMarkers.map((marker) => marker.getLatLng());
17595
17676
  if (points.length < 3) {
17596
17677
  return;
@@ -17606,7 +17687,7 @@ class PolygonDrawManager {
17606
17687
  const geoPos = this.turfHelper.getMultiPolygon([[coordinates]]);
17607
17688
  this.clearP2pMarkers();
17608
17689
  this.resetTracer();
17609
- this.emit("drawCompleted", {
17690
+ this.eventManager.emit("polydraw:polygon:created", {
17610
17691
  polygon: geoPos,
17611
17692
  mode: DrawMode.PointToPoint,
17612
17693
  isPointToPoint: true
@@ -17621,16 +17702,16 @@ class PolygonDrawManager {
17621
17702
  * Cancel point-to-point drawing
17622
17703
  */
17623
17704
  cancelPointToPointDrawing() {
17624
- console.log("PolygonDrawManager cancelPointToPointDrawing");
17625
17705
  this.clearP2pMarkers();
17626
17706
  this.resetTracer();
17627
- this.emit("drawCancelled", { mode: DrawMode.PointToPoint });
17707
+ this.eventManager.emit("polydraw:draw:cancel", {
17708
+ mode: DrawMode.PointToPoint
17709
+ });
17628
17710
  }
17629
17711
  /**
17630
17712
  * Clear all P2P markers
17631
17713
  */
17632
17714
  clearP2pMarkers() {
17633
- console.log("PolygonDrawManager clearP2pMarkers");
17634
17715
  this.p2pMarkers.forEach((marker) => this.map.removeLayer(marker));
17635
17716
  this.p2pMarkers = [];
17636
17717
  }
@@ -17638,7 +17719,6 @@ class PolygonDrawManager {
17638
17719
  * Reset the tracer
17639
17720
  */
17640
17721
  resetTracer() {
17641
- console.log("PolygonDrawManager resetTracer");
17642
17722
  this.tracer.setLatLngs([]);
17643
17723
  try {
17644
17724
  this.tracer.setStyle({
@@ -17651,7 +17731,6 @@ class PolygonDrawManager {
17651
17731
  * Check if clicking on the first point to close polygon
17652
17732
  */
17653
17733
  isClickingFirstPoint(clickLatLng, firstPoint) {
17654
- console.log("PolygonDrawManager isClickingFirstPoint");
17655
17734
  if (!firstPoint) return false;
17656
17735
  const zoom = this.map.getZoom();
17657
17736
  const baseTolerance = 5e-4;
@@ -17702,21 +17781,18 @@ class PolygonDrawManager {
17702
17781
  * Get current P2P markers (for external access)
17703
17782
  */
17704
17783
  getP2pMarkers() {
17705
- console.log("PolygonDrawManager getP2pMarkers");
17706
17784
  return [...this.p2pMarkers];
17707
17785
  }
17708
17786
  /**
17709
17787
  * Check if currently in point-to-point drawing mode
17710
17788
  */
17711
17789
  isInPointToPointMode() {
17712
- console.log("PolygonDrawManager isInPointToPointMode");
17713
17790
  return this.modeManager.getCurrentMode() === DrawMode.PointToPoint;
17714
17791
  }
17715
17792
  /**
17716
17793
  * Get current tracer points count
17717
17794
  */
17718
17795
  getTracerPointsCount() {
17719
- console.log("PolygonDrawManager getTracerPointsCount");
17720
17796
  const points = this.tracer.getLatLngs();
17721
17797
  return points.length;
17722
17798
  }
@@ -18321,18 +18397,18 @@ class PolygonInteractionManager {
18321
18397
  __publicField(this, "map");
18322
18398
  __publicField(this, "config");
18323
18399
  __publicField(this, "modeManager");
18324
- __publicField(this, "eventListeners", /* @__PURE__ */ new Map());
18400
+ __publicField(this, "eventManager");
18325
18401
  // Polygon drag state
18326
18402
  __publicField(this, "currentDragPolygon", null);
18327
18403
  __publicField(this, "currentModifierDragMode", false);
18328
18404
  __publicField(this, "isModifierKeyHeld", false);
18405
+ __publicField(this, "_openMenuPopup", null);
18329
18406
  // Read-only access to feature groups
18330
18407
  __publicField(this, "getFeatureGroups");
18331
18408
  __publicField(this, "addFeatureGroup");
18332
18409
  __publicField(this, "removeFeatureGroup");
18333
18410
  // Polygon dragging methods
18334
18411
  __publicField(this, "onPolygonMouseMove", (e) => {
18335
- console.log("PolygonInteractionManager onPolygonMouseMove");
18336
18412
  if (!this.currentDragPolygon || !this.currentDragPolygon._polydrawDragData.isDragging) return;
18337
18413
  const polygon2 = this.currentDragPolygon;
18338
18414
  const dragData = polygon2._polydrawDragData;
@@ -18350,7 +18426,6 @@ class PolygonInteractionManager {
18350
18426
  this.updateMarkersAndHoleLinesDuringDrag(polygon2, offsetLat, offsetLng);
18351
18427
  });
18352
18428
  __publicField(this, "onPolygonMouseUp", (e) => {
18353
- console.log("PolygonInteractionManager onPolygonMouseUp");
18354
18429
  if (!this.currentDragPolygon || !this.currentDragPolygon._polydrawDragData.isDragging) return;
18355
18430
  const polygon2 = this.currentDragPolygon;
18356
18431
  const dragData = polygon2._polydrawDragData;
@@ -18380,7 +18455,6 @@ class PolygonInteractionManager {
18380
18455
  this.currentDragPolygon = null;
18381
18456
  });
18382
18457
  __publicField(this, "onMarkerHoverForEdgeDeletionEvent", (e) => {
18383
- console.log("PolygonInteractionManager onMarkerHoverForEdgeDeletionEvent");
18384
18458
  if (!this.isModifierKeyHeld) return;
18385
18459
  const element = e.target;
18386
18460
  if (element) {
@@ -18390,7 +18464,6 @@ class PolygonInteractionManager {
18390
18464
  }
18391
18465
  });
18392
18466
  __publicField(this, "onMarkerLeaveForEdgeDeletionEvent", (e) => {
18393
- console.log("PolygonInteractionManager onMarkerLeaveForEdgeDeletionEvent");
18394
18467
  const element = e.target;
18395
18468
  if (element) {
18396
18469
  element.style.backgroundColor = "";
@@ -18398,41 +18471,20 @@ class PolygonInteractionManager {
18398
18471
  element.classList.remove("edge-deletion-hover");
18399
18472
  }
18400
18473
  });
18401
- console.log("PolygonInteractionManager constructor");
18402
18474
  this.turfHelper = dependencies.turfHelper;
18403
18475
  this.polygonInformation = dependencies.polygonInformation;
18404
18476
  this.map = dependencies.map;
18405
18477
  this.config = dependencies.config;
18406
18478
  this.modeManager = dependencies.modeManager;
18479
+ this.eventManager = dependencies.eventManager;
18407
18480
  this.getFeatureGroups = featureGroupAccess.getFeatureGroups;
18408
18481
  this.addFeatureGroup = featureGroupAccess.addFeatureGroup;
18409
18482
  this.removeFeatureGroup = featureGroupAccess.removeFeatureGroup;
18410
18483
  }
18411
- /**
18412
- * Add event listener
18413
- */
18414
- on(event, callback) {
18415
- console.log("PolygonInteractionManager on");
18416
- if (!this.eventListeners.has(event)) {
18417
- this.eventListeners.set(event, []);
18418
- }
18419
- this.eventListeners.get(event).push(callback);
18420
- }
18421
- /**
18422
- * Emit event to all listeners
18423
- */
18424
- emit(event, data) {
18425
- console.log("PolygonInteractionManager emit");
18426
- const listeners = this.eventListeners.get(event);
18427
- if (listeners) {
18428
- listeners.forEach((callback) => callback(data));
18429
- }
18430
- }
18431
18484
  /**
18432
18485
  * Add markers to a polygon feature group
18433
18486
  */
18434
18487
  addMarkers(latlngs, featureGroup) {
18435
- console.log("PolygonInteractionManager addMarkers");
18436
18488
  let menuMarkerIdx = this.getMarkerIndex(latlngs, this.config.markers.markerMenuIcon.position);
18437
18489
  let deleteMarkerIdx = this.getMarkerIndex(
18438
18490
  latlngs,
@@ -18459,6 +18511,7 @@ class PolygonInteractionManager {
18459
18511
  iconClasses = this.config.markers.markerInfoIcon.styleClasses;
18460
18512
  }
18461
18513
  const processedClasses = Array.isArray(iconClasses) ? iconClasses : [iconClasses];
18514
+ const isSpecialMarker = i === menuMarkerIdx && this.config.markers.menuMarker || i === deleteMarkerIdx && this.config.markers.deleteMarker || i === infoMarkerIdx && this.config.markers.infoMarker;
18462
18515
  const marker = new L.Marker(latlng, {
18463
18516
  icon: this.createDivIcon(processedClasses),
18464
18517
  draggable: this.config.modes.dragElbow,
@@ -18495,16 +18548,18 @@ class PolygonInteractionManager {
18495
18548
  });
18496
18549
  const el = marker.getElement();
18497
18550
  if (el) {
18498
- el.addEventListener("touchstart", (e) => {
18499
- console.log("marker touchstart");
18500
- e.stopPropagation();
18501
- });
18551
+ el.addEventListener(
18552
+ "touchstart",
18553
+ (e) => {
18554
+ e.stopPropagation();
18555
+ },
18556
+ { passive: true }
18557
+ );
18502
18558
  el.addEventListener("touchend", (e) => {
18503
- console.log("marker touchend");
18504
18559
  e.preventDefault();
18505
18560
  e.stopPropagation();
18506
18561
  marker.fire("click");
18507
- if (this.isDraggingMarker) {
18562
+ if (this.isDraggingMarker && !isSpecialMarker) {
18508
18563
  const fg = marker._polydrawFeatureGroup;
18509
18564
  if (this.modeManager.canPerformAction("markerDrag") && fg) {
18510
18565
  this.markerDragEnd(fg);
@@ -18530,21 +18585,31 @@ class PolygonInteractionManager {
18530
18585
  if (i === menuMarkerIdx && this.config.markers.menuMarker) {
18531
18586
  marker.options.zIndexOffset = this.config.markers.markerMenuIcon.zIndexOffset ?? this.config.markers.zIndexOffset;
18532
18587
  marker.on("click", () => {
18533
- console.log("menu marker clicked");
18534
- marker.unbindPopup();
18588
+ const polygonGeoJSON = this.getPolygonGeoJSONFromFeatureGroup(featureGroup);
18589
+ const centerOfMass2 = PolygonUtil.getCenterOfMass(polygonGeoJSON);
18535
18590
  const menuPopup = this.generateMenuMarkerPopup(latlngs, featureGroup);
18536
- marker.bindPopup(menuPopup, { className: "alter-marker" });
18537
- marker.openPopup();
18591
+ menuPopup.setLatLng(centerOfMass2).openOn(this.map);
18538
18592
  });
18539
- marker.on("popupopen", () => {
18540
- console.log("popupopen, setting touchAction to manipulation");
18593
+ marker.on("popupopen", (e) => {
18594
+ const popup = e.popup;
18595
+ const popupContent = popup.getElement();
18596
+ if (!popupContent) return;
18597
+ setTimeout(() => {
18598
+ const mapContainer = this.map.getContainer();
18599
+ const mapBounds = mapContainer.getBoundingClientRect();
18600
+ const popupBounds = popupContent.getBoundingClientRect();
18601
+ if (popupBounds.left < mapBounds.left) {
18602
+ popupContent.style.transform = `translateX(${mapBounds.left - popupBounds.left}px)`;
18603
+ } else if (popupBounds.right > mapBounds.right) {
18604
+ popupContent.style.transform = `translateX(${mapBounds.right - popupBounds.right}px)`;
18605
+ }
18606
+ }, 0);
18541
18607
  const container2 = this.map.getContainer();
18542
18608
  if (container2) {
18543
18609
  container2.style.touchAction = "manipulation";
18544
18610
  }
18545
18611
  });
18546
18612
  marker.on("popupclose", () => {
18547
- console.log("popupclose, resetting touchAction");
18548
18613
  const container2 = this.map.getContainer();
18549
18614
  if (container2) {
18550
18615
  container2.style.touchAction = "";
@@ -18557,21 +18622,30 @@ class PolygonInteractionManager {
18557
18622
  const perimeter = this.getTotalPolygonPerimeter(polygonGeoJSON);
18558
18623
  marker.options.zIndexOffset = this.config.markers.markerInfoIcon.zIndexOffset ?? this.config.markers.zIndexOffset;
18559
18624
  marker.on("click", () => {
18560
- console.log("info marker clicked");
18561
- marker.unbindPopup();
18562
18625
  const infoPopup = this.generateInfoMarkerPopup(area2, perimeter);
18563
- marker.bindPopup(infoPopup, { className: "info-marker" });
18564
- marker.openPopup();
18626
+ const centerOfMass2 = PolygonUtil.getCenterOfMass(polygonGeoJSON);
18627
+ infoPopup.setLatLng(centerOfMass2).openOn(this.map);
18565
18628
  });
18566
- marker.on("popupopen", () => {
18567
- console.log("popupopen, setting touchAction to manipulation");
18629
+ marker.on("popupopen", (e) => {
18630
+ const popup = e.popup;
18631
+ const popupContent = popup.getElement();
18632
+ if (!popupContent) return;
18633
+ setTimeout(() => {
18634
+ const mapContainer = this.map.getContainer();
18635
+ const mapBounds = mapContainer.getBoundingClientRect();
18636
+ const popupBounds = popupContent.getBoundingClientRect();
18637
+ if (popupBounds.left < mapBounds.left) {
18638
+ popupContent.style.transform = `translateX(${mapBounds.left - popupBounds.left}px)`;
18639
+ } else if (popupBounds.right > mapBounds.right) {
18640
+ popupContent.style.transform = `translateX(${mapBounds.right - popupBounds.right}px)`;
18641
+ }
18642
+ }, 0);
18568
18643
  const container2 = this.map.getContainer();
18569
18644
  if (container2) {
18570
18645
  container2.style.touchAction = "manipulation";
18571
18646
  }
18572
18647
  });
18573
18648
  marker.on("popupclose", () => {
18574
- console.log("popupclose, resetting touchAction");
18575
18649
  const container2 = this.map.getContainer();
18576
18650
  if (container2) {
18577
18651
  container2.style.touchAction = "";
@@ -18587,7 +18661,6 @@ class PolygonInteractionManager {
18587
18661
  });
18588
18662
  marker.on("click", (e) => {
18589
18663
  var _a2;
18590
- console.log("marker click");
18591
18664
  if (this.modeManager.isInOffMode()) {
18592
18665
  if (this.isModifierKeyPressed(e.originalEvent)) {
18593
18666
  const poly = (_a2 = featureGroup.getLayers().find((layer) => layer instanceof L.Polygon)) == null ? void 0 : _a2.toGeoJSON();
@@ -18596,9 +18669,10 @@ class PolygonInteractionManager {
18596
18669
  }
18597
18670
  } else {
18598
18671
  if (i === deleteMarkerIdx && this.config.markers.deleteMarker) {
18672
+ this.map.closePopup();
18599
18673
  this.removeFeatureGroup(featureGroup);
18600
18674
  this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups());
18601
- this.emit("polygonDeleted");
18675
+ this.eventManager.emit("polydraw:polygon:deleted", void 0);
18602
18676
  }
18603
18677
  }
18604
18678
  }
@@ -18615,7 +18689,6 @@ class PolygonInteractionManager {
18615
18689
  * Add hole markers to a polygon feature group
18616
18690
  */
18617
18691
  addHoleMarkers(latlngs, featureGroup) {
18618
- console.log("PolygonInteractionManager addHoleMarkers");
18619
18692
  latlngs.forEach((latlng, i) => {
18620
18693
  const iconClasses = this.config.markers.holeIcon.styleClasses;
18621
18694
  const processedClasses = Array.isArray(iconClasses) ? iconClasses : [iconClasses];
@@ -18650,7 +18723,6 @@ class PolygonInteractionManager {
18650
18723
  * Add edge click listeners to a polygon
18651
18724
  */
18652
18725
  addEdgeClickListeners(polygon2, featureGroup) {
18653
- console.log("PolygonInteractionManager addEdgeClickListeners");
18654
18726
  const rawLatLngs = polygon2.getLatLngs();
18655
18727
  let processedRings;
18656
18728
  if (Array.isArray(rawLatLngs) && rawLatLngs.length > 0) {
@@ -18713,7 +18785,6 @@ class PolygonInteractionManager {
18713
18785
  * Enable polygon dragging functionality
18714
18786
  */
18715
18787
  enablePolygonDragging(polygon2, latlngs) {
18716
- console.log("PolygonInteractionManager enablePolygonDragging");
18717
18788
  if (!this.config.modes.dragPolygons) return;
18718
18789
  polygon2._polydrawOriginalLatLngs = latlngs;
18719
18790
  polygon2._polydrawDragData = {
@@ -18722,7 +18793,6 @@ class PolygonInteractionManager {
18722
18793
  startLatLngs: null
18723
18794
  };
18724
18795
  polygon2.on("mousedown", (e) => {
18725
- console.log("polygon mousedown");
18726
18796
  if (!this.modeManager.isInOffMode()) {
18727
18797
  L.DomEvent.stopPropagation(e);
18728
18798
  this.map.fire("mousedown", e);
@@ -18775,7 +18845,6 @@ class PolygonInteractionManager {
18775
18845
  * Update marker draggable state based on current mode
18776
18846
  */
18777
18847
  updateMarkerDraggableState() {
18778
- console.log("PolygonInteractionManager updateMarkerDraggableState");
18779
18848
  const shouldBeDraggable = this.modeManager.canPerformAction("markerDrag");
18780
18849
  this.getFeatureGroups().forEach((featureGroup) => {
18781
18850
  featureGroup.eachLayer((layer) => {
@@ -18800,7 +18869,6 @@ class PolygonInteractionManager {
18800
18869
  * Update all markers for edge deletion visual feedback
18801
18870
  */
18802
18871
  updateAllMarkersForEdgeDeletion(showFeedback) {
18803
- console.log("PolygonInteractionManager updateAllMarkersForEdgeDeletion");
18804
18872
  this.getFeatureGroups().forEach((featureGroup) => {
18805
18873
  featureGroup.eachLayer((layer) => {
18806
18874
  if (layer instanceof L.Marker) {
@@ -18813,7 +18881,6 @@ class PolygonInteractionManager {
18813
18881
  * Update individual marker for edge deletion visual feedback
18814
18882
  */
18815
18883
  updateMarkerForEdgeDeletion(marker, showFeedback) {
18816
- console.log("PolygonInteractionManager updateMarkerForEdgeDeletion");
18817
18884
  const element = marker.getElement();
18818
18885
  if (!element) return;
18819
18886
  if (showFeedback) {
@@ -18830,12 +18897,10 @@ class PolygonInteractionManager {
18830
18897
  * Set modifier key held state
18831
18898
  */
18832
18899
  setModifierKeyHeld(isHeld) {
18833
- console.log("PolygonInteractionManager setModifierKeyHeld");
18834
18900
  this.isModifierKeyHeld = isHeld;
18835
18901
  }
18836
18902
  // Private methods
18837
18903
  onEdgeClick(e, edgePolyline) {
18838
- console.log("onEdgeClick");
18839
18904
  if (!this.config.modes.attachElbow) {
18840
18905
  return;
18841
18906
  }
@@ -18862,7 +18927,7 @@ class PolygonInteractionManager {
18862
18927
  const polydrawPolygon = parentPolygon;
18863
18928
  const optimizationLevel = polydrawPolygon._polydrawOptimizationLevel || 0;
18864
18929
  this.removeFeatureGroup(parentFeatureGroup);
18865
- this.emit("polygonModified", {
18930
+ this.eventManager.emit("polydraw:polygon:updated", {
18866
18931
  operation: "addVertex",
18867
18932
  polygon: newPolygon,
18868
18933
  optimizationLevel
@@ -18875,7 +18940,6 @@ class PolygonInteractionManager {
18875
18940
  L.DomEvent.stopPropagation(e);
18876
18941
  }
18877
18942
  highlightEdgeOnHover(edgePolyline, isHovering) {
18878
- console.log("PolygonInteractionManager highlightEdgeOnHover");
18879
18943
  if (isHovering) {
18880
18944
  edgePolyline.setStyle({
18881
18945
  color: "#7a9441",
@@ -18891,7 +18955,6 @@ class PolygonInteractionManager {
18891
18955
  }
18892
18956
  }
18893
18957
  elbowClicked(e, poly) {
18894
- console.log("elbowClicked");
18895
18958
  if (!this.config.modes.edgeDeletion) {
18896
18959
  return;
18897
18960
  }
@@ -18934,13 +18997,12 @@ class PolygonInteractionManager {
18934
18997
  this.removeFeatureGroup(currentFeatureGroup);
18935
18998
  }
18936
18999
  const newPolygon = this.turfHelper.getMultiPolygon([newAllRings]);
18937
- this.emit("polygonModified", {
19000
+ this.eventManager.emit("polydraw:polygon:updated", {
18938
19001
  operation: "removeVertex",
18939
19002
  polygon: newPolygon
18940
19003
  });
18941
19004
  }
18942
19005
  findFeatureGroupForPoly(poly) {
18943
- console.log("PolygonInteractionManager findFeatureGroupForPoly");
18944
19006
  for (const featureGroup of this.getFeatureGroups()) {
18945
19007
  const featureCollection2 = featureGroup.toGeoJSON();
18946
19008
  if (featureCollection2 && featureCollection2.features && featureCollection2.features[0]) {
@@ -18957,7 +19019,6 @@ class PolygonInteractionManager {
18957
19019
  console.warn("No active marker set for dragging.");
18958
19020
  return;
18959
19021
  }
18960
- console.log("PolygonInteractionManager markerDrag", featureGroup);
18961
19022
  const newPos = [];
18962
19023
  let testarray = [];
18963
19024
  let hole = [];
@@ -19033,9 +19094,11 @@ class PolygonInteractionManager {
19033
19094
  layerLength[0].setLatLngs(newPos);
19034
19095
  }
19035
19096
  async markerDragEnd(featureGroup) {
19036
- console.log("PolygonInteractionManager markerDragEnd");
19037
19097
  this.polygonInformation.deletePolygonInformationStorage();
19038
19098
  const featureCollection2 = featureGroup.toGeoJSON();
19099
+ if (!featureCollection2.features || featureCollection2.features.length === 0) {
19100
+ return;
19101
+ }
19039
19102
  this.removeFeatureGroup(featureGroup);
19040
19103
  if (featureCollection2.features[0].geometry.coordinates.length > 1) {
19041
19104
  for (const element of featureCollection2.features[0].geometry.coordinates) {
@@ -19043,14 +19106,14 @@ class PolygonInteractionManager {
19043
19106
  if (this.turfHelper.hasKinks(feature2)) {
19044
19107
  const unkink = this.turfHelper.getKinks(feature2);
19045
19108
  for (const polygon2 of unkink) {
19046
- this.emit("polygonModified", {
19109
+ this.eventManager.emit("polydraw:polygon:updated", {
19047
19110
  operation: "markerDrag",
19048
19111
  polygon: this.turfHelper.getTurfPolygon(polygon2),
19049
19112
  allowMerge: true
19050
19113
  });
19051
19114
  }
19052
19115
  } else {
19053
- this.emit("polygonModified", {
19116
+ this.eventManager.emit("polydraw:polygon:updated", {
19054
19117
  operation: "markerDrag",
19055
19118
  polygon: feature2,
19056
19119
  allowMerge: true
@@ -19064,14 +19127,24 @@ class PolygonInteractionManager {
19064
19127
  if (this.turfHelper.hasKinks(feature2)) {
19065
19128
  const unkink = this.turfHelper.getKinks(feature2);
19066
19129
  for (const polygon2 of unkink) {
19067
- this.emit("polygonModified", {
19130
+ this.eventManager.emit("polydraw:polygon:updated", {
19131
+ operation: "markerDrag",
19132
+ polygon: this.turfHelper.getTurfPolygon(polygon2),
19133
+ allowMerge: true
19134
+ });
19135
+ this.eventManager.emit("polydraw:polygon:updated", {
19068
19136
  operation: "markerDrag",
19069
19137
  polygon: this.turfHelper.getTurfPolygon(polygon2),
19070
19138
  allowMerge: true
19071
19139
  });
19072
19140
  }
19073
19141
  } else {
19074
- this.emit("polygonModified", {
19142
+ this.eventManager.emit("polydraw:polygon:updated", {
19143
+ operation: "markerDrag",
19144
+ polygon: feature2,
19145
+ allowMerge: true
19146
+ });
19147
+ this.eventManager.emit("polydraw:polygon:updated", {
19075
19148
  operation: "markerDrag",
19076
19149
  polygon: feature2,
19077
19150
  allowMerge: true
@@ -19081,7 +19154,6 @@ class PolygonInteractionManager {
19081
19154
  this.polygonInformation.createPolygonInformationStorage(this.getFeatureGroups());
19082
19155
  }
19083
19156
  offsetPolygonCoordinates(latLngs, offsetLat, offsetLng) {
19084
- console.log("PolygonInteractionManager offsetPolygonCoordinates");
19085
19157
  if (!latLngs) return latLngs;
19086
19158
  if (Array.isArray(latLngs[0])) {
19087
19159
  return latLngs.map((ring) => this.offsetPolygonCoordinates(ring, offsetLat, offsetLng));
@@ -19097,7 +19169,6 @@ class PolygonInteractionManager {
19097
19169
  }
19098
19170
  }
19099
19171
  updateMarkersAndHoleLinesDuringDrag(polygon2, offsetLat, offsetLng) {
19100
- console.log("PolygonInteractionManager updateMarkersAndHoleLinesDuringDrag");
19101
19172
  try {
19102
19173
  let featureGroup = null;
19103
19174
  for (const fg of this.getFeatureGroups()) {
@@ -19154,7 +19225,6 @@ class PolygonInteractionManager {
19154
19225
  }
19155
19226
  }
19156
19227
  async updatePolygonAfterDrag(polygon2) {
19157
- console.log("PolygonInteractionManager updatePolygonAfterDrag");
19158
19228
  try {
19159
19229
  let featureGroup = null;
19160
19230
  for (const fg of this.getFeatureGroups()) {
@@ -19177,7 +19247,7 @@ class PolygonInteractionManager {
19177
19247
  }
19178
19248
  this.removeFeatureGroup(featureGroup);
19179
19249
  const feature2 = this.turfHelper.getTurfPolygon(newGeoJSON);
19180
- this.emit("polygonModified", {
19250
+ this.eventManager.emit("polydraw:polygon:updated", {
19181
19251
  operation: "polygonDrag",
19182
19252
  polygon: feature2,
19183
19253
  allowMerge: true
@@ -19188,7 +19258,6 @@ class PolygonInteractionManager {
19188
19258
  }
19189
19259
  detectModifierKey(event) {
19190
19260
  var _a2, _b2;
19191
- console.log("PolygonInteractionManager detectModifierKey");
19192
19261
  if (!((_b2 = (_a2 = this.config.dragPolygons) == null ? void 0 : _a2.modifierSubtract) == null ? void 0 : _b2.enabled)) {
19193
19262
  return false;
19194
19263
  }
@@ -19204,7 +19273,6 @@ class PolygonInteractionManager {
19204
19273
  }
19205
19274
  }
19206
19275
  setSubtractVisualMode(polygon2, enabled) {
19207
- console.log("PolygonInteractionManager setSubtractVisualMode");
19208
19276
  if (!polygon2 || !polygon2.setStyle) {
19209
19277
  return;
19210
19278
  }
@@ -19224,7 +19292,6 @@ class PolygonInteractionManager {
19224
19292
  }
19225
19293
  updateMarkerColorsForSubtractMode(polygon2, subtractMode) {
19226
19294
  var _a2, _b2;
19227
- console.log("PolygonInteractionManager updateMarkerColorsForSubtractMode");
19228
19295
  try {
19229
19296
  let featureGroup = null;
19230
19297
  for (const fg of this.getFeatureGroups()) {
@@ -19270,7 +19337,6 @@ class PolygonInteractionManager {
19270
19337
  }
19271
19338
  }
19272
19339
  handleModifierToggleDuringDrag(event) {
19273
- console.log("PolygonInteractionManager handleModifierToggleDuringDrag");
19274
19340
  const isModifierPressed = this.detectModifierKey(event);
19275
19341
  this.currentModifierDragMode = isModifierPressed;
19276
19342
  this.isModifierKeyHeld = isModifierPressed;
@@ -19279,11 +19345,9 @@ class PolygonInteractionManager {
19279
19345
  }
19280
19346
  }
19281
19347
  isModifierDragActive() {
19282
- console.log("PolygonInteractionManager isModifierDragActive");
19283
19348
  return this.currentModifierDragMode;
19284
19349
  }
19285
19350
  performModifierSubtract(draggedGeoJSON, originalFeatureGroup) {
19286
- console.log("PolygonInteractionManager performModifierSubtract");
19287
19351
  try {
19288
19352
  const draggedPolygon = this.turfHelper.getTurfPolygon(draggedGeoJSON);
19289
19353
  const intersectingFeatureGroups = [];
@@ -19333,7 +19397,7 @@ class PolygonInteractionManager {
19333
19397
  const coords = this.turfHelper.getCoords(difference3);
19334
19398
  for (const coordSet of coords) {
19335
19399
  const individualPolygon = this.turfHelper.getMultiPolygon([coordSet]);
19336
- this.emit("polygonModified", {
19400
+ this.eventManager.emit("polydraw:polygon:updated", {
19337
19401
  operation: "modifierSubtract",
19338
19402
  polygon: this.turfHelper.getTurfPolygon(individualPolygon),
19339
19403
  allowMerge: false
@@ -19343,7 +19407,7 @@ class PolygonInteractionManager {
19343
19407
  }
19344
19408
  } catch (differenceError) {
19345
19409
  console.warn("Failed to perform difference operation:", differenceError);
19346
- this.emit("polygonModified", {
19410
+ this.eventManager.emit("polydraw:polygon:updated", {
19347
19411
  operation: "modifierSubtractFallback",
19348
19412
  polygon: existingPolygon,
19349
19413
  allowMerge: false
@@ -19365,7 +19429,6 @@ class PolygonInteractionManager {
19365
19429
  return !(bbox1[2] < bbox2[0] || bbox2[2] < bbox1[0] || bbox1[3] < bbox2[1] || bbox2[3] < bbox1[1]);
19366
19430
  }
19367
19431
  isModifierKeyPressed(event) {
19368
- console.log("PolygonInteractionManager isModifierKeyPressed");
19369
19432
  if (isTouchDevice()) {
19370
19433
  return false;
19371
19434
  }
@@ -19378,7 +19441,6 @@ class PolygonInteractionManager {
19378
19441
  }
19379
19442
  }
19380
19443
  onMarkerHoverForEdgeDeletion(marker, isHovering) {
19381
- console.log("PolygonInteractionManager onMarkerHoverForEdgeDeletion");
19382
19444
  const element = marker.getElement();
19383
19445
  if (!element) return;
19384
19446
  if (isHovering) {
@@ -19431,7 +19493,6 @@ class PolygonInteractionManager {
19431
19493
  }
19432
19494
  // Helper methods
19433
19495
  getMarkerIndex(latlngs, position) {
19434
- console.log("PolygonInteractionManager getMarkerIndex");
19435
19496
  const bounds = PolyDrawUtil.getBounds(latlngs, Math.sqrt(2) / 2);
19436
19497
  const compass = new Compass(
19437
19498
  bounds.getSouth(),
@@ -19450,7 +19511,6 @@ class PolygonInteractionManager {
19450
19511
  return nearestPointIdx;
19451
19512
  }
19452
19513
  ensureMarkerSeparation(polygonLength, markers2) {
19453
- console.log("PolygonInteractionManager ensureMarkerSeparation");
19454
19514
  const enabledMarkers = [];
19455
19515
  if (markers2.menu.enabled) {
19456
19516
  enabledMarkers.push({ type: "menu", index: markers2.menu.index });
@@ -19493,7 +19553,6 @@ class PolygonInteractionManager {
19493
19553
  };
19494
19554
  }
19495
19555
  findAlternativeMarkerPosition(polygonLength, originalIndex, usedIndices) {
19496
- console.log("PolygonInteractionManager findAlternativeMarkerPosition");
19497
19556
  const maxAttempts = polygonLength;
19498
19557
  const step = Math.max(1, Math.floor(polygonLength / 8));
19499
19558
  for (let attempt = 1; attempt < maxAttempts; attempt++) {
@@ -19515,21 +19574,16 @@ class PolygonInteractionManager {
19515
19574
  return originalIndex;
19516
19575
  }
19517
19576
  createDivIcon(processedClasses) {
19518
- console.log("PolygonInteractionManager createDivIcon");
19519
19577
  return IconFactory.createDivIcon(processedClasses);
19520
19578
  }
19521
19579
  getLatLngInfoString(latlng) {
19522
- console.log("PolygonInteractionManager getLatLngInfoString");
19523
19580
  return "Latitude: " + latlng.lat + " Longitude: " + latlng.lng;
19524
19581
  }
19525
19582
  generateMenuMarkerPopup(latLngs, featureGroup) {
19526
- console.log("PolygonInteractionManager generateMenuMarkerPopup");
19527
19583
  const outerWrapper = document.createElement("div");
19528
19584
  outerWrapper.classList.add("alter-marker-outer-wrapper");
19529
19585
  const wrapper = document.createElement("div");
19530
19586
  wrapper.classList.add("alter-marker-wrapper");
19531
- const invertedCorner = document.createElement("i");
19532
- invertedCorner.classList.add("inverted-corner");
19533
19587
  const markerContent = document.createElement("div");
19534
19588
  markerContent.classList.add("content");
19535
19589
  const markerContentWrapper = document.createElement("div");
@@ -19553,7 +19607,6 @@ class PolygonInteractionManager {
19553
19607
  const separator = document.createElement("div");
19554
19608
  separator.classList.add("separator");
19555
19609
  outerWrapper.appendChild(wrapper);
19556
- wrapper.appendChild(invertedCorner);
19557
19610
  wrapper.appendChild(markerContent);
19558
19611
  markerContent.appendChild(markerContentWrapper);
19559
19612
  markerContentWrapper.appendChild(simplify3);
@@ -19563,42 +19616,83 @@ class PolygonInteractionManager {
19563
19616
  markerContentWrapper.appendChild(bbox2);
19564
19617
  markerContentWrapper.appendChild(separator.cloneNode());
19565
19618
  markerContentWrapper.appendChild(bezier2);
19619
+ const closePopupIfOpen = () => {
19620
+ if (this._openMenuPopup) {
19621
+ this.map.closePopup(this._openMenuPopup);
19622
+ this._openMenuPopup = null;
19623
+ }
19624
+ };
19566
19625
  simplify3.addEventListener("touchend", (e) => {
19567
- console.log("simplify touchend");
19568
19626
  e.preventDefault();
19569
19627
  e.stopPropagation();
19570
- this.emit("menuAction", { action: "simplify", latLngs, featureGroup });
19628
+ this.eventManager.emit("polydraw:menu:action", {
19629
+ action: "simplify",
19630
+ latLngs,
19631
+ featureGroup
19632
+ });
19633
+ closePopupIfOpen();
19571
19634
  });
19572
19635
  simplify3.onclick = () => {
19573
- console.log("simplify clicked");
19574
- this.emit("menuAction", { action: "simplify", latLngs, featureGroup });
19636
+ this.eventManager.emit("polydraw:menu:action", {
19637
+ action: "simplify",
19638
+ latLngs,
19639
+ featureGroup
19640
+ });
19641
+ closePopupIfOpen();
19575
19642
  };
19576
19643
  bbox2.addEventListener("touchend", (e) => {
19577
- console.log("bbox touchend");
19578
19644
  e.preventDefault();
19579
19645
  e.stopPropagation();
19580
- this.emit("menuAction", { action: "bbox", latLngs, featureGroup });
19646
+ this.eventManager.emit("polydraw:menu:action", {
19647
+ action: "bbox",
19648
+ latLngs,
19649
+ featureGroup
19650
+ });
19651
+ closePopupIfOpen();
19581
19652
  });
19582
19653
  bbox2.onclick = () => {
19583
- this.emit("menuAction", { action: "bbox", latLngs, featureGroup });
19654
+ this.eventManager.emit("polydraw:menu:action", {
19655
+ action: "bbox",
19656
+ latLngs,
19657
+ featureGroup
19658
+ });
19659
+ closePopupIfOpen();
19584
19660
  };
19585
19661
  doubleElbows.addEventListener("touchend", (e) => {
19586
- console.log("doubleElbows touchend");
19587
19662
  e.preventDefault();
19588
19663
  e.stopPropagation();
19589
- this.emit("menuAction", { action: "doubleElbows", latLngs, featureGroup });
19664
+ this.eventManager.emit("polydraw:menu:action", {
19665
+ action: "doubleElbows",
19666
+ latLngs,
19667
+ featureGroup
19668
+ });
19669
+ closePopupIfOpen();
19590
19670
  });
19591
19671
  doubleElbows.onclick = () => {
19592
- this.emit("menuAction", { action: "doubleElbows", latLngs, featureGroup });
19672
+ this.eventManager.emit("polydraw:menu:action", {
19673
+ action: "doubleElbows",
19674
+ latLngs,
19675
+ featureGroup
19676
+ });
19677
+ closePopupIfOpen();
19593
19678
  };
19594
19679
  bezier2.addEventListener("touchend", (e) => {
19595
- console.log("bezier touchend");
19596
19680
  e.preventDefault();
19597
19681
  e.stopPropagation();
19598
- this.emit("menuAction", { action: "bezier", latLngs, featureGroup });
19682
+ this.eventManager.emit("polydraw:menu:action", {
19683
+ action: "bezier",
19684
+ latLngs,
19685
+ featureGroup
19686
+ });
19687
+ closePopupIfOpen();
19599
19688
  });
19600
19689
  bezier2.onclick = () => {
19601
- this.emit("menuAction", { action: "bezier", latLngs, featureGroup });
19690
+ this.eventManager.emit("polydraw:menu:action", {
19691
+ action: "bezier",
19692
+ latLngs,
19693
+ featureGroup
19694
+ });
19695
+ closePopupIfOpen();
19602
19696
  };
19603
19697
  L.DomEvent.disableClickPropagation(outerWrapper);
19604
19698
  outerWrapper.style.pointerEvents = "auto";
@@ -19606,10 +19700,16 @@ class PolygonInteractionManager {
19606
19700
  btn.style.pointerEvents = "auto";
19607
19701
  btn.addEventListener("click", (e) => e.stopPropagation());
19608
19702
  });
19609
- return outerWrapper;
19703
+ const isMobile = window.innerWidth <= 600;
19704
+ const popup = L.popup({
19705
+ closeButton: true,
19706
+ autoClose: true,
19707
+ className: `menu-popup${isMobile ? " mobile-popup" : ""}`
19708
+ }).setContent(outerWrapper);
19709
+ this._openMenuPopup = popup;
19710
+ return popup;
19610
19711
  }
19611
19712
  getPolygonGeoJSONFromFeatureGroup(featureGroup) {
19612
- console.log("PolygonInteractionManager getPolygonGeoJSONFromFeatureGroup");
19613
19713
  try {
19614
19714
  let polygon2 = null;
19615
19715
  featureGroup.eachLayer((layer) => {
@@ -19642,7 +19742,6 @@ class PolygonInteractionManager {
19642
19742
  }
19643
19743
  }
19644
19744
  getTotalPolygonPerimeter(polygonGeoJSON) {
19645
- console.log("PolygonInteractionManager getTotalPolygonPerimeter");
19646
19745
  try {
19647
19746
  if (!polygonGeoJSON || !polygonGeoJSON.geometry) {
19648
19747
  return 0;
@@ -19686,15 +19785,12 @@ class PolygonInteractionManager {
19686
19785
  }
19687
19786
  }
19688
19787
  generateInfoMarkerPopup(area2, perimeter) {
19689
- console.log("PolygonInteractionManager generateInfoMarkerPopup");
19690
19788
  const _perimeter = new Perimeter(perimeter, this.config);
19691
19789
  const _area = new Area(area2, this.config);
19692
19790
  const outerWrapper = document.createElement("div");
19693
19791
  outerWrapper.classList.add("info-marker-outer-wrapper");
19694
19792
  const wrapper = document.createElement("div");
19695
19793
  wrapper.classList.add("info-marker-wrapper");
19696
- const invertedCorner = document.createElement("i");
19697
- invertedCorner.classList.add("inverted-corner");
19698
19794
  const markerContent = document.createElement("div");
19699
19795
  markerContent.classList.add("content");
19700
19796
  const infoContentWrapper = document.createElement("div");
@@ -19709,7 +19805,6 @@ class PolygonInteractionManager {
19709
19805
  infoContentWrapper.appendChild(perimeterDiv);
19710
19806
  markerContent.appendChild(infoContentWrapper);
19711
19807
  outerWrapper.appendChild(wrapper);
19712
- wrapper.appendChild(invertedCorner);
19713
19808
  wrapper.appendChild(markerContent);
19714
19809
  L.DomEvent.disableClickPropagation(outerWrapper);
19715
19810
  outerWrapper.style.pointerEvents = "auto";
@@ -19717,7 +19812,13 @@ class PolygonInteractionManager {
19717
19812
  btn.style.pointerEvents = "auto";
19718
19813
  btn.addEventListener("click", (e) => e.stopPropagation());
19719
19814
  });
19720
- return outerWrapper;
19815
+ const isMobile = window.innerWidth <= 600;
19816
+ const popup = L.popup({
19817
+ closeButton: true,
19818
+ autoClose: true,
19819
+ className: `info-popup${isMobile ? " mobile-popup" : ""}`
19820
+ }).setContent(outerWrapper);
19821
+ return popup;
19721
19822
  }
19722
19823
  }
19723
19824
  class PolygonMutationManager {
@@ -19727,8 +19828,8 @@ class PolygonMutationManager {
19727
19828
  __publicField(this, "map");
19728
19829
  __publicField(this, "config");
19729
19830
  __publicField(this, "modeManager");
19831
+ __publicField(this, "eventManager");
19730
19832
  __publicField(this, "getFeatureGroups");
19731
- __publicField(this, "eventListeners", /* @__PURE__ */ new Map());
19732
19833
  // Specialized managers
19733
19834
  __publicField(this, "geometryManager");
19734
19835
  __publicField(this, "drawManager");
@@ -19738,6 +19839,7 @@ class PolygonMutationManager {
19738
19839
  this.map = dependencies.map;
19739
19840
  this.config = dependencies.config;
19740
19841
  this.modeManager = dependencies.modeManager;
19842
+ this.eventManager = dependencies.eventManager;
19741
19843
  this.getFeatureGroups = dependencies.getFeatureGroups;
19742
19844
  this.initializeSpecializedManagers(dependencies);
19743
19845
  }
@@ -19755,6 +19857,7 @@ class PolygonMutationManager {
19755
19857
  map: dependencies.map,
19756
19858
  config: dependencies.config,
19757
19859
  modeManager: dependencies.modeManager,
19860
+ eventManager: this.eventManager,
19758
19861
  tracer: placeholderTracer
19759
19862
  });
19760
19863
  this.interactionManager = new PolygonInteractionManager(
@@ -19763,7 +19866,8 @@ class PolygonMutationManager {
19763
19866
  polygonInformation: dependencies.polygonInformation,
19764
19867
  map: dependencies.map,
19765
19868
  config: dependencies.config,
19766
- modeManager: dependencies.modeManager
19869
+ modeManager: dependencies.modeManager,
19870
+ eventManager: this.eventManager
19767
19871
  },
19768
19872
  {
19769
19873
  getFeatureGroups: this.getFeatureGroups,
@@ -19777,38 +19881,29 @@ class PolygonMutationManager {
19777
19881
  * Set up event forwarding from specialized managers to facade
19778
19882
  */
19779
19883
  setupEventForwarding() {
19780
- this.drawManager.on("drawCompleted", (data) => {
19781
- this.handleDrawCompleted(data);
19782
- });
19783
- this.drawManager.on("drawCancelled", (data) => {
19884
+ this.eventManager.on("polydraw:draw:cancel", (data) => {
19784
19885
  this.emit("drawCancelled", data);
19785
19886
  });
19786
- this.interactionManager.on("polygonModified", (data) => {
19887
+ this.eventManager.on("polydraw:polygon:updated", (data) => {
19787
19888
  this.handlePolygonModified(data);
19788
19889
  });
19789
- this.interactionManager.on("menuAction", (data) => {
19890
+ this.eventManager.on("polydraw:menu:action", (data) => {
19790
19891
  this.handleMenuAction(data);
19791
19892
  });
19792
- this.interactionManager.on("checkIntersection", (data) => {
19893
+ this.eventManager.on("polydraw:check:intersection", (data) => {
19793
19894
  const hasIntersection = this.geometryManager.checkPolygonIntersection(
19794
19895
  data.polygon1,
19795
19896
  data.polygon2
19796
19897
  );
19797
19898
  data.callback(hasIntersection);
19798
19899
  });
19799
- this.interactionManager.on("performSubtractOperation", (data) => {
19900
+ this.eventManager.on("polydraw:subtract", (data) => {
19800
19901
  this.subtractPolygon(data.subtractPolygon);
19801
19902
  });
19802
- this.interactionManager.on("polygonDeleted", () => {
19903
+ this.eventManager.on("polydraw:polygon:deleted", () => {
19803
19904
  this.emit("polygonDeleted");
19804
19905
  });
19805
19906
  }
19806
- /**
19807
- * Handle draw completion from draw manager
19808
- */
19809
- async handleDrawCompleted(data) {
19810
- await this.addPolygon(data.polygon, { simplify: true });
19811
- }
19812
19907
  /**
19813
19908
  * Handle polygon modification from interaction manager
19814
19909
  */
@@ -19863,19 +19958,13 @@ class PolygonMutationManager {
19863
19958
  * Add event listener
19864
19959
  */
19865
19960
  on(event, callback) {
19866
- if (!this.eventListeners.has(event)) {
19867
- this.eventListeners.set(event, []);
19868
- }
19869
- this.eventListeners.get(event).push(callback);
19961
+ this.eventManager.on(event, callback);
19870
19962
  }
19871
19963
  /**
19872
19964
  * Emit event to all listeners
19873
19965
  */
19874
19966
  emit(event, data) {
19875
- const listeners = this.eventListeners.get(event);
19876
- if (listeners) {
19877
- listeners.forEach((callback) => callback(data));
19878
- }
19967
+ this.eventManager.emit(event, data);
19879
19968
  }
19880
19969
  /**
19881
19970
  * Add a polygon with optional merging logic
@@ -20447,7 +20536,6 @@ class PolygonMutationManager {
20447
20536
  }
20448
20537
  class Polydraw extends L.Control {
20449
20538
  constructor(options) {
20450
- console.log("constructor");
20451
20539
  super(options);
20452
20540
  __publicField(this, "map");
20453
20541
  __publicField(this, "tracer", {});
@@ -20455,6 +20543,7 @@ class Polydraw extends L.Control {
20455
20543
  __publicField(this, "subContainer");
20456
20544
  __publicField(this, "config");
20457
20545
  __publicField(this, "mapStateService");
20546
+ __publicField(this, "eventManager");
20458
20547
  __publicField(this, "polygonInformation");
20459
20548
  __publicField(this, "modeManager");
20460
20549
  __publicField(this, "polygonDrawManager");
@@ -20472,7 +20561,6 @@ class Polydraw extends L.Control {
20472
20561
  * Handle marker hover when modifier key is held - event handler version
20473
20562
  */
20474
20563
  __publicField(this, "onMarkerHoverForEdgeDeletionEvent", (e) => {
20475
- console.log("onMarkerHoverForEdgeDeletionEvent");
20476
20564
  if (!this.isModifierKeyHeld) return;
20477
20565
  const element = e.target;
20478
20566
  if (element) {
@@ -20485,7 +20573,6 @@ class Polydraw extends L.Control {
20485
20573
  * Handle marker leave when modifier key is held - event handler version
20486
20574
  */
20487
20575
  __publicField(this, "onMarkerLeaveForEdgeDeletionEvent", (e) => {
20488
- console.log("onMarkerLeaveForEdgeDeletionEvent");
20489
20576
  const element = e.target;
20490
20577
  if (element) {
20491
20578
  element.style.backgroundColor = "";
@@ -20528,8 +20615,9 @@ class Polydraw extends L.Control {
20528
20615
  initializeComponents() {
20529
20616
  this.turfHelper = new TurfHelper(this.config);
20530
20617
  this.mapStateService = new MapStateService();
20618
+ this.eventManager = new EventManager();
20531
20619
  this.polygonInformation = new PolygonInformationService(this.mapStateService);
20532
- this.modeManager = new ModeManager(this.config);
20620
+ this.modeManager = new ModeManager(this.config, this.eventManager);
20533
20621
  this.polygonInformation.onPolygonInfoUpdated((_k) => {
20534
20622
  this.updateActivateButtonIndicator();
20535
20623
  });
@@ -20543,8 +20631,6 @@ class Polydraw extends L.Control {
20543
20631
  if (L.Browser.touch && L.Browser.mobile) {
20544
20632
  _map.tap = false;
20545
20633
  }
20546
- console.log("iOS touch workaround applied");
20547
- console.log("onAdd");
20548
20634
  this.map = _map;
20549
20635
  const style = document.createElement("style");
20550
20636
  style.innerHTML = `
@@ -20587,7 +20673,6 @@ class Polydraw extends L.Control {
20587
20673
  this.updateActivateButtonIndicator();
20588
20674
  };
20589
20675
  const onDrawClick = (e) => {
20590
- console.log("onDrawClick");
20591
20676
  if (e) {
20592
20677
  e.preventDefault();
20593
20678
  e.stopPropagation();
@@ -20600,7 +20685,6 @@ class Polydraw extends L.Control {
20600
20685
  this.polygonInformation.saveCurrentState();
20601
20686
  };
20602
20687
  const onSubtractClick = (e) => {
20603
- console.log("onSubtractClick");
20604
20688
  if (e) {
20605
20689
  e.preventDefault();
20606
20690
  e.stopPropagation();
@@ -20613,7 +20697,7 @@ class Polydraw extends L.Control {
20613
20697
  this.polygonInformation.saveCurrentState();
20614
20698
  };
20615
20699
  const onEraseClick = (e) => {
20616
- console.log("onEraseClick");
20700
+ this.map.closePopup();
20617
20701
  if (e) {
20618
20702
  e.preventDefault();
20619
20703
  e.stopPropagation();
@@ -20624,7 +20708,6 @@ class Polydraw extends L.Control {
20624
20708
  this.removeAllFeatureGroups();
20625
20709
  };
20626
20710
  const onPointToPointClick = (e) => {
20627
- console.log("onPointToPointClick");
20628
20711
  if (e) {
20629
20712
  e.preventDefault();
20630
20713
  e.stopPropagation();
@@ -20663,6 +20746,7 @@ class Polydraw extends L.Control {
20663
20746
  map: this.map,
20664
20747
  config: this.config,
20665
20748
  modeManager: this.modeManager,
20749
+ eventManager: this.eventManager,
20666
20750
  tracer: this.tracer
20667
20751
  });
20668
20752
  this.polygonMutationManager = new PolygonMutationManager({
@@ -20671,10 +20755,10 @@ class Polydraw extends L.Control {
20671
20755
  map: this.map,
20672
20756
  config: this.config,
20673
20757
  modeManager: this.modeManager,
20758
+ eventManager: this.eventManager,
20674
20759
  getFeatureGroups: () => this.arrayOfFeatureGroups
20675
20760
  });
20676
20761
  this.polygonMutationManager.on("polygonOperationComplete", (data) => {
20677
- console.log("polygonOperationComplete");
20678
20762
  this.updateActivateButtonIndicator();
20679
20763
  this.modeManager.updateStateForMode(DrawMode.Off);
20680
20764
  this.drawMode = DrawMode.Off;
@@ -20699,7 +20783,7 @@ class Polydraw extends L.Control {
20699
20783
  this.polygonMutationManager.on("polygonDeleted", () => {
20700
20784
  this.updateActivateButtonIndicator();
20701
20785
  });
20702
- this.polygonDrawManager.on("drawCompleted", async (data) => {
20786
+ this.eventManager.on("polydraw:polygon:created", async (data) => {
20703
20787
  this.stopDraw();
20704
20788
  if (data.isPointToPoint) {
20705
20789
  await this.polygonMutationManager.addPolygon(data.polygon, {
@@ -20711,14 +20795,13 @@ class Polydraw extends L.Control {
20711
20795
  }
20712
20796
  this.polygonInformation.createPolygonInformationStorage(this.arrayOfFeatureGroups);
20713
20797
  });
20714
- this.polygonDrawManager.on("drawCancelled", () => {
20798
+ this.eventManager.on("polydraw:draw:cancel", () => {
20715
20799
  this.stopDraw();
20716
20800
  this.setDrawMode(DrawMode.Off);
20717
20801
  });
20718
20802
  return container;
20719
20803
  }
20720
20804
  addTo(map) {
20721
- console.log("addTo");
20722
20805
  super.addTo(map);
20723
20806
  return this;
20724
20807
  }
@@ -20726,7 +20809,6 @@ class Polydraw extends L.Control {
20726
20809
  return this.arrayOfFeatureGroups;
20727
20810
  }
20728
20811
  onRemove(_map) {
20729
- console.log("onRemove");
20730
20812
  this.removeKeyboardHandlers();
20731
20813
  if (this.tracer) {
20732
20814
  this.map.removeLayer(this.tracer);
@@ -20734,7 +20816,6 @@ class Polydraw extends L.Control {
20734
20816
  this.removeAllFeatureGroups();
20735
20817
  }
20736
20818
  async addPredefinedPolygon(geographicBorders, options) {
20737
- console.log("addPredefinedPolygon");
20738
20819
  if (!geographicBorders || geographicBorders.length === 0) {
20739
20820
  throw new Error("Cannot add empty polygon array");
20740
20821
  }
@@ -20771,7 +20852,6 @@ class Polydraw extends L.Control {
20771
20852
  }
20772
20853
  }
20773
20854
  setDrawMode(mode) {
20774
- console.log("setDrawMode");
20775
20855
  const previousMode = this.drawMode;
20776
20856
  this.drawMode = mode;
20777
20857
  this.modeManager.updateStateForMode(mode);
@@ -20828,22 +20908,18 @@ class Polydraw extends L.Control {
20828
20908
  }
20829
20909
  }
20830
20910
  getDrawMode() {
20831
- console.log("getDrawMode");
20832
20911
  return this.modeManager.getCurrentMode();
20833
20912
  }
20834
- onDrawModeChangeListener(callback) {
20835
- console.log("onDrawModeChangeListener");
20836
- this.drawModeListeners.push(callback);
20913
+ on(event, callback) {
20914
+ this.eventManager.on(event, callback);
20837
20915
  }
20838
- offDrawModeChangeListener(callback) {
20839
- console.log("offDrawModeChangeListener");
20840
- const index = this.drawModeListeners.indexOf(callback);
20841
- if (index > -1) {
20842
- this.drawModeListeners.splice(index, 1);
20843
- }
20916
+ off(event, callback) {
20917
+ this.eventManager.off(event, callback);
20844
20918
  }
20845
20919
  emitDrawModeChanged() {
20846
- console.log("emitDrawModeChanged");
20920
+ this.eventManager.emit("polydraw:mode:change", {
20921
+ mode: this.modeManager.getCurrentMode()
20922
+ });
20847
20923
  for (const cb of this.drawModeListeners) {
20848
20924
  cb(this.modeManager.getCurrentMode());
20849
20925
  }
@@ -20852,7 +20928,6 @@ class Polydraw extends L.Control {
20852
20928
  * Update the draggable state of all existing markers when draw mode changes
20853
20929
  */
20854
20930
  updateMarkerDraggableState() {
20855
- console.log("updateMarkerDraggableState");
20856
20931
  const shouldBeDraggable = this.modeManager.canPerformAction("markerDrag");
20857
20932
  this.arrayOfFeatureGroups.forEach((featureGroup) => {
20858
20933
  featureGroup.eachLayer((layer) => {
@@ -20874,7 +20949,6 @@ class Polydraw extends L.Control {
20874
20949
  });
20875
20950
  }
20876
20951
  removeAllFeatureGroups() {
20877
- console.log("removeAllFeatureGroups");
20878
20952
  this.arrayOfFeatureGroups.forEach((featureGroups) => {
20879
20953
  try {
20880
20954
  this.map.removeLayer(featureGroups);
@@ -20887,22 +20961,18 @@ class Polydraw extends L.Control {
20887
20961
  this.updateActivateButtonIndicator();
20888
20962
  }
20889
20963
  stopDraw() {
20890
- console.log("stopDraw");
20891
20964
  this.resetTracker();
20892
20965
  this.drawStartedEvents(false);
20893
20966
  }
20894
20967
  setLeafletMapEvents(enableDragging, enableDoubleClickZoom, enableScrollWheelZoom) {
20895
- console.log("setLeafletMapEvents");
20896
20968
  enableDragging ? this.map.dragging.enable() : this.map.dragging.disable();
20897
20969
  enableDoubleClickZoom ? this.map.doubleClickZoom.enable() : this.map.doubleClickZoom.disable();
20898
20970
  enableScrollWheelZoom ? this.map.scrollWheelZoom.enable() : this.map.scrollWheelZoom.disable();
20899
20971
  }
20900
20972
  resetTracker() {
20901
- console.log("resetTracker");
20902
20973
  this.tracer.setLatLngs([]);
20903
20974
  }
20904
20975
  drawStartedEvents(onoff) {
20905
- console.log("drawStartedEvents");
20906
20976
  const onoroff = onoff ? "on" : "off";
20907
20977
  this.map[onoroff]("mousemove", this.mouseMove, this);
20908
20978
  this.map[onoroff]("mouseup", this.mouseUpLeave, this);
@@ -20921,7 +20991,6 @@ class Polydraw extends L.Control {
20921
20991
  }
20922
20992
  }
20923
20993
  mouseMove(event) {
20924
- console.log("mouseMove");
20925
20994
  if ("cancelable" in event && event.cancelable) {
20926
20995
  event.preventDefault();
20927
20996
  }
@@ -20966,7 +21035,6 @@ class Polydraw extends L.Control {
20966
21035
  if ("cancelable" in event && event.cancelable) {
20967
21036
  event.preventDefault();
20968
21037
  }
20969
- console.log("mouseUpLeave");
20970
21038
  this.polygonInformation.deletePolygonInformationStorage();
20971
21039
  const tracerGeoJSON = this.tracer.toGeoJSON();
20972
21040
  if (!tracerGeoJSON || !tracerGeoJSON.geometry || !tracerGeoJSON.geometry.coordinates || tracerGeoJSON.geometry.coordinates.length < 3) {
@@ -21013,7 +21081,6 @@ class Polydraw extends L.Control {
21013
21081
  this.polygonInformation.createPolygonInformationStorage(this.arrayOfFeatureGroups);
21014
21082
  }
21015
21083
  events(onoff) {
21016
- console.log("events");
21017
21084
  const onoroff = onoff ? "on" : "off";
21018
21085
  this.map[onoroff]("mousedown", this.mouseDown, this);
21019
21086
  this.map[onoroff]("dblclick", this.handleDoubleClick, this);
@@ -21030,7 +21097,6 @@ class Polydraw extends L.Control {
21030
21097
  if ("cancelable" in event && event.cancelable) {
21031
21098
  event.preventDefault();
21032
21099
  }
21033
- console.log("mouseDown");
21034
21100
  if (this.modeManager.isInOffMode()) {
21035
21101
  return;
21036
21102
  }
@@ -21054,22 +21120,18 @@ class Polydraw extends L.Control {
21054
21120
  this.startDraw();
21055
21121
  }
21056
21122
  startDraw() {
21057
- console.log("startDraw");
21058
21123
  this.drawStartedEvents(true);
21059
21124
  }
21060
21125
  setupKeyboardHandlers() {
21061
- console.log("setupKeyboardHandlers");
21062
21126
  this._boundKeyUpHandler = this.handleKeyUp.bind(this);
21063
21127
  document.addEventListener("keydown", this._boundKeyDownHandler);
21064
21128
  document.addEventListener("keyup", this._boundKeyUpHandler);
21065
21129
  }
21066
21130
  removeKeyboardHandlers() {
21067
- console.log("removeKeyboardHandlers");
21068
21131
  document.removeEventListener("keydown", this._boundKeyDownHandler);
21069
21132
  document.removeEventListener("keyup", this._boundKeyUpHandler);
21070
21133
  }
21071
21134
  handleKeyDown(e) {
21072
- console.log("handleKeyDown");
21073
21135
  if (e.key === "Escape") {
21074
21136
  if (this.modeManager.getCurrentMode() === DrawMode.PointToPoint) {
21075
21137
  this.polygonDrawManager.cancelPointToPointDrawing();
@@ -21083,7 +21145,6 @@ class Polydraw extends L.Control {
21083
21145
  }
21084
21146
  }
21085
21147
  handleKeyUp(e) {
21086
- console.log("handleKeyUp");
21087
21148
  const isModifierPressed = this.isModifierKeyPressed(e);
21088
21149
  if (!isModifierPressed && this.isModifierKeyHeld) {
21089
21150
  this.isModifierKeyHeld = false;
@@ -21095,7 +21156,6 @@ class Polydraw extends L.Control {
21095
21156
  * Update all markers to show/hide edge deletion visual feedback
21096
21157
  */
21097
21158
  updateAllMarkersForEdgeDeletion(showFeedback) {
21098
- console.log("updateAllMarkersForEdgeDeletion");
21099
21159
  this.arrayOfFeatureGroups.forEach((featureGroup) => {
21100
21160
  featureGroup.eachLayer((layer) => {
21101
21161
  if (layer instanceof L.Marker) {
@@ -21108,7 +21168,6 @@ class Polydraw extends L.Control {
21108
21168
  * Update individual marker for edge deletion visual feedback
21109
21169
  */
21110
21170
  updateMarkerForEdgeDeletion(marker, showFeedback) {
21111
- console.log("updateMarkerForEdgeDeletion");
21112
21171
  const element = marker.getElement();
21113
21172
  if (!element) return;
21114
21173
  if (showFeedback) {
@@ -21122,7 +21181,6 @@ class Polydraw extends L.Control {
21122
21181
  }
21123
21182
  }
21124
21183
  handleDoubleClick(e) {
21125
- console.log("handleDoubleClick");
21126
21184
  if (this.modeManager.getCurrentMode() !== DrawMode.PointToPoint) {
21127
21185
  return;
21128
21186
  }
@@ -21132,10 +21190,6 @@ class Polydraw extends L.Control {
21132
21190
  * Detect if modifier key is pressed (Ctrl on Windows/Linux, Cmd on Mac)
21133
21191
  */
21134
21192
  isModifierKeyPressed(event) {
21135
- console.log("isModifierKeyPressed");
21136
- if (isTouchDevice()) {
21137
- return false;
21138
- }
21139
21193
  const userAgent = navigator.userAgent.toLowerCase();
21140
21194
  const isMac = userAgent.includes("mac");
21141
21195
  if (isMac) {