L.Control.Ruler=L.Control.extend({options:{position:"topright",circleMarker:{color:"red",radius:2},lineStyle:{color:"red",dashArray:"1,6"},lengthUnit:{display:"km",decimal:2,factor:.001,label:"Distance:"},angleUnit:{display:"°",decimal:2,factor:360,label:"Bearing:"}},initialize(t){L.Util.setOptions(this,t),this._layers=new L.LayerGroup,this._enabled=!1},onAdd(t){this._defaultCursor=t._container.style.cursor,this._map=t;let e=L.DomUtil.create("div","leaflet-bar");return e.classList.add("leaflet-ruler"),L.DomEvent.disableClickPropagation(e),L.DomEvent.on(e,"click",this._toggleMeasure,this),this._container=e},onRemove(){L.DomEvent.off(this._container,"click",this._toggleMeasure,this)},_attachMouseEvents(){let t=this._map;t.doubleClickZoom.disable(),L.DomEvent.on(t._container,"keydown",this._escape,this),L.DomEvent.on(t._container,"dblclick",this._closePath,this),t._container.style.cursor="crosshair",t.on("click",this._addPoint,this),t.on(L.version.startsWith("2")?"pointermove":"mousemove",this._moving,this)},_removeMouseEvents(){let t=this._map;t.doubleClickZoom.enable(),L.DomEvent.off(t._container,"keydown",this._escape,this),L.DomEvent.off(t._container,"dblclick",this._closePath,this),t._container.style.cursor=this._defaultCursor,t.off("click",this._addPoint,this),t.off(L.version.startsWith("2")?"pointermove":"mousemove",this._moving,this)},_disable(){this._enabled=!1,this._container.classList.remove("leaflet-ruler-clicked"),this._layers.remove().clearLayers(),this._latlngs=[],this._totalLength=0,this._removeMouseEvents()},_enable(){this._enabled=!0,this._container.classList.add("leaflet-ruler-clicked"),this._circles=new L.FeatureGroup().addTo(this._layers),this._polyline=new L.Polyline([],this.options.lineStyle).addTo(this._layers),this._layers.addTo(this._map),this._latlngs=[],this._totalLength=0,this._attachMouseEvents()},_toggleMeasure(){this._enabled?this._disable():this._enable()},_drawTooltip(t,e,i){let s=this._latlngs[this._latlngs.length-1]??t,o=this._calculateBearing(s,t),l=s.distanceTo(t)*this.options.lengthUnit.factor,n=this._totalLength+l,a=n.toFixed(this.options.lengthUnit.decimal),h=i?'