@defra/interactive-map 0.0.31-alpha → 0.0.33-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.
Files changed (131) hide show
  1. package/README.md +2 -2
  2. package/assets/images/bright-ofm-thumb.jpg +0 -0
  3. package/assets/images/dark-ofm-thumb.jpg +0 -0
  4. package/assets/images/road-ofm-thumb.jpg +0 -0
  5. package/assets/templates/add-polygons.njk +143 -0
  6. package/assets/templates/add-symbols.njk +119 -0
  7. package/assets/templates/{map.njk → basic-map.njk} +9 -17
  8. package/assets/templates/button-map.njk +56 -0
  9. package/assets/templates/draw-tools.njk +161 -0
  10. package/assets/templates/marker-panel.njk +91 -0
  11. package/assets/templates/place-marker.njk +104 -0
  12. package/assets/templates/search-control.njk +98 -0
  13. package/assets/templates/select-feature.njk +101 -0
  14. package/assets/templates/style-switcher.njk +87 -0
  15. package/assets/templates/toggle-marker-label.njk +74 -0
  16. package/dist/css/index.css +1 -1
  17. package/dist/esm/im-core.js +1 -1
  18. package/dist/esm/im-shell.js +1 -1
  19. package/dist/umd/im-core.js +1 -1
  20. package/dist/umd/index.js +1 -1
  21. package/docs/api/map-style-config.md +27 -3
  22. package/docs/api.md +55 -0
  23. package/docs/assets/css/docusaurus.scss +22 -6
  24. package/docs/assets/images/add-polygons.jpg +0 -0
  25. package/docs/assets/images/add-symbols.jpg +0 -0
  26. package/docs/assets/images/hero.png +0 -0
  27. package/docs/assets/images/place-marker.jpg +0 -0
  28. package/docs/assets/images/screenshot.jpg +0 -0
  29. package/docs/examples/add-marker-with-panel.mdx +1 -1
  30. package/docs/examples/add-polygons.mdx +225 -0
  31. package/docs/examples/add-symbols.mdx +177 -0
  32. package/docs/examples/{draw.mdx → draw-tools.mdx} +2 -2
  33. package/docs/examples/index.mdx +38 -2
  34. package/docs/examples/place-marker.mdx +151 -0
  35. package/docs/plugins/datasets.md +144 -96
  36. package/docs/plugins/interact.md +1 -4
  37. package/docusaurus.config.cjs +5 -2
  38. package/govuk-prototype-kit.config.json +52 -2
  39. package/package.json +1 -1
  40. package/plugins/beta/datasets/dist/css/index.css +1 -2
  41. package/plugins/beta/datasets/dist/esm/im-datasets-ml-adapter.js +1 -1
  42. package/plugins/beta/datasets/dist/esm/im-datasets-plugin.js +1 -1
  43. package/plugins/beta/datasets/dist/umd/im-datasets-ml-adapter.js +1 -1
  44. package/plugins/beta/datasets/dist/umd/im-datasets-plugin.js +1 -1
  45. package/plugins/beta/datasets/dist/umd/index.js +1 -1
  46. package/plugins/beta/datasets/src/adapters/maplibre/registry/mapLibreDataset.js +27 -9
  47. package/plugins/beta/datasets/src/adapters/maplibre/registry/mapLibreDataset.test.js +46 -4
  48. package/plugins/beta/datasets/src/api/setFeatureVisibility.js +10 -1
  49. package/plugins/beta/datasets/src/api/setFeatureVisibility.test.js +48 -6
  50. package/plugins/beta/datasets/src/components/LayersMenu/Layers.module.scss +12 -12
  51. package/plugins/beta/datasets/src/reducers/datasetsToMenu.js +11 -6
  52. package/plugins/beta/datasets/src/reducers/datasetsToMenu.test.js +49 -0
  53. package/plugins/beta/datasets/src/reducers/mappedDatasetsReducer.js +8 -1
  54. package/plugins/beta/datasets/src/reducers/pluginState.js +1 -1
  55. package/plugins/beta/datasets/src/registry/dataset.js +7 -3
  56. package/plugins/beta/datasets/src/registry/dataset.test.js +14 -0
  57. package/plugins/beta/datasets/src/registry/dynamicGeoJson.js +1 -1
  58. package/plugins/beta/draw-es/dist/esm/im-draw-es-plugin.js +1 -1
  59. package/plugins/beta/draw-es/src/api/addFeature.js +12 -3
  60. package/plugins/beta/draw-es/src/events.js +8 -3
  61. package/plugins/beta/draw-es/src/events.test.js +2 -0
  62. package/plugins/beta/draw-es/src/graphic.js +26 -2
  63. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  64. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  65. package/plugins/beta/draw-ml/src/DrawInit.jsx +19 -0
  66. package/plugins/beta/draw-ml/src/api/newLine.js +1 -0
  67. package/plugins/beta/draw-ml/src/api/newPolygon.js +1 -0
  68. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +52 -37
  69. package/plugins/beta/draw-ml/src/modes/editVertex/touchHandlers.js +1 -1
  70. package/plugins/beta/draw-ml/src/modes/editVertex/vertexOperations.js +5 -4
  71. package/plugins/beta/draw-ml/src/modes/editVertexMode.js +53 -21
  72. package/plugins/beta/draw-ol/dist/esm/DrawMode.js +1 -1
  73. package/plugins/beta/draw-ol/dist/esm/EditMode.js +1 -1
  74. package/plugins/beta/draw-ol/dist/esm/im-draw-ol-plugin.js +1 -1
  75. package/plugins/beta/draw-ol/src/core/OLDrawManager.js +3 -0
  76. package/plugins/beta/draw-ol/src/draw/DrawMode.js +57 -49
  77. package/plugins/beta/draw-ol/src/draw/drawInput.js +76 -32
  78. package/plugins/beta/draw-ol/src/edit/EditMode.js +4 -4
  79. package/plugins/beta/draw-ol/src/edit/keyboardHandler.js +4 -2
  80. package/plugins/beta/draw-ol/src/manifest.js +5 -1
  81. package/plugins/beta/draw-ol/src/reducer.js +1 -1
  82. package/plugins/beta/draw-ol/src/snap/snapEngine.js +75 -31
  83. package/plugins/beta/draw-ol/src/snap/snapGeometry.js +23 -46
  84. package/plugins/beta/draw-ol/src/snap/snapInteraction.js +30 -29
  85. package/plugins/beta/draw-ol/src/snap/snapManager.js +10 -1
  86. package/plugins/beta/draw-ol/src/utils/geometryHelpers.js +9 -3
  87. package/plugins/beta/draw-ol/src/utils/olCoords.js +2 -2
  88. package/plugins/beta/draw-ol/src/utils/spatial.js +4 -8
  89. package/plugins/beta/map-styles/src/mapStyles.scss +41 -41
  90. package/plugins/interact/dist/esm/im-interact-plugin.js +1 -1
  91. package/plugins/interact/dist/umd/im-interact-plugin.js +1 -1
  92. package/plugins/interact/dist/umd/index.js +1 -1
  93. package/plugins/interact/src/InteractInit.jsx +1 -3
  94. package/plugins/interact/src/InteractInit.test.js +0 -2
  95. package/plugins/interact/src/events.test.js +1 -1
  96. package/plugins/interact/src/hooks/useCrossHairVisibility.js +4 -10
  97. package/plugins/interact/src/hooks/useCrossHairVisibility.test.js +5 -10
  98. package/plugins/interact/src/hooks/useHighlightSync.js +1 -10
  99. package/plugins/interact/src/hooks/useHighlightSync.test.js +2 -21
  100. package/plugins/interact/src/hooks/useInteractionHandlers.js +5 -11
  101. package/plugins/interact/src/hooks/useInteractionHandlers.test.js +5 -25
  102. package/plugins/interact/src/reducer.js +4 -22
  103. package/plugins/interact/src/reducer.test.js +11 -39
  104. package/plugins/search/dist/css/index.css +5 -2
  105. package/plugins/search/src/components/Form/Form.module.scss +5 -2
  106. package/plugins/search/src/search.scss +4 -4
  107. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -1
  108. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +1 -1
  109. package/providers/beta/openlayers/dist/umd/index.js +1 -1
  110. package/providers/beta/openlayers/src/utils/tileLayers.js +29 -2
  111. package/providers/beta/openlayers/src/utils/tileLayers.test.js +53 -1
  112. package/src/App/components/CrossHair/CrossHair.module.scss +8 -8
  113. package/src/App/components/MapButton/MapButton.jsx +14 -10
  114. package/src/App/components/MapButton/MapButton.module.scss +1 -1
  115. package/src/App/components/MapButton/MapButton.test.jsx +1 -1
  116. package/src/App/components/PopupMenu/PopupMenu.test.jsx +79 -0
  117. package/src/App/components/PopupMenu/usePopupMenu.js +61 -12
  118. package/src/App/hooks/useLayoutMeasurements.js +10 -2
  119. package/src/App/hooks/useResizeObserver.js +4 -2
  120. package/src/InteractiveMap/InteractiveMap.js +4 -4
  121. package/src/InteractiveMap/InteractiveMap.test.js +3 -3
  122. package/src/InteractiveMap/behaviourController.js +3 -1
  123. package/src/InteractiveMap/behaviourController.test.js +6 -3
  124. package/src/InteractiveMap/domStateManager.js +2 -0
  125. package/src/config/events.js +21 -3
  126. package/src/types.js +12 -3
  127. package/src/utils/findNextTabStop.js +3 -3
  128. package/src/utils/findNextTabStop.test.js +25 -1
  129. package/webpack.dev.mjs +1 -0
  130. package/docs/assets/images/screens-blue.jpg +0 -0
  131. package/docs/assets/images/screens-white.jpg +0 -0
