@defra/interactive-map 0.0.43-alpha → 0.0.44-alpha
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/css/index.css +1 -1
- package/dist/esm/im-core.js +1 -1
- package/dist/esm/im-shell.js +1 -1
- package/dist/umd/im-core.js +1 -1
- package/dist/umd/index.js +1 -1
- package/docs/api.md +16 -8
- package/docs/plugins/draw.md +1 -1
- package/package.json +1 -1
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
- package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/im-map-styles-plugin.js +1 -1
- package/plugins/beta/map-styles/dist/umd/index.js +1 -1
- package/plugins/datasets/dist/css/index.css +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/src/components/LayersMenu/Layers.module.scss +1 -0
- package/plugins/datasets/src/initialise/DatasetsInit.jsx +2 -2
- package/plugins/datasets/src/initialise/DatasetsInit.test.jsx +6 -5
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/esm/index.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +1 -1
- package/plugins/draw/dist/umd/im-draw-plugin.js +1 -1
- package/plugins/draw/dist/umd/index.js +1 -1
- package/plugins/draw/src/DrawInit.jsx +31 -26
- package/plugins/draw/src/DrawInit.test.jsx +55 -12
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +113 -114
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +82 -9
- package/plugins/draw/src/adapters/maplibre/drawEvents.js +3 -1
- package/plugins/draw/src/adapters/maplibre/modes/createDrawMode.test.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/__helpers__/harness.js +18 -9
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +9 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +11 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.js +8 -2
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.test.js +35 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.js +29 -19
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.test.js +17 -2
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.js +35 -29
- package/plugins/draw/src/adapters/maplibre/modes/drawPointMode.test.js +24 -6
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/keyboardHandlers.js +22 -20
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode/pointOperations.js +1 -1
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/editPointMode.test.js +3 -3
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.js +31 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.test.js +8 -1
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.js +38 -30
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.test.js +20 -3
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.js +5 -5
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.test.js +2 -2
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +3 -3
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +7 -7
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.js +4 -4
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.test.js +14 -14
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.js +12 -32
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.test.js +10 -10
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +48 -22
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.test.js +74 -6
- package/plugins/draw/src/adapters/maplibre/utils/snapMovement.js +2 -2
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +6 -0
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +9 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +15 -2
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +27 -1
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +1 -1
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.js +31 -17
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.test.js +55 -1
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.js +13 -7
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.test.js +7 -15
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +36 -4
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +41 -1
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.js +35 -25
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.test.js +40 -2
- package/plugins/draw/src/adapters/openlayers/edit/nudge.js +2 -2
- package/plugins/draw/src/adapters/openlayers/edit/nudge.test.js +2 -2
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.js +32 -57
- package/plugins/draw/src/adapters/openlayers/point/drawPointMode.test.js +14 -13
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.js +1 -1
- package/plugins/draw/src/adapters/openlayers/point/editPointMode.test.js +17 -1
- package/plugins/draw/src/events.js +4 -4
- package/plugins/draw/src/events.test.js +1 -1
- package/plugins/draw/src/hooks/useSpatialList.js +180 -0
- package/plugins/draw/src/hooks/useSpatialList.test.js +339 -0
- package/plugins/draw/src/utils/spatial.js +1 -31
- package/plugins/draw/src/utils/spatial.test.js +1 -24
- package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
- package/plugins/interact/dist/umd/index.js +1 -1
- package/plugins/interact/src/InteractInit.jsx +2 -2
- package/plugins/interact/src/InteractInit.test.js +3 -3
- package/plugins/interact/src/events.js +5 -0
- package/plugins/interact/src/hooks/useAttachEvents.js +20 -0
- package/plugins/interact/src/hooks/useAttachEvents.test.js +44 -1
- package/plugins/interact/src/hooks/useCrossHairVisibility.js +4 -4
- package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +7 -7
- package/plugins/interact/src/hooks/{useMapItemList.js → useSpatialList.js} +87 -52
- package/plugins/interact/src/hooks/{useMapItemList.test.js → useSpatialList.test.js} +152 -71
- package/plugins/interact/src/manifest.js +12 -1
- package/plugins/interact/src/manifest.test.js +20 -0
- package/plugins/interact/src/utils/spatial.js +1 -1
- package/providers/beta/openlayers/src/utils/queryFeatures.js +1 -1
- package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
- package/providers/maplibre/dist/umd/index.js +1 -1
- package/providers/maplibre/src/utils/labels.js +2 -2
- package/providers/maplibre/src/utils/labels.test.js +5 -5
- package/providers/maplibre/src/utils/spatial.js +0 -57
- package/providers/maplibre/src/utils/spatial.test.js +0 -27
- package/src/App/components/CrossHair/CrossHair.jsx +10 -4
- package/src/App/components/CrossHair/CrossHair.module.scss +16 -12
- package/src/App/components/CrossHair/CrossHair.test.jsx +9 -4
- package/src/App/components/Hints/Hints.jsx +3 -3
- package/src/App/components/Hints/Hints.test.jsx +3 -3
- package/src/App/components/MapButton/MapButton.module.scss +1 -2
- package/src/App/components/{MoveControls/MoveControls.jsx → MapControls/MapControls.jsx} +10 -10
- package/src/App/components/{MoveControls/MoveControls.module.scss → MapControls/MapControls.module.scss} +25 -25
- package/src/App/components/{MoveControls/MoveControls.test.jsx → MapControls/MapControls.test.jsx} +48 -48
- package/src/App/components/Markers/Markers.jsx +2 -2
- package/src/App/components/Markers/Markers.test.jsx +3 -3
- package/src/App/components/Markers/SymbolMarker.test.jsx +2 -2
- package/src/App/components/Viewport/MapStatus.jsx +1 -1
- package/src/App/components/Viewport/SpatialList.jsx +47 -0
- package/src/App/components/Viewport/{Features.module.scss → SpatialList.module.scss} +3 -3
- package/src/App/components/Viewport/{Features.test.jsx → SpatialList.test.jsx} +60 -43
- package/src/App/components/Viewport/Viewport.jsx +20 -10
- package/src/App/components/Viewport/Viewport.test.jsx +18 -2
- package/src/App/hooks/useCrossHairAPI.js +5 -5
- package/src/App/hooks/useCrossHairAPI.test.js +5 -5
- package/src/App/hooks/useHintsAPI.js +5 -5
- package/src/App/hooks/useSpatialListFocus.js +296 -0
- package/src/App/hooks/{useFeatureFocus.test.js → useSpatialListFocus.test.js} +318 -163
- package/src/App/hooks/useSpatialListItems.js +51 -0
- package/src/App/hooks/useSpatialListItems.test.js +217 -0
- package/src/App/initialiseApp.js +6 -3
- package/src/App/initialiseApp.test.js +11 -0
- package/src/App/registry/spatialListRegistry.js +104 -0
- package/src/App/registry/spatialListRegistry.test.js +218 -0
- package/src/App/store/AppProvider.jsx +3 -2
- package/src/config/appConfig.js +14 -14
- package/src/config/appConfig.test.js +19 -19
- package/src/config/defaults.js +2 -2
- package/src/config/events.js +8 -8
- package/src/scss/main.scss +2 -2
- package/src/test-utils.js +8 -0
- package/src/types.js +11 -9
- package/src/utils/findNearestItemInDirection.js +29 -0
- package/src/utils/findNearestItemInDirection.test.js +67 -0
- package/src/utils/globalAltShortcuts.js +12 -0
- package/src/utils/globalAltShortcuts.test.js +27 -0
- package/src/utils/spatialNavigate.js +49 -0
- package/src/utils/spatialNavigate.test.js +42 -0
- package/src/App/components/Viewport/Features.jsx +0 -49
- package/src/App/hooks/useFeatureFocus.js +0 -257
- package/src/App/hooks/useFeatureItems.js +0 -39
- package/src/App/hooks/useFeatureItems.test.js +0 -155
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see im-draw-ml-adapter.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[356],{778(e,t,r){var n=r(628);function o(e){var t=0;if(e&&e.length>0){t+=Math.abs(i(e[0]));for(var r=1;r<e.length;r++)t-=Math.abs(i(e[r]))}return t}function i(e){var t,r,o,i,s,u,c=0,l=e.length;if(l>2){for(u=0;u<l;u++)u===l-2?(o=l-2,i=l-1,s=0):u===l-1?(o=l-1,i=0,s=1):(o=u,i=u+1,s=u+2),t=e[o],r=e[i],c+=(a(e[s][0])-a(t[0]))*Math.sin(a(r[1]));c=c*n.RADIUS*n.RADIUS/2}return c}function a(e){return e*Math.PI/180}e.exports.geometry=function e(t){var r,n=0;switch(t.type){case"Polygon":return o(t.coordinates);case"MultiPolygon":for(r=0;r<t.coordinates.length;r++)n+=o(t.coordinates[r]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(r=0;r<t.geometries.length;r++)n+=e(t.geometries[r]);return n}},e.exports.ring=i},186(e){e.exports=function(e){if(!e||!e.type)return null;var r=t[e.type];return r?"geometry"===r?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:e}]}:"feature"===r?{type:"FeatureCollection",features:[e]}:"featurecollection"===r?e:void 0:null};var t={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},17(e){"use strict";e.exports=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,o,i;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(o=n;0!==o--;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(i=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(o=n;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=n;0!==o--;){var a=i[o];if(!e(t[a],r[a]))return!1}return!0}return t!=t&&r!=r}},945(e,t,r){var n=r(341),o=r(339),i=r(609),a=r(368).Ay,s=i.featureEach,u=(i.coordEach,o.polygon,o.featureCollection);function c(e){var t=new n(e);return t.insert=function(e){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:a(e),n.prototype.insert.call(this,e)},t.load=function(e){var t=[];return Array.isArray(e)?e.forEach(function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:a(e),t.push(e)}):s(e,function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:a(e),t.push(e)}),n.prototype.load.call(this,t)},t.remove=function(e,t){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:a(e),n.prototype.remove.call(this,e,t)},t.clear=function(){return n.prototype.clear.call(this)},t.search=function(e){var t=n.prototype.search.call(this,this.toBBox(e));return u(t)},t.collides=function(e){return n.prototype.collides.call(this,this.toBBox(e))},t.all=function(){var e=n.prototype.all.call(this);return u(e)},t.toJSON=function(){return n.prototype.toJSON.call(this)},t.fromJSON=function(e){return n.prototype.fromJSON.call(this,e)},t.toBBox=function(e){var t;if(e.bbox)t=e.bbox;else if(Array.isArray(e)&&4===e.length)t=e;else if(Array.isArray(e)&&6===e.length)t=[e[0],e[1],e[3],e[4]];else if("Feature"===e.type)t=a(e);else{if("FeatureCollection"!==e.type)throw new Error("invalid geojson");t=a(e)}return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}},t}e.exports=c,e.exports.default=c},339(e,t){"use strict";function r(e,t,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function n(e,t,n){if(void 0===n&&(n={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!p(e[0])||!p(e[1]))throw new Error("coordinates must contain numbers");return r({type:"Point",coordinates:e},t,n)}function o(e,t,n){void 0===n&&(n={});for(var o=0,i=e;o<i.length;o++){var a=i[o];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return r({type:"Polygon",coordinates:e},t,n)}function i(e,t,n){if(void 0===n&&(n={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return r({type:"LineString",coordinates:e},t,n)}function a(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function s(e,t,n){return void 0===n&&(n={}),r({type:"MultiLineString",coordinates:e},t,n)}function u(e,t,n){return void 0===n&&(n={}),r({type:"MultiPoint",coordinates:e},t,n)}function c(e,t,n){return void 0===n&&(n={}),r({type:"MultiPolygon",coordinates:e},t,n)}function l(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e*n}function d(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e/n}function f(e){return e%(2*Math.PI)*180/Math.PI}function p(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.earthRadius=6371008.8,t.factors={centimeters:100*t.earthRadius,centimetres:100*t.earthRadius,degrees:t.earthRadius/111325,feet:3.28084*t.earthRadius,inches:39.37*t.earthRadius,kilometers:t.earthRadius/1e3,kilometres:t.earthRadius/1e3,meters:t.earthRadius,metres:t.earthRadius,miles:t.earthRadius/1609.344,millimeters:1e3*t.earthRadius,millimetres:1e3*t.earthRadius,nauticalmiles:t.earthRadius/1852,radians:1,yards:1.0936*t.earthRadius},t.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/t.earthRadius,yards:1.0936133},t.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046},t.feature=r,t.geometry=function(e,t,r){switch(void 0===r&&(r={}),e){case"Point":return n(t).geometry;case"LineString":return i(t).geometry;case"Polygon":return o(t).geometry;case"MultiPoint":return u(t).geometry;case"MultiLineString":return s(t).geometry;case"MultiPolygon":return c(t).geometry;default:throw new Error(e+" is invalid")}},t.point=n,t.points=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return n(e,t)}),r)},t.polygon=o,t.polygons=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return o(e,t)}),r)},t.lineString=i,t.lineStrings=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return i(e,t)}),r)},t.featureCollection=a,t.multiLineString=s,t.multiPoint=u,t.multiPolygon=c,t.geometryCollection=function(e,t,n){return void 0===n&&(n={}),r({type:"GeometryCollection",geometries:e},t,n)},t.round=function(e,t){if(void 0===t&&(t=0),t&&!(t>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,t||0);return Math.round(e*r)/r},t.radiansToLength=l,t.lengthToRadians=d,t.lengthToDegrees=function(e,t){return f(d(e,t))},t.bearingToAzimuth=function(e){var t=e%360;return t<0&&(t+=360),t},t.radiansToDegrees=f,t.degreesToRadians=function(e){return e%360*Math.PI/180},t.convertLength=function(e,t,r){if(void 0===t&&(t="kilometers"),void 0===r&&(r="kilometers"),!(e>=0))throw new Error("length must be a positive number");return l(d(e,t),r)},t.convertArea=function(e,r,n){if(void 0===r&&(r="meters"),void 0===n&&(n="kilometers"),!(e>=0))throw new Error("area must be a positive number");var o=t.areaFactors[r];if(!o)throw new Error("invalid original units");var i=t.areaFactors[n];if(!i)throw new Error("invalid final units");return e/o*i},t.isNumber=p,t.isObject=function(e){return!!e&&e.constructor===Object},t.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(function(e){if(!p(e))throw new Error("bbox must only contain numbers")})},t.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},609(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(339);function o(e,t,r){if(null!==e)for(var n,i,a,s,u,c,l,d,f=0,p=0,h=e.type,y="FeatureCollection"===h,m="Feature"===h,g=y?e.features.length:1,v=0;v<g;v++){u=(d=!!(l=y?e.features[v].geometry:m?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var S=0,w=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var P=s.type;switch(f=!r||"Polygon"!==P&&"MultiPolygon"!==P?0:1,P){case null:break;case"Point":if(!1===t(c,p,v,S,w))return!1;p++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],p,v,S,w))return!1;p++,"MultiPoint"===P&&S++}"LineString"===P&&S++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-f;i++){if(!1===t(c[n][i],p,v,S,w))return!1;p++}"MultiLineString"===P&&S++,"Polygon"===P&&w++}"Polygon"===P&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(w=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-f;a++){if(!1===t(c[n][i][a],p,v,S,w))return!1;p++}w++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,f=0,p="FeatureCollection"===e.type,h="Feature"===e.type,y=p?e.features.length:1;for(r=0;r<y;r++){for(s=p?e.features[r].geometry:h?e.geometry:e,c=p?e.features[r].properties:h?e.properties:{},l=p?e.features[r].bbox:h?e.bbox:void 0,d=p?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,f,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],f,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,f,c,l,d))return!1;f++}}function u(e,t){s(e,function(e,r,o,i,a){var s,u=null===e?null:e.type;switch(u){case null:case"Point":case"LineString":case"Polygon":return!1!==t(n.feature(e,o,{bbox:i,id:a}),r,0)&&void 0}switch(u){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<e.coordinates.length;c++){var l={type:s,coordinates:e.coordinates[c]};if(!1===t(n.feature(l,o),r,c))return!1}})}function c(e,t){u(e,function(e,r,i){var a=0;if(e.geometry){var s=e.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var u,c=0,l=0,d=0;return!1!==o(e,function(o,s,f,p,h){if(void 0===u||r>c||p>l||h>d)return u=o,c=r,l=p,d=h,void(a=0);var y=n.lineString([u,o],e.properties);if(!1===t(y,r,i,h,a))return!1;a++,u=o})&&void 0}}})}function l(e,t){if(!e)throw new Error("geojson is required");u(e,function(e,r,o){if(null!==e.geometry){var i=e.geometry.type,a=e.geometry.coordinates;switch(i){case"LineString":if(!1===t(e,r,o,0,0))return!1;break;case"Polygon":for(var s=0;s<a.length;s++)if(!1===t(n.lineString(a[s],e.properties),r,o,s))return!1}}})}t.coordAll=function(e){var t=[];return o(e,function(e){t.push(e)}),t},t.coordEach=o,t.coordReduce=function(e,t,r,n){var i=r;return o(e,function(e,n,o,a,s){i=0===n&&void 0===r?e:t(i,e,n,o,a,s)},n),i},t.featureEach=a,t.featureReduce=function(e,t,r){var n=r;return a(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.findPoint=function(e,t){if(t=t||{},!n.isObject(t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.coordIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":return n.point(c,u,t);case"MultiPoint":return i<0&&(i=c.length+i),n.point(c[i],u,t);case"LineString":return s<0&&(s=c.length+s),n.point(c[s],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s),n.point(c[a][s],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),n.point(c[i][s],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s),n.point(c[i][a][s],u,t)}throw new Error("geojson is invalid")},t.findSegment=function(e,t){if(t=t||{},!n.isObject(t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.segmentIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),n.lineString([c[s],c[s+1]],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s-1),n.lineString([c[a][s],c[a][s+1]],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),n.lineString([c[i][s],c[i][s+1]],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s-1),n.lineString([c[i][a][s],c[i][a][s+1]],u,t)}throw new Error("geojson is invalid")},t.flattenEach=u,t.flattenReduce=function(e,t,r){var n=r;return u(e,function(e,o,i){n=0===o&&0===i&&void 0===r?e:t(n,e,o,i)}),n},t.geomEach=s,t.geomReduce=function(e,t,r){var n=r;return s(e,function(e,o,i,a,s){n=0===o&&void 0===r?e:t(n,e,o,i,a,s)}),n},t.lineEach=l,t.lineReduce=function(e,t,r){var n=r;return l(e,function(e,o,i,a){n=0===o&&void 0===r?e:t(n,e,o,i,a)}),n},t.propEach=i,t.propReduce=function(e,t,r){var n=r;return i(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.segmentEach=c,t.segmentReduce=function(e,t,r){var n=r,o=!1;return c(e,function(e,i,a,s,u){n=!1===o&&void 0===r?e:t(n,e,i,a,s,u),o=!0}),n}},341(e){e.exports=function(){"use strict";function e(e,n,o,i,a){!function e(r,n,o,i,a){for(;i>o;){if(i-o>600){var s=i-o+1,u=n-o+1,c=Math.log(s),l=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*l*(s-l)/s)*(u-s/2<0?-1:1);e(r,n,Math.max(o,Math.floor(n-u*l/s+d)),Math.min(i,Math.floor(n+(s-u)*l/s+d)),a)}var f=r[n],p=o,h=i;for(t(r,o,n),a(r[i],f)>0&&t(r,o,i);p<h;){for(t(r,p,h),p++,h--;a(r[p],f)<0;)p++;for(;a(r[h],f)>0;)h--}0===a(r[o],f)?t(r,o,h):t(r,++h,i),h<=n&&(o=h+1),n<=h&&(i=h-1)}}(e,n,o||0,i||e.length-1,a||r)}function t(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function r(e,t){return e<t?-1:e>t?1:0}var n=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(e,t,r){if(!r)return t.indexOf(e);for(var n=0;n<t.length;n++)if(r(e,t[n]))return n;return-1}function i(e,t){a(e,0,e.children.length,t,e)}function a(e,t,r,n,o){o||(o=h(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(var i=t;i<r;i++){var a=e.children[i];s(o,e.leaf?n(a):a)}return o}function s(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function u(e,t){return e.minX-t.minX}function c(e,t){return e.minY-t.minY}function l(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function d(e){return e.maxX-e.minX+(e.maxY-e.minY)}function f(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function p(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function h(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function y(t,r,n,o,i){for(var a=[r,n];a.length;)if(!((n=a.pop())-(r=a.pop())<=o)){var s=r+Math.ceil((n-r)/o/2)*o;e(t,s,r,n,i),a.push(r,s,s,n)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(e){var t=this.data,r=[];if(!p(e,t))return r;for(var n=this.toBBox,o=[];t;){for(var i=0;i<t.children.length;i++){var a=t.children[i],s=t.leaf?n(a):a;p(e,s)&&(t.leaf?r.push(a):f(e,s)?this._all(a,r):o.push(a))}t=o.pop()}return r},n.prototype.collides=function(e){var t=this.data;if(!p(e,t))return!1;for(var r=[];t;){for(var n=0;n<t.children.length;n++){var o=t.children[n],i=t.leaf?this.toBBox(o):o;if(p(e,i)){if(t.leaf||f(e,i))return!0;r.push(o)}}t=r.pop()}return!1},n.prototype.load=function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0;t<e.length;t++)this.insert(e[t]);return this}var r=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){var n=this.data;this.data=r,r=n}this._insert(r,this.data.height-r.height-1,!0)}else this.data=r;return this},n.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},n.prototype.clear=function(){return this.data=h([]),this},n.prototype.remove=function(e,t){if(!e)return this;for(var r,n,i,a=this.data,s=this.toBBox(e),u=[],c=[];a||u.length;){if(a||(a=u.pop(),n=u[u.length-1],r=c.pop(),i=!0),a.leaf){var l=o(e,a.children,t);if(-1!==l)return a.children.splice(l,1),u.push(a),this._condense(u),this}i||a.leaf||!f(a,s)?n?(r++,a=n.children[r],i=!1):a=null:(u.push(a),c.push(r),r=0,n=a,a=a.children[0])}return this},n.prototype.toBBox=function(e){return e},n.prototype.compareMinX=function(e,t){return e.minX-t.minX},n.prototype.compareMinY=function(e,t){return e.minY-t.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(e){return this.data=e,this},n.prototype._all=function(e,t){for(var r=[];e;)e.leaf?t.push.apply(t,e.children):r.push.apply(r,e.children),e=r.pop();return t},n.prototype._build=function(e,t,r,n){var o,a=r-t+1,s=this._maxEntries;if(a<=s)return i(o=h(e.slice(t,r+1)),this.toBBox),o;n||(n=Math.ceil(Math.log(a)/Math.log(s)),s=Math.ceil(a/Math.pow(s,n-1))),(o=h([])).leaf=!1,o.height=n;var u=Math.ceil(a/s),c=u*Math.ceil(Math.sqrt(s));y(e,t,r,c,this.compareMinX);for(var l=t;l<=r;l+=c){var d=Math.min(l+c-1,r);y(e,l,d,u,this.compareMinY);for(var f=l;f<=d;f+=u){var p=Math.min(f+u-1,d);o.children.push(this._build(e,f,p,n-1))}}return i(o,this.toBBox),o},n.prototype._chooseSubtree=function(e,t,r,n){for(;n.push(t),!t.leaf&&n.length-1!==r;){for(var o=1/0,i=1/0,a=void 0,s=0;s<t.children.length;s++){var u=t.children[s],c=l(u),d=(f=e,p=u,(Math.max(p.maxX,f.maxX)-Math.min(p.minX,f.minX))*(Math.max(p.maxY,f.maxY)-Math.min(p.minY,f.minY))-c);d<i?(i=d,o=c<o?c:o,a=u):d===i&&c<o&&(o=c,a=u)}t=a||t.children[0]}var f,p;return t},n.prototype._insert=function(e,t,r){var n=r?e:this.toBBox(e),o=[],i=this._chooseSubtree(n,this.data,t,o);for(i.children.push(e),s(i,n);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(n,o,t)},n.prototype._split=function(e,t){var r=e[t],n=r.children.length,o=this._minEntries;this._chooseSplitAxis(r,o,n);var a=this._chooseSplitIndex(r,o,n),s=h(r.children.splice(a,r.children.length-a));s.height=r.height,s.leaf=r.leaf,i(r,this.toBBox),i(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(r,s)},n.prototype._splitRoot=function(e,t){this.data=h([e,t]),this.data.height=e.height+1,this.data.leaf=!1,i(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(e,t,r){for(var n,o,i,s,u,c,d,f=1/0,p=1/0,h=t;h<=r-t;h++){var y=a(e,0,h,this.toBBox),m=a(e,h,r,this.toBBox),g=(o=y,i=m,void 0,void 0,void 0,void 0,s=Math.max(o.minX,i.minX),u=Math.max(o.minY,i.minY),c=Math.min(o.maxX,i.maxX),d=Math.min(o.maxY,i.maxY),Math.max(0,c-s)*Math.max(0,d-u)),v=l(y)+l(m);g<f?(f=g,n=h,p=v<p?v:p):g===f&&v<p&&(p=v,n=h)}return n||r-t},n.prototype._chooseSplitAxis=function(e,t,r){var n=e.leaf?this.compareMinX:u,o=e.leaf?this.compareMinY:c;this._allDistMargin(e,t,r,n)<this._allDistMargin(e,t,r,o)&&e.children.sort(n)},n.prototype._allDistMargin=function(e,t,r,n){e.children.sort(n);for(var o=this.toBBox,i=a(e,0,t,o),u=a(e,r-t,r,o),c=d(i)+d(u),l=t;l<r-t;l++){var f=e.children[l];s(i,e.leaf?o(f):f),c+=d(i)}for(var p=r-t-1;p>=t;p--){var h=e.children[p];s(u,e.leaf?o(h):h),c+=d(u)}return c},n.prototype._adjustParentBBoxes=function(e,t,r){for(var n=r;n>=0;n--)s(t[n],e)},n.prototype._condense=function(e){for(var t=e.length-1,r=void 0;t>=0;t--)0===e[t].children.length?t>0?(r=e[t-1].children).splice(r.indexOf(e[t]),1):this.clear():i(e[t],this.toBBox)},n}()},628(e){e.exports.RADIUS=6378137,e.exports.FLATTENING=1/298.257223563,e.exports.POLAR_RADIUS=6356752.3142},368(e,t,r){"use strict";var n=r(861);var o=function(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const r=[1/0,1/0,-1/0,-1/0];return n.coordEach.call(void 0,e,e=>{r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])}),r};t.Ay=o},391(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=6371008.8,n={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*r,kilometers:6371.0088,kilometres:6371.0088,meters:r,metres:r,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:r/1852,radians:1,yards:6967335.223679999},o={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:2.9155334959812285e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046};function i(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function a(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!m(e[0])||!m(e[1]))throw new Error("coordinates must contain numbers");return i({type:"Point",coordinates:e},t,r)}function s(e,t,r={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return i({type:"Polygon",coordinates:e},t,r)}function u(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return i({type:"LineString",coordinates:e},t,r)}function c(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function l(e,t,r={}){return i({type:"MultiLineString",coordinates:e},t,r)}function d(e,t,r={}){return i({type:"MultiPoint",coordinates:e},t,r)}function f(e,t,r={}){return i({type:"MultiPolygon",coordinates:e},t,r)}function p(e,t="kilometers"){const r=n[t];if(!r)throw new Error(t+" units is invalid");return e*r}function h(e,t="kilometers"){const r=n[t];if(!r)throw new Error(t+" units is invalid");return e/r}function y(e){return e%(2*Math.PI)*180/Math.PI}function m(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}t.areaFactors=o,t.azimuthToBearing=function(e){return(e%=360)>180?e-360:e<-180?e+360:e},t.bearingToAzimuth=function(e){let t=e%360;return t<0&&(t+=360),t},t.convertArea=function(e,t="meters",r="kilometers"){if(!(e>=0))throw new Error("area must be a positive number");const n=o[t];if(!n)throw new Error("invalid original units");const i=o[r];if(!i)throw new Error("invalid final units");return e/n*i},t.convertLength=function(e,t="kilometers",r="kilometers"){if(!(e>=0))throw new Error("length must be a positive number");return p(h(e,t),r)},t.degreesToRadians=function(e){return e%360*Math.PI/180},t.earthRadius=r,t.factors=n,t.feature=i,t.featureCollection=c,t.geometry=function(e,t,r={}){switch(e){case"Point":return a(t).geometry;case"LineString":return u(t).geometry;case"Polygon":return s(t).geometry;case"MultiPoint":return d(t).geometry;case"MultiLineString":return l(t).geometry;case"MultiPolygon":return f(t).geometry;default:throw new Error(e+" is invalid")}},t.geometryCollection=function(e,t,r={}){return i({type:"GeometryCollection",geometries:e},t,r)},t.isNumber=m,t.isObject=function(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)},t.lengthToDegrees=function(e,t){return y(h(e,t))},t.lengthToRadians=h,t.lineString=u,t.lineStrings=function(e,t,r={}){return c(e.map(e=>u(e,t)),r)},t.multiLineString=l,t.multiPoint=d,t.multiPolygon=f,t.point=a,t.points=function(e,t,r={}){return c(e.map(e=>a(e,t)),r)},t.polygon=s,t.polygons=function(e,t,r={}){return c(e.map(e=>s(e,t)),r)},t.radiansToDegrees=y,t.radiansToLength=p,t.round=function(e,t=0){if(t&&!(t>=0))throw new Error("precision must be a positive number");const r=Math.pow(10,t||0);return Math.round(e*r)/r},t.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(e=>{if(!m(e))throw new Error("bbox must only contain numbers")})},t.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},861(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(391);function o(e,t,r){if(null!==e)for(var n,i,a,s,u,c,l,d,f=0,p=0,h=e.type,y="FeatureCollection"===h,m="Feature"===h,g=y?e.features.length:1,v=0;v<g;v++){u=(d=!!(l=y?e.features[v].geometry:m?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var S=0,w=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var P=s.type;switch(f=!r||"Polygon"!==P&&"MultiPolygon"!==P?0:1,P){case null:break;case"Point":if(!1===t(c,p,v,S,w))return!1;p++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],p,v,S,w))return!1;p++,"MultiPoint"===P&&S++}"LineString"===P&&S++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-f;i++){if(!1===t(c[n][i],p,v,S,w))return!1;p++}"MultiLineString"===P&&S++,"Polygon"===P&&w++}"Polygon"===P&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(w=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-f;a++){if(!1===t(c[n][i][a],p,v,S,w))return!1;p++}w++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,f=0,p="FeatureCollection"===e.type,h="Feature"===e.type,y=p?e.features.length:1;for(r=0;r<y;r++){for(s=p?e.features[r].geometry:h?e.geometry:e,c=p?e.features[r].properties:h?e.properties:{},l=p?e.features[r].bbox:h?e.bbox:void 0,d=p?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,f,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],f,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,f,c,l,d))return!1;f++}}function u(e,t){s(e,function(e,r,o,i,a){var s,u=null===e?null:e.type;switch(u){case null:case"Point":case"LineString":case"Polygon":return!1!==t(n.feature.call(void 0,e,o,{bbox:i,id:a}),r,0)&&void 0}switch(u){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<e.coordinates.length;c++){var l={type:s,coordinates:e.coordinates[c]};if(!1===t(n.feature.call(void 0,l,o),r,c))return!1}})}function c(e,t){u(e,function(e,r,i){var a=0;if(e.geometry){var s=e.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var u,c=0,l=0,d=0;return!1!==o(e,function(o,s,f,p,h){if(void 0===u||r>c||p>l||h>d)return u=o,c=r,l=p,d=h,void(a=0);var y=n.lineString.call(void 0,[u,o],e.properties);if(!1===t(y,r,i,h,a))return!1;a++,u=o})&&void 0}}})}function l(e,t){if(!e)throw new Error("geojson is required");u(e,function(e,r,o){if(null!==e.geometry){var i=e.geometry.type,a=e.geometry.coordinates;switch(i){case"LineString":if(!1===t(e,r,o,0,0))return!1;break;case"Polygon":for(var s=0;s<a.length;s++)if(!1===t(n.lineString.call(void 0,a[s],e.properties),r,o,s))return!1}}})}t.coordAll=function(e){var t=[];return o(e,function(e){t.push(e)}),t},t.coordEach=o,t.coordReduce=function(e,t,r,n){var i=r;return o(e,function(e,n,o,a,s){i=0===n&&void 0===r?e:t(i,e,n,o,a,s)},n),i},t.featureEach=a,t.featureReduce=function(e,t,r){var n=r;return a(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.findPoint=function(e,t){if(t=t||{},!n.isObject.call(void 0,t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.coordIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":return n.point.call(void 0,c,u,t);case"MultiPoint":return i<0&&(i=c.length+i),n.point.call(void 0,c[i],u,t);case"LineString":return s<0&&(s=c.length+s),n.point.call(void 0,c[s],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s),n.point.call(void 0,c[a][s],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),n.point.call(void 0,c[i][s],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s),n.point.call(void 0,c[i][a][s],u,t)}throw new Error("geojson is invalid")},t.findSegment=function(e,t){if(t=t||{},!n.isObject.call(void 0,t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.segmentIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),n.lineString.call(void 0,[c[s],c[s+1]],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s-1),n.lineString.call(void 0,[c[a][s],c[a][s+1]],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),n.lineString.call(void 0,[c[i][s],c[i][s+1]],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s-1),n.lineString.call(void 0,[c[i][a][s],c[i][a][s+1]],u,t)}throw new Error("geojson is invalid")},t.flattenEach=u,t.flattenReduce=function(e,t,r){var n=r;return u(e,function(e,o,i){n=0===o&&0===i&&void 0===r?e:t(n,e,o,i)}),n},t.geomEach=s,t.geomReduce=function(e,t,r){var n=r;return s(e,function(e,o,i,a,s){n=0===o&&void 0===r?e:t(n,e,o,i,a,s)}),n},t.lineEach=l,t.lineReduce=function(e,t,r){var n=r;return l(e,function(e,o,i,a){n=0===o&&void 0===r?e:t(n,e,o,i,a)}),n},t.propEach=i,t.propReduce=function(e,t,r){var n=r;return i(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.segmentEach=c,t.segmentReduce=function(e,t,r){var n=r,o=!1;return c(e,function(e,i,a,s,u){n=!1===o&&void 0===r?e:t(n,e,i,a,s,u),o=!0}),n}},826(e,t,r){"use strict";r.r(t),r.d(t,{MaplibreDrawAdapter:()=>ja,displayedShape:()=>Aa});var n={};r.r(n),r.d(n,{LAT_MAX:()=>b,LAT_MIN:()=>g,LAT_RENDERED_MAX:()=>S,LAT_RENDERED_MIN:()=>v,LNG_MAX:()=>P,LNG_MIN:()=>w,activeStates:()=>y,classes:()=>a,cursors:()=>u,events:()=>f,geojsonTypes:()=>l,interactions:()=>m,meta:()=>h,modes:()=>d,sources:()=>s,types:()=>c,updateActions:()=>p});var o={};r.r(o),r.d(o,{isActiveFeature:()=>E,isBackspaceKey:()=>k,isDeleteKey:()=>L,isDigit1Key:()=>F,isDigit2Key:()=>V,isDigit3Key:()=>D,isDigitKey:()=>N,isEnterKey:()=>j,isEscapeKey:()=>A,isFeature:()=>M,isInactiveFeature:()=>O,isOfMetaType:()=>x,isShiftDown:()=>T,isShiftMousedown:()=>_,isTrue:()=>R,isVertex:()=>C,noTarget:()=>I});var i={};r.r(i),r.d(i,{CommonSelectors:()=>o,ModeHandler:()=>ee,StringSet:()=>X,constrainFeatureMovement:()=>We,createMidPoint:()=>Ge,createSupplementaryPoints:()=>He,createVertex:()=>Ae,doubleClickZoom:()=>Ye,euclideanDistance:()=>W,featuresAt:()=>J,getFeatureAtAndSetCursors:()=>z,isClick:()=>Z,isEventAtCoordinates:()=>st,isTap:()=>Q,mapEventToBoundingBox:()=>Y,moveFeatures:()=>Ze,sortFeatures:()=>H,stringSetsAreEqual:()=>vt,theme:()=>Me,toDenseArray:()=>be});const a={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},s={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},u={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},c={POLYGON:"polygon",LINE:"line_string",POINT:"point"},l={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},d={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},f={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},p={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},h={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},y={ACTIVE:"true",INACTIVE:"false"},m=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],g=-90,v=-85,b=90,S=85,w=-270,P=270;function x(e){return function(t){const r=t.featureTarget;return!!r&&!!r.properties&&r.properties.meta===e}}function _(e){return!!e.originalEvent&&!!e.originalEvent.shiftKey&&0===e.originalEvent.button}function E(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===y.ACTIVE&&e.featureTarget.properties.meta===h.FEATURE}function O(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===y.INACTIVE&&e.featureTarget.properties.meta===h.FEATURE}function I(e){return void 0===e.featureTarget}function M(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.meta===h.FEATURE}function C(e){const t=e.featureTarget;return!!t&&!!t.properties&&t.properties.meta===h.VERTEX}function T(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function A(e){return"Escape"===e.key||27===e.keyCode}function j(e){return"Enter"===e.key||13===e.keyCode}function k(e){return"Backspace"===e.key||8===e.keyCode}function L(e){return"Delete"===e.key||46===e.keyCode}function F(e){return"1"===e.key||49===e.keyCode}function V(e){return"2"===e.key||50===e.keyCode}function D(e){return"3"===e.key||51===e.keyCode}function N(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function R(){return!0}var U=r(778);const B={Point:0,LineString:1,MultiLineString:1,Polygon:2};function G(e,t){const r=B[e.geometry.type]-B[t.geometry.type];return 0===r&&e.geometry.type===l.POLYGON?e.area-t.area:r}const H=function(e){return e.map(e=>(e.geometry.type===l.POLYGON&&(e.area=U.geometry({type:l.FEATURE,property:{},geometry:e.geometry})),e)).sort(G).map(e=>(delete e.area,e))},Y=function(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function $(e){if(this._items={},this._nums={},this._length=e?e.length:0,e)for(let t=0,r=e.length;t<r;t++)this.add(e[t]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}$.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},$.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},$.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},$.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((e,t)=>e.v-t.v).map(e=>e.k)},$.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const X=$,K=[h.FEATURE,h.MIDPOINT,h.VERTEX],J={click:function(e,t,r){return q(e,t,r,r.options.clickBuffer)},touch:function(e,t,r){return q(e,t,r,r.options.touchBuffer)}};function q(e,t,r,n){if(null===r.map)return[];const o=e?Y(e,n):t,i={};r.options.styles&&(i.layers=r.options.styles.map(e=>e.id).filter(e=>null!=r.map.getLayer(e)));const a=r.map.queryRenderedFeatures(o,i).filter(e=>-1!==K.indexOf(e.properties.meta)),s=new X,u=[];return a.forEach(e=>{const t=e.properties.id;s.has(t)||(s.add(t),u.push(e))}),H(u)}function z(e,t){const r=J.click(e,null,t),n={mouse:u.NONE};return r[0]&&(n.mouse=r[0].properties.active===y.ACTIVE?u.MOVE:u.POINTER,n.feature=r[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(n.mouse=u.ADD),t.ui.queueMapClasses(n),t.ui.updateMapClasses(),r[0]}function W(e,t){const r=e.x-t.x,n=e.y-t.y;return Math.sqrt(r*r+n*n)}function Z(e,t,r={}){const n=null!=r.fineTolerance?r.fineTolerance:4,o=null!=r.grossTolerance?r.grossTolerance:12,i=null!=r.interval?r.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;const a=W(e.point,t.point);return a<n||a<o&&t.time-e.time<i}function Q(e,t,r={}){const n=null!=r.tolerance?r.tolerance:25,o=null!=r.interval?r.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,W(e.point,t.point)<n&&t.time-e.time<o}const ee=function(e,t){const r={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},n={on(e,t,n){if(void 0===r[e])throw new Error(`Invalid event type: ${e}`);r[e].push({selector:t,fn:n})},render(e){t.store.featureChanged(e)}},o=function(e,o){const i=r[e];let a=i.length;for(;a--;){const e=i[a];if(e.selector(o)){e.fn.call(n,o)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(n),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(e){o("drag",e)},click(e){o("click",e)},mousemove(e){o("mousemove",e)},mousedown(e){o("mousedown",e)},mouseup(e){o("mouseup",e)},mouseout(e){o("mouseout",e)},keydown(e){o("keydown",e)},keyup(e){o("keyup",e)},touchstart(e){o("touchstart",e)},touchmove(e){o("touchmove",e)},touchend(e){o("touchend",e)},tap(e){o("tap",e)}}},te=((e,t=21)=>(r=t)=>{let n="",o=0|r;for(;o--;)n+=e[Math.random()*e.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function re(){return te()}const ne=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||re(),this.type=t.geometry.type};ne.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},ne.prototype.incomingCoords=function(e){this.setCoordinates(e)},ne.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},ne.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},ne.prototype.setProperty=function(e,t){this.properties[e]=t},ne.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:l.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},ne.prototype.internal=function(e){const t={id:this.id,meta:h.FEATURE,"meta:type":this.type,active:y.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const e in this.properties)t[`user_${e}`]=this.properties[e];return{type:l.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const oe=ne,ie=function(e,t){oe.call(this,e,t)};(ie.prototype=Object.create(oe.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},ie.prototype.updateCoordinate=function(e,t,r){this.coordinates=3===arguments.length?[t,r]:[e,t],this.changed()},ie.prototype.getCoordinate=function(){return this.getCoordinates()};const ae=ie,se=function(e,t){oe.call(this,e,t)};(se.prototype=Object.create(oe.prototype)).isValid=function(){return this.coordinates.length>1},se.prototype.addCoordinate=function(e,t,r){this.changed();const n=parseInt(e,10);this.coordinates.splice(n,0,[t,r])},se.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},se.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},se.prototype.updateCoordinate=function(e,t,r){const n=parseInt(e,10);this.coordinates[n]=[t,r],this.changed()};const ue=se,ce=function(e,t){oe.call(this,e,t),this.coordinates=this.coordinates.map(e=>e.slice(0,-1))};(ce.prototype=Object.create(oe.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},ce.prototype.incomingCoords=function(e){this.coordinates=e.map(e=>e.slice(0,-1)),this.changed()},ce.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},ce.prototype.addCoordinate=function(e,t,r){this.changed();const n=e.split(".").map(e=>parseInt(e,10));this.coordinates[n[0]].splice(n[1],0,[t,r])},ce.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];r&&(r.splice(t[1],1),r.length<3&&this.coordinates.splice(t[0],1))},ce.prototype.getCoordinate=function(e){const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];return JSON.parse(JSON.stringify(r[t[1]]))},ce.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},ce.prototype.updateCoordinate=function(e,t,r){this.changed();const n=e.split("."),o=parseInt(n[0],10),i=parseInt(n[1],10);void 0===this.coordinates[o]&&(this.coordinates[o]=[]),this.coordinates[o][i]=[t,r]};const le=ce,de={MultiPoint:ae,MultiLineString:ue,MultiPolygon:le},fe=(e,t,r,n,o)=>{const i=r.split("."),a=parseInt(i[0],10),s=i[1]?i.slice(1).join("."):null;return e[a][t](s,n,o)},pe=function(e,t){if(oe.call(this,e,t),delete this.coordinates,this.model=de[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};(pe.prototype=Object.create(oe.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(e=>new t(this.ctx,{id:re(),type:l.FEATURE,properties:{},geometry:{coordinates:e,type:this.type.replace("Multi","")}}))},pe.prototype.isValid=function(){return this.features.every(e=>e.isValid())},pe.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},pe.prototype.getCoordinate=function(e){return fe(this.features,"getCoordinate",e)},pe.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===l.POLYGON?e.getCoordinates():e.coordinates)))},pe.prototype.updateCoordinate=function(e,t,r){fe(this.features,"updateCoordinate",e,t,r),this.changed()},pe.prototype.addCoordinate=function(e,t,r){fe(this.features,"addCoordinate",e,t,r),this.changed()},pe.prototype.removeCoordinate=function(e){fe(this.features,"removeCoordinate",e),this.changed()},pe.prototype.getFeatures=function(){return this.features};const he=pe;function ye(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}ye.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},ye.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((e,t)=>(void 0===e[t.feature_id]&&(e[t.feature_id]=!0,this._ctx.store.get(t.feature_id).changed()),e),{})},ye.prototype.getSelected=function(){return this._ctx.store.getSelected()},ye.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},ye.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},ye.prototype.getFeature=function(e){return this._ctx.store.get(e)},ye.prototype.select=function(e){return this._ctx.store.select(e)},ye.prototype.deselect=function(e){return this._ctx.store.deselect(e)},ye.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},ye.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},ye.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},ye.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},ye.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)},ye.prototype.changeMode=function(e,t={},r={}){return this._ctx.events.changeMode(e,t,r)},ye.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},ye.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},ye.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},ye.prototype.featuresAt=function(e,t,r="click"){if("click"!==r&&"touch"!==r)throw new Error("invalid buffer type");return J[r](e,t,this._ctx)},ye.prototype.newFeature=function(e){const t=e.geometry.type;return t===l.POINT?new ae(this._ctx,e):t===l.LINE_STRING?new ue(this._ctx,e):t===l.POLYGON?new le(this._ctx,e):new he(this._ctx,e)},ye.prototype.isInstanceOf=function(e,t){if(e===l.POINT)return t instanceof ae;if(e===l.LINE_STRING)return t instanceof ue;if(e===l.POLYGON)return t instanceof le;if("MultiFeature"===e)return t instanceof he;throw new Error(`Unknown feature class: ${e}`)},ye.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const me=ye;ye.prototype.onSetup=function(){},ye.prototype.onDrag=function(){},ye.prototype.onClick=function(){},ye.prototype.onMouseMove=function(){},ye.prototype.onMouseDown=function(){},ye.prototype.onMouseUp=function(){},ye.prototype.onMouseOut=function(){},ye.prototype.onKeyUp=function(){},ye.prototype.onKeyDown=function(){},ye.prototype.onTouchStart=function(){},ye.prototype.onTouchMove=function(){},ye.prototype.onTouchEnd=function(){},ye.prototype.onTap=function(){},ye.prototype.onStop=function(){},ye.prototype.onTrash=function(){},ye.prototype.onCombineFeature=function(){},ye.prototype.onUncombineFeature=function(){},ye.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const ge={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},ve=Object.keys(ge);const be=function(e){return[].concat(e).filter(e=>void 0!==e)};function Se(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(s.HOT))return u();const t=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:t});let r=[],n=[];e.isDirty?n=e.getAllIds():(r=e.getChangedIds().filter(t=>void 0!==e.get(t)),n=e.sources.hot.filter(t=>t.properties.id&&-1===r.indexOf(t.properties.id)&&void 0!==e.get(t.properties.id)).map(e=>e.properties.id)),e.sources.hot=[];const o=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(e=>{const t=e.properties.id||e.properties.parent;return-1===r.indexOf(t)});const i=o!==e.sources.cold.length||n.length>0;function a(r,n){const o=e.get(r).internal(t);e.ctx.events.currentModeRender(o,r=>{r.properties.mode=t,e.sources[n].push(r)})}function u(){e.isDirty=!1,e.clearChangedIds()}r.forEach(e=>a(e,"hot")),n.forEach(e=>a(e,"cold")),i&&e.ctx.map.getSource(s.COLD).setData({type:l.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(s.HOT).setData({type:l.FEATURE_COLLECTION,features:e.sources.hot}),u()}function we(e){let t;this._features={},this._featureIds=new X,this._selectedFeatureIds=new X,this._selectedCoordinates=[],this._changedFeatureIds=new X,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,Se.call(this),this._emitSelectionChange&&(this.ctx.events.fire(f.SELECTION_CHANGE,{features:this.getSelected().map(e=>e.toGeoJSON()),points:this.getSelectedCoordinates().map(e=>({type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:e.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(f.RENDER,{})}))},this.isDirty=!1}function Pe(e,t={}){const r=e._selectedCoordinates.filter(t=>e._selectedFeatureIds.has(t.feature_id));e._selectedCoordinates.length===r.length||t.silent||(e._emitSelectionChange=!0),e._selectedCoordinates=r}we.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},we.prototype.setDirty=function(){return this.isDirty=!0,this},we.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const t=this.get(e);this.ctx.events.fire(f.CREATE,{features:[t.toGeoJSON()]})}return this},we.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(f.UPDATE,{action:t.action?t.action:p.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},we.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},we.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},we.prototype.getAllIds=function(){return this._featureIds.values()},we.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},we.prototype.delete=function(e,t={}){const r=[];return be(e).forEach(e=>{this._featureIds.has(e)&&(this._featureIds.delete(e),this._selectedFeatureIds.delete(e),t.silent||-1===r.indexOf(this._features[e])&&r.push(this._features[e].toGeoJSON()),delete this._features[e],this.isDirty=!0)}),r.length&&this.ctx.events.fire(f.DELETE,{features:r}),Pe(this,t),this},we.prototype.get=function(e){return this._features[e]},we.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},we.prototype.select=function(e,t={}){return be(e).forEach(e=>{this._selectedFeatureIds.has(e)||(this._selectedFeatureIds.add(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),this},we.prototype.deselect=function(e,t={}){return be(e).forEach(e=>{this._selectedFeatureIds.has(e)&&(this._selectedFeatureIds.delete(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),Pe(this,t),this},we.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},we.prototype.setSelected=function(e,t={}){return e=be(e),this.deselect(this._selectedFeatureIds.values().filter(t=>-1===e.indexOf(t)),{silent:t.silent}),this.select(e.filter(e=>!this._selectedFeatureIds.has(e)),{silent:t.silent}),this},we.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},we.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},we.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},we.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},we.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)}))},we.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},we.prototype.setFeatureProperty=function(e,t,r,n={}){this.get(e).setProperty(t,r),this.featureChanged(e,{silent:n.silent,action:p.CHANGE_PROPERTIES})},we.prototype.storeMapConfig=function(){m.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},we.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},we.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const xe=["mode","feature","mouse"];function _e(e){let t=null,r=null;const n={onRemove(){return e.map.off("load",n.connect),clearInterval(r),n.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",n.connect),clearInterval(r),n.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(o){if(e.map=o,e.events=function(e){const t=Object.keys(e.options.modes).reduce((t,r)=>(t[r]=function(e){const t=Object.keys(e);return function(r,n={}){let o={};const i=t.reduce((t,r)=>(t[r]=e[r],t),new me(r));return{start(){o=i.onSetup(n),ve.forEach(t=>{const r=ge[t];let n=()=>!1;var a;e[r]&&(n=()=>!0),this.on(t,n,(a=r,e=>i[a](o,e)))})},stop(){i.onStop(o)},trash(){i.onTrash(o)},combineFeatures(){i.onCombineFeatures(o)},uncombineFeatures(){i.onUncombineFeatures(o)},render(e,t){i.toDisplayFeatures(o,e,t)}}}}(e.options.modes[r]),t),{});let r={},n={};const o={};let i=null,s=null;o.drag=function(t,r){r({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:u.DRAG}),s.drag(t)):t.originalEvent.stopPropagation()},o.mousedrag=function(e){o.drag(e,e=>!Z(r,e))},o.touchdrag=function(e){o.drag(e,e=>!Q(n,e))},o.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return o.mousedrag(t);const r=z(t,e);t.featureTarget=r,s.mousemove(t)},o.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};const n=z(t,e);t.featureTarget=n,s.mousedown(t)},o.mouseup=function(t){const n=z(t,e);t.featureTarget=n,Z(r,{point:t.point,time:(new Date).getTime()})?s.click(t):s.mouseup(t)},o.mouseout=function(e){s.mouseout(e)},o.touchstart=function(t){if(!e.options.touchEnabled)return;n={time:(new Date).getTime(),point:t.point};const r=J.touch(t,null,e)[0];t.featureTarget=r,s.touchstart(t)},o.touchmove=function(t){if(e.options.touchEnabled)return s.touchmove(t),o.touchdrag(t)},o.touchend=function(t){if(t.originalEvent.preventDefault(),!e.options.touchEnabled)return;const r=J.touch(t,null,e)[0];t.featureTarget=r,Q(n,{time:(new Date).getTime(),point:t.point})?s.tap(t):s.touchend(t)};const c=e=>{const t=k(e),r=L(e),n=N(e);return!(t||r||n)};function l(r,n,o={}){s.stop();const a=t[r];if(void 0===a)throw new Error(`${r} is not valid`);i=r;const u=a(e,n);s=ee(u,e),o.silent||e.map.fire(f.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains(a.CANVAS)&&((k(t)||L(t))&&e.options.controls.trash?(t.preventDefault(),s.trash()):c(t)?s.keydown(t):F(t)&&e.options.controls.point?l(d.DRAW_POINT):V(t)&&e.options.controls.line_string?l(d.DRAW_LINE_STRING):D(t)&&e.options.controls.polygon&&l(d.DRAW_POLYGON))},o.keyup=function(e){c(e)&&s.keyup(e)},o.zoomend=function(){e.store.changeZoom()},o.data=function(t){if("style"===t.dataType){const{setup:t,map:r,options:n,store:o}=e;n.styles.some(e=>r.getLayer(e.id))||(t.addLayers(),o.setDirty(),o.render())}};const p={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start(){i=e.options.defaultMode,s=ee(t[i](e),e)},changeMode:l,actionable:function(t){let r=!1;Object.keys(t).forEach(e=>{if(void 0===p[e])throw new Error("Invalid action type");p[e]!==t[e]&&(r=!0),p[e]=t[e]}),r&&e.map.fire(f.ACTIONABLE,{actions:p})},currentModeName:()=>i,currentModeRender:(e,t)=>s.render(e,t),fire(t,r){e.map&&e.map.fire(t,r)},addEventListeners(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash(e){s.trash(e)},combineFeatures(){s.combineFeatures()},uncombineFeatures(){s.uncombineFeatures()},getMode:()=>i}}(e),e.ui=function(e){const t={};let r=null,n={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function i(e){o=Object.assign(o,e)}function s(){if(!e.container)return;const t=[],r=[];xe.forEach(e=>{o[e]!==n[e]&&(t.push(`${e}-${n[e]}`),null!==o[e]&&r.push(`${e}-${o[e]}`))}),t.length>0&&e.container.classList.remove(...t),r.length>0&&e.container.classList.add(...r),n=Object.assign(n,o)}function u(e,t={}){const n=document.createElement("button");return n.className=`${a.CONTROL_BUTTON} ${t.className}`,n.setAttribute("title",t.title),t.container.appendChild(n),n.addEventListener("click",n=>{if(n.preventDefault(),n.stopPropagation(),n.target===r)return l(),void t.onDeactivate();f(e),t.onActivate()},!0),n}function l(){r&&(r.classList.remove(a.ACTIVE_BUTTON),r=null)}function f(e){l();const n=t[e];n&&n&&"trash"!==e&&(n.classList.add(a.ACTIVE_BUTTON),r=n)}return{setActiveButton:f,queueMapClasses:i,updateMapClasses:s,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),s()},addButtons:function(){const r=e.options.controls,n=document.createElement("div");return n.className=`${a.CONTROL_GROUP} ${a.CONTROL_BASE}`,r?(r[c.POINT]&&(t[c.POINT]=u(c.POINT,{container:n,className:a.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(d.DRAW_POINT),onDeactivate:()=>e.events.trash()})),r[c.LINE]&&(t[c.LINE]=u(c.LINE,{container:n,className:a.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(d.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),r[c.POLYGON]&&(t[c.POLYGON]=u(c.POLYGON,{container:n,className:a.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(d.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),r.trash&&(t.trash=u("trash",{container:n,className:a.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),r.combine_features&&(t.combine_features=u("combineFeatures",{container:n,className:a.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),r.uncombine_features&&(t.uncombine_features=u("uncombineFeatures",{container:n,className:a.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}})),n):n},removeButtons:function(){Object.keys(t).forEach(e=>{const r=t[e];r.parentNode&&r.parentNode.removeChild(r),delete t[e]})}}}(e),e.container=o.getContainer(),e.store=new we(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=o.boxZoom.isEnabled(),o.boxZoom.disable();const t=o.dragPan.isEnabled();o.dragPan.disable(),o.dragPan.enable(),t||o.dragPan.disable()}return o.loaded()?n.connect():(o.on("load",n.connect),r=setInterval(()=>{o.loaded()&&n.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(s.COLD,{data:{type:l.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(s.HOT,{data:{type:l.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(t=>{e.map.addLayer(t)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(t=>{e.map.getLayer(t.id)&&e.map.removeLayer(t.id)}),e.map.getSource(s.COLD)&&e.map.removeSource(s.COLD),e.map.getSource(s.HOT)&&e.map.removeSource(s.HOT)}};return e.setup=n,n}const Ee="#3bb2d0",Oe="#fbb03b",Ie="#fff",Me=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],Oe,Ee],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],Oe,Ee],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Ie}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],Oe,Ee]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Ie}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":Oe}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":Oe}}];function Ce(e,t){this.x=e,this.y=t}Ce.prototype={clone(){return new Ce(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[0]*this.x+e[1]*this.y,r=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=r,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),r=Math.sin(e),n=t*this.x-r*this.y,o=r*this.x+t*this.y;return this.x=n,this.y=o,this},_rotateAround(e,t){const r=Math.cos(e),n=Math.sin(e),o=t.x+r*(this.x-t.x)-n*(this.y-t.y),i=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=o,this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ce},Ce.convert=function(e){if(e instanceof Ce)return e;if(Array.isArray(e))return new Ce(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Ce(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Te=function(e,t){const r=t.getBoundingClientRect();return new Ce(e.clientX-r.left-(t.clientLeft||0),e.clientY-r.top-(t.clientTop||0))};function Ae(e,t,r,n){return{type:l.FEATURE,properties:{meta:h.VERTEX,parent:e,coord_path:r,active:n?y.ACTIVE:y.INACTIVE},geometry:{type:l.POINT,coordinates:t}}}var je=r(850),ke=r(278);function Le(e){const t={type:"Feature"};return Object.keys(e).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:t[r]=e[r]}}),t.properties=Fe(e.properties),null==e.geometry?t.geometry=null:t.geometry=Ve(e.geometry),t}function Fe(e){const t={};return e?(Object.keys(e).forEach(r=>{const n=e[r];"object"==typeof n?null===n?t[r]=null:Array.isArray(n)?t[r]=n.map(e=>e):t[r]=Fe(n):t[r]=n}),t):t}function Ve(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(e=>Ve(e)),t):(t.coordinates=De(e.coordinates),t)}function De(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(e=>De(e))}function Ne(e,t={}){return Re(e,"mercator",t)}function Re(e,t,r={}){var n=(r=r||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&(0,ke.Et)(e[0])?e="mercator"===t?Ue(e):Be(e):(!0!==n&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Le(e);case"FeatureCollection":return function(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(r=>{switch(r){case"type":case"features":return;default:t[r]=e[r]}}),t.features=e.features.map(e=>Le(e)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Ve(e);default:throw new Error("unknown GeoJSON type")}}(e)),(0,je.Fh)(e,function(e){var r="mercator"===t?Ue(e):Be(e);e[0]=r[0],e[1]=r[1]})),e}function Ue(e){var t,r=Math.PI/180,n=6378137,o=20037508.342789244,i=[n*(Math.abs(e[0])<=180?e[0]:e[0]-360*((t=e[0])<0?-1:t>0?1:0))*r,n*Math.log(Math.tan(.25*Math.PI+.5*e[1]*r))];return i[0]>o&&(i[0]=o),i[0]<-o&&(i[0]=-o),i[1]>o&&(i[1]=o),i[1]<-o&&(i[1]=-o),i}function Be(e){var t=180/Math.PI,r=6378137;return[e[0]*t/r,(.5*Math.PI-2*Math.atan(Math.exp(-e[1]/r)))*t]}function Ge(e,t,r){const n=t.geometry.coordinates,o=r.geometry.coordinates;if(n[1]>S||n[1]<v||o[1]>S||o[1]<v)return null;const i=Ne(n),a=Ne(o),s=e=>Number(e.toFixed(8)),u=(e,t)=>(e+t)/2,c=function(e,t={}){return Re(e,"wgs84",t)}([u(i[0],a[0]),u(i[1],a[1])]),d=[s(c[0]),s(c[1])];return{type:l.FEATURE,properties:{meta:h.MIDPOINT,parent:e,lng:d[0],lat:d[1],coord_path:r.properties.coord_path},geometry:{type:l.POINT,coordinates:d}}}const He=function e(t,r={},n=null){const{type:o,coordinates:i}=t.geometry,a=t.properties&&t.properties.id;let s=[];function u(e,t){let n="",o=null;e.forEach((e,i)=>{const u=null!=t?`${t}.${i}`:String(i),l=Ae(a,e,u,c(u));if(r.midpoints&&o){const e=Ge(a,o,l);e&&s.push(e)}o=l;const d=JSON.stringify(e);n!==d&&s.push(l),0===i&&(n=d)})}function c(e){return!!r.selectedPaths&&-1!==r.selectedPaths.indexOf(e)}return o===l.POINT?s.push(Ae(a,i,n,c(n))):o===l.POLYGON?i.forEach((e,t)=>{u(e,null!==n?`${n}.${t}`:String(t))}):o===l.LINE_STRING?u(i,n):0===o.indexOf(l.MULTI_PREFIX)&&function(){const n=o.replace(l.MULTI_PREFIX,"");i.forEach((o,i)=>{const a={type:l.FEATURE,properties:t.properties,geometry:{type:n,coordinates:o}};s=s.concat(e(a,r,i))})}(),s},Ye={enable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e._ctx&&e._ctx.store&&e._ctx.store.getInitialConfigValue&&e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e.map.doubleClickZoom.disable()},0)}},{LAT_MIN:$e,LAT_MAX:Xe,LAT_RENDERED_MIN:Ke,LAT_RENDERED_MAX:Je,LNG_MIN:qe,LNG_MAX:ze}=n;function We(e,t){let r=$e,n=Xe,o=$e,i=Xe,a=ze,s=qe;e.forEach(e=>{const t=function(e){const t={Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type],r=[e.geometry.coordinates].flat(t),n=r.map(e=>e[0]),o=r.map(e=>e[1]),i=e=>Math.min.apply(null,e),a=e=>Math.max.apply(null,e);return[i(n),i(o),a(n),a(o)]}(e),u=t[1],c=t[3],l=t[0],d=t[2];u>r&&(r=u),c<n&&(n=c),c>o&&(o=c),u<i&&(i=u),l<a&&(a=l),d>s&&(s=d)});const u=t;return r+u.lat>Je&&(u.lat=Je-r),o+u.lat>Xe&&(u.lat=Xe-o),n+u.lat<Ke&&(u.lat=Ke-n),i+u.lat<$e&&(u.lat=$e-i),a+u.lng<=qe&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=ze&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function Ze(e,t){const r=We(e.map(e=>e.toGeoJSON()),t);e.forEach(e=>{const t=e.getCoordinates(),n=e=>{const t={lng:e[0]+r.lng,lat:e[1]+r.lat};return[t.lng,t.lat]},o=e=>e.map(e=>n(e));let i;e.type===l.POINT?i=n(t):e.type===l.LINE_STRING||e.type===l.MULTI_POINT?i=t.map(n):e.type===l.POLYGON||e.type===l.MULTI_LINE_STRING?i=t.map(o):e.type===l.MULTI_POLYGON&&(i=t.map(e=>e.map(e=>o(e)))),e.incomingCoords(i)})}const Qe={onSetup:function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(e=>void 0!==this.getFeature(e))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(f.UPDATE,{action:p.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(){const e=this.getSelected(),t=e.filter(e=>this.isInstanceOf("MultiFeature",e));let r=!1;if(e.length>1){r=!0;const t=e[0].type.replace("Multi","");e.forEach(e=>{e.type.replace("Multi","")!==t&&(r=!1)})}const n=t.length>0,o=e.length>0;this.setActionableState({combineFeatures:r,uncombineFeatures:n,trash:o})},getUniqueIds:function(e){return e.length?e.map(e=>e.properties.id).filter(e=>void 0!==e).reduce((e,t)=>(e.add(t),e),new X).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){Ye.enable(this)},onMouseMove:function(e,t){return M(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};Qe.onTap=Qe.onClick=function(e,t){return I(t)?this.clickAnywhere(e,t):x(h.VERTEX)(t)?this.clickOnVertex(e,t):M(t)?this.clickOnFeature(e,t):void 0},Qe.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(e=>this.doRender(e))),Ye.enable(this),this.stopExtendedInteractions(e)},Qe.clickOnVertex=function(e,t){this.changeMode(d.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:u.MOVE})},Qe.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},Qe.clickOnFeature=function(e,t){Ye.disable(this),this.stopExtendedInteractions(e);const r=T(t),n=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!r&&i&&this.getFeature(o).type!==l.POINT)return this.changeMode(d.DIRECT_SELECT,{featureId:o});i&&r?(this.deselect(o),this.updateUIClasses({mouse:u.POINTER}),1===n.length&&Ye.enable(this)):!i&&r?(this.select(o),this.updateUIClasses({mouse:u.MOVE})):i||r||(n.forEach(e=>this.doRender(e)),this.setSelected(o),this.updateUIClasses({mouse:u.MOVE})),this.doRender(o)},Qe.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),E(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&_(t)?this.startBoxSelect(e,t):void 0},Qe.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Te(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},Qe.onTouchStart=function(e,t){if(E(t))return this.startOnActiveFeature(e,t)},Qe.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},Qe.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:u.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(a.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const r=Te(t.originalEvent,this.map.getContainer()),n=Math.min(e.boxSelectStartLocation.x,r.x),o=Math.max(e.boxSelectStartLocation.x,r.x),i=Math.min(e.boxSelectStartLocation.y,r.y),s=Math.max(e.boxSelectStartLocation.y,r.y),c=`translate(${n}px, ${i}px)`;e.boxSelectElement.style.transform=c,e.boxSelectElement.style.WebkitTransform=c,e.boxSelectElement.style.width=o-n+"px",e.boxSelectElement.style.height=s-i+"px"},Qe.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};Ze(this.getSelected(),r),e.dragMoveLocation=t.lngLat},Qe.onTouchEnd=Qe.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const r=[e.boxSelectStartLocation,Te(t.originalEvent,this.map.getContainer())],n=this.featuresAt(null,r,"click"),o=this.getUniqueIds(n).filter(e=>!this.isSelected(e));o.length&&(this.select(o),o.forEach(e=>this.doRender(e)),this.updateUIClasses({mouse:u.MOVE}))}this.stopExtendedInteractions(e)},Qe.toDisplayFeatures=function(e,t,r){t.properties.active=this.isSelected(t.properties.id)?y.ACTIVE:y.INACTIVE,r(t),this.fireActionable(),t.properties.active===y.ACTIVE&&t.geometry.type!==l.POINT&&He(t).forEach(r)},Qe.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Qe.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],r=[],n=e[0].type.replace("Multi","");for(let o=0;o<e.length;o++){const i=e[o];if(i.type.replace("Multi","")!==n)return;i.type.includes("Multi")?i.getCoordinates().forEach(e=>{t.push(e)}):t.push(i.getCoordinates()),r.push(i.toGeoJSON())}if(r.length>1){const e=this.newFeature({type:l.FEATURE,properties:r[0].properties,geometry:{type:`Multi${n}`,coordinates:t}});this.addFeature(e),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([e.id]),this.fire(f.COMBINE_FEATURES,{createdFeatures:[e.toGeoJSON()],deletedFeatures:r})}this.fireActionable()},Qe.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],r=[];for(let n=0;n<e.length;n++){const o=e[n];this.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach(e=>{this.addFeature(e),e.properties=o.properties,t.push(e.toGeoJSON()),this.select([e.id])}),this.deleteFeature(o.id,{silent:!0}),r.push(o.toGeoJSON()))}t.length>1&&this.fire(f.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:r}),this.fireActionable()};const et=Qe,tt=x(h.VERTEX),rt=x(h.MIDPOINT),nt={fireUpdate:function(){this.fire(f.UPDATE,{action:p.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){null==e.initialDragPanState&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties,n=e.selectedCoordPaths.indexOf(r.coord_path);T(t)||-1!==n?T(t)&&-1===n&&e.selectedCoordPaths.push(r.coord_path):e.selectedCoordPaths=[r.coord_path];const o=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(o)},onMidpoint:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties;e.feature.addCoordinate(r.coord_path,r.lng,r.lat),this.fireUpdate(),e.selectedCoordPaths=[r.coord_path]},pathsToCoordinates:function(e,t){return t.map(t=>({feature_id:e,coord_path:t}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,r){Ze(this.getSelected(),r),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,r){const n=e.selectedCoordPaths.map(t=>e.feature.getCoordinate(t)),o=We(n.map(e=>({type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:e}})),r);for(let t=0;t<n.length;t++){const r=n[t];e.feature.updateCoordinate(e.selectedCoordPaths[t],r[0]+o.lng,r[1]+o.lat)}},clickNoTarget:function(){this.changeMode(d.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(d.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},onSetup:function(e){const t=e.featureId,r=this.getFeature(t);if(!r)throw new Error("You must provide a featureId to enter direct_select mode");if(r.type===l.POINT)throw new TypeError("direct_select mode doesn't handle point features");const n={featureId:t,feature:r,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,n.selectedCoordPaths)),this.setSelected(t),Ye.disable(this),this.setActionableState({trash:!0}),n},onStop:function(){Ye.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,r){e.featureId===t.properties.id?(t.properties.active=y.ACTIVE,r(t),He(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(r)):(t.properties.active=y.INACTIVE,r(t)),this.fireActionable(e)},onTrash:function(e){e.selectedCoordPaths.sort((e,t)=>t.localeCompare(e,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(d.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const r=E(t),n=tt(t),o=rt(t),i=0===e.selectedCoordPaths.length;return r&&i||n&&!i?this.updateUIClasses({mouse:u.MOVE}):this.updateUIClasses({mouse:u.NONE}),(n||r||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};nt.onTouchStart=nt.onMouseDown=function(e,t){return tt(t)?this.onVertex(e,t):E(t)?this.onFeature(e,t):rt(t)?this.onMidpoint(e,t):void 0},nt.onDrag=function(e,t){if(!0!==e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,r):this.dragFeature(e,t,r),e.dragMoveLocation=t.lngLat},nt.onClick=function(e,t){return I(t)?this.clickNoTarget(e,t):E(t)?this.clickActiveFeature(e,t):O(t)?this.clickInactive(e,t):void this.stopDragging(e)},nt.onTap=function(e,t){return I(t)?this.clickNoTarget(e,t):E(t)?this.clickActiveFeature(e,t):O(t)?this.clickInactive(e,t):void 0},nt.onTouchEnd=nt.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const ot=nt,it={onSetup:function(){const e=this.newFeature({type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:u.ADD}),this.activateUIButton(c.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)}};it.onTap=it.onClick=function(e,t){this.updateUIClasses({mouse:u.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(f.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.point.id]})},it.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},it.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.point.id;if(t.properties.active=n?y.ACTIVE:y.INACTIVE,!n)return r(t)},it.onTrash=it.stopDrawingAndRemove,it.onKeyUp=function(e,t){if(A(t)||j(t))return this.stopDrawingAndRemove(e,t)};const at=it,st=function(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},ut={onSetup:function(){const e=this.newFeature({type:l.FEATURE,properties:{},geometry:{type:l.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),Ye.disable(this),this.updateUIClasses({mouse:u.ADD}),this.activateUIButton(c.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&st(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:u.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),C(t)&&this.updateUIClasses({mouse:u.POINTER})}};ut.onTap=ut.onClick=function(e,t){return C(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},ut.onKeyUp=function(e,t){A(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)):j(t)&&this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},ut.onStop=function(e){this.updateUIClasses({mouse:u.NONE}),Ye.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(f.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT,{},{silent:!0})))},ut.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.polygon.id;if(t.properties.active=n?y.ACTIVE:y.INACTIVE,!n)return r(t);if(0===t.geometry.coordinates.length)return;const o=t.geometry.coordinates[0].length;if(!(o<3)){if(t.properties.meta=h.FEATURE,r(Ae(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const n=t.geometry.coordinates[0].length-3;r(Ae(e.polygon.id,t.geometry.coordinates[0][n],`0.${n}`,!1))}if(o<=4){const e=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(r({type:l.FEATURE,properties:t.properties,geometry:{coordinates:e,type:l.LINE_STRING}}),3===o)return}return r(t)}},ut.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)};const ct=ut,lt={onSetup:function(e){const t=(e=e||{}).featureId;let r,n,o="forward";if(t){if(r=this.getFeature(t),!r)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const a=r.coordinates.length-1;if(r.coordinates[a][0]===i[0]&&r.coordinates[a][1]===i[1])n=a+1,r.addCoordinate(n,...r.coordinates[a]);else{if(r.coordinates[0][0]!==i[0]||r.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");o="backwards",n=0,r.addCoordinate(n,...r.coordinates[0])}}else r=this.newFeature({type:l.FEATURE,properties:{},geometry:{type:l.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(r);return this.clearSelectedFeatures(),Ye.disable(this),this.updateUIClasses({mouse:u.ADD}),this.activateUIButton(c.LINE),this.setActionableState({trash:!0}),{line:r,currentVertexPosition:n,direction:o}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&st(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&st(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:u.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),C(t)&&this.updateUIClasses({mouse:u.POINTER})}};lt.onTap=lt.onClick=function(e,t){if(C(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},lt.onKeyUp=function(e,t){j(t)?this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.line.id]}):A(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT))},lt.onStop=function(e){Ye.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(f.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT,{},{silent:!0})))},lt.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)},lt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.line.id;if(t.properties.active=n?y.ACTIVE:y.INACTIVE,!n)return r(t);t.geometry.coordinates.length<2||(t.properties.meta=h.FEATURE,r(Ae(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),r(t))};const dt={simple_select:et,direct_select:ot,draw_point:at,draw_polygon:ct,draw_line_string:lt},ft={defaultMode:d.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Me,modes:dt,controls:{},userProperties:!1,suppressAPIEvents:!0},pt={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},ht={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function yt(e,t){return e.map(e=>e.source?e:Object.assign({},e,{id:`${e.id}.${t}`,source:"hot"===t?s.HOT:s.COLD}))}var mt=r(17),gt=r(186);function vt(e,t){return e.length===t.length&&JSON.stringify(e.map(e=>e).sort())===JSON.stringify(t.map(e=>e).sort())}const bt={Polygon:le,LineString:ue,Point:ae,MultiPolygon:he,MultiLineString:he,MultiPoint:he};function St(e){!function(e,t){const r={options:e=function(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),!1===e.displayControlsDefault?t.controls=Object.assign({},ht,e.controls):t.controls=Object.assign({},pt,e.controls),t=Object.assign({},ft,t),t.styles=yt(t.styles,"cold").concat(yt(t.styles,"hot")),t}(e)};t=function(e,t){t.modes=d;const r=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(t){return J.click({point:t},null,e).map(e=>e.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:l.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(t=>e.store.get(t)).map(e=>e.toGeoJSON())}},t.getSelectedPoints=function(){return{type:l.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(e=>({type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:e.coordinates}}))}},t.set=function(r){if(void 0===r.type||r.type!==l.FEATURE_COLLECTION||!Array.isArray(r.features))throw new Error("Invalid FeatureCollection");const n=e.store.createRenderBatch();let o=e.store.getAllIds().slice();const i=t.add(r),a=new X(i);return o=o.filter(e=>!a.has(e)),o.length&&t.delete(o),n(),i},t.add=function(t){const n=JSON.parse(JSON.stringify(gt(t))).features.map(t=>{if(t.id=t.id||re(),null===t.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(t.id)||e.store.get(t.id).type!==t.geometry.type){const n=bt[t.geometry.type];if(void 0===n)throw new Error(`Invalid geometry type: ${t.geometry.type}.`);const o=new n(e,t);e.store.add(o,{silent:r})}else{const n=e.store.get(t.id),o=n.properties;n.properties=t.properties,mt(o,t.properties)||e.store.featureChanged(n.id,{silent:r}),mt(n.getCoordinates(),t.geometry.coordinates)||n.incomingCoords(t.geometry.coordinates)}return t.id});return e.store.render(),n},t.get=function(t){const r=e.store.get(t);if(r)return r.toGeoJSON()},t.getAll=function(){return{type:l.FEATURE_COLLECTION,features:e.store.getAll().map(e=>e.toGeoJSON())}},t.delete=function(n){return e.store.delete(n,{silent:r}),t.getMode()!==d.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(d.SIMPLE_SELECT,void 0,{silent:r}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:r}),t.getMode()===d.DIRECT_SELECT?e.events.changeMode(d.SIMPLE_SELECT,void 0,{silent:r}):e.store.render(),t},t.changeMode=function(n,o={}){return n===d.SIMPLE_SELECT&&t.getMode()===d.SIMPLE_SELECT?(vt(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:r}),e.store.render()),t):(n===d.DIRECT_SELECT&&t.getMode()===d.DIRECT_SELECT&&o.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(n,o,{silent:r}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:r}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:r}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:r}),t},t.setFeatureProperty=function(n,o,i){return e.store.setFeatureProperty(n,o,i,{silent:r}),t},t}(r,t),r.api=t;const n=_e(r);t.onAdd=n.onAdd,t.onRemove=n.onRemove,t.types=c,t.options=e}(e,this)}St.modes=dt,St.constants=n,St.lib=i;const wt=St;var Pt={onSetup:function(){return{}},onClick:function(){return!1},onKeyUp:function(){return!1},onDrag:function(){return!1},toDisplayFeatures:function(e,t,r){t.properties.active="false",r(t)}},xt="draw.create",_t="draw.update",Et="draw.modechange",Ot="draw.editfinish",It="draw.cancel",Mt="draw.vertexselection",Ct="draw.vertexchange",Tt="draw.undochange",At="draw.geometrychange",jt="draw.interfacetypechange",kt="draw.placementblocked",Lt="draw.nudgevertex",Ft="styledata";function Vt(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return Dt(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Dt(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function Dt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Nt=function(e){if(null==e||!e.coordinates)return[];switch(e.type){case"LineString":return e.coordinates;case"Polygon":case"MultiLineString":return e.coordinates.flat(1);case"MultiPolygon":return e.coordinates.flat(2);default:return[]}},Rt=function(e){if(null==e||!e.coordinates)return[];var t=[],r=0;switch(e.type){case"LineString":t.push({start:0,length:e.coordinates.length,path:[],closed:!1});break;case"Polygon":e.coordinates.forEach(function(e,n){t.push({start:r,length:e.length,path:[n],closed:!0}),r+=e.length});break;case"MultiLineString":e.coordinates.forEach(function(e,n){t.push({start:r,length:e.length,path:[n],closed:!1}),r+=e.length});break;case"MultiPolygon":e.coordinates.forEach(function(e,n){e.forEach(function(e,o){t.push({start:r,length:e.length,path:[n,o],closed:!0}),r+=e.length})})}return t},Ut=function(e,t){var r,n=Vt(e);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(t>=o.start&&t<o.start+o.length)return{segment:o,localIdx:t-o.start}}}catch(e){n.e(e)}finally{n.f()}return null},Bt=function(e,t){var r,n=e.geometry.coordinates,o=Vt(t);try{for(o.s();!(r=o.n()).done;)n=n[r.value]}catch(e){o.e(e)}finally{o.f()}return n},Gt=function(e,t){var r,n=t.split(".").map(Number),o=Vt(Rt(e));try{for(o.s();!(r=o.n()).done;){var i=r.value;if(i.path.every(function(e,t){return e===n[t]})&&n.length===i.path.length+1){var a=n[n.length-1];return i.start+a}}}catch(e){o.e(e)}finally{o.f()}return n[n.length-1]},Ht=function(e,t){return{x:e.x*t,y:e.y*t}},Yt=function(e){return e instanceof window.SVGElement||e.ownerSVGElement},$t=r(682);function Xt(e){return Xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xt(e)}function Kt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Jt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Kt(Object(r),!0).forEach(function(t){qt(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Kt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function qt(e,t,r){return(t=function(e){var t=function(e){if("object"!=Xt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Xt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Xt(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function zt(e){var t;return null!==(t=null==e?void 0:e._snapInstance)&&void 0!==t?t:null}function Wt(e){var t;return!!(null!=e&&e.status&&null!=e&&e.snapStatus&&(null===(t=e.snapCoords)||void 0===t?void 0:t.length)>=2)}function Zt(e){return Wt(e)?{lng:e.snapCoords[0],lat:e.snapCoords[1]}:null}function Qt(e,t,r){if(!e||!t||!e.status)return!1;var n=t.unproject(r);return e.snapToClosestPoint({point:r,lngLat:n,_explicit:!0}),!0}function er(e,t){e&&(e._autoSnapSuspended=t)}function tr(e,t){if(!e||!t||!e.status)return!1;var r=t.getCenter(),n=t.project(r);return e.snapToClosestPoint({point:n,lngLat:r,_explicit:!0}),!0}function rr(e,t){var r,n,o;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(r=e.snappedFeatures)&&void 0!==r&&r.length&&(e.snappedFeatures.length=0),null!==(n=e.closeFeatures)&&void 0!==n&&n.length&&(e.closeFeatures.length=0),null!==(o=e.lines)&&void 0!==o&&o.length&&(e.lines.length=0)),null!=t&&t.getLayer("snap-helper-circle")&&t.setLayoutProperty("snap-helper-circle","visibility","none")}function nr(e){var t,r,n;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(t=e.snappedFeatures)&&void 0!==t&&t.length&&(e.snappedFeatures.length=0),null!==(r=e.closeFeatures)&&void 0!==r&&r.length&&(e.closeFeatures.length=0),null!==(n=e.lines)&&void 0!==n&&n.length&&(e.lines.length=0))}function or(e){return"function"==typeof(null==e?void 0:e.getSnapEnabled)&&!0===e.getSnapEnabled()}function ir(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ar(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ar(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ar(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var sr=function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=function(r){return function(n){return r.call(e,t,n)}},o={keydown:n(e.onKeydown),keyup:n(e.onKeyup),pointerdown:n(e.onPointerevent),pointermove:n(e.onPointerevent),pointerup:n(e.onPointerevent),click:n(e.onButtonClick),touchstart:n(e.onTouchstart),touchmove:n(e.onTouchmove),touchend:n(e.onTouchend),scalechange:n(e.onScaleChange),move:n(e.onMove),interfacetypechange:n(e.onInterfaceTypeChange)},i=0,a=Object.entries(r);i<a.length;i++){var s=ir(a[i],2),u=s[0],c=s[1];o[u]=n(c)}return o},ur=function(e,t,r){window.addEventListener("keydown",r.keydown,{capture:!0}),window.addEventListener("keyup",r.keyup,{capture:!0}),window.addEventListener("click",r.click),e.container.addEventListener("pointerdown",r.pointerdown),e.container.addEventListener("pointermove",r.pointermove),e.container.addEventListener("pointerup",r.pointerup),e.container.addEventListener("touchstart",r.touchstart,{passive:!1}),e.container.addEventListener("touchmove",r.touchmove,{passive:!1}),e.container.addEventListener("touchend",r.touchend,{passive:!1}),t.on("draw.scalechange",r.scalechange),t.on("move",r.move),t.on(jt,r.interfacetypechange),t.on(Lt,r.nudge)},cr=function(e,t,r){e.container.removeEventListener("pointerdown",r.pointerdown),e.container.removeEventListener("pointermove",r.pointermove),e.container.removeEventListener("pointerup",r.pointerup),e.container.removeEventListener("touchstart",r.touchstart),e.container.removeEventListener("touchmove",r.touchmove),e.container.removeEventListener("touchend",r.touchend),t.off("draw.scalechange",r.scalechange),t.off("move",r.move),t.off(jt,r.interfacetypechange),t.off(Lt,r.nudge),t.dragPan.enable(),window.removeEventListener("click",r.click),window.removeEventListener("keydown",r.keydown,{capture:!0}),window.removeEventListener("keyup",r.keyup,{capture:!0})},lr=function(e){var t=zt(e);t&&rr(t,e)},dr={fireGeometryChange:function(e){var t=this.getFeature(e.featureId);t&&this.map.fire("draw.update",{features:[t.toGeoJSON()],action:"change_coordinates"})},emitGeometryValidation:function(e,t,r){var n=this;e&&setTimeout(function(){var o=n.getFeature(r);o&&n.map.fire("draw.geometrychange",{feature:o.toGeoJSON(),phase:e,vertexIndex:t})},0)},pushUndo:function(e){var t=this.map._undoStack;t&&(t.push(e),this.emitGeometryValidation(this.UNDO_OP_PHASE[e.type],e.vertexIndex,e.featureId))}};function fr(e){return fr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fr(e)}function pr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function hr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function yr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?hr(Object(r),!0).forEach(function(t){mr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):hr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function mr(e,t,r){return(t=function(e){var t=function(e){if("object"!=fr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=fr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==fr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var gr={move_vertex:"commit-move",insert_vertex:"commit-delete",delete_vertex:"commit-insert"},vr=yr(yr({},dr),{},{UNDO_OP_PHASE:{move_vertex:"commit-move",insert_vertex:"commit-insert",delete_vertex:"commit-delete"},UNDO_INVERSE_PHASE:gr,handleUndo:function(e){var t=this.map._undoStack;if(t&&0!==t.length){var r=t.pop();"move_vertex"===r.type?this.undoMoveVertex(e,r):"insert_vertex"===r.type?this.undoInsertVertex(e,r):"delete_vertex"===r.type&&this.undoDeleteVertex(e,r),this.emitGeometryValidation(gr[r.type],r.vertexIndex,r.featureId)}},undoMoveVertex:function(e,t){var r=t.vertexIndex,n=t.previousPosition,o=t.featureId,i=this.getFeature(o);if(i){var a=i.toGeoJSON(),s=Rt(i),u=Ut(s,r);if(u){Bt(a,u.segment.path)[u.localIdx]=n,this._applyUndoAndSync(e,a,o);var c=e.vertecies[e.selectedVertexIndex];c&&this.updateTouchVertexTarget(e,Ht(this.map.project(c),e.scale))}}},undoInsertVertex:function(e,t){var r=t.vertexIndex,n=t.featureId,o=this.getFeature(n);if(o){var i=o.toGeoJSON(),a=Rt(o),s=Ut(a,r);s&&(Bt(i,s.segment.path).splice(s.localIdx,1),this._applyUndoAndSync(e,i,n),this.clearSelectedCoordinates(),this.hideTouchVertexIndicator(e),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null}))}},undoDeleteVertex:function(e,t){var r=t.vertexIndex,n=t.position,o=t.featureId,i=this.getFeature(o);if(i){var a=i.toGeoJSON(),s=Rt(i),u=Ut(s,r);if(!u){var c,l=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return pr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pr(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(s);try{for(l.s();!(c=l.n()).done;){var d=c.value;if(r===d.start+d.length){u={segment:d,localIdx:d.length};break}}}catch(e){l.e(e)}finally{l.f()}}u&&(Bt(a,u.segment.path).splice(u.localIdx,0,n),this._applyUndoAndSync(e,a,o),this.updateTouchVertexTarget(e,Ht(this.map.project(e.vertecies[r]),e.scale)),this.changeMode(e,{selectedVertexIndex:r,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,r)}))}},_applyUndoAndSync:function(e,t,r){this._ctx.api.add(t),e.vertecies=this.getVerticies(r),e.midpoints=this.getMidpoints(r),this._ctx.store.render(),this.fireGeometryChange(e)}}),br=r(722),Sr=r(473),wr=function(e){return{x:e.touches[0].clientX,y:e.touches[0].clientY}},Pr=function(e,t,r,n,o){var i=window.getComputedStyle(t),a={x:r.x-Number.parseFloat(i.left),y:r.y-Number.parseFloat(i.top)},s=e.project(n);return{deltaTarget:a,deltaVertex:{x:r.x/o-s.x,y:r.y/o-s.y}}},xr=function(e,t,r){var n={x:r.x/t.scale-t.deltaVertex.x,y:r.y/t.scale-t.deltaVertex.y},o=e.unproject(n);if(or(t)){var i=zt(e);Qt(i,e,n),o=Zt(i)||o}return o};function _r(e){return _r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_r(e)}function Er(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Or(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ir(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Or(Object(r),!0).forEach(function(t){Mr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Or(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Mr(e,t,r){return(t=function(e){var t=function(e){if("object"!=_r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=_r(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==_r(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Cr=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e){var n=(0,Sr.$)(t,r),o=n.editActive,i=n.editHalo,a=n.editVertex;(0,br.ZP)(e,{editActive:o,editHalo:i,editVertex:a})}},Tr={addTouchVertexTarget:function(e){e.touchVertexTarget=(0,br.DD)(e.container),Cr(e.touchVertexTarget,this.map._drawCurrentMapStyle,this.map._drawPluginConfig)},updateTouchVertexTarget:function(e,t){t&&"touch"===e.interfaceType&&e.selectedVertexIndex>=0?Object.assign(e.touchVertexTarget.style,{display:"block",top:"".concat(t.y,"px"),left:"".concat(t.x,"px")}):e.touchVertexTarget.style.display="none"},hideTouchVertexIndicator:function(e){e.touchVertexTarget.style.display="none"},onPointerevent:function(e,t){e.interfaceType="touch"===t.pointerType?"touch":"mouse",e.isPanEnabled=!0,"touch"!==t.pointerType||"pointermove"!==t.type||Yt(t.target.parentNode)||e._ignorePointermoveDeselect||this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,coordPath:null})},onTouchStart:function(){},onTouchMove:function(){},onTouchEnd:function(){},onTouchend:function(e){if(nr(zt(this.map)),null!=e&&e.featureId){this.syncVertices(e),e._touchMoved&&e._moveStartPosition&&null!=e._moveStartIndex&&this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,e._moveStartIndex=null,e._touchMoved=!1;var t=e.vertecies[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,Ht(this.map.project(t),e.scale))}},onTap:function(e,t){var r,n,o=zt(this.map);o&&rr(o,this.map);var i=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,a=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if("vertex"===i){var s=this.getFeature(e.featureId),u=Gt(s,a);this.changeMode(e,{selectedVertexIndex:u,selectedVertexType:"vertex",coordPath:a})}else"midpoint"===i?this.insertVertex(Ir(Ir({},e),{},{selectedVertexIndex:this.getVertexIndexFromMidpoint(e,a),selectedVertexType:"midpoint"})):this.clickNoTarget(e)},onTouchstart:function(e,t){nr(zt(this.map));var r,n=this.getVerticies(e.featureId),o=null==n?void 0:n[e.selectedVertexIndex];if(o&&Yt(t.target.parentNode)){e._moveStartPosition=function(e){if(Array.isArray(e))return Er(e)}(r=o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return Er(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Er(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e._moveStartIndex=e.selectedVertexIndex,e._touchMoved=!1;var i=wr(t);Object.assign(e,Pr(this.map,e.touchVertexTarget,i,o,e.scale))}},onTouchmove:function(e,t){if(!(e.selectedVertexIndex<0)&&Yt(t.target.parentNode)){e._touchMoved=!0;var r=wr(t);this.moveVertex(e,xr(this.map,e,r)),this.updateTouchVertexTarget(e,{x:r.x-e.deltaTarget.x,y:r.y-e.deltaTarget.y})}}},Ar=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),jr={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},kr=new Set(["INPUT","TEXTAREA","BUTTON","SELECT","A"]),Lr=function(e){var t,r=document.activeElement;return!(!r||r===document.body)&&(null===(t=e.container)||void 0===t||!t.contains(r))&&(kr.has(r.tagName)||r.isContentEditable||r.hasAttribute("tabindex"))},Fr=function(e){return"z"===e.key&&(e.metaKey||e.ctrlKey)&&!e.shiftKey},Vr={handleUndoShortcut:function(e,t){var r,n=null===(r=document.activeElement)||void 0===r?void 0:r.tagName;"INPUT"!==n&&"TEXTAREA"!==n&&(t.preventDefault(),t.stopPropagation(),this.handleUndo(e))}};function Dr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Nr={getOffset:function(e,t){var r=this.map.project(e),n=null!=t&&t.shiftKey?$t.WQ.nudgeAmount:$t.WQ.stepAmount,o=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Dr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Dr(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t?jr[t.key].map(function(e){return e*n}):[0,0],2),i=o[0],a=o[1];return this.map.unproject({x:r.x+i,y:r.y+a})},getOffsetByDelta:function(e,t,r,n){var o=this.map.project(e),i=n?$t.WQ.stepAmount:$t.WQ.nudgeAmount;return this.map.unproject({x:o.x+t*i,y:o.y+r*i})},resolveSnapTarget:function(e,t,r,n,o){var i=zt(this.map);if(or(e)&&e._isSnapped&&i){var a=function(e){var t,r;return null!==(t=null==e||null===(r=e.options)||void 0===r?void 0:r.radius)&&void 0!==t?t:$t.vf.snapRadius}(i)+1,s=this.map.project(n);return e._isSnapped=!1,rr(i,this.map),this.map.unproject({x:s.x+t*a,y:s.y+r*a})}var u=o();return or(e)&&i&&(Qt(i,this.map,this.map.project(u)),Wt(i))?(e._isSnapped=!0,Zt(i)):(e._isSnapped=!1,u)}},Rr=r(9);function Ur(e){return Ur="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ur(e)}function Br(e){return function(e){if(Array.isArray(e))return Hr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Gr(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Gr(e,t){if(e){if("string"==typeof e)return Hr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Hr(e,t):void 0}}function Hr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Yr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function $r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Yr(Object(r),!0).forEach(function(t){Xr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Xr(e,t,r){return(t=function(e){var t=function(e){if("object"!=Ur(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Ur(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ur(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Kr=$r($r({},Nr),{},{updateMidpoint:function(e){var t=this;setTimeout(function(){t.map.getSource("mapbox-gl-draw-hot").setData({type:"Feature",properties:{meta:"midpoint",active:"true",id:"active-midpoint"},geometry:{type:"Point",coordinates:e}})},0)},updateVertex:function(e,t){var r,n,o=(r=this.getVertexOrMidpoint(e,t),n=2,function(e){if(Array.isArray(e))return e}(r)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(r,n)||Gr(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1];i<0||!a||this.changeMode(e,$r({selectedVertexIndex:i,selectedVertexType:a},"vertex"===a&&{coordPath:this.getCoordPath(e,i)}))},getNewCoord:function(e,t){return this.getOffset(Nt(this.getFeature(e.featureId))[e.selectedVertexIndex],t)},nudgeVertexByDelta:function(e,t,r,n){var o,i=this;if(!("vertex"!==e.selectedVertexType||e.selectedVertexIndex<0)){var a=this.getFeature(e.featureId),s=a&&(null===(o=Nt(a))||void 0===o?void 0:o[e.selectedVertexIndex]);if(s){var u=Br(s),c=e.selectedVertexIndex,l=this.resolveSnapTarget(e,t,r,s,function(){return i.getOffsetByDelta(s,t,r,n)});this.moveVertex(e,l),this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:c,previousPosition:u})}}},insertVertex:function(e,t){var r,n=e.selectedVertexIndex-e.vertecies.length,o=this.getOffset(e.midpoints[n],t),i=this.getFeature(e.featureId),a=i.toGeoJSON(),s=n+1,u=null,c=0,l=0,d=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=Gr(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(Rt(i));try{for(d.s();!(r=d.n()).done;){var f=r.value,p=f.closed?f.length:f.length-1;if(n<l+p){u=f,c=n-l+1,s=f.start+c;break}l+=p}}catch(e){d.e(e)}finally{d.f()}u&&(Bt(a,u.path).splice(c,0,[o.lng,o.lat]),this._ctx.api.add(a),this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:s}),this.changeMode(e,{selectedVertexIndex:s,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,s)}))},moveVertex:function(e,t){if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).checkSnap&&!1!==e.enableSnap){var r,n=this.map._snapInstance;null!=n&&n.snapStatus&&(null===(r=n.snapCoords)||void 0===r?void 0:r.length)>=2&&(t={lng:n.snapCoords[0],lat:n.snapCoords[1]})}var o=this.getFeature(e.featureId),i=o.toGeoJSON(),a=Rt(o),s=Ut(a,e.selectedVertexIndex);s&&(Bt(i,s.segment.path)[s.localIdx]=[t.lng,t.lat],this._ctx.api.add(i),e.vertecies=this.getVerticies(e.featureId),this.map.fire("draw.geometrychange",e.feature))},deleteVertex:function(e){var t=this.getFeature(e.featureId);if(t){var r=Rt(t),n=Ut(r,e.selectedVertexIndex);if(n){var o=n.segment,i=o.closed?Rr.n8.Polygon:Rr.n8.LineString;if(!(o.length<=i)){var a=Br(e.vertecies[e.selectedVertexIndex]),s=e.selectedVertexIndex,u=[].concat(Br(n.segment.path),[n.localIdx]).join(".");t.removeCoordinate(u),this.fireUpdate(),this.clearSelectedCoordinates(),t.changed(),this._ctx.store.render(),this.pushUndo({type:"delete_vertex",featureId:e.featureId,vertexIndex:s,position:a}),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null})}}}}}),Jr=r(704);function qr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Zr(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function zr(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Zr(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function Wr(e){return function(e){if(Array.isArray(e))return Qr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Zr(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Zr(e,t){if(e){if("string"==typeof e)return Qr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Qr(e,t):void 0}}function Qr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var en={findVertexIndex:function(e,t,r){var n=[];return e.forEach(function(e,r){e[0]===t[0]&&e[1]===t[1]&&n.push(r)}),0===n.length?-1:1===n.length?n[0]:r>=0?n.reduce(function(e,t){return Math.abs(t-r)<Math.abs(e-r)?t:e},n[0]):n[0]},getCoordPath:function(e,t){var r=this.getFeature(e.featureId);if(!r)return"0";var n=Rt(r),o=Ut(n,t);if(!o)return"0";var i=o.segment,a=o.localIdx;return[].concat(Wr(i.path),[a]).join(".")},syncVertices:function(e){e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)},getVerticies:function(e){return Nt(this.getFeature(e))},getMidpoints:function(e){var t=this.getFeature(e),r=Nt(t),n=Rt(t);if(null==r||!r.length||!n.length)return[];var o,i=[],a=zr(n);try{for(a.s();!(o=a.n()).done;)for(var s=o.value,u=s.closed?s.length:s.length-1,c=0;c<u;c++){var l=s.start+c,d=s.start+(c+1)%s.length,f=qr(r[l],2),p=f[0],h=f[1],y=qr(r[d],2),m=y[0],g=y[1];i.push([(p+m)/2,(h+g)/2])}}catch(e){a.e(e)}finally{a.f()}return i},getVertexOrMidpoint:function(e,t){var r,n,o=this;if(null!==(r=e.vertecies)&&void 0!==r&&r.length||(e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),null===(n=e.vertecies)||void 0===n||!n.length)return[-1,null];var i=function(e){return e?Object.values(o.map.project(e)):null},a=[].concat(Wr(e.vertecies.map(i)),Wr(e.midpoints.map(i))).filter(Boolean);if(!a.length)return[-1,null];var s=a[e.selectedVertexIndex]||Object.values(this.map.project(this.map.getCenter())),u=(0,Jr.cj)(s,a,t);return[u,u<e.vertecies.length?"vertex":"midpoint"]},getVertexIndexFromMidpoint:function(e,t){var r,n=this.getFeature(e.featureId),o=Rt(n),i=t.split(".").map(Number),a=0,s=zr(o);try{for(s.s();!(r=s.n()).done;){var u=r.value;if(u.path.every(function(e,t){return e===i[t]})&&i.length===u.path.length+1){var c=i[i.length-1],l=c>0?c-1:u.length-2;return e.vertecies.length+a+l}a+=u.closed?u.length:u.length-1}}catch(e){s.e(e)}finally{s.f()}return e.vertecies.length}};function tn(e){return tn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},tn(e)}function rn(e,t){if(e){if("string"==typeof e)return nn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?nn(e,t):void 0}}function nn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function on(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function an(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?on(Object(r),!0).forEach(function(t){sn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):on(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function sn(e,t,r){return(t=function(e){var t=function(e){if("object"!=tn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=tn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==tn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var un=an(an({},Vr),{},{onKeydown:function(e,t){Lr(e)||(e.interfaceType="keyboard",this.hideTouchVertexIndicator(e)," "!==t.key?Ar.has(t.key)&&e.selectedVertexIndex>=0?this.handleArrowKey(e,t):"Escape"!==t.key?Fr(t)&&this.handleUndoShortcut(e,t):this.changeMode(e,{isPanEnabled:!0,selectedVertexIndex:-1,selectedVertexType:null}):this.handleSpace(e,t))},handleSpace:function(e,t){t.preventDefault(),e.selectedVertexIndex<0&&this.startKeyboardSelection(e)},handleArrowKey:function(e,t){t.preventDefault(),t.stopPropagation(),t.altKey?this.updateVertex(e,t.key):this.moveVertexByKey(e,t)},startKeyboardSelection:function(e){var t,r,n=zt(this.map);n&&rr(n,this.map),null!==(t=e.vertecies)&&void 0!==t&&t.length||(e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),null!==(r=e.vertecies)&&void 0!==r&&r.length&&(e.isPanEnabled=!1,this.updateVertex(e))},moveVertexByKey:function(e,t){var r,n;if("midpoint"!==e.selectedVertexType){var o=this.getFeature(e.featureId),i=o&&(null===(r=Nt(o))||void 0===r?void 0:r[e.selectedVertexIndex]);i&&(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=function(e){if(Array.isArray(e))return nn(e)}(n=i)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||rn(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e._keyboardMoveStartIndex=e.selectedVertexIndex),this.moveVertex(e,this._keyboardMoveTarget(e,t,i)))}else this.insertVertex(e,t)},_keyboardMoveTarget:function(e,t,r){var n=this,o=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||rn(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(jr[t.key],2),i=o[0],a=o[1];return this.resolveSnapTarget(e,i,a,r,function(){return n.getNewCoord(e,t)})},onKeyup:function(e,t){Lr(e)||(e.interfaceType="keyboard",Ar.has(t.key)&&e.selectedVertexIndex>=0&&(t.stopPropagation(),e._keyboardMoveStartPosition&&null!=e._keyboardMoveStartIndex&&(this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._keyboardMoveStartIndex,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null,e._keyboardMoveStartIndex=null)),"Delete"===t.key&&this.deleteVertex(e))}});function cn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var ln={onMouseDown:function(e,t){var r,n;nr(zt(this.map));var o,i=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,a=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if(["vertex","midpoint"].includes(i)&&(e.dragMoveLocation=t.lngLat,e.dragMoving=!1,ot.onMouseDown.call(this,e,t),"vertex"===i&&a)){var s,u=this.getFeature(e.featureId),c=Gt(u,a);e.selectedVertexIndex=c,e.selectedVertexType="vertex",e.coordPath=a;var l=null===(s=e.vertecies)||void 0===s?void 0:s[c];l&&(e._moveStartPosition=function(e){if(Array.isArray(e))return cn(e)}(o=l)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||function(e,t){if(e){if("string"==typeof e)return cn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?cn(e,t):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e._moveStartIndex=c)}if("midpoint"===i){var d=this.getFeature(e.featureId),f=Gt(d,a);e._insertedVertexIndex=f,e._isInsertingVertex=!0,e.selectedVertexIndex=this.getVertexIndexFromMidpoint(e,a),e.selectedVertexType="vertex",e.coordPath=null,this.map.fire(Mt,{index:e.selectedVertexIndex,numVertecies:e.vertecies.length})}},onClick:function(e,t){if(e._isInsertingVertex&&null!=e._insertedVertexIndex){var r=e._insertedVertexIndex;return this.syncVertices(e),this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:r}),e.selectedVertexIndex=r,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=null,void this.map.fire(Mt,{index:r,numVertecies:e.vertecies.length})}ot.onClick.call(this,e,t)},onMouseUp:function(e,t){nr(zt(this.map));var r=e._isInsertingVertex&&null!=e._insertedVertexIndex,n=this._didVertexMove(e);(e.dragMoving||n||r)&&(this.syncVertices(e),r?this._recordInsertionUndo(e):n&&this._recordMoveUndo(e)),e._moveStartPosition=null,e._moveStartIndex=null,ot.onMouseUp.call(this,e,t)},_didVertexMove:function(e){var t;if(!e._moveStartPosition||null==e._moveStartIndex)return!1;var r=this.getFeature(e.featureId),n=r&&(null===(t=Nt(r))||void 0===t?void 0:t[e._moveStartIndex]);return!!n&&(n[0]!==e._moveStartPosition[0]||n[1]!==e._moveStartPosition[1])},_recordInsertionUndo:function(e){var t=e._insertedVertexIndex;this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:t}),e.selectedVertexIndex=t,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=null,this.map.fire(Mt,{index:t,numVertecies:e.vertecies.length})},_recordMoveUndo:function(e){this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition})},onDrag:function(e,t){var r;if("touch"!==e.interfaceType){this.map.fire("draw.geometrychange",e.feature);var n=zt(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),or(e)&&null!=n&&n.status){if(null!==(r=e.selectedCoordPaths)&&void 0!==r&&r.length&&e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation(),Qt(n,this.map,t.point);var o=Zt(n)||t.lngLat;e.feature.updateCoordinate(e.selectedCoordPaths[0],o.lng,o.lat),e.dragMoveLocation=t.lngLat}}else ot.onDrag.call(this,e,t)}}};function dn(e){return dn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},dn(e)}function fn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function pn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fn(Object(r),!0).forEach(function(t){hn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function hn(e,t,r){return(t=function(e){var t=function(e){if("object"!=dn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=dn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==dn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var yn=pn(pn(pn(pn(pn(pn(pn(pn({},wt.modes.direct_select),vr),Tr),Kr),en),un),ln),{},{onSetup:function(e){var t,r,n,o=this,i=wt.modes.direct_select.onSetup.call(this,e);Object.assign(i,{container:e.container,interfaceType:e.interfaceType,deleteVertexButtonId:e.deleteVertexButtonId,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,featureId:i.featureId,selectedVertexIndex:null!==(t=e.selectedVertexIndex)&&void 0!==t?t:-1,selectedVertexType:e.selectedVertexType,coordPath:e.coordPath,scale:null!==(r=e.scale)&&void 0!==r?r:1}),this.map._lastEditFeatureId!==i.featureId&&(null===(n=this.map._undoStack)||void 0===n||n.clear(),this.map._lastEditFeatureId=i.featureId);var a=this.getFeature(i.featureId);if(i.featureType=null==a?void 0:a.type,i.vertecies=this.getVerticies(i.featureId),i.midpoints=this.getMidpoints(i.featureId),this.setupEventListeners(i),this.applyVertexSelection(i,e),this.map._drawEditContainer=e.container,this.addTouchVertexTarget(i),lr(this.map),"touch"===i.interfaceType&&i.selectedVertexIndex>=0&&"vertex"===i.selectedVertexType){var s=i.vertecies[i.selectedVertexIndex];s&&setTimeout(function(){o.updateTouchVertexTarget(i,Ht(o.map.project(s),i.scale))},0)}return i._ignorePointermoveDeselect=!0,setTimeout(function(){i._ignorePointermoveDeselect=!1},100),i},setupEventListeners:function(e){var t=this.handlers=sr(this,e,{nudge:this.onNudgeVertex,selectionchange:this.onSelectionChange,update:this.onUpdate});ur(e,this.map,t),this.map.on("draw.selectionchange",t.selectionchange),this.map.on("draw.update",t.update)},applyVertexSelection:function(e,t){if("midpoint"===t.selectedVertexType)return e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed(),this._ctx.store.render(),void this.updateMidpoint(e.midpoints[t.selectedVertexIndex-e.vertecies.length]);-1===t.selectedVertexIndex&&(e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed(),this._ctx.store.render())},onSelectionChange:function(e,t){var r,n;this.syncVertices(e);var o=null===(r=t.points[t.points.length-1])||void 0===r?void 0:r.geometry.coordinates;if("keyboard"!==e.interfaceType&&o&&!e.coordPath){var i,a=null===(i=t.features[0])||void 0===i?void 0:i.geometry,s=Nt(a);e.selectedVertexIndex=this.findVertexIndex(s,o,e.selectedVertexIndex)}null!==(n=e.selectedVertexType)&&void 0!==n||(e.selectedVertexType=e.selectedVertexIndex>=0?"vertex":null),this.map.fire(Mt,{index:"vertex"===e.selectedVertexType?e.selectedVertexIndex:-1,numVertecies:e.vertecies.length});var u=o||(e.selectedVertexIndex>=0?e.vertecies[e.selectedVertexIndex]:null);this.updateTouchVertexTarget(e,u?Ht(this.map.project(u),e.scale):null)},onScaleChange:function(e,t){e.scale=t.scale},onInterfaceTypeChange:function(e,t){e.interfaceType=t.interfaceType;var r=e.selectedVertexIndex>=0?e.vertecies[e.selectedVertexIndex]:null;this.updateTouchVertexTarget(e,r?Ht(this.map.project(r),e.scale):null)},onUpdate:function(e){var t;new Set(e.vertecies.map(function(e){return JSON.stringify(e)})).size!==e.vertecies.length&&(e.selectedVertexIndex=-1,null!==(t=e.selectedVertexType)&&void 0!==t||(e.selectedVertexType=null))},onMove:function(e){var t=e.vertecies[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,Ht(this.map.project(t),e.scale))},onNudgeVertex:function(e,t){this.nudgeVertexByDelta(e,t.dx,t.dy,t.isLargeStep);var r=e.vertecies[e.selectedVertexIndex];r&&this.updateTouchVertexTarget(e,Ht(this.map.project(r),e.scale))},onButtonClick:function(e,t){t.target.closest("#".concat(e.deleteVertexButtonId))&&"vertex"===e.selectedVertexType&&this.deleteVertex(e),t.target.closest("#".concat(e.undoButtonId))&&this.handleUndo(e)},clickNoTarget:function(e){this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,isPanEnabled:!0})},changeMode:function(e,t){e.featureId&&this._ctx.api.changeMode("edit_vertex",pn(pn({},e),t))},onStop:function(e){this.map._drawEditContainer=null,this.map._editingFeatureId=null;var t=this.handlers;this.map.off("draw.selectionchange",t.selectionchange),this.map.off("draw.update",t.update),cr(e,this.map,t),this.hideTouchVertexIndicator(e)}});function mn(e){return mn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},mn(e)}function gn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function vn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?gn(Object(r),!0).forEach(function(t){bn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):gn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function bn(e,t,r){return(t=function(e){var t=function(e){if("object"!=mn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=mn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==mn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Sn={move_point:"commit-move"},wn=vn(vn({},dr),{},{UNDO_OP_PHASE:{move_point:"commit-move"},UNDO_INVERSE_PHASE:Sn,handleUndo:function(e){var t=this.map._undoStack;if(t&&0!==t.length){var r=t.pop();"move_point"===r.type&&this.undoMovePoint(e,r),this.emitGeometryValidation(Sn[r.type],r.vertexIndex,r.featureId)}},undoMovePoint:function(e,t){var r=t.previousPosition,n=t.featureId,o=this.getFeature(n);o&&(o.updateCoordinate("",r[0],r[1]),this._ctx.store.render(),this.fireGeometryChange(e),this.updateTouchPointTarget(e,Ht(this.map.project(r),e.scale)))}});function Pn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var xn={addTouchPointTarget:function(e){e.touchPointTarget=(0,br.DD)(e.container),Cr(e.touchPointTarget,this.map._drawCurrentMapStyle,this.map._drawPluginConfig)},updateTouchPointTarget:function(e,t){t&&"touch"===e.interfaceType?Object.assign(e.touchPointTarget.style,{display:"block",top:"".concat(t.y,"px"),left:"".concat(t.x,"px")}):e.touchPointTarget.style.display="none"},hideTouchPointIndicator:function(e){e.touchPointTarget.style.display="none"},onPointerevent:function(e,t){e.interfaceType="touch"===t.pointerType?"touch":"mouse",e.isPanEnabled=!0},onTouchStart:function(){},onTouchMove:function(){},onTouchEnd:function(){},onTouchend:function(e){nr(zt(this.map)),e._touchMoved&&e._moveStartPosition&&this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,e._touchMoved=!1,e.feature&&this.updateTouchPointTarget(e,Ht(this.map.project(e.feature.coordinates),e.scale))},onTap:function(){},onTouchstart:function(e,t){nr(zt(this.map));var r,n=this.getPointCoord(e);if(n&&Yt(t.target.parentNode)){e._moveStartPosition=function(e){if(Array.isArray(e))return Pn(e)}(r=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return Pn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Pn(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e._touchMoved=!1;var o=wr(t);Object.assign(e,Pr(this.map,e.touchPointTarget,o,n,e.scale))}},onTouchmove:function(e,t){if(Yt(t.target.parentNode)){e._touchMoved=!0;var r=wr(t);this.movePoint(e,xr(this.map,e,r)),this.updateTouchPointTarget(e,{x:r.x-e.deltaTarget.x,y:r.y-e.deltaTarget.y})}}};function _n(e){return _n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_n(e)}function En(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function On(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function In(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?On(Object(r),!0).forEach(function(t){Mn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):On(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Mn(e,t,r){return(t=function(e){var t=function(e){if("object"!=_n(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=_n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==_n(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Cn=In(In({},Nr),{},{getPointCoord:function(e){var t;return null===(t=this.getFeature(e.featureId))||void 0===t?void 0:t.coordinates},getNewCoord:function(e,t){return this.getOffset(this.getPointCoord(e),t)},movePoint:function(e,t){e.feature.updateCoordinate("",t.lng,t.lat),this._ctx.store.render(),this.map.fire("draw.geometrychange",e.feature)},nudgePointByDelta:function(e,t,r,n){var o,i=this,a=this.getPointCoord(e);if(a){var s=function(e){if(Array.isArray(e))return En(e)}(o=a)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||function(e,t){if(e){if("string"==typeof e)return En(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?En(e,t):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=this.resolveSnapTarget(e,t,r,a,function(){return i.getOffsetByDelta(a,t,r,n)});this.movePoint(e,u),this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:s})}}});function Tn(e){return Tn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Tn(e)}function An(e,t){if(e){if("string"==typeof e)return jn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?jn(e,t):void 0}}function jn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function kn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ln(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?kn(Object(r),!0).forEach(function(t){Fn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):kn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Fn(e,t,r){return(t=function(e){var t=function(e){if("object"!=Tn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Tn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Tn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Vn=Ln(Ln({},Vr),{},{onKeydown:function(e,t){Lr(e)||(e.interfaceType="keyboard",this.hideTouchPointIndicator(e)," "!==t.key?Ar.has(t.key)?this.handleArrowKey(e,t):Fr(t)&&this.handleUndoShortcut(e,t):t.preventDefault())},handleArrowKey:function(e,t){t.preventDefault(),t.stopPropagation(),this.movePointByKey(e,t)},movePointByKey:function(e,t){var r,n=this.getPointCoord(e);n&&(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=function(e){if(Array.isArray(e))return jn(e)}(r=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||An(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),this.movePoint(e,this._keyboardMoveTarget(e,t,n)))},_keyboardMoveTarget:function(e,t,r){var n=this,o=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||An(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(jr[t.key],2),i=o[0],a=o[1];return this.resolveSnapTarget(e,i,a,r,function(){return n.getNewCoord(e,t)})},onKeyup:function(e,t){Lr(e)||(e.interfaceType="keyboard",Ar.has(t.key)&&(t.stopPropagation(),e._keyboardMoveStartPosition&&(this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null)))}}),Dn=r(520);function Nn(e){return function(e){if(Array.isArray(e))return Rn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Rn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Rn(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Un="edit_point",Bn={onFeature:function(e,t){e.dragMoving||(e._moveStartPosition=Nn(e.feature.coordinates),e._grabOffset=[e.feature.coordinates[0]-t.lngLat.lng,e.feature.coordinates[1]-t.lngLat.lat],er(zt(this.map),!0)),ot.onFeature.call(this,e,t)},onClick:function(e,t){if(!E(t)&&(r=this.map,n={type:"Feature",geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]},properties:{}},i=(o=(0,Dn.oK)(n,{mode:Un,vertexIndex:0},{onGeometryChange:r._drawGeometryValidator})).valid,a=o.reason,i||r.fire("draw.placementblocked",{feature:n,reason:null!=a?a:null,phase:"place",mode:Un,vertexIndex:0}),i)){var r,n,o,i,a,s=Nn(e.feature.coordinates),u=zt(this.map),c=t.lngLat;or(e)&&u&&(Qt(u,this.map,t.point),c=Zt(u)||t.lngLat),this.movePoint(e,c),this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:s})}},onMouseUp:function(e,t){var r=zt(this.map);nr(r),er(r,!1),this._didPointMove(e)&&this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,ot.onMouseUp.call(this,e,t)},_didPointMove:function(e){if(!e._moveStartPosition)return!1;var t=e.feature.coordinates;return t[0]!==e._moveStartPosition[0]||t[1]!==e._moveStartPosition[1]},onDrag:function(e,t){if("touch"!==e.interfaceType){this.map.fire("draw.geometrychange",e.feature);var r=zt(this.map);if(r&&(r.snapStatus=!1,r.snapCoords=null),or(e)&&null!=r&&r.status){if(e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation();var n={lng:t.lngLat.lng+e._grabOffset[0],lat:t.lngLat.lat+e._grabOffset[1]};Qt(r,this.map,this.map.project([n.lng,n.lat]));var o=Zt(r)||n;e.feature.updateCoordinate("",o.lng,o.lat),e.dragMoveLocation=t.lngLat}}else ot.onDrag.call(this,e,t)}},onTrash:function(){}};function Gn(e){return Gn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Gn(e)}function Hn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Yn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Hn(Object(r),!0).forEach(function(t){$n(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Hn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function $n(e,t,r){return(t=function(e){var t=function(e){if("object"!=Gn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Gn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Gn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Xn=Yn(Yn(Yn(Yn(Yn(Yn(Yn({},wt.modes.direct_select),wn),xn),Cn),Vn),Bn),{},{onSetup:function(e){var t,r,n=this,o=e.featureId,i=this.getFeature(o);if(!i)throw new Error("You must provide a featureId to enter edit_point mode");var a,s={featureId:o,feature:i,dragMoveLocation:null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:[]};return this.setSelectedCoordinates([]),this.setSelected(o),Ye.disable(this),this.setActionableState({trash:!1}),Object.assign(s,{container:e.container,interfaceType:e.interfaceType,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,scale:null!==(t=e.scale)&&void 0!==t?t:1}),this.map._lastEditFeatureId!==s.featureId&&(null===(a=this.map._undoStack)||void 0===a||a.clear(),this.map._lastEditFeatureId=s.featureId),this.setupEventListeners(s),this.map._drawEditContainer=e.container,this.addTouchPointTarget(s),null===(r=s.container)||void 0===r||r.focus({preventScroll:!0}),lr(this.map),"touch"===s.interfaceType&&setTimeout(function(){n.updateTouchPointTarget(s,Ht(n.map.project(s.feature.coordinates),s.scale))},0),this.map.fire(Mt,{index:0,numVertecies:1}),s},setupEventListeners:function(e){var t=this.handlers=sr(this,e,{nudge:this.onNudgePoint});ur(e,this.map,t)},toDisplayFeatures:function(e,t,r){t.properties.active=e.featureId===t.properties.id?"true":"false",r(t)},onScaleChange:function(e,t){e.scale=t.scale},onInterfaceTypeChange:function(e,t){e.interfaceType=t.interfaceType,this.updateTouchPointTarget(e,Ht(this.map.project(e.feature.coordinates),e.scale))},onMove:function(e){this.updateTouchPointTarget(e,Ht(this.map.project(e.feature.coordinates),e.scale))},onNudgePoint:function(e,t){this.nudgePointByDelta(e,t.dx,t.dy,t.isLargeStep),this.updateTouchPointTarget(e,Ht(this.map.project(e.feature.coordinates),e.scale))},onButtonClick:function(e,t){t.target.closest("#".concat(e.undoButtonId))&&this.handleUndo(e)},onStop:function(e){this.map._drawEditContainer=null,this.map._editingFeatureId=null,cr(e,this.map,this.handlers),this.hideTouchPointIndicator(e)}});function Kn(e){return Kn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Kn(e)}function Jn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return qn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qn(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function zn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Wn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?zn(Object(r),!0).forEach(function(t){Zn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):zn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Zn(e,t,r){return(t=function(e){var t=function(e){if("object"!=Kn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Kn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Kn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Qn=function(e){var t=e.ParentMode,r=e.featureProp,n=e.excludeFeatureIdFromSetup;return{onSetup:function(e){var o=this,i=this.map,a=n?Wn(Wn({},e),{},{featureId:null}):e,s=Wn(Wn({},t.onSetup.call(this,a)),e);s[r].properties=e.properties;var u=s.container,c=s.vertexMarkerId,l=s.getInterfaceType,d=l?l():s.interfaceType;s.interfaceType=d;var f=u.querySelector("#".concat(c));s.vertexMarker=f,["touch","keyboard"].includes(d)?this._showCrossHair(s):this._hideCrossHair(s),s.crossHair&&(s.crossHair.activate=function(){var e;return null===(e=o._placeAtCrossHair)||void 0===e?void 0:e.call(o,s)});var p={keydownHandler:this.onKeydown,keyupHandler:this.onKeyup,blurHandler:this.onBlur,createHandler:this.onCreate,moveHandler:this.onMove,pointerdownHandler:this.onPointerdown,pointermoveHandler:this.onPointermove,pointerupHandler:this.onPointerup,vertexButtonClickHandler:this.onVertexButtonClick,undoHandler:this.onUndo,interfaceTypeChangeHandler:this.onInterfaceTypeChange};return Object.entries(p).forEach(function(e){var t,r,n=Jn(e,2);return t=n[0],r=n[1],o[t]=r.bind(o,s)}),this._listeners=[[window,"keydown",this.keydownHandler],[window,"keyup",this.keyupHandler],[window,"click",this.vertexButtonClickHandler],[u,"blur",this.blurHandler],[u,"pointermove",this.pointermoveHandler],[u,"pointerup",this.pointerupHandler],[i,"pointerdown",this.pointerdownHandler],[i,"draw.create",this.createHandler],[i,"move",this.moveHandler],[i,"draw.undo",this.undoHandler],[i,"draw.interfacetypechange",this.interfaceTypeChangeHandler]],this._listeners.forEach(function(e){var t=Jn(e,3),r=t[0],n=t[1],o=t[2];return r.addEventListener?r.addEventListener(n,o):r.on(n,o)}),s},onStop:function(e){var r;t.onStop.call(this,e),this._listeners.forEach(function(e){var t=Jn(e,3),r=t[0],n=t[1],o=t[2];return r.removeEventListener?r.removeEventListener(n,o):r.off(n,o)}),null!==(r=e.crossHair)&&void 0!==r&&r.activate&&(e.crossHair.activate=null),["touch","keyboard"].includes(e.interfaceType)||this._hideCrossHair(e),this.map.fire("draw.interfacetypechange",{interfaceType:e.interfaceType})}}};function eo(e){return eo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},eo(e)}function to(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ro(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?to(Object(r),!0).forEach(function(t){no(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):to(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function no(e,t,r){return(t=function(e){var t=function(e){if("object"!=eo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=eo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==eo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var oo=function(e){return ro(ro({},function(e){var t=e.geometryType,r=e.getFeature,n=e.getCoords;return{_isIgnorableClick:function(e){return e.originalEvent.button>0||this.map._undoInProgress||e.originalEvent.target!==this.map.getCanvas()},_canPlaceVertex:function(e,o){var i=r(e);if(!i||!o)return!0;var a=(0,Dn.$b)({placed:n(i).slice(0,-1),point:o,geometryType:t,onGeometryChange:this.map._drawGeometryValidator});return a.valid||this.map.fire("draw.placementblocked",a.blocked),a.valid},dispatchVertexChange:function(e){this.map.fire("draw.vertexchange",{numVertecies:Math.max(0,e.length-1)})},emitDrawValidation:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"commit-add";!function(e,t,r,n,o){setTimeout(function(){var i=t(n);i&&e.fire("draw.geometrychange",function(e,t,r){var n=t(e).slice(0,-1);return{feature:{type:"Feature",geometry:"Polygon"===e.toGeoJSON().geometry.type?{type:"Polygon",coordinates:[n]}:{type:"LineString",coordinates:n},properties:{}},phase:r,vertexIndex:Math.max(0,n.length-1)}}(i,r,o))},0)}(this.map,r,n,e,t)},onTap:function(){},onVertexButtonClick:function(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest("#".concat(e.addVertexButtonId))&&this.doClick(e)},onCreate:function(e,t){!function(e,t,r){e.delete(t.id),t.id=r,e.add(t,{userProperties:!0})}(this._ctx.api,t.features[0],e.featureId)}}}(e)),function(e){var t=e.ParentMode,r=e.getFeature,n=e.getCoords,o=e.validateClick,i=e.finishOnInvalidClick;return{onClick:function(e,a){var s;if(!this._isIgnorableClick(a)&&(!1!==this.map._drawGeometryValid||"vertex"!==(null===(s=a.featureTarget)||void 0===s||null===(s=s.properties)||void 0===s?void 0:s.meta))){var u=zt(this.map);if(or(e)&&Wt(u))a=function(e,t){var r=Zt(t);return r?Jt(Jt({},e),{},{lngLat:r}):e}(a,u);else if(!function(e,t){var a=n(r(e));return a.length>0&&(a[a.length-1]=[t.lngLat.lng,t.lngLat.lat]),i||o(r(e))}(e,a))return;if(this._canPlaceVertex(e,[a.lngLat.lng,a.lngLat.lat])){var c=n(r(e)).length;t.onClick.call(this,e,a),n(r(e)).length>c&&(this.pushDrawUndo(e),this.dispatchVertexChange(n(r(e))),this.emitDrawValidation(e))}}},doClick:function(e){if(!this.map._undoInProgress){var a=r(e),s=n(a);if(this.dispatchVertexChange(s),o(a)){var u=zt(this.map),c=or(e)&&function(e,t){var r=Zt(t);if(!r)return null;var n=e.project([r.lng,r.lat]);return{lngLat:r,point:n,originalEvent:new MouseEvent("click",{clientX:n.x,clientY:n.y,bubbles:!0,cancelable:!0})}}(this.map,u),l=c?c.lngLat:this.map.getCenter();if(this._canPlaceVertex(e,[l.lng,l.lat])){c?(t.onClick.call(this,e,c),this._ctx.store.render()):this._simulateMouse("click",t.onClick,e);var d=n(r(e));this.pushDrawUndo(e),this.dispatchVertexChange(d),this.emitDrawValidation(e)}}else i&&!1!==this.map._drawGeometryValid&&(s.pop(),this.map.fire("draw.create",{features:[a.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[a.id]}))}}}}(e))};function io(e){return io="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},io(e)}function ao(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function so(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ao(Object(r),!0).forEach(function(t){uo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ao(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function uo(e,t,r){return(t=function(e){var t=function(e){if("object"!=io(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=io(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==io(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function co(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var lo=function(e){return so(so(so({},(r=(t=e).geometryType,n=t.getFeature,{pushDrawUndo:function(e){var t=this.map._undoStack;t&&!this.map._undoInProgress&&t.push({type:"draw_vertex",geometryType:r,featureId:n(e).id})},onUndo:function(e){var t=this,r=this.map._undoStack;if(r&&0!==r.length){var n=r.pop();"draw_vertex"===(null==n?void 0:n.type)&&(this.map._undoInProgress=!0,setTimeout(function(){t.map._undoInProgress=!1},100),this.undoVertex(e),this.emitDrawValidation(e,"commit-delete"))}},_handleUndoKeydown:function(e,t){var r,n=null===(r=document.activeElement)||void 0===r?void 0:r.tagName;"INPUT"!==n&&"TEXTAREA"!==n&&(t.preventDefault(),t.stopPropagation(),this.onUndo(e))}})),function(e){var t=e.ParentMode,r=e.geometryType,n=e.getCoords,o=e.getFeature,i=e.RUBBER_BAND_OFFSET;return{undoVertex:function(e){var t=o(e),r=n(t);return!(r.length<2)&&(2===r.length?this._reinitializeFeature(e,t):(this._removeLastVertex(e,t,r),!0))},_removeLastVertex:function(e,t,o){var a,s="Polygon"===r?t.coordinates[0]:o;s.splice(-i,1),s[s.length-1]=function(e){if(Array.isArray(e))return co(e)}(a=s[s.length-2])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||function(e,t){if(e){if("string"==typeof e)return co(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?co(e,t):void 0}}(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e.currentVertexPosition=Math.max(1,e.currentVertexPosition-1),this._ctx.store.render(),this._updateRubberBand(e,n(t))},_updateRubberBand:function(e,n){if(["touch","keyboard"].includes(e.interfaceType))this._simulateMouse("mousemove",t.onMouseMove,e),this._ctx.store.render();else{var o=n["Polygon"===r?n.length-2:n.length-1],i={lng:o[0],lat:o[1]},a=this.map.project(i);t.onMouseMove.call(this,e,{lngLat:i,point:a,originalEvent:new MouseEvent("mousemove",{clientX:a.x,clientY:a.y})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",e.polygon||e.line)}this.dispatchVertexChange(n)}}}(e)),function(e){var t=e.ParentMode,r=e.featureProp,n=e.geometryType;return{_reinitializeFeature:function(e,o){var i=o.id;if(this._ctx.store.delete([i]),"LineString"===n)return this._restartLineStringDraw(e,i);var a=this.map.getCenter(),s=[[a.lng,a.lat],[a.lng,a.lat]],u=this.newFeature({type:"Feature",properties:e.properties||{},geometry:{type:n,coordinates:[s]}});return u.id=i,this._ctx.store.add(u),e[r]=u,e.currentVertexPosition=0,this._ctx.store.render(),this._simulateMouse("mousemove",t.onMouseMove,e),this._ctx.store.render(),this.dispatchVertexChange(s),!0},_restartLineStringDraw:function(e,t){var r=this.map._undoStack;return r&&r.clear(),this._ctx.api.changeMode("draw_line",{featureId:t,container:e.container,interfaceType:e.interfaceType,crossHair:e.crossHair,vertexMarkerId:e.vertexMarkerId,addVertexButtonId:e.addVertexButtonId,getSnapEnabled:e.getSnapEnabled,properties:e.properties}),!0}}}(e));var t,r,n};function fo(e){return fo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},fo(e)}function po(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ho(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?po(Object(r),!0).forEach(function(t){yo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):po(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function yo(e,t,r){return(t=function(e){var t=function(e){if("object"!=fo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=fo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==fo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function mo(e){return mo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},mo(e)}function go(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function vo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?go(Object(r),!0).forEach(function(t){bo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):go(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function bo(e,t,r){return(t=function(e){var t=function(e){if("object"!=mo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=mo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==mo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var So=function(e,t){var r=t.featureProp,n=t.geometryType,o=t.getCoords,i=t.validateClick,a=t.getPlacedCoords,s=t.excludeFeatureIdFromSetup,u=void 0!==s&&s,c=t.finishOnInvalidClick,l={ParentMode:e,featureProp:r,geometryType:n,getCoords:o,validateClick:i,getPlacedCoords:a,excludeFeatureIdFromSetup:u,finishOnInvalidClick:void 0!==c&&c,getFeature:function(e){return e[r]},RUBBER_BAND_OFFSET:2,INTERFACE_KEYS:new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"])};return vo(vo(vo(vo(vo(vo(vo({},e),Qn(l)),oo(l)),lo(l)),function(e){var t=e.ParentMode,r=e.getFeature,n=e.INTERFACE_KEYS;return{onKeydown:function(e,t){"z"!==t.key||!t.metaKey&&!t.ctrlKey||t.shiftKey?document.activeElement===e.container&&("Escape"!==t.key?("Enter"===t.key&&(e.isActive=!0),n.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e,t))):t.preventDefault()):this._handleUndoKeydown(e,t)},onKeyup:function(e,t){"Escape"!==t.key?document.activeElement===e.container&&n.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e,t),"Enter"===t.key&&e.isActive&&this.doClick(e)):"keyboard"!==e.interfaceType&&this.map.fire("draw.cancel")},onKeyUp:function(e,n){var o=document.activeElement;if(!o||o===e.container||!e.container.contains(o))if("Escape"!==n.key)o!==e.container&&t.onKeyUp.call(this,e,n);else if("keyboard"===e.interfaceType){var i=this.map._undoStack;i&&i.clear(),this._reinitializeFeature(e,r(e))}}}}(l)),function(e){var t=e.ParentMode,r=e.getFeature,n=e.getCoords;return{onTouchStart:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onTouchEnd:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onInterfaceTypeChange:function(e,t){this._setInterface(e,t.interfaceType,["touch","keyboard"].includes(t.interfaceType)),this.onMove(e)},onBlur:function(e,t){t.target!==e.container&&this._hideCrossHair(e)},onMouseMove:function(e,r){if(or(e)){var n=zt(this.map);Qt(n,this.map,r.point);var o=Zt(n);o&&(r=ho(ho({},r),{},{lngLat:o}))}t.onMouseMove.call(this,e,r),this.map.fire("draw.geometrychange",e.polygon||e.line)},onMove:function(e){if(["touch","keyboard"].includes(e.interfaceType)){or(e)&&tr(zt(this.map),this.map);var r=zt(this.map),n=or(e)&&Zt(r);if(n){var o=this.map.project([n.lng,n.lat]);t.onMouseMove.call(this,e,{lngLat:n,point:o,originalEvent:new MouseEvent("mousemove",{clientX:o.x,clientY:o.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",e.polygon||e.line)}else this._simulateMouse("mousemove",t.onMouseMove,e)}},onPointerdown:function(e,t){"touch"!==t.pointerType&&this._setInterface(e,"mouse",!1)},onPointermove:function(e,t){"touch"!==t.pointerType&&this._hideCrossHair(e)},onPointerup:function(e){this.dispatchVertexChange(n(r(e)))}}}(l)),function(e){var t=e.ParentMode,r=e.geometryType,n=e.getFeature,o=e.getPlacedCoords;return{_simulateMouse:function(e,t,r){var n=this.map,o=n.getCenter(),i=n.project(o);t.call(this,r,{lngLat:o,point:i,originalEvent:new MouseEvent(e,{clientX:i.x,clientY:i.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",r.polygon||r.line)},_showCrossHair:function(e){e.crossHair?e.crossHair.show():e.vertexMarker.style.display="block"},_hideCrossHair:function(e){e.crossHair?e.crossHair.hide():e.vertexMarker.style.display="none"},_setInterface:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e.interfaceType=t,r&&this._showCrossHair(e)},toDisplayFeatures:function(e,i,a){t.toDisplayFeatures.call(this,e,i,a);var s=n(e);i.geometry.type===r&&i.properties.id===s.id&&o(i).forEach(function(e){return a({type:"Feature",properties:{meta:"draw-vertex",parent:s.id,active:"false"},geometry:{type:"Point",coordinates:e}})})}}}(l))},wo=So(wt.modes.draw_polygon,{featureProp:"polygon",geometryType:"Polygon",getCoords:function(e){return e.coordinates[0]},validateClick:function(e){return(0,Jr.jK)(e.coordinates)},getPlacedCoords:function(e){return e.geometry.coordinates[0].slice(0,-2)}}),Po=So(wt.modes.draw_line_string,{featureProp:"line",geometryType:"LineString",getCoords:function(e){return e.coordinates},validateClick:function(e){return(0,Jr.DF)(e.coordinates)},excludeFeatureIdFromSetup:!0,finishOnInvalidClick:!0,getPlacedCoords:function(e){return e.geometry.coordinates.slice(0,-1)}});function xo(e){return xo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},xo(e)}function _o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Eo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_o(Object(r),!0).forEach(function(t){Oo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Oo(e,t,r){return(t=function(e){var t=function(e){if("object"!=xo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=xo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==xo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Io="draw_point",Mo=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"]),Co=wt.modes.draw_point,To=Qn({ParentMode:Co,featureProp:"point",excludeFeatureIdFromSetup:!1}),Ao={onKeyUp:function(){},_showCrossHair:function(e){e.crossHair?e.crossHair.show():e.vertexMarker.style.display="block"},_hideCrossHair:function(e){e.crossHair?e.crossHair.hide():e.vertexMarker.style.display="none"},_setInterface:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e.interfaceType=t,r&&this._showCrossHair(e)},onCreate:function(e,t){var r,n=t.features[0];this._ctx.api.delete(n.id),n.id=e.featureId,this._ctx.api.add(n,{userProperties:!0}),null===(r=e.resolvePointSymbol)||void 0===r||r.call(e,e.featureId,n.properties)},onUndo:function(){},onPointerup:function(){},onMove:function(e){["touch","keyboard"].includes(e.interfaceType)&&or(e)&&tr(zt(this.map),this.map)},onBlur:function(e,t){t.target!==e.container&&this._hideCrossHair(e)},onPointerdown:function(e,t){"touch"!==t.pointerType&&this._setInterface(e,"mouse",!1)},onPointermove:function(e,t){"touch"!==t.pointerType&&this._hideCrossHair(e)},onTouchStart:function(e){this._setInterface(e,"touch"),this.onMove(e)},onTouchEnd:function(e){this._setInterface(e,"touch"),this.onMove(e)},onInterfaceTypeChange:function(e,t){this._setInterface(e,t.interfaceType,["touch","keyboard"].includes(t.interfaceType)),this.onMove(e)},onMouseMove:function(e,t){or(e)&&Qt(zt(this.map),this.map,t.point)},onVertexButtonClick:function(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest("#".concat(e.addVertexButtonId))&&this._placeAtCrossHair(e)},onKeydown:function(e,t){document.activeElement===e.container&&("Escape"!==t.key?("Enter"===t.key&&(e.isActive=!0),Mo.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e))):t.preventDefault())},onKeyup:function(e,t){"Escape"!==t.key?document.activeElement===e.container&&Mo.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e),"Enter"===t.key&&e.isActive&&this._placeAtCrossHair(e)):this.map.fire("draw.cancel")},onClick:function(e,t){if(!(t.originalEvent.button>0||t.originalEvent.target!==this.map.getCanvas())){var r=zt(this.map),n=or(e)&&Wt(r)?Zt(r):null;this._commit(e,n||t.lngLat)}},onTap:function(e,t){this.onClick(e,t)},_placeAtCrossHair:function(e){var t=zt(this.map);or(e)&&tr(t,this.map);var r=or(e)&&Wt(t)?Zt(t):null;this._commit(e,r||this.map.getCenter()),this._ctx.store.render()},_commit:function(e,t){var r,n,o,i,a;r=this.map,n={type:"Feature",geometry:{type:"Point",coordinates:[t.lng,t.lat]},properties:{}},i=(o=(0,Dn.oK)(n,{mode:Io,vertexIndex:0},{onGeometryChange:r._drawGeometryValidator})).valid,a=o.reason,i||r.fire("draw.placementblocked",{feature:n,reason:null!=a?a:null,phase:"place",mode:Io,vertexIndex:0}),i&&(e.point.updateCoordinate("",t.lng,t.lat),this.map.fire("draw.create",{features:[e.point.toGeoJSON()]}))}},jo=Eo(Eo(Eo({},Co),To),Ao);function ko(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Lo=function(e,t,r){return["coalesce",["get","user_".concat(t).concat(e.id.charAt(0).toUpperCase()+e.id.slice(1))],["get","user_".concat(t)],r]},Fo=["get","user_sortKey"],Vo=function(e,t){return{id:"fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","false"]],layout:{"fill-sort-key":Fo},paint:{"fill-color":Lo(e,"fill",t.shapeFill)}}},Do=function(e,t){return{id:"stroke-inactive",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","false"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round","line-sort-key":Fo},paint:{"line-color":Lo(e,"stroke",t.shapeStroke),"line-width":t.strokeWidth}}},No=function(e){return{id:"stroke-preview-line",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}},Ro=function(e,t){return{id:"vertex",type:"circle",filter:["all",["==","$type","Point"],["in","meta","vertex","draw-vertex"]],paint:{"circle-radius":t,"circle-color":e}}},Uo=function(e,t,r){return{id:"vertex-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":r,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},Bo=function(e,t){return{id:"vertex-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":t,"circle-color":e}}},Go=function(e,t){return{id:"midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":t,"circle-color":e}}},Ho=function(e,t,r){return{id:"midpoint-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":r,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},Yo=function(e,t){return{id:"midpoint-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":t,"circle-color":e}}},$o=function(e){return{id:"circle",type:"line",filter:["==","id","circle"],paint:{"line-color":e,"line-width":2,"line-opacity":.8}}},Xo=function(e){var t,r,n,o,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=(0,Sr.$)(e,a),u=$t.F0.vertexRadius,c=$t.F0.midpointRadius,l=$t.F0.vertexHaloRadius,d=$t.F0.midpointHaloRadius;return[Vo(e,s),(i=s.editFill,{id:"fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":i}}),(o=s.editStroke,{id:"stroke-active",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":o,"line-width":2,"line-opacity":1}}),(n=s.invalidStroke,{id:"stroke-active-invalid",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round",visibility:"none"},paint:{"line-color":n,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}),Do(e,s),{id:"point-symbol",type:"symbol",filter:["all",["==","$type","Point"],["==","meta","feature"]],layout:{"icon-image":["case",["==",["get","active"],"true"],["coalesce",["get","user_symbolSelectedImageId"],["get","user_symbolImageId"]],["get","user_symbolImageId"]],"icon-anchor":["get","user_symbolIconAnchor"],"icon-offset":["literal",[0,0]],"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":Fo},paint:{}},(r=s.splitInvalid,{id:"stroke-invalid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","invalid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":r,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}),(t=s.splitValid,{id:"stroke-valid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","valid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":t,"line-width":2,"line-opacity":1}}),No(s.editStroke),Go(s.editMidpoint,c),Ho(s.editHalo,s.editActive,d),Yo(s.editMidpoint,c),Ro(s.editVertex,u),Uo(s.editHalo,s.editActive,l),Bo(s.editVertex,u),$o(s.editStroke),{id:"touch-vertex-indicator",type:"circle",filter:["all",["==","$type","Point"],["==","meta","touch-vertex-indicator"]],paint:{"circle-radius":30,"circle-color":"#3bb2d0","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":.9}}]},Ko=6371008.8,Jo={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*Ko,kilometers:6371.0088,kilometres:6371.0088,meters:Ko,metres:Ko,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:Ko/1852,radians:1,yards:6967335.223679999};function qo(e,t,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function zo(e,t,r){if(void 0===r&&(r={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!ti(e[0])||!ti(e[1]))throw new Error("coordinates must contain numbers");return qo({type:"Point",coordinates:e},t,r)}function Wo(e,t,r){if(void 0===r&&(r={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return qo({type:"LineString",coordinates:e},t,r)}function Zo(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function Qo(e){return e%(2*Math.PI)*180/Math.PI}function ei(e){return e%360*Math.PI/180}function ti(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function ri(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ni(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}const oi=function(e,t,r){void 0===r&&(r={});var n=ri(e),o=ri(t),i=ei(o[1]-n[1]),a=ei(o[0]-n[0]),s=ei(n[1]),u=ei(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(u);return function(e,t){void 0===t&&(t="kilometers");var r=Jo[t];if(!r)throw new Error(t+" units is invalid");return e*r}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)};function ii(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ai(e,t,r,n={}){const o=ii(e),i=(0,ke.tR)(o[0]),a=(0,ke.tR)(o[1]),s=(0,ke.tR)(r),u=(0,ke.Gf)(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s)),l=i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c)),d=(0,ke.nv)(l),f=(0,ke.nv)(c);return void 0!==o[2]?(0,ke.zx)([d,f,o[2]],n.properties):(0,ke.zx)([d,f],n.properties)}function si(e,t,r){if(null!==e)for(var n,o,i,a,s,u,c,l,d=0,f=0,p=e.type,h="FeatureCollection"===p,y="Feature"===p,m=h?e.features.length:1,g=0;g<m;g++){s=(l=!!(c=h?e.features[g].geometry:y?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v<s;v++){var b=0,S=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var w=a.type;switch(d=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(u,f,g,b,S))return!1;f++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],f,g,b,S))return!1;f++,"MultiPoint"===w&&b++}"LineString"===w&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<u.length;n++){for(o=0;o<u[n].length-d;o++){if(!1===t(u[n][o],f,g,b,S))return!1;f++}"MultiLineString"===w&&b++,"Polygon"===w&&S++}"Polygon"===w&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(S=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-d;i++){if(!1===t(u[n][o][i],f,g,b,S))return!1;f++}S++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===si(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ui(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function ci(e,t){!function(e,t){var r,n,o,i,a,s,u,c,l,d,f=0,p="FeatureCollection"===e.type,h="Feature"===e.type,y=p?e.features.length:1;for(r=0;r<y;r++){for(s=p?e.features[r].geometry:h?e.geometry:e,c=p?e.features[r].properties:h?e.properties:{},l=p?e.features[r].bbox:h?e.bbox:void 0,d=p?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,f,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],f,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,f,c,l,d))return!1;f++}}(e,function(e,r,n,o,i){var a,s=null===e?null:e.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==t(qo(e,n,{bbox:o,id:i}),r,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var u=0;u<e.coordinates.length;u++){var c=e.coordinates[u];if(!1===t(qo({type:a,coordinates:c},n),r,u))return!1}})}function li(e,t){var r,n,o;return void 0===t&&(t={}),n=("Feature"===(r=e).type?r.geometry:r).coordinates,o=t.properties?t.properties:"Feature"===e.type?e.properties:{},n.length>1?function(e,t,r){return void 0===r&&(r={}),qo({type:"MultiLineString",coordinates:e},t,r)}(n,o):Wo(n[0],o)}var di=function e(t,r,n={}){if(!0===n.final)return function(t,r){let n=e(r,t);return n=(n+180)%360,n}(t,r);const o=ii(t),i=ii(r),a=(0,ke.tR)(o[0]),s=(0,ke.tR)(i[0]),u=(0,ke.tR)(o[1]),c=(0,ke.tR)(i[1]),l=Math.sin(s-a)*Math.cos(c),d=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(s-a);return(0,ke.nv)(Math.atan2(l,d))};function fi(e,t,r,n){void 0===n&&(n={});var o=ri(e),i=ei(o[0]),a=ei(o[1]),s=ei(r),u=function(e,t){void 0===t&&(t="kilometers");var r=Jo[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s));return zo([Qo(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),Qo(c)],n.properties)}const pi=function(e){if(!e)throw new Error("geojson is required");var t=[];return ci(e,function(e){!function(e,t){var r=[],n=e.geometry;if(null!==n){switch(n.type){case"Polygon":r=ni(n);break;case"LineString":r=[ni(n)]}r.forEach(function(r){var n=function(e,t){var r=[];return e.reduce(function(e,n){var o,i,a,s,u,c,l=Wo([e,n],t);return l.bbox=(i=n,a=(o=e)[0],s=o[1],[a<(u=i[0])?a:u,s<(c=i[1])?s:c,a>u?a:u,s>c?s:c]),r.push(l),n}),r}(r,e.properties);n.forEach(function(e){e.id=t.length,t.push(e)})})}}(e,t)}),Zo(t)};var hi=r(945);function yi(e,t){var r=ni(e),n=ni(t);if(2!==r.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==n.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var o=r[0][0],i=r[0][1],a=r[1][0],s=r[1][1],u=n[0][0],c=n[0][1],l=n[1][0],d=n[1][1],f=(d-c)*(a-o)-(l-u)*(s-i);if(0===f)return null;var p=((l-u)*(i-c)-(d-c)*(o-u))/f,h=((a-o)*(i-c)-(s-i)*(o-u))/f;return p>=0&&p<=1&&h>=0&&h<=1?zo([o+p*(a-o),i+p*(s-i)]):null}const mi=function(e,t){var r={},n=[];if("LineString"===e.type&&(e=qo(e)),"LineString"===t.type&&(t=qo(t)),"Feature"===e.type&&"Feature"===t.type&&null!==e.geometry&&null!==t.geometry&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var o=yi(e,t);return o&&n.push(o),Zo(n)}var i=hi();return i.load(pi(t)),ui(pi(e),function(e){ui(i.search(e),function(t){var o=yi(e,t);if(o){var i=ni(o).join(",");r[i]||(r[i]=!0,n.push(o))}})}),Zo(n)},gi=function(e,t,r){void 0===r&&(r={});var n=zo([1/0,1/0],{dist:1/0}),o=0;return ci(e,function(e){for(var i=ni(e),a=0;a<i.length-1;a++){var s=zo(i[a]);s.properties.dist=oi(t,s,r);var u=zo(i[a+1]);u.properties.dist=oi(t,u,r);var c=oi(s,u,r),l=Math.max(s.properties.dist,u.properties.dist),d=di(s,u),f=fi(t,l,d+90,r),p=fi(t,l,d-90,r),h=mi(Wo([f.geometry.coordinates,p.geometry.coordinates]),Wo([s.geometry.coordinates,u.geometry.coordinates])),y=null;h.features.length>0&&((y=h.features[0]).properties.dist=oi(t,y,r),y.properties.location=o+oi(s,y,r)),s.properties.dist<n.properties.dist&&((n=s).properties.index=a,n.properties.location=o),u.properties.dist<n.properties.dist&&((n=u).properties.index=a+1,n.properties.location=o+c),y&&y.properties.dist<n.properties.dist&&((n=y).properties.index=a),o+=c}}),n};var vi=6371008.8,bi={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:vi,metres:vi,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function Si(e){return e%(2*Math.PI)*180/Math.PI}function wi(e){return e%360*Math.PI/180}function Pi(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function xi(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}const _i=function(e,t,r){void 0===r&&(r={});var n=xi(e),o=xi(t),i=wi(o[1]-n[1]),a=wi(o[0]-n[0]),s=wi(n[1]),u=wi(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(u);return function(e,t){void 0===t&&(t="kilometers");var r=bi[t];if(!r)throw new Error(t+" units is invalid");return e*r}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)},Ei=function(e,t){var r=function(e,t,r,n){void 0===n&&(n={});var o=xi(e),i=wi(o[0]),a=wi(o[1]),s=wi(r),u=function(e,t){void 0===t&&(t="kilometers");var r=bi[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s));return function(e,t,r){if(void 0===r&&(r={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Pi(e[0])||!Pi(e[1]))throw new Error("coordinates must contain numbers");return function(e,t,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}({type:"Point",coordinates:e},t,r)}([Si(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),Si(c)],n.properties)}(e,_i(e,t)/2,di(e,t));return r};var Oi=function(){return Oi=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Oi.apply(this,arguments)},Ii=function(){function e(e){var t;this.status=null!==(t=e.status)&&void 0!==t&&t,this.map=e.map,this.drawing=e.drawing,this.options=e.options,this.onSnapped=function(t){void 0!==e.onSnapped&&e.onSnapped(t)},this.features={},this.snapStatus=!1,this.snapCoords=[],this.radiusInMeters=0,this.addRadiusCircleLayer(),this.addEvents()}return e.prototype.changeSnappedPoints=function(){for(var e=this.drawing.getAll(),t=[],r=0;r<e.features.length;r++){var n=e.features[r],o=n.id;if(this.features[o]){var i=this.features[o].snapPoints;if(void 0!==this.features.unknow){var a=this.features.unknow.snapPoints;i=Oi(Oi({},i),a)}var s=this.doSnap(n,i);t.push(s)}else void 0!==this.features.unknow?(a=this.features.unknow.snapPoints,s=this.doSnap(n,a),t.push(s)):t.push(n)}var u={type:"FeatureCollection",features:t};this.drawing.set(u),this.onSnapped&&this.onSnapped(u)},e.prototype.isPointSnapped=function(e,t){return oi(zo(e),zo(t),{units:"meters"})<this.radiusInMeters},e.prototype.doSnap=function(e,t){switch(e.geometry.type){case"Point":var r=e.geometry.coordinates;for(var n in t)this.isPointSnapped(r,t[n])&&(e.geometry.coordinates=t[n]);break;case"Polygon":for(var o=e.geometry.coordinates,i=[],a=0;a<o.length;a++){for(var s=o[a],u=[],c=0;c<s.length;c++){var l=s[c],d=!1;for(var n in t)if(this.isPointSnapped(l,t[n])){d=!0,u.push(t[n]);break}0==d&&u.push(l)}i.push(u)}e.geometry.coordinates=i;break;case"LineString":var f=e.geometry.coordinates;for(u=[],c=0;c<f.length;c++){var p=f[c];for(var n in d=!1,t)if(this.isPointSnapped(p,t[n])){d=!0,u.push(t[n]);break}0==d&&u.push(p)}e.geometry.coordinates=u}return e},e.prototype.getMe=function(){return this},e.prototype.setStatus=function(e){this.status=e},e.prototype.setMapData=function(e){var t=this.map.getSource("snap-helper-circle");t&&t.setData(e)},e.prototype.snapToClosestPoint=function(e){if(this.status){var t=e.point,r=this.map.unproject(t),n=[t.x+this.options.radius,t.y],o=this.map.unproject(n),i=oi(zo([r.lng,r.lat]),zo([o.lng,o.lat]),{units:"meters"});this.radiusInMeters=i;var a=!1,s=this.getCloseFeatures(e,i);s?(this.snapStatus=!0,this.snapCoords=s.coords,a=function(e,t,r={}){const n=r.steps||64,o=r.properties?r.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},i=[];for(let o=0;o<n;o++)i.push(ai(e,t,-360*o/n,r).geometry.coordinates);return i.push(i[0]),(0,ke.n1)([i],o)}(s.coords,i,{steps:64,units:"meters",properties:{color:s.color}})):(this.snapStatus=!1,this.snapCoords=[]);var u=Zo(0==a?[]:[a]);this.setMapData(u)}},e.prototype.addEvents=function(){var e=this;this.map.on("mousemove",function(t){e.snapToClosestPoint(t)}),this.map.on("draw.delete",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.update",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.create",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.selectionchange",function(t){t.features.length>0?e.status=!0:(e.status=!1,e.setMapData(Zo([])))}),this.map.on("draw.modechange",function(t){e.status=!0,"simple_select"==t.mode&&(e.status=!1)}),this.map.on("draw.render",function(t){var r=e.map.getSource("mapbox-gl-draw-hot");if(r){var n=r._data;if(e.snapStatus){var o=[e.snapCoords[0],e.snapCoords[1]];n.features.length>0&&(n.features[0].geometry.coordinates=o)}}}),this.map.on("mouseup",function(){e.drawingSnapCheck()}),this.map.on("click",function(){e.drawingSnapCheck()})},e.prototype.drawingSnapCheck=function(){if(this.snapStatus){var e=this.map.getSource("mapbox-gl-draw-hot"),t=[this.snapCoords[0],this.snapCoords[1]],r=t[0].toFixed(6),n=t[1].toFixed(6),o={};if(o["".concat(r,"_").concat(n)]=t,e){var i=e._data;if(i.features.length>0){var a=i.features.find(function(e){return"feature"==e.properties.meta});if(a){var s=a.properties.id;this.features[s]?this.features[s].snapPoints["".concat(r,"_").concat(n)]=t:this.features[s]={id:s,snapPoints:o}}}else this.features.unknow?this.features.unknow.snapPoints["".concat(r,"_").concat(n)]=t:this.features.unknow={id:s,snapPoints:o}}}},e.prototype.searchInVertex=function(e,t,r){var n,o=(n=[],si(e,function(e){n.push(e)}),n),i=[];if(o.map(function(e){var n=oi(zo(e),zo([t.lng,t.lat]),{units:"meters"});n<r&&i.push({coords:e,dist:n,color:"#8bc34a"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.getLines=function(e,t,r){var n=[];switch(e.geometry.type){case"LineString":n.push(e);break;case"MultiLineString":e.geometry.coodinates.map(function(e){n.push(Wo(e))});break;case"Polygon":var o=li(e.geometry);n.push(o);break;case"MultiPolygon":li(e.geometry).coodinates.map(function(e){n.push(Wo(e))})}return n},e.prototype.searchInMidPoint=function(e,t,r){var n=this.getLines(e,t,r),o=[];n.map(function(e){o=o.concat(pi(e).features)});var i=[];if(o.map(function(e){var n=Ei(e.geometry.coordinates[0],e.geometry.coordinates[1]),o=oi(n,zo([t.lng,t.lat]),{units:"meters"});o<r&&i.push({coords:n.geometry.coordinates,dist:o,color:"#03a9f4"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.searchInEdge=function(e,t,r){for(var n=this.getLines(e,t,r),o=[],i=0;i<n.length;i++){var a=gi(n[i],zo([t.lng,t.lat]),{units:"meters"});void 0!==a.properties.dist&&a.properties.dist<r&&o.push({coords:a.geometry.coordinates,dist:a.properties.dist,color:"#ff9800"})}if(o.length>0)return o.sort(function(e,t){return e.dist-t.dist}),o[0]},e.prototype.getCloseFeatures=function(e,t){var r=this.map.queryRenderedFeatures(e.point,{layers:this.options.layers});if(r.length>0){for(var n,o=!1,i=0;i<r.length;i++){var a=r[i],s=this.options.rules,u=e.lngLat;if(o=!1,-1!==s.indexOf("vertex")&&null==n&&(n=this.searchInVertex(a,u,t))){o=!0;break}if(-1!==s.indexOf("midpoint")&&null==n&&(n=this.searchInMidPoint(a,u,t))){o=!0;break}if(-1!==s.indexOf("edge")&&null==n&&(n=this.searchInEdge(a,u,t))){o=!0;break}}return!!o&&n}return!1},e.prototype.addRadiusCircleLayer=function(){this.map.addSource("snap-helper-circle",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"snap-helper-circle",type:"fill",source:"snap-helper-circle",paint:{"fill-color":["get","color"],"fill-opacity":.6}})},e}();const Mi=Ii;var Ci="snap-helper-circle",Ti="mapbox-gl-draw-hot";function Ai(e){return Ai="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ai(e)}function ji(e,t){!function r(){var n=e();null!==n&&(n?t(n):requestAnimationFrame(r))}()}function ki(e){var t;if(!(!e||e._data&&Array.isArray(null===(t=e._data)||void 0===t?void 0:t.features))){var r={type:"FeatureCollection",features:[]};Object.defineProperty(e,"_data",{get:function(){return r},set:function(e){r=e&&"object"===Ai(e)&&Array.isArray(e.features)?e:{type:"FeatureCollection",features:[]}},configurable:!0})}}var Li=new Set(["draw_polygon","draw_line","draw_point","edit_vertex","edit_point"]);function Fi(e,t,r,n){if(e._snapInstance||e._snapCreating)return e._snapInstance;e._snapCreating=!0,function(e){e.getLayer(Ci)&&e.removeLayer(Ci),e.getSource(Ci)&&e.removeSource(Ci)}(e),ki(r);var o=new Mi({map:e,drawing:t,options:{layers:n.layers,radius:n.radius,rules:n.rules},status:n.status,onSnapped:n.onSnapped});return function(e,t,r){var n=t;Object.defineProperty(e,"status",{get:function(){return n&&Li.has(r.getMode())},set:function(){},configurable:!0}),e.setSnapStatus=function(e){n=e}}(o,n.status,t),function(e,t){e._defaultLayers=t,e._activeLayers=null,e.setSnapLayers=function(t){null==t?e._activeLayers=null:Array.isArray(t)&&(e._activeLayers=t)}}(o,n.layers),void 0!==e._pendingSnapLayers&&(o.setSnapLayers(e._pendingSnapLayers),delete e._pendingSnapLayers),e._snapInstance=o,o}function Vi(e){return Vi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vi(e)}function Di(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ni(e,t,r){return(t=function(e){var t=function(e){if("object"!=Vi(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Vi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Vi(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ri(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e._snapInitialized)return e._snapInstance;e._snapInitialized=!0;var n=r.layers,o=void 0===n?[]:n,i=r.radius,a=void 0===i?$t.vf.snapRadius:i,s=r.rules,u=void 0===s?["vertex","midpoint","edge"]:s,c=r.status,l=void 0!==c&&c,d=r.onSnapped,f=void 0===d?function(){}:d,p=r.colors,h=void 0===p?{}:p,y={layers:o,radius:a,rules:u,status:l,onSnapped:f};return function(e){if(!Mi.prototype.__snapPatched){Mi.prototype.__snapPatched=!0;var t=Mi.prototype,r={setMapData:t.setMapData,drawingSnapCheck:t.drawingSnapCheck,getLines:t.getLines,getCloseFeatures:t.getCloseFeatures,searchInVertex:t.searchInVertex,searchInMidPoint:t.searchInMidPoint,searchInEdge:t.searchInEdge,snapToClosestPoint:t.snapToClosestPoint};t.changeSnappedPoints=function(){},function(e,t){e.setMapData=function(e){var r,n;if(this.status){var o=t.setMapData.call(this,e);return(null==e||null===(r=e.features)||void 0===r?void 0:r.length)>0&&null!==(n=this.map)&&void 0!==n&&n.getLayer(Ci)&&this.map.setLayoutProperty(Ci,"visibility","visible"),o}},e.drawingSnapCheck=function(){if(this.status)return t.drawingSnapCheck.call(this)}}(t,r),function(e,t){e.getLines=function(e,r,n){var o=e.geometry;if(null==o||!o.coordinates)return[];var i=o.coordinates;if(!Array.isArray(i)||0===i.length)return[];try{return"MultiPolygon"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return(0,ke.n1)(e)}):"MultiLineString"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return(0,ke.wi)(e)}):t.getLines.call(this,e,r,n)}catch(e){return[]}},e.getCloseFeatures=function(e,r){var n=this;if(!this.status)return[];var o=this._activeLayers||this._defaultLayers||[];this.options.layers=o.filter(function(e){return n.map.getLayer(e)});var i=this.options.radius||$t.vf.snapRadius,a=e.point;e.point=[[a.x-i,a.y-i],[a.x+i,a.y+i]];var s=t.getCloseFeatures.call(this,e,r);return e.point=a,s}}(t,r),function(e,t,r){e.searchInVertex=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var i=t.searchInVertex.apply(this,n);return i&&(i.color=r.vertex),i},e.searchInMidPoint=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var i=t.searchInMidPoint.apply(this,n);return i&&(i.color=r.midpoint),i},e.searchInEdge=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var i=t.searchInEdge.apply(this,n);return i&&(i.color=r.edge),i}}(t,r,e),function(e,t){e.snapToClosestPoint=function(e){var r;if(this.status&&(null===(r=this.map)||void 0===r||!r._isZooming)&&(!this._autoSnapSuspended||e._explicit))try{var n,o,i=t.snapToClosestPoint.call(this,e);return(null===(n=this.closeFeatures)||void 0===n?void 0:n.length)>100&&(this.closeFeatures.length=0),(null===(o=this.lines)||void 0===o?void 0:o.length)>100&&(this.lines.length=0),i}catch(e){return this.snapStatus=!1,void(this.snapCoords=null)}}}(t,r)}}(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Di(Object(r),!0).forEach(function(t){Ni(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Di(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({vertex:$t.lm.snapVertex,midpoint:$t.lm.snapMidpoint,edge:$t.lm.snapEdge},h)),function(e,t,r){e.on("style.load",function(){ji(function(){return e._removed?null:e.getSource(Ti)},function(n){ki(n),function(e){var t;e.getSource(Ci)||e.addSource(Ci,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(Ci)||e.addLayer({id:Ci,type:"fill",source:Ci,paint:{"fill-color":["get","color"]},layout:{visibility:null!==(t=e._snapInstance)&&void 0!==t&&t.status?"visible":"none"}})}(e),e._snapInstance||Fi(e,t,n,r)})})}(e,t,y),function(e){e.on("zoomstart",function(){e._isZooming=!0}),e.on("zoomend",function(){if(e._isZooming=!1,e.getLayer(Ci)){e.setLayoutProperty(Ci,"visibility","none");var t=e._snapInstance;null!=t&&t.status&&e.setLayoutProperty(Ci,"visibility","visible")}})}(e),ji(function(){return e._removed?null:e.getSource(Ti)},function(r){return Fi(e,t,r,y)}),e._snapInstance}var Ui=r(610),Bi=r(600),Gi=r(121);function Hi(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Yi(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yi(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Yi(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var $i=.25,Xi=.75,Ki=function(e){var t=Hi(e,2),r=t[0],n=t[1],o=function(e){return e<=$i?"left":e>=Xi?"right":""}(r),i=function(e){return e<=$i?"top":e>=Xi?"bottom":""}(n);return i+(o&&i?"-":"")+o||"center"},Ji=function(e){return e<=$i?0:e>=Xi?1:.5},qi=function(e){return Math.round(100*e)/100},zi=function(e,t){var r=Hi(e,2),n=r[0],o=r[1],i=Hi(t.split(" ").map(Number),4),a=i[2],s=i[3];return[qi((Ji(n)-n)*a),qi((Ji(o)-o)*s)]};function Wi(e){return Wi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Wi(e)}function Zi(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return Qi(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return i=t,s=0,u=e,f.n=r,a}};function p(r,n){for(s=r,u=n,t=0;!d&&c&&!o&&t<l.length;t++){var o,i=l[t],p=f.p,h=i[2];r>3?(o=h===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=r<2&&p<i[1])?(s=0,f.v=n,f.n=i[1]):p<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,f.n=h,s=0))}if(o||r>1)return a;throw d=!0,n}return function(o,l,h){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,h),s=l,u=h;(t=s<2?e:u)||!d;){i||(s?s<3?(s>1&&(f.n=-1),p(s,u)):f.n=u:f.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?u:r.call(n,f))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(Qi(t={},n,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,Qi(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,Qi(d,"constructor",c),Qi(c,"constructor",u),u.displayName="GeneratorFunction",Qi(c,o,"GeneratorFunction"),Qi(d),Qi(d,o,"Generator"),Qi(d,n,function(){return this}),Qi(d,"toString",function(){return"[object Generator]"}),(Zi=function(){return{w:i,m:f}})()}function Qi(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}Qi=function(e,t,r,n){function i(t,r){Qi(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},Qi(e,t,r,n)}function ea(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ta(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ea(Object(r),!0).forEach(function(t){ra(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ea(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ra(e,t,r){return(t=function(e){var t=function(e){if("object"!=Wi(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Wi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Wi(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function na(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function oa(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){na(i,n,o,a,s,"next",e)}function s(e){na(i,n,o,a,s,"throw",e)}a(void 0)})}}function ia(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return aa(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?aa(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function aa(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var sa=function(e){return!!(null!=e&&e.symbol||null!=e&&e.symbolSvgContent)},ua=function(e,t,r){var n;if(null!==(n=e._symbolIconOffsetMap)&&void 0!==n||(e._symbolIconOffsetMap={}),!e._symbolIconOffsetMap[t]){e._symbolIconOffsetMap[t]=r;var o=function(e){for(var t=["match",["get","user_symbolImageId"]],r=0,n=Object.entries(e);r<n.length;r++){var o=ia(n[r],2),i=o[0],a=o[1];t.push(i,["literal",a])}return t.push(["literal",[0,0]]),t}(e._symbolIconOffsetMap);["hot","cold"].forEach(function(t){var r="".concat("point-symbol",".").concat(t);e.getLayer(r)&&e.setLayoutProperty(r,"icon-offset",o)})}},ca=function(e){var t;return(null===(t=e.getPixelRatio)||void 0===t?void 0:t.call(e))||1},la=function(){var e=oa(Zi().m(function e(t){var r,n,o,i,a,s,u,c,l,d,f,p,h,y,m,g,v,b,S,w;return Zi().w(function(e){for(;;)switch(e.n){case 0:if(a=t.draw,s=t.mapProvider,u=t.map,c=t.featureId,l=t.properties,d=t.pixelRatioOverride,sa(l)){e.n=1;break}return e.a(2,null);case 1:return f=u._drawCurrentMapStyle,p=null!=d?d:ca(u),e.n=2,s.addSymbolsToMap([l],f,Bi.a);case 2:if(h=a.get(c)){e.n=3;break}return e.a(2,null);case 3:if(y=Bi.a.getSymbolImageId(l,f,!1,p)){e.n=4;break}return e.a(2,null);case 4:return m=null!==(r=null===(n=u._activeSymbolImageMap)||void 0===n?void 0:n[y])&&void 0!==r?r:null,g=null!==(o=null===(i=u._selectedSymbolImageMap)||void 0===i?void 0:i[y])&&void 0!==o?o:null,v=Bi.a.getSymbolDef(l),b=(0,Gi.Op)(l,v),S=Ki(b),w=zi(b,(0,Gi.n8)(l,v)),ua(u,y,w),e.a(2,ta(ta({},h),{},{properties:ta(ta({},l),{},{symbolImageId:y,symbolIconAnchor:S,symbolActiveImageId:m,symbolSelectedImageId:g})}))}},e)}));return function(t){return e.apply(this,arguments)}}(),da=function(){var e=oa(Zi().m(function e(t){var r,n;return Zi().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,la(t);case 1:if(r=e.v){e.n=2;break}return e.a(2);case 2:t.draw.add(r),e.n=4;break;case 3:e.p=3,n=e.v,console.error("[draw] failed to resolve point symbol",t.featureId,n);case 4:return e.a(2)}},e,null,[[0,3]])}));return function(t){return e.apply(this,arguments)}}(),fa=function(){var e=oa(Zi().m(function e(t){var r,n,o,i,a,s,u;return Zi().w(function(e){for(;;)switch(e.n){case 0:return r=t.draw,n=t.mapProvider,o=t.map,i=t.pixelRatioOverride,a=r.getAll().features.filter(function(e){return"Point"===e.geometry.type&&sa(e.properties)}),e.n=1,Promise.allSettled(a.map(function(e){return la({draw:r,mapProvider:n,map:o,featureId:e.id,properties:e.properties,pixelRatioOverride:i})}));case 1:(s=e.v).filter(function(e){return"rejected"===e.status}).forEach(function(e){console.error("[draw] failed to resolve point symbol",e.reason)}),(u=s.filter(function(e){return"fulfilled"===e.status&&e.value}).map(function(e){return e.value})).length&&r.add({type:"FeatureCollection",features:u});case 2:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}();function pa(e){return pa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},pa(e)}function ha(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ya(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ha(Object(r),!0).forEach(function(t){ma(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ha(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ma(e,t,r){return(t=function(e){var t=function(e){if("object"!=pa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=pa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==pa(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ga="mapbox-gl-draw-cold",va=function(e){var t=e.map,r=e.draw,n=e.mapProvider,o=e.pluginConfig,i=e.onDone,a=t._drawCurrentMapStyle;t.once("idle",function(){var e,s=function(e,t){if(e.getSource(ga))return!1;var r={type:"FeatureCollection",features:[]};return e.addSource(ga,{data:r,type:"geojson"}),e.addSource("mapbox-gl-draw-hot",{data:r,type:"geojson"}),t.options.styles.forEach(function(t){return e.addLayer(t)}),!0}(t,r);!function(e,t){Xo(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).forEach(function(t){Object.entries(t.paint).forEach(function(r){var n,o,i=(o=2,function(e){if(Array.isArray(e))return e}(n=r)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(n,o)||function(e,t){if(e){if("string"==typeof e)return ko(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ko(e,t):void 0}}(n,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=i[0],s=i[1];e.getLayer("".concat(t.id,".cold"))&&e.setPaintProperty("".concat(t.id,".cold"),a,s),e.getLayer("".concat(t.id,".hot"))&&e.setPaintProperty("".concat(t.id,".hot"),a,s)})})}(t,a,o);var u=null===(e=t._drawEditContainer)||void 0===e?void 0:e.querySelector("[data-im-draw-touch-target]");Cr(u,a,o),fa({draw:r,mapProvider:n,map:t}).then(function(){s&&r.set(r.getAll()),t.triggerRepaint(),i()})})},ba=r(360),Sa=r(788),wa=r(715);function Pa(e){return Pa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Pa(e)}function xa(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?xa(Object(r),!0).forEach(function(t){Ea(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xa(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ea(e,t,r){return(t=Ia(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Oa(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ia(n.key),n)}}function Ia(e){var t=function(e){if("object"!=Pa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Pa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Pa(t)?t:t+""}var Ma=function(e){return{type:"Feature",geometry:{type:"Polygon",coordinates:e}}},Ca=function(e){return{type:"Feature",geometry:{type:"LineString",coordinates:e}}},Ta=function(e){return{type:"Feature",geometry:{type:"Point",coordinates:e}}},Aa=function(e,t){var r,n,o;if("draw_polygon"===e)return{feature:Ma(t),numVertices:(null!==(r=null===(n=t[0])||void 0===n?void 0:n.length)&&void 0!==r?r:1)-1};if("draw_line"===e)return{feature:Ca(t),numVertices:(null!==(o=null==t?void 0:t.length)&&void 0!==o?o:1)-1};if("edit_vertex"===e){var i,a=t[0];return Array.isArray(null==a?void 0:a[0])?{feature:Ma(t),numVertices:a.length}:{feature:Ca(t),numVertices:null!==(i=null==t?void 0:t.length)&&void 0!==i?i:0}}return"edit_point"===e?{feature:Ta(t),numVertices:1}:null},ja=function(){return e=function e(t,r){var n,o,i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._mapProvider=t,this._map=t.map,this._bus=(o=new Map,{on:function(e,t){o.has(e)||o.set(e,new Set),o.get(e).add(t)},off:function(e,t){var r;null===(r=o.get(e))||void 0===r||r.delete(t)},emit:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=o.get(e);i&&Array.from(i).forEach(function(e){return e.apply(void 0,r)})}}),this._editingFeatureId=null,this._sortKeyCounter=0;var a=function(e){var t,r=e.mapStyle,n=e.mapProvider,o=e.events,i=e.eventBus,a=e.snapLayers,s=e.pluginConfig,u=void 0===s?{}:s,c=n.map;wt.constants.classes.CONTROL_BASE="maplibregl-ctrl",wt.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",wt.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var l=ya(ya({},wt.modes),{},{disabled:Pt,edit_vertex:yn,edit_point:Xn,draw_polygon:wo,draw_line:Po,draw_point:jo}),d=n._mapboxDrawInstance;d?Object.assign(d.modes,l):(d=new wt({modes:l,styles:Xo(r,u),displayControlsDefault:!1,userProperties:!0,defaultMode:"disabled"}),c.addControl(d),n._mapboxDrawInstance=d);var f=function(e,t){var r=e.getCanvas(),n=null,o=function(e){1===e.touches.length&&(n={x:e.touches[0].clientX,y:e.touches[0].clientY,time:Date.now()})},i=function(e){if("disabled"===t.getMode()&&n){var o=e.changedTouches[0],i=o.clientX-n.x,a=o.clientY-n.y;Date.now()-n.time<300&&Math.abs(i)<10&&Math.abs(a)<10&&r.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,clientX:o.clientX,clientY:o.clientY})),n=null}else n=null};return r.addEventListener("touchstart",o,{passive:!0}),r.addEventListener("touchend",i,{passive:!0}),{remove:function(){r.removeEventListener("touchstart",o),r.removeEventListener("touchend",i)}}}(c,d);n.draw=d,c._drawCurrentMapStyle=r,c._drawPluginConfig=u,n.snapEnabled=!1;var p=n.undoStack;p||(p=(0,Ui.B)(function(e){return c.fire("draw.undochange",{length:e})}),n.undoStack=p),c._undoStack=p;var h=(0,Sr.$)(r,u);Ri(c,d,{layers:a,radius:null!==(t=u.snapRadius)&&void 0!==t?t:$t.vf.snapRadius,rules:["vertex","edge"],colors:{vertex:h.snapVertex,edge:h.snapEdge}});var y=function(){return i.emit(o.MAP_DATA_CHANGE)},m=function(e){var t=e.map,r=e.draw,n=e.mapProvider,o=e.pluginConfig,i=e.eventBus,a=e.events,s=e.notifyPointSymbolsRefreshed,u=function(e){t._drawCurrentMapStyle=e};i.on(a.MAP_SET_STYLE,u);var c=!1,l=function(){c||(c=!0,va({map:t,draw:r,mapProvider:n,pluginConfig:o,onDone:function(){c=!1,s()}}))};return i.on(a.MAP_STYLE_CHANGE,l),{handleSetMapStyle:u,handleStyleChanged:l}}({map:c,draw:d,mapProvider:n,pluginConfig:u,eventBus:i,events:o,notifyPointSymbolsRefreshed:y}),g=m.handleSetMapStyle,v=m.handleStyleChanged,b=function(e){c.fire("draw.scalechange",{scale:$t.$y[e]})};i.on(o.MAP_SET_SIZE,b);var S=function(e){fa({draw:d,mapProvider:n,map:c,pixelRatioOverride:e}).then(function(){c.triggerRepaint(),y()})};return i.on(o.MAP_SET_PIXEL_RATIO,S),{draw:d,remove:function(){f.remove(),i.off(o.MAP_SET_STYLE,g),i.off(o.MAP_STYLE_CHANGE,v),i.off(o.MAP_SET_SIZE,b),i.off(o.MAP_SET_PIXEL_RATIO,S),d.changeMode("disabled"),n.draw=null}}}({mapStyle:r.mapStyle,mapProvider:t,events:r.events,eventBus:r.eventBus,snapLayers:r.snapLayers,pluginConfig:null!==(n=r.pluginConfig)&&void 0!==n?n:{}}),s=a.draw,u=a.remove;this._draw=s,this._cleanupDraw=u,this._liveStroke=(0,Sa.De)({onChange:function(e,t){i._applyStrokeInvalid(e);var r=i._draw.getMode();"edit_vertex"!==r&&"edit_point"!==r||i._bus.emit(ba.k.VALIDITY_CHANGE,{valid:!e,reason:t})}}),this._liveDrawChecks=(0,wa.O)({onStrokeChange:function(e,t){return i._liveStroke.set(e,t)},onPlaceChange:function(e,t){return i._bus.emit(ba.k.CAN_PLACE_CHANGE,{canPlace:!e,reason:t})}}),this._mapHandlers={create:function(e){var t=e.features[0];setTimeout(function(){i._draw.setFeatureProperty(t.id,"sortKey",i._nextSortKey()),i._bus.emit(ba.k.CREATE,i._draw.get(t.id))},0)},editfinish:function(e){return i._bus.emit(ba.k.EDIT_FINISH,e.features[0])},cancel:function(){return i._bus.emit(ba.k.CANCEL)},vertexselection:function(e){return i._bus.emit(ba.k.VERTEX_SELECTION,_a(_a({},e),{},{numVertices:e.numVertecies}))},vertexchange:function(e){return i._bus.emit(ba.k.VERTEX_CHANGE,_a(_a({},e),{},{numVertices:e.numVertecies}))},undochange:function(e){return i._bus.emit(ba.k.UNDO_CHANGE,e.length)},update:function(e){return i._bus.emit(ba.k.UPDATE,e.features[0])},geometrychange:function(e){null!=e&&e.phase||(i._updateLiveStroke(e),i._currentDrawEvent=e),i._bus.emit(ba.k.GEOMETRY_CHANGE,e)},placementblocked:function(e){return i._bus.emit(ba.k.PLACEMENT_BLOCKED,e)},interfacetypechange:function(e){return i._bus.emit(ba.k.INTERFACE_TYPE_CHANGE,{interfaceType:e.interfaceType})},modechange:function(e){return i._handleModeChange(e)},styledata:function(){return i._handleStyleData()}},this._map.on(xt,this._mapHandlers.create),this._map.on(Ot,this._mapHandlers.editfinish),this._map.on(It,this._mapHandlers.cancel),this._map.on(Mt,this._mapHandlers.vertexselection),this._map.on(Ct,this._mapHandlers.vertexchange),this._map.on(Tt,this._mapHandlers.undochange),this._map.on(_t,this._mapHandlers.update),this._map.on(At,this._mapHandlers.geometrychange),this._map.on(kt,this._mapHandlers.placementblocked),this._map.on(jt,this._mapHandlers.interfacetypechange),this._map.on(Et,this._mapHandlers.modechange),this._map.on(Ft,this._mapHandlers.styledata)},t=[{key:"changeMode",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"edit_vertex"!==e&&"edit_point"!==e||(this._editingFeatureId=null!==(t=n.featureId)&&void 0!==t?t:null),"draw_polygon"!==e&&"draw_line"!==e||(this._liveStroke.set(!1),this._liveDrawChecks.reset()),"draw_point"===e&&(n=_a(_a({},n),{},{resolvePointSymbol:function(e,t){return r._resolvePointSymbol(e,t)}})),this._draw.changeMode(e,n),this._handleModeChange({mode:e})}},{key:"_resolvePointSymbol",value:function(e,t){return da({draw:this._draw,mapProvider:this._mapProvider,map:this._map,featureId:e,properties:t})}},{key:"_updateLiveStroke",value:function(e){if(null!=e&&e.coordinates){var t=this._draw.getMode(),r=Aa(t,e.coordinates);r&&("draw_polygon"===t||"draw_line"===t?this._liveDrawChecks.update({feature:r.feature,numVertices:r.numVertices,context:{mode:t},onGeometryChange:this._geometryValidator}):this._liveStroke.update(_a(_a({},r),{},{context:{mode:t},onGeometryChange:this._geometryValidator})))}}},{key:"getMode",value:function(){return this._draw.getMode()}},{key:"setInterfaceType",value:function(e){this._map.fire(jt,{interfaceType:e})}},{key:"done",value:function(){var e;null===(e=this._mapProvider.undoStack)||void 0===e||e.clear();var t=this._draw.getMode();if(("edit_vertex"===t||"edit_point"===t)&&this._editingFeatureId)return this._handleModeChange({mode:"disabled"}),void this._map.fire(Ot,{features:[this._draw.get(this._editingFeatureId)]});"draw_polygon"!==t&&"draw_line"!==t||(this._draw.changeMode("disabled"),this._handleModeChange({mode:"disabled"}))}},{key:"cancel",value:function(){var e;null===(e=this._mapProvider.undoStack)||void 0===e||e.clear();var t=this._draw.getMode();"draw_polygon"!==t&&"draw_line"!==t||this._draw.trash(),this._draw.changeMode("disabled"),this._handleModeChange({mode:"disabled"})}},{key:"undo",value:function(){this._map.fire("draw.undo")}},{key:"nudgeSelectedVertex",value:function(e,t,r){this._map.fire(Lt,{dx:e,dy:t,isLargeStep:r})}},{key:"setGeometryValid",value:function(e){this._map._drawGeometryValid=e}},{key:"_geometryValidator",get:function(){return this._map._drawGeometryValidator},set:function(e){this._map._drawGeometryValidator=e}},{key:"setInvalid",value:function(e){this._liveStroke.set(e)}},{key:"_applyStrokeInvalid",value:function(e){this._setLayerVisibility("stroke-active",!e),this._setLayerVisibility("stroke-active-invalid",e),this._setLayerVisibility("fill-active",!e)}},{key:"_setLayerVisibility",value:function(e,t){var r=this;["hot","cold"].forEach(function(n){var o="".concat(e,".").concat(n);r._map.getLayer(o)&&r._map.setLayoutProperty(o,"visibility",t?"visible":"none")})}},{key:"deleteVertex",value:function(){}},{key:"get",value:function(e){return this._draw.get(e)}},{key:"_nextSortKey",value:function(){return this._sortKeyCounter+=1,this._sortKeyCounter}},{key:"add",value:function(e){var t,r,n=null==(null===(t=e.properties)||void 0===t?void 0:t.sortKey)?_a(_a({},e.properties),{},{sortKey:this._nextSortKey()}):e.properties,o=_a(_a({},e),{},{properties:n}),i=this._draw.add(o);return"Point"===(null===(r=o.geometry)||void 0===r?void 0:r.type)&&sa(n)&&this._resolvePointSymbol(i[0],n),i}},{key:"setStyle",value:function(e,t){var r=this._draw.get(e);r&&this.add(_a(_a({},r),{},{properties:_a(_a({},r.properties),t)}))}},{key:"delete",value:function(e){this._draw.delete(e)}},{key:"deleteAll",value:function(){this._draw.deleteAll()}},{key:"setSnapEnabled",value:function(e){this._mapProvider.snapEnabled=e;var t=zt(this._map);null!=t&&t.setSnapStatus&&t.setSnapStatus(e),!e&&t&&(nr(t),this._map.getLayer("snap-helper-circle")&&this._map.setLayoutProperty("snap-helper-circle","visibility","none"))}},{key:"setSnapLayers",value:function(e){var t=zt(this._map);null!=t&&t.setSnapLayers?t.setSnapLayers(e):e&&(this._map._pendingSnapLayers=e)}},{key:"isSnapEnabled",value:function(){return!0===this._mapProvider.snapEnabled}},{key:"setFeatureProperty",value:function(e,t,r){this._draw.setFeatureProperty(e,t,r)}},{key:"setDrawingPreviewProperty",value:function(e,t){var r,n=this._currentDrawEvent;null!=n&&n.properties&&(n.properties[e]=t),null==n||null===(r=n.ctx)||void 0===r||null===(r=r.store)||void 0===r||r.render()}},{key:"on",value:function(e,t){this._bus.on(e,t)}},{key:"off",value:function(e,t){this._bus.off(e,t)}},{key:"_handleModeChange",value:function(e){new Set(["draw_polygon","draw_line","draw_point","edit_vertex","edit_point"]).has(e.mode)||rr(zt(this._map),this._map)}},{key:"_handleStyleData",value:function(){var e,t=this,r=this._map.getStyle();if(r){this._liveStroke.refresh();var n=r.layers||[];!n.length||null!==(e=n[n.length-1].source)&&void 0!==e&&e.startsWith("mapbox-gl-draw")||n.filter(function(e){var t;return null===(t=e.source)||void 0===t?void 0:t.startsWith("mapbox-gl-draw")}).forEach(function(e){return t._map.moveLayer(e.id)})}}},{key:"remove",value:function(){this._map.off(xt,this._mapHandlers.create),this._map.off(Ot,this._mapHandlers.editfinish),this._map.off(It,this._mapHandlers.cancel),this._map.off(Mt,this._mapHandlers.vertexselection),this._map.off(Ct,this._mapHandlers.vertexchange),this._map.off(Tt,this._mapHandlers.undochange),this._map.off(_t,this._mapHandlers.update),this._map.off(At,this._mapHandlers.geometrychange),this._map.off(kt,this._mapHandlers.placementblocked),this._map.off(jt,this._mapHandlers.interfacetypechange),this._map.off(Et,this._mapHandlers.modechange),this._map.off(Ft,this._mapHandlers.styledata),this._liveStroke.destroy(),this._liveDrawChecks.destroy(),this._cleanupDraw()}}],t&&Oa(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()},473(e,t,r){"use strict";r.d(t,{$:()=>i});var n=r(682);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}var i=function(e){var t,r,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=null!==(t=null==e?void 0:e.mapColorScheme)&&void 0!==t?t:"light",u=null!==(r=null==e?void 0:e.id)&&void 0!==r?r:null,c=function(e){var t;return function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return"object"!==o(e)||null===e?e:r&&void 0!==e[r]?e[r]:void 0!==e[t]?e[t]:void 0!==e.light?e.light:Object.values(e)[0]}(null!==(t=a[e])&&void 0!==t?t:n.lm[e],s,u)};return{editStroke:c("editStroke"),editFill:c("editFill"),editVertex:c("editVertex"),editMidpoint:c("editMidpoint"),editActive:c("editActive"),editHalo:c("editHalo"),invalidStroke:c("invalidStroke"),splitValid:c("splitValid"),splitInvalid:c("splitInvalid"),shapeStroke:c("shapeStroke"),strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:n.F0.strokeWidth,shapeFill:c("shapeFill"),snapVertex:c("snapVertex"),snapEdge:c("snapEdge"),mapStyleId:u}}},722(e,t,r){"use strict";r.d(t,{$X:()=>u,DD:()=>i,Ox:()=>s,ZP:()=>a,mt:()=>c});var n=r(682),o=n.F0.touchTargetSize/2,i=function(e){var t,r,i=e.querySelector("[data-im-draw-touch-target]");return i||(e.insertAdjacentHTML("beforeend",(t=n.F0.touchTargetSize,r=o,"\n <svg width='".concat(t,"' height='").concat(t,"' viewBox='0 0 48 48' fill-rule='evenodd'\n style='display:none;position:absolute;top:0;left:0;margin:").concat(r,"px 0 0 -").concat(r,"px;cursor:grab'\n class='im-draw-touch-target' data-im-draw-touch-target>\n <circle cx='24' cy='24' r='24' fill='var(--draw-halo, #000)'/>\n <path d=\"M37.543 25H34a1 1 0 1 1 0-2h3.629l-.836-.837a1 1 0 0 1 1.414-1.414l2.5 2.501A1 1 0 0 1 41 24a1 1 0 0 1-.487.858l-2.306 2.306a1 1 0 0 1-1.414-1.414l.75-.75zM23 10.414l-.793.793a1 1 0 0 1-1.414-1.414l2.5-2.5C23.481 7.105 23.734 7 24 7s.519.105.707.293l2.5 2.5a1 1 0 0 1-1.414 1.414L25 10.414V14a1 1 0 1 1-2 0v-3.586zM7 24a1 1 0 0 1 .293-.75l2.5-2.501a1 1 0 0 1 1.414 1.414l-.836.837H14a1 1 0 1 1 0 2h-3.543l.75.75a1 1 0 0 1-1.414 1.414l-2.306-2.306A1 1 0 0 1 7 24zm16.293 16.707l-2.5-2.5a1 1 0 0 1 1.414-1.414l.793.793V34a1 1 0 1 1 2 0v3.586l.793-.793a1 1 0 0 1 1.414 1.414l-2.5 2.5c-.188.188-.441.293-.707.293s-.519-.105-.707-.293zM24 20c2.208 0 4 1.792 4 4s-1.792 4-4 4-4-1.792-4-4 1.792-4 4-4z\" fill='var(--draw-bg, #fff)'/>\n </svg>\n "))),i=e.querySelector("[data-im-draw-touch-target]")),i},a=function(e,t){e&&(e.style.setProperty("--draw-halo",t.editActive),e.style.setProperty("--draw-bg",t.editHalo),e.style.setProperty("--draw-primary",t.editVertex))},s=function(e,t){t&&e&&(e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px"),e.style.display="block")},u=function(e){e&&(e.style.display="none")},c=function(e){if(!e)return!1;var t=e.parentNode;return t instanceof globalThis.SVGElement||null!=(null==t?void 0:t.ownerSVGElement)}},610(e,t,r){"use strict";r.d(t,{B:()=>n});var n=function(e){var t=[];return{push:function(r){t.push(r),e(t.length)},pop:function(){var r=t.pop();return e(t.length),r},clear:function(){t.length=0,e(t.length)},get length(){return t.length}}}},715(e,t,r){"use strict";r.d(t,{O:()=>l});var n=r(520),o=r(9),i=r(788);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach(function(t){c(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function c(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var l=function(e){var t=e.onStrokeChange,r=e.onPlaceChange,a=function(e){var t=!1;return function(r,n){r!==t&&(t=r,e(r,null!=n?n:null))}},s=a(t),c=a(r),l=!1,d=null,f=null,p=null,h=function(){null!=f&&((0,i.WG)(f),f=null),p=null},y=function(e,t,r,o,i){var a,s=(null!==(a=t.numVertices)&&void 0!==a?a:0)<o?{valid:!0}:(0,n.$U)(e,u(u({},t),{},{phase:"preview"}),{rules:r});i(!s.valid||l,s.valid?d:s.reason)},m=function(){var e,t;if(p){var r=p,n=r.feature,i=r.context,a=null!==(e=o.n8[null==n||null===(t=n.geometry)||void 0===t?void 0:t.type])&&void 0!==e?e:0;y(n,i,o.PI,a,s),y(n,i,o.Oo,0,c)}},g=function(){if(f=null,p){var e=p,t=e.feature,r=e.context,o=e.onGeometryChange,i=(0,n.$U)(t,u(u({},r),{},{phase:"preview"}),{rules:[],onGeometryChange:o});l=!i.valid,d=i.reason,m()}};return{update:function(e){var t=e.feature,r=e.context,n=void 0===r?{}:r,o=e.numVertices,a=e.onGeometryChange;p={feature:t,context:u(u({},n),{},{numVertices:o}),onGeometryChange:a},m(),"function"==typeof a&&null==f&&(f=(0,i.PW)(g))},reset:function(){h(),l=!1,d=null,s(!1,null),c(!1,null)},destroy:function(){h()}}}},788(e,t,r){"use strict";r.d(t,{De:()=>l,PW:()=>u,WG:()=>c});var n=r(520);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var u=function(e){return"function"==typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,16)},c=function(e){return"function"==typeof cancelAnimationFrame?cancelAnimationFrame(e):clearTimeout(e)},l=function(e){var t=e.onChange,r=e.validate,o=void 0===r?n.Uk:r,i=!1,s=null,l=null,d=function(){null!=s&&(c(s),s=null),l=null},f=function(e,r){e!==i&&(i=e,t(e,null!=r?r:null))},p=function(){if(s=null,l){var e=l,t=e.feature,r=e.context,n=e.onGeometryChange,i=o(t,r,{onGeometryChange:n}),a=i.valid,u=i.reason;f(!a,u)}};return{update:function(e){var t=e.feature,r=e.context,n=void 0===r?{}:r,i=e.numVertices,c=e.onGeometryChange,h=a(a({},n),{},{numVertices:i}),y=o(t,h);return y.valid?"function"!=typeof c?(d(),void f(!1,null)):(l={feature:t,context:h,onGeometryChange:c},void(null==s&&(s=u(p)))):(d(),void f(!0,y.reason))},set:function(e,t){d(),f(e,null!=t?t:null)},refresh:function(){t(i,null)},destroy:function(){d()}}}},600(e,t,r){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}r.d(t,{a:()=>T});var o=function(e,t){if(!e)return null;if("string"==typeof e)return e.trim();if("object"===n(e)){if(t&&e[t])return e[t];var r=Object.values(e)[0];return null!=r?r:null}return null},i={symbol:"pin",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},a={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},s={id:"pin",viewBox:"0 0 44 44",anchor:[.5,.9],graphic:a.dot,svg:'<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},u={id:"circle",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:a.dot,svg:'<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},c={id:"square",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:a.dot,svg:'<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},l=r(121),d={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}},f=function(e,t,r){return new Promise(function(n,o){var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(e)),a=new Image(t,r);a.onload=function(){var e=document.createElement("canvas");e.width=t,e.height=r;var o=e.getContext("2d");o.drawImage(a,0,0,t,r),n(o.getImageData(0,0,t,r))},a.onerror=function(){o(new Error("Failed to rasterise SVG: ".concat(e.slice(0,80))))},a.src=i})};function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function h(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return y(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return i=t,s=0,u=e,f.n=r,a}};function p(r,n){for(s=r,u=n,t=0;!d&&c&&!o&&t<l.length;t++){var o,i=l[t],p=f.p,h=i[2];r>3?(o=h===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=r<2&&p<i[1])?(s=0,f.v=n,f.n=i[1]):p<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,f.n=h,s=0))}if(o||r>1)return a;throw d=!0,n}return function(o,l,h){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,h),s=l,u=h;(t=s<2?e:u)||!d;){i||(s?s<3?(s>1&&(f.n=-1),p(s,u)):f.n=u:f.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?u:r.call(n,f))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(y(t={},n,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,y(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,y(d,"constructor",c),y(c,"constructor",u),u.displayName="GeneratorFunction",y(c,o,"GeneratorFunction"),y(d),y(d,o,"Generator"),y(d,n,function(){return this}),y(d,"toString",function(){return"[object Generator]"}),(h=function(){return{w:i,m:f}})()}function y(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}y=function(e,t,r,n){function i(t,r){y(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},y(e,t,r,n)}function m(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach(function(t){b(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function b(e,t,r){return(t=function(e){var t=function(e){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==p(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||w(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e,t){if(e){if("string"==typeof e)return P(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var x=new Map,_=new Map,E={},O=function(e){var t,r=0,n=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=w(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(e);try{for(n.s();!(t=n.n()).done;){var o=t.value;r=Math.trunc((r<<5)-r+o.codePointAt(0))}}catch(e){n.e(e)}finally{n.f()}return Math.abs(r).toString(36)},I=new Set(["id","svg","viewBox","anchor","symbol","symbolSvgContent"]);function M(e,t,r){var n,s,u,c,l=null==r?void 0:r.id,f=Object.fromEntries(Object.entries(e||{}).filter(function(e){var t=S(e,1)[0];return!I.has(t)})),p=Object.fromEntries(Object.entries(E).filter(function(e){var t=S(e,1)[0];return!I.has(t)})),h=Object.fromEntries(Object.entries(t).filter(function(e){return null!=S(e,2)[1]})),y=v(v(v(v({},i),p),f),h),m=null!==(n=d[null==r?void 0:r.mapColorScheme])&&void 0!==n?n:d.light;return y.haloColor=null!==(s=null==r?void 0:r.haloColor)&&void 0!==s?s:m.haloColor,y.selectedColor=null!==(u=null==r?void 0:r.selectedColor)&&void 0!==u?u:m.selectedColor,y.activeColor=null!==(c=null==r?void 0:r.activeColor)&&void 0!==c?c:m.activeColor,"string"==typeof y.graphic&&a[y.graphic]&&(y.graphic=a[y.graphic]),Object.fromEntries(Object.entries(y).map(function(e){var t=S(e,2),r=t[0],n=t[1];return[r,o(n,l)||""]}))}function C(e,t){return Object.entries(t).reduce(function(e,t){var r=S(t,2),n=r[0],o=r[1];return e.replaceAll("{{".concat(n,"}}"),o)},e)}var T={setDefaults:function(e){E=e||{}},getDefaults:function(){return v(v({},i),E)},register:function(e){x.set(e.id,e)},get:function(e){return x.get(e)},list:function(){return function(e){if(Array.isArray(e))return P(e)}(e=x.values())||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||w(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var e},clear:function(){x.clear()},initialise:function(){this.register(s),this.register(u),this.register(c)},resolve:function(e,t,r){var n=M(e,t||{},r);return e?(n.selectedColor="none",n.activeColor="none",C(e.svg,n)):""},resolveActive:function(e,t,r){var n=M(e,t||{},r);return e?C(e.svg,n):""},resolveSelected:function(e,t,r){var n=M(e,t||{},r);return e?(n.activeColor="none",C(e.svg,n)):""},getSymbolImageId:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,o=this.getSymbolDef(e);if(!o)return null;var i=(0,l.sR)(e),a=r?this.resolveActive(o,i,t):this.resolve(o,i,t);return"symbol-".concat(r?"act-":"").concat(O(a),"-").concat(n,"x")},getSymbolDef:function(e){return e.symbolSvgContent?{svg:e.symbolSvgContent}:e.symbol?this.get(e.symbol):void 0},rasteriseSymbolImage:function(e,t,r,n){var o,i=this;return(o=h().m(function o(){var a,s,u,c,d,p,y,m,g,v,b,w;return h().w(function(o){for(;;)switch(o.n){case 0:if(a=i.getSymbolDef(e)){o.n=1;break}return o.a(2,null);case 1:if(s=(0,l.sR)(e),"active"===r?(u=i.resolveActive(a,s,t),c="act-"):"selected"===r?(u=i.resolveSelected(a,s,t),c="sel-"):(u=i.resolve(a,s,t),c=""),d="symbol-".concat(c).concat(O(u),"-").concat(n,"x"),p=_.get(d)){o.n=3;break}return y=(0,l.n8)(e,a),m=y.split(" ").map(Number),g=S(m,4),v=g[2],b=g[3],w='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(v*n,'" height="').concat(b*n,'" viewBox="').concat(y,'">').concat(u,"</svg>"),o.n=2,f(w,v*n,b*n);case 2:p=o.v,_.set(d,p);case 3:return o.a(2,{imageId:d,imageData:p})}},o)}),function(){var e=this,t=arguments;return new Promise(function(r,n){var i=o.apply(e,t);function a(e){m(i,r,n,a,s,"next",e)}function s(e){m(i,r,n,a,s,"throw",e)}a(void 0)})})()}};T.initialise()},121(e,t,r){"use strict";r.d(t,{Op:()=>a,n8:()=>i,sR:()=>o});var n=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),o=function(e){if(!function(e){return!(!e.symbol&&!e.symbolSvgContent)}(e))return{};var t={};return n.forEach(function(r){if(null!=e[r]){var n=r.charAt(6).toLowerCase()+r.slice(7);t[n]=e[r]}}),t},i=function(e,t){var r;return e.symbolViewBox?e.symbolViewBox:null!==(r=null==t?void 0:t.viewBox)&&void 0!==r?r:"0 0 38 38"},a=function(e,t){var r;return e.symbolAnchor?e.symbolAnchor:null!==(r=null==t?void 0:t.anchor)&&void 0!==r?r:[.5,.5]}}}]);
|
|
2
|
+
(this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[356],{778(e,t,r){var n=r(628);function o(e){var t=0;if(e&&e.length>0){t+=Math.abs(i(e[0]));for(var r=1;r<e.length;r++)t-=Math.abs(i(e[r]))}return t}function i(e){var t,r,o,i,s,u,c=0,l=e.length;if(l>2){for(u=0;u<l;u++)u===l-2?(o=l-2,i=l-1,s=0):u===l-1?(o=l-1,i=0,s=1):(o=u,i=u+1,s=u+2),t=e[o],r=e[i],c+=(a(e[s][0])-a(t[0]))*Math.sin(a(r[1]));c=c*n.RADIUS*n.RADIUS/2}return c}function a(e){return e*Math.PI/180}e.exports.geometry=function e(t){var r,n=0;switch(t.type){case"Polygon":return o(t.coordinates);case"MultiPolygon":for(r=0;r<t.coordinates.length;r++)n+=o(t.coordinates[r]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(r=0;r<t.geometries.length;r++)n+=e(t.geometries[r]);return n}},e.exports.ring=i},186(e){e.exports=function(e){if(!e||!e.type)return null;var r=t[e.type];return r?"geometry"===r?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:e}]}:"feature"===r?{type:"FeatureCollection",features:[e]}:"featurecollection"===r?e:void 0:null};var t={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},17(e){"use strict";e.exports=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,o,i;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(o=n;0!==o--;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(i=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(o=n;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=n;0!==o--;){var a=i[o];if(!e(t[a],r[a]))return!1}return!0}return t!=t&&r!=r}},945(e,t,r){var n=r(341),o=r(339),i=r(609),a=r(368).Ay,s=i.featureEach,u=(i.coordEach,o.polygon,o.featureCollection);function c(e){var t=new n(e);return t.insert=function(e){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:a(e),n.prototype.insert.call(this,e)},t.load=function(e){var t=[];return Array.isArray(e)?e.forEach(function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:a(e),t.push(e)}):s(e,function(e){if("Feature"!==e.type)throw new Error("invalid features");e.bbox=e.bbox?e.bbox:a(e),t.push(e)}),n.prototype.load.call(this,t)},t.remove=function(e,t){if("Feature"!==e.type)throw new Error("invalid feature");return e.bbox=e.bbox?e.bbox:a(e),n.prototype.remove.call(this,e,t)},t.clear=function(){return n.prototype.clear.call(this)},t.search=function(e){var t=n.prototype.search.call(this,this.toBBox(e));return u(t)},t.collides=function(e){return n.prototype.collides.call(this,this.toBBox(e))},t.all=function(){var e=n.prototype.all.call(this);return u(e)},t.toJSON=function(){return n.prototype.toJSON.call(this)},t.fromJSON=function(e){return n.prototype.fromJSON.call(this,e)},t.toBBox=function(e){var t;if(e.bbox)t=e.bbox;else if(Array.isArray(e)&&4===e.length)t=e;else if(Array.isArray(e)&&6===e.length)t=[e[0],e[1],e[3],e[4]];else if("Feature"===e.type)t=a(e);else{if("FeatureCollection"!==e.type)throw new Error("invalid geojson");t=a(e)}return{minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]}},t}e.exports=c,e.exports.default=c},339(e,t){"use strict";function r(e,t,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function n(e,t,n){if(void 0===n&&(n={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!p(e[0])||!p(e[1]))throw new Error("coordinates must contain numbers");return r({type:"Point",coordinates:e},t,n)}function o(e,t,n){void 0===n&&(n={});for(var o=0,i=e;o<i.length;o++){var a=i[o];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return r({type:"Polygon",coordinates:e},t,n)}function i(e,t,n){if(void 0===n&&(n={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return r({type:"LineString",coordinates:e},t,n)}function a(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function s(e,t,n){return void 0===n&&(n={}),r({type:"MultiLineString",coordinates:e},t,n)}function u(e,t,n){return void 0===n&&(n={}),r({type:"MultiPoint",coordinates:e},t,n)}function c(e,t,n){return void 0===n&&(n={}),r({type:"MultiPolygon",coordinates:e},t,n)}function l(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e*n}function d(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e/n}function f(e){return e%(2*Math.PI)*180/Math.PI}function p(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.earthRadius=6371008.8,t.factors={centimeters:100*t.earthRadius,centimetres:100*t.earthRadius,degrees:t.earthRadius/111325,feet:3.28084*t.earthRadius,inches:39.37*t.earthRadius,kilometers:t.earthRadius/1e3,kilometres:t.earthRadius/1e3,meters:t.earthRadius,metres:t.earthRadius,miles:t.earthRadius/1609.344,millimeters:1e3*t.earthRadius,millimetres:1e3*t.earthRadius,nauticalmiles:t.earthRadius/1852,radians:1,yards:1.0936*t.earthRadius},t.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/t.earthRadius,yards:1.0936133},t.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046},t.feature=r,t.geometry=function(e,t,r){switch(void 0===r&&(r={}),e){case"Point":return n(t).geometry;case"LineString":return i(t).geometry;case"Polygon":return o(t).geometry;case"MultiPoint":return u(t).geometry;case"MultiLineString":return s(t).geometry;case"MultiPolygon":return c(t).geometry;default:throw new Error(e+" is invalid")}},t.point=n,t.points=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return n(e,t)}),r)},t.polygon=o,t.polygons=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return o(e,t)}),r)},t.lineString=i,t.lineStrings=function(e,t,r){return void 0===r&&(r={}),a(e.map(function(e){return i(e,t)}),r)},t.featureCollection=a,t.multiLineString=s,t.multiPoint=u,t.multiPolygon=c,t.geometryCollection=function(e,t,n){return void 0===n&&(n={}),r({type:"GeometryCollection",geometries:e},t,n)},t.round=function(e,t){if(void 0===t&&(t=0),t&&!(t>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,t||0);return Math.round(e*r)/r},t.radiansToLength=l,t.lengthToRadians=d,t.lengthToDegrees=function(e,t){return f(d(e,t))},t.bearingToAzimuth=function(e){var t=e%360;return t<0&&(t+=360),t},t.radiansToDegrees=f,t.degreesToRadians=function(e){return e%360*Math.PI/180},t.convertLength=function(e,t,r){if(void 0===t&&(t="kilometers"),void 0===r&&(r="kilometers"),!(e>=0))throw new Error("length must be a positive number");return l(d(e,t),r)},t.convertArea=function(e,r,n){if(void 0===r&&(r="meters"),void 0===n&&(n="kilometers"),!(e>=0))throw new Error("area must be a positive number");var o=t.areaFactors[r];if(!o)throw new Error("invalid original units");var i=t.areaFactors[n];if(!i)throw new Error("invalid final units");return e/o*i},t.isNumber=p,t.isObject=function(e){return!!e&&e.constructor===Object},t.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(function(e){if(!p(e))throw new Error("bbox must only contain numbers")})},t.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},609(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(339);function o(e,t,r){if(null!==e)for(var n,i,a,s,u,c,l,d,f=0,p=0,h=e.type,y="FeatureCollection"===h,m="Feature"===h,g=y?e.features.length:1,v=0;v<g;v++){u=(d=!!(l=y?e.features[v].geometry:m?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var S=0,w=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var x=s.type;switch(f=!r||"Polygon"!==x&&"MultiPolygon"!==x?0:1,x){case null:break;case"Point":if(!1===t(c,p,v,S,w))return!1;p++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],p,v,S,w))return!1;p++,"MultiPoint"===x&&S++}"LineString"===x&&S++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-f;i++){if(!1===t(c[n][i],p,v,S,w))return!1;p++}"MultiLineString"===x&&S++,"Polygon"===x&&w++}"Polygon"===x&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(w=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-f;a++){if(!1===t(c[n][i][a],p,v,S,w))return!1;p++}w++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,f=0,p="FeatureCollection"===e.type,h="Feature"===e.type,y=p?e.features.length:1;for(r=0;r<y;r++){for(s=p?e.features[r].geometry:h?e.geometry:e,c=p?e.features[r].properties:h?e.properties:{},l=p?e.features[r].bbox:h?e.bbox:void 0,d=p?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,f,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],f,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,f,c,l,d))return!1;f++}}function u(e,t){s(e,function(e,r,o,i,a){var s,u=null===e?null:e.type;switch(u){case null:case"Point":case"LineString":case"Polygon":return!1!==t(n.feature(e,o,{bbox:i,id:a}),r,0)&&void 0}switch(u){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<e.coordinates.length;c++){var l={type:s,coordinates:e.coordinates[c]};if(!1===t(n.feature(l,o),r,c))return!1}})}function c(e,t){u(e,function(e,r,i){var a=0;if(e.geometry){var s=e.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var u,c=0,l=0,d=0;return!1!==o(e,function(o,s,f,p,h){if(void 0===u||r>c||p>l||h>d)return u=o,c=r,l=p,d=h,void(a=0);var y=n.lineString([u,o],e.properties);if(!1===t(y,r,i,h,a))return!1;a++,u=o})&&void 0}}})}function l(e,t){if(!e)throw new Error("geojson is required");u(e,function(e,r,o){if(null!==e.geometry){var i=e.geometry.type,a=e.geometry.coordinates;switch(i){case"LineString":if(!1===t(e,r,o,0,0))return!1;break;case"Polygon":for(var s=0;s<a.length;s++)if(!1===t(n.lineString(a[s],e.properties),r,o,s))return!1}}})}t.coordAll=function(e){var t=[];return o(e,function(e){t.push(e)}),t},t.coordEach=o,t.coordReduce=function(e,t,r,n){var i=r;return o(e,function(e,n,o,a,s){i=0===n&&void 0===r?e:t(i,e,n,o,a,s)},n),i},t.featureEach=a,t.featureReduce=function(e,t,r){var n=r;return a(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.findPoint=function(e,t){if(t=t||{},!n.isObject(t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.coordIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":return n.point(c,u,t);case"MultiPoint":return i<0&&(i=c.length+i),n.point(c[i],u,t);case"LineString":return s<0&&(s=c.length+s),n.point(c[s],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s),n.point(c[a][s],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),n.point(c[i][s],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s),n.point(c[i][a][s],u,t)}throw new Error("geojson is invalid")},t.findSegment=function(e,t){if(t=t||{},!n.isObject(t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.segmentIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),n.lineString([c[s],c[s+1]],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s-1),n.lineString([c[a][s],c[a][s+1]],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),n.lineString([c[i][s],c[i][s+1]],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s-1),n.lineString([c[i][a][s],c[i][a][s+1]],u,t)}throw new Error("geojson is invalid")},t.flattenEach=u,t.flattenReduce=function(e,t,r){var n=r;return u(e,function(e,o,i){n=0===o&&0===i&&void 0===r?e:t(n,e,o,i)}),n},t.geomEach=s,t.geomReduce=function(e,t,r){var n=r;return s(e,function(e,o,i,a,s){n=0===o&&void 0===r?e:t(n,e,o,i,a,s)}),n},t.lineEach=l,t.lineReduce=function(e,t,r){var n=r;return l(e,function(e,o,i,a){n=0===o&&void 0===r?e:t(n,e,o,i,a)}),n},t.propEach=i,t.propReduce=function(e,t,r){var n=r;return i(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.segmentEach=c,t.segmentReduce=function(e,t,r){var n=r,o=!1;return c(e,function(e,i,a,s,u){n=!1===o&&void 0===r?e:t(n,e,i,a,s,u),o=!0}),n}},341(e){e.exports=function(){"use strict";function e(e,n,o,i,a){!function e(r,n,o,i,a){for(;i>o;){if(i-o>600){var s=i-o+1,u=n-o+1,c=Math.log(s),l=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*l*(s-l)/s)*(u-s/2<0?-1:1);e(r,n,Math.max(o,Math.floor(n-u*l/s+d)),Math.min(i,Math.floor(n+(s-u)*l/s+d)),a)}var f=r[n],p=o,h=i;for(t(r,o,n),a(r[i],f)>0&&t(r,o,i);p<h;){for(t(r,p,h),p++,h--;a(r[p],f)<0;)p++;for(;a(r[h],f)>0;)h--}0===a(r[o],f)?t(r,o,h):t(r,++h,i),h<=n&&(o=h+1),n<=h&&(i=h-1)}}(e,n,o||0,i||e.length-1,a||r)}function t(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function r(e,t){return e<t?-1:e>t?1:0}var n=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function o(e,t,r){if(!r)return t.indexOf(e);for(var n=0;n<t.length;n++)if(r(e,t[n]))return n;return-1}function i(e,t){a(e,0,e.children.length,t,e)}function a(e,t,r,n,o){o||(o=h(null)),o.minX=1/0,o.minY=1/0,o.maxX=-1/0,o.maxY=-1/0;for(var i=t;i<r;i++){var a=e.children[i];s(o,e.leaf?n(a):a)}return o}function s(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function u(e,t){return e.minX-t.minX}function c(e,t){return e.minY-t.minY}function l(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function d(e){return e.maxX-e.minX+(e.maxY-e.minY)}function f(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function p(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function h(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function y(t,r,n,o,i){for(var a=[r,n];a.length;)if(!((n=a.pop())-(r=a.pop())<=o)){var s=r+Math.ceil((n-r)/o/2)*o;e(t,s,r,n,i),a.push(r,s,s,n)}}return n.prototype.all=function(){return this._all(this.data,[])},n.prototype.search=function(e){var t=this.data,r=[];if(!p(e,t))return r;for(var n=this.toBBox,o=[];t;){for(var i=0;i<t.children.length;i++){var a=t.children[i],s=t.leaf?n(a):a;p(e,s)&&(t.leaf?r.push(a):f(e,s)?this._all(a,r):o.push(a))}t=o.pop()}return r},n.prototype.collides=function(e){var t=this.data;if(!p(e,t))return!1;for(var r=[];t;){for(var n=0;n<t.children.length;n++){var o=t.children[n],i=t.leaf?this.toBBox(o):o;if(p(e,i)){if(t.leaf||f(e,i))return!0;r.push(o)}}t=r.pop()}return!1},n.prototype.load=function(e){if(!e||!e.length)return this;if(e.length<this._minEntries){for(var t=0;t<e.length;t++)this.insert(e[t]);return this}var r=this._build(e.slice(),0,e.length-1,0);if(this.data.children.length)if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){var n=this.data;this.data=r,r=n}this._insert(r,this.data.height-r.height-1,!0)}else this.data=r;return this},n.prototype.insert=function(e){return e&&this._insert(e,this.data.height-1),this},n.prototype.clear=function(){return this.data=h([]),this},n.prototype.remove=function(e,t){if(!e)return this;for(var r,n,i,a=this.data,s=this.toBBox(e),u=[],c=[];a||u.length;){if(a||(a=u.pop(),n=u[u.length-1],r=c.pop(),i=!0),a.leaf){var l=o(e,a.children,t);if(-1!==l)return a.children.splice(l,1),u.push(a),this._condense(u),this}i||a.leaf||!f(a,s)?n?(r++,a=n.children[r],i=!1):a=null:(u.push(a),c.push(r),r=0,n=a,a=a.children[0])}return this},n.prototype.toBBox=function(e){return e},n.prototype.compareMinX=function(e,t){return e.minX-t.minX},n.prototype.compareMinY=function(e,t){return e.minY-t.minY},n.prototype.toJSON=function(){return this.data},n.prototype.fromJSON=function(e){return this.data=e,this},n.prototype._all=function(e,t){for(var r=[];e;)e.leaf?t.push.apply(t,e.children):r.push.apply(r,e.children),e=r.pop();return t},n.prototype._build=function(e,t,r,n){var o,a=r-t+1,s=this._maxEntries;if(a<=s)return i(o=h(e.slice(t,r+1)),this.toBBox),o;n||(n=Math.ceil(Math.log(a)/Math.log(s)),s=Math.ceil(a/Math.pow(s,n-1))),(o=h([])).leaf=!1,o.height=n;var u=Math.ceil(a/s),c=u*Math.ceil(Math.sqrt(s));y(e,t,r,c,this.compareMinX);for(var l=t;l<=r;l+=c){var d=Math.min(l+c-1,r);y(e,l,d,u,this.compareMinY);for(var f=l;f<=d;f+=u){var p=Math.min(f+u-1,d);o.children.push(this._build(e,f,p,n-1))}}return i(o,this.toBBox),o},n.prototype._chooseSubtree=function(e,t,r,n){for(;n.push(t),!t.leaf&&n.length-1!==r;){for(var o=1/0,i=1/0,a=void 0,s=0;s<t.children.length;s++){var u=t.children[s],c=l(u),d=(f=e,p=u,(Math.max(p.maxX,f.maxX)-Math.min(p.minX,f.minX))*(Math.max(p.maxY,f.maxY)-Math.min(p.minY,f.minY))-c);d<i?(i=d,o=c<o?c:o,a=u):d===i&&c<o&&(o=c,a=u)}t=a||t.children[0]}var f,p;return t},n.prototype._insert=function(e,t,r){var n=r?e:this.toBBox(e),o=[],i=this._chooseSubtree(n,this.data,t,o);for(i.children.push(e),s(i,n);t>=0&&o[t].children.length>this._maxEntries;)this._split(o,t),t--;this._adjustParentBBoxes(n,o,t)},n.prototype._split=function(e,t){var r=e[t],n=r.children.length,o=this._minEntries;this._chooseSplitAxis(r,o,n);var a=this._chooseSplitIndex(r,o,n),s=h(r.children.splice(a,r.children.length-a));s.height=r.height,s.leaf=r.leaf,i(r,this.toBBox),i(s,this.toBBox),t?e[t-1].children.push(s):this._splitRoot(r,s)},n.prototype._splitRoot=function(e,t){this.data=h([e,t]),this.data.height=e.height+1,this.data.leaf=!1,i(this.data,this.toBBox)},n.prototype._chooseSplitIndex=function(e,t,r){for(var n,o,i,s,u,c,d,f=1/0,p=1/0,h=t;h<=r-t;h++){var y=a(e,0,h,this.toBBox),m=a(e,h,r,this.toBBox),g=(o=y,i=m,void 0,void 0,void 0,void 0,s=Math.max(o.minX,i.minX),u=Math.max(o.minY,i.minY),c=Math.min(o.maxX,i.maxX),d=Math.min(o.maxY,i.maxY),Math.max(0,c-s)*Math.max(0,d-u)),v=l(y)+l(m);g<f?(f=g,n=h,p=v<p?v:p):g===f&&v<p&&(p=v,n=h)}return n||r-t},n.prototype._chooseSplitAxis=function(e,t,r){var n=e.leaf?this.compareMinX:u,o=e.leaf?this.compareMinY:c;this._allDistMargin(e,t,r,n)<this._allDistMargin(e,t,r,o)&&e.children.sort(n)},n.prototype._allDistMargin=function(e,t,r,n){e.children.sort(n);for(var o=this.toBBox,i=a(e,0,t,o),u=a(e,r-t,r,o),c=d(i)+d(u),l=t;l<r-t;l++){var f=e.children[l];s(i,e.leaf?o(f):f),c+=d(i)}for(var p=r-t-1;p>=t;p--){var h=e.children[p];s(u,e.leaf?o(h):h),c+=d(u)}return c},n.prototype._adjustParentBBoxes=function(e,t,r){for(var n=r;n>=0;n--)s(t[n],e)},n.prototype._condense=function(e){for(var t=e.length-1,r=void 0;t>=0;t--)0===e[t].children.length?t>0?(r=e[t-1].children).splice(r.indexOf(e[t]),1):this.clear():i(e[t],this.toBBox)},n}()},628(e){e.exports.RADIUS=6378137,e.exports.FLATTENING=1/298.257223563,e.exports.POLAR_RADIUS=6356752.3142},368(e,t,r){"use strict";var n=r(861);var o=function(e,t={}){if(null!=e.bbox&&!0!==t.recompute)return e.bbox;const r=[1/0,1/0,-1/0,-1/0];return n.coordEach.call(void 0,e,e=>{r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])}),r};t.Ay=o},391(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=6371008.8,n={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*r,kilometers:6371.0088,kilometres:6371.0088,meters:r,metres:r,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:r/1852,radians:1,yards:6967335.223679999},o={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,nauticalmiles:2.9155334959812285e-7,millimeters:1e6,millimetres:1e6,yards:1.195990046};function i(e,t,r={}){const n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function a(e,t,r={}){if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!m(e[0])||!m(e[1]))throw new Error("coordinates must contain numbers");return i({type:"Point",coordinates:e},t,r)}function s(e,t,r={}){for(const t of e){if(t.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(t[t.length-1].length!==t[0].length)throw new Error("First and last Position are not equivalent.");for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw new Error("First and last Position are not equivalent.")}return i({type:"Polygon",coordinates:e},t,r)}function u(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return i({type:"LineString",coordinates:e},t,r)}function c(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function l(e,t,r={}){return i({type:"MultiLineString",coordinates:e},t,r)}function d(e,t,r={}){return i({type:"MultiPoint",coordinates:e},t,r)}function f(e,t,r={}){return i({type:"MultiPolygon",coordinates:e},t,r)}function p(e,t="kilometers"){const r=n[t];if(!r)throw new Error(t+" units is invalid");return e*r}function h(e,t="kilometers"){const r=n[t];if(!r)throw new Error(t+" units is invalid");return e/r}function y(e){return e%(2*Math.PI)*180/Math.PI}function m(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}t.areaFactors=o,t.azimuthToBearing=function(e){return(e%=360)>180?e-360:e<-180?e+360:e},t.bearingToAzimuth=function(e){let t=e%360;return t<0&&(t+=360),t},t.convertArea=function(e,t="meters",r="kilometers"){if(!(e>=0))throw new Error("area must be a positive number");const n=o[t];if(!n)throw new Error("invalid original units");const i=o[r];if(!i)throw new Error("invalid final units");return e/n*i},t.convertLength=function(e,t="kilometers",r="kilometers"){if(!(e>=0))throw new Error("length must be a positive number");return p(h(e,t),r)},t.degreesToRadians=function(e){return e%360*Math.PI/180},t.earthRadius=r,t.factors=n,t.feature=i,t.featureCollection=c,t.geometry=function(e,t,r={}){switch(e){case"Point":return a(t).geometry;case"LineString":return u(t).geometry;case"Polygon":return s(t).geometry;case"MultiPoint":return d(t).geometry;case"MultiLineString":return l(t).geometry;case"MultiPolygon":return f(t).geometry;default:throw new Error(e+" is invalid")}},t.geometryCollection=function(e,t,r={}){return i({type:"GeometryCollection",geometries:e},t,r)},t.isNumber=m,t.isObject=function(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)},t.lengthToDegrees=function(e,t){return y(h(e,t))},t.lengthToRadians=h,t.lineString=u,t.lineStrings=function(e,t,r={}){return c(e.map(e=>u(e,t)),r)},t.multiLineString=l,t.multiPoint=d,t.multiPolygon=f,t.point=a,t.points=function(e,t,r={}){return c(e.map(e=>a(e,t)),r)},t.polygon=s,t.polygons=function(e,t,r={}){return c(e.map(e=>s(e,t)),r)},t.radiansToDegrees=y,t.radiansToLength=p,t.round=function(e,t=0){if(t&&!(t>=0))throw new Error("precision must be a positive number");const r=Math.pow(10,t||0);return Math.round(e*r)/r},t.validateBBox=function(e){if(!e)throw new Error("bbox is required");if(!Array.isArray(e))throw new Error("bbox must be an Array");if(4!==e.length&&6!==e.length)throw new Error("bbox must be an Array of 4 or 6 numbers");e.forEach(e=>{if(!m(e))throw new Error("bbox must only contain numbers")})},t.validateId=function(e){if(!e)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof e))throw new Error("id must be a number or a string")}},861(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(391);function o(e,t,r){if(null!==e)for(var n,i,a,s,u,c,l,d,f=0,p=0,h=e.type,y="FeatureCollection"===h,m="Feature"===h,g=y?e.features.length:1,v=0;v<g;v++){u=(d=!!(l=y?e.features[v].geometry:m?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var S=0,w=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var x=s.type;switch(f=!r||"Polygon"!==x&&"MultiPolygon"!==x?0:1,x){case null:break;case"Point":if(!1===t(c,p,v,S,w))return!1;p++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],p,v,S,w))return!1;p++,"MultiPoint"===x&&S++}"LineString"===x&&S++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-f;i++){if(!1===t(c[n][i],p,v,S,w))return!1;p++}"MultiLineString"===x&&S++,"Polygon"===x&&w++}"Polygon"===x&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(w=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-f;a++){if(!1===t(c[n][i][a],p,v,S,w))return!1;p++}w++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,f=0,p="FeatureCollection"===e.type,h="Feature"===e.type,y=p?e.features.length:1;for(r=0;r<y;r++){for(s=p?e.features[r].geometry:h?e.geometry:e,c=p?e.features[r].properties:h?e.properties:{},l=p?e.features[r].bbox:h?e.bbox:void 0,d=p?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,f,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],f,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,f,c,l,d))return!1;f++}}function u(e,t){s(e,function(e,r,o,i,a){var s,u=null===e?null:e.type;switch(u){case null:case"Point":case"LineString":case"Polygon":return!1!==t(n.feature.call(void 0,e,o,{bbox:i,id:a}),r,0)&&void 0}switch(u){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}for(var c=0;c<e.coordinates.length;c++){var l={type:s,coordinates:e.coordinates[c]};if(!1===t(n.feature.call(void 0,l,o),r,c))return!1}})}function c(e,t){u(e,function(e,r,i){var a=0;if(e.geometry){var s=e.geometry.type;if("Point"!==s&&"MultiPoint"!==s){var u,c=0,l=0,d=0;return!1!==o(e,function(o,s,f,p,h){if(void 0===u||r>c||p>l||h>d)return u=o,c=r,l=p,d=h,void(a=0);var y=n.lineString.call(void 0,[u,o],e.properties);if(!1===t(y,r,i,h,a))return!1;a++,u=o})&&void 0}}})}function l(e,t){if(!e)throw new Error("geojson is required");u(e,function(e,r,o){if(null!==e.geometry){var i=e.geometry.type,a=e.geometry.coordinates;switch(i){case"LineString":if(!1===t(e,r,o,0,0))return!1;break;case"Polygon":for(var s=0;s<a.length;s++)if(!1===t(n.lineString.call(void 0,a[s],e.properties),r,o,s))return!1}}})}t.coordAll=function(e){var t=[];return o(e,function(e){t.push(e)}),t},t.coordEach=o,t.coordReduce=function(e,t,r,n){var i=r;return o(e,function(e,n,o,a,s){i=0===n&&void 0===r?e:t(i,e,n,o,a,s)},n),i},t.featureEach=a,t.featureReduce=function(e,t,r){var n=r;return a(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.findPoint=function(e,t){if(t=t||{},!n.isObject.call(void 0,t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.coordIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":return n.point.call(void 0,c,u,t);case"MultiPoint":return i<0&&(i=c.length+i),n.point.call(void 0,c[i],u,t);case"LineString":return s<0&&(s=c.length+s),n.point.call(void 0,c[s],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s),n.point.call(void 0,c[a][s],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s),n.point.call(void 0,c[i][s],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s),n.point.call(void 0,c[i][a][s],u,t)}throw new Error("geojson is invalid")},t.findSegment=function(e,t){if(t=t||{},!n.isObject.call(void 0,t))throw new Error("options is invalid");var r,o=t.featureIndex||0,i=t.multiFeatureIndex||0,a=t.geometryIndex||0,s=t.segmentIndex||0,u=t.properties;switch(e.type){case"FeatureCollection":o<0&&(o=e.features.length+o),u=u||e.features[o].properties,r=e.features[o].geometry;break;case"Feature":u=u||e.properties,r=e.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=e;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var c=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return s<0&&(s=c.length+s-1),n.lineString.call(void 0,[c[s],c[s+1]],u,t);case"Polygon":return a<0&&(a=c.length+a),s<0&&(s=c[a].length+s-1),n.lineString.call(void 0,[c[a][s],c[a][s+1]],u,t);case"MultiLineString":return i<0&&(i=c.length+i),s<0&&(s=c[i].length+s-1),n.lineString.call(void 0,[c[i][s],c[i][s+1]],u,t);case"MultiPolygon":return i<0&&(i=c.length+i),a<0&&(a=c[i].length+a),s<0&&(s=c[i][a].length-s-1),n.lineString.call(void 0,[c[i][a][s],c[i][a][s+1]],u,t)}throw new Error("geojson is invalid")},t.flattenEach=u,t.flattenReduce=function(e,t,r){var n=r;return u(e,function(e,o,i){n=0===o&&0===i&&void 0===r?e:t(n,e,o,i)}),n},t.geomEach=s,t.geomReduce=function(e,t,r){var n=r;return s(e,function(e,o,i,a,s){n=0===o&&void 0===r?e:t(n,e,o,i,a,s)}),n},t.lineEach=l,t.lineReduce=function(e,t,r){var n=r;return l(e,function(e,o,i,a){n=0===o&&void 0===r?e:t(n,e,o,i,a)}),n},t.propEach=i,t.propReduce=function(e,t,r){var n=r;return i(e,function(e,o){n=0===o&&void 0===r?e:t(n,e,o)}),n},t.segmentEach=c,t.segmentReduce=function(e,t,r){var n=r,o=!1;return c(e,function(e,i,a,s,u){n=!1===o&&void 0===r?e:t(n,e,i,a,s,u),o=!0}),n}},826(e,t,r){"use strict";r.r(t),r.d(t,{MaplibreDrawAdapter:()=>Da,displayedShape:()=>Va});var n={};r.r(n),r.d(n,{LAT_MAX:()=>b,LAT_MIN:()=>g,LAT_RENDERED_MAX:()=>S,LAT_RENDERED_MIN:()=>v,LNG_MAX:()=>x,LNG_MIN:()=>w,activeStates:()=>y,classes:()=>a,cursors:()=>u,events:()=>f,geojsonTypes:()=>l,interactions:()=>m,meta:()=>h,modes:()=>d,sources:()=>s,types:()=>c,updateActions:()=>p});var o={};r.r(o),r.d(o,{isActiveFeature:()=>E,isBackspaceKey:()=>k,isDeleteKey:()=>L,isDigit1Key:()=>F,isDigit2Key:()=>V,isDigit3Key:()=>D,isDigitKey:()=>N,isEnterKey:()=>j,isEscapeKey:()=>A,isFeature:()=>M,isInactiveFeature:()=>O,isOfMetaType:()=>P,isShiftDown:()=>T,isShiftMousedown:()=>_,isTrue:()=>R,isVertex:()=>C,noTarget:()=>I});var i={};r.r(i),r.d(i,{CommonSelectors:()=>o,ModeHandler:()=>ee,StringSet:()=>X,constrainFeatureMovement:()=>We,createMidPoint:()=>Ge,createSupplementaryPoints:()=>He,createVertex:()=>Ae,doubleClickZoom:()=>Ye,euclideanDistance:()=>W,featuresAt:()=>J,getFeatureAtAndSetCursors:()=>z,isClick:()=>Z,isEventAtCoordinates:()=>st,isTap:()=>Q,mapEventToBoundingBox:()=>Y,moveFeatures:()=>Ze,sortFeatures:()=>H,stringSetsAreEqual:()=>vt,theme:()=>Me,toDenseArray:()=>be});const a={CANVAS:"mapboxgl-canvas",CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},s={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},u={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},c={POLYGON:"polygon",LINE:"line_string",POINT:"point"},l={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},d={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},f={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},p={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},h={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},y={ACTIVE:"true",INACTIVE:"false"},m=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],g=-90,v=-85,b=90,S=85,w=-270,x=270;function P(e){return function(t){const r=t.featureTarget;return!!r&&!!r.properties&&r.properties.meta===e}}function _(e){return!!e.originalEvent&&!!e.originalEvent.shiftKey&&0===e.originalEvent.button}function E(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===y.ACTIVE&&e.featureTarget.properties.meta===h.FEATURE}function O(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===y.INACTIVE&&e.featureTarget.properties.meta===h.FEATURE}function I(e){return void 0===e.featureTarget}function M(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.meta===h.FEATURE}function C(e){const t=e.featureTarget;return!!t&&!!t.properties&&t.properties.meta===h.VERTEX}function T(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function A(e){return"Escape"===e.key||27===e.keyCode}function j(e){return"Enter"===e.key||13===e.keyCode}function k(e){return"Backspace"===e.key||8===e.keyCode}function L(e){return"Delete"===e.key||46===e.keyCode}function F(e){return"1"===e.key||49===e.keyCode}function V(e){return"2"===e.key||50===e.keyCode}function D(e){return"3"===e.key||51===e.keyCode}function N(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function R(){return!0}var U=r(778);const B={Point:0,LineString:1,MultiLineString:1,Polygon:2};function G(e,t){const r=B[e.geometry.type]-B[t.geometry.type];return 0===r&&e.geometry.type===l.POLYGON?e.area-t.area:r}const H=function(e){return e.map(e=>(e.geometry.type===l.POLYGON&&(e.area=U.geometry({type:l.FEATURE,property:{},geometry:e.geometry})),e)).sort(G).map(e=>(delete e.area,e))},Y=function(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function $(e){if(this._items={},this._nums={},this._length=e?e.length:0,e)for(let t=0,r=e.length;t<r;t++)this.add(e[t]),void 0!==e[t]&&("string"==typeof e[t]?this._items[e[t]]=t:this._nums[e[t]]=t)}$.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},$.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},$.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},$.prototype.values=function(){const e=[];return Object.keys(this._items).forEach(t=>{e.push({k:t,v:this._items[t]})}),Object.keys(this._nums).forEach(t=>{e.push({k:JSON.parse(t),v:this._nums[t]})}),e.sort((e,t)=>e.v-t.v).map(e=>e.k)},$.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const X=$,K=[h.FEATURE,h.MIDPOINT,h.VERTEX],J={click:function(e,t,r){return q(e,t,r,r.options.clickBuffer)},touch:function(e,t,r){return q(e,t,r,r.options.touchBuffer)}};function q(e,t,r,n){if(null===r.map)return[];const o=e?Y(e,n):t,i={};r.options.styles&&(i.layers=r.options.styles.map(e=>e.id).filter(e=>null!=r.map.getLayer(e)));const a=r.map.queryRenderedFeatures(o,i).filter(e=>-1!==K.indexOf(e.properties.meta)),s=new X,u=[];return a.forEach(e=>{const t=e.properties.id;s.has(t)||(s.add(t),u.push(e))}),H(u)}function z(e,t){const r=J.click(e,null,t),n={mouse:u.NONE};return r[0]&&(n.mouse=r[0].properties.active===y.ACTIVE?u.MOVE:u.POINTER,n.feature=r[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(n.mouse=u.ADD),t.ui.queueMapClasses(n),t.ui.updateMapClasses(),r[0]}function W(e,t){const r=e.x-t.x,n=e.y-t.y;return Math.sqrt(r*r+n*n)}function Z(e,t,r={}){const n=null!=r.fineTolerance?r.fineTolerance:4,o=null!=r.grossTolerance?r.grossTolerance:12,i=null!=r.interval?r.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;const a=W(e.point,t.point);return a<n||a<o&&t.time-e.time<i}function Q(e,t,r={}){const n=null!=r.tolerance?r.tolerance:25,o=null!=r.interval?r.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,W(e.point,t.point)<n&&t.time-e.time<o}const ee=function(e,t){const r={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},n={on(e,t,n){if(void 0===r[e])throw new Error(`Invalid event type: ${e}`);r[e].push({selector:t,fn:n})},render(e){t.store.featureChanged(e)}},o=function(e,o){const i=r[e];let a=i.length;for(;a--;){const e=i[a];if(e.selector(o)){e.fn.call(n,o)||t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(n),{render:e.render,stop(){e.stop&&e.stop()},trash(){e.trash&&(e.trash(),t.store.render())},combineFeatures(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures(){e.uncombineFeatures&&e.uncombineFeatures()},drag(e){o("drag",e)},click(e){o("click",e)},mousemove(e){o("mousemove",e)},mousedown(e){o("mousedown",e)},mouseup(e){o("mouseup",e)},mouseout(e){o("mouseout",e)},keydown(e){o("keydown",e)},keyup(e){o("keyup",e)},touchstart(e){o("touchstart",e)},touchmove(e){o("touchmove",e)},touchend(e){o("touchend",e)},tap(e){o("tap",e)}}},te=((e,t=21)=>(r=t)=>{let n="",o=0|r;for(;o--;)n+=e[Math.random()*e.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function re(){return te()}const ne=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||re(),this.type=t.geometry.type};ne.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},ne.prototype.incomingCoords=function(e){this.setCoordinates(e)},ne.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},ne.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},ne.prototype.setProperty=function(e,t){this.properties[e]=t},ne.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:l.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},ne.prototype.internal=function(e){const t={id:this.id,meta:h.FEATURE,"meta:type":this.type,active:y.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const e in this.properties)t[`user_${e}`]=this.properties[e];return{type:l.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const oe=ne,ie=function(e,t){oe.call(this,e,t)};(ie.prototype=Object.create(oe.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},ie.prototype.updateCoordinate=function(e,t,r){this.coordinates=3===arguments.length?[t,r]:[e,t],this.changed()},ie.prototype.getCoordinate=function(){return this.getCoordinates()};const ae=ie,se=function(e,t){oe.call(this,e,t)};(se.prototype=Object.create(oe.prototype)).isValid=function(){return this.coordinates.length>1},se.prototype.addCoordinate=function(e,t,r){this.changed();const n=parseInt(e,10);this.coordinates.splice(n,0,[t,r])},se.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},se.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},se.prototype.updateCoordinate=function(e,t,r){const n=parseInt(e,10);this.coordinates[n]=[t,r],this.changed()};const ue=se,ce=function(e,t){oe.call(this,e,t),this.coordinates=this.coordinates.map(e=>e.slice(0,-1))};(ce.prototype=Object.create(oe.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},ce.prototype.incomingCoords=function(e){this.coordinates=e.map(e=>e.slice(0,-1)),this.changed()},ce.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},ce.prototype.addCoordinate=function(e,t,r){this.changed();const n=e.split(".").map(e=>parseInt(e,10));this.coordinates[n[0]].splice(n[1],0,[t,r])},ce.prototype.removeCoordinate=function(e){this.changed();const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];r&&(r.splice(t[1],1),r.length<3&&this.coordinates.splice(t[0],1))},ce.prototype.getCoordinate=function(e){const t=e.split(".").map(e=>parseInt(e,10)),r=this.coordinates[t[0]];return JSON.parse(JSON.stringify(r[t[1]]))},ce.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},ce.prototype.updateCoordinate=function(e,t,r){this.changed();const n=e.split("."),o=parseInt(n[0],10),i=parseInt(n[1],10);void 0===this.coordinates[o]&&(this.coordinates[o]=[]),this.coordinates[o][i]=[t,r]};const le=ce,de={MultiPoint:ae,MultiLineString:ue,MultiPolygon:le},fe=(e,t,r,n,o)=>{const i=r.split("."),a=parseInt(i[0],10),s=i[1]?i.slice(1).join("."):null;return e[a][t](s,n,o)},pe=function(e,t){if(oe.call(this,e,t),delete this.coordinates,this.model=de[t.geometry.type],void 0===this.model)throw new TypeError(`${t.geometry.type} is not a valid type`);this.features=this._coordinatesToFeatures(t.geometry.coordinates)};(pe.prototype=Object.create(oe.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(e=>new t(this.ctx,{id:re(),type:l.FEATURE,properties:{},geometry:{coordinates:e,type:this.type.replace("Multi","")}}))},pe.prototype.isValid=function(){return this.features.every(e=>e.isValid())},pe.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},pe.prototype.getCoordinate=function(e){return fe(this.features,"getCoordinate",e)},pe.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===l.POLYGON?e.getCoordinates():e.coordinates)))},pe.prototype.updateCoordinate=function(e,t,r){fe(this.features,"updateCoordinate",e,t,r),this.changed()},pe.prototype.addCoordinate=function(e,t,r){fe(this.features,"addCoordinate",e,t,r),this.changed()},pe.prototype.removeCoordinate=function(e){fe(this.features,"removeCoordinate",e),this.changed()},pe.prototype.getFeatures=function(){return this.features};const he=pe;function ye(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}ye.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},ye.prototype.setSelectedCoordinates=function(e){this._ctx.store.setSelectedCoordinates(e),e.reduce((e,t)=>(void 0===e[t.feature_id]&&(e[t.feature_id]=!0,this._ctx.store.get(t.feature_id).changed()),e),{})},ye.prototype.getSelected=function(){return this._ctx.store.getSelected()},ye.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},ye.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},ye.prototype.getFeature=function(e){return this._ctx.store.get(e)},ye.prototype.select=function(e){return this._ctx.store.select(e)},ye.prototype.deselect=function(e){return this._ctx.store.deselect(e)},ye.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},ye.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},ye.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},ye.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},ye.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)},ye.prototype.changeMode=function(e,t={},r={}){return this._ctx.events.changeMode(e,t,r)},ye.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},ye.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},ye.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},ye.prototype.featuresAt=function(e,t,r="click"){if("click"!==r&&"touch"!==r)throw new Error("invalid buffer type");return J[r](e,t,this._ctx)},ye.prototype.newFeature=function(e){const t=e.geometry.type;return t===l.POINT?new ae(this._ctx,e):t===l.LINE_STRING?new ue(this._ctx,e):t===l.POLYGON?new le(this._ctx,e):new he(this._ctx,e)},ye.prototype.isInstanceOf=function(e,t){if(e===l.POINT)return t instanceof ae;if(e===l.LINE_STRING)return t instanceof ue;if(e===l.POLYGON)return t instanceof le;if("MultiFeature"===e)return t instanceof he;throw new Error(`Unknown feature class: ${e}`)},ye.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const me=ye;ye.prototype.onSetup=function(){},ye.prototype.onDrag=function(){},ye.prototype.onClick=function(){},ye.prototype.onMouseMove=function(){},ye.prototype.onMouseDown=function(){},ye.prototype.onMouseUp=function(){},ye.prototype.onMouseOut=function(){},ye.prototype.onKeyUp=function(){},ye.prototype.onKeyDown=function(){},ye.prototype.onTouchStart=function(){},ye.prototype.onTouchMove=function(){},ye.prototype.onTouchEnd=function(){},ye.prototype.onTap=function(){},ye.prototype.onStop=function(){},ye.prototype.onTrash=function(){},ye.prototype.onCombineFeature=function(){},ye.prototype.onUncombineFeature=function(){},ye.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const ge={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},ve=Object.keys(ge);const be=function(e){return[].concat(e).filter(e=>void 0!==e)};function Se(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(s.HOT))return u();const t=e.ctx.events.currentModeName();e.ctx.ui.queueMapClasses({mode:t});let r=[],n=[];e.isDirty?n=e.getAllIds():(r=e.getChangedIds().filter(t=>void 0!==e.get(t)),n=e.sources.hot.filter(t=>t.properties.id&&-1===r.indexOf(t.properties.id)&&void 0!==e.get(t.properties.id)).map(e=>e.properties.id)),e.sources.hot=[];const o=e.sources.cold.length;e.sources.cold=e.isDirty?[]:e.sources.cold.filter(e=>{const t=e.properties.id||e.properties.parent;return-1===r.indexOf(t)});const i=o!==e.sources.cold.length||n.length>0;function a(r,n){const o=e.get(r).internal(t);e.ctx.events.currentModeRender(o,r=>{r.properties.mode=t,e.sources[n].push(r)})}function u(){e.isDirty=!1,e.clearChangedIds()}r.forEach(e=>a(e,"hot")),n.forEach(e=>a(e,"cold")),i&&e.ctx.map.getSource(s.COLD).setData({type:l.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(s.HOT).setData({type:l.FEATURE_COLLECTION,features:e.sources.hot}),u()}function we(e){let t;this._features={},this._featureIds=new X,this._selectedFeatureIds=new X,this._selectedCoordinates=[],this._changedFeatureIds=new X,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,Se.call(this),this._emitSelectionChange&&(this.ctx.events.fire(f.SELECTION_CHANGE,{features:this.getSelected().map(e=>e.toGeoJSON()),points:this.getSelectedCoordinates().map(e=>({type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:e.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(f.RENDER,{})}))},this.isDirty=!1}function xe(e,t={}){const r=e._selectedCoordinates.filter(t=>e._selectedFeatureIds.has(t.feature_id));e._selectedCoordinates.length===r.length||t.silent||(e._emitSelectionChange=!0),e._selectedCoordinates=r}we.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},we.prototype.setDirty=function(){return this.isDirty=!0,this},we.prototype.featureCreated=function(e,t={}){if(this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)){const t=this.get(e);this.ctx.events.fire(f.CREATE,{features:[t.toGeoJSON()]})}return this},we.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(f.UPDATE,{action:t.action?t.action:p.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},we.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},we.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},we.prototype.getAllIds=function(){return this._featureIds.values()},we.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},we.prototype.delete=function(e,t={}){const r=[];return be(e).forEach(e=>{this._featureIds.has(e)&&(this._featureIds.delete(e),this._selectedFeatureIds.delete(e),t.silent||-1===r.indexOf(this._features[e])&&r.push(this._features[e].toGeoJSON()),delete this._features[e],this.isDirty=!0)}),r.length&&this.ctx.events.fire(f.DELETE,{features:r}),xe(this,t),this},we.prototype.get=function(e){return this._features[e]},we.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},we.prototype.select=function(e,t={}){return be(e).forEach(e=>{this._selectedFeatureIds.has(e)||(this._selectedFeatureIds.add(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),this},we.prototype.deselect=function(e,t={}){return be(e).forEach(e=>{this._selectedFeatureIds.has(e)&&(this._selectedFeatureIds.delete(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),xe(this,t),this},we.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},we.prototype.setSelected=function(e,t={}){return e=be(e),this.deselect(this._selectedFeatureIds.values().filter(t=>-1===e.indexOf(t)),{silent:t.silent}),this.select(e.filter(e=>!this._selectedFeatureIds.has(e)),{silent:t.silent}),this},we.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},we.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},we.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},we.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},we.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)}))},we.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},we.prototype.setFeatureProperty=function(e,t,r,n={}){this.get(e).setProperty(t,r),this.featureChanged(e,{silent:n.silent,action:p.CHANGE_PROPERTIES})},we.prototype.storeMapConfig=function(){m.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},we.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},we.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const Pe=["mode","feature","mouse"];function _e(e){let t=null,r=null;const n={onRemove(){return e.map.off("load",n.connect),clearInterval(r),n.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.boxZoomInitial&&e.map.boxZoom.enable(),e.map=null,e.container=null,e.store=null,t&&t.parentNode&&t.parentNode.removeChild(t),t=null,this},connect(){e.map.off("load",n.connect),clearInterval(r),n.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd(o){if(e.map=o,e.events=function(e){const t=Object.keys(e.options.modes).reduce((t,r)=>(t[r]=function(e){const t=Object.keys(e);return function(r,n={}){let o={};const i=t.reduce((t,r)=>(t[r]=e[r],t),new me(r));return{start(){o=i.onSetup(n),ve.forEach(t=>{const r=ge[t];let n=()=>!1;var a;e[r]&&(n=()=>!0),this.on(t,n,(a=r,e=>i[a](o,e)))})},stop(){i.onStop(o)},trash(){i.onTrash(o)},combineFeatures(){i.onCombineFeatures(o)},uncombineFeatures(){i.onUncombineFeatures(o)},render(e,t){i.toDisplayFeatures(o,e,t)}}}}(e.options.modes[r]),t),{});let r={},n={};const o={};let i=null,s=null;o.drag=function(t,r){r({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:u.DRAG}),s.drag(t)):t.originalEvent.stopPropagation()},o.mousedrag=function(e){o.drag(e,e=>!Z(r,e))},o.touchdrag=function(e){o.drag(e,e=>!Q(n,e))},o.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return o.mousedrag(t);const r=z(t,e);t.featureTarget=r,s.mousemove(t)},o.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};const n=z(t,e);t.featureTarget=n,s.mousedown(t)},o.mouseup=function(t){const n=z(t,e);t.featureTarget=n,Z(r,{point:t.point,time:(new Date).getTime()})?s.click(t):s.mouseup(t)},o.mouseout=function(e){s.mouseout(e)},o.touchstart=function(t){if(!e.options.touchEnabled)return;n={time:(new Date).getTime(),point:t.point};const r=J.touch(t,null,e)[0];t.featureTarget=r,s.touchstart(t)},o.touchmove=function(t){if(e.options.touchEnabled)return s.touchmove(t),o.touchdrag(t)},o.touchend=function(t){if(t.originalEvent.preventDefault(),!e.options.touchEnabled)return;const r=J.touch(t,null,e)[0];t.featureTarget=r,Q(n,{time:(new Date).getTime(),point:t.point})?s.tap(t):s.touchend(t)};const c=e=>{const t=k(e),r=L(e),n=N(e);return!(t||r||n)};function l(r,n,o={}){s.stop();const a=t[r];if(void 0===a)throw new Error(`${r} is not valid`);i=r;const u=a(e,n);s=ee(u,e),o.silent||e.map.fire(f.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains(a.CANVAS)&&((k(t)||L(t))&&e.options.controls.trash?(t.preventDefault(),s.trash()):c(t)?s.keydown(t):F(t)&&e.options.controls.point?l(d.DRAW_POINT):V(t)&&e.options.controls.line_string?l(d.DRAW_LINE_STRING):D(t)&&e.options.controls.polygon&&l(d.DRAW_POLYGON))},o.keyup=function(e){c(e)&&s.keyup(e)},o.zoomend=function(){e.store.changeZoom()},o.data=function(t){if("style"===t.dataType){const{setup:t,map:r,options:n,store:o}=e;n.styles.some(e=>r.getLayer(e.id))||(t.addLayers(),o.setDirty(),o.render())}};const p={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start(){i=e.options.defaultMode,s=ee(t[i](e),e)},changeMode:l,actionable:function(t){let r=!1;Object.keys(t).forEach(e=>{if(void 0===p[e])throw new Error("Invalid action type");p[e]!==t[e]&&(r=!0),p[e]=t[e]}),r&&e.map.fire(f.ACTIONABLE,{actions:p})},currentModeName:()=>i,currentModeRender:(e,t)=>s.render(e,t),fire(t,r){e.map&&e.map.fire(t,r)},addEventListeners(){e.map.on("mousemove",o.mousemove),e.map.on("mousedown",o.mousedown),e.map.on("mouseup",o.mouseup),e.map.on("data",o.data),e.map.on("touchmove",o.touchmove),e.map.on("touchstart",o.touchstart),e.map.on("touchend",o.touchend),e.container.addEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",o.keydown),e.container.addEventListener("keyup",o.keyup))},removeEventListeners(){e.map.off("mousemove",o.mousemove),e.map.off("mousedown",o.mousedown),e.map.off("mouseup",o.mouseup),e.map.off("data",o.data),e.map.off("touchmove",o.touchmove),e.map.off("touchstart",o.touchstart),e.map.off("touchend",o.touchend),e.container.removeEventListener("mouseout",o.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",o.keydown),e.container.removeEventListener("keyup",o.keyup))},trash(e){s.trash(e)},combineFeatures(){s.combineFeatures()},uncombineFeatures(){s.uncombineFeatures()},getMode:()=>i}}(e),e.ui=function(e){const t={};let r=null,n={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function i(e){o=Object.assign(o,e)}function s(){if(!e.container)return;const t=[],r=[];Pe.forEach(e=>{o[e]!==n[e]&&(t.push(`${e}-${n[e]}`),null!==o[e]&&r.push(`${e}-${o[e]}`))}),t.length>0&&e.container.classList.remove(...t),r.length>0&&e.container.classList.add(...r),n=Object.assign(n,o)}function u(e,t={}){const n=document.createElement("button");return n.className=`${a.CONTROL_BUTTON} ${t.className}`,n.setAttribute("title",t.title),t.container.appendChild(n),n.addEventListener("click",n=>{if(n.preventDefault(),n.stopPropagation(),n.target===r)return l(),void t.onDeactivate();f(e),t.onActivate()},!0),n}function l(){r&&(r.classList.remove(a.ACTIVE_BUTTON),r=null)}function f(e){l();const n=t[e];n&&n&&"trash"!==e&&(n.classList.add(a.ACTIVE_BUTTON),r=n)}return{setActiveButton:f,queueMapClasses:i,updateMapClasses:s,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),s()},addButtons:function(){const r=e.options.controls,n=document.createElement("div");return n.className=`${a.CONTROL_GROUP} ${a.CONTROL_BASE}`,r?(r[c.POINT]&&(t[c.POINT]=u(c.POINT,{container:n,className:a.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(d.DRAW_POINT),onDeactivate:()=>e.events.trash()})),r[c.LINE]&&(t[c.LINE]=u(c.LINE,{container:n,className:a.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(d.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),r[c.POLYGON]&&(t[c.POLYGON]=u(c.POLYGON,{container:n,className:a.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(d.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),r.trash&&(t.trash=u("trash",{container:n,className:a.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),r.combine_features&&(t.combine_features=u("combineFeatures",{container:n,className:a.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),r.uncombine_features&&(t.uncombine_features=u("uncombineFeatures",{container:n,className:a.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:()=>{e.events.uncombineFeatures()}})),n):n},removeButtons:function(){Object.keys(t).forEach(e=>{const r=t[e];r.parentNode&&r.parentNode.removeChild(r),delete t[e]})}}}(e),e.container=o.getContainer(),e.store=new we(e),t=e.ui.addButtons(),e.options.boxSelect){e.boxZoomInitial=o.boxZoom.isEnabled(),o.boxZoom.disable();const t=o.dragPan.isEnabled();o.dragPan.disable(),o.dragPan.enable(),t||o.dragPan.disable()}return o.loaded()?n.connect():(o.on("load",n.connect),r=setInterval(()=>{o.loaded()&&n.connect()},16)),e.events.start(),t},addLayers(){e.map.addSource(s.COLD,{data:{type:l.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(s.HOT,{data:{type:l.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach(t=>{e.map.addLayer(t)}),e.store.setDirty(!0),e.store.render()},removeLayers(){e.options.styles.forEach(t=>{e.map.getLayer(t.id)&&e.map.removeLayer(t.id)}),e.map.getSource(s.COLD)&&e.map.removeSource(s.COLD),e.map.getSource(s.HOT)&&e.map.removeSource(s.HOT)}};return e.setup=n,n}const Ee="#3bb2d0",Oe="#fbb03b",Ie="#fff",Me=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],Oe,Ee],"fill-opacity":.1}},{id:"gl-draw-lines",type:"line",filter:["any",["==","$type","LineString"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["==",["get","active"],"true"],Oe,Ee],"line-dasharray":["case",["==",["get","active"],"true"],[.2,2],[2,0]],"line-width":2}},{id:"gl-draw-point-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Ie}},{id:"gl-draw-point-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","feature"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":["case",["==",["get","active"],"true"],Oe,Ee]}},{id:"gl-draw-vertex-outer",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],7,5],"circle-color":Ie}},{id:"gl-draw-vertex-inner",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["!=","mode","simple_select"]],paint:{"circle-radius":["case",["==",["get","active"],"true"],5,3],"circle-color":Oe}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":Oe}}];function Ce(e,t){this.x=e,this.y=t}Ce.prototype={clone(){return new Ce(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[0]*this.x+e[1]*this.y,r=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=r,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),r=Math.sin(e),n=t*this.x-r*this.y,o=r*this.x+t*this.y;return this.x=n,this.y=o,this},_rotateAround(e,t){const r=Math.cos(e),n=Math.sin(e),o=t.x+r*(this.x-t.x)-n*(this.y-t.y),i=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=o,this.y=i,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Ce},Ce.convert=function(e){if(e instanceof Ce)return e;if(Array.isArray(e))return new Ce(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new Ce(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Te=function(e,t){const r=t.getBoundingClientRect();return new Ce(e.clientX-r.left-(t.clientLeft||0),e.clientY-r.top-(t.clientTop||0))};function Ae(e,t,r,n){return{type:l.FEATURE,properties:{meta:h.VERTEX,parent:e,coord_path:r,active:n?y.ACTIVE:y.INACTIVE},geometry:{type:l.POINT,coordinates:t}}}var je=r(850),ke=r(278);function Le(e){const t={type:"Feature"};return Object.keys(e).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:t[r]=e[r]}}),t.properties=Fe(e.properties),null==e.geometry?t.geometry=null:t.geometry=Ve(e.geometry),t}function Fe(e){const t={};return e?(Object.keys(e).forEach(r=>{const n=e[r];"object"==typeof n?null===n?t[r]=null:Array.isArray(n)?t[r]=n.map(e=>e):t[r]=Fe(n):t[r]=n}),t):t}function Ve(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(e=>Ve(e)),t):(t.coordinates=De(e.coordinates),t)}function De(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(e=>De(e))}function Ne(e,t={}){return Re(e,"mercator",t)}function Re(e,t,r={}){var n=(r=r||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&(0,ke.Et)(e[0])?e="mercator"===t?Ue(e):Be(e):(!0!==n&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Le(e);case"FeatureCollection":return function(e){const t={type:"FeatureCollection"};return Object.keys(e).forEach(r=>{switch(r){case"type":case"features":return;default:t[r]=e[r]}}),t.features=e.features.map(e=>Le(e)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Ve(e);default:throw new Error("unknown GeoJSON type")}}(e)),(0,je.Fh)(e,function(e){var r="mercator"===t?Ue(e):Be(e);e[0]=r[0],e[1]=r[1]})),e}function Ue(e){var t,r=Math.PI/180,n=6378137,o=20037508.342789244,i=[n*(Math.abs(e[0])<=180?e[0]:e[0]-360*((t=e[0])<0?-1:t>0?1:0))*r,n*Math.log(Math.tan(.25*Math.PI+.5*e[1]*r))];return i[0]>o&&(i[0]=o),i[0]<-o&&(i[0]=-o),i[1]>o&&(i[1]=o),i[1]<-o&&(i[1]=-o),i}function Be(e){var t=180/Math.PI,r=6378137;return[e[0]*t/r,(.5*Math.PI-2*Math.atan(Math.exp(-e[1]/r)))*t]}function Ge(e,t,r){const n=t.geometry.coordinates,o=r.geometry.coordinates;if(n[1]>S||n[1]<v||o[1]>S||o[1]<v)return null;const i=Ne(n),a=Ne(o),s=e=>Number(e.toFixed(8)),u=(e,t)=>(e+t)/2,c=function(e,t={}){return Re(e,"wgs84",t)}([u(i[0],a[0]),u(i[1],a[1])]),d=[s(c[0]),s(c[1])];return{type:l.FEATURE,properties:{meta:h.MIDPOINT,parent:e,lng:d[0],lat:d[1],coord_path:r.properties.coord_path},geometry:{type:l.POINT,coordinates:d}}}const He=function e(t,r={},n=null){const{type:o,coordinates:i}=t.geometry,a=t.properties&&t.properties.id;let s=[];function u(e,t){let n="",o=null;e.forEach((e,i)=>{const u=null!=t?`${t}.${i}`:String(i),l=Ae(a,e,u,c(u));if(r.midpoints&&o){const e=Ge(a,o,l);e&&s.push(e)}o=l;const d=JSON.stringify(e);n!==d&&s.push(l),0===i&&(n=d)})}function c(e){return!!r.selectedPaths&&-1!==r.selectedPaths.indexOf(e)}return o===l.POINT?s.push(Ae(a,i,n,c(n))):o===l.POLYGON?i.forEach((e,t)=>{u(e,null!==n?`${n}.${t}`:String(t))}):o===l.LINE_STRING?u(i,n):0===o.indexOf(l.MULTI_PREFIX)&&function(){const n=o.replace(l.MULTI_PREFIX,"");i.forEach((o,i)=>{const a={type:l.FEATURE,properties:t.properties,geometry:{type:n,coordinates:o}};s=s.concat(e(a,r,i))})}(),s},Ye={enable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e._ctx&&e._ctx.store&&e._ctx.store.getInitialConfigValue&&e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable()},0)},disable(e){setTimeout(()=>{e.map&&e.map.doubleClickZoom&&e.map.doubleClickZoom.disable()},0)}},{LAT_MIN:$e,LAT_MAX:Xe,LAT_RENDERED_MIN:Ke,LAT_RENDERED_MAX:Je,LNG_MIN:qe,LNG_MAX:ze}=n;function We(e,t){let r=$e,n=Xe,o=$e,i=Xe,a=ze,s=qe;e.forEach(e=>{const t=function(e){const t={Point:0,LineString:1,Polygon:2,MultiPoint:1,MultiLineString:2,MultiPolygon:3}[e.geometry.type],r=[e.geometry.coordinates].flat(t),n=r.map(e=>e[0]),o=r.map(e=>e[1]),i=e=>Math.min.apply(null,e),a=e=>Math.max.apply(null,e);return[i(n),i(o),a(n),a(o)]}(e),u=t[1],c=t[3],l=t[0],d=t[2];u>r&&(r=u),c<n&&(n=c),c>o&&(o=c),u<i&&(i=u),l<a&&(a=l),d>s&&(s=d)});const u=t;return r+u.lat>Je&&(u.lat=Je-r),o+u.lat>Xe&&(u.lat=Xe-o),n+u.lat<Ke&&(u.lat=Ke-n),i+u.lat<$e&&(u.lat=$e-i),a+u.lng<=qe&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=ze&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function Ze(e,t){const r=We(e.map(e=>e.toGeoJSON()),t);e.forEach(e=>{const t=e.getCoordinates(),n=e=>{const t={lng:e[0]+r.lng,lat:e[1]+r.lat};return[t.lng,t.lat]},o=e=>e.map(e=>n(e));let i;e.type===l.POINT?i=n(t):e.type===l.LINE_STRING||e.type===l.MULTI_POINT?i=t.map(n):e.type===l.POLYGON||e.type===l.MULTI_LINE_STRING?i=t.map(o):e.type===l.MULTI_POLYGON&&(i=t.map(e=>e.map(e=>o(e)))),e.incomingCoords(i)})}const Qe={onSetup:function(e){const t={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initialDragPanState:this.map.dragPan.isEnabled(),initiallySelectedFeatureIds:e.featureIds||[]};return this.setSelected(t.initiallySelectedFeatureIds.filter(e=>void 0!==this.getFeature(e))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),t},fireUpdate:function(){this.fire(f.UPDATE,{action:p.MOVE,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(){const e=this.getSelected(),t=e.filter(e=>this.isInstanceOf("MultiFeature",e));let r=!1;if(e.length>1){r=!0;const t=e[0].type.replace("Multi","");e.forEach(e=>{e.type.replace("Multi","")!==t&&(r=!1)})}const n=t.length>0,o=e.length>0;this.setActionableState({combineFeatures:r,uncombineFeatures:n,trash:o})},getUniqueIds:function(e){return e.length?e.map(e=>e.properties.id).filter(e=>void 0!==e).reduce((e,t)=>(e.add(t),e),new X).values():[]},stopExtendedInteractions:function(e){e.boxSelectElement&&(e.boxSelectElement.parentNode&&e.boxSelectElement.parentNode.removeChild(e.boxSelectElement),e.boxSelectElement=null),(e.canDragMove||e.canBoxSelect)&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.boxSelecting=!1,e.canBoxSelect=!1,e.dragMoving=!1,e.canDragMove=!1},onStop:function(){Ye.enable(this)},onMouseMove:function(e,t){return M(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};Qe.onTap=Qe.onClick=function(e,t){return I(t)?this.clickAnywhere(e,t):P(h.VERTEX)(t)?this.clickOnVertex(e,t):M(t)?this.clickOnFeature(e,t):void 0},Qe.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(e=>this.doRender(e))),Ye.enable(this),this.stopExtendedInteractions(e)},Qe.clickOnVertex=function(e,t){this.changeMode(d.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:u.MOVE})},Qe.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},Qe.clickOnFeature=function(e,t){Ye.disable(this),this.stopExtendedInteractions(e);const r=T(t),n=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!r&&i&&this.getFeature(o).type!==l.POINT)return this.changeMode(d.DIRECT_SELECT,{featureId:o});i&&r?(this.deselect(o),this.updateUIClasses({mouse:u.POINTER}),1===n.length&&Ye.enable(this)):!i&&r?(this.select(o),this.updateUIClasses({mouse:u.MOVE})):i||r||(n.forEach(e=>this.doRender(e)),this.setSelected(o),this.updateUIClasses({mouse:u.MOVE})),this.doRender(o)},Qe.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),E(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&_(t)?this.startBoxSelect(e,t):void 0},Qe.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Te(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},Qe.onTouchStart=function(e,t){if(E(t))return this.startOnActiveFeature(e,t)},Qe.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},Qe.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:u.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(a.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const r=Te(t.originalEvent,this.map.getContainer()),n=Math.min(e.boxSelectStartLocation.x,r.x),o=Math.max(e.boxSelectStartLocation.x,r.x),i=Math.min(e.boxSelectStartLocation.y,r.y),s=Math.max(e.boxSelectStartLocation.y,r.y),c=`translate(${n}px, ${i}px)`;e.boxSelectElement.style.transform=c,e.boxSelectElement.style.WebkitTransform=c,e.boxSelectElement.style.width=o-n+"px",e.boxSelectElement.style.height=s-i+"px"},Qe.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};Ze(this.getSelected(),r),e.dragMoveLocation=t.lngLat},Qe.onTouchEnd=Qe.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const r=[e.boxSelectStartLocation,Te(t.originalEvent,this.map.getContainer())],n=this.featuresAt(null,r,"click"),o=this.getUniqueIds(n).filter(e=>!this.isSelected(e));o.length&&(this.select(o),o.forEach(e=>this.doRender(e)),this.updateUIClasses({mouse:u.MOVE}))}this.stopExtendedInteractions(e)},Qe.toDisplayFeatures=function(e,t,r){t.properties.active=this.isSelected(t.properties.id)?y.ACTIVE:y.INACTIVE,r(t),this.fireActionable(),t.properties.active===y.ACTIVE&&t.geometry.type!==l.POINT&&He(t).forEach(r)},Qe.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Qe.onCombineFeatures=function(){const e=this.getSelected();if(0===e.length||e.length<2)return;const t=[],r=[],n=e[0].type.replace("Multi","");for(let o=0;o<e.length;o++){const i=e[o];if(i.type.replace("Multi","")!==n)return;i.type.includes("Multi")?i.getCoordinates().forEach(e=>{t.push(e)}):t.push(i.getCoordinates()),r.push(i.toGeoJSON())}if(r.length>1){const e=this.newFeature({type:l.FEATURE,properties:r[0].properties,geometry:{type:`Multi${n}`,coordinates:t}});this.addFeature(e),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([e.id]),this.fire(f.COMBINE_FEATURES,{createdFeatures:[e.toGeoJSON()],deletedFeatures:r})}this.fireActionable()},Qe.onUncombineFeatures=function(){const e=this.getSelected();if(0===e.length)return;const t=[],r=[];for(let n=0;n<e.length;n++){const o=e[n];this.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach(e=>{this.addFeature(e),e.properties=o.properties,t.push(e.toGeoJSON()),this.select([e.id])}),this.deleteFeature(o.id,{silent:!0}),r.push(o.toGeoJSON()))}t.length>1&&this.fire(f.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:r}),this.fireActionable()};const et=Qe,tt=P(h.VERTEX),rt=P(h.MIDPOINT),nt={fireUpdate:function(){this.fire(f.UPDATE,{action:p.CHANGE_COORDINATES,features:this.getSelected().map(e=>e.toGeoJSON())})},fireActionable:function(e){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:e.selectedCoordPaths.length>0})},startDragging:function(e,t){null==e.initialDragPanState&&(e.initialDragPanState=this.map.dragPan.isEnabled()),this.map.dragPan.disable(),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},stopDragging:function(e){e.canDragMove&&!0===e.initialDragPanState&&this.map.dragPan.enable(),e.initialDragPanState=null,e.dragMoving=!1,e.canDragMove=!1,e.dragMoveLocation=null},onVertex:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties,n=e.selectedCoordPaths.indexOf(r.coord_path);T(t)||-1!==n?T(t)&&-1===n&&e.selectedCoordPaths.push(r.coord_path):e.selectedCoordPaths=[r.coord_path];const o=this.pathsToCoordinates(e.featureId,e.selectedCoordPaths);this.setSelectedCoordinates(o)},onMidpoint:function(e,t){this.startDragging(e,t);const r=t.featureTarget.properties;e.feature.addCoordinate(r.coord_path,r.lng,r.lat),this.fireUpdate(),e.selectedCoordPaths=[r.coord_path]},pathsToCoordinates:function(e,t){return t.map(t=>({feature_id:e,coord_path:t}))},onFeature:function(e,t){0===e.selectedCoordPaths.length?this.startDragging(e,t):this.stopDragging(e)},dragFeature:function(e,t,r){Ze(this.getSelected(),r),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,r){const n=e.selectedCoordPaths.map(t=>e.feature.getCoordinate(t)),o=We(n.map(e=>({type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:e}})),r);for(let t=0;t<n.length;t++){const r=n[t];e.feature.updateCoordinate(e.selectedCoordPaths[t],r[0]+o.lng,r[1]+o.lat)}},clickNoTarget:function(){this.changeMode(d.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(d.SIMPLE_SELECT)},clickActiveFeature:function(e){e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed()},onSetup:function(e){const t=e.featureId,r=this.getFeature(t);if(!r)throw new Error("You must provide a featureId to enter direct_select mode");if(r.type===l.POINT)throw new TypeError("direct_select mode doesn't handle point features");const n={featureId:t,feature:r,dragMoveLocation:e.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:e.coordPath?[e.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(t,n.selectedCoordPaths)),this.setSelected(t),Ye.disable(this),this.setActionableState({trash:!0}),n},onStop:function(){Ye.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,r){e.featureId===t.properties.id?(t.properties.active=y.ACTIVE,r(t),He(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(r)):(t.properties.active=y.INACTIVE,r(t)),this.fireActionable(e)},onTrash:function(e){e.selectedCoordPaths.sort((e,t)=>t.localeCompare(e,"en",{numeric:!0})).forEach(t=>e.feature.removeCoordinate(t)),this.fireUpdate(),e.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(e),!1===e.feature.isValid()&&(this.deleteFeature([e.featureId]),this.changeMode(d.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const r=E(t),n=tt(t),o=rt(t),i=0===e.selectedCoordPaths.length;return r&&i||n&&!i?this.updateUIClasses({mouse:u.MOVE}):this.updateUIClasses({mouse:u.NONE}),(n||r||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};nt.onTouchStart=nt.onMouseDown=function(e,t){return tt(t)?this.onVertex(e,t):E(t)?this.onFeature(e,t):rt(t)?this.onMidpoint(e,t):void 0},nt.onDrag=function(e,t){if(!0!==e.canDragMove)return;e.dragMoving=!0,t.originalEvent.stopPropagation();const r={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};e.selectedCoordPaths.length>0?this.dragVertex(e,t,r):this.dragFeature(e,t,r),e.dragMoveLocation=t.lngLat},nt.onClick=function(e,t){return I(t)?this.clickNoTarget(e,t):E(t)?this.clickActiveFeature(e,t):O(t)?this.clickInactive(e,t):void this.stopDragging(e)},nt.onTap=function(e,t){return I(t)?this.clickNoTarget(e,t):E(t)?this.clickActiveFeature(e,t):O(t)?this.clickInactive(e,t):void 0},nt.onTouchEnd=nt.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const ot=nt,it={onSetup:function(){const e=this.newFeature({type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:u.ADD}),this.activateUIButton(c.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)}};it.onTap=it.onClick=function(e,t){this.updateUIClasses({mouse:u.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(f.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.point.id]})},it.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},it.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.point.id;if(t.properties.active=n?y.ACTIVE:y.INACTIVE,!n)return r(t)},it.onTrash=it.stopDrawingAndRemove,it.onKeyUp=function(e,t){if(A(t)||j(t))return this.stopDrawingAndRemove(e,t)};const at=it,st=function(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},ut={onSetup:function(){const e=this.newFeature({type:l.FEATURE,properties:{},geometry:{type:l.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),Ye.disable(this),this.updateUIClasses({mouse:u.ADD}),this.activateUIButton(c.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&st(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:u.ADD}),e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),C(t)&&this.updateUIClasses({mouse:u.POINTER})}};ut.onTap=ut.onClick=function(e,t){return C(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},ut.onKeyUp=function(e,t){A(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)):j(t)&&this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},ut.onStop=function(e){this.updateUIClasses({mouse:u.NONE}),Ye.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(f.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT,{},{silent:!0})))},ut.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.polygon.id;if(t.properties.active=n?y.ACTIVE:y.INACTIVE,!n)return r(t);if(0===t.geometry.coordinates.length)return;const o=t.geometry.coordinates[0].length;if(!(o<3)){if(t.properties.meta=h.FEATURE,r(Ae(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const n=t.geometry.coordinates[0].length-3;r(Ae(e.polygon.id,t.geometry.coordinates[0][n],`0.${n}`,!1))}if(o<=4){const e=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(r({type:l.FEATURE,properties:t.properties,geometry:{coordinates:e,type:l.LINE_STRING}}),3===o)return}return r(t)}},ut.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)};const ct=ut,lt={onSetup:function(e){const t=(e=e||{}).featureId;let r,n,o="forward";if(t){if(r=this.getFeature(t),!r)throw new Error("Could not find a feature with the provided featureId");let i=e.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");const a=r.coordinates.length-1;if(r.coordinates[a][0]===i[0]&&r.coordinates[a][1]===i[1])n=a+1,r.addCoordinate(n,...r.coordinates[a]);else{if(r.coordinates[0][0]!==i[0]||r.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");o="backwards",n=0,r.addCoordinate(n,...r.coordinates[0])}}else r=this.newFeature({type:l.FEATURE,properties:{},geometry:{type:l.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(r);return this.clearSelectedFeatures(),Ye.disable(this),this.updateUIClasses({mouse:u.ADD}),this.activateUIButton(c.LINE),this.setActionableState({trash:!0}),{line:r,currentVertexPosition:n,direction:o}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&st(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&st(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:u.ADD}),e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),"forward"===e.direction?(e.currentVertexPosition++,e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat)):e.line.addCoordinate(0,t.lngLat.lng,t.lngLat.lat)},clickOnVertex:function(e){return this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),C(t)&&this.updateUIClasses({mouse:u.POINTER})}};lt.onTap=lt.onClick=function(e,t){if(C(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},lt.onKeyUp=function(e,t){j(t)?this.changeMode(d.SIMPLE_SELECT,{featureIds:[e.line.id]}):A(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT))},lt.onStop=function(e){Ye.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(f.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT,{},{silent:!0})))},lt.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(d.SIMPLE_SELECT)},lt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.line.id;if(t.properties.active=n?y.ACTIVE:y.INACTIVE,!n)return r(t);t.geometry.coordinates.length<2||(t.properties.meta=h.FEATURE,r(Ae(e.line.id,t.geometry.coordinates["forward"===e.direction?t.geometry.coordinates.length-2:1],""+("forward"===e.direction?t.geometry.coordinates.length-2:1),!1)),r(t))};const dt={simple_select:et,direct_select:ot,draw_point:at,draw_polygon:ct,draw_line_string:lt},ft={defaultMode:d.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Me,modes:dt,controls:{},userProperties:!1,suppressAPIEvents:!0},pt={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},ht={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function yt(e,t){return e.map(e=>e.source?e:Object.assign({},e,{id:`${e.id}.${t}`,source:"hot"===t?s.HOT:s.COLD}))}var mt=r(17),gt=r(186);function vt(e,t){return e.length===t.length&&JSON.stringify(e.map(e=>e).sort())===JSON.stringify(t.map(e=>e).sort())}const bt={Polygon:le,LineString:ue,Point:ae,MultiPolygon:he,MultiLineString:he,MultiPoint:he};function St(e){!function(e,t){const r={options:e=function(e={}){let t=Object.assign({},e);return e.controls||(t.controls={}),!1===e.displayControlsDefault?t.controls=Object.assign({},ht,e.controls):t.controls=Object.assign({},pt,e.controls),t=Object.assign({},ft,t),t.styles=yt(t.styles,"cold").concat(yt(t.styles,"hot")),t}(e)};t=function(e,t){t.modes=d;const r=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(t){return J.click({point:t},null,e).map(e=>e.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:l.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(t=>e.store.get(t)).map(e=>e.toGeoJSON())}},t.getSelectedPoints=function(){return{type:l.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(e=>({type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:e.coordinates}}))}},t.set=function(r){if(void 0===r.type||r.type!==l.FEATURE_COLLECTION||!Array.isArray(r.features))throw new Error("Invalid FeatureCollection");const n=e.store.createRenderBatch();let o=e.store.getAllIds().slice();const i=t.add(r),a=new X(i);return o=o.filter(e=>!a.has(e)),o.length&&t.delete(o),n(),i},t.add=function(t){const n=JSON.parse(JSON.stringify(gt(t))).features.map(t=>{if(t.id=t.id||re(),null===t.geometry)throw new Error("Invalid geometry: null");if(void 0===e.store.get(t.id)||e.store.get(t.id).type!==t.geometry.type){const n=bt[t.geometry.type];if(void 0===n)throw new Error(`Invalid geometry type: ${t.geometry.type}.`);const o=new n(e,t);e.store.add(o,{silent:r})}else{const n=e.store.get(t.id),o=n.properties;n.properties=t.properties,mt(o,t.properties)||e.store.featureChanged(n.id,{silent:r}),mt(n.getCoordinates(),t.geometry.coordinates)||n.incomingCoords(t.geometry.coordinates)}return t.id});return e.store.render(),n},t.get=function(t){const r=e.store.get(t);if(r)return r.toGeoJSON()},t.getAll=function(){return{type:l.FEATURE_COLLECTION,features:e.store.getAll().map(e=>e.toGeoJSON())}},t.delete=function(n){return e.store.delete(n,{silent:r}),t.getMode()!==d.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(d.SIMPLE_SELECT,void 0,{silent:r}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:r}),t.getMode()===d.DIRECT_SELECT?e.events.changeMode(d.SIMPLE_SELECT,void 0,{silent:r}):e.store.render(),t},t.changeMode=function(n,o={}){return n===d.SIMPLE_SELECT&&t.getMode()===d.SIMPLE_SELECT?(vt(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:r}),e.store.render()),t):(n===d.DIRECT_SELECT&&t.getMode()===d.DIRECT_SELECT&&o.featureId===e.store.getSelectedIds()[0]||e.events.changeMode(n,o,{silent:r}),t)},t.getMode=function(){return e.events.getMode()},t.trash=function(){return e.events.trash({silent:r}),t},t.combineFeatures=function(){return e.events.combineFeatures({silent:r}),t},t.uncombineFeatures=function(){return e.events.uncombineFeatures({silent:r}),t},t.setFeatureProperty=function(n,o,i){return e.store.setFeatureProperty(n,o,i,{silent:r}),t},t}(r,t),r.api=t;const n=_e(r);t.onAdd=n.onAdd,t.onRemove=n.onRemove,t.types=c,t.options=e}(e,this)}St.modes=dt,St.constants=n,St.lib=i;const wt=St;var xt={onSetup:function(){return{}},onClick:function(){return!1},onKeyUp:function(){return!1},onDrag:function(){return!1},toDisplayFeatures:function(e,t,r){t.properties.active="false",r(t)}},Pt="draw.create",_t="draw.update",Et="draw.modechange",Ot="draw.editfinish",It="draw.cancel",Mt="draw.vertexselection",Ct="draw.vertexchange",Tt="draw.undochange",At="draw.geometrychange",jt="draw.interfacetypechange",kt="draw.placementblocked",Lt="draw.nudgevertex",Ft="draw.selectvertex",Vt="draw.insertvertexatmidpoint",Dt="styledata";function Nt(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||Ut(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Rt(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Ut(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function Ut(e,t){if(e){if("string"==typeof e)return Bt(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Bt(e,t):void 0}}function Bt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Gt=function(e){if(null==e||!e.coordinates)return[];switch(e.type){case"LineString":return e.coordinates;case"Polygon":case"MultiLineString":return e.coordinates.flat(1);case"MultiPolygon":return e.coordinates.flat(2);default:return[]}},Ht=function(e){var t=Gt(e),r=Yt(e);if(!t.length||!r.length)return[];var n,o=[],i=Rt(r);try{for(i.s();!(n=i.n()).done;)for(var a=n.value,s=a.closed?a.length:a.length-1,u=0;u<s;u++){var c=a.start+u,l=a.start+(u+1)%a.length,d=Nt(t[c],2),f=d[0],p=d[1],h=Nt(t[l],2),y=h[0],m=h[1];o.push([(f+y)/2,(p+m)/2])}}catch(e){i.e(e)}finally{i.f()}return o},Yt=function(e){if(null==e||!e.coordinates)return[];var t=[],r=0;switch(e.type){case"LineString":t.push({start:0,length:e.coordinates.length,path:[],closed:!1});break;case"Polygon":e.coordinates.forEach(function(e,n){t.push({start:r,length:e.length,path:[n],closed:!0}),r+=e.length});break;case"MultiLineString":e.coordinates.forEach(function(e,n){t.push({start:r,length:e.length,path:[n],closed:!1}),r+=e.length});break;case"MultiPolygon":e.coordinates.forEach(function(e,n){e.forEach(function(e,o){t.push({start:r,length:e.length,path:[n,o],closed:!0}),r+=e.length})})}return t},$t=function(e,t){var r,n=Rt(e);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(t>=o.start&&t<o.start+o.length)return{segment:o,localIdx:t-o.start}}}catch(e){n.e(e)}finally{n.f()}return null},Xt=function(e,t){var r,n=e.geometry.coordinates,o=Rt(t);try{for(o.s();!(r=o.n()).done;)n=n[r.value]}catch(e){o.e(e)}finally{o.f()}return n},Kt=function(e,t){var r,n=t.split(".").map(Number),o=Rt(Yt(e));try{for(o.s();!(r=o.n()).done;){var i=r.value;if(i.path.every(function(e,t){return e===n[t]})&&n.length===i.path.length+1){var a=n[n.length-1];return i.start+a}}}catch(e){o.e(e)}finally{o.f()}return n[n.length-1]},Jt=function(e,t){return{x:e.x*t,y:e.y*t}},qt=function(e){return e instanceof window.SVGElement||e.ownerSVGElement},zt=r(682);function Wt(e){return Wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Wt(e)}function Zt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Qt(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Zt(Object(r),!0).forEach(function(t){er(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Zt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function er(e,t,r){return(t=function(e){var t=function(e){if("object"!=Wt(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Wt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Wt(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function tr(e){var t;return null!==(t=null==e?void 0:e._snapInstance)&&void 0!==t?t:null}function rr(e){var t;return!!(null!=e&&e.status&&null!=e&&e.snapStatus&&(null===(t=e.snapCoords)||void 0===t?void 0:t.length)>=2)}function nr(e){return rr(e)?{lng:e.snapCoords[0],lat:e.snapCoords[1]}:null}function or(e,t,r){if(!e||!t||!e.status)return!1;var n=t.unproject(r);return e.snapToClosestPoint({point:r,lngLat:n,_explicit:!0}),!0}function ir(e,t){e&&(e._autoSnapSuspended=t)}function ar(e,t){if(!e||!t||!e.status)return!1;var r=t.getCenter(),n=t.project(r);return e.snapToClosestPoint({point:n,lngLat:r,_explicit:!0}),!0}function sr(e,t){var r,n,o;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(r=e.snappedFeatures)&&void 0!==r&&r.length&&(e.snappedFeatures.length=0),null!==(n=e.closeFeatures)&&void 0!==n&&n.length&&(e.closeFeatures.length=0),null!==(o=e.lines)&&void 0!==o&&o.length&&(e.lines.length=0)),null!=t&&t.getLayer("snap-helper-circle")&&t.setLayoutProperty("snap-helper-circle","visibility","none")}function ur(e){var t,r,n;e&&(e.snapStatus=!1,e.snapCoords=null,null!==(t=e.snappedFeatures)&&void 0!==t&&t.length&&(e.snappedFeatures.length=0),null!==(r=e.closeFeatures)&&void 0!==r&&r.length&&(e.closeFeatures.length=0),null!==(n=e.lines)&&void 0!==n&&n.length&&(e.lines.length=0))}function cr(e){return"function"==typeof(null==e?void 0:e.getSnapEnabled)&&!0===e.getSnapEnabled()}function lr(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return dr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?dr(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function dr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var fr=function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=function(r){return function(n){return r.call(e,t,n)}},o={keydown:n(e.onKeydown),keyup:n(e.onKeyup),pointerdown:n(e.onPointerevent),pointermove:n(e.onPointerevent),pointerup:n(e.onPointerevent),click:n(e.onButtonClick),touchstart:n(e.onTouchstart),touchmove:n(e.onTouchmove),touchend:n(e.onTouchend),scalechange:n(e.onScaleChange),move:n(e.onMove),interfacetypechange:n(e.onInterfaceTypeChange)},i=0,a=Object.entries(r);i<a.length;i++){var s=lr(a[i],2),u=s[0],c=s[1];o[u]=n(c)}return o},pr=function(e,t,r){window.addEventListener("keydown",r.keydown,{capture:!0}),window.addEventListener("keyup",r.keyup,{capture:!0}),window.addEventListener("click",r.click),e.container.addEventListener("pointerdown",r.pointerdown),e.container.addEventListener("pointermove",r.pointermove),e.container.addEventListener("pointerup",r.pointerup),e.container.addEventListener("touchstart",r.touchstart,{passive:!1}),e.container.addEventListener("touchmove",r.touchmove,{passive:!1}),e.container.addEventListener("touchend",r.touchend,{passive:!1}),t.on("draw.scalechange",r.scalechange),t.on("move",r.move),t.on(jt,r.interfacetypechange),t.on(Lt,r.nudge)},hr=function(e,t,r){e.container.removeEventListener("pointerdown",r.pointerdown),e.container.removeEventListener("pointermove",r.pointermove),e.container.removeEventListener("pointerup",r.pointerup),e.container.removeEventListener("touchstart",r.touchstart),e.container.removeEventListener("touchmove",r.touchmove),e.container.removeEventListener("touchend",r.touchend),t.off("draw.scalechange",r.scalechange),t.off("move",r.move),t.off(jt,r.interfacetypechange),t.off(Lt,r.nudge),t.dragPan.enable(),window.removeEventListener("click",r.click),window.removeEventListener("keydown",r.keydown,{capture:!0}),window.removeEventListener("keyup",r.keyup,{capture:!0})},yr=function(e){var t=tr(e);t&&sr(t,e)},mr={fireGeometryChange:function(e){var t=this.getFeature(e.featureId);t&&this.map.fire("draw.update",{features:[t.toGeoJSON()],action:"change_coordinates"})},emitGeometryValidation:function(e,t,r){var n=this;e&&setTimeout(function(){var o=n.getFeature(r);o&&n.map.fire("draw.geometrychange",{feature:o.toGeoJSON(),phase:e,vertexIndex:t})},0)},pushUndo:function(e){var t=this.map._undoStack;t&&(t.push(e),this.emitGeometryValidation(this.UNDO_OP_PHASE[e.type],e.vertexIndex,e.featureId))}};function gr(e){return gr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},gr(e)}function vr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function br(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Sr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?br(Object(r),!0).forEach(function(t){wr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):br(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function wr(e,t,r){return(t=function(e){var t=function(e){if("object"!=gr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=gr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==gr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var xr={move_vertex:"commit-move",insert_vertex:"commit-delete",delete_vertex:"commit-insert"},Pr=Sr(Sr({},mr),{},{UNDO_OP_PHASE:{move_vertex:"commit-move",insert_vertex:"commit-insert",delete_vertex:"commit-delete"},UNDO_INVERSE_PHASE:xr,handleUndo:function(e){var t=this.map._undoStack;if(t&&0!==t.length){var r=t.pop();"move_vertex"===r.type?this.undoMoveVertex(e,r):"insert_vertex"===r.type?this.undoInsertVertex(e,r):"delete_vertex"===r.type&&this.undoDeleteVertex(e,r),this.emitGeometryValidation(xr[r.type],r.vertexIndex,r.featureId)}},undoMoveVertex:function(e,t){var r=t.vertexIndex,n=t.previousPosition,o=t.featureId,i=this.getFeature(o);if(i){var a=i.toGeoJSON(),s=Yt(i),u=$t(s,r);if(u){Xt(a,u.segment.path)[u.localIdx]=n,this._applyUndoAndSync(e,a,o);var c=e.vertices[e.selectedVertexIndex];c&&this.updateTouchVertexTarget(e,Jt(this.map.project(c),e.scale))}}},undoInsertVertex:function(e,t){var r=t.vertexIndex,n=t.featureId,o=this.getFeature(n);if(o){var i=o.toGeoJSON(),a=Yt(o),s=$t(a,r);s&&(Xt(i,s.segment.path).splice(s.localIdx,1),this._applyUndoAndSync(e,i,n),this.clearSelectedCoordinates(),this.hideTouchVertexIndicator(e),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null}))}},undoDeleteVertex:function(e,t){var r=t.vertexIndex,n=t.position,o=t.featureId,i=this.getFeature(o);if(i){var a=i.toGeoJSON(),s=Yt(i),u=$t(s,r);if(!u){var c,l=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return vr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vr(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(s);try{for(l.s();!(c=l.n()).done;){var d=c.value;if(r===d.start+d.length){u={segment:d,localIdx:d.length};break}}}catch(e){l.e(e)}finally{l.f()}}u&&(Xt(a,u.segment.path).splice(u.localIdx,0,n),this._applyUndoAndSync(e,a,o),this.updateTouchVertexTarget(e,Jt(this.map.project(e.vertices[r]),e.scale)),this.changeMode(e,{selectedVertexIndex:r,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,r)}))}},_applyUndoAndSync:function(e,t,r){this._ctx.api.add(t),e.vertices=this.getVertices(r),e.midpoints=this.getMidpoints(r),this._ctx.store.render(),this.fireGeometryChange(e)}}),_r=r(722),Er=r(473),Or=function(e){return{x:e.touches[0].clientX,y:e.touches[0].clientY}},Ir=function(e,t,r,n,o){var i=window.getComputedStyle(t),a={x:r.x-Number.parseFloat(i.left),y:r.y-Number.parseFloat(i.top)},s=e.project(n);return{deltaTarget:a,deltaVertex:{x:r.x/o-s.x,y:r.y/o-s.y}}},Mr=function(e,t,r){var n={x:r.x/t.scale-t.deltaVertex.x,y:r.y/t.scale-t.deltaVertex.y},o=e.unproject(n);if(cr(t)){var i=tr(e);or(i,e,n),o=nr(i)||o}return o};function Cr(e){return Cr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Cr(e)}function Tr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Ar(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function jr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ar(Object(r),!0).forEach(function(t){kr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ar(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function kr(e,t,r){return(t=function(e){var t=function(e){if("object"!=Cr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Cr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Cr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Lr=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e){var n=(0,Er.$)(t,r),o=n.editActive,i=n.editHalo,a=n.editVertex;(0,_r.ZP)(e,{editActive:o,editHalo:i,editVertex:a})}},Fr={addTouchVertexTarget:function(e){e.touchVertexTarget=(0,_r.DD)(e.container),Lr(e.touchVertexTarget,this.map._drawCurrentMapStyle,this.map._drawPluginConfig)},updateTouchVertexTarget:function(e,t){t&&"touch"===e.interfaceType&&e.selectedVertexIndex>=0?Object.assign(e.touchVertexTarget.style,{display:"block",top:"".concat(t.y,"px"),left:"".concat(t.x,"px")}):e.touchVertexTarget.style.display="none"},hideTouchVertexIndicator:function(e){e.touchVertexTarget.style.display="none"},onPointerevent:function(e,t){e.interfaceType="touch"===t.pointerType?"touch":"mouse",e.isPanEnabled=!0,"touch"!==t.pointerType||"pointermove"!==t.type||qt(t.target.parentNode)||e._ignorePointermoveDeselect||this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,coordPath:null})},onTouchStart:function(){},onTouchMove:function(){},onTouchEnd:function(){},onTouchend:function(e){if(ur(tr(this.map)),null!=e&&e.featureId){this.syncVertices(e),e._touchMoved&&e._moveStartPosition&&null!=e._moveStartIndex&&this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,e._moveStartIndex=null,e._touchMoved=!1;var t=e.vertices[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,Jt(this.map.project(t),e.scale))}},onTap:function(e,t){var r,n,o=tr(this.map);o&&sr(o,this.map);var i=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,a=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if("vertex"===i){var s=this.getFeature(e.featureId),u=Kt(s,a);this.changeMode(e,{selectedVertexIndex:u,selectedVertexType:"vertex",coordPath:a})}else"midpoint"===i?this.insertVertex(jr(jr({},e),{},{selectedVertexIndex:this.getVertexIndexFromMidpoint(e,a),selectedVertexType:"midpoint"})):this.clickNoTarget(e)},onTouchstart:function(e,t){ur(tr(this.map));var r,n=this.getVertices(e.featureId),o=null==n?void 0:n[e.selectedVertexIndex];if(o&&qt(t.target.parentNode)){e._moveStartPosition=function(e){if(Array.isArray(e))return Tr(e)}(r=o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return Tr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Tr(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e._moveStartIndex=e.selectedVertexIndex,e._touchMoved=!1;var i=Or(t);Object.assign(e,Ir(this.map,e.touchVertexTarget,i,o,e.scale))}},onTouchmove:function(e,t){if(!(e.selectedVertexIndex<0)&&qt(t.target.parentNode)){e._touchMoved=!0;var r=Or(t);this.moveVertex(e,Mr(this.map,e,r)),this.updateTouchVertexTarget(e,{x:r.x-e.deltaTarget.x,y:r.y-e.deltaTarget.y})}}},Vr=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),Dr={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},Nr=new Set(["INPUT","TEXTAREA","BUTTON","SELECT","A"]),Rr=function(e){var t,r=document.activeElement;return!(!r||r===document.body)&&(null===(t=e.container)||void 0===t||!t.contains(r))&&(Nr.has(r.tagName)||r.isContentEditable||r.hasAttribute("tabindex"))},Ur=function(e){return"z"===e.key&&(e.metaKey||e.ctrlKey)&&!e.shiftKey},Br={handleUndoShortcut:function(e,t){var r,n=null===(r=document.activeElement)||void 0===r?void 0:r.tagName;"INPUT"!==n&&"TEXTAREA"!==n&&(t.preventDefault(),t.stopPropagation(),this.handleUndo(e))}};function Gr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Hr={getOffset:function(e,t){var r=this.map.project(e),n=null!=t&&t.shiftKey?zt.WQ.nudgeAmount:zt.WQ.stepAmount,o=function(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return Gr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Gr(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t?Dr[t.key].map(function(e){return e*n}):[0,0],2),i=o[0],a=o[1];return this.map.unproject({x:r.x+i,y:r.y+a})},getOffsetByDelta:function(e,t,r,n){var o=this.map.project(e),i=n?zt.WQ.stepAmount:zt.WQ.nudgeAmount;return this.map.unproject({x:o.x+t*i,y:o.y+r*i})},resolveSnapTarget:function(e,t,r,n,o){var i=tr(this.map);if(cr(e)&&e._isSnapped&&i){var a=function(e){var t,r;return null!==(t=null==e||null===(r=e.options)||void 0===r?void 0:r.radius)&&void 0!==t?t:zt.vf.snapRadius}(i)+1,s=this.map.project(n);return e._isSnapped=!1,sr(i,this.map),this.map.unproject({x:s.x+t*a,y:s.y+r*a})}var u=o();return cr(e)&&i&&(or(i,this.map,this.map.project(u)),rr(i))?(e._isSnapped=!0,nr(i)):(e._isSnapped=!1,u)}},Yr=r(9);function $r(e){return $r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$r(e)}function Xr(e){return function(e){if(Array.isArray(e))return Jr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Kr(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Kr(e,t){if(e){if("string"==typeof e)return Jr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Jr(e,t):void 0}}function Jr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function qr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function zr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?qr(Object(r),!0).forEach(function(t){Wr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):qr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Wr(e,t,r){return(t=function(e){var t=function(e){if("object"!=$r(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=$r(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==$r(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Zr=zr(zr({},Hr),{},{updateMidpoint:function(e){var t=this;setTimeout(function(){t.map.getSource("mapbox-gl-draw-hot").setData({type:"Feature",properties:{meta:"midpoint",active:"true",id:"active-midpoint"},geometry:{type:"Point",coordinates:e}})},0)},updateVertex:function(e,t){var r,n,o=(r=this.getVertexOrMidpoint(e,t),n=2,function(e){if(Array.isArray(e))return e}(r)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(r,n)||Kr(r,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),i=o[0],a=o[1];i<0||!a||this.changeMode(e,zr({selectedVertexIndex:i,selectedVertexType:a},"vertex"===a&&{coordPath:this.getCoordPath(e,i)}))},getNewCoord:function(e,t){return this.getOffset(Gt(this.getFeature(e.featureId))[e.selectedVertexIndex],t)},nudgeVertexByDelta:function(e,t,r,n){var o,i=this;if(!("vertex"!==e.selectedVertexType||e.selectedVertexIndex<0)){var a=this.getFeature(e.featureId),s=a&&(null===(o=Gt(a))||void 0===o?void 0:o[e.selectedVertexIndex]);if(s){var u=Xr(s),c=e.selectedVertexIndex,l=this.resolveSnapTarget(e,t,r,s,function(){return i.getOffsetByDelta(s,t,r,n)});this.moveVertex(e,l),this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:c,previousPosition:u})}}},insertVertex:function(e,t){var r,n=e.selectedVertexIndex-e.vertices.length,o=this.getOffset(e.midpoints[n],t),i=this.getFeature(e.featureId),a=i.toGeoJSON(),s=n+1,u=null,c=0,l=0,d=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=Kr(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(Yt(i));try{for(d.s();!(r=d.n()).done;){var f=r.value,p=f.closed?f.length:f.length-1;if(n<l+p){u=f,c=n-l+1,s=f.start+c;break}l+=p}}catch(e){d.e(e)}finally{d.f()}u&&(Xt(a,u.path).splice(c,0,[o.lng,o.lat]),this._ctx.api.add(a),this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:s}),this.changeMode(e,{selectedVertexIndex:s,selectedVertexType:"vertex",coordPath:this.getCoordPath(e,s)}))},moveVertex:function(e,t){if((arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).checkSnap&&!1!==e.enableSnap){var r,n=this.map._snapInstance;null!=n&&n.snapStatus&&(null===(r=n.snapCoords)||void 0===r?void 0:r.length)>=2&&(t={lng:n.snapCoords[0],lat:n.snapCoords[1]})}var o=this.getFeature(e.featureId),i=o.toGeoJSON(),a=Yt(o),s=$t(a,e.selectedVertexIndex);s&&(Xt(i,s.segment.path)[s.localIdx]=[t.lng,t.lat],this._ctx.api.add(i),e.vertices=this.getVertices(e.featureId),this.map.fire("draw.geometrychange",e.feature))},deleteVertex:function(e){var t=this.getFeature(e.featureId);if(t){var r=Yt(t),n=$t(r,e.selectedVertexIndex);if(n){var o=n.segment,i=o.closed?Yr.n8.Polygon:Yr.n8.LineString;if(!(o.length<=i)){var a=Xr(e.vertices[e.selectedVertexIndex]),s=e.selectedVertexIndex,u=[].concat(Xr(n.segment.path),[n.localIdx]).join(".");t.removeCoordinate(u),this.fireUpdate(),this.clearSelectedCoordinates(),t.changed(),this._ctx.store.render(),this.pushUndo({type:"delete_vertex",featureId:e.featureId,vertexIndex:s,position:a}),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null})}}}}}),Qr=r(107);function en(e){return function(e){if(Array.isArray(e))return rn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||tn(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tn(e,t){if(e){if("string"==typeof e)return rn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?rn(e,t):void 0}}function rn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var nn={findVertexIndex:function(e,t,r){var n=[];return e.forEach(function(e,r){e[0]===t[0]&&e[1]===t[1]&&n.push(r)}),0===n.length?-1:1===n.length?n[0]:r>=0?n.reduce(function(e,t){return Math.abs(t-r)<Math.abs(e-r)?t:e},n[0]):n[0]},getCoordPath:function(e,t){var r=this.getFeature(e.featureId);if(!r)return"0";var n=Yt(r),o=$t(n,t);if(!o)return"0";var i=o.segment,a=o.localIdx;return[].concat(en(i.path),[a]).join(".")},syncVertices:function(e){e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId)},getVertices:function(e){return Gt(this.getFeature(e))},getMidpoints:function(e){return Ht(this.getFeature(e))},getVertexOrMidpoint:function(e,t){var r,n,o=this;if(null!==(r=e.vertices)&&void 0!==r&&r.length||(e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),null===(n=e.vertices)||void 0===n||!n.length)return[-1,null];var i=function(e){return e?Object.values(o.map.project(e)):null},a=[].concat(en(e.vertices.map(i)),en(e.midpoints.map(i))).filter(Boolean);if(!a.length)return[-1,null];var s=a[e.selectedVertexIndex]||Object.values(this.map.project(this.map.getCenter())),u=(0,Qr.c)(s,a,t);return[u,u<e.vertices.length?"vertex":"midpoint"]},getVertexIndexFromMidpoint:function(e,t){var r,n=this.getFeature(e.featureId),o=Yt(n),i=t.split(".").map(Number),a=0,s=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=tn(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(o);try{for(s.s();!(r=s.n()).done;){var u=r.value;if(u.path.every(function(e,t){return e===i[t]})&&i.length===u.path.length+1){var c=i[i.length-1],l=c>0?c-1:u.length-2;return e.vertices.length+a+l}a+=u.closed?u.length:u.length-1}}catch(e){s.e(e)}finally{s.f()}return e.vertices.length}},on=r(195);function an(e){return an="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},an(e)}function sn(e,t){if(e){if("string"==typeof e)return un(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?un(e,t):void 0}}function un(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function cn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ln(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?cn(Object(r),!0).forEach(function(t){dn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):cn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function dn(e,t,r){return(t=function(e){var t=function(e){if("object"!=an(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=an(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==an(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var fn=ln(ln({},Br),{},{onKeydown:function(e,t){Rr(e)||(e.interfaceType="keyboard",this.hideTouchVertexIndicator(e)," "!==t.key?Vr.has(t.key)&&e.selectedVertexIndex>=0?this.handleArrowKey(e,t):"Escape"!==t.key?Ur(t)&&this.handleUndoShortcut(e,t):this.changeMode(e,{isPanEnabled:!0,selectedVertexIndex:-1,selectedVertexType:null}):this.handleSpace(e,t))},handleSpace:function(e,t){t.preventDefault(),e.selectedVertexIndex<0&&this.startKeyboardSelection(e)},handleArrowKey:function(e,t){t.preventDefault(),t.stopPropagation(),t.altKey?this.updateVertex(e,t.key):this.moveVertexByKey(e,t)},startKeyboardSelection:function(e){var t,r,n=tr(this.map);n&&sr(n,this.map),null!==(t=e.vertices)&&void 0!==t&&t.length||(e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),null!==(r=e.vertices)&&void 0!==r&&r.length&&(e.isPanEnabled=!1,this.updateVertex(e))},moveVertexByKey:function(e,t){var r,n;if("midpoint"!==e.selectedVertexType){var o=this.getFeature(e.featureId),i=o&&(null===(r=Gt(o))||void 0===r?void 0:r[e.selectedVertexIndex]);i&&(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=function(e){if(Array.isArray(e))return un(e)}(n=i)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||sn(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e._keyboardMoveStartIndex=e.selectedVertexIndex),this.moveVertex(e,this._keyboardMoveTarget(e,t,i)))}else this.insertVertex(e,t)},_keyboardMoveTarget:function(e,t,r){var n,o,i=this,a=(n=Dr[t.key],o=2,function(e){if(Array.isArray(e))return e}(n)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(n,o)||sn(n,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=a[0],u=a[1];return this.resolveSnapTarget(e,s,u,r,function(){return i.getNewCoord(e,t)})},onKeyup:function(e,t){Rr(e)||(e.interfaceType="keyboard",e.selectedVertexIndex>=0&&(0,on.z)(t),Vr.has(t.key)&&e.selectedVertexIndex>=0&&(t.stopPropagation(),e._keyboardMoveStartPosition&&null!=e._keyboardMoveStartIndex&&(this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._keyboardMoveStartIndex,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null,e._keyboardMoveStartIndex=null)),"Delete"===t.key&&this.deleteVertex(e))}});function pn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var hn={onMouseDown:function(e,t){var r,n;ur(tr(this.map));var o,i=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,a=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if(["vertex","midpoint"].includes(i)&&(e.dragMoveLocation=t.lngLat,e.dragMoving=!1,ot.onMouseDown.call(this,e,t),"vertex"===i&&a)){var s,u=this.getFeature(e.featureId),c=Kt(u,a);e.selectedVertexIndex=c,e.selectedVertexType="vertex",e.coordPath=a;var l=null===(s=e.vertices)||void 0===s?void 0:s[c];l&&(e._moveStartPosition=function(e){if(Array.isArray(e))return pn(e)}(o=l)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||function(e,t){if(e){if("string"==typeof e)return pn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pn(e,t):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e._moveStartIndex=c)}if("midpoint"===i){var d=this.getFeature(e.featureId),f=Kt(d,a);e._insertedVertexIndex=f,e._isInsertingVertex=!0,e.selectedVertexIndex=this.getVertexIndexFromMidpoint(e,a),e.selectedVertexType="vertex",e.coordPath=null,this.map.fire(Mt,{index:e.selectedVertexIndex,numVertices:e.vertices.length})}},onClick:function(e,t){if(e._isInsertingVertex&&null!=e._insertedVertexIndex){var r=e._insertedVertexIndex;return this.syncVertices(e),this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:r}),e.selectedVertexIndex=r,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=null,void this.map.fire(Mt,{index:r,numVertices:e.vertices.length})}ot.onClick.call(this,e,t)},onMouseUp:function(e,t){ur(tr(this.map));var r=e._isInsertingVertex&&null!=e._insertedVertexIndex,n=this._didVertexMove(e);(e.dragMoving||n||r)&&(this.syncVertices(e),r?this._recordInsertionUndo(e):n&&this._recordMoveUndo(e)),e._moveStartPosition=null,e._moveStartIndex=null,ot.onMouseUp.call(this,e,t)},_didVertexMove:function(e){var t;if(!e._moveStartPosition||null==e._moveStartIndex)return!1;var r=this.getFeature(e.featureId),n=r&&(null===(t=Gt(r))||void 0===t?void 0:t[e._moveStartIndex]);return!!n&&(n[0]!==e._moveStartPosition[0]||n[1]!==e._moveStartPosition[1])},_recordInsertionUndo:function(e){var t=e._insertedVertexIndex;this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:t}),e.selectedVertexIndex=t,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=null,this.map.fire(Mt,{index:t,numVertices:e.vertices.length})},_recordMoveUndo:function(e){this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition})},onDrag:function(e,t){var r;if("touch"!==e.interfaceType){this.map.fire("draw.geometrychange",e.feature);var n=tr(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),cr(e)&&null!=n&&n.status){if(null!==(r=e.selectedCoordPaths)&&void 0!==r&&r.length&&e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation(),or(n,this.map,t.point);var o=nr(n)||t.lngLat;e.feature.updateCoordinate(e.selectedCoordPaths[0],o.lng,o.lat),e.dragMoveLocation=t.lngLat}}else ot.onDrag.call(this,e,t)}}};function yn(e){return yn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yn(e)}function mn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function gn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?mn(Object(r),!0).forEach(function(t){vn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function vn(e,t,r){return(t=function(e){var t=function(e){if("object"!=yn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=yn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==yn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var bn=gn(gn(gn(gn(gn(gn(gn(gn({},wt.modes.direct_select),Pr),Fr),Zr),nn),fn),hn),{},{onSetup:function(e){var t,r,n,o=this,i=wt.modes.direct_select.onSetup.call(this,e);Object.assign(i,{container:e.container,interfaceType:e.interfaceType,deleteVertexButtonId:e.deleteVertexButtonId,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,featureId:i.featureId,selectedVertexIndex:null!==(t=e.selectedVertexIndex)&&void 0!==t?t:-1,selectedVertexType:e.selectedVertexType,coordPath:e.coordPath,scale:null!==(r=e.scale)&&void 0!==r?r:1}),this.map._lastEditFeatureId!==i.featureId&&(null===(n=this.map._undoStack)||void 0===n||n.clear(),this.map._lastEditFeatureId=i.featureId);var a=this.getFeature(i.featureId);if(i.featureType=null==a?void 0:a.type,i.vertices=this.getVertices(i.featureId),i.midpoints=this.getMidpoints(i.featureId),this.setupEventListeners(i),this.applyVertexSelection(i,e),this.map._drawEditContainer=e.container,this.addTouchVertexTarget(i),yr(this.map),"touch"===i.interfaceType&&i.selectedVertexIndex>=0&&"vertex"===i.selectedVertexType){var s=i.vertices[i.selectedVertexIndex];s&&setTimeout(function(){o.updateTouchVertexTarget(i,Jt(o.map.project(s),i.scale))},0)}return i._ignorePointermoveDeselect=!0,setTimeout(function(){i._ignorePointermoveDeselect=!1},100),i},setupEventListeners:function(e){var t=this.handlers=fr(this,e,{nudge:this.onNudgeVertex,selectionchange:this.onSelectionChange,update:this.onUpdate,selectvertex:this.onSelectVertex,insertvertexatmidpoint:this.onInsertVertexAtMidpoint});pr(e,this.map,t),this.map.on("draw.selectionchange",t.selectionchange),this.map.on("draw.update",t.update),this.map.on(Ft,t.selectvertex),this.map.on(Vt,t.insertvertexatmidpoint)},applyVertexSelection:function(e,t){if("midpoint"===t.selectedVertexType)return e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed(),this._ctx.store.render(),void this.updateMidpoint(e.midpoints[t.selectedVertexIndex-e.vertices.length]);-1===t.selectedVertexIndex&&(e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature.changed(),this._ctx.store.render())},onSelectionChange:function(e,t){var r,n;this.syncVertices(e);var o=null===(r=t.points[t.points.length-1])||void 0===r?void 0:r.geometry.coordinates;if("keyboard"!==e.interfaceType&&o&&!e.coordPath){var i,a=null===(i=t.features[0])||void 0===i?void 0:i.geometry,s=Gt(a);e.selectedVertexIndex=this.findVertexIndex(s,o,e.selectedVertexIndex)}null!==(n=e.selectedVertexType)&&void 0!==n||(e.selectedVertexType=e.selectedVertexIndex>=0?"vertex":null),this.map.fire(Mt,{index:"vertex"===e.selectedVertexType?e.selectedVertexIndex:-1,numVertices:e.vertices.length});var u=o||(e.selectedVertexIndex>=0?e.vertices[e.selectedVertexIndex]:null);this.updateTouchVertexTarget(e,u?Jt(this.map.project(u),e.scale):null)},onScaleChange:function(e,t){e.scale=t.scale},onInterfaceTypeChange:function(e,t){e.interfaceType=t.interfaceType;var r=e.selectedVertexIndex>=0?e.vertices[e.selectedVertexIndex]:null;this.updateTouchVertexTarget(e,r?Jt(this.map.project(r),e.scale):null)},onUpdate:function(e){var t;new Set(e.vertices.map(function(e){return JSON.stringify(e)})).size!==e.vertices.length&&(e.selectedVertexIndex=-1,null!==(t=e.selectedVertexType)&&void 0!==t||(e.selectedVertexType=null))},onMove:function(e){var t=e.vertices[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,Jt(this.map.project(t),e.scale))},onNudgeVertex:function(e,t){this.nudgeVertexByDelta(e,t.dx,t.dy,t.isLargeStep);var r=e.vertices[e.selectedVertexIndex];r&&this.updateTouchVertexTarget(e,Jt(this.map.project(r),e.scale))},onSelectVertex:function(e,t){var r;null!==(r=e.vertices)&&void 0!==r&&r.length||(e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId));var n=t.index<e.vertices.length?"vertex":"midpoint";this.changeMode(e,gn({selectedVertexIndex:t.index,selectedVertexType:n},"vertex"===n&&{coordPath:this.getCoordPath(e,t.index)}))},onInsertVertexAtMidpoint:function(e,t){var r;null!==(r=e.vertices)&&void 0!==r&&r.length||(e.vertices=this.getVertices(e.featureId),e.midpoints=this.getMidpoints(e.featureId)),this.insertVertex(gn(gn({},e),{},{selectedVertexIndex:t.index,selectedVertexType:"midpoint"}))},onButtonClick:function(e,t){t.target.closest("#".concat(e.deleteVertexButtonId))&&"vertex"===e.selectedVertexType&&this.deleteVertex(e),t.target.closest("#".concat(e.undoButtonId))&&this.handleUndo(e)},clickNoTarget:function(e){this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,isPanEnabled:!0})},changeMode:function(e,t){e.featureId&&this._ctx.api.changeMode("edit_vertex",gn(gn({},e),t))},onStop:function(e){this.map._drawEditContainer=null,this.map._editingFeatureId=null;var t=this.handlers;this.map.off("draw.selectionchange",t.selectionchange),this.map.off("draw.update",t.update),this.map.off(Ft,t.selectvertex),this.map.off(Vt,t.insertvertexatmidpoint),hr(e,this.map,t),this.hideTouchVertexIndicator(e)}});function Sn(e){return Sn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Sn(e)}function wn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function xn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?wn(Object(r),!0).forEach(function(t){Pn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Pn(e,t,r){return(t=function(e){var t=function(e){if("object"!=Sn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Sn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Sn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var _n={move_point:"commit-move"},En=xn(xn({},mr),{},{UNDO_OP_PHASE:{move_point:"commit-move"},UNDO_INVERSE_PHASE:_n,handleUndo:function(e){var t=this.map._undoStack;if(t&&0!==t.length){var r=t.pop();"move_point"===r.type&&this.undoMovePoint(e,r),this.emitGeometryValidation(_n[r.type],r.vertexIndex,r.featureId)}},undoMovePoint:function(e,t){var r=t.previousPosition,n=t.featureId,o=this.getFeature(n);o&&(o.updateCoordinate("",r[0],r[1]),this._ctx.store.render(),this.fireGeometryChange(e),this.updateTouchPointTarget(e,Jt(this.map.project(r),e.scale)))}});function On(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var In={addTouchPointTarget:function(e){e.touchPointTarget=(0,_r.DD)(e.container),Lr(e.touchPointTarget,this.map._drawCurrentMapStyle,this.map._drawPluginConfig)},updateTouchPointTarget:function(e,t){t&&"touch"===e.interfaceType?Object.assign(e.touchPointTarget.style,{display:"block",top:"".concat(t.y,"px"),left:"".concat(t.x,"px")}):e.touchPointTarget.style.display="none"},hideTouchPointIndicator:function(e){e.touchPointTarget.style.display="none"},onPointerevent:function(e,t){e.interfaceType="touch"===t.pointerType?"touch":"mouse",e.isPanEnabled=!0},onTouchStart:function(){},onTouchMove:function(){},onTouchEnd:function(){},onTouchend:function(e){ur(tr(this.map)),e._touchMoved&&e._moveStartPosition&&this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,e._touchMoved=!1,e.feature&&this.updateTouchPointTarget(e,Jt(this.map.project(e.feature.coordinates),e.scale))},onTap:function(){},onTouchstart:function(e,t){ur(tr(this.map));var r,n=this.getPointCoord(e);if(n&&qt(t.target.parentNode)){e._moveStartPosition=function(e){if(Array.isArray(e))return On(e)}(r=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return On(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?On(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e._touchMoved=!1;var o=Or(t);Object.assign(e,Ir(this.map,e.touchPointTarget,o,n,e.scale))}},onTouchmove:function(e,t){if(qt(t.target.parentNode)){e._touchMoved=!0;var r=Or(t);this.movePoint(e,Mr(this.map,e,r)),this.updateTouchPointTarget(e,{x:r.x-e.deltaTarget.x,y:r.y-e.deltaTarget.y})}}};function Mn(e){return Mn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Mn(e)}function Cn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Tn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function An(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Tn(Object(r),!0).forEach(function(t){jn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Tn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function jn(e,t,r){return(t=function(e){var t=function(e){if("object"!=Mn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Mn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Mn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var kn=An(An({},Hr),{},{getPointCoord:function(e){var t;return null===(t=this.getFeature(e.featureId))||void 0===t?void 0:t.coordinates},getNewCoord:function(e,t){return this.getOffset(this.getPointCoord(e),t)},movePoint:function(e,t){e.feature.updateCoordinate("",t.lng,t.lat),this._ctx.store.render(),this.map.fire("draw.geometrychange",e.feature)},nudgePointByDelta:function(e,t,r,n){var o,i=this,a=this.getPointCoord(e);if(a){var s=function(e){if(Array.isArray(e))return Cn(e)}(o=a)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||function(e,t){if(e){if("string"==typeof e)return Cn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Cn(e,t):void 0}}(o)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=this.resolveSnapTarget(e,t,r,a,function(){return i.getOffsetByDelta(a,t,r,n)});this.movePoint(e,u),this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:s})}}});function Ln(e){return Ln="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ln(e)}function Fn(e,t){if(e){if("string"==typeof e)return Vn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Vn(e,t):void 0}}function Vn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Dn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Nn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Dn(Object(r),!0).forEach(function(t){Rn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Dn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Rn(e,t,r){return(t=function(e){var t=function(e){if("object"!=Ln(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Ln(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ln(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Un=Nn(Nn({},Br),{},{onKeydown:function(e,t){Rr(e)||(e.interfaceType="keyboard",this.hideTouchPointIndicator(e)," "!==t.key?Vr.has(t.key)?this.handleArrowKey(e,t):Ur(t)&&this.handleUndoShortcut(e,t):t.preventDefault())},handleArrowKey:function(e,t){t.preventDefault(),t.stopPropagation(),this.movePointByKey(e,t)},movePointByKey:function(e,t){var r,n=this.getPointCoord(e);n&&(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=function(e){if(Array.isArray(e))return Vn(e)}(r=n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||Fn(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),this.movePoint(e,this._keyboardMoveTarget(e,t,n)))},_keyboardMoveTarget:function(e,t,r){var n,o,i=this,a=(n=Dr[t.key],o=2,function(e){if(Array.isArray(e))return e}(n)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(n,o)||Fn(n,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=a[0],u=a[1];return this.resolveSnapTarget(e,s,u,r,function(){return i.getNewCoord(e,t)})},onKeyup:function(e,t){Rr(e)||(e.interfaceType="keyboard",(0,on.z)(t),Vr.has(t.key)&&(t.stopPropagation(),e._keyboardMoveStartPosition&&(this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null)))}}),Bn=r(520);function Gn(e){return function(e){if(Array.isArray(e))return Hn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Hn(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Hn(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Hn(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Yn="edit_point",$n={onFeature:function(e,t){e.dragMoving||(e._moveStartPosition=Gn(e.feature.coordinates),e._grabOffset=[e.feature.coordinates[0]-t.lngLat.lng,e.feature.coordinates[1]-t.lngLat.lat],ir(tr(this.map),!0)),ot.onFeature.call(this,e,t)},onClick:function(e,t){if(!E(t)&&(r=this.map,n={type:"Feature",geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]},properties:{}},i=(o=(0,Bn.oK)(n,{mode:Yn,vertexIndex:0},{onGeometryChange:r._drawGeometryValidator})).valid,a=o.reason,i||r.fire("draw.placementblocked",{feature:n,reason:null!=a?a:null,phase:"place",mode:Yn,vertexIndex:0}),i)){var r,n,o,i,a,s=Gn(e.feature.coordinates),u=tr(this.map),c=t.lngLat;cr(e)&&u&&(or(u,this.map,t.point),c=nr(u)||t.lngLat),this.movePoint(e,c),this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:s})}},onMouseUp:function(e,t){var r=tr(this.map);ur(r),ir(r,!1),this._didPointMove(e)&&this.pushUndo({type:"move_point",featureId:e.featureId,vertexIndex:0,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,ot.onMouseUp.call(this,e,t)},_didPointMove:function(e){if(!e._moveStartPosition)return!1;var t=e.feature.coordinates;return t[0]!==e._moveStartPosition[0]||t[1]!==e._moveStartPosition[1]},onDrag:function(e,t){if("touch"!==e.interfaceType){this.map.fire("draw.geometrychange",e.feature);var r=tr(this.map);if(r&&(r.snapStatus=!1,r.snapCoords=null),cr(e)&&null!=r&&r.status){if(e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation();var n={lng:t.lngLat.lng+e._grabOffset[0],lat:t.lngLat.lat+e._grabOffset[1]};or(r,this.map,this.map.project([n.lng,n.lat]));var o=nr(r)||n;e.feature.updateCoordinate("",o.lng,o.lat),e.dragMoveLocation=t.lngLat}}else ot.onDrag.call(this,e,t)}},onTrash:function(){}};function Xn(e){return Xn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Xn(e)}function Kn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Jn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Kn(Object(r),!0).forEach(function(t){qn(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Kn(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function qn(e,t,r){return(t=function(e){var t=function(e){if("object"!=Xn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Xn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Xn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var zn=Jn(Jn(Jn(Jn(Jn(Jn(Jn({},wt.modes.direct_select),En),In),kn),Un),$n),{},{onSetup:function(e){var t,r,n=this,o=e.featureId,i=this.getFeature(o);if(!i)throw new Error("You must provide a featureId to enter edit_point mode");var a,s={featureId:o,feature:i,dragMoveLocation:null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:[]};return this.setSelectedCoordinates([]),this.setSelected(o),Ye.disable(this),this.setActionableState({trash:!1}),Object.assign(s,{container:e.container,interfaceType:e.interfaceType,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,scale:null!==(t=e.scale)&&void 0!==t?t:1}),this.map._lastEditFeatureId!==s.featureId&&(null===(a=this.map._undoStack)||void 0===a||a.clear(),this.map._lastEditFeatureId=s.featureId),this.setupEventListeners(s),this.map._drawEditContainer=e.container,this.addTouchPointTarget(s),null===(r=s.container)||void 0===r||r.focus({preventScroll:!0}),yr(this.map),"touch"===s.interfaceType&&setTimeout(function(){n.updateTouchPointTarget(s,Jt(n.map.project(s.feature.coordinates),s.scale))},0),this.map.fire(Mt,{index:0,numVertices:1}),s},setupEventListeners:function(e){var t=this.handlers=fr(this,e,{nudge:this.onNudgePoint});pr(e,this.map,t)},toDisplayFeatures:function(e,t,r){t.properties.active=e.featureId===t.properties.id?"true":"false",r(t)},onScaleChange:function(e,t){e.scale=t.scale},onInterfaceTypeChange:function(e,t){e.interfaceType=t.interfaceType,this.updateTouchPointTarget(e,Jt(this.map.project(e.feature.coordinates),e.scale))},onMove:function(e){this.updateTouchPointTarget(e,Jt(this.map.project(e.feature.coordinates),e.scale))},onNudgePoint:function(e,t){this.nudgePointByDelta(e,t.dx,t.dy,t.isLargeStep),this.updateTouchPointTarget(e,Jt(this.map.project(e.feature.coordinates),e.scale))},onButtonClick:function(e,t){t.target.closest("#".concat(e.undoButtonId))&&this.handleUndo(e)},onStop:function(e){this.map._drawEditContainer=null,this.map._editingFeatureId=null,hr(e,this.map,this.handlers),this.hideTouchPointIndicator(e)}}),Wn=r(704);function Zn(e){return Zn="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Zn(e)}function Qn(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return eo(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?eo(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eo(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function to(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function ro(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?to(Object(r),!0).forEach(function(t){no(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):to(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function no(e,t,r){return(t=function(e){var t=function(e){if("object"!=Zn(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Zn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Zn(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var oo=function(e){var t=e.ParentMode,r=e.featureProp,n=e.excludeFeatureIdFromSetup;return{onSetup:function(e){var o=this,i=this.map,a=n?ro(ro({},e),{},{featureId:null}):e,s=ro(ro({},t.onSetup.call(this,a)),e);s[r].properties=e.properties;var u=s.container,c=s.vertexMarkerId,l=s.getInterfaceType,d=l?l():s.interfaceType;s.interfaceType=d;var f=u.querySelector("#".concat(c));s.vertexMarker=f,["touch","keyboard"].includes(d)?this._showCrossHair(s):this._hideCrossHair(s),s.crossHair&&(s.crossHair.activate=function(){var e;return null===(e=o._placeAtCrossHair)||void 0===e?void 0:e.call(o,s)});var p={keydownHandler:this.onKeydown,keyupHandler:this.onKeyup,blurHandler:this.onBlur,createHandler:this.onCreate,moveHandler:this.onMove,pointerdownHandler:this.onPointerdown,pointermoveHandler:this.onPointermove,pointerupHandler:this.onPointerup,vertexButtonClickHandler:this.onVertexButtonClick,undoHandler:this.onUndo,interfaceTypeChangeHandler:this.onInterfaceTypeChange};return Object.entries(p).forEach(function(e){var t,r,n=Qn(e,2);return t=n[0],r=n[1],o[t]=r.bind(o,s)}),this._listeners=[[window,"keydown",this.keydownHandler],[window,"keyup",this.keyupHandler],[window,"keyup",on.z,{capture:!0}],[window,"click",this.vertexButtonClickHandler],[u,"blur",this.blurHandler],[u,"pointermove",this.pointermoveHandler],[u,"pointerup",this.pointerupHandler],[i,"pointerdown",this.pointerdownHandler],[i,"draw.create",this.createHandler],[i,"move",this.moveHandler],[i,"draw.undo",this.undoHandler],[i,"draw.interfacetypechange",this.interfaceTypeChangeHandler]],this._listeners.forEach(function(e){var t=Qn(e,4),r=t[0],n=t[1],o=t[2],i=t[3];return r.addEventListener?r.addEventListener(n,o,i):r.on(n,o)}),s},onStop:function(e){var r;t.onStop.call(this,e),this._listeners.forEach(function(e){var t=Qn(e,4),r=t[0],n=t[1],o=t[2],i=t[3];return r.removeEventListener?r.removeEventListener(n,o,i):r.off(n,o)}),null!==(r=e.crossHair)&&void 0!==r&&r.activate&&(e.crossHair.activate=null),["touch","keyboard"].includes(e.interfaceType)||this._hideCrossHair(e),this.map.fire("draw.interfacetypechange",{interfaceType:e.interfaceType})}}};function io(e){return io="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},io(e)}function ao(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function so(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ao(Object(r),!0).forEach(function(t){uo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ao(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function uo(e,t,r){return(t=function(e){var t=function(e){if("object"!=io(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=io(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==io(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var co=function(e){return so(so({},function(e){var t=e.geometryType,r=e.getFeature,n=e.getCoords;return{_isIgnorableClick:function(e){return e.originalEvent.button>0||this.map._undoInProgress||e.originalEvent.target!==this.map.getCanvas()},_canPlaceVertex:function(e,o){var i=r(e);if(!i||!o)return!0;var a=(0,Bn.$b)({placed:n(i).slice(0,-1),point:o,geometryType:t,onGeometryChange:this.map._drawGeometryValidator});return a.valid||this.map.fire("draw.placementblocked",a.blocked),a.valid},dispatchVertexChange:function(e){this.map.fire("draw.vertexchange",{numVertices:Math.max(0,e.length-1)})},emitDrawValidation:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"commit-add";!function(e,t,r,n,o){setTimeout(function(){var i=t(n);i&&e.fire("draw.geometrychange",function(e,t,r){var n=t(e).slice(0,-1);return{feature:{type:"Feature",geometry:"Polygon"===e.toGeoJSON().geometry.type?{type:"Polygon",coordinates:[n]}:{type:"LineString",coordinates:n},properties:{}},phase:r,vertexIndex:Math.max(0,n.length-1)}}(i,r,o))},0)}(this.map,r,n,e,t)},onTap:function(){},onVertexButtonClick:function(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest("#".concat(e.addVertexButtonId))&&this.doClick(e)},onCreate:function(e,t){!function(e,t,r){e.delete(t.id),t.id=r,e.add(t,{userProperties:!0})}(this._ctx.api,t.features[0],e.featureId)}}}(e)),function(e){var t=e.ParentMode,r=e.getFeature,n=e.getCoords,o=e.validateClick,i=e.finishOnInvalidClick;return{onClick:function(e,a){var s;if(!this._isIgnorableClick(a)&&(!1!==this.map._drawGeometryValid||"vertex"!==(null===(s=a.featureTarget)||void 0===s||null===(s=s.properties)||void 0===s?void 0:s.meta))){var u=tr(this.map);if(cr(e)&&rr(u))a=function(e,t){var r=nr(t);return r?Qt(Qt({},e),{},{lngLat:r}):e}(a,u);else if(!function(e,t){var a=n(r(e));return a.length>0&&(a[a.length-1]=[t.lngLat.lng,t.lngLat.lat]),i||o(r(e))}(e,a))return;if(this._canPlaceVertex(e,[a.lngLat.lng,a.lngLat.lat])){var c=n(r(e)).length;t.onClick.call(this,e,a),n(r(e)).length>c&&(this.pushDrawUndo(e),this.dispatchVertexChange(n(r(e))),this.emitDrawValidation(e))}}},doClick:function(e){if(!this.map._undoInProgress){var a=r(e),s=n(a);if(this.dispatchVertexChange(s),o(a)){var u=tr(this.map),c=cr(e)&&function(e,t){var r=nr(t);if(!r)return null;var n=e.project([r.lng,r.lat]);return{lngLat:r,point:n,originalEvent:new MouseEvent("click",{clientX:n.x,clientY:n.y,bubbles:!0,cancelable:!0})}}(this.map,u),l=c?c.lngLat:this.map.getCenter();if(this._canPlaceVertex(e,[l.lng,l.lat])){c?(t.onClick.call(this,e,c),this._ctx.store.render()):this._simulateMouse("click",t.onClick,e);var d=n(r(e));this.pushDrawUndo(e),this.dispatchVertexChange(d),this.emitDrawValidation(e)}}else i&&!1!==this.map._drawGeometryValid&&(s.pop(),this.map.fire("draw.create",{features:[a.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[a.id]}))}},_placeAtCrossHair:function(e){this.doClick(e)}}}(e))};function lo(e){return lo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},lo(e)}function fo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function po(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fo(Object(r),!0).forEach(function(t){ho(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ho(e,t,r){return(t=function(e){var t=function(e){if("object"!=lo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=lo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==lo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function yo(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var mo=function(e){return po(po(po({},(r=(t=e).geometryType,n=t.getFeature,{pushDrawUndo:function(e){var t=this.map._undoStack;t&&!this.map._undoInProgress&&t.push({type:"draw_vertex",geometryType:r,featureId:n(e).id})},onUndo:function(e){var t=this,r=this.map._undoStack;if(r&&0!==r.length){var n=r.pop();"draw_vertex"===(null==n?void 0:n.type)&&(this.map._undoInProgress=!0,setTimeout(function(){t.map._undoInProgress=!1},100),this.undoVertex(e),this.emitDrawValidation(e,"commit-delete"))}},_handleUndoKeydown:function(e,t){var r,n=null===(r=document.activeElement)||void 0===r?void 0:r.tagName;"INPUT"!==n&&"TEXTAREA"!==n&&(t.preventDefault(),t.stopPropagation(),this.onUndo(e))}})),function(e){var t=e.ParentMode,r=e.geometryType,n=e.getCoords,o=e.getFeature,i=e.RUBBER_BAND_OFFSET;return{undoVertex:function(e){var t=o(e),r=n(t);return!(r.length<2)&&(2===r.length?this._reinitializeFeature(e,t):(this._removeLastVertex(e,t,r),!0))},_removeLastVertex:function(e,t,o){var a,s="Polygon"===r?t.coordinates[0]:o;s.splice(-i,1),s[s.length-1]=function(e){if(Array.isArray(e))return yo(e)}(a=s[s.length-2])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||function(e,t){if(e){if("string"==typeof e)return yo(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yo(e,t):void 0}}(a)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),e.currentVertexPosition=Math.max(1,e.currentVertexPosition-1),this._ctx.store.render(),this._updateRubberBand(e,n(t))},_updateRubberBand:function(e,n){if(["touch","keyboard"].includes(e.interfaceType))this._simulateMouse("mousemove",t.onMouseMove,e),this._ctx.store.render();else{var o=n["Polygon"===r?n.length-2:n.length-1],i={lng:o[0],lat:o[1]},a=this.map.project(i);t.onMouseMove.call(this,e,{lngLat:i,point:a,originalEvent:new MouseEvent("mousemove",{clientX:a.x,clientY:a.y})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",e.polygon||e.line)}this.dispatchVertexChange(n)}}}(e)),function(e){var t=e.ParentMode,r=e.featureProp,n=e.geometryType;return{_reinitializeFeature:function(e,o){var i=o.id;if(this._ctx.store.delete([i]),"LineString"===n)return this._restartLineStringDraw(e,i);var a=this.map.getCenter(),s=[[a.lng,a.lat],[a.lng,a.lat]],u=this.newFeature({type:"Feature",properties:e.properties||{},geometry:{type:n,coordinates:[s]}});return u.id=i,this._ctx.store.add(u),e[r]=u,e.currentVertexPosition=0,this._ctx.store.render(),this._simulateMouse("mousemove",t.onMouseMove,e),this._ctx.store.render(),this.dispatchVertexChange(s),!0},_restartLineStringDraw:function(e,t){var r=this.map._undoStack;return r&&r.clear(),this._ctx.api.changeMode("draw_line",{featureId:t,container:e.container,interfaceType:e.interfaceType,crossHair:e.crossHair,vertexMarkerId:e.vertexMarkerId,addVertexButtonId:e.addVertexButtonId,getSnapEnabled:e.getSnapEnabled,properties:e.properties}),!0}}}(e));var t,r,n};function go(e){return go="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},go(e)}function vo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function bo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?vo(Object(r),!0).forEach(function(t){So(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):vo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function So(e,t,r){return(t=function(e){var t=function(e){if("object"!=go(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=go(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==go(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function wo(e){return wo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},wo(e)}function xo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Po(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?xo(Object(r),!0).forEach(function(t){_o(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _o(e,t,r){return(t=function(e){var t=function(e){if("object"!=wo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=wo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==wo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Eo=function(e,t){var r=t.featureProp,n=t.geometryType,o=t.getCoords,i=t.validateClick,a=t.getPlacedCoords,s=t.excludeFeatureIdFromSetup,u=void 0!==s&&s,c=t.finishOnInvalidClick,l={ParentMode:e,featureProp:r,geometryType:n,getCoords:o,validateClick:i,getPlacedCoords:a,excludeFeatureIdFromSetup:u,finishOnInvalidClick:void 0!==c&&c,getFeature:function(e){return e[r]},RUBBER_BAND_OFFSET:2,INTERFACE_KEYS:new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"])};return Po(Po(Po(Po(Po(Po(Po({},e),oo(l)),co(l)),mo(l)),function(e){var t=e.ParentMode,r=e.getFeature,n=e.INTERFACE_KEYS;return{onKeydown:function(e,t){"z"!==t.key||!t.metaKey&&!t.ctrlKey||t.shiftKey?document.activeElement===e.container&&("Escape"!==t.key?("Enter"===t.key&&(e.isActive=!0),n.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e,t))):t.preventDefault()):this._handleUndoKeydown(e,t)},onKeyup:function(e,t){"Escape"!==t.key?document.activeElement===e.container&&n.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e,t),"Enter"===t.key&&e.isActive&&this.doClick(e)):"keyboard"!==e.interfaceType&&this.map.fire("draw.cancel")},onKeyUp:function(e,n){var o=document.activeElement;if(!o||o===e.container||!e.container.contains(o))if("Escape"!==n.key)o!==e.container&&t.onKeyUp.call(this,e,n);else if("keyboard"===e.interfaceType){var i=this.map._undoStack;i&&i.clear(),this._reinitializeFeature(e,r(e))}}}}(l)),function(e){var t=e.ParentMode,r=e.getFeature,n=e.getCoords;return{onTouchStart:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onTouchEnd:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onInterfaceTypeChange:function(e,t){this._setInterface(e,t.interfaceType,["touch","keyboard"].includes(t.interfaceType)),this.onMove(e)},onBlur:function(e,t){t.target!==e.container&&this._hideCrossHair(e)},onMouseMove:function(e,r){if(cr(e)){var n=tr(this.map);or(n,this.map,r.point);var o=nr(n);o&&(r=bo(bo({},r),{},{lngLat:o}))}t.onMouseMove.call(this,e,r),this.map.fire("draw.geometrychange",e.polygon||e.line)},onMove:function(e,r){var n="move"===(null==r?void 0:r.type)&&!r.originalEvent;if(["touch","keyboard"].includes(e.interfaceType)||n){cr(e)&&ar(tr(this.map),this.map);var o=tr(this.map),i=cr(e)&&nr(o);if(i){var a=this.map.project([i.lng,i.lat]);t.onMouseMove.call(this,e,{lngLat:i,point:a,originalEvent:new MouseEvent("mousemove",{clientX:a.x,clientY:a.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",e.polygon||e.line)}else this._simulateMouse("mousemove",t.onMouseMove,e)}},onPointerdown:function(e,t){"touch"!==t.pointerType&&this._setInterface(e,"mouse",!1)},onPointermove:function(e,t){"touch"!==t.pointerType&&this._hideCrossHair(e)},onPointerup:function(e){this.dispatchVertexChange(n(r(e)))}}}(l)),function(e){var t=e.ParentMode,r=e.geometryType,n=e.getFeature,o=e.getPlacedCoords;return{_simulateMouse:function(e,t,r){var n=this.map,o=n.getCenter(),i=n.project(o);t.call(this,r,{lngLat:o,point:i,originalEvent:new MouseEvent(e,{clientX:i.x,clientY:i.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render(),this.map.fire("draw.geometrychange",r.polygon||r.line)},_showCrossHair:function(e){e.crossHair?e.crossHair.show():e.vertexMarker.style.display="block"},_hideCrossHair:function(e){e.crossHair?e.crossHair.hide():e.vertexMarker.style.display="none"},_setInterface:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e.interfaceType=t,r&&this._showCrossHair(e)},toDisplayFeatures:function(e,i,a){t.toDisplayFeatures.call(this,e,i,a);var s=n(e);i.geometry.type===r&&i.properties.id===s.id&&o(i).forEach(function(e){return a({type:"Feature",properties:{meta:"draw-vertex",parent:s.id,active:"false"},geometry:{type:"Point",coordinates:e}})})}}}(l))},Oo=Eo(wt.modes.draw_polygon,{featureProp:"polygon",geometryType:"Polygon",getCoords:function(e){return e.coordinates[0]},validateClick:function(e){return(0,Wn.jK)(e.coordinates)},getPlacedCoords:function(e){return e.geometry.coordinates[0].slice(0,-2)}}),Io=Eo(wt.modes.draw_line_string,{featureProp:"line",geometryType:"LineString",getCoords:function(e){return e.coordinates},validateClick:function(e){return(0,Wn.DF)(e.coordinates)},excludeFeatureIdFromSetup:!0,finishOnInvalidClick:!0,getPlacedCoords:function(e){return e.geometry.coordinates.slice(0,-1)}});function Mo(e){return Mo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Mo(e)}function Co(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function To(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Co(Object(r),!0).forEach(function(t){Ao(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Co(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ao(e,t,r){return(t=function(e){var t=function(e){if("object"!=Mo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Mo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Mo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var jo="draw_point",ko=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Enter"]),Lo=wt.modes.draw_point,Fo=oo({ParentMode:Lo,featureProp:"point",excludeFeatureIdFromSetup:!1}),Vo={onKeyUp:function(){},_showCrossHair:function(e){e.crossHair?e.crossHair.show():e.vertexMarker.style.display="block"},_hideCrossHair:function(e){e.crossHair?e.crossHair.hide():e.vertexMarker.style.display="none"},_setInterface:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e.interfaceType=t,r&&this._showCrossHair(e)},onCreate:function(e,t){var r,n=t.features[0];this._ctx.api.delete(n.id),n.id=e.featureId,this._ctx.api.add(n,{userProperties:!0}),null===(r=e.resolvePointSymbol)||void 0===r||r.call(e,e.featureId,n.properties)},onUndo:function(){},onPointerup:function(){},onMove:function(e,t){var r="move"===(null==t?void 0:t.type)&&!t.originalEvent;(["touch","keyboard"].includes(e.interfaceType)||r)&&cr(e)&&ar(tr(this.map),this.map)},onBlur:function(e,t){t.target!==e.container&&this._hideCrossHair(e)},onPointerdown:function(e,t){"touch"!==t.pointerType&&this._setInterface(e,"mouse",!1)},onPointermove:function(e,t){"touch"!==t.pointerType&&this._hideCrossHair(e)},onTouchStart:function(e){this._setInterface(e,"touch"),this.onMove(e)},onTouchEnd:function(e){this._setInterface(e,"touch"),this.onMove(e)},onInterfaceTypeChange:function(e,t){this._setInterface(e,t.interfaceType,["touch","keyboard"].includes(t.interfaceType)),this.onMove(e)},onMouseMove:function(e,t){cr(e)&&or(tr(this.map),this.map,t.point)},onVertexButtonClick:function(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest("#".concat(e.addVertexButtonId))&&this._placeAtCrossHair(e)},onKeydown:function(e,t){document.activeElement===e.container&&("Escape"!==t.key?("Enter"===t.key&&(e.isActive=!0),ko.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e))):t.preventDefault())},onKeyup:function(e,t){"Escape"!==t.key?document.activeElement===e.container&&ko.has(t.key)&&(this._setInterface(e,"keyboard"),this.onMove(e),"Enter"===t.key&&e.isActive&&this._placeAtCrossHair(e)):this.map.fire("draw.cancel")},onClick:function(e,t){if(!(t.originalEvent.button>0||t.originalEvent.target!==this.map.getCanvas())){var r=tr(this.map),n=cr(e)&&rr(r)?nr(r):null;this._commit(e,n||t.lngLat)}},onTap:function(e,t){this.onClick(e,t)},_placeAtCrossHair:function(e){var t=tr(this.map);cr(e)&&ar(t,this.map);var r=cr(e)&&rr(t)?nr(t):null;this._commit(e,r||this.map.getCenter()),this._ctx.store.render()},_commit:function(e,t){var r,n,o,i,a;r=this.map,n={type:"Feature",geometry:{type:"Point",coordinates:[t.lng,t.lat]},properties:{}},i=(o=(0,Bn.oK)(n,{mode:jo,vertexIndex:0},{onGeometryChange:r._drawGeometryValidator})).valid,a=o.reason,i||r.fire("draw.placementblocked",{feature:n,reason:null!=a?a:null,phase:"place",mode:jo,vertexIndex:0}),i&&(e.point.updateCoordinate("",t.lng,t.lat),this.map.fire("draw.create",{features:[e.point.toGeoJSON()]}))}},Do=To(To(To({},Lo),Fo),Vo);function No(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Ro=function(e,t,r){return["coalesce",["get","user_".concat(t).concat(e.id.charAt(0).toUpperCase()+e.id.slice(1))],["get","user_".concat(t)],r]},Uo=["get","user_sortKey"],Bo=function(e,t){return{id:"fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","false"]],layout:{"fill-sort-key":Uo},paint:{"fill-color":Ro(e,"fill",t.shapeFill)}}},Go=function(e,t){return{id:"stroke-inactive",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","false"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round","line-sort-key":Uo},paint:{"line-color":Ro(e,"stroke",t.shapeStroke),"line-width":t.strokeWidth}}},Ho=function(e){return{id:"stroke-preview-line",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}},Yo=function(e,t){return{id:"vertex",type:"circle",filter:["all",["==","$type","Point"],["in","meta","vertex","draw-vertex"]],paint:{"circle-radius":t,"circle-color":e}}},$o=function(e,t,r){return{id:"vertex-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":r,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},Xo=function(e,t){return{id:"vertex-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":t,"circle-color":e}}},Ko=function(e,t){return{id:"midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":t,"circle-color":e}}},Jo=function(e,t,r){return{id:"midpoint-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":r,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},qo=function(e,t){return{id:"midpoint-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":t,"circle-color":e}}},zo=function(e){return{id:"circle",type:"line",filter:["==","id","circle"],paint:{"line-color":e,"line-width":2,"line-opacity":.8}}},Wo=function(e){var t,r,n,o,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=(0,Er.$)(e,a),u=zt.F0.vertexRadius,c=zt.F0.midpointRadius,l=zt.F0.vertexHaloRadius,d=zt.F0.midpointHaloRadius;return[Bo(e,s),(i=s.editFill,{id:"fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":i}}),(o=s.editStroke,{id:"stroke-active",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":o,"line-width":2,"line-opacity":1}}),(n=s.invalidStroke,{id:"stroke-active-invalid",type:"line",filter:["all",["any",["==","$type","Polygon"],["==","$type","LineString"]],["==","active","true"],["!has","user_splitter"]],layout:{"line-cap":"round","line-join":"round",visibility:"none"},paint:{"line-color":n,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}),Go(e,s),{id:"point-symbol",type:"symbol",filter:["all",["==","$type","Point"],["==","meta","feature"]],layout:{"icon-image":["case",["==",["get","active"],"true"],["coalesce",["get","user_symbolSelectedImageId"],["get","user_symbolImageId"]],["get","user_symbolImageId"]],"icon-anchor":["get","user_symbolIconAnchor"],"icon-offset":["literal",[0,0]],"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":Uo},paint:{}},(r=s.splitInvalid,{id:"stroke-invalid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","invalid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":r,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}),(t=s.splitValid,{id:"stroke-valid-splitter",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"],["==","user_splitter","valid"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":t,"line-width":2,"line-opacity":1}}),Ho(s.editStroke),Ko(s.editMidpoint,c),Jo(s.editHalo,s.editActive,d),qo(s.editMidpoint,c),Yo(s.editVertex,u),$o(s.editHalo,s.editActive,l),Xo(s.editVertex,u),zo(s.editStroke),{id:"touch-vertex-indicator",type:"circle",filter:["all",["==","$type","Point"],["==","meta","touch-vertex-indicator"]],paint:{"circle-radius":30,"circle-color":"#3bb2d0","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":.9}}]},Zo=6371008.8,Qo={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*Zo,kilometers:6371.0088,kilometres:6371.0088,meters:Zo,metres:Zo,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:Zo/1852,radians:1,yards:6967335.223679999};function ei(e,t,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}function ti(e,t,r){if(void 0===r&&(r={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!ai(e[0])||!ai(e[1]))throw new Error("coordinates must contain numbers");return ei({type:"Point",coordinates:e},t,r)}function ri(e,t,r){if(void 0===r&&(r={}),e.length<2)throw new Error("coordinates must be an array of two or more positions");return ei({type:"LineString",coordinates:e},t,r)}function ni(e,t){void 0===t&&(t={});var r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function oi(e){return e%(2*Math.PI)*180/Math.PI}function ii(e){return e%360*Math.PI/180}function ai(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function si(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ui(e){if(Array.isArray(e))return e;if("Feature"===e.type){if(null!==e.geometry)return e.geometry.coordinates}else if(e.coordinates)return e.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}const ci=function(e,t,r){void 0===r&&(r={});var n=si(e),o=si(t),i=ii(o[1]-n[1]),a=ii(o[0]-n[0]),s=ii(n[1]),u=ii(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(u);return function(e,t){void 0===t&&(t="kilometers");var r=Qo[t];if(!r)throw new Error(t+" units is invalid");return e*r}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)};function li(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return[...e.geometry.coordinates];if("Point"===e.type)return[...e.coordinates]}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return[...e];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function di(e,t,r,n={}){const o=li(e),i=(0,ke.tR)(o[0]),a=(0,ke.tR)(o[1]),s=(0,ke.tR)(r),u=(0,ke.Gf)(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s)),l=i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c)),d=(0,ke.nv)(l),f=(0,ke.nv)(c);return void 0!==o[2]?(0,ke.zx)([d,f,o[2]],n.properties):(0,ke.zx)([d,f],n.properties)}function fi(e,t,r){if(null!==e)for(var n,o,i,a,s,u,c,l,d=0,f=0,p=e.type,h="FeatureCollection"===p,y="Feature"===p,m=h?e.features.length:1,g=0;g<m;g++){s=(l=!!(c=h?e.features[g].geometry:y?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v<s;v++){var b=0,S=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var w=a.type;switch(d=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(u,f,g,b,S))return!1;f++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],f,g,b,S))return!1;f++,"MultiPoint"===w&&b++}"LineString"===w&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<u.length;n++){for(o=0;o<u[n].length-d;o++){if(!1===t(u[n][o],f,g,b,S))return!1;f++}"MultiLineString"===w&&b++,"Polygon"===w&&S++}"Polygon"===w&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(S=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-d;i++){if(!1===t(u[n][o][i],f,g,b,S))return!1;f++}S++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===fi(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function pi(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function hi(e,t){!function(e,t){var r,n,o,i,a,s,u,c,l,d,f=0,p="FeatureCollection"===e.type,h="Feature"===e.type,y=p?e.features.length:1;for(r=0;r<y;r++){for(s=p?e.features[r].geometry:h?e.geometry:e,c=p?e.features[r].properties:h?e.properties:{},l=p?e.features[r].bbox:h?e.bbox:void 0,d=p?e.features[r].id:h?e.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(i,f,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],f,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,f,c,l,d))return!1;f++}}(e,function(e,r,n,o,i){var a,s=null===e?null:e.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==t(ei(e,n,{bbox:o,id:i}),r,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var u=0;u<e.coordinates.length;u++){var c=e.coordinates[u];if(!1===t(ei({type:a,coordinates:c},n),r,u))return!1}})}function yi(e,t){var r,n,o;return void 0===t&&(t={}),n=("Feature"===(r=e).type?r.geometry:r).coordinates,o=t.properties?t.properties:"Feature"===e.type?e.properties:{},n.length>1?function(e,t,r){return void 0===r&&(r={}),ei({type:"MultiLineString",coordinates:e},t,r)}(n,o):ri(n[0],o)}var mi=function e(t,r,n={}){if(!0===n.final)return function(t,r){let n=e(r,t);return n=(n+180)%360,n}(t,r);const o=li(t),i=li(r),a=(0,ke.tR)(o[0]),s=(0,ke.tR)(i[0]),u=(0,ke.tR)(o[1]),c=(0,ke.tR)(i[1]),l=Math.sin(s-a)*Math.cos(c),d=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(s-a);return(0,ke.nv)(Math.atan2(l,d))};function gi(e,t,r,n){void 0===n&&(n={});var o=si(e),i=ii(o[0]),a=ii(o[1]),s=ii(r),u=function(e,t){void 0===t&&(t="kilometers");var r=Qo[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s));return ti([oi(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),oi(c)],n.properties)}const vi=function(e){if(!e)throw new Error("geojson is required");var t=[];return hi(e,function(e){!function(e,t){var r=[],n=e.geometry;if(null!==n){switch(n.type){case"Polygon":r=ui(n);break;case"LineString":r=[ui(n)]}r.forEach(function(r){var n=function(e,t){var r=[];return e.reduce(function(e,n){var o,i,a,s,u,c,l=ri([e,n],t);return l.bbox=(i=n,a=(o=e)[0],s=o[1],[a<(u=i[0])?a:u,s<(c=i[1])?s:c,a>u?a:u,s>c?s:c]),r.push(l),n}),r}(r,e.properties);n.forEach(function(e){e.id=t.length,t.push(e)})})}}(e,t)}),ni(t)};var bi=r(945);function Si(e,t){var r=ui(e),n=ui(t);if(2!==r.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==n.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var o=r[0][0],i=r[0][1],a=r[1][0],s=r[1][1],u=n[0][0],c=n[0][1],l=n[1][0],d=n[1][1],f=(d-c)*(a-o)-(l-u)*(s-i);if(0===f)return null;var p=((l-u)*(i-c)-(d-c)*(o-u))/f,h=((a-o)*(i-c)-(s-i)*(o-u))/f;return p>=0&&p<=1&&h>=0&&h<=1?ti([o+p*(a-o),i+p*(s-i)]):null}const wi=function(e,t){var r={},n=[];if("LineString"===e.type&&(e=ei(e)),"LineString"===t.type&&(t=ei(t)),"Feature"===e.type&&"Feature"===t.type&&null!==e.geometry&&null!==t.geometry&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var o=Si(e,t);return o&&n.push(o),ni(n)}var i=bi();return i.load(vi(t)),pi(vi(e),function(e){pi(i.search(e),function(t){var o=Si(e,t);if(o){var i=ui(o).join(",");r[i]||(r[i]=!0,n.push(o))}})}),ni(n)},xi=function(e,t,r){void 0===r&&(r={});var n=ti([1/0,1/0],{dist:1/0}),o=0;return hi(e,function(e){for(var i=ui(e),a=0;a<i.length-1;a++){var s=ti(i[a]);s.properties.dist=ci(t,s,r);var u=ti(i[a+1]);u.properties.dist=ci(t,u,r);var c=ci(s,u,r),l=Math.max(s.properties.dist,u.properties.dist),d=mi(s,u),f=gi(t,l,d+90,r),p=gi(t,l,d-90,r),h=wi(ri([f.geometry.coordinates,p.geometry.coordinates]),ri([s.geometry.coordinates,u.geometry.coordinates])),y=null;h.features.length>0&&((y=h.features[0]).properties.dist=ci(t,y,r),y.properties.location=o+ci(s,y,r)),s.properties.dist<n.properties.dist&&((n=s).properties.index=a,n.properties.location=o),u.properties.dist<n.properties.dist&&((n=u).properties.index=a+1,n.properties.location=o+c),y&&y.properties.dist<n.properties.dist&&((n=y).properties.index=a),o+=c}}),n};var Pi=6371008.8,_i={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:Pi,metres:Pi,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function Ei(e){return e%(2*Math.PI)*180/Math.PI}function Oi(e){return e%360*Math.PI/180}function Ii(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function Mi(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}const Ci=function(e,t,r){void 0===r&&(r={});var n=Mi(e),o=Mi(t),i=Oi(o[1]-n[1]),a=Oi(o[0]-n[0]),s=Oi(n[1]),u=Oi(o[1]),c=Math.pow(Math.sin(i/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(s)*Math.cos(u);return function(e,t){void 0===t&&(t="kilometers");var r=_i[t];if(!r)throw new Error(t+" units is invalid");return e*r}(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),r.units)},Ti=function(e,t){var r=function(e,t,r,n){void 0===n&&(n={});var o=Mi(e),i=Oi(o[0]),a=Oi(o[1]),s=Oi(r),u=function(e,t){void 0===t&&(t="kilometers");var r=_i[t];if(!r)throw new Error(t+" units is invalid");return e/r}(t,n.units),c=Math.asin(Math.sin(a)*Math.cos(u)+Math.cos(a)*Math.sin(u)*Math.cos(s));return function(e,t,r){if(void 0===r&&(r={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ii(e[0])||!Ii(e[1]))throw new Error("coordinates must contain numbers");return function(e,t,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=t||{},n.geometry=e,n}({type:"Point",coordinates:e},t,r)}([Ei(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),Ei(c)],n.properties)}(e,Ci(e,t)/2,mi(e,t));return r};var Ai=function(){return Ai=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},Ai.apply(this,arguments)},ji=function(){function e(e){var t;this.status=null!==(t=e.status)&&void 0!==t&&t,this.map=e.map,this.drawing=e.drawing,this.options=e.options,this.onSnapped=function(t){void 0!==e.onSnapped&&e.onSnapped(t)},this.features={},this.snapStatus=!1,this.snapCoords=[],this.radiusInMeters=0,this.addRadiusCircleLayer(),this.addEvents()}return e.prototype.changeSnappedPoints=function(){for(var e=this.drawing.getAll(),t=[],r=0;r<e.features.length;r++){var n=e.features[r],o=n.id;if(this.features[o]){var i=this.features[o].snapPoints;if(void 0!==this.features.unknow){var a=this.features.unknow.snapPoints;i=Ai(Ai({},i),a)}var s=this.doSnap(n,i);t.push(s)}else void 0!==this.features.unknow?(a=this.features.unknow.snapPoints,s=this.doSnap(n,a),t.push(s)):t.push(n)}var u={type:"FeatureCollection",features:t};this.drawing.set(u),this.onSnapped&&this.onSnapped(u)},e.prototype.isPointSnapped=function(e,t){return ci(ti(e),ti(t),{units:"meters"})<this.radiusInMeters},e.prototype.doSnap=function(e,t){switch(e.geometry.type){case"Point":var r=e.geometry.coordinates;for(var n in t)this.isPointSnapped(r,t[n])&&(e.geometry.coordinates=t[n]);break;case"Polygon":for(var o=e.geometry.coordinates,i=[],a=0;a<o.length;a++){for(var s=o[a],u=[],c=0;c<s.length;c++){var l=s[c],d=!1;for(var n in t)if(this.isPointSnapped(l,t[n])){d=!0,u.push(t[n]);break}0==d&&u.push(l)}i.push(u)}e.geometry.coordinates=i;break;case"LineString":var f=e.geometry.coordinates;for(u=[],c=0;c<f.length;c++){var p=f[c];for(var n in d=!1,t)if(this.isPointSnapped(p,t[n])){d=!0,u.push(t[n]);break}0==d&&u.push(p)}e.geometry.coordinates=u}return e},e.prototype.getMe=function(){return this},e.prototype.setStatus=function(e){this.status=e},e.prototype.setMapData=function(e){var t=this.map.getSource("snap-helper-circle");t&&t.setData(e)},e.prototype.snapToClosestPoint=function(e){if(this.status){var t=e.point,r=this.map.unproject(t),n=[t.x+this.options.radius,t.y],o=this.map.unproject(n),i=ci(ti([r.lng,r.lat]),ti([o.lng,o.lat]),{units:"meters"});this.radiusInMeters=i;var a=!1,s=this.getCloseFeatures(e,i);s?(this.snapStatus=!0,this.snapCoords=s.coords,a=function(e,t,r={}){const n=r.steps||64,o=r.properties?r.properties:!Array.isArray(e)&&"Feature"===e.type&&e.properties?e.properties:{},i=[];for(let o=0;o<n;o++)i.push(di(e,t,-360*o/n,r).geometry.coordinates);return i.push(i[0]),(0,ke.n1)([i],o)}(s.coords,i,{steps:64,units:"meters",properties:{color:s.color}})):(this.snapStatus=!1,this.snapCoords=[]);var u=ni(0==a?[]:[a]);this.setMapData(u)}},e.prototype.addEvents=function(){var e=this;this.map.on("mousemove",function(t){e.snapToClosestPoint(t)}),this.map.on("draw.delete",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.update",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.create",function(t){setTimeout(function(){e.changeSnappedPoints()},100)}),this.map.on("draw.selectionchange",function(t){t.features.length>0?e.status=!0:(e.status=!1,e.setMapData(ni([])))}),this.map.on("draw.modechange",function(t){e.status=!0,"simple_select"==t.mode&&(e.status=!1)}),this.map.on("draw.render",function(t){var r=e.map.getSource("mapbox-gl-draw-hot");if(r){var n=r._data;if(e.snapStatus){var o=[e.snapCoords[0],e.snapCoords[1]];n.features.length>0&&(n.features[0].geometry.coordinates=o)}}}),this.map.on("mouseup",function(){e.drawingSnapCheck()}),this.map.on("click",function(){e.drawingSnapCheck()})},e.prototype.drawingSnapCheck=function(){if(this.snapStatus){var e=this.map.getSource("mapbox-gl-draw-hot"),t=[this.snapCoords[0],this.snapCoords[1]],r=t[0].toFixed(6),n=t[1].toFixed(6),o={};if(o["".concat(r,"_").concat(n)]=t,e){var i=e._data;if(i.features.length>0){var a=i.features.find(function(e){return"feature"==e.properties.meta});if(a){var s=a.properties.id;this.features[s]?this.features[s].snapPoints["".concat(r,"_").concat(n)]=t:this.features[s]={id:s,snapPoints:o}}}else this.features.unknow?this.features.unknow.snapPoints["".concat(r,"_").concat(n)]=t:this.features.unknow={id:s,snapPoints:o}}}},e.prototype.searchInVertex=function(e,t,r){var n,o=(n=[],fi(e,function(e){n.push(e)}),n),i=[];if(o.map(function(e){var n=ci(ti(e),ti([t.lng,t.lat]),{units:"meters"});n<r&&i.push({coords:e,dist:n,color:"#8bc34a"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.getLines=function(e,t,r){var n=[];switch(e.geometry.type){case"LineString":n.push(e);break;case"MultiLineString":e.geometry.coodinates.map(function(e){n.push(ri(e))});break;case"Polygon":var o=yi(e.geometry);n.push(o);break;case"MultiPolygon":yi(e.geometry).coodinates.map(function(e){n.push(ri(e))})}return n},e.prototype.searchInMidPoint=function(e,t,r){var n=this.getLines(e,t,r),o=[];n.map(function(e){o=o.concat(vi(e).features)});var i=[];if(o.map(function(e){var n=Ti(e.geometry.coordinates[0],e.geometry.coordinates[1]),o=ci(n,ti([t.lng,t.lat]),{units:"meters"});o<r&&i.push({coords:n.geometry.coordinates,dist:o,color:"#03a9f4"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.searchInEdge=function(e,t,r){for(var n=this.getLines(e,t,r),o=[],i=0;i<n.length;i++){var a=xi(n[i],ti([t.lng,t.lat]),{units:"meters"});void 0!==a.properties.dist&&a.properties.dist<r&&o.push({coords:a.geometry.coordinates,dist:a.properties.dist,color:"#ff9800"})}if(o.length>0)return o.sort(function(e,t){return e.dist-t.dist}),o[0]},e.prototype.getCloseFeatures=function(e,t){var r=this.map.queryRenderedFeatures(e.point,{layers:this.options.layers});if(r.length>0){for(var n,o=!1,i=0;i<r.length;i++){var a=r[i],s=this.options.rules,u=e.lngLat;if(o=!1,-1!==s.indexOf("vertex")&&null==n&&(n=this.searchInVertex(a,u,t))){o=!0;break}if(-1!==s.indexOf("midpoint")&&null==n&&(n=this.searchInMidPoint(a,u,t))){o=!0;break}if(-1!==s.indexOf("edge")&&null==n&&(n=this.searchInEdge(a,u,t))){o=!0;break}}return!!o&&n}return!1},e.prototype.addRadiusCircleLayer=function(){this.map.addSource("snap-helper-circle",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"snap-helper-circle",type:"fill",source:"snap-helper-circle",paint:{"fill-color":["get","color"],"fill-opacity":.6}})},e}();const ki=ji;var Li="snap-helper-circle",Fi="mapbox-gl-draw-hot";function Vi(e){return Vi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Vi(e)}function Di(e,t){!function r(){var n=e();null!==n&&(n?t(n):requestAnimationFrame(r))}()}function Ni(e){var t;if(!(!e||e._data&&Array.isArray(null===(t=e._data)||void 0===t?void 0:t.features))){var r={type:"FeatureCollection",features:[]};Object.defineProperty(e,"_data",{get:function(){return r},set:function(e){r=e&&"object"===Vi(e)&&Array.isArray(e.features)?e:{type:"FeatureCollection",features:[]}},configurable:!0})}}var Ri=new Set(["draw_polygon","draw_line","draw_point","edit_vertex","edit_point"]);function Ui(e,t,r,n){if(e._snapInstance||e._snapCreating)return e._snapInstance;e._snapCreating=!0,function(e){e.getLayer(Li)&&e.removeLayer(Li),e.getSource(Li)&&e.removeSource(Li)}(e),Ni(r);var o=new ki({map:e,drawing:t,options:{layers:n.layers,radius:n.radius,rules:n.rules},status:n.status,onSnapped:n.onSnapped});return function(e,t,r){var n=t;Object.defineProperty(e,"status",{get:function(){return n&&Ri.has(r.getMode())},set:function(){},configurable:!0}),e.setSnapStatus=function(e){n=e}}(o,n.status,t),function(e,t){e._defaultLayers=t,e._activeLayers=null,e.setSnapLayers=function(t){null==t?e._activeLayers=null:Array.isArray(t)&&(e._activeLayers=t)}}(o,n.layers),void 0!==e._pendingSnapLayers&&(o.setSnapLayers(e._pendingSnapLayers),delete e._pendingSnapLayers),e._snapInstance=o,o}function Bi(e){return Bi="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Bi(e)}function Gi(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Hi(e,t,r){return(t=function(e){var t=function(e){if("object"!=Bi(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Bi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Bi(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Yi(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e._snapInitialized)return e._snapInstance;e._snapInitialized=!0;var n=r.layers,o=void 0===n?[]:n,i=r.radius,a=void 0===i?zt.vf.snapRadius:i,s=r.rules,u=void 0===s?["vertex","midpoint","edge"]:s,c=r.status,l=void 0!==c&&c,d=r.onSnapped,f=void 0===d?function(){}:d,p=r.colors,h=void 0===p?{}:p,y={layers:o,radius:a,rules:u,status:l,onSnapped:f};return function(e){if(!ki.prototype.__snapPatched){ki.prototype.__snapPatched=!0;var t=ki.prototype,r={setMapData:t.setMapData,drawingSnapCheck:t.drawingSnapCheck,getLines:t.getLines,getCloseFeatures:t.getCloseFeatures,searchInVertex:t.searchInVertex,searchInMidPoint:t.searchInMidPoint,searchInEdge:t.searchInEdge,snapToClosestPoint:t.snapToClosestPoint};t.changeSnappedPoints=function(){},function(e,t){e.setMapData=function(e){var r,n;if(this.status){var o=t.setMapData.call(this,e);return(null==e||null===(r=e.features)||void 0===r?void 0:r.length)>0&&null!==(n=this.map)&&void 0!==n&&n.getLayer(Li)&&this.map.setLayoutProperty(Li,"visibility","visible"),o}},e.drawingSnapCheck=function(){if(this.status)return t.drawingSnapCheck.call(this)}}(t,r),function(e,t){e.getLines=function(e,r,n){var o=e.geometry;if(null==o||!o.coordinates)return[];var i=o.coordinates;if(!Array.isArray(i)||0===i.length)return[];try{return"MultiPolygon"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return(0,ke.n1)(e)}):"MultiLineString"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return(0,ke.wi)(e)}):t.getLines.call(this,e,r,n)}catch(e){return[]}},e.getCloseFeatures=function(e,r){var n=this;if(!this.status)return[];var o=this._activeLayers||this._defaultLayers||[];this.options.layers=o.filter(function(e){return n.map.getLayer(e)});var i=this.options.radius||zt.vf.snapRadius,a=e.point;e.point=[[a.x-i,a.y-i],[a.x+i,a.y+i]];var s=t.getCloseFeatures.call(this,e,r);return e.point=a,s}}(t,r),function(e,t,r){e.searchInVertex=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var i=t.searchInVertex.apply(this,n);return i&&(i.color=r.vertex),i},e.searchInMidPoint=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var i=t.searchInMidPoint.apply(this,n);return i&&(i.color=r.midpoint),i},e.searchInEdge=function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];var i=t.searchInEdge.apply(this,n);return i&&(i.color=r.edge),i}}(t,r,e),function(e,t){e.snapToClosestPoint=function(e){var r;if(this.status&&(null===(r=this.map)||void 0===r||!r._isZooming)&&(!this._autoSnapSuspended||e._explicit))try{var n,o,i=t.snapToClosestPoint.call(this,e);return(null===(n=this.closeFeatures)||void 0===n?void 0:n.length)>100&&(this.closeFeatures.length=0),(null===(o=this.lines)||void 0===o?void 0:o.length)>100&&(this.lines.length=0),i}catch(e){return this.snapStatus=!1,void(this.snapCoords=null)}}}(t,r)}}(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Gi(Object(r),!0).forEach(function(t){Hi(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Gi(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({vertex:zt.lm.snapVertex,midpoint:zt.lm.snapMidpoint,edge:zt.lm.snapEdge},h)),function(e,t,r){e.on("style.load",function(){Di(function(){return e._removed?null:e.getSource(Fi)},function(n){Ni(n),function(e){var t;e.getSource(Li)||e.addSource(Li,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(Li)||e.addLayer({id:Li,type:"fill",source:Li,paint:{"fill-color":["get","color"]},layout:{visibility:null!==(t=e._snapInstance)&&void 0!==t&&t.status?"visible":"none"}})}(e),e._snapInstance||Ui(e,t,n,r)})})}(e,t,y),function(e){e.on("zoomstart",function(){e._isZooming=!0}),e.on("zoomend",function(){if(e._isZooming=!1,e.getLayer(Li)){e.setLayoutProperty(Li,"visibility","none");var t=e._snapInstance;null!=t&&t.status&&e.setLayoutProperty(Li,"visibility","visible")}})}(e),Di(function(){return e._removed?null:e.getSource(Fi)},function(r){return Ui(e,t,r,y)}),e._snapInstance}var $i=r(610),Xi=r(600),Ki=r(121);function Ji(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return qi(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?qi(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function qi(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var zi=.25,Wi=.75,Zi=function(e){var t=Ji(e,2),r=t[0],n=t[1],o=function(e){return e<=zi?"left":e>=Wi?"right":""}(r),i=function(e){return e<=zi?"top":e>=Wi?"bottom":""}(n);return i+(o&&i?"-":"")+o||"center"},Qi=function(e){return e<=zi?0:e>=Wi?1:.5},ea=function(e){return Math.round(100*e)/100},ta=function(e,t){var r=Ji(e,2),n=r[0],o=r[1],i=Ji(t.split(" ").map(Number),4),a=i[2],s=i[3];return[ea((Qi(n)-n)*a),ea((Qi(o)-o)*s)]};function ra(e){return ra="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ra(e)}function na(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return oa(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return i=t,s=0,u=e,f.n=r,a}};function p(r,n){for(s=r,u=n,t=0;!d&&c&&!o&&t<l.length;t++){var o,i=l[t],p=f.p,h=i[2];r>3?(o=h===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=r<2&&p<i[1])?(s=0,f.v=n,f.n=i[1]):p<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,f.n=h,s=0))}if(o||r>1)return a;throw d=!0,n}return function(o,l,h){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,h),s=l,u=h;(t=s<2?e:u)||!d;){i||(s?s<3?(s>1&&(f.n=-1),p(s,u)):f.n=u:f.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?u:r.call(n,f))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(oa(t={},n,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,oa(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,oa(d,"constructor",c),oa(c,"constructor",u),u.displayName="GeneratorFunction",oa(c,o,"GeneratorFunction"),oa(d),oa(d,o,"Generator"),oa(d,n,function(){return this}),oa(d,"toString",function(){return"[object Generator]"}),(na=function(){return{w:i,m:f}})()}function oa(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}oa=function(e,t,r,n){function i(t,r){oa(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},oa(e,t,r,n)}function ia(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function aa(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ia(Object(r),!0).forEach(function(t){sa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ia(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function sa(e,t,r){return(t=function(e){var t=function(e){if("object"!=ra(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ra(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ra(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ua(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function ca(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){ua(i,n,o,a,s,"next",e)}function s(e){ua(i,n,o,a,s,"throw",e)}a(void 0)})}}function la(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return da(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?da(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function da(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var fa=function(e){return!!(null!=e&&e.symbol||null!=e&&e.symbolSvgContent)},pa=function(e,t,r){var n;if(null!==(n=e._symbolIconOffsetMap)&&void 0!==n||(e._symbolIconOffsetMap={}),!e._symbolIconOffsetMap[t]){e._symbolIconOffsetMap[t]=r;var o=function(e){for(var t=["match",["get","user_symbolImageId"]],r=0,n=Object.entries(e);r<n.length;r++){var o=la(n[r],2),i=o[0],a=o[1];t.push(i,["literal",a])}return t.push(["literal",[0,0]]),t}(e._symbolIconOffsetMap);["hot","cold"].forEach(function(t){var r="".concat("point-symbol",".").concat(t);e.getLayer(r)&&e.setLayoutProperty(r,"icon-offset",o)})}},ha=function(e){var t;return(null===(t=e.getPixelRatio)||void 0===t?void 0:t.call(e))||1},ya=function(){var e=ca(na().m(function e(t){var r,n,o,i,a,s,u,c,l,d,f,p,h,y,m,g,v,b,S,w;return na().w(function(e){for(;;)switch(e.n){case 0:if(a=t.draw,s=t.mapProvider,u=t.map,c=t.featureId,l=t.properties,d=t.pixelRatioOverride,fa(l)){e.n=1;break}return e.a(2,null);case 1:return f=u._drawCurrentMapStyle,p=null!=d?d:ha(u),e.n=2,s.addSymbolsToMap([l],f,Xi.a);case 2:if(h=a.get(c)){e.n=3;break}return e.a(2,null);case 3:if(y=Xi.a.getSymbolImageId(l,f,!1,p)){e.n=4;break}return e.a(2,null);case 4:return m=null!==(r=null===(n=u._activeSymbolImageMap)||void 0===n?void 0:n[y])&&void 0!==r?r:null,g=null!==(o=null===(i=u._selectedSymbolImageMap)||void 0===i?void 0:i[y])&&void 0!==o?o:null,v=Xi.a.getSymbolDef(l),b=(0,Ki.Op)(l,v),S=Zi(b),w=ta(b,(0,Ki.n8)(l,v)),pa(u,y,w),e.a(2,aa(aa({},h),{},{properties:aa(aa({},l),{},{symbolImageId:y,symbolIconAnchor:S,symbolActiveImageId:m,symbolSelectedImageId:g})}))}},e)}));return function(t){return e.apply(this,arguments)}}(),ma=function(){var e=ca(na().m(function e(t){var r,n;return na().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,ya(t);case 1:if(r=e.v){e.n=2;break}return e.a(2);case 2:t.draw.add(r),e.n=4;break;case 3:e.p=3,n=e.v,console.error("[draw] failed to resolve point symbol",t.featureId,n);case 4:return e.a(2)}},e,null,[[0,3]])}));return function(t){return e.apply(this,arguments)}}(),ga=function(){var e=ca(na().m(function e(t){var r,n,o,i,a,s,u;return na().w(function(e){for(;;)switch(e.n){case 0:return r=t.draw,n=t.mapProvider,o=t.map,i=t.pixelRatioOverride,a=r.getAll().features.filter(function(e){return"Point"===e.geometry.type&&fa(e.properties)}),e.n=1,Promise.allSettled(a.map(function(e){return ya({draw:r,mapProvider:n,map:o,featureId:e.id,properties:e.properties,pixelRatioOverride:i})}));case 1:(s=e.v).filter(function(e){return"rejected"===e.status}).forEach(function(e){console.error("[draw] failed to resolve point symbol",e.reason)}),(u=s.filter(function(e){return"fulfilled"===e.status&&e.value}).map(function(e){return e.value})).length&&r.add({type:"FeatureCollection",features:u});case 2:return e.a(2)}},e)}));return function(t){return e.apply(this,arguments)}}();function va(e){return va="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},va(e)}function ba(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Sa(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ba(Object(r),!0).forEach(function(t){wa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ba(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function wa(e,t,r){return(t=function(e){var t=function(e){if("object"!=va(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=va(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==va(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var xa="mapbox-gl-draw-cold",Pa=function(e){var t=e.map,r=e.draw,n=e.mapProvider,o=e.pluginConfig,i=e.onDone,a=t._drawCurrentMapStyle;t.once("idle",function(){var e,s=function(e,t){if(e.getSource(xa))return!1;var r={type:"FeatureCollection",features:[]};return e.addSource(xa,{data:r,type:"geojson"}),e.addSource("mapbox-gl-draw-hot",{data:r,type:"geojson"}),t.options.styles.forEach(function(t){return e.addLayer(t)}),!0}(t,r);!function(e,t){Wo(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).forEach(function(t){Object.entries(t.paint).forEach(function(r){var n,o,i=(o=2,function(e){if(Array.isArray(e))return e}(n=r)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(n,o)||function(e,t){if(e){if("string"==typeof e)return No(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?No(e,t):void 0}}(n,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=i[0],s=i[1];e.getLayer("".concat(t.id,".cold"))&&e.setPaintProperty("".concat(t.id,".cold"),a,s),e.getLayer("".concat(t.id,".hot"))&&e.setPaintProperty("".concat(t.id,".hot"),a,s)})})}(t,a,o);var u=null===(e=t._drawEditContainer)||void 0===e?void 0:e.querySelector("[data-im-draw-touch-target]");Lr(u,a,o),ga({draw:r,mapProvider:n,map:t}).then(function(){s&&r.set(r.getAll()),t.triggerRepaint(),i()})})},_a=r(360),Ea=r(788),Oa=r(715);function Ia(e){return Ia="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ia(e)}function Ma(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,ja(n.key),n)}}function Ca(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ta(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ca(Object(r),!0).forEach(function(t){Aa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ca(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Aa(e,t,r){return(t=ja(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ja(e){var t=function(e){if("object"!=Ia(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Ia(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ia(t)?t:t+""}var ka=function(e){return{type:"Feature",geometry:{type:"Polygon",coordinates:e}}},La=function(e){return{type:"Feature",geometry:{type:"LineString",coordinates:e}}},Fa=function(e){return{type:"Feature",geometry:{type:"Point",coordinates:e}}},Va=function(e,t){var r,n,o;if("draw_polygon"===e)return{feature:ka(t),numVertices:(null!==(r=null===(n=t[0])||void 0===n?void 0:n.length)&&void 0!==r?r:1)-1};if("draw_line"===e)return{feature:La(t),numVertices:(null!==(o=null==t?void 0:t.length)&&void 0!==o?o:1)-1};if("edit_vertex"===e){var i,a=t[0];return Array.isArray(null==a?void 0:a[0])?{feature:ka(t),numVertices:a.length}:{feature:La(t),numVertices:null!==(i=null==t?void 0:t.length)&&void 0!==i?i:0}}return"edit_point"===e?{feature:Fa(t),numVertices:1}:null},Da=function(){return e=function e(t,r){var n,o,i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._mapProvider=t,this._map=t.map,this._bus=(o=new Map,{on:function(e,t){o.has(e)||o.set(e,new Set),o.get(e).add(t)},off:function(e,t){var r;null===(r=o.get(e))||void 0===r||r.delete(t)},emit:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=o.get(e);i&&Array.from(i).forEach(function(e){return e.apply(void 0,r)})}}),this._editingFeatureId=null,this._sortKeyCounter=0;var a=function(e){var t,r=e.mapStyle,n=e.mapProvider,o=e.events,i=e.eventBus,a=e.snapLayers,s=e.pluginConfig,u=void 0===s?{}:s,c=n.map;wt.constants.classes.CONTROL_BASE="maplibregl-ctrl",wt.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",wt.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var l=Sa(Sa({},wt.modes),{},{disabled:xt,edit_vertex:bn,edit_point:zn,draw_polygon:Oo,draw_line:Io,draw_point:Do}),d=n._mapboxDrawInstance;d?Object.assign(d.modes,l):(d=new wt({modes:l,styles:Wo(r,u),displayControlsDefault:!1,userProperties:!0,defaultMode:"disabled"}),c.addControl(d),n._mapboxDrawInstance=d);var f=function(e,t){var r=e.getCanvas(),n=null,o=function(e){1===e.touches.length&&(n={x:e.touches[0].clientX,y:e.touches[0].clientY,time:Date.now()})},i=function(e){if("disabled"===t.getMode()&&n){var o=e.changedTouches[0],i=o.clientX-n.x,a=o.clientY-n.y;Date.now()-n.time<300&&Math.abs(i)<10&&Math.abs(a)<10&&r.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,clientX:o.clientX,clientY:o.clientY})),n=null}else n=null};return r.addEventListener("touchstart",o,{passive:!0}),r.addEventListener("touchend",i,{passive:!0}),{remove:function(){r.removeEventListener("touchstart",o),r.removeEventListener("touchend",i)}}}(c,d);n.draw=d,c._drawCurrentMapStyle=r,c._drawPluginConfig=u,n.snapEnabled=!1;var p=n.undoStack;p||(p=(0,$i.B)(function(e){return c.fire("draw.undochange",{length:e})}),n.undoStack=p),c._undoStack=p;var h=(0,Er.$)(r,u);Yi(c,d,{layers:a,radius:null!==(t=u.snapRadius)&&void 0!==t?t:zt.vf.snapRadius,rules:["vertex","edge"],colors:{vertex:h.snapVertex,edge:h.snapEdge}});var y=function(){return i.emit(o.MAP_DATA_CHANGE)},m=function(e){var t=e.map,r=e.draw,n=e.mapProvider,o=e.pluginConfig,i=e.eventBus,a=e.events,s=e.notifyPointSymbolsRefreshed,u=function(e){t._drawCurrentMapStyle=e};i.on(a.MAP_SET_STYLE,u);var c=!1,l=function(){c||(c=!0,Pa({map:t,draw:r,mapProvider:n,pluginConfig:o,onDone:function(){c=!1,s()}}))};return i.on(a.MAP_STYLE_CHANGE,l),{handleSetMapStyle:u,handleStyleChanged:l}}({map:c,draw:d,mapProvider:n,pluginConfig:u,eventBus:i,events:o,notifyPointSymbolsRefreshed:y}),g=m.handleSetMapStyle,v=m.handleStyleChanged,b=function(e){c.fire("draw.scalechange",{scale:zt.$y[e]})};i.on(o.MAP_SET_SIZE,b);var S=function(e){ga({draw:d,mapProvider:n,map:c,pixelRatioOverride:e}).then(function(){c.triggerRepaint(),y()})};return i.on(o.MAP_SET_PIXEL_RATIO,S),{draw:d,remove:function(){f.remove(),i.off(o.MAP_SET_STYLE,g),i.off(o.MAP_STYLE_CHANGE,v),i.off(o.MAP_SET_SIZE,b),i.off(o.MAP_SET_PIXEL_RATIO,S),d.changeMode("disabled"),n.draw=null}}}({mapStyle:r.mapStyle,mapProvider:t,events:r.events,eventBus:r.eventBus,snapLayers:r.snapLayers,pluginConfig:null!==(n=r.pluginConfig)&&void 0!==n?n:{}}),s=a.draw,u=a.remove;this._draw=s,this._cleanupDraw=u,this._liveStroke=(0,Ea.De)({onChange:function(e,t){i._applyStrokeInvalid(e);var r=i._draw.getMode();"edit_vertex"!==r&&"edit_point"!==r||i._bus.emit(_a.k.VALIDITY_CHANGE,{valid:!e,reason:t})}}),this._liveDrawChecks=(0,Oa.O)({onStrokeChange:function(e,t){return i._liveStroke.set(e,t)},onPlaceChange:function(e,t){return i._bus.emit(_a.k.CAN_PLACE_CHANGE,{canPlace:!e,reason:t})}}),this._mapHandlers={create:function(e){var t=e.features[0];setTimeout(function(){i._draw.setFeatureProperty(t.id,"sortKey",i._nextSortKey()),i._bus.emit(_a.k.CREATE,i._draw.get(t.id))},0)},editfinish:function(e){return i._bus.emit(_a.k.EDIT_FINISH,e.features[0])},cancel:function(){return i._bus.emit(_a.k.CANCEL)},vertexselection:function(e){return i._bus.emit(_a.k.VERTEX_SELECTION,e)},vertexchange:function(e){return i._bus.emit(_a.k.VERTEX_CHANGE,e)},undochange:function(e){return i._bus.emit(_a.k.UNDO_CHANGE,e.length)},update:function(e){return i._bus.emit(_a.k.UPDATE,e.features[0])},geometrychange:function(e){null!=e&&e.phase||(i._updateLiveStroke(e),i._currentDrawEvent=e),i._bus.emit(_a.k.GEOMETRY_CHANGE,e)},placementblocked:function(e){return i._bus.emit(_a.k.PLACEMENT_BLOCKED,e)},interfacetypechange:function(e){return i._bus.emit(_a.k.INTERFACE_TYPE_CHANGE,{interfaceType:e.interfaceType})},modechange:function(e){return i._handleModeChange(e)},styledata:function(){return i._handleStyleData()}},this._map.on(Pt,this._mapHandlers.create),this._map.on(Ot,this._mapHandlers.editfinish),this._map.on(It,this._mapHandlers.cancel),this._map.on(Mt,this._mapHandlers.vertexselection),this._map.on(Ct,this._mapHandlers.vertexchange),this._map.on(Tt,this._mapHandlers.undochange),this._map.on(_t,this._mapHandlers.update),this._map.on(At,this._mapHandlers.geometrychange),this._map.on(kt,this._mapHandlers.placementblocked),this._map.on(jt,this._mapHandlers.interfacetypechange),this._map.on(Et,this._mapHandlers.modechange),this._map.on(Dt,this._mapHandlers.styledata)},t=[{key:"changeMode",value:function(e){var t,r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"edit_vertex"!==e&&"edit_point"!==e||(this._editingFeatureId=null!==(t=n.featureId)&&void 0!==t?t:null),"draw_polygon"!==e&&"draw_line"!==e||(this._liveStroke.set(!1),this._liveDrawChecks.reset()),"draw_point"===e&&(n=Ta(Ta({},n),{},{resolvePointSymbol:function(e,t){return r._resolvePointSymbol(e,t)}})),this._draw.changeMode(e,n),this._handleModeChange({mode:e})}},{key:"_resolvePointSymbol",value:function(e,t){return ma({draw:this._draw,mapProvider:this._mapProvider,map:this._map,featureId:e,properties:t})}},{key:"_updateLiveStroke",value:function(e){if(null!=e&&e.coordinates){var t=this._draw.getMode(),r=Va(t,e.coordinates);r&&("draw_polygon"===t||"draw_line"===t?this._liveDrawChecks.update({feature:r.feature,numVertices:r.numVertices,context:{mode:t},onGeometryChange:this._geometryValidator}):this._liveStroke.update(Ta(Ta({},r),{},{context:{mode:t},onGeometryChange:this._geometryValidator})))}}},{key:"getMode",value:function(){return this._draw.getMode()}},{key:"setInterfaceType",value:function(e){this._map.fire(jt,{interfaceType:e})}},{key:"done",value:function(){var e;null===(e=this._mapProvider.undoStack)||void 0===e||e.clear();var t=this._draw.getMode();if(("edit_vertex"===t||"edit_point"===t)&&this._editingFeatureId)return this._handleModeChange({mode:"disabled"}),void this._map.fire(Ot,{features:[this._draw.get(this._editingFeatureId)]});"draw_polygon"!==t&&"draw_line"!==t||(this._draw.changeMode("disabled"),this._handleModeChange({mode:"disabled"}))}},{key:"cancel",value:function(){var e;null===(e=this._mapProvider.undoStack)||void 0===e||e.clear();var t=this._draw.getMode();"draw_polygon"!==t&&"draw_line"!==t||this._draw.trash(),this._draw.changeMode("disabled"),this._handleModeChange({mode:"disabled"})}},{key:"undo",value:function(){this._map.fire("draw.undo")}},{key:"nudgeSelectedVertex",value:function(e,t,r){this._map.fire(Lt,{dx:e,dy:t,isLargeStep:r})}},{key:"getVertexItems",value:function(){var e={vertices:[],midpoints:[]};if("edit_vertex"!==this._draw.getMode()||!this._editingFeatureId)return e;var t=this._draw.get(this._editingFeatureId);if(!t)return e;var r=function(e){return"Polygon"===e.type?Ta(Ta({},e),{},{coordinates:e.coordinates.map(function(e){return e.slice(0,-1)})}):"MultiPolygon"===e.type?Ta(Ta({},e),{},{coordinates:e.coordinates.map(function(e){return e.map(function(e){return e.slice(0,-1)})})}):e}(t.geometry);return{vertices:Gt(r),midpoints:Ht(r)}}},{key:"selectVertex",value:function(e){this._map.fire(Ft,{index:e})}},{key:"insertVertexAtMidpoint",value:function(e){this._map.fire(Vt,{index:e})}},{key:"setGeometryValid",value:function(e){this._map._drawGeometryValid=e}},{key:"_geometryValidator",get:function(){return this._map._drawGeometryValidator},set:function(e){this._map._drawGeometryValidator=e}},{key:"setInvalid",value:function(e){this._liveStroke.set(e)}},{key:"_applyStrokeInvalid",value:function(e){this._setLayerVisibility("stroke-active",!e),this._setLayerVisibility("stroke-active-invalid",e),this._setLayerVisibility("fill-active",!e)}},{key:"_setLayerVisibility",value:function(e,t){var r=this;["hot","cold"].forEach(function(n){var o="".concat(e,".").concat(n);r._map.getLayer(o)&&r._map.setLayoutProperty(o,"visibility",t?"visible":"none")})}},{key:"deleteVertex",value:function(){}},{key:"get",value:function(e){return this._draw.get(e)}},{key:"_nextSortKey",value:function(){return this._sortKeyCounter+=1,this._sortKeyCounter}},{key:"add",value:function(e){var t,r,n=null==(null===(t=e.properties)||void 0===t?void 0:t.sortKey)?Ta(Ta({},e.properties),{},{sortKey:this._nextSortKey()}):e.properties,o=Ta(Ta({},e),{},{properties:n}),i=this._draw.add(o);return"Point"===(null===(r=o.geometry)||void 0===r?void 0:r.type)&&fa(n)&&this._resolvePointSymbol(i[0],n),i}},{key:"setStyle",value:function(e,t){var r=this._draw.get(e);r&&this.add(Ta(Ta({},r),{},{properties:Ta(Ta({},r.properties),t)}))}},{key:"delete",value:function(e){this._draw.delete(e)}},{key:"deleteAll",value:function(){this._draw.deleteAll()}},{key:"setSnapEnabled",value:function(e){this._mapProvider.snapEnabled=e;var t=tr(this._map);null!=t&&t.setSnapStatus&&t.setSnapStatus(e),!e&&t&&(ur(t),this._map.getLayer("snap-helper-circle")&&this._map.setLayoutProperty("snap-helper-circle","visibility","none"))}},{key:"setSnapLayers",value:function(e){var t=tr(this._map);null!=t&&t.setSnapLayers?t.setSnapLayers(e):e&&(this._map._pendingSnapLayers=e)}},{key:"isSnapEnabled",value:function(){return!0===this._mapProvider.snapEnabled}},{key:"setFeatureProperty",value:function(e,t,r){this._draw.setFeatureProperty(e,t,r)}},{key:"setDrawingPreviewProperty",value:function(e,t){var r,n=this._currentDrawEvent;null!=n&&n.properties&&(n.properties[e]=t),null==n||null===(r=n.ctx)||void 0===r||null===(r=r.store)||void 0===r||r.render()}},{key:"on",value:function(e,t){this._bus.on(e,t)}},{key:"off",value:function(e,t){this._bus.off(e,t)}},{key:"_handleModeChange",value:function(e){new Set(["draw_polygon","draw_line","draw_point","edit_vertex","edit_point"]).has(e.mode)||sr(tr(this._map),this._map)}},{key:"_handleStyleData",value:function(){var e,t=this,r=this._map.getStyle();if(r){this._liveStroke.refresh();var n=r.layers||[];!n.length||null!==(e=n[n.length-1].source)&&void 0!==e&&e.startsWith("mapbox-gl-draw")||n.filter(function(e){var t;return null===(t=e.source)||void 0===t?void 0:t.startsWith("mapbox-gl-draw")}).forEach(function(e){return t._map.moveLayer(e.id)})}}},{key:"remove",value:function(){this._map.off(Pt,this._mapHandlers.create),this._map.off(Ot,this._mapHandlers.editfinish),this._map.off(It,this._mapHandlers.cancel),this._map.off(Mt,this._mapHandlers.vertexselection),this._map.off(Ct,this._mapHandlers.vertexchange),this._map.off(Tt,this._mapHandlers.undochange),this._map.off(_t,this._mapHandlers.update),this._map.off(At,this._mapHandlers.geometrychange),this._map.off(kt,this._mapHandlers.placementblocked),this._map.off(jt,this._mapHandlers.interfacetypechange),this._map.off(Et,this._mapHandlers.modechange),this._map.off(Dt,this._mapHandlers.styledata),this._liveStroke.destroy(),this._liveDrawChecks.destroy(),this._cleanupDraw()}}],t&&Ma(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}()},473(e,t,r){"use strict";r.d(t,{$:()=>i});var n=r(682);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}var i=function(e){var t,r,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=null!==(t=null==e?void 0:e.mapColorScheme)&&void 0!==t?t:"light",u=null!==(r=null==e?void 0:e.id)&&void 0!==r?r:null,c=function(e){var t;return function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return"object"!==o(e)||null===e?e:r&&void 0!==e[r]?e[r]:void 0!==e[t]?e[t]:void 0!==e.light?e.light:Object.values(e)[0]}(null!==(t=a[e])&&void 0!==t?t:n.lm[e],s,u)};return{editStroke:c("editStroke"),editFill:c("editFill"),editVertex:c("editVertex"),editMidpoint:c("editMidpoint"),editActive:c("editActive"),editHalo:c("editHalo"),invalidStroke:c("invalidStroke"),splitValid:c("splitValid"),splitInvalid:c("splitInvalid"),shapeStroke:c("shapeStroke"),strokeWidth:null!==(i=a.strokeWidth)&&void 0!==i?i:n.F0.strokeWidth,shapeFill:c("shapeFill"),snapVertex:c("snapVertex"),snapEdge:c("snapEdge"),mapStyleId:u}}},722(e,t,r){"use strict";r.d(t,{$X:()=>u,DD:()=>i,Ox:()=>s,ZP:()=>a,mt:()=>c});var n=r(682),o=n.F0.touchTargetSize/2,i=function(e){var t,r,i=e.querySelector("[data-im-draw-touch-target]");return i||(e.insertAdjacentHTML("beforeend",(t=n.F0.touchTargetSize,r=o,"\n <svg width='".concat(t,"' height='").concat(t,"' viewBox='0 0 48 48' fill-rule='evenodd'\n style='display:none;position:absolute;top:0;left:0;margin:").concat(r,"px 0 0 -").concat(r,"px;cursor:grab'\n class='im-draw-touch-target' data-im-draw-touch-target>\n <circle cx='24' cy='24' r='24' fill='var(--draw-halo, #000)'/>\n <path d=\"M37.543 25H34a1 1 0 1 1 0-2h3.629l-.836-.837a1 1 0 0 1 1.414-1.414l2.5 2.501A1 1 0 0 1 41 24a1 1 0 0 1-.487.858l-2.306 2.306a1 1 0 0 1-1.414-1.414l.75-.75zM23 10.414l-.793.793a1 1 0 0 1-1.414-1.414l2.5-2.5C23.481 7.105 23.734 7 24 7s.519.105.707.293l2.5 2.5a1 1 0 0 1-1.414 1.414L25 10.414V14a1 1 0 1 1-2 0v-3.586zM7 24a1 1 0 0 1 .293-.75l2.5-2.501a1 1 0 0 1 1.414 1.414l-.836.837H14a1 1 0 1 1 0 2h-3.543l.75.75a1 1 0 0 1-1.414 1.414l-2.306-2.306A1 1 0 0 1 7 24zm16.293 16.707l-2.5-2.5a1 1 0 0 1 1.414-1.414l.793.793V34a1 1 0 1 1 2 0v3.586l.793-.793a1 1 0 0 1 1.414 1.414l-2.5 2.5c-.188.188-.441.293-.707.293s-.519-.105-.707-.293zM24 20c2.208 0 4 1.792 4 4s-1.792 4-4 4-4-1.792-4-4 1.792-4 4-4z\" fill='var(--draw-bg, #fff)'/>\n </svg>\n "))),i=e.querySelector("[data-im-draw-touch-target]")),i},a=function(e,t){e&&(e.style.setProperty("--draw-halo",t.editActive),e.style.setProperty("--draw-bg",t.editHalo),e.style.setProperty("--draw-primary",t.editVertex))},s=function(e,t){t&&e&&(e.style.left="".concat(t.x,"px"),e.style.top="".concat(t.y,"px"),e.style.display="block")},u=function(e){e&&(e.style.display="none")},c=function(e){if(!e)return!1;var t=e.parentNode;return t instanceof globalThis.SVGElement||null!=(null==t?void 0:t.ownerSVGElement)}},610(e,t,r){"use strict";r.d(t,{B:()=>n});var n=function(e){var t=[];return{push:function(r){t.push(r),e(t.length)},pop:function(){var r=t.pop();return e(t.length),r},clear:function(){t.length=0,e(t.length)},get length(){return t.length}}}},715(e,t,r){"use strict";r.d(t,{O:()=>l});var n=r(520),o=r(9),i=r(788);function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach(function(t){c(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function c(e,t,r){return(t=function(e){var t=function(e){if("object"!=a(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=a(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==a(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var l=function(e){var t=e.onStrokeChange,r=e.onPlaceChange,a=function(e){var t=!1;return function(r,n){r!==t&&(t=r,e(r,null!=n?n:null))}},s=a(t),c=a(r),l=!1,d=null,f=null,p=null,h=function(){null!=f&&((0,i.WG)(f),f=null),p=null},y=function(e,t,r,o,i){var a,s=(null!==(a=t.numVertices)&&void 0!==a?a:0)<o?{valid:!0}:(0,n.$U)(e,u(u({},t),{},{phase:"preview"}),{rules:r});i(!s.valid||l,s.valid?d:s.reason)},m=function(){var e,t;if(p){var r=p,n=r.feature,i=r.context,a=null!==(e=o.n8[null==n||null===(t=n.geometry)||void 0===t?void 0:t.type])&&void 0!==e?e:0;y(n,i,o.PI,a,s),y(n,i,o.Oo,0,c)}},g=function(){if(f=null,p){var e=p,t=e.feature,r=e.context,o=e.onGeometryChange,i=(0,n.$U)(t,u(u({},r),{},{phase:"preview"}),{rules:[],onGeometryChange:o});l=!i.valid,d=i.reason,m()}};return{update:function(e){var t=e.feature,r=e.context,n=void 0===r?{}:r,o=e.numVertices,a=e.onGeometryChange;p={feature:t,context:u(u({},n),{},{numVertices:o}),onGeometryChange:a},m(),"function"==typeof a&&null==f&&(f=(0,i.PW)(g))},reset:function(){h(),l=!1,d=null,s(!1,null),c(!1,null)},destroy:function(){h()}}}},788(e,t,r){"use strict";r.d(t,{De:()=>l,PW:()=>u,WG:()=>c});var n=r(520);function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach(function(t){s(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function s(e,t,r){return(t=function(e){var t=function(e){if("object"!=o(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==o(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var u=function(e){return"function"==typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,16)},c=function(e){return"function"==typeof cancelAnimationFrame?cancelAnimationFrame(e):clearTimeout(e)},l=function(e){var t=e.onChange,r=e.validate,o=void 0===r?n.Uk:r,i=!1,s=null,l=null,d=function(){null!=s&&(c(s),s=null),l=null},f=function(e,r){e!==i&&(i=e,t(e,null!=r?r:null))},p=function(){if(s=null,l){var e=l,t=e.feature,r=e.context,n=e.onGeometryChange,i=o(t,r,{onGeometryChange:n}),a=i.valid,u=i.reason;f(!a,u)}};return{update:function(e){var t=e.feature,r=e.context,n=void 0===r?{}:r,i=e.numVertices,c=e.onGeometryChange,h=a(a({},n),{},{numVertices:i}),y=o(t,h);return y.valid?"function"!=typeof c?(d(),void f(!1,null)):(l={feature:t,context:h,onGeometryChange:c},void(null==s&&(s=u(p)))):(d(),void f(!0,y.reason))},set:function(e,t){d(),f(e,null!=t?t:null)},refresh:function(){t(i,null)},destroy:function(){d()}}}},600(e,t,r){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}r.d(t,{a:()=>T});var o=function(e,t){if(!e)return null;if("string"==typeof e)return e.trim();if("object"===n(e)){if(t&&e[t])return e[t];var r=Object.values(e)[0];return null!=r?r:null}return null},i={symbol:"pin",backgroundColor:"#ca3535",foregroundColor:"#ffffff"},a={dot:"M8 3c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.241 5-5-2.24-5-5-5z",cross:"M6 3H10V6H13V10H10V13H6V10H3V6H6Z",diamond:"M8 2L14 8L8 14L2 8Z",triangle:"M8 2L14 14H2Z",square:"M3 3H13V13H3Z"},s={id:"pin",viewBox:"0 0 44 44",anchor:[.5,.9],graphic:a.dot,svg:'<path d="M22 40.999c-3.621 0-8.306-5.864-10.258-8.3C9.02 29.302 6 23.66 6 19.002a16.01 16.01 0 0 1 16-16 16.01 16.01 0 0 1 16 16c0 4.658-3.02 10.3-5.742 13.697-1.952 2.437-6.637 8.3-10.258 8.3z" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M22 7.001a12.01 12.01 0 0 1 12 12c0 7.623-10.377 17.998-12 17.998S10 26.624 10 19.001a12.01 12.01 0 0 1 12-12z" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 19) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},u={id:"circle",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:a.dot,svg:'<circle cx="22" cy="22" r="16" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <circle cx="22" cy="22" r="12" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},c={id:"square",viewBox:"0 0 44 44",anchor:[.5,.5],graphic:a.dot,svg:'<path d="M13 6h18c3.863 0 7 3.137 7 7v18c0 3.863-3.137 7-7 7H13c-3.863 0-7-3.137-7-7V13c0-3.863 3.137-7 7-7" fill="{{selectedColor}}" stroke="{{activeColor}}" stroke-width="6" paint-order="stroke fill"/>\n <path d="M13 34a3 3 0 0 1-3-3V13a3 3 0 0 1 3-3h18a3 3 0 0 1 3 3v18a3 3 0 0 1-3 3H13z" fill-rule="nonzero" fill="{{backgroundColor}}" stroke="{{haloColor}}" stroke-width="2" paint-order="stroke fill"/>\n <g transform="translate(22, 22) scale(0.8) translate(-8, -8)"><path d="{{graphic}}" fill="{{foregroundColor}}"/></g>'},l=r(121),d={light:{haloColor:"#ffffff",selectedColor:"#0b0c0c",activeColor:"#ffdd00",foregroundColor:"#0b0c0c"},dark:{haloColor:"#0b0c0c",selectedColor:"#ffffff",activeColor:"#ffdd00",foregroundColor:"#ffffff"}},f=function(e,t,r){return new Promise(function(n,o){var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(e)),a=new Image(t,r);a.onload=function(){var e=document.createElement("canvas");e.width=t,e.height=r;var o=e.getContext("2d");o.drawImage(a,0,0,t,r),n(o.getImageData(0,0,t,r))},a.onerror=function(){o(new Error("Failed to rasterise SVG: ".concat(e.slice(0,80))))},a.src=i})};function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function h(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return y(c,"_invoke",function(r,n,o){var i,s,u,c=0,l=o||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,r){return i=t,s=0,u=e,f.n=r,a}};function p(r,n){for(s=r,u=n,t=0;!d&&c&&!o&&t<l.length;t++){var o,i=l[t],p=f.p,h=i[2];r>3?(o=h===n)&&(u=i[(s=i[4])?5:(s=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=r<2&&p<i[1])?(s=0,f.v=n,f.n=i[1]):p<h&&(o=r<3||i[0]>n||n>h)&&(i[4]=r,i[5]=n,f.n=h,s=0))}if(o||r>1)return a;throw d=!0,n}return function(o,l,h){if(c>1)throw TypeError("Generator is already running");for(d&&1===l&&p(l,h),s=l,u=h;(t=s<2?e:u)||!d;){i||(s?s<3?(s>1&&(f.n=-1),p(s,u)):f.n=u:f.v=u);try{if(c=2,i){if(s||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=i.return)&&t.call(i),s<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),s=1);i=e}else if((t=(d=f.n<0)?u:r.call(n,f))!==a)break}catch(t){i=e,s=1,u=t}finally{c=1}}return{value:t,done:d}}}(r,o,i),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var l=[][n]?t(t([][n]())):(y(t={},n,function(){return this}),t),d=c.prototype=s.prototype=Object.create(l);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,y(e,o,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=c,y(d,"constructor",c),y(c,"constructor",u),u.displayName="GeneratorFunction",y(c,o,"GeneratorFunction"),y(d),y(d,o,"Generator"),y(d,n,function(){return this}),y(d,"toString",function(){return"[object Generator]"}),(h=function(){return{w:i,m:f}})()}function y(e,t,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}y=function(e,t,r,n){function i(t,r){y(e,t,function(e){return this._invoke(t,r,e)})}t?o?o(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r:(i("next",0),i("throw",1),i("return",2))},y(e,t,r,n)}function m(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach(function(t){b(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function b(e,t,r){return(t=function(e){var t=function(e){if("object"!=p(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==p(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){c=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return s}}(e,t)||w(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(e,t){if(e){if("string"==typeof e)return x(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var P=new Map,_=new Map,E={},O=function(e){var t,r=0,n=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=w(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(a)throw o}}}}(e);try{for(n.s();!(t=n.n()).done;){var o=t.value;r=Math.trunc((r<<5)-r+o.codePointAt(0))}}catch(e){n.e(e)}finally{n.f()}return Math.abs(r).toString(36)},I=new Set(["id","svg","viewBox","anchor","symbol","symbolSvgContent"]);function M(e,t,r){var n,s,u,c,l=null==r?void 0:r.id,f=Object.fromEntries(Object.entries(e||{}).filter(function(e){var t=S(e,1)[0];return!I.has(t)})),p=Object.fromEntries(Object.entries(E).filter(function(e){var t=S(e,1)[0];return!I.has(t)})),h=Object.fromEntries(Object.entries(t).filter(function(e){return null!=S(e,2)[1]})),y=v(v(v(v({},i),p),f),h),m=null!==(n=d[null==r?void 0:r.mapColorScheme])&&void 0!==n?n:d.light;return y.haloColor=null!==(s=null==r?void 0:r.haloColor)&&void 0!==s?s:m.haloColor,y.selectedColor=null!==(u=null==r?void 0:r.selectedColor)&&void 0!==u?u:m.selectedColor,y.activeColor=null!==(c=null==r?void 0:r.activeColor)&&void 0!==c?c:m.activeColor,"string"==typeof y.graphic&&a[y.graphic]&&(y.graphic=a[y.graphic]),Object.fromEntries(Object.entries(y).map(function(e){var t=S(e,2),r=t[0],n=t[1];return[r,o(n,l)||""]}))}function C(e,t){return Object.entries(t).reduce(function(e,t){var r=S(t,2),n=r[0],o=r[1];return e.replaceAll("{{".concat(n,"}}"),o)},e)}var T={setDefaults:function(e){E=e||{}},getDefaults:function(){return v(v({},i),E)},register:function(e){P.set(e.id,e)},get:function(e){return P.get(e)},list:function(){return function(e){if(Array.isArray(e))return x(e)}(e=P.values())||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||w(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}();var e},clear:function(){P.clear()},initialise:function(){this.register(s),this.register(u),this.register(c)},resolve:function(e,t,r){var n=M(e,t||{},r);return e?(n.selectedColor="none",n.activeColor="none",C(e.svg,n)):""},resolveActive:function(e,t,r){var n=M(e,t||{},r);return e?C(e.svg,n):""},resolveSelected:function(e,t,r){var n=M(e,t||{},r);return e?(n.activeColor="none",C(e.svg,n)):""},getSymbolImageId:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2,o=this.getSymbolDef(e);if(!o)return null;var i=(0,l.sR)(e),a=r?this.resolveActive(o,i,t):this.resolve(o,i,t);return"symbol-".concat(r?"act-":"").concat(O(a),"-").concat(n,"x")},getSymbolDef:function(e){return e.symbolSvgContent?{svg:e.symbolSvgContent}:e.symbol?this.get(e.symbol):void 0},rasteriseSymbolImage:function(e,t,r,n){var o,i=this;return(o=h().m(function o(){var a,s,u,c,d,p,y,m,g,v,b,w;return h().w(function(o){for(;;)switch(o.n){case 0:if(a=i.getSymbolDef(e)){o.n=1;break}return o.a(2,null);case 1:if(s=(0,l.sR)(e),"active"===r?(u=i.resolveActive(a,s,t),c="act-"):"selected"===r?(u=i.resolveSelected(a,s,t),c="sel-"):(u=i.resolve(a,s,t),c=""),d="symbol-".concat(c).concat(O(u),"-").concat(n,"x"),p=_.get(d)){o.n=3;break}return y=(0,l.n8)(e,a),m=y.split(" ").map(Number),g=S(m,4),v=g[2],b=g[3],w='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(v*n,'" height="').concat(b*n,'" viewBox="').concat(y,'">').concat(u,"</svg>"),o.n=2,f(w,v*n,b*n);case 2:p=o.v,_.set(d,p);case 3:return o.a(2,{imageId:d,imageData:p})}},o)}),function(){var e=this,t=arguments;return new Promise(function(r,n){var i=o.apply(e,t);function a(e){m(i,r,n,a,s,"next",e)}function s(e){m(i,r,n,a,s,"throw",e)}a(void 0)})})()}};T.initialise()},195(e,t,r){"use strict";r.d(t,{z:()=>o});var n=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Enter"]),o=function(e){e.altKey&&n.has(e.key)&&e.stopPropagation()}},107(e,t,r){"use strict";r.d(t,{c:()=>n});var n=function(e,t,r){var n=function(e,t){return e[0]===t[0]&&e[1]===t[1]},o=t.filter(function(t){var o=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);return("ArrowUp"===r?t[1]<=e[1]&&i>=o:"ArrowDown"===r?t[1]>e[1]&&i>=o:"ArrowLeft"===r?t[0]<=e[0]&&i<o:"ArrowRight"!==r||t[0]>e[0]&&i<o)&&!n(t,e)});o.length||o.push(e);var i=function(t){return Math.hypot(e[0]-t[0],e[1]-t[1])},a=o.reduce(function(e,t){return i(t)<i(e)?t:e},o[0]);return t.findIndex(function(e){return n(e,a)})}},121(e,t,r){"use strict";r.d(t,{Op:()=>a,n8:()=>i,sR:()=>o});var n=new Set(["symbolBackgroundColor","symbolForegroundColor","symbolHaloWidth","symbolGraphic"]),o=function(e){if(!function(e){return!(!e.symbol&&!e.symbolSvgContent)}(e))return{};var t={};return n.forEach(function(r){if(null!=e[r]){var n=r.charAt(6).toLowerCase()+r.slice(7);t[n]=e[r]}}),t},i=function(e,t){var r;return e.symbolViewBox?e.symbolViewBox:null!==(r=null==t?void 0:t.viewBox)&&void 0!==r?r:"0 0 38 38"},a=function(e,t){var r;return e.symbolAnchor?e.symbolAnchor:null!==(r=null==t?void 0:t.anchor)&&void 0!==r?r:[.5,.5]}}}]);
|