mapbox-gl-draw-snap-mode
Version:
Snapping mode for mapbox-gl-draw
1 lines • 120 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mapboxGlDrawSnapMode=e():t.mapboxGlDrawSnapMode=e()}(this,(()=>(()=>{var t={188:function(t,e,n){t.exports=function(){"use strict";var t=function(t,e){var n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},r={on:function(t,e,r){if(void 0===n[t])throw new Error("Invalid event type: "+t);n[t].push({selector:e,fn:r})},render:function(t){e.store.featureChanged(t)}},o=function(t,o){for(var i=n[t],a=i.length;a--;){var s=i[a];if(s.selector(o)){s.fn.call(r,o)||e.store.render(),e.ui.updateMapClasses();break}}};return t.start.call(r),{render:t.render,stop:function(){t.stop&&t.stop()},trash:function(){t.trash&&(t.trash(),e.store.render())},combineFeatures:function(){t.combineFeatures&&t.combineFeatures()},uncombineFeatures:function(){t.uncombineFeatures&&t.uncombineFeatures()},drag:function(t){o("drag",t)},click:function(t){o("click",t)},mousemove:function(t){o("mousemove",t)},mousedown:function(t){o("mousedown",t)},mouseup:function(t){o("mouseup",t)},mouseout:function(t){o("mouseout",t)},keydown:function(t){o("keydown",t)},keyup:function(t){o("keyup",t)},touchstart:function(t){o("touchstart",t)},touchmove:function(t){o("touchmove",t)},touchend:function(t){o("touchend",t)},tap:function(t){o("tap",t)}}};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var n=function t(){if(this instanceof t){var n=[null];return n.push.apply(n,arguments),new(Function.bind.apply(e,n))}return e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}var o={},i={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:6356752.3142};function a(t){var e=0;if(t&&t.length>0){e+=Math.abs(s(t[0]));for(var n=1;n<t.length;n++)e-=Math.abs(s(t[n]))}return e}function s(t){var e,n,r,o,a,s,c=0,l=t.length;if(l>2){for(s=0;s<l;s++)s===l-2?(r=l-2,o=l-1,a=0):s===l-1?(r=l-1,o=0,a=1):(r=s,o=s+1,a=s+2),e=t[r],n=t[o],c+=(u(t[a][0])-u(e[0]))*Math.sin(u(n[1]));c=c*i.RADIUS*i.RADIUS/2}return c}function u(t){return t*Math.PI/180}o.geometry=function t(e){var n,r=0;switch(e.type){case"Polygon":return a(e.coordinates);case"MultiPolygon":for(n=0;n<e.coordinates.length;n++)r+=a(e.coordinates[n]);return r;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(n=0;n<e.geometries.length;n++)r+=t(e.geometries[n]);return r}},o.ring=s;var c={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"},l={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},p={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},d={POLYGON:"polygon",LINE:"line_string",POINT:"point"},f={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"},h={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select",STATIC:"static"},g={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"},y={MOVE:"move",CHANGE_COORDINATES:"change_coordinates"},v={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},m={ACTIVE:"true",INACTIVE:"false"},b=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],E=-85,_=Object.freeze({__proto__:null,classes:c,sources:l,cursors:p,types:d,geojsonTypes:f,modes:h,events:g,updateActions:y,meta:v,activeStates:m,interactions:b,LAT_MIN:-90,LAT_RENDERED_MIN:E,LAT_MAX:90,LAT_RENDERED_MAX:85,LNG_MIN:-270,LNG_MAX:270}),O={Point:0,LineString:1,MultiLineString:1,Polygon:2};function S(t,e){var n=O[t.geometry.type]-O[e.geometry.type];return 0===n&&t.geometry.type===f.POLYGON?t.area-e.area:n}function I(t){return t.map((function(t){return t.geometry.type===f.POLYGON&&(t.area=o.geometry({type:f.FEATURE,property:{},geometry:t.geometry})),t})).sort(S).map((function(t){return delete t.area,t}))}function C(t,e){return void 0===e&&(e=0),[[t.point.x-e,t.point.y-e],[t.point.x+e,t.point.y+e]]}function w(t){if(this._items={},this._nums={},this._length=t?t.length:0,t)for(var e=0,n=t.length;e<n;e++)this.add(t[e]),void 0!==t[e]&&("string"==typeof t[e]?this._items[t[e]]=e:this._nums[t[e]]=e)}w.prototype.add=function(t){return this.has(t)||(this._length++,"string"==typeof t?this._items[t]=this._length:this._nums[t]=this._length),this},w.prototype.delete=function(t){return!1===this.has(t)||(this._length--,delete this._items[t],delete this._nums[t]),this},w.prototype.has=function(t){return!("string"!=typeof t&&"number"!=typeof t||void 0===this._items[t]&&void 0===this._nums[t])},w.prototype.values=function(){var t=this,e=[];return Object.keys(this._items).forEach((function(n){e.push({k:n,v:t._items[n]})})),Object.keys(this._nums).forEach((function(n){e.push({k:JSON.parse(n),v:t._nums[n]})})),e.sort((function(t,e){return t.v-e.v})).map((function(t){return t.k}))},w.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};var T=[v.FEATURE,v.MIDPOINT,v.VERTEX],x={click:function(t,e,n){return P(t,e,n,n.options.clickBuffer)},touch:function(t,e,n){return P(t,e,n,n.options.touchBuffer)}};function P(t,e,n,r){if(null===n.map)return[];var o=t?C(t,r):e,i={};n.options.styles&&(i.layers=n.options.styles.map((function(t){return t.id})));var a=n.map.queryRenderedFeatures(o,i).filter((function(t){return-1!==T.indexOf(t.properties.meta)})),s=new w,u=[];return a.forEach((function(t){var e=t.properties.id;s.has(e)||(s.add(e),u.push(t))})),I(u)}function M(t,e){var n=x.click(t,null,e),r={mouse:p.NONE};return n[0]&&(r.mouse=n[0].properties.active===m.ACTIVE?p.MOVE:p.POINTER,r.feature=n[0].properties.meta),-1!==e.events.currentModeName().indexOf("draw")&&(r.mouse=p.ADD),e.ui.queueMapClasses(r),e.ui.updateMapClasses(),n[0]}function L(t,e){var n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function A(t,e,n){void 0===n&&(n={});var r=null!=n.fineTolerance?n.fineTolerance:4,o=null!=n.grossTolerance?n.grossTolerance:12,i=null!=n.interval?n.interval:500;t.point=t.point||e.point,t.time=t.time||e.time;var a=L(t.point,e.point);return a<r||a<o&&e.time-t.time<i}function F(t,e,n){void 0===n&&(n={});var r=null!=n.tolerance?n.tolerance:25,o=null!=n.interval?n.interval:250;return t.point=t.point||e.point,t.time=t.time||e.time,L(t.point,e.point)<r&&e.time-t.time<o}var N={exports:{}},j=N.exports=function(t,e){if(e||(e=16),void 0===t&&(t=128),t<=0)return"0";for(var n=Math.log(Math.pow(2,t))/Math.log(e),r=2;n===1/0;r*=2)n=Math.log(Math.pow(2,t/r))/Math.log(e)*r;var o=n-Math.floor(n),i="";for(r=0;r<Math.floor(n);r++)i=Math.floor(Math.random()*e).toString(e)+i;if(o){var a=Math.pow(e,o);i=Math.floor(Math.random()*a).toString(e)+i}var s=parseInt(i,e);return s!==1/0&&s>=Math.pow(2,t)?j(t,e):i};j.rack=function(t,e,n){var r=function(r){var i=0;do{if(i++>10){if(!n)throw new Error("too many ID collisions, use more bits");t+=n}var a=j(t,e)}while(Object.hasOwnProperty.call(o,a));return o[a]=r,a},o=r.hats={};return r.get=function(t){return r.hats[t]},r.set=function(t,e){return r.hats[t]=e,r},r.bits=t||128,r.base=e||16,r};var D=e(N.exports),R=function(t,e){this.ctx=t,this.properties=e.properties||{},this.coordinates=e.geometry.coordinates,this.id=e.id||D(),this.type=e.geometry.type};R.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},R.prototype.incomingCoords=function(t){this.setCoordinates(t)},R.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},R.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},R.prototype.setProperty=function(t,e){this.properties[t]=e},R.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:f.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},R.prototype.internal=function(t){var e={id:this.id,meta:v.FEATURE,"meta:type":this.type,active:m.INACTIVE,mode:t};if(this.ctx.options.userProperties)for(var n in this.properties)e["user_"+n]=this.properties[n];return{type:f.FEATURE,properties:e,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var k=function(t,e){R.call(this,t,e)};(k.prototype=Object.create(R.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},k.prototype.updateCoordinate=function(t,e,n){this.coordinates=3===arguments.length?[e,n]:[t,e],this.changed()},k.prototype.getCoordinate=function(){return this.getCoordinates()};var U=function(t,e){R.call(this,t,e)};(U.prototype=Object.create(R.prototype)).isValid=function(){return this.coordinates.length>1},U.prototype.addCoordinate=function(t,e,n){this.changed();var r=parseInt(t,10);this.coordinates.splice(r,0,[e,n])},U.prototype.getCoordinate=function(t){var e=parseInt(t,10);return JSON.parse(JSON.stringify(this.coordinates[e]))},U.prototype.removeCoordinate=function(t){this.changed(),this.coordinates.splice(parseInt(t,10),1)},U.prototype.updateCoordinate=function(t,e,n){var r=parseInt(t,10);this.coordinates[r]=[e,n],this.changed()};var G=function(t,e){R.call(this,t,e),this.coordinates=this.coordinates.map((function(t){return t.slice(0,-1)}))};(G.prototype=Object.create(R.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every((function(t){return t.length>2}))},G.prototype.incomingCoords=function(t){this.coordinates=t.map((function(t){return t.slice(0,-1)})),this.changed()},G.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},G.prototype.addCoordinate=function(t,e,n){this.changed();var r=t.split(".").map((function(t){return parseInt(t,10)}));this.coordinates[r[0]].splice(r[1],0,[e,n])},G.prototype.removeCoordinate=function(t){this.changed();var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];n&&(n.splice(e[1],1),n.length<3&&this.coordinates.splice(e[0],1))},G.prototype.getCoordinate=function(t){var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];return JSON.parse(JSON.stringify(n[e[1]]))},G.prototype.getCoordinates=function(){return this.coordinates.map((function(t){return t.concat([t[0]])}))},G.prototype.updateCoordinate=function(t,e,n){this.changed();var r=t.split("."),o=parseInt(r[0],10),i=parseInt(r[1],10);void 0===this.coordinates[o]&&(this.coordinates[o]=[]),this.coordinates[o][i]=[e,n]};var V={MultiPoint:k,MultiLineString:U,MultiPolygon:G},B=function(t,e,n,r,o){var i=n.split("."),a=parseInt(i[0],10),s=i[1]?i.slice(1).join("."):null;return t[a][e](s,r,o)},z=function(t,e){if(R.call(this,t,e),delete this.coordinates,this.model=V[e.geometry.type],void 0===this.model)throw new TypeError(e.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(e.geometry.coordinates)};function J(t){this.map=t.map,this.drawConfig=JSON.parse(JSON.stringify(t.options||{})),this._ctx=t}(z.prototype=Object.create(R.prototype))._coordinatesToFeatures=function(t){var e=this,n=this.model.bind(this);return t.map((function(t){return new n(e.ctx,{id:D(),type:f.FEATURE,properties:{},geometry:{coordinates:t,type:e.type.replace("Multi","")}})}))},z.prototype.isValid=function(){return this.features.every((function(t){return t.isValid()}))},z.prototype.setCoordinates=function(t){this.features=this._coordinatesToFeatures(t),this.changed()},z.prototype.getCoordinate=function(t){return B(this.features,"getCoordinate",t)},z.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map((function(t){return t.type===f.POLYGON?t.getCoordinates():t.coordinates}))))},z.prototype.updateCoordinate=function(t,e,n){B(this.features,"updateCoordinate",t,e,n),this.changed()},z.prototype.addCoordinate=function(t,e,n){B(this.features,"addCoordinate",t,e,n),this.changed()},z.prototype.removeCoordinate=function(t){B(this.features,"removeCoordinate",t),this.changed()},z.prototype.getFeatures=function(){return this.features},J.prototype.setSelected=function(t){return this._ctx.store.setSelected(t)},J.prototype.setSelectedCoordinates=function(t){var e=this;this._ctx.store.setSelectedCoordinates(t),t.reduce((function(t,n){return void 0===t[n.feature_id]&&(t[n.feature_id]=!0,e._ctx.store.get(n.feature_id).changed()),t}),{})},J.prototype.getSelected=function(){return this._ctx.store.getSelected()},J.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},J.prototype.isSelected=function(t){return this._ctx.store.isSelected(t)},J.prototype.getFeature=function(t){return this._ctx.store.get(t)},J.prototype.select=function(t){return this._ctx.store.select(t)},J.prototype.deselect=function(t){return this._ctx.store.deselect(t)},J.prototype.deleteFeature=function(t,e){return void 0===e&&(e={}),this._ctx.store.delete(t,e)},J.prototype.addFeature=function(t){return this._ctx.store.add(t)},J.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},J.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},J.prototype.setActionableState=function(t){void 0===t&&(t={});var e={trash:t.trash||!1,combineFeatures:t.combineFeatures||!1,uncombineFeatures:t.uncombineFeatures||!1};return this._ctx.events.actionable(e)},J.prototype.changeMode=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),this._ctx.events.changeMode(t,e,n)},J.prototype.updateUIClasses=function(t){return this._ctx.ui.queueMapClasses(t)},J.prototype.activateUIButton=function(t){return this._ctx.ui.setActiveButton(t)},J.prototype.featuresAt=function(t,e,n){if(void 0===n&&(n="click"),"click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return x[n](t,e,this._ctx)},J.prototype.newFeature=function(t){var e=t.geometry.type;return e===f.POINT?new k(this._ctx,t):e===f.LINE_STRING?new U(this._ctx,t):e===f.POLYGON?new G(this._ctx,t):new z(this._ctx,t)},J.prototype.isInstanceOf=function(t,e){if(t===f.POINT)return e instanceof k;if(t===f.LINE_STRING)return e instanceof U;if(t===f.POLYGON)return e instanceof G;if("MultiFeature"===t)return e instanceof z;throw new Error("Unknown feature class: "+t)},J.prototype.doRender=function(t){return this._ctx.store.featureChanged(t)},J.prototype.onSetup=function(){},J.prototype.onDrag=function(){},J.prototype.onClick=function(){},J.prototype.onMouseMove=function(){},J.prototype.onMouseDown=function(){},J.prototype.onMouseUp=function(){},J.prototype.onMouseOut=function(){},J.prototype.onKeyUp=function(){},J.prototype.onKeyDown=function(){},J.prototype.onTouchStart=function(){},J.prototype.onTouchMove=function(){},J.prototype.onTouchEnd=function(){},J.prototype.onTap=function(){},J.prototype.onStop=function(){},J.prototype.onTrash=function(){},J.prototype.onCombineFeature=function(){},J.prototype.onUncombineFeature=function(){},J.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var Z={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},H=Object.keys(Z);function $(t){var e=Object.keys(t);return function(n,r){void 0===r&&(r={});var o={},i=e.reduce((function(e,n){return e[n]=t[n],e}),new J(n));return{start:function(){var e=this;o=i.onSetup(r),H.forEach((function(n){var r,a=Z[n],s=function(){return!1};t[a]&&(s=function(){return!0}),e.on(n,s,(r=a,function(t){return i[r](o,t)}))}))},stop:function(){i.onStop(o)},trash:function(){i.onTrash(o)},combineFeatures:function(){i.onCombineFeatures(o)},uncombineFeatures:function(){i.onUncombineFeatures(o)},render:function(t,e){i.toDisplayFeatures(o,t,e)}}}}function q(t){return[].concat(t).filter((function(t){return void 0!==t}))}function Y(){var t=this;if(!t.ctx.map||void 0===t.ctx.map.getSource(l.HOT))return u();var e=t.ctx.events.currentModeName();t.ctx.ui.queueMapClasses({mode:e});var n=[],r=[];t.isDirty?r=t.getAllIds():(n=t.getChangedIds().filter((function(e){return void 0!==t.get(e)})),r=t.sources.hot.filter((function(e){return e.properties.id&&-1===n.indexOf(e.properties.id)&&void 0!==t.get(e.properties.id)})).map((function(t){return t.properties.id}))),t.sources.hot=[];var o=t.sources.cold.length;t.sources.cold=t.isDirty?[]:t.sources.cold.filter((function(t){var e=t.properties.id||t.properties.parent;return-1===n.indexOf(e)}));var i=o!==t.sources.cold.length||r.length>0;function a(n,r){var o=t.get(n).internal(e);t.ctx.events.currentModeRender(o,(function(e){t.sources[r].push(e)}))}if(n.forEach((function(t){return a(t,"hot")})),r.forEach((function(t){return a(t,"cold")})),i&&t.ctx.map.getSource(l.COLD).setData({type:f.FEATURE_COLLECTION,features:t.sources.cold}),t.ctx.map.getSource(l.HOT).setData({type:f.FEATURE_COLLECTION,features:t.sources.hot}),t._emitSelectionChange&&(t.ctx.map.fire(g.SELECTION_CHANGE,{features:t.getSelected().map((function(t){return t.toGeoJSON()})),points:t.getSelectedCoordinates().map((function(t){return{type:f.FEATURE,properties:{},geometry:{type:f.POINT,coordinates:t.coordinates}}}))}),t._emitSelectionChange=!1),t._deletedFeaturesToEmit.length){var s=t._deletedFeaturesToEmit.map((function(t){return t.toGeoJSON()}));t._deletedFeaturesToEmit=[],t.ctx.map.fire(g.DELETE,{features:s})}function u(){t.isDirty=!1,t.clearChangedIds()}u(),t.ctx.map.fire(g.RENDER,{})}function X(t){var e,n=this;this._features={},this._featureIds=new w,this._selectedFeatureIds=new w,this._selectedCoordinates=[],this._changedFeatureIds=new w,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=t,this.sources={hot:[],cold:[]},this.render=function(){e||(e=requestAnimationFrame((function(){e=null,Y.call(n)})))},this.isDirty=!1}function W(t,e){var n=t._selectedCoordinates.filter((function(e){return t._selectedFeatureIds.has(e.feature_id)}));t._selectedCoordinates.length===n.length||e.silent||(t._emitSelectionChange=!0),t._selectedCoordinates=n}X.prototype.createRenderBatch=function(){var t=this,e=this.render,n=0;return this.render=function(){n++},function(){t.render=e,n>0&&t.render()}},X.prototype.setDirty=function(){return this.isDirty=!0,this},X.prototype.featureChanged=function(t){return this._changedFeatureIds.add(t),this},X.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},X.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},X.prototype.getAllIds=function(){return this._featureIds.values()},X.prototype.add=function(t){return this.featureChanged(t.id),this._features[t.id]=t,this._featureIds.add(t.id),this},X.prototype.delete=function(t,e){var n=this;return void 0===e&&(e={}),q(t).forEach((function(t){n._featureIds.has(t)&&(n._featureIds.delete(t),n._selectedFeatureIds.delete(t),e.silent||-1===n._deletedFeaturesToEmit.indexOf(n._features[t])&&n._deletedFeaturesToEmit.push(n._features[t]),delete n._features[t],n.isDirty=!0)})),W(this,e),this},X.prototype.get=function(t){return this._features[t]},X.prototype.getAll=function(){var t=this;return Object.keys(this._features).map((function(e){return t._features[e]}))},X.prototype.select=function(t,e){var n=this;return void 0===e&&(e={}),q(t).forEach((function(t){n._selectedFeatureIds.has(t)||(n._selectedFeatureIds.add(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0))})),this},X.prototype.deselect=function(t,e){var n=this;return void 0===e&&(e={}),q(t).forEach((function(t){n._selectedFeatureIds.has(t)&&(n._selectedFeatureIds.delete(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0))})),W(this,e),this},X.prototype.clearSelected=function(t){return void 0===t&&(t={}),this.deselect(this._selectedFeatureIds.values(),{silent:t.silent}),this},X.prototype.setSelected=function(t,e){var n=this;return void 0===e&&(e={}),t=q(t),this.deselect(this._selectedFeatureIds.values().filter((function(e){return-1===t.indexOf(e)})),{silent:e.silent}),this.select(t.filter((function(t){return!n._selectedFeatureIds.has(t)})),{silent:e.silent}),this},X.prototype.setSelectedCoordinates=function(t){return this._selectedCoordinates=t,this._emitSelectionChange=!0,this},X.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},X.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},X.prototype.getSelected=function(){var t=this;return this._selectedFeatureIds.values().map((function(e){return t.get(e)}))},X.prototype.getSelectedCoordinates=function(){var t=this;return this._selectedCoordinates.map((function(e){return{coordinates:t.get(e.feature_id).getCoordinate(e.coord_path)}}))},X.prototype.isSelected=function(t){return this._selectedFeatureIds.has(t)},X.prototype.setFeatureProperty=function(t,e,n){this.get(t).setProperty(e,n),this.featureChanged(t)},X.prototype.storeMapConfig=function(){var t=this;b.forEach((function(e){t.ctx.map[e]&&(t._mapInitialConfig[e]=t.ctx.map[e].isEnabled())}))},X.prototype.restoreMapConfig=function(){var t=this;Object.keys(this._mapInitialConfig).forEach((function(e){t._mapInitialConfig[e]?t.ctx.map[e].enable():t.ctx.map[e].disable()}))},X.prototype.getInitialConfigValue=function(t){return void 0===this._mapInitialConfig[t]||this._mapInitialConfig[t]};var K=function(){for(var t=arguments,e={},n=0;n<arguments.length;n++){var r=t[n];for(var o in r)Q.call(r,o)&&(e[o]=r[o])}return e},Q=Object.prototype.hasOwnProperty,tt=e(K),et=["mode","feature","mouse"];function nt(e){var n=null,r=null,o={onRemove:function(){return e.map.off("load",o.connect),clearInterval(r),o.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,n&&n.parentNode&&n.parentNode.removeChild(n),n=null,this},connect:function(){e.map.off("load",o.connect),clearInterval(r),o.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners()},onAdd:function(i){var a=i.fire;return i.fire=function(t,e){var n=arguments;return 1===a.length&&1!==arguments.length&&(n=[tt({},{type:t},e)]),a.apply(i,n)},e.map=i,e.events=function(e){var n=Object.keys(e.options.modes).reduce((function(t,n){return t[n]=$(e.options.modes[n]),t}),{}),r={},o={},i={},a=null,s=null;i.drag=function(t,n){n({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:p.DRAG}),s.drag(t)):t.originalEvent.stopPropagation()},i.mousedrag=function(t){i.drag(t,(function(t){return!A(r,t)}))},i.touchdrag=function(t){i.drag(t,(function(t){return!F(o,t)}))},i.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return i.mousedrag(t);var n=M(t,e);t.featureTarget=n,s.mousemove(t)},i.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};var n=M(t,e);t.featureTarget=n,s.mousedown(t)},i.mouseup=function(t){var n=M(t,e);t.featureTarget=n,A(r,{point:t.point,time:(new Date).getTime()})?s.click(t):s.mouseup(t)},i.mouseout=function(t){s.mouseout(t)},i.touchstart=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled){o={time:(new Date).getTime(),point:t.point};var n=x.touch(t,null,e)[0];t.featureTarget=n,s.touchstart(t)}},i.touchmove=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled)return s.touchmove(t),i.touchdrag(t)},i.touchend=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled){var n=x.touch(t,null,e)[0];t.featureTarget=n,F(o,{time:(new Date).getTime(),point:t.point})?s.tap(t):s.touchend(t)}};var u=function(t){return!(8===t||46===t||t>=48&&t<=57)};function c(r,o,i){void 0===i&&(i={}),s.stop();var u=n[r];if(void 0===u)throw new Error(r+" is not valid");a=r;var c=u(e,o);s=t(c,e),i.silent||e.map.fire(g.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render()}i.keydown=function(t){(t.srcElement||t.target).classList.contains("mapboxgl-canvas")&&(8!==t.keyCode&&46!==t.keyCode||!e.options.controls.trash?u(t.keyCode)?s.keydown(t):49===t.keyCode&&e.options.controls.point?c(h.DRAW_POINT):50===t.keyCode&&e.options.controls.line_string?c(h.DRAW_LINE_STRING):51===t.keyCode&&e.options.controls.polygon&&c(h.DRAW_POLYGON):(t.preventDefault(),s.trash()))},i.keyup=function(t){u(t.keyCode)&&s.keyup(t)},i.zoomend=function(){e.store.changeZoom()},i.data=function(t){if("style"===t.dataType){var n=e.setup,r=e.map,o=e.options,i=e.store;o.styles.some((function(t){return r.getLayer(t.id)}))||(n.addLayers(),i.setDirty(),i.render())}};var l={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start:function(){a=e.options.defaultMode,s=t(n[a](e),e)},changeMode:c,actionable:function(t){var n=!1;Object.keys(t).forEach((function(e){if(void 0===l[e])throw new Error("Invalid action type");l[e]!==t[e]&&(n=!0),l[e]=t[e]})),n&&e.map.fire(g.ACTIONABLE,{actions:l})},currentModeName:function(){return a},currentModeRender:function(t,e){return s.render(t,e)},fire:function(t,e){i[t]&&i[t](e)},addEventListeners:function(){e.map.on("mousemove",i.mousemove),e.map.on("mousedown",i.mousedown),e.map.on("mouseup",i.mouseup),e.map.on("data",i.data),e.map.on("touchmove",i.touchmove),e.map.on("touchstart",i.touchstart),e.map.on("touchend",i.touchend),e.container.addEventListener("mouseout",i.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",i.keydown),e.container.addEventListener("keyup",i.keyup))},removeEventListeners:function(){e.map.off("mousemove",i.mousemove),e.map.off("mousedown",i.mousedown),e.map.off("mouseup",i.mouseup),e.map.off("data",i.data),e.map.off("touchmove",i.touchmove),e.map.off("touchstart",i.touchstart),e.map.off("touchend",i.touchend),e.container.removeEventListener("mouseout",i.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",i.keydown),e.container.removeEventListener("keyup",i.keyup))},trash:function(t){s.trash(t)},combineFeatures:function(){s.combineFeatures()},uncombineFeatures:function(){s.uncombineFeatures()},getMode:function(){return a}}}(e),e.ui=function(t){var e={},n=null,r={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function i(t){o=tt(o,t)}function a(){var e,n;if(t.container){var i=[],a=[];et.forEach((function(t){o[t]!==r[t]&&(i.push(t+"-"+r[t]),null!==o[t]&&a.push(t+"-"+o[t]))})),i.length>0&&(e=t.container.classList).remove.apply(e,i),a.length>0&&(n=t.container.classList).add.apply(n,a),r=tt(r,o)}}function s(t,e){void 0===e&&(e={});var r=document.createElement("button");return r.className=c.CONTROL_BUTTON+" "+e.className,r.setAttribute("title",e.title),e.container.appendChild(r),r.addEventListener("click",(function(r){if(r.preventDefault(),r.stopPropagation(),r.target===n)return u(),void e.onDeactivate();l(t),e.onActivate()}),!0),r}function u(){n&&(n.classList.remove(c.ACTIVE_BUTTON),n=null)}function l(t){u();var r=e[t];r&&r&&"trash"!==t&&(r.classList.add(c.ACTIVE_BUTTON),n=r)}return{setActiveButton:l,queueMapClasses:i,updateMapClasses:a,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),a()},addButtons:function(){var n=t.options.controls,r=document.createElement("div");return r.className=c.CONTROL_GROUP+" "+c.CONTROL_BASE,n?(n[d.LINE]&&(e[d.LINE]=s(d.LINE,{container:r,className:c.CONTROL_BUTTON_LINE,title:"LineString tool "+(t.options.keybindings?"(l)":""),onActivate:function(){return t.events.changeMode(h.DRAW_LINE_STRING)},onDeactivate:function(){return t.events.trash()}})),n[d.POLYGON]&&(e[d.POLYGON]=s(d.POLYGON,{container:r,className:c.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(t.options.keybindings?"(p)":""),onActivate:function(){return t.events.changeMode(h.DRAW_POLYGON)},onDeactivate:function(){return t.events.trash()}})),n[d.POINT]&&(e[d.POINT]=s(d.POINT,{container:r,className:c.CONTROL_BUTTON_POINT,title:"Marker tool "+(t.options.keybindings?"(m)":""),onActivate:function(){return t.events.changeMode(h.DRAW_POINT)},onDeactivate:function(){return t.events.trash()}})),n.trash&&(e.trash=s("trash",{container:r,className:c.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:function(){t.events.trash()}})),n.combine_features&&(e.combine_features=s("combineFeatures",{container:r,className:c.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:function(){t.events.combineFeatures()}})),n.uncombine_features&&(e.uncombine_features=s("uncombineFeatures",{container:r,className:c.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:function(){t.events.uncombineFeatures()}})),r):r},removeButtons:function(){Object.keys(e).forEach((function(t){var n=e[t];n.parentNode&&n.parentNode.removeChild(n),delete e[t]}))}}}(e),e.container=i.getContainer(),e.store=new X(e),n=e.ui.addButtons(),e.options.boxSelect&&(e.boxZoomInitial=i.boxZoom.isEnabled(),i.boxZoom.disable(),i.dragPan.disable(),i.dragPan.enable()),i.loaded()?o.connect():(i.on("load",o.connect),r=setInterval((function(){i.loaded()&&o.connect()}),16)),e.events.start(),n},addLayers:function(){e.map.addSource(l.COLD,{data:{type:f.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(l.HOT,{data:{type:f.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach((function(t){e.map.addLayer(t)})),e.store.setDirty(!0),e.store.render()},removeLayers:function(){e.options.styles.forEach((function(t){e.map.getLayer(t.id)&&e.map.removeLayer(t.id)})),e.map.getSource(l.COLD)&&e.map.removeSource(l.COLD),e.map.getSource(l.HOT)&&e.map.removeSource(l.HOT)}};return e.setup=o,o}var rt=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}];function ot(t){return function(e){var n=e.featureTarget;return!!n&&!!n.properties&&n.properties.meta===t}}function it(t){return!!t.originalEvent&&!!t.originalEvent.shiftKey&&0===t.originalEvent.button}function at(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.active===m.ACTIVE&&t.featureTarget.properties.meta===v.FEATURE}function st(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.active===m.INACTIVE&&t.featureTarget.properties.meta===v.FEATURE}function ut(t){return void 0===t.featureTarget}function ct(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.meta===v.FEATURE}function lt(t){var e=t.featureTarget;return!!e&&!!e.properties&&e.properties.meta===v.VERTEX}function pt(t){return!!t.originalEvent&&!0===t.originalEvent.shiftKey}function dt(t){return 27===t.keyCode}function ft(t){return 13===t.keyCode}var ht=Object.freeze({__proto__:null,isOfMetaType:ot,isShiftMousedown:it,isActiveFeature:at,isInactiveFeature:st,noTarget:ut,isFeature:ct,isVertex:lt,isShiftDown:pt,isEscapeKey:dt,isEnterKey:ft,isTrue:function(){return!0}}),gt=yt;function yt(t,e){this.x=t,this.y=e}yt.prototype={clone:function(){return new yt(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),r=e*this.x-n*this.y,o=n*this.x+e*this.y;return this.x=r,this.y=o,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),o=e.x+n*(this.x-e.x)-r*(this.y-e.y),i=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=o,this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},yt.convert=function(t){return t instanceof yt?t:Array.isArray(t)?new yt(t[0],t[1]):t};var vt=e(gt);function mt(t,e){var n=e.getBoundingClientRect();return new vt(t.clientX-n.left-(e.clientLeft||0),t.clientY-n.top-(e.clientTop||0))}function bt(t,e,n,r){return{type:f.FEATURE,properties:{meta:v.VERTEX,parent:t,coord_path:n,active:r?m.ACTIVE:m.INACTIVE},geometry:{type:f.POINT,coordinates:e}}}function Et(t,e,n){var r=e.geometry.coordinates,o=n.geometry.coordinates;if(r[1]>85||r[1]<E||o[1]>85||o[1]<E)return null;var i={lng:(r[0]+o[0])/2,lat:(r[1]+o[1])/2};return{type:f.FEATURE,properties:{meta:v.MIDPOINT,parent:t,lng:i.lng,lat:i.lat,coord_path:n.properties.coord_path},geometry:{type:f.POINT,coordinates:[i.lng,i.lat]}}}function _t(t,e,n){void 0===e&&(e={}),void 0===n&&(n=null);var r,o=t.geometry,i=o.type,a=o.coordinates,s=t.properties&&t.properties.id,u=[];function c(t,n){var r="",o=null;t.forEach((function(t,i){var a=null!=n?n+"."+i:String(i),c=bt(s,t,a,l(a));if(e.midpoints&&o){var p=Et(s,o,c);p&&u.push(p)}o=c;var d=JSON.stringify(t);r!==d&&u.push(c),0===i&&(r=d)}))}function l(t){return!!e.selectedPaths&&-1!==e.selectedPaths.indexOf(t)}return i===f.POINT?u.push(bt(s,a,n,l(n))):i===f.POLYGON?a.forEach((function(t,e){c(t,null!==n?n+"."+e:String(e))})):i===f.LINE_STRING?c(a,n):0===i.indexOf(f.MULTI_PREFIX)&&(r=i.replace(f.MULTI_PREFIX,""),a.forEach((function(n,o){var i={type:f.FEATURE,properties:t.properties,geometry:{type:r,coordinates:n}};u=u.concat(_t(i,e,o))}))),u}var Ot={enable:function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable()}),0)},disable:function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable()}),0)}},St={exports:{}},It=function(t){if(!t||!t.type)return null;var e=Ct[t.type];return e?"geometry"===e?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:t}]}:"feature"===e?{type:"FeatureCollection",features:[t]}:"featurecollection"===e?t:void 0:null},Ct={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"},wt=e(It),Tt=Object.freeze({__proto__:null,default:function t(e){switch(e&&e.type||null){case"FeatureCollection":return e.features=e.features.reduce((function(e,n){return e.concat(t(n))}),[]),e;case"Feature":return e.geometry?t(e.geometry).map((function(t){var n={type:"Feature",properties:JSON.parse(JSON.stringify(e.properties)),geometry:t};return void 0!==e.id&&(n.id=e.id),n})):[e];case"MultiPoint":return e.coordinates.map((function(t){return{type:"Point",coordinates:t}}));case"MultiPolygon":return e.coordinates.map((function(t){return{type:"Polygon",coordinates:t}}));case"MultiLineString":return e.coordinates.map((function(t){return{type:"LineString",coordinates:t}}));case"GeometryCollection":return e.geometries.map(t).reduce((function(t,e){return t.concat(e)}),[]);case"Point":case"Polygon":case"LineString":return[e]}}}),xt=It,Pt=r(Tt),Mt=function(t){return function t(e){return Array.isArray(e)&&e.length&&"number"==typeof e[0]?[e]:e.reduce((function(e,n){return Array.isArray(n)&&Array.isArray(n[0])?e.concat(t(n)):(e.push(n),e)}),[])}(t)};Pt instanceof Function||(Pt=Pt.default);var Lt={exports:{}},At=Lt.exports=function(t){return new Ft(t)};function Ft(t){this.value=t}function Nt(t,e,n){var r=[],o=[],i=!0;return function t(a){var s=n?jt(a):a,u={},c=!0,l={node:s,node_:a,path:[].concat(r),parent:o[o.length-1],parents:o,key:r.slice(-1)[0],isRoot:0===r.length,level:r.length,circular:null,update:function(t,e){l.isRoot||(l.parent.node[l.key]=t),l.node=t,e&&(c=!1)},delete:function(t){delete l.parent.node[l.key],t&&(c=!1)},remove:function(t){kt(l.parent.node)?l.parent.node.splice(l.key,1):delete l.parent.node[l.key],t&&(c=!1)},keys:null,before:function(t){u.before=t},after:function(t){u.after=t},pre:function(t){u.pre=t},post:function(t){u.post=t},stop:function(){i=!1},block:function(){c=!1}};if(!i)return l;function p(){if("object"==typeof l.node&&null!==l.node){l.keys&&l.node_===l.node||(l.keys=Dt(l.node)),l.isLeaf=0==l.keys.length;for(var t=0;t<o.length;t++)if(o[t].node_===a){l.circular=o[t];break}}else l.isLeaf=!0,l.keys=null;l.notLeaf=!l.isLeaf,l.notRoot=!l.isRoot}p();var d=e.call(l,l.node);return void 0!==d&&l.update&&l.update(d),u.before&&u.before.call(l,l.node),c?("object"!=typeof l.node||null===l.node||l.circular||(o.push(l),p(),Ut(l.keys,(function(e,o){r.push(e),u.pre&&u.pre.call(l,l.node[e],e);var i=t(l.node[e]);n&&Gt.call(l.node,e)&&(l.node[e]=i.node),i.isLast=o==l.keys.length-1,i.isFirst=0==o,u.post&&u.post.call(l,i),r.pop()})),o.pop()),u.after&&u.after.call(l,l.node),l):l}(t).node}function jt(t){if("object"==typeof t&&null!==t){var e;if(kt(t))e=[];else if("[object Date]"===Rt(t))e=new Date(t.getTime?t.getTime():t);else if(function(t){return"[object RegExp]"===Rt(t)}(t))e=new RegExp(t);else if(function(t){return"[object Error]"===Rt(t)}(t))e={message:t.message};else if(function(t){return"[object Boolean]"===Rt(t)}(t))e=new Boolean(t);else if(function(t){return"[object Number]"===Rt(t)}(t))e=new Number(t);else if(function(t){return"[object String]"===Rt(t)}(t))e=new String(t);else if(Object.create&&Object.getPrototypeOf)e=Object.create(Object.getPrototypeOf(t));else if(t.constructor===Object)e={};else{var n=t.constructor&&t.constructor.prototype||t.__proto__||{},r=function(){};r.prototype=n,e=new r}return Ut(Dt(t),(function(n){e[n]=t[n]})),e}return t}Ft.prototype.get=function(t){for(var e=this.value,n=0;n<t.length;n++){var r=t[n];if(!e||!Gt.call(e,r)){e=void 0;break}e=e[r]}return e},Ft.prototype.has=function(t){for(var e=this.value,n=0;n<t.length;n++){var r=t[n];if(!e||!Gt.call(e,r))return!1;e=e[r]}return!0},Ft.prototype.set=function(t,e){for(var n=this.value,r=0;r<t.length-1;r++){var o=t[r];Gt.call(n,o)||(n[o]={}),n=n[o]}return n[t[r]]=e,e},Ft.prototype.map=function(t){return Nt(this.value,t,!0)},Ft.prototype.forEach=function(t){return this.value=Nt(this.value,t,!1),this.value},Ft.prototype.reduce=function(t,e){var n=1===arguments.length,r=n?this.value:e;return this.forEach((function(e){this.isRoot&&n||(r=t.call(this,r,e))})),r},Ft.prototype.paths=function(){var t=[];return this.forEach((function(e){t.push(this.path)})),t},Ft.prototype.nodes=function(){var t=[];return this.forEach((function(e){t.push(this.node)})),t},Ft.prototype.clone=function(){var t=[],e=[];return function n(r){for(var o=0;o<t.length;o++)if(t[o]===r)return e[o];if("object"==typeof r&&null!==r){var i=jt(r);return t.push(r),e.push(i),Ut(Dt(r),(function(t){i[t]=n(r[t])})),t.pop(),e.pop(),i}return r}(this.value)};var Dt=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};function Rt(t){return Object.prototype.toString.call(t)}var kt=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Ut=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n<t.length;n++)e(t[n],n,t)};Ut(Dt(Ft.prototype),(function(t){At[t]=function(e){var n=[].slice.call(arguments,1),r=new Ft(e);return r[t].apply(r,n)}}));var Gt=Object.hasOwnProperty||function(t,e){return e in t},Vt=Lt.exports,Bt=zt;function zt(t){if(!(this instanceof zt))return new zt(t);this._bbox=t||[1/0,1/0,-1/0,-1/0],this._valid=!!t}zt.prototype.include=function(t){return this._valid=!0,this._bbox[0]=Math.min(this._bbox[0],t[0]),this._bbox[1]=Math.min(this._bbox[1],t[1]),this._bbox[2]=Math.max(this._bbox[2],t[0]),this._bbox[3]=Math.max(this._bbox[3],t[1]),this},zt.prototype.equals=function(t){var e;return e=t instanceof zt?t.bbox():t,this._bbox[0]==e[0]&&this._bbox[1]==e[1]&&this._bbox[2]==e[2]&&this._bbox[3]==e[3]},zt.prototype.center=function(t){return this._valid?[(this._bbox[0]+this._bbox[2])/2,(this._bbox[1]+this._bbox[3])/2]:null},zt.prototype.union=function(t){var e;return this._valid=!0,e=t instanceof zt?t.bbox():t,this._bbox[0]=Math.min(this._bbox[0],e[0]),this._bbox[1]=Math.min(this._bbox[1],e[1]),this._bbox[2]=Math.max(this._bbox[2],e[2]),this._bbox[3]=Math.max(this._bbox[3],e[3]),this},zt.prototype.bbox=function(){return this._valid?this._bbox:null},zt.prototype.contains=function(t){if(!t)return this._fastContains();if(!this._valid)return null;var e=t[0],n=t[1];return this._bbox[0]<=e&&this._bbox[1]<=n&&this._bbox[2]>=e&&this._bbox[3]>=n},zt.prototype.intersect=function(t){return this._valid?(e=t instanceof zt?t.bbox():t,!(this._bbox[0]>e[2]||this._bbox[2]<e[0]||this._bbox[3]<e[1]||this._bbox[1]>e[3])):null;var e},zt.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var t="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",t)},zt.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var Jt=function(t){if(!t)return[];var e=Pt(xt(t)),n=[];return e.features.forEach((function(t){t.geometry&&(n=n.concat(Mt(t.geometry.coordinates)))})),n},Zt=Vt,Ht=Bt,$t={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},qt=Object.keys($t);function Yt(t){for(var e=Ht(),n=Jt(t),r=0;r<n.length;r++)e.include(n[r]);return e}St.exports=function(t){return Yt(t).bbox()},St.exports.polygon=function(t){return Yt(t).polygon()},St.exports.bboxify=function(t){return Zt(t).map((function(t){t&&qt.some((function(e){return!!t[e]&&-1!==$t[e].indexOf(t.type)}))&&(t.bbox=Yt(t).bbox(),this.update(t))}))};var Xt=e(St.exports),Wt=-90;function Kt(t,e){var n=Wt,r=90,o=Wt,i=90,a=270,s=-270;t.forEach((function(t){var e=Xt(t),u=e[1],c=e[3],l=e[0],p=e[2];u>n&&(n=u),c<r&&(r=c),c>o&&(o=c),u<i&&(i=u),l<a&&(a=l),p>s&&(s=p)}));var u=e;return n+u.lat>85&&(u.lat=85-n),o+u.lat>90&&(u.lat=90-o),r+u.lat<-85&&(u.lat=-85-r),i+u.lat<Wt&&(u.lat=Wt-i),a+u.lng<=-270&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=270&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function Qt(t,e){var n=Kt(t.map((function(t){return t.toGeoJSON()})),e);t.forEach((function(t){var e,r=t.getCoordinates(),o=function(t){var e={lng:t[0]+n.lng,lat:t[1]+n.lat};return[e.lng,e.lat]},i=function(t){return t.map((function(t){return o(t)}))};t.type===f.POINT?e=o(r):t.type===f.LINE_STRING||t.type===f.MULTI_POINT?e=r.map(o):t.type===f.POLYGON||t.type===f.MULTI_LINE_STRING?e=r.map(i):t.type===f.MULTI_POLYGON&&(e=r.map((function(t){return t.map((function(t){return i(t)}))}))),t.incomingCoords(e)}))}var te={onSetup:function(t){var e=this,n={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:t.featureIds||[]};return this.setSelected(n.initiallySelectedFeatureIds.filter((function(t){return void 0!==e.getFeature(t)}))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),n},fireUpdate:function(){this.map.fire(g.UPDATE,{action:y.MOVE,features:this.getSelected().map((function(t){return t.toGeoJSON()}))})},fireActionable:function(){var t=this,e=this.getSelected(),n=e.filter((function(e){return t.isInstanceOf("MultiFeature",e)})),r=!1;if(e.length>1){r=!0;var o=e[0].type.replace("Multi","");e.forEach((function(t){t.type.replace("Multi","")!==o&&(r=!1)}))}var i=n.length>0,a=e.length>0;this.setActionableState({combineFeatures:r,uncombineFeatures:i,trash:a})},getUniqueIds:function(t){return t.length?t.map((function(t){return t.properties.id})).filter((function(t){return void 0!==t})).reduce((function(t,e){return t.add(e),t}),new w).values():[]},stopExtendedInteractions:function(t){t.boxSelectElement&&(t.boxSelectElement.parentNode&&t.boxSelectElement.parentNode.removeChild(t.boxSelectElement),t.boxSelectElement=null),this.map.dragPan.enable(),t.boxSelecting=!1,t.canBoxSelect=!1,t.dragMoving=!1,t.canDragMove=!1},onStop:function(){Ot.enable(this)},onMouseMove:function(t,e){return ct(e)&&t.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(t),!0},onMouseOut:function(t){return!t.dragMoving||this.fireUpdate()}};te.onTap=te.onClick=function(t,e){return ut(e)?this.clickAnywhere(t,e):ot(v.VERTEX)(e)?this.clickOnVertex(t,e):ct(e)?this.clickOnFeature(t,e):void 0},te.clickAnywhere=function(t){var e=this,n=this.getSelectedIds();n.length&&(this.clearSelectedFeatures(),n.forEach((function(t){return e.doRender(t)}))),Ot.enable(this),this.stopExtendedInteractions(t)},te.clickOnVertex=function(t,e){this.changeMode(h.DIRECT_SELECT,{featureId:e.featureTarget.properties.pare