@defra/interactive-map 0.0.36-alpha → 0.0.38-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/assets/templates/draw-tools.njk +4 -3
- 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 +32 -0
- package/docs/examples/draw-tools.mdx +0 -4
- package/docs/plugins/draw.md +482 -0
- package/docs/plugins.md +2 -6
- package/govuk-prototype-kit.config.json +3 -2
- package/package.json +2 -4
- package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
- package/plugins/beta/draw-es/src/events.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/css/index.css +1 -97
- package/plugins/datasets/dist/esm/esriLayerAdapter.js +1 -1
- package/plugins/datasets/dist/esm/im-datasets-plugin.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-esri-adapter.js +1 -1
- package/plugins/datasets/dist/umd/im-datasets-plugin.js +1 -1
- package/plugins/datasets/src/adapters/esri/esriLayerAdapter.js +13 -0
- package/plugins/draw/dist/esm/im-draw-ml-adapter.js +1 -0
- package/plugins/draw/dist/esm/im-draw-ol-adapter.js +1 -0
- package/plugins/draw/dist/esm/im-draw-plugin.js +1 -0
- package/plugins/draw/dist/esm/index.js +1 -0
- package/plugins/draw/dist/umd/im-draw-ml-adapter.js +1 -0
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js +2 -0
- package/plugins/draw/dist/umd/im-draw-ol-adapter.js.LICENSE.txt +1 -0
- package/plugins/draw/dist/umd/im-draw-plugin.js +2 -0
- package/plugins/draw/dist/umd/im-draw-plugin.js.LICENSE.txt +1 -0
- package/plugins/draw/dist/umd/index.js +2 -0
- package/plugins/draw/dist/umd/index.js.LICENSE.txt +1 -0
- package/plugins/draw/src/DrawInit.jsx +89 -0
- package/plugins/draw/src/DrawInit.test.jsx +184 -0
- package/plugins/draw/src/adapterEvents.js +127 -0
- package/plugins/draw/src/adapterEvents.test.js +20 -0
- package/plugins/draw/src/adapters/adapterContract.test.js +48 -0
- package/plugins/draw/src/adapters/loadDrawAdapter.js +14 -0
- package/plugins/draw/src/adapters/loadDrawAdapter.test.js +53 -0
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.js +367 -0
- package/plugins/draw/src/adapters/maplibre/MaplibreDrawAdapter.test.js +799 -0
- package/plugins/draw/src/adapters/maplibre/defaults.js +1 -0
- package/plugins/draw/src/adapters/maplibre/drawEvents.js +35 -0
- package/plugins/draw/src/adapters/maplibre/mapboxDraw.js +126 -0
- package/plugins/draw/src/adapters/maplibre/mapboxDraw.test.js +268 -0
- package/plugins/draw/src/adapters/maplibre/mapboxSnap.js +39 -0
- package/plugins/draw/src/adapters/maplibre/mapboxSnap.test.js +91 -0
- package/plugins/draw/src/adapters/maplibre/modes/createDrawMode.js +58 -0
- package/plugins/draw/src/adapters/maplibre/modes/createDrawMode.test.js +53 -0
- package/plugins/draw/src/adapters/maplibre/modes/disabledMode.js +23 -0
- package/plugins/draw/src/adapters/maplibre/modes/disabledMode.test.js +21 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawLineMode.js +15 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawLineMode.test.js +37 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/__helpers__/harness.js +115 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.js +193 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/clickHandlers.test.js +241 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/keyboardHandlers.js +78 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/keyboardHandlers.test.js +75 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.js +78 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/lifecycle.test.js +48 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.js +103 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/pointerHandlers.test.js +127 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/renderHelpers.js +59 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/renderHelpers.test.js +34 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.js +193 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawMode/undoHandlers.test.js +195 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawPolygonMode.js +16 -0
- package/plugins/draw/src/adapters/maplibre/modes/drawPolygonMode.test.js +27 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/__helpers__/harness.js +107 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.js +139 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/geometryHelpers.test.js +46 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/helpers.js +2 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/helpers.test.js +17 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.js +151 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/keyboardHandlers.test.js +123 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.js +161 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/pointerHandlers.test.js +98 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.js +133 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/touchHandlers.test.js +105 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.js +166 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/undoHandlers.test.js +133 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.js +210 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexOperations.test.js +167 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.js +121 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode/vertexQueries.test.js +73 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.js +249 -0
- package/plugins/draw/src/adapters/maplibre/modes/editVertexMode.test.js +153 -0
- package/plugins/draw/src/adapters/maplibre/snap/constants.js +2 -0
- package/plugins/draw/src/adapters/maplibre/snap/mapHandlers.js +39 -0
- package/plugins/draw/src/adapters/maplibre/snap/mapHandlers.test.js +106 -0
- package/plugins/draw/src/adapters/maplibre/snap/prototypePatches.js +148 -0
- package/plugins/draw/src/adapters/maplibre/snap/prototypePatches.test.js +238 -0
- package/plugins/draw/src/adapters/maplibre/snap/snapInstance.js +115 -0
- package/plugins/draw/src/adapters/maplibre/snap/snapInstance.test.js +151 -0
- package/plugins/draw/src/adapters/maplibre/snap/sourceData.js +34 -0
- package/plugins/draw/src/adapters/maplibre/snap/sourceData.test.js +62 -0
- package/plugins/draw/src/adapters/maplibre/styles.js +207 -0
- package/plugins/draw/src/adapters/maplibre/styles.test.js +155 -0
- package/plugins/draw/src/adapters/maplibre/utils/snapHelpers.js +202 -0
- package/plugins/draw/src/adapters/maplibre/utils/snapHelpers.test.js +253 -0
- package/plugins/draw/src/adapters/maplibre/utils/touchClickWorkaround.js +57 -0
- package/plugins/draw/src/adapters/maplibre/utils/touchClickWorkaround.test.js +106 -0
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.js +117 -0
- package/plugins/draw/src/adapters/openlayers/OLDrawAdapter.test.js +159 -0
- package/plugins/draw/src/adapters/openlayers/__helpers__/harness.js +90 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.js +178 -0
- package/plugins/draw/src/adapters/openlayers/core/OLDrawManager.test.js +153 -0
- package/plugins/draw/src/adapters/openlayers/core/featureStore.js +69 -0
- package/plugins/draw/src/adapters/openlayers/core/featureStore.test.js +58 -0
- package/plugins/draw/src/adapters/openlayers/core/internalEvents.js +8 -0
- package/plugins/draw/src/adapters/openlayers/core/styles.js +155 -0
- package/plugins/draw/src/adapters/openlayers/core/styles.test.js +143 -0
- package/plugins/draw/src/adapters/openlayers/defaults.js +1 -0
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.js +272 -0
- package/plugins/draw/src/adapters/openlayers/draw/DrawMode.test.js +431 -0
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.js +139 -0
- package/plugins/draw/src/adapters/openlayers/draw/drawInput.test.js +140 -0
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.js +144 -0
- package/plugins/draw/src/adapters/openlayers/draw/vertexPlacement.test.js +196 -0
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.js +385 -0
- package/plugins/draw/src/adapters/openlayers/edit/EditMode.test.js +303 -0
- package/plugins/draw/src/adapters/openlayers/edit/activeVertexLayer.js +55 -0
- package/plugins/draw/src/adapters/openlayers/edit/activeVertexLayer.test.js +53 -0
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.js +157 -0
- package/plugins/draw/src/adapters/openlayers/edit/keyboardHandler.test.js +195 -0
- package/plugins/draw/src/adapters/openlayers/edit/midpointLayer.js +57 -0
- package/plugins/draw/src/adapters/openlayers/edit/midpointLayer.test.js +42 -0
- package/plugins/draw/src/adapters/openlayers/edit/modifyInteraction.js +83 -0
- package/plugins/draw/src/adapters/openlayers/edit/modifyInteraction.test.js +80 -0
- package/plugins/draw/src/adapters/openlayers/edit/nudge.js +118 -0
- package/plugins/draw/src/adapters/openlayers/edit/nudge.test.js +165 -0
- package/plugins/draw/src/adapters/openlayers/edit/pointerHandlers.js +79 -0
- package/plugins/draw/src/adapters/openlayers/edit/pointerHandlers.test.js +78 -0
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.js +116 -0
- package/plugins/draw/src/adapters/openlayers/edit/selectionState.test.js +109 -0
- package/plugins/draw/src/adapters/openlayers/edit/touchHandler.js +184 -0
- package/plugins/draw/src/adapters/openlayers/edit/touchHandler.test.js +133 -0
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.js +94 -0
- package/plugins/draw/src/adapters/openlayers/edit/undoOps.test.js +64 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexHitTest.js +74 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexHitTest.test.js +28 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexLayer.js +49 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexLayer.test.js +42 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexOps.js +100 -0
- package/plugins/draw/src/adapters/openlayers/edit/vertexOps.test.js +80 -0
- package/plugins/draw/src/adapters/openlayers/olDraw.js +40 -0
- package/plugins/draw/src/adapters/openlayers/olDraw.test.js +70 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapEngine.js +220 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapEngine.test.js +232 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapGeometry.js +198 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapGeometry.test.js +136 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapIndicator.js +81 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapIndicator.test.js +72 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapInteraction.js +57 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapInteraction.test.js +68 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapManager.js +99 -0
- package/plugins/draw/src/adapters/openlayers/snap/snapManager.test.js +101 -0
- package/plugins/draw/src/adapters/openlayers/utils/geometryHelpers.js +103 -0
- package/plugins/draw/src/adapters/openlayers/utils/geometryHelpers.test.js +76 -0
- package/plugins/draw/src/adapters/openlayers/utils/olCoords.js +35 -0
- package/plugins/draw/src/adapters/openlayers/utils/olCoords.test.js +22 -0
- package/plugins/draw/src/adapters/openlayers/utils/sketchHelpers.js +22 -0
- package/plugins/draw/src/adapters/openlayers/utils/sketchHelpers.test.js +18 -0
- package/plugins/draw/src/adapters/openlayers/utils/touchTarget.js +8 -0
- package/plugins/draw/src/api/addFeature.js +22 -0
- package/plugins/draw/src/api/addFeature.test.js +41 -0
- package/plugins/draw/src/api/deleteFeature.js +11 -0
- package/plugins/draw/src/api/deleteFeature.test.js +24 -0
- package/plugins/draw/src/api/editFeature.js +54 -0
- package/plugins/draw/src/api/editFeature.test.js +134 -0
- package/plugins/draw/src/api/merge.js +30 -0
- package/plugins/draw/src/api/merge.test.js +57 -0
- package/plugins/draw/src/api/newLine.js +41 -0
- package/plugins/draw/src/api/newLine.test.js +93 -0
- package/plugins/draw/src/api/newPolygon.js +41 -0
- package/plugins/draw/src/api/newPolygon.test.js +93 -0
- package/plugins/draw/src/api/split.js +117 -0
- package/plugins/draw/src/api/split.test.js +204 -0
- package/plugins/draw/src/defaults.js +52 -0
- package/plugins/draw/src/defaults.test.js +18 -0
- package/plugins/draw/src/draw.scss +43 -0
- package/plugins/draw/src/events.js +237 -0
- package/plugins/draw/src/events.test.js +369 -0
- package/plugins/draw/src/index.js +10 -0
- package/plugins/draw/src/index.test.js +24 -0
- package/plugins/draw/src/manifest.js +170 -0
- package/plugins/draw/src/manifest.test.js +147 -0
- package/plugins/draw/src/reducer.js +69 -0
- package/plugins/draw/src/reducer.test.js +85 -0
- package/plugins/draw/src/utils/debounce.js +16 -0
- package/plugins/draw/src/utils/debounce.test.js +40 -0
- package/plugins/draw/src/utils/eventBus.js +36 -0
- package/plugins/draw/src/utils/eventBus.test.js +47 -0
- package/plugins/draw/src/utils/flattenStyleProperties.js +25 -0
- package/plugins/draw/src/utils/flattenStyleProperties.test.js +33 -0
- package/plugins/draw/src/utils/getValueForStyle.js +33 -0
- package/plugins/draw/src/utils/getValueForStyle.test.js +32 -0
- package/plugins/draw/src/utils/resolveColors.js +39 -0
- package/plugins/draw/src/utils/resolveColors.test.js +34 -0
- package/plugins/draw/src/utils/spatial.js +243 -0
- package/plugins/draw/src/utils/spatial.test.js +243 -0
- package/plugins/draw/src/utils/touchTarget.js +95 -0
- package/plugins/draw/src/utils/touchTarget.test.js +107 -0
- package/plugins/draw/src/utils/undoStack.js +31 -0
- package/plugins/draw/src/utils/undoStack.test.js +49 -0
- package/plugins/draw/src/validation/liveDrawChecks.js +120 -0
- package/plugins/draw/src/validation/liveDrawChecks.test.js +159 -0
- package/plugins/draw/src/validation/liveStroke.js +85 -0
- package/plugins/draw/src/validation/liveStroke.test.js +150 -0
- package/plugins/draw/src/validation/rules.areaError.test.js +12 -0
- package/plugins/draw/src/validation/rules.js +186 -0
- package/plugins/draw/src/validation/rules.test.js +120 -0
- package/plugins/draw/src/validation/validateGeometry.js +119 -0
- package/plugins/draw/src/validation/validateGeometry.test.js +200 -0
- 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/src/hooks/useInteractionHandlers.js +1 -1
- package/plugins/interact/src/hooks/useInteractionHandlers.test.js +1 -1
- package/plugins/interact/src/utils/buildStylesMap.js +1 -0
- package/plugins/search/dist/css/index.css +1 -317
- package/rollup.esm.mjs +35 -28
- package/sonar-project.properties +2 -2
- package/src/App/components/Attributions/Attributions.module.scss +1 -0
- package/src/App/components/Hints/Hints.module.scss +5 -4
- package/src/App/components/KeyboardHelp/KeyboardHelp.jsx +1 -1
- package/src/App/components/KeyboardHelp/KeyboardHelp.test.jsx +11 -0
- package/src/App/components/MoveControl/MoveControl.jsx +73 -9
- package/src/App/components/MoveControl/MoveControl.module.scss +12 -2
- package/src/App/components/MoveControl/MoveControl.test.jsx +136 -0
- package/src/App/hooks/useHintsAPI.js +67 -0
- package/src/App/hooks/useHintsAPI.test.js +145 -0
- package/src/App/renderer/PluginInits.jsx +4 -0
- package/src/App/renderer/PluginInits.test.jsx +7 -1
- package/src/InteractiveMap/InteractiveMap.js +20 -0
- package/src/InteractiveMap/InteractiveMap.test.js +7 -0
- package/src/config/events.js +4 -0
- package/src/scss/settings/_dimensions.scss +3 -0
- package/src/services/announcer.js +38 -3
- package/src/services/announcer.test.js +133 -1
- package/src/services/hints.js +3 -0
- package/src/services/hints.test.js +19 -0
- package/src/types.js +12 -0
- package/src/utils/detectInterfaceType.js +5 -1
- package/src/utils/isMac.js +15 -0
- package/src/utils/isMac.test.js +37 -0
- package/webpack.umd.mjs +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(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(!f(e[0])||!f(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 p(e){return e%(2*Math.PI)*180/Math.PI}function f(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 p(d(e,t))},t.bearingToAzimuth=function(e){var t=e%360;return t<0&&(t+=360),t},t.radiansToDegrees=p,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=f,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(!f(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,p=0,f=0,h=e.type,y="FeatureCollection"===h,g="Feature"===h,m=y?e.features.length:1,v=0;v<m;v++){u=(d=!!(l=y?e.features[v].geometry:g?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var x=0,S=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var w=s.type;switch(p=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(c,f,v,x,S))return!1;f++,x++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,x,S))return!1;f++,"MultiPoint"===w&&x++}"LineString"===w&&x++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-p;i++){if(!1===t(c[n][i],f,v,x,S))return!1;f++}"MultiLineString"===w&&x++,"Polygon"===w&&S++}"Polygon"===w&&x++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(S=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-p;a++){if(!1===t(c[n][i][a],f,v,x,S))return!1;f++}S++}x++}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,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,y=f?e.features.length:1;for(r=0;r<y;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?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,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}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,p,f,h){if(void 0===u||r>c||f>l||h>d)return u=o,c=r,l=f,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 p=r[n],f=o,h=i;for(t(r,o,n),a(r[i],p)>0&&t(r,o,i);f<h;){for(t(r,f,h),f++,h--;a(r[f],p)<0;)f++;for(;a(r[h],p)>0;)h--}0===a(r[o],p)?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 p(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function f(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(!f(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;f(e,s)&&(t.leaf?r.push(a):p(e,s)?this._all(a,r):o.push(a))}t=o.pop()}return r},n.prototype.collides=function(e){var t=this.data;if(!f(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(f(e,i)){if(t.leaf||p(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||!p(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 p=l;p<=d;p+=u){var f=Math.min(p+u-1,d);o.children.push(this._build(e,p,f,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=(p=e,f=u,(Math.max(f.maxX,p.maxX)-Math.min(f.minX,p.minX))*(Math.max(f.maxY,p.maxY)-Math.min(f.minY,p.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 p,f;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,p=1/0,f=1/0,h=t;h<=r-t;h++){var y=a(e,0,h,this.toBBox),g=a(e,h,r,this.toBBox),m=(o=y,i=g,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(g);m<p?(p=m,n=h,f=v<f?v:f):m===p&&v<f&&(f=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 p=e.children[l];s(i,e.leaf?o(p):p),c+=d(i)}for(var f=r-t-1;f>=t;f--){var h=e.children[f];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(!g(e[0])||!g(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 p(e,t,r={}){return i({type:"MultiPolygon",coordinates:e},t,r)}function f(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 g(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 f(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 p(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=g,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=p,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=f,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(!g(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,p=0,f=0,h=e.type,y="FeatureCollection"===h,g="Feature"===h,m=y?e.features.length:1,v=0;v<m;v++){u=(d=!!(l=y?e.features[v].geometry:g?e.geometry:e)&&"GeometryCollection"===l.type)?l.geometries.length:1;for(var b=0;b<u;b++){var x=0,S=0;if(null!==(s=d?l.geometries[b]:l)){c=s.coordinates;var w=s.type;switch(p=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(c,f,v,x,S))return!1;f++,x++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,x,S))return!1;f++,"MultiPoint"===w&&x++}"LineString"===w&&x++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-p;i++){if(!1===t(c[n][i],f,v,x,S))return!1;f++}"MultiLineString"===w&&x++,"Polygon"===w&&S++}"Polygon"===w&&x++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(S=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-p;a++){if(!1===t(c[n][i][a],f,v,x,S))return!1;f++}S++}x++}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,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,y=f?e.features.length:1;for(r=0;r<y;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?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,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}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,p,f,h){if(void 0===u||r>c||f>l||h>d)return u=o,c=r,l=f,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}},24(e,t,r){"use strict";r.r(t),r.d(t,{MaplibreDrawAdapter:()=>Ko,displayedShape:()=>qo});var n={};r.r(n),r.d(n,{LAT_MAX:()=>b,LAT_MIN:()=>m,LAT_RENDERED_MAX:()=>x,LAT_RENDERED_MIN:()=>v,LNG_MAX:()=>w,LNG_MIN:()=>S,activeStates:()=>y,classes:()=>a,cursors:()=>u,events:()=>p,geojsonTypes:()=>l,interactions:()=>g,meta:()=>h,modes:()=>d,sources:()=>s,types:()=>c,updateActions:()=>f});var o={};r.r(o),r.d(o,{isActiveFeature:()=>P,isBackspaceKey:()=>k,isDeleteKey:()=>F,isDigit1Key:()=>j,isDigit2Key:()=>V,isDigit3Key:()=>N,isDigitKey:()=>D,isEnterKey:()=>L,isEscapeKey:()=>A,isFeature:()=>O,isInactiveFeature:()=>I,isOfMetaType:()=>E,isShiftDown:()=>T,isShiftMousedown:()=>_,isTrue:()=>R,isVertex:()=>C,noTarget:()=>M});var i={};r.r(i),r.d(i,{CommonSelectors:()=>o,ModeHandler:()=>ee,StringSet:()=>$,constrainFeatureMovement:()=>ze,createMidPoint:()=>Ge,createSupplementaryPoints:()=>He,createVertex:()=>Ae,doubleClickZoom:()=>Ye,euclideanDistance:()=>z,featuresAt:()=>q,getFeatureAtAndSetCursors:()=>W,isClick:()=>Z,isEventAtCoordinates:()=>st,isTap:()=>Q,mapEventToBoundingBox:()=>Y,moveFeatures:()=>Ze,sortFeatures:()=>H,stringSetsAreEqual:()=>vt,theme:()=>Oe,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"},p={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"},f={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},h={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},y={ACTIVE:"true",INACTIVE:"false"},g=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],m=-90,v=-85,b=90,x=85,S=-270,w=270;function E(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 P(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===y.ACTIVE&&e.featureTarget.properties.meta===h.FEATURE}function I(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===y.INACTIVE&&e.featureTarget.properties.meta===h.FEATURE}function M(e){return void 0===e.featureTarget}function O(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 L(e){return"Enter"===e.key||13===e.keyCode}function k(e){return"Backspace"===e.key||8===e.keyCode}function F(e){return"Delete"===e.key||46===e.keyCode}function j(e){return"1"===e.key||49===e.keyCode}function V(e){return"2"===e.key||50===e.keyCode}function N(e){return"3"===e.key||51===e.keyCode}function D(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 X(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)}X.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},X.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},X.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},X.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)},X.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const $=X,J=[h.FEATURE,h.MIDPOINT,h.VERTEX],q={click:function(e,t,r){return K(e,t,r,r.options.clickBuffer)},touch:function(e,t,r){return K(e,t,r,r.options.touchBuffer)}};function K(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!==J.indexOf(e.properties.meta)),s=new $,u=[];return a.forEach(e=>{const t=e.properties.id;s.has(t)||(s.add(t),u.push(e))}),H(u)}function W(e,t){const r=q.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 z(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=z(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,z(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},pe=(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)},fe=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)};(fe.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","")}}))},fe.prototype.isValid=function(){return this.features.every(e=>e.isValid())},fe.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},fe.prototype.getCoordinate=function(e){return pe(this.features,"getCoordinate",e)},fe.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===l.POLYGON?e.getCoordinates():e.coordinates)))},fe.prototype.updateCoordinate=function(e,t,r){pe(this.features,"updateCoordinate",e,t,r),this.changed()},fe.prototype.addCoordinate=function(e,t,r){pe(this.features,"addCoordinate",e,t,r),this.changed()},fe.prototype.removeCoordinate=function(e){pe(this.features,"removeCoordinate",e),this.changed()},fe.prototype.getFeatures=function(){return this.features};const he=fe;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 q[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 ge=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 me={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(me);const be=function(e){return[].concat(e).filter(e=>void 0!==e)};function xe(){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 Se(e){let t;this._features={},this._featureIds=new $,this._selectedFeatureIds=new $,this._selectedCoordinates=[],this._changedFeatureIds=new $,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,xe.call(this),this._emitSelectionChange&&(this.ctx.events.fire(p.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(p.RENDER,{})}))},this.isDirty=!1}function we(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}Se.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},Se.prototype.setDirty=function(){return this.isDirty=!0,this},Se.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(p.CREATE,{features:[t.toGeoJSON()]})}return this},Se.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(p.UPDATE,{action:t.action?t.action:f.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},Se.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Se.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Se.prototype.getAllIds=function(){return this._featureIds.values()},Se.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},Se.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(p.DELETE,{features:r}),we(this,t),this},Se.prototype.get=function(e){return this._features[e]},Se.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},Se.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},Se.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))}),we(this,t),this},Se.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},Se.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},Se.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},Se.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Se.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Se.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},Se.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)}))},Se.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},Se.prototype.setFeatureProperty=function(e,t,r,n={}){this.get(e).setProperty(t,r),this.featureChanged(e,{silent:n.silent,action:f.CHANGE_PROPERTIES})},Se.prototype.storeMapConfig=function(){g.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},Se.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},Se.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const Ee=["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 ge(r));return{start(){o=i.onSetup(n),ve.forEach(t=>{const r=me[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=W(t,e);t.featureTarget=r,s.mousemove(t)},o.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};const n=W(t,e);t.featureTarget=n,s.mousedown(t)},o.mouseup=function(t){const n=W(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=q.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=q.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=F(e),n=D(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(p.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains(a.CANVAS)&&((k(t)||F(t))&&e.options.controls.trash?(t.preventDefault(),s.trash()):c(t)?s.keydown(t):j(t)&&e.options.controls.point?l(d.DRAW_POINT):V(t)&&e.options.controls.line_string?l(d.DRAW_LINE_STRING):N(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 f={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===f[e])throw new Error("Invalid action type");f[e]!==t[e]&&(r=!0),f[e]=t[e]}),r&&e.map.fire(p.ACTIONABLE,{actions:f})},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=[];Ee.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();p(e),t.onActivate()},!0),n}function l(){r&&(r.classList.remove(a.ACTIVE_BUTTON),r=null)}function p(e){l();const n=t[e];n&&n&&"trash"!==e&&(n.classList.add(a.ACTIVE_BUTTON),r=n)}return{setActiveButton:p,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 Se(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 Pe="#3bb2d0",Ie="#fbb03b",Me="#fff",Oe=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],Ie,Pe],"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"],Ie,Pe],"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":Me}},{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"],Ie,Pe]}},{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":Me}},{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":Ie}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":Ie}}];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 Le=r(850),ke=r(278);function Fe(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=je(e.properties),null==e.geometry?t.geometry=null:t.geometry=Ve(e.geometry),t}function je(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]=je(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=Ne(e.coordinates),t)}function Ne(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(e=>Ne(e))}function De(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 Fe(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=>Fe(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,Le.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]>x||n[1]<v||o[1]>x||o[1]<v)return null;const i=De(n),a=De(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:Xe,LAT_MAX:$e,LAT_RENDERED_MIN:Je,LAT_RENDERED_MAX:qe,LNG_MIN:Ke,LNG_MAX:We}=n;function ze(e,t){let r=Xe,n=$e,o=Xe,i=$e,a=We,s=Ke;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>qe&&(u.lat=qe-r),o+u.lat>$e&&(u.lat=$e-o),n+u.lat<Je&&(u.lat=Je-n),i+u.lat<Xe&&(u.lat=Xe-i),a+u.lng<=Ke&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=We&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function Ze(e,t){const r=ze(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(p.UPDATE,{action:f.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 $).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 O(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 M(t)?this.clickAnywhere(e,t):E(h.VERTEX)(t)?this.clickOnVertex(e,t):O(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(),P(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(P(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(p.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(p.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:r}),this.fireActionable()};const et=Qe,tt=E(h.VERTEX),rt=E(h.MIDPOINT),nt={fireUpdate:function(){this.fire(p.UPDATE,{action:f.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=ze(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=P(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):P(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 M(t)?this.clickNoTarget(e,t):P(t)?this.clickActiveFeature(e,t):I(t)?this.clickInactive(e,t):void this.stopDragging(e)},nt.onTap=function(e,t){return M(t)?this.clickNoTarget(e,t):P(t)?this.clickActiveFeature(e,t):I(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(p.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)||L(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)):L(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(p.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){L(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(p.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},pt={defaultMode:d.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Oe,modes:dt,controls:{},userProperties:!1,suppressAPIEvents:!0},ft={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 gt=r(17),mt=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 xt(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({},ft,e.controls),t=Object.assign({},pt,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 q.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 $(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(mt(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,gt(o,t.properties)||e.store.featureChanged(n.id,{silent:r}),gt(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)}xt.modes=dt,xt.constants=n,xt.lib=i;const St=xt;var wt={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)}},Et=r(682);function _t(e){return _t="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},_t(e)}function Pt(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 It(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Pt(Object(r),!0).forEach(function(t){Mt(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Pt(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Mt(e,t,r){return(t=function(e){var t=function(e){if("object"!=_t(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=_t(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==_t(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ot(e){var t;return null!==(t=null==e?void 0:e._snapInstance)&&void 0!==t?t:null}function Ct(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 Tt(e){return Ct(e)?{lng:e.snapCoords[0],lat:e.snapCoords[1]}:null}function At(e,t,r){if(!e||!t||!e.status)return!1;var n=t.unproject(r);return e.snapToClosestPoint({point:r,lngLat:n}),!0}function Lt(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 kt(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 Ft(e){return"function"==typeof(null==e?void 0:e.getSnapEnabled)&&!0===e.getSnapEnabled()}function jt(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 Vt(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)?Vt(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 Vt(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[]}},Dt=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},Rt=function(e,t){var r,n=jt(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},Ut=function(e,t){var r,n=e.geometry.coordinates,o=jt(t);try{for(o.s();!(r=o.n()).done;)n=n[r.value]}catch(e){o.e(e)}finally{o.f()}return n},Bt=function(e,t){var r,n=t.split(".").map(Number),o=jt(Dt(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]},Gt=function(e,t){return{x:e.x*t,y:e.y*t}},Ht=function(e){return e instanceof window.SVGElement||e.ownerSVGElement};function Yt(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 Xt={move_vertex:"commit-move",insert_vertex:"commit-insert",delete_vertex:"commit-delete"},$t={move_vertex:"commit-move",insert_vertex:"commit-delete",delete_vertex:"commit-insert"},Jt={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(Xt[e.type],e.vertexIndex,e.featureId))},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($t[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=Dt(i),u=Rt(s,r);if(u){Ut(a,u.segment.path)[u.localIdx]=n,this._applyUndoAndSync(e,a,o);var c=e.vertecies[e.selectedVertexIndex];c&&this.updateTouchVertexTarget(e,Gt(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=Dt(o),s=Rt(a,r);s&&(Ut(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=Dt(i),u=Rt(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 Yt(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)?Yt(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&&(Ut(a,u.segment.path).splice(u.localIdx,0,n),this._applyUndoAndSync(e,a,o),this.updateTouchVertexTarget(e,Gt(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)}},qt=r(722),Kt=r(473);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){(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 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}var tr=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(e){var n=(0,Kt.$)(t,r),o=n.editActive,i=n.editHalo,a=n.editVertex;(0,qt.ZP)(e,{editActive:o,editHalo:i,editVertex:a})}},rr={addTouchVertexTarget:function(e){e.touchVertexTarget=(0,qt.DD)(e.container),tr(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||Ht(t.target.parentNode)||e._ignorePointermoveDeselect||this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,coordPath:null})},onTouchStart:function(){},onTouchMove:function(){},onTouchEnd:function(){},onTouchend:function(e){kt(Ot(this.map)),null!=e&&e.featureId&&(this.syncVertices(e),e._touchMoved&&e._moveStartPosition&&void 0!==e._moveStartIndex&&this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._moveStartIndex,previousPosition:e._moveStartPosition}),e._moveStartPosition=null,e._moveStartIndex=void 0,e._touchMoved=!1)},onTap:function(e,t){var r,n,o=Ot(this.map);o&&Lt(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=Bt(s,a);this.changeMode(e,{selectedVertexIndex:u,selectedVertexType:"vertex",coordPath:a})}else"midpoint"===i?this.insertVertex(Qt(Qt({},e),{},{selectedVertexIndex:this.getVertexIndexFromMidpoint(e,a),selectedVertexType:"midpoint"})):this.clickNoTarget(e)},onTouchstart:function(e,t){kt(Ot(this.map));var r,n=this.getVerticies(e.featureId),o=null==n?void 0:n[e.selectedVertexIndex];if(o&&Ht(t.target.parentNode)){e._moveStartPosition=function(e){if(Array.isArray(e))return zt(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 zt(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)?zt(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=t.touches[0].clientX,a=t.touches[0].clientY,s=window.getComputedStyle(e.touchVertexTarget);e.deltaTarget={x:i-Number.parseFloat(s.left),y:a-Number.parseFloat(s.top)};var u=this.map.project(o);e.deltaVertex={x:i/e.scale-u.x,y:a/e.scale-u.y}}},onTouchmove:function(e,t){if(!(e.selectedVertexIndex<0)&&Ht(t.target.parentNode)){e._touchMoved=!0;var r=t.touches[0].clientX,n=t.touches[0].clientY,o={x:r/e.scale-e.deltaVertex.x,y:n/e.scale-e.deltaVertex.y},i=this.map.unproject(o);if(Ft(e)){var a=Ot(this.map);At(a,this.map,o),i=Tt(a)||i}this.moveVertex(e,i),this.updateTouchVertexTarget(e,{x:r-e.deltaTarget.x,y:n-e.deltaTarget.y})}}},nr=r(9);function or(e){return or="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},or(e)}function ir(e){return function(e){if(Array.isArray(e))return lr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||cr(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 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 sr(e,t,r){return(t=function(e){var t=function(e){if("object"!=or(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=or(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==or(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ur(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)||cr(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 cr(e,t){if(e){if("string"==typeof e)return lr(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)?lr(e,t):void 0}}function lr(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 dr={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},pr={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=ur(this.getVertexOrMidpoint(e,t),2),n=r[0],o=r[1];n<0||!o||this.changeMode(e,function(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){sr(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}({selectedVertexIndex:n,selectedVertexType:o},"vertex"===o&&{coordPath:this.getCoordPath(e,n)}))},getOffset:function(e,t){var r=this.map.project(e),n=null!=t&&t.shiftKey?Et.WQ.nudgeAmount:Et.WQ.stepAmount,o=ur(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})},getNewCoord:function(e,t){return this.getOffset(Nt(this.getFeature(e.featureId))[e.selectedVertexIndex],t)},getOffsetByDelta:function(e,t,r,n){var o=this.map.project(e),i=n?Et.WQ.stepAmount:Et.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=Ot(this.map);if(Ft(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:Et.vf.snapRadius}(i)+1,s=this.map.project(n);return e._isSnapped=!1,Lt(i,this.map),this.map.unproject({x:s.x+t*a,y:s.y+r*a})}var u=o();return Ft(e)&&i&&(At(i,this.map,this.map.project(u)),Ct(i))?(e._isSnapped=!0,Tt(i)):(e._isSnapped=!1,u)},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=ir(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=cr(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}}}}(Dt(i));try{for(d.s();!(r=d.n()).done;){var p=r.value,f=p.closed?p.length:p.length-1;if(n<l+f){u=p,c=n-l+1,s=p.start+c;break}l+=f}}catch(e){d.e(e)}finally{d.f()}u&&(Ut(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=Dt(o),s=Rt(a,e.selectedVertexIndex);s&&(Ut(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=Dt(t),n=Rt(r,e.selectedVertexIndex);if(n){var o=n.segment,i=o.closed?nr.n8.Polygon:nr.n8.LineString;if(!(o.length<=i)){var a=ir(e.vertecies[e.selectedVertexIndex]),s=e.selectedVertexIndex,u=[].concat(ir(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})}}}}},fr=r(704);function hr(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)||mr(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 yr(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=mr(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 gr(e){return function(e){if(Array.isArray(e))return vr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||mr(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 mr(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}}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}var br={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=Dt(r),o=Rt(n,t);if(!o)return"0";var i=o.segment,a=o.localIdx;return[].concat(gr(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=Dt(t);if(null==r||!r.length||!n.length)return[];var o,i=[],a=yr(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,p=hr(r[l],2),f=p[0],h=p[1],y=hr(r[d],2),g=y[0],m=y[1];i.push([(f+g)/2,(h+m)/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(gr(e.vertecies.map(i)),gr(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,fr.cj)(s,a,t);return[u,u<e.vertecies.length?"vertex":"midpoint"]},getVertexIndexFromMidpoint:function(e,t){var r,n=this.getFeature(e.featureId),o=Dt(n),i=t.split(".").map(Number),a=0,s=yr(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 xr(e,t){if(e){if("string"==typeof e)return Sr(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)?Sr(e,t):void 0}}function Sr(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 wr=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),Er={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},_r=new Set(["INPUT","TEXTAREA","BUTTON","SELECT","A"]),Pr=function(e){var t,r=document.activeElement;return!(!r||r===document.body)&&(null===(t=e.container)||void 0===t||!t.contains(r))&&(_r.has(r.tagName)||r.isContentEditable||r.hasAttribute("tabindex"))},Ir={onKeydown:function(e,t){Pr(e)||(e.interfaceType="keyboard",this.hideTouchVertexIndicator(e)," "!==t.key?wr.has(t.key)&&e.selectedVertexIndex>=0?this.handleArrowKey(e,t):"Escape"!==t.key?function(e){return"z"===e.key&&(e.metaKey||e.ctrlKey)&&!e.shiftKey}(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=Ot(this.map);n&&Lt(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 Sr(e)}(n=i)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||xr(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)||xr(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.")}()}(Er[t.key],2),i=o[0],a=o[1];return this.resolveSnapTarget(e,i,a,r,function(){return n.getNewCoord(e,t)})},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))},onKeyup:function(e,t){Pr(e)||(e.interfaceType="keyboard",wr.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 Mr(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 Or="draw.vertexselection",Cr={onMouseDown:function(e,t){var r,n;kt(Ot(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=Bt(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 Mr(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 Mr(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)?Mr(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),p=Bt(d,a);e._insertedVertexIndex=p,e._isInsertingVertex=!0,e.selectedVertexIndex=this.getVertexIndexFromMidpoint(e,a),e.selectedVertexType="vertex",e.coordPath=null,this.map.fire(Or,{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(Or,{index:r,numVertecies:e.vertecies.length})}ot.onClick.call(this,e,t)},onMouseUp:function(e,t){kt(Ot(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(Or,{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=Ot(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),Ft(e)&&null!=n&&n.status){if(null!==(r=e.selectedCoordPaths)&&void 0!==r&&r.length&&e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation(),At(n,this.map,t.point);var o=Tt(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 Tr(e){return Tr="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},Tr(e)}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 Lr(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"!=Tr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Tr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Tr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Fr="draw.nudgevertex",jr=Lr(Lr(Lr(Lr(Lr(Lr(Lr(Lr({},St.modes.direct_select),Jt),rr),pr),br),Ir),Cr),{},{onSetup:function(e){var t,r,n,o=this,i=St.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);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);var s=Ot(this.map);if(s&&Lt(s,this.map),"touch"===i.interfaceType&&i.selectedVertexIndex>=0&&"vertex"===i.selectedVertexType){var u=i.vertecies[i.selectedVertexIndex];u&&setTimeout(function(){o.updateTouchVertexTarget(i,Gt(o.map.project(u),i.scale))},0)}return i._ignorePointermoveDeselect=!0,setTimeout(function(){i._ignorePointermoveDeselect=!1},100),i},setupEventListeners:function(e){var t=this,r=function(r){return function(n){return r.call(t,e,n)}},n=this.handlers={keydown:r(this.onKeydown),keyup:r(this.onKeyup),pointerdown:r(this.onPointerevent),pointermove:r(this.onPointerevent),pointerup:r(this.onPointerevent),click:r(this.onButtonClick),touchstart:r(this.onTouchstart),touchmove:r(this.onTouchmove),touchend:r(this.onTouchend),selectionchange:r(this.onSelectionChange),scalechange:r(this.onScaleChange),update:r(this.onUpdate),move:r(this.onMove),interfacetypechange:r(this.onInterfaceTypeChange),nudgevertex:r(this.onNudgeVertex)};window.addEventListener("keydown",n.keydown,{capture:!0}),window.addEventListener("keyup",n.keyup,{capture:!0}),window.addEventListener("click",n.click),e.container.addEventListener("pointerdown",n.pointerdown),e.container.addEventListener("pointermove",n.pointermove),e.container.addEventListener("pointerup",n.pointerup),e.container.addEventListener("touchstart",n.touchstart,{passive:!1}),e.container.addEventListener("touchmove",n.touchmove,{passive:!1}),e.container.addEventListener("touchend",n.touchend,{passive:!1}),this.map.on("draw.selectionchange",n.selectionchange),this.map.on("draw.scalechange",n.scalechange),this.map.on("draw.update",n.update),this.map.on("move",n.move),this.map.on("draw.interfacetypechange",n.interfacetypechange),this.map.on(Fr,n.nudgevertex)},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("draw.vertexselection",{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?Gt(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?Gt(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,Gt(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,Gt(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",Lr(Lr({},e),t))},onStop:function(e){this.map._drawEditContainer=null,this.map._editingFeatureId=null;var t=this.handlers;e.container.removeEventListener("pointerdown",t.pointerdown),e.container.removeEventListener("pointermove",t.pointermove),e.container.removeEventListener("pointerup",t.pointerup),e.container.removeEventListener("touchstart",t.touchstart),e.container.removeEventListener("touchmove",t.touchmove),e.container.removeEventListener("touchend",t.touchend),this.map.off("draw.selectionchange",t.selectionchange),this.map.off("draw.scalechange",t.scalechange),this.map.off("draw.update",t.update),this.map.off("move",t.move),this.map.off("draw.interfacetypechange",t.interfacetypechange),this.map.off(Fr,t.nudgevertex),this.map.dragPan.enable(),window.removeEventListener("click",t.click),window.removeEventListener("keydown",t.keydown,{capture:!0}),window.removeEventListener("keyup",t.keyup,{capture:!0}),this.hideTouchVertexIndicator(e)}});function Vr(e){return Vr="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},Vr(e)}function Nr(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}function Rr(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 Ur(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Rr(Object(r),!0).forEach(function(t){Br(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Rr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Br(e,t,r){return(t=function(e){var t=function(e){if("object"!=Vr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Vr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Vr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Gr=r(520);function Hr(e){return Hr="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},Hr(e)}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 Xr(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){$r(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 $r(e,t,r){return(t=function(e){var t=function(e){if("object"!=Hr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Hr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Hr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Jr=function(e){return Xr(Xr({},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,Gr.$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=Ot(this.map);if(Ft(e)&&Ct(u))a=function(e,t){var r=Tt(t);return r?It(It({},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=Ot(this.map),c=Ft(e)&&function(e,t){var r=Tt(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 qr(e){return qr="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},qr(e)}function Kr(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 Wr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Kr(Object(r),!0).forEach(function(t){zr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Kr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function zr(e,t,r){return(t=function(e){var t=function(e){if("object"!=qr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=qr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==qr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Zr(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 Qr=function(e){return Wr(Wr(Wr({},(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 Zr(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 Zr(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)?Zr(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 en(e){return en="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},en(e)}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 rn(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){nn(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 nn(e,t,r){return(t=function(e){var t=function(e){if("object"!=en(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=en(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==en(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function on(e){return on="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},on(e)}function an(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 sn(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?an(Object(r),!0).forEach(function(t){un(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):an(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function un(e,t,r){return(t=function(e){var t=function(e){if("object"!=on(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=on(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==on(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var cn=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 sn(sn(sn(sn(sn(sn(sn({},e),function(e){var t=e.ParentMode,r=e.featureProp,n=e.excludeFeatureIdFromSetup;return{onSetup:function(e){var o=this,i=this.map,a=n?Ur(Ur({},e),{},{featureId:null}):e,s=Ur(Ur({},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 p=u.querySelector("#".concat(c));s.vertexMarker=p,["touch","keyboard"].includes(d)?this._showCrossHair(s):this._hideCrossHair(s);var f={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(f).forEach(function(e){var t,r,n=Nr(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=Nr(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){t.onStop.call(this,e),this._listeners.forEach(function(e){var t=Nr(e,3),r=t[0],n=t[1],o=t[2];return r.removeEventListener?r.removeEventListener(n,o):r.off(n,o)}),this._hideCrossHair(e),this.map.fire("draw.interfacetypechange",{interfaceType:e.interfaceType})}}}(l)),Jr(l)),Qr(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(Ft(e)){var n=Ot(this.map);At(n,this.map,r.point);var o=Tt(n);o&&(r=rn(rn({},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)){Ft(e)&&function(e,t){if(!e||!t||!e.status)return!1;var r=t.getCenter(),n=t.project(r);e.snapToClosestPoint({point:n,lngLat:r})}(Ot(this.map),this.map);var r=Ot(this.map),n=Ft(e)&&Tt(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))},ln=cn(St.modes.draw_polygon,{featureProp:"polygon",geometryType:"Polygon",getCoords:function(e){return e.coordinates[0]},validateClick:function(e){return(0,fr.jK)(e.coordinates)},getPlacedCoords:function(e){return e.geometry.coordinates[0].slice(0,-2)}}),dn=cn(St.modes.draw_line_string,{featureProp:"line",geometryType:"LineString",getCoords:function(e){return e.coordinates},validateClick:function(e){return(0,fr.DF)(e.coordinates)},excludeFeatureIdFromSetup:!0,finishOnInvalidClick:!0,getPlacedCoords:function(e){return e.geometry.coordinates.slice(0,-1)}});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 fn=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]},hn=function(e,t){return{id:"fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","false"]],paint:{"fill-color":fn(e,"fill",t.shapeFill)}}},yn=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"},paint:{"line-color":fn(e,"stroke",t.shapeStroke),"line-width":t.strokeWidth}}},gn=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}}},mn=function(e,t){return{id:"vertex",type:"circle",filter:["all",["==","$type","Point"],["in","meta","vertex","draw-vertex"]],paint:{"circle-radius":t,"circle-color":e}}},vn=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}}},bn=function(e,t){return{id:"vertex-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":t,"circle-color":e}}},xn=function(e,t){return{id:"midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":t,"circle-color":e}}},Sn=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}}},wn=function(e,t){return{id:"midpoint-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":t,"circle-color":e}}},En=function(e){return{id:"circle",type:"line",filter:["==","id","circle"],paint:{"line-color":e,"line-width":2,"line-opacity":.8}}},_n=function(e){var t,r,n,o,i,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=(0,Kt.$)(e,a),u=Et.F0.vertexRadius,c=Et.F0.midpointRadius,l=Et.F0.vertexHaloRadius,d=Et.F0.midpointHaloRadius;return[hn(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}}),yn(e,s),(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}}),gn(s.editStroke),xn(s.editMidpoint,c),Sn(s.editHalo,s.editActive,d),wn(s.editMidpoint,c),mn(s.editVertex,u),vn(s.editHalo,s.editActive,l),bn(s.editVertex,u),En(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}}]},Pn=6371008.8,In={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:39.37*Pn,kilometers:6371.0088,kilometres:6371.0088,meters:Pn,metres:Pn,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:Pn/1852,radians:1,yards:6967335.223679999};function Mn(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 On(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(!kn(e[0])||!kn(e[1]))throw new Error("coordinates must contain numbers");return Mn({type:"Point",coordinates:e},t,r)}function Cn(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 Mn({type:"LineString",coordinates:e},t,r)}function Tn(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 An(e){return e%(2*Math.PI)*180/Math.PI}function Ln(e){return e%360*Math.PI/180}function kn(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function Fn(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 jn(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 Vn=function(e,t,r){void 0===r&&(r={});var n=Fn(e),o=Fn(t),i=Ln(o[1]-n[1]),a=Ln(o[0]-n[0]),s=Ln(n[1]),u=Ln(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=In[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 Nn(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 Dn(e,t,r,n={}){const o=Nn(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),p=(0,ke.nv)(c);return void 0!==o[2]?(0,ke.zx)([d,p,o[2]],n.properties):(0,ke.zx)([d,p],n.properties)}function Rn(e,t,r){if(null!==e)for(var n,o,i,a,s,u,c,l,d=0,p=0,f=e.type,h="FeatureCollection"===f,y="Feature"===f,g=h?e.features.length:1,m=0;m<g;m++){s=(l=!!(c=h?e.features[m].geometry:y?e.geometry:e)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v<s;v++){var b=0,x=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var S=a.type;switch(d=!r||"Polygon"!==S&&"MultiPolygon"!==S?0:1,S){case null:break;case"Point":if(!1===t(u,p,m,b,x))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],p,m,b,x))return!1;p++,"MultiPoint"===S&&b++}"LineString"===S&&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],p,m,b,x))return!1;p++}"MultiLineString"===S&&b++,"Polygon"===S&&x++}"Polygon"===S&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(x=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],p,m,b,x))return!1;p++}x++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===Rn(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Un(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 Bn(e,t){!function(e,t){var r,n,o,i,a,s,u,c,l,d,p=0,f="FeatureCollection"===e.type,h="Feature"===e.type,y=f?e.features.length:1;for(r=0;r<y;r++){for(s=f?e.features[r].geometry:h?e.geometry:e,c=f?e.features[r].properties:h?e.properties:{},l=f?e.features[r].bbox:h?e.bbox:void 0,d=f?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,p,c,l,d))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],p,c,l,d))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,p,c,l,d))return!1;p++}}(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(Mn(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(Mn({type:a,coordinates:c},n),r,u))return!1}})}function Gn(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={}),Mn({type:"MultiLineString",coordinates:e},t,r)}(n,o):Cn(n[0],o)}var Hn=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=Nn(t),i=Nn(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 Yn(e,t,r,n){void 0===n&&(n={});var o=Fn(e),i=Ln(o[0]),a=Ln(o[1]),s=Ln(r),u=function(e,t){void 0===t&&(t="kilometers");var r=In[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 On([An(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),An(c)],n.properties)}const Xn=function(e){if(!e)throw new Error("geojson is required");var t=[];return Bn(e,function(e){!function(e,t){var r=[],n=e.geometry;if(null!==n){switch(n.type){case"Polygon":r=jn(n);break;case"LineString":r=[jn(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=Cn([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)}),Tn(t)};var $n=r(945);function Jn(e,t){var r=jn(e),n=jn(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],p=(d-c)*(a-o)-(l-u)*(s-i);if(0===p)return null;var f=((l-u)*(i-c)-(d-c)*(o-u))/p,h=((a-o)*(i-c)-(s-i)*(o-u))/p;return f>=0&&f<=1&&h>=0&&h<=1?On([o+f*(a-o),i+f*(s-i)]):null}const qn=function(e,t){var r={},n=[];if("LineString"===e.type&&(e=Mn(e)),"LineString"===t.type&&(t=Mn(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=Jn(e,t);return o&&n.push(o),Tn(n)}var i=$n();return i.load(Xn(t)),Un(Xn(e),function(e){Un(i.search(e),function(t){var o=Jn(e,t);if(o){var i=jn(o).join(",");r[i]||(r[i]=!0,n.push(o))}})}),Tn(n)},Kn=function(e,t,r){void 0===r&&(r={});var n=On([1/0,1/0],{dist:1/0}),o=0;return Bn(e,function(e){for(var i=jn(e),a=0;a<i.length-1;a++){var s=On(i[a]);s.properties.dist=Vn(t,s,r);var u=On(i[a+1]);u.properties.dist=Vn(t,u,r);var c=Vn(s,u,r),l=Math.max(s.properties.dist,u.properties.dist),d=Hn(s,u),p=Yn(t,l,d+90,r),f=Yn(t,l,d-90,r),h=qn(Cn([p.geometry.coordinates,f.geometry.coordinates]),Cn([s.geometry.coordinates,u.geometry.coordinates])),y=null;h.features.length>0&&((y=h.features[0]).properties.dist=Vn(t,y,r),y.properties.location=o+Vn(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 Wn=6371008.8,zn={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:Wn,metres:Wn,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function Zn(e){return e%(2*Math.PI)*180/Math.PI}function Qn(e){return e%360*Math.PI/180}function eo(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function to(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 ro=function(e,t,r){void 0===r&&(r={});var n=to(e),o=to(t),i=Qn(o[1]-n[1]),a=Qn(o[0]-n[0]),s=Qn(n[1]),u=Qn(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=zn[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)},no=function(e,t){var r=function(e,t,r,n){void 0===n&&(n={});var o=to(e),i=Qn(o[0]),a=Qn(o[1]),s=Qn(r),u=function(e,t){void 0===t&&(t="kilometers");var r=zn[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(!eo(e[0])||!eo(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)}([Zn(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),Zn(c)],n.properties)}(e,ro(e,t)/2,Hn(e,t));return r};var oo=function(){return oo=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},oo.apply(this,arguments)},io=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=oo(oo({},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 Vn(On(e),On(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 p=e.geometry.coordinates;for(u=[],c=0;c<p.length;c++){var f=p[c];for(var n in d=!1,t)if(this.isPointSnapped(f,t[n])){d=!0,u.push(t[n]);break}0==d&&u.push(f)}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=Vn(On([r.lng,r.lat]),On([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(Dn(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=Tn(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(Tn([])))}),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=[],Rn(e,function(e){n.push(e)}),n),i=[];if(o.map(function(e){var n=Vn(On(e),On([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(Cn(e))});break;case"Polygon":var o=Gn(e.geometry);n.push(o);break;case"MultiPolygon":Gn(e.geometry).coodinates.map(function(e){n.push(Cn(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(Xn(e).features)});var i=[];if(o.map(function(e){var n=no(e.geometry.coordinates[0],e.geometry.coordinates[1]),o=Vn(n,On([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=Kn(n[i],On([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 ao=io;var so="snap-helper-circle",uo="mapbox-gl-draw-hot";function co(e){return co="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},co(e)}function lo(e,t){!function r(){var n=e();null!==n&&(n?t(n):requestAnimationFrame(r))}()}function po(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"===co(e)&&Array.isArray(e.features)?e:{type:"FeatureCollection",features:[]}},configurable:!0})}}var fo=new Set(["draw_polygon","draw_line","edit_vertex"]);function ho(e,t,r,n){if(e._snapInstance||e._snapCreating)return e._snapInstance;e._snapCreating=!0,function(e){e.getLayer(so)&&e.removeLayer(so),e.getSource(so)&&e.removeSource(so)}(e),po(r);var o=new ao({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&&fo.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 yo(e){return yo="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},yo(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 mo(e,t,r){return(t=function(e){var t=function(e){if("object"!=yo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=yo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==yo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function vo(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?Et.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,p=void 0===d?function(){}:d,f=r.colors,h=void 0===f?{}:f,y={layers:o,radius:a,rules:u,status:l,onSnapped:p};return function(e){if(!ao.prototype.__snapPatched){ao.prototype.__snapPatched=!0;var t=ao.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(so)&&this.map.setLayoutProperty(so,"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||Et.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))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?go(Object(r),!0).forEach(function(t){mo(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}({vertex:Et.lm.snapVertex,midpoint:Et.lm.snapMidpoint,edge:Et.lm.snapEdge},h)),function(e,t,r){e.on("style.load",function(){lo(function(){return e._removed?null:e.getSource(uo)},function(n){po(n),function(e){var t;e.getSource(so)||e.addSource(so,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(so)||e.addLayer({id:so,type:"fill",source:so,paint:{"fill-color":["get","color"]},layout:{visibility:null!==(t=e._snapInstance)&&void 0!==t&&t.status?"visible":"none"}})}(e),e._snapInstance||ho(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(so)){e.setLayoutProperty(so,"visibility","none");var t=e._snapInstance;null!=t&&t.status&&e.setLayoutProperty(so,"visibility","visible")}})}(e),lo(function(){return e._removed?null:e.getSource(uo)},function(r){return ho(e,t,r,y)}),e._snapInstance}var bo=r(610);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 So(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 wo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?So(Object(r),!0).forEach(function(t){Eo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):So(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Eo(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 _o=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;St.constants.classes.CONTROL_BASE="maplibregl-ctrl",St.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",St.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var l=wo(wo({},St.modes),{},{disabled:wt,edit_vertex:jr,draw_polygon:ln,draw_line:dn}),d=n._mapboxDrawInstance;d?Object.assign(d.modes,l):(d=new St({modes:l,styles:_n(r,u),displayControlsDefault:!1,userProperties:!0,defaultMode:"disabled"}),c.addControl(d),n._mapboxDrawInstance=d);var p=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 f=n.undoStack;f||(f=(0,bo.B)(function(e){return c.fire("draw.undochange",{length:e})}),n.undoStack=f),c._undoStack=f;var h=(0,Kt.$)(r,u);vo(c,d,{layers:a,radius:null!==(t=u.snapRadius)&&void 0!==t?t:Et.vf.snapRadius,rules:["vertex","edge"],colors:{vertex:h.snapVertex,edge:h.snapEdge}});var y=function(e){c._drawCurrentMapStyle=e,c.once("idle",function(){var t;!function(e,t){_n(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).forEach(function(t){Object.entries(t.paint).forEach(function(r){var n=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 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}}(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.")}()}(r,2),o=n[0],i=n[1];e.getLayer("".concat(t.id,".cold"))&&e.setPaintProperty("".concat(t.id,".cold"),o,i),e.getLayer("".concat(t.id,".hot"))&&e.setPaintProperty("".concat(t.id,".hot"),o,i)})})}(c,e,u);var r=null===(t=c._drawEditContainer)||void 0===t?void 0:t.querySelector("[data-im-draw-touch-target]");tr(r,e,u)})};i.on(o.MAP_SET_STYLE,y);var g=function(e){c.fire("draw.scalechange",{scale:Et.$y[e]})};return i.on(o.MAP_SET_SIZE,g),{draw:d,remove:function(){p.remove(),i.off(o.MAP_SET_STYLE,y),i.off(o.MAP_SET_SIZE,g),d.changeMode("disabled"),n.draw=null}}},Po="draw.create",Io="draw.update",Mo="draw.modechange",Oo="draw.editfinish",Co="draw.cancel",To="draw.vertexselection",Ao="draw.vertexchange",Lo="draw.undochange",ko="draw.geometrychange",Fo="draw.interfacetypechange",jo="draw.placementblocked",Vo="styledata",No=r(360),Do=r(788),Ro=r(715);function Uo(e){return Uo="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},Uo(e)}function Bo(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 Go(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Bo(Object(r),!0).forEach(function(t){Ho(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Bo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ho(e,t,r){return(t=Xo(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Yo(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,Xo(n.key),n)}}function Xo(e){var t=function(e){if("object"!=Uo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Uo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Uo(t)?t:t+""}var $o=function(e){return{type:"Feature",geometry:{type:"Polygon",coordinates:e}}},Jo=function(e){return{type:"Feature",geometry:{type:"LineString",coordinates:e}}},qo=function(e,t){var r,n,o,i,a,s,u;return"draw_polygon"===e?{feature:$o(t),numVertices:(null!==(r=null===(n=t[0])||void 0===n?void 0:n.length)&&void 0!==r?r:1)-1}:"draw_line"===e?{feature:Jo(t),numVertices:(null!==(o=null==t?void 0:t.length)&&void 0!==o?o:1)-1}:"edit_vertex"===e?Array.isArray(null===(i=t[0])||void 0===i?void 0:i[0])?{feature:$o(t),numVertices:null!==(a=null===(s=t[0])||void 0===s?void 0:s.length)&&void 0!==a?a:0}:{feature:Jo(t),numVertices:null!==(u=null==t?void 0:t.length)&&void 0!==u?u:0}:null},Ko=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;var a=_o({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,Do.De)({onChange:function(e,t){i._applyStrokeInvalid(e),"edit_vertex"===i._draw.getMode()&&i._bus.emit(No.k.VALIDITY_CHANGE,{valid:!e,reason:t})}}),this._liveDrawChecks=(0,Ro.O)({onStrokeChange:function(e,t){return i._liveStroke.set(e,t)},onPlaceChange:function(e,t){return i._bus.emit(No.k.CAN_PLACE_CHANGE,{canPlace:!e,reason:t})}}),this._mapHandlers={create:function(e){return i._bus.emit(No.k.CREATE,e.features[0])},editfinish:function(e){return i._bus.emit(No.k.EDIT_FINISH,e.features[0])},cancel:function(){return i._bus.emit(No.k.CANCEL)},vertexselection:function(e){return i._bus.emit(No.k.VERTEX_SELECTION,Go(Go({},e),{},{numVertices:e.numVertecies}))},vertexchange:function(e){return i._bus.emit(No.k.VERTEX_CHANGE,Go(Go({},e),{},{numVertices:e.numVertecies}))},undochange:function(e){return i._bus.emit(No.k.UNDO_CHANGE,e.length)},update:function(e){return i._bus.emit(No.k.UPDATE,e.features[0])},geometrychange:function(e){null!=e&&e.phase||(i._updateLiveStroke(e),i._currentDrawEvent=e),i._bus.emit(No.k.GEOMETRY_CHANGE,e)},placementblocked:function(e){return i._bus.emit(No.k.PLACEMENT_BLOCKED,e)},interfacetypechange:function(e){return i._bus.emit(No.k.INTERFACE_TYPE_CHANGE,{interfaceType:e.interfaceType})},modechange:function(e){return i._handleModeChange(e)},styledata:function(){return i._handleStyleData()}},this._map.on(Po,this._mapHandlers.create),this._map.on(Oo,this._mapHandlers.editfinish),this._map.on(Co,this._mapHandlers.cancel),this._map.on(To,this._mapHandlers.vertexselection),this._map.on(Ao,this._mapHandlers.vertexchange),this._map.on(Lo,this._mapHandlers.undochange),this._map.on(Io,this._mapHandlers.update),this._map.on(ko,this._mapHandlers.geometrychange),this._map.on(jo,this._mapHandlers.placementblocked),this._map.on(Fo,this._mapHandlers.interfacetypechange),this._map.on(Mo,this._mapHandlers.modechange),this._map.on(Vo,this._mapHandlers.styledata)},t=[{key:"changeMode",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"edit_vertex"===e&&(this._editingFeatureId=null!==(t=r.featureId)&&void 0!==t?t:null),"draw_polygon"!==e&&"draw_line"!==e||(this._liveStroke.set(!1),this._liveDrawChecks.reset()),this._draw.changeMode(e,r),this._handleModeChange({mode:e})}},{key:"_updateLiveStroke",value:function(e){if(null!=e&&e.coordinates){var t=this._draw.getMode(),r=qo(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(Go(Go({},r),{},{context:{mode:t},onGeometryChange:this._geometryValidator})))}}},{key:"getMode",value:function(){return this._draw.getMode()}},{key:"setInterfaceType",value:function(e){this._map.fire(Fo,{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&&this._editingFeatureId)return this._handleModeChange({mode:"disabled"}),void this._map.fire(Oo,{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("draw.nudgevertex",{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:"add",value:function(e){return this._draw.add(e)}},{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=Ot(this._map);null!=t&&t.setSnapStatus&&t.setSnapStatus(e),!e&&t&&(kt(t),this._map.getLayer("snap-helper-circle")&&this._map.setLayoutProperty("snap-helper-circle","visibility","none"))}},{key:"setSnapLayers",value:function(e){var t=Ot(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","edit_vertex"]).has(e.mode)||Lt(Ot(this._map),this._map)}},{key:"_handleStyleData",value:function(){var e,t=this;this._liveStroke.refresh();var r=this._map.getStyle().layers||[];!r.length||null!==(e=r[r.length-1].source)&&void 0!==e&&e.startsWith("mapbox-gl-draw")||r.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(Po,this._mapHandlers.create),this._map.off(Oo,this._mapHandlers.editfinish),this._map.off(Co,this._mapHandlers.cancel),this._map.off(To,this._mapHandlers.vertexselection),this._map.off(Ao,this._mapHandlers.vertexchange),this._map.off(Lo,this._mapHandlers.undochange),this._map.off(Io,this._mapHandlers.update),this._map.off(ko,this._mapHandlers.geometrychange),this._map.off(jo,this._mapHandlers.placementblocked),this._map.off(Fo,this._mapHandlers.interfacetypechange),this._map.off(Mo,this._mapHandlers.modechange),this._map.off(Vo,this._mapHandlers.styledata),this._liveStroke.destroy(),this._liveDrawChecks.destroy(),this._cleanupDraw()}}],t&&Yo(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,p=null,f=null,h=function(){null!=p&&((0,i.WG)(p),p=null),f=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)},g=function(){var e,t;if(f){var r=f,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)}},m=function(){if(p=null,f){var e=f,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,g()}};return{update:function(e){var t=e.feature,r=e.context,n=void 0===r?{}:r,o=e.numVertices,a=e.onGeometryChange;f={feature:t,context:u(u({},n),{},{numVertices:o}),onGeometryChange:a},g(),"function"==typeof a&&null==p&&(p=(0,i.PW)(m))},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},p=function(e,r){e!==i&&(i=e,t(e,null!=r?r:null))},f=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;p(!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 p(!1,null)):(l={feature:t,context:h,onGeometryChange:c},void(null==s&&(s=u(f)))):(d(),void p(!0,y.reason))},set:function(e,t){d(),p(e,null!=t?t:null)},refresh:function(){t(i,null)},destroy:function(){d()}}}}}]);
|