terra-draw 0.0.1-alpha.66 → 0.0.1-alpha.67
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/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.modern.js +1 -1
- package/dist/terra-draw.modern.js.map +1 -1
- package/dist/terra-draw.module.js +1 -1
- package/dist/terra-draw.module.js.map +1 -1
- package/dist/terra-draw.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/terra-draw.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function t(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}function e(e,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,t(r.key),r)}}function i(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(){return n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},n.apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function s(t,e){void 0===e&&(e=9);var i=Math.pow(10,e);return Math.round(t*i)/i}var a=function(t,e){var i=e.x-t.x,n=e.y-t.y;return Math.sqrt(n*n+i*i)},l=function(t){var e=this,i=t.name,n=t.callback,r=t.unregister,o=t.register;this.name=void 0,this.callback=void 0,this.registered=!1,this.register=void 0,this.unregister=void 0,this.name=i,this.register=function(){e.registered||(e.registered=!0,o(n))},this.unregister=function(){e.register&&(e.registered=!1,r(n))},this.callback=n},c=/*#__PURE__*/function(){function t(t){this._minPixelDragDistance=void 0,this._minPixelDragDistanceDrawing=void 0,this._minPixelDragDistanceSelecting=void 0,this._lastDrawEvent=void 0,this._coordinatePrecision=void 0,this._heldKeys=new Set,this._listeners=[],this._dragState="not-dragging",this._currentModeCallbacks=void 0,this._minPixelDragDistance="number"==typeof t.minPixelDragDistance?t.minPixelDragDistance:1,this._minPixelDragDistanceSelecting="number"==typeof t.minPixelDragDistanceSelecting?t.minPixelDragDistanceSelecting:1,this._minPixelDragDistanceDrawing="number"==typeof t.minPixelDragDistanceDrawing?t.minPixelDragDistanceDrawing:8,this._coordinatePrecision="number"==typeof t.coordinatePrecision?t.coordinatePrecision:9}var e=t.prototype;return e.getButton=function(t){return-1===t.button?"neither":0===t.button?"left":1===t.button?"middle":2===t.button?"right":"neither"},e.getMapElementXYPosition=function(t){var e=this.getMapEventElement().getBoundingClientRect();return{containerX:t.clientX-e.left,containerY:t.clientY-e.top}},e.getDrawEventFromEvent=function(t){var e=this.getLngLatFromEvent(t);if(!e)return null;var i=e.lng,n=e.lat,r=this.getMapElementXYPosition(t),o=r.containerX,a=r.containerY,l=this.getButton(t),c=Array.from(this._heldKeys);return{lng:s(i,this._coordinatePrecision),lat:s(n,this._coordinatePrecision),containerX:o,containerY:a,button:l,heldKeys:c}},e.register=function(t){this._currentModeCallbacks=t,this._listeners=this.getAdapterListeners(),this._listeners.forEach(function(t){t.register()})},e.getCoordinatePrecision=function(){return this._coordinatePrecision},e.getAdapterListeners=function(){var t=this;return[new l({name:"pointerdown",callback:function(e){if(t._currentModeCallbacks&&e.isPrimary){var i=t.getDrawEventFromEvent(e);i&&(t._dragState="pre-dragging",t._lastDrawEvent=i)}},register:function(e){t.getMapEventElement().addEventListener("pointerdown",e)},unregister:function(e){t.getMapEventElement().removeEventListener("pointerdown",e)}}),new l({name:"pointermove",callback:function(e){if(t._currentModeCallbacks&&e.isPrimary){e.preventDefault();var i=t.getDrawEventFromEvent(e);if(i)if("not-dragging"===t._dragState)t._currentModeCallbacks.onMouseMove(i),t._lastDrawEvent=i;else if("pre-dragging"===t._dragState){if(!t._lastDrawEvent)return;var n={x:t._lastDrawEvent.containerX,y:t._lastDrawEvent.containerY},r={x:i.containerX,y:i.containerY},o=t._currentModeCallbacks.getState(),s=a(n,r);if("drawing"===o?s<t._minPixelDragDistanceDrawing:"selecting"===o?s<t._minPixelDragDistanceSelecting:s<t._minPixelDragDistance)return;t._dragState="dragging",t._currentModeCallbacks.onDragStart(i,function(e){t.setDraggability.bind(t)(e)})}else"dragging"===t._dragState&&t._currentModeCallbacks.onDrag(i,function(e){t.setDraggability.bind(t)(e)})}},register:function(e){t.getMapEventElement().addEventListener("pointermove",e)},unregister:function(e){t.getMapEventElement().removeEventListener("pointermove",e)}}),new l({name:"contextmenu",callback:function(e){if(t._currentModeCallbacks&&(e.preventDefault(),"not-dragging"===t._dragState||"pre-dragging"===t._dragState)){var i=t.getDrawEventFromEvent(e);if(!i)return;"neither"!==i.button&&t._currentModeCallbacks.onClick(i)}},register:function(e){t.getMapEventElement().addEventListener("contextmenu",e)},unregister:function(e){t.getMapEventElement().removeEventListener("contextmenu",e)}}),new l({name:"pointerup",callback:function(e){if(t._currentModeCallbacks&&e.target===t.getMapEventElement()&&e.isPrimary){var i=t.getDrawEventFromEvent(e);i&&("dragging"===t._dragState?t._currentModeCallbacks.onDragEnd(i,function(e){t.setDraggability.bind(t)(e)}):"not-dragging"!==t._dragState&&"pre-dragging"!==t._dragState||t._currentModeCallbacks.onClick(i),t._dragState="not-dragging",t.setDraggability(!0))}},register:function(e){t.getMapEventElement().addEventListener("pointerup",e)},unregister:function(e){t.getMapEventElement().removeEventListener("pointerup",e)}}),new l({name:"keyup",callback:function(e){t._currentModeCallbacks&&(t._heldKeys.delete(e.key),t._currentModeCallbacks.onKeyUp({key:e.key,heldKeys:Array.from(t._heldKeys),preventDefault:function(){return e.preventDefault()}}))},register:function(e){t.getMapEventElement().addEventListener("keyup",e)},unregister:function(e){t.getMapEventElement().removeEventListener("keyup",e)}}),new l({name:"keydown",callback:function(e){t._currentModeCallbacks&&(t._heldKeys.add(e.key),t._currentModeCallbacks.onKeyDown({key:e.key,heldKeys:Array.from(t._heldKeys),preventDefault:function(){return e.preventDefault()}}))},register:function(e){t.getMapEventElement().addEventListener("keydown",e)},unregister:function(e){t.getMapEventElement().removeEventListener("keydown",e)}})]},e.unregister=function(){this._listeners.forEach(function(t){t.unregister()}),this.clear()},t}(),d=/*#__PURE__*/function(t){function e(e){var i;if((i=t.call(this,e)||this)._cursor=void 0,i._cursorStyleSheet=void 0,i._lib=void 0,i._map=void 0,i._overlay=void 0,i._clickEventListener=void 0,i._mouseMoveEventListener=void 0,i.renderedFeatureIds=new Set,i._lib=e.lib,i._map=e.map,!i._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");return i._coordinatePrecision="number"==typeof e.coordinatePrecision?e.coordinatePrecision:9,i}r(e,t);var n=e.prototype;return n.circlePath=function(t,e,i){var n=2*i;return"M "+t+" "+e+" m -"+i+", 0 a "+i+","+i+" 0 1,0 "+n+",0 a "+i+","+i+" 0 1,0 -"+n+",0"},n.register=function(e){var i=this;t.prototype.register.call(this,e),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=function(){i._currentModeCallbacks&&i._currentModeCallbacks.onReady&&i._currentModeCallbacks.onReady()},this._overlay.setMap(this._map),this._clickEventListener=this._map.data.addListener("click",function(t){var e=i._listeners.find(function(t){return"click"===t.name});e&&e.callback(t)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",function(t){var e=i._listeners.find(function(t){return"mousemove"===t.name});e&&e.callback(t)})},n.unregister=function(){var e,i,n;t.prototype.unregister.call(this),null==(e=this._clickEventListener)||e.remove(),null==(i=this._mouseMoveEventListener)||i.remove(),null==(n=this._overlay)||n.setMap(null),this._overlay=void 0},n.getLngLatFromEvent=function(t){if(!this._overlay)throw new Error("cannot get overlay");var e=this._map.getBounds();if(!e)return null;var i=e.getNorthEast(),n=e.getSouthWest(),r=new this._lib.LatLngBounds(n,i),o=this._map.getDiv(),s=t.clientX-o.getBoundingClientRect().left,a=t.clientY-o.getBoundingClientRect().top,l=new this._lib.Point(s,a),c=this._overlay.getProjection();if(!c)return null;var d=c.fromContainerPixelToLatLng(l);return d&&r.contains(d)?{lng:d.lng(),lat:d.lat()}:null},n.getMapEventElement=function(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')},n.project=function(t,e){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");var i=this._overlay.getProjection();if(void 0===i)throw new Error("cannot get projection");var n=i.fromLatLngToContainerPixel(new this._lib.LatLng(e,t));if(null===n)throw new Error("cannot project coordinates");return{x:n.x,y:n.y}},n.unproject=function(t,e){if(!this._overlay)throw new Error("cannot get overlay");var i=this._overlay.getProjection();if(void 0===i)throw new Error("cannot get projection");var n=i.fromContainerPixelToLatLng(new this._lib.Point(t,e));if(null===n)throw new Error("cannot unproject coordinates");return{lng:n.lng(),lat:n.lat()}},n.setCursor=function(t){if(t!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==t){var e=this._map.getDiv(),i=document.querySelector("#"+e.id+" .gm-style > div");if(i){i.classList.add("terra-draw-google-maps");var n=document.createElement("style");n.innerHTML=".terra-draw-google-maps { cursor: "+t+" !important; }",document.getElementsByTagName("head")[0].appendChild(n),this._cursorStyleSheet=n}}this._cursor=t}},n.setDoubleClickToZoom=function(t){this._map.setOptions(t?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})},n.setDraggability=function(t){this._map.setOptions({draggable:t})},n.render=function(t,e){var i=this;this._layers&&(t.deletedIds.forEach(function(t){var e=i._map.data.getFeatureById(t);e&&(i._map.data.remove(e),i.renderedFeatureIds.delete(t))}),t.updated.forEach(function(t){if(!t||!t.id)throw new Error("Feature is not valid");var e=i._map.data.getFeatureById(t.id);if(!e)throw new Error("Feature could not be found by Google Maps API");switch(e.forEachProperty(function(t,i){e.setProperty(i,void 0)}),Object.keys(t.properties).forEach(function(i){e.setProperty(i,t.properties[i])}),t.geometry.type){case"Point":var n=t.geometry.coordinates;e.setGeometry(new i._lib.Data.Point(new i._lib.LatLng(n[1],n[0])));break;case"LineString":for(var r=t.geometry.coordinates,o=[],s=0;s<r.length;s++){var a=r[s],l=new i._lib.LatLng(a[1],a[0]);o.push(l)}e.setGeometry(new i._lib.Data.LineString(o));break;case"Polygon":for(var c=t.geometry.coordinates,d=[],h=0;h<c.length;h++){for(var u=[],g=0;g<c[h].length;g++){var p=new i._lib.LatLng(c[h][g][1],c[h][g][0]);u.push(p)}d.push(u)}e.setGeometry(new i._lib.Data.Polygon(d))}}),t.created.forEach(function(t){i.renderedFeatureIds.add(t.id),i._map.data.addGeoJson(t)})),t.created.forEach(function(t){i.renderedFeatureIds.add(t.id)});var n={type:"FeatureCollection",features:[].concat(t.created)};this._map.data.addGeoJson(n),this._map.data.setStyle(function(t){var n=t.getProperty("mode"),r=t.getGeometry();if(!r)throw new Error("Google Maps geometry not found");var o=r.getType(),s={};t.forEachProperty(function(t,e){s[e]=t});var a=e[n]({type:"Feature",geometry:{type:o,coordinates:[]},properties:s});switch(o){case"Point":return{clickable:!1,icon:{path:i.circlePath(0,0,a.pointWidth),fillColor:a.pointColor,fillOpacity:1,strokeColor:a.pointOutlineColor,strokeWeight:a.pointOutlineWidth,rotation:0,scale:1}};case"LineString":return{strokeColor:a.lineStringColor,strokeWeight:a.lineStringWidth};case"Polygon":return{strokeColor:a.polygonOutlineColor,strokeWeight:a.polygonOutlineWidth,fillOpacity:a.polygonFillOpacity,fillColor:a.polygonFillColor}}throw Error("Unknown feature type")})},n.clearLayers=function(){var t=this;this._layers&&(this._map.data.forEach(function(e){var i=e.getId();t.renderedFeatureIds.has(i)&&t._map.data.remove(e)}),this.renderedFeatureIds=new Set)},n.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},n.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i(e,[{key:"_layers",get:function(){var t;return Boolean((null==(t=this.renderedFeatureIds)?void 0:t.size)>0)}}]),e}(c),h=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this)._lib=void 0,i._map=void 0,i._panes={},i._container=void 0,i._layers={},i._lib=e.lib,i._map=e.map,i._container=i._map.getContainer(),i}r(e,t);var i=e.prototype;return i.createPaneStyleSheet=function(t,e){var i=document.createElement("style");return i.innerHTML=".leaflet-"+t+" {z-index: "+e+";}",document.getElementsByTagName("head")[0].appendChild(i),this._map.createPane(t),i},i.clearPanes=function(){Object.values(this._panes).forEach(function(t){t&&t.remove()}),this._panes={}},i.clearLayers=function(){var t=this;Object.values(this._layers).forEach(function(e){t._map.removeLayer(e)}),this._layers={}},i.styleGeoJSONLayer=function(t){var e=this;return{pointToLayer:function(i,n){if(!i.properties)throw new Error("Feature has no properties");if("string"!=typeof i.properties.mode)throw new Error("Feature mode is not a string");var r=(0,t[i.properties.mode])(i),o=String(r.zIndex);return e._panes[o]||(e._panes[o]=e.createPaneStyleSheet(o,r.zIndex)),e._lib.circleMarker(n,{radius:r.pointWidth,stroke:r.pointOutlineWidth||!1,color:r.pointOutlineColor,weight:r.pointOutlineWidth,fillOpacity:.8,fillColor:r.pointColor,pane:o,interactive:!1})},style:function(i){if(!i||!i.properties)return{};var n=i,r=(0,t[n.properties.mode])(n),o=String(r.zIndex);return e._panes[o]||(e._panes[o]=e.createPaneStyleSheet(o,r.zIndex)),"LineString"===n.geometry.type?{interactive:!1,color:r.lineStringColor,weight:r.lineStringWidth,pane:o}:"Polygon"===n.geometry.type?{interactive:!1,fillOpacity:r.polygonFillOpacity,fillColor:r.polygonFillColor,weight:r.polygonOutlineWidth,stroke:!0,color:r.polygonFillColor,pane:o}:{}}}},i.getLngLatFromEvent=function(t){var e=this.getMapElementXYPosition(t),i={x:e.containerX,y:e.containerY};if(isNaN(i.x)||isNaN(i.y))return null;var n=this._map.containerPointToLatLng(i);return isNaN(n.lng)||isNaN(n.lat)?null:{lng:n.lng,lat:n.lat}},i.getMapEventElement=function(){return this._container},i.setDraggability=function(t){t?this._map.dragging.enable():this._map.dragging.disable()},i.project=function(t,e){var i=this._map.latLngToContainerPoint({lng:t,lat:e});return{x:i.x,y:i.y}},i.unproject=function(t,e){var i=this._map.containerPointToLatLng({x:t,y:e});return{lng:i.lng,lat:i.lat}},i.setCursor=function(t){"unset"===t?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=t},i.setDoubleClickToZoom=function(t){t?this._map.doubleClickZoom.enable():this._map.doubleClickZoom.disable()},i.render=function(t,e){var i=this;t.created.forEach(function(t){i._layers[t.id]=i._lib.geoJSON(t,i.styleGeoJSONLayer(e)),i._map.addLayer(i._layers[t.id])}),t.deletedIds.forEach(function(t){i._map.removeLayer(i._layers[t])}),t.updated.forEach(function(t){i._map.removeLayer(i._layers[t.id]),i._layers[t.id]=i._lib.geoJSON(t,i.styleGeoJSONLayer(e)),i._map.addLayer(i._layers[t.id])})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers(),this.clearPanes())},i.register=function(e){t.prototype.register.call(this,e),this._currentModeCallbacks&&this._currentModeCallbacks.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){return t.prototype.unregister.call(this)},e}(c),u=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this)._nextRender=void 0,i._map=void 0,i._container=void 0,i._rendered=!1,i.changedIds={deletion:!1,points:!1,linestrings:!1,polygons:!1,styling:!1},i._map=e.map,i._container=i._map.getContainer(),i}r(e,t);var i=e.prototype;return i.clearLayers=function(){var t=this;this._rendered&&(["point","linestring","polygon"].forEach(function(e){var i="td-"+e.toLowerCase();t._map.removeLayer(i),"polygon"===e&&t._map.removeLayer(i+"-outline"),t._map.removeSource(i)}),this._rendered=!1,this._nextRender&&(cancelAnimationFrame(this._nextRender),this._nextRender=void 0))},i._addGeoJSONSource=function(t,e){this._map.addSource(t,{type:"geojson",data:{type:"FeatureCollection",features:e},tolerance:0})},i._addFillLayer=function(t){return this._map.addLayer({id:t,source:t,type:"fill",paint:{"fill-color":["get","polygonFillColor"],"fill-opacity":["get","polygonFillOpacity"]}})},i._addFillOutlineLayer=function(t,e){var i=this._map.addLayer({id:t+"-outline",source:t,type:"line",paint:{"line-width":["get","polygonOutlineWidth"],"line-color":["get","polygonOutlineColor"]}});return e&&this._map.moveLayer(t,e),i},i._addLineLayer=function(t,e){var i=this._map.addLayer({id:t,source:t,type:"line",paint:{"line-width":["get","lineStringWidth"],"line-color":["get","lineStringColor"]}});return e&&this._map.moveLayer(t,e),i},i._addPointLayer=function(t,e){var i=this._map.addLayer({id:t,source:t,type:"circle",paint:{"circle-stroke-color":["get","pointOutlineColor"],"circle-stroke-width":["get","pointOutlineWidth"],"circle-radius":["get","pointWidth"],"circle-color":["get","pointColor"]}});return e&&this._map.moveLayer(t,e),i},i._addLayer=function(t,e,i){"Point"===e&&this._addPointLayer(t,i),"LineString"===e&&this._addLineLayer(t,i),"Polygon"===e&&(this._addFillLayer(t),this._addFillOutlineLayer(t,i))},i._addGeoJSONLayer=function(t,e){var i="td-"+t.toLowerCase();return this._addGeoJSONSource(i,e),this._addLayer(i,t),i},i._setGeoJSONLayerData=function(t,e){var i="td-"+t.toLowerCase();return this._map.getSource(i).setData({type:"FeatureCollection",features:e}),i},i.getEmptyGeometries=function(){return{points:[],linestrings:[],polygons:[]}},i.updateChangedIds=function(t){var e=this;[].concat(t.updated,t.created).forEach(function(t){"Point"===t.geometry.type?e.changedIds.points=!0:"LineString"===t.geometry.type?e.changedIds.linestrings=!0:"Polygon"===t.geometry.type&&(e.changedIds.polygons=!0)}),t.deletedIds.length>0&&(this.changedIds.deletion=!0),0===t.created.length&&0===t.updated.length&&0===t.deletedIds.length&&(this.changedIds.styling=!0)},i.getLngLatFromEvent=function(t){var e=this._container.getBoundingClientRect();return this.unproject(t.clientX-e.left,t.clientY-e.top)},i.getMapEventElement=function(){return this._map.getCanvas()},i.setDraggability=function(t){t?(this._map.dragRotate.enable(),this._map.dragPan.enable()):(this._map.dragRotate.disable(),this._map.dragPan.disable())},i.project=function(t,e){var i=this._map.project({lng:t,lat:e});return{x:i.x,y:i.y}},i.unproject=function(t,e){var i=this._map.unproject({x:t,y:e});return{lng:i.lng,lat:i.lat}},i.setCursor=function(t){var e=this._map.getCanvas();"unset"===t?e.style.removeProperty("cursor"):e.style.cursor=t},i.setDoubleClickToZoom=function(t){t?this._map.doubleClickZoom.enable():this._map.doubleClickZoom.disable()},i.render=function(t,e){var i=this;this.updateChangedIds(t),this._nextRender&&cancelAnimationFrame(this._nextRender),this._nextRender=requestAnimationFrame(function(){for(var n=[].concat(t.created,t.updated,t.unchanged),r=i.getEmptyGeometries(),o=function(t){var i=n[t];Object.keys(e).forEach(function(t){var n=i.properties;if(n.mode===t){var o=e[t](i);"Point"===i.geometry.type?(n.pointColor=o.pointColor,n.pointOutlineColor=o.pointOutlineColor,n.pointOutlineWidth=o.pointOutlineWidth,n.pointWidth=o.pointWidth,r.points.push(i)):"LineString"===i.geometry.type?(n.lineStringColor=o.lineStringColor,n.lineStringWidth=o.lineStringWidth,r.linestrings.push(i)):"Polygon"===i.geometry.type&&(n.polygonFillColor=o.polygonFillColor,n.polygonFillOpacity=o.polygonFillOpacity,n.polygonOutlineColor=o.polygonOutlineColor,n.polygonOutlineWidth=o.polygonOutlineWidth,r.polygons.push(i))}})},s=0;s<n.length;s++)o(s);var a=r.points,l=r.linestrings,c=r.polygons;if(i._rendered){var d,h=i.changedIds.deletion||i.changedIds.styling,u=h||i.changedIds.linestrings,g=h||i.changedIds.polygons;(h||i.changedIds.points)&&(d=i._setGeoJSONLayerData("Point",a)),u&&i._setGeoJSONLayerData("LineString",l),g&&i._setGeoJSONLayerData("Polygon",c),d&&i._map.moveLayer(d)}else{var p=i._addGeoJSONLayer("Point",a);i._addGeoJSONLayer("LineString",l),i._addGeoJSONLayer("Polygon",c),i._rendered=!0,p&&i._map.moveLayer(p)}i.changedIds={points:!1,linestrings:!1,polygons:!1,deletion:!1,styling:!1}})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){return t.prototype.unregister.call(this)},i.register=function(e){t.prototype.register.call(this,e),this._currentModeCallbacks&&this._currentModeCallbacks.onReady&&this._currentModeCallbacks.onReady()},e}(c),g=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this).mapboxglAdapter=void 0,i.mapboxglAdapter=new u(e),i}r(e,t);var i=e.prototype;return i.register=function(t){this.mapboxglAdapter.register(t)},i.unregister=function(){this.mapboxglAdapter.unregister()},i.getCoordinatePrecision=function(){return this.mapboxglAdapter.getCoordinatePrecision()},i.getLngLatFromEvent=function(t){return this.mapboxglAdapter.getLngLatFromEvent(t)},i.getMapEventElement=function(){return this.mapboxglAdapter.getMapEventElement()},i.setDraggability=function(t){this.mapboxglAdapter.setDraggability(t)},i.project=function(t,e){return this.mapboxglAdapter.project(t,e)},i.unproject=function(t,e){return this.mapboxglAdapter.unproject(t,e)},i.setCursor=function(t){this.mapboxglAdapter.setCursor(t)},i.setDoubleClickToZoom=function(t){this.mapboxglAdapter.setDoubleClickToZoom(t)},i.render=function(t,e){this.mapboxglAdapter.render(t,e)},i.clear=function(){this.mapboxglAdapter.clear()},e}(c);function p(){throw new Error("Unimplemented abstract method.")}let f=0;function y(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}class v{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=y(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new v({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return p()}getImage(t){return p()}getHitDetectionImage(){return p()}getPixelRatio(t){return 1}getImageState(){return p()}getImageSize(){return p()}getOrigin(){return p()}getSize(){return p()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=y(t)}listenImageChange(t){p()}load(){p()}unlistenImageChange(t){p()}}var m=v;const _={1:"The view center is not defined",2:"The view resolution is not defined",3:"The view rotation is not defined",4:"`image` and `src` cannot be provided at the same time",5:"`imgSize` must be set when `image` is provided",7:"`format` must be set when `url` is set",8:"Unknown `serverType` configured",9:"`url` must be configured or set using `#setUrl()`",10:"The default `geometryFunction` can only handle `Point` geometries",11:"`options.featureTypes` must be an Array",12:"`options.geometryName` must also be provided when `options.bbox` is set",13:"Invalid corner",14:"Invalid color",15:"Tried to get a value for a key that does not exist in the cache",16:"Tried to set a value for a key that is used already",17:"`resolutions` must be sorted in descending order",18:"Either `origin` or `origins` must be configured, never both",19:"Number of `tileSizes` and `resolutions` must be equal",20:"Number of `origins` and `resolutions` must be equal",22:"Either `tileSize` or `tileSizes` must be configured, never both",24:"Invalid extent or geometry provided as `geometry`",25:"Cannot fit empty extent provided as `geometry`",26:"Features must have an id set",27:"Features must have an id set",28:'`renderMode` must be `"hybrid"` or `"vector"`',30:"The passed `feature` was already added to the source",31:"Tried to enqueue an `element` that was already added to the queue",32:"Transformation matrix cannot be inverted",33:"Invalid units",34:"Invalid geometry layout",36:"Unknown SRS type",37:"Unknown geometry type found",38:"`styleMapValue` has an unknown type",39:"Unknown geometry type",40:"Expected `feature` to have a geometry",41:"Expected an `ol/style/Style` or an array of `ol/style/Style.js`",42:"Question unknown, the answer is 42",43:"Expected `layers` to be an array or a `Collection`",47:"Expected `controls` to be an array or an `ol/Collection`",48:"Expected `interactions` to be an array or an `ol/Collection`",49:"Expected `overlays` to be an array or an `ol/Collection`",50:"`options.featureTypes` should be an Array",51:"Either `url` or `tileJSON` options must be provided",52:"Unknown `serverType` configured",53:"Unknown `tierSizeCalculation` configured",55:"The {-y} placeholder requires a tile grid with extent",56:"mapBrowserEvent must originate from a pointer event",57:"At least 2 conditions are required",59:"Invalid command found in the PBF",60:"Missing or invalid `size`",61:"Cannot determine IIIF Image API version from provided image information JSON",62:"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`",64:"Layer opacity must be a number",66:"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has not been enabled. This is done by providing adequate shaders using the `hitVertexShader` and `hitFragmentShader` properties of `WebGLPointsLayerRenderer`",67:"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both",68:"A VectorTile source can only be rendered if it has a projection compatible with the view projection"};class C extends Error{constructor(t){const e=_[t];super(e),this.code=t,this.name="AssertionError",this.message=e}}var P=C;function x(t,e,i){return Math.min(Math.max(t,e),i)}const S=/^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i,b=/^([a-z]*)$|^hsla?\(.*\)$/i,w=function(){const t={};let e=0;return function(i){let n;if(t.hasOwnProperty(i))n=t[i];else{if(e>=1024){let i=0;for(const n in t)3&i++||(delete t[n],--e)}n=function(t){let e,i,n,r,o;if(b.exec(t)&&(t=function(t){const e=document.createElement("div");if(e.style.color=t,""!==e.style.color){document.body.appendChild(e);const t=getComputedStyle(e).color;return document.body.removeChild(e),t}return""}(t)),S.exec(t)){const s=t.length-1;let a;a=s<=4?1:2;const l=4===s||8===s;e=parseInt(t.substr(1+0*a,a),16),i=parseInt(t.substr(1+1*a,a),16),n=parseInt(t.substr(1+2*a,a),16),r=l?parseInt(t.substr(1+3*a,a),16):255,1==a&&(e=(e<<4)+e,i=(i<<4)+i,n=(n<<4)+n,l&&(r=(r<<4)+r)),o=[e,i,n,r/255]}else t.startsWith("rgba(")?(o=t.slice(5,-1).split(",").map(Number),M(o)):t.startsWith("rgb(")?(o=t.slice(4,-1).split(",").map(Number),o.push(1),M(o)):function(t,e){throw new P(14)}();return o}(i),t[i]=n,++e}return n}}();function M(t){return t[0]=x(t[0]+.5|0,0,255),t[1]=x(t[1]+.5|0,0,255),t[2]=x(t[2]+.5|0,0,255),t[3]=x(t[3],0,1),t}function E(t){return Array.isArray(t)?function(t){let e=t[0];e!=(0|e)&&(e=e+.5|0);let i=t[1];i!=(0|i)&&(i=i+.5|0);let n=t[2];return n!=(0|n)&&(n=n+.5|0),"rgba("+e+","+i+","+n+","+(void 0===t[3]?1:Math.round(100*t[3])/100)+")"}(t):t}const I="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"";I.includes("firefox"),I.includes("safari")&&!I.includes("chrom")&&(I.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(I)),I.includes("webkit")&&I.includes("edge"),I.includes("macintosh");const D="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope;function k(t,e,i,n){let r;return r=i&&i.length?i.shift():D?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("2d",n)}!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch(t){}}();var F=class{constructor(t){this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},O=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function L(){}function W(t){for(const e in t)delete t[e]}var B=class extends O{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),n=i[t]||(i[t]=[]);n.includes(e)||n.push(e)}dispatchEvent(t){const e="string"==typeof t,i=e?t:t.type,n=this.listeners_&&this.listeners_[i];if(!n)return;const r=e?new F(t):t;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),s=this.pendingRemovals_||(this.pendingRemovals_={});let a;i in o||(o[i]=0,s[i]=0),++o[i];for(let t=0,e=n.length;t<e;++t)if(a="handleEvent"in n[t]?n[t].handleEvent(r):n[t].call(this,r),!1===a||r.propagationStopped){a=!1;break}if(0==--o[i]){let t=s[i];for(delete s[i];t--;)this.removeEventListener(i,L);delete o[i]}return a}disposeInternal(){this.listeners_&&W(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return!!this.listeners_&&(t?t in this.listeners_:Object.keys(this.listeners_).length>0)}removeEventListener(t,e){const i=this.listeners_&&this.listeners_[t];if(i){const n=i.indexOf(e);-1!==n&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[n]=L,++this.pendingRemovals_[t]):(i.splice(n,1),0===i.length&&delete this.listeners_[t]))}}};function A(t,e,i,n,r){if(n&&n!==t&&(i=i.bind(n)),r){const n=i;i=function(){t.removeEventListener(e,i),n.apply(this,arguments)}}const o={target:t,type:e,listener:i};return t.addEventListener(e,i),o}function G(t,e,i,n){return A(t,e,i,n,!0)}function j(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),W(t))}var R=class extends B{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent("change")}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=A(this,t[r],e);return n}return A(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const n=t.length;i=new Array(n);for(let r=0;r<n;++r)i[r]=G(this,t[r],e)}else i=G(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)!function(t){if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)j(t[e]);else j(t)}(i);else if(Array.isArray(t))for(let i=0,n=t.length;i<n;++i)this.removeEventListener(t[i],e);else this.removeEventListener(t,e)}};class N extends F{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}const V="#000",T="round";new class extends R{constructor(t){super(),this.ol_uid||(this.ol_uid=String(++f)),this.values_=null,void 0!==t&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new N(i,t,e)),i="propertychange",this.hasListener(i)&&this.dispatchEvent(new N(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const n=this.values_||(this.values_={});if(i)n[t]=e;else{const i=n[t];n[t]=e,i!==e&&this.notify(t,i)}}setProperties(t,e){for(const i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const i=this.values_[t];delete this.values_[t],function(t){let e;for(e in t)return!1;return!e}(this.values_)&&(this.values_=null),e||this.notify(t,i)}}};class z extends m{constructor(t){super({opacity:1,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,rotation:void 0!==t.rotation?t.rotation:0,scale:void 0!==t.scale?t.scale:1,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode}),this.canvas_=void 0,this.hitDetectionCanvas_=null,this.fill_=void 0!==t.fill?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius_=void 0!==t.radius?t.radius:t.radius1,this.radius2_=t.radius2,this.angle_=void 0!==t.angle?t.angle:0,this.stroke_=void 0!==t.stroke?t.stroke:null,this.size_=null,this.renderOptions_=null,this.render()}clone(){const t=this.getScale(),e=new z({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_;if(!t)return null;const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||this.createHitDetectionCanvas_(this.renderOptions_),this.hitDetectionCanvas_}getImage(t){let e=this.canvas_[t];if(!e){const i=this.renderOptions_,n=k(i.size*t,i.size*t);this.draw_(i,n,t),e=n.canvas,this.canvas_[t]=e}return e}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return 2}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius_}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(0===e||Infinity===this.points_||"bevel"!==t&&"miter"!==t)return e;let n=this.radius_,r=void 0===this.radius2_?n:this.radius2_;if(n<r){const t=n;n=r,r=t}const o=2*Math.PI/(void 0===this.radius2_?this.points_:2*this.points_),s=r*Math.sin(o),a=n-Math.sqrt(r*r-s*s),l=Math.sqrt(s*s+a*a),c=l/s;if("miter"===t&&c<=i)return c*e;const d=e/2/c,h=e/2*(a/l),u=Math.sqrt((n+d)*(n+d)+h*h)-n;if(void 0===this.radius2_||"bevel"===t)return 2*u;const g=n*Math.sin(o),p=r-Math.sqrt(n*n-g*g),f=Math.sqrt(g*g+p*p)/g;return f<=i?2*Math.max(u,f*e/2-r-n):2*u}createRenderOptions(){let t,e=T,i=0,n=null,r=0,o=0;this.stroke_&&(t=this.stroke_.getColor(),null===t&&(t="#000"),t=E(t),o=this.stroke_.getWidth(),void 0===o&&(o=1),n=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset(),e=this.stroke_.getLineJoin(),void 0===e&&(e=T),i=this.stroke_.getMiterLimit(),void 0===i&&(i=10));const s=this.calculateLineJoinSize_(e,o,i),a=Math.max(this.radius_,this.radius2_||0);return{strokeStyle:t,strokeWidth:o,size:Math.ceil(2*a+s),lineDash:n,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.canvas_={},this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let t=this.fill_.getColor();null===t&&(t=V),e.fillStyle=E(t),e.fill()}this.stroke_&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){if(this.fill_){let e=this.fill_.getColor(),i=0;if("string"==typeof e&&(e=function(t){return Array.isArray(t)?t:w(t)}(e)),null===e?i=1:Array.isArray(e)&&(i=4===e.length?e[3]:1),0===i){const e=k(t.size,t.size);this.hitDetectionCanvas_=e.canvas,this.drawHitDetectionCanvas_(t,e)}}this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.getImage(1))}createPath_(t){let e=this.points_;const i=this.radius_;if(Infinity===e)t.arc(0,0,i,0,2*Math.PI);else{const n=void 0===this.radius2_?i:this.radius2_;void 0!==this.radius2_&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let s=0;s<e;s++){const e=r+s*o,a=s%2==0?i:n;t.lineTo(a*Math.cos(e),a*Math.sin(e))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=V,e.fill(),this.stroke_&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}}var U=z;class X extends U{constructor(t){super({points:Infinity,fill:(t=t||{radius:5}).fill,radius:t.radius,stroke:t.stroke,scale:void 0!==t.scale?t.scale:1,rotation:void 0!==t.rotation?t.rotation:0,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new X({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}setRadius(t){this.radius_=t,this.render()}}var Y=X;class H{constructor(t){this.color_=void 0!==(t=t||{}).color?t.color:null}clone(){const t=this.getColor();return new H({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){this.color_=t}}var K=H;class J{constructor(t){this.color_=void 0!==(t=t||{}).color?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=void 0!==t.lineDash?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){const t=this.getColor();return new J({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}}var q=J;class Z{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=$,void 0!==t.geometry&&this.setGeometry(t.geometry),this.fill_=void 0!==t.fill?t.fill:null,this.image_=void 0!==t.image?t.image:null,this.renderer_=void 0!==t.renderer?t.renderer:null,this.hitDetectionRenderer_=void 0!==t.hitDetectionRenderer?t.hitDetectionRenderer:null,this.stroke_=void 0!==t.stroke?t.stroke:null,this.text_=void 0!==t.text?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&"object"==typeof t&&(t=t.clone()),new Z({geometry:t,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer(),stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=$,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function $(t){return t.getGeometry()}var Q=Z;const tt={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var et=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||tt[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!(!t||!this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!(!this.global_||!t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}};const it=6378137,nt=Math.PI*it,rt=[-nt,-nt,nt,nt],ot=[-180,-85,180,85],st=it*Math.log(Math.tan(Math.PI/2));class at extends et{constructor(t){super({code:t,units:"m",extent:rt,global:!0,worldExtent:ot,getPointResolution:function(t,e){return t/Math.cosh(e[1]/it)}})}}const lt=[new at("EPSG:3857"),new at("EPSG:102100"),new at("EPSG:102113"),new at("EPSG:900913"),new at("http://www.opengis.net/def/crs/EPSG/0/3857"),new at("http://www.opengis.net/gml/srs/epsg.xml#3857")],ct=[-180,-90,180,90],dt=6378137*Math.PI/180;class ht extends et{constructor(t,e){super({code:t,units:"degrees",extent:ct,axisOrientation:e,global:!0,metersPerUnit:dt,worldExtent:ct})}}const ut=[new ht("CRS:84"),new ht("EPSG:4326","neu"),new ht("urn:ogc:def:crs:OGC:1.3:CRS84"),new ht("urn:ogc:def:crs:OGC:2:84"),new ht("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new ht("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new ht("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let gt={},pt={};function ft(t,e,i){const n=t.getCode(),r=e.getCode();n in pt||(pt[n]={}),pt[n][r]=i}function yt(t,e,i){if(void 0!==e)for(let i=0,n=t.length;i<n;++i)e[i]=t[i];else e=t.slice();return e}function vt(t,e,i){if(void 0!==e&&t!==e){for(let i=0,n=t.length;i<n;++i)e[i]=t[i];t=e}return t}function mt(t){!function(t,e){gt[t]=e}(t.getCode(),t),ft(t,t,yt)}function _t(t){return"string"==typeof t?gt[e=t]||gt[e.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null:t||null;var e}function Ct(t){!function(t){t.forEach(mt)}(t),t.forEach(function(e){t.forEach(function(t){e!==t&&ft(e,t,yt)})})}function Pt(t,e,i){const n=function(t,e){return function(t,e){let i=function(t,e){let i;return t in pt&&e in pt[t]&&(i=pt[t][e]),i}(t.getCode(),e.getCode());return i||(i=vt),i}(_t(t),_t(e))}(e,i);return n(t,void 0,t.length)}var xt,St,bt;Ct(lt),Ct(ut),xt=lt,St=function(t,e,i){const n=t.length;i=i>1?i:2,void 0===e&&(e=i>2?t.slice():new Array(n));for(let r=0;r<n;r+=i){e[r]=nt*t[r]/180;let i=it*Math.log(Math.tan(Math.PI*(+t[r+1]+90)/360));i>st?i=st:i<-st&&(i=-st),e[r+1]=i}return e},bt=function(t,e,i){const n=t.length;i=i>1?i:2,void 0===e&&(e=i>2?t.slice():new Array(n));for(let r=0;r<n;r+=i)e[r]=180*t[r]/nt,e[r+1]=360*Math.atan(Math.exp(t[r+1]/it))/Math.PI-90;return e},ut.forEach(function(t){xt.forEach(function(e){ft(t,e,St),ft(e,t,bt)})});var wt,Mt=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).stylingFunction=function(){return{}},i._lib=void 0,i._map=void 0,i._container=void 0,i._projection="EPSG:3857",i._vectorSource=void 0,i._geoJSONReader=void 0,i._map=e.map,i._lib=e.lib,i._geoJSONReader=new i._lib.GeoJSON,i._container=i._map.getViewport(),i._container.setAttribute("tabindex","0");var n=new i._lib.VectorSource({features:[]});i._vectorSource=n;var r=new i._lib.VectorLayer({source:n,style:function(t){return i.getStyles(t,i.stylingFunction())}});return i._map.addLayer(r),i}r(e,t);var i=e.prototype;return i.hexToRGB=function(t){return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16)}},i.getStyles=function(t,e){var i=this,n=t.getGeometry();if(n)return{Point:function(t){var n=t.getProperties(),r=e[n.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:n});return new i._lib.Style({image:new Y({radius:r.pointWidth,fill:new K({color:r.pointColor}),stroke:new q({color:r.pointOutlineColor,width:r.pointOutlineWidth})})})},LineString:function(t){var n=t.getProperties(),r=e[n.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:n});return new i._lib.Style({stroke:new i._lib.Stroke({color:r.lineStringColor,width:r.lineStringWidth})})},Polygon:function(t){var n=t.getProperties(),r=e[n.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:n}),o=i.hexToRGB(r.polygonFillColor),s=o.r,a=o.g,l=o.b;return new Q({stroke:new q({color:r.polygonOutlineColor,width:r.polygonOutlineWidth}),fill:new K({color:"rgba("+s+","+a+","+l+","+r.polygonFillOpacity+")"})})}}[n.getType()](t)},i.clearLayers=function(){this._vectorSource&&this._vectorSource.clear()},i.addFeature=function(t){if(!this._vectorSource||!this._geoJSONReader)throw new Error("Vector Source not initalised");var e=this._geoJSONReader.readFeature(t,{featureProjection:this._projection});this._vectorSource.addFeature(e)},i.removeFeature=function(t){if(!this._vectorSource)throw new Error("Vector Source not initalised");var e=this._vectorSource.getFeatureById(t);e&&this._vectorSource.removeFeature(e)},i.getLngLatFromEvent=function(t){var e=this.getMapElementXYPosition(t),i=e.containerX,n=e.containerY;try{return this.unproject(i,n)}catch(t){return null}},i.getMapEventElement=function(){var t=this._container.querySelectorAll("canvas");if(t.length>1)throw Error("Terra Draw currently only supports 1 canvas with OpenLayers");return t[0]},i.setDraggability=function(t){this._map.getInteractions().forEach(function(e){"DragPan"===e.constructor.name&&e.setActive(t)})},i.project=function(t,e){var i=this._map.getPixelFromCoordinate(Pt([t,e],"EPSG:4326","EPSG:3857"));return{x:i[0],y:i[1]}},i.unproject=function(t,e){var i=function(t,e){const i=Pt(t,"EPSG:3857","EPSG:4326"),n=i[0];return(n<-180||n>180)&&(i[0]=function(t,e){const i=t%360;return 360*i<0?i+360:i}(n+180)-180),i}(this._map.getCoordinateFromPixel([t,e]));return{lng:i[0],lat:i[1]}},i.setCursor=function(t){"unset"===t?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=t},i.setDoubleClickToZoom=function(t){this._map.getInteractions().forEach(function(e){"DoubleClickZoom"===e.constructor.name&&e.setActive(t)})},i.render=function(t,e){var i=this;if(this.stylingFunction=function(){return e},!this._vectorSource)throw new Error("Vector Layer source has disappeared");t.deletedIds.forEach(function(t){i.removeFeature(t)}),t.updated.forEach(function(t){i.removeFeature(t.id),i.addFeature(t)}),t.created.forEach(function(t){i.addFeature(t)})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.register=function(e){t.prototype.register.call(this,e),this._currentModeCallbacks&&this._currentModeCallbacks.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){return t.prototype.unregister.call(this)},e}(c),Et=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this)._lib=void 0,i._mapView=void 0,i._container=void 0,i._featureIdAttributeName="__tdId",i._featureLayerName="__terraDrawFeatures",i._featureLayer=void 0,i._dragEnabled=!0,i._zoomEnabled=!0,i._dragHandler=void 0,i._doubleClickHandler=void 0,i._mapView=e.map,i._lib=e.lib,i._container=i._mapView.container,i._featureLayer=new i._lib.GraphicsLayer({id:i._featureLayerName}),i._mapView.map.add(i._featureLayer),i}r(e,t);var i=e.prototype;return i.register=function(e){var i=this;t.prototype.register.call(this,e),this._dragHandler=this._mapView.on("drag",function(t){i._dragEnabled||t.stopPropagation()}),this._doubleClickHandler=this._mapView.on("double-click",function(t){i._zoomEnabled||t.stopPropagation()}),this._currentModeCallbacks&&this._currentModeCallbacks.onReady&&this._currentModeCallbacks.onReady()},i.unregister=function(){t.prototype.unregister.call(this),this._dragHandler&&this._dragHandler.remove(),this._doubleClickHandler&&this._doubleClickHandler.remove()},i.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i.getLngLatFromEvent=function(t){var e=this.getMapElementXYPosition(t);return this.unproject(e.containerX,e.containerY)},i.getMapEventElement=function(){return this._container.querySelector(".esri-view-surface")},i.setDraggability=function(t){this._dragEnabled=t},i.project=function(t,e){var i=new this._lib.Point({longitude:t,latitude:e}),n=this._mapView.toScreen(i);return{x:n.x,y:n.y}},i.unproject=function(t,e){var i=this._mapView.toMap({x:t,y:e});return{lng:i.longitude,lat:i.latitude}},i.setCursor=function(t){"unset"===t?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=t},i.setDoubleClickToZoom=function(t){this._zoomEnabled=t},i.render=function(t,e){var i=this;t.created.forEach(function(t){i.addFeature(t,e)}),t.updated.forEach(function(t){i.removeFeatureById(t.id),i.addFeature(t,e)}),t.deletedIds.forEach(function(t){i.removeFeatureById(t)})},i.clear=function(){this._featureLayer.graphics.removeAll()},i.removeFeatureById=function(t){var e=this,i=this._featureLayer.graphics.find(function(i){return i.attributes[e._featureIdAttributeName]===t});this._featureLayer.remove(i)},i.addFeature=function(t,e){var i,n=t.geometry,r=n.coordinates,o=n.type,s=e[t.properties.mode](t),a=void 0,l=void 0;switch(o){case"Point":l=new this._lib.Point({latitude:r[1],longitude:r[0]}),a=new this._lib.SimpleMarkerSymbol({color:this.getColorFromHex(s.pointColor),size:2*s.pointWidth+"px",outline:{color:this.getColorFromHex(s.pointOutlineColor),width:s.pointOutlineWidth+"px"}});break;case"LineString":l=new this._lib.Polyline({paths:[r]}),a=new this._lib.SimpleLineSymbol({color:this.getColorFromHex(s.lineStringColor),width:s.lineStringWidth+"px"});break;case"Polygon":l=new this._lib.Polygon({rings:r}),a=new this._lib.SimpleFillSymbol({color:this.getColorFromHex(s.polygonFillColor,s.polygonFillOpacity),outline:{color:this.getColorFromHex(s.polygonOutlineColor),width:s.polygonOutlineWidth+"px"}})}var c=new this._lib.Graphic({geometry:l,symbol:a,attributes:(i={},i[this._featureIdAttributeName]=t.id,i)});"Point"===o?this._featureLayer.graphics.add(c):this._featureLayer.graphics.add(c,0)},i.getColorFromHex=function(t,e){var i=this._lib.Color.fromHex(t);return e&&(i.a=e),i},e}(c),It="selected",Dt="midPoint",kt="closingPoint";function Ft(t){return Boolean(t&&"object"==typeof t&&null!==t&&!Array.isArray(t))}function Ot(t){if(!function(t){return"number"==typeof t&&!isNaN(new Date(t).valueOf())}(t))throw new Error("updatedAt and createdAt are not valid timestamps");return!0}!function(t){t.Drawing="drawing",t.Select="select",t.Static="static",t.Render="render"}(wt||(wt={}));var Lt=/*#__PURE__*/function(){var t=e.prototype;function e(t){this._state=void 0,this._styles=void 0,this.behaviors=[],this.pointerDistance=void 0,this.coordinatePrecision=void 0,this.onStyleChange=void 0,this.store=void 0,this.setDoubleClickToZoom=void 0,this.unproject=void 0,this.project=void 0,this.setCursor=void 0,this.type=wt.Drawing,this.mode="base",this._state="unregistered",this._styles=t&&t.styles?n({},t.styles):{},this.pointerDistance=t&&t.pointerDistance||40}return t.registerBehaviors=function(t){},t.setDrawing=function(){if("started"!==this._state)throw new Error("Mode must be unregistered or stopped to start");this._state="drawing"},t.setStarted=function(){if("stopped"!==this._state&&"registered"!==this._state&&"drawing"!==this._state&&"selecting"!==this._state)throw new Error("Mode must be unregistered or stopped to start");this._state="started",this.setDoubleClickToZoom(!1)},t.setStopped=function(){if("started"!==this._state)throw new Error("Mode must be started to be stopped");this._state="stopped",this.setDoubleClickToZoom(!0)},t.register=function(t){if("unregistered"!==this._state)throw new Error("Can not register unless mode is unregistered");this._state="registered",this.store=t.store,this.store.registerOnChange(t.onChange),this.setDoubleClickToZoom=t.setDoubleClickToZoom,this.project=t.project,this.unproject=t.unproject,this.onSelect=t.onSelect,this.onDeselect=t.onDeselect,this.setCursor=t.setCursor,this.onStyleChange=t.onChange,this.onFinish=t.onFinish,this.coordinatePrecision=t.coordinatePrecision,this.registerBehaviors({mode:t.mode,store:this.store,project:this.project,unproject:this.unproject,pointerDistance:this.pointerDistance,coordinatePrecision:t.coordinatePrecision})},t.validateFeature=function(t){if("unregistered"===this._state)throw new Error("Mode must be registered");return function(t,e){var i;if(Ft(t))if(null==t.id)i="Feature has no id";else if("string"!=typeof t.id&&"number"!=typeof t.id)i="Feature must be string or number as per GeoJSON spec";else if(e(t.id))if(Ft(t.geometry))if(Ft(t.properties))if("string"==typeof t.geometry.type&&["Polygon","LineString","Point"].includes(t.geometry.type))if(Array.isArray(t.geometry.coordinates)){if(!t.properties.mode||"string"!=typeof t.properties.mode)throw new Error("Feature does not have a valid mode property")}else i="Feature coordinates is not an array";else i="Feature is not Point, LineString or Polygon";else i="Feature has no properties";else i="Feature has no geometry";else i="Feature must match the id strategy (default is UUID4)";else i="Feature is not object";if(i)throw new Error(i);return!0}(t,this.store.idStrategy.isValidId)},t.onFinish=function(t){},t.onDeselect=function(t){},t.onSelect=function(t){},t.onKeyDown=function(t){},t.onKeyUp=function(t){},t.onMouseMove=function(t){},t.onClick=function(t){},t.onDragStart=function(t,e){},t.onDrag=function(t,e){},t.onDragEnd=function(t,e){},t.getHexColorStylingValue=function(t,e,i){return this.getStylingValue(t,e,i)},t.getNumericStylingValue=function(t,e,i){return this.getStylingValue(t,e,i)},t.getStylingValue=function(t,e,i){return void 0===t?e:"function"==typeof t?t(i):t},i(e,[{key:"state",get:function(){return this._state},set:function(t){throw new Error("Please use the modes lifecycle methods")}},{key:"styles",get:function(){return this._styles},set:function(t){if("object"!=typeof t)throw new Error("Styling must be an object");this.onStyleChange([],"styling"),this._styles=t}}]),e}(),Wt=/*#__PURE__*/function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).type=wt.Select,e}return r(e,t),e}(Lt);function Bt(t,e){var i=function(t){return t*Math.PI/180},n=i(t[1]),r=i(t[0]),o=i(e[1]),s=o-n,a=i(e[0])-r,l=Math.sin(s/2)*Math.sin(s/2)+Math.cos(n)*Math.cos(o)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371e3/1e3}var At=6371008.8;function Gt(t){return t%360*Math.PI/180}function jt(t){return t%(2*Math.PI)*180/Math.PI}function Rt(t){for(var e=t.center,i=t.radiusKilometers,n=t.coordinatePrecision,r=t.steps?t.steps:64,o=[],a=0;a<r;a++){var l=(d=i,h=-360*a/r,u=Gt((c=e)[0]),g=Gt(c[1]),p=Gt(h),f=function(t){return t/6371.0088}(d),y=Math.asin(Math.sin(g)*Math.cos(f)+Math.cos(g)*Math.sin(f)*Math.cos(p)),[jt(u+Math.atan2(Math.sin(p)*Math.sin(f)*Math.cos(g),Math.cos(f)-Math.sin(g)*Math.sin(y))),jt(y)]);o.push([s(l[0],n),s(l[1],n)])}var c,d,h,u,g,p,f,y;return o.push(o[0]),{type:"Feature",geometry:{type:"Polygon",coordinates:[o]},properties:{}}}function Nt(t){var e,i={epsilon:0};if("Polygon"===t.geometry.type)e=t.geometry.coordinates;else{if("LineString"!==t.geometry.type)throw new Error("Self intersects only accepts Polygons and LineStrings");e=[t.geometry.coordinates]}for(var n=[],r=0;r<e.length;r++)for(var o=0;o<e[r].length-1;o++)for(var s=0;s<e.length;s++)for(var a=0;a<e[s].length-1;a++)c(r,o,s,a);return n.length>0;function l(t){return t<0-i.epsilon||t>1+i.epsilon}function c(t,i,r,o){var s,a=e[t][i],c=e[t][i+1],d=e[r][o],h=e[r][o+1],u=function(t,e,i,n){if(Vt(t,i)||Vt(t,n)||Vt(e,i)||Vt(n,i))return null;var r=t[0],o=t[1],s=e[0],a=e[1],l=i[0],c=i[1],d=n[0],h=n[1],u=(r-s)*(c-h)-(o-a)*(l-d);return 0===u?null:[((r*a-o*s)*(l-d)-(r-s)*(l*h-c*d))/u,((r*a-o*s)*(c-h)-(o-a)*(l*h-c*d))/u]}(a,c,d,h);null!==u&&(s=h[0]!==d[0]?(u[0]-d[0])/(h[0]-d[0]):(u[1]-d[1])/(h[1]-d[1]),l(c[0]!==a[0]?(u[0]-a[0])/(c[0]-a[0]):(u[1]-a[1])/(c[1]-a[1]))||l(s)||(u.toString(),n.push(u)))}}function Vt(t,e){return t[0]===e[0]&&t[1]===e[1]}function Tt(t,e){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&Infinity!==t[0]&&Infinity!==t[1]&&(n=t[0])>=-180&&n<=180&&(i=t[1])>=-90&&i<=90&&zt(t[0])<=e&&zt(t[1])<=e;var i,n}function zt(t){for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i}function Ut(t,e){return"Polygon"===t.geometry.type&&1===t.geometry.coordinates.length&&t.geometry.coordinates[0].length>=4&&t.geometry.coordinates[0].every(function(t){return Tt(t,e)})&&(i=t.geometry.coordinates[0][0])[0]===(n=t.geometry.coordinates[0][t.geometry.coordinates[0].length-1])[0]&&i[1]===n[1];var i,n}function Xt(t,e){return Ut(t,e)&&!Nt(t)}var Yt=/*#__PURE__*/function(t){function e(e){var i,r;(r=t.call(this,e)||this).mode="circle",r.center=void 0,r.clickCount=0,r.currentCircleId=void 0,r.keyEvents=void 0,r.cursors=void 0,r.minimumRadiusKilometers=void 0;var o={start:"crosshair"};if(r.cursors=e&&e.cursors?n({},o,e.cursors):o,null===(null==e?void 0:e.keyEvents))r.keyEvents={cancel:null,finish:null};else{var s={cancel:"Escape",finish:"Enter"};r.keyEvents=e&&e.keyEvents?n({},s,e.keyEvents):s}return r.minimumRadiusKilometers=null!=(i=null==e?void 0:e.minimumRadiusKilometers)?i:1e-5,r}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentCircleId){var t=this.currentCircleId;this.center=void 0,this.currentCircleId=void 0,this.clickCount=0,"drawing"===this.state&&this.setStarted(),this.onFinish(t)}},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onClick=function(t){if(0===this.clickCount){this.center=[t.lng,t.lat];var e=Rt({center:this.center,radiusKilometers:this.minimumRadiusKilometers,coordinatePrecision:this.coordinatePrecision}),i=this.store.create([{geometry:e.geometry,properties:{mode:this.mode,radiusKilometers:this.minimumRadiusKilometers}}]);this.currentCircleId=i[0],this.clickCount++,this.setDrawing()}else 1===this.clickCount&&this.center&&void 0!==this.currentCircleId&&this.createCircle(t),this.close()},i.onMouseMove=function(t){this.createCircle(t)},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel?this.cleanUp():t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){try{void 0!==this.currentCircleId&&this.store.delete([this.currentCircleId])}catch(t){}this.center=void 0,this.currentCircleId=void 0,this.clickCount=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"Polygon"===t.geometry.type&&t.properties.mode===this.mode?(e.polygonFillColor=this.getHexColorStylingValue(this.styles.fillColor,e.polygonFillColor,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.outlineColor,e.polygonOutlineColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.outlineWidth,e.polygonOutlineWidth,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.fillOpacity,e.polygonFillOpacity,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&Xt(e,this.coordinatePrecision)},i.createCircle=function(t){if(1===this.clickCount&&this.center&&this.currentCircleId){var e=Bt(this.center,[t.lng,t.lat]),i=e>this.minimumRadiusKilometers?e:this.minimumRadiusKilometers,n=Rt({center:this.center,radiusKilometers:i,coordinatePrecision:this.coordinatePrecision});this.store.updateGeometry([{id:this.currentCircleId,geometry:n.geometry}]),this.store.updateProperty([{id:this.currentCircleId,property:"radiusKilometers",value:i}])}},e}(Lt),Ht=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="freehand",i.startingClick=!1,i.currentId=void 0,i.closingPointId=void 0,i.minDistance=void 0,i.keyEvents=void 0,i.cursors=void 0,i.preventPointsNearClose=void 0;var r={start:"crosshair",close:"pointer"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,i.preventPointsNearClose=e&&e.preventPointsNearClose||!0,i.minDistance=e&&e.minDistance||20,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentId){var t=this.currentId;this.closingPointId&&this.store.delete([this.closingPointId]),this.startingClick=!1,this.currentId=void 0,this.closingPointId=void 0,"drawing"===this.state&&this.setStarted(),this.onFinish(t)}},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onMouseMove=function(t){if(void 0!==this.currentId&&!1!==this.startingClick){var e=this.store.getGeometryCopy(this.currentId),i=e.coordinates[0][e.coordinates[0].length-2],n=this.project(i[0],i[1]),r=a({x:n.x,y:n.y},{x:t.containerX,y:t.containerY}),o=e.coordinates[0][0],s=this.project(o[0],o[1]);if(a({x:s.x,y:s.y},{x:t.containerX,y:t.containerY})<this.pointerDistance){if(this.setCursor(this.cursors.close),this.preventPointsNearClose)return}else this.setCursor(this.cursors.start);r<this.minDistance||(e.coordinates[0].pop(),this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[[].concat(e.coordinates[0],[[t.lng,t.lat],e.coordinates[0][0]])]}}]))}},i.onClick=function(t){if(!1===this.startingClick){var e=this.store.create([{geometry:{type:"Polygon",coordinates:[[[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat]]]},properties:{mode:this.mode}},{geometry:{type:"Point",coordinates:[t.lng,t.lat]},properties:{mode:this.mode}}]),i=e[1];return this.currentId=e[0],this.closingPointId=i,this.startingClick=!0,void this.setDrawing()}this.close()},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel?this.cleanUp():t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){try{this.currentId&&this.store.delete([this.currentId]),this.closingPointId&&this.store.delete([this.closingPointId])}catch(t){}this.closingPointId=void 0,this.currentId=void 0,this.startingClick=!1,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"Polygon"===t.geometry.type&&t.properties.mode===this.mode?(e.polygonFillColor=this.getHexColorStylingValue(this.styles.fillColor,e.polygonFillColor,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.outlineColor,e.polygonOutlineColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.outlineWidth,e.polygonOutlineWidth,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.fillOpacity,e.polygonFillOpacity,t),e):"Feature"===t.type&&"Point"===t.geometry.type&&t.properties.mode===this.mode?(e.pointWidth=this.getNumericStylingValue(this.styles.closingPointWidth,e.pointWidth,t),e.pointColor=this.getHexColorStylingValue(this.styles.closingPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.closingPointOutlineColor,e.pointOutlineColor,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.closingPointOutlineWidth,2,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&Ut(e,this.coordinatePrecision)},e}(Lt),Kt=Math.PI/180,Jt=180/Math.PI,qt=/*#__PURE__*/function(){function t(t){this.coordinatePrecision=void 0,this.coords=void 0,this.length=void 0,this.coordinatePrecision=t,this.coords=[],this.length=0}return t.prototype.moveTo=function(t){this.length++,this.coords.push([s(t[0],this.coordinatePrecision),s(t[1],this.coordinatePrecision)])},t}(),Zt=/*#__PURE__*/function(){function t(t){var e=t.properties;this.geometries=void 0,this.properties=void 0,this.properties=e||{},this.geometries=[]}return t.prototype.toJSON=function(){if(1===this.geometries.length){var t=this.geometries[0].coords;if(t[0][0]&&!isNaN(t[0][0])&&t[0][1]&&!isNaN(t[0][1]))return{geometry:{type:"LineString",coordinates:t},type:"Feature",properties:this.properties}}return null},t}(),$t=/*#__PURE__*/function(){function t(t,e,i){if(this.g=void 0,this.start=void 0,this.end=void 0,this.properties=void 0,!t||void 0===t[0]||void 0===t[1])throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!e||void 0===e[0]||void 0===e[1])throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start={lng:t[0],lat:t[1],x:Kt*t[0],y:Kt*t[1]},this.end={lng:e[0],lat:e[1],x:Kt*e[0],y:Kt*e[1]},this.properties=i||{};var n=this.start.x-this.end.x,r=Math.pow(Math.sin((this.start.y-this.end.y)/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(n/2),2);if(this.g=2*Math.asin(Math.sqrt(r)),this.g===Math.PI)throw new Error("it appears "+t+" and "+e+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+t+" and "+e)}var e=t.prototype;return e.interpolate=function(t){var e=Math.sin((1-t)*this.g)/Math.sin(this.g),i=Math.sin(t*this.g)/Math.sin(this.g),n=e*Math.cos(this.start.y)*Math.cos(this.start.x)+i*Math.cos(this.end.y)*Math.cos(this.end.x),r=e*Math.cos(this.start.y)*Math.sin(this.start.x)+i*Math.cos(this.end.y)*Math.sin(this.end.x),o=e*Math.sin(this.start.y)+i*Math.sin(this.end.y),s=Jt*Math.atan2(o,Math.sqrt(Math.pow(n,2)+Math.pow(r,2)));return[Jt*Math.atan2(r,n),s]},e.arc=function(t,e){var i=[];if(!t||t<=2)i.push([this.start.lng,this.start.lat]),i.push([this.end.lng,this.end.lat]);else for(var n=1/(t-1),r=0;r<t;++r){var o=this.interpolate(n*r);i.push(o)}for(var s=!1,a=0,l=e&&e.offset?e.offset:10,c=180-l,d=-180+l,h=360-l,u=1;u<i.length;++u){var g=i[u-1][0],p=i[u][0],f=Math.abs(p-g);f>h&&(p>c&&g<d||g>c&&p<d)?s=!0:f>a&&(a=f)}var y=[];if(s&&a<l){var v=[];y.push(v);for(var m=0;m<i.length;++m){var _=i[m][0];if(m>0&&Math.abs(_-i[m-1][0])>h){var C=i[m-1][0],P=i[m-1][1],x=i[m][0],S=i[m][1];if(C>-180&&C<d&&180===x&&m+1<i.length&&i[m-1][0]>-180&&i[m-1][0]<d){v.push([-180,i[m][1]]),m++,v.push([i[m][0],i[m][1]]);continue}if(C>c&&C<180&&-180===x&&m+1<i.length&&i[m-1][0]>c&&i[m-1][0]<180){v.push([180,i[m][1]]),m++,v.push([i[m][0],i[m][1]]);continue}if(C<d&&x>c){var b=C;C=x,x=b;var w=P;P=S,S=w}if(C>c&&x<d&&(x+=360),C<=180&&x>=180&&C<x){var M=(180-C)/(x-C),E=M*S+(1-M)*P;v.push([i[m-1][0]>c?180:-180,E]),(v=[]).push([i[m-1][0]>c?-180:180,E]),y.push(v)}else y.push(v=[]);v.push([_,i[m][1]])}else v.push([i[m][0],i[m][1]])}}else{var I=[];y.push(I);for(var D=0;D<i.length;++D)I.push([i[D][0],i[D][1]])}for(var k=new Zt({properties:this.properties}),F=0;F<y.length;++F){var O=new qt(e.coordinatePrecision);k.geometries.push(O);for(var L=y[F],W=0;W<L.length;++W)O.moveTo(L[W])}return k},t}(),Qt=function(t){var e=t.store,i=t.mode,n=t.project,r=t.unproject,o=t.pointerDistance,s=t.coordinatePrecision;this.store=void 0,this.mode=void 0,this.project=void 0,this.unproject=void 0,this.pointerDistance=void 0,this.coordinatePrecision=void 0,this.store=e,this.mode=i,this.project=n,this.unproject=r,this.pointerDistance=o,this.coordinatePrecision=s},te=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.pixelDistance=void 0,r.clickBoundingBox=void 0,r.getSnappableCoordinate=function(t,e){return r.getSnappableEnds(t,function(t){return Boolean(!t.properties||t.properties.mode!==r.mode||!e||t.id!==e)})},r.config=e,r.pixelDistance=i,r.clickBoundingBox=n,r}return r(e,t),e.prototype.getSnappableEnds=function(t,e){var i=this,n=this.clickBoundingBox.create(t),r=this.store.search(n,e),o={coord:void 0,minDist:Infinity};return r.forEach(function(e){var n;if("LineString"===e.geometry.type){var r=(n=e.geometry.coordinates)[0],s=i.pixelDistance.measure(t,r);s<o.minDist&&s<i.pointerDistance&&(o.coord=r);var a=n[n.length-1],l=i.pixelDistance.measure(t,a);l<o.minDist&&l<i.pointerDistance&&(o.coord=a)}}),o.coord},e}(Qt),ee=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}return r(e,t),e.prototype.measure=function(t,e){var i=this.project(e[0],e[1]);return a({x:i.x,y:i.y},{x:t.containerX,y:t.containerY})},e}(Qt);function ie(t){var e=t.unproject,i=t.point,n=t.pointerDistance/2,r=i.x,o=i.y;return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[e(r-n,o-n),e(r+n,o-n),e(r+n,o+n),e(r-n,o+n),e(r-n,o-n)].map(function(t){return[t.lng,t.lat]})]}}}var ne=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}return r(e,t),e.prototype.create=function(t){return ie({unproject:this.unproject,point:{x:t.containerX,y:t.containerY},pointerDistance:this.pointerDistance})},e}(Qt),re=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="greatcircle",i.currentCoordinate=0,i.currentId=void 0,i.closingPointId=void 0,i.keyEvents=void 0,i.snappingEnabled=void 0,i.cursors=void 0,i.snapping=void 0;var r={start:"crosshair",close:"pointer"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,i.snappingEnabled=!(!e||void 0===e.snapping)&&e.snapping,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentId){var t=this.currentId;this.closingPointId&&this.store.delete([this.closingPointId]),this.currentCoordinate=0,this.currentId=void 0,this.closingPointId=void 0,"drawing"===this.state&&this.setStarted(),this.onFinish(t)}},i.registerBehaviors=function(t){this.snapping=new te(t,new ee(t),new ne(t))},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onMouseMove=function(t){if(this.setCursor(this.cursors.start),(void 0!==this.currentId||0!==this.currentCoordinate)&&this.currentId&&1===this.currentCoordinate&&this.closingPointId){var e=this.currentId&&this.snappingEnabled&&this.snapping.getSnappableCoordinate(t,this.currentId)||[t.lng,t.lat];this.store.updateGeometry([{id:this.closingPointId,geometry:{type:"Point",coordinates:e}}]);var i=this.store.getGeometryCopy(this.currentId);i.coordinates.pop();var n=function(t){var e=t.start,i=t.end,n=t.options||{};if("object"!=typeof n)throw new Error("options argument is invalid, must be of type object");var r=n.properties,o=n.numberOfPoints,s=void 0===o?100:o,a=n.offset,l=void 0===a?10:a,c=n.coordinatePrecision,d=void 0===c?9:c;return new $t(e,i,void 0===r?{}:r).arc(s,{offset:l,coordinatePrecision:d}).toJSON()}({start:i.coordinates[0],end:e,options:{coordinatePrecision:this.coordinatePrecision}});n&&this.store.updateGeometry([{id:this.currentId,geometry:n.geometry}])}},i.onClick=function(t){if(0===this.currentCoordinate){var e=this.snappingEnabled&&this.snapping.getSnappableCoordinate(t)||[t.lng,t.lat],i=this.store.create([{geometry:{type:"LineString",coordinates:[e,e]},properties:{mode:this.mode}}]);this.currentId=i[0];var n=this.store.create([{geometry:{type:"Point",coordinates:e},properties:{mode:this.mode}}]);this.closingPointId=n[0],this.currentCoordinate++,this.setDrawing()}else 1===this.currentCoordinate&&this.currentId&&(this.setCursor("pointer"),this.close())},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel&&this.cleanUp(),t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){try{this.currentId&&this.store.delete([this.currentId]),this.closingPointId&&this.store.delete([this.closingPointId])}catch(t){}this.closingPointId=void 0,this.currentId=void 0,this.currentCoordinate=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"LineString"===t.geometry.type&&t.properties.mode===this.mode?(e.lineStringColor=this.getHexColorStylingValue(this.styles.lineStringColor,e.lineStringColor,t),e.lineStringWidth=this.getNumericStylingValue(this.styles.lineStringWidth,e.lineStringWidth,t),e):"Feature"===t.type&&"Point"===t.geometry.type&&t.properties.mode===this.mode?(e.pointColor=this.getHexColorStylingValue(this.styles.closingPointColor,e.pointColor,t),e.pointWidth=this.getNumericStylingValue(this.styles.closingPointWidth,e.pointWidth,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.closingPointOutlineColor,"#ffffff",t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.closingPointOutlineWidth,2,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&"LineString"===e.geometry.type&&e.properties.mode===this.mode&&e.geometry.coordinates.length>=2},e}(Lt),oe=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.pixelDistance=void 0,r.clickBoundingBox=void 0,r.getSnappableCoordinateFirstClick=function(t){return r.getSnappable(t,function(t){return Boolean(t.properties&&t.properties.mode===r.mode)})},r.getSnappableCoordinate=function(t,e){return r.getSnappable(t,function(t){return Boolean(t.properties&&t.properties.mode===r.mode&&t.id!==e)})},r.config=e,r.pixelDistance=i,r.clickBoundingBox=n,r}return r(e,t),e.prototype.getSnappable=function(t,e){var i=this,n=this.clickBoundingBox.create(t),r=this.store.search(n,e),o={coord:void 0,minDist:Infinity};return r.forEach(function(e){var n;if("Polygon"===e.geometry.type)n=e.geometry.coordinates[0];else{if("LineString"!==e.geometry.type)return;n=e.geometry.coordinates}n.forEach(function(e){var n=i.pixelDistance.measure(t,e);n<o.minDist&&n<i.pointerDistance&&(o.coord=e)})}),o.coord},e}(Qt),se=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="linestring",i.currentCoordinate=0,i.currentId=void 0,i.closingPointId=void 0,i.allowSelfIntersections=void 0,i.keyEvents=void 0,i.snappingEnabled=void 0,i.cursors=void 0,i.mouseMove=!1,i.snapping=void 0;var r={start:"crosshair",close:"pointer"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,i.snappingEnabled=!(!e||void 0===e.snapping)&&e.snapping,i.allowSelfIntersections=!e||void 0===e.allowSelfIntersections||e.allowSelfIntersections,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentId){var t=this.store.getGeometryCopy(this.currentId);t.coordinates.pop(),this.store.updateGeometry([{id:this.currentId,geometry:{type:"LineString",coordinates:[].concat(t.coordinates)}}]);var e=this.currentId;this.closingPointId&&this.store.delete([this.closingPointId]),this.currentCoordinate=0,this.currentId=void 0,this.closingPointId=void 0,"drawing"===this.state&&this.setStarted(),this.onFinish(e)}},i.registerBehaviors=function(t){this.snapping=new oe(t,new ee(t),new ne(t))},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onMouseMove=function(t){if(this.mouseMove=!0,this.setCursor(this.cursors.start),void 0!==this.currentId&&0!==this.currentCoordinate){var e=this.store.getGeometryCopy(this.currentId);e.coordinates.pop();var i=this.snappingEnabled&&this.snapping.getSnappableCoordinate(t,this.currentId)||[t.lng,t.lat];if(this.closingPointId){var n=e.coordinates[e.coordinates.length-1],r=this.project(n[0],n[1]);a({x:r.x,y:r.y},{x:t.containerX,y:t.containerY})<this.pointerDistance&&this.setCursor(this.cursors.close)}this.store.updateGeometry([{id:this.currentId,geometry:{type:"LineString",coordinates:[].concat(e.coordinates,[i])}}])}},i.onClick=function(t){this.currentCoordinate>0&&!this.mouseMove&&this.onMouseMove(t),this.mouseMove=!1;var e=this.currentId&&this.snappingEnabled&&this.snapping.getSnappableCoordinate(t,this.currentId)||[t.lng,t.lat];if(0===this.currentCoordinate){var i=this.store.create([{geometry:{type:"LineString",coordinates:[e,e]},properties:{mode:this.mode}}]);this.currentId=i[0],this.currentCoordinate++,this.setDrawing()}else if(1===this.currentCoordinate&&this.currentId){var n=this.store.getGeometryCopy(this.currentId),r=this.store.create([{geometry:{type:"Point",coordinates:[].concat(e)},properties:{mode:this.mode}}]);this.closingPointId=r[0],this.setCursor(this.cursors.close),this.store.updateGeometry([{id:this.currentId,geometry:{type:"LineString",coordinates:[n.coordinates[0],e,e]}}]),this.currentCoordinate++}else if(this.currentId){var o=this.store.getGeometryCopy(this.currentId),s=o.coordinates[o.coordinates.length-2],l=this.project(s[0],s[1]);if(a({x:l.x,y:l.y},{x:t.containerX,y:t.containerY})<this.pointerDistance)this.close();else{var c={type:"LineString",coordinates:[].concat(o.coordinates,[e])};if(!this.allowSelfIntersections&&Nt({type:"Feature",geometry:c,properties:{}}))return;this.closingPointId&&(this.setCursor(this.cursors.close),this.store.updateGeometry([{id:this.currentId,geometry:c},{id:this.closingPointId,geometry:{type:"Point",coordinates:o.coordinates[o.coordinates.length-1]}}]),this.currentCoordinate++)}}},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel&&this.cleanUp(),t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){try{this.currentId&&this.store.delete([this.currentId]),this.closingPointId&&this.store.delete([this.closingPointId])}catch(t){}this.closingPointId=void 0,this.currentId=void 0,this.currentCoordinate=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"LineString"===t.geometry.type&&t.properties.mode===this.mode?(e.lineStringColor=this.getHexColorStylingValue(this.styles.lineStringColor,e.lineStringColor,t),e.lineStringWidth=this.getNumericStylingValue(this.styles.lineStringWidth,e.lineStringWidth,t),e):"Feature"===t.type&&"Point"===t.geometry.type&&t.properties.mode===this.mode?(e.pointColor=this.getHexColorStylingValue(this.styles.closingPointColor,e.pointColor,t),e.pointWidth=this.getNumericStylingValue(this.styles.closingPointWidth,e.pointWidth,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.closingPointOutlineColor,"#ffffff",t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.closingPointOutlineWidth,2,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&"LineString"===e.geometry.type&&e.properties.mode===this.mode&&e.geometry.coordinates.length>=2},e}(Lt);function ae(t,e){return"Point"===t.geometry.type&&Tt(t.geometry.coordinates,e)}var le=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="point",i.cursors=void 0;var r={create:"crosshair"};return i.cursors=e&&e.cursors?n({},r,e.cursors):r,i}r(e,t);var i=e.prototype;return i.start=function(){this.setStarted(),this.setCursor(this.cursors.create)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onClick=function(t){if(!this.store)throw new Error("Mode must be registered first");var e=this.store.create([{geometry:{type:"Point",coordinates:[t.lng,t.lat]},properties:{mode:this.mode}}]);this.onFinish(e[0])},i.onMouseMove=function(){},i.onKeyDown=function(){},i.onKeyUp=function(){},i.cleanUp=function(){},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"Point"===t.geometry.type&&t.properties.mode===this.mode&&(e.pointWidth=this.getNumericStylingValue(this.styles.pointWidth,e.pointWidth,t),e.pointColor=this.getHexColorStylingValue(this.styles.pointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.pointOutlineColor,e.pointOutlineColor,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.pointOutlineWidth,2,t)),e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&ae(e,this.coordinatePrecision)},e}(Lt);function ce(t,e){return t[0]===e[0]&&t[1]===e[1]}var de=/*#__PURE__*/function(t){function e(e,i){var n;return(n=t.call(this,e)||this).config=void 0,n.pixelDistance=void 0,n._startEndPoints=[],n.config=e,n.pixelDistance=i,n}r(e,t);var n=e.prototype;return n.create=function(t,e){var i,n;if(this.ids.length)throw new Error("Opening and closing points already creating");if(t.length<=3)throw new Error("Requires at least 4 cooridnates");this._startEndPoints=this.store.create([{geometry:{type:"Point",coordinates:t[0]},properties:(i={mode:e},i[kt]=!0,i)},{geometry:{type:"Point",coordinates:t[t.length-2]},properties:(n={mode:e},n[kt]=!0,n)}])},n.delete=function(){this.ids.length&&(this.store.delete(this.ids),this._startEndPoints=[])},n.update=function(t){if(2!==this.ids.length)throw new Error("No closing points to update");this.store.updateGeometry([{id:this.ids[0],geometry:{type:"Point",coordinates:t[0]}},{id:this.ids[1],geometry:{type:"Point",coordinates:t[t.length-3]}}])},n.isClosingPoint=function(t){var e=this.store.getGeometryCopy(this.ids[0]),i=this.store.getGeometryCopy(this.ids[1]),n=this.pixelDistance.measure(t,e.coordinates),r=this.pixelDistance.measure(t,i.coordinates);return{isClosing:n<this.pointerDistance,isPreviousClosing:r<this.pointerDistance}},i(e,[{key:"ids",get:function(){return this._startEndPoints.concat()},set:function(t){}}]),e}(Qt),he=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="polygon",i.currentCoordinate=0,i.currentId=void 0,i.allowSelfIntersections=void 0,i.keyEvents=void 0,i.snappingEnabled=void 0,i.snapping=void 0,i.pixelDistance=void 0,i.closingPoints=void 0,i.cursors=void 0,i.mouseMove=!1;var r={start:"crosshair",close:"pointer"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,i.snappingEnabled=!(!e||void 0===e.snapping)&&e.snapping,i.allowSelfIntersections=!e||void 0===e.allowSelfIntersections||e.allowSelfIntersections,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentId){var t=this.store.getGeometryCopy(this.currentId).coordinates[0];if(!(t.length<5)){this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[[].concat(t.slice(0,-2),[t[0]])]}}]);var e=this.currentId;this.currentCoordinate=0,this.currentId=void 0,this.closingPoints.delete(),"drawing"===this.state&&this.setStarted(),this.onFinish(e)}}},i.registerBehaviors=function(t){this.pixelDistance=new ee(t),this.snapping=new oe(t,this.pixelDistance,new ne(t)),this.closingPoints=new de(t,this.pixelDistance)},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onMouseMove=function(t){if(this.mouseMove=!0,this.setCursor(this.cursors.start),void 0!==this.currentId&&0!==this.currentCoordinate){var e,i=this.snappingEnabled?this.snapping.getSnappableCoordinate(t,this.currentId):void 0,n=this.store.getGeometryCopy(this.currentId).coordinates[0];if(i&&(t.lng=i[0],t.lat=i[1]),1===this.currentCoordinate){var r=1/Math.pow(10,this.coordinatePrecision-1),o=Math.max(1e-6,r);e=[n[0],[t.lng,t.lat],[t.lng,t.lat-o],n[0]]}else if(2===this.currentCoordinate)e=[n[0],n[1],[t.lng,t.lat],n[0]];else{var s=this.closingPoints.isClosingPoint(t);s.isPreviousClosing||s.isClosing?(this.setCursor(this.cursors.close),e=[].concat(n.slice(0,-2),[n[0],n[0]])):e=[].concat(n.slice(0,-2),[[t.lng,t.lat],n[0]])}this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[e]}}])}},i.onClick=function(t){if(this.currentCoordinate>0&&!this.mouseMove&&this.onMouseMove(t),this.mouseMove=!1,0===this.currentCoordinate){var e=this.snappingEnabled?this.snapping.getSnappableCoordinateFirstClick(t):void 0;e&&(t.lng=e[0],t.lat=e[1]);var i=this.store.create([{geometry:{type:"Polygon",coordinates:[[[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat]]]},properties:{mode:this.mode}}]);this.currentId=i[0],this.currentCoordinate++,this.setDrawing()}else if(1===this.currentCoordinate&&this.currentId){var n=this.snappingEnabled?this.snapping.getSnappableCoordinate(t,this.currentId):void 0;n&&(t.lng=n[0],t.lat=n[1]);var r=this.store.getGeometryCopy(this.currentId);if(ce([t.lng,t.lat],r.coordinates[0][0]))return;this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[[r.coordinates[0][0],[t.lng,t.lat],[t.lng,t.lat],r.coordinates[0][0]]]}}]),this.currentCoordinate++}else if(2===this.currentCoordinate&&this.currentId){var o=this.snappingEnabled?this.snapping.getSnappableCoordinate(t,this.currentId):void 0;o&&(t.lng=o[0],t.lat=o[1]);var s=this.store.getGeometryCopy(this.currentId).coordinates[0];if(ce([t.lng,t.lat],s[1]))return;2===this.currentCoordinate&&this.closingPoints.create(s,"polygon"),this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[[s[0],s[1],[t.lng,t.lat],[t.lng,t.lat],s[0]]]}}]),this.currentCoordinate++}else if(this.currentId){var a=this.snappingEnabled?this.snapping.getSnappableCoordinate(t,this.currentId):void 0,l=this.store.getGeometryCopy(this.currentId).coordinates[0],c=this.closingPoints.isClosingPoint(t);if(c.isPreviousClosing||c.isClosing)this.close();else{if(a&&(t.lng=a[0],t.lat=a[1]),ce([t.lng,t.lat],l[this.currentCoordinate-1]))return;var d=(void 0===(h=[[].concat(l.slice(0,-1),[[t.lng,t.lat],l[0]])])&&(h=[[[0,0],[0,1],[1,1],[1,0],[0,0]]]),{type:"Feature",geometry:{type:"Polygon",coordinates:h},properties:{}});if(this.currentCoordinate>2&&!this.allowSelfIntersections&&Nt(d))return;this.store.updateGeometry([{id:this.currentId,geometry:d.geometry}]),this.currentCoordinate++,this.closingPoints.ids.length&&this.closingPoints.update(d.geometry.coordinates[0])}}var h},i.onKeyUp=function(t){t.key===this.keyEvents.cancel?this.cleanUp():t.key===this.keyEvents.finish&&this.close()},i.onKeyDown=function(){},i.onDragStart=function(){this.setCursor("unset")},i.onDrag=function(){},i.onDragEnd=function(){this.setCursor(this.cursors.start)},i.cleanUp=function(){try{this.currentId&&this.store.delete([this.currentId]),this.closingPoints.ids.length&&this.closingPoints.delete()}catch(t){}this.currentId=void 0,this.currentCoordinate=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});if(t.properties.mode===this.mode){if("Polygon"===t.geometry.type)return e.polygonFillColor=this.getHexColorStylingValue(this.styles.fillColor,e.polygonFillColor,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.outlineColor,e.polygonOutlineColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.outlineWidth,e.polygonOutlineWidth,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.fillOpacity,e.polygonFillOpacity,t),e.zIndex=10,e;if("Point"===t.geometry.type)return e.pointWidth=this.getNumericStylingValue(this.styles.closingPointWidth,e.pointWidth,t),e.pointColor=this.getHexColorStylingValue(this.styles.closingPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.closingPointOutlineColor,e.pointOutlineColor,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.closingPointOutlineWidth,2,t),e.zIndex=30,e}return e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&Ut(e,this.coordinatePrecision)},e}(Lt),ue=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="rectangle",i.center=void 0,i.clickCount=0,i.currentRectangleId=void 0,i.keyEvents=void 0,i.cursors=void 0;var r={start:"crosshair"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.updateRectangle=function(t){if(1===this.clickCount&&this.center&&this.currentRectangleId){var e=this.store.getGeometryCopy(this.currentRectangleId).coordinates[0][0];this.store.updateGeometry([{id:this.currentRectangleId,geometry:{type:"Polygon",coordinates:[[e,[t.lng,e[1]],[t.lng,t.lat],[e[0],t.lat],e]]}}])}},i.close=function(){var t=this.currentRectangleId;this.center=void 0,this.currentRectangleId=void 0,this.clickCount=0,"drawing"===this.state&&this.setStarted(),t&&this.onFinish(t)},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onClick=function(t){if(0===this.clickCount){this.center=[t.lng,t.lat];var e=this.store.create([{geometry:{type:"Polygon",coordinates:[[[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat]]]},properties:{mode:this.mode}}]);this.currentRectangleId=e[0],this.clickCount++,this.setDrawing()}else this.updateRectangle(t),this.close()},i.onMouseMove=function(t){this.updateRectangle(t)},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel?this.cleanUp():t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){this.currentRectangleId&&this.store.delete([this.currentRectangleId]),this.center=void 0,this.currentRectangleId=void 0,this.clickCount=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"Polygon"===t.geometry.type&&t.properties.mode===this.mode?(e.polygonFillColor=this.getHexColorStylingValue(this.styles.fillColor,e.polygonFillColor,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.outlineColor,e.polygonOutlineColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.outlineWidth,e.polygonOutlineWidth,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.fillOpacity,e.polygonFillOpacity,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&Xt(e,this.coordinatePrecision)},e}(Lt),ge=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,{styles:e.styles})||this).type=wt.Render,i.mode="render",i.mode=e.modeName,i}r(e,t);var i=e.prototype;return i.registerBehaviors=function(t){this.mode=t.mode},i.start=function(){this.setStarted()},i.stop=function(){this.setStopped()},i.onKeyUp=function(){},i.onKeyDown=function(){},i.onClick=function(){},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.onMouseMove=function(){},i.cleanUp=function(){},i.styleFeature=function(t){return{pointColor:this.getHexColorStylingValue(this.styles.pointColor,"#3f97e0",t),pointWidth:this.getNumericStylingValue(this.styles.pointWidth,6,t),pointOutlineColor:this.getHexColorStylingValue(this.styles.pointOutlineColor,"#ffffff",t),pointOutlineWidth:this.getNumericStylingValue(this.styles.pointOutlineWidth,0,t),polygonFillColor:this.getHexColorStylingValue(this.styles.polygonFillColor,"#3f97e0",t),polygonFillOpacity:this.getNumericStylingValue(this.styles.polygonFillOpacity,.3,t),polygonOutlineColor:this.getHexColorStylingValue(this.styles.polygonOutlineColor,"#3f97e0",t),polygonOutlineWidth:this.getNumericStylingValue(this.styles.polygonOutlineWidth,4,t),lineStringWidth:this.getNumericStylingValue(this.styles.lineStringWidth,4,t),lineStringColor:this.getHexColorStylingValue(this.styles.lineStringColor,"#3f97e0",t),zIndex:this.getNumericStylingValue(this.styles.zIndex,0,t)}},i.validateFeature=function(e){return t.prototype.validateFeature.call(this,e)&&(ae(e,this.coordinatePrecision)||Ut(e,this.coordinatePrecision)||function(t,e){return"LineString"===t.geometry.type&&t.geometry.coordinates.length>=2&&t.geometry.coordinates.every(function(t){return Tt(t,e)})}(e,this.coordinatePrecision))},e}(Lt);function pe(t,e,i,n,r){var o=n(t[0],t[1]),a=n(e[0],e[1]),l=r((o.x+a.x)/2,(o.y+a.y)/2),c=l.lat;return[s(l.lng,i),s(c,i)]}function fe(t,e,i,n){for(var r=[],o=0;o<t.length-1;o++){var s=pe(t[o],t[o+1],e,i,n);r.push(s)}return r}var ye=/*#__PURE__*/function(t){function e(e,i){var n;return(n=t.call(this,e)||this).config=void 0,n.selectionPointBehavior=void 0,n._midPoints=[],n.config=e,n.selectionPointBehavior=i,n}r(e,t);var n=e.prototype;return n.insert=function(t,e){var i=this.store.getGeometryCopy(t),n=this.store.getPropertiesCopy(t),r=n.midPointFeatureId,o=n.midPointSegment,s=this.store.getGeometryCopy(r),a="Polygon"===s.type?s.coordinates[0]:s.coordinates;a.splice(o+1,0,i.coordinates),s.coordinates="Polygon"===s.type?[a]:a,this.store.updateGeometry([{id:r,geometry:s}]),this.store.delete([].concat(this._midPoints,this.selectionPointBehavior.ids)),this.create(a,r,e),this.selectionPointBehavior.create(a,s.type,r)},n.create=function(t,e,i){var n=this;if(!this.store.has(e))throw new Error("Store does not have feature with this id");this._midPoints=this.store.create(function(t,e,i,n,r){return fe(t,i,n,r).map(function(t,i){return{geometry:{type:"Point",coordinates:t},properties:e(i)}})}(t,function(t){var i;return(i={mode:n.mode})[Dt]=!0,i.midPointSegment=t,i.midPointFeatureId=e,i},i,this.config.project,this.config.unproject))},n.delete=function(){this._midPoints.length&&(this.store.delete(this._midPoints),this._midPoints=[])},n.getUpdated=function(t){var e=this;if(0!==this._midPoints.length)return fe(t,this.coordinatePrecision,this.config.project,this.config.unproject).map(function(t,i){return{id:e._midPoints[i],geometry:{type:"Point",coordinates:t}}})},i(e,[{key:"ids",get:function(){return this._midPoints.concat()},set:function(t){}}]),e}(Qt),ve=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this)._selectionPoints=[],i}r(e,t);var n=e.prototype;return n.create=function(t,e,i){var n=this;this._selectionPoints=this.store.create(function(t,e,i){for(var n=[],r="Polygon"===e?t.length-1:t.length,o=0;o<r;o++)n.push({geometry:{type:"Point",coordinates:t[o]},properties:i(o)});return n}(t,e,function(t){return{mode:n.mode,selectionPoint:!0,selectionPointFeatureId:i,index:t}}))},n.delete=function(){this.ids.length&&(this.store.delete(this.ids),this._selectionPoints=[])},n.getUpdated=function(t){if(0!==this._selectionPoints.length)return this._selectionPoints.map(function(e,i){return{id:e,geometry:{type:"Point",coordinates:t[i]}}})},n.getOneUpdated=function(t,e){if(void 0!==this._selectionPoints[t])return{id:this._selectionPoints[t],geometry:{type:"Point",coordinates:e}}},i(e,[{key:"ids",get:function(){return this._selectionPoints.concat()},set:function(t){}}]),e}(Qt);function me(t,e){for(var i,n,r,o=!1,s=0,a=e.length;s<a;s++)for(var l=e[s],c=0,d=l.length,h=d-1;c<d;h=c++)(n=l[c])[1]>(i=t)[1]!=(r=l[h])[1]>i[1]&&i[0]<(r[0]-n[0])*(i[1]-n[1])/(r[1]-n[1])+n[0]&&(o=!o);return o}var _e=function(t,e,i){var n=function(t){return t*t},r=function(t,e){return n(t.x-e.x)+n(t.y-e.y)};return Math.sqrt(function(t,e,i){var n=r(e,i);if(0===n)return r(t,e);var o=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n;return o=Math.max(0,Math.min(1,o)),r(t,{x:e.x+o*(i.x-e.x),y:e.y+o*(i.y-e.y)})}(t,e,i))},Ce=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.createClickBoundingBox=void 0,r.pixelDistance=void 0,r.config=e,r.createClickBoundingBox=i,r.pixelDistance=n,r}return r(e,t),e.prototype.find=function(t,e){for(var i=void 0,n=Infinity,r=void 0,o=Infinity,s=this.createClickBoundingBox.create(t),a=this.store.search(s),l=0;l<a.length;l++){var c=a[l],d=c.geometry;if("Point"===d.type){if(c.properties.selectionPoint||!e&&c.properties[Dt])continue;var h=this.pixelDistance.measure(t,d.coordinates);c.properties[Dt]&&h<this.pointerDistance&&h<o?(o=h,r=c):!c.properties[Dt]&&h<this.pointerDistance&&h<n&&(n=h,i=c)}else if("LineString"===d.type)for(var u=0;u<d.coordinates.length-1;u++){var g=d.coordinates[u],p=d.coordinates[u+1],f=_e({x:t.containerX,y:t.containerY},this.project(g[0],g[1]),this.project(p[0],p[1]));f<this.pointerDistance&&f<n&&(n=f,i=c)}else"Polygon"===d.type&&me([t.lng,t.lat],d.coordinates)&&(n=0,i=c)}return{clickedFeature:i,clickedMidPoint:r}},e}(Qt),Pe=/*#__PURE__*/function(t){function e(e,i,n,r){var o;return(o=t.call(this,e)||this).config=void 0,o.featuresAtMouseEvent=void 0,o.selectionPoints=void 0,o.midPoints=void 0,o.draggedFeatureId=null,o.dragPosition=void 0,o.config=e,o.featuresAtMouseEvent=i,o.selectionPoints=n,o.midPoints=r,o}r(e,t);var i=e.prototype;return i.startDragging=function(t,e){this.draggedFeatureId=e,this.dragPosition=[t.lng,t.lat]},i.stopDragging=function(){this.draggedFeatureId=null,this.dragPosition=void 0},i.isDragging=function(){return null!==this.draggedFeatureId},i.canDrag=function(t,e){var i=this.featuresAtMouseEvent.find(t,!0).clickedFeature;return!(!i||i.id!==e)},i.drag=function(t,e){if(this.draggedFeatureId){var i=this.store.getGeometryCopy(this.draggedFeatureId),n=[t.lng,t.lat];if("Polygon"===i.type||"LineString"===i.type){var r,o;if(o="Polygon"===i.type?(r=i.coordinates[0]).length-1:(r=i.coordinates).length,!this.dragPosition)return!1;for(var a=0;a<o;a++){var l=r[a],c=[this.dragPosition[0]-n[0],this.dragPosition[1]-n[1]],d=s(l[0]-c[0],this.config.coordinatePrecision),h=s(l[1]-c[1],this.config.coordinatePrecision);if(d>180||d<-180||h>90||h<-90)return!1;r[a]=[d,h]}"Polygon"===i.type&&(r[r.length-1]=[r[0][0],r[0][1]]);var u=this.selectionPoints.getUpdated(r)||[],g=this.midPoints.getUpdated(r)||[];if(e&&!e({type:"Feature",id:this.draggedFeatureId,geometry:i,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision}))return!1;this.store.updateGeometry([{id:this.draggedFeatureId,geometry:i}].concat(u,g)),this.dragPosition=[t.lng,t.lat]}else"Point"===i.type&&(this.store.updateGeometry([{id:this.draggedFeatureId,geometry:{type:"Point",coordinates:n}}]),this.dragPosition=[t.lng,t.lat])}},e}(Qt),xe=/*#__PURE__*/function(t){function e(e,i,n,r){var o;return(o=t.call(this,e)||this).config=void 0,o.pixelDistance=void 0,o.selectionPoints=void 0,o.midPoints=void 0,o.draggedCoordinate={id:null,index:-1},o.config=e,o.pixelDistance=i,o.selectionPoints=n,o.midPoints=r,o}r(e,t);var i=e.prototype;return i.getClosestCoordinate=function(t,e){var i,n={dist:Infinity,index:-1,isFirstOrLastPolygonCoord:!1};if("LineString"===e.type)i=e.coordinates;else{if("Polygon"!==e.type)return n;i=e.coordinates[0]}for(var r=0;r<i.length;r++){var o=this.pixelDistance.measure(t,i[r]);if(o<this.pointerDistance&&o<n.dist){var s="Polygon"===e.type&&(r===i.length-1||0===r);n.dist=o,n.index=s?0:r,n.isFirstOrLastPolygonCoord=s}}return n},i.getDraggableIndex=function(t,e){var i=this.store.getGeometryCopy(e),n=this.getClosestCoordinate(t,i);return-1===n.index?-1:n.index},i.drag=function(t,e,i){if(!this.draggedCoordinate.id)return!1;var n=this.draggedCoordinate.index,r=this.store.getGeometryCopy(this.draggedCoordinate.id),o="LineString"===r.type?r.coordinates:r.coordinates[0],s=[t.lng,t.lat];if(t.lng>180||t.lng<-180||t.lat>90||t.lat<-90)return!1;if("Polygon"!==r.type||n!==o.length-1&&0!==n)o[n]=s;else{var a=o.length-1;o[0]=s,o[a]=s}var l=this.selectionPoints.getOneUpdated(n,s),c=l?[l]:[],d=this.midPoints.getUpdated(o)||[];return!("Point"!==r.type&&!e&&Nt({type:"Feature",geometry:r,properties:{}})||i&&!i({type:"Feature",id:this.draggedCoordinate.id,geometry:r,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision})||(this.store.updateGeometry([{id:this.draggedCoordinate.id,geometry:r}].concat(c,d)),0))},i.isDragging=function(){return null!==this.draggedCoordinate.id},i.startDragging=function(t,e){this.draggedCoordinate={id:t,index:e}},i.stopDragging=function(){this.draggedCoordinate={id:null,index:-1}},e}(Qt);function Se(t){var e=0,i=0,n=0;return("Polygon"===t.geometry.type?t.geometry.coordinates[0].slice(0,-1):t.geometry.coordinates).forEach(function(t){e+=t[0],i+=t[1],n++},!0),[e/n,i/n]}function be(t,e){var i=t,n=e,r=Gt(i[1]),o=Gt(n[1]),s=Gt(n[0]-i[0]);s>Math.PI&&(s-=2*Math.PI),s<-Math.PI&&(s+=2*Math.PI);var a=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),l=(jt(Math.atan2(s,a))+360)%360;return l>180?-(360-l):l}function we(t,e,i){var n=e;e<0&&(n=-Math.abs(n));var r=n/At,o=t[0]*Math.PI/180,s=Gt(t[1]),a=Gt(i),l=r*Math.cos(a),c=s+l;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);var d=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),h=Math.abs(d)>1e-11?l/d:Math.cos(s),u=[(180*(o+r*Math.sin(a)/h)/Math.PI+540)%360-180,180*c/Math.PI];return u[0]+=u[0]-t[0]>180?-360:t[0]-u[0]>180?360:0,u}function Me(t,e){t[0]+=t[0]-e[0]>180?-360:e[0]-t[0]>180?360:0;var i=At,n=e[1]*Math.PI/180,r=t[1]*Math.PI/180,o=r-n,s=Math.abs(t[0]-e[0])*Math.PI/180;s>Math.PI&&(s-=2*Math.PI);var a=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(n/2+Math.PI/4)),l=Math.abs(a)>1e-11?o/a:Math.cos(n);return Math.sqrt(o*o+l*l*s*s)*i}var Ee=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.selectionPoints=void 0,r.midPoints=void 0,r.lastBearing=void 0,r.config=e,r.selectionPoints=i,r.midPoints=n,r}r(e,t);var i=e.prototype;return i.reset=function(){this.lastBearing=void 0},i.rotate=function(t,e,i){var n=this,r=this.store.getGeometryCopy(e);if("Polygon"===r.type||"LineString"===r.type){var o=[t.lng,t.lat],a=be(Se({type:"Feature",geometry:r,properties:{}}),o);if(this.lastBearing){!function(t,e){if(0===e)return t;var i=Se(t);("Polygon"===t.geometry.type?t.geometry.coordinates[0]:t.geometry.coordinates).forEach(function(t){var n=be(i,t)+e,r=Me(i,t),o=we(i,r,n);t[0]=o[0],t[1]=o[1]})}({type:"Feature",geometry:r,properties:{}},-(this.lastBearing-(a+180)));var l="Polygon"===r.type?r.coordinates[0]:r.coordinates;l.forEach(function(t){t[0]=s(t[0],n.coordinatePrecision),t[1]=s(t[1],n.coordinatePrecision)});var c=this.midPoints.getUpdated(l)||[],d=this.selectionPoints.getUpdated(l)||[];if(i&&!i({id:e,type:"Feature",geometry:r,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision}))return!1;this.store.updateGeometry([{id:e,geometry:r}].concat(d,c)),this.lastBearing=a+180}else this.lastBearing=a+180}},e}(Qt),Ie=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.selectionPoints=void 0,r.midPoints=void 0,r.lastDistance=void 0,r.config=e,r.selectionPoints=i,r.midPoints=n,r}r(e,t);var i=e.prototype;return i.reset=function(){this.lastDistance=void 0},i.scale=function(t,e,i){var n=this,r=this.store.getGeometryCopy(e);if("Polygon"===r.type||"LineString"===r.type){var o=[t.lng,t.lat],a=Bt(Se({type:"Feature",geometry:r,properties:{}}),o);if(this.lastDistance){var l={type:"Feature",geometry:r,properties:{}};!function(t,e,i,n){void 0===n&&(n="xy"),1===e||("Polygon"===t.geometry.type?t.geometry.coordinates[0]:t.geometry.coordinates).forEach(function(t){var r=Me(i,t),o=be(i,t),s=we(i,r*e,o);"x"!==n&&"xy"!==n||(t[0]=s[0]),"y"!==n&&"xy"!==n||(t[1]=s[1])})}(l,1-(this.lastDistance-a)/a,Se(l));var c="Polygon"===r.type?r.coordinates[0]:r.coordinates;c.forEach(function(t){t[0]=s(t[0],n.coordinatePrecision),t[1]=s(t[1],n.coordinatePrecision)});var d=this.midPoints.getUpdated(c)||[],h=this.selectionPoints.getUpdated(c)||[];if(i&&!i({id:e,type:"Feature",geometry:r,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision}))return!1;this.store.updateGeometry([{id:e,geometry:r}].concat(h,d)),this.lastDistance=a}else this.lastDistance=a}},e}(Qt),De=57.29577951308232,ke=.017453292519943295,Fe=6378137,Oe=function(t,e){return{x:0===t?0:t*ke*Fe,y:0===e?0:Math.log(Math.tan(Math.PI/4+e*ke/2))*Fe}};function Le(t){var e=function(t){for(var e=[Infinity,Infinity,-Infinity,-Infinity],i=0;i<t.length;i++){var n=t[i];e[0]>n[0]&&(e[0]=n[0]),e[1]>n[1]&&(e[1]=n[1]),e[2]<n[0]&&(e[2]=n[0]),e[3]<n[1]&&(e[3]=n[1])}return e}(("Polygon"===t.geometry.type?t.geometry.coordinates[0]:t.geometry.coordinates).map(function(t){var e=Oe(t[0],t[1]);return[e.x,e.y]}));return{x:(e[0]+e[2])/2,y:(e[1]+e[3])/2}}var We=/*#__PURE__*/function(t){function e(e,i,n,r){var o;return(o=t.call(this,e)||this).config=void 0,o.pixelDistance=void 0,o.selectionPoints=void 0,o.midPoints=void 0,o.minimumScale=1e-4,o.draggedCoordinate={id:null,index:-1},o.boundingBoxMaps={opposite:{0:4,1:5,2:6,3:7,4:0,5:1,6:2,7:3}},o.config=e,o.pixelDistance=i,o.selectionPoints=n,o.midPoints=r,o}r(e,t);var i=e.prototype;return i.getClosestCoordinate=function(t,e){var i,n={dist:Infinity,index:-1,isFirstOrLastPolygonCoord:!1};if("LineString"===e.type)i=e.coordinates;else{if("Polygon"!==e.type)return n;i=e.coordinates[0]}for(var r=0;r<i.length;r++){var o=this.pixelDistance.measure(t,i[r]);if(o<this.pointerDistance&&o<n.dist){var s="Polygon"===e.type&&(r===i.length-1||0===r);n.dist=o,n.index=s?0:r,n.isFirstOrLastPolygonCoord=s}}return n},i.isValidDragWebMercator=function(t,e,i){switch(t){case 0:if(e<=0||i>=0)return!1;break;case 1:if(i>=0)return!1;break;case 2:if(e>=0||i>=0)return!1;break;case 3:if(e>=0)return!1;break;case 4:if(e>=0||i<=0)return!1;break;case 5:if(i<=0)return!1;break;case 6:if(e<=0||i<=0)return!1;break;case 7:if(e<=0)return!1}return!0},i.getSelectedFeatureDataWebMercator=function(){if(!this.draggedCoordinate.id||-1===this.draggedCoordinate.index)return null;var t=this.getFeature(this.draggedCoordinate.id);if(!t)return null;var e=this.getNormalisedCoordinates(t.geometry);return{boundingBox:this.getBBoxWebMercator(e),feature:t,updatedCoords:e,selectedCoordinate:e[this.draggedCoordinate.index]}},i.centerWebMercatorDrag=function(t){var e=this.getSelectedFeatureDataWebMercator();if(!e)return null;var i=e.boundingBox,n=e.updatedCoords,r=e.selectedCoordinate,o=Le(e.feature);if(!o)return null;var s=Oe(r[0],r[1]),a=this.getIndexesWebMercator(i,s).closestBBoxIndex,l=Oe(t.lng,t.lat);return this.scaleWebMercator({closestBBoxIndex:a,updatedCoords:n,webMercatorCursor:l,webMercatorSelected:s,webMercatorOrigin:o}),n},i.centerFixedWebMercatorDrag=function(t){var e=this.getSelectedFeatureDataWebMercator();if(!e)return null;var i=e.boundingBox,n=e.updatedCoords,r=e.selectedCoordinate,o=Le(e.feature);if(!o)return null;var s=Oe(r[0],r[1]),a=this.getIndexesWebMercator(i,s).closestBBoxIndex,l=Oe(t.lng,t.lat);return this.scaleFixedWebMercator({closestBBoxIndex:a,updatedCoords:n,webMercatorCursor:l,webMercatorSelected:s,webMercatorOrigin:o}),n},i.scaleFixedWebMercator=function(t){var e=t.webMercatorOrigin,i=t.webMercatorSelected,n=t.webMercatorCursor,r=t.updatedCoords;if(!this.isValidDragWebMercator(t.closestBBoxIndex,e.x-n.x,e.y-n.y))return null;var o=a(e,n)/a(e,i);return o<0&&(o=this.minimumScale),this.performWebMercatorScale(r,e.x,e.y,o,o),r},i.oppositeFixedWebMercatorDrag=function(t){var e=this.getSelectedFeatureDataWebMercator();if(!e)return null;var i=e.boundingBox,n=e.updatedCoords,r=e.selectedCoordinate,o=Oe(r[0],r[1]),s=this.getIndexesWebMercator(i,o),a=s.oppositeBboxIndex,l=s.closestBBoxIndex,c={x:i[a][0],y:i[a][1]},d=Oe(t.lng,t.lat);return this.scaleFixedWebMercator({closestBBoxIndex:l,updatedCoords:n,webMercatorCursor:d,webMercatorSelected:o,webMercatorOrigin:c}),n},i.oppositeWebMercatorDrag=function(t){var e=this.getSelectedFeatureDataWebMercator();if(!e)return null;var i=e.boundingBox,n=e.updatedCoords,r=e.selectedCoordinate,o=Oe(r[0],r[1]),s=this.getIndexesWebMercator(i,o),a=s.oppositeBboxIndex,l=s.closestBBoxIndex,c={x:i[a][0],y:i[a][1]},d=Oe(t.lng,t.lat);return this.scaleWebMercator({closestBBoxIndex:l,updatedCoords:n,webMercatorCursor:d,webMercatorSelected:o,webMercatorOrigin:c}),n},i.scaleWebMercator=function(t){var e=t.closestBBoxIndex,i=t.webMercatorOrigin,n=t.webMercatorSelected,r=t.webMercatorCursor,o=t.updatedCoords,s=i.x-r.x,a=i.y-r.y;if(!this.isValidDragWebMercator(e,s,a))return null;var l=1;0!==s&&1!==e&&5!==e&&(l=1-(i.x-n.x-s)/s);var c=1;return 0!==a&&3!==e&&7!==e&&(c=1-(i.y-n.y-a)/a),this.validateScale(l,c)?(l<0&&(l=this.minimumScale),c<0&&(c=this.minimumScale),this.performWebMercatorScale(o,i.x,i.y,l,c),o):null},i.getFeature=function(t){if(null===this.draggedCoordinate.id)return null;var e=this.store.getGeometryCopy(t);return"Polygon"!==e.type&&"LineString"!==e.type?null:{type:"Feature",geometry:e,properties:{}}},i.getNormalisedCoordinates=function(t){return"Polygon"===t.type?t.coordinates[0]:t.coordinates},i.validateScale=function(t,e){var i=!isNaN(t)&&e<Number.MAX_SAFE_INTEGER,n=!isNaN(e)&&e<Number.MAX_SAFE_INTEGER;return i&&n},i.performWebMercatorScale=function(t,e,i,n,r){t.forEach(function(t){var o,s,a=Oe(t[0],t[1]),l={lng:0===(o=e+(a.x-e)*n)?0:De*(o/Fe),lat:0===(s=i+(a.y-i)*r)?0:(2*Math.atan(Math.exp(s/Fe))-Math.PI/2)*De},c=l.lat;t[0]=l.lng,t[1]=c})},i.getBBoxWebMercator=function(t){var e=[Infinity,Infinity,-Infinity,-Infinity];(t=t.map(function(t){var e=Oe(t[0],t[1]);return[e.x,e.y]})).forEach(function(t){var i=t[0],n=t[1];i<e[0]&&(e[0]=i),n<e[1]&&(e[1]=n),i>e[2]&&(e[2]=i),n>e[3]&&(e[3]=n)});var i=e[0],n=e[1],r=e[2],o=e[3];return[[i,o],[(i+r)/2,o],[r,o],[r,o+(n-o)/2],[r,n],[(i+r)/2,n],[i,n],[i,o+(n-o)/2]]},i.getIndexesWebMercator=function(t,e){for(var i,n=Infinity,r=0;r<t.length;r++){var o=a({x:e.x,y:e.y},{x:t[r][0],y:t[r][1]});o<n&&(i=r,n=o)}if(void 0===i)throw new Error("No closest coordinate found");return{oppositeBboxIndex:this.boundingBoxMaps.opposite[i],closestBBoxIndex:i}},i.isDragging=function(){return null!==this.draggedCoordinate.id},i.startDragging=function(t,e){this.draggedCoordinate={id:t,index:e}},i.stopDragging=function(){this.draggedCoordinate={id:null,index:-1}},i.getDraggableIndex=function(t,e){var i=this.store.getGeometryCopy(e),n=this.getClosestCoordinate(t,i);return-1===n.index?-1:n.index},i.drag=function(t,e,i){if(!this.draggedCoordinate.id)return!1;var n=this.getFeature(this.draggedCoordinate.id);if(!n)return!1;var r=null;if("center-web-mercator"===e?r=this.centerWebMercatorDrag(t):"opposite-web-mercator"===e?r=this.oppositeWebMercatorDrag(t):"center-fixed-web-mercator"===e?r=this.centerFixedWebMercatorDrag(t):"opposite-fixed-web-mercator"===e&&(r=this.oppositeFixedWebMercatorDrag(t)),!r)return!1;for(var o=0;o<r.length;o++){var a=r[o];if(a[0]=s(a[0],this.coordinatePrecision),a[1]=s(a[1],this.coordinatePrecision),!Tt(a,this.coordinatePrecision))return!1}var l=this.midPoints.getUpdated(r)||[],c=this.selectionPoints.getUpdated(r)||[],d={type:n.geometry.type,coordinates:"Polygon"===n.geometry.type?[r]:r};return!(i&&!i({id:this.draggedCoordinate.id,type:"Feature",geometry:d,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision})||(this.store.updateGeometry([{id:this.draggedCoordinate.id,geometry:d}].concat(c,l)),0))},e}(Qt),Be=/*#__PURE__*/function(t){function e(e){var i,r;(r=t.call(this,e)||this).mode="select",r.allowManualDeselection=!0,r.dragEventThrottle=5,r.dragEventCount=0,r.selected=[],r.flags=void 0,r.keyEvents=void 0,r.selectionPoints=void 0,r.midPoints=void 0,r.featuresAtMouseEvent=void 0,r.pixelDistance=void 0,r.clickBoundingBox=void 0,r.dragFeature=void 0,r.dragCoordinate=void 0,r.rotateFeature=void 0,r.scaleFeature=void 0,r.dragCoordinateResizeFeature=void 0,r.cursors=void 0,r.validations={},r.flags=e&&e.flags?e.flags:{};var o={pointerOver:"move",dragStart:"move",dragEnd:"move",insertMidpoint:"crosshair"};if(r.cursors=e&&e.cursors?n({},o,e.cursors):o,null===(null==e?void 0:e.keyEvents))r.keyEvents={deselect:null,delete:null,rotate:null,scale:null};else{var s={deselect:"Escape",delete:"Delete",rotate:["Control","r"],scale:["Control","s"]};r.keyEvents=e&&e.keyEvents?n({},s,e.keyEvents):s}if(r.dragEventThrottle=e&&void 0!==e.dragEventThrottle&&e.dragEventThrottle||5,r.allowManualDeselection=null==(i=null==e?void 0:e.allowManualDeselection)||i,e&&e.flags&&e.flags)for(var a in e.flags){var l=e.flags[a].feature;l&&l.validation&&(r.validations[a]=l.validation)}return r}r(e,t);var i=e.prototype;return i.selectFeature=function(t){this.select(t,!1)},i.setSelecting=function(){if("started"!==this._state)throw new Error("Mode must be started to move to selecting state");this._state="selecting"},i.registerBehaviors=function(t){this.pixelDistance=new ee(t),this.clickBoundingBox=new ne(t),this.featuresAtMouseEvent=new Ce(t,this.clickBoundingBox,this.pixelDistance),this.selectionPoints=new ve(t),this.midPoints=new ye(t,this.selectionPoints),this.rotateFeature=new Ee(t,this.selectionPoints,this.midPoints),this.scaleFeature=new Ie(t,this.selectionPoints,this.midPoints),this.dragFeature=new Pe(t,this.featuresAtMouseEvent,this.selectionPoints,this.midPoints),this.dragCoordinate=new xe(t,this.pixelDistance,this.selectionPoints,this.midPoints),this.dragCoordinateResizeFeature=new We(t,this.pixelDistance,this.selectionPoints,this.midPoints)},i.deselectFeature=function(){this.deselect()},i.deselect=function(){var t=this,e=this.selected.filter(function(e){return t.store.has(e)}).map(function(t){return{id:t,property:It,value:!1}});this.store.updateProperty(e),this.onDeselect(this.selected[0]),this.selected=[],this.selectionPoints.delete(),this.midPoints.delete()},i.deleteSelected=function(){this.store.delete(this.selected),this.selected=[]},i.onRightClick=function(t){var e=this;if(this.selectionPoints.ids.length){var i,n=Infinity;if(this.selectionPoints.ids.forEach(function(r){var o=e.store.getGeometryCopy(r),s=e.pixelDistance.measure(t,o.coordinates);s<e.pointerDistance&&s<n&&(n=s,i=e.store.getPropertiesCopy(r))}),i){var r=i.selectionPointFeatureId,o=i.index,s=this.store.getPropertiesCopy(r),a=this.flags[s.mode],l=this.validations[s.mode];if(a&&a.feature&&a.feature.coordinates&&a.feature.coordinates.deletable){var c,d=this.store.getGeometryCopy(r);if("Polygon"===d.type){if((c=d.coordinates[0]).length<=4)return}else if("LineString"===d.type&&(c=d.coordinates).length<=3)return;if(c){if("Polygon"===d.type&&0===o||o===c.length-1?(c.shift(),c.pop(),c.push([c[0][0],c[0][1]])):c.splice(o,1),l&&!l({id:r,type:"Feature",geometry:d,properties:s}))return;this.store.delete([].concat(this.midPoints.ids,this.selectionPoints.ids)),this.store.updateGeometry([{id:r,geometry:d}]),this.selectionPoints.create(c,d.type,r),a&&a.feature&&a.feature.coordinates&&a.feature.coordinates.midpoints&&this.midPoints.create(c,r,this.coordinatePrecision)}}}}},i.select=function(t,e){if(void 0===e&&(e=!0),this.selected[0]!==t){var i=this.store.getPropertiesCopy(t),n=this.flags[i.mode];if(n&&n.feature){var r=this.selected[0];if(r){if(r===t)return;this.deselect()}e&&this.setCursor(this.cursors.pointerOver),this.selected=[t],this.store.updateProperty([{id:t,property:"selected",value:!0}]),this.onSelect(t);var o=this.store.getGeometryCopy(t),s=o.type,a=o.coordinates;if("LineString"===s||"Polygon"===s){var l="LineString"===s?a:a[0];l&&n&&n.feature.coordinates&&(this.selectionPoints.create(l,s,t),n.feature.coordinates.midpoints&&this.midPoints.create(l,t,this.coordinatePrecision))}}}},i.onLeftClick=function(t){var e=this.featuresAtMouseEvent.find(t,this.selected.length>0),i=e.clickedFeature,n=e.clickedMidPoint;if(this.selected.length&&n)this.midPoints.insert(n.id,this.coordinatePrecision);else if(i&&i.id)this.select(i.id,!0);else if(this.selected.length&&this.allowManualDeselection)return void this.deselect()},i.start=function(){this.setStarted(),this.setSelecting()},i.stop=function(){this.cleanUp(),this.setStarted(),this.setStopped()},i.onClick=function(t){"right"!==t.button?"left"===t.button&&this.onLeftClick(t):this.onRightClick(t)},i.canScale=function(t){return this.keyEvents.scale&&this.keyEvents.scale.every(function(e){return t.heldKeys.includes(e)})},i.canRotate=function(t){return this.keyEvents.rotate&&this.keyEvents.rotate.every(function(e){return t.heldKeys.includes(e)})},i.preventDefaultKeyEvent=function(t){var e=this.canRotate(t),i=this.canScale(t);(e||i)&&t.preventDefault()},i.onKeyDown=function(t){this.preventDefaultKeyEvent(t)},i.onKeyUp=function(t){if(this.preventDefaultKeyEvent(t),this.keyEvents.delete&&t.key===this.keyEvents.delete){if(!this.selected.length)return;this.onDeselect(this.selected[0]),this.deleteSelected(),this.selectionPoints.delete(),this.midPoints.delete()}else this.keyEvents.deselect&&t.key===this.keyEvents.deselect&&this.cleanUp()},i.cleanUp=function(){this.selected.length&&this.deselect()},i.onDragStart=function(t,e){if(this.selected.length){var i=this.store.getPropertiesCopy(this.selected[0]),n=this.flags[i.mode];if(n&&n.feature&&(n.feature.draggable||n.feature.coordinates&&n.feature.coordinates.draggable||n.feature.coordinates&&n.feature.coordinates.resizable)){this.dragEventCount=0;var r=this.selected[0],o=this.dragCoordinate.getDraggableIndex(t,r);return n&&n.feature&&n.feature.coordinates&&(n.feature.coordinates.draggable||n.feature.coordinates.resizable)&&-1!==o?(this.setCursor(this.cursors.dragStart),n.feature.coordinates.resizable?this.dragCoordinateResizeFeature.startDragging(r,o):this.dragCoordinate.startDragging(r,o),void e(!1)):n&&n.feature&&n.feature.draggable&&this.dragFeature.canDrag(t,r)?(this.setCursor(this.cursors.dragStart),this.dragFeature.startDragging(t,r),void e(!1)):void 0}}},i.onDrag=function(t,e){var i=this.selected[0];if(i){var n=this.store.getPropertiesCopy(i),r=this.flags[n.mode],o=!0===(r&&r.feature&&r.feature.selfIntersectable);if(this.dragEventCount++,this.dragEventCount%this.dragEventThrottle!=0){var s=this.validations[n.mode];return r&&r.feature&&r.feature.rotateable&&this.canRotate(t)?(e(!1),void this.rotateFeature.rotate(t,i,s)):r&&r.feature&&r.feature.scaleable&&this.canScale(t)?(e(!1),void this.scaleFeature.scale(t,i,s)):this.dragCoordinateResizeFeature.isDragging()&&r.feature&&r.feature.coordinates&&r.feature.coordinates.resizable?(e(!1),void this.dragCoordinateResizeFeature.drag(t,r.feature.coordinates.resizable,s)):void(this.dragCoordinate.isDragging()?this.dragCoordinate.drag(t,o,s):this.dragFeature.isDragging()?this.dragFeature.drag(t,s):e(!0))}}},i.onDragEnd=function(t,e){this.setCursor(this.cursors.dragEnd),(this.dragCoordinate.isDragging()||this.dragFeature.isDragging()||this.dragCoordinateResizeFeature.isDragging())&&this.onFinish(this.selected[0]),this.dragCoordinate.stopDragging(),this.dragFeature.stopDragging(),this.dragCoordinateResizeFeature.stopDragging(),this.rotateFeature.reset(),this.scaleFeature.reset(),e(!0)},i.onMouseMove=function(t){var e=this;if(this.selected.length){if(!this.dragFeature.isDragging()){var i=!1;this.midPoints.ids.forEach(function(n){if(!i){var r=e.store.getGeometryCopy(n);e.pixelDistance.measure(t,r.coordinates)<e.pointerDistance&&(i=!0)}});var n=!1;if(this.selectionPoints.ids.forEach(function(r){var o=e.store.getGeometryCopy(r);e.pixelDistance.measure(t,o.coordinates)<e.pointerDistance&&(i=!1,n=!0)}),i)this.setCursor(this.cursors.insertMidpoint);else{var r=this.featuresAtMouseEvent.find(t,!0).clickedFeature;this.setCursor(this.selected.length>0&&(r&&r.id===this.selected[0]||n)?this.cursors.pointerOver:"unset")}}}else this.setCursor("unset")},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});if(t.properties.mode===this.mode&&"Point"===t.geometry.type){if(t.properties.selectionPoint)return e.pointColor=this.getHexColorStylingValue(this.styles.selectionPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.selectionPointOutlineColor,e.pointOutlineColor,t),e.pointWidth=this.getNumericStylingValue(this.styles.selectionPointWidth,e.pointWidth,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.selectionPointOutlineWidth,2,t),e.zIndex=30,e;if(t.properties.midPoint)return e.pointColor=this.getHexColorStylingValue(this.styles.midPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.midPointOutlineColor,e.pointOutlineColor,t),e.pointWidth=this.getNumericStylingValue(this.styles.midPointWidth,4,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.midPointOutlineWidth,2,t),e.zIndex=40,e}else if(t.properties[It]){if("Polygon"===t.geometry.type)return e.polygonFillColor=this.getHexColorStylingValue(this.styles.selectedPolygonColor,e.polygonFillColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth,e.polygonOutlineWidth,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor,e.polygonOutlineColor,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity,e.polygonFillOpacity,t),e.zIndex=10,e;if("LineString"===t.geometry.type)return e.lineStringColor=this.getHexColorStylingValue(this.styles.selectedLineStringColor,e.lineStringColor,t),e.lineStringWidth=this.getNumericStylingValue(this.styles.selectedLineStringWidth,e.lineStringWidth,t),e.zIndex=10,e;if("Point"===t.geometry.type)return e.pointWidth=this.getNumericStylingValue(this.styles.selectedPointWidth,e.pointWidth,t),e.pointColor=this.getHexColorStylingValue(this.styles.selectedPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.selectedPointOutlineColor,e.pointOutlineColor,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.selectedPointOutlineWidth,e.pointOutlineWidth,t),e.zIndex=10,e}return e},e}(Wt),Ae=/*#__PURE__*/function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).type=wt.Static,e.mode="static",e}r(e,t);var i=e.prototype;return i.start=function(){},i.stop=function(){},i.onKeyUp=function(){},i.onKeyDown=function(){},i.onClick=function(){},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.onMouseMove=function(){},i.cleanUp=function(){},i.styleFeature=function(){return n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0})},e}(Lt);function Ge(t,e,i,n,r){for(;n>i;){if(n-i>600){var o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ge(t,e,Math.max(i,Math.floor(e-s*l/o+c)),Math.min(n,Math.floor(e+(o-s)*l/o+c)),r)}var d=t[e],h=i,u=n;for(je(t,i,e),r(t[n],d)>0&&je(t,i,n);h<u;){for(je(t,h,u),h++,u--;r(t[h],d)<0;)h++;for(;r(t[u],d)>0;)u--}0===r(t[i],d)?je(t,i,u):je(t,++u,n),u<=e&&(i=u+1),e<=u&&(n=u-1)}}function je(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Re(t,e){Ne(t,0,t.children.length,e,t)}function Ne(t,e,i,n,r){r||(r=Ke([])),r.minX=Infinity,r.minY=Infinity,r.maxX=-Infinity,r.maxY=-Infinity;for(var o=e;o<i;o++){var s=t.children[o];Ve(r,t.leaf?n(s):s)}return r}function Ve(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Te(t,e){return t.minX-e.minX}function ze(t,e){return t.minY-e.minY}function Ue(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Xe(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Ye(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function He(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Ke(t){return{children:t,height:1,leaf:!0,minX:Infinity,minY:Infinity,maxX:-Infinity,maxY:-Infinity}}function Je(t,e,i,n,r){for(var o=[e,i];o.length;)if(!((i=o.pop())-(e=o.pop())<=n)){var s=e+Math.ceil((i-e)/n/2)*n;Ge(t,s,e,i,r),o.push(e,s,s,i)}}var qe=/*#__PURE__*/function(){function t(t){this._maxEntries=void 0,this._minEntries=void 0,this.data=void 0,this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}var e=t.prototype;return e.search=function(t){var e=this.data,i=[];if(!He(t,e))return i;for(var n=this.toBBox,r=[];e;){for(var o=0;o<e.children.length;o++){var s=e.children[o],a=e.leaf?n(s):s;He(t,a)&&(e.leaf?i.push(s):Ye(t,a)?this._all(s,i):r.push(s))}e=r.pop()}return i},e.collides=function(t){var e=this.data;if(He(t,e))for(var i=[];e;){for(var n=0;n<e.children.length;n++){var r=e.children[n],o=e.leaf?this.toBBox(r):r;if(He(t,o)){if(e.leaf||Ye(t,o))return!0;i.push(r)}}e=i.pop()}return!1},e.load=function(t){if(t.length<this._minEntries)for(var e=0;e<t.length;e++)this.insert(t[e]);else{var i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var n=this.data;this.data=i,i=n}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i}},e.insert=function(t){this._insert(t,this.data.height-1)},e.clear=function(){this.data=Ke([])},e.remove=function(t){for(var e,i,n=this.data,r=this.toBBox(t),o=[],s=[],a=!1;n||o.length;){if(n||(n=o.pop(),i=o[o.length-1],e=s.pop(),a=!0),n.leaf){var l=n.children.indexOf(t);-1!==l&&(n.children.splice(l,1),o.push(n),this._condense(o))}a||n.leaf||!Ye(n,r)?i?(e++,n=i.children[e],a=!1):n=null:(o.push(n),s.push(e),e=0,i=n,n=n.children[0])}},e.toBBox=function(t){return t},e.compareMinX=function(t,e){return t.minX-e.minX},e.compareMinY=function(t,e){return t.minY-e.minY},e._all=function(t,e){for(var i=[];t;)t.leaf?e.push.apply(e,t.children):i.push.apply(i,t.children),t=i.pop();return e},e._build=function(t,e,i,n){var r,o=i-e+1,s=this._maxEntries;if(o<=s)return Re(r=Ke(t.slice(e,i+1)),this.toBBox),r;n||(n=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,n-1))),(r=Ke([])).leaf=!1,r.height=n;var a=Math.ceil(o/s),l=a*Math.ceil(Math.sqrt(s));Je(t,e,i,l,this.compareMinX);for(var c=e;c<=i;c+=l){var d=Math.min(c+l-1,i);Je(t,c,d,a,this.compareMinY);for(var h=c;h<=d;h+=a){var u=Math.min(h+a-1,d);r.children.push(this._build(t,h,u,n-1))}}return Re(r,this.toBBox),r},e._chooseSubtree=function(t,e,i,n){for(;n.push(e),!e.leaf&&n.length-1!==i;){for(var r=Infinity,o=Infinity,s=void 0,a=0;a<e.children.length;a++){var l=e.children[a],c=Ue(l),d=(h=t,u=l,(Math.max(u.maxX,h.maxX)-Math.min(u.minX,h.minX))*(Math.max(u.maxY,h.maxY)-Math.min(u.minY,h.minY))-c);d<o?(o=d,r=c<r?c:r,s=l):d===o&&c<r&&(r=c,s=l)}e=s||e.children[0]}var h,u;return e},e._insert=function(t,e,i){var n=i?t:this.toBBox(t),r=[],o=this._chooseSubtree(n,this.data,e,r);for(o.children.push(t),Ve(o,n);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)},e._split=function(t,e){var i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);var o=this._chooseSplitIndex(i,r,n),s=Ke(i.children.splice(o,i.children.length-o));s.height=i.height,s.leaf=i.leaf,Re(i,this.toBBox),Re(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(i,s)},e._splitRoot=function(t,e){this.data=Ke([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Re(this.data,this.toBBox)},e._chooseSplitIndex=function(t,e,i){for(var n,r,o,s,a,l,c,d=Infinity,h=Infinity,u=e;u<=i-e;u++){var g=Ne(t,0,u,this.toBBox),p=Ne(t,u,i,this.toBBox),f=(r=g,o=p,s=Math.max(r.minX,o.minX),a=Math.max(r.minY,o.minY),l=Math.min(r.maxX,o.maxX),c=Math.min(r.maxY,o.maxY),Math.max(0,l-s)*Math.max(0,c-a)),y=Ue(g)+Ue(p);f<d?(d=f,n=u,h=y<h?y:h):f===d&&y<h&&(h=y,n=u)}return n||i-e},e._chooseSplitAxis=function(t,e,i){var n=t.leaf?this.compareMinX:Te,r=t.leaf?this.compareMinY:ze;this._allDistMargin(t,e,i,n)<this._allDistMargin(t,e,i,r)&&t.children.sort(n)},e._allDistMargin=function(t,e,i,n){t.children.sort(n);for(var r=this.toBBox,o=Ne(t,0,e,r),s=Ne(t,i-e,i,r),a=Xe(o)+Xe(s),l=e;l<i-e;l++){var c=t.children[l];Ve(o,t.leaf?r(c):c),a+=Xe(o)}for(var d=i-e-1;d>=e;d--){var h=t.children[d];Ve(s,t.leaf?r(h):h),a+=Xe(s)}return a},e._adjustParentBBoxes=function(t,e,i){for(var n=i;n>=0;n--)Ve(e[n],t)},e._condense=function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():Re(t[i],this.toBBox)},t}(),Ze=/*#__PURE__*/function(){function t(t){this.tree=void 0,this.idToNode=void 0,this.nodeToId=void 0,this.tree=new qe(t&&t.maxEntries?t.maxEntries:9),this.idToNode=new Map,this.nodeToId=new Map}var e=t.prototype;return e.setMaps=function(t,e){this.idToNode.set(t.id,e),this.nodeToId.set(e,t.id)},e.toBBox=function(t){var e,i=[],n=[];if("Polygon"===t.geometry.type)e=t.geometry.coordinates[0];else if("LineString"===t.geometry.type)e=t.geometry.coordinates;else{if("Point"!==t.geometry.type)throw new Error("Not a valid feature to turn into a bounding box");e=[t.geometry.coordinates]}for(var r=0;r<e.length;r++)n.push(e[r][1]),i.push(e[r][0]);var o=Math.min.apply(Math,n),s=Math.max.apply(Math,n);return{minX:Math.min.apply(Math,i),minY:o,maxX:Math.max.apply(Math,i),maxY:s}},e.insert=function(t){if(this.idToNode.get(String(t.id)))throw new Error("Feature already exists");var e=this.toBBox(t);this.setMaps(t,e),this.tree.insert(e)},e.load=function(t){var e=this,i=[],n=new Set;t.forEach(function(t){var r=e.toBBox(t);if(e.setMaps(t,r),n.has(String(t.id)))throw new Error("Duplicate feature ID found "+t.id);n.add(String(t.id)),i.push(r)}),this.tree.load(i)},e.update=function(t){this.remove(t.id);var e=this.toBBox(t);this.setMaps(t,e),this.tree.insert(e)},e.remove=function(t){var e=this.idToNode.get(t);if(!e)throw new Error(t+" not inserted into the spatial index");this.tree.remove(e)},e.clear=function(){this.tree.clear()},e.search=function(t){var e=this;return this.tree.search(this.toBBox(t)).map(function(t){return e.nodeToId.get(t)})},e.collides=function(t){return this.tree.collides(this.toBBox(t))},t}(),$e={getId:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)})},isValidId:function(t){return"string"==typeof t&&36===t.length}},Qe=/*#__PURE__*/function(){function t(t){this.idStrategy=void 0,this.tracked=void 0,this.spatialIndex=void 0,this.store=void 0,this._onChange=function(){},this.store={},this.spatialIndex=new Ze,this.tracked=!t||!1!==t.tracked,this.idStrategy=t&&t.idStrategy?t.idStrategy:$e}var e=t.prototype;return e.clone=function(t){return JSON.parse(JSON.stringify(t))},e.getId=function(){return this.idStrategy.getId()},e.has=function(t){return Boolean(this.store[t])},e.load=function(t,e){var i=this;if(0!==t.length){var n=this.clone(t);n.forEach(function(t){null==t.id&&(t.id=i.idStrategy.getId()),i.tracked&&(t.properties.createdAt?Ot(t.properties.createdAt):t.properties.createdAt=+new Date,t.properties.updatedAt?Ot(t.properties.updatedAt):t.properties.updatedAt=+new Date)});var r=[];n.forEach(function(t){var n=t.id;if(e&&!e(t))throw new Error("Feature is not "+n+" valid: "+JSON.stringify(t));if(i.has(n))throw new Error("Feature already exists with this id: "+n);i.store[n]=t,r.push(n)}),this.spatialIndex.load(n),this._onChange(r,"create")}},e.search=function(t,e){var i=this,n=this.spatialIndex.search(t).map(function(t){return i.store[t]});return this.clone(e?n.filter(e):n)},e.registerOnChange=function(t){this._onChange=function(e,i){t(e,i)}},e.getGeometryCopy=function(t){var e=this.store[t];if(!e)throw new Error("No feature with this id ("+t+"), can not get geometry copy");return this.clone(e.geometry)},e.getPropertiesCopy=function(t){var e=this.store[t];if(!e)throw new Error("No feature with this id ("+t+"), can not get properties copy");return this.clone(e.properties)},e.updateProperty=function(t){var e=this,i=[];t.forEach(function(t){var n=t.id,r=t.property,o=t.value,s=e.store[n];if(!s)throw new Error("No feature with this ("+n+"), can not update geometry");i.push(n),s.properties[r]=o,e.tracked&&(s.properties.updatedAt=+new Date)}),this._onChange&&this._onChange(i,"update")},e.updateGeometry=function(t){var e=this,i=[];t.forEach(function(t){var n=t.id,r=t.geometry;i.push(n);var o=e.store[n];if(!o)throw new Error("No feature with this ("+n+"), can not update geometry");o.geometry=e.clone(r),e.spatialIndex.update(o),e.tracked&&(o.properties.updatedAt=+new Date)}),this._onChange&&this._onChange(i,"update")},e.create=function(t){var e=this,i=[];return t.forEach(function(t){var r,o=t.geometry,s=t.properties,a=n({},s);e.tracked&&(r=+new Date,s?(a.createdAt="number"==typeof s.createdAt?s.createdAt:r,a.updatedAt="number"==typeof s.updatedAt?s.updatedAt:r):a={createdAt:r,updatedAt:r});var l=e.getId(),c={id:l,type:"Feature",geometry:o,properties:a};e.store[l]=c,e.spatialIndex.insert(c),i.push(l)}),this._onChange&&this._onChange([].concat(i),"create"),i},e.delete=function(t){var e=this;t.forEach(function(t){if(!e.store[t])throw new Error("No feature with this id, can not delete");delete e.store[t],e.spatialIndex.remove(t)}),this._onChange&&this._onChange([].concat(t),"delete")},e.copyAll=function(){var t=this;return this.clone(Object.keys(this.store).map(function(e){return t.store[e]}))},e.clear=function(){this.store={},this.spatialIndex.clear()},e.size=function(){return Object.keys(this.store).length},t}();function ti(t){var e=t.coordinates,i=0;if(e&&e.length>0){i+=Math.abs(ni(e[0]));for(var n=1;n<e.length;n++)i-=Math.abs(ni(e[n]))}return i}var ei=20294876564838.72,ii=Math.PI/180;function ni(t){var e=t.length;if(e<=2)return 0;for(var i=0,n=0;n<e;)i+=(t[n+2>=e?(n+2)%e:n+2][0]*ii-t[n][0]*ii)*Math.sin(t[n+1===e?0:n+1][1]*ii),n++;return i*ei}var ri={TerraDrawBaseDrawMode:Lt,TerraDrawBaseAdapter:c};exports.TerraDraw=/*#__PURE__*/function(){function t(t){var e=this;this._modes=void 0,this._mode=void 0,this._adapter=void 0,this._enabled=!1,this._store=void 0,this._eventListeners=void 0,this._instanceSelectMode=void 0,this._adapter=t.adapter,this._mode=new Ae;var i=new Set,r=t.modes.reduce(function(t,e){if(i.has(e.mode))throw new Error("There is already a "+e.mode+" mode provided");return i.add(e.mode),t[e.mode]=e,t},{}),o=Object.keys(r);if(0===o.length)throw new Error("No modes provided");o.forEach(function(t){if(r[t].type===wt.Select){if(e._instanceSelectMode)throw new Error("only one type of select mode can be provided");e._instanceSelectMode=t}}),this._modes=n({},r,{static:this._mode}),this._eventListeners={change:[],select:[],deselect:[],finish:[],ready:[]},this._store=new Qe({tracked:!!t.tracked,idStrategy:t.idStrategy?t.idStrategy:void 0});var s=function(t){var i=[],n=e._store.copyAll().filter(function(e){return!t.includes(e.id)||(i.push(e),!1)});return{changed:i,unchanged:n}},a=function(t){e._enabled&&e._eventListeners.finish.forEach(function(e){e(t)})},l=function(t,i){if(e._enabled){e._eventListeners.change.forEach(function(e){e(t,i)});var n=s(t),r=n.changed,o=n.unchanged;"create"===i?e._adapter.render({created:r,deletedIds:[],unchanged:o,updated:[]},e.getModeStyles()):"update"===i?e._adapter.render({created:[],deletedIds:[],unchanged:o,updated:r},e.getModeStyles()):"delete"===i?e._adapter.render({created:[],deletedIds:t,unchanged:o,updated:[]},e.getModeStyles()):"styling"===i&&e._adapter.render({created:[],deletedIds:[],unchanged:o,updated:[]},e.getModeStyles())}},c=function(t){if(e._enabled){e._eventListeners.select.forEach(function(e){e(t)});var i=s([t]);e._adapter.render({created:[],deletedIds:[],unchanged:i.unchanged,updated:i.changed},e.getModeStyles())}},d=function(t){if(e._enabled){e._eventListeners.deselect.forEach(function(t){t()});var i=s([t]),n=i.changed;n&&e._adapter.render({created:[],deletedIds:[],unchanged:i.unchanged,updated:n},e.getModeStyles())}};Object.keys(this._modes).forEach(function(t){e._modes[t].register({mode:t,store:e._store,setCursor:e._adapter.setCursor.bind(e._adapter),project:e._adapter.project.bind(e._adapter),unproject:e._adapter.unproject.bind(e._adapter),setDoubleClickToZoom:e._adapter.setDoubleClickToZoom.bind(e._adapter),onChange:l,onSelect:c,onDeselect:d,onFinish:a,coordinatePrecision:e._adapter.getCoordinatePrecision()})})}var e=t.prototype;return e.checkEnabled=function(){if(!this._enabled)throw new Error("Terra Draw is not enabled")},e.getModeStyles=function(){var t=this,e={};return Object.keys(this._modes).forEach(function(i){e[i]=function(e){return t._instanceSelectMode&&e.properties[It]?t._modes[t._instanceSelectMode].styleFeature.bind(t._modes[t._instanceSelectMode])(e):t._modes[i].styleFeature.bind(t._modes[i])(e)}}),e},e.featuresAtLocation=function(t,e){var i=t.lng,n=t.lat,r=e&&void 0!==e.pointerDistance?e.pointerDistance:30,o=!e||void 0===e.ignoreSelectFeatures||e.ignoreSelectFeatures,s=this._adapter.unproject.bind(this._adapter),l=this._adapter.project.bind(this._adapter),c=l(i,n),d=ie({unproject:s,point:c,pointerDistance:r});return this._store.search(d).filter(function(t){if(o&&(t.properties[Dt]||t.properties.selectionPoint))return!1;if("Point"===t.geometry.type){var e=t.geometry.coordinates,s=l(e[0],e[1]);return a(c,s)<r}if("LineString"===t.geometry.type){for(var d=t.geometry.coordinates,h=0;h<d.length-1;h++){var u=d[h],g=d[h+1];if(_e(c,l(u[0],u[1]),l(g[0],g[1]))<r)return!0}return!1}return!!me([i,n],t.geometry.coordinates)||void 0})},e.getSelectMode=function(){if(this.checkEnabled(),!this._instanceSelectMode)throw new Error("No select mode defined in instance");return this.getMode()!==this._instanceSelectMode&&this.setMode(this._instanceSelectMode),this._modes[this._instanceSelectMode]},e.setModeStyles=function(t,e){if(this.checkEnabled(),!this._modes[t])throw new Error("No mode with this name present");this._modes[t].styles=e},e.getSnapshot=function(){return this._store.copyAll()},e.clear=function(){this.checkEnabled(),this._adapter.clear()},e.getMode=function(){return this._mode.mode},e.setMode=function(t){if(this.checkEnabled(),!this._modes[t])throw new Error("No mode with this name present");this._mode.stop(),this._mode=this._modes[t],this._mode.start()},e.removeFeatures=function(t){this.checkEnabled(),this._store.delete(t)},e.selectFeature=function(t){this.getSelectMode().selectFeature(t)},e.deselectFeature=function(t){this.getSelectMode().deselectFeature(t)},e.getFeatureId=function(){return this._store.getId()},e.hasFeature=function(t){return this._store.has(t)},e.addFeatures=function(t){var e=this;this.checkEnabled(),0!==t.length&&this._store.load(t,function(t){if(Boolean(t&&"object"==typeof t&&"properties"in t&&"object"==typeof t.properties&&null!==t.properties&&"mode"in t.properties)){var i=e._modes[t.properties.mode];return!!i&&i.validateFeature.bind(i)(t)}return!1})},e.start=function(){var t=this;this._enabled=!0,this._adapter.register({onReady:function(){t._eventListeners.ready.forEach(function(t){t()})},getState:function(){return t._mode.state},onClick:function(e){t._mode.onClick(e)},onMouseMove:function(e){t._mode.onMouseMove(e)},onKeyDown:function(e){t._mode.onKeyDown(e)},onKeyUp:function(e){t._mode.onKeyUp(e)},onDragStart:function(e,i){t._mode.onDragStart(e,i)},onDrag:function(e,i){t._mode.onDrag(e,i)},onDragEnd:function(e,i){t._mode.onDragEnd(e,i)},onClear:function(){t._mode.cleanUp(),t._store.clear()}})},e.getFeaturesAtLngLat=function(t,e){return this.featuresAtLocation({lng:t.lng,lat:t.lat},e)},e.getFeaturesAtPointerEvent=function(t,e){var i=this._adapter.getLngLatFromEvent.bind(this._adapter)(t);return null===i?[]:this.featuresAtLocation(i,e)},e.stop=function(){this._enabled=!1,this._adapter.unregister()},e.on=function(t,e){var i=this._eventListeners[t];i.includes(e)||i.push(e)},e.off=function(t,e){var i=this._eventListeners[t];i.includes(e)&&i.splice(i.indexOf(e),1)},i(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){throw new Error("Enabled is read only")}}]),t}(),exports.TerraDrawArcGISMapsSDKAdapter=Et,exports.TerraDrawCircleMode=Yt,exports.TerraDrawExtend=ri,exports.TerraDrawFreehandMode=Ht,exports.TerraDrawGoogleMapsAdapter=d,exports.TerraDrawGreatCircleMode=re,exports.TerraDrawLeafletAdapter=h,exports.TerraDrawLineStringMode=se,exports.TerraDrawMapLibreGLAdapter=g,exports.TerraDrawMapboxGLAdapter=u,exports.TerraDrawOpenLayersAdapter=Mt,exports.TerraDrawPointMode=le,exports.TerraDrawPolygonMode=he,exports.TerraDrawRectangleMode=ue,exports.TerraDrawRenderMode=ge,exports.TerraDrawSelectMode=Be,exports.ValidateMaxSizeSquareMeters=function(t,e){return ti(t)<e},exports.ValidateMinSizeSquareMeters=function(t,e){return ti(t)>e};
|
|
1
|
+
function t(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}function e(e,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,t(r.key),r)}}function i(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(){return n=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},n.apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function s(t,e){void 0===e&&(e=9);var i=Math.pow(10,e);return Math.round(t*i)/i}var a=function(t,e){var i=e.x-t.x,n=e.y-t.y;return Math.sqrt(n*n+i*i)},l=function(t){var e=this,i=t.name,n=t.callback,r=t.unregister,o=t.register;this.name=void 0,this.callback=void 0,this.registered=!1,this.register=void 0,this.unregister=void 0,this.name=i,this.register=function(){e.registered||(e.registered=!0,o(n))},this.unregister=function(){e.register&&(e.registered=!1,r(n))},this.callback=n},c=/*#__PURE__*/function(){function t(t){this._minPixelDragDistance=void 0,this._minPixelDragDistanceDrawing=void 0,this._minPixelDragDistanceSelecting=void 0,this._lastDrawEvent=void 0,this._coordinatePrecision=void 0,this._heldKeys=new Set,this._listeners=[],this._dragState="not-dragging",this._currentModeCallbacks=void 0,this._minPixelDragDistance="number"==typeof t.minPixelDragDistance?t.minPixelDragDistance:1,this._minPixelDragDistanceSelecting="number"==typeof t.minPixelDragDistanceSelecting?t.minPixelDragDistanceSelecting:1,this._minPixelDragDistanceDrawing="number"==typeof t.minPixelDragDistanceDrawing?t.minPixelDragDistanceDrawing:8,this._coordinatePrecision="number"==typeof t.coordinatePrecision?t.coordinatePrecision:9}var e=t.prototype;return e.getButton=function(t){return-1===t.button?"neither":0===t.button?"left":1===t.button?"middle":2===t.button?"right":"neither"},e.getMapElementXYPosition=function(t){var e=this.getMapEventElement().getBoundingClientRect();return{containerX:t.clientX-e.left,containerY:t.clientY-e.top}},e.getDrawEventFromEvent=function(t){var e=this.getLngLatFromEvent(t);if(!e)return null;var i=e.lng,n=e.lat,r=this.getMapElementXYPosition(t),o=r.containerX,a=r.containerY,l=this.getButton(t),c=Array.from(this._heldKeys);return{lng:s(i,this._coordinatePrecision),lat:s(n,this._coordinatePrecision),containerX:o,containerY:a,button:l,heldKeys:c}},e.register=function(t){this._currentModeCallbacks=t,this._listeners=this.getAdapterListeners(),this._listeners.forEach(function(t){t.register()})},e.getCoordinatePrecision=function(){return this._coordinatePrecision},e.getAdapterListeners=function(){var t=this;return[new l({name:"pointerdown",callback:function(e){if(t._currentModeCallbacks&&e.isPrimary){var i=t.getDrawEventFromEvent(e);i&&(t._dragState="pre-dragging",t._lastDrawEvent=i)}},register:function(e){t.getMapEventElement().addEventListener("pointerdown",e)},unregister:function(e){t.getMapEventElement().removeEventListener("pointerdown",e)}}),new l({name:"pointermove",callback:function(e){if(t._currentModeCallbacks&&e.isPrimary){e.preventDefault();var i=t.getDrawEventFromEvent(e);if(i)if("not-dragging"===t._dragState)t._currentModeCallbacks.onMouseMove(i),t._lastDrawEvent=i;else if("pre-dragging"===t._dragState){if(!t._lastDrawEvent)return;var n={x:t._lastDrawEvent.containerX,y:t._lastDrawEvent.containerY},r={x:i.containerX,y:i.containerY},o=t._currentModeCallbacks.getState(),s=a(n,r);if("drawing"===o?s<t._minPixelDragDistanceDrawing:"selecting"===o?s<t._minPixelDragDistanceSelecting:s<t._minPixelDragDistance)return;t._dragState="dragging",t._currentModeCallbacks.onDragStart(i,function(e){t.setDraggability.bind(t)(e)})}else"dragging"===t._dragState&&t._currentModeCallbacks.onDrag(i,function(e){t.setDraggability.bind(t)(e)})}},register:function(e){t.getMapEventElement().addEventListener("pointermove",e)},unregister:function(e){t.getMapEventElement().removeEventListener("pointermove",e)}}),new l({name:"contextmenu",callback:function(e){t._currentModeCallbacks&&e.preventDefault()},register:function(e){t.getMapEventElement().addEventListener("contextmenu",e)},unregister:function(e){t.getMapEventElement().removeEventListener("contextmenu",e)}}),new l({name:"pointerup",callback:function(e){if(t._currentModeCallbacks&&e.target===t.getMapEventElement()&&e.isPrimary){var i=t.getDrawEventFromEvent(e);i&&("dragging"===t._dragState?t._currentModeCallbacks.onDragEnd(i,function(e){t.setDraggability.bind(t)(e)}):"not-dragging"!==t._dragState&&"pre-dragging"!==t._dragState||t._currentModeCallbacks.onClick(i),t._dragState="not-dragging",t.setDraggability(!0))}},register:function(e){t.getMapEventElement().addEventListener("pointerup",e)},unregister:function(e){t.getMapEventElement().removeEventListener("pointerup",e)}}),new l({name:"keyup",callback:function(e){t._currentModeCallbacks&&(t._heldKeys.delete(e.key),t._currentModeCallbacks.onKeyUp({key:e.key,heldKeys:Array.from(t._heldKeys),preventDefault:function(){return e.preventDefault()}}))},register:function(e){t.getMapEventElement().addEventListener("keyup",e)},unregister:function(e){t.getMapEventElement().removeEventListener("keyup",e)}}),new l({name:"keydown",callback:function(e){t._currentModeCallbacks&&(t._heldKeys.add(e.key),t._currentModeCallbacks.onKeyDown({key:e.key,heldKeys:Array.from(t._heldKeys),preventDefault:function(){return e.preventDefault()}}))},register:function(e){t.getMapEventElement().addEventListener("keydown",e)},unregister:function(e){t.getMapEventElement().removeEventListener("keydown",e)}})]},e.unregister=function(){this._listeners.forEach(function(t){t.unregister()}),this.clear()},t}(),d=/*#__PURE__*/function(t){function e(e){var i;if((i=t.call(this,e)||this)._cursor=void 0,i._cursorStyleSheet=void 0,i._lib=void 0,i._map=void 0,i._overlay=void 0,i._clickEventListener=void 0,i._mouseMoveEventListener=void 0,i.renderedFeatureIds=new Set,i._lib=e.lib,i._map=e.map,!i._map.getDiv().id)throw new Error("Google Map container div requires and id to be set");return i._coordinatePrecision="number"==typeof e.coordinatePrecision?e.coordinatePrecision:9,i}r(e,t);var n=e.prototype;return n.circlePath=function(t,e,i){var n=2*i;return"M "+t+" "+e+" m -"+i+", 0 a "+i+","+i+" 0 1,0 "+n+",0 a "+i+","+i+" 0 1,0 -"+n+",0"},n.register=function(e){var i=this;t.prototype.register.call(this,e),this._overlay=new this._lib.OverlayView,this._overlay.draw=function(){},this._overlay.onAdd=function(){i._currentModeCallbacks&&i._currentModeCallbacks.onReady&&i._currentModeCallbacks.onReady()},this._overlay.setMap(this._map),this._clickEventListener=this._map.data.addListener("click",function(t){var e=i._listeners.find(function(t){return"click"===t.name});e&&e.callback(t)}),this._mouseMoveEventListener=this._map.data.addListener("mousemove",function(t){var e=i._listeners.find(function(t){return"mousemove"===t.name});e&&e.callback(t)})},n.unregister=function(){var e,i,n;t.prototype.unregister.call(this),null==(e=this._clickEventListener)||e.remove(),null==(i=this._mouseMoveEventListener)||i.remove(),null==(n=this._overlay)||n.setMap(null),this._overlay=void 0},n.getLngLatFromEvent=function(t){if(!this._overlay)throw new Error("cannot get overlay");var e=this._map.getBounds();if(!e)return null;var i=e.getNorthEast(),n=e.getSouthWest(),r=new this._lib.LatLngBounds(n,i),o=this._map.getDiv(),s=t.clientX-o.getBoundingClientRect().left,a=t.clientY-o.getBoundingClientRect().top,l=new this._lib.Point(s,a),c=this._overlay.getProjection();if(!c)return null;var d=c.fromContainerPixelToLatLng(l);return d&&r.contains(d)?{lng:d.lng(),lat:d.lat()}:null},n.getMapEventElement=function(){return this._map.getDiv().querySelector('div[style*="z-index: 3;"]')},n.project=function(t,e){if(!this._overlay)throw new Error("cannot get overlay");if(void 0===this._map.getBounds())throw new Error("cannot get bounds");var i=this._overlay.getProjection();if(void 0===i)throw new Error("cannot get projection");var n=i.fromLatLngToContainerPixel(new this._lib.LatLng(e,t));if(null===n)throw new Error("cannot project coordinates");return{x:n.x,y:n.y}},n.unproject=function(t,e){if(!this._overlay)throw new Error("cannot get overlay");var i=this._overlay.getProjection();if(void 0===i)throw new Error("cannot get projection");var n=i.fromContainerPixelToLatLng(new this._lib.Point(t,e));if(null===n)throw new Error("cannot unproject coordinates");return{lng:n.lng(),lat:n.lat()}},n.setCursor=function(t){if(t!==this._cursor){if(this._cursorStyleSheet&&(this._cursorStyleSheet.remove(),this._cursorStyleSheet=void 0),"unset"!==t){var e=this._map.getDiv(),i=document.querySelector("#"+e.id+" .gm-style > div");if(i){i.classList.add("terra-draw-google-maps");var n=document.createElement("style");n.innerHTML=".terra-draw-google-maps { cursor: "+t+" !important; }",document.getElementsByTagName("head")[0].appendChild(n),this._cursorStyleSheet=n}}this._cursor=t}},n.setDoubleClickToZoom=function(t){this._map.setOptions(t?{disableDoubleClickZoom:!1}:{disableDoubleClickZoom:!0})},n.setDraggability=function(t){this._map.setOptions({draggable:t})},n.render=function(t,e){var i=this;this._layers&&(t.deletedIds.forEach(function(t){var e=i._map.data.getFeatureById(t);e&&(i._map.data.remove(e),i.renderedFeatureIds.delete(t))}),t.updated.forEach(function(t){if(!t||!t.id)throw new Error("Feature is not valid");var e=i._map.data.getFeatureById(t.id);if(!e)throw new Error("Feature could not be found by Google Maps API");switch(e.forEachProperty(function(t,i){e.setProperty(i,void 0)}),Object.keys(t.properties).forEach(function(i){e.setProperty(i,t.properties[i])}),t.geometry.type){case"Point":var n=t.geometry.coordinates;e.setGeometry(new i._lib.Data.Point(new i._lib.LatLng(n[1],n[0])));break;case"LineString":for(var r=t.geometry.coordinates,o=[],s=0;s<r.length;s++){var a=r[s],l=new i._lib.LatLng(a[1],a[0]);o.push(l)}e.setGeometry(new i._lib.Data.LineString(o));break;case"Polygon":for(var c=t.geometry.coordinates,d=[],h=0;h<c.length;h++){for(var u=[],g=0;g<c[h].length;g++){var p=new i._lib.LatLng(c[h][g][1],c[h][g][0]);u.push(p)}d.push(u)}e.setGeometry(new i._lib.Data.Polygon(d))}}),t.created.forEach(function(t){i.renderedFeatureIds.add(t.id),i._map.data.addGeoJson(t)})),t.created.forEach(function(t){i.renderedFeatureIds.add(t.id)});var n={type:"FeatureCollection",features:[].concat(t.created)};this._map.data.addGeoJson(n),this._map.data.setStyle(function(t){var n=t.getProperty("mode"),r=t.getGeometry();if(!r)throw new Error("Google Maps geometry not found");var o=r.getType(),s={};t.forEachProperty(function(t,e){s[e]=t});var a=e[n]({type:"Feature",geometry:{type:o,coordinates:[]},properties:s});switch(o){case"Point":return{clickable:!1,icon:{path:i.circlePath(0,0,a.pointWidth),fillColor:a.pointColor,fillOpacity:1,strokeColor:a.pointOutlineColor,strokeWeight:a.pointOutlineWidth,rotation:0,scale:1}};case"LineString":return{strokeColor:a.lineStringColor,strokeWeight:a.lineStringWidth};case"Polygon":return{strokeColor:a.polygonOutlineColor,strokeWeight:a.polygonOutlineWidth,fillOpacity:a.polygonFillOpacity,fillColor:a.polygonFillColor}}throw Error("Unknown feature type")})},n.clearLayers=function(){var t=this;this._layers&&(this._map.data.forEach(function(e){var i=e.getId();t.renderedFeatureIds.has(i)&&t._map.data.remove(e)}),this.renderedFeatureIds=new Set)},n.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},n.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i(e,[{key:"_layers",get:function(){var t;return Boolean((null==(t=this.renderedFeatureIds)?void 0:t.size)>0)}}]),e}(c),h=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this)._lib=void 0,i._map=void 0,i._panes={},i._container=void 0,i._layers={},i._lib=e.lib,i._map=e.map,i._container=i._map.getContainer(),i}r(e,t);var i=e.prototype;return i.createPaneStyleSheet=function(t,e){var i=document.createElement("style");return i.innerHTML=".leaflet-"+t+" {z-index: "+e+";}",document.getElementsByTagName("head")[0].appendChild(i),this._map.createPane(t),i},i.clearPanes=function(){Object.values(this._panes).forEach(function(t){t&&t.remove()}),this._panes={}},i.clearLayers=function(){var t=this;Object.values(this._layers).forEach(function(e){t._map.removeLayer(e)}),this._layers={}},i.styleGeoJSONLayer=function(t){var e=this;return{pointToLayer:function(i,n){if(!i.properties)throw new Error("Feature has no properties");if("string"!=typeof i.properties.mode)throw new Error("Feature mode is not a string");var r=(0,t[i.properties.mode])(i),o=String(r.zIndex);return e._panes[o]||(e._panes[o]=e.createPaneStyleSheet(o,r.zIndex)),e._lib.circleMarker(n,{radius:r.pointWidth,stroke:r.pointOutlineWidth||!1,color:r.pointOutlineColor,weight:r.pointOutlineWidth,fillOpacity:.8,fillColor:r.pointColor,pane:o,interactive:!1})},style:function(i){if(!i||!i.properties)return{};var n=i,r=(0,t[n.properties.mode])(n),o=String(r.zIndex);return e._panes[o]||(e._panes[o]=e.createPaneStyleSheet(o,r.zIndex)),"LineString"===n.geometry.type?{interactive:!1,color:r.lineStringColor,weight:r.lineStringWidth,pane:o}:"Polygon"===n.geometry.type?{interactive:!1,fillOpacity:r.polygonFillOpacity,fillColor:r.polygonFillColor,weight:r.polygonOutlineWidth,stroke:!0,color:r.polygonFillColor,pane:o}:{}}}},i.getLngLatFromEvent=function(t){var e=this.getMapElementXYPosition(t),i={x:e.containerX,y:e.containerY};if(isNaN(i.x)||isNaN(i.y))return null;var n=this._map.containerPointToLatLng(i);return isNaN(n.lng)||isNaN(n.lat)?null:{lng:n.lng,lat:n.lat}},i.getMapEventElement=function(){return this._container},i.setDraggability=function(t){t?this._map.dragging.enable():this._map.dragging.disable()},i.project=function(t,e){var i=this._map.latLngToContainerPoint({lng:t,lat:e});return{x:i.x,y:i.y}},i.unproject=function(t,e){var i=this._map.containerPointToLatLng({x:t,y:e});return{lng:i.lng,lat:i.lat}},i.setCursor=function(t){"unset"===t?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=t},i.setDoubleClickToZoom=function(t){t?this._map.doubleClickZoom.enable():this._map.doubleClickZoom.disable()},i.render=function(t,e){var i=this;t.created.forEach(function(t){i._layers[t.id]=i._lib.geoJSON(t,i.styleGeoJSONLayer(e)),i._map.addLayer(i._layers[t.id])}),t.deletedIds.forEach(function(t){i._map.removeLayer(i._layers[t])}),t.updated.forEach(function(t){i._map.removeLayer(i._layers[t.id]),i._layers[t.id]=i._lib.geoJSON(t,i.styleGeoJSONLayer(e)),i._map.addLayer(i._layers[t.id])})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers(),this.clearPanes())},i.register=function(e){t.prototype.register.call(this,e),this._currentModeCallbacks&&this._currentModeCallbacks.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){return t.prototype.unregister.call(this)},e}(c),u=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this)._nextRender=void 0,i._map=void 0,i._container=void 0,i._rendered=!1,i.changedIds={deletion:!1,points:!1,linestrings:!1,polygons:!1,styling:!1},i._map=e.map,i._container=i._map.getContainer(),i}r(e,t);var i=e.prototype;return i.clearLayers=function(){var t=this;this._rendered&&(["point","linestring","polygon"].forEach(function(e){var i="td-"+e.toLowerCase();t._map.removeLayer(i),"polygon"===e&&t._map.removeLayer(i+"-outline"),t._map.removeSource(i)}),this._rendered=!1,this._nextRender&&(cancelAnimationFrame(this._nextRender),this._nextRender=void 0))},i._addGeoJSONSource=function(t,e){this._map.addSource(t,{type:"geojson",data:{type:"FeatureCollection",features:e},tolerance:0})},i._addFillLayer=function(t){return this._map.addLayer({id:t,source:t,type:"fill",paint:{"fill-color":["get","polygonFillColor"],"fill-opacity":["get","polygonFillOpacity"]}})},i._addFillOutlineLayer=function(t,e){var i=this._map.addLayer({id:t+"-outline",source:t,type:"line",paint:{"line-width":["get","polygonOutlineWidth"],"line-color":["get","polygonOutlineColor"]}});return e&&this._map.moveLayer(t,e),i},i._addLineLayer=function(t,e){var i=this._map.addLayer({id:t,source:t,type:"line",paint:{"line-width":["get","lineStringWidth"],"line-color":["get","lineStringColor"]}});return e&&this._map.moveLayer(t,e),i},i._addPointLayer=function(t,e){var i=this._map.addLayer({id:t,source:t,type:"circle",paint:{"circle-stroke-color":["get","pointOutlineColor"],"circle-stroke-width":["get","pointOutlineWidth"],"circle-radius":["get","pointWidth"],"circle-color":["get","pointColor"]}});return e&&this._map.moveLayer(t,e),i},i._addLayer=function(t,e,i){"Point"===e&&this._addPointLayer(t,i),"LineString"===e&&this._addLineLayer(t,i),"Polygon"===e&&(this._addFillLayer(t),this._addFillOutlineLayer(t,i))},i._addGeoJSONLayer=function(t,e){var i="td-"+t.toLowerCase();return this._addGeoJSONSource(i,e),this._addLayer(i,t),i},i._setGeoJSONLayerData=function(t,e){var i="td-"+t.toLowerCase();return this._map.getSource(i).setData({type:"FeatureCollection",features:e}),i},i.getEmptyGeometries=function(){return{points:[],linestrings:[],polygons:[]}},i.updateChangedIds=function(t){var e=this;[].concat(t.updated,t.created).forEach(function(t){"Point"===t.geometry.type?e.changedIds.points=!0:"LineString"===t.geometry.type?e.changedIds.linestrings=!0:"Polygon"===t.geometry.type&&(e.changedIds.polygons=!0)}),t.deletedIds.length>0&&(this.changedIds.deletion=!0),0===t.created.length&&0===t.updated.length&&0===t.deletedIds.length&&(this.changedIds.styling=!0)},i.getLngLatFromEvent=function(t){var e=this._container.getBoundingClientRect();return this.unproject(t.clientX-e.left,t.clientY-e.top)},i.getMapEventElement=function(){return this._map.getCanvas()},i.setDraggability=function(t){t?(this._map.dragRotate.enable(),this._map.dragPan.enable()):(this._map.dragRotate.disable(),this._map.dragPan.disable())},i.project=function(t,e){var i=this._map.project({lng:t,lat:e});return{x:i.x,y:i.y}},i.unproject=function(t,e){var i=this._map.unproject({x:t,y:e});return{lng:i.lng,lat:i.lat}},i.setCursor=function(t){var e=this._map.getCanvas();"unset"===t?e.style.removeProperty("cursor"):e.style.cursor=t},i.setDoubleClickToZoom=function(t){t?this._map.doubleClickZoom.enable():this._map.doubleClickZoom.disable()},i.render=function(t,e){var i=this;this.updateChangedIds(t),this._nextRender&&cancelAnimationFrame(this._nextRender),this._nextRender=requestAnimationFrame(function(){for(var n=[].concat(t.created,t.updated,t.unchanged),r=i.getEmptyGeometries(),o=function(t){var i=n[t];Object.keys(e).forEach(function(t){var n=i.properties;if(n.mode===t){var o=e[t](i);"Point"===i.geometry.type?(n.pointColor=o.pointColor,n.pointOutlineColor=o.pointOutlineColor,n.pointOutlineWidth=o.pointOutlineWidth,n.pointWidth=o.pointWidth,r.points.push(i)):"LineString"===i.geometry.type?(n.lineStringColor=o.lineStringColor,n.lineStringWidth=o.lineStringWidth,r.linestrings.push(i)):"Polygon"===i.geometry.type&&(n.polygonFillColor=o.polygonFillColor,n.polygonFillOpacity=o.polygonFillOpacity,n.polygonOutlineColor=o.polygonOutlineColor,n.polygonOutlineWidth=o.polygonOutlineWidth,r.polygons.push(i))}})},s=0;s<n.length;s++)o(s);var a=r.points,l=r.linestrings,c=r.polygons;if(i._rendered){var d,h=i.changedIds.deletion||i.changedIds.styling,u=h||i.changedIds.linestrings,g=h||i.changedIds.polygons;(h||i.changedIds.points)&&(d=i._setGeoJSONLayerData("Point",a)),u&&i._setGeoJSONLayerData("LineString",l),g&&i._setGeoJSONLayerData("Polygon",c),d&&i._map.moveLayer(d)}else{var p=i._addGeoJSONLayer("Point",a);i._addGeoJSONLayer("LineString",l),i._addGeoJSONLayer("Polygon",c),i._rendered=!0,p&&i._map.moveLayer(p)}i.changedIds={points:!1,linestrings:!1,polygons:!1,deletion:!1,styling:!1}})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){return t.prototype.unregister.call(this)},i.register=function(e){t.prototype.register.call(this,e),this._currentModeCallbacks&&this._currentModeCallbacks.onReady&&this._currentModeCallbacks.onReady()},e}(c),g=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this).mapboxglAdapter=void 0,i.mapboxglAdapter=new u(e),i}r(e,t);var i=e.prototype;return i.register=function(t){this.mapboxglAdapter.register(t)},i.unregister=function(){this.mapboxglAdapter.unregister()},i.getCoordinatePrecision=function(){return this.mapboxglAdapter.getCoordinatePrecision()},i.getLngLatFromEvent=function(t){return this.mapboxglAdapter.getLngLatFromEvent(t)},i.getMapEventElement=function(){return this.mapboxglAdapter.getMapEventElement()},i.setDraggability=function(t){this.mapboxglAdapter.setDraggability(t)},i.project=function(t,e){return this.mapboxglAdapter.project(t,e)},i.unproject=function(t,e){return this.mapboxglAdapter.unproject(t,e)},i.setCursor=function(t){this.mapboxglAdapter.setCursor(t)},i.setDoubleClickToZoom=function(t){this.mapboxglAdapter.setDoubleClickToZoom(t)},i.render=function(t,e){this.mapboxglAdapter.render(t,e)},i.clear=function(){this.mapboxglAdapter.clear()},e}(c);function p(){throw new Error("Unimplemented abstract method.")}let f=0;function y(t,e){return Array.isArray(t)?t:(void 0===e?e=[t,t]:(e[0]=t,e[1]=t),e)}class v{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=y(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){const t=this.getScale();return new v({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return p()}getImage(t){return p()}getHitDetectionImage(){return p()}getPixelRatio(t){return 1}getImageState(){return p()}getImageSize(){return p()}getOrigin(){return p()}getSize(){return p()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=y(t)}listenImageChange(t){p()}load(){p()}unlistenImageChange(t){p()}}var m=v;const _={1:"The view center is not defined",2:"The view resolution is not defined",3:"The view rotation is not defined",4:"`image` and `src` cannot be provided at the same time",5:"`imgSize` must be set when `image` is provided",7:"`format` must be set when `url` is set",8:"Unknown `serverType` configured",9:"`url` must be configured or set using `#setUrl()`",10:"The default `geometryFunction` can only handle `Point` geometries",11:"`options.featureTypes` must be an Array",12:"`options.geometryName` must also be provided when `options.bbox` is set",13:"Invalid corner",14:"Invalid color",15:"Tried to get a value for a key that does not exist in the cache",16:"Tried to set a value for a key that is used already",17:"`resolutions` must be sorted in descending order",18:"Either `origin` or `origins` must be configured, never both",19:"Number of `tileSizes` and `resolutions` must be equal",20:"Number of `origins` and `resolutions` must be equal",22:"Either `tileSize` or `tileSizes` must be configured, never both",24:"Invalid extent or geometry provided as `geometry`",25:"Cannot fit empty extent provided as `geometry`",26:"Features must have an id set",27:"Features must have an id set",28:'`renderMode` must be `"hybrid"` or `"vector"`',30:"The passed `feature` was already added to the source",31:"Tried to enqueue an `element` that was already added to the queue",32:"Transformation matrix cannot be inverted",33:"Invalid units",34:"Invalid geometry layout",36:"Unknown SRS type",37:"Unknown geometry type found",38:"`styleMapValue` has an unknown type",39:"Unknown geometry type",40:"Expected `feature` to have a geometry",41:"Expected an `ol/style/Style` or an array of `ol/style/Style.js`",42:"Question unknown, the answer is 42",43:"Expected `layers` to be an array or a `Collection`",47:"Expected `controls` to be an array or an `ol/Collection`",48:"Expected `interactions` to be an array or an `ol/Collection`",49:"Expected `overlays` to be an array or an `ol/Collection`",50:"`options.featureTypes` should be an Array",51:"Either `url` or `tileJSON` options must be provided",52:"Unknown `serverType` configured",53:"Unknown `tierSizeCalculation` configured",55:"The {-y} placeholder requires a tile grid with extent",56:"mapBrowserEvent must originate from a pointer event",57:"At least 2 conditions are required",59:"Invalid command found in the PBF",60:"Missing or invalid `size`",61:"Cannot determine IIIF Image API version from provided image information JSON",62:"A `WebGLArrayBuffer` must either be of type `ELEMENT_ARRAY_BUFFER` or `ARRAY_BUFFER`",64:"Layer opacity must be a number",66:"`forEachFeatureAtCoordinate` cannot be used on a WebGL layer if the hit detection logic has not been enabled. This is done by providing adequate shaders using the `hitVertexShader` and `hitFragmentShader` properties of `WebGLPointsLayerRenderer`",67:"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both",68:"A VectorTile source can only be rendered if it has a projection compatible with the view projection"};class C extends Error{constructor(t){const e=_[t];super(e),this.code=t,this.name="AssertionError",this.message=e}}var P=C;function x(t,e,i){return Math.min(Math.max(t,e),i)}const S=/^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i,b=/^([a-z]*)$|^hsla?\(.*\)$/i,w=function(){const t={};let e=0;return function(i){let n;if(t.hasOwnProperty(i))n=t[i];else{if(e>=1024){let i=0;for(const n in t)3&i++||(delete t[n],--e)}n=function(t){let e,i,n,r,o;if(b.exec(t)&&(t=function(t){const e=document.createElement("div");if(e.style.color=t,""!==e.style.color){document.body.appendChild(e);const t=getComputedStyle(e).color;return document.body.removeChild(e),t}return""}(t)),S.exec(t)){const s=t.length-1;let a;a=s<=4?1:2;const l=4===s||8===s;e=parseInt(t.substr(1+0*a,a),16),i=parseInt(t.substr(1+1*a,a),16),n=parseInt(t.substr(1+2*a,a),16),r=l?parseInt(t.substr(1+3*a,a),16):255,1==a&&(e=(e<<4)+e,i=(i<<4)+i,n=(n<<4)+n,l&&(r=(r<<4)+r)),o=[e,i,n,r/255]}else t.startsWith("rgba(")?(o=t.slice(5,-1).split(",").map(Number),M(o)):t.startsWith("rgb(")?(o=t.slice(4,-1).split(",").map(Number),o.push(1),M(o)):function(t,e){throw new P(14)}();return o}(i),t[i]=n,++e}return n}}();function M(t){return t[0]=x(t[0]+.5|0,0,255),t[1]=x(t[1]+.5|0,0,255),t[2]=x(t[2]+.5|0,0,255),t[3]=x(t[3],0,1),t}function E(t){return Array.isArray(t)?function(t){let e=t[0];e!=(0|e)&&(e=e+.5|0);let i=t[1];i!=(0|i)&&(i=i+.5|0);let n=t[2];return n!=(0|n)&&(n=n+.5|0),"rgba("+e+","+i+","+n+","+(void 0===t[3]?1:Math.round(100*t[3])/100)+")"}(t):t}const I="undefined"!=typeof navigator&&void 0!==navigator.userAgent?navigator.userAgent.toLowerCase():"";I.includes("firefox"),I.includes("safari")&&!I.includes("chrom")&&(I.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(I)),I.includes("webkit")&&I.includes("edge"),I.includes("macintosh");const D="undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof OffscreenCanvas&&self instanceof WorkerGlobalScope;function k(t,e,i,n){let r;return r=i&&i.length?i.shift():D?new OffscreenCanvas(t||300,e||300):document.createElement("canvas"),t&&(r.width=t),e&&(r.height=e),r.getContext("2d",n)}!function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch(t){}}();var F=class{constructor(t){this.type=t,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}},O=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}};function L(){}function W(t){for(const e in t)delete t[e]}var B=class extends O{constructor(t){super(),this.eventTarget_=t,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(t,e){if(!t||!e)return;const i=this.listeners_||(this.listeners_={}),n=i[t]||(i[t]=[]);n.includes(e)||n.push(e)}dispatchEvent(t){const e="string"==typeof t,i=e?t:t.type,n=this.listeners_&&this.listeners_[i];if(!n)return;const r=e?new F(t):t;r.target||(r.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),s=this.pendingRemovals_||(this.pendingRemovals_={});let a;i in o||(o[i]=0,s[i]=0),++o[i];for(let t=0,e=n.length;t<e;++t)if(a="handleEvent"in n[t]?n[t].handleEvent(r):n[t].call(this,r),!1===a||r.propagationStopped){a=!1;break}if(0==--o[i]){let t=s[i];for(delete s[i];t--;)this.removeEventListener(i,L);delete o[i]}return a}disposeInternal(){this.listeners_&&W(this.listeners_)}getListeners(t){return this.listeners_&&this.listeners_[t]||void 0}hasListener(t){return!!this.listeners_&&(t?t in this.listeners_:Object.keys(this.listeners_).length>0)}removeEventListener(t,e){const i=this.listeners_&&this.listeners_[t];if(i){const n=i.indexOf(e);-1!==n&&(this.pendingRemovals_&&t in this.pendingRemovals_?(i[n]=L,++this.pendingRemovals_[t]):(i.splice(n,1),0===i.length&&delete this.listeners_[t]))}}};function A(t,e,i,n,r){if(n&&n!==t&&(i=i.bind(n)),r){const n=i;i=function(){t.removeEventListener(e,i),n.apply(this,arguments)}}const o={target:t,type:e,listener:i};return t.addEventListener(e,i),o}function G(t,e,i,n){return A(t,e,i,n,!0)}function j(t){t&&t.target&&(t.target.removeEventListener(t.type,t.listener),W(t))}var R=class extends B{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent("change")}getRevision(){return this.revision_}onInternal(t,e){if(Array.isArray(t)){const i=t.length,n=new Array(i);for(let r=0;r<i;++r)n[r]=A(this,t[r],e);return n}return A(this,t,e)}onceInternal(t,e){let i;if(Array.isArray(t)){const n=t.length;i=new Array(n);for(let r=0;r<n;++r)i[r]=G(this,t[r],e)}else i=G(this,t,e);return e.ol_key=i,i}unInternal(t,e){const i=e.ol_key;if(i)!function(t){if(Array.isArray(t))for(let e=0,i=t.length;e<i;++e)j(t[e]);else j(t)}(i);else if(Array.isArray(t))for(let i=0,n=t.length;i<n;++i)this.removeEventListener(t[i],e);else this.removeEventListener(t,e)}};class N extends F{constructor(t,e,i){super(t),this.key=e,this.oldValue=i}}const V="#000",T="round";new class extends R{constructor(t){super(),this.ol_uid||(this.ol_uid=String(++f)),this.values_=null,void 0!==t&&this.setProperties(t)}get(t){let e;return this.values_&&this.values_.hasOwnProperty(t)&&(e=this.values_[t]),e}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}hasProperties(){return!!this.values_}notify(t,e){let i;i=`change:${t}`,this.hasListener(i)&&this.dispatchEvent(new N(i,t,e)),i="propertychange",this.hasListener(i)&&this.dispatchEvent(new N(i,t,e))}addChangeListener(t,e){this.addEventListener(`change:${t}`,e)}removeChangeListener(t,e){this.removeEventListener(`change:${t}`,e)}set(t,e,i){const n=this.values_||(this.values_={});if(i)n[t]=e;else{const i=n[t];n[t]=e,i!==e&&this.notify(t,i)}}setProperties(t,e){for(const i in t)this.set(i,t[i],e)}applyProperties(t){t.values_&&Object.assign(this.values_||(this.values_={}),t.values_)}unset(t,e){if(this.values_&&t in this.values_){const i=this.values_[t];delete this.values_[t],function(t){let e;for(e in t)return!1;return!e}(this.values_)&&(this.values_=null),e||this.notify(t,i)}}};class z extends m{constructor(t){super({opacity:1,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,rotation:void 0!==t.rotation?t.rotation:0,scale:void 0!==t.scale?t.scale:1,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode}),this.canvas_=void 0,this.hitDetectionCanvas_=null,this.fill_=void 0!==t.fill?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius_=void 0!==t.radius?t.radius:t.radius1,this.radius2_=t.radius2,this.angle_=void 0!==t.angle?t.angle:0,this.stroke_=void 0!==t.stroke?t.stroke:null,this.size_=null,this.renderOptions_=null,this.render()}clone(){const t=this.getScale(),e=new z({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}getAnchor(){const t=this.size_;if(!t)return null;const e=this.getDisplacement(),i=this.getScaleArray();return[t[0]/2-e[0]/i[0],t[1]/2+e[1]/i[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||this.createHitDetectionCanvas_(this.renderOptions_),this.hitDetectionCanvas_}getImage(t){let e=this.canvas_[t];if(!e){const i=this.renderOptions_,n=k(i.size*t,i.size*t);this.draw_(i,n,t),e=n.canvas,this.canvas_[t]=e}return e}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return 2}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius_}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,e,i){if(0===e||Infinity===this.points_||"bevel"!==t&&"miter"!==t)return e;let n=this.radius_,r=void 0===this.radius2_?n:this.radius2_;if(n<r){const t=n;n=r,r=t}const o=2*Math.PI/(void 0===this.radius2_?this.points_:2*this.points_),s=r*Math.sin(o),a=n-Math.sqrt(r*r-s*s),l=Math.sqrt(s*s+a*a),c=l/s;if("miter"===t&&c<=i)return c*e;const d=e/2/c,h=e/2*(a/l),u=Math.sqrt((n+d)*(n+d)+h*h)-n;if(void 0===this.radius2_||"bevel"===t)return 2*u;const g=n*Math.sin(o),p=r-Math.sqrt(n*n-g*g),f=Math.sqrt(g*g+p*p)/g;return f<=i?2*Math.max(u,f*e/2-r-n):2*u}createRenderOptions(){let t,e=T,i=0,n=null,r=0,o=0;this.stroke_&&(t=this.stroke_.getColor(),null===t&&(t="#000"),t=E(t),o=this.stroke_.getWidth(),void 0===o&&(o=1),n=this.stroke_.getLineDash(),r=this.stroke_.getLineDashOffset(),e=this.stroke_.getLineJoin(),void 0===e&&(e=T),i=this.stroke_.getMiterLimit(),void 0===i&&(i=10));const s=this.calculateLineJoinSize_(e,o,i),a=Math.max(this.radius_,this.radius2_||0);return{strokeStyle:t,strokeWidth:o,size:Math.ceil(2*a+s),lineDash:n,lineDashOffset:r,lineJoin:e,miterLimit:i}}render(){this.renderOptions_=this.createRenderOptions();const t=this.renderOptions_.size;this.canvas_={},this.size_=[t,t]}draw_(t,e,i){if(e.scale(i,i),e.translate(t.size/2,t.size/2),this.createPath_(e),this.fill_){let t=this.fill_.getColor();null===t&&(t=V),e.fillStyle=E(t),e.fill()}this.stroke_&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}createHitDetectionCanvas_(t){if(this.fill_){let e=this.fill_.getColor(),i=0;if("string"==typeof e&&(e=function(t){return Array.isArray(t)?t:w(t)}(e)),null===e?i=1:Array.isArray(e)&&(i=4===e.length?e[3]:1),0===i){const e=k(t.size,t.size);this.hitDetectionCanvas_=e.canvas,this.drawHitDetectionCanvas_(t,e)}}this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.getImage(1))}createPath_(t){let e=this.points_;const i=this.radius_;if(Infinity===e)t.arc(0,0,i,0,2*Math.PI);else{const n=void 0===this.radius2_?i:this.radius2_;void 0!==this.radius2_&&(e*=2);const r=this.angle_-Math.PI/2,o=2*Math.PI/e;for(let s=0;s<e;s++){const e=r+s*o,a=s%2==0?i:n;t.lineTo(a*Math.cos(e),a*Math.sin(e))}t.closePath()}}drawHitDetectionCanvas_(t,e){e.translate(t.size/2,t.size/2),this.createPath_(e),e.fillStyle=V,e.fill(),this.stroke_&&(e.strokeStyle=t.strokeStyle,e.lineWidth=t.strokeWidth,t.lineDash&&(e.setLineDash(t.lineDash),e.lineDashOffset=t.lineDashOffset),e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit,e.stroke())}}var U=z;class X extends U{constructor(t){super({points:Infinity,fill:(t=t||{radius:5}).fill,radius:t.radius,stroke:t.stroke,scale:void 0!==t.scale?t.scale:1,rotation:void 0!==t.rotation?t.rotation:0,rotateWithView:void 0!==t.rotateWithView&&t.rotateWithView,displacement:void 0!==t.displacement?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){const t=this.getScale(),e=new X({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return e.setOpacity(this.getOpacity()),e}setRadius(t){this.radius_=t,this.render()}}var Y=X;class H{constructor(t){this.color_=void 0!==(t=t||{}).color?t.color:null}clone(){const t=this.getColor();return new H({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){this.color_=t}}var K=H;class J{constructor(t){this.color_=void 0!==(t=t||{}).color?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=void 0!==t.lineDash?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){const t=this.getColor();return new J({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}}var q=J;class Z{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=$,void 0!==t.geometry&&this.setGeometry(t.geometry),this.fill_=void 0!==t.fill?t.fill:null,this.image_=void 0!==t.image?t.image:null,this.renderer_=void 0!==t.renderer?t.renderer:null,this.hitDetectionRenderer_=void 0!==t.hitDetectionRenderer?t.hitDetectionRenderer:null,this.stroke_=void 0!==t.stroke?t.stroke:null,this.text_=void 0!==t.text?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&"object"==typeof t&&(t=t.clone()),new Z({geometry:t,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer(),stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){"function"==typeof t?this.geometryFunction_=t:"string"==typeof t?this.geometryFunction_=function(e){return e.get(t)}:t?void 0!==t&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=$,this.geometry_=t}setZIndex(t){this.zIndex_=t}}function $(t){return t.getGeometry()}var Q=Z;const tt={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var et=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||tt[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!(!t||!this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!(!this.global_||!t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(t){this.getPointResolutionFunc_=t}getPointResolutionFunc(){return this.getPointResolutionFunc_}};const it=6378137,nt=Math.PI*it,rt=[-nt,-nt,nt,nt],ot=[-180,-85,180,85],st=it*Math.log(Math.tan(Math.PI/2));class at extends et{constructor(t){super({code:t,units:"m",extent:rt,global:!0,worldExtent:ot,getPointResolution:function(t,e){return t/Math.cosh(e[1]/it)}})}}const lt=[new at("EPSG:3857"),new at("EPSG:102100"),new at("EPSG:102113"),new at("EPSG:900913"),new at("http://www.opengis.net/def/crs/EPSG/0/3857"),new at("http://www.opengis.net/gml/srs/epsg.xml#3857")],ct=[-180,-90,180,90],dt=6378137*Math.PI/180;class ht extends et{constructor(t,e){super({code:t,units:"degrees",extent:ct,axisOrientation:e,global:!0,metersPerUnit:dt,worldExtent:ct})}}const ut=[new ht("CRS:84"),new ht("EPSG:4326","neu"),new ht("urn:ogc:def:crs:OGC:1.3:CRS84"),new ht("urn:ogc:def:crs:OGC:2:84"),new ht("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new ht("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new ht("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];let gt={},pt={};function ft(t,e,i){const n=t.getCode(),r=e.getCode();n in pt||(pt[n]={}),pt[n][r]=i}function yt(t,e,i){if(void 0!==e)for(let i=0,n=t.length;i<n;++i)e[i]=t[i];else e=t.slice();return e}function vt(t,e,i){if(void 0!==e&&t!==e){for(let i=0,n=t.length;i<n;++i)e[i]=t[i];t=e}return t}function mt(t){!function(t,e){gt[t]=e}(t.getCode(),t),ft(t,t,yt)}function _t(t){return"string"==typeof t?gt[e=t]||gt[e.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null:t||null;var e}function Ct(t){!function(t){t.forEach(mt)}(t),t.forEach(function(e){t.forEach(function(t){e!==t&&ft(e,t,yt)})})}function Pt(t,e,i){const n=function(t,e){return function(t,e){let i=function(t,e){let i;return t in pt&&e in pt[t]&&(i=pt[t][e]),i}(t.getCode(),e.getCode());return i||(i=vt),i}(_t(t),_t(e))}(e,i);return n(t,void 0,t.length)}var xt,St,bt;Ct(lt),Ct(ut),xt=lt,St=function(t,e,i){const n=t.length;i=i>1?i:2,void 0===e&&(e=i>2?t.slice():new Array(n));for(let r=0;r<n;r+=i){e[r]=nt*t[r]/180;let i=it*Math.log(Math.tan(Math.PI*(+t[r+1]+90)/360));i>st?i=st:i<-st&&(i=-st),e[r+1]=i}return e},bt=function(t,e,i){const n=t.length;i=i>1?i:2,void 0===e&&(e=i>2?t.slice():new Array(n));for(let r=0;r<n;r+=i)e[r]=180*t[r]/nt,e[r+1]=360*Math.atan(Math.exp(t[r+1]/it))/Math.PI-90;return e},ut.forEach(function(t){xt.forEach(function(e){ft(t,e,St),ft(e,t,bt)})});var wt,Mt=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).stylingFunction=function(){return{}},i._lib=void 0,i._map=void 0,i._container=void 0,i._projection="EPSG:3857",i._vectorSource=void 0,i._geoJSONReader=void 0,i._map=e.map,i._lib=e.lib,i._geoJSONReader=new i._lib.GeoJSON,i._container=i._map.getViewport(),i._container.setAttribute("tabindex","0");var n=new i._lib.VectorSource({features:[]});i._vectorSource=n;var r=new i._lib.VectorLayer({source:n,style:function(t){return i.getStyles(t,i.stylingFunction())}});return i._map.addLayer(r),i}r(e,t);var i=e.prototype;return i.hexToRGB=function(t){return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16)}},i.getStyles=function(t,e){var i=this,n=t.getGeometry();if(n)return{Point:function(t){var n=t.getProperties(),r=e[n.mode]({type:"Feature",geometry:{type:"Point",coordinates:[]},properties:n});return new i._lib.Style({image:new Y({radius:r.pointWidth,fill:new K({color:r.pointColor}),stroke:new q({color:r.pointOutlineColor,width:r.pointOutlineWidth})})})},LineString:function(t){var n=t.getProperties(),r=e[n.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:n});return new i._lib.Style({stroke:new i._lib.Stroke({color:r.lineStringColor,width:r.lineStringWidth})})},Polygon:function(t){var n=t.getProperties(),r=e[n.mode]({type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:n}),o=i.hexToRGB(r.polygonFillColor),s=o.r,a=o.g,l=o.b;return new Q({stroke:new q({color:r.polygonOutlineColor,width:r.polygonOutlineWidth}),fill:new K({color:"rgba("+s+","+a+","+l+","+r.polygonFillOpacity+")"})})}}[n.getType()](t)},i.clearLayers=function(){this._vectorSource&&this._vectorSource.clear()},i.addFeature=function(t){if(!this._vectorSource||!this._geoJSONReader)throw new Error("Vector Source not initalised");var e=this._geoJSONReader.readFeature(t,{featureProjection:this._projection});this._vectorSource.addFeature(e)},i.removeFeature=function(t){if(!this._vectorSource)throw new Error("Vector Source not initalised");var e=this._vectorSource.getFeatureById(t);e&&this._vectorSource.removeFeature(e)},i.getLngLatFromEvent=function(t){var e=this.getMapElementXYPosition(t),i=e.containerX,n=e.containerY;try{return this.unproject(i,n)}catch(t){return null}},i.getMapEventElement=function(){var t=this._container.querySelectorAll("canvas");if(t.length>1)throw Error("Terra Draw currently only supports 1 canvas with OpenLayers");return t[0]},i.setDraggability=function(t){this._map.getInteractions().forEach(function(e){"DragPan"===e.constructor.name&&e.setActive(t)})},i.project=function(t,e){var i=this._map.getPixelFromCoordinate(Pt([t,e],"EPSG:4326","EPSG:3857"));return{x:i[0],y:i[1]}},i.unproject=function(t,e){var i=function(t,e){const i=Pt(t,"EPSG:3857","EPSG:4326"),n=i[0];return(n<-180||n>180)&&(i[0]=function(t,e){const i=t%360;return 360*i<0?i+360:i}(n+180)-180),i}(this._map.getCoordinateFromPixel([t,e]));return{lng:i[0],lat:i[1]}},i.setCursor=function(t){"unset"===t?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=t},i.setDoubleClickToZoom=function(t){this._map.getInteractions().forEach(function(e){"DoubleClickZoom"===e.constructor.name&&e.setActive(t)})},i.render=function(t,e){var i=this;if(this.stylingFunction=function(){return e},!this._vectorSource)throw new Error("Vector Layer source has disappeared");t.deletedIds.forEach(function(t){i.removeFeature(t)}),t.updated.forEach(function(t){i.removeFeature(t.id),i.addFeature(t)}),t.created.forEach(function(t){i.addFeature(t)})},i.clear=function(){this._currentModeCallbacks&&(this._currentModeCallbacks.onClear(),this.clearLayers())},i.register=function(e){t.prototype.register.call(this,e),this._currentModeCallbacks&&this._currentModeCallbacks.onReady&&this._currentModeCallbacks.onReady()},i.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i.unregister=function(){return t.prototype.unregister.call(this)},e}(c),Et=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this)._lib=void 0,i._mapView=void 0,i._container=void 0,i._featureIdAttributeName="__tdId",i._featureLayerName="__terraDrawFeatures",i._featureLayer=void 0,i._dragEnabled=!0,i._zoomEnabled=!0,i._dragHandler=void 0,i._doubleClickHandler=void 0,i._mapView=e.map,i._lib=e.lib,i._container=i._mapView.container,i._featureLayer=new i._lib.GraphicsLayer({id:i._featureLayerName}),i._mapView.map.add(i._featureLayer),i}r(e,t);var i=e.prototype;return i.register=function(e){var i=this;t.prototype.register.call(this,e),this._dragHandler=this._mapView.on("drag",function(t){i._dragEnabled||t.stopPropagation()}),this._doubleClickHandler=this._mapView.on("double-click",function(t){i._zoomEnabled||t.stopPropagation()}),this._currentModeCallbacks&&this._currentModeCallbacks.onReady&&this._currentModeCallbacks.onReady()},i.unregister=function(){t.prototype.unregister.call(this),this._dragHandler&&this._dragHandler.remove(),this._doubleClickHandler&&this._doubleClickHandler.remove()},i.getCoordinatePrecision=function(){return t.prototype.getCoordinatePrecision.call(this)},i.getLngLatFromEvent=function(t){var e=this.getMapElementXYPosition(t);return this.unproject(e.containerX,e.containerY)},i.getMapEventElement=function(){return this._container.querySelector(".esri-view-surface")},i.setDraggability=function(t){this._dragEnabled=t},i.project=function(t,e){var i=new this._lib.Point({longitude:t,latitude:e}),n=this._mapView.toScreen(i);return{x:n.x,y:n.y}},i.unproject=function(t,e){var i=this._mapView.toMap({x:t,y:e});return{lng:i.longitude,lat:i.latitude}},i.setCursor=function(t){"unset"===t?this.getMapEventElement().style.removeProperty("cursor"):this.getMapEventElement().style.cursor=t},i.setDoubleClickToZoom=function(t){this._zoomEnabled=t},i.render=function(t,e){var i=this;t.created.forEach(function(t){i.addFeature(t,e)}),t.updated.forEach(function(t){i.removeFeatureById(t.id),i.addFeature(t,e)}),t.deletedIds.forEach(function(t){i.removeFeatureById(t)})},i.clear=function(){this._featureLayer.graphics.removeAll()},i.removeFeatureById=function(t){var e=this,i=this._featureLayer.graphics.find(function(i){return i.attributes[e._featureIdAttributeName]===t});this._featureLayer.remove(i)},i.addFeature=function(t,e){var i,n=t.geometry,r=n.coordinates,o=n.type,s=e[t.properties.mode](t),a=void 0,l=void 0;switch(o){case"Point":l=new this._lib.Point({latitude:r[1],longitude:r[0]}),a=new this._lib.SimpleMarkerSymbol({color:this.getColorFromHex(s.pointColor),size:2*s.pointWidth+"px",outline:{color:this.getColorFromHex(s.pointOutlineColor),width:s.pointOutlineWidth+"px"}});break;case"LineString":l=new this._lib.Polyline({paths:[r]}),a=new this._lib.SimpleLineSymbol({color:this.getColorFromHex(s.lineStringColor),width:s.lineStringWidth+"px"});break;case"Polygon":l=new this._lib.Polygon({rings:r}),a=new this._lib.SimpleFillSymbol({color:this.getColorFromHex(s.polygonFillColor,s.polygonFillOpacity),outline:{color:this.getColorFromHex(s.polygonOutlineColor),width:s.polygonOutlineWidth+"px"}})}var c=new this._lib.Graphic({geometry:l,symbol:a,attributes:(i={},i[this._featureIdAttributeName]=t.id,i)});"Point"===o?this._featureLayer.graphics.add(c):this._featureLayer.graphics.add(c,0)},i.getColorFromHex=function(t,e){var i=this._lib.Color.fromHex(t);return e&&(i.a=e),i},e}(c),It="selected",Dt="midPoint",kt="closingPoint";function Ft(t){return Boolean(t&&"object"==typeof t&&null!==t&&!Array.isArray(t))}function Ot(t){if(!function(t){return"number"==typeof t&&!isNaN(new Date(t).valueOf())}(t))throw new Error("updatedAt and createdAt are not valid timestamps");return!0}!function(t){t.Drawing="drawing",t.Select="select",t.Static="static",t.Render="render"}(wt||(wt={}));var Lt=/*#__PURE__*/function(){var t=e.prototype;function e(t){this._state=void 0,this._styles=void 0,this.behaviors=[],this.pointerDistance=void 0,this.coordinatePrecision=void 0,this.onStyleChange=void 0,this.store=void 0,this.setDoubleClickToZoom=void 0,this.unproject=void 0,this.project=void 0,this.setCursor=void 0,this.type=wt.Drawing,this.mode="base",this._state="unregistered",this._styles=t&&t.styles?n({},t.styles):{},this.pointerDistance=t&&t.pointerDistance||40}return t.registerBehaviors=function(t){},t.setDrawing=function(){if("started"!==this._state)throw new Error("Mode must be unregistered or stopped to start");this._state="drawing"},t.setStarted=function(){if("stopped"!==this._state&&"registered"!==this._state&&"drawing"!==this._state&&"selecting"!==this._state)throw new Error("Mode must be unregistered or stopped to start");this._state="started",this.setDoubleClickToZoom(!1)},t.setStopped=function(){if("started"!==this._state)throw new Error("Mode must be started to be stopped");this._state="stopped",this.setDoubleClickToZoom(!0)},t.register=function(t){if("unregistered"!==this._state)throw new Error("Can not register unless mode is unregistered");this._state="registered",this.store=t.store,this.store.registerOnChange(t.onChange),this.setDoubleClickToZoom=t.setDoubleClickToZoom,this.project=t.project,this.unproject=t.unproject,this.onSelect=t.onSelect,this.onDeselect=t.onDeselect,this.setCursor=t.setCursor,this.onStyleChange=t.onChange,this.onFinish=t.onFinish,this.coordinatePrecision=t.coordinatePrecision,this.registerBehaviors({mode:t.mode,store:this.store,project:this.project,unproject:this.unproject,pointerDistance:this.pointerDistance,coordinatePrecision:t.coordinatePrecision})},t.validateFeature=function(t){if("unregistered"===this._state)throw new Error("Mode must be registered");return function(t,e){var i;if(Ft(t))if(null==t.id)i="Feature has no id";else if("string"!=typeof t.id&&"number"!=typeof t.id)i="Feature must be string or number as per GeoJSON spec";else if(e(t.id))if(Ft(t.geometry))if(Ft(t.properties))if("string"==typeof t.geometry.type&&["Polygon","LineString","Point"].includes(t.geometry.type))if(Array.isArray(t.geometry.coordinates)){if(!t.properties.mode||"string"!=typeof t.properties.mode)throw new Error("Feature does not have a valid mode property")}else i="Feature coordinates is not an array";else i="Feature is not Point, LineString or Polygon";else i="Feature has no properties";else i="Feature has no geometry";else i="Feature must match the id strategy (default is UUID4)";else i="Feature is not object";if(i)throw new Error(i);return!0}(t,this.store.idStrategy.isValidId)},t.onFinish=function(t){},t.onDeselect=function(t){},t.onSelect=function(t){},t.onKeyDown=function(t){},t.onKeyUp=function(t){},t.onMouseMove=function(t){},t.onClick=function(t){},t.onDragStart=function(t,e){},t.onDrag=function(t,e){},t.onDragEnd=function(t,e){},t.getHexColorStylingValue=function(t,e,i){return this.getStylingValue(t,e,i)},t.getNumericStylingValue=function(t,e,i){return this.getStylingValue(t,e,i)},t.getStylingValue=function(t,e,i){return void 0===t?e:"function"==typeof t?t(i):t},i(e,[{key:"state",get:function(){return this._state},set:function(t){throw new Error("Please use the modes lifecycle methods")}},{key:"styles",get:function(){return this._styles},set:function(t){if("object"!=typeof t)throw new Error("Styling must be an object");this.onStyleChange([],"styling"),this._styles=t}}]),e}(),Wt=/*#__PURE__*/function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).type=wt.Select,e}return r(e,t),e}(Lt);function Bt(t,e){var i=function(t){return t*Math.PI/180},n=i(t[1]),r=i(t[0]),o=i(e[1]),s=o-n,a=i(e[0])-r,l=Math.sin(s/2)*Math.sin(s/2)+Math.cos(n)*Math.cos(o)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l))*6371e3/1e3}var At=6371008.8;function Gt(t){return t%360*Math.PI/180}function jt(t){return t%(2*Math.PI)*180/Math.PI}function Rt(t){for(var e=t.center,i=t.radiusKilometers,n=t.coordinatePrecision,r=t.steps?t.steps:64,o=[],a=0;a<r;a++){var l=(d=i,h=-360*a/r,u=Gt((c=e)[0]),g=Gt(c[1]),p=Gt(h),f=function(t){return t/6371.0088}(d),y=Math.asin(Math.sin(g)*Math.cos(f)+Math.cos(g)*Math.sin(f)*Math.cos(p)),[jt(u+Math.atan2(Math.sin(p)*Math.sin(f)*Math.cos(g),Math.cos(f)-Math.sin(g)*Math.sin(y))),jt(y)]);o.push([s(l[0],n),s(l[1],n)])}var c,d,h,u,g,p,f,y;return o.push(o[0]),{type:"Feature",geometry:{type:"Polygon",coordinates:[o]},properties:{}}}function Nt(t){var e,i={epsilon:0};if("Polygon"===t.geometry.type)e=t.geometry.coordinates;else{if("LineString"!==t.geometry.type)throw new Error("Self intersects only accepts Polygons and LineStrings");e=[t.geometry.coordinates]}for(var n=[],r=0;r<e.length;r++)for(var o=0;o<e[r].length-1;o++)for(var s=0;s<e.length;s++)for(var a=0;a<e[s].length-1;a++)c(r,o,s,a);return n.length>0;function l(t){return t<0-i.epsilon||t>1+i.epsilon}function c(t,i,r,o){var s,a=e[t][i],c=e[t][i+1],d=e[r][o],h=e[r][o+1],u=function(t,e,i,n){if(Vt(t,i)||Vt(t,n)||Vt(e,i)||Vt(n,i))return null;var r=t[0],o=t[1],s=e[0],a=e[1],l=i[0],c=i[1],d=n[0],h=n[1],u=(r-s)*(c-h)-(o-a)*(l-d);return 0===u?null:[((r*a-o*s)*(l-d)-(r-s)*(l*h-c*d))/u,((r*a-o*s)*(c-h)-(o-a)*(l*h-c*d))/u]}(a,c,d,h);null!==u&&(s=h[0]!==d[0]?(u[0]-d[0])/(h[0]-d[0]):(u[1]-d[1])/(h[1]-d[1]),l(c[0]!==a[0]?(u[0]-a[0])/(c[0]-a[0]):(u[1]-a[1])/(c[1]-a[1]))||l(s)||(u.toString(),n.push(u)))}}function Vt(t,e){return t[0]===e[0]&&t[1]===e[1]}function Tt(t,e){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]&&Infinity!==t[0]&&Infinity!==t[1]&&(n=t[0])>=-180&&n<=180&&(i=t[1])>=-90&&i<=90&&zt(t[0])<=e&&zt(t[1])<=e;var i,n}function zt(t){for(var e=1,i=0;Math.round(t*e)/e!==t;)e*=10,i++;return i}function Ut(t,e){return"Polygon"===t.geometry.type&&1===t.geometry.coordinates.length&&t.geometry.coordinates[0].length>=4&&t.geometry.coordinates[0].every(function(t){return Tt(t,e)})&&(i=t.geometry.coordinates[0][0])[0]===(n=t.geometry.coordinates[0][t.geometry.coordinates[0].length-1])[0]&&i[1]===n[1];var i,n}function Xt(t,e){return Ut(t,e)&&!Nt(t)}var Yt=/*#__PURE__*/function(t){function e(e){var i,r;(r=t.call(this,e)||this).mode="circle",r.center=void 0,r.clickCount=0,r.currentCircleId=void 0,r.keyEvents=void 0,r.cursors=void 0,r.minimumRadiusKilometers=void 0;var o={start:"crosshair"};if(r.cursors=e&&e.cursors?n({},o,e.cursors):o,null===(null==e?void 0:e.keyEvents))r.keyEvents={cancel:null,finish:null};else{var s={cancel:"Escape",finish:"Enter"};r.keyEvents=e&&e.keyEvents?n({},s,e.keyEvents):s}return r.minimumRadiusKilometers=null!=(i=null==e?void 0:e.minimumRadiusKilometers)?i:1e-5,r}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentCircleId){var t=this.currentCircleId;this.center=void 0,this.currentCircleId=void 0,this.clickCount=0,"drawing"===this.state&&this.setStarted(),this.onFinish(t)}},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onClick=function(t){if(0===this.clickCount){this.center=[t.lng,t.lat];var e=Rt({center:this.center,radiusKilometers:this.minimumRadiusKilometers,coordinatePrecision:this.coordinatePrecision}),i=this.store.create([{geometry:e.geometry,properties:{mode:this.mode,radiusKilometers:this.minimumRadiusKilometers}}]);this.currentCircleId=i[0],this.clickCount++,this.setDrawing()}else 1===this.clickCount&&this.center&&void 0!==this.currentCircleId&&this.createCircle(t),this.close()},i.onMouseMove=function(t){this.createCircle(t)},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel?this.cleanUp():t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){try{void 0!==this.currentCircleId&&this.store.delete([this.currentCircleId])}catch(t){}this.center=void 0,this.currentCircleId=void 0,this.clickCount=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"Polygon"===t.geometry.type&&t.properties.mode===this.mode?(e.polygonFillColor=this.getHexColorStylingValue(this.styles.fillColor,e.polygonFillColor,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.outlineColor,e.polygonOutlineColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.outlineWidth,e.polygonOutlineWidth,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.fillOpacity,e.polygonFillOpacity,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&Xt(e,this.coordinatePrecision)},i.createCircle=function(t){if(1===this.clickCount&&this.center&&this.currentCircleId){var e=Bt(this.center,[t.lng,t.lat]),i=e>this.minimumRadiusKilometers?e:this.minimumRadiusKilometers,n=Rt({center:this.center,radiusKilometers:i,coordinatePrecision:this.coordinatePrecision});this.store.updateGeometry([{id:this.currentCircleId,geometry:n.geometry}]),this.store.updateProperty([{id:this.currentCircleId,property:"radiusKilometers",value:i}])}},e}(Lt),Ht=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="freehand",i.startingClick=!1,i.currentId=void 0,i.closingPointId=void 0,i.minDistance=void 0,i.keyEvents=void 0,i.cursors=void 0,i.preventPointsNearClose=void 0;var r={start:"crosshair",close:"pointer"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,i.preventPointsNearClose=e&&e.preventPointsNearClose||!0,i.minDistance=e&&e.minDistance||20,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentId){var t=this.currentId;this.closingPointId&&this.store.delete([this.closingPointId]),this.startingClick=!1,this.currentId=void 0,this.closingPointId=void 0,"drawing"===this.state&&this.setStarted(),this.onFinish(t)}},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onMouseMove=function(t){if(void 0!==this.currentId&&!1!==this.startingClick){var e=this.store.getGeometryCopy(this.currentId),i=e.coordinates[0][e.coordinates[0].length-2],n=this.project(i[0],i[1]),r=a({x:n.x,y:n.y},{x:t.containerX,y:t.containerY}),o=e.coordinates[0][0],s=this.project(o[0],o[1]);if(a({x:s.x,y:s.y},{x:t.containerX,y:t.containerY})<this.pointerDistance){if(this.setCursor(this.cursors.close),this.preventPointsNearClose)return}else this.setCursor(this.cursors.start);r<this.minDistance||(e.coordinates[0].pop(),this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[[].concat(e.coordinates[0],[[t.lng,t.lat],e.coordinates[0][0]])]}}]))}},i.onClick=function(t){if(!1===this.startingClick){var e=this.store.create([{geometry:{type:"Polygon",coordinates:[[[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat]]]},properties:{mode:this.mode}},{geometry:{type:"Point",coordinates:[t.lng,t.lat]},properties:{mode:this.mode}}]),i=e[1];return this.currentId=e[0],this.closingPointId=i,this.startingClick=!0,void this.setDrawing()}this.close()},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel?this.cleanUp():t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){try{this.currentId&&this.store.delete([this.currentId]),this.closingPointId&&this.store.delete([this.closingPointId])}catch(t){}this.closingPointId=void 0,this.currentId=void 0,this.startingClick=!1,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"Polygon"===t.geometry.type&&t.properties.mode===this.mode?(e.polygonFillColor=this.getHexColorStylingValue(this.styles.fillColor,e.polygonFillColor,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.outlineColor,e.polygonOutlineColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.outlineWidth,e.polygonOutlineWidth,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.fillOpacity,e.polygonFillOpacity,t),e):"Feature"===t.type&&"Point"===t.geometry.type&&t.properties.mode===this.mode?(e.pointWidth=this.getNumericStylingValue(this.styles.closingPointWidth,e.pointWidth,t),e.pointColor=this.getHexColorStylingValue(this.styles.closingPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.closingPointOutlineColor,e.pointOutlineColor,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.closingPointOutlineWidth,2,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&Ut(e,this.coordinatePrecision)},e}(Lt),Kt=Math.PI/180,Jt=180/Math.PI,qt=/*#__PURE__*/function(){function t(t){this.coordinatePrecision=void 0,this.coords=void 0,this.length=void 0,this.coordinatePrecision=t,this.coords=[],this.length=0}return t.prototype.moveTo=function(t){this.length++,this.coords.push([s(t[0],this.coordinatePrecision),s(t[1],this.coordinatePrecision)])},t}(),Zt=/*#__PURE__*/function(){function t(t){var e=t.properties;this.geometries=void 0,this.properties=void 0,this.properties=e||{},this.geometries=[]}return t.prototype.toJSON=function(){if(1===this.geometries.length){var t=this.geometries[0].coords;if(t[0][0]&&!isNaN(t[0][0])&&t[0][1]&&!isNaN(t[0][1]))return{geometry:{type:"LineString",coordinates:t},type:"Feature",properties:this.properties}}return null},t}(),$t=/*#__PURE__*/function(){function t(t,e,i){if(this.g=void 0,this.start=void 0,this.end=void 0,this.properties=void 0,!t||void 0===t[0]||void 0===t[1])throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!e||void 0===e[0]||void 0===e[1])throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start={lng:t[0],lat:t[1],x:Kt*t[0],y:Kt*t[1]},this.end={lng:e[0],lat:e[1],x:Kt*e[0],y:Kt*e[1]},this.properties=i||{};var n=this.start.x-this.end.x,r=Math.pow(Math.sin((this.start.y-this.end.y)/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(n/2),2);if(this.g=2*Math.asin(Math.sqrt(r)),this.g===Math.PI)throw new Error("it appears "+t+" and "+e+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+t+" and "+e)}var e=t.prototype;return e.interpolate=function(t){var e=Math.sin((1-t)*this.g)/Math.sin(this.g),i=Math.sin(t*this.g)/Math.sin(this.g),n=e*Math.cos(this.start.y)*Math.cos(this.start.x)+i*Math.cos(this.end.y)*Math.cos(this.end.x),r=e*Math.cos(this.start.y)*Math.sin(this.start.x)+i*Math.cos(this.end.y)*Math.sin(this.end.x),o=e*Math.sin(this.start.y)+i*Math.sin(this.end.y),s=Jt*Math.atan2(o,Math.sqrt(Math.pow(n,2)+Math.pow(r,2)));return[Jt*Math.atan2(r,n),s]},e.arc=function(t,e){var i=[];if(!t||t<=2)i.push([this.start.lng,this.start.lat]),i.push([this.end.lng,this.end.lat]);else for(var n=1/(t-1),r=0;r<t;++r){var o=this.interpolate(n*r);i.push(o)}for(var s=!1,a=0,l=e&&e.offset?e.offset:10,c=180-l,d=-180+l,h=360-l,u=1;u<i.length;++u){var g=i[u-1][0],p=i[u][0],f=Math.abs(p-g);f>h&&(p>c&&g<d||g>c&&p<d)?s=!0:f>a&&(a=f)}var y=[];if(s&&a<l){var v=[];y.push(v);for(var m=0;m<i.length;++m){var _=i[m][0];if(m>0&&Math.abs(_-i[m-1][0])>h){var C=i[m-1][0],P=i[m-1][1],x=i[m][0],S=i[m][1];if(C>-180&&C<d&&180===x&&m+1<i.length&&i[m-1][0]>-180&&i[m-1][0]<d){v.push([-180,i[m][1]]),m++,v.push([i[m][0],i[m][1]]);continue}if(C>c&&C<180&&-180===x&&m+1<i.length&&i[m-1][0]>c&&i[m-1][0]<180){v.push([180,i[m][1]]),m++,v.push([i[m][0],i[m][1]]);continue}if(C<d&&x>c){var b=C;C=x,x=b;var w=P;P=S,S=w}if(C>c&&x<d&&(x+=360),C<=180&&x>=180&&C<x){var M=(180-C)/(x-C),E=M*S+(1-M)*P;v.push([i[m-1][0]>c?180:-180,E]),(v=[]).push([i[m-1][0]>c?-180:180,E]),y.push(v)}else y.push(v=[]);v.push([_,i[m][1]])}else v.push([i[m][0],i[m][1]])}}else{var I=[];y.push(I);for(var D=0;D<i.length;++D)I.push([i[D][0],i[D][1]])}for(var k=new Zt({properties:this.properties}),F=0;F<y.length;++F){var O=new qt(e.coordinatePrecision);k.geometries.push(O);for(var L=y[F],W=0;W<L.length;++W)O.moveTo(L[W])}return k},t}(),Qt=function(t){var e=t.store,i=t.mode,n=t.project,r=t.unproject,o=t.pointerDistance,s=t.coordinatePrecision;this.store=void 0,this.mode=void 0,this.project=void 0,this.unproject=void 0,this.pointerDistance=void 0,this.coordinatePrecision=void 0,this.store=e,this.mode=i,this.project=n,this.unproject=r,this.pointerDistance=o,this.coordinatePrecision=s},te=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.pixelDistance=void 0,r.clickBoundingBox=void 0,r.getSnappableCoordinate=function(t,e){return r.getSnappableEnds(t,function(t){return Boolean(!t.properties||t.properties.mode!==r.mode||!e||t.id!==e)})},r.config=e,r.pixelDistance=i,r.clickBoundingBox=n,r}return r(e,t),e.prototype.getSnappableEnds=function(t,e){var i=this,n=this.clickBoundingBox.create(t),r=this.store.search(n,e),o={coord:void 0,minDist:Infinity};return r.forEach(function(e){var n;if("LineString"===e.geometry.type){var r=(n=e.geometry.coordinates)[0],s=i.pixelDistance.measure(t,r);s<o.minDist&&s<i.pointerDistance&&(o.coord=r);var a=n[n.length-1],l=i.pixelDistance.measure(t,a);l<o.minDist&&l<i.pointerDistance&&(o.coord=a)}}),o.coord},e}(Qt),ee=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}return r(e,t),e.prototype.measure=function(t,e){var i=this.project(e[0],e[1]);return a({x:i.x,y:i.y},{x:t.containerX,y:t.containerY})},e}(Qt);function ie(t){var e=t.unproject,i=t.point,n=t.pointerDistance/2,r=i.x,o=i.y;return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[e(r-n,o-n),e(r+n,o-n),e(r+n,o+n),e(r-n,o+n),e(r-n,o-n)].map(function(t){return[t.lng,t.lat]})]}}}var ne=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}return r(e,t),e.prototype.create=function(t){return ie({unproject:this.unproject,point:{x:t.containerX,y:t.containerY},pointerDistance:this.pointerDistance})},e}(Qt),re=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="greatcircle",i.currentCoordinate=0,i.currentId=void 0,i.closingPointId=void 0,i.keyEvents=void 0,i.snappingEnabled=void 0,i.cursors=void 0,i.snapping=void 0;var r={start:"crosshair",close:"pointer"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,i.snappingEnabled=!(!e||void 0===e.snapping)&&e.snapping,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentId){var t=this.currentId;this.closingPointId&&this.store.delete([this.closingPointId]),this.currentCoordinate=0,this.currentId=void 0,this.closingPointId=void 0,"drawing"===this.state&&this.setStarted(),this.onFinish(t)}},i.registerBehaviors=function(t){this.snapping=new te(t,new ee(t),new ne(t))},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onMouseMove=function(t){if(this.setCursor(this.cursors.start),(void 0!==this.currentId||0!==this.currentCoordinate)&&this.currentId&&1===this.currentCoordinate&&this.closingPointId){var e=this.currentId&&this.snappingEnabled&&this.snapping.getSnappableCoordinate(t,this.currentId)||[t.lng,t.lat];this.store.updateGeometry([{id:this.closingPointId,geometry:{type:"Point",coordinates:e}}]);var i=this.store.getGeometryCopy(this.currentId);i.coordinates.pop();var n=function(t){var e=t.start,i=t.end,n=t.options||{};if("object"!=typeof n)throw new Error("options argument is invalid, must be of type object");var r=n.properties,o=n.numberOfPoints,s=void 0===o?100:o,a=n.offset,l=void 0===a?10:a,c=n.coordinatePrecision,d=void 0===c?9:c;return new $t(e,i,void 0===r?{}:r).arc(s,{offset:l,coordinatePrecision:d}).toJSON()}({start:i.coordinates[0],end:e,options:{coordinatePrecision:this.coordinatePrecision}});n&&this.store.updateGeometry([{id:this.currentId,geometry:n.geometry}])}},i.onClick=function(t){if(0===this.currentCoordinate){var e=this.snappingEnabled&&this.snapping.getSnappableCoordinate(t)||[t.lng,t.lat],i=this.store.create([{geometry:{type:"LineString",coordinates:[e,e]},properties:{mode:this.mode}}]);this.currentId=i[0];var n=this.store.create([{geometry:{type:"Point",coordinates:e},properties:{mode:this.mode}}]);this.closingPointId=n[0],this.currentCoordinate++,this.setDrawing()}else 1===this.currentCoordinate&&this.currentId&&(this.setCursor("pointer"),this.close())},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel&&this.cleanUp(),t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){try{this.currentId&&this.store.delete([this.currentId]),this.closingPointId&&this.store.delete([this.closingPointId])}catch(t){}this.closingPointId=void 0,this.currentId=void 0,this.currentCoordinate=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"LineString"===t.geometry.type&&t.properties.mode===this.mode?(e.lineStringColor=this.getHexColorStylingValue(this.styles.lineStringColor,e.lineStringColor,t),e.lineStringWidth=this.getNumericStylingValue(this.styles.lineStringWidth,e.lineStringWidth,t),e):"Feature"===t.type&&"Point"===t.geometry.type&&t.properties.mode===this.mode?(e.pointColor=this.getHexColorStylingValue(this.styles.closingPointColor,e.pointColor,t),e.pointWidth=this.getNumericStylingValue(this.styles.closingPointWidth,e.pointWidth,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.closingPointOutlineColor,"#ffffff",t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.closingPointOutlineWidth,2,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&"LineString"===e.geometry.type&&e.properties.mode===this.mode&&e.geometry.coordinates.length>=2},e}(Lt),oe=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.pixelDistance=void 0,r.clickBoundingBox=void 0,r.getSnappableCoordinateFirstClick=function(t){return r.getSnappable(t,function(t){return Boolean(t.properties&&t.properties.mode===r.mode)})},r.getSnappableCoordinate=function(t,e){return r.getSnappable(t,function(t){return Boolean(t.properties&&t.properties.mode===r.mode&&t.id!==e)})},r.config=e,r.pixelDistance=i,r.clickBoundingBox=n,r}return r(e,t),e.prototype.getSnappable=function(t,e){var i=this,n=this.clickBoundingBox.create(t),r=this.store.search(n,e),o={coord:void 0,minDist:Infinity};return r.forEach(function(e){var n;if("Polygon"===e.geometry.type)n=e.geometry.coordinates[0];else{if("LineString"!==e.geometry.type)return;n=e.geometry.coordinates}n.forEach(function(e){var n=i.pixelDistance.measure(t,e);n<o.minDist&&n<i.pointerDistance&&(o.coord=e)})}),o.coord},e}(Qt),se=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="linestring",i.currentCoordinate=0,i.currentId=void 0,i.closingPointId=void 0,i.allowSelfIntersections=void 0,i.keyEvents=void 0,i.snappingEnabled=void 0,i.cursors=void 0,i.mouseMove=!1,i.snapping=void 0;var r={start:"crosshair",close:"pointer"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,i.snappingEnabled=!(!e||void 0===e.snapping)&&e.snapping,i.allowSelfIntersections=!e||void 0===e.allowSelfIntersections||e.allowSelfIntersections,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentId){var t=this.store.getGeometryCopy(this.currentId);t.coordinates.pop(),this.store.updateGeometry([{id:this.currentId,geometry:{type:"LineString",coordinates:[].concat(t.coordinates)}}]);var e=this.currentId;this.closingPointId&&this.store.delete([this.closingPointId]),this.currentCoordinate=0,this.currentId=void 0,this.closingPointId=void 0,"drawing"===this.state&&this.setStarted(),this.onFinish(e)}},i.registerBehaviors=function(t){this.snapping=new oe(t,new ee(t),new ne(t))},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onMouseMove=function(t){if(this.mouseMove=!0,this.setCursor(this.cursors.start),void 0!==this.currentId&&0!==this.currentCoordinate){var e=this.store.getGeometryCopy(this.currentId);e.coordinates.pop();var i=this.snappingEnabled&&this.snapping.getSnappableCoordinate(t,this.currentId)||[t.lng,t.lat];if(this.closingPointId){var n=e.coordinates[e.coordinates.length-1],r=this.project(n[0],n[1]);a({x:r.x,y:r.y},{x:t.containerX,y:t.containerY})<this.pointerDistance&&this.setCursor(this.cursors.close)}this.store.updateGeometry([{id:this.currentId,geometry:{type:"LineString",coordinates:[].concat(e.coordinates,[i])}}])}},i.onClick=function(t){this.currentCoordinate>0&&!this.mouseMove&&this.onMouseMove(t),this.mouseMove=!1;var e=this.currentId&&this.snappingEnabled&&this.snapping.getSnappableCoordinate(t,this.currentId)||[t.lng,t.lat];if(0===this.currentCoordinate){var i=this.store.create([{geometry:{type:"LineString",coordinates:[e,e]},properties:{mode:this.mode}}]);this.currentId=i[0],this.currentCoordinate++,this.setDrawing()}else if(1===this.currentCoordinate&&this.currentId){var n=this.store.getGeometryCopy(this.currentId),r=this.store.create([{geometry:{type:"Point",coordinates:[].concat(e)},properties:{mode:this.mode}}]);this.closingPointId=r[0],this.setCursor(this.cursors.close),this.store.updateGeometry([{id:this.currentId,geometry:{type:"LineString",coordinates:[n.coordinates[0],e,e]}}]),this.currentCoordinate++}else if(this.currentId){var o=this.store.getGeometryCopy(this.currentId),s=o.coordinates[o.coordinates.length-2],l=this.project(s[0],s[1]);if(a({x:l.x,y:l.y},{x:t.containerX,y:t.containerY})<this.pointerDistance)this.close();else{var c={type:"LineString",coordinates:[].concat(o.coordinates,[e])};if(!this.allowSelfIntersections&&Nt({type:"Feature",geometry:c,properties:{}}))return;this.closingPointId&&(this.setCursor(this.cursors.close),this.store.updateGeometry([{id:this.currentId,geometry:c},{id:this.closingPointId,geometry:{type:"Point",coordinates:o.coordinates[o.coordinates.length-1]}}]),this.currentCoordinate++)}}},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel&&this.cleanUp(),t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){try{this.currentId&&this.store.delete([this.currentId]),this.closingPointId&&this.store.delete([this.closingPointId])}catch(t){}this.closingPointId=void 0,this.currentId=void 0,this.currentCoordinate=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"LineString"===t.geometry.type&&t.properties.mode===this.mode?(e.lineStringColor=this.getHexColorStylingValue(this.styles.lineStringColor,e.lineStringColor,t),e.lineStringWidth=this.getNumericStylingValue(this.styles.lineStringWidth,e.lineStringWidth,t),e):"Feature"===t.type&&"Point"===t.geometry.type&&t.properties.mode===this.mode?(e.pointColor=this.getHexColorStylingValue(this.styles.closingPointColor,e.pointColor,t),e.pointWidth=this.getNumericStylingValue(this.styles.closingPointWidth,e.pointWidth,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.closingPointOutlineColor,"#ffffff",t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.closingPointOutlineWidth,2,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&"LineString"===e.geometry.type&&e.properties.mode===this.mode&&e.geometry.coordinates.length>=2},e}(Lt);function ae(t,e){return"Point"===t.geometry.type&&Tt(t.geometry.coordinates,e)}var le=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="point",i.cursors=void 0;var r={create:"crosshair"};return i.cursors=e&&e.cursors?n({},r,e.cursors):r,i}r(e,t);var i=e.prototype;return i.start=function(){this.setStarted(),this.setCursor(this.cursors.create)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onClick=function(t){if(!this.store)throw new Error("Mode must be registered first");var e=this.store.create([{geometry:{type:"Point",coordinates:[t.lng,t.lat]},properties:{mode:this.mode}}]);this.onFinish(e[0])},i.onMouseMove=function(){},i.onKeyDown=function(){},i.onKeyUp=function(){},i.cleanUp=function(){},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"Point"===t.geometry.type&&t.properties.mode===this.mode&&(e.pointWidth=this.getNumericStylingValue(this.styles.pointWidth,e.pointWidth,t),e.pointColor=this.getHexColorStylingValue(this.styles.pointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.pointOutlineColor,e.pointOutlineColor,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.pointOutlineWidth,2,t)),e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&ae(e,this.coordinatePrecision)},e}(Lt);function ce(t,e){return t[0]===e[0]&&t[1]===e[1]}var de=/*#__PURE__*/function(t){function e(e,i){var n;return(n=t.call(this,e)||this).config=void 0,n.pixelDistance=void 0,n._startEndPoints=[],n.config=e,n.pixelDistance=i,n}r(e,t);var n=e.prototype;return n.create=function(t,e){var i,n;if(this.ids.length)throw new Error("Opening and closing points already creating");if(t.length<=3)throw new Error("Requires at least 4 cooridnates");this._startEndPoints=this.store.create([{geometry:{type:"Point",coordinates:t[0]},properties:(i={mode:e},i[kt]=!0,i)},{geometry:{type:"Point",coordinates:t[t.length-2]},properties:(n={mode:e},n[kt]=!0,n)}])},n.delete=function(){this.ids.length&&(this.store.delete(this.ids),this._startEndPoints=[])},n.update=function(t){if(2!==this.ids.length)throw new Error("No closing points to update");this.store.updateGeometry([{id:this.ids[0],geometry:{type:"Point",coordinates:t[0]}},{id:this.ids[1],geometry:{type:"Point",coordinates:t[t.length-3]}}])},n.isClosingPoint=function(t){var e=this.store.getGeometryCopy(this.ids[0]),i=this.store.getGeometryCopy(this.ids[1]),n=this.pixelDistance.measure(t,e.coordinates),r=this.pixelDistance.measure(t,i.coordinates);return{isClosing:n<this.pointerDistance,isPreviousClosing:r<this.pointerDistance}},i(e,[{key:"ids",get:function(){return this._startEndPoints.concat()},set:function(t){}}]),e}(Qt),he=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="polygon",i.currentCoordinate=0,i.currentId=void 0,i.allowSelfIntersections=void 0,i.keyEvents=void 0,i.snappingEnabled=void 0,i.snapping=void 0,i.pixelDistance=void 0,i.closingPoints=void 0,i.cursors=void 0,i.mouseMove=!1;var r={start:"crosshair",close:"pointer"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,i.snappingEnabled=!(!e||void 0===e.snapping)&&e.snapping,i.allowSelfIntersections=!e||void 0===e.allowSelfIntersections||e.allowSelfIntersections,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.close=function(){if(void 0!==this.currentId){var t=this.store.getGeometryCopy(this.currentId).coordinates[0];if(!(t.length<5)){this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[[].concat(t.slice(0,-2),[t[0]])]}}]);var e=this.currentId;this.currentCoordinate=0,this.currentId=void 0,this.closingPoints.delete(),"drawing"===this.state&&this.setStarted(),this.onFinish(e)}}},i.registerBehaviors=function(t){this.pixelDistance=new ee(t),this.snapping=new oe(t,this.pixelDistance,new ne(t)),this.closingPoints=new de(t,this.pixelDistance)},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onMouseMove=function(t){if(this.mouseMove=!0,this.setCursor(this.cursors.start),void 0!==this.currentId&&0!==this.currentCoordinate){var e,i=this.snappingEnabled?this.snapping.getSnappableCoordinate(t,this.currentId):void 0,n=this.store.getGeometryCopy(this.currentId).coordinates[0];if(i&&(t.lng=i[0],t.lat=i[1]),1===this.currentCoordinate){var r=1/Math.pow(10,this.coordinatePrecision-1),o=Math.max(1e-6,r);e=[n[0],[t.lng,t.lat],[t.lng,t.lat-o],n[0]]}else if(2===this.currentCoordinate)e=[n[0],n[1],[t.lng,t.lat],n[0]];else{var s=this.closingPoints.isClosingPoint(t);s.isPreviousClosing||s.isClosing?(this.setCursor(this.cursors.close),e=[].concat(n.slice(0,-2),[n[0],n[0]])):e=[].concat(n.slice(0,-2),[[t.lng,t.lat],n[0]])}this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[e]}}])}},i.onClick=function(t){if(this.currentCoordinate>0&&!this.mouseMove&&this.onMouseMove(t),this.mouseMove=!1,0===this.currentCoordinate){var e=this.snappingEnabled?this.snapping.getSnappableCoordinateFirstClick(t):void 0;e&&(t.lng=e[0],t.lat=e[1]);var i=this.store.create([{geometry:{type:"Polygon",coordinates:[[[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat]]]},properties:{mode:this.mode}}]);this.currentId=i[0],this.currentCoordinate++,this.setDrawing()}else if(1===this.currentCoordinate&&this.currentId){var n=this.snappingEnabled?this.snapping.getSnappableCoordinate(t,this.currentId):void 0;n&&(t.lng=n[0],t.lat=n[1]);var r=this.store.getGeometryCopy(this.currentId);if(ce([t.lng,t.lat],r.coordinates[0][0]))return;this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[[r.coordinates[0][0],[t.lng,t.lat],[t.lng,t.lat],r.coordinates[0][0]]]}}]),this.currentCoordinate++}else if(2===this.currentCoordinate&&this.currentId){var o=this.snappingEnabled?this.snapping.getSnappableCoordinate(t,this.currentId):void 0;o&&(t.lng=o[0],t.lat=o[1]);var s=this.store.getGeometryCopy(this.currentId).coordinates[0];if(ce([t.lng,t.lat],s[1]))return;2===this.currentCoordinate&&this.closingPoints.create(s,"polygon"),this.store.updateGeometry([{id:this.currentId,geometry:{type:"Polygon",coordinates:[[s[0],s[1],[t.lng,t.lat],[t.lng,t.lat],s[0]]]}}]),this.currentCoordinate++}else if(this.currentId){var a=this.snappingEnabled?this.snapping.getSnappableCoordinate(t,this.currentId):void 0,l=this.store.getGeometryCopy(this.currentId).coordinates[0],c=this.closingPoints.isClosingPoint(t);if(c.isPreviousClosing||c.isClosing)this.close();else{if(a&&(t.lng=a[0],t.lat=a[1]),ce([t.lng,t.lat],l[this.currentCoordinate-1]))return;var d=(void 0===(h=[[].concat(l.slice(0,-1),[[t.lng,t.lat],l[0]])])&&(h=[[[0,0],[0,1],[1,1],[1,0],[0,0]]]),{type:"Feature",geometry:{type:"Polygon",coordinates:h},properties:{}});if(this.currentCoordinate>2&&!this.allowSelfIntersections&&Nt(d))return;this.store.updateGeometry([{id:this.currentId,geometry:d.geometry}]),this.currentCoordinate++,this.closingPoints.ids.length&&this.closingPoints.update(d.geometry.coordinates[0])}}var h},i.onKeyUp=function(t){t.key===this.keyEvents.cancel?this.cleanUp():t.key===this.keyEvents.finish&&this.close()},i.onKeyDown=function(){},i.onDragStart=function(){this.setCursor("unset")},i.onDrag=function(){},i.onDragEnd=function(){this.setCursor(this.cursors.start)},i.cleanUp=function(){try{this.currentId&&this.store.delete([this.currentId]),this.closingPoints.ids.length&&this.closingPoints.delete()}catch(t){}this.currentId=void 0,this.currentCoordinate=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});if(t.properties.mode===this.mode){if("Polygon"===t.geometry.type)return e.polygonFillColor=this.getHexColorStylingValue(this.styles.fillColor,e.polygonFillColor,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.outlineColor,e.polygonOutlineColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.outlineWidth,e.polygonOutlineWidth,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.fillOpacity,e.polygonFillOpacity,t),e.zIndex=10,e;if("Point"===t.geometry.type)return e.pointWidth=this.getNumericStylingValue(this.styles.closingPointWidth,e.pointWidth,t),e.pointColor=this.getHexColorStylingValue(this.styles.closingPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.closingPointOutlineColor,e.pointOutlineColor,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.closingPointOutlineWidth,2,t),e.zIndex=30,e}return e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&Ut(e,this.coordinatePrecision)},e}(Lt),ue=/*#__PURE__*/function(t){function e(e){var i;(i=t.call(this,e)||this).mode="rectangle",i.center=void 0,i.clickCount=0,i.currentRectangleId=void 0,i.keyEvents=void 0,i.cursors=void 0;var r={start:"crosshair"};if(i.cursors=e&&e.cursors?n({},r,e.cursors):r,null===(null==e?void 0:e.keyEvents))i.keyEvents={cancel:null,finish:null};else{var o={cancel:"Escape",finish:"Enter"};i.keyEvents=e&&e.keyEvents?n({},o,e.keyEvents):o}return i}r(e,t);var i=e.prototype;return i.updateRectangle=function(t){if(1===this.clickCount&&this.center&&this.currentRectangleId){var e=this.store.getGeometryCopy(this.currentRectangleId).coordinates[0][0];this.store.updateGeometry([{id:this.currentRectangleId,geometry:{type:"Polygon",coordinates:[[e,[t.lng,e[1]],[t.lng,t.lat],[e[0],t.lat],e]]}}])}},i.close=function(){var t=this.currentRectangleId;this.center=void 0,this.currentRectangleId=void 0,this.clickCount=0,"drawing"===this.state&&this.setStarted(),t&&this.onFinish(t)},i.start=function(){this.setStarted(),this.setCursor(this.cursors.start)},i.stop=function(){this.cleanUp(),this.setStopped(),this.setCursor("unset")},i.onClick=function(t){if(0===this.clickCount){this.center=[t.lng,t.lat];var e=this.store.create([{geometry:{type:"Polygon",coordinates:[[[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat],[t.lng,t.lat]]]},properties:{mode:this.mode}}]);this.currentRectangleId=e[0],this.clickCount++,this.setDrawing()}else this.updateRectangle(t),this.close()},i.onMouseMove=function(t){this.updateRectangle(t)},i.onKeyDown=function(){},i.onKeyUp=function(t){t.key===this.keyEvents.cancel?this.cleanUp():t.key===this.keyEvents.finish&&this.close()},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.cleanUp=function(){this.currentRectangleId&&this.store.delete([this.currentRectangleId]),this.center=void 0,this.currentRectangleId=void 0,this.clickCount=0,"drawing"===this.state&&this.setStarted()},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});return"Feature"===t.type&&"Polygon"===t.geometry.type&&t.properties.mode===this.mode?(e.polygonFillColor=this.getHexColorStylingValue(this.styles.fillColor,e.polygonFillColor,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.outlineColor,e.polygonOutlineColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.outlineWidth,e.polygonOutlineWidth,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.fillOpacity,e.polygonFillOpacity,t),e):e},i.validateFeature=function(e){return!!t.prototype.validateFeature.call(this,e)&&e.properties.mode===this.mode&&Xt(e,this.coordinatePrecision)},e}(Lt),ge=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,{styles:e.styles})||this).type=wt.Render,i.mode="render",i.mode=e.modeName,i}r(e,t);var i=e.prototype;return i.registerBehaviors=function(t){this.mode=t.mode},i.start=function(){this.setStarted()},i.stop=function(){this.setStopped()},i.onKeyUp=function(){},i.onKeyDown=function(){},i.onClick=function(){},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.onMouseMove=function(){},i.cleanUp=function(){},i.styleFeature=function(t){return{pointColor:this.getHexColorStylingValue(this.styles.pointColor,"#3f97e0",t),pointWidth:this.getNumericStylingValue(this.styles.pointWidth,6,t),pointOutlineColor:this.getHexColorStylingValue(this.styles.pointOutlineColor,"#ffffff",t),pointOutlineWidth:this.getNumericStylingValue(this.styles.pointOutlineWidth,0,t),polygonFillColor:this.getHexColorStylingValue(this.styles.polygonFillColor,"#3f97e0",t),polygonFillOpacity:this.getNumericStylingValue(this.styles.polygonFillOpacity,.3,t),polygonOutlineColor:this.getHexColorStylingValue(this.styles.polygonOutlineColor,"#3f97e0",t),polygonOutlineWidth:this.getNumericStylingValue(this.styles.polygonOutlineWidth,4,t),lineStringWidth:this.getNumericStylingValue(this.styles.lineStringWidth,4,t),lineStringColor:this.getHexColorStylingValue(this.styles.lineStringColor,"#3f97e0",t),zIndex:this.getNumericStylingValue(this.styles.zIndex,0,t)}},i.validateFeature=function(e){return t.prototype.validateFeature.call(this,e)&&(ae(e,this.coordinatePrecision)||Ut(e,this.coordinatePrecision)||function(t,e){return"LineString"===t.geometry.type&&t.geometry.coordinates.length>=2&&t.geometry.coordinates.every(function(t){return Tt(t,e)})}(e,this.coordinatePrecision))},e}(Lt);function pe(t,e,i,n,r){var o=n(t[0],t[1]),a=n(e[0],e[1]),l=r((o.x+a.x)/2,(o.y+a.y)/2),c=l.lat;return[s(l.lng,i),s(c,i)]}function fe(t,e,i,n){for(var r=[],o=0;o<t.length-1;o++){var s=pe(t[o],t[o+1],e,i,n);r.push(s)}return r}var ye=/*#__PURE__*/function(t){function e(e,i){var n;return(n=t.call(this,e)||this).config=void 0,n.selectionPointBehavior=void 0,n._midPoints=[],n.config=e,n.selectionPointBehavior=i,n}r(e,t);var n=e.prototype;return n.insert=function(t,e){var i=this.store.getGeometryCopy(t),n=this.store.getPropertiesCopy(t),r=n.midPointFeatureId,o=n.midPointSegment,s=this.store.getGeometryCopy(r),a="Polygon"===s.type?s.coordinates[0]:s.coordinates;a.splice(o+1,0,i.coordinates),s.coordinates="Polygon"===s.type?[a]:a,this.store.updateGeometry([{id:r,geometry:s}]),this.store.delete([].concat(this._midPoints,this.selectionPointBehavior.ids)),this.create(a,r,e),this.selectionPointBehavior.create(a,s.type,r)},n.create=function(t,e,i){var n=this;if(!this.store.has(e))throw new Error("Store does not have feature with this id");this._midPoints=this.store.create(function(t,e,i,n,r){return fe(t,i,n,r).map(function(t,i){return{geometry:{type:"Point",coordinates:t},properties:e(i)}})}(t,function(t){var i;return(i={mode:n.mode})[Dt]=!0,i.midPointSegment=t,i.midPointFeatureId=e,i},i,this.config.project,this.config.unproject))},n.delete=function(){this._midPoints.length&&(this.store.delete(this._midPoints),this._midPoints=[])},n.getUpdated=function(t){var e=this;if(0!==this._midPoints.length)return fe(t,this.coordinatePrecision,this.config.project,this.config.unproject).map(function(t,i){return{id:e._midPoints[i],geometry:{type:"Point",coordinates:t}}})},i(e,[{key:"ids",get:function(){return this._midPoints.concat()},set:function(t){}}]),e}(Qt),ve=/*#__PURE__*/function(t){function e(e){var i;return(i=t.call(this,e)||this)._selectionPoints=[],i}r(e,t);var n=e.prototype;return n.create=function(t,e,i){var n=this;this._selectionPoints=this.store.create(function(t,e,i){for(var n=[],r="Polygon"===e?t.length-1:t.length,o=0;o<r;o++)n.push({geometry:{type:"Point",coordinates:t[o]},properties:i(o)});return n}(t,e,function(t){return{mode:n.mode,selectionPoint:!0,selectionPointFeatureId:i,index:t}}))},n.delete=function(){this.ids.length&&(this.store.delete(this.ids),this._selectionPoints=[])},n.getUpdated=function(t){if(0!==this._selectionPoints.length)return this._selectionPoints.map(function(e,i){return{id:e,geometry:{type:"Point",coordinates:t[i]}}})},n.getOneUpdated=function(t,e){if(void 0!==this._selectionPoints[t])return{id:this._selectionPoints[t],geometry:{type:"Point",coordinates:e}}},i(e,[{key:"ids",get:function(){return this._selectionPoints.concat()},set:function(t){}}]),e}(Qt);function me(t,e){for(var i,n,r,o=!1,s=0,a=e.length;s<a;s++)for(var l=e[s],c=0,d=l.length,h=d-1;c<d;h=c++)(n=l[c])[1]>(i=t)[1]!=(r=l[h])[1]>i[1]&&i[0]<(r[0]-n[0])*(i[1]-n[1])/(r[1]-n[1])+n[0]&&(o=!o);return o}var _e=function(t,e,i){var n=function(t){return t*t},r=function(t,e){return n(t.x-e.x)+n(t.y-e.y)};return Math.sqrt(function(t,e,i){var n=r(e,i);if(0===n)return r(t,e);var o=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n;return o=Math.max(0,Math.min(1,o)),r(t,{x:e.x+o*(i.x-e.x),y:e.y+o*(i.y-e.y)})}(t,e,i))},Ce=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.createClickBoundingBox=void 0,r.pixelDistance=void 0,r.config=e,r.createClickBoundingBox=i,r.pixelDistance=n,r}return r(e,t),e.prototype.find=function(t,e){for(var i=void 0,n=Infinity,r=void 0,o=Infinity,s=this.createClickBoundingBox.create(t),a=this.store.search(s),l=0;l<a.length;l++){var c=a[l],d=c.geometry;if("Point"===d.type){if(c.properties.selectionPoint||!e&&c.properties[Dt])continue;var h=this.pixelDistance.measure(t,d.coordinates);c.properties[Dt]&&h<this.pointerDistance&&h<o?(o=h,r=c):!c.properties[Dt]&&h<this.pointerDistance&&h<n&&(n=h,i=c)}else if("LineString"===d.type)for(var u=0;u<d.coordinates.length-1;u++){var g=d.coordinates[u],p=d.coordinates[u+1],f=_e({x:t.containerX,y:t.containerY},this.project(g[0],g[1]),this.project(p[0],p[1]));f<this.pointerDistance&&f<n&&(n=f,i=c)}else"Polygon"===d.type&&me([t.lng,t.lat],d.coordinates)&&(n=0,i=c)}return{clickedFeature:i,clickedMidPoint:r}},e}(Qt),Pe=/*#__PURE__*/function(t){function e(e,i,n,r){var o;return(o=t.call(this,e)||this).config=void 0,o.featuresAtMouseEvent=void 0,o.selectionPoints=void 0,o.midPoints=void 0,o.draggedFeatureId=null,o.dragPosition=void 0,o.config=e,o.featuresAtMouseEvent=i,o.selectionPoints=n,o.midPoints=r,o}r(e,t);var i=e.prototype;return i.startDragging=function(t,e){this.draggedFeatureId=e,this.dragPosition=[t.lng,t.lat]},i.stopDragging=function(){this.draggedFeatureId=null,this.dragPosition=void 0},i.isDragging=function(){return null!==this.draggedFeatureId},i.canDrag=function(t,e){var i=this.featuresAtMouseEvent.find(t,!0).clickedFeature;return!(!i||i.id!==e)},i.drag=function(t,e){if(this.draggedFeatureId){var i=this.store.getGeometryCopy(this.draggedFeatureId),n=[t.lng,t.lat];if("Polygon"===i.type||"LineString"===i.type){var r,o;if(o="Polygon"===i.type?(r=i.coordinates[0]).length-1:(r=i.coordinates).length,!this.dragPosition)return!1;for(var a=0;a<o;a++){var l=r[a],c=[this.dragPosition[0]-n[0],this.dragPosition[1]-n[1]],d=s(l[0]-c[0],this.config.coordinatePrecision),h=s(l[1]-c[1],this.config.coordinatePrecision);if(d>180||d<-180||h>90||h<-90)return!1;r[a]=[d,h]}"Polygon"===i.type&&(r[r.length-1]=[r[0][0],r[0][1]]);var u=this.selectionPoints.getUpdated(r)||[],g=this.midPoints.getUpdated(r)||[];if(e&&!e({type:"Feature",id:this.draggedFeatureId,geometry:i,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision}))return!1;this.store.updateGeometry([{id:this.draggedFeatureId,geometry:i}].concat(u,g)),this.dragPosition=[t.lng,t.lat]}else"Point"===i.type&&(this.store.updateGeometry([{id:this.draggedFeatureId,geometry:{type:"Point",coordinates:n}}]),this.dragPosition=[t.lng,t.lat])}},e}(Qt),xe=/*#__PURE__*/function(t){function e(e,i,n,r){var o;return(o=t.call(this,e)||this).config=void 0,o.pixelDistance=void 0,o.selectionPoints=void 0,o.midPoints=void 0,o.draggedCoordinate={id:null,index:-1},o.config=e,o.pixelDistance=i,o.selectionPoints=n,o.midPoints=r,o}r(e,t);var i=e.prototype;return i.getClosestCoordinate=function(t,e){var i,n={dist:Infinity,index:-1,isFirstOrLastPolygonCoord:!1};if("LineString"===e.type)i=e.coordinates;else{if("Polygon"!==e.type)return n;i=e.coordinates[0]}for(var r=0;r<i.length;r++){var o=this.pixelDistance.measure(t,i[r]);if(o<this.pointerDistance&&o<n.dist){var s="Polygon"===e.type&&(r===i.length-1||0===r);n.dist=o,n.index=s?0:r,n.isFirstOrLastPolygonCoord=s}}return n},i.getDraggableIndex=function(t,e){var i=this.store.getGeometryCopy(e),n=this.getClosestCoordinate(t,i);return-1===n.index?-1:n.index},i.drag=function(t,e,i){if(!this.draggedCoordinate.id)return!1;var n=this.draggedCoordinate.index,r=this.store.getGeometryCopy(this.draggedCoordinate.id),o="LineString"===r.type?r.coordinates:r.coordinates[0],s=[t.lng,t.lat];if(t.lng>180||t.lng<-180||t.lat>90||t.lat<-90)return!1;if("Polygon"!==r.type||n!==o.length-1&&0!==n)o[n]=s;else{var a=o.length-1;o[0]=s,o[a]=s}var l=this.selectionPoints.getOneUpdated(n,s),c=l?[l]:[],d=this.midPoints.getUpdated(o)||[];return!("Point"!==r.type&&!e&&Nt({type:"Feature",geometry:r,properties:{}})||i&&!i({type:"Feature",id:this.draggedCoordinate.id,geometry:r,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision})||(this.store.updateGeometry([{id:this.draggedCoordinate.id,geometry:r}].concat(c,d)),0))},i.isDragging=function(){return null!==this.draggedCoordinate.id},i.startDragging=function(t,e){this.draggedCoordinate={id:t,index:e}},i.stopDragging=function(){this.draggedCoordinate={id:null,index:-1}},e}(Qt);function Se(t){var e=0,i=0,n=0;return("Polygon"===t.geometry.type?t.geometry.coordinates[0].slice(0,-1):t.geometry.coordinates).forEach(function(t){e+=t[0],i+=t[1],n++},!0),[e/n,i/n]}function be(t,e){var i=t,n=e,r=Gt(i[1]),o=Gt(n[1]),s=Gt(n[0]-i[0]);s>Math.PI&&(s-=2*Math.PI),s<-Math.PI&&(s+=2*Math.PI);var a=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),l=(jt(Math.atan2(s,a))+360)%360;return l>180?-(360-l):l}function we(t,e,i){var n=e;e<0&&(n=-Math.abs(n));var r=n/At,o=t[0]*Math.PI/180,s=Gt(t[1]),a=Gt(i),l=r*Math.cos(a),c=s+l;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);var d=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),h=Math.abs(d)>1e-11?l/d:Math.cos(s),u=[(180*(o+r*Math.sin(a)/h)/Math.PI+540)%360-180,180*c/Math.PI];return u[0]+=u[0]-t[0]>180?-360:t[0]-u[0]>180?360:0,u}function Me(t,e){t[0]+=t[0]-e[0]>180?-360:e[0]-t[0]>180?360:0;var i=At,n=e[1]*Math.PI/180,r=t[1]*Math.PI/180,o=r-n,s=Math.abs(t[0]-e[0])*Math.PI/180;s>Math.PI&&(s-=2*Math.PI);var a=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(n/2+Math.PI/4)),l=Math.abs(a)>1e-11?o/a:Math.cos(n);return Math.sqrt(o*o+l*l*s*s)*i}var Ee=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.selectionPoints=void 0,r.midPoints=void 0,r.lastBearing=void 0,r.config=e,r.selectionPoints=i,r.midPoints=n,r}r(e,t);var i=e.prototype;return i.reset=function(){this.lastBearing=void 0},i.rotate=function(t,e,i){var n=this,r=this.store.getGeometryCopy(e);if("Polygon"===r.type||"LineString"===r.type){var o=[t.lng,t.lat],a=be(Se({type:"Feature",geometry:r,properties:{}}),o);if(this.lastBearing){!function(t,e){if(0===e)return t;var i=Se(t);("Polygon"===t.geometry.type?t.geometry.coordinates[0]:t.geometry.coordinates).forEach(function(t){var n=be(i,t)+e,r=Me(i,t),o=we(i,r,n);t[0]=o[0],t[1]=o[1]})}({type:"Feature",geometry:r,properties:{}},-(this.lastBearing-(a+180)));var l="Polygon"===r.type?r.coordinates[0]:r.coordinates;l.forEach(function(t){t[0]=s(t[0],n.coordinatePrecision),t[1]=s(t[1],n.coordinatePrecision)});var c=this.midPoints.getUpdated(l)||[],d=this.selectionPoints.getUpdated(l)||[];if(i&&!i({id:e,type:"Feature",geometry:r,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision}))return!1;this.store.updateGeometry([{id:e,geometry:r}].concat(d,c)),this.lastBearing=a+180}else this.lastBearing=a+180}},e}(Qt),Ie=/*#__PURE__*/function(t){function e(e,i,n){var r;return(r=t.call(this,e)||this).config=void 0,r.selectionPoints=void 0,r.midPoints=void 0,r.lastDistance=void 0,r.config=e,r.selectionPoints=i,r.midPoints=n,r}r(e,t);var i=e.prototype;return i.reset=function(){this.lastDistance=void 0},i.scale=function(t,e,i){var n=this,r=this.store.getGeometryCopy(e);if("Polygon"===r.type||"LineString"===r.type){var o=[t.lng,t.lat],a=Bt(Se({type:"Feature",geometry:r,properties:{}}),o);if(this.lastDistance){var l={type:"Feature",geometry:r,properties:{}};!function(t,e,i,n){void 0===n&&(n="xy"),1===e||("Polygon"===t.geometry.type?t.geometry.coordinates[0]:t.geometry.coordinates).forEach(function(t){var r=Me(i,t),o=be(i,t),s=we(i,r*e,o);"x"!==n&&"xy"!==n||(t[0]=s[0]),"y"!==n&&"xy"!==n||(t[1]=s[1])})}(l,1-(this.lastDistance-a)/a,Se(l));var c="Polygon"===r.type?r.coordinates[0]:r.coordinates;c.forEach(function(t){t[0]=s(t[0],n.coordinatePrecision),t[1]=s(t[1],n.coordinatePrecision)});var d=this.midPoints.getUpdated(c)||[],h=this.selectionPoints.getUpdated(c)||[];if(i&&!i({id:e,type:"Feature",geometry:r,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision}))return!1;this.store.updateGeometry([{id:e,geometry:r}].concat(h,d)),this.lastDistance=a}else this.lastDistance=a}},e}(Qt),De=57.29577951308232,ke=.017453292519943295,Fe=6378137,Oe=function(t,e){return{x:0===t?0:t*ke*Fe,y:0===e?0:Math.log(Math.tan(Math.PI/4+e*ke/2))*Fe}};function Le(t){var e=function(t){for(var e=[Infinity,Infinity,-Infinity,-Infinity],i=0;i<t.length;i++){var n=t[i];e[0]>n[0]&&(e[0]=n[0]),e[1]>n[1]&&(e[1]=n[1]),e[2]<n[0]&&(e[2]=n[0]),e[3]<n[1]&&(e[3]=n[1])}return e}(("Polygon"===t.geometry.type?t.geometry.coordinates[0]:t.geometry.coordinates).map(function(t){var e=Oe(t[0],t[1]);return[e.x,e.y]}));return{x:(e[0]+e[2])/2,y:(e[1]+e[3])/2}}var We=/*#__PURE__*/function(t){function e(e,i,n,r){var o;return(o=t.call(this,e)||this).config=void 0,o.pixelDistance=void 0,o.selectionPoints=void 0,o.midPoints=void 0,o.minimumScale=1e-4,o.draggedCoordinate={id:null,index:-1},o.boundingBoxMaps={opposite:{0:4,1:5,2:6,3:7,4:0,5:1,6:2,7:3}},o.config=e,o.pixelDistance=i,o.selectionPoints=n,o.midPoints=r,o}r(e,t);var i=e.prototype;return i.getClosestCoordinate=function(t,e){var i,n={dist:Infinity,index:-1,isFirstOrLastPolygonCoord:!1};if("LineString"===e.type)i=e.coordinates;else{if("Polygon"!==e.type)return n;i=e.coordinates[0]}for(var r=0;r<i.length;r++){var o=this.pixelDistance.measure(t,i[r]);if(o<this.pointerDistance&&o<n.dist){var s="Polygon"===e.type&&(r===i.length-1||0===r);n.dist=o,n.index=s?0:r,n.isFirstOrLastPolygonCoord=s}}return n},i.isValidDragWebMercator=function(t,e,i){switch(t){case 0:if(e<=0||i>=0)return!1;break;case 1:if(i>=0)return!1;break;case 2:if(e>=0||i>=0)return!1;break;case 3:if(e>=0)return!1;break;case 4:if(e>=0||i<=0)return!1;break;case 5:if(i<=0)return!1;break;case 6:if(e<=0||i<=0)return!1;break;case 7:if(e<=0)return!1}return!0},i.getSelectedFeatureDataWebMercator=function(){if(!this.draggedCoordinate.id||-1===this.draggedCoordinate.index)return null;var t=this.getFeature(this.draggedCoordinate.id);if(!t)return null;var e=this.getNormalisedCoordinates(t.geometry);return{boundingBox:this.getBBoxWebMercator(e),feature:t,updatedCoords:e,selectedCoordinate:e[this.draggedCoordinate.index]}},i.centerWebMercatorDrag=function(t){var e=this.getSelectedFeatureDataWebMercator();if(!e)return null;var i=e.boundingBox,n=e.updatedCoords,r=e.selectedCoordinate,o=Le(e.feature);if(!o)return null;var s=Oe(r[0],r[1]),a=this.getIndexesWebMercator(i,s).closestBBoxIndex,l=Oe(t.lng,t.lat);return this.scaleWebMercator({closestBBoxIndex:a,updatedCoords:n,webMercatorCursor:l,webMercatorSelected:s,webMercatorOrigin:o}),n},i.centerFixedWebMercatorDrag=function(t){var e=this.getSelectedFeatureDataWebMercator();if(!e)return null;var i=e.boundingBox,n=e.updatedCoords,r=e.selectedCoordinate,o=Le(e.feature);if(!o)return null;var s=Oe(r[0],r[1]),a=this.getIndexesWebMercator(i,s).closestBBoxIndex,l=Oe(t.lng,t.lat);return this.scaleFixedWebMercator({closestBBoxIndex:a,updatedCoords:n,webMercatorCursor:l,webMercatorSelected:s,webMercatorOrigin:o}),n},i.scaleFixedWebMercator=function(t){var e=t.webMercatorOrigin,i=t.webMercatorSelected,n=t.webMercatorCursor,r=t.updatedCoords;if(!this.isValidDragWebMercator(t.closestBBoxIndex,e.x-n.x,e.y-n.y))return null;var o=a(e,n)/a(e,i);return o<0&&(o=this.minimumScale),this.performWebMercatorScale(r,e.x,e.y,o,o),r},i.oppositeFixedWebMercatorDrag=function(t){var e=this.getSelectedFeatureDataWebMercator();if(!e)return null;var i=e.boundingBox,n=e.updatedCoords,r=e.selectedCoordinate,o=Oe(r[0],r[1]),s=this.getIndexesWebMercator(i,o),a=s.oppositeBboxIndex,l=s.closestBBoxIndex,c={x:i[a][0],y:i[a][1]},d=Oe(t.lng,t.lat);return this.scaleFixedWebMercator({closestBBoxIndex:l,updatedCoords:n,webMercatorCursor:d,webMercatorSelected:o,webMercatorOrigin:c}),n},i.oppositeWebMercatorDrag=function(t){var e=this.getSelectedFeatureDataWebMercator();if(!e)return null;var i=e.boundingBox,n=e.updatedCoords,r=e.selectedCoordinate,o=Oe(r[0],r[1]),s=this.getIndexesWebMercator(i,o),a=s.oppositeBboxIndex,l=s.closestBBoxIndex,c={x:i[a][0],y:i[a][1]},d=Oe(t.lng,t.lat);return this.scaleWebMercator({closestBBoxIndex:l,updatedCoords:n,webMercatorCursor:d,webMercatorSelected:o,webMercatorOrigin:c}),n},i.scaleWebMercator=function(t){var e=t.closestBBoxIndex,i=t.webMercatorOrigin,n=t.webMercatorSelected,r=t.webMercatorCursor,o=t.updatedCoords,s=i.x-r.x,a=i.y-r.y;if(!this.isValidDragWebMercator(e,s,a))return null;var l=1;0!==s&&1!==e&&5!==e&&(l=1-(i.x-n.x-s)/s);var c=1;return 0!==a&&3!==e&&7!==e&&(c=1-(i.y-n.y-a)/a),this.validateScale(l,c)?(l<0&&(l=this.minimumScale),c<0&&(c=this.minimumScale),this.performWebMercatorScale(o,i.x,i.y,l,c),o):null},i.getFeature=function(t){if(null===this.draggedCoordinate.id)return null;var e=this.store.getGeometryCopy(t);return"Polygon"!==e.type&&"LineString"!==e.type?null:{type:"Feature",geometry:e,properties:{}}},i.getNormalisedCoordinates=function(t){return"Polygon"===t.type?t.coordinates[0]:t.coordinates},i.validateScale=function(t,e){var i=!isNaN(t)&&e<Number.MAX_SAFE_INTEGER,n=!isNaN(e)&&e<Number.MAX_SAFE_INTEGER;return i&&n},i.performWebMercatorScale=function(t,e,i,n,r){t.forEach(function(t){var o,s,a=Oe(t[0],t[1]),l={lng:0===(o=e+(a.x-e)*n)?0:De*(o/Fe),lat:0===(s=i+(a.y-i)*r)?0:(2*Math.atan(Math.exp(s/Fe))-Math.PI/2)*De},c=l.lat;t[0]=l.lng,t[1]=c})},i.getBBoxWebMercator=function(t){var e=[Infinity,Infinity,-Infinity,-Infinity];(t=t.map(function(t){var e=Oe(t[0],t[1]);return[e.x,e.y]})).forEach(function(t){var i=t[0],n=t[1];i<e[0]&&(e[0]=i),n<e[1]&&(e[1]=n),i>e[2]&&(e[2]=i),n>e[3]&&(e[3]=n)});var i=e[0],n=e[1],r=e[2],o=e[3];return[[i,o],[(i+r)/2,o],[r,o],[r,o+(n-o)/2],[r,n],[(i+r)/2,n],[i,n],[i,o+(n-o)/2]]},i.getIndexesWebMercator=function(t,e){for(var i,n=Infinity,r=0;r<t.length;r++){var o=a({x:e.x,y:e.y},{x:t[r][0],y:t[r][1]});o<n&&(i=r,n=o)}if(void 0===i)throw new Error("No closest coordinate found");return{oppositeBboxIndex:this.boundingBoxMaps.opposite[i],closestBBoxIndex:i}},i.isDragging=function(){return null!==this.draggedCoordinate.id},i.startDragging=function(t,e){this.draggedCoordinate={id:t,index:e}},i.stopDragging=function(){this.draggedCoordinate={id:null,index:-1}},i.getDraggableIndex=function(t,e){var i=this.store.getGeometryCopy(e),n=this.getClosestCoordinate(t,i);return-1===n.index?-1:n.index},i.drag=function(t,e,i){if(!this.draggedCoordinate.id)return!1;var n=this.getFeature(this.draggedCoordinate.id);if(!n)return!1;var r=null;if("center-web-mercator"===e?r=this.centerWebMercatorDrag(t):"opposite-web-mercator"===e?r=this.oppositeWebMercatorDrag(t):"center-fixed-web-mercator"===e?r=this.centerFixedWebMercatorDrag(t):"opposite-fixed-web-mercator"===e&&(r=this.oppositeFixedWebMercatorDrag(t)),!r)return!1;for(var o=0;o<r.length;o++){var a=r[o];if(a[0]=s(a[0],this.coordinatePrecision),a[1]=s(a[1],this.coordinatePrecision),!Tt(a,this.coordinatePrecision))return!1}var l=this.midPoints.getUpdated(r)||[],c=this.selectionPoints.getUpdated(r)||[],d={type:n.geometry.type,coordinates:"Polygon"===n.geometry.type?[r]:r};return!(i&&!i({id:this.draggedCoordinate.id,type:"Feature",geometry:d,properties:{}},{project:this.config.project,unproject:this.config.unproject,coordinatePrecision:this.config.coordinatePrecision})||(this.store.updateGeometry([{id:this.draggedCoordinate.id,geometry:d}].concat(c,l)),0))},e}(Qt),Be=/*#__PURE__*/function(t){function e(e){var i,r;(r=t.call(this,e)||this).mode="select",r.allowManualDeselection=!0,r.dragEventThrottle=5,r.dragEventCount=0,r.selected=[],r.flags=void 0,r.keyEvents=void 0,r.selectionPoints=void 0,r.midPoints=void 0,r.featuresAtMouseEvent=void 0,r.pixelDistance=void 0,r.clickBoundingBox=void 0,r.dragFeature=void 0,r.dragCoordinate=void 0,r.rotateFeature=void 0,r.scaleFeature=void 0,r.dragCoordinateResizeFeature=void 0,r.cursors=void 0,r.validations={},r.flags=e&&e.flags?e.flags:{};var o={pointerOver:"move",dragStart:"move",dragEnd:"move",insertMidpoint:"crosshair"};if(r.cursors=e&&e.cursors?n({},o,e.cursors):o,null===(null==e?void 0:e.keyEvents))r.keyEvents={deselect:null,delete:null,rotate:null,scale:null};else{var s={deselect:"Escape",delete:"Delete",rotate:["Control","r"],scale:["Control","s"]};r.keyEvents=e&&e.keyEvents?n({},s,e.keyEvents):s}if(r.dragEventThrottle=e&&void 0!==e.dragEventThrottle&&e.dragEventThrottle||5,r.allowManualDeselection=null==(i=null==e?void 0:e.allowManualDeselection)||i,e&&e.flags&&e.flags)for(var a in e.flags){var l=e.flags[a].feature;l&&l.validation&&(r.validations[a]=l.validation)}return r}r(e,t);var i=e.prototype;return i.selectFeature=function(t){this.select(t,!1)},i.setSelecting=function(){if("started"!==this._state)throw new Error("Mode must be started to move to selecting state");this._state="selecting"},i.registerBehaviors=function(t){this.pixelDistance=new ee(t),this.clickBoundingBox=new ne(t),this.featuresAtMouseEvent=new Ce(t,this.clickBoundingBox,this.pixelDistance),this.selectionPoints=new ve(t),this.midPoints=new ye(t,this.selectionPoints),this.rotateFeature=new Ee(t,this.selectionPoints,this.midPoints),this.scaleFeature=new Ie(t,this.selectionPoints,this.midPoints),this.dragFeature=new Pe(t,this.featuresAtMouseEvent,this.selectionPoints,this.midPoints),this.dragCoordinate=new xe(t,this.pixelDistance,this.selectionPoints,this.midPoints),this.dragCoordinateResizeFeature=new We(t,this.pixelDistance,this.selectionPoints,this.midPoints)},i.deselectFeature=function(){this.deselect()},i.deselect=function(){var t=this,e=this.selected.filter(function(e){return t.store.has(e)}).map(function(t){return{id:t,property:It,value:!1}});this.store.updateProperty(e),this.onDeselect(this.selected[0]),this.selected=[],this.selectionPoints.delete(),this.midPoints.delete()},i.deleteSelected=function(){this.store.delete(this.selected),this.selected=[]},i.onRightClick=function(t){var e=this;if(this.selectionPoints.ids.length){var i,n=Infinity;if(this.selectionPoints.ids.forEach(function(r){var o=e.store.getGeometryCopy(r),s=e.pixelDistance.measure(t,o.coordinates);s<e.pointerDistance&&s<n&&(n=s,i=e.store.getPropertiesCopy(r))}),i){var r=i.selectionPointFeatureId,o=i.index,s=this.store.getPropertiesCopy(r),a=this.flags[s.mode],l=this.validations[s.mode];if(a&&a.feature&&a.feature.coordinates&&a.feature.coordinates.deletable){var c,d=this.store.getGeometryCopy(r);if("Polygon"===d.type){if((c=d.coordinates[0]).length<=4)return}else if("LineString"===d.type&&(c=d.coordinates).length<=3)return;if(c){if("Polygon"===d.type&&0===o||o===c.length-1?(c.shift(),c.pop(),c.push([c[0][0],c[0][1]])):c.splice(o,1),l&&!l({id:r,type:"Feature",geometry:d,properties:s}))return;this.store.delete([].concat(this.midPoints.ids,this.selectionPoints.ids)),this.store.updateGeometry([{id:r,geometry:d}]),this.selectionPoints.create(c,d.type,r),a&&a.feature&&a.feature.coordinates&&a.feature.coordinates.midpoints&&this.midPoints.create(c,r,this.coordinatePrecision)}}}}},i.select=function(t,e){if(void 0===e&&(e=!0),this.selected[0]!==t){var i=this.store.getPropertiesCopy(t),n=this.flags[i.mode];if(n&&n.feature){var r=this.selected[0];if(r){if(r===t)return;this.deselect()}e&&this.setCursor(this.cursors.pointerOver),this.selected=[t],this.store.updateProperty([{id:t,property:"selected",value:!0}]),this.onSelect(t);var o=this.store.getGeometryCopy(t),s=o.type,a=o.coordinates;if("LineString"===s||"Polygon"===s){var l="LineString"===s?a:a[0];l&&n&&n.feature.coordinates&&(this.selectionPoints.create(l,s,t),n.feature.coordinates.midpoints&&this.midPoints.create(l,t,this.coordinatePrecision))}}}},i.onLeftClick=function(t){var e=this.featuresAtMouseEvent.find(t,this.selected.length>0),i=e.clickedFeature,n=e.clickedMidPoint;if(this.selected.length&&n)this.midPoints.insert(n.id,this.coordinatePrecision);else if(i&&i.id)this.select(i.id,!0);else if(this.selected.length&&this.allowManualDeselection)return void this.deselect()},i.start=function(){this.setStarted(),this.setSelecting()},i.stop=function(){this.cleanUp(),this.setStarted(),this.setStopped()},i.onClick=function(t){"right"!==t.button?"left"===t.button&&this.onLeftClick(t):this.onRightClick(t)},i.canScale=function(t){return this.keyEvents.scale&&this.keyEvents.scale.every(function(e){return t.heldKeys.includes(e)})},i.canRotate=function(t){return this.keyEvents.rotate&&this.keyEvents.rotate.every(function(e){return t.heldKeys.includes(e)})},i.preventDefaultKeyEvent=function(t){var e=this.canRotate(t),i=this.canScale(t);(e||i)&&t.preventDefault()},i.onKeyDown=function(t){this.preventDefaultKeyEvent(t)},i.onKeyUp=function(t){if(this.preventDefaultKeyEvent(t),this.keyEvents.delete&&t.key===this.keyEvents.delete){if(!this.selected.length)return;this.onDeselect(this.selected[0]),this.deleteSelected(),this.selectionPoints.delete(),this.midPoints.delete()}else this.keyEvents.deselect&&t.key===this.keyEvents.deselect&&this.cleanUp()},i.cleanUp=function(){this.selected.length&&this.deselect()},i.onDragStart=function(t,e){if(this.selected.length){var i=this.store.getPropertiesCopy(this.selected[0]),n=this.flags[i.mode];if(n&&n.feature&&(n.feature.draggable||n.feature.coordinates&&n.feature.coordinates.draggable||n.feature.coordinates&&n.feature.coordinates.resizable)){this.dragEventCount=0;var r=this.selected[0],o=this.dragCoordinate.getDraggableIndex(t,r);return n&&n.feature&&n.feature.coordinates&&(n.feature.coordinates.draggable||n.feature.coordinates.resizable)&&-1!==o?(this.setCursor(this.cursors.dragStart),n.feature.coordinates.resizable?this.dragCoordinateResizeFeature.startDragging(r,o):this.dragCoordinate.startDragging(r,o),void e(!1)):n&&n.feature&&n.feature.draggable&&this.dragFeature.canDrag(t,r)?(this.setCursor(this.cursors.dragStart),this.dragFeature.startDragging(t,r),void e(!1)):void 0}}},i.onDrag=function(t,e){var i=this.selected[0];if(i){var n=this.store.getPropertiesCopy(i),r=this.flags[n.mode],o=!0===(r&&r.feature&&r.feature.selfIntersectable);if(this.dragEventCount++,this.dragEventCount%this.dragEventThrottle!=0){var s=this.validations[n.mode];return r&&r.feature&&r.feature.rotateable&&this.canRotate(t)?(e(!1),void this.rotateFeature.rotate(t,i,s)):r&&r.feature&&r.feature.scaleable&&this.canScale(t)?(e(!1),void this.scaleFeature.scale(t,i,s)):this.dragCoordinateResizeFeature.isDragging()&&r.feature&&r.feature.coordinates&&r.feature.coordinates.resizable?(e(!1),void this.dragCoordinateResizeFeature.drag(t,r.feature.coordinates.resizable,s)):void(this.dragCoordinate.isDragging()?this.dragCoordinate.drag(t,o,s):this.dragFeature.isDragging()?this.dragFeature.drag(t,s):e(!0))}}},i.onDragEnd=function(t,e){this.setCursor(this.cursors.dragEnd),(this.dragCoordinate.isDragging()||this.dragFeature.isDragging()||this.dragCoordinateResizeFeature.isDragging())&&this.onFinish(this.selected[0]),this.dragCoordinate.stopDragging(),this.dragFeature.stopDragging(),this.dragCoordinateResizeFeature.stopDragging(),this.rotateFeature.reset(),this.scaleFeature.reset(),e(!0)},i.onMouseMove=function(t){var e=this;if(this.selected.length){if(!this.dragFeature.isDragging()){var i=!1;this.midPoints.ids.forEach(function(n){if(!i){var r=e.store.getGeometryCopy(n);e.pixelDistance.measure(t,r.coordinates)<e.pointerDistance&&(i=!0)}});var n=!1;if(this.selectionPoints.ids.forEach(function(r){var o=e.store.getGeometryCopy(r);e.pixelDistance.measure(t,o.coordinates)<e.pointerDistance&&(i=!1,n=!0)}),i)this.setCursor(this.cursors.insertMidpoint);else{var r=this.featuresAtMouseEvent.find(t,!0).clickedFeature;this.setCursor(this.selected.length>0&&(r&&r.id===this.selected[0]||n)?this.cursors.pointerOver:"unset")}}}else this.setCursor("unset")},i.styleFeature=function(t){var e=n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0});if(t.properties.mode===this.mode&&"Point"===t.geometry.type){if(t.properties.selectionPoint)return e.pointColor=this.getHexColorStylingValue(this.styles.selectionPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.selectionPointOutlineColor,e.pointOutlineColor,t),e.pointWidth=this.getNumericStylingValue(this.styles.selectionPointWidth,e.pointWidth,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.selectionPointOutlineWidth,2,t),e.zIndex=30,e;if(t.properties.midPoint)return e.pointColor=this.getHexColorStylingValue(this.styles.midPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.midPointOutlineColor,e.pointOutlineColor,t),e.pointWidth=this.getNumericStylingValue(this.styles.midPointWidth,4,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.midPointOutlineWidth,2,t),e.zIndex=40,e}else if(t.properties[It]){if("Polygon"===t.geometry.type)return e.polygonFillColor=this.getHexColorStylingValue(this.styles.selectedPolygonColor,e.polygonFillColor,t),e.polygonOutlineWidth=this.getNumericStylingValue(this.styles.selectedPolygonOutlineWidth,e.polygonOutlineWidth,t),e.polygonOutlineColor=this.getHexColorStylingValue(this.styles.selectedPolygonOutlineColor,e.polygonOutlineColor,t),e.polygonFillOpacity=this.getNumericStylingValue(this.styles.selectedPolygonFillOpacity,e.polygonFillOpacity,t),e.zIndex=10,e;if("LineString"===t.geometry.type)return e.lineStringColor=this.getHexColorStylingValue(this.styles.selectedLineStringColor,e.lineStringColor,t),e.lineStringWidth=this.getNumericStylingValue(this.styles.selectedLineStringWidth,e.lineStringWidth,t),e.zIndex=10,e;if("Point"===t.geometry.type)return e.pointWidth=this.getNumericStylingValue(this.styles.selectedPointWidth,e.pointWidth,t),e.pointColor=this.getHexColorStylingValue(this.styles.selectedPointColor,e.pointColor,t),e.pointOutlineColor=this.getHexColorStylingValue(this.styles.selectedPointOutlineColor,e.pointOutlineColor,t),e.pointOutlineWidth=this.getNumericStylingValue(this.styles.selectedPointOutlineWidth,e.pointOutlineWidth,t),e.zIndex=10,e}return e},e}(Wt),Ae=/*#__PURE__*/function(t){function e(){for(var e,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];return(e=t.call.apply(t,[this].concat(n))||this).type=wt.Static,e.mode="static",e}r(e,t);var i=e.prototype;return i.start=function(){},i.stop=function(){},i.onKeyUp=function(){},i.onKeyDown=function(){},i.onClick=function(){},i.onDragStart=function(){},i.onDrag=function(){},i.onDragEnd=function(){},i.onMouseMove=function(){},i.cleanUp=function(){},i.styleFeature=function(){return n({},{polygonFillColor:"#3f97e0",polygonOutlineColor:"#3f97e0",polygonOutlineWidth:4,polygonFillOpacity:.3,pointColor:"#3f97e0",pointOutlineColor:"#ffffff",pointOutlineWidth:0,pointWidth:6,lineStringColor:"#3f97e0",lineStringWidth:4,zIndex:0})},e}(Lt);function Ge(t,e,i,n,r){for(;n>i;){if(n-i>600){var o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ge(t,e,Math.max(i,Math.floor(e-s*l/o+c)),Math.min(n,Math.floor(e+(o-s)*l/o+c)),r)}var d=t[e],h=i,u=n;for(je(t,i,e),r(t[n],d)>0&&je(t,i,n);h<u;){for(je(t,h,u),h++,u--;r(t[h],d)<0;)h++;for(;r(t[u],d)>0;)u--}0===r(t[i],d)?je(t,i,u):je(t,++u,n),u<=e&&(i=u+1),e<=u&&(n=u-1)}}function je(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function Re(t,e){Ne(t,0,t.children.length,e,t)}function Ne(t,e,i,n,r){r||(r=Ke([])),r.minX=Infinity,r.minY=Infinity,r.maxX=-Infinity,r.maxY=-Infinity;for(var o=e;o<i;o++){var s=t.children[o];Ve(r,t.leaf?n(s):s)}return r}function Ve(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function Te(t,e){return t.minX-e.minX}function ze(t,e){return t.minY-e.minY}function Ue(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function Xe(t){return t.maxX-t.minX+(t.maxY-t.minY)}function Ye(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function He(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function Ke(t){return{children:t,height:1,leaf:!0,minX:Infinity,minY:Infinity,maxX:-Infinity,maxY:-Infinity}}function Je(t,e,i,n,r){for(var o=[e,i];o.length;)if(!((i=o.pop())-(e=o.pop())<=n)){var s=e+Math.ceil((i-e)/n/2)*n;Ge(t,s,e,i,r),o.push(e,s,s,i)}}var qe=/*#__PURE__*/function(){function t(t){this._maxEntries=void 0,this._minEntries=void 0,this.data=void 0,this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}var e=t.prototype;return e.search=function(t){var e=this.data,i=[];if(!He(t,e))return i;for(var n=this.toBBox,r=[];e;){for(var o=0;o<e.children.length;o++){var s=e.children[o],a=e.leaf?n(s):s;He(t,a)&&(e.leaf?i.push(s):Ye(t,a)?this._all(s,i):r.push(s))}e=r.pop()}return i},e.collides=function(t){var e=this.data;if(He(t,e))for(var i=[];e;){for(var n=0;n<e.children.length;n++){var r=e.children[n],o=e.leaf?this.toBBox(r):r;if(He(t,o)){if(e.leaf||Ye(t,o))return!0;i.push(r)}}e=i.pop()}return!1},e.load=function(t){if(t.length<this._minEntries)for(var e=0;e<t.length;e++)this.insert(t[e]);else{var i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){var n=this.data;this.data=i,i=n}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i}},e.insert=function(t){this._insert(t,this.data.height-1)},e.clear=function(){this.data=Ke([])},e.remove=function(t){for(var e,i,n=this.data,r=this.toBBox(t),o=[],s=[],a=!1;n||o.length;){if(n||(n=o.pop(),i=o[o.length-1],e=s.pop(),a=!0),n.leaf){var l=n.children.indexOf(t);-1!==l&&(n.children.splice(l,1),o.push(n),this._condense(o))}a||n.leaf||!Ye(n,r)?i?(e++,n=i.children[e],a=!1):n=null:(o.push(n),s.push(e),e=0,i=n,n=n.children[0])}},e.toBBox=function(t){return t},e.compareMinX=function(t,e){return t.minX-e.minX},e.compareMinY=function(t,e){return t.minY-e.minY},e._all=function(t,e){for(var i=[];t;)t.leaf?e.push.apply(e,t.children):i.push.apply(i,t.children),t=i.pop();return e},e._build=function(t,e,i,n){var r,o=i-e+1,s=this._maxEntries;if(o<=s)return Re(r=Ke(t.slice(e,i+1)),this.toBBox),r;n||(n=Math.ceil(Math.log(o)/Math.log(s)),s=Math.ceil(o/Math.pow(s,n-1))),(r=Ke([])).leaf=!1,r.height=n;var a=Math.ceil(o/s),l=a*Math.ceil(Math.sqrt(s));Je(t,e,i,l,this.compareMinX);for(var c=e;c<=i;c+=l){var d=Math.min(c+l-1,i);Je(t,c,d,a,this.compareMinY);for(var h=c;h<=d;h+=a){var u=Math.min(h+a-1,d);r.children.push(this._build(t,h,u,n-1))}}return Re(r,this.toBBox),r},e._chooseSubtree=function(t,e,i,n){for(;n.push(e),!e.leaf&&n.length-1!==i;){for(var r=Infinity,o=Infinity,s=void 0,a=0;a<e.children.length;a++){var l=e.children[a],c=Ue(l),d=(h=t,u=l,(Math.max(u.maxX,h.maxX)-Math.min(u.minX,h.minX))*(Math.max(u.maxY,h.maxY)-Math.min(u.minY,h.minY))-c);d<o?(o=d,r=c<r?c:r,s=l):d===o&&c<r&&(r=c,s=l)}e=s||e.children[0]}var h,u;return e},e._insert=function(t,e,i){var n=i?t:this.toBBox(t),r=[],o=this._chooseSubtree(n,this.data,e,r);for(o.children.push(t),Ve(o,n);e>=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)},e._split=function(t,e){var i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);var o=this._chooseSplitIndex(i,r,n),s=Ke(i.children.splice(o,i.children.length-o));s.height=i.height,s.leaf=i.leaf,Re(i,this.toBBox),Re(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(i,s)},e._splitRoot=function(t,e){this.data=Ke([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Re(this.data,this.toBBox)},e._chooseSplitIndex=function(t,e,i){for(var n,r,o,s,a,l,c,d=Infinity,h=Infinity,u=e;u<=i-e;u++){var g=Ne(t,0,u,this.toBBox),p=Ne(t,u,i,this.toBBox),f=(r=g,o=p,s=Math.max(r.minX,o.minX),a=Math.max(r.minY,o.minY),l=Math.min(r.maxX,o.maxX),c=Math.min(r.maxY,o.maxY),Math.max(0,l-s)*Math.max(0,c-a)),y=Ue(g)+Ue(p);f<d?(d=f,n=u,h=y<h?y:h):f===d&&y<h&&(h=y,n=u)}return n||i-e},e._chooseSplitAxis=function(t,e,i){var n=t.leaf?this.compareMinX:Te,r=t.leaf?this.compareMinY:ze;this._allDistMargin(t,e,i,n)<this._allDistMargin(t,e,i,r)&&t.children.sort(n)},e._allDistMargin=function(t,e,i,n){t.children.sort(n);for(var r=this.toBBox,o=Ne(t,0,e,r),s=Ne(t,i-e,i,r),a=Xe(o)+Xe(s),l=e;l<i-e;l++){var c=t.children[l];Ve(o,t.leaf?r(c):c),a+=Xe(o)}for(var d=i-e-1;d>=e;d--){var h=t.children[d];Ve(s,t.leaf?r(h):h),a+=Xe(s)}return a},e._adjustParentBBoxes=function(t,e,i){for(var n=i;n>=0;n--)Ve(e[n],t)},e._condense=function(t){for(var e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children).splice(e.indexOf(t[i]),1):this.clear():Re(t[i],this.toBBox)},t}(),Ze=/*#__PURE__*/function(){function t(t){this.tree=void 0,this.idToNode=void 0,this.nodeToId=void 0,this.tree=new qe(t&&t.maxEntries?t.maxEntries:9),this.idToNode=new Map,this.nodeToId=new Map}var e=t.prototype;return e.setMaps=function(t,e){this.idToNode.set(t.id,e),this.nodeToId.set(e,t.id)},e.toBBox=function(t){var e,i=[],n=[];if("Polygon"===t.geometry.type)e=t.geometry.coordinates[0];else if("LineString"===t.geometry.type)e=t.geometry.coordinates;else{if("Point"!==t.geometry.type)throw new Error("Not a valid feature to turn into a bounding box");e=[t.geometry.coordinates]}for(var r=0;r<e.length;r++)n.push(e[r][1]),i.push(e[r][0]);var o=Math.min.apply(Math,n),s=Math.max.apply(Math,n);return{minX:Math.min.apply(Math,i),minY:o,maxX:Math.max.apply(Math,i),maxY:s}},e.insert=function(t){if(this.idToNode.get(String(t.id)))throw new Error("Feature already exists");var e=this.toBBox(t);this.setMaps(t,e),this.tree.insert(e)},e.load=function(t){var e=this,i=[],n=new Set;t.forEach(function(t){var r=e.toBBox(t);if(e.setMaps(t,r),n.has(String(t.id)))throw new Error("Duplicate feature ID found "+t.id);n.add(String(t.id)),i.push(r)}),this.tree.load(i)},e.update=function(t){this.remove(t.id);var e=this.toBBox(t);this.setMaps(t,e),this.tree.insert(e)},e.remove=function(t){var e=this.idToNode.get(t);if(!e)throw new Error(t+" not inserted into the spatial index");this.tree.remove(e)},e.clear=function(){this.tree.clear()},e.search=function(t){var e=this;return this.tree.search(this.toBBox(t)).map(function(t){return e.nodeToId.get(t)})},e.collides=function(t){return this.tree.collides(this.toBBox(t))},t}(),$e={getId:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)})},isValidId:function(t){return"string"==typeof t&&36===t.length}},Qe=/*#__PURE__*/function(){function t(t){this.idStrategy=void 0,this.tracked=void 0,this.spatialIndex=void 0,this.store=void 0,this._onChange=function(){},this.store={},this.spatialIndex=new Ze,this.tracked=!t||!1!==t.tracked,this.idStrategy=t&&t.idStrategy?t.idStrategy:$e}var e=t.prototype;return e.clone=function(t){return JSON.parse(JSON.stringify(t))},e.getId=function(){return this.idStrategy.getId()},e.has=function(t){return Boolean(this.store[t])},e.load=function(t,e){var i=this;if(0!==t.length){var n=this.clone(t);n.forEach(function(t){null==t.id&&(t.id=i.idStrategy.getId()),i.tracked&&(t.properties.createdAt?Ot(t.properties.createdAt):t.properties.createdAt=+new Date,t.properties.updatedAt?Ot(t.properties.updatedAt):t.properties.updatedAt=+new Date)});var r=[];n.forEach(function(t){var n=t.id;if(e&&!e(t))throw new Error("Feature is not "+n+" valid: "+JSON.stringify(t));if(i.has(n))throw new Error("Feature already exists with this id: "+n);i.store[n]=t,r.push(n)}),this.spatialIndex.load(n),this._onChange(r,"create")}},e.search=function(t,e){var i=this,n=this.spatialIndex.search(t).map(function(t){return i.store[t]});return this.clone(e?n.filter(e):n)},e.registerOnChange=function(t){this._onChange=function(e,i){t(e,i)}},e.getGeometryCopy=function(t){var e=this.store[t];if(!e)throw new Error("No feature with this id ("+t+"), can not get geometry copy");return this.clone(e.geometry)},e.getPropertiesCopy=function(t){var e=this.store[t];if(!e)throw new Error("No feature with this id ("+t+"), can not get properties copy");return this.clone(e.properties)},e.updateProperty=function(t){var e=this,i=[];t.forEach(function(t){var n=t.id,r=t.property,o=t.value,s=e.store[n];if(!s)throw new Error("No feature with this ("+n+"), can not update geometry");i.push(n),s.properties[r]=o,e.tracked&&(s.properties.updatedAt=+new Date)}),this._onChange&&this._onChange(i,"update")},e.updateGeometry=function(t){var e=this,i=[];t.forEach(function(t){var n=t.id,r=t.geometry;i.push(n);var o=e.store[n];if(!o)throw new Error("No feature with this ("+n+"), can not update geometry");o.geometry=e.clone(r),e.spatialIndex.update(o),e.tracked&&(o.properties.updatedAt=+new Date)}),this._onChange&&this._onChange(i,"update")},e.create=function(t){var e=this,i=[];return t.forEach(function(t){var r,o=t.geometry,s=t.properties,a=n({},s);e.tracked&&(r=+new Date,s?(a.createdAt="number"==typeof s.createdAt?s.createdAt:r,a.updatedAt="number"==typeof s.updatedAt?s.updatedAt:r):a={createdAt:r,updatedAt:r});var l=e.getId(),c={id:l,type:"Feature",geometry:o,properties:a};e.store[l]=c,e.spatialIndex.insert(c),i.push(l)}),this._onChange&&this._onChange([].concat(i),"create"),i},e.delete=function(t){var e=this;t.forEach(function(t){if(!e.store[t])throw new Error("No feature with this id, can not delete");delete e.store[t],e.spatialIndex.remove(t)}),this._onChange&&this._onChange([].concat(t),"delete")},e.copyAll=function(){var t=this;return this.clone(Object.keys(this.store).map(function(e){return t.store[e]}))},e.clear=function(){this.store={},this.spatialIndex.clear()},e.size=function(){return Object.keys(this.store).length},t}();function ti(t){var e=t.coordinates,i=0;if(e&&e.length>0){i+=Math.abs(ni(e[0]));for(var n=1;n<e.length;n++)i-=Math.abs(ni(e[n]))}return i}var ei=20294876564838.72,ii=Math.PI/180;function ni(t){var e=t.length;if(e<=2)return 0;for(var i=0,n=0;n<e;)i+=(t[n+2>=e?(n+2)%e:n+2][0]*ii-t[n][0]*ii)*Math.sin(t[n+1===e?0:n+1][1]*ii),n++;return i*ei}var ri={TerraDrawBaseDrawMode:Lt,TerraDrawBaseAdapter:c};exports.TerraDraw=/*#__PURE__*/function(){function t(t){var e=this;this._modes=void 0,this._mode=void 0,this._adapter=void 0,this._enabled=!1,this._store=void 0,this._eventListeners=void 0,this._instanceSelectMode=void 0,this._adapter=t.adapter,this._mode=new Ae;var i=new Set,r=t.modes.reduce(function(t,e){if(i.has(e.mode))throw new Error("There is already a "+e.mode+" mode provided");return i.add(e.mode),t[e.mode]=e,t},{}),o=Object.keys(r);if(0===o.length)throw new Error("No modes provided");o.forEach(function(t){if(r[t].type===wt.Select){if(e._instanceSelectMode)throw new Error("only one type of select mode can be provided");e._instanceSelectMode=t}}),this._modes=n({},r,{static:this._mode}),this._eventListeners={change:[],select:[],deselect:[],finish:[],ready:[]},this._store=new Qe({tracked:!!t.tracked,idStrategy:t.idStrategy?t.idStrategy:void 0});var s=function(t){var i=[],n=e._store.copyAll().filter(function(e){return!t.includes(e.id)||(i.push(e),!1)});return{changed:i,unchanged:n}},a=function(t){e._enabled&&e._eventListeners.finish.forEach(function(e){e(t)})},l=function(t,i){if(e._enabled){e._eventListeners.change.forEach(function(e){e(t,i)});var n=s(t),r=n.changed,o=n.unchanged;"create"===i?e._adapter.render({created:r,deletedIds:[],unchanged:o,updated:[]},e.getModeStyles()):"update"===i?e._adapter.render({created:[],deletedIds:[],unchanged:o,updated:r},e.getModeStyles()):"delete"===i?e._adapter.render({created:[],deletedIds:t,unchanged:o,updated:[]},e.getModeStyles()):"styling"===i&&e._adapter.render({created:[],deletedIds:[],unchanged:o,updated:[]},e.getModeStyles())}},c=function(t){if(e._enabled){e._eventListeners.select.forEach(function(e){e(t)});var i=s([t]);e._adapter.render({created:[],deletedIds:[],unchanged:i.unchanged,updated:i.changed},e.getModeStyles())}},d=function(t){if(e._enabled){e._eventListeners.deselect.forEach(function(t){t()});var i=s([t]),n=i.changed;n&&e._adapter.render({created:[],deletedIds:[],unchanged:i.unchanged,updated:n},e.getModeStyles())}};Object.keys(this._modes).forEach(function(t){e._modes[t].register({mode:t,store:e._store,setCursor:e._adapter.setCursor.bind(e._adapter),project:e._adapter.project.bind(e._adapter),unproject:e._adapter.unproject.bind(e._adapter),setDoubleClickToZoom:e._adapter.setDoubleClickToZoom.bind(e._adapter),onChange:l,onSelect:c,onDeselect:d,onFinish:a,coordinatePrecision:e._adapter.getCoordinatePrecision()})})}var e=t.prototype;return e.checkEnabled=function(){if(!this._enabled)throw new Error("Terra Draw is not enabled")},e.getModeStyles=function(){var t=this,e={};return Object.keys(this._modes).forEach(function(i){e[i]=function(e){return t._instanceSelectMode&&e.properties[It]?t._modes[t._instanceSelectMode].styleFeature.bind(t._modes[t._instanceSelectMode])(e):t._modes[i].styleFeature.bind(t._modes[i])(e)}}),e},e.featuresAtLocation=function(t,e){var i=t.lng,n=t.lat,r=e&&void 0!==e.pointerDistance?e.pointerDistance:30,o=!e||void 0===e.ignoreSelectFeatures||e.ignoreSelectFeatures,s=this._adapter.unproject.bind(this._adapter),l=this._adapter.project.bind(this._adapter),c=l(i,n),d=ie({unproject:s,point:c,pointerDistance:r});return this._store.search(d).filter(function(t){if(o&&(t.properties[Dt]||t.properties.selectionPoint))return!1;if("Point"===t.geometry.type){var e=t.geometry.coordinates,s=l(e[0],e[1]);return a(c,s)<r}if("LineString"===t.geometry.type){for(var d=t.geometry.coordinates,h=0;h<d.length-1;h++){var u=d[h],g=d[h+1];if(_e(c,l(u[0],u[1]),l(g[0],g[1]))<r)return!0}return!1}return!!me([i,n],t.geometry.coordinates)||void 0})},e.getSelectMode=function(){if(this.checkEnabled(),!this._instanceSelectMode)throw new Error("No select mode defined in instance");return this.getMode()!==this._instanceSelectMode&&this.setMode(this._instanceSelectMode),this._modes[this._instanceSelectMode]},e.setModeStyles=function(t,e){if(this.checkEnabled(),!this._modes[t])throw new Error("No mode with this name present");this._modes[t].styles=e},e.getSnapshot=function(){return this._store.copyAll()},e.clear=function(){this.checkEnabled(),this._adapter.clear()},e.getMode=function(){return this._mode.mode},e.setMode=function(t){if(this.checkEnabled(),!this._modes[t])throw new Error("No mode with this name present");this._mode.stop(),this._mode=this._modes[t],this._mode.start()},e.removeFeatures=function(t){this.checkEnabled(),this._store.delete(t)},e.selectFeature=function(t){this.getSelectMode().selectFeature(t)},e.deselectFeature=function(t){this.getSelectMode().deselectFeature(t)},e.getFeatureId=function(){return this._store.getId()},e.hasFeature=function(t){return this._store.has(t)},e.addFeatures=function(t){var e=this;this.checkEnabled(),0!==t.length&&this._store.load(t,function(t){if(Boolean(t&&"object"==typeof t&&"properties"in t&&"object"==typeof t.properties&&null!==t.properties&&"mode"in t.properties)){var i=e._modes[t.properties.mode];return!!i&&i.validateFeature.bind(i)(t)}return!1})},e.start=function(){var t=this;this._enabled=!0,this._adapter.register({onReady:function(){t._eventListeners.ready.forEach(function(t){t()})},getState:function(){return t._mode.state},onClick:function(e){t._mode.onClick(e)},onMouseMove:function(e){t._mode.onMouseMove(e)},onKeyDown:function(e){t._mode.onKeyDown(e)},onKeyUp:function(e){t._mode.onKeyUp(e)},onDragStart:function(e,i){t._mode.onDragStart(e,i)},onDrag:function(e,i){t._mode.onDrag(e,i)},onDragEnd:function(e,i){t._mode.onDragEnd(e,i)},onClear:function(){t._mode.cleanUp(),t._store.clear()}})},e.getFeaturesAtLngLat=function(t,e){return this.featuresAtLocation({lng:t.lng,lat:t.lat},e)},e.getFeaturesAtPointerEvent=function(t,e){var i=this._adapter.getLngLatFromEvent.bind(this._adapter)(t);return null===i?[]:this.featuresAtLocation(i,e)},e.stop=function(){this._enabled=!1,this._adapter.unregister()},e.on=function(t,e){var i=this._eventListeners[t];i.includes(e)||i.push(e)},e.off=function(t,e){var i=this._eventListeners[t];i.includes(e)&&i.splice(i.indexOf(e),1)},i(t,[{key:"enabled",get:function(){return this._enabled},set:function(t){throw new Error("Enabled is read only")}}]),t}(),exports.TerraDrawArcGISMapsSDKAdapter=Et,exports.TerraDrawCircleMode=Yt,exports.TerraDrawExtend=ri,exports.TerraDrawFreehandMode=Ht,exports.TerraDrawGoogleMapsAdapter=d,exports.TerraDrawGreatCircleMode=re,exports.TerraDrawLeafletAdapter=h,exports.TerraDrawLineStringMode=se,exports.TerraDrawMapLibreGLAdapter=g,exports.TerraDrawMapboxGLAdapter=u,exports.TerraDrawOpenLayersAdapter=Mt,exports.TerraDrawPointMode=le,exports.TerraDrawPolygonMode=he,exports.TerraDrawRectangleMode=ue,exports.TerraDrawRenderMode=ge,exports.TerraDrawSelectMode=Be,exports.ValidateMaxSizeSquareMeters=function(t,e){return ti(t)<e},exports.ValidateMinSizeSquareMeters=function(t,e){return ti(t)>e};
|
|
2
2
|
//# sourceMappingURL=terra-draw.cjs.map
|