(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a){return a(o,!0)}if(i){return i(o,!0)}var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o=this.MIN_VERTEX-1){commit=true}}else if(index===0&&this._drawing===L.Editable.BACKWARD&&this._drawnLatLngs.length>=this.MIN_VERTEX){commit=true}else if(index===0&&this._drawing===L.Editable.FORWARD&&this._drawnLatLngs.length>=this.MIN_VERTEX&&this.CLOSED){commit=true;}else{this.onVertexRawMarkerClick(e)}this.fireAndForward('editable:vertex:clicked',e);if(commit){this.commitDrawing(e)}},onVertexRawMarkerClick:function(e){this.fireAndForward('editable:vertex:rawclick',e);if(e._cancelled){return}if(!this.vertexCanBeDeleted(e.vertex)){return}e.vertex.delete()},vertexCanBeDeleted:function(vertex){return vertex.latlngs.length>this.MIN_VERTEX},onVertexDeleted:function(e){this.fireAndForward('editable:vertex:deleted',e)},onVertexMarkerCtrlClick:function(e){this.fireAndForward('editable:vertex:ctrlclick',e)},onVertexMarkerShiftClick:function(e){this.fireAndForward('editable:vertex:shiftclick',e)},onVertexMarkerMetaKeyClick:function(e){this.fireAndForward('editable:vertex:metakeyclick',e)},onVertexMarkerAltClick:function(e){this.fireAndForward('editable:vertex:altclick',e)},onVertexMarkerContextMenu:function(e){this.fireAndForward('editable:vertex:contextmenu',e)},onVertexMarkerMouseDown:function(e){this.fireAndForward('editable:vertex:mousedown',e)},onMiddleMarkerMouseDown:function(e){this.fireAndForward('editable:middlemarker:mousedown',e)},onVertexMarkerDrag:function(e){this.onMove(e);if(this.feature._bounds){this.extendBounds(e)}this.fireAndForward('editable:vertex:drag',e)},onVertexMarkerDragStart:function(e){this.fireAndForward('editable:vertex:dragstart',e)},onVertexMarkerDragEnd:function(e){this.fireAndForward('editable:vertex:dragend',e)},setDrawnLatLngs:function(latlngs){this._drawnLatLngs=latlngs||this.getDefaultLatLngs()},startDrawing:function(){if(!this._drawnLatLngs){this.setDrawnLatLngs()}L.Editable.BaseEditor.prototype.startDrawing.call(this)},startDrawingForward:function(){this.startDrawing()},endDrawing:function(){this.tools.detachForwardLineGuide();this.tools.detachBackwardLineGuide();if(this._drawnLatLngs&&this._drawnLatLngs.length0){this.tools.attachBackwardLineGuide();this.tools.anchorBackwardLineGuide(latlngs[0])}this.startDrawingBackward()},continueForward:function(latlngs){if(this.drawing()){return}latlngs=latlngs||this.getDefaultLatLngs();this.setDrawnLatLngs(latlngs);if(latlngs.length>0){this.tools.attachForwardLineGuide();this.tools.anchorForwardLineGuide(latlngs[latlngs.length-1])}this.startDrawingForward()},getDefaultLatLngs:function(latlngs){latlngs=latlngs||this.feature._latlngs;if(!latlngs.length||latlngs[0]instanceof L.LatLng){return latlngs}else{return this.getDefaultLatLngs(latlngs[0])}},ensureMulti:function(){if(this.feature._latlngs.length&&isFlat(this.feature._latlngs)){this.feature._latlngs=[this.feature._latlngs]}},addNewEmptyShape:function(){if(this.feature._latlngs.length){var shape=[];this.appendShape(shape);return shape}else{return this.feature._latlngs}},formatShape:function(shape){if(isFlat(shape)){return shape}else if(shape[0]){return this.formatShape(shape[0])}},splitShape:function(shape,index){if(!index||index>=shape.length-1){return}this.ensureMulti();var shapeIndex=this.feature._latlngs.indexOf(shape);if(shapeIndex===-1){return}var first=shape.slice(0,index+1),second=shape.slice(index);second[0]=L.latLng(second[0].lat,second[0].lng,second[0].alt);this.feature._latlngs.splice(shapeIndex,1,first,second);this.refresh();this.reset()}});L.Editable.PolygonEditor=L.Editable.PathEditor.extend({CLOSED:true,MIN_VERTEX:3,newPointForward:function(latlng){L.Editable.PathEditor.prototype.newPointForward.call(this,latlng);if(!this.tools.backwardLineGuide._latlngs.length){this.tools.anchorBackwardLineGuide(latlng)}if(this._drawnLatLngs.length===2){this.tools.attachBackwardLineGuide()}},addNewEmptyHole:function(latlng){this.ensureNotFlat();var latlngs=this.feature.shapeAt(latlng);if(!latlngs){return}var holes=[];latlngs.push(holes);return holes},newHole:function(latlng){var holes=this.addNewEmptyHole(latlng);if(!holes){return}this.setDrawnLatLngs(holes);this.startDrawingForward();if(latlng){this.newPointForward(latlng)}},addNewEmptyShape:function(){if(this.feature._latlngs.length&&this.feature._latlngs[0].length){var shape=[];this.appendShape(shape);return shape}else{return this.feature._latlngs}},ensureMulti:function(){if(this.feature._latlngs.length&&isFlat(this.feature._latlngs[0])){this.feature._latlngs=[this.feature._latlngs]}},ensureNotFlat:function(){if(!this.feature._latlngs.length||isFlat(this.feature._latlngs)){this.feature._latlngs=[this.feature._latlngs]}},vertexCanBeDeleted:function(vertex){var parent=this.feature.parentShape(vertex.latlngs),idx=L.Util.indexOf(parent,vertex.latlngs);if(idx>0){return true;}return L.Editable.PathEditor.prototype.vertexCanBeDeleted.call(this,vertex)},getDefaultLatLngs:function(){if(!this.feature._latlngs.length){this.feature._latlngs.push([])}return this.feature._latlngs[0]},formatShape:function(shape){if(isFlat(shape)&&(!shape[0]||shape[0].length!==0)){return[shape]}else{return shape}}});L.Editable.RectangleEditor=L.Editable.PathEditor.extend({CLOSED:true,MIN_VERTEX:4,options:{skipMiddleMarkers:true},extendBounds:function(e){var index=e.vertex.getIndex(),next=e.vertex.getNext(),previous=e.vertex.getPrevious(),oppositeIndex=(index+2)%4,opposite=e.vertex.latlngs[oppositeIndex],bounds=new L.LatLngBounds(e.latlng,opposite);previous.latlng.update([e.latlng.lat,opposite.lng]);next.latlng.update([opposite.lat,e.latlng.lng]);this.updateBounds(bounds);this.refreshVertexMarkers()},onDrawingMouseDown:function(e){L.Editable.PathEditor.prototype.onDrawingMouseDown.call(this,e);this.connect();var latlngs=this.getDefaultLatLngs();if(latlngs.length===3){latlngs.push(e.latlng)}var bounds=new L.LatLngBounds(e.latlng,e.latlng);this.updateBounds(bounds);this.updateLatLngs(bounds);this.refresh();this.reset();e.originalEvent._simulated=false;this.map.dragging._draggable._onUp(e.originalEvent);latlngs[3].__vertex.dragging._draggable._onDown(e.originalEvent)},onDrawingMouseUp:function(e){this.commitDrawing(e);e.originalEvent._simulated=false;L.Editable.PathEditor.prototype.onDrawingMouseUp.call(this,e)},onDrawingMouseMove:function(e){e.originalEvent._simulated=false;L.Editable.PathEditor.prototype.onDrawingMouseMove.call(this,e)},getDefaultLatLngs:function(latlngs){return latlngs||this.feature._latlngs[0]},updateBounds:function(bounds){this.feature._bounds=bounds},updateLatLngs:function(bounds){var latlngs=this.getDefaultLatLngs(),newLatlngs=this.feature._boundsToLatLngs(bounds);for(var i=0;il.lat)!==(l2.lat>l.lat))&&(l.lng<(l2.lng-l1.lng)*(l.lat-l1.lat)/(l2.lat-l1.lat)+l1.lng)){inside=!inside}}return inside},parentShape:function(shape,latlngs){latlngs=latlngs||this._latlngs;if(!latlngs){return}var idx=L.Util.indexOf(latlngs,shape);if(idx!==-1){return latlngs}for(var i=0;i