@@ -1 +1 @@
1
- (this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[966],{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 p(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){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=p,t.lengthToDegrees=function(e,t){return d(p(e,t))},t.bearingToAzimuth=function(e){var t=e%360;return t<0&&(t+=360),t},t.radiansToDegrees=d,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(p(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,p,d=0,f=0,h=e.type,y="FeatureCollection"===h,g="Feature"===h,m=y?e.features.length:1,v=0;v<m;v++){u=(p=!!(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 S=0,E=0;if(null!==(s=p?l.geometries[b]:l)){c=s.coordinates;var w=s.type;switch(d=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(c,f,v,S,E))return!1;f++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,S,E))return!1;f++,"MultiPoint"===w&&S++}"LineString"===w&&S++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-d;i++){if(!1===t(c[n][i],f,v,S,E))return!1;f++}"MultiLineString"===w&&S++,"Polygon"===w&&E++}"Polygon"===w&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(E=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-d;a++){if(!1===t(c[n][i][a],f,v,S,E))return!1;f++}E++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,p,d=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,p=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,d,c,l,p))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],d,c,l,p))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,d,c,l,p))return!1;d++}}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,p=0;return!1!==o(e,function(o,s,d,f,h){if(void 0===u||r>c||f>l||h>p)return u=o,c=r,l=f,p=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),p=.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+p)),Math.min(i,Math.floor(n+(s-u)*l/s+p)),a)}var d=r[n],f=o,h=i;for(t(r,o,n),a(r[i],d)>0&&t(r,o,i);f<h;){for(t(r,f,h),f++,h--;a(r[f],d)<0;)f++;for(;a(r[h],d)>0;)h--}0===a(r[o],d)?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 p(e){return e.maxX-e.minX+(e.maxY-e.minY)}function d(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):d(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||d(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||!d(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 p=Math.min(l+c-1,r);y(e,l,p,u,this.compareMinY);for(var d=l;d<=p;d+=u){var f=Math.min(d+u-1,p);o.children.push(this._build(e,d,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),p=(d=e,f=u,(Math.max(f.maxX,d.maxX)-Math.min(f.minX,d.minX))*(Math.max(f.maxY,d.maxY)-Math.min(f.minY,d.minY))-c);p<i?(i=p,o=c<o?c:o,a=u):p===i&&c<o&&(o=c,a=u)}t=a||t.children[0]}var d,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,p,d=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),p=Math.min(o.maxY,i.maxY),Math.max(0,c-s)*Math.max(0,p-u)),v=l(y)+l(g);m<d?(d=m,n=h,f=v<f?v:f):m===d&&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=p(i)+p(u),l=t;l<r-t;l++){var d=e.children[l];s(i,e.leaf?o(d):d),c+=p(i)}for(var f=r-t-1;f>=t;f--){var h=e.children[f];s(u,e.leaf?o(h):h),c+=p(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 p(e,t,r={}){return i({type:"MultiPoint",coordinates:e},t,r)}function d(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 p(t).geometry;case"MultiLineString":return l(t).geometry;case"MultiPolygon":return d(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=p,t.multiPolygon=d,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,p,d=0,f=0,h=e.type,y="FeatureCollection"===h,g="Feature"===h,m=y?e.features.length:1,v=0;v<m;v++){u=(p=!!(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 S=0,E=0;if(null!==(s=p?l.geometries[b]:l)){c=s.coordinates;var w=s.type;switch(d=!r||"Polygon"!==w&&"MultiPolygon"!==w?0:1,w){case null:break;case"Point":if(!1===t(c,f,v,S,E))return!1;f++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,S,E))return!1;f++,"MultiPoint"===w&&S++}"LineString"===w&&S++;break;case"Polygon":case"MultiLineString":for(n=0;n<c.length;n++){for(i=0;i<c[n].length-d;i++){if(!1===t(c[n][i],f,v,S,E))return!1;f++}"MultiLineString"===w&&S++,"Polygon"===w&&E++}"Polygon"===w&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(E=0,i=0;i<c[n].length;i++){for(a=0;a<c[n][i].length-d;a++){if(!1===t(c[n][i][a],f,v,S,E))return!1;f++}E++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,p,d=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,p=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,d,c,l,p))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],d,c,l,p))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,d,c,l,p))return!1;d++}}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,p=0;return!1!==o(e,function(o,s,d,f,h){if(void 0===u||r>c||f>l||h>p)return u=o,c=r,l=f,p=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}},379(e,t,r){"use strict";r.r(t),r.d(t,{manifest:()=>Ra});var n={};r.r(n),r.d(n,{LAT_MAX:()=>D,LAT_MIN:()=>N,LAT_RENDERED_MAX:()=>R,LAT_RENDERED_MIN:()=>V,LNG_MAX:()=>B,LNG_MIN:()=>U,activeStates:()=>F,classes:()=>M,cursors:()=>O,events:()=>A,geojsonTypes:()=>C,interactions:()=>j,meta:()=>k,modes:()=>T,sources:()=>_,types:()=>I,updateActions:()=>L});var o={};r.r(o),r.d(o,{isActiveFeature:()=>X,isBackspaceKey:()=>Z,isDeleteKey:()=>Q,isDigit1Key:()=>ee,isDigit2Key:()=>te,isDigit3Key:()=>re,isDigitKey:()=>ne,isEnterKey:()=>z,isEscapeKey:()=>W,isFeature:()=>q,isInactiveFeature:()=>H,isOfMetaType:()=>G,isShiftDown:()=>K,isShiftMousedown:()=>Y,isTrue:()=>oe,isVertex:()=>$,noTarget:()=>J});var i={};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}r.r(i),r.d(i,{CommonSelectors:()=>o,ModeHandler:()=>be,StringSet:()=>pe,constrainFeatureMovement:()=>Ot,createMidPoint:()=>vt,createSupplementaryPoints:()=>bt,createVertex:()=>We,doubleClickZoom:()=>St,euclideanDistance:()=>ge,featuresAt:()=>fe,getFeatureAtAndSetCursors:()=>ye,isClick:()=>me,isEventAtCoordinates:()=>Vt,isTap:()=>ve,mapEventToBoundingBox:()=>ce,moveFeatures:()=>It,sortFeatures:()=>ue,stringSetsAreEqual:()=>Kt,theme:()=>qe,toDenseArray:()=>De});var l=new Set(["draw_polygon","draw_line"]),p={SET_MODE:function(e,t){return u(u({},e),{},{mode:t,numVertecies:l.has(t)?0:e.numVertecies})},SET_ACTION:function(e,t){return u(u({},e),{},{action:t.name,actionValid:t.isValid})},SET_FEATURE:function(e,t){return u(u({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature})},SET_SELECTED_VERTEX_INDEX:function(e,t){return u(u({},e),{},{selectedVertexIndex:t.index,numVertecies:t.numVertecies})},TOGGLE_SNAP:function(e){return u(u({},e),{},{snap:!e.snap})},SET_SNAP:function(e,t){return u(u({},e),{},{snap:!!t})},SET_HAS_SNAP_LAYERS:function(e,t){return u(u({},e),{},{hasSnapLayers:!!t})},SET_UNDO_STACK_LENGTH:function(e,t){return u(u({},e),{},{undoStackLength:t})}},d=r(738),f={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_SET_MODE:"app:setmode",APP_REVERT_MODE:"app:revertmode",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_FEATURES:"map:setfeatures",MAP_SET_ACTIVE_FEATURE:"map:setactivefeature",MAP_SELECT_FEATURE:"map:selectfeature",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"};function h(e){return h="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},h(e)}function y(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 g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach(function(t){m(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function m(e,t,r){return(t=function(e){var t=function(e){if("object"!=h(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=h(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==h(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e){var t;return null!==(t=null==e?void 0:e._snapInstance)&&void 0!==t?t:null}function b(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 S(e){return b(e)?{lng:e.snapCoords[0],lat:e.snapCoords[1]}:null}function E(e,t,r){if(!e||!t||!e.status)return!1;var n=t.unproject(r);return e.snapToClosestPoint({point:r,lngLat:n}),!0}function w(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 P(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 x(e){return"function"==typeof(null==e?void 0:e.getSnapEnabled)&&!0===e.getSnapEnabled()}const M={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"},_={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},O={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},I={POLYGON:"polygon",LINE:"line_string",POINT:"point"},C={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"},T={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},A={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"},L={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},k={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},F={ACTIVE:"true",INACTIVE:"false"},j=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],N=-90,V=-85,D=90,R=85,U=-270,B=270;function G(e){return function(t){const r=t.featureTarget;return!!r&&!!r.properties&&r.properties.meta===e}}function Y(e){return!!e.originalEvent&&!!e.originalEvent.shiftKey&&0===e.originalEvent.button}function X(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===F.ACTIVE&&e.featureTarget.properties.meta===k.FEATURE}function H(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===F.INACTIVE&&e.featureTarget.properties.meta===k.FEATURE}function J(e){return void 0===e.featureTarget}function q(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.meta===k.FEATURE}function $(e){const t=e.featureTarget;return!!t&&!!t.properties&&t.properties.meta===k.VERTEX}function K(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function W(e){return"Escape"===e.key||27===e.keyCode}function z(e){return"Enter"===e.key||13===e.keyCode}function Z(e){return"Backspace"===e.key||8===e.keyCode}function Q(e){return"Delete"===e.key||46===e.keyCode}function ee(e){return"1"===e.key||49===e.keyCode}function te(e){return"2"===e.key||50===e.keyCode}function re(e){return"3"===e.key||51===e.keyCode}function ne(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function oe(){return!0}var ie=r(778);const ae={Point:0,LineString:1,MultiLineString:1,Polygon:2};function se(e,t){const r=ae[e.geometry.type]-ae[t.geometry.type];return 0===r&&e.geometry.type===C.POLYGON?e.area-t.area:r}const ue=function(e){return e.map(e=>(e.geometry.type===C.POLYGON&&(e.area=ie.geometry({type:C.FEATURE,property:{},geometry:e.geometry})),e)).sort(se).map(e=>(delete e.area,e))},ce=function(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function le(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)}le.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},le.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},le.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},le.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)},le.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const pe=le,de=[k.FEATURE,k.MIDPOINT,k.VERTEX],fe={click:function(e,t,r){return he(e,t,r,r.options.clickBuffer)},touch:function(e,t,r){return he(e,t,r,r.options.touchBuffer)}};function he(e,t,r,n){if(null===r.map)return[];const o=e?ce(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!==de.indexOf(e.properties.meta)),s=new pe,u=[];return a.forEach(e=>{const t=e.properties.id;s.has(t)||(s.add(t),u.push(e))}),ue(u)}function ye(e,t){const r=fe.click(e,null,t),n={mouse:O.NONE};return r[0]&&(n.mouse=r[0].properties.active===F.ACTIVE?O.MOVE:O.POINTER,n.feature=r[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(n.mouse=O.ADD),t.ui.queueMapClasses(n),t.ui.updateMapClasses(),r[0]}function ge(e,t){const r=e.x-t.x,n=e.y-t.y;return Math.sqrt(r*r+n*n)}function me(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=ge(e.point,t.point);return a<n||a<o&&t.time-e.time<i}function ve(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,ge(e.point,t.point)<n&&t.time-e.time<o}const be=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)}}},Se=((e,t=21)=>(r=t)=>{let n="",o=0|r;for(;o--;)n+=e[Math.random()*e.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function Ee(){return Se()}const we=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||Ee(),this.type=t.geometry.type};we.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},we.prototype.incomingCoords=function(e){this.setCoordinates(e)},we.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},we.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},we.prototype.setProperty=function(e,t){this.properties[e]=t},we.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:C.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},we.prototype.internal=function(e){const t={id:this.id,meta:k.FEATURE,"meta:type":this.type,active:F.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const e in this.properties)t[`user_${e}`]=this.properties[e];return{type:C.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const Pe=we,xe=function(e,t){Pe.call(this,e,t)};(xe.prototype=Object.create(Pe.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},xe.prototype.updateCoordinate=function(e,t,r){this.coordinates=3===arguments.length?[t,r]:[e,t],this.changed()},xe.prototype.getCoordinate=function(){return this.getCoordinates()};const Me=xe,_e=function(e,t){Pe.call(this,e,t)};(_e.prototype=Object.create(Pe.prototype)).isValid=function(){return this.coordinates.length>1},_e.prototype.addCoordinate=function(e,t,r){this.changed();const n=parseInt(e,10);this.coordinates.splice(n,0,[t,r])},_e.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},_e.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},_e.prototype.updateCoordinate=function(e,t,r){const n=parseInt(e,10);this.coordinates[n]=[t,r],this.changed()};const Oe=_e,Ie=function(e,t){Pe.call(this,e,t),this.coordinates=this.coordinates.map(e=>e.slice(0,-1))};(Ie.prototype=Object.create(Pe.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},Ie.prototype.incomingCoords=function(e){this.coordinates=e.map(e=>e.slice(0,-1)),this.changed()},Ie.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},Ie.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])},Ie.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))},Ie.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]]))},Ie.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},Ie.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 Ce=Ie,Te={MultiPoint:Me,MultiLineString:Oe,MultiPolygon:Ce},Ae=(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)},Le=function(e,t){if(Pe.call(this,e,t),delete this.coordinates,this.model=Te[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)};(Le.prototype=Object.create(Pe.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(e=>new t(this.ctx,{id:Ee(),type:C.FEATURE,properties:{},geometry:{coordinates:e,type:this.type.replace("Multi","")}}))},Le.prototype.isValid=function(){return this.features.every(e=>e.isValid())},Le.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},Le.prototype.getCoordinate=function(e){return Ae(this.features,"getCoordinate",e)},Le.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===C.POLYGON?e.getCoordinates():e.coordinates)))},Le.prototype.updateCoordinate=function(e,t,r){Ae(this.features,"updateCoordinate",e,t,r),this.changed()},Le.prototype.addCoordinate=function(e,t,r){Ae(this.features,"addCoordinate",e,t,r),this.changed()},Le.prototype.removeCoordinate=function(e){Ae(this.features,"removeCoordinate",e),this.changed()},Le.prototype.getFeatures=function(){return this.features};const ke=Le;function Fe(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}Fe.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},Fe.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),{})},Fe.prototype.getSelected=function(){return this._ctx.store.getSelected()},Fe.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},Fe.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},Fe.prototype.getFeature=function(e){return this._ctx.store.get(e)},Fe.prototype.select=function(e){return this._ctx.store.select(e)},Fe.prototype.deselect=function(e){return this._ctx.store.deselect(e)},Fe.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},Fe.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},Fe.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},Fe.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},Fe.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)},Fe.prototype.changeMode=function(e,t={},r={}){return this._ctx.events.changeMode(e,t,r)},Fe.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},Fe.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},Fe.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},Fe.prototype.featuresAt=function(e,t,r="click"){if("click"!==r&&"touch"!==r)throw new Error("invalid buffer type");return fe[r](e,t,this._ctx)},Fe.prototype.newFeature=function(e){const t=e.geometry.type;return t===C.POINT?new Me(this._ctx,e):t===C.LINE_STRING?new Oe(this._ctx,e):t===C.POLYGON?new Ce(this._ctx,e):new ke(this._ctx,e)},Fe.prototype.isInstanceOf=function(e,t){if(e===C.POINT)return t instanceof Me;if(e===C.LINE_STRING)return t instanceof Oe;if(e===C.POLYGON)return t instanceof Ce;if("MultiFeature"===e)return t instanceof ke;throw new Error(`Unknown feature class: ${e}`)},Fe.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const je=Fe;Fe.prototype.onSetup=function(){},Fe.prototype.onDrag=function(){},Fe.prototype.onClick=function(){},Fe.prototype.onMouseMove=function(){},Fe.prototype.onMouseDown=function(){},Fe.prototype.onMouseUp=function(){},Fe.prototype.onMouseOut=function(){},Fe.prototype.onKeyUp=function(){},Fe.prototype.onKeyDown=function(){},Fe.prototype.onTouchStart=function(){},Fe.prototype.onTouchMove=function(){},Fe.prototype.onTouchEnd=function(){},Fe.prototype.onTap=function(){},Fe.prototype.onStop=function(){},Fe.prototype.onTrash=function(){},Fe.prototype.onCombineFeature=function(){},Fe.prototype.onUncombineFeature=function(){},Fe.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const Ne={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(Ne);const De=function(e){return[].concat(e).filter(e=>void 0!==e)};function Re(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(_.HOT))return s();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 s(){e.isDirty=!1,e.clearChangedIds()}r.forEach(e=>a(e,"hot")),n.forEach(e=>a(e,"cold")),i&&e.ctx.map.getSource(_.COLD).setData({type:C.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(_.HOT).setData({type:C.FEATURE_COLLECTION,features:e.sources.hot}),s()}function Ue(e){let t;this._features={},this._featureIds=new pe,this._selectedFeatureIds=new pe,this._selectedCoordinates=[],this._changedFeatureIds=new pe,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,Re.call(this),this._emitSelectionChange&&(this.ctx.events.fire(A.SELECTION_CHANGE,{features:this.getSelected().map(e=>e.toGeoJSON()),points:this.getSelectedCoordinates().map(e=>({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:e.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(A.RENDER,{})}))},this.isDirty=!1}function Be(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}Ue.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},Ue.prototype.setDirty=function(){return this.isDirty=!0,this},Ue.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(A.CREATE,{features:[t.toGeoJSON()]})}return this},Ue.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(A.UPDATE,{action:t.action?t.action:L.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},Ue.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Ue.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Ue.prototype.getAllIds=function(){return this._featureIds.values()},Ue.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},Ue.prototype.delete=function(e,t={}){const r=[];return De(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(A.DELETE,{features:r}),Be(this,t),this},Ue.prototype.get=function(e){return this._features[e]},Ue.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},Ue.prototype.select=function(e,t={}){return De(e).forEach(e=>{this._selectedFeatureIds.has(e)||(this._selectedFeatureIds.add(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),this},Ue.prototype.deselect=function(e,t={}){return De(e).forEach(e=>{this._selectedFeatureIds.has(e)&&(this._selectedFeatureIds.delete(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),Be(this,t),this},Ue.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},Ue.prototype.setSelected=function(e,t={}){return e=De(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},Ue.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},Ue.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Ue.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Ue.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},Ue.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)}))},Ue.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},Ue.prototype.setFeatureProperty=function(e,t,r,n={}){this.get(e).setProperty(t,r),this.featureChanged(e,{silent:n.silent,action:L.CHANGE_PROPERTIES})},Ue.prototype.storeMapConfig=function(){j.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},Ue.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},Ue.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const Ge=["mode","feature","mouse"];function Ye(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 je(r));return{start(){o=i.onSetup(n),Ve.forEach(t=>{const r=Ne[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,a=null;o.drag=function(t,r){r({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:O.DRAG}),a.drag(t)):t.originalEvent.stopPropagation()},o.mousedrag=function(e){o.drag(e,e=>!me(r,e))},o.touchdrag=function(e){o.drag(e,e=>!ve(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=ye(t,e);t.featureTarget=r,a.mousemove(t)},o.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};const n=ye(t,e);t.featureTarget=n,a.mousedown(t)},o.mouseup=function(t){const n=ye(t,e);t.featureTarget=n,me(r,{point:t.point,time:(new Date).getTime()})?a.click(t):a.mouseup(t)},o.mouseout=function(e){a.mouseout(e)},o.touchstart=function(t){if(!e.options.touchEnabled)return;n={time:(new Date).getTime(),point:t.point};const r=fe.touch(t,null,e)[0];t.featureTarget=r,a.touchstart(t)},o.touchmove=function(t){if(e.options.touchEnabled)return a.touchmove(t),o.touchdrag(t)},o.touchend=function(t){if(t.originalEvent.preventDefault(),!e.options.touchEnabled)return;const r=fe.touch(t,null,e)[0];t.featureTarget=r,ve(n,{time:(new Date).getTime(),point:t.point})?a.tap(t):a.touchend(t)};const s=e=>{const t=Z(e),r=Q(e),n=ne(e);return!(t||r||n)};function u(r,n,o={}){a.stop();const s=t[r];if(void 0===s)throw new Error(`${r} is not valid`);i=r;const u=s(e,n);a=be(u,e),o.silent||e.map.fire(A.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains(M.CANVAS)&&((Z(t)||Q(t))&&e.options.controls.trash?(t.preventDefault(),a.trash()):s(t)?a.keydown(t):ee(t)&&e.options.controls.point?u(T.DRAW_POINT):te(t)&&e.options.controls.line_string?u(T.DRAW_LINE_STRING):re(t)&&e.options.controls.polygon&&u(T.DRAW_POLYGON))},o.keyup=function(e){s(e)&&a.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 c={trash:!1,combineFeatures:!1,uncombineFeatures:!1},l={start(){i=e.options.defaultMode,a=be(t[i](e),e)},changeMode:u,actionable:function(t){let r=!1;Object.keys(t).forEach(e=>{if(void 0===c[e])throw new Error("Invalid action type");c[e]!==t[e]&&(r=!0),c[e]=t[e]}),r&&e.map.fire(A.ACTIONABLE,{actions:c})},currentModeName:()=>i,currentModeRender:(e,t)=>a.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){a.trash(e)},combineFeatures(){a.combineFeatures()},uncombineFeatures(){a.uncombineFeatures()},getMode:()=>i};return l}(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 a(){if(!e.container)return;const t=[],r=[];Ge.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 s(e,t={}){const n=document.createElement("button");return n.className=`${M.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 u(),void t.onDeactivate();c(e),t.onActivate()},!0),n}function u(){r&&(r.classList.remove(M.ACTIVE_BUTTON),r=null)}function c(e){u();const n=t[e];n&&n&&"trash"!==e&&(n.classList.add(M.ACTIVE_BUTTON),r=n)}return{setActiveButton:c,queueMapClasses:i,updateMapClasses:a,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),a()},addButtons:function(){const r=e.options.controls,n=document.createElement("div");return n.className=`${M.CONTROL_GROUP} ${M.CONTROL_BASE}`,r?(r[I.POINT]&&(t[I.POINT]=s(I.POINT,{container:n,className:M.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(T.DRAW_POINT),onDeactivate:()=>e.events.trash()})),r[I.LINE]&&(t[I.LINE]=s(I.LINE,{container:n,className:M.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(T.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),r[I.POLYGON]&&(t[I.POLYGON]=s(I.POLYGON,{container:n,className:M.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(T.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),r.trash&&(t.trash=s("trash",{container:n,className:M.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),r.combine_features&&(t.combine_features=s("combineFeatures",{container:n,className:M.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),r.uncombine_features&&(t.uncombine_features=s("uncombineFeatures",{container:n,className:M.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 Ue(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(_.COLD,{data:{type:C.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(_.HOT,{data:{type:C.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(_.COLD)&&e.map.removeSource(_.COLD),e.map.getSource(_.HOT)&&e.map.removeSource(_.HOT)}};return e.setup=n,n}const Xe="#3bb2d0",He="#fbb03b",Je="#fff",qe=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],He,Xe],"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"],He,Xe],"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":Je}},{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"],He,Xe]}},{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":Je}},{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":He}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":He}}];function $e(e,t){this.x=e,this.y=t}$e.prototype={clone(){return new $e(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:$e},$e.convert=function(e){if(e instanceof $e)return e;if(Array.isArray(e))return new $e(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new $e(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Ke=function(e,t){const r=t.getBoundingClientRect();return new $e(e.clientX-r.left-(t.clientLeft||0),e.clientY-r.top-(t.clientTop||0))};function We(e,t,r,n){return{type:C.FEATURE,properties:{meta:k.VERTEX,parent:e,coord_path:r,active:n?F.ACTIVE:F.INACTIVE},geometry:{type:C.POINT,coordinates:t}}}var ze=6371008.8,Ze={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*ze,kilometers:6371.0088,kilometres:6371.0088,meters:ze,metres:ze,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:ze/1852,radians:1,yards:6967335.223679999};function Qe(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 et(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(!at(e[0])||!at(e[1]))throw new Error("coordinates must contain numbers");return Qe({type:"Point",coordinates:e},t,r)}function tt(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 Qe({type:"Polygon",coordinates:e},t,r)}function rt(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Qe({type:"LineString",coordinates:e},t,r)}function nt(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function ot(e){return e%(2*Math.PI)*180/Math.PI}function it(e){return e%360*Math.PI/180}function at(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function st(e,t,r){if(null!==e)for(var n,o,i,a,s,u,c,l,p=0,d=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,S=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var E=a.type;switch(p=!r||"Polygon"!==E&&"MultiPolygon"!==E?0:1,E){case null:break;case"Point":if(!1===t(u,d,m,b,S))return!1;d++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],d,m,b,S))return!1;d++,"MultiPoint"===E&&b++}"LineString"===E&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<u.length;n++){for(o=0;o<u[n].length-p;o++){if(!1===t(u[n][o],d,m,b,S))return!1;d++}"MultiLineString"===E&&b++,"Polygon"===E&&S++}"Polygon"===E&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(S=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-p;i++){if(!1===t(u[n][o][i],d,m,b,S))return!1;d++}S++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===st(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ut(e,t){var r,n,o,i,a,s,u,c,l,p,d=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,p=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,d,c,l,p))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],d,c,l,p))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,d,c,l,p))return!1;d++}}function ct(e,t){ut(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(Qe(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(Qe({type:a,coordinates:c},n),r,u))return!1}})}function lt(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=pt(e.properties),null==e.geometry?t.geometry=null:t.geometry=dt(e.geometry),t}function pt(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]=pt(n):t[r]=n}),t):t}function dt(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(e=>dt(e)),t):(t.coordinates=ft(e.coordinates),t)}function ft(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(e=>ft(e))}function ht(e,t={}){return yt(e,"mercator",t)}function yt(e,t,r={}){var n=(r=r||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&at(e[0])?e="mercator"===t?gt(e):mt(e):(!0!==n&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return lt(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=>lt(e)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return dt(e);default:throw new Error("unknown GeoJSON type")}}(e)),st(e,function(e){var r="mercator"===t?gt(e):mt(e);e[0]=r[0],e[1]=r[1]})),e}function gt(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 mt(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 vt(e,t,r){const n=t.geometry.coordinates,o=r.geometry.coordinates;if(n[1]>R||n[1]<V||o[1]>R||o[1]<V)return null;const i=ht(n),a=ht(o),s=e=>Number(e.toFixed(8)),u=(e,t)=>(e+t)/2,c=function(e,t={}){return yt(e,"wgs84",t)}([u(i[0],a[0]),u(i[1],a[1])]),l=[s(c[0]),s(c[1])];return{type:C.FEATURE,properties:{meta:k.MIDPOINT,parent:e,lng:l[0],lat:l[1],coord_path:r.properties.coord_path},geometry:{type:C.POINT,coordinates:l}}}const bt=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=We(a,e,u,c(u));if(r.midpoints&&o){const e=vt(a,o,l);e&&s.push(e)}o=l;const p=JSON.stringify(e);n!==p&&s.push(l),0===i&&(n=p)})}function c(e){return!!r.selectedPaths&&-1!==r.selectedPaths.indexOf(e)}return o===C.POINT?s.push(We(a,i,n,c(n))):o===C.POLYGON?i.forEach((e,t)=>{u(e,null!==n?`${n}.${t}`:String(t))}):o===C.LINE_STRING?u(i,n):0===o.indexOf(C.MULTI_PREFIX)&&function(){const n=o.replace(C.MULTI_PREFIX,"");i.forEach((o,i)=>{const a={type:C.FEATURE,properties:t.properties,geometry:{type:n,coordinates:o}};s=s.concat(e(a,r,i))})}(),s},St={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:Et,LAT_MAX:wt,LAT_RENDERED_MIN:Pt,LAT_RENDERED_MAX:xt,LNG_MIN:Mt,LNG_MAX:_t}=n;function Ot(e,t){let r=Et,n=wt,o=Et,i=wt,a=_t,s=Mt;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],p=t[2];u>r&&(r=u),c<n&&(n=c),c>o&&(o=c),u<i&&(i=u),l<a&&(a=l),p>s&&(s=p)});const u=t;return r+u.lat>xt&&(u.lat=xt-r),o+u.lat>wt&&(u.lat=wt-o),n+u.lat<Pt&&(u.lat=Pt-n),i+u.lat<Et&&(u.lat=Et-i),a+u.lng<=Mt&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=_t&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function It(e,t){const r=Ot(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===C.POINT?i=n(t):e.type===C.LINE_STRING||e.type===C.MULTI_POINT?i=t.map(n):e.type===C.POLYGON||e.type===C.MULTI_LINE_STRING?i=t.map(o):e.type===C.MULTI_POLYGON&&(i=t.map(e=>e.map(e=>o(e)))),e.incomingCoords(i)})}const Ct={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(A.UPDATE,{action:L.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 pe).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(){St.enable(this)},onMouseMove:function(e,t){return q(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};Ct.onTap=Ct.onClick=function(e,t){return J(t)?this.clickAnywhere(e,t):G(k.VERTEX)(t)?this.clickOnVertex(e,t):q(t)?this.clickOnFeature(e,t):void 0},Ct.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(e=>this.doRender(e))),St.enable(this),this.stopExtendedInteractions(e)},Ct.clickOnVertex=function(e,t){this.changeMode(T.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:O.MOVE})},Ct.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},Ct.clickOnFeature=function(e,t){St.disable(this),this.stopExtendedInteractions(e);const r=K(t),n=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!r&&i&&this.getFeature(o).type!==C.POINT)return this.changeMode(T.DIRECT_SELECT,{featureId:o});i&&r?(this.deselect(o),this.updateUIClasses({mouse:O.POINTER}),1===n.length&&St.enable(this)):!i&&r?(this.select(o),this.updateUIClasses({mouse:O.MOVE})):i||r||(n.forEach(e=>this.doRender(e)),this.setSelected(o),this.updateUIClasses({mouse:O.MOVE})),this.doRender(o)},Ct.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),X(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&Y(t)?this.startBoxSelect(e,t):void 0},Ct.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ke(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},Ct.onTouchStart=function(e,t){if(X(t))return this.startOnActiveFeature(e,t)},Ct.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},Ct.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:O.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(M.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const r=Ke(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),a=Math.max(e.boxSelectStartLocation.y,r.y),s=`translate(${n}px, ${i}px)`;e.boxSelectElement.style.transform=s,e.boxSelectElement.style.WebkitTransform=s,e.boxSelectElement.style.width=o-n+"px",e.boxSelectElement.style.height=a-i+"px"},Ct.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};It(this.getSelected(),r),e.dragMoveLocation=t.lngLat},Ct.onTouchEnd=Ct.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const r=[e.boxSelectStartLocation,Ke(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:O.MOVE}))}this.stopExtendedInteractions(e)},Ct.toDisplayFeatures=function(e,t,r){t.properties.active=this.isSelected(t.properties.id)?F.ACTIVE:F.INACTIVE,r(t),this.fireActionable(),t.properties.active===F.ACTIVE&&t.geometry.type!==C.POINT&&bt(t).forEach(r)},Ct.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Ct.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:C.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(A.COMBINE_FEATURES,{createdFeatures:[e.toGeoJSON()],deletedFeatures:r})}this.fireActionable()},Ct.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(A.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:r}),this.fireActionable()};const Tt=Ct,At=G(k.VERTEX),Lt=G(k.MIDPOINT),kt={fireUpdate:function(){this.fire(A.UPDATE,{action:L.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);K(t)||-1!==n?K(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){It(this.getSelected(),r),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,r){const n=e.selectedCoordPaths.map(t=>e.feature.getCoordinate(t)),o=Ot(n.map(e=>({type:C.FEATURE,properties:{},geometry:{type:C.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(T.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(T.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===C.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),St.disable(this),this.setActionableState({trash:!0}),n},onStop:function(){St.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,r){e.featureId===t.properties.id?(t.properties.active=F.ACTIVE,r(t),bt(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(r)):(t.properties.active=F.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(T.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const r=X(t),n=At(t),o=Lt(t),i=0===e.selectedCoordPaths.length;return r&&i||n&&!i?this.updateUIClasses({mouse:O.MOVE}):this.updateUIClasses({mouse:O.NONE}),(n||r||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};kt.onTouchStart=kt.onMouseDown=function(e,t){return At(t)?this.onVertex(e,t):X(t)?this.onFeature(e,t):Lt(t)?this.onMidpoint(e,t):void 0},kt.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},kt.onClick=function(e,t){return J(t)?this.clickNoTarget(e,t):X(t)?this.clickActiveFeature(e,t):H(t)?this.clickInactive(e,t):void this.stopDragging(e)},kt.onTap=function(e,t){return J(t)?this.clickNoTarget(e,t):X(t)?this.clickActiveFeature(e,t):H(t)?this.clickInactive(e,t):void 0},kt.onTouchEnd=kt.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const Ft=kt,jt={onSetup:function(){const e=this.newFeature({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:O.ADD}),this.activateUIButton(I.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)}};jt.onTap=jt.onClick=function(e,t){this.updateUIClasses({mouse:O.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(A.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.point.id]})},jt.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},jt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.point.id;if(t.properties.active=n?F.ACTIVE:F.INACTIVE,!n)return r(t)},jt.onTrash=jt.stopDrawingAndRemove,jt.onKeyUp=function(e,t){if(W(t)||z(t))return this.stopDrawingAndRemove(e,t)};const Nt=jt,Vt=function(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},Dt={onSetup:function(){const e=this.newFeature({type:C.FEATURE,properties:{},geometry:{type:C.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),St.disable(this),this.updateUIClasses({mouse:O.ADD}),this.activateUIButton(I.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Vt(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:O.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(T.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),$(t)&&this.updateUIClasses({mouse:O.POINTER})}};Dt.onTap=Dt.onClick=function(e,t){return $(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},Dt.onKeyUp=function(e,t){W(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)):z(t)&&this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},Dt.onStop=function(e){this.updateUIClasses({mouse:O.NONE}),St.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(A.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT,{},{silent:!0})))},Dt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.polygon.id;if(t.properties.active=n?F.ACTIVE:F.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=k.FEATURE,r(We(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const n=t.geometry.coordinates[0].length-3;r(We(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:C.FEATURE,properties:t.properties,geometry:{coordinates:e,type:C.LINE_STRING}}),3===o)return}return r(t)}},Dt.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)};const Rt=Dt,Ut={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:C.FEATURE,properties:{},geometry:{type:C.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(r);return this.clearSelectedFeatures(),St.disable(this),this.updateUIClasses({mouse:O.ADD}),this.activateUIButton(I.LINE),this.setActionableState({trash:!0}),{line:r,currentVertexPosition:n,direction:o}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Vt(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&Vt(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:O.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(T.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),$(t)&&this.updateUIClasses({mouse:O.POINTER})}};Ut.onTap=Ut.onClick=function(e,t){if($(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},Ut.onKeyUp=function(e,t){z(t)?this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.line.id]}):W(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT))},Ut.onStop=function(e){St.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(A.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT,{},{silent:!0})))},Ut.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)},Ut.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.line.id;if(t.properties.active=n?F.ACTIVE:F.INACTIVE,!n)return r(t);t.geometry.coordinates.length<2||(t.properties.meta=k.FEATURE,r(We(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 Bt=Ut,Gt={simple_select:Tt,direct_select:Ft,draw_point:Nt,draw_polygon:Rt,draw_line_string:Bt},Yt={defaultMode:T.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:qe,modes:Gt,controls:{},userProperties:!1,suppressAPIEvents:!0},Xt={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 Jt(e,t){return e.map(e=>e.source?e:Object.assign({},e,{id:`${e.id}.${t}`,source:"hot"===t?_.HOT:_.COLD}))}var qt=r(17),$t=r(186);function Kt(e,t){return e.length===t.length&&JSON.stringify(e.map(e=>e).sort())===JSON.stringify(t.map(e=>e).sort())}const Wt={Polygon:Ce,LineString:Oe,Point:Me,MultiPolygon:ke,MultiLineString:ke,MultiPoint:ke};function zt(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({},Xt,e.controls),t=Object.assign({},Yt,t),t.styles=Jt(t.styles,"cold").concat(Jt(t.styles,"hot")),t}(e)};t=function(e,t){t.modes=T;const r=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(t){return fe.click({point:t},null,e).map(e=>e.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:C.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(t=>e.store.get(t)).map(e=>e.toGeoJSON())}},t.getSelectedPoints=function(){return{type:C.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(e=>({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:e.coordinates}}))}},t.set=function(r){if(void 0===r.type||r.type!==C.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 pe(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($t(t))).features.map(t=>{if(t.id=t.id||Ee(),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=Wt[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,qt(o,t.properties)||e.store.featureChanged(n.id,{silent:r}),qt(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:C.FEATURE_COLLECTION,features:e.store.getAll().map(e=>e.toGeoJSON())}},t.delete=function(n){return e.store.delete(n,{silent:r}),t.getMode()!==T.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(T.SIMPLE_SELECT,void 0,{silent:r}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:r}),t.getMode()===T.DIRECT_SELECT?e.events.changeMode(T.SIMPLE_SELECT,void 0,{silent:r}):e.store.render(),t},t.changeMode=function(n,o={}){return n===T.SIMPLE_SELECT&&t.getMode()===T.SIMPLE_SELECT?(Kt(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:r}),e.store.render()),t):(n===T.DIRECT_SELECT&&t.getMode()===T.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=Ye(r);t.onAdd=n.onAdd,t.onRemove=n.onRemove,t.types=I,t.options=e}(e,this)}zt.modes=Gt,zt.constants=n,zt.lib=i;const Zt=zt;var Qt={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)}};function er(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 tr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?tr(e,t):void 0}}(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 tr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var rr=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[]}},nr=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},or=function(e,t){var r,n=er(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},ir=function(e,t){var r,n=e.geometry.coordinates,o=er(t);try{for(o.s();!(r=o.n()).done;)n=n[r.value]}catch(e){o.e(e)}finally{o.f()}return n},ar=function(e,t){var r,n=t.split(".").map(Number),o=er(nr(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]},sr=function(e,t){return{x:e.x*t,y:e.y*t}},ur=function(e){return e instanceof window.SVGElement||e.ownerSVGElement};function cr(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 lr={fireGeometryChange:function(e){var t=this.getFeature(e.featureId);t&&this.map.fire("draw.update",{features:[t.toGeoJSON()],action:"change_coordinates"})},pushUndo:function(e){var t=this.map._undoStack;t&&t.push(e)},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)}},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=nr(i),u=or(s,r);if(u){ir(a,u.segment.path)[u.localIdx]=n,this._applyUndoAndSync(e,a,o);var c=e.vertecies[e.selectedVertexIndex];c&&this.updateTouchVertexTarget(e,sr(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=nr(o),s=or(a,r);s&&(ir(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=nr(i),u=or(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 cr(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)?cr(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 p=c.value;if(r===p.start+p.length){u={segment:p,localIdx:p.length};break}}}catch(e){l.e(e)}finally{l.f()}}if(u){ir(a,u.segment.path).splice(u.localIdx,0,n),this._applyUndoAndSync(e,a,o);var d=e.vertecies[r];d&&this.updateTouchVertexTarget(e,sr(this.map.project(d),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)}};function pr(e){return pr="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},pr(e)}function dr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function fr(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 hr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fr(Object(r),!0).forEach(function(t){yr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function yr(e,t,r){return(t=function(e){var t=function(e){if("object"!=pr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=pr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==pr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var gr=function(e,t){if(e){var r="dark"===(null==t?void 0:t.mapColorScheme);e.style.setProperty("--touch-fill",r?"#ffffff":"#000000"),e.style.setProperty("--touch-gfx",r?"#000000":"#ffffff")}},mr={addTouchVertexTarget:function(e){var t=e.container.querySelector("[data-touch-vertex-target]");t||(e.container.insertAdjacentHTML("beforeend","\n <svg width='48' height='48' viewBox='0 0 48 48' fill-rule='evenodd' style='display:none;position:absolute;top:50%;left:50%;margin:24px 0 0 -24px' class='touch-vertex-target' data-touch-vertex-target>\n <circle cx='24' cy='24' r='24' fill='var(--touch-fill, #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(--touch-gfx, #fff)'/>\n </svg>\n"),t=e.container.querySelector("[data-touch-vertex-target]")),e.touchVertexTarget=t,gr(t,this.map._drawCurrentMapStyle)},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":"pointer",e.isPanEnabled=!0,"touch"!==t.pointerType||"pointermove"!==t.type||ur(t.target.parentNode)||e._ignorePointermoveDeselect||this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,coordPath:null})},onTouchStart:function(){},onTouchMove:function(){},onTouchEnd:function(){},onTouchend:function(e){P(v(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=v(this.map);o&&w(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=ar(s,a);this.changeMode(e,{selectedVertexIndex:u,selectedVertexType:"vertex",coordPath:a})}else"midpoint"===i?this.insertVertex(hr(hr({},e),{},{selectedVertexIndex:this.getVertexIndexFromMidpoint(e,a),selectedVertexType:"midpoint"})):this.clickNoTarget(e)},onTouchstart:function(e,t){var r;P(v(this.map));var n,o=null===(r=e.vertecies)||void 0===r?void 0:r[e.selectedVertexIndex];if(o&&ur(t.target.parentNode)){e._moveStartPosition=function(e){if(Array.isArray(e))return dr(e)}(n=o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||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}}(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._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)&&ur(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(x(e)){var a=v(this.map);E(a,this.map,o),i=S(a)||i}this.moveVertex(e,i),this.updateTouchVertexTarget(e,{x:r-e.deltaTarget.x,y:n-e.deltaTarget.y})}}};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 br(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Sr(e,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}function Er(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)||wr(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 wr(e,t){if(e){if("string"==typeof e)return Pr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Pr(e,t):void 0}}function Pr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var xr={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},Mr={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=Er(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?br(Object(r),!0).forEach(function(t){Sr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):br(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({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?1:5,o=Er(t?xr[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(rr(this.getFeature(e.featureId))[e.selectedVertexIndex],t)},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,p=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=wr(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}}}}(nr(i));try{for(p.s();!(r=p.n()).done;){var d=r.value,f=d.closed?d.length:d.length-1;if(n<l+f){u=d,c=n-l+1,s=d.start+c;break}l+=f}}catch(e){p.e(e)}finally{p.f()}u&&(ir(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=nr(o),s=or(a,e.selectedVertexIndex);s&&(ir(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,r=this.getFeature(e.featureId);if(r){var n=nr(r),o=or(n,e.selectedVertexIndex);if(o){var i=o.segment,a=i.closed?3:2;if(!(i.length<=a)){var s=function(e){if(Array.isArray(e))return Pr(e)}(t=e.vertecies[e.selectedVertexIndex])||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||wr(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),u=e.selectedVertexIndex;this._ctx.api.trash(),this.clearSelectedCoordinates(),r.changed(),this._ctx.store.render(),this.pushUndo({type:"delete_vertex",featureId:e.featureId,vertexIndex:u,position:s}),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null})}}}}};function _r(e){var t={type:"Feature"};return Object.keys(e).forEach(function(r){switch(r){case"type":case"properties":case"geometry":return;default:t[r]=e[r]}}),t.properties=Or(e.properties),t.geometry=Ir(e.geometry),t}function Or(e){var t={};return e?(Object.keys(e).forEach(function(r){var n=e[r];"object"==typeof n?null===n?t[r]=null:Array.isArray(n)?t[r]=n.map(function(e){return e}):t[r]=Or(n):t[r]=n}),t):t}function Ir(e){var t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(function(e){return Ir(e)}),t):(t.coordinates=Cr(e.coordinates),t)}function Cr(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map(function(e){return Cr(e)})}function Tr(e){for(var t,r,n=function(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")}(e),o=0,i=1;i<n.length;)t=r||n[0],o+=((r=n[i])[0]-t[0])*(r[1]+t[1]),i++;return o>0}function Ar(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 Lr(e,t){var r,n,o,i,a,s,u,c,l,p,d=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,p=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,d,c,l,p))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],d,c,l,p))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,d,c,l,p))return!1;d++}}function kr(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")}function Fr(e,t){switch("Feature"===e.type?e.geometry.type:e.type){case"GeometryCollection":return Lr(e,function(e){Fr(e,t)}),e;case"LineString":return jr(kr(e),t),e;case"Polygon":return Nr(kr(e),t),e;case"MultiLineString":return kr(e).forEach(function(e){jr(e,t)}),e;case"MultiPolygon":return kr(e).forEach(function(e){Nr(e,t)}),e;case"Point":case"MultiPoint":return e}}function jr(e,t){Tr(e)===t&&e.reverse()}function Nr(e,t){Tr(e[0])!==t&&e[0].reverse();for(var r=1;r<e.length;r++)Tr(e[r])===t&&e[r].reverse()}const Vr=function(e,t){if(!(r=t=t||{})||r.constructor!==Object)throw new Error("options is invalid");var r,n=t.reverse||!1,o=t.mutate||!1;if(!e)throw new Error("<geojson> is required");if("boolean"!=typeof n)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof o)throw new Error("<mutate> must be a boolean");!1===o&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return _r(e);case"FeatureCollection":return function(e){var t={type:"FeatureCollection"};return Object.keys(e).forEach(function(r){switch(r){case"type":case"features":return;default:t[r]=e[r]}}),t.features=e.features.map(function(e){return _r(e)}),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Ir(e);default:throw new Error("unknown GeoJSON type")}}(e));var i=[];switch(e.type){case"GeometryCollection":return Lr(e,function(e){Fr(e,n)}),e;case"FeatureCollection":return Ar(e,function(e){Ar(Fr(e,n),function(e){i.push(e)})}),function(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}(i)}return Fr(e,n)},Dr=11102230246251565e-32,Rr=134217729,Ur=(3+8*Dr)*Dr;function Br(e,t,r,n,o){let i,a,s,u,c=t[0],l=n[0],p=0,d=0;l>c==l>-c?(i=c,c=t[++p]):(i=l,l=n[++d]);let f=0;if(p<e&&d<r)for(l>c==l>-c?(a=c+i,s=i-(a-c),c=t[++p]):(a=l+i,s=i-(a-l),l=n[++d]),i=a,0!==s&&(o[f++]=s);p<e&&d<r;)l>c==l>-c?(a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++p]):(a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++d]),i=a,0!==s&&(o[f++]=s);for(;p<e;)a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++p],i=a,0!==s&&(o[f++]=s);for(;d<r;)a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++d],i=a,0!==s&&(o[f++]=s);return 0===i&&0!==f||(o[f++]=i),f}function Gr(e){return new Float64Array(e)}const Yr=Gr(4),Xr=Gr(8),Hr=Gr(12),Jr=Gr(16),qr=Gr(4);function $r(e,t,r,n,o,i){const a=(t-i)*(r-o),s=(e-o)*(n-i),u=a-s,c=Math.abs(a+s);return Math.abs(u)>=33306690738754716e-32*c?u:-function(e,t,r,n,o,i,a){let s,u,c,l,p,d,f,h,y,g,m,v,b,S,E,w,P,x;const M=e-o,_=r-o,O=t-i,I=n-i;S=M*I,d=Rr*M,f=d-(d-M),h=M-f,d=Rr*I,y=d-(d-I),g=I-y,E=h*g-(S-f*y-h*y-f*g),w=O*_,d=Rr*O,f=d-(d-O),h=O-f,d=Rr*_,y=d-(d-_),g=_-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,p=E-m,Yr[0]=E-(m+p)+(p-P),v=S+m,p=v-S,b=S-(v-p)+(m-p),m=b-w,p=b-m,Yr[1]=b-(m+p)+(p-w),x=v+m,p=x-v,Yr[2]=v-(x-p)+(m-p),Yr[3]=x;let C=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,Yr),T=22204460492503146e-32*a;if(C>=T||-C>=T)return C;if(p=e-M,s=e-(M+p)+(p-o),p=r-_,c=r-(_+p)+(p-o),p=t-O,u=t-(O+p)+(p-i),p=n-I,l=n-(I+p)+(p-i),0===s&&0===u&&0===c&&0===l)return C;if(T=11093356479670487e-47*a+Ur*Math.abs(C),C+=M*l+I*s-(O*c+_*u),C>=T||-C>=T)return C;S=s*I,d=Rr*s,f=d-(d-s),h=s-f,d=Rr*I,y=d-(d-I),g=I-y,E=h*g-(S-f*y-h*y-f*g),w=u*_,d=Rr*u,f=d-(d-u),h=u-f,d=Rr*_,y=d-(d-_),g=_-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,p=E-m,qr[0]=E-(m+p)+(p-P),v=S+m,p=v-S,b=S-(v-p)+(m-p),m=b-w,p=b-m,qr[1]=b-(m+p)+(p-w),x=v+m,p=x-v,qr[2]=v-(x-p)+(m-p),qr[3]=x;const A=Br(4,Yr,4,qr,Xr);S=M*l,d=Rr*M,f=d-(d-M),h=M-f,d=Rr*l,y=d-(d-l),g=l-y,E=h*g-(S-f*y-h*y-f*g),w=O*c,d=Rr*O,f=d-(d-O),h=O-f,d=Rr*c,y=d-(d-c),g=c-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,p=E-m,qr[0]=E-(m+p)+(p-P),v=S+m,p=v-S,b=S-(v-p)+(m-p),m=b-w,p=b-m,qr[1]=b-(m+p)+(p-w),x=v+m,p=x-v,qr[2]=v-(x-p)+(m-p),qr[3]=x;const L=Br(A,Xr,4,qr,Hr);S=s*l,d=Rr*s,f=d-(d-s),h=s-f,d=Rr*l,y=d-(d-l),g=l-y,E=h*g-(S-f*y-h*y-f*g),w=u*c,d=Rr*u,f=d-(d-u),h=u-f,d=Rr*c,y=d-(d-c),g=c-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,p=E-m,qr[0]=E-(m+p)+(p-P),v=S+m,p=v-S,b=S-(v-p)+(m-p),m=b-w,p=b-m,qr[1]=b-(m+p)+(p-w),x=v+m,p=x-v,qr[2]=v-(x-p)+(m-p),qr[3]=x;const k=Br(L,Hr,4,qr,Jr);return Jr[k-1]}(e,t,r,n,o,i,c)}function Kr(e,t){var r,n,o,i,a,s,u,c,l,p=0,d=e[0],f=e[1],h=t.length;for(r=0;r<h;r++){n=0;var y=t[r],g=y.length-1;if((c=y[0])[0]!==y[g][0]&&c[1]!==y[g][1])throw new Error("First and last coordinates in a ring must be the same");for(i=c[0]-d,a=c[1]-f;n<g;n++){if(s=(l=y[n+1])[0]-d,u=l[1]-f,0===a&&0===u){if(s<=0&&i>=0||i<=0&&s>=0)return 0}else if(u>=0&&a<=0||u<=0&&a>=0){if(0===(o=$r(i,s,a,u,0,0)))return 0;(o>0&&u>0&&a<=0||o<0&&u<=0&&a>0)&&p++}c=l,a=u,i=s}}return p%2!=0}Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(8),Gr(8),Gr(8),Gr(4),Gr(8),Gr(8),Gr(8),Gr(12),Gr(192),Gr(192),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(8),Gr(8),Gr(8),Gr(8),Gr(8),Gr(8),Gr(8),Gr(8),Gr(8),Gr(4),Gr(4),Gr(4),Gr(8),Gr(16),Gr(16),Gr(16),Gr(32),Gr(32),Gr(48),Gr(64),Gr(1152),Gr(1152),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(4),Gr(24),Gr(24),Gr(24),Gr(24),Gr(24),Gr(24),Gr(24),Gr(24),Gr(24),Gr(24),Gr(1152),Gr(1152),Gr(1152),Gr(1152),Gr(1152),Gr(2304),Gr(2304),Gr(3456),Gr(5760),Gr(8),Gr(8),Gr(8),Gr(16),Gr(24),Gr(48),Gr(48),Gr(96),Gr(192),Gr(384),Gr(384),Gr(384),Gr(768),Gr(96),Gr(96),Gr(96),Gr(1152);const Wr=134217729;function zr(e,t,r,n,o){let i,a,s,u,c=t[0],l=n[0],p=0,d=0;l>c==l>-c?(i=c,c=t[++p]):(i=l,l=n[++d]);let f=0;if(p<e&&d<r)for(l>c==l>-c?(a=c+i,s=i-(a-c),c=t[++p]):(a=l+i,s=i-(a-l),l=n[++d]),i=a,0!==s&&(o[f++]=s);p<e&&d<r;)l>c==l>-c?(a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++p]):(a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++d]),i=a,0!==s&&(o[f++]=s);for(;p<e;)a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++p],i=a,0!==s&&(o[f++]=s);for(;d<r;)a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++d],i=a,0!==s&&(o[f++]=s);return 0===i&&0!==f||(o[f++]=i),f}function Zr(e){return new Float64Array(e)}const Qr=Zr(4),en=Zr(8),tn=Zr(12),rn=Zr(16),nn=Zr(4);function on(e,t,r,n,o,i){const a=(t-i)*(r-o),s=(e-o)*(n-i),u=a-s;if(0===a||0===s||a>0!=s>0)return u;const c=Math.abs(a+s);return Math.abs(u)>=33306690738754716e-32*c?u:-function(e,t,r,n,o,i,a){let s,u,c,l,p,d,f,h,y,g,m,v,b,S,E,w,P,x;const M=e-o,_=r-o,O=t-i,I=n-i;S=M*I,d=Wr*M,f=d-(d-M),h=M-f,d=Wr*I,y=d-(d-I),g=I-y,E=h*g-(S-f*y-h*y-f*g),w=O*_,d=Wr*O,f=d-(d-O),h=O-f,d=Wr*_,y=d-(d-_),g=_-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,p=E-m,Qr[0]=E-(m+p)+(p-P),v=S+m,p=v-S,b=S-(v-p)+(m-p),m=b-w,p=b-m,Qr[1]=b-(m+p)+(p-w),x=v+m,p=x-v,Qr[2]=v-(x-p)+(m-p),Qr[3]=x;let C=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,Qr),T=22204460492503146e-32*a;if(C>=T||-C>=T)return C;if(p=e-M,s=e-(M+p)+(p-o),p=r-_,c=r-(_+p)+(p-o),p=t-O,u=t-(O+p)+(p-i),p=n-I,l=n-(I+p)+(p-i),0===s&&0===u&&0===c&&0===l)return C;if(T=11093356479670487e-47*a+33306690738754706e-32*Math.abs(C),C+=M*l+I*s-(O*c+_*u),C>=T||-C>=T)return C;S=s*I,d=Wr*s,f=d-(d-s),h=s-f,d=Wr*I,y=d-(d-I),g=I-y,E=h*g-(S-f*y-h*y-f*g),w=u*_,d=Wr*u,f=d-(d-u),h=u-f,d=Wr*_,y=d-(d-_),g=_-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,p=E-m,nn[0]=E-(m+p)+(p-P),v=S+m,p=v-S,b=S-(v-p)+(m-p),m=b-w,p=b-m,nn[1]=b-(m+p)+(p-w),x=v+m,p=x-v,nn[2]=v-(x-p)+(m-p),nn[3]=x;const A=zr(4,Qr,4,nn,en);S=M*l,d=Wr*M,f=d-(d-M),h=M-f,d=Wr*l,y=d-(d-l),g=l-y,E=h*g-(S-f*y-h*y-f*g),w=O*c,d=Wr*O,f=d-(d-O),h=O-f,d=Wr*c,y=d-(d-c),g=c-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,p=E-m,nn[0]=E-(m+p)+(p-P),v=S+m,p=v-S,b=S-(v-p)+(m-p),m=b-w,p=b-m,nn[1]=b-(m+p)+(p-w),x=v+m,p=x-v,nn[2]=v-(x-p)+(m-p),nn[3]=x;const L=zr(A,en,4,nn,tn);S=s*l,d=Wr*s,f=d-(d-s),h=s-f,d=Wr*l,y=d-(d-l),g=l-y,E=h*g-(S-f*y-h*y-f*g),w=u*c,d=Wr*u,f=d-(d-u),h=u-f,d=Wr*c,y=d-(d-c),g=c-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,p=E-m,nn[0]=E-(m+p)+(p-P),v=S+m,p=v-S,b=S-(v-p)+(m-p),m=b-w,p=b-m,nn[1]=b-(m+p)+(p-w),x=v+m,p=x-v,nn[2]=v-(x-p)+(m-p),nn[3]=x;const k=zr(L,tn,4,nn,rn);return rn[k-1]}(e,t,r,n,o,i,c)}Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(8),Zr(8),Zr(8),Zr(4),Zr(8),Zr(8),Zr(8),Zr(12),Zr(192),Zr(192),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(8),Zr(8),Zr(8),Zr(8),Zr(8),Zr(8),Zr(8),Zr(8),Zr(8),Zr(4),Zr(4),Zr(4),Zr(8),Zr(16),Zr(16),Zr(16),Zr(32),Zr(32),Zr(48),Zr(64),Zr(1152),Zr(1152),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(4),Zr(24),Zr(24),Zr(24),Zr(24),Zr(24),Zr(24),Zr(24),Zr(24),Zr(24),Zr(24),Zr(1152),Zr(1152),Zr(1152),Zr(1152),Zr(1152),Zr(2304),Zr(2304),Zr(3456),Zr(5760),Zr(8),Zr(8),Zr(8),Zr(16),Zr(24),Zr(48),Zr(48),Zr(96),Zr(192),Zr(384),Zr(384),Zr(384),Zr(768),Zr(96),Zr(96),Zr(96),Zr(1152);var an=function(e,t,r,n,o){this.p1=e,this.p2=t,this.edgeType=r,this.originalIndex=n,this.polygonContourId=o,this.interiorRing=!1,this.minX=Math.min(e.p[0],t.p[0]),this.minY=Math.min(e.p[1],t.p[1]),this.maxX=Math.max(e.p[0],t.p[0]),this.maxY=Math.max(e.p[1],t.p[1]),this.intersectionPoints=[],this.nextEdge=null},sn=function(e){this.p=e},un=function(e,t){this.id=e,this.rawCoords=t};function cn(e,t){return!(e.maxX<t[0]||e.minX>t[2]||e.maxY<t[1]||e.minY>t[3])}var ln=function(e,t,r,n){this.p=e,this.polylineEdge=t,this.polygonEdge=r,this.isHeadingIn=n,this.distanceFromPolylineEdgeStart=pn(this.polylineEdge.p1.p,this.p),this.distanceFromPolygonEdgeStart=pn(this.polygonEdge.p1.p,this.p),this.polygonEdge.intersectionPoints.push(this),this.polylineEdge.intersectionPoints.push(this),this.visitCount=0};function pn(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*=r,n*=n,Math.sqrt(r+n)}function dn(e,t){return e[0]*t[1]-e[1]*t[0]}function fn(e,t){return e[0]*t[0]+e[1]*t[1]}function hn(e,t,r){return[e[0]+t*r[0],e[1]+t*r[1]]}function yn(e,t,r){var n=[e.p2.p[0]-e.p1.p[0],e.p2.p[1]-e.p1.p[1]],o=[t.p2.p[0]-t.p1.p[0],t.p2.p[1]-t.p1.p[1]],i=[t.p1.p[0]-e.p1.p[0],t.p1.p[1]-e.p1.p[1]],a=dn(n,o),s=a*a,u=fn(n,n);if(s>0){var c=dn(i,o)/a;if(c<0||c>1)return null;var l=dn(i,n)/a;return l<0||l>1?null:0===c||1===c?r?null:[hn(e.p1.p,c,n)]:0===l||1===l?r?null:[hn(t.p1.p,l,o)]:[hn(e.p1.p,c,n)]}var p=fn(i,i);if((s=(a=dn(i,n))*a)>1e-9*u*p)return null;var d=fn(n,i)/u,f=d+fn(n,o)/u,h=Math.min(d,f),y=Math.max(d,f);return h<=1&&y>=0?1===h?r?null:[hn(e.p1.p,h>0?h:0,n)]:0===y?r?null:[hn(e.p1.p,y<1?y:1,n)]:r&&0===h&&1===y?null:[hn(e.p1.p,h>0?h:0,n),hn(e.p1.p,y<1?y:1,n)]:null}function gn(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n.polygonContourId===t)return n}}function mn(e,t){return t.find(function(t){return t.id===e.polygonContourId}).rawCoords}function vn(e,t){for(var r=0;r<t.length;r++){var n=t[r];if(Kr(e[0],[n[0]]))return void n.push(e)}t.push([e])}function bn(e,t){var r=e.polygonEdge;if(r.intersectionPoints.length>1&&r.intersectionPoints[r.intersectionPoints.length-1]!==e){var n=Sn(e,r.intersectionPoints),o=r.intersectionPoints[n+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(r.p2.p),null===(r=r.nextEdge))return e;r.intersectionPoints.length>0&&(i=!1)}return r.intersectionPoints[0].incrementVisitCount(),t.push(r.intersectionPoints[0].p),r.intersectionPoints[0]}function Sn(e,t){for(var r=0;r<t.length;r++)if(t[r]===e)return r;return null}function En(e,t){var r=e.polylineEdge;if(2===r.intersectionPoints.length){var n=r.intersectionPoints[r.intersectionPoints.length-1];if(n===e){var o=r.intersectionPoints[0];return t.push(o.p),o.incrementVisitCount(),o}return t.push(n.p),n.incrementVisitCount(),n}if(r.intersectionPoints.length>2&&r.intersectionPoints[0]!==e){var i=Sn(e,r.intersectionPoints),a=r.intersectionPoints[i-1];return t.push(a.p),a.incrementVisitCount(),a}for(var s=!0;s;){if(t.push(r.p1.p),void 0===(r=r.prevEdge).originalIndex)return e;r.intersectionPoints.length>0&&(s=!1)}if(void 0===r.originalIndex)return e;var u=r.intersectionPoints[r.intersectionPoints.length-1];return u.incrementVisitCount(),t.push(u.p),u}function wn(e,t){var r=e.polylineEdge;if(r.intersectionPoints.length>1&&r.intersectionPoints[r.intersectionPoints.length-1]!==e){var n=Sn(e,r.intersectionPoints),o=r.intersectionPoints[n+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(r.p2.p),null===(r=r.nextEdge))return e;r.intersectionPoints.length>0&&(i=!1)}if(void 0===r)return e;var a=r.intersectionPoints[0];return a.incrementVisitCount(),t.push(a.p),a}function Pn(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 xn(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")}function Mn(e){return"Feature"===e.type?e.geometry:e}ln.prototype.incrementVisitCount=function(){this.visitCount=this.visitCount+1};var _n=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=Pn(t),i=Pn(r),a=it(o[0]),s=it(i[0]),u=it(o[1]),c=it(i[1]),l=Math.sin(s-a)*Math.cos(c),p=Math.cos(u)*Math.sin(c)-Math.sin(u)*Math.cos(c)*Math.cos(s-a);return ot(Math.atan2(l,p))};function On(e,t,r,n={}){const o=Pn(e),i=it(o[0]),a=it(o[1]),s=it(r),u=function(e,t="kilometers"){const r=Ze[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)),l=ot(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),p=ot(c);return void 0!==o[2]?et([l,p,o[2]],n.properties):et([l,p],n.properties)}var In=On;function Cn(e,t,r={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=Pn(e),o=Mn(t),i=o.type,a=t.bbox;let s=o.coordinates;if(a&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(n,a))return!1;"Polygon"===i&&(s=[s]);let u=!1;for(var c=0;c<s.length;++c){const e=Kr(n,s[c]);if(0===e)return!r.ignoreBoundary;e&&(u=!0)}return u}class Tn{constructor(e=[],t=An){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const o=e-1>>1,i=t[o];if(r(n,i)>=0)break;t[e]=i,e=o}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,o=t[e];for(;e<n;){let n=1+(e<<1),i=t[n];const a=n+1;if(a<this.length&&r(t[a],i)<0&&(n=a,i=t[a]),r(i,o)>=0)break;t[e]=i,e=n}t[e]=o}}function An(e,t){return e<t?-1:e>t?1:0}function Ln(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function kn(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class Fn{constructor(e,t,r,n){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=n,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}let jn=0,Nn=0,Vn=0;function Dn(e,t){const r="Feature"===e.type?e.geometry:e;let n=r.coordinates;"Polygon"!==r.type&&"MultiLineString"!==r.type||(n=[n]),"LineString"===r.type&&(n=[[n]]);for(let e=0;e<n.length;e++)for(let r=0;r<n[e].length;r++){let o=n[e][r][0],i=null;Nn+=1;for(let a=0;a<n[e][r].length-1;a++){i=n[e][r][a+1];const s=new Fn(o,jn,Nn,Vn),u=new Fn(i,jn,Nn,Vn+1);s.otherEvent=u,u.otherEvent=s,Ln(s,u)>0?(u.isLeftEndpoint=!0,s.isLeftEndpoint=!1):(s.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(s),t.push(u),o=i,Vn+=1}}jn+=1}class Rn{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function Un(e,t){if(null===e||null===t)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const r=e.leftSweepEvent.p.x,n=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,i=e.rightSweepEvent.p.y,a=t.leftSweepEvent.p.x,s=t.leftSweepEvent.p.y,u=t.rightSweepEvent.p.x,c=t.rightSweepEvent.p.y,l=(c-s)*(o-r)-(u-a)*(i-n);if(0===l)return!1;const p=((u-a)*(n-s)-(c-s)*(r-a))/l,d=((o-r)*(n-s)-(i-n)*(r-a))/l;return p>=0&&p<=1&&d>=0&&d<=1&&[r+p*(o-r),n+p*(i-n)]}function Bn(e,t,r={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:o=!0}=r;let i=[];"FeatureCollection"===e.type?i=i.concat(e.features):"Feature"===e.type?i.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||i.push(Qe(e)),"FeatureCollection"===t.type?i=i.concat(t.features):"Feature"===t.type?i.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||i.push(Qe(t));const a=function(e,t){const r=new Tn([],Ln);return function(e,t){if("FeatureCollection"===e.type){const r=e.features;for(let e=0;e<r.length;e++)Dn(r[e],t)}else Dn(e,t)}(e,r),function(e,t){t=t||!1;const r=[],n=new Tn([],kn);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const e=new Rn(o);for(let i=0;i<n.data.length;i++){const a=n.data[i];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const s=Un(e,a);!1!==s&&r.push(s)}n.push(e)}else!1===o.isLeftEndpoint&&n.pop()}return r}(r,t)}(nt(i),o);let s=[];if(n){const e={};a.forEach(t=>{const r=t.join(",");e[r]||(e[r]=!0,s.push(t))})}else s=a;return nt(s.map(e=>et(e)))}function Gn(e,t={}){const r=Mn(e);switch(t.properties||"Feature"!==e.type||(t.properties=e.properties),r.type){case"Polygon":return function(e,t={}){return Yn(Mn(e).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}(r,t);case"MultiPolygon":return function(e,t={}){const r=Mn(e).coordinates,n=t.properties?t.properties:"Feature"===e.type?e.properties:{},o=[];return r.forEach(e=>{o.push(Yn(e,n))}),nt(o)}(r,t);default:throw new Error("invalid poly")}}function Yn(e,t){return e.length>1?function(e,t,r={}){return Qe({type:"MultiLineString",coordinates:e},t,r)}(e,t):rt(e[0],t)}function Xn(e,t,{ignoreSelfIntersections:r=!0}={ignoreSelfIntersections:!0}){let n=!0;return ct(e,e=>{ct(t,t=>{if(!1===n)return!1;n=function(e,t,r){switch(e.type){case"Point":switch(t.type){case"Point":return n=e.coordinates,o=t.coordinates,!(n[0]===o[0]&&n[1]===o[1]);case"LineString":return!Hn(t,e);case"Polygon":return!Cn(e,t)}break;case"LineString":switch(t.type){case"Point":return!Hn(e,t);case"LineString":return!function(e,t,r){return Bn(e,t,{ignoreSelfIntersections:r}).features.length>0}(e,t,r);case"Polygon":return!Jn(t,e,r)}break;case"Polygon":switch(t.type){case"Point":return!Cn(t,e);case"LineString":return!Jn(e,t,r);case"Polygon":return!function(e,t,r){for(const r of e.coordinates[0])if(Cn(r,t))return!0;for(const r of t.coordinates[0])if(Cn(r,e))return!0;return Bn(Gn(e),Gn(t),{ignoreSelfIntersections:r}).features.length>0}(t,e,r)}}var n,o;return!1}(e.geometry,t.geometry,r)})}),n}function Hn(e,t){for(let r=0;r<e.coordinates.length-1;r++)if(qn(e.coordinates[r],e.coordinates[r+1],t.coordinates))return!0;return!1}function Jn(e,t,r){for(const r of t.coordinates)if(Cn(r,e))return!0;return Bn(t,Gn(e),{ignoreSelfIntersections:r}).features.length>0}function qn(e,t,r){const n=r[0]-e[0],o=r[1]-e[1],i=t[0]-e[0],a=t[1]-e[1];return 0===n*a-o*i&&(Math.abs(i)>=Math.abs(a)?i>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:a>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1])}var $n=Object.defineProperty,Kn=(e,t)=>$n(e,"name",{value:t,configurable:!0}),Wn=class{constructor(e){var t,r,n;this.direction=!1,this.compareProperties=!0,this.precision=10**-(null!=(t=null==e?void 0:e.precision)?t:17),this.direction=null!=(r=null==e?void 0:e.direction)&&r,this.compareProperties=null==(n=null==e?void 0:e.compareProperties)||n}compare(e,t){if(e.type!==t.type)return!1;if(!Zn(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates);case"Polygon":return this.comparePolygon(e,t);case"GeometryCollection":return this.compareGeometryCollection(e,t);case"Feature":return this.compareFeature(e,t);case"FeatureCollection":return this.compareFeatureCollection(e,t);default:if(e.type.startsWith("Multi")){const r=Qn(e),n=Qn(t);return r.every(e=>n.some(t=>this.compare(e,t)))}}return!1}compareCoord(e,t){return e.length===t.length&&e.every((e,r)=>Math.abs(e-t[r])<this.precision)}compareLine(e,t,r=0,n=!1){if(!Zn(e,t))return!1;const o=e;let i=t;if(n&&!this.compareCoord(o[0],i[0])){const e=this.fixStartIndex(i,o);if(!e)return!1;i=e}const a=this.compareCoord(o[r],i[r]);return this.direction||a?this.comparePath(o,i):!!this.compareCoord(o[r],i[i.length-(1+r)])&&this.comparePath(o.slice().reverse(),i)}fixStartIndex(e,t){let r,n=-1;for(let r=0;r<e.length;r++)if(this.compareCoord(e[r],t[0])){n=r;break}return n>=0&&(r=[].concat(e.slice(n,e.length),e.slice(1,n+1))),r}comparePath(e,t){return e.every((e,r)=>this.compareCoord(e,t[r]))}comparePolygon(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){const r=e.coordinates.slice(1,e.coordinates.length),n=t.coordinates.slice(1,t.coordinates.length);return r.every(e=>n.some(t=>this.compareLine(e,t,1,!0)))}return!1}compareGeometryCollection(e,t){return Zn(e.geometries,t.geometries)&&this.compareBBox(e,t)&&e.geometries.every((e,r)=>this.compare(e,t.geometries[r]))}compareFeature(e,t){return e.id===t.id&&(!this.compareProperties||to(e.properties,t.properties))&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return Zn(e.features,t.features)&&this.compareBBox(e,t)&&e.features.every((e,r)=>this.compare(e,t.features[r]))}compareBBox(e,t){return Boolean(!e.bbox&&!t.bbox)||!(!e.bbox||!t.bbox)&&this.compareCoord(e.bbox,t.bbox)}};Kn(Wn,"GeojsonEquality");var zn=Wn;function Zn(e,t){return e.coordinates?e.coordinates.length===t.coordinates.length:e.length===t.length}function Qn(e){return e.coordinates.map(t=>({type:e.type.replace("Multi",""),coordinates:t}))}function eo(e,t,r){return new zn(r).compare(e,t)}function to(e,t){if(null===e&&null===t)return!0;if(null===e||null===t)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o of r){const r=e[o],n=t[o],i=ro(r)&&ro(n);if(i&&!to(r,n)||!i&&r!==n)return!1}return!0}Kn(Zn,"sameLength"),Kn(Qn,"explode"),Kn(eo,"geojsonEquality"),Kn(to,"equal");var ro=Kn(e=>null!=e&&"object"==typeof e,"isObject");function no(e,t,r={}){const n=Pn(e),o=xn(t);for(let e=0;e<o.length-1;e++){let t=!1;if(r.ignoreEndVertices&&(0===e&&(t="start"),e===o.length-2&&(t="end"),0===e&&e+1===o.length-1&&(t="both")),oo(o[e],o[e+1],n,t,void 0===r.epsilon?null:r.epsilon))return!0}return!1}function oo(e,t,r,n,o){const i=r[0],a=r[1],s=e[0],u=e[1],c=t[0],l=t[1],p=c-s,d=l-u,f=(r[0]-s)*d-(r[1]-u)*p;if(null!==o){if(Math.abs(f)>o)return!1}else if(0!==f)return!1;return Math.abs(p)===Math.abs(d)&&0===Math.abs(p)?!n&&r[0]===e[0]&&r[1]===e[1]:n?"start"===n?Math.abs(p)>=Math.abs(d)?p>0?s<i&&i<=c:c<=i&&i<s:d>0?u<a&&a<=l:l<=a&&a<u:"end"===n?Math.abs(p)>=Math.abs(d)?p>0?s<=i&&i<c:c<i&&i<=s:d>0?u<=a&&a<l:l<a&&a<=u:"both"===n&&(Math.abs(p)>=Math.abs(d)?p>0?s<i&&i<c:c<i&&i<s:d>0?u<a&&a<l:l<a&&a<u):Math.abs(p)>=Math.abs(d)?p>0?s<=i&&i<=c:c<=i&&i<=s:d>0?u<=a&&a<=l:l<=a&&a<=u}function io(e,t={}){var r="object"==typeof t?t.mutate:t;if(!e)throw new Error("geojson is required");var n=function(e){return"FeatureCollection"===e.type?"FeatureCollection":"GeometryCollection"===e.type?"GeometryCollection":"Feature"===e.type&&null!==e.geometry?e.geometry.type:e.type}(e),o=[];switch(n){case"LineString":o=ao(e,n);break;case"MultiLineString":case"Polygon":xn(e).forEach(function(e){o.push(ao(e,n))});break;case"MultiPolygon":xn(e).forEach(function(e){var t=[];e.forEach(function(e){t.push(ao(e,n))}),o.push(t)});break;case"Point":return e;case"MultiPoint":var i={};xn(e).forEach(function(e){var t=e.join("-");Object.prototype.hasOwnProperty.call(i,t)||(o.push(e),i[t]=!0)});break;default:throw new Error(n+" geometry not supported")}return e.coordinates?!0===r?(e.coordinates=o,e):{type:n,coordinates:o}:!0===r?(e.geometry.coordinates=o,e):Qe({type:n,coordinates:o},e.properties,{bbox:e.bbox,id:e.id})}function ao(e,t){const r=xn(e);if(2===r.length&&!so(r[0],r[1]))return r;const n=[];let o=0,i=1,a=2;for(n.push(r[o]);a<r.length;)no(r[i],rt([r[o],r[a]]))?i=a:(n.push(r[i]),o=i,i++,a=i),a++;if(n.push(r[i]),"Polygon"===t||"MultiPolygon"===t){if(no(n[0],rt([n[1],n[n.length-2]]))&&(n.shift(),n.pop(),n.push(n[0])),n.length<4)throw new Error("invalid polygon, fewer than 4 points");if(!so(n[0],n[n.length-1]))throw new Error("invalid polygon, first and last points not equal")}return n}function so(e,t){return e[0]===t[0]&&e[1]===t[1]}function uo(e,t,r={}){let n=r.precision;if(n=null==n||isNaN(n)?6:n,"number"!=typeof n||!(n>=0))throw new Error("precision must be a positive number");return Mn(e).type===Mn(t).type&&eo(io(e),io(t),{precision:n})}function co(e,t){var r=Mn(e),n=Mn(t),o=r.type,i=n.type;switch(o){case"MultiPoint":switch(i){case"LineString":return lo(r,n);case"Polygon":return fo(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"LineString":switch(i){case"MultiPoint":return lo(n,r);case"LineString":return function(e,t){const r=Bn(e,t);if(0===r.features.length)return!1;for(const n of r.features)if(!(uo(n.geometry,et(e.coordinates[0]))||uo(n.geometry,et(e.coordinates[e.coordinates.length-1]))||uo(n.geometry,et(t.coordinates[0]))||uo(n.geometry,et(t.coordinates[t.coordinates.length-1]))))return!0;return!1}(r,n);case"Polygon":return po(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"Polygon":switch(i){case"MultiPoint":return fo(n,r);case"LineString":return po(n,r);default:throw new Error("feature2 "+i+" geometry not supported")}default:throw new Error("feature1 "+o+" geometry not supported")}}function lo(e,t){for(var r=!1,n=!1,o=e.coordinates.length,i=0;i<o&&!r&&!n;){for(var a=0;a<t.coordinates.length-1;a++){var s=!0;0!==a&&a!==t.coordinates.length-2||(s=!1),ho(t.coordinates[a],t.coordinates[a+1],e.coordinates[i],s)?r=!0:n=!0}i++}return r&&n}function po(e,t){return Bn(e,Gn(t)).features.length>0}function fo(e,t){var r=!1,n=!1,o=e.coordinates.length;for(let i=0;i<o&&(!r||!n);i++)Cn(et(e.coordinates[i]),t)?r=!0:n=!0;return n&&r}function ho(e,t,r,n){var o=r[0]-e[0],i=r[1]-e[1],a=t[0]-e[0],s=t[1]-e[1];return 0===o*s-i*a&&(n?Math.abs(a)>=Math.abs(s)?a>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:s>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1]:Math.abs(a)>=Math.abs(s)?a>0?e[0]<r[0]&&r[0]<t[0]:t[0]<r[0]&&r[0]<e[0]:s>0?e[1]<r[1]&&r[1]<t[1]:t[1]<r[1]&&r[1]<e[1])}function yo(e){return e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]}function go(e){for(var t=0;t<e.length-1;t++)for(var r=e[t],n=t+1;n<e.length-2;n++)if(no(r,rt([e[n],e[n+1]])))return!0;return!1}function mo(e,t,r){for(var n=tt(e),o=r+1;o<t.length;o++)if(!Xn(n,tt(t[o]))&&co(n,rt(t[o][0])))return!1;return!0}function vo(e){let t=0;if(e&&e.length>0){t+=Math.abs(So(e[0]));for(let r=1;r<e.length;r++)t-=Math.abs(So(e[r]))}return t}var bo=Math.PI/180;function So(e){const t=e.length-1;if(t<=2)return 0;let r=0,n=0;for(;n<t;){const o=e[n],i=e[n+1===t?0:n+1],a=e[n+2>=t?(n+2)%t:n+2],s=o[0]*bo,u=i[1]*bo;r+=(a[0]*bo-s)*Math.sin(u),n++}return 20294876564838.72*r}var Eo=function(e){return function(e){var t=0;return ut(e,function(e,r,n,o,i){t=t+function(e){let t,r=0;switch(e.type){case"Polygon":return vo(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)r+=vo(e.coordinates[t]);return r;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e)}),t}(e)};function wo(e){return wo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},wo(e)}function Po(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)||xo(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 xo(e,t){if(e){if("string"==typeof e)return Mo(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)?Mo(e,t):void 0}}function Mo(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 _o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Oo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_o(Object(r),!0).forEach(function(t){Io(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_o(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Io(e,t,r){return(t=function(e){var t=function(e){if("object"!=wo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=wo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==wo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Co=function(e,t){var r,n,o,i,a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"meters",n=e.geometry.coordinates,o=[],i=_n(n[1],n[0]),a=In(n[0],t,i,{units:r});o.push(a.geometry.coordinates);for(var s=0;s<n.length;s++){if(s>0&&s<n.length-1){var u=_n(n[s-1],n[s]),c=In(n[s],t,u,{units:r});o.push(c.geometry.coordinates)}o.push(n[s])}var l=_n(n[n.length-2],n[n.length-1]),p=In(n[n.length-1],t,l,{units:r});return o.push(p.geometry.coordinates),rt(o)}(t);try{i=function(e,t){var r=[],n=[],o=[],i=function(e,t,r,n,o){for(var i=0,a=[],s="Feature"===t.type?t.geometry:t,u="LineString"===s.type?[s.coordinates]:s.coordinates,c=0,l=0;l<u.length;l++){for(var p=u[l].length-1,d=new sn(u[l][0]),f=null,h={nextEdge:null},y=0;y<p;y++){f=new sn(u[l][y+1]),d.nextPoint=f,f.prevPoint=d;var g=new an(d,f,"polyline",c,null);n.push(g),h.nextEdge=g,g.prevEdge=h,o[0]=Math.min(o[0],d.p[0]),o[1]=Math.min(o[1],d.p[1]),o[2]=Math.max(o[2],d.p[0]),o[3]=Math.max(o[3],d.p[1]),d=f,c+=1,h=g}o[0]=Math.min(o[0],u[l][p][0]),o[1]=Math.min(o[1],u[l][p][1]),o[2]=Math.max(o[2],u[l][p][0]),o[3]=Math.max(o[3],u[l][p][1])}for(var m="Feature"===e.type?e.geometry:e,v="Polygon"===m.type?[m.coordinates]:m.coordinates,b=v.length,S=0;S<b;S++)for(var E=v[S].length,w=0;w<E;w++){i+=1;var P=v[S][w],x=P.length;a.push(new un(i,P));for(var M=new sn(P[0]),_=M,O=void 0,I=null,C={nextEdge:null,prevEdge:null},T=null,A=1;A<x;A++)O=new sn(P[A]),_.nextPoint=O,O.prevPoint=_,I=new an(_,O,"polygon",c,i),C.nextEdge=I,I.prevEdge=C,1===A&&(T=I),w>0&&(I.interiorRing=!0),I.intersectPolylineBbox=cn(I,o),r.push(I),_=O,c+=1,C=I;I.nextEdge=T,T.prevEdge=I,O.nextPoint=M.nextPoint,M.prevPoint=O.prevPoint}return a}(Vr(e),t,n,o,[1/0,1/0,1/0,1/0]);if(function(e,t,r){var n,o,i,a=t.length,s=e.length;for(n=0;n<a;n++){var u=t[n];for(o=0;o<s;o++){var c=e[o];if(c.intersectPolylineBbox&&!(c.maxX<u.minX||c.minX>u.maxX||c.maxY<u.minY||c.minY>u.maxY)){var l=yn(u,c);if(null!==l)for(i=0;i<l.length;i++){var p=on(c.p1.p[0],c.p1.p[1],c.p2.p[0],c.p2.p[1],u.p1.p[0],u.p1.p[1]),d=new ln(l[i],u,c,p>0);r.push(d)}}}}t.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolylineEdgeStart-t.distanceFromPolylineEdgeStart})}),e.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolygonEdgeStart-t.distanceFromPolygonEdgeStart})})}(n,o,r),0===r.length)return e;var a={};i.forEach(function(e){return a[e.id]=0}),r.forEach(function(e){var t=e.polygonEdge.polygonContourId;a[t]=a[t]+1});for(var s=0,u=[],c=null,l=0;l<o.length;l++){var p=o[l];if(p.intersectionPoints.length>0){c=p.intersectionPoints[0];break}}for(var d=c,f={visitCount:1};c!==f&&!(s>2*r.length);){if(s=s++,f.visitCount>=2){for(var h=!1,y=0;y<r.length;y++){var g=r[y];if(g.visitCount<2){d=g,h=!0;break}}if(!h)break}d.visitCount=d.visitCount+1;var m=[];u.push(m),m.push(d.p),d.visitCount=d.visitCount+1;var v=bn(d,m),b=!1;if(v===(f=v)&&2===r.length)for(var S=0;S<r.length;S++)r[S].visitCount<2&&(b=!0);for(;v!==d||b;)(v=(v.isHeadingIn?wn:En)(v,m))!==d&&(v=bn(v,m)),b=!1;if(f.visitCount>=2){for(var E=!1,w=0;w<r.length;w++){var P=r[w];if(P.visitCount<2){d=P,E=!0;break}}E&&(f=d)}d=f}for(var x=u.map(function(e){return[e]}),M=Object.keys(a),_=0;_<M.length;_++){var O=M[_];0===a[O]&&vn(mn(gn(n,parseInt(O)),i),x)}return{type:"Feature",properties:{},geometry:{type:"MultiPolygon",coordinates:x}}}(e,a)}catch(e){return null}var s=[];if("MultiPolygon"!==i.geometry.type)return null;if(2!==i.geometry.coordinates.length)return null;s=i.geometry.coordinates.map(function(t){return tt(t,e.properties)});var u=null!==(r=null!==(n=e.id)&&void 0!==n?n:null===(o=e.properties)||void 0===o?void 0:o.id)&&void 0!==r?r:"poly";return nt(s.map(function(t,r){return tt(t.geometry.coordinates,Oo(Oo({},e.properties),{},{id:u}),{id:"".concat(u,"-").concat(r+1)})}))},To=function(e,t){var r=Po(e,2),n=r[0],o=r[1],i=Po(t,2),a=i[0],s=i[1],u=function(e){return e*Math.PI/180},c=u(s-o),l=u(a-n),p=Math.pow(Math.sin(c/2),2)+Math.cos(u(o))*Math.cos(u(s))*Math.pow(Math.sin(l/2),2);return 12742e3*Math.atan2(Math.sqrt(p),Math.sqrt(1-p))},Ao=function(e){if(e[0].length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e[0].length<=1)return!0;if(e[0].length<=3)for(var r=0;r<e[0].length;r++)for(var n=r+1;n<e[0].length;n++)if(To(e[0][r],e[0][n])<t)return!1;return!0}(e))return!0;if(!Array.isArray(e)||e.length<4)return!1;var t=e[0],r=e[e.length-1];if(t[0]!==r[0]||t[1]!==r[1])return!1;var n=tt([e]);return!(!function(e){if(!e.type)return!1;const t=Mn(e),r=t.type,n=t.coordinates;switch(r){case"Point":return n.length>1;case"MultiPoint":for(var o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"LineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"MultiLineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"Polygon":for(o=0;o<t.coordinates.length;o++){if(n[o].length<4)return!1;if(!yo(n[o]))return!1;if(go(n[o]))return!1;if(o>0&&Bn(tt([n[0]]),tt([n[o]])).features.length>1)return!1}return!0;case"MultiPolygon":for(o=0;o<t.coordinates.length;o++)for(var i=t.coordinates[o],a=0;a<i.length;a++){if(i[a].length<4)return!1;if(!yo(i[a]))return!1;if(go(i[a]))return!1;if(0===a&&!mo(i,t.coordinates,o))return!1;if(a>0&&Bn(tt([i[0]]),tt([i[a]])).features.length>1)return!1}return!0;default:return!1}}(n)||Eo(n)<=0)},Lo=function(e,t,r){var n=t.filter(function(t,n){var o=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);return("ArrowUp"===r?t[1]<=e[1]&&i>=o:"ArrowDown"===r?t[1]>e[1]&&i>=o:"ArrowLeft"===r?t[0]<=e[0]&&i<o:"ArrowRight"!==r||t[0]>e[0]&&i<o)&&JSON.stringify(t)!==JSON.stringify(e)});n.length||n.push(e);var o,i=n.map(function(t){return r=Math.abs(e[0]-t[0]),n=Math.abs(e[1]-t[1]),Math.sqrt(Math.pow(r,2)+Math.pow(n,2));var r,n}),a=n[i.indexOf(Math.min.apply(Math,(o=i,function(e){if(Array.isArray(e))return Mo(e)}(o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||xo(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.")}())))];return t.findIndex(function(e){return JSON.stringify(e)===JSON.stringify(a)})};function ko(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)||No(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 Fo(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=No(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 jo(e){return function(e){if(Array.isArray(e))return Vo(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||No(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 No(e,t){if(e){if("string"==typeof e)return Vo(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)?Vo(e,t):void 0}}function Vo(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 Do={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]},getCoordPath:function(e,t){var r=this.getFeature(e.featureId);if(!r)return"0";var n=nr(r),o=or(n,t);if(!o)return"0";var i=o.segment,a=o.localIdx;return[].concat(jo(i.path),[a]).join(".")},syncVertices:function(e){e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)},getVerticies:function(e){return rr(this.getFeature(e))||[]},getMidpoints:function(e){var t=this.getFeature(e),r=rr(t),n=nr(t);if(null==r||!r.length||!n.length)return[];var o,i=[],a=Fo(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,p=s.start+(c+1)%s.length,d=ko(r[l],2),f=d[0],h=d[1],y=ko(r[p],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(jo(e.vertecies.map(i)),jo(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=Lo(s,a,t);return[u,u<e.vertecies.length?"vertex":"midpoint"]},getVertexIndexFromMidpoint:function(e,t){var r,n=this.getFeature(e.featureId),o=nr(n),i=t.split(".").map(Number),a=0,s=Fo(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 Ro(e){return Ro="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},Ro(e)}function Uo(e){return function(e){if(Array.isArray(e))return Go(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Bo(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 Bo(e,t){if(e){if("string"==typeof e)return Go(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)?Go(e,t):void 0}}function Go(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 Yo(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 Xo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Yo(Object(r),!0).forEach(function(t){Ho(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Ho(e,t,r){return(t=function(e){var t=function(e){if("object"!=Ro(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Ro(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ro(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Jo=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),qo={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},$o=Xo(Xo(Xo(Xo(Xo(Xo({},Ft),lr),mr),Mr),Do),{},{onSetup:function(e){var t,r,n=this,o=Ft.onSetup.call(this,e);Object.assign(o,{container:e.container,interfaceType:e.interfaceType,deleteVertexButtonId:e.deleteVertexButtonId,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,featureId:o.featureId||e.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});var i=this.getFeature(o.featureId);o.featureType=null==i?void 0:i.type,o.vertecies=this.getVerticies(o.featureId),o.midpoints=this.getMidpoints(o.featureId),this.setupEventListeners(o),"midpoint"===e.selectedVertexType?(o.selectedCoordPaths=[],this.clearSelectedCoordinates(),o.feature&&o.feature.changed(),this._ctx.store.render(),this.updateMidpoint(o.midpoints[e.selectedVertexIndex-o.vertecies.length])):-1===e.selectedVertexIndex&&(o.selectedCoordPaths=[],this.clearSelectedCoordinates(),o.feature&&o.feature.changed(),this._ctx.store.render()),this.map._drawEditContainer=e.container,this.addTouchVertexTarget(o);var a=v(this.map);if(a&&w(a,this.map),"touch"===o.interfaceType&&o.selectedVertexIndex>=0&&"vertex"===o.selectedVertexType){var s=o.vertecies[o.selectedVertexIndex];s&&setTimeout(function(){n.updateTouchVertexTarget(o,sr(n.map.project(s),o.scale))},0)}return o._ignorePointermoveDeselect=!0,setTimeout(function(){o._ignorePointermoveDeselect=!1},100),o},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)};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)},onSelectionChange:function(e,t){var r,n,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=rr(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?sr(this.map.project(u),e.scale):null)},onScaleChange:function(e,t){e.scale=t.scale},onUpdate:function(e){var t,r=new Set(e.vertecies.map(function(e){return JSON.stringify(e)}));r.size!==e.vertecies.length&&(e.selectedVertexIndex=e.vertecies.findIndex(function(e){return!r.has(JSON.stringify(e))}),null!==(t=e.selectedVertexType)&&void 0!==t||(e.selectedVertexType=e.selectedVertexIndex>=0?"vertex":null))},onKeydown:function(e,t){if(e.container.contains(document.activeElement)){if(e.interfaceType="keyboard",this.hideTouchVertexIndicator(e)," "===t.key&&e.selectedVertexIndex<0){var r,n,o=v(this.map);if(o&&w(o,this.map),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;return e.isPanEnabled=!1,this.updateVertex(e)}if(!t.altKey&&Jo.has(t.key)&&e.selectedVertexIndex>=0){if(t.preventDefault(),t.stopPropagation(),"midpoint"===e.selectedVertexType)return this.insertVertex(e,t);var i=v(this.map),a=this.getFeature(e.featureId);if(!a)return;var s=rr(a),u=null==s?void 0:s[e.selectedVertexIndex];if(!u)return;if(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=Uo(u),e._keyboardMoveStartIndex=e.selectedVertexIndex),x(e)&&e._isSnapped&&i){var c=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:15}(i)+1,l=this.map.project(u),p=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)||Bo(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.")}()}(qo[t.key].map(function(e){return e*c}),2),d=p[0],f=p[1];return e._isSnapped=!1,w(i,this.map),this.moveVertex(e,this.map.unproject({x:l.x+d,y:l.y+f}))}var h=this.getNewCoord(e,t);return x(e)&&i&&(E(i,this.map,this.map.project(h)),b(i))?(e._isSnapped=!0,this.moveVertex(e,S(i))):(e._isSnapped=!1,this.moveVertex(e,h))}if(t.altKey&&Jo.has(t.key)&&e.selectedVertexIndex>=0)return t.preventDefault(),t.stopPropagation(),this.updateVertex(e,t.key);if("Escape"===t.key&&this.changeMode(e,{isPanEnabled:!0,selectedVertexIndex:-1,selectedVertexType:null}),"z"===t.key&&(t.metaKey||t.ctrlKey)&&!t.shiftKey){var y,g=null===(y=document.activeElement)||void 0===y?void 0:y.tagName;if("INPUT"===g||"TEXTAREA"===g)return;return t.preventDefault(),t.stopPropagation(),this.handleUndo(e)}}},onKeyup:function(e,t){e.container.contains(document.activeElement)&&(e.interfaceType="keyboard",Jo.has(t.key)&&e.selectedVertexIndex>=0&&(t.stopPropagation(),e._keyboardMoveStartPosition&&void 0!==e._keyboardMoveStartIndex&&(this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._keyboardMoveStartIndex,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null,e._keyboardMoveStartIndex=void 0)),"Delete"===t.key&&this.deleteVertex(e))},onMouseDown:function(e,t){var r,n;P(v(this.map));var o=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,i=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if(["vertex","midpoint"].includes(o)&&(e.dragMoveLocation=t.lngLat,e.dragMoving=!1,Ft.onMouseDown.call(this,e,t),"vertex"===o&&i)){var a,s=this.getFeature(e.featureId),u=ar(s,i);e.selectedVertexIndex=u,e.selectedVertexType="vertex",e.coordPath=i;var c=null===(a=e.vertecies)||void 0===a?void 0:a[u];c&&(e._moveStartPosition=Uo(c),e._moveStartIndex=u)}if("midpoint"===o){var l=this.getFeature(e.featureId),p=ar(l,i);e._insertedVertexIndex=p,e._isInsertingVertex=!0,e.selectedVertexIndex=this.getVertexIndexFromMidpoint(e,i),e.selectedVertexType="vertex",e.coordPath=null,this.map.fire("draw.vertexselection",{index:e.selectedVertexIndex,numVertecies:e.vertecies.length})}},onMouseUp:function(e,t){P(v(this.map));var r=!1;if(e._moveStartPosition&&void 0!==e._moveStartIndex){var n=this.getFeature(e.featureId);if(n){var o,i=null===(o=rr(n))||void 0===o?void 0:o[e._moveStartIndex];i&&(r=i[0]!==e._moveStartPosition[0]||i[1]!==e._moveStartPosition[1])}}var a=e._isInsertingVertex&&void 0!==e._insertedVertexIndex;if(e.dragMoving||r||a)if(this.syncVertices(e),a){var s=e._insertedVertexIndex;this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:s}),e.selectedVertexIndex=s,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=void 0,this.map.fire("draw.vertexselection",{index:s,numVertecies:e.vertecies.length})}else r&&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=null,Ft.onMouseUp.call(this,e,t)},onDrag:function(e,t){var r;if("touch"!==e.interfaceType){this.map.fire("draw.geometrychange",e.feature);var n=v(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),x(e)&&null!=n&&n.status){if(null!==(r=e.selectedCoordPaths)&&void 0!==r&&r.length&&e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation(),E(n,this.map,t.point);var o=S(n)||t.lngLat;e.feature.updateCoordinate(e.selectedCoordPaths[0],o.lng,o.lat),e.dragMoveLocation=t.lngLat}}else Ft.onDrag.call(this,e,t)}},onMove:function(e){var t=e.vertecies[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,sr(this.map.project(t),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",Xo(Xo({},e),t))},onStop:function(e){this.map._drawEditContainer=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.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 Ko(e){return Ko="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},Ko(e)}function Wo(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)||zo(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 zo(e,t){if(e){if("string"==typeof e)return Zo(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)?Zo(e,t):void 0}}function Zo(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 Qo(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 ei(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Qo(Object(r),!0).forEach(function(t){ti(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Qo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ti(e,t,r){return(t=function(e){var t=function(e){if("object"!=Ko(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Ko(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ko(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ri=function(e,t){var r=t.featureProp,n=t.geometryType,o=t.getCoords,i=t.validateClick,a=t.createVertices,s=t.excludeFeatureIdFromSetup,u=void 0!==s&&s,c=t.finishOnInvalidClick,l=void 0!==c&&c,p=function(e){return e[r]};return ei(ei({},e),{},{onSetup:function(t){var n=this,o=this.map,i=u?ei(ei({},t),{},{featureId:void 0}):t,a=ei(ei({},e.onSetup.call(this,i)),t);a[r].properties=t.properties;var s=a.container,c=a.interfaceType,l=a.vertexMarkerId,p=s.querySelector("#".concat(l));p.style.display=["touch","keyboard"].includes(c)?"block":"none",a.vertexMarker=p;var d={keydownHandler:this.onKeydown,keyupHandler:this.onKeyup,focusHandler:this.onFocus,blurHandler:this.onBlur,createHandler:this.onCreate,moveHandler:this.onMove,pointerdownHandler:this.onPointerdown,pointermoveHandler:this.onPointermove,pointerupHandler:this.onPointerup,vertexButtonClickHandler:this.onVertexButtonClick,undoHandler:this.onUndo};return Object.entries(d).forEach(function(e){var t,r,o=Wo(e,2);return t=o[0],r=o[1],n[t]=r.bind(n,a)}),this._listeners=[[window,"keydown",this.keydownHandler],[window,"keyup",this.keyupHandler],[window,"click",this.vertexButtonClickHandler],[s,"focus",this.focusHandler],[s,"blur",this.blurHandler],[s,"pointermove",this.pointermoveHandler],[s,"pointerup",this.pointerupHandler],[o,"pointerdown",this.pointerdownHandler],[o,"draw.create",this.createHandler],[o,"move",this.moveHandler],[o,"draw.undo",this.undoHandler]],this._listeners.forEach(function(e){var t=Wo(e,3),r=t[0],n=t[1],o=t[2];return r.addEventListener?r.addEventListener(n,o):r.on(n,o)}),a},onClick:function(t,r){if(!(r.originalEvent.button>0||this.map._undoInProgress||r.originalEvent.target!==this.map.getCanvas())){var n=v(this.map);if(x(t)&&b(n))r=function(e,t){var r=S(t);return r?g(g({},e),{},{lngLat:r}):e}(r,n);else{var a=o(p(t));if(a.length>0&&(a[a.length-1]=[r.lngLat.lng,r.lngLat.lat]),!l&&!i(p(t)))return}var s=o(p(t)).length;e.onClick.call(this,t,r),o(p(t)).length>s&&this.pushDrawUndo(t)}},onTap:function(){},doClick:function(t){if(!this.map._undoInProgress){var r=p(t),n=o(r);if(this.dispatchVertexChange(n),i(r)){var a=v(this.map),s=x(t)&&function(e,t){var r=S(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,a),u=n.length;s?(e.onClick.call(this,t,s),this._ctx.store.render()):this._simulateMouse("click",e.onClick,t);var c=o(p(t));c.length>u&&(this.pushDrawUndo(t),this.dispatchVertexChange(c))}else l&&n.length>1&&(n.pop(),this.map.fire("draw.create",{features:[r.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[r.id]}))}},dispatchVertexChange:function(e){this.map.fire("draw.vertexchange",{numVertecies:Math.max(0,e.length-1)})},pushDrawUndo:function(e){var t=this.map._undoStack;t&&!this.map._undoInProgress&&t.push({type:"draw_vertex",geometryType:n,featureId:p(e).id})},undoVertex:function(e){var t=p(e),r=o(t);return!(r.length<2)&&(2===r.length?this._reinitializeFeature(e,t):(this._removeLastVertex(e,t,r),!0))},_reinitializeFeature:function(t,o){var i=o.id;if(this._ctx.store.delete([i]),"LineString"===n){var a=this.map._undoStack;return a&&a.clear(),this._ctx.api.changeMode("draw_line",{featureId:i,container:t.container,interfaceType:t.interfaceType,vertexMarkerId:t.vertexMarkerId,addVertexButtonId:t.addVertexButtonId,getSnapEnabled:t.getSnapEnabled,properties:t.properties}),!0}var s=this.map.getCenter(),u=[[s.lng,s.lat],[s.lng,s.lat]],c=this.newFeature({type:"Feature",properties:t.properties||{},geometry:{type:n,coordinates:[u]}});return c.id=i,this._ctx.store.add(c),t[r]=c,t.currentVertexPosition=0,this._ctx.store.render(),this._simulateMouse("mousemove",e.onMouseMove,t),this._ctx.store.render(),this.dispatchVertexChange(u),!0},_removeLastVertex:function(e,t,r){var i="Polygon"===n?t.coordinates[0]:r;i.splice(i.length-2,1);var a,s=i[i.length-2];s&&(i[i.length-1]=function(e){if(Array.isArray(e))return Zo(e)}(a=s)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||zo(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,o(t))},_updateRubberBand:function(t,r){if(["touch","keyboard"].includes(t.interfaceType))this._simulateMouse("mousemove",e.onMouseMove,t),this._ctx.store.render();else{var o=r["Polygon"===n?r.length-2:r.length-1];if(o){var i={lng:o[0],lat:o[1]},a=this.map.project(i);e.onMouseMove.call(this,t,{lngLat:i,point:a,originalEvent:new MouseEvent("mousemove",{clientX:a.x,clientY:a.y})}),this._ctx.store.render()}}this.dispatchVertexChange(r)},onUndo:function(e,t){var r;"draw_vertex"===(null===(r=t.operation)||void 0===r?void 0:r.type)&&this.undoVertex(e)},_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)},_setInterface:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];e.interfaceType=t,r&&(e.vertexMarker.style.display="block")},onCreate:function(e,t){var r=this._ctx.api,n=t.features[0];r.delete(n.id),n.id=e.featureId,r.add(n,{userProperties:!0})},onVertexButtonClick:function(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest("#".concat(e.addVertexButtonId))&&this.doClick(e)},onTouchStart:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onTouchEnd:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onKeydown:function(e,t){var r=this;if("z"!==t.key||!t.metaKey&&!t.ctrlKey||t.shiftKey){if(document.activeElement===e.container){if("Escape"===t.key)return t.preventDefault();"Enter"===t.key&&(e.isActive=!0),this._setInterface(e,"keyboard"),this.onMove(e,t)}}else{var n,o=null===(n=document.activeElement)||void 0===n?void 0:n.tagName;if("INPUT"===o||"TEXTAREA"===o)return;t.preventDefault(),t.stopPropagation();var i=this.map._undoStack;if(i&&i.length>0){var a=i.pop();"draw_vertex"===(null==a?void 0:a.type)&&(this.map._undoInProgress=!0,setTimeout(function(){r.map._undoInProgress=!1},100),this.undoVertex(e))}}},onKeyup:function(e,t){"Escape"!==t.key?document.activeElement===e.container&&(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(t,r){var n=document.activeElement;if(!n||n===t.container||!t.container.contains(n))if("Escape"!==r.key)n!==t.container&&e.onKeyUp.call(this,t,r);else if("keyboard"===t.interfaceType){var o=this.map._undoStack;o&&o.clear(),this._reinitializeFeature(t,p(t))}},onFocus:function(e){e.vertexMarker.style.display=["touch","keyboard"].includes(e.interfaceType)?"block":"none"},onBlur:function(e,t){t.target!==e.container&&(e.vertexMarker.style.display="none")},onMouseMove:function(t,r){if(x(t)){var n=v(this.map);E(n,this.map,r.point);var o=S(n);o&&(r=ei(ei({},r),{},{lngLat:o}))}this.map.fire("draw.geometrychange",t.polygon||t.line),e.onMouseMove.call(this,t,r)},onMove:function(t){if(["touch","keyboard"].includes(t.interfaceType)){x(t)&&function(e,t){if(!e||!t||!e.status)return!1;var r=t.getCenter(),n=t.project(r);e.snapToClosestPoint({point:n,lngLat:r})}(v(this.map),this.map);var r=v(this.map),n=x(t)&&S(r);if(n){var o=this.map.project([n.lng,n.lat]);e.onMouseMove.call(this,t,{lngLat:n,point:o,originalEvent:new MouseEvent("mousemove",{clientX:o.x,clientY:o.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render()}else this._simulateMouse("mousemove",e.onMouseMove,t)}},onPointerdown:function(e,t){"touch"!==t.pointerType&&this._setInterface(e,"pointer",!1)},onPointermove:function(e,t){"touch"!==t.pointerType&&(e.vertexMarker.style.display="none")},onPointerup:function(e){this.dispatchVertexChange(o(p(e)))},toDisplayFeatures:function(t,r,o){e.toDisplayFeatures.call(this,t,r,o);var i=p(t);r.geometry.type===n&&r.id===i.id&&a(r,o,We)},onStop:function(t){e.onStop.call(this,t),this._listeners.forEach(function(e){var t=Wo(e,3),r=t[0],n=t[1],o=t[2];return r.removeEventListener?r.removeEventListener(n,o):r.off(n,o)}),t.vertexMarker.style.display="none"}})},ni=ri(Rt,{featureProp:"polygon",geometryType:"Polygon",getCoords:function(e){return e.coordinates[0]},validateClick:function(e){return Ao(e.coordinates)},createVertices:function(e,t,r){for(var n=e.geometry.coordinates[0],o=1;o<n.length-2;o++)t(r(e.id,n[o],"0.".concat(o)))}}),oi=ri(Bt,{featureProp:"line",geometryType:"LineString",getCoords:function(e){return e.coordinates},validateClick:function(e){return(t=e.coordinates).length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e.length<=1)return!0;if(e.length>=2){var r=e[e.length-1],n=e[e.length-2];if(To(r,n)<t)return!1}return!0}(t);var t},excludeFeatureIdFromSetup:!0,finishOnInvalidClick:!0,createVertices:function(e,t,r){for(var n=e.geometry.coordinates,o=1;o<n.length-1;o++)t(r(e.id,n[o],"".concat(o)))}}),ii={editStroke:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editVertex:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editMidpoint:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editHalo:{light:"#ffffff",dark:"rgba(11,12,12,1)"},editActive:{light:"rgba(11,12,12,1)",dark:"#ffffff"},splitInvalid:{light:"rgba(29,112,184,1)",dark:"rgba(29,112,184,1)"},splitValid:{light:"rgba(29,112,184,1)",dark:"rgba(29,112,184,1)"},shapeStroke:"rgba(212,53,28,1)",shapeFill:"rgba(212,53,28,0.1)",strokeWidth:2,snapVertex:"rgba(212,53,28,1)",snapMidpoint:"rgba(40,161,151,1)",snapEdge:"rgba(29,112,184,1)",snapRadius:10,snapLayers:[]};function ai(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 si=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;return["coalesce",["get","user_".concat(t).concat(e.id.charAt(0).toUpperCase()+e.id.slice(1))],["get","user_".concat(t)],ii[r]]},ui=function(e){return{id:"fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","false"]],paint:{"fill-color":si(e,"fill","shapeFill")}}},ci=function(e){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":si(e,"stroke","shapeStroke"),"line-width":si(e,"strokeWidth")}}},li=function(e){return{id:"fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":e,"fill-opacity":.1}}},pi=function(e){return{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":e,"line-width":2,"line-opacity":1}}},di=function(e){return{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":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}},fi=function(e){return{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":e,"line-width":2,"line-opacity":1}}},hi=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}}},yi=function(e){return{id:"vertex",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"]],paint:{"circle-radius":6,"circle-color":e}}},gi=function(e,t){return{id:"vertex-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":8,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},mi=function(e){return{id:"vertex-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":e}}},vi=function(e){return{id:"midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":4,"circle-color":e}}},bi=function(e,t){return{id:"midpoint-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},Si=function(e){return{id:"midpoint-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":4,"circle-color":e}}},Ei=function(e){return{id:"circle",type:"line",filter:["==","id","circle"],paint:{"line-color":e,"line-width":2,"line-opacity":.8}}},wi=function(e){var t=function(e){var t;return null!==(t=e.mapColorScheme)&&void 0!==t?t:"light"}(e),r=ii.editStroke[t],n=ii.editVertex[t],o=ii.editMidpoint[t],i=ii.editHalo[t],a=ii.editActive[t],s=ii.splitInvalid[t],u=ii.splitValid[t];return[ui(e),li(r),pi(r),ci(e),di(s),fi(u),hi(r),vi(o),bi(i,a),Si(o),yi(n),gi(i,a),mi(n),Ei(r),{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}}]},Pi=6371008.8,xi={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:Pi,metres:Pi,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function Mi(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 _i(e,t,r){if(void 0===r&&(r={}),!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");if(e.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ai(e[0])||!Ai(e[1]))throw new Error("coordinates must contain numbers");return Mi({type:"Point",coordinates:e},t,r)}function Oi(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 Mi({type:"LineString",coordinates:e},t,r)}function Ii(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 Ci(e){return e%(2*Math.PI)*180/Math.PI}function Ti(e){return e%360*Math.PI/180}function Ai(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function Li(e){if(!e)throw new Error("coord is required");if(!Array.isArray(e)){if("Feature"===e.type&&null!==e.geometry&&"Point"===e.geometry.type)return e.geometry.coordinates;if("Point"===e.type)return e.coordinates}if(Array.isArray(e)&&e.length>=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function ki(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 Fi=function(e,t,r){void 0===r&&(r={});var n=Li(e),o=Li(t),i=Ti(o[1]-n[1]),a=Ti(o[0]-n[0]),s=Ti(n[1]),u=Ti(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=xi[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 ji(e,t,r){if(null!==e)for(var n,o,i,a,s,u,c,l,p=0,d=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,S=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var E=a.type;switch(p=!r||"Polygon"!==E&&"MultiPolygon"!==E?0:1,E){case null:break;case"Point":if(!1===t(u,d,m,b,S))return!1;d++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],d,m,b,S))return!1;d++,"MultiPoint"===E&&b++}"LineString"===E&&b++;break;case"Polygon":case"MultiLineString":for(n=0;n<u.length;n++){for(o=0;o<u[n].length-p;o++){if(!1===t(u[n][o],d,m,b,S))return!1;d++}"MultiLineString"===E&&b++,"Polygon"===E&&S++}"Polygon"===E&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(S=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-p;i++){if(!1===t(u[n][o][i],d,m,b,S))return!1;d++}S++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===ji(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Ni(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 Vi(e,t){!function(e,t){var r,n,o,i,a,s,u,c,l,p,d=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,p=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,d,c,l,p))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===t(i.geometries[n],d,c,l,p))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,d,c,l,p))return!1;d++}}(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(Mi(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(Mi({type:a,coordinates:c},n),r,u))return!1}})}function Di(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={}),Mi({type:"MultiLineString",coordinates:e},t,r)}(n,o):Oi(n[0],o)}function Ri(e,t,r,n){void 0===n&&(n={});var o=Li(e),i=Ti(o[0]),a=Ti(o[1]),s=Ti(r),u=function(e,t){void 0===t&&(t="kilometers");var r=xi[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 _i([Ci(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),Ci(c)],n.properties)}const Ui=function(e){if(!e)throw new Error("geojson is required");var t=[];return Vi(e,function(e){!function(e,t){var r=[],n=e.geometry;if(null!==n){switch(n.type){case"Polygon":r=ki(n);break;case"LineString":r=[ki(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=Oi([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)}),Ii(t)};var Bi=r(945);function Gi(e,t){var r=ki(e),n=ki(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],p=n[1][1],d=(p-c)*(a-o)-(l-u)*(s-i);if(0===d)return null;var f=((l-u)*(i-c)-(p-c)*(o-u))/d,h=((a-o)*(i-c)-(s-i)*(o-u))/d;return f>=0&&f<=1&&h>=0&&h<=1?_i([o+f*(a-o),i+f*(s-i)]):null}const Yi=function(e,t){var r={},n=[];if("LineString"===e.type&&(e=Mi(e)),"LineString"===t.type&&(t=Mi(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=Gi(e,t);return o&&n.push(o),Ii(n)}var i=Bi();return i.load(Ui(t)),Ni(Ui(e),function(e){Ni(i.search(e),function(t){var o=Gi(e,t);if(o){var i=ki(o).join(",");r[i]||(r[i]=!0,n.push(o))}})}),Ii(n)},Xi=function(e,t,r){void 0===r&&(r={});var n=_i([1/0,1/0],{dist:1/0}),o=0;return Vi(e,function(e){for(var i=ki(e),a=0;a<i.length-1;a++){var s=_i(i[a]);s.properties.dist=Fi(t,s,r);var u=_i(i[a+1]);u.properties.dist=Fi(t,u,r);var c=Fi(s,u,r),l=Math.max(s.properties.dist,u.properties.dist),p=_n(s,u),d=Ri(t,l,p+90,r),f=Ri(t,l,p-90,r),h=Yi(Oi([d.geometry.coordinates,f.geometry.coordinates]),Oi([s.geometry.coordinates,u.geometry.coordinates])),y=null;h.features.length>0&&((y=h.features[0]).properties.dist=Fi(t,y,r),y.properties.location=o+Fi(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 Hi=6371008.8,Ji={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:Hi,metres:Hi,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function qi(e){return e%(2*Math.PI)*180/Math.PI}function $i(e){return e%360*Math.PI/180}function Ki(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function Wi(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 zi=function(e,t,r){void 0===r&&(r={});var n=Wi(e),o=Wi(t),i=$i(o[1]-n[1]),a=$i(o[0]-n[0]),s=$i(n[1]),u=$i(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=Ji[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)},Zi=function(e,t){var r=function(e,t,r,n){void 0===n&&(n={});var o=Wi(e),i=$i(o[0]),a=$i(o[1]),s=$i(r),u=function(e,t){void 0===t&&(t="kilometers");var r=Ji[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(!Ki(e[0])||!Ki(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)}([qi(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),qi(c)],n.properties)}(e,zi(e,t)/2,_n(e,t));return r};var Qi=function(){return Qi=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},Qi.apply(this,arguments)},ea=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=Qi(Qi({},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 Fi(_i(e),_i(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],p=!1;for(var n in t)if(this.isPointSnapped(l,t[n])){p=!0,u.push(t[n]);break}0==p&&u.push(l)}i.push(u)}e.geometry.coordinates=i;break;case"LineString":var d=e.geometry.coordinates;for(u=[],c=0;c<d.length;c++){var f=d[c];for(var n in p=!1,t)if(this.isPointSnapped(f,t[n])){p=!0,u.push(t[n]);break}0==p&&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=Fi(_i([r.lng,r.lat]),_i([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(On(e,t,-360*o/n,r).geometry.coordinates);return i.push(i[0]),tt([i],o)}(s.coords,i,{steps:64,units:"meters",properties:{color:s.color}})):(this.snapStatus=!1,this.snapCoords=[]);var u=Ii(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(Ii([])))}),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=[],ji(e,function(e){n.push(e)}),n),i=[];if(o.map(function(e){var n=Fi(_i(e),_i([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(Oi(e))});break;case"Polygon":var o=Di(e.geometry);n.push(o);break;case"MultiPolygon":Di(e.geometry).coodinates.map(function(e){n.push(Oi(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(Ui(e).features)});var i=[];if(o.map(function(e){var n=Zi(e.geometry.coordinates[0],e.geometry.coordinates[1]),o=Fi(n,_i([t.lng,t.lat]),{units:"meters"});o<r&&i.push({coords:n.geometry.coordinates,dist:o,color:"#03a9f4"})}),i.length>0)return i.sort(function(e,t){return e.dist-t.dist}),i[0]},e.prototype.searchInEdge=function(e,t,r){for(var n=this.getLines(e,t,r),o=[],i=0;i<n.length;i++){var a=Xi(n[i],_i([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 ta=ea;function ra(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 na(e,t,r){return(t=function(e){var t=function(e){if("object"!=oa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=oa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==oa(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function oa(e){return oa="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},oa(e)}var ia="snap-helper-circle";function aa(e,t){!function r(){var n=e();null!==n&&(n?t(n):requestAnimationFrame(r))}()}function sa(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"===oa(e)&&Array.isArray(e.features)?e:{type:"FeatureCollection",features:[]}},configurable:!0})}}function ua(e){return ua="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},ua(e)}function ca(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function la(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ca(Object(r),!0).forEach(function(t){pa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ca(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function pa(e,t,r){return(t=function(e){var t=function(e){if("object"!=ua(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ua(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ua(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var da=function(e){var t=e.mapStyle,r=e.mapProvider,n=e.events,o=e.eventBus,i=e.snapLayers,a=r.map;Zt.constants.classes.CONTROL_BASE="maplibregl-ctrl",Zt.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",Zt.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var s=la(la({},Zt.modes),{},{disabled:Qt,edit_vertex:$o,draw_polygon:ni,draw_line:oi}),u=new Zt({modes:s,styles:wi(t),displayControlsDefault:!1,userProperties:!0,defaultMode:"disabled"});a.addControl(u);var c=a.getCanvas(),l=null,p=function(e){1===e.touches.length&&(l={x:e.touches[0].clientX,y:e.touches[0].clientY,time:Date.now()})},d=function(e){if("disabled"===u.getMode()&&l){var t=e.changedTouches[0],r=t.clientX-l.x,n=t.clientY-l.y;Date.now()-l.time<300&&Math.abs(r)<10&&Math.abs(n)<10&&c.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY})),l=null}else l=null};c.addEventListener("touchstart",p,{passive:!0}),c.addEventListener("touchend",d,{passive:!0}),r.draw=u,a._drawCurrentMapStyle=t,r.snapEnabled=!1;var f=function(e){var t=[],r=function(){e.fire("draw.undochange",{length:t.length})};return{push:function(e){t.push(e),r()},pop:function(){var e=t.pop();return r(),e},clear:function(){t.length=0,r()},get length(){return t.length}}}(a);r.undoStack=f,a._undoStack=f,function(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?15:i,s=r.rules,u=void 0===s?["vertex","midpoint","edge"]:s,c=r.status,l=void 0!==c&&c,p=r.onSnapped,d=void 0===p?function(){}:p,f=r.colors;function h(r){if(e._snapInstance||e._snapCreating)return e._snapInstance;e._snapCreating=!0,e.getLayer(ia)&&e.removeLayer(ia),e.getSource(ia)&&e.removeSource(ia),sa(r);var n=new ta({map:e,drawing:t,options:{layers:o,radius:a,rules:u},status:l,onSnapped:d}),i=l;return Object.defineProperty(n,"status",{get:function(){return i},set:function(){},configurable:!0}),n.setSnapStatus=function(e){i=e},n._defaultLayers=o,n._activeLayers=null,n.setSnapLayers=function(e){null==e?n._activeLayers=null:Array.isArray(e)&&(n._activeLayers=e)},void 0!==e._pendingSnapLayers&&(n.setSnapLayers(e._pendingSnapLayers),delete e._pendingSnapLayers),e._snapInstance=n,n}!function(e){if(!ta.prototype.__snapPatched){ta.prototype.__snapPatched=!0;var t=ta.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(){},t.setMapData=function(e){var t,n;if(this.status){var o=r.setMapData.call(this,e);return(null==e||null===(t=e.features)||void 0===t?void 0:t.length)>0&&null!==(n=this.map)&&void 0!==n&&n.getLayer(ia)&&this.map.setLayoutProperty(ia,"visibility","visible"),o}},t.drawingSnapCheck=function(){if(this.status)return r.drawingSnapCheck.call(this)},t.getLines=function(e,t,n){var o=e.geometry;if(!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 tt(e)}):"MultiLineString"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return rt(e)}):r.getLines.call(this,e,t,n)}catch(e){return console.log(e),[]}},t.getCloseFeatures=function(e,t){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||15,a=e.point;e.point=[[a.x-i,a.y-i],[a.x+i,a.y+i]];var s=r.getCloseFeatures.call(this,e,t);return e.point=a,s},t.searchInVertex=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInVertex.apply(this,n);return i&&(i.color=e.vertex),i},t.searchInMidPoint=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInMidPoint.apply(this,n);return i&&(i.color=e.midpoint),i},t.searchInEdge=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInEdge.apply(this,n);return i&&(i.color=e.edge),i},t.snapToClosestPoint=function(e){var t;if(this.status&&(null===(t=this.map)||void 0===t||!t._isZooming))try{var n,o,i=r.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){console.log(e),this.snapStatus=!1,this.snapCoords=null}}}}(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ra(Object(r),!0).forEach(function(t){na(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ra(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({vertex:ii.snapVertex,midpoint:ii.snapMidpoint,edge:ii.snapEdge},void 0===f?{}:f)),e.on("style.load",function(){aa(function(){return e._removed?null:e.getSource("mapbox-gl-draw-hot")},function(t){var r;sa(t),e.getSource(ia)||e.addSource(ia,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(ia)||e.addLayer({id:ia,type:"fill",source:ia,paint:{"fill-color":["get","color"],"fill-opacity":.6},layout:{visibility:null!==(r=e._snapInstance)&&void 0!==r&&r.status?"visible":"none"}}),e._snapInstance||h(t)})}),e.on("zoomstart",function(){e._isZooming=!0}),e.on("zoomend",function(){if(e._isZooming=!1,e.getLayer(ia)){e.setLayoutProperty(ia,"visibility","none");var t=e._snapInstance;null!=t&&t.status&&e.setLayoutProperty(ia,"visibility","visible")}}),aa(function(){return e._removed?null:e.getSource("mapbox-gl-draw-hot")},h)}(a,u,{layers:i,radius:10,rules:["vertex","edge"]});var h=function(e){a._drawCurrentMapStyle=e,a.once("idle",function(){var t;!function(e,t){wi(t).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 ai(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)?ai(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)})})}(a,e);var r=null===(t=a._drawEditContainer)||void 0===t?void 0:t.querySelector("[data-touch-vertex-target]");gr(r,e)})};return o.on(n.MAP_SET_STYLE,h),o.on(n.MAP_SET_SIZE,function(e){a.fire("draw.scalechange",{scale:{small:1,medium:1.5,large:2}[e]})}),{draw:u,remove:function(){c.removeEventListener("touchstart",p),c.removeEventListener("touchend",d),o.off(n.MAP_SET_STYLE,h),u.deleteAll(),u.changeMode("disabled"),a.removeControl(u)}}};function fa(e){return fa="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},fa(e)}function ha(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 ya(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)?ya(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 ya(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 ga=["stroke","fill","strokeWidth"],ma=function(e){if(!e)return{};for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var o=ha(n[r],2),i=o[0],a=o[1];if(ga.includes(i)&&"object"===fa(a)&&null!==a){var s=Object.entries(a);s.length>0&&(t[i]=s[0][1]);for(var u=0,c=s;u<c.length;u++){var l=ha(c[u],2),p=l[0],d=l[1];t["".concat(i).concat(p.charAt(0).toUpperCase()+p.slice(1))]=d}}else t[i]=a}return t};function va(e){return va="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},va(e)}var ba=["stroke","fill","strokeWidth","properties"];function Sa(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 Ea(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Sa(Object(r),!0).forEach(function(t){wa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Sa(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function wa(e,t,r){return(t=function(e){var t=function(e){if("object"!=va(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=va(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==va(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Pa(e){return Pa="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Pa(e)}var xa=["stroke","fill","strokeWidth","properties"];function Ma(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?Ma(Object(r),!0).forEach(function(t){Oa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ma(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Oa(e,t,r){return(t=function(e){var t=function(e){if("object"!=Pa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Pa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Pa(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ia(e){return Ia="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ia(e)}var Ca=["stroke","fill","strokeWidth","properties"];function Ta(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Aa(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ta(Object(r),!0).forEach(function(t){La(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ta(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function La(e,t,r){return(t=function(e){var t=function(e){if("object"!=Ia(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Ia(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ia(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ka(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 Fa(e){return Fa="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},Fa(e)}function ja(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 Na(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ja(Object(r),!0).forEach(function(t){Va(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ja(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Va(e,t,r){return(t=function(e){var t=function(e){if("object"!=Fa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Fa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Fa(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Da=function(e){return{mobile:{slot:"actions",showLabel:e},tablet:{slot:"actions",showLabel:e},desktop:{slot:"actions",showLabel:e}}},Ra={reducer:{initialState:{mode:null,action:null,actionValid:!1,feature:null,tempFeature:null,selectedVertexIndex:-1,numVertecies:null,snap:!1,hasSnapLayers:!1,undoStackLength:0},actions:p},InitComponent:function(e){var t=e.appState,r=e.appConfig,n=e.mapState,o=e.pluginConfig,i=e.pluginState,a=e.services,s=e.mapProvider,u=e.buttonConfig,c=a.eventBus,l=n.crossHair,p=["touch","keyboard"].includes(t.interfaceType);(0,d.useEffect)(function(){var e,r,a,u,l,p=null===(e=null===(r=o.includeModes)||void 0===r?void 0:r.includes(t.mode))||void 0===e||e,d=null!==(a=null===(u=o.excludeModes)||void 0===u?void 0:u.includes(t.mode))&&void 0!==a&&a;if(n.isMapReady&&p&&!d){var h=da({mapStyle:n.mapStyle,snapLayers:o.snapLayers,mapProvider:s,events:f,eventBus:c}).remove;return i.dispatch({type:"SET_HAS_SNAP_LAYERS",payload:(null===(l=o.snapLayers)||void 0===l?void 0:l.length)>0}),c.emit("draw:ready"),function(){return h()}}},[n.isMapReady,t.mode]),(0,d.useEffect)(function(){if(["draw_polygon","draw_line"].includes(i.mode)&&p){var e=l.isVisible;return l.fixAtCenter(),function(){e||l.hide()}}},[i.mode,t.interfaceType]),(0,d.useEffect)(function(){if(s.draw){var e=function(e){var t=e.pluginState,r=e.mapProvider,n=e.buttonConfig,o=e.eventBus,i=n.drawDone,a=n.drawAddPoint,s=n.drawUndo,u=n.drawDeletePoint,c=n.drawSnap,l=n.drawCancel,p=r.map,d=r.draw,f=t.dispatch,h=t.feature,y=t.tempFeature,g=function(){r.snapEnabled=!1,f({type:"SET_SNAP",payload:!1});var e,t=v(p);t&&(null===(e=t.setSnapStatus)||void 0===e||e.call(t,!1),P(t)),p.getLayer("snap-helper-circle")&&p.setLayoutProperty("snap-helper-circle","visibility","none")},m=function(){var e;null===(e=r.undoStack)||void 0===e||e.clear(),f({type:"SET_MODE",payload:null}),f({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}})},b=function(){d.trash(),null!=y&&y.id&&d.delete(y.id),h&&d.add(h),g(),d.changeMode("disabled"),m(),o.emit("draw:cancelled",h)},S=0,E=["draw_polygon","draw_line"],x=function(e){E.includes(e.mode)||w(v(p),p)},M=function(){var e,t=p.getStyle().layers||[];!t.length||null!==(e=t[t.length-1].source)&&void 0!==e&&e.startsWith("mapbox-gl-draw")||t.filter(function(e){var t;return null===(t=e.source)||void 0===t?void 0:t.startsWith("mapbox-gl-draw")}).forEach(function(e){return p.moveLayer(e.id)})},_=function(e){return function(t){var r=t.features[0];g(),m(),setTimeout(function(){return d.changeMode("disabled")},0),o.emit(e,r)}},O=function(e){var t=e.features[0];o.emit("draw:updated",t)},I=_("draw:created"),C=_("draw:edited"),T=function(e){f({type:"SET_SELECTED_VERTEX_INDEX",payload:e}),o.emit("draw:vertexselection",e)},A=function(e){f({type:"SET_SELECTED_VERTEX_INDEX",payload:{index:-1,numVertecies:e.numVertecies}})},L=function(e){f({type:"SET_UNDO_STACK_LENGTH",payload:e.length})};return i.onClick=function(){var e,t=d.getMode();g(),null===(e=r.undoStack)||void 0===e||e.clear(),"edit_vertex"!==t?["draw_polygon","draw_line"].includes(t)&&d.changeMode("disabled"):p.fire("draw.editfinish",{features:[d.get(y.id)]})},l.onClick=b,s.onClick=function(){if("edit_vertex"!==d.getMode()){var e=r.undoStack;if(null!=e&&e.length){var t=e.pop();p._undoInProgress=!0,setTimeout(function(){p._undoInProgress=!1},100),p.fire("draw.undo",{operation:t})}}},c.onClick=function(){var e=Date.now();if(!(e-S<300)){S=e;var n=!t.snap;f({type:"TOGGLE_SNAP"}),r.snapEnabled=n;var o=v(p);null!=o&&o.setSnapStatus&&o.setSnapStatus(n),!n&&o&&(P(o),p.getLayer("snap-helper-circle")&&p.setLayoutProperty("snap-helper-circle","visibility","none"))}},p.on("styledata",M),p.on("draw.cancel",b),p.on("draw.create",I),p.on("draw.modechange",x),p.on("draw.editfinish",C),p.on("draw.update",O),p.on("draw.vertexselection",T),p.on("draw.vertexchange",A),p.on("draw.undochange",L),function(){[i,a,s,u,c,l].forEach(function(e){e&&(e.onClick=null)}),p.off("styledata",M),p.off("draw.cancel",b),p.off("draw.create",I),p.off("draw.editfinish",C),p.off("draw.update",O),p.off("draw.modechange",x),p.off("draw.vertexselection",T),p.off("draw.vertexchange",A),p.off("draw.undochange",L)}}({appState:t,appConfig:r,mapState:n,mapProvider:s,buttonConfig:u,pluginState:i,events:f,eventBus:c});return function(){return e()}}},[s,t,i])},buttons:[Na({id:"drawCancel",label:"Cancel",variant:"tertiary",exclusiveSlot:!0,hiddenWhen:function(e){return!e.pluginState.mode}},Da(!0)),Na({id:"drawAddPoint",label:"Add point",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.appState,r=e.pluginState;return!["draw_polygon","draw_line"].includes(r.mode)||"touch"!==t.interfaceType}},Da(!0)),Na({id:"drawDone",label:"Done",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){var t=e.pluginState;return t.numVertecies>=("draw_polygon"===t.mode?3:2)}},Da(!0)),{id:"drawMenu",label:"Menu",iconId:"menu",hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},menuItems:[{id:"drawUndo",label:"Undo",iconId:"undo",hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){return e.pluginState.undoStackLength>0}},{id:"drawSnap",label:"Snap to feature",iconId:"magnet",hiddenWhen:function(e){var t=e.pluginState;return!t.mode||!t.hasSnapLayers},pressedWhen:function(e){return!!e.pluginState.snap}},{id:"drawDeletePoint",label:"Delete point",iconId:"trash",enableWhen:function(e){var t,r=e.pluginState;return r.selectedVertexIndex>=0&&r.numVertecies>("Polygon"===(null===(t=r.tempFeature)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type)?3:2)},hiddenWhen:function(e){var t=e.pluginState;return!["simple_select","edit_vertex"].includes(t.mode)}}],mobile:{slot:"bottom-right"},tablet:{slot:"top-middle"},desktop:{slot:"top-middle"}}],keyboardShortcuts:[{id:"drawStart",group:"Drawing",title:"Edit vertex",command:"<kbd>Spacebar</kbd></dd>"}],icons:[{id:"menu",svgContent:'<path d="m6 9 6 6 6-6"/>'},{id:"undo",svgContent:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/>'},{id:"check",svgContent:'<path d="M20 6 9 17l-5-5"/>'},{id:"magnet",svgContent:'<path d="m12 15 4 4"/><path d="M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z"/><path d="m5 8 4 4"/>'},{id:"trash",svgContent:'<path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>'}],api:{newPolygon:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginConfig,a=e.pluginState,s=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=a.dispatch,p=s.draw,d=s.map,f=u.eventBus;if(p){f.emit("draw:started",{mode:"draw_polygon"});var h;h=void 0!==c.snapLayers?c.snapLayers:void 0!==i.snapLayers?i.snapLayers:null;var y=v(d);null!=y&&y.setSnapLayers?y.setSnapLayers(h):h&&(d._pendingSnapLayers=h),l({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=h)||void 0===r?void 0:r.length)>0});var g=c.stroke,m=c.fill,b=c.strokeWidth,S=c.properties,E=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(c,ba),w=Ea(Ea({},S),ma({stroke:g,fill:m,strokeWidth:b}));p.changeMode("draw_polygon",Ea(Ea({container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,getSnapEnabled:function(){return!0===s.snapEnabled},featureId:t},E),{},{properties:w})),l({type:"SET_MODE",payload:"draw_polygon"})}},newLine:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginConfig,a=e.pluginState,s=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=a.dispatch,p=s.draw,d=s.map,f=u.eventBus;if(p){f.emit("draw:started",{mode:"draw_line"});var h;h=void 0!==c.snapLayers?c.snapLayers:void 0!==i.snapLayers?i.snapLayers:null;var y=v(d);null!=y&&y.setSnapLayers?y.setSnapLayers(h):h&&(d._pendingSnapLayers=h),l({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=h)||void 0===r?void 0:r.length)>0});var g=c.stroke,m=c.fill,b=c.strokeWidth,S=c.properties,E=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(c,xa),w=_a(_a({},S),ma({stroke:g,fill:m,strokeWidth:b}));p.changeMode("draw_line",_a(_a({container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,getSnapEnabled:function(){return!0===s.snapEnabled},featureId:t},E),{},{properties:w})),l({type:"SET_MODE",payload:"draw_line"})}},editFeature:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.mapState,a=e.pluginConfig,s=e.pluginState,u=e.mapProvider,c=e.services,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},p=s.dispatch,d=u.draw,f=u.map,h=c.eventBus;if(!d)return!1;var y=d.get(t);if(!y)return!1;h.emit("draw:editstart",{mode:{LineString:"edit_line",Polygon:"edit_polygon"}[y.geometry.type]});var g,m=null;m=void 0===l.snapLayers?null!==(g=a.snapLayers)&&void 0!==g?g:null:l.snapLayers;var b=v(f);null!=b&&b.setSnapLayers?b.setSnapLayers(m):m&&(f._pendingSnapLayers=m),p({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=m)||void 0===r?void 0:r.length)>0}),d.changeMode("edit_vertex",{container:n.layoutRefs.viewportRef.current,deleteVertexButtonId:"".concat(o.id,"-draw-delete-point"),undoButtonId:"".concat(o.id,"-draw-undo"),isPanEnabled:"keyboard"!==n.interfaceType,interfaceType:n.interfaceType,scale:{small:1,medium:1.5,large:2}[i.mapSize],featureId:t,getSnapEnabled:function(){return!0===u.snapEnabled}});var S=d.get(t);return p({type:"SET_FEATURE",payload:{feature:S,tempFeature:S}}),p({type:"SET_MODE",payload:"edit_vertex"}),!0},addFeature:function(e,t){var r=e.mapProvider,n=e.services,o=r.draw,i=n.eventBus;if(o){var a=t.stroke,s=t.fill,u=t.strokeWidth,c=t.properties,l=Aa(Aa({},function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(t,Ca)),{},{properties:Aa(Aa({},c),ma({stroke:a,fill:s,strokeWidth:u}))});o.add(l,{userProperties:!0}),i.emit("draw:add",l)}},deleteFeature:function(e,t){var r=e.mapProvider,n=e.services,o=r.draw,i=n.eventBus;o&&(o.delete(t),i.emit("draw:delete",{featureIds:t}))},split:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginState,a=e.mapProvider,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=i.dispatch,c=a.draw,l=a.map;if(c){var p=c.get(t),d=["stroke-inactive.cold"].concat(function(e){if(Array.isArray(e))return ka(e)}(r=s.snapLayers||[])||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 ka(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)?ka(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.")}()),f=v(l);null!=f&&f.setSnapLayers?f.setSnapLayers(d):s.snapLayers&&(l._pendingSnapLayers=d),u({type:"SET_HAS_SNAP_LAYERS",payload:!0}),c.changeMode("draw_line",{container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,getSnapEnabled:function(){return!0===a.snapEnabled},featureId:"_splitter",properties:{splitter:"invalid"}}),l.on("draw.create",function(e){var t=e.features[0],r=Co(p,t);c.setFeatureProperty("_splitter","splitter",r?"valid":"invalid"),u({type:"SET_ACTION",payload:{name:"split",isValid:!!r}})});var h,y,g,m=(h=function(e){if(!(e.coordinates.length<2)){var t={id:"_splitter",geometry:{type:"LineString",coordinates:e.coordinates}},r=!!Co(p,t);e.properties.splitter=r?"valid":"invalid",e.ctx.store.render(),"edit_vertex"===c.getMode()&&u({type:"SET_ACTION",payload:{name:"split",isValid:r}})}},g=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];clearTimeout(y),y=setTimeout(function(){return h.apply(void 0,t)},50)},g.cancel=function(){clearTimeout(y),y=null},g);l.on("draw.geometrychange",m),u({type:"SET_MODE",payload:"draw_line"}),u({type:"SET_ACTION",payload:{name:"split"}})}},merge:function(e,t){e.services,console.log("merge"),console.log(t)}}}}}]);
1
+ (this.webpackChunkdefra_DefraMap=this.webpackChunkdefra_DefraMap||[]).push([[966],{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 S=0,E=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,S,E))return!1;f++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,S,E))return!1;f++,"MultiPoint"===w&&S++}"LineString"===w&&S++;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,S,E))return!1;f++}"MultiLineString"===w&&S++,"Polygon"===w&&E++}"Polygon"===w&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(E=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,S,E))return!1;f++}E++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,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 S=0,E=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,S,E))return!1;f++,S++;break;case"LineString":case"MultiPoint":for(n=0;n<c.length;n++){if(!1===t(c[n],f,v,S,E))return!1;f++,"MultiPoint"===w&&S++}"LineString"===w&&S++;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,S,E))return!1;f++}"MultiLineString"===w&&S++,"Polygon"===w&&E++}"Polygon"===w&&S++;break;case"MultiPolygon":for(n=0;n<c.length;n++){for(E=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,S,E))return!1;f++}E++}S++}break;case"GeometryCollection":for(n=0;n<s.geometries.length;n++)if(!1===o(s.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i(e,t){var r;switch(e.type){case"FeatureCollection":for(r=0;r<e.features.length&&!1!==t(e.features[r].properties,r);r++);break;case"Feature":t(e.properties,0)}}function a(e,t){if("Feature"===e.type)t(e,0);else if("FeatureCollection"===e.type)for(var r=0;r<e.features.length&&!1!==t(e.features[r],r);r++);}function s(e,t){var r,n,o,i,a,s,u,c,l,d,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}},379(e,t,r){"use strict";r.r(t),r.d(t,{manifest:()=>Ua});var n={};r.r(n),r.d(n,{LAT_MAX:()=>D,LAT_MIN:()=>N,LAT_RENDERED_MAX:()=>R,LAT_RENDERED_MIN:()=>V,LNG_MAX:()=>B,LNG_MIN:()=>U,activeStates:()=>F,classes:()=>M,cursors:()=>I,events:()=>A,geojsonTypes:()=>C,interactions:()=>j,meta:()=>k,modes:()=>T,sources:()=>_,types:()=>O,updateActions:()=>L});var o={};r.r(o),r.d(o,{isActiveFeature:()=>X,isBackspaceKey:()=>Z,isDeleteKey:()=>Q,isDigit1Key:()=>ee,isDigit2Key:()=>te,isDigit3Key:()=>re,isDigitKey:()=>ne,isEnterKey:()=>z,isEscapeKey:()=>W,isFeature:()=>q,isInactiveFeature:()=>H,isOfMetaType:()=>G,isShiftDown:()=>K,isShiftMousedown:()=>Y,isTrue:()=>oe,isVertex:()=>$,noTarget:()=>J});var i={};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}r.r(i),r.d(i,{CommonSelectors:()=>o,ModeHandler:()=>be,StringSet:()=>de,constrainFeatureMovement:()=>It,createMidPoint:()=>vt,createSupplementaryPoints:()=>bt,createVertex:()=>We,doubleClickZoom:()=>St,euclideanDistance:()=>ge,featuresAt:()=>fe,getFeatureAtAndSetCursors:()=>ye,isClick:()=>me,isEventAtCoordinates:()=>Vt,isTap:()=>ve,mapEventToBoundingBox:()=>ce,moveFeatures:()=>Ot,sortFeatures:()=>ue,stringSetsAreEqual:()=>Kt,theme:()=>qe,toDenseArray:()=>De});var l=new Set(["draw_polygon","draw_line"]),d={SET_MODE:function(e,t){return u(u({},e),{},{mode:t,numVertecies:l.has(t)?0:e.numVertecies})},SET_ACTION:function(e,t){return u(u({},e),{},{action:t.name,actionValid:t.isValid})},SET_FEATURE:function(e,t){return u(u({},e),{},{feature:void 0===t.feature?e.feature:t.feature,tempFeature:void 0===t.tempFeature?e.tempFeature:t.tempFeature})},SET_SELECTED_VERTEX_INDEX:function(e,t){return u(u({},e),{},{selectedVertexIndex:t.index,numVertecies:t.numVertecies})},TOGGLE_SNAP:function(e){return u(u({},e),{},{snap:!e.snap})},SET_SNAP:function(e,t){return u(u({},e),{},{snap:!!t})},SET_HAS_SNAP_LAYERS:function(e,t){return u(u({},e),{},{hasSnapLayers:!!t})},SET_UNDO_STACK_LENGTH:function(e,t){return u(u({},e),{},{undoStackLength:t})}},p=r(738),f={APP_ADD_MARKER:"app:addmarker",APP_UPDATE_MARKER:"app:updatemarker",APP_REMOVE_MARKER:"app:removemarker",APP_SET_MODE:"app:setmode",APP_REVERT_MODE:"app:revertmode",APP_ADD_BUTTON:"app:addbutton",APP_TOGGLE_BUTTON_STATE:"app:togglebuttonstate",APP_ADD_PANEL:"app:addpanel",APP_REMOVE_PANEL:"app:removepanel",APP_SHOW_PANEL:"app:showpanel",APP_HIDE_PANEL:"app:hidepanel",APP_ADD_CONTROL:"app:addcontrol",APP_READY:"app:ready",APP_OPENED:"app:opened",APP_CLOSED:"app:closed",APP_FULLSCREEN_CHANGE:"app:fullscreenchange",APP_PANEL_OPENED:"app:panelopened",APP_PANEL_CLOSED:"app:panelclosed",MAP_SET_STYLE:"map:setstyle",MAP_SET_SIZE:"map:setsize",MAP_SET_FEATURES:"map:setfeatures",MAP_SET_ACTIVE_FEATURE:"map:setactivefeature",MAP_SELECT_FEATURE:"map:selectfeature",MAP_SET_PIXEL_RATIO:"map:setpixelratio",MAP_FIT_TO_BOUNDS:"map:fittobounds",MAP_SET_VIEW:"map:setview",MAP_INIT_MAP_STYLES:"map:initmapstyles",MAP_STYLE_CHANGE:"map:stylechange",MAP_LOADED:"map:loaded",MAP_READY:"map:ready",MAP_SIZE_CHANGE:"map:sizechange",MAP_FIRST_IDLE:"map:firstidle",MAP_MOVE_START:"map:movestart",MAP_MOVE:"map:move",MAP_MOVE_END:"map:moveend",MAP_STATE_UPDATED:"map:stateupdated",MAP_DATA_CHANGE:"map:datachange",MAP_RENDER:"map:render",MAP_CLICK:"map:click",MAP_DESTROY:"map:destroy"};function h(e){return h="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},h(e)}function y(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 g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?y(Object(r),!0).forEach(function(t){m(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function m(e,t,r){return(t=function(e){var t=function(e){if("object"!=h(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=h(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==h(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v(e){var t;return null!==(t=null==e?void 0:e._snapInstance)&&void 0!==t?t:null}function b(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 S(e){return b(e)?{lng:e.snapCoords[0],lat:e.snapCoords[1]}:null}function E(e,t,r){if(!e||!t||!e.status)return!1;var n=t.unproject(r);return e.snapToClosestPoint({point:r,lngLat:n}),!0}function w(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 P(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 x(e){return"function"==typeof(null==e?void 0:e.getSnapEnabled)&&!0===e.getSnapEnabled()}const M={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"},_={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},I={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},O={POLYGON:"polygon",LINE:"line_string",POINT:"point"},C={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"},T={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select"},A={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"},L={MOVE:"move",CHANGE_PROPERTIES:"change_properties",CHANGE_COORDINATES:"change_coordinates"},k={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},F={ACTIVE:"true",INACTIVE:"false"},j=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],N=-90,V=-85,D=90,R=85,U=-270,B=270;function G(e){return function(t){const r=t.featureTarget;return!!r&&!!r.properties&&r.properties.meta===e}}function Y(e){return!!e.originalEvent&&!!e.originalEvent.shiftKey&&0===e.originalEvent.button}function X(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===F.ACTIVE&&e.featureTarget.properties.meta===k.FEATURE}function H(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.active===F.INACTIVE&&e.featureTarget.properties.meta===k.FEATURE}function J(e){return void 0===e.featureTarget}function q(e){return!!e.featureTarget&&!!e.featureTarget.properties&&e.featureTarget.properties.meta===k.FEATURE}function $(e){const t=e.featureTarget;return!!t&&!!t.properties&&t.properties.meta===k.VERTEX}function K(e){return!!e.originalEvent&&!0===e.originalEvent.shiftKey}function W(e){return"Escape"===e.key||27===e.keyCode}function z(e){return"Enter"===e.key||13===e.keyCode}function Z(e){return"Backspace"===e.key||8===e.keyCode}function Q(e){return"Delete"===e.key||46===e.keyCode}function ee(e){return"1"===e.key||49===e.keyCode}function te(e){return"2"===e.key||50===e.keyCode}function re(e){return"3"===e.key||51===e.keyCode}function ne(e){const t=e.key||String.fromCharCode(e.keyCode);return t>="0"&&t<="9"}function oe(){return!0}var ie=r(778);const ae={Point:0,LineString:1,MultiLineString:1,Polygon:2};function se(e,t){const r=ae[e.geometry.type]-ae[t.geometry.type];return 0===r&&e.geometry.type===C.POLYGON?e.area-t.area:r}const ue=function(e){return e.map(e=>(e.geometry.type===C.POLYGON&&(e.area=ie.geometry({type:C.FEATURE,property:{},geometry:e.geometry})),e)).sort(se).map(e=>(delete e.area,e))},ce=function(e,t=0){return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]};function le(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)}le.prototype.add=function(e){return this.has(e)||(this._length++,"string"==typeof e?this._items[e]=this._length:this._nums[e]=this._length),this},le.prototype.delete=function(e){return!1===this.has(e)||(this._length--,delete this._items[e],delete this._nums[e]),this},le.prototype.has=function(e){return!("string"!=typeof e&&"number"!=typeof e||void 0===this._items[e]&&void 0===this._nums[e])},le.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)},le.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const de=le,pe=[k.FEATURE,k.MIDPOINT,k.VERTEX],fe={click:function(e,t,r){return he(e,t,r,r.options.clickBuffer)},touch:function(e,t,r){return he(e,t,r,r.options.touchBuffer)}};function he(e,t,r,n){if(null===r.map)return[];const o=e?ce(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!==pe.indexOf(e.properties.meta)),s=new de,u=[];return a.forEach(e=>{const t=e.properties.id;s.has(t)||(s.add(t),u.push(e))}),ue(u)}function ye(e,t){const r=fe.click(e,null,t),n={mouse:I.NONE};return r[0]&&(n.mouse=r[0].properties.active===F.ACTIVE?I.MOVE:I.POINTER,n.feature=r[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(n.mouse=I.ADD),t.ui.queueMapClasses(n),t.ui.updateMapClasses(),r[0]}function ge(e,t){const r=e.x-t.x,n=e.y-t.y;return Math.sqrt(r*r+n*n)}function me(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=ge(e.point,t.point);return a<n||a<o&&t.time-e.time<i}function ve(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,ge(e.point,t.point)<n&&t.time-e.time<o}const be=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)}}},Se=((e,t=21)=>(r=t)=>{let n="",o=0|r;for(;o--;)n+=e[Math.random()*e.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",32);function Ee(){return Se()}const we=function(e,t){this.ctx=e,this.properties=t.properties||{},this.coordinates=t.geometry.coordinates,this.id=t.id||Ee(),this.type=t.geometry.type};we.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},we.prototype.incomingCoords=function(e){this.setCoordinates(e)},we.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},we.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},we.prototype.setProperty=function(e,t){this.properties[e]=t},we.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:C.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},we.prototype.internal=function(e){const t={id:this.id,meta:k.FEATURE,"meta:type":this.type,active:F.INACTIVE,mode:e};if(this.ctx.options.userProperties)for(const e in this.properties)t[`user_${e}`]=this.properties[e];return{type:C.FEATURE,properties:t,geometry:{coordinates:this.getCoordinates(),type:this.type}}};const Pe=we,xe=function(e,t){Pe.call(this,e,t)};(xe.prototype=Object.create(Pe.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},xe.prototype.updateCoordinate=function(e,t,r){this.coordinates=3===arguments.length?[t,r]:[e,t],this.changed()},xe.prototype.getCoordinate=function(){return this.getCoordinates()};const Me=xe,_e=function(e,t){Pe.call(this,e,t)};(_e.prototype=Object.create(Pe.prototype)).isValid=function(){return this.coordinates.length>1},_e.prototype.addCoordinate=function(e,t,r){this.changed();const n=parseInt(e,10);this.coordinates.splice(n,0,[t,r])},_e.prototype.getCoordinate=function(e){const t=parseInt(e,10);return JSON.parse(JSON.stringify(this.coordinates[t]))},_e.prototype.removeCoordinate=function(e){this.changed(),this.coordinates.splice(parseInt(e,10),1)},_e.prototype.updateCoordinate=function(e,t,r){const n=parseInt(e,10);this.coordinates[n]=[t,r],this.changed()};const Ie=_e,Oe=function(e,t){Pe.call(this,e,t),this.coordinates=this.coordinates.map(e=>e.slice(0,-1))};(Oe.prototype=Object.create(Pe.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every(e=>e.length>2)},Oe.prototype.incomingCoords=function(e){this.coordinates=e.map(e=>e.slice(0,-1)),this.changed()},Oe.prototype.setCoordinates=function(e){this.coordinates=e,this.changed()},Oe.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])},Oe.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))},Oe.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]]))},Oe.prototype.getCoordinates=function(){return this.coordinates.map(e=>e.concat([e[0]]))},Oe.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 Ce=Oe,Te={MultiPoint:Me,MultiLineString:Ie,MultiPolygon:Ce},Ae=(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)},Le=function(e,t){if(Pe.call(this,e,t),delete this.coordinates,this.model=Te[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)};(Le.prototype=Object.create(Pe.prototype))._coordinatesToFeatures=function(e){const t=this.model.bind(this);return e.map(e=>new t(this.ctx,{id:Ee(),type:C.FEATURE,properties:{},geometry:{coordinates:e,type:this.type.replace("Multi","")}}))},Le.prototype.isValid=function(){return this.features.every(e=>e.isValid())},Le.prototype.setCoordinates=function(e){this.features=this._coordinatesToFeatures(e),this.changed()},Le.prototype.getCoordinate=function(e){return Ae(this.features,"getCoordinate",e)},Le.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(e=>e.type===C.POLYGON?e.getCoordinates():e.coordinates)))},Le.prototype.updateCoordinate=function(e,t,r){Ae(this.features,"updateCoordinate",e,t,r),this.changed()},Le.prototype.addCoordinate=function(e,t,r){Ae(this.features,"addCoordinate",e,t,r),this.changed()},Le.prototype.removeCoordinate=function(e){Ae(this.features,"removeCoordinate",e),this.changed()},Le.prototype.getFeatures=function(){return this.features};const ke=Le;function Fe(e){this.map=e.map,this.drawConfig=JSON.parse(JSON.stringify(e.options||{})),this._ctx=e}Fe.prototype.setSelected=function(e){return this._ctx.store.setSelected(e)},Fe.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),{})},Fe.prototype.getSelected=function(){return this._ctx.store.getSelected()},Fe.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},Fe.prototype.isSelected=function(e){return this._ctx.store.isSelected(e)},Fe.prototype.getFeature=function(e){return this._ctx.store.get(e)},Fe.prototype.select=function(e){return this._ctx.store.select(e)},Fe.prototype.deselect=function(e){return this._ctx.store.deselect(e)},Fe.prototype.deleteFeature=function(e,t={}){return this._ctx.store.delete(e,t)},Fe.prototype.addFeature=function(e,t={}){return this._ctx.store.add(e,t)},Fe.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},Fe.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},Fe.prototype.setActionableState=function(e={}){const t={trash:e.trash||!1,combineFeatures:e.combineFeatures||!1,uncombineFeatures:e.uncombineFeatures||!1};return this._ctx.events.actionable(t)},Fe.prototype.changeMode=function(e,t={},r={}){return this._ctx.events.changeMode(e,t,r)},Fe.prototype.fire=function(e,t){return this._ctx.events.fire(e,t)},Fe.prototype.updateUIClasses=function(e){return this._ctx.ui.queueMapClasses(e)},Fe.prototype.activateUIButton=function(e){return this._ctx.ui.setActiveButton(e)},Fe.prototype.featuresAt=function(e,t,r="click"){if("click"!==r&&"touch"!==r)throw new Error("invalid buffer type");return fe[r](e,t,this._ctx)},Fe.prototype.newFeature=function(e){const t=e.geometry.type;return t===C.POINT?new Me(this._ctx,e):t===C.LINE_STRING?new Ie(this._ctx,e):t===C.POLYGON?new Ce(this._ctx,e):new ke(this._ctx,e)},Fe.prototype.isInstanceOf=function(e,t){if(e===C.POINT)return t instanceof Me;if(e===C.LINE_STRING)return t instanceof Ie;if(e===C.POLYGON)return t instanceof Ce;if("MultiFeature"===e)return t instanceof ke;throw new Error(`Unknown feature class: ${e}`)},Fe.prototype.doRender=function(e){return this._ctx.store.featureChanged(e)};const je=Fe;Fe.prototype.onSetup=function(){},Fe.prototype.onDrag=function(){},Fe.prototype.onClick=function(){},Fe.prototype.onMouseMove=function(){},Fe.prototype.onMouseDown=function(){},Fe.prototype.onMouseUp=function(){},Fe.prototype.onMouseOut=function(){},Fe.prototype.onKeyUp=function(){},Fe.prototype.onKeyDown=function(){},Fe.prototype.onTouchStart=function(){},Fe.prototype.onTouchMove=function(){},Fe.prototype.onTouchEnd=function(){},Fe.prototype.onTap=function(){},Fe.prototype.onStop=function(){},Fe.prototype.onTrash=function(){},Fe.prototype.onCombineFeature=function(){},Fe.prototype.onUncombineFeature=function(){},Fe.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};const Ne={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(Ne);const De=function(e){return[].concat(e).filter(e=>void 0!==e)};function Re(){const e=this;if(!e.ctx.map||void 0===e.ctx.map.getSource(_.HOT))return s();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 s(){e.isDirty=!1,e.clearChangedIds()}r.forEach(e=>a(e,"hot")),n.forEach(e=>a(e,"cold")),i&&e.ctx.map.getSource(_.COLD).setData({type:C.FEATURE_COLLECTION,features:e.sources.cold}),e.ctx.map.getSource(_.HOT).setData({type:C.FEATURE_COLLECTION,features:e.sources.hot}),s()}function Ue(e){let t;this._features={},this._featureIds=new de,this._selectedFeatureIds=new de,this._selectedCoordinates=[],this._changedFeatureIds=new de,this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=e,this.sources={hot:[],cold:[]},this.render=()=>{t||(t=requestAnimationFrame(()=>{t=null,Re.call(this),this._emitSelectionChange&&(this.ctx.events.fire(A.SELECTION_CHANGE,{features:this.getSelected().map(e=>e.toGeoJSON()),points:this.getSelectedCoordinates().map(e=>({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:e.coordinates}}))}),this._emitSelectionChange=!1),this.ctx.events.fire(A.RENDER,{})}))},this.isDirty=!1}function Be(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}Ue.prototype.createRenderBatch=function(){const e=this.render;let t=0;return this.render=function(){t++},()=>{this.render=e,t>0&&this.render()}},Ue.prototype.setDirty=function(){return this.isDirty=!0,this},Ue.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(A.CREATE,{features:[t.toGeoJSON()]})}return this},Ue.prototype.featureChanged=function(e,t={}){return this._changedFeatureIds.add(e),!0!==(null!=t.silent?t.silent:this.ctx.options.suppressAPIEvents)&&this.ctx.events.fire(A.UPDATE,{action:t.action?t.action:L.CHANGE_COORDINATES,features:[this.get(e).toGeoJSON()]}),this},Ue.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Ue.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Ue.prototype.getAllIds=function(){return this._featureIds.values()},Ue.prototype.add=function(e,t={}){return this._features[e.id]=e,this._featureIds.add(e.id),this.featureCreated(e.id,{silent:t.silent}),this},Ue.prototype.delete=function(e,t={}){const r=[];return De(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(A.DELETE,{features:r}),Be(this,t),this},Ue.prototype.get=function(e){return this._features[e]},Ue.prototype.getAll=function(){return Object.keys(this._features).map(e=>this._features[e])},Ue.prototype.select=function(e,t={}){return De(e).forEach(e=>{this._selectedFeatureIds.has(e)||(this._selectedFeatureIds.add(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),this},Ue.prototype.deselect=function(e,t={}){return De(e).forEach(e=>{this._selectedFeatureIds.has(e)&&(this._selectedFeatureIds.delete(e),this._changedFeatureIds.add(e),t.silent||(this._emitSelectionChange=!0))}),Be(this,t),this},Ue.prototype.clearSelected=function(e={}){return this.deselect(this._selectedFeatureIds.values(),{silent:e.silent}),this},Ue.prototype.setSelected=function(e,t={}){return e=De(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},Ue.prototype.setSelectedCoordinates=function(e){return this._selectedCoordinates=e,this._emitSelectionChange=!0,this},Ue.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Ue.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Ue.prototype.getSelected=function(){return this.getSelectedIds().map(e=>this.get(e))},Ue.prototype.getSelectedCoordinates=function(){return this._selectedCoordinates.map(e=>({coordinates:this.get(e.feature_id).getCoordinate(e.coord_path)}))},Ue.prototype.isSelected=function(e){return this._selectedFeatureIds.has(e)},Ue.prototype.setFeatureProperty=function(e,t,r,n={}){this.get(e).setProperty(t,r),this.featureChanged(e,{silent:n.silent,action:L.CHANGE_PROPERTIES})},Ue.prototype.storeMapConfig=function(){j.forEach(e=>{this.ctx.map[e]&&(this._mapInitialConfig[e]=this.ctx.map[e].isEnabled())})},Ue.prototype.restoreMapConfig=function(){Object.keys(this._mapInitialConfig).forEach(e=>{this._mapInitialConfig[e]?this.ctx.map[e].enable():this.ctx.map[e].disable()})},Ue.prototype.getInitialConfigValue=function(e){return void 0===this._mapInitialConfig[e]||this._mapInitialConfig[e]};const Ge=["mode","feature","mouse"];function Ye(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 je(r));return{start(){o=i.onSetup(n),Ve.forEach(t=>{const r=Ne[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,a=null;o.drag=function(t,r){r({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:I.DRAG}),a.drag(t)):t.originalEvent.stopPropagation()},o.mousedrag=function(e){o.drag(e,e=>!me(r,e))},o.touchdrag=function(e){o.drag(e,e=>!ve(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=ye(t,e);t.featureTarget=r,a.mousemove(t)},o.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};const n=ye(t,e);t.featureTarget=n,a.mousedown(t)},o.mouseup=function(t){const n=ye(t,e);t.featureTarget=n,me(r,{point:t.point,time:(new Date).getTime()})?a.click(t):a.mouseup(t)},o.mouseout=function(e){a.mouseout(e)},o.touchstart=function(t){if(!e.options.touchEnabled)return;n={time:(new Date).getTime(),point:t.point};const r=fe.touch(t,null,e)[0];t.featureTarget=r,a.touchstart(t)},o.touchmove=function(t){if(e.options.touchEnabled)return a.touchmove(t),o.touchdrag(t)},o.touchend=function(t){if(t.originalEvent.preventDefault(),!e.options.touchEnabled)return;const r=fe.touch(t,null,e)[0];t.featureTarget=r,ve(n,{time:(new Date).getTime(),point:t.point})?a.tap(t):a.touchend(t)};const s=e=>{const t=Z(e),r=Q(e),n=ne(e);return!(t||r||n)};function u(r,n,o={}){a.stop();const s=t[r];if(void 0===s)throw new Error(`${r} is not valid`);i=r;const u=s(e,n);a=be(u,e),o.silent||e.map.fire(A.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains(M.CANVAS)&&((Z(t)||Q(t))&&e.options.controls.trash?(t.preventDefault(),a.trash()):s(t)?a.keydown(t):ee(t)&&e.options.controls.point?u(T.DRAW_POINT):te(t)&&e.options.controls.line_string?u(T.DRAW_LINE_STRING):re(t)&&e.options.controls.polygon&&u(T.DRAW_POLYGON))},o.keyup=function(e){s(e)&&a.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 c={trash:!1,combineFeatures:!1,uncombineFeatures:!1},l={start(){i=e.options.defaultMode,a=be(t[i](e),e)},changeMode:u,actionable:function(t){let r=!1;Object.keys(t).forEach(e=>{if(void 0===c[e])throw new Error("Invalid action type");c[e]!==t[e]&&(r=!0),c[e]=t[e]}),r&&e.map.fire(A.ACTIONABLE,{actions:c})},currentModeName:()=>i,currentModeRender:(e,t)=>a.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){a.trash(e)},combineFeatures(){a.combineFeatures()},uncombineFeatures(){a.uncombineFeatures()},getMode:()=>i};return l}(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 a(){if(!e.container)return;const t=[],r=[];Ge.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 s(e,t={}){const n=document.createElement("button");return n.className=`${M.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 u(),void t.onDeactivate();c(e),t.onActivate()},!0),n}function u(){r&&(r.classList.remove(M.ACTIVE_BUTTON),r=null)}function c(e){u();const n=t[e];n&&n&&"trash"!==e&&(n.classList.add(M.ACTIVE_BUTTON),r=n)}return{setActiveButton:c,queueMapClasses:i,updateMapClasses:a,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),a()},addButtons:function(){const r=e.options.controls,n=document.createElement("div");return n.className=`${M.CONTROL_GROUP} ${M.CONTROL_BASE}`,r?(r[O.POINT]&&(t[O.POINT]=s(O.POINT,{container:n,className:M.CONTROL_BUTTON_POINT,title:"Marker tool "+(e.options.keybindings?"(1)":""),onActivate:()=>e.events.changeMode(T.DRAW_POINT),onDeactivate:()=>e.events.trash()})),r[O.LINE]&&(t[O.LINE]=s(O.LINE,{container:n,className:M.CONTROL_BUTTON_LINE,title:"LineString tool "+(e.options.keybindings?"(2)":""),onActivate:()=>e.events.changeMode(T.DRAW_LINE_STRING),onDeactivate:()=>e.events.trash()})),r[O.POLYGON]&&(t[O.POLYGON]=s(O.POLYGON,{container:n,className:M.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(e.options.keybindings?"(3)":""),onActivate:()=>e.events.changeMode(T.DRAW_POLYGON),onDeactivate:()=>e.events.trash()})),r.trash&&(t.trash=s("trash",{container:n,className:M.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:()=>{e.events.trash()}})),r.combine_features&&(t.combine_features=s("combineFeatures",{container:n,className:M.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:()=>{e.events.combineFeatures()}})),r.uncombine_features&&(t.uncombine_features=s("uncombineFeatures",{container:n,className:M.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 Ue(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(_.COLD,{data:{type:C.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(_.HOT,{data:{type:C.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(_.COLD)&&e.map.removeSource(_.COLD),e.map.getSource(_.HOT)&&e.map.removeSource(_.HOT)}};return e.setup=n,n}const Xe="#3bb2d0",He="#fbb03b",Je="#fff",qe=[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"]],paint:{"fill-color":["case",["==",["get","active"],"true"],He,Xe],"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"],He,Xe],"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":Je}},{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"],He,Xe]}},{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":Je}},{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":He}},{id:"gl-draw-midpoint",type:"circle",filter:["all",["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":He}}];function $e(e,t){this.x=e,this.y=t}$e.prototype={clone(){return new $e(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:$e},$e.convert=function(e){if(e instanceof $e)return e;if(Array.isArray(e))return new $e(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new $e(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};const Ke=function(e,t){const r=t.getBoundingClientRect();return new $e(e.clientX-r.left-(t.clientLeft||0),e.clientY-r.top-(t.clientTop||0))};function We(e,t,r,n){return{type:C.FEATURE,properties:{meta:k.VERTEX,parent:e,coord_path:r,active:n?F.ACTIVE:F.INACTIVE},geometry:{type:C.POINT,coordinates:t}}}var ze=6371008.8,Ze={centimeters:637100880,centimetres:637100880,degrees:360/(2*Math.PI),feet:20902260.511392,inches:39.37*ze,kilometers:6371.0088,kilometres:6371.0088,meters:ze,metres:ze,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:ze/1852,radians:1,yards:6967335.223679999};function Qe(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 et(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(!at(e[0])||!at(e[1]))throw new Error("coordinates must contain numbers");return Qe({type:"Point",coordinates:e},t,r)}function tt(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 Qe({type:"Polygon",coordinates:e},t,r)}function rt(e,t,r={}){if(e.length<2)throw new Error("coordinates must be an array of two or more positions");return Qe({type:"LineString",coordinates:e},t,r)}function nt(e,t={}){const r={type:"FeatureCollection"};return t.id&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.features=e,r}function ot(e){return e%(2*Math.PI)*180/Math.PI}function it(e){return e%360*Math.PI/180}function at(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function st(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,S=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var E=a.type;switch(d=!r||"Polygon"!==E&&"MultiPolygon"!==E?0:1,E){case null:break;case"Point":if(!1===t(u,p,m,b,S))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],p,m,b,S))return!1;p++,"MultiPoint"===E&&b++}"LineString"===E&&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,S))return!1;p++}"MultiLineString"===E&&b++,"Polygon"===E&&S++}"Polygon"===E&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(S=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-d;i++){if(!1===t(u[n][o][i],p,m,b,S))return!1;p++}S++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===st(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ut(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 ct(e,t){ut(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(Qe(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(Qe({type:a,coordinates:c},n),r,u))return!1}})}function lt(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=dt(e.properties),null==e.geometry?t.geometry=null:t.geometry=pt(e.geometry),t}function dt(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]=dt(n):t[r]=n}),t):t}function pt(e){const t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(e=>pt(e)),t):(t.coordinates=ft(e.coordinates),t)}function ft(e){const t=e;return"object"!=typeof t[0]?t.slice():t.map(e=>ft(e))}function ht(e,t={}){return yt(e,"mercator",t)}function yt(e,t,r={}){var n=(r=r||{}).mutate;if(!e)throw new Error("geojson is required");return Array.isArray(e)&&at(e[0])?e="mercator"===t?gt(e):mt(e):(!0!==n&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return lt(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=>lt(e)),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return pt(e);default:throw new Error("unknown GeoJSON type")}}(e)),st(e,function(e){var r="mercator"===t?gt(e):mt(e);e[0]=r[0],e[1]=r[1]})),e}function gt(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 mt(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 vt(e,t,r){const n=t.geometry.coordinates,o=r.geometry.coordinates;if(n[1]>R||n[1]<V||o[1]>R||o[1]<V)return null;const i=ht(n),a=ht(o),s=e=>Number(e.toFixed(8)),u=(e,t)=>(e+t)/2,c=function(e,t={}){return yt(e,"wgs84",t)}([u(i[0],a[0]),u(i[1],a[1])]),l=[s(c[0]),s(c[1])];return{type:C.FEATURE,properties:{meta:k.MIDPOINT,parent:e,lng:l[0],lat:l[1],coord_path:r.properties.coord_path},geometry:{type:C.POINT,coordinates:l}}}const bt=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=We(a,e,u,c(u));if(r.midpoints&&o){const e=vt(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===C.POINT?s.push(We(a,i,n,c(n))):o===C.POLYGON?i.forEach((e,t)=>{u(e,null!==n?`${n}.${t}`:String(t))}):o===C.LINE_STRING?u(i,n):0===o.indexOf(C.MULTI_PREFIX)&&function(){const n=o.replace(C.MULTI_PREFIX,"");i.forEach((o,i)=>{const a={type:C.FEATURE,properties:t.properties,geometry:{type:n,coordinates:o}};s=s.concat(e(a,r,i))})}(),s},St={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:Et,LAT_MAX:wt,LAT_RENDERED_MIN:Pt,LAT_RENDERED_MAX:xt,LNG_MIN:Mt,LNG_MAX:_t}=n;function It(e,t){let r=Et,n=wt,o=Et,i=wt,a=_t,s=Mt;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>xt&&(u.lat=xt-r),o+u.lat>wt&&(u.lat=wt-o),n+u.lat<Pt&&(u.lat=Pt-n),i+u.lat<Et&&(u.lat=Et-i),a+u.lng<=Mt&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=_t&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function Ot(e,t){const r=It(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===C.POINT?i=n(t):e.type===C.LINE_STRING||e.type===C.MULTI_POINT?i=t.map(n):e.type===C.POLYGON||e.type===C.MULTI_LINE_STRING?i=t.map(o):e.type===C.MULTI_POLYGON&&(i=t.map(e=>e.map(e=>o(e)))),e.incomingCoords(i)})}const Ct={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(A.UPDATE,{action:L.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 de).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(){St.enable(this)},onMouseMove:function(e,t){return q(t)&&e.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(e),!0},onMouseOut:function(e){return!e.dragMoving||this.fireUpdate()}};Ct.onTap=Ct.onClick=function(e,t){return J(t)?this.clickAnywhere(e,t):G(k.VERTEX)(t)?this.clickOnVertex(e,t):q(t)?this.clickOnFeature(e,t):void 0},Ct.clickAnywhere=function(e){const t=this.getSelectedIds();t.length&&(this.clearSelectedFeatures(),t.forEach(e=>this.doRender(e))),St.enable(this),this.stopExtendedInteractions(e)},Ct.clickOnVertex=function(e,t){this.changeMode(T.DIRECT_SELECT,{featureId:t.featureTarget.properties.parent,coordPath:t.featureTarget.properties.coord_path,startPos:t.lngLat}),this.updateUIClasses({mouse:I.MOVE})},Ct.startOnActiveFeature=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),this.doRender(t.featureTarget.properties.id),e.canDragMove=!0,e.dragMoveLocation=t.lngLat},Ct.clickOnFeature=function(e,t){St.disable(this),this.stopExtendedInteractions(e);const r=K(t),n=this.getSelectedIds(),o=t.featureTarget.properties.id,i=this.isSelected(o);if(!r&&i&&this.getFeature(o).type!==C.POINT)return this.changeMode(T.DIRECT_SELECT,{featureId:o});i&&r?(this.deselect(o),this.updateUIClasses({mouse:I.POINTER}),1===n.length&&St.enable(this)):!i&&r?(this.select(o),this.updateUIClasses({mouse:I.MOVE})):i||r||(n.forEach(e=>this.doRender(e)),this.setSelected(o),this.updateUIClasses({mouse:I.MOVE})),this.doRender(o)},Ct.onMouseDown=function(e,t){return e.initialDragPanState=this.map.dragPan.isEnabled(),X(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&Y(t)?this.startBoxSelect(e,t):void 0},Ct.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=Ke(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},Ct.onTouchStart=function(e,t){if(X(t))return this.startOnActiveFeature(e,t)},Ct.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},Ct.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:I.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(M.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));const r=Ke(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),a=Math.max(e.boxSelectStartLocation.y,r.y),s=`translate(${n}px, ${i}px)`;e.boxSelectElement.style.transform=s,e.boxSelectElement.style.WebkitTransform=s,e.boxSelectElement.style.width=o-n+"px",e.boxSelectElement.style.height=a-i+"px"},Ct.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};Ot(this.getSelected(),r),e.dragMoveLocation=t.lngLat},Ct.onTouchEnd=Ct.onMouseUp=function(e,t){if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){const r=[e.boxSelectStartLocation,Ke(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:I.MOVE}))}this.stopExtendedInteractions(e)},Ct.toDisplayFeatures=function(e,t,r){t.properties.active=this.isSelected(t.properties.id)?F.ACTIVE:F.INACTIVE,r(t),this.fireActionable(),t.properties.active===F.ACTIVE&&t.geometry.type!==C.POINT&&bt(t).forEach(r)},Ct.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Ct.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:C.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(A.COMBINE_FEATURES,{createdFeatures:[e.toGeoJSON()],deletedFeatures:r})}this.fireActionable()},Ct.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(A.UNCOMBINE_FEATURES,{createdFeatures:t,deletedFeatures:r}),this.fireActionable()};const Tt=Ct,At=G(k.VERTEX),Lt=G(k.MIDPOINT),kt={fireUpdate:function(){this.fire(A.UPDATE,{action:L.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);K(t)||-1!==n?K(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){Ot(this.getSelected(),r),e.dragMoveLocation=t.lngLat},dragVertex:function(e,t,r){const n=e.selectedCoordPaths.map(t=>e.feature.getCoordinate(t)),o=It(n.map(e=>({type:C.FEATURE,properties:{},geometry:{type:C.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(T.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(T.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===C.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),St.disable(this),this.setActionableState({trash:!0}),n},onStop:function(){St.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(e,t,r){e.featureId===t.properties.id?(t.properties.active=F.ACTIVE,r(t),bt(t,{map:this.map,midpoints:!0,selectedPaths:e.selectedCoordPaths}).forEach(r)):(t.properties.active=F.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(T.SIMPLE_SELECT,{}))},onMouseMove:function(e,t){const r=X(t),n=At(t),o=Lt(t),i=0===e.selectedCoordPaths.length;return r&&i||n&&!i?this.updateUIClasses({mouse:I.MOVE}):this.updateUIClasses({mouse:I.NONE}),(n||r||o)&&e.dragMoving&&this.fireUpdate(),this.stopDragging(e),!0},onMouseOut:function(e){return e.dragMoving&&this.fireUpdate(),!0}};kt.onTouchStart=kt.onMouseDown=function(e,t){return At(t)?this.onVertex(e,t):X(t)?this.onFeature(e,t):Lt(t)?this.onMidpoint(e,t):void 0},kt.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},kt.onClick=function(e,t){return J(t)?this.clickNoTarget(e,t):X(t)?this.clickActiveFeature(e,t):H(t)?this.clickInactive(e,t):void this.stopDragging(e)},kt.onTap=function(e,t){return J(t)?this.clickNoTarget(e,t):X(t)?this.clickActiveFeature(e,t):H(t)?this.clickInactive(e,t):void 0},kt.onTouchEnd=kt.onMouseUp=function(e){e.dragMoving&&this.fireUpdate(),this.stopDragging(e)};const Ft=kt,jt={onSetup:function(){const e=this.newFeature({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:I.ADD}),this.activateUIButton(O.POINT),this.setActionableState({trash:!0}),{point:e}},stopDrawingAndRemove:function(e){this.deleteFeature([e.point.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)}};jt.onTap=jt.onClick=function(e,t){this.updateUIClasses({mouse:I.MOVE}),e.point.updateCoordinate("",t.lngLat.lng,t.lngLat.lat),this.fire(A.CREATE,{features:[e.point.toGeoJSON()]}),this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.point.id]})},jt.onStop=function(e){this.activateUIButton(),e.point.getCoordinate().length||this.deleteFeature([e.point.id],{silent:!0})},jt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.point.id;if(t.properties.active=n?F.ACTIVE:F.INACTIVE,!n)return r(t)},jt.onTrash=jt.stopDrawingAndRemove,jt.onKeyUp=function(e,t){if(W(t)||z(t))return this.stopDrawingAndRemove(e,t)};const Nt=jt,Vt=function(e,t){return!!e.lngLat&&e.lngLat.lng===t[0]&&e.lngLat.lat===t[1]},Dt={onSetup:function(){const e=this.newFeature({type:C.FEATURE,properties:{},geometry:{type:C.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),St.disable(this),this.updateUIClasses({mouse:I.ADD}),this.activateUIButton(O.POLYGON),this.setActionableState({trash:!0}),{polygon:e,currentVertexPosition:0}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Vt(t,e.polygon.coordinates[0][e.currentVertexPosition-1]))return this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.polygon.id]});this.updateUIClasses({mouse:I.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(T.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},onMouseMove:function(e,t){e.polygon.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),$(t)&&this.updateUIClasses({mouse:I.POINTER})}};Dt.onTap=Dt.onClick=function(e,t){return $(t)?this.clickOnVertex(e,t):this.clickAnywhere(e,t)},Dt.onKeyUp=function(e,t){W(t)?(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)):z(t)&&this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.polygon.id]})},Dt.onStop=function(e){this.updateUIClasses({mouse:I.NONE}),St.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.polygon.id)&&(e.polygon.removeCoordinate(`0.${e.currentVertexPosition}`),e.polygon.isValid()?this.fire(A.CREATE,{features:[e.polygon.toGeoJSON()]}):(this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT,{},{silent:!0})))},Dt.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.polygon.id;if(t.properties.active=n?F.ACTIVE:F.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=k.FEATURE,r(We(e.polygon.id,t.geometry.coordinates[0][0],"0.0",!1)),o>3){const n=t.geometry.coordinates[0].length-3;r(We(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:C.FEATURE,properties:t.properties,geometry:{coordinates:e,type:C.LINE_STRING}}),3===o)return}return r(t)}},Dt.onTrash=function(e){this.deleteFeature([e.polygon.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)};const Rt=Dt,Ut={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:C.FEATURE,properties:{},geometry:{type:C.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(r);return this.clearSelectedFeatures(),St.disable(this),this.updateUIClasses({mouse:I.ADD}),this.activateUIButton(O.LINE),this.setActionableState({trash:!0}),{line:r,currentVertexPosition:n,direction:o}},clickAnywhere:function(e,t){if(e.currentVertexPosition>0&&Vt(t,e.line.coordinates[e.currentVertexPosition-1])||"backwards"===e.direction&&Vt(t,e.line.coordinates[e.currentVertexPosition+1]))return this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.line.id]});this.updateUIClasses({mouse:I.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(T.SIMPLE_SELECT,{featureIds:[e.line.id]})},onMouseMove:function(e,t){e.line.updateCoordinate(e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),$(t)&&this.updateUIClasses({mouse:I.POINTER})}};Ut.onTap=Ut.onClick=function(e,t){if($(t))return this.clickOnVertex(e,t);this.clickAnywhere(e,t)},Ut.onKeyUp=function(e,t){z(t)?this.changeMode(T.SIMPLE_SELECT,{featureIds:[e.line.id]}):W(t)&&(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT))},Ut.onStop=function(e){St.enable(this),this.activateUIButton(),void 0!==this.getFeature(e.line.id)&&(e.line.removeCoordinate(`${e.currentVertexPosition}`),e.line.isValid()?this.fire(A.CREATE,{features:[e.line.toGeoJSON()]}):(this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT,{},{silent:!0})))},Ut.onTrash=function(e){this.deleteFeature([e.line.id],{silent:!0}),this.changeMode(T.SIMPLE_SELECT)},Ut.toDisplayFeatures=function(e,t,r){const n=t.properties.id===e.line.id;if(t.properties.active=n?F.ACTIVE:F.INACTIVE,!n)return r(t);t.geometry.coordinates.length<2||(t.properties.meta=k.FEATURE,r(We(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 Bt=Ut,Gt={simple_select:Tt,direct_select:Ft,draw_point:Nt,draw_polygon:Rt,draw_line_string:Bt},Yt={defaultMode:T.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:qe,modes:Gt,controls:{},userProperties:!1,suppressAPIEvents:!0},Xt={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 Jt(e,t){return e.map(e=>e.source?e:Object.assign({},e,{id:`${e.id}.${t}`,source:"hot"===t?_.HOT:_.COLD}))}var qt=r(17),$t=r(186);function Kt(e,t){return e.length===t.length&&JSON.stringify(e.map(e=>e).sort())===JSON.stringify(t.map(e=>e).sort())}const Wt={Polygon:Ce,LineString:Ie,Point:Me,MultiPolygon:ke,MultiLineString:ke,MultiPoint:ke};function zt(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({},Xt,e.controls),t=Object.assign({},Yt,t),t.styles=Jt(t.styles,"cold").concat(Jt(t.styles,"hot")),t}(e)};t=function(e,t){t.modes=T;const r=void 0===e.options.suppressAPIEvents||!!e.options.suppressAPIEvents;return t.getFeatureIdsAt=function(t){return fe.click({point:t},null,e).map(e=>e.properties.id)},t.getSelectedIds=function(){return e.store.getSelectedIds()},t.getSelected=function(){return{type:C.FEATURE_COLLECTION,features:e.store.getSelectedIds().map(t=>e.store.get(t)).map(e=>e.toGeoJSON())}},t.getSelectedPoints=function(){return{type:C.FEATURE_COLLECTION,features:e.store.getSelectedCoordinates().map(e=>({type:C.FEATURE,properties:{},geometry:{type:C.POINT,coordinates:e.coordinates}}))}},t.set=function(r){if(void 0===r.type||r.type!==C.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 de(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($t(t))).features.map(t=>{if(t.id=t.id||Ee(),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=Wt[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,qt(o,t.properties)||e.store.featureChanged(n.id,{silent:r}),qt(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:C.FEATURE_COLLECTION,features:e.store.getAll().map(e=>e.toGeoJSON())}},t.delete=function(n){return e.store.delete(n,{silent:r}),t.getMode()!==T.DIRECT_SELECT||e.store.getSelectedIds().length?e.store.render():e.events.changeMode(T.SIMPLE_SELECT,void 0,{silent:r}),t},t.deleteAll=function(){return e.store.delete(e.store.getAllIds(),{silent:r}),t.getMode()===T.DIRECT_SELECT?e.events.changeMode(T.SIMPLE_SELECT,void 0,{silent:r}):e.store.render(),t},t.changeMode=function(n,o={}){return n===T.SIMPLE_SELECT&&t.getMode()===T.SIMPLE_SELECT?(Kt(o.featureIds||[],e.store.getSelectedIds())||(e.store.setSelected(o.featureIds,{silent:r}),e.store.render()),t):(n===T.DIRECT_SELECT&&t.getMode()===T.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=Ye(r);t.onAdd=n.onAdd,t.onRemove=n.onRemove,t.types=O,t.options=e}(e,this)}zt.modes=Gt,zt.constants=n,zt.lib=i;const Zt=zt;var Qt={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)}};function er(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 tr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?tr(e,t):void 0}}(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 tr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var rr=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[]}},nr=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},or=function(e,t){var r,n=er(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},ir=function(e,t){var r,n=e.geometry.coordinates,o=er(t);try{for(o.s();!(r=o.n()).done;)n=n[r.value]}catch(e){o.e(e)}finally{o.f()}return n},ar=function(e,t){var r,n=t.split(".").map(Number),o=er(nr(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]},sr=function(e,t){return{x:e.x*t,y:e.y*t}},ur=function(e){return e instanceof window.SVGElement||e.ownerSVGElement};function cr(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 lr={fireGeometryChange:function(e){var t=this.getFeature(e.featureId);t&&this.map.fire("draw.update",{features:[t.toGeoJSON()],action:"change_coordinates"})},pushUndo:function(e){var t=this.map._undoStack;t&&t.push(e)},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)}},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=nr(i),u=or(s,r);if(u){ir(a,u.segment.path)[u.localIdx]=n,this._applyUndoAndSync(e,a,o);var c=e.vertecies[e.selectedVertexIndex];c&&this.updateTouchVertexTarget(e,sr(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=nr(o),s=or(a,r);s&&(ir(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=nr(i),u=or(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 cr(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)?cr(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()}}if(u){ir(a,u.segment.path).splice(u.localIdx,0,n),this._applyUndoAndSync(e,a,o);var p=e.vertecies[r];p&&this.updateTouchVertexTarget(e,sr(this.map.project(p),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)}};function dr(e){return dr="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},dr(e)}function pr(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function fr(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 hr(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?fr(Object(r),!0).forEach(function(t){yr(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fr(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function yr(e,t,r){return(t=function(e){var t=function(e){if("object"!=dr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=dr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==dr(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var gr=function(e,t){if(e){var r="dark"===(null==t?void 0:t.mapColorScheme);e.style.setProperty("--touch-fill",r?"#ffffff":"#000000"),e.style.setProperty("--touch-gfx",r?"#000000":"#ffffff")}},mr={addTouchVertexTarget:function(e){var t=e.container.querySelector("[data-touch-vertex-target]");t||(e.container.insertAdjacentHTML("beforeend","\n <svg width='48' height='48' viewBox='0 0 48 48' fill-rule='evenodd' style='display:none;position:absolute;top:50%;left:50%;margin:24px 0 0 -24px' class='touch-vertex-target' data-touch-vertex-target>\n <circle cx='24' cy='24' r='24' fill='var(--touch-fill, #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(--touch-gfx, #fff)'/>\n </svg>\n"),t=e.container.querySelector("[data-touch-vertex-target]")),e.touchVertexTarget=t,gr(t,this.map._drawCurrentMapStyle)},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||ur(t.target.parentNode)||e._ignorePointermoveDeselect||this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null,coordPath:null})},onTouchStart:function(){},onTouchMove:function(){},onTouchEnd:function(){},onTouchend:function(e){P(v(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=v(this.map);o&&w(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=ar(s,a);this.changeMode(e,{selectedVertexIndex:u,selectedVertexType:"vertex",coordPath:a})}else"midpoint"===i?this.insertVertex(hr(hr({},e),{},{selectedVertexIndex:this.getVertexIndexFromMidpoint(e,a),selectedVertexType:"midpoint"})):this.clickNoTarget(e)},onTouchstart:function(e,t){var r;P(v(this.map));var n,o=null===(r=e.vertecies)||void 0===r?void 0:r[e.selectedVertexIndex];if(o&&ur(t.target.parentNode)){e._moveStartPosition=function(e){if(Array.isArray(e))return pr(e)}(n=o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e,t){if(e){if("string"==typeof e)return pr(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pr(e,t):void 0}}(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._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)&&ur(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(x(e)){var a=v(this.map);E(a,this.map,o),i=S(a)||i}this.moveVertex(e,i),this.updateTouchVertexTarget(e,{x:r-e.deltaTarget.x,y:n-e.deltaTarget.y})}}};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 br(e){return function(e){if(Array.isArray(e))return xr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Pr(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 Sr(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 Er(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}function wr(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)||Pr(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 Pr(e,t){if(e){if("string"==typeof e)return xr(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)?xr(e,t):void 0}}function xr(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 Mr={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},_r={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=wr(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?Sr(Object(r),!0).forEach(function(t){Er(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Sr(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?1:5,o=wr(t?Mr[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(rr(this.getFeature(e.featureId))[e.selectedVertexIndex],t)},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=Pr(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}}}}(nr(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&&(ir(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=nr(o),s=or(a,e.selectedVertexIndex);s&&(ir(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=nr(t),n=or(r,e.selectedVertexIndex);if(n){var o=n.segment,i=o.closed?3:2;if(!(o.length<=i)){var a=br(e.vertecies[e.selectedVertexIndex]),s=e.selectedVertexIndex,u=[].concat(br(n.segment.path),[n.localIdx]).join(".");t.removeCoordinate(u),this.fireUpdate(),this.clearSelectedCoordinates(),t.changed(),this._ctx.store.render(),this.pushUndo({type:"delete_vertex",featureId:e.featureId,vertexIndex:s,position:a}),this.changeMode(e,{selectedVertexIndex:-1,selectedVertexType:null})}}}}};function Ir(e){var t={type:"Feature"};return Object.keys(e).forEach(function(r){switch(r){case"type":case"properties":case"geometry":return;default:t[r]=e[r]}}),t.properties=Or(e.properties),t.geometry=Cr(e.geometry),t}function Or(e){var t={};return e?(Object.keys(e).forEach(function(r){var n=e[r];"object"==typeof n?null===n?t[r]=null:Array.isArray(n)?t[r]=n.map(function(e){return e}):t[r]=Or(n):t[r]=n}),t):t}function Cr(e){var t={type:e.type};return e.bbox&&(t.bbox=e.bbox),"GeometryCollection"===e.type?(t.geometries=e.geometries.map(function(e){return Cr(e)}),t):(t.coordinates=Tr(e.coordinates),t)}function Tr(e){var t=e;return"object"!=typeof t[0]?t.slice():t.map(function(e){return Tr(e)})}function Ar(e){for(var t,r,n=function(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")}(e),o=0,i=1;i<n.length;)t=r||n[0],o+=((r=n[i])[0]-t[0])*(r[1]+t[1]),i++;return o>0}function Lr(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 kr(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 Fr(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")}function jr(e,t){switch("Feature"===e.type?e.geometry.type:e.type){case"GeometryCollection":return kr(e,function(e){jr(e,t)}),e;case"LineString":return Nr(Fr(e),t),e;case"Polygon":return Vr(Fr(e),t),e;case"MultiLineString":return Fr(e).forEach(function(e){Nr(e,t)}),e;case"MultiPolygon":return Fr(e).forEach(function(e){Vr(e,t)}),e;case"Point":case"MultiPoint":return e}}function Nr(e,t){Ar(e)===t&&e.reverse()}function Vr(e,t){Ar(e[0])!==t&&e[0].reverse();for(var r=1;r<e.length;r++)Ar(e[r])===t&&e[r].reverse()}const Dr=function(e,t){if(!(r=t=t||{})||r.constructor!==Object)throw new Error("options is invalid");var r,n=t.reverse||!1,o=t.mutate||!1;if(!e)throw new Error("<geojson> is required");if("boolean"!=typeof n)throw new Error("<reverse> must be a boolean");if("boolean"!=typeof o)throw new Error("<mutate> must be a boolean");!1===o&&(e=function(e){if(!e)throw new Error("geojson is required");switch(e.type){case"Feature":return Ir(e);case"FeatureCollection":return function(e){var t={type:"FeatureCollection"};return Object.keys(e).forEach(function(r){switch(r){case"type":case"features":return;default:t[r]=e[r]}}),t.features=e.features.map(function(e){return Ir(e)}),t}(e);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Cr(e);default:throw new Error("unknown GeoJSON type")}}(e));var i=[];switch(e.type){case"GeometryCollection":return kr(e,function(e){jr(e,n)}),e;case"FeatureCollection":return Lr(e,function(e){Lr(jr(e,n),function(e){i.push(e)})}),function(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}(i)}return jr(e,n)},Rr=11102230246251565e-32,Ur=134217729,Br=(3+8*Rr)*Rr;function Gr(e,t,r,n,o){let i,a,s,u,c=t[0],l=n[0],d=0,p=0;l>c==l>-c?(i=c,c=t[++d]):(i=l,l=n[++p]);let f=0;if(d<e&&p<r)for(l>c==l>-c?(a=c+i,s=i-(a-c),c=t[++d]):(a=l+i,s=i-(a-l),l=n[++p]),i=a,0!==s&&(o[f++]=s);d<e&&p<r;)l>c==l>-c?(a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d]):(a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p]),i=a,0!==s&&(o[f++]=s);for(;d<e;)a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d],i=a,0!==s&&(o[f++]=s);for(;p<r;)a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p],i=a,0!==s&&(o[f++]=s);return 0===i&&0!==f||(o[f++]=i),f}function Yr(e){return new Float64Array(e)}const Xr=Yr(4),Hr=Yr(8),Jr=Yr(12),qr=Yr(16),$r=Yr(4);function Kr(e,t,r,n,o,i){const a=(t-i)*(r-o),s=(e-o)*(n-i),u=a-s,c=Math.abs(a+s);return Math.abs(u)>=33306690738754716e-32*c?u:-function(e,t,r,n,o,i,a){let s,u,c,l,d,p,f,h,y,g,m,v,b,S,E,w,P,x;const M=e-o,_=r-o,I=t-i,O=n-i;S=M*O,p=Ur*M,f=p-(p-M),h=M-f,p=Ur*O,y=p-(p-O),g=O-y,E=h*g-(S-f*y-h*y-f*g),w=I*_,p=Ur*I,f=p-(p-I),h=I-f,p=Ur*_,y=p-(p-_),g=_-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,d=E-m,Xr[0]=E-(m+d)+(d-P),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-w,d=b-m,Xr[1]=b-(m+d)+(d-w),x=v+m,d=x-v,Xr[2]=v-(x-d)+(m-d),Xr[3]=x;let C=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,Xr),T=22204460492503146e-32*a;if(C>=T||-C>=T)return C;if(d=e-M,s=e-(M+d)+(d-o),d=r-_,c=r-(_+d)+(d-o),d=t-I,u=t-(I+d)+(d-i),d=n-O,l=n-(O+d)+(d-i),0===s&&0===u&&0===c&&0===l)return C;if(T=11093356479670487e-47*a+Br*Math.abs(C),C+=M*l+O*s-(I*c+_*u),C>=T||-C>=T)return C;S=s*O,p=Ur*s,f=p-(p-s),h=s-f,p=Ur*O,y=p-(p-O),g=O-y,E=h*g-(S-f*y-h*y-f*g),w=u*_,p=Ur*u,f=p-(p-u),h=u-f,p=Ur*_,y=p-(p-_),g=_-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,d=E-m,$r[0]=E-(m+d)+(d-P),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-w,d=b-m,$r[1]=b-(m+d)+(d-w),x=v+m,d=x-v,$r[2]=v-(x-d)+(m-d),$r[3]=x;const A=Gr(4,Xr,4,$r,Hr);S=M*l,p=Ur*M,f=p-(p-M),h=M-f,p=Ur*l,y=p-(p-l),g=l-y,E=h*g-(S-f*y-h*y-f*g),w=I*c,p=Ur*I,f=p-(p-I),h=I-f,p=Ur*c,y=p-(p-c),g=c-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,d=E-m,$r[0]=E-(m+d)+(d-P),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-w,d=b-m,$r[1]=b-(m+d)+(d-w),x=v+m,d=x-v,$r[2]=v-(x-d)+(m-d),$r[3]=x;const L=Gr(A,Hr,4,$r,Jr);S=s*l,p=Ur*s,f=p-(p-s),h=s-f,p=Ur*l,y=p-(p-l),g=l-y,E=h*g-(S-f*y-h*y-f*g),w=u*c,p=Ur*u,f=p-(p-u),h=u-f,p=Ur*c,y=p-(p-c),g=c-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,d=E-m,$r[0]=E-(m+d)+(d-P),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-w,d=b-m,$r[1]=b-(m+d)+(d-w),x=v+m,d=x-v,$r[2]=v-(x-d)+(m-d),$r[3]=x;const k=Gr(L,Jr,4,$r,qr);return qr[k-1]}(e,t,r,n,o,i,c)}function Wr(e,t){var r,n,o,i,a,s,u,c,l,d=0,p=e[0],f=e[1],h=t.length;for(r=0;r<h;r++){n=0;var y=t[r],g=y.length-1;if((c=y[0])[0]!==y[g][0]&&c[1]!==y[g][1])throw new Error("First and last coordinates in a ring must be the same");for(i=c[0]-p,a=c[1]-f;n<g;n++){if(s=(l=y[n+1])[0]-p,u=l[1]-f,0===a&&0===u){if(s<=0&&i>=0||i<=0&&s>=0)return 0}else if(u>=0&&a<=0||u<=0&&a>=0){if(0===(o=Kr(i,s,a,u,0,0)))return 0;(o>0&&u>0&&a<=0||o<0&&u<=0&&a>0)&&d++}c=l,a=u,i=s}}return d%2!=0}Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(8),Yr(8),Yr(8),Yr(4),Yr(8),Yr(8),Yr(8),Yr(12),Yr(192),Yr(192),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(8),Yr(8),Yr(8),Yr(8),Yr(8),Yr(8),Yr(8),Yr(8),Yr(8),Yr(4),Yr(4),Yr(4),Yr(8),Yr(16),Yr(16),Yr(16),Yr(32),Yr(32),Yr(48),Yr(64),Yr(1152),Yr(1152),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(4),Yr(24),Yr(24),Yr(24),Yr(24),Yr(24),Yr(24),Yr(24),Yr(24),Yr(24),Yr(24),Yr(1152),Yr(1152),Yr(1152),Yr(1152),Yr(1152),Yr(2304),Yr(2304),Yr(3456),Yr(5760),Yr(8),Yr(8),Yr(8),Yr(16),Yr(24),Yr(48),Yr(48),Yr(96),Yr(192),Yr(384),Yr(384),Yr(384),Yr(768),Yr(96),Yr(96),Yr(96),Yr(1152);const zr=134217729;function Zr(e,t,r,n,o){let i,a,s,u,c=t[0],l=n[0],d=0,p=0;l>c==l>-c?(i=c,c=t[++d]):(i=l,l=n[++p]);let f=0;if(d<e&&p<r)for(l>c==l>-c?(a=c+i,s=i-(a-c),c=t[++d]):(a=l+i,s=i-(a-l),l=n[++p]),i=a,0!==s&&(o[f++]=s);d<e&&p<r;)l>c==l>-c?(a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d]):(a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p]),i=a,0!==s&&(o[f++]=s);for(;d<e;)a=i+c,u=a-i,s=i-(a-u)+(c-u),c=t[++d],i=a,0!==s&&(o[f++]=s);for(;p<r;)a=i+l,u=a-i,s=i-(a-u)+(l-u),l=n[++p],i=a,0!==s&&(o[f++]=s);return 0===i&&0!==f||(o[f++]=i),f}function Qr(e){return new Float64Array(e)}const en=Qr(4),tn=Qr(8),rn=Qr(12),nn=Qr(16),on=Qr(4);function an(e,t,r,n,o,i){const a=(t-i)*(r-o),s=(e-o)*(n-i),u=a-s;if(0===a||0===s||a>0!=s>0)return u;const c=Math.abs(a+s);return Math.abs(u)>=33306690738754716e-32*c?u:-function(e,t,r,n,o,i,a){let s,u,c,l,d,p,f,h,y,g,m,v,b,S,E,w,P,x;const M=e-o,_=r-o,I=t-i,O=n-i;S=M*O,p=zr*M,f=p-(p-M),h=M-f,p=zr*O,y=p-(p-O),g=O-y,E=h*g-(S-f*y-h*y-f*g),w=I*_,p=zr*I,f=p-(p-I),h=I-f,p=zr*_,y=p-(p-_),g=_-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,d=E-m,en[0]=E-(m+d)+(d-P),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-w,d=b-m,en[1]=b-(m+d)+(d-w),x=v+m,d=x-v,en[2]=v-(x-d)+(m-d),en[3]=x;let C=function(e,t){let r=t[0];for(let e=1;e<4;e++)r+=t[e];return r}(0,en),T=22204460492503146e-32*a;if(C>=T||-C>=T)return C;if(d=e-M,s=e-(M+d)+(d-o),d=r-_,c=r-(_+d)+(d-o),d=t-I,u=t-(I+d)+(d-i),d=n-O,l=n-(O+d)+(d-i),0===s&&0===u&&0===c&&0===l)return C;if(T=11093356479670487e-47*a+33306690738754706e-32*Math.abs(C),C+=M*l+O*s-(I*c+_*u),C>=T||-C>=T)return C;S=s*O,p=zr*s,f=p-(p-s),h=s-f,p=zr*O,y=p-(p-O),g=O-y,E=h*g-(S-f*y-h*y-f*g),w=u*_,p=zr*u,f=p-(p-u),h=u-f,p=zr*_,y=p-(p-_),g=_-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,d=E-m,on[0]=E-(m+d)+(d-P),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-w,d=b-m,on[1]=b-(m+d)+(d-w),x=v+m,d=x-v,on[2]=v-(x-d)+(m-d),on[3]=x;const A=Zr(4,en,4,on,tn);S=M*l,p=zr*M,f=p-(p-M),h=M-f,p=zr*l,y=p-(p-l),g=l-y,E=h*g-(S-f*y-h*y-f*g),w=I*c,p=zr*I,f=p-(p-I),h=I-f,p=zr*c,y=p-(p-c),g=c-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,d=E-m,on[0]=E-(m+d)+(d-P),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-w,d=b-m,on[1]=b-(m+d)+(d-w),x=v+m,d=x-v,on[2]=v-(x-d)+(m-d),on[3]=x;const L=Zr(A,tn,4,on,rn);S=s*l,p=zr*s,f=p-(p-s),h=s-f,p=zr*l,y=p-(p-l),g=l-y,E=h*g-(S-f*y-h*y-f*g),w=u*c,p=zr*u,f=p-(p-u),h=u-f,p=zr*c,y=p-(p-c),g=c-y,P=h*g-(w-f*y-h*y-f*g),m=E-P,d=E-m,on[0]=E-(m+d)+(d-P),v=S+m,d=v-S,b=S-(v-d)+(m-d),m=b-w,d=b-m,on[1]=b-(m+d)+(d-w),x=v+m,d=x-v,on[2]=v-(x-d)+(m-d),on[3]=x;const k=Zr(L,rn,4,on,nn);return nn[k-1]}(e,t,r,n,o,i,c)}Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(8),Qr(8),Qr(8),Qr(4),Qr(8),Qr(8),Qr(8),Qr(12),Qr(192),Qr(192),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(8),Qr(8),Qr(8),Qr(8),Qr(8),Qr(8),Qr(8),Qr(8),Qr(8),Qr(4),Qr(4),Qr(4),Qr(8),Qr(16),Qr(16),Qr(16),Qr(32),Qr(32),Qr(48),Qr(64),Qr(1152),Qr(1152),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(4),Qr(24),Qr(24),Qr(24),Qr(24),Qr(24),Qr(24),Qr(24),Qr(24),Qr(24),Qr(24),Qr(1152),Qr(1152),Qr(1152),Qr(1152),Qr(1152),Qr(2304),Qr(2304),Qr(3456),Qr(5760),Qr(8),Qr(8),Qr(8),Qr(16),Qr(24),Qr(48),Qr(48),Qr(96),Qr(192),Qr(384),Qr(384),Qr(384),Qr(768),Qr(96),Qr(96),Qr(96),Qr(1152);var sn=function(e,t,r,n,o){this.p1=e,this.p2=t,this.edgeType=r,this.originalIndex=n,this.polygonContourId=o,this.interiorRing=!1,this.minX=Math.min(e.p[0],t.p[0]),this.minY=Math.min(e.p[1],t.p[1]),this.maxX=Math.max(e.p[0],t.p[0]),this.maxY=Math.max(e.p[1],t.p[1]),this.intersectionPoints=[],this.nextEdge=null},un=function(e){this.p=e},cn=function(e,t){this.id=e,this.rawCoords=t};function ln(e,t){return!(e.maxX<t[0]||e.minX>t[2]||e.maxY<t[1]||e.minY>t[3])}var dn=function(e,t,r,n){this.p=e,this.polylineEdge=t,this.polygonEdge=r,this.isHeadingIn=n,this.distanceFromPolylineEdgeStart=pn(this.polylineEdge.p1.p,this.p),this.distanceFromPolygonEdgeStart=pn(this.polygonEdge.p1.p,this.p),this.polygonEdge.intersectionPoints.push(this),this.polylineEdge.intersectionPoints.push(this),this.visitCount=0};function pn(e,t){var r=t[0]-e[0],n=t[1]-e[1];return r*=r,n*=n,Math.sqrt(r+n)}function fn(e,t){return e[0]*t[1]-e[1]*t[0]}function hn(e,t){return e[0]*t[0]+e[1]*t[1]}function yn(e,t,r){return[e[0]+t*r[0],e[1]+t*r[1]]}function gn(e,t,r){var n=[e.p2.p[0]-e.p1.p[0],e.p2.p[1]-e.p1.p[1]],o=[t.p2.p[0]-t.p1.p[0],t.p2.p[1]-t.p1.p[1]],i=[t.p1.p[0]-e.p1.p[0],t.p1.p[1]-e.p1.p[1]],a=fn(n,o),s=a*a,u=hn(n,n);if(s>0){var c=fn(i,o)/a;if(c<0||c>1)return null;var l=fn(i,n)/a;return l<0||l>1?null:0===c||1===c?r?null:[yn(e.p1.p,c,n)]:0===l||1===l?r?null:[yn(t.p1.p,l,o)]:[yn(e.p1.p,c,n)]}var d=hn(i,i);if((s=(a=fn(i,n))*a)>1e-9*u*d)return null;var p=hn(n,i)/u,f=p+hn(n,o)/u,h=Math.min(p,f),y=Math.max(p,f);return h<=1&&y>=0?1===h?r?null:[yn(e.p1.p,h>0?h:0,n)]:0===y?r?null:[yn(e.p1.p,y<1?y:1,n)]:r&&0===h&&1===y?null:[yn(e.p1.p,h>0?h:0,n),yn(e.p1.p,y<1?y:1,n)]:null}function mn(e,t){for(var r=0;r<e.length;r++){var n=e[r];if(n.polygonContourId===t)return n}}function vn(e,t){return t.find(function(t){return t.id===e.polygonContourId}).rawCoords}function bn(e,t){for(var r=0;r<t.length;r++){var n=t[r];if(Wr(e[0],[n[0]]))return void n.push(e)}t.push([e])}function Sn(e,t){var r=e.polygonEdge;if(r.intersectionPoints.length>1&&r.intersectionPoints[r.intersectionPoints.length-1]!==e){var n=En(e,r.intersectionPoints),o=r.intersectionPoints[n+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(r.p2.p),null===(r=r.nextEdge))return e;r.intersectionPoints.length>0&&(i=!1)}return r.intersectionPoints[0].incrementVisitCount(),t.push(r.intersectionPoints[0].p),r.intersectionPoints[0]}function En(e,t){for(var r=0;r<t.length;r++)if(t[r]===e)return r;return null}function wn(e,t){var r=e.polylineEdge;if(2===r.intersectionPoints.length){var n=r.intersectionPoints[r.intersectionPoints.length-1];if(n===e){var o=r.intersectionPoints[0];return t.push(o.p),o.incrementVisitCount(),o}return t.push(n.p),n.incrementVisitCount(),n}if(r.intersectionPoints.length>2&&r.intersectionPoints[0]!==e){var i=En(e,r.intersectionPoints),a=r.intersectionPoints[i-1];return t.push(a.p),a.incrementVisitCount(),a}for(var s=!0;s;){if(t.push(r.p1.p),void 0===(r=r.prevEdge).originalIndex)return e;r.intersectionPoints.length>0&&(s=!1)}if(void 0===r.originalIndex)return e;var u=r.intersectionPoints[r.intersectionPoints.length-1];return u.incrementVisitCount(),t.push(u.p),u}function Pn(e,t){var r=e.polylineEdge;if(r.intersectionPoints.length>1&&r.intersectionPoints[r.intersectionPoints.length-1]!==e){var n=En(e,r.intersectionPoints),o=r.intersectionPoints[n+1];return t.push(o.p),o.incrementVisitCount(),o}for(var i=!0;i;){if(t.push(r.p2.p),null===(r=r.nextEdge))return e;r.intersectionPoints.length>0&&(i=!1)}if(void 0===r)return e;var a=r.intersectionPoints[0];return a.incrementVisitCount(),t.push(a.p),a}function xn(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 Mn(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")}function _n(e){return"Feature"===e.type?e.geometry:e}dn.prototype.incrementVisitCount=function(){this.visitCount=this.visitCount+1};var In=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=xn(t),i=xn(r),a=it(o[0]),s=it(i[0]),u=it(o[1]),c=it(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 ot(Math.atan2(l,d))};function On(e,t,r,n={}){const o=xn(e),i=it(o[0]),a=it(o[1]),s=it(r),u=function(e,t="kilometers"){const r=Ze[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)),l=ot(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),d=ot(c);return void 0!==o[2]?et([l,d,o[2]],n.properties):et([l,d],n.properties)}var Cn=On;function Tn(e,t,r={}){if(!e)throw new Error("point is required");if(!t)throw new Error("polygon is required");const n=xn(e),o=_n(t),i=o.type,a=t.bbox;let s=o.coordinates;if(a&&!1===function(e,t){return t[0]<=e[0]&&t[1]<=e[1]&&t[2]>=e[0]&&t[3]>=e[1]}(n,a))return!1;"Polygon"===i&&(s=[s]);let u=!1;for(var c=0;c<s.length;++c){const e=Wr(n,s[c]);if(0===e)return!r.ignoreBoundary;e&&(u=!0)}return u}class An{constructor(e=[],t=Ln){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:r}=this,n=t[e];for(;e>0;){const o=e-1>>1,i=t[o];if(r(n,i)>=0)break;t[e]=i,e=o}t[e]=n}_down(e){const{data:t,compare:r}=this,n=this.length>>1,o=t[e];for(;e<n;){let n=1+(e<<1),i=t[n];const a=n+1;if(a<this.length&&r(t[a],i)<0&&(n=a,i=t[a]),r(i,o)>=0)break;t[e]=i,e=n}t[e]=o}}function Ln(e,t){return e<t?-1:e>t?1:0}function kn(e,t){return e.p.x>t.p.x?1:e.p.x<t.p.x?-1:e.p.y!==t.p.y?e.p.y>t.p.y?1:-1:1}function Fn(e,t){return e.rightSweepEvent.p.x>t.rightSweepEvent.p.x?1:e.rightSweepEvent.p.x<t.rightSweepEvent.p.x?-1:e.rightSweepEvent.p.y!==t.rightSweepEvent.p.y?e.rightSweepEvent.p.y<t.rightSweepEvent.p.y?1:-1:1}class jn{constructor(e,t,r,n){this.p={x:e[0],y:e[1]},this.featureId=t,this.ringId=r,this.eventId=n,this.otherEvent=null,this.isLeftEndpoint=null}isSamePoint(e){return this.p.x===e.p.x&&this.p.y===e.p.y}}let Nn=0,Vn=0,Dn=0;function Rn(e,t){const r="Feature"===e.type?e.geometry:e;let n=r.coordinates;"Polygon"!==r.type&&"MultiLineString"!==r.type||(n=[n]),"LineString"===r.type&&(n=[[n]]);for(let e=0;e<n.length;e++)for(let r=0;r<n[e].length;r++){let o=n[e][r][0],i=null;Vn+=1;for(let a=0;a<n[e][r].length-1;a++){i=n[e][r][a+1];const s=new jn(o,Nn,Vn,Dn),u=new jn(i,Nn,Vn,Dn+1);s.otherEvent=u,u.otherEvent=s,kn(s,u)>0?(u.isLeftEndpoint=!0,s.isLeftEndpoint=!1):(s.isLeftEndpoint=!0,u.isLeftEndpoint=!1),t.push(s),t.push(u),o=i,Dn+=1}}Nn+=1}class Un{constructor(e){this.leftSweepEvent=e,this.rightSweepEvent=e.otherEvent}}function Bn(e,t){if(null===e||null===t)return!1;if(e.leftSweepEvent.ringId===t.leftSweepEvent.ringId&&(e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.leftSweepEvent)||e.rightSweepEvent.isSamePoint(t.rightSweepEvent)||e.leftSweepEvent.isSamePoint(t.leftSweepEvent)||e.leftSweepEvent.isSamePoint(t.rightSweepEvent)))return!1;const r=e.leftSweepEvent.p.x,n=e.leftSweepEvent.p.y,o=e.rightSweepEvent.p.x,i=e.rightSweepEvent.p.y,a=t.leftSweepEvent.p.x,s=t.leftSweepEvent.p.y,u=t.rightSweepEvent.p.x,c=t.rightSweepEvent.p.y,l=(c-s)*(o-r)-(u-a)*(i-n);if(0===l)return!1;const d=((u-a)*(n-s)-(c-s)*(r-a))/l,p=((o-r)*(n-s)-(i-n)*(r-a))/l;return d>=0&&d<=1&&p>=0&&p<=1&&[r+d*(o-r),n+d*(i-n)]}function Gn(e,t,r={}){const{removeDuplicates:n=!0,ignoreSelfIntersections:o=!0}=r;let i=[];"FeatureCollection"===e.type?i=i.concat(e.features):"Feature"===e.type?i.push(e):"LineString"!==e.type&&"Polygon"!==e.type&&"MultiLineString"!==e.type&&"MultiPolygon"!==e.type||i.push(Qe(e)),"FeatureCollection"===t.type?i=i.concat(t.features):"Feature"===t.type?i.push(t):"LineString"!==t.type&&"Polygon"!==t.type&&"MultiLineString"!==t.type&&"MultiPolygon"!==t.type||i.push(Qe(t));const a=function(e,t){const r=new An([],kn);return function(e,t){if("FeatureCollection"===e.type){const r=e.features;for(let e=0;e<r.length;e++)Rn(r[e],t)}else Rn(e,t)}(e,r),function(e,t){t=t||!1;const r=[],n=new An([],Fn);for(;e.length;){const o=e.pop();if(o.isLeftEndpoint){const e=new Un(o);for(let i=0;i<n.data.length;i++){const a=n.data[i];if(t&&a.leftSweepEvent.featureId===o.featureId)continue;const s=Bn(e,a);!1!==s&&r.push(s)}n.push(e)}else!1===o.isLeftEndpoint&&n.pop()}return r}(r,t)}(nt(i),o);let s=[];if(n){const e={};a.forEach(t=>{const r=t.join(",");e[r]||(e[r]=!0,s.push(t))})}else s=a;return nt(s.map(e=>et(e)))}function Yn(e,t={}){const r=_n(e);switch(t.properties||"Feature"!==e.type||(t.properties=e.properties),r.type){case"Polygon":return function(e,t={}){return Xn(_n(e).coordinates,t.properties?t.properties:"Feature"===e.type?e.properties:{})}(r,t);case"MultiPolygon":return function(e,t={}){const r=_n(e).coordinates,n=t.properties?t.properties:"Feature"===e.type?e.properties:{},o=[];return r.forEach(e=>{o.push(Xn(e,n))}),nt(o)}(r,t);default:throw new Error("invalid poly")}}function Xn(e,t){return e.length>1?function(e,t,r={}){return Qe({type:"MultiLineString",coordinates:e},t,r)}(e,t):rt(e[0],t)}function Hn(e,t,{ignoreSelfIntersections:r=!0}={ignoreSelfIntersections:!0}){let n=!0;return ct(e,e=>{ct(t,t=>{if(!1===n)return!1;n=function(e,t,r){switch(e.type){case"Point":switch(t.type){case"Point":return n=e.coordinates,o=t.coordinates,!(n[0]===o[0]&&n[1]===o[1]);case"LineString":return!Jn(t,e);case"Polygon":return!Tn(e,t)}break;case"LineString":switch(t.type){case"Point":return!Jn(e,t);case"LineString":return!function(e,t,r){return Gn(e,t,{ignoreSelfIntersections:r}).features.length>0}(e,t,r);case"Polygon":return!qn(t,e,r)}break;case"Polygon":switch(t.type){case"Point":return!Tn(t,e);case"LineString":return!qn(e,t,r);case"Polygon":return!function(e,t,r){for(const r of e.coordinates[0])if(Tn(r,t))return!0;for(const r of t.coordinates[0])if(Tn(r,e))return!0;return Gn(Yn(e),Yn(t),{ignoreSelfIntersections:r}).features.length>0}(t,e,r)}}var n,o;return!1}(e.geometry,t.geometry,r)})}),n}function Jn(e,t){for(let r=0;r<e.coordinates.length-1;r++)if($n(e.coordinates[r],e.coordinates[r+1],t.coordinates))return!0;return!1}function qn(e,t,r){for(const r of t.coordinates)if(Tn(r,e))return!0;return Gn(t,Yn(e),{ignoreSelfIntersections:r}).features.length>0}function $n(e,t,r){const n=r[0]-e[0],o=r[1]-e[1],i=t[0]-e[0],a=t[1]-e[1];return 0===n*a-o*i&&(Math.abs(i)>=Math.abs(a)?i>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:a>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1])}var Kn=Object.defineProperty,Wn=(e,t)=>Kn(e,"name",{value:t,configurable:!0}),zn=class{constructor(e){var t,r,n;this.direction=!1,this.compareProperties=!0,this.precision=10**-(null!=(t=null==e?void 0:e.precision)?t:17),this.direction=null!=(r=null==e?void 0:e.direction)&&r,this.compareProperties=null==(n=null==e?void 0:e.compareProperties)||n}compare(e,t){if(e.type!==t.type)return!1;if(!Qn(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates);case"Polygon":return this.comparePolygon(e,t);case"GeometryCollection":return this.compareGeometryCollection(e,t);case"Feature":return this.compareFeature(e,t);case"FeatureCollection":return this.compareFeatureCollection(e,t);default:if(e.type.startsWith("Multi")){const r=eo(e),n=eo(t);return r.every(e=>n.some(t=>this.compare(e,t)))}}return!1}compareCoord(e,t){return e.length===t.length&&e.every((e,r)=>Math.abs(e-t[r])<this.precision)}compareLine(e,t,r=0,n=!1){if(!Qn(e,t))return!1;const o=e;let i=t;if(n&&!this.compareCoord(o[0],i[0])){const e=this.fixStartIndex(i,o);if(!e)return!1;i=e}const a=this.compareCoord(o[r],i[r]);return this.direction||a?this.comparePath(o,i):!!this.compareCoord(o[r],i[i.length-(1+r)])&&this.comparePath(o.slice().reverse(),i)}fixStartIndex(e,t){let r,n=-1;for(let r=0;r<e.length;r++)if(this.compareCoord(e[r],t[0])){n=r;break}return n>=0&&(r=[].concat(e.slice(n,e.length),e.slice(1,n+1))),r}comparePath(e,t){return e.every((e,r)=>this.compareCoord(e,t[r]))}comparePolygon(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){const r=e.coordinates.slice(1,e.coordinates.length),n=t.coordinates.slice(1,t.coordinates.length);return r.every(e=>n.some(t=>this.compareLine(e,t,1,!0)))}return!1}compareGeometryCollection(e,t){return Qn(e.geometries,t.geometries)&&this.compareBBox(e,t)&&e.geometries.every((e,r)=>this.compare(e,t.geometries[r]))}compareFeature(e,t){return e.id===t.id&&(!this.compareProperties||ro(e.properties,t.properties))&&this.compareBBox(e,t)&&this.compare(e.geometry,t.geometry)}compareFeatureCollection(e,t){return Qn(e.features,t.features)&&this.compareBBox(e,t)&&e.features.every((e,r)=>this.compare(e,t.features[r]))}compareBBox(e,t){return Boolean(!e.bbox&&!t.bbox)||!(!e.bbox||!t.bbox)&&this.compareCoord(e.bbox,t.bbox)}};Wn(zn,"GeojsonEquality");var Zn=zn;function Qn(e,t){return e.coordinates?e.coordinates.length===t.coordinates.length:e.length===t.length}function eo(e){return e.coordinates.map(t=>({type:e.type.replace("Multi",""),coordinates:t}))}function to(e,t,r){return new Zn(r).compare(e,t)}function ro(e,t){if(null===e&&null===t)return!0;if(null===e||null===t)return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(var o of r){const r=e[o],n=t[o],i=no(r)&&no(n);if(i&&!ro(r,n)||!i&&r!==n)return!1}return!0}Wn(Qn,"sameLength"),Wn(eo,"explode"),Wn(to,"geojsonEquality"),Wn(ro,"equal");var no=Wn(e=>null!=e&&"object"==typeof e,"isObject");function oo(e,t,r={}){const n=xn(e),o=Mn(t);for(let e=0;e<o.length-1;e++){let t=!1;if(r.ignoreEndVertices&&(0===e&&(t="start"),e===o.length-2&&(t="end"),0===e&&e+1===o.length-1&&(t="both")),io(o[e],o[e+1],n,t,void 0===r.epsilon?null:r.epsilon))return!0}return!1}function io(e,t,r,n,o){const i=r[0],a=r[1],s=e[0],u=e[1],c=t[0],l=t[1],d=c-s,p=l-u,f=(r[0]-s)*p-(r[1]-u)*d;if(null!==o){if(Math.abs(f)>o)return!1}else if(0!==f)return!1;return Math.abs(d)===Math.abs(p)&&0===Math.abs(d)?!n&&r[0]===e[0]&&r[1]===e[1]:n?"start"===n?Math.abs(d)>=Math.abs(p)?d>0?s<i&&i<=c:c<=i&&i<s:p>0?u<a&&a<=l:l<=a&&a<u:"end"===n?Math.abs(d)>=Math.abs(p)?d>0?s<=i&&i<c:c<i&&i<=s:p>0?u<=a&&a<l:l<a&&a<=u:"both"===n&&(Math.abs(d)>=Math.abs(p)?d>0?s<i&&i<c:c<i&&i<s:p>0?u<a&&a<l:l<a&&a<u):Math.abs(d)>=Math.abs(p)?d>0?s<=i&&i<=c:c<=i&&i<=s:p>0?u<=a&&a<=l:l<=a&&a<=u}function ao(e,t={}){var r="object"==typeof t?t.mutate:t;if(!e)throw new Error("geojson is required");var n=function(e){return"FeatureCollection"===e.type?"FeatureCollection":"GeometryCollection"===e.type?"GeometryCollection":"Feature"===e.type&&null!==e.geometry?e.geometry.type:e.type}(e),o=[];switch(n){case"LineString":o=so(e,n);break;case"MultiLineString":case"Polygon":Mn(e).forEach(function(e){o.push(so(e,n))});break;case"MultiPolygon":Mn(e).forEach(function(e){var t=[];e.forEach(function(e){t.push(so(e,n))}),o.push(t)});break;case"Point":return e;case"MultiPoint":var i={};Mn(e).forEach(function(e){var t=e.join("-");Object.prototype.hasOwnProperty.call(i,t)||(o.push(e),i[t]=!0)});break;default:throw new Error(n+" geometry not supported")}return e.coordinates?!0===r?(e.coordinates=o,e):{type:n,coordinates:o}:!0===r?(e.geometry.coordinates=o,e):Qe({type:n,coordinates:o},e.properties,{bbox:e.bbox,id:e.id})}function so(e,t){const r=Mn(e);if(2===r.length&&!uo(r[0],r[1]))return r;const n=[];let o=0,i=1,a=2;for(n.push(r[o]);a<r.length;)oo(r[i],rt([r[o],r[a]]))?i=a:(n.push(r[i]),o=i,i++,a=i),a++;if(n.push(r[i]),"Polygon"===t||"MultiPolygon"===t){if(oo(n[0],rt([n[1],n[n.length-2]]))&&(n.shift(),n.pop(),n.push(n[0])),n.length<4)throw new Error("invalid polygon, fewer than 4 points");if(!uo(n[0],n[n.length-1]))throw new Error("invalid polygon, first and last points not equal")}return n}function uo(e,t){return e[0]===t[0]&&e[1]===t[1]}function co(e,t,r={}){let n=r.precision;if(n=null==n||isNaN(n)?6:n,"number"!=typeof n||!(n>=0))throw new Error("precision must be a positive number");return _n(e).type===_n(t).type&&to(ao(e),ao(t),{precision:n})}function lo(e,t){var r=_n(e),n=_n(t),o=r.type,i=n.type;switch(o){case"MultiPoint":switch(i){case"LineString":return po(r,n);case"Polygon":return ho(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"LineString":switch(i){case"MultiPoint":return po(n,r);case"LineString":return function(e,t){const r=Gn(e,t);if(0===r.features.length)return!1;for(const n of r.features)if(!(co(n.geometry,et(e.coordinates[0]))||co(n.geometry,et(e.coordinates[e.coordinates.length-1]))||co(n.geometry,et(t.coordinates[0]))||co(n.geometry,et(t.coordinates[t.coordinates.length-1]))))return!0;return!1}(r,n);case"Polygon":return fo(r,n);default:throw new Error("feature2 "+i+" geometry not supported")}case"Polygon":switch(i){case"MultiPoint":return ho(n,r);case"LineString":return fo(n,r);default:throw new Error("feature2 "+i+" geometry not supported")}default:throw new Error("feature1 "+o+" geometry not supported")}}function po(e,t){for(var r=!1,n=!1,o=e.coordinates.length,i=0;i<o&&!r&&!n;){for(var a=0;a<t.coordinates.length-1;a++){var s=!0;0!==a&&a!==t.coordinates.length-2||(s=!1),yo(t.coordinates[a],t.coordinates[a+1],e.coordinates[i],s)?r=!0:n=!0}i++}return r&&n}function fo(e,t){return Gn(e,Yn(t)).features.length>0}function ho(e,t){var r=!1,n=!1,o=e.coordinates.length;for(let i=0;i<o&&(!r||!n);i++)Tn(et(e.coordinates[i]),t)?r=!0:n=!0;return n&&r}function yo(e,t,r,n){var o=r[0]-e[0],i=r[1]-e[1],a=t[0]-e[0],s=t[1]-e[1];return 0===o*s-i*a&&(n?Math.abs(a)>=Math.abs(s)?a>0?e[0]<=r[0]&&r[0]<=t[0]:t[0]<=r[0]&&r[0]<=e[0]:s>0?e[1]<=r[1]&&r[1]<=t[1]:t[1]<=r[1]&&r[1]<=e[1]:Math.abs(a)>=Math.abs(s)?a>0?e[0]<r[0]&&r[0]<t[0]:t[0]<r[0]&&r[0]<e[0]:s>0?e[1]<r[1]&&r[1]<t[1]:t[1]<r[1]&&r[1]<e[1])}function go(e){return e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]}function mo(e){for(var t=0;t<e.length-1;t++)for(var r=e[t],n=t+1;n<e.length-2;n++)if(oo(r,rt([e[n],e[n+1]])))return!0;return!1}function vo(e,t,r){for(var n=tt(e),o=r+1;o<t.length;o++)if(!Hn(n,tt(t[o]))&&lo(n,rt(t[o][0])))return!1;return!0}function bo(e){let t=0;if(e&&e.length>0){t+=Math.abs(Eo(e[0]));for(let r=1;r<e.length;r++)t-=Math.abs(Eo(e[r]))}return t}var So=Math.PI/180;function Eo(e){const t=e.length-1;if(t<=2)return 0;let r=0,n=0;for(;n<t;){const o=e[n],i=e[n+1===t?0:n+1],a=e[n+2>=t?(n+2)%t:n+2],s=o[0]*So,u=i[1]*So;r+=(a[0]*So-s)*Math.sin(u),n++}return 20294876564838.72*r}var wo=function(e){return function(e){var t=0;return ut(e,function(e,r,n,o,i){t=t+function(e){let t,r=0;switch(e.type){case"Polygon":return bo(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)r+=bo(e.coordinates[t]);return r;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}(e)}),t}(e)};function Po(e){return Po="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},Po(e)}function xo(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)||Mo(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 Mo(e,t){if(e){if("string"==typeof e)return _o(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)?_o(e,t):void 0}}function _o(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 Io(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 Oo(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Io(Object(r),!0).forEach(function(t){Co(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Io(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Co(e,t,r){return(t=function(e){var t=function(e){if("object"!=Po(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Po(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Po(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var To=function(e,t){var r,n,o,i,a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"meters",n=e.geometry.coordinates,o=[],i=In(n[1],n[0]),a=Cn(n[0],t,i,{units:r});o.push(a.geometry.coordinates);for(var s=0;s<n.length;s++){if(s>0&&s<n.length-1){var u=In(n[s-1],n[s]),c=Cn(n[s],t,u,{units:r});o.push(c.geometry.coordinates)}o.push(n[s])}var l=In(n[n.length-2],n[n.length-1]),d=Cn(n[n.length-1],t,l,{units:r});return o.push(d.geometry.coordinates),rt(o)}(t);try{i=function(e,t){var r=[],n=[],o=[],i=function(e,t,r,n,o){for(var i=0,a=[],s="Feature"===t.type?t.geometry:t,u="LineString"===s.type?[s.coordinates]:s.coordinates,c=0,l=0;l<u.length;l++){for(var d=u[l].length-1,p=new un(u[l][0]),f=null,h={nextEdge:null},y=0;y<d;y++){f=new un(u[l][y+1]),p.nextPoint=f,f.prevPoint=p;var g=new sn(p,f,"polyline",c,null);n.push(g),h.nextEdge=g,g.prevEdge=h,o[0]=Math.min(o[0],p.p[0]),o[1]=Math.min(o[1],p.p[1]),o[2]=Math.max(o[2],p.p[0]),o[3]=Math.max(o[3],p.p[1]),p=f,c+=1,h=g}o[0]=Math.min(o[0],u[l][d][0]),o[1]=Math.min(o[1],u[l][d][1]),o[2]=Math.max(o[2],u[l][d][0]),o[3]=Math.max(o[3],u[l][d][1])}for(var m="Feature"===e.type?e.geometry:e,v="Polygon"===m.type?[m.coordinates]:m.coordinates,b=v.length,S=0;S<b;S++)for(var E=v[S].length,w=0;w<E;w++){i+=1;var P=v[S][w],x=P.length;a.push(new cn(i,P));for(var M=new un(P[0]),_=M,I=void 0,O=null,C={nextEdge:null,prevEdge:null},T=null,A=1;A<x;A++)I=new un(P[A]),_.nextPoint=I,I.prevPoint=_,O=new sn(_,I,"polygon",c,i),C.nextEdge=O,O.prevEdge=C,1===A&&(T=O),w>0&&(O.interiorRing=!0),O.intersectPolylineBbox=ln(O,o),r.push(O),_=I,c+=1,C=O;O.nextEdge=T,T.prevEdge=O,I.nextPoint=M.nextPoint,M.prevPoint=I.prevPoint}return a}(Dr(e),t,n,o,[1/0,1/0,1/0,1/0]);if(function(e,t,r){var n,o,i,a=t.length,s=e.length;for(n=0;n<a;n++){var u=t[n];for(o=0;o<s;o++){var c=e[o];if(c.intersectPolylineBbox&&!(c.maxX<u.minX||c.minX>u.maxX||c.maxY<u.minY||c.minY>u.maxY)){var l=gn(u,c);if(null!==l)for(i=0;i<l.length;i++){var d=an(c.p1.p[0],c.p1.p[1],c.p2.p[0],c.p2.p[1],u.p1.p[0],u.p1.p[1]),p=new dn(l[i],u,c,d>0);r.push(p)}}}}t.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolylineEdgeStart-t.distanceFromPolylineEdgeStart})}),e.forEach(function(e){e.intersectionPoints.sort(function(e,t){return e.distanceFromPolygonEdgeStart-t.distanceFromPolygonEdgeStart})})}(n,o,r),0===r.length)return e;var a={};i.forEach(function(e){return a[e.id]=0}),r.forEach(function(e){var t=e.polygonEdge.polygonContourId;a[t]=a[t]+1});for(var s=0,u=[],c=null,l=0;l<o.length;l++){var d=o[l];if(d.intersectionPoints.length>0){c=d.intersectionPoints[0];break}}for(var p=c,f={visitCount:1};c!==f&&!(s>2*r.length);){if(s=s++,f.visitCount>=2){for(var h=!1,y=0;y<r.length;y++){var g=r[y];if(g.visitCount<2){p=g,h=!0;break}}if(!h)break}p.visitCount=p.visitCount+1;var m=[];u.push(m),m.push(p.p),p.visitCount=p.visitCount+1;var v=Sn(p,m),b=!1;if(v===(f=v)&&2===r.length)for(var S=0;S<r.length;S++)r[S].visitCount<2&&(b=!0);for(;v!==p||b;)(v=(v.isHeadingIn?Pn:wn)(v,m))!==p&&(v=Sn(v,m)),b=!1;if(f.visitCount>=2){for(var E=!1,w=0;w<r.length;w++){var P=r[w];if(P.visitCount<2){p=P,E=!0;break}}E&&(f=p)}p=f}for(var x=u.map(function(e){return[e]}),M=Object.keys(a),_=0;_<M.length;_++){var I=M[_];0===a[I]&&bn(vn(mn(n,parseInt(I)),i),x)}return{type:"Feature",properties:{},geometry:{type:"MultiPolygon",coordinates:x}}}(e,a)}catch(e){return null}var s=[];if("MultiPolygon"!==i.geometry.type)return null;if(2!==i.geometry.coordinates.length)return null;s=i.geometry.coordinates.map(function(t){return tt(t,e.properties)});var u=null!==(r=null!==(n=e.id)&&void 0!==n?n:null===(o=e.properties)||void 0===o?void 0:o.id)&&void 0!==r?r:"poly";return nt(s.map(function(t,r){return tt(t.geometry.coordinates,Oo(Oo({},e.properties),{},{id:u}),{id:"".concat(u,"-").concat(r+1)})}))},Ao=function(e,t){var r=xo(e,2),n=r[0],o=r[1],i=xo(t,2),a=i[0],s=i[1],u=function(e){return e*Math.PI/180},c=u(s-o),l=u(a-n),d=Math.pow(Math.sin(c/2),2)+Math.cos(u(o))*Math.cos(u(s))*Math.pow(Math.sin(l/2),2);return 12742e3*Math.atan2(Math.sqrt(d),Math.sqrt(1-d))},Lo=function(e){if(e[0].length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e[0].length<=1)return!0;if(e[0].length<=3)for(var r=0;r<e[0].length;r++)for(var n=r+1;n<e[0].length;n++)if(Ao(e[0][r],e[0][n])<t)return!1;return!0}(e))return!0;if(!Array.isArray(e)||e.length<4)return!1;var t=e[0],r=e[e.length-1];if(t[0]!==r[0]||t[1]!==r[1])return!1;var n=tt([e]);return!(!function(e){if(!e.type)return!1;const t=_n(e),r=t.type,n=t.coordinates;switch(r){case"Point":return n.length>1;case"MultiPoint":for(var o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"LineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"MultiLineString":if(n.length<2)return!1;for(o=0;o<n.length;o++)if(n[o].length<2)return!1;return!0;case"Polygon":for(o=0;o<t.coordinates.length;o++){if(n[o].length<4)return!1;if(!go(n[o]))return!1;if(mo(n[o]))return!1;if(o>0&&Gn(tt([n[0]]),tt([n[o]])).features.length>1)return!1}return!0;case"MultiPolygon":for(o=0;o<t.coordinates.length;o++)for(var i=t.coordinates[o],a=0;a<i.length;a++){if(i[a].length<4)return!1;if(!go(i[a]))return!1;if(mo(i[a]))return!1;if(0===a&&!vo(i,t.coordinates,o))return!1;if(a>0&&Gn(tt([i[0]]),tt([i[a]])).features.length>1)return!1}return!0;default:return!1}}(n)||wo(n)<=0)},ko=function(e,t,r){var n=t.filter(function(t,n){var o=Math.abs(t[0]-e[0]),i=Math.abs(t[1]-e[1]);return("ArrowUp"===r?t[1]<=e[1]&&i>=o:"ArrowDown"===r?t[1]>e[1]&&i>=o:"ArrowLeft"===r?t[0]<=e[0]&&i<o:"ArrowRight"!==r||t[0]>e[0]&&i<o)&&JSON.stringify(t)!==JSON.stringify(e)});n.length||n.push(e);var o,i=n.map(function(t){return r=Math.abs(e[0]-t[0]),n=Math.abs(e[1]-t[1]),Math.sqrt(Math.pow(r,2)+Math.pow(n,2));var r,n}),a=n[i.indexOf(Math.min.apply(Math,(o=i,function(e){if(Array.isArray(e))return _o(e)}(o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||Mo(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.")}())))];return t.findIndex(function(e){return JSON.stringify(e)===JSON.stringify(a)})};function Fo(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)||Vo(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 jo(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=Vo(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 No(e){return function(e){if(Array.isArray(e))return Do(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Vo(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 Vo(e,t){if(e){if("string"==typeof e)return Do(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)?Do(e,t):void 0}}function Do(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var Ro={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]},getCoordPath:function(e,t){var r=this.getFeature(e.featureId);if(!r)return"0";var n=nr(r),o=or(n,t);if(!o)return"0";var i=o.segment,a=o.localIdx;return[].concat(No(i.path),[a]).join(".")},syncVertices:function(e){e.vertecies=this.getVerticies(e.featureId),e.midpoints=this.getMidpoints(e.featureId)},getVerticies:function(e){return rr(this.getFeature(e))||[]},getMidpoints:function(e){var t=this.getFeature(e),r=rr(t),n=nr(t);if(null==r||!r.length||!n.length)return[];var o,i=[],a=jo(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=Fo(r[l],2),f=p[0],h=p[1],y=Fo(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(No(e.vertecies.map(i)),No(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=ko(s,a,t);return[u,u<e.vertecies.length?"vertex":"midpoint"]},getVertexIndexFromMidpoint:function(e,t){var r,n=this.getFeature(e.featureId),o=nr(n),i=t.split(".").map(Number),a=0,s=jo(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 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){return function(e){if(Array.isArray(e))return Yo(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Go(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 Go(e,t){if(e){if("string"==typeof e)return Yo(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Yo(e,t):void 0}}function Yo(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function Xo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function Ho(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Xo(Object(r),!0).forEach(function(t){Jo(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xo(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Jo(e,t,r){return(t=function(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+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var qo=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"]),$o={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},Ko=Ho(Ho(Ho(Ho(Ho(Ho({},Ft),lr),mr),_r),Ro),{},{onSetup:function(e){var t,r,n=this,o=Ft.onSetup.call(this,e);Object.assign(o,{container:e.container,interfaceType:e.interfaceType,deleteVertexButtonId:e.deleteVertexButtonId,undoButtonId:e.undoButtonId,isPanEnabled:e.isPanEnabled,getSnapEnabled:e.getSnapEnabled,featureId:o.featureId||e.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});var i=this.getFeature(o.featureId);o.featureType=null==i?void 0:i.type,o.vertecies=this.getVerticies(o.featureId),o.midpoints=this.getMidpoints(o.featureId),this.setupEventListeners(o),this.applyVertexSelection(o,e),this.map._drawEditContainer=e.container,this.addTouchVertexTarget(o);var a=v(this.map);if(a&&w(a,this.map),"touch"===o.interfaceType&&o.selectedVertexIndex>=0&&"vertex"===o.selectedVertexType){var s=o.vertecies[o.selectedVertexIndex];s&&setTimeout(function(){n.updateTouchVertexTarget(o,sr(n.map.project(s),o.scale))},0)}return o._ignorePointermoveDeselect=!0,setTimeout(function(){o._ignorePointermoveDeselect=!1},100),o},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)};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)},applyVertexSelection:function(e,t){if("midpoint"===t.selectedVertexType)return e.selectedCoordPaths=[],this.clearSelectedCoordinates(),e.feature&&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&&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=rr(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?sr(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?sr(this.map.project(r),e.scale):null)},onUpdate:function(e){var t,r=new Set(e.vertecies.map(function(e){return JSON.stringify(e)}));r.size!==e.vertecies.length&&(e.selectedVertexIndex=e.vertecies.findIndex(function(e){return!r.has(JSON.stringify(e))}),null!==(t=e.selectedVertexType)&&void 0!==t||(e.selectedVertexType=e.selectedVertexIndex>=0?"vertex":null))},onKeydown:function(e,t){if(e.container.contains(document.activeElement)){if(e.interfaceType="keyboard",this.hideTouchVertexIndicator(e)," "===t.key&&t.preventDefault()," "===t.key&&e.selectedVertexIndex<0){var r,n,o=v(this.map);if(o&&w(o,this.map),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;return e.isPanEnabled=!1,this.updateVertex(e)}if(!t.altKey&&qo.has(t.key)&&e.selectedVertexIndex>=0){if(t.preventDefault(),t.stopPropagation(),"midpoint"===e.selectedVertexType)return this.insertVertex(e,t);var i=v(this.map),a=this.getFeature(e.featureId);if(!a)return;var s=rr(a),u=null==s?void 0:s[e.selectedVertexIndex];if(!u)return;if(e._keyboardMoveStartPosition||(e._keyboardMoveStartPosition=Bo(u),e._keyboardMoveStartIndex=e.selectedVertexIndex),x(e)&&e._isSnapped&&i){var c=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:15}(i)+1,l=this.map.project(u),d=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)||Go(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.")}()}($o[t.key].map(function(e){return e*c}),2),p=d[0],f=d[1];return e._isSnapped=!1,w(i,this.map),this.moveVertex(e,this.map.unproject({x:l.x+p,y:l.y+f}))}var h=this.getNewCoord(e,t);return x(e)&&i&&(E(i,this.map,this.map.project(h)),b(i))?(e._isSnapped=!0,this.moveVertex(e,S(i))):(e._isSnapped=!1,this.moveVertex(e,h))}if(t.altKey&&qo.has(t.key)&&e.selectedVertexIndex>=0)return t.preventDefault(),t.stopPropagation(),this.updateVertex(e,t.key);if("Escape"===t.key&&this.changeMode(e,{isPanEnabled:!0,selectedVertexIndex:-1,selectedVertexType:null}),"z"===t.key&&(t.metaKey||t.ctrlKey)&&!t.shiftKey){var y,g=null===(y=document.activeElement)||void 0===y?void 0:y.tagName;if("INPUT"===g||"TEXTAREA"===g)return;return t.preventDefault(),t.stopPropagation(),this.handleUndo(e)}}},onKeyup:function(e,t){e.container.contains(document.activeElement)&&(e.interfaceType="keyboard",qo.has(t.key)&&e.selectedVertexIndex>=0&&(t.stopPropagation(),e._keyboardMoveStartPosition&&void 0!==e._keyboardMoveStartIndex&&(this.pushUndo({type:"move_vertex",featureId:e.featureId,vertexIndex:e._keyboardMoveStartIndex,previousPosition:e._keyboardMoveStartPosition}),e._keyboardMoveStartPosition=null,e._keyboardMoveStartIndex=void 0)),"Delete"===t.key&&this.deleteVertex(e))},onMouseDown:function(e,t){var r,n;P(v(this.map));var o=null===(r=t.featureTarget)||void 0===r?void 0:r.properties.meta,i=null===(n=t.featureTarget)||void 0===n?void 0:n.properties.coord_path;if(["vertex","midpoint"].includes(o)&&(e.dragMoveLocation=t.lngLat,e.dragMoving=!1,Ft.onMouseDown.call(this,e,t),"vertex"===o&&i)){var a,s=this.getFeature(e.featureId),u=ar(s,i);e.selectedVertexIndex=u,e.selectedVertexType="vertex",e.coordPath=i;var c=null===(a=e.vertecies)||void 0===a?void 0:a[u];c&&(e._moveStartPosition=Bo(c),e._moveStartIndex=u)}if("midpoint"===o){var l=this.getFeature(e.featureId),d=ar(l,i);e._insertedVertexIndex=d,e._isInsertingVertex=!0,e.selectedVertexIndex=this.getVertexIndexFromMidpoint(e,i),e.selectedVertexType="vertex",e.coordPath=null,this.map.fire("draw.vertexselection",{index:e.selectedVertexIndex,numVertecies:e.vertecies.length})}},onClick:function(e,t){if(e._isInsertingVertex&&void 0!==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=void 0,void this.map.fire("draw.vertexselection",{index:r,numVertecies:e.vertecies.length})}Ft.onClick.call(this,e,t)},onMouseUp:function(e,t){P(v(this.map));var r=!1;if(e._moveStartPosition&&void 0!==e._moveStartIndex){var n=this.getFeature(e.featureId);if(n){var o,i=null===(o=rr(n))||void 0===o?void 0:o[e._moveStartIndex];i&&(r=i[0]!==e._moveStartPosition[0]||i[1]!==e._moveStartPosition[1])}}var a=e._isInsertingVertex&&void 0!==e._insertedVertexIndex;if(e.dragMoving||r||a)if(this.syncVertices(e),a){var s=e._insertedVertexIndex;this.pushUndo({type:"insert_vertex",featureId:e.featureId,vertexIndex:s}),e.selectedVertexIndex=s,e.selectedVertexType="vertex",e._isInsertingVertex=!1,e._insertedVertexIndex=void 0,this.map.fire("draw.vertexselection",{index:s,numVertecies:e.vertecies.length})}else r&&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=null,Ft.onMouseUp.call(this,e,t)},onDrag:function(e,t){var r;if("touch"!==e.interfaceType){this.map.fire("draw.geometrychange",e.feature);var n=v(this.map);if(n&&(n.snapStatus=!1,n.snapCoords=null),x(e)&&null!=n&&n.status){if(null!==(r=e.selectedCoordPaths)&&void 0!==r&&r.length&&e.canDragMove){e.dragMoving=!0,t.originalEvent.stopPropagation(),E(n,this.map,t.point);var o=S(n)||t.lngLat;e.feature.updateCoordinate(e.selectedCoordPaths[0],o.lng,o.lat),e.dragMoveLocation=t.lngLat}}else Ft.onDrag.call(this,e,t)}},onMove:function(e){var t=e.vertecies[e.selectedVertexIndex];t&&this.updateTouchVertexTarget(e,sr(this.map.project(t),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",Ho(Ho({},e),t))},onStop:function(e){this.map._drawEditContainer=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.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 Wo(e){return Wo="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Wo(e)}function zo(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)||Zo(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 Zo(e,t){if(e){if("string"==typeof e)return Qo(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)?Qo(e,t):void 0}}function Qo(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 ei(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 ti(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ei(Object(r),!0).forEach(function(t){ri(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ei(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ri(e,t,r){return(t=function(e){var t=function(e){if("object"!=Wo(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Wo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Wo(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ni=function(e,t){var r=t.featureProp,n=t.geometryType,o=t.getCoords,i=t.validateClick,a=t.createVertices,s=t.excludeFeatureIdFromSetup,u=void 0!==s&&s,c=t.finishOnInvalidClick,l=void 0!==c&&c,d=function(e){return e[r]};return ti(ti({},e),{},{onSetup:function(t){var n=this,o=this.map,i=u?ti(ti({},t),{},{featureId:null}):t,a=ti(ti({},e.onSetup.call(this,i)),t);a[r].properties=t.properties;var s=a.container,c=a.vertexMarkerId,l=a.getInterfaceType,d=l?l():a.interfaceType;a.interfaceType=d;var p=s.querySelector("#".concat(c));a.vertexMarker=p,["touch","keyboard"].includes(d)?this._showCrossHair(a):this._hideCrossHair(a);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};return Object.entries(f).forEach(function(e){var t,r,o=zo(e,2);return t=o[0],r=o[1],n[t]=r.bind(n,a)}),this._listeners=[[window,"keydown",this.keydownHandler],[window,"keyup",this.keyupHandler],[window,"click",this.vertexButtonClickHandler],[s,"blur",this.blurHandler],[s,"pointermove",this.pointermoveHandler],[s,"pointerup",this.pointerupHandler],[o,"pointerdown",this.pointerdownHandler],[o,"draw.create",this.createHandler],[o,"move",this.moveHandler],[o,"draw.undo",this.undoHandler]],this._listeners.forEach(function(e){var t=zo(e,3),r=t[0],n=t[1],o=t[2];return r.addEventListener?r.addEventListener(n,o):r.on(n,o)}),a},onClick:function(t,r){if(!(r.originalEvent.button>0||this.map._undoInProgress||r.originalEvent.target!==this.map.getCanvas())){var n=v(this.map);if(x(t)&&b(n))r=function(e,t){var r=S(t);return r?g(g({},e),{},{lngLat:r}):e}(r,n);else{var a=o(d(t));if(a.length>0&&(a[a.length-1]=[r.lngLat.lng,r.lngLat.lat]),!l&&!i(d(t)))return}var s=o(d(t)).length;e.onClick.call(this,t,r),o(d(t)).length>s&&(this.pushDrawUndo(t),this.dispatchVertexChange(o(d(t))))}},onTap:function(){},doClick:function(t){if(!this.map._undoInProgress){var r=d(t),n=o(r);if(this.dispatchVertexChange(n),i(r)){var a=v(this.map),s=x(t)&&function(e,t){var r=S(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,a),u=n.length;s?(e.onClick.call(this,t,s),this._ctx.store.render()):this._simulateMouse("click",e.onClick,t);var c=o(d(t));c.length>u&&(this.pushDrawUndo(t),this.dispatchVertexChange(c))}else l&&n.length>1&&(n.pop(),this.map.fire("draw.create",{features:[r.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[r.id]}))}},dispatchVertexChange:function(e){this.map.fire("draw.vertexchange",{numVertecies:Math.max(0,e.length-1)})},pushDrawUndo:function(e){var t=this.map._undoStack;t&&!this.map._undoInProgress&&t.push({type:"draw_vertex",geometryType:n,featureId:d(e).id})},undoVertex:function(e){var t=d(e),r=o(t);return!(r.length<2)&&(2===r.length?this._reinitializeFeature(e,t):(this._removeLastVertex(e,t,r),!0))},_reinitializeFeature:function(t,o){var i=o.id;if(this._ctx.store.delete([i]),"LineString"===n){var a=this.map._undoStack;return a&&a.clear(),this._ctx.api.changeMode("draw_line",{featureId:i,container:t.container,interfaceType:t.interfaceType,crossHair:t.crossHair,vertexMarkerId:t.vertexMarkerId,addVertexButtonId:t.addVertexButtonId,getSnapEnabled:t.getSnapEnabled,properties:t.properties}),!0}var s=this.map.getCenter(),u=[[s.lng,s.lat],[s.lng,s.lat]],c=this.newFeature({type:"Feature",properties:t.properties||{},geometry:{type:n,coordinates:[u]}});return c.id=i,this._ctx.store.add(c),t[r]=c,t.currentVertexPosition=0,this._ctx.store.render(),this._simulateMouse("mousemove",e.onMouseMove,t),this._ctx.store.render(),this.dispatchVertexChange(u),!0},_removeLastVertex:function(e,t,r){var i="Polygon"===n?t.coordinates[0]:r;i.splice(-2,1);var a,s=i[i.length-2];s&&(i[i.length-1]=function(e){if(Array.isArray(e))return Qo(e)}(a=s)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(a)||Zo(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,o(t))},_updateRubberBand:function(t,r){if(["touch","keyboard"].includes(t.interfaceType))this._simulateMouse("mousemove",e.onMouseMove,t),this._ctx.store.render();else{var o=r["Polygon"===n?r.length-2:r.length-1];if(o){var i={lng:o[0],lat:o[1]},a=this.map.project(i);e.onMouseMove.call(this,t,{lngLat:i,point:a,originalEvent:new MouseEvent("mousemove",{clientX:a.x,clientY:a.y})}),this._ctx.store.render()}}this.dispatchVertexChange(r)},onUndo:function(e,t){var r;"draw_vertex"===(null===(r=t.operation)||void 0===r?void 0:r.type)&&this.undoVertex(e)},_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)},onCreate:function(e,t){var r=this._ctx.api,n=t.features[0];r.delete(n.id),n.id=e.featureId,r.add(n,{userProperties:!0})},onVertexButtonClick:function(e,t){e.addVertexButtonId&&!this.map._undoInProgress&&t.target.closest("#".concat(e.addVertexButtonId))&&this.doClick(e)},onTouchStart:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},onTouchEnd:function(e,t){this._setInterface(e,"touch"),this.onMove(e,t)},_handleUndoKeydown:function(e,t){var r,n=this,o=null===(r=document.activeElement)||void 0===r?void 0:r.tagName;if("INPUT"!==o&&"TEXTAREA"!==o){t.preventDefault(),t.stopPropagation();var i=this.map._undoStack;if(i&&i.length>0){var a=i.pop();"draw_vertex"===(null==a?void 0:a.type)&&(this.map._undoInProgress=!0,setTimeout(function(){n.map._undoInProgress=!1},100),this.undoVertex(e))}}},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),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&&(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(t,r){var n=document.activeElement;if(!n||n===t.container||!t.container.contains(n))if("Escape"!==r.key)n!==t.container&&e.onKeyUp.call(this,t,r);else if("keyboard"===t.interfaceType){var o=this.map._undoStack;o&&o.clear(),this._reinitializeFeature(t,d(t))}},onBlur:function(e,t){t.target!==e.container&&this._hideCrossHair(e)},onMouseMove:function(t,r){if(x(t)){var n=v(this.map);E(n,this.map,r.point);var o=S(n);o&&(r=ti(ti({},r),{},{lngLat:o}))}this.map.fire("draw.geometrychange",t.polygon||t.line),e.onMouseMove.call(this,t,r)},onMove:function(t){if(["touch","keyboard"].includes(t.interfaceType)){x(t)&&function(e,t){if(!e||!t||!e.status)return!1;var r=t.getCenter(),n=t.project(r);e.snapToClosestPoint({point:n,lngLat:r})}(v(this.map),this.map);var r=v(this.map),n=x(t)&&S(r);if(n){var o=this.map.project([n.lng,n.lat]);e.onMouseMove.call(this,t,{lngLat:n,point:o,originalEvent:new MouseEvent("mousemove",{clientX:o.x,clientY:o.y,bubbles:!0,cancelable:!0})}),this._ctx.store.render()}else this._simulateMouse("mousemove",e.onMouseMove,t)}},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(o(d(e)))},toDisplayFeatures:function(t,r,o){e.toDisplayFeatures.call(this,t,r,o);var i=d(t);r.geometry.type===n&&r.id===i.id&&a(r,o,We)},onStop:function(t){e.onStop.call(this,t),this._listeners.forEach(function(e){var t=zo(e,3),r=t[0],n=t[1],o=t[2];return r.removeEventListener?r.removeEventListener(n,o):r.off(n,o)}),this._hideCrossHair(t)}})},oi=ni(Rt,{featureProp:"polygon",geometryType:"Polygon",getCoords:function(e){return e.coordinates[0]},validateClick:function(e){return Lo(e.coordinates)},createVertices:function(e,t,r){for(var n=e.geometry.coordinates[0],o=1;o<n.length-2;o++)t(r(e.id,n[o],"0.".concat(o)))}}),ii=ni(Bt,{featureProp:"line",geometryType:"LineString",getCoords:function(e){return e.coordinates},validateClick:function(e){return(t=e.coordinates).length<=1||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.01;if(e.length<=1)return!0;if(e.length>=2){var r=e[e.length-1],n=e[e.length-2];if(Ao(r,n)<t)return!1}return!0}(t);var t},excludeFeatureIdFromSetup:!0,finishOnInvalidClick:!0,createVertices:function(e,t,r){for(var n=e.geometry.coordinates,o=1;o<n.length-1;o++)t(r(e.id,n[o],"".concat(o)))}}),ai={editStroke:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editVertex:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editMidpoint:{light:"rgba(29,112,184,1)",dark:"#ffffff"},editHalo:{light:"#ffffff",dark:"rgba(11,12,12,1)"},editActive:{light:"rgba(11,12,12,1)",dark:"#ffffff"},splitInvalid:{light:"rgba(29,112,184,1)",dark:"rgba(29,112,184,1)"},splitValid:{light:"rgba(29,112,184,1)",dark:"rgba(29,112,184,1)"},shapeStroke:"rgba(212,53,28,1)",shapeFill:"rgba(212,53,28,0.1)",strokeWidth:2,snapVertex:"rgba(212,53,28,1)",snapMidpoint:"rgba(40,161,151,1)",snapEdge:"rgba(29,112,184,1)",snapRadius:10,snapLayers:[]};function si(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 ui=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t;return["coalesce",["get","user_".concat(t).concat(e.id.charAt(0).toUpperCase()+e.id.slice(1))],["get","user_".concat(t)],ai[r]]},ci=function(e){return{id:"fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","false"]],paint:{"fill-color":ui(e,"fill","shapeFill")}}},li=function(e){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":ui(e,"stroke","shapeStroke"),"line-width":ui(e,"strokeWidth")}}},di=function(e){return{id:"fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":e,"fill-opacity":.1}}},pi=function(e){return{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":e,"line-width":2,"line-opacity":1}}},fi=function(e){return{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":e,"line-width":2,"line-dasharray":[.2,2],"line-opacity":1}}},hi=function(e){return{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":e,"line-width":2,"line-opacity":1}}},yi=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}}},gi=function(e){return{id:"vertex",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"]],paint:{"circle-radius":6,"circle-color":e}}},mi=function(e,t){return{id:"vertex-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":8,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},vi=function(e){return{id:"vertex-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","vertex"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":e}}},bi=function(e){return{id:"midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":4,"circle-color":e}}},Si=function(e,t){return{id:"midpoint-halo",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-stroke-width":3,"circle-color":e,"circle-stroke-color":t}}},Ei=function(e){return{id:"midpoint-active",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":4,"circle-color":e}}},wi=function(e){return{id:"circle",type:"line",filter:["==","id","circle"],paint:{"line-color":e,"line-width":2,"line-opacity":.8}}},Pi=function(e){var t=function(e){var t;return null!==(t=e.mapColorScheme)&&void 0!==t?t:"light"}(e),r=ai.editStroke[t],n=ai.editVertex[t],o=ai.editMidpoint[t],i=ai.editHalo[t],a=ai.editActive[t],s=ai.splitInvalid[t],u=ai.splitValid[t];return[ci(e),di(r),pi(r),li(e),fi(s),hi(u),yi(r),bi(o),Si(i,a),Ei(o),gi(n),mi(i,a),vi(n),wi(r),{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}}]},xi=6371008.8,Mi={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:xi,metres:xi,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function _i(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 Ii(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(!Li(e[0])||!Li(e[1]))throw new Error("coordinates must contain numbers");return _i({type:"Point",coordinates:e},t,r)}function Oi(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 _i({type:"LineString",coordinates:e},t,r)}function Ci(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 Ti(e){return e%(2*Math.PI)*180/Math.PI}function Ai(e){return e%360*Math.PI/180}function Li(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function ki(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 Fi(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 ji=function(e,t,r){void 0===r&&(r={});var n=ki(e),o=ki(t),i=Ai(o[1]-n[1]),a=Ai(o[0]-n[0]),s=Ai(n[1]),u=Ai(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=Mi[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 Ni(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,S=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var E=a.type;switch(d=!r||"Polygon"!==E&&"MultiPolygon"!==E?0:1,E){case null:break;case"Point":if(!1===t(u,p,m,b,S))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===t(u[n],p,m,b,S))return!1;p++,"MultiPoint"===E&&b++}"LineString"===E&&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,S))return!1;p++}"MultiLineString"===E&&b++,"Polygon"===E&&S++}"Polygon"===E&&b++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(S=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-d;i++){if(!1===t(u[n][o][i],p,m,b,S))return!1;p++}S++}b++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===Ni(a.geometries[n],t,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Vi(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 Di(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(_i(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(_i({type:a,coordinates:c},n),r,u))return!1}})}function Ri(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={}),_i({type:"MultiLineString",coordinates:e},t,r)}(n,o):Oi(n[0],o)}function Ui(e,t,r,n){void 0===n&&(n={});var o=ki(e),i=Ai(o[0]),a=Ai(o[1]),s=Ai(r),u=function(e,t){void 0===t&&(t="kilometers");var r=Mi[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 Ii([Ti(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),Ti(c)],n.properties)}const Bi=function(e){if(!e)throw new Error("geojson is required");var t=[];return Di(e,function(e){!function(e,t){var r=[],n=e.geometry;if(null!==n){switch(n.type){case"Polygon":r=Fi(n);break;case"LineString":r=[Fi(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=Oi([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)}),Ci(t)};var Gi=r(945);function Yi(e,t){var r=Fi(e),n=Fi(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?Ii([o+f*(a-o),i+f*(s-i)]):null}const Xi=function(e,t){var r={},n=[];if("LineString"===e.type&&(e=_i(e)),"LineString"===t.type&&(t=_i(t)),"Feature"===e.type&&"Feature"===t.type&&null!==e.geometry&&null!==t.geometry&&"LineString"===e.geometry.type&&"LineString"===t.geometry.type&&2===e.geometry.coordinates.length&&2===t.geometry.coordinates.length){var o=Yi(e,t);return o&&n.push(o),Ci(n)}var i=Gi();return i.load(Bi(t)),Vi(Bi(e),function(e){Vi(i.search(e),function(t){var o=Yi(e,t);if(o){var i=Fi(o).join(",");r[i]||(r[i]=!0,n.push(o))}})}),Ci(n)},Hi=function(e,t,r){void 0===r&&(r={});var n=Ii([1/0,1/0],{dist:1/0}),o=0;return Di(e,function(e){for(var i=Fi(e),a=0;a<i.length-1;a++){var s=Ii(i[a]);s.properties.dist=ji(t,s,r);var u=Ii(i[a+1]);u.properties.dist=ji(t,u,r);var c=ji(s,u,r),l=Math.max(s.properties.dist,u.properties.dist),d=In(s,u),p=Ui(t,l,d+90,r),f=Ui(t,l,d-90,r),h=Xi(Oi([p.geometry.coordinates,f.geometry.coordinates]),Oi([s.geometry.coordinates,u.geometry.coordinates])),y=null;h.features.length>0&&((y=h.features[0]).properties.dist=ji(t,y,r),y.properties.location=o+ji(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 Ji=6371008.8,qi={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260.511392,inches:250826616.45599997,kilometers:6371.0088,kilometres:6371.0088,meters:Ji,metres:Ji,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:3440.069546436285,radians:1,yards:6967335.223679999};function $i(e){return e%(2*Math.PI)*180/Math.PI}function Ki(e){return e%360*Math.PI/180}function Wi(e){return!isNaN(e)&&null!==e&&!Array.isArray(e)}function zi(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 Zi=function(e,t,r){void 0===r&&(r={});var n=zi(e),o=zi(t),i=Ki(o[1]-n[1]),a=Ki(o[0]-n[0]),s=Ki(n[1]),u=Ki(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=qi[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)},Qi=function(e,t){var r=function(e,t,r,n){void 0===n&&(n={});var o=zi(e),i=Ki(o[0]),a=Ki(o[1]),s=Ki(r),u=function(e,t){void 0===t&&(t="kilometers");var r=qi[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(!Wi(e[0])||!Wi(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)}([$i(i+Math.atan2(Math.sin(s)*Math.sin(u)*Math.cos(a),Math.cos(u)-Math.sin(a)*Math.sin(c))),$i(c)],n.properties)}(e,Zi(e,t)/2,In(e,t));return r};var ea=function(){return ea=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},ea.apply(this,arguments)},ta=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=ea(ea({},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 ji(Ii(e),Ii(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=ji(Ii([r.lng,r.lat]),Ii([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(On(e,t,-360*o/n,r).geometry.coordinates);return i.push(i[0]),tt([i],o)}(s.coords,i,{steps:64,units:"meters",properties:{color:s.color}})):(this.snapStatus=!1,this.snapCoords=[]);var u=Ci(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(Ci([])))}),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=[],Ni(e,function(e){n.push(e)}),n),i=[];if(o.map(function(e){var n=ji(Ii(e),Ii([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(Oi(e))});break;case"Polygon":var o=Ri(e.geometry);n.push(o);break;case"MultiPolygon":Ri(e.geometry).coodinates.map(function(e){n.push(Oi(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(Bi(e).features)});var i=[];if(o.map(function(e){var n=Qi(e.geometry.coordinates[0],e.geometry.coordinates[1]),o=ji(n,Ii([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=Hi(n[i],Ii([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 ra=ta;function na(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 oa(e,t,r){return(t=function(e){var t=function(e){if("object"!=ia(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ia(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ia(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ia(e){return ia="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ia(e)}var aa="snap-helper-circle";function sa(e,t){!function r(){var n=e();null!==n&&(n?t(n):requestAnimationFrame(r))}()}function ua(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"===ia(e)&&Array.isArray(e.features)?e:{type:"FeatureCollection",features:[]}},configurable:!0})}}function ca(e){return ca="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},ca(e)}function la(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 da(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?la(Object(r),!0).forEach(function(t){pa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):la(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function pa(e,t,r){return(t=function(e){var t=function(e){if("object"!=ca(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ca(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ca(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var fa=function(e){var t=e.mapStyle,r=e.mapProvider,n=e.events,o=e.eventBus,i=e.snapLayers,a=r.map;Zt.constants.classes.CONTROL_BASE="maplibregl-ctrl",Zt.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",Zt.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group";var s=da(da({},Zt.modes),{},{disabled:Qt,edit_vertex:Ko,draw_polygon:oi,draw_line:ii}),u=new Zt({modes:s,styles:Pi(t),displayControlsDefault:!1,userProperties:!0,defaultMode:"disabled"});a.addControl(u);var c=a.getCanvas(),l=null,d=function(e){1===e.touches.length&&(l={x:e.touches[0].clientX,y:e.touches[0].clientY,time:Date.now()})},p=function(e){if("disabled"===u.getMode()&&l){var t=e.changedTouches[0],r=t.clientX-l.x,n=t.clientY-l.y;Date.now()-l.time<300&&Math.abs(r)<10&&Math.abs(n)<10&&c.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,clientX:t.clientX,clientY:t.clientY})),l=null}else l=null};c.addEventListener("touchstart",d,{passive:!0}),c.addEventListener("touchend",p,{passive:!0}),r.draw=u,a._drawCurrentMapStyle=t,r.snapEnabled=!1;var f=function(e){var t=[],r=function(){e.fire("draw.undochange",{length:t.length})};return{push:function(e){t.push(e),r()},pop:function(){var e=t.pop();return r(),e},clear:function(){t.length=0,r()},get length(){return t.length}}}(a);r.undoStack=f,a._undoStack=f,function(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?15: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;function h(r){if(e._snapInstance||e._snapCreating)return e._snapInstance;e._snapCreating=!0,e.getLayer(aa)&&e.removeLayer(aa),e.getSource(aa)&&e.removeSource(aa),ua(r);var n=new ra({map:e,drawing:t,options:{layers:o,radius:a,rules:u},status:l,onSnapped:p}),i=l;return Object.defineProperty(n,"status",{get:function(){return i},set:function(){},configurable:!0}),n.setSnapStatus=function(e){i=e},n._defaultLayers=o,n._activeLayers=null,n.setSnapLayers=function(e){null==e?n._activeLayers=null:Array.isArray(e)&&(n._activeLayers=e)},void 0!==e._pendingSnapLayers&&(n.setSnapLayers(e._pendingSnapLayers),delete e._pendingSnapLayers),e._snapInstance=n,n}!function(e){if(!ra.prototype.__snapPatched){ra.prototype.__snapPatched=!0;var t=ra.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(){},t.setMapData=function(e){var t,n;if(this.status){var o=r.setMapData.call(this,e);return(null==e||null===(t=e.features)||void 0===t?void 0:t.length)>0&&null!==(n=this.map)&&void 0!==n&&n.getLayer(aa)&&this.map.setLayoutProperty(aa,"visibility","visible"),o}},t.drawingSnapCheck=function(){if(this.status)return r.drawingSnapCheck.call(this)},t.getLines=function(e,t,n){var o=e.geometry;if(!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 tt(e)}):"MultiLineString"===o.type?i.filter(function(e){return Array.isArray(e)&&e.length>0}).map(function(e){return rt(e)}):r.getLines.call(this,e,t,n)}catch(e){return console.log(e),[]}},t.getCloseFeatures=function(e,t){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||15,a=e.point;e.point=[[a.x-i,a.y-i],[a.x+i,a.y+i]];var s=r.getCloseFeatures.call(this,e,t);return e.point=a,s},t.searchInVertex=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInVertex.apply(this,n);return i&&(i.color=e.vertex),i},t.searchInMidPoint=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInMidPoint.apply(this,n);return i&&(i.color=e.midpoint),i},t.searchInEdge=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=r.searchInEdge.apply(this,n);return i&&(i.color=e.edge),i},t.snapToClosestPoint=function(e){var t;if(this.status&&(null===(t=this.map)||void 0===t||!t._isZooming))try{var n,o,i=r.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){console.log(e),this.snapStatus=!1,this.snapCoords=null}}}}(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?na(Object(r),!0).forEach(function(t){oa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):na(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({vertex:ai.snapVertex,midpoint:ai.snapMidpoint,edge:ai.snapEdge},void 0===f?{}:f)),e.on("style.load",function(){sa(function(){return e._removed?null:e.getSource("mapbox-gl-draw-hot")},function(t){var r;ua(t),e.getSource(aa)||e.addSource(aa,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),e.getLayer(aa)||e.addLayer({id:aa,type:"fill",source:aa,paint:{"fill-color":["get","color"],"fill-opacity":.6},layout:{visibility:null!==(r=e._snapInstance)&&void 0!==r&&r.status?"visible":"none"}}),e._snapInstance||h(t)})}),e.on("zoomstart",function(){e._isZooming=!0}),e.on("zoomend",function(){if(e._isZooming=!1,e.getLayer(aa)){e.setLayoutProperty(aa,"visibility","none");var t=e._snapInstance;null!=t&&t.status&&e.setLayoutProperty(aa,"visibility","visible")}}),sa(function(){return e._removed?null:e.getSource("mapbox-gl-draw-hot")},h)}(a,u,{layers:i,radius:10,rules:["vertex","edge"]});var h=function(e){a._drawCurrentMapStyle=e,a.once("idle",function(){var t;!function(e,t){Pi(t).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 si(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)?si(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)})})}(a,e);var r=null===(t=a._drawEditContainer)||void 0===t?void 0:t.querySelector("[data-touch-vertex-target]");gr(r,e)})};return o.on(n.MAP_SET_STYLE,h),o.on(n.MAP_SET_SIZE,function(e){a.fire("draw.scalechange",{scale:{small:1,medium:1.5,large:2}[e]})}),{draw:u,remove:function(){c.removeEventListener("touchstart",d),c.removeEventListener("touchend",p),o.off(n.MAP_SET_STYLE,h),u.deleteAll(),u.changeMode("disabled"),a.removeControl(u)}}};function ha(e){return ha="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},ha(e)}function ya(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 ga(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)?ga(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 ga(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 ma=["stroke","fill","strokeWidth"],va=function(e){if(!e)return{};for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var o=ya(n[r],2),i=o[0],a=o[1];if(ma.includes(i)&&"object"===ha(a)&&null!==a){var s=Object.entries(a);s.length>0&&(t[i]=s[0][1]);for(var u=0,c=s;u<c.length;u++){var l=ya(c[u],2),d=l[0],p=l[1];t["".concat(i).concat(d.charAt(0).toUpperCase()+d.slice(1))]=p}}else t[i]=a}return t};function ba(e){return ba="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},ba(e)}var Sa=["stroke","fill","strokeWidth","properties"];function Ea(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function wa(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ea(Object(r),!0).forEach(function(t){Pa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ea(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Pa(e,t,r){return(t=function(e){var t=function(e){if("object"!=ba(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ba(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ba(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xa(e){return xa="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},xa(e)}var Ma=["stroke","fill","strokeWidth","properties"];function _a(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 Ia(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?_a(Object(r),!0).forEach(function(t){Oa(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Oa(e,t,r){return(t=function(e){var t=function(e){if("object"!=xa(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=xa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==xa(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ca(e){return Ca="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},Ca(e)}var Ta=["stroke","fill","strokeWidth","properties"];function Aa(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 La(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Aa(Object(r),!0).forEach(function(t){ka(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Aa(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function ka(e,t,r){return(t=function(e){var t=function(e){if("object"!=Ca(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=Ca(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Ca(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Fa(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 ja(e){return ja="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},ja(e)}function Na(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 Va(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Na(Object(r),!0).forEach(function(t){Da(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Na(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function Da(e,t,r){return(t=function(e){var t=function(e){if("object"!=ja(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=ja(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==ja(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Ra=function(e){return{mobile:{slot:"actions",showLabel:e},tablet:{slot:"actions",showLabel:e},desktop:{slot:"actions",showLabel:e}}},Ua={reducer:{initialState:{mode:null,action:null,actionValid:!1,feature:null,tempFeature:null,selectedVertexIndex:-1,numVertecies:null,snap:!1,hasSnapLayers:!1,undoStackLength:0},actions:d},InitComponent:function(e){var t=e.appState,r=e.appConfig,n=e.mapState,o=e.pluginConfig,i=e.pluginState,a=e.services,s=e.mapProvider,u=e.buttonConfig,c=a.eventBus,l=n.crossHair,d=["touch","keyboard"].includes(t.interfaceType);(0,p.useEffect)(function(){var e,r,a,u,l,d=null===(e=null===(r=o.includeModes)||void 0===r?void 0:r.includes(t.mode))||void 0===e||e,p=null!==(a=null===(u=o.excludeModes)||void 0===u?void 0:u.includes(t.mode))&&void 0!==a&&a;if(n.isMapReady&&d&&!p){var h=fa({mapStyle:n.mapStyle,snapLayers:o.snapLayers,mapProvider:s,events:f,eventBus:c}).remove;return i.dispatch({type:"SET_HAS_SNAP_LAYERS",payload:(null===(l=o.snapLayers)||void 0===l?void 0:l.length)>0}),c.emit("draw:ready"),function(){return h()}}},[n.isMapReady,t.mode]),(0,p.useEffect)(function(){s.draw&&(s.draw._crossHair=l)},[s.draw,l]),(0,p.useEffect)(function(){if(["draw_polygon","draw_line"].includes(i.mode)&&d){var e=l.isVisible;return l.fixAtCenter(),function(){e||l.hide()}}},[i.mode,t.interfaceType]),(0,p.useEffect)(function(){"edit_vertex"===i.mode&&s.map&&s.map.fire("draw.interfacetypechange",{interfaceType:t.interfaceType})},[t.interfaceType,i.mode]),(0,p.useEffect)(function(){if(s.draw){var e=function(e){var t=e.pluginState,r=e.mapProvider,n=e.buttonConfig,o=e.eventBus,i=n.drawDone,a=n.drawAddPoint,s=n.drawUndo,u=n.drawDeletePoint,c=n.drawSnap,l=n.drawCancel,d=r.map,p=r.draw,f=t.dispatch,h=t.feature,y=t.tempFeature,g=function(){r.snapEnabled=!1,f({type:"SET_SNAP",payload:!1});var e,t=v(d);t&&(null===(e=t.setSnapStatus)||void 0===e||e.call(t,!1),P(t)),d.getLayer("snap-helper-circle")&&d.setLayoutProperty("snap-helper-circle","visibility","none")},m=function(){var e;null===(e=r.undoStack)||void 0===e||e.clear(),f({type:"SET_MODE",payload:null}),f({type:"SET_FEATURE",payload:{feature:null,tempFeature:null}})},b=function(){p.trash(),null!=y&&y.id&&p.delete(y.id),h&&p.add(h),g(),p.changeMode("disabled"),m(),o.emit("draw:cancelled",h)},S=0,E=["draw_polygon","draw_line"],x=function(e){E.includes(e.mode)||w(v(d),d)},M=function(){var e,t=d.getStyle().layers||[];!t.length||null!==(e=t[t.length-1].source)&&void 0!==e&&e.startsWith("mapbox-gl-draw")||t.filter(function(e){var t;return null===(t=e.source)||void 0===t?void 0:t.startsWith("mapbox-gl-draw")}).forEach(function(e){return d.moveLayer(e.id)})},_=function(e){return function(t){var r=t.features[0];g(),m(),setTimeout(function(){return p.changeMode("disabled")},0),o.emit(e,r)}},I=function(e){var t=e.features[0];o.emit("draw:updated",t)},O=_("draw:created"),C=_("draw:edited"),T=function(e){f({type:"SET_SELECTED_VERTEX_INDEX",payload:e}),o.emit("draw:vertexselection",e)},A=function(e){f({type:"SET_SELECTED_VERTEX_INDEX",payload:{index:-1,numVertecies:e.numVertecies}})},L=function(e){f({type:"SET_UNDO_STACK_LENGTH",payload:e.length})};return i.onClick=function(){var e,t=p.getMode();g(),null===(e=r.undoStack)||void 0===e||e.clear(),"edit_vertex"!==t?["draw_polygon","draw_line"].includes(t)&&p.changeMode("disabled"):d.fire("draw.editfinish",{features:[p.get(y.id)]})},l.onClick=b,s.onClick=function(){if("edit_vertex"!==p.getMode()){var e=r.undoStack;if(null!=e&&e.length){var t=e.pop();d._undoInProgress=!0,setTimeout(function(){d._undoInProgress=!1},100),d.fire("draw.undo",{operation:t})}}},c.onClick=function(){var e=Date.now();if(!(e-S<300)){S=e;var n=!t.snap;f({type:"TOGGLE_SNAP"}),r.snapEnabled=n;var o=v(d);null!=o&&o.setSnapStatus&&o.setSnapStatus(n),!n&&o&&(P(o),d.getLayer("snap-helper-circle")&&d.setLayoutProperty("snap-helper-circle","visibility","none"))}},d.on("styledata",M),d.on("draw.cancel",b),d.on("draw.create",O),d.on("draw.modechange",x),d.on("draw.editfinish",C),d.on("draw.update",I),d.on("draw.vertexselection",T),d.on("draw.vertexchange",A),d.on("draw.undochange",L),function(){[i,a,s,u,c,l].forEach(function(e){e&&(e.onClick=null)}),d.off("styledata",M),d.off("draw.cancel",b),d.off("draw.create",O),d.off("draw.editfinish",C),d.off("draw.update",I),d.off("draw.modechange",x),d.off("draw.vertexselection",T),d.off("draw.vertexchange",A),d.off("draw.undochange",L)}}({appState:t,appConfig:r,mapState:n,mapProvider:s,buttonConfig:u,pluginState:i,events:f,eventBus:c});return function(){return e()}}},[s,t,i])},buttons:[Va({id:"drawCancel",label:"Cancel",variant:"tertiary",exclusiveSlot:!0,hiddenWhen:function(e){return!e.pluginState.mode}},Ra(!0)),Va({id:"drawAddPoint",label:"Add point",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.appState,r=e.pluginState;return!["draw_polygon","draw_line"].includes(r.mode)||"touch"!==t.interfaceType}},Ra(!0)),Va({id:"drawDone",label:"Done",variant:"primary",exclusiveSlot:!0,hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){var t=e.pluginState;return t.numVertecies>=("draw_polygon"===t.mode?3:2)}},Ra(!0)),{id:"drawMenu",label:"Menu",iconId:"menu",hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},menuItems:[{id:"drawUndo",label:"Undo",iconId:"undo",hiddenWhen:function(e){var t=e.pluginState;return!["draw_polygon","draw_line","edit_vertex"].includes(t.mode)},enableWhen:function(e){return e.pluginState.undoStackLength>0}},{id:"drawSnap",label:"Snap to feature",iconId:"magnet",hiddenWhen:function(e){var t=e.pluginState;return!t.mode||!t.hasSnapLayers},pressedWhen:function(e){return!!e.pluginState.snap}},{id:"drawDeletePoint",label:"Delete point",iconId:"trash",enableWhen:function(e){var t,r=e.pluginState;return r.selectedVertexIndex>=0&&r.numVertecies>("Polygon"===(null===(t=r.tempFeature)||void 0===t||null===(t=t.geometry)||void 0===t?void 0:t.type)?3:2)},hiddenWhen:function(e){var t=e.pluginState;return!["simple_select","edit_vertex"].includes(t.mode)}}],mobile:{slot:"bottom-right"},tablet:{slot:"top-middle"},desktop:{slot:"top-middle"}}],keyboardShortcuts:[{id:"drawStart",group:"Drawing",title:"Edit vertex",command:"<kbd>Spacebar</kbd></dd>"}],icons:[{id:"menu",svgContent:'<path d="m6 9 6 6 6-6"/>'},{id:"undo",svgContent:'<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11"/>'},{id:"check",svgContent:'<path d="M20 6 9 17l-5-5"/>'},{id:"magnet",svgContent:'<path d="m12 15 4 4"/><path d="M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z"/><path d="m5 8 4 4"/>'},{id:"trash",svgContent:'<path d="M10 11v6"/><path d="M14 11v6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M3 6h18"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>'}],api:{newPolygon:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginConfig,a=e.pluginState,s=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=a.dispatch,d=s.draw,p=s.map,f=u.eventBus;if(d){f.emit("draw:started",{mode:"draw_polygon"});var h;h=void 0!==c.snapLayers?c.snapLayers:void 0!==i.snapLayers?i.snapLayers:null;var y=v(p);null!=y&&y.setSnapLayers?y.setSnapLayers(h):h&&(p._pendingSnapLayers=h),l({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=h)||void 0===r?void 0:r.length)>0});var g=c.stroke,m=c.fill,b=c.strokeWidth,S=c.properties,E=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(c,Sa),w=wa(wa({},S),va({stroke:g,fill:m,strokeWidth:b}));d.changeMode("draw_polygon",wa(wa({container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,crossHair:d._crossHair,getSnapEnabled:function(){return!0===s.snapEnabled},featureId:t},E),{},{properties:w})),l({type:"SET_MODE",payload:"draw_polygon"})}},newLine:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginConfig,a=e.pluginState,s=e.mapProvider,u=e.services,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},l=a.dispatch,d=s.draw,p=s.map,f=u.eventBus;if(d){f.emit("draw:started",{mode:"draw_line"});var h;h=void 0!==c.snapLayers?c.snapLayers:void 0!==i.snapLayers?i.snapLayers:null;var y=v(p);null!=y&&y.setSnapLayers?y.setSnapLayers(h):h&&(p._pendingSnapLayers=h),l({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=h)||void 0===r?void 0:r.length)>0});var g=c.stroke,m=c.fill,b=c.strokeWidth,S=c.properties,E=function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(c,Ma),w=Ia(Ia({},S),va({stroke:g,fill:m,strokeWidth:b}));d.changeMode("draw_line",Ia(Ia({container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,crossHair:d._crossHair,getSnapEnabled:function(){return!0===s.snapEnabled},featureId:t},E),{},{properties:w})),l({type:"SET_MODE",payload:"draw_line"})}},editFeature:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.mapState,a=e.pluginConfig,s=e.pluginState,u=e.mapProvider,c=e.services,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},d=s.dispatch,p=u.draw,f=u.map,h=c.eventBus;if(!p)return!1;var y=p.get(t);if(!y)return!1;h.emit("draw:editstart",{mode:{LineString:"edit_line",Polygon:"edit_polygon"}[y.geometry.type]});var g,m=null;m=void 0===l.snapLayers?null!==(g=a.snapLayers)&&void 0!==g?g:null:l.snapLayers;var b=v(f);null!=b&&b.setSnapLayers?b.setSnapLayers(m):m&&(f._pendingSnapLayers=m),d({type:"SET_HAS_SNAP_LAYERS",payload:(null===(r=m)||void 0===r?void 0:r.length)>0}),p.changeMode("edit_vertex",{container:n.layoutRefs.viewportRef.current,deleteVertexButtonId:"".concat(o.id,"-draw-delete-point"),undoButtonId:"".concat(o.id,"-draw-undo"),isPanEnabled:"keyboard"!==n.interfaceType,interfaceType:n.interfaceType,scale:{small:1,medium:1.5,large:2}[i.mapSize],featureId:t,getSnapEnabled:function(){return!0===u.snapEnabled}});var S=p.get(t);return d({type:"SET_FEATURE",payload:{feature:S,tempFeature:S}}),d({type:"SET_MODE",payload:"edit_vertex"}),!0},addFeature:function(e,t){var r=e.mapProvider,n=e.services,o=r.draw,i=n.eventBus;if(o){var a=t.stroke,s=t.fill,u=t.strokeWidth,c=t.properties,l=La(La({},function(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}(t,Ta)),{},{properties:La(La({},c),va({stroke:a,fill:s,strokeWidth:u}))});o.add(l,{userProperties:!0}),i.emit("draw:add",l)}},deleteFeature:function(e,t){var r=e.mapProvider,n=e.services,o=r.draw,i=n.eventBus;o&&(o.delete(t),i.emit("draw:delete",{featureIds:t}))},split:function(e,t){var r,n=e.appState,o=e.appConfig,i=e.pluginState,a=e.mapProvider,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=i.dispatch,c=a.draw,l=a.map;if(c){var d=c.get(t),p=["stroke-inactive.cold"].concat(function(e){if(Array.isArray(e))return Fa(e)}(r=s.snapLayers||[])||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 Fa(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)?Fa(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.")}()),f=v(l);null!=f&&f.setSnapLayers?f.setSnapLayers(p):s.snapLayers&&(l._pendingSnapLayers=p),u({type:"SET_HAS_SNAP_LAYERS",payload:!0}),c.changeMode("draw_line",{container:n.layoutRefs.viewportRef.current,vertexMarkerId:"".concat(o.id,"-cross-hair"),addVertexButtonId:"".concat(o.id,"-draw-add-point"),interfaceType:n.interfaceType,getSnapEnabled:function(){return!0===a.snapEnabled},featureId:"_splitter",properties:{splitter:"invalid"}}),l.on("draw.create",function(e){var t=e.features[0],r=To(d,t);c.setFeatureProperty("_splitter","splitter",r?"valid":"invalid"),u({type:"SET_ACTION",payload:{name:"split",isValid:!!r}})});var h,y,g,m=(h=function(e){if(!(e.coordinates.length<2)){var t={id:"_splitter",geometry:{type:"LineString",coordinates:e.coordinates}},r=!!To(d,t);e.properties.splitter=r?"valid":"invalid",e.ctx.store.render(),"edit_vertex"===c.getMode()&&u({type:"SET_ACTION",payload:{name:"split",isValid:r}})}},g=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];clearTimeout(y),y=setTimeout(function(){return h.apply(void 0,t)},50)},g.cancel=function(){clearTimeout(y),y=null},g);l.on("draw.geometrychange",m),u({type:"SET_MODE",payload:"draw_line"}),u({type:"SET_ACTION",payload:{name:"split"}})}},merge:function(e,t){e.services,console.log("merge"),console.log(t)}}}}}]);