0&&m>p)){l=c,u=h;continue}a[o++]=l,a[o++]=u,s=l,A=u,l=c,u=h}}return a[o++]=l,a[o++]=u,o}function hQ(r,e,t,n,i,a,o,s){for(var A=0,l=t.length;A 0;)p--}i(r[t],h)===0?$d(r,t,p):(p++,$d(r,p,n)),p<=e&&(t=p+1),e<=p&&(n=p-1)}}function $d(r,e,t){var n=r[e];r[e]=r[t],r[t]=n}function U3(r,e){return r 0&&m>p)){l=c,u=h;continue}a[o++]=l,a[o++]=u,s=l,A=u,l=c,u=h}}return a[o++]=l,a[o++]=u,o}function hQ(r,e,t,n,i,a,o,s){for(var A=0,l=t.length;AB&&(l=(u+c)/2,rF(r,e,t,n,l,p)&&(E=l,B=L)),u=c}return isNaN(E)&&(E=i[a]),o?(o.push(E,p,B),o):[E,p,B]}function dQ(r,e,t,n,i){for(var a=[],o=0,s=t.length;o=i[0]&&a[2]<=i[2]||a[1]>=i[1]&&a[3]<=i[3]?!0:vQ(r,e,t,n,function(o,s){return H6(i,o,s)}):!1}function FW(r,e,t,n,i){for(var a=0,o=t.length;a1&&typeof arguments[n-1]=="function"&&(i=arguments[n-1],--n);for(var a=0;a0},e.prototype.refresh=function(){this.clear(!0),this.loadedExtentsRtree_.clear(),r.prototype.refresh.call(this)},e.prototype.removeLoadedExtent=function(t){var n=this.loadedExtentsRtree_,i;n.forEachInExtent(t,function(a){if(AA(a.extent,t))return i=a,!0}),i&&n.remove(i)},e.prototype.removeFeature=function(t){if(t){var n=pe(t);n in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[n]:this.featuresRtree_&&this.featuresRtree_.remove(t);var i=this.removeFeatureInternal(t);i&&this.changed()}},e.prototype.removeFeatureInternal=function(t){var n=pe(t),i=this.featureChangeKeys_[n];if(i){i.forEach(Rr),delete this.featureChangeKeys_[n];var a=t.getId();return a!==void 0&&delete this.idIndex_[a.toString()],delete this.uidIndex_[n],this.dispatchEvent(new Yl(Oi.REMOVEFEATURE,t)),t}},e.prototype.removeFromIdIndex_=function(t){var n=!1;for(var i in this.idIndex_)if(this.idIndex_[i]===t){delete this.idIndex_[i],n=!0;break}return n},e.prototype.setLoader=function(t){this.loader_=t},e.prototype.setUrl=function(t){_e(this.format_,7),this.url_=t,this.setLoader(IM(t,this.format_))},e}(ow),_l=hJ,ZQ=globalThis&&globalThis.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),xr={POINT:"Point",LINE_STRING:"LineString",POLYGON:"Polygon",CIRCLE:"Circle"},Fm={DRAWSTART:"drawstart",DRAWEND:"drawend",DRAWABORT:"drawabort"},Lm=function(r){ZQ(e,r);function e(t,n){var i=r.call(this,t)||this;return i.feature=n,i}return e}(fo),fJ=function(r){ZQ(e,r);function e(t){var n=this,i=t;i.stopDown||(i.stopDown=Ch),n=r.call(this,i)||this,n.on,n.once,n.un,n.shouldHandle_=!1,n.downPx_=null,n.downTimeout_,n.lastDragTime_,n.pointerType_,n.freehand_=!1,n.source_=t.source?t.source:null,n.features_=t.features?t.features:null,n.snapTolerance_=t.snapTolerance?t.snapTolerance:12,n.type_=t.type,n.mode_=dJ(n.type_),n.stopClick_=!!t.stopClick,n.minPoints_=t.minPoints?t.minPoints:n.mode_===xr.POLYGON?3:2,n.maxPoints_=n.mode_===xr.CIRCLE?2:t.maxPoints?t.maxPoints:1/0,n.finishCondition_=t.finishCondition?t.finishCondition:iA;var a=t.geometryFunction;if(!a){var o=n.mode_;if(o===xr.CIRCLE)a=function(A,l,u){var c=l||new uF([NaN,NaN]),h=Tn(A[0]),f=el(h,Tn(A[A.length-1]));return c.setCenterAndRadius(h,Math.sqrt(f)),c};else{var s;o===xr.POINT?s=fr:o===xr.LINE_STRING?s=Hr:o===xr.POLYGON&&(s=bn),a=function(A,l,u){return l?o===xr.POLYGON?A[0].length?l.setCoordinates([A[0].concat([A[0][0]])]):l.setCoordinates([]):l.setCoordinates(A):l=new s(A),l}}}return n.geometryFunction_=a,n.dragVertexDelay_=t.dragVertexDelay!==void 0?t.dragVertexDelay:500,n.finishCoordinate_=null,n.sketchFeature_=null,n.sketchPoint_=null,n.sketchCoords_=null,n.sketchLine_=null,n.sketchLineCoords_=null,n.squaredClickTolerance_=t.clickTolerance?t.clickTolerance*t.clickTolerance:36,n.overlay_=new hA({source:new _l({useSpatialIndex:!1,wrapX:t.wrapX?t.wrapX:!1}),style:t.style?t.style:pJ(),updateWhileInteracting:!0}),n.geometryName_=t.geometryName,n.condition_=t.condition?t.condition:iw,n.freehandCondition_,t.freehand?n.freehandCondition_=rw:n.freehandCondition_=t.freehandCondition?t.freehandCondition:Jg,n.addChangeListener(qT.ACTIVE,n.updateState_),n}return e.prototype.setMap=function(t){r.prototype.setMap.call(this,t),this.updateState_()},e.prototype.getOverlay=function(){return this.overlay_},e.prototype.handleEvent=function(t){t.originalEvent.type===ye.CONTEXTMENU&&t.originalEvent.preventDefault(),this.freehand_=this.mode_!==xr.POINT&&this.freehandCondition_(t);var n=t.type===ar.POINTERMOVE,i=!0;if(!this.freehand_&&this.lastDragTime_&&t.type===ar.POINTERDRAG){var a=Date.now();a-this.lastDragTime_>=this.dragVertexDelay_?(this.downPx_=t.pixel,this.shouldHandle_=!this.freehand_,n=!0):this.lastDragTime_=void 0,this.shouldHandle_&&this.downTimeout_!==void 0&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0)}return this.freehand_&&t.type===ar.POINTERDRAG&&this.sketchFeature_!==null?(this.addToDrawing_(t.coordinate),i=!1):this.freehand_&&t.type===ar.POINTERDOWN?i=!1:n&&this.getPointerCount()<2?(i=t.type===ar.POINTERMOVE,i&&this.freehand_?(this.handlePointerMove_(t),this.shouldHandle_&&t.originalEvent.preventDefault()):(t.originalEvent.pointerType==="mouse"||t.type===ar.POINTERDRAG&&this.downTimeout_===void 0)&&this.handlePointerMove_(t)):t.type===ar.DBLCLICK&&(i=!1),r.prototype.handleEvent.call(this,t)&&i},e.prototype.handleDownEvent=function(t){return this.shouldHandle_=!this.freehand_,this.freehand_?(this.downPx_=t.pixel,this.finishCoordinate_||this.startDrawing_(t.coordinate),!0):this.condition_(t)?(this.lastDragTime_=Date.now(),this.downTimeout_=setTimeout(function(){this.handlePointerMove_(new KA(ar.POINTERMOVE,t.map,t.originalEvent,!1,t.frameState))}.bind(this),this.dragVertexDelay_),this.downPx_=t.pixel,!0):(this.lastDragTime_=void 0,!1)},e.prototype.handleUpEvent=function(t){var n=!0;if(this.getPointerCount()===0)if(this.downTimeout_&&(clearTimeout(this.downTimeout_),this.downTimeout_=void 0),this.handlePointerMove_(t),this.shouldHandle_){var i=!this.finishCoordinate_;i&&this.startDrawing_(t.coordinate),!i&&this.freehand_?this.finishDrawing():!this.freehand_&&(!i||this.mode_===xr.POINT)&&(this.atFinish_(t.pixel)?this.finishCondition_(t)&&this.finishDrawing():this.addToDrawing_(t.coordinate)),n=!1}else this.freehand_&&this.abortDrawing();return!n&&this.stopClick_&&t.preventDefault(),n},e.prototype.handlePointerMove_=function(t){if(this.pointerType_=t.originalEvent.pointerType,this.downPx_&&(!this.freehand_&&this.shouldHandle_||this.freehand_&&!this.shouldHandle_)){var n=this.downPx_,i=t.pixel,a=n[0]-i[0],o=n[1]-i[1],s=a*a+o*o;if(this.shouldHandle_=this.freehand_?s>this.squaredClickTolerance_:s<=this.squaredClickTolerance_,!this.shouldHandle_)return}this.finishCoordinate_?this.modifyDrawing_(t.coordinate):this.createOrUpdateSketchPoint_(t.coordinate.slice())},e.prototype.atFinish_=function(t){var n=!1;if(this.sketchFeature_){var i=!1,a=[this.finishCoordinate_],o=this.mode_;if(o===xr.POINT)n=!0;else if(o===xr.CIRCLE)n=this.sketchCoords_.length===2;else if(o===xr.LINE_STRING)i=this.sketchCoords_.length>this.minPoints_;else if(o===xr.POLYGON){var s=this.sketchCoords_;i=s[0].length>this.minPoints_,a=[s[0][0],s[0][s[0].length-2]]}if(i)for(var A=this.getMap(),l=0,u=a.length;l=this.maxPoints_&&(this.freehand_?o.pop():a=!0),o.push(t.slice()),this.geometryFunction_(o,n,i)):s===xr.POLYGON&&(o=this.sketchCoords_[0],o.length>=this.maxPoints_&&(this.freehand_?o.pop():a=!0),o.push(t.slice()),a&&(this.finishCoordinate_=o[0]),this.geometryFunction_(this.sketchCoords_,n,i)),this.createOrUpdateSketchPoint_(t.slice()),this.updateSketchFeatures_(),a&&this.finishDrawing()},e.prototype.removeLastPoint=function(){if(this.sketchFeature_){var t=this.sketchFeature_.getGeometry(),n=this.getMap().getView().getProjection(),i,a=this.mode_;if(a===xr.LINE_STRING||a===xr.CIRCLE){if(i=this.sketchCoords_,i.splice(-2,1),i.length>=2){this.finishCoordinate_=i[i.length-2].slice();var o=this.finishCoordinate_.slice();i[i.length-1]=o,this.createOrUpdateSketchPoint_(o)}this.geometryFunction_(i,t,n),t.getType()===st.POLYGON&&this.sketchLine_&&this.createOrUpdateCustomSketchLine_(t)}else if(a===xr.POLYGON){i=this.sketchCoords_[0],i.splice(-2,1);var s=this.sketchLine_.getGeometry();if(i.length>=2){var o=i[i.length-2].slice();i[i.length-1]=o,this.createOrUpdateSketchPoint_(o)}s.setCoordinates(i),this.geometryFunction_(this.sketchCoords_,t,n)}i.length===1&&this.abortDrawing(),this.updateSketchFeatures_()}},e.prototype.finishDrawing=function(){var t=this.abortDrawing_();if(t){var n=this.sketchCoords_,i=t.getGeometry(),a=this.getMap().getView().getProjection();this.mode_===xr.LINE_STRING?(n.pop(),this.geometryFunction_(n,i,a)):this.mode_===xr.POLYGON&&(n[0].pop(),this.geometryFunction_(n,i,a),n=i.getCoordinates()),this.type_===st.MULTI_POINT?t.setGeometry(new es([n])):this.type_===st.MULTI_LINE_STRING?t.setGeometry(new xa([n])):this.type_===st.MULTI_POLYGON&&t.setGeometry(new ba([n])),this.dispatchEvent(new Lm(Fm.DRAWEND,t)),this.features_&&this.features_.push(t),this.source_&&this.source_.addFeature(t)}},e.prototype.abortDrawing_=function(){this.finishCoordinate_=null;var t=this.sketchFeature_;return this.sketchFeature_=null,this.sketchPoint_=null,this.sketchLine_=null,this.overlay_.getSource().clear(!0),t},e.prototype.abortDrawing=function(){var t=this.abortDrawing_();t&&this.dispatchEvent(new Lm(Fm.DRAWABORT,t))},e.prototype.appendCoordinates=function(t){var n=this.mode_,i=!this.sketchFeature_;i&&this.startDrawing_(t[0]);var a;if(n===xr.LINE_STRING||n===xr.CIRCLE)a=this.sketchCoords_;else if(n===xr.POLYGON)a=this.sketchCoords_&&this.sketchCoords_.length?this.sketchCoords_[0]:[];else return;i&&a.shift(),a.pop();for(var o=0;o0;)this.pop()},e.prototype.extend=function(t){for(var n=0,i=t.length;nthis.moveTolerance_||Math.abs(t.clientY-this.down_.clientY)>this.moveTolerance_},e.prototype.disposeInternal=function(){this.relayedListenerKey_&&(Rr(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(ye.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(Rr(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(Rr),this.dragListenerKeys_.length=0,this.element_=null,r.prototype.disposeInternal.call(this)},e}(Th),RX=OX,zs={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},ti={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},C_=1/0,MX=function(){function r(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}return r.prototype.clear=function(){this.elements_.length=0,this.priorities_.length=0,Bh(this.queuedElements_)},r.prototype.dequeue=function(){var e=this.elements_,t=this.priorities_,n=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));var i=this.keyFunction_(n);return delete this.queuedElements_[i],n},r.prototype.enqueue=function(e){_e(!(this.keyFunction_(e)in this.queuedElements_),31);var t=this.priorityFunction_(e);return t!=C_?(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1},r.prototype.getCount=function(){return this.elements_.length},r.prototype.getLeftChildIndex_=function(e){return e*2+1},r.prototype.getRightChildIndex_=function(e){return e*2+2},r.prototype.getParentIndex_=function(e){return e-1>>1},r.prototype.heapify_=function(){var e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)},r.prototype.isEmpty=function(){return this.elements_.length===0},r.prototype.isKeyQueued=function(e){return e in this.queuedElements_},r.prototype.isQueued=function(e){return this.isKeyQueued(this.keyFunction_(e))},r.prototype.siftUp_=function(e){for(var t=this.elements_,n=this.priorities_,i=t.length,a=t[e],o=n[e],s=e;e>1;){var A=this.getLeftChildIndex_(e),l=this.getRightChildIndex_(e),u=le;){var s=this.getParentIndex_(t);if(i[s]>o)n[t]=n[s],i[t]=i[s],t=s;else break}n[t]=a,i[t]=o},r.prototype.reprioritize=function(){var e=this.priorityFunction_,t=this.elements_,n=this.priorities_,i=0,a=t.length,o,s,A;for(s=0;s0;)o=this.dequeue()[0],s=o.getKey(),a=o.getState(),a===ge.IDLE&&!(s in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[s]=!0,++this.tilesLoading_,++i,o.load())},e}(NX),DX=UX;function QX(r,e,t,n,i){if(!r||!(t in r.wantedTiles)||!r.wantedTiles[t][e.getKey()])return C_;var a=r.viewState.center,o=n[0]-a[0],s=n[1]-a[1];return 65536*Math.log(i)+Math.sqrt(o*o+s*s)/i}var st={POINT:"Point",LINE_STRING:"LineString",LINEAR_RING:"LinearRing",POLYGON:"Polygon",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon",GEOMETRY_COLLECTION:"GeometryCollection",CIRCLE:"Circle"},jp={RADIANS:"radians",DEGREES:"degrees",FEET:"ft",METERS:"m",PIXELS:"pixels",TILE_PIXELS:"tile-pixels",USFEET:"us-ft"},Is={};Is[jp.RADIANS]=6370997/(2*Math.PI);Is[jp.DEGREES]=2*Math.PI*6370997/360;Is[jp.FEET]=.3048;Is[jp.METERS]=1;Is[jp.USFEET]=1200/3937;var Ha=jp,gn={ANIMATING:0,INTERACTING:1},So={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"},HX=42,kI=256,GX=function(){function r(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}return r.prototype.canWrapX=function(){return this.canWrapX_},r.prototype.getCode=function(){return this.code_},r.prototype.getExtent=function(){return this.extent_},r.prototype.getUnits=function(){return this.units_},r.prototype.getMetersPerUnit=function(){return this.metersPerUnit_||Is[this.units_]},r.prototype.getWorldExtent=function(){return this.worldExtent_},r.prototype.getAxisOrientation=function(){return this.axisOrientation_},r.prototype.isGlobal=function(){return this.global_},r.prototype.setGlobal=function(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)},r.prototype.getDefaultTileGrid=function(){return this.defaultTileGrid_},r.prototype.setDefaultTileGrid=function(e){this.defaultTileGrid_=e},r.prototype.setExtent=function(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)},r.prototype.setWorldExtent=function(e){this.worldExtent_=e},r.prototype.setGetPointResolution=function(e){this.getPointResolutionFunc_=e},r.prototype.getPointResolutionFunc=function(){return this.getPointResolutionFunc_},r}(),_l=GX,kX=globalThis&&globalThis.__extends||function(){var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a])},r(e,t)};return function(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");r(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}}(),qg=6378137,Vf=Math.PI*qg,$X=[-Vf,-Vf,Vf,Vf],VX=[-180,-85,180,85],Cm=qg*Math.log(Math.tan(Math.PI/2)),cf=function(r){kX(e,r);function e(t){return r.call(this,{code:t,units:Ha.METERS,extent:$X,global:!0,worldExtent:VX,getPointResolution:function(n,i){return n/kY(i[1]/qg)}})||this}return e}(_l),iM=[new cf("EPSG:3857"),new cf("EPSG:102100"),new cf("EPSG:102113"),new cf("EPSG:900913"),new cf("http://www.opengis.net/def/crs/EPSG/0/3857"),new cf("http://www.opengis.net/gml/srs/epsg.xml#3857")];function jX(r,e,t){var n=r.length,i=t>1?t:2,a=e;a===void 0&&(i>2?a=r.slice():a=new Array(n));for(var o=0;oB&&(l=(u+c)/2,nF(r,e,t,n,l,p)&&(E=l,B=L)),u=c}return isNaN(E)&&(E=i[a]),o?(o.push(E,p,B),o):[E,p,B]}function dQ(r,e,t,n,i){for(var a=[],o=0,s=t.length;o=i[0]&&a[2]<=i[2]||a[1]>=i[1]&&a[3]<=i[3]?!0:vQ(r,e,t,n,function(o,s){return H6(i,o,s)}):!1}function RW(r,e,t,n,i){for(var a=0,o=t.length;a1&&typeof arguments[n-1]=="function"&&(i=arguments[n-1],--n);for(var a=0;a